@squeed/flow-sdk 1.1.16 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,358 +1,182 @@
1
- "use strict";var Iq=Object.create;var J1=Object.defineProperty;var Dq=Object.getOwnPropertyDescriptor;var Bq=Object.getOwnPropertyNames;var Mq=Object.getPrototypeOf,Lq=Object.prototype.hasOwnProperty;var Oq=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Bq(e))!Lq.call(r,a)&&a!==t&&J1(r,a,{get:()=>e[a],enumerable:!(n=Dq(e,a))||n.enumerable});return r};var Ar=(r,e,t)=>(t=r!=null?Iq(Mq(r)):{},Oq(e||!r||!r.__esModule?J1(t,"default",{value:r,enumerable:!0}):t,r));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("react/jsx-runtime"),Re=require("@chakra-ui/react"),xe=require("react"),rr=require("react-icons/pi");var St=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function gl(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ko={exports:{}};/**
2
- * @license
3
- * Lodash <https://lodash.com/>
4
- * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
5
- * Released under MIT license <https://lodash.com/license>
6
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
7
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
8
- */var kq=Ko.exports,ew;function qq(){return ew||(ew=1,(function(r,e){(function(){var t,n="4.17.23",a=200,i="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",o="Expected a function",s="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",l=500,f="__lodash_placeholder__",d=1,h=2,g=4,p=1,x=2,b=1,w=2,y=4,E=8,C=16,S=32,R=64,_=128,A=256,P=512,I=30,D="...",L=800,M=16,q=1,N=2,W=3,V=1/0,$=9007199254740991,Z=17976931348623157e292,ee=NaN,K=4294967295,j=K-1,fe=K>>>1,G=[["ary",_],["bind",b],["bindKey",w],["curry",E],["curryRight",C],["flip",P],["partial",S],["partialRight",R],["rearg",A]],z="[object Arguments]",Y="[object Array]",te="[object AsyncFunction]",ue="[object Boolean]",oe="[object Date]",X="[object DOMException]",Q="[object Error]",ie="[object Function]",de="[object GeneratorFunction]",we="[object Map]",Ae="[object Number]",ve="[object Null]",le="[object Object]",Me="[object Promise]",Se="[object Proxy]",Ee="[object RegExp]",re="[object Set]",ce="[object String]",_e="[object Symbol]",me="[object Undefined]",Te="[object WeakMap]",De="[object WeakSet]",Ne="[object ArrayBuffer]",ze="[object DataView]",$e="[object Float32Array]",ke="[object Float64Array]",Oe="[object Int8Array]",ye="[object Int16Array]",O="[object Int32Array]",ne="[object Uint8Array]",he="[object Uint8ClampedArray]",ge="[object Uint16Array]",be="[object Uint32Array]",Ve=/\b__p \+= '';/g,Be=/\b(__p \+=) '' \+/g,He=/(__e\(.*?\)|\b__t\)) \+\n'';/g,We=/&(?:amp|lt|gt|quot|#39);/g,Ze=/[&<>"']/g,sr=RegExp(We.source),ar=RegExp(Ze.source),Ke=/<%-([\s\S]+?)%>/g,lr=/<%([\s\S]+?)%>/g,ir=/<%=([\s\S]+?)%>/g,Ur=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Mr=/^\w*$/,ct=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Lr=/[\\^$.*+?()[\]{}|]/g,jr=RegExp(Lr.source),Nr=/^\s+/,Qr=/\s/,Pn=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Vr=/\{\n\/\* \[wrapped with (.+)\] \*/,pn=/,? & /,yn=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ua=/[()=,{}\[\]\/\s]/,Ci=/\\(\\)?/g,Gn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,dt=/\w*$/,ot=/^[-+]0x[0-9a-f]+$/i,Et=/^0b[01]+$/i,Ga=/^\[object .+?Constructor\]$/,kt=/^0o[0-7]+$/i,qs=/^(?:0|[1-9]\d*)$/,rf=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,_i=/($^)/,tf=/['\n\r\u2028\u2029\\]/g,Si="\\ud800-\\udfff",nf="\\u0300-\\u036f",af="\\ufe20-\\ufe2f",of="\\u20d0-\\u20ff",la=nf+af+of,Ti="\\u2700-\\u27bf",Wa="a-z\\xdf-\\xf6\\xf8-\\xff",Ns="\\xac\\xb1\\xd7\\xf7",Fs="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",sf="\\u2000-\\u206f",Ut=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ri="A-Z\\xc0-\\xd6\\xd8-\\xde",_o="\\ufe0e\\ufe0f",fa=Ns+Fs+sf+Ut,Pt="['’]",uf="["+Si+"]",lf="["+fa+"]",Ai="["+la+"]",O0="\\d+",DI="["+Ti+"]",k0="["+Wa+"]",q0="[^"+Si+fa+O0+Ti+Wa+Ri+"]",ff="\\ud83c[\\udffb-\\udfff]",BI="(?:"+Ai+"|"+ff+")",N0="[^"+Si+"]",cf="(?:\\ud83c[\\udde6-\\uddff]){2}",df="[\\ud800-\\udbff][\\udc00-\\udfff]",Pi="["+Ri+"]",F0="\\u200d",z0="(?:"+k0+"|"+q0+")",MI="(?:"+Pi+"|"+q0+")",$0="(?:"+Pt+"(?:d|ll|m|re|s|t|ve))?",V0="(?:"+Pt+"(?:D|LL|M|RE|S|T|VE))?",G0=BI+"?",W0="["+_o+"]?",LI="(?:"+F0+"(?:"+[N0,cf,df].join("|")+")"+W0+G0+")*",OI="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",kI="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",U0=W0+G0+LI,qI="(?:"+[DI,cf,df].join("|")+")"+U0,NI="(?:"+[N0+Ai+"?",Ai,cf,df,uf].join("|")+")",FI=RegExp(Pt,"g"),zI=RegExp(Ai,"g"),vf=RegExp(ff+"(?="+ff+")|"+NI+U0,"g"),$I=RegExp([Pi+"?"+k0+"+"+$0+"(?="+[lf,Pi,"$"].join("|")+")",MI+"+"+V0+"(?="+[lf,Pi+z0,"$"].join("|")+")",Pi+"?"+z0+"+"+$0,Pi+"+"+V0,kI,OI,O0,qI].join("|"),"g"),VI=RegExp("["+F0+Si+la+_o+"]"),GI=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,WI=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],UI=-1,Dr={};Dr[$e]=Dr[ke]=Dr[Oe]=Dr[ye]=Dr[O]=Dr[ne]=Dr[he]=Dr[ge]=Dr[be]=!0,Dr[z]=Dr[Y]=Dr[Ne]=Dr[ue]=Dr[ze]=Dr[oe]=Dr[Q]=Dr[ie]=Dr[we]=Dr[Ae]=Dr[le]=Dr[Ee]=Dr[re]=Dr[ce]=Dr[Te]=!1;var Rr={};Rr[z]=Rr[Y]=Rr[Ne]=Rr[ze]=Rr[ue]=Rr[oe]=Rr[$e]=Rr[ke]=Rr[Oe]=Rr[ye]=Rr[O]=Rr[we]=Rr[Ae]=Rr[le]=Rr[Ee]=Rr[re]=Rr[ce]=Rr[_e]=Rr[ne]=Rr[he]=Rr[ge]=Rr[be]=!0,Rr[Q]=Rr[ie]=Rr[Te]=!1;var HI={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},KI={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},jI={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},YI={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ZI=parseFloat,XI=parseInt,H0=typeof St=="object"&&St&&St.Object===Object&&St,QI=typeof self=="object"&&self&&self.Object===Object&&self,vt=H0||QI||Function("return this")(),hf=e&&!e.nodeType&&e,Ua=hf&&!0&&r&&!r.nodeType&&r,K0=Ua&&Ua.exports===hf,gf=K0&&H0.process,tn=(function(){try{var ae=Ua&&Ua.require&&Ua.require("util").types;return ae||gf&&gf.binding&&gf.binding("util")}catch{}})(),j0=tn&&tn.isArrayBuffer,Y0=tn&&tn.isDate,Z0=tn&&tn.isMap,X0=tn&&tn.isRegExp,Q0=tn&&tn.isSet,J0=tn&&tn.isTypedArray;function Ht(ae,Ce,pe){switch(pe.length){case 0:return ae.call(Ce);case 1:return ae.call(Ce,pe[0]);case 2:return ae.call(Ce,pe[0],pe[1]);case 3:return ae.call(Ce,pe[0],pe[1],pe[2])}return ae.apply(Ce,pe)}function JI(ae,Ce,pe,Ge){for(var tr=-1,br=ae==null?0:ae.length;++tr<br;){var Jr=ae[tr];Ce(Ge,Jr,pe(Jr),ae)}return Ge}function nn(ae,Ce){for(var pe=-1,Ge=ae==null?0:ae.length;++pe<Ge&&Ce(ae[pe],pe,ae)!==!1;);return ae}function eD(ae,Ce){for(var pe=ae==null?0:ae.length;pe--&&Ce(ae[pe],pe,ae)!==!1;);return ae}function eb(ae,Ce){for(var pe=-1,Ge=ae==null?0:ae.length;++pe<Ge;)if(!Ce(ae[pe],pe,ae))return!1;return!0}function ca(ae,Ce){for(var pe=-1,Ge=ae==null?0:ae.length,tr=0,br=[];++pe<Ge;){var Jr=ae[pe];Ce(Jr,pe,ae)&&(br[tr++]=Jr)}return br}function zs(ae,Ce){var pe=ae==null?0:ae.length;return!!pe&&Ii(ae,Ce,0)>-1}function pf(ae,Ce,pe){for(var Ge=-1,tr=ae==null?0:ae.length;++Ge<tr;)if(pe(Ce,ae[Ge]))return!0;return!1}function Or(ae,Ce){for(var pe=-1,Ge=ae==null?0:ae.length,tr=Array(Ge);++pe<Ge;)tr[pe]=Ce(ae[pe],pe,ae);return tr}function da(ae,Ce){for(var pe=-1,Ge=Ce.length,tr=ae.length;++pe<Ge;)ae[tr+pe]=Ce[pe];return ae}function yf(ae,Ce,pe,Ge){var tr=-1,br=ae==null?0:ae.length;for(Ge&&br&&(pe=ae[++tr]);++tr<br;)pe=Ce(pe,ae[tr],tr,ae);return pe}function rD(ae,Ce,pe,Ge){var tr=ae==null?0:ae.length;for(Ge&&tr&&(pe=ae[--tr]);tr--;)pe=Ce(pe,ae[tr],tr,ae);return pe}function mf(ae,Ce){for(var pe=-1,Ge=ae==null?0:ae.length;++pe<Ge;)if(Ce(ae[pe],pe,ae))return!0;return!1}var tD=bf("length");function nD(ae){return ae.split("")}function aD(ae){return ae.match(yn)||[]}function rb(ae,Ce,pe){var Ge;return pe(ae,function(tr,br,Jr){if(Ce(tr,br,Jr))return Ge=br,!1}),Ge}function $s(ae,Ce,pe,Ge){for(var tr=ae.length,br=pe+(Ge?1:-1);Ge?br--:++br<tr;)if(Ce(ae[br],br,ae))return br;return-1}function Ii(ae,Ce,pe){return Ce===Ce?pD(ae,Ce,pe):$s(ae,tb,pe)}function iD(ae,Ce,pe,Ge){for(var tr=pe-1,br=ae.length;++tr<br;)if(Ge(ae[tr],Ce))return tr;return-1}function tb(ae){return ae!==ae}function nb(ae,Ce){var pe=ae==null?0:ae.length;return pe?xf(ae,Ce)/pe:ee}function bf(ae){return function(Ce){return Ce==null?t:Ce[ae]}}function wf(ae){return function(Ce){return ae==null?t:ae[Ce]}}function ab(ae,Ce,pe,Ge,tr){return tr(ae,function(br,Jr,Sr){pe=Ge?(Ge=!1,br):Ce(pe,br,Jr,Sr)}),pe}function oD(ae,Ce){var pe=ae.length;for(ae.sort(Ce);pe--;)ae[pe]=ae[pe].value;return ae}function xf(ae,Ce){for(var pe,Ge=-1,tr=ae.length;++Ge<tr;){var br=Ce(ae[Ge]);br!==t&&(pe=pe===t?br:pe+br)}return pe}function Ef(ae,Ce){for(var pe=-1,Ge=Array(ae);++pe<ae;)Ge[pe]=Ce(pe);return Ge}function sD(ae,Ce){return Or(Ce,function(pe){return[pe,ae[pe]]})}function ib(ae){return ae&&ae.slice(0,lb(ae)+1).replace(Nr,"")}function Kt(ae){return function(Ce){return ae(Ce)}}function Cf(ae,Ce){return Or(Ce,function(pe){return ae[pe]})}function So(ae,Ce){return ae.has(Ce)}function ob(ae,Ce){for(var pe=-1,Ge=ae.length;++pe<Ge&&Ii(Ce,ae[pe],0)>-1;);return pe}function sb(ae,Ce){for(var pe=ae.length;pe--&&Ii(Ce,ae[pe],0)>-1;);return pe}function uD(ae,Ce){for(var pe=ae.length,Ge=0;pe--;)ae[pe]===Ce&&++Ge;return Ge}var lD=wf(HI),fD=wf(KI);function cD(ae){return"\\"+YI[ae]}function dD(ae,Ce){return ae==null?t:ae[Ce]}function Di(ae){return VI.test(ae)}function vD(ae){return GI.test(ae)}function hD(ae){for(var Ce,pe=[];!(Ce=ae.next()).done;)pe.push(Ce.value);return pe}function _f(ae){var Ce=-1,pe=Array(ae.size);return ae.forEach(function(Ge,tr){pe[++Ce]=[tr,Ge]}),pe}function ub(ae,Ce){return function(pe){return ae(Ce(pe))}}function va(ae,Ce){for(var pe=-1,Ge=ae.length,tr=0,br=[];++pe<Ge;){var Jr=ae[pe];(Jr===Ce||Jr===f)&&(ae[pe]=f,br[tr++]=pe)}return br}function Vs(ae){var Ce=-1,pe=Array(ae.size);return ae.forEach(function(Ge){pe[++Ce]=Ge}),pe}function gD(ae){var Ce=-1,pe=Array(ae.size);return ae.forEach(function(Ge){pe[++Ce]=[Ge,Ge]}),pe}function pD(ae,Ce,pe){for(var Ge=pe-1,tr=ae.length;++Ge<tr;)if(ae[Ge]===Ce)return Ge;return-1}function yD(ae,Ce,pe){for(var Ge=pe+1;Ge--;)if(ae[Ge]===Ce)return Ge;return Ge}function Bi(ae){return Di(ae)?bD(ae):tD(ae)}function mn(ae){return Di(ae)?wD(ae):nD(ae)}function lb(ae){for(var Ce=ae.length;Ce--&&Qr.test(ae.charAt(Ce)););return Ce}var mD=wf(jI);function bD(ae){for(var Ce=vf.lastIndex=0;vf.test(ae);)++Ce;return Ce}function wD(ae){return ae.match(vf)||[]}function xD(ae){return ae.match($I)||[]}var ED=(function ae(Ce){Ce=Ce==null?vt:Mi.defaults(vt.Object(),Ce,Mi.pick(vt,WI));var pe=Ce.Array,Ge=Ce.Date,tr=Ce.Error,br=Ce.Function,Jr=Ce.Math,Sr=Ce.Object,Sf=Ce.RegExp,CD=Ce.String,an=Ce.TypeError,Gs=pe.prototype,_D=br.prototype,Li=Sr.prototype,Ws=Ce["__core-js_shared__"],Us=_D.toString,wr=Li.hasOwnProperty,SD=0,fb=(function(){var c=/[^.]+$/.exec(Ws&&Ws.keys&&Ws.keys.IE_PROTO||"");return c?"Symbol(src)_1."+c:""})(),Hs=Li.toString,TD=Us.call(Sr),RD=vt._,AD=Sf("^"+Us.call(wr).replace(Lr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ks=K0?Ce.Buffer:t,ha=Ce.Symbol,js=Ce.Uint8Array,cb=Ks?Ks.allocUnsafe:t,Ys=ub(Sr.getPrototypeOf,Sr),db=Sr.create,vb=Li.propertyIsEnumerable,Zs=Gs.splice,hb=ha?ha.isConcatSpreadable:t,To=ha?ha.iterator:t,Ha=ha?ha.toStringTag:t,Xs=(function(){try{var c=Xa(Sr,"defineProperty");return c({},"",{}),c}catch{}})(),PD=Ce.clearTimeout!==vt.clearTimeout&&Ce.clearTimeout,ID=Ge&&Ge.now!==vt.Date.now&&Ge.now,DD=Ce.setTimeout!==vt.setTimeout&&Ce.setTimeout,Qs=Jr.ceil,Js=Jr.floor,Tf=Sr.getOwnPropertySymbols,BD=Ks?Ks.isBuffer:t,gb=Ce.isFinite,MD=Gs.join,LD=ub(Sr.keys,Sr),et=Jr.max,Ct=Jr.min,OD=Ge.now,kD=Ce.parseInt,pb=Jr.random,qD=Gs.reverse,Rf=Xa(Ce,"DataView"),Ro=Xa(Ce,"Map"),Af=Xa(Ce,"Promise"),Oi=Xa(Ce,"Set"),Ao=Xa(Ce,"WeakMap"),Po=Xa(Sr,"create"),eu=Ao&&new Ao,ki={},ND=Qa(Rf),FD=Qa(Ro),zD=Qa(Af),$D=Qa(Oi),VD=Qa(Ao),ru=ha?ha.prototype:t,Io=ru?ru.valueOf:t,yb=ru?ru.toString:t;function k(c){if(Gr(c)&&!nr(c)&&!(c instanceof vr)){if(c instanceof on)return c;if(wr.call(c,"__wrapped__"))return m1(c)}return new on(c)}var qi=(function(){function c(){}return function(v){if(!Fr(v))return{};if(db)return db(v);c.prototype=v;var m=new c;return c.prototype=t,m}})();function tu(){}function on(c,v){this.__wrapped__=c,this.__actions__=[],this.__chain__=!!v,this.__index__=0,this.__values__=t}k.templateSettings={escape:Ke,evaluate:lr,interpolate:ir,variable:"",imports:{_:k}},k.prototype=tu.prototype,k.prototype.constructor=k,on.prototype=qi(tu.prototype),on.prototype.constructor=on;function vr(c){this.__wrapped__=c,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=K,this.__views__=[]}function GD(){var c=new vr(this.__wrapped__);return c.__actions__=qt(this.__actions__),c.__dir__=this.__dir__,c.__filtered__=this.__filtered__,c.__iteratees__=qt(this.__iteratees__),c.__takeCount__=this.__takeCount__,c.__views__=qt(this.__views__),c}function WD(){if(this.__filtered__){var c=new vr(this);c.__dir__=-1,c.__filtered__=!0}else c=this.clone(),c.__dir__*=-1;return c}function UD(){var c=this.__wrapped__.value(),v=this.__dir__,m=nr(c),T=v<0,B=m?c.length:0,F=nM(0,B,this.__views__),U=F.start,J=F.end,se=J-U,Pe=T?J:U-1,Ie=this.__iteratees__,Le=Ie.length,Fe=0,je=Ct(se,this.__takeCount__);if(!m||!T&&B==se&&je==se)return $b(c,this.__actions__);var Je=[];e:for(;se--&&Fe<je;){Pe+=v;for(var ur=-1,er=c[Pe];++ur<Le;){var dr=Ie[ur],hr=dr.iteratee,Zt=dr.type,Bt=hr(er);if(Zt==N)er=Bt;else if(!Bt){if(Zt==q)continue e;break e}}Je[Fe++]=er}return Je}vr.prototype=qi(tu.prototype),vr.prototype.constructor=vr;function Ka(c){var v=-1,m=c==null?0:c.length;for(this.clear();++v<m;){var T=c[v];this.set(T[0],T[1])}}function HD(){this.__data__=Po?Po(null):{},this.size=0}function KD(c){var v=this.has(c)&&delete this.__data__[c];return this.size-=v?1:0,v}function jD(c){var v=this.__data__;if(Po){var m=v[c];return m===u?t:m}return wr.call(v,c)?v[c]:t}function YD(c){var v=this.__data__;return Po?v[c]!==t:wr.call(v,c)}function ZD(c,v){var m=this.__data__;return this.size+=this.has(c)?0:1,m[c]=Po&&v===t?u:v,this}Ka.prototype.clear=HD,Ka.prototype.delete=KD,Ka.prototype.get=jD,Ka.prototype.has=YD,Ka.prototype.set=ZD;function Wn(c){var v=-1,m=c==null?0:c.length;for(this.clear();++v<m;){var T=c[v];this.set(T[0],T[1])}}function XD(){this.__data__=[],this.size=0}function QD(c){var v=this.__data__,m=nu(v,c);if(m<0)return!1;var T=v.length-1;return m==T?v.pop():Zs.call(v,m,1),--this.size,!0}function JD(c){var v=this.__data__,m=nu(v,c);return m<0?t:v[m][1]}function eB(c){return nu(this.__data__,c)>-1}function rB(c,v){var m=this.__data__,T=nu(m,c);return T<0?(++this.size,m.push([c,v])):m[T][1]=v,this}Wn.prototype.clear=XD,Wn.prototype.delete=QD,Wn.prototype.get=JD,Wn.prototype.has=eB,Wn.prototype.set=rB;function Un(c){var v=-1,m=c==null?0:c.length;for(this.clear();++v<m;){var T=c[v];this.set(T[0],T[1])}}function tB(){this.size=0,this.__data__={hash:new Ka,map:new(Ro||Wn),string:new Ka}}function nB(c){var v=gu(this,c).delete(c);return this.size-=v?1:0,v}function aB(c){return gu(this,c).get(c)}function iB(c){return gu(this,c).has(c)}function oB(c,v){var m=gu(this,c),T=m.size;return m.set(c,v),this.size+=m.size==T?0:1,this}Un.prototype.clear=tB,Un.prototype.delete=nB,Un.prototype.get=aB,Un.prototype.has=iB,Un.prototype.set=oB;function ja(c){var v=-1,m=c==null?0:c.length;for(this.__data__=new Un;++v<m;)this.add(c[v])}function sB(c){return this.__data__.set(c,u),this}function uB(c){return this.__data__.has(c)}ja.prototype.add=ja.prototype.push=sB,ja.prototype.has=uB;function bn(c){var v=this.__data__=new Wn(c);this.size=v.size}function lB(){this.__data__=new Wn,this.size=0}function fB(c){var v=this.__data__,m=v.delete(c);return this.size=v.size,m}function cB(c){return this.__data__.get(c)}function dB(c){return this.__data__.has(c)}function vB(c,v){var m=this.__data__;if(m instanceof Wn){var T=m.__data__;if(!Ro||T.length<a-1)return T.push([c,v]),this.size=++m.size,this;m=this.__data__=new Un(T)}return m.set(c,v),this.size=m.size,this}bn.prototype.clear=lB,bn.prototype.delete=fB,bn.prototype.get=cB,bn.prototype.has=dB,bn.prototype.set=vB;function mb(c,v){var m=nr(c),T=!m&&Ja(c),B=!m&&!T&&ba(c),F=!m&&!T&&!B&&$i(c),U=m||T||B||F,J=U?Ef(c.length,CD):[],se=J.length;for(var Pe in c)(v||wr.call(c,Pe))&&!(U&&(Pe=="length"||B&&(Pe=="offset"||Pe=="parent")||F&&(Pe=="buffer"||Pe=="byteLength"||Pe=="byteOffset")||Yn(Pe,se)))&&J.push(Pe);return J}function bb(c){var v=c.length;return v?c[Ff(0,v-1)]:t}function hB(c,v){return pu(qt(c),Ya(v,0,c.length))}function gB(c){return pu(qt(c))}function Pf(c,v,m){(m!==t&&!wn(c[v],m)||m===t&&!(v in c))&&Hn(c,v,m)}function Do(c,v,m){var T=c[v];(!(wr.call(c,v)&&wn(T,m))||m===t&&!(v in c))&&Hn(c,v,m)}function nu(c,v){for(var m=c.length;m--;)if(wn(c[m][0],v))return m;return-1}function pB(c,v,m,T){return ga(c,function(B,F,U){v(T,B,m(B),U)}),T}function wb(c,v){return c&&Dn(v,st(v),c)}function yB(c,v){return c&&Dn(v,Ft(v),c)}function Hn(c,v,m){v=="__proto__"&&Xs?Xs(c,v,{configurable:!0,enumerable:!0,value:m,writable:!0}):c[v]=m}function If(c,v){for(var m=-1,T=v.length,B=pe(T),F=c==null;++m<T;)B[m]=F?t:fc(c,v[m]);return B}function Ya(c,v,m){return c===c&&(m!==t&&(c=c<=m?c:m),v!==t&&(c=c>=v?c:v)),c}function sn(c,v,m,T,B,F){var U,J=v&d,se=v&h,Pe=v&g;if(m&&(U=B?m(c,T,B,F):m(c)),U!==t)return U;if(!Fr(c))return c;var Ie=nr(c);if(Ie){if(U=iM(c),!J)return qt(c,U)}else{var Le=_t(c),Fe=Le==ie||Le==de;if(ba(c))return Wb(c,J);if(Le==le||Le==z||Fe&&!B){if(U=se||Fe?{}:l1(c),!J)return se?jB(c,yB(U,c)):KB(c,wb(U,c))}else{if(!Rr[Le])return B?c:{};U=oM(c,Le,J)}}F||(F=new bn);var je=F.get(c);if(je)return je;F.set(c,U),N1(c)?c.forEach(function(er){U.add(sn(er,v,m,er,c,F))}):k1(c)&&c.forEach(function(er,dr){U.set(dr,sn(er,v,m,dr,c,F))});var Je=Pe?se?Zf:Yf:se?Ft:st,ur=Ie?t:Je(c);return nn(ur||c,function(er,dr){ur&&(dr=er,er=c[dr]),Do(U,dr,sn(er,v,m,dr,c,F))}),U}function mB(c){var v=st(c);return function(m){return xb(m,c,v)}}function xb(c,v,m){var T=m.length;if(c==null)return!T;for(c=Sr(c);T--;){var B=m[T],F=v[B],U=c[B];if(U===t&&!(B in c)||!F(U))return!1}return!0}function Eb(c,v,m){if(typeof c!="function")throw new an(o);return No(function(){c.apply(t,m)},v)}function Bo(c,v,m,T){var B=-1,F=zs,U=!0,J=c.length,se=[],Pe=v.length;if(!J)return se;m&&(v=Or(v,Kt(m))),T?(F=pf,U=!1):v.length>=a&&(F=So,U=!1,v=new ja(v));e:for(;++B<J;){var Ie=c[B],Le=m==null?Ie:m(Ie);if(Ie=T||Ie!==0?Ie:0,U&&Le===Le){for(var Fe=Pe;Fe--;)if(v[Fe]===Le)continue e;se.push(Ie)}else F(v,Le,T)||se.push(Ie)}return se}var ga=Yb(In),Cb=Yb(Bf,!0);function bB(c,v){var m=!0;return ga(c,function(T,B,F){return m=!!v(T,B,F),m}),m}function au(c,v,m){for(var T=-1,B=c.length;++T<B;){var F=c[T],U=v(F);if(U!=null&&(J===t?U===U&&!Yt(U):m(U,J)))var J=U,se=F}return se}function wB(c,v,m,T){var B=c.length;for(m=or(m),m<0&&(m=-m>B?0:B+m),T=T===t||T>B?B:or(T),T<0&&(T+=B),T=m>T?0:z1(T);m<T;)c[m++]=v;return c}function _b(c,v){var m=[];return ga(c,function(T,B,F){v(T,B,F)&&m.push(T)}),m}function ht(c,v,m,T,B){var F=-1,U=c.length;for(m||(m=uM),B||(B=[]);++F<U;){var J=c[F];v>0&&m(J)?v>1?ht(J,v-1,m,T,B):da(B,J):T||(B[B.length]=J)}return B}var Df=Zb(),Sb=Zb(!0);function In(c,v){return c&&Df(c,v,st)}function Bf(c,v){return c&&Sb(c,v,st)}function iu(c,v){return ca(v,function(m){return Zn(c[m])})}function Za(c,v){v=ya(v,c);for(var m=0,T=v.length;c!=null&&m<T;)c=c[Bn(v[m++])];return m&&m==T?c:t}function Tb(c,v,m){var T=v(c);return nr(c)?T:da(T,m(c))}function It(c){return c==null?c===t?me:ve:Ha&&Ha in Sr(c)?tM(c):gM(c)}function Mf(c,v){return c>v}function xB(c,v){return c!=null&&wr.call(c,v)}function EB(c,v){return c!=null&&v in Sr(c)}function CB(c,v,m){return c>=Ct(v,m)&&c<et(v,m)}function Lf(c,v,m){for(var T=m?pf:zs,B=c[0].length,F=c.length,U=F,J=pe(F),se=1/0,Pe=[];U--;){var Ie=c[U];U&&v&&(Ie=Or(Ie,Kt(v))),se=Ct(Ie.length,se),J[U]=!m&&(v||B>=120&&Ie.length>=120)?new ja(U&&Ie):t}Ie=c[0];var Le=-1,Fe=J[0];e:for(;++Le<B&&Pe.length<se;){var je=Ie[Le],Je=v?v(je):je;if(je=m||je!==0?je:0,!(Fe?So(Fe,Je):T(Pe,Je,m))){for(U=F;--U;){var ur=J[U];if(!(ur?So(ur,Je):T(c[U],Je,m)))continue e}Fe&&Fe.push(Je),Pe.push(je)}}return Pe}function _B(c,v,m,T){return In(c,function(B,F,U){v(T,m(B),F,U)}),T}function Mo(c,v,m){v=ya(v,c),c=v1(c,v);var T=c==null?c:c[Bn(ln(v))];return T==null?t:Ht(T,c,m)}function Rb(c){return Gr(c)&&It(c)==z}function SB(c){return Gr(c)&&It(c)==Ne}function TB(c){return Gr(c)&&It(c)==oe}function Lo(c,v,m,T,B){return c===v?!0:c==null||v==null||!Gr(c)&&!Gr(v)?c!==c&&v!==v:RB(c,v,m,T,Lo,B)}function RB(c,v,m,T,B,F){var U=nr(c),J=nr(v),se=U?Y:_t(c),Pe=J?Y:_t(v);se=se==z?le:se,Pe=Pe==z?le:Pe;var Ie=se==le,Le=Pe==le,Fe=se==Pe;if(Fe&&ba(c)){if(!ba(v))return!1;U=!0,Ie=!1}if(Fe&&!Ie)return F||(F=new bn),U||$i(c)?o1(c,v,m,T,B,F):eM(c,v,se,m,T,B,F);if(!(m&p)){var je=Ie&&wr.call(c,"__wrapped__"),Je=Le&&wr.call(v,"__wrapped__");if(je||Je){var ur=je?c.value():c,er=Je?v.value():v;return F||(F=new bn),B(ur,er,m,T,F)}}return Fe?(F||(F=new bn),rM(c,v,m,T,B,F)):!1}function AB(c){return Gr(c)&&_t(c)==we}function Of(c,v,m,T){var B=m.length,F=B,U=!T;if(c==null)return!F;for(c=Sr(c);B--;){var J=m[B];if(U&&J[2]?J[1]!==c[J[0]]:!(J[0]in c))return!1}for(;++B<F;){J=m[B];var se=J[0],Pe=c[se],Ie=J[1];if(U&&J[2]){if(Pe===t&&!(se in c))return!1}else{var Le=new bn;if(T)var Fe=T(Pe,Ie,se,c,v,Le);if(!(Fe===t?Lo(Ie,Pe,p|x,T,Le):Fe))return!1}}return!0}function Ab(c){if(!Fr(c)||fM(c))return!1;var v=Zn(c)?AD:Ga;return v.test(Qa(c))}function PB(c){return Gr(c)&&It(c)==Ee}function IB(c){return Gr(c)&&_t(c)==re}function DB(c){return Gr(c)&&Eu(c.length)&&!!Dr[It(c)]}function Pb(c){return typeof c=="function"?c:c==null?zt:typeof c=="object"?nr(c)?Bb(c[0],c[1]):Db(c):X1(c)}function kf(c){if(!qo(c))return LD(c);var v=[];for(var m in Sr(c))wr.call(c,m)&&m!="constructor"&&v.push(m);return v}function BB(c){if(!Fr(c))return hM(c);var v=qo(c),m=[];for(var T in c)T=="constructor"&&(v||!wr.call(c,T))||m.push(T);return m}function qf(c,v){return c<v}function Ib(c,v){var m=-1,T=Nt(c)?pe(c.length):[];return ga(c,function(B,F,U){T[++m]=v(B,F,U)}),T}function Db(c){var v=Qf(c);return v.length==1&&v[0][2]?c1(v[0][0],v[0][1]):function(m){return m===c||Of(m,c,v)}}function Bb(c,v){return ec(c)&&f1(v)?c1(Bn(c),v):function(m){var T=fc(m,c);return T===t&&T===v?cc(m,c):Lo(v,T,p|x)}}function ou(c,v,m,T,B){c!==v&&Df(v,function(F,U){if(B||(B=new bn),Fr(F))MB(c,v,U,m,ou,T,B);else{var J=T?T(tc(c,U),F,U+"",c,v,B):t;J===t&&(J=F),Pf(c,U,J)}},Ft)}function MB(c,v,m,T,B,F,U){var J=tc(c,m),se=tc(v,m),Pe=U.get(se);if(Pe){Pf(c,m,Pe);return}var Ie=F?F(J,se,m+"",c,v,U):t,Le=Ie===t;if(Le){var Fe=nr(se),je=!Fe&&ba(se),Je=!Fe&&!je&&$i(se);Ie=se,Fe||je||Je?nr(J)?Ie=J:Hr(J)?Ie=qt(J):je?(Le=!1,Ie=Wb(se,!0)):Je?(Le=!1,Ie=Ub(se,!0)):Ie=[]:Fo(se)||Ja(se)?(Ie=J,Ja(J)?Ie=$1(J):(!Fr(J)||Zn(J))&&(Ie=l1(se))):Le=!1}Le&&(U.set(se,Ie),B(Ie,se,T,F,U),U.delete(se)),Pf(c,m,Ie)}function Mb(c,v){var m=c.length;if(m)return v+=v<0?m:0,Yn(v,m)?c[v]:t}function Lb(c,v,m){v.length?v=Or(v,function(F){return nr(F)?function(U){return Za(U,F.length===1?F[0]:F)}:F}):v=[zt];var T=-1;v=Or(v,Kt(Qe()));var B=Ib(c,function(F,U,J){var se=Or(v,function(Pe){return Pe(F)});return{criteria:se,index:++T,value:F}});return oD(B,function(F,U){return HB(F,U,m)})}function LB(c,v){return Ob(c,v,function(m,T){return cc(c,T)})}function Ob(c,v,m){for(var T=-1,B=v.length,F={};++T<B;){var U=v[T],J=Za(c,U);m(J,U)&&Oo(F,ya(U,c),J)}return F}function OB(c){return function(v){return Za(v,c)}}function Nf(c,v,m,T){var B=T?iD:Ii,F=-1,U=v.length,J=c;for(c===v&&(v=qt(v)),m&&(J=Or(c,Kt(m)));++F<U;)for(var se=0,Pe=v[F],Ie=m?m(Pe):Pe;(se=B(J,Ie,se,T))>-1;)J!==c&&Zs.call(J,se,1),Zs.call(c,se,1);return c}function kb(c,v){for(var m=c?v.length:0,T=m-1;m--;){var B=v[m];if(m==T||B!==F){var F=B;Yn(B)?Zs.call(c,B,1):Vf(c,B)}}return c}function Ff(c,v){return c+Js(pb()*(v-c+1))}function kB(c,v,m,T){for(var B=-1,F=et(Qs((v-c)/(m||1)),0),U=pe(F);F--;)U[T?F:++B]=c,c+=m;return U}function zf(c,v){var m="";if(!c||v<1||v>$)return m;do v%2&&(m+=c),v=Js(v/2),v&&(c+=c);while(v);return m}function fr(c,v){return nc(d1(c,v,zt),c+"")}function qB(c){return bb(Vi(c))}function NB(c,v){var m=Vi(c);return pu(m,Ya(v,0,m.length))}function Oo(c,v,m,T){if(!Fr(c))return c;v=ya(v,c);for(var B=-1,F=v.length,U=F-1,J=c;J!=null&&++B<F;){var se=Bn(v[B]),Pe=m;if(se==="__proto__"||se==="constructor"||se==="prototype")return c;if(B!=U){var Ie=J[se];Pe=T?T(Ie,se,J):t,Pe===t&&(Pe=Fr(Ie)?Ie:Yn(v[B+1])?[]:{})}Do(J,se,Pe),J=J[se]}return c}var qb=eu?function(c,v){return eu.set(c,v),c}:zt,FB=Xs?function(c,v){return Xs(c,"toString",{configurable:!0,enumerable:!1,value:vc(v),writable:!0})}:zt;function zB(c){return pu(Vi(c))}function un(c,v,m){var T=-1,B=c.length;v<0&&(v=-v>B?0:B+v),m=m>B?B:m,m<0&&(m+=B),B=v>m?0:m-v>>>0,v>>>=0;for(var F=pe(B);++T<B;)F[T]=c[T+v];return F}function $B(c,v){var m;return ga(c,function(T,B,F){return m=v(T,B,F),!m}),!!m}function su(c,v,m){var T=0,B=c==null?T:c.length;if(typeof v=="number"&&v===v&&B<=fe){for(;T<B;){var F=T+B>>>1,U=c[F];U!==null&&!Yt(U)&&(m?U<=v:U<v)?T=F+1:B=F}return B}return $f(c,v,zt,m)}function $f(c,v,m,T){var B=0,F=c==null?0:c.length;if(F===0)return 0;v=m(v);for(var U=v!==v,J=v===null,se=Yt(v),Pe=v===t;B<F;){var Ie=Js((B+F)/2),Le=m(c[Ie]),Fe=Le!==t,je=Le===null,Je=Le===Le,ur=Yt(Le);if(U)var er=T||Je;else Pe?er=Je&&(T||Fe):J?er=Je&&Fe&&(T||!je):se?er=Je&&Fe&&!je&&(T||!ur):je||ur?er=!1:er=T?Le<=v:Le<v;er?B=Ie+1:F=Ie}return Ct(F,j)}function Nb(c,v){for(var m=-1,T=c.length,B=0,F=[];++m<T;){var U=c[m],J=v?v(U):U;if(!m||!wn(J,se)){var se=J;F[B++]=U===0?0:U}}return F}function Fb(c){return typeof c=="number"?c:Yt(c)?ee:+c}function jt(c){if(typeof c=="string")return c;if(nr(c))return Or(c,jt)+"";if(Yt(c))return yb?yb.call(c):"";var v=c+"";return v=="0"&&1/c==-V?"-0":v}function pa(c,v,m){var T=-1,B=zs,F=c.length,U=!0,J=[],se=J;if(m)U=!1,B=pf;else if(F>=a){var Pe=v?null:QB(c);if(Pe)return Vs(Pe);U=!1,B=So,se=new ja}else se=v?[]:J;e:for(;++T<F;){var Ie=c[T],Le=v?v(Ie):Ie;if(Ie=m||Ie!==0?Ie:0,U&&Le===Le){for(var Fe=se.length;Fe--;)if(se[Fe]===Le)continue e;v&&se.push(Le),J.push(Ie)}else B(se,Le,m)||(se!==J&&se.push(Le),J.push(Ie))}return J}function Vf(c,v){v=ya(v,c);var m=-1,T=v.length;if(!T)return!0;for(var B=c==null||typeof c!="object"&&typeof c!="function";++m<T;){var F=v[m];if(typeof F=="string"){if(F==="__proto__"&&!wr.call(c,"__proto__"))return!1;if(F==="constructor"&&m+1<T&&typeof v[m+1]=="string"&&v[m+1]==="prototype"){if(B&&m===0)continue;return!1}}}var U=v1(c,v);return U==null||delete U[Bn(ln(v))]}function zb(c,v,m,T){return Oo(c,v,m(Za(c,v)),T)}function uu(c,v,m,T){for(var B=c.length,F=T?B:-1;(T?F--:++F<B)&&v(c[F],F,c););return m?un(c,T?0:F,T?F+1:B):un(c,T?F+1:0,T?B:F)}function $b(c,v){var m=c;return m instanceof vr&&(m=m.value()),yf(v,function(T,B){return B.func.apply(B.thisArg,da([T],B.args))},m)}function Gf(c,v,m){var T=c.length;if(T<2)return T?pa(c[0]):[];for(var B=-1,F=pe(T);++B<T;)for(var U=c[B],J=-1;++J<T;)J!=B&&(F[B]=Bo(F[B]||U,c[J],v,m));return pa(ht(F,1),v,m)}function Vb(c,v,m){for(var T=-1,B=c.length,F=v.length,U={};++T<B;){var J=T<F?v[T]:t;m(U,c[T],J)}return U}function Wf(c){return Hr(c)?c:[]}function Uf(c){return typeof c=="function"?c:zt}function ya(c,v){return nr(c)?c:ec(c,v)?[c]:y1(xr(c))}var VB=fr;function ma(c,v,m){var T=c.length;return m=m===t?T:m,!v&&m>=T?c:un(c,v,m)}var Gb=PD||function(c){return vt.clearTimeout(c)};function Wb(c,v){if(v)return c.slice();var m=c.length,T=cb?cb(m):new c.constructor(m);return c.copy(T),T}function Hf(c){var v=new c.constructor(c.byteLength);return new js(v).set(new js(c)),v}function GB(c,v){var m=v?Hf(c.buffer):c.buffer;return new c.constructor(m,c.byteOffset,c.byteLength)}function WB(c){var v=new c.constructor(c.source,dt.exec(c));return v.lastIndex=c.lastIndex,v}function UB(c){return Io?Sr(Io.call(c)):{}}function Ub(c,v){var m=v?Hf(c.buffer):c.buffer;return new c.constructor(m,c.byteOffset,c.length)}function Hb(c,v){if(c!==v){var m=c!==t,T=c===null,B=c===c,F=Yt(c),U=v!==t,J=v===null,se=v===v,Pe=Yt(v);if(!J&&!Pe&&!F&&c>v||F&&U&&se&&!J&&!Pe||T&&U&&se||!m&&se||!B)return 1;if(!T&&!F&&!Pe&&c<v||Pe&&m&&B&&!T&&!F||J&&m&&B||!U&&B||!se)return-1}return 0}function HB(c,v,m){for(var T=-1,B=c.criteria,F=v.criteria,U=B.length,J=m.length;++T<U;){var se=Hb(B[T],F[T]);if(se){if(T>=J)return se;var Pe=m[T];return se*(Pe=="desc"?-1:1)}}return c.index-v.index}function Kb(c,v,m,T){for(var B=-1,F=c.length,U=m.length,J=-1,se=v.length,Pe=et(F-U,0),Ie=pe(se+Pe),Le=!T;++J<se;)Ie[J]=v[J];for(;++B<U;)(Le||B<F)&&(Ie[m[B]]=c[B]);for(;Pe--;)Ie[J++]=c[B++];return Ie}function jb(c,v,m,T){for(var B=-1,F=c.length,U=-1,J=m.length,se=-1,Pe=v.length,Ie=et(F-J,0),Le=pe(Ie+Pe),Fe=!T;++B<Ie;)Le[B]=c[B];for(var je=B;++se<Pe;)Le[je+se]=v[se];for(;++U<J;)(Fe||B<F)&&(Le[je+m[U]]=c[B++]);return Le}function qt(c,v){var m=-1,T=c.length;for(v||(v=pe(T));++m<T;)v[m]=c[m];return v}function Dn(c,v,m,T){var B=!m;m||(m={});for(var F=-1,U=v.length;++F<U;){var J=v[F],se=T?T(m[J],c[J],J,m,c):t;se===t&&(se=c[J]),B?Hn(m,J,se):Do(m,J,se)}return m}function KB(c,v){return Dn(c,Jf(c),v)}function jB(c,v){return Dn(c,s1(c),v)}function lu(c,v){return function(m,T){var B=nr(m)?JI:pB,F=v?v():{};return B(m,c,Qe(T,2),F)}}function Ni(c){return fr(function(v,m){var T=-1,B=m.length,F=B>1?m[B-1]:t,U=B>2?m[2]:t;for(F=c.length>3&&typeof F=="function"?(B--,F):t,U&&Dt(m[0],m[1],U)&&(F=B<3?t:F,B=1),v=Sr(v);++T<B;){var J=m[T];J&&c(v,J,T,F)}return v})}function Yb(c,v){return function(m,T){if(m==null)return m;if(!Nt(m))return c(m,T);for(var B=m.length,F=v?B:-1,U=Sr(m);(v?F--:++F<B)&&T(U[F],F,U)!==!1;);return m}}function Zb(c){return function(v,m,T){for(var B=-1,F=Sr(v),U=T(v),J=U.length;J--;){var se=U[c?J:++B];if(m(F[se],se,F)===!1)break}return v}}function YB(c,v,m){var T=v&b,B=ko(c);function F(){var U=this&&this!==vt&&this instanceof F?B:c;return U.apply(T?m:this,arguments)}return F}function Xb(c){return function(v){v=xr(v);var m=Di(v)?mn(v):t,T=m?m[0]:v.charAt(0),B=m?ma(m,1).join(""):v.slice(1);return T[c]()+B}}function Fi(c){return function(v){return yf(Y1(j1(v).replace(FI,"")),c,"")}}function ko(c){return function(){var v=arguments;switch(v.length){case 0:return new c;case 1:return new c(v[0]);case 2:return new c(v[0],v[1]);case 3:return new c(v[0],v[1],v[2]);case 4:return new c(v[0],v[1],v[2],v[3]);case 5:return new c(v[0],v[1],v[2],v[3],v[4]);case 6:return new c(v[0],v[1],v[2],v[3],v[4],v[5]);case 7:return new c(v[0],v[1],v[2],v[3],v[4],v[5],v[6])}var m=qi(c.prototype),T=c.apply(m,v);return Fr(T)?T:m}}function ZB(c,v,m){var T=ko(c);function B(){for(var F=arguments.length,U=pe(F),J=F,se=zi(B);J--;)U[J]=arguments[J];var Pe=F<3&&U[0]!==se&&U[F-1]!==se?[]:va(U,se);if(F-=Pe.length,F<m)return t1(c,v,fu,B.placeholder,t,U,Pe,t,t,m-F);var Ie=this&&this!==vt&&this instanceof B?T:c;return Ht(Ie,this,U)}return B}function Qb(c){return function(v,m,T){var B=Sr(v);if(!Nt(v)){var F=Qe(m,3);v=st(v),m=function(J){return F(B[J],J,B)}}var U=c(v,m,T);return U>-1?B[F?v[U]:U]:t}}function Jb(c){return jn(function(v){var m=v.length,T=m,B=on.prototype.thru;for(c&&v.reverse();T--;){var F=v[T];if(typeof F!="function")throw new an(o);if(B&&!U&&hu(F)=="wrapper")var U=new on([],!0)}for(T=U?T:m;++T<m;){F=v[T];var J=hu(F),se=J=="wrapper"?Xf(F):t;se&&rc(se[0])&&se[1]==(_|E|S|A)&&!se[4].length&&se[9]==1?U=U[hu(se[0])].apply(U,se[3]):U=F.length==1&&rc(F)?U[J]():U.thru(F)}return function(){var Pe=arguments,Ie=Pe[0];if(U&&Pe.length==1&&nr(Ie))return U.plant(Ie).value();for(var Le=0,Fe=m?v[Le].apply(this,Pe):Ie;++Le<m;)Fe=v[Le].call(this,Fe);return Fe}})}function fu(c,v,m,T,B,F,U,J,se,Pe){var Ie=v&_,Le=v&b,Fe=v&w,je=v&(E|C),Je=v&P,ur=Fe?t:ko(c);function er(){for(var dr=arguments.length,hr=pe(dr),Zt=dr;Zt--;)hr[Zt]=arguments[Zt];if(je)var Bt=zi(er),Xt=uD(hr,Bt);if(T&&(hr=Kb(hr,T,B,je)),F&&(hr=jb(hr,F,U,je)),dr-=Xt,je&&dr<Pe){var Kr=va(hr,Bt);return t1(c,v,fu,er.placeholder,m,hr,Kr,J,se,Pe-dr)}var xn=Le?m:this,Qn=Fe?xn[c]:c;return dr=hr.length,J?hr=pM(hr,J):Je&&dr>1&&hr.reverse(),Ie&&se<dr&&(hr.length=se),this&&this!==vt&&this instanceof er&&(Qn=ur||ko(Qn)),Qn.apply(xn,hr)}return er}function e1(c,v){return function(m,T){return _B(m,c,v(T),{})}}function cu(c,v){return function(m,T){var B;if(m===t&&T===t)return v;if(m!==t&&(B=m),T!==t){if(B===t)return T;typeof m=="string"||typeof T=="string"?(m=jt(m),T=jt(T)):(m=Fb(m),T=Fb(T)),B=c(m,T)}return B}}function Kf(c){return jn(function(v){return v=Or(v,Kt(Qe())),fr(function(m){var T=this;return c(v,function(B){return Ht(B,T,m)})})})}function du(c,v){v=v===t?" ":jt(v);var m=v.length;if(m<2)return m?zf(v,c):v;var T=zf(v,Qs(c/Bi(v)));return Di(v)?ma(mn(T),0,c).join(""):T.slice(0,c)}function XB(c,v,m,T){var B=v&b,F=ko(c);function U(){for(var J=-1,se=arguments.length,Pe=-1,Ie=T.length,Le=pe(Ie+se),Fe=this&&this!==vt&&this instanceof U?F:c;++Pe<Ie;)Le[Pe]=T[Pe];for(;se--;)Le[Pe++]=arguments[++J];return Ht(Fe,B?m:this,Le)}return U}function r1(c){return function(v,m,T){return T&&typeof T!="number"&&Dt(v,m,T)&&(m=T=t),v=Xn(v),m===t?(m=v,v=0):m=Xn(m),T=T===t?v<m?1:-1:Xn(T),kB(v,m,T,c)}}function vu(c){return function(v,m){return typeof v=="string"&&typeof m=="string"||(v=fn(v),m=fn(m)),c(v,m)}}function t1(c,v,m,T,B,F,U,J,se,Pe){var Ie=v&E,Le=Ie?U:t,Fe=Ie?t:U,je=Ie?F:t,Je=Ie?t:F;v|=Ie?S:R,v&=~(Ie?R:S),v&y||(v&=-4);var ur=[c,v,B,je,Le,Je,Fe,J,se,Pe],er=m.apply(t,ur);return rc(c)&&h1(er,ur),er.placeholder=T,g1(er,c,v)}function jf(c){var v=Jr[c];return function(m,T){if(m=fn(m),T=T==null?0:Ct(or(T),292),T&&gb(m)){var B=(xr(m)+"e").split("e"),F=v(B[0]+"e"+(+B[1]+T));return B=(xr(F)+"e").split("e"),+(B[0]+"e"+(+B[1]-T))}return v(m)}}var QB=Oi&&1/Vs(new Oi([,-0]))[1]==V?function(c){return new Oi(c)}:pc;function n1(c){return function(v){var m=_t(v);return m==we?_f(v):m==re?gD(v):sD(v,c(v))}}function Kn(c,v,m,T,B,F,U,J){var se=v&w;if(!se&&typeof c!="function")throw new an(o);var Pe=T?T.length:0;if(Pe||(v&=-97,T=B=t),U=U===t?U:et(or(U),0),J=J===t?J:or(J),Pe-=B?B.length:0,v&R){var Ie=T,Le=B;T=B=t}var Fe=se?t:Xf(c),je=[c,v,m,T,B,Ie,Le,F,U,J];if(Fe&&vM(je,Fe),c=je[0],v=je[1],m=je[2],T=je[3],B=je[4],J=je[9]=je[9]===t?se?0:c.length:et(je[9]-Pe,0),!J&&v&(E|C)&&(v&=-25),!v||v==b)var Je=YB(c,v,m);else v==E||v==C?Je=ZB(c,v,J):(v==S||v==(b|S))&&!B.length?Je=XB(c,v,m,T):Je=fu.apply(t,je);var ur=Fe?qb:h1;return g1(ur(Je,je),c,v)}function a1(c,v,m,T){return c===t||wn(c,Li[m])&&!wr.call(T,m)?v:c}function i1(c,v,m,T,B,F){return Fr(c)&&Fr(v)&&(F.set(v,c),ou(c,v,t,i1,F),F.delete(v)),c}function JB(c){return Fo(c)?t:c}function o1(c,v,m,T,B,F){var U=m&p,J=c.length,se=v.length;if(J!=se&&!(U&&se>J))return!1;var Pe=F.get(c),Ie=F.get(v);if(Pe&&Ie)return Pe==v&&Ie==c;var Le=-1,Fe=!0,je=m&x?new ja:t;for(F.set(c,v),F.set(v,c);++Le<J;){var Je=c[Le],ur=v[Le];if(T)var er=U?T(ur,Je,Le,v,c,F):T(Je,ur,Le,c,v,F);if(er!==t){if(er)continue;Fe=!1;break}if(je){if(!mf(v,function(dr,hr){if(!So(je,hr)&&(Je===dr||B(Je,dr,m,T,F)))return je.push(hr)})){Fe=!1;break}}else if(!(Je===ur||B(Je,ur,m,T,F))){Fe=!1;break}}return F.delete(c),F.delete(v),Fe}function eM(c,v,m,T,B,F,U){switch(m){case ze:if(c.byteLength!=v.byteLength||c.byteOffset!=v.byteOffset)return!1;c=c.buffer,v=v.buffer;case Ne:return!(c.byteLength!=v.byteLength||!F(new js(c),new js(v)));case ue:case oe:case Ae:return wn(+c,+v);case Q:return c.name==v.name&&c.message==v.message;case Ee:case ce:return c==v+"";case we:var J=_f;case re:var se=T&p;if(J||(J=Vs),c.size!=v.size&&!se)return!1;var Pe=U.get(c);if(Pe)return Pe==v;T|=x,U.set(c,v);var Ie=o1(J(c),J(v),T,B,F,U);return U.delete(c),Ie;case _e:if(Io)return Io.call(c)==Io.call(v)}return!1}function rM(c,v,m,T,B,F){var U=m&p,J=Yf(c),se=J.length,Pe=Yf(v),Ie=Pe.length;if(se!=Ie&&!U)return!1;for(var Le=se;Le--;){var Fe=J[Le];if(!(U?Fe in v:wr.call(v,Fe)))return!1}var je=F.get(c),Je=F.get(v);if(je&&Je)return je==v&&Je==c;var ur=!0;F.set(c,v),F.set(v,c);for(var er=U;++Le<se;){Fe=J[Le];var dr=c[Fe],hr=v[Fe];if(T)var Zt=U?T(hr,dr,Fe,v,c,F):T(dr,hr,Fe,c,v,F);if(!(Zt===t?dr===hr||B(dr,hr,m,T,F):Zt)){ur=!1;break}er||(er=Fe=="constructor")}if(ur&&!er){var Bt=c.constructor,Xt=v.constructor;Bt!=Xt&&"constructor"in c&&"constructor"in v&&!(typeof Bt=="function"&&Bt instanceof Bt&&typeof Xt=="function"&&Xt instanceof Xt)&&(ur=!1)}return F.delete(c),F.delete(v),ur}function jn(c){return nc(d1(c,t,x1),c+"")}function Yf(c){return Tb(c,st,Jf)}function Zf(c){return Tb(c,Ft,s1)}var Xf=eu?function(c){return eu.get(c)}:pc;function hu(c){for(var v=c.name+"",m=ki[v],T=wr.call(ki,v)?m.length:0;T--;){var B=m[T],F=B.func;if(F==null||F==c)return B.name}return v}function zi(c){var v=wr.call(k,"placeholder")?k:c;return v.placeholder}function Qe(){var c=k.iteratee||hc;return c=c===hc?Pb:c,arguments.length?c(arguments[0],arguments[1]):c}function gu(c,v){var m=c.__data__;return lM(v)?m[typeof v=="string"?"string":"hash"]:m.map}function Qf(c){for(var v=st(c),m=v.length;m--;){var T=v[m],B=c[T];v[m]=[T,B,f1(B)]}return v}function Xa(c,v){var m=dD(c,v);return Ab(m)?m:t}function tM(c){var v=wr.call(c,Ha),m=c[Ha];try{c[Ha]=t;var T=!0}catch{}var B=Hs.call(c);return T&&(v?c[Ha]=m:delete c[Ha]),B}var Jf=Tf?function(c){return c==null?[]:(c=Sr(c),ca(Tf(c),function(v){return vb.call(c,v)}))}:yc,s1=Tf?function(c){for(var v=[];c;)da(v,Jf(c)),c=Ys(c);return v}:yc,_t=It;(Rf&&_t(new Rf(new ArrayBuffer(1)))!=ze||Ro&&_t(new Ro)!=we||Af&&_t(Af.resolve())!=Me||Oi&&_t(new Oi)!=re||Ao&&_t(new Ao)!=Te)&&(_t=function(c){var v=It(c),m=v==le?c.constructor:t,T=m?Qa(m):"";if(T)switch(T){case ND:return ze;case FD:return we;case zD:return Me;case $D:return re;case VD:return Te}return v});function nM(c,v,m){for(var T=-1,B=m.length;++T<B;){var F=m[T],U=F.size;switch(F.type){case"drop":c+=U;break;case"dropRight":v-=U;break;case"take":v=Ct(v,c+U);break;case"takeRight":c=et(c,v-U);break}}return{start:c,end:v}}function aM(c){var v=c.match(Vr);return v?v[1].split(pn):[]}function u1(c,v,m){v=ya(v,c);for(var T=-1,B=v.length,F=!1;++T<B;){var U=Bn(v[T]);if(!(F=c!=null&&m(c,U)))break;c=c[U]}return F||++T!=B?F:(B=c==null?0:c.length,!!B&&Eu(B)&&Yn(U,B)&&(nr(c)||Ja(c)))}function iM(c){var v=c.length,m=new c.constructor(v);return v&&typeof c[0]=="string"&&wr.call(c,"index")&&(m.index=c.index,m.input=c.input),m}function l1(c){return typeof c.constructor=="function"&&!qo(c)?qi(Ys(c)):{}}function oM(c,v,m){var T=c.constructor;switch(v){case Ne:return Hf(c);case ue:case oe:return new T(+c);case ze:return GB(c,m);case $e:case ke:case Oe:case ye:case O:case ne:case he:case ge:case be:return Ub(c,m);case we:return new T;case Ae:case ce:return new T(c);case Ee:return WB(c);case re:return new T;case _e:return UB(c)}}function sM(c,v){var m=v.length;if(!m)return c;var T=m-1;return v[T]=(m>1?"& ":"")+v[T],v=v.join(m>2?", ":" "),c.replace(Pn,`{
9
- /* [wrapped with `+v+`] */
10
- `)}function uM(c){return nr(c)||Ja(c)||!!(hb&&c&&c[hb])}function Yn(c,v){var m=typeof c;return v=v??$,!!v&&(m=="number"||m!="symbol"&&qs.test(c))&&c>-1&&c%1==0&&c<v}function Dt(c,v,m){if(!Fr(m))return!1;var T=typeof v;return(T=="number"?Nt(m)&&Yn(v,m.length):T=="string"&&v in m)?wn(m[v],c):!1}function ec(c,v){if(nr(c))return!1;var m=typeof c;return m=="number"||m=="symbol"||m=="boolean"||c==null||Yt(c)?!0:Mr.test(c)||!Ur.test(c)||v!=null&&c in Sr(v)}function lM(c){var v=typeof c;return v=="string"||v=="number"||v=="symbol"||v=="boolean"?c!=="__proto__":c===null}function rc(c){var v=hu(c),m=k[v];if(typeof m!="function"||!(v in vr.prototype))return!1;if(c===m)return!0;var T=Xf(m);return!!T&&c===T[0]}function fM(c){return!!fb&&fb in c}var cM=Ws?Zn:mc;function qo(c){var v=c&&c.constructor,m=typeof v=="function"&&v.prototype||Li;return c===m}function f1(c){return c===c&&!Fr(c)}function c1(c,v){return function(m){return m==null?!1:m[c]===v&&(v!==t||c in Sr(m))}}function dM(c){var v=wu(c,function(T){return m.size===l&&m.clear(),T}),m=v.cache;return v}function vM(c,v){var m=c[1],T=v[1],B=m|T,F=B<(b|w|_),U=T==_&&m==E||T==_&&m==A&&c[7].length<=v[8]||T==(_|A)&&v[7].length<=v[8]&&m==E;if(!(F||U))return c;T&b&&(c[2]=v[2],B|=m&b?0:y);var J=v[3];if(J){var se=c[3];c[3]=se?Kb(se,J,v[4]):J,c[4]=se?va(c[3],f):v[4]}return J=v[5],J&&(se=c[5],c[5]=se?jb(se,J,v[6]):J,c[6]=se?va(c[5],f):v[6]),J=v[7],J&&(c[7]=J),T&_&&(c[8]=c[8]==null?v[8]:Ct(c[8],v[8])),c[9]==null&&(c[9]=v[9]),c[0]=v[0],c[1]=B,c}function hM(c){var v=[];if(c!=null)for(var m in Sr(c))v.push(m);return v}function gM(c){return Hs.call(c)}function d1(c,v,m){return v=et(v===t?c.length-1:v,0),function(){for(var T=arguments,B=-1,F=et(T.length-v,0),U=pe(F);++B<F;)U[B]=T[v+B];B=-1;for(var J=pe(v+1);++B<v;)J[B]=T[B];return J[v]=m(U),Ht(c,this,J)}}function v1(c,v){return v.length<2?c:Za(c,un(v,0,-1))}function pM(c,v){for(var m=c.length,T=Ct(v.length,m),B=qt(c);T--;){var F=v[T];c[T]=Yn(F,m)?B[F]:t}return c}function tc(c,v){if(!(v==="constructor"&&typeof c[v]=="function")&&v!="__proto__")return c[v]}var h1=p1(qb),No=DD||function(c,v){return vt.setTimeout(c,v)},nc=p1(FB);function g1(c,v,m){var T=v+"";return nc(c,sM(T,yM(aM(T),m)))}function p1(c){var v=0,m=0;return function(){var T=OD(),B=M-(T-m);if(m=T,B>0){if(++v>=L)return arguments[0]}else v=0;return c.apply(t,arguments)}}function pu(c,v){var m=-1,T=c.length,B=T-1;for(v=v===t?T:v;++m<v;){var F=Ff(m,B),U=c[F];c[F]=c[m],c[m]=U}return c.length=v,c}var y1=dM(function(c){var v=[];return c.charCodeAt(0)===46&&v.push(""),c.replace(ct,function(m,T,B,F){v.push(B?F.replace(Ci,"$1"):T||m)}),v});function Bn(c){if(typeof c=="string"||Yt(c))return c;var v=c+"";return v=="0"&&1/c==-V?"-0":v}function Qa(c){if(c!=null){try{return Us.call(c)}catch{}try{return c+""}catch{}}return""}function yM(c,v){return nn(G,function(m){var T="_."+m[0];v&m[1]&&!zs(c,T)&&c.push(T)}),c.sort()}function m1(c){if(c instanceof vr)return c.clone();var v=new on(c.__wrapped__,c.__chain__);return v.__actions__=qt(c.__actions__),v.__index__=c.__index__,v.__values__=c.__values__,v}function mM(c,v,m){(m?Dt(c,v,m):v===t)?v=1:v=et(or(v),0);var T=c==null?0:c.length;if(!T||v<1)return[];for(var B=0,F=0,U=pe(Qs(T/v));B<T;)U[F++]=un(c,B,B+=v);return U}function bM(c){for(var v=-1,m=c==null?0:c.length,T=0,B=[];++v<m;){var F=c[v];F&&(B[T++]=F)}return B}function wM(){var c=arguments.length;if(!c)return[];for(var v=pe(c-1),m=arguments[0],T=c;T--;)v[T-1]=arguments[T];return da(nr(m)?qt(m):[m],ht(v,1))}var xM=fr(function(c,v){return Hr(c)?Bo(c,ht(v,1,Hr,!0)):[]}),EM=fr(function(c,v){var m=ln(v);return Hr(m)&&(m=t),Hr(c)?Bo(c,ht(v,1,Hr,!0),Qe(m,2)):[]}),CM=fr(function(c,v){var m=ln(v);return Hr(m)&&(m=t),Hr(c)?Bo(c,ht(v,1,Hr,!0),t,m):[]});function _M(c,v,m){var T=c==null?0:c.length;return T?(v=m||v===t?1:or(v),un(c,v<0?0:v,T)):[]}function SM(c,v,m){var T=c==null?0:c.length;return T?(v=m||v===t?1:or(v),v=T-v,un(c,0,v<0?0:v)):[]}function TM(c,v){return c&&c.length?uu(c,Qe(v,3),!0,!0):[]}function RM(c,v){return c&&c.length?uu(c,Qe(v,3),!0):[]}function AM(c,v,m,T){var B=c==null?0:c.length;return B?(m&&typeof m!="number"&&Dt(c,v,m)&&(m=0,T=B),wB(c,v,m,T)):[]}function b1(c,v,m){var T=c==null?0:c.length;if(!T)return-1;var B=m==null?0:or(m);return B<0&&(B=et(T+B,0)),$s(c,Qe(v,3),B)}function w1(c,v,m){var T=c==null?0:c.length;if(!T)return-1;var B=T-1;return m!==t&&(B=or(m),B=m<0?et(T+B,0):Ct(B,T-1)),$s(c,Qe(v,3),B,!0)}function x1(c){var v=c==null?0:c.length;return v?ht(c,1):[]}function PM(c){var v=c==null?0:c.length;return v?ht(c,V):[]}function IM(c,v){var m=c==null?0:c.length;return m?(v=v===t?1:or(v),ht(c,v)):[]}function DM(c){for(var v=-1,m=c==null?0:c.length,T={};++v<m;){var B=c[v];T[B[0]]=B[1]}return T}function E1(c){return c&&c.length?c[0]:t}function BM(c,v,m){var T=c==null?0:c.length;if(!T)return-1;var B=m==null?0:or(m);return B<0&&(B=et(T+B,0)),Ii(c,v,B)}function MM(c){var v=c==null?0:c.length;return v?un(c,0,-1):[]}var LM=fr(function(c){var v=Or(c,Wf);return v.length&&v[0]===c[0]?Lf(v):[]}),OM=fr(function(c){var v=ln(c),m=Or(c,Wf);return v===ln(m)?v=t:m.pop(),m.length&&m[0]===c[0]?Lf(m,Qe(v,2)):[]}),kM=fr(function(c){var v=ln(c),m=Or(c,Wf);return v=typeof v=="function"?v:t,v&&m.pop(),m.length&&m[0]===c[0]?Lf(m,t,v):[]});function qM(c,v){return c==null?"":MD.call(c,v)}function ln(c){var v=c==null?0:c.length;return v?c[v-1]:t}function NM(c,v,m){var T=c==null?0:c.length;if(!T)return-1;var B=T;return m!==t&&(B=or(m),B=B<0?et(T+B,0):Ct(B,T-1)),v===v?yD(c,v,B):$s(c,tb,B,!0)}function FM(c,v){return c&&c.length?Mb(c,or(v)):t}var zM=fr(C1);function C1(c,v){return c&&c.length&&v&&v.length?Nf(c,v):c}function $M(c,v,m){return c&&c.length&&v&&v.length?Nf(c,v,Qe(m,2)):c}function VM(c,v,m){return c&&c.length&&v&&v.length?Nf(c,v,t,m):c}var GM=jn(function(c,v){var m=c==null?0:c.length,T=If(c,v);return kb(c,Or(v,function(B){return Yn(B,m)?+B:B}).sort(Hb)),T});function WM(c,v){var m=[];if(!(c&&c.length))return m;var T=-1,B=[],F=c.length;for(v=Qe(v,3);++T<F;){var U=c[T];v(U,T,c)&&(m.push(U),B.push(T))}return kb(c,B),m}function ac(c){return c==null?c:qD.call(c)}function UM(c,v,m){var T=c==null?0:c.length;return T?(m&&typeof m!="number"&&Dt(c,v,m)?(v=0,m=T):(v=v==null?0:or(v),m=m===t?T:or(m)),un(c,v,m)):[]}function HM(c,v){return su(c,v)}function KM(c,v,m){return $f(c,v,Qe(m,2))}function jM(c,v){var m=c==null?0:c.length;if(m){var T=su(c,v);if(T<m&&wn(c[T],v))return T}return-1}function YM(c,v){return su(c,v,!0)}function ZM(c,v,m){return $f(c,v,Qe(m,2),!0)}function XM(c,v){var m=c==null?0:c.length;if(m){var T=su(c,v,!0)-1;if(wn(c[T],v))return T}return-1}function QM(c){return c&&c.length?Nb(c):[]}function JM(c,v){return c&&c.length?Nb(c,Qe(v,2)):[]}function eL(c){var v=c==null?0:c.length;return v?un(c,1,v):[]}function rL(c,v,m){return c&&c.length?(v=m||v===t?1:or(v),un(c,0,v<0?0:v)):[]}function tL(c,v,m){var T=c==null?0:c.length;return T?(v=m||v===t?1:or(v),v=T-v,un(c,v<0?0:v,T)):[]}function nL(c,v){return c&&c.length?uu(c,Qe(v,3),!1,!0):[]}function aL(c,v){return c&&c.length?uu(c,Qe(v,3)):[]}var iL=fr(function(c){return pa(ht(c,1,Hr,!0))}),oL=fr(function(c){var v=ln(c);return Hr(v)&&(v=t),pa(ht(c,1,Hr,!0),Qe(v,2))}),sL=fr(function(c){var v=ln(c);return v=typeof v=="function"?v:t,pa(ht(c,1,Hr,!0),t,v)});function uL(c){return c&&c.length?pa(c):[]}function lL(c,v){return c&&c.length?pa(c,Qe(v,2)):[]}function fL(c,v){return v=typeof v=="function"?v:t,c&&c.length?pa(c,t,v):[]}function ic(c){if(!(c&&c.length))return[];var v=0;return c=ca(c,function(m){if(Hr(m))return v=et(m.length,v),!0}),Ef(v,function(m){return Or(c,bf(m))})}function _1(c,v){if(!(c&&c.length))return[];var m=ic(c);return v==null?m:Or(m,function(T){return Ht(v,t,T)})}var cL=fr(function(c,v){return Hr(c)?Bo(c,v):[]}),dL=fr(function(c){return Gf(ca(c,Hr))}),vL=fr(function(c){var v=ln(c);return Hr(v)&&(v=t),Gf(ca(c,Hr),Qe(v,2))}),hL=fr(function(c){var v=ln(c);return v=typeof v=="function"?v:t,Gf(ca(c,Hr),t,v)}),gL=fr(ic);function pL(c,v){return Vb(c||[],v||[],Do)}function yL(c,v){return Vb(c||[],v||[],Oo)}var mL=fr(function(c){var v=c.length,m=v>1?c[v-1]:t;return m=typeof m=="function"?(c.pop(),m):t,_1(c,m)});function S1(c){var v=k(c);return v.__chain__=!0,v}function bL(c,v){return v(c),c}function yu(c,v){return v(c)}var wL=jn(function(c){var v=c.length,m=v?c[0]:0,T=this.__wrapped__,B=function(F){return If(F,c)};return v>1||this.__actions__.length||!(T instanceof vr)||!Yn(m)?this.thru(B):(T=T.slice(m,+m+(v?1:0)),T.__actions__.push({func:yu,args:[B],thisArg:t}),new on(T,this.__chain__).thru(function(F){return v&&!F.length&&F.push(t),F}))});function xL(){return S1(this)}function EL(){return new on(this.value(),this.__chain__)}function CL(){this.__values__===t&&(this.__values__=F1(this.value()));var c=this.__index__>=this.__values__.length,v=c?t:this.__values__[this.__index__++];return{done:c,value:v}}function _L(){return this}function SL(c){for(var v,m=this;m instanceof tu;){var T=m1(m);T.__index__=0,T.__values__=t,v?B.__wrapped__=T:v=T;var B=T;m=m.__wrapped__}return B.__wrapped__=c,v}function TL(){var c=this.__wrapped__;if(c instanceof vr){var v=c;return this.__actions__.length&&(v=new vr(this)),v=v.reverse(),v.__actions__.push({func:yu,args:[ac],thisArg:t}),new on(v,this.__chain__)}return this.thru(ac)}function RL(){return $b(this.__wrapped__,this.__actions__)}var AL=lu(function(c,v,m){wr.call(c,m)?++c[m]:Hn(c,m,1)});function PL(c,v,m){var T=nr(c)?eb:bB;return m&&Dt(c,v,m)&&(v=t),T(c,Qe(v,3))}function IL(c,v){var m=nr(c)?ca:_b;return m(c,Qe(v,3))}var DL=Qb(b1),BL=Qb(w1);function ML(c,v){return ht(mu(c,v),1)}function LL(c,v){return ht(mu(c,v),V)}function OL(c,v,m){return m=m===t?1:or(m),ht(mu(c,v),m)}function T1(c,v){var m=nr(c)?nn:ga;return m(c,Qe(v,3))}function R1(c,v){var m=nr(c)?eD:Cb;return m(c,Qe(v,3))}var kL=lu(function(c,v,m){wr.call(c,m)?c[m].push(v):Hn(c,m,[v])});function qL(c,v,m,T){c=Nt(c)?c:Vi(c),m=m&&!T?or(m):0;var B=c.length;return m<0&&(m=et(B+m,0)),Cu(c)?m<=B&&c.indexOf(v,m)>-1:!!B&&Ii(c,v,m)>-1}var NL=fr(function(c,v,m){var T=-1,B=typeof v=="function",F=Nt(c)?pe(c.length):[];return ga(c,function(U){F[++T]=B?Ht(v,U,m):Mo(U,v,m)}),F}),FL=lu(function(c,v,m){Hn(c,m,v)});function mu(c,v){var m=nr(c)?Or:Ib;return m(c,Qe(v,3))}function zL(c,v,m,T){return c==null?[]:(nr(v)||(v=v==null?[]:[v]),m=T?t:m,nr(m)||(m=m==null?[]:[m]),Lb(c,v,m))}var $L=lu(function(c,v,m){c[m?0:1].push(v)},function(){return[[],[]]});function VL(c,v,m){var T=nr(c)?yf:ab,B=arguments.length<3;return T(c,Qe(v,4),m,B,ga)}function GL(c,v,m){var T=nr(c)?rD:ab,B=arguments.length<3;return T(c,Qe(v,4),m,B,Cb)}function WL(c,v){var m=nr(c)?ca:_b;return m(c,xu(Qe(v,3)))}function UL(c){var v=nr(c)?bb:qB;return v(c)}function HL(c,v,m){(m?Dt(c,v,m):v===t)?v=1:v=or(v);var T=nr(c)?hB:NB;return T(c,v)}function KL(c){var v=nr(c)?gB:zB;return v(c)}function jL(c){if(c==null)return 0;if(Nt(c))return Cu(c)?Bi(c):c.length;var v=_t(c);return v==we||v==re?c.size:kf(c).length}function YL(c,v,m){var T=nr(c)?mf:$B;return m&&Dt(c,v,m)&&(v=t),T(c,Qe(v,3))}var ZL=fr(function(c,v){if(c==null)return[];var m=v.length;return m>1&&Dt(c,v[0],v[1])?v=[]:m>2&&Dt(v[0],v[1],v[2])&&(v=[v[0]]),Lb(c,ht(v,1),[])}),bu=ID||function(){return vt.Date.now()};function XL(c,v){if(typeof v!="function")throw new an(o);return c=or(c),function(){if(--c<1)return v.apply(this,arguments)}}function A1(c,v,m){return v=m?t:v,v=c&&v==null?c.length:v,Kn(c,_,t,t,t,t,v)}function P1(c,v){var m;if(typeof v!="function")throw new an(o);return c=or(c),function(){return--c>0&&(m=v.apply(this,arguments)),c<=1&&(v=t),m}}var oc=fr(function(c,v,m){var T=b;if(m.length){var B=va(m,zi(oc));T|=S}return Kn(c,T,v,m,B)}),I1=fr(function(c,v,m){var T=b|w;if(m.length){var B=va(m,zi(I1));T|=S}return Kn(v,T,c,m,B)});function D1(c,v,m){v=m?t:v;var T=Kn(c,E,t,t,t,t,t,v);return T.placeholder=D1.placeholder,T}function B1(c,v,m){v=m?t:v;var T=Kn(c,C,t,t,t,t,t,v);return T.placeholder=B1.placeholder,T}function M1(c,v,m){var T,B,F,U,J,se,Pe=0,Ie=!1,Le=!1,Fe=!0;if(typeof c!="function")throw new an(o);v=fn(v)||0,Fr(m)&&(Ie=!!m.leading,Le="maxWait"in m,F=Le?et(fn(m.maxWait)||0,v):F,Fe="trailing"in m?!!m.trailing:Fe);function je(Kr){var xn=T,Qn=B;return T=B=t,Pe=Kr,U=c.apply(Qn,xn),U}function Je(Kr){return Pe=Kr,J=No(dr,v),Ie?je(Kr):U}function ur(Kr){var xn=Kr-se,Qn=Kr-Pe,Q1=v-xn;return Le?Ct(Q1,F-Qn):Q1}function er(Kr){var xn=Kr-se,Qn=Kr-Pe;return se===t||xn>=v||xn<0||Le&&Qn>=F}function dr(){var Kr=bu();if(er(Kr))return hr(Kr);J=No(dr,ur(Kr))}function hr(Kr){return J=t,Fe&&T?je(Kr):(T=B=t,U)}function Zt(){J!==t&&Gb(J),Pe=0,T=se=B=J=t}function Bt(){return J===t?U:hr(bu())}function Xt(){var Kr=bu(),xn=er(Kr);if(T=arguments,B=this,se=Kr,xn){if(J===t)return Je(se);if(Le)return Gb(J),J=No(dr,v),je(se)}return J===t&&(J=No(dr,v)),U}return Xt.cancel=Zt,Xt.flush=Bt,Xt}var QL=fr(function(c,v){return Eb(c,1,v)}),JL=fr(function(c,v,m){return Eb(c,fn(v)||0,m)});function eO(c){return Kn(c,P)}function wu(c,v){if(typeof c!="function"||v!=null&&typeof v!="function")throw new an(o);var m=function(){var T=arguments,B=v?v.apply(this,T):T[0],F=m.cache;if(F.has(B))return F.get(B);var U=c.apply(this,T);return m.cache=F.set(B,U)||F,U};return m.cache=new(wu.Cache||Un),m}wu.Cache=Un;function xu(c){if(typeof c!="function")throw new an(o);return function(){var v=arguments;switch(v.length){case 0:return!c.call(this);case 1:return!c.call(this,v[0]);case 2:return!c.call(this,v[0],v[1]);case 3:return!c.call(this,v[0],v[1],v[2])}return!c.apply(this,v)}}function rO(c){return P1(2,c)}var tO=VB(function(c,v){v=v.length==1&&nr(v[0])?Or(v[0],Kt(Qe())):Or(ht(v,1),Kt(Qe()));var m=v.length;return fr(function(T){for(var B=-1,F=Ct(T.length,m);++B<F;)T[B]=v[B].call(this,T[B]);return Ht(c,this,T)})}),sc=fr(function(c,v){var m=va(v,zi(sc));return Kn(c,S,t,v,m)}),L1=fr(function(c,v){var m=va(v,zi(L1));return Kn(c,R,t,v,m)}),nO=jn(function(c,v){return Kn(c,A,t,t,t,v)});function aO(c,v){if(typeof c!="function")throw new an(o);return v=v===t?v:or(v),fr(c,v)}function iO(c,v){if(typeof c!="function")throw new an(o);return v=v==null?0:et(or(v),0),fr(function(m){var T=m[v],B=ma(m,0,v);return T&&da(B,T),Ht(c,this,B)})}function oO(c,v,m){var T=!0,B=!0;if(typeof c!="function")throw new an(o);return Fr(m)&&(T="leading"in m?!!m.leading:T,B="trailing"in m?!!m.trailing:B),M1(c,v,{leading:T,maxWait:v,trailing:B})}function sO(c){return A1(c,1)}function uO(c,v){return sc(Uf(v),c)}function lO(){if(!arguments.length)return[];var c=arguments[0];return nr(c)?c:[c]}function fO(c){return sn(c,g)}function cO(c,v){return v=typeof v=="function"?v:t,sn(c,g,v)}function dO(c){return sn(c,d|g)}function vO(c,v){return v=typeof v=="function"?v:t,sn(c,d|g,v)}function hO(c,v){return v==null||xb(c,v,st(v))}function wn(c,v){return c===v||c!==c&&v!==v}var gO=vu(Mf),pO=vu(function(c,v){return c>=v}),Ja=Rb((function(){return arguments})())?Rb:function(c){return Gr(c)&&wr.call(c,"callee")&&!vb.call(c,"callee")},nr=pe.isArray,yO=j0?Kt(j0):SB;function Nt(c){return c!=null&&Eu(c.length)&&!Zn(c)}function Hr(c){return Gr(c)&&Nt(c)}function mO(c){return c===!0||c===!1||Gr(c)&&It(c)==ue}var ba=BD||mc,bO=Y0?Kt(Y0):TB;function wO(c){return Gr(c)&&c.nodeType===1&&!Fo(c)}function xO(c){if(c==null)return!0;if(Nt(c)&&(nr(c)||typeof c=="string"||typeof c.splice=="function"||ba(c)||$i(c)||Ja(c)))return!c.length;var v=_t(c);if(v==we||v==re)return!c.size;if(qo(c))return!kf(c).length;for(var m in c)if(wr.call(c,m))return!1;return!0}function EO(c,v){return Lo(c,v)}function CO(c,v,m){m=typeof m=="function"?m:t;var T=m?m(c,v):t;return T===t?Lo(c,v,t,m):!!T}function uc(c){if(!Gr(c))return!1;var v=It(c);return v==Q||v==X||typeof c.message=="string"&&typeof c.name=="string"&&!Fo(c)}function _O(c){return typeof c=="number"&&gb(c)}function Zn(c){if(!Fr(c))return!1;var v=It(c);return v==ie||v==de||v==te||v==Se}function O1(c){return typeof c=="number"&&c==or(c)}function Eu(c){return typeof c=="number"&&c>-1&&c%1==0&&c<=$}function Fr(c){var v=typeof c;return c!=null&&(v=="object"||v=="function")}function Gr(c){return c!=null&&typeof c=="object"}var k1=Z0?Kt(Z0):AB;function SO(c,v){return c===v||Of(c,v,Qf(v))}function TO(c,v,m){return m=typeof m=="function"?m:t,Of(c,v,Qf(v),m)}function RO(c){return q1(c)&&c!=+c}function AO(c){if(cM(c))throw new tr(i);return Ab(c)}function PO(c){return c===null}function IO(c){return c==null}function q1(c){return typeof c=="number"||Gr(c)&&It(c)==Ae}function Fo(c){if(!Gr(c)||It(c)!=le)return!1;var v=Ys(c);if(v===null)return!0;var m=wr.call(v,"constructor")&&v.constructor;return typeof m=="function"&&m instanceof m&&Us.call(m)==TD}var lc=X0?Kt(X0):PB;function DO(c){return O1(c)&&c>=-$&&c<=$}var N1=Q0?Kt(Q0):IB;function Cu(c){return typeof c=="string"||!nr(c)&&Gr(c)&&It(c)==ce}function Yt(c){return typeof c=="symbol"||Gr(c)&&It(c)==_e}var $i=J0?Kt(J0):DB;function BO(c){return c===t}function MO(c){return Gr(c)&&_t(c)==Te}function LO(c){return Gr(c)&&It(c)==De}var OO=vu(qf),kO=vu(function(c,v){return c<=v});function F1(c){if(!c)return[];if(Nt(c))return Cu(c)?mn(c):qt(c);if(To&&c[To])return hD(c[To]());var v=_t(c),m=v==we?_f:v==re?Vs:Vi;return m(c)}function Xn(c){if(!c)return c===0?c:0;if(c=fn(c),c===V||c===-V){var v=c<0?-1:1;return v*Z}return c===c?c:0}function or(c){var v=Xn(c),m=v%1;return v===v?m?v-m:v:0}function z1(c){return c?Ya(or(c),0,K):0}function fn(c){if(typeof c=="number")return c;if(Yt(c))return ee;if(Fr(c)){var v=typeof c.valueOf=="function"?c.valueOf():c;c=Fr(v)?v+"":v}if(typeof c!="string")return c===0?c:+c;c=ib(c);var m=Et.test(c);return m||kt.test(c)?XI(c.slice(2),m?2:8):ot.test(c)?ee:+c}function $1(c){return Dn(c,Ft(c))}function qO(c){return c?Ya(or(c),-$,$):c===0?c:0}function xr(c){return c==null?"":jt(c)}var NO=Ni(function(c,v){if(qo(v)||Nt(v)){Dn(v,st(v),c);return}for(var m in v)wr.call(v,m)&&Do(c,m,v[m])}),V1=Ni(function(c,v){Dn(v,Ft(v),c)}),_u=Ni(function(c,v,m,T){Dn(v,Ft(v),c,T)}),FO=Ni(function(c,v,m,T){Dn(v,st(v),c,T)}),zO=jn(If);function $O(c,v){var m=qi(c);return v==null?m:wb(m,v)}var VO=fr(function(c,v){c=Sr(c);var m=-1,T=v.length,B=T>2?v[2]:t;for(B&&Dt(v[0],v[1],B)&&(T=1);++m<T;)for(var F=v[m],U=Ft(F),J=-1,se=U.length;++J<se;){var Pe=U[J],Ie=c[Pe];(Ie===t||wn(Ie,Li[Pe])&&!wr.call(c,Pe))&&(c[Pe]=F[Pe])}return c}),GO=fr(function(c){return c.push(t,i1),Ht(G1,t,c)});function WO(c,v){return rb(c,Qe(v,3),In)}function UO(c,v){return rb(c,Qe(v,3),Bf)}function HO(c,v){return c==null?c:Df(c,Qe(v,3),Ft)}function KO(c,v){return c==null?c:Sb(c,Qe(v,3),Ft)}function jO(c,v){return c&&In(c,Qe(v,3))}function YO(c,v){return c&&Bf(c,Qe(v,3))}function ZO(c){return c==null?[]:iu(c,st(c))}function XO(c){return c==null?[]:iu(c,Ft(c))}function fc(c,v,m){var T=c==null?t:Za(c,v);return T===t?m:T}function QO(c,v){return c!=null&&u1(c,v,xB)}function cc(c,v){return c!=null&&u1(c,v,EB)}var JO=e1(function(c,v,m){v!=null&&typeof v.toString!="function"&&(v=Hs.call(v)),c[v]=m},vc(zt)),ek=e1(function(c,v,m){v!=null&&typeof v.toString!="function"&&(v=Hs.call(v)),wr.call(c,v)?c[v].push(m):c[v]=[m]},Qe),rk=fr(Mo);function st(c){return Nt(c)?mb(c):kf(c)}function Ft(c){return Nt(c)?mb(c,!0):BB(c)}function tk(c,v){var m={};return v=Qe(v,3),In(c,function(T,B,F){Hn(m,v(T,B,F),T)}),m}function nk(c,v){var m={};return v=Qe(v,3),In(c,function(T,B,F){Hn(m,B,v(T,B,F))}),m}var ak=Ni(function(c,v,m){ou(c,v,m)}),G1=Ni(function(c,v,m,T){ou(c,v,m,T)}),ik=jn(function(c,v){var m={};if(c==null)return m;var T=!1;v=Or(v,function(F){return F=ya(F,c),T||(T=F.length>1),F}),Dn(c,Zf(c),m),T&&(m=sn(m,d|h|g,JB));for(var B=v.length;B--;)Vf(m,v[B]);return m});function ok(c,v){return W1(c,xu(Qe(v)))}var sk=jn(function(c,v){return c==null?{}:LB(c,v)});function W1(c,v){if(c==null)return{};var m=Or(Zf(c),function(T){return[T]});return v=Qe(v),Ob(c,m,function(T,B){return v(T,B[0])})}function uk(c,v,m){v=ya(v,c);var T=-1,B=v.length;for(B||(B=1,c=t);++T<B;){var F=c==null?t:c[Bn(v[T])];F===t&&(T=B,F=m),c=Zn(F)?F.call(c):F}return c}function lk(c,v,m){return c==null?c:Oo(c,v,m)}function fk(c,v,m,T){return T=typeof T=="function"?T:t,c==null?c:Oo(c,v,m,T)}var U1=n1(st),H1=n1(Ft);function ck(c,v,m){var T=nr(c),B=T||ba(c)||$i(c);if(v=Qe(v,4),m==null){var F=c&&c.constructor;B?m=T?new F:[]:Fr(c)?m=Zn(F)?qi(Ys(c)):{}:m={}}return(B?nn:In)(c,function(U,J,se){return v(m,U,J,se)}),m}function dk(c,v){return c==null?!0:Vf(c,v)}function vk(c,v,m){return c==null?c:zb(c,v,Uf(m))}function hk(c,v,m,T){return T=typeof T=="function"?T:t,c==null?c:zb(c,v,Uf(m),T)}function Vi(c){return c==null?[]:Cf(c,st(c))}function gk(c){return c==null?[]:Cf(c,Ft(c))}function pk(c,v,m){return m===t&&(m=v,v=t),m!==t&&(m=fn(m),m=m===m?m:0),v!==t&&(v=fn(v),v=v===v?v:0),Ya(fn(c),v,m)}function yk(c,v,m){return v=Xn(v),m===t?(m=v,v=0):m=Xn(m),c=fn(c),CB(c,v,m)}function mk(c,v,m){if(m&&typeof m!="boolean"&&Dt(c,v,m)&&(v=m=t),m===t&&(typeof v=="boolean"?(m=v,v=t):typeof c=="boolean"&&(m=c,c=t)),c===t&&v===t?(c=0,v=1):(c=Xn(c),v===t?(v=c,c=0):v=Xn(v)),c>v){var T=c;c=v,v=T}if(m||c%1||v%1){var B=pb();return Ct(c+B*(v-c+ZI("1e-"+((B+"").length-1))),v)}return Ff(c,v)}var bk=Fi(function(c,v,m){return v=v.toLowerCase(),c+(m?K1(v):v)});function K1(c){return dc(xr(c).toLowerCase())}function j1(c){return c=xr(c),c&&c.replace(rf,lD).replace(zI,"")}function wk(c,v,m){c=xr(c),v=jt(v);var T=c.length;m=m===t?T:Ya(or(m),0,T);var B=m;return m-=v.length,m>=0&&c.slice(m,B)==v}function xk(c){return c=xr(c),c&&ar.test(c)?c.replace(Ze,fD):c}function Ek(c){return c=xr(c),c&&jr.test(c)?c.replace(Lr,"\\$&"):c}var Ck=Fi(function(c,v,m){return c+(m?"-":"")+v.toLowerCase()}),_k=Fi(function(c,v,m){return c+(m?" ":"")+v.toLowerCase()}),Sk=Xb("toLowerCase");function Tk(c,v,m){c=xr(c),v=or(v);var T=v?Bi(c):0;if(!v||T>=v)return c;var B=(v-T)/2;return du(Js(B),m)+c+du(Qs(B),m)}function Rk(c,v,m){c=xr(c),v=or(v);var T=v?Bi(c):0;return v&&T<v?c+du(v-T,m):c}function Ak(c,v,m){c=xr(c),v=or(v);var T=v?Bi(c):0;return v&&T<v?du(v-T,m)+c:c}function Pk(c,v,m){return m||v==null?v=0:v&&(v=+v),kD(xr(c).replace(Nr,""),v||0)}function Ik(c,v,m){return(m?Dt(c,v,m):v===t)?v=1:v=or(v),zf(xr(c),v)}function Dk(){var c=arguments,v=xr(c[0]);return c.length<3?v:v.replace(c[1],c[2])}var Bk=Fi(function(c,v,m){return c+(m?"_":"")+v.toLowerCase()});function Mk(c,v,m){return m&&typeof m!="number"&&Dt(c,v,m)&&(v=m=t),m=m===t?K:m>>>0,m?(c=xr(c),c&&(typeof v=="string"||v!=null&&!lc(v))&&(v=jt(v),!v&&Di(c))?ma(mn(c),0,m):c.split(v,m)):[]}var Lk=Fi(function(c,v,m){return c+(m?" ":"")+dc(v)});function Ok(c,v,m){return c=xr(c),m=m==null?0:Ya(or(m),0,c.length),v=jt(v),c.slice(m,m+v.length)==v}function kk(c,v,m){var T=k.templateSettings;m&&Dt(c,v,m)&&(v=t),c=xr(c),v=_u({},v,T,a1);var B=_u({},v.imports,T.imports,a1),F=st(B),U=Cf(B,F),J,se,Pe=0,Ie=v.interpolate||_i,Le="__p += '",Fe=Sf((v.escape||_i).source+"|"+Ie.source+"|"+(Ie===ir?Gn:_i).source+"|"+(v.evaluate||_i).source+"|$","g"),je="//# sourceURL="+(wr.call(v,"sourceURL")?(v.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++UI+"]")+`
11
- `;c.replace(Fe,function(er,dr,hr,Zt,Bt,Xt){return hr||(hr=Zt),Le+=c.slice(Pe,Xt).replace(tf,cD),dr&&(J=!0,Le+=`' +
12
- __e(`+dr+`) +
13
- '`),Bt&&(se=!0,Le+=`';
14
- `+Bt+`;
15
- __p += '`),hr&&(Le+=`' +
16
- ((__t = (`+hr+`)) == null ? '' : __t) +
17
- '`),Pe=Xt+er.length,er}),Le+=`';
18
- `;var Je=wr.call(v,"variable")&&v.variable;if(!Je)Le=`with (obj) {
19
- `+Le+`
20
- }
21
- `;else if(ua.test(Je))throw new tr(s);Le=(se?Le.replace(Ve,""):Le).replace(Be,"$1").replace(He,"$1;"),Le="function("+(Je||"obj")+`) {
22
- `+(Je?"":`obj || (obj = {});
23
- `)+"var __t, __p = ''"+(J?", __e = _.escape":"")+(se?`, __j = Array.prototype.join;
24
- function print() { __p += __j.call(arguments, '') }
25
- `:`;
26
- `)+Le+`return __p
27
- }`;var ur=Z1(function(){return br(F,je+"return "+Le).apply(t,U)});if(ur.source=Le,uc(ur))throw ur;return ur}function qk(c){return xr(c).toLowerCase()}function Nk(c){return xr(c).toUpperCase()}function Fk(c,v,m){if(c=xr(c),c&&(m||v===t))return ib(c);if(!c||!(v=jt(v)))return c;var T=mn(c),B=mn(v),F=ob(T,B),U=sb(T,B)+1;return ma(T,F,U).join("")}function zk(c,v,m){if(c=xr(c),c&&(m||v===t))return c.slice(0,lb(c)+1);if(!c||!(v=jt(v)))return c;var T=mn(c),B=sb(T,mn(v))+1;return ma(T,0,B).join("")}function $k(c,v,m){if(c=xr(c),c&&(m||v===t))return c.replace(Nr,"");if(!c||!(v=jt(v)))return c;var T=mn(c),B=ob(T,mn(v));return ma(T,B).join("")}function Vk(c,v){var m=I,T=D;if(Fr(v)){var B="separator"in v?v.separator:B;m="length"in v?or(v.length):m,T="omission"in v?jt(v.omission):T}c=xr(c);var F=c.length;if(Di(c)){var U=mn(c);F=U.length}if(m>=F)return c;var J=m-Bi(T);if(J<1)return T;var se=U?ma(U,0,J).join(""):c.slice(0,J);if(B===t)return se+T;if(U&&(J+=se.length-J),lc(B)){if(c.slice(J).search(B)){var Pe,Ie=se;for(B.global||(B=Sf(B.source,xr(dt.exec(B))+"g")),B.lastIndex=0;Pe=B.exec(Ie);)var Le=Pe.index;se=se.slice(0,Le===t?J:Le)}}else if(c.indexOf(jt(B),J)!=J){var Fe=se.lastIndexOf(B);Fe>-1&&(se=se.slice(0,Fe))}return se+T}function Gk(c){return c=xr(c),c&&sr.test(c)?c.replace(We,mD):c}var Wk=Fi(function(c,v,m){return c+(m?" ":"")+v.toUpperCase()}),dc=Xb("toUpperCase");function Y1(c,v,m){return c=xr(c),v=m?t:v,v===t?vD(c)?xD(c):aD(c):c.match(v)||[]}var Z1=fr(function(c,v){try{return Ht(c,t,v)}catch(m){return uc(m)?m:new tr(m)}}),Uk=jn(function(c,v){return nn(v,function(m){m=Bn(m),Hn(c,m,oc(c[m],c))}),c});function Hk(c){var v=c==null?0:c.length,m=Qe();return c=v?Or(c,function(T){if(typeof T[1]!="function")throw new an(o);return[m(T[0]),T[1]]}):[],fr(function(T){for(var B=-1;++B<v;){var F=c[B];if(Ht(F[0],this,T))return Ht(F[1],this,T)}})}function Kk(c){return mB(sn(c,d))}function vc(c){return function(){return c}}function jk(c,v){return c==null||c!==c?v:c}var Yk=Jb(),Zk=Jb(!0);function zt(c){return c}function hc(c){return Pb(typeof c=="function"?c:sn(c,d))}function Xk(c){return Db(sn(c,d))}function Qk(c,v){return Bb(c,sn(v,d))}var Jk=fr(function(c,v){return function(m){return Mo(m,c,v)}}),eq=fr(function(c,v){return function(m){return Mo(c,m,v)}});function gc(c,v,m){var T=st(v),B=iu(v,T);m==null&&!(Fr(v)&&(B.length||!T.length))&&(m=v,v=c,c=this,B=iu(v,st(v)));var F=!(Fr(m)&&"chain"in m)||!!m.chain,U=Zn(c);return nn(B,function(J){var se=v[J];c[J]=se,U&&(c.prototype[J]=function(){var Pe=this.__chain__;if(F||Pe){var Ie=c(this.__wrapped__),Le=Ie.__actions__=qt(this.__actions__);return Le.push({func:se,args:arguments,thisArg:c}),Ie.__chain__=Pe,Ie}return se.apply(c,da([this.value()],arguments))})}),c}function rq(){return vt._===this&&(vt._=RD),this}function pc(){}function tq(c){return c=or(c),fr(function(v){return Mb(v,c)})}var nq=Kf(Or),aq=Kf(eb),iq=Kf(mf);function X1(c){return ec(c)?bf(Bn(c)):OB(c)}function oq(c){return function(v){return c==null?t:Za(c,v)}}var sq=r1(),uq=r1(!0);function yc(){return[]}function mc(){return!1}function lq(){return{}}function fq(){return""}function cq(){return!0}function dq(c,v){if(c=or(c),c<1||c>$)return[];var m=K,T=Ct(c,K);v=Qe(v),c-=K;for(var B=Ef(T,v);++m<c;)v(m);return B}function vq(c){return nr(c)?Or(c,Bn):Yt(c)?[c]:qt(y1(xr(c)))}function hq(c){var v=++SD;return xr(c)+v}var gq=cu(function(c,v){return c+v},0),pq=jf("ceil"),yq=cu(function(c,v){return c/v},1),mq=jf("floor");function bq(c){return c&&c.length?au(c,zt,Mf):t}function wq(c,v){return c&&c.length?au(c,Qe(v,2),Mf):t}function xq(c){return nb(c,zt)}function Eq(c,v){return nb(c,Qe(v,2))}function Cq(c){return c&&c.length?au(c,zt,qf):t}function _q(c,v){return c&&c.length?au(c,Qe(v,2),qf):t}var Sq=cu(function(c,v){return c*v},1),Tq=jf("round"),Rq=cu(function(c,v){return c-v},0);function Aq(c){return c&&c.length?xf(c,zt):0}function Pq(c,v){return c&&c.length?xf(c,Qe(v,2)):0}return k.after=XL,k.ary=A1,k.assign=NO,k.assignIn=V1,k.assignInWith=_u,k.assignWith=FO,k.at=zO,k.before=P1,k.bind=oc,k.bindAll=Uk,k.bindKey=I1,k.castArray=lO,k.chain=S1,k.chunk=mM,k.compact=bM,k.concat=wM,k.cond=Hk,k.conforms=Kk,k.constant=vc,k.countBy=AL,k.create=$O,k.curry=D1,k.curryRight=B1,k.debounce=M1,k.defaults=VO,k.defaultsDeep=GO,k.defer=QL,k.delay=JL,k.difference=xM,k.differenceBy=EM,k.differenceWith=CM,k.drop=_M,k.dropRight=SM,k.dropRightWhile=TM,k.dropWhile=RM,k.fill=AM,k.filter=IL,k.flatMap=ML,k.flatMapDeep=LL,k.flatMapDepth=OL,k.flatten=x1,k.flattenDeep=PM,k.flattenDepth=IM,k.flip=eO,k.flow=Yk,k.flowRight=Zk,k.fromPairs=DM,k.functions=ZO,k.functionsIn=XO,k.groupBy=kL,k.initial=MM,k.intersection=LM,k.intersectionBy=OM,k.intersectionWith=kM,k.invert=JO,k.invertBy=ek,k.invokeMap=NL,k.iteratee=hc,k.keyBy=FL,k.keys=st,k.keysIn=Ft,k.map=mu,k.mapKeys=tk,k.mapValues=nk,k.matches=Xk,k.matchesProperty=Qk,k.memoize=wu,k.merge=ak,k.mergeWith=G1,k.method=Jk,k.methodOf=eq,k.mixin=gc,k.negate=xu,k.nthArg=tq,k.omit=ik,k.omitBy=ok,k.once=rO,k.orderBy=zL,k.over=nq,k.overArgs=tO,k.overEvery=aq,k.overSome=iq,k.partial=sc,k.partialRight=L1,k.partition=$L,k.pick=sk,k.pickBy=W1,k.property=X1,k.propertyOf=oq,k.pull=zM,k.pullAll=C1,k.pullAllBy=$M,k.pullAllWith=VM,k.pullAt=GM,k.range=sq,k.rangeRight=uq,k.rearg=nO,k.reject=WL,k.remove=WM,k.rest=aO,k.reverse=ac,k.sampleSize=HL,k.set=lk,k.setWith=fk,k.shuffle=KL,k.slice=UM,k.sortBy=ZL,k.sortedUniq=QM,k.sortedUniqBy=JM,k.split=Mk,k.spread=iO,k.tail=eL,k.take=rL,k.takeRight=tL,k.takeRightWhile=nL,k.takeWhile=aL,k.tap=bL,k.throttle=oO,k.thru=yu,k.toArray=F1,k.toPairs=U1,k.toPairsIn=H1,k.toPath=vq,k.toPlainObject=$1,k.transform=ck,k.unary=sO,k.union=iL,k.unionBy=oL,k.unionWith=sL,k.uniq=uL,k.uniqBy=lL,k.uniqWith=fL,k.unset=dk,k.unzip=ic,k.unzipWith=_1,k.update=vk,k.updateWith=hk,k.values=Vi,k.valuesIn=gk,k.without=cL,k.words=Y1,k.wrap=uO,k.xor=dL,k.xorBy=vL,k.xorWith=hL,k.zip=gL,k.zipObject=pL,k.zipObjectDeep=yL,k.zipWith=mL,k.entries=U1,k.entriesIn=H1,k.extend=V1,k.extendWith=_u,gc(k,k),k.add=gq,k.attempt=Z1,k.camelCase=bk,k.capitalize=K1,k.ceil=pq,k.clamp=pk,k.clone=fO,k.cloneDeep=dO,k.cloneDeepWith=vO,k.cloneWith=cO,k.conformsTo=hO,k.deburr=j1,k.defaultTo=jk,k.divide=yq,k.endsWith=wk,k.eq=wn,k.escape=xk,k.escapeRegExp=Ek,k.every=PL,k.find=DL,k.findIndex=b1,k.findKey=WO,k.findLast=BL,k.findLastIndex=w1,k.findLastKey=UO,k.floor=mq,k.forEach=T1,k.forEachRight=R1,k.forIn=HO,k.forInRight=KO,k.forOwn=jO,k.forOwnRight=YO,k.get=fc,k.gt=gO,k.gte=pO,k.has=QO,k.hasIn=cc,k.head=E1,k.identity=zt,k.includes=qL,k.indexOf=BM,k.inRange=yk,k.invoke=rk,k.isArguments=Ja,k.isArray=nr,k.isArrayBuffer=yO,k.isArrayLike=Nt,k.isArrayLikeObject=Hr,k.isBoolean=mO,k.isBuffer=ba,k.isDate=bO,k.isElement=wO,k.isEmpty=xO,k.isEqual=EO,k.isEqualWith=CO,k.isError=uc,k.isFinite=_O,k.isFunction=Zn,k.isInteger=O1,k.isLength=Eu,k.isMap=k1,k.isMatch=SO,k.isMatchWith=TO,k.isNaN=RO,k.isNative=AO,k.isNil=IO,k.isNull=PO,k.isNumber=q1,k.isObject=Fr,k.isObjectLike=Gr,k.isPlainObject=Fo,k.isRegExp=lc,k.isSafeInteger=DO,k.isSet=N1,k.isString=Cu,k.isSymbol=Yt,k.isTypedArray=$i,k.isUndefined=BO,k.isWeakMap=MO,k.isWeakSet=LO,k.join=qM,k.kebabCase=Ck,k.last=ln,k.lastIndexOf=NM,k.lowerCase=_k,k.lowerFirst=Sk,k.lt=OO,k.lte=kO,k.max=bq,k.maxBy=wq,k.mean=xq,k.meanBy=Eq,k.min=Cq,k.minBy=_q,k.stubArray=yc,k.stubFalse=mc,k.stubObject=lq,k.stubString=fq,k.stubTrue=cq,k.multiply=Sq,k.nth=FM,k.noConflict=rq,k.noop=pc,k.now=bu,k.pad=Tk,k.padEnd=Rk,k.padStart=Ak,k.parseInt=Pk,k.random=mk,k.reduce=VL,k.reduceRight=GL,k.repeat=Ik,k.replace=Dk,k.result=uk,k.round=Tq,k.runInContext=ae,k.sample=UL,k.size=jL,k.snakeCase=Bk,k.some=YL,k.sortedIndex=HM,k.sortedIndexBy=KM,k.sortedIndexOf=jM,k.sortedLastIndex=YM,k.sortedLastIndexBy=ZM,k.sortedLastIndexOf=XM,k.startCase=Lk,k.startsWith=Ok,k.subtract=Rq,k.sum=Aq,k.sumBy=Pq,k.template=kk,k.times=dq,k.toFinite=Xn,k.toInteger=or,k.toLength=z1,k.toLower=qk,k.toNumber=fn,k.toSafeInteger=qO,k.toString=xr,k.toUpper=Nk,k.trim=Fk,k.trimEnd=zk,k.trimStart=$k,k.truncate=Vk,k.unescape=Gk,k.uniqueId=hq,k.upperCase=Wk,k.upperFirst=dc,k.each=T1,k.eachRight=R1,k.first=E1,gc(k,(function(){var c={};return In(k,function(v,m){wr.call(k.prototype,m)||(c[m]=v)}),c})(),{chain:!1}),k.VERSION=n,nn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(c){k[c].placeholder=k}),nn(["drop","take"],function(c,v){vr.prototype[c]=function(m){m=m===t?1:et(or(m),0);var T=this.__filtered__&&!v?new vr(this):this.clone();return T.__filtered__?T.__takeCount__=Ct(m,T.__takeCount__):T.__views__.push({size:Ct(m,K),type:c+(T.__dir__<0?"Right":"")}),T},vr.prototype[c+"Right"]=function(m){return this.reverse()[c](m).reverse()}}),nn(["filter","map","takeWhile"],function(c,v){var m=v+1,T=m==q||m==W;vr.prototype[c]=function(B){var F=this.clone();return F.__iteratees__.push({iteratee:Qe(B,3),type:m}),F.__filtered__=F.__filtered__||T,F}}),nn(["head","last"],function(c,v){var m="take"+(v?"Right":"");vr.prototype[c]=function(){return this[m](1).value()[0]}}),nn(["initial","tail"],function(c,v){var m="drop"+(v?"":"Right");vr.prototype[c]=function(){return this.__filtered__?new vr(this):this[m](1)}}),vr.prototype.compact=function(){return this.filter(zt)},vr.prototype.find=function(c){return this.filter(c).head()},vr.prototype.findLast=function(c){return this.reverse().find(c)},vr.prototype.invokeMap=fr(function(c,v){return typeof c=="function"?new vr(this):this.map(function(m){return Mo(m,c,v)})}),vr.prototype.reject=function(c){return this.filter(xu(Qe(c)))},vr.prototype.slice=function(c,v){c=or(c);var m=this;return m.__filtered__&&(c>0||v<0)?new vr(m):(c<0?m=m.takeRight(-c):c&&(m=m.drop(c)),v!==t&&(v=or(v),m=v<0?m.dropRight(-v):m.take(v-c)),m)},vr.prototype.takeRightWhile=function(c){return this.reverse().takeWhile(c).reverse()},vr.prototype.toArray=function(){return this.take(K)},In(vr.prototype,function(c,v){var m=/^(?:filter|find|map|reject)|While$/.test(v),T=/^(?:head|last)$/.test(v),B=k[T?"take"+(v=="last"?"Right":""):v],F=T||/^find/.test(v);B&&(k.prototype[v]=function(){var U=this.__wrapped__,J=T?[1]:arguments,se=U instanceof vr,Pe=J[0],Ie=se||nr(U),Le=function(dr){var hr=B.apply(k,da([dr],J));return T&&Fe?hr[0]:hr};Ie&&m&&typeof Pe=="function"&&Pe.length!=1&&(se=Ie=!1);var Fe=this.__chain__,je=!!this.__actions__.length,Je=F&&!Fe,ur=se&&!je;if(!F&&Ie){U=ur?U:new vr(this);var er=c.apply(U,J);return er.__actions__.push({func:yu,args:[Le],thisArg:t}),new on(er,Fe)}return Je&&ur?c.apply(this,J):(er=this.thru(Le),Je?T?er.value()[0]:er.value():er)})}),nn(["pop","push","shift","sort","splice","unshift"],function(c){var v=Gs[c],m=/^(?:push|sort|unshift)$/.test(c)?"tap":"thru",T=/^(?:pop|shift)$/.test(c);k.prototype[c]=function(){var B=arguments;if(T&&!this.__chain__){var F=this.value();return v.apply(nr(F)?F:[],B)}return this[m](function(U){return v.apply(nr(U)?U:[],B)})}}),In(vr.prototype,function(c,v){var m=k[v];if(m){var T=m.name+"";wr.call(ki,T)||(ki[T]=[]),ki[T].push({name:v,func:m})}}),ki[fu(t,w).name]=[{name:"wrapper",func:t}],vr.prototype.clone=GD,vr.prototype.reverse=WD,vr.prototype.value=UD,k.prototype.at=wL,k.prototype.chain=xL,k.prototype.commit=EL,k.prototype.next=CL,k.prototype.plant=SL,k.prototype.reverse=TL,k.prototype.toJSON=k.prototype.valueOf=k.prototype.value=RL,k.prototype.first=k.prototype.head,To&&(k.prototype[To]=_L),k}),Mi=ED();Ua?((Ua.exports=Mi)._=Mi,hf._=Mi):vt._=Mi}).call(kq)})(Ko,Ko.exports)),Ko.exports}var pr=qq();const pl={label:"Untitled",description:"",isTask:!1,isLocked:!1},$m={id:null,type:"text",data:{...pl,viewProps:{width:"max-content !important",maxWidth:700,height:"100%",borderColor:"transparent",borderRadius:25,borderWidth:0,boxShadow:"none",textOverflow:"ellipsis",fontWeight:"bold",textColor:"gray.800",textAlign:"center"}}},rw={id:null,type:"objectView",data:{...pl,headerTitle:null,viewProps:{width:"100%",borderWidth:2,borderRadius:25,height:"100%",justifyContent:"space-between",flexDirection:"row",textColor:"gray.900"}}},Nq={id:null,type:"arrayView",data:{...pl,viewProps:{width:"max-content !important",maxWidth:700,height:"100%",textAlign:"center",borderRadius:25,fontSize:"5xl",borderWidth:2,textOverflow:"ellipsis",wordBreak:"keep-all",fontWeight:"bold",textColor:"gray.900",placeholder:"Start Typing"}}},tw={id:null,type:"workflowStep",data:{...pl,viewProps:{width:"max-content !important",maxWidth:350,minWidth:280,height:"100%",borderRadius:15,borderWidth:3}}};let Su;const Fq=new Uint8Array(16);function zq(){if(!Su&&(Su=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Su))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Su(Fq)}const pt=[];for(let r=0;r<256;++r)pt.push((r+256).toString(16).slice(1));function $q(r,e=0){return pt[r[e+0]]+pt[r[e+1]]+pt[r[e+2]]+pt[r[e+3]]+"-"+pt[r[e+4]]+pt[r[e+5]]+"-"+pt[r[e+6]]+pt[r[e+7]]+"-"+pt[r[e+8]]+pt[r[e+9]]+"-"+pt[r[e+10]]+pt[r[e+11]]+pt[r[e+12]]+pt[r[e+13]]+pt[r[e+14]]+pt[r[e+15]]}const Vq=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),nw={randomUUID:Vq};function Gq(r,e,t){if(nw.randomUUID&&!r)return nw.randomUUID();r=r||{};const n=r.random||(r.rng||zq)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,$q(n)}const Qt=r=>typeof r=="object",f2=r=>Array.isArray(r),Wq=["order","position","selected","locked","grabbed","grabbable","scratch"],Pa=r=>Object.entries(r).reduce((e,[t,n])=>(!Qt(n)&&!t.startsWith("$")&&(e[t]=n),e),{}),Vm=(r,e)=>typeof r=="string"&&r.startsWith("$")?bc(r,e):Qt(r)&&!f2(r)?Object.entries(r).reduce((t,[n,a])=>(typeof a=="string"&&a.startsWith("$")&&n==="..."?(delete t["..."],t[n]={...bc(a,e),...r}):typeof a=="string"&&a.startsWith("$")?t[n]=bc(a,e):t[n]=a,t),{}):r,Ia=r=>Object.entries(r).reduce((e,[t,n])=>(Qt(n)&&t&&n&&!t.startsWith("$")&&(Wq.includes(t)&&(t=t+"#"),e[t]=n),e),{}),ai=(r,e,{label:t,parent:n=void 0},a,i=null)=>(i!==null&&(Qt(i)||f2(i))&&(i=JSON.stringify(i,null,2)),{data:{parent:n,...r.data,id:e,text:t||"",label:t,code:i||null,type:r.type,description:a}}),Ca=(r,e,t=null,n=null,a=null,i=!1,o=null)=>({data:{id:Gq(),source:a?e:r,target:a?r:e,label:n||"",isInverted:a,isEdgeAnimated:i,parent:o}}),_n=(r,e=[])=>{const t={},n={};let a=[];if(r)for(const[i,o]of Object.entries(r))i.startsWith("$")&&i!=="$"?t[i.slice(1)]=o:i!=="$"?n[i]=o:i==="$"&&(a=o);return{newConfig:t,updatedObject:n,arrayObject:a}},Qi=(r,e)=>{let t=rw;const{view:n,borderColor:a,borderRadius:i,bgColor:o,textColor:s,fontSize:u,stepType:l}=e;r=n||r,l?t={...tw}:r==="object"?t=rw:r==="text"?t=$m:r==="array"?t=Nq:r==="workflowStep"&&(t={...tw});const f=t.data.viewProps;return t.data.viewProps={...f,borderRadius:i||(l?15:50),bgColor:o,borderColor:a,textColor:s,fontSize:u},t.data.config=e,{config:t}},ss=(r,e)=>(r=e.find(n=>n.data.id===r)?`${r}.#`:r,r),bc=(r,{ids:e,jsnObjct:t})=>{if(typeof r=="string"&&(r!=null&&r.startsWith("$"))){const n=r.replace("$","").replace("*","");r==null||r.endsWith("*");const a=e.find(s=>s.split(".").slice(-1)[0]===n||n===s);if(!a)return r;const i=Uq(a,t);return JSON.stringify(i).includes(r)?r:i||r}return r},Uq=(r,e)=>{let t=r.split(".").splice(1);return t=t[t.length-1]==="#"||t[t.length-1].includes("{")?t.slice(0,-2):t,(i=>t.reduce((o,s)=>{s=s.replace("[","").replace("]","");const{arrayObject:u}=_n(o);return o=u.length?u:o,o[s]},i))(e)};function to(r,e="root",t=[]){try{const{arrayObject:n}=_n(r);n.length&&(r=n);const a=Pa(r),i=Ia(r);return Qt(r)?(pr.isArray(r)||pr.isArray(r)&&e==="root"||!pr.isArray(r)&&Object.keys(a).length||e==="root")&&t.push(e):t.push(e),Object.keys(i).length&&!pr.isArray(r)?rs({chldPth:null,itrblObjct:i,nodes:t,path:e}):pr.isArray(r)&&r.forEach((o,s)=>{const u=Pa(o),l=Ia(o),{newConfig:f,arrayObject:d}=_n(o);let h=`${e}.${s}`;Qt(o)?Object.keys(u).length?(to(u,h,t),Object.keys(l).length&&!pr.isArray(o)&&rs({chldPth:h,itrblObjct:l,nodes:t,path:e})):Object.keys(l).length&&!pr.isArray(o)?rs({chldPth:h,itrblObjct:l,nodes:t,path:e}):pr.isArray(o)&&c2({chldPth:h,item:o,nodes:t,path:e}):t.push(h)}),{nodes:t}}catch{return{nodes:t}}}const rs=({chldPth:r,itrblObjct:e,nodes:t,path:n})=>Object.entries(e).forEach(([a,i],o)=>{const s=Pa(i),u=Ia(i),{newConfig:l,arrayObject:f}=_n(i);f.length&&(i=f),n.split(".").slice(0,2).join(".");let d=r?`${r}.${a}`:`${n}.${a}`;if(Qt(i)&&!pr.isArray(i)){const h=Object.keys(s).length===0;if(h&&(Qi("array",l),t.push(d)),Object.keys(s).length){const g=pr.isArray(i)?`${i.length||""}`:`{${Object.keys(i).length||""}}`;let p=d;h&&(p=`${d}.${g}`),to(i,p,t)}else Object.keys(u).length&&!pr.isArray(i)?rs({chldPth:d,itrblObjct:u,path:d,nodes:t}):to(i,d,t)}else pr.isArray(i)&&to(i,d,t)}),c2=({chldPth:r,item:e,nodes:t,path:n})=>e.forEach((a,i)=>{let o=`${r}.${i}`;const s=Ia(a),u=Pa(a);Qt(a)?!pr.isArray(a)&&Object.keys(u).length?to(a,o,t):Object.keys(s).length&&!pr.isArray(a)?rs({chldPth:o,itrblObjct:s,path:n,nodes:t}):pr.isArray(a)&&c2({chldPth:o,item:a,nodes:t,path:n}):t.push(o)}),Qu=[];let ts;function li(r,e="root",t=[],n=[],a="untitled",i={hideDefaultObject:!1,sprtObjctKy:!1,isCntr:!1},o={}){if(!r||typeof r!="object")return console.error("Invalid object passed",r),{nodes:t,edges:n};const s=r;if(!ts){const{nodes:f}=to(r);ts={ids:f,jsnObjct:r}}let{hideDefaultObject:u,sprtObjctKy:l}=i;try{e=ss(e,t);const{newConfig:f,arrayObject:d}=_n(r),h=Object.keys(o).length>0?o:f;d.length&&(r=d);const g=Pa(r),p=Ia(r),{label:x,collapsed:b,parent:w}=h;if(!Qt(r))t.push(ai($m,e,{label:x||e,parent:w},r,s));else if(pr.isArray(r)||pr.isArray(r)&&e==="root"){const{config:y}=Qi("array",h),E=pr.isArray(r)?`${r.length||""}`:`{${Object.keys(r).length||""}}`,C=e==="root"?a:`${a} ${E}`;t.push(ai(y,e,{label:x||C,parent:w},r,pr.isArray(s)?{[a]:s}:s))}else if(!pr.isArray(r)&&Object.keys(g).length||e==="root"){const{config:y}=Qi(null,h),E=pr.isArray(r)?`${r.length||""}`:`{${Object.keys(r).length||""}}`,C=e.split("."),S=C[C.length-1];let R=isNaN(Number(S))?null:Number(S)+1;const _=isNaN(Number(S))?S:C[C.length-2]+" "+R,A=e==="root"?a:_;let P=!1;Number.isNaN(Number(a))||(P=!0);const I=r;if(x){const{config:D}=Qi("object",h);t.push(ai(D,e,{label:x||`${x} ${E}`,parent:w},g,I))}else y.data.headerTitle=A,t.push(ai(y,e,{label:x,parent:w},g,I))}return b||(Object.keys(p).length&&!pr.isArray(r)?ns({flowConfig:i,chldPth:null,edges:n,isInverted:null,itrblObjct:p,nodes:t,path:e,newConfig:h}):pr.isArray(r)&&r.forEach((y,E)=>{y=Vm(y,ts);const C=y,S=Pa(y),R=Ia(y),{newConfig:_,arrayObject:A}=_n(y);A.length&&(y=A);const{config:P}=Qi(typeof y=="string"?"text":"array",_),{hideConfig:I,sourceLabel:D,label:L,isEdgeAnimated:M,parent:q}=_;u=u||I;const N=e==="root"&&i.isCntr,W=e.split(".").slice(0,2).join("."),V=Qu.includes(W),$=i.isCntr&&V||E%2===0&&N;let Z=`${e}.${E}`;Z=ss(Z,t),$&&Qu.push(Z),Qt(y)?Object.keys(S).length&&!pr.isArray(y)?(n.push(Ca(e,Z,null,D,$,M)),li(y,Z,t,n,L||E,i,_)):Object.keys(R).length&&!pr.isArray(y)?ns({flowConfig:i,chldPth:Z,isInverted:$,edges:n,itrblObjct:R,nodes:t,path:e,newConfig:_,forceIsInverted:!0}):pr.isArray(y)?d2({flowConfig:i,chldPth:Z,edges:n,isInverted:$,item:y,nodes:t,path:e}):Qt(y)&&ns({flowConfig:i,chldPth:Z,isInverted:$,edges:n,itrblObjct:[y],nodes:t,path:e,newConfig:_}):(n.push(Ca(e,Z,null,D,$,M)),t.push(ai(P,Z,{label:L||String(y),parent:q},y,C)))})),{nodes:t,edges:n}}catch{return{nodes:t,edges:n}}}const ns=({chldPth:r,flowConfig:e,edges:t,itrblObjct:n,nodes:a,isInverted:i,path:o,newConfig:s,forceIsInverted:u=!1})=>{let{hideDefaultObject:l,sprtObjctKy:f}=e;return Object.entries(n).forEach(([d,h],g)=>{h=Vm(h,ts);const p=h,x=Pa(h),b=Ia(h),{newConfig:w,arrayObject:y}=_n(h);y.length&&(h=y);const{hideConfig:E,sourceLabel:C,label:S,content:R,target:_,targetLabel:A,collapsed:P,isEdgeAnimated:I,parent:D}=w;l=l||E;const L=o==="root"&&e.isCntr,M=o.split(".").slice(0,2).join("."),q=Qu.includes(M);u||(i=e.isCntr&&q||g%2===0&&L);let N=r?`${r}.${d}`:`${o}.${d}`;if(N=ss(N,a),i&&Qu.push(N),_&&t.push(Ca(N,_,null,A,i,I)),Qt(h)&&!pr.isArray(h)){t.push(Ca(o,N,null,C,i,I));const W=f||Object.keys(x).length===0;if(W){const V=R?"object":"array",{config:$}=Qi(V,w);$.data.headerTitle=R?S:null,a.push(ai($,N,{label:S||d,parent:D},h,p))}if(Object.keys(x).length&&!l){const V=pr.isArray(h)?` ${h.length||""}`:`{${Object.keys(h).length||""}}`;let $=N;W&&($=`${N}.${V}`,$=ss($,a),t.push(Ca(N,$,null,C,i,I))),li(h,$,a,t,S||d,e,w)}else Object.keys(b).length&&!pr.isArray(h)?ns({chldPth:N,flowConfig:e,itrblObjct:b,path:N,edges:t,nodes:a,newConfig:w,isInverted:i}):li(h,N,a,t,d,e,w)}else pr.isArray(h)&&(t.push(Ca(o,N,null,C,i,I)),li(h,N,a,t,d,e,w))})},d2=({flowConfig:r,chldPth:e,edges:t,isInverted:n,item:a,nodes:i,path:o})=>a.forEach((s,u)=>{let l=`${e}.${u}`;l=ss(l,i);const f=s;s=Vm(s,ts);const d=Ia(s),h=Pa(s),{newConfig:g}=_n(s),{collapsed:p,label:x,parent:b,sourceLabel:w,isEdgeAnimated:y,content:E}=g;Qt(s)?!pr.isArray(s)&&Object.keys(h).length?(t.push(Ca(o,l,null,w,n,y)),li(s,l,i,t,u,r,g)):Object.keys(d).length&&!pr.isArray(s)&&!p?ns({chldPth:l,flowConfig:r,itrblObjct:d,path:o,edges:t,nodes:i,isInverted:n,newConfig:g}):pr.isArray(s)&&d2({flowConfig:r,chldPth:l,edges:t,isInverted:n,item:s,nodes:i,path:o}):(t.push(Ca(o,l,null,w,n,y)),i.push(ai($m,l,{label:x||String(s),parent:b},s,f)))}),yl="root",aw=r=>r==="#"||r.startsWith("{")||/^\s\d*$/.test(r);function fi(r){const e=r.split(".");for(e[0]===yl&&e.shift();e.length&&aw(e[e.length-1]);)e.pop();return e.filter(t=>!aw(t))}function Hq(r){if(r==null||typeof r!="object")return r;const{arrayObject:e}=_n(r);return Array.isArray(e)&&e.length?e:r}function mm(r,e){return fi(e).reduce((t,n)=>{var a;if(t!=null)return(a=Hq(t))==null?void 0:a[n]},r)}function Kq(r){return Array.isArray(r)?[...r]:{...r}}function pi(r,e,t){const n=fi(e),a=(i,o)=>{if(o===n.length)return t(i);const s=n[o],{arrayObject:u}=_n(i),l=Array.isArray(u)&&u.length>0,f=l?u:i;if(f==null||typeof f!="object")return i;const d=Kq(f);return d[s]=a(f[s],o+1),l?{...i,$:d}:d};return a(r,0)}function Gm(r,e,t){const n=t===""||t===void 0||t===null;if(Array.isArray(r))return n?r:{[e]:t,$:[...r]};const a=r!=null&&typeof r=="object"?{...r}:{};return r!=null&&typeof r!="object"&&(a.$label=String(r)),n?delete a[e]:a[e]=t,a}function no(r,e,t,n){return pi(r,e,a=>Gm(a,t,n))}const v2=(r,e,t)=>no(r,e,"$collapsed",t||void 0);function ml(r){const e=r.isInverted?r.target:r.source,t=r.isInverted?r.source:r.target,n=fi(e).join("."),a=fi(t).join(".");return a.startsWith(n?n+".":"")&&a!==n?{address:t,kind:"hierarchy"}:n.startsWith(a?a+".":"")&&n!==a?{address:e,kind:"hierarchy"}:{address:e,kind:"target"}}function us(r,e,t,n){const{address:a,kind:i}=ml(e),o=i==="target"&&t==="$sourceLabel"?"$targetLabel":t;return pi(r,a,s=>Gm(s,o,n))}const h2=(r,e,t)=>us(us(r,e,"$isEdgeAnimated",t==="animated"||void 0),e,"$isEdgeDashed",t==="dashed"||void 0);function g2(r,e,t,n){let a=n||"";const i=pi(r,e,s=>{const u=s!=null&&typeof s=="object"&&!Array.isArray(s)?{...s}:s!=null&&typeof s!="object"?{$label:String(s)}:{};if(Array.isArray(s))return a=String(s.length),[...s,t];if(!a){let l=1;for(;`node_${l}`in u;)l++;a=`node_${l}`}return u[a]=t,u}),o=fi(e);return{json:i,address:[yl,...o,a].join(".")}}function p2(r,e){const t=fi(e);if(!t.length)return r;const n=t[t.length-1],a=[yl,...t.slice(0,-1)].join(".");return pi(r,a,i=>{const{arrayObject:o}=_n(i);if(Array.isArray(o)&&o.length)return{...i,$:o.filter((l,f)=>String(f)!==n)};if(Array.isArray(i))return i.filter((l,f)=>String(f)!==n);const{[n]:s,...u}=i;return u})}const y2=(r,e,t,n)=>no(n?pi(r,e,a=>Gm(a,"$targetLabel",n)):r,e,"$target",t);function m2(r,e){const{address:t,kind:n}=ml(e);return n!=="target"?{json:r,removed:!1}:{json:pi(r,t,i=>{const{$target:o,$targetLabel:s,...u}=i||{};return u}),removed:!0}}function b2(r,e={}){const{nodes:t,edges:n}=li(r,yl,[],[],e.title||"untitled",{hideDefaultObject:!!e.hideDefaultObject,sprtObjctKy:!!e.separateObjectKeys,isCntr:!!e.isCenter}),a=t.map(s=>{const u=mm(r,s.data.id);if(!u||typeof u!="object"||Array.isArray(u))return s;const l={...s.data};return typeof u.$label=="string"&&(l.label=u.$label,l.headerTitle=u.$label),(u.$collapsed!==void 0||u.$icon!==void 0)&&(l.config={...l.config||{}},u.$collapsed!==void 0&&(l.config.collapsed=!!u.$collapsed),u.$icon!==void 0&&(l.config.icon=u.$icon)),{data:l}}),i=new Map,o=n.map(s=>{const u=`${s.data.source}->${s.data.target}`,l=i.get(u)??0;i.set(u,l+1);const f=mm(r,ml(s.data).address),d={...s.data,id:l?`${u}#${l}`:u};return f&&typeof f=="object"&&(f.$isEdgeAnimated!==void 0&&(d.isEdgeAnimated=!!f.$isEdgeAnimated),f.$isEdgeDashed!==void 0&&(d.isEdgeDashed=!!f.$isEdgeDashed),f.$edgeColor&&(d.color=f.$edgeColor)),{data:d}});return{nodes:a,edges:o}}function jq(r,e){const t=new Set(r.filter(i=>{var o,s;return(s=(o=i.data)==null?void 0:o.config)==null?void 0:s.collapsed}).map(i=>i.data.id));if(!t.size)return{nodes:r,edges:e};const n=new Map;for(const i of e){const o=i.data.isInverted?i.data.target:i.data.source,s=i.data.isInverted?i.data.source:i.data.target;(n.get(o)??n.set(o,[]).get(o)).push(s)}const a=new Set;for(const i of t){const o=[...n.get(i)||[]];for(;o.length;){const s=o.pop();t.has(s)||a.has(s)||(a.add(s),o.push(...n.get(s)||[]))}}return{nodes:r.filter(i=>!a.has(i.data.id)),edges:e.filter(i=>!a.has(i.data.source)&&!a.has(i.data.target))}}function Yq(r,e){const t=a=>r&&typeof r=="object"&&a in r;let n=1;for(;t(`${e}_${n}`);)n++;return`${e}_${n}`}function w2(r,e,t,n){const a=(o,s)=>{o!==r&&(n==null||n(o,s))},i=o=>{var u;const s=(u=e.find(l=>l.data.id===o))==null?void 0:u.data;return s&&{source:s.source,target:s.target,isInverted:s.isInverted}};return{...t,onNodeLabelChange:(o,s)=>{var u;(u=t.onNodeLabelChange)==null||u.call(t,o,s),a(no(r,o,"$label",s),{type:"nodeLabel",address:o,key:"$label",value:s})},onNodeColorChange:(o,s,u)=>{var f;(f=t.onNodeColorChange)==null||f.call(t,o,s,u);const l=s==="bg"?"$bgColor":"$textColor";a(no(r,o,l,u),{type:"nodeColor",address:o,key:l,value:u})},onNodeIconChange:(o,s)=>{var u;(u=t.onNodeIconChange)==null||u.call(t,o,s),a(no(r,o,"$icon",s),{type:"nodeIcon",address:o,key:"$icon",value:s})},onNodeCollapse:(o,s)=>{var u;(u=t.onNodeCollapse)==null||u.call(t,o,s),a(v2(r,o,s),{type:"nodeCollapse",address:o,key:"$collapsed",value:s})},onNodeCreate:o=>{var d;(d=t.onNodeCreate)==null||d.call(t,o);const s=o.sourceNodeId||"root",l=Yq(s==="root"?r:void 0,o.isArrayMode?"list":"node"),f=g2(r,s,o.isArrayMode?[]:{},l);a(f.json,{type:"nodeCreate",address:f.address,value:o.isArrayMode?"array":"set"})},onNodeDelete:(o,s)=>{var u;(u=t.onNodeDelete)==null||u.call(t,o,s),a(p2(r,o),{type:"nodeDelete",address:o})},onEdgeCreate:(o,s)=>{var u;(u=t.onEdgeCreate)==null||u.call(t,o,s),a(y2(r,o,s),{type:"edgeCreate",address:o,key:"$target",value:s})},onEdgeLabelChange:(o,s)=>{var l;(l=t.onEdgeLabelChange)==null||l.call(t,o,s);const u=i(o);u&&a(us(r,u,"$sourceLabel",s),{type:"edgeLabel",edge:u,key:"$sourceLabel",value:s})},onEdgeStyleChange:(o,s)=>{var l;(l=t.onEdgeStyleChange)==null||l.call(t,o,s);const u=i(o);u&&a(h2(r,u,s),{type:"edgeStyle",edge:u,value:s})},onEdgeColorChange:(o,s)=>{var l;(l=t.onEdgeColorChange)==null||l.call(t,o,s);const u=i(o);u&&a(us(r,u,"$edgeColor",s),{type:"edgeColor",edge:u,key:"$edgeColor",value:s})},onEdgeDelete:(o,s)=>{var f;(f=t.onEdgeDelete)==null||f.call(t,o,s);const u=i(o);if(!u)return;const l=m2(r,u);l.removed&&a(l.json,{type:"edgeDelete",edge:u,key:"$target"})}}}const x2=xe.createContext(null),E2=xe.createContext({nodeById:new Map,edgeById:new Map});function Wm(){return xe.useContext(E2)}function en(){const r=xe.useContext(x2);if(!r)throw new Error("useFlowDiagramContext must be used within FlowDiagram");return r}function Zq({config:r,callbacks:e,nodes:t=[],edges:n=[],children:a}){const i=xe.useMemo(()=>{var te,ue;const z=new Map;for(const oe of t)(te=oe.data)!=null&&te.id&&z.set(oe.data.id,oe);const Y=new Map;for(const oe of n)(ue=oe.data)!=null&&ue.id&&Y.set(oe.data.id,oe);return{nodeById:z,edgeById:Y}},[t,n]),o=xe.useRef(null),[s,u]=xe.useState([]),[l,f]=xe.useState(null),[d,h]=xe.useState(!0),[g,p]=xe.useState(!1),[x,b]=xe.useState(!0),[w,y]=xe.useState(r.edgeHandles===!0),[E,C]=xe.useState(!1),[S,R]=xe.useState(!0),[_,A]=xe.useState(!1),P=xe.useRef(e);P.current=e;const I=xe.useMemo(()=>{const z=Y=>(...te)=>{var ue,oe;return(oe=(ue=P.current)==null?void 0:ue[Y])==null?void 0:oe.call(ue,...te)};return{onNodeSelect:z("onNodeSelect"),onNodeDeselect:z("onNodeDeselect"),onNodeDoubleClick:z("onNodeDoubleClick"),onNodeCreate:z("onNodeCreate"),onNodeDelete:z("onNodeDelete"),onNodeLabelChange:z("onNodeLabelChange"),onNodeCollapse:z("onNodeCollapse"),onNodeColorChange:z("onNodeColorChange"),onNodeIconChange:z("onNodeIconChange"),onNodeHoverAction:z("onNodeHoverAction"),onEdgeCreate:z("onEdgeCreate"),onEdgeSelect:z("onEdgeSelect"),onEdgeDeselect:z("onEdgeDeselect"),onEdgeRemove:z("onEdgeRemove"),onEdgeDelete:z("onEdgeDelete"),onEdgeColorChange:z("onEdgeColorChange"),onEdgeLabelChange:z("onEdgeLabelChange"),onEdgeStyleChange:z("onEdgeStyleChange"),onViewportChange:z("onViewportChange"),onDirectionChange:z("onDirectionChange"),onArrayModeChange:z("onArrayModeChange"),onCyInit:z("onCyInit"),onJsonChange:z("onJsonChange")}},[]),D=r.themeColor||"blue.500",L=r.edgeColor||"",M=r.colorMode||"light",q=r.direction||"LR",N=r.readOnly??!1,W=JSON.stringify(r.parentNodeStyle??null),V=xe.useMemo(()=>r.parentNodeStyle,[W]),$=r.isZoomMode!==void 0?r.isZoomMode:d,Z=r.isMultiSelectMode!==void 0?r.isMultiSelectMode:g,ee=r.isEdgeHandlesEnabled!==void 0?r.isEdgeHandlesEnabled:w,K=r.isDragMode!==void 0?r.isDragMode:x,j=xe.useRef(r);j.current=r;const fe=xe.useMemo(()=>({get direction(){return j.current.direction},get themeColor(){return j.current.themeColor},get colorMode(){return j.current.colorMode},get readOnly(){return j.current.readOnly},get editable(){return j.current.editable},get minZoom(){return j.current.minZoom},get maxZoom(){return j.current.maxZoom},get backgroundPattern(){return j.current.backgroundPattern},get edgeColor(){return j.current.edgeColor},get parentNodeStyle(){return j.current.parentNodeStyle},get backgroundColor(){return j.current.backgroundColor},get edgeHandles(){return j.current.edgeHandles},get initialViewport(){return j.current.initialViewport},get nodeOverlayActions(){return j.current.nodeOverlayActions},get renderNodeOverlay(){return j.current.renderNodeOverlay},get renderSelectedNodeToolbar(){return j.current.renderSelectedNodeToolbar},get renderSelectedEdgeToolbar(){return j.current.renderSelectedEdgeToolbar},get renderBottomBar(){return j.current.renderBottomBar},get selectionToolbar(){return j.current.selectionToolbar},get customViews(){return j.current.customViews},get disableKeyboardShortcuts(){return j.current.disableKeyboardShortcuts},get isZoomMode(){return j.current.isZoomMode},get isMultiSelectMode(){return j.current.isMultiSelectMode},get isEdgeHandlesEnabled(){return j.current.isEdgeHandlesEnabled},get isDragMode(){return j.current.isDragMode}}),[]),G=xe.useMemo(()=>({themeColor:D,edgeColor:L,colorMode:M,direction:q,parentNodeStyle:V,selectedNodeIds:s,setSelectedNodeIds:u,selectedEdgeId:l,setSelectedEdgeId:f,isZoomMode:$,setIsZoomMode:h,isMultiSelectMode:Z,setIsMultiSelectMode:p,isDragMode:K,setIsDragMode:b,isEdgeHandlesEnabled:ee,setIsEdgeHandlesEnabled:y,isArrayNodeMode:E,setIsArrayNodeMode:C,isPinned:S,setIsPinned:R,isPerformanceMode:_,setIsPerformanceMode:A,cyRef:o,callbacks:I,config:fe,readOnly:N}),[D,L,M,q,V,s,l,$,Z,K,ee,E,S,_,N,I,fe]);return H.jsx(x2.Provider,{value:G,children:H.jsx(E2.Provider,{value:i,children:a})})}function Ju(r,e=.2){const t=r.replace(/^#/,""),n=parseInt(t,16);let a=n>>16&255,i=n>>8&255,o=n&255;return a=Math.max(0,Math.floor(a*(1-e))),i=Math.max(0,Math.floor(i*(1-e))),o=Math.max(0,Math.floor(o*(1-e))),"#"+((1<<24)+(a<<16)+(i<<8)+o).toString(16).slice(1).toUpperCase()}function Xq(r,e,t){const n=s=>{const u=/^#?([0-9a-f]{6})$/i.exec((s==null?void 0:s.trim())??"");return u?parseInt(u[1],16):null},a=n(r),i=n(e);if(a===null||i===null)return null;const o=s=>Math.round((a>>s&255)*(1-t)+(i>>s&255)*t);return"#"+((1<<24)+(o(16)<<16)+(o(8)<<8)+o(0)).toString(16).slice(1).toUpperCase()}const kn=r=>r!=null&&r.startsWith("#")?{background:r,highlight:Ju(r,.1),border:Ju(r,.5),property:"gray.900",boolean:"green.200",string:"gray.900",number:"orange.800"}:r==="gray"?{background:"gray.950",highlight:"gray.800",border:"gray.700",property:"gray.200",boolean:"green.400",string:"gray.200",number:"orange.600"}:r==="white"?{background:"white",highlight:"gray.200",border:"gray.400",property:"gray.900",boolean:"green.400",string:"gray.900",number:"orange.600"}:{background:r+".100",highlight:r+".200",border:r+".700",property:"gray.900",boolean:"green.800",string:"gray.900",number:"orange.800"},C2=r=>{let e=r;if(e!=null&&e.startsWith("#"))return{secondary:Ju(r)};let t=String(Number(r.slice(-3))+200);t=r.slice(0,-3).concat(t);let n=String(Number(r.slice(-3))-100);return n=r.slice(0,-3).concat(n),{primary:e,secondary:t,light:n}},iw={red:{50:"#FFF5F5",100:"#FED7D7",200:"#FEB2B2",300:"#FC8181",400:"#F56565",500:"#E53E3E",600:"#C53030",700:"#9B2C2C",800:"#822727",900:"#63171B"},orange:{50:"#FFFAF0",100:"#FEEBC8",200:"#FBD38D",300:"#F6AD55",400:"#ED8936",500:"#DD6B20",600:"#C05621",700:"#9C4221",800:"#7B341E",900:"#652B19"},yellow:{50:"#FFFFF0",100:"#FEFCBF",200:"#FAF089",300:"#F6E05E",400:"#ECC94B",500:"#D69E2E",600:"#B7791F",700:"#975A16",800:"#744210",900:"#5F370E"},green:{50:"#F0FFF4",100:"#C6F6D5",200:"#9AE6B4",300:"#68D391",400:"#48BB78",500:"#38A169",600:"#2F855A",700:"#276749",800:"#22543D",900:"#1C4532"},teal:{50:"#E6FFFA",100:"#B2F5EA",200:"#81E6D9",300:"#4FD1C5",400:"#38B2AC",500:"#319795",600:"#2C7A7B",700:"#285E61",800:"#234E52",900:"#1D4044"},blue:{50:"#EBF8FF",100:"#BEE3F8",200:"#90CDF4",300:"#63B3ED",400:"#4299E1",500:"#3182CE",600:"#2B6CB0",700:"#2C5282",800:"#2A4365",900:"#1A365D"},cyan:{50:"#EDFDFD",100:"#C4F1F9",200:"#9DECF9",300:"#76E4F7",400:"#0BC5EA",500:"#00B5D8",600:"#00A3C4",700:"#0987A0",800:"#086F83",900:"#065666"},purple:{50:"#FAF5FF",100:"#E9D8FD",200:"#D6BCFA",300:"#B794F4",400:"#9F7AEA",500:"#805AD5",600:"#6B46C1",700:"#553C9A",800:"#44337A",900:"#322659"},pink:{50:"#FFF5F7",100:"#FED7E2",200:"#FBB6CE",300:"#F687B3",400:"#ED64A6",500:"#D53F8C",600:"#B83280",700:"#97266D",800:"#702459",900:"#521B41"},gray:{50:"#F7FAFC",100:"#EDF2F7",200:"#E2E8F0",300:"#CBD5E0",400:"#A0AEC0",500:"#718096",600:"#4A5568",700:"#2D3748",800:"#1A202C",900:"#171923",950:"#0d1117"}},zr=(r,e)=>{var i;if(r!=null&&r.startsWith("#"))return r;if(!r)return"whitesmoke";const t=r.replace(/\./g,"-");try{const s=getComputedStyle(document.documentElement).getPropertyValue(`--chakra-colors-${t}`).trim();if(s&&s!=="")return s}catch{}const[n,a]=r.split(".");return n&&a&&((i=iw[n])!=null&&i[Number(a)])?iw[n][Number(a)]:`var(--chakra-colors-${t})`};function gt(r,e,t){return r?t:e}function bs(r){const[e]=(r==null?void 0:r.split("."))||[],{secondary:t}=C2(r),n=kn(e).background,a=kn(e).highlight,i=kn(e).border,o=kn(e).property,s=kn(e).property;let u=kn(e).background,l=kn(e).highlight;return u=zr(u)+50,l=zr(l)+20,{bgColor:n,highlightColor:a,borderColor:i,textColor:o,propertyColor:s,secondary:t,bgColorFaint:u,highlightColorFaint:l}}function Rn(r=null){const{colorMode:e}=en(),t=r==null?void 0:r.includes("gray"),n=e==="dark",a=gt(n,"white","gray.900"),i=gt(n,"gray.100","gray.800"),o=gt(n,"gray.200","blackAlpha.400"),s=gt(n,"gray.200","blackAlpha.600"),u=gt(n,"gray.500","gray.700"),l=gt(n,"gray.700","gray.700"),f=gt(n,"gray.900","gray.900"),d=gt(n,"gray.400","gray.500"),h=gt(n,"gray.400","gray.700"),g=gt(n,"gray.900","gray.200"),p=gt(n,t?"gray.900":"gray.200",t?"gray.200":"gray.900"),x=gt(n,"gray.900","gray.200"),b=gt(n,r&&"#000000",r||"#ffffff"),w=gt(n,r||"#ffffff",r?"#000000":"#ffffff"),y=l,E=gt(n,"gray.300","gray.800"),C=gt(n,"white","blackAlpha.400"),S=gt(n,"green.100","green.700");return{canvas:a,background:i,backgroundSecondary:o,darkBackgroundSecondary:s,border:u,darkColor:f,backgroundWhiteColor:C,borderSecondary:l,colorActive:d,colorInactive:h,iconColor:x,moreIconColor:y,colorText:g,themedColorText:p,logoColor:b,logoColorSecondary:w,darkColorActive:E,greenColor:S}}var jo=(r=>(r.TOP_DOWN="TB",r.BOTTOM_UP="BT",r.LEFT_RIGHT="LR",r.RIGHT_LEFT="RL",r.CENTER="C",r))(jo||{});function rt({label:r,children:e}){if(!Re.Tooltip.Root){const t=Re.Tooltip;return H.jsx(t,{label:r,placement:"top",fontSize:"xs",children:e})}return H.jsxs(Re.Tooltip.Root,{positioning:{placement:"top"},children:[H.jsx(Re.Tooltip.Trigger,{asChild:!0,children:e}),H.jsx(Re.Tooltip.Positioner,{children:H.jsx(Re.Tooltip.Content,{fontSize:"xs",children:r})})]})}function yt({icon:r,...e}){return H.jsx(Re.IconButton,{...e,children:r})}const Qq=["blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500"],Jq=["gray.900","gray.600","gray.200","white"];function _2(){const{config:r}=en(),e=r.selectionToolbar||{},t=new Set(e.hide||[]);return{palette:e.palette||Qq,show:n=>!t.has(n)}}function qn(){const{border:r}=Rn();return H.jsx(Re.Icon,{mx:-1,as:rr.PiLineVerticalThin,boxSize:5,color:r})}function S2({onClick:r}){const{colorText:e}=Rn();return H.jsx(rt,{label:"Close",children:H.jsx(yt,{"aria-label":"Close selection tools",icon:H.jsx(Re.Icon,{as:rr.PiX,boxSize:5}),size:"sm",variant:"ghost",color:e,onClick:r})})}function bm({value:r,placeholder:e,ariaLabel:t,width:n="140px",onCommit:a}){const{colorText:i,border:o}=Rn(),[s,u]=xe.useState(r);xe.useEffect(()=>u(r),[r]);const l=()=>{const f=s.trim();f!==r&&a(f)};return H.jsx(Re.Input,{"aria-label":t,size:"xs",w:n,value:s,placeholder:e,color:i,borderColor:o,borderRadius:"8px",onChange:f=>u(f.target.value),onBlur:l,onKeyDown:f=>{f.key==="Enter"&&(l(),f.target.blur()),f.key==="Escape"&&(u(r),f.target.blur())}})}function wm({colors:r,value:e,label:t,onPick:n,onReset:a}){const{colorInactive:i}=Rn();return H.jsxs(Re.HStack,{gap:1,"aria-label":t,role:"group",children:[r.map(o=>{const s=e===o;return H.jsx(rt,{label:`${t}: ${o}`,children:H.jsx(Re.Box,{as:"button","aria-label":`${t} ${o}`,"aria-pressed":s,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:zr(o)},outline:s?"2px solid white":"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>n(o)})},o)}),a&&H.jsx(rt,{label:`Reset ${t.toLowerCase()}`,children:H.jsx(yt,{"aria-label":`Reset ${t}`,icon:H.jsx(Re.Icon,{as:rr.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:i,onClick:a})})]})}function eN({edgeId:r,onClose:e}){var d;const{callbacks:t,themeColor:n}=en(),{colorInactive:a}=Rn(),{edgeById:i}=Wm(),{palette:o,show:s}=_2(),u=(d=i.get(r))==null?void 0:d.data,l=u!=null&&u.isEdgeAnimated?"animated":u!=null&&u.isEdgeDashed?"dashed":"solid",f=[{key:"solid",icon:rr.PiLineSegment,label:"Solid"},{key:"dashed",icon:rr.PiLineSegments,label:"Dashed"},{key:"animated",icon:rr.PiFastForward,label:"Animated"}];return H.jsxs(H.Fragment,{children:[H.jsx(S2,{onClick:e}),s("label")&&H.jsxs(H.Fragment,{children:[H.jsx(qn,{}),H.jsx(bm,{ariaLabel:"Edge label",placeholder:"Edge label",value:(u==null?void 0:u.label)||"",onCommit:h=>{var g;return(g=t.onEdgeLabelChange)==null?void 0:g.call(t,r,h)}})]}),s("style")&&H.jsxs(H.Fragment,{children:[H.jsx(qn,{}),f.map(h=>H.jsx(rt,{label:h.label,children:H.jsx(yt,{"aria-label":`Edge style ${h.key}`,"aria-pressed":l===h.key,icon:H.jsx(Re.Icon,{as:h.icon,boxSize:5}),size:"sm",variant:"ghost",color:l===h.key?n:a,onClick:()=>{var g;return(g=t.onEdgeStyleChange)==null?void 0:g.call(t,r,h.key)}})},h.key))]}),s("color")&&H.jsxs(H.Fragment,{children:[H.jsx(qn,{}),H.jsx(wm,{label:"Edge color",colors:o,value:u==null?void 0:u.color,onPick:h=>{var g;return(g=t.onEdgeColorChange)==null?void 0:g.call(t,r,h)},onReset:()=>{var h;return(h=t.onEdgeColorChange)==null?void 0:h.call(t,r,"")}})]}),s("delete")&&H.jsxs(H.Fragment,{children:[H.jsx(qn,{}),H.jsx(rt,{label:"Delete edge",children:H.jsx(yt,{"aria-label":"Delete edge",icon:H.jsx(Re.Icon,{as:rr.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var h;(h=t.onEdgeDelete)==null||h.call(t,r,u),e()}})})]})]})}function rN({ids:r,onClose:e}){var g,p,x,b,w;const{callbacks:t,colorMode:n}=en(),{colorText:a,colorInactive:i}=Rn(),{nodeById:o}=Wm(),{palette:s,show:u}=_2(),l=r.length===1,f=l?(g=o.get(r[0]))==null?void 0:g.data:void 0,d=(p=f==null?void 0:f.config)==null?void 0:p.collapsed,h=y=>r.forEach(y);return H.jsxs(H.Fragment,{children:[H.jsx(S2,{onClick:e}),H.jsx(qn,{}),l&&u("label")?H.jsx(bm,{ariaLabel:"Node label",placeholder:"Node label",value:(f==null?void 0:f.label)??(f==null?void 0:f.headerTitle)??"",onCommit:y=>{var E;return(E=t.onNodeLabelChange)==null?void 0:E.call(t,r[0],y)}}):H.jsxs(Re.Text,{fontSize:"xs",color:a,whiteSpace:"nowrap",px:1,children:[r.length," selected"]}),u("color")&&H.jsxs(H.Fragment,{children:[H.jsx(qn,{}),H.jsx(wm,{label:"Background",colors:s,value:(x=f==null?void 0:f.viewProps)==null?void 0:x.bgColor,onPick:y=>h(E=>{var C;return(C=t.onNodeColorChange)==null?void 0:C.call(t,E,"bg",y)}),onReset:()=>h(y=>{var E;return(E=t.onNodeColorChange)==null?void 0:E.call(t,y,"bg","")})})]}),u("textColor")&&H.jsxs(H.Fragment,{children:[H.jsx(qn,{}),H.jsx(wm,{label:"Text color",colors:Jq,value:(b=f==null?void 0:f.viewProps)==null?void 0:b.textColor,onPick:y=>h(E=>{var C;return(C=t.onNodeColorChange)==null?void 0:C.call(t,E,"text",y)}),onReset:()=>h(y=>{var E;return(E=t.onNodeColorChange)==null?void 0:E.call(t,y,"text","")})})]}),l&&u("icon")&&H.jsxs(H.Fragment,{children:[H.jsx(qn,{}),H.jsx(bm,{ariaLabel:"Node icon",placeholder:"Icon (e.g. PiGear)",width:"120px",value:((w=f==null?void 0:f.config)==null?void 0:w.icon)||"",onCommit:y=>{var E;return(E=t.onNodeIconChange)==null?void 0:E.call(t,r[0],y)}})]}),l&&u("collapse")&&d!==void 0&&H.jsxs(H.Fragment,{children:[H.jsx(qn,{}),H.jsx(rt,{label:d?"Expand":"Collapse",children:H.jsx(yt,{"aria-label":d?"Expand node":"Collapse node",icon:H.jsx(Re.Icon,{as:d?rr.PiArrowsOutLineVertical:rr.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:i,onClick:()=>{var y;return(y=t.onNodeCollapse)==null?void 0:y.call(t,r[0],!d)}})})]}),u("delete")&&H.jsxs(H.Fragment,{children:[H.jsx(qn,{}),H.jsx(rt,{label:l?"Delete node":`Delete ${r.length} nodes`,children:H.jsx(yt,{"aria-label":"Delete selected nodes",icon:H.jsx(Re.Icon,{as:rr.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:n==="dark"?"red.300":"red.500",onClick:()=>{h(y=>{var E,C;return(C=t.onNodeDelete)==null?void 0:C.call(t,y,((E=o.get(y))==null?void 0:E.data)||{id:y})}),e()}})})]})]})}const tN=[{value:"BT",label:"Bottom to Up",icon:rr.PiArrowUp,flowType:jo.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:rr.PiArrowDown,flowType:jo.TOP_DOWN},{value:"LR",label:"Left to Right",icon:rr.PiArrowRight,flowType:jo.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:rr.PiArrowLeft,flowType:jo.RIGHT_LEFT}],T2=()=>{const{cyRef:r,themeColor:e,direction:t,selectedNodeIds:n,setSelectedNodeIds:a,selectedEdgeId:i,setSelectedEdgeId:o,isZoomMode:s,setIsZoomMode:u,isMultiSelectMode:l,setIsMultiSelectMode:f,isDragMode:d,setIsDragMode:h,isEdgeHandlesEnabled:g,setIsEdgeHandlesEnabled:p,isArrayNodeMode:x,setIsArrayNodeMode:b,isPinned:w,setIsPinned:y,callbacks:E,config:C,readOnly:S}=en(),{nodeById:R}=Wm(),_=C.colorMode==="dark",{background:A,border:P,colorInactive:I,colorText:D,colorActive:L,darkBackgroundSecondary:M}=Rn(),[q,N]=xe.useState(!0),[W,V]=xe.useState(!1),[$,Z]=xe.useState(!0),[ee,K]=xe.useState(!1),[j,fe]=xe.useState(!0);xe.useEffect(()=>{const Se=()=>Z(window.innerWidth>=768);return Se(),window.addEventListener("resize",Se),()=>window.removeEventListener("resize",Se)},[]),xe.useEffect(()=>{if(!$){N(!0);return}if(!w){N(!1);return}const Se=re=>{N(window.innerHeight-re.clientY<=250)},Ee=()=>N(!1);return window.addEventListener("mousemove",Se),window.addEventListener("mouseleave",Ee),()=>{window.removeEventListener("mousemove",Se),window.removeEventListener("mouseleave",Ee)}},[$,w]);const G=xe.useCallback(Se=>{const Ee=r.current;if(!Ee)return;const re=C.minZoom??.01,ce=C.maxZoom??1.5,_e=.02,me=Ee.zoomingEnabled(),Te=Ee.userZoomingEnabled();Ee.zoomingEnabled(!0),Ee.userZoomingEnabled(!0);let De=Ee.zoom();switch(Se){case"increase":De=Math.min(ce,De+_e),Ee.zoom(De),Ee.center();break;case"decrease":De=Math.max(re,De-_e),Ee.zoom(De),Ee.center();break;case"reset":Ee.fit(void 0,50);break}Ee.zoomingEnabled(me),Ee.userZoomingEnabled(Te)},[r,C.minZoom,C.maxZoom]),z=C.renderSelectedNodeToolbar,Y=n.length>0&&!!z,te=xe.useMemo(()=>{if(!Y)return[];const Se=r.current;return n.map(Ee=>{var _e;const re=Se==null?void 0:Se.getElementById(Ee);return{...((_e=R.get(Ee))==null?void 0:_e.data)??(re!=null&&re.length?re.data():{id:Ee}),isParent:!!(re!=null&&re.length)&&re.isParent()}})},[Y,n,r,R]),ue=xe.useCallback(()=>{var Se;a([]),(Se=E.onNodeDeselect)==null||Se.call(E)},[a,E]),oe=C.renderSelectedEdgeToolbar,X=!!i&&!!oe,Q=xe.useMemo(()=>{if(!X||!i)return null;const Se=r.current;if(!Se)return{id:i};const Ee=Se.getElementById(i);return Ee!=null&&Ee.length?Ee.data():{id:i}},[X,i,r]),ie=xe.useCallback(()=>{var Ee;o(null);const Se=r.current;Se&&Se.edges().unselect(),(Ee=E.onEdgeDeselect)==null||Ee.call(E)},[o,r,E]),de=C.selectionToolbar!==!1&&!S,we=de&&!!i&&!oe,Ae=de&&!we&&n.length>0&&!z,ve=we||Ae,le=q||W||ee||ve,Me=C.renderBottomBar;return Me?H.jsxs(H.Fragment,{children:[Y&&H.jsx(Re.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:z({selectedNodeIds:n,selectedNodeData:te,onDeselect:ue})}),X&&Q&&H.jsx(Re.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:oe({edgeId:i,edgeData:Q,onDeselect:ie})}),H.jsx(Re.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:Me({zoomIn:()=>G("increase"),zoomOut:()=>G("decrease"),resetZoom:()=>G("reset"),direction:t,isZoomMode:s,setIsZoomMode:u,isMultiSelectMode:l,setIsMultiSelectMode:f,isDragMode:d,setIsDragMode:h,isEdgeHandlesEnabled:g,setIsEdgeHandlesEnabled:p,isArrayNodeMode:x,setIsArrayNodeMode:b,selectedNodeIds:n,selectedNodeData:te,selectedEdgeId:i,selectedEdgeData:Q,onNodeDeselect:ue,onEdgeDeselect:ie,callbacks:E})})]}):H.jsxs(H.Fragment,{children:[Y&&H.jsx(Re.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:z({selectedNodeIds:n,selectedNodeData:te,onDeselect:ue})}),X&&Q&&H.jsx(Re.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:oe({edgeId:i,edgeData:Q,onDeselect:ie})}),!w&&H.jsx(Re.Box,{position:"absolute",bottom:5,left:0,zIndex:101,w:3,children:H.jsx(rt,{label:"Show Bottom Bar",children:H.jsx(Re.Flex,{align:"center",bg:A,borderColor:P,borderWidth:1,py:6,px:0,w:4,h:50,borderRadius:"15px",borderLeftRadius:0,onMouseEnter:()=>{V(!0),N(!0)},onMouseLeave:()=>V(!1),_hover:{bg:M},children:H.jsx(Re.Icon,{ml:-1,as:rr.PiLineVerticalBold,boxSize:5,color:P})})})}),H.jsx(Re.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",transition:"opacity 0.3s ease-in, transform 0.3s ease",transform:le?"translateY(0)":"translateY(100%)",pointerEvents:le?"auto":"none",opacity:le?1:0,onMouseEnter:()=>{w||N(!0)},onMouseLeave:()=>{w||(N(!1),V(!1))},children:H.jsxs(Re.Flex,{w:"100%",px:5,position:"absolute",bottom:5,flexDirection:"row",justifyContent:"space-between",alignItems:"center",children:[H.jsx(Re.Box,{bg:A,alignContent:"center",h:50,borderColor:P,borderWidth:1,borderRadius:"15px",children:H.jsx(Re.HStack,{px:2,gap:1,children:we?H.jsx(eN,{edgeId:i,onClose:ie}):Ae?H.jsx(rN,{ids:n,onClose:ue}):H.jsxs(H.Fragment,{children:[H.jsx(rt,{label:w?"Unpin":"Pin",children:H.jsx(yt,{"aria-label":"Pin",icon:H.jsx(Re.Icon,{as:w?rr.PiPushPinFill:rr.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:w?e:I,onClick:()=>{const Se=!w;y(Se),N(Se)}})}),H.jsx(Re.Icon,{mx:-1,as:rr.PiLineVerticalThin,boxSize:5,color:P}),H.jsx(rt,{label:"Zoom Out",children:H.jsx(yt,{"aria-label":"Zoom out",icon:H.jsx(Re.Icon,{as:rr.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:D,onClick:()=>G("decrease")})}),H.jsx(rt,{label:"Zoom In",children:H.jsx(yt,{"aria-label":"Zoom in",icon:H.jsx(Re.Icon,{as:rr.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:D,onClick:()=>G("increase")})}),H.jsx(rt,{label:"Reset Zoom",children:H.jsx(yt,{"aria-label":"Reset zoom",icon:H.jsx(Re.Icon,{as:rr.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:D,onClick:()=>G("reset")})}),!j&&H.jsxs(H.Fragment,{children:[H.jsx(Re.Icon,{mx:-1,as:rr.PiLineVerticalThin,boxSize:5,color:P}),H.jsx(rt,{label:s?"Zoom Mode (z)":"Pan Mode (z)",children:H.jsx(yt,{"aria-label":"Toggle zoom mode",icon:H.jsx(Re.Icon,{as:s?rr.PiMagnifyingGlassPlus:rr.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:s?e:I,onClick:()=>u(!s)})}),H.jsx(Re.Icon,{mx:-1,as:rr.PiLineVerticalThin,boxSize:5,color:P}),H.jsx(rt,{label:l?"Multi-Select On (m)":"Multi-Select Off (m)",children:H.jsx(yt,{"aria-label":"Toggle multi-select",icon:H.jsx(Re.Icon,{as:rr.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:l?e:I,onClick:()=>f(!l)})}),H.jsx(Re.Icon,{mx:-1,as:rr.PiLineVerticalThin,boxSize:5,color:P}),H.jsx(rt,{label:d?"Drag Mode On (d)":"Drag Mode Off (d)",children:H.jsx(yt,{"aria-label":"Toggle drag mode",icon:H.jsx(Re.Icon,{as:rr.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:d?e:I,onClick:()=>h(!d)})}),C.edgeHandles!==!1&&H.jsxs(H.Fragment,{children:[H.jsx(Re.Icon,{mx:-1,as:rr.PiLineVerticalThin,boxSize:5,color:P}),H.jsx(rt,{label:g?"Draw Mode On":"Draw Mode Off",children:H.jsx(yt,{"aria-label":"Toggle draw mode",icon:H.jsx(Re.Icon,{as:rr.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:g?e:I,onClick:()=>p(!g)})})]}),H.jsx(Re.Icon,{mx:-1,as:rr.PiLineVerticalThin,boxSize:5,color:P}),H.jsx(rt,{label:x?"Array Mode [ ]":"Set Mode { }",children:H.jsx(yt,{"aria-label":"Toggle array mode",icon:H.jsx(Re.Icon,{as:x?rr.PiBracketsSquare:rr.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:x?e:I,onClick:()=>{var Ee;const Se=!x;b(Se),(Ee=E.onArrayModeChange)==null||Ee.call(E,Se)}})})]}),H.jsx(Re.Icon,{mx:-1,as:rr.PiLineVerticalThin,boxSize:5,color:P}),H.jsx(rt,{label:j?"Expand toolbar":"Collapse toolbar",children:H.jsx(yt,{"aria-label":"Toggle toolbar collapse",icon:H.jsx(Re.Icon,{as:j?rr.PiCaretRight:rr.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:I,onClick:()=>fe(!j)})})]})})}),!ve&&H.jsxs(Re.Box,{position:"relative",ml:"auto",onMouseLeave:()=>K(!1),children:[H.jsx(Re.Box,{bg:A,borderWidth:1,borderColor:P,borderRadius:"15px",h:50,px:3,cursor:"pointer",onClick:()=>K(!ee),children:H.jsxs(Re.Flex,{align:"center",h:"100%",children:[H.jsx(rt,{label:"Flow Direction",children:H.jsx(yt,{"aria-label":"Direction",icon:H.jsx(Re.Icon,{as:rr.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:I})}),H.jsx(Re.Text,{fontSize:"xs",color:_?"whiteAlpha.600":"blackAlpha.500",ml:1,children:t})]})}),ee&&H.jsx(Re.Box,{position:"absolute",bottom:"100%",right:0,pb:"10px",zIndex:200,children:H.jsxs(Re.Box,{bg:A,borderWidth:1,borderColor:P,borderRadius:"15px",p:2,minW:"180px",shadow:"lg",children:[tN.map(Se=>H.jsxs(Re.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"10px",cursor:"pointer",_hover:{bg:_?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Ee;(Ee=E.onDirectionChange)==null||Ee.call(E,Se.value),K(!1)},children:[H.jsx(Re.Icon,{as:Se.icon,boxSize:5,color:D}),H.jsx(Re.Text,{fontSize:"sm",color:D,flex:1,whiteSpace:"nowrap",children:Se.label}),t===Se.value&&H.jsx(Re.Icon,{as:rr.PiCheck,boxSize:4,color:L})]},Se.value)),H.jsxs(Re.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"10px",cursor:"pointer",_hover:{bg:_?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Se;(Se=E.onDirectionChange)==null||Se.call(E,"C"),K(!1)},children:[H.jsx(Re.Icon,{as:rr.PiAlignCenterHorizontal,boxSize:5,color:D}),H.jsx(Re.Text,{fontSize:"sm",color:D,flex:1,whiteSpace:"nowrap",children:"Center"}),t==="C"&&H.jsx(Re.Icon,{as:rr.PiCheck,boxSize:4,color:L})]})]})})]})]})})]})};T2.displayName="BottomBar";const nN=xe.memo(T2),aN=r=>{const n=1/(Math.cbrt(r)*.8);let a=Math.round(650*n),i=Math.round(350*n);return a=Math.max(40,Math.min(450,a)),i=Math.max(30,Math.min(300,i)),{edgeSep:a,rankSep:i}},ao=new Map;let ii=null;const iN=.1,oN=1e3;function R2(){ii=null;const r=Date.now()*iN%oN,e=new Set;for(const{edge:t}of ao.values())t.removed()||e.add(t.cy());e.forEach(t=>t.startBatch());for(const{edge:t,inverted:n}of ao.values())t.removed()||t.style("line-dash-offset",n?r:-r);e.forEach(t=>t.endBatch()),ao.size&&(ii=requestAnimationFrame(R2))}function ow(r,e,t=!1){if(e){ao.set(r,{edge:e,inverted:t}),ii===null&&(ii=requestAnimationFrame(R2));return}ao.delete(r),!ao.size&&ii!==null&&(cancelAnimationFrame(ii),ii=null)}function wc(r,e,t){let n=2;return r.getElementById(e).length===1&&(n-=1),r.getElementById(t).length===1&&(n-=1),n}function sN({cytoInstance:r,id:e,source:t,type:n,target:a,label:i,children:o,layout:s,styleCallback:u,isPerformanceMode:l,animated:f=!1,inverted:d=!1,edgeData:h}){const g=xe.useRef(null),p=xe.useRef({}),[x,b]=xe.useState(2);function w(S){u&&S.style(u(S,t,a,h))}function y(){const S=r.getElementById(e);S.length===0?(w(r.add({data:{id:e,source:t,target:a,label:i,type:n}})),s()):(S.data({source:t,target:a,label:i,type:n}),w(S))}if(xe.useEffect(()=>{const S=wc(r,t,a);b(S),S===0&&y()},[t,a,e,i,n,r]),xe.useEffect(()=>{function S(_){const A=_.target.id();if(A!==t&&A!==a)return;const P=wc(r,t,a);b(P),P===0&&y()}function R(_){const A=_.target.id();if(A!==t&&A!==a)return;const P=wc(r,t,a);b(P),P>0&&r.getElementById(e).length&&(r.getElementById(e).remove(),s())}return r.on("add","node",S),r.on("remove","node",R),()=>{r.off("add","node",S),r.off("remove","node",R),ow(p.current,null),r.getElementById(e).length&&(r.getElementById(e).remove(),s())}},[]),xe.useEffect(()=>{const S=r.getElementById(e),R=f&&!l&&x===0&&S.length>0;ow(p.current,R?S:null,d)},[f,d,l,x,r,e]),xe.useEffect(()=>{if(x)return;const S=r.getElementById(e);S.length&&w(S)},[u,h,x]),x>0)return null;function E(S){return xe.cloneElement(S,{cytoInstance:r,layout:s})}const C=xe.Children.map(o,E);return H.jsx("div",{ref:g,className:"cytoscape-react-edge",children:C})}var xc,sw;function rn(){if(sw)return xc;sw=1;function r(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}return xc=r,xc}var Ec,uw;function A2(){if(uw)return Ec;uw=1;var r=typeof St=="object"&&St&&St.Object===Object&&St;return Ec=r,Ec}var Cc,lw;function An(){if(lw)return Cc;lw=1;var r=A2(),e=typeof self=="object"&&self&&self.Object===Object&&self,t=r||e||Function("return this")();return Cc=t,Cc}var _c,fw;function P2(){if(fw)return _c;fw=1;var r=An(),e=function(){return r.Date.now()};return _c=e,_c}var Sc,cw;function uN(){if(cw)return Sc;cw=1;var r=/\s/;function e(t){for(var n=t.length;n--&&r.test(t.charAt(n)););return n}return Sc=e,Sc}var Tc,dw;function lN(){if(dw)return Tc;dw=1;var r=uN(),e=/^\s+/;function t(n){return n&&n.slice(0,r(n)+1).replace(e,"")}return Tc=t,Tc}var Rc,vw;function vo(){if(vw)return Rc;vw=1;var r=An(),e=r.Symbol;return Rc=e,Rc}var Ac,hw;function fN(){if(hw)return Ac;hw=1;var r=vo(),e=Object.prototype,t=e.hasOwnProperty,n=e.toString,a=r?r.toStringTag:void 0;function i(o){var s=t.call(o,a),u=o[a];try{o[a]=void 0;var l=!0}catch{}var f=n.call(o);return l&&(s?o[a]=u:delete o[a]),f}return Ac=i,Ac}var Pc,gw;function cN(){if(gw)return Pc;gw=1;var r=Object.prototype,e=r.toString;function t(n){return e.call(n)}return Pc=t,Pc}var Ic,pw;function yi(){if(pw)return Ic;pw=1;var r=vo(),e=fN(),t=cN(),n="[object Null]",a="[object Undefined]",i=r?r.toStringTag:void 0;function o(s){return s==null?s===void 0?a:n:i&&i in Object(s)?e(s):t(s)}return Ic=o,Ic}var Dc,yw;function zn(){if(yw)return Dc;yw=1;function r(e){return e!=null&&typeof e=="object"}return Dc=r,Dc}var Bc,mw;function ho(){if(mw)return Bc;mw=1;var r=yi(),e=zn(),t="[object Symbol]";function n(a){return typeof a=="symbol"||e(a)&&r(a)==t}return Bc=n,Bc}var Mc,bw;function I2(){if(bw)return Mc;bw=1;var r=lN(),e=rn(),t=ho(),n=NaN,a=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=parseInt;function u(l){if(typeof l=="number")return l;if(t(l))return n;if(e(l)){var f=typeof l.valueOf=="function"?l.valueOf():l;l=e(f)?f+"":f}if(typeof l!="string")return l===0?l:+l;l=r(l);var d=i.test(l);return d||o.test(l)?s(l.slice(2),d?2:8):a.test(l)?n:+l}return Mc=u,Mc}var Lc,ww;function dN(){if(ww)return Lc;ww=1;var r=rn(),e=P2(),t=I2(),n="Expected a function",a=Math.max,i=Math.min;function o(s,u,l){var f,d,h,g,p,x,b=0,w=!1,y=!1,E=!0;if(typeof s!="function")throw new TypeError(n);u=t(u)||0,r(l)&&(w=!!l.leading,y="maxWait"in l,h=y?a(t(l.maxWait)||0,u):h,E="trailing"in l?!!l.trailing:E);function C(M){var q=f,N=d;return f=d=void 0,b=M,g=s.apply(N,q),g}function S(M){return b=M,p=setTimeout(A,u),w?C(M):g}function R(M){var q=M-x,N=M-b,W=u-q;return y?i(W,h-N):W}function _(M){var q=M-x,N=M-b;return x===void 0||q>=u||q<0||y&&N>=h}function A(){var M=e();if(_(M))return P(M);p=setTimeout(A,R(M))}function P(M){return p=void 0,E&&f?C(M):(f=d=void 0,g)}function I(){p!==void 0&&clearTimeout(p),b=0,f=x=d=p=void 0}function D(){return p===void 0?g:P(e())}function L(){var M=e(),q=_(M);if(f=arguments,d=this,x=M,q){if(p===void 0)return S(x);if(y)return clearTimeout(p),p=setTimeout(A,u),C(x)}return p===void 0&&(p=setTimeout(A,u)),g}return L.cancel=I,L.flush=D,L}return Lc=o,Lc}var vN=dN();const xw=gl(vN);function xm(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function hN(r){if(Array.isArray(r))return r}function gN(r){if(Array.isArray(r))return xm(r)}function qa(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function pN(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,B2(n.key),n)}}function Na(r,e,t){return e&&pN(r.prototype,e),Object.defineProperty(r,"prototype",{writable:!1}),r}function Gt(r,e){var t=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=Um(r))||e){t&&(r=t);var n=0,a=function(){};return{s:a,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(u){throw u},f:a}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
28
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var i,o=!0,s=!1;return{s:function(){t=t.call(r)},n:function(){var u=t.next();return o=u.done,u},e:function(u){s=!0,i=u},f:function(){try{o||t.return==null||t.return()}finally{if(s)throw i}}}}function D2(r,e,t){return(e=B2(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function yN(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function mN(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var n,a,i,o,s=[],u=!0,l=!1;try{if(i=(t=t.call(r)).next,e===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(n=i.call(t)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(f){l=!0,a=f}finally{try{if(!u&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(l)throw a}}return s}}function bN(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
29
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function wN(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
30
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Zr(r,e){return hN(r)||mN(r,e)||Um(r,e)||bN()}function el(r){return gN(r)||yN(r)||Um(r)||wN()}function xN(r,e){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function B2(r){var e=xN(r,"string");return typeof e=="symbol"?e:e+""}function at(r){"@babel/helpers - typeof";return at=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},at(r)}function Um(r,e){if(r){if(typeof r=="string")return xm(r,e);var t={}.toString.call(r).slice(8,-1);return t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set"?Array.from(r):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?xm(r,e):void 0}}var tt=typeof window>"u"?null:window,Ew=tt?tt.navigator:null;tt&&tt.document;var EN=at(""),M2=at({}),CN=at(function(){}),_N=typeof HTMLElement>"u"?"undefined":at(HTMLElement),ws=function(e){return e&&e.instanceString&&$r(e.instanceString)?e.instanceString():null},Ye=function(e){return e!=null&&at(e)==EN},$r=function(e){return e!=null&&at(e)===CN},Tr=function(e){return!Jt(e)&&(Array.isArray?Array.isArray(e):e!=null&&e instanceof Array)},yr=function(e){return e!=null&&at(e)===M2&&!Tr(e)&&e.constructor===Object},SN=function(e){return e!=null&&at(e)===M2},qe=function(e){return e!=null&&at(e)===at(1)&&!isNaN(e)},TN=function(e){return qe(e)&&Math.floor(e)===e},rl=function(e){if(_N!=="undefined")return e!=null&&e instanceof HTMLElement},Jt=function(e){return xs(e)||L2(e)},xs=function(e){return ws(e)==="collection"&&e._private.single},L2=function(e){return ws(e)==="collection"&&!e._private.single},Hm=function(e){return ws(e)==="core"},O2=function(e){return ws(e)==="stylesheet"},RN=function(e){return ws(e)==="event"},Da=function(e){return e==null?!0:!!(e===""||e.match(/^\s+$/))},AN=function(e){return typeof HTMLElement>"u"?!1:e instanceof HTMLElement},PN=function(e){return yr(e)&&qe(e.x1)&&qe(e.x2)&&qe(e.y1)&&qe(e.y2)},IN=function(e){return SN(e)&&$r(e.then)},DN=function(){return Ew&&Ew.userAgent.match(/msie|trident|edge/i)},lo=function(e,t){t||(t=function(){if(arguments.length===1)return arguments[0];if(arguments.length===0)return"undefined";for(var i=[],o=0;o<arguments.length;o++)i.push(arguments[o]);return i.join("$")});var n=function(){var i=this,o=arguments,s,u=t.apply(i,o),l=n.cache;return(s=l[u])||(s=l[u]=e.apply(i,o)),s};return n.cache={},n},Km=lo(function(r){return r.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}),bl=lo(function(r){return r.replace(/(-\w)/g,function(e){return e[1].toUpperCase()})}),k2=lo(function(r,e){return r+e[0].toUpperCase()+e.substring(1)},function(r,e){return r+"$"+e}),Cw=function(e){return Da(e)?e:e.charAt(0).toUpperCase()+e.substring(1)},_a=function(e,t){return e.slice(-1*t.length)===t},nt="(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))",BN="rgb[a]?\\(("+nt+"[%]?)\\s*,\\s*("+nt+"[%]?)\\s*,\\s*("+nt+"[%]?)(?:\\s*,\\s*("+nt+"))?\\)",MN="rgb[a]?\\((?:"+nt+"[%]?)\\s*,\\s*(?:"+nt+"[%]?)\\s*,\\s*(?:"+nt+"[%]?)(?:\\s*,\\s*(?:"+nt+"))?\\)",LN="hsl[a]?\\(("+nt+")\\s*,\\s*("+nt+"[%])\\s*,\\s*("+nt+"[%])(?:\\s*,\\s*("+nt+"))?\\)",ON="hsl[a]?\\((?:"+nt+")\\s*,\\s*(?:"+nt+"[%])\\s*,\\s*(?:"+nt+"[%])(?:\\s*,\\s*(?:"+nt+"))?\\)",kN="\\#[0-9a-fA-F]{3}",qN="\\#[0-9a-fA-F]{6}",q2=function(e,t){return e<t?-1:e>t?1:0},NN=function(e,t){return-1*q2(e,t)},Xe=Object.assign!=null?Object.assign.bind(Object):function(r){for(var e=arguments,t=1;t<e.length;t++){var n=e[t];if(n!=null)for(var a=Object.keys(n),i=0;i<a.length;i++){var o=a[i];r[o]=n[o]}}return r},FN=function(e){if(!(!(e.length===4||e.length===7)||e[0]!=="#")){var t=e.length===4,n,a,i,o=16;return t?(n=parseInt(e[1]+e[1],o),a=parseInt(e[2]+e[2],o),i=parseInt(e[3]+e[3],o)):(n=parseInt(e[1]+e[2],o),a=parseInt(e[3]+e[4],o),i=parseInt(e[5]+e[6],o)),[n,a,i]}},zN=function(e){var t,n,a,i,o,s,u,l;function f(p,x,b){return b<0&&(b+=1),b>1&&(b-=1),b<1/6?p+(x-p)*6*b:b<1/2?x:b<2/3?p+(x-p)*(2/3-b)*6:p}var d=new RegExp("^"+LN+"$").exec(e);if(d){if(n=parseInt(d[1]),n<0?n=(360- -1*n%360)%360:n>360&&(n=n%360),n/=360,a=parseFloat(d[2]),a<0||a>100||(a=a/100,i=parseFloat(d[3]),i<0||i>100)||(i=i/100,o=d[4],o!==void 0&&(o=parseFloat(o),o<0||o>1)))return;if(a===0)s=u=l=Math.round(i*255);else{var h=i<.5?i*(1+a):i+a-i*a,g=2*i-h;s=Math.round(255*f(g,h,n+1/3)),u=Math.round(255*f(g,h,n)),l=Math.round(255*f(g,h,n-1/3))}t=[s,u,l,o]}return t},$N=function(e){var t,n=new RegExp("^"+BN+"$").exec(e);if(n){t=[];for(var a=[],i=1;i<=3;i++){var o=n[i];if(o[o.length-1]==="%"&&(a[i]=!0),o=parseFloat(o),a[i]&&(o=o/100*255),o<0||o>255)return;t.push(Math.floor(o))}var s=a[1]||a[2]||a[3],u=a[1]&&a[2]&&a[3];if(s&&!u)return;var l=n[4];if(l!==void 0){if(l=parseFloat(l),l<0||l>1)return;t.push(l)}}return t},VN=function(e){return GN[e.toLowerCase()]},N2=function(e){return(Tr(e)?e:null)||VN(e)||FN(e)||$N(e)||zN(e)},GN={transparent:[0,0,0,0],aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],grey:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},F2=function(e){for(var t=e.map,n=e.keys,a=n.length,i=0;i<a;i++){var o=n[i];if(yr(o))throw Error("Tried to set map with object key");i<n.length-1?(t[o]==null&&(t[o]={}),t=t[o]):t[o]=e.value}},z2=function(e){for(var t=e.map,n=e.keys,a=n.length,i=0;i<a;i++){var o=n[i];if(yr(o))throw Error("Tried to get map with object key");if(t=t[o],t==null)return t}return t},Tu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Es(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Oc,_w;function Cs(){if(_w)return Oc;_w=1;function r(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}return Oc=r,Oc}var kc,Sw;function WN(){if(Sw)return kc;Sw=1;var r=typeof Tu=="object"&&Tu&&Tu.Object===Object&&Tu;return kc=r,kc}var qc,Tw;function wl(){if(Tw)return qc;Tw=1;var r=WN(),e=typeof self=="object"&&self&&self.Object===Object&&self,t=r||e||Function("return this")();return qc=t,qc}var Nc,Rw;function UN(){if(Rw)return Nc;Rw=1;var r=wl(),e=function(){return r.Date.now()};return Nc=e,Nc}var Fc,Aw;function HN(){if(Aw)return Fc;Aw=1;var r=/\s/;function e(t){for(var n=t.length;n--&&r.test(t.charAt(n)););return n}return Fc=e,Fc}var zc,Pw;function KN(){if(Pw)return zc;Pw=1;var r=HN(),e=/^\s+/;function t(n){return n&&n.slice(0,r(n)+1).replace(e,"")}return zc=t,zc}var $c,Iw;function jm(){if(Iw)return $c;Iw=1;var r=wl(),e=r.Symbol;return $c=e,$c}var Vc,Dw;function jN(){if(Dw)return Vc;Dw=1;var r=jm(),e=Object.prototype,t=e.hasOwnProperty,n=e.toString,a=r?r.toStringTag:void 0;function i(o){var s=t.call(o,a),u=o[a];try{o[a]=void 0;var l=!0}catch{}var f=n.call(o);return l&&(s?o[a]=u:delete o[a]),f}return Vc=i,Vc}var Gc,Bw;function YN(){if(Bw)return Gc;Bw=1;var r=Object.prototype,e=r.toString;function t(n){return e.call(n)}return Gc=t,Gc}var Wc,Mw;function $2(){if(Mw)return Wc;Mw=1;var r=jm(),e=jN(),t=YN(),n="[object Null]",a="[object Undefined]",i=r?r.toStringTag:void 0;function o(s){return s==null?s===void 0?a:n:i&&i in Object(s)?e(s):t(s)}return Wc=o,Wc}var Uc,Lw;function ZN(){if(Lw)return Uc;Lw=1;function r(e){return e!=null&&typeof e=="object"}return Uc=r,Uc}var Hc,Ow;function _s(){if(Ow)return Hc;Ow=1;var r=$2(),e=ZN(),t="[object Symbol]";function n(a){return typeof a=="symbol"||e(a)&&r(a)==t}return Hc=n,Hc}var Kc,kw;function XN(){if(kw)return Kc;kw=1;var r=KN(),e=Cs(),t=_s(),n=NaN,a=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=parseInt;function u(l){if(typeof l=="number")return l;if(t(l))return n;if(e(l)){var f=typeof l.valueOf=="function"?l.valueOf():l;l=e(f)?f+"":f}if(typeof l!="string")return l===0?l:+l;l=r(l);var d=i.test(l);return d||o.test(l)?s(l.slice(2),d?2:8):a.test(l)?n:+l}return Kc=u,Kc}var jc,qw;function QN(){if(qw)return jc;qw=1;var r=Cs(),e=UN(),t=XN(),n="Expected a function",a=Math.max,i=Math.min;function o(s,u,l){var f,d,h,g,p,x,b=0,w=!1,y=!1,E=!0;if(typeof s!="function")throw new TypeError(n);u=t(u)||0,r(l)&&(w=!!l.leading,y="maxWait"in l,h=y?a(t(l.maxWait)||0,u):h,E="trailing"in l?!!l.trailing:E);function C(M){var q=f,N=d;return f=d=void 0,b=M,g=s.apply(N,q),g}function S(M){return b=M,p=setTimeout(A,u),w?C(M):g}function R(M){var q=M-x,N=M-b,W=u-q;return y?i(W,h-N):W}function _(M){var q=M-x,N=M-b;return x===void 0||q>=u||q<0||y&&N>=h}function A(){var M=e();if(_(M))return P(M);p=setTimeout(A,R(M))}function P(M){return p=void 0,E&&f?C(M):(f=d=void 0,g)}function I(){p!==void 0&&clearTimeout(p),b=0,f=x=d=p=void 0}function D(){return p===void 0?g:P(e())}function L(){var M=e(),q=_(M);if(f=arguments,d=this,x=M,q){if(p===void 0)return S(x);if(y)return clearTimeout(p),p=setTimeout(A,u),C(x)}return p===void 0&&(p=setTimeout(A,u)),g}return L.cancel=I,L.flush=D,L}return jc=o,jc}var JN=QN(),Ss=Es(JN),Yc=tt?tt.performance:null,V2=Yc&&Yc.now?function(){return Yc.now()}:function(){return Date.now()},eF=(function(){if(tt){if(tt.requestAnimationFrame)return function(r){tt.requestAnimationFrame(r)};if(tt.mozRequestAnimationFrame)return function(r){tt.mozRequestAnimationFrame(r)};if(tt.webkitRequestAnimationFrame)return function(r){tt.webkitRequestAnimationFrame(r)};if(tt.msRequestAnimationFrame)return function(r){tt.msRequestAnimationFrame(r)}}return function(r){r&&setTimeout(function(){r(V2())},1e3/60)}})(),tl=function(e){return eF(e)},ta=V2,oi=9261,G2=65599,Xi=5381,W2=function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:oi,n=t,a;a=e.next(),!a.done;)n=n*G2+a.value|0;return n},ls=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:oi;return t*G2+e|0},fs=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Xi;return(t<<5)+t+e|0},rF=function(e,t){return e*2097152+t},wa=function(e){return e[0]*2097152+e[1]},Ru=function(e,t){return[ls(e[0],t[0]),fs(e[1],t[1])]},Nw=function(e,t){var n={value:0,done:!1},a=0,i=e.length,o={next:function(){return a<i?n.value=e[a++]:n.done=!0,n}};return W2(o,t)},ci=function(e,t){var n={value:0,done:!1},a=0,i=e.length,o={next:function(){return a<i?n.value=e.charCodeAt(a++):n.done=!0,n}};return W2(o,t)},U2=function(){return tF(arguments)},tF=function(e){for(var t,n=0;n<e.length;n++){var a=e[n];n===0?t=ci(a):t=ci(a,t)}return t};function nF(r,e,t,n,a){var i=a*Math.PI/180,o=Math.cos(i)*(r-t)-Math.sin(i)*(e-n)+t,s=Math.sin(i)*(r-t)+Math.cos(i)*(e-n)+n;return{x:o,y:s}}var aF=function(e,t,n,a,i,o){return{x:(e-n)*i+n,y:(t-a)*o+a}};function iF(r,e,t){if(t===0)return r;var n=(e.x1+e.x2)/2,a=(e.y1+e.y2)/2,i=e.w/e.h,o=1/i,s=nF(r.x,r.y,n,a,t),u=aF(s.x,s.y,n,a,i,o);return{x:u.x,y:u.y}}var Fw=!0,oF=console.warn!=null,sF=console.trace!=null,Ym=Number.MAX_SAFE_INTEGER||9007199254740991,H2=function(){return!0},nl=function(){return!1},zw=function(){return 0},Zm=function(){},kr=function(e){throw new Error(e)},K2=function(e){if(e!==void 0)Fw=!!e;else return Fw},Cr=function(e){K2()&&(oF?console.warn(e):(console.log(e),sF&&console.trace()))},uF=function(e){return Xe({},e)},Nn=function(e){return e==null?e:Tr(e)?e.slice():yr(e)?uF(e):e},lF=function(e){return e.slice()},j2=function(e,t){for(t=e="";e++<36;t+=e*51&52?(e^15?8^Math.random()*(e^20?16:4):4).toString(16):"-");return t},fF={},Y2=function(){return fF},wt=function(e){var t=Object.keys(e);return function(n){for(var a={},i=0;i<t.length;i++){var o=t[i],s=n==null?void 0:n[o];a[o]=s===void 0?e[o]:s}return a}},Ba=function(e,t,n){for(var a=e.length-1;a>=0;a--)e[a]===t&&e.splice(a,1)},Xm=function(e){e.splice(0,e.length)},cF=function(e,t){for(var n=0;n<t.length;n++){var a=t[n];e.push(a)}},$t=function(e,t,n){return n&&(t=k2(n,t)),e[t]},ea=function(e,t,n,a){n&&(t=k2(n,t)),e[t]=a},dF=(function(){function r(){qa(this,r),this._obj={}}return Na(r,[{key:"set",value:function(t,n){return this._obj[t]=n,this}},{key:"delete",value:function(t){return this._obj[t]=void 0,this}},{key:"clear",value:function(){this._obj={}}},{key:"has",value:function(t){return this._obj[t]!==void 0}},{key:"get",value:function(t){return this._obj[t]}}])})(),ra=typeof Map<"u"?Map:dF,vF="undefined",hF=(function(){function r(e){if(qa(this,r),this._obj=Object.create(null),this.size=0,e!=null){var t;e.instanceString!=null&&e.instanceString()===this.instanceString()?t=e.toArray():t=e;for(var n=0;n<t.length;n++)this.add(t[n])}}return Na(r,[{key:"instanceString",value:function(){return"set"}},{key:"add",value:function(t){var n=this._obj;n[t]!==1&&(n[t]=1,this.size++)}},{key:"delete",value:function(t){var n=this._obj;n[t]===1&&(n[t]=0,this.size--)}},{key:"clear",value:function(){this._obj=Object.create(null)}},{key:"has",value:function(t){return this._obj[t]===1}},{key:"toArray",value:function(){var t=this;return Object.keys(this._obj).filter(function(n){return t.has(n)})}},{key:"forEach",value:function(t,n){return this.toArray().forEach(t,n)}}])})(),go=(typeof Set>"u"?"undefined":at(Set))!==vF?Set:hF,xl=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(e===void 0||t===void 0||!Hm(e)){kr("An element must have a core reference and parameters set");return}var a=t.group;if(a==null&&(t.data&&t.data.source!=null&&t.data.target!=null?a="edges":a="nodes"),a!=="nodes"&&a!=="edges"){kr("An element must be of type `nodes` or `edges`; you specified `"+a+"`");return}this.length=1,this[0]=this;var i=this._private={cy:e,single:!0,data:t.data||{},position:t.position||{x:0,y:0},autoWidth:void 0,autoHeight:void 0,autoPadding:void 0,compoundBoundsClean:!1,listeners:[],group:a,style:{},rstyle:{},styleCxts:[],styleKeys:{},removed:!0,selected:!!t.selected,selectable:t.selectable===void 0?!0:!!t.selectable,locked:!!t.locked,grabbed:!1,grabbable:t.grabbable===void 0?!0:!!t.grabbable,pannable:t.pannable===void 0?a==="edges":!!t.pannable,active:!1,classes:new go,animation:{current:[],queue:[]},rscratch:{},scratch:t.scratch||{},edges:[],children:[],parent:t.parent&&t.parent.isNode()?t.parent:null,traversalCache:{},backgrounding:!1,bbCache:null,bbCacheShift:{x:0,y:0},bodyBounds:null,overlayBounds:null,labelBounds:{all:null,source:null,target:null,main:null},arrowBounds:{source:null,target:null,"mid-source":null,"mid-target":null}};if(i.position.x==null&&(i.position.x=0),i.position.y==null&&(i.position.y=0),t.renderedPosition){var o=t.renderedPosition,s=e.pan(),u=e.zoom();i.position={x:(o.x-s.x)/u,y:(o.y-s.y)/u}}var l=[];Tr(t.classes)?l=t.classes:Ye(t.classes)&&(l=t.classes.split(/\s+/));for(var f=0,d=l.length;f<d;f++){var h=l[f];!h||h===""||i.classes.add(h)}this.createEmitter(),(n===void 0||n)&&this.restore();var g=t.style||t.css;g&&(Cr("Setting a `style` bypass at element creation should be done only when absolutely necessary. Try to use the stylesheet instead."),this.style(g))},$w=function(e){return e={bfs:e.bfs||!e.dfs,dfs:e.dfs||!e.bfs},function(n,a,i){var o;yr(n)&&!Jt(n)&&(o=n,n=o.roots||o.root,a=o.visit,i=o.directed),i=arguments.length===2&&!$r(a)?a:i,a=$r(a)?a:function(){};for(var s=this._private.cy,u=n=Ye(n)?this.filter(n):n,l=[],f=[],d={},h={},g={},p=0,x,b=this.byGroup(),w=b.nodes,y=b.edges,E=0;E<u.length;E++){var C=u[E],S=C.id();C.isNode()&&(l.unshift(C),e.bfs&&(g[S]=!0,f.push(C)),h[S]=0)}for(var R=function(){var M=e.bfs?l.shift():l.pop(),q=M.id();if(e.dfs){if(g[q])return 0;g[q]=!0,f.push(M)}var N=h[q],W=d[q],V=W!=null?W.source():null,$=W!=null?W.target():null,Z=W==null?void 0:M.same(V)?$[0]:V[0],ee;if(ee=a(M,W,Z,p++,N),ee===!0)return x=M,1;if(ee===!1)return 1;for(var K=M.connectedEdges().filter(function(Y){return(!i||Y.source().same(M))&&y.has(Y)}),j=0;j<K.length;j++){var fe=K[j],G=fe.connectedNodes().filter(function(Y){return!Y.same(M)&&w.has(Y)}),z=G.id();G.length!==0&&!g[z]&&(G=G[0],l.push(G),e.bfs&&(g[z]=!0,f.push(G)),d[z]=fe,h[z]=h[q]+1)}},_;l.length!==0&&(_=R(),!(_!==0&&_===1)););for(var A=s.collection(),P=0;P<f.length;P++){var I=f[P],D=d[I.id()];D!=null&&A.push(D),A.push(I)}return{path:s.collection(A),found:s.collection(x)}}},cs={breadthFirstSearch:$w({bfs:!0}),depthFirstSearch:$w({dfs:!0})};cs.bfs=cs.breadthFirstSearch;cs.dfs=cs.depthFirstSearch;var Fu={exports:{}},gF=Fu.exports,Vw;function pF(){return Vw||(Vw=1,(function(r,e){(function(){var t,n,a,i,o,s,u,l,f,d,h,g,p,x,b;a=Math.floor,d=Math.min,n=function(w,y){return w<y?-1:w>y?1:0},f=function(w,y,E,C,S){var R;if(E==null&&(E=0),S==null&&(S=n),E<0)throw new Error("lo must be non-negative");for(C==null&&(C=w.length);E<C;)R=a((E+C)/2),S(y,w[R])<0?C=R:E=R+1;return[].splice.apply(w,[E,E-E].concat(y)),y},s=function(w,y,E){return E==null&&(E=n),w.push(y),x(w,0,w.length-1,E)},o=function(w,y){var E,C;return y==null&&(y=n),E=w.pop(),w.length?(C=w[0],w[0]=E,b(w,0,y)):C=E,C},l=function(w,y,E){var C;return E==null&&(E=n),C=w[0],w[0]=y,b(w,0,E),C},u=function(w,y,E){var C;return E==null&&(E=n),w.length&&E(w[0],y)<0&&(C=[w[0],y],y=C[0],w[0]=C[1],b(w,0,E)),y},i=function(w,y){var E,C,S,R,_,A;for(y==null&&(y=n),R=(function(){A=[];for(var P=0,I=a(w.length/2);0<=I?P<I:P>I;0<=I?P++:P--)A.push(P);return A}).apply(this).reverse(),_=[],C=0,S=R.length;C<S;C++)E=R[C],_.push(b(w,E,y));return _},p=function(w,y,E){var C;if(E==null&&(E=n),C=w.indexOf(y),C!==-1)return x(w,0,C,E),b(w,C,E)},h=function(w,y,E){var C,S,R,_,A;if(E==null&&(E=n),S=w.slice(0,y),!S.length)return S;for(i(S,E),A=w.slice(y),R=0,_=A.length;R<_;R++)C=A[R],u(S,C,E);return S.sort(E).reverse()},g=function(w,y,E){var C,S,R,_,A,P,I,D,L;if(E==null&&(E=n),y*10<=w.length){if(R=w.slice(0,y).sort(E),!R.length)return R;for(S=R[R.length-1],I=w.slice(y),_=0,P=I.length;_<P;_++)C=I[_],E(C,S)<0&&(f(R,C,0,null,E),R.pop(),S=R[R.length-1]);return R}for(i(w,E),L=[],A=0,D=d(y,w.length);0<=D?A<D:A>D;0<=D?++A:--A)L.push(o(w,E));return L},x=function(w,y,E,C){var S,R,_;for(C==null&&(C=n),S=w[E];E>y;){if(_=E-1>>1,R=w[_],C(S,R)<0){w[E]=R,E=_;continue}break}return w[E]=S},b=function(w,y,E){var C,S,R,_,A;for(E==null&&(E=n),S=w.length,A=y,R=w[y],C=2*y+1;C<S;)_=C+1,_<S&&!(E(w[C],w[_])<0)&&(C=_),w[y]=w[C],y=C,C=2*y+1;return w[y]=R,x(w,A,y,E)},t=(function(){w.push=s,w.pop=o,w.replace=l,w.pushpop=u,w.heapify=i,w.updateItem=p,w.nlargest=h,w.nsmallest=g;function w(y){this.cmp=y??n,this.nodes=[]}return w.prototype.push=function(y){return s(this.nodes,y,this.cmp)},w.prototype.pop=function(){return o(this.nodes,this.cmp)},w.prototype.peek=function(){return this.nodes[0]},w.prototype.contains=function(y){return this.nodes.indexOf(y)!==-1},w.prototype.replace=function(y){return l(this.nodes,y,this.cmp)},w.prototype.pushpop=function(y){return u(this.nodes,y,this.cmp)},w.prototype.heapify=function(){return i(this.nodes,this.cmp)},w.prototype.updateItem=function(y){return p(this.nodes,y,this.cmp)},w.prototype.clear=function(){return this.nodes=[]},w.prototype.empty=function(){return this.nodes.length===0},w.prototype.size=function(){return this.nodes.length},w.prototype.clone=function(){var y;return y=new w,y.nodes=this.nodes.slice(0),y},w.prototype.toArray=function(){return this.nodes.slice(0)},w.prototype.insert=w.prototype.push,w.prototype.top=w.prototype.peek,w.prototype.front=w.prototype.peek,w.prototype.has=w.prototype.contains,w.prototype.copy=w.prototype.clone,w})(),(function(w,y){return r.exports=y()})(this,function(){return t})}).call(gF)})(Fu)),Fu.exports}var Zc,Gw;function yF(){return Gw||(Gw=1,Zc=pF()),Zc}var mF=yF(),Ts=Es(mF),bF=wt({root:null,weight:function(e){return 1},directed:!1}),wF={dijkstra:function(e){if(!yr(e)){var t=arguments;e={root:t[0],weight:t[1],directed:t[2]}}var n=bF(e),a=n.root,i=n.weight,o=n.directed,s=this,u=i,l=Ye(a)?this.filter(a)[0]:a[0],f={},d={},h={},g=this.byGroup(),p=g.nodes,x=g.edges;x.unmergeBy(function(N){return N.isLoop()});for(var b=function(W){return f[W.id()]},w=function(W,V){f[W.id()]=V,y.updateItem(W)},y=new Ts(function(N,W){return b(N)-b(W)}),E=0;E<p.length;E++){var C=p[E];f[C.id()]=C.same(l)?0:1/0,y.push(C)}for(var S=function(W,V){for(var $=(o?W.edgesTo(V):W.edgesWith(V)).intersect(x),Z=1/0,ee,K=0;K<$.length;K++){var j=$[K],fe=u(j);(fe<Z||!ee)&&(Z=fe,ee=j)}return{edge:ee,dist:Z}};y.size()>0;){var R=y.pop(),_=b(R),A=R.id();if(h[A]=_,_!==1/0)for(var P=R.neighborhood().intersect(p),I=0;I<P.length;I++){var D=P[I],L=D.id(),M=S(R,D),q=_+M.dist;q<b(D)&&(w(D,q),d[L]={node:R,edge:M.edge})}}return{distanceTo:function(W){var V=Ye(W)?p.filter(W)[0]:W[0];return h[V.id()]},pathTo:function(W){var V=Ye(W)?p.filter(W)[0]:W[0],$=[],Z=V,ee=Z.id();if(V.length>0)for($.unshift(V);d[ee];){var K=d[ee];$.unshift(K.edge),$.unshift(K.node),Z=K.node,ee=Z.id()}return s.spawn($)}}}},xF={kruskal:function(e){e=e||function(E){return 1};for(var t=this.byGroup(),n=t.nodes,a=t.edges,i=n.length,o=new Array(i),s=n,u=function(C){for(var S=0;S<o.length;S++){var R=o[S];if(R.has(C))return S}},l=0;l<i;l++)o[l]=this.spawn(n[l]);for(var f=a.sort(function(E,C){return e(E)-e(C)}),d=0;d<f.length;d++){var h=f[d],g=h.source()[0],p=h.target()[0],x=u(g),b=u(p),w=o[x],y=o[b];x!==b&&(s.merge(h),w.merge(y),o.splice(b,1))}return s}},EF=wt({root:null,goal:null,weight:function(e){return 1},heuristic:function(e){return 0},directed:!1}),CF={aStar:function(e){var t=this.cy(),n=EF(e),a=n.root,i=n.goal,o=n.heuristic,s=n.directed,u=n.weight;a=t.collection(a)[0],i=t.collection(i)[0];var l=a.id(),f=i.id(),d={},h={},g={},p=new Ts(function(ee,K){return h[ee.id()]-h[K.id()]}),x=new go,b={},w={},y=function(K,j){p.push(K),x.add(j)},E,C,S=function(){E=p.pop(),C=E.id(),x.delete(C)},R=function(K){return x.has(K)};y(a,l),d[l]=0,h[l]=o(a);for(var _=0;p.size()>0;){if(S(),_++,C===f){for(var A=[],P=i,I=f,D=w[I];A.unshift(P),D!=null&&A.unshift(D),P=b[I],P!=null;)I=P.id(),D=w[I];return{found:!0,distance:d[C],path:this.spawn(A),steps:_}}g[C]=!0;for(var L=E._private.edges,M=0;M<L.length;M++){var q=L[M];if(this.hasElementWithId(q.id())&&!(s&&q.data("source")!==C)){var N=q.source(),W=q.target(),V=N.id()!==C?N:W,$=V.id();if(this.hasElementWithId($)&&!g[$]){var Z=d[C]+u(q);if(!R($)){d[$]=Z,h[$]=Z+o(V),y(V,$),b[$]=E,w[$]=q;continue}Z<d[$]&&(d[$]=Z,h[$]=Z+o(V),b[$]=E,w[$]=q)}}}}return{found:!1,distance:void 0,path:void 0,steps:_}}},_F=wt({weight:function(e){return 1},directed:!1}),SF={floydWarshall:function(e){for(var t=this.cy(),n=_F(e),a=n.weight,i=n.directed,o=a,s=this.byGroup(),u=s.nodes,l=s.edges,f=u.length,d=f*f,h=function(fe){return u.indexOf(fe)},g=function(fe){return u[fe]},p=new Array(d),x=0;x<d;x++){var b=x%f,w=(x-b)/f;w===b?p[x]=0:p[x]=1/0}for(var y=new Array(d),E=new Array(d),C=0;C<l.length;C++){var S=l[C],R=S.source()[0],_=S.target()[0];if(R!==_){var A=h(R),P=h(_),I=A*f+P,D=o(S);if(p[I]>D&&(p[I]=D,y[I]=P,E[I]=S),!i){var L=P*f+A;!i&&p[L]>D&&(p[L]=D,y[L]=A,E[L]=S)}}}for(var M=0;M<f;M++)for(var q=0;q<f;q++)for(var N=q*f+M,W=0;W<f;W++){var V=q*f+W,$=M*f+W;p[N]+p[$]<p[V]&&(p[V]=p[N]+p[$],y[V]=y[N])}var Z=function(fe){return(Ye(fe)?t.filter(fe):fe)[0]},ee=function(fe){return h(Z(fe))},K={distance:function(fe,G){var z=ee(fe),Y=ee(G);return p[z*f+Y]},path:function(fe,G){var z=ee(fe),Y=ee(G),te=g(z);if(z===Y)return te.collection();if(y[z*f+Y]==null)return t.collection();var ue=t.collection(),oe=z,X;for(ue.merge(te);z!==Y;)oe=z,z=y[z*f+Y],X=E[oe*f+z],ue.merge(X),ue.merge(g(z));return ue}};return K}},TF=wt({weight:function(e){return 1},directed:!1,root:null}),RF={bellmanFord:function(e){var t=this,n=TF(e),a=n.weight,i=n.directed,o=n.root,s=a,u=this,l=this.cy(),f=this.byGroup(),d=f.edges,h=f.nodes,g=h.length,p=new ra,x=!1,b=[];o=l.collection(o)[0],d.unmergeBy(function(le){return le.isLoop()});for(var w=d.length,y=function(Me){var Se=p.get(Me.id());return Se||(Se={},p.set(Me.id(),Se)),Se},E=function(Me){return(Ye(Me)?l.$(Me):Me)[0]},C=function(Me){return y(E(Me)).dist},S=function(Me){for(var Se=arguments.length>1&&arguments[1]!==void 0?arguments[1]:o,Ee=E(Me),re=[],ce=Ee;;){if(ce==null)return t.spawn();var _e=y(ce),me=_e.edge,Te=_e.pred;if(re.unshift(ce[0]),ce.same(Se)&&re.length>0)break;me!=null&&re.unshift(me),ce=Te}return u.spawn(re)},R=0;R<g;R++){var _=h[R],A=y(_);_.same(o)?A.dist=0:A.dist=1/0,A.pred=null,A.edge=null}for(var P=!1,I=function(Me,Se,Ee,re,ce,_e){var me=re.dist+_e;me<ce.dist&&!Ee.same(re.edge)&&(ce.dist=me,ce.pred=Me,ce.edge=Ee,P=!0)},D=1;D<g;D++){P=!1;for(var L=0;L<w;L++){var M=d[L],q=M.source(),N=M.target(),W=s(M),V=y(q),$=y(N);I(q,N,M,V,$,W),i||I(N,q,M,$,V,W)}if(!P)break}if(P)for(var Z=[],ee=0;ee<w;ee++){var K=d[ee],j=K.source(),fe=K.target(),G=s(K),z=y(j).dist,Y=y(fe).dist;if(z+G<Y||!i&&Y+G<z)if(x||(Cr("Graph contains a negative weight cycle for Bellman-Ford"),x=!0),e.findNegativeWeightCycles!==!1){var te=[];z+G<Y&&te.push(j),!i&&Y+G<z&&te.push(fe);for(var ue=te.length,oe=0;oe<ue;oe++){var X=te[oe],Q=[X];Q.push(y(X).edge);for(var ie=y(X).pred;Q.indexOf(ie)===-1;)Q.push(ie),Q.push(y(ie).edge),ie=y(ie).pred;Q=Q.slice(Q.indexOf(ie));for(var de=Q[0].id(),we=0,Ae=2;Ae<Q.length;Ae+=2)Q[Ae].id()<de&&(de=Q[Ae].id(),we=Ae);Q=Q.slice(we).concat(Q.slice(0,we)),Q.push(Q[0]);var ve=Q.map(function(le){return le.id()}).join(",");Z.indexOf(ve)===-1&&(b.push(u.spawn(Q)),Z.push(ve))}}else break}return{distanceTo:C,pathTo:S,hasNegativeWeightCycle:x,negativeWeightCycles:b}}},AF=Math.sqrt(2),PF=function(e,t,n){n.length===0&&kr("Karger-Stein must be run on a connected (sub)graph");for(var a=n[e],i=a[1],o=a[2],s=t[i],u=t[o],l=n,f=l.length-1;f>=0;f--){var d=l[f],h=d[1],g=d[2];(t[h]===s&&t[g]===u||t[h]===u&&t[g]===s)&&l.splice(f,1)}for(var p=0;p<l.length;p++){var x=l[p];x[1]===u?(l[p]=x.slice(),l[p][1]=s):x[2]===u&&(l[p]=x.slice(),l[p][2]=s)}for(var b=0;b<t.length;b++)t[b]===u&&(t[b]=s);return l},Xc=function(e,t,n,a){for(;n>a;){var i=Math.floor(Math.random()*t.length);t=PF(i,e,t),n--}return t},IF={kargerStein:function(){var e=this,t=this.byGroup(),n=t.nodes,a=t.edges;a.unmergeBy(function($){return $.isLoop()});var i=n.length,o=a.length,s=Math.ceil(Math.pow(Math.log(i)/Math.LN2,2)),u=Math.floor(i/AF);if(i<2){kr("At least 2 nodes are required for Karger-Stein algorithm");return}for(var l=[],f=0;f<o;f++){var d=a[f];l.push([f,n.indexOf(d.source()),n.indexOf(d.target())])}for(var h=1/0,g=[],p=new Array(i),x=new Array(i),b=new Array(i),w=function(Z,ee){for(var K=0;K<i;K++)ee[K]=Z[K]},y=0;y<=s;y++){for(var E=0;E<i;E++)x[E]=E;var C=Xc(x,l.slice(),i,u),S=C.slice();w(x,b);var R=Xc(x,C,u,2),_=Xc(b,S,u,2);R.length<=_.length&&R.length<h?(h=R.length,g=R,w(x,p)):_.length<=R.length&&_.length<h&&(h=_.length,g=_,w(b,p))}for(var A=this.spawn(g.map(function($){return a[$[0]]})),P=this.spawn(),I=this.spawn(),D=p[0],L=0;L<p.length;L++){var M=p[L],q=n[L];M===D?P.merge(q):I.merge(q)}var N=function(Z){var ee=e.spawn();return Z.forEach(function(K){ee.merge(K),K.connectedEdges().forEach(function(j){e.contains(j)&&!A.contains(j)&&ee.merge(j)})}),ee},W=[N(P),N(I)],V={cut:A,components:W,partition1:P,partition2:I};return V}},Qc,DF=function(e){return{x:e.x,y:e.y}},El=function(e,t,n){return{x:e.x*t+n.x,y:e.y*t+n.y}},Z2=function(e,t,n){return{x:(e.x-n.x)/t,y:(e.y-n.y)/t}},Ji=function(e){return{x:e[0],y:e[1]}},BF=function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,a=1/0,i=t;i<n;i++){var o=e[i];isFinite(o)&&(a=Math.min(o,a))}return a},MF=function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,a=-1/0,i=t;i<n;i++){var o=e[i];isFinite(o)&&(a=Math.max(o,a))}return a},LF=function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,a=0,i=0,o=t;o<n;o++){var s=e[o];isFinite(s)&&(a+=s,i++)}return a/i},OF=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0;a?e=e.slice(t,n):(n<e.length&&e.splice(n,e.length-n),t>0&&e.splice(0,t));for(var s=0,u=e.length-1;u>=0;u--){var l=e[u];o?isFinite(l)||(e[u]=-1/0,s++):e.splice(u,1)}i&&e.sort(function(h,g){return h-g});var f=e.length,d=Math.floor(f/2);return f%2!==0?e[d+1+s]:(e[d-1+s]+e[d+s])/2},kF=function(e){return Math.PI*e/180},Au=function(e,t){return Math.atan2(t,e)-Math.PI/2},Qm=Math.log2||function(r){return Math.log(r)/Math.log(2)},Jm=function(e){return e>0?1:e<0?-1:0},di=function(e,t){return Math.sqrt(ti(e,t))},ti=function(e,t){var n=t.x-e.x,a=t.y-e.y;return n*n+a*a},qF=function(e){for(var t=e.length,n=0,a=0;a<t;a++)n+=e[a];for(var i=0;i<t;i++)e[i]=e[i]/n;return e},ut=function(e,t,n,a){return(1-a)*(1-a)*e+2*(1-a)*a*t+a*a*n},io=function(e,t,n,a){return{x:ut(e.x,t.x,n.x,a),y:ut(e.y,t.y,n.y,a)}},NF=function(e,t,n,a){var i={x:t.x-e.x,y:t.y-e.y},o=di(e,t),s={x:i.x/o,y:i.y/o};return n=n??0,a=a??n*o,{x:e.x+s.x*a,y:e.y+s.y*a}},ds=function(e,t,n){return Math.max(e,Math.min(n,t))},Lt=function(e){if(e==null)return{x1:1/0,y1:1/0,x2:-1/0,y2:-1/0,w:0,h:0};if(e.x1!=null&&e.y1!=null){if(e.x2!=null&&e.y2!=null&&e.x2>=e.x1&&e.y2>=e.y1)return{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,w:e.x2-e.x1,h:e.y2-e.y1};if(e.w!=null&&e.h!=null&&e.w>=0&&e.h>=0)return{x1:e.x1,y1:e.y1,x2:e.x1+e.w,y2:e.y1+e.h,w:e.w,h:e.h}}},FF=function(e){return{x1:e.x1,x2:e.x2,w:e.w,y1:e.y1,y2:e.y2,h:e.h}},zF=function(e){e.x1=1/0,e.y1=1/0,e.x2=-1/0,e.y2=-1/0,e.w=0,e.h=0},$F=function(e,t){e.x1=Math.min(e.x1,t.x1),e.x2=Math.max(e.x2,t.x2),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,t.y1),e.y2=Math.max(e.y2,t.y2),e.h=e.y2-e.y1},X2=function(e,t,n){e.x1=Math.min(e.x1,t),e.x2=Math.max(e.x2,t),e.w=e.x2-e.x1,e.y1=Math.min(e.y1,n),e.y2=Math.max(e.y2,n),e.h=e.y2-e.y1},zu=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return e.x1-=t,e.x2+=t,e.y1-=t,e.y2+=t,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},$u=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0],n,a,i,o;if(t.length===1)n=a=i=o=t[0];else if(t.length===2)n=i=t[0],o=a=t[1];else if(t.length===4){var s=Zr(t,4);n=s[0],a=s[1],i=s[2],o=s[3]}return e.x1-=o,e.x2+=a,e.y1-=n,e.y2+=i,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},Ww=function(e,t){e.x1=t.x1,e.y1=t.y1,e.x2=t.x2,e.y2=t.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1},e0=function(e,t){return!(e.x1>t.x2||t.x1>e.x2||e.x2<t.x1||t.x2<e.x1||e.y2<t.y1||t.y2<e.y1||e.y1>t.y2||t.y1>e.y2)},Sa=function(e,t,n){return e.x1<=t&&t<=e.x2&&e.y1<=n&&n<=e.y2},Uw=function(e,t){return Sa(e,t.x,t.y)},Q2=function(e,t){return Sa(e,t.x1,t.y1)&&Sa(e,t.x2,t.y2)},VF=(Qc=Math.hypot)!==null&&Qc!==void 0?Qc:function(r,e){return Math.sqrt(r*r+e*e)};function GF(r,e){if(r.length<3)throw new Error("Need at least 3 vertices");var t=function(A,P){return{x:A.x+P.x,y:A.y+P.y}},n=function(A,P){return{x:A.x-P.x,y:A.y-P.y}},a=function(A,P){return{x:A.x*P,y:A.y*P}},i=function(A,P){return A.x*P.y-A.y*P.x},o=function(A){var P=VF(A.x,A.y);return P===0?{x:0,y:0}:{x:A.x/P,y:A.y/P}},s=function(A){for(var P=0,I=0;I<A.length;I++){var D=A[I],L=A[(I+1)%A.length];P+=D.x*L.y-L.x*D.y}return P/2},u=function(A,P,I,D){var L=n(P,A),M=n(D,I),q=i(L,M);if(Math.abs(q)<1e-9)return t(A,a(L,.5));var N=i(n(I,A),M)/q;return t(A,a(L,N))},l=r.map(function(_){return{x:_.x,y:_.y}});s(l)<0&&l.reverse();for(var f=l.length,d=[],h=0;h<f;h++){var g=l[h],p=l[(h+1)%f],x=n(p,g),b=o({x:x.y,y:-x.x});d.push(b)}for(var w=d.map(function(_,A){var P=t(l[A],a(_,e)),I=t(l[(A+1)%f],a(_,e));return{p1:P,p2:I}}),y=[],E=0;E<f;E++){var C=w[(E-1+f)%f],S=w[E],R=u(C.p1,C.p2,S.p1,S.p2);y.push(R)}return y}function WF(r,e,t,n,a,i){var o=JF(r,e,t,n,a),s=GF(o,i),u=Lt();return s.forEach(function(l){return X2(u,l.x,l.y)}),u}var J2=function(e,t,n,a,i,o,s){var u=arguments.length>7&&arguments[7]!==void 0?arguments[7]:"auto",l=u==="auto"?Ma(i,o):u,f=i/2,d=o/2;l=Math.min(l,f,d);var h=l!==f,g=l!==d,p;if(h){var x=n-f+l-s,b=a-d-s,w=n+f-l+s,y=b;if(p=Ta(e,t,n,a,x,b,w,y,!1),p.length>0)return p}if(g){var E=n+f+s,C=a-d+l-s,S=E,R=a+d-l+s;if(p=Ta(e,t,n,a,E,C,S,R,!1),p.length>0)return p}if(h){var _=n-f+l-s,A=a+d+s,P=n+f-l+s,I=A;if(p=Ta(e,t,n,a,_,A,P,I,!1),p.length>0)return p}if(g){var D=n-f-s,L=a-d+l-s,M=D,q=a+d-l+s;if(p=Ta(e,t,n,a,D,L,M,q,!1),p.length>0)return p}var N;{var W=n-f+l,V=a-d+l;if(N=Yo(e,t,n,a,W,V,l+s),N.length>0&&N[0]<=W&&N[1]<=V)return[N[0],N[1]]}{var $=n+f-l,Z=a-d+l;if(N=Yo(e,t,n,a,$,Z,l+s),N.length>0&&N[0]>=$&&N[1]<=Z)return[N[0],N[1]]}{var ee=n+f-l,K=a+d-l;if(N=Yo(e,t,n,a,ee,K,l+s),N.length>0&&N[0]>=ee&&N[1]>=K)return[N[0],N[1]]}{var j=n-f+l,fe=a+d-l;if(N=Yo(e,t,n,a,j,fe,l+s),N.length>0&&N[0]<=j&&N[1]>=fe)return[N[0],N[1]]}return[]},UF=function(e,t,n,a,i,o,s){var u=s,l=Math.min(n,i),f=Math.max(n,i),d=Math.min(a,o),h=Math.max(a,o);return l-u<=e&&e<=f+u&&d-u<=t&&t<=h+u},HF=function(e,t,n,a,i,o,s,u,l){var f={x1:Math.min(n,s,i)-l,x2:Math.max(n,s,i)+l,y1:Math.min(a,u,o)-l,y2:Math.max(a,u,o)+l};return!(e<f.x1||e>f.x2||t<f.y1||t>f.y2)},KF=function(e,t,n,a){n-=a;var i=t*t-4*e*n;if(i<0)return[];var o=Math.sqrt(i),s=2*e,u=(-t+o)/s,l=(-t-o)/s;return[u,l]},jF=function(e,t,n,a,i){var o=1e-5;e===0&&(e=o),t/=e,n/=e,a/=e;var s,u,l,f,d,h,g,p;if(u=(3*n-t*t)/9,l=-(27*a)+t*(9*n-2*(t*t)),l/=54,s=u*u*u+l*l,i[1]=0,g=t/3,s>0){d=l+Math.sqrt(s),d=d<0?-Math.pow(-d,1/3):Math.pow(d,1/3),h=l-Math.sqrt(s),h=h<0?-Math.pow(-h,1/3):Math.pow(h,1/3),i[0]=-g+d+h,g+=(d+h)/2,i[4]=i[2]=-g,g=Math.sqrt(3)*(-h+d)/2,i[3]=g,i[5]=-g;return}if(i[5]=i[3]=0,s===0){p=l<0?-Math.pow(-l,1/3):Math.pow(l,1/3),i[0]=-g+2*p,i[4]=i[2]=-(p+g);return}u=-u,f=u*u*u,f=Math.acos(l/Math.sqrt(f)),p=2*Math.sqrt(u),i[0]=-g+p*Math.cos(f/3),i[2]=-g+p*Math.cos((f+2*Math.PI)/3),i[4]=-g+p*Math.cos((f+4*Math.PI)/3)},YF=function(e,t,n,a,i,o,s,u){var l=1*n*n-4*n*i+2*n*s+4*i*i-4*i*s+s*s+a*a-4*a*o+2*a*u+4*o*o-4*o*u+u*u,f=9*n*i-3*n*n-3*n*s-6*i*i+3*i*s+9*a*o-3*a*a-3*a*u-6*o*o+3*o*u,d=3*n*n-6*n*i+n*s-n*e+2*i*i+2*i*e-s*e+3*a*a-6*a*o+a*u-a*t+2*o*o+2*o*t-u*t,h=1*n*i-n*n+n*e-i*e+a*o-a*a+a*t-o*t,g=[];jF(l,f,d,h,g);for(var p=1e-7,x=[],b=0;b<6;b+=2)Math.abs(g[b+1])<p&&g[b]>=0&&g[b]<=1&&x.push(g[b]);x.push(1),x.push(0);for(var w=-1,y,E,C,S=0;S<x.length;S++)y=Math.pow(1-x[S],2)*n+2*(1-x[S])*x[S]*i+x[S]*x[S]*s,E=Math.pow(1-x[S],2)*a+2*(1-x[S])*x[S]*o+x[S]*x[S]*u,C=Math.pow(y-e,2)+Math.pow(E-t,2),w>=0?C<w&&(w=C):w=C;return w},ZF=function(e,t,n,a,i,o){var s=[e-n,t-a],u=[i-n,o-a],l=u[0]*u[0]+u[1]*u[1],f=s[0]*s[0]+s[1]*s[1],d=s[0]*u[0]+s[1]*u[1],h=d*d/l;return d<0?f:h>l?(e-i)*(e-i)+(t-o)*(t-o):f-h},Vt=function(e,t,n){for(var a,i,o,s,u,l=0,f=0;f<n.length/2;f++)if(a=n[f*2],i=n[f*2+1],f+1<n.length/2?(o=n[(f+1)*2],s=n[(f+1)*2+1]):(o=n[(f+1-n.length/2)*2],s=n[(f+1-n.length/2)*2+1]),!(a==e&&o==e))if(a>=e&&e>=o||a<=e&&e<=o)u=(e-a)/(o-a)*(s-i)+i,u>t&&l++;else continue;return l%2!==0},na=function(e,t,n,a,i,o,s,u,l){var f=new Array(n.length),d;u[0]!=null?(d=Math.atan(u[1]/u[0]),u[0]<0?d=d+Math.PI/2:d=-d-Math.PI/2):d=u;for(var h=Math.cos(-d),g=Math.sin(-d),p=0;p<f.length/2;p++)f[p*2]=o/2*(n[p*2]*h-n[p*2+1]*g),f[p*2+1]=s/2*(n[p*2+1]*h+n[p*2]*g),f[p*2]+=a,f[p*2+1]+=i;var x;if(l>0){var b=il(f,-l);x=al(b)}else x=f;return Vt(e,t,x)},XF=function(e,t,n,a,i,o,s,u){for(var l=new Array(n.length*2),f=0;f<u.length;f++){var d=u[f];l[f*4+0]=d.startX,l[f*4+1]=d.startY,l[f*4+2]=d.stopX,l[f*4+3]=d.stopY;var h=Math.pow(d.cx-e,2)+Math.pow(d.cy-t,2);if(h<=Math.pow(d.radius,2))return!0}return Vt(e,t,l)},al=function(e){for(var t=new Array(e.length/2),n,a,i,o,s,u,l,f,d=0;d<e.length/4;d++){n=e[d*4],a=e[d*4+1],i=e[d*4+2],o=e[d*4+3],d<e.length/4-1?(s=e[(d+1)*4],u=e[(d+1)*4+1],l=e[(d+1)*4+2],f=e[(d+1)*4+3]):(s=e[0],u=e[1],l=e[2],f=e[3]);var h=Ta(n,a,i,o,s,u,l,f,!0);t[d*2]=h[0],t[d*2+1]=h[1]}return t},il=function(e,t){for(var n=new Array(e.length*2),a,i,o,s,u=0;u<e.length/2;u++){a=e[u*2],i=e[u*2+1],u<e.length/2-1?(o=e[(u+1)*2],s=e[(u+1)*2+1]):(o=e[0],s=e[1]);var l=s-i,f=-(o-a),d=Math.sqrt(l*l+f*f),h=l/d,g=f/d;n[u*4]=a+h*t,n[u*4+1]=i+g*t,n[u*4+2]=o+h*t,n[u*4+3]=s+g*t}return n},QF=function(e,t,n,a,i,o){var s=n-e,u=a-t;s/=i,u/=o;var l=Math.sqrt(s*s+u*u),f=l-1;if(f<0)return[];var d=f/l;return[(n-e)*d+e,(a-t)*d+t]},ui=function(e,t,n,a,i,o,s){return e-=i,t-=o,e/=n/2+s,t/=a/2+s,e*e+t*t<=1},Yo=function(e,t,n,a,i,o,s){var u=[n-e,a-t],l=[e-i,t-o],f=u[0]*u[0]+u[1]*u[1],d=2*(l[0]*u[0]+l[1]*u[1]),h=l[0]*l[0]+l[1]*l[1]-s*s,g=d*d-4*f*h;if(g<0)return[];var p=(-d+Math.sqrt(g))/(2*f),x=(-d-Math.sqrt(g))/(2*f),b=Math.min(p,x),w=Math.max(p,x),y=[];if(b>=0&&b<=1&&y.push(b),w>=0&&w<=1&&y.push(w),y.length===0)return[];var E=y[0]*u[0]+e,C=y[0]*u[1]+t;if(y.length>1){if(y[0]==y[1])return[E,C];var S=y[1]*u[0]+e,R=y[1]*u[1]+t;return[E,C,S,R]}else return[E,C]},Jc=function(e,t,n){return t<=e&&e<=n||n<=e&&e<=t?e:e<=t&&t<=n||n<=t&&t<=e?t:n},Ta=function(e,t,n,a,i,o,s,u,l){var f=e-i,d=n-e,h=s-i,g=t-o,p=a-t,x=u-o,b=h*g-x*f,w=d*g-p*f,y=x*d-h*p;if(y!==0){var E=b/y,C=w/y,S=.001,R=0-S,_=1+S;return R<=E&&E<=_&&R<=C&&C<=_?[e+E*d,t+E*p]:l?[e+E*d,t+E*p]:[]}else return b===0||w===0?Jc(e,n,s)===s?[s,u]:Jc(e,n,i)===i?[i,o]:Jc(i,s,n)===n?[n,a]:[]:[]},JF=function(e,t,n,a,i){var o=[],s=a/2,u=i/2,l=t,f=n;o.push({x:l+s*e[0],y:f+u*e[1]});for(var d=1;d<e.length/2;d++)o.push({x:l+s*e[d*2],y:f+u*e[d*2+1]});return o},vs=function(e,t,n,a,i,o,s,u){var l=[],f,d=new Array(n.length),h=!0;o==null&&(h=!1);var g;if(h){for(var p=0;p<d.length/2;p++)d[p*2]=n[p*2]*o+a,d[p*2+1]=n[p*2+1]*s+i;if(u>0){var x=il(d,-u);g=al(x)}else g=d}else g=n;for(var b,w,y,E,C=0;C<g.length/2;C++)b=g[C*2],w=g[C*2+1],C<g.length/2-1?(y=g[(C+1)*2],E=g[(C+1)*2+1]):(y=g[0],E=g[1]),f=Ta(e,t,a,i,b,w,y,E),f.length!==0&&l.push(f[0],f[1]);return l},ez=function(e,t,n,a,i,o,s,u,l){var f=[],d,h=new Array(n.length*2);l.forEach(function(y,E){E===0?(h[h.length-2]=y.startX,h[h.length-1]=y.startY):(h[E*4-2]=y.startX,h[E*4-1]=y.startY),h[E*4]=y.stopX,h[E*4+1]=y.stopY,d=Yo(e,t,a,i,y.cx,y.cy,y.radius),d.length!==0&&f.push(d[0],d[1])});for(var g=0;g<h.length/4;g++)d=Ta(e,t,a,i,h[g*4],h[g*4+1],h[g*4+2],h[g*4+3],!1),d.length!==0&&f.push(d[0],d[1]);if(f.length>2){for(var p=[f[0],f[1]],x=Math.pow(p[0]-e,2)+Math.pow(p[1]-t,2),b=1;b<f.length/2;b++){var w=Math.pow(f[b*2]-e,2)+Math.pow(f[b*2+1]-t,2);w<=x&&(p[0]=f[b*2],p[1]=f[b*2+1],x=w)}return p}return f},Pu=function(e,t,n){var a=[e[0]-t[0],e[1]-t[1]],i=Math.sqrt(a[0]*a[0]+a[1]*a[1]),o=(i-n)/i;return o<0&&(o=1e-5),[t[0]+o*a[0],t[1]+o*a[1]]},Mt=function(e,t){var n=Em(e,t);return n=eA(n),n},eA=function(e){for(var t,n,a=e.length/2,i=1/0,o=1/0,s=-1/0,u=-1/0,l=0;l<a;l++)t=e[2*l],n=e[2*l+1],i=Math.min(i,t),s=Math.max(s,t),o=Math.min(o,n),u=Math.max(u,n);for(var f=2/(s-i),d=2/(u-o),h=0;h<a;h++)t=e[2*h]=e[2*h]*f,n=e[2*h+1]=e[2*h+1]*d,i=Math.min(i,t),s=Math.max(s,t),o=Math.min(o,n),u=Math.max(u,n);if(o<-1)for(var g=0;g<a;g++)n=e[2*g+1]=e[2*g+1]+(-1-o);return e},Em=function(e,t){var n=1/e*2*Math.PI,a=e%2===0?Math.PI/2+n/2:Math.PI/2;a+=t;for(var i=new Array(e*2),o,s=0;s<e;s++)o=s*n+a,i[2*s]=Math.cos(o),i[2*s+1]=Math.sin(-o);return i},Ma=function(e,t){return Math.min(e/4,t/4,8)},rA=function(e,t){return Math.min(e/10,t/10,8)},r0=function(){return 8},rz=function(e,t,n){return[e-2*t+n,2*(t-e),e]},Cm=function(e,t){return{heightOffset:Math.min(15,.05*t),widthOffset:Math.min(100,.25*e),ctrlPtOffsetPct:.05}};function ed(r,e){function t(d){for(var h=[],g=0;g<d.length;g++){var p=d[g],x=d[(g+1)%d.length],b={x:x.x-p.x,y:x.y-p.y},w={x:-b.y,y:b.x},y=Math.sqrt(w.x*w.x+w.y*w.y);h.push({x:w.x/y,y:w.y/y})}return h}function n(d,h){var g=1/0,p=-1/0,x=Gt(d),b;try{for(x.s();!(b=x.n()).done;){var w=b.value,y=w.x*h.x+w.y*h.y;g=Math.min(g,y),p=Math.max(p,y)}}catch(E){x.e(E)}finally{x.f()}return{min:g,max:p}}function a(d,h){return!(d.max<h.min||h.max<d.min)}var i=[].concat(el(t(r)),el(t(e))),o=Gt(i),s;try{for(o.s();!(s=o.n()).done;){var u=s.value,l=n(r,u),f=n(e,u);if(!a(l,f))return!1}}catch(d){o.e(d)}finally{o.f()}return!0}var tz=wt({dampingFactor:.8,precision:1e-6,iterations:200,weight:function(e){return 1}}),nz={pageRank:function(e){for(var t=tz(e),n=t.dampingFactor,a=t.precision,i=t.iterations,o=t.weight,s=this._private.cy,u=this.byGroup(),l=u.nodes,f=u.edges,d=l.length,h=d*d,g=f.length,p=new Array(h),x=new Array(d),b=(1-n)/d,w=0;w<d;w++){for(var y=0;y<d;y++){var E=w*d+y;p[E]=0}x[w]=0}for(var C=0;C<g;C++){var S=f[C],R=S.data("source"),_=S.data("target");if(R!==_){var A=l.indexOfId(R),P=l.indexOfId(_),I=o(S),D=P*d+A;p[D]+=I,x[A]+=I}}for(var L=1/d+b,M=0;M<d;M++)if(x[M]===0)for(var q=0;q<d;q++){var N=q*d+M;p[N]=L}else for(var W=0;W<d;W++){var V=W*d+M;p[V]=p[V]/x[M]+b}for(var $=new Array(d),Z=new Array(d),ee,K=0;K<d;K++)$[K]=1;for(var j=0;j<i;j++){for(var fe=0;fe<d;fe++)Z[fe]=0;for(var G=0;G<d;G++)for(var z=0;z<d;z++){var Y=G*d+z;Z[G]+=p[Y]*$[z]}qF(Z),ee=$,$=Z,Z=ee;for(var te=0,ue=0;ue<d;ue++){var oe=ee[ue]-$[ue];te+=oe*oe}if(te<a)break}var X={rank:function(ie){return ie=s.collection(ie)[0],$[l.indexOf(ie)]}};return X}},Hw=wt({root:null,weight:function(e){return 1},directed:!1,alpha:0}),oo={degreeCentralityNormalized:function(e){e=Hw(e);var t=this.cy(),n=this.nodes(),a=n.length;if(e.directed){for(var f={},d={},h=0,g=0,p=0;p<a;p++){var x=n[p],b=x.id();e.root=x;var w=this.degreeCentrality(e);h<w.indegree&&(h=w.indegree),g<w.outdegree&&(g=w.outdegree),f[b]=w.indegree,d[b]=w.outdegree}return{indegree:function(E){return h==0?0:(Ye(E)&&(E=t.filter(E)),f[E.id()]/h)},outdegree:function(E){return g===0?0:(Ye(E)&&(E=t.filter(E)),d[E.id()]/g)}}}else{for(var i={},o=0,s=0;s<a;s++){var u=n[s];e.root=u;var l=this.degreeCentrality(e);o<l.degree&&(o=l.degree),i[u.id()]=l.degree}return{degree:function(E){return o===0?0:(Ye(E)&&(E=t.filter(E)),i[E.id()]/o)}}}},degreeCentrality:function(e){e=Hw(e);var t=this.cy(),n=this,a=e,i=a.root,o=a.weight,s=a.directed,u=a.alpha;if(i=t.collection(i)[0],s){for(var g=i.connectedEdges(),p=g.filter(function(R){return R.target().same(i)&&n.has(R)}),x=g.filter(function(R){return R.source().same(i)&&n.has(R)}),b=p.length,w=x.length,y=0,E=0,C=0;C<p.length;C++)y+=o(p[C]);for(var S=0;S<x.length;S++)E+=o(x[S]);return{indegree:Math.pow(b,1-u)*Math.pow(y,u),outdegree:Math.pow(w,1-u)*Math.pow(E,u)}}else{for(var l=i.connectedEdges().intersection(n),f=l.length,d=0,h=0;h<l.length;h++)d+=o(l[h]);return{degree:Math.pow(f,1-u)*Math.pow(d,u)}}}};oo.dc=oo.degreeCentrality;oo.dcn=oo.degreeCentralityNormalised=oo.degreeCentralityNormalized;var Kw=wt({harmonic:!0,weight:function(){return 1},directed:!1,root:null}),so={closenessCentralityNormalized:function(e){for(var t=Kw(e),n=t.harmonic,a=t.weight,i=t.directed,o=this.cy(),s={},u=0,l=this.nodes(),f=this.floydWarshall({weight:a,directed:i}),d=0;d<l.length;d++){for(var h=0,g=l[d],p=0;p<l.length;p++)if(d!==p){var x=f.distance(g,l[p]);n?h+=1/x:h+=x}n||(h=1/h),u<h&&(u=h),s[g.id()]=h}return{closeness:function(w){return u==0?0:(Ye(w)?w=o.filter(w)[0].id():w=w.id(),s[w]/u)}}},closenessCentrality:function(e){var t=Kw(e),n=t.root,a=t.weight,i=t.directed,o=t.harmonic;n=this.filter(n)[0];for(var s=this.dijkstra({root:n,weight:a,directed:i}),u=0,l=this.nodes(),f=0;f<l.length;f++){var d=l[f];if(!d.same(n)){var h=s.distanceTo(d);o?u+=1/h:u+=h}}return o?u:1/u}};so.cc=so.closenessCentrality;so.ccn=so.closenessCentralityNormalised=so.closenessCentralityNormalized;var az=wt({weight:null,directed:!1}),_m={betweennessCentrality:function(e){for(var t=az(e),n=t.directed,a=t.weight,i=a!=null,o=this.cy(),s=this.nodes(),u={},l={},f=0,d={set:function(E,C){l[E]=C,C>f&&(f=C)},get:function(E){return l[E]}},h=0;h<s.length;h++){var g=s[h],p=g.id();n?u[p]=g.outgoers().nodes():u[p]=g.openNeighborhood().nodes(),d.set(p,0)}for(var x=function(){for(var E=s[b].id(),C=[],S={},R={},_={},A=new Ts(function(G,z){return _[G]-_[z]}),P=0;P<s.length;P++){var I=s[P].id();S[I]=[],R[I]=0,_[I]=1/0}for(R[E]=1,_[E]=0,A.push(E);!A.empty();){var D=A.pop();if(C.push(D),i)for(var L=0;L<u[D].length;L++){var M=u[D][L],q=o.getElementById(D),N=void 0;q.edgesTo(M).length>0?N=q.edgesTo(M)[0]:N=M.edgesTo(q)[0];var W=a(N);M=M.id(),_[M]>_[D]+W&&(_[M]=_[D]+W,A.nodes.indexOf(M)<0?A.push(M):A.updateItem(M),R[M]=0,S[M]=[]),_[M]==_[D]+W&&(R[M]=R[M]+R[D],S[M].push(D))}else for(var V=0;V<u[D].length;V++){var $=u[D][V].id();_[$]==1/0&&(A.push($),_[$]=_[D]+1),_[$]==_[D]+1&&(R[$]=R[$]+R[D],S[$].push(D))}}for(var Z={},ee=0;ee<s.length;ee++)Z[s[ee].id()]=0;for(;C.length>0;){for(var K=C.pop(),j=0;j<S[K].length;j++){var fe=S[K][j];Z[fe]=Z[fe]+R[fe]/R[K]*(1+Z[K])}K!=s[b].id()&&d.set(K,d.get(K)+Z[K])}},b=0;b<s.length;b++)x();var w={betweenness:function(E){var C=o.collection(E).id();return d.get(C)},betweennessNormalized:function(E){if(f==0)return 0;var C=o.collection(E).id();return d.get(C)/f}};return w.betweennessNormalised=w.betweennessNormalized,w}};_m.bc=_m.betweennessCentrality;var iz=wt({expandFactor:2,inflateFactor:2,multFactor:1,maxIterations:20,attributes:[function(r){return 1}]}),oz=function(e){return iz(e)},sz=function(e,t){for(var n=0,a=0;a<t.length;a++)n+=t[a](e);return n},uz=function(e,t,n){for(var a=0;a<t;a++)e[a*t+a]=n},tA=function(e,t){for(var n,a=0;a<t;a++){n=0;for(var i=0;i<t;i++)n+=e[i*t+a];for(var o=0;o<t;o++)e[o*t+a]=e[o*t+a]/n}},lz=function(e,t,n){for(var a=new Array(n*n),i=0;i<n;i++){for(var o=0;o<n;o++)a[i*n+o]=0;for(var s=0;s<n;s++)for(var u=0;u<n;u++)a[i*n+u]+=e[i*n+s]*t[s*n+u]}return a},fz=function(e,t,n){for(var a=e.slice(0),i=1;i<n;i++)e=lz(e,a,t);return e},cz=function(e,t,n){for(var a=new Array(t*t),i=0;i<t*t;i++)a[i]=Math.pow(e[i],n);return tA(a,t),a},dz=function(e,t,n,a){for(var i=0;i<n;i++){var o=Math.round(e[i]*Math.pow(10,a))/Math.pow(10,a),s=Math.round(t[i]*Math.pow(10,a))/Math.pow(10,a);if(o!==s)return!1}return!0},vz=function(e,t,n,a){for(var i=[],o=0;o<t;o++){for(var s=[],u=0;u<t;u++)Math.round(e[o*t+u]*1e3)/1e3>0&&s.push(n[u]);s.length!==0&&i.push(a.collection(s))}return i},hz=function(e,t){for(var n=0;n<e.length;n++)if(!t[n]||e[n].id()!==t[n].id())return!1;return!0},gz=function(e){for(var t=0;t<e.length;t++)for(var n=0;n<e.length;n++)t!=n&&hz(e[t],e[n])&&e.splice(n,1);return e},jw=function(e){for(var t=this.nodes(),n=this.edges(),a=this.cy(),i=oz(e),o={},s=0;s<t.length;s++)o[t[s].id()]=s;for(var u=t.length,l=u*u,f=new Array(l),d,h=0;h<l;h++)f[h]=0;for(var g=0;g<n.length;g++){var p=n[g],x=o[p.source().id()],b=o[p.target().id()],w=sz(p,i.attributes);f[x*u+b]+=w,f[b*u+x]+=w}uz(f,u,i.multFactor),tA(f,u);for(var y=!0,E=0;y&&E<i.maxIterations;)y=!1,d=fz(f,u,i.expandFactor),f=cz(d,u,i.inflateFactor),dz(f,d,l,4)||(y=!0),E++;var C=vz(f,u,t,a);return C=gz(C),C},pz={markovClustering:jw,mcl:jw},yz=function(e){return e},nA=function(e,t){return Math.abs(t-e)},Yw=function(e,t,n){return e+nA(t,n)},Zw=function(e,t,n){return e+Math.pow(n-t,2)},mz=function(e){return Math.sqrt(e)},bz=function(e,t,n){return Math.max(e,nA(t,n))},zo=function(e,t,n,a,i){for(var o=arguments.length>5&&arguments[5]!==void 0?arguments[5]:yz,s=a,u,l,f=0;f<e;f++)u=t(f),l=n(f),s=i(s,u,l);return o(s)},fo={euclidean:function(e,t,n){return e>=2?zo(e,t,n,0,Zw,mz):zo(e,t,n,0,Yw)},squaredEuclidean:function(e,t,n){return zo(e,t,n,0,Zw)},manhattan:function(e,t,n){return zo(e,t,n,0,Yw)},max:function(e,t,n){return zo(e,t,n,-1/0,bz)}};fo["squared-euclidean"]=fo.squaredEuclidean;fo.squaredeuclidean=fo.squaredEuclidean;function Cl(r,e,t,n,a,i){var o;return $r(r)?o=r:o=fo[r]||fo.euclidean,e===0&&$r(r)?o(a,i):o(e,t,n,a,i)}var wz=wt({k:2,m:2,sensitivityThreshold:1e-4,distance:"euclidean",maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),t0=function(e){return wz(e)},ol=function(e,t,n,a,i){var o=i!=="kMedoids",s=o?function(d){return n[d]}:function(d){return a[d](n)},u=function(h){return a[h](t)},l=n,f=t;return Cl(e,a.length,s,u,l,f)},rd=function(e,t,n){for(var a=n.length,i=new Array(a),o=new Array(a),s=new Array(t),u=null,l=0;l<a;l++)i[l]=e.min(n[l]).value,o[l]=e.max(n[l]).value;for(var f=0;f<t;f++){u=[];for(var d=0;d<a;d++)u[d]=Math.random()*(o[d]-i[d])+i[d];s[f]=u}return s},aA=function(e,t,n,a,i){for(var o=1/0,s=0,u=0;u<t.length;u++){var l=ol(n,e,t[u],a,i);l<o&&(o=l,s=u)}return s},iA=function(e,t,n){for(var a=[],i=null,o=0;o<t.length;o++)i=t[o],n[i.id()]===e&&a.push(i);return a},xz=function(e,t,n){return Math.abs(t-e)<=n},Ez=function(e,t,n){for(var a=0;a<e.length;a++)for(var i=0;i<e[a].length;i++){var o=Math.abs(e[a][i]-t[a][i]);if(o>n)return!1}return!0},Cz=function(e,t,n){for(var a=0;a<n;a++)if(e===t[a])return!0;return!1},Xw=function(e,t){var n=new Array(t);if(e.length<50)for(var a=0;a<t;a++){for(var i=e[Math.floor(Math.random()*e.length)];Cz(i,n,a);)i=e[Math.floor(Math.random()*e.length)];n[a]=i}else for(var o=0;o<t;o++)n[o]=e[Math.floor(Math.random()*e.length)];return n},Qw=function(e,t,n){for(var a=0,i=0;i<t.length;i++)a+=ol("manhattan",t[i],e,n,"kMedoids");return a},_z=function(e){var t=this.cy(),n=this.nodes(),a=null,i=t0(e),o=new Array(i.k),s={},u;i.testMode?typeof i.testCentroids=="number"?(i.testCentroids,u=rd(n,i.k,i.attributes)):at(i.testCentroids)==="object"?u=i.testCentroids:u=rd(n,i.k,i.attributes):u=rd(n,i.k,i.attributes);for(var l=!0,f=0;l&&f<i.maxIterations;){for(var d=0;d<n.length;d++)a=n[d],s[a.id()]=aA(a,u,i.distance,i.attributes,"kMeans");l=!1;for(var h=0;h<i.k;h++){var g=iA(h,n,s);if(g.length!==0){for(var p=i.attributes.length,x=u[h],b=new Array(p),w=new Array(p),y=0;y<p;y++){w[y]=0;for(var E=0;E<g.length;E++)a=g[E],w[y]+=i.attributes[y](a);b[y]=w[y]/g.length,xz(b[y],x[y],i.sensitivityThreshold)||(l=!0)}u[h]=b,o[h]=t.collection(g)}}f++}return o},Sz=function(e){var t=this.cy(),n=this.nodes(),a=null,i=t0(e),o=new Array(i.k),s,u={},l,f=new Array(i.k);i.testMode?typeof i.testCentroids=="number"||(at(i.testCentroids)==="object"?s=i.testCentroids:s=Xw(n,i.k)):s=Xw(n,i.k);for(var d=!0,h=0;d&&h<i.maxIterations;){for(var g=0;g<n.length;g++)a=n[g],u[a.id()]=aA(a,s,i.distance,i.attributes,"kMedoids");d=!1;for(var p=0;p<s.length;p++){var x=iA(p,n,u);if(x.length!==0){f[p]=Qw(s[p],x,i.attributes);for(var b=0;b<x.length;b++)l=Qw(x[b],x,i.attributes),l<f[p]&&(f[p]=l,s[p]=x[b],d=!0);o[p]=t.collection(x)}}h++}return o},Tz=function(e,t,n,a,i){for(var o,s,u=0;u<t.length;u++)for(var l=0;l<e.length;l++)a[u][l]=Math.pow(n[u][l],i.m);for(var f=0;f<e.length;f++)for(var d=0;d<i.attributes.length;d++){o=0,s=0;for(var h=0;h<t.length;h++)o+=a[h][f]*i.attributes[d](t[h]),s+=a[h][f];e[f][d]=o/s}},Rz=function(e,t,n,a,i){for(var o=0;o<e.length;o++)t[o]=e[o].slice();for(var s,u,l,f=2/(i.m-1),d=0;d<n.length;d++)for(var h=0;h<a.length;h++){s=0;for(var g=0;g<n.length;g++)u=ol(i.distance,a[h],n[d],i.attributes,"cmeans"),l=ol(i.distance,a[h],n[g],i.attributes,"cmeans"),s+=Math.pow(u/l,f);e[h][d]=1/s}},Az=function(e,t,n,a){for(var i=new Array(n.k),o=0;o<i.length;o++)i[o]=[];for(var s,u,l=0;l<t.length;l++){s=-1/0,u=-1;for(var f=0;f<t[0].length;f++)t[l][f]>s&&(s=t[l][f],u=f);i[u].push(e[l])}for(var d=0;d<i.length;d++)i[d]=a.collection(i[d]);return i},Jw=function(e){var t=this.cy(),n=this.nodes(),a=t0(e),i,o,s,u,l;u=new Array(n.length);for(var f=0;f<n.length;f++)u[f]=new Array(a.k);s=new Array(n.length);for(var d=0;d<n.length;d++)s[d]=new Array(a.k);for(var h=0;h<n.length;h++){for(var g=0,p=0;p<a.k;p++)s[h][p]=Math.random(),g+=s[h][p];for(var x=0;x<a.k;x++)s[h][x]=s[h][x]/g}o=new Array(a.k);for(var b=0;b<a.k;b++)o[b]=new Array(a.attributes.length);l=new Array(n.length);for(var w=0;w<n.length;w++)l[w]=new Array(a.k);for(var y=!0,E=0;y&&E<a.maxIterations;)y=!1,Tz(o,n,s,l,a),Rz(s,u,o,n,a),Ez(s,u,a.sensitivityThreshold)||(y=!0),E++;return i=Az(n,s,a,t),{clusters:i,degreeOfMembership:s}},Pz={kMeans:_z,kMedoids:Sz,fuzzyCMeans:Jw,fcm:Jw},Iz=wt({distance:"euclidean",linkage:"min",mode:"threshold",threshold:1/0,addDendrogram:!1,dendrogramDepth:0,attributes:[]}),Dz={single:"min",complete:"max"},Bz=function(e){var t=Iz(e),n=Dz[t.linkage];return n!=null&&(t.linkage=n),t},ex=function(e,t,n,a,i){for(var o=0,s=1/0,u,l=i.attributes,f=function(P,I){return Cl(i.distance,l.length,function(D){return l[D](P)},function(D){return l[D](I)},P,I)},d=0;d<e.length;d++){var h=e[d].key,g=n[h][a[h]];g<s&&(o=h,s=g)}if(i.mode==="threshold"&&s>=i.threshold||i.mode==="dendrogram"&&e.length===1)return!1;var p=t[o],x=t[a[o]],b;i.mode==="dendrogram"?b={left:p,right:x,key:p.key}:b={value:p.value.concat(x.value),key:p.key},e[p.index]=b,e.splice(x.index,1),t[p.key]=b;for(var w=0;w<e.length;w++){var y=e[w];p.key===y.key?u=1/0:i.linkage==="min"?(u=n[p.key][y.key],n[p.key][y.key]>n[x.key][y.key]&&(u=n[x.key][y.key])):i.linkage==="max"?(u=n[p.key][y.key],n[p.key][y.key]<n[x.key][y.key]&&(u=n[x.key][y.key])):i.linkage==="mean"?u=(n[p.key][y.key]*p.size+n[x.key][y.key]*x.size)/(p.size+x.size):i.mode==="dendrogram"?u=f(y.value,p.value):u=f(y.value[0],p.value[0]),n[p.key][y.key]=n[y.key][p.key]=u}for(var E=0;E<e.length;E++){var C=e[E].key;if(a[C]===p.key||a[C]===x.key){for(var S=C,R=0;R<e.length;R++){var _=e[R].key;n[C][_]<n[C][S]&&(S=_)}a[C]=S}e[E].index=E}return p.key=x.key=p.index=x.index=null,!0},eo=function(e,t,n){e&&(e.value?t.push(e.value):(e.left&&eo(e.left,t),e.right&&eo(e.right,t)))},Sm=function(e,t){if(!e)return"";if(e.left&&e.right){var n=Sm(e.left,t),a=Sm(e.right,t),i=t.add({group:"nodes",data:{id:n+","+a}});return t.add({group:"edges",data:{source:n,target:i.id()}}),t.add({group:"edges",data:{source:a,target:i.id()}}),i.id()}else if(e.value)return e.value.id()},Tm=function(e,t,n){if(!e)return[];var a=[],i=[],o=[];return t===0?(e.left&&eo(e.left,a),e.right&&eo(e.right,i),o=a.concat(i),[n.collection(o)]):t===1?e.value?[n.collection(e.value)]:(e.left&&eo(e.left,a),e.right&&eo(e.right,i),[n.collection(a),n.collection(i)]):e.value?[n.collection(e.value)]:(e.left&&(a=Tm(e.left,t-1,n)),e.right&&(i=Tm(e.right,t-1,n)),a.concat(i))},rx=function(e){for(var t=this.cy(),n=this.nodes(),a=Bz(e),i=a.attributes,o=function(E,C){return Cl(a.distance,i.length,function(S){return i[S](E)},function(S){return i[S](C)},E,C)},s=[],u=[],l=[],f=[],d=0;d<n.length;d++){var h={value:a.mode==="dendrogram"?n[d]:[n[d]],key:d,index:d};s[d]=h,f[d]=h,u[d]=[],l[d]=0}for(var g=0;g<s.length;g++)for(var p=0;p<=g;p++){var x=void 0;a.mode==="dendrogram"?x=g===p?1/0:o(s[g].value,s[p].value):x=g===p?1/0:o(s[g].value[0],s[p].value[0]),u[g][p]=x,u[p][g]=x,x<u[g][l[g]]&&(l[g]=p)}for(var b=ex(s,f,u,l,a);b;)b=ex(s,f,u,l,a);var w;return a.mode==="dendrogram"?(w=Tm(s[0],a.dendrogramDepth,t),a.addDendrogram&&Sm(s[0],t)):(w=new Array(s.length),s.forEach(function(y,E){y.key=y.index=null,w[E]=t.collection(y.value)})),w},Mz={hierarchicalClustering:rx,hca:rx},Lz=wt({distance:"euclidean",preference:"median",damping:.8,maxIterations:1e3,minIterations:100,attributes:[]}),Oz=function(e){var t=e.damping,n=e.preference;.5<=t&&t<1||kr("Damping must range on [0.5, 1). Got: ".concat(t));var a=["median","mean","min","max"];return a.some(function(i){return i===n})||qe(n)||kr("Preference must be one of [".concat(a.map(function(i){return"'".concat(i,"'")}).join(", "),"] or a number. Got: ").concat(n)),Lz(e)},kz=function(e,t,n,a){var i=function(s,u){return a[u](s)};return-Cl(e,a.length,function(o){return i(t,o)},function(o){return i(n,o)},t,n)},qz=function(e,t){var n=null;return t==="median"?n=OF(e):t==="mean"?n=LF(e):t==="min"?n=BF(e):t==="max"?n=MF(e):n=t,n},Nz=function(e,t,n){for(var a=[],i=0;i<e;i++)t[i*e+i]+n[i*e+i]>0&&a.push(i);return a},tx=function(e,t,n){for(var a=[],i=0;i<e;i++){for(var o=-1,s=-1/0,u=0;u<n.length;u++){var l=n[u];t[i*e+l]>s&&(o=l,s=t[i*e+l])}o>0&&a.push(o)}for(var f=0;f<n.length;f++)a[n[f]]=n[f];return a},Fz=function(e,t,n){for(var a=tx(e,t,n),i=0;i<n.length;i++){for(var o=[],s=0;s<a.length;s++)a[s]===n[i]&&o.push(s);for(var u=-1,l=-1/0,f=0;f<o.length;f++){for(var d=0,h=0;h<o.length;h++)d+=t[o[h]*e+o[f]];d>l&&(u=f,l=d)}n[i]=o[u]}return a=tx(e,t,n),a},nx=function(e){for(var t=this.cy(),n=this.nodes(),a=Oz(e),i={},o=0;o<n.length;o++)i[n[o].id()]=o;var s,u,l,f,d,h;s=n.length,u=s*s,l=new Array(u);for(var g=0;g<u;g++)l[g]=-1/0;for(var p=0;p<s;p++)for(var x=0;x<s;x++)p!==x&&(l[p*s+x]=kz(a.distance,n[p],n[x],a.attributes));f=qz(l,a.preference);for(var b=0;b<s;b++)l[b*s+b]=f;d=new Array(u);for(var w=0;w<u;w++)d[w]=0;h=new Array(u);for(var y=0;y<u;y++)h[y]=0;for(var E=new Array(s),C=new Array(s),S=new Array(s),R=0;R<s;R++)E[R]=0,C[R]=0,S[R]=0;for(var _=new Array(s*a.minIterations),A=0;A<_.length;A++)_[A]=0;var P;for(P=0;P<a.maxIterations;P++){for(var I=0;I<s;I++){for(var D=-1/0,L=-1/0,M=-1,q=0,N=0;N<s;N++)E[N]=d[I*s+N],q=h[I*s+N]+l[I*s+N],q>=D?(L=D,D=q,M=N):q>L&&(L=q);for(var W=0;W<s;W++)d[I*s+W]=(1-a.damping)*(l[I*s+W]-D)+a.damping*E[W];d[I*s+M]=(1-a.damping)*(l[I*s+M]-L)+a.damping*E[M]}for(var V=0;V<s;V++){for(var $=0,Z=0;Z<s;Z++)E[Z]=h[Z*s+V],C[Z]=Math.max(0,d[Z*s+V]),$+=C[Z];$-=C[V],C[V]=d[V*s+V],$+=C[V];for(var ee=0;ee<s;ee++)h[ee*s+V]=(1-a.damping)*Math.min(0,$-C[ee])+a.damping*E[ee];h[V*s+V]=(1-a.damping)*($-C[V])+a.damping*E[V]}for(var K=0,j=0;j<s;j++){var fe=h[j*s+j]+d[j*s+j]>0?1:0;_[P%a.minIterations*s+j]=fe,K+=fe}if(K>0&&(P>=a.minIterations-1||P==a.maxIterations-1)){for(var G=0,z=0;z<s;z++){S[z]=0;for(var Y=0;Y<a.minIterations;Y++)S[z]+=_[Y*s+z];(S[z]===0||S[z]===a.minIterations)&&G++}if(G===s)break}}for(var te=Nz(s,d,h),ue=Fz(s,l,te),oe={},X=0;X<te.length;X++)oe[te[X]]=[];for(var Q=0;Q<n.length;Q++){var ie=i[n[Q].id()],de=ue[ie];de!=null&&oe[de].push(n[Q])}for(var we=new Array(te.length),Ae=0;Ae<te.length;Ae++)we[Ae]=t.collection(oe[te[Ae]]);return we},zz={affinityPropagation:nx,ap:nx},$z=wt({root:void 0,directed:!1}),Vz={hierholzer:function(e){if(!yr(e)){var t=arguments;e={root:t[0],directed:t[1]}}var n=$z(e),a=n.root,i=n.directed,o=this,s=!1,u,l,f;a&&(f=Ye(a)?this.filter(a)[0].id():a[0].id());var d={},h={};i?o.forEach(function(y){var E=y.id();if(y.isNode()){var C=y.indegree(!0),S=y.outdegree(!0),R=C-S,_=S-C;R==1?u?s=!0:u=E:_==1?l?s=!0:l=E:(_>1||R>1)&&(s=!0),d[E]=[],y.outgoers().forEach(function(A){A.isEdge()&&d[E].push(A.id())})}else h[E]=[void 0,y.target().id()]}):o.forEach(function(y){var E=y.id();if(y.isNode()){var C=y.degree(!0);C%2&&(u?l?s=!0:l=E:u=E),d[E]=[],y.connectedEdges().forEach(function(S){return d[E].push(S.id())})}else h[E]=[y.source().id(),y.target().id()]});var g={found:!1,trail:void 0};if(s)return g;if(l&&u)if(i){if(f&&l!=f)return g;f=l}else{if(f&&l!=f&&u!=f)return g;f||(f=l)}else f||(f=o[0].id());var p=function(E){for(var C=E,S=[E],R,_,A;d[C].length;)R=d[C].shift(),_=h[R][0],A=h[R][1],C!=A?(d[A]=d[A].filter(function(P){return P!=R}),C=A):!i&&C!=_&&(d[_]=d[_].filter(function(P){return P!=R}),C=_),S.unshift(R),S.unshift(C);return S},x=[],b=[];for(b=p(f);b.length!=1;)d[b[0]].length==0?(x.unshift(o.getElementById(b.shift())),x.unshift(o.getElementById(b.shift()))):b=p(b.shift()).concat(b);x.unshift(o.getElementById(b.shift()));for(var w in d)if(d[w].length)return g;return g.found=!0,g.trail=this.spawn(x,!0),g}},Iu=function(){var e=this,t={},n=0,a=0,i=[],o=[],s={},u=function(h,g){for(var p=o.length-1,x=[],b=e.spawn();o[p].x!=h||o[p].y!=g;)x.push(o.pop().edge),p--;x.push(o.pop().edge),x.forEach(function(w){var y=w.connectedNodes().intersection(e);b.merge(w),y.forEach(function(E){var C=E.id(),S=E.connectedEdges().intersection(e);b.merge(E),t[C].cutVertex?b.merge(S.filter(function(R){return R.isLoop()})):b.merge(S)})}),i.push(b)},l=function(h,g,p){h===p&&(a+=1),t[g]={id:n,low:n++,cutVertex:!1};var x=e.getElementById(g).connectedEdges().intersection(e);if(x.size()===0)i.push(e.spawn(e.getElementById(g)));else{var b,w,y,E;x.forEach(function(C){b=C.source().id(),w=C.target().id(),y=b===g?w:b,y!==p&&(E=C.id(),s[E]||(s[E]=!0,o.push({x:g,y,edge:C})),y in t?t[g].low=Math.min(t[g].low,t[y].id):(l(h,y,g),t[g].low=Math.min(t[g].low,t[y].low),t[g].id<=t[y].low&&(t[g].cutVertex=!0,u(g,y))))})}};e.forEach(function(d){if(d.isNode()){var h=d.id();h in t||(a=0,l(h,h),t[h].cutVertex=a>1)}});var f=Object.keys(t).filter(function(d){return t[d].cutVertex}).map(function(d){return e.getElementById(d)});return{cut:e.spawn(f),components:i}},Gz={hopcroftTarjanBiconnected:Iu,htbc:Iu,htb:Iu,hopcroftTarjanBiconnectedComponents:Iu},Du=function(){var e=this,t={},n=0,a=[],i=[],o=e.spawn(e),s=function(l){i.push(l),t[l]={index:n,low:n++,explored:!1};var f=e.getElementById(l).connectedEdges().intersection(e);if(f.forEach(function(x){var b=x.target().id();b!==l&&(b in t||s(b),t[b].explored||(t[l].low=Math.min(t[l].low,t[b].low)))}),t[l].index===t[l].low){for(var d=e.spawn();;){var h=i.pop();if(d.merge(e.getElementById(h)),t[h].low=t[l].index,t[h].explored=!0,h===l)break}var g=d.edgesWith(d),p=d.merge(g);a.push(p),o=o.difference(p)}};return e.forEach(function(u){if(u.isNode()){var l=u.id();l in t||s(l)}}),{cut:o,components:a}},Wz={tarjanStronglyConnected:Du,tsc:Du,tscc:Du,tarjanStronglyConnectedComponents:Du},oA={};[cs,wF,xF,CF,SF,RF,IF,nz,oo,so,_m,pz,Pz,Mz,zz,Vz,Gz,Wz].forEach(function(r){Xe(oA,r)});/*!
31
- Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable
32
- Copyright (c) 2013-2014 Ralf S. Engelschall (http://engelschall.com)
33
- Licensed under The MIT License (http://opensource.org/licenses/MIT)
34
- */var sA=0,uA=1,lA=2,Sn=function(e){if(!(this instanceof Sn))return new Sn(e);this.id="Thenable/1.0.7",this.state=sA,this.fulfillValue=void 0,this.rejectReason=void 0,this.onFulfilled=[],this.onRejected=[],this.proxy={then:this.then.bind(this)},typeof e=="function"&&e.call(this,this.fulfill.bind(this),this.reject.bind(this))};Sn.prototype={fulfill:function(e){return ax(this,uA,"fulfillValue",e)},reject:function(e){return ax(this,lA,"rejectReason",e)},then:function(e,t){var n=this,a=new Sn;return n.onFulfilled.push(ox(e,a,"fulfill")),n.onRejected.push(ox(t,a,"reject")),fA(n),a.proxy}};var ax=function(e,t,n,a){return e.state===sA&&(e.state=t,e[n]=a,fA(e)),e},fA=function(e){e.state===uA?ix(e,"onFulfilled",e.fulfillValue):e.state===lA&&ix(e,"onRejected",e.rejectReason)},ix=function(e,t,n){if(e[t].length!==0){var a=e[t];e[t]=[];var i=function(){for(var s=0;s<a.length;s++)a[s](n)};typeof setImmediate=="function"?setImmediate(i):setTimeout(i,0)}},ox=function(e,t,n){return function(a){if(typeof e!="function")t[n].call(t,a);else{var i;try{i=e(a)}catch(o){t.reject(o);return}cA(t,i)}}},cA=function(e,t){if(e===t||e.proxy===t){e.reject(new TypeError("cannot resolve promise with itself"));return}var n;if(at(t)==="object"&&t!==null||typeof t=="function")try{n=t.then}catch(i){e.reject(i);return}if(typeof n=="function"){var a=!1;try{n.call(t,function(i){a||(a=!0,i===t?e.reject(new TypeError("circular thenable chain")):cA(e,i))},function(i){a||(a=!0,e.reject(i))})}catch(i){a||e.reject(i)}return}e.fulfill(t)};Sn.all=function(r){return new Sn(function(e,t){for(var n=new Array(r.length),a=0,i=function(u,l){n[u]=l,a++,a===r.length&&e(n)},o=0;o<r.length;o++)(function(s){var u=r[s],l=u!=null&&u.then!=null;if(l)u.then(function(d){i(s,d)},function(d){t(d)});else{var f=u;i(s,f)}})(o)})};Sn.resolve=function(r){return new Sn(function(e,t){e(r)})};Sn.reject=function(r){return new Sn(function(e,t){t(r)})};var po=typeof Promise<"u"?Promise:Sn,Rm=function(e,t,n){var a=Hm(e),i=!a,o=this._private=Xe({duration:1e3},t,n);if(o.target=e,o.style=o.style||o.css,o.started=!1,o.playing=!1,o.hooked=!1,o.applying=!1,o.progress=0,o.completes=[],o.frames=[],o.complete&&$r(o.complete)&&o.completes.push(o.complete),i){var s=e.position();o.startPosition=o.startPosition||{x:s.x,y:s.y},o.startStyle=o.startStyle||e.cy().style().getAnimationStartStyle(e,o.style)}if(a){var u=e.pan();o.startPan={x:u.x,y:u.y},o.startZoom=e.zoom()}this.length=1,this[0]=this},vi=Rm.prototype;Xe(vi,{instanceString:function(){return"animation"},hook:function(){var e=this._private;if(!e.hooked){var t,n=e.target._private.animation;e.queue?t=n.queue:t=n.current,t.push(this),Jt(e.target)&&e.target.cy().addToAnimationPool(e.target),e.hooked=!0}return this},play:function(){var e=this._private;return e.progress===1&&(e.progress=0),e.playing=!0,e.started=!1,e.stopped=!1,this.hook(),this},playing:function(){return this._private.playing},apply:function(){var e=this._private;return e.applying=!0,e.started=!1,e.stopped=!1,this.hook(),this},applying:function(){return this._private.applying},pause:function(){var e=this._private;return e.playing=!1,e.started=!1,this},stop:function(){var e=this._private;return e.playing=!1,e.started=!1,e.stopped=!0,this},rewind:function(){return this.progress(0)},fastforward:function(){return this.progress(1)},time:function(e){var t=this._private;return e===void 0?t.progress*t.duration:this.progress(e/t.duration)},progress:function(e){var t=this._private,n=t.playing;return e===void 0?t.progress:(n&&this.pause(),t.progress=e,t.started=!1,n&&this.play(),this)},completed:function(){return this._private.progress===1},reverse:function(){var e=this._private,t=e.playing;t&&this.pause(),e.progress=1-e.progress,e.started=!1;var n=function(l,f){var d=e[l];d!=null&&(e[l]=e[f],e[f]=d)};if(n("zoom","startZoom"),n("pan","startPan"),n("position","startPosition"),e.style)for(var a=0;a<e.style.length;a++){var i=e.style[a],o=i.name,s=e.startStyle[o];e.startStyle[o]=i,e.style[a]=s}return t&&this.play(),this},promise:function(e){var t=this._private,n;switch(e){case"frame":n=t.frames;break;default:case"complete":case"completed":n=t.completes}return new po(function(a,i){n.push(function(){a()})})}});vi.complete=vi.completed;vi.run=vi.play;vi.running=vi.playing;var Uz={animated:function(){return function(){var t=this,n=t.length!==void 0,a=n?t:[t],i=this._private.cy||this;if(!i.styleEnabled())return!1;var o=a[0];if(o)return o._private.animation.current.length>0}},clearQueue:function(){return function(){var t=this,n=t.length!==void 0,a=n?t:[t],i=this._private.cy||this;if(!i.styleEnabled())return this;for(var o=0;o<a.length;o++){var s=a[o];s._private.animation.queue=[]}return this}},delay:function(){return function(t,n){var a=this._private.cy||this;return a.styleEnabled()?this.animate({delay:t,duration:t,complete:n}):this}},delayAnimation:function(){return function(t,n){var a=this._private.cy||this;return a.styleEnabled()?this.animation({delay:t,duration:t,complete:n}):this}},animation:function(){return function(t,n){var a=this,i=a.length!==void 0,o=i?a:[a],s=this._private.cy||this,u=!i,l=!u;if(!s.styleEnabled())return this;var f=s.style();t=Xe({},t,n);var d=Object.keys(t).length===0;if(d)return new Rm(o[0],t);switch(t.duration===void 0&&(t.duration=400),t.duration){case"slow":t.duration=600;break;case"fast":t.duration=200;break}if(l&&(t.style=f.getPropsList(t.style||t.css),t.css=void 0),l&&t.renderedPosition!=null){var h=t.renderedPosition,g=s.pan(),p=s.zoom();t.position=Z2(h,p,g)}if(u&&t.panBy!=null){var x=t.panBy,b=s.pan();t.pan={x:b.x+x.x,y:b.y+x.y}}var w=t.center||t.centre;if(u&&w!=null){var y=s.getCenterPan(w.eles,t.zoom);y!=null&&(t.pan=y)}if(u&&t.fit!=null){var E=t.fit,C=s.getFitViewport(E.eles||E.boundingBox,E.padding);C!=null&&(t.pan=C.pan,t.zoom=C.zoom)}if(u&&yr(t.zoom)){var S=s.getZoomedViewport(t.zoom);S!=null?(S.zoomed&&(t.zoom=S.zoom),S.panned&&(t.pan=S.pan)):t.zoom=null}return new Rm(o[0],t)}},animate:function(){return function(t,n){var a=this,i=a.length!==void 0,o=i?a:[a],s=this._private.cy||this;if(!s.styleEnabled())return this;n&&(t=Xe({},t,n));for(var u=0;u<o.length;u++){var l=o[u],f=l.animated()&&(t.queue===void 0||t.queue),d=l.animation(t,f?{queue:!0}:void 0);d.play()}return this}},stop:function(){return function(t,n){var a=this,i=a.length!==void 0,o=i?a:[a],s=this._private.cy||this;if(!s.styleEnabled())return this;for(var u=0;u<o.length;u++){for(var l=o[u],f=l._private,d=f.animation.current,h=0;h<d.length;h++){var g=d[h],p=g._private;n&&(p.duration=0)}t&&(f.animation.queue=[]),n||(f.animation.current=[])}return s.notify("draw"),this}}},td,sx;function _l(){if(sx)return td;sx=1;var r=Array.isArray;return td=r,td}var nd,ux;function Hz(){if(ux)return nd;ux=1;var r=_l(),e=_s(),t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function a(i,o){if(r(i))return!1;var s=typeof i;return s=="number"||s=="symbol"||s=="boolean"||i==null||e(i)?!0:n.test(i)||!t.test(i)||o!=null&&i in Object(o)}return nd=a,nd}var ad,lx;function Kz(){if(lx)return ad;lx=1;var r=$2(),e=Cs(),t="[object AsyncFunction]",n="[object Function]",a="[object GeneratorFunction]",i="[object Proxy]";function o(s){if(!e(s))return!1;var u=r(s);return u==n||u==a||u==t||u==i}return ad=o,ad}var id,fx;function jz(){if(fx)return id;fx=1;var r=wl(),e=r["__core-js_shared__"];return id=e,id}var od,cx;function Yz(){if(cx)return od;cx=1;var r=jz(),e=(function(){var n=/[^.]+$/.exec(r&&r.keys&&r.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function t(n){return!!e&&e in n}return od=t,od}var sd,dx;function Zz(){if(dx)return sd;dx=1;var r=Function.prototype,e=r.toString;function t(n){if(n!=null){try{return e.call(n)}catch{}try{return n+""}catch{}}return""}return sd=t,sd}var ud,vx;function Xz(){if(vx)return ud;vx=1;var r=Kz(),e=Yz(),t=Cs(),n=Zz(),a=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,u=o.toString,l=s.hasOwnProperty,f=RegExp("^"+u.call(l).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function d(h){if(!t(h)||e(h))return!1;var g=r(h)?f:i;return g.test(n(h))}return ud=d,ud}var ld,hx;function Qz(){if(hx)return ld;hx=1;function r(e,t){return e==null?void 0:e[t]}return ld=r,ld}var fd,gx;function n0(){if(gx)return fd;gx=1;var r=Xz(),e=Qz();function t(n,a){var i=e(n,a);return r(i)?i:void 0}return fd=t,fd}var cd,px;function Sl(){if(px)return cd;px=1;var r=n0(),e=r(Object,"create");return cd=e,cd}var dd,yx;function Jz(){if(yx)return dd;yx=1;var r=Sl();function e(){this.__data__=r?r(null):{},this.size=0}return dd=e,dd}var vd,mx;function e5(){if(mx)return vd;mx=1;function r(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}return vd=r,vd}var hd,bx;function r5(){if(bx)return hd;bx=1;var r=Sl(),e="__lodash_hash_undefined__",t=Object.prototype,n=t.hasOwnProperty;function a(i){var o=this.__data__;if(r){var s=o[i];return s===e?void 0:s}return n.call(o,i)?o[i]:void 0}return hd=a,hd}var gd,wx;function t5(){if(wx)return gd;wx=1;var r=Sl(),e=Object.prototype,t=e.hasOwnProperty;function n(a){var i=this.__data__;return r?i[a]!==void 0:t.call(i,a)}return gd=n,gd}var pd,xx;function n5(){if(xx)return pd;xx=1;var r=Sl(),e="__lodash_hash_undefined__";function t(n,a){var i=this.__data__;return this.size+=this.has(n)?0:1,i[n]=r&&a===void 0?e:a,this}return pd=t,pd}var yd,Ex;function a5(){if(Ex)return yd;Ex=1;var r=Jz(),e=e5(),t=r5(),n=t5(),a=n5();function i(o){var s=-1,u=o==null?0:o.length;for(this.clear();++s<u;){var l=o[s];this.set(l[0],l[1])}}return i.prototype.clear=r,i.prototype.delete=e,i.prototype.get=t,i.prototype.has=n,i.prototype.set=a,yd=i,yd}var md,Cx;function i5(){if(Cx)return md;Cx=1;function r(){this.__data__=[],this.size=0}return md=r,md}var bd,_x;function dA(){if(_x)return bd;_x=1;function r(e,t){return e===t||e!==e&&t!==t}return bd=r,bd}var wd,Sx;function Tl(){if(Sx)return wd;Sx=1;var r=dA();function e(t,n){for(var a=t.length;a--;)if(r(t[a][0],n))return a;return-1}return wd=e,wd}var xd,Tx;function o5(){if(Tx)return xd;Tx=1;var r=Tl(),e=Array.prototype,t=e.splice;function n(a){var i=this.__data__,o=r(i,a);if(o<0)return!1;var s=i.length-1;return o==s?i.pop():t.call(i,o,1),--this.size,!0}return xd=n,xd}var Ed,Rx;function s5(){if(Rx)return Ed;Rx=1;var r=Tl();function e(t){var n=this.__data__,a=r(n,t);return a<0?void 0:n[a][1]}return Ed=e,Ed}var Cd,Ax;function u5(){if(Ax)return Cd;Ax=1;var r=Tl();function e(t){return r(this.__data__,t)>-1}return Cd=e,Cd}var _d,Px;function l5(){if(Px)return _d;Px=1;var r=Tl();function e(t,n){var a=this.__data__,i=r(a,t);return i<0?(++this.size,a.push([t,n])):a[i][1]=n,this}return _d=e,_d}var Sd,Ix;function f5(){if(Ix)return Sd;Ix=1;var r=i5(),e=o5(),t=s5(),n=u5(),a=l5();function i(o){var s=-1,u=o==null?0:o.length;for(this.clear();++s<u;){var l=o[s];this.set(l[0],l[1])}}return i.prototype.clear=r,i.prototype.delete=e,i.prototype.get=t,i.prototype.has=n,i.prototype.set=a,Sd=i,Sd}var Td,Dx;function c5(){if(Dx)return Td;Dx=1;var r=n0(),e=wl(),t=r(e,"Map");return Td=t,Td}var Rd,Bx;function d5(){if(Bx)return Rd;Bx=1;var r=a5(),e=f5(),t=c5();function n(){this.size=0,this.__data__={hash:new r,map:new(t||e),string:new r}}return Rd=n,Rd}var Ad,Mx;function v5(){if(Mx)return Ad;Mx=1;function r(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}return Ad=r,Ad}var Pd,Lx;function Rl(){if(Lx)return Pd;Lx=1;var r=v5();function e(t,n){var a=t.__data__;return r(n)?a[typeof n=="string"?"string":"hash"]:a.map}return Pd=e,Pd}var Id,Ox;function h5(){if(Ox)return Id;Ox=1;var r=Rl();function e(t){var n=r(this,t).delete(t);return this.size-=n?1:0,n}return Id=e,Id}var Dd,kx;function g5(){if(kx)return Dd;kx=1;var r=Rl();function e(t){return r(this,t).get(t)}return Dd=e,Dd}var Bd,qx;function p5(){if(qx)return Bd;qx=1;var r=Rl();function e(t){return r(this,t).has(t)}return Bd=e,Bd}var Md,Nx;function y5(){if(Nx)return Md;Nx=1;var r=Rl();function e(t,n){var a=r(this,t),i=a.size;return a.set(t,n),this.size+=a.size==i?0:1,this}return Md=e,Md}var Ld,Fx;function m5(){if(Fx)return Ld;Fx=1;var r=d5(),e=h5(),t=g5(),n=p5(),a=y5();function i(o){var s=-1,u=o==null?0:o.length;for(this.clear();++s<u;){var l=o[s];this.set(l[0],l[1])}}return i.prototype.clear=r,i.prototype.delete=e,i.prototype.get=t,i.prototype.has=n,i.prototype.set=a,Ld=i,Ld}var Od,zx;function b5(){if(zx)return Od;zx=1;var r=m5(),e="Expected a function";function t(n,a){if(typeof n!="function"||a!=null&&typeof a!="function")throw new TypeError(e);var i=function(){var o=arguments,s=a?a.apply(this,o):o[0],u=i.cache;if(u.has(s))return u.get(s);var l=n.apply(this,o);return i.cache=u.set(s,l)||u,l};return i.cache=new(t.Cache||r),i}return t.Cache=r,Od=t,Od}var kd,$x;function w5(){if($x)return kd;$x=1;var r=b5(),e=500;function t(n){var a=r(n,function(o){return i.size===e&&i.clear(),o}),i=a.cache;return a}return kd=t,kd}var qd,Vx;function vA(){if(Vx)return qd;Vx=1;var r=w5(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,n=r(function(a){var i=[];return a.charCodeAt(0)===46&&i.push(""),a.replace(e,function(o,s,u,l){i.push(u?l.replace(t,"$1"):s||o)}),i});return qd=n,qd}var Nd,Gx;function hA(){if(Gx)return Nd;Gx=1;function r(e,t){for(var n=-1,a=e==null?0:e.length,i=Array(a);++n<a;)i[n]=t(e[n],n,e);return i}return Nd=r,Nd}var Fd,Wx;function x5(){if(Wx)return Fd;Wx=1;var r=jm(),e=hA(),t=_l(),n=_s(),a=r?r.prototype:void 0,i=a?a.toString:void 0;function o(s){if(typeof s=="string")return s;if(t(s))return e(s,o)+"";if(n(s))return i?i.call(s):"";var u=s+"";return u=="0"&&1/s==-1/0?"-0":u}return Fd=o,Fd}var zd,Ux;function gA(){if(Ux)return zd;Ux=1;var r=x5();function e(t){return t==null?"":r(t)}return zd=e,zd}var $d,Hx;function pA(){if(Hx)return $d;Hx=1;var r=_l(),e=Hz(),t=vA(),n=gA();function a(i,o){return r(i)?i:e(i,o)?[i]:t(n(i))}return $d=a,$d}var Vd,Kx;function a0(){if(Kx)return Vd;Kx=1;var r=_s();function e(t){if(typeof t=="string"||r(t))return t;var n=t+"";return n=="0"&&1/t==-1/0?"-0":n}return Vd=e,Vd}var Gd,jx;function E5(){if(jx)return Gd;jx=1;var r=pA(),e=a0();function t(n,a){a=r(a,n);for(var i=0,o=a.length;n!=null&&i<o;)n=n[e(a[i++])];return i&&i==o?n:void 0}return Gd=t,Gd}var Wd,Yx;function C5(){if(Yx)return Wd;Yx=1;var r=E5();function e(t,n,a){var i=t==null?void 0:r(t,n);return i===void 0?a:i}return Wd=e,Wd}var _5=C5(),S5=Es(_5),Ud,Zx;function T5(){if(Zx)return Ud;Zx=1;var r=n0(),e=(function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch{}})();return Ud=e,Ud}var Hd,Xx;function R5(){if(Xx)return Hd;Xx=1;var r=T5();function e(t,n,a){n=="__proto__"&&r?r(t,n,{configurable:!0,enumerable:!0,value:a,writable:!0}):t[n]=a}return Hd=e,Hd}var Kd,Qx;function A5(){if(Qx)return Kd;Qx=1;var r=R5(),e=dA(),t=Object.prototype,n=t.hasOwnProperty;function a(i,o,s){var u=i[o];(!(n.call(i,o)&&e(u,s))||s===void 0&&!(o in i))&&r(i,o,s)}return Kd=a,Kd}var jd,Jx;function P5(){if(Jx)return jd;Jx=1;var r=9007199254740991,e=/^(?:0|[1-9]\d*)$/;function t(n,a){var i=typeof n;return a=a??r,!!a&&(i=="number"||i!="symbol"&&e.test(n))&&n>-1&&n%1==0&&n<a}return jd=t,jd}var Yd,eE;function I5(){if(eE)return Yd;eE=1;var r=A5(),e=pA(),t=P5(),n=Cs(),a=a0();function i(o,s,u,l){if(!n(o))return o;s=e(s,o);for(var f=-1,d=s.length,h=d-1,g=o;g!=null&&++f<d;){var p=a(s[f]),x=u;if(p==="__proto__"||p==="constructor"||p==="prototype")return o;if(f!=h){var b=g[p];x=l?l(b,p,g):void 0,x===void 0&&(x=n(b)?b:t(s[f+1])?[]:{})}r(g,p,x),g=g[p]}return o}return Yd=i,Yd}var Zd,rE;function D5(){if(rE)return Zd;rE=1;var r=I5();function e(t,n,a){return t==null?t:r(t,n,a)}return Zd=e,Zd}var B5=D5(),M5=Es(B5),Xd,tE;function L5(){if(tE)return Xd;tE=1;function r(e,t){var n=-1,a=e.length;for(t||(t=Array(a));++n<a;)t[n]=e[n];return t}return Xd=r,Xd}var Qd,nE;function O5(){if(nE)return Qd;nE=1;var r=hA(),e=L5(),t=_l(),n=_s(),a=vA(),i=a0(),o=gA();function s(u){return t(u)?r(u,i):n(u)?[u]:e(a(o(u)))}return Qd=s,Qd}var k5=O5(),q5=Es(k5),N5={data:function(e){var t={field:"data",bindingEvent:"data",allowBinding:!1,allowSetting:!1,allowGetting:!1,settingEvent:"data",settingTriggersEvent:!1,triggerFnName:"trigger",immutableKeys:{},updateStyle:!1,beforeGet:function(a){},beforeSet:function(a,i){},onSet:function(a){},canSet:function(a){return!0}};return e=Xe({},t,e),function(a,i){var o=e,s=this,u=s.length!==void 0,l=u?s:[s],f=u?s[0]:s;if(Ye(a)){var d=a.indexOf(".")!==-1,h=d&&q5(a);if(o.allowGetting&&i===void 0){var g;return f&&(o.beforeGet(f),h&&f._private[o.field][a]===void 0?g=S5(f._private[o.field],h):g=f._private[o.field][a]),g}else if(o.allowSetting&&i!==void 0){var p=!o.immutableKeys[a];if(p){var x=D2({},a,i);o.beforeSet(s,x);for(var b=0,w=l.length;b<w;b++){var y=l[b];o.canSet(y)&&(h&&f._private[o.field][a]===void 0?M5(y._private[o.field],h,i):y._private[o.field][a]=i)}o.updateStyle&&s.updateStyle(),o.onSet(s),o.settingTriggersEvent&&s[o.triggerFnName](o.settingEvent)}}}else if(o.allowSetting&&yr(a)){var E=a,C,S,R=Object.keys(E);o.beforeSet(s,E);for(var _=0;_<R.length;_++){C=R[_],S=E[C];var A=!o.immutableKeys[C];if(A)for(var P=0;P<l.length;P++){var I=l[P];o.canSet(I)&&(I._private[o.field][C]=S)}}o.updateStyle&&s.updateStyle(),o.onSet(s),o.settingTriggersEvent&&s[o.triggerFnName](o.settingEvent)}else if(o.allowBinding&&$r(a)){var D=a;s.on(o.bindingEvent,D)}else if(o.allowGetting&&a===void 0){var L;return f&&(o.beforeGet(f),L=f._private[o.field]),L}return s}},removeData:function(e){var t={field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!1,immutableKeys:{}};return e=Xe({},t,e),function(a){var i=e,o=this,s=o.length!==void 0,u=s?o:[o];if(Ye(a)){for(var l=a.split(/\s+/),f=l.length,d=0;d<f;d++){var h=l[d];if(!Da(h)){var g=!i.immutableKeys[h];if(g)for(var p=0,x=u.length;p<x;p++)u[p]._private[i.field][h]=void 0}}i.triggerEvent&&o[i.triggerFnName](i.event)}else if(a===void 0){for(var b=0,w=u.length;b<w;b++)for(var y=u[b]._private[i.field],E=Object.keys(y),C=0;C<E.length;C++){var S=E[C],R=!i.immutableKeys[S];R&&(y[S]=void 0)}i.triggerEvent&&o[i.triggerFnName](i.event)}return o}}},F5={eventAliasesOn:function(e){var t=e;t.addListener=t.listen=t.bind=t.on,t.unlisten=t.unbind=t.off=t.removeListener,t.trigger=t.emit,t.pon=t.promiseOn=function(n,a){var i=this,o=Array.prototype.slice.call(arguments,0);return new po(function(s,u){var l=function(g){i.off.apply(i,d),s(g)},f=o.concat([l]),d=f.concat([]);i.on.apply(i,f)})}}},Er={};[Uz,N5,F5].forEach(function(r){Xe(Er,r)});var z5={animate:Er.animate(),animation:Er.animation(),animated:Er.animated(),clearQueue:Er.clearQueue(),delay:Er.delay(),delayAnimation:Er.delayAnimation(),stop:Er.stop()},Vu={classes:function(e){var t=this;if(e===void 0){var n=[];return t[0]._private.classes.forEach(function(p){return n.push(p)}),n}else Tr(e)||(e=(e||"").match(/\S+/g)||[]);for(var a=[],i=new go(e),o=0;o<t.length;o++){for(var s=t[o],u=s._private,l=u.classes,f=!1,d=0;d<e.length;d++){var h=e[d],g=l.has(h);if(!g){f=!0;break}}f||(f=l.size!==e.length),f&&(u.classes=i,a.push(s))}return a.length>0&&this.spawn(a).updateStyle().emit("class"),t},addClass:function(e){return this.toggleClass(e,!0)},hasClass:function(e){var t=this[0];return t!=null&&t._private.classes.has(e)},toggleClass:function(e,t){Tr(e)||(e=e.match(/\S+/g)||[]);for(var n=this,a=t===void 0,i=[],o=0,s=n.length;o<s;o++)for(var u=n[o],l=u._private.classes,f=!1,d=0;d<e.length;d++){var h=e[d],g=l.has(h),p=!1;t||a&&!g?(l.add(h),p=!0):(!t||a&&g)&&(l.delete(h),p=!0),!f&&p&&(i.push(u),f=!0)}return i.length>0&&this.spawn(i).updateStyle().emit("class"),n},removeClass:function(e){return this.toggleClass(e,!1)},flashClass:function(e,t){var n=this;if(t==null)t=250;else if(t===0)return n;return n.addClass(e),setTimeout(function(){n.removeClass(e)},t),n}};Vu.className=Vu.classNames=Vu.classes;var gr={metaChar:"[\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\`\\{\\|\\}\\~]",comparatorOp:"=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=",boolOp:"\\?|\\!|\\^",string:`"(?:\\\\"|[^"])*"|'(?:\\\\'|[^'])*'`,number:nt,meta:"degree|indegree|outdegree",separator:"\\s*,\\s*",descendant:"\\s+",child:"\\s+>\\s+",subject:"\\$",group:"node|edge|\\*",directedEdge:"\\s+->\\s+",undirectedEdge:"\\s+<->\\s+"};gr.variable="(?:[\\w-.]|(?:\\\\"+gr.metaChar+"))+";gr.className="(?:[\\w-]|(?:\\\\"+gr.metaChar+"))+";gr.value=gr.string+"|"+gr.number;gr.id=gr.variable;(function(){var r,e,t;for(r=gr.comparatorOp.split("|"),t=0;t<r.length;t++)e=r[t],gr.comparatorOp+="|@"+e;for(r=gr.comparatorOp.split("|"),t=0;t<r.length;t++)e=r[t],!(e.indexOf("!")>=0)&&e!=="="&&(gr.comparatorOp+="|\\!"+e)})();var _r=function(){return{checks:[]}},Ue={GROUP:0,COLLECTION:1,FILTER:2,DATA_COMPARE:3,DATA_EXIST:4,DATA_BOOL:5,META_COMPARE:6,STATE:7,ID:8,CLASS:9,UNDIRECTED_EDGE:10,DIRECTED_EDGE:11,NODE_SOURCE:12,NODE_TARGET:13,NODE_NEIGHBOR:14,CHILD:15,DESCENDANT:16,PARENT:17,ANCESTOR:18,COMPOUND_SPLIT:19,TRUE:20},Am=[{selector:":selected",matches:function(e){return e.selected()}},{selector:":unselected",matches:function(e){return!e.selected()}},{selector:":selectable",matches:function(e){return e.selectable()}},{selector:":unselectable",matches:function(e){return!e.selectable()}},{selector:":locked",matches:function(e){return e.locked()}},{selector:":unlocked",matches:function(e){return!e.locked()}},{selector:":visible",matches:function(e){return e.visible()}},{selector:":hidden",matches:function(e){return!e.visible()}},{selector:":transparent",matches:function(e){return e.transparent()}},{selector:":grabbed",matches:function(e){return e.grabbed()}},{selector:":free",matches:function(e){return!e.grabbed()}},{selector:":removed",matches:function(e){return e.removed()}},{selector:":inside",matches:function(e){return!e.removed()}},{selector:":grabbable",matches:function(e){return e.grabbable()}},{selector:":ungrabbable",matches:function(e){return!e.grabbable()}},{selector:":animated",matches:function(e){return e.animated()}},{selector:":unanimated",matches:function(e){return!e.animated()}},{selector:":parent",matches:function(e){return e.isParent()}},{selector:":childless",matches:function(e){return e.isChildless()}},{selector:":child",matches:function(e){return e.isChild()}},{selector:":orphan",matches:function(e){return e.isOrphan()}},{selector:":nonorphan",matches:function(e){return e.isChild()}},{selector:":compound",matches:function(e){return e.isNode()?e.isParent():e.source().isParent()||e.target().isParent()}},{selector:":loop",matches:function(e){return e.isLoop()}},{selector:":simple",matches:function(e){return e.isSimple()}},{selector:":active",matches:function(e){return e.active()}},{selector:":inactive",matches:function(e){return!e.active()}},{selector:":backgrounding",matches:function(e){return e.backgrounding()}},{selector:":nonbackgrounding",matches:function(e){return!e.backgrounding()}}].sort(function(r,e){return NN(r.selector,e.selector)}),$5=(function(){for(var r={},e,t=0;t<Am.length;t++)e=Am[t],r[e.selector]=e.matches;return r})(),V5=function(e,t){return $5[e](t)},G5="("+Am.map(function(r){return r.selector}).join("|")+")",Gi=function(e){return e.replace(new RegExp("\\\\("+gr.metaChar+")","g"),function(t,n){return n})},xa=function(e,t,n){e[e.length-1]=n},Pm=[{name:"group",query:!0,regex:"("+gr.group+")",populate:function(e,t,n){var a=Zr(n,1),i=a[0];t.checks.push({type:Ue.GROUP,value:i==="*"?i:i+"s"})}},{name:"state",query:!0,regex:G5,populate:function(e,t,n){var a=Zr(n,1),i=a[0];t.checks.push({type:Ue.STATE,value:i})}},{name:"id",query:!0,regex:"\\#("+gr.id+")",populate:function(e,t,n){var a=Zr(n,1),i=a[0];t.checks.push({type:Ue.ID,value:Gi(i)})}},{name:"className",query:!0,regex:"\\.("+gr.className+")",populate:function(e,t,n){var a=Zr(n,1),i=a[0];t.checks.push({type:Ue.CLASS,value:Gi(i)})}},{name:"dataExists",query:!0,regex:"\\[\\s*("+gr.variable+")\\s*\\]",populate:function(e,t,n){var a=Zr(n,1),i=a[0];t.checks.push({type:Ue.DATA_EXIST,field:Gi(i)})}},{name:"dataCompare",query:!0,regex:"\\[\\s*("+gr.variable+")\\s*("+gr.comparatorOp+")\\s*("+gr.value+")\\s*\\]",populate:function(e,t,n){var a=Zr(n,3),i=a[0],o=a[1],s=a[2],u=new RegExp("^"+gr.string+"$").exec(s)!=null;u?s=s.substring(1,s.length-1):s=parseFloat(s),t.checks.push({type:Ue.DATA_COMPARE,field:Gi(i),operator:o,value:s})}},{name:"dataBool",query:!0,regex:"\\[\\s*("+gr.boolOp+")\\s*("+gr.variable+")\\s*\\]",populate:function(e,t,n){var a=Zr(n,2),i=a[0],o=a[1];t.checks.push({type:Ue.DATA_BOOL,field:Gi(o),operator:i})}},{name:"metaCompare",query:!0,regex:"\\[\\[\\s*("+gr.meta+")\\s*("+gr.comparatorOp+")\\s*("+gr.number+")\\s*\\]\\]",populate:function(e,t,n){var a=Zr(n,3),i=a[0],o=a[1],s=a[2];t.checks.push({type:Ue.META_COMPARE,field:Gi(i),operator:o,value:parseFloat(s)})}},{name:"nextQuery",separator:!0,regex:gr.separator,populate:function(e,t){var n=e.currentSubject,a=e.edgeCount,i=e.compoundCount,o=e[e.length-1];n!=null&&(o.subject=n,e.currentSubject=null),o.edgeCount=a,o.compoundCount=i,e.edgeCount=0,e.compoundCount=0;var s=e[e.length++]=_r();return s}},{name:"directedEdge",separator:!0,regex:gr.directedEdge,populate:function(e,t){if(e.currentSubject==null){var n=_r(),a=t,i=_r();return n.checks.push({type:Ue.DIRECTED_EDGE,source:a,target:i}),xa(e,t,n),e.edgeCount++,i}else{var o=_r(),s=t,u=_r();return o.checks.push({type:Ue.NODE_SOURCE,source:s,target:u}),xa(e,t,o),e.edgeCount++,u}}},{name:"undirectedEdge",separator:!0,regex:gr.undirectedEdge,populate:function(e,t){if(e.currentSubject==null){var n=_r(),a=t,i=_r();return n.checks.push({type:Ue.UNDIRECTED_EDGE,nodes:[a,i]}),xa(e,t,n),e.edgeCount++,i}else{var o=_r(),s=t,u=_r();return o.checks.push({type:Ue.NODE_NEIGHBOR,node:s,neighbor:u}),xa(e,t,o),u}}},{name:"child",separator:!0,regex:gr.child,populate:function(e,t){if(e.currentSubject==null){var n=_r(),a=_r(),i=e[e.length-1];return n.checks.push({type:Ue.CHILD,parent:i,child:a}),xa(e,t,n),e.compoundCount++,a}else if(e.currentSubject===t){var o=_r(),s=e[e.length-1],u=_r(),l=_r(),f=_r(),d=_r();return o.checks.push({type:Ue.COMPOUND_SPLIT,left:s,right:u,subject:l}),l.checks=t.checks,t.checks=[{type:Ue.TRUE}],d.checks.push({type:Ue.TRUE}),u.checks.push({type:Ue.PARENT,parent:d,child:f}),xa(e,s,o),e.currentSubject=l,e.compoundCount++,f}else{var h=_r(),g=_r(),p=[{type:Ue.PARENT,parent:h,child:g}];return h.checks=t.checks,t.checks=p,e.compoundCount++,g}}},{name:"descendant",separator:!0,regex:gr.descendant,populate:function(e,t){if(e.currentSubject==null){var n=_r(),a=_r(),i=e[e.length-1];return n.checks.push({type:Ue.DESCENDANT,ancestor:i,descendant:a}),xa(e,t,n),e.compoundCount++,a}else if(e.currentSubject===t){var o=_r(),s=e[e.length-1],u=_r(),l=_r(),f=_r(),d=_r();return o.checks.push({type:Ue.COMPOUND_SPLIT,left:s,right:u,subject:l}),l.checks=t.checks,t.checks=[{type:Ue.TRUE}],d.checks.push({type:Ue.TRUE}),u.checks.push({type:Ue.ANCESTOR,ancestor:d,descendant:f}),xa(e,s,o),e.currentSubject=l,e.compoundCount++,f}else{var h=_r(),g=_r(),p=[{type:Ue.ANCESTOR,ancestor:h,descendant:g}];return h.checks=t.checks,t.checks=p,e.compoundCount++,g}}},{name:"subject",modifier:!0,regex:gr.subject,populate:function(e,t){if(e.currentSubject!=null&&e.currentSubject!==t)return Cr("Redefinition of subject in selector `"+e.toString()+"`"),!1;e.currentSubject=t;var n=e[e.length-1],a=n.checks[0],i=a==null?null:a.type;i===Ue.DIRECTED_EDGE?a.type=Ue.NODE_TARGET:i===Ue.UNDIRECTED_EDGE&&(a.type=Ue.NODE_NEIGHBOR,a.node=a.nodes[1],a.neighbor=a.nodes[0],a.nodes=null)}}];Pm.forEach(function(r){return r.regexObj=new RegExp("^"+r.regex)});var W5=function(e){for(var t,n,a,i=0;i<Pm.length;i++){var o=Pm[i],s=o.name,u=e.match(o.regexObj);if(u!=null){n=u,t=o,a=s;var l=u[0];e=e.substring(l.length);break}}return{expr:t,match:n,name:a,remaining:e}},U5=function(e){var t=e.match(/^\s+/);if(t){var n=t[0];e=e.substring(n.length)}return e},H5=function(e){var t=this,n=t.inputText=e,a=t[0]=_r();for(t.length=1,n=U5(n);;){var i=W5(n);if(i.expr==null)return Cr("The selector `"+e+"`is invalid"),!1;var o=i.match.slice(1),s=i.expr.populate(t,a,o);if(s===!1)return!1;if(s!=null&&(a=s),n=i.remaining,n.match(/^\s*$/))break}var u=t[t.length-1];t.currentSubject!=null&&(u.subject=t.currentSubject),u.edgeCount=t.edgeCount,u.compoundCount=t.compoundCount;for(var l=0;l<t.length;l++){var f=t[l];if(f.compoundCount>0&&f.edgeCount>0)return Cr("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(f.edgeCount>1)return Cr("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;f.edgeCount===1&&Cr("The selector `"+e+"` is deprecated. Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons. Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.")}return!0},K5=function(){if(this.toStringCache!=null)return this.toStringCache;for(var e=function(f){return f??""},t=function(f){return Ye(f)?'"'+f+'"':e(f)},n=function(f){return" "+f+" "},a=function(f,d){var h=f.type,g=f.value;switch(h){case Ue.GROUP:{var p=e(g);return p.substring(0,p.length-1)}case Ue.DATA_COMPARE:{var x=f.field,b=f.operator;return"["+x+n(e(b))+t(g)+"]"}case Ue.DATA_BOOL:{var w=f.operator,y=f.field;return"["+e(w)+y+"]"}case Ue.DATA_EXIST:{var E=f.field;return"["+E+"]"}case Ue.META_COMPARE:{var C=f.operator,S=f.field;return"[["+S+n(e(C))+t(g)+"]]"}case Ue.STATE:return g;case Ue.ID:return"#"+g;case Ue.CLASS:return"."+g;case Ue.PARENT:case Ue.CHILD:return i(f.parent,d)+n(">")+i(f.child,d);case Ue.ANCESTOR:case Ue.DESCENDANT:return i(f.ancestor,d)+" "+i(f.descendant,d);case Ue.COMPOUND_SPLIT:{var R=i(f.left,d),_=i(f.subject,d),A=i(f.right,d);return R+(R.length>0?" ":"")+_+A}case Ue.TRUE:return""}},i=function(f,d){return f.checks.reduce(function(h,g,p){return h+(d===f&&p===0?"$":"")+a(g,d)},"")},o="",s=0;s<this.length;s++){var u=this[s];o+=i(u,u.subject),this.length>1&&s<this.length-1&&(o+=", ")}return this.toStringCache=o,o},j5={parse:H5,toString:K5},yA=function(e,t,n){var a,i=Ye(e),o=qe(e),s=Ye(n),u,l,f=!1,d=!1,h=!1;switch(t.indexOf("!")>=0&&(t=t.replace("!",""),d=!0),t.indexOf("@")>=0&&(t=t.replace("@",""),f=!0),(i||s||f)&&(u=!i&&!o?"":""+e,l=""+n),f&&(e=u=u.toLowerCase(),n=l=l.toLowerCase()),t){case"*=":a=u.indexOf(l)>=0;break;case"$=":a=u.indexOf(l,u.length-l.length)>=0;break;case"^=":a=u.indexOf(l)===0;break;case"=":a=e===n;break;case">":h=!0,a=e>n;break;case">=":h=!0,a=e>=n;break;case"<":h=!0,a=e<n;break;case"<=":h=!0,a=e<=n;break;default:a=!1;break}return d&&(e!=null||!h)&&(a=!a),a},Y5=function(e,t){switch(t){case"?":return!!e;case"!":return!e;case"^":return e===void 0}},Z5=function(e){return e!==void 0},i0=function(e,t){return e.data(t)},X5=function(e,t){return e[t]()},Wr=[],Br=function(e,t){return e.checks.every(function(n){return Wr[n.type](n,t)})};Wr[Ue.GROUP]=function(r,e){var t=r.value;return t==="*"||t===e.group()};Wr[Ue.STATE]=function(r,e){var t=r.value;return V5(t,e)};Wr[Ue.ID]=function(r,e){var t=r.value;return e.id()===t};Wr[Ue.CLASS]=function(r,e){var t=r.value;return e.hasClass(t)};Wr[Ue.META_COMPARE]=function(r,e){var t=r.field,n=r.operator,a=r.value;return yA(X5(e,t),n,a)};Wr[Ue.DATA_COMPARE]=function(r,e){var t=r.field,n=r.operator,a=r.value;return yA(i0(e,t),n,a)};Wr[Ue.DATA_BOOL]=function(r,e){var t=r.field,n=r.operator;return Y5(i0(e,t),n)};Wr[Ue.DATA_EXIST]=function(r,e){var t=r.field;return r.operator,Z5(i0(e,t))};Wr[Ue.UNDIRECTED_EDGE]=function(r,e){var t=r.nodes[0],n=r.nodes[1],a=e.source(),i=e.target();return Br(t,a)&&Br(n,i)||Br(n,a)&&Br(t,i)};Wr[Ue.NODE_NEIGHBOR]=function(r,e){return Br(r.node,e)&&e.neighborhood().some(function(t){return t.isNode()&&Br(r.neighbor,t)})};Wr[Ue.DIRECTED_EDGE]=function(r,e){return Br(r.source,e.source())&&Br(r.target,e.target())};Wr[Ue.NODE_SOURCE]=function(r,e){return Br(r.source,e)&&e.outgoers().some(function(t){return t.isNode()&&Br(r.target,t)})};Wr[Ue.NODE_TARGET]=function(r,e){return Br(r.target,e)&&e.incomers().some(function(t){return t.isNode()&&Br(r.source,t)})};Wr[Ue.CHILD]=function(r,e){return Br(r.child,e)&&Br(r.parent,e.parent())};Wr[Ue.PARENT]=function(r,e){return Br(r.parent,e)&&e.children().some(function(t){return Br(r.child,t)})};Wr[Ue.DESCENDANT]=function(r,e){return Br(r.descendant,e)&&e.ancestors().some(function(t){return Br(r.ancestor,t)})};Wr[Ue.ANCESTOR]=function(r,e){return Br(r.ancestor,e)&&e.descendants().some(function(t){return Br(r.descendant,t)})};Wr[Ue.COMPOUND_SPLIT]=function(r,e){return Br(r.subject,e)&&Br(r.left,e)&&Br(r.right,e)};Wr[Ue.TRUE]=function(){return!0};Wr[Ue.COLLECTION]=function(r,e){var t=r.value;return t.has(e)};Wr[Ue.FILTER]=function(r,e){var t=r.value;return t(e)};var Q5=function(e){var t=this;if(t.length===1&&t[0].checks.length===1&&t[0].checks[0].type===Ue.ID)return e.getElementById(t[0].checks[0].value).collection();var n=function(i){for(var o=0;o<t.length;o++){var s=t[o];if(Br(s,i))return!0}return!1};return t.text()==null&&(n=function(){return!0}),e.filter(n)},J5=function(e){for(var t=this,n=0;n<t.length;n++){var a=t[n];if(Br(a,e))return!0}return!1},e$={matches:J5,filter:Q5},La=function(e){this.inputText=e,this.currentSubject=null,this.compoundCount=0,this.edgeCount=0,this.length=0,e==null||Ye(e)&&e.match(/^\s*$/)||(Jt(e)?this.addQuery({checks:[{type:Ue.COLLECTION,value:e.collection()}]}):$r(e)?this.addQuery({checks:[{type:Ue.FILTER,value:e}]}):Ye(e)?this.parse(e)||(this.invalid=!0):kr("A selector must be created from a string; found "))},Oa=La.prototype;[j5,e$].forEach(function(r){return Xe(Oa,r)});Oa.text=function(){return this.inputText};Oa.size=function(){return this.length};Oa.eq=function(r){return this[r]};Oa.sameText=function(r){return!this.invalid&&!r.invalid&&this.text()===r.text()};Oa.addQuery=function(r){this[this.length++]=r};Oa.selector=Oa.toString;var Ra={allAre:function(e){var t=new La(e);return this.every(function(n){return t.matches(n)})},is:function(e){var t=new La(e);return this.some(function(n){return t.matches(n)})},some:function(e,t){for(var n=0;n<this.length;n++){var a=t?e.apply(t,[this[n],n,this]):e(this[n],n,this);if(a)return!0}return!1},every:function(e,t){for(var n=0;n<this.length;n++){var a=t?e.apply(t,[this[n],n,this]):e(this[n],n,this);if(!a)return!1}return!0},same:function(e){if(this===e)return!0;e=this.cy().collection(e);var t=this.length,n=e.length;return t!==n?!1:t===1?this[0]===e[0]:this.every(function(a){return e.hasElementWithId(a.id())})},anySame:function(e){return e=this.cy().collection(e),this.some(function(t){return e.hasElementWithId(t.id())})},allAreNeighbors:function(e){e=this.cy().collection(e);var t=this.neighborhood();return e.every(function(n){return t.hasElementWithId(n.id())})},contains:function(e){e=this.cy().collection(e);var t=this;return e.every(function(n){return t.hasElementWithId(n.id())})}};Ra.allAreNeighbours=Ra.allAreNeighbors;Ra.has=Ra.contains;Ra.equal=Ra.equals=Ra.same;var hn=function(e,t){return function(a,i,o,s){var u=a,l=this,f;if(u==null?f="":Jt(u)&&u.length===1&&(f=u.id()),l.length===1&&f){var d=l[0]._private,h=d.traversalCache=d.traversalCache||{},g=h[t]=h[t]||[],p=ci(f),x=g[p];return x||(g[p]=e.call(l,a,i,o,s))}else return e.call(l,a,i,o,s)}},co={parent:function(e){var t=[];if(this.length===1){var n=this[0]._private.parent;if(n)return n}for(var a=0;a<this.length;a++){var i=this[a],o=i._private.parent;o&&t.push(o)}return this.spawn(t,!0).filter(e)},parents:function(e){for(var t=[],n=this.parent();n.nonempty();){for(var a=0;a<n.length;a++){var i=n[a];t.push(i)}n=n.parent()}return this.spawn(t,!0).filter(e)},commonAncestors:function(e){for(var t,n=0;n<this.length;n++){var a=this[n],i=a.parents();t=t||i,t=t.intersect(i)}return t.filter(e)},orphans:function(e){return this.stdFilter(function(t){return t.isOrphan()}).filter(e)},nonorphans:function(e){return this.stdFilter(function(t){return t.isChild()}).filter(e)},children:hn(function(r){for(var e=[],t=0;t<this.length;t++)for(var n=this[t],a=n._private.children,i=0;i<a.length;i++)e.push(a[i]);return this.spawn(e,!0).filter(r)},"children"),siblings:function(e){return this.parent().children().not(this).filter(e)},isParent:function(){var e=this[0];if(e)return e.isNode()&&e._private.children.length!==0},isChildless:function(){var e=this[0];if(e)return e.isNode()&&e._private.children.length===0},isChild:function(){var e=this[0];if(e)return e.isNode()&&e._private.parent!=null},isOrphan:function(){var e=this[0];if(e)return e.isNode()&&e._private.parent==null},descendants:function(e){var t=[];function n(a){for(var i=0;i<a.length;i++){var o=a[i];t.push(o),o.children().nonempty()&&n(o.children())}}return n(this.children()),this.spawn(t,!0).filter(e)}};function o0(r,e,t,n){for(var a=[],i=new go,o=r.cy(),s=o.hasCompoundNodes(),u=0;u<r.length;u++){var l=r[u];t?a.push(l):s&&n(a,i,l)}for(;a.length>0;){var f=a.shift();e(f),i.add(f.id()),s&&n(a,i,f)}return r}function mA(r,e,t){if(t.isParent())for(var n=t._private.children,a=0;a<n.length;a++){var i=n[a];e.has(i.id())||r.push(i)}}co.forEachDown=function(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return o0(this,r,e,mA)};function bA(r,e,t){if(t.isChild()){var n=t._private.parent;e.has(n.id())||r.push(n)}}co.forEachUp=function(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return o0(this,r,e,bA)};function r$(r,e,t){bA(r,e,t),mA(r,e,t)}co.forEachUpAndDown=function(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return o0(this,r,e,r$)};co.ancestors=co.parents;var hs,wA;hs=wA={data:Er.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),removeData:Er.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:Er.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:Er.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),rscratch:Er.data({field:"rscratch",allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:Er.removeData({field:"rscratch",triggerEvent:!1}),id:function(){var e=this[0];if(e)return e._private.data.id}};hs.attr=hs.data;hs.removeAttr=hs.removeData;var t$=wA,Al={};function Jd(r){return function(e){var t=this;if(e===void 0&&(e=!0),t.length!==0)if(t.isNode()&&!t.removed()){for(var n=0,a=t[0],i=a._private.edges,o=0;o<i.length;o++){var s=i[o];!e&&s.isLoop()||(n+=r(a,s))}return n}else return}}Xe(Al,{degree:Jd(function(r,e){return e.source().same(e.target())?2:1}),indegree:Jd(function(r,e){return e.target().same(r)?1:0}),outdegree:Jd(function(r,e){return e.source().same(r)?1:0})});function Wi(r,e){return function(t){for(var n,a=this.nodes(),i=0;i<a.length;i++){var o=a[i],s=o[r](t);s!==void 0&&(n===void 0||e(s,n))&&(n=s)}return n}}Xe(Al,{minDegree:Wi("degree",function(r,e){return r<e}),maxDegree:Wi("degree",function(r,e){return r>e}),minIndegree:Wi("indegree",function(r,e){return r<e}),maxIndegree:Wi("indegree",function(r,e){return r>e}),minOutdegree:Wi("outdegree",function(r,e){return r<e}),maxOutdegree:Wi("outdegree",function(r,e){return r>e})});Xe(Al,{totalDegree:function(e){for(var t=0,n=this.nodes(),a=0;a<n.length;a++)t+=n[a].degree(e);return t}});var Cn,xA,EA=function(e,t,n){for(var a=0;a<e.length;a++){var i=e[a];if(!i.locked()){var o=i._private.position,s={x:t.x!=null?t.x-o.x:0,y:t.y!=null?t.y-o.y:0};i.isParent()&&!(s.x===0&&s.y===0)&&i.children().shift(s,n),i.dirtyBoundingBoxCache()}}},aE={field:"position",bindingEvent:"position",allowBinding:!0,allowSetting:!0,settingEvent:"position",settingTriggersEvent:!0,triggerFnName:"emitAndNotify",allowGetting:!0,validKeys:["x","y"],beforeGet:function(e){e.updateCompoundBounds()},beforeSet:function(e,t){EA(e,t,!1)},onSet:function(e){e.dirtyCompoundBoundsCache()},canSet:function(e){return!e.locked()}};Cn=xA={position:Er.data(aE),silentPosition:Er.data(Xe({},aE,{allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!1,beforeSet:function(e,t){EA(e,t,!0)},onSet:function(e){e.dirtyCompoundBoundsCache()}})),positions:function(e,t){if(yr(e))t?this.silentPosition(e):this.position(e);else if($r(e)){var n=e,a=this.cy();a.startBatch();for(var i=0;i<this.length;i++){var o=this[i],s=void 0;(s=n(o,i))&&(t?o.silentPosition(s):o.position(s))}a.endBatch()}return this},silentPositions:function(e){return this.positions(e,!0)},shift:function(e,t,n){var a;if(yr(e)?(a={x:qe(e.x)?e.x:0,y:qe(e.y)?e.y:0},n=t):Ye(e)&&qe(t)&&(a={x:0,y:0},a[e]=t),a!=null){var i=this.cy();i.startBatch();for(var o=0;o<this.length;o++){var s=this[o];if(!(i.hasCompoundNodes()&&s.isChild()&&s.ancestors().anySame(this))){var u=s.position(),l={x:u.x+a.x,y:u.y+a.y};n?s.silentPosition(l):s.position(l)}}i.endBatch()}return this},silentShift:function(e,t){return yr(e)?this.shift(e,!0):Ye(e)&&qe(t)&&this.shift(e,t,!0),this},renderedPosition:function(e,t){var n=this[0],a=this.cy(),i=a.zoom(),o=a.pan(),s=yr(e)?e:void 0,u=s!==void 0||t!==void 0&&Ye(e);if(n&&n.isNode())if(u)for(var l=0;l<this.length;l++){var f=this[l];t!==void 0?f.position(e,(t-o[e])/i):s!==void 0&&f.position(Z2(s,i,o))}else{var d=n.position();return s=El(d,i,o),e===void 0?s:s[e]}else if(!u)return;return this},relativePosition:function(e,t){var n=this[0],a=this.cy(),i=yr(e)?e:void 0,o=i!==void 0||t!==void 0&&Ye(e),s=a.hasCompoundNodes();if(n&&n.isNode())if(o)for(var u=0;u<this.length;u++){var l=this[u],f=s?l.parent():null,d=f&&f.length>0,h=d;d&&(f=f[0]);var g=h?f.position():{x:0,y:0};t!==void 0?l.position(e,t+g[e]):i!==void 0&&l.position({x:i.x+g.x,y:i.y+g.y})}else{var p=n.position(),x=s?n.parent():null,b=x&&x.length>0,w=b;b&&(x=x[0]);var y=w?x.position():{x:0,y:0};return i={x:p.x-y.x,y:p.y-y.y},e===void 0?i:i[e]}else if(!o)return;return this}};Cn.modelPosition=Cn.point=Cn.position;Cn.modelPositions=Cn.points=Cn.positions;Cn.renderedPoint=Cn.renderedPosition;Cn.relativePoint=Cn.relativePosition;var n$=xA,uo,Fa;uo=Fa={};Fa.renderedBoundingBox=function(r){var e=this.boundingBox(r),t=this.cy(),n=t.zoom(),a=t.pan(),i=e.x1*n+a.x,o=e.x2*n+a.x,s=e.y1*n+a.y,u=e.y2*n+a.y;return{x1:i,x2:o,y1:s,y2:u,w:o-i,h:u-s}};Fa.dirtyCompoundBoundsCache=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,e=this.cy();return!e.styleEnabled()||!e.hasCompoundNodes()?this:(this.forEachUp(function(t){if(t.isParent()){var n=t._private;n.compoundBoundsClean=!1,n.bbCache=null,r||t.emitAndNotify("bounds")}}),this)};Fa.updateCompoundBounds=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,e=this.cy();if(!e.styleEnabled()||!e.hasCompoundNodes())return this;if(!r&&e.batching())return this;function t(o){if(!o.isParent())return;var s=o._private,u=o.children(),l=o.pstyle("compound-sizing-wrt-labels").value==="include",f={width:{val:o.pstyle("min-width").pfValue,left:o.pstyle("min-width-bias-left"),right:o.pstyle("min-width-bias-right")},height:{val:o.pstyle("min-height").pfValue,top:o.pstyle("min-height-bias-top"),bottom:o.pstyle("min-height-bias-bottom")}},d=u.boundingBox({includeLabels:l,includeOverlays:!1,useCache:!1}),h=s.position;(d.w===0||d.h===0)&&(d={w:o.pstyle("width").pfValue,h:o.pstyle("height").pfValue},d.x1=h.x-d.w/2,d.x2=h.x+d.w/2,d.y1=h.y-d.h/2,d.y2=h.y+d.h/2);function g(P,I,D){var L=0,M=0,q=I+D;return P>0&&q>0&&(L=I/q*P,M=D/q*P),{biasDiff:L,biasComplementDiff:M}}function p(P,I,D,L){if(D.units==="%")switch(L){case"width":return P>0?D.pfValue*P:0;case"height":return I>0?D.pfValue*I:0;case"average":return P>0&&I>0?D.pfValue*(P+I)/2:0;case"min":return P>0&&I>0?P>I?D.pfValue*I:D.pfValue*P:0;case"max":return P>0&&I>0?P>I?D.pfValue*P:D.pfValue*I:0;default:return 0}else return D.units==="px"?D.pfValue:0}var x=f.width.left.value;f.width.left.units==="px"&&f.width.val>0&&(x=x*100/f.width.val);var b=f.width.right.value;f.width.right.units==="px"&&f.width.val>0&&(b=b*100/f.width.val);var w=f.height.top.value;f.height.top.units==="px"&&f.height.val>0&&(w=w*100/f.height.val);var y=f.height.bottom.value;f.height.bottom.units==="px"&&f.height.val>0&&(y=y*100/f.height.val);var E=g(f.width.val-d.w,x,b),C=E.biasDiff,S=E.biasComplementDiff,R=g(f.height.val-d.h,w,y),_=R.biasDiff,A=R.biasComplementDiff;s.autoPadding=p(d.w,d.h,o.pstyle("padding"),o.pstyle("padding-relative-to").value),s.autoWidth=Math.max(d.w,f.width.val),h.x=(-C+d.x1+d.x2+S)/2,s.autoHeight=Math.max(d.h,f.height.val),h.y=(-_+d.y1+d.y2+A)/2}for(var n=0;n<this.length;n++){var a=this[n],i=a._private;(!i.compoundBoundsClean||r)&&(t(a),e.batching()||(i.compoundBoundsClean=!0))}return this};var dn=function(e){return e===1/0||e===-1/0?0:e},En=function(e,t,n,a,i){a-t===0||i-n===0||t==null||n==null||a==null||i==null||(e.x1=t<e.x1?t:e.x1,e.x2=a>e.x2?a:e.x2,e.y1=n<e.y1?n:e.y1,e.y2=i>e.y2?i:e.y2,e.w=e.x2-e.x1,e.h=e.y2-e.y1)},Ea=function(e,t){return t==null?e:En(e,t.x1,t.y1,t.x2,t.y2)},$o=function(e,t,n){return $t(e,t,n)},Bu=function(e,t,n){if(!t.cy().headless()){var a=t._private,i=a.rstyle,o=i.arrowWidth/2,s=t.pstyle(n+"-arrow-shape").value,u,l;if(s!=="none"){n==="source"?(u=i.srcX,l=i.srcY):n==="target"?(u=i.tgtX,l=i.tgtY):(u=i.midX,l=i.midY);var f=a.arrowBounds=a.arrowBounds||{},d=f[n]=f[n]||{};d.x1=u-o,d.y1=l-o,d.x2=u+o,d.y2=l+o,d.w=d.x2-d.x1,d.h=d.y2-d.y1,zu(d,1),En(e,d.x1,d.y1,d.x2,d.y2)}}},ev=function(e,t,n){if(!t.cy().headless()){var a;n?a=n+"-":a="";var i=t._private,o=i.rstyle,s=t.pstyle(a+"label").strValue;if(s){var u=t.pstyle("text-halign"),l=t.pstyle("text-valign"),f=$o(o,"labelWidth",n),d=$o(o,"labelHeight",n),h=$o(o,"labelX",n),g=$o(o,"labelY",n),p=t.pstyle(a+"text-margin-x").pfValue,x=t.pstyle(a+"text-margin-y").pfValue,b=t.isEdge(),w=t.pstyle(a+"text-rotation"),y=t.pstyle("text-outline-width").pfValue,E=t.pstyle("text-border-width").pfValue,C=E/2,S=t.pstyle("text-background-padding").pfValue,R=2,_=d,A=f,P=A/2,I=_/2,D,L,M,q;if(b)D=h-P,L=h+P,M=g-I,q=g+I;else{switch(u.value){case"left":D=h-A,L=h;break;case"center":D=h-P,L=h+P;break;case"right":D=h,L=h+A;break}switch(l.value){case"top":M=g-_,q=g;break;case"center":M=g-I,q=g+I;break;case"bottom":M=g,q=g+_;break}}var N=p-Math.max(y,C)-S-R,W=p+Math.max(y,C)+S+R,V=x-Math.max(y,C)-S-R,$=x+Math.max(y,C)+S+R;D+=N,L+=W,M+=V,q+=$;var Z=n||"main",ee=i.labelBounds,K=ee[Z]=ee[Z]||{};K.x1=D,K.y1=M,K.x2=L,K.y2=q,K.w=L-D,K.h=q-M,K.leftPad=N,K.rightPad=W,K.topPad=V,K.botPad=$;var j=b&&w.strValue==="autorotate",fe=w.pfValue!=null&&w.pfValue!==0;if(j||fe){var G=j?$o(i.rstyle,"labelAngle",n):w.pfValue,z=Math.cos(G),Y=Math.sin(G),te=(D+L)/2,ue=(M+q)/2;if(!b){switch(u.value){case"left":te=L;break;case"right":te=D;break}switch(l.value){case"top":ue=q;break;case"bottom":ue=M;break}}var oe=function(le,Me){return le=le-te,Me=Me-ue,{x:le*z-Me*Y+te,y:le*Y+Me*z+ue}},X=oe(D,M),Q=oe(D,q),ie=oe(L,M),de=oe(L,q);D=Math.min(X.x,Q.x,ie.x,de.x),L=Math.max(X.x,Q.x,ie.x,de.x),M=Math.min(X.y,Q.y,ie.y,de.y),q=Math.max(X.y,Q.y,ie.y,de.y)}var we=Z+"Rot",Ae=ee[we]=ee[we]||{};Ae.x1=D,Ae.y1=M,Ae.x2=L,Ae.y2=q,Ae.w=L-D,Ae.h=q-M,En(e,D,M,L,q),En(i.labelBounds.all,D,M,L,q)}return e}},iE=function(e,t){if(!t.cy().headless()){var n=t.pstyle("outline-opacity").value,a=t.pstyle("outline-width").value,i=t.pstyle("outline-offset").value,o=a+i;CA(e,t,n,o,"outside",o/2)}},CA=function(e,t,n,a,i,o){if(!(n===0||a<=0||i==="inside")){var s=t.cy(),u=t.pstyle("shape").value,l=s.renderer().nodeShapes[u],f=t.position(),d=f.x,h=f.y,g=t.width(),p=t.height();if(l.hasMiterBounds){i==="center"&&(a/=2);var x=l.miterBounds(d,h,g,p,a);Ea(e,x)}else o!=null&&o>0&&$u(e,[o,o,o,o])}},a$=function(e,t){if(!t.cy().headless()){var n=t.pstyle("border-opacity").value,a=t.pstyle("border-width").pfValue,i=t.pstyle("border-position").value;CA(e,t,n,a,i)}},i$=function(e,t){var n=e._private.cy,a=n.styleEnabled(),i=n.headless(),o=Lt(),s=e._private,u=e.isNode(),l=e.isEdge(),f,d,h,g,p,x,b=s.rstyle,w=u&&a?e.pstyle("bounds-expansion").pfValue:[0],y=function(ve){return ve.pstyle("display").value!=="none"},E=!a||y(e)&&(!l||y(e.source())&&y(e.target()));if(E){var C=0,S=0;a&&t.includeOverlays&&(C=e.pstyle("overlay-opacity").value,C!==0&&(S=e.pstyle("overlay-padding").value));var R=0,_=0;a&&t.includeUnderlays&&(R=e.pstyle("underlay-opacity").value,R!==0&&(_=e.pstyle("underlay-padding").value));var A=Math.max(S,_),P=0,I=0;if(a&&(P=e.pstyle("width").pfValue,I=P/2),u&&t.includeNodes){var D=e.position();p=D.x,x=D.y;var L=e.outerWidth(),M=L/2,q=e.outerHeight(),N=q/2;f=p-M,d=p+M,h=x-N,g=x+N,En(o,f,h,d,g),a&&iE(o,e),a&&t.includeOutlines&&!i&&iE(o,e),a&&a$(o,e)}else if(l&&t.includeEdges)if(a&&!i){var W=e.pstyle("curve-style").strValue;if(f=Math.min(b.srcX,b.midX,b.tgtX),d=Math.max(b.srcX,b.midX,b.tgtX),h=Math.min(b.srcY,b.midY,b.tgtY),g=Math.max(b.srcY,b.midY,b.tgtY),f-=I,d+=I,h-=I,g+=I,En(o,f,h,d,g),W==="haystack"){var V=b.haystackPts;if(V&&V.length===2){if(f=V[0].x,h=V[0].y,d=V[1].x,g=V[1].y,f>d){var $=f;f=d,d=$}if(h>g){var Z=h;h=g,g=Z}En(o,f-I,h-I,d+I,g+I)}}else if(W==="bezier"||W==="unbundled-bezier"||_a(W,"segments")||_a(W,"taxi")){var ee;switch(W){case"bezier":case"unbundled-bezier":ee=b.bezierPts;break;case"segments":case"taxi":case"round-segments":case"round-taxi":ee=b.linePts;break}if(ee!=null)for(var K=0;K<ee.length;K++){var j=ee[K];f=j.x-I,d=j.x+I,h=j.y-I,g=j.y+I,En(o,f,h,d,g)}}}else{var fe=e.source(),G=fe.position(),z=e.target(),Y=z.position();if(f=G.x,d=Y.x,h=G.y,g=Y.y,f>d){var te=f;f=d,d=te}if(h>g){var ue=h;h=g,g=ue}f-=I,d+=I,h-=I,g+=I,En(o,f,h,d,g)}if(a&&t.includeEdges&&l&&(Bu(o,e,"mid-source"),Bu(o,e,"mid-target"),Bu(o,e,"source"),Bu(o,e,"target")),a){var oe=e.pstyle("ghost").value==="yes";if(oe){var X=e.pstyle("ghost-offset-x").pfValue,Q=e.pstyle("ghost-offset-y").pfValue;En(o,o.x1+X,o.y1+Q,o.x2+X,o.y2+Q)}}var ie=s.bodyBounds=s.bodyBounds||{};Ww(ie,o),$u(ie,w),zu(ie,1),a&&(f=o.x1,d=o.x2,h=o.y1,g=o.y2,En(o,f-A,h-A,d+A,g+A));var de=s.overlayBounds=s.overlayBounds||{};Ww(de,o),$u(de,w),zu(de,1);var we=s.labelBounds=s.labelBounds||{};we.all!=null?zF(we.all):we.all=Lt(),a&&t.includeLabels&&(t.includeMainLabels&&ev(o,e,null),l&&(t.includeSourceLabels&&ev(o,e,"source"),t.includeTargetLabels&&ev(o,e,"target")))}return o.x1=dn(o.x1),o.y1=dn(o.y1),o.x2=dn(o.x2),o.y2=dn(o.y2),o.w=dn(o.x2-o.x1),o.h=dn(o.y2-o.y1),o.w>0&&o.h>0&&E&&($u(o,w),zu(o,1)),o},_A=function(e){var t=0,n=function(o){return(o?1:0)<<t++},a=0;return a+=n(e.incudeNodes),a+=n(e.includeEdges),a+=n(e.includeLabels),a+=n(e.includeMainLabels),a+=n(e.includeSourceLabels),a+=n(e.includeTargetLabels),a+=n(e.includeOverlays),a+=n(e.includeOutlines),a},SA=function(e){var t=function(s){return Math.round(s)};if(e.isEdge()){var n=e.source().position(),a=e.target().position();return Nw([t(n.x),t(n.y),t(a.x),t(a.y)])}else{var i=e.position();return Nw([t(i.x),t(i.y)])}},oE=function(e,t){var n=e._private,a,i=e.isEdge(),o=t==null?sE:_A(t),s=o===sE;if(n.bbCache==null?(a=i$(e,gs),n.bbCache=a,n.bbCachePosKey=SA(e)):a=n.bbCache,!s){var u=e.isNode();a=Lt(),(t.includeNodes&&u||t.includeEdges&&!u)&&(t.includeOverlays?Ea(a,n.overlayBounds):Ea(a,n.bodyBounds)),t.includeLabels&&(t.includeMainLabels&&(!i||t.includeSourceLabels&&t.includeTargetLabels)?Ea(a,n.labelBounds.all):(t.includeMainLabels&&Ea(a,n.labelBounds.mainRot),t.includeSourceLabels&&Ea(a,n.labelBounds.sourceRot),t.includeTargetLabels&&Ea(a,n.labelBounds.targetRot))),a.w=a.x2-a.x1,a.h=a.y2-a.y1}return a},gs={includeNodes:!0,includeEdges:!0,includeLabels:!0,includeMainLabels:!0,includeSourceLabels:!0,includeTargetLabels:!0,includeOverlays:!0,includeUnderlays:!0,includeOutlines:!0,useCache:!0},sE=_A(gs),uE=wt(gs);Fa.boundingBox=function(r){var e,t=r===void 0||r.useCache===void 0||r.useCache===!0,n=lo(function(f){var d=f._private;return d.bbCache==null||d.styleDirty||d.bbCachePosKey!==SA(f)},function(f){return f.id()});if(t&&this.length===1&&!n(this[0]))r===void 0?r=gs:r=uE(r),e=oE(this[0],r);else{e=Lt(),r=r||gs;var a=uE(r),i=this,o=i.cy(),s=o.styleEnabled();this.edges().forEach(n),this.nodes().forEach(n),s&&this.recalculateRenderedStyle(t),this.updateCompoundBounds(!t);for(var u=0;u<i.length;u++){var l=i[u];n(l)&&l.dirtyBoundingBoxCache(),Ea(e,oE(l,a))}}return e.x1=dn(e.x1),e.y1=dn(e.y1),e.x2=dn(e.x2),e.y2=dn(e.y2),e.w=dn(e.x2-e.x1),e.h=dn(e.y2-e.y1),e};Fa.dirtyBoundingBoxCache=function(){for(var r=0;r<this.length;r++){var e=this[r]._private;e.bbCache=null,e.bbCachePosKey=null,e.bodyBounds=null,e.overlayBounds=null,e.labelBounds.all=null,e.labelBounds.source=null,e.labelBounds.target=null,e.labelBounds.main=null,e.labelBounds.sourceRot=null,e.labelBounds.targetRot=null,e.labelBounds.mainRot=null,e.arrowBounds.source=null,e.arrowBounds.target=null,e.arrowBounds["mid-source"]=null,e.arrowBounds["mid-target"]=null}return this.emitAndNotify("bounds"),this};Fa.boundingBoxAt=function(r){var e=this.nodes(),t=this.cy(),n=t.hasCompoundNodes(),a=t.collection();if(n&&(a=e.filter(function(l){return l.isParent()}),e=e.not(a)),yr(r)){var i=r;r=function(){return i}}var o=function(f,d){return f._private.bbAtOldPos=r(f,d)},s=function(f){return f._private.bbAtOldPos};t.startBatch(),e.forEach(o).silentPositions(r),n&&(a.dirtyCompoundBoundsCache(),a.dirtyBoundingBoxCache(),a.updateCompoundBounds(!0));var u=FF(this.boundingBox({useCache:!1}));return e.silentPositions(s),n&&(a.dirtyCompoundBoundsCache(),a.dirtyBoundingBoxCache(),a.updateCompoundBounds(!0)),t.endBatch(),u};uo.boundingbox=uo.bb=uo.boundingBox;uo.renderedBoundingbox=uo.renderedBoundingBox;var o$=Fa,Zo,Rs;Zo=Rs={};var TA=function(e){e.uppercaseName=Cw(e.name),e.autoName="auto"+e.uppercaseName,e.labelName="label"+e.uppercaseName,e.outerName="outer"+e.uppercaseName,e.uppercaseOuterName=Cw(e.outerName),Zo[e.name]=function(){var n=this[0],a=n._private,i=a.cy,o=i._private.styleEnabled;if(n)if(o){if(n.isParent())return n.updateCompoundBounds(),a[e.autoName]||0;var s=n.pstyle(e.name);switch(s.strValue){case"label":return n.recalculateRenderedStyle(),a.rstyle[e.labelName]||0;default:return s.pfValue}}else return 1},Zo["outer"+e.uppercaseName]=function(){var n=this[0],a=n._private,i=a.cy,o=i._private.styleEnabled;if(n)if(o){var s=n[e.name](),u=n.pstyle("border-position").value,l;u==="center"?l=n.pstyle("border-width").pfValue:u==="outside"?l=2*n.pstyle("border-width").pfValue:l=0;var f=2*n.padding();return s+l+f}else return 1},Zo["rendered"+e.uppercaseName]=function(){var n=this[0];if(n){var a=n[e.name]();return a*this.cy().zoom()}},Zo["rendered"+e.uppercaseOuterName]=function(){var n=this[0];if(n){var a=n[e.outerName]();return a*this.cy().zoom()}}};TA({name:"width"});TA({name:"height"});Rs.padding=function(){var r=this[0],e=r._private;return r.isParent()?(r.updateCompoundBounds(),e.autoPadding!==void 0?e.autoPadding:r.pstyle("padding").pfValue):r.pstyle("padding").pfValue};Rs.paddedHeight=function(){var r=this[0];return r.height()+2*r.padding()};Rs.paddedWidth=function(){var r=this[0];return r.width()+2*r.padding()};var s$=Rs,u$=function(e,t){if(e.isEdge()&&e.takesUpSpace())return t(e)},l$=function(e,t){if(e.isEdge()&&e.takesUpSpace()){var n=e.cy();return El(t(e),n.zoom(),n.pan())}},f$=function(e,t){if(e.isEdge()&&e.takesUpSpace()){var n=e.cy(),a=n.pan(),i=n.zoom();return t(e).map(function(o){return El(o,i,a)})}},c$=function(e){return e.renderer().getControlPoints(e)},d$=function(e){return e.renderer().getSegmentPoints(e)},v$=function(e){return e.renderer().getSourceEndpoint(e)},h$=function(e){return e.renderer().getTargetEndpoint(e)},g$=function(e){return e.renderer().getEdgeMidpoint(e)},lE={controlPoints:{get:c$,mult:!0},segmentPoints:{get:d$,mult:!0},sourceEndpoint:{get:v$},targetEndpoint:{get:h$},midpoint:{get:g$}},p$=function(e){return"rendered"+e[0].toUpperCase()+e.substr(1)},y$=Object.keys(lE).reduce(function(r,e){var t=lE[e],n=p$(e);return r[e]=function(){return u$(this,t.get)},t.mult?r[n]=function(){return f$(this,t.get)}:r[n]=function(){return l$(this,t.get)},r},{}),m$=Xe({},n$,o$,s$,y$);/*!
35
- Event object based on jQuery events, MIT license
36
-
37
- https://jquery.org/license/
38
- https://tldrlegal.com/license/mit-license
39
- https://github.com/jquery/jquery/blob/master/src/event.js
40
- */var RA=function(e,t){this.recycle(e,t)};function Vo(){return!1}function Mu(){return!0}RA.prototype={instanceString:function(){return"event"},recycle:function(e,t){if(this.isImmediatePropagationStopped=this.isPropagationStopped=this.isDefaultPrevented=Vo,e!=null&&e.preventDefault?(this.type=e.type,this.isDefaultPrevented=e.defaultPrevented?Mu:Vo):e!=null&&e.type?t=e:this.type=e,t!=null&&(this.originalEvent=t.originalEvent,this.type=t.type!=null?t.type:this.type,this.cy=t.cy,this.target=t.target,this.position=t.position,this.renderedPosition=t.renderedPosition,this.namespace=t.namespace,this.layout=t.layout),this.cy!=null&&this.position!=null&&this.renderedPosition==null){var n=this.position,a=this.cy.zoom(),i=this.cy.pan();this.renderedPosition={x:n.x*a+i.x,y:n.y*a+i.y}}this.timeStamp=e&&e.timeStamp||Date.now()},preventDefault:function(){this.isDefaultPrevented=Mu;var e=this.originalEvent;e&&e.preventDefault&&e.preventDefault()},stopPropagation:function(){this.isPropagationStopped=Mu;var e=this.originalEvent;e&&e.stopPropagation&&e.stopPropagation()},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=Mu,this.stopPropagation()},isDefaultPrevented:Vo,isPropagationStopped:Vo,isImmediatePropagationStopped:Vo};var AA=/^([^.]+)(\.(?:[^.]+))?$/,b$=".*",PA={qualifierCompare:function(e,t){return e===t},eventMatches:function(){return!0},addEventFields:function(){},callbackContext:function(e){return e},beforeEmit:function(){},afterEmit:function(){},bubble:function(){return!1},parent:function(){return null},context:null},fE=Object.keys(PA),w$={};function Pl(){for(var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:w$,e=arguments.length>1?arguments[1]:void 0,t=0;t<fE.length;t++){var n=fE[t];this[n]=r[n]||PA[n]}this.context=e||this.context,this.listeners=[],this.emitting=0}var ka=Pl.prototype,IA=function(e,t,n,a,i,o,s){$r(a)&&(i=a,a=null),s&&(o==null?o=s:o=Xe({},o,s));for(var u=Tr(n)?n:n.split(/\s+/),l=0;l<u.length;l++){var f=u[l];if(!Da(f)){var d=f.match(AA);if(d){var h=d[1],g=d[2]?d[2]:null,p=t(e,f,h,g,a,i,o);if(p===!1)break}}}},cE=function(e,t){return e.addEventFields(e.context,t),new RA(t.type,t)},x$=function(e,t,n){if(RN(n)){t(e,n);return}else if(yr(n)){t(e,cE(e,n));return}for(var a=Tr(n)?n:n.split(/\s+/),i=0;i<a.length;i++){var o=a[i];if(!Da(o)){var s=o.match(AA);if(s){var u=s[1],l=s[2]?s[2]:null,f=cE(e,{type:u,namespace:l,target:e.context});t(e,f)}}}};ka.on=ka.addListener=function(r,e,t,n,a){return IA(this,function(i,o,s,u,l,f,d){$r(f)&&i.listeners.push({event:o,callback:f,type:s,namespace:u,qualifier:l,conf:d})},r,e,t,n,a),this};ka.one=function(r,e,t,n){return this.on(r,e,t,n,{one:!0})};ka.removeListener=ka.off=function(r,e,t,n){var a=this;this.emitting!==0&&(this.listeners=lF(this.listeners));for(var i=this.listeners,o=function(l){var f=i[l];IA(a,function(d,h,g,p,x,b){if((f.type===g||r==="*")&&(!p&&f.namespace!==".*"||f.namespace===p)&&(!x||d.qualifierCompare(f.qualifier,x))&&(!b||f.callback===b))return i.splice(l,1),!1},r,e,t,n)},s=i.length-1;s>=0;s--)o(s);return this};ka.removeAllListeners=function(){return this.removeListener("*")};ka.emit=ka.trigger=function(r,e,t){var n=this.listeners,a=n.length;return this.emitting++,Tr(e)||(e=[e]),x$(this,function(i,o){t!=null&&(n=[{event:o.event,type:o.type,namespace:o.namespace,callback:t}],a=n.length);for(var s=function(){var f=n[u];if(f.type===o.type&&(!f.namespace||f.namespace===o.namespace||f.namespace===b$)&&i.eventMatches(i.context,f,o)){var d=[o];e!=null&&cF(d,e),i.beforeEmit(i.context,f,o),f.conf&&f.conf.one&&(i.listeners=i.listeners.filter(function(p){return p!==f}));var h=i.callbackContext(i.context,f,o),g=f.callback.apply(h,d);i.afterEmit(i.context,f,o),g===!1&&(o.stopPropagation(),o.preventDefault())}},u=0;u<a;u++)s();i.bubble(i.context)&&!o.isPropagationStopped()&&i.parent(i.context).emit(o,e)},r),this.emitting--,this};var E$={qualifierCompare:function(e,t){return e==null||t==null?e==null&&t==null:e.sameText(t)},eventMatches:function(e,t,n){var a=t.qualifier;return a!=null?e!==n.target&&xs(n.target)&&a.matches(n.target):!0},addEventFields:function(e,t){t.cy=e.cy(),t.target=e},callbackContext:function(e,t,n){return t.qualifier!=null?n.target:e},beforeEmit:function(e,t){t.conf&&t.conf.once&&t.conf.onceCollection.removeListener(t.event,t.qualifier,t.callback)},bubble:function(){return!0},parent:function(e){return e.isChild()?e.parent():e.cy()}},Lu=function(e){return Ye(e)?new La(e):e},DA={createEmitter:function(){for(var e=0;e<this.length;e++){var t=this[e],n=t._private;n.emitter||(n.emitter=new Pl(E$,t))}return this},emitter:function(){return this._private.emitter},on:function(e,t,n){for(var a=Lu(t),i=0;i<this.length;i++){var o=this[i];o.emitter().on(e,a,n)}return this},removeListener:function(e,t,n){for(var a=Lu(t),i=0;i<this.length;i++){var o=this[i];o.emitter().removeListener(e,a,n)}return this},removeAllListeners:function(){for(var e=0;e<this.length;e++){var t=this[e];t.emitter().removeAllListeners()}return this},one:function(e,t,n){for(var a=Lu(t),i=0;i<this.length;i++){var o=this[i];o.emitter().one(e,a,n)}return this},once:function(e,t,n){for(var a=Lu(t),i=0;i<this.length;i++){var o=this[i];o.emitter().on(e,a,n,{once:!0,onceCollection:this})}},emit:function(e,t){for(var n=0;n<this.length;n++){var a=this[n];a.emitter().emit(e,t)}return this},emitAndNotify:function(e,t){if(this.length!==0)return this.cy().notify(e,this),this.emit(e,t),this}};Er.eventAliasesOn(DA);var BA={nodes:function(e){return this.filter(function(t){return t.isNode()}).filter(e)},edges:function(e){return this.filter(function(t){return t.isEdge()}).filter(e)},byGroup:function(){for(var e=this.spawn(),t=this.spawn(),n=0;n<this.length;n++){var a=this[n];a.isNode()?e.push(a):t.push(a)}return{nodes:e,edges:t}},filter:function(e,t){if(e===void 0)return this;if(Ye(e)||Jt(e))return new La(e).filter(this);if($r(e)){for(var n=this.spawn(),a=this,i=0;i<a.length;i++){var o=a[i],s=t?e.apply(t,[o,i,a]):e(o,i,a);s&&n.push(o)}return n}return this.spawn()},not:function(e){if(e){Ye(e)&&(e=this.filter(e));for(var t=this.spawn(),n=0;n<this.length;n++){var a=this[n],i=e.has(a);i||t.push(a)}return t}else return this},absoluteComplement:function(){var e=this.cy();return e.mutableElements().not(this)},intersect:function(e){if(Ye(e)){var t=e;return this.filter(t)}for(var n=this.spawn(),a=this,i=e,o=this.length<e.length,s=o?a:i,u=o?i:a,l=0;l<s.length;l++){var f=s[l];u.has(f)&&n.push(f)}return n},xor:function(e){var t=this._private.cy;Ye(e)&&(e=t.$(e));var n=this.spawn(),a=this,i=e,o=function(u,l){for(var f=0;f<u.length;f++){var d=u[f],h=d._private.data.id,g=l.hasElementWithId(h);g||n.push(d)}};return o(a,i),o(i,a),n},diff:function(e){var t=this._private.cy;Ye(e)&&(e=t.$(e));var n=this.spawn(),a=this.spawn(),i=this.spawn(),o=this,s=e,u=function(f,d,h){for(var g=0;g<f.length;g++){var p=f[g],x=p._private.data.id,b=d.hasElementWithId(x);b?i.merge(p):h.push(p)}};return u(o,s,n),u(s,o,a),{left:n,right:a,both:i}},add:function(e){var t=this._private.cy;if(!e)return this;if(Ye(e)){var n=e;e=t.mutableElements().filter(n)}for(var a=this.spawnSelf(),i=0;i<e.length;i++){var o=e[i],s=!this.has(o);s&&a.push(o)}return a},merge:function(e){var t=this._private,n=t.cy;if(!e)return this;if(e&&Ye(e)){var a=e;e=n.mutableElements().filter(a)}for(var i=t.map,o=0;o<e.length;o++){var s=e[o],u=s._private.data.id,l=!i.has(u);if(l){var f=this.length++;this[f]=s,i.set(u,{ele:s,index:f})}}return this},unmergeAt:function(e){var t=this[e],n=t.id(),a=this._private,i=a.map;this[e]=void 0,i.delete(n);var o=e===this.length-1;if(this.length>1&&!o){var s=this.length-1,u=this[s],l=u._private.data.id;this[s]=void 0,this[e]=u,i.set(l,{ele:u,index:e})}return this.length--,this},unmergeOne:function(e){e=e[0];var t=this._private,n=e._private.data.id,a=t.map,i=a.get(n);if(!i)return this;var o=i.index;return this.unmergeAt(o),this},unmerge:function(e){var t=this._private.cy;if(!e)return this;if(e&&Ye(e)){var n=e;e=t.mutableElements().filter(n)}for(var a=0;a<e.length;a++)this.unmergeOne(e[a]);return this},unmergeBy:function(e){for(var t=this.length-1;t>=0;t--){var n=this[t];e(n)&&this.unmergeAt(t)}return this},map:function(e,t){for(var n=[],a=this,i=0;i<a.length;i++){var o=a[i],s=t?e.apply(t,[o,i,a]):e(o,i,a);n.push(s)}return n},reduce:function(e,t){for(var n=t,a=this,i=0;i<a.length;i++)n=e(n,a[i],i,a);return n},max:function(e,t){for(var n=-1/0,a,i=this,o=0;o<i.length;o++){var s=i[o],u=t?e.apply(t,[s,o,i]):e(s,o,i);u>n&&(n=u,a=s)}return{value:n,ele:a}},min:function(e,t){for(var n=1/0,a,i=this,o=0;o<i.length;o++){var s=i[o],u=t?e.apply(t,[s,o,i]):e(s,o,i);u<n&&(n=u,a=s)}return{value:n,ele:a}}},mr=BA;mr.u=mr["|"]=mr["+"]=mr.union=mr.or=mr.add;mr["\\"]=mr["!"]=mr["-"]=mr.difference=mr.relativeComplement=mr.subtract=mr.not;mr.n=mr["&"]=mr["."]=mr.and=mr.intersection=mr.intersect;mr["^"]=mr["(+)"]=mr["(-)"]=mr.symmetricDifference=mr.symdiff=mr.xor;mr.fnFilter=mr.filterFn=mr.stdFilter=mr.filter;mr.complement=mr.abscomp=mr.absoluteComplement;var C$={isNode:function(){return this.group()==="nodes"},isEdge:function(){return this.group()==="edges"},isLoop:function(){return this.isEdge()&&this.source()[0]===this.target()[0]},isSimple:function(){return this.isEdge()&&this.source()[0]!==this.target()[0]},group:function(){var e=this[0];if(e)return e._private.group}},MA=function(e,t){var n=e.cy(),a=n.hasCompoundNodes();function i(f){var d=f.pstyle("z-compound-depth");return d.value==="auto"?a?f.zDepth():0:d.value==="bottom"?-1:d.value==="top"?Ym:0}var o=i(e)-i(t);if(o!==0)return o;function s(f){var d=f.pstyle("z-index-compare");return d.value==="auto"&&f.isNode()?1:0}var u=s(e)-s(t);if(u!==0)return u;var l=e.pstyle("z-index").value-t.pstyle("z-index").value;return l!==0?l:e.poolIndex()-t.poolIndex()},sl={forEach:function(e,t){if($r(e))for(var n=this.length,a=0;a<n;a++){var i=this[a],o=t?e.apply(t,[i,a,this]):e(i,a,this);if(o===!1)break}return this},toArray:function(){for(var e=[],t=0;t<this.length;t++)e.push(this[t]);return e},slice:function(e,t){var n=[],a=this.length;t==null&&(t=a),e==null&&(e=0),e<0&&(e=a+e),t<0&&(t=a+t);for(var i=e;i>=0&&i<t&&i<a;i++)n.push(this[i]);return this.spawn(n)},size:function(){return this.length},eq:function(e){return this[e]||this.spawn()},first:function(){return this[0]||this.spawn()},last:function(){return this[this.length-1]||this.spawn()},empty:function(){return this.length===0},nonempty:function(){return!this.empty()},sort:function(e){if(!$r(e))return this;var t=this.toArray().sort(e);return this.spawn(t)},sortByZIndex:function(){return this.sort(MA)},zDepth:function(){var e=this[0];if(e){var t=e._private,n=t.group;if(n==="nodes"){var a=t.data.parent?e.parents().size():0;return e.isParent()?a:Ym-1}else{var i=t.source,o=t.target,s=i.zDepth(),u=o.zDepth();return Math.max(s,u,0)}}}};sl.each=sl.forEach;var _$=function(){var e="undefined",t=(typeof Symbol>"u"?"undefined":at(Symbol))!=e&&at(Symbol.iterator)!=e;t&&(sl[Symbol.iterator]=function(){var n=this,a={value:void 0,done:!1},i=0,o=this.length;return D2({next:function(){return i<o?a.value=n[i++]:(a.value=void 0,a.done=!0),a}},Symbol.iterator,function(){return this})})};_$();var S$=wt({nodeDimensionsIncludeLabels:!1}),Gu={layoutDimensions:function(e){e=S$(e);var t;if(!this.takesUpSpace())t={w:0,h:0};else if(e.nodeDimensionsIncludeLabels){var n=this.boundingBox();t={w:n.w,h:n.h}}else t={w:this.outerWidth(),h:this.outerHeight()};return(t.w===0||t.h===0)&&(t.w=t.h=1),t},layoutPositions:function(e,t,n){var a=this.nodes().filter(function(S){return!S.isParent()}),i=this.cy(),o=t.eles,s=function(R){return R.id()},u=lo(n,s);e.emit({type:"layoutstart",layout:e}),e.animations=[];var l=function(R,_,A){var P={x:_.x1+_.w/2,y:_.y1+_.h/2},I={x:(A.x-P.x)*R,y:(A.y-P.y)*R};return{x:P.x+I.x,y:P.y+I.y}},f=t.spacingFactor&&t.spacingFactor!==1,d=function(){if(!f)return null;for(var R=Lt(),_=0;_<a.length;_++){var A=a[_],P=u(A,_);X2(R,P.x,P.y)}return R},h=d(),g=lo(function(S,R){var _=u(S,R);if(f){var A=Math.abs(t.spacingFactor);_=l(A,h,_)}return t.transform!=null&&(_=t.transform(S,_)),_},s);if(t.animate){for(var p=0;p<a.length;p++){var x=a[p],b=g(x,p),w=t.animateFilter==null||t.animateFilter(x,p);if(w){var y=x.animation({position:b,duration:t.animationDuration,easing:t.animationEasing});e.animations.push(y)}else x.position(b)}if(t.fit){var E=i.animation({fit:{boundingBox:o.boundingBoxAt(g),padding:t.padding},duration:t.animationDuration,easing:t.animationEasing});e.animations.push(E)}else if(t.zoom!==void 0&&t.pan!==void 0){var C=i.animation({zoom:t.zoom,pan:t.pan,duration:t.animationDuration,easing:t.animationEasing});e.animations.push(C)}e.animations.forEach(function(S){return S.play()}),e.one("layoutready",t.ready),e.emit({type:"layoutready",layout:e}),po.all(e.animations.map(function(S){return S.promise()})).then(function(){e.one("layoutstop",t.stop),e.emit({type:"layoutstop",layout:e})})}else a.positions(g),t.fit&&i.fit(t.eles,t.padding),t.zoom!=null&&i.zoom(t.zoom),t.pan&&i.pan(t.pan),e.one("layoutready",t.ready),e.emit({type:"layoutready",layout:e}),e.one("layoutstop",t.stop),e.emit({type:"layoutstop",layout:e});return this},layout:function(e){var t=this.cy();return t.makeLayout(Xe({},e,{eles:this}))}};Gu.createLayout=Gu.makeLayout=Gu.layout;function LA(r,e,t){var n=t._private,a=n.styleCache=n.styleCache||[],i;return(i=a[r])!=null||(i=a[r]=e(t)),i}function Il(r,e){return r=ci(r),function(n){return LA(r,e,n)}}function Dl(r,e){r=ci(r);var t=function(a){return e.call(a)};return function(){var a=this[0];if(a)return LA(r,t,a)}}var mt={recalculateRenderedStyle:function(e){var t=this.cy(),n=t.renderer(),a=t.styleEnabled();return n&&a&&n.recalculateRenderedStyle(this,e),this},dirtyStyleCache:function(){var e=this.cy(),t=function(i){return i._private.styleCache=null};if(e.hasCompoundNodes()){var n;n=this.spawnSelf().merge(this.descendants()).merge(this.parents()),n.merge(n.connectedEdges()),n.forEach(t)}else this.forEach(function(a){t(a),a.connectedEdges().forEach(t)});return this},updateStyle:function(e){var t=this._private.cy;if(!t.styleEnabled())return this;if(t.batching()){var n=t._private.batchStyleEles;return n.merge(this),this}var a=t.hasCompoundNodes(),i=this;e=!!(e||e===void 0),a&&(i=this.spawnSelf().merge(this.descendants()).merge(this.parents()));var o=i;return e?o.emitAndNotify("style"):o.emit("style"),i.forEach(function(s){return s._private.styleDirty=!0}),this},cleanStyle:function(){var e=this.cy();if(e.styleEnabled())for(var t=0;t<this.length;t++){var n=this[t];n._private.styleDirty&&(n._private.styleDirty=!1,e.style().apply(n))}},parsedStyle:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=this[0],a=n.cy();if(a.styleEnabled()&&n){n._private.styleDirty&&(n._private.styleDirty=!1,a.style().apply(n));var i=n._private.style[e];return i??(t?a.style().getDefaultProperty(e):null)}},numericStyle:function(e){var t=this[0];if(t.cy().styleEnabled()&&t){var n=t.pstyle(e);return n.pfValue!==void 0?n.pfValue:n.value}},numericStyleUnits:function(e){var t=this[0];if(t.cy().styleEnabled()&&t)return t.pstyle(e).units},renderedStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=this[0];if(n)return t.style().getRenderedStyle(n,e)},style:function(e,t){var n=this.cy();if(!n.styleEnabled())return this;var a=!1,i=n.style();if(yr(e)){var o=e;i.applyBypass(this,o,a),this.emitAndNotify("style")}else if(Ye(e))if(t===void 0){var s=this[0];return s?i.getStylePropertyValue(s,e):void 0}else i.applyBypass(this,e,t,a),this.emitAndNotify("style");else if(e===void 0){var u=this[0];return u?i.getRawStyle(u):void 0}return this},removeStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=!1,a=t.style(),i=this;if(e===void 0)for(var o=0;o<i.length;o++){var s=i[o];a.removeAllBypasses(s,n)}else{e=e.split(/\s+/);for(var u=0;u<i.length;u++){var l=i[u];a.removeBypasses(l,e,n)}}return this.emitAndNotify("style"),this},show:function(){return this.css("display","element"),this},hide:function(){return this.css("display","none"),this},effectiveOpacity:function(){var e=this.cy();if(!e.styleEnabled())return 1;var t=e.hasCompoundNodes(),n=this[0];if(n){var a=n._private,i=n.pstyle("opacity").value;if(!t)return i;var o=a.data.parent?n.parents():null;if(o)for(var s=0;s<o.length;s++){var u=o[s],l=u.pstyle("opacity").value;i=l*i}return i}},transparent:function(){var e=this.cy();if(!e.styleEnabled())return!1;var t=this[0],n=t.cy().hasCompoundNodes();if(t)return n?t.effectiveOpacity()===0:t.pstyle("opacity").value===0},backgrounding:function(){var e=this.cy();if(!e.styleEnabled())return!1;var t=this[0];return!!t._private.backgrounding}};function rv(r,e){var t=r._private,n=t.data.parent?r.parents():null;if(n)for(var a=0;a<n.length;a++){var i=n[a];if(!e(i))return!1}return!0}function s0(r){var e=r.ok,t=r.edgeOkViaNode||r.ok,n=r.parentOk||r.ok;return function(){var a=this.cy();if(!a.styleEnabled())return!0;var i=this[0],o=a.hasCompoundNodes();if(i){var s=i._private;if(!e(i))return!1;if(i.isNode())return!o||rv(i,n);var u=s.source,l=s.target;return t(u)&&(!o||rv(u,t))&&(u===l||t(l)&&(!o||rv(l,t)))}}}var yo=Il("eleTakesUpSpace",function(r){return r.pstyle("display").value==="element"&&r.width()!==0&&(r.isNode()?r.height()!==0:!0)});mt.takesUpSpace=Dl("takesUpSpace",s0({ok:yo}));var T$=Il("eleInteractive",function(r){return r.pstyle("events").value==="yes"&&r.pstyle("visibility").value==="visible"&&yo(r)}),R$=Il("parentInteractive",function(r){return r.pstyle("visibility").value==="visible"&&yo(r)});mt.interactive=Dl("interactive",s0({ok:T$,parentOk:R$,edgeOkViaNode:yo}));mt.noninteractive=function(){var r=this[0];if(r)return!r.interactive()};var A$=Il("eleVisible",function(r){return r.pstyle("visibility").value==="visible"&&r.pstyle("opacity").pfValue!==0&&yo(r)}),P$=yo;mt.visible=Dl("visible",s0({ok:A$,edgeOkViaNode:P$}));mt.hidden=function(){var r=this[0];if(r)return!r.visible()};mt.isBundledBezier=Dl("isBundledBezier",function(){return this.cy().styleEnabled()?!this.removed()&&this.pstyle("curve-style").value==="bezier"&&this.takesUpSpace():!1});mt.bypass=mt.css=mt.style;mt.renderedCss=mt.renderedStyle;mt.removeBypass=mt.removeCss=mt.removeStyle;mt.pstyle=mt.parsedStyle;var Aa={};function dE(r){return function(){var e=arguments,t=[];if(e.length===2){var n=e[0],a=e[1];this.on(r.event,n,a)}else if(e.length===1&&$r(e[0])){var i=e[0];this.on(r.event,i)}else if(e.length===0||e.length===1&&Tr(e[0])){for(var o=e.length===1?e[0]:null,s=0;s<this.length;s++){var u=this[s],l=!r.ableField||u._private[r.ableField],f=u._private[r.field]!=r.value;if(r.overrideAble){var d=r.overrideAble(u);if(d!==void 0&&(l=d,!d))return this}l&&(u._private[r.field]=r.value,f&&t.push(u))}var h=this.spawn(t);h.updateStyle(),h.emit(r.event),o&&h.emit(o)}return this}}function mo(r){Aa[r.field]=function(){var e=this[0];if(e){if(r.overrideField){var t=r.overrideField(e);if(t!==void 0)return t}return e._private[r.field]}},Aa[r.on]=dE({event:r.on,field:r.field,ableField:r.ableField,overrideAble:r.overrideAble,value:!0}),Aa[r.off]=dE({event:r.off,field:r.field,ableField:r.ableField,overrideAble:r.overrideAble,value:!1})}mo({field:"locked",overrideField:function(e){return e.cy().autolock()?!0:void 0},on:"lock",off:"unlock"});mo({field:"grabbable",overrideField:function(e){return e.cy().autoungrabify()||e.pannable()?!1:void 0},on:"grabify",off:"ungrabify"});mo({field:"selected",ableField:"selectable",overrideAble:function(e){return e.cy().autounselectify()?!1:void 0},on:"select",off:"unselect"});mo({field:"selectable",overrideField:function(e){return e.cy().autounselectify()?!1:void 0},on:"selectify",off:"unselectify"});Aa.deselect=Aa.unselect;Aa.grabbed=function(){var r=this[0];if(r)return r._private.grabbed};mo({field:"active",on:"activate",off:"unactivate"});mo({field:"pannable",on:"panify",off:"unpanify"});Aa.inactive=function(){var r=this[0];if(r)return!r._private.active};var Tt={},vE=function(e){return function(n){for(var a=this,i=[],o=0;o<a.length;o++){var s=a[o];if(s.isNode()){for(var u=!1,l=s.connectedEdges(),f=0;f<l.length;f++){var d=l[f],h=d.source(),g=d.target();if(e.noIncomingEdges&&g===s&&h!==s||e.noOutgoingEdges&&h===s&&g!==s){u=!0;break}}u||i.push(s)}}return this.spawn(i,!0).filter(n)}},hE=function(e){return function(t){for(var n=this,a=[],i=0;i<n.length;i++){var o=n[i];if(o.isNode())for(var s=o.connectedEdges(),u=0;u<s.length;u++){var l=s[u],f=l.source(),d=l.target();e.outgoing&&f===o?(a.push(l),a.push(d)):e.incoming&&d===o&&(a.push(l),a.push(f))}}return this.spawn(a,!0).filter(t)}},gE=function(e){return function(t){for(var n=this,a=[],i={};;){var o=e.outgoing?n.outgoers():n.incomers();if(o.length===0)break;for(var s=!1,u=0;u<o.length;u++){var l=o[u],f=l.id();i[f]||(i[f]=!0,a.push(l),s=!0)}if(!s)break;n=o}return this.spawn(a,!0).filter(t)}};Tt.clearTraversalCache=function(){for(var r=0;r<this.length;r++)this[r]._private.traversalCache=null};Xe(Tt,{roots:vE({noIncomingEdges:!0}),leaves:vE({noOutgoingEdges:!0}),outgoers:hn(hE({outgoing:!0}),"outgoers"),successors:gE({outgoing:!0}),incomers:hn(hE({incoming:!0}),"incomers"),predecessors:gE({})});Xe(Tt,{neighborhood:hn(function(r){for(var e=[],t=this.nodes(),n=0;n<t.length;n++)for(var a=t[n],i=a.connectedEdges(),o=0;o<i.length;o++){var s=i[o],u=s.source(),l=s.target(),f=a===u?l:u;f.length>0&&e.push(f[0]),e.push(s[0])}return this.spawn(e,!0).filter(r)},"neighborhood"),closedNeighborhood:function(e){return this.neighborhood().add(this).filter(e)},openNeighborhood:function(e){return this.neighborhood(e)}});Tt.neighbourhood=Tt.neighborhood;Tt.closedNeighbourhood=Tt.closedNeighborhood;Tt.openNeighbourhood=Tt.openNeighborhood;Xe(Tt,{source:hn(function(e){var t=this[0],n;return t&&(n=t._private.source||t.cy().collection()),n&&e?n.filter(e):n},"source"),target:hn(function(e){var t=this[0],n;return t&&(n=t._private.target||t.cy().collection()),n&&e?n.filter(e):n},"target"),sources:pE({attr:"source"}),targets:pE({attr:"target"})});function pE(r){return function(t){for(var n=[],a=0;a<this.length;a++){var i=this[a],o=i._private[r.attr];o&&n.push(o)}return this.spawn(n,!0).filter(t)}}Xe(Tt,{edgesWith:hn(yE(),"edgesWith"),edgesTo:hn(yE({thisIsSrc:!0}),"edgesTo")});function yE(r){return function(t){var n=[],a=this._private.cy,i=r||{};Ye(t)&&(t=a.$(t));for(var o=0;o<t.length;o++)for(var s=t[o]._private.edges,u=0;u<s.length;u++){var l=s[u],f=l._private.data,d=this.hasElementWithId(f.source)&&t.hasElementWithId(f.target),h=t.hasElementWithId(f.source)&&this.hasElementWithId(f.target),g=d||h;g&&((i.thisIsSrc||i.thisIsTgt)&&(i.thisIsSrc&&!d||i.thisIsTgt&&!h)||n.push(l))}return this.spawn(n,!0)}}Xe(Tt,{connectedEdges:hn(function(r){for(var e=[],t=this,n=0;n<t.length;n++){var a=t[n];if(a.isNode())for(var i=a._private.edges,o=0;o<i.length;o++){var s=i[o];e.push(s)}}return this.spawn(e,!0).filter(r)},"connectedEdges"),connectedNodes:hn(function(r){for(var e=[],t=this,n=0;n<t.length;n++){var a=t[n];a.isEdge()&&(e.push(a.source()[0]),e.push(a.target()[0]))}return this.spawn(e,!0).filter(r)},"connectedNodes"),parallelEdges:hn(mE(),"parallelEdges"),codirectedEdges:hn(mE({codirected:!0}),"codirectedEdges")});function mE(r){var e={codirected:!1};return r=Xe({},e,r),function(n){for(var a=[],i=this.edges(),o=r,s=0;s<i.length;s++)for(var u=i[s],l=u._private,f=l.source,d=f._private.data.id,h=l.data.target,g=f._private.edges,p=0;p<g.length;p++){var x=g[p],b=x._private.data,w=b.target,y=b.source,E=w===h&&y===d,C=d===w&&h===y;(o.codirected&&E||!o.codirected&&(E||C))&&a.push(x)}return this.spawn(a,!0).filter(n)}}Xe(Tt,{components:function(e){var t=this,n=t.cy(),a=n.collection(),i=e==null?t.nodes():e.nodes(),o=[];e!=null&&i.empty()&&(i=e.sources());var s=function(f,d){a.merge(f),i.unmerge(f),d.merge(f)};if(i.empty())return t.spawn();var u=function(){var f=n.collection();o.push(f);var d=i[0];s(d,f),t.bfs({directed:!1,roots:d,visit:function(g){return s(g,f)}}),f.forEach(function(h){h.connectedEdges().forEach(function(g){t.has(g)&&f.has(g.source())&&f.has(g.target())&&f.merge(g)})})};do u();while(i.length>0);return o},component:function(){var e=this[0];return e.cy().mutableElements().components(e)[0]}});Tt.componentsOf=Tt.components;var bt=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(e===void 0){kr("A collection must have a reference to the core");return}var i=new ra,o=!1;if(!t)t=[];else if(t.length>0&&yr(t[0])&&!xs(t[0])){o=!0;for(var s=[],u=new go,l=0,f=t.length;l<f;l++){var d=t[l];d.data==null&&(d.data={});var h=d.data;if(h.id==null)h.id=j2();else if(e.hasElementWithId(h.id)||u.has(h.id))continue;var g=new xl(e,d,!1);s.push(g),u.add(h.id)}t=s}this.length=0;for(var p=0,x=t.length;p<x;p++){var b=t[p][0];if(b!=null){var w=b._private.data.id;(!n||!i.has(w))&&(n&&i.set(w,{index:this.length,ele:b}),this[this.length]=b,this.length++)}}this._private={eles:this,cy:e,get map(){return this.lazyMap==null&&this.rebuildMap(),this.lazyMap},set map(y){this.lazyMap=y},rebuildMap:function(){for(var E=this.lazyMap=new ra,C=this.eles,S=0;S<C.length;S++){var R=C[S];E.set(R.id(),{index:S,ele:R})}}},n&&(this._private.map=i),o&&!a&&this.restore()},Ir=xl.prototype=bt.prototype=Object.create(Array.prototype);Ir.instanceString=function(){return"collection"};Ir.spawn=function(r,e){return new bt(this.cy(),r,e)};Ir.spawnSelf=function(){return this.spawn(this)};Ir.cy=function(){return this._private.cy};Ir.renderer=function(){return this._private.cy.renderer()};Ir.element=function(){return this[0]};Ir.collection=function(){return L2(this)?this:new bt(this._private.cy,[this])};Ir.unique=function(){return new bt(this._private.cy,this,!0)};Ir.hasElementWithId=function(r){return r=""+r,this._private.map.has(r)};Ir.getElementById=function(r){r=""+r;var e=this._private.cy,t=this._private.map.get(r);return t?t.ele:new bt(e)};Ir.$id=Ir.getElementById;Ir.poolIndex=function(){var r=this._private.cy,e=r._private.elements,t=this[0]._private.data.id;return e._private.map.get(t).index};Ir.indexOf=function(r){var e=r[0]._private.data.id;return this._private.map.get(e).index};Ir.indexOfId=function(r){return r=""+r,this._private.map.get(r).index};Ir.json=function(r){var e=this.element(),t=this.cy();if(e==null&&r)return this;if(e!=null){var n=e._private;if(yr(r)){if(t.startBatch(),r.data){e.data(r.data);var a=n.data;if(e.isEdge()){var i=!1,o={},s=r.data.source,u=r.data.target;s!=null&&s!=a.source&&(o.source=""+s,i=!0),u!=null&&u!=a.target&&(o.target=""+u,i=!0),i&&(e=e.move(o))}else{var l="parent"in r.data,f=r.data.parent;l&&(f!=null||a.parent!=null)&&f!=a.parent&&(f===void 0&&(f=null),f!=null&&(f=""+f),e=e.move({parent:f}))}}r.position&&e.position(r.position);var d=function(x,b,w){var y=r[x];y!=null&&y!==n[x]&&(y?e[b]():e[w]())};return d("removed","remove","restore"),d("selected","select","unselect"),d("selectable","selectify","unselectify"),d("locked","lock","unlock"),d("grabbable","grabify","ungrabify"),d("pannable","panify","unpanify"),r.classes!=null&&e.classes(r.classes),t.endBatch(),this}else if(r===void 0){var h={data:Nn(n.data),position:Nn(n.position),group:n.group,removed:n.removed,selected:n.selected,selectable:n.selectable,locked:n.locked,grabbable:n.grabbable,pannable:n.pannable,classes:null};h.classes="";var g=0;return n.classes.forEach(function(p){return h.classes+=g++===0?p:" "+p}),h}}};Ir.jsons=function(){for(var r=[],e=0;e<this.length;e++){var t=this[e],n=t.json();r.push(n)}return r};Ir.clone=function(){for(var r=this.cy(),e=[],t=0;t<this.length;t++){var n=this[t],a=n.json(),i=new xl(r,a,!1);e.push(i)}return new bt(r,e)};Ir.copy=Ir.clone;Ir.restore=function(){for(var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,t=this,n=t.cy(),a=n._private,i=[],o=[],s,u=0,l=t.length;u<l;u++){var f=t[u];e&&!f.removed()||(f.isNode()?i.push(f):o.push(f))}s=i.concat(o);var d,h=function(){s.splice(d,1),d--};for(d=0;d<s.length;d++){var g=s[d],p=g._private,x=p.data;if(g.clearTraversalCache(),!(!e&&!p.removed)){if(x.id===void 0)x.id=j2();else if(qe(x.id))x.id=""+x.id;else if(Da(x.id)||!Ye(x.id)){kr("Can not create element with invalid string ID `"+x.id+"`"),h();continue}else if(n.hasElementWithId(x.id)){kr("Can not create second element with ID `"+x.id+"`"),h();continue}}var b=x.id;if(g.isNode()){var w=p.position;w.x==null&&(w.x=0),w.y==null&&(w.y=0)}if(g.isEdge()){for(var y=g,E=["source","target"],C=E.length,S=!1,R=0;R<C;R++){var _=E[R],A=x[_];qe(A)&&(A=x[_]=""+x[_]),A==null||A===""?(kr("Can not create edge `"+b+"` with unspecified "+_),S=!0):n.hasElementWithId(A)||(kr("Can not create edge `"+b+"` with nonexistant "+_+" `"+A+"`"),S=!0)}if(S){h();continue}var P=n.getElementById(x.source),I=n.getElementById(x.target);P.same(I)?P._private.edges.push(y):(P._private.edges.push(y),I._private.edges.push(y)),y._private.source=P,y._private.target=I}p.map=new ra,p.map.set(b,{ele:g,index:0}),p.removed=!1,e&&n.addToPool(g)}for(var D=0;D<i.length;D++){var L=i[D],M=L._private.data;qe(M.parent)&&(M.parent=""+M.parent);var q=M.parent,N=q!=null;if(N||L._private.parent){var W=L._private.parent?n.collection().merge(L._private.parent):n.getElementById(q);if(W.empty())M.parent=void 0;else if(W[0].removed())Cr("Node added with missing parent, reference to parent removed"),M.parent=void 0,L._private.parent=null;else{for(var V=!1,$=W;!$.empty();){if(L.same($)){V=!0,M.parent=void 0;break}$=$.parent()}V||(W[0]._private.children.push(L),L._private.parent=W[0],a.hasCompoundNodes=!0)}}}if(s.length>0){for(var Z=s.length===t.length?t:new bt(n,s),ee=0;ee<Z.length;ee++){var K=Z[ee];K.isNode()||(K.parallelEdges().clearTraversalCache(),K.source().clearTraversalCache(),K.target().clearTraversalCache())}var j;a.hasCompoundNodes?j=n.collection().merge(Z).merge(Z.connectedNodes()).merge(Z.parent()):j=Z,j.dirtyCompoundBoundsCache().dirtyBoundingBoxCache().updateStyle(r),r?Z.emitAndNotify("add"):e&&Z.emit("add")}return t};Ir.removed=function(){var r=this[0];return r&&r._private.removed};Ir.inside=function(){var r=this[0];return r&&!r._private.removed};Ir.remove=function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,t=this,n=[],a={},i=t._private.cy;function o(q){for(var N=q._private.edges,W=0;W<N.length;W++)u(N[W])}function s(q){for(var N=q._private.children,W=0;W<N.length;W++)u(N[W])}function u(q){var N=a[q.id()];e&&q.removed()||N||(a[q.id()]=!0,q.isNode()?(n.push(q),o(q),s(q)):n.unshift(q))}for(var l=0,f=t.length;l<f;l++){var d=t[l];u(d)}function h(q,N){var W=q._private.edges;Ba(W,N),q.clearTraversalCache()}function g(q){q.clearTraversalCache()}var p=[];p.ids={};function x(q,N){N=N[0],q=q[0];var W=q._private.children,V=q.id();Ba(W,N),N._private.parent=null,p.ids[V]||(p.ids[V]=!0,p.push(q))}t.dirtyCompoundBoundsCache(),e&&i.removeFromPool(n);for(var b=0;b<n.length;b++){var w=n[b];if(w.isEdge()){var y=w.source()[0],E=w.target()[0];h(y,w),h(E,w);for(var C=w.parallelEdges(),S=0;S<C.length;S++){var R=C[S];g(R),R.isBundledBezier()&&R.dirtyBoundingBoxCache()}}else{var _=w.parent();_.length!==0&&x(_,w)}e&&(w._private.removed=!0)}var A=i._private.elements;i._private.hasCompoundNodes=!1;for(var P=0;P<A.length;P++){var I=A[P];if(I.isParent()){i._private.hasCompoundNodes=!0;break}}var D=new bt(this.cy(),n);D.size()>0&&(r?D.emitAndNotify("remove"):e&&D.emit("remove"));for(var L=0;L<p.length;L++){var M=p[L];(!e||!M.removed())&&M.updateStyle()}return D};Ir.move=function(r){var e=this._private.cy,t=this,n=!1,a=!1,i=function(p){return p==null?p:""+p};if(r.source!==void 0||r.target!==void 0){var o=i(r.source),s=i(r.target),u=o!=null&&e.hasElementWithId(o),l=s!=null&&e.hasElementWithId(s);(u||l)&&(e.batch(function(){t.remove(n,a),t.emitAndNotify("moveout");for(var g=0;g<t.length;g++){var p=t[g],x=p._private.data;p.isEdge()&&(u&&(x.source=o),l&&(x.target=s))}t.restore(n,a)}),t.emitAndNotify("move"))}else if(r.parent!==void 0){var f=i(r.parent),d=f===null||e.hasElementWithId(f);if(d){var h=f===null?void 0:f;e.batch(function(){var g=t.remove(n,a);g.emitAndNotify("moveout");for(var p=0;p<t.length;p++){var x=t[p],b=x._private.data;x.isNode()&&(b.parent=h)}g.restore(n,a)}),t.emitAndNotify("move")}}return this};[oA,z5,Vu,Ra,co,t$,Al,m$,DA,BA,C$,sl,Gu,mt,Aa,Tt].forEach(function(r){Xe(Ir,r)});var I$={add:function(e){var t,n=this;if(Jt(e)){var a=e;if(a._private.cy===n)t=a.restore();else{for(var i=[],o=0;o<a.length;o++){var s=a[o];i.push(s.json())}t=new bt(n,i)}}else if(Tr(e)){var u=e;t=new bt(n,u)}else if(yr(e)&&(Tr(e.nodes)||Tr(e.edges))){for(var l=e,f=[],d=["nodes","edges"],h=0,g=d.length;h<g;h++){var p=d[h],x=l[p];if(Tr(x))for(var b=0,w=x.length;b<w;b++){var y=Xe({group:p},x[b]);f.push(y)}}t=new bt(n,f)}else{var E=e;t=new xl(n,E).collection()}return t},remove:function(e){if(!Jt(e)){if(Ye(e)){var t=e;e=this.$(t)}}return e.remove()}};/*! Bezier curve function generator. Copyright Gaetan Renaudeau. MIT License: http://en.wikipedia.org/wiki/MIT_License */function D$(r,e,t,n){var a=4,i=.001,o=1e-7,s=10,u=11,l=1/(u-1),f=typeof Float32Array<"u";if(arguments.length!==4)return!1;for(var d=0;d<4;++d)if(typeof arguments[d]!="number"||isNaN(arguments[d])||!isFinite(arguments[d]))return!1;r=Math.min(r,1),t=Math.min(t,1),r=Math.max(r,0),t=Math.max(t,0);var h=f?new Float32Array(u):new Array(u);function g(I,D){return 1-3*D+3*I}function p(I,D){return 3*D-6*I}function x(I){return 3*I}function b(I,D,L){return((g(D,L)*I+p(D,L))*I+x(D))*I}function w(I,D,L){return 3*g(D,L)*I*I+2*p(D,L)*I+x(D)}function y(I,D){for(var L=0;L<a;++L){var M=w(D,r,t);if(M===0)return D;var q=b(D,r,t)-I;D-=q/M}return D}function E(){for(var I=0;I<u;++I)h[I]=b(I*l,r,t)}function C(I,D,L){var M,q,N=0;do q=D+(L-D)/2,M=b(q,r,t)-I,M>0?L=q:D=q;while(Math.abs(M)>o&&++N<s);return q}function S(I){for(var D=0,L=1,M=u-1;L!==M&&h[L]<=I;++L)D+=l;--L;var q=(I-h[L])/(h[L+1]-h[L]),N=D+q*l,W=w(N,r,t);return W>=i?y(I,N):W===0?N:C(I,D,D+l)}var R=!1;function _(){R=!0,(r!==e||t!==n)&&E()}var A=function(D){return R||_(),r===e&&t===n?D:D===0?0:D===1?1:b(S(D),e,n)};A.getControlPoints=function(){return[{x:r,y:e},{x:t,y:n}]};var P="generateBezier("+[r,e,t,n]+")";return A.toString=function(){return P},A}/*! Runge-Kutta spring physics function generator. Adapted from Framer.js, copyright Koen Bok. MIT License: http://en.wikipedia.org/wiki/MIT_License */var B$=(function(){function r(n){return-n.tension*n.x-n.friction*n.v}function e(n,a,i){var o={x:n.x+i.dx*a,v:n.v+i.dv*a,tension:n.tension,friction:n.friction};return{dx:o.v,dv:r(o)}}function t(n,a){var i={dx:n.v,dv:r(n)},o=e(n,a*.5,i),s=e(n,a*.5,o),u=e(n,a,s),l=1/6*(i.dx+2*(o.dx+s.dx)+u.dx),f=1/6*(i.dv+2*(o.dv+s.dv)+u.dv);return n.x=n.x+l*a,n.v=n.v+f*a,n}return function n(a,i,o){var s={x:-1,v:0,tension:null,friction:null},u=[0],l=0,f=1/1e4,d=16/1e3,h,g,p;for(a=parseFloat(a)||500,i=parseFloat(i)||20,o=o||null,s.tension=a,s.friction=i,h=o!==null,h?(l=n(a,i),g=l/o*d):g=d;p=t(p||s,g),u.push(1+p.x),l+=16,Math.abs(p.x)>f&&Math.abs(p.v)>f;);return h?function(x){return u[x*(u.length-1)|0]}:l}})(),Pr=function(e,t,n,a){var i=D$(e,t,n,a);return function(o,s,u){return o+(s-o)*i(u)}},Wu={linear:function(e,t,n){return e+(t-e)*n},ease:Pr(.25,.1,.25,1),"ease-in":Pr(.42,0,1,1),"ease-out":Pr(0,0,.58,1),"ease-in-out":Pr(.42,0,.58,1),"ease-in-sine":Pr(.47,0,.745,.715),"ease-out-sine":Pr(.39,.575,.565,1),"ease-in-out-sine":Pr(.445,.05,.55,.95),"ease-in-quad":Pr(.55,.085,.68,.53),"ease-out-quad":Pr(.25,.46,.45,.94),"ease-in-out-quad":Pr(.455,.03,.515,.955),"ease-in-cubic":Pr(.55,.055,.675,.19),"ease-out-cubic":Pr(.215,.61,.355,1),"ease-in-out-cubic":Pr(.645,.045,.355,1),"ease-in-quart":Pr(.895,.03,.685,.22),"ease-out-quart":Pr(.165,.84,.44,1),"ease-in-out-quart":Pr(.77,0,.175,1),"ease-in-quint":Pr(.755,.05,.855,.06),"ease-out-quint":Pr(.23,1,.32,1),"ease-in-out-quint":Pr(.86,0,.07,1),"ease-in-expo":Pr(.95,.05,.795,.035),"ease-out-expo":Pr(.19,1,.22,1),"ease-in-out-expo":Pr(1,0,0,1),"ease-in-circ":Pr(.6,.04,.98,.335),"ease-out-circ":Pr(.075,.82,.165,1),"ease-in-out-circ":Pr(.785,.135,.15,.86),spring:function(e,t,n){if(n===0)return Wu.linear;var a=B$(e,t,n);return function(i,o,s){return i+(o-i)*a(s)}},"cubic-bezier":Pr};function bE(r,e,t,n,a){if(n===1||e===t)return t;var i=a(e,t,n);return r==null||((r.roundValue||r.color)&&(i=Math.round(i)),r.min!==void 0&&(i=Math.max(i,r.min)),r.max!==void 0&&(i=Math.min(i,r.max))),i}function wE(r,e){return r.pfValue!=null||r.value!=null?r.pfValue!=null&&(e==null||e.type.units!=="%")?r.pfValue:r.value:r}function Ui(r,e,t,n,a){var i=a!=null?a.type:null;t<0?t=0:t>1&&(t=1);var o=wE(r,a),s=wE(e,a);if(qe(o)&&qe(s))return bE(i,o,s,t,n);if(Tr(o)&&Tr(s)){for(var u=[],l=0;l<s.length;l++){var f=o[l],d=s[l];if(f!=null&&d!=null){var h=bE(i,f,d,t,n);u.push(h)}else u.push(d)}return u}}function M$(r,e,t,n){var a=!n,i=r._private,o=e._private,s=o.easing,u=o.startTime,l=n?r:r.cy(),f=l.style();if(!o.easingImpl)if(s==null)o.easingImpl=Wu.linear;else{var d;if(Ye(s)){var h=f.parse("transition-timing-function",s);d=h.value}else d=s;var g,p;Ye(d)?(g=d,p=[]):(g=d[1],p=d.slice(2).map(function(Z){return+Z})),p.length>0?(g==="spring"&&p.push(o.duration),o.easingImpl=Wu[g].apply(null,p)):o.easingImpl=Wu[g]}var x=o.easingImpl,b;if(o.duration===0?b=1:b=(t-u)/o.duration,o.applying&&(b=o.progress),b<0?b=0:b>1&&(b=1),o.delay==null){var w=o.startPosition,y=o.position;if(y&&a&&!r.locked()){var E={};Go(w.x,y.x)&&(E.x=Ui(w.x,y.x,b,x)),Go(w.y,y.y)&&(E.y=Ui(w.y,y.y,b,x)),r.position(E)}var C=o.startPan,S=o.pan,R=i.pan,_=S!=null&&n;_&&(Go(C.x,S.x)&&(R.x=Ui(C.x,S.x,b,x)),Go(C.y,S.y)&&(R.y=Ui(C.y,S.y,b,x)),r.emit("pan"));var A=o.startZoom,P=o.zoom,I=P!=null&&n;I&&(Go(A,P)&&(i.zoom=ds(i.minZoom,Ui(A,P,b,x),i.maxZoom)),r.emit("zoom")),(_||I)&&r.emit("viewport");var D=o.style;if(D&&D.length>0&&a){for(var L=0;L<D.length;L++){var M=D[L],q=M.name,N=M,W=o.startStyle[q],V=f.properties[W.name],$=Ui(W,N,b,x,V);f.overrideBypass(r,q,$)}r.emit("style")}}return o.progress=b,b}function Go(r,e){return r==null||e==null?!1:qe(r)&&qe(e)?!0:!!(r&&e)}function L$(r,e,t,n){var a=e._private;a.started=!0,a.startTime=t-a.progress*a.duration}function xE(r,e){var t=e._private.aniEles,n=[];function a(f,d){var h=f._private,g=h.animation.current,p=h.animation.queue,x=!1;if(g.length===0){var b=p.shift();b&&g.push(b)}for(var w=function(R){for(var _=R.length-1;_>=0;_--){var A=R[_];A()}R.splice(0,R.length)},y=g.length-1;y>=0;y--){var E=g[y],C=E._private;if(C.stopped){g.splice(y,1),C.hooked=!1,C.playing=!1,C.started=!1,w(C.frames);continue}!C.playing&&!C.applying||(C.playing&&C.applying&&(C.applying=!1),C.started||L$(f,E,r),M$(f,E,r,d),C.applying&&(C.applying=!1),w(C.frames),C.step!=null&&C.step(r),E.completed()&&(g.splice(y,1),C.hooked=!1,C.playing=!1,C.started=!1,w(C.completes)),x=!0)}return!d&&g.length===0&&p.length===0&&n.push(f),x}for(var i=!1,o=0;o<t.length;o++){var s=t[o],u=a(s);i=i||u}var l=a(e,!0);(i||l)&&(t.length>0?e.notify("draw",t):e.notify("draw")),t.unmerge(n),e.emit("step")}var O$={animate:Er.animate(),animation:Er.animation(),animated:Er.animated(),clearQueue:Er.clearQueue(),delay:Er.delay(),delayAnimation:Er.delayAnimation(),stop:Er.stop(),addToAnimationPool:function(e){var t=this;t.styleEnabled()&&t._private.aniEles.merge(e)},stopAnimationLoop:function(){this._private.animationsRunning=!1},startAnimationLoop:function(){var e=this;if(e._private.animationsRunning=!0,!e.styleEnabled())return;function t(){e._private.animationsRunning&&tl(function(i){xE(i,e),t()})}var n=e.renderer();n&&n.beforeRender?n.beforeRender(function(i,o){xE(o,e)},n.beforeRenderPriorities.animations):t()}},k$={qualifierCompare:function(e,t){return e==null||t==null?e==null&&t==null:e.sameText(t)},eventMatches:function(e,t,n){var a=t.qualifier;return a!=null?e!==n.target&&xs(n.target)&&a.matches(n.target):!0},addEventFields:function(e,t){t.cy=e,t.target=e},callbackContext:function(e,t,n){return t.qualifier!=null?n.target:e}},Ou=function(e){return Ye(e)?new La(e):e},OA={createEmitter:function(){var e=this._private;return e.emitter||(e.emitter=new Pl(k$,this)),this},emitter:function(){return this._private.emitter},on:function(e,t,n){return this.emitter().on(e,Ou(t),n),this},removeListener:function(e,t,n){return this.emitter().removeListener(e,Ou(t),n),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},one:function(e,t,n){return this.emitter().one(e,Ou(t),n),this},once:function(e,t,n){return this.emitter().one(e,Ou(t),n),this},emit:function(e,t){return this.emitter().emit(e,t),this},emitAndNotify:function(e,t){return this.emit(e),this.notify(e,t),this}};Er.eventAliasesOn(OA);var Im={png:function(e){var t=this._private.renderer;return e=e||{},t.png(e)},jpg:function(e){var t=this._private.renderer;return e=e||{},e.bg=e.bg||"#fff",t.jpg(e)}};Im.jpeg=Im.jpg;var Uu={layout:function(e){var t=this;if(e==null){kr("Layout options must be specified to make a layout");return}if(e.name==null){kr("A `name` must be specified to make a layout");return}var n=e.name,a=t.extension("layout",n);if(a==null){kr("No such layout `"+n+"` found. Did you forget to import it and `cytoscape.use()` it?");return}var i;Ye(e.eles)?i=t.$(e.eles):i=e.eles!=null?e.eles:t.$();var o=new a(Xe({},e,{cy:t,eles:i}));return o}};Uu.createLayout=Uu.makeLayout=Uu.layout;var q$={notify:function(e,t){var n=this._private;if(this.batching()){n.batchNotifications=n.batchNotifications||{};var a=n.batchNotifications[e]=n.batchNotifications[e]||this.collection();t!=null&&a.merge(t);return}if(n.notificationsEnabled){var i=this.renderer();this.destroyed()||!i||i.notify(e,t)}},notifications:function(e){var t=this._private;return e===void 0?t.notificationsEnabled:(t.notificationsEnabled=!!e,this)},noNotifications:function(e){this.notifications(!1),e(),this.notifications(!0)},batching:function(){return this._private.batchCount>0},startBatch:function(){var e=this._private;return e.batchCount==null&&(e.batchCount=0),e.batchCount===0&&(e.batchStyleEles=this.collection(),e.batchNotifications={}),e.batchCount++,this},endBatch:function(){var e=this._private;if(e.batchCount===0)return this;if(e.batchCount--,e.batchCount===0){e.batchStyleEles.updateStyle();var t=this.renderer();Object.keys(e.batchNotifications).forEach(function(n){var a=e.batchNotifications[n];a.empty()?t.notify(n):t.notify(n,a)})}return this},batch:function(e){return this.startBatch(),e(),this.endBatch(),this},batchData:function(e){var t=this;return this.batch(function(){for(var n=Object.keys(e),a=0;a<n.length;a++){var i=n[a],o=e[i],s=t.getElementById(i);s.data(o)}})}},N$=wt({hideEdgesOnViewport:!1,textureOnViewport:!1,motionBlur:!1,motionBlurOpacity:.05,pixelRatio:void 0,desktopTapThreshold:4,touchTapThreshold:8,wheelSensitivity:1,debug:!1,showFps:!1,webgl:!1,webglDebug:!1,webglDebugShowAtlases:!1,webglTexSize:2048,webglTexRows:36,webglTexRowsNodes:18,webglBatchSize:2048,webglTexPerBatch:14,webglBgColor:[255,255,255]}),Dm={renderTo:function(e,t,n,a){var i=this._private.renderer;return i.renderTo(e,t,n,a),this},renderer:function(){return this._private.renderer},forceRender:function(){return this.notify("draw"),this},resize:function(){return this.invalidateSize(),this.emitAndNotify("resize"),this},initRenderer:function(e){var t=this,n=t.extension("renderer",e.name);if(n==null){kr("Can not initialise: No such renderer `".concat(e.name,"` found. Did you forget to import it and `cytoscape.use()` it?"));return}e.wheelSensitivity!==void 0&&Cr("You have set a custom wheel sensitivity. This will make your app zoom unnaturally when using mainstream mice. You should change this value from the default only if you can guarantee that all your users will use the same hardware and OS configuration as your current machine.");var a=N$(e);a.cy=t,t._private.renderer=new n(a),this.notify("init")},destroyRenderer:function(){var e=this;e.notify("destroy");var t=e.container();if(t)for(t._cyreg=null;t.childNodes.length>0;)t.removeChild(t.childNodes[0]);e._private.renderer=null,e.mutableElements().forEach(function(n){var a=n._private;a.rscratch={},a.rstyle={},a.animation.current=[],a.animation.queue=[]})},onRender:function(e){return this.on("render",e)},offRender:function(e){return this.off("render",e)}};Dm.invalidateDimensions=Dm.resize;var Hu={collection:function(e,t){return Ye(e)?this.$(e):Jt(e)?e.collection():Tr(e)?(t||(t={}),new bt(this,e,t.unique,t.removed)):new bt(this)},nodes:function(e){var t=this.$(function(n){return n.isNode()});return e?t.filter(e):t},edges:function(e){var t=this.$(function(n){return n.isEdge()});return e?t.filter(e):t},$:function(e){var t=this._private.elements;return e?t.filter(e):t.spawnSelf()},mutableElements:function(){return this._private.elements}};Hu.elements=Hu.filter=Hu.$;var ft={},as="t",F$="f";ft.apply=function(r){for(var e=this,t=e._private,n=t.cy,a=n.collection(),i=0;i<r.length;i++){var o=r[i],s=e.getContextMeta(o);if(!s.empty){var u=e.getContextStyle(s),l=e.applyContextStyle(s,u,o);o._private.appliedInitStyle?e.updateTransitions(o,l.diffProps):o._private.appliedInitStyle=!0;var f=e.updateStyleHints(o);f&&a.push(o)}}return a};ft.getPropertiesDiff=function(r,e){var t=this,n=t._private.propDiffs=t._private.propDiffs||{},a=r+"-"+e,i=n[a];if(i)return i;for(var o=[],s={},u=0;u<t.length;u++){var l=t[u],f=r[u]===as,d=e[u]===as,h=f!==d,g=l.mappedProperties.length>0;if(h||d&&g){var p=void 0;h&&g||h?p=l.properties:g&&(p=l.mappedProperties);for(var x=0;x<p.length;x++){for(var b=p[x],w=b.name,y=!1,E=u+1;E<t.length;E++){var C=t[E],S=e[E]===as;if(S&&(y=C.properties[b.name]!=null,y))break}!s[w]&&!y&&(s[w]=!0,o.push(w))}}}return n[a]=o,o};ft.getContextMeta=function(r){for(var e=this,t="",n,a=r._private.styleCxtKey||"",i=0;i<e.length;i++){var o=e[i],s=o.selector&&o.selector.matches(r);s?t+=as:t+=F$}return n=e.getPropertiesDiff(a,t),r._private.styleCxtKey=t,{key:t,diffPropNames:n,empty:n.length===0}};ft.getContextStyle=function(r){var e=r.key,t=this,n=this._private.contextStyles=this._private.contextStyles||{};if(n[e])return n[e];for(var a={_private:{key:e}},i=0;i<t.length;i++){var o=t[i],s=e[i]===as;if(s)for(var u=0;u<o.properties.length;u++){var l=o.properties[u];a[l.name]=l}}return n[e]=a,a};ft.applyContextStyle=function(r,e,t){for(var n=this,a=r.diffPropNames,i={},o=n.types,s=0;s<a.length;s++){var u=a[s],l=e[u],f=t.pstyle(u);if(!l)if(f)f.bypass?l={name:u,deleteBypassed:!0}:l={name:u,delete:!0};else continue;if(f!==l){if(l.mapped===o.fn&&f!=null&&f.mapping!=null&&f.mapping.value===l.value){var d=f.mapping,h=d.fnValue=l.value(t);if(h===d.prevFnValue)continue}var g=i[u]={prev:f};n.applyParsedProperty(t,l),g.next=t.pstyle(u),g.next&&g.next.bypass&&(g.next=g.next.bypassed)}}return{diffProps:i}};ft.updateStyleHints=function(r){var e=r._private,t=this,n=t.propertyGroupNames,a=t.propertyGroupKeys,i=function(ie,de,we){return t.getPropertiesHash(ie,de,we)},o=e.styleKey;if(r.removed())return!1;var s=e.group==="nodes",u=r._private.style;n=Object.keys(u);for(var l=0;l<a.length;l++){var f=a[l];e.styleKeys[f]=[oi,Xi]}for(var d=function(ie,de){return e.styleKeys[de][0]=ls(ie,e.styleKeys[de][0])},h=function(ie,de){return e.styleKeys[de][1]=fs(ie,e.styleKeys[de][1])},g=function(ie,de){d(ie,de),h(ie,de)},p=function(ie,de){for(var we=0;we<ie.length;we++){var Ae=ie.charCodeAt(we);d(Ae,de),h(Ae,de)}},x=2e9,b=function(ie){return-128<ie&&ie<128&&Math.floor(ie)!==ie?x-(ie*1024|0):ie},w=0;w<n.length;w++){var y=n[w],E=u[y];if(E!=null){var C=this.properties[y],S=C.type,R=C.groupKey,_=void 0;C.hashOverride!=null?_=C.hashOverride(r,E):E.pfValue!=null&&(_=E.pfValue);var A=C.enums==null?E.value:null,P=_!=null,I=A!=null,D=P||I,L=E.units;if(S.number&&D&&!S.multiple){var M=P?_:A;g(b(M),R),!P&&L!=null&&p(L,R)}else p(E.strValue,R)}}for(var q=[oi,Xi],N=0;N<a.length;N++){var W=a[N],V=e.styleKeys[W];q[0]=ls(V[0],q[0]),q[1]=fs(V[1],q[1])}e.styleKey=rF(q[0],q[1]);var $=e.styleKeys;e.labelDimsKey=wa($.labelDimensions);var Z=i(r,["label"],$.labelDimensions);if(e.labelKey=wa(Z),e.labelStyleKey=wa(Ru($.commonLabel,Z)),!s){var ee=i(r,["source-label"],$.labelDimensions);e.sourceLabelKey=wa(ee),e.sourceLabelStyleKey=wa(Ru($.commonLabel,ee));var K=i(r,["target-label"],$.labelDimensions);e.targetLabelKey=wa(K),e.targetLabelStyleKey=wa(Ru($.commonLabel,K))}if(s){var j=e.styleKeys,fe=j.nodeBody,G=j.nodeBorder,z=j.nodeOutline,Y=j.backgroundImage,te=j.compound,ue=j.pie,oe=j.stripe,X=[fe,G,z,Y,te,ue,oe].filter(function(Q){return Q!=null}).reduce(Ru,[oi,Xi]);e.nodeKey=wa(X),e.hasPie=ue!=null&&ue[0]!==oi&&ue[1]!==Xi,e.hasStripe=oe!=null&&oe[0]!==oi&&oe[1]!==Xi}return o!==e.styleKey};ft.clearStyleHints=function(r){var e=r._private;e.styleCxtKey="",e.styleKeys={},e.styleKey=null,e.labelKey=null,e.labelStyleKey=null,e.sourceLabelKey=null,e.sourceLabelStyleKey=null,e.targetLabelKey=null,e.targetLabelStyleKey=null,e.nodeKey=null,e.hasPie=null,e.hasStripe=null};ft.applyParsedProperty=function(r,e){var t=this,n=e,a=r._private.style,i,o=t.types,s=t.properties[n.name].type,u=n.bypass,l=a[n.name],f=l&&l.bypass,d=r._private,h="mapping",g=function(fe){return fe==null?null:fe.pfValue!=null?fe.pfValue:fe.value},p=function(){var fe=g(l),G=g(n);t.checkTriggers(r,n.name,fe,G)};if(e.name==="curve-style"&&r.isEdge()&&(e.value!=="bezier"&&r.isLoop()||e.value==="haystack"&&(r.source().isParent()||r.target().isParent()))&&(n=e=this.parse(e.name,"bezier",u)),n.delete)return a[n.name]=void 0,p(),!0;if(n.deleteBypassed)return l?l.bypass?(l.bypassed=void 0,p(),!0):!1:(p(),!0);if(n.deleteBypass)return l?l.bypass?(a[n.name]=l.bypassed,p(),!0):!1:(p(),!0);var x=function(){Cr("Do not assign mappings to elements without corresponding data (i.e. ele `"+r.id()+"` has no mapping for property `"+n.name+"` with data field `"+n.field+"`); try a `["+n.field+"]` selector to limit scope to elements with `"+n.field+"` defined")};switch(n.mapped){case o.mapData:{for(var b=n.field.split("."),w=d.data,y=0;y<b.length&&w;y++){var E=b[y];w=w[E]}if(w==null)return x(),!1;var C;if(qe(w)){var S=n.fieldMax-n.fieldMin;S===0?C=0:C=(w-n.fieldMin)/S}else return Cr("Do not use continuous mappers without specifying numeric data (i.e. `"+n.field+": "+w+"` for `"+r.id()+"` is non-numeric)"),!1;if(C<0?C=0:C>1&&(C=1),s.color){var R=n.valueMin[0],_=n.valueMax[0],A=n.valueMin[1],P=n.valueMax[1],I=n.valueMin[2],D=n.valueMax[2],L=n.valueMin[3]==null?1:n.valueMin[3],M=n.valueMax[3]==null?1:n.valueMax[3],q=[Math.round(R+(_-R)*C),Math.round(A+(P-A)*C),Math.round(I+(D-I)*C),Math.round(L+(M-L)*C)];i={bypass:n.bypass,name:n.name,value:q,strValue:"rgb("+q[0]+", "+q[1]+", "+q[2]+")"}}else if(s.number){var N=n.valueMin+(n.valueMax-n.valueMin)*C;i=this.parse(n.name,N,n.bypass,h)}else return!1;if(!i)return x(),!1;i.mapping=n,n=i;break}case o.data:{for(var W=n.field.split("."),V=d.data,$=0;$<W.length&&V;$++){var Z=W[$];V=V[Z]}if(V!=null&&(i=this.parse(n.name,V,n.bypass,h)),!i)return x(),!1;i.mapping=n,n=i;break}case o.fn:{var ee=n.value,K=n.fnValue!=null?n.fnValue:ee(r);if(n.prevFnValue=K,K==null)return Cr("Custom function mappers may not return null (i.e. `"+n.name+"` for ele `"+r.id()+"` is null)"),!1;if(i=this.parse(n.name,K,n.bypass,h),!i)return Cr("Custom function mappers may not return invalid values for the property type (i.e. `"+n.name+"` for ele `"+r.id()+"` is invalid)"),!1;i.mapping=Nn(n),n=i;break}case void 0:break;default:return!1}return u?(f?n.bypassed=l.bypassed:n.bypassed=l,a[n.name]=n):f?l.bypassed=n:a[n.name]=n,p(),!0};ft.cleanElements=function(r,e){for(var t=0;t<r.length;t++){var n=r[t];if(this.clearStyleHints(n),n.dirtyCompoundBoundsCache(),n.dirtyBoundingBoxCache(),!e)n._private.style={};else for(var a=n._private.style,i=Object.keys(a),o=0;o<i.length;o++){var s=i[o],u=a[s];u!=null&&(u.bypass?u.bypassed=null:a[s]=null)}}};ft.update=function(){var r=this._private.cy,e=r.mutableElements();e.updateStyle()};ft.updateTransitions=function(r,e){var t=this,n=r._private,a=r.pstyle("transition-property").value,i=r.pstyle("transition-duration").pfValue,o=r.pstyle("transition-delay").pfValue;if(a.length>0&&i>0){for(var s={},u=!1,l=0;l<a.length;l++){var f=a[l],d=r.pstyle(f),h=e[f];if(h){var g=h.prev,p=g,x=h.next!=null?h.next:d,b=!1,w=void 0,y=1e-6;p&&(qe(p.pfValue)&&qe(x.pfValue)?(b=x.pfValue-p.pfValue,w=p.pfValue+y*b):qe(p.value)&&qe(x.value)?(b=x.value-p.value,w=p.value+y*b):Tr(p.value)&&Tr(x.value)&&(b=p.value[0]!==x.value[0]||p.value[1]!==x.value[1]||p.value[2]!==x.value[2],w=p.strValue),b&&(s[f]=x.strValue,this.applyBypass(r,f,w),u=!0))}}if(!u)return;n.transitioning=!0,new po(function(E){o>0?r.delayAnimation(o).play().promise().then(E):E()}).then(function(){return r.animation({style:s,duration:i,easing:r.pstyle("transition-timing-function").value,queue:!1}).play().promise()}).then(function(){t.removeBypasses(r,a),r.emitAndNotify("style"),n.transitioning=!1})}else n.transitioning&&(this.removeBypasses(r,a),r.emitAndNotify("style"),n.transitioning=!1)};ft.checkTrigger=function(r,e,t,n,a,i){var o=this.properties[e],s=a(o);r.removed()||s!=null&&s(t,n,r)&&i(o)};ft.checkZOrderTrigger=function(r,e,t,n){var a=this;this.checkTrigger(r,e,t,n,function(i){return i.triggersZOrder},function(){a._private.cy.notify("zorder",r)})};ft.checkBoundsTrigger=function(r,e,t,n){this.checkTrigger(r,e,t,n,function(a){return a.triggersBounds},function(a){r.dirtyCompoundBoundsCache(),r.dirtyBoundingBoxCache()})};ft.checkConnectedEdgesBoundsTrigger=function(r,e,t,n){this.checkTrigger(r,e,t,n,function(a){return a.triggersBoundsOfConnectedEdges},function(a){r.connectedEdges().forEach(function(i){i.dirtyBoundingBoxCache()})})};ft.checkParallelEdgesBoundsTrigger=function(r,e,t,n){this.checkTrigger(r,e,t,n,function(a){return a.triggersBoundsOfParallelEdges},function(a){r.parallelEdges().forEach(function(i){i.dirtyBoundingBoxCache()})})};ft.checkTriggers=function(r,e,t,n){r.dirtyStyleCache(),this.checkZOrderTrigger(r,e,t,n),this.checkBoundsTrigger(r,e,t,n),this.checkConnectedEdgesBoundsTrigger(r,e,t,n),this.checkParallelEdgesBoundsTrigger(r,e,t,n)};var As={};As.applyBypass=function(r,e,t,n){var a=this,i=[],o=!0;if(e==="*"||e==="**"){if(t!==void 0)for(var s=0;s<a.properties.length;s++){var u=a.properties[s],l=u.name,f=this.parse(l,t,!0);f&&i.push(f)}}else if(Ye(e)){var d=this.parse(e,t,!0);d&&i.push(d)}else if(yr(e)){var h=e;n=t;for(var g=Object.keys(h),p=0;p<g.length;p++){var x=g[p],b=h[x];if(b===void 0&&(b=h[bl(x)]),b!==void 0){var w=this.parse(x,b,!0);w&&i.push(w)}}}else return!1;if(i.length===0)return!1;for(var y=!1,E=0;E<r.length;E++){for(var C=r[E],S={},R=void 0,_=0;_<i.length;_++){var A=i[_];if(n){var P=C.pstyle(A.name);R=S[A.name]={prev:P}}y=this.applyParsedProperty(C,Nn(A))||y,n&&(R.next=C.pstyle(A.name))}y&&this.updateStyleHints(C),n&&this.updateTransitions(C,S,o)}return y};As.overrideBypass=function(r,e,t){e=Km(e);for(var n=0;n<r.length;n++){var a=r[n],i=a._private.style[e],o=this.properties[e].type,s=o.color,u=o.mutiple,l=i?i.pfValue!=null?i.pfValue:i.value:null;!i||!i.bypass?this.applyBypass(a,e,t):(i.value=t,i.pfValue!=null&&(i.pfValue=t),s?i.strValue="rgb("+t.join(",")+")":u?i.strValue=t.join(" "):i.strValue=""+t,this.updateStyleHints(a)),this.checkTriggers(a,e,l,t)}};As.removeAllBypasses=function(r,e){return this.removeBypasses(r,this.propertyNames,e)};As.removeBypasses=function(r,e,t){for(var n=!0,a=0;a<r.length;a++){for(var i=r[a],o={},s=0;s<e.length;s++){var u=e[s],l=this.properties[u],f=i.pstyle(l.name);if(!(!f||!f.bypass)){var d="",h=this.parse(u,d,!0),g=o[l.name]={prev:f};this.applyParsedProperty(i,h),g.next=i.pstyle(l.name)}}this.updateStyleHints(i),t&&this.updateTransitions(i,o,n)}};var u0={};u0.getEmSizeInPixels=function(){var r=this.containerCss("font-size");return r!=null?parseFloat(r):1};u0.containerCss=function(r){var e=this._private.cy,t=e.container(),n=e.window();if(n&&t&&n.getComputedStyle)return n.getComputedStyle(t).getPropertyValue(r)};var Fn={};Fn.getRenderedStyle=function(r,e){return e?this.getStylePropertyValue(r,e,!0):this.getRawStyle(r,!0)};Fn.getRawStyle=function(r,e){var t=this;if(r=r[0],r){for(var n={},a=0;a<t.properties.length;a++){var i=t.properties[a],o=t.getStylePropertyValue(r,i.name,e);o!=null&&(n[i.name]=o,n[bl(i.name)]=o)}return n}};Fn.getIndexedStyle=function(r,e,t,n){var a=r.pstyle(e)[t][n];return a??r.cy().style().getDefaultProperty(e)[t][0]};Fn.getStylePropertyValue=function(r,e,t){var n=this;if(r=r[0],r){var a=n.properties[e];a.alias&&(a=a.pointsTo);var i=a.type,o=r.pstyle(a.name);if(o){var s=o.value,u=o.units,l=o.strValue;if(t&&i.number&&s!=null&&qe(s)){var f=r.cy().zoom(),d=function(b){return b*f},h=function(b,w){return d(b)+w},g=Tr(s),p=g?u.every(function(x){return x!=null}):u!=null;return p?g?s.map(function(x,b){return h(x,u[b])}).join(" "):h(s,u):g?s.map(function(x){return Ye(x)?x:""+d(x)}).join(" "):""+d(s)}else if(l!=null)return l}return null}};Fn.getAnimationStartStyle=function(r,e){for(var t={},n=0;n<e.length;n++){var a=e[n],i=a.name,o=r.pstyle(i);o!==void 0&&(yr(o)?o=this.parse(i,o.strValue):o=this.parse(i,o)),o&&(t[i]=o)}return t};Fn.getPropsList=function(r){var e=this,t=[],n=r,a=e.properties;if(n)for(var i=Object.keys(n),o=0;o<i.length;o++){var s=i[o],u=n[s],l=a[s]||a[Km(s)],f=this.parse(l.name,u);f&&t.push(f)}return t};Fn.getNonDefaultPropertiesHash=function(r,e,t){var n=t.slice(),a,i,o,s,u,l;for(u=0;u<e.length;u++)if(a=e[u],i=r.pstyle(a,!1),i!=null)if(i.pfValue!=null)n[0]=ls(s,n[0]),n[1]=fs(s,n[1]);else for(o=i.strValue,l=0;l<o.length;l++)s=o.charCodeAt(l),n[0]=ls(s,n[0]),n[1]=fs(s,n[1]);return n};Fn.getPropertiesHash=Fn.getNonDefaultPropertiesHash;var Bl={};Bl.appendFromJson=function(r){for(var e=this,t=0;t<r.length;t++){var n=r[t],a=n.selector,i=n.style||n.css,o=Object.keys(i);e.selector(a);for(var s=0;s<o.length;s++){var u=o[s],l=i[u];e.css(u,l)}}return e};Bl.fromJson=function(r){var e=this;return e.resetToDefault(),e.appendFromJson(r),e};Bl.json=function(){for(var r=[],e=this.defaultLength;e<this.length;e++){for(var t=this[e],n=t.selector,a=t.properties,i={},o=0;o<a.length;o++){var s=a[o];i[s.name]=s.strValue}r.push({selector:n?n.toString():"core",style:i})}return r};var l0={};l0.appendFromString=function(r){var e=this,t=this,n=""+r,a,i,o;n=n.replace(/[/][*](\s|.)+?[*][/]/g,"");function s(){n.length>a.length?n=n.substr(a.length):n=""}function u(){i.length>o.length?i=i.substr(o.length):i=""}for(;;){var l=n.match(/^\s*$/);if(l)break;var f=n.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!f){Cr("Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: "+n);break}a=f[0];var d=f[1];if(d!=="core"){var h=new La(d);if(h.invalid){Cr("Skipping parsing of block: Invalid selector found in string stylesheet: "+d),s();continue}}var g=f[2],p=!1;i=g;for(var x=[];;){var b=i.match(/^\s*$/);if(b)break;var w=i.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/);if(!w){Cr("Skipping parsing of block: Invalid formatting of style property and value definitions found in:"+g),p=!0;break}o=w[0];var y=w[1],E=w[2],C=e.properties[y];if(!C){Cr("Skipping property: Invalid property name in: "+o),u();continue}var S=t.parse(y,E);if(!S){Cr("Skipping property: Invalid property definition in: "+o),u();continue}x.push({name:y,val:E}),u()}if(p){s();break}t.selector(d);for(var R=0;R<x.length;R++){var _=x[R];t.css(_.name,_.val)}s()}return t};l0.fromString=function(r){var e=this;return e.resetToDefault(),e.appendFromString(r),e};var Yr={};(function(){var r=nt,e=MN,t=ON,n=kN,a=qN,i=function(Q){return"^"+Q+"\\s*\\(\\s*([\\w\\.]+)\\s*\\)$"},o=function(Q){var ie=r+"|\\w+|"+e+"|"+t+"|"+n+"|"+a;return"^"+Q+"\\s*\\(([\\w\\.]+)\\s*\\,\\s*("+r+")\\s*\\,\\s*("+r+")\\s*,\\s*("+ie+")\\s*\\,\\s*("+ie+")\\)$"},s=[`^url\\s*\\(\\s*['"]?(.+?)['"]?\\s*\\)$`,"^(none)$","^(.+)$"];Yr.types={time:{number:!0,min:0,units:"s|ms",implicitUnits:"ms"},percent:{number:!0,min:0,max:100,units:"%",implicitUnits:"%"},percentages:{number:!0,min:0,max:100,units:"%",implicitUnits:"%",multiple:!0},zeroOneNumber:{number:!0,min:0,max:1,unitless:!0},zeroOneNumbers:{number:!0,min:0,max:1,unitless:!0,multiple:!0},nOneOneNumber:{number:!0,min:-1,max:1,unitless:!0},nonNegativeInt:{number:!0,min:0,integer:!0,unitless:!0},nonNegativeNumber:{number:!0,min:0,unitless:!0},position:{enums:["parent","origin"]},nodeSize:{number:!0,min:0,enums:["label"]},number:{number:!0,unitless:!0},numbers:{number:!0,unitless:!0,multiple:!0},positiveNumber:{number:!0,unitless:!0,min:0,strictMin:!0},size:{number:!0,min:0},bidirectionalSize:{number:!0},bidirectionalSizeMaybePercent:{number:!0,allowPercent:!0},bidirectionalSizes:{number:!0,multiple:!0},sizeMaybePercent:{number:!0,min:0,allowPercent:!0},axisDirection:{enums:["horizontal","leftward","rightward","vertical","upward","downward","auto"]},axisDirectionExplicit:{enums:["leftward","rightward","upward","downward"]},axisDirectionPrimary:{enums:["horizontal","vertical"]},paddingRelativeTo:{enums:["width","height","average","min","max"]},bgWH:{number:!0,min:0,allowPercent:!0,enums:["auto"],multiple:!0},bgPos:{number:!0,allowPercent:!0,multiple:!0},bgRelativeTo:{enums:["inner","include-padding"],multiple:!0},bgRepeat:{enums:["repeat","repeat-x","repeat-y","no-repeat"],multiple:!0},bgFit:{enums:["none","contain","cover"],multiple:!0},bgCrossOrigin:{enums:["anonymous","use-credentials","null"],multiple:!0},bgClip:{enums:["none","node"],multiple:!0},bgContainment:{enums:["inside","over"],multiple:!0},boxSelection:{enums:["contain","overlap","none"]},color:{color:!0},colors:{color:!0,multiple:!0},fill:{enums:["solid","linear-gradient","radial-gradient"]},bool:{enums:["yes","no"]},bools:{enums:["yes","no"],multiple:!0},lineStyle:{enums:["solid","dotted","dashed"]},lineCap:{enums:["butt","round","square"]},linePosition:{enums:["center","inside","outside"]},lineJoin:{enums:["round","bevel","miter"]},borderStyle:{enums:["solid","dotted","dashed","double"]},curveStyle:{enums:["bezier","unbundled-bezier","haystack","segments","straight","straight-triangle","taxi","round-segments","round-taxi"]},radiusType:{enums:["arc-radius","influence-radius"],multiple:!0},fontFamily:{regex:'^([\\w- \\"]+(?:\\s*,\\s*[\\w- \\"]+)*)$'},fontStyle:{enums:["italic","normal","oblique"]},fontWeight:{enums:["normal","bold","bolder","lighter","100","200","300","400","500","600","800","900",100,200,300,400,500,600,700,800,900]},textDecoration:{enums:["none","underline","overline","line-through"]},textTransform:{enums:["none","uppercase","lowercase"]},textWrap:{enums:["none","wrap","ellipsis"]},textOverflowWrap:{enums:["whitespace","anywhere"]},textBackgroundShape:{enums:["rectangle","roundrectangle","round-rectangle","circle"]},nodeShape:{enums:["rectangle","roundrectangle","round-rectangle","cutrectangle","cut-rectangle","bottomroundrectangle","bottom-round-rectangle","barrel","ellipse","triangle","round-triangle","square","pentagon","round-pentagon","hexagon","round-hexagon","concavehexagon","concave-hexagon","heptagon","round-heptagon","octagon","round-octagon","tag","round-tag","star","diamond","round-diamond","vee","rhomboid","right-rhomboid","polygon"]},overlayShape:{enums:["roundrectangle","round-rectangle","ellipse"]},cornerRadius:{number:!0,min:0,units:"px|em",implicitUnits:"px",enums:["auto"]},compoundIncludeLabels:{enums:["include","exclude"]},arrowShape:{enums:["tee","triangle","triangle-tee","circle-triangle","triangle-cross","triangle-backcurve","vee","square","circle","diamond","chevron","none"]},arrowFill:{enums:["filled","hollow"]},arrowWidth:{number:!0,units:"%|px|em",implicitUnits:"px",enums:["match-line"]},display:{enums:["element","none"]},visibility:{enums:["hidden","visible"]},zCompoundDepth:{enums:["bottom","orphan","auto","top"]},zIndexCompare:{enums:["auto","manual"]},valign:{enums:["top","center","bottom"]},halign:{enums:["left","center","right"]},justification:{enums:["left","center","right","auto"]},text:{string:!0},data:{mapping:!0,regex:i("data")},layoutData:{mapping:!0,regex:i("layoutData")},scratch:{mapping:!0,regex:i("scratch")},mapData:{mapping:!0,regex:o("mapData")},mapLayoutData:{mapping:!0,regex:o("mapLayoutData")},mapScratch:{mapping:!0,regex:o("mapScratch")},fn:{mapping:!0,fn:!0},url:{regexes:s,singleRegexMatchValue:!0},urls:{regexes:s,singleRegexMatchValue:!0,multiple:!0},propList:{propList:!0},angle:{number:!0,units:"deg|rad",implicitUnits:"rad"},textRotation:{number:!0,units:"deg|rad",implicitUnits:"rad",enums:["none","autorotate"]},polygonPointList:{number:!0,multiple:!0,evenMultiple:!0,min:-1,max:1,unitless:!0},edgeDistances:{enums:["intersection","node-position","endpoints"]},edgeEndpoint:{number:!0,multiple:!0,units:"%|px|em|deg|rad",implicitUnits:"px",enums:["inside-to-node","outside-to-node","outside-to-node-or-label","outside-to-line","outside-to-line-or-label"],singleEnum:!0,validate:function(Q,ie){switch(Q.length){case 2:return ie[0]!=="deg"&&ie[0]!=="rad"&&ie[1]!=="deg"&&ie[1]!=="rad";case 1:return Ye(Q[0])||ie[0]==="deg"||ie[0]==="rad";default:return!1}}},easing:{regexes:["^(spring)\\s*\\(\\s*("+r+")\\s*,\\s*("+r+")\\s*\\)$","^(cubic-bezier)\\s*\\(\\s*("+r+")\\s*,\\s*("+r+")\\s*,\\s*("+r+")\\s*,\\s*("+r+")\\s*\\)$"],enums:["linear","ease","ease-in","ease-out","ease-in-out","ease-in-sine","ease-out-sine","ease-in-out-sine","ease-in-quad","ease-out-quad","ease-in-out-quad","ease-in-cubic","ease-out-cubic","ease-in-out-cubic","ease-in-quart","ease-out-quart","ease-in-out-quart","ease-in-quint","ease-out-quint","ease-in-out-quint","ease-in-expo","ease-out-expo","ease-in-out-expo","ease-in-circ","ease-out-circ","ease-in-out-circ"]},gradientDirection:{enums:["to-bottom","to-top","to-left","to-right","to-bottom-right","to-bottom-left","to-top-right","to-top-left","to-right-bottom","to-left-bottom","to-right-top","to-left-top"]},boundsExpansion:{number:!0,multiple:!0,min:0,validate:function(Q){var ie=Q.length;return ie===1||ie===2||ie===4}}};var u={zeroNonZero:function(Q,ie){return(Q==null||ie==null)&&Q!==ie||Q==0&&ie!=0?!0:Q!=0&&ie==0},any:function(Q,ie){return Q!=ie},emptyNonEmpty:function(Q,ie){var de=Da(Q),we=Da(ie);return de&&!we||!de&&we}},l=Yr.types,f=[{name:"label",type:l.text,triggersBounds:u.any,triggersZOrder:u.emptyNonEmpty},{name:"text-rotation",type:l.textRotation,triggersBounds:u.any},{name:"text-margin-x",type:l.bidirectionalSize,triggersBounds:u.any},{name:"text-margin-y",type:l.bidirectionalSize,triggersBounds:u.any}],d=[{name:"source-label",type:l.text,triggersBounds:u.any},{name:"source-text-rotation",type:l.textRotation,triggersBounds:u.any},{name:"source-text-margin-x",type:l.bidirectionalSize,triggersBounds:u.any},{name:"source-text-margin-y",type:l.bidirectionalSize,triggersBounds:u.any},{name:"source-text-offset",type:l.size,triggersBounds:u.any}],h=[{name:"target-label",type:l.text,triggersBounds:u.any},{name:"target-text-rotation",type:l.textRotation,triggersBounds:u.any},{name:"target-text-margin-x",type:l.bidirectionalSize,triggersBounds:u.any},{name:"target-text-margin-y",type:l.bidirectionalSize,triggersBounds:u.any},{name:"target-text-offset",type:l.size,triggersBounds:u.any}],g=[{name:"font-family",type:l.fontFamily,triggersBounds:u.any},{name:"font-style",type:l.fontStyle,triggersBounds:u.any},{name:"font-weight",type:l.fontWeight,triggersBounds:u.any},{name:"font-size",type:l.size,triggersBounds:u.any},{name:"text-transform",type:l.textTransform,triggersBounds:u.any},{name:"text-wrap",type:l.textWrap,triggersBounds:u.any},{name:"text-overflow-wrap",type:l.textOverflowWrap,triggersBounds:u.any},{name:"text-max-width",type:l.size,triggersBounds:u.any},{name:"text-outline-width",type:l.size,triggersBounds:u.any},{name:"line-height",type:l.positiveNumber,triggersBounds:u.any}],p=[{name:"text-valign",type:l.valign,triggersBounds:u.any},{name:"text-halign",type:l.halign,triggersBounds:u.any},{name:"color",type:l.color},{name:"text-outline-color",type:l.color},{name:"text-outline-opacity",type:l.zeroOneNumber},{name:"text-background-color",type:l.color},{name:"text-background-opacity",type:l.zeroOneNumber},{name:"text-background-padding",type:l.size,triggersBounds:u.any},{name:"text-border-opacity",type:l.zeroOneNumber},{name:"text-border-color",type:l.color},{name:"text-border-width",type:l.size,triggersBounds:u.any},{name:"text-border-style",type:l.borderStyle,triggersBounds:u.any},{name:"text-background-shape",type:l.textBackgroundShape,triggersBounds:u.any},{name:"text-justification",type:l.justification},{name:"box-select-labels",type:l.bool,triggersBounds:u.any}],x=[{name:"events",type:l.bool,triggersZOrder:u.any},{name:"text-events",type:l.bool,triggersZOrder:u.any},{name:"box-selection",type:l.boxSelection,triggersZOrder:u.any}],b=[{name:"display",type:l.display,triggersZOrder:u.any,triggersBounds:u.any,triggersBoundsOfConnectedEdges:u.any,triggersBoundsOfParallelEdges:function(Q,ie,de){return Q===ie?!1:de.pstyle("curve-style").value==="bezier"}},{name:"visibility",type:l.visibility,triggersZOrder:u.any},{name:"opacity",type:l.zeroOneNumber,triggersZOrder:u.zeroNonZero},{name:"text-opacity",type:l.zeroOneNumber},{name:"min-zoomed-font-size",type:l.size},{name:"z-compound-depth",type:l.zCompoundDepth,triggersZOrder:u.any},{name:"z-index-compare",type:l.zIndexCompare,triggersZOrder:u.any},{name:"z-index",type:l.number,triggersZOrder:u.any}],w=[{name:"overlay-padding",type:l.size,triggersBounds:u.any},{name:"overlay-color",type:l.color},{name:"overlay-opacity",type:l.zeroOneNumber,triggersBounds:u.zeroNonZero},{name:"overlay-shape",type:l.overlayShape,triggersBounds:u.any},{name:"overlay-corner-radius",type:l.cornerRadius}],y=[{name:"underlay-padding",type:l.size,triggersBounds:u.any},{name:"underlay-color",type:l.color},{name:"underlay-opacity",type:l.zeroOneNumber,triggersBounds:u.zeroNonZero},{name:"underlay-shape",type:l.overlayShape,triggersBounds:u.any},{name:"underlay-corner-radius",type:l.cornerRadius}],E=[{name:"transition-property",type:l.propList},{name:"transition-duration",type:l.time},{name:"transition-delay",type:l.time},{name:"transition-timing-function",type:l.easing}],C=function(Q,ie){return ie.value==="label"?-Q.poolIndex():ie.pfValue},S=[{name:"height",type:l.nodeSize,triggersBounds:u.any,hashOverride:C},{name:"width",type:l.nodeSize,triggersBounds:u.any,hashOverride:C},{name:"shape",type:l.nodeShape,triggersBounds:u.any},{name:"shape-polygon-points",type:l.polygonPointList,triggersBounds:u.any},{name:"corner-radius",type:l.cornerRadius},{name:"background-color",type:l.color},{name:"background-fill",type:l.fill},{name:"background-opacity",type:l.zeroOneNumber},{name:"background-blacken",type:l.nOneOneNumber},{name:"background-gradient-stop-colors",type:l.colors},{name:"background-gradient-stop-positions",type:l.percentages},{name:"background-gradient-direction",type:l.gradientDirection},{name:"padding",type:l.sizeMaybePercent,triggersBounds:u.any},{name:"padding-relative-to",type:l.paddingRelativeTo,triggersBounds:u.any},{name:"bounds-expansion",type:l.boundsExpansion,triggersBounds:u.any}],R=[{name:"border-color",type:l.color},{name:"border-opacity",type:l.zeroOneNumber},{name:"border-width",type:l.size,triggersBounds:u.any},{name:"border-style",type:l.borderStyle},{name:"border-cap",type:l.lineCap},{name:"border-join",type:l.lineJoin},{name:"border-dash-pattern",type:l.numbers},{name:"border-dash-offset",type:l.number},{name:"border-position",type:l.linePosition}],_=[{name:"outline-color",type:l.color},{name:"outline-opacity",type:l.zeroOneNumber},{name:"outline-width",type:l.size,triggersBounds:u.any},{name:"outline-style",type:l.borderStyle},{name:"outline-offset",type:l.size,triggersBounds:u.any}],A=[{name:"background-image",type:l.urls},{name:"background-image-crossorigin",type:l.bgCrossOrigin},{name:"background-image-opacity",type:l.zeroOneNumbers},{name:"background-image-containment",type:l.bgContainment},{name:"background-image-smoothing",type:l.bools},{name:"background-position-x",type:l.bgPos},{name:"background-position-y",type:l.bgPos},{name:"background-width-relative-to",type:l.bgRelativeTo},{name:"background-height-relative-to",type:l.bgRelativeTo},{name:"background-repeat",type:l.bgRepeat},{name:"background-fit",type:l.bgFit},{name:"background-clip",type:l.bgClip},{name:"background-width",type:l.bgWH},{name:"background-height",type:l.bgWH},{name:"background-offset-x",type:l.bgPos},{name:"background-offset-y",type:l.bgPos}],P=[{name:"position",type:l.position,triggersBounds:u.any},{name:"compound-sizing-wrt-labels",type:l.compoundIncludeLabels,triggersBounds:u.any},{name:"min-width",type:l.size,triggersBounds:u.any},{name:"min-width-bias-left",type:l.sizeMaybePercent,triggersBounds:u.any},{name:"min-width-bias-right",type:l.sizeMaybePercent,triggersBounds:u.any},{name:"min-height",type:l.size,triggersBounds:u.any},{name:"min-height-bias-top",type:l.sizeMaybePercent,triggersBounds:u.any},{name:"min-height-bias-bottom",type:l.sizeMaybePercent,triggersBounds:u.any}],I=[{name:"line-style",type:l.lineStyle},{name:"line-color",type:l.color},{name:"line-fill",type:l.fill},{name:"line-cap",type:l.lineCap},{name:"line-opacity",type:l.zeroOneNumber},{name:"line-dash-pattern",type:l.numbers},{name:"line-dash-offset",type:l.number},{name:"line-outline-width",type:l.size},{name:"line-outline-color",type:l.color},{name:"line-gradient-stop-colors",type:l.colors},{name:"line-gradient-stop-positions",type:l.percentages},{name:"curve-style",type:l.curveStyle,triggersBounds:u.any,triggersBoundsOfParallelEdges:function(Q,ie){return Q===ie?!1:Q==="bezier"||ie==="bezier"}},{name:"haystack-radius",type:l.zeroOneNumber,triggersBounds:u.any},{name:"source-endpoint",type:l.edgeEndpoint,triggersBounds:u.any},{name:"target-endpoint",type:l.edgeEndpoint,triggersBounds:u.any},{name:"control-point-step-size",type:l.size,triggersBounds:u.any},{name:"control-point-distances",type:l.bidirectionalSizes,triggersBounds:u.any},{name:"control-point-weights",type:l.numbers,triggersBounds:u.any},{name:"segment-distances",type:l.bidirectionalSizes,triggersBounds:u.any},{name:"segment-weights",type:l.numbers,triggersBounds:u.any},{name:"segment-radii",type:l.numbers,triggersBounds:u.any},{name:"radius-type",type:l.radiusType,triggersBounds:u.any},{name:"taxi-turn",type:l.bidirectionalSizeMaybePercent,triggersBounds:u.any},{name:"taxi-turn-min-distance",type:l.size,triggersBounds:u.any},{name:"taxi-direction",type:l.axisDirection,triggersBounds:u.any},{name:"taxi-radius",type:l.number,triggersBounds:u.any},{name:"edge-distances",type:l.edgeDistances,triggersBounds:u.any},{name:"arrow-scale",type:l.positiveNumber,triggersBounds:u.any},{name:"loop-direction",type:l.angle,triggersBounds:u.any},{name:"loop-sweep",type:l.angle,triggersBounds:u.any},{name:"source-distance-from-node",type:l.size,triggersBounds:u.any},{name:"target-distance-from-node",type:l.size,triggersBounds:u.any}],D=[{name:"ghost",type:l.bool,triggersBounds:u.any},{name:"ghost-offset-x",type:l.bidirectionalSize,triggersBounds:u.any},{name:"ghost-offset-y",type:l.bidirectionalSize,triggersBounds:u.any},{name:"ghost-opacity",type:l.zeroOneNumber}],L=[{name:"selection-box-color",type:l.color},{name:"selection-box-opacity",type:l.zeroOneNumber},{name:"selection-box-border-color",type:l.color},{name:"selection-box-border-width",type:l.size},{name:"active-bg-color",type:l.color},{name:"active-bg-opacity",type:l.zeroOneNumber},{name:"active-bg-size",type:l.size},{name:"outside-texture-bg-color",type:l.color},{name:"outside-texture-bg-opacity",type:l.zeroOneNumber}],M=[];Yr.pieBackgroundN=16,M.push({name:"pie-size",type:l.sizeMaybePercent}),M.push({name:"pie-hole",type:l.sizeMaybePercent}),M.push({name:"pie-start-angle",type:l.angle});for(var q=1;q<=Yr.pieBackgroundN;q++)M.push({name:"pie-"+q+"-background-color",type:l.color}),M.push({name:"pie-"+q+"-background-size",type:l.percent}),M.push({name:"pie-"+q+"-background-opacity",type:l.zeroOneNumber});var N=[];Yr.stripeBackgroundN=16,N.push({name:"stripe-size",type:l.sizeMaybePercent}),N.push({name:"stripe-direction",type:l.axisDirectionPrimary});for(var W=1;W<=Yr.stripeBackgroundN;W++)N.push({name:"stripe-"+W+"-background-color",type:l.color}),N.push({name:"stripe-"+W+"-background-size",type:l.percent}),N.push({name:"stripe-"+W+"-background-opacity",type:l.zeroOneNumber});var V=[],$=Yr.arrowPrefixes=["source","mid-source","target","mid-target"];[{name:"arrow-shape",type:l.arrowShape,triggersBounds:u.any},{name:"arrow-color",type:l.color},{name:"arrow-fill",type:l.arrowFill},{name:"arrow-width",type:l.arrowWidth}].forEach(function(X){$.forEach(function(Q){var ie=Q+"-"+X.name,de=X.type,we=X.triggersBounds;V.push({name:ie,type:de,triggersBounds:we})})},{});var Z=Yr.properties=[].concat(x,E,b,w,y,D,p,g,f,d,h,S,R,_,A,M,N,P,I,V,L),ee=Yr.propertyGroups={behavior:x,transition:E,visibility:b,overlay:w,underlay:y,ghost:D,commonLabel:p,labelDimensions:g,mainLabel:f,sourceLabel:d,targetLabel:h,nodeBody:S,nodeBorder:R,nodeOutline:_,backgroundImage:A,pie:M,stripe:N,compound:P,edgeLine:I,edgeArrow:V,core:L},K=Yr.propertyGroupNames={},j=Yr.propertyGroupKeys=Object.keys(ee);j.forEach(function(X){K[X]=ee[X].map(function(Q){return Q.name}),ee[X].forEach(function(Q){return Q.groupKey=X})});var fe=Yr.aliases=[{name:"content",pointsTo:"label"},{name:"control-point-distance",pointsTo:"control-point-distances"},{name:"control-point-weight",pointsTo:"control-point-weights"},{name:"segment-distance",pointsTo:"segment-distances"},{name:"segment-weight",pointsTo:"segment-weights"},{name:"segment-radius",pointsTo:"segment-radii"},{name:"edge-text-rotation",pointsTo:"text-rotation"},{name:"padding-left",pointsTo:"padding"},{name:"padding-right",pointsTo:"padding"},{name:"padding-top",pointsTo:"padding"},{name:"padding-bottom",pointsTo:"padding"}];Yr.propertyNames=Z.map(function(X){return X.name});for(var G=0;G<Z.length;G++){var z=Z[G];Z[z.name]=z}for(var Y=0;Y<fe.length;Y++){var te=fe[Y],ue=Z[te.pointsTo],oe={name:te.name,alias:!0,pointsTo:ue};Z.push(oe),Z[te.name]=oe}})();Yr.getDefaultProperty=function(r){return this.getDefaultProperties()[r]};Yr.getDefaultProperties=function(){var r=this._private;if(r.defaultProperties!=null)return r.defaultProperties;for(var e=Xe({"selection-box-color":"#ddd","selection-box-opacity":.65,"selection-box-border-color":"#aaa","selection-box-border-width":1,"active-bg-color":"black","active-bg-opacity":.15,"active-bg-size":30,"outside-texture-bg-color":"#000","outside-texture-bg-opacity":.125,events:"yes","text-events":"no","text-valign":"top","text-halign":"center","text-justification":"auto","line-height":1,color:"#000","box-selection":"contain","text-outline-color":"#000","text-outline-width":0,"text-outline-opacity":1,"text-opacity":1,"text-decoration":"none","text-transform":"none","text-wrap":"none","text-overflow-wrap":"whitespace","text-max-width":9999,"text-background-color":"#000","text-background-opacity":0,"text-background-shape":"rectangle","text-background-padding":0,"text-border-opacity":0,"text-border-width":0,"text-border-style":"solid","text-border-color":"#000","font-family":"Helvetica Neue, Helvetica, sans-serif","font-style":"normal","font-weight":"normal","font-size":16,"min-zoomed-font-size":0,"text-rotation":"none","source-text-rotation":"none","target-text-rotation":"none",visibility:"visible",display:"element",opacity:1,"z-compound-depth":"auto","z-index-compare":"auto","z-index":0,label:"","text-margin-x":0,"text-margin-y":0,"source-label":"","source-text-offset":0,"source-text-margin-x":0,"source-text-margin-y":0,"target-label":"","target-text-offset":0,"target-text-margin-x":0,"target-text-margin-y":0,"overlay-opacity":0,"overlay-color":"#000","overlay-padding":10,"overlay-shape":"round-rectangle","overlay-corner-radius":"auto","underlay-opacity":0,"underlay-color":"#000","underlay-padding":10,"underlay-shape":"round-rectangle","underlay-corner-radius":"auto","transition-property":"none","transition-duration":0,"transition-delay":0,"transition-timing-function":"linear","box-select-labels":"no","background-blacken":0,"background-color":"#999","background-fill":"solid","background-opacity":1,"background-image":"none","background-image-crossorigin":"anonymous","background-image-opacity":1,"background-image-containment":"inside","background-image-smoothing":"yes","background-position-x":"50%","background-position-y":"50%","background-offset-x":0,"background-offset-y":0,"background-width-relative-to":"include-padding","background-height-relative-to":"include-padding","background-repeat":"no-repeat","background-fit":"none","background-clip":"node","background-width":"auto","background-height":"auto","border-color":"#000","border-opacity":1,"border-width":0,"border-style":"solid","border-dash-pattern":[4,2],"border-dash-offset":0,"border-cap":"butt","border-join":"miter","border-position":"center","outline-color":"#999","outline-opacity":1,"outline-width":0,"outline-offset":0,"outline-style":"solid",height:30,width:30,shape:"ellipse","shape-polygon-points":"-1, -1, 1, -1, 1, 1, -1, 1","corner-radius":"auto","bounds-expansion":0,"background-gradient-direction":"to-bottom","background-gradient-stop-colors":"#999","background-gradient-stop-positions":"0%",ghost:"no","ghost-offset-y":0,"ghost-offset-x":0,"ghost-opacity":0,padding:0,"padding-relative-to":"width",position:"origin","compound-sizing-wrt-labels":"include","min-width":0,"min-width-bias-left":0,"min-width-bias-right":0,"min-height":0,"min-height-bias-top":0,"min-height-bias-bottom":0},{"pie-size":"100%","pie-hole":0,"pie-start-angle":"0deg"},[{name:"pie-{{i}}-background-color",value:"black"},{name:"pie-{{i}}-background-size",value:"0%"},{name:"pie-{{i}}-background-opacity",value:1}].reduce(function(u,l){for(var f=1;f<=Yr.pieBackgroundN;f++){var d=l.name.replace("{{i}}",f),h=l.value;u[d]=h}return u},{}),{"stripe-size":"100%","stripe-direction":"horizontal"},[{name:"stripe-{{i}}-background-color",value:"black"},{name:"stripe-{{i}}-background-size",value:"0%"},{name:"stripe-{{i}}-background-opacity",value:1}].reduce(function(u,l){for(var f=1;f<=Yr.stripeBackgroundN;f++){var d=l.name.replace("{{i}}",f),h=l.value;u[d]=h}return u},{}),{"line-style":"solid","line-color":"#999","line-fill":"solid","line-cap":"butt","line-opacity":1,"line-outline-width":0,"line-outline-color":"#000","line-gradient-stop-colors":"#999","line-gradient-stop-positions":"0%","control-point-step-size":40,"control-point-weights":.5,"segment-weights":.5,"segment-distances":20,"segment-radii":15,"radius-type":"arc-radius","taxi-turn":"50%","taxi-radius":15,"taxi-turn-min-distance":10,"taxi-direction":"auto","edge-distances":"intersection","curve-style":"haystack","haystack-radius":0,"arrow-scale":1,"loop-direction":"-45deg","loop-sweep":"-90deg","source-distance-from-node":0,"target-distance-from-node":0,"source-endpoint":"outside-to-node","target-endpoint":"outside-to-node","line-dash-pattern":[6,3],"line-dash-offset":0},[{name:"arrow-shape",value:"none"},{name:"arrow-color",value:"#999"},{name:"arrow-fill",value:"filled"},{name:"arrow-width",value:1}].reduce(function(u,l){return Yr.arrowPrefixes.forEach(function(f){var d=f+"-"+l.name,h=l.value;u[d]=h}),u},{})),t={},n=0;n<this.properties.length;n++){var a=this.properties[n];if(!a.pointsTo){var i=a.name,o=e[i],s=this.parse(i,o);t[i]=s}}return r.defaultProperties=t,r.defaultProperties};Yr.addDefaultStylesheet=function(){this.selector(":parent").css({shape:"rectangle",padding:10,"background-color":"#eee","border-color":"#ccc","border-width":1}).selector("edge").css({width:3}).selector(":loop").css({"curve-style":"bezier"}).selector("edge:compound").css({"curve-style":"bezier","source-endpoint":"outside-to-line","target-endpoint":"outside-to-line"}).selector(":selected").css({"background-color":"#0169D9","line-color":"#0169D9","source-arrow-color":"#0169D9","target-arrow-color":"#0169D9","mid-source-arrow-color":"#0169D9","mid-target-arrow-color":"#0169D9"}).selector(":parent:selected").css({"background-color":"#CCE1F9","border-color":"#aec8e5"}).selector(":active").css({"overlay-color":"black","overlay-padding":10,"overlay-opacity":.25}),this.defaultLength=this.length};var Ml={};Ml.parse=function(r,e,t,n){var a=this;if($r(e))return a.parseImplWarn(r,e,t,n);var i=n==="mapping"||n===!0||n===!1||n==null?"dontcare":n,o=t?"t":"f",s=""+e,u=U2(r,s,o,i),l=a.propCache=a.propCache||[],f;return(f=l[u])||(f=l[u]=a.parseImplWarn(r,e,t,n)),(t||n==="mapping")&&(f=Nn(f),f&&(f.value=Nn(f.value))),f};Ml.parseImplWarn=function(r,e,t,n){var a=this.parseImpl(r,e,t,n);return!a&&e!=null&&Cr("The style property `".concat(r,": ").concat(e,"` is invalid")),a&&(a.name==="width"||a.name==="height")&&e==="label"&&Cr("The style value of `label` is deprecated for `"+a.name+"`"),a};Ml.parseImpl=function(r,e,t,n){var a=this;r=Km(r);var i=a.properties[r],o=e,s=a.types;if(!i||e===void 0)return null;i.alias&&(i=i.pointsTo,r=i.name);var u=Ye(e);u&&(e=e.trim());var l=i.type;if(!l)return null;if(t&&(e===""||e===null))return{name:r,value:e,bypass:!0,deleteBypass:!0};if($r(e))return{name:r,value:e,strValue:"fn",mapped:s.fn,bypass:t};var f,d;if(!(!u||n||e.length<7||e[1]!=="a")){if(e.length>=7&&e[0]==="d"&&(f=new RegExp(s.data.regex).exec(e))){if(t)return!1;var h=s.data;return{name:r,value:f,strValue:""+e,mapped:h,field:f[1],bypass:t}}else if(e.length>=10&&e[0]==="m"&&(d=new RegExp(s.mapData.regex).exec(e))){if(t||l.multiple)return!1;var g=s.mapData;if(!(l.color||l.number))return!1;var p=this.parse(r,d[4]);if(!p||p.mapped)return!1;var x=this.parse(r,d[5]);if(!x||x.mapped)return!1;if(p.pfValue===x.pfValue||p.strValue===x.strValue)return Cr("`"+r+": "+e+"` is not a valid mapper because the output range is zero; converting to `"+r+": "+p.strValue+"`"),this.parse(r,p.strValue);if(l.color){var b=p.value,w=x.value,y=b[0]===w[0]&&b[1]===w[1]&&b[2]===w[2]&&(b[3]===w[3]||(b[3]==null||b[3]===1)&&(w[3]==null||w[3]===1));if(y)return!1}return{name:r,value:d,strValue:""+e,mapped:g,field:d[1],fieldMin:parseFloat(d[2]),fieldMax:parseFloat(d[3]),valueMin:p.value,valueMax:x.value,bypass:t}}}if(l.multiple&&n!=="multiple"){var E;if(u?E=e.split(/\s+/):Tr(e)?E=e:E=[e],l.evenMultiple&&E.length%2!==0)return null;for(var C=[],S=[],R=[],_="",A=!1,P=0;P<E.length;P++){var I=a.parse(r,E[P],t,"multiple");A=A||Ye(I.value),C.push(I.value),R.push(I.pfValue!=null?I.pfValue:I.value),S.push(I.units),_+=(P>0?" ":"")+I.strValue}return l.validate&&!l.validate(C,S)?null:l.singleEnum&&A?C.length===1&&Ye(C[0])?{name:r,value:C[0],strValue:C[0],bypass:t}:null:{name:r,value:C,pfValue:R,strValue:_,bypass:t,units:S}}var D=function(){for(var oe=0;oe<l.enums.length;oe++){var X=l.enums[oe];if(X===e)return{name:r,value:e,strValue:""+e,bypass:t}}return null};if(l.number){var L,M="px";if(l.units&&(L=l.units),l.implicitUnits&&(M=l.implicitUnits),!l.unitless)if(u){var q="px|em"+(l.allowPercent?"|\\%":"");L&&(q=L);var N=e.match("^("+nt+")("+q+")?$");N&&(e=N[1],L=N[2]||M)}else(!L||l.implicitUnits)&&(L=M);if(e=parseFloat(e),isNaN(e)&&l.enums===void 0)return null;if(isNaN(e)&&l.enums!==void 0)return e=o,D();if(l.integer&&!TN(e)||l.min!==void 0&&(e<l.min||l.strictMin&&e===l.min)||l.max!==void 0&&(e>l.max||l.strictMax&&e===l.max))return null;var W={name:r,value:e,strValue:""+e+(L||""),units:L,bypass:t};return l.unitless||L!=="px"&&L!=="em"?W.pfValue=e:W.pfValue=L==="px"||!L?e:this.getEmSizeInPixels()*e,(L==="ms"||L==="s")&&(W.pfValue=L==="ms"?e:1e3*e),(L==="deg"||L==="rad")&&(W.pfValue=L==="rad"?e:kF(e)),L==="%"&&(W.pfValue=e/100),W}else if(l.propList){var V=[],$=""+e;if($!=="none"){for(var Z=$.split(/\s*,\s*|\s+/),ee=0;ee<Z.length;ee++){var K=Z[ee].trim();a.properties[K]?V.push(K):Cr("`"+K+"` is not a valid property name")}if(V.length===0)return null}return{name:r,value:V,strValue:V.length===0?"none":V.join(" "),bypass:t}}else if(l.color){var j=N2(e);return j?{name:r,value:j,pfValue:j,strValue:"rgb("+j[0]+","+j[1]+","+j[2]+")",bypass:t}:null}else if(l.regex||l.regexes){if(l.enums){var fe=D();if(fe)return fe}for(var G=l.regexes?l.regexes:[l.regex],z=0;z<G.length;z++){var Y=new RegExp(G[z]),te=Y.exec(e);if(te)return{name:r,value:l.singleRegexMatchValue?te[1]:te,strValue:""+e,bypass:t}}return null}else return l.string?{name:r,value:""+e,strValue:""+e,bypass:t}:l.enums?D():null};var lt=function(e){if(!(this instanceof lt))return new lt(e);if(!Hm(e)){kr("A style must have a core reference");return}this._private={cy:e,coreStyle:{}},this.length=0,this.resetToDefault()},Rt=lt.prototype;Rt.instanceString=function(){return"style"};Rt.clear=function(){for(var r=this._private,e=r.cy,t=e.elements(),n=0;n<this.length;n++)this[n]=void 0;return this.length=0,r.contextStyles={},r.propDiffs={},this.cleanElements(t,!0),t.forEach(function(a){var i=a[0]._private;i.styleDirty=!0,i.appliedInitStyle=!1}),this};Rt.resetToDefault=function(){return this.clear(),this.addDefaultStylesheet(),this};Rt.core=function(r){return this._private.coreStyle[r]||this.getDefaultProperty(r)};Rt.selector=function(r){var e=r==="core"?null:new La(r),t=this.length++;return this[t]={selector:e,properties:[],mappedProperties:[],index:t},this};Rt.css=function(){var r=this,e=arguments;if(e.length===1)for(var t=e[0],n=0;n<r.properties.length;n++){var a=r.properties[n],i=t[a.name];i===void 0&&(i=t[bl(a.name)]),i!==void 0&&this.cssRule(a.name,i)}else e.length===2&&this.cssRule(e[0],e[1]);return this};Rt.style=Rt.css;Rt.cssRule=function(r,e){var t=this.parse(r,e);if(t){var n=this.length-1;this[n].properties.push(t),this[n].properties[t.name]=t,t.name.match(/pie-(\d+)-background-size/)&&t.value&&(this._private.hasPie=!0),t.name.match(/stripe-(\d+)-background-size/)&&t.value&&(this._private.hasStripe=!0),t.mapped&&this[n].mappedProperties.push(t);var a=!this[n].selector;a&&(this._private.coreStyle[t.name]=t)}return this};Rt.append=function(r){return O2(r)?r.appendToStyle(this):Tr(r)?this.appendFromJson(r):Ye(r)&&this.appendFromString(r),this};lt.fromJson=function(r,e){var t=new lt(r);return t.fromJson(e),t};lt.fromString=function(r,e){return new lt(r).fromString(e)};[ft,As,u0,Fn,Bl,l0,Yr,Ml].forEach(function(r){Xe(Rt,r)});lt.types=Rt.types;lt.properties=Rt.properties;lt.propertyGroups=Rt.propertyGroups;lt.propertyGroupNames=Rt.propertyGroupNames;lt.propertyGroupKeys=Rt.propertyGroupKeys;var z$={style:function(e){if(e){var t=this.setStyle(e);t.update()}return this._private.style},setStyle:function(e){var t=this._private;return O2(e)?t.style=e.generateStyle(this):Tr(e)?t.style=lt.fromJson(this,e):Ye(e)?t.style=lt.fromString(this,e):t.style=lt(this),t.style},updateStyle:function(){this.mutableElements().updateStyle()}},$$="single",hi={autolock:function(e){if(e!==void 0)this._private.autolock=!!e;else return this._private.autolock;return this},autoungrabify:function(e){if(e!==void 0)this._private.autoungrabify=!!e;else return this._private.autoungrabify;return this},autounselectify:function(e){if(e!==void 0)this._private.autounselectify=!!e;else return this._private.autounselectify;return this},selectionType:function(e){var t=this._private;if(t.selectionType==null&&(t.selectionType=$$),e!==void 0)(e==="additive"||e==="single")&&(t.selectionType=e);else return t.selectionType;return this},panningEnabled:function(e){if(e!==void 0)this._private.panningEnabled=!!e;else return this._private.panningEnabled;return this},userPanningEnabled:function(e){if(e!==void 0)this._private.userPanningEnabled=!!e;else return this._private.userPanningEnabled;return this},zoomingEnabled:function(e){if(e!==void 0)this._private.zoomingEnabled=!!e;else return this._private.zoomingEnabled;return this},userZoomingEnabled:function(e){if(e!==void 0)this._private.userZoomingEnabled=!!e;else return this._private.userZoomingEnabled;return this},boxSelectionEnabled:function(e){if(e!==void 0)this._private.boxSelectionEnabled=!!e;else return this._private.boxSelectionEnabled;return this},pan:function(){var e=arguments,t=this._private.pan,n,a,i,o,s;switch(e.length){case 0:return t;case 1:if(Ye(e[0]))return n=e[0],t[n];if(yr(e[0])){if(!this._private.panningEnabled)return this;i=e[0],o=i.x,s=i.y,qe(o)&&(t.x=o),qe(s)&&(t.y=s),this.emit("pan viewport")}break;case 2:if(!this._private.panningEnabled)return this;n=e[0],a=e[1],(n==="x"||n==="y")&&qe(a)&&(t[n]=a),this.emit("pan viewport");break}return this.notify("viewport"),this},panBy:function(e,t){var n=arguments,a=this._private.pan,i,o,s,u,l;if(!this._private.panningEnabled)return this;switch(n.length){case 1:yr(e)&&(s=n[0],u=s.x,l=s.y,qe(u)&&(a.x+=u),qe(l)&&(a.y+=l),this.emit("pan viewport"));break;case 2:i=e,o=t,(i==="x"||i==="y")&&qe(o)&&(a[i]+=o),this.emit("pan viewport");break}return this.notify("viewport"),this},gc:function(){this.notify("gc")},fit:function(e,t){var n=this.getFitViewport(e,t);if(n){var a=this._private;a.zoom=n.zoom,a.pan=n.pan,this.emit("pan zoom viewport"),this.notify("viewport")}return this},getFitViewport:function(e,t){if(qe(e)&&t===void 0&&(t=e,e=void 0),!(!this._private.panningEnabled||!this._private.zoomingEnabled)){var n;if(Ye(e)){var a=e;e=this.$(a)}else if(PN(e)){var i=e;n={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2},n.w=n.x2-n.x1,n.h=n.y2-n.y1}else Jt(e)||(e=this.mutableElements());if(!(Jt(e)&&e.empty())){n=n||e.boundingBox();var o=this.width(),s=this.height(),u;if(t=qe(t)?t:0,!isNaN(o)&&!isNaN(s)&&o>0&&s>0&&!isNaN(n.w)&&!isNaN(n.h)&&n.w>0&&n.h>0){u=Math.min((o-2*t)/n.w,(s-2*t)/n.h),u=u>this._private.maxZoom?this._private.maxZoom:u,u=u<this._private.minZoom?this._private.minZoom:u;var l={x:(o-u*(n.x1+n.x2))/2,y:(s-u*(n.y1+n.y2))/2};return{zoom:u,pan:l}}}}},zoomRange:function(e,t){var n=this._private;if(t==null){var a=e;e=a.min,t=a.max}return qe(e)&&qe(t)&&e<=t?(n.minZoom=e,n.maxZoom=t):qe(e)&&t===void 0&&e<=n.maxZoom?n.minZoom=e:qe(t)&&e===void 0&&t>=n.minZoom&&(n.maxZoom=t),this},minZoom:function(e){return e===void 0?this._private.minZoom:this.zoomRange({min:e})},maxZoom:function(e){return e===void 0?this._private.maxZoom:this.zoomRange({max:e})},getZoomedViewport:function(e){var t=this._private,n=t.pan,a=t.zoom,i,o,s=!1;if(t.zoomingEnabled||(s=!0),qe(e)?o=e:yr(e)&&(o=e.level,e.position!=null?i=El(e.position,a,n):e.renderedPosition!=null&&(i=e.renderedPosition),i!=null&&!t.panningEnabled&&(s=!0)),o=o>t.maxZoom?t.maxZoom:o,o=o<t.minZoom?t.minZoom:o,s||!qe(o)||o===a||i!=null&&(!qe(i.x)||!qe(i.y)))return null;if(i!=null){var u=n,l=a,f=o,d={x:-f/l*(i.x-u.x)+i.x,y:-f/l*(i.y-u.y)+i.y};return{zoomed:!0,panned:!0,zoom:f,pan:d}}else return{zoomed:!0,panned:!1,zoom:o,pan:n}},zoom:function(e){if(e===void 0)return this._private.zoom;var t=this.getZoomedViewport(e),n=this._private;return t==null||!t.zoomed?this:(n.zoom=t.zoom,t.panned&&(n.pan.x=t.pan.x,n.pan.y=t.pan.y),this.emit("zoom"+(t.panned?" pan":"")+" viewport"),this.notify("viewport"),this)},viewport:function(e){var t=this._private,n=!0,a=!0,i=[],o=!1,s=!1;if(!e)return this;if(qe(e.zoom)||(n=!1),yr(e.pan)||(a=!1),!n&&!a)return this;if(n){var u=e.zoom;u<t.minZoom||u>t.maxZoom||!t.zoomingEnabled?o=!0:(t.zoom=u,i.push("zoom"))}if(a&&(!o||!e.cancelOnFailedZoom)&&t.panningEnabled){var l=e.pan;qe(l.x)&&(t.pan.x=l.x,s=!1),qe(l.y)&&(t.pan.y=l.y,s=!1),s||i.push("pan")}return i.length>0&&(i.push("viewport"),this.emit(i.join(" ")),this.notify("viewport")),this},center:function(e){var t=this.getCenterPan(e);return t&&(this._private.pan=t,this.emit("pan viewport"),this.notify("viewport")),this},getCenterPan:function(e,t){if(this._private.panningEnabled){if(Ye(e)){var n=e;e=this.mutableElements().filter(n)}else Jt(e)||(e=this.mutableElements());if(e.length!==0){var a=e.boundingBox(),i=this.width(),o=this.height();t=t===void 0?this._private.zoom:t;var s={x:(i-t*(a.x1+a.x2))/2,y:(o-t*(a.y1+a.y2))/2};return s}}},reset:function(){return!this._private.panningEnabled||!this._private.zoomingEnabled?this:(this.viewport({pan:{x:0,y:0},zoom:1}),this)},invalidateSize:function(){this._private.sizeCache=null},size:function(){var e=this._private,t=e.container,n=this;return e.sizeCache=e.sizeCache||(t?(function(){var a=n.window().getComputedStyle(t),i=function(s){return parseFloat(a.getPropertyValue(s))};return{width:t.clientWidth-i("padding-left")-i("padding-right"),height:t.clientHeight-i("padding-top")-i("padding-bottom")}})():{width:1,height:1})},width:function(){return this.size().width},height:function(){return this.size().height},extent:function(){var e=this._private.pan,t=this._private.zoom,n=this.renderedExtent(),a={x1:(n.x1-e.x)/t,x2:(n.x2-e.x)/t,y1:(n.y1-e.y)/t,y2:(n.y2-e.y)/t};return a.w=a.x2-a.x1,a.h=a.y2-a.y1,a},renderedExtent:function(){var e=this.width(),t=this.height();return{x1:0,y1:0,x2:e,y2:t,w:e,h:t}},multiClickDebounceTime:function(e){if(e)this._private.multiClickDebounceTime=e;else return this._private.multiClickDebounceTime;return this}};hi.centre=hi.center;hi.autolockNodes=hi.autolock;hi.autoungrabifyNodes=hi.autoungrabify;var ps={data:Er.data({field:"data",bindingEvent:"data",allowBinding:!0,allowSetting:!0,settingEvent:"data",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeData:Er.removeData({field:"data",event:"data",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0}),scratch:Er.data({field:"scratch",bindingEvent:"scratch",allowBinding:!0,allowSetting:!0,settingEvent:"scratch",settingTriggersEvent:!0,triggerFnName:"trigger",allowGetting:!0,updateStyle:!0}),removeScratch:Er.removeData({field:"scratch",event:"scratch",triggerFnName:"trigger",triggerEvent:!0,updateStyle:!0})};ps.attr=ps.data;ps.removeAttr=ps.removeData;var ys=function(e){var t=this;e=Xe({},e);var n=e.container;n&&!rl(n)&&rl(n[0])&&(n=n[0]);var a=n?n._cyreg:null;a=a||{},a&&a.cy&&(a.cy.destroy(),a={});var i=a.readies=a.readies||[];n&&(n._cyreg=a),a.cy=t;var o=tt!==void 0&&n!==void 0&&!e.headless,s=e;s.layout=Xe({name:o?"grid":"null"},s.layout),s.renderer=Xe({name:o?"canvas":"null"},s.renderer);var u=function(p,x,b){return x!==void 0?x:b!==void 0?b:p},l=this._private={container:n,ready:!1,options:s,elements:new bt(this),listeners:[],aniEles:new bt(this),data:s.data||{},scratch:{},layout:null,renderer:null,destroyed:!1,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:u(!0,s.zoomingEnabled),userZoomingEnabled:u(!0,s.userZoomingEnabled),panningEnabled:u(!0,s.panningEnabled),userPanningEnabled:u(!0,s.userPanningEnabled),boxSelectionEnabled:u(!0,s.boxSelectionEnabled),autolock:u(!1,s.autolock,s.autolockNodes),autoungrabify:u(!1,s.autoungrabify,s.autoungrabifyNodes),autounselectify:u(!1,s.autounselectify),styleEnabled:s.styleEnabled===void 0?o:s.styleEnabled,zoom:qe(s.zoom)?s.zoom:1,pan:{x:yr(s.pan)&&qe(s.pan.x)?s.pan.x:0,y:yr(s.pan)&&qe(s.pan.y)?s.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1,multiClickDebounceTime:u(250,s.multiClickDebounceTime)};this.createEmitter(),this.selectionType(s.selectionType),this.zoomRange({min:s.minZoom,max:s.maxZoom});var f=function(p,x){var b=p.some(IN);if(b)return po.all(p).then(x);x(p)};l.styleEnabled&&t.setStyle([]);var d=Xe({},s,s.renderer);t.initRenderer(d);var h=function(p,x,b){t.notifications(!1);var w=t.mutableElements();w.length>0&&w.remove(),p!=null&&(yr(p)||Tr(p))&&t.add(p),t.one("layoutready",function(E){t.notifications(!0),t.emit(E),t.one("load",x),t.emitAndNotify("load")}).one("layoutstop",function(){t.one("done",b),t.emit("done")});var y=Xe({},t._private.options.layout);y.eles=t.elements(),t.layout(y).run()};f([s.style,s.elements],function(g){var p=g[0],x=g[1];l.styleEnabled&&t.style().append(p),h(x,function(){t.startAnimationLoop(),l.ready=!0,$r(s.ready)&&t.on("ready",s.ready);for(var b=0;b<i.length;b++){var w=i[b];t.on("ready",w)}a&&(a.readies=[]),t.emit("ready")},s.done)})},ul=ys.prototype;Xe(ul,{instanceString:function(){return"core"},isReady:function(){return this._private.ready},destroyed:function(){return this._private.destroyed},ready:function(e){return this.isReady()?this.emitter().emit("ready",[],e):this.on("ready",e),this},destroy:function(){var e=this;if(!e.destroyed())return e.stopAnimationLoop(),e.destroyRenderer(),this.emit("destroy"),e._private.destroyed=!0,e},hasElementWithId:function(e){return this._private.elements.hasElementWithId(e)},getElementById:function(e){return this._private.elements.getElementById(e)},hasCompoundNodes:function(){return this._private.hasCompoundNodes},headless:function(){return this._private.renderer.isHeadless()},styleEnabled:function(){return this._private.styleEnabled},addToPool:function(e){return this._private.elements.merge(e),this},removeFromPool:function(e){return this._private.elements.unmerge(e),this},container:function(){return this._private.container||null},window:function(){var e=this._private.container;if(e==null)return tt;var t=this._private.container.ownerDocument;return t===void 0||t==null?tt:t.defaultView||tt},mount:function(e){if(e!=null){var t=this,n=t._private,a=n.options;return!rl(e)&&rl(e[0])&&(e=e[0]),t.stopAnimationLoop(),t.destroyRenderer(),n.container=e,n.styleEnabled=!0,t.invalidateSize(),t.initRenderer(Xe({},a,a.renderer,{name:a.renderer.name==="null"?"canvas":a.renderer.name})),t.startAnimationLoop(),t.style(a.style),t.emit("mount"),t}},unmount:function(){var e=this;return e.stopAnimationLoop(),e.destroyRenderer(),e.initRenderer({name:"null"}),e.emit("unmount"),e},options:function(){return Nn(this._private.options)},json:function(e){var t=this,n=t._private,a=t.mutableElements(),i=function(C){return t.getElementById(C.id())};if(yr(e)){if(t.startBatch(),e.elements){var o={},s=function(C,S){for(var R=[],_=[],A=0;A<C.length;A++){var P=C[A];if(!P.data.id){Cr("cy.json() cannot handle elements without an ID attribute");continue}var I=""+P.data.id,D=t.getElementById(I);o[I]=!0,D.length!==0?_.push({ele:D,json:P}):(S&&(P.group=S),R.push(P))}t.add(R);for(var L=0;L<_.length;L++){var M=_[L],q=M.ele,N=M.json;q.json(N)}};if(Tr(e.elements))s(e.elements);else for(var u=["nodes","edges"],l=0;l<u.length;l++){var f=u[l],d=e.elements[f];Tr(d)&&s(d,f)}var h=t.collection();a.filter(function(E){return!o[E.id()]}).forEach(function(E){E.isParent()?h.merge(E):E.remove()}),h.forEach(function(E){return E.children().move({parent:null})}),h.forEach(function(E){return i(E).remove()})}e.style&&t.style(e.style),e.zoom!=null&&e.zoom!==n.zoom&&t.zoom(e.zoom),e.pan&&(e.pan.x!==n.pan.x||e.pan.y!==n.pan.y)&&t.pan(e.pan),e.data&&t.data(e.data);for(var g=["minZoom","maxZoom","zoomingEnabled","userZoomingEnabled","panningEnabled","userPanningEnabled","boxSelectionEnabled","autolock","autoungrabify","autounselectify","multiClickDebounceTime"],p=0;p<g.length;p++){var x=g[p];e[x]!=null&&t[x](e[x])}return t.endBatch(),this}else{var b=!!e,w={};b?w.elements=this.elements().map(function(E){return E.json()}):(w.elements={},a.forEach(function(E){var C=E.group();w.elements[C]||(w.elements[C]=[]),w.elements[C].push(E.json())})),this._private.styleEnabled&&(w.style=t.style().json()),w.data=Nn(t.data());var y=n.options;return w.zoomingEnabled=n.zoomingEnabled,w.userZoomingEnabled=n.userZoomingEnabled,w.zoom=n.zoom,w.minZoom=n.minZoom,w.maxZoom=n.maxZoom,w.panningEnabled=n.panningEnabled,w.userPanningEnabled=n.userPanningEnabled,w.pan=Nn(n.pan),w.boxSelectionEnabled=n.boxSelectionEnabled,w.renderer=Nn(y.renderer),w.hideEdgesOnViewport=y.hideEdgesOnViewport,w.textureOnViewport=y.textureOnViewport,w.wheelSensitivity=y.wheelSensitivity,w.motionBlur=y.motionBlur,w.multiClickDebounceTime=y.multiClickDebounceTime,w}}});ul.$id=ul.getElementById;[I$,O$,OA,Im,Uu,q$,Dm,Hu,z$,hi,ps].forEach(function(r){Xe(ul,r)});var V$={fit:!0,directed:!1,direction:"downward",padding:30,circle:!1,grid:!1,spacingFactor:1.75,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,roots:void 0,depthSort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}},G$={maximal:!1,acyclic:!1},Hi=function(e){return e.scratch("breadthfirst")},EE=function(e,t){return e.scratch("breadthfirst",t)};function kA(r){this.options=Xe({},V$,G$,r)}kA.prototype.run=function(){var r=this.options,e=r.cy,t=r.eles,n=t.nodes().filter(function(Se){return Se.isChildless()}),a=t,i=r.directed,o=r.acyclic||r.maximal||r.maximalAdjustments>0,s=!!r.boundingBox,u=Lt(s?r.boundingBox:structuredClone(e.extent())),l;if(Jt(r.roots))l=r.roots;else if(Tr(r.roots)){for(var f=[],d=0;d<r.roots.length;d++){var h=r.roots[d],g=e.getElementById(h);f.push(g)}l=e.collection(f)}else if(Ye(r.roots))l=e.$(r.roots);else if(i)l=n.roots();else{var p=t.components();l=e.collection();for(var x=function(){var Ee=p[b],re=Ee.maxDegree(!1),ce=Ee.filter(function(_e){return _e.degree(!1)===re});l=l.add(ce)},b=0;b<p.length;b++)x()}var w=[],y={},E=function(Ee,re){w[re]==null&&(w[re]=[]);var ce=w[re].length;w[re].push(Ee),EE(Ee,{index:ce,depth:re})},C=function(Ee,re){var ce=Hi(Ee),_e=ce.depth,me=ce.index;w[_e][me]=null,Ee.isChildless()&&E(Ee,re)};a.bfs({roots:l,directed:r.directed,visit:function(Ee,re,ce,_e,me){var Te=Ee[0],De=Te.id();Te.isChildless()&&E(Te,me),y[De]=!0}});for(var S=[],R=0;R<n.length;R++){var _=n[R];y[_.id()]||S.push(_)}var A=function(Ee){for(var re=w[Ee],ce=0;ce<re.length;ce++){var _e=re[ce];if(_e==null){re.splice(ce,1),ce--;continue}EE(_e,{depth:Ee,index:ce})}},P=function(Ee,re){for(var ce=Hi(Ee),_e=Ee.incomers().filter(function(ke){return ke.isNode()&&t.has(ke)}),me=-1,Te=Ee.id(),De=0;De<_e.length;De++){var Ne=_e[De],ze=Hi(Ne);me=Math.max(me,ze.depth)}if(ce.depth<=me){if(!r.acyclic&&re[Te])return null;var $e=me+1;return C(Ee,$e),re[Te]=$e,!0}return!1};if(i&&o){var I=[],D={},L=function(Ee){return I.push(Ee)},M=function(){return I.shift()};for(n.forEach(function(Se){return I.push(Se)});I.length>0;){var q=M(),N=P(q,D);if(N)q.outgoers().filter(function(Se){return Se.isNode()&&t.has(Se)}).forEach(L);else if(N===null){Cr("Detected double maximal shift for node `"+q.id()+"`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");break}}}var W=0;if(r.avoidOverlap)for(var V=0;V<n.length;V++){var $=n[V],Z=$.layoutDimensions(r),ee=Z.w,K=Z.h;W=Math.max(W,ee,K)}var j={},fe=function(Ee){if(j[Ee.id()])return j[Ee.id()];for(var re=Hi(Ee).depth,ce=Ee.neighborhood(),_e=0,me=0,Te=0;Te<ce.length;Te++){var De=ce[Te];if(!(De.isEdge()||De.isParent()||!n.has(De))){var Ne=Hi(De);if(Ne!=null){var ze=Ne.index,$e=Ne.depth;if(!(ze==null||$e==null)){var ke=w[$e].length;$e<re&&(_e+=ze/ke,me++)}}}}return me=Math.max(1,me),_e=_e/me,me===0&&(_e=0),j[Ee.id()]=_e,_e},G=function(Ee,re){var ce=fe(Ee),_e=fe(re),me=ce-_e;return me===0?q2(Ee.id(),re.id()):me};r.depthSort!==void 0&&(G=r.depthSort);for(var z=w.length,Y=0;Y<z;Y++)w[Y].sort(G),A(Y);for(var te=[],ue=0;ue<S.length;ue++)te.push(S[ue]);var oe=function(){for(var Ee=0;Ee<z;Ee++)A(Ee)};te.length&&(w.unshift(te),z=w.length,oe());for(var X=0,Q=0;Q<z;Q++)X=Math.max(w[Q].length,X);var ie={x:u.x1+u.w/2,y:u.y1+u.h/2},de=n.reduce(function(Se,Ee){return(function(re){return{w:Se.w===-1?re.w:(Se.w+re.w)/2,h:Se.h===-1?re.h:(Se.h+re.h)/2}})(Ee.boundingBox({includeLabels:r.nodeDimensionsIncludeLabels}))},{w:-1,h:-1}),we=Math.max(z===1?0:s?(u.h-r.padding*2-de.h)/(z-1):(u.h-r.padding*2-de.h)/(z+1),W),Ae=w.reduce(function(Se,Ee){return Math.max(Se,Ee.length)},0),ve=function(Ee){var re=Hi(Ee),ce=re.depth,_e=re.index;if(r.circle){var me=Math.min(u.w/2/z,u.h/2/z);me=Math.max(me,W);var Te=me*ce+me-(z>0&&w[0].length<=3?me/2:0),De=2*Math.PI/w[ce].length*_e;return ce===0&&w[0].length===1&&(Te=1),{x:ie.x+Te*Math.cos(De),y:ie.y+Te*Math.sin(De)}}else{var Ne=w[ce].length,ze=Math.max(Ne===1?0:s?(u.w-r.padding*2-de.w)/((r.grid?Ae:Ne)-1):(u.w-r.padding*2-de.w)/((r.grid?Ae:Ne)+1),W),$e={x:ie.x+(_e+1-(Ne+1)/2)*ze,y:ie.y+(ce+1-(z+1)/2)*we};return $e}},le={downward:0,leftward:90,upward:180,rightward:-90};Object.keys(le).indexOf(r.direction)===-1&&kr("Invalid direction '".concat(r.direction,"' specified for breadthfirst layout. Valid values are: ").concat(Object.keys(le).join(", ")));var Me=function(Ee){return iF(ve(Ee),u,le[r.direction])};return t.nodes().layoutPositions(this,r,Me),this};var W$={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,radius:void 0,startAngle:3/2*Math.PI,sweep:void 0,clockwise:!0,sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function qA(r){this.options=Xe({},W$,r)}qA.prototype.run=function(){var r=this.options,e=r,t=r.cy,n=e.eles,a=e.counterclockwise!==void 0?!e.counterclockwise:e.clockwise,i=n.nodes().not(":parent");e.sort&&(i=i.sort(e.sort));for(var o=Lt(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:t.width(),h:t.height()}),s={x:o.x1+o.w/2,y:o.y1+o.h/2},u=e.sweep===void 0?2*Math.PI-2*Math.PI/i.length:e.sweep,l=u/Math.max(1,i.length-1),f,d=0,h=0;h<i.length;h++){var g=i[h],p=g.layoutDimensions(e),x=p.w,b=p.h;d=Math.max(d,x,b)}if(qe(e.radius)?f=e.radius:i.length<=1?f=0:f=Math.min(o.h,o.w)/2-d,i.length>1&&e.avoidOverlap){d*=1.75;var w=Math.cos(l)-Math.cos(0),y=Math.sin(l)-Math.sin(0),E=Math.sqrt(d*d/(w*w+y*y));f=Math.max(E,f)}var C=function(R,_){var A=e.startAngle+_*l*(a?1:-1),P=f*Math.cos(A),I=f*Math.sin(A),D={x:s.x+P,y:s.y+I};return D};return n.nodes().layoutPositions(this,e,C),this};var U$={fit:!0,padding:30,startAngle:3/2*Math.PI,sweep:void 0,clockwise:!0,equidistant:!1,minNodeSpacing:10,boundingBox:void 0,avoidOverlap:!0,nodeDimensionsIncludeLabels:!1,height:void 0,width:void 0,spacingFactor:void 0,concentric:function(e){return e.degree()},levelWidth:function(e){return e.maxDegree()/4},animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function NA(r){this.options=Xe({},U$,r)}NA.prototype.run=function(){for(var r=this.options,e=r,t=e.counterclockwise!==void 0?!e.counterclockwise:e.clockwise,n=r.cy,a=e.eles,i=a.nodes().not(":parent"),o=Lt(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()}),s={x:o.x1+o.w/2,y:o.y1+o.h/2},u=[],l=0,f=0;f<i.length;f++){var d=i[f],h=void 0;h=e.concentric(d),u.push({value:h,node:d}),d._private.scratch.concentric=h}i.updateStyle();for(var g=0;g<i.length;g++){var p=i[g],x=p.layoutDimensions(e);l=Math.max(l,x.w,x.h)}u.sort(function(we,Ae){return Ae.value-we.value});for(var b=e.levelWidth(i),w=[[]],y=w[0],E=0;E<u.length;E++){var C=u[E];if(y.length>0){var S=Math.abs(y[0].value-C.value);S>=b&&(y=[],w.push(y))}y.push(C)}var R=l+e.minNodeSpacing;if(!e.avoidOverlap){var _=w.length>0&&w[0].length>1,A=Math.min(o.w,o.h)/2-R,P=A/(w.length+_?1:0);R=Math.min(R,P)}for(var I=0,D=0;D<w.length;D++){var L=w[D],M=e.sweep===void 0?2*Math.PI-2*Math.PI/L.length:e.sweep,q=L.dTheta=M/Math.max(1,L.length-1);if(L.length>1&&e.avoidOverlap){var N=Math.cos(q)-Math.cos(0),W=Math.sin(q)-Math.sin(0),V=Math.sqrt(R*R/(N*N+W*W));I=Math.max(V,I)}L.r=I,I+=R}if(e.equidistant){for(var $=0,Z=0,ee=0;ee<w.length;ee++){var K=w[ee],j=K.r-Z;$=Math.max($,j)}Z=0;for(var fe=0;fe<w.length;fe++){var G=w[fe];fe===0&&(Z=G.r),G.r=Z,Z+=$}}for(var z={},Y=0;Y<w.length;Y++)for(var te=w[Y],ue=te.dTheta,oe=te.r,X=0;X<te.length;X++){var Q=te[X],ie=e.startAngle+(t?1:-1)*ue*X,de={x:s.x+oe*Math.cos(ie),y:s.y+oe*Math.sin(ie)};z[Q.node.id()]=de}return a.nodes().layoutPositions(this,e,function(we){var Ae=we.id();return z[Ae]}),this};var tv,H$={ready:function(){},stop:function(){},animate:!0,animationEasing:void 0,animationDuration:void 0,animateFilter:function(e,t){return!0},animationThreshold:250,refresh:20,fit:!0,padding:30,boundingBox:void 0,nodeDimensionsIncludeLabels:!1,randomize:!1,componentSpacing:40,nodeRepulsion:function(e){return 2048},nodeOverlap:4,idealEdgeLength:function(e){return 32},edgeElasticity:function(e){return 32},nestingFactor:1.2,gravity:1,numIter:1e3,initialTemp:1e3,coolingFactor:.99,minTemp:1};function Ll(r){this.options=Xe({},H$,r),this.options.layout=this;var e=this.options.eles.nodes(),t=this.options.eles.edges(),n=t.filter(function(a){var i=a.source().data("id"),o=a.target().data("id"),s=e.some(function(l){return l.data("id")===i}),u=e.some(function(l){return l.data("id")===o});return!s||!u});this.options.eles=this.options.eles.not(n)}Ll.prototype.run=function(){var r=this.options,e=r.cy,t=this;t.stopped=!1,(r.animate===!0||r.animate===!1)&&t.emit({type:"layoutstart",layout:t}),r.debug===!0?tv=!0:tv=!1;var n=K$(e,t,r);tv&&Y$(n),r.randomize&&Z$(n);var a=ta(),i=function(){X$(n,e,r),r.fit===!0&&e.fit(r.padding)},o=function(h){return!(t.stopped||h>=r.numIter||(Q$(n,r),n.temperature=n.temperature*r.coolingFactor,n.temperature<r.minTemp))},s=function(){if(r.animate===!0||r.animate===!1)i(),t.one("layoutstop",r.stop),t.emit({type:"layoutstop",layout:t});else{var h=r.eles.nodes(),g=zA(n,r,h);h.layoutPositions(t,r,g)}},u=0,l=!0;if(r.animate===!0){var f=function(){for(var h=0;l&&h<r.refresh;)l=o(u),u++,h++;if(!l)_E(n,r),s();else{var g=ta();g-a>=r.animationThreshold&&i(),tl(f)}};f()}else{for(;l;)l=o(u),u++;_E(n,r),s()}return this};Ll.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit("layoutstop"),this};Ll.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var K$=function(e,t,n){for(var a=n.eles.edges(),i=n.eles.nodes(),o=Lt(n.boundingBox?n.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()}),s={isCompound:e.hasCompoundNodes(),layoutNodes:[],idToIndex:{},nodeSize:i.size(),graphSet:[],indexToGraph:[],layoutEdges:[],edgeSize:a.size(),temperature:n.initialTemp,clientWidth:o.w,clientHeight:o.h,boundingBox:o},u=n.eles.components(),l={},f=0;f<u.length;f++)for(var d=u[f],h=0;h<d.length;h++){var g=d[h];l[g.id()]=f}for(var f=0;f<s.nodeSize;f++){var p=i[f],x=p.layoutDimensions(n),b={};b.isLocked=p.locked(),b.id=p.data("id"),b.parentId=p.data("parent"),b.cmptId=l[p.id()],b.children=[],b.positionX=p.position("x"),b.positionY=p.position("y"),b.offsetX=0,b.offsetY=0,b.height=x.w,b.width=x.h,b.maxX=b.positionX+b.width/2,b.minX=b.positionX-b.width/2,b.maxY=b.positionY+b.height/2,b.minY=b.positionY-b.height/2,b.padLeft=parseFloat(p.style("padding")),b.padRight=parseFloat(p.style("padding")),b.padTop=parseFloat(p.style("padding")),b.padBottom=parseFloat(p.style("padding")),b.nodeRepulsion=$r(n.nodeRepulsion)?n.nodeRepulsion(p):n.nodeRepulsion,s.layoutNodes.push(b),s.idToIndex[b.id]=f}for(var w=[],y=0,E=-1,C=[],f=0;f<s.nodeSize;f++){var p=s.layoutNodes[f],S=p.parentId;S!=null?s.layoutNodes[s.idToIndex[S]].children.push(p.id):(w[++E]=p.id,C.push(p.id))}for(s.graphSet.push(C);y<=E;){var R=w[y++],_=s.idToIndex[R],g=s.layoutNodes[_],A=g.children;if(A.length>0){s.graphSet.push(A);for(var f=0;f<A.length;f++)w[++E]=A[f]}}for(var f=0;f<s.graphSet.length;f++)for(var P=s.graphSet[f],h=0;h<P.length;h++){var I=s.idToIndex[P[h]];s.indexToGraph[I]=f}for(var f=0;f<s.edgeSize;f++){var D=a[f],L={};L.id=D.data("id"),L.sourceId=D.data("source"),L.targetId=D.data("target");var M=$r(n.idealEdgeLength)?n.idealEdgeLength(D):n.idealEdgeLength,q=$r(n.edgeElasticity)?n.edgeElasticity(D):n.edgeElasticity,N=s.idToIndex[L.sourceId],W=s.idToIndex[L.targetId],V=s.indexToGraph[N],$=s.indexToGraph[W];if(V!=$){for(var Z=j$(L.sourceId,L.targetId,s),ee=s.graphSet[Z],K=0,b=s.layoutNodes[N];ee.indexOf(b.id)===-1;)b=s.layoutNodes[s.idToIndex[b.parentId]],K++;for(b=s.layoutNodes[W];ee.indexOf(b.id)===-1;)b=s.layoutNodes[s.idToIndex[b.parentId]],K++;M*=K*n.nestingFactor}L.idealLength=M,L.elasticity=q,s.layoutEdges.push(L)}return s},j$=function(e,t,n){var a=FA(e,t,0,n);return 2>a.count?0:a.graph},FA=function(e,t,n,a){var i=a.graphSet[n];if(-1<i.indexOf(e)&&-1<i.indexOf(t))return{count:2,graph:n};for(var o=0,s=0;s<i.length;s++){var u=i[s],l=a.idToIndex[u],f=a.layoutNodes[l].children;if(f.length!==0){var d=a.indexToGraph[a.idToIndex[f[0]]],h=FA(e,t,d,a);if(h.count!==0)if(h.count===1){if(o++,o===2)break}else return h}}return{count:o,graph:n}},Y$,Z$=function(e,t){for(var n=e.clientWidth,a=e.clientHeight,i=0;i<e.nodeSize;i++){var o=e.layoutNodes[i];o.children.length===0&&!o.isLocked&&(o.positionX=Math.random()*n,o.positionY=Math.random()*a)}},zA=function(e,t,n){var a=e.boundingBox,i={x1:1/0,x2:-1/0,y1:1/0,y2:-1/0};return t.boundingBox&&(n.forEach(function(o){var s=e.layoutNodes[e.idToIndex[o.data("id")]];i.x1=Math.min(i.x1,s.positionX),i.x2=Math.max(i.x2,s.positionX),i.y1=Math.min(i.y1,s.positionY),i.y2=Math.max(i.y2,s.positionY)}),i.w=i.x2-i.x1,i.h=i.y2-i.y1),function(o,s){var u=e.layoutNodes[e.idToIndex[o.data("id")]];if(t.boundingBox){var l=i.w===0?.5:(u.positionX-i.x1)/i.w,f=i.h===0?.5:(u.positionY-i.y1)/i.h;return{x:a.x1+l*a.w,y:a.y1+f*a.h}}else return{x:u.positionX,y:u.positionY}}},X$=function(e,t,n){var a=n.layout,i=n.eles.nodes(),o=zA(e,n,i);i.positions(o),e.ready!==!0&&(e.ready=!0,a.one("layoutready",n.ready),a.emit({type:"layoutready",layout:this}))},Q$=function(e,t,n){J$(e,t),t3(e),n3(e,t),a3(e),i3(e)},J$=function(e,t){for(var n=0;n<e.graphSet.length;n++)for(var a=e.graphSet[n],i=a.length,o=0;o<i;o++)for(var s=e.layoutNodes[e.idToIndex[a[o]]],u=o+1;u<i;u++){var l=e.layoutNodes[e.idToIndex[a[u]]];e3(s,l,e,t)}},CE=function(e){return-1+2*e*Math.random()},e3=function(e,t,n,a){var i=e.cmptId,o=t.cmptId;if(!(i!==o&&!n.isCompound)){var s=t.positionX-e.positionX,u=t.positionY-e.positionY,l=1;s===0&&u===0&&(s=CE(l),u=CE(l));var f=r3(e,t,s,u);if(f>0)var d=a.nodeOverlap*f,h=Math.sqrt(s*s+u*u),g=d*s/h,p=d*u/h;else var x=ll(e,s,u),b=ll(t,-1*s,-1*u),w=b.x-x.x,y=b.y-x.y,E=w*w+y*y,h=Math.sqrt(E),d=(e.nodeRepulsion+t.nodeRepulsion)/E,g=d*w/h,p=d*y/h;e.isLocked||(e.offsetX-=g,e.offsetY-=p),t.isLocked||(t.offsetX+=g,t.offsetY+=p)}},r3=function(e,t,n,a){if(n>0)var i=e.maxX-t.minX;else var i=t.maxX-e.minX;if(a>0)var o=e.maxY-t.minY;else var o=t.maxY-e.minY;return i>=0&&o>=0?Math.sqrt(i*i+o*o):0},ll=function(e,t,n){var a=e.positionX,i=e.positionY,o=e.height||1,s=e.width||1,u=n/t,l=o/s,f={};return t===0&&0<n||t===0&&0>n?(f.x=a,f.y=i+o/2,f):0<t&&-1*l<=u&&u<=l?(f.x=a+s/2,f.y=i+s*n/2/t,f):0>t&&-1*l<=u&&u<=l?(f.x=a-s/2,f.y=i-s*n/2/t,f):0<n&&(u<=-1*l||u>=l)?(f.x=a+o*t/2/n,f.y=i+o/2,f):(0>n&&(u<=-1*l||u>=l)&&(f.x=a-o*t/2/n,f.y=i-o/2),f)},t3=function(e,t){for(var n=0;n<e.edgeSize;n++){var a=e.layoutEdges[n],i=e.idToIndex[a.sourceId],o=e.layoutNodes[i],s=e.idToIndex[a.targetId],u=e.layoutNodes[s],l=u.positionX-o.positionX,f=u.positionY-o.positionY;if(!(l===0&&f===0)){var d=ll(o,l,f),h=ll(u,-1*l,-1*f),g=h.x-d.x,p=h.y-d.y,x=Math.sqrt(g*g+p*p),b=Math.pow(a.idealLength-x,2)/a.elasticity;if(x!==0)var w=b*g/x,y=b*p/x;else var w=0,y=0;o.isLocked||(o.offsetX+=w,o.offsetY+=y),u.isLocked||(u.offsetX-=w,u.offsetY-=y)}}},n3=function(e,t){if(t.gravity!==0)for(var n=1,a=0;a<e.graphSet.length;a++){var i=e.graphSet[a],o=i.length;if(a===0)var s=e.clientHeight/2,u=e.clientWidth/2;else var l=e.layoutNodes[e.idToIndex[i[0]]],f=e.layoutNodes[e.idToIndex[l.parentId]],s=f.positionX,u=f.positionY;for(var d=0;d<o;d++){var h=e.layoutNodes[e.idToIndex[i[d]]];if(!h.isLocked){var g=s-h.positionX,p=u-h.positionY,x=Math.sqrt(g*g+p*p);if(x>n){var b=t.gravity*g/x,w=t.gravity*p/x;h.offsetX+=b,h.offsetY+=w}}}}},a3=function(e,t){var n=[],a=0,i=-1;for(n.push.apply(n,e.graphSet[0]),i+=e.graphSet[0].length;a<=i;){var o=n[a++],s=e.idToIndex[o],u=e.layoutNodes[s],l=u.children;if(0<l.length&&!u.isLocked){for(var f=u.offsetX,d=u.offsetY,h=0;h<l.length;h++){var g=e.layoutNodes[e.idToIndex[l[h]]];g.offsetX+=f,g.offsetY+=d,n[++i]=l[h]}u.offsetX=0,u.offsetY=0}}},i3=function(e,t){for(var n=0;n<e.nodeSize;n++){var a=e.layoutNodes[n];0<a.children.length&&(a.maxX=void 0,a.minX=void 0,a.maxY=void 0,a.minY=void 0)}for(var n=0;n<e.nodeSize;n++){var a=e.layoutNodes[n];if(!(0<a.children.length||a.isLocked)){var i=o3(a.offsetX,a.offsetY,e.temperature);a.positionX+=i.x,a.positionY+=i.y,a.offsetX=0,a.offsetY=0,a.minX=a.positionX-a.width,a.maxX=a.positionX+a.width,a.minY=a.positionY-a.height,a.maxY=a.positionY+a.height,$A(a,e)}}for(var n=0;n<e.nodeSize;n++){var a=e.layoutNodes[n];0<a.children.length&&!a.isLocked&&(a.positionX=(a.maxX+a.minX)/2,a.positionY=(a.maxY+a.minY)/2,a.width=a.maxX-a.minX,a.height=a.maxY-a.minY)}},o3=function(e,t,n){var a=Math.sqrt(e*e+t*t);if(a>n)var i={x:n*e/a,y:n*t/a};else var i={x:e,y:t};return i},$A=function(e,t){var n=e.parentId;if(n!=null){var a=t.layoutNodes[t.idToIndex[n]],i=!1;if((a.maxX==null||e.maxX+a.padRight>a.maxX)&&(a.maxX=e.maxX+a.padRight,i=!0),(a.minX==null||e.minX-a.padLeft<a.minX)&&(a.minX=e.minX-a.padLeft,i=!0),(a.maxY==null||e.maxY+a.padBottom>a.maxY)&&(a.maxY=e.maxY+a.padBottom,i=!0),(a.minY==null||e.minY-a.padTop<a.minY)&&(a.minY=e.minY-a.padTop,i=!0),i)return $A(a,t)}},_E=function(e,t){for(var n=e.layoutNodes,a=[],i=0;i<n.length;i++){var o=n[i],s=o.cmptId,u=a[s]=a[s]||[];u.push(o)}for(var l=0,i=0;i<a.length;i++){var f=a[i];if(f){f.x1=1/0,f.x2=-1/0,f.y1=1/0,f.y2=-1/0;for(var d=0;d<f.length;d++){var h=f[d];f.x1=Math.min(f.x1,h.positionX-h.width/2),f.x2=Math.max(f.x2,h.positionX+h.width/2),f.y1=Math.min(f.y1,h.positionY-h.height/2),f.y2=Math.max(f.y2,h.positionY+h.height/2)}f.w=f.x2-f.x1,f.h=f.y2-f.y1,l+=f.w*f.h}}a.sort(function(y,E){return E.w*E.h-y.w*y.h});for(var g=0,p=0,x=0,b=0,w=Math.sqrt(l)*e.clientWidth/e.clientHeight,i=0;i<a.length;i++){var f=a[i];if(f){for(var d=0;d<f.length;d++){var h=f[d];h.isLocked||(h.positionX+=g-f.x1,h.positionY+=p-f.y1)}g+=f.w+t.componentSpacing,x+=f.w+t.componentSpacing,b=Math.max(b,f.h),x>w&&(p+=b+t.componentSpacing,g=0,x=0,b=0)}}},s3={fit:!0,padding:30,boundingBox:void 0,avoidOverlap:!0,avoidOverlapPadding:10,nodeDimensionsIncludeLabels:!1,spacingFactor:void 0,condense:!1,rows:void 0,cols:void 0,position:function(e){},sort:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function VA(r){this.options=Xe({},s3,r)}VA.prototype.run=function(){var r=this.options,e=r,t=r.cy,n=e.eles,a=n.nodes().not(":parent");e.sort&&(a=a.sort(e.sort));var i=Lt(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:t.width(),h:t.height()});if(i.h===0||i.w===0)n.nodes().layoutPositions(this,e,function(fe){return{x:i.x1,y:i.y1}});else{var o=a.size(),s=Math.sqrt(o*i.h/i.w),u=Math.round(s),l=Math.round(i.w/i.h*s),f=function(G){if(G==null)return Math.min(u,l);var z=Math.min(u,l);z==u?u=G:l=G},d=function(G){if(G==null)return Math.max(u,l);var z=Math.max(u,l);z==u?u=G:l=G},h=e.rows,g=e.cols!=null?e.cols:e.columns;if(h!=null&&g!=null)u=h,l=g;else if(h!=null&&g==null)u=h,l=Math.ceil(o/u);else if(h==null&&g!=null)l=g,u=Math.ceil(o/l);else if(l*u>o){var p=f(),x=d();(p-1)*x>=o?f(p-1):(x-1)*p>=o&&d(x-1)}else for(;l*u<o;){var b=f(),w=d();(w+1)*b>=o?d(w+1):f(b+1)}var y=i.w/l,E=i.h/u;if(e.condense&&(y=0,E=0),e.avoidOverlap)for(var C=0;C<a.length;C++){var S=a[C],R=S._private.position;(R.x==null||R.y==null)&&(R.x=0,R.y=0);var _=S.layoutDimensions(e),A=e.avoidOverlapPadding,P=_.w+A,I=_.h+A;y=Math.max(y,P),E=Math.max(E,I)}for(var D={},L=function(G,z){return!!D["c-"+G+"-"+z]},M=function(G,z){D["c-"+G+"-"+z]=!0},q=0,N=0,W=function(){N++,N>=l&&(N=0,q++)},V={},$=0;$<a.length;$++){var Z=a[$],ee=e.position(Z);if(ee&&(ee.row!==void 0||ee.col!==void 0)){var K={row:ee.row,col:ee.col};if(K.col===void 0)for(K.col=0;L(K.row,K.col);)K.col++;else if(K.row===void 0)for(K.row=0;L(K.row,K.col);)K.row++;V[Z.id()]=K,M(K.row,K.col)}}var j=function(G,z){var Y,te;if(G.locked()||G.isParent())return!1;var ue=V[G.id()];if(ue)Y=ue.col*y+y/2+i.x1,te=ue.row*E+E/2+i.y1;else{for(;L(q,N);)W();Y=N*y+y/2+i.x1,te=q*E+E/2+i.y1,M(q,N),W()}return{x:Y,y:te}};a.layoutPositions(this,e,j)}return this};var u3={ready:function(){},stop:function(){}};function f0(r){this.options=Xe({},u3,r)}f0.prototype.run=function(){var r=this.options,e=r.eles,t=this;return r.cy,t.emit("layoutstart"),e.nodes().positions(function(){return{x:0,y:0}}),t.one("layoutready",r.ready),t.emit("layoutready"),t.one("layoutstop",r.stop),t.emit("layoutstop"),this};f0.prototype.stop=function(){return this};var l3={positions:void 0,zoom:void 0,pan:void 0,fit:!0,padding:30,spacingFactor:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function GA(r){this.options=Xe({},l3,r)}GA.prototype.run=function(){var r=this.options,e=r.eles,t=e.nodes(),n=$r(r.positions);function a(i){if(r.positions==null)return DF(i.position());if(n)return r.positions(i);var o=r.positions[i._private.data.id];return o??null}return t.layoutPositions(this,r,function(i,o){var s=a(i);return i.locked()||s==null?!1:s}),this};var f3={fit:!0,padding:30,boundingBox:void 0,animate:!1,animationDuration:500,animationEasing:void 0,animateFilter:function(e,t){return!0},ready:void 0,stop:void 0,transform:function(e,t){return t}};function WA(r){this.options=Xe({},f3,r)}WA.prototype.run=function(){var r=this.options,e=r.cy,t=r.eles,n=Lt(r.boundingBox?r.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()}),a=function(o,s){return{x:n.x1+Math.round(Math.random()*n.w),y:n.y1+Math.round(Math.random()*n.h)}};return t.nodes().layoutPositions(this,r,a),this};var c3=[{name:"breadthfirst",impl:kA},{name:"circle",impl:qA},{name:"concentric",impl:NA},{name:"cose",impl:Ll},{name:"grid",impl:VA},{name:"null",impl:f0},{name:"preset",impl:GA},{name:"random",impl:WA}];function UA(r){this.options=r,this.notifications=0}var SE=function(){},TE=function(){throw new Error("A headless instance can not render images")};UA.prototype={recalculateRenderedStyle:SE,notify:function(){this.notifications++},init:SE,isHeadless:function(){return!0},png:TE,jpg:TE};var c0={};c0.arrowShapeWidth=.3;c0.registerArrowShapes=function(){var r=this.arrowShapes={},e=this,t=function(l,f,d,h,g,p,x){var b=g.x-d/2-x,w=g.x+d/2+x,y=g.y-d/2-x,E=g.y+d/2+x,C=b<=l&&l<=w&&y<=f&&f<=E;return C},n=function(l,f,d,h,g){var p=l*Math.cos(h)-f*Math.sin(h),x=l*Math.sin(h)+f*Math.cos(h),b=p*d,w=x*d,y=b+g.x,E=w+g.y;return{x:y,y:E}},a=function(l,f,d,h){for(var g=[],p=0;p<l.length;p+=2){var x=l[p],b=l[p+1];g.push(n(x,b,f,d,h))}return g},i=function(l){for(var f=[],d=0;d<l.length;d++){var h=l[d];f.push(h.x,h.y)}return f},o=function(l){return l.pstyle("width").pfValue*l.pstyle("arrow-scale").pfValue*2},s=function(l,f){Ye(f)&&(f=r[f]),r[l]=Xe({name:l,points:[-.15,-.3,.15,-.3,.15,.3,-.15,.3],collide:function(h,g,p,x,b,w){var y=i(a(this.points,p+2*w,x,b)),E=Vt(h,g,y);return E},roughCollide:t,draw:function(h,g,p,x){var b=a(this.points,g,p,x);e.arrowShapeImpl("polygon")(h,b)},spacing:function(h){return 0},gap:o},f)};s("none",{collide:nl,roughCollide:nl,draw:Zm,spacing:zw,gap:zw}),s("triangle",{points:[-.15,-.3,0,0,.15,-.3]}),s("arrow","triangle"),s("triangle-backcurve",{points:r.triangle.points,controlPoint:[0,-.15],roughCollide:t,draw:function(l,f,d,h,g){var p=a(this.points,f,d,h),x=this.controlPoint,b=n(x[0],x[1],f,d,h);e.arrowShapeImpl(this.name)(l,p,b)},gap:function(l){return o(l)*.8}}),s("triangle-tee",{points:[0,0,.15,-.3,-.15,-.3,0,0],pointsTee:[-.15,-.4,-.15,-.5,.15,-.5,.15,-.4],collide:function(l,f,d,h,g,p,x){var b=i(a(this.points,d+2*x,h,g)),w=i(a(this.pointsTee,d+2*x,h,g)),y=Vt(l,f,b)||Vt(l,f,w);return y},draw:function(l,f,d,h,g){var p=a(this.points,f,d,h),x=a(this.pointsTee,f,d,h);e.arrowShapeImpl(this.name)(l,p,x)}}),s("circle-triangle",{radius:.15,pointsTr:[0,-.15,.15,-.45,-.15,-.45,0,-.15],collide:function(l,f,d,h,g,p,x){var b=g,w=Math.pow(b.x-l,2)+Math.pow(b.y-f,2)<=Math.pow((d+2*x)*this.radius,2),y=i(a(this.points,d+2*x,h,g));return Vt(l,f,y)||w},draw:function(l,f,d,h,g){var p=a(this.pointsTr,f,d,h);e.arrowShapeImpl(this.name)(l,p,h.x,h.y,this.radius*f)},spacing:function(l){return e.getArrowWidth(l.pstyle("width").pfValue,l.pstyle("arrow-scale").value)*this.radius}}),s("triangle-cross",{points:[0,0,.15,-.3,-.15,-.3,0,0],baseCrossLinePts:[-.15,-.4,-.15,-.4,.15,-.4,.15,-.4],crossLinePts:function(l,f){var d=this.baseCrossLinePts.slice(),h=f/l,g=3,p=5;return d[g]=d[g]-h,d[p]=d[p]-h,d},collide:function(l,f,d,h,g,p,x){var b=i(a(this.points,d+2*x,h,g)),w=i(a(this.crossLinePts(d,p),d+2*x,h,g)),y=Vt(l,f,b)||Vt(l,f,w);return y},draw:function(l,f,d,h,g){var p=a(this.points,f,d,h),x=a(this.crossLinePts(f,g),f,d,h);e.arrowShapeImpl(this.name)(l,p,x)}}),s("vee",{points:[-.15,-.3,0,0,.15,-.3,0,-.15],gap:function(l){return o(l)*.525}}),s("circle",{radius:.15,collide:function(l,f,d,h,g,p,x){var b=g,w=Math.pow(b.x-l,2)+Math.pow(b.y-f,2)<=Math.pow((d+2*x)*this.radius,2);return w},draw:function(l,f,d,h,g){e.arrowShapeImpl(this.name)(l,h.x,h.y,this.radius*f)},spacing:function(l){return e.getArrowWidth(l.pstyle("width").pfValue,l.pstyle("arrow-scale").value)*this.radius}}),s("tee",{points:[-.15,0,-.15,-.1,.15,-.1,.15,0],spacing:function(l){return 1},gap:function(l){return 1}}),s("square",{points:[-.15,0,.15,0,.15,-.3,-.15,-.3]}),s("diamond",{points:[-.15,-.15,0,-.3,.15,-.15,0,0],gap:function(l){return l.pstyle("width").pfValue*l.pstyle("arrow-scale").value}}),s("chevron",{points:[0,0,-.15,-.15,-.1,-.2,0,-.1,.1,-.2,.15,-.15],gap:function(l){return .95*l.pstyle("width").pfValue*l.pstyle("arrow-scale").value}})};var mi={};mi.projectIntoViewport=function(r,e){var t=this.cy,n=this.findContainerClientCoords(),a=n[0],i=n[1],o=n[4],s=t.pan(),u=t.zoom(),l=((r-a)/o-s.x)/u,f=((e-i)/o-s.y)/u;return[l,f]};mi.findContainerClientCoords=function(){if(this.containerBB)return this.containerBB;var r=this.container,e=r.getBoundingClientRect(),t=this.cy.window().getComputedStyle(r),n=function(w){return parseFloat(t.getPropertyValue(w))},a={left:n("padding-left"),right:n("padding-right"),top:n("padding-top"),bottom:n("padding-bottom")},i={left:n("border-left-width"),right:n("border-right-width"),top:n("border-top-width"),bottom:n("border-bottom-width")},o=r.clientWidth,s=r.clientHeight,u=a.left+a.right,l=a.top+a.bottom,f=i.left+i.right,d=e.width/(o+f),h=o-u,g=s-l,p=e.left+a.left+i.left,x=e.top+a.top+i.top;return this.containerBB=[p,x,h,g,d]};mi.invalidateContainerClientCoordsCache=function(){this.containerBB=null};mi.findNearestElement=function(r,e,t,n){return this.findNearestElements(r,e,t,n)[0]};mi.findNearestElements=function(r,e,t,n){var a=this,i=this,o=i.getCachedZSortedEles(),s=[],u=i.cy.zoom(),l=i.cy.hasCompoundNodes(),f=(n?24:8)/u,d=(n?8:2)/u,h=(n?8:2)/u,g=1/0,p,x;t&&(o=o.interactive);function b(_,A){if(_.isNode()){if(x)return;x=_,s.push(_)}if(_.isEdge()&&(A==null||A<g))if(p){if(p.pstyle("z-compound-depth").value===_.pstyle("z-compound-depth").value&&p.pstyle("z-compound-depth").value===_.pstyle("z-compound-depth").value){for(var P=0;P<s.length;P++)if(s[P].isEdge()){s[P]=_,p=_,g=A??g;break}}}else s.push(_),p=_,g=A??g}function w(_){var A=_.outerWidth()+2*d,P=_.outerHeight()+2*d,I=A/2,D=P/2,L=_.position(),M=_.pstyle("corner-radius").value==="auto"?"auto":_.pstyle("corner-radius").pfValue,q=_._private.rscratch;if(L.x-I<=r&&r<=L.x+I&&L.y-D<=e&&e<=L.y+D){var N=i.nodeShapes[a.getNodeShape(_)];if(N.checkPoint(r,e,0,A,P,L.x,L.y,M,q))return b(_,0),!0}}function y(_){var A=_._private,P=A.rscratch,I=_.pstyle("width").pfValue,D=_.pstyle("arrow-scale").value,L=I/2+f,M=L*L,q=L*2,$=A.source,Z=A.target,N;if(P.edgeType==="segments"||P.edgeType==="straight"||P.edgeType==="haystack"){for(var W=P.allpts,V=0;V+3<W.length;V+=2)if(UF(r,e,W[V],W[V+1],W[V+2],W[V+3],q)&&M>(N=ZF(r,e,W[V],W[V+1],W[V+2],W[V+3])))return b(_,N),!0}else if(P.edgeType==="bezier"||P.edgeType==="multibezier"||P.edgeType==="self"||P.edgeType==="compound"){for(var W=P.allpts,V=0;V+5<P.allpts.length;V+=4)if(HF(r,e,W[V],W[V+1],W[V+2],W[V+3],W[V+4],W[V+5],q)&&M>(N=YF(r,e,W[V],W[V+1],W[V+2],W[V+3],W[V+4],W[V+5])))return b(_,N),!0}for(var $=$||A.source,Z=Z||A.target,ee=a.getArrowWidth(I,D),K=[{name:"source",x:P.arrowStartX,y:P.arrowStartY,angle:P.srcArrowAngle},{name:"target",x:P.arrowEndX,y:P.arrowEndY,angle:P.tgtArrowAngle},{name:"mid-source",x:P.midX,y:P.midY,angle:P.midsrcArrowAngle},{name:"mid-target",x:P.midX,y:P.midY,angle:P.midtgtArrowAngle}],V=0;V<K.length;V++){var j=K[V],fe=i.arrowShapes[_.pstyle(j.name+"-arrow-shape").value],G=_.pstyle("width").pfValue;if(fe.roughCollide(r,e,ee,j.angle,{x:j.x,y:j.y},G,f)&&fe.collide(r,e,ee,j.angle,{x:j.x,y:j.y},G,f))return b(_),!0}l&&s.length>0&&(w($),w(Z))}function E(_,A,P){return $t(_,A,P)}function C(_,A){var P=_._private,I=h,D;A?D=A+"-":D="",_.boundingBox();var L=P.labelBounds[A||"main"],M=_.pstyle(D+"label").value,q=_.pstyle("text-events").strValue==="yes";if(!(!q||!M)){var N=E(P.rscratch,"labelX",A),W=E(P.rscratch,"labelY",A),V=E(P.rscratch,"labelAngle",A),$=_.pstyle(D+"text-margin-x").pfValue,Z=_.pstyle(D+"text-margin-y").pfValue,ee=L.x1-I-$,K=L.x2+I-$,j=L.y1-I-Z,fe=L.y2+I-Z;if(V){var G=Math.cos(V),z=Math.sin(V),Y=function(de,we){return de=de-N,we=we-W,{x:de*G-we*z+N,y:de*z+we*G+W}},te=Y(ee,j),ue=Y(ee,fe),oe=Y(K,j),X=Y(K,fe),Q=[te.x+$,te.y+Z,oe.x+$,oe.y+Z,X.x+$,X.y+Z,ue.x+$,ue.y+Z];if(Vt(r,e,Q))return b(_),!0}else if(Sa(L,r,e))return b(_),!0}}for(var S=o.length-1;S>=0;S--){var R=o[S];R.isNode()?w(R)||C(R):y(R)||C(R)||C(R,"source")||C(R,"target")}return s};mi.getAllInBox=function(r,e,t,n){var a=this.getCachedZSortedEles().interactive,i=this.cy.zoom(),o=2/i,s=[],u=Math.min(r,t),l=Math.max(r,t),f=Math.min(e,n),d=Math.max(e,n);r=u,t=l,e=f,n=d;var h=Lt({x1:r,y1:e,x2:t,y2:n}),g=[{x:h.x1,y:h.y1},{x:h.x2,y:h.y1},{x:h.x2,y:h.y2},{x:h.x1,y:h.y2}],p=[[g[0],g[1]],[g[1],g[2]],[g[2],g[3]],[g[3],g[0]]];function x(de,we,Ae){return $t(de,we,Ae)}function b(de,we){var Ae=de._private,ve=o,le="";de.boundingBox();var Me=Ae.labelBounds.main;if(!Me)return null;var Se=x(Ae.rscratch,"labelX",we),Ee=x(Ae.rscratch,"labelY",we),re=x(Ae.rscratch,"labelAngle",we),ce=de.pstyle(le+"text-margin-x").pfValue,_e=de.pstyle(le+"text-margin-y").pfValue,me=Me.x1-ve-ce,Te=Me.x2+ve-ce,De=Me.y1-ve-_e,Ne=Me.y2+ve-_e;if(re){var ze=Math.cos(re),$e=Math.sin(re),ke=function(ye,O){return ye=ye-Se,O=O-Ee,{x:ye*ze-O*$e+Se,y:ye*$e+O*ze+Ee}};return[ke(me,De),ke(Te,De),ke(Te,Ne),ke(me,Ne)]}else return[{x:me,y:De},{x:Te,y:De},{x:Te,y:Ne},{x:me,y:Ne}]}function w(de,we,Ae,ve){function le(Me,Se,Ee){return(Ee.y-Me.y)*(Se.x-Me.x)>(Se.y-Me.y)*(Ee.x-Me.x)}return le(de,Ae,ve)!==le(we,Ae,ve)&&le(de,we,Ae)!==le(de,we,ve)}for(var y=0;y<a.length;y++){var E=a[y];if(E.isNode()){var C=E,S=C.pstyle("text-events").strValue==="yes",R=C.pstyle("box-selection").strValue,_=C.pstyle("box-select-labels").strValue==="yes";if(R==="none")continue;var A=(R==="overlap"||_)&&S,P=C.boundingBox({includeNodes:!0,includeEdges:!1,includeLabels:A});if(R==="contain"){var I=!1;if(_&&S){var D=b(C);D&&ed(D,g)&&(s.push(C),I=!0)}!I&&Q2(h,P)&&s.push(C)}else if(R==="overlap"&&e0(h,P)){var L=C.boundingBox({includeNodes:!0,includeEdges:!0,includeLabels:!1,includeMainLabels:!1,includeSourceLabels:!1,includeTargetLabels:!1}),M=[{x:L.x1,y:L.y1},{x:L.x2,y:L.y1},{x:L.x2,y:L.y2},{x:L.x1,y:L.y2}];if(ed(M,g))s.push(C);else{var q=b(C);q&&ed(q,g)&&s.push(C)}}}else{var N=E,W=N._private,V=W.rscratch,$=N.pstyle("box-selection").strValue;if($==="none")continue;if($==="contain"){if(V.startX!=null&&V.startY!=null&&!Sa(h,V.startX,V.startY)||V.endX!=null&&V.endY!=null&&!Sa(h,V.endX,V.endY))continue;if(V.edgeType==="bezier"||V.edgeType==="multibezier"||V.edgeType==="self"||V.edgeType==="compound"||V.edgeType==="segments"||V.edgeType==="haystack"){for(var Z=W.rstyle.bezierPts||W.rstyle.linePts||W.rstyle.haystackPts,ee=!0,K=0;K<Z.length;K++)if(!Uw(h,Z[K])){ee=!1;break}ee&&s.push(N)}else V.edgeType==="straight"&&s.push(N)}else if($==="overlap"){var j=!1;if(V.startX!=null&&V.startY!=null&&V.endX!=null&&V.endY!=null&&(Sa(h,V.startX,V.startY)||Sa(h,V.endX,V.endY)))s.push(N),j=!0;else if(!j&&V.edgeType==="haystack"){for(var fe=W.rstyle.haystackPts,G=0;G<fe.length;G++)if(Uw(h,fe[G])){s.push(N),j=!0;break}}if(!j){var z=W.rstyle.bezierPts||W.rstyle.linePts||W.rstyle.haystackPts;if((!z||z.length<2)&&V.edgeType==="straight"&&V.startX!=null&&V.startY!=null&&V.endX!=null&&V.endY!=null&&(z=[{x:V.startX,y:V.startY},{x:V.endX,y:V.endY}]),!z||z.length<2)continue;for(var Y=0;Y<z.length-1;Y++){for(var te=z[Y],ue=z[Y+1],oe=0;oe<p.length;oe++){var X=Zr(p[oe],2),Q=X[0],ie=X[1];if(w(te,ue,Q,ie)){s.push(N),j=!0;break}}if(j)break}}}}}return s};var fl={};fl.calculateArrowAngles=function(r){var e=r._private.rscratch,t=e.edgeType==="haystack",n=e.edgeType==="bezier",a=e.edgeType==="multibezier",i=e.edgeType==="segments",o=e.edgeType==="compound",s=e.edgeType==="self",u,l,f,d,h,g,w,y;if(t?(f=e.haystackPts[0],d=e.haystackPts[1],h=e.haystackPts[2],g=e.haystackPts[3]):(f=e.arrowStartX,d=e.arrowStartY,h=e.arrowEndX,g=e.arrowEndY),w=e.midX,y=e.midY,i)u=f-e.segpts[0],l=d-e.segpts[1];else if(a||o||s||n){var p=e.allpts,x=ut(p[0],p[2],p[4],.1),b=ut(p[1],p[3],p[5],.1);u=f-x,l=d-b}else u=f-w,l=d-y;e.srcArrowAngle=Au(u,l);var w=e.midX,y=e.midY;if(t&&(w=(f+h)/2,y=(d+g)/2),u=h-f,l=g-d,i){var p=e.allpts;if(p.length/2%2===0){var E=p.length/2,C=E-2;u=p[E]-p[C],l=p[E+1]-p[C+1]}else if(e.isRound)u=e.midVector[1],l=-e.midVector[0];else{var E=p.length/2-1,C=E-2;u=p[E]-p[C],l=p[E+1]-p[C+1]}}else if(a||o||s){var p=e.allpts,S=e.ctrlpts,R,_,A,P;if(S.length/2%2===0){var I=p.length/2-1,D=I+2,L=D+2;R=ut(p[I],p[D],p[L],0),_=ut(p[I+1],p[D+1],p[L+1],0),A=ut(p[I],p[D],p[L],1e-4),P=ut(p[I+1],p[D+1],p[L+1],1e-4)}else{var D=p.length/2-1,I=D-2,L=D+2;R=ut(p[I],p[D],p[L],.4999),_=ut(p[I+1],p[D+1],p[L+1],.4999),A=ut(p[I],p[D],p[L],.5),P=ut(p[I+1],p[D+1],p[L+1],.5)}u=A-R,l=P-_}if(e.midtgtArrowAngle=Au(u,l),e.midDispX=u,e.midDispY=l,u*=-1,l*=-1,i){var p=e.allpts;if(p.length/2%2!==0){if(!e.isRound){var E=p.length/2-1,M=E+2;u=-(p[M]-p[E]),l=-(p[M+1]-p[E+1])}}}if(e.midsrcArrowAngle=Au(u,l),i)u=h-e.segpts[e.segpts.length-2],l=g-e.segpts[e.segpts.length-1];else if(a||o||s||n){var p=e.allpts,q=p.length,x=ut(p[q-6],p[q-4],p[q-2],.9),b=ut(p[q-5],p[q-3],p[q-1],.9);u=h-x,l=g-b}else u=h-w,l=g-y;e.tgtArrowAngle=Au(u,l)};fl.getArrowWidth=fl.getArrowHeight=function(r,e){var t=this.arrowWidthCache=this.arrowWidthCache||{},n=t[r+", "+e];return n||(n=Math.max(Math.pow(r*13.37,.9),29)*e,t[r+", "+e]=n,n)};var Bm,Mm,On={},cn={},RE,AE,si,Ku,Jn,ei,ni,Mn,Ki,ku,HA,KA,Lm,Om,PE,IE=function(e,t,n){n.x=t.x-e.x,n.y=t.y-e.y,n.len=Math.sqrt(n.x*n.x+n.y*n.y),n.nx=n.x/n.len,n.ny=n.y/n.len,n.ang=Math.atan2(n.ny,n.nx)},d3=function(e,t){t.x=e.x*-1,t.y=e.y*-1,t.nx=e.nx*-1,t.ny=e.ny*-1,t.ang=e.ang>0?-(Math.PI-e.ang):Math.PI+e.ang},v3=function(e,t,n,a,i){if(e!==PE?IE(t,e,On):d3(cn,On),IE(t,n,cn),RE=On.nx*cn.ny-On.ny*cn.nx,AE=On.nx*cn.nx-On.ny*-cn.ny,Jn=Math.asin(Math.max(-1,Math.min(1,RE))),Math.abs(Jn)<1e-6){Bm=t.x,Mm=t.y,ni=Ki=0;return}si=1,Ku=!1,AE<0?Jn<0?Jn=Math.PI+Jn:(Jn=Math.PI-Jn,si=-1,Ku=!0):Jn>0&&(si=-1,Ku=!0),t.radius!==void 0?Ki=t.radius:Ki=a,ei=Jn/2,ku=Math.min(On.len/2,cn.len/2),i?(Mn=Math.abs(Math.cos(ei)*Ki/Math.sin(ei)),Mn>ku?(Mn=ku,ni=Math.abs(Mn*Math.sin(ei)/Math.cos(ei))):ni=Ki):(Mn=Math.min(ku,Ki),ni=Math.abs(Mn*Math.sin(ei)/Math.cos(ei))),Lm=t.x+cn.nx*Mn,Om=t.y+cn.ny*Mn,Bm=Lm-cn.ny*ni*si,Mm=Om+cn.nx*ni*si,HA=t.x+On.nx*Mn,KA=t.y+On.ny*Mn,PE=t};function jA(r,e){e.radius===0?r.lineTo(e.cx,e.cy):r.arc(e.cx,e.cy,e.radius,e.startAngle,e.endAngle,e.counterClockwise)}function d0(r,e,t,n){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0;return n===0||e.radius===0?{cx:e.x,cy:e.y,radius:0,startX:e.x,startY:e.y,stopX:e.x,stopY:e.y,startAngle:void 0,endAngle:void 0,counterClockwise:void 0}:(v3(r,e,t,n,a),{cx:Bm,cy:Mm,radius:ni,startX:HA,startY:KA,stopX:Lm,stopY:Om,startAngle:On.ang+Math.PI/2*si,endAngle:cn.ang-Math.PI/2*si,counterClockwise:Ku})}var ms=.01,h3=Math.sqrt(2*ms),At={};At.findMidptPtsEtc=function(r,e){var t=e.posPts,n=e.intersectionPts,a=e.vectorNormInverse,i,o=r.pstyle("source-endpoint"),s=r.pstyle("target-endpoint"),u=o.units!=null&&s.units!=null,l=function(S,R,_,A){var P=A-R,I=_-S,D=Math.sqrt(I*I+P*P);return{x:-P/D,y:I/D}},f=r.pstyle("edge-distances").value;switch(f){case"node-position":i=t;break;case"intersection":i=n;break;case"endpoints":{if(u){var d=this.manualEndptToPx(r.source()[0],o),h=Zr(d,2),g=h[0],p=h[1],x=this.manualEndptToPx(r.target()[0],s),b=Zr(x,2),w=b[0],y=b[1],E={x1:g,y1:p,x2:w,y2:y};a=l(g,p,w,y),i=E}else Cr("Edge ".concat(r.id()," has edge-distances:endpoints specified without manual endpoints specified via source-endpoint and target-endpoint. Falling back on edge-distances:intersection (default).")),i=n;break}}return{midptPts:i,vectorNormInverse:a}};At.findHaystackPoints=function(r){for(var e=0;e<r.length;e++){var t=r[e],n=t._private,a=n.rscratch;if(!a.haystack){var i=Math.random()*2*Math.PI;a.source={x:Math.cos(i),y:Math.sin(i)},i=Math.random()*2*Math.PI,a.target={x:Math.cos(i),y:Math.sin(i)}}var o=n.source,s=n.target,u=o.position(),l=s.position(),f=o.width(),d=s.width(),h=o.height(),g=s.height(),p=t.pstyle("haystack-radius").value,x=p/2;a.haystackPts=a.allpts=[a.source.x*f*x+u.x,a.source.y*h*x+u.y,a.target.x*d*x+l.x,a.target.y*g*x+l.y],a.midX=(a.allpts[0]+a.allpts[2])/2,a.midY=(a.allpts[1]+a.allpts[3])/2,a.edgeType="haystack",a.haystack=!0,this.storeEdgeProjections(t),this.calculateArrowAngles(t),this.recalculateEdgeLabelProjections(t),this.calculateLabelAngles(t)}};At.findSegmentsPoints=function(r,e){var t=r._private.rscratch,n=r.pstyle("segment-weights"),a=r.pstyle("segment-distances"),i=r.pstyle("segment-radii"),o=r.pstyle("radius-type"),s=Math.min(n.pfValue.length,a.pfValue.length),u=i.pfValue[i.pfValue.length-1],l=o.pfValue[o.pfValue.length-1];t.edgeType="segments",t.segpts=[],t.radii=[],t.isArcRadius=[];for(var f=0;f<s;f++){var d=n.pfValue[f],h=a.pfValue[f],g=1-d,p=d,x=this.findMidptPtsEtc(r,e),b=x.midptPts,w=x.vectorNormInverse,y={x:b.x1*g+b.x2*p,y:b.y1*g+b.y2*p};t.segpts.push(y.x+w.x*h,y.y+w.y*h),t.radii.push(i.pfValue[f]!==void 0?i.pfValue[f]:u),t.isArcRadius.push((o.pfValue[f]!==void 0?o.pfValue[f]:l)==="arc-radius")}};At.findLoopPoints=function(r,e,t,n){var a=r._private.rscratch,i=e.dirCounts,o=e.srcPos,s=r.pstyle("control-point-distances"),u=s?s.pfValue[0]:void 0,l=r.pstyle("loop-direction").pfValue,f=r.pstyle("loop-sweep").pfValue,d=r.pstyle("control-point-step-size").pfValue;a.edgeType="self";var h=t,g=d;n&&(h=0,g=u);var p=l-Math.PI/2,x=p-f/2,b=p+f/2,w=l+"_"+f;h=i[w]===void 0?i[w]=0:++i[w],a.ctrlpts=[o.x+Math.cos(x)*1.4*g*(h/3+1),o.y+Math.sin(x)*1.4*g*(h/3+1),o.x+Math.cos(b)*1.4*g*(h/3+1),o.y+Math.sin(b)*1.4*g*(h/3+1)]};At.findCompoundLoopPoints=function(r,e,t,n){var a=r._private.rscratch;a.edgeType="compound";var i=e.srcPos,o=e.tgtPos,s=e.srcW,u=e.srcH,l=e.tgtW,f=e.tgtH,d=r.pstyle("control-point-step-size").pfValue,h=r.pstyle("control-point-distances"),g=h?h.pfValue[0]:void 0,p=t,x=d;n&&(p=0,x=g);var b=50,w={x:i.x-s/2,y:i.y-u/2},y={x:o.x-l/2,y:o.y-f/2},E={x:Math.min(w.x,y.x),y:Math.min(w.y,y.y)},C=.5,S=Math.max(C,Math.log(s*ms)),R=Math.max(C,Math.log(l*ms));a.ctrlpts=[E.x,E.y-(1+Math.pow(b,1.12)/100)*x*(p/3+1)*S,E.x-(1+Math.pow(b,1.12)/100)*x*(p/3+1)*R,E.y]};At.findStraightEdgePoints=function(r){r._private.rscratch.edgeType="straight"};At.findBezierPoints=function(r,e,t,n,a){var i=r._private.rscratch,o=r.pstyle("control-point-step-size").pfValue,s=r.pstyle("control-point-distances"),u=r.pstyle("control-point-weights"),l=s&&u?Math.min(s.value.length,u.value.length):1,f=s?s.pfValue[0]:void 0,d=u.value[0],h=n;i.edgeType=h?"multibezier":"bezier",i.ctrlpts=[];for(var g=0;g<l;g++){var p=(.5-e.eles.length/2+t)*o*(a?-1:1),x=void 0,b=Jm(p);h&&(f=s?s.pfValue[g]:o,d=u.value[g]),n?x=f:x=f!==void 0?b*f:void 0;var w=x!==void 0?x:p,y=1-d,E=d,C=this.findMidptPtsEtc(r,e),S=C.midptPts,R=C.vectorNormInverse,_={x:S.x1*y+S.x2*E,y:S.y1*y+S.y2*E};i.ctrlpts.push(_.x+R.x*w,_.y+R.y*w)}};At.findTaxiPoints=function(r,e){var t=r._private.rscratch;t.edgeType="segments";var n="vertical",a="horizontal",i="leftward",o="rightward",s="downward",u="upward",l="auto",f=e.posPts,d=e.srcW,h=e.srcH,g=e.tgtW,p=e.tgtH,x=r.pstyle("edge-distances").value,b=x!=="node-position",w=r.pstyle("taxi-direction").value,y=w,E=r.pstyle("taxi-turn"),C=E.units==="%",S=E.pfValue,R=S<0,_=r.pstyle("taxi-turn-min-distance").pfValue,A=b?(d+g)/2:0,P=b?(h+p)/2:0,I=f.x2-f.x1,D=f.y2-f.y1,L=function(O,ne){return O>0?Math.max(O-ne,0):Math.min(O+ne,0)},M=L(I,A),q=L(D,P),N=!1;y===l?w=Math.abs(M)>Math.abs(q)?a:n:y===u||y===s?(w=n,N=!0):(y===i||y===o)&&(w=a,N=!0);var W=w===n,V=W?q:M,$=W?D:I,Z=Jm($),ee=!1;!(N&&(C||R))&&(y===s&&$<0||y===u&&$>0||y===i&&$>0||y===o&&$<0)&&(Z*=-1,V=Z*Math.abs(V),ee=!0);var K;if(C){var j=S<0?1+S:S;K=j*V}else{var fe=S<0?V:0;K=fe+S*Z}var G=function(O){return Math.abs(O)<_||Math.abs(O)>=Math.abs(V)},z=G(K),Y=G(Math.abs(V)-Math.abs(K)),te=z||Y;if(te&&!ee)if(W){var ue=Math.abs($)<=h/2,oe=Math.abs(I)<=g/2;if(ue){var X=(f.x1+f.x2)/2,Q=f.y1,ie=f.y2;t.segpts=[X,Q,X,ie]}else if(oe){var de=(f.y1+f.y2)/2,we=f.x1,Ae=f.x2;t.segpts=[we,de,Ae,de]}else t.segpts=[f.x1,f.y2]}else{var ve=Math.abs($)<=d/2,le=Math.abs(D)<=p/2;if(ve){var Me=(f.y1+f.y2)/2,Se=f.x1,Ee=f.x2;t.segpts=[Se,Me,Ee,Me]}else if(le){var re=(f.x1+f.x2)/2,ce=f.y1,_e=f.y2;t.segpts=[re,ce,re,_e]}else t.segpts=[f.x2,f.y1]}else if(W){var me=f.y1+K+(b?h/2*Z:0),Te=f.x1,De=f.x2;t.segpts=[Te,me,De,me]}else{var Ne=f.x1+K+(b?d/2*Z:0),ze=f.y1,$e=f.y2;t.segpts=[Ne,ze,Ne,$e]}if(t.isRound){var ke=r.pstyle("taxi-radius").value,Oe=r.pstyle("radius-type").value[0]==="arc-radius";t.radii=new Array(t.segpts.length/2).fill(ke),t.isArcRadius=new Array(t.segpts.length/2).fill(Oe)}};At.tryToCorrectInvalidPoints=function(r,e){var t=r._private.rscratch;if(t.edgeType==="bezier"){var n=e.srcPos,a=e.tgtPos,i=e.srcW,o=e.srcH,s=e.tgtW,u=e.tgtH,l=e.srcShape,f=e.tgtShape,d=e.srcCornerRadius,h=e.tgtCornerRadius,g=e.srcRs,p=e.tgtRs,x=!qe(t.startX)||!qe(t.startY),b=!qe(t.arrowStartX)||!qe(t.arrowStartY),w=!qe(t.endX)||!qe(t.endY),y=!qe(t.arrowEndX)||!qe(t.arrowEndY),E=3,C=this.getArrowWidth(r.pstyle("width").pfValue,r.pstyle("arrow-scale").value)*this.arrowShapeWidth,S=E*C,R=di({x:t.ctrlpts[0],y:t.ctrlpts[1]},{x:t.startX,y:t.startY}),_=R<S,A=di({x:t.ctrlpts[0],y:t.ctrlpts[1]},{x:t.endX,y:t.endY}),P=A<S,I=!1;if(x||b||_){I=!0;var D={x:t.ctrlpts[0]-n.x,y:t.ctrlpts[1]-n.y},L=Math.sqrt(D.x*D.x+D.y*D.y),M={x:D.x/L,y:D.y/L},q=Math.max(i,o),N={x:t.ctrlpts[0]+M.x*2*q,y:t.ctrlpts[1]+M.y*2*q},W=l.intersectLine(n.x,n.y,i,o,N.x,N.y,0,d,g);_?(t.ctrlpts[0]=t.ctrlpts[0]+M.x*(S-R),t.ctrlpts[1]=t.ctrlpts[1]+M.y*(S-R)):(t.ctrlpts[0]=W[0]+M.x*S,t.ctrlpts[1]=W[1]+M.y*S)}if(w||y||P){I=!0;var V={x:t.ctrlpts[0]-a.x,y:t.ctrlpts[1]-a.y},$=Math.sqrt(V.x*V.x+V.y*V.y),Z={x:V.x/$,y:V.y/$},ee=Math.max(i,o),K={x:t.ctrlpts[0]+Z.x*2*ee,y:t.ctrlpts[1]+Z.y*2*ee},j=f.intersectLine(a.x,a.y,s,u,K.x,K.y,0,h,p);P?(t.ctrlpts[0]=t.ctrlpts[0]+Z.x*(S-A),t.ctrlpts[1]=t.ctrlpts[1]+Z.y*(S-A)):(t.ctrlpts[0]=j[0]+Z.x*S,t.ctrlpts[1]=j[1]+Z.y*S)}I&&this.findEndpoints(r)}};At.storeAllpts=function(r){var e=r._private.rscratch;if(e.edgeType==="multibezier"||e.edgeType==="bezier"||e.edgeType==="self"||e.edgeType==="compound"){e.allpts=[],e.allpts.push(e.startX,e.startY);for(var t=0;t+1<e.ctrlpts.length;t+=2)e.allpts.push(e.ctrlpts[t],e.ctrlpts[t+1]),t+3<e.ctrlpts.length&&e.allpts.push((e.ctrlpts[t]+e.ctrlpts[t+2])/2,(e.ctrlpts[t+1]+e.ctrlpts[t+3])/2);e.allpts.push(e.endX,e.endY);var n,a;e.ctrlpts.length/2%2===0?(n=e.allpts.length/2-1,e.midX=e.allpts[n],e.midY=e.allpts[n+1]):(n=e.allpts.length/2-3,a=.5,e.midX=ut(e.allpts[n],e.allpts[n+2],e.allpts[n+4],a),e.midY=ut(e.allpts[n+1],e.allpts[n+3],e.allpts[n+5],a))}else if(e.edgeType==="straight")e.allpts=[e.startX,e.startY,e.endX,e.endY],e.midX=(e.startX+e.endX+e.arrowStartX+e.arrowEndX)/4,e.midY=(e.startY+e.endY+e.arrowStartY+e.arrowEndY)/4;else if(e.edgeType==="segments"){if(e.allpts=[],e.allpts.push(e.startX,e.startY),e.allpts.push.apply(e.allpts,e.segpts),e.allpts.push(e.endX,e.endY),e.isRound){e.roundCorners=[];for(var i=2;i+3<e.allpts.length;i+=2){var o=e.radii[i/2-1],s=e.isArcRadius[i/2-1];e.roundCorners.push(d0({x:e.allpts[i-2],y:e.allpts[i-1]},{x:e.allpts[i],y:e.allpts[i+1],radius:o},{x:e.allpts[i+2],y:e.allpts[i+3]},o,s))}}if(e.segpts.length%4===0){var u=e.segpts.length/2,l=u-2;e.midX=(e.segpts[l]+e.segpts[u])/2,e.midY=(e.segpts[l+1]+e.segpts[u+1])/2}else{var f=e.segpts.length/2-1;if(!e.isRound)e.midX=e.segpts[f],e.midY=e.segpts[f+1];else{var d={x:e.segpts[f],y:e.segpts[f+1]},h=e.roundCorners[f/2];if(h.radius===0){var g={x:e.segpts[f+2],y:e.segpts[f+3]};e.midX=d.x,e.midY=d.y,e.midVector=[d.y-g.y,g.x-d.x]}else{var p=[d.x-h.cx,d.y-h.cy],x=h.radius/Math.sqrt(Math.pow(p[0],2)+Math.pow(p[1],2));p=p.map(function(b){return b*x}),e.midX=h.cx+p[0],e.midY=h.cy+p[1],e.midVector=p}}}}};At.checkForInvalidEdgeWarning=function(r){var e=r[0]._private.rscratch;e.nodesOverlap||qe(e.startX)&&qe(e.startY)&&qe(e.endX)&&qe(e.endY)?e.loggedErr=!1:e.loggedErr||(e.loggedErr=!0,Cr("Edge `"+r.id()+"` has invalid endpoints and so it is impossible to draw. Adjust your edge style (e.g. control points) accordingly or use an alternative edge type. This is expected behaviour when the source node and the target node overlap."))};At.findEdgeControlPoints=function(r){var e=this;if(!(!r||r.length===0)){for(var t=this,n=t.cy,a=n.hasCompoundNodes(),i=new ra,o=function(P,I){return[].concat(el(P),[I?1:0]).join("-")},s=[],u=[],l=0;l<r.length;l++){var f=r[l],d=f._private,h=f.pstyle("curve-style").value;if(!(f.removed()||!f.takesUpSpace())){if(h==="haystack"){u.push(f);continue}var g=h==="unbundled-bezier"||_a(h,"segments")||h==="straight"||h==="straight-triangle"||_a(h,"taxi"),p=h==="unbundled-bezier"||h==="bezier",x=d.source,b=d.target,w=x.poolIndex(),y=b.poolIndex(),E=[w,y].sort(),C=o(E,g),S=i.get(C);S==null&&(S={eles:[]},s.push({pairId:E,edgeIsUnbundled:g}),i.set(C,S)),S.eles.push(f),g&&(S.hasUnbundled=!0),p&&(S.hasBezier=!0)}}for(var R=function(){var P=s[_],I=P.pairId,D=P.edgeIsUnbundled,L=o(I,D),M=i.get(L),q;if(!M.hasUnbundled){var N=M.eles[0].parallelEdges().filter(function(Oe){return Oe.isBundledBezier()});Xm(M.eles),N.forEach(function(Oe){return M.eles.push(Oe)}),M.eles.sort(function(Oe,ye){return Oe.poolIndex()-ye.poolIndex()})}var W=M.eles[0],V=W.source(),$=W.target();if(V.poolIndex()>$.poolIndex()){var Z=V;V=$,$=Z}var ee=M.srcPos=V.position(),K=M.tgtPos=$.position(),j=M.srcW=V.outerWidth(),fe=M.srcH=V.outerHeight(),G=M.tgtW=$.outerWidth(),z=M.tgtH=$.outerHeight(),Y=M.srcShape=t.nodeShapes[e.getNodeShape(V)],te=M.tgtShape=t.nodeShapes[e.getNodeShape($)],ue=M.srcCornerRadius=V.pstyle("corner-radius").value==="auto"?"auto":V.pstyle("corner-radius").pfValue,oe=M.tgtCornerRadius=$.pstyle("corner-radius").value==="auto"?"auto":$.pstyle("corner-radius").pfValue,X=M.tgtRs=$._private.rscratch,Q=M.srcRs=V._private.rscratch;M.dirCounts={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0};for(var ie=0;ie<M.eles.length;ie++){var de=M.eles[ie],we=de[0]._private.rscratch,Ae=de.pstyle("curve-style").value,ve=Ae==="unbundled-bezier"||_a(Ae,"segments")||_a(Ae,"taxi"),le=!V.same(de.source());if(!M.calculatedIntersection&&V!==$&&(M.hasBezier||M.hasUnbundled)){M.calculatedIntersection=!0;var Me=Y.intersectLine(ee.x,ee.y,j,fe,K.x,K.y,0,ue,Q),Se=M.srcIntn=Me,Ee=te.intersectLine(K.x,K.y,G,z,ee.x,ee.y,0,oe,X),re=M.tgtIntn=Ee,ce=M.intersectionPts={x1:Me[0],x2:Ee[0],y1:Me[1],y2:Ee[1]},_e=M.posPts={x1:ee.x,x2:K.x,y1:ee.y,y2:K.y},me=Ee[1]-Me[1],Te=Ee[0]-Me[0],De=Math.sqrt(Te*Te+me*me);qe(De)&&De>=h3||(De=Math.sqrt(Math.max(Te*Te,ms)+Math.max(me*me,ms)));var Ne=M.vector={x:Te,y:me},ze=M.vectorNorm={x:Ne.x/De,y:Ne.y/De},$e={x:-ze.y,y:ze.x};M.nodesOverlap=!qe(De)||te.checkPoint(Me[0],Me[1],0,G,z,K.x,K.y,oe,X)||Y.checkPoint(Ee[0],Ee[1],0,j,fe,ee.x,ee.y,ue,Q),M.vectorNormInverse=$e,q={nodesOverlap:M.nodesOverlap,dirCounts:M.dirCounts,calculatedIntersection:!0,hasBezier:M.hasBezier,hasUnbundled:M.hasUnbundled,eles:M.eles,srcPos:K,srcRs:X,tgtPos:ee,tgtRs:Q,srcW:G,srcH:z,tgtW:j,tgtH:fe,srcIntn:re,tgtIntn:Se,srcShape:te,tgtShape:Y,posPts:{x1:_e.x2,y1:_e.y2,x2:_e.x1,y2:_e.y1},intersectionPts:{x1:ce.x2,y1:ce.y2,x2:ce.x1,y2:ce.y1},vector:{x:-Ne.x,y:-Ne.y},vectorNorm:{x:-ze.x,y:-ze.y},vectorNormInverse:{x:-$e.x,y:-$e.y}}}var ke=le?q:M;we.nodesOverlap=ke.nodesOverlap,we.srcIntn=ke.srcIntn,we.tgtIntn=ke.tgtIntn,we.isRound=Ae.startsWith("round"),a&&(V.isParent()||V.isChild()||$.isParent()||$.isChild())&&(V.parents().anySame($)||$.parents().anySame(V)||V.same($)&&V.isParent())?e.findCompoundLoopPoints(de,ke,ie,ve):V===$?e.findLoopPoints(de,ke,ie,ve):Ae.endsWith("segments")?e.findSegmentsPoints(de,ke):Ae.endsWith("taxi")?e.findTaxiPoints(de,ke):Ae==="straight"||!ve&&M.eles.length%2===1&&ie===Math.floor(M.eles.length/2)?e.findStraightEdgePoints(de):e.findBezierPoints(de,ke,ie,ve,le),e.findEndpoints(de),e.tryToCorrectInvalidPoints(de,ke),e.checkForInvalidEdgeWarning(de),e.storeAllpts(de),e.storeEdgeProjections(de),e.calculateArrowAngles(de),e.recalculateEdgeLabelProjections(de),e.calculateLabelAngles(de)}},_=0;_<s.length;_++)R();this.findHaystackPoints(u)}};function YA(r){var e=[];if(r!=null){for(var t=0;t<r.length;t+=2){var n=r[t],a=r[t+1];e.push({x:n,y:a})}return e}}At.getSegmentPoints=function(r){var e=r[0]._private.rscratch;this.recalculateRenderedStyle(r);var t=e.edgeType;if(t==="segments")return YA(e.segpts)};At.getControlPoints=function(r){var e=r[0]._private.rscratch;this.recalculateRenderedStyle(r);var t=e.edgeType;if(t==="bezier"||t==="multibezier"||t==="self"||t==="compound")return YA(e.ctrlpts)};At.getEdgeMidpoint=function(r){var e=r[0]._private.rscratch;return this.recalculateRenderedStyle(r),{x:e.midX,y:e.midY}};var Ps={};Ps.manualEndptToPx=function(r,e){var t=this,n=r.position(),a=r.outerWidth(),i=r.outerHeight(),o=r._private.rscratch;if(e.value.length===2){var s=[e.pfValue[0],e.pfValue[1]];return e.units[0]==="%"&&(s[0]=s[0]*a),e.units[1]==="%"&&(s[1]=s[1]*i),s[0]+=n.x,s[1]+=n.y,s}else{var u=e.pfValue[0];u=-Math.PI/2+u;var l=2*Math.max(a,i),f=[n.x+Math.cos(u)*l,n.y+Math.sin(u)*l];return t.nodeShapes[this.getNodeShape(r)].intersectLine(n.x,n.y,a,i,f[0],f[1],0,r.pstyle("corner-radius").value==="auto"?"auto":r.pstyle("corner-radius").pfValue,o)}};Ps.findEndpoints=function(r){var e,t,n,a,i=this,o,s=r.source()[0],u=r.target()[0],l=s.position(),f=u.position(),d=r.pstyle("target-arrow-shape").value,h=r.pstyle("source-arrow-shape").value,g=r.pstyle("target-distance-from-node").pfValue,p=r.pstyle("source-distance-from-node").pfValue,x=s._private.rscratch,b=u._private.rscratch,w=r.pstyle("curve-style").value,y=r._private.rscratch,E=y.edgeType,C=_a(w,"taxi"),S=E==="self"||E==="compound",R=E==="bezier"||E==="multibezier"||S,_=E!=="bezier",A=E==="straight"||E==="segments",P=E==="segments",I=R||_||A,D=S||C,L=r.pstyle("source-endpoint"),M=D?"outside-to-node":L.value,q=s.pstyle("corner-radius").value==="auto"?"auto":s.pstyle("corner-radius").pfValue,N=r.pstyle("target-endpoint"),W=D?"outside-to-node":N.value,V=u.pstyle("corner-radius").value==="auto"?"auto":u.pstyle("corner-radius").pfValue;y.srcManEndpt=L,y.tgtManEndpt=N;var $,Z,ee,K,j=(e=(N==null||(t=N.pfValue)===null||t===void 0?void 0:t.length)===2?N.pfValue:null)!==null&&e!==void 0?e:[0,0],fe=(n=(L==null||(a=L.pfValue)===null||a===void 0?void 0:a.length)===2?L.pfValue:null)!==null&&n!==void 0?n:[0,0];if(R){var G=[y.ctrlpts[0],y.ctrlpts[1]],z=_?[y.ctrlpts[y.ctrlpts.length-2],y.ctrlpts[y.ctrlpts.length-1]]:G;$=z,Z=G}else if(A){var Y=P?y.segpts.slice(0,2):[f.x+j[0],f.y+j[1]],te=P?y.segpts.slice(y.segpts.length-2):[l.x+fe[0],l.y+fe[1]];$=te,Z=Y}if(W==="inside-to-node")o=[f.x,f.y];else if(N.units)o=this.manualEndptToPx(u,N);else if(W==="outside-to-line")o=y.tgtIntn;else if(W==="outside-to-node"||W==="outside-to-node-or-label"?ee=$:(W==="outside-to-line"||W==="outside-to-line-or-label")&&(ee=[l.x,l.y]),o=i.nodeShapes[this.getNodeShape(u)].intersectLine(f.x,f.y,u.outerWidth(),u.outerHeight(),ee[0],ee[1],0,V,b),W==="outside-to-node-or-label"||W==="outside-to-line-or-label"){var ue=u._private.rscratch,oe=ue.labelWidth,X=ue.labelHeight,Q=ue.labelX,ie=ue.labelY,de=oe/2,we=X/2,Ae=u.pstyle("text-valign").value;Ae==="top"?ie-=we:Ae==="bottom"&&(ie+=we);var ve=u.pstyle("text-halign").value;ve==="left"?Q-=de:ve==="right"&&(Q+=de);var le=vs(ee[0],ee[1],[Q-de,ie-we,Q+de,ie-we,Q+de,ie+we,Q-de,ie+we],f.x,f.y);if(le.length>0){var Me=l,Se=ti(Me,Ji(o)),Ee=ti(Me,Ji(le)),re=Se;if(Ee<Se&&(o=le,re=Ee),le.length>2){var ce=ti(Me,{x:le[2],y:le[3]});ce<re&&(o=[le[2],le[3]])}}}var _e=Pu(o,$,i.arrowShapes[d].spacing(r)+g),me=Pu(o,$,i.arrowShapes[d].gap(r)+g);if(y.endX=me[0],y.endY=me[1],y.arrowEndX=_e[0],y.arrowEndY=_e[1],M==="inside-to-node")o=[l.x,l.y];else if(L.units)o=this.manualEndptToPx(s,L);else if(M==="outside-to-line")o=y.srcIntn;else if(M==="outside-to-node"||M==="outside-to-node-or-label"?K=Z:(M==="outside-to-line"||M==="outside-to-line-or-label")&&(K=[f.x,f.y]),o=i.nodeShapes[this.getNodeShape(s)].intersectLine(l.x,l.y,s.outerWidth(),s.outerHeight(),K[0],K[1],0,q,x),M==="outside-to-node-or-label"||M==="outside-to-line-or-label"){var Te=s._private.rscratch,De=Te.labelWidth,Ne=Te.labelHeight,ze=Te.labelX,$e=Te.labelY,ke=De/2,Oe=Ne/2,ye=s.pstyle("text-valign").value;ye==="top"?$e-=Oe:ye==="bottom"&&($e+=Oe);var O=s.pstyle("text-halign").value;O==="left"?ze-=ke:O==="right"&&(ze+=ke);var ne=vs(K[0],K[1],[ze-ke,$e-Oe,ze+ke,$e-Oe,ze+ke,$e+Oe,ze-ke,$e+Oe],l.x,l.y);if(ne.length>0){var he=f,ge=ti(he,Ji(o)),be=ti(he,Ji(ne)),Ve=ge;if(be<ge&&(o=[ne[0],ne[1]],Ve=be),ne.length>2){var Be=ti(he,{x:ne[2],y:ne[3]});Be<Ve&&(o=[ne[2],ne[3]])}}}var He=Pu(o,Z,i.arrowShapes[h].spacing(r)+p),We=Pu(o,Z,i.arrowShapes[h].gap(r)+p);y.startX=We[0],y.startY=We[1],y.arrowStartX=He[0],y.arrowStartY=He[1],I&&(!qe(y.startX)||!qe(y.startY)||!qe(y.endX)||!qe(y.endY)?y.badLine=!0:y.badLine=!1)};Ps.getSourceEndpoint=function(r){var e=r[0]._private.rscratch;switch(this.recalculateRenderedStyle(r),e.edgeType){case"haystack":return{x:e.haystackPts[0],y:e.haystackPts[1]};default:return{x:e.arrowStartX,y:e.arrowStartY}}};Ps.getTargetEndpoint=function(r){var e=r[0]._private.rscratch;switch(this.recalculateRenderedStyle(r),e.edgeType){case"haystack":return{x:e.haystackPts[2],y:e.haystackPts[3]};default:return{x:e.arrowEndX,y:e.arrowEndY}}};var v0={};function g3(r,e,t){for(var n=function(l,f,d,h){return ut(l,f,d,h)},a=e._private,i=a.rstyle.bezierPts,o=0;o<r.bezierProjPcts.length;o++){var s=r.bezierProjPcts[o];i.push({x:n(t[0],t[2],t[4],s),y:n(t[1],t[3],t[5],s)})}}v0.storeEdgeProjections=function(r){var e=r._private,t=e.rscratch,n=t.edgeType;if(e.rstyle.bezierPts=null,e.rstyle.linePts=null,e.rstyle.haystackPts=null,n==="multibezier"||n==="bezier"||n==="self"||n==="compound"){e.rstyle.bezierPts=[];for(var a=0;a+5<t.allpts.length;a+=4)g3(this,r,t.allpts.slice(a,a+6))}else if(n==="segments")for(var i=e.rstyle.linePts=[],a=0;a+1<t.allpts.length;a+=2)i.push({x:t.allpts[a],y:t.allpts[a+1]});else if(n==="haystack"){var o=t.haystackPts;e.rstyle.haystackPts=[{x:o[0],y:o[1]},{x:o[2],y:o[3]}]}e.rstyle.arrowWidth=this.getArrowWidth(r.pstyle("width").pfValue,r.pstyle("arrow-scale").value)*this.arrowShapeWidth};v0.recalculateEdgeProjections=function(r){this.findEdgeControlPoints(r)};var $n={};$n.recalculateNodeLabelProjection=function(r){var e=r.pstyle("label").strValue;if(!Da(e)){var t,n,a=r._private,i=r.width(),o=r.height(),s=r.padding(),u=r.position(),l=r.pstyle("text-halign").strValue,f=r.pstyle("text-valign").strValue,d=a.rscratch,h=a.rstyle;switch(l){case"left":t=u.x-i/2-s;break;case"right":t=u.x+i/2+s;break;default:t=u.x}switch(f){case"top":n=u.y-o/2-s;break;case"bottom":n=u.y+o/2+s;break;default:n=u.y}d.labelX=t,d.labelY=n,h.labelX=t,h.labelY=n,this.calculateLabelAngles(r),this.applyLabelDimensions(r)}};var ZA=function(e,t){var n=Math.atan(t/e);return e===0&&n<0&&(n=n*-1),n},XA=function(e,t){var n=t.x-e.x,a=t.y-e.y;return ZA(n,a)},p3=function(e,t,n,a){var i=ds(0,a-.001,1),o=ds(0,a+.001,1),s=io(e,t,n,i),u=io(e,t,n,o);return XA(s,u)};$n.recalculateEdgeLabelProjections=function(r){var e,t=r._private,n=t.rscratch,a=this,i={mid:r.pstyle("label").strValue,source:r.pstyle("source-label").strValue,target:r.pstyle("target-label").strValue};if(i.mid||i.source||i.target){e={x:n.midX,y:n.midY};var o=function(d,h,g){ea(t.rscratch,d,h,g),ea(t.rstyle,d,h,g)};o("labelX",null,e.x),o("labelY",null,e.y);var s=ZA(n.midDispX,n.midDispY);o("labelAutoAngle",null,s);var u=function(){if(u.cache)return u.cache;for(var d=[],h=0;h+5<n.allpts.length;h+=4){var g={x:n.allpts[h],y:n.allpts[h+1]},p={x:n.allpts[h+2],y:n.allpts[h+3]},x={x:n.allpts[h+4],y:n.allpts[h+5]};d.push({p0:g,p1:p,p2:x,startDist:0,length:0,segments:[]})}var b=t.rstyle.bezierPts,w=a.bezierProjPcts.length;function y(_,A,P,I,D){var L=di(A,P),M=_.segments[_.segments.length-1],q={p0:A,p1:P,t0:I,t1:D,startDist:M?M.startDist+M.length:0,length:L};_.segments.push(q),_.length+=L}for(var E=0;E<d.length;E++){var C=d[E],S=d[E-1];S&&(C.startDist=S.startDist+S.length),y(C,C.p0,b[E*w],0,a.bezierProjPcts[0]);for(var R=0;R<w-1;R++)y(C,b[E*w+R],b[E*w+R+1],a.bezierProjPcts[R],a.bezierProjPcts[R+1]);y(C,b[E*w+w-1],C.p2,a.bezierProjPcts[w-1],1)}return u.cache=d},l=function(d){var h,g=d==="source";if(i[d]){var p=r.pstyle(d+"-text-offset").pfValue;switch(n.edgeType){case"self":case"compound":case"bezier":case"multibezier":{for(var x=u(),b,w=0,y=0,E=0;E<x.length;E++){for(var C=x[g?E:x.length-1-E],S=0;S<C.segments.length;S++){var R=C.segments[g?S:C.segments.length-1-S],_=E===x.length-1&&S===C.segments.length-1;if(w=y,y+=R.length,y>=p||_){b={cp:C,segment:R};break}}if(b)break}var A=b.cp,P=b.segment,I=(p-w)/P.length,D=P.t1-P.t0,L=g?P.t0+D*I:P.t1-D*I;L=ds(0,L,1),e=io(A.p0,A.p1,A.p2,L),h=p3(A.p0,A.p1,A.p2,L);break}case"straight":case"segments":case"haystack":{for(var M=0,q,N,W,V,$=n.allpts.length,Z=0;Z+3<$&&(g?(W={x:n.allpts[Z],y:n.allpts[Z+1]},V={x:n.allpts[Z+2],y:n.allpts[Z+3]}):(W={x:n.allpts[$-2-Z],y:n.allpts[$-1-Z]},V={x:n.allpts[$-4-Z],y:n.allpts[$-3-Z]}),q=di(W,V),N=M,M+=q,!(M>=p));Z+=2);var ee=p-N,K=ee/q;K=ds(0,K,1),e=NF(W,V,K),h=XA(W,V);break}}o("labelX",d,e.x),o("labelY",d,e.y),o("labelAutoAngle",d,h)}};l("source"),l("target"),this.applyLabelDimensions(r)}};$n.applyLabelDimensions=function(r){this.applyPrefixedLabelDimensions(r),r.isEdge()&&(this.applyPrefixedLabelDimensions(r,"source"),this.applyPrefixedLabelDimensions(r,"target"))};$n.applyPrefixedLabelDimensions=function(r,e){var t=r._private,n=this.getLabelText(r,e),a=ci(n,r._private.labelDimsKey);if($t(t.rscratch,"prefixedLabelDimsKey",e)!==a){ea(t.rscratch,"prefixedLabelDimsKey",e,a);var i=this.calculateLabelDimensions(r,n),o=r.pstyle("line-height").pfValue,s=r.pstyle("text-wrap").strValue,u=$t(t.rscratch,"labelWrapCachedLines",e)||[],l=s!=="wrap"?1:Math.max(u.length,1),f=i.height/l,d=f*o,h=i.width,g=i.height+(l-1)*(o-1)*f;ea(t.rstyle,"labelWidth",e,h),ea(t.rscratch,"labelWidth",e,h),ea(t.rstyle,"labelHeight",e,g),ea(t.rscratch,"labelHeight",e,g),ea(t.rscratch,"labelLineHeight",e,d)}};$n.getLabelText=function(r,e){var t=r._private,n=e?e+"-":"",a=r.pstyle(n+"label").strValue,i=r.pstyle("text-transform").value,o=function(fe,G){return G?(ea(t.rscratch,fe,e,G),G):$t(t.rscratch,fe,e)};if(!a)return"";i=="none"||(i=="uppercase"?a=a.toUpperCase():i=="lowercase"&&(a=a.toLowerCase()));var s=r.pstyle("text-wrap").value;if(s==="wrap"){var u=o("labelKey");if(u!=null&&o("labelWrapKey")===u)return o("labelWrapCachedText");for(var l="​",f=a.split(`
41
- `),d=r.pstyle("text-max-width").pfValue,h=r.pstyle("text-overflow-wrap").value,g=h==="anywhere",p=[],x=/[\s\u200b]+|$/g,b=0;b<f.length;b++){var w=f[b],y=this.calculateLabelDimensions(r,w),E=y.width;if(g){var C=w.split("").join(l);w=C}if(E>d){var S=w.matchAll(x),R="",_=0,A=Gt(S),P;try{for(A.s();!(P=A.n()).done;){var I=P.value,D=I[0],L=w.substring(_,I.index);_=I.index+D.length;var M=R.length===0?L:R+L+D,q=this.calculateLabelDimensions(r,M),N=q.width;N<=d?R+=L+D:(R&&p.push(R),R=L+D)}}catch(j){A.e(j)}finally{A.f()}R.match(/^[\s\u200b]+$/)||p.push(R)}else p.push(w)}o("labelWrapCachedLines",p),a=o("labelWrapCachedText",p.join(`
42
- `)),o("labelWrapKey",u)}else if(s==="ellipsis"){var W=r.pstyle("text-max-width").pfValue,V="",$="…",Z=!1;if(this.calculateLabelDimensions(r,a).width<W)return a;for(var ee=0;ee<a.length;ee++){var K=this.calculateLabelDimensions(r,V+a[ee]+$).width;if(K>W)break;V+=a[ee],ee===a.length-1&&(Z=!0)}return Z||(V+=$),V}return a};$n.getLabelJustification=function(r){var e=r.pstyle("text-justification").strValue,t=r.pstyle("text-halign").strValue;if(e==="auto")if(r.isNode())switch(t){case"left":return"right";case"right":return"left";default:return"center"}else return"center";else return e};$n.calculateLabelDimensions=function(r,e){var t=this,n=t.cy.window(),a=n.document,i=0,o=r.pstyle("font-style").strValue,s=r.pstyle("font-size").pfValue,u=r.pstyle("font-family").strValue,l=r.pstyle("font-weight").strValue,f=this.labelCalcCanvas,d=this.labelCalcCanvasContext;if(!f){f=this.labelCalcCanvas=a.createElement("canvas"),d=this.labelCalcCanvasContext=f.getContext("2d");var h=f.style;h.position="absolute",h.left="-9999px",h.top="-9999px",h.zIndex="-1",h.visibility="hidden",h.pointerEvents="none"}d.font="".concat(o," ").concat(l," ").concat(s,"px ").concat(u);for(var g=0,p=0,x=e.split(`
43
- `),b=0;b<x.length;b++){var w=x[b],y=d.measureText(w),E=Math.ceil(y.width),C=s;g=Math.max(E,g),p+=C}return g+=i,p+=i,{width:g,height:p}};$n.calculateLabelAngle=function(r,e){var t=r._private,n=t.rscratch,a=r.isEdge(),i=e?e+"-":"",o=r.pstyle(i+"text-rotation"),s=o.strValue;return s==="none"?0:a&&s==="autorotate"?n.labelAutoAngle:s==="autorotate"?0:o.pfValue};$n.calculateLabelAngles=function(r){var e=this,t=r.isEdge(),n=r._private,a=n.rscratch;a.labelAngle=e.calculateLabelAngle(r),t&&(a.sourceLabelAngle=e.calculateLabelAngle(r,"source"),a.targetLabelAngle=e.calculateLabelAngle(r,"target"))};var QA={},DE=28,BE=!1;QA.getNodeShape=function(r){var e=this,t=r.pstyle("shape").value;if(t==="cutrectangle"&&(r.width()<DE||r.height()<DE))return BE||(Cr("The `cutrectangle` node shape can not be used at small sizes so `rectangle` is used instead"),BE=!0),"rectangle";if(r.isParent())return t==="rectangle"||t==="roundrectangle"||t==="round-rectangle"||t==="cutrectangle"||t==="cut-rectangle"||t==="barrel"?t:"rectangle";if(t==="polygon"){var n=r.pstyle("shape-polygon-points").value;return e.nodeShapes.makePolygon(n).name}return t};var Ol={};Ol.registerCalculationListeners=function(){var r=this.cy,e=r.collection(),t=this,n=function(o){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(e.merge(o),s)for(var u=0;u<o.length;u++){var l=o[u],f=l._private,d=f.rstyle;d.clean=!1,d.cleanConnected=!1}};t.binder(r).on("bounds.* dirty.*",function(o){var s=o.target;n(s)}).on("style.* background.*",function(o){var s=o.target;n(s,!1)});var a=function(o){if(o){var s=t.onUpdateEleCalcsFns;e.cleanStyle();for(var u=0;u<e.length;u++){var l=e[u],f=l._private.rstyle;l.isNode()&&!f.cleanConnected&&(n(l.connectedEdges()),f.cleanConnected=!0)}if(s)for(var d=0;d<s.length;d++){var h=s[d];h(o,e)}t.recalculateRenderedStyle(e),e=r.collection()}};t.flushRenderedStyleQueue=function(){a(!0)},t.beforeRender(a,t.beforeRenderPriorities.eleCalcs)};Ol.onUpdateEleCalcs=function(r){var e=this.onUpdateEleCalcsFns=this.onUpdateEleCalcsFns||[];e.push(r)};Ol.recalculateRenderedStyle=function(r,e){var t=function(C){return C._private.rstyle.cleanConnected};if(r.length!==0){var n=[],a=[];if(!this.destroyed){e===void 0&&(e=!0);for(var i=0;i<r.length;i++){var o=r[i],s=o._private,u=s.rstyle;o.isEdge()&&(!t(o.source())||!t(o.target()))&&(u.clean=!1),o.isEdge()&&o.isBundledBezier()&&o.parallelEdges().some(function(E){return!E._private.rstyle.clean&&E.isBundledBezier()})&&(u.clean=!1),!(e&&u.clean||o.removed())&&o.pstyle("display").value!=="none"&&(s.group==="nodes"?a.push(o):n.push(o),u.clean=!0)}for(var l=0;l<a.length;l++){var f=a[l],d=f._private,h=d.rstyle,g=f.position();this.recalculateNodeLabelProjection(f),h.nodeX=g.x,h.nodeY=g.y,h.nodeW=f.pstyle("width").pfValue,h.nodeH=f.pstyle("height").pfValue}this.recalculateEdgeProjections(n);for(var p=0;p<n.length;p++){var x=n[p],b=x._private,w=b.rstyle,y=b.rscratch;w.srcX=y.arrowStartX,w.srcY=y.arrowStartY,w.tgtX=y.arrowEndX,w.tgtY=y.arrowEndY,w.midX=y.midX,w.midY=y.midY,w.labelAngle=y.labelAngle,w.sourceLabelAngle=y.sourceLabelAngle,w.targetLabelAngle=y.targetLabelAngle}}}};var kl={};kl.updateCachedGrabbedEles=function(){var r=this.cachedZSortedEles;if(r){r.drag=[],r.nondrag=[];for(var e=[],t=0;t<r.length;t++){var n=r[t],a=n._private.rscratch;n.grabbed()&&!n.isParent()?e.push(n):a.inDragLayer?r.drag.push(n):r.nondrag.push(n)}for(var t=0;t<e.length;t++){var n=e[t];r.drag.push(n)}}};kl.invalidateCachedZSortedEles=function(){this.cachedZSortedEles=null};kl.getCachedZSortedEles=function(r){if(r||!this.cachedZSortedEles){var e=this.cy.mutableElements().toArray();e.sort(MA),e.interactive=e.filter(function(t){return t.interactive()}),this.cachedZSortedEles=e,this.updateCachedGrabbedEles()}else e=this.cachedZSortedEles;return e};var JA={};[mi,fl,At,Ps,v0,$n,QA,Ol,kl].forEach(function(r){Xe(JA,r)});var eP={};eP.getCachedImage=function(r,e,t){var n=this,a=n.imageCache=n.imageCache||{},i=a[r];if(i)return i.image.complete||i.image.addEventListener("load",t),i.image;i=a[r]=a[r]||{};var o=i.image=new Image;o.addEventListener("load",t),o.addEventListener("error",function(){o.error=!0});var s="data:",u=r.substring(0,s.length).toLowerCase()===s;return u||(e=e==="null"?null:e,o.crossOrigin=e),o.src=r,o};var bo={};bo.registerBinding=function(r,e,t,n){var a=Array.prototype.slice.apply(arguments,[1]);if(Array.isArray(r)){for(var i=[],o=0;o<r.length;o++){var s=r[o];if(s!==void 0){var u=this.binder(s);i.push(u.on.apply(u,a))}}return i}var u=this.binder(r);return u.on.apply(u,a)};bo.binder=function(r){var e=this,t=e.cy.window(),n=r===t||r===t.document||r===t.document.body||AN(r);if(e.supportsPassiveEvents==null){var a=!1;try{var i=Object.defineProperty({},"passive",{get:function(){return a=!0,!0}});t.addEventListener("test",null,i)}catch{}e.supportsPassiveEvents=a}var o=function(u,l,f){var d=Array.prototype.slice.call(arguments);return n&&e.supportsPassiveEvents&&(d[2]={capture:f??!1,passive:!1,once:!1}),e.bindings.push({target:r,args:d}),(r.addEventListener||r.on).apply(r,d),this};return{on:o,addEventListener:o,addListener:o,bind:o}};bo.nodeIsDraggable=function(r){return r&&r.isNode()&&!r.locked()&&r.grabbable()};bo.nodeIsGrabbable=function(r){return this.nodeIsDraggable(r)&&r.interactive()};bo.load=function(){var r=this,e=r.cy.window(),t=function(O){return O.selected()},n=function(O){var ne=O.getRootNode();if(ne&&ne.nodeType===11&&ne.host!==void 0)return ne},a=function(O,ne,he,ge){O==null&&(O=r.cy);for(var be=0;be<ne.length;be++){var Ve=ne[be];O.emit({originalEvent:he,type:Ve,position:ge})}},i=function(O){return O.shiftKey||O.metaKey||O.ctrlKey},o=function(O,ne){var he=!0;if(r.cy.hasCompoundNodes()&&O&&O.pannable())for(var ge=0;ne&&ge<ne.length;ge++){var O=ne[ge];if(O.isNode()&&O.isParent()&&!O.pannable()){he=!1;break}}else he=!0;return he},s=function(O){O[0]._private.grabbed=!0},u=function(O){O[0]._private.grabbed=!1},l=function(O){O[0]._private.rscratch.inDragLayer=!0},f=function(O){O[0]._private.rscratch.inDragLayer=!1},d=function(O){O[0]._private.rscratch.isGrabTarget=!0},h=function(O){O[0]._private.rscratch.isGrabTarget=!1},g=function(O,ne){var he=ne.addToList,ge=he.has(O);!ge&&O.grabbable()&&!O.locked()&&(he.merge(O),s(O))},p=function(O,ne){if(O.cy().hasCompoundNodes()&&!(ne.inDragLayer==null&&ne.addToList==null)){var he=O.descendants();ne.inDragLayer&&(he.forEach(l),he.connectedEdges().forEach(l)),ne.addToList&&g(he,ne)}},x=function(O,ne){ne=ne||{};var he=O.cy().hasCompoundNodes();ne.inDragLayer&&(O.forEach(l),O.neighborhood().stdFilter(function(ge){return!he||ge.isEdge()}).forEach(l)),ne.addToList&&O.forEach(function(ge){g(ge,ne)}),p(O,ne),y(O,{inDragLayer:ne.inDragLayer}),r.updateCachedGrabbedEles()},b=x,w=function(O){O&&(r.getCachedZSortedEles().forEach(function(ne){u(ne),f(ne),h(ne)}),r.updateCachedGrabbedEles())},y=function(O,ne){if(!(ne.inDragLayer==null&&ne.addToList==null)&&O.cy().hasCompoundNodes()){var he=O.ancestors().orphans();if(!he.same(O)){var ge=he.descendants().spawnSelf().merge(he).unmerge(O).unmerge(O.descendants()),be=ge.connectedEdges();ne.inDragLayer&&(be.forEach(l),ge.forEach(l)),ne.addToList&&ge.forEach(function(Ve){g(Ve,ne)})}}},E=function(){document.activeElement!=null&&document.activeElement.blur!=null&&document.activeElement.blur()},C=typeof MutationObserver<"u",S=typeof ResizeObserver<"u";C?(r.removeObserver=new MutationObserver(function(ye){for(var O=0;O<ye.length;O++){var ne=ye[O],he=ne.removedNodes;if(he)for(var ge=0;ge<he.length;ge++){var be=he[ge];if(be===r.container){r.destroy();break}}}}),r.container.parentNode&&r.removeObserver.observe(r.container.parentNode,{childList:!0})):r.registerBinding(r.container,"DOMNodeRemoved",function(ye){r.destroy()});var R=Ss(function(){r.cy.resize()},100);C&&(r.styleObserver=new MutationObserver(R),r.styleObserver.observe(r.container,{attributes:!0})),r.registerBinding(e,"resize",R),S&&(r.resizeObserver=new ResizeObserver(R),r.resizeObserver.observe(r.container));var _=function(O,ne){for(;O!=null;)ne(O),O=O.parentNode},A=function(){r.invalidateContainerClientCoordsCache()};_(r.container,function(ye){r.registerBinding(ye,"transitionend",A),r.registerBinding(ye,"animationend",A),r.registerBinding(ye,"scroll",A)}),r.registerBinding(r.container,"contextmenu",function(ye){ye.preventDefault()});var P=function(){return r.selection[4]!==0},I=function(O){for(var ne=r.findContainerClientCoords(),he=ne[0],ge=ne[1],be=ne[2],Ve=ne[3],Be=O.touches?O.touches:[O],He=!1,We=0;We<Be.length;We++){var Ze=Be[We];if(he<=Ze.clientX&&Ze.clientX<=he+be&&ge<=Ze.clientY&&Ze.clientY<=ge+Ve){He=!0;break}}if(!He)return!1;for(var sr=r.container,ar=O.target,Ke=ar.parentNode,lr=!1;Ke;){if(Ke===sr){lr=!0;break}Ke=Ke.parentNode}return!!lr};r.registerBinding(r.container,"mousedown",function(O){if(I(O)&&!(r.hoverData.which===1&&O.which!==1)){O.preventDefault(),E(),r.hoverData.capture=!0,r.hoverData.which=O.which;var ne=r.cy,he=[O.clientX,O.clientY],ge=r.projectIntoViewport(he[0],he[1]),be=r.selection,Ve=r.findNearestElements(ge[0],ge[1],!0,!1),Be=Ve[0],He=r.dragData.possibleDragElements;r.hoverData.mdownPos=ge,r.hoverData.mdownGPos=he;var We=function(ir){return{originalEvent:O,type:ir,position:{x:ge[0],y:ge[1]}}},Ze=function(){r.hoverData.tapholdCancelled=!1,clearTimeout(r.hoverData.tapholdTimeout),r.hoverData.tapholdTimeout=setTimeout(function(){if(!r.hoverData.tapholdCancelled){var ir=r.hoverData.down;ir?ir.emit(We("taphold")):ne.emit(We("taphold"))}},r.tapholdDuration)};if(O.which==3){r.hoverData.cxtStarted=!0;var sr={originalEvent:O,type:"cxttapstart",position:{x:ge[0],y:ge[1]}};Be?(Be.activate(),Be.emit(sr),r.hoverData.down=Be):ne.emit(sr),r.hoverData.downTime=new Date().getTime(),r.hoverData.cxtDragged=!1}else if(O.which==1){Be&&Be.activate();{if(Be!=null&&r.nodeIsGrabbable(Be)){var ar=function(ir){ir.emit(We("grab"))};if(d(Be),!Be.selected())He=r.dragData.possibleDragElements=ne.collection(),b(Be,{addToList:He}),Be.emit(We("grabon")).emit(We("grab"));else{He=r.dragData.possibleDragElements=ne.collection();var Ke=ne.$(function(lr){return lr.isNode()&&lr.selected()&&r.nodeIsGrabbable(lr)});x(Ke,{addToList:He}),Be.emit(We("grabon")),Ke.forEach(ar)}r.redrawHint("eles",!0),r.redrawHint("drag",!0)}r.hoverData.down=Be,r.hoverData.downs=Ve,r.hoverData.downTime=new Date().getTime()}a(Be,["mousedown","tapstart","vmousedown"],O,{x:ge[0],y:ge[1]}),Be==null?(be[4]=1,r.data.bgActivePosistion={x:ge[0],y:ge[1]},r.redrawHint("select",!0),r.redraw()):Be.pannable()&&(be[4]=1),Ze()}be[0]=be[2]=ge[0],be[1]=be[3]=ge[1]}},!1);var D=n(r.container);r.registerBinding([e,D],"mousemove",function(O){var ne=r.hoverData.capture;if(!(!ne&&!I(O))){var he=!1,ge=r.cy,be=ge.zoom(),Ve=[O.clientX,O.clientY],Be=r.projectIntoViewport(Ve[0],Ve[1]),He=r.hoverData.mdownPos,We=r.hoverData.mdownGPos,Ze=r.selection,sr=null;!r.hoverData.draggingEles&&!r.hoverData.dragging&&!r.hoverData.selecting&&(sr=r.findNearestElement(Be[0],Be[1],!0,!1));var ar=r.hoverData.last,Ke=r.hoverData.down,lr=[Be[0]-Ze[2],Be[1]-Ze[3]],ir=r.dragData.possibleDragElements,Ur;if(We){var Mr=Ve[0]-We[0],ct=Mr*Mr,Lr=Ve[1]-We[1],jr=Lr*Lr,Nr=ct+jr;r.hoverData.isOverThresholdDrag=Ur=Nr>=r.desktopTapThreshold2}var Qr=i(O);Ur&&(r.hoverData.tapholdCancelled=!0);var Pn=function(){var kt=r.hoverData.dragDelta=r.hoverData.dragDelta||[];kt.length===0?(kt.push(lr[0]),kt.push(lr[1])):(kt[0]+=lr[0],kt[1]+=lr[1])};he=!0,a(sr,["mousemove","vmousemove","tapdrag"],O,{x:Be[0],y:Be[1]});var Vr=function(kt){return{originalEvent:O,type:kt,position:{x:Be[0],y:Be[1]}}},pn=function(){r.data.bgActivePosistion=void 0,r.hoverData.selecting||ge.emit(Vr("boxstart")),Ze[4]=1,r.hoverData.selecting=!0,r.redrawHint("select",!0),r.redraw()};if(r.hoverData.which===3){if(Ur){var yn=Vr("cxtdrag");Ke?Ke.emit(yn):ge.emit(yn),r.hoverData.cxtDragged=!0,(!r.hoverData.cxtOver||sr!==r.hoverData.cxtOver)&&(r.hoverData.cxtOver&&r.hoverData.cxtOver.emit(Vr("cxtdragout")),r.hoverData.cxtOver=sr,sr&&sr.emit(Vr("cxtdragover")))}}else if(r.hoverData.dragging){if(he=!0,ge.panningEnabled()&&ge.userPanningEnabled()){var ua;if(r.hoverData.justStartedPan){var Ci=r.hoverData.mdownPos;ua={x:(Be[0]-Ci[0])*be,y:(Be[1]-Ci[1])*be},r.hoverData.justStartedPan=!1}else ua={x:lr[0]*be,y:lr[1]*be};ge.panBy(ua),ge.emit(Vr("dragpan")),r.hoverData.dragged=!0}Be=r.projectIntoViewport(O.clientX,O.clientY)}else if(Ze[4]==1&&(Ke==null||Ke.pannable())){if(Ur){if(!r.hoverData.dragging&&ge.boxSelectionEnabled()&&(Qr||!ge.panningEnabled()||!ge.userPanningEnabled()))pn();else if(!r.hoverData.selecting&&ge.panningEnabled()&&ge.userPanningEnabled()){var Gn=o(Ke,r.hoverData.downs);Gn&&(r.hoverData.dragging=!0,r.hoverData.justStartedPan=!0,Ze[4]=0,r.data.bgActivePosistion=Ji(He),r.redrawHint("select",!0),r.redraw())}Ke&&Ke.pannable()&&Ke.active()&&Ke.unactivate()}}else{if(Ke&&Ke.pannable()&&Ke.active()&&Ke.unactivate(),(!Ke||!Ke.grabbed())&&sr!=ar&&(ar&&a(ar,["mouseout","tapdragout"],O,{x:Be[0],y:Be[1]}),sr&&a(sr,["mouseover","tapdragover"],O,{x:Be[0],y:Be[1]}),r.hoverData.last=sr),Ke)if(Ur){if(ge.boxSelectionEnabled()&&Qr)Ke&&Ke.grabbed()&&(w(ir),Ke.emit(Vr("freeon")),ir.emit(Vr("free")),r.dragData.didDrag&&(Ke.emit(Vr("dragfreeon")),ir.emit(Vr("dragfree")))),pn();else if(Ke&&Ke.grabbed()&&r.nodeIsDraggable(Ke)){var dt=!r.dragData.didDrag;dt&&r.redrawHint("eles",!0),r.dragData.didDrag=!0,r.hoverData.draggingEles||x(ir,{inDragLayer:!0});var ot={x:0,y:0};if(qe(lr[0])&&qe(lr[1])&&(ot.x+=lr[0],ot.y+=lr[1],dt)){var Et=r.hoverData.dragDelta;Et&&qe(Et[0])&&qe(Et[1])&&(ot.x+=Et[0],ot.y+=Et[1])}r.hoverData.draggingEles=!0,ir.silentShift(ot).emit(Vr("position")).emit(Vr("drag")),r.redrawHint("drag",!0),r.redraw()}}else Pn();he=!0}if(Ze[2]=Be[0],Ze[3]=Be[1],he)return O.stopPropagation&&O.stopPropagation(),O.preventDefault&&O.preventDefault(),!1}},!1);var L,M,q;r.registerBinding(e,"mouseup",function(O){if(!(r.hoverData.which===1&&O.which!==1&&r.hoverData.capture)){var ne=r.hoverData.capture;if(ne){r.hoverData.capture=!1;var he=r.cy,ge=r.projectIntoViewport(O.clientX,O.clientY),be=r.selection,Ve=r.findNearestElement(ge[0],ge[1],!0,!1),Be=r.dragData.possibleDragElements,He=r.hoverData.down,We=i(O);r.data.bgActivePosistion&&(r.redrawHint("select",!0),r.redraw()),r.hoverData.tapholdCancelled=!0,r.data.bgActivePosistion=void 0,He&&He.unactivate();var Ze=function(Mr){return{originalEvent:O,type:Mr,position:{x:ge[0],y:ge[1]}}};if(r.hoverData.which===3){var sr=Ze("cxttapend");if(He?He.emit(sr):he.emit(sr),!r.hoverData.cxtDragged){var ar=Ze("cxttap");He?He.emit(ar):he.emit(ar)}r.hoverData.cxtDragged=!1,r.hoverData.which=null}else if(r.hoverData.which===1){if(a(Ve,["mouseup","tapend","vmouseup"],O,{x:ge[0],y:ge[1]}),!r.dragData.didDrag&&!r.hoverData.dragged&&!r.hoverData.selecting&&!r.hoverData.isOverThresholdDrag&&(a(He,["click","tap","vclick"],O,{x:ge[0],y:ge[1]}),M=!1,O.timeStamp-q<=he.multiClickDebounceTime()?(L&&clearTimeout(L),M=!0,q=null,a(He,["dblclick","dbltap","vdblclick"],O,{x:ge[0],y:ge[1]})):(L=setTimeout(function(){M||a(He,["oneclick","onetap","voneclick"],O,{x:ge[0],y:ge[1]})},he.multiClickDebounceTime()),q=O.timeStamp)),He==null&&!r.dragData.didDrag&&!r.hoverData.selecting&&!r.hoverData.dragged&&!i(O)&&(he.$(t).unselect(["tapunselect"]),Be.length>0&&r.redrawHint("eles",!0),r.dragData.possibleDragElements=Be=he.collection()),Ve==He&&!r.dragData.didDrag&&!r.hoverData.selecting&&Ve!=null&&Ve._private.selectable&&(r.hoverData.dragging||(he.selectionType()==="additive"||We?Ve.selected()?Ve.unselect(["tapunselect"]):Ve.select(["tapselect"]):We||(he.$(t).unmerge(Ve).unselect(["tapunselect"]),Ve.select(["tapselect"]))),r.redrawHint("eles",!0)),r.hoverData.selecting){var Ke=he.collection(r.getAllInBox(be[0],be[1],be[2],be[3]));r.redrawHint("select",!0),Ke.length>0&&r.redrawHint("eles",!0),he.emit(Ze("boxend"));var lr=function(Mr){return Mr.selectable()&&!Mr.selected()};he.selectionType()==="additive"||We||he.$(t).unmerge(Ke).unselect(),Ke.emit(Ze("box")).stdFilter(lr).select().emit(Ze("boxselect")),r.redraw()}if(r.hoverData.dragging&&(r.hoverData.dragging=!1,r.redrawHint("select",!0),r.redrawHint("eles",!0),r.redraw()),!be[4]){r.redrawHint("drag",!0),r.redrawHint("eles",!0);var ir=He&&He.grabbed();w(Be),ir&&(He.emit(Ze("freeon")),Be.emit(Ze("free")),r.dragData.didDrag&&(He.emit(Ze("dragfreeon")),Be.emit(Ze("dragfree"))))}}be[4]=0,r.hoverData.down=null,r.hoverData.cxtStarted=!1,r.hoverData.draggingEles=!1,r.hoverData.selecting=!1,r.hoverData.isOverThresholdDrag=!1,r.dragData.didDrag=!1,r.hoverData.dragged=!1,r.hoverData.dragDelta=[],r.hoverData.mdownPos=null,r.hoverData.mdownGPos=null,r.hoverData.which=null}}},!1);var N=[],W=4,V,$=1e5,Z=function(O,ne){for(var he=0;he<O.length;he++)if(O[he]%ne!==0)return!1;return!0},ee=function(O){for(var ne=Math.abs(O[0]),he=1;he<O.length;he++)if(Math.abs(O[he])!==ne)return!1;return!0},K=function(O){var ne=!1,he=O.deltaY;if(he==null&&(O.wheelDeltaY!=null?he=O.wheelDeltaY/4:O.wheelDelta!=null&&(he=O.wheelDelta/4)),he!==0){if(V==null)if(N.length>=W){var ge=N;if(V=Z(ge,5),!V){var be=Math.abs(ge[0]);V=ee(ge)&&be>5}if(V)for(var Ve=0;Ve<ge.length;Ve++)$=Math.min(Math.abs(ge[Ve]),$)}else N.push(he),ne=!0;else V&&($=Math.min(Math.abs(he),$));if(!r.scrollingPage){var Be=r.cy,He=Be.zoom(),We=Be.pan(),Ze=r.projectIntoViewport(O.clientX,O.clientY),sr=[Ze[0]*He+We.x,Ze[1]*He+We.y];if(r.hoverData.draggingEles||r.hoverData.dragging||r.hoverData.cxtStarted||P()){O.preventDefault();return}if(Be.panningEnabled()&&Be.userPanningEnabled()&&Be.zoomingEnabled()&&Be.userZoomingEnabled()){O.preventDefault(),r.data.wheelZooming=!0,clearTimeout(r.data.wheelTimeout),r.data.wheelTimeout=setTimeout(function(){r.data.wheelZooming=!1,r.redrawHint("eles",!0),r.redraw()},150);var ar;ne&&Math.abs(he)>5&&(he=Jm(he)*5),ar=he/-250,V&&(ar/=$,ar*=3),ar=ar*r.wheelSensitivity;var Ke=O.deltaMode===1;Ke&&(ar*=33);var lr=Be.zoom()*Math.pow(10,ar);O.type==="gesturechange"&&(lr=r.gestureStartZoom*O.scale),Be.zoom({level:lr,renderedPosition:{x:sr[0],y:sr[1]}}),Be.emit({type:O.type==="gesturechange"?"pinchzoom":"scrollzoom",originalEvent:O,position:{x:Ze[0],y:Ze[1]}})}}}};r.registerBinding(r.container,"wheel",K,!0),r.registerBinding(e,"scroll",function(O){r.scrollingPage=!0,clearTimeout(r.scrollingPageTimeout),r.scrollingPageTimeout=setTimeout(function(){r.scrollingPage=!1},250)},!0),r.registerBinding(r.container,"gesturestart",function(O){r.gestureStartZoom=r.cy.zoom(),r.hasTouchStarted||O.preventDefault()},!0),r.registerBinding(r.container,"gesturechange",function(ye){r.hasTouchStarted||K(ye)},!0),r.registerBinding(r.container,"mouseout",function(O){var ne=r.projectIntoViewport(O.clientX,O.clientY);r.cy.emit({originalEvent:O,type:"mouseout",position:{x:ne[0],y:ne[1]}})},!1),r.registerBinding(r.container,"mouseover",function(O){var ne=r.projectIntoViewport(O.clientX,O.clientY);r.cy.emit({originalEvent:O,type:"mouseover",position:{x:ne[0],y:ne[1]}})},!1);var j,fe,G,z,Y,te,ue,oe,X,Q,ie,de,we,Ae=function(O,ne,he,ge){return Math.sqrt((he-O)*(he-O)+(ge-ne)*(ge-ne))},ve=function(O,ne,he,ge){return(he-O)*(he-O)+(ge-ne)*(ge-ne)},le;r.registerBinding(r.container,"touchstart",le=function(O){if(r.hasTouchStarted=!0,!!I(O)){E(),r.touchData.capture=!0,r.data.bgActivePosistion=void 0;var ne=r.cy,he=r.touchData.now,ge=r.touchData.earlier;if(O.touches[0]){var be=r.projectIntoViewport(O.touches[0].clientX,O.touches[0].clientY);he[0]=be[0],he[1]=be[1]}if(O.touches[1]){var be=r.projectIntoViewport(O.touches[1].clientX,O.touches[1].clientY);he[2]=be[0],he[3]=be[1]}if(O.touches[2]){var be=r.projectIntoViewport(O.touches[2].clientX,O.touches[2].clientY);he[4]=be[0],he[5]=be[1]}var Ve=function(Qr){return{originalEvent:O,type:Qr,position:{x:he[0],y:he[1]}}};if(O.touches[1]){r.touchData.singleTouchMoved=!0,w(r.dragData.touchDragEles);var Be=r.findContainerClientCoords();X=Be[0],Q=Be[1],ie=Be[2],de=Be[3],j=O.touches[0].clientX-X,fe=O.touches[0].clientY-Q,G=O.touches[1].clientX-X,z=O.touches[1].clientY-Q,we=0<=j&&j<=ie&&0<=G&&G<=ie&&0<=fe&&fe<=de&&0<=z&&z<=de;var He=ne.pan(),We=ne.zoom();Y=Ae(j,fe,G,z),te=ve(j,fe,G,z),ue=[(j+G)/2,(fe+z)/2],oe=[(ue[0]-He.x)/We,(ue[1]-He.y)/We];var Ze=200,sr=Ze*Ze;if(te<sr&&!O.touches[2]){var ar=r.findNearestElement(he[0],he[1],!0,!0),Ke=r.findNearestElement(he[2],he[3],!0,!0);ar&&ar.isNode()?(ar.activate().emit(Ve("cxttapstart")),r.touchData.start=ar):Ke&&Ke.isNode()?(Ke.activate().emit(Ve("cxttapstart")),r.touchData.start=Ke):ne.emit(Ve("cxttapstart")),r.touchData.start&&(r.touchData.start._private.grabbed=!1),r.touchData.cxt=!0,r.touchData.cxtDragged=!1,r.data.bgActivePosistion=void 0,r.redraw();return}}if(O.touches[2])ne.boxSelectionEnabled()&&O.preventDefault();else if(!O.touches[1]){if(O.touches[0]){var lr=r.findNearestElements(he[0],he[1],!0,!0),ir=lr[0];if(ir!=null&&(ir.activate(),r.touchData.start=ir,r.touchData.starts=lr,r.nodeIsGrabbable(ir))){var Ur=r.dragData.touchDragEles=ne.collection(),Mr=null;r.redrawHint("eles",!0),r.redrawHint("drag",!0),ir.selected()?(Mr=ne.$(function(Nr){return Nr.selected()&&r.nodeIsGrabbable(Nr)}),x(Mr,{addToList:Ur})):b(ir,{addToList:Ur}),d(ir),ir.emit(Ve("grabon")),Mr?Mr.forEach(function(Nr){Nr.emit(Ve("grab"))}):ir.emit(Ve("grab"))}a(ir,["touchstart","tapstart","vmousedown"],O,{x:he[0],y:he[1]}),ir==null&&(r.data.bgActivePosistion={x:be[0],y:be[1]},r.redrawHint("select",!0),r.redraw()),r.touchData.singleTouchMoved=!1,r.touchData.singleTouchStartTime=+new Date,clearTimeout(r.touchData.tapholdTimeout),r.touchData.tapholdTimeout=setTimeout(function(){r.touchData.singleTouchMoved===!1&&!r.pinching&&!r.touchData.selecting&&a(r.touchData.start,["taphold"],O,{x:he[0],y:he[1]})},r.tapholdDuration)}}if(O.touches.length>=1){for(var ct=r.touchData.startPosition=[null,null,null,null,null,null],Lr=0;Lr<he.length;Lr++)ct[Lr]=ge[Lr]=he[Lr];var jr=O.touches[0];r.touchData.startGPosition=[jr.clientX,jr.clientY]}}},!1);var Me;r.registerBinding(e,"touchmove",Me=function(O){var ne=r.touchData.capture;if(!(!ne&&!I(O))){var he=r.selection,ge=r.cy,be=r.touchData.now,Ve=r.touchData.earlier,Be=ge.zoom();if(O.touches[0]){var He=r.projectIntoViewport(O.touches[0].clientX,O.touches[0].clientY);be[0]=He[0],be[1]=He[1]}if(O.touches[1]){var He=r.projectIntoViewport(O.touches[1].clientX,O.touches[1].clientY);be[2]=He[0],be[3]=He[1]}if(O.touches[2]){var He=r.projectIntoViewport(O.touches[2].clientX,O.touches[2].clientY);be[4]=He[0],be[5]=He[1]}var We=function(Ai){return{originalEvent:O,type:Ai,position:{x:be[0],y:be[1]}}},Ze=r.touchData.startGPosition,sr;if(ne&&O.touches[0]&&Ze){for(var ar=[],Ke=0;Ke<be.length;Ke++)ar[Ke]=be[Ke]-Ve[Ke];var lr=O.touches[0].clientX-Ze[0],ir=lr*lr,Ur=O.touches[0].clientY-Ze[1],Mr=Ur*Ur,ct=ir+Mr;sr=ct>=r.touchTapThreshold2}if(ne&&r.touchData.cxt){O.preventDefault();var Lr=O.touches[0].clientX-X,jr=O.touches[0].clientY-Q,Nr=O.touches[1].clientX-X,Qr=O.touches[1].clientY-Q,Pn=ve(Lr,jr,Nr,Qr),Vr=Pn/te,pn=150,yn=pn*pn,ua=1.5,Ci=ua*ua;if(Vr>=Ci||Pn>=yn){r.touchData.cxt=!1,r.data.bgActivePosistion=void 0,r.redrawHint("select",!0);var Gn=We("cxttapend");r.touchData.start?(r.touchData.start.unactivate().emit(Gn),r.touchData.start=null):ge.emit(Gn)}}if(ne&&r.touchData.cxt){var Gn=We("cxtdrag");r.data.bgActivePosistion=void 0,r.redrawHint("select",!0),r.touchData.start?r.touchData.start.emit(Gn):ge.emit(Gn),r.touchData.start&&(r.touchData.start._private.grabbed=!1),r.touchData.cxtDragged=!0;var dt=r.findNearestElement(be[0],be[1],!0,!0);(!r.touchData.cxtOver||dt!==r.touchData.cxtOver)&&(r.touchData.cxtOver&&r.touchData.cxtOver.emit(We("cxtdragout")),r.touchData.cxtOver=dt,dt&&dt.emit(We("cxtdragover")))}else if(ne&&O.touches[2]&&ge.boxSelectionEnabled())O.preventDefault(),r.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,r.touchData.selecting||ge.emit(We("boxstart")),r.touchData.selecting=!0,r.touchData.didSelect=!0,he[4]=1,!he||he.length===0||he[0]===void 0?(he[0]=(be[0]+be[2]+be[4])/3,he[1]=(be[1]+be[3]+be[5])/3,he[2]=(be[0]+be[2]+be[4])/3+1,he[3]=(be[1]+be[3]+be[5])/3+1):(he[2]=(be[0]+be[2]+be[4])/3,he[3]=(be[1]+be[3]+be[5])/3),r.redrawHint("select",!0),r.redraw();else if(ne&&O.touches[1]&&!r.touchData.didSelect&&ge.zoomingEnabled()&&ge.panningEnabled()&&ge.userZoomingEnabled()&&ge.userPanningEnabled()){O.preventDefault(),r.data.bgActivePosistion=void 0,r.redrawHint("select",!0);var ot=r.dragData.touchDragEles;if(ot){r.redrawHint("drag",!0);for(var Et=0;Et<ot.length;Et++){var Ga=ot[Et]._private;Ga.grabbed=!1,Ga.rscratch.inDragLayer=!1}}var kt=r.touchData.start,Lr=O.touches[0].clientX-X,jr=O.touches[0].clientY-Q,Nr=O.touches[1].clientX-X,Qr=O.touches[1].clientY-Q,qs=Ae(Lr,jr,Nr,Qr),rf=qs/Y;if(we){var _i=Lr-j,tf=jr-fe,Si=Nr-G,nf=Qr-z,af=(_i+Si)/2,of=(tf+nf)/2,la=ge.zoom(),Ti=la*rf,Wa=ge.pan(),Ns=oe[0]*la+Wa.x,Fs=oe[1]*la+Wa.y,sf={x:-Ti/la*(Ns-Wa.x-af)+Ns,y:-Ti/la*(Fs-Wa.y-of)+Fs};if(kt&&kt.active()){var ot=r.dragData.touchDragEles;w(ot),r.redrawHint("drag",!0),r.redrawHint("eles",!0),kt.unactivate().emit(We("freeon")),ot.emit(We("free")),r.dragData.didDrag&&(kt.emit(We("dragfreeon")),ot.emit(We("dragfree")))}ge.viewport({zoom:Ti,pan:sf,cancelOnFailedZoom:!0}),ge.emit(We("pinchzoom")),Y=qs,j=Lr,fe=jr,G=Nr,z=Qr,r.pinching=!0}if(O.touches[0]){var He=r.projectIntoViewport(O.touches[0].clientX,O.touches[0].clientY);be[0]=He[0],be[1]=He[1]}if(O.touches[1]){var He=r.projectIntoViewport(O.touches[1].clientX,O.touches[1].clientY);be[2]=He[0],be[3]=He[1]}if(O.touches[2]){var He=r.projectIntoViewport(O.touches[2].clientX,O.touches[2].clientY);be[4]=He[0],be[5]=He[1]}}else if(O.touches[0]&&!r.touchData.didSelect){var Ut=r.touchData.start,Ri=r.touchData.last,dt;if(!r.hoverData.draggingEles&&!r.swipePanning&&(dt=r.findNearestElement(be[0],be[1],!0,!0)),ne&&Ut!=null&&O.preventDefault(),ne&&Ut!=null&&r.nodeIsDraggable(Ut))if(sr){var ot=r.dragData.touchDragEles,_o=!r.dragData.didDrag;_o&&x(ot,{inDragLayer:!0}),r.dragData.didDrag=!0;var fa={x:0,y:0};if(qe(ar[0])&&qe(ar[1])&&(fa.x+=ar[0],fa.y+=ar[1],_o)){r.redrawHint("eles",!0);var Pt=r.touchData.dragDelta;Pt&&qe(Pt[0])&&qe(Pt[1])&&(fa.x+=Pt[0],fa.y+=Pt[1])}r.hoverData.draggingEles=!0,ot.silentShift(fa).emit(We("position")).emit(We("drag")),r.redrawHint("drag",!0),r.touchData.startPosition[0]==Ve[0]&&r.touchData.startPosition[1]==Ve[1]&&r.redrawHint("eles",!0),r.redraw()}else{var Pt=r.touchData.dragDelta=r.touchData.dragDelta||[];Pt.length===0?(Pt.push(ar[0]),Pt.push(ar[1])):(Pt[0]+=ar[0],Pt[1]+=ar[1])}if(a(Ut||dt,["touchmove","tapdrag","vmousemove"],O,{x:be[0],y:be[1]}),(!Ut||!Ut.grabbed())&&dt!=Ri&&(Ri&&Ri.emit(We("tapdragout")),dt&&dt.emit(We("tapdragover"))),r.touchData.last=dt,ne)for(var Et=0;Et<be.length;Et++)be[Et]&&r.touchData.startPosition[Et]&&sr&&(r.touchData.singleTouchMoved=!0);if(ne&&(Ut==null||Ut.pannable())&&ge.panningEnabled()&&ge.userPanningEnabled()){var uf=o(Ut,r.touchData.starts);uf&&(O.preventDefault(),r.data.bgActivePosistion||(r.data.bgActivePosistion=Ji(r.touchData.startPosition)),r.swipePanning?(ge.panBy({x:ar[0]*Be,y:ar[1]*Be}),ge.emit(We("dragpan"))):sr&&(r.swipePanning=!0,ge.panBy({x:lr*Be,y:Ur*Be}),ge.emit(We("dragpan")),Ut&&(Ut.unactivate(),r.redrawHint("select",!0),r.touchData.start=null)));var He=r.projectIntoViewport(O.touches[0].clientX,O.touches[0].clientY);be[0]=He[0],be[1]=He[1]}}for(var Ke=0;Ke<be.length;Ke++)Ve[Ke]=be[Ke];ne&&O.touches.length>0&&!r.hoverData.draggingEles&&!r.swipePanning&&r.data.bgActivePosistion!=null&&(r.data.bgActivePosistion=void 0,r.redrawHint("select",!0),r.redraw())}},!1);var Se;r.registerBinding(e,"touchcancel",Se=function(O){var ne=r.touchData.start;r.touchData.capture=!1,ne&&ne.unactivate()});var Ee,re,ce,_e;if(r.registerBinding(e,"touchend",Ee=function(O){var ne=r.touchData.start,he=r.touchData.capture;if(he)O.touches.length===0&&(r.touchData.capture=!1),O.preventDefault();else return;var ge=r.selection;r.swipePanning=!1,r.hoverData.draggingEles=!1;var be=r.cy,Ve=be.zoom(),Be=r.touchData.now,He=r.touchData.earlier;if(O.touches[0]){var We=r.projectIntoViewport(O.touches[0].clientX,O.touches[0].clientY);Be[0]=We[0],Be[1]=We[1]}if(O.touches[1]){var We=r.projectIntoViewport(O.touches[1].clientX,O.touches[1].clientY);Be[2]=We[0],Be[3]=We[1]}if(O.touches[2]){var We=r.projectIntoViewport(O.touches[2].clientX,O.touches[2].clientY);Be[4]=We[0],Be[5]=We[1]}var Ze=function(yn){return{originalEvent:O,type:yn,position:{x:Be[0],y:Be[1]}}};ne&&ne.unactivate();var sr;if(r.touchData.cxt){if(sr=Ze("cxttapend"),ne?ne.emit(sr):be.emit(sr),!r.touchData.cxtDragged){var ar=Ze("cxttap");ne?ne.emit(ar):be.emit(ar)}r.touchData.start&&(r.touchData.start._private.grabbed=!1),r.touchData.cxt=!1,r.touchData.start=null,r.redraw();return}if(!O.touches[2]&&be.boxSelectionEnabled()&&r.touchData.selecting){r.touchData.selecting=!1;var Ke=be.collection(r.getAllInBox(ge[0],ge[1],ge[2],ge[3]));ge[0]=void 0,ge[1]=void 0,ge[2]=void 0,ge[3]=void 0,ge[4]=0,r.redrawHint("select",!0),be.emit(Ze("boxend"));var lr=function(yn){return yn.selectable()&&!yn.selected()};Ke.emit(Ze("box")).stdFilter(lr).select().emit(Ze("boxselect")),Ke.nonempty()&&r.redrawHint("eles",!0),r.redraw()}if(ne!=null&&ne.unactivate(),O.touches[2])r.data.bgActivePosistion=void 0,r.redrawHint("select",!0);else if(!O.touches[1]){if(!O.touches[0]){if(!O.touches[0]){r.data.bgActivePosistion=void 0,r.redrawHint("select",!0);var ir=r.dragData.touchDragEles;if(ne!=null){var Ur=ne._private.grabbed;w(ir),r.redrawHint("drag",!0),r.redrawHint("eles",!0),Ur&&(ne.emit(Ze("freeon")),ir.emit(Ze("free")),r.dragData.didDrag&&(ne.emit(Ze("dragfreeon")),ir.emit(Ze("dragfree")))),a(ne,["touchend","tapend","vmouseup","tapdragout"],O,{x:Be[0],y:Be[1]}),ne.unactivate(),r.touchData.start=null}else{var Mr=r.findNearestElement(Be[0],Be[1],!0,!0);a(Mr,["touchend","tapend","vmouseup","tapdragout"],O,{x:Be[0],y:Be[1]})}var ct=r.touchData.startPosition[0]-Be[0],Lr=ct*ct,jr=r.touchData.startPosition[1]-Be[1],Nr=jr*jr,Qr=Lr+Nr,Pn=Qr*Ve*Ve;r.touchData.singleTouchMoved||(ne||be.$(":selected").unselect(["tapunselect"]),a(ne,["tap","vclick"],O,{x:Be[0],y:Be[1]}),re=!1,O.timeStamp-_e<=be.multiClickDebounceTime()?(ce&&clearTimeout(ce),re=!0,_e=null,a(ne,["dbltap","vdblclick"],O,{x:Be[0],y:Be[1]})):(ce=setTimeout(function(){re||a(ne,["onetap","voneclick"],O,{x:Be[0],y:Be[1]})},be.multiClickDebounceTime()),_e=O.timeStamp)),ne!=null&&!r.dragData.didDrag&&ne._private.selectable&&Pn<r.touchTapThreshold2&&!r.pinching&&(be.selectionType()==="single"?(be.$(t).unmerge(ne).unselect(["tapunselect"]),ne.select(["tapselect"])):ne.selected()?ne.unselect(["tapunselect"]):ne.select(["tapselect"]),r.redrawHint("eles",!0)),r.touchData.singleTouchMoved=!0}}}for(var Vr=0;Vr<Be.length;Vr++)He[Vr]=Be[Vr];r.dragData.didDrag=!1,O.touches.length===0&&(r.touchData.dragDelta=[],r.touchData.startPosition=[null,null,null,null,null,null],r.touchData.startGPosition=null,r.touchData.didSelect=!1),O.touches.length<2&&(O.touches.length===1&&(r.touchData.startGPosition=[O.touches[0].clientX,O.touches[0].clientY]),r.pinching=!1,r.redrawHint("eles",!0),r.redraw())},!1),typeof TouchEvent>"u"){var me=[],Te=function(O){return{clientX:O.clientX,clientY:O.clientY,force:1,identifier:O.pointerId,pageX:O.pageX,pageY:O.pageY,radiusX:O.width/2,radiusY:O.height/2,screenX:O.screenX,screenY:O.screenY,target:O.target}},De=function(O){return{event:O,touch:Te(O)}},Ne=function(O){me.push(De(O))},ze=function(O){for(var ne=0;ne<me.length;ne++){var he=me[ne];if(he.event.pointerId===O.pointerId){me.splice(ne,1);return}}},$e=function(O){var ne=me.filter(function(he){return he.event.pointerId===O.pointerId})[0];ne.event=O,ne.touch=Te(O)},ke=function(O){O.touches=me.map(function(ne){return ne.touch})},Oe=function(O){return O.pointerType==="mouse"||O.pointerType===4};r.registerBinding(r.container,"pointerdown",function(ye){Oe(ye)||(ye.preventDefault(),Ne(ye),ke(ye),le(ye))}),r.registerBinding(r.container,"pointerup",function(ye){Oe(ye)||(ze(ye),ke(ye),Ee(ye))}),r.registerBinding(r.container,"pointercancel",function(ye){Oe(ye)||(ze(ye),ke(ye),Se(ye))}),r.registerBinding(r.container,"pointermove",function(ye){Oe(ye)||(ye.preventDefault(),$e(ye),ke(ye),Me(ye))})}};var aa={};aa.generatePolygon=function(r,e){return this.nodeShapes[r]={renderer:this,name:r,points:e,draw:function(n,a,i,o,s,u){this.renderer.nodeShapeImpl("polygon",n,a,i,o,s,this.points)},intersectLine:function(n,a,i,o,s,u,l,f){return vs(s,u,this.points,n,a,i/2,o/2,l)},checkPoint:function(n,a,i,o,s,u,l,f){return na(n,a,this.points,u,l,o,s,[0,-1],i)},hasMiterBounds:r!=="rectangle",miterBounds:function(n,a,i,o,s,u){return WF(this.points,n,a,i,o,s)}}};aa.generateEllipse=function(){return this.nodeShapes.ellipse={renderer:this,name:"ellipse",draw:function(e,t,n,a,i,o){this.renderer.nodeShapeImpl(this.name,e,t,n,a,i)},intersectLine:function(e,t,n,a,i,o,s,u){return QF(i,o,e,t,n/2+s,a/2+s)},checkPoint:function(e,t,n,a,i,o,s,u){return ui(e,t,a,i,o,s,n)}}};aa.generateRoundPolygon=function(r,e){return this.nodeShapes[r]={renderer:this,name:r,points:e,getOrCreateCorners:function(n,a,i,o,s,u,l){if(u[l]!==void 0&&u[l+"-cx"]===n&&u[l+"-cy"]===a)return u[l];u[l]=new Array(e.length/2),u[l+"-cx"]=n,u[l+"-cy"]=a;var f=i/2,d=o/2;s=s==="auto"?rA(i,o):s;for(var h=new Array(e.length/2),g=0;g<e.length/2;g++)h[g]={x:n+f*e[g*2],y:a+d*e[g*2+1]};var p,x,b,w,y=h.length;for(x=h[y-1],p=0;p<y;p++)b=h[p%y],w=h[(p+1)%y],u[l][p]=d0(x,b,w,s),x=b,b=w;return u[l]},draw:function(n,a,i,o,s,u,l){this.renderer.nodeShapeImpl("round-polygon",n,a,i,o,s,this.points,this.getOrCreateCorners(a,i,o,s,u,l,"drawCorners"))},intersectLine:function(n,a,i,o,s,u,l,f,d){return ez(s,u,this.points,n,a,i,o,l,this.getOrCreateCorners(n,a,i,o,f,d,"corners"))},checkPoint:function(n,a,i,o,s,u,l,f,d){return XF(n,a,this.points,u,l,o,s,this.getOrCreateCorners(u,l,o,s,f,d,"corners"))}}};aa.generateRoundRectangle=function(){return this.nodeShapes["round-rectangle"]=this.nodeShapes.roundrectangle={renderer:this,name:"round-rectangle",points:Mt(4,0),draw:function(e,t,n,a,i,o){this.renderer.nodeShapeImpl(this.name,e,t,n,a,i,this.points,o)},intersectLine:function(e,t,n,a,i,o,s,u){return J2(i,o,e,t,n,a,s,u)},checkPoint:function(e,t,n,a,i,o,s,u){var l=a/2,f=i/2;u=u==="auto"?Ma(a,i):u,u=Math.min(l,f,u);var d=u*2;return!!(na(e,t,this.points,o,s,a,i-d,[0,-1],n)||na(e,t,this.points,o,s,a-d,i,[0,-1],n)||ui(e,t,d,d,o-l+u,s-f+u,n)||ui(e,t,d,d,o+l-u,s-f+u,n)||ui(e,t,d,d,o+l-u,s+f-u,n)||ui(e,t,d,d,o-l+u,s+f-u,n))}}};aa.generateCutRectangle=function(){return this.nodeShapes["cut-rectangle"]=this.nodeShapes.cutrectangle={renderer:this,name:"cut-rectangle",cornerLength:r0(),points:Mt(4,0),draw:function(e,t,n,a,i,o){this.renderer.nodeShapeImpl(this.name,e,t,n,a,i,null,o)},generateCutTrianglePts:function(e,t,n,a,i){var o=i==="auto"?this.cornerLength:i,s=t/2,u=e/2,l=n-u,f=n+u,d=a-s,h=a+s;return{topLeft:[l,d+o,l+o,d,l+o,d+o],topRight:[f-o,d,f,d+o,f-o,d+o],bottomRight:[f,h-o,f-o,h,f-o,h-o],bottomLeft:[l+o,h,l,h-o,l+o,h-o]}},intersectLine:function(e,t,n,a,i,o,s,u){var l=this.generateCutTrianglePts(n+2*s,a+2*s,e,t,u),f=[].concat.apply([],[l.topLeft.splice(0,4),l.topRight.splice(0,4),l.bottomRight.splice(0,4),l.bottomLeft.splice(0,4)]);return vs(i,o,f,e,t)},checkPoint:function(e,t,n,a,i,o,s,u){var l=u==="auto"?this.cornerLength:u;if(na(e,t,this.points,o,s,a,i-2*l,[0,-1],n)||na(e,t,this.points,o,s,a-2*l,i,[0,-1],n))return!0;var f=this.generateCutTrianglePts(a,i,o,s);return Vt(e,t,f.topLeft)||Vt(e,t,f.topRight)||Vt(e,t,f.bottomRight)||Vt(e,t,f.bottomLeft)}}};aa.generateBarrel=function(){return this.nodeShapes.barrel={renderer:this,name:"barrel",points:Mt(4,0),draw:function(e,t,n,a,i,o){this.renderer.nodeShapeImpl(this.name,e,t,n,a,i)},intersectLine:function(e,t,n,a,i,o,s,u){var l=.15,f=.5,d=.85,h=this.generateBarrelBezierPts(n+2*s,a+2*s,e,t),g=function(b){var w=io({x:b[0],y:b[1]},{x:b[2],y:b[3]},{x:b[4],y:b[5]},l),y=io({x:b[0],y:b[1]},{x:b[2],y:b[3]},{x:b[4],y:b[5]},f),E=io({x:b[0],y:b[1]},{x:b[2],y:b[3]},{x:b[4],y:b[5]},d);return[b[0],b[1],w.x,w.y,y.x,y.y,E.x,E.y,b[4],b[5]]},p=[].concat(g(h.topLeft),g(h.topRight),g(h.bottomRight),g(h.bottomLeft));return vs(i,o,p,e,t)},generateBarrelBezierPts:function(e,t,n,a){var i=t/2,o=e/2,s=n-o,u=n+o,l=a-i,f=a+i,d=Cm(e,t),h=d.heightOffset,g=d.widthOffset,p=d.ctrlPtOffsetPct*e,x={topLeft:[s,l+h,s+p,l,s+g,l],topRight:[u-g,l,u-p,l,u,l+h],bottomRight:[u,f-h,u-p,f,u-g,f],bottomLeft:[s+g,f,s+p,f,s,f-h]};return x.topLeft.isTop=!0,x.topRight.isTop=!0,x.bottomLeft.isBottom=!0,x.bottomRight.isBottom=!0,x},checkPoint:function(e,t,n,a,i,o,s,u){var l=Cm(a,i),f=l.heightOffset,d=l.widthOffset;if(na(e,t,this.points,o,s,a,i-2*f,[0,-1],n)||na(e,t,this.points,o,s,a-2*d,i,[0,-1],n))return!0;for(var h=this.generateBarrelBezierPts(a,i,o,s),g=function(A,P,I){var D=I[4],L=I[2],M=I[0],q=I[5],N=I[1],W=Math.min(D,M),V=Math.max(D,M),$=Math.min(q,N),Z=Math.max(q,N);if(W<=A&&A<=V&&$<=P&&P<=Z){var ee=rz(D,L,M),K=KF(ee[0],ee[1],ee[2],A),j=K.filter(function(fe){return 0<=fe&&fe<=1});if(j.length>0)return j[0]}return null},p=Object.keys(h),x=0;x<p.length;x++){var b=p[x],w=h[b],y=g(e,t,w);if(y!=null){var E=w[5],C=w[3],S=w[1],R=ut(E,C,S,y);if(w.isTop&&R<=t||w.isBottom&&t<=R)return!0}}return!1}}};aa.generateBottomRoundrectangle=function(){return this.nodeShapes["bottom-round-rectangle"]=this.nodeShapes.bottomroundrectangle={renderer:this,name:"bottom-round-rectangle",points:Mt(4,0),draw:function(e,t,n,a,i,o){this.renderer.nodeShapeImpl(this.name,e,t,n,a,i,this.points,o)},intersectLine:function(e,t,n,a,i,o,s,u){var l=e-(n/2+s),f=t-(a/2+s),d=f,h=e+(n/2+s),g=Ta(i,o,e,t,l,f,h,d,!1);return g.length>0?g:J2(i,o,e,t,n,a,s,u)},checkPoint:function(e,t,n,a,i,o,s,u){u=u==="auto"?Ma(a,i):u;var l=2*u;if(na(e,t,this.points,o,s,a,i-l,[0,-1],n)||na(e,t,this.points,o,s,a-l,i,[0,-1],n))return!0;var f=a/2+2*n,d=i/2+2*n,h=[o-f,s-d,o-f,s,o+f,s,o+f,s-d];return!!(Vt(e,t,h)||ui(e,t,l,l,o+a/2-u,s+i/2-u,n)||ui(e,t,l,l,o-a/2+u,s+i/2-u,n))}}};aa.registerNodeShapes=function(){var r=this.nodeShapes={},e=this;this.generateEllipse(),this.generatePolygon("triangle",Mt(3,0)),this.generateRoundPolygon("round-triangle",Mt(3,0)),this.generatePolygon("rectangle",Mt(4,0)),r.square=r.rectangle,this.generateRoundRectangle(),this.generateCutRectangle(),this.generateBarrel(),this.generateBottomRoundrectangle();{var t=[0,1,1,0,0,-1,-1,0];this.generatePolygon("diamond",t),this.generateRoundPolygon("round-diamond",t)}this.generatePolygon("pentagon",Mt(5,0)),this.generateRoundPolygon("round-pentagon",Mt(5,0)),this.generatePolygon("hexagon",Mt(6,0)),this.generateRoundPolygon("round-hexagon",Mt(6,0)),this.generatePolygon("heptagon",Mt(7,0)),this.generateRoundPolygon("round-heptagon",Mt(7,0)),this.generatePolygon("octagon",Mt(8,0)),this.generateRoundPolygon("round-octagon",Mt(8,0));var n=new Array(20);{var a=Em(5,0),i=Em(5,Math.PI/5),o=.5*(3-Math.sqrt(5));o*=1.57;for(var s=0;s<i.length/2;s++)i[s*2]*=o,i[s*2+1]*=o;for(var s=0;s<20/4;s++)n[s*4]=a[s*2],n[s*4+1]=a[s*2+1],n[s*4+2]=i[s*2],n[s*4+3]=i[s*2+1]}n=eA(n),this.generatePolygon("star",n),this.generatePolygon("vee",[-1,-1,0,-.333,1,-1,0,1]),this.generatePolygon("rhomboid",[-1,-1,.333,-1,1,1,-.333,1]),this.generatePolygon("right-rhomboid",[-.333,-1,1,-1,.333,1,-1,1]),this.nodeShapes.concavehexagon=this.generatePolygon("concave-hexagon",[-1,-.95,-.75,0,-1,.95,1,.95,.75,0,1,-.95]);{var u=[-1,-1,.25,-1,1,0,.25,1,-1,1];this.generatePolygon("tag",u),this.generateRoundPolygon("round-tag",u)}r.makePolygon=function(l){var f=l.join("$"),d="polygon-"+f,h;return(h=this[d])?h:e.generatePolygon(d,l)}};var Is={};Is.timeToRender=function(){return this.redrawTotalTime/this.redrawCount};Is.redraw=function(r){r=r||Y2();var e=this;e.averageRedrawTime===void 0&&(e.averageRedrawTime=0),e.lastRedrawTime===void 0&&(e.lastRedrawTime=0),e.lastDrawTime===void 0&&(e.lastDrawTime=0),e.requestedFrame=!0,e.renderOptions=r};Is.beforeRender=function(r,e){if(!this.destroyed){e==null&&kr("Priority is not optional for beforeRender");var t=this.beforeRenderCallbacks;t.push({fn:r,priority:e}),t.sort(function(n,a){return a.priority-n.priority})}};var ME=function(e,t,n){for(var a=e.beforeRenderCallbacks,i=0;i<a.length;i++)a[i].fn(t,n)};Is.startRenderLoop=function(){var r=this,e=r.cy;if(!r.renderLoopStarted){r.renderLoopStarted=!0;var t=function(a){if(!r.destroyed){if(!e.batching())if(r.requestedFrame&&!r.skipFrame){ME(r,!0,a);var i=ta();r.render(r.renderOptions);var o=r.lastDrawTime=ta();r.averageRedrawTime===void 0&&(r.averageRedrawTime=o-i),r.redrawCount===void 0&&(r.redrawCount=0),r.redrawCount++,r.redrawTotalTime===void 0&&(r.redrawTotalTime=0);var s=o-i;r.redrawTotalTime+=s,r.lastRedrawTime=s,r.averageRedrawTime=r.averageRedrawTime/2+s/2,r.requestedFrame=!1}else ME(r,!1,a);r.skipFrame=!1,tl(t)}};tl(t)}};var y3=function(e){this.init(e)},rP=y3,wo=rP.prototype;wo.clientFunctions=["redrawHint","render","renderTo","matchCanvasSize","nodeShapeImpl","arrowShapeImpl"];wo.init=function(r){var e=this;e.options=r,e.cy=r.cy;var t=e.container=r.cy.container(),n=e.cy.window();if(n){var a=n.document,i=a.head,o="__________cytoscape_stylesheet",s="__________cytoscape_container",u=a.getElementById(o)!=null;if(t.className.indexOf(s)<0&&(t.className=(t.className||"")+" "+s),!u){var l=a.createElement("style");l.id=o,l.textContent="."+s+" { position: relative; }",i.insertBefore(l,i.children[0])}var f=n.getComputedStyle(t),d=f.getPropertyValue("position");d==="static"&&Cr("A Cytoscape container has style position:static and so can not use UI extensions properly")}e.selection=[void 0,void 0,void 0,void 0,0],e.bezierProjPcts=[.05,.225,.4,.5,.6,.775,.95],e.hoverData={down:null,last:null,downTime:null,triggerMode:null,dragging:!1,initialPan:[null,null],capture:!1},e.dragData={possibleDragElements:[]},e.touchData={start:null,capture:!1,startPosition:[null,null,null,null,null,null],singleTouchStartTime:null,singleTouchMoved:!0,now:[null,null,null,null,null,null],earlier:[null,null,null,null,null,null]},e.redraws=0,e.showFps=r.showFps,e.debug=r.debug,e.webgl=r.webgl,e.hideEdgesOnViewport=r.hideEdgesOnViewport,e.textureOnViewport=r.textureOnViewport,e.wheelSensitivity=r.wheelSensitivity,e.motionBlurEnabled=r.motionBlur,e.forcedPixelRatio=qe(r.pixelRatio)?r.pixelRatio:null,e.motionBlur=r.motionBlur,e.motionBlurOpacity=r.motionBlurOpacity,e.motionBlurTransparency=1-e.motionBlurOpacity,e.motionBlurPxRatio=1,e.mbPxRBlurry=1,e.minMbLowQualFrames=4,e.fullQualityMb=!1,e.clearedForMotionBlur=[],e.desktopTapThreshold=r.desktopTapThreshold,e.desktopTapThreshold2=r.desktopTapThreshold*r.desktopTapThreshold,e.touchTapThreshold=r.touchTapThreshold,e.touchTapThreshold2=r.touchTapThreshold*r.touchTapThreshold,e.tapholdDuration=500,e.bindings=[],e.beforeRenderCallbacks=[],e.beforeRenderPriorities={animations:400,eleCalcs:300,eleTxrDeq:200,lyrTxrDeq:150,lyrTxrSkip:100},e.registerNodeShapes(),e.registerArrowShapes(),e.registerCalculationListeners()};wo.notify=function(r,e){var t=this,n=t.cy;if(!this.destroyed){if(r==="init"){t.load();return}if(r==="destroy"){t.destroy();return}(r==="add"||r==="remove"||r==="move"&&n.hasCompoundNodes()||r==="load"||r==="zorder"||r==="mount")&&t.invalidateCachedZSortedEles(),r==="viewport"&&t.redrawHint("select",!0),r==="gc"&&t.redrawHint("gc",!0),(r==="load"||r==="resize"||r==="mount")&&(t.invalidateContainerClientCoordsCache(),t.matchCanvasSize(t.container)),t.redrawHint("eles",!0),t.redrawHint("drag",!0),this.startRenderLoop(),this.redraw()}};wo.destroy=function(){var r=this;r.destroyed=!0,r.cy.stopAnimationLoop();for(var e=0;e<r.bindings.length;e++){var t=r.bindings[e],n=t,a=n.target;(a.off||a.removeEventListener).apply(a,n.args)}if(r.bindings=[],r.beforeRenderCallbacks=[],r.onUpdateEleCalcsFns=[],r.removeObserver&&r.removeObserver.disconnect(),r.styleObserver&&r.styleObserver.disconnect(),r.resizeObserver&&r.resizeObserver.disconnect(),r.labelCalcDiv)try{document.body.removeChild(r.labelCalcDiv)}catch{}};wo.isHeadless=function(){return!1};[c0,JA,eP,bo,aa,Is].forEach(function(r){Xe(wo,r)});var nv=1e3/60,tP={setupDequeueing:function(e){return function(){var n=this,a=this.renderer;if(!n.dequeueingSetup){n.dequeueingSetup=!0;var i=Ss(function(){a.redrawHint("eles",!0),a.redrawHint("drag",!0),a.redraw()},e.deqRedrawThreshold),o=function(l,f){var d=ta(),h=a.averageRedrawTime,g=a.lastRedrawTime,p=[],x=a.cy.extent(),b=a.getPixelRatio();for(l||a.flushRenderedStyleQueue();;){var w=ta(),y=w-d,E=w-f;if(g<nv){var C=nv-(l?h:0);if(E>=e.deqFastCost*C)break}else if(l){if(y>=e.deqCost*g||y>=e.deqAvgCost*h)break}else if(E>=e.deqNoDrawCost*nv)break;var S=e.deq(n,b,x);if(S.length>0)for(var R=0;R<S.length;R++)p.push(S[R]);else break}p.length>0&&(e.onDeqd(n,p),!l&&e.shouldRedraw(n,p,b,x)&&i())},s=e.priority||Zm;a.beforeRender(o,s(n))}}}},m3=(function(){function r(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:nl;qa(this,r),this.idsByKey=new ra,this.keyForId=new ra,this.cachesByLvl=new ra,this.lvls=[],this.getKey=e,this.doesEleInvalidateKey=t}return Na(r,[{key:"getIdsFor",value:function(t){t==null&&kr("Can not get id list for null key");var n=this.idsByKey,a=this.idsByKey.get(t);return a||(a=new go,n.set(t,a)),a}},{key:"addIdForKey",value:function(t,n){t!=null&&this.getIdsFor(t).add(n)}},{key:"deleteIdForKey",value:function(t,n){t!=null&&this.getIdsFor(t).delete(n)}},{key:"getNumberOfIdsForKey",value:function(t){return t==null?0:this.getIdsFor(t).size}},{key:"updateKeyMappingFor",value:function(t){var n=t.id(),a=this.keyForId.get(n),i=this.getKey(t);this.deleteIdForKey(a,n),this.addIdForKey(i,n),this.keyForId.set(n,i)}},{key:"deleteKeyMappingFor",value:function(t){var n=t.id(),a=this.keyForId.get(n);this.deleteIdForKey(a,n),this.keyForId.delete(n)}},{key:"keyHasChangedFor",value:function(t){var n=t.id(),a=this.keyForId.get(n),i=this.getKey(t);return a!==i}},{key:"isInvalid",value:function(t){return this.keyHasChangedFor(t)||this.doesEleInvalidateKey(t)}},{key:"getCachesAt",value:function(t){var n=this.cachesByLvl,a=this.lvls,i=n.get(t);return i||(i=new ra,n.set(t,i),a.push(t)),i}},{key:"getCache",value:function(t,n){return this.getCachesAt(n).get(t)}},{key:"get",value:function(t,n){var a=this.getKey(t),i=this.getCache(a,n);return i!=null&&this.updateKeyMappingFor(t),i}},{key:"getForCachedKey",value:function(t,n){var a=this.keyForId.get(t.id()),i=this.getCache(a,n);return i}},{key:"hasCache",value:function(t,n){return this.getCachesAt(n).has(t)}},{key:"has",value:function(t,n){var a=this.getKey(t);return this.hasCache(a,n)}},{key:"setCache",value:function(t,n,a){a.key=t,this.getCachesAt(n).set(t,a)}},{key:"set",value:function(t,n,a){var i=this.getKey(t);this.setCache(i,n,a),this.updateKeyMappingFor(t)}},{key:"deleteCache",value:function(t,n){this.getCachesAt(n).delete(t)}},{key:"delete",value:function(t,n){var a=this.getKey(t);this.deleteCache(a,n)}},{key:"invalidateKey",value:function(t){var n=this;this.lvls.forEach(function(a){return n.deleteCache(t,a)})}},{key:"invalidate",value:function(t){var n=t.id(),a=this.keyForId.get(n);this.deleteKeyMappingFor(t);var i=this.doesEleInvalidateKey(t);return i&&this.invalidateKey(a),i||this.getNumberOfIdsForKey(a)===0}}])})(),LE=25,qu=50,ju=-4,km=3,nP=7.99,b3=8,w3=1024,x3=1024,E3=1024,C3=.2,_3=.8,S3=10,T3=.15,R3=.1,A3=.9,P3=.9,I3=100,D3=1,ro={dequeue:"dequeue",downscale:"downscale",highQuality:"highQuality"},B3=wt({getKey:null,doesEleInvalidateKey:nl,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:H2,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),Xo=function(e,t){var n=this;n.renderer=e,n.onDequeues=[];var a=B3(t);Xe(n,a),n.lookup=new m3(a.getKey,a.doesEleInvalidateKey),n.setupDequeueing()},it=Xo.prototype;it.reasons=ro;it.getTextureQueue=function(r){var e=this;return e.eleImgCaches=e.eleImgCaches||{},e.eleImgCaches[r]=e.eleImgCaches[r]||[]};it.getRetiredTextureQueue=function(r){var e=this,t=e.eleImgCaches.retired=e.eleImgCaches.retired||{},n=t[r]=t[r]||[];return n};it.getElementQueue=function(){var r=this,e=r.eleCacheQueue=r.eleCacheQueue||new Ts(function(t,n){return n.reqs-t.reqs});return e};it.getElementKeyToQueue=function(){var r=this,e=r.eleKeyToCacheQueue=r.eleKeyToCacheQueue||{};return e};it.getElement=function(r,e,t,n,a){var i=this,o=this.renderer,s=o.cy.zoom(),u=this.lookup;if(!e||e.w===0||e.h===0||isNaN(e.w)||isNaN(e.h)||!r.visible()||r.removed()||!i.allowEdgeTxrCaching&&r.isEdge()||!i.allowParentTxrCaching&&r.isParent())return null;if(n==null&&(n=Math.ceil(Qm(s*t))),n<ju)n=ju;else if(s>=nP||n>km)return null;var l=Math.pow(2,n),f=e.h*l,d=e.w*l,h=o.eleTextBiggerThanMin(r,l);if(!this.isVisible(r,h))return null;var g=u.get(r,n);if(g&&g.invalidated&&(g.invalidated=!1,g.texture.invalidatedWidth-=g.width),g)return g;var p;if(f<=LE?p=LE:f<=qu?p=qu:p=Math.ceil(f/qu)*qu,f>E3||d>x3)return null;var x=i.getTextureQueue(p),b=x[x.length-2],w=function(){return i.recycleTexture(p,d)||i.addTexture(p,d)};b||(b=x[x.length-1]),b||(b=w()),b.width-b.usedWidth<d&&(b=w());for(var y=function(W){return W&&W.scaledLabelShown===h},E=a&&a===ro.dequeue,C=a&&a===ro.highQuality,S=a&&a===ro.downscale,R,_=n+1;_<=km;_++){var A=u.get(r,_);if(A){R=A;break}}var P=R&&R.level===n+1?R:null,I=function(){b.context.drawImage(P.texture.canvas,P.x,0,P.width,P.height,b.usedWidth,0,d,f)};if(b.context.setTransform(1,0,0,1,0,0),b.context.clearRect(b.usedWidth,0,d,p),y(P))I();else if(y(R))if(C){for(var D=R.level;D>n;D--)P=i.getElement(r,e,t,D,ro.downscale);I()}else return i.queueElement(r,R.level-1),R;else{var L;if(!E&&!C&&!S)for(var M=n-1;M>=ju;M--){var q=u.get(r,M);if(q){L=q;break}}if(y(L))return i.queueElement(r,n),L;b.context.translate(b.usedWidth,0),b.context.scale(l,l),this.drawElement(b.context,r,e,h,!1),b.context.scale(1/l,1/l),b.context.translate(-b.usedWidth,0)}return g={x:b.usedWidth,texture:b,level:n,scale:l,width:d,height:f,scaledLabelShown:h},b.usedWidth+=Math.ceil(d+b3),b.eleCaches.push(g),u.set(r,n,g),i.checkTextureFullness(b),g};it.invalidateElements=function(r){for(var e=0;e<r.length;e++)this.invalidateElement(r[e])};it.invalidateElement=function(r){var e=this,t=e.lookup,n=[],a=t.isInvalid(r);if(a){for(var i=ju;i<=km;i++){var o=t.getForCachedKey(r,i);o&&n.push(o)}var s=t.invalidate(r);if(s)for(var u=0;u<n.length;u++){var l=n[u],f=l.texture;f.invalidatedWidth+=l.width,l.invalidated=!0,e.checkTextureUtility(f)}e.removeFromQueue(r)}};it.checkTextureUtility=function(r){r.invalidatedWidth>=C3*r.width&&this.retireTexture(r)};it.checkTextureFullness=function(r){var e=this,t=e.getTextureQueue(r.height);r.usedWidth/r.width>_3&&r.fullnessChecks>=S3?Ba(t,r):r.fullnessChecks++};it.retireTexture=function(r){var e=this,t=r.height,n=e.getTextureQueue(t),a=this.lookup;Ba(n,r),r.retired=!0;for(var i=r.eleCaches,o=0;o<i.length;o++){var s=i[o];a.deleteCache(s.key,s.level)}Xm(i);var u=e.getRetiredTextureQueue(t);u.push(r)};it.addTexture=function(r,e){var t=this,n=t.getTextureQueue(r),a={};return n.push(a),a.eleCaches=[],a.height=r,a.width=Math.max(w3,e),a.usedWidth=0,a.invalidatedWidth=0,a.fullnessChecks=0,a.canvas=t.renderer.makeOffscreenCanvas(a.width,a.height),a.context=a.canvas.getContext("2d"),a};it.recycleTexture=function(r,e){for(var t=this,n=t.getTextureQueue(r),a=t.getRetiredTextureQueue(r),i=0;i<a.length;i++){var o=a[i];if(o.width>=e)return o.retired=!1,o.usedWidth=0,o.invalidatedWidth=0,o.fullnessChecks=0,Xm(o.eleCaches),o.context.setTransform(1,0,0,1,0,0),o.context.clearRect(0,0,o.width,o.height),Ba(a,o),n.push(o),o}};it.queueElement=function(r,e){var t=this,n=t.getElementQueue(),a=t.getElementKeyToQueue(),i=this.getKey(r),o=a[i];if(o)o.level=Math.max(o.level,e),o.eles.merge(r),o.reqs++,n.updateItem(o);else{var s={eles:r.spawn().merge(r),level:e,reqs:1,key:i};n.push(s),a[i]=s}};it.dequeue=function(r){for(var e=this,t=e.getElementQueue(),n=e.getElementKeyToQueue(),a=[],i=e.lookup,o=0;o<D3&&t.size()>0;o++){var s=t.pop(),u=s.key,l=s.eles[0],f=i.hasCache(l,s.level);if(n[u]=null,f)continue;a.push(s);var d=e.getBoundingBox(l);e.getElement(l,d,r,s.level,ro.dequeue)}return a};it.removeFromQueue=function(r){var e=this,t=e.getElementQueue(),n=e.getElementKeyToQueue(),a=this.getKey(r),i=n[a];i!=null&&(i.eles.length===1?(i.reqs=Ym,t.updateItem(i),t.pop(),n[a]=null):i.eles.unmerge(r))};it.onDequeue=function(r){this.onDequeues.push(r)};it.offDequeue=function(r){Ba(this.onDequeues,r)};it.setupDequeueing=tP.setupDequeueing({deqRedrawThreshold:I3,deqCost:T3,deqAvgCost:R3,deqNoDrawCost:A3,deqFastCost:P3,deq:function(e,t,n){return e.dequeue(t,n)},onDeqd:function(e,t){for(var n=0;n<e.onDequeues.length;n++){var a=e.onDequeues[n];a(t)}},shouldRedraw:function(e,t,n,a){for(var i=0;i<t.length;i++)for(var o=t[i].eles,s=0;s<o.length;s++){var u=o[s].boundingBox();if(e0(u,a))return!0}return!1},priority:function(e){return e.renderer.beforeRenderPriorities.eleTxrDeq}});var M3=1,is=-4,cl=2,L3=3.99,O3=50,k3=50,q3=.15,N3=.1,F3=.9,z3=.9,$3=1,OE=250,V3=4e3*4e3,kE=32767,G3=!0,aP=function(e){var t=this,n=t.renderer=e,a=n.cy;t.layersByLevel={},t.firstGet=!0,t.lastInvalidationTime=ta()-2*OE,t.skipping=!1,t.eleTxrDeqs=a.collection(),t.scheduleElementRefinement=Ss(function(){t.refineElementTextures(t.eleTxrDeqs),t.eleTxrDeqs.unmerge(t.eleTxrDeqs)},k3),n.beforeRender(function(o,s){s-t.lastInvalidationTime<=OE?t.skipping=!0:t.skipping=!1},n.beforeRenderPriorities.lyrTxrSkip);var i=function(s,u){return u.reqs-s.reqs};t.layersQueue=new Ts(i),t.setupDequeueing()},xt=aP.prototype,qE=0,W3=Math.pow(2,53)-1;xt.makeLayer=function(r,e){var t=Math.pow(2,e),n=Math.ceil(r.w*t),a=Math.ceil(r.h*t),i=this.renderer.makeOffscreenCanvas(n,a),o={id:qE=++qE%W3,bb:r,level:e,width:n,height:a,canvas:i,context:i.getContext("2d"),eles:[],elesQueue:[],reqs:0},s=o.context,u=-o.bb.x1,l=-o.bb.y1;return s.scale(t,t),s.translate(u,l),o};xt.getLayers=function(r,e,t){var n=this,a=n.renderer,i=a.cy,o=i.zoom(),s=n.firstGet;if(n.firstGet=!1,t==null){if(t=Math.ceil(Qm(o*e)),t<is)t=is;else if(o>=L3||t>cl)return null}n.validateLayersElesOrdering(t,r);var u=n.layersByLevel,l=Math.pow(2,t),f=u[t]=u[t]||[],d,h=n.levelIsComplete(t,r),g,p=function(){var I=function(N){if(n.validateLayersElesOrdering(N,r),n.levelIsComplete(N,r))return g=u[N],!0},D=function(N){if(!g)for(var W=t+N;is<=W&&W<=cl&&!I(W);W+=N);};D(1),D(-1);for(var L=f.length-1;L>=0;L--){var M=f[L];M.invalid&&Ba(f,M)}};if(!h)p();else return f;var x=function(){if(!d){d=Lt();for(var I=0;I<r.length;I++)$F(d,r[I].boundingBox())}return d},b=function(I){I=I||{};var D=I.after;x();var L=Math.ceil(d.w*l),M=Math.ceil(d.h*l);if(L>kE||M>kE)return null;var q=L*M;if(q>V3)return null;var N=n.makeLayer(d,t);if(D!=null){var W=f.indexOf(D)+1;f.splice(W,0,N)}else(I.insert===void 0||I.insert)&&f.unshift(N);return N};if(n.skipping&&!s)return null;for(var w=null,y=r.length/M3,E=!s,C=0;C<r.length;C++){var S=r[C],R=S._private.rscratch,_=R.imgLayerCaches=R.imgLayerCaches||{},A=_[t];if(A){w=A;continue}if((!w||w.eles.length>=y||!Q2(w.bb,S.boundingBox()))&&(w=b({insert:!0,after:w}),!w))return null;g||E?n.queueLayer(w,S):n.drawEleInLayer(w,S,t,e),w.eles.push(S),_[t]=w}return g||(E?null:f)};xt.getEleLevelForLayerLevel=function(r,e){return r};xt.drawEleInLayer=function(r,e,t,n){var a=this,i=this.renderer,o=r.context,s=e.boundingBox();s.w===0||s.h===0||!e.visible()||(t=a.getEleLevelForLayerLevel(t,n),i.setImgSmoothing(o,!1),i.drawCachedElement(o,e,null,null,t,G3),i.setImgSmoothing(o,!0))};xt.levelIsComplete=function(r,e){var t=this,n=t.layersByLevel[r];if(!n||n.length===0)return!1;for(var a=0,i=0;i<n.length;i++){var o=n[i];if(o.reqs>0||o.invalid)return!1;a+=o.eles.length}return a===e.length};xt.validateLayersElesOrdering=function(r,e){var t=this.layersByLevel[r];if(t)for(var n=0;n<t.length;n++){for(var a=t[n],i=-1,o=0;o<e.length;o++)if(a.eles[0]===e[o]){i=o;break}if(i<0){this.invalidateLayer(a);continue}for(var s=i,o=0;o<a.eles.length;o++)if(a.eles[o]!==e[s+o]){this.invalidateLayer(a);break}}};xt.updateElementsInLayers=function(r,e){for(var t=this,n=xs(r[0]),a=0;a<r.length;a++)for(var i=n?null:r[a],o=n?r[a]:r[a].ele,s=o._private.rscratch,u=s.imgLayerCaches=s.imgLayerCaches||{},l=is;l<=cl;l++){var f=u[l];f&&(i&&t.getEleLevelForLayerLevel(f.level)!==i.level||e(f,o,i))}};xt.haveLayers=function(){for(var r=this,e=!1,t=is;t<=cl;t++){var n=r.layersByLevel[t];if(n&&n.length>0){e=!0;break}}return e};xt.invalidateElements=function(r){var e=this;r.length!==0&&(e.lastInvalidationTime=ta(),!(r.length===0||!e.haveLayers())&&e.updateElementsInLayers(r,function(n,a,i){e.invalidateLayer(n)}))};xt.invalidateLayer=function(r){if(this.lastInvalidationTime=ta(),!r.invalid){var e=r.level,t=r.eles,n=this.layersByLevel[e];Ba(n,r),r.elesQueue=[],r.invalid=!0,r.replacement&&(r.replacement.invalid=!0);for(var a=0;a<t.length;a++){var i=t[a]._private.rscratch.imgLayerCaches;i&&(i[e]=null)}}};xt.refineElementTextures=function(r){var e=this;e.updateElementsInLayers(r,function(n,a,i){var o=n.replacement;if(o||(o=n.replacement=e.makeLayer(n.bb,n.level),o.replaces=n,o.eles=n.eles),!o.reqs)for(var s=0;s<o.eles.length;s++)e.queueLayer(o,o.eles[s])})};xt.enqueueElementRefinement=function(r){this.eleTxrDeqs.merge(r),this.scheduleElementRefinement()};xt.queueLayer=function(r,e){var t=this,n=t.layersQueue,a=r.elesQueue,i=a.hasId=a.hasId||{};if(!r.replacement){if(e){if(i[e.id()])return;a.push(e),i[e.id()]=!0}r.reqs?(r.reqs++,n.updateItem(r)):(r.reqs=1,n.push(r))}};xt.dequeue=function(r){for(var e=this,t=e.layersQueue,n=[],a=0;a<$3&&t.size()!==0;){var i=t.peek();if(i.replacement){t.pop();continue}if(i.replaces&&i!==i.replaces.replacement){t.pop();continue}if(i.invalid){t.pop();continue}var o=i.elesQueue.shift();o&&(e.drawEleInLayer(i,o,i.level,r),a++),n.length===0&&n.push(!0),i.elesQueue.length===0&&(t.pop(),i.reqs=0,i.replaces&&e.applyLayerReplacement(i),e.requestRedraw())}return n};xt.applyLayerReplacement=function(r){var e=this,t=e.layersByLevel[r.level],n=r.replaces,a=t.indexOf(n);if(!(a<0||n.invalid)){t[a]=r;for(var i=0;i<r.eles.length;i++){var o=r.eles[i]._private,s=o.imgLayerCaches=o.imgLayerCaches||{};s&&(s[r.level]=r)}e.requestRedraw()}};xt.requestRedraw=Ss(function(){var r=this.renderer;r.redrawHint("eles",!0),r.redrawHint("drag",!0),r.redraw()},100);xt.setupDequeueing=tP.setupDequeueing({deqRedrawThreshold:O3,deqCost:q3,deqAvgCost:N3,deqNoDrawCost:F3,deqFastCost:z3,deq:function(e,t){return e.dequeue(t)},onDeqd:Zm,shouldRedraw:H2,priority:function(e){return e.renderer.beforeRenderPriorities.lyrTxrDeq}});var iP={},NE;function U3(r,e){for(var t=0;t<e.length;t++){var n=e[t];r.lineTo(n.x,n.y)}}function H3(r,e,t){for(var n,a=0;a<e.length;a++){var i=e[a];a===0&&(n=i),r.lineTo(i.x,i.y)}r.quadraticCurveTo(t.x,t.y,n.x,n.y)}function FE(r,e,t){r.beginPath&&r.beginPath();for(var n=e,a=0;a<n.length;a++){var i=n[a];r.lineTo(i.x,i.y)}var o=t,s=t[0];r.moveTo(s.x,s.y);for(var a=1;a<o.length;a++){var i=o[a];r.lineTo(i.x,i.y)}r.closePath&&r.closePath()}function K3(r,e,t,n,a){r.beginPath&&r.beginPath(),r.arc(t,n,a,0,Math.PI*2,!1);var i=e,o=i[0];r.moveTo(o.x,o.y);for(var s=0;s<i.length;s++){var u=i[s];r.lineTo(u.x,u.y)}r.closePath&&r.closePath()}function j3(r,e,t,n){r.arc(e,t,n,0,Math.PI*2,!1)}iP.arrowShapeImpl=function(r){return(NE||(NE={polygon:U3,"triangle-backcurve":H3,"triangle-tee":FE,"circle-triangle":K3,"triangle-cross":FE,circle:j3}))[r]};var Vn={};Vn.drawElement=function(r,e,t,n,a,i){var o=this;e.isNode()?o.drawNode(r,e,t,n,a,i):o.drawEdge(r,e,t,n,a,i)};Vn.drawElementOverlay=function(r,e){var t=this;e.isNode()?t.drawNodeOverlay(r,e):t.drawEdgeOverlay(r,e)};Vn.drawElementUnderlay=function(r,e){var t=this;e.isNode()?t.drawNodeUnderlay(r,e):t.drawEdgeUnderlay(r,e)};Vn.drawCachedElementPortion=function(r,e,t,n,a,i,o,s){var u=this,l=t.getBoundingBox(e);if(!(l.w===0||l.h===0)){var f=t.getElement(e,l,n,a,i);if(f!=null){var d=s(u,e);if(d===0)return;var h=o(u,e),g=l.x1,p=l.y1,x=l.w,b=l.h,w,y,E,C,S;if(h!==0){var R=t.getRotationPoint(e);E=R.x,C=R.y,r.translate(E,C),r.rotate(h),S=u.getImgSmoothing(r),S||u.setImgSmoothing(r,!0);var _=t.getRotationOffset(e);w=_.x,y=_.y}else w=g,y=p;var A;d!==1&&(A=r.globalAlpha,r.globalAlpha=A*d),r.drawImage(f.texture.canvas,f.x,0,f.width,f.height,w,y,x,b),d!==1&&(r.globalAlpha=A),h!==0&&(r.rotate(-h),r.translate(-E,-C),S||u.setImgSmoothing(r,!1))}else t.drawElement(r,e)}};var Y3=function(){return 0},Z3=function(e,t){return e.getTextAngle(t,null)},X3=function(e,t){return e.getTextAngle(t,"source")},Q3=function(e,t){return e.getTextAngle(t,"target")},J3=function(e,t){return t.effectiveOpacity()},av=function(e,t){return t.pstyle("text-opacity").pfValue*t.effectiveOpacity()};Vn.drawCachedElement=function(r,e,t,n,a,i){var o=this,s=o.data,u=s.eleTxrCache,l=s.lblTxrCache,f=s.slbTxrCache,d=s.tlbTxrCache,h=e.boundingBox(),g=i===!0?u.reasons.highQuality:null;if(!(h.w===0||h.h===0||!e.visible())&&(!n||e0(h,n))){var p=e.isEdge(),x=e.element()._private.rscratch.badLine;o.drawElementUnderlay(r,e),o.drawCachedElementPortion(r,e,u,t,a,g,Y3,J3),(!p||!x)&&o.drawCachedElementPortion(r,e,l,t,a,g,Z3,av),p&&!x&&(o.drawCachedElementPortion(r,e,f,t,a,g,X3,av),o.drawCachedElementPortion(r,e,d,t,a,g,Q3,av)),o.drawElementOverlay(r,e)}};Vn.drawElements=function(r,e){for(var t=this,n=0;n<e.length;n++){var a=e[n];t.drawElement(r,a)}};Vn.drawCachedElements=function(r,e,t,n){for(var a=this,i=0;i<e.length;i++){var o=e[i];a.drawCachedElement(r,o,t,n)}};Vn.drawCachedNodes=function(r,e,t,n){for(var a=this,i=0;i<e.length;i++){var o=e[i];o.isNode()&&a.drawCachedElement(r,o,t,n)}};Vn.drawLayeredElements=function(r,e,t,n){var a=this,i=a.data.lyrTxrCache.getLayers(e,t);if(i)for(var o=0;o<i.length;o++){var s=i[o],u=s.bb;u.w===0||u.h===0||r.drawImage(s.canvas,u.x1,u.y1,u.w,u.h)}else a.drawCachedElements(r,e,t,n)};var ia={};ia.drawEdge=function(r,e,t){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0,o=this,s=e._private.rscratch;if(!(i&&!e.visible())&&!(s.badLine||s.allpts==null||isNaN(s.allpts[0]))){var u;t&&(u=t,r.translate(-u.x1,-u.y1));var l=i?e.pstyle("opacity").value:1,f=i?e.pstyle("line-opacity").value:1,d=e.pstyle("curve-style").value,h=e.pstyle("line-style").value,g=e.pstyle("width").pfValue,p=e.pstyle("line-cap").value,x=e.pstyle("line-outline-width").value,b=e.pstyle("line-outline-color").value,w=l*f,y=l*f,E=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:w;d==="straight-triangle"?(o.eleStrokeStyle(r,e,N),o.drawEdgeTrianglePath(e,r,s.allpts)):(r.lineWidth=g,r.lineCap=p,o.eleStrokeStyle(r,e,N),o.drawEdgePath(e,r,s.allpts,h),r.lineCap="butt")},C=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:w;if(r.lineWidth=g+x,r.lineCap=p,x>0)o.colorStrokeStyle(r,b[0],b[1],b[2],N);else{r.lineCap="butt";return}d==="straight-triangle"?o.drawEdgeTrianglePath(e,r,s.allpts):(o.drawEdgePath(e,r,s.allpts,h),r.lineCap="butt")},S=function(){a&&o.drawEdgeOverlay(r,e)},R=function(){a&&o.drawEdgeUnderlay(r,e)},_=function(){var N=arguments.length>0&&arguments[0]!==void 0?arguments[0]:y;o.drawArrowheads(r,e,N)},A=function(){o.drawElementText(r,e,null,n)};r.lineJoin="round";var P=e.pstyle("ghost").value==="yes";if(P){var I=e.pstyle("ghost-offset-x").pfValue,D=e.pstyle("ghost-offset-y").pfValue,L=e.pstyle("ghost-opacity").value,M=w*L;r.translate(I,D),E(M),_(M),r.translate(-I,-D)}else C();R(),E(),_(),S(),A(),t&&r.translate(u.x1,u.y1)}};var oP=function(e){if(!["overlay","underlay"].includes(e))throw new Error("Invalid state");return function(t,n){if(n.visible()){var a=n.pstyle("".concat(e,"-opacity")).value;if(a!==0){var i=this,o=i.usePaths(),s=n._private.rscratch,u=n.pstyle("".concat(e,"-padding")).pfValue,l=2*u,f=n.pstyle("".concat(e,"-color")).value;t.lineWidth=l,s.edgeType==="self"&&!o?t.lineCap="butt":t.lineCap="round",i.colorStrokeStyle(t,f[0],f[1],f[2],a),i.drawEdgePath(n,t,s.allpts,"solid")}}}};ia.drawEdgeOverlay=oP("overlay");ia.drawEdgeUnderlay=oP("underlay");ia.drawEdgePath=function(r,e,t,n){var a=r._private.rscratch,i=e,o,s=!1,u=this.usePaths(),l=r.pstyle("line-dash-pattern").pfValue,f=r.pstyle("line-dash-offset").pfValue;if(u){var d=t.join("$"),h=a.pathCacheKey&&a.pathCacheKey===d;h?(o=e=a.pathCache,s=!0):(o=e=new Path2D,a.pathCacheKey=d,a.pathCache=o)}if(i.setLineDash)switch(n){case"dotted":i.setLineDash([1,1]);break;case"dashed":i.setLineDash(l),i.lineDashOffset=f;break;case"solid":i.setLineDash([]);break}if(!s&&!a.badLine)switch(e.beginPath&&e.beginPath(),e.moveTo(t[0],t[1]),a.edgeType){case"bezier":case"self":case"compound":case"multibezier":for(var g=2;g+3<t.length;g+=4)e.quadraticCurveTo(t[g],t[g+1],t[g+2],t[g+3]);break;case"straight":case"haystack":for(var p=2;p+1<t.length;p+=2)e.lineTo(t[p],t[p+1]);break;case"segments":if(a.isRound){var x=Gt(a.roundCorners),b;try{for(x.s();!(b=x.n()).done;){var w=b.value;jA(e,w)}}catch(E){x.e(E)}finally{x.f()}e.lineTo(t[t.length-2],t[t.length-1])}else for(var y=2;y+1<t.length;y+=2)e.lineTo(t[y],t[y+1]);break}e=i,u?e.stroke(o):e.stroke(),e.setLineDash&&e.setLineDash([])};ia.drawEdgeTrianglePath=function(r,e,t){e.fillStyle=e.strokeStyle;for(var n=r.pstyle("width").pfValue,a=0;a+1<t.length;a+=2){var i=[t[a+2]-t[a],t[a+3]-t[a+1]],o=Math.sqrt(i[0]*i[0]+i[1]*i[1]),s=[i[1]/o,-i[0]/o],u=[s[0]*n/2,s[1]*n/2];e.beginPath(),e.moveTo(t[a]-u[0],t[a+1]-u[1]),e.lineTo(t[a]+u[0],t[a+1]+u[1]),e.lineTo(t[a+2],t[a+3]),e.closePath(),e.fill()}};ia.drawArrowheads=function(r,e,t){var n=e._private.rscratch,a=n.edgeType==="haystack";a||this.drawArrowhead(r,e,"source",n.arrowStartX,n.arrowStartY,n.srcArrowAngle,t),this.drawArrowhead(r,e,"mid-target",n.midX,n.midY,n.midtgtArrowAngle,t),this.drawArrowhead(r,e,"mid-source",n.midX,n.midY,n.midsrcArrowAngle,t),a||this.drawArrowhead(r,e,"target",n.arrowEndX,n.arrowEndY,n.tgtArrowAngle,t)};ia.drawArrowhead=function(r,e,t,n,a,i,o){if(!(isNaN(n)||n==null||isNaN(a)||a==null||isNaN(i)||i==null)){var s=this,u=e.pstyle(t+"-arrow-shape").value;if(u!=="none"){var l=e.pstyle(t+"-arrow-fill").value==="hollow"?"both":"filled",f=e.pstyle(t+"-arrow-fill").value,d=e.pstyle("width").pfValue,h=e.pstyle(t+"-arrow-width"),g=h.value==="match-line"?d:h.pfValue;h.units==="%"&&(g*=d);var p=e.pstyle("opacity").value;o===void 0&&(o=p);var x=r.globalCompositeOperation;(o!==1||f==="hollow")&&(r.globalCompositeOperation="destination-out",s.colorFillStyle(r,255,255,255,1),s.colorStrokeStyle(r,255,255,255,1),s.drawArrowShape(e,r,l,d,u,g,n,a,i),r.globalCompositeOperation=x);var b=e.pstyle(t+"-arrow-color").value;s.colorFillStyle(r,b[0],b[1],b[2],o),s.colorStrokeStyle(r,b[0],b[1],b[2],o),s.drawArrowShape(e,r,f,d,u,g,n,a,i)}}};ia.drawArrowShape=function(r,e,t,n,a,i,o,s,u){var l=this,f=this.usePaths()&&a!=="triangle-cross",d=!1,h,g=e,p={x:o,y:s},x=r.pstyle("arrow-scale").value,b=this.getArrowWidth(n,x),w=l.arrowShapes[a];if(f){var y=l.arrowPathCache=l.arrowPathCache||[],E=ci(a),C=y[E];C!=null?(h=e=C,d=!0):(h=e=new Path2D,y[E]=h)}d||(e.beginPath&&e.beginPath(),f?w.draw(e,1,0,{x:0,y:0},1):w.draw(e,b,u,p,n),e.closePath&&e.closePath()),e=g,f&&(e.translate(o,s),e.rotate(u),e.scale(b,b)),(t==="filled"||t==="both")&&(f?e.fill(h):e.fill()),(t==="hollow"||t==="both")&&(e.lineWidth=i/(f?b:1),e.lineJoin="miter",f?e.stroke(h):e.stroke()),f&&(e.scale(1/b,1/b),e.rotate(-u),e.translate(-o,-s))};var h0={};h0.safeDrawImage=function(r,e,t,n,a,i,o,s,u,l){if(!(a<=0||i<=0||u<=0||l<=0))try{r.drawImage(e,t,n,a,i,o,s,u,l)}catch(f){Cr(f)}};h0.drawInscribedImage=function(r,e,t,n,a){var i=this,o=t.position(),s=o.x,u=o.y,l=t.cy().style(),f=l.getIndexedStyle.bind(l),d=f(t,"background-fit","value",n),h=f(t,"background-repeat","value",n),g=t.width(),p=t.height(),x=t.padding()*2,b=g+(f(t,"background-width-relative-to","value",n)==="inner"?0:x),w=p+(f(t,"background-height-relative-to","value",n)==="inner"?0:x),y=t._private.rscratch,E=f(t,"background-clip","value",n),C=E==="node",S=f(t,"background-image-opacity","value",n)*a,R=f(t,"background-image-smoothing","value",n),_=t.pstyle("corner-radius").value;_!=="auto"&&(_=t.pstyle("corner-radius").pfValue);var A=e.width||e.cachedW,P=e.height||e.cachedH;(A==null||P==null)&&(document.body.appendChild(e),A=e.cachedW=e.width||e.offsetWidth,P=e.cachedH=e.height||e.offsetHeight,document.body.removeChild(e));var I=A,D=P;if(f(t,"background-width","value",n)!=="auto"&&(f(t,"background-width","units",n)==="%"?I=f(t,"background-width","pfValue",n)*b:I=f(t,"background-width","pfValue",n)),f(t,"background-height","value",n)!=="auto"&&(f(t,"background-height","units",n)==="%"?D=f(t,"background-height","pfValue",n)*w:D=f(t,"background-height","pfValue",n)),!(I===0||D===0)){if(d==="contain"){var L=Math.min(b/I,w/D);I*=L,D*=L}else if(d==="cover"){var L=Math.max(b/I,w/D);I*=L,D*=L}var M=s-b/2,q=f(t,"background-position-x","units",n),N=f(t,"background-position-x","pfValue",n);q==="%"?M+=(b-I)*N:M+=N;var W=f(t,"background-offset-x","units",n),V=f(t,"background-offset-x","pfValue",n);W==="%"?M+=(b-I)*V:M+=V;var $=u-w/2,Z=f(t,"background-position-y","units",n),ee=f(t,"background-position-y","pfValue",n);Z==="%"?$+=(w-D)*ee:$+=ee;var K=f(t,"background-offset-y","units",n),j=f(t,"background-offset-y","pfValue",n);K==="%"?$+=(w-D)*j:$+=j,y.pathCache&&(M-=s,$-=u,s=0,u=0);var fe=r.globalAlpha;r.globalAlpha=S;var G=i.getImgSmoothing(r),z=!1;if(R==="no"&&G?(i.setImgSmoothing(r,!1),z=!0):R==="yes"&&!G&&(i.setImgSmoothing(r,!0),z=!0),h==="no-repeat")C&&(r.save(),y.pathCache?r.clip(y.pathCache):(i.nodeShapes[i.getNodeShape(t)].draw(r,s,u,b,w,_,y),r.clip())),i.safeDrawImage(r,e,0,0,A,P,M,$,I,D),C&&r.restore();else{var Y=r.createPattern(e,h);r.fillStyle=Y,i.nodeShapes[i.getNodeShape(t)].draw(r,s,u,b,w,_,y),r.translate(M,$),r.fill(),r.translate(-M,-$)}r.globalAlpha=fe,z&&i.setImgSmoothing(r,G)}};var bi={};bi.eleTextBiggerThanMin=function(r,e){if(!e){var t=r.cy().zoom(),n=this.getPixelRatio(),a=Math.ceil(Qm(t*n));e=Math.pow(2,a)}var i=r.pstyle("font-size").pfValue*e,o=r.pstyle("min-zoomed-font-size").pfValue;return!(i<o)};bi.drawElementText=function(r,e,t,n,a){var i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0,o=this;if(n==null){if(i&&!o.eleTextBiggerThanMin(e))return}else if(n===!1)return;if(e.isNode()){var s=e.pstyle("label");if(!s||!s.value)return;var u=o.getLabelJustification(e);r.textAlign=u,r.textBaseline="bottom"}else{var l=e.element()._private.rscratch.badLine,f=e.pstyle("label"),d=e.pstyle("source-label"),h=e.pstyle("target-label");if(l||(!f||!f.value)&&(!d||!d.value)&&(!h||!h.value))return;r.textAlign="center",r.textBaseline="bottom"}var g=!t,p;t&&(p=t,r.translate(-p.x1,-p.y1)),a==null?(o.drawText(r,e,null,g,i),e.isEdge()&&(o.drawText(r,e,"source",g,i),o.drawText(r,e,"target",g,i))):o.drawText(r,e,a,g,i),t&&r.translate(p.x1,p.y1)};bi.getFontCache=function(r){var e;this.fontCaches=this.fontCaches||[];for(var t=0;t<this.fontCaches.length;t++)if(e=this.fontCaches[t],e.context===r)return e;return e={context:r},this.fontCaches.push(e),e};bi.setupTextStyle=function(r,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,n=e.pstyle("font-style").strValue,a=e.pstyle("font-size").pfValue+"px",i=e.pstyle("font-family").strValue,o=e.pstyle("font-weight").strValue,s=t?e.effectiveOpacity()*e.pstyle("text-opacity").value:1,u=e.pstyle("text-outline-opacity").value*s,l=e.pstyle("color").value,f=e.pstyle("text-outline-color").value;r.font=n+" "+o+" "+a+" "+i,r.lineJoin="round",this.colorFillStyle(r,l[0],l[1],l[2],s),this.colorStrokeStyle(r,f[0],f[1],f[2],u)};function eV(r,e,t,n,a){var i=Math.min(n,a),o=i/2,s=e+n/2,u=t+a/2;r.beginPath(),r.arc(s,u,o,0,Math.PI*2),r.closePath()}function zE(r,e,t,n,a){var i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:5,o=Math.min(i,n/2,a/2);r.beginPath(),r.moveTo(e+o,t),r.lineTo(e+n-o,t),r.quadraticCurveTo(e+n,t,e+n,t+o),r.lineTo(e+n,t+a-o),r.quadraticCurveTo(e+n,t+a,e+n-o,t+a),r.lineTo(e+o,t+a),r.quadraticCurveTo(e,t+a,e,t+a-o),r.lineTo(e,t+o),r.quadraticCurveTo(e,t,e+o,t),r.closePath()}bi.getTextAngle=function(r,e){var t,n=r._private,a=n.rscratch,i=e?e+"-":"",o=r.pstyle(i+"text-rotation");if(o.strValue==="autorotate"){var s=$t(a,"labelAngle",e);t=r.isEdge()?s:0}else o.strValue==="none"?t=0:t=o.pfValue;return t};bi.drawText=function(r,e,t){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,i=e._private,o=i.rscratch,s=a?e.effectiveOpacity():1;if(!(a&&(s===0||e.pstyle("text-opacity").value===0))){t==="main"&&(t=null);var u=$t(o,"labelX",t),l=$t(o,"labelY",t),f,d,h=this.getLabelText(e,t);if(h!=null&&h!==""&&!isNaN(u)&&!isNaN(l)){this.setupTextStyle(r,e,a);var g=t?t+"-":"",p=$t(o,"labelWidth",t),x=$t(o,"labelHeight",t),b=e.pstyle(g+"text-margin-x").pfValue,w=e.pstyle(g+"text-margin-y").pfValue,y=e.isEdge(),E=e.pstyle("text-halign").value,C=e.pstyle("text-valign").value;y&&(E="center",C="center"),u+=b,l+=w;var S;switch(n?S=this.getTextAngle(e,t):S=0,S!==0&&(f=u,d=l,r.translate(f,d),r.rotate(S),u=0,l=0),C){case"top":break;case"center":l+=x/2;break;case"bottom":l+=x;break}var R=e.pstyle("text-background-opacity").value,_=e.pstyle("text-border-opacity").value,A=e.pstyle("text-border-width").pfValue,P=e.pstyle("text-background-padding").pfValue,I=e.pstyle("text-background-shape").strValue,D=I==="round-rectangle"||I==="roundrectangle",L=I==="circle",M=2;if(R>0||A>0&&_>0){var q=r.fillStyle,N=r.strokeStyle,W=r.lineWidth,V=e.pstyle("text-background-color").value,$=e.pstyle("text-border-color").value,Z=e.pstyle("text-border-style").value,ee=R>0,K=A>0&&_>0,j=u-P;switch(E){case"left":j-=p;break;case"center":j-=p/2;break}var fe=l-x-P,G=p+2*P,z=x+2*P;if(ee&&(r.fillStyle="rgba(".concat(V[0],",").concat(V[1],",").concat(V[2],",").concat(R*s,")")),K&&(r.strokeStyle="rgba(".concat($[0],",").concat($[1],",").concat($[2],",").concat(_*s,")"),r.lineWidth=A,r.setLineDash))switch(Z){case"dotted":r.setLineDash([1,1]);break;case"dashed":r.setLineDash([4,2]);break;case"double":r.lineWidth=A/4,r.setLineDash([]);break;case"solid":default:r.setLineDash([]);break}if(D?(r.beginPath(),zE(r,j,fe,G,z,M)):L?(r.beginPath(),eV(r,j,fe,G,z)):(r.beginPath(),r.rect(j,fe,G,z)),ee&&r.fill(),K&&r.stroke(),K&&Z==="double"){var Y=A/2;r.beginPath(),D?zE(r,j+Y,fe+Y,G-2*Y,z-2*Y,M):r.rect(j+Y,fe+Y,G-2*Y,z-2*Y),r.stroke()}r.fillStyle=q,r.strokeStyle=N,r.lineWidth=W,r.setLineDash&&r.setLineDash([])}var te=2*e.pstyle("text-outline-width").pfValue;if(te>0&&(r.lineWidth=te),e.pstyle("text-wrap").value==="wrap"){var ue=$t(o,"labelWrapCachedLines",t),oe=$t(o,"labelLineHeight",t),X=p/2,Q=this.getLabelJustification(e);switch(Q==="auto"||(E==="left"?Q==="left"?u+=-p:Q==="center"&&(u+=-X):E==="center"?Q==="left"?u+=-X:Q==="right"&&(u+=X):E==="right"&&(Q==="center"?u+=X:Q==="right"&&(u+=p))),C){case"top":l-=(ue.length-1)*oe;break;case"center":case"bottom":l-=(ue.length-1)*oe;break}for(var ie=0;ie<ue.length;ie++)te>0&&r.strokeText(ue[ie],u,l),r.fillText(ue[ie],u,l),l+=oe}else te>0&&r.strokeText(h,u,l),r.fillText(h,u,l);S!==0&&(r.rotate(-S),r.translate(-f,-d))}}};var za={};za.drawNode=function(r,e,t){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0,o=this,s,u,l=e._private,f=l.rscratch,d=e.position();if(!(!qe(d.x)||!qe(d.y))&&!(i&&!e.visible())){var h=i?e.effectiveOpacity():1,g=o.usePaths(),p,x=!1,b=e.padding();s=e.width()+2*b,u=e.height()+2*b;var w;t&&(w=t,r.translate(-w.x1,-w.y1));for(var y=e.pstyle("background-image"),E=y.value,C=new Array(E.length),S=new Array(E.length),R=0,_=0;_<E.length;_++){var A=E[_],P=C[_]=A!=null&&A!=="none";if(P){var I=e.cy().style().getIndexedStyle(e,"background-image-crossorigin","value",_);R++,S[_]=o.getCachedImage(A,I,function(){l.backgroundTimestamp=Date.now(),e.emitAndNotify("background")})}}var D=e.pstyle("background-blacken").value,L=e.pstyle("border-width").pfValue,M=e.pstyle("background-opacity").value*h,q=e.pstyle("border-color").value,N=e.pstyle("border-style").value,W=e.pstyle("border-join").value,V=e.pstyle("border-cap").value,$=e.pstyle("border-position").value,Z=e.pstyle("border-dash-pattern").pfValue,ee=e.pstyle("border-dash-offset").pfValue,K=e.pstyle("border-opacity").value*h,j=e.pstyle("outline-width").pfValue,fe=e.pstyle("outline-color").value,G=e.pstyle("outline-style").value,z=e.pstyle("outline-opacity").value*h,Y=e.pstyle("outline-offset").value,te=e.pstyle("corner-radius").value;te!=="auto"&&(te=e.pstyle("corner-radius").pfValue);var ue=function(){var Oe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:M;o.eleFillStyle(r,e,Oe)},oe=function(){var Oe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:K;o.colorStrokeStyle(r,q[0],q[1],q[2],Oe)},X=function(){var Oe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:z;o.colorStrokeStyle(r,fe[0],fe[1],fe[2],Oe)},Q=function(Oe,ye,O,ne){var he=o.nodePathCache=o.nodePathCache||[],ge=U2(O==="polygon"?O+","+ne.join(","):O,""+ye,""+Oe,""+te),be=he[ge],Ve,Be=!1;return be!=null?(Ve=be,Be=!0,f.pathCache=Ve):(Ve=new Path2D,he[ge]=f.pathCache=Ve),{path:Ve,cacheHit:Be}},ie=e.pstyle("shape").strValue,de=e.pstyle("shape-polygon-points").pfValue;if(g){r.translate(d.x,d.y);var we=Q(s,u,ie,de);p=we.path,x=we.cacheHit}var Ae=function(){if(!x){var Oe=d;g&&(Oe={x:0,y:0}),o.nodeShapes[o.getNodeShape(e)].draw(p||r,Oe.x,Oe.y,s,u,te,f)}g?r.fill(p):r.fill()},ve=function(){for(var Oe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:h,ye=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,O=l.backgrounding,ne=0,he=0;he<S.length;he++){var ge=e.cy().style().getIndexedStyle(e,"background-image-containment","value",he);if(ye&&ge==="over"||!ye&&ge==="inside"){ne++;continue}C[he]&&S[he].complete&&!S[he].error&&(ne++,o.drawInscribedImage(r,S[he],e,he,Oe))}l.backgrounding=ne!==R,O!==l.backgrounding&&e.updateStyle(!1)},le=function(){var Oe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,ye=arguments.length>1&&arguments[1]!==void 0?arguments[1]:h;o.hasPie(e)&&(o.drawPie(r,e,ye),Oe&&(g||o.nodeShapes[o.getNodeShape(e)].draw(r,d.x,d.y,s,u,te,f)))},Me=function(){var Oe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,ye=arguments.length>1&&arguments[1]!==void 0?arguments[1]:h;o.hasStripe(e)&&(r.save(),g?r.clip(f.pathCache):(o.nodeShapes[o.getNodeShape(e)].draw(r,d.x,d.y,s,u,te,f),r.clip()),o.drawStripe(r,e,ye),r.restore(),Oe&&(g||o.nodeShapes[o.getNodeShape(e)].draw(r,d.x,d.y,s,u,te,f)))},Se=function(){var Oe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:h,ye=(D>0?D:-D)*Oe,O=D>0?0:255;D!==0&&(o.colorFillStyle(r,O,O,O,ye),g?r.fill(p):r.fill())},Ee=function(){if(L>0){if(r.lineWidth=L,r.lineCap=V,r.lineJoin=W,r.setLineDash)switch(N){case"dotted":r.setLineDash([1,1]);break;case"dashed":r.setLineDash(Z),r.lineDashOffset=ee;break;case"solid":case"double":r.setLineDash([]);break}if($!=="center"){if(r.save(),r.lineWidth*=2,$==="inside")g?r.clip(p):r.clip();else{var Oe=new Path2D;Oe.rect(-s/2-L,-u/2-L,s+2*L,u+2*L),Oe.addPath(p),r.clip(Oe,"evenodd")}g?r.stroke(p):r.stroke(),r.restore()}else g?r.stroke(p):r.stroke();if(N==="double"){r.lineWidth=L/3;var ye=r.globalCompositeOperation;r.globalCompositeOperation="destination-out",g?r.stroke(p):r.stroke(),r.globalCompositeOperation=ye}r.setLineDash&&r.setLineDash([])}},re=function(){if(j>0){if(r.lineWidth=j,r.lineCap="butt",r.setLineDash)switch(G){case"dotted":r.setLineDash([1,1]);break;case"dashed":r.setLineDash([4,2]);break;case"solid":case"double":r.setLineDash([]);break}var Oe=d;g&&(Oe={x:0,y:0});var ye=o.getNodeShape(e),O=L;$==="inside"&&(O=0),$==="outside"&&(O*=2);var ne=(s+O+(j+Y))/s,he=(u+O+(j+Y))/u,ge=s*ne,be=u*he,Ve=o.nodeShapes[ye].points,Be;if(g){var He=Q(ge,be,ye,Ve);Be=He.path}if(ye==="ellipse")o.drawEllipsePath(Be||r,Oe.x,Oe.y,ge,be);else if(["round-diamond","round-heptagon","round-hexagon","round-octagon","round-pentagon","round-polygon","round-triangle","round-tag"].includes(ye)){var We=0,Ze=0,sr=0;ye==="round-diamond"?We=(O+Y+j)*1.4:ye==="round-heptagon"?(We=(O+Y+j)*1.075,sr=-(O/2+Y+j)/35):ye==="round-hexagon"?We=(O+Y+j)*1.12:ye==="round-pentagon"?(We=(O+Y+j)*1.13,sr=-(O/2+Y+j)/15):ye==="round-tag"?(We=(O+Y+j)*1.12,Ze=(O/2+j+Y)*.07):ye==="round-triangle"&&(We=(O+Y+j)*(Math.PI/2),sr=-(O+Y/2+j)/Math.PI),We!==0&&(ne=(s+We)/s,ge=s*ne,["round-hexagon","round-tag"].includes(ye)||(he=(u+We)/u,be=u*he)),te=te==="auto"?rA(ge,be):te;for(var ar=ge/2,Ke=be/2,lr=te+(O+j+Y)/2,ir=new Array(Ve.length/2),Ur=new Array(Ve.length/2),Mr=0;Mr<Ve.length/2;Mr++)ir[Mr]={x:Oe.x+Ze+ar*Ve[Mr*2],y:Oe.y+sr+Ke*Ve[Mr*2+1]};var ct,Lr,jr,Nr,Qr=ir.length;for(Lr=ir[Qr-1],ct=0;ct<Qr;ct++)jr=ir[ct%Qr],Nr=ir[(ct+1)%Qr],Ur[ct]=d0(Lr,jr,Nr,lr),Lr=jr,jr=Nr;o.drawRoundPolygonPath(Be||r,Oe.x+Ze,Oe.y+sr,s*ne,u*he,Ve,Ur)}else if(["roundrectangle","round-rectangle"].includes(ye))te=te==="auto"?Ma(ge,be):te,o.drawRoundRectanglePath(Be||r,Oe.x,Oe.y,ge,be,te+(O+j+Y)/2);else if(["cutrectangle","cut-rectangle"].includes(ye))te=te==="auto"?r0():te,o.drawCutRectanglePath(Be||r,Oe.x,Oe.y,ge,be,null,te+(O+j+Y)/4);else if(["bottomroundrectangle","bottom-round-rectangle"].includes(ye))te=te==="auto"?Ma(ge,be):te,o.drawBottomRoundRectanglePath(Be||r,Oe.x,Oe.y,ge,be,te+(O+j+Y)/2);else if(ye==="barrel")o.drawBarrelPath(Be||r,Oe.x,Oe.y,ge,be);else if(ye.startsWith("polygon")||["rhomboid","right-rhomboid","round-tag","tag","vee"].includes(ye)){var Pn=(O+j+Y)/s;Ve=al(il(Ve,Pn)),o.drawPolygonPath(Be||r,Oe.x,Oe.y,s,u,Ve)}else{var Vr=(O+j+Y)/s;Ve=al(il(Ve,-Vr)),o.drawPolygonPath(Be||r,Oe.x,Oe.y,s,u,Ve)}if(g?r.stroke(Be):r.stroke(),G==="double"){r.lineWidth=O/3;var pn=r.globalCompositeOperation;r.globalCompositeOperation="destination-out",g?r.stroke(Be):r.stroke(),r.globalCompositeOperation=pn}r.setLineDash&&r.setLineDash([])}},ce=function(){a&&o.drawNodeOverlay(r,e,d,s,u)},_e=function(){a&&o.drawNodeUnderlay(r,e,d,s,u)},me=function(){o.drawElementText(r,e,null,n)},Te=e.pstyle("ghost").value==="yes";if(Te){var De=e.pstyle("ghost-offset-x").pfValue,Ne=e.pstyle("ghost-offset-y").pfValue,ze=e.pstyle("ghost-opacity").value,$e=ze*h;r.translate(De,Ne),X(),re(),ue(ze*M),Ae(),ve($e,!0),oe(ze*K),Ee(),le(D!==0||L!==0),Me(D!==0||L!==0),ve($e,!1),Se($e),r.translate(-De,-Ne)}g&&r.translate(-d.x,-d.y),_e(),g&&r.translate(d.x,d.y),X(),re(),ue(),Ae(),ve(h,!0),oe(),Ee(),le(D!==0||L!==0),Me(D!==0||L!==0),ve(h,!1),Se(),g&&r.translate(-d.x,-d.y),me(),ce(),t&&r.translate(w.x1,w.y1)}};var sP=function(e){if(!["overlay","underlay"].includes(e))throw new Error("Invalid state");return function(t,n,a,i,o){var s=this;if(n.visible()){var u=n.pstyle("".concat(e,"-padding")).pfValue,l=n.pstyle("".concat(e,"-opacity")).value,f=n.pstyle("".concat(e,"-color")).value,d=n.pstyle("".concat(e,"-shape")).value,h=n.pstyle("".concat(e,"-corner-radius")).value;if(l>0){if(a=a||n.position(),i==null||o==null){var g=n.padding();i=n.width()+2*g,o=n.height()+2*g}s.colorFillStyle(t,f[0],f[1],f[2],l),s.nodeShapes[d].draw(t,a.x,a.y,i+u*2,o+u*2,h),t.fill()}}}};za.drawNodeOverlay=sP("overlay");za.drawNodeUnderlay=sP("underlay");za.hasPie=function(r){return r=r[0],r._private.hasPie};za.hasStripe=function(r){return r=r[0],r._private.hasStripe};za.drawPie=function(r,e,t,n){e=e[0],n=n||e.position();var a=e.cy().style(),i=e.pstyle("pie-size"),o=e.pstyle("pie-hole"),s=e.pstyle("pie-start-angle").pfValue,u=n.x,l=n.y,f=e.width(),d=e.height(),h=Math.min(f,d)/2,g,p=0,x=this.usePaths();if(x&&(u=0,l=0),i.units==="%"?h=h*i.pfValue:i.pfValue!==void 0&&(h=i.pfValue/2),o.units==="%"?g=h*o.pfValue:o.pfValue!==void 0&&(g=o.pfValue/2),!(g>=h))for(var b=1;b<=a.pieBackgroundN;b++){var w=e.pstyle("pie-"+b+"-background-size").value,y=e.pstyle("pie-"+b+"-background-color").value,E=e.pstyle("pie-"+b+"-background-opacity").value*t,C=w/100;C+p>1&&(C=1-p);var S=1.5*Math.PI+2*Math.PI*p;S+=s;var R=2*Math.PI*C,_=S+R;w===0||p>=1||p+C>1||(g===0?(r.beginPath(),r.moveTo(u,l),r.arc(u,l,h,S,_),r.closePath()):(r.beginPath(),r.arc(u,l,h,S,_),r.arc(u,l,g,_,S,!0),r.closePath()),this.colorFillStyle(r,y[0],y[1],y[2],E),r.fill(),p+=C)}};za.drawStripe=function(r,e,t,n){e=e[0],n=n||e.position();var a=e.cy().style(),i=n.x,o=n.y,s=e.width(),u=e.height(),l=0,f=this.usePaths();r.save();var d=e.pstyle("stripe-direction").value,h=e.pstyle("stripe-size");switch(d){case"vertical":break;case"righward":r.rotate(-Math.PI/2);break}var g=s,p=u;h.units==="%"?(g=g*h.pfValue,p=p*h.pfValue):h.pfValue!==void 0&&(g=h.pfValue,p=h.pfValue),f&&(i=0,o=0),o-=g/2,i-=p/2;for(var x=1;x<=a.stripeBackgroundN;x++){var b=e.pstyle("stripe-"+x+"-background-size").value,w=e.pstyle("stripe-"+x+"-background-color").value,y=e.pstyle("stripe-"+x+"-background-opacity").value*t,E=b/100;E+l>1&&(E=1-l),!(b===0||l>=1||l+E>1)&&(r.beginPath(),r.rect(i,o+p*l,g,p*E),r.closePath(),this.colorFillStyle(r,w[0],w[1],w[2],y),r.fill(),l+=E)}r.restore()};var Ot={},rV=100;Ot.getPixelRatio=function(){var r=this.data.contexts[0];if(this.forcedPixelRatio!=null)return this.forcedPixelRatio;var e=this.cy.window(),t=r.backingStorePixelRatio||r.webkitBackingStorePixelRatio||r.mozBackingStorePixelRatio||r.msBackingStorePixelRatio||r.oBackingStorePixelRatio||r.backingStorePixelRatio||1;return(e.devicePixelRatio||1)/t};Ot.paintCache=function(r){for(var e=this.paintCaches=this.paintCaches||[],t=!0,n,a=0;a<e.length;a++)if(n=e[a],n.context===r){t=!1;break}return t&&(n={context:r},e.push(n)),n};Ot.createGradientStyleFor=function(r,e,t,n,a){var i,o=this.usePaths(),s=t.pstyle(e+"-gradient-stop-colors").value,u=t.pstyle(e+"-gradient-stop-positions").pfValue;if(n==="radial-gradient")if(t.isEdge()){var l=t.sourceEndpoint(),f=t.targetEndpoint(),d=t.midpoint(),h=di(l,d),g=di(f,d);i=r.createRadialGradient(d.x,d.y,0,d.x,d.y,Math.max(h,g))}else{var p=o?{x:0,y:0}:t.position(),x=t.paddedWidth(),b=t.paddedHeight();i=r.createRadialGradient(p.x,p.y,0,p.x,p.y,Math.max(x,b))}else if(t.isEdge()){var w=t.sourceEndpoint(),y=t.targetEndpoint();i=r.createLinearGradient(w.x,w.y,y.x,y.y)}else{var E=o?{x:0,y:0}:t.position(),C=t.paddedWidth(),S=t.paddedHeight(),R=C/2,_=S/2,A=t.pstyle("background-gradient-direction").value;switch(A){case"to-bottom":i=r.createLinearGradient(E.x,E.y-_,E.x,E.y+_);break;case"to-top":i=r.createLinearGradient(E.x,E.y+_,E.x,E.y-_);break;case"to-left":i=r.createLinearGradient(E.x+R,E.y,E.x-R,E.y);break;case"to-right":i=r.createLinearGradient(E.x-R,E.y,E.x+R,E.y);break;case"to-bottom-right":case"to-right-bottom":i=r.createLinearGradient(E.x-R,E.y-_,E.x+R,E.y+_);break;case"to-top-right":case"to-right-top":i=r.createLinearGradient(E.x-R,E.y+_,E.x+R,E.y-_);break;case"to-bottom-left":case"to-left-bottom":i=r.createLinearGradient(E.x+R,E.y-_,E.x-R,E.y+_);break;case"to-top-left":case"to-left-top":i=r.createLinearGradient(E.x+R,E.y+_,E.x-R,E.y-_);break}}if(!i)return null;for(var P=u.length===s.length,I=s.length,D=0;D<I;D++)i.addColorStop(P?u[D]:D/(I-1),"rgba("+s[D][0]+","+s[D][1]+","+s[D][2]+","+a+")");return i};Ot.gradientFillStyle=function(r,e,t,n){var a=this.createGradientStyleFor(r,"background",e,t,n);if(!a)return null;r.fillStyle=a};Ot.colorFillStyle=function(r,e,t,n,a){r.fillStyle="rgba("+e+","+t+","+n+","+a+")"};Ot.eleFillStyle=function(r,e,t){var n=e.pstyle("background-fill").value;if(n==="linear-gradient"||n==="radial-gradient")this.gradientFillStyle(r,e,n,t);else{var a=e.pstyle("background-color").value;this.colorFillStyle(r,a[0],a[1],a[2],t)}};Ot.gradientStrokeStyle=function(r,e,t,n){var a=this.createGradientStyleFor(r,"line",e,t,n);if(!a)return null;r.strokeStyle=a};Ot.colorStrokeStyle=function(r,e,t,n,a){r.strokeStyle="rgba("+e+","+t+","+n+","+a+")"};Ot.eleStrokeStyle=function(r,e,t){var n=e.pstyle("line-fill").value;if(n==="linear-gradient"||n==="radial-gradient")this.gradientStrokeStyle(r,e,n,t);else{var a=e.pstyle("line-color").value;this.colorStrokeStyle(r,a[0],a[1],a[2],t)}};Ot.matchCanvasSize=function(r){var e=this,t=e.data,n=e.findContainerClientCoords(),a=n[2],i=n[3],o=e.getPixelRatio(),s=e.motionBlurPxRatio;(r===e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_NODE]||r===e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_DRAG])&&(o=s);var u=a*o,l=i*o,f;if(!(u===e.canvasWidth&&l===e.canvasHeight)){e.fontCaches=null;var d=t.canvasContainer;d.style.width=a+"px",d.style.height=i+"px";for(var h=0;h<e.CANVAS_LAYERS;h++)f=t.canvases[h],f.width=u,f.height=l,f.style.width=a+"px",f.style.height=i+"px";for(var h=0;h<e.BUFFER_COUNT;h++)f=t.bufferCanvases[h],f.width=u,f.height=l,f.style.width=a+"px",f.style.height=i+"px";e.textureMult=1,o<=1&&(f=t.bufferCanvases[e.TEXTURE_BUFFER],e.textureMult=2,f.width=u*e.textureMult,f.height=l*e.textureMult),e.canvasWidth=u,e.canvasHeight=l,e.pixelRatio=o}};Ot.renderTo=function(r,e,t,n){this.render({forcedContext:r,forcedZoom:e,forcedPan:t,drawAllLayers:!0,forcedPxRatio:n})};Ot.clearCanvas=function(){var r=this,e=r.data;function t(n){n.clearRect(0,0,r.canvasWidth,r.canvasHeight)}t(e.contexts[r.NODE]),t(e.contexts[r.DRAG])};Ot.render=function(r){var e=this;r=r||Y2();var t=e.cy,n=r.forcedContext,a=r.drawAllLayers,i=r.drawOnlyNodeLayer,o=r.forcedZoom,s=r.forcedPan,u=r.forcedPxRatio===void 0?this.getPixelRatio():r.forcedPxRatio,l=e.data,f=l.canvasNeedsRedraw,d=e.textureOnViewport&&!n&&(e.pinching||e.hoverData.dragging||e.swipePanning||e.data.wheelZooming),h=r.motionBlur!==void 0?r.motionBlur:e.motionBlur,g=e.motionBlurPxRatio,p=t.hasCompoundNodes(),x=e.hoverData.draggingEles,b=!!(e.hoverData.selecting||e.touchData.selecting);h=h&&!n&&e.motionBlurEnabled&&!b;var w=h;n||(e.prevPxRatio!==u&&(e.invalidateContainerClientCoordsCache(),e.matchCanvasSize(e.container),e.redrawHint("eles",!0),e.redrawHint("drag",!0)),e.prevPxRatio=u),!n&&e.motionBlurTimeout&&clearTimeout(e.motionBlurTimeout),h&&(e.mbFrames==null&&(e.mbFrames=0),e.mbFrames++,e.mbFrames<3&&(w=!1),e.mbFrames>e.minMbLowQualFrames&&(e.motionBlurPxRatio=e.mbPxRBlurry)),e.clearingMotionBlur&&(e.motionBlurPxRatio=1),e.textureDrawLastFrame&&!d&&(f[e.NODE]=!0,f[e.SELECT_BOX]=!0);var y=t.style(),E=t.zoom(),C=o!==void 0?o:E,S=t.pan(),R={x:S.x,y:S.y},_={zoom:E,pan:{x:S.x,y:S.y}},A=e.prevViewport,P=A===void 0||_.zoom!==A.zoom||_.pan.x!==A.pan.x||_.pan.y!==A.pan.y;!P&&!(x&&!p)&&(e.motionBlurPxRatio=1),s&&(R=s),C*=u,R.x*=u,R.y*=u;var I=e.getCachedZSortedEles();function D(oe,X,Q,ie,de){var we=oe.globalCompositeOperation;oe.globalCompositeOperation="destination-out",e.colorFillStyle(oe,255,255,255,e.motionBlurTransparency),oe.fillRect(X,Q,ie,de),oe.globalCompositeOperation=we}function L(oe,X){var Q,ie,de,we;!e.clearingMotionBlur&&(oe===l.bufferContexts[e.MOTIONBLUR_BUFFER_NODE]||oe===l.bufferContexts[e.MOTIONBLUR_BUFFER_DRAG])?(Q={x:S.x*g,y:S.y*g},ie=E*g,de=e.canvasWidth*g,we=e.canvasHeight*g):(Q=R,ie=C,de=e.canvasWidth,we=e.canvasHeight),oe.setTransform(1,0,0,1,0,0),X==="motionBlur"?D(oe,0,0,de,we):!n&&(X===void 0||X)&&oe.clearRect(0,0,de,we),a||(oe.translate(Q.x,Q.y),oe.scale(ie,ie)),s&&oe.translate(s.x,s.y),o&&oe.scale(o,o)}if(d||(e.textureDrawLastFrame=!1),d){if(e.textureDrawLastFrame=!0,!e.textureCache){e.textureCache={},e.textureCache.bb=t.mutableElements().boundingBox(),e.textureCache.texture=e.data.bufferCanvases[e.TEXTURE_BUFFER];var M=e.data.bufferContexts[e.TEXTURE_BUFFER];M.setTransform(1,0,0,1,0,0),M.clearRect(0,0,e.canvasWidth*e.textureMult,e.canvasHeight*e.textureMult),e.render({forcedContext:M,drawOnlyNodeLayer:!0,forcedPxRatio:u*e.textureMult});var _=e.textureCache.viewport={zoom:t.zoom(),pan:t.pan(),width:e.canvasWidth,height:e.canvasHeight};_.mpan={x:(0-_.pan.x)/_.zoom,y:(0-_.pan.y)/_.zoom}}f[e.DRAG]=!1,f[e.NODE]=!1;var q=l.contexts[e.NODE],N=e.textureCache.texture,_=e.textureCache.viewport;q.setTransform(1,0,0,1,0,0),h?D(q,0,0,_.width,_.height):q.clearRect(0,0,_.width,_.height);var W=y.core("outside-texture-bg-color").value,V=y.core("outside-texture-bg-opacity").value;e.colorFillStyle(q,W[0],W[1],W[2],V),q.fillRect(0,0,_.width,_.height);var E=t.zoom();L(q,!1),q.clearRect(_.mpan.x,_.mpan.y,_.width/_.zoom/u,_.height/_.zoom/u),q.drawImage(N,_.mpan.x,_.mpan.y,_.width/_.zoom/u,_.height/_.zoom/u)}else e.textureOnViewport&&!n&&(e.textureCache=null);var $=t.extent(),Z=e.pinching||e.hoverData.dragging||e.swipePanning||e.data.wheelZooming||e.hoverData.draggingEles||e.cy.animated(),ee=e.hideEdgesOnViewport&&Z,K=[];if(K[e.NODE]=!f[e.NODE]&&h&&!e.clearedForMotionBlur[e.NODE]||e.clearingMotionBlur,K[e.NODE]&&(e.clearedForMotionBlur[e.NODE]=!0),K[e.DRAG]=!f[e.DRAG]&&h&&!e.clearedForMotionBlur[e.DRAG]||e.clearingMotionBlur,K[e.DRAG]&&(e.clearedForMotionBlur[e.DRAG]=!0),f[e.NODE]||a||i||K[e.NODE]){var j=h&&!K[e.NODE]&&g!==1,q=n||(j?e.data.bufferContexts[e.MOTIONBLUR_BUFFER_NODE]:l.contexts[e.NODE]),fe=h&&!j?"motionBlur":void 0;L(q,fe),ee?e.drawCachedNodes(q,I.nondrag,u,$):e.drawLayeredElements(q,I.nondrag,u,$),e.debug&&e.drawDebugPoints(q,I.nondrag),!a&&!h&&(f[e.NODE]=!1)}if(!i&&(f[e.DRAG]||a||K[e.DRAG])){var j=h&&!K[e.DRAG]&&g!==1,q=n||(j?e.data.bufferContexts[e.MOTIONBLUR_BUFFER_DRAG]:l.contexts[e.DRAG]);L(q,h&&!j?"motionBlur":void 0),ee?e.drawCachedNodes(q,I.drag,u,$):e.drawCachedElements(q,I.drag,u,$),e.debug&&e.drawDebugPoints(q,I.drag),!a&&!h&&(f[e.DRAG]=!1)}if(this.drawSelectionRectangle(r,L),h&&g!==1){var G=l.contexts[e.NODE],z=e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_NODE],Y=l.contexts[e.DRAG],te=e.data.bufferCanvases[e.MOTIONBLUR_BUFFER_DRAG],ue=function(X,Q,ie){X.setTransform(1,0,0,1,0,0),ie||!w?X.clearRect(0,0,e.canvasWidth,e.canvasHeight):D(X,0,0,e.canvasWidth,e.canvasHeight);var de=g;X.drawImage(Q,0,0,e.canvasWidth*de,e.canvasHeight*de,0,0,e.canvasWidth,e.canvasHeight)};(f[e.NODE]||K[e.NODE])&&(ue(G,z,K[e.NODE]),f[e.NODE]=!1),(f[e.DRAG]||K[e.DRAG])&&(ue(Y,te,K[e.DRAG]),f[e.DRAG]=!1)}e.prevViewport=_,e.clearingMotionBlur&&(e.clearingMotionBlur=!1,e.motionBlurCleared=!0,e.motionBlur=!0),h&&(e.motionBlurTimeout=setTimeout(function(){e.motionBlurTimeout=null,e.clearedForMotionBlur[e.NODE]=!1,e.clearedForMotionBlur[e.DRAG]=!1,e.motionBlur=!1,e.clearingMotionBlur=!d,e.mbFrames=0,f[e.NODE]=!0,f[e.DRAG]=!0,e.redraw()},rV)),n||t.emit("render")};var Wo;Ot.drawSelectionRectangle=function(r,e){var t=this,n=t.cy,a=t.data,i=n.style(),o=r.drawOnlyNodeLayer,s=r.drawAllLayers,u=a.canvasNeedsRedraw,l=r.forcedContext;if(t.showFps||!o&&u[t.SELECT_BOX]&&!s){var f=l||a.contexts[t.SELECT_BOX];if(e(f),t.selection[4]==1&&(t.hoverData.selecting||t.touchData.selecting)){var d=t.cy.zoom(),h=i.core("selection-box-border-width").value/d;f.lineWidth=h,f.fillStyle="rgba("+i.core("selection-box-color").value[0]+","+i.core("selection-box-color").value[1]+","+i.core("selection-box-color").value[2]+","+i.core("selection-box-opacity").value+")",f.fillRect(t.selection[0],t.selection[1],t.selection[2]-t.selection[0],t.selection[3]-t.selection[1]),h>0&&(f.strokeStyle="rgba("+i.core("selection-box-border-color").value[0]+","+i.core("selection-box-border-color").value[1]+","+i.core("selection-box-border-color").value[2]+","+i.core("selection-box-opacity").value+")",f.strokeRect(t.selection[0],t.selection[1],t.selection[2]-t.selection[0],t.selection[3]-t.selection[1]))}if(a.bgActivePosistion&&!t.hoverData.selecting){var d=t.cy.zoom(),g=a.bgActivePosistion;f.fillStyle="rgba("+i.core("active-bg-color").value[0]+","+i.core("active-bg-color").value[1]+","+i.core("active-bg-color").value[2]+","+i.core("active-bg-opacity").value+")",f.beginPath(),f.arc(g.x,g.y,i.core("active-bg-size").pfValue/d,0,2*Math.PI),f.fill()}var p=t.lastRedrawTime;if(t.showFps&&p){p=Math.round(p);var x=Math.round(1e3/p),b="1 frame = "+p+" ms = "+x+" fps";if(f.setTransform(1,0,0,1,0,0),f.fillStyle="rgba(255, 0, 0, 0.75)",f.strokeStyle="rgba(255, 0, 0, 0.75)",f.font="30px Arial",!Wo){var w=f.measureText(b);Wo=w.actualBoundingBoxAscent}f.fillText(b,0,Wo);var y=60;f.strokeRect(0,Wo+10,250,20),f.fillRect(0,Wo+10,250*Math.min(x/y,1),20)}s||(u[t.SELECT_BOX]=!1)}};function $E(r,e,t){var n=r.createShader(e);if(r.shaderSource(n,t),r.compileShader(n),!r.getShaderParameter(n,r.COMPILE_STATUS))throw new Error(r.getShaderInfoLog(n));return n}function tV(r,e,t){var n=$E(r,r.VERTEX_SHADER,e),a=$E(r,r.FRAGMENT_SHADER,t),i=r.createProgram();if(r.attachShader(i,n),r.attachShader(i,a),r.linkProgram(i),!r.getProgramParameter(i,r.LINK_STATUS))throw new Error("Could not initialize shaders");return i}function nV(r,e,t){t===void 0&&(t=e);var n=r.makeOffscreenCanvas(e,t),a=n.context=n.getContext("2d");return n.clear=function(){return a.clearRect(0,0,n.width,n.height)},n.clear(),n}function g0(r){var e=r.pixelRatio,t=r.cy.zoom(),n=r.cy.pan();return{zoom:t*e,pan:{x:n.x*e,y:n.y*e}}}function aV(r){var e=r.pixelRatio,t=r.cy.zoom();return t*e}function iV(r,e,t,n,a){var i=n*t+e.x,o=a*t+e.y;return o=Math.round(r.canvasHeight-o),[i,o]}function oV(r){return r.pstyle("background-fill").value!=="solid"||r.pstyle("background-image").strValue!=="none"?!1:r.pstyle("border-width").value===0||r.pstyle("border-opacity").value===0?!0:r.pstyle("border-style").value==="solid"}function sV(r,e){if(r.length!==e.length)return!1;for(var t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}function ri(r,e,t){var n=r[0]/255,a=r[1]/255,i=r[2]/255,o=e,s=t||new Array(4);return s[0]=n*o,s[1]=a*o,s[2]=i*o,s[3]=o,s}function ji(r,e){var t=e||new Array(4);return t[0]=(r>>0&255)/255,t[1]=(r>>8&255)/255,t[2]=(r>>16&255)/255,t[3]=(r>>24&255)/255,t}function uV(r){return r[0]+(r[1]<<8)+(r[2]<<16)+(r[3]<<24)}function lV(r,e){var t=r.createTexture();return t.buffer=function(n){r.bindTexture(r.TEXTURE_2D,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR_MIPMAP_NEAREST),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,n),r.generateMipmap(r.TEXTURE_2D),r.bindTexture(r.TEXTURE_2D,null)},t.deleteTexture=function(){r.deleteTexture(t)},t}function uP(r,e){switch(e){case"float":return[1,r.FLOAT,4];case"vec2":return[2,r.FLOAT,4];case"vec3":return[3,r.FLOAT,4];case"vec4":return[4,r.FLOAT,4];case"int":return[1,r.INT,4];case"ivec2":return[2,r.INT,4]}}function lP(r,e,t){switch(e){case r.FLOAT:return new Float32Array(t);case r.INT:return new Int32Array(t)}}function fV(r,e,t,n,a,i){switch(e){case r.FLOAT:return new Float32Array(t.buffer,i*n,a);case r.INT:return new Int32Array(t.buffer,i*n,a)}}function cV(r,e,t,n){var a=uP(r,e),i=Zr(a,2),o=i[0],s=i[1],u=lP(r,s,n),l=r.createBuffer();return r.bindBuffer(r.ARRAY_BUFFER,l),r.bufferData(r.ARRAY_BUFFER,u,r.STATIC_DRAW),s===r.FLOAT?r.vertexAttribPointer(t,o,s,!1,0,0):s===r.INT&&r.vertexAttribIPointer(t,o,s,0,0),r.enableVertexAttribArray(t),r.bindBuffer(r.ARRAY_BUFFER,null),l}function Ln(r,e,t,n){var a=uP(r,t),i=Zr(a,3),o=i[0],s=i[1],u=i[2],l=lP(r,s,e*o),f=o*u,d=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,d),r.bufferData(r.ARRAY_BUFFER,e*f,r.DYNAMIC_DRAW),r.enableVertexAttribArray(n),s===r.FLOAT?r.vertexAttribPointer(n,o,s,!1,f,0):s===r.INT&&r.vertexAttribIPointer(n,o,s,f,0),r.vertexAttribDivisor(n,1),r.bindBuffer(r.ARRAY_BUFFER,null);for(var h=new Array(e),g=0;g<e;g++)h[g]=fV(r,s,l,f,o,g);return d.dataArray=l,d.stride=f,d.size=o,d.getView=function(p){return h[p]},d.setPoint=function(p,x,b){var w=h[p];w[0]=x,w[1]=b},d.bufferSubData=function(p){r.bindBuffer(r.ARRAY_BUFFER,d),p?r.bufferSubData(r.ARRAY_BUFFER,0,l,0,p*o):r.bufferSubData(r.ARRAY_BUFFER,0,l)},d}function dV(r,e,t){for(var n=9,a=new Float32Array(e*n),i=new Array(e),o=0;o<e;o++){var s=o*n*4;i[o]=new Float32Array(a.buffer,s,n)}var u=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,u),r.bufferData(r.ARRAY_BUFFER,a.byteLength,r.DYNAMIC_DRAW);for(var l=0;l<3;l++){var f=t+l;r.enableVertexAttribArray(f),r.vertexAttribPointer(f,3,r.FLOAT,!1,36,l*12),r.vertexAttribDivisor(f,1)}return r.bindBuffer(r.ARRAY_BUFFER,null),u.getMatrixView=function(d){return i[d]},u.setData=function(d,h){i[h].set(d,0)},u.bufferSubData=function(){r.bindBuffer(r.ARRAY_BUFFER,u),r.bufferSubData(r.ARRAY_BUFFER,0,a)},u}function vV(r){var e=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,e);var t=r.createTexture();return r.bindTexture(r.TEXTURE_2D,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,t,0),r.bindFramebuffer(r.FRAMEBUFFER,null),e.setFramebufferAttachmentSizes=function(n,a){r.bindTexture(r.TEXTURE_2D,t),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,n,a,0,r.RGBA,r.UNSIGNED_BYTE,null)},e}var VE=typeof Float32Array<"u"?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var r=0,e=arguments.length;e--;)r+=arguments[e]*arguments[e];return Math.sqrt(r)});function iv(){var r=new VE(9);return VE!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[5]=0,r[6]=0,r[7]=0),r[0]=1,r[4]=1,r[8]=1,r}function GE(r){return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=1,r[5]=0,r[6]=0,r[7]=0,r[8]=1,r}function hV(r,e,t){var n=e[0],a=e[1],i=e[2],o=e[3],s=e[4],u=e[5],l=e[6],f=e[7],d=e[8],h=t[0],g=t[1],p=t[2],x=t[3],b=t[4],w=t[5],y=t[6],E=t[7],C=t[8];return r[0]=h*n+g*o+p*l,r[1]=h*a+g*s+p*f,r[2]=h*i+g*u+p*d,r[3]=x*n+b*o+w*l,r[4]=x*a+b*s+w*f,r[5]=x*i+b*u+w*d,r[6]=y*n+E*o+C*l,r[7]=y*a+E*s+C*f,r[8]=y*i+E*u+C*d,r}function Yu(r,e,t){var n=e[0],a=e[1],i=e[2],o=e[3],s=e[4],u=e[5],l=e[6],f=e[7],d=e[8],h=t[0],g=t[1];return r[0]=n,r[1]=a,r[2]=i,r[3]=o,r[4]=s,r[5]=u,r[6]=h*n+g*o+l,r[7]=h*a+g*s+f,r[8]=h*i+g*u+d,r}function WE(r,e,t){var n=e[0],a=e[1],i=e[2],o=e[3],s=e[4],u=e[5],l=e[6],f=e[7],d=e[8],h=Math.sin(t),g=Math.cos(t);return r[0]=g*n+h*o,r[1]=g*a+h*s,r[2]=g*i+h*u,r[3]=g*o-h*n,r[4]=g*s-h*a,r[5]=g*u-h*i,r[6]=l,r[7]=f,r[8]=d,r}function qm(r,e,t){var n=t[0],a=t[1];return r[0]=n*e[0],r[1]=n*e[1],r[2]=n*e[2],r[3]=a*e[3],r[4]=a*e[4],r[5]=a*e[5],r[6]=e[6],r[7]=e[7],r[8]=e[8],r}function gV(r,e,t){return r[0]=2/e,r[1]=0,r[2]=0,r[3]=0,r[4]=-2/t,r[5]=0,r[6]=-1,r[7]=1,r[8]=1,r}var pV=(function(){function r(e,t,n,a){qa(this,r),this.debugID=Math.floor(Math.random()*1e4),this.r=e,this.texSize=t,this.texRows=n,this.texHeight=Math.floor(t/n),this.enableWrapping=!0,this.locked=!1,this.texture=null,this.needsBuffer=!0,this.freePointer={x:0,row:0},this.keyToLocation=new Map,this.canvas=a(e,t,t),this.scratch=a(e,t,this.texHeight,"scratch")}return Na(r,[{key:"lock",value:function(){this.locked=!0}},{key:"getKeys",value:function(){return new Set(this.keyToLocation.keys())}},{key:"getScale",value:function(t){var n=t.w,a=t.h,i=this.texHeight,o=this.texSize,s=i/a,u=n*s,l=a*s;return u>o&&(s=o/n,u=n*s,l=a*s),{scale:s,texW:u,texH:l}}},{key:"draw",value:function(t,n,a){var i=this;if(this.locked)throw new Error("can't draw, atlas is locked");var o=this.texSize,s=this.texRows,u=this.texHeight,l=this.getScale(n),f=l.scale,d=l.texW,h=l.texH,g=function(E,C){if(a&&C){var S=C.context,R=E.x,_=E.row,A=R,P=u*_;S.save(),S.translate(A,P),S.scale(f,f),a(S,n),S.restore()}},p=[null,null],x=function(){g(i.freePointer,i.canvas),p[0]={x:i.freePointer.x,y:i.freePointer.row*u,w:d,h},p[1]={x:i.freePointer.x+d,y:i.freePointer.row*u,w:0,h},i.freePointer.x+=d,i.freePointer.x==o&&(i.freePointer.x=0,i.freePointer.row++)},b=function(){var E=i.scratch,C=i.canvas;E.clear(),g({x:0,row:0},E);var S=o-i.freePointer.x,R=d-S,_=u;{var A=i.freePointer.x,P=i.freePointer.row*u,I=S;C.context.drawImage(E,0,0,I,_,A,P,I,_),p[0]={x:A,y:P,w:I,h}}{var D=S,L=(i.freePointer.row+1)*u,M=R;C&&C.context.drawImage(E,D,0,M,_,0,L,M,_),p[1]={x:0,y:L,w:M,h}}i.freePointer.x=R,i.freePointer.row++},w=function(){i.freePointer.x=0,i.freePointer.row++};if(this.freePointer.x+d<=o)x();else{if(this.freePointer.row>=s-1)return!1;this.freePointer.x===o?(w(),x()):this.enableWrapping?b():(w(),x())}return this.keyToLocation.set(t,p),this.needsBuffer=!0,p}},{key:"getOffsets",value:function(t){return this.keyToLocation.get(t)}},{key:"isEmpty",value:function(){return this.freePointer.x===0&&this.freePointer.row===0}},{key:"canFit",value:function(t){if(this.locked)return!1;var n=this.texSize,a=this.texRows,i=this.getScale(t),o=i.texW;return this.freePointer.x+o>n?this.freePointer.row<a-1:!0}},{key:"bufferIfNeeded",value:function(t){this.texture||(this.texture=lV(t,this.debugID)),this.needsBuffer&&(this.texture.buffer(this.canvas),this.needsBuffer=!1,this.locked&&(this.canvas=null,this.scratch=null))}},{key:"dispose",value:function(){this.texture&&(this.texture.deleteTexture(),this.texture=null),this.canvas=null,this.scratch=null,this.locked=!0}}])})(),yV=(function(){function r(e,t,n,a){qa(this,r),this.r=e,this.texSize=t,this.texRows=n,this.createTextureCanvas=a,this.atlases=[],this.styleKeyToAtlas=new Map,this.markedKeys=new Set}return Na(r,[{key:"getKeys",value:function(){return new Set(this.styleKeyToAtlas.keys())}},{key:"_createAtlas",value:function(){var t=this.r,n=this.texSize,a=this.texRows,i=this.createTextureCanvas;return new pV(t,n,a,i)}},{key:"_getScratchCanvas",value:function(){if(!this.scratch){var t=this.r,n=this.texSize,a=this.texRows,i=this.createTextureCanvas,o=Math.floor(n/a);this.scratch=i(t,n,o,"scratch")}return this.scratch}},{key:"draw",value:function(t,n,a){var i=this.styleKeyToAtlas.get(t);return i||(i=this.atlases[this.atlases.length-1],(!i||!i.canFit(n))&&(i&&i.lock(),i=this._createAtlas(),this.atlases.push(i)),i.draw(t,n,a),this.styleKeyToAtlas.set(t,i)),i}},{key:"getAtlas",value:function(t){return this.styleKeyToAtlas.get(t)}},{key:"hasAtlas",value:function(t){return this.styleKeyToAtlas.has(t)}},{key:"markKeyForGC",value:function(t){this.markedKeys.add(t)}},{key:"gc",value:function(){var t=this,n=this.markedKeys;if(n.size===0){console.log("nothing to garbage collect");return}var a=[],i=new Map,o=null,s=Gt(this.atlases),u;try{var l=function(){var d=u.value,h=d.getKeys(),g=mV(n,h);if(g.size===0)return a.push(d),h.forEach(function(S){return i.set(S,d)}),1;o||(o=t._createAtlas(),a.push(o));var p=Gt(h),x;try{for(p.s();!(x=p.n()).done;){var b=x.value;if(!g.has(b)){var w=d.getOffsets(b),y=Zr(w,2),E=y[0],C=y[1];o.canFit({w:E.w+C.w,h:E.h})||(o.lock(),o=t._createAtlas(),a.push(o)),d.canvas&&(t._copyTextureToNewAtlas(b,d,o),i.set(b,o))}}}catch(S){p.e(S)}finally{p.f()}d.dispose()};for(s.s();!(u=s.n()).done;)l()}catch(f){s.e(f)}finally{s.f()}this.atlases=a,this.styleKeyToAtlas=i,this.markedKeys=new Set}},{key:"_copyTextureToNewAtlas",value:function(t,n,a){var i=n.getOffsets(t),o=Zr(i,2),s=o[0],u=o[1];if(u.w===0)a.draw(t,s,function(h){h.drawImage(n.canvas,s.x,s.y,s.w,s.h,0,0,s.w,s.h)});else{var l=this._getScratchCanvas();l.clear(),l.context.drawImage(n.canvas,s.x,s.y,s.w,s.h,0,0,s.w,s.h),l.context.drawImage(n.canvas,u.x,u.y,u.w,u.h,s.w,0,u.w,u.h);var f=s.w+u.w,d=s.h;a.draw(t,{w:f,h:d},function(h){h.drawImage(l,0,0,f,d,0,0,f,d)})}}},{key:"getCounts",value:function(){return{keyCount:this.styleKeyToAtlas.size,atlasCount:new Set(this.styleKeyToAtlas.values()).size}}}])})();function mV(r,e){return r.intersection?r.intersection(e):new Set(el(r).filter(function(t){return e.has(t)}))}var bV=(function(){function r(e,t){qa(this,r),this.r=e,this.globalOptions=t,this.atlasSize=t.webglTexSize,this.maxAtlasesPerBatch=t.webglTexPerBatch,this.renderTypes=new Map,this.collections=new Map,this.typeAndIdToKey=new Map}return Na(r,[{key:"getAtlasSize",value:function(){return this.atlasSize}},{key:"addAtlasCollection",value:function(t,n){var a=this.globalOptions,i=a.webglTexSize,o=a.createTextureCanvas,s=n.texRows,u=this._cacheScratchCanvas(o),l=new yV(this.r,i,s,u);this.collections.set(t,l)}},{key:"addRenderType",value:function(t,n){var a=n.collection;if(!this.collections.has(a))throw new Error("invalid atlas collection name '".concat(a,"'"));var i=this.collections.get(a),o=Xe({type:t,atlasCollection:i},n);this.renderTypes.set(t,o)}},{key:"getRenderTypeOpts",value:function(t){return this.renderTypes.get(t)}},{key:"getAtlasCollection",value:function(t){return this.collections.get(t)}},{key:"_cacheScratchCanvas",value:function(t){var n=-1,a=-1,i=null;return function(o,s,u,l){return l?((!i||s!=n||u!=a)&&(n=s,a=u,i=t(o,s,u)),i):t(o,s,u)}}},{key:"_key",value:function(t,n){return"".concat(t,"-").concat(n)}},{key:"invalidate",value:function(t){var n=this,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=a.forceRedraw,o=i===void 0?!1:i,s=a.filterEle,u=s===void 0?function(){return!0}:s,l=a.filterType,f=l===void 0?function(){return!0}:l,d=!1,h=!1,g=Gt(t),p;try{for(g.s();!(p=g.n()).done;){var x=p.value;if(u(x)){var b=Gt(this.renderTypes.values()),w;try{var y=function(){var C=w.value,S=C.type;if(f(S)){var R=n.collections.get(C.collection),_=C.getKey(x),A=Array.isArray(_)?_:[_];if(o)A.forEach(function(L){return R.markKeyForGC(L)}),h=!0;else{var P=C.getID?C.getID(x):x.id(),I=n._key(S,P),D=n.typeAndIdToKey.get(I);D!==void 0&&!sV(A,D)&&(d=!0,n.typeAndIdToKey.delete(I),D.forEach(function(L){return R.markKeyForGC(L)}))}}};for(b.s();!(w=b.n()).done;)y()}catch(E){b.e(E)}finally{b.f()}}}}catch(E){g.e(E)}finally{g.f()}return h&&(this.gc(),d=!1),d}},{key:"gc",value:function(){var t=Gt(this.collections.values()),n;try{for(t.s();!(n=t.n()).done;){var a=n.value;a.gc()}}catch(i){t.e(i)}finally{t.f()}}},{key:"getOrCreateAtlas",value:function(t,n,a,i){var o=this.renderTypes.get(n),s=this.collections.get(o.collection),u=!1,l=s.draw(i,a,function(h){o.drawClipped?(h.save(),h.beginPath(),h.rect(0,0,a.w,a.h),h.clip(),o.drawElement(h,t,a,!0,!0),h.restore()):o.drawElement(h,t,a,!0,!0),u=!0});if(u){var f=o.getID?o.getID(t):t.id(),d=this._key(n,f);this.typeAndIdToKey.has(d)?this.typeAndIdToKey.get(d).push(i):this.typeAndIdToKey.set(d,[i])}return l}},{key:"getAtlasInfo",value:function(t,n){var a=this,i=this.renderTypes.get(n),o=i.getKey(t),s=Array.isArray(o)?o:[o];return s.map(function(u){var l=i.getBoundingBox(t,u),f=a.getOrCreateAtlas(t,n,l,u),d=f.getOffsets(u),h=Zr(d,2),g=h[0],p=h[1];return{atlas:f,tex:g,tex1:g,tex2:p,bb:l}})}},{key:"getDebugInfo",value:function(){var t=[],n=Gt(this.collections),a;try{for(n.s();!(a=n.n()).done;){var i=Zr(a.value,2),o=i[0],s=i[1],u=s.getCounts(),l=u.keyCount,f=u.atlasCount;t.push({type:o,keyCount:l,atlasCount:f})}}catch(d){n.e(d)}finally{n.f()}return t}}])})(),wV=(function(){function r(e){qa(this,r),this.globalOptions=e,this.atlasSize=e.webglTexSize,this.maxAtlasesPerBatch=e.webglTexPerBatch,this.batchAtlases=[]}return Na(r,[{key:"getMaxAtlasesPerBatch",value:function(){return this.maxAtlasesPerBatch}},{key:"getAtlasSize",value:function(){return this.atlasSize}},{key:"getIndexArray",value:function(){return Array.from({length:this.maxAtlasesPerBatch},function(t,n){return n})}},{key:"startBatch",value:function(){this.batchAtlases=[]}},{key:"getAtlasCount",value:function(){return this.batchAtlases.length}},{key:"getAtlases",value:function(){return this.batchAtlases}},{key:"canAddToCurrentBatch",value:function(t){return this.batchAtlases.length===this.maxAtlasesPerBatch?this.batchAtlases.includes(t):!0}},{key:"getAtlasIndexForBatch",value:function(t){var n=this.batchAtlases.indexOf(t);if(n<0){if(this.batchAtlases.length===this.maxAtlasesPerBatch)throw new Error("cannot add more atlases to batch");this.batchAtlases.push(t),n=this.batchAtlases.length-1}return n}}])})(),xV=`
44
- float circleSD(vec2 p, float r) {
45
- return distance(vec2(0), p) - r; // signed distance
1
+ "use strict";var Gm=Object.create;var Hn=Object.defineProperty;var Um=Object.getOwnPropertyDescriptor;var Hm=Object.getOwnPropertyNames;var Km=Object.getPrototypeOf,Zm=Object.prototype.hasOwnProperty;var Jm=(e,t,r)=>t in e?Hn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Ym=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Hm(t))!Zm.call(e,o)&&o!==r&&Hn(e,o,{get:()=>t[o],enumerable:!(n=Um(t,o))||n.enumerable});return e};var qe=(e,t,r)=>(r=e!=null?Gm(Km(e)):{},Ym(t||!e||!e.__esModule?Hn(r,"default",{value:e,enumerable:!0}):r,e));var Ar=(e,t,r)=>Jm(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),F=require("@chakra-ui/react"),E=require("react"),Z=require("react-icons/pi"),Xm=require("@emotion/react"),Qm=require("@emotion/styled"),ev=require("react-icons/tb"),Lt=require("react-dom"),rv=require("markdown-to-jsx/react"),dy=e=>e&&e.__esModule?e:{default:e},gn=dy(Qm),tv=dy(rv),fy=E.createContext(null),hy=E.createContext({nodeById:new Map,edgeById:new Map,parentIds:new Set});function Wr(){return E.useContext(hy)}function Ie(){const e=E.useContext(fy);if(!e)throw new Error("useFlowDiagramContext must be used within FlowDiagram");return e}function py({config:e,callbacks:t,nodes:r=[],edges:n=[],children:o}){const i=E.useMemo(()=>{var $e,Xe,Y;const ne=new Map;for(const D of r)($e=D.data)!=null&&$e.id&&ne.set(D.data.id,D);const Fe=new Map;for(const D of n)(Xe=D.data)!=null&&Xe.id&&Fe.set(D.data.id,D);const Je=new Set;for(const D of r)(Y=D.data)!=null&&Y.parent&&Je.add(D.data.parent);return{nodeById:ne,edgeById:Fe,parentIds:Je}},[r,n]),a=E.useRef(null),[s,u]=E.useState([]),[c,l]=E.useState(null),[d,f]=E.useState(!0),[p,b]=E.useState(!1),[y,m]=E.useState(!0),[x,g]=E.useState(!1),[w,v]=E.useState(!1),[_,C]=E.useState(!0),[S,T]=E.useState(!1),[k,j]=E.useState("auto"),[P,R]=E.useState(!1),I=e.compactPropertyLayout??P,[O,M]=E.useState({}),q=e.nodeViewModes??O,H=[...i.nodeById.values()].filter(ne=>{var Fe;return i.parentIds.has(ne.data.id)||((Fe=ne.data.config)==null?void 0:Fe.parentContainer)||ne.data.type==="objectView"||ne.data.type==="arrayView"}),V=!!H.length&&H.every(ne=>{var Fe,Je,$e;return i.parentIds.has(ne.data.id)||(Fe=ne.data.config)!=null&&Fe.parentContainer?!!((Je=ne.data.config)!=null&&Je.collapsed):q[ne.data.id]==="icon-label"||(($e=ne.data.config)==null?void 0:$e.labelBelow)&&q[ne.data.id]!=="properties"}),[re,ce]=E.useState("normal"),[le,be]=E.useState(),K=e.edgeRadius??le,N=K!==void 0&&Number.isFinite(K)?Math.min(500,Math.max(0,K)):void 0,[B,W]=E.useState(),z=e.spacing??re,X=typeof z=="number"?Number.isFinite(z)?Math.min(2,Math.max(.5,z)):1:z==="compact"?.5:z==="spacious"?2:1,se=e.backgroundVariant??B??(e.backgroundPattern==="none"&&e.backgroundColor==="transparent"?"transparent":e.backgroundPattern??"dot"),[Q,G]=E.useState(),J=Object.prototype.hasOwnProperty.call(e,"workflowContract")?e.workflowContract:Q,[te,de]=E.useState("blue.500"),[fe,Ee]=E.useState(!1),ge=E.useRef(t);ge.current=t;const We=E.useMemo(()=>{const ne=Fe=>(...Je)=>{var $e,Xe;return(Xe=($e=ge.current)==null?void 0:$e[Fe])==null?void 0:Xe.call($e,...Je)};return{onNodeSelect:ne("onNodeSelect"),onBackgroundClick:ne("onBackgroundClick"),onNodeDeselect:ne("onNodeDeselect"),onNodeDoubleClick:ne("onNodeDoubleClick"),onNodeViewToggle:ne("onNodeViewToggle"),onNodeTypeViewChange:ne("onNodeTypeViewChange"),onNodeCreate:ne("onNodeCreate"),onNodeCreateRequest:ne("onNodeCreateRequest"),onNodeDelete:ne("onNodeDelete"),onNodeLabelChange:ne("onNodeLabelChange"),onNodeContentChange:ne("onNodeContentChange"),onNodeCollapse:ne("onNodeCollapse"),onNodeColorChange:ne("onNodeColorChange"),onNodeBorderColorChange:ne("onNodeBorderColorChange"),onNodeBorderStyleChange:ne("onNodeBorderStyleChange"),onNodeBorderWidthChange:ne("onNodeBorderWidthChange"),onNodeBorderRadiusChange:ne("onNodeBorderRadiusChange"),onNodeIconChange:ne("onNodeIconChange"),onNodeOutlineChange:ne("onNodeOutlineChange"),onNodeAnimationChange:ne("onNodeAnimationChange"),onNodeAnimationVariantChange:ne("onNodeAnimationVariantChange"),onEdgeAnimationVariantChange:ne("onEdgeAnimationVariantChange"),onNodeHoverAction:ne("onNodeHoverAction"),onEdgeCreate:ne("onEdgeCreate"),onEdgeSelect:ne("onEdgeSelect"),onEdgeDeselect:ne("onEdgeDeselect"),onEdgeRemove:ne("onEdgeRemove"),onEdgeDelete:ne("onEdgeDelete"),onEdgeColorChange:ne("onEdgeColorChange"),onEdgeTypeChange:ne("onEdgeTypeChange"),onEdgeIconChange:ne("onEdgeIconChange"),onEdgeLabelChange:ne("onEdgeLabelChange"),onEdgeStyleChange:ne("onEdgeStyleChange"),onViewportChange:ne("onViewportChange"),onDirectionChange:ne("onDirectionChange"),onThemeColorChange:ne("onThemeColorChange"),onSpacingChange:ne("onSpacingChange"),onEdgeRadiusChange:ne("onEdgeRadiusChange"),onBackgroundVariantChange:ne("onBackgroundVariantChange"),onEdgeModeChange:ne("onEdgeModeChange"),onCompactPropertyLayoutChange:ne("onCompactPropertyLayoutChange"),onWorkflowContractChange:ne("onWorkflowContractChange"),onArrayModeChange:ne("onArrayModeChange"),onInit:ne("onInit"),onLayoutComplete:ne("onLayoutComplete"),onJsonChange:ne("onJsonChange")}},[]),me=e.themeColor||te,Te=e.edgeColor||"",er=e.colorMode||"light",De=e.direction||"LR",Ne=e.nodeAlignment??"center",He=e.edgeMode==="workflow"?"nodes":e.edgeMode??k,rr=e.readOnly??!1,ze=JSON.stringify(e.parentNodeStyle??null),xr=E.useMemo(()=>e.parentNodeStyle,[ze]),Ze=e.isZoomMode!==void 0?e.isZoomMode:d,pr=e.isMultiSelectMode!==void 0?e.isMultiSelectMode:p,dr=e.isEdgeHandlesEnabled!==void 0?e.isEdgeHandlesEnabled:x,jr=e.isDragMode!==void 0?e.isDragMode:y,we=E.useRef(e);we.current=e;const or=E.useMemo(()=>({get direction(){return we.current.direction},get nodeAlignment(){return we.current.nodeAlignment},get edgeMode(){return we.current.edgeMode},get compactPropertyLayout(){return we.current.compactPropertyLayout},get edgeType(){return we.current.edgeType},get customEdgeTypes(){return we.current.customEdgeTypes},get themeColor(){return we.current.themeColor},get colorMode(){return we.current.colorMode},get readOnly(){return we.current.readOnly},get editable(){return we.current.editable},get minZoom(){return we.current.minZoom},get maxZoom(){return we.current.maxZoom},get backgroundPattern(){return we.current.backgroundPattern},get edgeColor(){return we.current.edgeColor},get parentNodeStyle(){return we.current.parentNodeStyle},get backgroundColor(){return we.current.backgroundColor},get edgeHandles(){return we.current.edgeHandles},get initialViewport(){return we.current.initialViewport},get nodeOverlayActions(){return we.current.nodeOverlayActions},get renderNodeOverlay(){return we.current.renderNodeOverlay},get renderSelectedNodeToolbar(){return we.current.renderSelectedNodeToolbar},get renderSelectedEdgeToolbar(){return we.current.renderSelectedEdgeToolbar},get renderBottomBar(){return we.current.renderBottomBar},get bottomBarExtra(){return we.current.bottomBarExtra},get selectionToolbar(){return we.current.selectionToolbar},get customViews(){return we.current.customViews},get disableKeyboardShortcuts(){return we.current.disableKeyboardShortcuts},get isZoomMode(){return we.current.isZoomMode},get isMultiSelectMode(){return we.current.isMultiSelectMode},get isEdgeHandlesEnabled(){return we.current.isEdgeHandlesEnabled},get isDragMode(){return we.current.isDragMode}}),[]),ar=E.useCallback((ne,Fe)=>{var Je;if(Fe!=="default"&&Fe!=="properties"&&Fe!=="icon-label")throw new Error("Unknown node view mode.");M($e=>$e[ne]===Fe?$e:{...$e,[ne]:Fe}),(Je=t.onNodeViewModeChange)==null||Je.call(t,ne,Fe)},[t.onNodeViewModeChange]),xt=E.useMemo(()=>({allNodesIconLabel:V,setAllNodesIconLabel:ne=>{var Fe,Je,$e,Xe;for(const Y of H)i.parentIds.has(Y.data.id)||(Fe=Y.data.config)!=null&&Fe.parentContainer?!rr&&!!((Je=Y.data.config)!=null&&Je.collapsed)!==ne&&(($e=t.onNodeCollapse)==null||$e.call(t,Y.data.id,ne)):ar(Y.data.id,ne?"icon-label":"default");(Xe=t.onAllNodesIconLabelChange)==null||Xe.call(t,ne)},nodeViewModes:q,setNodeViewMode:ar,spacing:X,setSpacing:ce,edgeRadius:N,setEdgeRadius:be,backgroundVariant:se,setBackgroundVariant:W,themeColor:me,setThemeColor:de,backgroundSelected:fe,setBackgroundSelected:Ee,edgeColor:Te,colorMode:er,direction:De,nodeAlignment:Ne,edgeMode:He,setEdgeMode:j,compactPropertyLayout:I,setCompactPropertyLayout:R,workflowContract:J,setWorkflowContract:G,parentNodeStyle:xr,selectedNodeIds:s,setSelectedNodeIds:u,selectedEdgeId:c,setSelectedEdgeId:l,isZoomMode:Ze,setIsZoomMode:f,isMultiSelectMode:pr,setIsMultiSelectMode:b,isDragMode:jr,setIsDragMode:m,isEdgeHandlesEnabled:dr,setIsEdgeHandlesEnabled:g,isArrayNodeMode:w,setIsArrayNodeMode:v,isPinned:_,setIsPinned:C,isPerformanceMode:S,setIsPerformanceMode:T,engineRef:a,callbacks:We,config:or,readOnly:rr}),[V,i,ar,t.onNodeCollapse,t.onAllNodesIconLabelChange,q,t.onNodeViewModeChange,me,X,se,N,e.backgroundColor,fe,Te,er,De,Ne,He,J,xr,s,c,Ze,pr,jr,dr,w,_,S,rr,e.edgeHandles,e.edgeType,e.customEdgeTypes,e.selectionToolbar,e.bottomBarExtra,e.compactPropertyLayout,I,We,or]);return h.jsx(fy.Provider,{value:xt,children:h.jsx(hy.Provider,{value:i,children:o})})}function cn(e,t=.2){const r=e.replace(/^#/,""),n=parseInt(r,16);let o=n>>16&255,i=n>>8&255,a=n&255;return o=Math.max(0,Math.floor(o*(1-t))),i=Math.max(0,Math.floor(i*(1-t))),a=Math.max(0,Math.floor(a*(1-t))),"#"+((1<<24)+(o<<16)+(i<<8)+a).toString(16).slice(1).toUpperCase()}function cl(e,t,r){const n=s=>{const u=/^#?([0-9a-f]{6})$/i.exec((s==null?void 0:s.trim())??"");return u?parseInt(u[1],16):null},o=n(e),i=n(t);if(o===null||i===null)return null;const a=s=>Math.round((o>>s&255)*(1-r)+(i>>s&255)*r);return"#"+((1<<24)+(a(16)<<16)+(a(8)<<8)+a(0)).toString(16).slice(1).toUpperCase()}const Er=e=>e==="transparent"?{background:"transparent",highlight:"transparent",border:"transparent",property:"gray.900",boolean:"green.800",string:"gray.900",number:"orange.800"}:e!=null&&e.startsWith("#")?{background:e,highlight:cn(e,.1),border:cn(e,.5),property:"gray.900",boolean:"green.200",string:"gray.900",number:"orange.800"}:e==="gray"?{background:"gray.950",highlight:"gray.800",border:"gray.700",property:"gray.200",boolean:"green.400",string:"gray.200",number:"orange.600"}:e==="white"?{background:"white",highlight:"gray.200",border:"gray.400",property:"gray.900",boolean:"green.400",string:"gray.900",number:"orange.600"}:{background:e+".100",highlight:e+".200",border:e+".700",property:"gray.900",boolean:"green.800",string:"gray.900",number:"orange.800"},gy=e=>{if(e==="transparent")return{primary:e,secondary:e,light:e};let t=e;if(t!=null&&t.startsWith("#"))return{secondary:cn(e)};let r=String(Number(e.slice(-3))+200);r=e.slice(0,-3).concat(r);let n=String(Number(e.slice(-3))-100);return n=e.slice(0,-3).concat(n),{primary:t,secondary:r,light:n}},ul={red:{50:"#FFF5F5",100:"#FED7D7",200:"#FEB2B2",300:"#FC8181",400:"#F56565",500:"#E53E3E",600:"#C53030",700:"#9B2C2C",800:"#822727",900:"#63171B"},orange:{50:"#FFFAF0",100:"#FEEBC8",200:"#FBD38D",300:"#F6AD55",400:"#ED8936",500:"#DD6B20",600:"#C05621",700:"#9C4221",800:"#7B341E",900:"#652B19"},yellow:{50:"#FFFFF0",100:"#FEFCBF",200:"#FAF089",300:"#F6E05E",400:"#ECC94B",500:"#D69E2E",600:"#B7791F",700:"#975A16",800:"#744210",900:"#5F370E"},green:{50:"#F0FFF4",100:"#C6F6D5",200:"#9AE6B4",300:"#68D391",400:"#48BB78",500:"#38A169",600:"#2F855A",700:"#276749",800:"#22543D",900:"#1C4532"},teal:{50:"#E6FFFA",100:"#B2F5EA",200:"#81E6D9",300:"#4FD1C5",400:"#38B2AC",500:"#319795",600:"#2C7A7B",700:"#285E61",800:"#234E52",900:"#1D4044"},blue:{50:"#EBF8FF",100:"#BEE3F8",200:"#90CDF4",300:"#63B3ED",400:"#4299E1",500:"#3182CE",600:"#2B6CB0",700:"#2C5282",800:"#2A4365",900:"#1A365D"},cyan:{50:"#EDFDFD",100:"#C4F1F9",200:"#9DECF9",300:"#76E4F7",400:"#0BC5EA",500:"#00B5D8",600:"#00A3C4",700:"#0987A0",800:"#086F83",900:"#065666"},purple:{50:"#FAF5FF",100:"#E9D8FD",200:"#D6BCFA",300:"#B794F4",400:"#9F7AEA",500:"#805AD5",600:"#6B46C1",700:"#553C9A",800:"#44337A",900:"#322659"},pink:{50:"#FFF5F7",100:"#FED7E2",200:"#FBB6CE",300:"#F687B3",400:"#ED64A6",500:"#D53F8C",600:"#B83280",700:"#97266D",800:"#702459",900:"#521B41"},gray:{50:"#F7FAFC",100:"#EDF2F7",200:"#E2E8F0",300:"#CBD5E0",400:"#A0AEC0",500:"#718096",600:"#4A5568",700:"#2D3748",800:"#1A202C",900:"#171923",950:"#0d1117"}},pe=(e,t)=>{var i;if(e==="transparent"||e!=null&&e.startsWith("#"))return e;if(!e)return"whitesmoke";const r=e.replace(/\./g,"-");try{const s=getComputedStyle(document.documentElement).getPropertyValue(`--chakra-colors-${r}`).trim();if(s&&s!=="")return s}catch{}const[n,o]=e.split(".");return n&&o&&((i=ul[n])!=null&&i[Number(o)])?ul[n][Number(o)]:`var(--chakra-colors-${r})`};function tr(e,t,r){return e?r:t}function Zt(e){const[t]=(e==null?void 0:e.split("."))||[],{secondary:r}=gy(e),n=Er(t).background,o=Er(t).highlight,i=Er(t).border,a=Er(t).property,s=Er(t).property;let u=Er(t).background,c=Er(t).highlight;return u=e==="transparent"?e:pe(u)+50,c=e==="transparent"?e:pe(c)+20,{bgColor:n,highlightColor:o,borderColor:i,textColor:a,propertyColor:s,secondary:r,bgColorFaint:u,highlightColorFaint:c}}function Ve(e=null){const{colorMode:t}=Ie(),r=e==null?void 0:e.includes("gray"),n=t==="dark",o=tr(n,"white","gray.900"),i=tr(n,"gray.100","gray.800"),a=tr(n,"gray.200","blackAlpha.400"),s=tr(n,"gray.200","blackAlpha.600"),u=tr(n,"gray.500","gray.700"),c=tr(n,"gray.700","gray.700"),l=tr(n,"gray.900","gray.900"),d=tr(n,"gray.400","gray.500"),f=tr(n,"gray.400","gray.500"),p=tr(n,"gray.900","gray.200"),b=tr(n,r?"gray.900":"gray.200",r?"gray.200":"gray.900"),y=tr(n,"gray.900","gray.200"),m=tr(n,e&&"#000000",e||"#ffffff"),x=tr(n,e||"#ffffff",e?"#000000":"#ffffff"),g=c,w=tr(n,"gray.300","gray.800"),v=tr(n,"white","blackAlpha.400"),_=tr(n,"green.100","green.700");return{canvas:o,background:i,backgroundSecondary:a,darkBackgroundSecondary:s,border:u,darkColor:l,backgroundWhiteColor:v,borderSecondary:c,colorActive:d,colorInactive:f,iconColor:y,moreIconColor:g,colorText:p,themedColorText:b,logoColor:m,logoColorSecondary:x,darkColorActive:w,greenColor:_}}const nv=Xm.keyframes`
2
+ 0%, 100% { box-shadow: var(--flow-rest-shadow); }
3
+ 25%, 50% { box-shadow: var(--flow-hover-shadow); }
4
+ `;function Su(e,t=!0,r="&:hover",n=!0){const o=`color-mix(in srgb, ${e} 60%, transparent)`,a=`0 0 0 ${t?8:0}px ${o}`,s=`0 0 0 8px ${o}`;return{boxShadow:a,css:{"--flow-rest-shadow":s,"--flow-hover-shadow":`0 0 0 18px ${o}`,"@media (hover: hover)":{[r]:{boxShadow:s,"@media (prefers-reduced-motion: no-preference)":{animation:n?`${nv} 1200ms steps(10, end) 600ms`:"none"}}}}}}var St=(e=>(e.TOP_DOWN="TB",e.BOTTOM_UP="BT",e.LEFT_RIGHT="LR",e.RIGHT_LEFT="RL",e.CENTER="C",e))(St||{});const Ft=["","icon-label","object","text"];var ov=typeof global=="object"&&global&&global.Object===Object&&global,iv=typeof self=="object"&&self&&self.Object===Object&&self,av=ov||iv||Function("return this")(),dt=av.Symbol,yy=Object.prototype,sv=yy.hasOwnProperty,cv=yy.toString,Ct=dt?dt.toStringTag:void 0;function uv(e){var t=sv.call(e,Ct),r=e[Ct];try{e[Ct]=void 0;var n=!0}catch{}var o=cv.call(e);return n&&(t?e[Ct]=r:delete e[Ct]),o}var lv=Object.prototype,dv=lv.toString;function fv(e){return dv.call(e)}var hv="[object Null]",pv="[object Undefined]",ll=dt?dt.toStringTag:void 0;function gv(e){return e==null?e===void 0?pv:hv:ll&&ll in Object(e)?uv(e):fv(e)}function yv(e){return e!=null&&typeof e=="object"}var bv="[object Symbol]";function mv(e){return typeof e=="symbol"||yv(e)&&gv(e)==bv}function vv(e,t){for(var r=-1,n=e==null?0:e.length,o=Array(n);++r<n;)o[r]=t(e[r],r,e);return o}var Pe=Array.isArray,dl=dt?dt.prototype:void 0,fl=dl?dl.toString:void 0;function by(e){if(typeof e=="string")return e;if(Pe(e))return vv(e,by)+"";if(mv(e))return fl?fl.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function ju(e){return e==null?"":by(e)}function xv(e,t,r){var n=-1,o=e.length;t<0&&(t=-t>o?0:o+t),r=r>o?o:r,r<0&&(r+=o),o=t>r?0:r-t>>>0,t>>>=0;for(var i=Array(o);++n<o;)i[n]=e[n+t];return i}function wv(e,t,r){var n=e.length;return r=r===void 0?n:r,!t&&r>=n?e:xv(e,t,r)}var Cv="\\ud800-\\udfff",_v="\\u0300-\\u036f",Sv="\\ufe20-\\ufe2f",jv="\\u20d0-\\u20ff",Ev=_v+Sv+jv,Rv="\\ufe0e\\ufe0f",kv="\\u200d",Pv=RegExp("["+kv+Cv+Ev+Rv+"]");function my(e){return Pv.test(e)}function Av(e){return e.split("")}var vy="\\ud800-\\udfff",Tv="\\u0300-\\u036f",Ov="\\ufe20-\\ufe2f",Iv="\\u20d0-\\u20ff",Mv=Tv+Ov+Iv,qv="\\ufe0e\\ufe0f",Nv="["+vy+"]",yu="["+Mv+"]",bu="\\ud83c[\\udffb-\\udfff]",$v="(?:"+yu+"|"+bu+")",xy="[^"+vy+"]",wy="(?:\\ud83c[\\udde6-\\uddff]){2}",Cy="[\\ud800-\\udbff][\\udc00-\\udfff]",Lv="\\u200d",_y=$v+"?",Sy="["+qv+"]?",Fv="(?:"+Lv+"(?:"+[xy,wy,Cy].join("|")+")"+Sy+_y+")*",Bv=Sy+_y+Fv,Dv="(?:"+[xy+yu+"?",yu,wy,Cy,Nv].join("|")+")",zv=RegExp(bu+"(?="+bu+")|"+Dv+Bv,"g");function Vv(e){return e.match(zv)||[]}function Wv(e){return my(e)?Vv(e):Av(e)}function Gv(e){return function(t){t=ju(t);var r=my(t)?Wv(t):void 0,n=r?r[0]:t.charAt(0),o=r?wv(r,1).join(""):t.slice(1);return n[e]()+o}}var Uv=Gv("toUpperCase");function Hv(e,t,r,n){for(var o=-1,i=e==null?0:e.length;++o<i;)r=t(r,e[o],o,e);return r}function Kv(e){return function(t){return e==null?void 0:e[t]}}var Zv={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},Jv=Kv(Zv),Yv=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Xv="\\u0300-\\u036f",Qv="\\ufe20-\\ufe2f",ex="\\u20d0-\\u20ff",rx=Xv+Qv+ex,tx="["+rx+"]",nx=RegExp(tx,"g");function ox(e){return e=ju(e),e&&e.replace(Yv,Jv).replace(nx,"")}var ix=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function ax(e){return e.match(ix)||[]}var sx=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function cx(e){return sx.test(e)}var jy="\\ud800-\\udfff",ux="\\u0300-\\u036f",lx="\\ufe20-\\ufe2f",dx="\\u20d0-\\u20ff",fx=ux+lx+dx,Ey="\\u2700-\\u27bf",Ry="a-z\\xdf-\\xf6\\xf8-\\xff",hx="\\xac\\xb1\\xd7\\xf7",px="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",gx="\\u2000-\\u206f",yx=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",ky="A-Z\\xc0-\\xd6\\xd8-\\xde",bx="\\ufe0e\\ufe0f",Py=hx+px+gx+yx,Ay="['’]",hl="["+Py+"]",mx="["+fx+"]",Ty="\\d+",vx="["+Ey+"]",Oy="["+Ry+"]",Iy="[^"+jy+Py+Ty+Ey+Ry+ky+"]",xx="\\ud83c[\\udffb-\\udfff]",wx="(?:"+mx+"|"+xx+")",Cx="[^"+jy+"]",My="(?:\\ud83c[\\udde6-\\uddff]){2}",qy="[\\ud800-\\udbff][\\udc00-\\udfff]",it="["+ky+"]",_x="\\u200d",pl="(?:"+Oy+"|"+Iy+")",Sx="(?:"+it+"|"+Iy+")",gl="(?:"+Ay+"(?:d|ll|m|re|s|t|ve))?",yl="(?:"+Ay+"(?:D|LL|M|RE|S|T|VE))?",Ny=wx+"?",$y="["+bx+"]?",jx="(?:"+_x+"(?:"+[Cx,My,qy].join("|")+")"+$y+Ny+")*",Ex="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Rx="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",kx=$y+Ny+jx,Px="(?:"+[vx,My,qy].join("|")+")"+kx,Ax=RegExp([it+"?"+Oy+"+"+gl+"(?="+[hl,it,"$"].join("|")+")",Sx+"+"+yl+"(?="+[hl,it+pl,"$"].join("|")+")",it+"?"+pl+"+"+gl,it+"+"+yl,Rx,Ex,Ty,Px].join("|"),"g");function Tx(e){return e.match(Ax)||[]}function Ox(e,t,r){return e=ju(e),t=t,t===void 0?cx(e)?Tx(e):ax(e):e.match(t)||[]}var Ix="['’]",Mx=RegExp(Ix,"g");function qx(e){return function(t){return Hv(Ox(ox(t).replace(Mx,"")),e,"")}}var Cr=qx(function(e,t,r){return e+(r?" ":"")+Uv(t)});function je({label:e,children:t}){const r=E.cloneElement(t,{title:t.props.title??e});if(!F.Tooltip.Root){const n=F.Tooltip;return h.jsx(n,{label:e,placement:"top",fontSize:"xs",borderRadius:"15px",children:r})}return h.jsxs(F.Tooltip.Root,{positioning:{placement:"top"},children:[h.jsx(F.Tooltip.Trigger,{asChild:!0,children:r}),h.jsx(F.Portal,{children:h.jsx(F.Tooltip.Positioner,{children:h.jsx(F.Tooltip.Content,{fontSize:"xs",borderRadius:"15px",children:e})})})]})}function Ot(){const{border:e}=Ve();return h.jsx(F.chakra.span,{role:"separator","aria-orientation":"vertical",display:"block",flexShrink:0,w:"1px",h:"20px",mx:"4px",bg:e})}function Or({children:e,value:t,onValueChange:r,disabled:n,style:o,title:i,icon:a,popupContent:s,labelCase:u="title","aria-label":c}){var P;const{colorMode:l}=Ie(),{background:d,border:f,colorText:p,colorActive:b,colorInactive:y}=Ve(),m=l==="dark",x=E.useId(),g=E.useRef(null),w=E.useRef(null),[v,_]=E.useState(!1);E.useEffect(()=>{const R=w.current;R.setAttribute("popover","auto");const I=O=>_(O.newState==="open");return R.addEventListener("toggle",I),()=>R.removeEventListener("toggle",I)},[]);const C=E.Children.toArray(e).filter(E.isValidElement).map(R=>{const I=R.props;return{value:String(I.value),label:typeof I.children=="string"&&u==="title"?Cr(I.children):I.children,disabled:I.disabled}}),S=()=>{var R;return(R=w.current)==null?void 0:R.hidePopover()},T=()=>{var H,V,re,ce;const R=(H=g.current)==null?void 0:H.getBoundingClientRect(),I=w.current;if(!R||!I)return;const M=((ce=(re=(V=g.current)==null?void 0:V.closest("[data-flow-toolbar-scroll]"))==null?void 0:re.parentElement)==null?void 0:ce.getBoundingClientRect())??R;I.style.maxHeight=`${Math.max(60,Math.max(M.top-40,window.innerHeight-M.bottom-40))}px`;const q=I.getBoundingClientRect();I.style.left=`${Math.max(12,Math.min(R.right-q.width,window.innerWidth-q.width-12))}px`,I.style.top=`${Math.max(12,M.top>=q.height+36?M.top-q.height-24:Math.min(M.bottom+24,window.innerHeight-q.height-12))}px`},k=()=>{var O,M,q,H,V,re;if(n)return;if((O=w.current)==null||O.showPopover(),T(),s){(q=(M=w.current)==null?void 0:M.querySelector("input"))==null||q.focus({preventScroll:!0});return}const R=(H=w.current)==null?void 0:H.querySelectorAll('[role="option"]:not(:disabled)');(re=((V=w.current)==null?void 0:V.querySelector('[aria-selected="true"]:not(:disabled)'))??(R==null?void 0:R[0]))==null||re.focus()};E.useEffect(()=>{if(v){if(n){S();return}return window.addEventListener("resize",T),window.addEventListener("scroll",T,!0),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,!0)}}},[v,n]);const j=`var(--chakra-colors-${d.replace(".","-")})`;return h.jsxs(h.Fragment,{children:[h.jsx(je,{label:i??c,children:h.jsx(F.chakra.button,{ref:g,type:"button",role:"combobox","data-flow-select-icon":a?"":void 0,"aria-label":c,title:i??c,"aria-haspopup":s?"dialog":"listbox","aria-expanded":v,"aria-controls":x,disabled:n,h:"30px",w:"160px",px:"6px",fontSize:"12px",border:"none",borderRadius:"4px",bg:"transparent",color:a?y:p,display:"flex",alignItems:"center",justifyContent:a?"center":"space-between",gap:2,style:o,onClick:()=>v?S():k(),onKeyDown:R=>{["ArrowDown","ArrowUp"].includes(R.key)&&(R.preventDefault(),k())},children:a??h.jsxs(h.Fragment,{children:[h.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((P=C.find(R=>R.value===t))==null?void 0:P.label)??t}),h.jsx(Z.PiCaretUp,{size:16,style:{flexShrink:0}})]})})}),h.jsx(F.chakra.div,{ref:w,id:x,role:s?"dialog":"listbox","aria-label":c,position:"fixed",m:0,p:2,minW:"180px",maxW:"calc(100vw - 24px)",overflowY:"auto",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},bg:d,color:p,borderWidth:1,borderColor:m?f:"gray.300",borderRadius:"30px",boxShadow:`0 0 0 8px color-mix(in srgb, ${j} 40%, transparent), var(--chakra-shadows-lg)`,onKeyDown:R=>{var M,q,H;if(s&&!["Escape","Tab"].includes(R.key))return;const I=[...R.currentTarget.querySelectorAll('[role="option"]:not(:disabled)')],O=I.indexOf(document.activeElement);if(["ArrowDown","ArrowUp","Home","End"].includes(R.key)){R.preventDefault();const V=R.key==="Home"?0:R.key==="End"?I.length-1:(O+(R.key==="ArrowDown"?1:-1)+I.length)%I.length;(M=I[V])==null||M.focus()}else R.key==="Escape"||R.key==="Tab"?(R.key==="Escape"&&(R.preventDefault(),R.stopPropagation()),S(),(q=g.current)==null||q.focus()):R.key.length===1&&R.key!==" "&&((H=I.find((V,re)=>{var ce;return re>O&&((ce=V.textContent)==null?void 0:ce.toLowerCase().startsWith(R.key.toLowerCase()))}))==null||H.focus())},children:s??C.map(R=>h.jsxs(F.chakra.button,{type:"button",role:"option","aria-selected":R.value===t,disabled:R.disabled,tabIndex:-1,display:"flex",alignItems:"center",gap:3,px:3,py:2,w:"100%",borderRadius:"30px",fontSize:"sm",textAlign:"left",bg:"transparent",color:p,_hover:{bg:m?"whiteAlpha.100":"blackAlpha.50"},_focusVisible:{bg:m?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var I;S(),(I=g.current)==null||I.focus(),r(R.value)},children:[h.jsx("span",{style:{flex:1},children:R.label}),h.jsx(Z.PiCheck,{size:16,color:`var(--chakra-colors-${b.replace(".","-")})`,"aria-hidden":"true",style:{flexShrink:0,visibility:R.value===t?"visible":"hidden"}})]},R.value))})]})}const ve=E.forwardRef(function({icon:t,...r},n){const{colorMode:o}=Ie();return h.jsx(F.IconButton,{ref:n,_hover:{bg:o==="dark"?"whiteAlpha.100":"blackAlpha.50"},title:r.title??r["aria-label"],...r,children:t})}),ht=E.forwardRef(function(t,r){const{themeColor:n}=Ie();return h.jsx(je,{label:"Close",children:h.jsx(ve,{ref:r,size:"sm",variant:"ghost",color:n,focusRingColor:n,...t,"aria-label":t["aria-label"]??"Close selection tools",icon:h.jsx(Z.PiXLight,{size:20,"aria-hidden":"true"})})})}),Ly=gn.default.input`
5
+ appearance: none;
6
+ width: 100%;
7
+ height: 24px;
8
+ margin: 0;
9
+ padding: 0;
10
+ border: 0;
11
+ box-shadow: none;
12
+ background-color: transparent;
13
+ background-size: 100% 6px;
14
+ background-position: center;
15
+ background-repeat: no-repeat;
16
+ cursor: pointer;
17
+ &::-webkit-slider-runnable-track {
18
+ height: 6px;
19
+ background: transparent;
20
+ border: 0;
21
+ box-shadow: none;
46
22
  }
47
- `,EV=`
48
- float rectangleSD(vec2 p, vec2 b) {
49
- vec2 d = abs(p)-b;
50
- return distance(vec2(0),max(d,0.0)) + min(max(d.x,d.y),0.0);
23
+ &::-moz-range-track {
24
+ height: 6px;
25
+ background: transparent;
26
+ border: 0;
27
+ box-shadow: none;
51
28
  }
52
- `,CV=`
53
- float roundRectangleSD(vec2 p, vec2 b, vec4 cr) {
54
- cr.xy = (p.x > 0.0) ? cr.xy : cr.zw;
55
- cr.x = (p.y > 0.0) ? cr.x : cr.y;
56
- vec2 q = abs(p) - b + cr.x;
57
- return min(max(q.x, q.y), 0.0) + distance(vec2(0), max(q, 0.0)) - cr.x;
29
+ &::-webkit-slider-thumb {
30
+ appearance: none;
31
+ width: 16px;
32
+ height: 16px;
33
+ margin-top: -5px;
34
+ border: 0;
35
+ border-radius: 50%;
36
+ background: currentColor;
37
+ box-shadow: none;
58
38
  }
59
- `,_V=`
60
- float ellipseSD(vec2 p, vec2 ab) {
61
- p = abs( p ); // symmetry
62
-
63
- // find root with Newton solver
64
- vec2 q = ab*(p-ab);
65
- float w = (q.x<q.y)? 1.570796327 : 0.0;
66
- for( int i=0; i<5; i++ ) {
67
- vec2 cs = vec2(cos(w),sin(w));
68
- vec2 u = ab*vec2( cs.x,cs.y);
69
- vec2 v = ab*vec2(-cs.y,cs.x);
70
- w = w + dot(p-u,v)/(dot(p-u,u)+dot(v,v));
71
- }
72
-
73
- // compute final point and distance
74
- float d = length(p-ab*vec2(cos(w),sin(w)));
75
-
76
- // return signed distance
77
- return (dot(p/ab,p/ab)>1.0) ? d : -d;
39
+ &::-moz-range-thumb {
40
+ width: 16px;
41
+ height: 16px;
42
+ border: 0;
43
+ border-radius: 50%;
44
+ background: currentColor;
45
+ box-shadow: none;
78
46
  }
79
- `,os={SCREEN:{name:"screen",screen:!0},PICKING:{name:"picking",picking:!0}},dl={IGNORE:1,USE_BB:2},ov=0,UE=1,HE=2,sv=3,Yi=4,Nu=5,Uo=6,Ho=7,SV=(function(){function r(e,t,n){qa(this,r),this.r=e,this.gl=t,this.maxInstances=n.webglBatchSize,this.atlasSize=n.webglTexSize,this.bgColor=n.bgColor,this.debug=n.webglDebug,this.batchDebugInfo=[],n.enableWrapping=!0,n.createTextureCanvas=nV,this.atlasManager=new bV(e,n),this.batchManager=new wV(n),this.simpleShapeOptions=new Map,this.program=this._createShaderProgram(os.SCREEN),this.pickingProgram=this._createShaderProgram(os.PICKING),this.vao=this._createVAO()}return Na(r,[{key:"addAtlasCollection",value:function(t,n){this.atlasManager.addAtlasCollection(t,n)}},{key:"addTextureAtlasRenderType",value:function(t,n){this.atlasManager.addRenderType(t,n)}},{key:"addSimpleShapeRenderType",value:function(t,n){this.simpleShapeOptions.set(t,n)}},{key:"invalidate",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=n.type,i=this.atlasManager;return a?i.invalidate(t,{filterType:function(s){return s===a},forceRedraw:!0}):i.invalidate(t)}},{key:"gc",value:function(){this.atlasManager.gc()}},{key:"_createShaderProgram",value:function(t){var n=this.gl,a=`#version 300 es
80
- precision highp float;
81
-
82
- uniform mat3 uPanZoomMatrix;
83
- uniform int uAtlasSize;
84
-
85
- // instanced
86
- in vec2 aPosition; // a vertex from the unit square
87
-
88
- in mat3 aTransform; // used to transform verticies, eg into a bounding box
89
- in int aVertType; // the type of thing we are rendering
90
-
91
- // the z-index that is output when using picking mode
92
- in vec4 aIndex;
93
-
94
- // For textures
95
- in int aAtlasId; // which shader unit/atlas to use
96
- in vec4 aTex; // x/y/w/h of texture in atlas
97
-
98
- // for edges
99
- in vec4 aPointAPointB;
100
- in vec4 aPointCPointD;
101
- in vec2 aLineWidth; // also used for node border width
102
-
103
- // simple shapes
104
- in vec4 aCornerRadius; // for round-rectangle [top-right, bottom-right, top-left, bottom-left]
105
- in vec4 aColor; // also used for edges
106
- in vec4 aBorderColor; // aLineWidth is used for border width
107
-
108
- // output values passed to the fragment shader
109
- out vec2 vTexCoord;
110
- out vec4 vColor;
111
- out vec2 vPosition;
112
- // flat values are not interpolated
113
- flat out int vAtlasId;
114
- flat out int vVertType;
115
- flat out vec2 vTopRight;
116
- flat out vec2 vBotLeft;
117
- flat out vec4 vCornerRadius;
118
- flat out vec4 vBorderColor;
119
- flat out vec2 vBorderWidth;
120
- flat out vec4 vIndex;
121
-
122
- void main(void) {
123
- int vid = gl_VertexID;
124
- vec2 position = aPosition; // TODO make this a vec3, simplifies some code below
125
-
126
- if(aVertType == `.concat(ov,`) {
127
- float texX = aTex.x; // texture coordinates
128
- float texY = aTex.y;
129
- float texW = aTex.z;
130
- float texH = aTex.w;
131
-
132
- if(vid == 1 || vid == 2 || vid == 4) {
133
- texX += texW;
134
- }
135
- if(vid == 2 || vid == 4 || vid == 5) {
136
- texY += texH;
137
- }
138
-
139
- float d = float(uAtlasSize);
140
- vTexCoord = vec2(texX / d, texY / d); // tex coords must be between 0 and 1
141
-
142
- gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);
143
- }
144
- else if(aVertType == `).concat(Yi," || aVertType == ").concat(Ho,`
145
- || aVertType == `).concat(Nu," || aVertType == ").concat(Uo,`) { // simple shapes
146
-
147
- // the bounding box is needed by the fragment shader
148
- vBotLeft = (aTransform * vec3(0, 0, 1)).xy; // flat
149
- vTopRight = (aTransform * vec3(1, 1, 1)).xy; // flat
150
- vPosition = (aTransform * vec3(position, 1)).xy; // will be interpolated
151
-
152
- // calculations are done in the fragment shader, just pass these along
153
- vColor = aColor;
154
- vCornerRadius = aCornerRadius;
155
- vBorderColor = aBorderColor;
156
- vBorderWidth = aLineWidth;
157
-
158
- gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);
159
- }
160
- else if(aVertType == `).concat(UE,`) {
161
- vec2 source = aPointAPointB.xy;
162
- vec2 target = aPointAPointB.zw;
163
-
164
- // adjust the geometry so that the line is centered on the edge
165
- position.y = position.y - 0.5;
166
-
167
- // stretch the unit square into a long skinny rectangle
168
- vec2 xBasis = target - source;
169
- vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));
170
- vec2 point = source + xBasis * position.x + yBasis * aLineWidth[0] * position.y;
171
-
172
- gl_Position = vec4(uPanZoomMatrix * vec3(point, 1.0), 1.0);
173
- vColor = aColor;
174
- }
175
- else if(aVertType == `).concat(HE,`) {
176
- vec2 pointA = aPointAPointB.xy;
177
- vec2 pointB = aPointAPointB.zw;
178
- vec2 pointC = aPointCPointD.xy;
179
- vec2 pointD = aPointCPointD.zw;
180
-
181
- // adjust the geometry so that the line is centered on the edge
182
- position.y = position.y - 0.5;
183
-
184
- vec2 p0, p1, p2, pos;
185
- if(position.x == 0.0) { // The left side of the unit square
186
- p0 = pointA;
187
- p1 = pointB;
188
- p2 = pointC;
189
- pos = position;
190
- } else { // The right side of the unit square, use same approach but flip the geometry upside down
191
- p0 = pointD;
192
- p1 = pointC;
193
- p2 = pointB;
194
- pos = vec2(0.0, -position.y);
195
- }
196
-
197
- vec2 p01 = p1 - p0;
198
- vec2 p12 = p2 - p1;
199
- vec2 p21 = p1 - p2;
200
-
201
- // Find the normal vector.
202
- vec2 tangent = normalize(normalize(p12) + normalize(p01));
203
- vec2 normal = vec2(-tangent.y, tangent.x);
204
-
205
- // Find the vector perpendicular to p0 -> p1.
206
- vec2 p01Norm = normalize(vec2(-p01.y, p01.x));
207
-
208
- // Determine the bend direction.
209
- float sigma = sign(dot(p01 + p21, normal));
210
- float width = aLineWidth[0];
211
-
212
- if(sign(pos.y) == -sigma) {
213
- // This is an intersecting vertex. Adjust the position so that there's no overlap.
214
- vec2 point = 0.5 * width * normal * -sigma / dot(normal, p01Norm);
215
- gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);
216
- } else {
217
- // This is a non-intersecting vertex. Treat it like a mitre join.
218
- vec2 point = 0.5 * width * normal * sigma * dot(normal, p01Norm);
219
- gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);
220
- }
221
-
222
- vColor = aColor;
223
- }
224
- else if(aVertType == `).concat(sv,` && vid < 3) {
225
- // massage the first triangle into an edge arrow
226
- if(vid == 0)
227
- position = vec2(-0.15, -0.3);
228
- if(vid == 1)
229
- position = vec2( 0.0, 0.0);
230
- if(vid == 2)
231
- position = vec2( 0.15, -0.3);
232
-
233
- gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);
234
- vColor = aColor;
235
- }
236
- else {
237
- gl_Position = vec4(2.0, 0.0, 0.0, 1.0); // discard vertex by putting it outside webgl clip space
238
- }
239
-
240
- vAtlasId = aAtlasId;
241
- vVertType = aVertType;
242
- vIndex = aIndex;
243
- }
244
- `),i=this.batchManager.getIndexArray(),o=`#version 300 es
245
- precision highp float;
246
-
247
- // declare texture unit for each texture atlas in the batch
248
- `.concat(i.map(function(l){return"uniform sampler2D uTexture".concat(l,";")}).join(`
249
- `),`
250
-
251
- uniform vec4 uBGColor;
252
- uniform float uZoom;
253
-
254
- in vec2 vTexCoord;
255
- in vec4 vColor;
256
- in vec2 vPosition; // model coordinates
257
-
258
- flat in int vAtlasId;
259
- flat in vec4 vIndex;
260
- flat in int vVertType;
261
- flat in vec2 vTopRight;
262
- flat in vec2 vBotLeft;
263
- flat in vec4 vCornerRadius;
264
- flat in vec4 vBorderColor;
265
- flat in vec2 vBorderWidth;
266
-
267
- out vec4 outColor;
268
-
269
- `).concat(xV,`
270
- `).concat(EV,`
271
- `).concat(CV,`
272
- `).concat(_V,`
273
-
274
- vec4 blend(vec4 top, vec4 bot) { // blend colors with premultiplied alpha
275
- return vec4(
276
- top.rgb + (bot.rgb * (1.0 - top.a)),
277
- top.a + (bot.a * (1.0 - top.a))
278
- );
279
- }
280
-
281
- vec4 distInterp(vec4 cA, vec4 cB, float d) { // interpolate color using Signed Distance
282
- // scale to the zoom level so that borders don't look blurry when zoomed in
283
- // note 1.5 is an aribitrary value chosen because it looks good
284
- return mix(cA, cB, 1.0 - smoothstep(0.0, 1.5 / uZoom, abs(d)));
285
- }
286
-
287
- void main(void) {
288
- if(vVertType == `).concat(ov,`) {
289
- // look up the texel from the texture unit
290
- `).concat(i.map(function(l){return"if(vAtlasId == ".concat(l,") outColor = texture(uTexture").concat(l,", vTexCoord);")}).join(`
291
- else `),`
292
- }
293
- else if(vVertType == `).concat(sv,`) {
294
- // mimics how canvas renderer uses context.globalCompositeOperation = 'destination-out';
295
- outColor = blend(vColor, uBGColor);
296
- outColor.a = 1.0; // make opaque, masks out line under arrow
297
- }
298
- else if(vVertType == `).concat(Yi,` && vBorderWidth == vec2(0.0)) { // simple rectangle with no border
299
- outColor = vColor; // unit square is already transformed to the rectangle, nothing else needs to be done
300
- }
301
- else if(vVertType == `).concat(Yi," || vVertType == ").concat(Ho,`
302
- || vVertType == `).concat(Nu," || vVertType == ").concat(Uo,`) { // use SDF
303
-
304
- float outerBorder = vBorderWidth[0];
305
- float innerBorder = vBorderWidth[1];
306
- float borderPadding = outerBorder * 2.0;
307
- float w = vTopRight.x - vBotLeft.x - borderPadding;
308
- float h = vTopRight.y - vBotLeft.y - borderPadding;
309
- vec2 b = vec2(w/2.0, h/2.0); // half width, half height
310
- vec2 p = vPosition - vec2(vTopRight.x - b[0] - outerBorder, vTopRight.y - b[1] - outerBorder); // translate to center
311
-
312
- float d; // signed distance
313
- if(vVertType == `).concat(Yi,`) {
314
- d = rectangleSD(p, b);
315
- } else if(vVertType == `).concat(Ho,` && w == h) {
316
- d = circleSD(p, b.x); // faster than ellipse
317
- } else if(vVertType == `).concat(Ho,`) {
318
- d = ellipseSD(p, b);
319
- } else {
320
- d = roundRectangleSD(p, b, vCornerRadius.wzyx);
321
- }
322
-
323
- // use the distance to interpolate a color to smooth the edges of the shape, doesn't need multisampling
324
- // we must smooth colors inwards, because we can't change pixels outside the shape's bounding box
325
- if(d > 0.0) {
326
- if(d > outerBorder) {
327
- discard;
328
- } else {
329
- outColor = distInterp(vBorderColor, vec4(0), d - outerBorder);
330
- }
331
- } else {
332
- if(d > innerBorder) {
333
- vec4 outerColor = outerBorder == 0.0 ? vec4(0) : vBorderColor;
334
- vec4 innerBorderColor = blend(vBorderColor, vColor);
335
- outColor = distInterp(innerBorderColor, outerColor, d);
336
- }
337
- else {
338
- vec4 outerColor;
339
- if(innerBorder == 0.0 && outerBorder == 0.0) {
340
- outerColor = vec4(0);
341
- } else if(innerBorder == 0.0) {
342
- outerColor = vBorderColor;
343
- } else {
344
- outerColor = blend(vBorderColor, vColor);
345
- }
346
- outColor = distInterp(vColor, outerColor, d - innerBorder);
347
- }
348
- }
349
- }
350
- else {
351
- outColor = vColor;
352
- }
353
-
354
- `).concat(t.picking?`if(outColor.a == 0.0) discard;
355
- else outColor = vIndex;`:"",`
356
- }
357
- `),s=tV(n,a,o);s.aPosition=n.getAttribLocation(s,"aPosition"),s.aIndex=n.getAttribLocation(s,"aIndex"),s.aVertType=n.getAttribLocation(s,"aVertType"),s.aTransform=n.getAttribLocation(s,"aTransform"),s.aAtlasId=n.getAttribLocation(s,"aAtlasId"),s.aTex=n.getAttribLocation(s,"aTex"),s.aPointAPointB=n.getAttribLocation(s,"aPointAPointB"),s.aPointCPointD=n.getAttribLocation(s,"aPointCPointD"),s.aLineWidth=n.getAttribLocation(s,"aLineWidth"),s.aColor=n.getAttribLocation(s,"aColor"),s.aCornerRadius=n.getAttribLocation(s,"aCornerRadius"),s.aBorderColor=n.getAttribLocation(s,"aBorderColor"),s.uPanZoomMatrix=n.getUniformLocation(s,"uPanZoomMatrix"),s.uAtlasSize=n.getUniformLocation(s,"uAtlasSize"),s.uBGColor=n.getUniformLocation(s,"uBGColor"),s.uZoom=n.getUniformLocation(s,"uZoom"),s.uTextures=[];for(var u=0;u<this.batchManager.getMaxAtlasesPerBatch();u++)s.uTextures.push(n.getUniformLocation(s,"uTexture".concat(u)));return s}},{key:"_createVAO",value:function(){var t=[0,0,1,0,1,1,0,0,1,1,0,1];this.vertexCount=t.length/2;var n=this.maxInstances,a=this.gl,i=this.program,o=a.createVertexArray();return a.bindVertexArray(o),cV(a,"vec2",i.aPosition,t),this.transformBuffer=dV(a,n,i.aTransform),this.indexBuffer=Ln(a,n,"vec4",i.aIndex),this.vertTypeBuffer=Ln(a,n,"int",i.aVertType),this.atlasIdBuffer=Ln(a,n,"int",i.aAtlasId),this.texBuffer=Ln(a,n,"vec4",i.aTex),this.pointAPointBBuffer=Ln(a,n,"vec4",i.aPointAPointB),this.pointCPointDBuffer=Ln(a,n,"vec4",i.aPointCPointD),this.lineWidthBuffer=Ln(a,n,"vec2",i.aLineWidth),this.colorBuffer=Ln(a,n,"vec4",i.aColor),this.cornerRadiusBuffer=Ln(a,n,"vec4",i.aCornerRadius),this.borderColorBuffer=Ln(a,n,"vec4",i.aBorderColor),a.bindVertexArray(null),o}},{key:"buffers",get:function(){var t=this;return this._buffers||(this._buffers=Object.keys(this).filter(function(n){return _a(n,"Buffer")}).map(function(n){return t[n]})),this._buffers}},{key:"startFrame",value:function(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:os.SCREEN;this.panZoomMatrix=t,this.renderTarget=n,this.batchDebugInfo=[],this.wrappedCount=0,this.simpleCount=0,this.startBatch()}},{key:"startBatch",value:function(){this.instanceCount=0,this.batchManager.startBatch()}},{key:"endFrame",value:function(){this.endBatch()}},{key:"_isVisible",value:function(t,n){return t.visible()?n&&n.isVisible?n.isVisible(t):!0:!1}},{key:"drawTexture",value:function(t,n,a){var i=this.atlasManager,o=this.batchManager,s=i.getRenderTypeOpts(a);if(this._isVisible(t,s)&&!(t.isEdge()&&!this._isValidEdge(t))){if(this.renderTarget.picking&&s.getTexPickingMode){var u=s.getTexPickingMode(t);if(u===dl.IGNORE)return;if(u==dl.USE_BB){this.drawPickingRectangle(t,n,a);return}}var l=i.getAtlasInfo(t,a),f=Gt(l),d;try{for(f.s();!(d=f.n()).done;){var h=d.value,g=h.atlas,p=h.tex1,x=h.tex2;o.canAddToCurrentBatch(g)||this.endBatch();for(var b=o.getAtlasIndexForBatch(g),w=0,y=[[p,!0],[x,!1]];w<y.length;w++){var E=Zr(y[w],2),C=E[0],S=E[1];if(C.w!=0){var R=this.instanceCount;this.vertTypeBuffer.getView(R)[0]=ov;var _=this.indexBuffer.getView(R);ji(n,_);var A=this.atlasIdBuffer.getView(R);A[0]=b;var P=this.texBuffer.getView(R);P[0]=C.x,P[1]=C.y,P[2]=C.w,P[3]=C.h;var I=this.transformBuffer.getMatrixView(R);this.setTransformMatrix(t,I,s,h,S),this.instanceCount++,S||this.wrappedCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}catch(D){f.e(D)}finally{f.f()}}}},{key:"setTransformMatrix",value:function(t,n,a,i){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,s=0;if(a.shapeProps&&a.shapeProps.padding&&(s=t.pstyle(a.shapeProps.padding).pfValue),i){var u=i.bb,l=i.tex1,f=i.tex2,d=l.w/(l.w+f.w);o||(d=1-d);var h=this._getAdjustedBB(u,s,o,d);this._applyTransformMatrix(n,h,a,t)}else{var g=a.getBoundingBox(t),p=this._getAdjustedBB(g,s,!0,1);this._applyTransformMatrix(n,p,a,t)}}},{key:"_applyTransformMatrix",value:function(t,n,a,i){var o,s;GE(t);var u=a.getRotation?a.getRotation(i):0;if(u!==0){var l=a.getRotationPoint(i),f=l.x,d=l.y;Yu(t,t,[f,d]),WE(t,t,u);var h=a.getRotationOffset(i);o=h.x+(n.xOffset||0),s=h.y+(n.yOffset||0)}else o=n.x1,s=n.y1;Yu(t,t,[o,s]),qm(t,t,[n.w,n.h])}},{key:"_getAdjustedBB",value:function(t,n,a,i){var o=t.x1,s=t.y1,u=t.w,l=t.h,f=t.yOffset;n&&(o-=n,s-=n,u+=2*n,l+=2*n);var d=0,h=u*i;return a&&i<1?u=h:!a&&i<1&&(d=u-h,o+=d,u=h),{x1:o,y1:s,w:u,h:l,xOffset:d,yOffset:f}}},{key:"drawPickingRectangle",value:function(t,n,a){var i=this.atlasManager.getRenderTypeOpts(a),o=this.instanceCount;this.vertTypeBuffer.getView(o)[0]=Yi;var s=this.indexBuffer.getView(o);ji(n,s);var u=this.colorBuffer.getView(o);ri([0,0,0],1,u);var l=this.transformBuffer.getMatrixView(o);this.setTransformMatrix(t,l,i),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}},{key:"drawNode",value:function(t,n,a){var i=this.simpleShapeOptions.get(a);if(this._isVisible(t,i)){var o=i.shapeProps,s=this._getVertTypeForShape(t,o.shape);if(s===void 0||i.isSimple&&!i.isSimple(t)){this.drawTexture(t,n,a);return}var u=this.instanceCount;if(this.vertTypeBuffer.getView(u)[0]=s,s===Nu||s===Uo){var l=i.getBoundingBox(t),f=this._getCornerRadius(t,o.radius,l),d=this.cornerRadiusBuffer.getView(u);d[0]=f,d[1]=f,d[2]=f,d[3]=f,s===Uo&&(d[0]=0,d[2]=0)}var h=this.indexBuffer.getView(u);ji(n,h);var g=t.pstyle(o.color).value,p=t.pstyle(o.opacity).value,x=this.colorBuffer.getView(u);ri(g,p,x);var b=this.lineWidthBuffer.getView(u);if(b[0]=0,b[1]=0,o.border){var w=t.pstyle("border-width").value;if(w>0){var y=t.pstyle("border-color").value,E=t.pstyle("border-opacity").value,C=this.borderColorBuffer.getView(u);ri(y,E,C);var S=t.pstyle("border-position").value;if(S==="inside")b[0]=0,b[1]=-w;else if(S==="outside")b[0]=w,b[1]=0;else{var R=w/2;b[0]=R,b[1]=-R}}}var _=this.transformBuffer.getMatrixView(u);this.setTransformMatrix(t,_,i),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}},{key:"_getVertTypeForShape",value:function(t,n){var a=t.pstyle(n).value;switch(a){case"rectangle":return Yi;case"ellipse":return Ho;case"roundrectangle":case"round-rectangle":return Nu;case"bottom-round-rectangle":return Uo;default:return}}},{key:"_getCornerRadius",value:function(t,n,a){var i=a.w,o=a.h;if(t.pstyle(n).value==="auto")return Ma(i,o);var s=t.pstyle(n).pfValue,u=i/2,l=o/2;return Math.min(s,l,u)}},{key:"drawEdgeArrow",value:function(t,n,a){if(t.visible()){var i=t._private.rscratch,o,s,u;if(a==="source"?(o=i.arrowStartX,s=i.arrowStartY,u=i.srcArrowAngle):(o=i.arrowEndX,s=i.arrowEndY,u=i.tgtArrowAngle),!(isNaN(o)||o==null||isNaN(s)||s==null||isNaN(u)||u==null)){var l=t.pstyle(a+"-arrow-shape").value;if(l!=="none"){var f=t.pstyle(a+"-arrow-color").value,d=t.pstyle("opacity").value,h=t.pstyle("line-opacity").value,g=d*h,p=t.pstyle("width").pfValue,x=t.pstyle("arrow-scale").value,b=this.r.getArrowWidth(p,x),w=this.instanceCount,y=this.transformBuffer.getMatrixView(w);GE(y),Yu(y,y,[o,s]),qm(y,y,[b,b]),WE(y,y,u),this.vertTypeBuffer.getView(w)[0]=sv;var E=this.indexBuffer.getView(w);ji(n,E);var C=this.colorBuffer.getView(w);ri(f,g,C),this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}},{key:"drawEdgeLine",value:function(t,n){if(t.visible()){var a=this._getEdgePoints(t);if(a){var i=t.pstyle("opacity").value,o=t.pstyle("line-opacity").value,s=t.pstyle("width").pfValue,u=t.pstyle("line-color").value,l=i*o;if(a.length/2+this.instanceCount>this.maxInstances&&this.endBatch(),a.length==4){var f=this.instanceCount;this.vertTypeBuffer.getView(f)[0]=UE;var d=this.indexBuffer.getView(f);ji(n,d);var h=this.colorBuffer.getView(f);ri(u,l,h);var g=this.lineWidthBuffer.getView(f);g[0]=s;var p=this.pointAPointBBuffer.getView(f);p[0]=a[0],p[1]=a[1],p[2]=a[2],p[3]=a[3],this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}else for(var x=0;x<a.length-2;x+=2){var b=this.instanceCount;this.vertTypeBuffer.getView(b)[0]=HE;var w=this.indexBuffer.getView(b);ji(n,w);var y=this.colorBuffer.getView(b);ri(u,l,y);var E=this.lineWidthBuffer.getView(b);E[0]=s;var C=a[x-2],S=a[x-1],R=a[x],_=a[x+1],A=a[x+2],P=a[x+3],I=a[x+4],D=a[x+5];x==0&&(C=2*R-A+.001,S=2*_-P+.001),x==a.length-4&&(I=2*A-R+.001,D=2*P-_+.001);var L=this.pointAPointBBuffer.getView(b);L[0]=C,L[1]=S,L[2]=R,L[3]=_;var M=this.pointCPointDBuffer.getView(b);M[0]=A,M[1]=P,M[2]=I,M[3]=D,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}},{key:"_isValidEdge",value:function(t){var n=t._private.rscratch;return!(n.badLine||n.allpts==null||isNaN(n.allpts[0]))}},{key:"_getEdgePoints",value:function(t){var n=t._private.rscratch;if(this._isValidEdge(t)){var a=n.allpts;if(a.length==4)return a;var i=this._getNumSegments(t);return this._getCurveSegmentPoints(a,i)}}},{key:"_getNumSegments",value:function(t){var n=15;return Math.min(Math.max(n,5),this.maxInstances)}},{key:"_getCurveSegmentPoints",value:function(t,n){if(t.length==4)return t;for(var a=Array((n+1)*2),i=0;i<=n;i++)if(i==0)a[0]=t[0],a[1]=t[1];else if(i==n)a[i*2]=t[t.length-2],a[i*2+1]=t[t.length-1];else{var o=i/n;this._setCurvePoint(t,o,a,i*2)}return a}},{key:"_setCurvePoint",value:function(t,n,a,i){if(t.length<=2)a[i]=t[0],a[i+1]=t[1];else{for(var o=Array(t.length-2),s=0;s<o.length;s+=2){var u=(1-n)*t[s]+n*t[s+2],l=(1-n)*t[s+1]+n*t[s+3];o[s]=u,o[s+1]=l}return this._setCurvePoint(o,n,a,i)}}},{key:"endBatch",value:function(){var t=this.gl,n=this.vao,a=this.vertexCount,i=this.instanceCount;if(i!==0){var o=this.renderTarget.picking?this.pickingProgram:this.program;t.useProgram(o),t.bindVertexArray(n);var s=Gt(this.buffers),u;try{for(s.s();!(u=s.n()).done;){var l=u.value;l.bufferSubData(i)}}catch(p){s.e(p)}finally{s.f()}for(var f=this.batchManager.getAtlases(),d=0;d<f.length;d++)f[d].bufferIfNeeded(t);for(var h=0;h<f.length;h++)t.activeTexture(t.TEXTURE0+h),t.bindTexture(t.TEXTURE_2D,f[h].texture),t.uniform1i(o.uTextures[h],h);t.uniform1f(o.uZoom,aV(this.r)),t.uniformMatrix3fv(o.uPanZoomMatrix,!1,this.panZoomMatrix),t.uniform1i(o.uAtlasSize,this.batchManager.getAtlasSize());var g=ri(this.bgColor,1);t.uniform4fv(o.uBGColor,g),t.drawArraysInstanced(t.TRIANGLES,0,a,i),t.bindVertexArray(null),t.bindTexture(t.TEXTURE_2D,null),this.debug&&this.batchDebugInfo.push({count:i,atlasCount:f.length}),this.startBatch()}}},{key:"getDebugInfo",value:function(){var t=this.atlasManager.getDebugInfo(),n=t.reduce(function(o,s){return o+s.atlasCount},0),a=this.batchDebugInfo,i=a.reduce(function(o,s){return o+s.count},0);return{atlasInfo:t,totalAtlases:n,wrappedCount:this.wrappedCount,simpleCount:this.simpleCount,batchCount:a.length,batchInfo:a,totalInstances:i}}}])})(),fP={};fP.initWebgl=function(r,e){var t=this,n=t.data.contexts[t.WEBGL];r.bgColor=TV(t),r.webglTexSize=Math.min(r.webglTexSize,n.getParameter(n.MAX_TEXTURE_SIZE)),r.webglTexRows=Math.min(r.webglTexRows,54),r.webglTexRowsNodes=Math.min(r.webglTexRowsNodes,54),r.webglBatchSize=Math.min(r.webglBatchSize,16384),r.webglTexPerBatch=Math.min(r.webglTexPerBatch,n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS)),t.webglDebug=r.webglDebug,t.webglDebugShowAtlases=r.webglDebugShowAtlases,t.pickingFrameBuffer=vV(n),t.pickingFrameBuffer.needsDraw=!0,t.drawing=new SV(t,n,r);var a=function(d){return function(h){return t.getTextAngle(h,d)}},i=function(d){return function(h){var g=h.pstyle(d);return g&&g.value}},o=function(d){return function(h){return h.pstyle("".concat(d,"-opacity")).value>0}},s=function(d){var h=d.pstyle("text-events").strValue==="yes";return h?dl.USE_BB:dl.IGNORE},u=function(d){var h=d.position(),g=h.x,p=h.y,x=d.outerWidth(),b=d.outerHeight();return{w:x,h:b,x1:g-x/2,y1:p-b/2}};t.drawing.addAtlasCollection("node",{texRows:r.webglTexRowsNodes}),t.drawing.addAtlasCollection("label",{texRows:r.webglTexRows}),t.drawing.addTextureAtlasRenderType("node-body",{collection:"node",getKey:e.getStyleKey,getBoundingBox:e.getElementBox,drawElement:e.drawElement}),t.drawing.addSimpleShapeRenderType("node-body",{getBoundingBox:u,isSimple:oV,shapeProps:{shape:"shape",color:"background-color",opacity:"background-opacity",radius:"corner-radius",border:!0}}),t.drawing.addSimpleShapeRenderType("node-overlay",{getBoundingBox:u,isVisible:o("overlay"),shapeProps:{shape:"overlay-shape",color:"overlay-color",opacity:"overlay-opacity",padding:"overlay-padding",radius:"overlay-corner-radius"}}),t.drawing.addSimpleShapeRenderType("node-underlay",{getBoundingBox:u,isVisible:o("underlay"),shapeProps:{shape:"underlay-shape",color:"underlay-color",opacity:"underlay-opacity",padding:"underlay-padding",radius:"underlay-corner-radius"}}),t.drawing.addTextureAtlasRenderType("label",{collection:"label",getTexPickingMode:s,getKey:uv(e.getLabelKey,null),getBoundingBox:lv(e.getLabelBox,null),drawClipped:!0,drawElement:e.drawLabel,getRotation:a(null),getRotationPoint:e.getLabelRotationPoint,getRotationOffset:e.getLabelRotationOffset,isVisible:i("label")}),t.drawing.addTextureAtlasRenderType("edge-source-label",{collection:"label",getTexPickingMode:s,getKey:uv(e.getSourceLabelKey,"source"),getBoundingBox:lv(e.getSourceLabelBox,"source"),drawClipped:!0,drawElement:e.drawSourceLabel,getRotation:a("source"),getRotationPoint:e.getSourceLabelRotationPoint,getRotationOffset:e.getSourceLabelRotationOffset,isVisible:i("source-label")}),t.drawing.addTextureAtlasRenderType("edge-target-label",{collection:"label",getTexPickingMode:s,getKey:uv(e.getTargetLabelKey,"target"),getBoundingBox:lv(e.getTargetLabelBox,"target"),drawClipped:!0,drawElement:e.drawTargetLabel,getRotation:a("target"),getRotationPoint:e.getTargetLabelRotationPoint,getRotationOffset:e.getTargetLabelRotationOffset,isVisible:i("target-label")});var l=Ss(function(){console.log("garbage collect flag set"),t.data.gc=!0},1e4);t.onUpdateEleCalcs(function(f,d){var h=!1;d&&d.length>0&&(h|=t.drawing.invalidate(d)),h&&l()}),RV(t)};function TV(r){var e=r.cy.container(),t=e&&e.style&&e.style.backgroundColor||"white";return N2(t)}function cP(r,e){var t=r._private.rscratch;return $t(t,"labelWrapCachedLines",e)||[]}var uv=function(e,t){return function(n){var a=e(n),i=cP(n,t);return i.length>1?i.map(function(o,s){return"".concat(a,"_").concat(s)}):a}},lv=function(e,t){return function(n,a){var i=e(n);if(typeof a=="string"){var o=a.indexOf("_");if(o>0){var s=Number(a.substring(o+1)),u=cP(n,t),l=i.h/u.length,f=l*s,d=i.y1+f;return{x1:i.x1,w:i.w,y1:d,h:l,yOffset:f}}}return i}};function RV(r){{var e=r.render;r.render=function(i){i=i||{};var o=r.cy;r.webgl&&(o.zoom()>nP?(AV(r),e.call(r,i)):(PV(r),vP(r,i,os.SCREEN)))}}{var t=r.matchCanvasSize;r.matchCanvasSize=function(i){t.call(r,i),r.pickingFrameBuffer.setFramebufferAttachmentSizes(r.canvasWidth,r.canvasHeight),r.pickingFrameBuffer.needsDraw=!0}}r.findNearestElements=function(i,o,s,u){return OV(r,i,o)};{var n=r.invalidateCachedZSortedEles;r.invalidateCachedZSortedEles=function(){n.call(r),r.pickingFrameBuffer.needsDraw=!0}}{var a=r.notify;r.notify=function(i,o){a.call(r,i,o),i==="viewport"||i==="bounds"?r.pickingFrameBuffer.needsDraw=!0:i==="background"&&r.drawing.invalidate(o,{type:"node-body"})}}}function AV(r){var e=r.data.contexts[r.WEBGL];e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)}function PV(r){var e=function(n){n.save(),n.setTransform(1,0,0,1,0,0),n.clearRect(0,0,r.canvasWidth,r.canvasHeight),n.restore()};e(r.data.contexts[r.NODE]),e(r.data.contexts[r.DRAG])}function IV(r){var e=r.canvasWidth,t=r.canvasHeight,n=g0(r),a=n.pan,i=n.zoom,o=iv();Yu(o,o,[a.x,a.y]),qm(o,o,[i,i]);var s=iv();gV(s,e,t);var u=iv();return hV(u,s,o),u}function dP(r,e){var t=r.canvasWidth,n=r.canvasHeight,a=g0(r),i=a.pan,o=a.zoom;e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t,n),e.translate(i.x,i.y),e.scale(o,o)}function DV(r,e){r.drawSelectionRectangle(e,function(t){return dP(r,t)})}function BV(r){var e=r.data.contexts[r.NODE];e.save(),dP(r,e),e.strokeStyle="rgba(0, 0, 0, 0.3)",e.beginPath(),e.moveTo(-1e3,0),e.lineTo(1e3,0),e.stroke(),e.beginPath(),e.moveTo(0,-1e3),e.lineTo(0,1e3),e.stroke(),e.restore()}function MV(r){var e=function(a,i,o){for(var s=a.atlasManager.getAtlasCollection(i),u=r.data.contexts[r.NODE],l=s.atlases,f=0;f<l.length;f++){var d=l[f],h=d.canvas;if(h){var g=h.width,p=h.height,x=g*f,b=h.height*o,w=.4;u.save(),u.scale(w,w),u.drawImage(h,x,b),u.strokeStyle="black",u.rect(x,b,g,p),u.stroke(),u.restore()}}},t=0;e(r.drawing,"node",t++),e(r.drawing,"label",t++)}function LV(r,e,t,n,a){var i,o,s,u,l=g0(r),f=l.pan,d=l.zoom;{var h=iV(r,f,d,e,t),g=Zr(h,2),p=g[0],x=g[1],b=6;i=p-b/2,o=x-b/2,s=b,u=b}if(s===0||u===0)return[];var w=r.data.contexts[r.WEBGL];w.bindFramebuffer(w.FRAMEBUFFER,r.pickingFrameBuffer),r.pickingFrameBuffer.needsDraw&&(w.viewport(0,0,w.canvas.width,w.canvas.height),vP(r,null,os.PICKING),r.pickingFrameBuffer.needsDraw=!1);var y=s*u,E=new Uint8Array(y*4);w.readPixels(i,o,s,u,w.RGBA,w.UNSIGNED_BYTE,E),w.bindFramebuffer(w.FRAMEBUFFER,null);for(var C=new Set,S=0;S<y;S++){var R=E.slice(S*4,S*4+4),_=uV(R)-1;_>=0&&C.add(_)}return C}function OV(r,e,t){var n=LV(r,e,t),a=r.getCachedZSortedEles(),i,o,s=Gt(n),u;try{for(s.s();!(u=s.n()).done;){var l=u.value,f=a[l];if(!i&&f.isNode()&&(i=f),!o&&f.isEdge()&&(o=f),i&&o)break}}catch(d){s.e(d)}finally{s.f()}return[i,o].filter(Boolean)}function fv(r,e,t){var n=r.drawing;e+=1,t.isNode()?(n.drawNode(t,e,"node-underlay"),n.drawNode(t,e,"node-body"),n.drawTexture(t,e,"label"),n.drawNode(t,e,"node-overlay")):(n.drawEdgeLine(t,e),n.drawEdgeArrow(t,e,"source"),n.drawEdgeArrow(t,e,"target"),n.drawTexture(t,e,"label"),n.drawTexture(t,e,"edge-source-label"),n.drawTexture(t,e,"edge-target-label"))}function vP(r,e,t){var n;r.webglDebug&&(n=performance.now());var a=r.drawing,i=0;if(t.screen&&r.data.canvasNeedsRedraw[r.SELECT_BOX]&&DV(r,e),r.data.canvasNeedsRedraw[r.NODE]||t.picking){var o=r.data.contexts[r.WEBGL];t.screen?(o.clearColor(0,0,0,0),o.enable(o.BLEND),o.blendFunc(o.ONE,o.ONE_MINUS_SRC_ALPHA)):o.disable(o.BLEND),o.clear(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT),o.viewport(0,0,o.canvas.width,o.canvas.height);var s=IV(r),u=r.getCachedZSortedEles();if(i=u.length,a.startFrame(s,t),t.screen){for(var l=0;l<u.nondrag.length;l++)fv(r,l,u.nondrag[l]);for(var f=0;f<u.drag.length;f++)fv(r,f,u.drag[f])}else if(t.picking)for(var d=0;d<u.length;d++)fv(r,d,u[d]);a.endFrame(),t.screen&&r.webglDebugShowAtlases&&(BV(r),MV(r)),r.data.canvasNeedsRedraw[r.NODE]=!1,r.data.canvasNeedsRedraw[r.DRAG]=!1}if(r.webglDebug){var h=performance.now(),g=!1,p=Math.ceil(h-n),x=a.getDebugInfo(),b=["".concat(i," elements"),"".concat(x.totalInstances," instances"),"".concat(x.batchCount," batches"),"".concat(x.totalAtlases," atlases"),"".concat(x.wrappedCount," wrapped textures"),"".concat(x.simpleCount," simple shapes")].join(", ");if(g)console.log("WebGL (".concat(t.name,") - time ").concat(p,"ms, ").concat(b));else{console.log("WebGL (".concat(t.name,") - frame time ").concat(p,"ms")),console.log("Totals:"),console.log(" ".concat(b)),console.log("Texture Atlases Used:");var w=x.atlasInfo,y=Gt(w),E;try{for(y.s();!(E=y.n()).done;){var C=E.value;console.log(" ".concat(C.type,": ").concat(C.keyCount," keys, ").concat(C.atlasCount," atlases"))}}catch(S){y.e(S)}finally{y.f()}console.log("")}}r.data.gc&&(console.log("Garbage Collect!"),r.data.gc=!1,a.gc())}var $a={};$a.drawPolygonPath=function(r,e,t,n,a,i){var o=n/2,s=a/2;r.beginPath&&r.beginPath(),r.moveTo(e+o*i[0],t+s*i[1]);for(var u=1;u<i.length/2;u++)r.lineTo(e+o*i[u*2],t+s*i[u*2+1]);r.closePath()};$a.drawRoundPolygonPath=function(r,e,t,n,a,i,o){o.forEach(function(s){return jA(r,s)}),r.closePath()};$a.drawRoundRectanglePath=function(r,e,t,n,a,i){var o=n/2,s=a/2,u=i==="auto"?Ma(n,a):Math.min(i,s,o);r.beginPath&&r.beginPath(),r.moveTo(e,t-s),r.arcTo(e+o,t-s,e+o,t,u),r.arcTo(e+o,t+s,e,t+s,u),r.arcTo(e-o,t+s,e-o,t,u),r.arcTo(e-o,t-s,e,t-s,u),r.lineTo(e,t-s),r.closePath()};$a.drawBottomRoundRectanglePath=function(r,e,t,n,a,i){var o=n/2,s=a/2,u=i==="auto"?Ma(n,a):i;r.beginPath&&r.beginPath(),r.moveTo(e,t-s),r.lineTo(e+o,t-s),r.lineTo(e+o,t),r.arcTo(e+o,t+s,e,t+s,u),r.arcTo(e-o,t+s,e-o,t,u),r.lineTo(e-o,t-s),r.lineTo(e,t-s),r.closePath()};$a.drawCutRectanglePath=function(r,e,t,n,a,i,o){var s=n/2,u=a/2,l=o==="auto"?r0():o;r.beginPath&&r.beginPath(),r.moveTo(e-s+l,t-u),r.lineTo(e+s-l,t-u),r.lineTo(e+s,t-u+l),r.lineTo(e+s,t+u-l),r.lineTo(e+s-l,t+u),r.lineTo(e-s+l,t+u),r.lineTo(e-s,t+u-l),r.lineTo(e-s,t-u+l),r.closePath()};$a.drawBarrelPath=function(r,e,t,n,a){var i=n/2,o=a/2,s=e-i,u=e+i,l=t-o,f=t+o,d=Cm(n,a),h=d.widthOffset,g=d.heightOffset,p=d.ctrlPtOffsetPct*h;r.beginPath&&r.beginPath(),r.moveTo(s,l+g),r.lineTo(s,f-g),r.quadraticCurveTo(s+p,f,s+h,f),r.lineTo(u-h,f),r.quadraticCurveTo(u-p,f,u,f-g),r.lineTo(u,l+g),r.quadraticCurveTo(u-p,l,u-h,l),r.lineTo(s+h,l),r.quadraticCurveTo(s+p,l,s,l+g),r.closePath()};var KE=Math.sin(0),jE=Math.cos(0),Nm={},Fm={},hP=Math.PI/40;for(var Zi=0*Math.PI;Zi<2*Math.PI;Zi+=hP)Nm[Zi]=Math.sin(Zi),Fm[Zi]=Math.cos(Zi);$a.drawEllipsePath=function(r,e,t,n,a){if(r.beginPath&&r.beginPath(),r.ellipse)r.ellipse(e,t,n/2,a/2,0,0,2*Math.PI);else for(var i,o,s=n/2,u=a/2,l=0*Math.PI;l<2*Math.PI;l+=hP)i=e-s*Nm[l]*KE+s*Fm[l]*jE,o=t+u*Fm[l]*KE+u*Nm[l]*jE,l===0?r.moveTo(i,o):r.lineTo(i,o);r.closePath()};var Ds={};Ds.createBuffer=function(r,e){var t=document.createElement("canvas");return t.width=r,t.height=e,[t,t.getContext("2d")]};Ds.bufferCanvasImage=function(r){var e=this.cy,t=e.mutableElements(),n=t.boundingBox(),a=this.findContainerClientCoords(),i=r.full?Math.ceil(n.w):a[2],o=r.full?Math.ceil(n.h):a[3],s=qe(r.maxWidth)||qe(r.maxHeight),u=this.getPixelRatio(),l=1;if(r.scale!==void 0)i*=r.scale,o*=r.scale,l=r.scale;else if(s){var f=1/0,d=1/0;qe(r.maxWidth)&&(f=l*r.maxWidth/i),qe(r.maxHeight)&&(d=l*r.maxHeight/o),l=Math.min(f,d),i*=l,o*=l}s||(i*=u,o*=u,l*=u);var h=document.createElement("canvas");h.width=i,h.height=o,h.style.width=i+"px",h.style.height=o+"px";var g=h.getContext("2d");if(i>0&&o>0){g.clearRect(0,0,i,o),g.globalCompositeOperation="source-over";var p=this.getCachedZSortedEles();if(r.full)g.translate(-n.x1*l,-n.y1*l),g.scale(l,l),this.drawElements(g,p),g.scale(1/l,1/l),g.translate(n.x1*l,n.y1*l);else{var x=e.pan(),b={x:x.x*l,y:x.y*l};l*=e.zoom(),g.translate(b.x,b.y),g.scale(l,l),this.drawElements(g,p),g.scale(1/l,1/l),g.translate(-b.x,-b.y)}r.bg&&(g.globalCompositeOperation="destination-over",g.fillStyle=r.bg,g.rect(0,0,i,o),g.fill())}return h};function kV(r,e){for(var t=atob(r),n=new ArrayBuffer(t.length),a=new Uint8Array(n),i=0;i<t.length;i++)a[i]=t.charCodeAt(i);return new Blob([n],{type:e})}function YE(r){var e=r.indexOf(",");return r.substr(e+1)}function gP(r,e,t){var n=function(){return e.toDataURL(t,r.quality)};switch(r.output){case"blob-promise":return new po(function(a,i){try{e.toBlob(function(o){o!=null?a(o):i(new Error("`canvas.toBlob()` sent a null value in its callback"))},t,r.quality)}catch(o){i(o)}});case"blob":return kV(YE(n()),t);case"base64":return YE(n());case"base64uri":default:return n()}}Ds.png=function(r){return gP(r,this.bufferCanvasImage(r),"image/png")};Ds.jpg=function(r){return gP(r,this.bufferCanvasImage(r),"image/jpeg")};var pP={};pP.nodeShapeImpl=function(r,e,t,n,a,i,o,s){switch(r){case"ellipse":return this.drawEllipsePath(e,t,n,a,i);case"polygon":return this.drawPolygonPath(e,t,n,a,i,o);case"round-polygon":return this.drawRoundPolygonPath(e,t,n,a,i,o,s);case"roundrectangle":case"round-rectangle":return this.drawRoundRectanglePath(e,t,n,a,i,s);case"cutrectangle":case"cut-rectangle":return this.drawCutRectanglePath(e,t,n,a,i,o,s);case"bottomroundrectangle":case"bottom-round-rectangle":return this.drawBottomRoundRectanglePath(e,t,n,a,i,s);case"barrel":return this.drawBarrelPath(e,t,n,a,i)}};var qV=yP,cr=yP.prototype;cr.CANVAS_LAYERS=3;cr.SELECT_BOX=0;cr.DRAG=1;cr.NODE=2;cr.WEBGL=3;cr.CANVAS_TYPES=["2d","2d","2d","webgl2"];cr.BUFFER_COUNT=3;cr.TEXTURE_BUFFER=0;cr.MOTIONBLUR_BUFFER_NODE=1;cr.MOTIONBLUR_BUFFER_DRAG=2;function yP(r){var e=this,t=e.cy.window(),n=t.document;r.webgl&&(cr.CANVAS_LAYERS=e.CANVAS_LAYERS=4,console.log("webgl rendering enabled")),e.data={canvases:new Array(cr.CANVAS_LAYERS),contexts:new Array(cr.CANVAS_LAYERS),canvasNeedsRedraw:new Array(cr.CANVAS_LAYERS),bufferCanvases:new Array(cr.BUFFER_COUNT),bufferContexts:new Array(cr.CANVAS_LAYERS)};var a="-webkit-tap-highlight-color",i="rgba(0,0,0,0)";e.data.canvasContainer=n.createElement("div");var o=e.data.canvasContainer.style;e.data.canvasContainer.style[a]=i,o.position="relative",o.zIndex="0",o.overflow="hidden";var s=r.cy.container();s.appendChild(e.data.canvasContainer),s.style[a]=i;var u={"-webkit-user-select":"none","-moz-user-select":"-moz-none","user-select":"none","-webkit-tap-highlight-color":"rgba(0,0,0,0)","outline-style":"none"};DN()&&(u["-ms-touch-action"]="none",u["touch-action"]="none");for(var l=0;l<cr.CANVAS_LAYERS;l++){var f=e.data.canvases[l]=n.createElement("canvas"),d=cr.CANVAS_TYPES[l];e.data.contexts[l]=f.getContext(d),e.data.contexts[l]||kr("Could not create canvas of type "+d),Object.keys(u).forEach(function(oe){f.style[oe]=u[oe]}),f.style.position="absolute",f.setAttribute("data-id","layer"+l),f.style.zIndex=String(cr.CANVAS_LAYERS-l),e.data.canvasContainer.appendChild(f),e.data.canvasNeedsRedraw[l]=!1}e.data.topCanvas=e.data.canvases[0],e.data.canvases[cr.NODE].setAttribute("data-id","layer"+cr.NODE+"-node"),e.data.canvases[cr.SELECT_BOX].setAttribute("data-id","layer"+cr.SELECT_BOX+"-selectbox"),e.data.canvases[cr.DRAG].setAttribute("data-id","layer"+cr.DRAG+"-drag"),e.data.canvases[cr.WEBGL]&&e.data.canvases[cr.WEBGL].setAttribute("data-id","layer"+cr.WEBGL+"-webgl");for(var l=0;l<cr.BUFFER_COUNT;l++)e.data.bufferCanvases[l]=n.createElement("canvas"),e.data.bufferContexts[l]=e.data.bufferCanvases[l].getContext("2d"),e.data.bufferCanvases[l].style.position="absolute",e.data.bufferCanvases[l].setAttribute("data-id","buffer"+l),e.data.bufferCanvases[l].style.zIndex=String(-l-1),e.data.bufferCanvases[l].style.visibility="hidden";e.pathsEnabled=!0;var h=Lt(),g=function(X){return{x:(X.x1+X.x2)/2,y:(X.y1+X.y2)/2}},p=function(X){return{x:-X.w/2,y:-X.h/2}},x=function(X){var Q=X[0]._private,ie=Q.oldBackgroundTimestamp===Q.backgroundTimestamp;return!ie},b=function(X){return X[0]._private.nodeKey},w=function(X){return X[0]._private.labelStyleKey},y=function(X){return X[0]._private.sourceLabelStyleKey},E=function(X){return X[0]._private.targetLabelStyleKey},C=function(X,Q,ie,de,we){return e.drawElement(X,Q,ie,!1,!1,we)},S=function(X,Q,ie,de,we){return e.drawElementText(X,Q,ie,de,"main",we)},R=function(X,Q,ie,de,we){return e.drawElementText(X,Q,ie,de,"source",we)},_=function(X,Q,ie,de,we){return e.drawElementText(X,Q,ie,de,"target",we)},A=function(X){return X.boundingBox(),X[0]._private.bodyBounds},P=function(X){return X.boundingBox(),X[0]._private.labelBounds.main||h},I=function(X){return X.boundingBox(),X[0]._private.labelBounds.source||h},D=function(X){return X.boundingBox(),X[0]._private.labelBounds.target||h},L=function(X,Q){return Q},M=function(X){return g(A(X))},q=function(X,Q,ie){var de=X?X+"-":"";return{x:Q.x+ie.pstyle(de+"text-margin-x").pfValue,y:Q.y+ie.pstyle(de+"text-margin-y").pfValue}},N=function(X,Q,ie){var de=X[0]._private.rscratch;return{x:de[Q],y:de[ie]}},W=function(X){return q("",N(X,"labelX","labelY"),X)},V=function(X){return q("source",N(X,"sourceLabelX","sourceLabelY"),X)},$=function(X){return q("target",N(X,"targetLabelX","targetLabelY"),X)},Z=function(X){return p(A(X))},ee=function(X){return p(I(X))},K=function(X){return p(D(X))},j=function(X){var Q=P(X),ie=p(P(X));if(X.isNode()){switch(X.pstyle("text-halign").value){case"left":ie.x=-Q.w-(Q.leftPad||0);break;case"right":ie.x=-(Q.rightPad||0);break}switch(X.pstyle("text-valign").value){case"top":ie.y=-Q.h-(Q.topPad||0);break;case"bottom":ie.y=-(Q.botPad||0);break}}return ie},fe=e.data.eleTxrCache=new Xo(e,{getKey:b,doesEleInvalidateKey:x,drawElement:C,getBoundingBox:A,getRotationPoint:M,getRotationOffset:Z,allowEdgeTxrCaching:!1,allowParentTxrCaching:!1}),G=e.data.lblTxrCache=new Xo(e,{getKey:w,drawElement:S,getBoundingBox:P,getRotationPoint:W,getRotationOffset:j,isVisible:L}),z=e.data.slbTxrCache=new Xo(e,{getKey:y,drawElement:R,getBoundingBox:I,getRotationPoint:V,getRotationOffset:ee,isVisible:L}),Y=e.data.tlbTxrCache=new Xo(e,{getKey:E,drawElement:_,getBoundingBox:D,getRotationPoint:$,getRotationOffset:K,isVisible:L}),te=e.data.lyrTxrCache=new aP(e);e.onUpdateEleCalcs(function(X,Q){fe.invalidateElements(Q),G.invalidateElements(Q),z.invalidateElements(Q),Y.invalidateElements(Q),te.invalidateElements(Q);for(var ie=0;ie<Q.length;ie++){var de=Q[ie]._private;de.oldBackgroundTimestamp=de.backgroundTimestamp}});var ue=function(X){for(var Q=0;Q<X.length;Q++)te.enqueueElementRefinement(X[Q].ele)};fe.onDequeue(ue),G.onDequeue(ue),z.onDequeue(ue),Y.onDequeue(ue),r.webgl&&e.initWebgl(r,{getStyleKey:b,getLabelKey:w,getSourceLabelKey:y,getTargetLabelKey:E,drawElement:C,drawLabel:S,drawSourceLabel:R,drawTargetLabel:_,getElementBox:A,getLabelBox:P,getSourceLabelBox:I,getTargetLabelBox:D,getElementRotationPoint:M,getElementRotationOffset:Z,getLabelRotationPoint:W,getSourceLabelRotationPoint:V,getTargetLabelRotationPoint:$,getLabelRotationOffset:j,getSourceLabelRotationOffset:ee,getTargetLabelRotationOffset:K})}cr.redrawHint=function(r,e){var t=this;switch(r){case"eles":t.data.canvasNeedsRedraw[cr.NODE]=e;break;case"drag":t.data.canvasNeedsRedraw[cr.DRAG]=e;break;case"select":t.data.canvasNeedsRedraw[cr.SELECT_BOX]=e;break;case"gc":t.data.gc=!0;break}};var NV=typeof Path2D<"u";cr.path2dEnabled=function(r){if(r===void 0)return this.pathsEnabled;this.pathsEnabled=!!r};cr.usePaths=function(){return NV&&this.pathsEnabled};cr.setImgSmoothing=function(r,e){r.imageSmoothingEnabled!=null?r.imageSmoothingEnabled=e:(r.webkitImageSmoothingEnabled=e,r.mozImageSmoothingEnabled=e,r.msImageSmoothingEnabled=e)};cr.getImgSmoothing=function(r){return r.imageSmoothingEnabled!=null?r.imageSmoothingEnabled:r.webkitImageSmoothingEnabled||r.mozImageSmoothingEnabled||r.msImageSmoothingEnabled};cr.makeOffscreenCanvas=function(r,e){var t;if((typeof OffscreenCanvas>"u"?"undefined":at(OffscreenCanvas))!=="undefined")t=new OffscreenCanvas(r,e);else{var n=this.cy.window(),a=n.document;t=a.createElement("canvas"),t.width=r,t.height=e}return t};[iP,Vn,ia,h0,bi,za,Ot,fP,$a,Ds,pP].forEach(function(r){Xe(cr,r)});var FV=[{name:"null",impl:UA},{name:"base",impl:rP},{name:"canvas",impl:qV}],zV=[{type:"layout",extensions:c3},{type:"renderer",extensions:FV}],mP={},bP={};function wP(r,e,t){var n=t,a=function(A){Cr("Can not register `"+e+"` for `"+r+"` since `"+A+"` already exists in the prototype and can not be overridden")};if(r==="core"){if(ys.prototype[e])return a(e);ys.prototype[e]=t}else if(r==="collection"){if(bt.prototype[e])return a(e);bt.prototype[e]=t}else if(r==="layout"){for(var i=function(A){this.options=A,t.call(this,A),yr(this._private)||(this._private={}),this._private.cy=A.cy,this._private.listeners=[],this.createEmitter()},o=i.prototype=Object.create(t.prototype),s=[],u=0;u<s.length;u++){var l=s[u];o[l]=o[l]||function(){return this}}o.start&&!o.run?o.run=function(){return this.start(),this}:!o.start&&o.run&&(o.start=function(){return this.run(),this});var f=t.prototype.stop;o.stop=function(){var _=this.options;if(_&&_.animate){var A=this.animations;if(A)for(var P=0;P<A.length;P++)A[P].stop()}return f?f.call(this):this.emit("layoutstop"),this},o.destroy||(o.destroy=function(){return this}),o.cy=function(){return this._private.cy};var d=function(A){return A._private.cy},h={addEventFields:function(A,P){P.layout=A,P.cy=d(A),P.target=A},bubble:function(){return!0},parent:function(A){return d(A)}};Xe(o,{createEmitter:function(){return this._private.emitter=new Pl(h,this),this},emitter:function(){return this._private.emitter},on:function(A,P){return this.emitter().on(A,P),this},one:function(A,P){return this.emitter().one(A,P),this},once:function(A,P){return this.emitter().one(A,P),this},removeListener:function(A,P){return this.emitter().removeListener(A,P),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},emit:function(A,P){return this.emitter().emit(A,P),this}}),Er.eventAliasesOn(o),n=i}else if(r==="renderer"&&e!=="null"&&e!=="base"){var g=xP("renderer","base"),p=g.prototype,x=t,b=t.prototype,w=function(){g.apply(this,arguments),x.apply(this,arguments)},y=w.prototype;for(var E in p){var C=p[E],S=b[E]!=null;if(S)return a(E);y[E]=C}for(var R in b)y[R]=b[R];p.clientFunctions.forEach(function(_){y[_]=y[_]||function(){kr("Renderer does not implement `renderer."+_+"()` on its prototype")}}),n=w}else if(r==="__proto__"||r==="constructor"||r==="prototype")return kr(r+" is an illegal type to be registered, possibly lead to prototype pollutions");return F2({map:mP,keys:[r,e],value:n})}function xP(r,e){return z2({map:mP,keys:[r,e]})}function $V(r,e,t,n,a){return F2({map:bP,keys:[r,e,t,n],value:a})}function VV(r,e,t,n){return z2({map:bP,keys:[r,e,t,n]})}var zm=function(){if(arguments.length===2)return xP.apply(null,arguments);if(arguments.length===3)return wP.apply(null,arguments);if(arguments.length===4)return VV.apply(null,arguments);if(arguments.length===5)return $V.apply(null,arguments);kr("Invalid extension access syntax")};ys.prototype.extension=zm;zV.forEach(function(r){r.extensions.forEach(function(e){wP(r.type,e.name,e.impl)})});var vl=function(){if(!(this instanceof vl))return new vl;this.length=0},gi=vl.prototype;gi.instanceString=function(){return"stylesheet"};gi.selector=function(r){var e=this.length++;return this[e]={selector:r,properties:[]},this};gi.css=function(r,e){var t=this.length-1;if(Ye(r))this[t].properties.push({name:r,value:e});else if(yr(r))for(var n=r,a=Object.keys(n),i=0;i<a.length;i++){var o=a[i],s=n[o];if(s!=null){var u=lt.properties[o]||lt.properties[bl(o)];if(u!=null){var l=u.name,f=s;this[t].properties.push({name:l,value:f})}}}return this};gi.style=gi.css;gi.generateStyle=function(r){var e=new lt(r);return this.appendToStyle(e)};gi.appendToStyle=function(r){for(var e=0;e<this.length;e++){var t=this[e],n=t.selector,a=t.properties;r.selector(n);for(var i=0;i<a.length;i++){var o=a[i];r.css(o.name,o.value)}}return r};var GV="3.33.1",vn=function(e){if(e===void 0&&(e={}),yr(e))return new ys(e);if(Ye(e))return zm.apply(zm,arguments)};vn.use=function(r){var e=Array.prototype.slice.call(arguments,1);return e.unshift(vn),r.apply(null,e),this};vn.warnings=function(r){return K2(r)};vn.version=GV;vn.stylesheet=vn.Stylesheet=vl;var Zu={exports:{}};function p0(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var cv,ZE;function WV(){if(ZE)return cv;ZE=1;function r(){this.__data__=[],this.size=0}return cv=r,cv}var dv,XE;function xo(){if(XE)return dv;XE=1;function r(e,t){return e===t||e!==e&&t!==t}return dv=r,dv}var vv,QE;function ql(){if(QE)return vv;QE=1;var r=xo();function e(t,n){for(var a=t.length;a--;)if(r(t[a][0],n))return a;return-1}return vv=e,vv}var hv,JE;function UV(){if(JE)return hv;JE=1;var r=ql(),e=Array.prototype,t=e.splice;function n(a){var i=this.__data__,o=r(i,a);if(o<0)return!1;var s=i.length-1;return o==s?i.pop():t.call(i,o,1),--this.size,!0}return hv=n,hv}var gv,eC;function HV(){if(eC)return gv;eC=1;var r=ql();function e(t){var n=this.__data__,a=r(n,t);return a<0?void 0:n[a][1]}return gv=e,gv}var pv,rC;function KV(){if(rC)return pv;rC=1;var r=ql();function e(t){return r(this.__data__,t)>-1}return pv=e,pv}var yv,tC;function jV(){if(tC)return yv;tC=1;var r=ql();function e(t,n){var a=this.__data__,i=r(a,t);return i<0?(++this.size,a.push([t,n])):a[i][1]=n,this}return yv=e,yv}var mv,nC;function Nl(){if(nC)return mv;nC=1;var r=WV(),e=UV(),t=HV(),n=KV(),a=jV();function i(o){var s=-1,u=o==null?0:o.length;for(this.clear();++s<u;){var l=o[s];this.set(l[0],l[1])}}return i.prototype.clear=r,i.prototype.delete=e,i.prototype.get=t,i.prototype.has=n,i.prototype.set=a,mv=i,mv}var bv,aC;function YV(){if(aC)return bv;aC=1;var r=Nl();function e(){this.__data__=new r,this.size=0}return bv=e,bv}var wv,iC;function ZV(){if(iC)return wv;iC=1;function r(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}return wv=r,wv}var xv,oC;function XV(){if(oC)return xv;oC=1;function r(e){return this.__data__.get(e)}return xv=r,xv}var Ev,sC;function QV(){if(sC)return Ev;sC=1;function r(e){return this.__data__.has(e)}return Ev=r,Ev}var Cv,uC;function Bs(){if(uC)return Cv;uC=1;var r=yi(),e=rn(),t="[object AsyncFunction]",n="[object Function]",a="[object GeneratorFunction]",i="[object Proxy]";function o(s){if(!e(s))return!1;var u=r(s);return u==n||u==a||u==t||u==i}return Cv=o,Cv}var _v,lC;function JV(){if(lC)return _v;lC=1;var r=An(),e=r["__core-js_shared__"];return _v=e,_v}var Sv,fC;function e4(){if(fC)return Sv;fC=1;var r=JV(),e=(function(){var n=/[^.]+$/.exec(r&&r.keys&&r.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function t(n){return!!e&&e in n}return Sv=t,Sv}var Tv,cC;function EP(){if(cC)return Tv;cC=1;var r=Function.prototype,e=r.toString;function t(n){if(n!=null){try{return e.call(n)}catch{}try{return n+""}catch{}}return""}return Tv=t,Tv}var Rv,dC;function r4(){if(dC)return Rv;dC=1;var r=Bs(),e=e4(),t=rn(),n=EP(),a=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,u=o.toString,l=s.hasOwnProperty,f=RegExp("^"+u.call(l).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function d(h){if(!t(h)||e(h))return!1;var g=r(h)?f:i;return g.test(n(h))}return Rv=d,Rv}var Av,vC;function t4(){if(vC)return Av;vC=1;function r(e,t){return e==null?void 0:e[t]}return Av=r,Av}var Pv,hC;function wi(){if(hC)return Pv;hC=1;var r=r4(),e=t4();function t(n,a){var i=e(n,a);return r(i)?i:void 0}return Pv=t,Pv}var Iv,gC;function y0(){if(gC)return Iv;gC=1;var r=wi(),e=An(),t=r(e,"Map");return Iv=t,Iv}var Dv,pC;function Fl(){if(pC)return Dv;pC=1;var r=wi(),e=r(Object,"create");return Dv=e,Dv}var Bv,yC;function n4(){if(yC)return Bv;yC=1;var r=Fl();function e(){this.__data__=r?r(null):{},this.size=0}return Bv=e,Bv}var Mv,mC;function a4(){if(mC)return Mv;mC=1;function r(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}return Mv=r,Mv}var Lv,bC;function i4(){if(bC)return Lv;bC=1;var r=Fl(),e="__lodash_hash_undefined__",t=Object.prototype,n=t.hasOwnProperty;function a(i){var o=this.__data__;if(r){var s=o[i];return s===e?void 0:s}return n.call(o,i)?o[i]:void 0}return Lv=a,Lv}var Ov,wC;function o4(){if(wC)return Ov;wC=1;var r=Fl(),e=Object.prototype,t=e.hasOwnProperty;function n(a){var i=this.__data__;return r?i[a]!==void 0:t.call(i,a)}return Ov=n,Ov}var kv,xC;function s4(){if(xC)return kv;xC=1;var r=Fl(),e="__lodash_hash_undefined__";function t(n,a){var i=this.__data__;return this.size+=this.has(n)?0:1,i[n]=r&&a===void 0?e:a,this}return kv=t,kv}var qv,EC;function u4(){if(EC)return qv;EC=1;var r=n4(),e=a4(),t=i4(),n=o4(),a=s4();function i(o){var s=-1,u=o==null?0:o.length;for(this.clear();++s<u;){var l=o[s];this.set(l[0],l[1])}}return i.prototype.clear=r,i.prototype.delete=e,i.prototype.get=t,i.prototype.has=n,i.prototype.set=a,qv=i,qv}var Nv,CC;function l4(){if(CC)return Nv;CC=1;var r=u4(),e=Nl(),t=y0();function n(){this.size=0,this.__data__={hash:new r,map:new(t||e),string:new r}}return Nv=n,Nv}var Fv,_C;function f4(){if(_C)return Fv;_C=1;function r(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}return Fv=r,Fv}var zv,SC;function zl(){if(SC)return zv;SC=1;var r=f4();function e(t,n){var a=t.__data__;return r(n)?a[typeof n=="string"?"string":"hash"]:a.map}return zv=e,zv}var $v,TC;function c4(){if(TC)return $v;TC=1;var r=zl();function e(t){var n=r(this,t).delete(t);return this.size-=n?1:0,n}return $v=e,$v}var Vv,RC;function d4(){if(RC)return Vv;RC=1;var r=zl();function e(t){return r(this,t).get(t)}return Vv=e,Vv}var Gv,AC;function v4(){if(AC)return Gv;AC=1;var r=zl();function e(t){return r(this,t).has(t)}return Gv=e,Gv}var Wv,PC;function h4(){if(PC)return Wv;PC=1;var r=zl();function e(t,n){var a=r(this,t),i=a.size;return a.set(t,n),this.size+=a.size==i?0:1,this}return Wv=e,Wv}var Uv,IC;function m0(){if(IC)return Uv;IC=1;var r=l4(),e=c4(),t=d4(),n=v4(),a=h4();function i(o){var s=-1,u=o==null?0:o.length;for(this.clear();++s<u;){var l=o[s];this.set(l[0],l[1])}}return i.prototype.clear=r,i.prototype.delete=e,i.prototype.get=t,i.prototype.has=n,i.prototype.set=a,Uv=i,Uv}var Hv,DC;function g4(){if(DC)return Hv;DC=1;var r=Nl(),e=y0(),t=m0(),n=200;function a(i,o){var s=this.__data__;if(s instanceof r){var u=s.__data__;if(!e||u.length<n-1)return u.push([i,o]),this.size=++s.size,this;s=this.__data__=new t(u)}return s.set(i,o),this.size=s.size,this}return Hv=a,Hv}var Kv,BC;function $l(){if(BC)return Kv;BC=1;var r=Nl(),e=YV(),t=ZV(),n=XV(),a=QV(),i=g4();function o(s){var u=this.__data__=new r(s);this.size=u.size}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=a,o.prototype.set=i,Kv=o,Kv}var jv,MC;function b0(){if(MC)return jv;MC=1;function r(e,t){for(var n=-1,a=e==null?0:e.length;++n<a&&t(e[n],n,e)!==!1;);return e}return jv=r,jv}var Yv,LC;function CP(){if(LC)return Yv;LC=1;var r=wi(),e=(function(){try{var t=r(Object,"defineProperty");return t({},"",{}),t}catch{}})();return Yv=e,Yv}var Zv,OC;function Vl(){if(OC)return Zv;OC=1;var r=CP();function e(t,n,a){n=="__proto__"&&r?r(t,n,{configurable:!0,enumerable:!0,value:a,writable:!0}):t[n]=a}return Zv=e,Zv}var Xv,kC;function Gl(){if(kC)return Xv;kC=1;var r=Vl(),e=xo(),t=Object.prototype,n=t.hasOwnProperty;function a(i,o,s){var u=i[o];(!(n.call(i,o)&&e(u,s))||s===void 0&&!(o in i))&&r(i,o,s)}return Xv=a,Xv}var Qv,qC;function Ms(){if(qC)return Qv;qC=1;var r=Gl(),e=Vl();function t(n,a,i,o){var s=!i;i||(i={});for(var u=-1,l=a.length;++u<l;){var f=a[u],d=o?o(i[f],n[f],f,i,n):void 0;d===void 0&&(d=n[f]),s?e(i,f,d):r(i,f,d)}return i}return Qv=t,Qv}var Jv,NC;function p4(){if(NC)return Jv;NC=1;function r(e,t){for(var n=-1,a=Array(e);++n<e;)a[n]=t(n);return a}return Jv=r,Jv}var eh,FC;function y4(){if(FC)return eh;FC=1;var r=yi(),e=zn(),t="[object Arguments]";function n(a){return e(a)&&r(a)==t}return eh=n,eh}var rh,zC;function Ls(){if(zC)return rh;zC=1;var r=y4(),e=zn(),t=Object.prototype,n=t.hasOwnProperty,a=t.propertyIsEnumerable,i=r((function(){return arguments})())?r:function(o){return e(o)&&n.call(o,"callee")&&!a.call(o,"callee")};return rh=i,rh}var th,$C;function Xr(){if($C)return th;$C=1;var r=Array.isArray;return th=r,th}var Qo={exports:{}},nh,VC;function m4(){if(VC)return nh;VC=1;function r(){return!1}return nh=r,nh}Qo.exports;var GC;function Eo(){return GC||(GC=1,(function(r,e){var t=An(),n=m4(),a=e&&!e.nodeType&&e,i=a&&!0&&r&&!r.nodeType&&r,o=i&&i.exports===a,s=o?t.Buffer:void 0,u=s?s.isBuffer:void 0,l=u||n;r.exports=l})(Qo,Qo.exports)),Qo.exports}var ah,WC;function Wl(){if(WC)return ah;WC=1;var r=9007199254740991,e=/^(?:0|[1-9]\d*)$/;function t(n,a){var i=typeof n;return a=a??r,!!a&&(i=="number"||i!="symbol"&&e.test(n))&&n>-1&&n%1==0&&n<a}return ah=t,ah}var ih,UC;function w0(){if(UC)return ih;UC=1;var r=9007199254740991;function e(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=r}return ih=e,ih}var oh,HC;function b4(){if(HC)return oh;HC=1;var r=yi(),e=w0(),t=zn(),n="[object Arguments]",a="[object Array]",i="[object Boolean]",o="[object Date]",s="[object Error]",u="[object Function]",l="[object Map]",f="[object Number]",d="[object Object]",h="[object RegExp]",g="[object Set]",p="[object String]",x="[object WeakMap]",b="[object ArrayBuffer]",w="[object DataView]",y="[object Float32Array]",E="[object Float64Array]",C="[object Int8Array]",S="[object Int16Array]",R="[object Int32Array]",_="[object Uint8Array]",A="[object Uint8ClampedArray]",P="[object Uint16Array]",I="[object Uint32Array]",D={};D[y]=D[E]=D[C]=D[S]=D[R]=D[_]=D[A]=D[P]=D[I]=!0,D[n]=D[a]=D[b]=D[i]=D[w]=D[o]=D[s]=D[u]=D[l]=D[f]=D[d]=D[h]=D[g]=D[p]=D[x]=!1;function L(M){return t(M)&&e(M.length)&&!!D[r(M)]}return oh=L,oh}var sh,KC;function Ul(){if(KC)return sh;KC=1;function r(e){return function(t){return e(t)}}return sh=r,sh}var Jo={exports:{}};Jo.exports;var jC;function x0(){return jC||(jC=1,(function(r,e){var t=A2(),n=e&&!e.nodeType&&e,a=n&&!0&&r&&!r.nodeType&&r,i=a&&a.exports===n,o=i&&t.process,s=(function(){try{var u=a&&a.require&&a.require("util").types;return u||o&&o.binding&&o.binding("util")}catch{}})();r.exports=s})(Jo,Jo.exports)),Jo.exports}var uh,YC;function Os(){if(YC)return uh;YC=1;var r=b4(),e=Ul(),t=x0(),n=t&&t.isTypedArray,a=n?e(n):r;return uh=a,uh}var lh,ZC;function _P(){if(ZC)return lh;ZC=1;var r=p4(),e=Ls(),t=Xr(),n=Eo(),a=Wl(),i=Os(),o=Object.prototype,s=o.hasOwnProperty;function u(l,f){var d=t(l),h=!d&&e(l),g=!d&&!h&&n(l),p=!d&&!h&&!g&&i(l),x=d||h||g||p,b=x?r(l.length,String):[],w=b.length;for(var y in l)(f||s.call(l,y))&&!(x&&(y=="length"||g&&(y=="offset"||y=="parent")||p&&(y=="buffer"||y=="byteLength"||y=="byteOffset")||a(y,w)))&&b.push(y);return b}return lh=u,lh}var fh,XC;function Hl(){if(XC)return fh;XC=1;var r=Object.prototype;function e(t){var n=t&&t.constructor,a=typeof n=="function"&&n.prototype||r;return t===a}return fh=e,fh}var ch,QC;function SP(){if(QC)return ch;QC=1;function r(e,t){return function(n){return e(t(n))}}return ch=r,ch}var dh,JC;function w4(){if(JC)return dh;JC=1;var r=SP(),e=r(Object.keys,Object);return dh=e,dh}var vh,e_;function E0(){if(e_)return vh;e_=1;var r=Hl(),e=w4(),t=Object.prototype,n=t.hasOwnProperty;function a(i){if(!r(i))return e(i);var o=[];for(var s in Object(i))n.call(i,s)&&s!="constructor"&&o.push(s);return o}return vh=a,vh}var hh,r_;function oa(){if(r_)return hh;r_=1;var r=Bs(),e=w0();function t(n){return n!=null&&e(n.length)&&!r(n)}return hh=t,hh}var gh,t_;function Va(){if(t_)return gh;t_=1;var r=_P(),e=E0(),t=oa();function n(a){return t(a)?r(a):e(a)}return gh=n,gh}var ph,n_;function x4(){if(n_)return ph;n_=1;var r=Ms(),e=Va();function t(n,a){return n&&r(a,e(a),n)}return ph=t,ph}var yh,a_;function E4(){if(a_)return yh;a_=1;function r(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}return yh=r,yh}var mh,i_;function C4(){if(i_)return mh;i_=1;var r=rn(),e=Hl(),t=E4(),n=Object.prototype,a=n.hasOwnProperty;function i(o){if(!r(o))return t(o);var s=e(o),u=[];for(var l in o)l=="constructor"&&(s||!a.call(o,l))||u.push(l);return u}return mh=i,mh}var bh,o_;function xi(){if(o_)return bh;o_=1;var r=_P(),e=C4(),t=oa();function n(a){return t(a)?r(a,!0):e(a)}return bh=n,bh}var wh,s_;function _4(){if(s_)return wh;s_=1;var r=Ms(),e=xi();function t(n,a){return n&&r(a,e(a),n)}return wh=t,wh}var es={exports:{}};es.exports;var u_;function TP(){return u_||(u_=1,(function(r,e){var t=An(),n=e&&!e.nodeType&&e,a=n&&!0&&r&&!r.nodeType&&r,i=a&&a.exports===n,o=i?t.Buffer:void 0,s=o?o.allocUnsafe:void 0;function u(l,f){if(f)return l.slice();var d=l.length,h=s?s(d):new l.constructor(d);return l.copy(h),h}r.exports=u})(es,es.exports)),es.exports}var xh,l_;function RP(){if(l_)return xh;l_=1;function r(e,t){var n=-1,a=e.length;for(t||(t=Array(a));++n<a;)t[n]=e[n];return t}return xh=r,xh}var Eh,f_;function AP(){if(f_)return Eh;f_=1;function r(e,t){for(var n=-1,a=e==null?0:e.length,i=0,o=[];++n<a;){var s=e[n];t(s,n,e)&&(o[i++]=s)}return o}return Eh=r,Eh}var Ch,c_;function PP(){if(c_)return Ch;c_=1;function r(){return[]}return Ch=r,Ch}var _h,d_;function C0(){if(d_)return _h;d_=1;var r=AP(),e=PP(),t=Object.prototype,n=t.propertyIsEnumerable,a=Object.getOwnPropertySymbols,i=a?function(o){return o==null?[]:(o=Object(o),r(a(o),function(s){return n.call(o,s)}))}:e;return _h=i,_h}var Sh,v_;function S4(){if(v_)return Sh;v_=1;var r=Ms(),e=C0();function t(n,a){return r(n,e(n),a)}return Sh=t,Sh}var Th,h_;function _0(){if(h_)return Th;h_=1;function r(e,t){for(var n=-1,a=t.length,i=e.length;++n<a;)e[i+n]=t[n];return e}return Th=r,Th}var Rh,g_;function Kl(){if(g_)return Rh;g_=1;var r=SP(),e=r(Object.getPrototypeOf,Object);return Rh=e,Rh}var Ah,p_;function IP(){if(p_)return Ah;p_=1;var r=_0(),e=Kl(),t=C0(),n=PP(),a=Object.getOwnPropertySymbols,i=a?function(o){for(var s=[];o;)r(s,t(o)),o=e(o);return s}:n;return Ah=i,Ah}var Ph,y_;function T4(){if(y_)return Ph;y_=1;var r=Ms(),e=IP();function t(n,a){return r(n,e(n),a)}return Ph=t,Ph}var Ih,m_;function DP(){if(m_)return Ih;m_=1;var r=_0(),e=Xr();function t(n,a,i){var o=a(n);return e(n)?o:r(o,i(n))}return Ih=t,Ih}var Dh,b_;function BP(){if(b_)return Dh;b_=1;var r=DP(),e=C0(),t=Va();function n(a){return r(a,t,e)}return Dh=n,Dh}var Bh,w_;function R4(){if(w_)return Bh;w_=1;var r=DP(),e=IP(),t=xi();function n(a){return r(a,t,e)}return Bh=n,Bh}var Mh,x_;function A4(){if(x_)return Mh;x_=1;var r=wi(),e=An(),t=r(e,"DataView");return Mh=t,Mh}var Lh,E_;function P4(){if(E_)return Lh;E_=1;var r=wi(),e=An(),t=r(e,"Promise");return Lh=t,Lh}var Oh,C_;function MP(){if(C_)return Oh;C_=1;var r=wi(),e=An(),t=r(e,"Set");return Oh=t,Oh}var kh,__;function I4(){if(__)return kh;__=1;var r=wi(),e=An(),t=r(e,"WeakMap");return kh=t,kh}var qh,S_;function Co(){if(S_)return qh;S_=1;var r=A4(),e=y0(),t=P4(),n=MP(),a=I4(),i=yi(),o=EP(),s="[object Map]",u="[object Object]",l="[object Promise]",f="[object Set]",d="[object WeakMap]",h="[object DataView]",g=o(r),p=o(e),x=o(t),b=o(n),w=o(a),y=i;return(r&&y(new r(new ArrayBuffer(1)))!=h||e&&y(new e)!=s||t&&y(t.resolve())!=l||n&&y(new n)!=f||a&&y(new a)!=d)&&(y=function(E){var C=i(E),S=C==u?E.constructor:void 0,R=S?o(S):"";if(R)switch(R){case g:return h;case p:return s;case x:return l;case b:return f;case w:return d}return C}),qh=y,qh}var Nh,T_;function D4(){if(T_)return Nh;T_=1;var r=Object.prototype,e=r.hasOwnProperty;function t(n){var a=n.length,i=new n.constructor(a);return a&&typeof n[0]=="string"&&e.call(n,"index")&&(i.index=n.index,i.input=n.input),i}return Nh=t,Nh}var Fh,R_;function LP(){if(R_)return Fh;R_=1;var r=An(),e=r.Uint8Array;return Fh=e,Fh}var zh,A_;function S0(){if(A_)return zh;A_=1;var r=LP();function e(t){var n=new t.constructor(t.byteLength);return new r(n).set(new r(t)),n}return zh=e,zh}var $h,P_;function B4(){if(P_)return $h;P_=1;var r=S0();function e(t,n){var a=n?r(t.buffer):t.buffer;return new t.constructor(a,t.byteOffset,t.byteLength)}return $h=e,$h}var Vh,I_;function M4(){if(I_)return Vh;I_=1;var r=/\w*$/;function e(t){var n=new t.constructor(t.source,r.exec(t));return n.lastIndex=t.lastIndex,n}return Vh=e,Vh}var Gh,D_;function L4(){if(D_)return Gh;D_=1;var r=vo(),e=r?r.prototype:void 0,t=e?e.valueOf:void 0;function n(a){return t?Object(t.call(a)):{}}return Gh=n,Gh}var Wh,B_;function OP(){if(B_)return Wh;B_=1;var r=S0();function e(t,n){var a=n?r(t.buffer):t.buffer;return new t.constructor(a,t.byteOffset,t.length)}return Wh=e,Wh}var Uh,M_;function O4(){if(M_)return Uh;M_=1;var r=S0(),e=B4(),t=M4(),n=L4(),a=OP(),i="[object Boolean]",o="[object Date]",s="[object Map]",u="[object Number]",l="[object RegExp]",f="[object Set]",d="[object String]",h="[object Symbol]",g="[object ArrayBuffer]",p="[object DataView]",x="[object Float32Array]",b="[object Float64Array]",w="[object Int8Array]",y="[object Int16Array]",E="[object Int32Array]",C="[object Uint8Array]",S="[object Uint8ClampedArray]",R="[object Uint16Array]",_="[object Uint32Array]";function A(P,I,D){var L=P.constructor;switch(I){case g:return r(P);case i:case o:return new L(+P);case p:return e(P,D);case x:case b:case w:case y:case E:case C:case S:case R:case _:return a(P,D);case s:return new L;case u:case d:return new L(P);case l:return t(P);case f:return new L;case h:return n(P)}}return Uh=A,Uh}var Hh,L_;function kP(){if(L_)return Hh;L_=1;var r=rn(),e=Object.create,t=(function(){function n(){}return function(a){if(!r(a))return{};if(e)return e(a);n.prototype=a;var i=new n;return n.prototype=void 0,i}})();return Hh=t,Hh}var Kh,O_;function qP(){if(O_)return Kh;O_=1;var r=kP(),e=Kl(),t=Hl();function n(a){return typeof a.constructor=="function"&&!t(a)?r(e(a)):{}}return Kh=n,Kh}var jh,k_;function k4(){if(k_)return jh;k_=1;var r=Co(),e=zn(),t="[object Map]";function n(a){return e(a)&&r(a)==t}return jh=n,jh}var Yh,q_;function q4(){if(q_)return Yh;q_=1;var r=k4(),e=Ul(),t=x0(),n=t&&t.isMap,a=n?e(n):r;return Yh=a,Yh}var Zh,N_;function N4(){if(N_)return Zh;N_=1;var r=Co(),e=zn(),t="[object Set]";function n(a){return e(a)&&r(a)==t}return Zh=n,Zh}var Xh,F_;function F4(){if(F_)return Xh;F_=1;var r=N4(),e=Ul(),t=x0(),n=t&&t.isSet,a=n?e(n):r;return Xh=a,Xh}var Qh,z_;function NP(){if(z_)return Qh;z_=1;var r=$l(),e=b0(),t=Gl(),n=x4(),a=_4(),i=TP(),o=RP(),s=S4(),u=T4(),l=BP(),f=R4(),d=Co(),h=D4(),g=O4(),p=qP(),x=Xr(),b=Eo(),w=q4(),y=rn(),E=F4(),C=Va(),S=xi(),R=1,_=2,A=4,P="[object Arguments]",I="[object Array]",D="[object Boolean]",L="[object Date]",M="[object Error]",q="[object Function]",N="[object GeneratorFunction]",W="[object Map]",V="[object Number]",$="[object Object]",Z="[object RegExp]",ee="[object Set]",K="[object String]",j="[object Symbol]",fe="[object WeakMap]",G="[object ArrayBuffer]",z="[object DataView]",Y="[object Float32Array]",te="[object Float64Array]",ue="[object Int8Array]",oe="[object Int16Array]",X="[object Int32Array]",Q="[object Uint8Array]",ie="[object Uint8ClampedArray]",de="[object Uint16Array]",we="[object Uint32Array]",Ae={};Ae[P]=Ae[I]=Ae[G]=Ae[z]=Ae[D]=Ae[L]=Ae[Y]=Ae[te]=Ae[ue]=Ae[oe]=Ae[X]=Ae[W]=Ae[V]=Ae[$]=Ae[Z]=Ae[ee]=Ae[K]=Ae[j]=Ae[Q]=Ae[ie]=Ae[de]=Ae[we]=!0,Ae[M]=Ae[q]=Ae[fe]=!1;function ve(le,Me,Se,Ee,re,ce){var _e,me=Me&R,Te=Me&_,De=Me&A;if(Se&&(_e=re?Se(le,Ee,re,ce):Se(le)),_e!==void 0)return _e;if(!y(le))return le;var Ne=x(le);if(Ne){if(_e=h(le),!me)return o(le,_e)}else{var ze=d(le),$e=ze==q||ze==N;if(b(le))return i(le,me);if(ze==$||ze==P||$e&&!re){if(_e=Te||$e?{}:p(le),!me)return Te?u(le,a(_e,le)):s(le,n(_e,le))}else{if(!Ae[ze])return re?le:{};_e=g(le,ze,me)}}ce||(ce=new r);var ke=ce.get(le);if(ke)return ke;ce.set(le,_e),E(le)?le.forEach(function(O){_e.add(ve(O,Me,Se,O,le,ce))}):w(le)&&le.forEach(function(O,ne){_e.set(ne,ve(O,Me,Se,ne,le,ce))});var Oe=De?Te?f:l:Te?S:C,ye=Ne?void 0:Oe(le);return e(ye||le,function(O,ne){ye&&(ne=O,O=le[ne]),t(_e,ne,ve(O,Me,Se,ne,le,ce))}),_e}return Qh=ve,Qh}var Jh,$_;function z4(){if($_)return Jh;$_=1;var r=NP(),e=4;function t(n){return r(n,e)}return Jh=t,Jh}var eg,V_;function T0(){if(V_)return eg;V_=1;function r(e){return function(){return e}}return eg=r,eg}var rg,G_;function $4(){if(G_)return rg;G_=1;function r(e){return function(t,n,a){for(var i=-1,o=Object(t),s=a(t),u=s.length;u--;){var l=s[e?u:++i];if(n(o[l],l,o)===!1)break}return t}}return rg=r,rg}var tg,W_;function R0(){if(W_)return tg;W_=1;var r=$4(),e=r();return tg=e,tg}var ng,U_;function A0(){if(U_)return ng;U_=1;var r=R0(),e=Va();function t(n,a){return n&&r(n,a,e)}return ng=t,ng}var ag,H_;function V4(){if(H_)return ag;H_=1;var r=oa();function e(t,n){return function(a,i){if(a==null)return a;if(!r(a))return t(a,i);for(var o=a.length,s=n?o:-1,u=Object(a);(n?s--:++s<o)&&i(u[s],s,u)!==!1;);return a}}return ag=e,ag}var ig,K_;function jl(){if(K_)return ig;K_=1;var r=A0(),e=V4(),t=e(r);return ig=t,ig}var og,j_;function Ei(){if(j_)return og;j_=1;function r(e){return e}return og=r,og}var sg,Y_;function FP(){if(Y_)return sg;Y_=1;var r=Ei();function e(t){return typeof t=="function"?t:r}return sg=e,sg}var ug,Z_;function zP(){if(Z_)return ug;Z_=1;var r=b0(),e=jl(),t=FP(),n=Xr();function a(i,o){var s=n(i)?r:e;return s(i,t(o))}return ug=a,ug}var lg,X_;function $P(){return X_||(X_=1,lg=zP()),lg}var fg,Q_;function G4(){if(Q_)return fg;Q_=1;var r=jl();function e(t,n){var a=[];return r(t,function(i,o,s){n(i,o,s)&&a.push(i)}),a}return fg=e,fg}var cg,J_;function W4(){if(J_)return cg;J_=1;var r="__lodash_hash_undefined__";function e(t){return this.__data__.set(t,r),this}return cg=e,cg}var dg,eS;function U4(){if(eS)return dg;eS=1;function r(e){return this.__data__.has(e)}return dg=r,dg}var vg,rS;function VP(){if(rS)return vg;rS=1;var r=m0(),e=W4(),t=U4();function n(a){var i=-1,o=a==null?0:a.length;for(this.__data__=new r;++i<o;)this.add(a[i])}return n.prototype.add=n.prototype.push=e,n.prototype.has=t,vg=n,vg}var hg,tS;function H4(){if(tS)return hg;tS=1;function r(e,t){for(var n=-1,a=e==null?0:e.length;++n<a;)if(t(e[n],n,e))return!0;return!1}return hg=r,hg}var gg,nS;function GP(){if(nS)return gg;nS=1;function r(e,t){return e.has(t)}return gg=r,gg}var pg,aS;function WP(){if(aS)return pg;aS=1;var r=VP(),e=H4(),t=GP(),n=1,a=2;function i(o,s,u,l,f,d){var h=u&n,g=o.length,p=s.length;if(g!=p&&!(h&&p>g))return!1;var x=d.get(o),b=d.get(s);if(x&&b)return x==s&&b==o;var w=-1,y=!0,E=u&a?new r:void 0;for(d.set(o,s),d.set(s,o);++w<g;){var C=o[w],S=s[w];if(l)var R=h?l(S,C,w,s,o,d):l(C,S,w,o,s,d);if(R!==void 0){if(R)continue;y=!1;break}if(E){if(!e(s,function(_,A){if(!t(E,A)&&(C===_||f(C,_,u,l,d)))return E.push(A)})){y=!1;break}}else if(!(C===S||f(C,S,u,l,d))){y=!1;break}}return d.delete(o),d.delete(s),y}return pg=i,pg}var yg,iS;function K4(){if(iS)return yg;iS=1;function r(e){var t=-1,n=Array(e.size);return e.forEach(function(a,i){n[++t]=[i,a]}),n}return yg=r,yg}var mg,oS;function P0(){if(oS)return mg;oS=1;function r(e){var t=-1,n=Array(e.size);return e.forEach(function(a){n[++t]=a}),n}return mg=r,mg}var bg,sS;function j4(){if(sS)return bg;sS=1;var r=vo(),e=LP(),t=xo(),n=WP(),a=K4(),i=P0(),o=1,s=2,u="[object Boolean]",l="[object Date]",f="[object Error]",d="[object Map]",h="[object Number]",g="[object RegExp]",p="[object Set]",x="[object String]",b="[object Symbol]",w="[object ArrayBuffer]",y="[object DataView]",E=r?r.prototype:void 0,C=E?E.valueOf:void 0;function S(R,_,A,P,I,D,L){switch(A){case y:if(R.byteLength!=_.byteLength||R.byteOffset!=_.byteOffset)return!1;R=R.buffer,_=_.buffer;case w:return!(R.byteLength!=_.byteLength||!D(new e(R),new e(_)));case u:case l:case h:return t(+R,+_);case f:return R.name==_.name&&R.message==_.message;case g:case x:return R==_+"";case d:var M=a;case p:var q=P&o;if(M||(M=i),R.size!=_.size&&!q)return!1;var N=L.get(R);if(N)return N==_;P|=s,L.set(R,_);var W=n(M(R),M(_),P,I,D,L);return L.delete(R),W;case b:if(C)return C.call(R)==C.call(_)}return!1}return bg=S,bg}var wg,uS;function Y4(){if(uS)return wg;uS=1;var r=BP(),e=1,t=Object.prototype,n=t.hasOwnProperty;function a(i,o,s,u,l,f){var d=s&e,h=r(i),g=h.length,p=r(o),x=p.length;if(g!=x&&!d)return!1;for(var b=g;b--;){var w=h[b];if(!(d?w in o:n.call(o,w)))return!1}var y=f.get(i),E=f.get(o);if(y&&E)return y==o&&E==i;var C=!0;f.set(i,o),f.set(o,i);for(var S=d;++b<g;){w=h[b];var R=i[w],_=o[w];if(u)var A=d?u(_,R,w,o,i,f):u(R,_,w,i,o,f);if(!(A===void 0?R===_||l(R,_,s,u,f):A)){C=!1;break}S||(S=w=="constructor")}if(C&&!S){var P=i.constructor,I=o.constructor;P!=I&&"constructor"in i&&"constructor"in o&&!(typeof P=="function"&&P instanceof P&&typeof I=="function"&&I instanceof I)&&(C=!1)}return f.delete(i),f.delete(o),C}return wg=a,wg}var xg,lS;function Z4(){if(lS)return xg;lS=1;var r=$l(),e=WP(),t=j4(),n=Y4(),a=Co(),i=Xr(),o=Eo(),s=Os(),u=1,l="[object Arguments]",f="[object Array]",d="[object Object]",h=Object.prototype,g=h.hasOwnProperty;function p(x,b,w,y,E,C){var S=i(x),R=i(b),_=S?f:a(x),A=R?f:a(b);_=_==l?d:_,A=A==l?d:A;var P=_==d,I=A==d,D=_==A;if(D&&o(x)){if(!o(b))return!1;S=!0,P=!1}if(D&&!P)return C||(C=new r),S||s(x)?e(x,b,w,y,E,C):t(x,b,_,w,y,E,C);if(!(w&u)){var L=P&&g.call(x,"__wrapped__"),M=I&&g.call(b,"__wrapped__");if(L||M){var q=L?x.value():x,N=M?b.value():b;return C||(C=new r),E(q,N,w,y,C)}}return D?(C||(C=new r),n(x,b,w,y,E,C)):!1}return xg=p,xg}var Eg,fS;function UP(){if(fS)return Eg;fS=1;var r=Z4(),e=zn();function t(n,a,i,o,s){return n===a?!0:n==null||a==null||!e(n)&&!e(a)?n!==n&&a!==a:r(n,a,i,o,t,s)}return Eg=t,Eg}var Cg,cS;function X4(){if(cS)return Cg;cS=1;var r=$l(),e=UP(),t=1,n=2;function a(i,o,s,u){var l=s.length,f=l,d=!u;if(i==null)return!f;for(i=Object(i);l--;){var h=s[l];if(d&&h[2]?h[1]!==i[h[0]]:!(h[0]in i))return!1}for(;++l<f;){h=s[l];var g=h[0],p=i[g],x=h[1];if(d&&h[2]){if(p===void 0&&!(g in i))return!1}else{var b=new r;if(u)var w=u(p,x,g,i,o,b);if(!(w===void 0?e(x,p,t|n,u,b):w))return!1}}return!0}return Cg=a,Cg}var _g,dS;function HP(){if(dS)return _g;dS=1;var r=rn();function e(t){return t===t&&!r(t)}return _g=e,_g}var Sg,vS;function Q4(){if(vS)return Sg;vS=1;var r=HP(),e=Va();function t(n){for(var a=e(n),i=a.length;i--;){var o=a[i],s=n[o];a[i]=[o,s,r(s)]}return a}return Sg=t,Sg}var Tg,hS;function KP(){if(hS)return Tg;hS=1;function r(e,t){return function(n){return n==null?!1:n[e]===t&&(t!==void 0||e in Object(n))}}return Tg=r,Tg}var Rg,gS;function J4(){if(gS)return Rg;gS=1;var r=X4(),e=Q4(),t=KP();function n(a){var i=e(a);return i.length==1&&i[0][2]?t(i[0][0],i[0][1]):function(o){return o===a||r(o,a,i)}}return Rg=n,Rg}var Ag,pS;function I0(){if(pS)return Ag;pS=1;var r=Xr(),e=ho(),t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function a(i,o){if(r(i))return!1;var s=typeof i;return s=="number"||s=="symbol"||s=="boolean"||i==null||e(i)?!0:n.test(i)||!t.test(i)||o!=null&&i in Object(o)}return Ag=a,Ag}var Pg,yS;function eG(){if(yS)return Pg;yS=1;var r=m0(),e="Expected a function";function t(n,a){if(typeof n!="function"||a!=null&&typeof a!="function")throw new TypeError(e);var i=function(){var o=arguments,s=a?a.apply(this,o):o[0],u=i.cache;if(u.has(s))return u.get(s);var l=n.apply(this,o);return i.cache=u.set(s,l)||u,l};return i.cache=new(t.Cache||r),i}return t.Cache=r,Pg=t,Pg}var Ig,mS;function rG(){if(mS)return Ig;mS=1;var r=eG(),e=500;function t(n){var a=r(n,function(o){return i.size===e&&i.clear(),o}),i=a.cache;return a}return Ig=t,Ig}var Dg,bS;function tG(){if(bS)return Dg;bS=1;var r=rG(),e=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,n=r(function(a){var i=[];return a.charCodeAt(0)===46&&i.push(""),a.replace(e,function(o,s,u,l){i.push(u?l.replace(t,"$1"):s||o)}),i});return Dg=n,Dg}var Bg,wS;function Yl(){if(wS)return Bg;wS=1;function r(e,t){for(var n=-1,a=e==null?0:e.length,i=Array(a);++n<a;)i[n]=t(e[n],n,e);return i}return Bg=r,Bg}var Mg,xS;function nG(){if(xS)return Mg;xS=1;var r=vo(),e=Yl(),t=Xr(),n=ho(),a=r?r.prototype:void 0,i=a?a.toString:void 0;function o(s){if(typeof s=="string")return s;if(t(s))return e(s,o)+"";if(n(s))return i?i.call(s):"";var u=s+"";return u=="0"&&1/s==-1/0?"-0":u}return Mg=o,Mg}var Lg,ES;function jP(){if(ES)return Lg;ES=1;var r=nG();function e(t){return t==null?"":r(t)}return Lg=e,Lg}var Og,CS;function Zl(){if(CS)return Og;CS=1;var r=Xr(),e=I0(),t=tG(),n=jP();function a(i,o){return r(i)?i:e(i,o)?[i]:t(n(i))}return Og=a,Og}var kg,_S;function ks(){if(_S)return kg;_S=1;var r=ho();function e(t){if(typeof t=="string"||r(t))return t;var n=t+"";return n=="0"&&1/t==-1/0?"-0":n}return kg=e,kg}var qg,SS;function Xl(){if(SS)return qg;SS=1;var r=Zl(),e=ks();function t(n,a){a=r(a,n);for(var i=0,o=a.length;n!=null&&i<o;)n=n[e(a[i++])];return i&&i==o?n:void 0}return qg=t,qg}var Ng,TS;function aG(){if(TS)return Ng;TS=1;var r=Xl();function e(t,n,a){var i=t==null?void 0:r(t,n);return i===void 0?a:i}return Ng=e,Ng}var Fg,RS;function iG(){if(RS)return Fg;RS=1;function r(e,t){return e!=null&&t in Object(e)}return Fg=r,Fg}var zg,AS;function YP(){if(AS)return zg;AS=1;var r=Zl(),e=Ls(),t=Xr(),n=Wl(),a=w0(),i=ks();function o(s,u,l){u=r(u,s);for(var f=-1,d=u.length,h=!1;++f<d;){var g=i(u[f]);if(!(h=s!=null&&l(s,g)))break;s=s[g]}return h||++f!=d?h:(d=s==null?0:s.length,!!d&&a(d)&&n(g,d)&&(t(s)||e(s)))}return zg=o,zg}var $g,PS;function ZP(){if(PS)return $g;PS=1;var r=iG(),e=YP();function t(n,a){return n!=null&&e(n,a,r)}return $g=t,$g}var Vg,IS;function oG(){if(IS)return Vg;IS=1;var r=UP(),e=aG(),t=ZP(),n=I0(),a=HP(),i=KP(),o=ks(),s=1,u=2;function l(f,d){return n(f)&&a(d)?i(o(f),d):function(h){var g=e(h,f);return g===void 0&&g===d?t(h,f):r(d,g,s|u)}}return Vg=l,Vg}var Gg,DS;function XP(){if(DS)return Gg;DS=1;function r(e){return function(t){return t==null?void 0:t[e]}}return Gg=r,Gg}var Wg,BS;function sG(){if(BS)return Wg;BS=1;var r=Xl();function e(t){return function(n){return r(n,t)}}return Wg=e,Wg}var Ug,MS;function uG(){if(MS)return Ug;MS=1;var r=XP(),e=sG(),t=I0(),n=ks();function a(i){return t(i)?r(n(i)):e(i)}return Ug=a,Ug}var Hg,LS;function sa(){if(LS)return Hg;LS=1;var r=J4(),e=oG(),t=Ei(),n=Xr(),a=uG();function i(o){return typeof o=="function"?o:o==null?t:typeof o=="object"?n(o)?e(o[0],o[1]):r(o):a(o)}return Hg=i,Hg}var Kg,OS;function QP(){if(OS)return Kg;OS=1;var r=AP(),e=G4(),t=sa(),n=Xr();function a(i,o){var s=n(i)?r:e;return s(i,t(o,3))}return Kg=a,Kg}var jg,kS;function lG(){if(kS)return jg;kS=1;var r=Object.prototype,e=r.hasOwnProperty;function t(n,a){return n!=null&&e.call(n,a)}return jg=t,jg}var Yg,qS;function JP(){if(qS)return Yg;qS=1;var r=lG(),e=YP();function t(n,a){return n!=null&&e(n,a,r)}return Yg=t,Yg}var Zg,NS;function fG(){if(NS)return Zg;NS=1;var r=E0(),e=Co(),t=Ls(),n=Xr(),a=oa(),i=Eo(),o=Hl(),s=Os(),u="[object Map]",l="[object Set]",f=Object.prototype,d=f.hasOwnProperty;function h(g){if(g==null)return!0;if(a(g)&&(n(g)||typeof g=="string"||typeof g.splice=="function"||i(g)||s(g)||t(g)))return!g.length;var p=e(g);if(p==u||p==l)return!g.size;if(o(g))return!r(g).length;for(var x in g)if(d.call(g,x))return!1;return!0}return Zg=h,Zg}var Xg,FS;function eI(){if(FS)return Xg;FS=1;function r(e){return e===void 0}return Xg=r,Xg}var Qg,zS;function rI(){if(zS)return Qg;zS=1;var r=jl(),e=oa();function t(n,a){var i=-1,o=e(n)?Array(n.length):[];return r(n,function(s,u,l){o[++i]=a(s,u,l)}),o}return Qg=t,Qg}var Jg,$S;function tI(){if($S)return Jg;$S=1;var r=Yl(),e=sa(),t=rI(),n=Xr();function a(i,o){var s=n(i)?r:t;return s(i,e(o,3))}return Jg=a,Jg}var ep,VS;function cG(){if(VS)return ep;VS=1;function r(e,t,n,a){var i=-1,o=e==null?0:e.length;for(a&&o&&(n=e[++i]);++i<o;)n=t(n,e[i],i,e);return n}return ep=r,ep}var rp,GS;function dG(){if(GS)return rp;GS=1;function r(e,t,n,a,i){return i(e,function(o,s,u){n=a?(a=!1,o):t(n,o,s,u)}),n}return rp=r,rp}var tp,WS;function nI(){if(WS)return tp;WS=1;var r=cG(),e=jl(),t=sa(),n=dG(),a=Xr();function i(o,s,u){var l=a(o)?r:n,f=arguments.length<3;return l(o,t(s,4),u,f,e)}return tp=i,tp}var np,US;function vG(){if(US)return np;US=1;var r=yi(),e=Xr(),t=zn(),n="[object String]";function a(i){return typeof i=="string"||!e(i)&&t(i)&&r(i)==n}return np=a,np}var ap,HS;function hG(){if(HS)return ap;HS=1;var r=XP(),e=r("length");return ap=e,ap}var ip,KS;function gG(){if(KS)return ip;KS=1;var r="\\ud800-\\udfff",e="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",a=e+t+n,i="\\ufe0e\\ufe0f",o="\\u200d",s=RegExp("["+o+r+a+i+"]");function u(l){return s.test(l)}return ip=u,ip}var op,jS;function pG(){if(jS)return op;jS=1;var r="\\ud800-\\udfff",e="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",a=e+t+n,i="\\ufe0e\\ufe0f",o="["+r+"]",s="["+a+"]",u="\\ud83c[\\udffb-\\udfff]",l="(?:"+s+"|"+u+")",f="[^"+r+"]",d="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",g="\\u200d",p=l+"?",x="["+i+"]?",b="(?:"+g+"(?:"+[f,d,h].join("|")+")"+x+p+")*",w=x+p+b,y="(?:"+[f+s+"?",s,d,h,o].join("|")+")",E=RegExp(u+"(?="+u+")|"+y+w,"g");function C(S){for(var R=E.lastIndex=0;E.test(S);)++R;return R}return op=C,op}var sp,YS;function yG(){if(YS)return sp;YS=1;var r=hG(),e=gG(),t=pG();function n(a){return e(a)?t(a):r(a)}return sp=n,sp}var up,ZS;function mG(){if(ZS)return up;ZS=1;var r=E0(),e=Co(),t=oa(),n=vG(),a=yG(),i="[object Map]",o="[object Set]";function s(u){if(u==null)return 0;if(t(u))return n(u)?a(u):u.length;var l=e(u);return l==i||l==o?u.size:r(u).length}return up=s,up}var lp,XS;function bG(){if(XS)return lp;XS=1;var r=b0(),e=kP(),t=A0(),n=sa(),a=Kl(),i=Xr(),o=Eo(),s=Bs(),u=rn(),l=Os();function f(d,h,g){var p=i(d),x=p||o(d)||l(d);if(h=n(h,4),g==null){var b=d&&d.constructor;x?g=p?new b:[]:u(d)?g=s(b)?e(a(d)):{}:g={}}return(x?r:t)(d,function(w,y,E){return h(g,w,y,E)}),g}return lp=f,lp}var fp,QS;function wG(){if(QS)return fp;QS=1;var r=vo(),e=Ls(),t=Xr(),n=r?r.isConcatSpreadable:void 0;function a(i){return t(i)||e(i)||!!(n&&i&&i[n])}return fp=a,fp}var cp,JS;function D0(){if(JS)return cp;JS=1;var r=_0(),e=wG();function t(n,a,i,o,s){var u=-1,l=n.length;for(i||(i=e),s||(s=[]);++u<l;){var f=n[u];a>0&&i(f)?a>1?t(f,a-1,i,o,s):r(s,f):o||(s[s.length]=f)}return s}return cp=t,cp}var dp,eT;function xG(){if(eT)return dp;eT=1;function r(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}return dp=r,dp}var vp,rT;function aI(){if(rT)return vp;rT=1;var r=xG(),e=Math.max;function t(n,a,i){return a=e(a===void 0?n.length-1:a,0),function(){for(var o=arguments,s=-1,u=e(o.length-a,0),l=Array(u);++s<u;)l[s]=o[a+s];s=-1;for(var f=Array(a+1);++s<a;)f[s]=o[s];return f[a]=i(l),r(n,this,f)}}return vp=t,vp}var hp,tT;function EG(){if(tT)return hp;tT=1;var r=T0(),e=CP(),t=Ei(),n=e?function(a,i){return e(a,"toString",{configurable:!0,enumerable:!1,value:r(i),writable:!0})}:t;return hp=n,hp}var gp,nT;function CG(){if(nT)return gp;nT=1;var r=800,e=16,t=Date.now;function n(a){var i=0,o=0;return function(){var s=t(),u=e-(s-o);if(o=s,u>0){if(++i>=r)return arguments[0]}else i=0;return a.apply(void 0,arguments)}}return gp=n,gp}var pp,aT;function iI(){if(aT)return pp;aT=1;var r=EG(),e=CG(),t=e(r);return pp=t,pp}var yp,iT;function Ql(){if(iT)return yp;iT=1;var r=Ei(),e=aI(),t=iI();function n(a,i){return t(e(a,i,r),a+"")}return yp=n,yp}var mp,oT;function oI(){if(oT)return mp;oT=1;function r(e,t,n,a){for(var i=e.length,o=n+(a?1:-1);a?o--:++o<i;)if(t(e[o],o,e))return o;return-1}return mp=r,mp}var bp,sT;function _G(){if(sT)return bp;sT=1;function r(e){return e!==e}return bp=r,bp}var wp,uT;function SG(){if(uT)return wp;uT=1;function r(e,t,n){for(var a=n-1,i=e.length;++a<i;)if(e[a]===t)return a;return-1}return wp=r,wp}var xp,lT;function TG(){if(lT)return xp;lT=1;var r=oI(),e=_G(),t=SG();function n(a,i,o){return i===i?t(a,i,o):r(a,e,o)}return xp=n,xp}var Ep,fT;function RG(){if(fT)return Ep;fT=1;var r=TG();function e(t,n){var a=t==null?0:t.length;return!!a&&r(t,n,0)>-1}return Ep=e,Ep}var Cp,cT;function AG(){if(cT)return Cp;cT=1;function r(e,t,n){for(var a=-1,i=e==null?0:e.length;++a<i;)if(n(t,e[a]))return!0;return!1}return Cp=r,Cp}var _p,dT;function PG(){if(dT)return _p;dT=1;function r(){}return _p=r,_p}var Sp,vT;function IG(){if(vT)return Sp;vT=1;var r=MP(),e=PG(),t=P0(),n=1/0,a=r&&1/t(new r([,-0]))[1]==n?function(i){return new r(i)}:e;return Sp=a,Sp}var Tp,hT;function DG(){if(hT)return Tp;hT=1;var r=VP(),e=RG(),t=AG(),n=GP(),a=IG(),i=P0(),o=200;function s(u,l,f){var d=-1,h=e,g=u.length,p=!0,x=[],b=x;if(f)p=!1,h=t;else if(g>=o){var w=l?null:a(u);if(w)return i(w);p=!1,h=n,b=new r}else b=l?[]:x;e:for(;++d<g;){var y=u[d],E=l?l(y):y;if(y=f||y!==0?y:0,p&&E===E){for(var C=b.length;C--;)if(b[C]===E)continue e;l&&b.push(E),x.push(y)}else h(b,E,f)||(b!==x&&b.push(E),x.push(y))}return x}return Tp=s,Tp}var Rp,gT;function sI(){if(gT)return Rp;gT=1;var r=oa(),e=zn();function t(n){return e(n)&&r(n)}return Rp=t,Rp}var Ap,pT;function BG(){if(pT)return Ap;pT=1;var r=D0(),e=Ql(),t=DG(),n=sI(),a=e(function(i){return t(r(i,1,n,!0))});return Ap=a,Ap}var Pp,yT;function MG(){if(yT)return Pp;yT=1;var r=Yl();function e(t,n){return r(n,function(a){return t[a]})}return Pp=e,Pp}var Ip,mT;function uI(){if(mT)return Ip;mT=1;var r=MG(),e=Va();function t(n){return n==null?[]:r(n,e(n))}return Ip=t,Ip}var Dp,bT;function gn(){if(bT)return Dp;bT=1;var r;if(typeof p0=="function")try{r={clone:z4(),constant:T0(),each:$P(),filter:QP(),has:JP(),isArray:Xr(),isEmpty:fG(),isFunction:Bs(),isUndefined:eI(),keys:Va(),map:tI(),reduce:nI(),size:mG(),transform:bG(),union:BG(),values:uI()}}catch{}return r||(r=window._),Dp=r,Dp}var Bp,wT;function B0(){if(wT)return Bp;wT=1;var r=gn();Bp=a;var e="\0",t="\0",n="";function a(f){this._isDirected=r.has(f,"directed")?f.directed:!0,this._isMultigraph=r.has(f,"multigraph")?f.multigraph:!1,this._isCompound=r.has(f,"compound")?f.compound:!1,this._label=void 0,this._defaultNodeLabelFn=r.constant(void 0),this._defaultEdgeLabelFn=r.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[t]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}a.prototype._nodeCount=0,a.prototype._edgeCount=0,a.prototype.isDirected=function(){return this._isDirected},a.prototype.isMultigraph=function(){return this._isMultigraph},a.prototype.isCompound=function(){return this._isCompound},a.prototype.setGraph=function(f){return this._label=f,this},a.prototype.graph=function(){return this._label},a.prototype.setDefaultNodeLabel=function(f){return r.isFunction(f)||(f=r.constant(f)),this._defaultNodeLabelFn=f,this},a.prototype.nodeCount=function(){return this._nodeCount},a.prototype.nodes=function(){return r.keys(this._nodes)},a.prototype.sources=function(){var f=this;return r.filter(this.nodes(),function(d){return r.isEmpty(f._in[d])})},a.prototype.sinks=function(){var f=this;return r.filter(this.nodes(),function(d){return r.isEmpty(f._out[d])})},a.prototype.setNodes=function(f,d){var h=arguments,g=this;return r.each(f,function(p){h.length>1?g.setNode(p,d):g.setNode(p)}),this},a.prototype.setNode=function(f,d){return r.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=d),this):(this._nodes[f]=arguments.length>1?d:this._defaultNodeLabelFn(f),this._isCompound&&(this._parent[f]=t,this._children[f]={},this._children[t][f]=!0),this._in[f]={},this._preds[f]={},this._out[f]={},this._sucs[f]={},++this._nodeCount,this)},a.prototype.node=function(f){return this._nodes[f]},a.prototype.hasNode=function(f){return r.has(this._nodes,f)},a.prototype.removeNode=function(f){var d=this;if(r.has(this._nodes,f)){var h=function(g){d.removeEdge(d._edgeObjs[g])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],r.each(this.children(f),function(g){d.setParent(g)}),delete this._children[f]),r.each(r.keys(this._in[f]),h),delete this._in[f],delete this._preds[f],r.each(r.keys(this._out[f]),h),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},a.prototype.setParent=function(f,d){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(r.isUndefined(d))d=t;else{d+="";for(var h=d;!r.isUndefined(h);h=this.parent(h))if(h===f)throw new Error("Setting "+d+" as parent of "+f+" would create a cycle");this.setNode(d)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=d,this._children[d][f]=!0,this},a.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},a.prototype.parent=function(f){if(this._isCompound){var d=this._parent[f];if(d!==t)return d}},a.prototype.children=function(f){if(r.isUndefined(f)&&(f=t),this._isCompound){var d=this._children[f];if(d)return r.keys(d)}else{if(f===t)return this.nodes();if(this.hasNode(f))return[]}},a.prototype.predecessors=function(f){var d=this._preds[f];if(d)return r.keys(d)},a.prototype.successors=function(f){var d=this._sucs[f];if(d)return r.keys(d)},a.prototype.neighbors=function(f){var d=this.predecessors(f);if(d)return r.union(d,this.successors(f))},a.prototype.isLeaf=function(f){var d;return this.isDirected()?d=this.successors(f):d=this.neighbors(f),d.length===0},a.prototype.filterNodes=function(f){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var h=this;r.each(this._nodes,function(x,b){f(b)&&d.setNode(b,x)}),r.each(this._edgeObjs,function(x){d.hasNode(x.v)&&d.hasNode(x.w)&&d.setEdge(x,h.edge(x))});var g={};function p(x){var b=h.parent(x);return b===void 0||d.hasNode(b)?(g[x]=b,b):b in g?g[b]:p(b)}return this._isCompound&&r.each(d.nodes(),function(x){d.setParent(x,p(x))}),d},a.prototype.setDefaultEdgeLabel=function(f){return r.isFunction(f)||(f=r.constant(f)),this._defaultEdgeLabelFn=f,this},a.prototype.edgeCount=function(){return this._edgeCount},a.prototype.edges=function(){return r.values(this._edgeObjs)},a.prototype.setPath=function(f,d){var h=this,g=arguments;return r.reduce(f,function(p,x){return g.length>1?h.setEdge(p,x,d):h.setEdge(p,x),x}),this},a.prototype.setEdge=function(){var f,d,h,g,p=!1,x=arguments[0];typeof x=="object"&&x!==null&&"v"in x?(f=x.v,d=x.w,h=x.name,arguments.length===2&&(g=arguments[1],p=!0)):(f=x,d=arguments[1],h=arguments[3],arguments.length>2&&(g=arguments[2],p=!0)),f=""+f,d=""+d,r.isUndefined(h)||(h=""+h);var b=s(this._isDirected,f,d,h);if(r.has(this._edgeLabels,b))return p&&(this._edgeLabels[b]=g),this;if(!r.isUndefined(h)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(d),this._edgeLabels[b]=p?g:this._defaultEdgeLabelFn(f,d,h);var w=u(this._isDirected,f,d,h);return f=w.v,d=w.w,Object.freeze(w),this._edgeObjs[b]=w,i(this._preds[d],f),i(this._sucs[f],d),this._in[d][b]=w,this._out[f][b]=w,this._edgeCount++,this},a.prototype.edge=function(f,d,h){var g=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,f,d,h);return this._edgeLabels[g]},a.prototype.hasEdge=function(f,d,h){var g=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,f,d,h);return r.has(this._edgeLabels,g)},a.prototype.removeEdge=function(f,d,h){var g=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,f,d,h),p=this._edgeObjs[g];return p&&(f=p.v,d=p.w,delete this._edgeLabels[g],delete this._edgeObjs[g],o(this._preds[d],f),o(this._sucs[f],d),delete this._in[d][g],delete this._out[f][g],this._edgeCount--),this},a.prototype.inEdges=function(f,d){var h=this._in[f];if(h){var g=r.values(h);return d?r.filter(g,function(p){return p.v===d}):g}},a.prototype.outEdges=function(f,d){var h=this._out[f];if(h){var g=r.values(h);return d?r.filter(g,function(p){return p.w===d}):g}},a.prototype.nodeEdges=function(f,d){var h=this.inEdges(f,d);if(h)return h.concat(this.outEdges(f,d))};function i(f,d){f[d]?f[d]++:f[d]=1}function o(f,d){--f[d]||delete f[d]}function s(f,d,h,g){var p=""+d,x=""+h;if(!f&&p>x){var b=p;p=x,x=b}return p+n+x+n+(r.isUndefined(g)?e:g)}function u(f,d,h,g){var p=""+d,x=""+h;if(!f&&p>x){var b=p;p=x,x=b}var w={v:p,w:x};return g&&(w.name=g),w}function l(f,d){return s(f,d.v,d.w,d.name)}return Bp}var Mp,xT;function LG(){return xT||(xT=1,Mp="2.1.8"),Mp}var Lp,ET;function OG(){return ET||(ET=1,Lp={Graph:B0(),version:LG()}),Lp}var Op,CT;function kG(){if(CT)return Op;CT=1;var r=gn(),e=B0();Op={write:t,read:i};function t(o){var s={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:n(o),edges:a(o)};return r.isUndefined(o.graph())||(s.value=r.clone(o.graph())),s}function n(o){return r.map(o.nodes(),function(s){var u=o.node(s),l=o.parent(s),f={v:s};return r.isUndefined(u)||(f.value=u),r.isUndefined(l)||(f.parent=l),f})}function a(o){return r.map(o.edges(),function(s){var u=o.edge(s),l={v:s.v,w:s.w};return r.isUndefined(s.name)||(l.name=s.name),r.isUndefined(u)||(l.value=u),l})}function i(o){var s=new e(o.options).setGraph(o.value);return r.each(o.nodes,function(u){s.setNode(u.v,u.value),u.parent&&s.setParent(u.v,u.parent)}),r.each(o.edges,function(u){s.setEdge({v:u.v,w:u.w,name:u.name},u.value)}),s}return Op}var kp,_T;function qG(){if(_T)return kp;_T=1;var r=gn();kp=e;function e(t){var n={},a=[],i;function o(s){r.has(n,s)||(n[s]=!0,i.push(s),r.each(t.successors(s),o),r.each(t.predecessors(s),o))}return r.each(t.nodes(),function(s){i=[],o(s),i.length&&a.push(i)}),a}return kp}var qp,ST;function lI(){if(ST)return qp;ST=1;var r=gn();qp=e;function e(){this._arr=[],this._keyIndices={}}return 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(t){return r.has(this._keyIndices,t)},e.prototype.priority=function(t){var n=this._keyIndices[t];if(n!==void 0)return this._arr[n].priority},e.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},e.prototype.add=function(t,n){var a=this._keyIndices;if(t=String(t),!r.has(a,t)){var i=this._arr,o=i.length;return a[t]=o,i.push({key:t,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,n){var a=this._keyIndices[t];if(n>this._arr[a].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[a].priority+" New: "+n);this._arr[a].priority=n,this._decrease(a)},e.prototype._heapify=function(t){var n=this._arr,a=2*t,i=a+1,o=t;a<n.length&&(o=n[a].priority<n[o].priority?a:o,i<n.length&&(o=n[i].priority<n[o].priority?i:o),o!==t&&(this._swap(t,o),this._heapify(o)))},e.prototype._decrease=function(t){for(var n=this._arr,a=n[t].priority,i;t!==0&&(i=t>>1,!(n[i].priority<a));)this._swap(t,i),t=i},e.prototype._swap=function(t,n){var a=this._arr,i=this._keyIndices,o=a[t],s=a[n];a[t]=s,a[n]=o,i[s.key]=t,i[o.key]=n},qp}var Np,TT;function fI(){if(TT)return Np;TT=1;var r=gn(),e=lI();Np=n;var t=r.constant(1);function n(i,o,s,u){return a(i,String(o),s||t,u||function(l){return i.outEdges(l)})}function a(i,o,s,u){var l={},f=new e,d,h,g=function(p){var x=p.v!==d?p.v:p.w,b=l[x],w=s(p),y=h.distance+w;if(w<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+p+" Weight: "+w);y<b.distance&&(b.distance=y,b.predecessor=d,f.decrease(x,y))};for(i.nodes().forEach(function(p){var x=p===o?0:Number.POSITIVE_INFINITY;l[p]={distance:x},f.add(p,x)});f.size()>0&&(d=f.removeMin(),h=l[d],h.distance!==Number.POSITIVE_INFINITY);)u(d).forEach(g);return l}return Np}var Fp,RT;function NG(){if(RT)return Fp;RT=1;var r=fI(),e=gn();Fp=t;function t(n,a,i){return e.transform(n.nodes(),function(o,s){o[s]=r(n,s,a,i)},{})}return Fp}var zp,AT;function cI(){if(AT)return zp;AT=1;var r=gn();zp=e;function e(t){var n=0,a=[],i={},o=[];function s(u){var l=i[u]={onStack:!0,lowlink:n,index:n++};if(a.push(u),t.successors(u).forEach(function(h){r.has(i,h)?i[h].onStack&&(l.lowlink=Math.min(l.lowlink,i[h].index)):(s(h),l.lowlink=Math.min(l.lowlink,i[h].lowlink))}),l.lowlink===l.index){var f=[],d;do d=a.pop(),i[d].onStack=!1,f.push(d);while(u!==d);o.push(f)}}return t.nodes().forEach(function(u){r.has(i,u)||s(u)}),o}return zp}var $p,PT;function FG(){if(PT)return $p;PT=1;var r=gn(),e=cI();$p=t;function t(n){return r.filter(e(n),function(a){return a.length>1||a.length===1&&n.hasEdge(a[0],a[0])})}return $p}var Vp,IT;function zG(){if(IT)return Vp;IT=1;var r=gn();Vp=t;var e=r.constant(1);function t(a,i,o){return n(a,i||e,o||function(s){return a.outEdges(s)})}function n(a,i,o){var s={},u=a.nodes();return u.forEach(function(l){s[l]={},s[l][l]={distance:0},u.forEach(function(f){l!==f&&(s[l][f]={distance:Number.POSITIVE_INFINITY})}),o(l).forEach(function(f){var d=f.v===l?f.w:f.v,h=i(f);s[l][d]={distance:h,predecessor:l}})}),u.forEach(function(l){var f=s[l];u.forEach(function(d){var h=s[d];u.forEach(function(g){var p=h[l],x=f[g],b=h[g],w=p.distance+x.distance;w<b.distance&&(b.distance=w,b.predecessor=x.predecessor)})})}),s}return Vp}var Gp,DT;function dI(){if(DT)return Gp;DT=1;var r=gn();Gp=e,e.CycleException=t;function e(n){var a={},i={},o=[];function s(u){if(r.has(i,u))throw new t;r.has(a,u)||(i[u]=!0,a[u]=!0,r.each(n.predecessors(u),s),delete i[u],o.push(u))}if(r.each(n.sinks(),s),r.size(a)!==n.nodeCount())throw new t;return o}function t(){}return t.prototype=new Error,Gp}var Wp,BT;function $G(){if(BT)return Wp;BT=1;var r=dI();Wp=e;function e(t){try{r(t)}catch(n){if(n instanceof r.CycleException)return!1;throw n}return!0}return Wp}var Up,MT;function vI(){if(MT)return Up;MT=1;var r=gn();Up=e;function e(n,a,i){r.isArray(a)||(a=[a]);var o=(n.isDirected()?n.successors:n.neighbors).bind(n),s=[],u={};return r.each(a,function(l){if(!n.hasNode(l))throw new Error("Graph does not have node: "+l);t(n,l,i==="post",u,o,s)}),s}function t(n,a,i,o,s,u){r.has(o,a)||(o[a]=!0,i||u.push(a),r.each(s(a),function(l){t(n,l,i,o,s,u)}),i&&u.push(a))}return Up}var Hp,LT;function VG(){if(LT)return Hp;LT=1;var r=vI();Hp=e;function e(t,n){return r(t,n,"post")}return Hp}var Kp,OT;function GG(){if(OT)return Kp;OT=1;var r=vI();Kp=e;function e(t,n){return r(t,n,"pre")}return Kp}var jp,kT;function WG(){if(kT)return jp;kT=1;var r=gn(),e=B0(),t=lI();jp=n;function n(a,i){var o=new e,s={},u=new t,l;function f(h){var g=h.v===l?h.w:h.v,p=u.priority(g);if(p!==void 0){var x=i(h);x<p&&(s[g]=l,u.decrease(g,x))}}if(a.nodeCount()===0)return o;r.each(a.nodes(),function(h){u.add(h,Number.POSITIVE_INFINITY),o.setNode(h)}),u.decrease(a.nodes()[0],0);for(var d=!1;u.size()>0;){if(l=u.removeMin(),r.has(s,l))o.setEdge(l,s[l]);else{if(d)throw new Error("Input graph is not connected: "+a);d=!0}a.nodeEdges(l).forEach(f)}return o}return jp}var Yp,qT;function UG(){return qT||(qT=1,Yp={components:qG(),dijkstra:fI(),dijkstraAll:NG(),findCycles:FG(),floydWarshall:zG(),isAcyclic:$G(),postorder:VG(),preorder:GG(),prim:WG(),tarjan:cI(),topsort:dI()}),Yp}var Zp,NT;function HG(){if(NT)return Zp;NT=1;var r=OG();return Zp={Graph:r.Graph,json:kG(),alg:UG(),version:r.version},Zp}var Xp,FT;function Tn(){if(FT)return Xp;FT=1;var r;if(typeof p0=="function")try{r=HG()}catch{}return r||(r=window.graphlib),Xp=r,Xp}var Qp,zT;function KG(){if(zT)return Qp;zT=1;var r=NP(),e=1,t=4;function n(a){return r(a,e|t)}return Qp=n,Qp}var Jp,$T;function Jl(){if($T)return Jp;$T=1;var r=xo(),e=oa(),t=Wl(),n=rn();function a(i,o,s){if(!n(s))return!1;var u=typeof o;return(u=="number"?e(s)&&t(o,s.length):u=="string"&&o in s)?r(s[o],i):!1}return Jp=a,Jp}var ey,VT;function jG(){if(VT)return ey;VT=1;var r=Ql(),e=xo(),t=Jl(),n=xi(),a=Object.prototype,i=a.hasOwnProperty,o=r(function(s,u){s=Object(s);var l=-1,f=u.length,d=f>2?u[2]:void 0;for(d&&t(u[0],u[1],d)&&(f=1);++l<f;)for(var h=u[l],g=n(h),p=-1,x=g.length;++p<x;){var b=g[p],w=s[b];(w===void 0||e(w,a[b])&&!i.call(s,b))&&(s[b]=h[b])}return s});return ey=o,ey}var ry,GT;function YG(){if(GT)return ry;GT=1;var r=sa(),e=oa(),t=Va();function n(a){return function(i,o,s){var u=Object(i);if(!e(i)){var l=r(o,3);i=t(i),o=function(d){return l(u[d],d,u)}}var f=a(i,o,s);return f>-1?u[l?i[f]:f]:void 0}}return ry=n,ry}var ty,WT;function hI(){if(WT)return ty;WT=1;var r=I2(),e=1/0,t=17976931348623157e292;function n(a){if(!a)return a===0?a:0;if(a=r(a),a===e||a===-e){var i=a<0?-1:1;return i*t}return a===a?a:0}return ty=n,ty}var ny,UT;function ZG(){if(UT)return ny;UT=1;var r=hI();function e(t){var n=r(t),a=n%1;return n===n?a?n-a:n:0}return ny=e,ny}var ay,HT;function XG(){if(HT)return ay;HT=1;var r=oI(),e=sa(),t=ZG(),n=Math.max;function a(i,o,s){var u=i==null?0:i.length;if(!u)return-1;var l=s==null?0:t(s);return l<0&&(l=n(u+l,0)),r(i,e(o,3),l)}return ay=a,ay}var iy,KT;function QG(){if(KT)return iy;KT=1;var r=YG(),e=XG(),t=r(e);return iy=t,iy}var oy,jT;function gI(){if(jT)return oy;jT=1;var r=D0();function e(t){var n=t==null?0:t.length;return n?r(t,1):[]}return oy=e,oy}var sy,YT;function JG(){if(YT)return sy;YT=1;var r=R0(),e=FP(),t=xi();function n(a,i){return a==null?a:r(a,e(i),t)}return sy=n,sy}var uy,ZT;function eW(){if(ZT)return uy;ZT=1;function r(e){var t=e==null?0:e.length;return t?e[t-1]:void 0}return uy=r,uy}var ly,XT;function rW(){if(XT)return ly;XT=1;var r=Vl(),e=A0(),t=sa();function n(a,i){var o={};return i=t(i,3),e(a,function(s,u,l){r(o,u,i(s,u,l))}),o}return ly=n,ly}var fy,QT;function M0(){if(QT)return fy;QT=1;var r=ho();function e(t,n,a){for(var i=-1,o=t.length;++i<o;){var s=t[i],u=n(s);if(u!=null&&(l===void 0?u===u&&!r(u):a(u,l)))var l=u,f=s}return f}return fy=e,fy}var cy,JT;function tW(){if(JT)return cy;JT=1;function r(e,t){return e>t}return cy=r,cy}var dy,eR;function nW(){if(eR)return dy;eR=1;var r=M0(),e=tW(),t=Ei();function n(a){return a&&a.length?r(a,t,e):void 0}return dy=n,dy}var vy,rR;function pI(){if(rR)return vy;rR=1;var r=Vl(),e=xo();function t(n,a,i){(i!==void 0&&!e(n[a],i)||i===void 0&&!(a in n))&&r(n,a,i)}return vy=t,vy}var hy,tR;function aW(){if(tR)return hy;tR=1;var r=yi(),e=Kl(),t=zn(),n="[object Object]",a=Function.prototype,i=Object.prototype,o=a.toString,s=i.hasOwnProperty,u=o.call(Object);function l(f){if(!t(f)||r(f)!=n)return!1;var d=e(f);if(d===null)return!0;var h=s.call(d,"constructor")&&d.constructor;return typeof h=="function"&&h instanceof h&&o.call(h)==u}return hy=l,hy}var gy,nR;function yI(){if(nR)return gy;nR=1;function r(e,t){if(!(t==="constructor"&&typeof e[t]=="function")&&t!="__proto__")return e[t]}return gy=r,gy}var py,aR;function iW(){if(aR)return py;aR=1;var r=Ms(),e=xi();function t(n){return r(n,e(n))}return py=t,py}var yy,iR;function oW(){if(iR)return yy;iR=1;var r=pI(),e=TP(),t=OP(),n=RP(),a=qP(),i=Ls(),o=Xr(),s=sI(),u=Eo(),l=Bs(),f=rn(),d=aW(),h=Os(),g=yI(),p=iW();function x(b,w,y,E,C,S,R){var _=g(b,y),A=g(w,y),P=R.get(A);if(P){r(b,y,P);return}var I=S?S(_,A,y+"",b,w,R):void 0,D=I===void 0;if(D){var L=o(A),M=!L&&u(A),q=!L&&!M&&h(A);I=A,L||M||q?o(_)?I=_:s(_)?I=n(_):M?(D=!1,I=e(A,!0)):q?(D=!1,I=t(A,!0)):I=[]:d(A)||i(A)?(I=_,i(_)?I=p(_):(!f(_)||l(_))&&(I=a(A))):D=!1}D&&(R.set(A,I),C(I,A,E,S,R),R.delete(A)),r(b,y,I)}return yy=x,yy}var my,oR;function sW(){if(oR)return my;oR=1;var r=$l(),e=pI(),t=R0(),n=oW(),a=rn(),i=xi(),o=yI();function s(u,l,f,d,h){u!==l&&t(l,function(g,p){if(h||(h=new r),a(g))n(u,l,p,f,s,d,h);else{var x=d?d(o(u,p),g,p+"",u,l,h):void 0;x===void 0&&(x=g),e(u,p,x)}},i)}return my=s,my}var by,sR;function uW(){if(sR)return by;sR=1;var r=Ql(),e=Jl();function t(n){return r(function(a,i){var o=-1,s=i.length,u=s>1?i[s-1]:void 0,l=s>2?i[2]:void 0;for(u=n.length>3&&typeof u=="function"?(s--,u):void 0,l&&e(i[0],i[1],l)&&(u=s<3?void 0:u,s=1),a=Object(a);++o<s;){var f=i[o];f&&n(a,f,o,u)}return a})}return by=t,by}var wy,uR;function lW(){if(uR)return wy;uR=1;var r=sW(),e=uW(),t=e(function(n,a,i){r(n,a,i)});return wy=t,wy}var xy,lR;function mI(){if(lR)return xy;lR=1;function r(e,t){return e<t}return xy=r,xy}var Ey,fR;function fW(){if(fR)return Ey;fR=1;var r=M0(),e=mI(),t=Ei();function n(a){return a&&a.length?r(a,t,e):void 0}return Ey=n,Ey}var Cy,cR;function cW(){if(cR)return Cy;cR=1;var r=M0(),e=sa(),t=mI();function n(a,i){return a&&a.length?r(a,e(i,2),t):void 0}return Cy=n,Cy}var _y,dR;function dW(){if(dR)return _y;dR=1;var r=Gl(),e=Zl(),t=Wl(),n=rn(),a=ks();function i(o,s,u,l){if(!n(o))return o;s=e(s,o);for(var f=-1,d=s.length,h=d-1,g=o;g!=null&&++f<d;){var p=a(s[f]),x=u;if(p==="__proto__"||p==="constructor"||p==="prototype")return o;if(f!=h){var b=g[p];x=l?l(b,p,g):void 0,x===void 0&&(x=n(b)?b:t(s[f+1])?[]:{})}r(g,p,x),g=g[p]}return o}return _y=i,_y}var Sy,vR;function vW(){if(vR)return Sy;vR=1;var r=Xl(),e=dW(),t=Zl();function n(a,i,o){for(var s=-1,u=i.length,l={};++s<u;){var f=i[s],d=r(a,f);o(d,f)&&e(l,t(f,a),d)}return l}return Sy=n,Sy}var Ty,hR;function hW(){if(hR)return Ty;hR=1;var r=vW(),e=ZP();function t(n,a){return r(n,a,function(i,o){return e(n,o)})}return Ty=t,Ty}var Ry,gR;function gW(){if(gR)return Ry;gR=1;var r=gI(),e=aI(),t=iI();function n(a){return t(e(a,void 0,r),a+"")}return Ry=n,Ry}var Ay,pR;function pW(){if(pR)return Ay;pR=1;var r=hW(),e=gW(),t=e(function(n,a){return n==null?{}:r(n,a)});return Ay=t,Ay}var Py,yR;function yW(){if(yR)return Py;yR=1;var r=Math.ceil,e=Math.max;function t(n,a,i,o){for(var s=-1,u=e(r((a-n)/(i||1)),0),l=Array(u);u--;)l[o?u:++s]=n,n+=i;return l}return Py=t,Py}var Iy,mR;function mW(){if(mR)return Iy;mR=1;var r=yW(),e=Jl(),t=hI();function n(a){return function(i,o,s){return s&&typeof s!="number"&&e(i,o,s)&&(o=s=void 0),i=t(i),o===void 0?(o=i,i=0):o=t(o),s=s===void 0?i<o?1:-1:t(s),r(i,o,s,a)}}return Iy=n,Iy}var Dy,bR;function bW(){if(bR)return Dy;bR=1;var r=mW(),e=r();return Dy=e,Dy}var By,wR;function wW(){if(wR)return By;wR=1;function r(e,t){var n=e.length;for(e.sort(t);n--;)e[n]=e[n].value;return e}return By=r,By}var My,xR;function xW(){if(xR)return My;xR=1;var r=ho();function e(t,n){if(t!==n){var a=t!==void 0,i=t===null,o=t===t,s=r(t),u=n!==void 0,l=n===null,f=n===n,d=r(n);if(!l&&!d&&!s&&t>n||s&&u&&f&&!l&&!d||i&&u&&f||!a&&f||!o)return 1;if(!i&&!s&&!d&&t<n||d&&a&&o&&!i&&!s||l&&a&&o||!u&&o||!f)return-1}return 0}return My=e,My}var Ly,ER;function EW(){if(ER)return Ly;ER=1;var r=xW();function e(t,n,a){for(var i=-1,o=t.criteria,s=n.criteria,u=o.length,l=a.length;++i<u;){var f=r(o[i],s[i]);if(f){if(i>=l)return f;var d=a[i];return f*(d=="desc"?-1:1)}}return t.index-n.index}return Ly=e,Ly}var Oy,CR;function CW(){if(CR)return Oy;CR=1;var r=Yl(),e=Xl(),t=sa(),n=rI(),a=wW(),i=Ul(),o=EW(),s=Ei(),u=Xr();function l(f,d,h){d.length?d=r(d,function(x){return u(x)?function(b){return e(b,x.length===1?x[0]:x)}:x}):d=[s];var g=-1;d=r(d,i(t));var p=n(f,function(x,b,w){var y=r(d,function(E){return E(x)});return{criteria:y,index:++g,value:x}});return a(p,function(x,b){return o(x,b,h)})}return Oy=l,Oy}var ky,_R;function _W(){if(_R)return ky;_R=1;var r=D0(),e=CW(),t=Ql(),n=Jl(),a=t(function(i,o){if(i==null)return[];var s=o.length;return s>1&&n(i,o[0],o[1])?o=[]:s>2&&n(o[0],o[1],o[2])&&(o=[o[0]]),e(i,r(o,1),[])});return ky=a,ky}var qy,SR;function SW(){if(SR)return qy;SR=1;var r=jP(),e=0;function t(n){var a=++e;return r(n)+a}return qy=t,qy}var Ny,TR;function TW(){if(TR)return Ny;TR=1;function r(e,t,n){for(var a=-1,i=e.length,o=t.length,s={};++a<i;){var u=a<o?t[a]:void 0;n(s,e[a],u)}return s}return Ny=r,Ny}var Fy,RR;function RW(){if(RR)return Fy;RR=1;var r=Gl(),e=TW();function t(n,a){return e(n||[],a||[],r)}return Fy=t,Fy}var zy,AR;function qr(){if(AR)return zy;AR=1;var r;if(typeof p0=="function")try{r={cloneDeep:KG(),constant:T0(),defaults:jG(),each:$P(),filter:QP(),find:QG(),flatten:gI(),forEach:zP(),forIn:JG(),has:JP(),isUndefined:eI(),last:eW(),map:tI(),mapValues:rW(),max:nW(),merge:lW(),min:fW(),minBy:cW(),now:P2(),pick:pW(),range:bW(),reduce:nI(),sortBy:_W(),uniqueId:SW(),values:uI(),zipObject:RW()}}catch{}return r||(r=window._),zy=r,zy}var $y,PR;function AW(){if(PR)return $y;PR=1,$y=r;function r(){var n={};n._next=n._prev=n,this._sentinel=n}r.prototype.dequeue=function(){var n=this._sentinel,a=n._prev;if(a!==n)return e(a),a},r.prototype.enqueue=function(n){var a=this._sentinel;n._prev&&n._next&&e(n),n._next=a._next,a._next._prev=n,a._next=n,n._prev=a},r.prototype.toString=function(){for(var n=[],a=this._sentinel,i=a._prev;i!==a;)n.push(JSON.stringify(i,t)),i=i._prev;return"["+n.join(", ")+"]"};function e(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function t(n,a){if(n!=="_next"&&n!=="_prev")return a}return $y}var Vy,IR;function PW(){if(IR)return Vy;IR=1;var r=qr(),e=Tn().Graph,t=AW();Vy=a;var n=r.constant(1);function a(l,f){if(l.nodeCount()<=1)return[];var d=s(l,f||n),h=i(d.graph,d.buckets,d.zeroIdx);return r.flatten(r.map(h,function(g){return l.outEdges(g.v,g.w)}),!0)}function i(l,f,d){for(var h=[],g=f[f.length-1],p=f[0],x;l.nodeCount();){for(;x=p.dequeue();)o(l,f,d,x);for(;x=g.dequeue();)o(l,f,d,x);if(l.nodeCount()){for(var b=f.length-2;b>0;--b)if(x=f[b].dequeue(),x){h=h.concat(o(l,f,d,x,!0));break}}}return h}function o(l,f,d,h,g){var p=g?[]:void 0;return r.forEach(l.inEdges(h.v),function(x){var b=l.edge(x),w=l.node(x.v);g&&p.push({v:x.v,w:x.w}),w.out-=b,u(f,d,w)}),r.forEach(l.outEdges(h.v),function(x){var b=l.edge(x),w=x.w,y=l.node(w);y.in-=b,u(f,d,y)}),l.removeNode(h.v),p}function s(l,f){var d=new e,h=0,g=0;r.forEach(l.nodes(),function(b){d.setNode(b,{v:b,in:0,out:0})}),r.forEach(l.edges(),function(b){var w=d.edge(b.v,b.w)||0,y=f(b),E=w+y;d.setEdge(b.v,b.w,E),g=Math.max(g,d.node(b.v).out+=y),h=Math.max(h,d.node(b.w).in+=y)});var p=r.range(g+h+3).map(function(){return new t}),x=h+1;return r.forEach(d.nodes(),function(b){u(p,x,d.node(b))}),{graph:d,buckets:p,zeroIdx:x}}function u(l,f,d){d.out?d.in?l[d.out-d.in+f].enqueue(d):l[l.length-1].enqueue(d):l[0].enqueue(d)}return Vy}var Gy,DR;function IW(){if(DR)return Gy;DR=1;var r=qr(),e=PW();Gy={run:t,undo:a};function t(i){var o=i.graph().acyclicer==="greedy"?e(i,s(i)):n(i);r.forEach(o,function(u){var l=i.edge(u);i.removeEdge(u),l.forwardName=u.name,l.reversed=!0,i.setEdge(u.w,u.v,l,r.uniqueId("rev"))});function s(u){return function(l){return u.edge(l).weight}}}function n(i){var o=[],s={},u={};function l(f){r.has(u,f)||(u[f]=!0,s[f]=!0,r.forEach(i.outEdges(f),function(d){r.has(s,d.w)?o.push(d):l(d.w)}),delete s[f])}return r.forEach(i.nodes(),l),o}function a(i){r.forEach(i.edges(),function(o){var s=i.edge(o);if(s.reversed){i.removeEdge(o);var u=s.forwardName;delete s.reversed,delete s.forwardName,i.setEdge(o.w,o.v,s,u)}})}return Gy}var Wy,BR;function Wt(){if(BR)return Wy;BR=1;var r=qr(),e=Tn().Graph;Wy={addDummyNode:t,simplify:n,asNonCompoundGraph:a,successorWeights:i,predecessorWeights:o,intersectRect:s,buildLayerMatrix:u,normalizeRanks:l,removeEmptyRanks:f,addBorderNode:d,maxRank:h,partition:g,time:p,notime:x};function t(b,w,y,E){var C;do C=r.uniqueId(E);while(b.hasNode(C));return y.dummy=w,b.setNode(C,y),C}function n(b){var w=new e().setGraph(b.graph());return r.forEach(b.nodes(),function(y){w.setNode(y,b.node(y))}),r.forEach(b.edges(),function(y){var E=w.edge(y.v,y.w)||{weight:0,minlen:1},C=b.edge(y);w.setEdge(y.v,y.w,{weight:E.weight+C.weight,minlen:Math.max(E.minlen,C.minlen)})}),w}function a(b){var w=new e({multigraph:b.isMultigraph()}).setGraph(b.graph());return r.forEach(b.nodes(),function(y){b.children(y).length||w.setNode(y,b.node(y))}),r.forEach(b.edges(),function(y){w.setEdge(y,b.edge(y))}),w}function i(b){var w=r.map(b.nodes(),function(y){var E={};return r.forEach(b.outEdges(y),function(C){E[C.w]=(E[C.w]||0)+b.edge(C).weight}),E});return r.zipObject(b.nodes(),w)}function o(b){var w=r.map(b.nodes(),function(y){var E={};return r.forEach(b.inEdges(y),function(C){E[C.v]=(E[C.v]||0)+b.edge(C).weight}),E});return r.zipObject(b.nodes(),w)}function s(b,w){var y=b.x,E=b.y,C=w.x-y,S=w.y-E,R=b.width/2,_=b.height/2;if(!C&&!S)throw new Error("Not possible to find intersection inside of the rectangle");var A,P;return Math.abs(S)*R>Math.abs(C)*_?(S<0&&(_=-_),A=_*C/S,P=_):(C<0&&(R=-R),A=R,P=R*S/C),{x:y+A,y:E+P}}function u(b){var w=r.map(r.range(h(b)+1),function(){return[]});return r.forEach(b.nodes(),function(y){var E=b.node(y),C=E.rank;r.isUndefined(C)||(w[C][E.order]=y)}),w}function l(b){var w=r.min(r.map(b.nodes(),function(y){return b.node(y).rank}));r.forEach(b.nodes(),function(y){var E=b.node(y);r.has(E,"rank")&&(E.rank-=w)})}function f(b){var w=r.min(r.map(b.nodes(),function(S){return b.node(S).rank})),y=[];r.forEach(b.nodes(),function(S){var R=b.node(S).rank-w;y[R]||(y[R]=[]),y[R].push(S)});var E=0,C=b.graph().nodeRankFactor;r.forEach(y,function(S,R){r.isUndefined(S)&&R%C!==0?--E:E&&r.forEach(S,function(_){b.node(_).rank+=E})})}function d(b,w,y,E){var C={width:0,height:0};return arguments.length>=4&&(C.rank=y,C.order=E),t(b,"border",C,w)}function h(b){return r.max(r.map(b.nodes(),function(w){var y=b.node(w).rank;if(!r.isUndefined(y))return y}))}function g(b,w){var y={lhs:[],rhs:[]};return r.forEach(b,function(E){w(E)?y.lhs.push(E):y.rhs.push(E)}),y}function p(b,w){var y=r.now();try{return w()}finally{console.log(b+" time: "+(r.now()-y)+"ms")}}function x(b,w){return w()}return Wy}var Uy,MR;function DW(){if(MR)return Uy;MR=1;var r=qr(),e=Wt();Uy={run:t,undo:a};function t(i){i.graph().dummyChains=[],r.forEach(i.edges(),function(o){n(i,o)})}function n(i,o){var s=o.v,u=i.node(s).rank,l=o.w,f=i.node(l).rank,d=o.name,h=i.edge(o),g=h.labelRank;if(f!==u+1){i.removeEdge(o);var p,x,b;for(b=0,++u;u<f;++b,++u)h.points=[],x={width:0,height:0,edgeLabel:h,edgeObj:o,rank:u},p=e.addDummyNode(i,"edge",x,"_d"),u===g&&(x.width=h.width,x.height=h.height,x.dummy="edge-label",x.labelpos=h.labelpos),i.setEdge(s,p,{weight:h.weight},d),b===0&&i.graph().dummyChains.push(p),s=p;i.setEdge(s,l,{weight:h.weight},d)}}function a(i){r.forEach(i.graph().dummyChains,function(o){var s=i.node(o),u=s.edgeLabel,l;for(i.setEdge(s.edgeObj,u);s.dummy;)l=i.successors(o)[0],i.removeNode(o),u.points.push({x:s.x,y:s.y}),s.dummy==="edge-label"&&(u.x=s.x,u.y=s.y,u.width=s.width,u.height=s.height),o=l,s=i.node(o)})}return Uy}var Hy,LR;function hl(){if(LR)return Hy;LR=1;var r=qr();Hy={longestPath:e,slack:t};function e(n){var a={};function i(o){var s=n.node(o);if(r.has(a,o))return s.rank;a[o]=!0;var u=r.min(r.map(n.outEdges(o),function(l){return i(l.w)-n.edge(l).minlen}));return(u===Number.POSITIVE_INFINITY||u===void 0||u===null)&&(u=0),s.rank=u}r.forEach(n.sources(),i)}function t(n,a){return n.node(a.w).rank-n.node(a.v).rank-n.edge(a).minlen}return Hy}var Ky,OR;function bI(){if(OR)return Ky;OR=1;var r=qr(),e=Tn().Graph,t=hl().slack;Ky=n;function n(s){var u=new e({directed:!1}),l=s.nodes()[0],f=s.nodeCount();u.setNode(l,{});for(var d,h;a(u,s)<f;)d=i(u,s),h=u.hasNode(d.v)?t(s,d):-t(s,d),o(u,s,h);return u}function a(s,u){function l(f){r.forEach(u.nodeEdges(f),function(d){var h=d.v,g=f===h?d.w:h;!s.hasNode(g)&&!t(u,d)&&(s.setNode(g,{}),s.setEdge(f,g,{}),l(g))})}return r.forEach(s.nodes(),l),s.nodeCount()}function i(s,u){return r.minBy(u.edges(),function(l){if(s.hasNode(l.v)!==s.hasNode(l.w))return t(u,l)})}function o(s,u,l){r.forEach(s.nodes(),function(f){u.node(f).rank+=l})}return Ky}var jy,kR;function BW(){if(kR)return jy;kR=1;var r=qr(),e=bI(),t=hl().slack,n=hl().longestPath,a=Tn().alg.preorder,i=Tn().alg.postorder,o=Wt().simplify;jy=s,s.initLowLimValues=d,s.initCutValues=u,s.calcCutValue=f,s.leaveEdge=g,s.enterEdge=p,s.exchangeEdges=x;function s(E){E=o(E),n(E);var C=e(E);d(C),u(C,E);for(var S,R;S=g(C);)R=p(C,E,S),x(C,E,S,R)}function u(E,C){var S=i(E,E.nodes());S=S.slice(0,S.length-1),r.forEach(S,function(R){l(E,C,R)})}function l(E,C,S){var R=E.node(S),_=R.parent;E.edge(S,_).cutvalue=f(E,C,S)}function f(E,C,S){var R=E.node(S),_=R.parent,A=!0,P=C.edge(S,_),I=0;return P||(A=!1,P=C.edge(_,S)),I=P.weight,r.forEach(C.nodeEdges(S),function(D){var L=D.v===S,M=L?D.w:D.v;if(M!==_){var q=L===A,N=C.edge(D).weight;if(I+=q?N:-N,w(E,S,M)){var W=E.edge(S,M).cutvalue;I+=q?-W:W}}}),I}function d(E,C){arguments.length<2&&(C=E.nodes()[0]),h(E,{},1,C)}function h(E,C,S,R,_){var A=S,P=E.node(R);return C[R]=!0,r.forEach(E.neighbors(R),function(I){r.has(C,I)||(S=h(E,C,S,I,R))}),P.low=A,P.lim=S++,_?P.parent=_:delete P.parent,S}function g(E){return r.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function p(E,C,S){var R=S.v,_=S.w;C.hasEdge(R,_)||(R=S.w,_=S.v);var A=E.node(R),P=E.node(_),I=A,D=!1;A.lim>P.lim&&(I=P,D=!0);var L=r.filter(C.edges(),function(M){return D===y(E,E.node(M.v),I)&&D!==y(E,E.node(M.w),I)});return r.minBy(L,function(M){return t(C,M)})}function x(E,C,S,R){var _=S.v,A=S.w;E.removeEdge(_,A),E.setEdge(R.v,R.w,{}),d(E),u(E,C),b(E,C)}function b(E,C){var S=r.find(E.nodes(),function(_){return!C.node(_).parent}),R=a(E,S);R=R.slice(1),r.forEach(R,function(_){var A=E.node(_).parent,P=C.edge(_,A),I=!1;P||(P=C.edge(A,_),I=!0),C.node(_).rank=C.node(A).rank+(I?P.minlen:-P.minlen)})}function w(E,C,S){return E.hasEdge(C,S)}function y(E,C,S){return S.low<=C.lim&&C.lim<=S.lim}return jy}var Yy,qR;function MW(){if(qR)return Yy;qR=1;var r=hl(),e=r.longestPath,t=bI(),n=BW();Yy=a;function a(u){switch(u.graph().ranker){case"network-simplex":s(u);break;case"tight-tree":o(u);break;case"longest-path":i(u);break;default:s(u)}}var i=e;function o(u){e(u),t(u)}function s(u){n(u)}return Yy}var Zy,NR;function LW(){if(NR)return Zy;NR=1;var r=qr();Zy=e;function e(a){var i=n(a);r.forEach(a.graph().dummyChains,function(o){for(var s=a.node(o),u=s.edgeObj,l=t(a,i,u.v,u.w),f=l.path,d=l.lca,h=0,g=f[h],p=!0;o!==u.w;){if(s=a.node(o),p){for(;(g=f[h])!==d&&a.node(g).maxRank<s.rank;)h++;g===d&&(p=!1)}if(!p){for(;h<f.length-1&&a.node(g=f[h+1]).minRank<=s.rank;)h++;g=f[h]}a.setParent(o,g),o=a.successors(o)[0]}})}function t(a,i,o,s){var u=[],l=[],f=Math.min(i[o].low,i[s].low),d=Math.max(i[o].lim,i[s].lim),h,g;h=o;do h=a.parent(h),u.push(h);while(h&&(i[h].low>f||d>i[h].lim));for(g=h,h=s;(h=a.parent(h))!==g;)l.push(h);return{path:u.concat(l.reverse()),lca:g}}function n(a){var i={},o=0;function s(u){var l=o;r.forEach(a.children(u),s),i[u]={low:l,lim:o++}}return r.forEach(a.children(),s),i}return Zy}var Xy,FR;function OW(){if(FR)return Xy;FR=1;var r=qr(),e=Wt();Xy={run:t,cleanup:o};function t(s){var u=e.addDummyNode(s,"root",{},"_root"),l=a(s),f=r.max(r.values(l))-1,d=2*f+1;s.graph().nestingRoot=u,r.forEach(s.edges(),function(g){s.edge(g).minlen*=d});var h=i(s)+1;r.forEach(s.children(),function(g){n(s,u,d,h,f,l,g)}),s.graph().nodeRankFactor=d}function n(s,u,l,f,d,h,g){var p=s.children(g);if(!p.length){g!==u&&s.setEdge(u,g,{weight:0,minlen:l});return}var x=e.addBorderNode(s,"_bt"),b=e.addBorderNode(s,"_bb"),w=s.node(g);s.setParent(x,g),w.borderTop=x,s.setParent(b,g),w.borderBottom=b,r.forEach(p,function(y){n(s,u,l,f,d,h,y);var E=s.node(y),C=E.borderTop?E.borderTop:y,S=E.borderBottom?E.borderBottom:y,R=E.borderTop?f:2*f,_=C!==S?1:d-h[g]+1;s.setEdge(x,C,{weight:R,minlen:_,nestingEdge:!0}),s.setEdge(S,b,{weight:R,minlen:_,nestingEdge:!0})}),s.parent(g)||s.setEdge(u,x,{weight:0,minlen:d+h[g]})}function a(s){var u={};function l(f,d){var h=s.children(f);h&&h.length&&r.forEach(h,function(g){l(g,d+1)}),u[f]=d}return r.forEach(s.children(),function(f){l(f,1)}),u}function i(s){return r.reduce(s.edges(),function(u,l){return u+s.edge(l).weight},0)}function o(s){var u=s.graph();s.removeNode(u.nestingRoot),delete u.nestingRoot,r.forEach(s.edges(),function(l){var f=s.edge(l);f.nestingEdge&&s.removeEdge(l)})}return Xy}var Qy,zR;function kW(){if(zR)return Qy;zR=1;var r=qr(),e=Wt();Qy=t;function t(a){function i(o){var s=a.children(o),u=a.node(o);if(s.length&&r.forEach(s,i),r.has(u,"minRank")){u.borderLeft=[],u.borderRight=[];for(var l=u.minRank,f=u.maxRank+1;l<f;++l)n(a,"borderLeft","_bl",o,u,l),n(a,"borderRight","_br",o,u,l)}}r.forEach(a.children(),i)}function n(a,i,o,s,u,l){var f={width:0,height:0,rank:l,borderType:i},d=u[i][l-1],h=e.addDummyNode(a,"border",f,o);u[i][l]=h,a.setParent(h,s),d&&a.setEdge(d,h,{weight:1})}return Qy}var Jy,$R;function qW(){if($R)return Jy;$R=1;var r=qr();Jy={adjust:e,undo:t};function e(l){var f=l.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&n(l)}function t(l){var f=l.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&i(l),(f==="lr"||f==="rl")&&(s(l),n(l))}function n(l){r.forEach(l.nodes(),function(f){a(l.node(f))}),r.forEach(l.edges(),function(f){a(l.edge(f))})}function a(l){var f=l.width;l.width=l.height,l.height=f}function i(l){r.forEach(l.nodes(),function(f){o(l.node(f))}),r.forEach(l.edges(),function(f){var d=l.edge(f);r.forEach(d.points,o),r.has(d,"y")&&o(d)})}function o(l){l.y=-l.y}function s(l){r.forEach(l.nodes(),function(f){u(l.node(f))}),r.forEach(l.edges(),function(f){var d=l.edge(f);r.forEach(d.points,u),r.has(d,"x")&&u(d)})}function u(l){var f=l.x;l.x=l.y,l.y=f}return Jy}var em,VR;function NW(){if(VR)return em;VR=1;var r=qr();em=e;function e(t){var n={},a=r.filter(t.nodes(),function(l){return!t.children(l).length}),i=r.max(r.map(a,function(l){return t.node(l).rank})),o=r.map(r.range(i+1),function(){return[]});function s(l){if(!r.has(n,l)){n[l]=!0;var f=t.node(l);o[f.rank].push(l),r.forEach(t.successors(l),s)}}var u=r.sortBy(a,function(l){return t.node(l).rank});return r.forEach(u,s),o}return em}var rm,GR;function FW(){if(GR)return rm;GR=1;var r=qr();rm=e;function e(n,a){for(var i=0,o=1;o<a.length;++o)i+=t(n,a[o-1],a[o]);return i}function t(n,a,i){for(var o=r.zipObject(i,r.map(i,function(h,g){return g})),s=r.flatten(r.map(a,function(h){return r.sortBy(r.map(n.outEdges(h),function(g){return{pos:o[g.w],weight:n.edge(g).weight}}),"pos")}),!0),u=1;u<i.length;)u<<=1;var l=2*u-1;u-=1;var f=r.map(new Array(l),function(){return 0}),d=0;return r.forEach(s.forEach(function(h){var g=h.pos+u;f[g]+=h.weight;for(var p=0;g>0;)g%2&&(p+=f[g+1]),g=g-1>>1,f[g]+=h.weight;d+=h.weight*p})),d}return rm}var tm,WR;function zW(){if(WR)return tm;WR=1;var r=qr();tm=e;function e(t,n){return r.map(n,function(a){var i=t.inEdges(a);if(i.length){var o=r.reduce(i,function(s,u){var l=t.edge(u),f=t.node(u.v);return{sum:s.sum+l.weight*f.order,weight:s.weight+l.weight}},{sum:0,weight:0});return{v:a,barycenter:o.sum/o.weight,weight:o.weight}}else return{v:a}})}return tm}var nm,UR;function $W(){if(UR)return nm;UR=1;var r=qr();nm=e;function e(a,i){var o={};r.forEach(a,function(u,l){var f=o[u.v]={indegree:0,in:[],out:[],vs:[u.v],i:l};r.isUndefined(u.barycenter)||(f.barycenter=u.barycenter,f.weight=u.weight)}),r.forEach(i.edges(),function(u){var l=o[u.v],f=o[u.w];!r.isUndefined(l)&&!r.isUndefined(f)&&(f.indegree++,l.out.push(o[u.w]))});var s=r.filter(o,function(u){return!u.indegree});return t(s)}function t(a){var i=[];function o(l){return function(f){f.merged||(r.isUndefined(f.barycenter)||r.isUndefined(l.barycenter)||f.barycenter>=l.barycenter)&&n(l,f)}}function s(l){return function(f){f.in.push(l),--f.indegree===0&&a.push(f)}}for(;a.length;){var u=a.pop();i.push(u),r.forEach(u.in.reverse(),o(u)),r.forEach(u.out,s(u))}return r.map(r.filter(i,function(l){return!l.merged}),function(l){return r.pick(l,["vs","i","barycenter","weight"])})}function n(a,i){var o=0,s=0;a.weight&&(o+=a.barycenter*a.weight,s+=a.weight),i.weight&&(o+=i.barycenter*i.weight,s+=i.weight),a.vs=i.vs.concat(a.vs),a.barycenter=o/s,a.weight=s,a.i=Math.min(i.i,a.i),i.merged=!0}return nm}var am,HR;function VW(){if(HR)return am;HR=1;var r=qr(),e=Wt();am=t;function t(i,o){var s=e.partition(i,function(x){return r.has(x,"barycenter")}),u=s.lhs,l=r.sortBy(s.rhs,function(x){return-x.i}),f=[],d=0,h=0,g=0;u.sort(a(!!o)),g=n(f,l,g),r.forEach(u,function(x){g+=x.vs.length,f.push(x.vs),d+=x.barycenter*x.weight,h+=x.weight,g=n(f,l,g)});var p={vs:r.flatten(f,!0)};return h&&(p.barycenter=d/h,p.weight=h),p}function n(i,o,s){for(var u;o.length&&(u=r.last(o)).i<=s;)o.pop(),i.push(u.vs),s++;return s}function a(i){return function(o,s){return o.barycenter<s.barycenter?-1:o.barycenter>s.barycenter?1:i?s.i-o.i:o.i-s.i}}return am}var im,KR;function GW(){if(KR)return im;KR=1;var r=qr(),e=zW(),t=$W(),n=VW();im=a;function a(s,u,l,f){var d=s.children(u),h=s.node(u),g=h?h.borderLeft:void 0,p=h?h.borderRight:void 0,x={};g&&(d=r.filter(d,function(S){return S!==g&&S!==p}));var b=e(s,d);r.forEach(b,function(S){if(s.children(S.v).length){var R=a(s,S.v,l,f);x[S.v]=R,r.has(R,"barycenter")&&o(S,R)}});var w=t(b,l);i(w,x);var y=n(w,f);if(g&&(y.vs=r.flatten([g,y.vs,p],!0),s.predecessors(g).length)){var E=s.node(s.predecessors(g)[0]),C=s.node(s.predecessors(p)[0]);r.has(y,"barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+E.order+C.order)/(y.weight+2),y.weight+=2}return y}function i(s,u){r.forEach(s,function(l){l.vs=r.flatten(l.vs.map(function(f){return u[f]?u[f].vs:f}),!0)})}function o(s,u){r.isUndefined(s.barycenter)?(s.barycenter=u.barycenter,s.weight=u.weight):(s.barycenter=(s.barycenter*s.weight+u.barycenter*u.weight)/(s.weight+u.weight),s.weight+=u.weight)}return im}var om,jR;function WW(){if(jR)return om;jR=1;var r=qr(),e=Tn().Graph;om=t;function t(a,i,o){var s=n(a),u=new e({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(function(l){return a.node(l)});return r.forEach(a.nodes(),function(l){var f=a.node(l),d=a.parent(l);(f.rank===i||f.minRank<=i&&i<=f.maxRank)&&(u.setNode(l),u.setParent(l,d||s),r.forEach(a[o](l),function(h){var g=h.v===l?h.w:h.v,p=u.edge(g,l),x=r.isUndefined(p)?0:p.weight;u.setEdge(g,l,{weight:a.edge(h).weight+x})}),r.has(f,"minRank")&&u.setNode(l,{borderLeft:f.borderLeft[i],borderRight:f.borderRight[i]}))}),u}function n(a){for(var i;a.hasNode(i=r.uniqueId("_root")););return i}return om}var sm,YR;function UW(){if(YR)return sm;YR=1;var r=qr();sm=e;function e(t,n,a){var i={},o;r.forEach(a,function(s){for(var u=t.parent(s),l,f;u;){if(l=t.parent(u),l?(f=i[l],i[l]=u):(f=o,o=u),f&&f!==u){n.setEdge(f,u);return}u=l}})}return sm}var um,ZR;function HW(){if(ZR)return um;ZR=1;var r=qr(),e=NW(),t=FW(),n=GW(),a=WW(),i=UW(),o=Tn().Graph,s=Wt();um=u;function u(h){var g=s.maxRank(h),p=l(h,r.range(1,g+1),"inEdges"),x=l(h,r.range(g-1,-1,-1),"outEdges"),b=e(h);d(h,b);for(var w=Number.POSITIVE_INFINITY,y,E=0,C=0;C<4;++E,++C){f(E%2?p:x,E%4>=2),b=s.buildLayerMatrix(h);var S=t(h,b);S<w&&(C=0,y=r.cloneDeep(b),w=S)}d(h,y)}function l(h,g,p){return r.map(g,function(x){return a(h,x,p)})}function f(h,g){var p=new o;r.forEach(h,function(x){var b=x.graph().root,w=n(x,b,p,g);r.forEach(w.vs,function(y,E){x.node(y).order=E}),i(x,p,w.vs)})}function d(h,g){r.forEach(g,function(p){r.forEach(p,function(x,b){h.node(x).order=b})})}return um}var lm,XR;function KW(){if(XR)return lm;XR=1;var r=qr(),e=Tn().Graph,t=Wt();lm={positionX:p,findType1Conflicts:n,findType2Conflicts:a,addConflict:o,hasConflict:s,verticalAlignment:u,horizontalCompaction:l,alignCoordinates:h,findSmallestWidthAlignment:d,balance:g};function n(w,y){var E={};function C(S,R){var _=0,A=0,P=S.length,I=r.last(R);return r.forEach(R,function(D,L){var M=i(w,D),q=M?w.node(M).order:P;(M||D===I)&&(r.forEach(R.slice(A,L+1),function(N){r.forEach(w.predecessors(N),function(W){var V=w.node(W),$=V.order;($<_||q<$)&&!(V.dummy&&w.node(N).dummy)&&o(E,W,N)})}),A=L+1,_=q)}),R}return r.reduce(y,C),E}function a(w,y){var E={};function C(R,_,A,P,I){var D;r.forEach(r.range(_,A),function(L){D=R[L],w.node(D).dummy&&r.forEach(w.predecessors(D),function(M){var q=w.node(M);q.dummy&&(q.order<P||q.order>I)&&o(E,M,D)})})}function S(R,_){var A=-1,P,I=0;return r.forEach(_,function(D,L){if(w.node(D).dummy==="border"){var M=w.predecessors(D);M.length&&(P=w.node(M[0]).order,C(_,I,L,A,P),I=L,A=P)}C(_,I,_.length,P,R.length)}),_}return r.reduce(y,S),E}function i(w,y){if(w.node(y).dummy)return r.find(w.predecessors(y),function(E){return w.node(E).dummy})}function o(w,y,E){if(y>E){var C=y;y=E,E=C}var S=w[y];S||(w[y]=S={}),S[E]=!0}function s(w,y,E){if(y>E){var C=y;y=E,E=C}return r.has(w[y],E)}function u(w,y,E,C){var S={},R={},_={};return r.forEach(y,function(A){r.forEach(A,function(P,I){S[P]=P,R[P]=P,_[P]=I})}),r.forEach(y,function(A){var P=-1;r.forEach(A,function(I){var D=C(I);if(D.length){D=r.sortBy(D,function(W){return _[W]});for(var L=(D.length-1)/2,M=Math.floor(L),q=Math.ceil(L);M<=q;++M){var N=D[M];R[I]===I&&P<_[N]&&!s(E,I,N)&&(R[N]=I,R[I]=S[I]=S[N],P=_[N])}}})}),{root:S,align:R}}function l(w,y,E,C,S){var R={},_=f(w,y,E,S),A=S?"borderLeft":"borderRight";function P(L,M){for(var q=_.nodes(),N=q.pop(),W={};N;)W[N]?L(N):(W[N]=!0,q.push(N),q=q.concat(M(N))),N=q.pop()}function I(L){R[L]=_.inEdges(L).reduce(function(M,q){return Math.max(M,R[q.v]+_.edge(q))},0)}function D(L){var M=_.outEdges(L).reduce(function(N,W){return Math.min(N,R[W.w]-_.edge(W))},Number.POSITIVE_INFINITY),q=w.node(L);M!==Number.POSITIVE_INFINITY&&q.borderType!==A&&(R[L]=Math.max(R[L],M))}return P(I,_.predecessors.bind(_)),P(D,_.successors.bind(_)),r.forEach(C,function(L){R[L]=R[E[L]]}),R}function f(w,y,E,C){var S=new e,R=w.graph(),_=x(R.nodesep,R.edgesep,C);return r.forEach(y,function(A){var P;r.forEach(A,function(I){var D=E[I];if(S.setNode(D),P){var L=E[P],M=S.edge(L,D);S.setEdge(L,D,Math.max(_(w,I,P),M||0))}P=I})}),S}function d(w,y){return r.minBy(r.values(y),function(E){var C=Number.NEGATIVE_INFINITY,S=Number.POSITIVE_INFINITY;return r.forIn(E,function(R,_){var A=b(w,_)/2;C=Math.max(R+A,C),S=Math.min(R-A,S)}),C-S})}function h(w,y){var E=r.values(y),C=r.min(E),S=r.max(E);r.forEach(["u","d"],function(R){r.forEach(["l","r"],function(_){var A=R+_,P=w[A],I;if(P!==y){var D=r.values(P);I=_==="l"?C-r.min(D):S-r.max(D),I&&(w[A]=r.mapValues(P,function(L){return L+I}))}})})}function g(w,y){return r.mapValues(w.ul,function(E,C){if(y)return w[y.toLowerCase()][C];var S=r.sortBy(r.map(w,C));return(S[1]+S[2])/2})}function p(w){var y=t.buildLayerMatrix(w),E=r.merge(n(w,y),a(w,y)),C={},S;r.forEach(["u","d"],function(_){S=_==="u"?y:r.values(y).reverse(),r.forEach(["l","r"],function(A){A==="r"&&(S=r.map(S,function(L){return r.values(L).reverse()}));var P=(_==="u"?w.predecessors:w.successors).bind(w),I=u(w,S,E,P),D=l(w,S,I.root,I.align,A==="r");A==="r"&&(D=r.mapValues(D,function(L){return-L})),C[_+A]=D})});var R=d(w,C);return h(C,R),g(C,w.graph().align)}function x(w,y,E){return function(C,S,R){var _=C.node(S),A=C.node(R),P=0,I;if(P+=_.width/2,r.has(_,"labelpos"))switch(_.labelpos.toLowerCase()){case"l":I=-_.width/2;break;case"r":I=_.width/2;break}if(I&&(P+=E?I:-I),I=0,P+=(_.dummy?y:w)/2,P+=(A.dummy?y:w)/2,P+=A.width/2,r.has(A,"labelpos"))switch(A.labelpos.toLowerCase()){case"l":I=A.width/2;break;case"r":I=-A.width/2;break}return I&&(P+=E?I:-I),I=0,P}}function b(w,y){return w.node(y).width}return lm}var fm,QR;function jW(){if(QR)return fm;QR=1;var r=qr(),e=Wt(),t=KW().positionX;fm=n;function n(i){i=e.asNonCompoundGraph(i),a(i),r.forEach(t(i),function(o,s){i.node(s).x=o})}function a(i){var o=e.buildLayerMatrix(i),s=i.graph().ranksep,u=0;r.forEach(o,function(l){var f=r.max(r.map(l,function(d){return i.node(d).height}));r.forEach(l,function(d){i.node(d).y=u+f/2}),u+=f+s})}return fm}var cm,JR;function YW(){if(JR)return cm;JR=1;var r=qr(),e=IW(),t=DW(),n=MW(),a=Wt().normalizeRanks,i=LW(),o=Wt().removeEmptyRanks,s=OW(),u=kW(),l=qW(),f=HW(),d=jW(),h=Wt(),g=Tn().Graph;cm=p;function p(G,z){var Y=z&&z.debugTiming?h.time:h.notime;Y("layout",function(){var te=Y(" buildLayoutGraph",function(){return P(G)});Y(" runLayout",function(){x(te,Y)}),Y(" updateInputGraph",function(){b(G,te)})})}function x(G,z){z(" makeSpaceForEdgeLabels",function(){I(G)}),z(" removeSelfEdges",function(){Z(G)}),z(" acyclic",function(){e.run(G)}),z(" nestingGraph.run",function(){s.run(G)}),z(" rank",function(){n(h.asNonCompoundGraph(G))}),z(" injectEdgeLabelProxies",function(){D(G)}),z(" removeEmptyRanks",function(){o(G)}),z(" nestingGraph.cleanup",function(){s.cleanup(G)}),z(" normalizeRanks",function(){a(G)}),z(" assignRankMinMax",function(){L(G)}),z(" removeEdgeLabelProxies",function(){M(G)}),z(" normalize.run",function(){t.run(G)}),z(" parentDummyChains",function(){i(G)}),z(" addBorderSegments",function(){u(G)}),z(" order",function(){f(G)}),z(" insertSelfEdges",function(){ee(G)}),z(" adjustCoordinateSystem",function(){l.adjust(G)}),z(" position",function(){d(G)}),z(" positionSelfEdges",function(){K(G)}),z(" removeBorderNodes",function(){$(G)}),z(" normalize.undo",function(){t.undo(G)}),z(" fixupEdgeLabelCoords",function(){W(G)}),z(" undoCoordinateSystem",function(){l.undo(G)}),z(" translateGraph",function(){q(G)}),z(" assignNodeIntersects",function(){N(G)}),z(" reversePoints",function(){V(G)}),z(" acyclic.undo",function(){e.undo(G)})}function b(G,z){r.forEach(G.nodes(),function(Y){var te=G.node(Y),ue=z.node(Y);te&&(te.x=ue.x,te.y=ue.y,z.children(Y).length&&(te.width=ue.width,te.height=ue.height))}),r.forEach(G.edges(),function(Y){var te=G.edge(Y),ue=z.edge(Y);te.points=ue.points,r.has(ue,"x")&&(te.x=ue.x,te.y=ue.y)}),G.graph().width=z.graph().width,G.graph().height=z.graph().height}var w=["nodesep","edgesep","ranksep","marginx","marginy"],y={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],C=["width","height"],S={width:0,height:0},R=["minlen","weight","width","height","labeloffset"],_={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},A=["labelpos"];function P(G){var z=new g({multigraph:!0,compound:!0}),Y=fe(G.graph());return z.setGraph(r.merge({},y,j(Y,w),r.pick(Y,E))),r.forEach(G.nodes(),function(te){var ue=fe(G.node(te));z.setNode(te,r.defaults(j(ue,C),S)),z.setParent(te,G.parent(te))}),r.forEach(G.edges(),function(te){var ue=fe(G.edge(te));z.setEdge(te,r.merge({},_,j(ue,R),r.pick(ue,A)))}),z}function I(G){var z=G.graph();z.ranksep/=2,r.forEach(G.edges(),function(Y){var te=G.edge(Y);te.minlen*=2,te.labelpos.toLowerCase()!=="c"&&(z.rankdir==="TB"||z.rankdir==="BT"?te.width+=te.labeloffset:te.height+=te.labeloffset)})}function D(G){r.forEach(G.edges(),function(z){var Y=G.edge(z);if(Y.width&&Y.height){var te=G.node(z.v),ue=G.node(z.w),oe={rank:(ue.rank-te.rank)/2+te.rank,e:z};h.addDummyNode(G,"edge-proxy",oe,"_ep")}})}function L(G){var z=0;r.forEach(G.nodes(),function(Y){var te=G.node(Y);te.borderTop&&(te.minRank=G.node(te.borderTop).rank,te.maxRank=G.node(te.borderBottom).rank,z=r.max(z,te.maxRank))}),G.graph().maxRank=z}function M(G){r.forEach(G.nodes(),function(z){var Y=G.node(z);Y.dummy==="edge-proxy"&&(G.edge(Y.e).labelRank=Y.rank,G.removeNode(z))})}function q(G){var z=Number.POSITIVE_INFINITY,Y=0,te=Number.POSITIVE_INFINITY,ue=0,oe=G.graph(),X=oe.marginx||0,Q=oe.marginy||0;function ie(de){var we=de.x,Ae=de.y,ve=de.width,le=de.height;z=Math.min(z,we-ve/2),Y=Math.max(Y,we+ve/2),te=Math.min(te,Ae-le/2),ue=Math.max(ue,Ae+le/2)}r.forEach(G.nodes(),function(de){ie(G.node(de))}),r.forEach(G.edges(),function(de){var we=G.edge(de);r.has(we,"x")&&ie(we)}),z-=X,te-=Q,r.forEach(G.nodes(),function(de){var we=G.node(de);we.x-=z,we.y-=te}),r.forEach(G.edges(),function(de){var we=G.edge(de);r.forEach(we.points,function(Ae){Ae.x-=z,Ae.y-=te}),r.has(we,"x")&&(we.x-=z),r.has(we,"y")&&(we.y-=te)}),oe.width=Y-z+X,oe.height=ue-te+Q}function N(G){r.forEach(G.edges(),function(z){var Y=G.edge(z),te=G.node(z.v),ue=G.node(z.w),oe,X;Y.points?(oe=Y.points[0],X=Y.points[Y.points.length-1]):(Y.points=[],oe=ue,X=te),Y.points.unshift(h.intersectRect(te,oe)),Y.points.push(h.intersectRect(ue,X))})}function W(G){r.forEach(G.edges(),function(z){var Y=G.edge(z);if(r.has(Y,"x"))switch((Y.labelpos==="l"||Y.labelpos==="r")&&(Y.width-=Y.labeloffset),Y.labelpos){case"l":Y.x-=Y.width/2+Y.labeloffset;break;case"r":Y.x+=Y.width/2+Y.labeloffset;break}})}function V(G){r.forEach(G.edges(),function(z){var Y=G.edge(z);Y.reversed&&Y.points.reverse()})}function $(G){r.forEach(G.nodes(),function(z){if(G.children(z).length){var Y=G.node(z),te=G.node(Y.borderTop),ue=G.node(Y.borderBottom),oe=G.node(r.last(Y.borderLeft)),X=G.node(r.last(Y.borderRight));Y.width=Math.abs(X.x-oe.x),Y.height=Math.abs(ue.y-te.y),Y.x=oe.x+Y.width/2,Y.y=te.y+Y.height/2}}),r.forEach(G.nodes(),function(z){G.node(z).dummy==="border"&&G.removeNode(z)})}function Z(G){r.forEach(G.edges(),function(z){if(z.v===z.w){var Y=G.node(z.v);Y.selfEdges||(Y.selfEdges=[]),Y.selfEdges.push({e:z,label:G.edge(z)}),G.removeEdge(z)}})}function ee(G){var z=h.buildLayerMatrix(G);r.forEach(z,function(Y){var te=0;r.forEach(Y,function(ue,oe){var X=G.node(ue);X.order=oe+te,r.forEach(X.selfEdges,function(Q){h.addDummyNode(G,"selfedge",{width:Q.label.width,height:Q.label.height,rank:X.rank,order:oe+ ++te,e:Q.e,label:Q.label},"_se")}),delete X.selfEdges})})}function K(G){r.forEach(G.nodes(),function(z){var Y=G.node(z);if(Y.dummy==="selfedge"){var te=G.node(Y.e.v),ue=te.x+te.width/2,oe=te.y,X=Y.x-ue,Q=te.height/2;G.setEdge(Y.e,Y.label),G.removeNode(z),Y.label.points=[{x:ue+2*X/3,y:oe-Q},{x:ue+5*X/6,y:oe-Q},{x:ue+X,y:oe},{x:ue+5*X/6,y:oe+Q},{x:ue+2*X/3,y:oe+Q}],Y.label.x=Y.x,Y.label.y=Y.y}})}function j(G,z){return r.mapValues(r.pick(G,z),Number)}function fe(G){var z={};return r.forEach(G,function(Y,te){z[te.toLowerCase()]=Y}),z}return cm}var dm,e2;function ZW(){if(e2)return dm;e2=1;var r=qr(),e=Wt(),t=Tn().Graph;dm={debugOrdering:n};function n(a){var i=e.buildLayerMatrix(a),o=new t({compound:!0,multigraph:!0}).setGraph({});return r.forEach(a.nodes(),function(s){o.setNode(s,{label:s}),o.setParent(s,"layer"+a.node(s).rank)}),r.forEach(a.edges(),function(s){o.setEdge(s.v,s.w,{},s.name)}),r.forEach(i,function(s,u){var l="layer"+u;o.setNode(l,{rank:"same"}),r.reduce(s,function(f,d){return o.setEdge(f,d,{style:"invis"}),d})}),o}return dm}var vm,r2;function XW(){return r2||(r2=1,vm="0.8.5"),vm}var hm,t2;function QW(){return t2||(t2=1,hm={graphlib:Tn(),layout:YW(),debug:ZW(),util:{time:Wt().time,notime:Wt().notime},version:XW()}),hm}var JW=Zu.exports,n2;function eU(){return n2||(n2=1,(function(r,e){(function(n,a){r.exports=a(QW())})(JW,function(t){return(function(n){var a={};function i(o){if(a[o])return a[o].exports;var s=a[o]={i:o,l:!1,exports:{}};return n[o].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=n,i.c=a,i.d=function(o,s,u){i.o(o,s)||Object.defineProperty(o,s,{enumerable:!0,get:u})},i.r=function(o){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},i.t=function(o,s){if(s&1&&(o=i(o)),s&8||s&4&&typeof o=="object"&&o&&o.__esModule)return o;var u=Object.create(null);if(i.r(u),Object.defineProperty(u,"default",{enumerable:!0,value:o}),s&2&&typeof o!="string")for(var l in o)i.d(u,l,(function(f){return o[f]}).bind(null,l));return u},i.n=function(o){var s=o&&o.__esModule?function(){return o.default}:function(){return o};return i.d(s,"a",s),s},i.o=function(o,s){return Object.prototype.hasOwnProperty.call(o,s)},i.p="",i(i.s=0)})([(function(n,a,i){var o=i(1),s=function(l){l&&l("layout","dagre",o)};typeof cytoscape<"u"&&s(cytoscape),n.exports=s}),(function(n,a,i){function o(h){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?o=function(p){return typeof p}:o=function(p){return p&&typeof Symbol=="function"&&p.constructor===Symbol&&p!==Symbol.prototype?"symbol":typeof p},o(h)}var s=function(g){return typeof g=="function"},u=i(2),l=i(3),f=i(4);function d(h){this.options=l({},u,h)}d.prototype.run=function(){var h=this.options,g=this,p=h.cy,x=h.eles,b=function(K,j){return s(j)?j.apply(K,[K]):j},w=h.boundingBox||{x1:0,y1:0,w:p.width(),h:p.height()};w.x2===void 0&&(w.x2=w.x1+w.w),w.w===void 0&&(w.w=w.x2-w.x1),w.y2===void 0&&(w.y2=w.y1+w.h),w.h===void 0&&(w.h=w.y2-w.y1);var y=new f.graphlib.Graph({multigraph:!0,compound:!0}),E={},C=function(K,j){j!=null&&(E[K]=j)};C("nodesep",h.nodeSep),C("edgesep",h.edgeSep),C("ranksep",h.rankSep),C("rankdir",h.rankDir),C("align",h.align),C("ranker",h.ranker),C("acyclicer",h.acyclicer),y.setGraph(E),y.setDefaultEdgeLabel(function(){return{}}),y.setDefaultNodeLabel(function(){return{}});var S=x.nodes();s(h.sort)&&(S=S.sort(h.sort));for(var R=0;R<S.length;R++){var _=S[R],A=_.layoutDimensions(h);y.setNode(_.id(),{width:A.w,height:A.h,name:_.id()})}for(var P=0;P<S.length;P++){var I=S[P];I.isChild()&&y.setParent(I.id(),I.parent().id())}var D=x.edges().stdFilter(function(ee){return!ee.source().isParent()&&!ee.target().isParent()});s(h.sort)&&(D=D.sort(h.sort));for(var L=0;L<D.length;L++){var M=D[L];y.setEdge(M.source().id(),M.target().id(),{minlen:b(M,h.minLen),weight:b(M,h.edgeWeight),name:M.id()},M.id())}f.layout(y);for(var q=y.nodes(),N=0;N<q.length;N++){var W=q[N],V=y.node(W);p.getElementById(W).scratch().dagre=V}var $;h.boundingBox?($={x1:1/0,x2:-1/0,y1:1/0,y2:-1/0},S.forEach(function(ee){var K=ee.scratch().dagre;$.x1=Math.min($.x1,K.x),$.x2=Math.max($.x2,K.x),$.y1=Math.min($.y1,K.y),$.y2=Math.max($.y2,K.y)}),$.w=$.x2-$.x1,$.h=$.y2-$.y1):$=w;var Z=function(K){if(h.boundingBox){var j=$.w===0?0:(K.x-$.x1)/$.w,fe=$.h===0?0:(K.y-$.y1)/$.h;return{x:w.x1+j*w.w,y:w.y1+fe*w.h}}else return K};return S.layoutPositions(g,h,function(ee){ee=o(ee)==="object"?ee:this;var K=ee.scratch().dagre;return Z({x:K.x,y:K.y})}),this},n.exports=d}),(function(n,a){var i={nodeSep:void 0,edgeSep:void 0,rankSep:void 0,rankDir:void 0,align:void 0,acyclicer:void 0,ranker:void 0,minLen:function(s){return 1},edgeWeight:function(s){return 1},fit:!0,padding:30,spacingFactor:void 0,nodeDimensionsIncludeLabels:!1,animate:!1,animateFilter:function(s,u){return!0},animationDuration:500,animationEasing:void 0,boundingBox:void 0,transform:function(s,u){return u},ready:function(){},sort:void 0,stop:function(){}};n.exports=i}),(function(n,a){n.exports=Object.assign!=null?Object.assign.bind(Object):function(i){for(var o=arguments.length,s=new Array(o>1?o-1:0),u=1;u<o;u++)s[u-1]=arguments[u];return s.forEach(function(l){Object.keys(l).forEach(function(f){return i[f]=l[f]})}),i}}),(function(n,a){n.exports=t})])})})(Zu)),Zu.exports}var rU=eU();const tU=gl(rU);var Xu={exports:{}},gm,a2;function nU(){if(a2)return gm;a2=1;var r="Expected a function",e="__lodash_hash_undefined__",t="[object Function]",n="[object GeneratorFunction]",a=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,o=typeof St=="object"&&St&&St.Object===Object&&St,s=typeof self=="object"&&self&&self.Object===Object&&self,u=o||s||Function("return this")();function l(ve,le){return ve==null?void 0:ve[le]}function f(ve){var le=!1;if(ve!=null&&typeof ve.toString!="function")try{le=!!(ve+"")}catch{}return le}var d=Array.prototype,h=Function.prototype,g=Object.prototype,p=u["__core-js_shared__"],x=(function(){var ve=/[^.]+$/.exec(p&&p.keys&&p.keys.IE_PROTO||"");return ve?"Symbol(src)_1."+ve:""})(),b=h.toString,w=g.hasOwnProperty,y=g.toString,E=RegExp("^"+b.call(w).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),C=d.splice,S=ue(u,"Map"),R=ue(Object,"create");function _(ve){var le=-1,Me=ve?ve.length:0;for(this.clear();++le<Me;){var Se=ve[le];this.set(Se[0],Se[1])}}function A(){this.__data__=R?R(null):{}}function P(ve){return this.has(ve)&&delete this.__data__[ve]}function I(ve){var le=this.__data__;if(R){var Me=le[ve];return Me===e?void 0:Me}return w.call(le,ve)?le[ve]:void 0}function D(ve){var le=this.__data__;return R?le[ve]!==void 0:w.call(le,ve)}function L(ve,le){var Me=this.__data__;return Me[ve]=R&&le===void 0?e:le,this}_.prototype.clear=A,_.prototype.delete=P,_.prototype.get=I,_.prototype.has=D,_.prototype.set=L;function M(ve){var le=-1,Me=ve?ve.length:0;for(this.clear();++le<Me;){var Se=ve[le];this.set(Se[0],Se[1])}}function q(){this.__data__=[]}function N(ve){var le=this.__data__,Me=z(le,ve);if(Me<0)return!1;var Se=le.length-1;return Me==Se?le.pop():C.call(le,Me,1),!0}function W(ve){var le=this.__data__,Me=z(le,ve);return Me<0?void 0:le[Me][1]}function V(ve){return z(this.__data__,ve)>-1}function $(ve,le){var Me=this.__data__,Se=z(Me,ve);return Se<0?Me.push([ve,le]):Me[Se][1]=le,this}M.prototype.clear=q,M.prototype.delete=N,M.prototype.get=W,M.prototype.has=V,M.prototype.set=$;function Z(ve){var le=-1,Me=ve?ve.length:0;for(this.clear();++le<Me;){var Se=ve[le];this.set(Se[0],Se[1])}}function ee(){this.__data__={hash:new _,map:new(S||M),string:new _}}function K(ve){return te(this,ve).delete(ve)}function j(ve){return te(this,ve).get(ve)}function fe(ve){return te(this,ve).has(ve)}function G(ve,le){return te(this,ve).set(ve,le),this}Z.prototype.clear=ee,Z.prototype.delete=K,Z.prototype.get=j,Z.prototype.has=fe,Z.prototype.set=G;function z(ve,le){for(var Me=ve.length;Me--;)if(de(ve[Me][0],le))return Me;return-1}function Y(ve){if(!Ae(ve)||X(ve))return!1;var le=we(ve)||f(ve)?E:i;return le.test(Q(ve))}function te(ve,le){var Me=ve.__data__;return oe(le)?Me[typeof le=="string"?"string":"hash"]:Me.map}function ue(ve,le){var Me=l(ve,le);return Y(Me)?Me:void 0}function oe(ve){var le=typeof ve;return le=="string"||le=="number"||le=="symbol"||le=="boolean"?ve!=="__proto__":ve===null}function X(ve){return!!x&&x in ve}function Q(ve){if(ve!=null){try{return b.call(ve)}catch{}try{return ve+""}catch{}}return""}function ie(ve,le){if(typeof ve!="function"||le&&typeof le!="function")throw new TypeError(r);var Me=function(){var Se=arguments,Ee=le?le.apply(this,Se):Se[0],re=Me.cache;if(re.has(Ee))return re.get(Ee);var ce=ve.apply(this,Se);return Me.cache=re.set(Ee,ce),ce};return Me.cache=new(ie.Cache||Z),Me}ie.Cache=Z;function de(ve,le){return ve===le||ve!==ve&&le!==le}function we(ve){var le=Ae(ve)?y.call(ve):"";return le==t||le==n}function Ae(ve){var le=typeof ve;return!!ve&&(le=="object"||le=="function")}return gm=ie,gm}var pm,i2;function aU(){if(i2)return pm;i2=1;var r="Expected a function",e=NaN,t="[object Symbol]",n=/^\s+|\s+$/g,a=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=parseInt,u=typeof St=="object"&&St&&St.Object===Object&&St,l=typeof self=="object"&&self&&self.Object===Object&&self,f=u||l||Function("return this")(),d=Object.prototype,h=d.toString,g=Math.max,p=Math.min,x=function(){return f.Date.now()};function b(R,_,A){var P,I,D,L,M,q,N=0,W=!1,V=!1,$=!0;if(typeof R!="function")throw new TypeError(r);_=S(_)||0,y(A)&&(W=!!A.leading,V="maxWait"in A,D=V?g(S(A.maxWait)||0,_):D,$="trailing"in A?!!A.trailing:$);function Z(ue){var oe=P,X=I;return P=I=void 0,N=ue,L=R.apply(X,oe),L}function ee(ue){return N=ue,M=setTimeout(fe,_),W?Z(ue):L}function K(ue){var oe=ue-q,X=ue-N,Q=_-oe;return V?p(Q,D-X):Q}function j(ue){var oe=ue-q,X=ue-N;return q===void 0||oe>=_||oe<0||V&&X>=D}function fe(){var ue=x();if(j(ue))return G(ue);M=setTimeout(fe,K(ue))}function G(ue){return M=void 0,$&&P?Z(ue):(P=I=void 0,L)}function z(){M!==void 0&&clearTimeout(M),N=0,P=q=I=M=void 0}function Y(){return M===void 0?L:G(x())}function te(){var ue=x(),oe=j(ue);if(P=arguments,I=this,q=ue,oe){if(M===void 0)return ee(q);if(V)return M=setTimeout(fe,_),Z(q)}return M===void 0&&(M=setTimeout(fe,_)),L}return te.cancel=z,te.flush=Y,te}function w(R,_,A){var P=!0,I=!0;if(typeof R!="function")throw new TypeError(r);return y(A)&&(P="leading"in A?!!A.leading:P,I="trailing"in A?!!A.trailing:I),b(R,_,{leading:P,maxWait:_,trailing:I})}function y(R){var _=typeof R;return!!R&&(_=="object"||_=="function")}function E(R){return!!R&&typeof R=="object"}function C(R){return typeof R=="symbol"||E(R)&&h.call(R)==t}function S(R){if(typeof R=="number")return R;if(C(R))return e;if(y(R)){var _=typeof R.valueOf=="function"?R.valueOf():R;R=y(_)?_+"":_}if(typeof R!="string")return R===0?R:+R;R=R.replace(n,"");var A=i.test(R);return A||o.test(R)?s(R.slice(2),A?2:8):a.test(R)?e:+R}return pm=w,pm}var iU=Xu.exports,o2;function oU(){return o2||(o2=1,(function(r,e){(function(n,a){r.exports=a(nU(),aU())})(iU,function(t,n){return(function(a){var i={};function o(s){if(i[s])return i[s].exports;var u=i[s]={i:s,l:!1,exports:{}};return a[s].call(u.exports,u,u.exports,o),u.l=!0,u.exports}return o.m=a,o.c=i,o.i=function(s){return s},o.d=function(s,u,l){o.o(s,u)||Object.defineProperty(s,u,{configurable:!1,enumerable:!0,get:l})},o.n=function(s){var u=s&&s.__esModule?function(){return s.default}:function(){return s};return o.d(u,"a",u),u},o.o=function(s,u){return Object.prototype.hasOwnProperty.call(s,u)},o.p="",o(o.s=12)})([(function(a,i,o){a.exports=Object.assign!=null?Object.assign.bind(Object):function(s){for(var u=arguments.length,l=Array(u>1?u-1:0),f=1;f<u;f++)l[f-1]=arguments[f];return l.filter(function(d){return d!=null}).forEach(function(d){Object.keys(d).forEach(function(h){return s[h]=d[h]})}),s}}),(function(a,i,o){var s=o(10),u=o(0);a.exports=function(l){var f=this;return new s(u({cy:f},l))}}),(function(a,i,o){function s(){if(this.saveGestureState(),this.cy.zoomingEnabled(!1).panningEnabled(!1).boxSelectionEnabled(!1),this.options.disableBrowserGestures){var f=this.windowListenerOptions;window.addEventListener("touchstart",this.preventDefault,f),window.addEventListener("touchmove",this.preventDefault,f),window.addEventListener("wheel",this.preventDefault,f)}return this}function u(){if(this.cy.zoomingEnabled(this.lastZoomingEnabled).panningEnabled(this.lastPanningEnabled).boxSelectionEnabled(this.lastBoxSelectionEnabled),this.options.disableBrowserGestures){var f=this.windowListenerOptions;window.removeEventListener("touchstart",this.preventDefault,f),window.removeEventListener("touchmove",this.preventDefault,f),window.removeEventListener("wheel",this.preventDefault,f)}return this}function l(){var f=this.cy;return this.lastPanningEnabled=f.panningEnabled(),this.lastZoomingEnabled=f.zoomingEnabled(),this.lastBoxSelectionEnabled=f.boxSelectionEnabled(),this}a.exports={disableGestures:s,resetGestures:u,saveGestureState:l}}),(function(a,i,o){function s(){var u=this,l=this.cy,f=this.options;return this.addListener(l,"drag",function(){return u.grabbingNode=!0}),this.addListener(l,"free",function(){return u.grabbingNode=!1}),this.addListener(l,"tapstart","node",function(d){var h=d.target;u.drawMode&&u.start(h)}),this.addListener(l,"tapdrag",function(d){u.update(d.position)}),this.addListener(l,"tapdragover","node",function(d){f.snap||u.preview(d.target)}),this.addListener(l,"tapdragout","node",function(d){f.snap||u.unpreview(d.target)}),this.addListener(l,"tapend",function(){u.stop()}),this}a.exports={addCytoscapeListeners:s}}),(function(a,i,o){var s={canConnect:function(l,f){return!l.same(f)},edgeParams:function(l,f){return{}},hoverDelay:150,snap:!0,snapThreshold:50,snapFrequency:15,noEdgeEventsInDraw:!0,disableBrowserGestures:!0};a.exports=s}),(function(a,i,o){function s(f){var d=this.cy;return this.drawMode=f??!this.drawMode,this.drawMode?(this.prevUngrabifyState=d.autoungrabify(),d.autoungrabify(!0),this.emit("drawon")):(d.autoungrabify(this.prevUngrabifyState),this.emit("drawoff")),this}function u(){return this.toggleDrawMode(!0)}function l(){return this.toggleDrawMode(!1)}a.exports={toggleDrawMode:s,enableDrawMode:u,disableDrawMode:l}}),(function(a,i,o){var s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(w){return typeof w}:function(w){return w&&typeof Symbol=="function"&&w.constructor===Symbol&&w!==Symbol.prototype?"symbol":typeof w},u=o(0),l=function(y){return(typeof y>"u"?"undefined":s(y))===s("")},f=function(y){return(typeof y>"u"?"undefined":s(y))===s([])&&y.length!=null};function d(w,y,E){var C={};return u(C,y,w),u(C.data,y.data,w.data),l(y.classes)?C.classes=y.classes+" "+E:f(y.classes)?C.classes=y.classes.join(" ")+" "+E:C.classes=E,C}function h(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,y=this.cy;this.options;var E=this.presumptiveTargets,C=this.previewEles,S=this.active,R=this.sourceNode,_=this.targetNode,A=w?"eh-preview":"",P=y.collection(),I=this.canConnect(_);if(S&&I){if(!_||_.size()===0){C.remove(),this.emit("cancel",this.mp(),R,E);return}if(!w){C.removeClass("eh-preview").style("events",""),this.emit("complete",this.mp(),R,_,C);return}var D=y.add(d({group:"edges",data:{source:R.id(),target:_.id()}},this.edgeParams(_),A));return P=P.merge(D),w?(this.previewEles=P,P.style("events","no")):(P.style("events",""),this.emit("complete",this.mp(),R,_,P)),this}}function g(){return this.makeEdges(!0),this}function p(){return this.previewEles.nonempty()&&this.previewEles.inside()}function x(){return this.previewShown()&&this.previewEles.remove(),this}function b(){var w=this,y=this.sourceNode,E=this.ghostNode,C=this.cy,S=this.mx,R=this.my,_=S,A=R,P=void 0,I=void 0;if(y)return(!E||E.length===0||E.removed())&&(I=this.ghostEles=C.collection(),C.batch(function(){E=w.ghostNode=C.add({group:"nodes",classes:"eh-ghost eh-ghost-node",position:{x:0,y:0}}),E.style({"background-color":"blue",width:1e-4,height:1e-4,opacity:0,events:"no"});var D={};P=C.add(u({},D,{group:"edges",data:u({},D.data,{source:y.id(),target:E.id()}),classes:"eh-ghost eh-ghost-edge"})),P.style({events:"no"})}),I.merge(E).merge(P)),E.position({x:_,y:A}),this}a.exports={makeEdges:h,makePreview:g,removePreview:x,previewShown:p,updateEdge:b}}),(function(a,i,o){function s(){return this.options.noEdgeEventsInDraw&&this.cy.edges().style("events","no"),this}function u(){return this.options.noEdgeEventsInDraw&&this.cy.edges().style("events",""),this}a.exports={disableEdgeEvents:s,enableEdgeEvents:u}}),(function(a,i,o){function s(){return this.enabled=!0,this.emit("enable"),this}function u(){return this.enabled=!1,this.emit("disable"),this}a.exports={enable:s,disable:u}}),(function(a,i,o){var s=o(13),u=Math.sqrt(2);function l(y){var E=this.previewEles,C=this.ghostEles,S=function(L){return E.anySame(L)},R=function(L){return C.anySame(L)},_=function(L){return S(L)||R(L)},A=this.enabled,P=this.active,I=this.grabbingNode;return A&&!P&&!I&&y!=null&&y.nonempty()&&!_(y)}function f(y){return this.canStartOn(y)&&this.drawMode}function d(y){return this.canStartOn(y)&&!this.drawMode}function h(y){var E=this;if(this.canStartOn(y)){this.active=!0,this.sourceNode=y,this.sourceNode.addClass("eh-source"),this.disableGestures(),this.disableEdgeEvents();var C=function(R){return R.id()};this.canConnect=s(function(S){return E.options.canConnect(E.sourceNode,S)},C),this.edgeParams=s(function(S){return E.options.edgeParams(E.sourceNode,S)},C),this.emit("start",this.hp(),y)}}function g(y){if(this.active){var E=y;return this.mx=E.x,this.my=E.y,this.updateEdge(),this.throttledSnap(),this}}function p(){if(!this.active||!this.options.snap)return!1;var y=this.cy,E=this.targetNode,C=this.options.snapThreshold,S=this.mp(),R=this.previewEles,_=this.ghostNode,A=function(z){return u*Math.max(z.outerWidth(),z.outerHeight())/2},P=function(z,Y,te,ue){var oe=te-z,X=ue-Y;return oe*oe+X*X},I=function(z,Y){return P(z.x,z.y,Y.x,Y.y)},D=function(z){return I(z.position(),S)},L=function(z){var Y=A(z),te=Y+C;return te*te},M=function(z){return D(z)<=L(z)},q=function(z){var Y=z.position(),te=z.outerWidth()/2,ue=z.outerHeight()/2,oe=Y.x,X=Y.y,Q=S.x,ie=S.y,de=oe-te,we=oe+te,Ae=X-ue,ve=X+ue,le=de<=Q&&Q<=we,Me=Ae<=ie&&ie<=ve;if(le&&Me)return 0;if(le){var Se=ie-Ae,Ee=ie-ve;return Math.min(Se*Se,Ee*Ee)}else if(Me){var re=Q-de,ce=Q-we;return Math.min(re*re,ce*ce)}else return Q<de&&ie<Ae?P(Q,ie,de,Ae):Q>we&&ie<Ae?P(Q,ie,we,Ae):Q<de&&ie>ve?P(Q,ie,de,ve):P(Q,ie,we,ve)},N=function(z,Y){return q(z)-q(Y)},W=N,V=!1,$=function(z){var Y=S,te=z.outerWidth(),ue=te/2,oe=z.outerHeight(),X=oe/2,Q=z.position(),ie=Q.x-ue,de=Q.x+ue,we=Q.y-X,Ae=Q.y+X;return ie<=Y.x&&Y.x<=de&&we<=Y.y&&Y.y<=Ae},Z=function(z){return z.same(R)||z.same(_)},ee=y.nodes(function(G){return!Z(G)&&M(G)}).sort(W),K=!1;E.nonempty()&&!M(E)&&this.unpreview(E);for(var j=0;j<ee.length;j++){var fe=ee[j];if(!(fe.isParent()&&$(fe))&&!(fe.isChild()&&!$(fe.parent()))&&(fe.same(E)||this.preview(fe,V))){K=!0;break}}return K}function x(y){var E=this,C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,S=this.options,R=this.sourceNode,_=this.ghostNode,A=this.ghostEles,P=this.presumptiveTargets,I=this.previewEles,D=this.active,L=R,M=y.same(_),q=!this.canConnect(y),N=y.same(this.targetNode);if(!D||M||q||N)return!1;this.targetNode.nonempty()&&this.unpreview(this.targetNode),clearTimeout(this.previewTimeout);var W=function(){E.targetNode=y,P.merge(y),y.addClass("eh-presumptive-target"),y.addClass("eh-target"),E.emit("hoverover",E.mp(),L,y),y.addClass("eh-preview"),A.addClass("eh-preview-active"),R.addClass("eh-preview-active"),y.addClass("eh-preview-active"),E.makePreview(),E.emit("previewon",E.mp(),L,y,I)};return C&&S.hoverDelay>0?this.previewTimeout=setTimeout(W,S.hoverDelay):W(),!0}function b(y){if(this.active){var E=this.previewTimeout,C=this.sourceNode,S=this.previewEles,R=this.ghostEles,_=this.cy;clearTimeout(E),this.previewTimeout=null;var A=C;return y.removeClass("eh-preview eh-target eh-presumptive-target eh-preview-active"),R.removeClass("eh-preview-active"),C.removeClass("eh-preview-active"),this.targetNode=_.collection(),this.removePreview(A,y),this.emit("hoverout",this.mp(),A,y),this.emit("previewoff",this.mp(),A,y,S),this}}function w(){if(this.active){var y=this.sourceNode,E=this.targetNode,C=this.ghostEles,S=this.presumptiveTargets;return clearTimeout(this.previewTimeout),y.removeClass("eh-source eh-preview-active"),E.removeClass("eh-target eh-preview eh-hover eh-preview-active"),S.removeClass("eh-presumptive-target"),this.makeEdges(),C.remove(),this.clearCollections(),this.resetGestures(),this.enableEdgeEvents(),this.active=!1,this.emit("stop",this.mp(),y),this}}a.exports={start:h,update:g,preview:x,unpreview:b,stop:w,snap:p,canStartOn:l,canStartDrawModeOn:f,canStartNonDrawModeOn:d}}),(function(a,i,o){var s=o(4),u=o(0),l=o(14),f=o(2),d=o(3),h=o(5),g=o(6),p=o(8),x=o(9),b=o(11),w=o(7);function y(S){var R=S.cy;this.cy=R,this.listeners=[],this.enabled=!0,this.drawMode=!1,this.active=!1,this.grabbingNode=!1,this.clearCollections(),this.mx=0,this.my=0,this.options=u({},s,S),this.saveGestureState(),this.addListeners(),this.throttledSnap=l(this.snap.bind(this),1e3/S.snapFrequency),this.preventDefault=function(P){return P.preventDefault()},this.canConnect=function(){return!1};var _=!1;try{var A=Object.defineProperty({},"passive",{get:function(){_=!0}});window.addEventListener("test",null,A)}catch{}_?this.windowListenerOptions={capture:!0,passive:!1}:this.windowListenerOptions=!0}var E=y.prototype={},C=function(R){return u(E,R)};E.destroy=function(){this.removeListeners()},E.setOptions=function(S){u(this.options,S)},E.mp=function(){return{x:this.mx,y:this.my}},E.hp=function(){return{x:this.hx,y:this.hy}},E.clearCollections=function(){var S=this.cy;this.previewEles=S.collection(),this.ghostEles=S.collection(),this.ghostNode=S.collection(),this.sourceNode=S.collection(),this.targetNode=S.collection(),this.presumptiveTargets=S.collection()},[f,d,h,g,p,x,b,w].forEach(C),a.exports=y}),(function(a,i,o){var s=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(x){return typeof x}:function(x){return x&&typeof Symbol=="function"&&x.constructor===Symbol&&x!==Symbol.prototype?"symbol":typeof x};function u(){var x=this;return this.addCytoscapeListeners(),this.addListener(this.cy,"destroy",function(){return x.destroy()}),this}function l(){for(var x=this.listeners.length-1;x>=0;x--){var b=this.listeners[x];this.removeListener(b.target,b.event,b.selector,b.callback,b.options)}return this}function f(x,b,w,y,E){return(typeof w>"u"?"undefined":s(w))!==s("")&&(y=w,E=y,w=null),E==null&&(E=!1),{target:x,event:b,selector:w,callback:y,options:E}}function d(x){return x instanceof Element}function h(x,b,w,y,E){var C=f(x,b,w,y,E);return this.listeners.push(C),d(C.target)?C.target.addEventListener(C.event,C.callback,C.options):C.selector?C.target.addListener(C.event,C.selector,C.callback,C.options):C.target.addListener(C.event,C.callback,C.options),this}function g(x,b,w,y,E){for(var C=f(x,b,w,y,E),S=this.listeners.length-1;S>=0;S--){var R=this.listeners[S];if(C.target===R.target&&C.event===R.event&&(C.selector==null||C.selector===R.selector)&&(C.callback==null||C.callback===R.callback)){this.listeners.splice(S,1),d(C.target)?C.target.removeEventListener(C.event,C.callback,C.options):C.selector?C.target.removeListener(C.event,C.selector,C.callback,C.options):C.target.removeListener(C.event,C.callback,C.options);break}}return this}function p(x,b){for(var w=this.cy,y=arguments.length,E=Array(y>2?y-2:0),C=2;C<y;C++)E[C-2]=arguments[C];return w.emit({type:"eh"+x,position:b},E),this}a.exports={addListener:h,addListeners:u,removeListener:g,removeListeners:l,emit:p}}),(function(a,i,o){var s=o(1),u=function(f){f&&f("core","edgehandles",s)};typeof cytoscape<"u"&&u(cytoscape),a.exports=u}),(function(a,i){a.exports=t}),(function(a,i){a.exports=n})])})})(Xu)),Xu.exports}var sU=oU();const uU=gl(sU);var ym,s2;function lU(){if(s2)return ym;s2=1;class r{constructor(n,a={}){this._cy=n,this._params=a,this._node_dom={};let i=n.container();if(a.dom_container)this._nodes_dom_container=a.dom_container;else{let s=document.createElement("div");s.style.position="absolute",s.style.zIndex=10,i.querySelector("canvas").parentNode.appendChild(s),this._nodes_dom_container=s}this._resize_observer=new ResizeObserver(s=>{for(let u of s){let l=u.target,f=l.__cy_id;n.getElementById(f).style({width:l.offsetWidth,height:l.offsetHeight,shape:"rectangle"})}}),n.on("add","node",s=>{this._add_node(s.target)}),n.on("remove","node",s=>{this._remove_node(s.target)});for(let s of n.nodes())this._add_node(s);this._nodes_dom_container.style.willChange="transform",this._nodes_dom_container.style.backfaceVisibility="hidden";let o=null;n.on("pan zoom",()=>{o===null&&(o=requestAnimationFrame(()=>{o=null;let s=n.pan(),u=n.zoom(),l="translate3d("+s.x+"px,"+s.y+"px,0) scale("+u+")";this._nodes_dom_container.style.transform=l}))}),this._panZoomRafId=o,n.on("position bounds","node",s=>{let u=s.target,l=u.id();if(!this._node_dom[l])return;let f=this._node_dom[l],d=`translate(-50%, -50%) translate3d(${u.position("x").toFixed(2)}px, ${u.position("y").toFixed(2)}px, 0)`;f.style.transform=d,f.style.display="inline",f.style.position="absolute",f.style["z-index"]=10})}_add_node(n){let a=n.data();a.dom&&(a.skip_node_append!==!0&&this._nodes_dom_container.appendChild(a.dom),a.dom.__cy_id=n.id(),a.dom.style.willChange="transform",a.dom.style.backfaceVisibility="hidden",this._node_dom[n.id()]=a.dom,this._resize_observer.observe(a.dom))}_remove_node(n){let a=n.id(),i=this._node_dom[a];i&&(this._resize_observer.unobserve(i),i.parentNode===this._nodes_dom_container&&this._nodes_dom_container.removeChild(i),delete this._node_dom[a])}node_dom(n){return this._node_dom[n]}update(n,a){let i=this._cy.getElementById(n);if(!i){console.warn(`Node with id ${n} not found`);return}let o=this._node_dom[n];if(!o){console.warn(`DOM element for node ${n} not found`);return}a(o),i.data("dom",o),this._cy.trigger("position",["node",i])}remove(){for(let n in this._node_dom)this._resize_observer.unobserve(this._node_dom[n]);for(;this._nodes_dom_container.firstChild;)this._nodes_dom_container.removeChild(this._nodes_dom_container.firstChild);this._node_dom={},this._cy.removeListener("add","node"),this._cy.removeListener("remove","node"),this._cy.removeListener("pan zoom"),this._cy.removeListener("position bounds","node"),this._params.dom_container||this._nodes_dom_container.parentNode.removeChild(this._nodes_dom_container),this._panZoomRafId!==null&&cancelAnimationFrame(this._panZoomRafId),this._cy=null,this._params=null,this._nodes_dom_container=null,this._resize_observer=null}}function e(t){t&&t("core","domNode",function(n,a){return new r(this,n,a)})}return typeof cytoscape<"u"&&e(cytoscape),ym=e,ym}var fU=lU();const cU=gl(fU);vn.prototype.hasInitialised||(vn.use(tU),vn.use(uU),vn.use(cU),vn.prototype.hasInitialised=!0);function dU({cyParams:r,cyInst:e,layoutParams:t,layoutDebounce:n=50,children:a,init:i=()=>{},onCyInit:o}){const[s,u]=xe.useState(!1),l=xe.useRef(null),f=xe.useRef(null),d=xe.useRef(null),h=xe.useRef(!0),g=xe.useRef(t);g.current=t;const p=xe.useCallback(()=>{var w;d.current!==null&&d.current.stop(),f.current&&(d.current=f.current.layout(g.current),(w=d.current)==null||w.run())},[]),x=xe.useMemo(()=>xw(p,n),[p,n]);xe.useEffect(()=>()=>{x.cancel()},[x]),xe.useEffect(()=>{var C;if(!l.current)return;const w=vn({container:l.current,...r}),y=(C=l.current.parentElement)==null?void 0:C.querySelector(".cytoscape-react-nodes-and-edges");if(y&&w.domNode({dom_container:y}),f.current=e||w,l.current&&(l.current.cy=f.current),o==null||o(f.current),i(w),l.current&&f.current){const S=l.current.parentElement;let R=0,_=0;S&&(R=S.clientHeight,_=S.clientWidth,R===0&&(R=window.innerHeight-S.getBoundingClientRect().top-100),_===0&&(_=window.innerWidth)),R>0&&_>0&&(l.current.style.width=`${_}px`,l.current.style.height=`${R}px`),f.current.resize(),r.zoom&&r.pan&&f.current.viewport({zoom:r.zoom,pan:r.pan})}u(!0);const E=new ResizeObserver(xw(()=>{if(l.current&&f.current){const S=l.current.parentElement;let R=0,_=0;S&&(R=S.clientHeight,_=S.clientWidth,R===0&&(R=window.innerHeight-S.getBoundingClientRect().top-100),_===0&&(_=window.innerWidth),R>0&&_>0&&(l.current.style.width=`${_}px`,l.current.style.height=`${R}px`));const A=f.current.zoom()!==void 0?{zoom:f.current.zoom(),pan:f.current.pan()}:null;f.current.resize(),A&&f.current.viewport(A)}},50));return l.current&&E.observe(l.current),()=>{E.disconnect();try{w.destroy()}catch{}f.current=null,u(!1)}},[]),xe.useEffect(()=>{h.current?(h.current=!1,p()):x()},[s,t,x,p]);const b=xe.useMemo(()=>{var w;return f.current!==null?((w=xe.Children.map(a,y=>{var E;return y?xe.cloneElement(y,{key:(E=y==null?void 0:y.props)==null?void 0:E.id,cytoInstance:f.current,layout:x}):null}))==null?void 0:w.filter(Boolean))||[]:[]},[a,s,x]);return H.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",background:"transparent"},children:[H.jsx("div",{ref:l,className:"cytoscape-react-cy-container",style:{width:"100%",height:"100%",position:"relative",background:"transparent"}}),H.jsx("div",{className:"cytoscape-react-nodes-and-edges",style:{pointerEvents:"none",position:"absolute",top:0,left:0,transformOrigin:"0 0",zIndex:10},children:b})]})}function vU({cytoInstance:r,id:e,parent:t,label:n,children:a,layout:i,classes:o,styleCallback:s,parentViewProps:u}){const l=xe.useRef(null),f=xe.useRef("");function d(p){s&&p.isParent()&&(p.style("shape","roundrectangle"),p.style(s(u)))}xe.useEffect(()=>{try{if(l.current){const p={id:e,dom:l.current};t&&(p.parent=t),n&&(p.label=n);const x=r.add({data:p,classes:o});d(x),i()}}catch{}return()=>{r.getElementById(e).remove(),i()}},[l,t,n]),xe.useEffect(()=>{const p=l.current;if(!p||typeof ResizeObserver>"u")return;const x=new ResizeObserver(()=>{const b=`${p.offsetWidth}x${p.offsetHeight}`;b!==f.current&&(f.current=b,i())});return x.observe(p),()=>x.disconnect()},[i]),xe.useEffect(()=>{if(!s)return;const p=r.getElementById(e);p.length&&d(p)},[s,u]);function h(p){return xe.cloneElement(p,{cytoInstance:r,layout:i})}const g=xe.Children.map(a,h);return H.jsx("div",{ref:l,className:"cytoscape-react-node",children:g})}const wI=.4,hU=r=>[{selector:"node",style:{"outline-opacity":0,"background-opacity":0,"background-color":"transparent","border-color":"transparent",color:"transparent","border-opacity":0,"text-valign":"center","text-halign":"center","border-width":0,"outline-width":0,width:60,height:60}},{selector:"node:selected",style:{"overlay-opacity":0,"overlay-color":"transparent"}},{selector:"node:active",style:{"overlay-opacity":0,"overlay-color":"transparent"}},{selector:":parent",style:{shape:"round-rectangle","background-opacity":wI,"corner-radius":50,"line-color":r("light"),"background-color":r(),"border-color":r(),"border-width":6,"border-style":"solid","border-opacity":1,padding:"120px","text-valign":"top","font-size":"70px","font-weight":"bold","text-margin-y":90,"text-background-opacity":0,"text-background-padding":"45px","z-index":1e3,"compound-sizing-wrt-labels":"include",label:"data(label)"}},{selector:"edge",style:{width:6,label:"data(label)","z-index":-100,"control-point-step-size":10,"taxi-direction":"horizontal","curve-style":"round-taxi","edge-distances":"intersection","line-color":r("light"),color:r("light"),"text-rotation":"autorotate","target-arrow-color":r("light"),"source-arrow-color":r("light"),"target-arrow-shape":"triangle","arrow-scale":"3","text-background-color":r("dark"),"text-background-opacity":1,"text-background-padding":"15px","taxi-radius":500,"source-arrow-fill":"filled","target-arrow-fill":"filled","text-max-width":"200px","font-size":"45px","text-wrap":"wrap","text-margin-x":50,"transition-duration":"0.5s","source-endpoint":"outside-to-node","target-endpoint":"outside-to-node","source-distance-from-node":80,"target-distance-from-node":80}},{selector:"edge:loop",style:{"curve-style":"bezier","control-point-step-size":350,"loop-direction":"-90deg","loop-sweep":"-60deg","source-distance-from-node":0,"target-distance-from-node":0}}],xI={padding:20,motionBlur:!1,compound:!0,pixelRatio:"auto",zoomingEnabled:!0,userZoomingEnabled:!0,dragpan:!0,avoidOverlap:!0,panningEnabled:!0,userPanningEnabled:!0,boxSelectionEnabled:!1,selectionType:"additive",minZoom:.01,maxZoom:1.5,autoungrabify:!0,styleEnabled:!0,hideEdgesOnViewport:!1,hideLabelsOnViewport:!0,headless:!1,touchTapThreshold:8,desktopTapThreshold:4,touchHoldDuration:500,desktopHoldDuration:1e3,autolock:!1,autounselectify:!1,wheelPanEnabled:!0,wheelPanThreshold:1,wheelPanDebounce:10,wheelAction:"pan"},EI={...xI,pixelRatio:1,motionBlur:!0,textureOnViewport:!0,wheelPanDebounce:20},gU={...EI,hideEdgesOnViewport:!0,hideLabelsOnViewport:!0},pU={name:"dagre",rankDir:"LR",fit:!1,padding:20,spacingFactor:1.3,animate:!1,nodeDimensionsIncludeLabels:!0,ranker:"network-simplex",rankSep:10,nodeSep:5,edgeSep:10,avoidOverlap:!0,edgeWeight:function(r){return 1},minLen:function(r){return 1},useSimpleEdgeFunction:!0,edgeRouting:!0,controlPoints:!0},L0=({name:r,...e})=>{const[t,n]=xe.useState(null),[a,i]=xe.useState(!0),[o,s]=xe.useState(!1);return xe.useEffect(()=>{if(!r||r.length<2){n(null),i(!1);return}i(!0),s(!1),(async()=>{try{let l;if(r.startsWith("Md"))l="md";else if(r.startsWith("Fa"))l="fa6";else if(r.startsWith("Io5"))l="io5";else if(r.startsWith("Io"))l="io";else if(r.startsWith("Ti"))l="ti";else if(r.startsWith("Go"))l="go";else if(r.startsWith("Fi"))l="fi";else if(r.startsWith("Di"))l="di";else if(r.startsWith("Ai"))l="ai";else if(r.startsWith("Bs"))l="bs";else if(r.startsWith("Ri"))l="ri";else if(r.startsWith("Fc"))l="fc";else if(r.startsWith("Gi"))l="gi";else if(r.startsWith("Hi2"))l="hi2";else if(r.startsWith("Hi"))l="hi";else if(r.startsWith("Si"))l="si";else if(r.startsWith("Sl"))l="sl";else if(r.startsWith("Im"))l="im";else if(r.startsWith("Bi"))l="bi";else if(r.startsWith("Pi"))l="pi";else if(r.startsWith("Vsc"))l="vsc";else if(r.startsWith("Tb"))l="tb";else if(r.startsWith("Tfi"))l="tfi";else if(r.startsWith("Cg"))l="cg";else if(r.startsWith("Lia"))l="lia";else if(r.startsWith("Lu"))l="lu";else throw new Error(`Unknown library prefix for icon: ${r}`);let f;switch(l){case"md":f=await import("react-icons/md");break;case"fa6":f=await import("react-icons/fa6");break;case"io5":f=await import("react-icons/io5");break;case"io":f=await import("react-icons/io");break;case"ti":f=await import("react-icons/ti");break;case"go":f=await import("react-icons/go");break;case"fi":f=await import("react-icons/fi");break;case"di":f=await import("react-icons/di");break;case"ai":f=await import("react-icons/ai");break;case"bs":f=await import("react-icons/bs");break;case"ri":f=await import("react-icons/ri");break;case"fc":f=await import("react-icons/fc");break;case"gi":f=await import("react-icons/gi");break;case"hi2":f=await import("react-icons/hi2");break;case"hi":f=await import("react-icons/hi");break;case"si":f=await import("react-icons/si");break;case"sl":f=await import("react-icons/sl");break;case"im":f=await import("react-icons/im");break;case"bi":f=await import("react-icons/bi");break;case"pi":f=await import("react-icons/pi");break;case"vsc":f=await import("react-icons/vsc");break;case"tb":f=await import("react-icons/tb");break;case"tfi":f=await import("react-icons/tfi");break;case"cg":f=await import("react-icons/cg");break;case"lia":f=await import("react-icons/lia");break;case"lu":f=await import("react-icons/lu");break;default:throw new Error(`Unsupported library: ${l}`)}const d=f[r];if(!d)throw new Error(`Icon ${r} not found in library ${l}`);n(()=>d)}catch(l){console.warn(`Failed to load icon ${r}:`,l.message),s(!0),n(null)}finally{i(!1)}})()},[r]),a||!t?null:H.jsx(t,{...e})},u2=({icon:r,label:e,onClick:t,color:n,boxSize:a=6,...i})=>{const{background:o,border:s,colorText:u}=Rn();return H.jsxs(Re.Tooltip.Root,{positioning:{placement:i.placement||"top"},children:[H.jsx(Re.Tooltip.Trigger,{asChild:!0,children:H.jsx(Re.Flex,{children:H.jsx(Re.Icon,{as:r,boxSize:a,color:n,cursor:t?"pointer":void 0,onClick:t})})}),H.jsx(Re.Tooltip.Positioner,{children:H.jsx(Re.Tooltip.Content,{bgColor:i.bgColor||o,borderColor:i.borderColor||s,borderWidth:1,color:i.textColor||u,borderRadius:15,fontWeight:300,fontSize:"sm",p:2,px:4,shadow:"none",children:e})})]})},yU=({data:r,children:e,isInverted:t,isParent:n})=>{var W,V;const{selectedNodeIds:a,setSelectedNodeIds:i,setSelectedEdgeId:o,isMultiSelectMode:s,isPerformanceMode:u,cyRef:l,callbacks:f,config:d,themeColor:h,direction:g}=en(),{background:p,border:x,colorText:b}=Rn(),w=xe.useRef(null),y=xe.useRef(null),[E,C]=xe.useState(!1),[S,R]=xe.useState(!1),_=r==null?void 0:r.id,A=a.includes(_),P=d.nodeOverlayActions,I=d.renderNodeOverlay,D=(()=>{var $;try{const Z=($=l.current)==null?void 0:$.zoom();return Z!==void 0&&Z<.08}catch{return!1}})(),L=xe.useCallback(()=>{var $,Z,ee,K;if(!S)if(o(null),($=l.current)==null||$.edges(":selected").unselect(),s){const j=a.includes(_),fe=j?a.filter(G=>G!==_):[...a,_];i(fe),j?(Z=f.onNodeDeselect)==null||Z.call(f):(ee=f.onNodeSelect)==null||ee.call(f,_,r)}else i([_]),(K=f.onNodeSelect)==null||K.call(f,_,r)},[_,r,a,s,S,i,o,l,f]),M=xe.useCallback(()=>{var $;S||($=f.onNodeDoubleClick)==null||$.call(f,_,r)},[_,r,S,f]),q=xe.useCallback(()=>{y.current&&clearTimeout(y.current),y.current=setTimeout(()=>C(!0),100)},[]),N=xe.useCallback(()=>{y.current&&clearTimeout(y.current),C(!1)},[]);return n?H.jsxs(Re.Box,{ref:w,onClick:L,onDoubleClick:M,onMouseEnter:q,onMouseLeave:N,cursor:"pointer",position:"relative",children:[!u&&(I||P&&P.length>0)&&E&&!D&&H.jsxs(H.Fragment,{children:[H.jsx(Re.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>C(!0),onMouseLeave:N}),I?H.jsx(Re.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>C(!0),onMouseLeave:N,willChange:"transform",children:I({nodeId:_,nodeData:r,isRoot:_==="root",isParent:!0,isHovered:E,setIsHovered:C})}):H.jsx(Re.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:p,p:3,borderColor:x,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>C(!0),onMouseLeave:N,willChange:"transform",children:H.jsx(Re.HStack,{px:2,gap:2,children:P.map(($,Z)=>H.jsxs(Re.Box,{display:"contents",children:[Z>0&&H.jsx(Re.Box,{borderColor:x,height:5,borderRightWidth:1}),H.jsx(u2,{icon:$.icon,label:$.label,color:b,bgColor:p,borderColor:x,textColor:b,boxSize:5,onClick:ee=>{var K;ee.stopPropagation(),(K=f.onNodeHoverAction)==null||K.call(f,$.id,_,r)}})]},$.id))})})]}),e({id:_,data:r,isActive:A,isLowZoom:D,isEditing:S,onEditStart:()=>R(!0),onEditEnd:()=>R(!1)}),((W=r==null?void 0:r.config)==null?void 0:W.collapsed)!==void 0&&(()=>{var ee;const $=g==="TB"||g==="BT",Z=t||g==="RL";return H.jsx(Re.IconButton,{position:"absolute",...$?{[g==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:Z?void 0:"-75px",left:Z?"-75px":void 0,top:"50%",transform:"translateY(-50%)"},"aria-label":r.config.collapsed?"Expand":"Collapse",onClick:K=>{var j;K.stopPropagation(),(j=f.onNodeCollapse)==null||j.call(f,_,!r.config.collapsed)},bgColor:zr(((ee=r==null?void 0:r.viewProps)==null?void 0:ee.bgColor)||h),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:r.config.collapsed?H.jsx(rr.PiPlusBold,{size:30,color:"gray.800"}):H.jsx(rr.PiMinusBold,{size:30,color:"gray.800"})})})()]}):H.jsxs(Re.Box,{ref:w,onClick:L,onDoubleClick:M,onMouseEnter:q,onMouseLeave:N,cursor:"pointer",transition:"transform 0.1s ease",position:"relative",children:[!u&&(I||P&&P.length>0)&&E&&!D&&H.jsxs(H.Fragment,{children:[H.jsx(Re.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>C(!0),onMouseLeave:N}),I?H.jsx(Re.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>C(!0),onMouseLeave:N,willChange:"transform",children:I({nodeId:_,nodeData:r,isRoot:_==="root",isParent:!!n,isHovered:E,setIsHovered:C})}):H.jsx(Re.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:p,p:3,borderColor:x,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>C(!0),onMouseLeave:N,willChange:"transform",children:H.jsx(Re.HStack,{px:2,gap:2,children:P.map(($,Z)=>H.jsxs(Re.Box,{display:"contents",children:[Z>0&&H.jsx(Re.Box,{borderColor:x,height:5,borderRightWidth:1}),H.jsx(u2,{icon:$.icon,label:$.label,color:b,bgColor:p,borderColor:x,textColor:b,boxSize:5,onClick:ee=>{var K;ee.stopPropagation(),(K=f.onNodeHoverAction)==null||K.call(f,$.id,_,r)}})]},$.id))})})]}),H.jsxs(Re.Box,{position:"relative",display:"flex",h:"100%",w:"100%",children:[((V=r==null?void 0:r.config)==null?void 0:V.collapsed)!==void 0&&!n&&(()=>{var ee;const $=g==="TB"||g==="BT",Z=t||g==="RL";return H.jsx(Re.IconButton,{position:"absolute",...$?{[g==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:Z?void 0:"-75px",left:Z?"-75px":void 0,alignSelf:"center"},"aria-label":r.config.collapsed?"Expand":"Collapse",onClick:K=>{var j;K.stopPropagation(),(j=f.onNodeCollapse)==null||j.call(f,_,!r.config.collapsed)},bgColor:zr(((ee=r==null?void 0:r.viewProps)==null?void 0:ee.bgColor)||h),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:r.config.collapsed?H.jsx(rr.PiPlusBold,{size:30,color:"gray.800"}):H.jsx(rr.PiMinusBold,{size:30,color:"gray.800"})})})(),e({id:_,data:r,isActive:A,isLowZoom:D,isEditing:S,onEditStart:()=>R(!0),onEditEnd:()=>R(!1)})]})]})},ef=xe.memo(yU);function CI(r=!0){const e=xe.useRef(null);return xe.useEffect(()=>{if(!r||!e.current)return;const t=i=>{i.stopPropagation()},n=e.current,a=["mousedown","mouseup","click","dblclick","pointerdown","pointerup","wheel"];return a.forEach(i=>n.addEventListener(i,t)),()=>{a.forEach(i=>n.removeEventListener(i,t))}},[r]),e}const _I=({nodeId:r,label:e,color:t,fontWeight:n="bold",fontSize:a="5xl",isEditing:i,onEditStart:o,onEditEnd:s})=>{const{callbacks:u,config:l,readOnly:f}=en(),d=l.editable&&!f,[h,g]=xe.useState(e),p=xe.useRef(null),x=xe.useRef(!1),b=CI(i);xe.useEffect(()=>{i&&(x.current=!1,p.current&&(p.current.focus(),p.current.select()))},[i]);const w=()=>{var E;if(x.current)return;x.current=!0;const y=h.trim();y&&y!==e&&((E=u.onNodeLabelChange)==null||E.call(u,r,y)),s()};return!d||!i?H.jsx(Re.Text,{color:t,fontWeight:n,fontSize:a,onDoubleClick:d?y=>{y.stopPropagation(),g(e),o()}:void 0,cursor:d?"text":void 0,children:e}):H.jsx("div",{ref:b,children:H.jsx(Re.Input,{ref:p,value:h,onChange:y=>g(y.target.value),onBlur:w,onKeyDown:y=>{y.key==="Enter"&&w(),y.key==="Escape"&&s()},color:t,fontWeight:n,fontSize:a,bg:"transparent",borderWidth:0,p:0,h:"auto",lineHeight:"normal"})})},mU=({id:r,data:e,isActive:t,isEditing:n,onEditStart:a,onEditEnd:i})=>{var d,h,g;const{themeColor:o}=en(),{bgColor:s,borderColor:u,textColor:l}=bs(((d=e==null?void 0:e.viewProps)==null?void 0:d.bgColor)||o),f=zr(((h=e==null?void 0:e.viewProps)==null?void 0:h.textColor)||l);return H.jsx(Re.Box,{borderRadius:(g=e==null?void 0:e.viewProps)==null?void 0:g.borderRadius,bgColor:s,borderColor:t?"white":u,_hover:{borderColor:"white"},borderWidth:2,py:14,px:20,whiteSpace:"normal",children:H.jsx(Re.Flex,{justifyContent:"start",w:900,fontSize:"5xl",lineHeight:"normal",children:H.jsx(_I,{nodeId:r,label:(e==null?void 0:e.label)||(e==null?void 0:e.text)||"",color:f,isEditing:n,onEditStart:a,onEditEnd:i})})})},bU=({id:r,isActive:e,data:t,isEditing:n,onEditStart:a,onEditEnd:i})=>{var p,x,b,w;const{themeColor:o}=en(),s=((p=t==null?void 0:t.viewProps)==null?void 0:p.bgColor)||o,{borderColor:u,highlightColor:l,textColor:f}=bs(s),d=zr(((x=t==null?void 0:t.viewProps)==null?void 0:x.textColor)||f),h=zr(((b=t==null?void 0:t.viewProps)==null?void 0:b.borderColor)||u),g=s!=null&&s.startsWith("#")?s:zr(l);return H.jsx(Re.Flex,{align:"center",borderRadius:(w=t==null?void 0:t.viewProps)==null?void 0:w.borderRadius,bgColor:g,style:{backgroundColor:g},textTransform:"capitalize",borderColor:e?"white":h,_hover:{borderColor:"white"},borderWidth:2,px:50,whiteSpace:"nowrap",children:H.jsx(Re.Flex,{justifyContent:"start",py:14,fontSize:"5xl",lineHeight:"normal",w:900,children:H.jsx(_I,{nodeId:r,label:(t==null?void 0:t.label)||(t==null?void 0:t.text)||"",color:d,isEditing:n,onEditStart:a,onEditEnd:i})})})},SI=(r,e)=>{var u,l,f;const t=((u=r==null?void 0:r.viewProps)==null?void 0:u.bgColor)||e,[n]=t.split("."),a=bs(t),i=t!=null&&t.startsWith("#")?zr(t):zr(a.bgColor),o=zr(((l=r==null?void 0:r.viewProps)==null?void 0:l.textColor)||a.textColor),s=zr(((f=r==null?void 0:r.viewProps)==null?void 0:f.borderColor)||a.borderColor);return{...a,bg:t,wordBeforeDot:n,hexbgColor:i,hextextColor:o,hexborderColor:s}},wU=(r,e=350)=>`${String(r).substring(0,e)}${String(r).length>e?"...":""}`,TI=r=>r!=null&&r.includes("root")?r.replace("root","untitled"):r,xU=r=>{const e=Math.max(...Object.keys(r||{}).map(n=>n.length),0);return Math.max(e*28+30,200)},RI=r=>H.jsx(ef,{...r,children:e=>H.jsx(mU,{...e})}),AI=r=>H.jsx(ef,{...r,children:e=>H.jsx(bU,{...e})}),PI=r=>{const{themeColor:e}=en(),[t,n]=xe.useState(!1);return H.jsx(ef,{...r,children:({data:a,isActive:i,isLowZoom:o})=>{var h,g,p,x,b,w,y,E;const s=SI(a,e),u=Object.entries(a.description||{}).length>0,l=xU(a.description),f=(g=(h=r.data)==null?void 0:h.config)==null?void 0:g.icon,d=(x=(p=r.data)==null?void 0:p.config)==null?void 0:x.content;return H.jsx(Re.Flex,{justifyContent:"space-between",...a==null?void 0:a.viewProps,direction:"column",p:0,borderRadius:(b=a==null?void 0:a.viewProps)==null?void 0:b.borderRadius,overflow:"hidden",alignItems:"center",style:{backgroundColor:s.hexbgColor,transition:"border-color 0.2s ease-in-out"},width:"100%",borderColor:i?"white":s.hexborderColor,_hover:{borderColor:"white"},borderWidth:3,children:H.jsxs(Re.Flex,{width:"100%",direction:"column",borderRadius:(w=a==null?void 0:a.viewProps)==null?void 0:w.borderRadius,borderColor:s.hexborderColor,borderWidth:0,overflow:"hidden",children:[a.headerTitle&&H.jsxs(Re.Flex,{justify:"flex-start",direction:"row",p:Object.entries(a.description||{}).length?8:20,borderBottomWidth:1,minWidth:"max-content !important",width:"100%",textTransform:"capitalize",align:d?"left":"center",textOverflow:"ellipsis",alignItems:"center",fontWeight:"bold",color:s.propertyColor,bgColor:s.highlightColor,borderBottomColor:!u&&!d?"transparent":s.hexborderColor,children:[!!f&&H.jsx(Re.Box,{mr:8,justifyContent:"flex-start",height:"100%",w:50,alignItems:"center",rounded:"full",children:H.jsx(L0,{name:f,size:80,color:s.hextextColor},s.hextextColor)}),H.jsx(Re.Text,{fontSize:"5xl",lineClamp:2,textOverflow:"ellipsis",whiteSpace:"nowrap",color:(y=a==null?void 0:a.viewProps)==null?void 0:y.textColor,children:TI(a.headerTitle)}),!!d&&H.jsx(Re.Box,{ml:10,onClick:()=>n(!t),children:t?H.jsx(rr.PiGear,{size:30,style:{cursor:"pointer"}}):H.jsx(rr.PiNotepad,{size:30,style:{cursor:"pointer"}})})]}),d&&!t?H.jsx(Re.Flex,{w:"100%",overflow:"auto",justifyContent:"start",background:s.highlightColor,p:10,fontSize:"5xl",lineHeight:"normal",cursor:"text",children:H.jsx(Re.Text,{whiteSpace:"pre-wrap",overflow:"hidden",textOverflow:"ellipsis",color:(E=a==null?void 0:a.viewProps)==null?void 0:E.textColor,children:d})}):H.jsx(Re.Box,{children:Object.entries(a.description||{}).map(([C,S],R)=>{var P,I;const _=kn(s.wordBeforeDot)[typeof S],A=kn(s.wordBeforeDot).property;return H.jsxs(Re.Box,{children:[H.jsxs(Re.Flex,{flexWrap:"nowrap",overflow:"hidden",children:[H.jsx(Re.Flex,{justifyContent:"start",align:"center",background:s.highlightColor,width:`${l}px`,minWidth:`${l}px`,borderRightColor:s.hexborderColor,borderRightWidth:1,children:H.jsx(Re.Text,{py:5,px:10,w:"100%",whiteSpace:"nowrap",fontWeight:"bold",fontSize:"4xl",color:((P=a==null?void 0:a.viewProps)==null?void 0:P.textColor)||A,children:C})}),H.jsx(Re.Flex,{flex:1,justifyContent:"start",overflow:"hidden",p:4,background:s.hexbgColor,w:600,maxH:200,children:H.jsx(Re.Text,{overflow:"hidden",py:3,px:4,whiteSpace:"normal",textOverflow:"ellipsis",fontSize:"4xl",color:((I=a==null?void 0:a.viewProps)==null?void 0:I.textColor)||_,fontWeight:400,children:wU(S)})})]}),R!==Object.entries(a.description||{}).length-1&&H.jsx(Re.Box,{borderTopWidth:1,my:0,borderColor:s.hexborderColor})]},R)})})]})})}})},II=r=>{const{themeColor:e}=en();return H.jsx(ef,{...r,children:({data:t,isActive:n})=>{var o,s,u,l;const a=SI(t,e),i=(s=(o=r.data)==null?void 0:o.config)==null?void 0:s.icon;return H.jsx(Re.Flex,{justifyContent:"space-between",...t==null?void 0:t.viewProps,direction:"column",p:0,borderRadius:((u=t==null?void 0:t.viewProps)==null?void 0:u.borderRadius)||15,overflow:"hidden",bgColor:a.bgColor,position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",style:{backgroundColor:a.hexbgColor,transition:"border-color 0.2s ease-in-out"},borderColor:n?"white":a.hexborderColor,_hover:{borderColor:"white"},borderWidth:3,children:t.headerTitle&&H.jsxs(Re.Flex,{justify:"flex-start",direction:"row",p:20,borderBottomWidth:1,minWidth:"max-content !important",width:"100%",textTransform:"capitalize",align:"center",alignItems:"center",fontWeight:"bold",color:a.propertyColor,bgColor:a.highlightColor,borderBottomColor:a.hexborderColor,children:[!!i&&H.jsx(Re.Box,{mr:8,justifyContent:"flex-start",height:"100%",w:50,alignItems:"center",rounded:"full",children:H.jsx(L0,{name:i,size:80,color:a.hextextColor},a.hextextColor)}),H.jsx(Re.Text,{fontSize:"5xl",lineClamp:2,textOverflow:"ellipsis",whiteSpace:"nowrap",color:(l=t==null?void 0:t.viewProps)==null?void 0:l.textColor,children:TI(t.headerTitle)})]})})}})};RI.displayName="text";AI.displayName="arrayView";PI.displayName="NodeJsonObjectView";II.displayName="ParentContainerView";const EU={objectView:PI,arrayView:AI,text:RI,parentContainer:II},CU=({children:r,pattern:e="dot",backgroundColor:t})=>{const{colorMode:n}=en(),a=n==="dark",i=a?"--chakra-colors-gray-700":"--chakra-colors-gray-500",o=a?"--chakra-colors-gray-700":"--chakra-colors-gray-800";return e==="none"?H.jsx(Re.Box,{width:"100%",height:"100%",padding:0,bg:t,children:r}):H.jsxs(Re.Box,{position:"relative",width:"100%",height:"100%",padding:0,bg:t,children:[H.jsx(Re.Box,{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:0,pointerEvents:"none",style:{backgroundImage:e==="dot"?`radial-gradient(var(${i}) 8%, transparent 8%)`:e==="steel"?`repeating-linear-gradient(45deg, var(${o}) 0, var(${o}) 1px, transparent 1px, transparent 20px)`:`linear-gradient(var(${o}) 1px, transparent 1px), linear-gradient(90deg, var(${o}) 1px, transparent 1px)`,backgroundSize:"20px 20px",opacity:.3}}),H.jsx(Re.Box,{position:"relative",width:"100%",height:"100%",zIndex:1,padding:0,children:r})]})},_U=({nodes:r,edges:e})=>{const{themeColor:t,edgeColor:n,direction:a,parentNodeStyle:i,cyRef:o,callbacks:s,config:u,selectedNodeIds:l,setSelectedNodeIds:f,setSelectedEdgeId:d,setIsPerformanceMode:h,isZoomMode:g,setIsZoomMode:p,isMultiSelectMode:x,setIsMultiSelectMode:b,isDragMode:w,setIsDragMode:y,isEdgeHandlesEnabled:E,isArrayNodeMode:C}=en(),S=xe.useRef(null),R=xe.useRef(null),_=xe.useRef(C),A=r.length>200;xe.useEffect(()=>{h(A)},[A,h]);const{edgeSep:P,rankSep:I}=xe.useMemo(()=>aN(r.length),[r.length]),{bgColor:D}=bs(t),{canvas:L,borderSecondary:M}=Rn(),q=u.backgroundColor||L,N=xe.useCallback(re=>{if(re!=null&&re.includes("gray"))return"whitesmoke";if(!re)return zr(t);switch(re){case"dark":return zr(q);case"light":return zr(M);default:return zr(re)}},[t,q,M]),W=u.colorMode==="dark",V=xe.useMemo(()=>N(W?D:"light"),[W,D,N]),$=n?N(n):V,Z=xe.useMemo(()=>hU(N),[N]),ee=u.initialViewport||{pan:{x:0,y:0},zoom:.01},K=xe.useMemo(()=>({...A?gU:r.length>100?EI:xI,style:Z,zoom:ee.zoom,pan:ee.pan,minZoom:u.minZoom??.01,maxZoom:u.maxZoom??1.5}),[Z,ee,r.length,u.minZoom,u.maxZoom]),j=xe.useRef(!1),fe=xe.useRef();xe.useEffect(()=>()=>{clearTimeout(fe.current)},[]);const G=a==="C"?"LR":a,z=xe.useMemo(()=>({...pU,...G&&{rankDir:G},edgeSep:P,rankSep:I,get animate(){return j.current&&!A},animationDuration:300,animationEasing:"ease-in-out-cubic",stop:()=>{o.current&&(j.current||setTimeout(()=>{var re;(re=o.current)==null||re.fit(void 0,50)},100),clearTimeout(fe.current),fe.current=setTimeout(()=>{j.current=!0},500))}}),[G,P,I,o,A]),Y=xe.useCallback(re=>{const ce={...i,...re};return{...ce,bgColor:ce.bgColor||t,bgOpacity:ce.bgOpacity??wI}},[i,t]),te=xe.useCallback(re=>{const ce=Y(re),_e=zr(ce.bgColor),me={shape:"round-rectangle","background-color":_e,"background-opacity":ce.bgOpacity,"border-color":ce.borderColor?zr(ce.borderColor):_e,color:ce.textColor?zr(ce.textColor):_e,"corner-radius":ce.borderRadius??50};return ce.borderWidth!==void 0&&(me["border-width"]=ce.borderWidth),ce.borderStyle&&(me["border-style"]=ce.borderStyle),ce.fontSize!==void 0&&(me["font-size"]=`${ce.fontSize}px`),ce.padding!==void 0&&(me.padding=`${ce.padding}px`),ce.labelPosition&&(me["text-valign"]=ce.labelPosition,me["text-margin-y"]=ce.labelPosition==="top"?90:ce.labelPosition==="bottom"?-90:0),me},[Y]),ue=xe.useMemo(()=>{var ce;const re=new Map;for(const _e of r)(ce=_e.data)!=null&&ce.id&&re.set(_e.data.id,_e);return re},[r]),oe=xe.useMemo(()=>{var _e,me;const re=new Map;for(const Te of e){const De=(_e=Te.data)==null?void 0:_e.source,Ne=(me=Te.data)==null?void 0:me.target;if(!De||!Ne||De===Ne)continue;const ze=De<Ne?`${De}|${Ne}`:`${Ne}|${De}`,$e=re.get(ze);$e?$e.push({id:Te.data.id,source:De}):re.set(ze,[{id:Te.data.id,source:De}])}const ce=new Map;for(const[Te,De]of re){if(De.length<2)continue;const Ne=Te.split("|")[0],ze=Math.min(20,70/De.length);De.forEach(({id:$e,source:ke},Oe)=>{const ye=50+(Oe-(De.length-1)/2)*ze;ce.set($e,`${ke===Ne?ye:100-ye}%`)})}return ce},[e]),X=xe.useCallback((re,ce,_e,me)=>{var ke,Oe,ye,O,ne,he;let Te={};me!=null&&me.isInverted&&(me==null?void 0:me.source)===ce&&(Te["target-arrow-shape"]="none",Te["source-arrow-shape"]="triangle"),me!=null&&me.isEdgeAnimated?(Te["line-style"]="dashed",Te["line-dash-pattern"]=[32,18],Te["line-dash-offset"]=0):me!=null&&me.isEdgeDashed?(Te["line-style"]="dashed",Te["line-dash-pattern"]=[],Te["line-dash-offset"]=0):(Te["line-style"]="solid",Te["line-dash-pattern"]=[],Te["line-dash-offset"]=0),G==="TB"&&(Te["taxi-direction"]="downward"),G==="BT"&&(Te["taxi-direction"]="upward"),G==="LR"&&(Te["taxi-direction"]="rightward"),G==="RL"&&(Te["taxi-direction"]="leftward"),Te["taxi-turn"]=oe.get(me==null?void 0:me.id)??"50%";const De=me!=null&&me.color?zr(me.color):$;Te["line-color"]=De,Te.color=De,Te["target-arrow-color"]=De,Te["source-arrow-color"]=De;const Ne=N("dark");Te["text-background-color"]=Ne;const ze=(Oe=(ke=ue.get(me==null?void 0:me.source))==null?void 0:ke.data)==null?void 0:Oe.parent,$e=(O=(ye=ue.get(me==null?void 0:me.target))==null?void 0:ye.data)==null?void 0:O.parent;if(ze&&ze===$e){const ge=Y((he=(ne=ue.get(ze))==null?void 0:ne.data)==null?void 0:he.viewProps),be=Xq(Ne,zr(ge.bgColor),ge.bgOpacity);be&&(Te["text-background-color"]=be)}return Te},[$,G,oe,ue,Y,N]),Q=xe.useRef(ue);Q.current=ue;const ie=xe.useRef(te);ie.current=te,xe.useEffect(()=>{if(!o.current)return;const re=o.current,ce=Te=>{var Ne;const De=Q.current.get(Te.id());Te.style(ie.current((Ne=De==null?void 0:De.data)==null?void 0:Ne.viewProps))},_e=Te=>{const De=Te.target;if(!De.isNode())return;De.isParent()&&ce(De);const Ne=De.parent();Ne.length&&ce(Ne)},me=Te=>{const De=Te.target;De.isNode()&&De.isParent()&&De.style("shape")==="rectangle"&&ce(De)};return re.on("add",_e),re.on("style","node",me),()=>{re.off("add",_e),re.off("style","node",me)}},[]),xe.useEffect(()=>{if(!o.current)return;const re=o.current;re.startBatch(),re.nodes(":parent").forEach(ce=>{var me;const _e=ue.get(ce.id());ce.style(te((me=_e==null?void 0:_e.data)==null?void 0:me.viewProps))}),e.forEach(({data:ce})=>{const _e=re.getElementById(ce.id);_e!=null&&_e.length&&(_e.data({isEdgeAnimated:ce.isEdgeAnimated,isEdgeDashed:ce.isEdgeDashed}),_e.style(X(_e,ce.source,ce.target,ce)))}),re.endBatch()},[ue,e,$,te,X]);const de=xe.useRef(u);de.current=u;const we=xe.useRef(g);we.current=g;const Ae=xe.useRef(E);Ae.current=E,_.current=C,xe.useEffect(()=>{if(!o.current||!o.current.container)return;const re=o.current,ce=S.current;if(!ce)return;let _e=null,me=null,Te=0,De=0,Ne=0,ze=0,$e=0;const ke=Oe=>{Oe.preventDefault(),Oe.stopPropagation(),we.current||Oe.metaKey||Oe.ctrlKey?(Ne+=Oe.deltaY,ze=Oe.clientX,$e=Oe.clientY,me===null&&(me=requestAnimationFrame(()=>{me=null;const O=de.current,ne=re.zoom(),he=Ne;Ne=0;let ge=ne-he*.05/100;ge=Math.max(O.minZoom??.01,Math.min(O.maxZoom??1.5,ge));const be=ce.getBoundingClientRect();re.zoom({level:ge,renderedPosition:{x:ze-be.left,y:$e-be.top}})}))):(Te+=Oe.deltaX,De+=Oe.deltaY,_e===null&&(_e=requestAnimationFrame(()=>{_e=null;const O=re.pan(),ne=re.zoom(),he=.35,ge=Te,be=De;Te=0,De=0,re.pan({x:O.x+-ge*he/ne,y:O.y+-be*he/ne})})))};return ce.addEventListener("wheel",ke,{passive:!1}),()=>{ce.removeEventListener("wheel",ke),_e!==null&&cancelAnimationFrame(_e),me!==null&&cancelAnimationFrame(me)}},[o.current]),xe.useEffect(()=>{o.current&&o.current.userPanningEnabled(w)},[w]),xe.useEffect(()=>{if(!o.current)return;const re=o.current;re.boxSelectionEnabled(!!x),re.selectionType(x?"additive":"single"),re.userPanningEnabled(!x&&w)},[x,w]),xe.useEffect(()=>{R.current&&(E?R.current.enableDrawMode():R.current.disableDrawMode())},[E]);const ve=xe.useRef(l);ve.current=l,xe.useEffect(()=>{if(u.disableKeyboardShortcuts)return;const re=ce=>{var me,Te;const _e=ce.target;if(!(_e.tagName==="INPUT"||_e.tagName==="TEXTAREA"||_e.isContentEditable)&&((ce.key==="z"||ce.key==="Z")&&p(!we.current),(ce.key==="m"||ce.key==="M")&&b(!x),(ce.key==="d"||ce.key==="D")&&y(!w),(ce.key==="Delete"||ce.key==="Backspace")&&ve.current.length>0)){ce.preventDefault();const De=ve.current.filter(ze=>ze!=="root");if(De.length===0)return;const Ne=o.current;for(const ze of De){const $e=(me=Ne==null?void 0:Ne.getElementById(ze))==null?void 0:me.data();(Te=s.onNodeDelete)==null||Te.call(s,ze,$e||{})}f([])}};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)},[x,w,p,b,y,u.disableKeyboardShortcuts,s,f,o]),xe.useEffect(()=>()=>{if(o.current)try{o.current.removeAllListeners()}catch{}},[]);const le=xe.useMemo(()=>A?300:r.length>50?150:r.length>20?100:50,[r.length,A]),Me=xe.useMemo(()=>{var ce;const re=new Set;for(const _e of r)(ce=_e.data)!=null&&ce.parent&&re.add(_e.data.parent);return re},[r]),Se=xe.useMemo(()=>{var ce;const re=new Map;for(const _e of e)(ce=_e.data)!=null&&ce.source&&!re.has(_e.data.source)&&re.set(_e.data.source,_e.data);return re},[e]),Ee=u.backgroundPattern||"dot";return H.jsx(CU,{pattern:Ee,backgroundColor:q,children:H.jsx(Re.Box,{ref:S,className:E?"flow-draw-mode":void 0,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:H.jsxs(dU,{cyParams:K,layoutParams:z,layoutDebounce:le,onCyInit:re=>{var _e;o.current=re,(_e=s.onCyInit)==null||_e.call(s,re);let ce=null;if(re.on("zoom pan",()=>{ce===null&&(ce=requestAnimationFrame(()=>{var me;ce=null,(me=s.onViewportChange)==null||me.call(s,{zoom:re.zoom(),pan:re.pan()})}))}),re.on("select","edge",me=>{var De;const Te=me.target;ve.current.length&&f([]),d(Te.id()),(De=s.onEdgeSelect)==null||De.call(s,Te.id(),Te.data())}),re.on("unselect","edge",()=>{var me;d(null),(me=s.onEdgeDeselect)==null||me.call(s)}),re.on("remove","edge",me=>{var De;const Te=me.target;(De=s.onEdgeRemove)==null||De.call(s,Te.id(),Te.data())}),re.on("boxselect","node",me=>{var Ne;const Te=me.target.id(),De=ve.current;De.includes(Te)||(f([...De,Te]),(Ne=s.onNodeSelect)==null||Ne.call(s,Te,me.target.data()))}),re.on("tap",me=>{var Te;me.target===re&&ve.current.length&&(f([]),(Te=s.onNodeDeselect)==null||Te.call(s))}),re.on("tap",":parent",me=>{var De;const Te=me.target;f([Te.id()]),(De=s.onNodeSelect)==null||De.call(s,Te.id(),Te.data())}),u.edgeHandles!==!1){const me={canConnect:(ze,$e)=>!ze.same($e),edgeParams:(ze,$e)=>({data:{source:ze.id(),target:$e.id(),label:""}}),loopAllowed:()=>!1,hoverDelay:500,snap:!1,snapThreshold:10,snapFrequency:5,noEdgeEventsInDraw:!0,disableBrowserGestures:!0,handlePosition:"left",handleNodes:"node",handleSize:20,handleColor:t||"#0ea5e9",handleOutlineColor:"#B92020FF",handleOutlineWidth:2,handleLineType:"ghost",handleLineWidth:2,preview:!0,ghostEdgeParams:()=>({}),edgeType:()=>"flat",nodeParams:()=>({})},Te=re.edgehandles(me);R.current=Te,Ae.current&&Te.enableDrawMode();let De=null,Ne=null;re.on("ehstart",(ze,$e)=>{Ne=$e;const ke=ze.originalEvent||window.event;if(ke!=null&&ke.clientX&&(ke!=null&&ke.clientY))De={x:ke.clientX,y:ke.clientY};else{const Oe=$e.renderedPosition();De={x:Oe.x,y:Oe.y}}}),re.on("ehcancel",ze=>{if(!De||!Ne)return;const $e=ze.originalEvent||window.event,ke=$e==null?void 0:$e.clientX,Oe=$e==null?void 0:$e.clientY;if(ke&&Oe&&s.onNodeCreate){const ye=Math.abs(ke-De.x),O=Math.abs(Oe-De.y);if(Math.max(ye,O)>30){const ne=re.renderer().projectIntoViewport(ke,Oe);s.onNodeCreate({type:"text",sourceNodeId:Ne.id(),position:{x:ne[0],y:ne[1]},isArrayMode:_.current})}}De=null,Ne=null}),re.on("ehcomplete",(ze,$e,ke)=>{var Oe;(Oe=s.onEdgeCreate)==null||Oe.call(s,$e.id(),ke.id())}),re.on("ehstop",()=>{De=null,Ne=null})}},children:[(r||[]).map(re=>{var Ne,ze,$e,ke,Oe,ye,O,ne,he,ge;const ce=u.customViews||EU,_e=Me.has((Ne=re.data)==null?void 0:Ne.id)&&!((ze=re.data)!=null&&ze.parent),me=_e?(($e=re.data)==null?void 0:$e.label)||((ke=re.data)==null?void 0:ke.headerTitle)||"Container":void 0,Te=_e?ce.parentContainer:ce[re==null?void 0:re.data.type]||ce.text,De=Se.get((Oe=re.data)==null?void 0:Oe.id);return H.jsx(vU,{id:(ye=re.data)==null?void 0:ye.id,parent:(O=re.data)==null?void 0:O.parent,label:me,styleCallback:te,parentViewProps:(ne=re.data)==null?void 0:ne.viewProps,children:xe.createElement(Te,{...re,isInverted:De==null?void 0:De.isInverted,isParent:_e,key:`${(he=re.data)==null?void 0:he.id}-${t}`})},(ge=re.data)==null?void 0:ge.id)}),(e||[]).map(({data:re})=>H.jsx(sN,{id:re==null?void 0:re.id,source:re==null?void 0:re.source,target:re==null?void 0:re.target,label:re==null?void 0:re.label,isPerformanceMode:A,animated:!!(re!=null&&re.isEdgeAnimated),inverted:!!(re!=null&&re.isInverted),edgeData:re,styleCallback:X},re==null?void 0:re.id))]})})})},SU=xe.memo(_U),TU=".cytoscape-react-nodes-and-edges{position:absolute!important;top:0!important;left:0!important;z-index:10!important;pointer-events:none!important;overflow:visible!important;transform-origin:0 0!important}.cytoscape-react-node{z-index:0!important;overflow:visible!important;pointer-events:auto!important;position:absolute!important;transform-origin:0 0!important}.cytoscape-react-node input,.cytoscape-react-node textarea{pointer-events:auto!important;user-select:text!important;cursor:text!important}.cytoscape-react-edge{overflow:visible!important;pointer-events:none!important}.cytoscape-react-cy-container{width:100%!important;height:100%!important;overflow:visible!important;position:relative!important;background:transparent!important}.cytoscape-react-cy-container canvas{display:inline!important;vertical-align:baseline!important;overflow:visible!important}.cytoscape-react-cy-container>div{overflow:visible!important}.flow-draw-mode .cytoscape-react-node{pointer-events:none!important}.flow-draw-mode .cytoscape-react-node input,.flow-draw-mode .cytoscape-react-node textarea{pointer-events:none!important}.flow-draw-mode .cytoscape-react-cy-container{cursor:crosshair}";let l2=!1;function RU(){if(l2||typeof document>"u")return;const r=document.createElement("style");r.setAttribute("data-flow-sdk",""),r.textContent=TU,document.head.appendChild(r),l2=!0}function AU({title:r="untitled",json:e,nodes:t,edges:n,config:a={},callbacks:i={},className:o,style:s,showBottomBar:u=!0}){RU();const l=a.direction==="C",f=xe.useMemo(()=>e?b2(e,{title:r,isCenter:l}):null,[e,r,l]),d=(f==null?void 0:f.nodes)??t??[],h=(f==null?void 0:f.edges)??n??[],g=xe.useMemo(()=>e&&f?w2(e,f.edges,i,i.onJsonChange):i,[e,f,i]);return H.jsx(Zq,{config:a,callbacks:g,nodes:d,edges:h,children:H.jsxs(Re.Box,{className:o,style:s,width:"100%",height:"100%",position:"relative",overflow:"hidden",children:[H.jsx(SU,{nodes:d,edges:h}),u&&H.jsx(nN,{})]})})}exports.DynamicIcon=L0;exports.FlowDiagram=AU;exports.addChild=g2;exports.addTargetEdge=y2;exports.addressToPath=fi;exports.applyCollapsed=jq;exports.bindSqueedCallbacks=w2;exports.compileSqueed=b2;exports.contentObjTheme=kn;exports.createFlowDiagram=li;exports.getChakraColorHex=zr;exports.getColorVariant=C2;exports.getDarkerHexColor=Ju;exports.getNode=mm;exports.removeEdge=m2;exports.removeNode=p2;exports.resolveEdgeOwner=ml;exports.setCollapsed=v2;exports.setEdgeProp=us;exports.setEdgeStyle=h2;exports.setNodeProp=no;exports.updateNode=pi;exports.useCustomColors=Rn;exports.useStopPropagation=CI;exports.useThemeContentColors=bs;
47
+ &:disabled {
48
+ cursor: default;
49
+ opacity: 0.5;
50
+ }
51
+ `;function bl({label:e,inputLabel:t,value:r,displayValue:n,min:o,max:i,onChange:a}){const s=E.useId(),{readOnly:u,themeColor:c}=Ie(),{colorInactive:l}=Ve(),d=(r-o)/(i-o)*100,f=c.includes(".")?`var(--chakra-colors-${c.replace(".","-")})`:c;return h.jsxs("div",{style:{width:224,maxWidth:"calc(100vw - 64px)",padding:12},children:[h.jsxs("label",{htmlFor:s,style:{display:"flex",justifyContent:"space-between",fontSize:14,marginBottom:12},children:[e," ",h.jsx("span",{children:n})]}),h.jsx(Ly,{id:s,"aria-label":t,type:"range",min:o,max:i,step:5,value:r,disabled:u,style:{color:f,accentColor:f,backgroundImage:`linear-gradient(to right, currentColor ${d}%, var(--chakra-colors-${l.replace(".","-")}) ${d}%)`},onChange:p=>a(Number(p.target.value))})]})}const ml={dot:{label:"Dots",icon:Z.PiDotsNine},grid:{label:"Grid",icon:Z.PiGridFour},steel:{label:"Steel",icon:Z.PiLineSegments},none:{label:"Solid",icon:Z.PiSquareFill},transparent:{label:"Transparent",icon:Z.PiSelection}};function Fy(){const{spacing:e,setSpacing:t,edgeRadius:r,setEdgeRadius:n,backgroundVariant:o,setBackgroundVariant:i,callbacks:a,readOnly:s}=Ie(),u=ml[o].icon;return h.jsxs(h.Fragment,{children:[h.jsx(Ot,{}),h.jsx(Or,{"aria-label":"Node spacing",title:`Spacing: ${Math.round(e*100)}%`,icon:h.jsx(Z.PiArrowsOutCardinal,{size:20}),style:{width:36},value:"spacing",disabled:s,onValueChange:()=>{},popupContent:h.jsx(bl,{label:"Spacing",inputLabel:"Node spacing percentage",min:50,max:200,value:Math.round(e*100),displayValue:`${Math.round(e*100)}%`,onChange:c=>{var l;t(c/100),(l=a.onSpacingChange)==null||l.call(a,c/100)}}),children:h.jsx("option",{value:"spacing",children:"Spacing"})}),h.jsx(Ot,{}),h.jsx(Or,{"aria-label":"Edge radius",title:`Edge radius: ${r??"Default"}`,icon:h.jsx(Z.PiBezierCurve,{size:20}),style:{width:36},value:"radius",disabled:s,onValueChange:()=>{},popupContent:h.jsx(bl,{label:"Edge radius",inputLabel:"Edge corner radius",min:0,max:500,value:r??500,displayValue:r??"Default",onChange:c=>{var l;n(c),(l=a.onEdgeRadiusChange)==null||l.call(a,c)}}),children:h.jsx("option",{value:"radius",children:"Edge radius"})}),h.jsx(Ot,{}),h.jsxs(Or,{"aria-label":"Background variant",title:`Background: ${ml[o].label}`,icon:h.jsx(u,{size:20,"data-background-icon":o}),style:{width:36},value:o,disabled:s,onValueChange:c=>{var l;i(c),(l=a.onBackgroundVariantChange)==null||l.call(a,c)},children:[h.jsx("option",{value:"dot",children:"Dots"}),h.jsx("option",{value:"grid",children:"Grid"}),h.jsx("option",{value:"steel",children:"Steel"}),h.jsx("option",{value:"none",children:"Solid"}),h.jsx("option",{value:"transparent",children:"Transparent"})]})]})}function By({label:e,icon:t,checked:r,onChange:n,disabled:o}){const{themeColor:i,readOnly:a}=Ie(),{colorInactive:s}=Ve();return h.jsx(je,{label:e,children:h.jsx(ve,{"aria-label":e,"aria-pressed":r,icon:h.jsxs(h.Fragment,{children:[t,h.jsx(F.Text,{as:"span",fontSize:"xs",fontWeight:"normal",whiteSpace:"nowrap",children:e})]}),size:"sm",variant:"ghost",width:"auto",px:2,gap:2,color:r?i:s,disabled:o||a,onClick:()=>n(!r)})})}function Dy({label:e="Compact layout"}={}){const{compactPropertyLayout:t,setCompactPropertyLayout:r,callbacks:n}=Ie();return h.jsx(By,{label:e,checked:t,icon:h.jsx(F.Icon,{as:Z.PiArrowsIn,boxSize:5}),onChange:o=>{var i;r(o),(i=n.onCompactPropertyLayoutChange)==null||i.call(n,o)}})}const nr=[];for(let e=0;e<256;++e)nr.push((e+256).toString(16).slice(1));function Nx(e,t=0){return(nr[e[t+0]]+nr[e[t+1]]+nr[e[t+2]]+nr[e[t+3]]+"-"+nr[e[t+4]]+nr[e[t+5]]+"-"+nr[e[t+6]]+nr[e[t+7]]+"-"+nr[e[t+8]]+nr[e[t+9]]+"-"+nr[e[t+10]]+nr[e[t+11]]+nr[e[t+12]]+nr[e[t+13]]+nr[e[t+14]]+nr[e[t+15]]).toLowerCase()}let Kn;const $x=new Uint8Array(16);function Lx(){if(!Kn){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Kn=crypto.getRandomValues.bind(crypto)}return Kn($x)}const Fx=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),vl={randomUUID:Fx};function Eu(e,t,r){var o;if(vl.randomUUID&&!e)return vl.randomUUID();e=e||{};const n=e.random??((o=e.rng)==null?void 0:o.call(e))??Lx();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Nx(n)}const yn={label:"Untitled",description:"",isTask:!1,isLocked:!1},Ru={id:null,type:"text",data:{...yn,viewProps:{width:"max-content !important",maxWidth:700,height:"100%",borderColor:"transparent",borderRadius:25,borderWidth:0,boxShadow:"none",textOverflow:"ellipsis",fontWeight:"bold",textColor:"gray.800",textAlign:"center"}}},xl={id:null,type:"objectView",data:{...yn,headerTitle:null,viewProps:{width:"100%",borderWidth:2,borderRadius:53,height:"100%",justifyContent:"space-between",flexDirection:"row",textColor:"gray.900"}}},Bx={id:null,type:"arrayView",data:{...yn,viewProps:{width:"max-content !important",maxWidth:700,height:"100%",textAlign:"center",borderRadius:25,fontSize:"5xl",borderWidth:2,textOverflow:"ellipsis",wordBreak:"keep-all",fontWeight:"bold",textColor:"gray.900",placeholder:"Start Typing"}}},wl={id:null,type:"workflowStep",data:{...yn,viewProps:{width:"max-content !important",maxWidth:350,minWidth:280,height:"100%",borderRadius:15,borderWidth:3}}},fr=e=>typeof e=="object",zy=e=>Array.isArray(e),Dx=["order","position","selected","locked","grabbed","grabbable","scratch"],Dr=e=>Object.entries(e).reduce((t,[r,n])=>(!fr(n)&&!r.startsWith("$")&&(t[r]=n),t),{}),ku=(e,t)=>typeof e=="string"&&e.startsWith("$")?Zn(e,t):fr(e)&&!zy(e)?Object.entries(e).reduce((r,[n,o])=>(typeof o=="string"&&o.startsWith("$")&&n==="..."?(delete r["..."],r[n]={...Zn(o,t),...e}):typeof o=="string"&&o.startsWith("$")?r[n]=Zn(o,t):r[n]=o,r),{}):e,zr=e=>Object.entries(e).reduce((t,[r,n])=>(fr(n)&&r&&n&&!r.startsWith("$")&&(Dx.includes(r)&&(r=r+"#"),t[r]=n),t),{}),Zr=(e,t,{label:r,parent:n=void 0},o,i=null)=>(i!==null&&(fr(i)||zy(i))&&(i=JSON.stringify(i,null,2)),{data:{parent:n,...e.data,id:t,text:r||"",label:r,code:i||null,type:e.type,description:o}}),Br=(e,t,r=null,n=null,o=null,i=!1,a=null)=>({data:{id:Eu(),source:o?t:e,target:o?e:t,label:n||"",isInverted:o,isEdgeAnimated:i,parent:a}}),Vr=(e,t=[])=>{const r={},n={};let o=[];if(e)for(const[i,a]of Object.entries(e))i.startsWith("$")&&i!=="$"?r[i.slice(1)]=a:i!=="$"?n[i]=a:i==="$"&&(o=a);return{newConfig:r,updatedObject:n,arrayObject:o}},ct=(e,t)=>{let r=xl;const{view:n,borderColor:o,borderRadius:i,bgColor:a,textColor:s,fontSize:u,stepType:c}=t;e=n||e,c?r={...wl}:e==="object"?r=xl:e==="text"?r=Ru:e==="array"?r=Bx:e==="workflowStep"&&(r={...wl});const l=r.data.viewProps;return r.data.viewProps={...l,borderRadius:i||(c?15:53),bgColor:a,borderColor:o,textColor:s,fontSize:u},r.data.config=t,{config:r}},Bt=(e,t)=>(e=t.find(n=>n.data.id===e)?`${e}.#`:e,e),Zn=(e,{ids:t,jsnObjct:r})=>{if(typeof e=="string"&&(e!=null&&e.startsWith("$"))){const n=e.replace("$","").replace("*","");e==null||e.endsWith("*");const o=t.find(s=>s.split(".").slice(-1)[0]===n||n===s);if(!o)return e;const i=zx(o,r);return JSON.stringify(i).includes(e)?e:i||e}return e},zx=(e,t)=>{let r=e.split(".").splice(1);return r=r[r.length-1]==="#"||r[r.length-1].includes("{")?r.slice(0,-2):r,(i=>r.reduce((a,s)=>{s=s.replace("[","").replace("]","");const{arrayObject:u}=Vr(a);return a=u.length?u:a,a[s]},i))(t)};function lt(e,t="root",r=[]){try{const{arrayObject:n}=Vr(e);n.length&&(e=n);const o=Dr(e),i=zr(e);return fr(e)?(Pe(e)||Pe(e)&&t==="root"||!Pe(e)&&Object.keys(o).length||t==="root")&&r.push(t):r.push(t),Object.keys(i).length&&!Pe(e)?It({chldPth:null,itrblObjct:i,nodes:r,path:t}):Pe(e)&&e.forEach((a,s)=>{const u=Dr(a),c=zr(a),{newConfig:l,arrayObject:d}=Vr(a);let f=`${t}.${s}`;fr(a)?Object.keys(u).length?(lt(u,f,r),Object.keys(c).length&&!Pe(a)&&It({chldPth:f,itrblObjct:c,nodes:r,path:t})):Object.keys(c).length&&!Pe(a)?It({chldPth:f,itrblObjct:c,nodes:r,path:t}):Pe(a)&&Vy({chldPth:f,item:a,nodes:r,path:t}):r.push(f)}),{nodes:r}}catch{return{nodes:r}}}const It=({chldPth:e,itrblObjct:t,nodes:r,path:n})=>Object.entries(t).forEach(([o,i],a)=>{const s=Dr(i),u=zr(i),{newConfig:c,arrayObject:l}=Vr(i);l.length&&(i=l),n.split(".").slice(0,2).join(".");let d=e?`${e}.${o}`:`${n}.${o}`;if(fr(i)&&!Pe(i)){const f=Object.keys(s).length===0;if(f&&(ct("array",c),r.push(d)),Object.keys(s).length){const p=Pe(i)?`${i.length||""}`:`{${Object.keys(i).length||""}}`;let b=d;f&&(b=`${d}.${p}`),lt(i,b,r)}else Object.keys(u).length&&!Pe(i)?It({chldPth:d,itrblObjct:u,path:d,nodes:r}):lt(i,d,r)}else Pe(i)&&lt(i,d,r)}),Vy=({chldPth:e,item:t,nodes:r,path:n})=>t.forEach((o,i)=>{let a=`${e}.${i}`;const s=zr(o),u=Dr(o);fr(o)?!Pe(o)&&Object.keys(u).length?lt(o,a,r):Object.keys(s).length&&!Pe(o)?It({chldPth:a,itrblObjct:s,path:n,nodes:r}):Pe(o)&&Vy({chldPth:a,item:o,nodes:r,path:n}):r.push(a)}),un=[];let Mt;function Yr(e,t="root",r=[],n=[],o="untitled",i={hideDefaultObject:!1,sprtObjctKy:!1,isCntr:!1},a={}){if(!e||typeof e!="object")return console.error("Invalid object passed",e),{nodes:r,edges:n};const s=e;if(!Mt){const{nodes:l}=lt(e);Mt={ids:l,jsnObjct:e}}let{hideDefaultObject:u,sprtObjctKy:c}=i;try{t=Bt(t,r);const{newConfig:l,arrayObject:d}=Vr(e),f=Object.keys(a).length>0?a:l;d.length&&(e=d);const p=Dr(e),b=zr(e),{label:y,collapsed:m,parent:x}=f;if(!fr(e))r.push(Zr(Ru,t,{label:y||t,parent:x},e,s));else if(Pe(e)||Pe(e)&&t==="root"){const{config:g}=ct("array",f),w=Pe(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,v=t==="root"?o:`${o} ${w}`;r.push(Zr(g,t,{label:y||v,parent:x},e,Pe(s)?{[o]:s}:s))}else if(!Pe(e)&&Object.keys(p).length||t==="root"){const{config:g}=ct(null,f),w=Pe(e)?`${e.length||""}`:`{${Object.keys(e).length||""}}`,v=t.split("."),_=v[v.length-1];let C=isNaN(Number(_))?null:Number(_)+1;const S=isNaN(Number(_))?_:v[v.length-2]+" "+C,T=t==="root"?o:S;let k=!1;Number.isNaN(Number(o))||(k=!0);const j=e;if(y){const{config:P}=ct("object",f);r.push(Zr(P,t,{label:y||`${y} ${w}`,parent:x},p,j))}else g.data.headerTitle=T,r.push(Zr(g,t,{label:y,parent:x},p,j))}return m||(Object.keys(b).length&&!Pe(e)?qt({flowConfig:i,chldPth:null,edges:n,isInverted:null,itrblObjct:b,nodes:r,path:t,newConfig:f}):Pe(e)&&e.forEach((g,w)=>{g=ku(g,Mt);const v=g,_=Dr(g),C=zr(g),{newConfig:S,arrayObject:T}=Vr(g);T.length&&(g=T);const{config:k}=ct(typeof g=="string"?"text":"array",S),{hideConfig:j,sourceLabel:P,label:R,isEdgeAnimated:I,parent:O}=S;u=u||j;const M=t==="root"&&i.isCntr,q=t.split(".").slice(0,2).join("."),H=un.includes(q),V=i.isCntr&&H||w%2===0&&M;let re=`${t}.${w}`;re=Bt(re,r),V&&un.push(re),fr(g)?Object.keys(_).length&&!Pe(g)?(n.push(Br(t,re,null,P,V,I)),Yr(g,re,r,n,R||w,i,S)):Object.keys(C).length&&!Pe(g)?qt({flowConfig:i,chldPth:re,isInverted:V,edges:n,itrblObjct:C,nodes:r,path:t,newConfig:S,forceIsInverted:!0}):Pe(g)?Wy({flowConfig:i,chldPth:re,edges:n,isInverted:V,item:g,nodes:r,path:t}):fr(g)&&qt({flowConfig:i,chldPth:re,isInverted:V,edges:n,itrblObjct:[g],nodes:r,path:t,newConfig:S}):(n.push(Br(t,re,null,P,V,I)),r.push(Zr(k,re,{label:R||String(g),parent:O},g,v)))})),{nodes:r,edges:n}}catch{return{nodes:r,edges:n}}}const qt=({chldPth:e,flowConfig:t,edges:r,itrblObjct:n,nodes:o,isInverted:i,path:a,newConfig:s,forceIsInverted:u=!1})=>{let{hideDefaultObject:c,sprtObjctKy:l}=t;return Object.entries(n).forEach(([d,f],p)=>{f=ku(f,Mt);const b=f,y=Dr(f),m=zr(f),{newConfig:x,arrayObject:g}=Vr(f);g.length&&(f=g);const{hideConfig:w,sourceLabel:v,label:_,content:C,target:S,targetLabel:T,collapsed:k,isEdgeAnimated:j,parent:P}=x;c=c||w;const R=a==="root"&&t.isCntr,I=a.split(".").slice(0,2).join("."),O=un.includes(I);u||(i=t.isCntr&&O||p%2===0&&R);let M=e?`${e}.${d}`:`${a}.${d}`;if(M=Bt(M,o),i&&un.push(M),S&&r.push(Br(M,S,null,T,i,j)),fr(f)&&!Pe(f)){r.push(Br(a,M,null,v,i,j));const q=l||Object.keys(y).length===0;if(q){const H=C?"object":"array",{config:V}=ct(H,x);V.data.headerTitle=C?_:null,o.push(Zr(V,M,{label:_||d,parent:P},f,b))}if(Object.keys(y).length&&!c){const H=Pe(f)?` ${f.length||""}`:`{${Object.keys(f).length||""}}`;let V=M;q&&(V=`${M}.${H}`,V=Bt(V,o),r.push(Br(M,V,null,v,i,j))),Yr(f,V,o,r,_||d,t,x)}else Object.keys(m).length&&!Pe(f)?qt({chldPth:M,flowConfig:t,itrblObjct:m,path:M,edges:r,nodes:o,newConfig:x,isInverted:i}):Yr(f,M,o,r,d,t,x)}else Pe(f)&&(r.push(Br(a,M,null,v,i,j)),Yr(f,M,o,r,d,t,x))})},Wy=({flowConfig:e,chldPth:t,edges:r,isInverted:n,item:o,nodes:i,path:a})=>o.forEach((s,u)=>{let c=`${t}.${u}`;c=Bt(c,i);const l=s;s=ku(s,Mt);const d=zr(s),f=Dr(s),{newConfig:p}=Vr(s),{collapsed:b,label:y,parent:m,sourceLabel:x,isEdgeAnimated:g,content:w}=p;fr(s)?!Pe(s)&&Object.keys(f).length?(r.push(Br(a,c,null,x,n,g)),Yr(s,c,i,r,u,e,p)):Object.keys(d).length&&!Pe(s)&&!b?qt({chldPth:c,flowConfig:e,itrblObjct:d,path:a,edges:r,nodes:i,isInverted:n,newConfig:p}):Pe(s)&&Wy({flowConfig:e,chldPth:c,edges:r,isInverted:n,item:s,nodes:i,path:a}):(r.push(Br(a,c,null,x,n,g)),i.push(Zr(Ru,c,{label:y||String(s),parent:m},s,l)))});function Vx(e,t){const r=new Set,n=c=>{if(!(!c||typeof c!="object")){typeof c.$parent=="string"&&r.add(c.$parent);for(const[l,d]of Object.entries(c))(!l.startsWith("$")||l==="$")&&n(d)}};if(n(e),!r.size)return t;const o=new Map(t.nodes.map(c=>[c.data.id,c])),i=c=>{var p,b;let l=c.data.id;const d=new Set([c.data.id]);let f=c.data.parent;for(;f&&!d.has(f);)r.has(f)&&o.has(f)&&((p=xe(e,f))!=null&&p.$collapsed)&&(l=f),d.add(f),f=(b=o.get(f))==null?void 0:b.data.parent;return l},a=new Map(t.nodes.map(c=>[c.data.id,i(c)])),s=t.nodes.filter(c=>a.get(c.data.id)===c.data.id).map(c=>{if(!r.has(c.data.id))return c;const l=xe(e,c.data.id),d=!!(l!=null&&l.$collapsed);return{...c,data:{...c.data,...d?{type:"arrayView"}:{},config:{...c.data.config,parentContainer:!0,collapsed:d,...d?{labelBelow:!0,icon:(l==null?void 0:l.$icon)||"PiStack"}:{}}}}}),u=new Set(s.map(c=>c.data.id));return{nodes:s,edges:t.edges.flatMap(c=>{const l=a.get(c.data.source),d=a.get(c.data.target);return!l||!d||!u.has(l)||!u.has(d)?[]:l===c.data.source&&d===c.data.target?[c]:l===d?[]:[{...c,data:{...c.data,source:l,target:d,collapsedEndpoints:c.data.collapsedEndpoints??{source:c.data.source,target:c.data.target}}}]})}}function bn(e){if(!Array.isArray(e==null?void 0:e.$connections))return[];const t=new Map;return e.$connections.flatMap((r,n)=>{if(!r||typeof r!="object")return[];const o=r;if(typeof o.target!="string"||!/^root(?:\.|$)/.test(o.target))return[];if(o.sourceProperty!==void 0&&typeof o.sourceProperty!="string")return[];if(o.targetProperty!==void 0&&typeof o.targetProperty!="string")return[];const i=typeof o.id=="string"&&o.id?JSON.stringify(["id",o.id]):JSON.stringify(["ports",o.target,o.sourceProperty??null,o.targetProperty??null]),a=t.get(i)??0;return t.set(i,a+1),[{value:o,key:`${i}#${a}`,index:n}]})}function Gy(e,t,r){const n=bn(e).find(u=>u.key===t);if(!n)return e;const o=r(n.value),i=e.$connections.flatMap((u,c)=>c===n.index?o?[o]:[]:[u]);if(i.length)return{...e,$connections:i};const{$connections:a,...s}=e;return s}function Wx(e){const t=[],r=(n,o)=>{if(!n||typeof n!="object")return n;if(Array.isArray(n))return n.map((i,a)=>r(i,`${o}.${a}`));for(const i of bn(n)){const a=i.value;t.push({data:{id:`connection:${JSON.stringify([o,i.key])}`,source:o,target:a.target,type:typeof a.type=="string"?a.type:void 0,sourceProperty:a.sourceProperty,targetProperty:a.targetProperty,icon:typeof a.icon=="string"?a.icon:void 0,label:typeof a.label=="string"?a.label:void 0,color:typeof a.color=="string"?a.color:void 0,isEdgeDashed:a.style==="dashed",isEdgeAnimated:a.style==="animated",...["dashed","traveling"].includes(a.animationVariant)?{edgeAnimationVariant:a.animationVariant}:{},connection:{address:o,key:i.key}}})}return Object.fromEntries(Object.entries(n).filter(([i])=>i!=="$connections").map(([i,a])=>[i,i==="$"?r(a,o):i.startsWith("$")?a:r(a,`${o}.${i}`)]))};return{json:r(e,"root"),edges:t}}const Dt="root",Cl=e=>e==="#"||e.startsWith("{")||/^\s\d*$/.test(e);function Ir(e){const t=e.split(".");for(t[0]===Dt&&t.shift();t.length&&Cl(t[t.length-1]);)t.pop();return t.filter(r=>!Cl(r))}function mn(e){return e==null||typeof e!="object"?e:Array.isArray(e.$)?e.$:e}function xe(e,t){return Ir(t).reduce((r,n)=>{var o;if(r!=null)return(o=mn(r))==null?void 0:o[n]},e)}function Gx(e){return Array.isArray(e)?[...e]:{...e}}function hr(e,t,r){const n=Ir(t),o=(i,a)=>{if(a===n.length)return r(i);const s=n[a],u=mn(i);if(u==null||typeof u!="object")return i;const c=o(u[s],a+1);if(Object.is(c,u[s]))return i;const l=Gx(u);return l[s]=c,u!==i?{...i,$:l}:l};return o(e,0)}function Tr(e,t,r){const n=r===""&&t!=="$content"||r===void 0||r===null;if(Array.isArray(e))return n?e:{[t]:r,$:[...e]};const o=e!=null&&typeof e=="object"?{...e}:{};return e!=null&&typeof e!="object"&&(o.$label=String(e)),n?delete o[t]:o[t]=r,o}function ir(e,t,r,n){return hr(e,t,o=>r==="$label"&&typeof o=="string"&&typeof n=="string"&&n!==""?n:Tr(o,r,n))}const Uy=(e,t,r)=>ir(e,t,"$collapsed",r);function zt(e){if(e.connection)return{address:e.connection.address,kind:"connection"};const t=e.collapsedEndpoints??e,r=e.isInverted?t.target:t.source,n=e.isInverted?t.source:t.target,o=Ir(r).join("."),i=Ir(n).join(".");return i.startsWith(o?o+".":"")&&i!==o?{address:n,kind:"hierarchy"}:o.startsWith(i?i+".":"")&&o!==i?{address:r,kind:"hierarchy"}:{address:r,kind:"target"}}function Fr(e,t,r,n){if(t.connection){const s=t.connection;return hr(e,s.address,u=>Gy(u,s.key,c=>{if(r==="$edgeIcon")return Tr(c,"icon",n);if(r==="$edgeType")return Tr(c,"type",n);if(r==="$edgeAnimationVariant")return Tr(c,"animationVariant",n);if(r==="$sourceLabel"||r==="$edgeColor")return Tr(c,r==="$sourceLabel"?"label":"color",n);const l=r==="$isEdgeAnimated"?"animated":"dashed";return n?{...c,style:l}:c.style===l?Tr(c,"style",void 0):c}))}const{address:o,kind:i}=zt(t),a=i==="target"&&r==="$sourceLabel"?"$targetLabel":i==="target"&&r==="$edgeType"?"$targetEdgeType":i==="target"&&r==="$edgeIcon"?"$targetIcon":i==="target"&&r==="$edgeAnimationVariant"?"$targetAnimationVariant":r;return hr(e,o,s=>Tr(s,a,n))}const Hy=(e,t,r)=>Fr(Fr(e,t,"$isEdgeAnimated",r==="animated"||void 0),t,"$isEdgeDashed",r==="dashed"||void 0);function Pu(e,t,r,n){let o=n||"";const i=hr(e,t,s=>{const u=mn(s);if(Array.isArray(u)){o=String(u.length);const l=[...u,r];return u===s?l:{...s,$:l}}const c=s!=null&&typeof s=="object"&&!Array.isArray(s)?{...s}:s!=null&&typeof s!="object"?{$label:String(s)}:{};if(!o){let l=1;for(;`node_${l}`in c;)l++;o=`node_${l}`}return c[o]=r,c}),a=Ir(t);return{json:i,address:[Dt,...a,o].join(".")}}function Ky(e,t){const r=Ir(t);if(!r.length)return e;const n=r[r.length-1],o=[Dt,...r.slice(0,-1)].join(".");return hr(e,o,i=>{const a=mn(i);if(a==null||typeof a!="object"||!Object.prototype.hasOwnProperty.call(a,n))return i;if(Array.isArray(a)){const c=a.filter((l,d)=>String(d)!==n);return a===i?c:{...i,$:c}}const{[n]:s,...u}=i;return u})}const Zy=(e,t,r,n)=>ir(n?hr(e,t,o=>Tr(o,"$targetLabel",n)):e,t,"$target",r);function Au(e,t,r){const n=xe(e,t);return bn(n).some(({value:i})=>i.target===r.target&&i.sourceProperty===r.sourceProperty&&i.targetProperty===r.targetProperty)?e:hr(e,t,i=>Tr(i,"$connections",[...Array.isArray(i==null?void 0:i.$connections)?i.$connections:[],{...r,id:r.id||Eu()}]))}function Jy(e,t){if(t.connection){const i=t.connection;return bn(xe(e,i.address)).some(a=>a.key===i.key)?{json:hr(e,i.address,a=>Gy(a,i.key,()=>null)),removed:!0}:{json:e,removed:!1}}const{address:r,kind:n}=zt(t);return n==="hierarchy"?xe(e,r)===void 0?{json:e,removed:!1}:{json:hr(e,r,i=>({...i,$hideParentEdge:!0})),removed:!0}:n!=="target"?{json:e,removed:!1}:{json:hr(e,r,i=>{const{$target:a,$targetLabel:s,...u}=i||{};return u}),removed:!0}}function mu(e,t={}){var x;const r=Wx(e),{nodes:n,edges:o}=Yr(r.json,Dt,[],[],t.title||"untitled",{hideDefaultObject:!!t.hideDefaultObject,sprtObjctKy:!!t.separateObjectKeys,isCntr:!!t.isCenter}),i=new Set(n.map(g=>g.data.id)),a=new Map;for(const g of n){const w=g.data.id;if(!w.endsWith(".0")||xe(e,w)!==void 0)continue;const v=w.slice(0,-2),_=xe(e,v);!i.has(v)&&_&&typeof _=="object"&&!Array.isArray(_)&&typeof _.$label=="string"&&Object.keys(_).every(C=>C.startsWith("$")&&C!=="$")&&a.set(w,v)}const s=g=>a.get(g)??g,u=new Set(n.flatMap(g=>g.data.parent?[s(g.data.parent)]:[])),c=n.map(g=>{var T;const w=s(g.data.id),v=xe(e,w),_={...g.data,id:w},C=v&&typeof v=="object"&&!Array.isArray(v)&&"$"in v?v.$:v;if((Array.isArray(C)?C.length>0:C&&typeof C=="object"&&Object.keys(C).some(k=>!k.startsWith("$")))&&(_.config={..._.config,collapsed:!!v.$collapsed}),u.has(w)||(_.viewProps={..._.viewProps},delete _.viewProps.borderWidth),!v||typeof v!="object"||Array.isArray(v))return{data:_};if(v.$form&&typeof v.$form=="object"&&(_.config={..._.config,form:v.$form},_.type="objectView"),Array.isArray(v.$ports)){const k=v.$ports.filter(j=>j&&typeof j.id=="string"&&["source","target"].includes(j.role)&&["top","right","bottom","left"].includes(j.side));_.config={..._.config,ports:k}}return _.parent&&(_.parent=s(_.parent)),typeof v.$label=="string"&&(_.label=v.$label,_.headerTitle=v.$label),typeof v.$subtitle=="string"&&(_.config={..._.config,subtitle:v.$subtitle}),typeof v.$outline=="boolean"&&(_.viewProps={..._.viewProps,outline:v.$outline}),["solid","dashed","dotted","double"].includes(v.$borderStyle)&&(_.viewProps={..._.viewProps,borderStyle:v.$borderStyle}),Number.isFinite(v.$borderWidth)&&v.$borderWidth>=0&&(_.viewProps={..._.viewProps,borderWidth:v.$borderWidth}),Number.isFinite(v.$borderRadius)&&v.$borderRadius>=0&&(_.viewProps={..._.viewProps,borderRadius:v.$borderRadius}),typeof v.$isNodeAnimated=="boolean"&&(_.isNodeAnimated=v.$isNodeAnimated),["traveling","pulse"].includes(v.$nodeAnimationVariant)&&(_.nodeAnimationVariant=v.$nodeAnimationVariant),typeof v.$content=="string"&&(_.config={..._.config,content:v.$content},v.$view||(_.type="objectView")),(((T=_.config)==null?void 0:T.collapsed)!==void 0||v.$collapsed!==void 0||v.$icon!==void 0)&&(_.config={..._.config||{}},(v.$collapsed!==void 0||_.config.collapsed!==void 0)&&(_.config.collapsed=!!v.$collapsed),v.$icon!==void 0&&(_.config.icon=v.$icon)),{data:_}}),l=new Map,d=o.map(g=>{const w=s(g.data.source),v=s(g.data.target),_=`${w}->${v}`,C=l.get(_)??0;l.set(_,C+1);const S={...g.data,id:C?`${_}#${C}`:_,source:w,target:v},T=zt(S),k=xe(e,T.address);if(k&&typeof k=="object"){const j=k[T.kind==="target"?"$targetEdgeType":"$edgeType"];typeof j=="string"&&(S.type=j);const P=k[T.kind==="target"?"$targetIcon":"$edgeIcon"];typeof P=="string"&&(S.icon=P),k.$isEdgeAnimated!==void 0&&(S.isEdgeAnimated=!!k.$isEdgeAnimated);const R=k[T.kind==="target"?"$targetAnimationVariant":"$edgeAnimationVariant"];["dashed","traveling"].includes(R)&&(S.edgeAnimationVariant=R),k.$isEdgeDashed!==void 0&&(S.isEdgeDashed=!!k.$isEdgeDashed),k.$edgeColor&&(S.color=k.$edgeColor)}return{data:S}});if(!Array.isArray(e)&&(e==null?void 0:e.$hideRoot)===!0){const g=c.findIndex(w=>w.data.id===Dt);g!==-1&&c.splice(g,1)}const f=new Set(c.map(g=>g.data.id));for(let g=d.length-1;g>=0;g--){const w=d[g].data,v=zt(w);(!f.has(w.source)||!f.has(w.target)||v.kind==="hierarchy"&&((x=xe(e,v.address))==null?void 0:x.$hideParentEdge)===!0)&&d.splice(g,1)}d.push(...r.edges.filter(g=>f.has(g.data.source)&&f.has(g.data.target)));const p=Vx(e,{nodes:c,edges:d}),b=p.nodes.filter(g=>{var w;return(w=g.data.config)==null?void 0:w.collapsed}).map(g=>Ir(g.data.id));if(!b.length)return p;const y=p.nodes.filter(g=>{const w=Ir(g.data.id);return!b.some(v=>v.length<w.length&&v.every((_,C)=>_===w[C]))}),m=new Set(y.map(g=>g.data.id));return{nodes:y,edges:p.edges.filter(g=>m.has(g.data.source)&&m.has(g.data.target))}}function Ux(e,t){const r=new Set(e.filter(u=>{var c,l;return(l=(c=u.data)==null?void 0:c.config)==null?void 0:l.collapsed}).map(u=>u.data.id));if(!r.size)return{nodes:e,edges:t};const n=new Map(e.map(u=>[u.data.id,u])),o=new Set(e.map(u=>u.data.parent).filter(Boolean)),i=new Map(e.map(u=>{var f;let c=u.data.id,l=u.data.parent;const d=new Set([c]);for(;l&&!d.has(l);)r.has(l)&&(c=l),d.add(l),l=(f=n.get(l))==null?void 0:f.data.parent;return[u.data.id,c]})),a=new Map;for(const u of t){const c=u.data.isInverted?u.data.target:u.data.source,l=u.data.isInverted?u.data.source:u.data.target;(a.get(c)??a.set(c,[]).get(c)).push(l)}const s=new Set(e.filter(u=>i.get(u.data.id)!==u.data.id).map(u=>u.data.id));for(const u of r){if(o.has(u))continue;const c=[...a.get(u)||[]];for(;c.length;){const l=c.pop();r.has(l)||s.has(l)||(s.add(l),c.push(...a.get(l)||[]))}}return{nodes:e.filter(u=>!s.has(u.data.id)).map(u=>{var c;return r.has(u.data.id)&&o.has(u.data.id)?{...u,data:{...u.data,type:"arrayView",label:u.data.label??u.data.headerTitle,config:{...u.data.config,parentContainer:!0,labelBelow:!0,icon:((c=u.data.config)==null?void 0:c.icon)||"PiStack"}}}:u}),edges:t.flatMap(u=>{const c=i.get(u.data.source)??u.data.source,l=i.get(u.data.target)??u.data.target;return s.has(c)||s.has(l)?[]:c===u.data.source&&l===u.data.target?[u]:c===l?[]:[{...u,data:{...u.data,source:c,target:l,collapsedEndpoints:u.data.collapsedEndpoints??{source:u.data.source,target:u.data.target}}}]})}}function Tu(e,t){const r=JSON.parse(e);let n=512;const o=(a,s=[])=>{if(--n<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(!a||typeof a!="object"||Array.isArray(a))throw new Error("Expected a JSON Schema object.");const u=new Set(["$schema","$id","$defs","definitions","$ref","title","description","default","examples","type","properties","required","items","enum","const","anyOf","additionalProperties"]);for(const l of Object.keys(a))if(!u.has(l))throw new Error(`Unsupported JSON Schema keyword: ${l}`);const c=["$schema","$id","$defs","definitions","title","description","default","examples"];if(a.$ref){if(Object.keys(a).some(d=>!["$ref","title","description"].includes(d)))throw new Error("Use $ref without sibling constraints.");if(typeof a.$ref!="string"||!a.$ref.startsWith("#/")||s.includes(a.$ref))throw new Error("Only nonrecursive local $ref references are supported.");let l=r;for(const d of a.$ref.slice(2).split("/")){const f=d.replace(/~1/g,"/").replace(/~0/g,"~");if(!l||!Object.prototype.hasOwnProperty.call(l,f))throw new Error(`Unresolved reference: ${a.$ref}`);l=l[f]}return o(l,[...s,a.$ref])}if(a.anyOf){if(!Array.isArray(a.anyOf)||!a.anyOf.length||Object.keys(a).some(l=>l!=="anyOf"&&!c.includes(l)))throw new Error("Use a nonempty anyOf without sibling type constraints.");return{kind:"union",types:a.anyOf.map(l=>o(l,s))}}if(Object.prototype.hasOwnProperty.call(a,"const")||a.enum){if(Object.keys(a).some(f=>![...c,"const","enum","type"].includes(f))||a.enum&&Object.prototype.hasOwnProperty.call(a,"const"))throw new Error("Use enum or const without sibling constraints other than type.");const l=Object.prototype.hasOwnProperty.call(a,"const")?[a.const]:a.enum;if(!Array.isArray(l)||!l.length)throw new Error("Expected a nonempty enum.");return{kind:"union",types:l.map(f=>{if(f!==null&&!["string","number","boolean"].includes(typeof f))throw new Error("Only primitive literals are supported.");const p=f===null?"null":typeof f;if(a.type&&!(Array.isArray(a.type)?a.type:[a.type]).some(b=>b===p||b==="integer"&&Number.isInteger(f)))throw new Error("Literal does not match its declared type.");return{kind:"literal",value:f}})}}if(Array.isArray(a.type)){if(!a.type.length||a.type.some(l=>typeof l!="string"))throw new Error("Expected a nonempty list of primitive types.");if(Object.keys(a).some(l=>l!=="type"&&!c.includes(l)))throw new Error("Use anyOf for unions with object or array constraints.");return{kind:"union",types:a.type.map(l=>o({type:l},s))}}if((a.properties||a.required||a.additionalProperties!==void 0)&&a.type!=="object"&&a.type!==void 0)throw new Error("Object constraints require an object type.");if(a.items&&a.type!=="array")throw new Error("items requires an array type.");if(a.type==="object"||a.properties){if(a.additionalProperties!==void 0&&a.additionalProperties!==!0)throw new Error("Closed objects and typed additionalProperties are not supported.");if(!a.properties||typeof a.properties!="object"||Array.isArray(a.properties))throw new Error("Object schemas must declare properties.");if(a.required!==void 0&&(!Array.isArray(a.required)||a.required.some(d=>typeof d!="string"||!Object.prototype.hasOwnProperty.call(a.properties,d))))throw new Error("required must list declared property names.");return{kind:"object",properties:Object.fromEntries(Object.entries(a.properties).map(([d,f])=>[d,{type:o(f,s),optional:!(a.required??[]).includes(d)}]))}}if(a.type==="array")return{kind:"array",items:o(a.items,s)};if(["string","number","integer","boolean","null"].includes(a.type))return{kind:a.type};throw new Error("Every property must declare a supported type.")},i=o(r);if(i.kind!=="object")throw new Error("The root schema must be an object keyed by node ID.");if(Object.values(i.properties).some(a=>a.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:t,nodes:i.properties}}async function Ou(e,t,r,n={}){var b;let o=512;const i=await import("typescript"),a=i.createSourceFile(t,e,i.ScriptTarget.Latest,!0,i.ScriptKind.TS),s=a.parseDiagnostics;if(s!=null&&s.length)throw new Error("Invalid TypeScript syntax.");const u=new Map;for(const y of a.statements){if(!i.isInterfaceDeclaration(y)&&!i.isTypeAliasDeclaration(y))throw new Error("Upload interfaces/type aliases only; imports and executable code are not supported.");if((b=y.typeParameters)!=null&&b.length||u.has(y.name.text))throw new Error("Generics and duplicate declarations are not supported.");u.set(y.name.text,y)}const c=(y,m)=>{var _;const x={},g=y.find(C=>i.isIndexSignatureDeclaration(C));let w;if(g&&n.allowJson&&i.isIndexSignatureDeclaration(g)){if(y.filter(C=>i.isIndexSignatureDeclaration(C)).length!==1||g.parameters.length!==1||((_=g.parameters[0].type)==null?void 0:_.kind)!==i.SyntaxKind.StringKeyword||!g.type)throw new Error("Only one string-keyed index signature is supported for forms.");w=d(g.type,m)}return{kind:"object",properties:Object.fromEntries(y.filter(C=>C!==g||!w).map(C=>{if(!i.isPropertySignature(C)||!C.type||!C.name||!i.isIdentifier(C.name)&&!i.isStringLiteral(C.name))throw new Error("Only explicitly typed named properties are supported.");const S=d(C.type,m),T=n.allowJson?i.getJSDocTags(C).filter(k=>k.tagName.text==="port"):[];if(T.length>1)throw new Error(`Duplicate port declaration: ${C.name.text}`);if(T.length){const[k,j,P]=String(T[0].comment??"").trim().split(/\s+/);if(k!=="config"||!j||P||!u.has(j))throw new Error(`Config port ${C.name.text} requires @port config ResourceType`);const R=S.kind==="array";if((S.kind==="array"?S.items.kind:S.kind)!=="string")throw new Error(`Config port ${C.name.text} must be a string or string array reference`);x[C.name.text]={kind:"config",resourceType:j,multiple:R}}return[C.name.text,{type:S,optional:!!C.questionToken}]})),...w?{additionalProperties:w}:{},...Object.keys(x).length?{ports:x}:{}}},l=(y,m)=>{var _;if(m.includes(y))throw new Error("Recursive types are not supported.");const x=u.get(y);if(!x)throw new Error(`Unknown type: ${y}`);let g;if(i.isInterfaceDeclaration(x)){if((_=x.heritageClauses)!=null&&_.length)throw new Error("Interface inheritance is not supported; declare properties explicitly.");g=c(x.members,[...m,y])}else g=d(x.type,[...m,y]);const w=n.allowJson?i.getJSDocTags(x).filter(C=>C.tagName.text==="port"):[];if(!w.length)return g;if(g.kind!=="object")throw new Error("Node ports require an object interface");const v={...g.ports};for(const C of w){const[S,T,k]=String(C.comment??"").trim().split(/\s+/);if(!["input","output","error"].includes(S)||!/^[A-Za-z][\w-]*$/.test(T??"")||k)throw new Error("Node ports require @port input|output|error Name");if(Object.prototype.hasOwnProperty.call(v,T))throw new Error(`Duplicate port declaration: ${T}`);v[T]={kind:S}}return{...g,ports:v}},d=(y,m)=>{var x,g,w;if(--o<0)throw new Error("Interface exceeds the 512-type expansion limit.");if(y.kind===i.SyntaxKind.StringKeyword)return{kind:"string"};if(y.kind===i.SyntaxKind.NumberKeyword)return{kind:"number"};if(y.kind===i.SyntaxKind.BooleanKeyword)return{kind:"boolean"};if(n.allowJson&&[i.SyntaxKind.AnyKeyword,i.SyntaxKind.UnknownKeyword].includes(y.kind))return{kind:"json"};if(i.isParenthesizedTypeNode(y))return d(y.type,m);if(i.isUnionTypeNode(y))return{kind:"union",types:y.types.map(v=>d(v,m))};if(i.isArrayTypeNode(y))return{kind:"array",items:d(y.elementType,m)};if(i.isTypeLiteralNode(y))return c(y.members,m);if(i.isLiteralTypeNode(y)){const v=y.literal;if(i.isStringLiteral(v))return{kind:"literal",value:v.text};if(i.isNumericLiteral(v))return{kind:"literal",value:Number(v.text)};if(v.kind===i.SyntaxKind.NullKeyword)return{kind:"null"};if(v.kind===i.SyntaxKind.TrueKeyword||v.kind===i.SyntaxKind.FalseKeyword)return{kind:"literal",value:v.kind===i.SyntaxKind.TrueKeyword}}if(i.isTypeReferenceNode(y)&&i.isIdentifier(y.typeName)){if(n.allowJson&&y.typeName.text==="Record"&&!u.has("Record")&&((x=y.typeArguments)==null?void 0:x.length)===2&&y.typeArguments[0].kind===i.SyntaxKind.StringKeyword)return{kind:"object",properties:{},additionalProperties:d(y.typeArguments[1],m)};if(y.typeName.text==="Array"&&((g=y.typeArguments)==null?void 0:g.length)===1)return{kind:"array",items:d(y.typeArguments[0],m)};if(!((w=y.typeArguments)!=null&&w.length))return l(y.typeName.text,m)}throw new Error(`Unsupported TypeScript type: ${y.getText(a)}`)},f=r??(u.has("Graph")?"Graph":u.size===1?[...u.keys()][0]:void 0);if(!f)throw new Error("Declare an interface Graph keyed by node ID.");const p=l(f,[]);if(p.kind!=="object")throw new Error("Graph must be an object keyed by node ID.");return p}async function Yy(e,t){const r=await Ou(e,t);if(Object.values(r.properties).some(n=>n.type.kind!=="object"))throw new Error("Each node must declare an object of property types.");return{name:t,nodes:r.properties}}function jt(e,t){if(e.kind==="json"||t.kind==="json"||e.kind==="object"&&e.additionalProperties||t.kind==="object"&&t.additionalProperties)return!1;if(e.kind==="union")return e.types.every(r=>jt(r,t));if(t.kind==="union")return t.types.some(r=>jt(e,r));if(e.kind==="literal"){if(t.kind==="literal")return e.value===t.value;const r=e.value===null?"null":typeof e.value;return t.kind===r||t.kind==="integer"&&typeof e.value=="number"&&Number.isInteger(e.value)}return e.kind==="integer"&&t.kind==="number"?!0:e.kind==="array"&&t.kind==="array"?jt(e.items,t.items):e.kind==="object"&&t.kind==="object"?Object.entries(t.properties).every(([r,n])=>{const o=Object.prototype.hasOwnProperty.call(e.properties,r)?e.properties[r]:void 0;return o?(n.optional||!o.optional)&&jt(o.type,n.type):n.optional}):e.kind===t.kind}function Iu(e,t){if(!t.sourceProperty&&!t.targetProperty)return;const r=(a,s)=>{var l;const u=Object.prototype.hasOwnProperty.call(e.nodes,a)?a:a.replace(/^root\./,""),c=Object.prototype.hasOwnProperty.call(e.nodes,u)?(l=e.nodes[u])==null?void 0:l.type:void 0;return s&&(c==null?void 0:c.kind)==="object"&&Object.prototype.hasOwnProperty.call(c.properties,s)?c.properties[s]:void 0},n=r(t.source,t.sourceProperty),o=r(t.target,t.targetProperty);if(!n||!o)return"Unverified: source or target property is missing from the interface.";const i=a=>a.kind==="json"||a.kind==="object"&&(!!a.additionalProperties||Object.values(a.properties).some(s=>i(s.type)))||a.kind==="array"&&i(a.items)||a.kind==="union"&&a.types.some(i);if(i(n.type)||i(o.type))return"Unverified: arbitrary JSON or dictionary fields require runtime validation.";if(n.optional&&!o.optional)return"Optional source cannot supply a required target property.";if(!jt(n.type,o.type))return`Incompatible property types: ${t.sourceProperty} -> ${t.targetProperty}.`}async function Xy(e){if(e.size>256*1024)throw new Error("Interface must be 256 KB or smaller.");const t=await e.text();if(/\.json$/i.test(e.name))return Tu(t,e.name);if(/\.ts$/i.test(e.name))return Yy(t,e.name);throw new Error("Choose a .ts interface or .json JSON Schema file.")}const _l=new WeakMap;function Vt(e){if(!e||typeof e!="object")return e;const t=_l.get(e);if(t)return t;const r=()=>{throw new Error("Form callback data is read-only. Return edits instead.")},n=new Proxy(Array.isArray(e)?[]:{},{get:(o,i)=>Vt(Reflect.get(e,i)),has:(o,i)=>Reflect.has(e,i),ownKeys:()=>Reflect.ownKeys(e),getOwnPropertyDescriptor:(o,i)=>{const a=Reflect.getOwnPropertyDescriptor(e,i);return a&&{...a,value:Vt(Reflect.get(e,i)),configurable:i!=="length"||!Array.isArray(e)}},set:r,deleteProperty:r,defineProperty:r,setPrototypeOf:r,preventExtensions:r});return _l.set(e,n),n}function pt(e,t,r){var o;const n=t.split(".");for(let i=n.length;i>0;i--){const a=n.slice(0,i).join("."),s=(o=xe(e,a))==null?void 0:o.$form;if(!(s!=null&&s.$type))continue;let u=Object.prototype.hasOwnProperty.call(r,s.$type)?r[s.$type]:void 0;for(const d of n.slice(i))(u==null?void 0:u.kind)==="array"&&/^\d+$/.test(d)?u=u.items:(u==null?void 0:u.kind)==="object"?u=Object.prototype.hasOwnProperty.call(u.properties,d)?u.properties[d].type:void 0:u=void 0;if((u==null?void 0:u.kind)!=="object")return;const c=n.slice(i).join("."),l=Object.fromEntries(Object.entries(s.$fields??{}).filter(([d])=>!c||d.startsWith(`${c}.`)).map(([d,f])=>[c?d.slice(c.length+1):d,f]));return{type:u,fields:l,binding:s}}}async function Mu(e,t){if(e.size>256*1024)throw new Error("Form schema exceeds 256 KB.");const r=await e.text();if(e.name.endsWith(".ts")){if(!t.length||t.length>32)throw new Error("Choose between 1 and 32 form interface names.");const o=[],i=new Set(t);for(const a of i){if(i.size>32)throw new Error("Choose between 1 and 32 form interface names.");const s=await Ou(r,e.name,a,{allowJson:!0});o.push([a,s]);for(const u of Object.values(s.ports??{}))u.resourceType&&i.add(u.resourceType)}return Object.fromEntries(o)}if(!e.name.endsWith(".json"))throw new Error("Choose a .ts interface or .json schema file.");const n=Tu(r,e.name);return Object.fromEntries(Object.entries(n.nodes).map(([o,i])=>[o,i.type]))}function vn(e,t){return!e||("$in"in e?e.$in.includes(xe(t,e.$address)):xe(t,e.$address)===e.$equals)}function Nt(e){const t=e.kind==="array"?e.items:e,r=t.kind==="union"?t.types:[t];if(r.every(n=>n.kind==="literal"))return r.map(n=>({label:String(n.value),value:n.value}))}function Rr(e,t,r){if(t===void 0||t==="")return r?"Required":void 0;if(e.kind==="json"){const n=new Set,o=i=>{if(i===null||typeof i=="string"||typeof i=="boolean")return!0;if(typeof i=="number")return Number.isFinite(i);if(!i||typeof i!="object"||n.has(i)||!Array.isArray(i)&&![Object.prototype,null].includes(Object.getPrototypeOf(i)))return!1;n.add(i);const a=Object.values(i).every(o);return n.delete(i),a};return o(t)?void 0:"Expected a JSON value"}if(e.kind==="union")return e.types.some(n=>!Rr(n,t,!0))?void 0:"Choose a valid value";if(e.kind==="literal")return t===e.value?void 0:"Choose a valid value";if(e.kind==="array")return Array.isArray(t)&&t.every(n=>!Rr(e.items,n,!0))?void 0:"Invalid list value";if(e.kind==="object")return!t||typeof t!="object"||Array.isArray(t)?"Expected an object":e.additionalProperties&&Object.entries(t).some(([n,o])=>!Object.prototype.hasOwnProperty.call(e.properties,n)&&Rr(e.additionalProperties,o,!0))?"Invalid dictionary value":Object.entries(e.properties).some(([n,o])=>Rr(o.type,t[n],!o.optional))?"Invalid object fields":void 0;if(e.kind==="null")return t===null?void 0:"Expected null";if(e.kind==="integer")return Number.isInteger(t)?void 0:"Expected a whole number";if(typeof t!==e.kind||typeof t=="number"&&!Number.isFinite(t))return`Expected ${e.kind}`}function Sl(e,t){const r=t.address.split(".");if(r.shift()!=="root"||!r.length||r.some(s=>!s||["__proto__","prototype","constructor","#"].includes(s)))throw new Error("Invalid form field address.");const n=r.pop(),o=n==="$bgColor"||n==="$textColor"||n==="$borderColor";if(r.some(s=>s.startsWith("$"))||n.startsWith("$")&&!o)throw new Error("Unsupported form metadata address.");const i=["root",...r].join("."),a=xe(e,i);if(!a||typeof a!="object")throw new Error(`Missing form parent: ${i}`);if(o){if(t.op==="set"&&typeof t.value!="string")throw new Error("Node colors must be strings.");return ir(e,i,n,t.op==="remove"?void 0:t.value)}return hr(e,i,s=>{const u=Array.isArray(s.$)?s.$:s;if(t.op==="remove"&&!Object.prototype.hasOwnProperty.call(u,n)||t.op==="set"&&Object.is(u[n],t.value))return s;const c=Array.isArray(u)?[...u]:{...u};if(Array.isArray(c)&&(!/^(0|[1-9]\d*)$/.test(n)||Number(n)>=c.length))throw new Error("Invalid array address.");return t.op==="remove"?Array.isArray(c)?c.splice(Number(n),1):delete c[n]:Object.defineProperty(c,n,{value:structuredClone(t.value),enumerable:!0,writable:!0,configurable:!0}),u===s?c:{...s,$:c}})}function xn(e,t,r){let n=Sl(e,t.value===void 0?{op:"remove",address:t.address}:{op:"set",address:t.address,value:t.value});const o=r==null?void 0:r({...t,previousValue:Vt(xe(e,t.address)),data:Vt(n)});if(o&&!Array.isArray(o))throw new Error("Form change handlers must return edits synchronously.");for(const i of Array.isArray(o)?o:[]){if(i.op!=="set"&&i.op!=="remove")throw new Error("Unsupported form edit.");n=Sl(n,i)}return n}function Hx(e,t){let r=e;for(const n of t){if(n.op!=="set"&&n.op!=="remove")throw new Error("Unsupported state edit.");const o=n.address.split(".");if(o.some(a=>a.startsWith("$")||["__proto__","prototype","constructor"].includes(a)))throw new Error("State edits cannot target view metadata or unsafe keys.");const i=n.op==="remove"?void 0:n.value;Wt(i),r=xn(r,{address:n.address,nodeAddress:o.slice(0,-1).join("."),value:i})}return Wt(r),r}function Jt(e,t,r){const n=Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;if(!(!n||!r||!Object.prototype.hasOwnProperty.call(r,n.type)))return{address:n.address,type:r[n.type],fields:n.fields??{}}}function Wt(e){if(!(!e||typeof e!="object"))for(const[t,r]of Object.entries(e)){if(t.startsWith("$")||["__proto__","prototype","constructor"].includes(t))throw new Error(`Form state cannot contain view metadata or unsafe keys: ${t}`);Wt(r)}}function Kx(e,t,r){Wt(t.value);const n=xn(e,t,r);return Wt(n),n}function Qy(e,t){const r=(n,o="")=>{if(!n||typeof n!="object")return n;if(["$label","$subtitle","$content","$icon","$bgColor","$textColor","$borderColor"].includes(o)&&typeof n.$state=="string"){const a=xe(t,n.$state);return a==null?"":typeof a=="object"?JSON.stringify(a,null,2):String(a)}let i=n;for(const[a,s]of Object.entries(n)){const u=r(s,a);u!==s&&(i===n&&(i=Array.isArray(n)?[...n]:{...n}),Object.defineProperty(i,a,{value:u,enumerable:!0,writable:!0,configurable:!0}))}return i};return r(e)}const Jr=(e="reference")=>({kind:e,text:"",paths:[""]}),eb=e=>/^[A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*|\.\d+)+$/.test(e)&&!e.split(".").some(t=>["__proto__","constructor","prototype"].includes(t));function Zx(e,t){const r=new Set(t.map(a=>a.path)),n=a=>{if(!a.paths.length||a.paths.some(s=>!eb(s)||!r.has(s)))throw new Error("Choose an available reference.");return[...a.paths,...a.fallback===void 0?[]:[JSON.stringify(a.fallback)]].join(" || ")},o=a=>{if(a.includes("{{")||a.includes("}}"))throw new Error("Use a reference part for dynamic values.");return a},i=a=>a.map(s=>{if(s.kind==="text")return o(s.text);if(s.kind==="conditional"){if(s.paths.length!==1||s.fallback!==void 0)throw new Error("Choose one condition reference.");return`{{#if ${n(s)}}}${o(s.text)}{{/if}}`}return`{{${n(s)}}}`}).join("");if(e.mode==="reference"||e.mode==="condition"){if(e.parts.length!==1||e.parts[0].kind!=="reference")throw new Error("Choose one reference binding.");const a=i(e.parts);return e.mode==="condition"?`${a} == ${JSON.stringify(e.comparison)}`:a}if(e.mode==="json"){const a=e.fields.map(s=>s.key);if(!a.length||new Set(a).size!==a.length||a.some(s=>!s||["__proto__","constructor","prototype"].includes(s)))throw new Error("Output field names must be unique and nonempty.");return JSON.stringify(Object.fromEntries(e.fields.map(s=>[s.key,i(s.parts)])))}return i(e.parts)}async function Jx(e){const t=await import("typescript"),r=a=>{const s=t.createSourceFile("binding.ts",`(${a})`,t.ScriptTarget.Latest,!0,t.ScriptKind.TS);if(s.parseDiagnostics.length)throw new Error("Unsupported reference expression.");const u=s.statements[0];if(!u||!t.isExpressionStatement(u))throw new Error("Unsupported reference expression.");const c=Jr();c.paths=[];const l=d=>{if(t.isParenthesizedExpression(d))return l(d.expression);if(t.isBinaryExpression(d)&&d.operatorToken.kind===t.SyntaxKind.BarBarToken){l(d.left),l(d.right);return}if(t.isStringLiteral(d)){if(c.fallback!==void 0)throw new Error("Multiple fallback values.");c.fallback=d.text;return}const f=d.getText(s);if(!eb(f)||c.fallback!==void 0)throw new Error("Unsupported reference expression.");c.paths.push(f)};if(l(u.expression),!c.paths.length)throw new Error("A binding needs a reference.");return c},n=a=>{const s=[];let u=0;const c=/\{\{([\s\S]*?)\}\}/g;for(const l of a.matchAll(c)){const d=l.index;if(d<u)continue;d>u&&s.push({...Jr("text"),text:a.slice(u,d)});const f=l[1].trim();if(f.startsWith("#if ")){const p=a.indexOf("{{/if}}",d+l[0].length);if(p<0)throw new Error("Unclosed condition.");s.push({...r(f.slice(4)),kind:"conditional",text:a.slice(d+l[0].length,p)}),u=p+7}else s.push(r(f)),u=d+l[0].length}return u<a.length&&s.push({...Jr("text"),text:a.slice(u)}),s},o={mode:"reference",parts:[Jr()],comparison:"",fields:[]};if(!e)return o;if(e.trim().startsWith("{"))try{const a=JSON.parse(e);if(a&&typeof a=="object"&&!Array.isArray(a)&&Object.values(a).every(s=>typeof s=="string"))return{...o,mode:"json",fields:Object.entries(a).map(([s,u])=>({key:s,parts:n(u)}))}}catch{}const i=n(e);if(i.length===2&&i[0].kind==="reference"&&i[1].kind==="text"){const a=t.createSourceFile("condition.ts",`value ${i[1].text}`,t.ScriptTarget.Latest,!0,t.ScriptKind.TS),s=a.statements[0];if(a.statements.length===1&&t.isExpressionStatement(s)&&t.isBinaryExpression(s.expression)&&s.expression.operatorToken.kind===t.SyntaxKind.EqualsEqualsToken&&t.isStringLiteral(s.expression.right))return{...o,mode:"condition",parts:[i[0]],comparison:s.expression.right.text}}return{...o,mode:i.length===1&&i[0].kind==="reference"?"reference":"template",parts:i}}function jl({parts:e,references:t,onChange:r,disabled:n}){const o=(i,a)=>r(e.map((s,u)=>u===i?{...s,...a}:s));return h.jsxs("div",{style:{display:"grid",gap:12},children:[e.map((i,a)=>h.jsxs("fieldset",{"data-binding-part":a,style:{border:0,padding:0,margin:0,minWidth:0},children:[h.jsxs("legend",{children:["Part ",a+1]}),h.jsxs("div",{style:{display:"flex",gap:8},children:[h.jsxs("span",{"data-form-select":"",style:{flex:1},children:[h.jsxs("select",{"aria-label":"Part type",disabled:n,value:i.kind,onChange:s=>o(a,{kind:s.target.value}),children:[h.jsx("option",{value:"reference",children:"Reference"}),h.jsx("option",{value:"text",children:"Text"}),h.jsx("option",{value:"conditional",children:"Conditional text"})]}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]}),h.jsx(ve,{"aria-label":`Remove part ${a+1}`,title:"Remove part",icon:h.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>r(e.filter((s,u)=>u!==a))})]}),i.kind!=="text"&&h.jsxs(h.Fragment,{children:[i.paths.map((s,u)=>h.jsxs("label",{children:["Reference ",u+1,h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsxs("select",{"aria-label":`Reference ${u+1}`,disabled:n,value:s,onChange:c=>o(a,{paths:i.paths.map((l,d)=>d===u?c.target.value:l)}),children:[h.jsx("option",{value:"",children:"Select reference"}),t.map(c=>h.jsx("option",{value:c.path,children:c.label},c.path))]}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]},u)),i.kind==="reference"&&h.jsxs(h.Fragment,{children:[h.jsx(ve,{"aria-label":"Add fallback reference",title:"Add fallback reference",icon:h.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>o(a,{paths:[...i.paths,""]})}),h.jsxs("label",{style:{display:"flex",gap:8,alignItems:"center"},children:[h.jsx("input",{type:"checkbox","aria-label":"Default value enabled",disabled:n,checked:i.fallback!==void 0,onChange:s=>o(a,{fallback:s.target.checked?"":void 0})}),"Default value"]}),i.fallback!==void 0&&h.jsx("input",{"aria-label":"Default value",disabled:n,value:i.fallback,onChange:s=>o(a,{fallback:s.target.value})})]})]}),i.kind!=="reference"&&h.jsxs("label",{children:["Text",h.jsx("textarea",{"aria-label":"Part text",disabled:n,value:i.text,onChange:s=>o(a,{text:s.target.value})})]})]},a)),h.jsx(ve,{"aria-label":"Add part",title:"Add part",icon:h.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:n,onClick:()=>r([...e,Jr()])})]})}function Yx({label:e,value:t,references:r,disabled:n,onChange:o}){const[i,a]=E.useState(),[s,u]=E.useState(""),[c,l]=E.useState(!1),d=async()=>{l(!0),u("");try{a(await Jx(typeof t=="string"?t:""))}catch(f){u(f instanceof Error?f.message:"Unable to read binding.")}finally{l(!1)}};return h.jsxs("div",{"data-runtime-binding":e,style:{marginBottom:8},children:[h.jsx(ve,{"aria-label":`Bind ${e}`,title:`Bind ${e}`,icon:h.jsx(Z.PiLink,{size:18}),size:"sm",variant:"ghost",disabled:n||c,onClick:d}),typeof t=="string"&&t.includes("{{")&&h.jsx("span",{children:"Bound value"}),i&&h.jsxs("fieldset",{disabled:n,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[h.jsxs("label",{children:["Binding mode",h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsxs("select",{"aria-label":"Binding mode",value:i.mode,onChange:f=>a({...i,mode:f.target.value,parts:[Jr()]}),children:[h.jsx("option",{value:"reference",children:"Reference"}),h.jsx("option",{value:"condition",children:"Equals"}),h.jsx("option",{value:"template",children:"Text template"}),h.jsx("option",{value:"json",children:"JSON output"})]}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),i.mode==="json"?h.jsxs(h.Fragment,{children:[i.fields.map((f,p)=>h.jsxs("fieldset",{"data-output-field":p,style:{border:0,margin:0,padding:"8px 0",minWidth:0},children:[h.jsxs("label",{children:["Output field name",h.jsx("input",{"aria-label":"Output field name",value:f.key,onChange:b=>a({...i,fields:i.fields.map((y,m)=>m===p?{...y,key:b.target.value}:y)})})]}),h.jsx(jl,{parts:f.parts,references:r,disabled:n,onChange:b=>a({...i,fields:i.fields.map((y,m)=>m===p?{...y,parts:b}:y)})}),h.jsx(ve,{"aria-label":"Remove output field",title:"Remove output field",icon:h.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",onClick:()=>a({...i,fields:i.fields.filter((b,y)=>y!==p)})})]},p)),h.jsx(ve,{"aria-label":"Add output field",title:"Add output field",icon:h.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",onClick:()=>a({...i,fields:[...i.fields,{key:"",parts:[Jr()]}]})})]}):h.jsx(jl,{parts:i.parts,references:r,disabled:n,onChange:f=>a({...i,parts:f})}),i.mode==="condition"&&h.jsxs("label",{children:["Equals",h.jsx("input",{"aria-label":"Comparison value",value:i.comparison,onChange:f=>a({...i,comparison:f.target.value})})]}),h.jsxs("div",{style:{display:"flex",gap:8,marginTop:12},children:[h.jsx(ve,{"aria-label":"Apply binding",title:"Apply binding",icon:h.jsx(Z.PiCheck,{size:20}),size:"sm",variant:"ghost",onClick:()=>{try{o(Zx(i,r)),a(void 0),u("")}catch(f){u(f instanceof Error?f.message:"Unable to apply binding.")}}}),h.jsx(ve,{"aria-label":"Cancel binding",title:"Cancel binding",icon:h.jsx(Z.PiX,{size:20}),size:"sm",variant:"ghost",onClick:()=>{a(void 0),u("")}})]})]}),s&&h.jsx("p",{role:"alert",children:s})]})}const Xx=e=>!!e&&!e.includes(".")&&!e.startsWith("$")&&!["__proto__","constructor","prototype"].includes(e),Qx=e=>`root.__form_${encodeURIComponent(e).replace(/\./g,"%2E")}`,Et=(e,t)=>JSON.stringify([e,t]);function Gt(e,t){if(e.kind==="union"){const r=e.types.find(n=>n.kind===(Array.isArray(t)?"array":t===null?"null":typeof t)||n.kind==="literal"&&Object.is(n.value,t));return Gt(r??e.types.find(n=>n.kind!=="null")??e.types[0]??{kind:"json"},t)}return e.kind!=="json"?e:Array.isArray(t)?{kind:"array",items:{kind:"json"}}:t!==null&&typeof t=="object"||t===void 0?{kind:"object",properties:{},additionalProperties:{kind:"json"}}:{kind:t===null?"null":typeof t}}function Rt(e){const t=Gt(e,void 0);return t.kind==="object"?{}:t.kind==="array"?[]:t.kind==="literal"?t.value:t.kind==="number"||t.kind==="integer"?0:t.kind==="boolean"?!1:t.kind==="null"?null:""}function El(e){return e.kind==="json"?[{kind:"string"},{kind:"number"},{kind:"boolean"},{kind:"null"},{kind:"object",properties:{},additionalProperties:{kind:"json"}},{kind:"array",items:{kind:"json"}}]:e.kind==="union"&&!Nt(e)?e.types:[e]}function e0(e,t,r){if(t.address===r.address)return;const n=xe(e,t.address),o=(i,a)=>a===void 0?!1:i.kind==="union"?i.types.some(s=>o(s,a)):i.kind==="array"?Array.isArray(a)&&a.every(s=>o(i.items,s)):i.kind==="object"?!!a&&typeof a=="object"&&!Array.isArray(a)&&Object.entries(i.properties).every(([s,u])=>u.optional&&a[s]===void 0||o(u.type,a[s]))&&Object.entries(a).every(([s,u])=>Object.prototype.hasOwnProperty.call(i.properties,s)||!i.additionalProperties||o(i.additionalProperties,u)):a===""?i.kind==="string"||i.kind==="json"||i.kind==="literal"&&i.value==="":!Rr(i,a,!0);if(o(r.type,n))return structuredClone(n)}function r0(e,t,r,n){var u;const o={sourceSchema:r,sourceBindings:t,nodes:[],edges:[],schema:{...r},bindings:{...t},slots:new Map,containers:new Map},i=new Set(n.map(c=>c.data.id)),a=new Map(n.flatMap(c=>{const l=t[c.data.id];return l&&r[l.type]?[[l.address,c.data.id]]:[]})),s=(c,l,d,f,p,b=!1)=>{var C,S,T;if(p>24||o.containers.size>512)throw new Error("Structured form exceeds the flow node limit.");const y=xe(e,l),m=Gt(d,y),x=m.kind!=="object"&&m.kind!=="array";o.containers.set(c,{address:l,type:m,declared:d,scalar:x});const g=`__form:${c}`,w={...(C=o.bindings[c])==null?void 0:C.fields},v={kind:"object",properties:{},ports:{...m.kind==="object"?m.ports:{},...b?{resource:{kind:"output"}}:{}}},_=m.kind==="object"?{...m.properties,...Object.fromEntries(Object.keys(y??{}).filter(k=>!Object.prototype.hasOwnProperty.call(m.properties,k)&&m.additionalProperties).map(k=>[k,{type:m.additionalProperties,optional:!0}]))}:m.kind==="array"?Object.fromEntries((Array.isArray(y)?y:[]).map((k,j)=>[String(j),{type:m.items,optional:!0}])):{value:{type:Nt(d)?d:m,optional:!1}};for(const[k,j]of Object.entries(_)){if(!Xx(k))throw new Error(`Unsupported structured property key: ${k}`);const P=x?l:`${l}.${k}`,R=xe(e,P),I=Gt(j.type,R),O=I.kind==="object"||I.kind==="array",M=(S=v.ports)==null?void 0:S[k],q=(M==null?void 0:M.kind)==="config"&&(((T=w[k])==null?void 0:T.$options)||Nt(j.type)),H=j.type.kind==="json"||j.type.kind==="union"&&!Nt(j.type);if(!O&&m.kind!=="array"&&(!H||x)||q){v.properties[k]={...j,type:j.type.kind==="json"?I:j.type};continue}const V=a.get(P)??Qx(P),re=m.kind==="array"?`Item ${Number(k)+1}`:k,ce={address:P,owner:c,field:k,type:j.type,label:re,nodeId:V,present:R!==void 0};if(o.slots.set(Et(c,k),ce),v.ports[k]={kind:"config",resourceType:`__form:${V}`},R===void 0||(o.edges.push({data:{id:`__form-edge:${c}:${k}`,source:V,target:c,sourceProperty:"output:resource",targetProperty:`config:${k}`,isEdgeDashed:!0}}),o.containers.has(V)||a.has(P)))continue;if(i.has(V))throw new Error(`Structured node identity conflict: ${V}`);i.add(V);const le={data:{id:V,type:"objectView",label:re,headerTitle:re,description:{},config:{form:!0,icon:I.kind==="array"?"PiListNumbers":O?"PiBracketsCurly":"PiTextT"},viewProps:{bgColor:f}}};o.nodes.push(le),s(V,P,j.type,f,p+1,!0);const be=o.schema[`__form:${V}`];le.data.description=Object.fromEntries(Object.keys(be.properties).map(K=>[K,xe(e,I.kind==="array"||I.kind==="object"?`${P}.${K}`:P)]).filter(([,K])=>K!==void 0))}o.schema[g]=v,o.bindings[c]={...o.bindings[c],address:l,type:g,fields:w}};for(const c of n){const l=t[c.data.id],d=l&&r[l.type];!l||!d||xe(e,l.address)===void 0||s(c.data.id,l.address,d,(u=c.data.viewProps)==null?void 0:u.bgColor,0,o.edges.some(f=>f.data.source===c.data.id))}for(const c of o.edges){const l=o.bindings[c.data.source];o.schema[l.type].ports.resource={kind:"output"}}return o}function t0({nodeAddress:e}){const{structured:t,data:r,callbacks:n,editable:o}=E.useContext(kr),i=Ie(),[a,s]=E.useState(""),[u,c]=E.useState("0"),[l,d]=E.useState(""),f=t==null?void 0:t.containers.get(e);if(!f||!r||!t)return null;const p=i.readOnly||i.config.editable===!1||!o,b=xe(r,f.address),y=El(f.declared),m=f.type.kind==="array"?f.type.items:f.type.kind==="object"?f.type.additionalProperties:void 0,x=m?El(m):[],g=j=>j.kind==="literal"?String(j.value):j.kind==="string"?"Text":Cr(j.kind),w=[...t.slots.values()].filter(j=>j.owner===e),v=(j,P)=>{var R;return(R=n.onFormChange)==null?void 0:R.call(n,{data:r,nodeAddress:f.address,address:j,previousValue:xe(r,j),value:P})},_=j=>{var P;i.setSelectedNodeIds([j]),(P=i.engineRef.current)==null||P.focusNode(j,90,!1)},C=(j,P)=>{if(!Array.isArray(b))return;const R=[...b];[R[j],R[j+P]]=[R[j+P],R[j]],v(f.address,R)},S=()=>{const j=x[Number(u)]??x[0];if(j)if(f.type.kind==="array")v(f.address,[...Array.isArray(b)?b:[],Rt(j)]);else{if(!a||a.includes(".")||a.startsWith("$")||["__proto__","constructor","prototype"].includes(a)){d("Choose a property name without dots or reserved prefixes.");return}if(Object.prototype.hasOwnProperty.call(b,a)){d("Property already exists.");return}v(`${f.address}.${a}`,Rt(j)),s(""),d("")}},T=f.type.kind==="object"&&!!f.type.additionalProperties,k=f.type.kind==="array";return h.jsxs("div",{"data-structured-controls":"",style:{display:"grid",gap:8,minWidth:0},children:[y.length>1&&h.jsxs("label",{children:["Value type",h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsx("select",{"aria-label":"Value type",disabled:p,value:y.findIndex(j=>Gt(j,b).kind===f.type.kind),onChange:j=>v(f.address,Rt(y[Number(j.target.value)])),children:y.map((j,P)=>h.jsx("option",{value:P,children:g(j)},P))}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),w.map((j,P)=>h.jsxs("div",{"data-structured-slot":j.address,style:{display:"flex",gap:6,alignItems:"center",minWidth:0},children:[j.type.kind==="array"?h.jsx(Z.PiListNumbers,{size:20}):h.jsx(Z.PiBracketsCurly,{size:20}),h.jsx("span",{style:{flex:1,overflowWrap:"anywhere"},children:Cr(j.label)}),h.jsx(ve,{"aria-label":`${j.present?"Focus":"Create"} ${Cr(j.label)}`,title:`${j.present?"Focus":"Create"} ${Cr(j.label)}`,icon:j.present?h.jsx(Z.PiMagnifyingGlass,{size:18}):h.jsx(Z.PiPlus,{size:18}),size:"sm",variant:"ghost",disabled:p&&!j.present,onClick:R=>{var I;j.present?((I=R.currentTarget.closest("dialog"))==null||I.close(),_(j.nodeId)):v(j.address,Rt(j.type))}}),k&&h.jsxs(h.Fragment,{children:[h.jsx(ve,{"aria-label":`Move item ${P+1} up`,icon:h.jsx(Z.PiArrowUp,{size:18}),size:"sm",variant:"ghost",disabled:p||P===0,onClick:()=>C(P,-1)}),h.jsx(ve,{"aria-label":`Move item ${P+1} down`,icon:h.jsx(Z.PiArrowDown,{size:18}),size:"sm",variant:"ghost",disabled:p||P===w.length-1,onClick:()=>C(P,1)})]}),j.present&&h.jsx(ve,{"aria-label":`Remove ${Cr(j.label)}`,icon:h.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:p,onClick:()=>k?v(f.address,b.filter((R,I)=>I!==P)):v(j.address,void 0)})]},j.address)),(k||T)&&h.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap",alignItems:"end"},children:[T&&h.jsxs("label",{style:{flex:"1 1 120px",minWidth:0},children:["Property name",h.jsx("input",{"aria-label":"Property name",value:a,disabled:p,onChange:j=>s(j.target.value)})]}),x.length>1&&h.jsxs("label",{style:{flex:"1 1 100px"},children:["New value type",h.jsxs("span",{"data-form-select":"",style:{display:"block"},children:[h.jsx("select",{"aria-label":"New value type",value:u,disabled:p,onChange:j=>c(j.target.value),children:x.map((j,P)=>h.jsx("option",{value:P,children:g(j)},P))}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]})]}),h.jsx("span",{style:{display:"flex",alignItems:"center",flexShrink:0,...T||x.length>1?{height:"calc(1.4em + 20px)",fontSize:15,marginBottom:6}:{}},children:h.jsx(ve,{"aria-label":k?"Add item":"Add property",icon:h.jsx(Z.PiPlus,{size:20}),size:"sm",variant:"ghost",disabled:p,onClick:S})})]}),l&&h.jsx("p",{role:"alert",children:l})]})}const kr=E.createContext({callbacks:{}}),tn=gn.default.div`
52
+ padding: 0;
53
+ font-size: 16px;
54
+ line-height: 1.4;
55
+ width: 100%;
56
+ box-sizing: border-box;
57
+ & [data-form-field] {
58
+ padding: 8px 0;
59
+ min-width: 0;
60
+ }
61
+ & label {
62
+ display: block;
63
+ margin-bottom: 6px;
64
+ font-size: 15px;
65
+ }
66
+ & input:not([type="checkbox"]),
67
+ & textarea,
68
+ & select {
69
+ width: 100%;
70
+ min-width: 0;
71
+ box-sizing: border-box;
72
+ font: inherit;
73
+ color: inherit;
74
+ padding: 10px 14px;
75
+ border: 0;
76
+ border-radius: 16px;
77
+ background: color-mix(in srgb, currentColor 7%, transparent);
78
+ outline: none;
79
+ box-shadow: none;
80
+ }
81
+ & textarea {
82
+ min-height: 98px;
83
+ resize: vertical;
84
+ }
85
+ & [data-form-select] {
86
+ position: relative;
87
+ }
88
+ & [data-form-select] select {
89
+ appearance: none;
90
+ padding-right: 40px;
91
+ }
92
+ & [data-form-select] > svg {
93
+ position: absolute;
94
+ right: 12px;
95
+ top: 50%;
96
+ transform: translateY(-50%);
97
+ pointer-events: none;
98
+ }
99
+ & [data-form-select] select:disabled + svg {
100
+ opacity: 0.55;
101
+ }
102
+ & details {
103
+ border-bottom: 1px solid color-mix(in srgb, currentColor 12%, transparent);
104
+ }
105
+ & summary {
106
+ display: flex;
107
+ align-items: center;
108
+ justify-content: space-between;
109
+ gap: 12px;
110
+ padding: 12px 0;
111
+ cursor: pointer;
112
+ font-weight: 600;
113
+ list-style: none;
114
+ }
115
+ & summary::-webkit-details-marker {
116
+ display: none;
117
+ }
118
+ & summary > span {
119
+ min-width: 0;
120
+ overflow-wrap: anywhere;
121
+ }
122
+ & summary > svg {
123
+ flex-shrink: 0;
124
+ transform: rotate(-90deg);
125
+ }
126
+ & details[open] > summary > svg {
127
+ transform: rotate(0deg);
128
+ }
129
+ & input[type="checkbox"] {
130
+ width: 20px;
131
+ height: 20px;
132
+ }
133
+ & button {
134
+ font: inherit;
135
+ cursor: pointer;
136
+ }
137
+ & button:disabled,
138
+ & input:disabled,
139
+ & select:disabled,
140
+ & textarea:disabled {
141
+ cursor: default;
142
+ opacity: 0.55;
143
+ }
144
+ & [role="alert"] {
145
+ color: #dc2626;
146
+ font-size: 14px;
147
+ margin-top: 8px;
148
+ }
149
+ `;function Rl({request:e,property:t,config:r,value:n,disabled:o}){var B,W;const{callbacks:i,structured:a,references:s}=E.useContext(kr),{themeColor:u}=Ie(),{background:c}=Ve(),l=E.useId(),d=t.type.kind==="object"||t.type.kind==="array"||t.type.kind==="json",f=n===void 0?"":d?JSON.stringify(n,null,2):String(n),[p,b]=E.useState(f),[y,m]=E.useState(""),[x,g]=E.useState(0),[w,v]=E.useState(),_=((B=r.$options)==null?void 0:B.$source)==="callback",C=i.resolveFormOptions,{data:S,address:T,nodeAddress:k,nodeId:j}=e,P=E.useRef(S);P.current=S;const R=JSON.stringify([T,j,(W=r.$options)!=null&&W.$dependsOn?r.$options.$dependsOn.map(z=>xe(S,z)):xe(S,k)]);E.useEffect(()=>{b(f),m("")},[f,T,j]),E.useEffect(()=>{if(!_)return;const z=new AbortController;return Promise.resolve().then(()=>{if(!C)throw new Error("No options resolver configured");return C({address:T,nodeAddress:k,nodeId:j,data:Vt(P.current),signal:z.signal})}).then(X=>{if(!Array.isArray(X)||X.some(se=>!se||typeof se.label!="string"||!["string","number","boolean"].includes(typeof se.value)&&se.value!==null))throw new Error("Invalid options response");z.signal.aborted||v({key:R,options:X})}).catch(X=>{z.signal.aborted||v({key:R,options:[],error:X instanceof Error?X.message:"Options unavailable"})}),()=>z.abort()},[_,C,R,T,k,j,x]);const I=_&&(w==null?void 0:w.key)!==R,O=_?(w==null?void 0:w.key)===R?w.options:[]:t.type.kind==="null"?[{label:"Null",value:null}]:t.type.kind==="boolean"?[{label:"Yes",value:!0},{label:"No",value:!1}]:Nt(t.type),M=t.type.kind==="array",q=(a&&d||r.$control==="checkbox"?"pills":r.$control)??(O?M||t.type.kind==="boolean"?"pills":"select":t.type.kind==="boolean"?"checkbox":d?"textarea":"input"),H=!t.optional||!!r.$requiredWhen&&vn(r.$requiredWhen,S),V=!!(s!=null&&s.length)&&typeof n=="string"&&n.includes("{{"),re=y||_&&(w==null?void 0:w.key)===R&&w.error||!V&&Rr(t.type,n,H),ce=Cr(r.$label??T.split(".").pop()),le=z=>{var X;if(!(o||Object.is(z,n)))try{(X=i.onFormChange)==null||X.call(i,{...e,previousValue:n,value:z}),m("")}catch(se){m(se instanceof Error?se.message:"Unable to update field")}},be=()=>{if(d){try{const Q=p===""&&t.optional?void 0:JSON.parse(p),G=Rr(t.type,Q,H);if(G){m(G);return}le(Q)}catch{m("Enter valid JSON")}return}const z=t.type.kind==="number"||t.type.kind==="integer",X=p===""&&t.optional?void 0:z&&p!==""?Number(p):p,se=Rr(t.type,X,H);if(z&&se&&p!==""){m(se);return}le(X)},K={id:l,disabled:o,"aria-label":ce,"aria-required":H,"aria-invalid":!!re,"aria-describedby":re?`${l}-error`:void 0},N=pe(u);return h.jsxs("div",{"data-form-field":T,"data-flow-property":T.slice(k.length+1),children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[h.jsxs("label",{htmlFor:l,children:[ce,H?" *":""]}),t.optional&&n!==void 0&&h.jsx("button",{type:"button","aria-label":`Reset ${ce}`,title:`Reset ${ce}`,disabled:o,style:{width:24,height:24,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:0,background:"transparent",color:"inherit"},onClick:()=>le(void 0),children:h.jsx(Z.PiArrowCounterClockwise,{size:14})})]}),!!(s!=null&&s.length)&&!d&&h.jsx(Yx,{label:ce,value:n,references:s,disabled:o,onChange:le}),V?null:q==="select"?h.jsxs("div",{"data-form-select":"",children:[h.jsxs("select",{...K,disabled:o||I||!!(w!=null&&w.error),value:(O==null?void 0:O.findIndex(z=>Object.is(z.value,n)))??-1,onChange:z=>{const X=O==null?void 0:O[Number(z.target.value)];X&&le(X.value)},children:[h.jsx("option",{value:-1,disabled:!0,children:n!==void 0?String(n):""}),O==null?void 0:O.map((z,X)=>h.jsx("option",{value:X,style:{background:pe(c)},children:Cr(z.label)||z.label},X))]}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]}):q==="pills"?h.jsxs("div",{id:l,role:"group","aria-label":ce,"aria-describedby":K["aria-describedby"],style:{display:"flex",flexWrap:"wrap",gap:8},children:[O==null?void 0:O.map((z,X)=>{const se=M?Array.isArray(n)&&n.includes(z.value):Object.is(n,z.value);return h.jsx("button",{type:"button",disabled:o||I,"aria-pressed":se,style:{padding:"8px 16px",borderRadius:24,border:0,color:se?N:"inherit",background:se?"color-mix(in srgb, currentColor 12%, transparent)":"color-mix(in srgb, currentColor 7%, transparent)"},onClick:()=>le(M?se?n.filter(Q=>Q!==z.value):[...Array.isArray(n)?n:[],z.value]:z.value),children:Cr(z.label)||z.label},X)}),I&&h.jsx("span",{role:"status",children:"Loading..."})]}):q==="textarea"?h.jsx("textarea",{...K,value:p,onChange:z=>b(z.target.value),onBlur:be}):h.jsx("input",{...K,type:t.type.kind==="number"||t.type.kind==="integer"?"number":"text",step:t.type.kind==="integer"?1:"any",value:p,onChange:z=>b(z.target.value),onBlur:be,onKeyDown:z=>{z.key==="Enter"&&be(),z.key==="Escape"&&b(n===void 0?"":String(n))}}),re&&h.jsx("div",{role:"alert",id:`${l}-error`,children:re}),_&&(w==null?void 0:w.error)&&h.jsx("button",{type:"button",disabled:o,onClick:()=>{v(void 0),g(x+1)},children:"Retry"})]})}function rb({nodeAddress:e}){var v,_;const{data:t,schema:r,callbacks:n,bindings:o,editable:i,renderForm:a,structured:s}=E.useContext(kr),{readOnly:u,config:c}=Ie(),l=a==null?void 0:a(e);if(l!==void 0)return h.jsx("fieldset",{"data-flow-form":e,disabled:u||c.editable===!1||!i,style:{border:0,margin:0,padding:0,minWidth:0},children:l});if(!t)return h.jsx(tn,{role:"alert",children:"Forms require a JSON document."});const d=o?Jt(o,e,r):void 0,f=o?d:r&&pt(t,e,r);if(!f)return h.jsx(tn,{role:"status",children:"Form schema unavailable."});const p=(d==null?void 0:d.address)??e,b=xe(t,p),y=(v=s==null?void 0:s.containers.get(e))==null?void 0:v.scalar;if(b===void 0||typeof b!="object"&&!y)return h.jsx(tn,{role:"alert",children:"Bound form state is unavailable."});const m=Object.entries(f.type.properties).filter(([C])=>{var S;return vn((S=f.fields[C])==null?void 0:S.$visibleWhen,t)}),x=m.length>8||m.some(([C])=>{var S;return(S=f.fields[C])==null?void 0:S.$section}),g=new Map;for(const C of m){const[S,T]=C,k=x?Cr(((_=f.fields[S])==null?void 0:_.$section)??(T.type.kind==="object"||T.type.kind==="array"?S:T.optional?"Options":"General")):"";g.has(k)||g.set(k,[]),g.get(k).push(C)}const w=([C,S])=>h.jsx(Rl,{request:{data:t,address:y?p:`${p}.${C}`,nodeAddress:p,nodeId:typeof(b==null?void 0:b.id)=="string"?b.id:void 0},property:S,config:f.fields[C]??{},value:y?b:b==null?void 0:b[C],disabled:u||c.editable===!1||!(i??!!n.onJsonChange)},`${(b==null?void 0:b.id)??e}:${C}`);return h.jsxs(tn,{"data-flow-form":e,onClick:C=>C.stopPropagation(),onDoubleClick:C=>C.stopPropagation(),children:[s&&h.jsx(t0,{nodeAddress:e}),d&&f.type.additionalProperties&&m.length===0&&h.jsx(Rl,{request:{data:t,address:p,nodeAddress:p},property:{type:f.type,optional:!1},config:{$label:"Configuration",$control:"textarea"},value:b,disabled:u||c.editable===!1||!i}),[...g].map(([C,S])=>x&&S.length>1?h.jsxs("details",{open:!0,children:[h.jsxs("summary",{children:[h.jsx("span",{children:C}),h.jsx(Z.PiCaretDown,{size:16,"aria-hidden":"true"})]}),S.map(w)]},C):S.map(w))]})}function tb(e){const{viewData:t}=E.useContext(kr),{nodeById:r,edgeById:n,parentIds:o}=Wr();if(t){const i=xe(t,e),a=i&&typeof i=="object"&&!Array.isArray(i)&&"$"in i?i.$:i;return Array.isArray(a)?a.length>0:!!a&&typeof a=="object"&&Object.entries(a).some(([s,u])=>!s.startsWith("$")&&u!==null&&typeof u=="object")}return o.has(e)?!0:[...n.values()].some(({data:i})=>{const a=i.isInverted?i.target:i.source,s=i.isInverted?i.source:i.target;return a===e&&s!==e&&r.has(s)})}function Ut(e,t){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:t}function ln(e,t,r,n){return{borderColor:t,borderWidth:Ut(e==null?void 0:e.borderWidth,n),borderStyle:(e==null?void 0:e.borderStyle)??"solid",...Su(t==="transparent"?"currentColor":t,r,".flow-sdk-node:hover &",!r)}}function nb({label:e,value:t,options:r,onChange:n,disabled:o}){var i;return h.jsxs(Or,{"aria-label":e,title:`Animation: ${((i=r.find(a=>a.value===t))==null?void 0:i.label)??"Mixed"}`,value:t,style:{width:104},disabled:o,onValueChange:a=>{const s=r.find(u=>u.value===a);s&&n(s.value)},children:[t===""&&h.jsx("option",{value:"",disabled:!0,children:"Mixed"}),r.map(a=>h.jsx("option",{value:a.value,children:a.label},a.value))]})}const dn="data:image/svg+xml;base64,";function kt(e){if(e.startsWith(dn))return!0;try{const t=new URL(e);return(t.protocol==="https:"||t.protocol==="http:")&&!t.username&&!t.password}catch{return!1}}async function n0(e){if(e.size>256*1024)throw new Error("SVG must be 256 KB or smaller.");const t=await e.text(),r=new DOMParser().parseFromString(t,"image/svg+xml");if(r.doctype||r.querySelector("parsererror")||r.documentElement.localName!=="svg"||r.documentElement.namespaceURI!=="http://www.w3.org/2000/svg")throw new Error("Choose a valid SVG file.");if(r.querySelector("script, foreignObject")||[...r.querySelectorAll("*")].some(i=>[...i.attributes].some(a=>/^on/i.test(a.name))))throw new Error("SVG scripts and event handlers are not allowed.");const n=new TextEncoder().encode(t);let o="";for(const i of n)o+=String.fromCharCode(i);return dn+btoa(o)}const Mr=({name:e,svg:t=!1,...r})=>{const[n,o]=E.useState(null),[i,a]=E.useState(!0),[s,u]=E.useState(!1),c=typeof e=="string"&&kt(e);if(E.useEffect(()=>{if(c||!e||e.length<2){o(null),a(!1);return}a(!0),u(!1),(async()=>{try{let d;if(e.startsWith("Md"))d="md";else if(e.startsWith("Fa"))d="fa6";else if(e.startsWith("Io5"))d="io5";else if(e.startsWith("Io"))d="io";else if(e.startsWith("Ti"))d="ti";else if(e.startsWith("Go"))d="go";else if(e.startsWith("Fi"))d="fi";else if(e.startsWith("Di"))d="di";else if(e.startsWith("Ai"))d="ai";else if(e.startsWith("Bs"))d="bs";else if(e.startsWith("Ri"))d="ri";else if(e.startsWith("Fc"))d="fc";else if(e.startsWith("Gi"))d="gi";else if(e.startsWith("Hi2"))d="hi2";else if(e.startsWith("Hi"))d="hi";else if(e.startsWith("Si"))d="si";else if(e.startsWith("Sl"))d="sl";else if(e.startsWith("Im"))d="im";else if(e.startsWith("Bi"))d="bi";else if(e.startsWith("Pi"))d="pi";else if(e.startsWith("Vsc"))d="vsc";else if(e.startsWith("Tb"))d="tb";else if(e.startsWith("Tfi"))d="tfi";else if(e.startsWith("Cg"))d="cg";else if(e.startsWith("Lia"))d="lia";else if(e.startsWith("Lu"))d="lu";else throw new Error(`Unknown library prefix for icon: ${e}`);let f;switch(d){case"md":f=await import("react-icons/md");break;case"fa6":f=await import("react-icons/fa6");break;case"io5":f=await import("react-icons/io5");break;case"io":f=await import("react-icons/io");break;case"ti":f=await import("react-icons/ti");break;case"go":f=await import("react-icons/go");break;case"fi":f=await import("react-icons/fi");break;case"di":f=await import("react-icons/di");break;case"ai":f=await import("react-icons/ai");break;case"bs":f=await import("react-icons/bs");break;case"ri":f=await import("react-icons/ri");break;case"fc":f=await import("react-icons/fc");break;case"gi":f=await import("react-icons/gi");break;case"hi2":f=await import("react-icons/hi2");break;case"hi":f=await import("react-icons/hi");break;case"si":f=await import("react-icons/si");break;case"sl":f=await import("react-icons/sl");break;case"im":f=await import("react-icons/im");break;case"bi":f=await import("react-icons/bi");break;case"pi":f=await import("react-icons/pi");break;case"vsc":f=await import("react-icons/vsc");break;case"tb":f=await import("react-icons/tb");break;case"tfi":f=await import("react-icons/tfi");break;case"cg":f=await import("react-icons/cg");break;case"lia":f=await import("react-icons/lia");break;case"lu":f=await import("react-icons/lu");break;default:throw new Error(`Unsupported library: ${d}`)}const p=f[e];if(!p)throw new Error(`Icon ${e} not found in library ${d}`);o(()=>p)}catch(d){console.warn(`Failed to load icon ${e}:`,d.message),u(!0),o(null)}finally{a(!1)}})()},[e,c]),c){const{size:l=80,style:d,...f}=r;return t?h.jsx("image",{...f,href:e,width:l,height:l,preserveAspectRatio:"xMidYMid meet",style:d}):h.jsx("img",{...f,src:e,alt:"",width:l,height:l,referrerPolicy:"no-referrer",style:{objectFit:"contain",...d}})}return i||!n?null:h.jsx(n,{...r})};function qu({nodeId:e,edgeId:t,value:r}){const{callbacks:n,readOnly:o,themeColor:i}=Ie(),{background:a,backgroundSecondary:s,border:u,colorText:c}=Ve(),l=E.useRef(null),d=E.useId(),f=E.useRef(null),p=E.useRef(0),[b,y]=E.useState(!1),[m,x]=E.useState("icons"),[g,w]=E.useState([]),[v,_]=E.useState("loading"),[C,S]=E.useState(""),[T,k]=E.useState(0),[j,P]=E.useState(""),[R,I]=E.useState(""),[O,M]=E.useState(!1);E.useEffect(()=>()=>{p.current++},[]),E.useEffect(()=>{if(!b)return;let K=!0;return import("react-icons/pi").then(N=>{K&&(w(Object.keys(N).filter(B=>B.startsWith("Pi")).sort()),_("ready"))}).catch(()=>{K&&_("unavailable")}),()=>{K=!1}},[b]),E.useEffect(()=>{var K;o&&((K=l.current)==null||K.close())},[o]);const q=K=>{var N,B,W;o||(t?(N=n.onEdgeIconChange)==null||N.call(n,t,K):e&&((B=n.onNodeIconChange)==null||B.call(n,e,K)),(W=l.current)==null||W.close())},H=g.filter(K=>K.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase().includes(C.trim().toLowerCase())),V=36,re=Math.max(1,Math.ceil(H.length/V)),ce=Math.min(T,re-1),le=H.slice(ce*V,(ce+1)*V),be={width:"100%",padding:"8px 14px",background:"transparent",color:"inherit",border:`1px solid ${pe(u)}`,borderRadius:30};return h.jsxs(h.Fragment,{children:[h.jsx(je,{label:t?"Choose edge icon":"Choose node icon",children:h.jsx(ve,{"aria-label":t?"Choose edge icon":"Choose node icon",icon:h.jsx(Z.PiShapes,{size:20}),size:"sm",variant:"ghost",color:pe(i),disabled:o,onClick:()=>{var K;I(""),x(r&&kt(r)?"custom":"icons"),P(r&&!r.startsWith(dn)&&kt(r)?r:""),y(!0),(K=l.current)==null||K.showModal()}})}),h.jsx("dialog",{ref:l,"aria-label":t?"Choose edge icon":"Choose node icon",onClose:()=>{y(!1),p.current++,M(!1)},onClick:K=>{K.stopPropagation(),K.target===K.currentTarget&&K.currentTarget.close()},onKeyDown:K=>K.stopPropagation(),style:{margin:"auto",padding:12,width:336,maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100vh - 32px)",overflowY:"auto",border:`1px solid ${pe(u)}`,borderRadius:30,boxShadow:`0 0 0 8px color-mix(in srgb, ${pe(a)} 60%, transparent)`,background:pe(a),color:pe(c)},children:b&&h.jsxs("div",{style:{display:"grid",gap:8},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[h.jsx("strong",{children:t?"Edge icon":"Node icon"}),h.jsxs("div",{style:{display:"flex",alignItems:"center",marginLeft:"auto",gap:4},children:[r&&h.jsx(je,{label:"Remove icon",children:h.jsx(ve,{"aria-label":t?"Remove edge icon":"Remove node icon",icon:h.jsx(Z.PiTrash,{size:18}),size:"sm",variant:"ghost",disabled:o||O,onClick:()=>q("")})}),h.jsx(ht,{"aria-label":"Close icon picker",onClick:()=>{var K;return(K=l.current)==null?void 0:K.close()}})]})]}),h.jsx("div",{role:"tablist","aria-label":"Icon source",style:{display:"flex",borderBottom:`1px solid ${pe(u)}`},children:["icons","custom"].map(K=>h.jsx("button",{id:`${d}-${K}`,type:"button",role:"tab","aria-selected":m===K,"aria-controls":`${d}-panel`,tabIndex:m===K?0:-1,onClick:()=>{x(K),I("")},onKeyDown:N=>{var W;if(!["ArrowLeft","ArrowRight","Home","End"].includes(N.key))return;N.preventDefault();const B=N.key==="Home"?"icons":N.key==="End"||K==="icons"?"custom":"icons";x(B),I(""),(W=document.getElementById(`${d}-${B}`))==null||W.focus()},style:{flex:1,padding:"8px 12px",background:"transparent",border:0,borderBottom:`2px solid ${m===K?pe(i):"transparent"}`,color:m===K?pe(i):"inherit",cursor:"pointer",fontSize:13},children:K==="icons"?"React icons":"Custom SVG"},K))}),h.jsx("input",{ref:f,type:"file",accept:".svg,image/svg+xml","aria-label":"Upload SVG icon",hidden:!0,disabled:O||o,onChange:async K=>{var W;const N=(W=K.target.files)==null?void 0:W[0];if(K.target.value="",!N)return;const B=++p.current;M(!0),I("");try{const z=await n0(N);B===p.current&&q(z)}catch(z){B===p.current&&I(z instanceof Error?z.message:"Unable to read SVG.")}finally{B===p.current&&M(!1)}}}),h.jsx("div",{id:`${d}-panel`,role:"tabpanel","aria-labelledby":`${d}-${m}`,style:{display:"grid",gap:8},children:m==="icons"?h.jsxs(h.Fragment,{children:[h.jsx("input",{"aria-label":"Search icons",placeholder:"Search icons...",value:C,onChange:K=>{S(K.target.value),k(0)},style:be}),h.jsxs("div",{style:{height:244,overflowY:"auto",display:"grid",gridTemplateColumns:"repeat(6, minmax(0, 1fr))",gridAutoRows:36,gap:4},children:[le.map(K=>h.jsx("button",{type:"button","aria-label":`Choose ${K}`,"aria-pressed":r===K,title:K,onClick:()=>q(K),style:{display:"grid",placeItems:"center",borderRadius:5,border:`${r===K?2:1}px solid ${pe(r===K?i:u)}`,background:pe(r===K?a:s),color:"inherit",cursor:"pointer"},children:h.jsx(Mr,{name:K,size:24})},K)),le.length===0&&h.jsx("span",{role:"status",style:{gridColumn:"1 / -1"},children:v==="loading"?"Loading icons...":v==="unavailable"?"React icons unavailable":"No icons found"})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[h.jsxs("span",{role:"status",style:{fontSize:12},children:[H.length," icons · ",ce+1," / ",re]}),h.jsxs("div",{style:{display:"flex",gap:4},children:[h.jsx(je,{label:"Previous icons",children:h.jsx(ve,{"aria-label":"Previous icons",icon:h.jsx(Z.PiCaretLeft,{size:18}),size:"sm",variant:"ghost",disabled:ce===0,onClick:()=>k(ce-1)})}),h.jsx(je,{label:"Next icons",children:h.jsx(ve,{"aria-label":"Next icons",icon:h.jsx(Z.PiCaretRight,{size:18}),size:"sm",variant:"ghost",disabled:ce+1>=re,onClick:()=>k(ce+1)})})]})]})]}):h.jsxs(h.Fragment,{children:[r&&kt(r)&&h.jsx(Mr,{name:r,size:64}),h.jsxs("button",{type:"button",disabled:O||o,onClick:()=>{var K;return(K=f.current)==null?void 0:K.click()},style:{...be,display:"flex",justifyContent:"center",gap:8,alignItems:"center",cursor:"pointer"},children:[h.jsx(Z.PiUploadSimple,{}),O?"Uploading...":"Upload SVG"]}),h.jsxs("form",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},onSubmit:K=>{K.preventDefault(),!(O||o)&&(!kt(j.trim())||j.trim().startsWith(dn)?I("Enter an HTTP or HTTPS image URL."):q(j.trim()))},children:[h.jsx("input",{type:"url","aria-label":"SVG URL",placeholder:"https://example.com/icon.svg",value:j,disabled:O||o,onChange:K=>P(K.target.value),style:{...be,flex:1,minWidth:0}}),h.jsx(je,{label:"Apply URL",children:h.jsx(ve,{type:"submit","aria-label":"Apply URL",icon:h.jsx(Z.PiArrowRight,{size:20}),size:"sm",variant:"ghost",disabled:O||o||!j.trim(),style:{flexShrink:0}})})]})]})}),R&&h.jsx("div",{role:"alert",style:{fontSize:13},children:R})]})})]})}const Nu=["white","blue.500","teal.500","green.500","yellow.500","orange.500","red.500","purple.500","pink.500","gray.500"],ob=["gray.900","gray.600","gray.200","white"];function ib(){const{config:e}=Ie(),t=e.selectionToolbar||{},r=new Set(t.hide||[]);return{palette:t.palette||Nu,show:n=>!r.has(n)}}function cr(){const{border:e}=Ve();return h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:e})}function Xr({value:e,placeholder:t,ariaLabel:r,width:n="140px",type:o="text",min:i,onCommit:a}){const{colorText:s}=Ve(),[u,c]=E.useState(e),l=E.useRef(!1);E.useEffect(()=>c(e),[e]);const d=()=>{if(l.current)return;l.current=!0;const f=u.trim();if(o==="number"&&f!==""&&(!Number.isFinite(Number(f))||Number(f)<(i??0))){c(e);return}f!==e&&a(f)};return h.jsx(F.Input,{"aria-label":r,type:o,min:i,size:"xs",w:n,value:u,placeholder:t,color:s,borderWidth:0,_focusVisible:{boxShadow:"none",outline:"none"},borderRadius:"8px",onFocus:()=>{l.current=!1},onChange:f=>c(f.target.value),onBlur:d,onKeyDown:f=>{f.key==="Enter"&&(d(),f.target.blur()),f.key==="Escape"&&(l.current=!0,c(e),f.target.blur())}})}function Ht({colors:e,value:t,label:r,onPick:n,onReset:o,includeTransparent:i=!0}){const{colorInactive:a,colorText:s}=Ve(),[u,c]=E.useState(!1),l=E.useId(),d=E.useRef(null),f=t??e[0]??"transparent";return h.jsxs(F.HStack,{gap:1,"aria-label":r,role:"group",onKeyDown:p=>{var b;p.key==="Escape"&&(c(!1),(b=d.current)==null||b.focus())},children:[h.jsx(je,{label:`${r}: ${f}`,children:h.jsx(F.chakra.button,{ref:d,type:"button","aria-label":`${r} colors`,"aria-expanded":u,"aria-controls":l,w:4,h:4,flexShrink:0,borderRadius:"full",cursor:"pointer",style:{backgroundColor:pe(f),...f==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:`2px solid ${pe(s)}`,outlineOffset:"1px",onClick:()=>c(p=>!p)})}),u&&h.jsxs(F.HStack,{id:l,gap:1,children:[[...new Set([...e,...i?["transparent"]:[]])].map(p=>{const b=t===p;return h.jsx(je,{label:`${r}: ${p}`,children:h.jsx(F.Box,{as:"button","aria-label":`${r} ${p}`,"aria-pressed":b,w:4,h:4,borderRadius:"full",cursor:"pointer",style:{backgroundColor:pe(p),...p==="transparent"?{backgroundImage:"conic-gradient(#fff 25%, #a0aec0 0 50%, #fff 0 75%, #a0aec0 0)",backgroundSize:"8px 8px"}:{}},outline:b?`2px solid ${pe(s)}`:"none",outlineOffset:"1px",_hover:{transform:"scale(1.15)"},onClick:()=>{var y;n(p),c(!1),(y=d.current)==null||y.focus()}})},p)}),o&&h.jsx(je,{label:`Reset ${r.toLowerCase()}`,children:h.jsx(ve,{"aria-label":`Reset ${r}`,icon:h.jsx(F.Icon,{as:Z.PiEraser,boxSize:4}),size:"xs",variant:"ghost",color:a,onClick:()=>{var p;o(),c(!1),(p=d.current)==null||p.focus()}})})]})]})}function ab({edgeId:e,onClose:t}){var p;const{callbacks:r,themeColor:n,config:o}=Ie(),{colorInactive:i}=Ve(),{edgeById:a}=Wr(),{palette:s,show:u}=ib(),c=(p=a.get(e))==null?void 0:p.data,l=[...new Set(["rounded-orthogonal","orthogonal","straight","bezier",...Object.keys(o.customEdgeTypes??{}),...c!=null&&c.type?[c.type]:[]])],d=c!=null&&c.isEdgeAnimated?"animated":c!=null&&c.isEdgeDashed?"dashed":"solid",f=[{key:"solid",icon:Z.PiLineSegment,label:"Solid"},{key:"dashed",icon:Z.PiLineSegments,label:"Dashed"},{key:"animated",icon:Z.PiFastForward,label:"Animated"}];return h.jsxs(h.Fragment,{children:[h.jsx(ht,{onClick:t}),u("label")&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),h.jsx(Xr,{ariaLabel:"Edge label",placeholder:"Edge label",value:(c==null?void 0:c.label)||"",onCommit:b=>{var y;return(y=r.onEdgeLabelChange)==null?void 0:y.call(r,e,b)}})]}),u("style")&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),f.map(b=>h.jsx(je,{label:b.label,children:h.jsx(ve,{"aria-label":`Edge style ${b.key}`,"aria-pressed":d===b.key,icon:h.jsx(F.Icon,{as:b.icon,boxSize:5}),size:"sm",variant:"ghost",color:d===b.key?n:i,onClick:()=>{var y;return(y=r.onEdgeStyleChange)==null?void 0:y.call(r,e,b.key)}})},b.key)),d==="animated"&&h.jsx(nb,{label:"Edge animation",value:(c==null?void 0:c.edgeAnimationVariant)??"dashed",options:[{value:"dashed",label:"Dash"},{value:"traveling",label:"Trace"}],disabled:o.readOnly,onChange:b=>{var y;return(y=r.onEdgeAnimationVariantChange)==null?void 0:y.call(r,e,b)}}),h.jsxs(Or,{"aria-label":"Edge shape",title:`Edge shape: ${(c==null?void 0:c.type)??"Default"}`,icon:h.jsx(Z.PiBezierCurve,{size:20}),style:{width:36},value:(c==null?void 0:c.type)??"",disabled:o.readOnly,onValueChange:b=>{var y;return(y=r.onEdgeTypeChange)==null?void 0:y.call(r,e,b||void 0)},children:[h.jsx("option",{value:"",children:"Default"}),l.map(b=>h.jsx("option",{value:b,children:b},b))]})]}),u("icon")&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),h.jsx(qu,{edgeId:e,value:c==null?void 0:c.icon},e),h.jsx(Xr,{ariaLabel:"Edge icon",placeholder:"Icon name or SVG URL",value:(c==null?void 0:c.icon)??"",onCommit:b=>{var y;return(y=r.onEdgeIconChange)==null?void 0:y.call(r,e,b)}})]}),u("color")&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),h.jsx(Ht,{label:"Edge color",colors:s,value:c==null?void 0:c.color,onPick:b=>{var y;return(y=r.onEdgeColorChange)==null?void 0:y.call(r,e,b)},onReset:()=>{var b;return(b=r.onEdgeColorChange)==null?void 0:b.call(r,e,"")}})]}),u("delete")&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),h.jsx(je,{label:"Delete edge",children:h.jsx(ve,{"aria-label":"Delete edge",icon:h.jsx(F.Icon,{as:Z.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:"red.400",onClick:()=>{var b;(b=r.onEdgeDelete)==null||b.call(r,e,c),t()}})})]})]})}function sb({ids:e,showDivider:t=!0}){const{callbacks:r,config:n}=Ie(),{colorInactive:o}=Ve(),{nodeById:i}=Wr(),[a,s]=E.useState(!1),u=e.map(b=>{var y,m;return(m=(y=i.get(b))==null?void 0:y.data.viewProps)==null?void 0:m.borderRadius}),c=!u.every(b=>b===u[0]),l=c?"mixed":String(u[0]??""),d=["0","8","16","30","53","100"],f=a||!c&&l!==""&&!d.includes(l),p=b=>e.forEach(y=>{var m;return(m=r.onNodeBorderRadiusChange)==null?void 0:m.call(r,y,b)});return h.jsxs(h.Fragment,{children:[t&&h.jsx(cr,{}),h.jsx(F.Box,{position:"relative",w:"36px",h:"30px",display:"grid",placeItems:"center",children:h.jsxs(Or,{icon:h.jsx(F.Icon,{as:ev.TbBorderRadius,boxSize:5,color:o,"aria-hidden":"true"}),"aria-label":"Node border radius",title:`Border radius: ${c?"Mixed":u[0]===void 0?"Default":`${u[0]}px`}`,style:{position:"absolute",inset:0,width:"100%",height:"100%",cursor:"pointer"},value:f?"custom":l,disabled:n.readOnly,onValueChange:b=>{s(b==="custom"),b!=="custom"&&p(b===""?void 0:Number(b))},children:[h.jsx("option",{value:"",children:"Default radius"}),c&&h.jsx("option",{value:"mixed",disabled:!0,children:"Mixed radii"}),d.map(b=>h.jsxs("option",{value:b,children:[b,"px radius"]},b)),h.jsx("option",{value:"custom",children:"Custom radius"})]})}),f&&h.jsx(Xr,{ariaLabel:"Custom border radius",placeholder:c?"Mixed":"Auto",type:"number",min:0,width:"72px",value:c?"":l,onCommit:b=>p(b===""?void 0:Number(b))})]})}function cb({ids:e,onClose:t}){var K,N,B,W,z,X,se,Q;const{callbacks:r,colorMode:n,themeColor:o,config:i,setNodeViewMode:a}=Ie(),{colorText:s,colorInactive:u}=Ve(),{nodeById:c,parentIds:l}=Wr(),{palette:d,show:f}=ib(),p=e.length===1,b=p?(K=c.get(e[0]))==null?void 0:K.data:void 0,y=e.map(G=>{var J,te;return((te=(J=c.get(G))==null?void 0:J.data.config)==null?void 0:te.typeView)??""}),m=y.some(G=>G!==y[0]),x=m?"mixed":y[0]??"",g=e.some(G=>{var te,de;const J=(te=c.get(G))==null?void 0:te.data;return J&&(l.has(G)||((de=J.config)==null?void 0:de.parentContainer)||Object.prototype.hasOwnProperty.call(i.customViews??{},J.type))}),w=(N=b==null?void 0:b.config)==null?void 0:N.collapsed,v=tb(e[0]),_=G=>{var J,te,de;return(((te=(J=c.get(G))==null?void 0:J.data.viewProps)==null?void 0:te.outline)??(l.has(G)?(de=i.parentNodeStyle)==null?void 0:de.outline:!1))===!0},C=e.every(_),S=!C&&e.some(_),T=G=>{var J;return((J=c.get(G))==null?void 0:J.data.isNodeAnimated)===!0},k=e.every(T),j=!k&&e.some(T),P=e.map(G=>{var J;return((J=c.get(G))==null?void 0:J.data.nodeAnimationVariant)??"traveling"}),R=P.every(G=>G===P[0])?P[0]:"",I=G=>e.forEach(G),[O,M]=E.useState(!1),q=O&&f("color")&&f("borderColor"),H=G=>{var J,te,de;return(((te=(J=c.get(G))==null?void 0:J.data.viewProps)==null?void 0:te.borderStyle)??(l.has(G)?(de=i.parentNodeStyle)==null?void 0:de.borderStyle:"solid"))==="dashed"},V=e.every(H),re=!V&&e.some(H),ce=e.map(G=>{var de,fe,Ee;const J=(de=c.get(G))==null?void 0:de.data,te=l.has(G)?Ut((fe=i.parentNodeStyle)==null?void 0:fe.borderWidth,6):(J==null?void 0:J.type)==="objectView"?3:2;return Ut((Ee=J==null?void 0:J.viewProps)==null?void 0:Ee.borderWidth,te)}),le=ce.every(G=>G===ce[0])?String(ce[0]??""):"",be=G=>I(J=>{var te,de;q?(te=r.onNodeBorderColorChange)==null||te.call(r,J,G):(de=r.onNodeColorChange)==null||de.call(r,J,"bg",G)});return h.jsxs(h.Fragment,{children:[h.jsx(ht,{onClick:t}),h.jsx(cr,{}),p&&f("label")?h.jsx(Xr,{ariaLabel:"Node label",placeholder:"Node label",value:(b==null?void 0:b.label)??(b==null?void 0:b.headerTitle)??"",onCommit:G=>{var J;return(J=r.onNodeLabelChange)==null?void 0:J.call(r,e[0],G)}}):h.jsxs(F.Text,{fontSize:"xs",color:s,whiteSpace:"nowrap",px:1,children:[e.length," selected"]}),f("typeView")&&h.jsxs(Or,{"aria-label":"Type view",title:g?"Type view is managed by the custom renderer or container":`Type view: ${x||"None (default)"}`,icon:h.jsx(Z.PiImage,{size:20}),style:{width:36},value:x,disabled:i.readOnly||i.editable===!1||g,onValueChange:G=>{Ft.includes(G)&&I(J=>{var te,de;(te=r.onNodeTypeViewChange)==null||te.call(r,J,G||void 0),a(J,"default"),(de=r.onNodeViewToggle)==null||de.call(r,J)})},children:[m&&h.jsx("option",{value:"mixed",disabled:!0,children:"Mixed"}),Ft.map(G=>h.jsx("option",{value:G,children:G||"None"},G))]}),f("style")&&h.jsx(sb,{ids:e},e.join("\0")),f("outline")&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),h.jsx(je,{label:C?"Restore node fill":"Remove node fill",children:h.jsx(ve,{"aria-label":"Toggle node outline","aria-pressed":S?"mixed":C,icon:h.jsx(F.Icon,{as:C?Z.PiSquare:Z.PiSquareFill,boxSize:5}),size:"sm",variant:"ghost",color:C?o:u,onClick:()=>I(G=>{var J;return(J=r.onNodeOutlineChange)==null?void 0:J.call(r,G,!C)})})})]}),f("color")&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),f("borderColor")&&h.jsx(je,{label:q?"Edit node colors":"Edit node border",children:h.jsx(ve,{"aria-label":"Edit node border","aria-pressed":q,icon:h.jsx(F.Icon,{as:Z.PiBoundingBox,boxSize:5}),size:"sm",variant:"ghost",color:q?o:u,bg:q?n==="dark"?"whiteAlpha.200":"blackAlpha.100":void 0,onClick:()=>M(G=>!G)})}),h.jsx(Ht,{label:q?"Border color":"Background",colors:d,value:q?((B=b==null?void 0:b.viewProps)==null?void 0:B.borderColor)??(p&&l.has(e[0])?(W=i.parentNodeStyle)==null?void 0:W.borderColor:void 0):(z=b==null?void 0:b.viewProps)==null?void 0:z.bgColor,onPick:be,onReset:()=>be("")}),q&&f("style")&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),h.jsx(je,{label:V?"Solid border":"Dashed border",children:h.jsx(ve,{"aria-label":"Toggle dashed border","aria-pressed":re?"mixed":V,icon:h.jsx(F.Icon,{as:V?Z.PiLineSegments:Z.PiLineSegment,boxSize:5}),size:"sm",variant:"ghost",color:V?o:u,onClick:()=>I(G=>{var J;return(J=r.onNodeBorderStyleChange)==null?void 0:J.call(r,G,V?"solid":"dashed")})})}),h.jsx(Xr,{ariaLabel:"Border thickness",placeholder:p?"Auto":"Mixed",width:"64px",type:"number",min:0,value:le,onCommit:G=>I(J=>{var te;return(te=r.onNodeBorderWidthChange)==null?void 0:te.call(r,J,G===""?void 0:Number(G))})})]})]}),f("animation")&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),h.jsx(je,{label:k?"Stop border animation":"Animate node border",children:h.jsx(ve,{"aria-label":"Toggle node animation","aria-pressed":j?"mixed":k,icon:h.jsx(F.Icon,{as:Z.PiSpinnerGap,boxSize:5}),size:"sm",variant:"ghost",color:k?o:u,onClick:()=>I(G=>{var J;return(J=r.onNodeAnimationChange)==null?void 0:J.call(r,G,!k)})})}),(k||j)&&h.jsx(nb,{label:"Node animation",value:R,options:[{value:"traveling",label:"Trace"},{value:"pulse",label:"Pulse"}],disabled:i.readOnly,onChange:G=>I(J=>{var te;return(te=r.onNodeAnimationVariantChange)==null?void 0:te.call(r,J,G)})})]}),!q&&f("textColor")&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),h.jsx(Ht,{label:"Text color",colors:ob,value:(X=b==null?void 0:b.viewProps)==null?void 0:X.textColor,onPick:G=>I(J=>{var te;return(te=r.onNodeColorChange)==null?void 0:te.call(r,J,"text",G)}),onReset:()=>I(G=>{var J;return(J=r.onNodeColorChange)==null?void 0:J.call(r,G,"text","")})})]}),p&&f("icon")&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),h.jsx(qu,{nodeId:e[0],value:(se=b==null?void 0:b.config)==null?void 0:se.icon},e[0]),h.jsx(Xr,{ariaLabel:"Node icon",placeholder:"(e.g. PiGear)",width:"120px",value:((Q=b==null?void 0:b.config)==null?void 0:Q.icon)||"",onCommit:G=>{var J;return(J=r.onNodeIconChange)==null?void 0:J.call(r,e[0],G)}})]}),p&&v&&f("collapse")&&w!==void 0&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),h.jsx(je,{label:w?"Expand":"Collapse",children:h.jsx(ve,{"aria-label":w?"Expand node":"Collapse node",icon:h.jsx(F.Icon,{as:w?Z.PiArrowsOutLineVertical:Z.PiArrowsInLineVertical,boxSize:5}),size:"sm",variant:"ghost",color:u,onClick:()=>{var G;return(G=r.onNodeCollapse)==null?void 0:G.call(r,e[0],!w)}})})]}),f("delete")&&h.jsxs(h.Fragment,{children:[h.jsx(cr,{}),h.jsx(je,{label:p?"Delete node":`Delete ${e.length} nodes`,children:h.jsx(ve,{"aria-label":"Delete selected nodes",icon:h.jsx(F.Icon,{as:Z.PiTrash,boxSize:5}),size:"sm",variant:"ghost",color:n==="dark"?"red.300":"red.500",onClick:()=>{I(G=>{var J,te;return(te=r.onNodeDelete)==null?void 0:te.call(r,G,((J=c.get(G))==null?void 0:J.data)||{id:G})}),t()}})})]})]})}async function ub(e){const{toSvg:t}=await Promise.resolve().then(()=>require("./index-sHQXTNv9.cjs"));await document.fonts.ready;const r=await t(e,{filter:o=>!(o instanceof Element)||!o.matches("button, [role=tooltip], .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-edge-hit, .flow-sdk-ghost, .flow-sdk-node-animation")}),n=new DOMParser().parseFromString(decodeURIComponent(r.slice(r.indexOf(",")+1)),"image/svg+xml");return n.querySelectorAll(".flow-sdk-edge-hit, .flow-sdk-handle, .flow-sdk-property-port, .flow-sdk-ghost").forEach(o=>o.remove()),`data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(n))}`}async function lb(e,t="squeed.svg"){const r=document.createElement("a");r.href=await ub(e),r.download=t.endsWith(".svg")?t:`${t}.svg`,r.click()}function db(){const{themeColor:e}=Ie(),[t,r]=E.useState(!1),[n,o]=E.useState("");return h.jsxs(h.Fragment,{children:[h.jsx(je,{label:"Download SVG (current view)",children:h.jsx(ve,{"aria-label":"Download SVG",icon:h.jsx(Z.PiDownloadSimpleFill,{size:20}),disabled:t,borderRadius:"30%",color:e,variant:"ghost",onClick:async i=>{var s;const a=(s=i.currentTarget.closest("[data-flow-diagram]"))==null?void 0:s.querySelector("[data-flow-background]");if(!a){o("Diagram not available for export.");return}r(!0),o("");try{await lb(a)}catch(u){o(u instanceof Error?u.message:"Unable to export SVG.")}finally{r(!1)}}})}),n&&h.jsx("span",{role:"alert",style:{fontSize:12,maxWidth:220},children:n})]})}function fb({children:e,background:t,border:r}){const n=E.useRef(null),[o,i]=E.useState({left:!1,right:!1});E.useLayoutEffect(()=>{const s=n.current,u=()=>{const l=s.scrollLeft>1,d=s.scrollWidth-s.clientWidth-s.scrollLeft>1;i(f=>f.left===l&&f.right===d?f:{left:l,right:d})},c=new ResizeObserver(u);return c.observe(s),s.firstElementChild&&c.observe(s.firstElementChild),s.addEventListener("scroll",u,{passive:!0}),u(),()=>{c.disconnect(),s.removeEventListener("scroll",u)}},[]);const a=`var(--chakra-colors-${t.replace(".","-")})`;return h.jsxs(F.Box,{position:"relative",bg:t,minW:0,maxW:"100%",flex:"0 1 auto",borderColor:r,borderWidth:1,borderRadius:"30px",...Su(a),children:[h.jsx(F.Box,{ref:n,"data-flow-toolbar-scroll":"",h:50,minH:50,alignContent:"center",overflowX:"auto",overflowY:"hidden",borderRadius:"inherit",css:{scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:e}),["left","right"].map(s=>h.jsx(F.Box,{"data-flow-toolbar-fade":s,"aria-hidden":"true",position:"absolute",top:0,bottom:0,w:"20px",pointerEvents:"none",borderRadius:s==="left"?"30px 0 0 30px":"0 30px 30px 0",style:{[s]:0,opacity:o[s]?1:0,background:`linear-gradient(to ${s==="left"?"right":"left"}, ${a}, transparent)`}},s))]})}async function o0(e,t){const r=new Set,n=[],o=(s,u)=>{var l,d,f;if(!s||typeof s!="object")return;const c=s;n.push(u),typeof((l=c.$form)==null?void 0:l.$type)=="string"&&r.add(c.$form.$type),typeof((f=(d=c.$form)==null?void 0:d.$create)==null?void 0:f.$type)=="string"&&r.add(c.$form.$create.$type);for(const[p,b]of Object.entries(c))p==="$"?o(b,u):p.startsWith("$")||o(b,`${u}.${p}`)};if(o(t,"root"),!r.size)return{contract:await Xy(e)};const i=await Mu(e,[...r]);for(const s of r)if(!Object.prototype.hasOwnProperty.call(i,s))throw new Error(`Missing form type: ${s}`);const a={};for(const s of n){const u=pt(t,s,i);u&&(a[s]={type:u.type,optional:!1})}return{schema:i,contract:{name:e.name,nodes:a}}}function hb({message:e,onDismiss:t}){const{background:r,colorText:n,border:o}=Ve();return!e||typeof document>"u"?null:Lt.createPortal(h.jsxs("div",{role:"alert","aria-atomic":"true",onPointerDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),style:{position:"fixed",top:20,right:20,zIndex:1e4,width:360,maxWidth:"calc(100vw - 40px)",boxSizing:"border-box",display:"flex",alignItems:"flex-start",gap:10,padding:16,borderRadius:8,border:`1px solid ${pe(o)}`,background:pe(r),color:pe(n),boxShadow:"0 4px 20px #0003",fontSize:14,lineHeight:1.5},children:[h.jsx(Z.PiWarningCircle,{size:20,"aria-hidden":"true",style:{flexShrink:0,color:"#ef4444"}}),h.jsxs("div",{style:{flex:1,minWidth:0,overflowWrap:"anywhere"},children:[h.jsx("strong",{children:"Interface upload failed"}),h.jsx("div",{children:e})]}),h.jsx(ht,{type:"button","aria-label":"Dismiss upload error",title:"Dismiss upload error",onClick:t,flexShrink:0,width:"24px",height:"24px",minWidth:"24px",padding:0})]}),document.body)}function pb({showDivider:e=!0,compact:t=!1}={}){const{edgeMode:r,setEdgeMode:n,workflowContract:o,setWorkflowContract:i,callbacks:a,readOnly:s,themeColor:u}=Ie(),{edgeById:c}=Wr(),{data:l,schema:d,setSchema:f,bindings:p,structured:b}=E.useContext(kr),y=(b==null?void 0:b.sourceBindings)??p,m=(b==null?void 0:b.sourceSchema)??d,{colorText:x}=Ve(),g=E.useRef(null),w=E.useRef(0),[v,_]=E.useState(!1),[C,S]=E.useState("");E.useEffect(()=>()=>{w.current++},[]),E.useEffect(()=>{w.current++,_(!1)},[s,l,y]);const T=o?[...c.values()].filter(j=>Iu(o,j.data)).length:0,k=o?`${o.name}: ${m?`${Object.keys(m).length} form types loaded; `:""}${T} invalid or unverified connections`:"";return h.jsxs(h.Fragment,{children:[h.jsx(hb,{message:C,onDismiss:()=>S("")}),e&&h.jsx(Ot,{}),h.jsxs(Or,{"aria-label":"Edge mode",title:r==="auto"?"Connections: Auto":r==="properties"?"Connections: Properties":"Connections: Nodes",icon:r==="auto"?h.jsx(Z.PiGraph,{size:20}):r==="properties"?h.jsx(Z.PiTable,{size:20}):h.jsx(Z.PiTreeStructure,{size:20}),style:{width:36},value:r,disabled:s,onValueChange:j=>{var R;const P=j==="auto"?"auto":j==="properties"?"properties":"nodes";n(P),(R=a.onEdgeModeChange)==null||R.call(a,P)},children:[h.jsx("option",{value:"auto",children:"Auto"}),h.jsx("option",{value:"nodes",children:"Nodes"}),h.jsx("option",{value:"properties",children:"Properties"})]}),h.jsxs("span",{style:{display:r==="auto"||r==="properties"?"contents":"none"},children:[h.jsx(je,{label:o?`Replace ${o.name}`:"Upload workflow interface",children:h.jsx(ve,{"aria-label":"Upload workflow interface",icon:h.jsx(Z.PiUploadSimple,{size:20}),color:pe(u),size:"sm",variant:"ghost",disabled:v||s,onClick:()=>{var j;return(j=g.current)==null?void 0:j.click()}})}),h.jsx("input",{ref:g,type:"file",hidden:!0,accept:".ts,.json","aria-label":"Workflow interface file",disabled:s||v,onChange:async j=>{var I,O;const P=(I=j.target.files)==null?void 0:I[0];if(j.target.value="",!P)return;const R=++w.current;_(!0),S("");try{const M=y?await Mu(P,[...new Set(Object.values(y).map(V=>V.schemaType??V.type))]):void 0;if(y&&M){for(const V of Object.values(y))if(!Object.prototype.hasOwnProperty.call(M,V.schemaType??V.type))throw new Error(`Missing form type: ${V.schemaType??V.type}`)}const{contract:q,schema:H}=y&&M?{schema:M,contract:{name:P.name,nodes:Object.fromEntries(Object.entries(y).map(([V,re])=>[V,{type:M[re.schemaType??re.type],optional:!1}]))}}:await o0(P,l);if(R!==w.current)return;f==null||f(H),i(q),(O=a.onWorkflowContractChange)==null||O.call(a,q)}catch(M){R===w.current&&S(`${P.name}: ${M instanceof Error?M.message:"Unable to load interface."}`)}finally{R===w.current&&_(!1)}}}),!t&&(k||v)&&h.jsx("span",{role:"status",title:k,style:{color:pe(x),fontSize:12,maxWidth:180,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v?"Loading interface...":k}),!t&&o&&h.jsx(je,{label:"Remove workflow interface",children:h.jsx(ve,{"aria-label":"Remove workflow interface",icon:h.jsx(Z.PiX,{size:16}),size:"sm",variant:"ghost",disabled:s||v,onClick:()=>{var j;f==null||f(void 0),i(void 0),(j=a.onWorkflowContractChange)==null||j.call(a,void 0),S("")}})})]})]})}const i0=[{value:"BT",label:"Bottom to Up",icon:Z.PiArrowUp,flowType:St.BOTTOM_UP},{value:"TB",label:"Top to Bottom",icon:Z.PiArrowDown,flowType:St.TOP_DOWN},{value:"LR",label:"Left to Right",icon:Z.PiArrowRight,flowType:St.LEFT_RIGHT},{value:"RL",label:"Right to Left",icon:Z.PiArrowLeft,flowType:St.RIGHT_LEFT}],gb=()=>{const{engineRef:e,themeColor:t,setThemeColor:r,backgroundSelected:n,setBackgroundSelected:o,direction:i,edgeMode:a,selectedNodeIds:s,setSelectedNodeIds:u,selectedEdgeId:c,setSelectedEdgeId:l,isZoomMode:d,setIsZoomMode:f,isMultiSelectMode:p,setIsMultiSelectMode:b,isDragMode:y,setIsDragMode:m,isEdgeHandlesEnabled:x,setIsEdgeHandlesEnabled:g,isArrayNodeMode:w,setIsArrayNodeMode:v,isPinned:_,setIsPinned:C,callbacks:S,config:T,readOnly:k}=Ie(),{nodeById:j,edgeById:P,parentIds:R}=Wr(),I=T.colorMode==="dark",{background:O,border:M,colorInactive:q,colorText:H,colorActive:V,darkBackgroundSecondary:re}=Ve(),[ce,le]=E.useState(!1),[be,K]=E.useState(!0),N=E.useCallback(me=>{const Te=e.current;if(!Te)return;const er=T.minZoom??.01,De=T.maxZoom??1.5,Ne=.02;let He=Te.zoom();switch(me){case"increase":He=Math.min(De,He+Ne),Te.zoom(He),Te.center();break;case"decrease":He=Math.max(er,He-Ne),Te.zoom(He),Te.center();break;case"reset":Te.fit(50);break}},[e,T.minZoom,T.maxZoom]),B=T.renderSelectedNodeToolbar,W=s.length>0&&!!B,z=E.useMemo(()=>W?s.map(me=>{var er;return{...((er=j.get(me))==null?void 0:er.data)??{id:me},isParent:R.has(me)}}):[],[W,s,j,R]),X=E.useCallback(()=>{var me;u([]),(me=S.onNodeDeselect)==null||me.call(S)},[u,S]),se=T.renderSelectedEdgeToolbar,Q=!!c&&!!se,G=E.useMemo(()=>{var me;return!Q||!c?null:((me=P.get(c))==null?void 0:me.data)??{id:c}},[Q,c,P]),J=E.useCallback(()=>{var me;l(null),(me=S.onEdgeDeselect)==null||me.call(S)},[l,S]),te=T.selectionToolbar!==!1&&!k,de=te&&!!c&&!se,fe=te&&!de&&s.length>0&&!B,Ee=de||fe,ge=_||ce||Ee;E.useEffect(()=>{s.length||c?o(!1):n&&!k&&(C(!0),K(!1))},[n,s.length,c,k,o,C]);const We=T.renderBottomBar;return We?h.jsxs(h.Fragment,{children:[W&&h.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:B({selectedNodeIds:s,selectedNodeData:z,onDeselect:X})}),Q&&G&&h.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:se({edgeId:c,edgeData:G,onDeselect:J})}),h.jsx(F.Box,{position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",children:We({zoomIn:()=>N("increase"),zoomOut:()=>N("decrease"),resetZoom:()=>N("reset"),direction:i,isZoomMode:d,setIsZoomMode:f,isMultiSelectMode:p,setIsMultiSelectMode:b,isDragMode:y,setIsDragMode:m,isEdgeHandlesEnabled:x,setIsEdgeHandlesEnabled:g,isArrayNodeMode:w,setIsArrayNodeMode:v,selectedNodeIds:s,selectedNodeData:z,selectedEdgeId:c,selectedEdgeData:G,onNodeDeselect:X,onEdgeDeselect:J,callbacks:S})})]}):h.jsxs(h.Fragment,{children:[W&&h.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:B({selectedNodeIds:s,selectedNodeData:z,onDeselect:X})}),Q&&G&&h.jsx(F.Box,{position:"absolute",bottom:5,left:"50%",transform:"translateX(-50%)",zIndex:101,children:se({edgeId:c,edgeData:G,onDeselect:J})}),!_&&h.jsx(F.Box,{position:"absolute",bottom:5,left:0,zIndex:101,w:3,children:h.jsx(je,{label:"Show Bottom Bar",children:h.jsx(F.chakra.button,{type:"button","aria-label":"Show Bottom Bar",display:"flex",alignItems:"center",bg:O,borderColor:M,borderWidth:1,py:6,px:0,w:4,h:50,borderRadius:"15px",borderLeftRadius:0,onMouseEnter:()=>C(!0),onClick:()=>C(!0),_hover:{bg:re},children:h.jsx(F.Icon,{ml:-1,as:Z.PiLineVerticalBold,boxSize:5,color:M})})})}),h.jsx(F.Box,{role:"toolbar","aria-label":"Diagram controls",position:"absolute",bottom:0,left:0,right:0,zIndex:100,w:"100%",transition:"opacity 0.3s ease-in, transform 0.3s ease",transform:ge?"translateY(0)":"translateY(100%)",pointerEvents:ge?"auto":"none",visibility:ge?"visible":"hidden",opacity:ge?1:0,children:h.jsxs(F.Flex,{w:"100%",px:5,position:"absolute",bottom:5,flexDirection:"row",justifyContent:"space-between",alignItems:"center",gap:"24px",children:[h.jsx(fb,{background:O,border:I?M:"gray.300",children:h.jsxs(F.HStack,{px:2,gap:1,flexWrap:"nowrap",w:"max-content",minW:"100%",h:"100%",css:{"& > *":{flexShrink:0}},children:[de?h.jsx(ab,{edgeId:c,onClose:J}):fe?h.jsx(cb,{ids:s,onClose:X}):null,h.jsxs("div",{style:{display:de||fe?"none":"contents"},children:[h.jsx(je,{label:_?"Unpin":"Pin",children:h.jsx(ve,{"aria-label":"Pin",icon:h.jsx(F.Icon,{as:_?Z.PiPushPinFill:Z.PiPushPin,boxSize:5}),size:"sm",variant:"ghost",color:_?t:q,onClick:()=>{C(!_),le(!1)}})}),h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M}),h.jsx(je,{label:"Zoom Out",children:h.jsx(ve,{"aria-label":"Zoom out",icon:h.jsx(F.Icon,{as:Z.PiMinus,boxSize:5}),size:"sm",variant:"ghost",color:H,onClick:()=>N("decrease")})}),h.jsx(je,{label:"Zoom In",children:h.jsx(ve,{"aria-label":"Zoom in",icon:h.jsx(F.Icon,{as:Z.PiPlus,boxSize:5}),size:"sm",variant:"ghost",color:H,onClick:()=>N("increase")})}),h.jsx(je,{label:"Reset Zoom",children:h.jsx(ve,{"aria-label":"Reset zoom",icon:h.jsx(F.Icon,{as:Z.PiArrowCounterClockwise,boxSize:5}),size:"sm",variant:"ghost",color:H,onClick:()=>N("reset")})}),!be&&h.jsxs(h.Fragment,{children:[h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M}),h.jsx(je,{label:d?"Zoom Mode (z)":"Pan Mode (z)",children:h.jsx(ve,{"aria-label":"Toggle zoom mode",icon:h.jsx(F.Icon,{as:d?Z.PiMagnifyingGlassPlus:Z.PiArrowsOutCardinal,boxSize:5}),size:"sm",variant:"ghost",color:d?t:q,onClick:()=>f(!d)})}),h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M}),h.jsx(je,{label:p?"Multi-Select On (m)":"Multi-Select Off (m)",children:h.jsx(ve,{"aria-label":"Toggle multi-select",icon:h.jsx(F.Icon,{as:Z.PiSelectionPlus,boxSize:5}),size:"sm",variant:"ghost",color:p?t:q,onClick:()=>b(!p)})}),h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M}),h.jsx(je,{label:y?"Drag Mode On (d)":"Drag Mode Off (d)",children:h.jsx(ve,{"aria-label":"Toggle drag mode",icon:h.jsx(F.Icon,{as:Z.PiHandGrabbing,boxSize:5}),size:"sm",variant:"ghost",color:y?t:q,onClick:()=>m(!y)})}),T.edgeHandles!==!1&&h.jsxs(h.Fragment,{children:[h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M}),h.jsx(je,{label:x?"Draw Mode On":"Draw Mode Off",children:h.jsx(ve,{"aria-label":"Toggle draw mode",icon:h.jsx(F.Icon,{as:Z.PiPencilSimpleLine,boxSize:5}),size:"sm",variant:"ghost",color:x?t:q,onClick:()=>g(!x)})})]}),T.bottomBarExtra&&h.jsxs(h.Fragment,{children:[h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M,role:"separator","aria-orientation":"vertical"}),T.bottomBarExtra]}),h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M,role:"separator","aria-orientation":"vertical"}),h.jsx(Dy,{}),a!=="properties"&&h.jsxs(h.Fragment,{children:[h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M}),h.jsx(je,{label:w?"Array Mode [ ]":"Set Mode { }",children:h.jsx(ve,{"aria-label":"Toggle array mode",icon:h.jsx(F.Icon,{as:w?Z.PiBracketsSquare:Z.PiBracketsCurly,boxSize:5}),size:"sm",variant:"ghost",color:w?t:q,onClick:()=>{var Te;const me=!w;v(me),(Te=S.onArrayModeChange)==null||Te.call(S,me)}})})]}),n&&!k&&h.jsxs(h.Fragment,{children:[h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M}),h.jsx(Ht,{label:"Graph theme",colors:Nu,value:t,includeTransparent:!1,onPick:me=>{var Te;r(me),(Te=S.onThemeColorChange)==null||Te.call(S,me)}})]}),h.jsx(pb,{}),h.jsx(Fy,{})]}),h.jsx(F.Icon,{mx:-1,as:Z.PiLineVerticalThin,boxSize:5,color:M}),h.jsx(je,{label:be?"Expand toolbar":"Collapse toolbar",children:h.jsx(ve,{"aria-label":"Toggle toolbar collapse",icon:h.jsx(F.Icon,{as:be?Z.PiCaretRight:Z.PiCaretLeft,boxSize:5}),size:"sm",variant:"ghost",color:q,onClick:()=>K(!be)})}),!be&&h.jsx(db,{})]})]})}),!Ee&&h.jsxs(F.Box,{position:"relative",ml:"auto",flexShrink:0,children:[h.jsx(F.Box,{"data-flow-direction-control":"",bg:O,borderWidth:1,borderColor:I?M:"gray.300",borderRadius:"30px",h:50,...Su(`var(--chakra-colors-${O.replace(".","-")})`),px:3,cursor:"pointer",onClick:()=>le(!ce),children:h.jsxs(F.Flex,{align:"center",h:"100%",children:[h.jsx(je,{label:"Flow Direction",children:h.jsx(ve,{"aria-label":"Direction",icon:h.jsx(F.Icon,{as:Z.PiCaretUp,boxSize:5}),size:"sm",variant:"ghost",color:q})}),h.jsx(F.Text,{fontSize:"xs",color:I?"whiteAlpha.600":"blackAlpha.500",ml:1,children:i})]})}),ce&&h.jsx(F.Box,{position:"absolute",bottom:"100%",right:0,pb:"24px",zIndex:200,children:h.jsxs(F.Box,{bg:O,borderWidth:1,borderColor:I?M:"gray.300",borderRadius:"30px",p:2,minW:"180px",boxShadow:`0 0 0 8px color-mix(in srgb, var(--chakra-colors-${O.replace(".","-")}) 40%, transparent), var(--chakra-shadows-lg)`,children:[i0.map(me=>h.jsxs(F.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"30px",cursor:"pointer",_hover:{bg:I?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var Te;(Te=S.onDirectionChange)==null||Te.call(S,me.value),le(!1)},children:[h.jsx(F.Icon,{as:me.icon,boxSize:5,color:H}),h.jsx(F.Text,{fontSize:"sm",color:H,flex:1,whiteSpace:"nowrap",children:me.label}),i===me.value&&h.jsx(F.Icon,{as:Z.PiCheck,boxSize:4,color:V})]},me.value)),h.jsxs(F.Flex,{align:"center",gap:3,px:3,py:2,borderRadius:"10px",cursor:"pointer",_hover:{bg:I?"whiteAlpha.100":"blackAlpha.50"},onClick:()=>{var me;(me=S.onDirectionChange)==null||me.call(S,"C"),le(!1)},children:[h.jsx(F.Icon,{as:Z.PiAlignCenterHorizontal,boxSize:5,color:H}),h.jsx(F.Text,{fontSize:"sm",color:H,flex:1,whiteSpace:"nowrap",children:"Center"}),i==="C"&&h.jsx(F.Icon,{as:Z.PiCheck,boxSize:4,color:V})]})]})})]})]})})]})};gb.displayName="BottomBar";const yb=E.memo(gb);function a0({checked:e,onChange:t,disabled:r,label:n="Connected nodes"}){return h.jsx(By,{label:n,checked:e,onChange:t,disabled:r,icon:h.jsx(F.Icon,{as:Z.PiGraph,boxSize:5})})}const kl={$bgColor:"bgColor",$textColor:"textColor",$borderColor:"borderColor"};function bb(e,t){const r=new Map,n=(i,a)=>{if(Object.is(i,a))return!0;if(!i||!a||typeof i!="object"||typeof a!="object"||Array.isArray(i)!==Array.isArray(a))return!1;const s=Object.keys(i);return s.length===Object.keys(a).length&&s.every(u=>Object.prototype.hasOwnProperty.call(a,u)&&n(i[u],a[u]))},o=(i,a,s)=>{if(i===a)return!0;if(!i||!a||typeof i!="object"||typeof a!="object"||Array.isArray(i)!==Array.isArray(a))return!1;const u=new Set([...Object.keys(i),...Object.keys(a)]);for(const c of u)if(!n(i[c],a[c])){if(Object.prototype.hasOwnProperty.call(kl,c)){if(typeof a[c]!="string"||!a[c])return!1;r.set(s,{...r.get(s),[kl[c]]:a[c]})}else if(c.startsWith("$")&&c!=="$"||!o(i[c],a[c],c==="$"?s:`${s}.${c}`))return!1}return!0};if(o(e,t,"root"))return r}function s0(e,t){return bb(e,t)!==void 0}function c0(e,t,r){if(e===t)return r;const n=bb(e,t);if(!n)return;const o=new Set(r.nodes.map(i=>i.data.id));for(const i of n.keys())if(!o.has(i)||!xe(t,i))return;return{edges:r.edges,nodes:r.nodes.map(i=>{const a=n.get(i.data.id),s=xe(e,i.data.id),u=xe(t,i.data.id);return!a&&s===u?i:{...i,data:{...i.data,...typeof i.data.code=="string"?{code:JSON.stringify(u,null,2)}:{},...a?{viewProps:{...i.data.viewProps,...a},config:{...i.data.config,...a}}:{}}}})}}function vu(e){return e.kind==="literal"?e.value:e.kind==="union"?vu(e.types[0]):e.kind==="array"?[]:e.kind==="object"?Object.fromEntries(Object.entries(e.properties).filter(([,t])=>!t.optional).map(([t,r])=>[t,vu(r.type)])):e.kind==="boolean"?!1:e.kind==="number"||e.kind==="integer"?0:e.kind==="null"?null:""}function mb(e,t,r){var m,x,g;const n=(m=xe(e,t))==null?void 0:m.$form,o=n==null?void 0:n.$create;if(!o)return;const i=o.$address.split(".");if(i.shift()!=="root"||!i.length||i.some(w=>!/^[A-Za-z0-9_-]+$/.test(w)||["__proto__","constructor","prototype"].includes(w)))throw new Error("Invalid form creation address.");if(!r||!Object.prototype.hasOwnProperty.call(r,o.$type))throw new Error(`Load form type: ${o.$type}`);const a=i.pop(),s=["root",...i].join("."),u=pt(e,s,r),c=(x=u==null?void 0:u.type.properties[a])==null?void 0:x.type;if((c==null?void 0:c.kind)!=="array"||c.items.kind!=="object")throw new Error("Form creation must target an object-array field.");const l=r[o.$type],d=o.$defaults??{};for(const[w,v]of Object.entries(d))if(!Object.prototype.hasOwnProperty.call(l.properties,w)||Rr(l.properties[w].type,v,!l.properties[w].optional))throw new Error(`Invalid creation default: ${w}`);const f={...vu(l),...structuredClone(d)};((g=l.properties.id)==null?void 0:g.type.kind)==="string"&&(f.id=Eu());let p=e;const b=xe(e,o.$address);if(b===void 0)p=hr(e,s,w=>({...w,[a]:[]}));else if(!Array.isArray(b)&&!Array.isArray(b==null?void 0:b.$))throw new Error("Form creation destination is not an array.");const y=Pu(p,o.$address,{...f,$label:o.$label??o.$type,...o.$icon?{$icon:o.$icon}:{},$form:{$type:o.$type,$create:o}});return{address:y.address,json:Au(y.json,t,{target:y.address,label:o.$edgeLabel})}}function u0(e,t){const r=o=>e&&typeof e=="object"&&o in e;let n=1;for(;r(`${t}_${n}`);)n++;return`${t}_${n}`}function vb(e,t,r,n,o){const i=(s,u)=>{s!==e&&(e=s,n==null||n(s,u))},a=s=>{var c;const u=(c=t.find(l=>l.data.id===s))==null?void 0:c.data;return u&&{source:u.source,target:u.target,isInverted:u.isInverted,sourceProperty:u.sourceProperty,targetProperty:u.targetProperty,connection:u.connection}};return{...r,onFormChange:s=>{const u=xe(e,s.nodeAddress);if(!u||s.nodeId!==void 0&&u.id!==s.nodeId)throw new Error("This form node has moved. Retry the edit.");i(xn(e,s,r.onFormChange),{type:"form",address:s.address,value:s.value})},onNodeLabelChange:(s,u)=>{var c;(c=r.onNodeLabelChange)==null||c.call(r,s,u),i(ir(e,s,"$label",u),{type:"nodeLabel",address:s,key:"$label",value:u})},onNodeContentChange:(s,u)=>{var c;(c=r.onNodeContentChange)==null||c.call(r,s,u),i(ir(e,s,"$content",u),{type:"nodeContent",address:s,key:"$content",value:u})},onNodeTypeViewChange:(s,u)=>{var c;u!==void 0&&!Ft.includes(u)||((c=r.onNodeTypeViewChange)==null||c.call(r,s,u),i(ir(e,s,"$view",u),{type:"nodeStyle",address:s,key:"$view",value:u}))},onNodeColorChange:(s,u,c)=>{var d;(d=r.onNodeColorChange)==null||d.call(r,s,u,c);const l=u==="bg"?"$bgColor":"$textColor";i(ir(e,s,l,c),{type:"nodeColor",address:s,key:l,value:c})},onNodeBorderColorChange:(s,u)=>{var c;(c=r.onNodeBorderColorChange)==null||c.call(r,s,u),i(ir(e,s,"$borderColor",u),{type:"nodeColor",address:s,key:"$borderColor",value:u})},onNodeBorderStyleChange:(s,u)=>{var c;(c=r.onNodeBorderStyleChange)==null||c.call(r,s,u),i(ir(e,s,"$borderStyle",u),{type:"nodeStyle",address:s,key:"$borderStyle",value:u})},onNodeBorderWidthChange:(s,u)=>{var c;u!==void 0&&(!Number.isFinite(u)||u<0)||((c=r.onNodeBorderWidthChange)==null||c.call(r,s,u),i(ir(e,s,"$borderWidth",u),{type:"nodeStyle",address:s,key:"$borderWidth",value:u}))},onNodeBorderRadiusChange:(s,u)=>{var c;u!==void 0&&(!Number.isFinite(u)||u<0)||((c=r.onNodeBorderRadiusChange)==null||c.call(r,s,u),i(ir(e,s,"$borderRadius",u),{type:"nodeStyle",address:s,key:"$borderRadius",value:u}))},onNodeIconChange:(s,u)=>{var c;(c=r.onNodeIconChange)==null||c.call(r,s,u),i(ir(e,s,"$icon",u),{type:"nodeIcon",address:s,key:"$icon",value:u})},onNodeOutlineChange:(s,u)=>{var c;(c=r.onNodeOutlineChange)==null||c.call(r,s,u),i(ir(e,s,"$outline",u),{type:"nodeOutline",address:s,key:"$outline",value:u})},onNodeAnimationChange:(s,u)=>{var c;(c=r.onNodeAnimationChange)==null||c.call(r,s,u),i(ir(e,s,"$isNodeAnimated",u),{type:"nodeAnimation",address:s,key:"$isNodeAnimated",value:u})},onNodeAnimationVariantChange:(s,u)=>{var c;u!=="traveling"&&u!=="pulse"||((c=r.onNodeAnimationVariantChange)==null||c.call(r,s,u),i(ir(e,s,"$nodeAnimationVariant",u),{type:"nodeAnimation",address:s,key:"$nodeAnimationVariant",value:u}))},onNodeCollapse:(s,u)=>{var c;(c=r.onNodeCollapse)==null||c.call(r,s,u),i(Uy(e,s,u),{type:"nodeCollapse",address:s,key:"$collapsed",value:u})},onNodeCreate:s=>{var p,b;const u=s.sourceNodeId&&mb(e,s.sourceNodeId,o);if(u){(p=r.onNodeCreate)==null||p.call(r,s),i(u.json,{type:"nodeCreate",address:u.address,value:"form"});return}(b=r.onNodeCreate)==null||b.call(r,s);const c=s.sourceNodeId||"root",l=xe(e,c),d=u0(l,s.isArrayMode?"list":"node"),f=Pu(e,c,s.isArrayMode?[]:{},d);i(f.json,{type:"nodeCreate",address:f.address,value:s.isArrayMode?"array":"set"})},onNodeDelete:(s,u)=>{var c;(c=r.onNodeDelete)==null||c.call(r,s,u),i(Ky(e,s),{type:"nodeDelete",address:s})},onEdgeCreate:(s,u,c)=>{var d;(d=r.onEdgeCreate)==null||d.call(r,s,u,c);const l=c&&(c.sourceProperty!==void 0||c.targetProperty!==void 0)?{...c,target:u}:void 0;i(l?Au(e,s,l):Zy(e,s,u),{type:"edgeCreate",address:s,key:l?"$connections":"$target",value:l??u})},onEdgeLabelChange:(s,u)=>{var l;(l=r.onEdgeLabelChange)==null||l.call(r,s,u);const c=a(s);c&&i(Fr(e,c,"$sourceLabel",u),{type:"edgeLabel",edge:c,key:c.connection?"$connections":"$sourceLabel",value:u})},onEdgeStyleChange:(s,u)=>{var l;(l=r.onEdgeStyleChange)==null||l.call(r,s,u);const c=a(s);c&&i(Hy(e,c,u),{type:"edgeStyle",edge:c,value:u})},onEdgeAnimationVariantChange:(s,u)=>{var l;if(u!=="dashed"&&u!=="traveling")return;(l=r.onEdgeAnimationVariantChange)==null||l.call(r,s,u);const c=a(s);c&&i(Fr(e,c,"$edgeAnimationVariant",u),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeAnimationVariant",value:u})},onEdgeTypeChange:(s,u)=>{var l;(l=r.onEdgeTypeChange)==null||l.call(r,s,u);const c=a(s);c&&i(Fr(e,c,"$edgeType",u),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeType",value:u})},onEdgeIconChange:(s,u)=>{var l;(l=r.onEdgeIconChange)==null||l.call(r,s,u);const c=a(s);c&&i(Fr(e,c,"$edgeIcon",u||void 0),{type:"edgeStyle",edge:c,key:c.connection?"$connections":"$edgeIcon",value:u})},onEdgeColorChange:(s,u)=>{var l;(l=r.onEdgeColorChange)==null||l.call(r,s,u);const c=a(s);c&&i(Fr(e,c,"$edgeColor",u),{type:"edgeColor",edge:c,key:c.connection?"$connections":"$edgeColor",value:u})},onEdgeDelete:(s,u)=>{var d;(d=r.onEdgeDelete)==null||d.call(r,s,u);const c=a(s);if(!c)return;const l=Jy(e,c);l.removed&&i(l.json,{type:"edgeDelete",edge:c,key:c.connection?"$connections":"$target"})}}}const l0=".flow-sdk-edge-trace{pointer-events:none;animation:flow-sdk-edge-trace 2.4s linear infinite}.flow-sdk-edge-trace-reverse{animation-direction:reverse}@keyframes flow-sdk-edge-trace{from{stroke-dashoffset:18}to{stroke-dashoffset:-100}}@media(prefers-reduced-motion:reduce){.flow-sdk-edge-trace,.flow-sdk-edge-anim{animation:none}}";function d0({path:e,color:t,width:r,reversed:n}){return h.jsx("path",{className:`flow-sdk-edge-trace${n?" flow-sdk-edge-trace-reverse":""}`,"data-animation-variant":"traveling","aria-hidden":"true",pointerEvents:"none",d:e,fill:"none",stroke:t,strokeWidth:r,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 100"})}const f0=".flow-sdk-node-animation{position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none;z-index:1}.flow-sdk-node-border-animation{pointer-events:none;animation:flow-sdk-node-border 2.4s linear infinite}.flow-sdk-node-border-pulse{stroke-width:var(--flow-pulse-rest-width);animation:flow-sdk-node-pulse 1.8s ease-in-out infinite}@keyframes flow-sdk-node-border{from{stroke-dashoffset:0}to{stroke-dashoffset:-100}}@keyframes flow-sdk-node-pulse{0%,100%{stroke-width:var(--flow-pulse-rest-width)}50%{stroke-width:var(--flow-pulse-expanded-width)}}@media(prefers-reduced-motion:reduce){.flow-sdk-node-border-animation{animation:none}}";function xb({x:e=0,y:t=0,width:r,height:n,radius:o,color:i,strokeWidth:a=8,path:s,variant:u="traveling"}){const c=E.useId(),l=`flow-sdk-node-border-animation${u==="pulse"?" flow-sdk-node-border-pulse":""}`;if(u==="pulse"){const d=s?"path":"rect",f=s?{d:s}:{x:e,y:t,width:Math.max(0,r),height:Math.max(0,n),rx:Math.max(0,Math.min(o,r/2,n/2))},p=a+36,b={x:e-p,y:t-p,width:r+2*p,height:n+2*p};return h.jsxs("g",{"aria-hidden":"true",pointerEvents:"none",children:[h.jsx("defs",{children:h.jsxs("mask",{id:c,maskUnits:"userSpaceOnUse",...b,style:{maskType:"luminance"},children:[h.jsx("rect",{...b,fill:"white"}),h.jsx(d,{...f,fill:"black",stroke:"black",strokeWidth:a,strokeLinejoin:"round"})]})}),h.jsx(d,{...f,className:l,"data-animation-variant":u,fill:"none",stroke:`color-mix(in srgb, ${i} 60%, transparent)`,strokeLinejoin:"round",mask:`url(#${c})`,style:{"--flow-pulse-rest-width":`${a+16}px`,"--flow-pulse-expanded-width":`${a+36}px`}})]})}return s?h.jsx("path",{className:l,"data-animation-variant":u,"aria-hidden":"true",pointerEvents:"none",d:s,fill:"none",stroke:i,strokeWidth:a,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"}):h.jsx("rect",{className:l,"data-animation-variant":u,"aria-hidden":"true",pointerEvents:"none",x:e,y:t,width:Math.max(0,r),height:Math.max(0,n),rx:Math.max(0,Math.min(o,r/2,n/2)),fill:"none",stroke:i,strokeWidth:a,strokeLinecap:"round",pathLength:100,strokeDasharray:"18 82"})}const h0=e=>{const n=1/(Math.cbrt(e)*.8);let o=Math.round(650*n),i=Math.round(350*n);return o=Math.max(40,Math.min(450,o)),i=Math.max(30,Math.min(300,i)),{edgeSep:o,rankSep:i}};function Pl(e,t,r){const n=new Set([e]),o=[e];for(;o.length;){const i=o.pop();for(const a of t)(a.parent===i||a.id.startsWith(`${i}.`)||r.some(u=>(u.inverted?u.target:u.source)===i&&(u.inverted?u.source:u.target)===a.id))&&!n.has(a.id)&&(n.add(a.id),o.push(a.id))}return n}function p0(e,t,r){const n=r==="downward"||r==="upward",o=new Map;for(const a of e){if(a.source===a.target||a.sourceProperty||a.targetProperty)continue;const s=t(a.source),u=t(a.target);if(!s||!u)continue;const c=n?u.y-s.y:u.x-s.x,l=Math.abs(c)-(n?s.h+u.h:s.w+u.w)/2;if(l<=320)continue;const d=JSON.stringify([a.source,Math.sign(c)]),f=o.get(d)??[];f.push({edge:a,gap:l,cross:n?u.x-s.x:u.y-s.y}),o.set(d,f)}const i=new Map;for(const a of o.values()){if(new Set(a.map(({edge:u})=>u.target)).size<2)continue;const s=new Map;for(const{edge:u}of a)s.set(u.target,(s.get(u.target)??0)+1);for(const u of[-1,0,1]){const c=a.filter(({cross:d})=>Math.sign(d)===u);c.sort((d,f)=>Math.abs(f.cross)-Math.abs(d.cross)||d.edge.id.localeCompare(f.edge.id));const l=Math.min(...c.map(({gap:d})=>d));c.forEach(({edge:d,gap:f,cross:p},b)=>{const y=c.length===1?l/2:120+(l-280)*b/(c.length-1),m=c.find(x=>Math.abs(x.cross)<Math.abs(p));i.set(d.id,{turn:y/f,labelAtTarget:s.get(d.target)===1,labelFraction:p?(p+((m==null?void 0:m.cross)??0))/(2*p):.5})})}}return i}const at=e=>({x1:e.x-e.w/2,y1:e.y-e.h/2,x2:e.x+e.w/2,y2:e.y+e.h/2}),g0=e=>({x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2,w:e.x2-e.x1,h:e.y2-e.y1});function Jn(e){if(!e.length)return null;const t={...e[0]};for(let r=1;r<e.length;r++)t.x1=Math.min(t.x1,e[r].x1),t.y1=Math.min(t.y1,e[r].y1),t.x2=Math.max(t.x2,e[r].x2),t.y2=Math.max(t.y2,e[r].y2);return t}const y0=(e,t)=>e.x1<=t.x2&&e.x2>=t.x1&&e.y1<=t.y2&&e.y2>=t.y1,Al=(e,t)=>e.x>=t.x1&&e.x<=t.x2&&e.y>=t.y1&&e.y<=t.y2,ur=e=>(Math.round(e*10)/10).toString(),Ue=e=>`${ur(e.x)} ${ur(e.y)}`,b0=e=>e>0?1:e<0?-1:0,Tl=(e,t)=>e>0?Math.max(e-t,0):Math.min(e+t,0);function m0(e,t,r,n,o=10){const i=t.x-e.x,a=t.y-e.y,s=Tl(i,(e.w+t.w)/2),u=Tl(a,(e.h+t.h)/2),c=r==="downward"||r==="upward",l=c?u:s,d=c?a:i,f=b0(d),p=n*l,b=g=>Math.abs(g)<o||Math.abs(g)>=Math.abs(l),y=b(p)||b(Math.abs(l)-Math.abs(p));let m;if(y)if(c)if(Math.abs(d)<=e.h/2){const g=(e.x+t.x)/2;m=[g,e.y,g,t.y]}else if(Math.abs(i)<=t.w/2){const g=(e.y+t.y)/2;m=[e.x,g,t.x,g]}else m=[e.x,t.y];else if(Math.abs(d)<=e.w/2){const g=(e.y+t.y)/2;m=[e.x,g,t.x,g]}else if(Math.abs(a)<=t.h/2){const g=(e.x+t.x)/2;m=[g,e.y,g,t.y]}else m=[t.x,e.y];else if(c){const g=e.y+p+e.h/2*f;m=[e.x,g,t.x,g]}else{const g=e.x+p+e.w/2*f;m=[g,e.y,g,t.y]}const x=[{x:e.x,y:e.y}];for(let g=0;g<m.length;g+=2)x.push({x:m[g],y:m[g+1]});return x.push({x:t.x,y:t.y}),x}function v0(e,t,r){const n=t.x-e.x,o=t.y-e.y,i=n>0?(r.x2-e.x)/n:n<0?(r.x1-e.x)/n:1/0,a=o>0?(r.y2-e.y)/o:o<0?(r.y1-e.y)/o:1/0,s=Math.min(i,a);return!Number.isFinite(s)||s>=1||s<0?null:{x:e.x+n*s,y:e.y+o*s}}function ft(e,t,r){var a;if(!((a=r.outline)!=null&&a.length))return v0(e,t,at(r));const n=t.x-e.x,o=t.y-e.y;let i=1/0;return r.outline.forEach((s,u,c)=>{const l=c[(u+1)%c.length],d=l.x-s.x,f=l.y-s.y,p=n*f-o*d;if(Math.abs(p)<1e-9)return;const b=s.x-e.x,y=s.y-e.y,m=(b*f-y*d)/p,x=(b*o-y*n)/p;m>=0&&m<1&&x>=-1e-9&&x<=1+1e-9&&(i=Math.min(i,m))}),Number.isFinite(i)?{x:e.x+n*i,y:e.y+o*i}:null}function wb(e,t,r=.5){const n=Number.isFinite(r)?Math.max(0,Math.min(1,r)):.5,o=t==="top"||t==="bottom",i=t==="top"||t==="left"?-1:1,a={x:o?e.x-e.w/2+e.w*n:e.x,y:o?e.y:e.y-e.h/2+e.h*n},s=Math.max(e.w,e.h)*2+1;return{...ft(a,{x:a.x+(o?0:i*s),y:a.y+(o?i*s:0)},e)??{x:o?a.x:e.x+i*e.w/2,y:o?e.y+i*e.h/2:a.y},side:t}}function ut(e,t){return{x:e.x+(e.side==="right"?t:e.side==="left"?-t:0),y:e.y+(e.side==="bottom"?t:e.side==="top"?-t:0)}}function x0(e,t,r,n){const o=ut(e,r.srcDist),i=ut(t,r.tgtDist);if(n==="straight")return _b(o,i,r);const a=Math.max(80,Math.min(300,Math.hypot(i.x-o.x,i.y-o.y)/3)),s=e.side==="bottom"&&t.side==="top"?i.y-o.y:e.side==="top"&&t.side==="bottom"?o.y-i.y:e.side==="right"&&t.side==="left"?i.x-o.x:e.side==="left"&&t.side==="right"?o.x-i.x:void 0,u=s!==void 0&&s>0?Math.min(a,s/2):a,c=ut({...o,side:e.side},u),l=ut({...i,side:t.side},u),d=r.arrowAt==="source"?Qe(o,c,r.arrowGap):o,f=r.arrowAt==="target"?Qe(i,l,r.arrowGap):i,p=r.arrowAt==="source"?br(o,c,r.arrowSize,r.headShape):r.arrowAt==="target"?br(i,l,r.arrowSize,r.headShape):void 0;if(n==="bezier")return{d:`M${Ue(d)} C${Ue(c)} ${Ue(l)} ${Ue(f)}`,arrow:p,label:{x:(d.x+3*c.x+3*l.x+f.x)/8,y:(d.y+3*c.y+3*l.y+f.y)/8,angle:0}};const b=e.side==="left"||e.side==="right",y=t.side==="left"||t.side==="right";let m;if(b!==y){const g=b?{x:l.x,y:c.y}:{x:c.x,y:l.y},w=(g.x-c.x)*(c.x-o.x)+(g.y-c.y)*(c.y-o.y)>=0,v=(g.x-l.x)*(l.x-i.x)+(g.y-l.y)*(l.y-i.y)>=0;m=[w&&v?g:b?{x:c.x,y:l.y}:{x:l.x,y:c.y}]}else if(s!==void 0&&s<=0)if(b){const g=(c.y+l.y)/2;m=[{x:c.x,y:g},{x:l.x,y:g}]}else{const g=(c.x+l.x)/2;m=[{x:g,y:c.y},{x:g,y:l.y}]}else if(b){const g=e.side===t.side?e.side==="right"?Math.max(c.x,l.x):Math.min(c.x,l.x):(c.x+l.x)/2;m=[{x:g,y:c.y},{x:g,y:l.y}]}else{const g=e.side===t.side?e.side==="bottom"?Math.max(c.y,l.y):Math.min(c.y,l.y):(c.y+l.y)/2;m=[{x:c.x,y:g},{x:l.x,y:g}]}const x=[c,...m,l].filter((g,w,v)=>w===0||g.x!==v[w-1].x||g.y!==v[w-1].y);return wn(d,x,f,p,n==="orthogonal"?0:r.radius)}function Qe(e,t,r){const n=e.x-t.x,o=e.y-t.y,i=Math.hypot(n,o);if(!i)return e;let a=(i-r)/i;return a<0&&(a=1e-5),{x:t.x+a*n,y:t.y+a*o}}function br(e,t,r,n="triangle"){const o=e.x-t.x,i=e.y-t.y,a=Math.hypot(o,i)||1,s=o/a,u=i/a,c=(n==="square"?.15:.3)*r,l=.15*r,d=e.x-s*c,f=e.y-u*c;return n==="square"?`M${Ue(e)} L${ur(e.x-u*l)} ${ur(e.y+s*l)} L${ur(d-u*l)} ${ur(f+s*l)} L${ur(d+u*l)} ${ur(f-s*l)} L${ur(e.x+u*l)} ${ur(e.y-s*l)} Z`:`M${Ue(e)} L${ur(d-u*l)} ${ur(f+s*l)} L${ur(d+u*l)} ${ur(f-s*l)} Z`}function Lr(e,t){let r=Math.atan(t/e);return e===0&&r<0&&(r=-r),Number.isFinite(r)||(r=0),r*180/Math.PI}function w0(e,t,r,n){const o={x:t.x-e.x,y:t.y-e.y},i={x:r.x-t.x,y:r.y-t.y},a=Math.hypot(o.x,o.y),s=Math.hypot(i.x,i.y),u=o.x*i.y-o.y*i.x;if(a<1e-6||s<1e-6||Math.abs(u)<1e-6)return{p1:t,b:t,p2:t,r:0};const c=Math.min(n,a/2,s/2);return{p1:{x:t.x-o.x/a*c,y:t.y-o.y/a*c},b:t,p2:{x:t.x+i.x/s*c,y:t.y+i.y/s*c},r:c}}function Cb(e,t,r,n){let o=-1,i=null;for(let b=0;b<e.length-1;b++){const y=ft(e[b],e[b+1],t);if(y){o=b,i=y;break}}let a=-1,s=null;for(let b=e.length-1;b>0;b--){const y=ft(e[b],e[b-1],r);if(y){a=b,s=y;break}}if(!i||!s||o>=a)return null;const u=e.slice(o+1,a),c=u[0]??s,l=u[u.length-1]??i;let d,f,p;if(n.arrowAt==="source"){const b=Qe(i,c,n.srcDist);d=Qe(i,c,n.srcDist+n.arrowGap),p=br(b,c,n.arrowSize,n.headShape)}else d=Qe(i,c,n.srcDist);if(n.arrowAt==="target"){const b=Qe(s,l,n.tgtDist);f=Qe(s,l,n.tgtDist+n.arrowGap),p=br(b,l,n.arrowSize,n.headShape)}else f=Qe(s,l,n.tgtDist);return wn(d,u,f,p,n.radius,n.labelTargetLength,n.labelFraction)}function wn(e,t,r,n,o,i,a){var f;const s=[e,...t,r],u=[];let c=`M${Ue(e)}`;for(let p=1;p<s.length-1;p++){const b=w0(s[p-1],s[p],s[p+1],o);u.push(b),b.r===0?c+=` L${Ue(b.b)}`:c+=` L${Ue(b.p1)} Q${Ue(b.b)} ${Ue(b.p2)}`}c+=` L${Ue(r)}`;let l;const d=t.length;if(d===0)l={x:(e.x+r.x)/2,y:(e.y+r.y)/2,angle:Lr(r.x-e.x,r.y-e.y)};else if(d%2===0){const p=t[d/2-1],b=t[d/2];l={x:(p.x+b.x)/2,y:(p.y+b.y)/2,angle:Lr(b.x-p.x,b.y-p.y)}}else{const p=u[(d-1)/2];if(p.r===0){const b=s[(d-1)/2+2];l={x:p.b.x,y:p.b.y,angle:Lr(b.x-p.b.x,b.y-p.b.y)}}else l={x:.25*p.p1.x+.5*p.b.x+.25*p.p2.x,y:.25*p.p1.y+.5*p.b.y+.25*p.p2.y,angle:Lr(p.p2.x-p.p1.x,p.p2.y-p.p1.y)}}if(i!==void 0){if(a!==void 0&&u.length===2){const m=u[0].p2,x=u[1].p1,g=Math.hypot(x.x-m.x,x.y-m.y),w=Math.min(.5,i/(2*g)),v=Math.max(w,Math.min(1-w,a));l={x:m.x+(x.x-m.x)*v,y:m.y+(x.y-m.y)*v,angle:Lr(x.x-m.x,x.y-m.y)}}const p=((f=u[u.length-1])==null?void 0:f.p2)??e,b=r.x-p.x,y=r.y-p.y;Math.hypot(b,y)>=i&&(l={x:(p.x+r.x)/2,y:(p.y+r.y)/2,angle:Lr(b,y)})}return{d:c,arrow:n,label:l}}function Ol(e,t,r,n,o,i,a){const s=r==="leftward"?-1:1,u={x:e.x+s*(e.w/2+a.srcDist),y:n??e.y},c={x:t.x-s*(t.w/2+a.tgtDist),y:o??t.y},l=Math.max(80,a.arrowGap+a.arrowSize*.3),d=u.x+s*l,f=c.x-s*l;let p;if(s*(f-d)>=0){const x=u.x+(c.x-u.x)*i,g=Math.max(Math.min(d,f),Math.min(Math.max(d,f),x));p=[{x:g,y:u.y},{x:g,y:c.y}]}else{const x=Math.min(e.y-e.h/2,t.y-t.h/2)-l*(1+i);p=[{x:d,y:u.y},{x:d,y:x},{x:f,y:x},{x:f,y:c.y}]}const b=a.arrowAt==="source"?Qe(u,p[0],a.arrowGap):u,y=a.arrowAt==="target"?Qe(c,p[p.length-1],a.arrowGap):c,m=a.arrowAt==="source"?br(u,p[0],a.arrowSize,a.headShape):a.arrowAt==="target"?br(c,p[p.length-1],a.arrowSize,a.headShape):void 0;return wn(b,p,y,m,a.radius)}function Il(e,t,r,n,o){return Cb(m0(e,t,r,n),e,t,o)}function Ml(e,t,r,n,o,i){const a=n===void 0&&o===void 0&&(r==="downward"||r==="upward"),s=r==="leftward"||a&&r==="upward"?-1:1,u=(c,l,d)=>{const f={x:c.x,y:l??c.y},p=Math.max(c.w,c.h)*2+1,b=ft(f,{x:f.x+(a?0:d*p),y:f.y+(a?d*p:0)},c);return b?{x:b.x+(a?0:d*i),y:b.y+(a?d*i:0)}:a?{x:c.x,y:c.y+d*(c.h/2+i)}:{x:c.x+d*(c.w/2+i),y:l??c.y}};return{sourcePoint:u(e,n,s),targetPoint:u(t,o,-s)}}function C0(e,t,r,n){const o=r==="downward"||r==="upward",i=r==="leftward"||r==="upward"?-1:1,a=Math.max(100,Math.abs(o?t.y-e.y:t.x-e.x)/2),s={x:e.x+(o?0:i*a),y:e.y+(o?i*a:0)},u={x:t.x-(o?0:i*a),y:t.y-(o?i*a:0)},c=n.arrowAt==="source"?Qe(e,s,n.arrowGap):e,l=n.arrowAt==="target"?Qe(t,u,n.arrowGap):t;return{d:`M${Ue(c)} C${Ue(s)} ${Ue(u)} ${Ue(l)}`,arrow:n.arrowAt==="source"?br(e,s,n.arrowSize,n.headShape):n.arrowAt==="target"?br(t,u,n.arrowSize,n.headShape):void 0,label:{x:(c.x+3*s.x+3*u.x+l.x)/8,y:(c.y+3*s.y+3*u.y+l.y)/8,angle:Lr(l.x+u.x-s.x-c.x,l.y+u.y-s.y-c.y)}}}function _b(e,t,r){const n=r.arrowAt==="source"?Qe(e,t,r.arrowGap):e,o=r.arrowAt==="target"?Qe(t,e,r.arrowGap):t,i=r.arrowAt==="source"?br(e,t,r.arrowSize,r.headShape):r.arrowAt==="target"?br(t,e,r.arrowSize,r.headShape):void 0;return wn(n,[],o,i,0)}function _0(e,t,r,n=-90,o=-60,i=350){const a=n*Math.PI/180,s=o*Math.PI/180,u=a-Math.PI/2,c=u-s/2,l=u+s/2,d=1.4*i*(t/3+1),f={x:e.x+Math.cos(c)*d,y:e.y+Math.sin(c)*d},p={x:e.x+Math.cos(l)*d,y:e.y+Math.sin(l)*d},b={x:e.x,y:e.y},y=ft(b,f,e),m=ft(b,p,e);if(!y||!m)return null;const x={x:(f.x+p.x)/2,y:(f.y+p.y)/2};let g=Qe(y,f,r.srcDist),w=Qe(m,p,r.tgtDist),v;if(r.arrowAt==="target"){const C=w;w=Qe(m,p,r.tgtDist+r.arrowGap),v=br(C,p,r.arrowSize,r.headShape)}else if(r.arrowAt==="source"){const C=g;g=Qe(y,f,r.srcDist+r.arrowGap),v=br(C,f,r.arrowSize,r.headShape)}return{d:`M${Ue(g)} Q${Ue(f)} ${Ue(x)} Q${Ue(p)} ${Ue(w)}`,arrow:v,label:{x:x.x,y:x.y,angle:Lr(p.x-f.x,p.y-f.y)}}}const ot=e=>Math.round(e*1e3)/1e3;function Sb(e){const t=e.querySelector("[data-flow-node-surface]");if(!t)return;const r=e.getBoundingClientRect(),n=r.width/e.offsetWidth;if(!Number.isFinite(n)||n<=0)return;const o=t.getBoundingClientRect();if(!o.width||!o.height)return;const i=t,a=typeof i.getScreenCTM=="function"?i.getScreenCTM():null,s=typeof i.getTotalLength=="function"?i.getTotalLength():0,u=i.points,c=(u==null?void 0:u.numberOfItems)||128,l=a&&s>0?Array.from({length:c},(d,f)=>{const p=u!=null&&u.numberOfItems?u.getItem(f):i.getPointAtLength(s*f/c);return{x:ot((a.a*p.x+a.c*p.y+a.e-r.left)/n),y:ot((a.b*p.x+a.d*p.y+a.f-r.top)/n)}}):void 0;return{left:ot((o.left-r.left)/n),top:ot((o.top-r.top)/n),width:t instanceof HTMLElement?t.offsetWidth:ot(o.width/n),height:t instanceof HTMLElement?t.offsetHeight:ot(o.height/n),radius:parseFloat(getComputedStyle(t).borderTopLeftRadius)||0,...l?{outline:l}:{}}}function $t(e,t){const r=e.x-e.w/2,n=e.y-e.h/2;return{x:r+t.left+t.width/2,y:n+t.top+t.height/2,w:t.width,h:t.height,...t.outline?{outline:t.outline.map(o=>({x:r+o.x,y:n+o.y}))}:{}}}function S0(e,t,r,n,o){var l;const i=o!=="TB"&&o!=="BT",a=i?"top":"left",s=i?"bottom":"right",u=new Map;for(const d of n)for(const[f,p,b]of[[d.source,d.sourceProperty,d.target],[d.target,d.targetProperty,d.source]]){const y=t.get(b);if(p===void 0||!y||b===f)continue;const m=r.get(b),x=JSON.stringify([f,p]),g=u.get(x)??[];g.push(m?$t(y,m):y),u.set(x,g)}const c=new Map(e);for(const[d,f]of e){const p=t.get(d);if(!p||!f.some(w=>w.placement==="config"))continue;const b=r.get(d),y=b?$t(p,b):p,m={x:p.w/2,y:p.h/2,w:p.w,h:p.h},x=b?$t(m,b):m,g=new Map;for(const w of f){if(w.placement!=="config")continue;const _=(u.get(JSON.stringify([d,w.property]))??[]).reduce((S,T)=>S+(i?T.y-y.y:T.x-y.x),0),C=((l=w.anchor)==null?void 0:l.side)===s?s:a;g.set(w,_<-.001?a:_>.001?s:C)}c.set(d,f.map(w=>{const v=g.get(w);if(!v)return w;const _=f.filter(T=>g.get(T)===v),C=(_.indexOf(w)+1)/(_.length+1),S=wb(x,v,C);return{...w,anchor:S,top:S.y,height:0}}))}return c}function ql(e,t,r){const n=new Set(t.map(s=>s.id));if(!n.has(e))return new Set;const o=new Set([e]);let i=!0;for(;i;){i=!1;for(const s of t)!o.has(s.id)&&(o.has(s.parent??"")||s.id.startsWith(`${e}.`))&&(o.add(s.id),i=!0)}const a=new Set(o);for(const s of r)o.has(s.source)&&n.has(s.target)&&a.add(s.target),o.has(s.target)&&n.has(s.source)&&a.add(s.source);return a}const Qr='"Helvetica Neue", Helvetica, sans-serif';let _t;const nn=new Map;function Cn(e,t){const r=`${t}|${e}`,n=nn.get(r);if(n!==void 0)return n;_t===void 0&&(_t=typeof document<"u"?document.createElement("canvas").getContext("2d"):null);let o;return _t?(_t.font=t,o=_t.measureText(e).width):o=e.length*(parseFloat(t)||16)*.55,nn.size>5e3&&nn.clear(),nn.set(r,o),o}function j0(e,t,r){const n=[];for(const o of String(e).split(`
150
+ `)){const i=o.split(/\s+/).filter(Boolean);if(!i.length){n.push("");continue}let a="";for(const s of i){const u=a?`${a} ${s}`:s;!a||Cn(u,t)<=r?a=u:(n.push(a),a=s)}n.push(a)}return n}const E0=e=>e.stopPropagation();function R0({id:e,rect:t,label:r,labelLayer:n,style:o,onSelect:i,onCollapse:a,selected:s=!1}){const u=t.x2-t.x1,c=t.y2-t.y1,l=o.borderWidth,d=o.borderStyle==="dashed"?`${l*4} ${l*2}`:o.borderStyle==="dotted"?`${l} ${l}`:void 0,f=t.x1+u/2,p=o.labelPosition==="top"?t.y1+o.labelMargin-o.fontSize/2:o.labelPosition==="bottom"?t.y2-o.labelMargin+o.fontSize/2:t.y1+c/2,b=r?Cn(r,`bold ${o.fontSize}px ${Qr}`):0,y=o.fontSize/5,m=r||s&&a?h.jsxs("g",{className:"flow-sdk-container-label","data-node-id":e,children:[s&&a&&h.jsx("foreignObject",{x:f+b/2+y+8,y:p-24,width:48,height:48,"data-flow-content-toggle":"",style:{pointerEvents:"auto"},children:h.jsx(je,{label:"Show icon",children:h.jsx(ve,{"aria-label":"Show icon",icon:h.jsx(Z.PiCircleFill,{}),variant:"ghost",style:{width:48,height:48,color:o.textColor},onClick:x=>{x.stopPropagation(),a(e)}})})}),r&&h.jsxs(h.Fragment,{children:[h.jsx("rect",{x:f-b/2-y,y:p-o.fontSize/2-y,width:b+2*y,height:o.fontSize+2*y,fill:o.textColor==="transparent"?"transparent":o.labelBg}),h.jsx("text",{x:f,y:p,fill:o.textColor,fontSize:o.fontSize,fontWeight:"bold",fontFamily:Qr,style:{fontSize:o.fontSize,fontWeight:"bold",fontFamily:Qr},textAnchor:"middle",dominantBaseline:"central",children:r})]})]}):null;return h.jsxs("g",{className:"flow-sdk-container","data-node-id":e,onPointerDown:E0,onClick:x=>{x.stopPropagation(),i==null||i(e,{shiftKey:x.shiftKey,ctrlKey:x.ctrlKey,metaKey:x.metaKey,altKey:x.altKey})},children:[h.jsx("rect",{x:t.x1,y:t.y1,width:u,height:c,rx:o.borderRadius,ry:o.borderRadius,fill:o.bgColor,fillOpacity:o.bgOpacity,stroke:o.borderColor,strokeWidth:o.borderStyle==="double"?l/3:l,strokeDasharray:d}),o.borderStyle==="double"&&h.jsx("rect",{x:t.x1+l*2/3,y:t.y1+l*2/3,width:Math.max(0,u-l*4/3),height:Math.max(0,c-l*4/3),rx:Math.max(0,o.borderRadius-l*2/3),ry:Math.max(0,o.borderRadius-l*2/3),fill:"none",stroke:o.borderColor,strokeWidth:l/3}),o.animated&&l>0&&h.jsx(xb,{variant:o.animationVariant,x:t.x1,y:t.y1,width:u,height:c,radius:o.borderRadius,color:o.animationColor||o.borderColor,strokeWidth:Math.max(8,l*1.6)}),n&&m?Lt.createPortal(m,n):m]})}const k0=E.memo(R0),fn=45,jb=70,Kr=15,Eb=50;function Rb(e,t,r=fn){const n=`${r}px ${Qr}`,o=e?j0(e,n,200*r/fn):[],i=t?48+(o.length?12:0):0,a=i+Math.max(0,...o.map(c=>Cn(c,n))),s=Math.max(o.length*r,t?48:0),u=o.length||t?2*Kr:0;return{lines:o,iconWidth:i,contentWidth:a,contentHeight:s,width:a+u,height:s+u}}const hn=6,kb=3,$u=Math.max(Math.pow(hn*13.37,.9),29)*kb,Pb=hn*kb*2,an=80,P0=2*an+$u*.3+100,A0=36+2*Math.max(80,Pb+$u*.3);function xu(e){return e.sourceProperty!==void 0||e.targetProperty!==void 0}function wu(e,t){return t==="auto"||(t==="properties"?xu(e):!xu(e))}function st(e,t,r){return r!=="properties"||e!=="root"||t.some(n=>(n.source===e||n.target===e)&&xu(n))}function T0(e,t,r,n=!1,o){if(!n||r!=="properties"&&!o)return{nodes:e,edges:t};const i=e.filter(s=>st(s.id,t,r)&&(!o||o.has(s.id))),a=new Set(i.map(s=>s.id));return{nodes:i,edges:t.filter(s=>wu(s,r)&&a.has(s.source)&&a.has(s.target))}}const O0=500,I0="32 18",M0=e=>e.stopPropagation();function q0({id:e,edgeData:t,validationIssue:r,edgeType:n="rounded-orthogonal",edgeRadius:o,customEdgeTypes:i,source:a,target:s,sourceProperty:u,targetProperty:c,sourceY:l,targetY:d,sourcePort:f,targetPort:p,propertyMode:b=!1,dir:y,turn:m,labelAtTarget:x,labelFraction:g,color:w,labelBg:v,labelLayer:_,label:C,dashed:S,animated:T,inverted:k,loopIndex:j=0,onSelect:P}){const R=t==null?void 0:t.icon,I=b?fn:jb,{lines:O,iconWidth:M,contentWidth:q,contentHeight:H}=E.useMemo(()=>Rb(C,R,I),[C,R,I]),V=E.useMemo(()=>{const X={srcDist:an,tgtDist:an,arrowGap:Pb,arrowSize:$u,headShape:b&&(k?l!==void 0||f:d!==void 0||p)?"square":"triangle",radius:o??(x?40:O0),arrowAt:k?"source":"target",labelTargetLength:x?q+2*Kr:void 0,labelFraction:x?g:void 0},se=l!==void 0||d!==void 0||!!f||!!p,Q=Ml(a,s,y,l,d,0),G=l===void 0&&d===void 0&&(y==="downward"||y==="upward"),J=f??{...Q.sourcePoint,side:G?y==="upward"?"top":"bottom":y==="leftward"?"left":"right"},te=p??{...Q.targetPoint,side:G?y==="upward"?"bottom":"top":y==="leftward"?"right":"left"},de=a.x===s.x&&a.y===s.y,fe=f||p?x0(J,te,{...X,srcDist:18,tgtDist:18},n):se?Ol(a,s,y,l,d,m,{...X,srcDist:18,tgtDist:18,radius:o??Math.min(X.radius,40)}):de?_0(a,j,{...X,srcDist:0,tgtDist:0}):Il(a,s,y,m,X);if(!fe)return null;const Ee=Ml(a,s,y,l,d,se?18:an);f&&(Ee.sourcePoint=ut(f,18)),p&&(Ee.targetPoint=ut(p,18));const ge=Object.prototype.hasOwnProperty.call(i??{},n)?i==null?void 0:i[n]:void 0;if(ge){const We={rightward:"LR",leftward:"RL",downward:"TB",upward:"BT"};return ge({edge:t??{id:e,source:"",target:""},source:{...a},target:{...s},...Ee,direction:We[y],sourceY:l,targetY:d,inverted:!!k,defaultGeometry:fe})??fe}return de||f||p?fe:n==="straight"?se?_b(Ee.sourcePoint,Ee.targetPoint,X):Cb([a,s],a,s,X):n==="bezier"?C0(Ee.sourcePoint,Ee.targetPoint,se?y==="leftward"?"leftward":"rightward":y,X):n==="orthogonal"?se?Ol(a,s,y,l,d,m,{...X,srcDist:18,tgtDist:18,radius:0}):Il(a,s,y,m,{...X,radius:0}):fe},[a,e,t,n,o,i,s,b,l,d,f,p,y,m,k,j,x,g,q]);if(!V)return null;const re=(y==="rightward"||y==="leftward")&&!Object.prototype.hasOwnProperty.call(i??{},n)&&!(b&&(l!==void 0||d!==void 0||f||p)),ce=re?`translate(${V.label.x} ${V.label.y-H/2-2*Kr})`:`translate(${V.label.x} ${V.label.y}) rotate(${V.label.angle}) translate(${x||Object.prototype.hasOwnProperty.call(i??{},n)?0:Eb} 0)`,le=r!=null&&r.startsWith("Unverified:")?"#b45309":"#dc2626",be=r?le:w,K=r?h.jsxs("g",{className:"flow-sdk-edge-validation",role:"img","aria-label":r,transform:`translate(${V.label.x} ${V.label.y-O.length*I/2-55})`,children:[h.jsx("title",{children:r}),h.jsx(Mr,{name:"PiWarningCircleFill",svg:!0,size:48,x:-24,y:-24,color:le})]}):null,N=T&&(t==null?void 0:t.edgeAnimationVariant)==="traveling",B=!N&&(S||T)?I0:void 0,W=T&&!N?`flow-sdk-edge-anim${k?" flow-sdk-edge-anim-rev":""}`:void 0;let z=null;if(O.length||R){const X=q,se=H;z=h.jsxs("g",{className:"flow-sdk-edge-label","data-label-transform":ce,"data-label-horizontal":re||void 0,"data-edge-id":e,"data-source-property":u,"data-target-property":c,transform:ce,children:[h.jsx("rect",{x:-X/2-Kr,y:-se/2-Kr,width:X+2*Kr,height:se+2*Kr,fill:w==="transparent"?"transparent":v}),h.jsx("text",{fill:w,fontSize:I,style:{fontSize:I,fontFamily:Qr},fontFamily:Qr,textAnchor:"middle",dominantBaseline:"central",children:O.map((Q,G)=>h.jsx("tspan",{x:M/2,y:(G-(O.length-1)/2)*I,children:Q},G))}),R&&h.jsxs("g",{className:"flow-sdk-edge-icon",opacity:w==="transparent"?0:1,children:[h.jsx("title",{children:C?`Edge icon: ${C}`:"Edge icon"}),h.jsx("rect",{x:-X/2,y:-24,width:48,height:48,fill:"transparent"}),h.jsx(Mr,{name:R,svg:!0,size:48,x:-X/2,y:-24,color:w})]})]})}return h.jsxs("g",{className:"flow-sdk-edge","data-edge-id":e,"data-source-property":u,"data-target-property":c,"data-validation":r?r.startsWith("Unverified:")?"unverified":"invalid":void 0,"aria-label":r,onPointerDown:M0,onClick:X=>{X.stopPropagation(),P==null||P(e)},children:[h.jsx("path",{d:V.d,fill:"none",stroke:be,strokeWidth:hn,strokeOpacity:N?.35:void 0,strokeDasharray:B,className:W}),N&&h.jsx(d0,{path:V.d,color:be,width:hn*1.6,reversed:k}),V.arrow&&h.jsx("path",{d:V.arrow,fill:be}),_&&z?Lt.createPortal(z,_):z,_&&K?Lt.createPortal(K,_):K,h.jsx("path",{className:"flow-sdk-edge-hit",d:V.d,fill:"none",stroke:"transparent"})]})}const Nl=E.memo(q0),$l=(e,t)=>e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top;function N0(e){const t=e.querySelector(".flow-sdk-labels"),r=t==null?void 0:t.getScreenCTM();if(!t||!r)return;const n=r.inverse(),o=(c,l=0)=>{const d=c.getBoundingClientRect(),f=new DOMPoint(d.left,d.top).matrixTransform(n),p=new DOMPoint(d.right,d.bottom).matrixTransform(n);return{left:f.x-l,right:p.x+l,top:f.y-l,bottom:p.y+l}},i=[...e.querySelectorAll(".flow-sdk-node, .flow-sdk-node button")].filter(c=>{const l=c.getBoundingClientRect(),d=getComputedStyle(c);return l.width>0&&l.height>0&&d.visibility!=="hidden"&&d.opacity!=="0"}).map(c=>o(c,24));for(const c of t.querySelectorAll(".flow-sdk-container-label"))i.push(o(c,12));const a=[...t.querySelectorAll(".flow-sdk-edge-label")];for(const c of a)c.setAttribute("transform",c.dataset.labelTransform??"");const s=new Map(a.map(c=>[c,o(c,8)])),u=new Map([...e.querySelectorAll(".flow-sdk-edge")].map(c=>[c.dataset.edgeId,c.querySelector("path")]));for(const c of a){const l=c.dataset.labelHorizontal==="true",d=s.get(c);s.delete(c);const f=S=>i.some(T=>$l(S,T))||[...s.values()].some(T=>$l(S,T));if(!l&&!f(d)){s.set(c,d);continue}const p=u.get(c.dataset.edgeId),b=c.querySelector("rect");if(!p||!b)continue;const y=b.getBBox(),m=p.getTotalLength();if(!Number.isFinite(m)||m<=0)continue;const x=(d.left+d.right)/2,g=(d.top+d.bottom)/2,w=Math.min(256,Math.max(16,Math.ceil(m/24))),v=Array.from({length:w+1},(S,T)=>p.getPointAtLength(m*T/w)),C=Array.from({length:w+1},(S,T)=>{const k=m*T/w,j=v[T],P=l?{x:j.x,y:j.y-y.height/2-15}:j,R=p.getPointAtLength(Math.max(0,k-2)),I=p.getPointAtLength(Math.min(m,k+2));let O=Math.atan2(I.y-R.y,I.x-R.x)*180/Math.PI;O>90&&(O-=180),O<-90&&(O+=180);const M=Math.abs(O)<1;l&&(O=0);const q=O*Math.PI/180,H=Math.abs(Math.cos(q))*y.width+Math.abs(Math.sin(q))*y.height,V=Math.abs(Math.sin(q))*y.width+Math.abs(Math.cos(q))*y.height;return{point:P,angle:O,straight:M,score:Math.hypot(P.x-x,P.y-g),bounds:{left:P.x-H/2-8,right:P.x+H/2+8,top:P.y-V/2-8,bottom:P.y+V/2+8}}}).sort((S,T)=>S.score-T.score).find(S=>!f(S.bounds)&&(!l||S.straight&&!v.some(T=>T.x>S.bounds.left&&T.x<S.bounds.right&&T.y>S.bounds.top&&T.y<S.bounds.bottom)));C?(c.setAttribute("transform",`translate(${C.point.x} ${C.point.y}) rotate(${C.angle})`),s.set(c,C.bounds)):s.set(c,d)}}var on=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Lu(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Yn,Ll;function L0(){if(Ll)return Yn;Ll=1;function e(){this.__data__=[],this.size=0}return Yn=e,Yn}var Xn,Fl;function gt(){if(Fl)return Xn;Fl=1;function e(t,r){return t===r||t!==t&&r!==r}return Xn=e,Xn}var Qn,Bl;function _n(){if(Bl)return Qn;Bl=1;var e=gt();function t(r,n){for(var o=r.length;o--;)if(e(r[o][0],n))return o;return-1}return Qn=t,Qn}var eo,Dl;function F0(){if(Dl)return eo;Dl=1;var e=_n(),t=Array.prototype,r=t.splice;function n(o){var i=this.__data__,a=e(i,o);if(a<0)return!1;var s=i.length-1;return a==s?i.pop():r.call(i,a,1),--this.size,!0}return eo=n,eo}var ro,zl;function B0(){if(zl)return ro;zl=1;var e=_n();function t(r){var n=this.__data__,o=e(n,r);return o<0?void 0:n[o][1]}return ro=t,ro}var to,Vl;function D0(){if(Vl)return to;Vl=1;var e=_n();function t(r){return e(this.__data__,r)>-1}return to=t,to}var no,Wl;function z0(){if(Wl)return no;Wl=1;var e=_n();function t(r,n){var o=this.__data__,i=e(o,r);return i<0?(++this.size,o.push([r,n])):o[i][1]=n,this}return no=t,no}var oo,Gl;function Sn(){if(Gl)return oo;Gl=1;var e=L0(),t=F0(),r=B0(),n=D0(),o=z0();function i(a){var s=-1,u=a==null?0:a.length;for(this.clear();++s<u;){var c=a[s];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,oo=i,oo}var io,Ul;function V0(){if(Ul)return io;Ul=1;var e=Sn();function t(){this.__data__=new e,this.size=0}return io=t,io}var ao,Hl;function W0(){if(Hl)return ao;Hl=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return ao=e,ao}var so,Kl;function G0(){if(Kl)return so;Kl=1;function e(t){return this.__data__.get(t)}return so=e,so}var co,Zl;function U0(){if(Zl)return co;Zl=1;function e(t){return this.__data__.has(t)}return co=e,co}var uo,Jl;function Ab(){if(Jl)return uo;Jl=1;var e=typeof on=="object"&&on&&on.Object===Object&&on;return uo=e,uo}var lo,Yl;function Sr(){if(Yl)return lo;Yl=1;var e=Ab(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return lo=r,lo}var fo,Xl;function yt(){if(Xl)return fo;Xl=1;var e=Sr(),t=e.Symbol;return fo=t,fo}var ho,Ql;function H0(){if(Ql)return ho;Ql=1;var e=yt(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,o=e?e.toStringTag:void 0;function i(a){var s=r.call(a,o),u=a[o];try{a[o]=void 0;var c=!0}catch{}var l=n.call(a);return c&&(s?a[o]=u:delete a[o]),l}return ho=i,ho}var po,ed;function K0(){if(ed)return po;ed=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return po=r,po}var go,rd;function et(){if(rd)return go;rd=1;var e=yt(),t=H0(),r=K0(),n="[object Null]",o="[object Undefined]",i=e?e.toStringTag:void 0;function a(s){return s==null?s===void 0?o:n:i&&i in Object(s)?t(s):r(s)}return go=a,go}var yo,td;function mr(){if(td)return yo;td=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return yo=e,yo}var bo,nd;function Yt(){if(nd)return bo;nd=1;var e=et(),t=mr(),r="[object AsyncFunction]",n="[object Function]",o="[object GeneratorFunction]",i="[object Proxy]";function a(s){if(!t(s))return!1;var u=e(s);return u==n||u==o||u==r||u==i}return bo=a,bo}var mo,od;function Z0(){if(od)return mo;od=1;var e=Sr(),t=e["__core-js_shared__"];return mo=t,mo}var vo,id;function J0(){if(id)return vo;id=1;var e=Z0(),t=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!t&&t in n}return vo=r,vo}var xo,ad;function Tb(){if(ad)return xo;ad=1;var e=Function.prototype,t=e.toString;function r(n){if(n!=null){try{return t.call(n)}catch{}try{return n+""}catch{}}return""}return xo=r,xo}var wo,sd;function Y0(){if(sd)return wo;sd=1;var e=Yt(),t=J0(),r=mr(),n=Tb(),o=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,a=Function.prototype,s=Object.prototype,u=a.toString,c=s.hasOwnProperty,l=RegExp("^"+u.call(c).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function d(f){if(!r(f)||t(f))return!1;var p=e(f)?l:i;return p.test(n(f))}return wo=d,wo}var Co,cd;function X0(){if(cd)return Co;cd=1;function e(t,r){return t==null?void 0:t[r]}return Co=e,Co}var _o,ud;function rt(){if(ud)return _o;ud=1;var e=Y0(),t=X0();function r(n,o){var i=t(n,o);return e(i)?i:void 0}return _o=r,_o}var So,ld;function Fu(){if(ld)return So;ld=1;var e=rt(),t=Sr(),r=e(t,"Map");return So=r,So}var jo,dd;function jn(){if(dd)return jo;dd=1;var e=rt(),t=e(Object,"create");return jo=t,jo}var Eo,fd;function Q0(){if(fd)return Eo;fd=1;var e=jn();function t(){this.__data__=e?e(null):{},this.size=0}return Eo=t,Eo}var Ro,hd;function ew(){if(hd)return Ro;hd=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return Ro=e,Ro}var ko,pd;function rw(){if(pd)return ko;pd=1;var e=jn(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function o(i){var a=this.__data__;if(e){var s=a[i];return s===t?void 0:s}return n.call(a,i)?a[i]:void 0}return ko=o,ko}var Po,gd;function tw(){if(gd)return Po;gd=1;var e=jn(),t=Object.prototype,r=t.hasOwnProperty;function n(o){var i=this.__data__;return e?i[o]!==void 0:r.call(i,o)}return Po=n,Po}var Ao,yd;function nw(){if(yd)return Ao;yd=1;var e=jn(),t="__lodash_hash_undefined__";function r(n,o){var i=this.__data__;return this.size+=this.has(n)?0:1,i[n]=e&&o===void 0?t:o,this}return Ao=r,Ao}var To,bd;function ow(){if(bd)return To;bd=1;var e=Q0(),t=ew(),r=rw(),n=tw(),o=nw();function i(a){var s=-1,u=a==null?0:a.length;for(this.clear();++s<u;){var c=a[s];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,To=i,To}var Oo,md;function iw(){if(md)return Oo;md=1;var e=ow(),t=Sn(),r=Fu();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return Oo=n,Oo}var Io,vd;function aw(){if(vd)return Io;vd=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return Io=e,Io}var Mo,xd;function En(){if(xd)return Mo;xd=1;var e=aw();function t(r,n){var o=r.__data__;return e(n)?o[typeof n=="string"?"string":"hash"]:o.map}return Mo=t,Mo}var qo,wd;function sw(){if(wd)return qo;wd=1;var e=En();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return qo=t,qo}var No,Cd;function cw(){if(Cd)return No;Cd=1;var e=En();function t(r){return e(this,r).get(r)}return No=t,No}var $o,_d;function uw(){if(_d)return $o;_d=1;var e=En();function t(r){return e(this,r).has(r)}return $o=t,$o}var Lo,Sd;function lw(){if(Sd)return Lo;Sd=1;var e=En();function t(r,n){var o=e(this,r),i=o.size;return o.set(r,n),this.size+=o.size==i?0:1,this}return Lo=t,Lo}var Fo,jd;function Bu(){if(jd)return Fo;jd=1;var e=iw(),t=sw(),r=cw(),n=uw(),o=lw();function i(a){var s=-1,u=a==null?0:a.length;for(this.clear();++s<u;){var c=a[s];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=o,Fo=i,Fo}var Bo,Ed;function dw(){if(Ed)return Bo;Ed=1;var e=Sn(),t=Fu(),r=Bu(),n=200;function o(i,a){var s=this.__data__;if(s instanceof e){var u=s.__data__;if(!t||u.length<n-1)return u.push([i,a]),this.size=++s.size,this;s=this.__data__=new r(u)}return s.set(i,a),this.size=s.size,this}return Bo=o,Bo}var Do,Rd;function Rn(){if(Rd)return Do;Rd=1;var e=Sn(),t=V0(),r=W0(),n=G0(),o=U0(),i=dw();function a(s){var u=this.__data__=new e(s);this.size=u.size}return a.prototype.clear=t,a.prototype.delete=r,a.prototype.get=n,a.prototype.has=o,a.prototype.set=i,Do=a,Do}var zo,kd;function Du(){if(kd)return zo;kd=1;function e(t,r){for(var n=-1,o=t==null?0:t.length;++n<o&&r(t[n],n,t)!==!1;);return t}return zo=e,zo}var Vo,Pd;function Ob(){if(Pd)return Vo;Pd=1;var e=rt(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return Vo=t,Vo}var Wo,Ad;function kn(){if(Ad)return Wo;Ad=1;var e=Ob();function t(r,n,o){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[n]=o}return Wo=t,Wo}var Go,Td;function Pn(){if(Td)return Go;Td=1;var e=kn(),t=gt(),r=Object.prototype,n=r.hasOwnProperty;function o(i,a,s){var u=i[a];(!(n.call(i,a)&&t(u,s))||s===void 0&&!(a in i))&&e(i,a,s)}return Go=o,Go}var Uo,Od;function Xt(){if(Od)return Uo;Od=1;var e=Pn(),t=kn();function r(n,o,i,a){var s=!i;i||(i={});for(var u=-1,c=o.length;++u<c;){var l=o[u],d=a?a(i[l],n[l],l,i,n):void 0;d===void 0&&(d=n[l]),s?t(i,l,d):e(i,l,d)}return i}return Uo=r,Uo}var Ho,Id;function fw(){if(Id)return Ho;Id=1;function e(t,r){for(var n=-1,o=Array(t);++n<t;)o[n]=r(n);return o}return Ho=e,Ho}var Ko,Md;function Pr(){if(Md)return Ko;Md=1;function e(t){return t!=null&&typeof t=="object"}return Ko=e,Ko}var Zo,qd;function hw(){if(qd)return Zo;qd=1;var e=et(),t=Pr(),r="[object Arguments]";function n(o){return t(o)&&e(o)==r}return Zo=n,Zo}var Jo,Nd;function Qt(){if(Nd)return Jo;Nd=1;var e=hw(),t=Pr(),r=Object.prototype,n=r.hasOwnProperty,o=r.propertyIsEnumerable,i=e((function(){return arguments})())?e:function(a){return t(a)&&n.call(a,"callee")&&!o.call(a,"callee")};return Jo=i,Jo}var Yo,$d;function Ke(){if($d)return Yo;$d=1;var e=Array.isArray;return Yo=e,Yo}var Pt={exports:{}},Xo,Ld;function pw(){if(Ld)return Xo;Ld=1;function e(){return!1}return Xo=e,Xo}Pt.exports;var Fd;function bt(){return Fd||(Fd=1,(function(e,t){var r=Sr(),n=pw(),o=t&&!t.nodeType&&t,i=o&&!0&&e&&!e.nodeType&&e,a=i&&i.exports===o,s=a?r.Buffer:void 0,u=s?s.isBuffer:void 0,c=u||n;e.exports=c})(Pt,Pt.exports)),Pt.exports}var Qo,Bd;function An(){if(Bd)return Qo;Bd=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(n,o){var i=typeof n;return o=o??e,!!o&&(i=="number"||i!="symbol"&&t.test(n))&&n>-1&&n%1==0&&n<o}return Qo=r,Qo}var ei,Dd;function zu(){if(Dd)return ei;Dd=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return ei=t,ei}var ri,zd;function gw(){if(zd)return ri;zd=1;var e=et(),t=zu(),r=Pr(),n="[object Arguments]",o="[object Array]",i="[object Boolean]",a="[object Date]",s="[object Error]",u="[object Function]",c="[object Map]",l="[object Number]",d="[object Object]",f="[object RegExp]",p="[object Set]",b="[object String]",y="[object WeakMap]",m="[object ArrayBuffer]",x="[object DataView]",g="[object Float32Array]",w="[object Float64Array]",v="[object Int8Array]",_="[object Int16Array]",C="[object Int32Array]",S="[object Uint8Array]",T="[object Uint8ClampedArray]",k="[object Uint16Array]",j="[object Uint32Array]",P={};P[g]=P[w]=P[v]=P[_]=P[C]=P[S]=P[T]=P[k]=P[j]=!0,P[n]=P[o]=P[m]=P[i]=P[x]=P[a]=P[s]=P[u]=P[c]=P[l]=P[d]=P[f]=P[p]=P[b]=P[y]=!1;function R(I){return r(I)&&t(I.length)&&!!P[e(I)]}return ri=R,ri}var ti,Vd;function Tn(){if(Vd)return ti;Vd=1;function e(t){return function(r){return t(r)}}return ti=e,ti}var At={exports:{}};At.exports;var Wd;function Vu(){return Wd||(Wd=1,(function(e,t){var r=Ab(),n=t&&!t.nodeType&&t,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,a=i&&r.process,s=(function(){try{var u=o&&o.require&&o.require("util").types;return u||a&&a.binding&&a.binding("util")}catch{}})();e.exports=s})(At,At.exports)),At.exports}var ni,Gd;function en(){if(Gd)return ni;Gd=1;var e=gw(),t=Tn(),r=Vu(),n=r&&r.isTypedArray,o=n?t(n):e;return ni=o,ni}var oi,Ud;function Ib(){if(Ud)return oi;Ud=1;var e=fw(),t=Qt(),r=Ke(),n=bt(),o=An(),i=en(),a=Object.prototype,s=a.hasOwnProperty;function u(c,l){var d=r(c),f=!d&&t(c),p=!d&&!f&&n(c),b=!d&&!f&&!p&&i(c),y=d||f||p||b,m=y?e(c.length,String):[],x=m.length;for(var g in c)(l||s.call(c,g))&&!(y&&(g=="length"||p&&(g=="offset"||g=="parent")||b&&(g=="buffer"||g=="byteLength"||g=="byteOffset")||o(g,x)))&&m.push(g);return m}return oi=u,oi}var ii,Hd;function On(){if(Hd)return ii;Hd=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,o=typeof n=="function"&&n.prototype||e;return r===o}return ii=t,ii}var ai,Kd;function Mb(){if(Kd)return ai;Kd=1;function e(t,r){return function(n){return t(r(n))}}return ai=e,ai}var si,Zd;function yw(){if(Zd)return si;Zd=1;var e=Mb(),t=e(Object.keys,Object);return si=t,si}var ci,Jd;function Wu(){if(Jd)return ci;Jd=1;var e=On(),t=yw(),r=Object.prototype,n=r.hasOwnProperty;function o(i){if(!e(i))return t(i);var a=[];for(var s in Object(i))n.call(i,s)&&s!="constructor"&&a.push(s);return a}return ci=o,ci}var ui,Yd;function qr(){if(Yd)return ui;Yd=1;var e=Yt(),t=zu();function r(n){return n!=null&&t(n.length)&&!e(n)}return ui=r,ui}var li,Xd;function Gr(){if(Xd)return li;Xd=1;var e=Ib(),t=Wu(),r=qr();function n(o){return r(o)?e(o):t(o)}return li=n,li}var di,Qd;function bw(){if(Qd)return di;Qd=1;var e=Xt(),t=Gr();function r(n,o){return n&&e(o,t(o),n)}return di=r,di}var fi,ef;function mw(){if(ef)return fi;ef=1;function e(t){var r=[];if(t!=null)for(var n in Object(t))r.push(n);return r}return fi=e,fi}var hi,rf;function vw(){if(rf)return hi;rf=1;var e=mr(),t=On(),r=mw(),n=Object.prototype,o=n.hasOwnProperty;function i(a){if(!e(a))return r(a);var s=t(a),u=[];for(var c in a)c=="constructor"&&(s||!o.call(a,c))||u.push(c);return u}return hi=i,hi}var pi,tf;function tt(){if(tf)return pi;tf=1;var e=Ib(),t=vw(),r=qr();function n(o){return r(o)?e(o,!0):t(o)}return pi=n,pi}var gi,nf;function xw(){if(nf)return gi;nf=1;var e=Xt(),t=tt();function r(n,o){return n&&e(o,t(o),n)}return gi=r,gi}var Tt={exports:{}};Tt.exports;var of;function qb(){return of||(of=1,(function(e,t){var r=Sr(),n=t&&!t.nodeType&&t,o=n&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===n,a=i?r.Buffer:void 0,s=a?a.allocUnsafe:void 0;function u(c,l){if(l)return c.slice();var d=c.length,f=s?s(d):new c.constructor(d);return c.copy(f),f}e.exports=u})(Tt,Tt.exports)),Tt.exports}var yi,af;function Nb(){if(af)return yi;af=1;function e(t,r){var n=-1,o=t.length;for(r||(r=Array(o));++n<o;)r[n]=t[n];return r}return yi=e,yi}var bi,sf;function $b(){if(sf)return bi;sf=1;function e(t,r){for(var n=-1,o=t==null?0:t.length,i=0,a=[];++n<o;){var s=t[n];r(s,n,t)&&(a[i++]=s)}return a}return bi=e,bi}var mi,cf;function Lb(){if(cf)return mi;cf=1;function e(){return[]}return mi=e,mi}var vi,uf;function Gu(){if(uf)return vi;uf=1;var e=$b(),t=Lb(),r=Object.prototype,n=r.propertyIsEnumerable,o=Object.getOwnPropertySymbols,i=o?function(a){return a==null?[]:(a=Object(a),e(o(a),function(s){return n.call(a,s)}))}:t;return vi=i,vi}var xi,lf;function ww(){if(lf)return xi;lf=1;var e=Xt(),t=Gu();function r(n,o){return e(n,t(n),o)}return xi=r,xi}var wi,df;function Uu(){if(df)return wi;df=1;function e(t,r){for(var n=-1,o=r.length,i=t.length;++n<o;)t[i+n]=r[n];return t}return wi=e,wi}var Ci,ff;function In(){if(ff)return Ci;ff=1;var e=Mb(),t=e(Object.getPrototypeOf,Object);return Ci=t,Ci}var _i,hf;function Fb(){if(hf)return _i;hf=1;var e=Uu(),t=In(),r=Gu(),n=Lb(),o=Object.getOwnPropertySymbols,i=o?function(a){for(var s=[];a;)e(s,r(a)),a=t(a);return s}:n;return _i=i,_i}var Si,pf;function Cw(){if(pf)return Si;pf=1;var e=Xt(),t=Fb();function r(n,o){return e(n,t(n),o)}return Si=r,Si}var ji,gf;function Bb(){if(gf)return ji;gf=1;var e=Uu(),t=Ke();function r(n,o,i){var a=o(n);return t(n)?a:e(a,i(n))}return ji=r,ji}var Ei,yf;function Db(){if(yf)return Ei;yf=1;var e=Bb(),t=Gu(),r=Gr();function n(o){return e(o,r,t)}return Ei=n,Ei}var Ri,bf;function _w(){if(bf)return Ri;bf=1;var e=Bb(),t=Fb(),r=tt();function n(o){return e(o,r,t)}return Ri=n,Ri}var ki,mf;function Sw(){if(mf)return ki;mf=1;var e=rt(),t=Sr(),r=e(t,"DataView");return ki=r,ki}var Pi,vf;function jw(){if(vf)return Pi;vf=1;var e=rt(),t=Sr(),r=e(t,"Promise");return Pi=r,Pi}var Ai,xf;function zb(){if(xf)return Ai;xf=1;var e=rt(),t=Sr(),r=e(t,"Set");return Ai=r,Ai}var Ti,wf;function Ew(){if(wf)return Ti;wf=1;var e=rt(),t=Sr(),r=e(t,"WeakMap");return Ti=r,Ti}var Oi,Cf;function mt(){if(Cf)return Oi;Cf=1;var e=Sw(),t=Fu(),r=jw(),n=zb(),o=Ew(),i=et(),a=Tb(),s="[object Map]",u="[object Object]",c="[object Promise]",l="[object Set]",d="[object WeakMap]",f="[object DataView]",p=a(e),b=a(t),y=a(r),m=a(n),x=a(o),g=i;return(e&&g(new e(new ArrayBuffer(1)))!=f||t&&g(new t)!=s||r&&g(r.resolve())!=c||n&&g(new n)!=l||o&&g(new o)!=d)&&(g=function(w){var v=i(w),_=v==u?w.constructor:void 0,C=_?a(_):"";if(C)switch(C){case p:return f;case b:return s;case y:return c;case m:return l;case x:return d}return v}),Oi=g,Oi}var Ii,_f;function Rw(){if(_f)return Ii;_f=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n){var o=n.length,i=new n.constructor(o);return o&&typeof n[0]=="string"&&t.call(n,"index")&&(i.index=n.index,i.input=n.input),i}return Ii=r,Ii}var Mi,Sf;function Vb(){if(Sf)return Mi;Sf=1;var e=Sr(),t=e.Uint8Array;return Mi=t,Mi}var qi,jf;function Hu(){if(jf)return qi;jf=1;var e=Vb();function t(r){var n=new r.constructor(r.byteLength);return new e(n).set(new e(r)),n}return qi=t,qi}var Ni,Ef;function kw(){if(Ef)return Ni;Ef=1;var e=Hu();function t(r,n){var o=n?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return Ni=t,Ni}var $i,Rf;function Pw(){if(Rf)return $i;Rf=1;var e=/\w*$/;function t(r){var n=new r.constructor(r.source,e.exec(r));return n.lastIndex=r.lastIndex,n}return $i=t,$i}var Li,kf;function Aw(){if(kf)return Li;kf=1;var e=yt(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function n(o){return r?Object(r.call(o)):{}}return Li=n,Li}var Fi,Pf;function Wb(){if(Pf)return Fi;Pf=1;var e=Hu();function t(r,n){var o=n?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return Fi=t,Fi}var Bi,Af;function Tw(){if(Af)return Bi;Af=1;var e=Hu(),t=kw(),r=Pw(),n=Aw(),o=Wb(),i="[object Boolean]",a="[object Date]",s="[object Map]",u="[object Number]",c="[object RegExp]",l="[object Set]",d="[object String]",f="[object Symbol]",p="[object ArrayBuffer]",b="[object DataView]",y="[object Float32Array]",m="[object Float64Array]",x="[object Int8Array]",g="[object Int16Array]",w="[object Int32Array]",v="[object Uint8Array]",_="[object Uint8ClampedArray]",C="[object Uint16Array]",S="[object Uint32Array]";function T(k,j,P){var R=k.constructor;switch(j){case p:return e(k);case i:case a:return new R(+k);case b:return t(k,P);case y:case m:case x:case g:case w:case v:case _:case C:case S:return o(k,P);case s:return new R;case u:case d:return new R(k);case c:return r(k);case l:return new R;case f:return n(k)}}return Bi=T,Bi}var Di,Tf;function Gb(){if(Tf)return Di;Tf=1;var e=mr(),t=Object.create,r=(function(){function n(){}return function(o){if(!e(o))return{};if(t)return t(o);n.prototype=o;var i=new n;return n.prototype=void 0,i}})();return Di=r,Di}var zi,Of;function Ub(){if(Of)return zi;Of=1;var e=Gb(),t=In(),r=On();function n(o){return typeof o.constructor=="function"&&!r(o)?e(t(o)):{}}return zi=n,zi}var Vi,If;function Ow(){if(If)return Vi;If=1;var e=mt(),t=Pr(),r="[object Map]";function n(o){return t(o)&&e(o)==r}return Vi=n,Vi}var Wi,Mf;function Iw(){if(Mf)return Wi;Mf=1;var e=Ow(),t=Tn(),r=Vu(),n=r&&r.isMap,o=n?t(n):e;return Wi=o,Wi}var Gi,qf;function Mw(){if(qf)return Gi;qf=1;var e=mt(),t=Pr(),r="[object Set]";function n(o){return t(o)&&e(o)==r}return Gi=n,Gi}var Ui,Nf;function qw(){if(Nf)return Ui;Nf=1;var e=Mw(),t=Tn(),r=Vu(),n=r&&r.isSet,o=n?t(n):e;return Ui=o,Ui}var Hi,$f;function Hb(){if($f)return Hi;$f=1;var e=Rn(),t=Du(),r=Pn(),n=bw(),o=xw(),i=qb(),a=Nb(),s=ww(),u=Cw(),c=Db(),l=_w(),d=mt(),f=Rw(),p=Tw(),b=Ub(),y=Ke(),m=bt(),x=Iw(),g=mr(),w=qw(),v=Gr(),_=tt(),C=1,S=2,T=4,k="[object Arguments]",j="[object Array]",P="[object Boolean]",R="[object Date]",I="[object Error]",O="[object Function]",M="[object GeneratorFunction]",q="[object Map]",H="[object Number]",V="[object Object]",re="[object RegExp]",ce="[object Set]",le="[object String]",be="[object Symbol]",K="[object WeakMap]",N="[object ArrayBuffer]",B="[object DataView]",W="[object Float32Array]",z="[object Float64Array]",X="[object Int8Array]",se="[object Int16Array]",Q="[object Int32Array]",G="[object Uint8Array]",J="[object Uint8ClampedArray]",te="[object Uint16Array]",de="[object Uint32Array]",fe={};fe[k]=fe[j]=fe[N]=fe[B]=fe[P]=fe[R]=fe[W]=fe[z]=fe[X]=fe[se]=fe[Q]=fe[q]=fe[H]=fe[V]=fe[re]=fe[ce]=fe[le]=fe[be]=fe[G]=fe[J]=fe[te]=fe[de]=!0,fe[I]=fe[O]=fe[K]=!1;function Ee(ge,We,me,Te,er,De){var Ne,He=We&C,rr=We&S,ze=We&T;if(me&&(Ne=er?me(ge,Te,er,De):me(ge)),Ne!==void 0)return Ne;if(!g(ge))return ge;var xr=y(ge);if(xr){if(Ne=f(ge),!He)return a(ge,Ne)}else{var Ze=d(ge),pr=Ze==O||Ze==M;if(m(ge))return i(ge,He);if(Ze==V||Ze==k||pr&&!er){if(Ne=rr||pr?{}:b(ge),!He)return rr?u(ge,o(Ne,ge)):s(ge,n(Ne,ge))}else{if(!fe[Ze])return er?ge:{};Ne=p(ge,Ze,He)}}De||(De=new e);var dr=De.get(ge);if(dr)return dr;De.set(ge,Ne),w(ge)?ge.forEach(function(or){Ne.add(Ee(or,We,me,or,ge,De))}):x(ge)&&ge.forEach(function(or,ar){Ne.set(ar,Ee(or,We,me,ar,ge,De))});var jr=ze?rr?l:c:rr?_:v,we=xr?void 0:jr(ge);return t(we||ge,function(or,ar){we&&(ar=or,or=ge[ar]),r(Ne,ar,Ee(or,We,me,ar,ge,De))}),Ne}return Hi=Ee,Hi}var Ki,Lf;function Nw(){if(Lf)return Ki;Lf=1;var e=Hb(),t=4;function r(n){return e(n,t)}return Ki=r,Ki}var Zi,Ff;function Ku(){if(Ff)return Zi;Ff=1;function e(t){return function(){return t}}return Zi=e,Zi}var Ji,Bf;function $w(){if(Bf)return Ji;Bf=1;function e(t){return function(r,n,o){for(var i=-1,a=Object(r),s=o(r),u=s.length;u--;){var c=s[t?u:++i];if(n(a[c],c,a)===!1)break}return r}}return Ji=e,Ji}var Yi,Df;function Zu(){if(Df)return Yi;Df=1;var e=$w(),t=e();return Yi=t,Yi}var Xi,zf;function Ju(){if(zf)return Xi;zf=1;var e=Zu(),t=Gr();function r(n,o){return n&&e(n,o,t)}return Xi=r,Xi}var Qi,Vf;function Lw(){if(Vf)return Qi;Vf=1;var e=qr();function t(r,n){return function(o,i){if(o==null)return o;if(!e(o))return r(o,i);for(var a=o.length,s=n?a:-1,u=Object(o);(n?s--:++s<a)&&i(u[s],s,u)!==!1;);return o}}return Qi=t,Qi}var ea,Wf;function Mn(){if(Wf)return ea;Wf=1;var e=Ju(),t=Lw(),r=t(e);return ea=r,ea}var ra,Gf;function nt(){if(Gf)return ra;Gf=1;function e(t){return t}return ra=e,ra}var ta,Uf;function Kb(){if(Uf)return ta;Uf=1;var e=nt();function t(r){return typeof r=="function"?r:e}return ta=t,ta}var na,Hf;function Zb(){if(Hf)return na;Hf=1;var e=Du(),t=Mn(),r=Kb(),n=Ke();function o(i,a){var s=n(i)?e:t;return s(i,r(a))}return na=o,na}var oa,Kf;function Jb(){return Kf||(Kf=1,oa=Zb()),oa}var ia,Zf;function Fw(){if(Zf)return ia;Zf=1;var e=Mn();function t(r,n){var o=[];return e(r,function(i,a,s){n(i,a,s)&&o.push(i)}),o}return ia=t,ia}var aa,Jf;function Bw(){if(Jf)return aa;Jf=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return aa=t,aa}var sa,Yf;function Dw(){if(Yf)return sa;Yf=1;function e(t){return this.__data__.has(t)}return sa=e,sa}var ca,Xf;function Yb(){if(Xf)return ca;Xf=1;var e=Bu(),t=Bw(),r=Dw();function n(o){var i=-1,a=o==null?0:o.length;for(this.__data__=new e;++i<a;)this.add(o[i])}return n.prototype.add=n.prototype.push=t,n.prototype.has=r,ca=n,ca}var ua,Qf;function zw(){if(Qf)return ua;Qf=1;function e(t,r){for(var n=-1,o=t==null?0:t.length;++n<o;)if(r(t[n],n,t))return!0;return!1}return ua=e,ua}var la,eh;function Xb(){if(eh)return la;eh=1;function e(t,r){return t.has(r)}return la=e,la}var da,rh;function Qb(){if(rh)return da;rh=1;var e=Yb(),t=zw(),r=Xb(),n=1,o=2;function i(a,s,u,c,l,d){var f=u&n,p=a.length,b=s.length;if(p!=b&&!(f&&b>p))return!1;var y=d.get(a),m=d.get(s);if(y&&m)return y==s&&m==a;var x=-1,g=!0,w=u&o?new e:void 0;for(d.set(a,s),d.set(s,a);++x<p;){var v=a[x],_=s[x];if(c)var C=f?c(_,v,x,s,a,d):c(v,_,x,a,s,d);if(C!==void 0){if(C)continue;g=!1;break}if(w){if(!t(s,function(S,T){if(!r(w,T)&&(v===S||l(v,S,u,c,d)))return w.push(T)})){g=!1;break}}else if(!(v===_||l(v,_,u,c,d))){g=!1;break}}return d.delete(a),d.delete(s),g}return da=i,da}var fa,th;function Vw(){if(th)return fa;th=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(o,i){n[++r]=[i,o]}),n}return fa=e,fa}var ha,nh;function Yu(){if(nh)return ha;nh=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(o){n[++r]=o}),n}return ha=e,ha}var pa,oh;function Ww(){if(oh)return pa;oh=1;var e=yt(),t=Vb(),r=gt(),n=Qb(),o=Vw(),i=Yu(),a=1,s=2,u="[object Boolean]",c="[object Date]",l="[object Error]",d="[object Map]",f="[object Number]",p="[object RegExp]",b="[object Set]",y="[object String]",m="[object Symbol]",x="[object ArrayBuffer]",g="[object DataView]",w=e?e.prototype:void 0,v=w?w.valueOf:void 0;function _(C,S,T,k,j,P,R){switch(T){case g:if(C.byteLength!=S.byteLength||C.byteOffset!=S.byteOffset)return!1;C=C.buffer,S=S.buffer;case x:return!(C.byteLength!=S.byteLength||!P(new t(C),new t(S)));case u:case c:case f:return r(+C,+S);case l:return C.name==S.name&&C.message==S.message;case p:case y:return C==S+"";case d:var I=o;case b:var O=k&a;if(I||(I=i),C.size!=S.size&&!O)return!1;var M=R.get(C);if(M)return M==S;k|=s,R.set(C,S);var q=n(I(C),I(S),k,j,P,R);return R.delete(C),q;case m:if(v)return v.call(C)==v.call(S)}return!1}return pa=_,pa}var ga,ih;function Gw(){if(ih)return ga;ih=1;var e=Db(),t=1,r=Object.prototype,n=r.hasOwnProperty;function o(i,a,s,u,c,l){var d=s&t,f=e(i),p=f.length,b=e(a),y=b.length;if(p!=y&&!d)return!1;for(var m=p;m--;){var x=f[m];if(!(d?x in a:n.call(a,x)))return!1}var g=l.get(i),w=l.get(a);if(g&&w)return g==a&&w==i;var v=!0;l.set(i,a),l.set(a,i);for(var _=d;++m<p;){x=f[m];var C=i[x],S=a[x];if(u)var T=d?u(S,C,x,a,i,l):u(C,S,x,i,a,l);if(!(T===void 0?C===S||c(C,S,s,u,l):T)){v=!1;break}_||(_=x=="constructor")}if(v&&!_){var k=i.constructor,j=a.constructor;k!=j&&"constructor"in i&&"constructor"in a&&!(typeof k=="function"&&k instanceof k&&typeof j=="function"&&j instanceof j)&&(v=!1)}return l.delete(i),l.delete(a),v}return ga=o,ga}var ya,ah;function Uw(){if(ah)return ya;ah=1;var e=Rn(),t=Qb(),r=Ww(),n=Gw(),o=mt(),i=Ke(),a=bt(),s=en(),u=1,c="[object Arguments]",l="[object Array]",d="[object Object]",f=Object.prototype,p=f.hasOwnProperty;function b(y,m,x,g,w,v){var _=i(y),C=i(m),S=_?l:o(y),T=C?l:o(m);S=S==c?d:S,T=T==c?d:T;var k=S==d,j=T==d,P=S==T;if(P&&a(y)){if(!a(m))return!1;_=!0,k=!1}if(P&&!k)return v||(v=new e),_||s(y)?t(y,m,x,g,w,v):r(y,m,S,x,g,w,v);if(!(x&u)){var R=k&&p.call(y,"__wrapped__"),I=j&&p.call(m,"__wrapped__");if(R||I){var O=R?y.value():y,M=I?m.value():m;return v||(v=new e),w(O,M,x,g,v)}}return P?(v||(v=new e),n(y,m,x,g,w,v)):!1}return ya=b,ya}var ba,sh;function em(){if(sh)return ba;sh=1;var e=Uw(),t=Pr();function r(n,o,i,a,s){return n===o?!0:n==null||o==null||!t(n)&&!t(o)?n!==n&&o!==o:e(n,o,i,a,r,s)}return ba=r,ba}var ma,ch;function Hw(){if(ch)return ma;ch=1;var e=Rn(),t=em(),r=1,n=2;function o(i,a,s,u){var c=s.length,l=c,d=!u;if(i==null)return!l;for(i=Object(i);c--;){var f=s[c];if(d&&f[2]?f[1]!==i[f[0]]:!(f[0]in i))return!1}for(;++c<l;){f=s[c];var p=f[0],b=i[p],y=f[1];if(d&&f[2]){if(b===void 0&&!(p in i))return!1}else{var m=new e;if(u)var x=u(b,y,p,i,a,m);if(!(x===void 0?t(y,b,r|n,u,m):x))return!1}}return!0}return ma=o,ma}var va,uh;function rm(){if(uh)return va;uh=1;var e=mr();function t(r){return r===r&&!e(r)}return va=t,va}var xa,lh;function Kw(){if(lh)return xa;lh=1;var e=rm(),t=Gr();function r(n){for(var o=t(n),i=o.length;i--;){var a=o[i],s=n[a];o[i]=[a,s,e(s)]}return o}return xa=r,xa}var wa,dh;function tm(){if(dh)return wa;dh=1;function e(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}return wa=e,wa}var Ca,fh;function Zw(){if(fh)return Ca;fh=1;var e=Hw(),t=Kw(),r=tm();function n(o){var i=t(o);return i.length==1&&i[0][2]?r(i[0][0],i[0][1]):function(a){return a===o||e(a,o,i)}}return Ca=n,Ca}var _a,hh;function vt(){if(hh)return _a;hh=1;var e=et(),t=Pr(),r="[object Symbol]";function n(o){return typeof o=="symbol"||t(o)&&e(o)==r}return _a=n,_a}var Sa,ph;function Xu(){if(ph)return Sa;ph=1;var e=Ke(),t=vt(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function o(i,a){if(e(i))return!1;var s=typeof i;return s=="number"||s=="symbol"||s=="boolean"||i==null||t(i)?!0:n.test(i)||!r.test(i)||a!=null&&i in Object(a)}return Sa=o,Sa}var ja,gh;function Jw(){if(gh)return ja;gh=1;var e=Bu(),t="Expected a function";function r(n,o){if(typeof n!="function"||o!=null&&typeof o!="function")throw new TypeError(t);var i=function(){var a=arguments,s=o?o.apply(this,a):a[0],u=i.cache;if(u.has(s))return u.get(s);var c=n.apply(this,a);return i.cache=u.set(s,c)||u,c};return i.cache=new(r.Cache||e),i}return r.Cache=e,ja=r,ja}var Ea,yh;function Yw(){if(yh)return Ea;yh=1;var e=Jw(),t=500;function r(n){var o=e(n,function(a){return i.size===t&&i.clear(),a}),i=o.cache;return o}return Ea=r,Ea}var Ra,bh;function Xw(){if(bh)return Ra;bh=1;var e=Yw(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(o){var i=[];return o.charCodeAt(0)===46&&i.push(""),o.replace(t,function(a,s,u,c){i.push(u?c.replace(r,"$1"):s||a)}),i});return Ra=n,Ra}var ka,mh;function qn(){if(mh)return ka;mh=1;function e(t,r){for(var n=-1,o=t==null?0:t.length,i=Array(o);++n<o;)i[n]=r(t[n],n,t);return i}return ka=e,ka}var Pa,vh;function Qw(){if(vh)return Pa;vh=1;var e=yt(),t=qn(),r=Ke(),n=vt(),o=e?e.prototype:void 0,i=o?o.toString:void 0;function a(s){if(typeof s=="string")return s;if(r(s))return t(s,a)+"";if(n(s))return i?i.call(s):"";var u=s+"";return u=="0"&&1/s==-1/0?"-0":u}return Pa=a,Pa}var Aa,xh;function nm(){if(xh)return Aa;xh=1;var e=Qw();function t(r){return r==null?"":e(r)}return Aa=t,Aa}var Ta,wh;function Nn(){if(wh)return Ta;wh=1;var e=Ke(),t=Xu(),r=Xw(),n=nm();function o(i,a){return e(i)?i:t(i,a)?[i]:r(n(i))}return Ta=o,Ta}var Oa,Ch;function rn(){if(Ch)return Oa;Ch=1;var e=vt();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return Oa=t,Oa}var Ia,_h;function $n(){if(_h)return Ia;_h=1;var e=Nn(),t=rn();function r(n,o){o=e(o,n);for(var i=0,a=o.length;n!=null&&i<a;)n=n[t(o[i++])];return i&&i==a?n:void 0}return Ia=r,Ia}var Ma,Sh;function e1(){if(Sh)return Ma;Sh=1;var e=$n();function t(r,n,o){var i=r==null?void 0:e(r,n);return i===void 0?o:i}return Ma=t,Ma}var qa,jh;function r1(){if(jh)return qa;jh=1;function e(t,r){return t!=null&&r in Object(t)}return qa=e,qa}var Na,Eh;function om(){if(Eh)return Na;Eh=1;var e=Nn(),t=Qt(),r=Ke(),n=An(),o=zu(),i=rn();function a(s,u,c){u=e(u,s);for(var l=-1,d=u.length,f=!1;++l<d;){var p=i(u[l]);if(!(f=s!=null&&c(s,p)))break;s=s[p]}return f||++l!=d?f:(d=s==null?0:s.length,!!d&&o(d)&&n(p,d)&&(r(s)||t(s)))}return Na=a,Na}var $a,Rh;function im(){if(Rh)return $a;Rh=1;var e=r1(),t=om();function r(n,o){return n!=null&&t(n,o,e)}return $a=r,$a}var La,kh;function t1(){if(kh)return La;kh=1;var e=em(),t=e1(),r=im(),n=Xu(),o=rm(),i=tm(),a=rn(),s=1,u=2;function c(l,d){return n(l)&&o(d)?i(a(l),d):function(f){var p=t(f,l);return p===void 0&&p===d?r(f,l):e(d,p,s|u)}}return La=c,La}var Fa,Ph;function am(){if(Ph)return Fa;Ph=1;function e(t){return function(r){return r==null?void 0:r[t]}}return Fa=e,Fa}var Ba,Ah;function n1(){if(Ah)return Ba;Ah=1;var e=$n();function t(r){return function(n){return e(n,r)}}return Ba=t,Ba}var Da,Th;function o1(){if(Th)return Da;Th=1;var e=am(),t=n1(),r=Xu(),n=rn();function o(i){return r(i)?e(n(i)):t(i)}return Da=o,Da}var za,Oh;function Nr(){if(Oh)return za;Oh=1;var e=Zw(),t=t1(),r=nt(),n=Ke(),o=o1();function i(a){return typeof a=="function"?a:a==null?r:typeof a=="object"?n(a)?t(a[0],a[1]):e(a):o(a)}return za=i,za}var Va,Ih;function sm(){if(Ih)return Va;Ih=1;var e=$b(),t=Fw(),r=Nr(),n=Ke();function o(i,a){var s=n(i)?e:t;return s(i,r(a,3))}return Va=o,Va}var Wa,Mh;function i1(){if(Mh)return Wa;Mh=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n,o){return n!=null&&t.call(n,o)}return Wa=r,Wa}var Ga,qh;function cm(){if(qh)return Ga;qh=1;var e=i1(),t=om();function r(n,o){return n!=null&&t(n,o,e)}return Ga=r,Ga}var Ua,Nh;function a1(){if(Nh)return Ua;Nh=1;var e=Wu(),t=mt(),r=Qt(),n=Ke(),o=qr(),i=bt(),a=On(),s=en(),u="[object Map]",c="[object Set]",l=Object.prototype,d=l.hasOwnProperty;function f(p){if(p==null)return!0;if(o(p)&&(n(p)||typeof p=="string"||typeof p.splice=="function"||i(p)||s(p)||r(p)))return!p.length;var b=t(p);if(b==u||b==c)return!p.size;if(a(p))return!e(p).length;for(var y in p)if(d.call(p,y))return!1;return!0}return Ua=f,Ua}var Ha,$h;function um(){if($h)return Ha;$h=1;function e(t){return t===void 0}return Ha=e,Ha}var Ka,Lh;function lm(){if(Lh)return Ka;Lh=1;var e=Mn(),t=qr();function r(n,o){var i=-1,a=t(n)?Array(n.length):[];return e(n,function(s,u,c){a[++i]=o(s,u,c)}),a}return Ka=r,Ka}var Za,Fh;function dm(){if(Fh)return Za;Fh=1;var e=qn(),t=Nr(),r=lm(),n=Ke();function o(i,a){var s=n(i)?e:r;return s(i,t(a,3))}return Za=o,Za}var Ja,Bh;function s1(){if(Bh)return Ja;Bh=1;function e(t,r,n,o){var i=-1,a=t==null?0:t.length;for(o&&a&&(n=t[++i]);++i<a;)n=r(n,t[i],i,t);return n}return Ja=e,Ja}var Ya,Dh;function c1(){if(Dh)return Ya;Dh=1;function e(t,r,n,o,i){return i(t,function(a,s,u){n=o?(o=!1,a):r(n,a,s,u)}),n}return Ya=e,Ya}var Xa,zh;function fm(){if(zh)return Xa;zh=1;var e=s1(),t=Mn(),r=Nr(),n=c1(),o=Ke();function i(a,s,u){var c=o(a)?e:n,l=arguments.length<3;return c(a,r(s,4),u,l,t)}return Xa=i,Xa}var Qa,Vh;function u1(){if(Vh)return Qa;Vh=1;var e=et(),t=Ke(),r=Pr(),n="[object String]";function o(i){return typeof i=="string"||!t(i)&&r(i)&&e(i)==n}return Qa=o,Qa}var es,Wh;function l1(){if(Wh)return es;Wh=1;var e=am(),t=e("length");return es=t,es}var rs,Gh;function d1(){if(Gh)return rs;Gh=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=t+r+n,i="\\ufe0e\\ufe0f",a="\\u200d",s=RegExp("["+a+e+o+i+"]");function u(c){return s.test(c)}return rs=u,rs}var ts,Uh;function f1(){if(Uh)return ts;Uh=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",o=t+r+n,i="\\ufe0e\\ufe0f",a="["+e+"]",s="["+o+"]",u="\\ud83c[\\udffb-\\udfff]",c="(?:"+s+"|"+u+")",l="[^"+e+"]",d="(?:\\ud83c[\\udde6-\\uddff]){2}",f="[\\ud800-\\udbff][\\udc00-\\udfff]",p="\\u200d",b=c+"?",y="["+i+"]?",m="(?:"+p+"(?:"+[l,d,f].join("|")+")"+y+b+")*",x=y+b+m,g="(?:"+[l+s+"?",s,d,f,a].join("|")+")",w=RegExp(u+"(?="+u+")|"+g+x,"g");function v(_){for(var C=w.lastIndex=0;w.test(_);)++C;return C}return ts=v,ts}var ns,Hh;function h1(){if(Hh)return ns;Hh=1;var e=l1(),t=d1(),r=f1();function n(o){return t(o)?r(o):e(o)}return ns=n,ns}var os,Kh;function p1(){if(Kh)return os;Kh=1;var e=Wu(),t=mt(),r=qr(),n=u1(),o=h1(),i="[object Map]",a="[object Set]";function s(u){if(u==null)return 0;if(r(u))return n(u)?o(u):u.length;var c=t(u);return c==i||c==a?u.size:e(u).length}return os=s,os}var is,Zh;function g1(){if(Zh)return is;Zh=1;var e=Du(),t=Gb(),r=Ju(),n=Nr(),o=In(),i=Ke(),a=bt(),s=Yt(),u=mr(),c=en();function l(d,f,p){var b=i(d),y=b||a(d)||c(d);if(f=n(f,4),p==null){var m=d&&d.constructor;y?p=b?new m:[]:u(d)?p=s(m)?t(o(d)):{}:p={}}return(y?e:r)(d,function(x,g,w){return f(p,x,g,w)}),p}return is=l,is}var as,Jh;function y1(){if(Jh)return as;Jh=1;var e=yt(),t=Qt(),r=Ke(),n=e?e.isConcatSpreadable:void 0;function o(i){return r(i)||t(i)||!!(n&&i&&i[n])}return as=o,as}var ss,Yh;function Qu(){if(Yh)return ss;Yh=1;var e=Uu(),t=y1();function r(n,o,i,a,s){var u=-1,c=n.length;for(i||(i=t),s||(s=[]);++u<c;){var l=n[u];o>0&&i(l)?o>1?r(l,o-1,i,a,s):e(s,l):a||(s[s.length]=l)}return s}return ss=r,ss}var cs,Xh;function b1(){if(Xh)return cs;Xh=1;function e(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}return cs=e,cs}var us,Qh;function hm(){if(Qh)return us;Qh=1;var e=b1(),t=Math.max;function r(n,o,i){return o=t(o===void 0?n.length-1:o,0),function(){for(var a=arguments,s=-1,u=t(a.length-o,0),c=Array(u);++s<u;)c[s]=a[o+s];s=-1;for(var l=Array(o+1);++s<o;)l[s]=a[s];return l[o]=i(c),e(n,this,l)}}return us=r,us}var ls,ep;function m1(){if(ep)return ls;ep=1;var e=Ku(),t=Ob(),r=nt(),n=t?function(o,i){return t(o,"toString",{configurable:!0,enumerable:!1,value:e(i),writable:!0})}:r;return ls=n,ls}var ds,rp;function v1(){if(rp)return ds;rp=1;var e=800,t=16,r=Date.now;function n(o){var i=0,a=0;return function(){var s=r(),u=t-(s-a);if(a=s,u>0){if(++i>=e)return arguments[0]}else i=0;return o.apply(void 0,arguments)}}return ds=n,ds}var fs,tp;function pm(){if(tp)return fs;tp=1;var e=m1(),t=v1(),r=t(e);return fs=r,fs}var hs,np;function Ln(){if(np)return hs;np=1;var e=nt(),t=hm(),r=pm();function n(o,i){return r(t(o,i,e),o+"")}return hs=n,hs}var ps,op;function gm(){if(op)return ps;op=1;function e(t,r,n,o){for(var i=t.length,a=n+(o?1:-1);o?a--:++a<i;)if(r(t[a],a,t))return a;return-1}return ps=e,ps}var gs,ip;function x1(){if(ip)return gs;ip=1;function e(t){return t!==t}return gs=e,gs}var ys,ap;function w1(){if(ap)return ys;ap=1;function e(t,r,n){for(var o=n-1,i=t.length;++o<i;)if(t[o]===r)return o;return-1}return ys=e,ys}var bs,sp;function C1(){if(sp)return bs;sp=1;var e=gm(),t=x1(),r=w1();function n(o,i,a){return i===i?r(o,i,a):e(o,t,a)}return bs=n,bs}var ms,cp;function _1(){if(cp)return ms;cp=1;var e=C1();function t(r,n){var o=r==null?0:r.length;return!!o&&e(r,n,0)>-1}return ms=t,ms}var vs,up;function S1(){if(up)return vs;up=1;function e(t,r,n){for(var o=-1,i=t==null?0:t.length;++o<i;)if(n(r,t[o]))return!0;return!1}return vs=e,vs}var xs,lp;function j1(){if(lp)return xs;lp=1;function e(){}return xs=e,xs}var ws,dp;function E1(){if(dp)return ws;dp=1;var e=zb(),t=j1(),r=Yu(),n=1/0,o=e&&1/r(new e([,-0]))[1]==n?function(i){return new e(i)}:t;return ws=o,ws}var Cs,fp;function R1(){if(fp)return Cs;fp=1;var e=Yb(),t=_1(),r=S1(),n=Xb(),o=E1(),i=Yu(),a=200;function s(u,c,l){var d=-1,f=t,p=u.length,b=!0,y=[],m=y;if(l)b=!1,f=r;else if(p>=a){var x=c?null:o(u);if(x)return i(x);b=!1,f=n,m=new e}else m=c?[]:y;e:for(;++d<p;){var g=u[d],w=c?c(g):g;if(g=l||g!==0?g:0,b&&w===w){for(var v=m.length;v--;)if(m[v]===w)continue e;c&&m.push(w),y.push(g)}else f(m,w,l)||(m!==y&&m.push(w),y.push(g))}return y}return Cs=s,Cs}var _s,hp;function ym(){if(hp)return _s;hp=1;var e=qr(),t=Pr();function r(n){return t(n)&&e(n)}return _s=r,_s}var Ss,pp;function k1(){if(pp)return Ss;pp=1;var e=Qu(),t=Ln(),r=R1(),n=ym(),o=t(function(i){return r(e(i,1,n,!0))});return Ss=o,Ss}var js,gp;function P1(){if(gp)return js;gp=1;var e=qn();function t(r,n){return e(n,function(o){return r[o]})}return js=t,js}var Es,yp;function bm(){if(yp)return Es;yp=1;var e=P1(),t=Gr();function r(n){return n==null?[]:e(n,t(n))}return Es=r,Es}var Rs,bp;function vr(){if(bp)return Rs;bp=1;var e;if(typeof Lu=="function")try{e={clone:Nw(),constant:Ku(),each:Jb(),filter:sm(),has:cm(),isArray:Ke(),isEmpty:a1(),isFunction:Yt(),isUndefined:um(),keys:Gr(),map:dm(),reduce:fm(),size:p1(),transform:g1(),union:k1(),values:bm()}}catch{}return e||(e=window._),Rs=e,Rs}var ks,mp;function el(){if(mp)return ks;mp=1;var e=vr();ks=o;var t="\0",r="\0",n="";function o(l){this._isDirected=e.has(l,"directed")?l.directed:!0,this._isMultigraph=e.has(l,"multigraph")?l.multigraph:!1,this._isCompound=e.has(l,"compound")?l.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(l){return this._label=l,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultNodeLabelFn=l,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var l=this;return e.filter(this.nodes(),function(d){return e.isEmpty(l._in[d])})},o.prototype.sinks=function(){var l=this;return e.filter(this.nodes(),function(d){return e.isEmpty(l._out[d])})},o.prototype.setNodes=function(l,d){var f=arguments,p=this;return e.each(l,function(b){f.length>1?p.setNode(b,d):p.setNode(b)}),this},o.prototype.setNode=function(l,d){return e.has(this._nodes,l)?(arguments.length>1&&(this._nodes[l]=d),this):(this._nodes[l]=arguments.length>1?d:this._defaultNodeLabelFn(l),this._isCompound&&(this._parent[l]=r,this._children[l]={},this._children[r][l]=!0),this._in[l]={},this._preds[l]={},this._out[l]={},this._sucs[l]={},++this._nodeCount,this)},o.prototype.node=function(l){return this._nodes[l]},o.prototype.hasNode=function(l){return e.has(this._nodes,l)},o.prototype.removeNode=function(l){var d=this;if(e.has(this._nodes,l)){var f=function(p){d.removeEdge(d._edgeObjs[p])};delete this._nodes[l],this._isCompound&&(this._removeFromParentsChildList(l),delete this._parent[l],e.each(this.children(l),function(p){d.setParent(p)}),delete this._children[l]),e.each(e.keys(this._in[l]),f),delete this._in[l],delete this._preds[l],e.each(e.keys(this._out[l]),f),delete this._out[l],delete this._sucs[l],--this._nodeCount}return this},o.prototype.setParent=function(l,d){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(d))d=r;else{d+="";for(var f=d;!e.isUndefined(f);f=this.parent(f))if(f===l)throw new Error("Setting "+d+" as parent of "+l+" would create a cycle");this.setNode(d)}return this.setNode(l),this._removeFromParentsChildList(l),this._parent[l]=d,this._children[d][l]=!0,this},o.prototype._removeFromParentsChildList=function(l){delete this._children[this._parent[l]][l]},o.prototype.parent=function(l){if(this._isCompound){var d=this._parent[l];if(d!==r)return d}},o.prototype.children=function(l){if(e.isUndefined(l)&&(l=r),this._isCompound){var d=this._children[l];if(d)return e.keys(d)}else{if(l===r)return this.nodes();if(this.hasNode(l))return[]}},o.prototype.predecessors=function(l){var d=this._preds[l];if(d)return e.keys(d)},o.prototype.successors=function(l){var d=this._sucs[l];if(d)return e.keys(d)},o.prototype.neighbors=function(l){var d=this.predecessors(l);if(d)return e.union(d,this.successors(l))},o.prototype.isLeaf=function(l){var d;return this.isDirected()?d=this.successors(l):d=this.neighbors(l),d.length===0},o.prototype.filterNodes=function(l){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var f=this;e.each(this._nodes,function(y,m){l(m)&&d.setNode(m,y)}),e.each(this._edgeObjs,function(y){d.hasNode(y.v)&&d.hasNode(y.w)&&d.setEdge(y,f.edge(y))});var p={};function b(y){var m=f.parent(y);return m===void 0||d.hasNode(m)?(p[y]=m,m):m in p?p[m]:b(m)}return this._isCompound&&e.each(d.nodes(),function(y){d.setParent(y,b(y))}),d},o.prototype.setDefaultEdgeLabel=function(l){return e.isFunction(l)||(l=e.constant(l)),this._defaultEdgeLabelFn=l,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(l,d){var f=this,p=arguments;return e.reduce(l,function(b,y){return p.length>1?f.setEdge(b,y,d):f.setEdge(b,y),y}),this},o.prototype.setEdge=function(){var l,d,f,p,b=!1,y=arguments[0];typeof y=="object"&&y!==null&&"v"in y?(l=y.v,d=y.w,f=y.name,arguments.length===2&&(p=arguments[1],b=!0)):(l=y,d=arguments[1],f=arguments[3],arguments.length>2&&(p=arguments[2],b=!0)),l=""+l,d=""+d,e.isUndefined(f)||(f=""+f);var m=s(this._isDirected,l,d,f);if(e.has(this._edgeLabels,m))return b&&(this._edgeLabels[m]=p),this;if(!e.isUndefined(f)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(l),this.setNode(d),this._edgeLabels[m]=b?p:this._defaultEdgeLabelFn(l,d,f);var x=u(this._isDirected,l,d,f);return l=x.v,d=x.w,Object.freeze(x),this._edgeObjs[m]=x,i(this._preds[d],l),i(this._sucs[l],d),this._in[d][m]=x,this._out[l][m]=x,this._edgeCount++,this},o.prototype.edge=function(l,d,f){var p=arguments.length===1?c(this._isDirected,arguments[0]):s(this._isDirected,l,d,f);return this._edgeLabels[p]},o.prototype.hasEdge=function(l,d,f){var p=arguments.length===1?c(this._isDirected,arguments[0]):s(this._isDirected,l,d,f);return e.has(this._edgeLabels,p)},o.prototype.removeEdge=function(l,d,f){var p=arguments.length===1?c(this._isDirected,arguments[0]):s(this._isDirected,l,d,f),b=this._edgeObjs[p];return b&&(l=b.v,d=b.w,delete this._edgeLabels[p],delete this._edgeObjs[p],a(this._preds[d],l),a(this._sucs[l],d),delete this._in[d][p],delete this._out[l][p],this._edgeCount--),this},o.prototype.inEdges=function(l,d){var f=this._in[l];if(f){var p=e.values(f);return d?e.filter(p,function(b){return b.v===d}):p}},o.prototype.outEdges=function(l,d){var f=this._out[l];if(f){var p=e.values(f);return d?e.filter(p,function(b){return b.w===d}):p}},o.prototype.nodeEdges=function(l,d){var f=this.inEdges(l,d);if(f)return f.concat(this.outEdges(l,d))};function i(l,d){l[d]?l[d]++:l[d]=1}function a(l,d){--l[d]||delete l[d]}function s(l,d,f,p){var b=""+d,y=""+f;if(!l&&b>y){var m=b;b=y,y=m}return b+n+y+n+(e.isUndefined(p)?t:p)}function u(l,d,f,p){var b=""+d,y=""+f;if(!l&&b>y){var m=b;b=y,y=m}var x={v:b,w:y};return p&&(x.name=p),x}function c(l,d){return s(l,d.v,d.w,d.name)}return ks}var Ps,vp;function A1(){return vp||(vp=1,Ps="2.1.8"),Ps}var As,xp;function T1(){return xp||(xp=1,As={Graph:el(),version:A1()}),As}var Ts,wp;function O1(){if(wp)return Ts;wp=1;var e=vr(),t=el();Ts={write:r,read:i};function r(a){var s={options:{directed:a.isDirected(),multigraph:a.isMultigraph(),compound:a.isCompound()},nodes:n(a),edges:o(a)};return e.isUndefined(a.graph())||(s.value=e.clone(a.graph())),s}function n(a){return e.map(a.nodes(),function(s){var u=a.node(s),c=a.parent(s),l={v:s};return e.isUndefined(u)||(l.value=u),e.isUndefined(c)||(l.parent=c),l})}function o(a){return e.map(a.edges(),function(s){var u=a.edge(s),c={v:s.v,w:s.w};return e.isUndefined(s.name)||(c.name=s.name),e.isUndefined(u)||(c.value=u),c})}function i(a){var s=new t(a.options).setGraph(a.value);return e.each(a.nodes,function(u){s.setNode(u.v,u.value),u.parent&&s.setParent(u.v,u.parent)}),e.each(a.edges,function(u){s.setEdge({v:u.v,w:u.w,name:u.name},u.value)}),s}return Ts}var Os,Cp;function I1(){if(Cp)return Os;Cp=1;var e=vr();Os=t;function t(r){var n={},o=[],i;function a(s){e.has(n,s)||(n[s]=!0,i.push(s),e.each(r.successors(s),a),e.each(r.predecessors(s),a))}return e.each(r.nodes(),function(s){i=[],a(s),i.length&&o.push(i)}),o}return Os}var Is,_p;function mm(){if(_p)return Is;_p=1;var e=vr();Is=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(r){return r.key})},t.prototype.has=function(r){return e.has(this._keyIndices,r)},t.prototype.priority=function(r){var n=this._keyIndices[r];if(n!==void 0)return this._arr[n].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(r,n){var o=this._keyIndices;if(r=String(r),!e.has(o,r)){var i=this._arr,a=i.length;return o[r]=a,i.push({key:r,priority:n}),this._decrease(a),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},t.prototype.decrease=function(r,n){var o=this._keyIndices[r];if(n>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[o].priority+" New: "+n);this._arr[o].priority=n,this._decrease(o)},t.prototype._heapify=function(r){var n=this._arr,o=2*r,i=o+1,a=r;o<n.length&&(a=n[o].priority<n[a].priority?o:a,i<n.length&&(a=n[i].priority<n[a].priority?i:a),a!==r&&(this._swap(r,a),this._heapify(a)))},t.prototype._decrease=function(r){for(var n=this._arr,o=n[r].priority,i;r!==0&&(i=r>>1,!(n[i].priority<o));)this._swap(r,i),r=i},t.prototype._swap=function(r,n){var o=this._arr,i=this._keyIndices,a=o[r],s=o[n];o[r]=s,o[n]=a,i[s.key]=r,i[a.key]=n},Is}var Ms,Sp;function vm(){if(Sp)return Ms;Sp=1;var e=vr(),t=mm();Ms=n;var r=e.constant(1);function n(i,a,s,u){return o(i,String(a),s||r,u||function(c){return i.outEdges(c)})}function o(i,a,s,u){var c={},l=new t,d,f,p=function(b){var y=b.v!==d?b.v:b.w,m=c[y],x=s(b),g=f.distance+x;if(x<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+b+" Weight: "+x);g<m.distance&&(m.distance=g,m.predecessor=d,l.decrease(y,g))};for(i.nodes().forEach(function(b){var y=b===a?0:Number.POSITIVE_INFINITY;c[b]={distance:y},l.add(b,y)});l.size()>0&&(d=l.removeMin(),f=c[d],f.distance!==Number.POSITIVE_INFINITY);)u(d).forEach(p);return c}return Ms}var qs,jp;function M1(){if(jp)return qs;jp=1;var e=vm(),t=vr();qs=r;function r(n,o,i){return t.transform(n.nodes(),function(a,s){a[s]=e(n,s,o,i)},{})}return qs}var Ns,Ep;function xm(){if(Ep)return Ns;Ep=1;var e=vr();Ns=t;function t(r){var n=0,o=[],i={},a=[];function s(u){var c=i[u]={onStack:!0,lowlink:n,index:n++};if(o.push(u),r.successors(u).forEach(function(f){e.has(i,f)?i[f].onStack&&(c.lowlink=Math.min(c.lowlink,i[f].index)):(s(f),c.lowlink=Math.min(c.lowlink,i[f].lowlink))}),c.lowlink===c.index){var l=[],d;do d=o.pop(),i[d].onStack=!1,l.push(d);while(u!==d);a.push(l)}}return r.nodes().forEach(function(u){e.has(i,u)||s(u)}),a}return Ns}var $s,Rp;function q1(){if(Rp)return $s;Rp=1;var e=vr(),t=xm();$s=r;function r(n){return e.filter(t(n),function(o){return o.length>1||o.length===1&&n.hasEdge(o[0],o[0])})}return $s}var Ls,kp;function N1(){if(kp)return Ls;kp=1;var e=vr();Ls=r;var t=e.constant(1);function r(o,i,a){return n(o,i||t,a||function(s){return o.outEdges(s)})}function n(o,i,a){var s={},u=o.nodes();return u.forEach(function(c){s[c]={},s[c][c]={distance:0},u.forEach(function(l){c!==l&&(s[c][l]={distance:Number.POSITIVE_INFINITY})}),a(c).forEach(function(l){var d=l.v===c?l.w:l.v,f=i(l);s[c][d]={distance:f,predecessor:c}})}),u.forEach(function(c){var l=s[c];u.forEach(function(d){var f=s[d];u.forEach(function(p){var b=f[c],y=l[p],m=f[p],x=b.distance+y.distance;x<m.distance&&(m.distance=x,m.predecessor=y.predecessor)})})}),s}return Ls}var Fs,Pp;function wm(){if(Pp)return Fs;Pp=1;var e=vr();Fs=t,t.CycleException=r;function t(n){var o={},i={},a=[];function s(u){if(e.has(i,u))throw new r;e.has(o,u)||(i[u]=!0,o[u]=!0,e.each(n.predecessors(u),s),delete i[u],a.push(u))}if(e.each(n.sinks(),s),e.size(o)!==n.nodeCount())throw new r;return a}function r(){}return r.prototype=new Error,Fs}var Bs,Ap;function $1(){if(Ap)return Bs;Ap=1;var e=wm();Bs=t;function t(r){try{e(r)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return Bs}var Ds,Tp;function Cm(){if(Tp)return Ds;Tp=1;var e=vr();Ds=t;function t(n,o,i){e.isArray(o)||(o=[o]);var a=(n.isDirected()?n.successors:n.neighbors).bind(n),s=[],u={};return e.each(o,function(c){if(!n.hasNode(c))throw new Error("Graph does not have node: "+c);r(n,c,i==="post",u,a,s)}),s}function r(n,o,i,a,s,u){e.has(a,o)||(a[o]=!0,i||u.push(o),e.each(s(o),function(c){r(n,c,i,a,s,u)}),i&&u.push(o))}return Ds}var zs,Op;function L1(){if(Op)return zs;Op=1;var e=Cm();zs=t;function t(r,n){return e(r,n,"post")}return zs}var Vs,Ip;function F1(){if(Ip)return Vs;Ip=1;var e=Cm();Vs=t;function t(r,n){return e(r,n,"pre")}return Vs}var Ws,Mp;function B1(){if(Mp)return Ws;Mp=1;var e=vr(),t=el(),r=mm();Ws=n;function n(o,i){var a=new t,s={},u=new r,c;function l(f){var p=f.v===c?f.w:f.v,b=u.priority(p);if(b!==void 0){var y=i(f);y<b&&(s[p]=c,u.decrease(p,y))}}if(o.nodeCount()===0)return a;e.each(o.nodes(),function(f){u.add(f,Number.POSITIVE_INFINITY),a.setNode(f)}),u.decrease(o.nodes()[0],0);for(var d=!1;u.size()>0;){if(c=u.removeMin(),e.has(s,c))a.setEdge(c,s[c]);else{if(d)throw new Error("Input graph is not connected: "+o);d=!0}o.nodeEdges(c).forEach(l)}return a}return Ws}var Gs,qp;function D1(){return qp||(qp=1,Gs={components:I1(),dijkstra:vm(),dijkstraAll:M1(),findCycles:q1(),floydWarshall:N1(),isAcyclic:$1(),postorder:L1(),preorder:F1(),prim:B1(),tarjan:xm(),topsort:wm()}),Gs}var Us,Np;function z1(){if(Np)return Us;Np=1;var e=T1();return Us={Graph:e.Graph,json:O1(),alg:D1(),version:e.version},Us}var Hs,$p;function _r(){if($p)return Hs;$p=1;var e;if(typeof Lu=="function")try{e=z1()}catch{}return e||(e=window.graphlib),Hs=e,Hs}var Ks,Lp;function V1(){if(Lp)return Ks;Lp=1;var e=Hb(),t=1,r=4;function n(o){return e(o,t|r)}return Ks=n,Ks}var Zs,Fp;function Fn(){if(Fp)return Zs;Fp=1;var e=gt(),t=qr(),r=An(),n=mr();function o(i,a,s){if(!n(s))return!1;var u=typeof a;return(u=="number"?t(s)&&r(a,s.length):u=="string"&&a in s)?e(s[a],i):!1}return Zs=o,Zs}var Js,Bp;function W1(){if(Bp)return Js;Bp=1;var e=Ln(),t=gt(),r=Fn(),n=tt(),o=Object.prototype,i=o.hasOwnProperty,a=e(function(s,u){s=Object(s);var c=-1,l=u.length,d=l>2?u[2]:void 0;for(d&&r(u[0],u[1],d)&&(l=1);++c<l;)for(var f=u[c],p=n(f),b=-1,y=p.length;++b<y;){var m=p[b],x=s[m];(x===void 0||t(x,o[m])&&!i.call(s,m))&&(s[m]=f[m])}return s});return Js=a,Js}var Ys,Dp;function G1(){if(Dp)return Ys;Dp=1;var e=Nr(),t=qr(),r=Gr();function n(o){return function(i,a,s){var u=Object(i);if(!t(i)){var c=e(a,3);i=r(i),a=function(d){return c(u[d],d,u)}}var l=o(i,a,s);return l>-1?u[c?i[l]:l]:void 0}}return Ys=n,Ys}var Xs,zp;function U1(){if(zp)return Xs;zp=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return Xs=t,Xs}var Qs,Vp;function H1(){if(Vp)return Qs;Vp=1;var e=U1(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return Qs=r,Qs}var ec,Wp;function K1(){if(Wp)return ec;Wp=1;var e=H1(),t=mr(),r=vt(),n=NaN,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,a=/^0o[0-7]+$/i,s=parseInt;function u(c){if(typeof c=="number")return c;if(r(c))return n;if(t(c)){var l=typeof c.valueOf=="function"?c.valueOf():c;c=t(l)?l+"":l}if(typeof c!="string")return c===0?c:+c;c=e(c);var d=i.test(c);return d||a.test(c)?s(c.slice(2),d?2:8):o.test(c)?n:+c}return ec=u,ec}var rc,Gp;function _m(){if(Gp)return rc;Gp=1;var e=K1(),t=1/0,r=17976931348623157e292;function n(o){if(!o)return o===0?o:0;if(o=e(o),o===t||o===-t){var i=o<0?-1:1;return i*r}return o===o?o:0}return rc=n,rc}var tc,Up;function Z1(){if(Up)return tc;Up=1;var e=_m();function t(r){var n=e(r),o=n%1;return n===n?o?n-o:n:0}return tc=t,tc}var nc,Hp;function J1(){if(Hp)return nc;Hp=1;var e=gm(),t=Nr(),r=Z1(),n=Math.max;function o(i,a,s){var u=i==null?0:i.length;if(!u)return-1;var c=s==null?0:r(s);return c<0&&(c=n(u+c,0)),e(i,t(a,3),c)}return nc=o,nc}var oc,Kp;function Y1(){if(Kp)return oc;Kp=1;var e=G1(),t=J1(),r=e(t);return oc=r,oc}var ic,Zp;function Sm(){if(Zp)return ic;Zp=1;var e=Qu();function t(r){var n=r==null?0:r.length;return n?e(r,1):[]}return ic=t,ic}var ac,Jp;function X1(){if(Jp)return ac;Jp=1;var e=Zu(),t=Kb(),r=tt();function n(o,i){return o==null?o:e(o,t(i),r)}return ac=n,ac}var sc,Yp;function Q1(){if(Yp)return sc;Yp=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return sc=e,sc}var cc,Xp;function eC(){if(Xp)return cc;Xp=1;var e=kn(),t=Ju(),r=Nr();function n(o,i){var a={};return i=r(i,3),t(o,function(s,u,c){e(a,u,i(s,u,c))}),a}return cc=n,cc}var uc,Qp;function rl(){if(Qp)return uc;Qp=1;var e=vt();function t(r,n,o){for(var i=-1,a=r.length;++i<a;){var s=r[i],u=n(s);if(u!=null&&(c===void 0?u===u&&!e(u):o(u,c)))var c=u,l=s}return l}return uc=t,uc}var lc,eg;function rC(){if(eg)return lc;eg=1;function e(t,r){return t>r}return lc=e,lc}var dc,rg;function tC(){if(rg)return dc;rg=1;var e=rl(),t=rC(),r=nt();function n(o){return o&&o.length?e(o,r,t):void 0}return dc=n,dc}var fc,tg;function jm(){if(tg)return fc;tg=1;var e=kn(),t=gt();function r(n,o,i){(i!==void 0&&!t(n[o],i)||i===void 0&&!(o in n))&&e(n,o,i)}return fc=r,fc}var hc,ng;function nC(){if(ng)return hc;ng=1;var e=et(),t=In(),r=Pr(),n="[object Object]",o=Function.prototype,i=Object.prototype,a=o.toString,s=i.hasOwnProperty,u=a.call(Object);function c(l){if(!r(l)||e(l)!=n)return!1;var d=t(l);if(d===null)return!0;var f=s.call(d,"constructor")&&d.constructor;return typeof f=="function"&&f instanceof f&&a.call(f)==u}return hc=c,hc}var pc,og;function Em(){if(og)return pc;og=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return pc=e,pc}var gc,ig;function oC(){if(ig)return gc;ig=1;var e=Xt(),t=tt();function r(n){return e(n,t(n))}return gc=r,gc}var yc,ag;function iC(){if(ag)return yc;ag=1;var e=jm(),t=qb(),r=Wb(),n=Nb(),o=Ub(),i=Qt(),a=Ke(),s=ym(),u=bt(),c=Yt(),l=mr(),d=nC(),f=en(),p=Em(),b=oC();function y(m,x,g,w,v,_,C){var S=p(m,g),T=p(x,g),k=C.get(T);if(k){e(m,g,k);return}var j=_?_(S,T,g+"",m,x,C):void 0,P=j===void 0;if(P){var R=a(T),I=!R&&u(T),O=!R&&!I&&f(T);j=T,R||I||O?a(S)?j=S:s(S)?j=n(S):I?(P=!1,j=t(T,!0)):O?(P=!1,j=r(T,!0)):j=[]:d(T)||i(T)?(j=S,i(S)?j=b(S):(!l(S)||c(S))&&(j=o(T))):P=!1}P&&(C.set(T,j),v(j,T,w,_,C),C.delete(T)),e(m,g,j)}return yc=y,yc}var bc,sg;function aC(){if(sg)return bc;sg=1;var e=Rn(),t=jm(),r=Zu(),n=iC(),o=mr(),i=tt(),a=Em();function s(u,c,l,d,f){u!==c&&r(c,function(p,b){if(f||(f=new e),o(p))n(u,c,b,l,s,d,f);else{var y=d?d(a(u,b),p,b+"",u,c,f):void 0;y===void 0&&(y=p),t(u,b,y)}},i)}return bc=s,bc}var mc,cg;function sC(){if(cg)return mc;cg=1;var e=Ln(),t=Fn();function r(n){return e(function(o,i){var a=-1,s=i.length,u=s>1?i[s-1]:void 0,c=s>2?i[2]:void 0;for(u=n.length>3&&typeof u=="function"?(s--,u):void 0,c&&t(i[0],i[1],c)&&(u=s<3?void 0:u,s=1),o=Object(o);++a<s;){var l=i[a];l&&n(o,l,a,u)}return o})}return mc=r,mc}var vc,ug;function cC(){if(ug)return vc;ug=1;var e=aC(),t=sC(),r=t(function(n,o,i){e(n,o,i)});return vc=r,vc}var xc,lg;function Rm(){if(lg)return xc;lg=1;function e(t,r){return t<r}return xc=e,xc}var wc,dg;function uC(){if(dg)return wc;dg=1;var e=rl(),t=Rm(),r=nt();function n(o){return o&&o.length?e(o,r,t):void 0}return wc=n,wc}var Cc,fg;function lC(){if(fg)return Cc;fg=1;var e=rl(),t=Nr(),r=Rm();function n(o,i){return o&&o.length?e(o,t(i,2),r):void 0}return Cc=n,Cc}var _c,hg;function dC(){if(hg)return _c;hg=1;var e=Sr(),t=function(){return e.Date.now()};return _c=t,_c}var Sc,pg;function fC(){if(pg)return Sc;pg=1;var e=Pn(),t=Nn(),r=An(),n=mr(),o=rn();function i(a,s,u,c){if(!n(a))return a;s=t(s,a);for(var l=-1,d=s.length,f=d-1,p=a;p!=null&&++l<d;){var b=o(s[l]),y=u;if(b==="__proto__"||b==="constructor"||b==="prototype")return a;if(l!=f){var m=p[b];y=c?c(m,b,p):void 0,y===void 0&&(y=n(m)?m:r(s[l+1])?[]:{})}e(p,b,y),p=p[b]}return a}return Sc=i,Sc}var jc,gg;function hC(){if(gg)return jc;gg=1;var e=$n(),t=fC(),r=Nn();function n(o,i,a){for(var s=-1,u=i.length,c={};++s<u;){var l=i[s],d=e(o,l);a(d,l)&&t(c,r(l,o),d)}return c}return jc=n,jc}var Ec,yg;function pC(){if(yg)return Ec;yg=1;var e=hC(),t=im();function r(n,o){return e(n,o,function(i,a){return t(n,a)})}return Ec=r,Ec}var Rc,bg;function gC(){if(bg)return Rc;bg=1;var e=Sm(),t=hm(),r=pm();function n(o){return r(t(o,void 0,e),o+"")}return Rc=n,Rc}var kc,mg;function yC(){if(mg)return kc;mg=1;var e=pC(),t=gC(),r=t(function(n,o){return n==null?{}:e(n,o)});return kc=r,kc}var Pc,vg;function bC(){if(vg)return Pc;vg=1;var e=Math.ceil,t=Math.max;function r(n,o,i,a){for(var s=-1,u=t(e((o-n)/(i||1)),0),c=Array(u);u--;)c[a?u:++s]=n,n+=i;return c}return Pc=r,Pc}var Ac,xg;function mC(){if(xg)return Ac;xg=1;var e=bC(),t=Fn(),r=_m();function n(o){return function(i,a,s){return s&&typeof s!="number"&&t(i,a,s)&&(a=s=void 0),i=r(i),a===void 0?(a=i,i=0):a=r(a),s=s===void 0?i<a?1:-1:r(s),e(i,a,s,o)}}return Ac=n,Ac}var Tc,wg;function vC(){if(wg)return Tc;wg=1;var e=mC(),t=e();return Tc=t,Tc}var Oc,Cg;function xC(){if(Cg)return Oc;Cg=1;function e(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}return Oc=e,Oc}var Ic,_g;function wC(){if(_g)return Ic;_g=1;var e=vt();function t(r,n){if(r!==n){var o=r!==void 0,i=r===null,a=r===r,s=e(r),u=n!==void 0,c=n===null,l=n===n,d=e(n);if(!c&&!d&&!s&&r>n||s&&u&&l&&!c&&!d||i&&u&&l||!o&&l||!a)return 1;if(!i&&!s&&!d&&r<n||d&&o&&a&&!i&&!s||c&&o&&a||!u&&a||!l)return-1}return 0}return Ic=t,Ic}var Mc,Sg;function CC(){if(Sg)return Mc;Sg=1;var e=wC();function t(r,n,o){for(var i=-1,a=r.criteria,s=n.criteria,u=a.length,c=o.length;++i<u;){var l=e(a[i],s[i]);if(l){if(i>=c)return l;var d=o[i];return l*(d=="desc"?-1:1)}}return r.index-n.index}return Mc=t,Mc}var qc,jg;function _C(){if(jg)return qc;jg=1;var e=qn(),t=$n(),r=Nr(),n=lm(),o=xC(),i=Tn(),a=CC(),s=nt(),u=Ke();function c(l,d,f){d.length?d=e(d,function(y){return u(y)?function(m){return t(m,y.length===1?y[0]:y)}:y}):d=[s];var p=-1;d=e(d,i(r));var b=n(l,function(y,m,x){var g=e(d,function(w){return w(y)});return{criteria:g,index:++p,value:y}});return o(b,function(y,m){return a(y,m,f)})}return qc=c,qc}var Nc,Eg;function SC(){if(Eg)return Nc;Eg=1;var e=Qu(),t=_C(),r=Ln(),n=Fn(),o=r(function(i,a){if(i==null)return[];var s=a.length;return s>1&&n(i,a[0],a[1])?a=[]:s>2&&n(a[0],a[1],a[2])&&(a=[a[0]]),t(i,e(a,1),[])});return Nc=o,Nc}var $c,Rg;function jC(){if(Rg)return $c;Rg=1;var e=nm(),t=0;function r(n){var o=++t;return e(n)+o}return $c=r,$c}var Lc,kg;function EC(){if(kg)return Lc;kg=1;function e(t,r,n){for(var o=-1,i=t.length,a=r.length,s={};++o<i;){var u=o<a?r[o]:void 0;n(s,t[o],u)}return s}return Lc=e,Lc}var Fc,Pg;function RC(){if(Pg)return Fc;Pg=1;var e=Pn(),t=EC();function r(n,o){return t(n||[],o||[],e)}return Fc=r,Fc}var Bc,Ag;function Be(){if(Ag)return Bc;Ag=1;var e;if(typeof Lu=="function")try{e={cloneDeep:V1(),constant:Ku(),defaults:W1(),each:Jb(),filter:sm(),find:Y1(),flatten:Sm(),forEach:Zb(),forIn:X1(),has:cm(),isUndefined:um(),last:Q1(),map:dm(),mapValues:eC(),max:tC(),merge:cC(),min:uC(),minBy:lC(),now:dC(),pick:yC(),range:vC(),reduce:fm(),sortBy:SC(),uniqueId:jC(),values:bm(),zipObject:RC()}}catch{}return e||(e=window._),Bc=e,Bc}var Dc,Tg;function kC(){if(Tg)return Dc;Tg=1,Dc=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,o=n._prev;if(o!==n)return t(o),o},e.prototype.enqueue=function(n){var o=this._sentinel;n._prev&&n._next&&t(n),n._next=o._next,o._next._prev=n,o._next=n,n._prev=o},e.prototype.toString=function(){for(var n=[],o=this._sentinel,i=o._prev;i!==o;)n.push(JSON.stringify(i,r)),i=i._prev;return"["+n.join(", ")+"]"};function t(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function r(n,o){if(n!=="_next"&&n!=="_prev")return o}return Dc}var zc,Og;function PC(){if(Og)return zc;Og=1;var e=Be(),t=_r().Graph,r=kC();zc=o;var n=e.constant(1);function o(c,l){if(c.nodeCount()<=1)return[];var d=s(c,l||n),f=i(d.graph,d.buckets,d.zeroIdx);return e.flatten(e.map(f,function(p){return c.outEdges(p.v,p.w)}),!0)}function i(c,l,d){for(var f=[],p=l[l.length-1],b=l[0],y;c.nodeCount();){for(;y=b.dequeue();)a(c,l,d,y);for(;y=p.dequeue();)a(c,l,d,y);if(c.nodeCount()){for(var m=l.length-2;m>0;--m)if(y=l[m].dequeue(),y){f=f.concat(a(c,l,d,y,!0));break}}}return f}function a(c,l,d,f,p){var b=p?[]:void 0;return e.forEach(c.inEdges(f.v),function(y){var m=c.edge(y),x=c.node(y.v);p&&b.push({v:y.v,w:y.w}),x.out-=m,u(l,d,x)}),e.forEach(c.outEdges(f.v),function(y){var m=c.edge(y),x=y.w,g=c.node(x);g.in-=m,u(l,d,g)}),c.removeNode(f.v),b}function s(c,l){var d=new t,f=0,p=0;e.forEach(c.nodes(),function(m){d.setNode(m,{v:m,in:0,out:0})}),e.forEach(c.edges(),function(m){var x=d.edge(m.v,m.w)||0,g=l(m),w=x+g;d.setEdge(m.v,m.w,w),p=Math.max(p,d.node(m.v).out+=g),f=Math.max(f,d.node(m.w).in+=g)});var b=e.range(p+f+3).map(function(){return new r}),y=f+1;return e.forEach(d.nodes(),function(m){u(b,y,d.node(m))}),{graph:d,buckets:b,zeroIdx:y}}function u(c,l,d){d.out?d.in?c[d.out-d.in+l].enqueue(d):c[c.length-1].enqueue(d):c[0].enqueue(d)}return zc}var Vc,Ig;function AC(){if(Ig)return Vc;Ig=1;var e=Be(),t=PC();Vc={run:r,undo:o};function r(i){var a=i.graph().acyclicer==="greedy"?t(i,s(i)):n(i);e.forEach(a,function(u){var c=i.edge(u);i.removeEdge(u),c.forwardName=u.name,c.reversed=!0,i.setEdge(u.w,u.v,c,e.uniqueId("rev"))});function s(u){return function(c){return u.edge(c).weight}}}function n(i){var a=[],s={},u={};function c(l){e.has(u,l)||(u[l]=!0,s[l]=!0,e.forEach(i.outEdges(l),function(d){e.has(s,d.w)?a.push(d):c(d.w)}),delete s[l])}return e.forEach(i.nodes(),c),a}function o(i){e.forEach(i.edges(),function(a){var s=i.edge(a);if(s.reversed){i.removeEdge(a);var u=s.forwardName;delete s.reversed,delete s.forwardName,i.setEdge(a.w,a.v,s,u)}})}return Vc}var Wc,Mg;function lr(){if(Mg)return Wc;Mg=1;var e=Be(),t=_r().Graph;Wc={addDummyNode:r,simplify:n,asNonCompoundGraph:o,successorWeights:i,predecessorWeights:a,intersectRect:s,buildLayerMatrix:u,normalizeRanks:c,removeEmptyRanks:l,addBorderNode:d,maxRank:f,partition:p,time:b,notime:y};function r(m,x,g,w){var v;do v=e.uniqueId(w);while(m.hasNode(v));return g.dummy=x,m.setNode(v,g),v}function n(m){var x=new t().setGraph(m.graph());return e.forEach(m.nodes(),function(g){x.setNode(g,m.node(g))}),e.forEach(m.edges(),function(g){var w=x.edge(g.v,g.w)||{weight:0,minlen:1},v=m.edge(g);x.setEdge(g.v,g.w,{weight:w.weight+v.weight,minlen:Math.max(w.minlen,v.minlen)})}),x}function o(m){var x=new t({multigraph:m.isMultigraph()}).setGraph(m.graph());return e.forEach(m.nodes(),function(g){m.children(g).length||x.setNode(g,m.node(g))}),e.forEach(m.edges(),function(g){x.setEdge(g,m.edge(g))}),x}function i(m){var x=e.map(m.nodes(),function(g){var w={};return e.forEach(m.outEdges(g),function(v){w[v.w]=(w[v.w]||0)+m.edge(v).weight}),w});return e.zipObject(m.nodes(),x)}function a(m){var x=e.map(m.nodes(),function(g){var w={};return e.forEach(m.inEdges(g),function(v){w[v.v]=(w[v.v]||0)+m.edge(v).weight}),w});return e.zipObject(m.nodes(),x)}function s(m,x){var g=m.x,w=m.y,v=x.x-g,_=x.y-w,C=m.width/2,S=m.height/2;if(!v&&!_)throw new Error("Not possible to find intersection inside of the rectangle");var T,k;return Math.abs(_)*C>Math.abs(v)*S?(_<0&&(S=-S),T=S*v/_,k=S):(v<0&&(C=-C),T=C,k=C*_/v),{x:g+T,y:w+k}}function u(m){var x=e.map(e.range(f(m)+1),function(){return[]});return e.forEach(m.nodes(),function(g){var w=m.node(g),v=w.rank;e.isUndefined(v)||(x[v][w.order]=g)}),x}function c(m){var x=e.min(e.map(m.nodes(),function(g){return m.node(g).rank}));e.forEach(m.nodes(),function(g){var w=m.node(g);e.has(w,"rank")&&(w.rank-=x)})}function l(m){var x=e.min(e.map(m.nodes(),function(_){return m.node(_).rank})),g=[];e.forEach(m.nodes(),function(_){var C=m.node(_).rank-x;g[C]||(g[C]=[]),g[C].push(_)});var w=0,v=m.graph().nodeRankFactor;e.forEach(g,function(_,C){e.isUndefined(_)&&C%v!==0?--w:w&&e.forEach(_,function(S){m.node(S).rank+=w})})}function d(m,x,g,w){var v={width:0,height:0};return arguments.length>=4&&(v.rank=g,v.order=w),r(m,"border",v,x)}function f(m){return e.max(e.map(m.nodes(),function(x){var g=m.node(x).rank;if(!e.isUndefined(g))return g}))}function p(m,x){var g={lhs:[],rhs:[]};return e.forEach(m,function(w){x(w)?g.lhs.push(w):g.rhs.push(w)}),g}function b(m,x){var g=e.now();try{return x()}finally{console.log(m+" time: "+(e.now()-g)+"ms")}}function y(m,x){return x()}return Wc}var Gc,qg;function TC(){if(qg)return Gc;qg=1;var e=Be(),t=lr();Gc={run:r,undo:o};function r(i){i.graph().dummyChains=[],e.forEach(i.edges(),function(a){n(i,a)})}function n(i,a){var s=a.v,u=i.node(s).rank,c=a.w,l=i.node(c).rank,d=a.name,f=i.edge(a),p=f.labelRank;if(l!==u+1){i.removeEdge(a);var b,y,m;for(m=0,++u;u<l;++m,++u)f.points=[],y={width:0,height:0,edgeLabel:f,edgeObj:a,rank:u},b=t.addDummyNode(i,"edge",y,"_d"),u===p&&(y.width=f.width,y.height=f.height,y.dummy="edge-label",y.labelpos=f.labelpos),i.setEdge(s,b,{weight:f.weight},d),m===0&&i.graph().dummyChains.push(b),s=b;i.setEdge(s,c,{weight:f.weight},d)}}function o(i){e.forEach(i.graph().dummyChains,function(a){var s=i.node(a),u=s.edgeLabel,c;for(i.setEdge(s.edgeObj,u);s.dummy;)c=i.successors(a)[0],i.removeNode(a),u.points.push({x:s.x,y:s.y}),s.dummy==="edge-label"&&(u.x=s.x,u.y=s.y,u.width=s.width,u.height=s.height),a=c,s=i.node(a)})}return Gc}var Uc,Ng;function pn(){if(Ng)return Uc;Ng=1;var e=Be();Uc={longestPath:t,slack:r};function t(n){var o={};function i(a){var s=n.node(a);if(e.has(o,a))return s.rank;o[a]=!0;var u=e.min(e.map(n.outEdges(a),function(c){return i(c.w)-n.edge(c).minlen}));return(u===Number.POSITIVE_INFINITY||u===void 0||u===null)&&(u=0),s.rank=u}e.forEach(n.sources(),i)}function r(n,o){return n.node(o.w).rank-n.node(o.v).rank-n.edge(o).minlen}return Uc}var Hc,$g;function km(){if($g)return Hc;$g=1;var e=Be(),t=_r().Graph,r=pn().slack;Hc=n;function n(s){var u=new t({directed:!1}),c=s.nodes()[0],l=s.nodeCount();u.setNode(c,{});for(var d,f;o(u,s)<l;)d=i(u,s),f=u.hasNode(d.v)?r(s,d):-r(s,d),a(u,s,f);return u}function o(s,u){function c(l){e.forEach(u.nodeEdges(l),function(d){var f=d.v,p=l===f?d.w:f;!s.hasNode(p)&&!r(u,d)&&(s.setNode(p,{}),s.setEdge(l,p,{}),c(p))})}return e.forEach(s.nodes(),c),s.nodeCount()}function i(s,u){return e.minBy(u.edges(),function(c){if(s.hasNode(c.v)!==s.hasNode(c.w))return r(u,c)})}function a(s,u,c){e.forEach(s.nodes(),function(l){u.node(l).rank+=c})}return Hc}var Kc,Lg;function OC(){if(Lg)return Kc;Lg=1;var e=Be(),t=km(),r=pn().slack,n=pn().longestPath,o=_r().alg.preorder,i=_r().alg.postorder,a=lr().simplify;Kc=s,s.initLowLimValues=d,s.initCutValues=u,s.calcCutValue=l,s.leaveEdge=p,s.enterEdge=b,s.exchangeEdges=y;function s(w){w=a(w),n(w);var v=t(w);d(v),u(v,w);for(var _,C;_=p(v);)C=b(v,w,_),y(v,w,_,C)}function u(w,v){var _=i(w,w.nodes());_=_.slice(0,_.length-1),e.forEach(_,function(C){c(w,v,C)})}function c(w,v,_){var C=w.node(_),S=C.parent;w.edge(_,S).cutvalue=l(w,v,_)}function l(w,v,_){var C=w.node(_),S=C.parent,T=!0,k=v.edge(_,S),j=0;return k||(T=!1,k=v.edge(S,_)),j=k.weight,e.forEach(v.nodeEdges(_),function(P){var R=P.v===_,I=R?P.w:P.v;if(I!==S){var O=R===T,M=v.edge(P).weight;if(j+=O?M:-M,x(w,_,I)){var q=w.edge(_,I).cutvalue;j+=O?-q:q}}}),j}function d(w,v){arguments.length<2&&(v=w.nodes()[0]),f(w,{},1,v)}function f(w,v,_,C,S){var T=_,k=w.node(C);return v[C]=!0,e.forEach(w.neighbors(C),function(j){e.has(v,j)||(_=f(w,v,_,j,C))}),k.low=T,k.lim=_++,S?k.parent=S:delete k.parent,_}function p(w){return e.find(w.edges(),function(v){return w.edge(v).cutvalue<0})}function b(w,v,_){var C=_.v,S=_.w;v.hasEdge(C,S)||(C=_.w,S=_.v);var T=w.node(C),k=w.node(S),j=T,P=!1;T.lim>k.lim&&(j=k,P=!0);var R=e.filter(v.edges(),function(I){return P===g(w,w.node(I.v),j)&&P!==g(w,w.node(I.w),j)});return e.minBy(R,function(I){return r(v,I)})}function y(w,v,_,C){var S=_.v,T=_.w;w.removeEdge(S,T),w.setEdge(C.v,C.w,{}),d(w),u(w,v),m(w,v)}function m(w,v){var _=e.find(w.nodes(),function(S){return!v.node(S).parent}),C=o(w,_);C=C.slice(1),e.forEach(C,function(S){var T=w.node(S).parent,k=v.edge(S,T),j=!1;k||(k=v.edge(T,S),j=!0),v.node(S).rank=v.node(T).rank+(j?k.minlen:-k.minlen)})}function x(w,v,_){return w.hasEdge(v,_)}function g(w,v,_){return _.low<=v.lim&&v.lim<=_.lim}return Kc}var Zc,Fg;function IC(){if(Fg)return Zc;Fg=1;var e=pn(),t=e.longestPath,r=km(),n=OC();Zc=o;function o(u){switch(u.graph().ranker){case"network-simplex":s(u);break;case"tight-tree":a(u);break;case"longest-path":i(u);break;default:s(u)}}var i=t;function a(u){t(u),r(u)}function s(u){n(u)}return Zc}var Jc,Bg;function MC(){if(Bg)return Jc;Bg=1;var e=Be();Jc=t;function t(o){var i=n(o);e.forEach(o.graph().dummyChains,function(a){for(var s=o.node(a),u=s.edgeObj,c=r(o,i,u.v,u.w),l=c.path,d=c.lca,f=0,p=l[f],b=!0;a!==u.w;){if(s=o.node(a),b){for(;(p=l[f])!==d&&o.node(p).maxRank<s.rank;)f++;p===d&&(b=!1)}if(!b){for(;f<l.length-1&&o.node(p=l[f+1]).minRank<=s.rank;)f++;p=l[f]}o.setParent(a,p),a=o.successors(a)[0]}})}function r(o,i,a,s){var u=[],c=[],l=Math.min(i[a].low,i[s].low),d=Math.max(i[a].lim,i[s].lim),f,p;f=a;do f=o.parent(f),u.push(f);while(f&&(i[f].low>l||d>i[f].lim));for(p=f,f=s;(f=o.parent(f))!==p;)c.push(f);return{path:u.concat(c.reverse()),lca:p}}function n(o){var i={},a=0;function s(u){var c=a;e.forEach(o.children(u),s),i[u]={low:c,lim:a++}}return e.forEach(o.children(),s),i}return Jc}var Yc,Dg;function qC(){if(Dg)return Yc;Dg=1;var e=Be(),t=lr();Yc={run:r,cleanup:a};function r(s){var u=t.addDummyNode(s,"root",{},"_root"),c=o(s),l=e.max(e.values(c))-1,d=2*l+1;s.graph().nestingRoot=u,e.forEach(s.edges(),function(p){s.edge(p).minlen*=d});var f=i(s)+1;e.forEach(s.children(),function(p){n(s,u,d,f,l,c,p)}),s.graph().nodeRankFactor=d}function n(s,u,c,l,d,f,p){var b=s.children(p);if(!b.length){p!==u&&s.setEdge(u,p,{weight:0,minlen:c});return}var y=t.addBorderNode(s,"_bt"),m=t.addBorderNode(s,"_bb"),x=s.node(p);s.setParent(y,p),x.borderTop=y,s.setParent(m,p),x.borderBottom=m,e.forEach(b,function(g){n(s,u,c,l,d,f,g);var w=s.node(g),v=w.borderTop?w.borderTop:g,_=w.borderBottom?w.borderBottom:g,C=w.borderTop?l:2*l,S=v!==_?1:d-f[p]+1;s.setEdge(y,v,{weight:C,minlen:S,nestingEdge:!0}),s.setEdge(_,m,{weight:C,minlen:S,nestingEdge:!0})}),s.parent(p)||s.setEdge(u,y,{weight:0,minlen:d+f[p]})}function o(s){var u={};function c(l,d){var f=s.children(l);f&&f.length&&e.forEach(f,function(p){c(p,d+1)}),u[l]=d}return e.forEach(s.children(),function(l){c(l,1)}),u}function i(s){return e.reduce(s.edges(),function(u,c){return u+s.edge(c).weight},0)}function a(s){var u=s.graph();s.removeNode(u.nestingRoot),delete u.nestingRoot,e.forEach(s.edges(),function(c){var l=s.edge(c);l.nestingEdge&&s.removeEdge(c)})}return Yc}var Xc,zg;function NC(){if(zg)return Xc;zg=1;var e=Be(),t=lr();Xc=r;function r(o){function i(a){var s=o.children(a),u=o.node(a);if(s.length&&e.forEach(s,i),e.has(u,"minRank")){u.borderLeft=[],u.borderRight=[];for(var c=u.minRank,l=u.maxRank+1;c<l;++c)n(o,"borderLeft","_bl",a,u,c),n(o,"borderRight","_br",a,u,c)}}e.forEach(o.children(),i)}function n(o,i,a,s,u,c){var l={width:0,height:0,rank:c,borderType:i},d=u[i][c-1],f=t.addDummyNode(o,"border",l,a);u[i][c]=f,o.setParent(f,s),d&&o.setEdge(d,f,{weight:1})}return Xc}var Qc,Vg;function $C(){if(Vg)return Qc;Vg=1;var e=Be();Qc={adjust:t,undo:r};function t(c){var l=c.graph().rankdir.toLowerCase();(l==="lr"||l==="rl")&&n(c)}function r(c){var l=c.graph().rankdir.toLowerCase();(l==="bt"||l==="rl")&&i(c),(l==="lr"||l==="rl")&&(s(c),n(c))}function n(c){e.forEach(c.nodes(),function(l){o(c.node(l))}),e.forEach(c.edges(),function(l){o(c.edge(l))})}function o(c){var l=c.width;c.width=c.height,c.height=l}function i(c){e.forEach(c.nodes(),function(l){a(c.node(l))}),e.forEach(c.edges(),function(l){var d=c.edge(l);e.forEach(d.points,a),e.has(d,"y")&&a(d)})}function a(c){c.y=-c.y}function s(c){e.forEach(c.nodes(),function(l){u(c.node(l))}),e.forEach(c.edges(),function(l){var d=c.edge(l);e.forEach(d.points,u),e.has(d,"x")&&u(d)})}function u(c){var l=c.x;c.x=c.y,c.y=l}return Qc}var eu,Wg;function LC(){if(Wg)return eu;Wg=1;var e=Be();eu=t;function t(r){var n={},o=e.filter(r.nodes(),function(c){return!r.children(c).length}),i=e.max(e.map(o,function(c){return r.node(c).rank})),a=e.map(e.range(i+1),function(){return[]});function s(c){if(!e.has(n,c)){n[c]=!0;var l=r.node(c);a[l.rank].push(c),e.forEach(r.successors(c),s)}}var u=e.sortBy(o,function(c){return r.node(c).rank});return e.forEach(u,s),a}return eu}var ru,Gg;function FC(){if(Gg)return ru;Gg=1;var e=Be();ru=t;function t(n,o){for(var i=0,a=1;a<o.length;++a)i+=r(n,o[a-1],o[a]);return i}function r(n,o,i){for(var a=e.zipObject(i,e.map(i,function(f,p){return p})),s=e.flatten(e.map(o,function(f){return e.sortBy(e.map(n.outEdges(f),function(p){return{pos:a[p.w],weight:n.edge(p).weight}}),"pos")}),!0),u=1;u<i.length;)u<<=1;var c=2*u-1;u-=1;var l=e.map(new Array(c),function(){return 0}),d=0;return e.forEach(s.forEach(function(f){var p=f.pos+u;l[p]+=f.weight;for(var b=0;p>0;)p%2&&(b+=l[p+1]),p=p-1>>1,l[p]+=f.weight;d+=f.weight*b})),d}return ru}var tu,Ug;function BC(){if(Ug)return tu;Ug=1;var e=Be();tu=t;function t(r,n){return e.map(n,function(o){var i=r.inEdges(o);if(i.length){var a=e.reduce(i,function(s,u){var c=r.edge(u),l=r.node(u.v);return{sum:s.sum+c.weight*l.order,weight:s.weight+c.weight}},{sum:0,weight:0});return{v:o,barycenter:a.sum/a.weight,weight:a.weight}}else return{v:o}})}return tu}var nu,Hg;function DC(){if(Hg)return nu;Hg=1;var e=Be();nu=t;function t(o,i){var a={};e.forEach(o,function(u,c){var l=a[u.v]={indegree:0,in:[],out:[],vs:[u.v],i:c};e.isUndefined(u.barycenter)||(l.barycenter=u.barycenter,l.weight=u.weight)}),e.forEach(i.edges(),function(u){var c=a[u.v],l=a[u.w];!e.isUndefined(c)&&!e.isUndefined(l)&&(l.indegree++,c.out.push(a[u.w]))});var s=e.filter(a,function(u){return!u.indegree});return r(s)}function r(o){var i=[];function a(c){return function(l){l.merged||(e.isUndefined(l.barycenter)||e.isUndefined(c.barycenter)||l.barycenter>=c.barycenter)&&n(c,l)}}function s(c){return function(l){l.in.push(c),--l.indegree===0&&o.push(l)}}for(;o.length;){var u=o.pop();i.push(u),e.forEach(u.in.reverse(),a(u)),e.forEach(u.out,s(u))}return e.map(e.filter(i,function(c){return!c.merged}),function(c){return e.pick(c,["vs","i","barycenter","weight"])})}function n(o,i){var a=0,s=0;o.weight&&(a+=o.barycenter*o.weight,s+=o.weight),i.weight&&(a+=i.barycenter*i.weight,s+=i.weight),o.vs=i.vs.concat(o.vs),o.barycenter=a/s,o.weight=s,o.i=Math.min(i.i,o.i),i.merged=!0}return nu}var ou,Kg;function zC(){if(Kg)return ou;Kg=1;var e=Be(),t=lr();ou=r;function r(i,a){var s=t.partition(i,function(y){return e.has(y,"barycenter")}),u=s.lhs,c=e.sortBy(s.rhs,function(y){return-y.i}),l=[],d=0,f=0,p=0;u.sort(o(!!a)),p=n(l,c,p),e.forEach(u,function(y){p+=y.vs.length,l.push(y.vs),d+=y.barycenter*y.weight,f+=y.weight,p=n(l,c,p)});var b={vs:e.flatten(l,!0)};return f&&(b.barycenter=d/f,b.weight=f),b}function n(i,a,s){for(var u;a.length&&(u=e.last(a)).i<=s;)a.pop(),i.push(u.vs),s++;return s}function o(i){return function(a,s){return a.barycenter<s.barycenter?-1:a.barycenter>s.barycenter?1:i?s.i-a.i:a.i-s.i}}return ou}var iu,Zg;function VC(){if(Zg)return iu;Zg=1;var e=Be(),t=BC(),r=DC(),n=zC();iu=o;function o(s,u,c,l){var d=s.children(u),f=s.node(u),p=f?f.borderLeft:void 0,b=f?f.borderRight:void 0,y={};p&&(d=e.filter(d,function(_){return _!==p&&_!==b}));var m=t(s,d);e.forEach(m,function(_){if(s.children(_.v).length){var C=o(s,_.v,c,l);y[_.v]=C,e.has(C,"barycenter")&&a(_,C)}});var x=r(m,c);i(x,y);var g=n(x,l);if(p&&(g.vs=e.flatten([p,g.vs,b],!0),s.predecessors(p).length)){var w=s.node(s.predecessors(p)[0]),v=s.node(s.predecessors(b)[0]);e.has(g,"barycenter")||(g.barycenter=0,g.weight=0),g.barycenter=(g.barycenter*g.weight+w.order+v.order)/(g.weight+2),g.weight+=2}return g}function i(s,u){e.forEach(s,function(c){c.vs=e.flatten(c.vs.map(function(l){return u[l]?u[l].vs:l}),!0)})}function a(s,u){e.isUndefined(s.barycenter)?(s.barycenter=u.barycenter,s.weight=u.weight):(s.barycenter=(s.barycenter*s.weight+u.barycenter*u.weight)/(s.weight+u.weight),s.weight+=u.weight)}return iu}var au,Jg;function WC(){if(Jg)return au;Jg=1;var e=Be(),t=_r().Graph;au=r;function r(o,i,a){var s=n(o),u=new t({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(function(c){return o.node(c)});return e.forEach(o.nodes(),function(c){var l=o.node(c),d=o.parent(c);(l.rank===i||l.minRank<=i&&i<=l.maxRank)&&(u.setNode(c),u.setParent(c,d||s),e.forEach(o[a](c),function(f){var p=f.v===c?f.w:f.v,b=u.edge(p,c),y=e.isUndefined(b)?0:b.weight;u.setEdge(p,c,{weight:o.edge(f).weight+y})}),e.has(l,"minRank")&&u.setNode(c,{borderLeft:l.borderLeft[i],borderRight:l.borderRight[i]}))}),u}function n(o){for(var i;o.hasNode(i=e.uniqueId("_root")););return i}return au}var su,Yg;function GC(){if(Yg)return su;Yg=1;var e=Be();su=t;function t(r,n,o){var i={},a;e.forEach(o,function(s){for(var u=r.parent(s),c,l;u;){if(c=r.parent(u),c?(l=i[c],i[c]=u):(l=a,a=u),l&&l!==u){n.setEdge(l,u);return}u=c}})}return su}var cu,Xg;function UC(){if(Xg)return cu;Xg=1;var e=Be(),t=LC(),r=FC(),n=VC(),o=WC(),i=GC(),a=_r().Graph,s=lr();cu=u;function u(f){var p=s.maxRank(f),b=c(f,e.range(1,p+1),"inEdges"),y=c(f,e.range(p-1,-1,-1),"outEdges"),m=t(f);d(f,m);for(var x=Number.POSITIVE_INFINITY,g,w=0,v=0;v<4;++w,++v){l(w%2?b:y,w%4>=2),m=s.buildLayerMatrix(f);var _=r(f,m);_<x&&(v=0,g=e.cloneDeep(m),x=_)}d(f,g)}function c(f,p,b){return e.map(p,function(y){return o(f,y,b)})}function l(f,p){var b=new a;e.forEach(f,function(y){var m=y.graph().root,x=n(y,m,b,p);e.forEach(x.vs,function(g,w){y.node(g).order=w}),i(y,b,x.vs)})}function d(f,p){e.forEach(p,function(b){e.forEach(b,function(y,m){f.node(y).order=m})})}return cu}var uu,Qg;function HC(){if(Qg)return uu;Qg=1;var e=Be(),t=_r().Graph,r=lr();uu={positionX:b,findType1Conflicts:n,findType2Conflicts:o,addConflict:a,hasConflict:s,verticalAlignment:u,horizontalCompaction:c,alignCoordinates:f,findSmallestWidthAlignment:d,balance:p};function n(x,g){var w={};function v(_,C){var S=0,T=0,k=_.length,j=e.last(C);return e.forEach(C,function(P,R){var I=i(x,P),O=I?x.node(I).order:k;(I||P===j)&&(e.forEach(C.slice(T,R+1),function(M){e.forEach(x.predecessors(M),function(q){var H=x.node(q),V=H.order;(V<S||O<V)&&!(H.dummy&&x.node(M).dummy)&&a(w,q,M)})}),T=R+1,S=O)}),C}return e.reduce(g,v),w}function o(x,g){var w={};function v(C,S,T,k,j){var P;e.forEach(e.range(S,T),function(R){P=C[R],x.node(P).dummy&&e.forEach(x.predecessors(P),function(I){var O=x.node(I);O.dummy&&(O.order<k||O.order>j)&&a(w,I,P)})})}function _(C,S){var T=-1,k,j=0;return e.forEach(S,function(P,R){if(x.node(P).dummy==="border"){var I=x.predecessors(P);I.length&&(k=x.node(I[0]).order,v(S,j,R,T,k),j=R,T=k)}v(S,j,S.length,k,C.length)}),S}return e.reduce(g,_),w}function i(x,g){if(x.node(g).dummy)return e.find(x.predecessors(g),function(w){return x.node(w).dummy})}function a(x,g,w){if(g>w){var v=g;g=w,w=v}var _=x[g];_||(x[g]=_={}),_[w]=!0}function s(x,g,w){if(g>w){var v=g;g=w,w=v}return e.has(x[g],w)}function u(x,g,w,v){var _={},C={},S={};return e.forEach(g,function(T){e.forEach(T,function(k,j){_[k]=k,C[k]=k,S[k]=j})}),e.forEach(g,function(T){var k=-1;e.forEach(T,function(j){var P=v(j);if(P.length){P=e.sortBy(P,function(q){return S[q]});for(var R=(P.length-1)/2,I=Math.floor(R),O=Math.ceil(R);I<=O;++I){var M=P[I];C[j]===j&&k<S[M]&&!s(w,j,M)&&(C[M]=j,C[j]=_[j]=_[M],k=S[M])}}})}),{root:_,align:C}}function c(x,g,w,v,_){var C={},S=l(x,g,w,_),T=_?"borderLeft":"borderRight";function k(R,I){for(var O=S.nodes(),M=O.pop(),q={};M;)q[M]?R(M):(q[M]=!0,O.push(M),O=O.concat(I(M))),M=O.pop()}function j(R){C[R]=S.inEdges(R).reduce(function(I,O){return Math.max(I,C[O.v]+S.edge(O))},0)}function P(R){var I=S.outEdges(R).reduce(function(M,q){return Math.min(M,C[q.w]-S.edge(q))},Number.POSITIVE_INFINITY),O=x.node(R);I!==Number.POSITIVE_INFINITY&&O.borderType!==T&&(C[R]=Math.max(C[R],I))}return k(j,S.predecessors.bind(S)),k(P,S.successors.bind(S)),e.forEach(v,function(R){C[R]=C[w[R]]}),C}function l(x,g,w,v){var _=new t,C=x.graph(),S=y(C.nodesep,C.edgesep,v);return e.forEach(g,function(T){var k;e.forEach(T,function(j){var P=w[j];if(_.setNode(P),k){var R=w[k],I=_.edge(R,P);_.setEdge(R,P,Math.max(S(x,j,k),I||0))}k=j})}),_}function d(x,g){return e.minBy(e.values(g),function(w){var v=Number.NEGATIVE_INFINITY,_=Number.POSITIVE_INFINITY;return e.forIn(w,function(C,S){var T=m(x,S)/2;v=Math.max(C+T,v),_=Math.min(C-T,_)}),v-_})}function f(x,g){var w=e.values(g),v=e.min(w),_=e.max(w);e.forEach(["u","d"],function(C){e.forEach(["l","r"],function(S){var T=C+S,k=x[T],j;if(k!==g){var P=e.values(k);j=S==="l"?v-e.min(P):_-e.max(P),j&&(x[T]=e.mapValues(k,function(R){return R+j}))}})})}function p(x,g){return e.mapValues(x.ul,function(w,v){if(g)return x[g.toLowerCase()][v];var _=e.sortBy(e.map(x,v));return(_[1]+_[2])/2})}function b(x){var g=r.buildLayerMatrix(x),w=e.merge(n(x,g),o(x,g)),v={},_;e.forEach(["u","d"],function(S){_=S==="u"?g:e.values(g).reverse(),e.forEach(["l","r"],function(T){T==="r"&&(_=e.map(_,function(R){return e.values(R).reverse()}));var k=(S==="u"?x.predecessors:x.successors).bind(x),j=u(x,_,w,k),P=c(x,_,j.root,j.align,T==="r");T==="r"&&(P=e.mapValues(P,function(R){return-R})),v[S+T]=P})});var C=d(x,v);return f(v,C),p(v,x.graph().align)}function y(x,g,w){return function(v,_,C){var S=v.node(_),T=v.node(C),k=0,j;if(k+=S.width/2,e.has(S,"labelpos"))switch(S.labelpos.toLowerCase()){case"l":j=-S.width/2;break;case"r":j=S.width/2;break}if(j&&(k+=w?j:-j),j=0,k+=(S.dummy?g:x)/2,k+=(T.dummy?g:x)/2,k+=T.width/2,e.has(T,"labelpos"))switch(T.labelpos.toLowerCase()){case"l":j=T.width/2;break;case"r":j=-T.width/2;break}return j&&(k+=w?j:-j),j=0,k}}function m(x,g){return x.node(g).width}return uu}var lu,ey;function KC(){if(ey)return lu;ey=1;var e=Be(),t=lr(),r=HC().positionX;lu=n;function n(i){i=t.asNonCompoundGraph(i),o(i),e.forEach(r(i),function(a,s){i.node(s).x=a})}function o(i){var a=t.buildLayerMatrix(i),s=i.graph().ranksep,u=0;e.forEach(a,function(c){var l=e.max(e.map(c,function(d){return i.node(d).height}));e.forEach(c,function(d){i.node(d).y=u+l/2}),u+=l+s})}return lu}var du,ry;function ZC(){if(ry)return du;ry=1;var e=Be(),t=AC(),r=TC(),n=IC(),o=lr().normalizeRanks,i=MC(),a=lr().removeEmptyRanks,s=qC(),u=NC(),c=$C(),l=UC(),d=KC(),f=lr(),p=_r().Graph;du=b;function b(N,B){var W=B&&B.debugTiming?f.time:f.notime;W("layout",function(){var z=W(" buildLayoutGraph",function(){return k(N)});W(" runLayout",function(){y(z,W)}),W(" updateInputGraph",function(){m(N,z)})})}function y(N,B){B(" makeSpaceForEdgeLabels",function(){j(N)}),B(" removeSelfEdges",function(){re(N)}),B(" acyclic",function(){t.run(N)}),B(" nestingGraph.run",function(){s.run(N)}),B(" rank",function(){n(f.asNonCompoundGraph(N))}),B(" injectEdgeLabelProxies",function(){P(N)}),B(" removeEmptyRanks",function(){a(N)}),B(" nestingGraph.cleanup",function(){s.cleanup(N)}),B(" normalizeRanks",function(){o(N)}),B(" assignRankMinMax",function(){R(N)}),B(" removeEdgeLabelProxies",function(){I(N)}),B(" normalize.run",function(){r.run(N)}),B(" parentDummyChains",function(){i(N)}),B(" addBorderSegments",function(){u(N)}),B(" order",function(){l(N)}),B(" insertSelfEdges",function(){ce(N)}),B(" adjustCoordinateSystem",function(){c.adjust(N)}),B(" position",function(){d(N)}),B(" positionSelfEdges",function(){le(N)}),B(" removeBorderNodes",function(){V(N)}),B(" normalize.undo",function(){r.undo(N)}),B(" fixupEdgeLabelCoords",function(){q(N)}),B(" undoCoordinateSystem",function(){c.undo(N)}),B(" translateGraph",function(){O(N)}),B(" assignNodeIntersects",function(){M(N)}),B(" reversePoints",function(){H(N)}),B(" acyclic.undo",function(){t.undo(N)})}function m(N,B){e.forEach(N.nodes(),function(W){var z=N.node(W),X=B.node(W);z&&(z.x=X.x,z.y=X.y,B.children(W).length&&(z.width=X.width,z.height=X.height))}),e.forEach(N.edges(),function(W){var z=N.edge(W),X=B.edge(W);z.points=X.points,e.has(X,"x")&&(z.x=X.x,z.y=X.y)}),N.graph().width=B.graph().width,N.graph().height=B.graph().height}var x=["nodesep","edgesep","ranksep","marginx","marginy"],g={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},w=["acyclicer","ranker","rankdir","align"],v=["width","height"],_={width:0,height:0},C=["minlen","weight","width","height","labeloffset"],S={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},T=["labelpos"];function k(N){var B=new p({multigraph:!0,compound:!0}),W=K(N.graph());return B.setGraph(e.merge({},g,be(W,x),e.pick(W,w))),e.forEach(N.nodes(),function(z){var X=K(N.node(z));B.setNode(z,e.defaults(be(X,v),_)),B.setParent(z,N.parent(z))}),e.forEach(N.edges(),function(z){var X=K(N.edge(z));B.setEdge(z,e.merge({},S,be(X,C),e.pick(X,T)))}),B}function j(N){var B=N.graph();B.ranksep/=2,e.forEach(N.edges(),function(W){var z=N.edge(W);z.minlen*=2,z.labelpos.toLowerCase()!=="c"&&(B.rankdir==="TB"||B.rankdir==="BT"?z.width+=z.labeloffset:z.height+=z.labeloffset)})}function P(N){e.forEach(N.edges(),function(B){var W=N.edge(B);if(W.width&&W.height){var z=N.node(B.v),X=N.node(B.w),se={rank:(X.rank-z.rank)/2+z.rank,e:B};f.addDummyNode(N,"edge-proxy",se,"_ep")}})}function R(N){var B=0;e.forEach(N.nodes(),function(W){var z=N.node(W);z.borderTop&&(z.minRank=N.node(z.borderTop).rank,z.maxRank=N.node(z.borderBottom).rank,B=e.max(B,z.maxRank))}),N.graph().maxRank=B}function I(N){e.forEach(N.nodes(),function(B){var W=N.node(B);W.dummy==="edge-proxy"&&(N.edge(W.e).labelRank=W.rank,N.removeNode(B))})}function O(N){var B=Number.POSITIVE_INFINITY,W=0,z=Number.POSITIVE_INFINITY,X=0,se=N.graph(),Q=se.marginx||0,G=se.marginy||0;function J(te){var de=te.x,fe=te.y,Ee=te.width,ge=te.height;B=Math.min(B,de-Ee/2),W=Math.max(W,de+Ee/2),z=Math.min(z,fe-ge/2),X=Math.max(X,fe+ge/2)}e.forEach(N.nodes(),function(te){J(N.node(te))}),e.forEach(N.edges(),function(te){var de=N.edge(te);e.has(de,"x")&&J(de)}),B-=Q,z-=G,e.forEach(N.nodes(),function(te){var de=N.node(te);de.x-=B,de.y-=z}),e.forEach(N.edges(),function(te){var de=N.edge(te);e.forEach(de.points,function(fe){fe.x-=B,fe.y-=z}),e.has(de,"x")&&(de.x-=B),e.has(de,"y")&&(de.y-=z)}),se.width=W-B+Q,se.height=X-z+G}function M(N){e.forEach(N.edges(),function(B){var W=N.edge(B),z=N.node(B.v),X=N.node(B.w),se,Q;W.points?(se=W.points[0],Q=W.points[W.points.length-1]):(W.points=[],se=X,Q=z),W.points.unshift(f.intersectRect(z,se)),W.points.push(f.intersectRect(X,Q))})}function q(N){e.forEach(N.edges(),function(B){var W=N.edge(B);if(e.has(W,"x"))switch((W.labelpos==="l"||W.labelpos==="r")&&(W.width-=W.labeloffset),W.labelpos){case"l":W.x-=W.width/2+W.labeloffset;break;case"r":W.x+=W.width/2+W.labeloffset;break}})}function H(N){e.forEach(N.edges(),function(B){var W=N.edge(B);W.reversed&&W.points.reverse()})}function V(N){e.forEach(N.nodes(),function(B){if(N.children(B).length){var W=N.node(B),z=N.node(W.borderTop),X=N.node(W.borderBottom),se=N.node(e.last(W.borderLeft)),Q=N.node(e.last(W.borderRight));W.width=Math.abs(Q.x-se.x),W.height=Math.abs(X.y-z.y),W.x=se.x+W.width/2,W.y=z.y+W.height/2}}),e.forEach(N.nodes(),function(B){N.node(B).dummy==="border"&&N.removeNode(B)})}function re(N){e.forEach(N.edges(),function(B){if(B.v===B.w){var W=N.node(B.v);W.selfEdges||(W.selfEdges=[]),W.selfEdges.push({e:B,label:N.edge(B)}),N.removeEdge(B)}})}function ce(N){var B=f.buildLayerMatrix(N);e.forEach(B,function(W){var z=0;e.forEach(W,function(X,se){var Q=N.node(X);Q.order=se+z,e.forEach(Q.selfEdges,function(G){f.addDummyNode(N,"selfedge",{width:G.label.width,height:G.label.height,rank:Q.rank,order:se+ ++z,e:G.e,label:G.label},"_se")}),delete Q.selfEdges})})}function le(N){e.forEach(N.nodes(),function(B){var W=N.node(B);if(W.dummy==="selfedge"){var z=N.node(W.e.v),X=z.x+z.width/2,se=z.y,Q=W.x-X,G=z.height/2;N.setEdge(W.e,W.label),N.removeNode(B),W.label.points=[{x:X+2*Q/3,y:se-G},{x:X+5*Q/6,y:se-G},{x:X+Q,y:se},{x:X+5*Q/6,y:se+G},{x:X+2*Q/3,y:se+G}],W.label.x=W.x,W.label.y=W.y}})}function be(N,B){return e.mapValues(e.pick(N,B),Number)}function K(N){var B={};return e.forEach(N,function(W,z){B[z.toLowerCase()]=W}),B}return du}var fu,ty;function JC(){if(ty)return fu;ty=1;var e=Be(),t=lr(),r=_r().Graph;fu={debugOrdering:n};function n(o){var i=t.buildLayerMatrix(o),a=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(s){a.setNode(s,{label:s}),a.setParent(s,"layer"+o.node(s).rank)}),e.forEach(o.edges(),function(s){a.setEdge(s.v,s.w,{},s.name)}),e.forEach(i,function(s,u){var c="layer"+u;a.setNode(c,{rank:"same"}),e.reduce(s,function(l,d){return a.setEdge(l,d,{style:"invis"}),d})}),a}return fu}var hu,ny;function YC(){return ny||(ny=1,hu="0.8.5"),hu}var pu,oy;function XC(){return oy||(oy=1,pu={graphlib:_r(),layout:ZC(),debug:JC(),util:{time:lr().time,notime:lr().notime},version:YC()}),pu}var QC=XC();const iy=$0(QC);function e_(e,t,r){var l;const n=new Set(e.map(d=>d.id)),o=new Set;for(const d of e)d.parent&&n.has(d.parent)&&o.add(d.parent);const i=new iy.graphlib.Graph({multigraph:!0,compound:!0}),a=r.compactSpacingScale??(r.spacingFactor>0?r.spacingFactor/1.3:1);i.setGraph({rankdir:r.rankDir,nodesep:r.compact?Math.max(r.nodeSep,24*a):r.nodeSep,edgesep:r.compact?Math.min(r.edgeSep,24*a):r.edgeSep,ranksep:r.compact?Math.min(r.rankSep,80*a):r.rankSep,ranker:"network-simplex"}),i.setDefaultEdgeLabel(()=>({})),i.setDefaultNodeLabel(()=>({}));for(const d of e)i.setNode(d.id,{width:d.width+2,height:d.height+2});for(const d of e)d.parent&&n.has(d.parent)&&i.setParent(d.id,d.parent);for(const d of t){if(!n.has(d.source)||!n.has(d.target)||o.has(d.source)||o.has(d.target))continue;const f=Rb(d.label,d.icon??((l=d.data)==null?void 0:l.icon),r.edgeLabelFontSize),p=r.rankDir==="LR"||r.rankDir==="RL",b=(f.width?f.width+2*Eb:0)+(d.connectorClearance??0);i.setEdge(d.source,d.target,{minlen:1,weight:1,...b?{width:p?b:Math.max(1,f.height),height:p?Math.max(1,f.height):b,labelpos:"c"}:{}},d.id)}iy.layout(i);const s=new Map;for(const d of e){if(o.has(d.id))continue;const f=i.node(d.id);f&&Number.isFinite(f.x)&&Number.isFinite(f.y)&&s.set(d.id,{x:f.x,y:f.y})}const u=r.compact?1:r.spacingFactor;if(u&&u!==1&&s.size){let d=1/0,f=1/0,p=-1/0,b=-1/0;s.forEach(x=>{d=Math.min(d,x.x),f=Math.min(f,x.y),p=Math.max(p,x.x),b=Math.max(b,x.y)});const y=(d+p)/2,m=(f+b)/2;s.forEach((x,g)=>s.set(g,{x:y+(x.x-y)*u,y:m+(x.y-m)*u}))}const c=r.nodeAlignment??"center";if(c!=="center"){const d=r.rankDir==="LR"||r.rankDir==="RL",f=d?"x":"y",p=d?"width":"height",b=r.rankDir==="RL"||r.rankDir==="BT"?-1:1,y=c==="leading"?-b:b,m=new Map;for(const x of e){const g=s.get(x.id);if(!g)continue;const w=g[f];m.set(w,Math.max(m.get(w)??0,x[p]))}for(const x of e){const g=s.get(x.id);if(!g)continue;const w=g[f],v=(m.get(w)-x[p])/2;s.set(x.id,{...g,[f]:w+y*v})}}return s}function r_(e,t,r,n,o){const i=new Map,a=new Map(e.map(l=>[l.id,l]));for(const l of e){if(!l.parent||!a.has(l.parent))continue;const d=i.get(l.parent);d?d.push(l.id):i.set(l.parent,[l.id])}const s=(l,d=new Set)=>{var p;const f=(p=a.get(l))==null?void 0:p.parent;return!f||!a.has(f)||d.has(l)?0:(d.add(l),1+s(f,d))},u=[...i.keys()].sort((l,d)=>s(d)-s(l)),c=new Map;for(const l of u){let d=null;for(const b of i.get(l)||[]){let y=c.get(b);if(!y){const m=t.get(b);if(!m)continue;const x=r.get(b)||{w:60,h:60};y={x1:m.x-x.w/2,y1:m.y-x.h/2,x2:m.x+x.w/2,y2:m.y+x.h/2}}d=d?{x1:Math.min(d.x1,y.x1),y1:Math.min(d.y1,y.y1),x2:Math.max(d.x2,y.x2),y2:Math.max(d.y2,y.y2)}:{...y}}if(!d)continue;const f=n(l);d={x1:d.x1-f,y1:d.y1-f,x2:d.x2+f,y2:d.y2+f};const p=o(l);if(p){const b=d.x2-d.x1,y=d.y2-d.y1;if(p.w>b){const m=(p.w-b)/2;d.x1-=m,d.x2+=m}if(p.h>y){const m=(p.h-y)/2;d.y1-=m,d.y2+=m}}c.set(l,d)}return c}function t_(e){const t=e.getBoundingClientRect(),r=t.height/e.offsetHeight;if(!Number.isFinite(r)||r<=0)return[];const n=Sb(e),o={x:e.offsetWidth/2,y:e.offsetHeight/2,w:e.offsetWidth,h:e.offsetHeight},i=[...e.querySelectorAll("[data-flow-property]")],a=new Set(i.filter(s=>s.hasAttribute("data-flow-inspection-row")&&s.getBoundingClientRect().height>0).map(s=>s.dataset.flowProperty));return i.flatMap(s=>{if(s.closest(".flow-sdk-node")!==e)return[];if(a.has(s.dataset.flowProperty)&&!s.hasAttribute("data-flow-inspection-row"))return[];const u=s.dataset.flowPortSide;if(u&&["top","right","bottom","left"].includes(u)){const l=wb(n?$t(o,n):o,u,Number(s.dataset.flowPortPosition??.5));return[{property:s.getAttribute("data-flow-property"),top:l.y,height:0,anchor:l,...s.dataset.flowPortPlacement==="config"?{placement:"config"}:{},...s.dataset.flowPortRole==="source"||s.dataset.flowPortRole==="target"?{role:s.dataset.flowPortRole}:{}}]}const c=s.getBoundingClientRect();return!c.width||!c.height?[]:[{property:s.getAttribute("data-flow-property"),top:Math.round((c.top-t.top)/r*1e3)/1e3,height:Math.round(c.height/r*1e3)/1e3,...s.dataset.flowPortRole==="source"||s.dataset.flowPortRole==="target"?{role:s.dataset.flowPortRole}:{}}]})}function n_({id:e,x:t,y:r,placed:n,hidden:o,onMount:i,drawHandles:a,drawMode:s,connectedPorts:u,resolvedRows:c,hasCollapseControl:l,handleColor:d,animated:f,animationColor:p,animationWidth:b=8,animationVariant:y,width:m=0,height:x=0,propertyMode:g,reversePorts:w,direction:v="LR",onPropertyRows:_,onSurface:C,children:S}){const T=E.useRef(null),[k,j]=E.useState([]),P=c??k,[R,I]=E.useState();return E.useLayoutEffect(()=>{const O=T.current;if(!O)return;const M=()=>{const V=Sb(O);I(re=>JSON.stringify(re)===JSON.stringify(V)?re:V),C==null||C(e,V)};M();const q=new ResizeObserver(M);q.observe(O);const H=O.querySelector("[data-flow-node-surface]");return H&&q.observe(H),()=>q.disconnect()},[e,S,C]),E.useLayoutEffect(()=>(i(e,T.current),()=>{i(e,null),C==null||C(e,void 0)}),[e,i,C]),E.useLayoutEffect(()=>{const O=T.current;if(!O)return;let M="";const q=()=>{const ce=t_(O),le=g?ce:ce.filter(K=>K.anchor),be=JSON.stringify(le);be!==M&&(M=be,j(le),_==null||_(e,le))};if(q(),!g&&!O.querySelector("[data-flow-port-side]"))return;const H=new ResizeObserver(q),V=()=>{H.disconnect(),H.observe(O),O.querySelectorAll("[data-flow-property]").forEach(ce=>H.observe(ce)),q()};V();const re=new MutationObserver(V);return re.observe(O,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["data-flow-property","data-flow-port-role","data-flow-port-side","data-flow-port-position","data-flow-port-placement"]}),O.addEventListener("scroll",q,!0),()=>{H.disconnect(),re.disconnect(),O.removeEventListener("scroll",q,!0)}},[e,g,_,S]),h.jsxs("div",{ref:T,className:"flow-sdk-node","data-node-id":e,style:{transform:`translate(-50%, -50%) translate3d(${t.toFixed(2)}px, ${r.toFixed(2)}px, 0)`,visibility:n&&!o?void 0:"hidden"},children:[S,f&&b>0&&m>0&&x>0&&h.jsx("svg",{className:"flow-sdk-node-animation","aria-hidden":"true",pointerEvents:"none",children:h.jsx(xb,{variant:y,x:((R==null?void 0:R.left)??0)+b/2,y:((R==null?void 0:R.top)??0)+b/2,width:((R==null?void 0:R.width)??m)-b,height:((R==null?void 0:R.height)??x)-b,radius:((R==null?void 0:R.radius)??0)-b/2,path:R!=null&&R.outline?`M${R.outline.map(O=>`${O.x} ${O.y}`).join(" L")} Z`:void 0,color:p||d||"currentColor",strokeWidth:b})}),a&&g&&P.map(O=>["source","target"].filter(M=>!O.role||O.role===M).filter(M=>s||(u==null?void 0:u.has(`${M}:${O.property}`))).map(M=>{var q;return h.jsx("button",{type:"button",className:"flow-sdk-property-port","data-property":O.property,"data-port-role":M,"data-port-side":(q=O.anchor)==null?void 0:q.side,"aria-label":`${M==="source"?"Connect":"Input"} ${O.property}`,title:`${M==="source"?"Connect":"Input"} ${O.property}`,style:{color:d,...O.anchor?{top:O.anchor.y,left:O.anchor.x-16}:{top:O.top+O.height/2,[M==="source"!=!!w?"right":"left"]:-16}},onClick:H=>H.stopPropagation()},`${O.property}:${M}`)})),a&&!l&&(!g||!P.length)&&(!g||!P.some(O=>O.anchor))&&h.jsx("button",{type:"button",className:"flow-sdk-handle","aria-label":"Draw edge",title:"Draw edge",style:{color:d,left:((R==null?void 0:R.left)??0)+(v==="RL"?-36:v==="LR"?(R==null?void 0:R.width)??m:((R==null?void 0:R.width)??m)/2),top:((R==null?void 0:R.top)??0)+(v==="BT"?-36:v==="TB"?(R==null?void 0:R.height)??x:((R==null?void 0:R.height)??x)/2),transform:v==="BT"||v==="TB"?"translateX(-50%)":"translateY(-50%)"},onClick:O=>O.stopPropagation(),children:h.jsx(Z.PiPlusBold,{size:24})})]})}const o_=E.memo(n_);class i_{constructor(t,r,n){Ar(this,"_pan");Ar(this,"_zoom");Ar(this,"minZoom");Ar(this,"maxZoom");Ar(this,"size",{w:0,h:0});Ar(this,"listeners",new Set);Ar(this,"animationFrame");Ar(this,"animationTimer");this.minZoom=r,this.maxZoom=n,this._pan={...t.pan},this._zoom=this.clamp(t.zoom)}cancelAnimation(){this.animationFrame!==void 0&&cancelAnimationFrame(this.animationFrame),clearTimeout(this.animationTimer),this.animationFrame=void 0,this.animationTimer=void 0}transition(t,r=!1){if(this.cancelAnimation(),!r||typeof requestAnimationFrame>"u"||typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches){this.set(t.pan,t.zoom);return}const n=this.state,o={pan:{...t.pan},zoom:this.clamp(t.zoom)},i=performance.now(),a=()=>{this.cancelAnimation(),this.set(o.pan,o.zoom)},s=u=>{const c=Math.min(1,(u-i)/300);if(c>=1){a();return}const l=c*c*(3-2*c);this.apply({x:n.pan.x+(o.pan.x-n.pan.x)*l,y:n.pan.y+(o.pan.y-n.pan.y)*l},n.zoom+(o.zoom-n.zoom)*l),this.animationFrame=requestAnimationFrame(s)};this.animationFrame=requestAnimationFrame(s),this.animationTimer=setTimeout(a,400)}get pan(){return{...this._pan}}get zoom(){return this._zoom}get state(){return{pan:this.pan,zoom:this._zoom}}clamp(t){return Number.isFinite(t)?Math.max(this.minZoom,Math.min(this.maxZoom,t)):this.minZoom}set(t,r){this.cancelAnimation(),this.apply(t,r)}apply(t,r){let n=!1;if(t&&(t.x!==this._pan.x||t.y!==this._pan.y)&&(this._pan={x:t.x,y:t.y},n=!0),r!==void 0){const o=this.clamp(r);o!==this._zoom&&(this._zoom=o,n=!0)}n&&this.emit()}zoomAt(t,r){const n=this.clamp(t),o=this._zoom;if(n===o)return;const i=n/o;this.set({x:r.x-(r.x-this._pan.x)*i,y:r.y-(r.y-this._pan.y)*i},n)}fit(t,r=0,n=!1){const o=t.x2-t.x1,i=t.y2-t.y1;if(!(o>0)||!(i>0)||!this.size.w||!this.size.h)return;const a=this.clamp(Math.min((this.size.w-2*r)/o,(this.size.h-2*r)/i));this.transition({pan:{x:(this.size.w-a*(t.x1+t.x2))/2,y:(this.size.h-a*(t.y1+t.y2))/2},zoom:a},n)}center(t,r=!1){if(!this.size.w||!this.size.h)return;const n=this._zoom;this.transition({pan:{x:(this.size.w-n*(t.x1+t.x2))/2,y:(this.size.h-n*(t.y1+t.y2))/2},zoom:n},r)}renderedToModel(t){return{x:(t.x-this._pan.x)/this._zoom,y:(t.y-this._pan.y)/this._zoom}}modelToRendered(t){return{x:t.x*this._zoom+this._pan.x,y:t.y*this._zoom+this._pan.y}}onChange(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}emit(){const t=this.state;this.listeners.forEach(r=>r(t))}}const a_={LR:"rightward",RL:"leftward",TB:"downward",BT:"upward"},gu={w:60,h:60},ay=4,s_=30,sy=300,c_=500,u_=45,l_=e=>e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2;function cy(e){const[t,r]=[...e.values()];return!t||!r?null:{center:{x:(t.x+r.x)/2,y:(t.y+r.y)/2},distance:Math.max(1,Math.hypot(r.x-t.x,r.y-t.y))}}function d_(e){const{nodes:t,edges:r,direction:n,nodeAlignment:o="center",edgeMode:i="auto",compactPropertyLayout:a=!1,rankSep:s,edgeSep:u,spacingFactor:c=1.3,compactSpacingScale:l,minZoom:d,maxZoom:f,initialViewport:p,containerStyle:b,lineColor:y,drawMode:m,dragMode:x,multiSelect:g,isPerformanceMode:w}=e,[v,_]=E.useState(null),C=E.useMemo(()=>v?(v.mode==="connections"?ql:Pl)(v.id,t,r):null,[v,t,r]),S=i==="auto"||i==="properties",T=E.useMemo(()=>r.filter(A=>wu(A,i)&&(!C||C.has(A.source)&&C.has(A.target))),[r,i,C]),k=E.useMemo(()=>T0(t,r,i,a,C),[t,r,i,a,C]),j=E.useRef(k);j.current=k;const P=E.useRef(e);P.current=e;const R=E.useRef(null),I=E.useRef(null),O=E.useRef(null),M=E.useRef(null),q=E.useMemo(()=>new i_(p,d,f),[]);E.useEffect(()=>{q.minZoom=d,q.maxZoom=f},[q,d,f]);const H=E.useRef(new Map),V=E.useRef(new Map),re=E.useRef(new Map),ce=E.useRef(null),[le,be]=E.useState(new Map),K=E.useCallback((A,$)=>{be(L=>{if(JSON.stringify(L.get(A))===JSON.stringify($))return L;const U=new Map(L);return $?U.set(A,$):U.delete(A),U})},[]),[N,B]=E.useState(new Map),W=E.useRef(N),z=E.useCallback((A,$)=>{B(L=>{if(JSON.stringify(L.get(A)??[])===JSON.stringify($))return L;const U=new Map(L);return $.length?U.set(A,$):U.delete(A),U})},[]),[X,se]=E.useState(()=>new Map),Q=E.useRef(X);Q.current=X;const G=E.useRef(new Map),J=E.useRef(!1),[te,de]=E.useState(0),fe=E.useRef(),Ee=E.useRef(),ge=E.useRef(null),We=E.useRef(),me=E.useRef(!1),Te=E.useRef(null),er=E.useRef(c),De=a&&(i==="properties"||!!C),Ne=E.useRef(De),[He,rr]=E.useState(!0),ze=E.useRef(null);ze.current=C;const xr=E.useRef(1);xr.current=(v==null?void 0:v.mode)==="connections"?1.25:1;const Ze=E.useRef(null),pr=E.useRef(t),dr=E.useRef([]),jr=E.useRef(!1),we=()=>{ge.current!==null&&cancelAnimationFrame(ge.current),ge.current=null,clearTimeout(We.current)},or=()=>{dr.current.length&&(jr.current=!0),!J.current&&P.current.fitOnInit!==!1&&(me.current=!0),clearTimeout(Ee.current),Ee.current=setTimeout(()=>{J.current=!0,de(A=>A+1)},c_)},ar=A=>{we();const $=new Map(Q.current),L=performance.now(),U=()=>{we(),se(A),or()},oe=he=>{const Re=Math.min(1,(he-L)/sy);if(Re>=1)return U();const Ae=l_(Re),ie=new Map;A.forEach((ae,ue)=>{const ye=$.get(ue);ie.set(ue,ye?{x:ye.x+(ae.x-ye.x)*Ae,y:ye.y+(ae.y-ye.y)*Ae}:ae)}),se(ie),ge.current=requestAnimationFrame(oe)};ge.current=requestAnimationFrame(oe),We.current=setTimeout(U,sy+100)},xt=()=>{const A=P.current,$=xr.current,L=j.current,U=L.nodes.map(he=>{const Re=H.current.get(he.id)||gu;return{id:he.id,parent:he.parent,width:Re.w,height:Re.h}});let oe;try{const he=A.compactPropertyLayout&&(A.edgeMode==="properties"||!!ze.current),Re=A.edgeMode!=="nodes"&&A.edgeMode!=="workflow",Ae=L.edges.map(ie=>({...ie,connectorClearance:he?Re&&(ie.sourceProperty!==void 0||ie.targetProperty!==void 0)?A0:P0:0}));oe=e_(U,Ae,{edgeLabelFontSize:A.edgeMode==="nodes"||A.edgeMode==="workflow"?jb:fn,rankDir:A.direction,compact:he,nodeAlignment:A.nodeAlignment,rankSep:A.rankSep*$,edgeSep:A.edgeSep*$,nodeSep:5*$,spacingFactor:A.spacingFactor??1.3,compactSpacingScale:(A.compactSpacingScale??(A.spacingFactor??1.3)/1.3)*$})}catch(he){console.warn("[flow-sdk] layout failed",he);return}for(const[he,Re]of G.current)oe.has(he)?oe.set(he,Re):A.nodes.some(Ae=>Ae.id===he)||G.current.delete(he);J.current&&!A.isPerformanceMode?ar(oe):(we(),se(oe),or())},ne=E.useCallback(()=>{clearTimeout(Ee.current),clearTimeout(fe.current),fe.current=setTimeout(xt,P.current.layoutDebounce)},[]);E.useEffect(()=>{const A=new Map(pr.current.map($=>[$.id,$]));t.some($=>{var L;return((L=A.get($.id))==null?void 0:L.collapsed)===!0&&!$.collapsed})&&(dr.current=t.filter($=>!A.has($.id)).map($=>$.id)),pr.current=t,er.current!==c&&Q.current.size>0&&(J.current=!0,me.current=!1,clearTimeout(Ee.current)),er.current=c,Ne.current!==De&&(me.current=!Te.current),Ne.current=De,ne()},[t,r,k.nodes,k.edges,De,n,o,s,u,ne,c,l]),E.useEffect(()=>()=>{clearTimeout(fe.current),clearTimeout(Ee.current),we()},[]);const Fe=E.useCallback((A,$)=>{var L,U;if(!ce.current&&typeof ResizeObserver<"u"&&(ce.current=new ResizeObserver(oe=>{let he=!1;for(const Re of oe){const Ae=re.current.get(Re.target);if(!Ae)continue;const ie=Re.target,ae=ie.offsetWidth,ue=ie.offsetHeight;if(!ae&&!ue)continue;const ye=H.current.get(Ae);ye&&ye.w===ae&&ye.h===ue||(H.current.set(Ae,{w:ae,h:ue}),he=!0)}he&&ne()})),$){V.current.set(A,$),re.current.set($,A),(L=ce.current)==null||L.observe($);const oe=$.offsetWidth,he=$.offsetHeight;(oe||he)&&H.current.set(A,{w:oe,h:he})}else{const oe=V.current.get(A);oe&&((U=ce.current)==null||U.unobserve(oe),re.current.delete(oe)),V.current.delete(A),H.current.delete(A),W.current.has(A)&&z(A,[])}ne()},[ne,z]);E.useEffect(()=>()=>{var A;return(A=ce.current)==null?void 0:A.disconnect()},[]);const Je=E.useMemo(()=>{const A=new Map;for(const $ of t)$.label&&A.set($.id,$.label);return A},[t]),$e=E.useMemo(()=>r_(k.nodes,X,H.current,A=>b(A).padding,A=>{const $=Je.get(A);if(!$)return;const L=b(A);return{w:Cn($,`bold ${L.fontSize}px ${Qr}`)+2*u_,h:0}}),[k.nodes,X,b,Je]),Xe=E.useRef($e);Xe.current=$e;const Y=E.useCallback(A=>{const $=Xe.current.get(A);if($)return g0($);const L=Q.current.get(A);if(!L)return;const U=H.current.get(A)||gu;return{x:L.x,y:L.y,w:U.w,h:U.h}},[]),D=E.useMemo(()=>{const A=new Map;for(const $ of t){const L=Y($.id);L&&A.set($.id,L)}return S0(N,A,le,r,n)},[N,t,X,$e,le,r,n,Y]);W.current=D;const ee=(A,$)=>{var oe;if(!S||$===void 0)return;const L=(oe=D.get(A))==null?void 0:oe.find(he=>he.property===$),U=Y(A);return L&&!L.anchor&&U?U.y-U.h/2+L.top+L.height/2:void 0},Ce=(A,$)=>{var oe,he;if($===void 0)return;const L=(he=(oe=D.get(A))==null?void 0:oe.find(Re=>Re.property===$))==null?void 0:he.anchor,U=Y(A);return L&&U?{x:U.x-U.w/2+L.x,y:U.y-U.h/2+L.y,side:L.side}:void 0},_e=(A,$)=>{const L=Y(A),U=le.get(A);return L&&U&&!$e.has(A)&&ee(A,$)===void 0?$t(L,U):L},Se=()=>{const A=[];Q.current.forEach(($,L)=>{if(Xe.current.has(L))return;const U=H.current.get(L)||gu;A.push(at({x:$.x,y:$.y,w:U.w,h:U.h}))}),Xe.current.forEach($=>A.push($));try{for(const $ of[I.current,O.current]){const L=$==null?void 0:$.getBBox();L&&L.width>0&&L.height>0&&A.push({x1:L.x,y1:L.y,x2:L.x+L.width,y2:L.y+L.height})}}catch{}return Jn(A)},Ge=()=>{var L,U;const{pan:A,zoom:$}=q;M.current&&(M.current.style.transform=`translate3d(${A.x}px, ${A.y}px, 0) scale(${$})`),(L=I.current)==null||L.setAttribute("transform",`translate(${A.x} ${A.y}) scale(${$})`),(U=O.current)==null||U.setAttribute("transform",`translate(${A.x} ${A.y}) scale(${$})`)};E.useEffect(()=>{Ge();let A=null,$;const L=q.onChange(()=>{Ge();const U=R.current;U&&(U.classList.add("flow-sdk-busy"),clearTimeout($),$=setTimeout(()=>U.classList.remove("flow-sdk-busy"),150)),A===null&&(A=requestAnimationFrame(()=>{var oe,he;A=null,(he=(oe=P.current).onViewportChange)==null||he.call(oe,q.state)}))});return()=>{L(),clearTimeout($),A!==null&&cancelAnimationFrame(A)}},[]),E.useLayoutEffect(()=>{const A=R.current;if(!A)return;const $=()=>{let U=A.clientWidth,oe=A.clientHeight;oe||(oe=Math.max(0,window.innerHeight-A.getBoundingClientRect().top-100),oe&&(A.style.height=`${oe}px`)),U||(U=window.innerWidth,U&&(A.style.width=`${U}px`)),q.size={w:U,h:oe}};if($(),typeof ResizeObserver>"u")return;const L=new ResizeObserver($);return L.observe(A),()=>L.disconnect()},[q]),E.useEffect(()=>{if(jr.current){jr.current=!1;const $=dr.current.flatMap(U=>{const oe=Y(U);return oe?[at(oe)]:[]});dr.current=[];const L=Jn($);if(L){me.current=!1,q.center(L,P.current.animateViewport);return}}if(!me.current)return;me.current=!1;const A=Se();A&&q.fit(A,50,P.current.animateViewport)},[X]);const Le=E.useMemo(()=>{const A=ie=>Pl(ie,P.current.nodes,P.current.edges),$=(ie,ae=50,ue=P.current.animateViewport)=>{const ye=Jn([...ie].flatMap(sr=>{const wt=Y(sr);return wt?[at(wt)]:[]}));ye&&(me.current=!1,q.fit(ye,Number.isFinite(ae)?Math.max(0,ae):50,ue))},L=(ie,ae,ue,ye)=>{if(!Y(ie))return;const sr=ae==="connections"?oe(ie):A(ie);Ze.current||(Ze.current={pan:{...q.pan},zoom:q.zoom}),ze.current=sr,P.current.compactPropertyLayout&&(me.current=!1,Te.current=()=>$(ze.current??sr,ue,ye)),_({id:ie,mode:ae}),P.current.compactPropertyLayout||$(sr,ue,ye)},U=ie=>{Te.current?Te.current=ie:ie()},oe=ie=>ql(ie,P.current.nodes,P.current.edges),he=(ie=>{if(ie===void 0)return q.zoom;q.set(void 0,ie)}),Re=(ie=>{if(ie===void 0)return q.pan;q.set(ie)}),Ae=(ie,ae)=>{var ye;const ue=(ye=R.current)==null?void 0:ye.getBoundingClientRect();return{x:ie-((ue==null?void 0:ue.left)??0),y:ae-((ue==null?void 0:ue.top)??0)}};return{zoom:he,pan:Re,setEdgesVisible:rr,focusNode:(ie,ae,ue)=>U(()=>$(new Set([ie]),ae,ue)),focusBranch:(ie,ae,ue)=>U(()=>$(A(ie),ae,ue)),focusConnections:(ie,ae,ue)=>U(()=>$(oe(ie),ae,ue)),isolateConnections:(ie,ae,ue)=>L(ie,"connections",ae,ue),isolateBranch:(ie,ae,ue)=>L(ie,"branch",ae,ue),restoreView:(ie=P.current.animateViewport)=>{const ae=P.current.compactPropertyLayout&&!!ze.current;ze.current=null,_(null);const ue=Ze.current;Ze.current=null,ae?Te.current=()=>{ue&&q.transition(ue,ie)}:ue&&U(()=>q.transition(ue,ie))},zoomAt:(ie,ae)=>q.zoomAt(ie,ae),fit:(ie=0,ae=P.current.animateViewport)=>{U(()=>{const ue=Se();ue&&q.fit(ue,ie,ae)})},centerAndFit:(ie=0,ae=P.current.animateViewport)=>{U(()=>{const ue=Se();ue&&q.fit(ue,ie,ae)})},center:(ie=P.current.animateViewport)=>{const ae=Se();ae&&q.center(ae,ie)},clientToModel:(ie,ae)=>q.renderedToModel(Ae(ie,ae)),modelToClient:ie=>{var ye;const ae=(ye=R.current)==null?void 0:ye.getBoundingClientRect(),ue=q.modelToRendered(ie);return{x:ue.x+((ae==null?void 0:ae.left)??0),y:ue.y+((ae==null?void 0:ae.top)??0)}},getNodeBox:ie=>Y(ie),setNodePosition:(ie,ae,ue)=>{if(!Q.current.has(ie)||ae&&(!Number.isFinite(ae.x)||!Number.isFinite(ae.y)))return!1;if(we(),!ae)return G.current.delete(ie),ne(),!0;const ye=new Map(Q.current);return ye.set(ie,{...ae}),(ue==null?void 0:ue.persist)===!1?G.current.delete(ie):G.current.set(ie,{...ae}),Q.current=ye,se(ye),(ue==null?void 0:ue.persist)===!1&&ne(),!0},onViewportChange:ie=>q.onChange(ie)}},[]);E.useEffect(()=>{var A,$;return($=(A=P.current).onInit)==null||$.call(A,Le),()=>q.cancelAnimation()},[Le]),E.useEffect(()=>{var A,$;if(te>0){const L=Te.current;Te.current=null,L==null||L(),($=(A=P.current).onLayoutComplete)==null||$.call(A,Le)}},[Le,te]);const ke=E.useRef(null),Me=E.useRef(new Map),gr=E.useRef(!1),[Ye,yr]=E.useState(null),[Oe,wr]=E.useState(null),$r=A=>{const $=R.current.getBoundingClientRect();return{x:A.clientX-$.left,y:A.clientY-$.top}},zn=(A,$)=>{const L=P.current.nodes;for(let U=L.length-1;U>=0;U--){const oe=L[U].id;if(!st(oe,P.current.edges,P.current.edgeMode)||ze.current&&!ze.current.has(oe)||oe===$||Xe.current.has(oe))continue;const he=Y(oe);if(he&&Al(A,at(he)))return oe}for(const[U,oe]of Xe.current)if(st(U,P.current.edges,P.current.edgeMode)&&!(ze.current&&!ze.current.has(U))&&U!==$&&Al(A,oe))return U;return null},Vn=(A,$)=>{if(P.current.edgeMode==="nodes"||P.current.edgeMode==="workflow")return null;const L=P.current.direction==="RL",U=Math.max(16,6/q.zoom);let oe=null;for(const he of[...P.current.nodes].reverse()){if(!st(he.id,P.current.edges,P.current.edgeMode)||ze.current&&!ze.current.has(he.id))continue;const Re=Y(he.id),Ae=W.current.get(he.id);if(!Re||!Ae||Xe.current.has(he.id))continue;const ie=Re.x+($==="source"!==L?1:-1)*Re.w/2;for(const ae of Ae){if(ae.role&&ae.role!==$)continue;const ue=Re.y-Re.h/2+ae.top,ye=Math.hypot(A.x-(ae.anchor?Re.x-Re.w/2+ae.anchor.x:ie),A.y-ue-ae.height/2);if(!ae.anchor&&A.x>=Re.x-Re.w/2&&A.x<=Re.x+Re.w/2&&A.y>=ue&&A.y<=ue+ae.height)return{nodeId:he.id,property:ae.property};ye<=U&&(!oe||ye<oe.distance)&&(oe={nodeId:he.id,property:ae.property,distance:ye})}}return oe},Lm=A=>{var Re;if(!A.currentTarget.contains(A.target)||A.button!==0||P.current.readOnly)return;ke.current||(gr.current=!1);const $=A.target;if($.closest('input, textarea, select, [contenteditable="true"], [data-flow-content-toggle]'))return;const L=P.current,U=$r(A);if(A.pointerType==="touch"){Me.current.set(A.pointerId,U);const Ae=cy(Me.current);if(Ae){ke.current={kind:"pinch",distance:Ae.distance,zoom:q.zoom,anchor:q.renderedToModel(Ae.center)},wr(null),yr(null),gr.current=!0;for(const ie of Me.current.keys())A.currentTarget.setPointerCapture(ie);return}}if(ke.current)return;const oe=L.drawHandles&&$.closest(".flow-sdk-handle"),he=L.drawHandles&&$.closest(".flow-sdk-property-port");if(L.drawMode||oe||he){const Ae=q.renderedToModel(U),ie=L.drawMode?Vn(Ae,"source"):null,ae=he||oe,ue=ae?(Re=ae.closest("[data-node-id]"))==null?void 0:Re.dataset.nodeId:(ie==null?void 0:ie.nodeId)??zn(Ae),ye=he?he.dataset.property:ie==null?void 0:ie.property;if(ue){ke.current={kind:"draw",pointerId:A.pointerId,source:ue,sourceProperty:ye,reverse:(he==null?void 0:he.dataset.portRole)==="target",startClient:{x:A.clientX,y:A.clientY}},gr.current=!0,wr({source:ue,sourceProperty:ye,point:Ae,target:null}),A.currentTarget.setPointerCapture(A.pointerId);return}}$.closest(".flow-sdk-node, .flow-sdk-container, .flow-sdk-edge, .flow-sdk-edge-label, .flow-sdk-container-label")||(L.multiSelect?ke.current={kind:"box",pointerId:A.pointerId,start:U,current:U}:L.dragMode?ke.current={kind:"pan",pointerId:A.pointerId,start:U,pan0:q.pan,moved:!1}:ke.current={kind:"tap",pointerId:A.pointerId,start:U,moved:!1},A.currentTarget.setPointerCapture(A.pointerId))},Fm=A=>{const $=ke.current;if(!$||P.current.readOnly)return;const L=$r(A);if(Me.current.has(A.pointerId)&&Me.current.set(A.pointerId,L),$.kind==="pinch"){const U=cy(Me.current);if(!U)return;const oe=Math.max(q.minZoom,Math.min(q.maxZoom,$.zoom*U.distance/$.distance));q.set({x:U.center.x-$.anchor.x*oe,y:U.center.y-$.anchor.y*oe},oe);return}if($.pointerId===A.pointerId)switch($.kind){case"pan":{const U=L.x-$.start.x,oe=L.y-$.start.y;if(!$.moved&&Math.hypot(U,oe)<=ay)return;$.moved=!0,gr.current=!0,q.set({x:$.pan0.x+U,y:$.pan0.y+oe});break}case"tap":{Math.hypot(L.x-$.start.x,L.y-$.start.y)>ay&&($.moved=!0);break}case"box":{gr.current=!0,$.current=L,yr({x1:Math.min($.start.x,L.x),y1:Math.min($.start.y,L.y),x2:Math.max($.start.x,L.x),y2:Math.max($.start.y,L.y)});break}case"draw":{const U=q.renderedToModel(L),oe=Vn(U,$.reverse?"source":"target");wr($.reverse&&oe?{source:oe.nodeId,sourceProperty:oe.property,point:U,target:$.source,targetProperty:$.sourceProperty}:{source:$.source,sourceProperty:$.sourceProperty,point:U,target:(oe==null?void 0:oe.nodeId)??zn(U,$.source),targetProperty:oe==null?void 0:oe.property});break}}},ol=(A,$)=>{var oe,he,Re,Ae,ie;Me.current.delete(A.pointerId);const L=ke.current;if(!L)return;if(L.kind==="pinch"){const ae=[...Me.current][0];ke.current=ae&&P.current.dragMode&&!$?{kind:"pan",pointerId:ae[0],start:ae[1],pan0:q.pan,moved:!0}:null;return}if(L.pointerId!==A.pointerId)return;ke.current=null;try{A.currentTarget.releasePointerCapture(A.pointerId)}catch{}const U=P.current;switch($=$||!!U.readOnly,L.kind){case"pan":case"tap":!$&&!L.moved&&((oe=U.onBackgroundTap)==null||oe.call(U));break;case"box":{if(yr(null),$)break;const ae=q.renderedToModel(L.start),ue=q.renderedToModel(L.current),ye={x1:Math.min(ae.x,ue.x),y1:Math.min(ae.y,ue.y),x2:Math.max(ae.x,ue.x),y2:Math.max(ae.y,ue.y)};if(ye.x2-ye.x1<1&&ye.y2-ye.y1<1){(he=U.onBackgroundTap)==null||he.call(U);break}const sr=[];for(const wt of U.nodes){const sl=Y(wt.id);sl&&y0(at(sl),ye)&&sr.push(wt.id)}sr.length&&((Re=U.onBoxSelect)==null||Re.call(U,sr));break}case"draw":{if(wr(null),$)break;const ae=$r(A),ue=q.renderedToModel(ae),ye=Vn(ue,L.reverse?"source":"target"),sr=(ye==null?void 0:ye.nodeId)??zn(ue);if(sr===L.source&&(L.sourceProperty===void 0||(ye==null?void 0:ye.property)===void 0||ye.property===L.sourceProperty))break;sr?(Ae=U.onEdgeDraw)==null||Ae.call(U,L.reverse?sr:L.source,L.reverse?L.source:sr,L.sourceProperty!==void 0||(ye==null?void 0:ye.property)!==void 0?{sourceProperty:L.reverse?ye==null?void 0:ye.property:L.sourceProperty,targetProperty:L.reverse?L.sourceProperty:ye==null?void 0:ye.property}:void 0):Math.max(Math.abs(A.clientX-L.startClient.x),Math.abs(A.clientY-L.startClient.y))>s_&&((ie=U.onDrawIntoSpace)==null||ie.call(U,L.source,ue,L.sourceProperty,L.reverse));break}}},Ur=E.useCallback(()=>{var L;const A=ke.current,$=[...Me.current.keys()];A&&A.kind!=="pinch"&&$.push(A.pointerId),ke.current=null,Me.current.clear(),wr(null),yr(null);for(const U of $)(L=R.current)!=null&&L.hasPointerCapture(U)&&R.current.releasePointerCapture(U)},[]);E.useEffect(()=>{const A=$=>{$.key==="Escape"&&Ur()};return window.addEventListener("keydown",A),window.addEventListener("blur",Ur),()=>{window.removeEventListener("keydown",A),window.removeEventListener("blur",Ur),ke.current=null,Me.current.clear()}},[Ur]),E.useEffect(()=>{Ur()},[m,x,g,i,n,e.drawHandles,e.readOnly,Ur]);const Bm=E.useMemo(()=>{const A=new Map,$=new Map;for(const L of T){if(L.source!==L.target)continue;const U=A.get(L.source)??0;A.set(L.source,U+1),$.set(L.id,U)}return $},[T]),Wn=a_[n],[Gn,Dm]=E.useState(null);E.useLayoutEffect(()=>{R.current&&Gn&&N0(R.current)});const Un=p0(T,_e,Wn),zm=e.onEdgeSelect,Vm=e.onContainerSelect,il=Oe?Oe.target&&_e(Oe.target,Oe.targetProperty)||{x:Oe.point.x,y:Oe.point.y,w:1,h:1}:null,al=Oe?_e(Oe.source,Oe.sourceProperty):null,Wm=["flow-sdk-canvas",m?"flow-sdk-draw":"",w?"flow-sdk-perf":""].filter(Boolean).join(" ");return h.jsxs("div",{ref:R,className:Wm,"data-edge-mode":i,onPointerDownCapture:Lm,onPointerMove:Fm,onPointerUp:A=>ol(A,!1),onPointerCancel:A=>ol(A,!0),onLostPointerCapture:A=>{const $=ke.current;$&&($.kind==="pinch"||$.pointerId===A.pointerId)&&Ur()},onClickCapture:A=>{A.currentTarget.contains(A.target)&&(gr.current||e.readOnly)&&(A.preventDefault(),A.stopPropagation())},children:[h.jsx("svg",{className:"flow-sdk-svg",children:h.jsxs("g",{ref:I,children:[h.jsx("g",{className:"flow-sdk-containers",children:[...$e].filter(([A])=>st(A,r,i)).filter(([A])=>!C||C.has(A)).map(([A,$])=>{var L;return h.jsx(k0,{id:A,rect:$,label:Je.get(A),labelLayer:Gn,style:b(A),onSelect:Vm,onCollapse:e.readOnly?void 0:e.onContainerCollapse,selected:(L=e.selectedNodeIds)==null?void 0:L.includes(A)},A)})}),h.jsx("g",{className:"flow-sdk-edges",children:He&&T.map(A=>{var U,oe,he;if(C&&(!C.has(A.source)||!C.has(A.target)))return null;const $=_e(A.source,A.sourceProperty),L=_e(A.target,A.targetProperty);return!$||!L?null:h.jsx(Nl,{id:A.id,edgeData:A.data,validationIssue:A.validationIssue,edgeType:A.type,edgeRadius:e.edgeRadius,propertyMode:S,customEdgeTypes:e.customEdgeTypes,source:$,target:L,sourceProperty:A.sourceProperty,targetProperty:A.targetProperty,sourceY:ee(A.source,A.sourceProperty),targetY:ee(A.target,A.targetProperty),sourcePort:Ce(A.source,A.sourceProperty),targetPort:Ce(A.target,A.targetProperty),dir:Wn,turn:((U=Un.get(A.id))==null?void 0:U.turn)??A.turn,labelAtTarget:(oe=Un.get(A.id))==null?void 0:oe.labelAtTarget,labelFraction:(he=Un.get(A.id))==null?void 0:he.labelFraction,color:A.color,labelBg:A.labelBg,label:A.label,labelLayer:Gn,dashed:A.dashed,animated:A.animated&&!w,inverted:A.inverted,loopIndex:Bm.get(A.id)??0,onSelect:zm},A.id)})}),He&&Oe&&wu(Oe,i)&&al&&il&&h.jsx("g",{className:"flow-sdk-ghost",pointerEvents:"none",children:h.jsx(Nl,{id:"__flow-sdk-ghost",edgeData:{id:"__flow-sdk-ghost",source:Oe.source,target:Oe.target??"",sourceProperty:Oe.sourceProperty,targetProperty:Oe.targetProperty},edgeType:e.edgeType,edgeRadius:e.edgeRadius,propertyMode:S,customEdgeTypes:e.customEdgeTypes,source:al,target:il,sourceProperty:Oe.sourceProperty,targetProperty:Oe.targetProperty,sourceY:ee(Oe.source,Oe.sourceProperty),sourcePort:Ce(Oe.source,Oe.sourceProperty),targetPort:Oe.target?Ce(Oe.target,Oe.targetProperty):void 0,targetY:Oe.target?ee(Oe.target,Oe.targetProperty):void 0,dir:Wn,turn:.5,color:y,labelBg:y})})]})}),h.jsx("div",{ref:M,className:"flow-sdk-nodes",children:t.map(A=>{var he,Re;const $=X.get(A.id),L=$e.get(A.id),U=($==null?void 0:$.x)??(L?(L.x1+L.x2)/2:0),oe=($==null?void 0:$.y)??(L?(L.y1+L.y2)/2:0);return h.jsx(o_,{id:A.id,x:U,y:oe,placed:!!$||!!L,hidden:!st(A.id,r,i)||!!C&&!C.has(A.id),onMount:Fe,drawHandles:e.drawHandles&&!e.readOnly,drawMode:m,connectedPorts:new Set(T.flatMap(Ae=>[...Ae.source===A.id&&Ae.sourceProperty!==void 0?[`source:${Ae.sourceProperty}`]:[],...Ae.target===A.id&&Ae.targetProperty!==void 0?[`target:${Ae.targetProperty}`]:[]])),hasCollapseControl:A.hasCollapseControl,handleColor:y,animated:A.animated&&!L&&!w,animationColor:A.animationColor,animationWidth:A.animationWidth,animationVariant:A.animationVariant,width:(he=H.current.get(A.id))==null?void 0:he.w,height:(Re=H.current.get(A.id))==null?void 0:Re.h,propertyMode:S,resolvedRows:D.get(A.id),reversePorts:n==="RL",direction:n,onPropertyRows:z,onSurface:K,children:A.element},A.id)})}),Ye&&h.jsx("div",{className:"flow-sdk-box",style:{left:Ye.x1,top:Ye.y1,width:Ye.x2-Ye.x1,height:Ye.y2-Ye.y1}}),h.jsx("svg",{className:"flow-sdk-svg flow-sdk-label-overlay",style:{zIndex:11,pointerEvents:"none"},children:h.jsx("g",{ref:O,transform:`translate(${q.pan.x} ${q.pan.y}) scale(${q.zoom})`,children:h.jsx("g",{ref:Dm,className:"flow-sdk-labels",style:{pointerEvents:m?"none":"visiblePainted",outline:"none"}})})})]})}const f_=E.memo(d_);function Pm({id:e,role:t,side:r,position:n=.5,placement:o,children:i,style:a}){return h.jsx("div",{"data-flow-property":e,"data-flow-port-role":t,"data-flow-port-side":r,"data-flow-port-position":r?n:void 0,"data-flow-port-placement":o,style:{minHeight:32,display:"flex",alignItems:"center",justifyContent:t==="source"?"flex-end":"flex-start",...a,...r?{display:"none"}:{}},children:i??e})}const h_=gn.default.dialog`
151
+ &[open] {
152
+ display: flex;
153
+ flex-direction: column;
154
+ }
155
+ &,
156
+ & * {
157
+ scrollbar-width: none;
158
+ }
159
+ &::-webkit-scrollbar,
160
+ & *::-webkit-scrollbar {
161
+ display: none;
162
+ }
163
+ `,p_=gn.default.div`
164
+ min-height: 0;
165
+ overflow: auto;
166
+ padding: 32px 0;
167
+ mask-image: linear-gradient(
168
+ to bottom,
169
+ transparent,
170
+ black 32px,
171
+ black calc(100% - 32px),
172
+ transparent
173
+ );
174
+ -webkit-mask-image: linear-gradient(
175
+ to bottom,
176
+ transparent,
177
+ black 32px,
178
+ black calc(100% - 32px),
179
+ transparent
180
+ );
181
+ `;function Am({nodeAddress:e,active:t,label:r,open:n=!1,onClose:o,children:i,filter:a,height:s}){const{background:u,border:c,colorText:l}=Ve(),d=E.useRef(null),f=E.useId(),{data:p,schema:b,bindings:y}=E.useContext(kr),m=i!==void 0||!!(p&&b&&(y?Jt(y,e,b):pt(p,e,b)));E.useEffect(()=>{var g,w,v,_,C;!t||!m||!n?(g=d.current)==null||g.close():(w=d.current)!=null&&w.open||((v=d.current)==null||v.showModal(),(C=(_=d.current)==null?void 0:_.querySelector("[data-form-filter] input"))==null||C.focus())},[t,m,n]);const x=pe(u);return m?h.jsx(h.Fragment,{children:typeof document<"u"&&Lt.createPortal(h.jsx(h_,{ref:d,id:f,"aria-label":`Configure ${r}`,onClose:o,onPointerDown:g=>g.stopPropagation(),onWheel:g=>g.stopPropagation(),onKeyDown:g=>g.stopPropagation(),onClick:g=>{var w;g.stopPropagation(),g.target===g.currentTarget&&((w=d.current)==null||w.close())},style:{margin:"auto",padding:20,width:380,boxSizing:"border-box",maxWidth:"calc(100vw - 32px)",maxHeight:"calc(100dvh - 32px)",height:s,overflow:"hidden",borderRadius:30,border:`1px solid ${pe(c)}`,background:x,color:pe(l),boxShadow:`0 0 0 8px color-mix(in srgb, ${x} 60%, transparent)`,fontSize:16,textTransform:"none"},children:n&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,flexShrink:0},children:[h.jsx("strong",{style:{overflowWrap:"anywhere",minWidth:0},children:r}),h.jsx("form",{method:"dialog",style:{margin:0},onSubmit:g=>g.stopPropagation(),children:h.jsx(ht,{type:"submit","aria-label":"Close node configuration"})})]}),a&&h.jsx("div",{"data-form-filter":"",style:{flexShrink:0},children:a}),h.jsx(p_,{"data-form-scroll":"",style:s?{flex:1}:void 0,children:i??h.jsx(rb,{nodeAddress:e})})]})}),document.body)}):null}const Cu=({icon:e,label:t,onClick:r,color:n,boxSize:o=6,...i})=>{const{background:a,border:s,colorText:u}=Ve();return h.jsx(je,{label:t,children:h.jsx(F.Flex,{children:h.jsx(F.Icon,{as:e,boxSize:o,color:n,cursor:r?"pointer":void 0,onClick:r})})})},g_=({data:e,children:t,isInverted:r,isParent:n})=>{var N,B,W,z,X,se;const{selectedNodeIds:o,setSelectedNodeIds:i,selectedEdgeId:a,setSelectedEdgeId:s,isMultiSelectMode:u,isPerformanceMode:c,engineRef:l,callbacks:d,config:f,themeColor:p,direction:b}=Ie(),{background:y,border:m,colorText:x}=Ve(),g=E.useRef(null),w=E.useRef(null),[v,_]=E.useState(!1),[C,S]=E.useState(!1),[T,k]=E.useState(!1),j=e==null?void 0:e.id,P=tb(j),R=o.includes(j),I=f.nodeOverlayActions,O=f.renderNodeOverlay,M=(()=>{var Q;try{const G=(Q=l.current)==null?void 0:Q.zoom();return G!==void 0&&G<.08}catch{return!1}})(),q=E.useCallback(Q=>{var J,te,de,fe;if(C||f.readOnly)return;const G={shiftKey:Q.shiftKey,ctrlKey:Q.ctrlKey,metaKey:Q.metaKey,altKey:Q.altKey};if(a&&(s(null),(J=d.onEdgeDeselect)==null||J.call(d)),u){const Ee=o.includes(j),ge=Ee?o.filter(We=>We!==j):[...o,j];i(ge),Ee?(te=d.onNodeDeselect)==null||te.call(d):(de=d.onNodeSelect)==null||de.call(d,j,e,G)}else i([j]),(fe=d.onNodeSelect)==null||fe.call(d,j,e,G)},[j,e,o,a,u,C,i,s,d,f]),H=E.useCallback(()=>{var Q;C||f.readOnly||(Q=d.onNodeDoubleClick)==null||Q.call(d,j,e)},[j,e,C,d,f]),V=E.useCallback(()=>{w.current&&clearTimeout(w.current),w.current=setTimeout(()=>_(!0),100)},[]),re=E.useCallback(()=>{w.current&&clearTimeout(w.current),_(!1)},[]),ce=!!((N=e==null?void 0:e.config)!=null&&N.form),le={tabIndex:ce?0:void 0,"aria-haspopup":ce?"dialog":void 0,"aria-expanded":ce?T:void 0,onDoubleClickCapture:Q=>{var G;!ce||f.readOnly||C||!Q.currentTarget.contains(Q.target)||Q.target instanceof Element&&Q.target.closest("button, input, textarea, select, a, [contenteditable=true]")||(Q.preventDefault(),Q.stopPropagation(),i([j]),k(!0),(G=d.onNodeDoubleClick)==null||G.call(d,j,e))},onKeyDown:Q=>{!ce||f.readOnly||Q.target!==Q.currentTarget||Q.key!=="Enter"||(Q.preventDefault(),Q.stopPropagation(),i([j]),k(!0))}},be=ce&&h.jsx(Am,{nodeAddress:j,active:R,label:e.label||e.headerTitle||"Node",open:T,onClose:()=>{var Q;k(!1),R&&((Q=g.current)==null||Q.focus({preventScroll:!0}))}}),K=Array.isArray((B=e==null?void 0:e.config)==null?void 0:B.ports)?e.config.ports.map(Q=>h.jsx(Pm,{...Q},`${Q.id}:${Q.role}`)):null;return n?h.jsxs(F.Box,{ref:g,...le,onClick:q,onDoubleClick:H,onMouseEnter:V,onMouseLeave:re,cursor:"pointer",position:"relative",children:[be,!c&&(O||I&&I.length>0)&&v&&!M&&h.jsxs(h.Fragment,{children:[h.jsx(F.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>_(!0),onMouseLeave:re}),O?h.jsx(F.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>_(!0),onMouseLeave:re,willChange:"transform",children:O({nodeId:j,nodeData:e,isRoot:j==="root",isParent:!0,isHovered:v,setIsHovered:_})}):h.jsx(F.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:y,p:3,borderColor:m,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>_(!0),onMouseLeave:re,willChange:"transform",children:h.jsx(F.HStack,{px:2,gap:2,children:I.map((Q,G)=>h.jsxs(F.Box,{display:"contents",children:[G>0&&h.jsx(F.Box,{borderColor:m,height:5,borderRightWidth:1}),h.jsx(Cu,{icon:Q.icon,label:Q.label,color:x,bgColor:y,borderColor:m,textColor:x,boxSize:5,onClick:J=>{var te;J.stopPropagation(),(te=d.onNodeHoverAction)==null||te.call(d,Q.id,j,e)}})]},Q.id))})})]}),t({id:j,data:e,isActive:R,isLowZoom:M,isEditing:C,onEditStart:()=>S(!0),onEditEnd:()=>S(!1)}),P&&!((W=e==null?void 0:e.config)!=null&&W.parentContainer)&&((z=e==null?void 0:e.config)==null?void 0:z.collapsed)!==void 0&&(()=>{var J;const Q=b==="TB"||b==="BT",G=r||b==="RL";return h.jsx(F.IconButton,{position:"absolute",...Q?{[b==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:G?void 0:"-75px",left:G?"-75px":void 0,top:"50%",transform:"translateY(-50%)"},"aria-label":e.config.collapsed?"Expand":"Collapse",disabled:f.readOnly,onClick:te=>{var de;te.stopPropagation(),(de=d.onNodeCollapse)==null||de.call(d,j,!e.config.collapsed)},bgColor:pe(((J=e==null?void 0:e.viewProps)==null?void 0:J.bgColor)||p),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?h.jsx(Z.PiPlusBold,{size:30,color:pe("gray.800")}):h.jsx(Z.PiMinusBold,{size:30,color:pe("gray.800")})})})()]}):h.jsxs(F.Box,{ref:g,...le,onClick:q,onDoubleClick:H,onMouseEnter:V,onMouseLeave:re,cursor:"pointer",transition:"transform 0.1s ease",position:"relative",children:[be,K,!c&&(O||I&&I.length>0)&&v&&!M&&h.jsxs(h.Fragment,{children:[h.jsx(F.Box,{position:"absolute",top:-150,left:"0",right:"0",height:"150px",pointerEvents:"auto",onMouseEnter:()=>_(!0),onMouseLeave:re}),O?h.jsx(F.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",onMouseEnter:()=>_(!0),onMouseLeave:re,willChange:"transform",children:O({nodeId:j,nodeData:e,isRoot:j==="root",isParent:!!n,isHovered:v,setIsHovered:_})}):h.jsx(F.Box,{position:"absolute",zIndex:1e3,top:"-100px",left:"50%",bg:y,p:3,borderColor:m,borderWidth:1,borderRadius:15,pointerEvents:"auto",transform:"translateX(-50%) scale3d(3, 3, 1)",boxShadow:"lg",onMouseEnter:()=>_(!0),onMouseLeave:re,willChange:"transform",children:h.jsx(F.HStack,{px:2,gap:2,children:I.map((Q,G)=>h.jsxs(F.Box,{display:"contents",children:[G>0&&h.jsx(F.Box,{borderColor:m,height:5,borderRightWidth:1}),h.jsx(Cu,{icon:Q.icon,label:Q.label,color:x,bgColor:y,borderColor:m,textColor:x,boxSize:5,onClick:J=>{var te;J.stopPropagation(),(te=d.onNodeHoverAction)==null||te.call(d,Q.id,j,e)}})]},Q.id))})})]}),h.jsxs(F.Box,{position:"relative",display:"flex",h:"100%",w:"100%",children:[P&&!((X=e==null?void 0:e.config)!=null&&X.parentContainer)&&((se=e==null?void 0:e.config)==null?void 0:se.collapsed)!==void 0&&!n&&(()=>{var te,de,fe;const Q=b==="TB"||b==="BT",G=r||b==="RL",J=(te=e==null?void 0:e.config)!=null&&te.labelBelow?((((de=e==null?void 0:e.viewProps)==null?void 0:de.fontSize)||1)*100+100)/2:void 0;return h.jsx(F.IconButton,{position:"absolute",...Q?{[b==="BT"?"top":"bottom"]:"-75px",left:"50%",transform:"translateX(-50%)"}:{right:G?void 0:J===void 0?"-75px":`calc(50% - ${J+75}px)`,left:G?J===void 0?"-75px":`calc(50% - ${J+75}px)`:void 0,alignSelf:J===void 0?"center":void 0,top:J===void 0?void 0:`${J}px`,transform:J===void 0?void 0:"translateY(-50%)",zIndex:J===void 0?void 0:1},"aria-label":e.config.collapsed?"Expand":"Collapse",disabled:f.readOnly,onClick:Ee=>{var ge;Ee.stopPropagation(),(ge=d.onNodeCollapse)==null||ge.call(d,j,!e.config.collapsed)},bgColor:pe(((fe=e==null?void 0:e.viewProps)==null?void 0:fe.bgColor)||p),size:"md",color:"gray.100",rounded:"full",mr:2,px:2,py:4,children:e.config.collapsed?h.jsx(Z.PiPlusBold,{size:30,color:pe("gray.800")}):h.jsx(Z.PiMinusBold,{size:30,color:pe("gray.800")})})})(),t({id:j,data:e,isActive:R,isLowZoom:M,isEditing:C,onEditStart:()=>S(!0),onEditEnd:()=>S(!1)})]})]})},Bn=E.memo(g_);function tl(e=!0){const t=E.useRef(null);return E.useEffect(()=>{if(!e||!t.current)return;const r=i=>{i.stopPropagation()},n=t.current,o=["mousedown","mouseup","click","dblclick","pointerdown","pointerup","wheel"];return o.forEach(i=>n.addEventListener(i,r)),()=>{o.forEach(i=>n.removeEventListener(i,r))}},[e]),t}const Kt=({nodeId:e,label:t,color:r,fontWeight:n="bold",fontSize:o="5xl",wrap:i=!1,isEditing:a,onEditStart:s,onEditEnd:u})=>{const{callbacks:c,config:l,readOnly:d}=Ie(),f=l.editable&&!d,[p,b]=E.useState(t),[y,m]=E.useState(),x=E.useRef(null),g=E.useRef(!1),w=tl(a);E.useEffect(()=>{a&&(g.current=!1,x.current&&(x.current.focus(),x.current.select()))},[a]);const v=()=>{var C;if(g.current)return;g.current=!0;const _=p.trim();_&&_!==t&&((C=c.onNodeLabelChange)==null||C.call(c,e,_)),u()};return!f||!a?h.jsx(F.Text,{color:r,fontWeight:n,fontSize:o,minW:0,maxW:"100%",whiteSpace:i?"normal":"nowrap",overflowWrap:i?"anywhere":void 0,overflow:"hidden",textOverflow:"ellipsis",title:t,onDoubleClick:f?_=>{_.stopPropagation(),m({width:_.currentTarget.offsetWidth,height:_.currentTarget.offsetHeight}),b(t),s()}:void 0,cursor:f?"text":void 0,children:t}):h.jsxs("div",{ref:w,style:{position:"relative",width:"max-content",minWidth:y==null?void 0:y.width,maxWidth:900,height:y==null?void 0:y.height},children:[h.jsx(F.Text,{as:"span","aria-hidden":"true",display:"block",visibility:"hidden",fontWeight:n,fontSize:o,lineHeight:"normal",whiteSpace:"pre",overflow:"hidden",children:p||" "}),h.jsx(F.Input,{ref:x,value:p,onChange:_=>b(_.target.value),onBlur:v,onKeyDown:_=>{_.key==="Enter"&&v(),_.key==="Escape"&&(g.current=!0,u())},color:r,fontWeight:n,fontSize:o,bg:"transparent",borderWidth:0,_focus:{outline:"none",boxShadow:"none"},_focusVisible:{outline:"none",boxShadow:"none"},p:0,display:"block",position:"absolute",top:0,left:0,w:"100%",h:"100%",minW:0,minH:0,lineHeight:"normal"})]})},y_=({id:e,data:t,isActive:r,isEditing:n,onEditStart:o,onEditEnd:i})=>{var y,m,x,g,w,v,_,C;const{themeColor:a}=Ie(),{colorText:s}=Ve(),u=((y=t==null?void 0:t.viewProps)==null?void 0:y.bgColor)==="transparent",c=((m=t==null?void 0:t.viewProps)==null?void 0:m.outline)===!0,{bgColor:l,borderColor:d,textColor:f}=Zt(((x=t==null?void 0:t.viewProps)==null?void 0:x.bgColor)||a),p=pe(((g=t==null?void 0:t.viewProps)==null?void 0:g.textColor)||(u||c?s:f)),b=((w=t==null?void 0:t.viewProps)==null?void 0:w.borderColor)||(c?!u&&((v=t==null?void 0:t.viewProps)==null?void 0:v.bgColor)||a:d);return h.jsx(F.Box,{"data-flow-node-surface":"",borderRadius:(_=t==null?void 0:t.viewProps)==null?void 0:_.borderRadius,bgColor:c?"transparent":l,...ln(t==null?void 0:t.viewProps,b,r,2),py:14,px:20,whiteSpace:"nowrap",w:"fit-content",children:h.jsxs(F.Flex,{justifyContent:"start",alignItems:"center",gap:8,w:"fit-content",maxW:900,minW:0,fontSize:"5xl",lineHeight:"normal",children:[((C=t==null?void 0:t.config)==null?void 0:C.icon)&&h.jsx(F.Box,{flexShrink:0,children:h.jsx(Mr,{name:t.config.icon,size:80,color:p})}),h.jsx(Kt,{nodeId:e,label:(t==null?void 0:t.label)||(t==null?void 0:t.text)||"",color:p,isEditing:n,onEditStart:o,onEditEnd:i})]})})};function Dn(){const{nodeViewModes:e,setNodeViewMode:t,allNodesIconLabel:r,setAllNodesIconLabel:n}=Ie();return{allNodesIconLabel:r,setAllNodesIconLabel:n,getNodeViewMode:o=>e[o]??"default",showNodeProperties:o=>t(o,"properties"),restoreNodeView:o=>t(o,"default"),toggleNodeView:o=>t(o,e[o]==="properties"?"default":"properties"),setNodeViewMode:t}}const b_=({id:e,isActive:t,data:r,isEditing:n,onEditStart:o,onEditEnd:i})=>{var w,v,_,C,S,T,k,j,P,R,I,O,M,q,H;const{themeColor:a}=Ie(),{colorText:s}=Ve(),u=((w=r==null?void 0:r.viewProps)==null?void 0:w.bgColor)==="transparent",c=((v=r==null?void 0:r.viewProps)==null?void 0:v.outline)===!0,l=!u&&((_=r==null?void 0:r.viewProps)==null?void 0:_.bgColor)||a,{borderColor:d,highlightColor:f,textColor:p}=Zt(l),b=pe(((C=r==null?void 0:r.viewProps)==null?void 0:C.textColor)||(u||c?s:p)),y=u&&!c&&!((S=r==null?void 0:r.viewProps)!=null&&S.borderColor)?"transparent":pe(((T=r==null?void 0:r.viewProps)==null?void 0:T.borderColor)||(c?l:d)),m=u||c?"transparent":l!=null&&l.startsWith("#")?l:pe(f),x=(k=r==null?void 0:r.config)==null?void 0:k.icon,g=(r==null?void 0:r.label)??(r==null?void 0:r.text)??"";if((j=r==null?void 0:r.config)!=null&&j.labelBelow){const V=(((P=r==null?void 0:r.viewProps)==null?void 0:P.fontSize)||1)*100;return h.jsxs(F.Flex,{"data-flow-icon-label":"",direction:"column",align:"center",gap:"24px",width:`${Math.max(V+200,360)}px`,position:"relative",children:[h.jsx(F.Flex,{"data-flow-node-surface":"",align:"center",justify:"center",width:`${V+100}px`,height:`${V+100}px`,flexShrink:0,borderRadius:(R=r==null?void 0:r.viewProps)==null?void 0:R.borderRadius,backgroundColor:m,...ln(r==null?void 0:r.viewProps,y,t,2),children:!!x&&h.jsx(Mr,{name:x,size:V,color:b})}),h.jsxs(F.Flex,{"data-flow-icon-caption":"",direction:"column",align:"center",gap:"8px",justify:"center",width:"100%",minW:0,textAlign:"center",children:[h.jsx(Kt,{nodeId:e,label:g,color:pe(((I=r==null?void 0:r.viewProps)==null?void 0:I.textColor)||s),isEditing:n,onEditStart:o,onEditEnd:i,wrap:!0}),typeof((O=r.config)==null?void 0:O.subtitle)=="string"&&r.config.subtitle!==""&&h.jsx(F.Text,{"data-flow-node-subtitle":"",color:pe(((M=r==null?void 0:r.viewProps)==null?void 0:M.textColor)||s),opacity:.65,fontSize:"32px",fontWeight:"normal",lineHeight:1.3,width:"100%",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",title:r.config.subtitle,children:r.config.subtitle})]})]})}return h.jsxs(F.Flex,{"data-flow-node-surface":"",align:"center",borderRadius:(q=r==null?void 0:r.viewProps)==null?void 0:q.borderRadius,bgColor:m,style:{backgroundColor:m},textTransform:"capitalize",...ln(r==null?void 0:r.viewProps,y,t,2),px:50,w:"fit-content",whiteSpace:"nowrap",children:[!!x&&h.jsx(F.Flex,{align:"center",py:14,mr:g?8:0,flexShrink:0,children:h.jsx(Mr,{name:x,size:(((H=r==null?void 0:r.viewProps)==null?void 0:H.fontSize)||1)*100,color:b},b)}),(g||!x)&&h.jsx(F.Flex,{justifyContent:"start",py:14,fontSize:"5xl",lineHeight:"normal",w:"fit-content",maxW:900,minW:0,children:h.jsx(Kt,{nodeId:e,label:g,color:b,isEditing:n,onEditStart:o,onEditEnd:i})})]})};function Tm({onExpand:e,toggleLabel:t="Show properties",toggleDisabled:r=!1,renderCompact:n=b_,...o}){const{colorMode:i,callbacks:a}=Ie();return h.jsx(Bn,{...o,children:s=>h.jsxs(F.Box,{position:"relative",children:[h.jsx(n,{...s}),e&&s.isActive&&h.jsx(F.Box,{position:"absolute",top:"-24px",right:"-48px","data-flow-content-toggle":"",children:h.jsx(je,{label:t,children:h.jsx(ve,{"aria-label":t,icon:h.jsx(F.Icon,{as:Z.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:i==="dark"?"gray.100":"gray.800",disabled:r,onClick:u=>{var c;u.stopPropagation(),e(),(c=a.onNodeViewToggle)==null||c.call(a,o.data.id)}})})})]})})}const uy=1.55;function m_({nodeId:e,content:t,color:r}){const{callbacks:n,config:o,readOnly:i}=Ie(),a=!!o.editable&&!i,[s,u]=E.useState(!1),[c,l]=E.useState(t),[d,f]=E.useState(),p=E.useRef(null),b=E.useRef(!1),y=tl(s);E.useLayoutEffect(()=>{const g=p.current;!s||!g||(g.style.height="auto",g.style.height=`${Math.max((d==null?void 0:d.height)??0,g.scrollHeight)}px`)},[c,s,d]),E.useEffect(()=>{var g;a?s&&(b.current=!1,(g=p.current)==null||g.focus()):u(!1)},[s,a]);const m=g=>{a&&(f({width:g.offsetWidth,height:g.offsetHeight}),l(t),u(!0))},x=()=>{var g;b.current||!a||(b.current=!0,c!==t&&((g=n.onNodeContentChange)==null||g.call(n,e,c)),u(!1))};return!s||!a?h.jsx(F.Box,{"data-flow-content":"",color:r,w:"100%",minH:"1.2em",whiteSpace:"normal",lineHeight:uy,overflowWrap:"anywhere",css:{"& > :first-of-type":{marginTop:0},"& > :last-of-type":{marginBottom:0},"& h1, & h2, & h3, & h4, & h5, & h6":{fontWeight:700,lineHeight:1.2,margin:"1em 0 0.45em"},"& h1":{fontSize:"1.5em"},"& h2":{fontSize:"1.3em"},"& h3":{fontSize:"1.1em"},"& p":{margin:"0.65em 0",whiteSpace:"pre-wrap"},"& ul, & ol":{margin:"0.65em 0",paddingInlineStart:"1.6em"},"& ul":{listStyleType:"disc"},"& ol":{listStyleType:"decimal"},"& li":{display:"list-item",margin:"0.3em 0",paddingInlineStart:"0.15em"},"& li > ul, & li > ol":{margin:"0.25em 0"},"& li > p":{margin:0},"& a":{color:"inherit",textDecoration:"underline"},"& code":{fontFamily:"monospace",fontSize:"0.85em"},"& :not(pre) > code":{background:"color-mix(in srgb, currentColor 10%, transparent)",padding:"0.1em 0.25em",borderRadius:"0.2em"},"& pre":{margin:"0.75em 0",padding:"0.75em",background:"color-mix(in srgb, currentColor 8%, transparent)",border:0,borderRadius:"6px",maxWidth:"100%",overflowX:"auto",whiteSpace:"pre",overflowWrap:"normal",lineHeight:1.5},"& pre code":{background:"transparent",padding:0,whiteSpace:"inherit"},"& strong":{fontWeight:700},"& em":{fontStyle:"italic"},"& blockquote":{margin:"0.4em 0",borderInlineStart:"0.1em solid currentColor",paddingInlineStart:"0.6em"},"& table":{width:"100%",tableLayout:"fixed",borderCollapse:"collapse",margin:"0.4em 0"},"& th, & td":{border:"1px solid currentColor",padding:"0.2em 0.3em",textAlign:"left"},"& th":{fontWeight:700},"& img":{maxWidth:"100%",height:"auto"}},cursor:a?"text":void 0,tabIndex:a?0:void 0,onDoubleClick:g=>{g.stopPropagation(),m(g.currentTarget)},onKeyDown:g=>{a&&g.key==="Enter"&&g.target===g.currentTarget&&(g.preventDefault(),g.stopPropagation(),m(g.currentTarget))},children:h.jsx(tv.default,{options:{forceBlock:!0,wrapper:E.Fragment,disableParsingRawHTML:!0,overrides:{a:{props:{target:"_blank",rel:"noopener noreferrer"}},img:{props:{loading:"lazy",referrerPolicy:"no-referrer"}}}},children:t})}):h.jsx("div",{ref:y,style:{width:d==null?void 0:d.width,minHeight:d==null?void 0:d.height,maxWidth:"100%"},children:h.jsx(F.Textarea,{ref:p,"aria-label":"Node content",value:c,onChange:g=>l(g.target.value),onBlur:x,onKeyDown:g=>{g.stopPropagation(),!g.nativeEvent.isComposing&&(g.key==="Enter"&&(g.ctrlKey||g.metaKey)&&(g.preventDefault(),x()),g.key==="Escape"&&(b.current=!0,u(!1)))},color:r,fontFamily:"inherit",fontSize:"inherit",lineHeight:uy,overflowWrap:"anywhere",whiteSpace:"pre-wrap",rows:1,bg:"transparent",display:"block",style:{border:0,outline:"none",boxShadow:"none"},p:0,w:"100%",h:"100%",minW:0,minH:0,resize:"none"})})}const v_=(e,t,r)=>{var f,p,b,y;const n=((f=e==null?void 0:e.viewProps)==null?void 0:f.bgColor)||t,[o]=n.split("."),i=Zt(n),a=((p=e==null?void 0:e.viewProps)==null?void 0:p.outline)===!0,s=n==="transparent"||a,u=r==="dark"?"gray.200":"gray.900",c=s?"transparent":n!=null&&n.startsWith("#")?pe(n):pe(i.bgColor),l=pe(((b=e==null?void 0:e.viewProps)==null?void 0:b.textColor)||(s?u:i.textColor)),d=pe(((y=e==null?void 0:e.viewProps)==null?void 0:y.borderColor)||(a?n==="transparent"?t:n:i.borderColor));return{...i,bgColor:s?"transparent":i.bgColor,highlightColor:s?"transparent":i.highlightColor,isTransparent:s,propertyColor:s?u:i.propertyColor,bg:n,wordBeforeDot:o,hexbgColor:c,hextextColor:l,hexborderColor:d}},x_=(e,t=350)=>`${String(e).substring(0,t)}${String(e).length>t?"...":""}`,w_=e=>e!=null&&e.includes("root")?e.replace("root","untitled"):e,Om=600,C_=3,__=e=>{const t=Math.max(...Object.keys(e||{}).map(n=>n.length),0);return Math.max(t*28+30,200)};function S_({headerTitle:e,hasContent:t,data:r,icon:n,colors:o,hasConfig:i,id:a,isActive:s,isEditing:u,onEditStart:c,onEditEnd:l,props:d,objVisible:f,setObjVisible:p,onShowNativeIcon:b}){var g,w;const{callbacks:y}=Ie(),m=d.onShowIcon??b,x=m?"Show icon":f?"Show content":"Show properties";return h.jsx(h.Fragment,{children:(e||t||((g=r.config)==null?void 0:g.form)||s&&b)&&h.jsxs(F.Flex,{justify:"flex-start",direction:"row",p:Object.entries(r.description||{}).length?8:20,borderBottomWidth:1,minWidth:"max-content !important",width:"100%",textTransform:"capitalize",align:"center",textOverflow:"ellipsis",alignItems:"center",fontWeight:"bold",color:o.propertyColor,bgColor:o.highlightColor,borderBottomColor:!i&&!t?"transparent":o.hexborderColor,children:[!!n&&h.jsx(F.Flex,{mr:6,alignItems:"center",flexShrink:0,children:h.jsx(Mr,{name:n,size:64,color:o.hextextColor},o.hextextColor)}),h.jsx(Kt,{nodeId:a,label:w_(e),color:((w=r==null?void 0:r.viewProps)==null?void 0:w.textColor)||o.propertyColor,isEditing:u,onEditStart:c,onEditEnd:l}),s&&(t||m)&&h.jsx(F.Box,{ml:"auto",pl:6,flexShrink:0,"data-flow-content-toggle":"",children:h.jsx(je,{label:x,children:h.jsx(ve,{"aria-label":x,icon:h.jsx(F.Icon,{as:Z.PiCircleFill,boxSize:4}),variant:"ghost",w:12,h:12,minW:12,color:o.hextextColor,onClick:v=>{var _;v.stopPropagation(),m?m():p(!f),(_=y.onNodeViewToggle)==null||_.call(y,a)}})})})]})})}function j_({data:e,resourcePorts:t,inspecting:r,form:n,inspectionPorts:o,extraPorts:i,colors:a,direction:s,uniformKeyWidth:u}){const{edgeById:c}=Wr(),l=new Set;for(const{data:d}of c.values())d.source===e.id&&d.sourceProperty!==void 0&&l.add(`source:${d.sourceProperty}`),d.target===e.id&&d.targetProperty!==void 0&&l.add(`target:${d.targetProperty}`);return h.jsx(F.Box,{children:Object.entries(e.description||{}).map(([d,f],p)=>{var I,O,M;const b=t&&Object.keys(t).find(q=>q.slice(q.indexOf(":")+1)===d),y=r&&((I=n==null?void 0:n.type.ports)==null?void 0:I[d]),m=b??(y?`${y.kind}:${d}`:d),x=o.find(q=>q.id===m),g=b?"source":x==null?void 0:x.role,w=l.has(`source:${m}`),v=l.has(`target:${m}`),_=i.some(q=>q.id===d),C=f===""&&(_||(g?l.has(`${g}:${m}`):w||v)),S=g??(w!==v?w?"source":"target":void 0),T=(x==null?void 0:x.side)??(S?S==="source"!=(s==="RL")?"right":"left":void 0),k=C&&T==="right"?"right":"left",j=_?d.replace(/^(template|input|output|config|error):/,""):d,P=Er(a.wordBeforeDot)[typeof f],R=Er(a.wordBeforeDot).property;return h.jsxs(F.Box,{"data-flow-property":b&&(s==="TB"||s==="BT")?void 0:m,"data-flow-port-role":g,"data-flow-inspection-row":r?"":void 0,children:[h.jsxs(F.Flex,{flexWrap:"nowrap",overflow:"hidden",children:[h.jsx(F.Flex,{justifyContent:"start",align:"center",background:a.highlightColor,width:C?"100%":`${u}px`,minWidth:`${u}px`,borderRightColor:a.hexborderColor,borderRightWidth:C?0:1,children:h.jsx(F.Text,{py:5,px:10,w:"100%",textAlign:k,whiteSpace:"nowrap",fontWeight:"bold",fontSize:"4xl",color:((O=e==null?void 0:e.viewProps)==null?void 0:O.textColor)||(a.isTransparent?a.hextextColor:R),children:j})}),!C&&h.jsx(F.Flex,{flex:1,justifyContent:"start",overflow:"hidden",p:4,background:a.hexbgColor,w:Om,maxH:200,children:h.jsx(F.Text,{overflow:"hidden",py:3,px:4,whiteSpace:"normal",textOverflow:"ellipsis",fontSize:"4xl",color:((M=e==null?void 0:e.viewProps)==null?void 0:M.textColor)||(a.isTransparent?a.hextextColor:P),fontWeight:400,children:x_(f)})})]}),p!==Object.entries(e.description||{}).length-1&&h.jsx(F.Box,{borderTopWidth:1,my:0,borderColor:a.hexborderColor})]},d)})})}function E_(e){var w,v,_;const{themeColor:t,colorMode:r,direction:n}=Ie(),o=Dn(),i=o.getNodeViewMode(e.data.id)==="properties",a=C=>o.setNodeViewMode(e.data.id,C?"properties":"default"),s=!!e.onShowIcon||i||typeof((w=e.data.config)==null?void 0:w.content)!="string",{bindings:u,data:c,schema:l}=E.useContext(kr),d=(v=u==null?void 0:u[e.data.id])==null?void 0:v.portResources,f=u?Jt(u,e.data.id,l):c&&l?pt(c,e.data.id,l):void 0,p=f&&xe(c,"address"in f?f.address:e.data.id),b=p&&typeof p=="object"&&f?Object.fromEntries(Object.keys(f.type.properties).filter(C=>{var S;return Object.prototype.hasOwnProperty.call(p,C)&&vn((S=f.fields[C])==null?void 0:S.$visibleWhen,c)}).map(C=>[C,p[C]!==null&&typeof p[C]=="object"?JSON.stringify(p[C],null,2):p[C]===null?"null":p[C]])):{},y=d?Object.fromEntries(Object.entries(d).map(([C,S])=>{var T;return[C.slice(C.indexOf(":")+1),((T=xe(c,S))==null?void 0:T.name)??S.split(".").at(-1)]})):Object.keys(e.data.description??{}).length?e.data.description:b,m=s&&!d?((_=e.data.config)==null?void 0:_.ports)??[]:[],x=m.filter(C=>!Object.prototype.hasOwnProperty.call(y,C.id)&&!Object.entries((f==null?void 0:f.type.ports)??{}).some(([S,T])=>`${T.kind}:${S}`===C.id&&Object.prototype.hasOwnProperty.call(y,S))),g={...y,...Object.fromEntries(x.map(C=>[C.id,""]))};return{themeColor:t,colorMode:r,direction:n,objVisible:i,setObjVisible:a,inspecting:s,resourcePorts:d,form:f,description:g,inspectionPorts:m,extraPorts:x}}const nl=e=>{var m,x,g;const{themeColor:t,colorMode:r,direction:n,objVisible:o,setObjVisible:i,inspecting:a,resourcePorts:s,form:u,description:c,inspectionPorts:l,extraPorts:d}=E_(e),f=Dn(),p=f.getNodeViewMode(e.data.id)==="icon-label",y=!e.onShowIcon&&!((m=e.data.config)!=null&&m.parentContainer)&&typeof((x=e.data.config)==null?void 0:x.content)!="string"?()=>f.setNodeViewMode(e.data.id,"icon-label"):void 0;return!e.onShowIcon&&p?h.jsx(Tm,{...e,data:{...e.data,label:e.data.label??e.data.headerTitle,config:{...e.data.config,labelBelow:!0,icon:((g=e.data.config)==null?void 0:g.icon)||"PiBracketsCurly"}},onExpand:()=>f.restoreNodeView(e.data.id)}):h.jsx(Bn,{...e,data:{...e.data,description:c},children:({id:w,data:v,isActive:_,isEditing:C,onEditStart:S,onEditEnd:T})=>{var V,re,ce,le,be,K;const k=v_(v,t,r),j=v.label??v.headerTitle,P=Object.entries(v.description||{}).length>0,R=__(v.description),I=(re=(V=e.data)==null?void 0:V.config)==null?void 0:re.icon,O=(le=(ce=e.data)==null?void 0:ce.config)==null?void 0:le.content,M=typeof O=="string"&&!e.onShowIcon,q=((be=v==null?void 0:v.viewProps)==null?void 0:be.borderRadius)??"53px",H=ln(v==null?void 0:v.viewProps,k.hexborderColor,_,C_);return h.jsx(F.Flex,{justifyContent:"space-between",...v==null?void 0:v.viewProps,"data-flow-node-surface":"",direction:"column",p:0,borderRadius:q,overflow:"hidden",alignItems:"center",style:{backgroundColor:k.hexbgColor,transition:"border-color 0.2s ease-in-out"},width:"100%",minW:M||e.onShowIcon?R+Om+H.borderWidth*2:void 0,...H,children:h.jsxs(F.Flex,{width:"100%",direction:"column",borderRadius:q,borderColor:k.hexborderColor,borderWidth:0,overflow:"hidden",children:[h.jsx(S_,{headerTitle:j,hasContent:M,data:v,icon:I,colors:k,hasConfig:P,id:w,isActive:_,isEditing:C,onEditStart:S,onEditEnd:T,props:e,objVisible:o,setObjVisible:i,onShowNativeIcon:y}),M&&!o?h.jsx(F.Flex,{w:"100%",overflow:"auto",justifyContent:"start",background:k.highlightColor,p:12,fontSize:"5xl",lineHeight:"normal",children:h.jsx(m_,{nodeId:w,content:O,color:((K=v==null?void 0:v.viewProps)==null?void 0:K.textColor)||k.hextextColor})}):h.jsx(j_,{data:v,resourcePorts:s,inspecting:a,form:u,inspectionPorts:l,extraPorts:d,colors:k,direction:n,uniformKeyWidth:R})]})})}})};nl.displayName="NodeJsonObjectView";const Im=e=>{var c,l,d,f,p,b,y;const t=Dn(),r=t.getNodeViewMode(e.data.id)==="properties",n=m=>t.setNodeViewMode(e.data.id,m?"properties":"default"),{callbacks:o,readOnly:i}=Ie(),a=(l=(c=e.data)==null?void 0:c.config)==null?void 0:l.parentContainer,s=a?"Show parent":"Show properties",u=a||((f=(d=e.data)==null?void 0:d.config)==null?void 0:f.form)||((y=(b=(p=e.data)==null?void 0:p.config)==null?void 0:b.ports)==null?void 0:y.length);return!a&&u&&r?h.jsx(nl,{...e,onShowIcon:()=>n(!1)}):h.jsx(Tm,{...e,toggleLabel:s,toggleDisabled:a&&i,onExpand:u?()=>{var m;a?(m=o.onNodeCollapse)==null||m.call(o,e.data.id,!1):n(!0)}:void 0})},Mm=e=>h.jsx(Im,{...e,renderCompact:y_}),qm=e=>h.jsx(Im,{...e}),Nm=e=>h.jsx(Bn,{...e,children:()=>null});Mm.displayName="text";qm.displayName="arrayView";Nm.displayName="ParentContainerView";const R_={objectView:nl,arrayView:qm,text:Mm,parentContainer:Nm},k_=({children:e,pattern:t="dot",backgroundColor:r})=>{const{colorMode:n}=Ie(),o=n==="dark",i=o?"--chakra-colors-gray-700":"--chakra-colors-gray-500",a=o?"--chakra-colors-gray-700":"--chakra-colors-gray-800";return t==="none"?h.jsx(F.Box,{"data-flow-background":"none",width:"100%",height:"100%",padding:0,bg:r,children:e}):h.jsxs(F.Box,{"data-flow-background":t,position:"relative",width:"100%",height:"100%",padding:0,bg:r,children:[h.jsx(F.Box,{position:"absolute",top:0,left:0,right:0,bottom:0,width:"100%",height:"100%",zIndex:0,pointerEvents:"none",style:{backgroundImage:t==="dot"?`radial-gradient(var(${i}) 8%, transparent 8%)`:t==="steel"?`repeating-linear-gradient(45deg, var(${a}) 0, var(${a}) 1px, transparent 1px, transparent 20px)`:`linear-gradient(var(${a}) 1px, transparent 1px), linear-gradient(90deg, var(${a}) 1px, transparent 1px)`,backgroundSize:"20px 20px",opacity:.3}}),h.jsx(F.Box,{position:"relative",width:"100%",height:"100%",zIndex:1,padding:0,children:e})]})},P_=.4,Hr={borderWidth:6,borderStyle:"solid",borderRadius:50,fontSize:70,padding:120,labelPosition:"top",labelMargin:90},A_=({nodes:e,edges:t})=>{const{themeColor:r,spacing:n,edgeRadius:o,backgroundVariant:i,setBackgroundSelected:a,edgeColor:s,direction:u,nodeAlignment:c,edgeMode:l,compactPropertyLayout:d,workflowContract:f,parentNodeStyle:p,engineRef:b,callbacks:y,config:m,selectedNodeIds:x,setSelectedNodeIds:g,selectedEdgeId:w,setSelectedEdgeId:v,setIsPerformanceMode:_,isZoomMode:C,setIsZoomMode:S,isMultiSelectMode:T,setIsMultiSelectMode:k,isDragMode:j,setIsDragMode:P,isEdgeHandlesEnabled:R,isArrayNodeMode:I}=Ie(),O=E.useRef(null),[M,q]=E.useState(null),H=e.length>200;E.useEffect(()=>{_(H)},[H,_]);const{edgeSep:V,rankSep:re,spacingFactor:ce}=E.useMemo(()=>{const Y=h0(e.length),D=n<1?.3+.7*n:.5+.5*n;return{edgeSep:Y.edgeSep*D,rankSep:Y.rankSep*D,spacingFactor:1.3+(n-1)*(n<1?.4:.3)}},[e.length,n]),{bgColor:le}=Zt(r),{canvas:be,borderSecondary:K,colorText:N}=Ve(),B=i==="transparent"?"transparent":m.backgroundColor||be,W=E.useCallback(Y=>{if(Y!=null&&Y.includes("gray"))return"whitesmoke";if(!Y)return pe(r);switch(Y){case"dark":return pe(B);case"light":return pe(K);default:return pe(Y)}},[r,B,K]),z=m.colorMode==="dark",X=E.useMemo(()=>W(z?le:"light"),[z,le,W]),se=s?W(s):X,Q=E.useMemo(()=>m.initialViewport||{pan:{x:0,y:0},zoom:.01},[]),G=u==="C"?"LR":u,J=E.useCallback(Y=>{const D={...p,...Y};return{...D,bgColor:D.bgColor||r,bgOpacity:D.outline?0:D.bgOpacity??P_}},[p,r]),te=E.useMemo(()=>{var D;const Y=new Map;for(const ee of e)(D=ee.data)!=null&&D.id&&Y.set(ee.data.id,ee);return Y},[e]),de=E.useMemo(()=>{var D;const Y=new Map;for(const ee of t)(D=ee.data)!=null&&D.id&&Y.set(ee.data.id,ee);return Y},[t]),fe=E.useCallback(Y=>{var _e;const D=(_e=te.get(Y))==null?void 0:_e.data,ee=J(D==null?void 0:D.viewProps),Ce=pe(ee.bgColor);return{animated:!!(D!=null&&D.isNodeAnimated)&&!H,animationVariant:D==null?void 0:D.nodeAnimationVariant,animationColor:pe(ee.borderColor||r),bgColor:ee.outline?"transparent":Ce,bgOpacity:ee.bgOpacity,borderColor:ee.borderColor?pe(ee.borderColor):ee.outline&&ee.bgColor==="transparent"?pe(r):Ce,borderWidth:Ut(ee.borderWidth,Hr.borderWidth),borderStyle:ee.borderStyle??Hr.borderStyle,borderRadius:ee.borderRadius??Hr.borderRadius,textColor:ee.textColor?pe(ee.textColor):ee.outline||ee.bgColor==="transparent"?pe(N):Ce,fontSize:ee.fontSize??Hr.fontSize,labelPosition:ee.labelPosition??Hr.labelPosition,labelMargin:Hr.labelMargin,labelBg:cl(W("dark"),Ce,ee.bgOpacity)??W("dark"),padding:ee.padding??Hr.padding}},[J,te,N,r,H,W]),Ee=E.useMemo(()=>{var ee,Ce;const Y=new Map;for(const _e of t){const Se=(ee=_e.data)==null?void 0:ee.source,Ge=(Ce=_e.data)==null?void 0:Ce.target;if(!Se||!Ge||Se===Ge)continue;const Le=Se<Ge?`${Se}|${Ge}`:`${Ge}|${Se}`,ke=Y.get(Le);ke?ke.push({id:_e.data.id,source:Se}):Y.set(Le,[{id:_e.data.id,source:Se}])}const D=new Map;for(const[_e,Se]of Y){if(Se.length<2)continue;const Ge=_e.split("|")[0],Le=Math.min(20,70/Se.length);Se.forEach(({id:ke,source:Me},gr)=>{const Ye=50+(gr-(Se.length-1)/2)*Le;D.set(ke,(Me===Ge?Ye:100-Ye)/100)})}return D},[t]),ge=E.useMemo(()=>{const Y=W("dark");return t.filter(D=>{var ee;return((ee=D.data)==null?void 0:ee.id)&&D.data.source&&D.data.target}).map(({data:D})=>{var Se,Ge,Le,ke,Me,gr;let ee=Y;const Ce=(Ge=(Se=te.get(D.source))==null?void 0:Se.data)==null?void 0:Ge.parent,_e=(ke=(Le=te.get(D.target))==null?void 0:Le.data)==null?void 0:ke.parent;if(Ce&&Ce===_e){const Ye=J((gr=(Me=te.get(Ce))==null?void 0:Me.data)==null?void 0:gr.viewProps),yr=cl(Y,pe(Ye.bgColor),Ye.bgOpacity);yr&&(ee=yr)}return{id:D.id,data:D,type:D.type??m.edgeType??"rounded-orthogonal",source:D.source,target:D.target,sourceProperty:D.sourceProperty,targetProperty:D.targetProperty,label:D.label,validationIssue:(l==="auto"||l==="properties")&&(D.sourceProperty!==void 0||D.targetProperty!==void 0)&&f?Iu(f,D):void 0,color:D.color?pe(D.color):se,labelBg:ee,dashed:!!D.isEdgeDashed,animated:!!D.isEdgeAnimated,inverted:!!D.isInverted,turn:Ee.get(D.id)??.5}})},[t,se,Ee,m.edgeType,l,f,te,J,W]),We=E.useMemo(()=>{var D;const Y=new Set;for(const ee of e)(D=ee.data)!=null&&D.parent&&Y.add(ee.data.parent);return Y},[e]),me=E.useMemo(()=>{var D;const Y=new Map;for(const ee of t)(D=ee.data)!=null&&D.source&&!Y.has(ee.data.source)&&Y.set(ee.data.source,ee.data);return Y},[t]),Te=E.useMemo(()=>{const Y={...R_,...m.customViews};return e.filter(D=>{var ee;return(ee=D.data)==null?void 0:ee.id}).map(D=>{var Ge,Le,ke,Me;const ee=We.has(D.data.id)&&!D.data.parent,Ce=ee?D.data.label??D.data.headerTitle??"Container":void 0,_e=ee?Y.parentContainer:Y[D.data.type]||Y.text,Se=me.get(D.data.id);return{id:D.data.id,collapsed:(Ge=D.data.config)==null?void 0:Ge.collapsed,parent:D.data.parent,label:Ce,animated:!!D.data.isNodeAnimated,animationVariant:D.data.nodeAnimationVariant,hasCollapseControl:((Le=D.data.config)==null?void 0:Le.collapsed)!==void 0,animationColor:pe(((ke=D.data.viewProps)==null?void 0:ke.borderColor)||r),animationWidth:Ut((Me=D.data.viewProps)==null?void 0:Me.borderWidth,8),element:E.createElement(_e,{...D,isInverted:Se==null?void 0:Se.isInverted,isParent:ee,key:`${D.data.id}-${r}`})}})},[e,We,me,r,m.customViews]),er=E.useMemo(()=>H?300:e.length>50?150:e.length>20?100:50,[e.length,H]),De=E.useRef(m);De.current=m;const Ne=E.useRef(C);Ne.current=C;const He=E.useRef(I);He.current=I;const rr=E.useRef(x);rr.current=x;const ze=E.useRef(w);ze.current=w;const xr=E.useRef(T);xr.current=T;const Ze=E.useRef(te);Ze.current=te;const pr=E.useRef(de);pr.current=de;const dr=E.useRef(new Map);E.useEffect(()=>{var ee,Ce;const Y=new Map([...de].filter(([,_e])=>te.has(_e.data.source)&&te.has(_e.data.target))),D=dr.current;dr.current=Y;for(const[_e,Se]of D)Y.has(_e)||(ze.current===_e&&(v(null),(ee=y.onEdgeDeselect)==null||ee.call(y)),(Ce=y.onEdgeRemove)==null||Ce.call(y,_e,Se.data))},[de,te,y,v]),E.useEffect(()=>{const Y=O.current;if(!M||!Y)return;let D=null,ee=null,Ce=0,_e=0,Se=0,Ge=0,Le=0;const ke=Me=>{if(De.current.readOnly)return;Me.preventDefault(),Me.stopPropagation(),Ne.current||Me.metaKey||Me.ctrlKey?(Se+=Me.deltaY,Ge=Me.clientX,Le=Me.clientY,ee===null&&(ee=requestAnimationFrame(()=>{ee=null;const Ye=De.current,yr=M.zoom(),Oe=Se;Se=0;let wr=yr-Oe*.05/100;wr=Math.max(Ye.minZoom??.01,Math.min(Ye.maxZoom??1.5,wr));const $r=Y.getBoundingClientRect();M.zoomAt(wr,{x:Ge-$r.left,y:Le-$r.top})}))):(Ce+=Me.deltaX,_e+=Me.deltaY,D===null&&(D=requestAnimationFrame(()=>{D=null;const Ye=M.pan(),yr=M.zoom(),Oe=.35,wr=Ce,$r=_e;Ce=0,_e=0,M.pan({x:Ye.x+-wr*Oe/yr,y:Ye.y+-$r*Oe/yr})})))};return Y.addEventListener("wheel",ke,{passive:!1}),()=>{Y.removeEventListener("wheel",ke),D!==null&&cancelAnimationFrame(D),ee!==null&&cancelAnimationFrame(ee)}},[M]),E.useEffect(()=>{if(m.disableKeyboardShortcuts)return;const Y=D=>{var Ce,_e,Se,Ge;if(De.current.readOnly)return;const ee=D.target;if(!(ee.tagName==="INPUT"||ee.tagName==="TEXTAREA"||ee.isContentEditable)){if((D.key==="z"||D.key==="Z")&&S(!Ne.current),(D.key==="m"||D.key==="M")&&k(!T),(D.key==="d"||D.key==="D")&&P(!j),(D.key==="Delete"||D.key==="Backspace")&&ze.current){D.preventDefault();const Le=ze.current;(_e=y.onEdgeDelete)==null||_e.call(y,Le,((Ce=pr.current.get(Le))==null?void 0:Ce.data)??{id:Le}),v(null);return}if((D.key==="Delete"||D.key==="Backspace")&&rr.current.length>0){D.preventDefault();const Le=rr.current.filter(ke=>ke!=="root");if(Le.length===0)return;for(const ke of Le){const Me=(Se=Ze.current.get(ke))==null?void 0:Se.data;(Ge=y.onNodeDelete)==null||Ge.call(y,ke,Me||{})}g([])}}};return window.addEventListener("keydown",Y),()=>window.removeEventListener("keydown",Y)},[T,j,S,k,P,m.disableKeyboardShortcuts,y,g,v]);const jr=E.useCallback(Y=>{var D;b.current=Y,q(Y),(D=y.onInit)==null||D.call(y,Y)},[b,y]),we=E.useCallback(Y=>{var D;return(D=y.onViewportChange)==null?void 0:D.call(y,Y)},[y]),or=E.useCallback(Y=>{var ee,Ce,_e;const D=((ee=pr.current.get(Y))==null?void 0:ee.data)??{id:Y};if(ze.current===Y&&xr.current){v(null),(Ce=y.onEdgeDeselect)==null||Ce.call(y);return}rr.current.length&&g([]),v(Y),(_e=y.onEdgeSelect)==null||_e.call(y,Y,D)},[y,v,g]),ar=E.useCallback(()=>{var Y,D,ee;a(!0),(Y=y.onBackgroundClick)==null||Y.call(y),rr.current.length&&(g([]),(D=y.onNodeDeselect)==null||D.call(y)),ze.current&&(v(null),(ee=y.onEdgeDeselect)==null||ee.call(y))},[y,g,v,a]),xt=E.useCallback(Y=>{var Ce,_e;const D=rr.current,ee=Y.filter(Se=>!D.includes(Se));if(ee.length){g([...D,...ee]);for(const Se of ee)(_e=y.onNodeSelect)==null||_e.call(y,Se,((Ce=Ze.current.get(Se))==null?void 0:Ce.data)??{id:Se})}},[y,g]),ne=E.useCallback((Y,D)=>{var ee,Ce;g([Y]),(Ce=y.onNodeSelect)==null||Ce.call(y,Y,((ee=Ze.current.get(Y))==null?void 0:ee.data)??{id:Y},D)},[y,g]),Fe=E.useCallback((Y,D,ee)=>{var Ce;return(Ce=y.onEdgeCreate)==null?void 0:Ce.call(y,Y,D,ee)},[y]),Je=E.useCallback((Y,D,ee,Ce=!1)=>{var _e,Se;l==="properties"&&((_e=y.onNodeCreateRequest)==null?void 0:_e.call(y,{sourceNodeId:Y,position:D,sourceProperty:ee,reverse:Ce}))===!0||ee!==void 0||Ce||(Se=y.onNodeCreate)==null||Se.call(y,{type:"text",sourceNodeId:Y,position:D,isArrayMode:He.current})},[y,l]),$e=!m.readOnly&&R&&m.edgeHandles!==!1,Xe=i==="transparent"?"none":i;return h.jsx(k_,{pattern:Xe,backgroundColor:B,children:h.jsx(F.Box,{ref:O,padding:0,width:"100%",height:"100%",flex:1,position:"relative",children:h.jsx(f_,{nodes:Te,edges:ge,direction:G,nodeAlignment:c,onContainerCollapse:Y=>{var D,ee;(D=y.onNodeCollapse)==null||D.call(y,Y,!0),(ee=y.onNodeViewToggle)==null||ee.call(y,Y)},selectedNodeIds:x,edgeMode:l,compactPropertyLayout:d,edgeType:m.edgeType,edgeRadius:o,customEdgeTypes:m.customEdgeTypes,rankSep:re,edgeSep:V,spacingFactor:ce,compactSpacingScale:n,layoutDebounce:er,isPerformanceMode:H,minZoom:m.minZoom??.01,maxZoom:m.maxZoom??1.5,initialViewport:Q,fitOnInit:!m.initialViewport,readOnly:!!m.readOnly,containerStyle:fe,lineColor:se,drawMode:$e,drawHandles:!m.readOnly&&m.edgeHandles!==!1,dragMode:j,multiSelect:!!T,onInit:jr,onLayoutComplete:y.onLayoutComplete,animateViewport:m.animateViewport,onViewportChange:we,onBackgroundTap:ar,onBoxSelect:xt,onEdgeSelect:or,onContainerSelect:ne,onEdgeDraw:Fe,onDrawIntoSpace:Je})})})},$m=E.memo(A_),T_=".flow-sdk-canvas{position:relative;width:100%;height:100%;overflow:clip;user-select:none;-webkit-user-select:none;touch-action:none}.flow-sdk-svg{position:absolute;top:0;left:0;width:100%;height:100%;overflow:visible;display:block}.flow-sdk-nodes{position:absolute;top:0;left:0;transform-origin:0 0;pointer-events:none;will-change:transform;backface-visibility:hidden;z-index:10}.flow-sdk-node{position:absolute;top:0;left:0;transform-origin:0 0;pointer-events:auto;will-change:transform;backface-visibility:hidden;z-index:10}.flow-sdk-node input,.flow-sdk-node textarea{pointer-events:auto;user-select:text;-webkit-user-select:text;cursor:text}.flow-sdk-edge-hit{fill:none;stroke:transparent;stroke-width:24px;vector-effect:non-scaling-stroke;pointer-events:stroke;cursor:pointer}.flow-sdk-container{cursor:pointer}.flow-sdk-edge-anim{animation:flow-sdk-dash .5s linear infinite}.flow-sdk-edge-anim-rev{animation-direction:reverse}@keyframes flow-sdk-dash{to{stroke-dashoffset:-50}}.flow-sdk-draw{cursor:crosshair}.flow-sdk-draw .flow-sdk-node,.flow-sdk-draw .flow-sdk-node input,.flow-sdk-draw .flow-sdk-node textarea,.flow-sdk-draw .flow-sdk-edge,.flow-sdk-draw .flow-sdk-container{pointer-events:none}.flow-sdk-perf.flow-sdk-busy .flow-sdk-edges{display:none}.flow-sdk-box{position:absolute;border:1px solid rgba(170,170,170,.9);background:rgba(221,221,221,.25);pointer-events:none;z-index:20}";let ly=!1;function O_(){if(ly||typeof document>"u")return;const e=document.createElement("style");e.setAttribute("data-flow-sdk",""),e.textContent=T_+f0+l0+".flow-sdk-handle{position:absolute;left:-36px;top:50%;transform:translateY(-50%);width:36px;height:36px;display:grid;place-items:center;border:2px solid currentColor;border-radius:50%;background:white;cursor:crosshair;opacity:0;pointer-events:none}.flow-sdk-node:hover>.flow-sdk-handle,.flow-sdk-handle:focus-visible{opacity:1;pointer-events:auto}.flow-sdk-draw .flow-sdk-node *,.flow-sdk-draw .flow-sdk-edge *,.flow-sdk-draw .flow-sdk-container *,.flow-sdk-ghost *{pointer-events:none}",document.head.appendChild(e),e.textContent+=".flow-sdk-draw .flow-sdk-node{pointer-events:auto}.flow-sdk-draw .flow-sdk-node>.flow-sdk-handle{opacity:0;pointer-events:none}.flow-sdk-draw .flow-sdk-node:hover>.flow-sdk-handle,.flow-sdk-draw .flow-sdk-node>.flow-sdk-handle:focus-visible{opacity:1;pointer-events:auto}",e.textContent+='.flow-sdk-property-port{position:absolute;transform:translateY(-50%);width:32px;height:32px;margin:0;padding:0;border:3px solid currentColor;border-radius:50%;background:white;cursor:crosshair;pointer-events:auto;z-index:20}.flow-sdk-property-port[data-port-role="source"]{background:currentColor}.flow-sdk-property-port:hover{outline:3px solid currentColor;outline-offset:3px}.flow-sdk-draw .flow-sdk-node .flow-sdk-property-port{pointer-events:auto}',ly=!0}function I_({loading:e=!1,loader:t,...r}){var u,c;const[n,o]=E.useState(null),i=E.useMemo(()=>!!(n!=null&&n.json)&&!!r.json&&s0(n.json,r.json),[n==null?void 0:n.json,r.json]),a=n===null||n.json!==r.json&&!i,s=e||a;return E.useEffect(()=>{!e&&i&&(n==null?void 0:n.json)!==r.json&&o(r)},[e,i,n==null?void 0:n.json,r.json]),E.useEffect(()=>{if(e||!a)return;let l;const d=requestAnimationFrame(()=>{l=requestAnimationFrame(()=>o(r))});return()=>{cancelAnimationFrame(d),l!==void 0&&cancelAnimationFrame(l)}},[e,a,r.json]),h.jsxs(F.Box,{className:r.className,style:r.style,width:"100%",height:"100%",position:"relative","aria-busy":s,children:[h.jsx("div",{style:{width:"100%",height:"100%"},ref:l=>{s?l==null||l.setAttribute("inert",""):l==null||l.removeAttribute("inert")},children:n&&h.jsx(M_,{...a?n:r,className:void 0,style:void 0})}),s&&h.jsx(F.Box,{"data-flow-loader":"",role:"status","aria-label":"Loading diagram",position:"absolute",inset:0,zIndex:1e3,display:"grid",placeItems:"center",background:((u=r.config)==null?void 0:u.colorMode)==="dark"?"gray.800":"gray.100",color:((c=r.config)==null?void 0:c.colorMode)==="dark"?"whiteAlpha.800":"blackAlpha.800",children:t===void 0?h.jsx("span",{children:"Loading diagram..."}):t})]})}function M_({title:e="untitled",json:t,forms:r,nodes:n,edges:o,config:i={},callbacks:a={},className:s,style:u,showBottomBar:c=!0,children:l}){O_();const[d,f]=E.useState(),p=i.formSchema??d,b=E.useMemo(()=>t&&r?Qy(t,r.state):t,[t,r==null?void 0:r.state]),y=i.direction==="C",m=E.useMemo(()=>{let k,j;return P=>(j=k&&j?c0(k,P,j)??mu(P,{title:e,isCenter:y}):mu(P,{title:e,isCenter:y}),k=P,j)},[e,y]),x=E.useMemo(()=>b?m(b):null,[b,m]),g=E.useMemo(()=>r!=null&&r.structured&&p?r0(r.state,r.bindings,p,(x==null?void 0:x.nodes)??n??[]):void 0,[r==null?void 0:r.structured,r==null?void 0:r.state,r==null?void 0:r.bindings,p,x,n]),w=(g==null?void 0:g.schema)??p,v=(g==null?void 0:g.bindings)??(r==null?void 0:r.bindings),_=E.useMemo(()=>[...(x==null?void 0:x.nodes)??n??[],...(g==null?void 0:g.nodes)??[]].map(j=>{var H,V,re,ce;const P=t?(H=xe(t,j.data.id))==null?void 0:H.$view:(V=j.data.config)==null?void 0:V.typeView,R=P&&Ft.includes(P)?P:void 0,I=R?R==="icon-label":(re=j.data.config)==null?void 0:re.labelBelow,O=R==="object"?"objectView":R==="text"?"text":I?"arrayView":j.data.type,M=w&&(r?Jt(v,j.data.id,w):t&&pt(t,j.data.id,w)),q=(((ce=j.data.config)==null?void 0:ce.ports)??[]).map(le=>({...le}));if(g&&M){const le=i.direction==="RL"?{input:"right",output:"left",config:"bottom",error:"top"}:i.direction==="TB"?{input:"top",output:"bottom",config:"right",error:"left"}:i.direction==="BT"?{input:"bottom",output:"top",config:"left",error:"right"}:{input:"left",output:"right",config:"top",error:"bottom"};for(const[be,K]of Object.entries(M.type.ports??{})){const N=`${K.kind}:${be}`;q.some(B=>B.id===N)||q.push({id:N,role:K.kind==="input"||K.kind==="config"?"target":"source",side:le[K.kind],...K.kind==="config"?{placement:"config"}:{}})}for(const be of q){const K=q.filter(N=>N.side===be.side);be.position=(K.indexOf(be)+1)/(K.length+1)}}return M||I||R?{...j,data:{...j.data,type:O,...r?{description:Object.fromEntries(Object.entries(j.data.description??{}).filter(([le])=>!le.startsWith("$")&&!(g!=null&&g.slots.has(Et(j.data.id,le)))))}:{},config:{...j.data.config,...g&&M?{ports:q}:{},...M?{form:!0}:{},...R?{typeView:R,labelBelow:!!I}:I?{labelBelow:!0}:{}}}}:j}),[x,n,t,w,v,g,i.direction]),C=[...(x==null?void 0:x.edges)??o??[],...(g==null?void 0:g.edges)??[]],S=E.useMemo(()=>{const k=t&&x?vb(t,x.edges,a,a.onJsonChange,p):{...a};if(g){const j=new Set([...g.nodes.map(P=>P.data.id),...g.edges.map(P=>P.data.id)]);for(const P of Object.keys(k)){if(!/^on(?:Node|Edge).*(?:Change|Collapse)$/.test(P))continue;const R=k[P];k[P]=(I,...O)=>{if(!j.has(I))return R==null?void 0:R(I,...O)}}}return k},[t,x,a,p,g]),T=E.useMemo(()=>{if(!r)return S;let k=r.state;const j=R=>{if(i.readOnly||i.editable===!1)return;const I=r.onStateChange??r.onChange;if(!I)return;const O=Kx(k,R,a.onFormChange);O!==k&&(k=O,I(O,{...R,data:O}))},P=(R,I,O)=>{var q;const M=t&&((q=xe(t,R))==null?void 0:q[I]);return!M||typeof M.$state!="string"?!1:(j({address:M.$state,nodeAddress:R,previousValue:xe(k,M.$state),value:O,data:k}),!0)};return{...S,onFormChange:j,onNodeCreateRequest:R=>{var M,q;const I=(M=R.sourceProperty)!=null&&M.startsWith("config:")?R.sourceProperty.slice(7):void 0,O=I!==void 0&&(g==null?void 0:g.slots.get(Et(R.sourceNodeId,I)));return O?(O.present||j({data:k,nodeAddress:O.address.split(".").slice(0,-1).join("."),address:O.address,value:Rt(O.type),previousValue:void 0}),!0):((q=S.onNodeCreateRequest)==null?void 0:q.call(S,R))??!1},onNodeDelete:(R,I)=>{var re,ce;if(!(g!=null&&g.nodes.some(le=>le.data.id===R)))return(re=S.onNodeDelete)==null?void 0:re.call(S,R,I);const O=g&&[...g.slots.values()].find(le=>le.nodeId===R);if(!O)return(ce=S.onNodeDelete)==null?void 0:ce.call(S,R,I);const M=O.address.split("."),q=M.pop(),H=M.join("."),V=xe(k,H);j(Array.isArray(V)?{data:k,nodeAddress:H,address:H,previousValue:V,value:V.filter((le,be)=>String(be)!==q)}:{data:k,nodeAddress:H,address:O.address,previousValue:xe(k,O.address),value:void 0})},onEdgeCreate:(R,I,O)=>{var H,V;const M=((H=O==null?void 0:O.targetProperty)==null?void 0:H.startsWith("config:"))&&(g==null?void 0:g.slots.get(Et(I,O.targetProperty.slice(7)))),q=g==null?void 0:g.containers.get(R);if(M&&q&&(O==null?void 0:O.sourceProperty)==="output:resource"){const re=e0(k,q,M);re!==void 0&&j({data:k,nodeAddress:M.address.split(".").slice(0,-1).join("."),address:M.address,previousValue:xe(k,M.address),value:re});return}M||g!=null&&g.nodes.some(re=>re.data.id===R||re.data.id===I)||(V=S.onEdgeCreate)==null||V.call(S,R,I,O)},onEdgeDelete:(R,I)=>{var ce;const O=g==null?void 0:g.edges.find(le=>le.data.id===R);if(!O)return(ce=S.onEdgeDelete)==null?void 0:ce.call(S,R,I);const M=g.slots.get(Et(O.data.target,O.data.targetProperty.slice(7))),q=M.address.split("."),H=q.pop(),V=q.join("."),re=xe(k,V);j(Array.isArray(re)?{data:k,nodeAddress:V,address:V,previousValue:re,value:re.filter((le,be)=>String(be)!==H)}:{data:k,nodeAddress:V,address:M.address,previousValue:xe(k,M.address),value:void 0})},onNodeContentChange:(R,I)=>{var O,M;P(R,"$content",I)?(O=a.onNodeContentChange)==null||O.call(a,R,I):(M=S.onNodeContentChange)==null||M.call(S,R,I)},onNodeLabelChange:(R,I)=>{var O,M;P(R,"$label",I)?(O=a.onNodeLabelChange)==null||O.call(a,R,I):(M=S.onNodeLabelChange)==null||M.call(S,R,I)}}},[S,r,t,a,g,i.readOnly,i.editable]);return h.jsx(kr.Provider,{value:{data:(r==null?void 0:r.state)??t,viewData:t,bindings:v,references:r==null?void 0:r.references,structured:g,renderForm:r==null?void 0:r.renderForm,editable:r?!!(r.onStateChange??r.onChange):!!a.onJsonChange,schema:w,setSchema:k=>{var j;f(k),(j=a.onFormSchemaChange)==null||j.call(a,k)},callbacks:T},children:h.jsx(py,{config:g?{...i,formSchema:w}:i,callbacks:T,nodes:_,edges:C,children:h.jsxs(F.Box,{className:s,"data-flow-diagram":"",style:u,width:"100%",height:"100%",position:"relative",overflow:"hidden",css:{"& input, & textarea, & select":{outline:"none !important",boxShadow:"none !important"}},children:[h.jsx($m,{nodes:_,edges:C}),c&&h.jsx(yb,{}),l]})})})}function sn(e){let t="",r=!1,n="",o;const i=()=>{clearTimeout(o),o=void 0},a=()=>{if(i(),!(r||!t.trim()))try{const u=e.parse(e.repair(t)),c=JSON.stringify(u);if(c===n)return;e.preview(u),n=c}catch{}},s=u=>{if(!r){if(new TextEncoder().encode(u).byteLength>(e.maxBytes??1024*1024))throw r=!0,i(),new Error("JSON stream exceeds the size limit.");t=u,o||(o=setTimeout(a,e.intervalMs??150))}};return{snapshot:s,append(u){s(t+u)},flush:a,finish(){if(r)throw new Error("JSON stream is closed.");r=!0,i();const u=e.parse(t);return e.commit(u),u},cancel(){r=!0,i(),t=""}}}function q_(e){const{source:t}=e,r=e.tickMs??50,n=e.durationMs??8e3;if(!Number.isFinite(r)||r<=0||!Number.isFinite(n)||n<=0)throw new Error("Playback timing must be positive.");if(new TextEncoder().encode(t).byteLength>(e.maxBytes??1024*1024))throw new Error("JSON stream exceeds the size limit.");e.parse(t);let o=sn(e),i=0,a=!1,s=!1,u;const c=Math.max(1,Math.ceil(t.length*r/n)),l=()=>e.onChange({position:i,total:t.length,playing:a}),d=()=>{clearTimeout(u),u=void 0},f=(y=!1)=>{o.snapshot(t.slice(0,i)),i===t.length?(a=!1,d(),o.finish()):y&&o.flush()},p=y=>{a=!1,d(),o.cancel(),l(),e.onError(y)},b=()=>{if(u=void 0,!(!a||s)){i=Math.min(t.length,i+c);try{f()}catch(y){p(y);return}l(),a&&(u=setTimeout(b,r))}};return{play(){s||a||(i===t.length&&(o.cancel(),o=sn(e),i=0),a=!0,l(),u=setTimeout(b,r))},pause(){s||(a=!1,d(),o.flush(),l())},seek(y){if(!s){if(!Number.isFinite(y))throw new Error("Playback position must be finite.");d(),i=Math.max(0,Math.min(t.length,Math.round(y))),o.cancel(),o=sn(e);try{f(!0)}catch(m){p(m);return}l(),a&&(u=setTimeout(b,r))}},dispose(){s=!0,a=!1,d(),o.cancel()}}}function N_(e,t){const r=(n,o)=>{if(n===null||typeof n!="object")return typeof n==typeof o?n:void 0;if(!(!o||typeof o!="object"))return Array.isArray(n)?Array.isArray(o)?n.map((i,a)=>r(i,o[a])).filter(i=>i!==void 0):void 0:Object.fromEntries(Object.entries(n).flatMap(([i,a])=>{if(!Object.prototype.hasOwnProperty.call(o,i))return[];if(i.startsWith("$")&&i!=="$")return JSON.stringify(a)===JSON.stringify(o[i])?[[i,a]]:[];const s=r(a,o[i]);return s===void 0?[]:[[i,s]]}))};return r(e,t)??{}}function $_(e){return _u(JSON.parse(e))}function _u(e){if(!e||typeof e!="object")throw new Error("Expected a JSON object or array.");const t=new Set,r=n=>{if(!(n===null||typeof n=="string"||typeof n=="boolean")&&!(typeof n=="number"&&Number.isFinite(n))){if(!n||typeof n!="object"||t.has(n)||!Array.isArray(n)&&![Object.prototype,null].includes(Object.getPrototypeOf(n)))throw new Error("Document must contain only finite, acyclic JSON values.");t.add(n);for(const[o,i]of Object.entries(n)){if(["__proto__","prototype","constructor"].includes(o))throw new Error(`Unsafe document key: ${o}`);r(i)}t.delete(n)}};return r(e),structuredClone(e)}function L_(e){return{replaceJson(t){if(e.readOnly||!e.onJsonChange)throw new Error("JSON document is read-only.");const r=_u(t);return e.onJsonChange(r,{type:"documentReplace",address:"root"}),r},replaceState(t){if(e.readOnly||!e.onStateChange)throw new Error("Form state is read-only.");const r=_u(t);return e.onStateChange(r,{address:"root",nodeAddress:"root",previousValue:e.state,value:r,data:r}),r}}}function F_({nodeAddress:e,expanded:t=!1}){var c;const{data:r,schema:n,bindings:o}=E.useContext(kr),{colorText:i,background:a}=Ve();if((c=o==null?void 0:o[e])!=null&&c.portResources)return null;const s=o&&Jt(o,e,n);if(!r||!s)return null;const u=xe(r,s.address);return!u||typeof u!="object"?null:h.jsx("div",{"data-flow-config-summary":"",style:{width:"100%",minWidth:0,color:pe(i),background:pe(a),fontSize:24,lineHeight:1.4,textTransform:"none"},children:Object.keys(s.type.properties).map(l=>{const d=s.fields[l]??{};if(!vn(d.$visibleWhen,r))return null;const f=u[l],p=f==null?"":typeof f=="object"?JSON.stringify(f):String(f);return h.jsxs("div",{"data-flow-property":l,style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(0, 1fr)",gap:12,padding:"10px 16px",borderTop:"1px solid color-mix(in srgb, currentColor 12%, transparent)"},children:[h.jsx("span",{style:{overflowWrap:"anywhere"},children:Cr(d.$label??l)}),h.jsx("span",{title:p,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:t?"pre-wrap":"nowrap",overflowWrap:t?"anywhere":void 0},children:p})]},l)})})}exports.BottomBar=yb;exports.CompactPropertyLayoutToggle=Dy;exports.ConnectionsOnlyToggle=a0;exports.DEFAULT_PALETTE=Nu;exports.DiagramAppearanceControls=Fy;exports.DynamicIcon=Mr;exports.EdgeTools=ab;exports.EditableLabel=Kt;exports.ErrorToast=hb;exports.FlowDiagram=I_;exports.FlowDiagramProvider=py;exports.FlowPort=Pm;exports.FlowView=$m;exports.FormDocumentContext=kr;exports.NODE_TYPE_VIEWS=Ft;exports.NodeBorderRadiusControl=sb;exports.NodeConfigSummary=F_;exports.NodeForm=rb;exports.NodeFormPopover=Am;exports.NodeIconPicker=qu;exports.NodeTools=cb;exports.NodeView=Bn;exports.SvgExportButton=db;exports.Swatches=Ht;exports.TEXT_PALETTE=ob;exports.ToolbarCloseButton=ht;exports.ToolbarCommitInput=Xr;exports.ToolbarDivider=Ot;exports.ToolbarIconButton=ve;exports.ToolbarRangeInput=Ly;exports.ToolbarScrollContainer=fb;exports.ToolbarSelect=Or;exports.ToolbarTooltip=je;exports.TooltipIconButton=Cu;exports.WorkflowControls=pb;exports.addChild=Pu;exports.addConnection=Au;exports.addTargetEdge=Zy;exports.addressToPath=Ir;exports.applyCollapsed=Ux;exports.applyFormChange=xn;exports.applyStateEdits=Hx;exports.bindSqueedCallbacks=vb;exports.compileSqueed=mu;exports.connectionIssue=Iu;exports.contentObjTheme=Er;exports.createFlowDiagram=Yr;exports.createFlowDocumentActions=L_;exports.createFormNode=mb;exports.createJsonPlayback=q_;exports.createJsonStream=sn;exports.downloadSvg=lb;exports.exportSvg=ub;exports.formValueError=Rr;exports.getChakraColorHex=pe;exports.getColorVariant=gy;exports.getDarkerHexColor=cn;exports.getNode=xe;exports.parseFlowDocument=$_;exports.parseJsonContract=Tu;exports.parseTypeScriptContract=Yy;exports.parseTypeScriptForm=Ou;exports.projectJsonPlaybackPreview=N_;exports.readFormSchema=Mu;exports.readWorkflowContract=Xy;exports.removeEdge=Jy;exports.removeNode=Ky;exports.resolveEdgeOwner=zt;exports.resolveStateView=Qy;exports.setCollapsed=Uy;exports.setEdgeProp=Fr;exports.setEdgeStyle=Hy;exports.setNodeProp=ir;exports.updateNode=hr;exports.useCustomColors=Ve;exports.useFlowData=Wr;exports.useFlowDiagramContext=Ie;exports.useNodeViewActions=Dn;exports.useStopPropagation=tl;exports.useThemeContentColors=Zt;
358
182
  //# sourceMappingURL=index.cjs.map