vsview-graph 0.1.0__py3-none-any.whl
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.
- vsview_graph/__init__.py +12 -0
- vsview_graph/analysis.py +322 -0
- vsview_graph/bridge.py +168 -0
- vsview_graph/call.py +122 -0
- vsview_graph/constants.py +2 -0
- vsview_graph/plugin.py +509 -0
- vsview_graph/py.typed +1 -0
- vsview_graph/settings.py +164 -0
- vsview_graph/theme.py +48 -0
- vsview_graph/web.py +27 -0
- vsview_graph/web_dist/THIRD_PARTY_LICENSES.md +78 -0
- vsview_graph/web_dist/assets/index-BKkkzcEy.js +769 -0
- vsview_graph/web_dist/assets/index-Dgbf_RCq.css +1 -0
- vsview_graph/web_dist/index.html +38 -0
- vsview_graph-0.1.0.dist-info/METADATA +34 -0
- vsview_graph-0.1.0.dist-info/RECORD +19 -0
- vsview_graph-0.1.0.dist-info/WHEEL +4 -0
- vsview_graph-0.1.0.dist-info/entry_points.txt +2 -0
- vsview_graph-0.1.0.dist-info/licenses/LICENSE +291 -0
|
@@ -0,0 +1,769 @@
|
|
|
1
|
+
var e=globalThis,t=e=>e,n=e.trustedTypes,r=n?n.createPolicy(`lit-html`,{createHTML:e=>e}):void 0,i=`$lit$`,a=`lit$${Math.random().toFixed(9).slice(2)}$`,o=`?`+a,s=`<${o}>`,c=document,l=()=>c.createComment(``),u=e=>e===null||typeof e!=`object`&&typeof e!=`function`,d=Array.isArray,f=e=>d(e)||typeof e?.[Symbol.iterator]==`function`,p=`[
|
|
2
|
+
\f\r]`,m=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,h=/-->/g,g=/>/g,_=RegExp(`>|${p}(?:([^\\s"'>=/]+)(${p}*=${p}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,`g`),v=/'/g,y=/"/g,b=/^(?:script|style|textarea|title)$/i,x=(e=>(t,...n)=>({_$litType$:e,strings:t,values:n}))(1),S=Symbol.for(`lit-noChange`),C=Symbol.for(`lit-nothing`),w=new WeakMap,T=c.createTreeWalker(c,129);function E(e,t){if(!d(e)||!e.hasOwnProperty(`raw`))throw Error(`invalid template strings array`);return r===void 0?t:r.createHTML(t)}var D=(e,t)=>{let n=e.length-1,r=[],o,c=t===2?`<svg>`:t===3?`<math>`:``,l=m;for(let t=0;t<n;t++){let n=e[t],u,d,f=-1,p=0;for(;p<n.length&&(l.lastIndex=p,d=l.exec(n),d!==null);)p=l.lastIndex,l===m?d[1]===`!--`?l=h:d[1]===void 0?d[2]===void 0?d[3]!==void 0&&(l=_):(b.test(d[2])&&(o=RegExp(`</`+d[2],`g`)),l=_):l=g:l===_?d[0]===`>`?(l=o??m,f=-1):d[1]===void 0?f=-2:(f=l.lastIndex-d[2].length,u=d[1],l=d[3]===void 0?_:d[3]===`"`?y:v):l===y||l===v?l=_:l===h||l===g?l=m:(l=_,o=void 0);let x=l===_&&e[t+1].startsWith(`/>`)?` `:``;c+=l===m?n+s:f>=0?(r.push(u),n.slice(0,f)+i+n.slice(f)+a+x):n+a+(f===-2?t:x)}return[E(e,c+(e[n]||`<?>`)+(t===2?`</svg>`:t===3?`</math>`:``)),r]},O=class e{constructor({strings:t,_$litType$:r},s){let c;this.parts=[];let u=0,d=0,f=t.length-1,p=this.parts,[m,h]=D(t,r);if(this.el=e.createElement(m,s),T.currentNode=this.el.content,r===2||r===3){let e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;(c=T.nextNode())!==null&&p.length<f;){if(c.nodeType===1){if(c.hasAttributes())for(let e of c.getAttributeNames())if(e.endsWith(i)){let t=h[d++],n=c.getAttribute(e).split(a),r=/([.?@])?(.*)/.exec(t);p.push({type:1,index:u,name:r[2],strings:n,ctor:r[1]===`.`?N:r[1]===`?`?P:r[1]===`@`?F:M}),c.removeAttribute(e)}else e.startsWith(a)&&(p.push({type:6,index:u}),c.removeAttribute(e));if(b.test(c.tagName)){let e=c.textContent.split(a),t=e.length-1;if(t>0){c.textContent=n?n.emptyScript:``;for(let n=0;n<t;n++)c.append(e[n],l()),T.nextNode(),p.push({type:2,index:++u});c.append(e[t],l())}}}else if(c.nodeType===8){if(c.data===o)p.push({type:2,index:u});else{let e=-1;for(;(e=c.data.indexOf(a,e+1))!==-1;)p.push({type:7,index:u}),e+=a.length-1}}u++}}static createElement(e,t){let n=c.createElement(`template`);return n.innerHTML=e,n}};function k(e,t,n=e,r){if(t===S)return t;let i=r===void 0?n._$Cl:n._$Co?.[r],a=u(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,r)),r===void 0?n._$Cl=i:(n._$Co??=[])[r]=i),i!==void 0&&(t=k(e,i._$AS(e,t.values),i,r)),t}var A=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,r=(e?.creationScope??c).importNode(t,!0);T.currentNode=r;let i=T.nextNode(),a=0,o=0,s=n[0];for(;s!==void 0;){if(a===s.index){let t;s.type===2?t=new j(i,i.nextSibling,this,e):s.type===1?t=new s.ctor(i,s.name,s.strings,this,e):s.type===6&&(t=new I(i,this,e)),this._$AV.push(t),s=n[++o]}a!==s?.index&&(i=T.nextNode(),a++)}return T.currentNode=c,r}p(e){let t=0;for(let n of this._$AV)n!==void 0&&(n.strings===void 0?n._$AI(e[t]):(n._$AI(e,n,t),t+=n.strings.length-2)),t++}},j=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,r){this.type=2,this._$AH=C,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=k(this,e,t),u(e)?e===C||e==null||e===``?(this._$AH!==C&&this._$AR(),this._$AH=C):e!==this._$AH&&e!==S&&this._(e):e._$litType$===void 0?e.nodeType===void 0?f(e)?this.k(e):this._(e):this.T(e):this.$(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==C&&u(this._$AH)?this._$AA.nextSibling.data=e:this.T(c.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,r=typeof n==`number`?this._$AC(e):(n.el===void 0&&(n.el=O.createElement(E(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(t);else{let e=new A(r,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=w.get(e.strings);return t===void 0&&w.set(e.strings,t=new O(e)),t}k(t){d(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,i=0;for(let a of t)i===n.length?n.push(r=new e(this.O(l()),this.O(l()),this,this.options)):r=n[i],r._$AI(a),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,n){for(this._$AP?.(!1,!0,n);e!==this._$AB;){let n=t(e).nextSibling;t(e).remove(),e=n}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},M=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,r,i){this.type=1,this._$AH=C,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=i,n.length>2||n[0]!==``||n[1]!==``?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=C}_$AI(e,t=this,n,r){let i=this.strings,a=!1;if(i===void 0)e=k(this,e,t,0),a=!u(e)||e!==this._$AH&&e!==S,a&&(this._$AH=e);else{let r=e,o,s;for(e=i[0],o=0;o<i.length-1;o++)s=k(this,r[n+o],t,o),s===S&&(s=this._$AH[o]),a||=!u(s)||s!==this._$AH[o],s===C?e=C:e!==C&&(e+=(s??``)+i[o+1]),this._$AH[o]=s}a&&!r&&this.j(e)}j(e){e===C?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??``)}},N=class extends M{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===C?void 0:e}},P=class extends M{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==C)}},F=class extends M{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){if((e=k(this,e,t,0)??C)===S)return;let n=this._$AH,r=e===C&&n!==C||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,i=e!==C&&(n===C||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH==`function`?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},I=class{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){k(this,e)}},L={M:i,P:a,A:o,C:1,L:D,R:A,D:f,V:k,I:j,H:M,N:P,U:F,B:N,F:I},R=e.litHtmlPolyfillSupport;R?.(O,j),(e.litHtmlVersions??=[]).push(`3.3.3`);var z=(e,t,n)=>{let r=n?.renderBefore??t,i=r._$litPart$;if(i===void 0){let e=n?.renderBefore??null;r._$litPart$=i=new j(t.insertBefore(l(),e),e,void 0,n??{})}return i._$AI(e),i},B=class e{value;ok=!0;constructor(e){this.value=e}map(t){return new e(t(this.value))}mapErr(t){return new e(this.value)}andThen(e){return e(this.value)}tap(e){return e(this.value),this}match(e){return e.ok(this.value)}unwrap(){return this.value}unwrapOr(e){return this.value}},V=class e{error;ok=!1;constructor(e){this.error=e}map(e){return this}mapErr(t){return new e(t(this.error))}andThen(e){return this}tap(e){return this}match(e){return e.err(this.error)}unwrap(){throw this.error instanceof Error?this.error:Error(String(this.error),{cause:this.error})}unwrapOr(e){return e}},H=class e{promise;static fromResult(t){return new e(Promise.resolve(t))}constructor(e){this.promise=e}then(e,t){return this.promise.then(e,t)}map(t){return new e(this.promise.then(async e=>e.ok?U.ok(await t(e.value)):e))}mapErr(t){return new e(this.promise.then(async e=>e.ok?U.ok(e.value):U.err(await t(e.error))))}andThen(t){return new e(this.promise.then(async e=>e.ok?await t(e.value):e))}tap(t){return new e(this.promise.then(async e=>(e.ok&&await t(e.value),e)))}async match(e){let t=await this.promise;return t.ok?e.ok(t.value):e.err(t.error)}async unwrap(){return(await this.promise).unwrap()}async unwrapOr(e){let t=await this.promise;return t.ok?t.value:e}},U={ok(e){return new B(e)},err(e){return new V(e)},fromThrowable:W,fromPromise:ee};function W(e,t){try{return new B(e())}catch(e){return new V(t?t(e):G(e))}}function ee(e,t){return new H((async()=>{try{return new B(typeof e==`function`?await e():await e)}catch(e){return new V(t?t(e):G(e))}})())}function G(e){return e instanceof Error?e:Error(String(e))}function K(e){let t=!1;return{dispose:()=>{t||(t=!0,e())}}}var q=class{isDisposed=!1;disposables=[];add(e){return this.isDisposed?(console.warn(`Adding a disposable to a disposed DisposableStore; it is disposed at once. This is likely a use-after-dispose bug.`),e.dispose()):this.disposables.push(e),e}dispose(){if(!this.isDisposed)for(this.isDisposed=!0;this.disposables.length>0;)U.fromThrowable(()=>this.disposables.pop()?.dispose()).mapErr(e=>console.error(`Error during resource disposal:`,e))}[Symbol.dispose](){this.dispose()}},J=class{_disposables=new q;dispose(){this._disposables.dispose()}[Symbol.dispose](){this.dispose()}},te=3e4,ne=class extends J{bridge=null;commandHandlers=new Map;isDisposed=!1;boundSignalHandler=null;initResult=null;pendingInvokes=new Set;initBridge(){return this.isDisposed?H.fromResult(U.err(Error(`Cannot initialize a disposed bridge`))):(this.initResult??=this.connectBridge().mapErr(e=>(this.initResult=null,e)),this.initResult)}onCommand(e,t){let n=t,r=this.commandHandlers.get(e)??[];return r.push(n),this.commandHandlers.set(e,r),K(()=>{let t=this.commandHandlers.get(e);if(t){let e=t.indexOf(n);e!==-1&&t.splice(e,1)}})}sendEvent(...[e,t]){if(!this.bridge){let t=Error(`Cannot send event '${e}': Bridge not ready`);return console.error(t.message),U.err(t)}return U.fromThrowable(()=>{let n=JSON.stringify(t??{});this.bridge.dispatchFromJs(e,n)}).mapErr(t=>(console.error(`Failed to send bridge event '${e}':`,t),t))}invoke(e,t=`Bridge RPC call returned no result`){let n=this.bridge;return n?U.fromPromise(()=>new Promise((r,i)=>{let a=e=>{clearTimeout(s),this.pendingInvokes.delete(o),e.ok?r(e.value):i(e.error)},o=e=>a(U.err(e));this.pendingInvokes.add(o);let s=setTimeout(()=>o(Error(`Bridge RPC call timed out after ${te} ms`)),te),c=U.fromThrowable(()=>{e(n,e=>{a(e==null?U.err(Error(t)):U.ok(e))})});c.ok||o(c.error)})):H.fromResult(U.err(Error(`Bridge not ready`)))}dispose(){this.isDisposed=!0,this.commandHandlers.clear(),this.detachBridge();let e=[...this.pendingInvokes];this.pendingInvokes.clear();for(let t of e)t(Error(`Bridge was disposed before the RPC call returned`));super.dispose()}onBridgeReady(e){}onBridgeError(e){}handleCommand(e,t){if(this.isDisposed)return;let n={};if(t){let r=U.fromThrowable(()=>JSON.parse(t));if(!r.ok){console.error(`Failed to parse command payload for ${e}:`,r.error);return}n=r.value}if(typeof n!=`object`||!n||Array.isArray(n)){console.error(`Invalid non-object payload for bridge command ${e}:`,n);return}let r=this.commandHandlers.get(e);if(!r||r.length===0)console.debug(`No handler registered for bridge command: ${e}`);else for(let t of[...r])U.fromThrowable(()=>t(n)).mapErr(t=>{console.error(`Error in handler for bridge command ${e}:`,t)})}connectBridge(){return U.fromPromise(()=>new Promise((e,t)=>{let n=e=>{t(e),console.error(e),this.onBridgeError(e)},r=window.qt?.webChannelTransport;if(!r){n(Error(`Qt WebChannel transport is not available`));return}let i=U.fromThrowable(()=>new window.QWebChannel(r,r=>{if(this.isDisposed){t(Error(`Bridge was disposed before the Qt WebChannel was ready`));return}let i=r.objects.bridge;if(!i){n(Error(`Bridge object not found on Qt WebChannel`));return}let a=U.fromThrowable(()=>this.attachBridge(i));a.ok?e(i):(this.detachBridge(),n(a.error))}));i.ok||n(i.error)}))}attachBridge(e){this.bridge=e,this.boundSignalHandler=(e,t)=>this.handleCommand(e,t),e.dispatchCommandSignal.connect(this.boundSignalHandler),this.onBridgeReady(e),e.onWebReady()}detachBridge(){let{bridge:e,boundSignalHandler:t}=this;this.bridge=null,this.boundSignalHandler=null,e&&t&&U.fromThrowable(()=>e.dispatchCommandSignal.disconnect(t)).mapErr(e=>{console.error(`Failed to disconnect the bridge command signal:`,e)})}},re=class extends ne{};function ie(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ae(e){if(Array.isArray(e))return e}function oe(e){if(Array.isArray(e))return ie(e)}function se(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ce(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,ye(r.key),r)}}function le(e,t,n){return t&&ce(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function ue(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=xe(e))||t){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function de(e,t,n){return(t=ye(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function fe(e){if(typeof Symbol<`u`&&e[Symbol.iterator]!=null||e[`@@iterator`]!=null)return Array.from(e)}function pe(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function me(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
4
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function he(){throw TypeError(`Invalid attempt to spread non-iterable instance.
|
|
5
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ge(e,t){return ae(e)||pe(e,t)||xe(e,t)||me()}function _e(e){return oe(e)||fe(e)||xe(e)||he()}function ve(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return String(e)}function ye(e){var t=ve(e,`string`);return typeof t==`symbol`?t:t+``}function be(e){"@babel/helpers - typeof";return be=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},be(e)}function xe(e,t){if(e){if(typeof e==`string`)return ie(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ie(e,t):void 0}}var Se=typeof window>`u`?null:window,Ce=Se?Se.navigator:null;Se&&Se.document;var we=be(``),Te=be({}),Ee=be(function(){}),De=typeof HTMLElement>`u`?`undefined`:be(HTMLElement),Oe=function(e){return e&&e.instanceString&&ke(e.instanceString)?e.instanceString():null},Y=function(e){return e!=null&&be(e)==we},ke=function(e){return e!=null&&be(e)===Ee},Ae=function(e){return!Fe(e)&&(Array.isArray?Array.isArray(e):e!=null&&e instanceof Array)},je=function(e){return e!=null&&be(e)===Te&&!Ae(e)&&e.constructor===Object},Me=function(e){return e!=null&&be(e)===Te},X=function(e){return e!=null&&be(e)===be(1)&&!isNaN(e)},Ne=function(e){return X(e)&&Math.floor(e)===e},Pe=function(e){if(De!==`undefined`)return e!=null&&e instanceof HTMLElement},Fe=function(e){return Ie(e)||Le(e)},Ie=function(e){return Oe(e)===`collection`&&e._private.single},Le=function(e){return Oe(e)===`collection`&&!e._private.single},Re=function(e){return Oe(e)===`core`},ze=function(e){return Oe(e)===`stylesheet`},Be=function(e){return Oe(e)===`event`},Ve=function(e){return!!(e==null||e===``||e.match(/^\s+$/))},He=function(e){return typeof HTMLElement>`u`?!1:e instanceof HTMLElement},Ue=function(e){return je(e)&&X(e.x1)&&X(e.x2)&&X(e.y1)&&X(e.y2)},We=function(e){return Me(e)&&ke(e.then)},Ge=function(){return Ce&&Ce.userAgent.match(/msie|trident|edge/i)},Ke=function(e,t){t||=function(){if(arguments.length===1)return arguments[0];if(arguments.length===0)return`undefined`;for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);return e.join(`$`)};var n=function(){var r=this,i=arguments,a,o=t.apply(r,i),s=n.cache;return(a=s[o])||(a=s[o]=e.apply(r,i)),a};return n.cache={},n},qe=Ke(function(e){return e.replace(/([A-Z])/g,function(e){return`-`+e.toLowerCase()})}),Je=Ke(function(e){return e.replace(/(-\w)/g,function(e){return e[1].toUpperCase()})}),Ye=Ke(function(e,t){return e+t[0].toUpperCase()+t.substring(1)},function(e,t){return e+`$`+t}),Xe=function(e){return Ve(e)?e:e.charAt(0).toUpperCase()+e.substring(1)},Ze=function(e,t){return e.slice(-1*t.length)===t},Qe=`(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))`,$e=`rgb[a]?\\((`+Qe+`[%]?)\\s*,\\s*(`+Qe+`[%]?)\\s*,\\s*(`+Qe+`[%]?)(?:\\s*,\\s*(`+Qe+`))?\\)`,et=`rgb[a]?\\((?:`+Qe+`[%]?)\\s*,\\s*(?:`+Qe+`[%]?)\\s*,\\s*(?:`+Qe+`[%]?)(?:\\s*,\\s*(?:`+Qe+`))?\\)`,tt=`hsl[a]?\\((`+Qe+`)\\s*,\\s*(`+Qe+`[%])\\s*,\\s*(`+Qe+`[%])(?:\\s*,\\s*(`+Qe+`))?\\)`,nt=`hsl[a]?\\((?:`+Qe+`)\\s*,\\s*(?:`+Qe+`[%])\\s*,\\s*(?:`+Qe+`[%])(?:\\s*,\\s*(?:`+Qe+`))?\\)`,rt=`\\#[0-9a-fA-F]{3}`,it=`\\#[0-9a-fA-F]{6}`,at=function(e,t){return e<t?-1:+(e>t)},ot=function(e,t){return-1*at(e,t)},Z=Object.assign==null?function(e){for(var t=arguments,n=1;n<t.length;n++){var r=t[n];if(r!=null)for(var i=Object.keys(r),a=0;a<i.length;a++){var o=i[a];e[o]=r[o]}}return e}:Object.assign.bind(Object),st=function(e){if(!(e.length!==4&&e.length!==7||e[0]!==`#`)){var t=e.length===4,n,r,i,a=16;return t?(n=parseInt(e[1]+e[1],a),r=parseInt(e[2]+e[2],a),i=parseInt(e[3]+e[3],a)):(n=parseInt(e[1]+e[2],a),r=parseInt(e[3]+e[4],a),i=parseInt(e[5]+e[6],a)),[n,r,i]}},ct=function(e){var t,n,r,i,a,o,s,c;function l(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}var u=RegExp(`^`+tt+`$`).exec(e);if(u){if(n=parseInt(u[1]),n<0?n=(360- -1*n%360)%360:n>360&&(n%=360),n/=360,r=parseFloat(u[2]),r<0||r>100||(r/=100,i=parseFloat(u[3]),i<0||i>100)||(i/=100,a=u[4],a!==void 0&&(a=parseFloat(a),a<0||a>1)))return;if(r===0)o=s=c=Math.round(i*255);else{var d=i<.5?i*(1+r):i+r-i*r,f=2*i-d;o=Math.round(255*l(f,d,n+1/3)),s=Math.round(255*l(f,d,n)),c=Math.round(255*l(f,d,n-1/3))}t=[o,s,c,a]}return t},lt=function(e){var t,n=RegExp(`^`+$e+`$`).exec(e);if(n){t=[];for(var r=[],i=1;i<=3;i++){var a=n[i];if(a[a.length-1]===`%`&&(r[i]=!0),a=parseFloat(a),r[i]&&(a=a/100*255),a<0||a>255)return;t.push(Math.floor(a))}var o=r[1]||r[2]||r[3],s=r[1]&&r[2]&&r[3];if(o&&!s)return;var c=n[4];if(c!==void 0){if(c=parseFloat(c),c<0||c>1)return;t.push(c)}}return t},ut=function(e){return ft[e.toLowerCase()]},dt=function(e){return(Ae(e)?e:null)||ut(e)||st(e)||lt(e)||ct(e)},ft={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]},pt=function(e){for(var t=e.map,n=e.keys,r=n.length,i=0;i<r;i++){var a=n[i];if(je(a))throw Error(`Tried to set map with object key`);i<n.length-1?(t[a]??(t[a]={}),t=t[a]):t[a]=e.value}},mt=function(e){for(var t=e.map,n=e.keys,r=n.length,i=0;i<r;i++){var a=n[i];if(je(a))throw Error(`Tried to get map with object key`);if(t=t[a],t==null)return t}return t},ht=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{};function gt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var _t,vt;function yt(){if(vt)return _t;vt=1;function e(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}return _t=e,_t}var bt,xt;function St(){return xt||(xt=1,bt=typeof ht==`object`&&ht&&ht.Object===Object&&ht),bt}var Ct,wt;function Tt(){if(wt)return Ct;wt=1;var e=St(),t=typeof self==`object`&&self&&self.Object===Object&&self;return Ct=e||t||Function(`return this`)(),Ct}var Et,Dt;function Ot(){if(Dt)return Et;Dt=1;var e=Tt();return Et=function(){return e.Date.now()},Et}var kt,At;function jt(){if(At)return kt;At=1;var e=/\s/;function t(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n}return kt=t,kt}var Mt,Nt;function Pt(){if(Nt)return Mt;Nt=1;var e=jt(),t=/^\s+/;function n(n){return n&&n.slice(0,e(n)+1).replace(t,``)}return Mt=n,Mt}var Ft,It;function Lt(){return It||(It=1,Ft=Tt().Symbol),Ft}var Rt,zt;function Bt(){if(zt)return Rt;zt=1;var e=Lt(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,i=e?e.toStringTag:void 0;function a(e){var t=n.call(e,i),a=e[i];try{e[i]=void 0;var o=!0}catch{}var s=r.call(e);return o&&(t?e[i]=a:delete e[i]),s}return Rt=a,Rt}var Vt,Ht;function Ut(){if(Ht)return Vt;Ht=1;var e=Object.prototype.toString;function t(t){return e.call(t)}return Vt=t,Vt}var Wt,Gt;function Kt(){if(Gt)return Wt;Gt=1;var e=Lt(),t=Bt(),n=Ut(),r=`[object Null]`,i=`[object Undefined]`,a=e?e.toStringTag:void 0;function o(e){return e==null?e===void 0?i:r:a&&a in Object(e)?t(e):n(e)}return Wt=o,Wt}var qt,Jt;function Yt(){if(Jt)return qt;Jt=1;function e(e){return typeof e==`object`&&!!e}return qt=e,qt}var Xt,Zt;function Qt(){if(Zt)return Xt;Zt=1;var e=Kt(),t=Yt(),n=`[object Symbol]`;function r(r){return typeof r==`symbol`||t(r)&&e(r)==n}return Xt=r,Xt}var $t,en;function tn(){if(en)return $t;en=1;var e=Pt(),t=yt(),n=Qt(),r=NaN,i=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=parseInt;function c(c){if(typeof c==`number`)return c;if(n(c))return r;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 u=a.test(c);return u||o.test(c)?s(c.slice(2),u?2:8):i.test(c)?r:+c}return $t=c,$t}var nn,rn;function an(){if(rn)return nn;rn=1;var e=yt(),t=Ot(),n=tn(),r=`Expected a function`,i=Math.max,a=Math.min;function o(o,s,c){var l,u,d,f,p,m,h=0,g=!1,_=!1,v=!0;if(typeof o!=`function`)throw TypeError(r);s=n(s)||0,e(c)&&(g=!!c.leading,_=`maxWait`in c,d=_?i(n(c.maxWait)||0,s):d,v=`trailing`in c?!!c.trailing:v);function y(e){var t=l,n=u;return l=u=void 0,h=e,f=o.apply(n,t),f}function b(e){return h=e,p=setTimeout(C,s),g?y(e):f}function x(e){var t=e-m,n=e-h,r=s-t;return _?a(r,d-n):r}function S(e){var t=e-m,n=e-h;return m===void 0||t>=s||t<0||_&&n>=d}function C(){var e=t();if(S(e))return w(e);p=setTimeout(C,x(e))}function w(e){return p=void 0,v&&l?y(e):(l=u=void 0,f)}function T(){p!==void 0&&clearTimeout(p),h=0,l=m=u=p=void 0}function E(){return p===void 0?f:w(t())}function D(){var e=t(),n=S(e);if(l=arguments,u=this,m=e,n){if(p===void 0)return b(m);if(_)return clearTimeout(p),p=setTimeout(C,s),y(m)}return p===void 0&&(p=setTimeout(C,s)),f}return D.cancel=T,D.flush=E,D}return nn=o,nn}var on=gt(an()),sn=Se?Se.performance:null,cn=sn&&sn.now?function(){return sn.now()}:function(){return Date.now()},ln=function(){if(Se){if(Se.requestAnimationFrame)return function(e){Se.requestAnimationFrame(e)};if(Se.mozRequestAnimationFrame)return function(e){Se.mozRequestAnimationFrame(e)};if(Se.webkitRequestAnimationFrame)return function(e){Se.webkitRequestAnimationFrame(e)};if(Se.msRequestAnimationFrame)return function(e){Se.msRequestAnimationFrame(e)}}return function(e){e&&setTimeout(function(){e(cn())},1e3/60)}}(),un=function(e){return ln(e)},dn=cn,fn=9261,pn=65599,mn=5381,hn=function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:fn,n;n=e.next(),!n.done;)t=t*pn+n.value|0;return t},gn=function(e){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:fn)*pn+e|0},_n=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:mn;return(t<<5)+t+e|0},vn=function(e,t){return e*2097152+t},yn=function(e){return e[0]*2097152+e[1]},bn=function(e,t){return[gn(e[0],t[0]),_n(e[1],t[1])]},xn=function(e,t){var n={value:0,done:!1},r=0,i=e.length;return hn({next:function(){return r<i?n.value=e[r++]:n.done=!0,n}},t)},Sn=function(e,t){var n={value:0,done:!1},r=0,i=e.length;return hn({next:function(){return r<i?n.value=e.charCodeAt(r++):n.done=!0,n}},t)},Cn=function(){return wn(arguments)},wn=function(e){for(var t,n=0;n<e.length;n++){var r=e[n];t=n===0?Sn(r):Sn(r,t)}return t};function Tn(e,t,n,r,i){var a=i*Math.PI/180;return{x:Math.cos(a)*(e-n)-Math.sin(a)*(t-r)+n,y:Math.sin(a)*(e-n)+Math.cos(a)*(t-r)+r}}var En=function(e,t,n,r,i,a){return{x:(e-n)*i+n,y:(t-r)*a+r}};function Dn(e,t,n){if(n===0)return e;var r=(t.x1+t.x2)/2,i=(t.y1+t.y2)/2,a=t.w/t.h,o=1/a,s=Tn(e.x,e.y,r,i,n),c=En(s.x,s.y,r,i,a,o);return{x:c.x,y:c.y}}var On=!0,kn=console.warn!=null,An=console.trace!=null,jn=2**53-1||9007199254740991,Mn=function(){return!0},Nn=function(){return!1},Pn=function(){return 0},Fn=function(){},In=function(e){throw Error(e)},Ln=function(e){if(e!==void 0)On=!!e;else return On},Rn=function(e){Ln()&&(kn?console.warn(e):(console.log(e),An&&console.trace()))},zn=function(e){return Z({},e)},Bn=function(e){return e==null?e:Ae(e)?e.slice():je(e)?zn(e):e},Vn=function(e){return e.slice()},Hn=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},Un={},Wn=function(){return Un},Gn=function(e){var t=Object.keys(e);return function(n){for(var r={},i=0;i<t.length;i++){var a=t[i],o=n?.[a];r[a]=o===void 0?e[a]:o}return r}},Kn=function(e,t,n){for(var r=e.length-1;r>=0;r--)e[r]===t&&e.splice(r,1)},qn=function(e){e.splice(0,e.length)},Jn=function(e,t){for(var n=0;n<t.length;n++){var r=t[n];e.push(r)}},Yn=function(e,t,n){return n&&(t=Ye(n,t)),e[t]},Xn=function(e,t,n,r){n&&(t=Ye(n,t)),e[t]=r},Zn=typeof Map<`u`?Map:function(){function e(){se(this,e),this._obj={}}return le(e,[{key:`set`,value:function(e,t){return this._obj[e]=t,this}},{key:`delete`,value:function(e){return this._obj[e]=void 0,this}},{key:`clear`,value:function(){this._obj={}}},{key:`has`,value:function(e){return this._obj[e]!==void 0}},{key:`get`,value:function(e){return this._obj[e]}}])}(),Qn=`undefined`,$n=function(){function e(t){if(se(this,e),this._obj=Object.create(null),this.size=0,t!=null)for(var n=t.instanceString!=null&&t.instanceString()===this.instanceString()?t.toArray():t,r=0;r<n.length;r++)this.add(n[r])}return le(e,[{key:`instanceString`,value:function(){return`set`}},{key:`add`,value:function(e){var t=this._obj;t[e]!==1&&(t[e]=1,this.size++)}},{key:`delete`,value:function(e){var t=this._obj;t[e]===1&&(t[e]=0,this.size--)}},{key:`clear`,value:function(){this._obj=Object.create(null)}},{key:`has`,value:function(e){return this._obj[e]===1}},{key:`toArray`,value:function(){var e=this;return Object.keys(this._obj).filter(function(t){return e.has(t)})}},{key:`forEach`,value:function(e,t){return this.toArray().forEach(e,t)}}])}(),er=(typeof Set>`u`?`undefined`:be(Set))===Qn?$n:Set,tr=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;if(e===void 0||t===void 0||!Re(e))In(`An element must have a core reference and parameters set`);else{var r=t.group;if(r??=t.data&&t.data.source!=null&&t.data.target!=null?`edges`:`nodes`,r!==`nodes`&&r!==`edges`)In("An element must be of type `nodes` or `edges`; you specified `"+r+"`");else{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:r,style:{},rstyle:{},styleCxts:[],styleKeys:{},removed:!0,selected:!!t.selected,selectable:t.selectable===void 0||!!t.selectable,locked:!!t.locked,grabbed:!1,grabbable:t.grabbable===void 0||!!t.grabbable,pannable:t.pannable===void 0?r===`edges`:!!t.pannable,active:!1,classes:new er,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??(i.position.x=0),i.position.y??(i.position.y=0),t.renderedPosition){var a=t.renderedPosition,o=e.pan(),s=e.zoom();i.position={x:(a.x-o.x)/s,y:(a.y-o.y)/s}}var c=[];Ae(t.classes)?c=t.classes:Y(t.classes)&&(c=t.classes.split(/\s+/));for(var l=0,u=c.length;l<u;l++){var d=c[l];d&&d!==``&&i.classes.add(d)}this.createEmitter(),(n===void 0||n)&&this.restore();var f=t.style||t.css;f&&(Rn("Setting a `style` bypass at element creation should be done only when absolutely necessary. Try to use the stylesheet instead."),this.style(f))}}},nr=function(e){return e={bfs:e.bfs||!e.dfs,dfs:e.dfs||!e.bfs},function(t,n,r){var i;je(t)&&!Fe(t)&&(i=t,t=i.roots||i.root,n=i.visit,r=i.directed),r=arguments.length===2&&!ke(n)?n:r,n=ke(n)?n:function(){};for(var a=this._private.cy,o=t=Y(t)?this.filter(t):t,s=[],c=[],l={},u={},d={},f=0,p,m=this.byGroup(),h=m.nodes,g=m.edges,_=0;_<o.length;_++){var v=o[_],y=v.id();v.isNode()&&(s.unshift(v),e.bfs&&(d[y]=!0,c.push(v)),u[y]=0)}for(var b=function(){var t=e.bfs?s.shift():s.pop(),i=t.id();if(e.dfs){if(d[i])return 0;d[i]=!0,c.push(t)}var a=u[i],o=l[i],m=o==null?null:o.source(),_=o==null?null:o.target(),v=o==null?void 0:t.same(m)?_[0]:m[0],y=n(t,o,v,f++,a);if(y===!0)return p=t,1;if(y===!1)return 1;for(var b=t.connectedEdges().filter(function(e){return(!r||e.source().same(t))&&g.has(e)}),x=0;x<b.length;x++){var S=b[x],C=S.connectedNodes().filter(function(e){return!e.same(t)&&h.has(e)}),w=C.id();C.length!==0&&!d[w]&&(C=C[0],s.push(C),e.bfs&&(d[w]=!0,c.push(C)),l[w]=S,u[w]=u[i]+1)}},x;s.length!==0&&(x=b(),x===0||x!==1););for(var S=a.collection(),C=0;C<c.length;C++){var w=c[C],T=l[w.id()];T!=null&&S.push(T),S.push(w)}return{path:a.collection(S),found:a.collection(p)}}},rr={breadthFirstSearch:nr({bfs:!0}),depthFirstSearch:nr({dfs:!0})};rr.bfs=rr.breadthFirstSearch,rr.dfs=rr.depthFirstSearch;var ir={exports:{}},ar=ir.exports,or;function sr(){return or||(or=1,(function(e,t){(function(){var t,n,r=Math.floor,i,a,o,s,c,l,u=Math.min,d,f,p,m,h;n=function(e,t){return e<t?-1:+(e>t)},l=function(e,t,i,a,o){var s;if(i??=0,o??=n,i<0)throw Error(`lo must be non-negative`);for(a??=e.length;i<a;)s=r((i+a)/2),o(t,e[s])<0?a=s:i=s+1;return[].splice.apply(e,[i,i-i].concat(t)),t},o=function(e,t,r){return r??=n,e.push(t),m(e,0,e.length-1,r)},a=function(e,t){var r,i;return t??=n,r=e.pop(),e.length?(i=e[0],e[0]=r,h(e,0,t)):i=r,i},c=function(e,t,r){var i;return r??=n,i=e[0],e[0]=t,h(e,0,r),i},s=function(e,t,r){var i;return r??=n,e.length&&r(e[0],t)<0&&(i=[e[0],t],t=i[0],e[0]=i[1],h(e,0,r)),t},i=function(e,t){var i,a,o,s,c,l;for(t??=n,s=(function(){l=[];for(var t=0,n=r(e.length/2);0<=n?t<n:t>n;0<=n?t++:t--)l.push(t);return l}).apply(this).reverse(),c=[],a=0,o=s.length;a<o;a++)i=s[a],c.push(h(e,i,t));return c},p=function(e,t,r){var i;if(r??=n,i=e.indexOf(t),i!==-1)return m(e,0,i,r),h(e,i,r)},d=function(e,t,r){var a,o,c,l,u;if(r??=n,o=e.slice(0,t),!o.length)return o;for(i(o,r),u=e.slice(t),c=0,l=u.length;c<l;c++)a=u[c],s(o,a,r);return o.sort(r).reverse()},f=function(e,t,r){var o,s,c,d,f,p,m,h,g;if(r??=n,t*10<=e.length){if(c=e.slice(0,t).sort(r),!c.length)return c;for(s=c[c.length-1],m=e.slice(t),d=0,p=m.length;d<p;d++)o=m[d],r(o,s)<0&&(l(c,o,0,null,r),c.pop(),s=c[c.length-1]);return c}for(i(e,r),g=[],f=0,h=u(t,e.length);0<=h?f<h:f>h;0<=h?++f:--f)g.push(a(e,r));return g},m=function(e,t,r,i){var a,o,s;for(i??=n,a=e[r];r>t&&(s=r-1>>1,o=e[s],i(a,o)<0);)e[r]=o,r=s;return e[r]=a},h=function(e,t,r){var i,a,o,s,c;for(r??=n,a=e.length,c=t,o=e[t],i=2*t+1;i<a;)s=i+1,s<a&&!(r(e[i],e[s])<0)&&(i=s),e[t]=e[i],t=i,i=2*t+1;return e[t]=o,m(e,c,t,r)},t=(function(){e.push=o,e.pop=a,e.replace=c,e.pushpop=s,e.heapify=i,e.updateItem=p,e.nlargest=d,e.nsmallest=f;function e(e){this.cmp=e??n,this.nodes=[]}return e.prototype.push=function(e){return o(this.nodes,e,this.cmp)},e.prototype.pop=function(){return a(this.nodes,this.cmp)},e.prototype.peek=function(){return this.nodes[0]},e.prototype.contains=function(e){return this.nodes.indexOf(e)!==-1},e.prototype.replace=function(e){return c(this.nodes,e,this.cmp)},e.prototype.pushpop=function(e){return s(this.nodes,e,this.cmp)},e.prototype.heapify=function(){return i(this.nodes,this.cmp)},e.prototype.updateItem=function(e){return p(this.nodes,e,this.cmp)},e.prototype.clear=function(){return this.nodes=[]},e.prototype.empty=function(){return this.nodes.length===0},e.prototype.size=function(){return this.nodes.length},e.prototype.clone=function(){var t=new e;return t.nodes=this.nodes.slice(0),t},e.prototype.toArray=function(){return this.nodes.slice(0)},e.prototype.insert=e.prototype.push,e.prototype.top=e.prototype.peek,e.prototype.front=e.prototype.peek,e.prototype.has=e.prototype.contains,e.prototype.copy=e.prototype.clone,e})(),(function(t,n){return e.exports=n()})(this,function(){return t})}).call(ar)})(ir)),ir.exports}var cr,lr;function ur(){return lr||(lr=1,cr=sr()),cr}var dr=gt(ur()),fr=Gn({root:null,weight:function(e){return 1},directed:!1}),pr={dijkstra:function(e){if(!je(e)){var t=arguments;e={root:t[0],weight:t[1],directed:t[2]}}var n=fr(e),r=n.root,i=n.weight,a=n.directed,o=this,s=i,c=Y(r)?this.filter(r)[0]:r[0],l={},u={},d={},f=this.byGroup(),p=f.nodes,m=f.edges;m.unmergeBy(function(e){return e.isLoop()});for(var h=function(e){return l[e.id()]},g=function(e,t){l[e.id()]=t,_.updateItem(e)},_=new dr(function(e,t){return h(e)-h(t)}),v=0;v<p.length;v++){var y=p[v];l[y.id()]=y.same(c)?0:1/0,_.push(y)}for(var b=function(e,t){for(var n=(a?e.edgesTo(t):e.edgesWith(t)).intersect(m),r=1/0,i,o=0;o<n.length;o++){var c=n[o],l=s(c);(l<r||!i)&&(r=l,i=c)}return{edge:i,dist:r}};_.size()>0;){var x=_.pop(),S=h(x),C=x.id();if(d[C]=S,S!==1/0)for(var w=x.neighborhood().intersect(p),T=0;T<w.length;T++){var E=w[T],D=E.id(),O=b(x,E),k=S+O.dist;k<h(E)&&(g(E,k),u[D]={node:x,edge:O.edge})}}return{distanceTo:function(e){return d[(Y(e)?p.filter(e)[0]:e[0]).id()]},pathTo:function(e){var t=Y(e)?p.filter(e)[0]:e[0],n=[],r=t,i=r.id();if(t.length>0)for(n.unshift(t);u[i];){var a=u[i];n.unshift(a.edge),n.unshift(a.node),r=a.node,i=r.id()}return o.spawn(n)}}}},mr={kruskal:function(e){e||=function(e){return 1};for(var t=this.byGroup(),n=t.nodes,r=t.edges,i=n.length,a=Array(i),o=n,s=function(e){for(var t=0;t<a.length;t++)if(a[t].has(e))return t},c=0;c<i;c++)a[c]=this.spawn(n[c]);for(var l=r.sort(function(t,n){return e(t)-e(n)}),u=0;u<l.length;u++){var d=l[u],f=d.source()[0],p=d.target()[0],m=s(f),h=s(p),g=a[m],_=a[h];m!==h&&(o.merge(d),g.merge(_),a.splice(h,1))}return o}},hr=Gn({root:null,goal:null,weight:function(e){return 1},heuristic:function(e){return 0},directed:!1}),gr={aStar:function(e){var t=this.cy(),n=hr(e),r=n.root,i=n.goal,a=n.heuristic,o=n.directed,s=n.weight;r=t.collection(r)[0],i=t.collection(i)[0];var c=r.id(),l=i.id(),u={},d={},f={},p=new dr(function(e,t){return d[e.id()]-d[t.id()]}),m=new er,h={},g={},_=function(e,t){p.push(e),m.add(t)},v,y,b=function(){v=p.pop(),y=v.id(),m.delete(y)},x=function(e){return m.has(e)};_(r,c),u[c]=0,d[c]=a(r);for(var S=0;p.size()>0;){if(b(),S++,y===l){for(var C=[],w=i,T=l,E=g[T];C.unshift(w),E!=null&&C.unshift(E),w=h[T],w!=null;)T=w.id(),E=g[T];return{found:!0,distance:u[y],path:this.spawn(C),steps:S}}f[y]=!0;for(var D=v._private.edges,O=0;O<D.length;O++){var k=D[O];if(this.hasElementWithId(k.id())&&!(o&&k.data(`source`)!==y)){var A=k.source(),j=k.target(),M=A.id()===y?j:A,N=M.id();if(this.hasElementWithId(N)&&!f[N]){var P=u[y]+s(k);x(N)?P<u[N]&&(u[N]=P,d[N]=P+a(M),p.updateItem(M),h[N]=v,g[N]=k):(u[N]=P,d[N]=P+a(M),_(M,N),h[N]=v,g[N]=k)}}}}return{found:!1,distance:void 0,path:void 0,steps:S}}},_r=Gn({weight:function(e){return 1},directed:!1}),vr={floydWarshall:function(e){for(var t=this.cy(),n=_r(e),r=n.weight,i=n.directed,a=r,o=this.byGroup(),s=o.nodes,c=o.edges,l=s.length,u=l*l,d=function(e){return s.indexOf(e)},f=function(e){return s[e]},p=Array(u),m=0;m<u;m++){var h=m%l;(m-h)/l===h?p[m]=0:p[m]=1/0}for(var g=Array(u),_=Array(u),v=0;v<c.length;v++){var y=c[v],b=y.source()[0],x=y.target()[0];if(b!==x){var S=d(b),C=d(x),w=S*l+C,T=a(y);if(p[w]>T&&(p[w]=T,g[w]=C,_[w]=y),!i){var E=C*l+S;!i&&p[E]>T&&(p[E]=T,g[E]=S,_[E]=y)}}}for(var D=0;D<l;D++)for(var O=0;O<l;O++)for(var k=O*l+D,A=0;A<l;A++){var j=O*l+A,M=D*l+A;p[k]+p[M]<p[j]&&(p[j]=p[k]+p[M],g[j]=g[k])}var N=function(e){return(Y(e)?t.filter(e):e)[0]},P=function(e){return d(N(e))};return{distance:function(e,t){var n=P(e),r=P(t);return p[n*l+r]},path:function(e,n){var r=P(e),i=P(n),a=f(r);if(r===i)return a.collection();if(g[r*l+i]==null)return t.collection();var o=t.collection(),s=r,c;for(o.merge(a);r!==i;)s=r,r=g[r*l+i],c=_[s*l+r],o.merge(c),o.merge(f(r));return o}}}},yr=Gn({weight:function(e){return 1},directed:!1,root:null}),br={bellmanFord:function(e){var t=this,n=yr(e),r=n.weight,i=n.directed,a=n.root,o=r,s=this,c=this.cy(),l=this.byGroup(),u=l.edges,d=l.nodes,f=d.length,p=new Zn,m=!1,h=[];a=c.collection(a)[0],u.unmergeBy(function(e){return e.isLoop()});for(var g=u.length,_=function(e){var t=p.get(e.id());return t||(t={},p.set(e.id(),t)),t},v=function(e){return(Y(e)?c.$(e):e)[0]},y=function(e){return _(v(e)).dist},b=function(e){for(var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:a,r=v(e),i=[],o=r;;){if(o==null)return t.spawn();var c=_(o),l=c.edge,u=c.pred;if(i.unshift(o[0]),o.same(n)&&i.length>0)break;l!=null&&i.unshift(l),o=u}return s.spawn(i)},x=0;x<f;x++){var S=d[x],C=_(S);C.dist=S.same(a)?0:1/0,C.pred=null,C.edge=null}for(var w=!1,T=function(e,t,n,r,i,a){var o=r.dist+a;o<i.dist&&!n.same(r.edge)&&(i.dist=o,i.pred=e,i.edge=n,w=!0)},E=1;E<f;E++){w=!1;for(var D=0;D<g;D++){var O=u[D],k=O.source(),A=O.target(),j=o(O),M=_(k),N=_(A);T(k,A,O,M,N,j),i||T(A,k,O,N,M,j)}if(!w)break}if(w)for(var P=[],F=0;F<g;F++){var I=u[F],L=I.source(),R=I.target(),z=o(I),B=_(L).dist,V=_(R).dist;if(B+z<V||!i&&V+z<B){if(m||=(Rn(`Graph contains a negative weight cycle for Bellman-Ford`),!0),e.findNegativeWeightCycles!==!1){var H=[];B+z<V&&H.push(L),!i&&V+z<B&&H.push(R);for(var U=H.length,W=0;W<U;W++){var ee=H[W],G=[ee];G.push(_(ee).edge);for(var K=_(ee).pred;G.indexOf(K)===-1;)G.push(K),G.push(_(K).edge),K=_(K).pred;G=G.slice(G.indexOf(K));for(var q=G[0].id(),J=0,te=2;te<G.length;te+=2)G[te].id()<q&&(q=G[te].id(),J=te);G=G.slice(J).concat(G.slice(0,J)),G.push(G[0]);var ne=G.map(function(e){return e.id()}).join(`,`);P.indexOf(ne)===-1&&(h.push(s.spawn(G)),P.push(ne))}}else break}}return{distanceTo:y,pathTo:b,hasNegativeWeightCycle:m,negativeWeightCycles:h}}},xr=Math.sqrt(2),Sr=function(e,t,n){n.length===0&&In(`Karger-Stein must be run on a connected (sub)graph`);for(var r=n[e],i=r[1],a=r[2],o=t[i],s=t[a],c=n,l=c.length-1;l>=0;l--){var u=c[l],d=u[1],f=u[2];(t[d]===o&&t[f]===s||t[d]===s&&t[f]===o)&&c.splice(l,1)}for(var p=0;p<c.length;p++){var m=c[p];m[1]===s?(c[p]=m.slice(),c[p][1]=o):m[2]===s&&(c[p]=m.slice(),c[p][2]=o)}for(var h=0;h<t.length;h++)t[h]===s&&(t[h]=o);return c},Cr=function(e,t,n,r){for(;n>r;)t=Sr(Math.floor(Math.random()*t.length),e,t),n--;return t},wr={kargerStein:function(){var e=this,t=this.byGroup(),n=t.nodes,r=t.edges;r.unmergeBy(function(e){return e.isLoop()});var i=n.length,a=r.length,o=Math.ceil((Math.log(i)/Math.LN2)**2),s=Math.floor(i/xr);if(i<2)In(`At least 2 nodes are required for Karger-Stein algorithm`);else{for(var c=[],l=0;l<a;l++){var u=r[l];c.push([l,n.indexOf(u.source()),n.indexOf(u.target())])}for(var d=1/0,f=[],p=Array(i),m=Array(i),h=Array(i),g=function(e,t){for(var n=0;n<i;n++)t[n]=e[n]},_=0;_<=o;_++){for(var v=0;v<i;v++)m[v]=v;var y=Cr(m,c.slice(),i,s),b=y.slice();g(m,h);var x=Cr(m,y,s,2),S=Cr(h,b,s,2);x.length<=S.length&&x.length<d?(d=x.length,f=x,g(m,p)):S.length<=x.length&&S.length<d&&(d=S.length,f=S,g(h,p))}for(var C=this.spawn(f.map(function(e){return r[e[0]]})),w=this.spawn(),T=this.spawn(),E=p[0],D=0;D<p.length;D++){var O=p[D],k=n[D];O===E?w.merge(k):T.merge(k)}var A=function(t){var n=e.spawn();return t.forEach(function(t){n.merge(t),t.connectedEdges().forEach(function(t){e.contains(t)&&!C.contains(t)&&n.merge(t)})}),n};return{cut:C,components:[A(w),A(T)],partition1:w,partition2:T}}}},Tr=function(e){return{x:e.x,y:e.y}},Er=function(e,t,n){return{x:e.x*t+n.x,y:e.y*t+n.y}},Dr=function(e,t,n){return{x:(e.x-n.x)/t,y:(e.y-n.y)/t}},Or=function(e){return{x:e[0],y:e[1]}},kr=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,r=1/0,i=t;i<n;i++){var a=e[i];isFinite(a)&&(r=Math.min(a,r))}return r},Ar=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,r=-1/0,i=t;i<n;i++){var a=e[i];isFinite(a)&&(r=Math.max(a,r))}return r},jr=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,r=0,i=0,a=t;a<n;a++){var o=e[a];isFinite(o)&&(r+=o,i++)}return r/i},Mr=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,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0;r?e=e.slice(t,n):(n<e.length&&e.splice(n,e.length-n),t>0&&e.splice(0,t));for(var o=0,s=e.length-1;s>=0;s--){var c=e[s];a?isFinite(c)||(e[s]=-1/0,o++):e.splice(s,1)}i&&e.sort(function(e,t){return e-t});var l=e.length,u=Math.floor(l/2);return l%2==0?(e[u-1+o]+e[u+o])/2:e[u+1+o]},Nr=function(e,t){return t===0?e:Nr(t,e%t)},Pr=function(e){for(var t=e[0],n=0;n<e.length;n++)if(Ne(e[n]))n>0&&(t=Nr(t,e[n]));else return 0;return t},Fr=function(e,t){var n=e/t,r=Math.round(n);return r>=1&&Math.abs(n-r)<1e-6},Ir=function(e){return Math.PI*e/180},Lr=function(e,t){return Math.atan2(t,e)-Math.PI/2},Rr=Math.log2||function(e){return Math.log(e)/Math.log(2)},zr=function(e){return e>0?1:e<0?-1:0},Br=function(e,t){return Math.sqrt(Vr(e,t))},Vr=function(e,t){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r},Hr=function(e){for(var t=e.length,n=0,r=0;r<t;r++)n+=e[r];for(var i=0;i<t;i++)e[i]=e[i]/n;return e},Ur=function(e,t,n,r){return(1-r)*(1-r)*e+2*(1-r)*r*t+r*r*n},Wr=function(e,t,n,r){return{x:Ur(e.x,t.x,n.x,r),y:Ur(e.y,t.y,n.y,r)}},Gr=function(e,t,n,r){var i={x:t.x-e.x,y:t.y-e.y},a=Br(e,t),o={x:i.x/a,y:i.y/a};return n??=0,r??=n*a,{x:e.x+o.x*r,y:e.y+o.y*r}},Kr=function(e,t,n){return Math.max(e,Math.min(n,t))},qr=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}}},Jr=function(e){return{x1:e.x1,x2:e.x2,w:e.w,y1:e.y1,y2:e.y2,h:e.h}},Yr=function(e){e.x1=1/0,e.y1=1/0,e.x2=-1/0,e.y2=-1/0,e.w=0,e.h=0},Xr=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},Zr=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},Qr=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},$r=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0],n,r,i,a;if(t.length===1)n=r=i=a=t[0];else if(t.length===2)n=i=t[0],a=r=t[1];else if(t.length===4){var o=ge(t,4);n=o[0],r=o[1],i=o[2],a=o[3]}return e.x1-=a,e.x2+=r,e.y1-=n,e.y2+=i,e.w=e.x2-e.x1,e.h=e.y2-e.y1,e},ei=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},ti=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)},ni=function(e,t,n){return e.x1<=t&&t<=e.x2&&e.y1<=n&&n<=e.y2},ri=function(e,t){return ni(e,t.x,t.y)},ii=function(e,t){return ni(e,t.x1,t.y1)&&ni(e,t.x2,t.y2)},ai=Math.hypot??function(e,t){return Math.sqrt(e*e+t*t)};function oi(e,t){if(e.length<3)throw Error(`Need at least 3 vertices`);var n=function(e,t){return{x:e.x+t.x,y:e.y+t.y}},r=function(e,t){return{x:e.x-t.x,y:e.y-t.y}},i=function(e,t){return{x:e.x*t,y:e.y*t}},a=function(e,t){return e.x*t.y-e.y*t.x},o=function(e){var t=ai(e.x,e.y);return t===0?{x:0,y:0}:{x:e.x/t,y:e.y/t}},s=function(e){for(var t=0,n=0;n<e.length;n++){var r=e[n],i=e[(n+1)%e.length];t+=r.x*i.y-i.x*r.y}return t/2},c=function(e,t,o,s){var c=r(t,e),l=r(s,o),u=a(c,l);return Math.abs(u)<1e-9?n(e,i(c,.5)):n(e,i(c,a(r(o,e),l)/u))},l=e.map(function(e){return{x:e.x,y:e.y}});s(l)<0&&l.reverse();for(var u=l.length,d=[],f=0;f<u;f++){var p=l[f],m=l[(f+1)%u],h=r(m,p),g=o({x:h.y,y:-h.x});d.push(g)}for(var _=d.map(function(e,r){return{p1:n(l[r],i(e,t)),p2:n(l[(r+1)%u],i(e,t))}}),v=[],y=0;y<u;y++){var b=_[(y-1+u)%u],x=_[y],S=c(b.p1,b.p2,x.p1,x.p2);v.push(S)}return v}function si(e,t,n,r,i,a){var o=oi(Ti(e,t,n,r,i),a),s=qr();return o.forEach(function(e){return Zr(s,e.x,e.y)}),s}var ci=function(e,t,n,r,i,a,o){var s=arguments.length>7&&arguments[7]!==void 0?arguments[7]:`auto`,c=s===`auto`?Mi(i,a):s,l=i/2,u=a/2;c=Math.min(c,l,u);var d=c!==l,f=c!==u,p;if(d){var m=n-l+c-o,h=r-u-o;if(p=wi(e,t,n,r,m,h,n+l-c+o,h,!1),p.length>0)return p}if(f){var g=n+l+o;if(p=wi(e,t,n,r,g,r-u+c-o,g,r+u-c+o,!1),p.length>0)return p}if(d){var _=n-l+c-o,v=r+u+o;if(p=wi(e,t,n,r,_,v,n+l-c+o,v,!1),p.length>0)return p}if(f){var y=n-l-o;if(p=wi(e,t,n,r,y,r-u+c-o,y,r+u-c+o,!1),p.length>0)return p}var b,x=n-l+c,S=r-u+c;if(b=Si(e,t,n,r,x,S,c+o),b.length>0&&b[0]<=x&&b[1]<=S)return[b[0],b[1]];var C=n+l-c,w=r-u+c;if(b=Si(e,t,n,r,C,w,c+o),b.length>0&&b[0]>=C&&b[1]<=w)return[b[0],b[1]];var T=n+l-c,E=r+u-c;if(b=Si(e,t,n,r,T,E,c+o),b.length>0&&b[0]>=T&&b[1]>=E)return[b[0],b[1]];var D=n-l+c,O=r+u-c;return b=Si(e,t,n,r,D,O,c+o),b.length>0&&b[0]<=D&&b[1]>=O?[b[0],b[1]]:[]},li=function(e,t,n,r,i,a,o){var s=o,c=Math.min(n,i),l=Math.max(n,i),u=Math.min(r,a),d=Math.max(r,a);return c-s<=e&&e<=l+s&&u-s<=t&&t<=d+s},ui=function(e,t,n,r,i,a,o,s,c){var l={x1:Math.min(n,o,i)-c,x2:Math.max(n,o,i)+c,y1:Math.min(r,s,a)-c,y2:Math.max(r,s,a)+c};return!(e<l.x1||e>l.x2||t<l.y1||t>l.y2)},di=function(e,t,n,r){n-=r;var i=t*t-4*e*n;if(i<0)return[];var a=Math.sqrt(i),o=2*e;return[(-t+a)/o,(-t-a)/o]},fi=function(e,t,n,r,i){e===0&&(e=1e-5),t/=e,n/=e,r/=e;var a,o=(3*n-t*t)/9,s=-(27*r)+t*(9*n-t*t*2),c,l,u,d,f;s/=54,a=o*o*o+s*s,i[1]=0,d=t/3,a>0?(l=s+Math.sqrt(a),l=l<0?-((-l)**(1/3)):l**(1/3),u=s-Math.sqrt(a),u=u<0?-((-u)**(1/3)):u**(1/3),i[0]=-d+l+u,d+=(l+u)/2,i[4]=i[2]=-d,d=Math.sqrt(3)*(-u+l)/2,i[3]=d,i[5]=-d):(i[5]=i[3]=0,a===0?(f=s<0?-((-s)**(1/3)):s**(1/3),i[0]=-d+2*f,i[4]=i[2]=-(f+d)):(o=-o,c=o*o*o,c=Math.acos(s/Math.sqrt(c)),f=2*Math.sqrt(o),i[0]=-d+f*Math.cos(c/3),i[2]=-d+f*Math.cos((c+2*Math.PI)/3),i[4]=-d+f*Math.cos((c+4*Math.PI)/3)))},pi=function(e,t,n,r,i,a,o,s){var c=1*n*n-4*n*i+2*n*o+4*i*i-4*i*o+o*o+r*r-4*r*a+2*r*s+4*a*a-4*a*s+s*s,l=9*n*i-3*n*n-3*n*o-6*i*i+3*i*o+9*r*a-3*r*r-3*r*s-6*a*a+3*a*s,u=3*n*n-6*n*i+n*o-n*e+2*i*i+2*i*e-o*e+3*r*r-6*r*a+r*s-r*t+2*a*a+2*a*t-s*t,d=1*n*i-n*n+n*e-i*e+r*a-r*r+r*t-a*t,f=[];fi(c,l,u,d,f);for(var p=1e-7,m=[],h=0;h<6;h+=2)Math.abs(f[h+1])<p&&f[h]>=0&&f[h]<=1&&m.push(f[h]);m.push(1),m.push(0);for(var g=-1,_,v,y,b=0;b<m.length;b++)_=(1-m[b])**2*n+2*(1-m[b])*m[b]*i+m[b]*m[b]*o,v=(1-m[b])**2*r+2*(1-m[b])*m[b]*a+m[b]*m[b]*s,y=(_-e)**2+(v-t)**2,g>=0?y<g&&(g=y):g=y;return g},mi=function(e,t,n,r,i,a){var o=[e-n,t-r],s=[i-n,a-r],c=s[0]*s[0]+s[1]*s[1],l=o[0]*o[0]+o[1]*o[1],u=o[0]*s[0]+o[1]*s[1],d=u*u/c;return u<0?l:d>c?(e-i)*(e-i)+(t-a)*(t-a):l-d},hi=function(e,t,n){for(var r,i,a,o,s,c=0,l=0;l<n.length/2;l++)if(r=n[l*2],i=n[l*2+1],l+1<n.length/2?(a=n[(l+1)*2],o=n[(l+1)*2+1]):(a=n[(l+1-n.length/2)*2],o=n[(l+1-n.length/2)*2+1]),r!=e||a!=e){if(r>=e&&e>=a||r<=e&&e<=a)s=(e-r)/(a-r)*(o-i)+i,s>t&&c++;else continue}return c%2!=0},gi=function(e,t,n,r,i,a,o,s,c){var l=Array(n.length),u;s[0]==null?u=s:(u=Math.atan(s[1]/s[0]),s[0]<0?u+=Math.PI/2:u=-u-Math.PI/2);for(var d=Math.cos(-u),f=Math.sin(-u),p=0;p<l.length/2;p++)l[p*2]=a/2*(n[p*2]*d-n[p*2+1]*f),l[p*2+1]=o/2*(n[p*2+1]*d+n[p*2]*f),l[p*2]+=r,l[p*2+1]+=i;return hi(e,t,c>0?vi(yi(l,-c)):l)},_i=function(e,t,n,r,i,a,o,s){for(var c=Array(n.length*2),l=0;l<s.length;l++){var u=s[l];if(c[l*4+0]=u.startX,c[l*4+1]=u.startY,c[l*4+2]=u.stopX,c[l*4+3]=u.stopY,(u.cx-e)**2+(u.cy-t)**2<=u.radius**2)return!0}return hi(e,t,c)},vi=function(e){for(var t=Array(e.length/2),n,r,i,a,o,s,c,l,u=0;u<e.length/4;u++){n=e[u*4],r=e[u*4+1],i=e[u*4+2],a=e[u*4+3],u<e.length/4-1?(o=e[(u+1)*4],s=e[(u+1)*4+1],c=e[(u+1)*4+2],l=e[(u+1)*4+3]):(o=e[0],s=e[1],c=e[2],l=e[3]);var d=wi(n,r,i,a,o,s,c,l,!0);t[u*2]=d[0],t[u*2+1]=d[1]}return t},yi=function(e,t){for(var n=Array(e.length*2),r,i,a,o,s=0;s<e.length/2;s++){r=e[s*2],i=e[s*2+1],s<e.length/2-1?(a=e[(s+1)*2],o=e[(s+1)*2+1]):(a=e[0],o=e[1]);var c=o-i,l=-(a-r),u=Math.sqrt(c*c+l*l),d=c/u,f=l/u;n[s*4]=r+d*t,n[s*4+1]=i+f*t,n[s*4+2]=a+d*t,n[s*4+3]=o+f*t}return n},bi=function(e,t,n,r,i,a){var o=n-e,s=r-t;o/=i,s/=a;var c=Math.sqrt(o*o+s*s),l=c-1;if(l<0)return[];var u=l/c;return[(n-e)*u+e,(r-t)*u+t]},xi=function(e,t,n,r,i,a,o){return e-=i,t-=a,e/=n/2+o,t/=r/2+o,e*e+t*t<=1},Si=function(e,t,n,r,i,a,o){var s=[n-e,r-t],c=[e-i,t-a],l=s[0]*s[0]+s[1]*s[1],u=2*(c[0]*s[0]+c[1]*s[1]),d=c[0]*c[0]+c[1]*c[1]-o*o,f=u*u-4*l*d;if(f<0)return[];var p=(-u+Math.sqrt(f))/(2*l),m=(-u-Math.sqrt(f))/(2*l),h=Math.min(p,m),g=Math.max(p,m),_=[];if(h>=0&&h<=1&&_.push(h),g>=0&&g<=1&&_.push(g),_.length===0)return[];var v=_[0]*s[0]+e,y=_[0]*s[1]+t;return _.length>1?_[0]==_[1]?[v,y]:[v,y,_[1]*s[0]+e,_[1]*s[1]+t]:[v,y]},Ci=function(e,t,n){return t<=e&&e<=n||n<=e&&e<=t?e:e<=t&&t<=n||n<=t&&t<=e?t:n},wi=function(e,t,n,r,i,a,o,s,c){var l=e-i,u=n-e,d=o-i,f=t-a,p=r-t,m=s-a,h=d*f-m*l,g=u*f-p*l,_=m*u-d*p;if(_!==0){var v=h/_,y=g/_,b=.001,x=0-b,S=1+b;return x<=v&&v<=S&&x<=y&&y<=S||c?[e+v*u,t+v*p]:[]}return h===0||g===0?Ci(e,n,o)===o?[o,s]:Ci(e,n,i)===i?[i,a]:Ci(i,o,n)===n?[n,r]:[]:[]},Ti=function(e,t,n,r,i){var a=[],o=r/2,s=i/2,c=t,l=n;a.push({x:c+o*e[0],y:l+s*e[1]});for(var u=1;u<e.length/2;u++)a.push({x:c+o*e[u*2],y:l+s*e[u*2+1]});return a},Ei=function(e,t,n,r,i,a,o,s){var c=[],l,u=Array(n.length),d=!0;a??(d=!1);var f;if(d){for(var p=0;p<u.length/2;p++)u[p*2]=n[p*2]*a+r,u[p*2+1]=n[p*2+1]*o+i;f=s>0?vi(yi(u,-s)):u}else f=n;for(var m,h,g,_,v=0;v<f.length/2;v++)m=f[v*2],h=f[v*2+1],v<f.length/2-1?(g=f[(v+1)*2],_=f[(v+1)*2+1]):(g=f[0],_=f[1]),l=wi(e,t,r,i,m,h,g,_),l.length!==0&&c.push(l[0],l[1]);return c},Di=function(e,t,n,r,i,a,o,s,c){var l=[],u,d=Array(n.length*2);c.forEach(function(n,a){a===0?(d[d.length-2]=n.startX,d[d.length-1]=n.startY):(d[a*4-2]=n.startX,d[a*4-1]=n.startY),d[a*4]=n.stopX,d[a*4+1]=n.stopY,u=Si(e,t,r,i,n.cx,n.cy,n.radius),u.length!==0&&l.push(u[0],u[1])});for(var f=0;f<d.length/4;f++)u=wi(e,t,r,i,d[f*4],d[f*4+1],d[f*4+2],d[f*4+3],!1),u.length!==0&&l.push(u[0],u[1]);if(l.length>2){for(var p=[l[0],l[1]],m=(p[0]-e)**2+(p[1]-t)**2,h=1;h<l.length/2;h++){var g=(l[h*2]-e)**2+(l[h*2+1]-t)**2;g<=m&&(p[0]=l[h*2],p[1]=l[h*2+1],m=g)}return p}return l},Oi=function(e,t,n){var r=[e[0]-t[0],e[1]-t[1]],i=Math.sqrt(r[0]*r[0]+r[1]*r[1]),a=(i-n)/i;return a<0&&(a=1e-5),[t[0]+a*r[0],t[1]+a*r[1]]},ki=function(e,t){var n=ji(e,t);return n=Ai(n),n},Ai=function(e){for(var t,n,r=e.length/2,i=1/0,a=1/0,o=-1/0,s=-1/0,c=0;c<r;c++)t=e[2*c],n=e[2*c+1],i=Math.min(i,t),o=Math.max(o,t),a=Math.min(a,n),s=Math.max(s,n);for(var l=2/(o-i),u=2/(s-a),d=0;d<r;d++)t=e[2*d]=e[2*d]*l,n=e[2*d+1]=e[2*d+1]*u,i=Math.min(i,t),o=Math.max(o,t),a=Math.min(a,n),s=Math.max(s,n);if(a<-1)for(var f=0;f<r;f++)n=e[2*f+1]=e[2*f+1]+(-1-a);return e},ji=function(e,t){var n=1/e*2*Math.PI,r=e%2==0?Math.PI/2+n/2:Math.PI/2;r+=t;for(var i=Array(e*2),a,o=0;o<e;o++)a=o*n+r,i[2*o]=Math.cos(a),i[2*o+1]=Math.sin(-a);return i},Mi=function(e,t){return Math.min(e/4,t/4,8)},Ni=function(e,t){return Math.min(e/10,t/10,8)},Pi=function(){return 8},Fi=function(e,t,n){return[e-2*t+n,2*(t-e),e]},Ii=function(e,t){return{heightOffset:Math.min(15,.05*t),widthOffset:Math.min(100,.25*e),ctrlPtOffsetPct:.05}},Li=function(e,t,n,r,i,a,o){var s=e.x1-o-i,c=e.x2+o-i,l=e.y1-o-a,u=e.y2+o-a;if(r){var d=Math.cos(r),f=Math.sin(r),p=function(e,r){return e-=t,r-=n,{x:e*d-r*f+t+i,y:e*f+r*d+n+a}};return[p(s,l),p(c,l),p(c,u),p(s,u)]}return[{x:s+i,y:l+a},{x:c+i,y:l+a},{x:c+i,y:u+a},{x:s+i,y:u+a}]};function Ri(e,t){function n(e){for(var t=[],n=0;n<e.length;n++){var r=e[n],i=e[(n+1)%e.length],a={x:i.x-r.x,y:i.y-r.y},o={x:-a.y,y:a.x},s=Math.sqrt(o.x*o.x+o.y*o.y);t.push({x:o.x/s,y:o.y/s})}return t}function r(e,t){var n=1/0,r=-1/0,i=ue(e),a;try{for(i.s();!(a=i.n()).done;){var o=a.value,s=o.x*t.x+o.y*t.y;n=Math.min(n,s),r=Math.max(r,s)}}catch(e){i.e(e)}finally{i.f()}return{min:n,max:r}}function i(e,t){return!(e.max<t.min||t.max<e.min)}var a=ue([].concat(_e(n(e)),_e(n(t)))),o;try{for(a.s();!(o=a.n()).done;){var s=o.value;if(!i(r(e,s),r(t,s)))return!1}}catch(e){a.e(e)}finally{a.f()}return!0}function zi(e,t,n,r){function i(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}return i(e,n,r)!==i(t,n,r)&&i(e,t,n)!==i(e,t,r)}function Bi(e,t){for(var n=!1,r=0,i=t.length-1;r<t.length;i=r++){var a=t[r],o=t[i];a.y>e.y!=o.y>e.y&&e.x<(o.x-a.x)*(e.y-a.y)/(o.y-a.y)+a.x&&(n=!n)}return n}function Vi(e,t,n){if(Bi(e,n))return!0;for(var r=0;r<n.length;r++){var i=n[r],a=n[(r+1)%n.length];if(zi(e,t,i,a))return!0}return!1}var Hi=Gn({dampingFactor:.8,precision:1e-6,iterations:200,weight:function(e){return 1}}),Ui={pageRank:function(e){for(var t=Hi(e),n=t.dampingFactor,r=t.precision,i=t.iterations,a=t.weight,o=this._private.cy,s=this.byGroup(),c=s.nodes,l=s.edges,u=c.length,d=u*u,f=l.length,p=Array(d),m=Array(u),h=(1-n)/u,g=0;g<u;g++){for(var _=0;_<u;_++){var v=g*u+_;p[v]=0}m[g]=0}for(var y=0;y<f;y++){var b=l[y],x=b.data(`source`),S=b.data(`target`);if(x!==S){var C=c.indexOfId(x),w=c.indexOfId(S),T=a(b),E=w*u+C;p[E]+=T,m[C]+=T}}for(var D=n/u+h,O=0;O<u;O++)if(m[O]===0)for(var k=0;k<u;k++){var A=k*u+O;p[A]=D}else for(var j=0;j<u;j++){var M=j*u+O;p[M]=n*p[M]/m[O]+h}for(var N=Array(u),P=Array(u),F,I=0;I<u;I++)N[I]=1;for(var L=0;L<i;L++){for(var R=0;R<u;R++)P[R]=0;for(var z=0;z<u;z++)for(var B=0;B<u;B++){var V=z*u+B;P[z]+=p[V]*N[B]}Hr(P),F=N,N=P,P=F;for(var H=0,U=0;U<u;U++){var W=F[U]-N[U];H+=W*W}if(H<r)break}return{rank:function(e){return e=o.collection(e)[0],N[c.indexOf(e)]}}}},Wi=Gn({root:null,weight:function(e){return 1},directed:!1,alpha:0}),Gi={degreeCentralityNormalized:function(e){e=Wi(e);var t=this.cy(),n=this.nodes(),r=n.length;if(e.directed){for(var i={},a={},o=0,s=0,c=0;c<r;c++){var l=n[c],u=l.id();e.root=l;var d=this.degreeCentrality(e);o<d.indegree&&(o=d.indegree),s<d.outdegree&&(s=d.outdegree),i[u]=d.indegree,a[u]=d.outdegree}return{indegree:function(e){return o==0?0:(Y(e)&&(e=t.filter(e)),i[e.id()]/o)},outdegree:function(e){return s===0?0:(Y(e)&&(e=t.filter(e)),a[e.id()]/s)}}}for(var f={},p=0,m=0;m<r;m++){var h=n[m];e.root=h;var g=this.degreeCentrality(e);p<g.degree&&(p=g.degree),f[h.id()]=g.degree}return{degree:function(e){return p===0?0:(Y(e)&&(e=t.filter(e)),f[e.id()]/p)}}},degreeCentrality:function(e){e=Wi(e);var t=this.cy(),n=this,r=e,i=r.root,a=r.weight,o=r.directed,s=r.alpha;if(i=t.collection(i)[0],o){for(var c=i.connectedEdges(),l=c.filter(function(e){return e.target().same(i)&&n.has(e)}),u=c.filter(function(e){return e.source().same(i)&&n.has(e)}),d=l.length,f=u.length,p=0,m=0,h=0;h<l.length;h++)p+=a(l[h]);for(var g=0;g<u.length;g++)m+=a(u[g]);return{indegree:d**(1-s)*p**+s,outdegree:f**(1-s)*m**+s}}for(var _=i.connectedEdges().intersection(n),v=_.length,y=0,b=0;b<_.length;b++)y+=a(_[b]);return{degree:v**(1-s)*y**+s}}};Gi.dc=Gi.degreeCentrality,Gi.dcn=Gi.degreeCentralityNormalised=Gi.degreeCentralityNormalized;var Ki=Gn({harmonic:!0,weight:function(){return 1},directed:!1,root:null}),qi={closenessCentralityNormalized:function(e){for(var t=Ki(e),n=t.harmonic,r=t.weight,i=t.directed,a=this.cy(),o={},s=0,c=this.nodes(),l=this.floydWarshall({weight:r,directed:i}),u=0;u<c.length;u++){for(var d=0,f=c[u],p=0;p<c.length;p++)if(u!==p){var m=l.distance(f,c[p]);d+=n?1/m:m}n||(d=1/d),s<d&&(s=d),o[f.id()]=d}return{closeness:function(e){return s==0?0:(e=Y(e)?a.filter(e)[0].id():e.id(),o[e]/s)}}},closenessCentrality:function(e){var t=Ki(e),n=t.root,r=t.weight,i=t.directed,a=t.harmonic;n=this.filter(n)[0];for(var o=this.dijkstra({root:n,weight:r,directed:i}),s=0,c=this.nodes(),l=0;l<c.length;l++){var u=c[l];if(!u.same(n)){var d=o.distanceTo(u);s+=a?1/d:d}}return a?s:1/s}};qi.cc=qi.closenessCentrality,qi.ccn=qi.closenessCentralityNormalised=qi.closenessCentralityNormalized;var Ji=Gn({weight:null,directed:!1}),Yi={betweennessCentrality:function(e){for(var t=Ji(e),n=t.directed,r=t.weight,i=r!=null,a=this.cy(),o=this.nodes(),s={},c={},l=0,u={set:function(e,t){c[e]=t,t>l&&(l=t)},get:function(e){return c[e]}},d=0;d<o.length;d++){var f=o[d],p=f.id();s[p]=n?f.outgoers().nodes():f.openNeighborhood().nodes(),u.set(p,0)}for(var m=function(){for(var e=o[h].id(),t=[],n={},c={},l={},d=new dr(function(e,t){return l[e]-l[t]}),f=0;f<o.length;f++){var p=o[f].id();n[p]=[],c[p]=0,l[p]=1/0}for(c[e]=1,l[e]=0,d.push(e);!d.empty();){var m=d.pop();if(t.push(m),i)for(var g=0;g<s[m].length;g++){var _=s[m][g],v=a.getElementById(m),y=void 0;y=v.edgesTo(_).length>0?v.edgesTo(_)[0]:_.edgesTo(v)[0];var b=r(y);_=_.id(),l[_]>l[m]+b&&(l[_]=l[m]+b,d.nodes.indexOf(_)<0?d.push(_):d.updateItem(_),c[_]=0,n[_]=[]),l[_]==l[m]+b&&(c[_]=c[_]+c[m],n[_].push(m))}else for(var x=0;x<s[m].length;x++){var S=s[m][x].id();l[S]==1/0&&(d.push(S),l[S]=l[m]+1),l[S]==l[m]+1&&(c[S]=c[S]+c[m],n[S].push(m))}}for(var C={},w=0;w<o.length;w++)C[o[w].id()]=0;for(;t.length>0;){for(var T=t.pop(),E=0;E<n[T].length;E++){var D=n[T][E];C[D]=C[D]+c[D]/c[T]*(1+C[T])}T!=o[h].id()&&u.set(T,u.get(T)+C[T])}},h=0;h<o.length;h++)m();var g={betweenness:function(e){var t=a.collection(e).id();return u.get(t)},betweennessNormalized:function(e){if(l==0)return 0;var t=a.collection(e).id();return u.get(t)/l}};return g.betweennessNormalised=g.betweennessNormalized,g}};Yi.bc=Yi.betweennessCentrality;var Xi=Gn({expandFactor:2,inflateFactor:2,multFactor:1,maxIterations:20,attributes:[function(e){return 1}]}),Zi=function(e){return Xi(e)},Qi=function(e,t){for(var n=0,r=0;r<t.length;r++)n+=t[r](e);return n},$i=function(e,t,n){for(var r=0;r<t;r++)e[r*t+r]=n},ea=function(e,t){for(var n,r=0;r<t;r++){n=0;for(var i=0;i<t;i++)n+=e[i*t+r];for(var a=0;a<t;a++)e[a*t+r]=e[a*t+r]/n}},ta=function(e,t,n){for(var r=Array(n*n),i=0;i<n;i++){for(var a=0;a<n;a++)r[i*n+a]=0;for(var o=0;o<n;o++)for(var s=0;s<n;s++)r[i*n+s]+=e[i*n+o]*t[o*n+s]}return r},na=function(e,t,n){for(var r=e.slice(0),i=1;i<n;i++)e=ta(e,r,t);return e},ra=function(e,t,n){for(var r=Array(t*t),i=0;i<t*t;i++)r[i]=e[i]**+n;return ea(r,t),r},ia=function(e,t,n,r){for(var i=0;i<n;i++)if(Math.round(e[i]*10**r)/10**r!=Math.round(t[i]*10**r)/10**r)return!1;return!0},aa=function(e,t,n,r){for(var i=[],a=0;a<t;a++){for(var o=[],s=0;s<t;s++)Math.round(e[a*t+s]*1e3)/1e3>0&&o.push(n[s]);o.length!==0&&i.push(r.collection(o))}return i},oa=function(e,t){for(var n=0;n<e.length;n++)if(!t[n]||e[n].id()!==t[n].id())return!1;return!0},sa=function(e){for(var t=0;t<e.length;t++)for(var n=0;n<e.length;n++)t!=n&&oa(e[t],e[n])&&e.splice(n,1);return e},ca=function(e){for(var t=this.nodes(),n=this.edges(),r=this.cy(),i=Zi(e),a={},o=0;o<t.length;o++)a[t[o].id()]=o;for(var s=t.length,c=s*s,l=Array(c),u,d=0;d<c;d++)l[d]=0;for(var f=0;f<n.length;f++){var p=n[f],m=a[p.source().id()],h=a[p.target().id()],g=Qi(p,i.attributes);l[m*s+h]+=g,l[h*s+m]+=g}$i(l,s,i.multFactor),ea(l,s);for(var _=!0,v=0;_&&v<i.maxIterations;)_=!1,u=na(l,s,i.expandFactor),l=ra(u,s,i.inflateFactor),ia(l,u,c,4)||(_=!0),v++;var y=aa(l,s,t,r);return y=sa(y),y},la={markovClustering:ca,mcl:ca},ua=function(e){return e},da=function(e,t){return Math.abs(t-e)},fa=function(e,t,n){return e+da(t,n)},pa=function(e,t,n){return e+(n-t)**2},ma=function(e){return Math.sqrt(e)},ha=function(e,t,n){return Math.max(e,da(t,n))},ga=function(e,t,n,r,i){for(var a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:ua,o=r,s,c,l=0;l<e;l++)s=t(l),c=n(l),o=i(o,s,c);return a(o)},_a={euclidean:function(e,t,n){return e>=2?ga(e,t,n,0,pa,ma):ga(e,t,n,0,fa)},squaredEuclidean:function(e,t,n){return ga(e,t,n,0,pa)},manhattan:function(e,t,n){return ga(e,t,n,0,fa)},max:function(e,t,n){return ga(e,t,n,-1/0,ha)}};_a[`squared-euclidean`]=_a.squaredEuclidean,_a.squaredeuclidean=_a.squaredEuclidean;function va(e,t,n,r,i,a){var o=ke(e)?e:_a[e]||_a.euclidean;return t===0&&ke(e)?o(i,a):o(t,n,r,i,a)}var ya=Gn({k:2,m:2,sensitivityThreshold:1e-4,distance:`euclidean`,maxIterations:10,attributes:[],testMode:!1,testCentroids:null}),ba=function(e){return ya(e)},xa=function(e,t,n,r,i){var a=i===`kMedoids`?function(e){return r[e](n)}:function(e){return n[e]},o=function(e){return r[e](t)},s=n,c=t;return va(e,r.length,a,o,s,c)},Sa=function(e,t,n){for(var r=n.length,i=Array(r),a=Array(r),o=Array(t),s=null,c=0;c<r;c++)i[c]=e.min(n[c]).value,a[c]=e.max(n[c]).value;for(var l=0;l<t;l++){s=[];for(var u=0;u<r;u++)s[u]=Math.random()*(a[u]-i[u])+i[u];o[l]=s}return o},Ca=function(e,t,n,r,i){for(var a=1/0,o=0,s=0;s<t.length;s++){var c=xa(n,e,t[s],r,i);c<a&&(a=c,o=s)}return o},wa=function(e,t,n){for(var r=[],i=null,a=0;a<t.length;a++)i=t[a],n[i.id()]===e&&r.push(i);return r},Ta=function(e,t,n){return Math.abs(t-e)<=n},Ea=function(e,t,n){for(var r=0;r<e.length;r++)for(var i=0;i<e[r].length;i++)if(Math.abs(e[r][i]-t[r][i])>n)return!1;return!0},Da=function(e,t,n){for(var r=0;r<n;r++)if(e===t[r])return!0;return!1},Oa=function(e,t){var n=Array(t);if(e.length<50)for(var r=0;r<t;r++){for(var i=e[Math.floor(Math.random()*e.length)];Da(i,n,r);)i=e[Math.floor(Math.random()*e.length)];n[r]=i}else for(var a=0;a<t;a++)n[a]=e[Math.floor(Math.random()*e.length)];return n},ka=function(e,t,n){for(var r=0,i=0;i<t.length;i++)r+=xa(`manhattan`,t[i],e,n,`kMedoids`);return r},Aa=function(e){var t=this.cy(),n=this.nodes(),r=null,i=ba(e),a=Array(i.k),o={},s;i.testMode?typeof i.testCentroids==`number`?(i.testCentroids,s=Sa(n,i.k,i.attributes)):s=be(i.testCentroids)===`object`?i.testCentroids:Sa(n,i.k,i.attributes):s=Sa(n,i.k,i.attributes);for(var c=!0,l=0;c&&l<i.maxIterations;){for(var u=0;u<n.length;u++)r=n[u],o[r.id()]=Ca(r,s,i.distance,i.attributes,`kMeans`);c=!1;for(var d=0;d<i.k;d++){var f=wa(d,n,o);if(f.length!==0){for(var p=i.attributes.length,m=s[d],h=Array(p),g=Array(p),_=0;_<p;_++){g[_]=0;for(var v=0;v<f.length;v++)r=f[v],g[_]+=i.attributes[_](r);h[_]=g[_]/f.length,Ta(h[_],m[_],i.sensitivityThreshold)||(c=!0)}s[d]=h,a[d]=t.collection(f)}}l++}return a},ja=function(e){var t=this.cy(),n=this.nodes(),r=null,i=ba(e);i.k>n.length&&In(`kMedoids: k (${i.k}) cannot exceed the number of nodes (${n.length}).`);var a=Array(i.k),o,s={},c,l=Array(i.k);i.testMode?typeof i.testCentroids==`number`||(o=be(i.testCentroids)===`object`?i.testCentroids:Oa(n,i.k)):o=Oa(n,i.k);for(var u=!0,d=0;u&&d<i.maxIterations;){for(var f=0;f<n.length;f++)r=n[f],s[r.id()]=Ca(r,o,i.distance,i.attributes,`kMedoids`);u=!1;for(var p=0;p<o.length;p++){var m=wa(p,n,s);if(m.length!==0){l[p]=ka(o[p],m,i.attributes);for(var h=0;h<m.length;h++)c=ka(m[h],m,i.attributes),c<l[p]&&(l[p]=c,o[p]=m[h],u=!0);a[p]=t.collection(m)}}d++}return a},Ma=function(e,t,n,r,i){for(var a,o,s=0;s<t.length;s++)for(var c=0;c<e.length;c++)r[s][c]=n[s][c]**+i.m;for(var l=0;l<e.length;l++)for(var u=0;u<i.attributes.length;u++){a=0,o=0;for(var d=0;d<t.length;d++)a+=r[d][l]*i.attributes[u](t[d]),o+=r[d][l];e[l][u]=a/o}},Na=function(e,t,n,r,i){for(var a=0;a<e.length;a++)t[a]=e[a].slice();for(var o,s,c,l=2/(i.m-1),u=0;u<n.length;u++)for(var d=0;d<r.length;d++){o=0;for(var f=0;f<n.length;f++)s=xa(i.distance,r[d],n[u],i.attributes,`cmeans`),c=xa(i.distance,r[d],n[f],i.attributes,`cmeans`),o+=(s/c)**+l;e[d][u]=1/o}},Pa=function(e,t,n,r){for(var i=Array(n.k),a=0;a<i.length;a++)i[a]=[];for(var o,s,c=0;c<t.length;c++){o=-1/0,s=-1;for(var l=0;l<t[0].length;l++)t[c][l]>o&&(o=t[c][l],s=l);i[s].push(e[c])}for(var u=0;u<i.length;u++)i[u]=r.collection(i[u]);return i},Fa=function(e){for(var t=this.cy(),n=this.nodes(),r=ba(e),i,a,o,s=Array(n.length),c,l=0;l<n.length;l++)s[l]=Array(r.k);o=Array(n.length);for(var u=0;u<n.length;u++)o[u]=Array(r.k);for(var d=0;d<n.length;d++){for(var f=0,p=0;p<r.k;p++)o[d][p]=Math.random(),f+=o[d][p];for(var m=0;m<r.k;m++)o[d][m]=o[d][m]/f}a=Array(r.k);for(var h=0;h<r.k;h++)a[h]=Array(r.attributes.length);c=Array(n.length);for(var g=0;g<n.length;g++)c[g]=Array(r.k);for(var _=!0,v=0;_&&v<r.maxIterations;)_=!1,Ma(a,n,o,c,r),Na(o,s,a,n,r),Ea(o,s,r.sensitivityThreshold)||(_=!0),v++;return i=Pa(n,o,r,t),{clusters:i,degreeOfMembership:o}},Ia={kMeans:Aa,kMedoids:ja,fuzzyCMeans:Fa,fcm:Fa},La=Gn({distance:`euclidean`,linkage:`min`,mode:`threshold`,threshold:1/0,addDendrogram:!1,dendrogramDepth:0,attributes:[]}),Ra={single:`min`,complete:`max`},za=function(e){var t=La(e),n=Ra[t.linkage];return n!=null&&(t.linkage=n),t},Ba=function(e,t,n,r,i){for(var a=0,o=1/0,s,c=i.attributes,l=function(e,t){return va(i.distance,c.length,function(t){return c[t](e)},function(e){return c[e](t)},e,t)},u=0;u<e.length;u++){var d=e[u].key,f=n[d][r[d]];f<o&&(a=d,o=f)}if(i.mode===`threshold`&&o>=i.threshold||i.mode===`dendrogram`&&e.length===1)return!1;var p=t[a],m=t[r[a]],h=i.mode===`dendrogram`?{left:p,right:m,key:p.key,size:p.size+m.size}:{value:p.value.concat(m.value),key:p.key,size:p.size+m.size};e[p.index]=h,e.splice(m.index,1),t[p.key]=h;for(var g=0;g<e.length;g++){var _=e[g];p.key===_.key?s=1/0:i.linkage===`min`?(s=n[p.key][_.key],n[p.key][_.key]>n[m.key][_.key]&&(s=n[m.key][_.key])):i.linkage===`max`?(s=n[p.key][_.key],n[p.key][_.key]<n[m.key][_.key]&&(s=n[m.key][_.key])):s=i.linkage===`mean`?(n[p.key][_.key]*p.size+n[m.key][_.key]*m.size)/(p.size+m.size):i.mode===`dendrogram`?l(_.value,p.value):l(_.value[0],p.value[0]),n[p.key][_.key]=n[_.key][p.key]=s}for(var v=0;v<e.length;v++){var y=e[v].key;if(r[y]===p.key||r[y]===m.key){for(var b=y,x=0;x<e.length;x++){var S=e[x].key;n[y][S]<n[y][b]&&(b=S)}r[y]=b}e[v].index=v}return p.key=m.key=p.index=m.index=null,!0},Va=function(e,t,n){e&&(e.value?t.push(e.value):(e.left&&Va(e.left,t),e.right&&Va(e.right,t)))},Ha=function(e,t){if(!e)return``;if(e.left&&e.right){var n=Ha(e.left,t),r=Ha(e.right,t),i=t.add({group:`nodes`,data:{id:n+`,`+r}});return t.add({group:`edges`,data:{source:n,target:i.id()}}),t.add({group:`edges`,data:{source:r,target:i.id()}}),i.id()}if(e.value)return e.value.id()},Ua=function(e,t,n){if(!e)return[];var r=[],i=[],a=[];return t===0?(e.left&&Va(e.left,r),e.right&&Va(e.right,i),a=r.concat(i),[n.collection(a)]):t===1?e.value?[n.collection(e.value)]:(e.left&&Va(e.left,r),e.right&&Va(e.right,i),[n.collection(r),n.collection(i)]):e.value?[n.collection(e.value)]:(e.left&&(r=Ua(e.left,t-1,n)),e.right&&(i=Ua(e.right,t-1,n)),r.concat(i))},Wa=function(e){var t=this.cy(),n=this.nodes();if(n.length===0)return[];for(var r=za(e),i=r.attributes,a=function(e,t){return va(r.distance,i.length,function(t){return i[t](e)},function(e){return i[e](t)},e,t)},o=[],s=[],c=[],l=[],u=0;u<n.length;u++){var d={value:r.mode===`dendrogram`?n[u]:[n[u]],key:u,index:u,size:1};o[u]=d,l[u]=d,s[u]=[],c[u]=0}for(var f=0;f<o.length;f++)for(var p=0;p<=f;p++){var m=void 0;m=r.mode===`dendrogram`?f===p?1/0:a(o[f].value,o[p].value):f===p?1/0:a(o[f].value[0],o[p].value[0]),s[f][p]=m,s[p][f]=m,m<s[f][c[f]]&&(c[f]=p)}for(var h=Ba(o,l,s,c,r);h;)h=Ba(o,l,s,c,r);var g;return r.mode===`dendrogram`?(g=Ua(o[0],r.dendrogramDepth,t),r.addDendrogram&&Ha(o[0],t)):(g=Array(o.length),o.forEach(function(e,n){e.key=e.index=null,g[n]=t.collection(e.value)})),g},Ga={hierarchicalClustering:Wa,hca:Wa},Ka=Gn({distance:`euclidean`,preference:`median`,damping:.8,maxIterations:1e3,minIterations:100,attributes:[]}),qa=function(e){var t=e.damping,n=e.preference;.5<=t&&t<1||In(`Damping must range on [0.5, 1). Got: ${t}`);var r=[`median`,`mean`,`min`,`max`];return r.some(function(e){return e===n})||X(n)||In(`Preference must be one of [${r.map(function(e){return`'${e}'`}).join(`, `)}] or a number. Got: ${n}`),Ka(e)},Ja=function(e,t,n,r){var i=function(e,t){return r[t](e)};return-va(e,r.length,function(e){return i(t,e)},function(e){return i(n,e)},t,n)},Ya=function(e,t){var n=null;return n=t===`median`?Mr(e):t===`mean`?jr(e):t===`min`?kr(e):t===`max`?Ar(e):t,n},Xa=function(e,t,n){for(var r=[],i=0;i<e;i++)t[i*e+i]+n[i*e+i]>0&&r.push(i);return r},Za=function(e,t,n){for(var r=[],i=0;i<e;i++){for(var a=-1,o=-1/0,s=0;s<n.length;s++){var c=n[s];t[i*e+c]>o&&(a=c,o=t[i*e+c])}a>0&&r.push(a)}for(var l=0;l<n.length;l++)r[n[l]]=n[l];return r},Qa=function(e,t,n){for(var r=Za(e,t,n),i=0;i<n.length;i++){for(var a=[],o=0;o<r.length;o++)r[o]===n[i]&&a.push(o);for(var s=-1,c=-1/0,l=0;l<a.length;l++){for(var u=0,d=0;d<a.length;d++)u+=t[a[d]*e+a[l]];u>c&&(s=l,c=u)}n[i]=a[s]}return r=Za(e,t,n),r},$a=function(e){for(var t=this.cy(),n=this.nodes(),r=qa(e),i={},a=0;a<n.length;a++)i[n[a].id()]=a;for(var o=n.length,s=o*o,c=Array(s),l,u,d,f=0;f<s;f++)c[f]=-1/0;for(var p=0;p<o;p++)for(var m=0;m<o;m++)p!==m&&(c[p*o+m]=Ja(r.distance,n[p],n[m],r.attributes));l=Ya(c,r.preference);for(var h=0;h<o;h++)c[h*o+h]=l;u=Array(s);for(var g=0;g<s;g++)u[g]=0;d=Array(s);for(var _=0;_<s;_++)d[_]=0;for(var v=Array(o),y=Array(o),b=Array(o),x=0;x<o;x++)v[x]=0,y[x]=0,b[x]=0;for(var S=Array(o*r.minIterations),C=0;C<S.length;C++)S[C]=0;for(var w=0;w<r.maxIterations;w++){for(var T=0;T<o;T++){for(var E=-1/0,D=-1/0,O=-1,k=0,A=0;A<o;A++)v[A]=u[T*o+A],k=d[T*o+A]+c[T*o+A],k>=E?(D=E,E=k,O=A):k>D&&(D=k);for(var j=0;j<o;j++)u[T*o+j]=(1-r.damping)*(c[T*o+j]-E)+r.damping*v[j];u[T*o+O]=(1-r.damping)*(c[T*o+O]-D)+r.damping*v[O]}for(var M=0;M<o;M++){for(var N=0,P=0;P<o;P++)v[P]=d[P*o+M],y[P]=Math.max(0,u[P*o+M]),N+=y[P];N-=y[M],y[M]=u[M*o+M],N+=y[M];for(var F=0;F<o;F++)d[F*o+M]=(1-r.damping)*Math.min(0,N-y[F])+r.damping*v[F];d[M*o+M]=(1-r.damping)*(N-y[M])+r.damping*v[M]}for(var I=0,L=0;L<o;L++){var R=+(d[L*o+L]+u[L*o+L]>0);S[w%r.minIterations*o+L]=R,I+=R}if(I>0&&(w>=r.minIterations-1||w==r.maxIterations-1)){for(var z=0,B=0;B<o;B++){b[B]=0;for(var V=0;V<r.minIterations;V++)b[B]+=S[V*o+B];(b[B]===0||b[B]===r.minIterations)&&z++}if(z===o)break}}for(var H=Xa(o,u,d),U=Qa(o,c,H),W={},ee=0;ee<H.length;ee++)W[H[ee]]=[];for(var G=0;G<n.length;G++){var K=U[i[n[G].id()]];K!=null&&W[K].push(n[G])}for(var q=Array(H.length),J=0;J<H.length;J++)q[J]=t.collection(W[H[J]]);return q},eo={affinityPropagation:$a,ap:$a},to=Gn({root:void 0,directed:!1}),no={hierholzer:function(e){if(!je(e)){var t=arguments;e={root:t[0],directed:t[1]}}var n=to(e),r=n.root,i=n.directed,a=this,o=!1,s,c,l;r&&(l=Y(r)?this.filter(r)[0].id():r[0].id());var u={},d={},f=a.edges().filter(function(e){return a.has(e.source())&&a.has(e.target())});i?a.forEach(function(e){var t=e.id();if(e.isNode()){var n=e.incomers().edges().intersection(f),r=e.outgoers().edges().intersection(f),i=n.length,a=r.length,l=i-a,p=a-i;l==1?s?o=!0:s=t:p==1?c?o=!0:c=t:(p>1||l>1)&&(o=!0),u[t]=[],r.forEach(function(e){return u[t].push(e.id())})}else d[t]=[void 0,e.target().id()]}):a.forEach(function(e){var t=e.id();if(e.isNode()){var n=e.connectedEdges().intersection(f);(n.length+n.filter(function(e){return e.isLoop()}).length)%2&&(s?c?o=!0:c=t:s=t),u[t]=[],n.forEach(function(e){return u[t].push(e.id())})}else d[t]=[e.source().id(),e.target().id()]});var p={found:!1,trail:void 0};if(o)return p;if(c&&s){if(i){if(l&&c!=l)return p;l=c}else if(l&&c!=l&&s!=l)return p;else l||=c}else l||=a[0].id();var m=function(e){for(var t=e,n=[e],r,a,o;u[t].length;)r=u[t].shift(),a=d[r][0],o=d[r][1],t==o?!i&&t!=a&&(u[a]=u[a].filter(function(e){return e!=r}),t=a):(u[o]=u[o].filter(function(e){return e!=r}),t=o),n.unshift(r),n.unshift(t);return n},h=[],g=[];for(g=m(l);g.length!=1;)u[g[0]].length==0?(h.unshift(a.getElementById(g.shift())),h.unshift(a.getElementById(g.shift()))):g=m(g.shift()).concat(g);for(var _ in h.unshift(a.getElementById(g.shift())),u)if(u[_].length)return p;return p.found=!0,p.trail=this.spawn(h,!0),p}},ro=function(){var e=this,t={},n=0,r=0,i=[],a=[],o={},s=function(n,r){for(var o=a.length-1,s=[],c=e.spawn();a[o].x!=n||a[o].y!=r;)s.push(a.pop().edge),o--;s.push(a.pop().edge),s.forEach(function(n){var r=n.connectedNodes().intersection(e);c.merge(n),r.forEach(function(n){var r=n.id(),i=n.connectedEdges().intersection(e);c.merge(n),t[r].cutVertex?c.merge(i.filter(function(e){return e.isLoop()})):c.merge(i)})}),i.push(c)},c=function(l,u,d){l===d&&(r+=1),t[u]={id:n,low:n++,cutVertex:!1};var f=e.getElementById(u).connectedEdges().intersection(e);if(f.size()===0)i.push(e.spawn(e.getElementById(u)));else{var p,m,h,g;f.forEach(function(e){p=e.source().id(),m=e.target().id(),h=p===u?m:p,h!==d&&(g=e.id(),o[g]||(o[g]=!0,a.push({x:u,y:h,edge:e})),h in t?t[u].low=Math.min(t[u].low,t[h].id):(c(l,h,u),t[u].low=Math.min(t[u].low,t[h].low),t[u].id<=t[h].low&&(t[u].cutVertex=!0,s(u,h))))})}};e.forEach(function(e){if(e.isNode()){var n=e.id();n in t||(r=0,c(n,n),t[n].cutVertex=r>1)}});var l=Object.keys(t).filter(function(e){return t[e].cutVertex}).map(function(t){return e.getElementById(t)});return{cut:e.spawn(l),components:i}},io={hopcroftTarjanBiconnected:ro,htbc:ro,htb:ro,hopcroftTarjanBiconnectedComponents:ro},ao=function(){var e=this,t={},n=0,r=[],i=[],a=e.spawn(e),o=function(s){if(i.push(s),t[s]={index:n,low:n++,explored:!1},e.getElementById(s).connectedEdges().intersection(e).forEach(function(e){var n=e.target().id();n!==s&&(n in t||o(n),t[n].explored||(t[s].low=Math.min(t[s].low,t[n].low)))}),t[s].index===t[s].low){for(var c=e.spawn();;){var l=i.pop();if(c.merge(e.getElementById(l)),t[l].low=t[s].index,t[l].explored=!0,l===s)break}var u=c.edgesWith(c),d=c.merge(u);r.push(d),a=a.difference(d)}};return e.forEach(function(e){if(e.isNode()){var n=e.id();n in t||o(n)}}),{cut:a,components:r}},oo={tarjanStronglyConnected:ao,tsc:ao,tscc:ao,tarjanStronglyConnectedComponents:ao},so={};[rr,pr,mr,gr,vr,br,wr,Ui,Gi,qi,Yi,la,Ia,Ga,eo,no,io,oo].forEach(function(e){Z(so,e)});var co=0,lo=1,uo=2,fo=function(e){if(!(this instanceof fo))return new fo(e);this.id=`Thenable/1.0.7`,this.state=co,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))};fo.prototype={fulfill:function(e){return po(this,lo,`fulfillValue`,e)},reject:function(e){return po(this,uo,`rejectReason`,e)},then:function(e,t){var n=this,r=new fo;return n.onFulfilled.push(go(e,r,`fulfill`)),n.onRejected.push(go(t,r,`reject`)),mo(n),r.proxy}};var po=function(e,t,n,r){return e.state===co&&(e.state=t,e[n]=r,mo(e)),e},mo=function(e){e.state===lo?ho(e,`onFulfilled`,e.fulfillValue):e.state===uo&&ho(e,`onRejected`,e.rejectReason)},ho=function(e,t,n){if(e[t].length!==0){var r=e[t];e[t]=[];var i=function(){for(var e=0;e<r.length;e++)r[e](n)};typeof setImmediate==`function`?setImmediate(i):setTimeout(i,0)}},go=function(e,t,n){return function(r){if(typeof e!=`function`)t[n].call(t,r);else{var i;try{i=e(r)}catch(e){t.reject(e);return}_o(t,i)}}},_o=function(e,t){if(e===t||e.proxy===t)e.reject(TypeError(`cannot resolve promise with itself`));else{var n;if(be(t)===`object`&&t!==null||typeof t==`function`)try{n=t.then}catch(t){e.reject(t);return}if(typeof n==`function`){var r=!1;try{n.call(t,function(n){r||(r=!0,n===t?e.reject(TypeError(`circular thenable chain`)):_o(e,n))},function(t){r||(r=!0,e.reject(t))})}catch(t){r||e.reject(t)}}else e.fulfill(t)}};fo.all=function(e){return new fo(function(t,n){for(var r=Array(e.length),i=0,a=function(n,a){r[n]=a,i++,i===e.length&&t(r)},o=0;o<e.length;o++)(function(t){var r=e[t];r!=null&&r.then!=null?r.then(function(e){a(t,e)},function(e){n(e)}):a(t,r)})(o)})},fo.resolve=function(e){return new fo(function(t,n){t(e)})},fo.reject=function(e){return new fo(function(t,n){n(e)})};var vo=typeof Promise<`u`?Promise:fo,yo=function(e,t,n){var r=Re(e),i=!r,a=this._private=Z({duration:1e3},t,n);if(a.target=e,a.style=a.style||a.css,a.started=!1,a.playing=!1,a.hooked=!1,a.applying=!1,a.progress=0,a.completes=[],a.frames=[],a.complete&&ke(a.complete)&&a.completes.push(a.complete),i){var o=e.position();a.startPosition=a.startPosition||{x:o.x,y:o.y},a.startStyle=a.startStyle||e.cy().style().getAnimationStartStyle(e,a.style)}if(r){var s=e.pan();a.startPan={x:s.x,y:s.y},a.startZoom=e.zoom()}this.length=1,this[0]=this},bo=yo.prototype;Z(bo,{instanceString:function(){return`animation`},hook:function(){var e=this._private;if(!e.hooked){var t,n=e.target._private.animation;t=e.queue?n.queue:n.current,t.push(this),Fe(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(t,n){var r=e[t];r!=null&&(e[t]=e[n],e[n]=r)};if(n(`zoom`,`startZoom`),n(`pan`,`startPan`),n(`position`,`startPosition`),e.style)for(var r=0;r<e.style.length;r++){var i=e.style[r],a=i.name,o=e.startStyle[a];e.startStyle[a]=i,e.style[r]=o}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 vo(function(e,t){n.push(function(){e()})})}}),bo.complete=bo.completed,bo.run=bo.play,bo.running=bo.playing;var xo={animated:function(){return function(){var e=this,t=e.length===void 0?[e]:e;if(!(this._private.cy||this).styleEnabled())return!1;var n=t[0];if(n)return n._private.animation.current.length>0}},clearQueue:function(){return function(){var e=this,t=e.length===void 0?[e]:e;if(!(this._private.cy||this).styleEnabled())return this;for(var n=0;n<t.length;n++){var r=t[n];r._private.animation.queue=[]}return this}},delay:function(){return function(e,t){return(this._private.cy||this).styleEnabled()?this.animate({delay:e,duration:e,complete:t}):this}},delayAnimation:function(){return function(e,t){return(this._private.cy||this).styleEnabled()?this.animation({delay:e,duration:e,complete:t}):this}},animation:function(){return function(e,t){var n=this,r=n.length!==void 0,i=r?n:[n],a=this._private.cy||this,o=!r,s=!o;if(!a.styleEnabled())return this;var c=a.style();if(e=Z({},e,t),Object.keys(e).length===0)return new yo(i[0],e);switch(e.duration===void 0&&(e.duration=400),e.duration){case`slow`:e.duration=600;break;case`fast`:e.duration=200}if(s&&(e.style=c.getPropsList(e.style||e.css),e.css=void 0),s&&e.renderedPosition!=null){var l=e.renderedPosition,u=a.pan(),d=a.zoom();e.position=Dr(l,d,u)}if(o&&e.panBy!=null){var f=e.panBy,p=a.pan();e.pan={x:p.x+f.x,y:p.y+f.y}}var m=e.center||e.centre;if(o&&m!=null){var h=a.getCenterPan(m.eles,e.zoom);h!=null&&(e.pan=h)}if(o&&e.fit!=null){var g=e.fit,_=a.getFitViewport(g.eles||g.boundingBox,g.padding);_!=null&&(e.pan=_.pan,e.zoom=_.zoom)}if(o&&je(e.zoom)){var v=a.getZoomedViewport(e.zoom);v==null?e.zoom=null:(v.zoomed&&(e.zoom=v.zoom),v.panned&&(e.pan=v.pan))}return new yo(i[0],e)}},animate:function(){return function(e,t){var n=this,r=n.length===void 0?[n]:n;if(!(this._private.cy||this).styleEnabled())return this;t&&(e=Z({},e,t));for(var i=0;i<r.length;i++){var a=r[i],o=a.animated()&&(e.queue===void 0||e.queue);a.animation(e,o?{queue:!0}:void 0).play()}return this}},stop:function(){return function(e,t){var n=this,r=n.length===void 0?[n]:n,i=this._private.cy||this;if(!i.styleEnabled())return this;for(var a=0;a<r.length;a++){for(var o=r[a]._private,s=o.animation.current,c=0;c<s.length;c++){var l=s[c]._private;t&&(l.duration=0)}e&&(o.animation.queue=[]),t||(o.animation.current=[])}return i.notify(`draw`),this}}},So,Co;function wo(){return Co||(Co=1,So=Array.isArray),So}var To,Eo;function Do(){if(Eo)return To;Eo=1;var e=wo(),t=Qt(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(i,a){if(e(i))return!1;var o=typeof i;return o==`number`||o==`symbol`||o==`boolean`||i==null||t(i)?!0:r.test(i)||!n.test(i)||a!=null&&i in Object(a)}return To=i,To}var Oo,ko;function Ao(){if(ko)return Oo;ko=1;var e=Kt(),t=yt(),n=`[object AsyncFunction]`,r=`[object Function]`,i=`[object GeneratorFunction]`,a=`[object Proxy]`;function o(o){if(!t(o))return!1;var s=e(o);return s==r||s==i||s==n||s==a}return Oo=o,Oo}var jo,Mo;function No(){return Mo||(Mo=1,jo=Tt()[`__core-js_shared__`]),jo}var Po,Fo;function Io(){if(Fo)return Po;Fo=1;var e=No(),t=function(){var t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||``);return t?`Symbol(src)_1.`+t:``}();function n(e){return!!t&&t in e}return Po=n,Po}var Lo,Ro;function zo(){if(Ro)return Lo;Ro=1;var e=Function.prototype.toString;function t(t){if(t!=null){try{return e.call(t)}catch{}try{return t+``}catch{}}return``}return Lo=t,Lo}var Bo,Vo;function Ho(){if(Vo)return Bo;Vo=1;var e=Ao(),t=Io(),n=yt(),r=zo(),i=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,c=o.toString,l=s.hasOwnProperty,u=RegExp(`^`+c.call(l).replace(i,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function d(i){return!n(i)||t(i)?!1:(e(i)?u:a).test(r(i))}return Bo=d,Bo}var Uo,Wo;function Go(){if(Wo)return Uo;Wo=1;function e(e,t){return e?.[t]}return Uo=e,Uo}var Ko,qo;function Jo(){if(qo)return Ko;qo=1;var e=Ho(),t=Go();function n(n,r){var i=t(n,r);return e(i)?i:void 0}return Ko=n,Ko}var Yo,Xo;function Zo(){return Xo||(Xo=1,Yo=Jo()(Object,`create`)),Yo}var Qo,$o;function es(){if($o)return Qo;$o=1;var e=Zo();function t(){this.__data__=e?e(null):{},this.size=0}return Qo=t,Qo}var ts,ns;function rs(){if(ns)return ts;ns=1;function e(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}return ts=e,ts}var is,as;function os(){if(as)return is;as=1;var e=Zo(),t=`__lodash_hash_undefined__`,n=Object.prototype.hasOwnProperty;function r(r){var i=this.__data__;if(e){var a=i[r];return a===t?void 0:a}return n.call(i,r)?i[r]:void 0}return is=r,is}var ss,cs;function ls(){if(cs)return ss;cs=1;var e=Zo(),t=Object.prototype.hasOwnProperty;function n(n){var r=this.__data__;return e?r[n]!==void 0:t.call(r,n)}return ss=n,ss}var us,ds;function fs(){if(ds)return us;ds=1;var e=Zo(),t=`__lodash_hash_undefined__`;function n(n,r){var i=this.__data__;return this.size+=+!this.has(n),i[n]=e&&r===void 0?t:r,this}return us=n,us}var ps,ms;function hs(){if(ms)return ps;ms=1;var e=es(),t=rs(),n=os(),r=ls(),i=fs();function a(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,ps=a,ps}var gs,_s;function vs(){if(_s)return gs;_s=1;function e(){this.__data__=[],this.size=0}return gs=e,gs}var ys,bs;function xs(){if(bs)return ys;bs=1;function e(e,t){return e===t||e!==e&&t!==t}return ys=e,ys}var Ss,Cs;function ws(){if(Cs)return Ss;Cs=1;var e=xs();function t(t,n){for(var r=t.length;r--;)if(e(t[r][0],n))return r;return-1}return Ss=t,Ss}var Ts,Es;function Ds(){if(Es)return Ts;Es=1;var e=ws(),t=Array.prototype.splice;function n(n){var r=this.__data__,i=e(r,n);return i<0?!1:(i==r.length-1?r.pop():t.call(r,i,1),--this.size,!0)}return Ts=n,Ts}var Os,ks;function As(){if(ks)return Os;ks=1;var e=ws();function t(t){var n=this.__data__,r=e(n,t);return r<0?void 0:n[r][1]}return Os=t,Os}var js,Ms;function Ns(){if(Ms)return js;Ms=1;var e=ws();function t(t){return e(this.__data__,t)>-1}return js=t,js}var Ps,Fs;function Is(){if(Fs)return Ps;Fs=1;var e=ws();function t(t,n){var r=this.__data__,i=e(r,t);return i<0?(++this.size,r.push([t,n])):r[i][1]=n,this}return Ps=t,Ps}var Ls,Rs;function zs(){if(Rs)return Ls;Rs=1;var e=vs(),t=Ds(),n=As(),r=Ns(),i=Is();function a(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,Ls=a,Ls}var Bs,Vs;function Hs(){return Vs||(Vs=1,Bs=Jo()(Tt(),`Map`)),Bs}var Us,Ws;function Gs(){if(Ws)return Us;Ws=1;var e=hs(),t=zs(),n=Hs();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return Us=r,Us}var Ks,qs;function Js(){if(qs)return Ks;qs=1;function e(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}return Ks=e,Ks}var Ys,Xs;function Zs(){if(Xs)return Ys;Xs=1;var e=Js();function t(t,n){var r=t.__data__;return e(n)?r[typeof n==`string`?`string`:`hash`]:r.map}return Ys=t,Ys}var Qs,$s;function ec(){if($s)return Qs;$s=1;var e=Zs();function t(t){var n=e(this,t).delete(t);return this.size-=+!!n,n}return Qs=t,Qs}var tc,nc;function rc(){if(nc)return tc;nc=1;var e=Zs();function t(t){return e(this,t).get(t)}return tc=t,tc}var ic,ac;function oc(){if(ac)return ic;ac=1;var e=Zs();function t(t){return e(this,t).has(t)}return ic=t,ic}var sc,cc;function lc(){if(cc)return sc;cc=1;var e=Zs();function t(t,n){var r=e(this,t),i=r.size;return r.set(t,n),this.size+=r.size==i?0:1,this}return sc=t,sc}var uc,dc;function fc(){if(dc)return uc;dc=1;var e=Gs(),t=ec(),n=rc(),r=oc(),i=lc();function a(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,uc=a,uc}var pc,mc;function hc(){if(mc)return pc;mc=1;var e=fc(),t=`Expected a function`;function n(r,i){if(typeof r!=`function`||i!=null&&typeof i!=`function`)throw TypeError(t);var a=function(){var e=arguments,t=i?i.apply(this,e):e[0],n=a.cache;if(n.has(t))return n.get(t);var o=r.apply(this,e);return a.cache=n.set(t,o)||n,o};return a.cache=new(n.Cache||e),a}return n.Cache=e,pc=n,pc}var gc,_c;function vc(){if(_c)return gc;_c=1;var e=hc(),t=500;function n(n){var r=e(n,function(e){return i.size===t&&i.clear(),e}),i=r.cache;return r}return gc=n,gc}var yc,bc;function xc(){if(bc)return yc;bc=1;var e=vc(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g;return yc=e(function(e){var r=[];return e.charCodeAt(0)===46&&r.push(``),e.replace(t,function(e,t,i,a){r.push(i?a.replace(n,`$1`):t||e)}),r}),yc}var Sc,Cc;function wc(){if(Cc)return Sc;Cc=1;function e(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}return Sc=e,Sc}var Tc,Ec;function Dc(){if(Ec)return Tc;Ec=1;var e=Lt(),t=wc(),n=wo(),r=Qt(),i=e?e.prototype:void 0,a=i?i.toString:void 0;function o(e){if(typeof e==`string`)return e;if(n(e))return t(e,o)+``;if(r(e))return a?a.call(e):``;var i=e+``;return i==`0`&&1/e==-1/0?`-0`:i}return Tc=o,Tc}var Oc,kc;function Ac(){if(kc)return Oc;kc=1;var e=Dc();function t(t){return t==null?``:e(t)}return Oc=t,Oc}var jc,Mc;function Nc(){if(Mc)return jc;Mc=1;var e=wo(),t=Do(),n=xc(),r=Ac();function i(i,a){return e(i)?i:t(i,a)?[i]:n(r(i))}return jc=i,jc}var Pc,Fc;function Ic(){if(Fc)return Pc;Fc=1;var e=Qt();function t(t){if(typeof t==`string`||e(t))return t;var n=t+``;return n==`0`&&1/t==-1/0?`-0`:n}return Pc=t,Pc}var Lc,Rc;function zc(){if(Rc)return Lc;Rc=1;var e=Nc(),t=Ic();function n(n,r){r=e(r,n);for(var i=0,a=r.length;n!=null&&i<a;)n=n[t(r[i++])];return i&&i==a?n:void 0}return Lc=n,Lc}var Bc,Vc;function Hc(){if(Vc)return Bc;Vc=1;var e=zc();function t(t,n,r){var i=t==null?void 0:e(t,n);return i===void 0?r:i}return Bc=t,Bc}var Uc=gt(Hc()),Wc,Gc;function Kc(){if(Gc)return Wc;Gc=1;var e=Jo();return Wc=function(){try{var t=e(Object,`defineProperty`);return t({},``,{}),t}catch{}}(),Wc}var qc,Jc;function Yc(){if(Jc)return qc;Jc=1;var e=Kc();function t(t,n,r){n==`__proto__`&&e?e(t,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[n]=r}return qc=t,qc}var Xc,Zc;function Qc(){if(Zc)return Xc;Zc=1;var e=Yc(),t=xs(),n=Object.prototype.hasOwnProperty;function r(r,i,a){var o=r[i];(!(n.call(r,i)&&t(o,a))||a===void 0&&!(i in r))&&e(r,i,a)}return Xc=r,Xc}var $c,el;function tl(){if(el)return $c;el=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(n,r){var i=typeof n;return r??=e,!!r&&(i==`number`||i!=`symbol`&&t.test(n))&&n>-1&&n%1==0&&n<r}return $c=n,$c}var nl,rl;function il(){if(rl)return nl;rl=1;var e=Qc(),t=Nc(),n=tl(),r=yt(),i=Ic();function a(a,o,s,c){if(!r(a))return a;o=t(o,a);for(var l=-1,u=o.length,d=u-1,f=a;f!=null&&++l<u;){var p=i(o[l]),m=s;if(p===`__proto__`||p===`constructor`||p===`prototype`)return a;if(l!=d){var h=f[p];m=c?c(h,p,f):void 0,m===void 0&&(m=r(h)?h:n(o[l+1])?[]:{})}e(f,p,m),f=f[p]}return a}return nl=a,nl}var al,ol;function sl(){if(ol)return al;ol=1;var e=il();function t(t,n,r){return t==null?t:e(t,n,r)}return al=t,al}var cl=gt(sl()),ll,ul;function dl(){if(ul)return ll;ul=1;function e(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}return ll=e,ll}var fl,pl;function ml(){if(pl)return fl;pl=1;var e=wc(),t=dl(),n=wo(),r=Qt(),i=xc(),a=Ic(),o=Ac();function s(s){return n(s)?e(s,a):r(s)?[s]:t(i(o(s)))}return fl=s,fl}var hl=gt(ml()),gl={data:function(e){return e=Z({},{field:`data`,bindingEvent:`data`,allowBinding:!1,allowSetting:!1,allowGetting:!1,settingEvent:`data`,settingTriggersEvent:!1,triggerFnName:`trigger`,immutableKeys:{},updateStyle:!1,beforeGet:function(e){},beforeSet:function(e,t){},onSet:function(e){},canSet:function(e){return!0}},e),function(t,n){var r=e,i=this,a=i.length!==void 0,o=a?i:[i],s=a?i[0]:i;if(Y(t)){var c=t.indexOf(`.`)!==-1&&hl(t);if(r.allowGetting&&n===void 0){var l;return s&&(r.beforeGet(s),l=c&&s._private[r.field][t]===void 0?Uc(s._private[r.field],c):s._private[r.field][t]),l}if(r.allowSetting&&n!==void 0&&!r.immutableKeys[t]){var u=de({},t,n);r.beforeSet(i,u);for(var d=0,f=o.length;d<f;d++){var p=o[d];r.canSet(p)&&(c&&s._private[r.field][t]===void 0?cl(p._private[r.field],c,n):p._private[r.field][t]=n)}r.updateStyle&&i.updateStyle(),r.onSet(i),r.settingTriggersEvent&&i[r.triggerFnName](r.settingEvent)}}else if(r.allowSetting&&je(t)){var m=t,h,g,_=Object.keys(m);r.beforeSet(i,m);for(var v=0;v<_.length;v++)if(h=_[v],g=m[h],!r.immutableKeys[h])for(var y=0;y<o.length;y++){var b=o[y];r.canSet(b)&&(b._private[r.field][h]=g)}r.updateStyle&&i.updateStyle(),r.onSet(i),r.settingTriggersEvent&&i[r.triggerFnName](r.settingEvent)}else if(r.allowBinding&&ke(t)){var x=t;i.on(r.bindingEvent,x)}else if(r.allowGetting&&t===void 0){var S;return s&&(r.beforeGet(s),S=s._private[r.field]),S}return i}},removeData:function(e){return e=Z({},{field:`data`,event:`data`,triggerFnName:`trigger`,triggerEvent:!1,immutableKeys:{}},e),function(t){var n=e,r=this,i=r.length===void 0?[r]:r;if(Y(t)){for(var a=t.split(/\s+/),o=a.length,s=0;s<o;s++){var c=a[s];if(!Ve(c)&&!n.immutableKeys[c])for(var l=0,u=i.length;l<u;l++)i[l]._private[n.field][c]=void 0}n.triggerEvent&&r[n.triggerFnName](n.event)}else if(t===void 0){for(var d=0,f=i.length;d<f;d++)for(var p=i[d]._private[n.field],m=Object.keys(p),h=0;h<m.length;h++){var g=m[h];n.immutableKeys[g]||(p[g]=void 0)}n.triggerEvent&&r[n.triggerFnName](n.event)}return r}}},_l={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(e,t){var n=this,r=Array.prototype.slice.call(arguments,0);return new vo(function(e,t){var i=r.concat([function(t){n.off.apply(n,a),e(t)}]),a=i.concat([]);n.on.apply(n,i)})}}},vl={};[xo,gl,_l].forEach(function(e){Z(vl,e)});var yl={animate:vl.animate(),animation:vl.animation(),animated:vl.animated(),clearQueue:vl.clearQueue(),delay:vl.delay(),delayAnimation:vl.delayAnimation(),stop:vl.stop()},bl={classes:function(e){var t=this;if(e===void 0){var n=[];return t[0]._private.classes.forEach(function(e){return n.push(e)}),n}Ae(e)||(e=(e||``).match(/\S+/g)||[]);for(var r=[],i=new er(e),a=0;a<t.length;a++){for(var o=t[a],s=o._private,c=s.classes,l=!1,u=0;u<e.length;u++){var d=e[u];if(!c.has(d)){l=!0;break}}l||=c.size!==e.length,l&&(s.classes=i,r.push(o))}return r.length>0&&this.spawn(r).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){Ae(e)||(e=e.match(/\S+/g)||[]);for(var n=this,r=t===void 0,i=[],a=0,o=n.length;a<o;a++)for(var s=n[a],c=s._private.classes,l=!1,u=0;u<e.length;u++){var d=e[u],f=c.has(d),p=!1;t||r&&!f?(c.add(d),p=!0):(!t||r&&f)&&(c.delete(d),p=!0),!l&&p&&(i.push(s),l=!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}};bl.className=bl.classNames=bl.classes;var xl={metaChar:`[\\!\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\]\\^\\\`\\{\\|\\}\\~]`,comparatorOp:`=|\\!=|>|>=|<|<=|\\$=|\\^=|\\*=`,boolOp:`\\?|\\!|\\^`,string:`"(?:\\\\"|[^"])*"|'(?:\\\\'|[^'])*'`,number:Qe,meta:`degree|indegree|outdegree`,separator:`\\s*,\\s*`,descendant:`\\s+`,child:`\\s+>\\s+`,subject:`\\$`,group:`node|edge|\\*`,directedEdge:`\\s+->\\s+`,undirectedEdge:`\\s+<->\\s+`};xl.variable=`(?:[\\w-.]|(?:\\\\`+xl.metaChar+`))+`,xl.className=`(?:[\\w-]|(?:\\\\`+xl.metaChar+`))+`,xl.value=xl.string+`|`+xl.number,xl.id=xl.variable,(function(){for(var e=xl.comparatorOp.split(`|`),t,n=0;n<e.length;n++)t=e[n],xl.comparatorOp+=`|@`+t;for(e=xl.comparatorOp.split(`|`),n=0;n<e.length;n++)t=e[n],t.indexOf(`!`)>=0||t!==`=`&&(xl.comparatorOp+=`|\\!`+t)})();var Sl=function(){return{checks:[]}},Q={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},Cl=[{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(e,t){return ot(e.selector,t.selector)}),wl=function(){for(var e={},t,n=0;n<Cl.length;n++)t=Cl[n],e[t.selector]=t.matches;return e}(),Tl=function(e,t){return wl[e](t)},El=`(`+Cl.map(function(e){return e.selector}).join(`|`)+`)`,Dl=function(e){return e.replace(RegExp(`\\\\(`+xl.metaChar+`)`,`g`),function(e,t){return t})},Ol=function(e,t,n){e[e.length-1]=n},kl=[{name:`group`,query:!0,regex:`(`+xl.group+`)`,populate:function(e,t,n){var r=ge(n,1)[0];t.checks.push({type:Q.GROUP,value:r===`*`?r:r+`s`})}},{name:`state`,query:!0,regex:El,populate:function(e,t,n){var r=ge(n,1)[0];t.checks.push({type:Q.STATE,value:r})}},{name:`id`,query:!0,regex:`\\#(`+xl.id+`)`,populate:function(e,t,n){var r=ge(n,1)[0];t.checks.push({type:Q.ID,value:Dl(r)})}},{name:`className`,query:!0,regex:`\\.(`+xl.className+`)`,populate:function(e,t,n){var r=ge(n,1)[0];t.checks.push({type:Q.CLASS,value:Dl(r)})}},{name:`dataExists`,query:!0,regex:`\\[\\s*(`+xl.variable+`)\\s*\\]`,populate:function(e,t,n){var r=ge(n,1)[0];t.checks.push({type:Q.DATA_EXIST,field:Dl(r)})}},{name:`dataCompare`,query:!0,regex:`\\[\\s*(`+xl.variable+`)\\s*(`+xl.comparatorOp+`)\\s*(`+xl.value+`)\\s*\\]`,populate:function(e,t,n){var r=ge(n,3),i=r[0],a=r[1],o=r[2];o=RegExp(`^`+xl.string+`$`).exec(o)==null?parseFloat(o):o.substring(1,o.length-1),t.checks.push({type:Q.DATA_COMPARE,field:Dl(i),operator:a,value:o})}},{name:`dataBool`,query:!0,regex:`\\[\\s*(`+xl.boolOp+`)\\s*(`+xl.variable+`)\\s*\\]`,populate:function(e,t,n){var r=ge(n,2),i=r[0],a=r[1];t.checks.push({type:Q.DATA_BOOL,field:Dl(a),operator:i})}},{name:`metaCompare`,query:!0,regex:`\\[\\[\\s*(`+xl.meta+`)\\s*(`+xl.comparatorOp+`)\\s*(`+xl.number+`)\\s*\\]\\]`,populate:function(e,t,n){var r=ge(n,3),i=r[0],a=r[1],o=r[2];t.checks.push({type:Q.META_COMPARE,field:Dl(i),operator:a,value:parseFloat(o)})}},{name:`nextQuery`,separator:!0,regex:xl.separator,populate:function(e,t){var n=e.currentSubject,r=e.edgeCount,i=e.compoundCount,a=e[e.length-1];return n!=null&&(a.subject=n,e.currentSubject=null),a.edgeCount=r,a.compoundCount=i,e.edgeCount=0,e.compoundCount=0,e[e.length++]=Sl()}},{name:`directedEdge`,separator:!0,regex:xl.directedEdge,populate:function(e,t){if(e.currentSubject==null){var n=Sl(),r=t,i=Sl();return n.checks.push({type:Q.DIRECTED_EDGE,source:r,target:i}),Ol(e,t,n),e.edgeCount++,i}var a=Sl(),o=t,s=Sl();return a.checks.push({type:Q.NODE_SOURCE,source:o,target:s}),Ol(e,t,a),e.edgeCount++,s}},{name:`undirectedEdge`,separator:!0,regex:xl.undirectedEdge,populate:function(e,t){if(e.currentSubject==null){var n=Sl(),r=t,i=Sl();return n.checks.push({type:Q.UNDIRECTED_EDGE,nodes:[r,i]}),Ol(e,t,n),e.edgeCount++,i}var a=Sl(),o=t,s=Sl();return a.checks.push({type:Q.NODE_NEIGHBOR,node:o,neighbor:s}),Ol(e,t,a),s}},{name:`child`,separator:!0,regex:xl.child,populate:function(e,t){if(e.currentSubject==null){var n=Sl(),r=Sl(),i=e[e.length-1];return n.checks.push({type:Q.CHILD,parent:i,child:r}),Ol(e,t,n),e.compoundCount++,r}if(e.currentSubject===t){var a=Sl(),o=e[e.length-1],s=Sl(),c=Sl(),l=Sl(),u=Sl();return a.checks.push({type:Q.COMPOUND_SPLIT,left:o,right:s,subject:c}),c.checks=t.checks,t.checks=[{type:Q.TRUE}],u.checks.push({type:Q.TRUE}),s.checks.push({type:Q.PARENT,parent:u,child:l}),Ol(e,o,a),e.currentSubject=c,e.compoundCount++,l}var d=Sl(),f=Sl(),p=[{type:Q.PARENT,parent:d,child:f}];return d.checks=t.checks,t.checks=p,e.compoundCount++,f}},{name:`descendant`,separator:!0,regex:xl.descendant,populate:function(e,t){if(e.currentSubject==null){var n=Sl(),r=Sl(),i=e[e.length-1];return n.checks.push({type:Q.DESCENDANT,ancestor:i,descendant:r}),Ol(e,t,n),e.compoundCount++,r}if(e.currentSubject===t){var a=Sl(),o=e[e.length-1],s=Sl(),c=Sl(),l=Sl(),u=Sl();return a.checks.push({type:Q.COMPOUND_SPLIT,left:o,right:s,subject:c}),c.checks=t.checks,t.checks=[{type:Q.TRUE}],u.checks.push({type:Q.TRUE}),s.checks.push({type:Q.ANCESTOR,ancestor:u,descendant:l}),Ol(e,o,a),e.currentSubject=c,e.compoundCount++,l}var d=Sl(),f=Sl(),p=[{type:Q.ANCESTOR,ancestor:d,descendant:f}];return d.checks=t.checks,t.checks=p,e.compoundCount++,f}},{name:`subject`,modifier:!0,regex:xl.subject,populate:function(e,t){if(e.currentSubject!=null&&e.currentSubject!==t)return Rn("Redefinition of subject in selector `"+e.toString()+"`"),!1;e.currentSubject=t;var n=e[e.length-1].checks[0],r=n==null?null:n.type;r===Q.DIRECTED_EDGE?n.type=Q.NODE_TARGET:r===Q.UNDIRECTED_EDGE&&(n.type=Q.NODE_NEIGHBOR,n.node=n.nodes[1],n.neighbor=n.nodes[0],n.nodes=null)}}];kl.forEach(function(e){return e.regexObj=RegExp(`^`+e.regex)});var Al=function(e){for(var t,n,r,i=0;i<kl.length;i++){var a=kl[i],o=a.name,s=e.match(a.regexObj);if(s!=null){n=s,t=a,r=o;var c=s[0];e=e.substring(c.length);break}}return{expr:t,match:n,name:r,remaining:e}},jl=function(e){var t=e.match(/^\s+/);if(t){var n=t[0];e=e.substring(n.length)}return e},Ml={parse:function(e){var t=this,n=t.inputText=e,r=t[0]=Sl();for(t.length=1,n=jl(n);;){var i=Al(n);if(i.expr==null)return Rn("The selector `"+e+"`is invalid"),!1;var a=i.match.slice(1),o=i.expr.populate(t,r,a);if(o===!1)return!1;if(o!=null&&(r=o),n=i.remaining,n.match(/^\s*$/))break}var s=t[t.length-1];t.currentSubject!=null&&(s.subject=t.currentSubject),s.edgeCount=t.edgeCount,s.compoundCount=t.compoundCount;for(var c=0;c<t.length;c++){var l=t[c];if(l.compoundCount>0&&l.edgeCount>0)return Rn("The selector `"+e+"` is invalid because it uses both a compound selector and an edge selector"),!1;if(l.edgeCount>1)return Rn("The selector `"+e+"` is invalid because it uses multiple edge selectors"),!1;l.edgeCount===1&&Rn("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},toString:function(){if(this.toStringCache!=null)return this.toStringCache;for(var e=function(e){return e??``},t=function(t){return Y(t)?`"`+t+`"`:e(t)},n=function(e){return` `+e+` `},r=function(r,a){var o=r.type,s=r.value;switch(o){case Q.GROUP:var c=e(s);return c.substring(0,c.length-1);case Q.DATA_COMPARE:var l=r.field,u=r.operator;return`[`+l+n(e(u))+t(s)+`]`;case Q.DATA_BOOL:var d=r.operator,f=r.field;return`[`+e(d)+f+`]`;case Q.DATA_EXIST:return`[`+r.field+`]`;case Q.META_COMPARE:var p=r.operator;return`[[`+r.field+n(e(p))+t(s)+`]]`;case Q.STATE:return s;case Q.ID:return`#`+s;case Q.CLASS:return`.`+s;case Q.PARENT:case Q.CHILD:return i(r.parent,a)+n(`>`)+i(r.child,a);case Q.ANCESTOR:case Q.DESCENDANT:return i(r.ancestor,a)+` `+i(r.descendant,a);case Q.COMPOUND_SPLIT:var m=i(r.left,a),h=i(r.subject,a),g=i(r.right,a);return m+(m.length>0?` `:``)+h+g;case Q.TRUE:return``}},i=function(e,t){return e.checks.reduce(function(n,i,a){return n+(t===e&&a===0?`$`:``)+r(i,t)},``)},a=``,o=0;o<this.length;o++){var s=this[o];a+=i(s,s.subject),this.length>1&&o<this.length-1&&(a+=`, `)}return this.toStringCache=a,a}},Nl=function(e,t,n){var r,i=Y(e),a=X(e),o=Y(n),s,c,l=!1,u=!1,d=!1;switch(t.indexOf(`!`)>=0&&(t=t.replace(`!`,``),u=!0),t.indexOf(`@`)>=0&&(t=t.replace(`@`,``),l=!0),(i||o||l||t===`*=`||t===`^=`||t===`$=`)&&(s=!i&&!a?``:``+e,c=``+n),l&&(e=s=s.toLowerCase(),n=c=c.toLowerCase()),t){case`*=`:r=s.indexOf(c)>=0;break;case`$=`:r=s.indexOf(c,s.length-c.length)>=0;break;case`^=`:r=s.indexOf(c)===0;break;case`=`:r=e===n;break;case`>`:d=!0,r=e>n;break;case`>=`:d=!0,r=e>=n;break;case`<`:d=!0,r=e<n;break;case`<=`:d=!0,r=e<=n;break;default:r=!1}return u&&(e!=null||!d)&&(r=!r),r},Pl=function(e,t){switch(t){case`?`:return!!e;case`!`:return!e;case`^`:return e===void 0}},Fl=function(e){return e!==void 0},Il=function(e,t){return e.data(t)},Ll=function(e,t){return e[t]()},Rl=[],zl=function(e,t){return e.checks.every(function(e){return Rl[e.type](e,t)})};Rl[Q.GROUP]=function(e,t){var n=e.value;return n===`*`||n===t.group()},Rl[Q.STATE]=function(e,t){var n=e.value;return Tl(n,t)},Rl[Q.ID]=function(e,t){var n=e.value;return t.id()===n},Rl[Q.CLASS]=function(e,t){var n=e.value;return t.hasClass(n)},Rl[Q.META_COMPARE]=function(e,t){var n=e.field,r=e.operator,i=e.value;return Nl(Ll(t,n),r,i)},Rl[Q.DATA_COMPARE]=function(e,t){var n=e.field,r=e.operator,i=e.value;return Nl(Il(t,n),r,i)},Rl[Q.DATA_BOOL]=function(e,t){var n=e.field,r=e.operator;return Pl(Il(t,n),r)},Rl[Q.DATA_EXIST]=function(e,t){var n=e.field;return e.operator,Fl(Il(t,n))},Rl[Q.UNDIRECTED_EDGE]=function(e,t){var n=e.nodes[0],r=e.nodes[1],i=t.source(),a=t.target();return zl(n,i)&&zl(r,a)||zl(r,i)&&zl(n,a)},Rl[Q.NODE_NEIGHBOR]=function(e,t){return zl(e.node,t)&&t.neighborhood().some(function(t){return t.isNode()&&zl(e.neighbor,t)})},Rl[Q.DIRECTED_EDGE]=function(e,t){return zl(e.source,t.source())&&zl(e.target,t.target())},Rl[Q.NODE_SOURCE]=function(e,t){return zl(e.source,t)&&t.outgoers().some(function(t){return t.isNode()&&zl(e.target,t)})},Rl[Q.NODE_TARGET]=function(e,t){return zl(e.target,t)&&t.incomers().some(function(t){return t.isNode()&&zl(e.source,t)})},Rl[Q.CHILD]=function(e,t){return zl(e.child,t)&&zl(e.parent,t.parent())},Rl[Q.PARENT]=function(e,t){return zl(e.parent,t)&&t.children().some(function(t){return zl(e.child,t)})},Rl[Q.DESCENDANT]=function(e,t){return zl(e.descendant,t)&&t.ancestors().some(function(t){return zl(e.ancestor,t)})},Rl[Q.ANCESTOR]=function(e,t){return zl(e.ancestor,t)&&t.descendants().some(function(t){return zl(e.descendant,t)})},Rl[Q.COMPOUND_SPLIT]=function(e,t){return zl(e.subject,t)&&zl(e.left,t)&&zl(e.right,t)},Rl[Q.TRUE]=function(){return!0},Rl[Q.COLLECTION]=function(e,t){return e.value.has(t)},Rl[Q.FILTER]=function(e,t){var n=e.value;return n(t)};var Bl={matches:function(e){for(var t=this,n=0;n<t.length;n++){var r=t[n];if(zl(r,e))return!0}return!1},filter:function(e){var t=this;if(t.length===1&&t[0].checks.length===1&&t[0].checks[0].type===Q.ID)return e.getElementById(t[0].checks[0].value).collection();var n=function(e){for(var n=0;n<t.length;n++){var r=t[n];if(zl(r,e))return!0}return!1};return t.text()??(n=function(){return!0}),e.filter(n)}},Vl=function(e){this.inputText=e,this.currentSubject=null,this.compoundCount=0,this.edgeCount=0,this.length=0,e==null||Y(e)&&e.match(/^\s*$/)||(Fe(e)?this.addQuery({checks:[{type:Q.COLLECTION,value:e.collection()}]}):ke(e)?this.addQuery({checks:[{type:Q.FILTER,value:e}]}):Y(e)?this.parse(e)||(this.invalid=!0):In(`A selector must be created from a string; found `))},Hl=Vl.prototype;[Ml,Bl].forEach(function(e){return Z(Hl,e)}),Hl.text=function(){return this.inputText},Hl.size=function(){return this.length},Hl.eq=function(e){return this[e]},Hl.sameText=function(e){return!this.invalid&&!e.invalid&&this.text()===e.text()},Hl.addQuery=function(e){this[this.length++]=e},Hl.selector=Hl.toString;var Ul={allAre:function(e){var t=new Vl(e);return this.every(function(e){return t.matches(e)})},is:function(e){var t=new Vl(e);return this.some(function(e){return t.matches(e)})},some:function(e,t){for(var n=0;n<this.length;n++)if(t?e.apply(t,[this[n],n,this]):e(this[n],n,this))return!0;return!1},every:function(e,t){for(var n=0;n<this.length;n++)if(!(t?e.apply(t,[this[n],n,this]):e(this[n],n,this)))return!1;return!0},same:function(e){if(this===e)return!0;e=this.cy().collection(e);var t=this.length;return t===e.length?t===1?this[0]===e[0]:this.every(function(t){return e.hasElementWithId(t.id())}):!1},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(e){return t.hasElementWithId(e.id())})},contains:function(e){e=this.cy().collection(e);var t=this;return e.every(function(e){return t.hasElementWithId(e.id())})}};Ul.allAreNeighbours=Ul.allAreNeighbors,Ul.has=Ul.contains,Ul.equal=Ul.equals=Ul.same;var Wl=function(e,t){return function(n,r,i,a){var o=n,s=this,c;if(o==null?c=``:Fe(o)&&o.length===1&&(c=o.id()),s.length===1&&c){var l=s[0]._private,u=l.traversalCache=l.traversalCache||{},d=u[t]=u[t]||[],f=Sn(c);return d[f]||(d[f]=e.call(s,n,r,i,a))}return e.call(s,n,r,i,a)}},Gl={parent:function(e){var t=[];if(this.length===1){var n=this[0]._private.parent;if(n)return n}for(var r=0;r<this.length;r++){var i=this[r]._private.parent;i&&t.push(i)}return this.spawn(t,!0).filter(e)},parents:function(e){for(var t=[],n=this.parent();n.nonempty();){for(var r=0;r<n.length;r++){var i=n[r];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 r=this[n].parents();t||=r,t=t.intersect(r)}return t.filter(e)},orphans:function(e){return this.stdFilter(function(e){return e.isOrphan()}).filter(e)},nonorphans:function(e){return this.stdFilter(function(e){return e.isChild()}).filter(e)},children:Wl(function(e){for(var t=[],n=0;n<this.length;n++)for(var r=this[n]._private.children,i=0;i<r.length;i++)t.push(r[i]);return this.spawn(t,!0).filter(e)},`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(e){for(var r=0;r<e.length;r++){var i=e[r];t.push(i),i.children().nonempty()&&n(i.children())}}return n(this.children()),this.spawn(t,!0).filter(e)}};function Kl(e,t,n,r){for(var i=[],a=new er,o=e.cy().hasCompoundNodes(),s=0;s<e.length;s++){var c=e[s];n?i.push(c):o&&r(i,a,c)}for(;i.length>0;){var l=i.shift();t(l),a.add(l.id()),o&&r(i,a,l)}return e}function ql(e,t,n){if(n.isParent())for(var r=n._private.children,i=0;i<r.length;i++){var a=r[i];t.has(a.id())||e.push(a)}}Gl.forEachDown=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return Kl(this,e,t,ql)};function Jl(e,t,n){if(n.isChild()){var r=n._private.parent;t.has(r.id())||e.push(r)}}Gl.forEachUp=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return Kl(this,e,t,Jl)};function Yl(e,t,n){Jl(e,t,n),ql(e,t,n)}Gl.forEachUpAndDown=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return Kl(this,e,t,Yl)},Gl.ancestors=Gl.parents;var Xl=Zl={data:vl.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:vl.removeData({field:`data`,event:`data`,triggerFnName:`trigger`,triggerEvent:!0,immutableKeys:{id:!0,source:!0,target:!0,parent:!0},updateStyle:!0}),scratch:vl.data({field:`scratch`,bindingEvent:`scratch`,allowBinding:!0,allowSetting:!0,settingEvent:`scratch`,settingTriggersEvent:!0,triggerFnName:`trigger`,allowGetting:!0,updateStyle:!0}),removeScratch:vl.removeData({field:`scratch`,event:`scratch`,triggerFnName:`trigger`,triggerEvent:!0,updateStyle:!0}),rscratch:vl.data({field:`rscratch`,allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!0}),removeRscratch:vl.removeData({field:`rscratch`,triggerEvent:!1}),id:function(){var e=this[0];if(e)return e._private.data.id}},Zl;Xl.attr=Xl.data,Xl.removeAttr=Xl.removeData;var Ql=Zl,$l={};function eu(e){return function(t){var n=this;if(t===void 0&&(t=!0),n.length!==0&&n.isNode()&&!n.removed()){for(var r=0,i=n[0],a=i._private.edges,o=0;o<a.length;o++){var s=a[o];(t||!s.isLoop())&&(r+=e(i,s))}return r}}}Z($l,{degree:eu(function(e,t){return t.source().same(t.target())?2:1}),indegree:eu(function(e,t){return+!!t.target().same(e)}),outdegree:eu(function(e,t){return+!!t.source().same(e)})});function tu(e,t){return function(n){for(var r,i=this.nodes(),a=0;a<i.length;a++){var o=i[a][e](n);o!==void 0&&(r===void 0||t(o,r))&&(r=o)}return r}}Z($l,{minDegree:tu(`degree`,function(e,t){return e<t}),maxDegree:tu(`degree`,function(e,t){return e>t}),minIndegree:tu(`indegree`,function(e,t){return e<t}),maxIndegree:tu(`indegree`,function(e,t){return e>t}),minOutdegree:tu(`outdegree`,function(e,t){return e<t}),maxOutdegree:tu(`outdegree`,function(e,t){return e>t})}),Z($l,{totalDegree:function(e){for(var t=0,n=this.nodes(),r=0;r<n.length;r++)t+=n[r].degree(e);return t}});var nu,ru,iu=function(e,t,n){for(var r=0;r<e.length;r++){var i=e[r];if(!i.locked()){var a=i._private.position,o={x:t.x==null?0:t.x-a.x,y:t.y==null?0:t.y-a.y};i.isParent()&&(o.x!==0||o.y!==0)&&i.children().shift(o,n),i.dirtyBoundingBoxCache(),i.isNode()&&i.connectedEdges().dirtyBoundingBoxCache()}}},au={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){iu(e,t,!1)},onSet:function(e){e.dirtyCompoundBoundsCache()},canSet:function(e){return!e.locked()}};nu=ru={position:vl.data(au),silentPosition:vl.data(Z({},au,{allowBinding:!1,allowSetting:!0,settingTriggersEvent:!1,allowGetting:!1,beforeSet:function(e,t){iu(e,t,!0)},onSet:function(e){e.dirtyCompoundBoundsCache()}})),positions:function(e,t){if(je(e))t?this.silentPosition(e):this.position(e);else if(ke(e)){var n=e,r=this.cy();r.startBatch();for(var i=0;i<this.length;i++){var a=this[i],o=void 0;(o=n(a,i))&&(t?a.silentPosition(o):a.position(o))}r.endBatch()}return this},silentPositions:function(e){return this.positions(e,!0)},shift:function(e,t,n){var r;if(je(e)?(r={x:X(e.x)?e.x:0,y:X(e.y)?e.y:0},n=t):Y(e)&&X(t)&&(r={x:0,y:0},r[e]=t),r!=null){var i=this.cy();i.startBatch();for(var a=0;a<this.length;a++){var o=this[a];if(!(i.hasCompoundNodes()&&o.isChild()&&o.ancestors().anySame(this))){var s=o.position(),c={x:s.x+r.x,y:s.y+r.y};n?o.silentPosition(c):o.position(c)}}i.endBatch()}return this},silentShift:function(e,t){return je(e)?this.shift(e,!0):Y(e)&&X(t)&&this.shift(e,t,!0),this},renderedPosition:function(e,t){var n=this[0],r=this.cy(),i=r.zoom(),a=r.pan(),o=je(e)?e:void 0,s=o!==void 0||t!==void 0&&Y(e);if(n&&n.isNode()){if(s)for(var c=0;c<this.length;c++){var l=this[c];t===void 0?o!==void 0&&l.position(Dr(o,i,a)):l.position(e,(t-a[e])/i)}else return o=Er(n.position(),i,a),e===void 0?o:o[e]}else if(!s)return;return this},relativePosition:function(e,t){var n=this[0],r=this.cy(),i=je(e)?e:void 0,a=i!==void 0||t!==void 0&&Y(e),o=r.hasCompoundNodes();if(n&&n.isNode()){if(a)for(var s=0;s<this.length;s++){var c=this[s],l=o?c.parent():null,u=l&&l.length>0,d=u;u&&(l=l[0]);var f=d?l.position():{x:0,y:0};t===void 0?i!==void 0&&c.position({x:i.x+f.x,y:i.y+f.y}):c.position(e,t+f[e])}else{var p=n.position(),m=o?n.parent():null,h=m&&m.length>0,g=h;h&&(m=m[0]);var _=g?m.position():{x:0,y:0};return i={x:p.x-_.x,y:p.y-_.y},e===void 0?i:i[e]}}else if(!a)return;return this}},nu.modelPosition=nu.point=nu.position,nu.modelPositions=nu.points=nu.positions,nu.renderedPoint=nu.renderedPosition,nu.relativePoint=nu.relativePosition;var ou=ru,su=function(e){switch(e){case`left`:case`right-inside`:return`left`;case`right`:case`left-inside`:return`right`;default:return`center`}},cu=function(e){switch(e){case`top`:case`bottom-inside`:return`top`;case`bottom`:case`top-inside`:return`bottom`;default:return`center`}},lu=function(e){switch(e){case`left`:return`right`;case`right`:return`left`;case`left-inside`:return`left`;case`right-inside`:return`right`;default:return`center`}},uu=du={},du;du.renderedBoundingBox=function(e){var t=this.boundingBox(e),n=this.cy(),r=n.zoom(),i=n.pan(),a=t.x1*r+i.x,o=t.x2*r+i.x,s=t.y1*r+i.y,c=t.y2*r+i.y;return{x1:a,x2:o,y1:s,y2:c,w:o-a,h:c-s}};var fu=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`main`;if(!e||!e.cy().styleEnabled())return null;var n=t===`main`?void 0:t,r=e._private,i=r.labelPolygonCache,a=Du(e);if(!(i==null||i[t]==null||r.styleDirty||r.labelPolygonPosKey!==a))return i[t];e.recalculateRenderedStyle(),a=Du(e),(r.labelPolygonCache==null||r.labelPolygonPosKey!==a)&&(r.labelPolygonCache={},r.labelPolygonPosKey=a);var o=_u(e,n);return r.labelPolygonCache[t]=o,o};du.dirtyCompoundBoundsCache=function(){var e=arguments.length>0&&arguments[0]!==void 0&&arguments[0],t=this.cy();return!t.styleEnabled()||!t.hasCompoundNodes()||this.forEachUp(function(t){if(t.isParent()){var n=t._private;n.compoundBoundsClean=!1,n.bbCache=null,e||t.emitAndNotify(`bounds`)}}),this},du.updateCompoundBounds=function(){var e=arguments.length>0&&arguments[0]!==void 0&&arguments[0],t=this.cy();if(!t.styleEnabled()||!t.hasCompoundNodes()||!e&&t.batching())return this;function n(e){if(!e.isParent())return;var t=e._private,n=e.children(),r=e.pstyle(`compound-sizing-wrt-labels`).value===`include`,i={width:{val:e.pstyle(`min-width`).pfValue,left:e.pstyle(`min-width-bias-left`),right:e.pstyle(`min-width-bias-right`)},height:{val:e.pstyle(`min-height`).pfValue,top:e.pstyle(`min-height-bias-top`),bottom:e.pstyle(`min-height-bias-bottom`)}},a=n.boundingBox({includeLabels:r,includeOverlays:!1,useCache:!1}),o=t.position;(a.w===0||a.h===0)&&(a={w:e.pstyle(`width`).pfValue,h:e.pstyle(`height`).pfValue},a.x1=o.x-a.w/2,a.x2=o.x+a.w/2,a.y1=o.y-a.h/2,a.y2=o.y+a.h/2);function s(e,t,n){var r=0,i=0,a=t+n;return e>0&&a>0&&(r=t/a*e,i=n/a*e),{biasDiff:r,biasComplementDiff:i}}function c(e,t,n,r){if(n.units===`%`)switch(r){case`width`:return e>0?n.pfValue*e:0;case`height`:return t>0?n.pfValue*t:0;case`average`:return e>0&&t>0?n.pfValue*(e+t)/2:0;case`min`:return e>0&&t>0?e>t?n.pfValue*t:n.pfValue*e:0;case`max`:return e>0&&t>0?e>t?n.pfValue*e:n.pfValue*t:0;default:return 0}else if(n.units===`px`)return n.pfValue;else return 0}var l=i.width.left.value;i.width.left.units===`px`&&i.width.val>0&&(l=l*100/i.width.val);var u=i.width.right.value;i.width.right.units===`px`&&i.width.val>0&&(u=u*100/i.width.val);var d=i.height.top.value;i.height.top.units===`px`&&i.height.val>0&&(d=d*100/i.height.val);var f=i.height.bottom.value;i.height.bottom.units===`px`&&i.height.val>0&&(f=f*100/i.height.val);var p=s(i.width.val-a.w,l,u),m=p.biasDiff,h=p.biasComplementDiff,g=s(i.height.val-a.h,d,f),_=g.biasDiff,v=g.biasComplementDiff;t.autoPadding=c(a.w,a.h,e.pstyle(`padding`),e.pstyle(`padding-relative-to`).value),t.autoWidth=Math.max(a.w,i.width.val),o.x=(-m+a.x1+a.x2+h)/2,t.autoHeight=Math.max(a.h,i.height.val),o.y=(-_+a.y1+a.y2+v)/2}for(var r=0;r<this.length;r++){var i=this[r],a=i._private;(!a.compoundBoundsClean||e)&&(n(i),t.batching()||(a.compoundBoundsClean=!0))}return this};var pu=function(e){return e===1/0||e===-1/0?0:e},mu=function(e,t,n,r,i){r-t!==0&&i-n!==0&&t!=null&&n!=null&&r!=null&&i!=null&&(e.x1=t<e.x1?t:e.x1,e.x2=r>e.x2?r: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)},hu=function(e,t){return t==null?e:mu(e,t.x1,t.y1,t.x2,t.y2)},gu=function(e,t,n){return Yn(e,t,n)},_u=function(e,t){if(!e.cy().headless()){var n=e._private,r=t?t+`-`:``;if(!e.pstyle(r+`label`).strValue)return null;e.boundingBox({includeLabels:!0});var i=t||`main`,a=n.labelBounds[i];if(!a)return null;var o=gu(n.rscratch,`labelX`,t),s=gu(n.rscratch,`labelY`,t),c=gu(n.rscratch,`labelAngle`,t),l=e.pstyle(r+`text-margin-x`).pfValue,u=e.pstyle(r+`text-margin-y`).pfValue;return Li(a,o,s,c,l,u,0)}},vu=function(e,t,n){if(!t.cy().headless()){var r=t._private,i=r.rstyle,a=(i.arrowWidths!=null&&i.arrowWidths[n]!=null?i.arrowWidths[n]:i.arrowWidth)/2,o=t.pstyle(n+`-arrow-shape`).value,s,c;if(o!==`none`){n===`source`?(s=i.srcX,c=i.srcY):n===`target`?(s=i.tgtX,c=i.tgtY):(s=i.midX,c=i.midY);var l=r.arrowBounds=r.arrowBounds||{},u=l[n]=l[n]||{};u.x1=s-a,u.y1=c-a,u.x2=s+a,u.y2=c+a,u.w=u.x2-u.x1,u.h=u.y2-u.y1,Qr(u,1),mu(e,u.x1,u.y1,u.x2,u.y2)}}},yu=function(e,t,n){if(!t.cy().headless()){var r=n?n+`-`:``,i=t._private,a=i.rstyle;if(t.pstyle(r+`label`).strValue){var o=t.pstyle(`text-halign`),s=t.pstyle(`text-valign`),c=gu(a,`labelWidth`,n),l=gu(a,`labelHeight`,n),u=gu(a,`labelX`,n),d=gu(a,`labelY`,n),f=t.pstyle(r+`text-margin-x`).pfValue,p=t.pstyle(r+`text-margin-y`).pfValue,m=t.isEdge(),h=t.pstyle(r+`text-rotation`),g=t.pstyle(`text-outline-width`).pfValue,_=t.pstyle(`text-border-width`).pfValue/2,v=t.pstyle(`text-background-padding`).pfValue,y=2,b=l,x=c,S=x/2,C=b/2,w,T,E,D;if(m)w=u-S,T=u+S,E=d-C,D=d+C;else{switch(su(o.value)){case`left`:w=u-x,T=u;break;case`center`:w=u-S,T=u+S;break;case`right`:w=u,T=u+x}switch(cu(s.value)){case`top`:E=d-b,D=d;break;case`center`:E=d-C,D=d+C;break;case`bottom`:E=d,D=d+b}}var O=f-Math.max(g,_)-v-y,k=f+Math.max(g,_)+v+y,A=p-Math.max(g,_)-v-y,j=p+Math.max(g,_)+v+y;w+=O,T+=k,E+=A,D+=j;var M=n||`main`,N=i.labelBounds,P=N[M]=N[M]||{};P.x1=w,P.y1=E,P.x2=T,P.y2=D,P.w=T-w,P.h=D-E,P.leftPad=O,P.rightPad=k,P.topPad=A,P.botPad=j;var F=m&&h.strValue===`autorotate`,I=h.pfValue!=null&&h.pfValue!==0;if(F||I){var L=F?gu(i.rstyle,`labelAngle`,n):h.pfValue,R=Math.cos(L),z=Math.sin(L),B=(w+T)/2,V=(E+D)/2;if(!m){switch(su(o.value)){case`left`:B=T;break;case`right`:B=w}switch(cu(s.value)){case`top`:V=D;break;case`bottom`:V=E}}var H=function(e,t){return e-=B,t-=V,{x:e*R-t*z+B,y:e*z+t*R+V}},U=H(w,E),W=H(w,D),ee=H(T,E),G=H(T,D);w=Math.min(U.x,W.x,ee.x,G.x),T=Math.max(U.x,W.x,ee.x,G.x),E=Math.min(U.y,W.y,ee.y,G.y),D=Math.max(U.y,W.y,ee.y,G.y)}var K=M+`Rot`,q=N[K]=N[K]||{};q.x1=w,q.y1=E,q.x2=T,q.y2=D,q.w=T-w,q.h=D-E,mu(e,w,E,T,D),mu(i.labelBounds.all,w,E,T,D)}return e}},bu=function(e,t){if(!t.cy().headless()){var n=t.pstyle(`outline-opacity`).value,r=t.pstyle(`outline-width`).value+t.pstyle(`outline-offset`).value;xu(e,t,n,r,`outside`,r/2)}},xu=function(e,t,n,r,i,a){if(!(n===0||r<=0||i===`inside`)){var o=t.cy().renderer(),s=o.nodeShapes[o.getNodeShape(t)];if(s){var c=t.position(),l=c.x,u=c.y,d=t.width(),f=t.height();s.hasMiterBounds?(i===`center`&&(r/=2),hu(e,s.miterBounds(l,u,d,f,r))):a!=null&&a>0&&$r(e,[a,a,a,a])}}},Su=function(e,t){if(!t.cy().headless()){var n=t.pstyle(`border-opacity`).value,r=t.pstyle(`border-width`).pfValue,i=t.pstyle(`border-position`).value;xu(e,t,n,r,i)}},Cu=function(e,t){var n=e._private.cy,r=n.styleEnabled(),i=n.headless(),a=qr(),o=e._private,s=e.isNode(),c=e.isEdge(),l,u,d,f,p,m,h=o.rstyle,g=s&&r?e.pstyle(`bounds-expansion`).pfValue:[0],_=function(e){return e.pstyle(`display`).value!==`none`},v=!r||_(e)&&(!c||_(e.source())&&_(e.target()));if(v){var y=0,b=0;r&&t.includeOverlays&&(y=e.pstyle(`overlay-opacity`).value,y!==0&&(b=e.pstyle(`overlay-padding`).value));var x=0,S=0;r&&t.includeUnderlays&&(x=e.pstyle(`underlay-opacity`).value,x!==0&&(S=e.pstyle(`underlay-padding`).value));var C=Math.max(b,S),w=0,T=0;if(r&&(w=e.pstyle(`width`).pfValue,T=w/2),s&&t.includeNodes){var E=e.position();p=E.x,m=E.y;var D=e.outerWidth()/2,O=e.outerHeight()/2;l=p-D,u=p+D,d=m-O,f=m+O,mu(a,l,d,u,f),r&&bu(a,e),r&&t.includeOutlines&&!i&&bu(a,e),r&&Su(a,e)}else if(c&&t.includeEdges){if(r&&!i){var k=e.pstyle(`curve-style`).strValue;if(l=Math.min(h.srcX,h.midX,h.tgtX),u=Math.max(h.srcX,h.midX,h.tgtX),d=Math.min(h.srcY,h.midY,h.tgtY),f=Math.max(h.srcY,h.midY,h.tgtY),l-=T,u+=T,d-=T,f+=T,mu(a,l,d,u,f),k===`haystack`){var A=h.haystackPts;if(A&&A.length===2){if(l=A[0].x,d=A[0].y,u=A[1].x,f=A[1].y,l>u){var j=l;l=u,u=j}if(d>f){var M=d;d=f,f=M}mu(a,l-T,d-T,u+T,f+T)}}else if(k===`bezier`||k===`unbundled-bezier`||Ze(k,`segments`)||Ze(k,`taxi`)){var N;switch(k){case`bezier`:case`unbundled-bezier`:N=h.bezierPts;break;case`segments`:case`taxi`:case`round-segments`:case`round-taxi`:N=h.linePts}if(N!=null)for(var P=0;P<N.length;P++){var F=N[P];l=F.x-T,u=F.x+T,d=F.y-T,f=F.y+T,mu(a,l,d,u,f)}}}else{var I=e.source().position(),L=e.target().position();if(l=I.x,u=L.x,d=I.y,f=L.y,l>u){var R=l;l=u,u=R}if(d>f){var z=d;d=f,f=z}l-=T,u+=T,d-=T,f+=T,mu(a,l,d,u,f)}}if(r&&t.includeEdges&&c&&(vu(a,e,`mid-source`),vu(a,e,`mid-target`),vu(a,e,`source`),vu(a,e,`target`)),r&&e.pstyle(`ghost`).value===`yes`){var B=e.pstyle(`ghost-offset-x`).pfValue,V=e.pstyle(`ghost-offset-y`).pfValue;mu(a,a.x1+B,a.y1+V,a.x2+B,a.y2+V)}var H=o.bodyBounds=o.bodyBounds||{};ei(H,a),$r(H,g),Qr(H,1),r&&(l=a.x1,u=a.x2,d=a.y1,f=a.y2,mu(a,l-C,d-C,u+C,f+C));var U=o.overlayBounds=o.overlayBounds||{};ei(U,a),$r(U,g),Qr(U,1);var W=o.labelBounds=o.labelBounds||{};W.all==null?W.all=qr():Yr(W.all),r&&t.includeLabels&&(t.includeMainLabels&&yu(a,e,null),c&&(t.includeSourceLabels&&yu(a,e,`source`),t.includeTargetLabels&&yu(a,e,`target`)))}return a.x1=pu(a.x1),a.y1=pu(a.y1),a.x2=pu(a.x2),a.y2=pu(a.y2),a.w=pu(a.x2-a.x1),a.h=pu(a.y2-a.y1),a.w>0&&a.h>0&&v&&($r(a,g),Qr(a,1)),a},wu=function(e){var t=0,n=function(e){return+!!e<<t++},r=0;return r+=n(e.incudeNodes),r+=n(e.includeEdges),r+=n(e.includeLabels),r+=n(e.includeMainLabels),r+=n(e.includeSourceLabels),r+=n(e.includeTargetLabels),r+=n(e.includeOverlays),r+=n(e.includeOutlines),r},Tu=function(e){var t=function(e){return Math.round(e)};if(e.isEdge()){var n=e.source().position(),r=e.target().position();return xn([t(n.x),t(n.y),t(r.x),t(r.y)])}var i=e.position();return xn([t(i.x),t(i.y)])},Eu=function(e,t){var n=e._private,r,i=e.isEdge(),a=(t==null?ku:wu(t))===ku;if(n.bbCache==null?(r=Cu(e,Ou),n.bbCache=r,n.bbCachePosKey=Tu(e)):r=n.bbCache,!a){var o=e.isNode();r=qr(),(t.includeNodes&&o||t.includeEdges&&!o)&&(t.includeOverlays?hu(r,n.overlayBounds):hu(r,n.bodyBounds)),t.includeLabels&&(t.includeMainLabels&&(!i||t.includeSourceLabels&&t.includeTargetLabels)?hu(r,n.labelBounds.all):(t.includeMainLabels&&hu(r,n.labelBounds.mainRot),t.includeSourceLabels&&hu(r,n.labelBounds.sourceRot),t.includeTargetLabels&&hu(r,n.labelBounds.targetRot))),r.w=r.x2-r.x1,r.h=r.y2-r.y1}return r},Du=function(e){var t=e.pstyle(`text-rotation`).pfValue||0;if(e.isEdge()){var n=e.source().position(),r=e.target().position();return xn([Math.round(n.x),Math.round(n.y),Math.round(r.x),Math.round(r.y),Math.round(t*1e3)])}var i=e.position();return xn([Math.round(i.x),Math.round(i.y),Math.round(t*1e3)])},Ou={includeNodes:!0,includeEdges:!0,includeLabels:!0,includeMainLabels:!0,includeSourceLabels:!0,includeTargetLabels:!0,includeOverlays:!0,includeUnderlays:!0,includeOutlines:!0,useCache:!0},ku=wu(Ou),Au=Gn(Ou);du.boundingBox=function(e){var t,n=e===void 0||e.useCache===void 0||e.useCache===!0,r=Ke(function(e){var t=e._private;return t.bbCache==null||t.styleDirty||t.bbCachePosKey!==Tu(e)},function(e){return e.id()});if(n&&this.length===1&&!r(this[0]))e=e===void 0?Ou:Au(e),t=Eu(this[0],e);else{t=qr(),e||=Ou;var i=Au(e),a=this,o=a.cy().styleEnabled();this.edges().forEach(r),this.nodes().forEach(r),o&&this.recalculateRenderedStyle(n),this.updateCompoundBounds(!n);for(var s=0;s<a.length;s++){var c=a[s];r(c)&&c.dirtyBoundingBoxCache(),hu(t,Eu(c,i))}}return t.x1=pu(t.x1),t.y1=pu(t.y1),t.x2=pu(t.x2),t.y2=pu(t.y2),t.w=pu(t.x2-t.x1),t.h=pu(t.y2-t.y1),t},du.dirtyBoundingBoxCache=function(){for(var e=0;e<this.length;e++){var t=this[e]._private;t.bbCache=null,t.bbCachePosKey=null,t.bodyBounds=null,t.overlayBounds=null,t.labelBounds.all=null,t.labelBounds.source=null,t.labelBounds.target=null,t.labelBounds.main=null,t.labelBounds.sourceRot=null,t.labelBounds.targetRot=null,t.labelBounds.mainRot=null,t.arrowBounds.source=null,t.arrowBounds.target=null,t.arrowBounds[`mid-source`]=null,t.arrowBounds[`mid-target`]=null,t.labelPolygonCache={},t.labelPolygonPosKey=null}return this.emitAndNotify(`bounds`),this},du.boundingBoxAt=function(e){var t=this.nodes(),n=this.cy(),r=n.hasCompoundNodes(),i=n.collection();if(r&&(i=t.filter(function(e){return e.isParent()}),t=t.not(i)),je(e)){var a=e;e=function(){return a}}var o=function(t,n){return t._private.bbAtOldPos=e(t,n)},s=function(e){return e._private.bbAtOldPos};n.startBatch(),t.forEach(o).silentPositions(e),r&&(i.dirtyCompoundBoundsCache(),i.dirtyBoundingBoxCache(),i.updateCompoundBounds(!0));var c=Jr(this.boundingBox({useCache:!1}));return t.silentPositions(s),r&&(i.dirtyCompoundBoundsCache(),i.dirtyBoundingBoxCache(),i.updateCompoundBounds(!0)),n.endBatch(),c},uu.boundingbox=uu.bb=uu.boundingBox,uu.renderedBoundingbox=uu.renderedBoundingBox;var ju=du,Mu=Nu={},Nu,Pu=function(e){e.uppercaseName=Xe(e.name),e.autoName=`auto`+e.uppercaseName,e.labelName=`label`+e.uppercaseName,e.outerName=`outer`+e.uppercaseName,e.uppercaseOuterName=Xe(e.outerName),Mu[e.name]=function(){var t=this[0],n=t._private,r=n.cy._private.styleEnabled;if(t){if(r){if(t.isParent())return t.updateCompoundBounds(),n[e.autoName]||0;var i=t.pstyle(e.name);switch(i.strValue){case`label`:return t.recalculateRenderedStyle(),n.rstyle[e.labelName]||0;default:return i.pfValue}}else return 1}},Mu[`outer`+e.uppercaseName]=function(){var t=this[0],n=t._private.cy._private.styleEnabled;if(t){if(n){var r=t[e.name](),i=t.pstyle(`border-position`).value,a=i===`center`?t.pstyle(`border-width`).pfValue:i===`outside`?2*t.pstyle(`border-width`).pfValue:0,o=2*t.padding();return r+a+o}return 1}},Mu[`rendered`+e.uppercaseName]=function(){var t=this[0];if(t)return t[e.name]()*this.cy().zoom()},Mu[`rendered`+e.uppercaseOuterName]=function(){var t=this[0];if(t)return t[e.outerName]()*this.cy().zoom()}};Pu({name:`width`}),Pu({name:`height`}),Nu.padding=function(){var e=this[0],t=e._private;return e.isParent()?(e.updateCompoundBounds(),t.autoPadding===void 0?e.pstyle(`padding`).pfValue:t.autoPadding):e.pstyle(`padding`).pfValue},Nu.paddedHeight=function(){var e=this[0];return e.height()+2*e.padding()},Nu.paddedWidth=function(){var e=this[0];return e.width()+2*e.padding()};var Fu=Nu,Iu=function(e,t){if(e.isEdge()&&e.takesUpSpace())return t(e)},Lu=function(e,t){if(e.isEdge()&&e.takesUpSpace()){var n=e.cy();return Er(t(e),n.zoom(),n.pan())}},Ru=function(e,t){if(e.isEdge()&&e.takesUpSpace()){var n=e.cy(),r=n.pan(),i=n.zoom();return t(e).map(function(e){return Er(e,i,r)})}},zu={controlPoints:{get:function(e){return e.renderer().getControlPoints(e)},mult:!0},segmentPoints:{get:function(e){return e.renderer().getSegmentPoints(e)},mult:!0},sourceEndpoint:{get:function(e){return e.renderer().getSourceEndpoint(e)}},targetEndpoint:{get:function(e){return e.renderer().getTargetEndpoint(e)}},midpoint:{get:function(e){return e.renderer().getEdgeMidpoint(e)}}},Bu=function(e){return`rendered`+e[0].toUpperCase()+e.substr(1)},Vu=Z({},ou,ju,Fu,Object.keys(zu).reduce(function(e,t){var n=zu[t],r=Bu(t);return e[t]=function(){return Iu(this,n.get)},e[r]=n.mult?function(){return Ru(this,n.get)}:function(){return Lu(this,n.get)},e},{})),Hu=function(e,t){this.recycle(e,t)};function Uu(){return!1}function Wu(){return!0}Hu.prototype={instanceString:function(){return`event`},recycle:function(e,t){if(this.isImmediatePropagationStopped=this.isPropagationStopped=this.isDefaultPrevented=Uu,e!=null&&e.preventDefault?(this.type=e.type,this.isDefaultPrevented=e.defaultPrevented?Wu:Uu):e!=null&&e.type?t=e:this.type=e,t!=null&&(this.originalEvent=t.originalEvent,this.type=t.type==null?this.type:t.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,r=this.cy.zoom(),i=this.cy.pan();this.renderedPosition={x:n.x*r+i.x,y:n.y*r+i.y}}this.timeStamp=e&&e.timeStamp||Date.now()},preventDefault:function(){this.isDefaultPrevented=Wu;var e=this.originalEvent;e&&e.preventDefault&&e.preventDefault()},stopPropagation:function(){this.isPropagationStopped=Wu;var e=this.originalEvent;e&&e.stopPropagation&&e.stopPropagation()},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=Wu,this.stopPropagation()},isDefaultPrevented:Uu,isPropagationStopped:Uu,isImmediatePropagationStopped:Uu};var Gu=/^([^.]+)(\.(?:[^.]+))?$/,Ku=`.*`,qu={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},Ju=Object.keys(qu),Yu={};function Xu(){for(var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Yu,t=arguments.length>1?arguments[1]:void 0,n=0;n<Ju.length;n++){var r=Ju[n];this[r]=e[r]||qu[r]}this.context=t||this.context,this.listeners=[],this.emitting=0}var Zu=Xu.prototype,Qu=function(e,t,n,r,i,a,o){ke(r)&&(i=r,r=null),o&&(a=a==null?o:Z({},a,o));for(var s=Ae(n)?n:n.split(/\s+/),c=0;c<s.length;c++){var l=s[c];if(!Ve(l)){var u=l.match(Gu);if(u){var d=u[1];if(t(e,l,d,u[2]?u[2]:null,r,i,a)===!1)break}}}},$u=function(e,t){return e.addEventFields(e.context,t),new Hu(t.type,t)},ed=function(e,t,n){if(Be(n))t(e,n);else if(je(n))t(e,$u(e,n));else for(var r=Ae(n)?n:n.split(/\s+/),i=0;i<r.length;i++){var a=r[i];if(!Ve(a)){var o=a.match(Gu);if(o){var s=o[1];t(e,$u(e,{type:s,namespace:o[2]?o[2]:null,target:e.context}))}}}};Zu.on=Zu.addListener=function(e,t,n,r,i){return Qu(this,function(e,t,n,r,i,a,o){ke(a)&&e.listeners.push({event:t,callback:a,type:n,namespace:r,qualifier:i,conf:o})},e,t,n,r,i),this},Zu.one=function(e,t,n,r){return this.on(e,t,n,r,{one:!0})},Zu.removeListener=Zu.off=function(e,t,n,r){var i=this;this.emitting!==0&&(this.listeners=Vn(this.listeners));for(var a=this.listeners,o=function(o){var s=a[o];Qu(i,function(t,n,r,i,c,l){if((s.type===r||e===`*`)&&(!i&&s.namespace!==`.*`||s.namespace===i)&&(!c||t.qualifierCompare(s.qualifier,c))&&(!l||s.callback===l))return a.splice(o,1),!1},e,t,n,r)},s=a.length-1;s>=0;s--)o(s);return this},Zu.removeAllListeners=function(){return this.removeListener(`*`)},Zu.emit=Zu.trigger=function(e,t,n){var r=this.listeners,i=r.length;return this.emitting++,Ae(t)||(t=[t]),ed(this,function(e,a){n!=null&&(r=[{event:a.event,type:a.type,namespace:a.namespace,callback:n}],i=r.length);for(var o=function(){var n=r[s];if(n.type===a.type&&(!n.namespace||n.namespace===a.namespace||n.namespace===Ku)&&e.eventMatches(e.context,n,a)){var i=[a];t!=null&&Jn(i,t),e.beforeEmit(e.context,n,a),n.conf&&n.conf.one&&(e.listeners=e.listeners.filter(function(e){return e!==n}));var o=e.callbackContext(e.context,n,a),c=n.callback.apply(o,i);e.afterEmit(e.context,n,a),c===!1&&(a.stopPropagation(),a.preventDefault())}},s=0;s<i;s++)o();e.bubble(e.context)&&!a.isPropagationStopped()&&e.parent(e.context).emit(a,t)},e),this.emitting--,this};var td={qualifierCompare:function(e,t){return e==null||t==null?e==null&&t==null:e.sameText(t)},eventMatches:function(e,t,n){var r=t.qualifier;return r==null||e!==n.target&&Ie(n.target)&&r.matches(n.target)},addEventFields:function(e,t){t.cy=e.cy(),t.target=e},callbackContext:function(e,t,n){return t.qualifier==null?e:n.target},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()}},nd=function(e){return Y(e)?new Vl(e):e},rd={createEmitter:function(){for(var e=0;e<this.length;e++){var t=this[e],n=t._private;n.emitter||=new Xu(td,t)}return this},emitter:function(){return this._private.emitter},on:function(e,t,n){for(var r=nd(t),i=0;i<this.length;i++)this[i].emitter().on(e,r,n);return this},removeListener:function(e,t,n){for(var r=nd(t),i=0;i<this.length;i++)this[i].emitter().removeListener(e,r,n);return this},removeAllListeners:function(){for(var e=0;e<this.length;e++)this[e].emitter().removeAllListeners();return this},one:function(e,t,n){for(var r=nd(t),i=0;i<this.length;i++)this[i].emitter().one(e,r,n);return this},once:function(e,t,n){for(var r=nd(t),i=0;i<this.length;i++)this[i].emitter().on(e,r,n,{once:!0,onceCollection:this})},emit:function(e,t){for(var n=0;n<this.length;n++)this[n].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}};vl.eventAliasesOn(rd);var id={nodes:function(e){return this.filter(function(e){return e.isNode()}).filter(e)},edges:function(e){return this.filter(function(e){return e.isEdge()}).filter(e)},byGroup:function(){for(var e=this.spawn(),t=this.spawn(),n=0;n<this.length;n++){var r=this[n];r.isNode()?e.push(r):t.push(r)}return{nodes:e,edges:t}},filter:function(e,t){if(e===void 0)return this;if(Y(e)||Fe(e))return new Vl(e).filter(this);if(ke(e)){for(var n=this.spawn(),r=this,i=0;i<r.length;i++){var a=r[i];(t?e.apply(t,[a,i,r]):e(a,i,r))&&n.push(a)}return n}return this.spawn()},not:function(e){if(e){Y(e)&&(e=this.filter(e));for(var t=this.spawn(),n=0;n<this.length;n++){var r=this[n];e.has(r)||t.push(r)}return t}return this},absoluteComplement:function(){return this.cy().mutableElements().not(this)},intersect:function(e){if(Y(e)){var t=e;return this.filter(t)}for(var n=this.spawn(),r=this,i=e,a=this.length<e.length,o=a?r:i,s=a?i:r,c=0;c<o.length;c++){var l=o[c];s.has(l)&&n.push(l)}return n},xor:function(e){var t=this._private.cy;Y(e)&&(e=t.$(e));var n=this.spawn(),r=this,i=e,a=function(e,t){for(var r=0;r<e.length;r++){var i=e[r],a=i._private.data.id;t.hasElementWithId(a)||n.push(i)}};return a(r,i),a(i,r),n},diff:function(e){var t=this._private.cy;Y(e)&&(e=t.$(e));var n=this.spawn(),r=this.spawn(),i=this.spawn(),a=this,o=e,s=function(e,t,n){for(var r=0;r<e.length;r++){var a=e[r],o=a._private.data.id;t.hasElementWithId(o)?i.merge(a):n.push(a)}};return s(a,o,n),s(o,a,r),{left:n,right:r,both:i}},add:function(e){var t=this._private.cy;if(!e)return this;if(Y(e)){var n=e;e=t.mutableElements().filter(n)}for(var r=this.spawnSelf(),i=0;i<e.length;i++){var a=e[i];this.has(a)||r.push(a)}return r},merge:function(e){var t=this._private,n=t.cy;if(!e)return this;if(e&&Y(e)){var r=e;e=n.mutableElements().filter(r)}for(var i=t.map,a=0;a<e.length;a++){var o=e[a],s=o._private.data.id;if(!i.has(s)){var c=this.length++;this[c]=o,i.set(s,{ele:o,index:c})}}return this},unmergeAt:function(e){var t=this[e].id(),n=this._private.map;this[e]=void 0,n.delete(t);var r=e===this.length-1;if(this.length>1&&!r){var i=this.length-1,a=this[i],o=a._private.data.id;this[i]=void 0,this[e]=a,n.set(o,{ele:a,index:e})}return this.length--,this},unmergeOne:function(e){e=e[0];var t=this._private,n=e._private.data.id,r=t.map.get(n);if(!r)return this;var i=r.index;return this.unmergeAt(i),this},unmerge:function(e){var t=this._private.cy;if(!e)return this;if(e&&Y(e)){var n=e;e=t.mutableElements().filter(n)}for(var r=0;r<e.length;r++)this.unmergeOne(e[r]);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=[],r=this,i=0;i<r.length;i++){var a=r[i],o=t?e.apply(t,[a,i,r]):e(a,i,r);n.push(o)}return n},reduce:function(e,t){for(var n=t,r=this,i=0;i<r.length;i++)n=e(n,r[i],i,r);return n},max:function(e,t){for(var n=-1/0,r,i=this,a=0;a<i.length;a++){var o=i[a],s=t?e.apply(t,[o,a,i]):e(o,a,i);s>n&&(n=s,r=o)}return{value:n,ele:r}},min:function(e,t){for(var n=1/0,r,i=this,a=0;a<i.length;a++){var o=i[a],s=t?e.apply(t,[o,a,i]):e(o,a,i);s<n&&(n=s,r=o)}return{value:n,ele:r}},withinBox:function(e){var t=this.cy(),n=t.renderer();t.styleEnabled()&&this.recalculateRenderedStyle();var r=e.x2==null?e.x1+e.w:e.x2,i=e.y2==null?e.y1+e.h:e.y2,a=qr({x1:Math.min(e.x1,r),x2:Math.max(e.x1,r),y1:Math.min(e.y1,i),y2:Math.max(e.y1,i)}),o=n.getAllInBox(a.x1,a.y1,a.x2,a.y2),s=this;return this.spawn(o.filter(function(e){return s.has(e)}))},hit:function(e,t){var n=this.cy(),r=n.renderer();return n.styleEnabled()&&this.recalculateRenderedStyle(),this.spawn(r.hitTestAt(e.x,e.y,this,t))},polygonIntersection:function(e){var t=this;t.cy().styleEnabled()&&this.recalculateRenderedStyle();for(var n=[],r=0;r<t.length;r++){var i=t[r];if(i.boundingBox(),i.isEdge()){var a=i._private.rscratch,o=i._private.rstyle,s=o.bezierPts||o.linePts||o.haystackPts;if(o.bezierPts&&a.allpts&&a.allpts.length>=6){var c=(a.allpts.length-2)/4,l=o.bezierPts.length/c;s=[{x:a.allpts[0],y:a.allpts[1]}];for(var u=0;u<c;u++){for(var d=0;d<l;d++)s.push(o.bezierPts[u*l+d]);s.push({x:a.allpts[u*4+4],y:a.allpts[u*4+5]})}}if((!s||s.length<2)&&a.startX!=null&&a.startY!=null&&a.endX!=null&&a.endY!=null&&(s=[{x:a.startX,y:a.startY},{x:a.endX,y:a.endY}]),s&&s.length>1){for(var f=!1,p=0;p<s.length-1&&!f;p++)Vi(s[p],s[p+1],e)&&(n.push(i),f=!0);if(f)continue}}else{var m=i._private.bodyBounds;if(m&&Ri([{x:m.x1,y:m.y1},{x:m.x2,y:m.y1},{x:m.x2,y:m.y2},{x:m.x1,y:m.y2}],e)){n.push(i);continue}}for(var h=i.isEdge()?[`main`,`source`,`target`]:[`main`],g=!1,_=0;_<h.length&&!g;_++){var v=fu(i,h[_]);v&&v.length&&Ri(v,e)&&(n.push(i),g=!0)}}return this.spawn(n)}},ad=id;ad.u=ad[`|`]=ad[`+`]=ad.union=ad.or=ad.add,ad[`\\`]=ad[`!`]=ad[`-`]=ad.difference=ad.relativeComplement=ad.subtract=ad.not,ad.n=ad[`&`]=ad[`.`]=ad.and=ad.intersection=ad.intersect,ad[`^`]=ad[`(+)`]=ad[`(-)`]=ad.symmetricDifference=ad.symdiff=ad.xor,ad.fnFilter=ad.filterFn=ad.stdFilter=ad.filter,ad.complement=ad.abscomp=ad.absoluteComplement;var od={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}},sd=function(e,t){var n=e.cy().hasCompoundNodes();function r(e){var t=e.pstyle(`z-compound-depth`);return t.value===`auto`?n?e.zDepth():0:t.value===`bottom`?-1:t.value===`top`?jn:0}var i=r(e)-r(t);if(i!==0)return i;function a(e){return e.pstyle(`z-index-compare`).value===`auto`?+!!e.isNode():0}var o=a(e)-a(t);if(o!==0)return o;var s=e.pstyle(`z-index`).value-t.pstyle(`z-index`).value;return s===0?e.poolIndex()-t.poolIndex():s},cd={forEach:function(e,t){if(ke(e))for(var n=this.length,r=0;r<n;r++){var i=this[r];if((t?e.apply(t,[i,r,this]):e(i,r,this))===!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=[],r=this.length;t??=r,e??=0,e<0&&(e=r+e),t<0&&(t=r+t);for(var i=e;i>=0&&i<t&&i<r;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(!ke(e))return this;var t=this.toArray().sort(e);return this.spawn(t)},sortByZIndex:function(){return this.sort(sd)},zDepth:function(){var e=this[0];if(e){var t=e._private;if(t.group===`nodes`){var n=t.data.parent?e.parents().size():0;return e.isParent()?n:jn-1}var r=t.source,i=t.target,a=r.zDepth(),o=i.zDepth();return Math.max(a,o,0)}}};cd.each=cd.forEach,(function(){var e=`undefined`;(typeof Symbol>`u`?`undefined`:be(Symbol))!=e&&be(Symbol.iterator)!=e&&(cd[Symbol.iterator]=function(){var e=this,t={value:void 0,done:!1},n=0,r=this.length;return de({next:function(){return n<r?t.value=e[n++]:(t.value=void 0,t.done=!0),t}},Symbol.iterator,function(){return this})})})();var ld=Gn({nodeDimensionsIncludeLabels:!1}),ud={layoutDimensions:function(e){e=ld(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 r=this.nodes().filter(function(e){return!e.isParent()}),i=this.cy(),a=t.eles,o=function(e){return e.id()},s=Ke(n,o);e.emit({type:`layoutstart`,layout:e}),e.animations=[];var c=function(e,t,n){var r={x:t.x1+t.w/2,y:t.y1+t.h/2},i={x:(n.x-r.x)*e,y:(n.y-r.y)*e};return{x:r.x+i.x,y:r.y+i.y}},l=t.spacingFactor&&t.spacingFactor!==1,u=function(){if(!l)return null;for(var e=qr(),t=0;t<r.length;t++){var n=r[t],i=s(n,t);Zr(e,i.x,i.y)}return e}(),d=Ke(function(e,n){var r=s(e,n);return l&&(r=c(Math.abs(t.spacingFactor),u,r)),t.transform!=null&&(r=t.transform(e,r)),r},o);if(t.animate){for(var f=0;f<r.length;f++){var p=r[f],m=d(p,f);if(t.animateFilter==null||t.animateFilter(p,f)){var h=p.animation({position:m,duration:t.animationDuration,easing:t.animationEasing});e.animations.push(h)}else p.position(m)}if(t.fit){var g=i.animation({fit:{boundingBox:a.boundingBoxAt(d),padding:t.padding},duration:t.animationDuration,easing:t.animationEasing});e.animations.push(g)}else if(t.zoom!==void 0&&t.pan!==void 0){var _=i.animation({zoom:t.zoom,pan:t.pan,duration:t.animationDuration,easing:t.animationEasing});e.animations.push(_)}e.animations.forEach(function(e){return e.play()}),e.one(`layoutready`,t.ready),e.emit({type:`layoutready`,layout:e}),vo.all(e.animations.map(function(e){return e.promise()})).then(function(){e.one(`layoutstop`,t.stop),e.emit({type:`layoutstop`,layout:e})})}else r.positions(d),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){return this.cy().makeLayout(Z({},e,{eles:this}))}};ud.createLayout=ud.makeLayout=ud.layout;function dd(e,t,n){var r=n._private,i=r.styleCache=r.styleCache||[],a;return(a=i[e])??(a=i[e]=t(n)),a}function fd(e,t){return e=Sn(e),function(n){return dd(e,t,n)}}function pd(e,t){e=Sn(e);var n=function(e){return t.call(e)};return function(){var t=this[0];if(t)return dd(e,n,t)}}var md={recalculateRenderedStyle:function(e){var t=this.cy(),n=t.renderer(),r=t.styleEnabled();return n&&r&&n.recalculateRenderedStyle(this,e),this},dirtyStyleCache:function(){var e=this.cy(),t=function(e){return e._private.styleCache=null};if(e.hasCompoundNodes()){var n=this.spawnSelf().merge(this.descendants()).merge(this.parents());n.merge(n.connectedEdges()),n.forEach(t)}else this.forEach(function(e){t(e),e.connectedEdges().forEach(t)});return this},updateStyle:function(e){var t=this._private.cy;if(!t.styleEnabled())return this;if(t.batching())return t._private.batchStyleEles.merge(this),this;var n=t.hasCompoundNodes(),r=this;e=!!(e||e===void 0),n&&(r=this.spawnSelf().merge(this.descendants()).merge(this.parents()));var i=r;return e?i.emitAndNotify(`style`):i.emit(`style`),r.forEach(function(e){return e._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],r=n.cy();if(r.styleEnabled()&&n)return n._private.styleDirty&&(n._private.styleDirty=!1,r.style().apply(n)),n._private.style[e]??(t?r.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.value:n.pfValue}},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 r=!1,i=n.style();if(je(e)){var a=e;i.applyBypass(this,a,r),this.emitAndNotify(`style`)}else if(Y(e)){if(t===void 0){var o=this[0];return o?i.getStylePropertyValue(o,e):void 0}i.applyBypass(this,e,t,r),this.emitAndNotify(`style`)}else if(e===void 0){var s=this[0];return s?i.getRawStyle(s):void 0}return this},removeStyle:function(e){var t=this.cy();if(!t.styleEnabled())return this;var n=!1,r=t.style(),i=this;if(e===void 0)for(var a=0;a<i.length;a++){var o=i[a];r.removeAllBypasses(o,n)}else{e=e.split(/\s+/);for(var s=0;s<i.length;s++){var c=i[s];r.removeBypasses(c,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 r=n._private,i=n.pstyle(`opacity`).value;if(!t)return i;var a=r.data.parent?n.parents():null;if(a)for(var o=0;o<a.length;o++)i=a[o].pstyle(`opacity`).value*i;return i}},transparent:function(){if(!this.cy().styleEnabled())return!1;var e=this[0],t=e.cy().hasCompoundNodes();if(e)return t?e.effectiveOpacity()===0:e.pstyle(`opacity`).value===0},backgrounding:function(){return this.cy().styleEnabled()?!!this[0]._private.backgrounding:!1}};function hd(e,t){var n=e._private.data.parent?e.parents():null;if(n)for(var r=0;r<n.length;r++){var i=n[r];if(!t(i))return!1}return!0}function gd(e){var t=e.ok,n=e.edgeOkViaNode||e.ok,r=e.parentOk||e.ok;return function(){var e=this.cy();if(!e.styleEnabled())return!0;var i=this[0],a=e.hasCompoundNodes();if(i){var o=i._private;if(!t(i))return!1;if(i.isNode())return!a||hd(i,r);var s=o.source,c=o.target;return n(s)&&(!a||hd(s,n))&&(s===c||n(c)&&(!a||hd(c,n)))}}}var _d=fd(`eleTakesUpSpace`,function(e){return e.pstyle(`display`).value===`element`&&e.width()!==0&&(!e.isNode()||e.height()!==0)});md.takesUpSpace=pd(`takesUpSpace`,gd({ok:_d})),md.interactive=pd(`interactive`,gd({ok:fd(`eleInteractive`,function(e){return e.pstyle(`events`).value===`yes`&&e.pstyle(`visibility`).value===`visible`&&_d(e)}),parentOk:fd(`parentInteractive`,function(e){return e.pstyle(`visibility`).value===`visible`&&_d(e)}),edgeOkViaNode:_d})),md.noninteractive=function(){var e=this[0];if(e)return!e.interactive()},md.visible=pd(`visible`,gd({ok:fd(`eleVisible`,function(e){return e.pstyle(`visibility`).value===`visible`&&e.pstyle(`opacity`).pfValue!==0&&_d(e)}),edgeOkViaNode:_d})),md.hidden=function(){var e=this[0];if(e)return!e.visible()},md.isBundledBezier=pd(`isBundledBezier`,function(){return this.cy().styleEnabled()?!this.removed()&&this.pstyle(`curve-style`).value===`bezier`&&this.takesUpSpace():!1}),md.bypass=md.css=md.style,md.renderedCss=md.renderedStyle,md.removeBypass=md.removeCss=md.removeStyle,md.pstyle=md.parsedStyle;var vd={};function yd(e){return function(){var t=arguments,n=[];if(t.length===2){var r=t[0],i=t[1];this.on(e.event,r,i)}else if(t.length===1&&ke(t[0])){var a=t[0];this.on(e.event,a)}else if(t.length===0||t.length===1&&Ae(t[0])){for(var o=t.length===1?t[0]:null,s=0;s<this.length;s++){var c=this[s],l=!e.ableField||c._private[e.ableField],u=c._private[e.field]!=e.value;if(e.overrideAble){var d=e.overrideAble(c);if(d!==void 0&&(l=d,!d))return this}l&&(c._private[e.field]=e.value,u&&n.push(c))}var f=this.spawn(n);f.updateStyle(),f.emit(e.event),o&&f.emit(o)}return this}}function bd(e){vd[e.field]=function(){var t=this[0];if(t){if(e.overrideField){var n=e.overrideField(t);if(n!==void 0)return n}return t._private[e.field]}},vd[e.on]=yd({event:e.on,field:e.field,ableField:e.ableField,overrideAble:e.overrideAble,value:!0}),vd[e.off]=yd({event:e.off,field:e.field,ableField:e.ableField,overrideAble:e.overrideAble,value:!1})}bd({field:`locked`,overrideField:function(e){return e.cy().autolock()?!0:void 0},on:`lock`,off:`unlock`}),bd({field:`grabbable`,overrideField:function(e){return e.cy().autoungrabify()||e.pannable()?!1:void 0},on:`grabify`,off:`ungrabify`}),bd({field:`selected`,ableField:`selectable`,overrideAble:function(e){return!e.cy().autounselectify()&&void 0},on:`select`,off:`unselect`}),bd({field:`selectable`,overrideField:function(e){return!e.cy().autounselectify()&&void 0},on:`selectify`,off:`unselectify`}),vd.deselect=vd.unselect,vd.grabbed=function(){var e=this[0];if(e)return e._private.grabbed},bd({field:`active`,on:`activate`,off:`unactivate`}),bd({field:`pannable`,on:`panify`,off:`unpanify`}),vd.inactive=function(){var e=this[0];if(e)return!e._private.active};var xd={},Sd=function(e){return function(t){for(var n=this,r=[],i=0;i<n.length;i++){var a=n[i];if(a.isNode()){for(var o=!1,s=a.connectedEdges(),c=0;c<s.length;c++){var l=s[c],u=l.source(),d=l.target();if(e.noIncomingEdges&&d===a&&u!==a||e.noOutgoingEdges&&u===a&&d!==a){o=!0;break}}o||r.push(a)}}return this.spawn(r,!0).filter(t)}},Cd=function(e){return function(t){for(var n=this,r=[],i=0;i<n.length;i++){var a=n[i];if(a.isNode())for(var o=a.connectedEdges(),s=0;s<o.length;s++){var c=o[s],l=c.source(),u=c.target();e.outgoing&&l===a?(r.push(c),r.push(u)):e.incoming&&u===a&&(r.push(c),r.push(l))}}return this.spawn(r,!0).filter(t)}},wd=function(e){return function(t){for(var n=this,r=[],i={};;){var a=e.outgoing?n.outgoers():n.incomers();if(a.length===0)break;for(var o=!1,s=0;s<a.length;s++){var c=a[s],l=c.id();i[l]||(i[l]=!0,r.push(c),o=!0)}if(!o)break;n=a}return this.spawn(r,!0).filter(t)}};xd.clearTraversalCache=function(){for(var e=0;e<this.length;e++)this[e]._private.traversalCache=null},Z(xd,{roots:Sd({noIncomingEdges:!0}),leaves:Sd({noOutgoingEdges:!0}),outgoers:Wl(Cd({outgoing:!0}),`outgoers`),successors:wd({outgoing:!0}),incomers:Wl(Cd({incoming:!0}),`incomers`),predecessors:wd({})}),Z(xd,{neighborhood:Wl(function(e){for(var t=[],n=this.nodes(),r=0;r<n.length;r++)for(var i=n[r],a=i.connectedEdges(),o=0;o<a.length;o++){var s=a[o],c=s.source(),l=s.target(),u=i===c?l:c;u.length>0&&t.push(u[0]),t.push(s[0])}return this.spawn(t,!0).filter(e)},`neighborhood`),closedNeighborhood:function(e){return this.neighborhood().add(this).filter(e)},openNeighborhood:function(e){return this.neighborhood(e)}}),xd.neighbourhood=xd.neighborhood,xd.closedNeighbourhood=xd.closedNeighborhood,xd.openNeighbourhood=xd.openNeighborhood,Z(xd,{source:Wl(function(e){var t=this[0],n;return t&&(n=t._private.source||t.cy().collection()),n&&e?n.filter(e):n},`source`),target:Wl(function(e){var t=this[0],n;return t&&(n=t._private.target||t.cy().collection()),n&&e?n.filter(e):n},`target`),sources:Td({attr:`source`}),targets:Td({attr:`target`})});function Td(e){return function(t){for(var n=[],r=0;r<this.length;r++){var i=this[r]._private[e.attr];i&&n.push(i)}return this.spawn(n,!0).filter(t)}}Z(xd,{edgesWith:Wl(Ed(),`edgesWith`),edgesTo:Wl(Ed({thisIsSrc:!0}),`edgesTo`)});function Ed(e){return function(t){var n=[],r=this._private.cy,i=e||{};Y(t)&&(t=r.$(t));for(var a=0;a<t.length;a++)for(var o=t[a]._private.edges,s=0;s<o.length;s++){var c=o[s],l=c._private.data,u=this.hasElementWithId(l.source)&&t.hasElementWithId(l.target),d=t.hasElementWithId(l.source)&&this.hasElementWithId(l.target);(u||d)&&((i.thisIsSrc||i.thisIsTgt)&&(i.thisIsSrc&&!u||i.thisIsTgt&&!d)||n.push(c))}return this.spawn(n,!0)}}Z(xd,{connectedEdges:Wl(function(e){for(var t=[],n=this,r=0;r<n.length;r++){var i=n[r];if(i.isNode())for(var a=i._private.edges,o=0;o<a.length;o++){var s=a[o];t.push(s)}}return this.spawn(t,!0).filter(e)},`connectedEdges`),connectedNodes:Wl(function(e){for(var t=[],n=this,r=0;r<n.length;r++){var i=n[r];i.isEdge()&&(t.push(i.source()[0]),t.push(i.target()[0]))}return this.spawn(t,!0).filter(e)},`connectedNodes`),parallelEdges:Wl(Dd(),`parallelEdges`),codirectedEdges:Wl(Dd({codirected:!0}),`codirectedEdges`)});function Dd(e){return e=Z({},{codirected:!1},e),function(t){for(var n=[],r=this.edges(),i=e,a=0;a<r.length;a++)for(var o=r[a]._private,s=o.source,c=s._private.data.id,l=o.data.target,u=s._private.edges,d=0;d<u.length;d++){var f=u[d],p=f._private.data,m=p.target,h=p.source,g=m===l&&h===c,_=c===m&&l===h;(i.codirected&&g||!i.codirected&&(g||_))&&n.push(f)}return this.spawn(n,!0).filter(t)}}Z(xd,{components:function(e){var t=this,n=t.cy(),r=n.collection(),i=e==null?t.nodes():e.nodes(),a=[];e!=null&&i.empty()&&(i=e.sources());var o=function(e,t){r.merge(e),i.unmerge(e),t.merge(e)};if(i.empty())return t.spawn();var s=function(){var e=n.collection();a.push(e);var r=i[0];o(r,e),t.bfs({directed:!1,roots:r,visit:function(t){return o(t,e)}}),e.forEach(function(n){n.connectedEdges().forEach(function(n){t.has(n)&&e.has(n.source())&&e.has(n.target())&&e.merge(n)})})};do s();while(i.length>0);return a},component:function(){var e=this[0];return e.cy().mutableElements().components(e)[0]}}),xd.componentsOf=xd.components;var Od=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(e===void 0)In(`A collection must have a reference to the core`);else{var i=new Zn,a=!1;if(!t)t=[];else if(t.length>0&&je(t[0])&&!Ie(t[0])){a=!0;for(var o=[],s=new er,c=0,l=t.length;c<l;c++){var u=t[c];u.data??={};var d=u.data;if(d.id==null)d.id=Hn();else if(e.hasElementWithId(d.id)||s.has(d.id))continue;var f=new tr(e,u,!1);o.push(f),s.add(d.id)}t=o}this.length=0;for(var p=0,m=t.length;p<m;p++){var h=t[p][0];if(h!=null){var g=h._private.data.id;n&&i.has(g)||(n&&i.set(g,{index:this.length,ele:h}),this[this.length]=h,this.length++)}}this._private={eles:this,cy:e,get map(){return this.lazyMap??this.rebuildMap(),this.lazyMap},set map(e){this.lazyMap=e},rebuildMap:function(){for(var e=this.lazyMap=new Zn,t=this.eles,n=0;n<t.length;n++){var r=t[n];e.set(r.id(),{index:n,ele:r})}}},n&&(this._private.map=i),a&&!r&&this.restore()}},kd=tr.prototype=Od.prototype=Object.create(Array.prototype);kd.instanceString=function(){return`collection`},kd.spawn=function(e,t){return new Od(this.cy(),e,t)},kd.spawnSelf=function(){return this.spawn(this)},kd.cy=function(){return this._private.cy},kd.renderer=function(){return this._private.cy.renderer()},kd.element=function(){return this[0]},kd.collection=function(){return Le(this)?this:new Od(this._private.cy,[this])},kd.unique=function(){return new Od(this._private.cy,this,!0)},kd.hasElementWithId=function(e){return e=``+e,this._private.map.has(e)},kd.getElementById=function(e){e=``+e;var t=this._private.cy,n=this._private.map.get(e);return n?n.ele:new Od(t)},kd.$id=kd.getElementById,kd.poolIndex=function(){var e=this._private.cy._private.elements,t=this[0]._private.data.id;return e._private.map.get(t).index},kd.indexOf=function(e){var t=e[0]._private.data.id;return this._private.map.get(t).index},kd.indexOfId=function(e){return e=``+e,this._private.map.get(e).index},kd.json=function(e){var t=this.element(),n=this.cy();if(t==null&&e)return this;if(t!=null){var r=t._private;if(je(e)){if(n.startBatch(),e.data){t.data(e.data);var i=r.data;if(t.isEdge()){var a=!1,o={},s=e.data.source,c=e.data.target;s!=null&&s!=i.source&&(o.source=``+s,a=!0),c!=null&&c!=i.target&&(o.target=``+c,a=!0),a&&(t=t.move(o))}else{var l=`parent`in e.data,u=e.data.parent;l&&(u!=null||i.parent!=null)&&u!=i.parent&&(u===void 0&&(u=null),u!=null&&(u=``+u),t=t.move({parent:u}))}}e.position&&t.position(e.position);var d=function(n,i,a){var o=e[n];o!=null&&o!==r[n]&&(o?t[i]():t[a]())};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`),e.classes!=null&&t.classes(e.classes),n.endBatch(),this}if(e===void 0){var f={data:Bn(r.data),position:Bn(r.position),group:r.group,removed:r.removed,selected:r.selected,selectable:r.selectable,locked:r.locked,grabbable:r.grabbable,pannable:r.pannable,classes:null};f.classes=``;var p=0;return r.classes.forEach(function(e){return f.classes+=p++===0?e:` `+e}),f}}},kd.jsons=function(){for(var e=[],t=0;t<this.length;t++){var n=this[t].json();e.push(n)}return e},kd.clone=function(){for(var e=this.cy(),t=[],n=0;n<this.length;n++){var r=new tr(e,this[n].json(),!1);t.push(r)}return new Od(e,t)},kd.copy=kd.clone,kd.restore=function(){for(var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=this,r=n.cy(),i=r._private,a=[],o=[],s,c=0,l=n.length;c<l;c++){var u=n[c];(!t||u.removed())&&(u.isNode()?a.push(u):o.push(u))}s=a.concat(o);var d,f=function(){s.splice(d,1),d--};for(d=0;d<s.length;d++){var p=s[d],m=p._private,h=m.data;if(p.clearTraversalCache(),t||m.removed){if(h.id===void 0)h.id=Hn();else if(X(h.id))h.id=``+h.id;else if(Ve(h.id)||!Y(h.id)){In("Can not create element with invalid string ID `"+h.id+"`"),f();continue}else if(r.hasElementWithId(h.id)){In("Can not create second element with ID `"+h.id+"`"),f();continue}}var g=h.id;if(p.isNode()){var _=m.position;_.x??=0,_.y??=0}if(p.isEdge()){for(var v=p,y=[`source`,`target`],b=y.length,x=!1,S=0;S<b;S++){var C=y[S],w=h[C];X(w)&&(w=h[C]=``+h[C]),w==null||w===``?(In("Can not create edge `"+g+"` with unspecified "+C),x=!0):r.hasElementWithId(w)||(In("Can not create edge `"+g+"` with nonexistent "+C+" `"+w+"`"),x=!0)}if(x){f();continue}var T=r.getElementById(h.source),E=r.getElementById(h.target);T.same(E)?T._private.edges.push(v):(T._private.edges.push(v),E._private.edges.push(v)),v._private.source=T,v._private.target=E}m.map=new Zn,m.map.set(g,{ele:p,index:0}),m.removed=!1,t&&r.addToPool(p)}for(var D=0;D<a.length;D++){var O=a[D],k=O._private.data;X(k.parent)&&(k.parent=``+k.parent);var A=k.parent;if(A!=null||O._private.parent){var j=O._private.parent?r.collection().merge(O._private.parent):r.getElementById(A);if(j.empty())k.parent=void 0;else if(j[0].removed())Rn(`Node added with missing parent, reference to parent removed`),k.parent=void 0,O._private.parent=null;else{for(var M=!1,N=j;!N.empty();){if(O.same(N)){M=!0,k.parent=void 0;break}N=N.parent()}M||(j[0]._private.children.push(O),O._private.parent=j[0],i.hasCompoundNodes=!0)}}}if(s.length>0){for(var P=s.length===n.length?n:new Od(r,s),F=0;F<P.length;F++){var I=P[F];I.isNode()||(I.parallelEdges().clearTraversalCache(),I.source().clearTraversalCache(),I.target().clearTraversalCache())}(i.hasCompoundNodes?r.collection().merge(P).merge(P.connectedNodes()).merge(P.parent()):P).dirtyCompoundBoundsCache().dirtyBoundingBoxCache().updateStyle(e),e?P.emitAndNotify(`add`):t&&P.emit(`add`)}return n},kd.removed=function(){var e=this[0];return e&&e._private.removed},kd.inside=function(){var e=this[0];return e&&!e._private.removed},kd.remove=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=this,r=[],i=new er,a=n._private.cy;function o(e){for(var t=e._private.edges,n=0;n<t.length;n++)c(t[n])}function s(e){for(var t=e._private.children,n=0;n<t.length;n++)c(t[n])}function c(e){var n=i.has(e.id());t&&e.removed()||n||(i.add(e.id()),e.isNode()?(r.push(e),o(e),s(e)):r.unshift(e))}for(var l=0,u=n.length;l<u;l++){var d=n[l];c(d)}function f(e,t){var n=e._private.edges;Kn(n,t),e.clearTraversalCache()}function p(e){e.clearTraversalCache()}var m=[];m.ids=new er;function h(e,t){t=t[0],e=e[0];var n=e._private.children,r=e.id();Kn(n,t),t._private.parent=null,m.ids.has(r)||(m.ids.add(r),m.push(e))}n.dirtyCompoundBoundsCache(),t&&a.removeFromPool(r);for(var g=0;g<r.length;g++){var _=r[g];if(_.isEdge()){var v=_.source()[0],y=_.target()[0];f(v,_),f(y,_);for(var b=_.parallelEdges(),x=0;x<b.length;x++){var S=b[x];p(S),S.isBundledBezier()&&S.dirtyBoundingBoxCache()}}else{var C=_.parent();C.length!==0&&h(C,_)}t&&(_._private.removed=!0)}var w=a._private.elements;a._private.hasCompoundNodes=!1;for(var T=0;T<w.length;T++)if(w[T].isParent()){a._private.hasCompoundNodes=!0;break}var E=new Od(this.cy(),r);E.size()>0&&(e?E.emitAndNotify(`remove`):t&&E.emit(`remove`));for(var D=0;D<m.length;D++){var O=m[D];t&&O.removed()||O.updateStyle()}return E},kd.move=function(e){var t=this._private.cy,n=this,r=!1,i=!1,a=function(e){return e==null?e:``+e};if(e.source!==void 0||e.target!==void 0){var o=a(e.source),s=a(e.target),c=o!=null&&t.hasElementWithId(o),l=s!=null&&t.hasElementWithId(s);(c||l)&&(t.batch(function(){n.remove(r,i),n.emitAndNotify(`moveout`);for(var e=0;e<n.length;e++){var t=n[e],a=t._private.data;t.isEdge()&&(c&&(a.source=o),l&&(a.target=s))}n.restore(r,i)}),n.emitAndNotify(`move`))}else if(e.parent!==void 0){var u=a(e.parent);if(u===null||t.hasElementWithId(u)){var d=u===null?void 0:u;t.batch(function(){var e=n.remove(r,i);e.emitAndNotify(`moveout`);for(var t=0;t<n.length;t++){var a=n[t],o=a._private.data;a.isNode()&&(o.parent=d)}e.restore(r,i)}),n.emitAndNotify(`move`)}}return this},[so,yl,bl,Ul,Gl,Ql,$l,Vu,rd,id,od,cd,ud,md,vd,xd].forEach(function(e){Z(kd,e)});var Ad={add:function(e){var t,n=this;if(Fe(e)){var r=e;if(r._private.cy===n)t=r.restore();else{for(var i=[],a=0;a<r.length;a++){var o=r[a];i.push(o.json())}t=new Od(n,i)}}else if(Ae(e))t=new Od(n,e);else if(je(e)&&(Ae(e.nodes)||Ae(e.edges))){for(var s=e,c=[],l=[`nodes`,`edges`],u=0,d=l.length;u<d;u++){var f=l[u],p=s[f];if(Ae(p))for(var m=0,h=p.length;m<h;m++){var g=Z({group:f},p[m]);c.push(g)}}t=new Od(n,c)}else t=new tr(n,e).collection();return t},remove:function(e){if(!Fe(e)&&Y(e)){var t=e;e=this.$(t)}return e.remove()}},jd=Math.cbrt||function(e){return e<0?-((-e)**(1/3)):e**(1/3)};function Md(e,t,n,r){var i=1/Math.max(r,Math.sqrt(e)),a=e*i,o=a*i,s=r*i,c=n*o,l=s*s+c,u=-s*(s*s+1.5*c)-t*a*o,d=u*u-l*l*l,f;if(l===0||d>1e-12*u*u){var p=-jd(u<0?u-Math.sqrt(d):u+Math.sqrt(d));f=p+l/p||0}else{var m=Math.sqrt(l);f=2*m*Math.cos(Math.acos(Math.max(-1,Math.min(1,-u/(l*m))))/3)}return Math.min(1,a/(f+s))}function Nd(e,t,n,r){if(arguments.length!==4)return!1;for(var i=0;i<4;++i)if(typeof arguments[i]!=`number`||isNaN(arguments[i])||!isFinite(arguments[i]))return!1;e=Math.min(e,1),n=Math.min(n,1),e=Math.max(e,0),n=Math.max(n,0);var a=e===t&&n===r,o=(3*e-3*n+1)/2,s=n-2*e,c=e,l=3*t-3*r+1,u=3*(r-2*t),d=3*t,f=function(e){if(a)return e;if(e<=0)return 0;if(e>=1)return 1;var t=Md(e,o,s,c);return((l*t+u)*t+d)*t};f.getControlPoints=function(){return[{x:e,y:t},{x:n,y:r}]};var p=`generateBezier(`+[e,t,n,r]+`)`;return f.toString=function(){return p},f}var Pd=function(){function e(e){return-e.tension*e.x-e.friction*e.v}function t(t,n,r){var i={x:t.x+r.dx*n,v:t.v+r.dv*n,tension:t.tension,friction:t.friction};return{dx:i.v,dv:e(i)}}function n(n,r){var i={dx:n.v,dv:e(n)},a=t(n,r*.5,i),o=t(n,r*.5,a),s=t(n,r,o),c=1/6*(i.dx+2*(a.dx+o.dx)+s.dx),l=1/6*(i.dv+2*(a.dv+o.dv)+s.dv);return n.x+=c*r,n.v+=l*r,n}return function e(t,r,i){var a={x:-1,v:0,tension:null,friction:null},o=[0],s=0,c=1/1e4,l=16/1e3,u,d,f;for(t=parseFloat(t)||500,r=parseFloat(r)||20,i||=null,a.tension=t,a.friction=r,u=i!==null,u?(s=e(t,r),d=s/i*l):d=l;f=n(f||a,d),o.push(1+f.x),s+=16,Math.abs(f.x)>c&&Math.abs(f.v)>c;);return u?function(e){return o[e*(o.length-1)|0]}:s}}(),Fd=function(e,t,n,r){var i=Nd(e,t,n,r);return function(e,t,n){return e+(t-e)*i(n)}},Id={linear:function(e,t,n){return e+(t-e)*n},ease:Fd(.25,.1,.25,1),"ease-in":Fd(.42,0,1,1),"ease-out":Fd(0,0,.58,1),"ease-in-out":Fd(.42,0,.58,1),"ease-in-sine":Fd(.47,0,.745,.715),"ease-out-sine":Fd(.39,.575,.565,1),"ease-in-out-sine":Fd(.445,.05,.55,.95),"ease-in-quad":Fd(.55,.085,.68,.53),"ease-out-quad":Fd(.25,.46,.45,.94),"ease-in-out-quad":Fd(.455,.03,.515,.955),"ease-in-cubic":Fd(.55,.055,.675,.19),"ease-out-cubic":Fd(.215,.61,.355,1),"ease-in-out-cubic":Fd(.645,.045,.355,1),"ease-in-quart":Fd(.895,.03,.685,.22),"ease-out-quart":Fd(.165,.84,.44,1),"ease-in-out-quart":Fd(.77,0,.175,1),"ease-in-quint":Fd(.755,.05,.855,.06),"ease-out-quint":Fd(.23,1,.32,1),"ease-in-out-quint":Fd(.86,0,.07,1),"ease-in-expo":Fd(.95,.05,.795,.035),"ease-out-expo":Fd(.19,1,.22,1),"ease-in-out-expo":Fd(1,0,0,1),"ease-in-circ":Fd(.6,.04,.98,.335),"ease-out-circ":Fd(.075,.82,.165,1),"ease-in-out-circ":Fd(.785,.135,.15,.86),spring:function(e,t,n){if(n===0)return Id.linear;var r=Pd(e,t,n);return function(e,t,n){return e+(t-e)*r(n)}},"cubic-bezier":Fd};function Ld(e,t,n,r,i){if(r===1||t===n)return n;var a=i(t,n,r);return e==null||((e.roundValue||e.color)&&(a=Math.round(a)),e.min!==void 0&&(a=Math.max(a,e.min)),e.max!==void 0&&(a=Math.min(a,e.max))),a}function Rd(e,t){return e.pfValue!=null||e.value!=null?e.pfValue!=null&&(t==null||t.type.units!==`%`)?e.pfValue:e.value:e}function zd(e,t,n,r,i){var a=i==null?null:i.type;n<0?n=0:n>1&&(n=1);var o=Rd(e,i),s=Rd(t,i);if(X(o)&&X(s))return Ld(a,o,s,n,r);if(Ae(o)&&Ae(s)){for(var c=[],l=0;l<s.length;l++){var u=o[l],d=s[l];if(u!=null&&d!=null){var f=Ld(a,u,d,n,r);c.push(f)}else c.push(d)}return c}}function Bd(e,t,n,r){var i=!r,a=e._private,o=t._private,s=o.easing,c=o.startTime,l=(r?e:e.cy()).style();if(!o.easingImpl){if(s==null)o.easingImpl=Id.linear;else{var u=Y(s)?l.parse(`transition-timing-function`,s).value:s,d,f;Y(u)?(d=u,f=[]):(d=u[1],f=u.slice(2).map(function(e){return+e})),f.length>0?(d===`spring`&&f.push(o.duration),o.easingImpl=Id[d].apply(null,f)):o.easingImpl=Id[d]}}var p=o.easingImpl,m=o.duration===0?1:(n-c)/o.duration;if(o.applying&&(m=o.progress),m<0?m=0:m>1&&(m=1),o.delay==null){var h=o.startPosition,g=o.position;if(g&&i&&!e.locked()){var _={};Vd(h.x,g.x)&&(_.x=zd(h.x,g.x,m,p)),Vd(h.y,g.y)&&(_.y=zd(h.y,g.y,m,p)),e.position(_)}var v=o.startPan,y=o.pan,b=a.pan,x=y!=null&&r;x&&(Vd(v.x,y.x)&&(b.x=zd(v.x,y.x,m,p)),Vd(v.y,y.y)&&(b.y=zd(v.y,y.y,m,p)),e.emit(`pan`));var S=o.startZoom,C=o.zoom,w=C!=null&&r;w&&(Vd(S,C)&&(a.zoom=Kr(a.minZoom,zd(S,C,m,p),a.maxZoom)),e.emit(`zoom`)),(x||w)&&e.emit(`viewport`);var T=o.style;if(T&&T.length>0&&i){for(var E=0;E<T.length;E++){var D=T[E],O=D.name,k=D,A=o.startStyle[O],j=l.properties[A.name],M=zd(A,k,m,p,j);l.overrideBypass(e,O,M)}e.emit(`style`)}}return o.progress=m,m}function Vd(e,t){return e==null||t==null?!1:!!(X(e)&&X(t)||e&&t)}function Hd(e,t,n,r){var i=t._private;i.started=!0,i.startTime=n-i.progress*i.duration}function Ud(e,t){var n=t._private.aniEles,r=[];function i(t,n){var i=t._private,a=i.animation.current,o=i.animation.queue,s=!1;if(a.length===0){var c=o.shift();c&&a.push(c)}for(var l=function(e){for(var t=e.length-1;t>=0;t--){var n=e[t];n()}e.splice(0,e.length)},u=a.length-1;u>=0;u--){var d=a[u],f=d._private;f.stopped?(a.splice(u,1),f.hooked=!1,f.playing=!1,f.started=!1,l(f.frames)):(f.playing||f.applying)&&(f.playing&&f.applying&&(f.applying=!1),f.started||Hd(t,d,e),Bd(t,d,e,n),f.applying&&=!1,l(f.frames),f.step!=null&&f.step(e),d.completed()&&(a.splice(u,1),f.hooked=!1,f.playing=!1,f.started=!1,l(f.completes)),s=!0)}return!n&&a.length===0&&o.length===0&&r.push(t),s}for(var a=!1,o=0;o<n.length;o++){var s=n[o],c=i(s);a||=c}var l=i(t,!0);(a||l)&&(n.length>0?t.notify(`draw`,n):t.notify(`draw`)),n.unmerge(r),t.emit(`step`)}var Wd={animate:vl.animate(),animation:vl.animation(),animated:vl.animated(),clearQueue:vl.clearQueue(),delay:vl.delay(),delayAnimation:vl.delayAnimation(),stop:vl.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&&un(function(n){Ud(n,e),t()})}var n=e.renderer();n&&n.beforeRender?n.beforeRender(function(t,n){Ud(n,e)},n.beforeRenderPriorities.animations):t()}},Gd={qualifierCompare:function(e,t){return e==null||t==null?e==null&&t==null:e.sameText(t)},eventMatches:function(e,t,n){var r=t.qualifier;return r==null||e!==n.target&&Ie(n.target)&&r.matches(n.target)},addEventFields:function(e,t){t.cy=e,t.target=e},callbackContext:function(e,t,n){return t.qualifier==null?e:n.target}},Kd=function(e){return Y(e)?new Vl(e):e},qd={createEmitter:function(){var e=this._private;return e.emitter||=new Xu(Gd,this),this},emitter:function(){return this._private.emitter},on:function(e,t,n){return this.emitter().on(e,Kd(t),n),this},removeListener:function(e,t,n){return this.emitter().removeListener(e,Kd(t),n),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},one:function(e,t,n){return this.emitter().one(e,Kd(t),n),this},once:function(e,t,n){return this.emitter().one(e,Kd(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}};vl.eventAliasesOn(qd);var Jd={png:function(e){var t=this._private.renderer;return e||={},t.png(e)},jpg:function(e){var t=this._private.renderer;return e||={},e.bg=e.bg||`#fff`,t.jpg(e)}};Jd.jpeg=Jd.jpg;var Yd={layout:function(e){var t=this;if(e==null)In(`Layout options must be specified to make a layout`);else if(e.name==null)In("A `name` must be specified to make a layout");else{var n=e.name,r=t.extension(`layout`,n);if(r==null)In("No such layout `"+n+"` found. Did you forget to import it and `cytoscape.use()` it?");else return new r(Z({},e,{cy:t,eles:Y(e.eles)?t.$(e.eles):e.eles==null?t.$():e.eles}))}}};Yd.createLayout=Yd.makeLayout=Yd.layout;var Xd={notify:function(e,t){var n=this._private;if(this.batching()){n.batchNotifications=n.batchNotifications||{};var r=n.batchNotifications[e]=n.batchNotifications[e]||this.collection();t!=null&&r.merge(t)}else 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??=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 r=e.batchNotifications[n];r.empty()?t.notify(n):t.notify(n,r)})}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),r=0;r<n.length;r++){var i=n[r],a=e[i];t.getElementById(i).data(a)}})}},Zd=Gn({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]}),Qd={renderTo:function(e,t,n,r){return this._private.renderer.renderTo(e,t,n,r),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)In(`Can not initialise: No such renderer \`${e.name}\` found. Did you forget to import it and \`cytoscape.use()\` it?`);else{e.wheelSensitivity!==void 0&&Rn(`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 r=Zd(e);r.cy=t,t._private.renderer=new n(r),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(e){var t=e._private;t.rscratch={},t.rstyle={},t.animation.current=[],t.animation.queue=[]})},onRender:function(e){return this.on(`render`,e)},offRender:function(e){return this.off(`render`,e)}};Qd.invalidateDimensions=Qd.resize;var $d={collection:function(e,t){return Y(e)?this.$(e):Fe(e)?e.collection():Ae(e)?(t||={},new Od(this,e,t.unique,t.removed)):new Od(this)},nodes:function(e){var t=this.$(function(e){return e.isNode()});return e?t.filter(e):t},edges:function(e){var t=this.$(function(e){return e.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}};$d.elements=$d.filter=$d.$;var ef={},tf=`t`,nf=`f`;ef.apply=function(e){for(var t=this,n=t._private.cy.collection(),r=0;r<e.length;r++){var i=e[r],a=t.getContextMeta(i);if(!a.empty){var o=t.getContextStyle(a),s=t.applyContextStyle(a,o,i);i._private.appliedInitStyle?t.updateTransitions(i,s.diffProps):i._private.appliedInitStyle=!0,t.updateStyleHints(i)&&n.push(i)}}return n},ef.getPropertiesDiff=function(e,t){var n=this,r=n._private.propDiffs=n._private.propDiffs||{},i=e+`-`+t,a=r[i];if(a)return a;for(var o=[],s={},c=0;c<n.length;c++){var l=n[c],u=e[c]===tf,d=t[c]===tf,f=u!==d,p=l.mappedProperties.length>0;if(f||d&&p){var m=void 0;f&&p||f?m=l.properties:p&&(m=l.mappedProperties);for(var h=0;h<m.length;h++){for(var g=m[h],_=g.name,v=!1,y=c+1;y<n.length;y++){var b=n[y];if(t[y]===tf&&(v=b.properties[g.name]!=null,v))break}!s[_]&&!v&&(s[_]=!0,o.push(_))}}}return r[i]=o,o},ef.getContextMeta=function(e){for(var t=this,n=``,r,i=e._private.styleCxtKey||``,a=0;a<t.length;a++){var o=t[a];o.selector&&o.selector.matches(e)?n+=tf:n+=nf}return r=t.getPropertiesDiff(i,n),e._private.styleCxtKey=n,{key:n,diffPropNames:r,empty:r.length===0}},ef.getContextStyle=function(e){var t=e.key,n=this,r=this._private.contextStyles=this._private.contextStyles||{};if(r[t])return r[t];for(var i={_private:{key:t}},a=0;a<n.length;a++){var o=n[a];if(t[a]===tf)for(var s=0;s<o.properties.length;s++){var c=o.properties[s];i[c.name]=c}}return r[t]=i,i},ef.applyContextStyle=function(e,t,n){for(var r=this,i=e.diffPropNames,a={},o=r.types,s=0;s<i.length;s++){var c=i[s],l=t[c],u=n.pstyle(c);if(!l){if(u)l=u.bypass?{name:c,deleteBypassed:!0}:{name:c,delete:!0};else continue}if(u!==l){if(l.mapped===o.fn&&u!=null&&u.mapping!=null&&u.mapping.value===l.value){var d=u.mapping;if((d.fnValue=l.value(n))===d.prevFnValue)continue}var f=a[c]={prev:u};r.applyParsedProperty(n,l),f.next=n.pstyle(c),f.next&&f.next.bypass&&(f.next=f.next.bypassed)}}return{diffProps:a}},ef.updateStyleHints=function(e){var t=e._private,n=this,r=n.propertyGroupNames,i=n.propertyGroupKeys,a=function(e,t,r){return n.getPropertiesHash(e,t,r)},o=t.styleKey;if(e.removed())return!1;var s=t.group===`nodes`,c=e._private.style;r=Object.keys(c);for(var l=0;l<i.length;l++){var u=i[l];t.styleKeys[u]=[fn,mn]}for(var d=function(e,n){return t.styleKeys[n][0]=gn(e,t.styleKeys[n][0])},f=function(e,n){return t.styleKeys[n][1]=_n(e,t.styleKeys[n][1])},p=function(e,t){d(e,t),f(e,t)},m=function(e,t){for(var n=0;n<e.length;n++){var r=e.charCodeAt(n);d(r,t),f(r,t)}},h=2e9,g=function(e){return-128<e&&e<128&&Math.floor(e)!==e?h-(e*1024|0):e},_=0;_<r.length;_++){var v=r[_],y=c[v];if(y!=null){var b=this.properties[v],x=b.type,S=b.groupKey,C=void 0;b.hashOverride==null?y.pfValue!=null&&(C=y.pfValue):C=b.hashOverride(e,y);var w=b.enums==null?y.value:null,T=C!=null,E=T||w!=null,D=y.units;x.number&&E&&!x.multiple?(p(g(T?C:w),S),!T&&D!=null&&m(D,S)):m(y.strValue,S)}}for(var O=[fn,mn],k=0;k<i.length;k++){var A=i[k],j=t.styleKeys[A];O[0]=gn(j[0],O[0]),O[1]=_n(j[1],O[1])}t.styleKey=vn(O[0],O[1]);var M=t.styleKeys;t.labelDimsKey=yn(M.labelDimensions);var N=a(e,[`label`],M.labelDimensions);if(t.labelKey=yn(N),t.labelStyleKey=yn(bn(M.commonLabel,N)),!s){var P=a(e,[`source-label`],M.labelDimensions);t.sourceLabelKey=yn(P),t.sourceLabelStyleKey=yn(bn(M.commonLabel,P));var F=a(e,[`target-label`],M.labelDimensions);t.targetLabelKey=yn(F),t.targetLabelStyleKey=yn(bn(M.commonLabel,F))}if(s){var I=t.styleKeys,L=I.nodeBody,R=I.nodeBorder,z=I.nodeOutline,B=I.backgroundImage,V=I.compound,H=I.pie,U=I.stripe;t.nodeKey=yn([L,R,z,B,V,H,U].filter(function(e){return e!=null}).reduce(bn,[fn,mn])),t.hasPie=H!=null&&H[0]!==fn&&H[1]!==mn,t.hasStripe=U!=null&&U[0]!==fn&&U[1]!==mn}return o!==t.styleKey},ef.clearStyleHints=function(e){var t=e._private;t.styleCxtKey=``,t.styleKeys={},t.styleKey=null,t.labelKey=null,t.labelStyleKey=null,t.sourceLabelKey=null,t.sourceLabelStyleKey=null,t.targetLabelKey=null,t.targetLabelStyleKey=null,t.nodeKey=null,t.hasPie=null,t.hasStripe=null},ef.applyParsedProperty=function(e,t){var n=this,r=t,i=e._private.style,a,o=n.types,s=n.properties[r.name].type,c=r.bypass,l=i[r.name],u=l&&l.bypass,d=e._private,f=`mapping`,p=function(e){return e==null?null:e.pfValue==null?e.value:e.pfValue},m=function(){var t=p(l),i=p(r);n.checkTriggers(e,r.name,t,i)};if(t.name===`curve-style`&&e.isEdge()&&(t.value!==`bezier`&&e.isLoop()||t.value===`haystack`&&(e.source().isParent()||e.target().isParent()))&&(r=t=this.parse(t.name,`bezier`,c)),r.delete)return i[r.name]=void 0,m(),!0;if(r.deleteBypassed)return l?l.bypass?(l.bypassed=void 0,m(),!0):!1:(m(),!0);if(r.deleteBypass)return l?l.bypass?(i[r.name]=l.bypassed,m(),!0):!1:(m(),!0);var h=function(){Rn("Do not assign mappings to elements without corresponding data (i.e. ele `"+e.id()+"` has no mapping for property `"+r.name+"` with data field `"+r.field+"`); try a `["+r.field+"]` selector to limit scope to elements with `"+r.field+"` defined")};switch(r.mapped){case o.mapData:for(var g=r.field.split(`.`),_=d.data,v=0;v<g.length&&_;v++){var y=g[v];_=_[y]}if(_==null)return h(),!1;var b;if(X(_)){var x=r.fieldMax-r.fieldMin;b=x===0?0:(_-r.fieldMin)/x}else return Rn("Do not use continuous mappers without specifying numeric data (i.e. `"+r.field+`: `+_+"` for `"+e.id()+"` is non-numeric)"),!1;if(b<0?b=0:b>1&&(b=1),s.color){var S=r.valueMin[0],C=r.valueMax[0],w=r.valueMin[1],T=r.valueMax[1],E=r.valueMin[2],D=r.valueMax[2],O=r.valueMin[3]==null?1:r.valueMin[3],k=r.valueMax[3]==null?1:r.valueMax[3],A=[Math.round(S+(C-S)*b),Math.round(w+(T-w)*b),Math.round(E+(D-E)*b),O+(k-O)*b];a={bypass:r.bypass,name:r.name,value:A,strValue:`rgba(`+A[0]+`, `+A[1]+`, `+A[2]+`, `+A[3]+`)`}}else if(s.number){var j=r.valueMin+(r.valueMax-r.valueMin)*b;a=this.parse(r.name,j,r.bypass,f)}else return!1;if(!a)return h(),!1;a.mapping=r,r=a;break;case o.data:for(var M=r.field.split(`.`),N=d.data,P=0;P<M.length&&N;P++){var F=M[P];N=N[F]}if(N!=null&&(a=this.parse(r.name,N,r.bypass,f)),!a)return h(),!1;a.mapping=r,r=a;break;case o.fn:var I=r.value,L=r.fnValue==null?I(e):r.fnValue;if(r.prevFnValue=L,L==null)return Rn("Custom function mappers may not return null (i.e. `"+r.name+"` for ele `"+e.id()+"` is null)"),!1;if(a=this.parse(r.name,L,r.bypass,f),!a)return Rn("Custom function mappers may not return invalid values for the property type (i.e. `"+r.name+"` for ele `"+e.id()+"` is invalid)"),!1;a.mapping=Bn(r),r=a;break;case void 0:break;default:return!1}return c?(u?r.bypassed=l.bypassed:r.bypassed=l,i[r.name]=r):u?l.bypassed=r:i[r.name]=r,m(),!0},ef.cleanElements=function(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(this.clearStyleHints(r),r.dirtyCompoundBoundsCache(),r.dirtyBoundingBoxCache(),!t)r._private.style={};else for(var i=r._private.style,a=Object.keys(i),o=0;o<a.length;o++){var s=a[o],c=i[s];c!=null&&(c.bypass?c.bypassed=null:i[s]=null)}}},ef.update=function(){this._private.cy.mutableElements().updateStyle()},ef.updateTransitions=function(e,t){var n=this,r=e._private,i=e.pstyle(`transition-property`).value,a=e.pstyle(`transition-duration`).pfValue,o=e.pstyle(`transition-delay`).pfValue;if(i.length>0&&a>0){for(var s={},c=!1,l=0;l<i.length;l++){var u=i[l],d=e.pstyle(u),f=t[u];if(f){var p=f.prev,m=f.next==null?d:f.next,h=!1,g=void 0,_=1e-6;p&&(X(p.pfValue)&&X(m.pfValue)?(h=m.pfValue-p.pfValue,g=p.pfValue+_*h):X(p.value)&&X(m.value)?(h=m.value-p.value,g=p.value+_*h):Ae(p.value)&&Ae(m.value)&&(h=p.value[0]!==m.value[0]||p.value[1]!==m.value[1]||p.value[2]!==m.value[2],g=p.strValue),h&&(s[u]=m.strValue,this.applyBypass(e,u,g),c=!0))}}if(!c)return;r.transitioning=!0,new vo(function(t){o>0?e.delayAnimation(o).play().promise().then(t):t()}).then(function(){return e.animation({style:s,duration:a,easing:e.pstyle(`transition-timing-function`).value,queue:!1}).play().promise()}).then(function(){n.removeBypasses(e,i),e.emitAndNotify(`style`),r.transitioning=!1})}else r.transitioning&&=(this.removeBypasses(e,i),e.emitAndNotify(`style`),!1)},ef.checkTrigger=function(e,t,n,r,i,a){var o=this.properties[t],s=i(o);e.removed()||s!=null&&s(n,r,e)&&a(o)},ef.checkZOrderTrigger=function(e,t,n,r){var i=this;this.checkTrigger(e,t,n,r,function(e){return e.triggersZOrder},function(){i._private.cy.notify(`zorder`,e)})},ef.checkBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,function(e){return e.triggersBounds},function(t){e.dirtyCompoundBoundsCache(),e.dirtyBoundingBoxCache()})},ef.checkConnectedEdgesBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,function(e){return e.triggersBoundsOfConnectedEdges},function(t){e.connectedEdges().forEach(function(e){e.dirtyBoundingBoxCache()})})},ef.checkParallelEdgesBoundsTrigger=function(e,t,n,r){this.checkTrigger(e,t,n,r,function(e){return e.triggersBoundsOfParallelEdges},function(t){e.parallelEdges().forEach(function(e){e.dirtyBoundingBoxCache()})})},ef.checkTriggers=function(e,t,n,r){e.dirtyStyleCache(),this.checkZOrderTrigger(e,t,n,r),this.checkBoundsTrigger(e,t,n,r),this.checkConnectedEdgesBoundsTrigger(e,t,n,r),this.checkParallelEdgesBoundsTrigger(e,t,n,r)};var rf={};rf.applyBypass=function(e,t,n,r){var i=this,a=[],o=!0;if(t===`*`||t===`**`){if(n!==void 0)for(var s=0;s<i.properties.length;s++){var c=i.properties[s].name,l=this.parse(c,n,!0);l&&a.push(l)}}else if(Y(t)){var u=this.parse(t,n,!0);u&&a.push(u)}else if(je(t)){var d=t;r=n;for(var f=Object.keys(d),p=0;p<f.length;p++){var m=f[p],h=d[m];if(h===void 0&&(h=d[Je(m)]),h!==void 0){var g=this.parse(m,h,!0);g&&a.push(g)}}}else return!1;if(a.length===0)return!1;for(var _=!1,v=0;v<e.length;v++){for(var y=e[v],b={},x=void 0,S=0;S<a.length;S++){var C=a[S];if(r){var w=y.pstyle(C.name);x=b[C.name]={prev:w}}_=this.applyParsedProperty(y,Bn(C))||_,r&&(x.next=y.pstyle(C.name))}_&&this.updateStyleHints(y),r&&this.updateTransitions(y,b,o)}return _},rf.overrideBypass=function(e,t,n){t=qe(t);for(var r=0;r<e.length;r++){var i=e[r],a=i._private.style[t],o=this.properties[t].type,s=o.color,c=o.mutiple,l=a?a.pfValue==null?a.value:a.pfValue:null;!a||!a.bypass?this.applyBypass(i,t,n):(a.value=n,a.pfValue!=null&&(a.pfValue=n),a.strValue=s?n[3]==null?`rgb(`+n[0]+`,`+n[1]+`,`+n[2]+`)`:`rgba(`+n[0]+`,`+n[1]+`,`+n[2]+`,`+n[3]+`)`:c?n.join(` `):``+n,this.updateStyleHints(i)),this.checkTriggers(i,t,l,n)}},rf.removeAllBypasses=function(e,t){return this.removeBypasses(e,this.propertyNames,t)},rf.removeBypasses=function(e,t,n){for(var r=!0,i=0;i<e.length;i++){for(var a=e[i],o={},s=0;s<t.length;s++){var c=t[s],l=this.properties[c],u=a.pstyle(l.name);if(u&&u.bypass){var d=this.parse(c,``,!0),f=o[l.name]={prev:u};this.applyParsedProperty(a,d),f.next=a.pstyle(l.name)}}this.updateStyleHints(a),n&&this.updateTransitions(a,o,r)}};var af={};af.getEmSizeInPixels=function(){var e=this.containerCss(`font-size`);return e==null?1:parseFloat(e)},af.containerCss=function(e){var t=this._private.cy,n=t.container(),r=t.window();if(r&&n&&r.getComputedStyle)return r.getComputedStyle(n).getPropertyValue(e)};var of={};of.getRenderedStyle=function(e,t){return t?this.getStylePropertyValue(e,t,!0):this.getRawStyle(e,!0)},of.getRawStyle=function(e,t){var n=this;if(e=e[0],e){for(var r={},i=0;i<n.properties.length;i++){var a=n.properties[i],o=n.getStylePropertyValue(e,a.name,t);o!=null&&(r[a.name]=o,r[Je(a.name)]=o)}return r}},of.getIndexedStyle=function(e,t,n,r){return e.pstyle(t)[n][r]??e.cy().style().getDefaultProperty(t)[n][0]},of.getStylePropertyValue=function(e,t,n){var r=this;if(e=e[0],e){var i=r.properties[t];i.alias&&(i=i.pointsTo);var a=i.type,o=e.pstyle(i.name);if(o){var s=o.value,c=o.units,l=o.strValue;if(n&&a.number&&s!=null&&X(s)){var u=e.cy().zoom(),d=function(e){return e*u},f=function(e,t){return d(e)+t},p=Ae(s);return(p?c.every(function(e){return e!=null}):c!=null)?p?s.map(function(e,t){return f(e,c[t])}).join(` `):f(s,c):p?s.map(function(e){return Y(e)?e:``+d(e)}).join(` `):``+d(s)}if(l!=null)return l}return null}},of.getAnimationStartStyle=function(e,t){for(var n={},r=0;r<t.length;r++){var i=t[r].name,a=e.pstyle(i);a!==void 0&&(a=je(a)?this.parse(i,a.strValue):this.parse(i,a)),a&&(n[i]=a)}return n},of.getPropsList=function(e){var t=this,n=[],r=e,i=t.properties;if(r)for(var a=Object.keys(r),o=0;o<a.length;o++){var s=a[o],c=r[s],l=i[s]||i[qe(s)],u=this.parse(l.name,c);u&&n.push(u)}return n},of.getNonDefaultPropertiesHash=function(e,t,n){for(var r=n.slice(),i,a,o,s,c=0,l;c<t.length;c++)if(i=t[c],a=e.pstyle(i,!1),a!=null){if(a.pfValue!=null)r[0]=gn(s,r[0]),r[1]=_n(s,r[1]);else for(o=a.strValue,l=0;l<o.length;l++)s=o.charCodeAt(l),r[0]=gn(s,r[0]),r[1]=_n(s,r[1])}return r},of.getPropertiesHash=of.getNonDefaultPropertiesHash;var sf={};sf.appendFromJson=function(e){for(var t=this,n=0;n<e.length;n++){var r=e[n],i=r.selector,a=r.style||r.css,o=Object.keys(a);t.selector(i);for(var s=0;s<o.length;s++){var c=o[s],l=a[c];t.css(c,l)}}return t},sf.fromJson=function(e){var t=this;return t.resetToDefault(),t.appendFromJson(e),t},sf.json=function(){for(var e=[],t=this.defaultLength;t<this.length;t++){for(var n=this[t],r=n.selector,i=n.properties,a={},o=0;o<i.length;o++){var s=i[o];a[s.name]=s.strValue}e.push({selector:r?r.toString():`core`,style:a})}return e};var cf={};cf.appendFromString=function(e){var t=this,n=this,r=``+e,i,a,o;r=r.replace(/[/][*](\s|.)+?[*][/]/g,``);function s(){r=r.length>i.length?r.substr(i.length):``}function c(){a=a.length>o.length?a.substr(o.length):``}for(;!r.match(/^\s*$/);){var l=r.match(/^\s*((?:.|\s)+?)\s*\{((?:.|\s)+?)\}/);if(!l){Rn(`Halting stylesheet parsing: String stylesheet contains more to parse but no selector and block found in: `+r);break}i=l[0];var u=l[1];if(u!==`core`&&new Vl(u).invalid)Rn(`Skipping parsing of block: Invalid selector found in string stylesheet: `+u),s();else{var d=l[2],f=!1;a=d;for(var p=[];!a.match(/^\s*$/);){var m=a.match(/^\s*(.+?)\s*:\s*(.+?)(?:\s*;|\s*$)/);if(!m){Rn(`Skipping parsing of block: Invalid formatting of style property and value definitions found in:`+d),f=!0;break}o=m[0];var h=m[1],g=m[2];t.properties[h]?n.parse(h,g)?(p.push({name:h,val:g}),c()):(Rn(`Skipping property: Invalid property definition in: `+o),c()):(Rn(`Skipping property: Invalid property name in: `+o),c())}if(f){s();break}n.selector(u);for(var _=0;_<p.length;_++){var v=p[_];n.css(v.name,v.val)}s()}}return n},cf.fromString=function(e){var t=this;return t.resetToDefault(),t.appendFromString(e),t};var lf=[`source`,`mid-source`,`target`,`mid-target`],uf=function(e,t){if(t!=null){var n=e.pstyle(t+`-arrow-scale`);if(n!=null&&n.value!==`inherit`)return n.value}return e.pstyle(`arrow-scale`).value},df={};(function(){var e=Qe,t=et,n=nt,r=rt,i=it,a=function(e){return`^`+e+`\\s*\\(\\s*([\\w\\.]+)\\s*\\)$`},o=function(a){var o=e+`|\\w+|`+t+`|`+n+`|`+r+`|`+i;return`^`+a+`\\s*\\(([\\w\\.]+)\\s*\\,\\s*(`+e+`)\\s*\\,\\s*(`+e+`)\\s*,\\s*(`+o+`)\\s*\\,\\s*(`+o+`)\\)$`},s=[`^url\\s*\\(\\s*['"]?(.+?)['"]?\\s*\\)$`,`^(none)$`,`^(.+)$`];df.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},arrowScale:{number:!0,unitless:!0,min:0,strictMin:!0,enums:[`inherit`]},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`.split(`.`)},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`,`top-inside`,`center`,`bottom`,`bottom-inside`]},halign:{enums:[`left`,`left-inside`,`center`,`right`,`right-inside`]},justification:{enums:[`left`,`center`,`right`,`auto`]},textMetrics:{enums:[`font`,`glyph`]},text:{string:!0},data:{mapping:!0,regex:a(`data`)},layoutData:{mapping:!0,regex:a(`layoutData`)},scratch:{mapping:!0,regex:a(`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(e,t){switch(e.length){case 2:return t[0]!==`deg`&&t[0]!==`rad`&&t[1]!==`deg`&&t[1]!==`rad`;case 1:return Y(e[0])||t[0]===`deg`||t[0]===`rad`;default:return!1}}},easing:{regexes:[`^(spring)\\s*\\(\\s*(`+e+`)\\s*,\\s*(`+e+`)\\s*\\)$`,`^(cubic-bezier)\\s*\\(\\s*(`+e+`)\\s*,\\s*(`+e+`)\\s*,\\s*(`+e+`)\\s*,\\s*(`+e+`)\\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`.split(`.`)},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(e){var t=e.length;return t===1||t===2||t===4}}};var c={zeroNonZero:function(e,t){return(e==null||t==null)&&e!==t||e==0&&t!=0||e!=0&&t==0},any:function(e,t){return e!=t},emptyNonEmpty:function(e,t){var n=Ve(e),r=Ve(t);return n&&!r||!n&&r}},l=df.types,u=[{name:`label`,type:l.text,triggersBounds:c.any,triggersZOrder:c.emptyNonEmpty},{name:`text-rotation`,type:l.textRotation,triggersBounds:c.any},{name:`text-margin-x`,type:l.bidirectionalSize,triggersBounds:c.any},{name:`text-margin-y`,type:l.bidirectionalSize,triggersBounds:c.any}],d=[{name:`source-label`,type:l.text,triggersBounds:c.any},{name:`source-text-rotation`,type:l.textRotation,triggersBounds:c.any},{name:`source-text-margin-x`,type:l.bidirectionalSize,triggersBounds:c.any},{name:`source-text-margin-y`,type:l.bidirectionalSize,triggersBounds:c.any},{name:`source-text-offset`,type:l.size,triggersBounds:c.any}],f=[{name:`target-label`,type:l.text,triggersBounds:c.any},{name:`target-text-rotation`,type:l.textRotation,triggersBounds:c.any},{name:`target-text-margin-x`,type:l.bidirectionalSize,triggersBounds:c.any},{name:`target-text-margin-y`,type:l.bidirectionalSize,triggersBounds:c.any},{name:`target-text-offset`,type:l.size,triggersBounds:c.any}],p=[{name:`font-family`,type:l.fontFamily,triggersBounds:c.any},{name:`font-style`,type:l.fontStyle,triggersBounds:c.any},{name:`font-weight`,type:l.fontWeight,triggersBounds:c.any},{name:`font-size`,type:l.size,triggersBounds:c.any},{name:`text-transform`,type:l.textTransform,triggersBounds:c.any},{name:`text-wrap`,type:l.textWrap,triggersBounds:c.any},{name:`text-overflow-wrap`,type:l.textOverflowWrap,triggersBounds:c.any},{name:`text-max-width`,type:l.size,triggersBounds:c.any},{name:`text-outline-width`,type:l.size,triggersBounds:c.any},{name:`line-height`,type:l.positiveNumber,triggersBounds:c.any}],m=[{name:`text-valign`,type:l.valign,triggersBounds:c.any},{name:`text-halign`,type:l.halign,triggersBounds:c.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:c.any},{name:`text-border-opacity`,type:l.zeroOneNumber},{name:`text-border-color`,type:l.color},{name:`text-border-width`,type:l.size,triggersBounds:c.any},{name:`text-border-style`,type:l.borderStyle,triggersBounds:c.any},{name:`text-background-shape`,type:l.textBackgroundShape,triggersBounds:c.any},{name:`text-justification`,type:l.justification},{name:`text-metrics`,type:l.textMetrics},{name:`box-select-labels`,type:l.bool,triggersBounds:c.any}],h=[{name:`events`,type:l.bool,triggersZOrder:c.any},{name:`text-events`,type:l.bool,triggersZOrder:c.any},{name:`box-selection`,type:l.boxSelection,triggersZOrder:c.any}],g=[{name:`display`,type:l.display,triggersZOrder:c.any,triggersBounds:c.any,triggersBoundsOfConnectedEdges:c.any,triggersBoundsOfParallelEdges:function(e,t,n){return e!==t&&n.pstyle(`curve-style`).value===`bezier`}},{name:`visibility`,type:l.visibility,triggersZOrder:c.any},{name:`opacity`,type:l.zeroOneNumber,triggersZOrder:c.zeroNonZero},{name:`text-opacity`,type:l.zeroOneNumber},{name:`min-zoomed-font-size`,type:l.size},{name:`z-compound-depth`,type:l.zCompoundDepth,triggersZOrder:c.any},{name:`z-index-compare`,type:l.zIndexCompare,triggersZOrder:c.any},{name:`z-index`,type:l.number,triggersZOrder:c.any}],_=[{name:`overlay-padding`,type:l.size,triggersBounds:c.any},{name:`overlay-color`,type:l.color},{name:`overlay-fill`,type:l.fill},{name:`overlay-gradient-stop-colors`,type:l.colors},{name:`overlay-gradient-stop-positions`,type:l.percentages},{name:`overlay-gradient-direction`,type:l.gradientDirection},{name:`overlay-opacity`,type:l.zeroOneNumber,triggersBounds:c.zeroNonZero},{name:`overlay-shape`,type:l.overlayShape,triggersBounds:c.any},{name:`overlay-corner-radius`,type:l.cornerRadius}],v=[{name:`underlay-padding`,type:l.size,triggersBounds:c.any},{name:`underlay-color`,type:l.color},{name:`underlay-fill`,type:l.fill},{name:`underlay-gradient-stop-colors`,type:l.colors},{name:`underlay-gradient-stop-positions`,type:l.percentages},{name:`underlay-gradient-direction`,type:l.gradientDirection},{name:`underlay-opacity`,type:l.zeroOneNumber,triggersBounds:c.zeroNonZero},{name:`underlay-shape`,type:l.overlayShape,triggersBounds:c.any},{name:`underlay-corner-radius`,type:l.cornerRadius}],y=[{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}],b=function(e,t){return t.value===`label`?-e.poolIndex():t.pfValue},x=[{name:`height`,type:l.nodeSize,triggersBounds:c.any,hashOverride:b},{name:`width`,type:l.nodeSize,triggersBounds:c.any,hashOverride:b},{name:`shape`,type:l.nodeShape,triggersBounds:c.any},{name:`shape-polygon-points`,type:l.polygonPointList,triggersBounds:c.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:c.any},{name:`padding-relative-to`,type:l.paddingRelativeTo,triggersBounds:c.any},{name:`bounds-expansion`,type:l.boundsExpansion,triggersBounds:c.any}],S=[{name:`border-color`,type:l.color},{name:`border-opacity`,type:l.zeroOneNumber},{name:`border-width`,type:l.size,triggersBounds:c.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}],C=[{name:`outline-color`,type:l.color},{name:`outline-opacity`,type:l.zeroOneNumber},{name:`outline-width`,type:l.size,triggersBounds:c.any},{name:`outline-style`,type:l.borderStyle},{name:`outline-offset`,type:l.size,triggersBounds:c.any}],w=[{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}],T=[{name:`position`,type:l.position,triggersBounds:c.any},{name:`compound-sizing-wrt-labels`,type:l.compoundIncludeLabels,triggersBounds:c.any},{name:`min-width`,type:l.size,triggersBounds:c.any},{name:`min-width-bias-left`,type:l.sizeMaybePercent,triggersBounds:c.any},{name:`min-width-bias-right`,type:l.sizeMaybePercent,triggersBounds:c.any},{name:`min-height`,type:l.size,triggersBounds:c.any},{name:`min-height-bias-top`,type:l.sizeMaybePercent,triggersBounds:c.any},{name:`min-height-bias-bottom`,type:l.sizeMaybePercent,triggersBounds:c.any}],E=[{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:c.any,triggersBoundsOfParallelEdges:function(e,t){return e===t?!1:e===`bezier`||t===`bezier`}},{name:`haystack-radius`,type:l.zeroOneNumber,triggersBounds:c.any},{name:`source-endpoint`,type:l.edgeEndpoint,triggersBounds:c.any},{name:`target-endpoint`,type:l.edgeEndpoint,triggersBounds:c.any},{name:`control-point-step-size`,type:l.size,triggersBounds:c.any},{name:`control-point-distances`,type:l.bidirectionalSizes,triggersBounds:c.any},{name:`control-point-weights`,type:l.numbers,triggersBounds:c.any},{name:`segment-distances`,type:l.bidirectionalSizes,triggersBounds:c.any},{name:`segment-weights`,type:l.numbers,triggersBounds:c.any},{name:`segment-radii`,type:l.numbers,triggersBounds:c.any},{name:`radius-type`,type:l.radiusType,triggersBounds:c.any},{name:`taxi-turn`,type:l.bidirectionalSizeMaybePercent,triggersBounds:c.any},{name:`taxi-turn-min-distance`,type:l.size,triggersBounds:c.any},{name:`taxi-direction`,type:l.axisDirection,triggersBounds:c.any},{name:`taxi-radius`,type:l.number,triggersBounds:c.any},{name:`edge-distances`,type:l.edgeDistances,triggersBounds:c.any},{name:`arrow-scale`,type:l.positiveNumber,triggersBounds:c.any},{name:`loop-direction`,type:l.angle,triggersBounds:c.any},{name:`loop-sweep`,type:l.angle,triggersBounds:c.any},{name:`source-distance-from-node`,type:l.size,triggersBounds:c.any},{name:`target-distance-from-node`,type:l.size,triggersBounds:c.any}],D=[{name:`ghost`,type:l.bool,triggersBounds:c.any},{name:`ghost-offset-x`,type:l.bidirectionalSize,triggersBounds:c.any},{name:`ghost-offset-y`,type:l.bidirectionalSize,triggersBounds:c.any},{name:`ghost-opacity`,type:l.zeroOneNumber}],O=[{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}],k=[];df.pieBackgroundN=16,k.push({name:`pie-size`,type:l.sizeMaybePercent}),k.push({name:`pie-hole`,type:l.sizeMaybePercent}),k.push({name:`pie-start-angle`,type:l.angle});for(var A=1;A<=df.pieBackgroundN;A++)k.push({name:`pie-`+A+`-background-color`,type:l.color}),k.push({name:`pie-`+A+`-background-size`,type:l.percent}),k.push({name:`pie-`+A+`-background-opacity`,type:l.zeroOneNumber});var j=[];df.stripeBackgroundN=16,j.push({name:`stripe-size`,type:l.sizeMaybePercent}),j.push({name:`stripe-direction`,type:l.axisDirectionPrimary});for(var M=1;M<=df.stripeBackgroundN;M++)j.push({name:`stripe-`+M+`-background-color`,type:l.color}),j.push({name:`stripe-`+M+`-background-size`,type:l.percent}),j.push({name:`stripe-`+M+`-background-opacity`,type:l.zeroOneNumber});var N=[];df.arrowPrefixes=lf,[{name:`arrow-shape`,type:l.arrowShape,triggersBounds:c.any},{name:`arrow-color`,type:l.color},{name:`arrow-fill`,type:l.arrowFill},{name:`arrow-width`,type:l.arrowWidth},{name:`arrow-scale`,type:l.arrowScale,triggersBounds:c.any}].forEach(function(e){lf.forEach(function(t){var n=t+`-`+e.name,r=e.type,i=e.triggersBounds;N.push({name:n,type:r,triggersBounds:i})})},{});var P=df.properties=[].concat(h,y,g,_,v,D,m,p,u,d,f,x,S,C,w,k,j,T,E,N,O),F=df.propertyGroups={behavior:h,transition:y,visibility:g,overlay:_,underlay:v,ghost:D,commonLabel:m,labelDimensions:p,mainLabel:u,sourceLabel:d,targetLabel:f,nodeBody:x,nodeBorder:S,nodeOutline:C,backgroundImage:w,pie:k,stripe:j,compound:T,edgeLine:E,edgeArrow:N,core:O},I=df.propertyGroupNames={};(df.propertyGroupKeys=Object.keys(F)).forEach(function(e){I[e]=F[e].map(function(e){return e.name}),F[e].forEach(function(t){return t.groupKey=e})});var L=df.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`}];df.propertyNames=P.map(function(e){return e.name});for(var R=0;R<P.length;R++){var z=P[R];P[z.name]=z}for(var B=0;B<L.length;B++){var V=L[B],H=P[V.pointsTo],U={name:V.name,alias:!0,pointsTo:H};P.push(U),P[V.name]=U}})(),df.getDefaultProperty=function(e){return this.getDefaultProperties()[e]},df.getDefaultProperties=function(){var e=this._private;if(e.defaultProperties!=null)return e.defaultProperties;for(var t=Z({"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-fill":`solid`,"overlay-gradient-stop-colors":`#999`,"overlay-gradient-stop-positions":`0%`,"overlay-gradient-direction":`to-bottom`,"overlay-padding":10,"overlay-shape":`round-rectangle`,"overlay-corner-radius":`auto`,"underlay-opacity":0,"underlay-color":`#000`,"underlay-fill":`solid`,"underlay-gradient-stop-colors":`#999`,"underlay-gradient-stop-positions":`0%`,"underlay-gradient-direction":`to-bottom`,"underlay-padding":10,"underlay-shape":`round-rectangle`,"underlay-corner-radius":`auto`,"text-metrics":`font`,"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(e,t){for(var n=1;n<=df.pieBackgroundN;n++){var r=t.name.replace(`{{i}}`,n);e[r]=t.value}return e},{}),{"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(e,t){for(var n=1;n<=df.stripeBackgroundN;n++){var r=t.name.replace(`{{i}}`,n);e[r]=t.value}return e},{}),{"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},{name:`arrow-scale`,value:`inherit`}].reduce(function(e,t){return df.arrowPrefixes.forEach(function(n){var r=n+`-`+t.name;e[r]=t.value}),e},{})),n={},r=0;r<this.properties.length;r++){var i=this.properties[r];if(!i.pointsTo){var a=i.name,o=t[a];n[a]=this.parse(a,o)}}return e.defaultProperties=n,e.defaultProperties},df.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 ff={};ff.parse=function(e,t,n,r){var i=this;if(ke(t))return i.parseImplWarn(e,t,n,r);var a=r===`mapping`||r===!0||r===!1||r==null?`dontcare`:r,o=n?`t`:`f`,s=Cn(e,``+t,o,a),c=i.propCache=i.propCache||[],l;return(l=c[s])||(l=c[s]=i.parseImplWarn(e,t,n,r)),(n||r===`mapping`)&&(l=Bn(l),l&&(l.value=Bn(l.value))),l},ff.parseImplWarn=function(e,t,n,r){var i=this.parseImpl(e,t,n,r);return!i&&t!=null&&Rn(`The style property \`${e}: ${t}\` is invalid`),i&&(i.name===`width`||i.name===`height`)&&t===`label`&&Rn("The style value of `label` is deprecated for `"+i.name+"`"),i},ff.parseImpl=function(e,t,n,r){var i=this;e=qe(e);var a=i.properties[e],o=t,s=i.types;if(!a||t===void 0)return null;a.alias&&(a=a.pointsTo,e=a.name);var c=Y(t);c&&(t=t.trim());var l=a.type;if(!l)return null;if(n&&(t===``||t===null))return{name:e,value:t,bypass:!0,deleteBypass:!0};if(ke(t))return{name:e,value:t,strValue:`fn`,mapped:s.fn,bypass:n};var u,d;if(!(!c||r||t.length<7||t[1]!==`a`)){if(t.length>=7&&t[0]===`d`&&(u=new RegExp(s.data.regex).exec(t))){if(n)return!1;var f=s.data;return{name:e,value:u,strValue:``+t,mapped:f,field:u[1],bypass:n}}if(t.length>=10&&t[0]===`m`&&(d=new RegExp(s.mapData.regex).exec(t))){if(n||l.multiple)return!1;var p=s.mapData;if(!(l.color||l.number))return!1;var m=this.parse(e,d[4]);if(!m||m.mapped)return!1;var h=this.parse(e,d[5]);if(!h||h.mapped)return!1;if(m.pfValue===h.pfValue||m.strValue===h.strValue)return Rn("`"+e+`: `+t+"` is not a valid mapper because the output range is zero; converting to `"+e+`: `+m.strValue+"`"),this.parse(e,m.strValue);if(l.color){var g=m.value,_=h.value;if(g[0]===_[0]&&g[1]===_[1]&&g[2]===_[2]&&(g[3]===_[3]||(g[3]==null||g[3]===1)&&(_[3]==null||_[3]===1)))return!1}return{name:e,value:d,strValue:``+t,mapped:p,field:d[1],fieldMin:parseFloat(d[2]),fieldMax:parseFloat(d[3]),valueMin:m.value,valueMax:h.value,bypass:n}}}if(l.multiple&&r!==`multiple`){var v=c?t.split(/\s+/):Ae(t)?t:[t];if(l.evenMultiple&&v.length%2!=0)return null;for(var y=[],b=[],x=[],S=``,C=!1,w=0;w<v.length;w++){var T=i.parse(e,v[w],n,`multiple`);C||=Y(T.value),y.push(T.value),x.push(T.pfValue==null?T.value:T.pfValue),b.push(T.units),S+=(w>0?` `:``)+T.strValue}return l.validate&&!l.validate(y,b)?null:l.singleEnum&&C?y.length===1&&Y(y[0])?{name:e,value:y[0],strValue:y[0],bypass:n}:null:{name:e,value:y,pfValue:x,strValue:S,bypass:n,units:b}}var E=function(){for(var r=0;r<l.enums.length;r++)if(l.enums[r]===t)return{name:e,value:t,strValue:``+t,bypass:n};return null};if(l.number){var D,O=`px`;if(l.units&&(D=l.units),l.implicitUnits&&(O=l.implicitUnits),!l.unitless){if(c){var k=`px|em`+(l.allowPercent?`|\\%`:``);D&&(k=D);var A=t.match(`^(`+Qe+`)(`+k+`)?$`);A&&(t=A[1],D=A[2]||O)}else(!D||l.implicitUnits)&&(D=O)}if(t=parseFloat(t),isNaN(t)&&l.enums===void 0)return null;if(isNaN(t)&&l.enums!==void 0)return t=o,E();if(l.integer&&!Ne(t)||l.min!==void 0&&(t<l.min||l.strictMin&&t===l.min)||l.max!==void 0&&(t>l.max||l.strictMax&&t===l.max))return null;var j={name:e,value:t,strValue:``+t+(D||``),units:D,bypass:n};return j.pfValue=l.unitless||D!==`px`&&D!==`em`||D===`px`||!D?t:this.getEmSizeInPixels()*t,(D===`ms`||D===`s`)&&(j.pfValue=D===`ms`?t:1e3*t),(D===`deg`||D===`rad`)&&(j.pfValue=D===`rad`?t:Ir(t)),D===`%`&&(j.pfValue=t/100),j}if(l.propList){var M=[],N=``+t;if(N!==`none`){for(var P=N.split(/\s*,\s*|\s+/),F=0;F<P.length;F++){var I=P[F].trim();i.properties[I]?M.push(I):Rn("`"+I+"` is not a valid property name")}if(M.length===0)return null}return{name:e,value:M,strValue:M.length===0?`none`:M.join(` `),bypass:n}}if(l.color){var L=dt(t);return L?{name:e,value:L,pfValue:L,strValue:L[3]==null?`rgb(`+L[0]+`,`+L[1]+`,`+L[2]+`)`:`rgba(`+L[0]+`,`+L[1]+`,`+L[2]+`,`+L[3]+`)`,bypass:n}:null}if(l.regex||l.regexes){if(l.enums){var R=E();if(R)return R}for(var z=l.regexes?l.regexes:[l.regex],B=0;B<z.length;B++){var V=new RegExp(z[B]).exec(t);if(V)return{name:e,value:l.singleRegexMatchValue?V[1]:V,strValue:``+t,bypass:n}}return null}return l.string?{name:e,value:``+t,strValue:``+t,bypass:n}:l.enums?E():null};var pf=function(e){if(!(this instanceof pf))return new pf(e);Re(e)?(this._private={cy:e,coreStyle:{}},this.length=0,this.resetToDefault()):In(`A style must have a core reference`)},mf=pf.prototype;mf.instanceString=function(){return`style`},mf.clear=function(){for(var e=this._private,t=e.cy.elements(),n=0;n<this.length;n++)this[n]=void 0;return this.length=0,e.contextStyles={},e.propDiffs={},this.cleanElements(t,!0),t.forEach(function(e){var t=e[0]._private;t.styleDirty=!0,t.appliedInitStyle=!1}),this},mf.resetToDefault=function(){return this.clear(),this.addDefaultStylesheet(),this},mf.core=function(e){return this._private.coreStyle[e]||this.getDefaultProperty(e)},mf.selector=function(e){var t=e===`core`?null:new Vl(e),n=this.length++;return this[n]={selector:t,properties:[],mappedProperties:[],index:n},this},mf.css=function(){var e=this,t=arguments;if(t.length===1)for(var n=t[0],r=0;r<e.properties.length;r++){var i=e.properties[r],a=n[i.name];a===void 0&&(a=n[Je(i.name)]),a!==void 0&&this.cssRule(i.name,a)}else t.length===2&&this.cssRule(t[0],t[1]);return this},mf.style=mf.css,mf.cssRule=function(e,t){var n=this.parse(e,t);if(n){var r=this.length-1;this[r].properties.push(n),this[r].properties[n.name]=n,n.name.match(/pie-(\d+)-background-size/)&&n.value&&(this._private.hasPie=!0),n.name.match(/stripe-(\d+)-background-size/)&&n.value&&(this._private.hasStripe=!0),n.mapped&&this[r].mappedProperties.push(n),this[r].selector||(this._private.coreStyle[n.name]=n)}return this},mf.append=function(e){return ze(e)?e.appendToStyle(this):Ae(e)?this.appendFromJson(e):Y(e)&&this.appendFromString(e),this},pf.fromJson=function(e,t){var n=new pf(e);return n.fromJson(t),n},pf.fromString=function(e,t){return new pf(e).fromString(t)},[ef,rf,af,of,sf,cf,df,ff].forEach(function(e){Z(mf,e)}),pf.types=mf.types,pf.properties=mf.properties,pf.propertyGroups=mf.propertyGroups,pf.propertyGroupNames=mf.propertyGroupNames,pf.propertyGroupKeys=mf.propertyGroupKeys;var hf={style:function(e){return e&&this.setStyle(e).update(),this._private.style},setStyle:function(e){var t=this._private;return t.style=ze(e)?e.generateStyle(this):Ae(e)?pf.fromJson(this,e):Y(e)?pf.fromString(this,e):pf(this),t.style},updateStyle:function(){this.mutableElements().updateStyle()}},gf=`single`,_f={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??=gf,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,r,i,a,o;switch(e.length){case 0:return t;case 1:if(Y(e[0]))return n=e[0],t[n];if(je(e[0])){if(!this._private.panningEnabled)return this;i=e[0],a=i.x,o=i.y,X(a)&&(t.x=a),X(o)&&(t.y=o),this.emit(`pan viewport`)}break;case 2:if(!this._private.panningEnabled)return this;n=e[0],r=e[1],(n===`x`||n===`y`)&&X(r)&&(t[n]=r),this.emit(`pan viewport`)}return this.notify(`viewport`),this},panBy:function(e,t){var n=arguments,r=this._private.pan,i,a,o,s,c;if(!this._private.panningEnabled)return this;switch(n.length){case 1:je(e)&&(o=n[0],s=o.x,c=o.y,X(s)&&(r.x+=s),X(c)&&(r.y+=c),this.emit(`pan viewport`));break;case 2:i=e,a=t,(i===`x`||i===`y`)&&X(a)&&(r[i]+=a),this.emit(`pan viewport`)}return this.notify(`viewport`),this},gc:function(){this.notify(`gc`)},fit:function(e,t){var n=this.getFitViewport(e,t);if(n){var r=this._private;r.zoom=n.zoom,r.pan=n.pan,this.emit(`pan zoom viewport`),this.notify(`viewport`)}return this},getFitViewport:function(e,t){if(X(e)&&t===void 0&&(t=e,e=void 0),this._private.panningEnabled&&this._private.zoomingEnabled){var n;if(Y(e)){var r=e;e=this.$(r)}else if(Ue(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 Fe(e)||(e=this.mutableElements());if(!(Fe(e)&&e.empty())){n||=e.boundingBox();var a=this.width(),o=this.height(),s;if(t=X(t)?t:0,!isNaN(a)&&!isNaN(o)&&a>0&&o>0&&!isNaN(n.w)&&!isNaN(n.h)&&n.w>0&&n.h>0){s=Math.min((a-2*t)/n.w,(o-2*t)/n.h),s=s>this._private.maxZoom?this._private.maxZoom:s,s=s<this._private.minZoom?this._private.minZoom:s;var c={x:(a-s*(n.x1+n.x2))/2,y:(o-s*(n.y1+n.y2))/2};return{zoom:s,pan:c}}}}},zoomRange:function(e,t){var n=this._private;if(t==null){var r=e;e=r.min,t=r.max}return X(e)&&X(t)&&e<=t?(n.minZoom=e,n.maxZoom=t):X(e)&&t===void 0&&e<=n.maxZoom?n.minZoom=e:X(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,r=t.zoom,i,a,o=!1;if(t.zoomingEnabled||(o=!0),X(e)?a=e:je(e)&&(a=e.level,e.position==null?e.renderedPosition!=null&&(i=e.renderedPosition):i=Er(e.position,r,n),i!=null&&!t.panningEnabled&&(o=!0)),a=a>t.maxZoom?t.maxZoom:a,a=a<t.minZoom?t.minZoom:a,o||!X(a)||a===r||i!=null&&(!X(i.x)||!X(i.y)))return null;if(i!=null){var s=n,c=r,l=a;return{zoomed:!0,panned:!0,zoom:l,pan:{x:-l/c*(i.x-s.x)+i.x,y:-l/c*(i.y-s.y)+i.y}}}return{zoomed:!0,panned:!1,zoom:a,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||(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,r=!0,i=[],a=!1,o=!1;if(!e||(X(e.zoom)||(n=!1),je(e.pan)||(r=!1),!n&&!r))return this;if(n){var s=e.zoom;s<t.minZoom||s>t.maxZoom||!t.zoomingEnabled?a=!0:(t.zoom=s,i.push(`zoom`))}if(r&&(!a||!e.cancelOnFailedZoom)&&t.panningEnabled){var c=e.pan;X(c.x)&&(t.pan.x=c.x,o=!1),X(c.y)&&(t.pan.y=c.y,o=!1),o||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(Y(e)){var n=e;e=this.mutableElements().filter(n)}else Fe(e)||(e=this.mutableElements());if(e.length!==0){var r=e.boundingBox(),i=this.width(),a=this.height();return t=t===void 0?this._private.zoom:t,{x:(i-t*(r.x1+r.x2))/2,y:(a-t*(r.y1+r.y2))/2}}}},reset:function(){return!this._private.panningEnabled||!this._private.zoomingEnabled||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 e=n.window().getComputedStyle(t),r=function(t){return parseFloat(e.getPropertyValue(t))};return{width:t.clientWidth-r(`padding-left`)-r(`padding-right`),height:t.clientHeight-r(`padding-top`)-r(`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(),r={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 r.w=r.x2-r.x1,r.h=r.y2-r.y1,r},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}};_f.centre=_f.center,_f.autolockNodes=_f.autolock,_f.autoungrabifyNodes=_f.autoungrabify;var vf={data:vl.data({field:`data`,bindingEvent:`data`,allowBinding:!0,allowSetting:!0,settingEvent:`data`,settingTriggersEvent:!0,triggerFnName:`trigger`,allowGetting:!0,updateStyle:!0}),removeData:vl.removeData({field:`data`,event:`data`,triggerFnName:`trigger`,triggerEvent:!0,updateStyle:!0}),scratch:vl.data({field:`scratch`,bindingEvent:`scratch`,allowBinding:!0,allowSetting:!0,settingEvent:`scratch`,settingTriggersEvent:!0,triggerFnName:`trigger`,allowGetting:!0,updateStyle:!0}),removeScratch:vl.removeData({field:`scratch`,event:`scratch`,triggerFnName:`trigger`,triggerEvent:!0,updateStyle:!0})};vf.attr=vf.data,vf.removeAttr=vf.removeData;var yf=function(e){var t=this;e=Z({},e);var n=e.container;n&&!Pe(n)&&Pe(n[0])&&(n=n[0]);var r=n?n._cyreg:null;r||={},r&&r.cy&&(r.cy.destroy(),r={});var i=r.readies=r.readies||[];n&&(n._cyreg=r),r.cy=t;var a=Se!==void 0&&n!==void 0&&!e.headless,o=e;o.layout=Z({name:a?`grid`:`null`},o.layout),o.renderer=Z({name:a?`canvas`:`null`},o.renderer);var s=function(e,t,n){return t===void 0?n===void 0?e:n:t},c=this._private={container:n,ready:!1,options:o,elements:new Od(this),listeners:[],aniEles:new Od(this),data:o.data||{},scratch:{},layout:null,renderer:null,destroyed:!1,notificationsEnabled:!0,minZoom:1e-50,maxZoom:1e50,zoomingEnabled:s(!0,o.zoomingEnabled),userZoomingEnabled:s(!0,o.userZoomingEnabled),panningEnabled:s(!0,o.panningEnabled),userPanningEnabled:s(!0,o.userPanningEnabled),boxSelectionEnabled:s(!0,o.boxSelectionEnabled),autolock:s(!1,o.autolock,o.autolockNodes),autoungrabify:s(!1,o.autoungrabify,o.autoungrabifyNodes),autounselectify:s(!1,o.autounselectify),styleEnabled:o.styleEnabled===void 0?a:o.styleEnabled,zoom:X(o.zoom)?o.zoom:1,pan:{x:je(o.pan)&&X(o.pan.x)?o.pan.x:0,y:je(o.pan)&&X(o.pan.y)?o.pan.y:0},animation:{current:[],queue:[]},hasCompoundNodes:!1,multiClickDebounceTime:s(250,o.multiClickDebounceTime)};this.createEmitter(),this.selectionType(o.selectionType),this.zoomRange({min:o.minZoom,max:o.maxZoom});var l=function(e,t){if(e.some(We))return vo.all(e).then(t);t(e)};c.styleEnabled&&t.setStyle([]);var u=Z({},o,o.renderer);t.initRenderer(u);var d=function(e,n,r){t.notifications(!1);var i=t.mutableElements();i.length>0&&i.remove(),e!=null&&(je(e)||Ae(e))&&t.add(e),t.one(`layoutready`,function(e){t.notifications(!0),t.emit(e),t.one(`load`,n),t.emitAndNotify(`load`)}).one(`layoutstop`,function(){t.one(`done`,r),t.emit(`done`)});var a=Z({},t._private.options.layout);a.eles=t.elements(),t.layout(a).run()};l([o.style,o.elements],function(e){var n=e[0],a=e[1];c.styleEnabled&&t.style().append(n),d(a,function(){t.startAnimationLoop(),c.ready=!0,ke(o.ready)&&t.on(`ready`,o.ready);for(var e=0;e<i.length;e++){var n=i[e];t.on(`ready`,n)}r&&(r.readies=[]),t.emit(`ready`)},o.done)})},bf=yf.prototype;Z(bf,{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(){if(this._private.container==null)return Se;var e=this._private.container.ownerDocument;return e===void 0||e==null?Se:e.defaultView||Se},mount:function(e){if(e!=null){var t=this,n=t._private,r=n.options;return!Pe(e)&&Pe(e[0])&&(e=e[0]),t.stopAnimationLoop(),t.destroyRenderer(),n.container=e,n.styleEnabled=!0,t.invalidateSize(),t.initRenderer(Z({},r,r.renderer,{name:r.renderer.name===`null`?`canvas`:r.renderer.name})),t.startAnimationLoop(),t.style(r.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 Bn(this._private.options)},json:function(e){var t=this,n=t._private,r=t.mutableElements(),i=function(e){return t.getElementById(e.id())};if(je(e)){if(t.startBatch(),e.elements){var a={},o=function(e,n){for(var r=[],i=[],o=0;o<e.length;o++){var s=e[o];if(!s.data.id)Rn(`cy.json() cannot handle elements without an ID attribute`);else{var c=``+s.data.id,l=t.getElementById(c);a[c]=!0,l.length===0?(n&&(s.group=n),r.push(s)):i.push({ele:l,json:s})}}t.add(r);for(var u=0;u<i.length;u++){var d=i[u],f=d.ele,p=d.json;f.json(p)}};if(Ae(e.elements))o(e.elements);else for(var s=[`nodes`,`edges`],c=0;c<s.length;c++){var l=s[c],u=e.elements[l];Ae(u)&&o(u,l)}var d=t.collection();r.filter(function(e){return!a[e.id()]}).forEach(function(e){e.isParent()?d.merge(e):e.remove()}),d.forEach(function(e){return e.children().move({parent:null})}),d.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 f=[`minZoom`,`maxZoom`,`zoomingEnabled`,`userZoomingEnabled`,`panningEnabled`,`userPanningEnabled`,`boxSelectionEnabled`,`autolock`,`autoungrabify`,`autounselectify`,`multiClickDebounceTime`],p=0;p<f.length;p++){var m=f[p];e[m]!=null&&t[m](e[m])}return t.endBatch(),this}var h=!!e,g={};h?g.elements=this.elements().map(function(e){return e.json()}):(g.elements={},r.forEach(function(e){var t=e.group();g.elements[t]||(g.elements[t]=[]),g.elements[t].push(e.json())})),this._private.styleEnabled&&(g.style=t.style().json()),g.data=Bn(t.data());var _=n.options;return g.zoomingEnabled=n.zoomingEnabled,g.userZoomingEnabled=n.userZoomingEnabled,g.zoom=n.zoom,g.minZoom=n.minZoom,g.maxZoom=n.maxZoom,g.panningEnabled=n.panningEnabled,g.userPanningEnabled=n.userPanningEnabled,g.pan=Bn(n.pan),g.boxSelectionEnabled=n.boxSelectionEnabled,g.renderer=Bn(_.renderer),g.hideEdgesOnViewport=_.hideEdgesOnViewport,g.textureOnViewport=_.textureOnViewport,g.wheelSensitivity=_.wheelSensitivity,g.motionBlur=_.motionBlur,g.multiClickDebounceTime=_.multiClickDebounceTime,g}}),bf.$id=bf.getElementById,[Ad,Wd,qd,Jd,Yd,Xd,Qd,$d,hf,_f,vf].forEach(function(e){Z(bf,e)});var xf={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}},Sf={maximal:!1,acyclic:!1},Cf=function(e){return e.scratch(`breadthfirst`)},wf=function(e,t){return e.scratch(`breadthfirst`,t)};function Tf(e){this.options=Z({},xf,Sf,e)}Tf.prototype.run=function(){var e=this.options,t=e.cy,n=e.eles,r=n.nodes().filter(function(e){return e.isChildless()}),i=n,a=e.directed,o=e.acyclic||e.maximal||e.maximalAdjustments>0,s=!!e.boundingBox,c=qr(s?e.boundingBox:structuredClone(t.extent())),l;if(Fe(e.roots))l=e.roots;else if(Ae(e.roots)){for(var u=[],d=0;d<e.roots.length;d++){var f=e.roots[d],p=t.getElementById(f);u.push(p)}l=t.collection(u)}else if(Y(e.roots))l=t.$(e.roots);else if(a)l=r.roots();else{var m=n.components();l=t.collection();for(var h=function(){var e=m[g],t=e.maxDegree(!1),n=e.filter(function(e){return e.degree(!1)===t});l=l.add(n)},g=0;g<m.length;g++)h()}var _=[],v={},y=function(e,t){_[t]??(_[t]=[]);var n=_[t].length;_[t].push(e),wf(e,{index:n,depth:t})},b=function(e,t){var n=Cf(e),r=n.depth,i=n.index;_[r][i]=null,e.isChildless()&&y(e,t)};i.bfs({roots:l,directed:e.directed,visit:function(e,t,n,r,i){var a=e[0],o=a.id();a.isChildless()&&y(a,i),v[o]=!0}});for(var x=[],S=0;S<r.length;S++){var C=r[S];v[C.id()]||x.push(C)}var w=function(e){for(var t=_[e],n=0;n<t.length;n++){var r=t[n];r==null?(t.splice(n,1),n--):wf(r,{depth:e,index:n})}},T=function(t,r){for(var i=Cf(t),a=t.incomers().filter(function(e){return e.isNode()&&n.has(e)}),o=-1,s=t.id(),c=0;c<a.length;c++){var l=a[c],u=Cf(l);o=Math.max(o,u.depth)}if(i.depth<=o){if(!e.acyclic&&r[s])return null;var d=o+1;return b(t,d),r[s]=d,!0}return!1};if(a&&o){var E=[],D={},O=function(e){return E.push(e)},k=function(){return E.shift()};for(r.forEach(function(e){return E.push(e)});E.length>0;){var A=k(),j=T(A,D);if(j)A.outgoers().filter(function(e){return e.isNode()&&n.has(e)}).forEach(O);else if(j===null){Rn("Detected double maximal shift for node `"+A.id()+"`. Bailing maximal adjustment due to cycle. Use `options.maximal: true` only on DAGs.");break}}}var M=0;if(e.avoidOverlap)for(var N=0;N<r.length;N++){var P=r[N].layoutDimensions(e),F=P.w,I=P.h;M=Math.max(M,F,I)}var L={},R=function(e){if(L[e.id()])return L[e.id()];for(var t=Cf(e).depth,n=e.neighborhood(),i=0,a=0,o=0;o<n.length;o++){var s=n[o];if(!(s.isEdge()||s.isParent()||!r.has(s))){var c=Cf(s);if(c!=null){var l=c.index,u=c.depth;if(l!=null&&u!=null){var d=_[u].length;u<t&&(i+=l/d,a++)}}}}return a=Math.max(1,a),i/=a,a===0&&(i=0),L[e.id()]=i,i},z=function(e,t){var n=R(e)-R(t);return n===0?at(e.id(),t.id()):n};e.depthSort!==void 0&&(z=e.depthSort);for(var B=_.length,V=0;V<B;V++)_[V].sort(z),w(V);for(var H=[],U=0;U<x.length;U++)H.push(x[U]);H.length&&(_.unshift(H),B=_.length,function(){for(var e=0;e<B;e++)w(e)}());for(var W=0,ee=0;ee<B;ee++)W=Math.max(_[ee].length,W);var G={x:c.x1+c.w/2,y:c.y1+c.h/2},K=r.reduce(function(t,n){return function(e){return{w:t.w===-1?e.w:(t.w+e.w)/2,h:t.h===-1?e.h:(t.h+e.h)/2}}(n.boundingBox({includeLabels:e.nodeDimensionsIncludeLabels}))},{w:-1,h:-1}),q=Math.max(B===1?0:s?(c.h-e.padding*2-K.h)/(B-1):(c.h-e.padding*2-K.h)/(B+1),M),J=_.reduce(function(e,t){return Math.max(e,t.length)},0),te=function(t){var n=Cf(t),r=n.depth,i=n.index;if(e.circle){var a=Math.min(c.w/2/B,c.h/2/B);a=Math.max(a,M);var o=a*r+a-(B>0&&_[0].length<=3?a/2:0),l=2*Math.PI/_[r].length*i;return r===0&&_[0].length===1&&(o=1),{x:G.x+o*Math.cos(l),y:G.y+o*Math.sin(l)}}var u=_[r].length,d=Math.max(u===1?0:s?(c.w-e.padding*2-K.w)/((e.grid?J:u)-1):(c.w-e.padding*2-K.w)/((e.grid?J:u)+1),M);return{x:G.x+(i+1-(u+1)/2)*d,y:G.y+(r+1-(B+1)/2)*q}},ne={downward:0,leftward:90,upward:180,rightward:-90};return Object.keys(ne).indexOf(e.direction)===-1&&In(`Invalid direction '${e.direction}' specified for breadthfirst layout. Valid values are: ${Object.keys(ne).join(`, `)}`),n.nodes().layoutPositions(this,e,function(t){return Dn(te(t),c,ne[e.direction])}),this};var Ef={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 Df(e){this.options=Z({},Ef,e)}Df.prototype.run=function(){var e=this.options,t=e,n=e.cy,r=t.eles,i=t.counterclockwise===void 0?t.clockwise:!t.counterclockwise,a=r.nodes().not(`:parent`);t.sort&&(a=a.sort(t.sort));for(var o=qr(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()}),s={x:o.x1+o.w/2,y:o.y1+o.h/2},c=(t.sweep===void 0?2*Math.PI-2*Math.PI/a.length:t.sweep)/Math.max(1,a.length-1),l,u=0,d=0;d<a.length;d++){var f=a[d].layoutDimensions(t),p=f.w,m=f.h;u=Math.max(u,p,m)}if(l=X(t.radius)?t.radius:a.length<=1?0:Math.min(o.h,o.w)/2-u,a.length>1&&t.avoidOverlap){u*=1.75;var h=Math.cos(c)-Math.cos(0),g=Math.sin(c)-Math.sin(0),_=Math.sqrt(u*u/(h*h+g*g));l=Math.max(_,l)}return r.nodes().layoutPositions(this,t,function(e,n){var r=t.startAngle+n*c*(i?1:-1),a=l*Math.cos(r),o=l*Math.sin(r);return{x:s.x+a,y:s.y+o}}),this};var Of={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 kf(e){this.options=Z({},Of,e)}kf.prototype.run=function(){for(var e=this.options,t=e,n=t.counterclockwise===void 0?t.clockwise:!t.counterclockwise,r=e.cy,i=t.eles,a=i.nodes().not(`:parent`),o=qr(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:r.width(),h:r.height()}),s={x:o.x1+o.w/2,y:o.y1+o.h/2},c=[],l=0,u=0;u<a.length;u++){var d=a[u],f=void 0;f=t.concentric(d),c.push({value:f,node:d}),d._private.scratch.concentric=f}a.updateStyle();for(var p=0;p<a.length;p++){var m=a[p].layoutDimensions(t);l=Math.max(l,m.w,m.h)}c.sort(function(e,t){return t.value-e.value});for(var h=t.levelWidth(a),g=[[]],_=g[0],v=0;v<c.length;v++){var y=c[v];_.length>0&&Math.abs(_[0].value-y.value)>=h&&(_=[],g.push(_)),_.push(y)}var b=l+t.minNodeSpacing;if(!t.avoidOverlap){var x=g.length>0&&g[0].length>1,S=(Math.min(o.w,o.h)/2-b)/(g.length+x?1:0);b=Math.min(b,S)}for(var C=0,w=0;w<g.length;w++){var T=g[w],E=T.dTheta=(t.sweep===void 0?2*Math.PI-2*Math.PI/T.length:t.sweep)/Math.max(1,T.length-1);if(T.length>1&&t.avoidOverlap){var D=Math.cos(E)-Math.cos(0),O=Math.sin(E)-Math.sin(0),k=Math.sqrt(b*b/(D*D+O*O));C=Math.max(k,C)}T.r=C,C+=b}if(t.equidistant){for(var A=0,j=0,M=0;M<g.length;M++){var N=g[M].r-j;A=Math.max(A,N)}j=0;for(var P=0;P<g.length;P++){var F=g[P];P===0&&(j=F.r),F.r=j,j+=A}}for(var I={},L=0;L<g.length;L++)for(var R=g[L],z=R.dTheta,B=R.r,V=0;V<R.length;V++){var H=R[V],U=t.startAngle+(n?1:-1)*z*V,W={x:s.x+B*Math.cos(U),y:s.y+B*Math.sin(U)};I[H.node.id()]=W}return i.nodes().layoutPositions(this,t,function(e){return I[e.id()]}),this};var Af,jf={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 Mf(e){this.options=Z({},jf,e),this.options.layout=this;var t=this.options.eles.nodes(),n=this.options.eles.edges().filter(function(e){var n=e.source().data(`id`),r=e.target().data(`id`),i=t.hasElementWithId(n),a=t.hasElementWithId(r);return!i||!a});this.options.eles=this.options.eles.not(n)}Mf.prototype.run=function(){var e=this.options,t=e.cy,n=this;n.stopped=!1,(e.animate===!0||e.animate===!1)&&n.emit({type:`layoutstart`,layout:n}),Af=!0===e.debug;var r=Nf(t,n,e);Af&&If(r),e.randomize&&Lf(r);var i=dn(),a=function(){zf(r,t,e),!0===e.fit&&t.fit(e.padding)},o=function(t){return!(n.stopped||t>=e.numIter||(Bf(r,e),r.temperature*=e.coolingFactor,r.temperature<e.minTemp))},s=function(){if(e.animate===!0||e.animate===!1)a(),n.one(`layoutstop`,e.stop),n.emit({type:`layoutstop`,layout:n});else{var t=e.eles.nodes(),i=Rf(r,e,t);t.layoutPositions(n,e,i)}},c=0,l=!0;if(e.animate===!0){var u=function(){for(var t=0;l&&t<e.refresh;)l=o(c),c++,t++;l?(dn()-i>=e.animationThreshold&&a(),un(u)):(Qf(r,e),s())};u()}else{for(;l;)l=o(c),c++;Qf(r,e),s()}return this},Mf.prototype.stop=function(){return this.stopped=!0,this.thread&&this.thread.stop(),this.emit(`layoutstop`),this},Mf.prototype.destroy=function(){return this.thread&&this.thread.stop(),this};var Nf=function(e,t,n){for(var r=n.eles.edges(),i=n.eles.nodes(),a=qr(n.boundingBox?n.boundingBox:{x1:0,y1:0,w:e.width(),h:e.height()}),o={isCompound:e.hasCompoundNodes(),layoutNodes:[],idToIndex:{},nodeSize:i.size(),graphSet:[],indexToGraph:[],layoutEdges:[],edgeSize:r.size(),temperature:n.initialTemp,clientWidth:a.w,clientHeight:a.h,boundingBox:a},s=n.eles.components(),c={},l=0;l<s.length;l++)for(var u=s[l],d=0;d<u.length;d++){var f=u[d];c[f.id()]=l}for(var l=0;l<o.nodeSize;l++){var p=i[l],m=p.layoutDimensions(n),h={};h.isLocked=p.locked(),h.id=p.data(`id`),h.parentId=p.data(`parent`),h.cmptId=c[p.id()],h.children=[],h.positionX=p.position(`x`),h.positionY=p.position(`y`),h.offsetX=0,h.offsetY=0,h.height=m.w,h.width=m.h,h.maxX=h.positionX+h.width/2,h.minX=h.positionX-h.width/2,h.maxY=h.positionY+h.height/2,h.minY=h.positionY-h.height/2,h.padLeft=parseFloat(p.style(`padding`)),h.padRight=parseFloat(p.style(`padding`)),h.padTop=parseFloat(p.style(`padding`)),h.padBottom=parseFloat(p.style(`padding`)),h.nodeRepulsion=ke(n.nodeRepulsion)?n.nodeRepulsion(p):n.nodeRepulsion,o.layoutNodes.push(h),o.idToIndex[h.id]=l}for(var g=[],_=0,v=-1,y=[],l=0;l<o.nodeSize;l++){var p=o.layoutNodes[l],b=p.parentId;b==null?(g[++v]=p.id,y.push(p.id)):o.layoutNodes[o.idToIndex[b]].children.push(p.id)}for(o.graphSet.push(y);_<=v;){var x=g[_++],S=o.idToIndex[x],f=o.layoutNodes[S],C=f.children;if(C.length>0){o.graphSet.push(C);for(var l=0;l<C.length;l++)g[++v]=C[l]}}for(var l=0;l<o.graphSet.length;l++)for(var w=o.graphSet[l],d=0;d<w.length;d++){var T=o.idToIndex[w[d]];o.indexToGraph[T]=l}for(var l=0;l<o.edgeSize;l++){var E=r[l],D={};D.id=E.data(`id`),D.sourceId=E.data(`source`),D.targetId=E.data(`target`);var O=ke(n.idealEdgeLength)?n.idealEdgeLength(E):n.idealEdgeLength,k=ke(n.edgeElasticity)?n.edgeElasticity(E):n.edgeElasticity,A=o.idToIndex[D.sourceId],j=o.idToIndex[D.targetId];if(o.indexToGraph[A]!=o.indexToGraph[j]){for(var M=Pf(D.sourceId,D.targetId,o),N=o.graphSet[M],P=0,h=o.layoutNodes[A];N.indexOf(h.id)===-1;)h=o.layoutNodes[o.idToIndex[h.parentId]],P++;for(h=o.layoutNodes[j];N.indexOf(h.id)===-1;)h=o.layoutNodes[o.idToIndex[h.parentId]],P++;O*=P*n.nestingFactor}D.idealLength=O,D.elasticity=k,o.layoutEdges.push(D)}return o},Pf=function(e,t,n){var r=Ff(e,t,0,n);return 2>r.count?0:r.graph},Ff=function(e,t,n,r){var i=r.graphSet[n];if(-1<i.indexOf(e)&&-1<i.indexOf(t))return{count:2,graph:n};for(var a=0,o=0;o<i.length;o++){var s=i[o],c=r.idToIndex[s],l=r.layoutNodes[c].children;if(l.length!==0){var u=r.indexToGraph[r.idToIndex[l[0]]],d=Ff(e,t,u,r);if(d.count!==0){if(d.count===1){if(a++,a===2)break}else return d}}}return{count:a,graph:n}},If,Lf=function(e,t){for(var n=e.clientWidth,r=e.clientHeight,i=0;i<e.nodeSize;i++){var a=e.layoutNodes[i];a.children.length===0&&!a.isLocked&&(a.positionX=Math.random()*n,a.positionY=Math.random()*r)}},Rf=function(e,t,n){var r=e.boundingBox,i={x1:1/0,x2:-1/0,y1:1/0,y2:-1/0};return t.boundingBox&&(n.forEach(function(t){var n=e.layoutNodes[e.idToIndex[t.data(`id`)]];i.x1=Math.min(i.x1,n.positionX),i.x2=Math.max(i.x2,n.positionX),i.y1=Math.min(i.y1,n.positionY),i.y2=Math.max(i.y2,n.positionY)}),i.w=i.x2-i.x1,i.h=i.y2-i.y1),function(n,a){var o=e.layoutNodes[e.idToIndex[n.data(`id`)]];if(t.boundingBox){var s=i.w===0?.5:(o.positionX-i.x1)/i.w,c=i.h===0?.5:(o.positionY-i.y1)/i.h;return{x:r.x1+s*r.w,y:r.y1+c*r.h}}return{x:o.positionX,y:o.positionY}}},zf=function(e,t,n){var r=n.layout,i=n.eles.nodes(),a=Rf(e,n,i);i.positions(a),!0!==e.ready&&(e.ready=!0,r.one(`layoutready`,n.ready),r.emit({type:`layoutready`,layout:this}))},Bf=function(e,t,n){Vf(e,t),Kf(e),qf(e,t),Jf(e),Yf(e)},Vf=function(e,t){for(var n=0;n<e.graphSet.length;n++)for(var r=e.graphSet[n],i=r.length,a=0;a<i;a++)for(var o=e.layoutNodes[e.idToIndex[r[a]]],s=a+1;s<i;s++){var c=e.layoutNodes[e.idToIndex[r[s]]];Uf(o,c,e,t)}},Hf=function(e){return-e+2*e*Math.random()},Uf=function(e,t,n,r){if(e.cmptId===t.cmptId||n.isCompound){var i=t.positionX-e.positionX,a=t.positionY-e.positionY,o=1;i===0&&a===0&&(i=Hf(o),a=Hf(o));var s=Wf(e,t,i,a);if(s>0)var c=r.nodeOverlap*s,l=Math.sqrt(i*i+a*a),u=c*i/l,d=c*a/l;else var f=Gf(e,i,a),p=Gf(t,-1*i,-1*a),m=p.x-f.x,h=p.y-f.y,g=m*m+h*h,l=Math.sqrt(g),c=(e.nodeRepulsion+t.nodeRepulsion)/g,u=c*m/l,d=c*h/l;e.isLocked||(e.offsetX-=u,e.offsetY-=d),t.isLocked||(t.offsetX+=u,t.offsetY+=d)}},Wf=function(e,t,n,r){if(n>0)var i=e.maxX-t.minX;else var i=t.maxX-e.minX;if(r>0)var a=e.maxY-t.minY;else var a=t.maxY-e.minY;return i>=0&&a>=0?Math.sqrt(i*i+a*a):0},Gf=function(e,t,n){var r=e.positionX,i=e.positionY,a=e.height||1,o=e.width||1,s=n/t,c=a/o,l={};return t===0&&0<n||t===0&&0>n?(l.x=r,l.y=i+a/2,l):0<t&&-1*c<=s&&s<=c?(l.x=r+o/2,l.y=i+o*n/2/t,l):0>t&&-1*c<=s&&s<=c?(l.x=r-o/2,l.y=i-o*n/2/t,l):0<n&&(s<=-1*c||s>=c)?(l.x=r+a*t/2/n,l.y=i+a/2,l):(0>n&&(s<=-1*c||s>=c)&&(l.x=r-a*t/2/n,l.y=i-a/2),l)},Kf=function(e,t){for(var n=0;n<e.edgeSize;n++){var r=e.layoutEdges[n],i=e.idToIndex[r.sourceId],a=e.layoutNodes[i],o=e.idToIndex[r.targetId],s=e.layoutNodes[o],c=s.positionX-a.positionX,l=s.positionY-a.positionY;if(c!==0||l!==0){var u=Gf(a,c,l),d=Gf(s,-1*c,-1*l),f=d.x-u.x,p=d.y-u.y,m=Math.sqrt(f*f+p*p),h=(r.idealLength-m)**2/r.elasticity;if(m!==0)var g=h*f/m,_=h*p/m;else var g=0,_=0;a.isLocked||(a.offsetX+=g,a.offsetY+=_),s.isLocked||(s.offsetX-=g,s.offsetY-=_)}}},qf=function(e,t){if(t.gravity!==0)for(var n=1,r=0;r<e.graphSet.length;r++){var i=e.graphSet[r],a=i.length;if(r===0)var o=e.clientHeight/2,s=e.clientWidth/2;else var c=e.layoutNodes[e.idToIndex[i[0]]],l=e.layoutNodes[e.idToIndex[c.parentId]],o=l.positionX,s=l.positionY;for(var u=0;u<a;u++){var d=e.layoutNodes[e.idToIndex[i[u]]];if(!d.isLocked){var f=o-d.positionX,p=s-d.positionY,m=Math.sqrt(f*f+p*p);if(m>n){var h=t.gravity*f/m,g=t.gravity*p/m;d.offsetX+=h,d.offsetY+=g}}}}},Jf=function(e,t){var n=[],r=0,i=-1;for(n.push.apply(n,e.graphSet[0]),i+=e.graphSet[0].length;r<=i;){var a=n[r++],o=e.idToIndex[a],s=e.layoutNodes[o],c=s.children;if(0<c.length&&!s.isLocked){for(var l=s.offsetX,u=s.offsetY,d=0;d<c.length;d++){var f=e.layoutNodes[e.idToIndex[c[d]]];f.offsetX+=l,f.offsetY+=u,n[++i]=c[d]}s.offsetX=0,s.offsetY=0}}},Yf=function(e,t){for(var n=0;n<e.nodeSize;n++){var r=e.layoutNodes[n];0<r.children.length&&(r.maxX=void 0,r.minX=void 0,r.maxY=void 0,r.minY=void 0)}for(var n=0;n<e.nodeSize;n++){var r=e.layoutNodes[n];if(!(0<r.children.length||r.isLocked)){var i=Xf(r.offsetX,r.offsetY,e.temperature);r.positionX+=i.x,r.positionY+=i.y,r.offsetX=0,r.offsetY=0,r.minX=r.positionX-r.width,r.maxX=r.positionX+r.width,r.minY=r.positionY-r.height,r.maxY=r.positionY+r.height,Zf(r,e)}}for(var n=0;n<e.nodeSize;n++){var r=e.layoutNodes[n];0<r.children.length&&!r.isLocked&&(r.positionX=(r.maxX+r.minX)/2,r.positionY=(r.maxY+r.minY)/2,r.width=r.maxX-r.minX,r.height=r.maxY-r.minY)}},Xf=function(e,t,n){var r=Math.sqrt(e*e+t*t);if(r>n)var i={x:n*e/r,y:n*t/r};else var i={x:e,y:t};return i},Zf=function(e,t){var n=e.parentId;if(n!=null){var r=t.layoutNodes[t.idToIndex[n]],i=!1;if((r.maxX==null||e.maxX+r.padRight>r.maxX)&&(r.maxX=e.maxX+r.padRight,i=!0),(r.minX==null||e.minX-r.padLeft<r.minX)&&(r.minX=e.minX-r.padLeft,i=!0),(r.maxY==null||e.maxY+r.padBottom>r.maxY)&&(r.maxY=e.maxY+r.padBottom,i=!0),(r.minY==null||e.minY-r.padTop<r.minY)&&(r.minY=e.minY-r.padTop,i=!0),i)return Zf(r,t)}},Qf=function(e,t){for(var n=e.layoutNodes,r=[],i=0;i<n.length;i++){var a=n[i],o=a.cmptId;(r[o]=r[o]||[]).push(a)}for(var s=0,i=0;i<r.length;i++){var c=r[i];if(c){c.x1=1/0,c.x2=-1/0,c.y1=1/0,c.y2=-1/0;for(var l=0;l<c.length;l++){var u=c[l];c.x1=Math.min(c.x1,u.positionX-u.width/2),c.x2=Math.max(c.x2,u.positionX+u.width/2),c.y1=Math.min(c.y1,u.positionY-u.height/2),c.y2=Math.max(c.y2,u.positionY+u.height/2)}c.w=c.x2-c.x1,c.h=c.y2-c.y1,s+=c.w*c.h}}r.sort(function(e,t){return t.w*t.h-e.w*e.h});for(var d=0,f=0,p=0,m=0,h=Math.sqrt(s)*e.clientWidth/e.clientHeight,i=0;i<r.length;i++){var c=r[i];if(c){for(var l=0;l<c.length;l++){var u=c[l];u.isLocked||(u.positionX+=d-c.x1,u.positionY+=f-c.y1)}d+=c.w+t.componentSpacing,p+=c.w+t.componentSpacing,m=Math.max(m,c.h),p>h&&(f+=m+t.componentSpacing,d=0,p=0,m=0)}}},$f={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 ep(e){this.options=Z({},$f,e)}ep.prototype.run=function(){var e=this.options,t=e,n=e.cy,r=t.eles,i=r.nodes().not(`:parent`);t.sort&&(i=i.sort(t.sort));var a=qr(t.boundingBox?t.boundingBox:{x1:0,y1:0,w:n.width(),h:n.height()});if(a.h===0||a.w===0)r.nodes().layoutPositions(this,t,function(e){return{x:a.x1,y:a.y1}});else{var o=i.size(),s=Math.sqrt(o*a.h/a.w),c=Math.round(s),l=Math.round(a.w/a.h*s),u=function(e){if(e==null)return Math.min(c,l);Math.min(c,l)==c?c=e:l=e},d=function(e){if(e==null)return Math.max(c,l);Math.max(c,l)==c?c=e:l=e},f=t.rows,p=t.cols==null?t.columns:t.cols;if(f!=null&&p!=null)c=f,l=p;else if(f!=null&&p==null)c=f,l=Math.ceil(o/c);else if(f==null&&p!=null)l=p,c=Math.ceil(o/l);else if(l*c>o){var m=u(),h=d();(m-1)*h>=o?u(m-1):(h-1)*m>=o&&d(h-1)}else for(;l*c<o;){var g=u(),_=d();(_+1)*g>=o?d(_+1):u(g+1)}var v=a.w/l,y=a.h/c;if(t.condense&&(v=0,y=0),t.avoidOverlap)for(var b=0;b<i.length;b++){var x=i[b],S=x._private.position;(S.x==null||S.y==null)&&(S.x=0,S.y=0);var C=x.layoutDimensions(t),w=t.avoidOverlapPadding,T=C.w+w,E=C.h+w;v=Math.max(v,T),y=Math.max(y,E)}for(var D={},O=function(e,t){return!!D[`c-`+e+`-`+t]},k=function(e,t){D[`c-`+e+`-`+t]=!0},A=0,j=0,M=function(){j++,j>=l&&(j=0,A++)},N={},P=0;P<i.length;P++){var F=i[P],I=t.position(F);if(I&&(I.row!==void 0||I.col!==void 0)){var L={row:I.row,col:I.col};if(L.col===void 0)for(L.col=0;O(L.row,L.col);)L.col++;else if(L.row===void 0)for(L.row=0;O(L.row,L.col);)L.row++;N[F.id()]=L,k(L.row,L.col)}}i.layoutPositions(this,t,function(e,t){var n,r;if(e.locked()||e.isParent())return!1;var i=N[e.id()];if(i)n=i.col*v+v/2+a.x1,r=i.row*y+y/2+a.y1;else{for(;O(A,j);)M();n=j*v+v/2+a.x1,r=A*y+y/2+a.y1,k(A,j),M()}return{x:n,y:r}})}return this};var tp={ready:function(){},stop:function(){}};function np(e){this.options=Z({},tp,e)}np.prototype.run=function(){var e=this.options,t=e.eles,n=this;return e.cy,n.emit(`layoutstart`),t.nodes().positions(function(){return{x:0,y:0}}),n.one(`layoutready`,e.ready),n.emit(`layoutready`),n.one(`layoutstop`,e.stop),n.emit(`layoutstop`),this},np.prototype.stop=function(){return this};var rp={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 ip(e){this.options=Z({},rp,e)}ip.prototype.run=function(){var e=this.options,t=e.eles.nodes(),n=ke(e.positions);function r(t){return e.positions==null?Tr(t.position()):n?e.positions(t):e.positions[t._private.data.id]??null}return t.layoutPositions(this,e,function(e,t){var n=r(e);return e.locked()||n==null?!1:n}),this};var ap={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 op(e){this.options=Z({},ap,e)}op.prototype.run=function(){var e=this.options,t=e.cy,n=e.eles,r=qr(e.boundingBox?e.boundingBox:{x1:0,y1:0,w:t.width(),h:t.height()});return n.nodes().layoutPositions(this,e,function(e,t){return{x:r.x1+Math.round(Math.random()*r.w),y:r.y1+Math.round(Math.random()*r.h)}}),this};var sp=[{name:`breadthfirst`,impl:Tf},{name:`circle`,impl:Df},{name:`concentric`,impl:kf},{name:`cose`,impl:Mf},{name:`grid`,impl:ep},{name:`null`,impl:np},{name:`preset`,impl:ip},{name:`random`,impl:op}];function cp(e){this.options=e,this.notifications=0}var lp=function(){},up=function(){throw Error(`A headless instance can not render images`)};cp.prototype={recalculateRenderedStyle:lp,notify:function(){this.notifications++},init:lp,isHeadless:function(){return!0},getAllInBox:function(){return[]},hitTestAt:function(){return[]},png:up,jpg:up};var dp={};dp.arrowShapeWidth=.3,dp.registerArrowShapes=function(){var e=this.arrowShapes={},t=this,n=function(e,t,n,r,i,a,o){var s=i.x-n/2-o,c=i.x+n/2+o,l=i.y-n/2-o,u=i.y+n/2+o;return s<=e&&e<=c&&l<=t&&t<=u},r=function(e,t,n,r,i){var a=e*Math.cos(r)-t*Math.sin(r),o=e*Math.sin(r)+t*Math.cos(r),s=a*n,c=o*n;return{x:s+i.x,y:c+i.y}},i=function(e,t,n,i){for(var a=[],o=0;o<e.length;o+=2){var s=e[o],c=e[o+1];a.push(r(s,c,t,n,i))}return a},a=function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];t.push(r.x,r.y)}return t},o=function(e,t){return e.pstyle(`width`).pfValue*uf(e,t)*2},s=function(r,s){Y(s)&&(s=e[s]),e[r]=Z({name:r,points:[-.15,-.3,.15,-.3,.15,.3,-.15,.3],collide:function(e,t,n,r,o,s){return hi(e,t,a(i(this.points,n+2*s,r,o)))},roughCollide:n,draw:function(e,n,r,a){var o=i(this.points,n,r,a);t.arrowShapeImpl(`polygon`)(e,o)},spacing:function(e,t){return 0},gap:o},s)};s(`none`,{collide:Nn,roughCollide:Nn,draw:Fn,spacing:Pn,gap:Pn}),s(`triangle`,{points:[-.15,-.3,0,0,.15,-.3]}),s(`arrow`,`triangle`),s(`triangle-backcurve`,{points:e.triangle.points,controlPoint:[0,-.15],roughCollide:n,draw:function(e,n,a,o,s){var c=i(this.points,n,a,o),l=this.controlPoint,u=r(l[0],l[1],n,a,o);t.arrowShapeImpl(this.name)(e,c,u)},gap:function(e,t){return o(e,t)*.8}}),s(`triangle-tee`,{points:[0,0,.15,-.3,-.15,-.3,0,0],pointsTee:[-.15,-.4,-.15,-.5,.15,-.5,.15,-.4],collide:function(e,t,n,r,o,s,c){var l=a(i(this.points,n+2*c,r,o)),u=a(i(this.pointsTee,n+2*c,r,o));return hi(e,t,l)||hi(e,t,u)},draw:function(e,n,r,a,o){var s=i(this.points,n,r,a),c=i(this.pointsTee,n,r,a);t.arrowShapeImpl(this.name)(e,s,c)}}),s(`circle-triangle`,{radius:.15,pointsTr:[0,-.15,.15,-.45,-.15,-.45,0,-.15],collide:function(e,t,n,r,o,s,c){var l=o,u=(l.x-e)**2+(l.y-t)**2<=((n+2*c)*this.radius)**2;return hi(e,t,a(i(this.points,n+2*c,r,o)))||u},draw:function(e,n,r,a,o){var s=i(this.pointsTr,n,r,a);t.arrowShapeImpl(this.name)(e,s,a.x,a.y,this.radius*n)},spacing:function(e,n){return t.getArrowWidth(e.pstyle(`width`).pfValue,uf(e,n))*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(e,t){var n=this.baseCrossLinePts.slice(),r=t/e,i=3,a=5;return n[i]=n[i]-r,n[a]=n[a]-r,n},collide:function(e,t,n,r,o,s,c){var l=a(i(this.points,n+2*c,r,o)),u=a(i(this.crossLinePts(n,s),n+2*c,r,o));return hi(e,t,l)||hi(e,t,u)},draw:function(e,n,r,a,o){var s=i(this.points,n,r,a),c=i(this.crossLinePts(n,o),n,r,a);t.arrowShapeImpl(this.name)(e,s,c)}}),s(`vee`,{points:[-.15,-.3,0,0,.15,-.3,0,-.15],gap:function(e,t){return o(e,t)*.525}}),s(`circle`,{radius:.15,collide:function(e,t,n,r,i,a,o){var s=i;return(s.x-e)**2+(s.y-t)**2<=((n+2*o)*this.radius)**2},draw:function(e,n,r,i,a){t.arrowShapeImpl(this.name)(e,i.x,i.y,this.radius*n)},spacing:function(e,n){return t.getArrowWidth(e.pstyle(`width`).pfValue,uf(e,n))*this.radius}}),s(`tee`,{points:[-.15,0,-.15,-.1,.15,-.1,.15,0],spacing:function(e,t){return 1},gap:function(e,t){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(e,t){return e.pstyle(`width`).pfValue*uf(e,t)}}),s(`chevron`,{points:[0,0,-.15,-.15,-.1,-.2,0,-.1,.1,-.2,.15,-.15],gap:function(e,t){return .95*e.pstyle(`width`).pfValue*uf(e,t)}})};var fp={};fp.projectIntoViewport=function(e,t){var n=this.cy,r=this.findContainerClientCoords(),i=r[0],a=r[1],o=r[4],s=n.pan(),c=n.zoom();return[((e-i)/o-s.x)/c,((t-a)/o-s.y)/c]},fp.findContainerClientCoords=function(){if(this.containerBB)return this.containerBB;var e=this.container,t=e.getBoundingClientRect(),n=this.cy.window().getComputedStyle(e),r=function(e){return parseFloat(n.getPropertyValue(e))},i={left:r(`padding-left`),right:r(`padding-right`),top:r(`padding-top`),bottom:r(`padding-bottom`)},a={left:r(`border-left-width`),right:r(`border-right-width`),top:r(`border-top-width`),bottom:r(`border-bottom-width`)},o=e.clientWidth,s=e.clientHeight,c=i.left+i.right,l=i.top+i.bottom,u=a.left+a.right,d=t.width/(o+u),f=o-c,p=s-l,m=t.left+i.left+a.left,h=t.top+i.top+a.top;return this.containerBB=[m,h,f,p,d]},fp.invalidateContainerClientCoordsCache=function(){this.containerBB=null},fp.getLabelHitPolygon=function(e,t,n){var r=e._private,i=t?t+`-`:``;e.boundingBox();var a=r.labelBounds[t||`main`];if(!a)return null;var o=Yn(r.rscratch,`labelX`,t),s=Yn(r.rscratch,`labelY`,t),c=Yn(r.rscratch,`labelAngle`,t),l=e.pstyle(i+`text-margin-x`).pfValue,u=e.pstyle(i+`text-margin-y`).pfValue;return Li(a,o,s,c,l,u,n)},fp.checkLabelHitAt=function(e,t,n,r,i){var a=r?r+`-`:``,o=e.pstyle(a+`label`).value;if(e.pstyle(`text-events`).strValue!==`yes`||!o)return!1;var s=this.getLabelHitPolygon(e,r,i);if(!s)return!1;for(var c=[],l=0;l<s.length;l++)c.push(s[l].x,s[l].y);return hi(t,n,c)},fp.checkNodeHitAt=function(e,t,n,r){var i=this,a=e.outerWidth()+2*r,o=e.outerHeight()+2*r,s=e.position();if(s.x-a/2<=t&&t<=s.x+a/2&&s.y-o/2<=n&&n<=s.y+o/2){var c=e.pstyle(`corner-radius`).value===`auto`?`auto`:e.pstyle(`corner-radius`).pfValue;return i.nodeShapes[i.getNodeShape(e)].checkPoint(t,n,0,a,o,s.x,s.y,c,e._private.rscratch)}return!1},fp.checkEdgeHitAt=function(e,t,n,r){var i=this,a=e._private.rscratch,o=e.pstyle(`width`).pfValue,s=o/2+r,c=s*s,l=s*2,u;if(a.edgeType===`segments`||a.edgeType===`straight`||a.edgeType===`haystack`){for(var d=a.allpts,f=0;f+3<d.length;f+=2)if(li(t,n,d[f],d[f+1],d[f+2],d[f+3],l)&&c>(u=mi(t,n,d[f],d[f+1],d[f+2],d[f+3])))return{sqDist:u}}else if(a.edgeType===`bezier`||a.edgeType===`multibezier`||a.edgeType===`self`||a.edgeType===`compound`){for(var p=a.allpts,m=0;m+5<p.length;m+=4)if(ui(t,n,p[m],p[m+1],p[m+2],p[m+3],p[m+4],p[m+5],l)&&c>(u=pi(t,n,p[m],p[m+1],p[m+2],p[m+3],p[m+4],p[m+5])))return{sqDist:u}}for(var h=[{name:`source`,x:a.arrowStartX,y:a.arrowStartY,angle:a.srcArrowAngle},{name:`target`,x:a.arrowEndX,y:a.arrowEndY,angle:a.tgtArrowAngle},{name:`mid-source`,x:a.midX,y:a.midY,angle:a.midsrcArrowAngle},{name:`mid-target`,x:a.midX,y:a.midY,angle:a.midtgtArrowAngle}],g=0;g<h.length;g++){var _=h[g],v=i.arrowShapes[e.pstyle(_.name+`-arrow-shape`).value],y=o,b=i.getArrowWidth(o,uf(e,_.name));if(v.roughCollide(t,n,b,_.angle,{x:_.x,y:_.y},y,r)&&v.collide(t,n,b,_.angle,{x:_.x,y:_.y},y,r))return{sqDist:null}}return null},fp.hitTestAt=function(e,t,n,r){for(var i=this,a=i.cy.zoom(),o=r||{},s=o.isTouch,c=o.includeBody!==!1,l=o.includeMainLabels!==!1,u=o.includeSourceLabels!==!1,d=o.includeTargetLabels!==!1,f=(s?8:2)/a,p=(s?8:2)/a,m=(s?24:8)/a,h=new Set,g=0;g<n.length;g++)h.add(n[g]._private.data.id);for(var _=i.getCachedZSortedEles().interactive,v=[],y=_.length-1;y>=0;y--){var b=_[y];if(h.has(b._private.data.id)){var x=!1;b.isNode()?(c&&(x=i.checkNodeHitAt(b,e,t,f)),!x&&l&&(x=i.checkLabelHitAt(b,e,t,null,p))):(c&&(x=i.checkEdgeHitAt(b,e,t,m)!=null),!x&&l&&(x=i.checkLabelHitAt(b,e,t,null,p)),!x&&u&&(x=i.checkLabelHitAt(b,e,t,`source`,p)),!x&&d&&(x=i.checkLabelHitAt(b,e,t,`target`,p))),x&&v.push(b)}}return v},fp.findNearestElement=function(e,t,n,r){return this.findNearestElements(e,t,n,r)[0]},fp.findNearestElements=function(e,t,n,r){var i=this,a=this,o=a.getCachedZSortedEles(),s=[],c=a.cy.zoom(),l=a.cy.hasCompoundNodes(),u=(r?24:8)/c,d=(r?8:2)/c,f=(r?8:2)/c,p=1/0,m,h;n&&(o=o.interactive);function g(e,t){if(e.isNode()){if(h)return;h=e,s.push(e)}if(e.isEdge()&&(t==null||t<p)){if(m){if(m.pstyle(`z-compound-depth`).value===e.pstyle(`z-compound-depth`).value&&m.pstyle(`z-compound-depth`).value===e.pstyle(`z-compound-depth`).value){for(var n=0;n<s.length;n++)if(s[n].isEdge()){s[n]=e,m=e,p=t??p;break}}}else s.push(e),m=e,p=t??p}}function _(n){if(a.checkNodeHitAt(n,e,t,d))return g(n,0),!0}function v(n){var r=n._private,o=r.rscratch,c=n.pstyle(`width`).pfValue,d=c/2+u,f=d*d,p=d*2,m=r.source,h=r.target,v;if(o.edgeType===`segments`||o.edgeType===`straight`||o.edgeType===`haystack`){for(var y=o.allpts,b=0;b+3<y.length;b+=2)if(li(e,t,y[b],y[b+1],y[b+2],y[b+3],p)&&f>(v=mi(e,t,y[b],y[b+1],y[b+2],y[b+3])))return g(n,v),!0}else if(o.edgeType===`bezier`||o.edgeType===`multibezier`||o.edgeType===`self`||o.edgeType===`compound`){for(var y=o.allpts,b=0;b+5<o.allpts.length;b+=4)if(ui(e,t,y[b],y[b+1],y[b+2],y[b+3],y[b+4],y[b+5],p)&&f>(v=pi(e,t,y[b],y[b+1],y[b+2],y[b+3],y[b+4],y[b+5])))return g(n,v),!0}for(var m=m||r.source,h=h||r.target,x=[{name:`source`,x:o.arrowStartX,y:o.arrowStartY,angle:o.srcArrowAngle},{name:`target`,x:o.arrowEndX,y:o.arrowEndY,angle:o.tgtArrowAngle},{name:`mid-source`,x:o.midX,y:o.midY,angle:o.midsrcArrowAngle},{name:`mid-target`,x:o.midX,y:o.midY,angle:o.midtgtArrowAngle}],b=0;b<x.length;b++){var S=x[b],C=a.arrowShapes[n.pstyle(S.name+`-arrow-shape`).value],w=n.pstyle(`width`).pfValue,T=i.getArrowWidth(c,uf(n,S.name));if(C.roughCollide(e,t,T,S.angle,{x:S.x,y:S.y},w,u)&&C.collide(e,t,T,S.angle,{x:S.x,y:S.y},w,u))return g(n),!0}l&&s.length>0&&(_(m),_(h))}function y(n,r){if(i.checkLabelHitAt(n,e,t,r,f))return g(n),!0}for(var b=o.length-1;b>=0;b--){var x=o[b];x.isNode()?_(x)||y(x):v(x)||y(x)||y(x,`source`)||y(x,`target`)}return s},fp.getAllInBox=function(e,t,n,r){var i=this,a=this.getCachedZSortedEles().interactive,o=2/this.cy.zoom(),s=[],c=Math.min(e,n),l=Math.max(e,n),u=Math.min(t,r),d=Math.max(t,r);e=c,n=l,t=u,r=d;var f=qr({x1:e,y1:t,x2:n,y2:r}),p=[{x:f.x1,y:f.y1},{x:f.x2,y:f.y1},{x:f.x2,y:f.y2},{x:f.x1,y:f.y2}],m=[[p[0],p[1]],[p[1],p[2]],[p[2],p[3]],[p[3],p[0]]];function h(e,t){return i.getLabelHitPolygon(e,t,o)}function g(e,t,n,r){function i(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}return i(e,n,r)!==i(t,n,r)&&i(e,t,n)!==i(e,t,r)}for(var _=0;_<a.length;_++){var v=a[_];if(v.isNode()){var y=v,b=y.pstyle(`text-events`).strValue===`yes`,x=y.pstyle(`box-selection`).strValue,S=y.pstyle(`box-select-labels`).strValue===`yes`;if(x===`none`)continue;var C=(x===`overlap`||S)&&b,w=y.boundingBox({includeNodes:!0,includeEdges:!1,includeLabels:C});if(x===`contain`){var T=!1;if(S&&b){var E=h(y);E&&Ri(E,p)&&(s.push(y),T=!0)}!T&&ii(f,w)&&s.push(y)}else if(x===`overlap`&&ti(f,w)){var D=y.boundingBox({includeNodes:!0,includeEdges:!0,includeLabels:!1,includeMainLabels:!1,includeSourceLabels:!1,includeTargetLabels:!1});if(Ri([{x:D.x1,y:D.y1},{x:D.x2,y:D.y1},{x:D.x2,y:D.y2},{x:D.x1,y:D.y2}],p))s.push(y);else{var O=h(y);O&&Ri(O,p)&&s.push(y)}}}else{var k=v,A=k._private,j=A.rscratch,M=k.pstyle(`box-selection`).strValue;if(M===`none`)continue;if(M===`contain`){if(j.startX!=null&&j.startY!=null&&!ni(f,j.startX,j.startY)||j.endX!=null&&j.endY!=null&&!ni(f,j.endX,j.endY))continue;if(j.edgeType===`bezier`||j.edgeType===`multibezier`||j.edgeType===`self`||j.edgeType===`compound`||j.edgeType===`segments`||j.edgeType===`haystack`){for(var N=A.rstyle.bezierPts||A.rstyle.linePts||A.rstyle.haystackPts,P=!0,F=0;F<N.length;F++)if(!ri(f,N[F])){P=!1;break}P&&s.push(k)}else j.edgeType===`straight`&&s.push(k)}else if(M===`overlap`){var I=!1;if(j.startX!=null&&j.startY!=null&&j.endX!=null&&j.endY!=null&&(ni(f,j.startX,j.startY)||ni(f,j.endX,j.endY)))s.push(k),I=!0;else if(!I&&j.edgeType===`haystack`){for(var L=A.rstyle.haystackPts,R=0;R<L.length;R++)if(ri(f,L[R])){s.push(k),I=!0;break}}if(!I){var z=A.rstyle.bezierPts||A.rstyle.linePts||A.rstyle.haystackPts;if((!z||z.length<2)&&j.edgeType===`straight`&&j.startX!=null&&j.startY!=null&&j.endX!=null&&j.endY!=null&&(z=[{x:j.startX,y:j.startY},{x:j.endX,y:j.endY}]),!z||z.length<2)continue;for(var B=0;B<z.length-1;B++){for(var V=z[B],H=z[B+1],U=0;U<m.length;U++){var W=ge(m[U],2),ee=W[0],G=W[1];if(g(V,H,ee,G)){s.push(k),I=!0;break}}if(I)break}}}}}return s};var pp={};pp.calculateArrowAngles=function(e){var t=e._private.rscratch,n=t.edgeType===`haystack`,r=t.edgeType===`bezier`,i=t.edgeType===`multibezier`,a=t.edgeType===`segments`,o=t.edgeType===`compound`,s=t.edgeType===`self`,c,l,u,d,f,p,m,h;if(n?(u=t.haystackPts[0],d=t.haystackPts[1],f=t.haystackPts[2],p=t.haystackPts[3]):(u=t.arrowStartX,d=t.arrowStartY,f=t.arrowEndX,p=t.arrowEndY),m=t.midX,h=t.midY,a)c=u-t.segpts[0],l=d-t.segpts[1];else if(i||o||s||r){var g=t.allpts,_=Ur(g[0],g[2],g[4],.1),v=Ur(g[1],g[3],g[5],.1);c=u-_,l=d-v}else c=u-m,l=d-h;t.srcArrowAngle=Lr(c,l);var m=t.midX,h=t.midY;if(n&&(m=(u+f)/2,h=(d+p)/2),c=f-u,l=p-d,a){var g=t.allpts;if(g.length/2%2==0){var y=g.length/2,b=y-2;c=g[y]-g[b],l=g[y+1]-g[b+1]}else if(t.isRound)c=t.midVector[1],l=-t.midVector[0];else{var y=g.length/2-1,b=y-2;c=g[y]-g[b],l=g[y+1]-g[b+1]}}else if(i||o||s){var g=t.allpts,x=t.ctrlpts,S,C,w,T;if(x.length/2%2==0){var E=g.length/2-1,D=E+2,O=D+2;S=Ur(g[E],g[D],g[O],0),C=Ur(g[E+1],g[D+1],g[O+1],0),w=Ur(g[E],g[D],g[O],1e-4),T=Ur(g[E+1],g[D+1],g[O+1],1e-4)}else{var D=g.length/2-1,E=D-2,O=D+2;S=Ur(g[E],g[D],g[O],.4999),C=Ur(g[E+1],g[D+1],g[O+1],.4999),w=Ur(g[E],g[D],g[O],.5),T=Ur(g[E+1],g[D+1],g[O+1],.5)}c=w-S,l=T-C}if(t.midtgtArrowAngle=Lr(c,l),t.midDispX=c,t.midDispY=l,c*=-1,l*=-1,a){var g=t.allpts;if(g.length/2%2!=0&&!t.isRound){var y=g.length/2-1,k=y+2;c=-(g[k]-g[y]),l=-(g[k+1]-g[y+1])}}if(t.midsrcArrowAngle=Lr(c,l),a)c=f-t.segpts[t.segpts.length-2],l=p-t.segpts[t.segpts.length-1];else if(i||o||s||r){var g=t.allpts,A=g.length,_=Ur(g[A-6],g[A-4],g[A-2],.9),v=Ur(g[A-5],g[A-3],g[A-1],.9);c=f-_,l=p-v}else c=f-m,l=p-h;t.tgtArrowAngle=Lr(c,l)},pp.getArrowWidth=pp.getArrowHeight=function(e,t){var n=this.arrowWidthCache=this.arrowWidthCache||{},r=n[e+`, `+t];return r||(r=Math.max((e*13.37)**.9,29)*t,n[e+`, `+t]=r,r)};var mp,hp,gp={},_p={},vp,yp,bp,xp,Sp,Cp,wp,Tp,Ep,Dp,Op,kp,Ap,jp,Mp,Np=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)},Pp=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},Fp=function(e,t,n,r,i){e===Mp?Pp(_p,gp):Np(t,e,gp),Np(t,n,_p),vp=gp.nx*_p.ny-gp.ny*_p.nx,yp=gp.nx*_p.nx-gp.ny*-_p.ny,Sp=Math.asin(Math.max(-1,Math.min(1,vp))),Math.abs(Sp)<1e-6?(mp=t.x,hp=t.y,wp=Ep=0):(bp=1,xp=!1,yp<0?Sp<0?Sp=Math.PI+Sp:(Sp=Math.PI-Sp,bp=-1,xp=!0):Sp>0&&(bp=-1,xp=!0),Ep=t.radius===void 0?r:t.radius,Cp=Sp/2,Dp=Math.min(gp.len/2,_p.len/2),i?(Tp=Math.abs(Math.cos(Cp)*Ep/Math.sin(Cp)),Tp>Dp?(Tp=Dp,wp=Math.abs(Tp*Math.sin(Cp)/Math.cos(Cp))):wp=Ep):(Tp=Math.min(Dp,Ep),wp=Math.abs(Tp*Math.sin(Cp)/Math.cos(Cp))),Ap=t.x+_p.nx*Tp,jp=t.y+_p.ny*Tp,mp=Ap-_p.ny*wp*bp,hp=jp+_p.nx*wp*bp,Op=t.x+gp.nx*Tp,kp=t.y+gp.ny*Tp,Mp=t)};function Ip(e,t){t.radius===0?e.lineTo(t.cx,t.cy):e.arc(t.cx,t.cy,t.radius,t.startAngle,t.endAngle,t.counterClockwise)}function Lp(e,t,n,r){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0;return r===0||t.radius===0?{cx:t.x,cy:t.y,radius:0,startX:t.x,startY:t.y,stopX:t.x,stopY:t.y,startAngle:void 0,endAngle:void 0,counterClockwise:void 0}:(Fp(e,t,n,r,i),{cx:mp,cy:hp,radius:wp,startX:Op,startY:kp,stopX:Ap,stopY:jp,startAngle:gp.ang+Math.PI/2*bp,endAngle:_p.ang-Math.PI/2*bp,counterClockwise:xp})}var Rp=.01,zp=Math.sqrt(2*Rp),Bp={};Bp.findMidptPtsEtc=function(e,t){var n=t.posPts,r=t.intersectionPts,i=t.vectorNormInverse,a,o=e.pstyle(`source-endpoint`),s=e.pstyle(`target-endpoint`),c=o.units!=null&&s.units!=null,l=function(e,t,n,r){var i=r-t,a=n-e,o=Math.sqrt(a*a+i*i);return{x:-i/o,y:a/o}};switch(e.pstyle(`edge-distances`).value){case`node-position`:a=n;break;case`intersection`:a=r;break;case`endpoints`:if(c){var u=ge(this.manualEndptToPx(e.source()[0],o),2),d=u[0],f=u[1],p=ge(this.manualEndptToPx(e.target()[0],s),2),m=p[0],h=p[1],g={x1:d,y1:f,x2:m,y2:h};i=l(d,f,m,h),a=g}else Rn(`Edge ${e.id()} has edge-distances:endpoints specified without manual endpoints specified via source-endpoint and target-endpoint. Falling back on edge-distances:intersection (default).`),a=r}return{midptPts:a,vectorNormInverse:i}},Bp.findHaystackPoints=function(e){for(var t=0;t<e.length;t++){var n=e[t],r=n._private,i=r.rscratch;if(!i.haystack){var a=Math.random()*2*Math.PI;i.source={x:Math.cos(a),y:Math.sin(a)},a=Math.random()*2*Math.PI,i.target={x:Math.cos(a),y:Math.sin(a)}}var o=r.source,s=r.target,c=o.position(),l=s.position(),u=o.width(),d=s.width(),f=o.height(),p=s.height(),m=n.pstyle(`haystack-radius`).value/2;i.haystackPts=i.allpts=[i.source.x*u*m+c.x,i.source.y*f*m+c.y,i.target.x*d*m+l.x,i.target.y*p*m+l.y],i.midX=(i.allpts[0]+i.allpts[2])/2,i.midY=(i.allpts[1]+i.allpts[3])/2,i.edgeType=`haystack`,i.haystack=!0,this.storeEdgeProjections(n),this.calculateArrowAngles(n),this.recalculateEdgeLabelProjections(n),this.calculateLabelAngles(n)}},Bp.findSegmentsPoints=function(e,t){var n=e._private.rscratch,r=e.pstyle(`segment-weights`),i=e.pstyle(`segment-distances`),a=e.pstyle(`segment-radii`),o=e.pstyle(`radius-type`),s=Math.min(r.pfValue.length,i.pfValue.length),c=a.pfValue[a.pfValue.length-1],l=o.pfValue[o.pfValue.length-1];n.edgeType=`segments`,n.segpts=[],n.radii=[],n.isArcRadius=[];for(var u=0;u<s;u++){var d=r.pfValue[u],f=i.pfValue[u],p=1-d,m=d,h=this.findMidptPtsEtc(e,t),g=h.midptPts,_=h.vectorNormInverse,v={x:g.x1*p+g.x2*m,y:g.y1*p+g.y2*m};n.segpts.push(v.x+_.x*f,v.y+_.y*f),n.radii.push(a.pfValue[u]===void 0?c:a.pfValue[u]),n.isArcRadius.push((o.pfValue[u]===void 0?l:o.pfValue[u])===`arc-radius`)}},Bp.findLoopPoints=function(e,t,n,r){var i=e._private.rscratch,a=t.dirCounts,o=t.srcPos,s=e.pstyle(`control-point-distances`),c=s?s.pfValue[0]:void 0,l=e.pstyle(`loop-direction`).pfValue,u=e.pstyle(`loop-sweep`).pfValue,d=e.pstyle(`control-point-step-size`).pfValue;i.edgeType=`self`;var f=n,p=d;r&&(f=0,p=c);var m=l-Math.PI/2,h=m-u/2,g=m+u/2,_=String(l+`_`+u);f=a[_]===void 0?a[_]=0:++a[_],i.ctrlpts=[o.x+Math.cos(h)*1.4*p*(f/3+1),o.y+Math.sin(h)*1.4*p*(f/3+1),o.x+Math.cos(g)*1.4*p*(f/3+1),o.y+Math.sin(g)*1.4*p*(f/3+1)]},Bp.findCompoundLoopPoints=function(e,t,n,r){var i=e._private.rscratch;i.edgeType=`compound`;var a=t.srcPos,o=t.tgtPos,s=t.srcW,c=t.srcH,l=t.tgtW,u=t.tgtH,d=e.pstyle(`control-point-step-size`).pfValue,f=e.pstyle(`control-point-distances`),p=f?f.pfValue[0]:void 0,m=n,h=d;r&&(m=0,h=p);var g=50,_={x:a.x-s/2,y:a.y-c/2},v={x:o.x-l/2,y:o.y-u/2},y={x:Math.min(_.x,v.x),y:Math.min(_.y,v.y)},b=.5,x=Math.max(b,Math.log(s*Rp)),S=Math.max(b,Math.log(l*Rp));i.ctrlpts=[y.x,y.y-(1+g**1.12/100)*h*(m/3+1)*x,y.x-(1+g**1.12/100)*h*(m/3+1)*S,y.y]},Bp.findStraightEdgePoints=function(e){e._private.rscratch.edgeType=`straight`},Bp.findBezierPoints=function(e,t,n,r,i){var a=e._private.rscratch,o=e.pstyle(`control-point-step-size`).pfValue,s=e.pstyle(`control-point-distances`),c=e.pstyle(`control-point-weights`),l=s&&c?Math.min(s.value.length,c.value.length):1,u=s?s.pfValue[0]:void 0,d=c.value[0],f=r;a.edgeType=f?`multibezier`:`bezier`,a.ctrlpts=[];for(var p=0;p<l;p++){var m=(.5-t.eles.length/2+n)*o*(i?-1:1),h=void 0,g=zr(m);f&&(u=s?s.pfValue[p]:o,d=c.value[p]),h=r?u:u===void 0?void 0:g*u;var _=h===void 0?m:h,v=1-d,y=d,b=this.findMidptPtsEtc(e,t),x=b.midptPts,S=b.vectorNormInverse,C={x:x.x1*v+x.x2*y,y:x.y1*v+x.y2*y};a.ctrlpts.push(C.x+S.x*_,C.y+S.y*_)}},Bp.findTaxiPoints=function(e,t){var n=e._private.rscratch;n.edgeType=`segments`;var r=`vertical`,i=`horizontal`,a=`leftward`,o=`rightward`,s=`downward`,c=`upward`,l=`auto`,u=t.posPts,d=t.srcW,f=t.srcH,p=t.tgtW,m=t.tgtH,h=e.pstyle(`edge-distances`).value!==`node-position`,g=e.pstyle(`taxi-direction`).value,_=g,v=e.pstyle(`taxi-turn`),y=v.units===`%`,b=v.pfValue,x=b<0,S=e.pstyle(`taxi-turn-min-distance`).pfValue,C=h?(d+p)/2:0,w=h?(f+m)/2:0,T=u.x2-u.x1,E=u.y2-u.y1,D=function(e,t){return e>0?Math.max(e-t,0):Math.min(e+t,0)},O=D(T,C),k=D(E,w),A=function(e,t,n,r){if(!h)return(e+t)/2;var i=zr(t-e),a=e+i*n/2,o=t-i*r/2;return i*(o-a)>=0?(a+o)/2:(e+t)/2},j=!1;_===l?g=Math.abs(O)>Math.abs(k)?i:r:_===c||_===s?(g=r,j=!0):(_===a||_===o)&&(g=i,j=!0);var M=g===r,N=M?k:O,P=M?E:T,F=zr(P),I=!1;!(j&&(y||x))&&(_===s&&P<0||_===c&&P>0||_===a&&P>0||_===o&&P<0)&&(F*=-1,N=F*Math.abs(N),I=!0);var L=y?(b<0?1+b:b)*N:(b<0?N:0)+b*F,R=function(e){return Math.abs(e)<S||Math.abs(e)>=Math.abs(N)},z=R(L),B=R(Math.abs(N)-Math.abs(L));if((z||B)&&!I){if(M){var V=Math.abs(P)<=f/2,H=Math.abs(T)<=p/2;if(V){var U=A(u.x1,u.x2,d,p);n.segpts=[U,u.y1,U,u.y2]}else if(H){var W=A(u.y1,u.y2,f,m);n.segpts=[u.x1,W,u.x2,W]}else n.segpts=[u.x1,u.y2]}else{var ee=Math.abs(P)<=d/2,G=Math.abs(E)<=m/2;if(ee){var K=A(u.y1,u.y2,f,m);n.segpts=[u.x1,K,u.x2,K]}else if(G){var q=A(u.x1,u.x2,d,p);n.segpts=[q,u.y1,q,u.y2]}else n.segpts=[u.x2,u.y1]}}else if(M){var J=u.y1+L+(h?f/2*F:0);n.segpts=[u.x1,J,u.x2,J]}else{var te=u.x1+L+(h?d/2*F:0);n.segpts=[te,u.y1,te,u.y2]}if(n.isRound){var ne=e.pstyle(`taxi-radius`).value,re=e.pstyle(`radius-type`).value[0]===`arc-radius`;n.radii=Array(n.segpts.length/2).fill(ne),n.isArcRadius=Array(n.segpts.length/2).fill(re)}},Bp.tryToCorrectInvalidPoints=function(e,t){var n=e._private.rscratch;if(n.edgeType===`bezier`){var r=t.srcPos,i=t.tgtPos,a=t.srcW,o=t.srcH,s=t.tgtW,c=t.tgtH,l=t.srcShape,u=t.tgtShape,d=t.srcCornerRadius,f=t.tgtCornerRadius,p=t.srcRs,m=t.tgtRs,h=!X(n.startX)||!X(n.startY),g=!X(n.arrowStartX)||!X(n.arrowStartY),_=!X(n.endX)||!X(n.endY),v=!X(n.arrowEndX)||!X(n.arrowEndY),y=3,b=e.pstyle(`width`).pfValue,x=y*this.getArrowWidth(b,uf(e,`source`))*this.arrowShapeWidth,S=y*this.getArrowWidth(b,uf(e,`target`))*this.arrowShapeWidth,C=Br({x:n.ctrlpts[0],y:n.ctrlpts[1]},{x:n.startX,y:n.startY}),w=C<x,T=!1;if(h||g||w){T=!0;var E={x:n.ctrlpts[0]-r.x,y:n.ctrlpts[1]-r.y},D=Math.sqrt(E.x*E.x+E.y*E.y),O={x:E.x/D,y:E.y/D},k=Math.max(a,o),A={x:n.ctrlpts[0]+O.x*2*k,y:n.ctrlpts[1]+O.y*2*k},j=l.intersectLine(r.x,r.y,a,o,A.x,A.y,0,d,p);w?(n.ctrlpts[0]=n.ctrlpts[0]+O.x*(x-C),n.ctrlpts[1]=n.ctrlpts[1]+O.y*(x-C)):(n.ctrlpts[0]=j[0]+O.x*x,n.ctrlpts[1]=j[1]+O.y*x)}var M=Br({x:n.ctrlpts[0],y:n.ctrlpts[1]},{x:n.endX,y:n.endY}),N=M<S;if(_||v||N){T=!0;var P={x:n.ctrlpts[0]-i.x,y:n.ctrlpts[1]-i.y},F=Math.sqrt(P.x*P.x+P.y*P.y),I={x:P.x/F,y:P.y/F},L=Math.max(a,o),R={x:n.ctrlpts[0]+I.x*2*L,y:n.ctrlpts[1]+I.y*2*L},z=u.intersectLine(i.x,i.y,s,c,R.x,R.y,0,f,m);N?(n.ctrlpts[0]=n.ctrlpts[0]+I.x*(S-M),n.ctrlpts[1]=n.ctrlpts[1]+I.y*(S-M)):(n.ctrlpts[0]=z[0]+I.x*S,n.ctrlpts[1]=z[1]+I.y*S)}T&&this.findEndpoints(e)}},Bp.storeAllpts=function(e){var t=e._private.rscratch;if(t.edgeType===`multibezier`||t.edgeType===`bezier`||t.edgeType===`self`||t.edgeType===`compound`){t.allpts=[],t.allpts.push(t.startX,t.startY);for(var n=0;n+1<t.ctrlpts.length;n+=2)t.allpts.push(t.ctrlpts[n],t.ctrlpts[n+1]),n+3<t.ctrlpts.length&&t.allpts.push((t.ctrlpts[n]+t.ctrlpts[n+2])/2,(t.ctrlpts[n+1]+t.ctrlpts[n+3])/2);t.allpts.push(t.endX,t.endY);var r,i;t.ctrlpts.length/2%2==0?(r=t.allpts.length/2-1,t.midX=t.allpts[r],t.midY=t.allpts[r+1]):(r=t.allpts.length/2-3,i=.5,t.midX=Ur(t.allpts[r],t.allpts[r+2],t.allpts[r+4],i),t.midY=Ur(t.allpts[r+1],t.allpts[r+3],t.allpts[r+5],i))}else if(t.edgeType===`straight`)t.allpts=[t.startX,t.startY,t.endX,t.endY],t.midX=(t.startX+t.endX+t.arrowStartX+t.arrowEndX)/4,t.midY=(t.startY+t.endY+t.arrowStartY+t.arrowEndY)/4;else if(t.edgeType===`segments`){if(t.allpts=[],t.allpts.push(t.startX,t.startY),t.allpts.push.apply(t.allpts,t.segpts),t.allpts.push(t.endX,t.endY),t.isRound){t.roundCorners=[];for(var a=2;a+3<t.allpts.length;a+=2){var o=t.radii[a/2-1],s=t.isArcRadius[a/2-1];t.roundCorners.push(Lp({x:t.allpts[a-2],y:t.allpts[a-1]},{x:t.allpts[a],y:t.allpts[a+1],radius:o},{x:t.allpts[a+2],y:t.allpts[a+3]},o,s))}}if(t.segpts.length%4==0){var c=t.segpts.length/2,l=c-2;t.midX=(t.segpts[l]+t.segpts[c])/2,t.midY=(t.segpts[l+1]+t.segpts[c+1])/2}else{var u=t.segpts.length/2-1;if(!t.isRound)t.midX=t.segpts[u],t.midY=t.segpts[u+1];else{var d={x:t.segpts[u],y:t.segpts[u+1]},f=t.roundCorners[u/2];if(f.radius===0){var p={x:t.segpts[u+2],y:t.segpts[u+3]};t.midX=d.x,t.midY=d.y,t.midVector=[d.y-p.y,p.x-d.x]}else{var m=[d.x-f.cx,d.y-f.cy],h=f.radius/Math.sqrt(m[0]**2+m[1]**2);m=m.map(function(e){return e*h}),t.midX=f.cx+m[0],t.midY=f.cy+m[1],t.midVector=m}}}}},Bp.checkForInvalidEdgeWarning=function(e){var t=e[0]._private.rscratch;t.nodesOverlap||X(t.startX)&&X(t.startY)&&X(t.endX)&&X(t.endY)?t.loggedErr=!1:t.loggedErr||(t.loggedErr=!0,Rn("Edge `"+e.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."))},Bp.findEdgeControlPoints=function(e){var t=this;if(e&&e.length!==0){for(var n=this,r=n.cy.hasCompoundNodes(),i=new Zn,a=function(e,t){return[].concat(_e(e),[+!!t]).join(`-`)},o=[],s=[],c=0;c<e.length;c++){var l=e[c],u=l._private,d=l.pstyle(`curve-style`).value;if(!l.removed()&&l.takesUpSpace()){if(d===`haystack`)s.push(l);else{var f=d===`unbundled-bezier`||Ze(d,`segments`)||d===`straight`||d===`straight-triangle`||Ze(d,`taxi`),p=d===`unbundled-bezier`||d===`bezier`,m=u.source,h=u.target,g=[m.poolIndex(),h.poolIndex()].sort(),_=a(g,f),v=i.get(_);v??(v={eles:[]},o.push({pairId:g,edgeIsUnbundled:f}),i.set(_,v)),v.eles.push(l),f&&(v.hasUnbundled=!0),p&&(v.hasBezier=!0)}}}for(var y=function(){var e=o[b],s=e.pairId,c=e.edgeIsUnbundled,l=a(s,c),u=i.get(l),d;if(!u.hasUnbundled){var f=u.eles[0].parallelEdges().filter(function(e){return e.isBundledBezier()});qn(u.eles),f.forEach(function(e){return u.eles.push(e)}),u.eles.sort(function(e,t){return e.poolIndex()-t.poolIndex()})}var p=u.eles[0],m=p.source(),h=p.target();if(m.poolIndex()>h.poolIndex()){var g=m;m=h,h=g}var _=u.srcPos=m.position(),v=u.tgtPos=h.position(),y=u.srcW=m.outerWidth(),x=u.srcH=m.outerHeight(),S=u.tgtW=h.outerWidth(),C=u.tgtH=h.outerHeight(),w=u.srcShape=n.nodeShapes[t.getNodeShape(m)],T=u.tgtShape=n.nodeShapes[t.getNodeShape(h)],E=u.srcCornerRadius=m.pstyle(`corner-radius`).value===`auto`?`auto`:m.pstyle(`corner-radius`).pfValue,D=u.tgtCornerRadius=h.pstyle(`corner-radius`).value===`auto`?`auto`:h.pstyle(`corner-radius`).pfValue,O=u.tgtRs=h._private.rscratch,k=u.srcRs=m._private.rscratch;u.dirCounts={north:0,west:0,south:0,east:0,northwest:0,southwest:0,northeast:0,southeast:0};for(var A=0;A<u.eles.length;A++){var j=u.eles[A],M=j[0]._private.rscratch,N=j.pstyle(`curve-style`).value,P=N===`unbundled-bezier`||Ze(N,`segments`)||Ze(N,`taxi`),F=!m.same(j.source());if(!u.calculatedIntersection&&m!==h&&(u.hasBezier||u.hasUnbundled)){u.calculatedIntersection=!0;var I=w.intersectLine(_.x,_.y,y,x,v.x,v.y,0,E,k),L=u.srcIntn=I,R=T.intersectLine(v.x,v.y,S,C,_.x,_.y,0,D,O),z=u.tgtIntn=R,B=u.intersectionPts={x1:I[0],x2:R[0],y1:I[1],y2:R[1]},V=u.posPts={x1:_.x,x2:v.x,y1:_.y,y2:v.y},H=R[1]-I[1],U=R[0]-I[0],W=Math.sqrt(U*U+H*H);X(W)&&W>=zp||(W=Math.sqrt(Math.max(U*U,Rp)+Math.max(H*H,Rp)));var ee=u.vector={x:U,y:H},G=u.vectorNorm={x:ee.x/W,y:ee.y/W},K={x:-G.y,y:G.x};u.nodesOverlap=!X(W)||T.checkPoint(I[0],I[1],0,S,C,v.x,v.y,D,O)||w.checkPoint(R[0],R[1],0,y,x,_.x,_.y,E,k),u.vectorNormInverse=K,d={nodesOverlap:u.nodesOverlap,dirCounts:u.dirCounts,calculatedIntersection:!0,hasBezier:u.hasBezier,hasUnbundled:u.hasUnbundled,eles:u.eles,srcPos:v,srcRs:O,tgtPos:_,tgtRs:k,srcW:S,srcH:C,tgtW:y,tgtH:x,srcIntn:z,tgtIntn:L,srcShape:T,tgtShape:w,posPts:{x1:V.x2,y1:V.y2,x2:V.x1,y2:V.y1},intersectionPts:{x1:B.x2,y1:B.y2,x2:B.x1,y2:B.y1},vector:{x:-ee.x,y:-ee.y},vectorNorm:{x:-G.x,y:-G.y},vectorNormInverse:{x:-K.x,y:-K.y}}}var q=F?d:u;M.nodesOverlap=q.nodesOverlap,M.srcIntn=q.srcIntn,M.tgtIntn=q.tgtIntn,M.isRound=N.startsWith(`round`),r&&(m.isParent()||m.isChild()||h.isParent()||h.isChild())&&(m.parents().anySame(h)||h.parents().anySame(m)||m.same(h)&&m.isParent())?t.findCompoundLoopPoints(j,q,A,P):m===h?t.findLoopPoints(j,q,A,P):N.endsWith(`segments`)?t.findSegmentsPoints(j,q):N.endsWith(`taxi`)?t.findTaxiPoints(j,q):N===`straight`||!P&&u.eles.length%2==1&&A===Math.floor(u.eles.length/2)?t.findStraightEdgePoints(j):t.findBezierPoints(j,q,A,P,F),t.findEndpoints(j),t.tryToCorrectInvalidPoints(j,q),t.checkForInvalidEdgeWarning(j),t.storeAllpts(j),t.storeEdgeProjections(j),t.calculateArrowAngles(j),t.recalculateEdgeLabelProjections(j),t.calculateLabelAngles(j)}},b=0;b<o.length;b++)y();this.findHaystackPoints(s)}};function Vp(e){var t=[];if(e!=null){for(var n=0;n<e.length;n+=2){var r=e[n],i=e[n+1];t.push({x:r,y:i})}return t}}Bp.getSegmentPoints=function(e){var t=e[0]._private.rscratch;if(this.recalculateRenderedStyle(e),t.edgeType===`segments`)return Vp(t.segpts)},Bp.getControlPoints=function(e){var t=e[0]._private.rscratch;this.recalculateRenderedStyle(e);var n=t.edgeType;if(n===`bezier`||n===`multibezier`||n===`self`||n===`compound`)return Vp(t.ctrlpts)},Bp.getEdgeMidpoint=function(e){var t=e[0]._private.rscratch;return this.recalculateRenderedStyle(e),{x:t.midX,y:t.midY}};var Hp={};Hp.manualEndptToPx=function(e,t){var n=this,r=e.position(),i=e.outerWidth(),a=e.outerHeight(),o=e._private.rscratch;if(t.value.length===2){var s=[t.pfValue[0],t.pfValue[1]];return t.units[0]===`%`&&(s[0]*=i),t.units[1]===`%`&&(s[1]*=a),s[0]+=r.x,s[1]+=r.y,s}var c=t.pfValue[0];c=-Math.PI/2+c;var l=2*Math.max(i,a),u=[r.x+Math.cos(c)*l,r.y+Math.sin(c)*l];return n.nodeShapes[this.getNodeShape(e)].intersectLine(r.x,r.y,i,a,u[0],u[1],0,e.pstyle(`corner-radius`).value===`auto`?`auto`:e.pstyle(`corner-radius`).pfValue,o)},Hp.findEndpoints=function(e){var t,n,r=this,i,a=e.source()[0],o=e.target()[0],s=a.position(),c=o.position(),l=e.pstyle(`target-arrow-shape`).value,u=e.pstyle(`source-arrow-shape`).value,d=e.pstyle(`target-distance-from-node`).pfValue,f=e.pstyle(`source-distance-from-node`).pfValue,p=a._private.rscratch,m=o._private.rscratch,h=e.pstyle(`curve-style`).value,g=e._private.rscratch,_=g.edgeType,v=Ze(h,`taxi`),y=_===`self`||_===`compound`,b=_===`bezier`||_===`multibezier`||y,x=_!==`bezier`,S=_===`straight`||_===`segments`,C=_===`segments`,w=b||x||S,T=y||v,E=e.pstyle(`source-endpoint`),D=T?`outside-to-node`:E.value,O=a.pstyle(`corner-radius`).value===`auto`?`auto`:a.pstyle(`corner-radius`).pfValue,k=e.pstyle(`target-endpoint`),A=T?`outside-to-node`:k.value,j=o.pstyle(`corner-radius`).value===`auto`?`auto`:o.pstyle(`corner-radius`).pfValue;g.srcManEndpt=E,g.tgtManEndpt=k;var M,N,P,F,I=((k==null||(t=k.pfValue)==null?void 0:t.length)===2?k.pfValue:null)??[0,0],L=((E==null||(n=E.pfValue)==null?void 0:n.length)===2?E.pfValue:null)??[0,0];if(b){var R=[g.ctrlpts[0],g.ctrlpts[1]];M=x?[g.ctrlpts[g.ctrlpts.length-2],g.ctrlpts[g.ctrlpts.length-1]]:R,N=R}else if(S){var z=C?g.segpts.slice(0,2):[c.x+I[0],c.y+I[1]];M=C?g.segpts.slice(g.segpts.length-2):[s.x+L[0],s.y+L[1]],N=z}if(A===`inside-to-node`)i=[c.x,c.y];else if(k.units)i=this.manualEndptToPx(o,k);else if(A===`outside-to-line`)i=g.tgtIntn;else if(A===`outside-to-node`||A===`outside-to-node-or-label`?P=M:(A===`outside-to-line`||A===`outside-to-line-or-label`)&&(P=[s.x,s.y]),i=r.nodeShapes[this.getNodeShape(o)].intersectLine(c.x,c.y,o.outerWidth(),o.outerHeight(),P[0],P[1],0,j,m),A===`outside-to-node-or-label`||A===`outside-to-line-or-label`){var B=o._private.rscratch,V=B.labelWidth,H=B.labelHeight,U=B.labelX,W=B.labelY,ee=V/2,G=H/2,K=o.pstyle(`text-valign`).value;K=cu(K),K===`top`?W-=G:K===`bottom`&&(W+=G);var q=o.pstyle(`text-halign`).value;q=su(q),q===`left`?U-=ee:q===`right`&&(U+=ee);var J=Ei(P[0],P[1],[U-ee,W-G,U+ee,W-G,U+ee,W+G,U-ee,W+G],c.x,c.y);if(J.length>0){var te=s,ne=Vr(te,Or(i)),re=Vr(te,Or(J)),ie=ne;re<ne&&(i=J,ie=re),J.length>2&&Vr(te,{x:J[2],y:J[3]})<ie&&(i=[J[2],J[3]])}}var ae=Oi(i,M,r.arrowShapes[l].spacing(e,`target`)+d),oe=Oi(i,M,r.arrowShapes[l].gap(e,`target`)+d);if(g.endX=oe[0],g.endY=oe[1],g.arrowEndX=ae[0],g.arrowEndY=ae[1],D===`inside-to-node`)i=[s.x,s.y];else if(E.units)i=this.manualEndptToPx(a,E);else if(D===`outside-to-line`)i=g.srcIntn;else if(D===`outside-to-node`||D===`outside-to-node-or-label`?F=N:(D===`outside-to-line`||D===`outside-to-line-or-label`)&&(F=[c.x,c.y]),i=r.nodeShapes[this.getNodeShape(a)].intersectLine(s.x,s.y,a.outerWidth(),a.outerHeight(),F[0],F[1],0,O,p),D===`outside-to-node-or-label`||D===`outside-to-line-or-label`){var se=a._private.rscratch,ce=se.labelWidth,le=se.labelHeight,ue=se.labelX,de=se.labelY,fe=ce/2,pe=le/2,me=a.pstyle(`text-valign`).value;me=cu(me),me===`top`?de-=pe:me===`bottom`&&(de+=pe);var he=a.pstyle(`text-halign`).value;he=su(he),he===`left`?ue-=fe:he===`right`&&(ue+=fe);var ge=Ei(F[0],F[1],[ue-fe,de-pe,ue+fe,de-pe,ue+fe,de+pe,ue-fe,de+pe],s.x,s.y);if(ge.length>0){var _e=c,ve=Vr(_e,Or(i)),ye=Vr(_e,Or(ge)),be=ve;ye<ve&&(i=[ge[0],ge[1]],be=ye),ge.length>2&&Vr(_e,{x:ge[2],y:ge[3]})<be&&(i=[ge[2],ge[3]])}}var xe=Oi(i,N,r.arrowShapes[u].spacing(e,`source`)+f),Se=Oi(i,N,r.arrowShapes[u].gap(e,`source`)+f);g.startX=Se[0],g.startY=Se[1],g.arrowStartX=xe[0],g.arrowStartY=xe[1],w&&(g.badLine=!X(g.startX)||!X(g.startY)||!X(g.endX)||!X(g.endY))},Hp.getSourceEndpoint=function(e){var t=e[0]._private.rscratch;switch(this.recalculateRenderedStyle(e),t.edgeType){case`haystack`:return{x:t.haystackPts[0],y:t.haystackPts[1]};default:return{x:t.arrowStartX,y:t.arrowStartY}}},Hp.getTargetEndpoint=function(e){var t=e[0]._private.rscratch;switch(this.recalculateRenderedStyle(e),t.edgeType){case`haystack`:return{x:t.haystackPts[2],y:t.haystackPts[3]};default:return{x:t.arrowEndX,y:t.arrowEndY}}};var Up={};function Wp(e,t,n){for(var r=function(e,t,n,r){return Ur(e,t,n,r)},i=t._private.rstyle.bezierPts,a=0;a<e.bezierProjPcts.length;a++){var o=e.bezierProjPcts[a];i.push({x:r(n[0],n[2],n[4],o),y:r(n[1],n[3],n[5],o)})}}Up.storeEdgeProjections=function(e){var t=e._private,n=t.rscratch,r=n.edgeType;if(t.rstyle.bezierPts=null,t.rstyle.linePts=null,t.rstyle.haystackPts=null,r===`multibezier`||r===`bezier`||r===`self`||r===`compound`){t.rstyle.bezierPts=[];for(var i=0;i+5<n.allpts.length;i+=4)Wp(this,e,n.allpts.slice(i,i+6))}else if(r===`segments`)for(var a=t.rstyle.linePts=[],i=0;i+1<n.allpts.length;i+=2)a.push({x:n.allpts[i],y:n.allpts[i+1]});else if(r===`haystack`){var o=n.haystackPts;t.rstyle.haystackPts=[{x:o[0],y:o[1]},{x:o[2],y:o[3]}]}for(var s=e.pstyle(`width`).pfValue,c=t.rstyle.arrowWidths=t.rstyle.arrowWidths||{},l=0,u=0;u<lf.length;u++){var d=lf[u],f=uf(e,d);c[d]=this.getArrowWidth(s,f)*this.arrowShapeWidth,f>l&&(l=f)}t.rstyle.arrowWidth=this.getArrowWidth(s,l)*this.arrowShapeWidth},Up.recalculateEdgeProjections=function(e){this.findEdgeControlPoints(e)};var Gp={};Gp.recalculateNodeLabelProjection=function(e){var t=e.pstyle(`label`).strValue;if(!Ve(t)){var n,r,i=e._private,a=e.width(),o=e.height(),s=e.padding(),c=e.position(),l=e.pstyle(`text-halign`).strValue,u=e.pstyle(`text-valign`).strValue,d=i.rscratch,f=i.rstyle;switch(l){case`left`:n=c.x-a/2-s;break;case`left-inside`:n=c.x-a/2+s;break;case`right`:n=c.x+a/2+s;break;case`right-inside`:n=c.x+a/2-s;break;default:n=c.x}switch(u){case`top`:r=c.y-o/2-s;break;case`top-inside`:r=c.y-o/2+s;break;case`bottom`:r=c.y+o/2+s;break;case`bottom-inside`:r=c.y+o/2-s;break;default:r=c.y}d.labelX=n,d.labelY=r,f.labelX=n,f.labelY=r,this.calculateLabelAngles(e),this.applyLabelDimensions(e)}};var Kp=function(e,t){var n=Math.atan(t/e);return e===0&&n<0&&(n*=-1),n},qp=function(e,t){return Kp(t.x-e.x,t.y-e.y)},Jp=function(e,t,n,r){var i=Kr(0,r-.001,1),a=Kr(0,r+.001,1);return qp(Wr(e,t,n,i),Wr(e,t,n,a))};Gp.recalculateEdgeLabelProjections=function(e){var t,n=e._private,r=n.rscratch,i=this,a={mid:e.pstyle(`label`).strValue,source:e.pstyle(`source-label`).strValue,target:e.pstyle(`target-label`).strValue};if(a.mid||a.source||a.target){t={x:r.midX,y:r.midY};var o=function(e,t,r){Xn(n.rscratch,e,t,r),Xn(n.rstyle,e,t,r)};o(`labelX`,null,t.x),o(`labelY`,null,t.y),o(`labelAutoAngle`,null,Kp(r.midDispX,r.midDispY));var s=function(){if(s.cache)return s.cache;for(var e=[],t=0;t+5<r.allpts.length;t+=4){var a={x:r.allpts[t],y:r.allpts[t+1]},o={x:r.allpts[t+2],y:r.allpts[t+3]},c={x:r.allpts[t+4],y:r.allpts[t+5]};e.push({p0:a,p1:o,p2:c,startDist:0,length:0,segments:[]})}var l=n.rstyle.bezierPts,u=i.bezierProjPcts.length;function d(e,t,n,r,i){var a=Br(t,n),o=e.segments[e.segments.length-1],s={p0:t,p1:n,t0:r,t1:i,startDist:o?o.startDist+o.length:0,length:a};e.segments.push(s),e.length+=a}for(var f=0;f<e.length;f++){var p=e[f],m=e[f-1];m&&(p.startDist=m.startDist+m.length),d(p,p.p0,l[f*u],0,i.bezierProjPcts[0]);for(var h=0;h<u-1;h++)d(p,l[f*u+h],l[f*u+h+1],i.bezierProjPcts[h],i.bezierProjPcts[h+1]);d(p,l[f*u+u-1],p.p2,i.bezierProjPcts[u-1],1)}return s.cache=e},c=function(n){var i,c=n===`source`;if(a[n]){var l=e.pstyle(n+`-text-offset`).pfValue;switch(r.edgeType){case`self`:case`compound`:case`bezier`:case`multibezier`:for(var u=s(),d,f=0,p=0,m=0;m<u.length;m++){for(var h=u[c?m:u.length-1-m],g=0;g<h.segments.length;g++){var _=h.segments[c?g:h.segments.length-1-g],v=m===u.length-1&&g===h.segments.length-1;if(f=p,p+=_.length,p>=l||v){d={cp:h,segment:_};break}}if(d)break}var y=d.cp,b=d.segment,x=(l-f)/b.length,S=b.t1-b.t0,C=c?b.t0+S*x:b.t1-S*x;C=Kr(0,C,1),t=Wr(y.p0,y.p1,y.p2,C),i=Jp(y.p0,y.p1,y.p2,C);break;case`straight`:case`segments`:case`haystack`:for(var w=0,T,E,D,O,k=r.allpts.length,A=0;A+3<k&&(c?(D={x:r.allpts[A],y:r.allpts[A+1]},O={x:r.allpts[A+2],y:r.allpts[A+3]}):(D={x:r.allpts[k-2-A],y:r.allpts[k-1-A]},O={x:r.allpts[k-4-A],y:r.allpts[k-3-A]}),T=Br(D,O),E=w,w+=T,!(w>=l));A+=2);var j=(l-E)/T;j=Kr(0,j,1),t=Gr(D,O,j),i=qp(D,O)}o(`labelX`,n,t.x),o(`labelY`,n,t.y),o(`labelAutoAngle`,n,i)}};c(`source`),c(`target`),this.applyLabelDimensions(e)}},Gp.applyLabelDimensions=function(e){this.applyPrefixedLabelDimensions(e),e.isEdge()&&(this.applyPrefixedLabelDimensions(e,`source`),this.applyPrefixedLabelDimensions(e,`target`))},Gp.applyPrefixedLabelDimensions=function(e,t){var n=e._private,r=this.getLabelText(e,t),i=Sn(r,e._private.labelDimsKey);if(Yn(n.rscratch,`prefixedLabelDimsKey`,t)!==i){Xn(n.rscratch,`prefixedLabelDimsKey`,t,i);var a=this.calculateLabelDimensions(e,r),o=e.pstyle(`line-height`).pfValue,s=e.pstyle(`font-size`).pfValue,c=e.pstyle(`text-wrap`).strValue,l=Yn(n.rscratch,`labelWrapCachedLines`,t)||[],u=c===`wrap`?Math.max(l.length,1):1,d=s*o,f=a.width,p=a.height+(u-1)*(o-1)*s;Xn(n.rstyle,`labelWidth`,t,f),Xn(n.rscratch,`labelWidth`,t,f),Xn(n.rstyle,`labelHeight`,t,p),Xn(n.rscratch,`labelHeight`,t,p),Xn(n.rscratch,`labelLineHeight`,t,d),Xn(n.rscratch,`labelActualDescent`,t,a.labelActualDescent)}},Gp.getLabelText=function(e,t){var n=e._private,r=t?t+`-`:``,i=e.pstyle(r+`label`).strValue,a=e.pstyle(`text-transform`).value,o=function(e,r){return r?(Xn(n.rscratch,e,t,r),r):Yn(n.rscratch,e,t)};if(!i)return``;a==`none`||(a==`uppercase`?i=i.toUpperCase():a==`lowercase`&&(i=i.toLowerCase()));var s=e.pstyle(`text-wrap`).value;if(s===`wrap`){var c=o(`labelKey`);if(c!=null&&o(`labelWrapKey`)===c)return o(`labelWrapCachedText`);for(var l=``,u=i.split(`
|
|
6
|
+
`),d=e.pstyle(`text-max-width`).pfValue,f=e.pstyle(`text-overflow-wrap`).value===`anywhere`,p=[],m=/[\s\u200b]+|$/g,h=0;h<u.length;h++){var g=u[h],_=this.calculateLabelDimensions(e,g).width;if(f&&(g=g.split(``).join(l)),_>d){var v=g.matchAll(m),y=``,b=0,x=ue(v),S;try{for(x.s();!(S=x.n()).done;){var C=S.value,w=C[0],T=g.substring(b,C.index);b=C.index+w.length;var E=y.length===0?T:y+T+w;this.calculateLabelDimensions(e,E).width<=d?y+=T+w:(y&&p.push(y),y=T+w)}}catch(e){x.e(e)}finally{x.f()}y.match(/^[\s\u200b]+$/)||p.push(y)}else p.push(g)}o(`labelWrapCachedLines`,p),i=o(`labelWrapCachedText`,p.join(`
|
|
7
|
+
`)),o(`labelWrapKey`,c)}else if(s===`ellipsis`){var D=e.pstyle(`text-max-width`).pfValue,O=``,k=`…`,A=!1;if(this.calculateLabelDimensions(e,i).width<D)return i;for(var j=0;j<i.length&&!(this.calculateLabelDimensions(e,O+i[j]+k).width>D);j++)O+=i[j],j===i.length-1&&(A=!0);return A||(O+=k),O}return i},Gp.getLabelJustification=function(e){var t=e.pstyle(`text-justification`).strValue,n=e.pstyle(`text-halign`).strValue;return t===`auto`?e.isNode()?lu(n):`center`:t},Gp.calculateLabelDimensions=function(e,t){var n=this.cy.window().document,r=0,i=e.pstyle(`font-style`).strValue,a=e.pstyle(`font-size`).pfValue,o=e.pstyle(`font-family`).strValue,s=e.pstyle(`font-weight`).strValue,c=e.pstyle(`text-metrics`).strValue||`font`,l=this.labelCalcCanvas,u=this.labelCalcCanvasContext;if(!l){l=this.labelCalcCanvas=n.createElement(`canvas`),u=this.labelCalcCanvasContext=l.getContext(`2d`);var d=l.style;d.position=`absolute`,d.left=`-9999px`,d.top=`-9999px`,d.zIndex=`-1`,d.visibility=`hidden`,d.pointerEvents=`none`}u.font=`${i} ${s} ${a}px ${o}`;for(var f=0,p=0,m=t.split(`
|
|
8
|
+
`),h=m.length,g=0,_=0,v=0;v<h;v++){var y=m[v],b=u.measureText(y),x=Math.ceil(b.width),S=a;c===`glyph`&&(v===0&&(_=b.actualBoundingBoxAscent),v===h-1&&(g=b.actualBoundingBoxDescent)),f=Math.max(x,f),p+=S}return c===`glyph`&&(p-=a-_-g),f+=r,p+=r,{width:f,height:p,labelActualAscent:_,labelActualDescent:g}},Gp.calculateLabelAngle=function(e,t){var n=e._private.rscratch,r=e.isEdge(),i=t?t+`-`:``,a=e.pstyle(i+`text-rotation`),o=a.strValue;return o===`none`?0:r&&o===`autorotate`?n.labelAutoAngle:o===`autorotate`?0:a.pfValue},Gp.calculateLabelAngles=function(e){var t=this,n=e.isEdge(),r=e._private.rscratch;r.labelAngle=t.calculateLabelAngle(e),n&&(r.sourceLabelAngle=t.calculateLabelAngle(e,`source`),r.targetLabelAngle=t.calculateLabelAngle(e,`target`))};var Yp={},Xp=28,Zp=!1;Yp.getNodeShape=function(e){var t=this,n=e.pstyle(`shape`).value;if(n===`cutrectangle`&&(e.width()<Xp||e.height()<Xp))return Zp||=(Rn("The `cutrectangle` node shape can not be used at small sizes so `rectangle` is used instead"),!0),`rectangle`;if(e.isParent())return n===`rectangle`||n===`roundrectangle`||n===`round-rectangle`||n===`cutrectangle`||n===`cut-rectangle`||n===`barrel`?n:`rectangle`;if(n===`polygon`){var r=e.pstyle(`shape-polygon-points`).value;return t.nodeShapes.makePolygon(r).name}return n};var Qp={};Qp.registerCalculationListeners=function(){var e=this.cy,t=e.collection(),n=this,r=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(t.merge(e),n)for(var r=0;r<e.length;r++){var i=e[r]._private.rstyle;i.clean=!1,i.cleanConnected=!1}};n.binder(e).on(`bounds.* dirty.*`,function(e){var t=e.target;r(t)}).on(`style.* background.*`,function(e){var t=e.target;r(t,!1)});var i=function(i){if(i){var a=n.onUpdateEleCalcsFns;t.cleanStyle();for(var o=0;o<t.length;o++){var s=t[o],c=s._private.rstyle;s.isNode()&&!c.cleanConnected&&(r(s.connectedEdges()),c.cleanConnected=!0)}if(a)for(var l=0;l<a.length;l++){var u=a[l];u(i,t)}n.recalculateRenderedStyle(t),t=e.collection()}};n.flushRenderedStyleQueue=function(){i(!0)},n.beforeRender(i,n.beforeRenderPriorities.eleCalcs)},Qp.onUpdateEleCalcs=function(e){(this.onUpdateEleCalcsFns=this.onUpdateEleCalcsFns||[]).push(e)},Qp.recalculateRenderedStyle=function(e,t){var n=function(e){return e._private.rstyle.cleanConnected};if(e.length!==0){var r=[],i=[];if(!this.destroyed){t===void 0&&(t=!0);for(var a=0;a<e.length;a++){var o=e[a],s=o._private,c=s.rstyle;!o.isEdge()||n(o.source())&&n(o.target())||(c.clean=!1),o.isEdge()&&o.isBundledBezier()&&o.parallelEdges().some(function(e){return!e._private.rstyle.clean&&e.isBundledBezier()})&&(c.clean=!1),t&&c.clean||o.removed()||o.pstyle(`display`).value!==`none`&&(s.group===`nodes`?i.push(o):r.push(o),c.clean=!0)}for(var l=0;l<i.length;l++){var u=i[l],d=u._private.rstyle,f=u.position();this.recalculateNodeLabelProjection(u),d.nodeX=f.x,d.nodeY=f.y,d.nodeW=u.pstyle(`width`).pfValue,d.nodeH=u.pstyle(`height`).pfValue}this.recalculateEdgeProjections(r);for(var p=0;p<r.length;p++){var m=r[p]._private,h=m.rstyle,g=m.rscratch;h.srcX=g.arrowStartX,h.srcY=g.arrowStartY,h.tgtX=g.arrowEndX,h.tgtY=g.arrowEndY,h.midX=g.midX,h.midY=g.midY,h.labelAngle=g.labelAngle,h.sourceLabelAngle=g.sourceLabelAngle,h.targetLabelAngle=g.targetLabelAngle}}}};var $p={};$p.updateCachedGrabbedEles=function(){var e=this.cachedZSortedEles;if(e){e.drag=[],e.nondrag=[];for(var t=[],n=0;n<e.length;n++){var r=e[n],i=r._private.rscratch;r.grabbed()&&!r.isParent()?t.push(r):i.inDragLayer?e.drag.push(r):e.nondrag.push(r)}for(var n=0;n<t.length;n++){var r=t[n];e.drag.push(r)}}},$p.invalidateCachedZSortedEles=function(){this.cachedZSortedEles=null},$p.getCachedZSortedEles=function(e){if(e||!this.cachedZSortedEles){var t=this.cy.mutableElements().toArray();t.sort(sd),t.interactive=t.filter(function(e){return e.interactive()}),this.cachedZSortedEles=t,this.updateCachedGrabbedEles()}else t=this.cachedZSortedEles;return t};var em={};[fp,pp,Bp,Hp,Up,Gp,Yp,Qp,$p].forEach(function(e){Z(em,e)});var tm={};tm.getCachedImage=function(e,t,n){var r=this,i=r.imageCache=r.imageCache||{},a=i[e];if(a)return a.image.complete||a.image.addEventListener(`load`,n),a.image;a=i[e]=i[e]||{};var o=a.image=new Image;o.addEventListener(`load`,n),o.addEventListener(`error`,function(){o.error=!0});var s=`data:`;return e.substring(0,s.length).toLowerCase()!==s&&(t=t===`null`?null:t,o.crossOrigin=t),o.src=e,o};var nm=function(e,t){var n=e[0];n&&n._private.grabbed!==t&&(n._private.grabbed=t,e.updateStyle(!1))},rm=function(e){nm(e,!0)},im=function(e){nm(e,!1)},am={};am.registerBinding=function(e,t,n,r){var i=Array.prototype.slice.apply(arguments,[1]);if(Array.isArray(e)){for(var a=[],o=0;o<e.length;o++){var s=e[o];if(s!==void 0){var c=this.binder(s);a.push(c.on.apply(c,i))}}return a}var c=this.binder(e);return c.on.apply(c,i)},am.binder=function(e){var t=this,n=t.cy.window(),r=e===n||e===n.document||e===n.document.body||He(e);if(t.supportsPassiveEvents==null){var i=!1;try{var a=Object.defineProperty({},"passive",{get:function(){return i=!0,!0}});n.addEventListener(`test`,null,a)}catch{}t.supportsPassiveEvents=i}var o=function(n,i,a){var o=Array.prototype.slice.call(arguments);return r&&t.supportsPassiveEvents&&(o[2]={capture:a??!1,passive:!1,once:!1}),t.bindings.push({target:e,args:o}),(e.addEventListener||e.on).apply(e,o),this};return{on:o,addEventListener:o,addListener:o,bind:o}},am.nodeIsDraggable=function(e){return e&&e.isNode()&&!e.locked()&&e.grabbable()},am.nodeIsGrabbable=function(e){return this.nodeIsDraggable(e)&&e.interactive()},am.load=function(){var e=this,t=e.cy.window(),n=function(e){return e.selected()},r=function(e){var t=e.getRootNode();if(t&&t.nodeType===11&&t.host!==void 0)return t},i=function(t,n,r,i){t??=e.cy;for(var a=0;a<n.length;a++){var o=n[a];t.emit({originalEvent:r,type:o,position:i})}},a=function(e){return e.shiftKey||e.metaKey||e.ctrlKey},o=function(t,n){var r=!0;if(e.cy.hasCompoundNodes()&&t&&t.pannable())for(var i=0;n&&i<n.length;i++){var t=n[i];if(t.isNode()&&t.isParent()&&!t.pannable()){r=!1;break}}else r=!0;return r},s=function(e){e[0]._private.rscratch.inDragLayer=!0},c=function(e){e[0]._private.rscratch.inDragLayer=!1},l=function(e){e[0]._private.rscratch.isGrabTarget=!0},u=function(e){e[0]._private.rscratch.isGrabTarget=!1},d=function(e,t){var n=t.addToList;!n.has(e)&&e.grabbable()&&!e.locked()&&(n.merge(e),rm(e))},f=function(e,t){if(e.cy().hasCompoundNodes()&&(t.inDragLayer!=null||t.addToList!=null)){var n=e.descendants();t.inDragLayer&&(n.forEach(s),n.connectedEdges().forEach(s)),t.addToList&&d(n,t)}},p=function(t,n){n||={};var r=t.cy().hasCompoundNodes();n.inDragLayer&&(t.forEach(s),t.neighborhood().stdFilter(function(e){return!r||e.isEdge()}).forEach(s)),n.addToList&&t.forEach(function(e){d(e,n)}),f(t,n),g(t,{inDragLayer:n.inDragLayer}),e.updateCachedGrabbedEles()},m=p,h=function(t){t&&(e.getCachedZSortedEles().forEach(function(e){im(e),c(e),u(e)}),e.updateCachedGrabbedEles())},g=function(e,t){if((t.inDragLayer!=null||t.addToList!=null)&&e.cy().hasCompoundNodes()){var n=e.ancestors().orphans();if(!n.same(e)){var r=n.descendants().spawnSelf().merge(n).unmerge(e).unmerge(e.descendants()),i=r.connectedEdges();t.inDragLayer&&(i.forEach(s),r.forEach(s)),t.addToList&&r.forEach(function(e){d(e,t)})}}},_=function(){document.activeElement!=null&&document.activeElement.blur!=null&&document.activeElement.blur()},v=typeof MutationObserver<`u`,y=typeof ResizeObserver<`u`;v?(e.removeObserver=new MutationObserver(function(t){for(var n=0;n<t.length;n++){var r=t[n].removedNodes;if(r){for(var i=0;i<r.length;i++)if(r[i]===e.container){e.destroy();break}}}}),e.container.parentNode&&e.removeObserver.observe(e.container.parentNode,{childList:!0})):e.registerBinding(e.container,`DOMNodeRemoved`,function(t){e.destroy()});var b=on(function(){e.cy.resize()},100);v&&(e.styleObserver=new MutationObserver(b),e.styleObserver.observe(e.container,{attributes:!0})),e.registerBinding(t,`resize`,b),y&&(e.resizeObserver=new ResizeObserver(b),e.resizeObserver.observe(e.container));var x=function(e,t){for(;e!=null;)t(e),e=e.parentNode},S=function(){e.invalidateContainerClientCoordsCache()};x(e.container,function(t){e.registerBinding(t,`transitionend`,S),e.registerBinding(t,`animationend`,S),e.registerBinding(t,`scroll`,S)}),e.registerBinding(e.container,`contextmenu`,function(e){e.preventDefault()});var C=function(){return e.selection[4]!==0},w=function(t){for(var n=e.findContainerClientCoords(),r=n[0],i=n[1],a=n[2],o=n[3],s=t.touches?t.touches:[t],c=!1,l=0;l<s.length;l++){var u=s[l];if(r<=u.clientX&&u.clientX<=r+a&&i<=u.clientY&&u.clientY<=i+o){c=!0;break}}if(!c)return!1;for(var d=e.container,f=t.target.parentNode,p=!1;f;){if(f===d){p=!0;break}f=f.parentNode}return!!p};e.registerBinding(e.container,`mousedown`,function(t){if(w(t)&&(e.hoverData.which!==1||t.which===1)){t.preventDefault(),_(),e.hoverData.capture=!0,e.hoverData.which=t.which;var n=e.cy,r=[t.clientX,t.clientY],a=e.projectIntoViewport(r[0],r[1]),o=e.selection,s=e.findNearestElements(a[0],a[1],!0,!1),c=s[0],u=e.dragData.possibleDragElements;e.hoverData.mdownPos=a,e.hoverData.mdownGPos=r;var d=function(e){return{originalEvent:t,type:e,position:{x:a[0],y:a[1]}}},f=function(){e.hoverData.tapholdCancelled=!1,clearTimeout(e.hoverData.tapholdTimeout),e.hoverData.tapholdTimeout=setTimeout(function(){if(!e.hoverData.tapholdCancelled){var t=e.hoverData.down;t?t.emit(d(`taphold`)):n.emit(d(`taphold`))}},e.tapholdDuration)};if(t.which==3){e.hoverData.cxtStarted=!0;var h={originalEvent:t,type:`cxttapstart`,position:{x:a[0],y:a[1]}};c?(c.activate(),c.emit(h),e.hoverData.down=c):n.emit(h),e.hoverData.downTime=new Date().getTime(),e.hoverData.cxtDragged=!1}else if(t.which==1){if(c&&c.activate(),c!=null&&e.nodeIsGrabbable(c)){var g=function(e){e.emit(d(`grab`))};if(l(c),!c.selected())u=e.dragData.possibleDragElements=n.collection(),m(c,{addToList:u}),c.emit(d(`grabon`)).emit(d(`grab`));else{u=e.dragData.possibleDragElements=n.collection();var v=n.$(function(t){return t.isNode()&&t.selected()&&e.nodeIsGrabbable(t)});p(v,{addToList:u}),c.emit(d(`grabon`)),v.forEach(g)}e.redrawHint(`eles`,!0),e.redrawHint(`drag`,!0)}e.hoverData.down=c,e.hoverData.downs=s,e.hoverData.downTime=new Date().getTime(),i(c,[`mousedown`,`tapstart`,`vmousedown`],t,{x:a[0],y:a[1]}),c==null?(o[4]=1,e.data.bgActivePosistion={x:a[0],y:a[1]},e.redrawHint(`select`,!0),e.redraw()):c.pannable()&&(o[4]=1),f()}o[0]=o[2]=a[0],o[1]=o[3]=a[1]}},!1);var T=r(e.container);e.registerBinding([t,T],`mousemove`,function(t){if(e.hoverData.capture||w(t)){var n=!1,r=e.cy,s=r.zoom(),c=[t.clientX,t.clientY],l=e.projectIntoViewport(c[0],c[1]),u=e.hoverData.mdownPos,d=e.hoverData.mdownGPos,f=e.selection,m=null;e.hoverData.draggingEles||e.hoverData.dragging||e.hoverData.selecting||(m=e.findNearestElement(l[0],l[1],!0,!1));var g=e.hoverData.last,_=e.hoverData.down,v=[l[0]-f[2],l[1]-f[3]],y=e.dragData.possibleDragElements,b;if(d){var x=c[0]-d[0],S=x*x,C=c[1]-d[1],T=S+C*C;e.hoverData.isOverThresholdDrag=b=T>=e.desktopTapThreshold2}var E=a(t);b&&(e.hoverData.tapholdCancelled=!0);var D=function(){var t=e.hoverData.dragDelta=e.hoverData.dragDelta||[];t.length===0?(t.push(v[0]),t.push(v[1])):(t[0]+=v[0],t[1]+=v[1])};n=!0,i(m,[`mousemove`,`vmousemove`,`tapdrag`],t,{x:l[0],y:l[1]});var O=function(e){return{originalEvent:t,type:e,position:{x:l[0],y:l[1]}}},k=function(){e.data.bgActivePosistion=void 0,e.hoverData.selecting||r.emit(O(`boxstart`)),f[4]=1,e.hoverData.selecting=!0,e.redrawHint(`select`,!0),e.redraw()};if(e.hoverData.which===3){if(b){var A=O(`cxtdrag`);_?_.emit(A):r.emit(A),e.hoverData.cxtDragged=!0,e.hoverData.cxtOver&&m===e.hoverData.cxtOver||(e.hoverData.cxtOver&&e.hoverData.cxtOver.emit(O(`cxtdragout`)),e.hoverData.cxtOver=m,m&&m.emit(O(`cxtdragover`)))}}else if(e.hoverData.dragging){if(n=!0,r.panningEnabled()&&r.userPanningEnabled()){var j;if(e.hoverData.justStartedPan){var M=e.hoverData.mdownPos;j={x:(l[0]-M[0])*s,y:(l[1]-M[1])*s},e.hoverData.justStartedPan=!1}else j={x:v[0]*s,y:v[1]*s};r.panBy(j),r.emit(O(`dragpan`)),e.hoverData.dragged=!0}l=e.projectIntoViewport(t.clientX,t.clientY)}else if(f[4]==1&&(_==null||_.pannable()))b&&(!e.hoverData.dragging&&r.boxSelectionEnabled()&&(E||!r.panningEnabled()||!r.userPanningEnabled())?k():!e.hoverData.selecting&&r.panningEnabled()&&r.userPanningEnabled()&&o(_,e.hoverData.downs)&&(e.hoverData.dragging=!0,e.hoverData.justStartedPan=!0,f[4]=0,e.data.bgActivePosistion=Or(u),e.redrawHint(`select`,!0),e.redraw()),_&&_.pannable()&&_.active()&&_.unactivate());else{if(_&&_.pannable()&&_.active()&&_.unactivate(),_&&_.grabbed()||m==g||(g&&i(g,[`mouseout`,`tapdragout`],t,{x:l[0],y:l[1]}),m&&i(m,[`mouseover`,`tapdragover`],t,{x:l[0],y:l[1]}),e.hoverData.last=m),_){if(b){if(r.boxSelectionEnabled()&&E)_&&_.grabbed()&&(h(y),_.emit(O(`freeon`)),y.emit(O(`free`)),e.dragData.didDrag&&(_.emit(O(`dragfreeon`)),y.emit(O(`dragfree`)))),k();else if(_&&_.grabbed()&&e.nodeIsDraggable(_)){var N=!e.dragData.didDrag;N&&e.redrawHint(`eles`,!0),e.dragData.didDrag=!0,e.hoverData.draggingEles||p(y,{inDragLayer:!0});var P={x:0,y:0};if(X(v[0])&&X(v[1])&&(P.x+=v[0],P.y+=v[1],N)){var F=e.hoverData.dragDelta;F&&X(F[0])&&X(F[1])&&(P.x+=F[0],P.y+=F[1])}e.hoverData.draggingEles=!0,y.silentShift(P).emit(O(`position`)).emit(O(`drag`)),e.redrawHint(`drag`,!0),e.redraw()}}else D()}n=!0}if(f[2]=l[0],f[3]=l[1],n)return t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),!1}},!1);var E,D,O;e.registerBinding(t,`mouseup`,function(t){if(!(e.hoverData.which===1&&t.which!==1&&e.hoverData.capture)&&e.hoverData.capture){e.hoverData.capture=!1;var r=e.cy,o=e.projectIntoViewport(t.clientX,t.clientY),s=e.selection,c=e.findNearestElement(o[0],o[1],!0,!1),l=e.dragData.possibleDragElements,u=e.hoverData.down,d=a(t);e.data.bgActivePosistion&&(e.redrawHint(`select`,!0),e.redraw()),e.hoverData.tapholdCancelled=!0,e.data.bgActivePosistion=void 0,u&&u.unactivate();var f=function(e){return{originalEvent:t,type:e,position:{x:o[0],y:o[1]}}};if(e.hoverData.which===3){var p=f(`cxttapend`);if(u?u.emit(p):r.emit(p),!e.hoverData.cxtDragged){var m=f(`cxttap`);u?u.emit(m):r.emit(m)}e.hoverData.cxtDragged=!1,e.hoverData.which=null}else if(e.hoverData.which===1){if(i(c,[`mouseup`,`tapend`,`vmouseup`],t,{x:o[0],y:o[1]}),e.dragData.didDrag||e.hoverData.dragged||e.hoverData.selecting||e.hoverData.isOverThresholdDrag||(i(u,[`click`,`tap`,`vclick`],t,{x:o[0],y:o[1]}),D=!1,t.timeStamp-O<=r.multiClickDebounceTime()?(E&&clearTimeout(E),D=!0,O=null,i(u,[`dblclick`,`dbltap`,`vdblclick`],t,{x:o[0],y:o[1]})):(E=setTimeout(function(){D||i(u,[`oneclick`,`onetap`,`voneclick`],t,{x:o[0],y:o[1]})},r.multiClickDebounceTime()),O=t.timeStamp)),u!=null||e.dragData.didDrag||e.hoverData.selecting||e.hoverData.dragged||a(t)||(r.$(n).unselect([`tapunselect`]),l.length>0&&e.redrawHint(`eles`,!0),e.dragData.possibleDragElements=l=r.collection()),c==u&&!e.dragData.didDrag&&!e.hoverData.selecting&&c!=null&&c._private.selectable&&(e.hoverData.dragging||(r.selectionType()===`additive`||d?c.selected()?c.unselect([`tapunselect`]):c.select([`tapselect`]):d||(r.$(n).unmerge(c).unselect([`tapunselect`]),c.select([`tapselect`]))),e.redrawHint(`eles`,!0)),e.hoverData.selecting){var g=r.collection(e.getAllInBox(s[0],s[1],s[2],s[3]));e.redrawHint(`select`,!0),g.length>0&&e.redrawHint(`eles`,!0),r.emit(f(`boxend`)),r.selectionType()===`additive`||d||r.$(n).unmerge(g).unselect(),g.emit(f(`box`)).stdFilter(function(e){return e.selectable()&&!e.selected()}).select().emit(f(`boxselect`)),e.redraw()}if(e.hoverData.dragging&&(e.hoverData.dragging=!1,e.redrawHint(`select`,!0),e.redrawHint(`eles`,!0),e.redraw()),!s[4]){e.redrawHint(`drag`,!0),e.redrawHint(`eles`,!0);var _=u&&u.grabbed();h(l),_&&(u.emit(f(`freeon`)),l.emit(f(`free`)),e.dragData.didDrag&&(u.emit(f(`dragfreeon`)),l.emit(f(`dragfree`))))}}s[4]=0,e.hoverData.down=null,e.hoverData.cxtStarted=!1,e.hoverData.draggingEles=!1,e.hoverData.selecting=!1,e.hoverData.isOverThresholdDrag=!1,e.dragData.didDrag=!1,e.hoverData.dragged=!1,e.hoverData.dragDelta=[],e.hoverData.mdownPos=null,e.hoverData.mdownGPos=null,e.hoverData.which=null}},!1);var k=[],A=4,j,M=1e5,N,P=4,F=8,I=15,L=null,R=function(e){for(var t=Math.abs(e[0]),n=1;n<e.length;n++)if(Math.abs(e[n])!==t)return!1;return!0},z=function(t){var n=!1,r=t.deltaY;if(r??(t.wheelDeltaY==null?t.wheelDelta!=null&&(r=t.wheelDelta/4):r=t.wheelDeltaY/4),r!==0){if(j==null){if(k.length>=A){j=!1;var i=k;if(i[0]>=5){var a=R(i)?i[0]:Pr(i);a>1&&(j=!0,M=a,N=a)}}else k.push(Math.abs(r)),n=!0}var o=!1;if(j){var s=Math.abs(r);if(o=Fr(s,M),!o){if(s<Math.min(N/F,I))L=null;else if(!Ne(s)&&Fr(M,s))M=s,L=null,o=!0;else if(s===L){var c=Pr([M,s]);M=c*P>=N?c:s,L=null,o=!0}else L=s,n=Ne(s)||s>M}}if(!e.scrollingPage){var l=e.cy,u=l.zoom(),d=l.pan(),f=e.projectIntoViewport(t.clientX,t.clientY),p=[f[0]*u+d.x,f[1]*u+d.y];if(e.hoverData.draggingEles||e.hoverData.dragging||e.hoverData.cxtStarted||C())t.preventDefault();else if(l.panningEnabled()&&l.userPanningEnabled()&&l.zoomingEnabled()&&l.userZoomingEnabled()){t.preventDefault(),e.data.wheelZooming=!0,clearTimeout(e.data.wheelTimeout),e.data.wheelTimeout=setTimeout(function(){e.data.wheelZooming=!1,e.redrawHint(`eles`,!0),e.redraw()},150);var m;n&&Math.abs(r)>5&&(r=zr(r)*5),m=r/-250,o&&(m/=M,m*=3),m*=e.wheelSensitivity,t.deltaMode===1&&(m*=33);var h=l.zoom()*10**m;t.type===`gesturechange`&&(h=e.gestureStartZoom*t.scale),l.zoom({level:h,renderedPosition:{x:p[0],y:p[1]}}),l.emit({type:t.type===`gesturechange`?`pinchzoom`:`scrollzoom`,originalEvent:t,position:{x:f[0],y:f[1]}})}}}};e.registerBinding(e.container,`wheel`,z,!0),e.registerBinding(t,`scroll`,function(t){e.scrollingPage=!0,clearTimeout(e.scrollingPageTimeout),e.scrollingPageTimeout=setTimeout(function(){e.scrollingPage=!1},250)},!0),e.registerBinding(e.container,`gesturestart`,function(t){e.gestureStartZoom=e.cy.zoom(),e.hasTouchStarted||t.preventDefault()},!0),e.registerBinding(e.container,`gesturechange`,function(t){e.hasTouchStarted||z(t)},!0),e.registerBinding(e.container,`mouseout`,function(t){var n=e.projectIntoViewport(t.clientX,t.clientY);e.cy.emit({originalEvent:t,type:`mouseout`,position:{x:n[0],y:n[1]}})},!1),e.registerBinding(e.container,`mouseover`,function(t){var n=e.projectIntoViewport(t.clientX,t.clientY);e.cy.emit({originalEvent:t,type:`mouseover`,position:{x:n[0],y:n[1]}})},!1);var B,V,H,U,W,ee,G,K,q,J,te,ne,re,ie=function(e,t,n,r){return Math.sqrt((n-e)*(n-e)+(r-t)*(r-t))},ae=function(e,t,n,r){return(n-e)*(n-e)+(r-t)*(r-t)},oe;e.registerBinding(e.container,`touchstart`,oe=function(t){if(e.hasTouchStarted=!0,w(t)){_(),e.touchData.capture=!0,e.data.bgActivePosistion=void 0;var n=e.cy,r=e.touchData.now,a=e.touchData.earlier;if(t.touches[0]){var o=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);r[0]=o[0],r[1]=o[1]}if(t.touches[1]){var o=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);r[2]=o[0],r[3]=o[1]}if(t.touches[2]){var o=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);r[4]=o[0],r[5]=o[1]}var s=function(e){return{originalEvent:t,type:e,position:{x:r[0],y:r[1]}}};if(t.touches[1]){e.touchData.singleTouchMoved=!0,h(e.dragData.touchDragEles);var c=e.findContainerClientCoords();q=c[0],J=c[1],te=c[2],ne=c[3],B=t.touches[0].clientX-q,V=t.touches[0].clientY-J,H=t.touches[1].clientX-q,U=t.touches[1].clientY-J,re=0<=B&&B<=te&&0<=H&&H<=te&&0<=V&&V<=ne&&0<=U&&U<=ne;var u=n.pan(),d=n.zoom();W=ie(B,V,H,U),ee=ae(B,V,H,U),G=[(B+H)/2,(V+U)/2],K=[(G[0]-u.x)/d,(G[1]-u.y)/d];var f=200,g=f*f;if(ee<g&&!t.touches[2]){var v=e.findNearestElement(r[0],r[1],!0,!0),y=e.findNearestElement(r[2],r[3],!0,!0);v&&v.isNode()?(v.activate().emit(s(`cxttapstart`)),e.touchData.start=v):y&&y.isNode()?(y.activate().emit(s(`cxttapstart`)),e.touchData.start=y):n.emit(s(`cxttapstart`)),e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxt=!0,e.touchData.cxtDragged=!1,e.data.bgActivePosistion=void 0,e.redraw();return}}if(t.touches[2])n.boxSelectionEnabled()&&t.preventDefault();else if(!t.touches[1]&&t.touches[0]){var b=e.findNearestElements(r[0],r[1],!0,!0),x=b[0];if(x!=null&&(x.activate(),e.touchData.start=x,e.touchData.starts=b,e.nodeIsGrabbable(x))){var S=e.dragData.touchDragEles=n.collection(),C=null;e.redrawHint(`eles`,!0),e.redrawHint(`drag`,!0),x.selected()?(C=n.$(function(t){return t.selected()&&e.nodeIsGrabbable(t)}),p(C,{addToList:S})):m(x,{addToList:S}),l(x),x.emit(s(`grabon`)),C?C.forEach(function(e){e.emit(s(`grab`))}):x.emit(s(`grab`))}i(x,[`touchstart`,`tapstart`,`vmousedown`],t,{x:r[0],y:r[1]}),x??(e.data.bgActivePosistion={x:o[0],y:o[1]},e.redrawHint(`select`,!0),e.redraw()),e.touchData.singleTouchMoved=!1,e.touchData.singleTouchStartTime=+new Date,clearTimeout(e.touchData.tapholdTimeout),e.touchData.tapholdTimeout=setTimeout(function(){e.touchData.singleTouchMoved===!1&&!e.pinching&&!e.touchData.selecting&&i(e.touchData.start,[`taphold`],t,{x:r[0],y:r[1]})},e.tapholdDuration)}if(t.touches.length>=1){for(var T=e.touchData.startPosition=[null,null,null,null,null,null],E=0;E<r.length;E++)T[E]=a[E]=r[E];var D=t.touches[0];e.touchData.startGPosition=[D.clientX,D.clientY]}}},!1);var se;e.registerBinding(t,`touchmove`,se=function(t){var n=e.touchData.capture;if(n||w(t)){var r=e.selection,a=e.cy,s=e.touchData.now,c=e.touchData.earlier,l=a.zoom();if(t.touches[0]){var u=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);s[0]=u[0],s[1]=u[1]}if(t.touches[1]){var u=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);s[2]=u[0],s[3]=u[1]}if(t.touches[2]){var u=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);s[4]=u[0],s[5]=u[1]}var d=function(e){return{originalEvent:t,type:e,position:{x:s[0],y:s[1]}}},f=e.touchData.startGPosition,m;if(n&&t.touches[0]&&f){for(var g=[],_=0;_<s.length;_++)g[_]=s[_]-c[_];var v=t.touches[0].clientX-f[0],y=v*v,b=t.touches[0].clientY-f[1];m=y+b*b>=e.touchTapThreshold2}if(n&&e.touchData.cxt){t.preventDefault();var x=t.touches[0].clientX-q,S=t.touches[0].clientY-J,C=t.touches[1].clientX-q,T=t.touches[1].clientY-J,E=ae(x,S,C,T),D=E/ee,O=150,k=O*O,A=1.5;if(D>=A*A||E>=k){e.touchData.cxt=!1,e.data.bgActivePosistion=void 0,e.redrawHint(`select`,!0);var j=d(`cxttapend`);e.touchData.start?(e.touchData.start.unactivate().emit(j),e.touchData.start=null):a.emit(j)}}if(n&&e.touchData.cxt){var j=d(`cxtdrag`);e.data.bgActivePosistion=void 0,e.redrawHint(`select`,!0),e.touchData.start?e.touchData.start.emit(j):a.emit(j),e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxtDragged=!0;var M=e.findNearestElement(s[0],s[1],!0,!0);e.touchData.cxtOver&&M===e.touchData.cxtOver||(e.touchData.cxtOver&&e.touchData.cxtOver.emit(d(`cxtdragout`)),e.touchData.cxtOver=M,M&&M.emit(d(`cxtdragover`)))}else if(n&&t.touches[2]&&a.boxSelectionEnabled())t.preventDefault(),e.data.bgActivePosistion=void 0,this.lastThreeTouch=+new Date,e.touchData.selecting||a.emit(d(`boxstart`)),e.touchData.selecting=!0,e.touchData.didSelect=!0,r[4]=1,!r||r.length===0||r[0]===void 0?(r[0]=(s[0]+s[2]+s[4])/3,r[1]=(s[1]+s[3]+s[5])/3,r[2]=(s[0]+s[2]+s[4])/3+1,r[3]=(s[1]+s[3]+s[5])/3+1):(r[2]=(s[0]+s[2]+s[4])/3,r[3]=(s[1]+s[3]+s[5])/3),e.redrawHint(`select`,!0),e.redraw();else if(n&&t.touches[1]&&!e.touchData.didSelect&&a.zoomingEnabled()&&a.panningEnabled()&&a.userZoomingEnabled()&&a.userPanningEnabled()){t.preventDefault(),e.data.bgActivePosistion=void 0,e.redrawHint(`select`,!0);var N=e.dragData.touchDragEles;if(N){e.redrawHint(`drag`,!0);for(var P=0;P<N.length;P++){var F=N[P]._private;F.grabbed=!1,F.rscratch.inDragLayer=!1}}var I=e.touchData.start,x=t.touches[0].clientX-q,S=t.touches[0].clientY-J,C=t.touches[1].clientX-q,T=t.touches[1].clientY-J,L=ie(x,S,C,T),R=L/W;if(re){var z=x-B,G=S-V,te=C-H,ne=T-U,oe=(z+te)/2,se=(G+ne)/2,ce=a.zoom(),le=ce*R,ue=a.pan(),de=K[0]*ce+ue.x,fe=K[1]*ce+ue.y,pe={x:-le/ce*(de-ue.x-oe)+de,y:-le/ce*(fe-ue.y-se)+fe};if(I&&I.active()){var N=e.dragData.touchDragEles;h(N),e.redrawHint(`drag`,!0),e.redrawHint(`eles`,!0),I.unactivate().emit(d(`freeon`)),N&&N.emit(d(`free`)),e.dragData.didDrag&&(I.emit(d(`dragfreeon`)),N&&N.emit(d(`dragfree`)))}a.viewport({zoom:le,pan:pe,cancelOnFailedZoom:!0}),a.emit(d(`pinchzoom`)),W=L,B=x,V=S,H=C,U=T,e.pinching=!0}if(t.touches[0]){var u=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);s[0]=u[0],s[1]=u[1]}if(t.touches[1]){var u=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);s[2]=u[0],s[3]=u[1]}if(t.touches[2]){var u=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);s[4]=u[0],s[5]=u[1]}}else if(t.touches[0]&&!e.touchData.didSelect){var me=e.touchData.start,he=e.touchData.last,M;if(!e.hoverData.draggingEles&&!e.swipePanning&&(M=e.findNearestElement(s[0],s[1],!0,!0)),n&&me!=null&&t.preventDefault(),n&&me!=null&&e.nodeIsDraggable(me)){if(m){var N=e.dragData.touchDragEles,ge=!e.dragData.didDrag;ge&&p(N,{inDragLayer:!0}),e.dragData.didDrag=!0;var _e={x:0,y:0};if(X(g[0])&&X(g[1])&&(_e.x+=g[0],_e.y+=g[1],ge)){e.redrawHint(`eles`,!0);var ve=e.touchData.dragDelta;ve&&X(ve[0])&&X(ve[1])&&(_e.x+=ve[0],_e.y+=ve[1])}e.hoverData.draggingEles=!0,N.silentShift(_e).emit(d(`position`)).emit(d(`drag`)),e.redrawHint(`drag`,!0),e.touchData.startPosition[0]==c[0]&&e.touchData.startPosition[1]==c[1]&&e.redrawHint(`eles`,!0),e.redraw()}else{var ve=e.touchData.dragDelta=e.touchData.dragDelta||[];ve.length===0?(ve.push(g[0]),ve.push(g[1])):(ve[0]+=g[0],ve[1]+=g[1])}}if(i(me||M,[`touchmove`,`tapdrag`,`vmousemove`],t,{x:s[0],y:s[1]}),me&&me.grabbed()||M==he||(he&&he.emit(d(`tapdragout`)),M&&M.emit(d(`tapdragover`))),e.touchData.last=M,n)for(var P=0;P<s.length;P++)s[P]&&e.touchData.startPosition[P]&&m&&(e.touchData.singleTouchMoved=!0);if(n&&(me==null||me.pannable())&&a.panningEnabled()&&a.userPanningEnabled()){o(me,e.touchData.starts)&&(t.preventDefault(),e.data.bgActivePosistion||(e.data.bgActivePosistion=Or(e.touchData.startPosition)),e.swipePanning?(a.panBy({x:g[0]*l,y:g[1]*l}),a.emit(d(`dragpan`))):m&&(e.swipePanning=!0,a.panBy({x:v*l,y:b*l}),a.emit(d(`dragpan`)),me&&(me.unactivate(),e.redrawHint(`select`,!0),e.touchData.start=null)));var u=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);s[0]=u[0],s[1]=u[1]}}for(var _=0;_<s.length;_++)c[_]=s[_];n&&t.touches.length>0&&!e.hoverData.draggingEles&&!e.swipePanning&&e.data.bgActivePosistion!=null&&(e.data.bgActivePosistion=void 0,e.redrawHint(`select`,!0),e.redraw())}},!1);var ce;e.registerBinding(t,`touchcancel`,ce=function(t){var n=e.touchData.start;e.touchData.capture=!1,n&&n.unactivate()});var le,ue,de,fe;if(e.registerBinding(t,`touchend`,le=function(t){var r=e.touchData.start;if(e.touchData.capture)t.touches.length===0&&(e.touchData.capture=!1),t.preventDefault();else return;var a=e.selection;e.swipePanning=!1,e.hoverData.draggingEles=!1;var o=e.cy,s=o.zoom(),c=e.touchData.now,l=e.touchData.earlier;if(t.touches[0]){var u=e.projectIntoViewport(t.touches[0].clientX,t.touches[0].clientY);c[0]=u[0],c[1]=u[1]}if(t.touches[1]){var u=e.projectIntoViewport(t.touches[1].clientX,t.touches[1].clientY);c[2]=u[0],c[3]=u[1]}if(t.touches[2]){var u=e.projectIntoViewport(t.touches[2].clientX,t.touches[2].clientY);c[4]=u[0],c[5]=u[1]}var d=function(e){return{originalEvent:t,type:e,position:{x:c[0],y:c[1]}}};r&&r.unactivate();var f;if(e.touchData.cxt){if(f=d(`cxttapend`),r?r.emit(f):o.emit(f),!e.touchData.cxtDragged){var p=d(`cxttap`);r?r.emit(p):o.emit(p)}e.touchData.start&&(e.touchData.start._private.grabbed=!1),e.touchData.cxt=!1,e.touchData.start=null,e.redraw()}else{if(!t.touches[2]&&o.boxSelectionEnabled()&&e.touchData.selecting){e.touchData.selecting=!1;var m=o.collection(e.getAllInBox(a[0],a[1],a[2],a[3]));a[0]=void 0,a[1]=void 0,a[2]=void 0,a[3]=void 0,a[4]=0,e.redrawHint(`select`,!0),o.emit(d(`boxend`)),m.emit(d(`box`)).stdFilter(function(e){return e.selectable()&&!e.selected()}).select().emit(d(`boxselect`)),m.nonempty()&&e.redrawHint(`eles`,!0),e.redraw()}if(r?.unactivate(),t.touches[2])e.data.bgActivePosistion=void 0,e.redrawHint(`select`,!0);else if(!t.touches[1]&&!t.touches[0]&&!t.touches[0]){e.data.bgActivePosistion=void 0,e.redrawHint(`select`,!0);var g=e.dragData.touchDragEles;if(r!=null){var _=r._private.grabbed;h(g),e.redrawHint(`drag`,!0),e.redrawHint(`eles`,!0),_&&(r.emit(d(`freeon`)),g.emit(d(`free`)),e.dragData.didDrag&&(r.emit(d(`dragfreeon`)),g.emit(d(`dragfree`)))),i(r,[`touchend`,`tapend`,`vmouseup`,`tapdragout`],t,{x:c[0],y:c[1]}),r.unactivate(),e.touchData.start=null}else i(e.findNearestElement(c[0],c[1],!0,!0),[`touchend`,`tapend`,`vmouseup`,`tapdragout`],t,{x:c[0],y:c[1]});var v=e.touchData.startPosition[0]-c[0],y=v*v,b=e.touchData.startPosition[1]-c[1],x=(y+b*b)*s*s;e.touchData.singleTouchMoved||(r||o.$(`:selected`).unselect([`tapunselect`]),i(r,[`tap`,`vclick`],t,{x:c[0],y:c[1]}),ue=!1,t.timeStamp-fe<=o.multiClickDebounceTime()?(de&&clearTimeout(de),ue=!0,fe=null,i(r,[`dbltap`,`vdblclick`],t,{x:c[0],y:c[1]})):(de=setTimeout(function(){ue||i(r,[`onetap`,`voneclick`],t,{x:c[0],y:c[1]})},o.multiClickDebounceTime()),fe=t.timeStamp)),r!=null&&!e.dragData.didDrag&&r._private.selectable&&x<e.touchTapThreshold2&&!e.pinching&&(o.selectionType()===`single`?(o.$(n).unmerge(r).unselect([`tapunselect`]),r.select([`tapselect`])):r.selected()?r.unselect([`tapunselect`]):r.select([`tapselect`]),e.redrawHint(`eles`,!0)),e.touchData.singleTouchMoved=!0}for(var S=0;S<c.length;S++)l[S]=c[S];e.dragData.didDrag=!1,t.touches.length===0&&(e.touchData.dragDelta=[],e.touchData.startPosition=[null,null,null,null,null,null],e.touchData.startGPosition=null,e.touchData.didSelect=!1),t.touches.length<2&&(t.touches.length===1&&(e.touchData.startGPosition=[t.touches[0].clientX,t.touches[0].clientY]),e.pinching=!1,e.redrawHint(`eles`,!0),e.redraw())}},!1),typeof TouchEvent>`u`){var pe=[],me=function(e){return{clientX:e.clientX,clientY:e.clientY,force:1,identifier:e.pointerId,pageX:e.pageX,pageY:e.pageY,radiusX:e.width/2,radiusY:e.height/2,screenX:e.screenX,screenY:e.screenY,target:e.target}},he=function(e){return{event:e,touch:me(e)}},ge=function(e){pe.push(he(e))},_e=function(e){for(var t=0;t<pe.length;t++)if(pe[t].event.pointerId===e.pointerId){pe.splice(t,1);return}},ve=function(e){var t=pe.filter(function(t){return t.event.pointerId===e.pointerId})[0];t.event=e,t.touch=me(e)},ye=function(e){e.touches=pe.map(function(e){return e.touch})},be=function(e){return e.pointerType===`mouse`||e.pointerType===4};e.registerBinding(e.container,`pointerdown`,function(e){be(e)||(e.preventDefault(),ge(e),ye(e),oe(e))}),e.registerBinding(e.container,`pointerup`,function(e){be(e)||(_e(e),ye(e),le(e))}),e.registerBinding(e.container,`pointercancel`,function(e){be(e)||(_e(e),ye(e),ce(e))}),e.registerBinding(e.container,`pointermove`,function(e){be(e)||(e.preventDefault(),ve(e),ye(e),se(e))})}};var om={};om.generatePolygon=function(e,t){return this.nodeShapes[e]={renderer:this,name:e,points:t,draw:function(e,t,n,r,i,a){this.renderer.nodeShapeImpl(`polygon`,e,t,n,r,i,this.points)},intersectLine:function(e,t,n,r,i,a,o,s){return Ei(i,a,this.points,e,t,n/2,r/2,o)},checkPoint:function(e,t,n,r,i,a,o,s){return gi(e,t,this.points,a,o,r,i,[0,-1],n)},hasMiterBounds:e!==`rectangle`,miterBounds:function(e,t,n,r,i,a){return si(this.points,e,t,n,r,i)}}},om.generateEllipse=function(){return this.nodeShapes.ellipse={renderer:this,name:`ellipse`,draw:function(e,t,n,r,i,a){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i)},intersectLine:function(e,t,n,r,i,a,o,s){return bi(i,a,e,t,n/2+o,r/2+o)},checkPoint:function(e,t,n,r,i,a,o,s){return xi(e,t,r,i,a,o,n)}}},om.generateRoundPolygon=function(e,t){return this.nodeShapes[e]={renderer:this,name:e,points:t,getOrCreateCorners:function(e,n,r,i,a,o,s){if(o[s]!==void 0&&o[s+`-cx`]===e&&o[s+`-cy`]===n&&o[s+`-w`]===r&&o[s+`-h`]===i&&o[s+`-corner-radius`]===a)return o[s];o[s]=Array(t.length/2),o[s+`-cx`]=e,o[s+`-cy`]=n,o[s+`-w`]=r,o[s+`-h`]=i,o[s+`-corner-radius`]=a;var c=r/2,l=i/2;a=a===`auto`?Ni(r,i):a;for(var u=Array(t.length/2),d=0;d<t.length/2;d++)u[d]={x:e+c*t[d*2],y:n+l*t[d*2+1]};var f,p,m,h,g=u.length;for(p=u[g-1],f=0;f<g;f++)m=u[f%g],h=u[(f+1)%g],o[s][f]=Lp(p,m,h,a),p=m,m=h;return o[s]},draw:function(e,t,n,r,i,a,o){this.renderer.nodeShapeImpl(`round-polygon`,e,t,n,r,i,this.points,this.getOrCreateCorners(t,n,r,i,a,o,`drawCorners`))},intersectLine:function(e,t,n,r,i,a,o,s,c){return Di(i,a,this.points,e,t,n,r,o,this.getOrCreateCorners(e,t,n,r,s,c,`corners`))},checkPoint:function(e,t,n,r,i,a,o,s,c){return _i(e,t,this.points,a,o,r,i,this.getOrCreateCorners(a,o,r,i,s,c,`corners`))}}},om.generateRoundRectangle=function(){return this.nodeShapes[`round-rectangle`]=this.nodeShapes.roundrectangle={renderer:this,name:`round-rectangle`,points:ki(4,0),draw:function(e,t,n,r,i,a){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i,this.points,a)},intersectLine:function(e,t,n,r,i,a,o,s){return ci(i,a,e,t,n,r,o,s)},checkPoint:function(e,t,n,r,i,a,o,s){var c=r/2,l=i/2;s=s===`auto`?Mi(r,i):s,s=Math.min(c,l,s);var u=s*2;return!!(gi(e,t,this.points,a,o,r,i-u,[0,-1],n)||gi(e,t,this.points,a,o,r-u,i,[0,-1],n)||xi(e,t,u,u,a-c+s,o-l+s,n)||xi(e,t,u,u,a+c-s,o-l+s,n)||xi(e,t,u,u,a+c-s,o+l-s,n)||xi(e,t,u,u,a-c+s,o+l-s,n))}}},om.generateCutRectangle=function(){return this.nodeShapes[`cut-rectangle`]=this.nodeShapes.cutrectangle={renderer:this,name:`cut-rectangle`,cornerLength:Pi(),points:ki(4,0),draw:function(e,t,n,r,i,a){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i,null,a)},generateCutTrianglePts:function(e,t,n,r,i){var a=i===`auto`?this.cornerLength:i,o=t/2,s=e/2,c=n-s,l=n+s,u=r-o,d=r+o;return{topLeft:[c,u+a,c+a,u,c+a,u+a],topRight:[l-a,u,l,u+a,l-a,u+a],bottomRight:[l,d-a,l-a,d,l-a,d-a],bottomLeft:[c+a,d,c,d-a,c+a,d-a]}},intersectLine:function(e,t,n,r,i,a,o,s){var c=this.generateCutTrianglePts(n+2*o,r+2*o,e,t,s);return Ei(i,a,[].concat.apply([],[c.topLeft.splice(0,4),c.topRight.splice(0,4),c.bottomRight.splice(0,4),c.bottomLeft.splice(0,4)]),e,t)},checkPoint:function(e,t,n,r,i,a,o,s){var c=s===`auto`?this.cornerLength:s;if(gi(e,t,this.points,a,o,r,i-2*c,[0,-1],n)||gi(e,t,this.points,a,o,r-2*c,i,[0,-1],n))return!0;var l=this.generateCutTrianglePts(r,i,a,o);return hi(e,t,l.topLeft)||hi(e,t,l.topRight)||hi(e,t,l.bottomRight)||hi(e,t,l.bottomLeft)}}},om.generateBarrel=function(){return this.nodeShapes.barrel={renderer:this,name:`barrel`,points:ki(4,0),draw:function(e,t,n,r,i,a){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i)},intersectLine:function(e,t,n,r,i,a,o,s){var c=this.generateBarrelBezierPts(n+2*o,r+2*o,e,t),l=function(e){var t=Wr({x:e[0],y:e[1]},{x:e[2],y:e[3]},{x:e[4],y:e[5]},.15),n=Wr({x:e[0],y:e[1]},{x:e[2],y:e[3]},{x:e[4],y:e[5]},.5),r=Wr({x:e[0],y:e[1]},{x:e[2],y:e[3]},{x:e[4],y:e[5]},.85);return[e[0],e[1],t.x,t.y,n.x,n.y,r.x,r.y,e[4],e[5]]};return Ei(i,a,[].concat(l(c.topLeft),l(c.topRight),l(c.bottomRight),l(c.bottomLeft)),e,t)},generateBarrelBezierPts:function(e,t,n,r){var i=t/2,a=e/2,o=n-a,s=n+a,c=r-i,l=r+i,u=Ii(e,t),d=u.heightOffset,f=u.widthOffset,p=u.ctrlPtOffsetPct*e,m={topLeft:[o,c+d,o+p,c,o+f,c],topRight:[s-f,c,s-p,c,s,c+d],bottomRight:[s,l-d,s-p,l,s-f,l],bottomLeft:[o+f,l,o+p,l,o,l-d]};return m.topLeft.isTop=!0,m.topRight.isTop=!0,m.bottomLeft.isBottom=!0,m.bottomRight.isBottom=!0,m},checkPoint:function(e,t,n,r,i,a,o,s){var c=Ii(r,i),l=c.heightOffset,u=c.widthOffset;if(gi(e,t,this.points,a,o,r,i-2*l,[0,-1],n)||gi(e,t,this.points,a,o,r-2*u,i,[0,-1],n))return!0;for(var d=this.generateBarrelBezierPts(r,i,a,o),f=function(e,t,n){var r=n[4],i=n[2],a=n[0],o=n[5],s=n[1];if(Math.min(r,a)<=e&&e<=Math.max(r,a)&&Math.min(o,s)<=t&&t<=Math.max(o,s)){var c=Fi(r,i,a),l=di(c[0],c[1],c[2],e).filter(function(e){return 0<=e&&e<=1});if(l.length>0)return l[0]}return null},p=Object.keys(d),m=0;m<p.length;m++){var h=d[p[m]],g=f(e,t,h);if(g!=null){var _=h[5],v=h[3],y=h[1],b=Ur(_,v,y,g);if(h.isTop&&b<=t||h.isBottom&&t<=b)return!0}}return!1}}},om.generateBottomRoundrectangle=function(){return this.nodeShapes[`bottom-round-rectangle`]=this.nodeShapes.bottomroundrectangle={renderer:this,name:`bottom-round-rectangle`,points:ki(4,0),draw:function(e,t,n,r,i,a){this.renderer.nodeShapeImpl(this.name,e,t,n,r,i,this.points,a)},intersectLine:function(e,t,n,r,i,a,o,s){var c=e-(n/2+o),l=t-(r/2+o),u=l,d=wi(i,a,e,t,c,l,e+(n/2+o),u,!1);return d.length>0?d:ci(i,a,e,t,n,r,o,s)},checkPoint:function(e,t,n,r,i,a,o,s){s=s===`auto`?Mi(r,i):s;var c=2*s;if(gi(e,t,this.points,a,o,r,i-c,[0,-1],n)||gi(e,t,this.points,a,o,r-c,i,[0,-1],n))return!0;var l=r/2+2*n,u=i/2+2*n;return!!(hi(e,t,[a-l,o-u,a-l,o,a+l,o,a+l,o-u])||xi(e,t,c,c,a+r/2-s,o+i/2-s,n)||xi(e,t,c,c,a-r/2+s,o+i/2-s,n))}}},om.registerNodeShapes=function(){var e=this.nodeShapes={},t=this;this.generateEllipse(),this.generatePolygon(`triangle`,ki(3,0)),this.generateRoundPolygon(`round-triangle`,ki(3,0)),this.generatePolygon(`rectangle`,ki(4,0)),e.square=e.rectangle,this.generateRoundRectangle(),this.generateCutRectangle(),this.generateBarrel(),this.generateBottomRoundrectangle();var n=[0,1,1,0,0,-1,-1,0];this.generatePolygon(`diamond`,n),this.generateRoundPolygon(`round-diamond`,n),this.generatePolygon(`pentagon`,ki(5,0)),this.generateRoundPolygon(`round-pentagon`,ki(5,0)),this.generatePolygon(`hexagon`,ki(6,0)),this.generateRoundPolygon(`round-hexagon`,ki(6,0)),this.generatePolygon(`heptagon`,ki(7,0)),this.generateRoundPolygon(`round-heptagon`,ki(7,0)),this.generatePolygon(`octagon`,ki(8,0)),this.generateRoundPolygon(`round-octagon`,ki(8,0));var r=Array(20),i=ji(5,0),a=ji(5,Math.PI/5),o=.5*(3-Math.sqrt(5));o*=1.57;for(var s=0;s<a.length/2;s++)a[s*2]*=o,a[s*2+1]*=o;for(var s=0;s<5;s++)r[s*4]=i[s*2],r[s*4+1]=i[s*2+1],r[s*4+2]=a[s*2],r[s*4+3]=a[s*2+1];r=Ai(r),this.generatePolygon(`star`,r),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 c=[-1,-1,.25,-1,1,0,.25,1,-1,1];this.generatePolygon(`tag`,c),this.generateRoundPolygon(`round-tag`,c),e.makePolygon=function(e){var n=`polygon-`+e.join(`$`),r;return(r=this[n])?r:t.generatePolygon(n,e)}};var sm={};sm.timeToRender=function(){return this.redrawTotalTime/this.redrawCount},sm.redraw=function(e){e||=Wn();var t=this;t.averageRedrawTime===void 0&&(t.averageRedrawTime=0),t.lastRedrawTime===void 0&&(t.lastRedrawTime=0),t.lastDrawTime===void 0&&(t.lastDrawTime=0),t.requestedFrame=!0,t.renderOptions=e},sm.beforeRender=function(e,t){if(!this.destroyed){t??In(`Priority is not optional for beforeRender`);var n=this.beforeRenderCallbacks;n.push({fn:e,priority:t}),n.sort(function(e,t){return t.priority-e.priority})}};var cm=function(e,t,n){for(var r=e.beforeRenderCallbacks,i=0;i<r.length;i++)r[i].fn(t,n)};sm.startRenderLoop=function(){var e=this,t=e.cy;if(!e.renderLoopStarted){e.renderLoopStarted=!0;var n=function(r){if(!e.destroyed){if(!t.batching()){if(e.requestedFrame&&!e.skipFrame){e.requestedFrame=!1,cm(e,!0,r);var i=dn();e.render(e.renderOptions);var a=e.lastDrawTime=dn();e.averageRedrawTime===void 0&&(e.averageRedrawTime=a-i),e.redrawCount===void 0&&(e.redrawCount=0),e.redrawCount++,e.redrawTotalTime===void 0&&(e.redrawTotalTime=0);var o=a-i;e.redrawTotalTime+=o,e.lastRedrawTime=o,e.averageRedrawTime=e.averageRedrawTime/2+o/2}else cm(e,!1,r)}e.skipFrame=!1,un(n)}};un(n)}};var lm=function(e){this.init(e)},um=lm.prototype;um.clientFunctions=[`redrawHint`,`render`,`renderTo`,`matchCanvasSize`,`nodeShapeImpl`,`arrowShapeImpl`],um.init=function(e){var t=this;t.options=e,t.cy=e.cy;var n=t.container=e.cy.container(),r=t.cy.window();if(r){var i=r.document,a=i.head,o=`__________cytoscape_stylesheet`,s=`__________cytoscape_container`,c=i.getElementById(o)!=null;if(n.className.indexOf(s)<0&&(n.className=(n.className||``)+` `+s),!c){var l=i.createElement(`style`);l.id=o,l.textContent=`.`+s+` { position: relative; }`,a.insertBefore(l,a.children[0])}r.getComputedStyle(n).getPropertyValue(`position`)===`static`&&Rn(`A Cytoscape container has style position:static and so can not use UI extensions properly`)}t.selection=[void 0,void 0,void 0,void 0,0],t.bezierProjPcts=[.05,.225,.4,.5,.6,.775,.95],t.hoverData={down:null,last:null,downTime:null,triggerMode:null,dragging:!1,initialPan:[null,null],capture:!1},t.dragData={possibleDragElements:[]},t.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]},t.redraws=0,t.showFps=e.showFps,t.debug=e.debug,t.webgl=e.webgl,t.hideEdgesOnViewport=e.hideEdgesOnViewport,t.textureOnViewport=e.textureOnViewport,t.wheelSensitivity=e.wheelSensitivity,t.motionBlurEnabled=e.motionBlur,t.forcedPixelRatio=X(e.pixelRatio)?e.pixelRatio:null,t.motionBlur=e.motionBlur,t.motionBlurOpacity=e.motionBlurOpacity,t.motionBlurTransparency=1-t.motionBlurOpacity,t.motionBlurPxRatio=1,t.mbPxRBlurry=1,t.minMbLowQualFrames=4,t.fullQualityMb=!1,t.clearedForMotionBlur=[],t.desktopTapThreshold=e.desktopTapThreshold,t.desktopTapThreshold2=e.desktopTapThreshold*e.desktopTapThreshold,t.touchTapThreshold=e.touchTapThreshold,t.touchTapThreshold2=e.touchTapThreshold*e.touchTapThreshold,t.tapholdDuration=500,t.bindings=[],t.beforeRenderCallbacks=[],t.beforeRenderPriorities={animations:400,eleCalcs:300,eleTxrDeq:200,lyrTxrDeq:150,lyrTxrSkip:100},t.registerNodeShapes(),t.registerArrowShapes(),t.registerCalculationListeners()},um.notify=function(e,t){var n=this,r=n.cy;this.destroyed||(e===`init`?n.load():e===`destroy`?n.destroy():((e===`add`||e===`remove`||e===`move`&&r.hasCompoundNodes()||e===`load`||e===`zorder`||e===`mount`)&&n.invalidateCachedZSortedEles(),e===`viewport`&&n.redrawHint(`select`,!0),e===`gc`&&n.redrawHint(`gc`,!0),(e===`load`||e===`resize`||e===`mount`)&&(n.invalidateContainerClientCoordsCache(),n.matchCanvasSize(n.container)),n.redrawHint(`eles`,!0),n.redrawHint(`drag`,!0),this.startRenderLoop(),this.redraw()))},um.destroy=function(){var e=this;e.destroyed=!0,e.cy.stopAnimationLoop();for(var t=0;t<e.bindings.length;t++){var n=e.bindings[t],r=n.target;(r.off||r.removeEventListener).apply(r,n.args)}if(e.bindings=[],e.beforeRenderCallbacks=[],e.onUpdateEleCalcsFns=[],e.removeObserver&&e.removeObserver.disconnect(),e.styleObserver&&e.styleObserver.disconnect(),e.resizeObserver&&e.resizeObserver.disconnect(),e.labelCalcDiv)try{document.body.removeChild(e.labelCalcDiv)}catch{}},um.isHeadless=function(){return!1},[dp,em,tm,am,om,sm].forEach(function(e){Z(um,e)});var dm=1e3/60,fm={setupDequeueing:function(e){return function(){var t=this,n=this.renderer;if(!t.dequeueingSetup){t.dequeueingSetup=!0;var r=on(function(){n.redrawHint(`eles`,!0),n.redrawHint(`drag`,!0),n.redraw()},e.deqRedrawThreshold),i=function(i,a){var o=dn(),s=n.averageRedrawTime,c=n.lastRedrawTime,l=[],u=n.cy.extent(),d=n.getPixelRatio();for(i||n.flushRenderedStyleQueue();;){var f=dn(),p=f-o,m=f-a;if(c<dm){var h=dm-(i?s:0);if(m>=e.deqFastCost*h)break}else if(i){if(p>=e.deqCost*c||p>=e.deqAvgCost*s)break}else if(m>=e.deqNoDrawCost*dm)break;var g=e.deq(t,d,u);if(g.length>0)for(var _=0;_<g.length;_++)l.push(g[_]);else break}l.length>0&&(e.onDeqd(t,l),!i&&e.shouldRedraw(t,l,d,u)&&r())},a=e.priority||Fn;n.beforeRender(i,a(t))}}}},pm=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Nn;se(this,e),this.idsByKey=new Zn,this.keyForId=new Zn,this.cachesByLvl=new Zn,this.lvls=[],this.getKey=t,this.doesEleInvalidateKey=n}return le(e,[{key:`getIdsFor`,value:function(e){e??In(`Can not get id list for null key`);var t=this.idsByKey,n=this.idsByKey.get(e);return n||(n=new er,t.set(e,n)),n}},{key:`addIdForKey`,value:function(e,t){e!=null&&this.getIdsFor(e).add(t)}},{key:`deleteIdForKey`,value:function(e,t){e!=null&&this.getIdsFor(e).delete(t)}},{key:`getNumberOfIdsForKey`,value:function(e){return e==null?0:this.getIdsFor(e).size}},{key:`updateKeyMappingFor`,value:function(e){var t=e.id(),n=this.keyForId.get(t),r=this.getKey(e);this.deleteIdForKey(n,t),this.addIdForKey(r,t),this.keyForId.set(t,r)}},{key:`deleteKeyMappingFor`,value:function(e){var t=e.id(),n=this.keyForId.get(t);this.deleteIdForKey(n,t),this.keyForId.delete(t)}},{key:`keyHasChangedFor`,value:function(e){var t=e.id();return this.keyForId.get(t)!==this.getKey(e)}},{key:`isInvalid`,value:function(e){return this.keyHasChangedFor(e)||this.doesEleInvalidateKey(e)}},{key:`getCachesAt`,value:function(e){var t=this.cachesByLvl,n=this.lvls,r=t.get(e);return r||(r=new Zn,t.set(e,r),n.push(e)),r}},{key:`getCache`,value:function(e,t){return this.getCachesAt(t).get(e)}},{key:`get`,value:function(e,t){var n=this.getKey(e),r=this.getCache(n,t);return r!=null&&this.updateKeyMappingFor(e),r}},{key:`getForCachedKey`,value:function(e,t){var n=this.keyForId.get(e.id());return this.getCache(n,t)}},{key:`hasCache`,value:function(e,t){return this.getCachesAt(t).has(e)}},{key:`has`,value:function(e,t){var n=this.getKey(e);return this.hasCache(n,t)}},{key:`setCache`,value:function(e,t,n){n.key=e,this.getCachesAt(t).set(e,n)}},{key:`set`,value:function(e,t,n){var r=this.getKey(e);this.setCache(r,t,n),this.updateKeyMappingFor(e)}},{key:`deleteCache`,value:function(e,t){this.getCachesAt(t).delete(e)}},{key:`delete`,value:function(e,t){var n=this.getKey(e);this.deleteCache(n,t)}},{key:`invalidateKey`,value:function(e){var t=this;this.lvls.forEach(function(n){return t.deleteCache(e,n)})}},{key:`invalidate`,value:function(e){var t=e.id(),n=this.keyForId.get(t);this.deleteKeyMappingFor(e);var r=this.doesEleInvalidateKey(e);return r&&this.invalidateKey(n),r||this.getNumberOfIdsForKey(n)===0}}])}(),mm=25,hm=50,gm=-4,_m=3,vm=7.99,ym=8,bm=1024,xm=1024,Sm=1024,Cm=.2,wm=.8,Tm=10,Em=.15,Dm=.1,Om=.9,km=.9,Am=100,jm=1,Mm={dequeue:`dequeue`,downscale:`downscale`,highQuality:`highQuality`},Nm=Gn({getKey:null,doesEleInvalidateKey:Nn,drawElement:null,getBoundingBox:null,getRotationPoint:null,getRotationOffset:null,isVisible:Mn,allowEdgeTxrCaching:!0,allowParentTxrCaching:!0}),Pm=function(e,t){var n=this;n.renderer=e,n.onDequeues=[];var r=Nm(t);Z(n,r),n.lookup=new pm(r.getKey,r.doesEleInvalidateKey),n.setupDequeueing()},Fm=Pm.prototype;Fm.reasons=Mm,Fm.getTextureQueue=function(e){var t=this;return t.eleImgCaches=t.eleImgCaches||{},t.eleImgCaches[e]=t.eleImgCaches[e]||[]},Fm.getRetiredTextureQueue=function(e){var t=this,n=t.eleImgCaches.retired=t.eleImgCaches.retired||{};return n[e]=n[e]||[]},Fm.getElementQueue=function(){var e=this;return e.eleCacheQueue=e.eleCacheQueue||new dr(function(e,t){return t.reqs-e.reqs})},Fm.getElementKeyToQueue=function(){var e=this;return e.eleKeyToCacheQueue=e.eleKeyToCacheQueue||{}},Fm.getElement=function(e,t,n,r,i){var a=this,o=this.renderer,s=o.cy.zoom(),c=this.lookup;if(!t||t.w===0||t.h===0||isNaN(t.w)||isNaN(t.h)||!e.visible()||e.removed()||!a.allowEdgeTxrCaching&&e.isEdge()||!a.allowParentTxrCaching&&e.isParent())return null;if(r??=Math.ceil(Rr(s*n)),r<gm)r=gm;else if(s>=vm||r>_m)return null;var l=2**r,u=t.h*l,d=t.w*l,f=o.eleTextBiggerThanMin(e,l);if(!this.isVisible(e,f))return null;var p=c.get(e,r);if(p&&p.invalidated&&(p.invalidated=!1,p.texture.invalidatedWidth-=p.width),p)return p;var m=u<=mm?mm:u<=hm?hm:Math.ceil(u/hm)*hm;if(u>Sm||d>xm)return null;var h=a.getTextureQueue(m),g=h[h.length-2],_=function(){return a.recycleTexture(m,d)||a.addTexture(m,d)};g||=h[h.length-1],g||=_(),g.width-g.usedWidth<d&&(g=_());for(var v=function(e){return e&&e.scaledLabelShown===f},y=i&&i===Mm.dequeue,b=i&&i===Mm.highQuality,x=i&&i===Mm.downscale,S,C=r+1;C<=_m;C++){var w=c.get(e,C);if(w){S=w;break}}var T=S&&S.level===r+1?S:null,E=function(){g.context.drawImage(T.texture.canvas,T.x,0,T.width,T.height,g.usedWidth,0,d,u)};if(g.context.setTransform(1,0,0,1,0,0),g.context.clearRect(g.usedWidth,0,d,m),v(T))E();else if(v(S)){if(b){for(var D=S.level;D>r;D--)T=a.getElement(e,t,n,D,Mm.downscale);E()}else return a.queueElement(e,S.level-1),S}else{var O;if(!y&&!b&&!x)for(var k=r-1;k>=gm;k--){var A=c.get(e,k);if(A){O=A;break}}if(v(O))return a.queueElement(e,r),O;g.context.translate(g.usedWidth,0),g.context.scale(l,l),this.drawElement(g.context,e,t,f,!1),g.context.scale(1/l,1/l),g.context.translate(-g.usedWidth,0)}return p={x:g.usedWidth,texture:g,level:r,scale:l,width:d,height:u,scaledLabelShown:f},g.usedWidth+=Math.ceil(d+ym),g.eleCaches.push(p),c.set(e,r,p),a.checkTextureFullness(g),p},Fm.invalidateElements=function(e){for(var t=0;t<e.length;t++)this.invalidateElement(e[t])},Fm.invalidateElement=function(e){var t=this,n=t.lookup,r=[];if(n.isInvalid(e)){for(var i=gm;i<=_m;i++){var a=n.getForCachedKey(e,i);a&&r.push(a)}if(n.invalidate(e))for(var o=0;o<r.length;o++){var s=r[o],c=s.texture;c.invalidatedWidth+=s.width,s.invalidated=!0,t.checkTextureUtility(c)}t.removeFromQueue(e)}},Fm.checkTextureUtility=function(e){e.invalidatedWidth>=Cm*e.width&&this.retireTexture(e)},Fm.checkTextureFullness=function(e){var t=this.getTextureQueue(e.height);e.usedWidth/e.width>wm&&e.fullnessChecks>=Tm?Kn(t,e):e.fullnessChecks++},Fm.retireTexture=function(e){var t=this,n=e.height,r=t.getTextureQueue(n),i=this.lookup;Kn(r,e),e.retired=!0;for(var a=e.eleCaches,o=0;o<a.length;o++){var s=a[o];i.deleteCache(s.key,s.level)}qn(a),t.getRetiredTextureQueue(n).push(e)},Fm.addTexture=function(e,t){var n=this,r=n.getTextureQueue(e),i={};return r.push(i),i.eleCaches=[],i.height=e,i.width=Math.max(bm,t),i.usedWidth=0,i.invalidatedWidth=0,i.fullnessChecks=0,i.canvas=n.renderer.makeOffscreenCanvas(i.width,i.height),i.context=i.canvas.getContext(`2d`),i},Fm.recycleTexture=function(e,t){for(var n=this,r=n.getTextureQueue(e),i=n.getRetiredTextureQueue(e),a=0;a<i.length;a++){var o=i[a];if(o.width>=t)return o.retired=!1,o.usedWidth=0,o.invalidatedWidth=0,o.fullnessChecks=0,qn(o.eleCaches),o.context.setTransform(1,0,0,1,0,0),o.context.clearRect(0,0,o.width,o.height),Kn(i,o),r.push(o),o}},Fm.queueElement=function(e,t){var n=this,r=n.getElementQueue(),i=n.getElementKeyToQueue(),a=this.getKey(e),o=i[a];if(o)o.level=Math.max(o.level,t),o.eles.merge(e),o.reqs++,r.updateItem(o);else{var s={eles:e.spawn().merge(e),level:t,reqs:1,key:a};r.push(s),i[a]=s}},Fm.dequeue=function(e){for(var t=this,n=t.getElementQueue(),r=t.getElementKeyToQueue(),i=[],a=t.lookup,o=0;o<jm&&n.size()>0;o++){var s=n.pop(),c=s.key,l=s.eles[0],u=a.hasCache(l,s.level);if(r[c]=null,!u){i.push(s);var d=t.getBoundingBox(l);t.getElement(l,d,e,s.level,Mm.dequeue)}}return i},Fm.removeFromQueue=function(e){var t=this,n=t.getElementQueue(),r=t.getElementKeyToQueue(),i=this.getKey(e),a=r[i];a!=null&&(a.eles.length===1?(a.reqs=jn,n.updateItem(a),n.pop(),r[i]=null):a.eles.unmerge(e))},Fm.onDequeue=function(e){this.onDequeues.push(e)},Fm.offDequeue=function(e){Kn(this.onDequeues,e)},Fm.setupDequeueing=fm.setupDequeueing({deqRedrawThreshold:Am,deqCost:Em,deqAvgCost:Dm,deqNoDrawCost:Om,deqFastCost:km,deq:function(e,t,n){return e.dequeue(t,n)},onDeqd:function(e,t){for(var n=0;n<e.onDequeues.length;n++){var r=e.onDequeues[n];r(t)}},shouldRedraw:function(e,t,n,r){for(var i=0;i<t.length;i++)for(var a=t[i].eles,o=0;o<a.length;o++)if(ti(a[o].boundingBox(),r))return!0;return!1},priority:function(e){return e.renderer.beforeRenderPriorities.eleTxrDeq}});var Im=1,Lm=-4,Rm=2,zm=3.99,Bm=50,Vm=50,Hm=.15,Um=.1,Wm=.9,Gm=.9,Km=1,qm=250,Jm=16e6,Ym=32767,Xm=!0,Zm=function(e){var t=this,n=t.renderer=e,r=n.cy;t.layersByLevel={},t.firstGet=!0,t.lastInvalidationTime=dn()-2*qm,t.skipping=!1,t.eleTxrDeqs=r.collection(),t.scheduleElementRefinement=on(function(){t.refineElementTextures(t.eleTxrDeqs),t.eleTxrDeqs.unmerge(t.eleTxrDeqs)},Vm),n.beforeRender(function(e,n){t.skipping=n-t.lastInvalidationTime<=qm},n.beforeRenderPriorities.lyrTxrSkip),t.layersQueue=new dr(function(e,t){return t.reqs-e.reqs}),t.setupDequeueing()},Qm=Zm.prototype,$m=0,eh=2**53-1;Qm.makeLayer=function(e,t){var n=2**t,r=Math.ceil(e.w*n),i=Math.ceil(e.h*n),a=this.renderer.makeOffscreenCanvas(r,i),o={id:$m=++$m%eh,bb:e,level:t,width:r,height:i,canvas:a,context:a.getContext(`2d`),eles:[],elesQueue:[],reqs:0},s=o.context,c=-o.bb.x1,l=-o.bb.y1;return s.scale(n,n),s.translate(c,l),o},Qm.getLayers=function(e,t,n){var r=this,i=r.renderer.cy.zoom(),a=r.firstGet;if(r.firstGet=!1,n==null){if(n=Math.ceil(Rr(i*t)),n<Lm)n=Lm;else if(i>=zm||n>Rm)return null}r.validateLayersElesOrdering(n,e);var o=r.layersByLevel,s=2**n,c=o[n]=o[n]||[],l,u=r.levelIsComplete(n,e),d,f=function(){var t=function(t){if(r.validateLayersElesOrdering(t,e),r.levelIsComplete(t,e))return d=o[t],!0},i=function(e){if(!d)for(var r=n+e;Lm<=r&&r<=Rm&&!t(r);r+=e);};i(1),i(-1);for(var a=c.length-1;a>=0;a--){var s=c[a];s.invalid&&Kn(c,s)}};if(!u)f();else return c;var p=function(){if(!l){l=qr();for(var t=0;t<e.length;t++)Xr(l,e[t].boundingBox())}return l},m=function(e){e||={};var t=e.after;p();var i=Math.ceil(l.w*s),a=Math.ceil(l.h*s);if(i>Ym||a>Ym||i*a>Jm)return null;var o=r.makeLayer(l,n);if(t!=null){var u=c.indexOf(t)+1;c.splice(u,0,o)}else(e.insert===void 0||e.insert)&&c.unshift(o);return o};if(r.skipping&&!a)return null;for(var h=null,g=e.length/Im,_=!a,v=0;v<e.length;v++){var y=e[v],b=y._private.rscratch,x=b.imgLayerCaches=b.imgLayerCaches||{},S=x[n];if(S)h=S;else{if((!h||h.eles.length>=g||!ii(h.bb,y.boundingBox()))&&(h=m({insert:!0,after:h}),!h))return null;d||_?r.queueLayer(h,y):r.drawEleInLayer(h,y,n,t),h.eles.push(y),x[n]=h}}return d||(_?null:c)},Qm.getEleLevelForLayerLevel=function(e,t){return e},Qm.drawEleInLayer=function(e,t,n,r){var i=this,a=this.renderer,o=e.context,s=t.boundingBox();s.w!==0&&s.h!==0&&t.visible()&&(n=i.getEleLevelForLayerLevel(n,r),a.setImgSmoothing(o,!1),a.drawCachedElement(o,t,null,null,n,Xm),a.setImgSmoothing(o,!0))},Qm.levelIsComplete=function(e,t){var n=this.layersByLevel[e];if(!n||n.length===0)return!1;for(var r=0,i=0;i<n.length;i++){var a=n[i];if(a.reqs>0||a.invalid)return!1;r+=a.eles.length}return r===t.length},Qm.validateLayersElesOrdering=function(e,t){var n=this.layersByLevel[e];if(n)for(var r=0;r<n.length;r++){for(var i=n[r],a=-1,o=0;o<t.length;o++)if(i.eles[0]===t[o]){a=o;break}if(a<0)this.invalidateLayer(i);else for(var s=a,o=0;o<i.eles.length;o++)if(i.eles[o]!==t[s+o]){this.invalidateLayer(i);break}}},Qm.updateElementsInLayers=function(e,t){for(var n=this,r=Ie(e[0]),i=0;i<e.length;i++)for(var a=r?null:e[i],o=r?e[i]:e[i].ele,s=o._private.rscratch,c=s.imgLayerCaches=s.imgLayerCaches||{},l=Lm;l<=Rm;l++){var u=c[l];u&&(a&&n.getEleLevelForLayerLevel(u.level)!==a.level||t(u,o,a))}},Qm.haveLayers=function(){for(var e=this,t=!1,n=Lm;n<=Rm;n++){var r=e.layersByLevel[n];if(r&&r.length>0){t=!0;break}}return t},Qm.invalidateElements=function(e){var t=this;e.length!==0&&(t.lastInvalidationTime=dn(),e.length!==0&&t.haveLayers()&&t.updateElementsInLayers(e,function(e,n,r){t.invalidateLayer(e)}))},Qm.invalidateLayer=function(e){if(this.lastInvalidationTime=dn(),!e.invalid){var t=e.level,n=e.eles,r=this.layersByLevel[t];Kn(r,e),e.elesQueue=[],e.invalid=!0,e.replacement&&(e.replacement.invalid=!0);for(var i=0;i<n.length;i++){var a=n[i]._private.rscratch.imgLayerCaches;a&&(a[t]=null)}}},Qm.refineElementTextures=function(e){var t=this;t.updateElementsInLayers(e,function(e,n,r){var i=e.replacement;if(i||(i=e.replacement=t.makeLayer(e.bb,e.level),i.replaces=e,i.eles=e.eles),!i.reqs)for(var a=0;a<i.eles.length;a++)t.queueLayer(i,i.eles[a])})},Qm.enqueueElementRefinement=function(e){this.eleTxrDeqs.merge(e),this.scheduleElementRefinement()},Qm.queueLayer=function(e,t){var n=this.layersQueue,r=e.elesQueue,i=r.hasId=r.hasId||{};if(!e.replacement){if(t){if(i[t.id()])return;r.push(t),i[t.id()]=!0}e.reqs?(e.reqs++,n.updateItem(e)):(e.reqs=1,n.push(e))}},Qm.dequeue=function(e){for(var t=this,n=t.layersQueue,r=[],i=0;i<Km&&n.size()!==0;){var a=n.peek();if(a.replacement)n.pop();else if(a.replaces&&a!==a.replaces.replacement)n.pop();else if(a.invalid)n.pop();else{var o=a.elesQueue.shift();o&&(t.drawEleInLayer(a,o,a.level,e),i++),r.length===0&&r.push(!0),a.elesQueue.length===0&&(n.pop(),a.reqs=0,a.replaces&&t.applyLayerReplacement(a),t.requestRedraw())}}return r},Qm.applyLayerReplacement=function(e){var t=this,n=t.layersByLevel[e.level],r=e.replaces,i=n.indexOf(r);if(!(i<0||r.invalid)){n[i]=e;for(var a=0;a<e.eles.length;a++){var o=e.eles[a]._private,s=o.imgLayerCaches=o.imgLayerCaches||{};s&&(s[e.level]=e)}t.requestRedraw()}},Qm.requestRedraw=on(function(){var e=this.renderer;e.redrawHint(`eles`,!0),e.redrawHint(`drag`,!0),e.redraw()},100),Qm.setupDequeueing=fm.setupDequeueing({deqRedrawThreshold:Bm,deqCost:Hm,deqAvgCost:Um,deqNoDrawCost:Wm,deqFastCost:Gm,deq:function(e,t){return e.dequeue(t)},onDeqd:Fn,shouldRedraw:Mn,priority:function(e){return e.renderer.beforeRenderPriorities.lyrTxrDeq}});var th={},nh;function rh(e,t){for(var n=0;n<t.length;n++){var r=t[n];e.lineTo(r.x,r.y)}}function ih(e,t,n){for(var r,i=0;i<t.length;i++){var a=t[i];i===0&&(r=a),e.lineTo(a.x,a.y)}e.quadraticCurveTo(n.x,n.y,r.x,r.y)}function ah(e,t,n){e.beginPath&&e.beginPath();for(var r=t,i=0;i<r.length;i++){var a=r[i];e.lineTo(a.x,a.y)}var o=n,s=n[0];e.moveTo(s.x,s.y);for(var i=1;i<o.length;i++){var a=o[i];e.lineTo(a.x,a.y)}e.closePath&&e.closePath()}function oh(e,t,n,r,i){e.beginPath&&e.beginPath(),e.arc(n,r,i,0,Math.PI*2,!1);var a=t,o=a[0];e.moveTo(o.x,o.y);for(var s=0;s<a.length;s++){var c=a[s];e.lineTo(c.x,c.y)}e.closePath&&e.closePath()}function sh(e,t,n,r){e.arc(t,n,r,0,Math.PI*2,!1)}th.arrowShapeImpl=function(e){return(nh||={polygon:rh,"triangle-backcurve":ih,"triangle-tee":ah,"circle-triangle":oh,"triangle-cross":ah,circle:sh})[e]};var ch={};ch.drawElement=function(e,t,n,r,i,a){var o=this;t.isNode()?o.drawNode(e,t,n,r,i,a):o.drawEdge(e,t,n,r,i,a)},ch.drawElementOverlay=function(e,t){var n=this;t.isNode()?n.drawNodeOverlay(e,t):n.drawEdgeOverlay(e,t)},ch.drawElementUnderlay=function(e,t){var n=this;t.isNode()?n.drawNodeUnderlay(e,t):n.drawEdgeUnderlay(e,t)},ch.drawCachedElementPortion=function(e,t,n,r,i,a,o,s){var c=this,l=n.getBoundingBox(t);if(l.w!==0&&l.h!==0){var u=n.getElement(t,l,r,i,a);if(u!=null){var d=s(c,t);if(d===0)return;var f=o(c,t),p=l.x1,m=l.y1,h=l.w,g=l.h,_,v,y,b,x;if(f!==0){var S=n.getRotationPoint(t);y=S.x,b=S.y,e.translate(y,b),e.rotate(f),x=c.getImgSmoothing(e),x||c.setImgSmoothing(e,!0);var C=n.getRotationOffset(t);_=C.x,v=C.y}else _=p,v=m;var w;d!==1&&(w=e.globalAlpha,e.globalAlpha=w*d),e.drawImage(u.texture.canvas,u.x,0,u.width,u.height,_,v,h,g),d!==1&&(e.globalAlpha=w),f!==0&&(e.rotate(-f),e.translate(-y,-b),x||c.setImgSmoothing(e,!1))}else n.drawElement(e,t)}};var lh=function(){return 0},uh=function(e,t){return e.getTextAngle(t,null)},dh=function(e,t){return e.getTextAngle(t,`source`)},fh=function(e,t){return e.getTextAngle(t,`target`)},ph=function(e,t){return t.effectiveOpacity()},mh=function(e,t){return t.pstyle(`text-opacity`).pfValue*t.effectiveOpacity()};ch.drawCachedElement=function(e,t,n,r,i,a){var o=this,s=o.data,c=s.eleTxrCache,l=s.lblTxrCache,u=s.slbTxrCache,d=s.tlbTxrCache,f=t.boundingBox(),p=a===!0?c.reasons.highQuality:null;if(f.w!==0&&f.h!==0&&t.visible()&&(!r||ti(f,r))){var m=t.isEdge(),h=t.element()._private.rscratch.badLine;o.drawElementUnderlay(e,t),o.drawCachedElementPortion(e,t,c,n,i,p,lh,ph),m&&h||o.drawCachedElementPortion(e,t,l,n,i,p,uh,mh),m&&!h&&(o.drawCachedElementPortion(e,t,u,n,i,p,dh,mh),o.drawCachedElementPortion(e,t,d,n,i,p,fh,mh)),o.drawElementOverlay(e,t)}},ch.drawElements=function(e,t){for(var n=this,r=0;r<t.length;r++){var i=t[r];n.drawElement(e,i)}},ch.drawCachedElements=function(e,t,n,r){for(var i=this,a=0;a<t.length;a++){var o=t[a];i.drawCachedElement(e,o,n,r)}},ch.drawCachedNodes=function(e,t,n,r){for(var i=this,a=0;a<t.length;a++){var o=t[a];o.isNode()&&i.drawCachedElement(e,o,n,r)}},ch.drawLayeredElements=function(e,t,n,r){var i=this,a=i.data.lyrTxrCache.getLayers(t,n);if(a)for(var o=0;o<a.length;o++){var s=a[o],c=s.bb;c.w!==0&&c.h!==0&&e.drawImage(s.canvas,c.x1,c.y1,c.w,c.h)}else i.drawCachedElements(e,t,n,r)};var hh={};hh.drawEdge=function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0,o=this,s=t._private.rscratch;if((!a||t.visible())&&!(s.badLine||s.allpts==null||isNaN(s.allpts[0]))){var c;n&&(c=n,e.translate(-c.x1,-c.y1));var l=a?t.pstyle(`opacity`).value:1,u=a?t.pstyle(`line-opacity`).value:1,d=t.pstyle(`curve-style`).value,f=t.pstyle(`line-style`).value,p=t.pstyle(`width`).pfValue,m=t.pstyle(`line-cap`).value,h=t.pstyle(`line-outline-width`).value,g=t.pstyle(`line-outline-color`).value,_=l*u,v=l*u,y=function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:_;d===`straight-triangle`?(o.eleStrokeStyle(e,t,n),o.drawEdgeTrianglePath(t,e,s.allpts)):(e.lineWidth=p,e.lineCap=m,o.eleStrokeStyle(e,t,n),o.drawEdgePath(t,e,s.allpts,f),e.lineCap=`butt`)},b=function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:_;if(e.lineWidth=p+h,e.lineCap=m,h>0)o.colorStrokeStyle(e,g,n);else{e.lineCap=`butt`;return}d===`straight-triangle`?o.drawEdgeTrianglePath(t,e,s.allpts):(o.drawEdgePath(t,e,s.allpts,f),e.lineCap=`butt`)},x=function(){i&&o.drawEdgeOverlay(e,t)},S=function(){i&&o.drawEdgeUnderlay(e,t)},C=function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:v;o.drawArrowheads(e,t,n)},w=function(){o.drawElementText(e,t,null,r)};if(e.lineJoin=`round`,t.pstyle(`ghost`).value===`yes`){var T=t.pstyle(`ghost-offset-x`).pfValue,E=t.pstyle(`ghost-offset-y`).pfValue,D=_*t.pstyle(`ghost-opacity`).value;e.translate(T,E),y(D),C(D),e.translate(-T,-E)}else b();S(),y(),C(),x(),w(),n&&e.translate(c.x1,c.y1)}};var gh=function(e){if(![`overlay`,`underlay`].includes(e))throw Error(`Invalid state`);return function(t,n){if(n.visible()){var r=n.pstyle(`${e}-opacity`).value;if(r!==0){var i=this,a=i.usePaths(),o=n._private.rscratch;t.lineWidth=2*n.pstyle(`${e}-padding`).pfValue,t.lineCap=o.edgeType===`self`&&!a?`butt`:`round`;var s=n.pstyle(`${e}-fill`)?.value;if(s===`linear-gradient`||s===`radial-gradient`){var c=i.createGradientStyleFor(t,e,n,s,r);if(c)t.strokeStyle=c;else{var l=n.pstyle(`${e}-color`).value;i.colorStrokeStyle(t,l,r)}}else{var u=n.pstyle(`${e}-color`).value;i.colorStrokeStyle(t,u,r)}i.drawEdgePath(n,t,o.allpts,`solid`)}}}};hh.drawEdgeOverlay=gh(`overlay`),hh.drawEdgeUnderlay=gh(`underlay`),hh.drawEdgePath=function(e,t,n,r){var i=e._private.rscratch,a=t,o,s=!1,c=this.usePaths(),l=e.pstyle(`line-dash-pattern`).pfValue,u=e.pstyle(`line-dash-offset`).pfValue;if(c){var d=n.join(`$`);i.pathCacheKey&&i.pathCacheKey===d?(o=t=i.pathCache,s=!0):(o=t=new Path2D,i.pathCacheKey=d,i.pathCache=o)}if(a.setLineDash)switch(r){case`dotted`:a.setLineDash([1,1]);break;case`dashed`:a.setLineDash(l),a.lineDashOffset=u;break;case`solid`:a.setLineDash([])}if(!s&&!i.badLine)switch(t.beginPath&&t.beginPath(),t.moveTo(n[0],n[1]),i.edgeType){case`bezier`:case`self`:case`compound`:case`multibezier`:for(var f=2;f+3<n.length;f+=4)t.quadraticCurveTo(n[f],n[f+1],n[f+2],n[f+3]);break;case`straight`:case`haystack`:for(var p=2;p+1<n.length;p+=2)t.lineTo(n[p],n[p+1]);break;case`segments`:if(i.isRound){var m=ue(i.roundCorners),h;try{for(m.s();!(h=m.n()).done;){var g=h.value;Ip(t,g)}}catch(e){m.e(e)}finally{m.f()}t.lineTo(n[n.length-2],n[n.length-1])}else for(var _=2;_+1<n.length;_+=2)t.lineTo(n[_],n[_+1])}t=a,c?t.stroke(o):t.stroke(),t.setLineDash&&t.setLineDash([])},hh.drawEdgeTrianglePath=function(e,t,n){t.fillStyle=t.strokeStyle;for(var r=e.pstyle(`width`).pfValue,i=0;i+1<n.length;i+=2){var a=[n[i+2]-n[i],n[i+3]-n[i+1]],o=Math.sqrt(a[0]*a[0]+a[1]*a[1]),s=[a[1]/o,-a[0]/o],c=[s[0]*r/2,s[1]*r/2];t.beginPath(),t.moveTo(n[i]-c[0],n[i+1]-c[1]),t.lineTo(n[i]+c[0],n[i+1]+c[1]),t.lineTo(n[i+2],n[i+3]),t.closePath(),t.fill()}},hh.drawArrowheads=function(e,t,n){var r=t._private.rscratch,i=r.edgeType===`haystack`;i||this.drawArrowhead(e,t,`source`,r.arrowStartX,r.arrowStartY,r.srcArrowAngle,n),this.drawArrowhead(e,t,`mid-target`,r.midX,r.midY,r.midtgtArrowAngle,n),this.drawArrowhead(e,t,`mid-source`,r.midX,r.midY,r.midsrcArrowAngle,n),i||this.drawArrowhead(e,t,`target`,r.arrowEndX,r.arrowEndY,r.tgtArrowAngle,n)},hh.drawArrowhead=function(e,t,n,r,i,a,o){if(!(isNaN(r)||r==null||isNaN(i)||i==null||isNaN(a)||a==null)){var s=this,c=t.pstyle(n+`-arrow-shape`).value;if(c!==`none`){var l=t.pstyle(n+`-arrow-fill`).value===`hollow`?`both`:`filled`,u=t.pstyle(n+`-arrow-fill`).value,d=t.pstyle(`width`).pfValue,f=t.pstyle(n+`-arrow-width`),p=f.value===`match-line`?d:f.pfValue;f.units===`%`&&(p*=d);var m=t.pstyle(`opacity`).value;o===void 0&&(o=m);var h=e.globalCompositeOperation;(o!==1||u===`hollow`)&&(e.globalCompositeOperation=`destination-out`,s.colorFillStyle(e,[255,255,255],1),s.colorStrokeStyle(e,[255,255,255],1),s.drawArrowShape(t,e,l,d,c,p,r,i,a,n),e.globalCompositeOperation=h);var g=t.pstyle(n+`-arrow-color`).value;s.colorFillStyle(e,g,o),s.colorStrokeStyle(e,g,o),s.drawArrowShape(t,e,u,d,c,p,r,i,a,n)}}},hh.drawArrowShape=function(e,t,n,r,i,a,o,s,c,l){var u=this,d=this.usePaths()&&i!==`triangle-cross`,f=!1,p,m=t,h={x:o,y:s},g=u.arrowShapes[i],_=uf(e,l),v=this.getArrowWidth(r,_);if(d){var y=u.arrowPathCache=u.arrowPathCache||[],b=Sn(i),x=y[b];x==null?(p=t=new Path2D,y[b]=p):(p=t=x,f=!0)}f||(t.beginPath&&t.beginPath(),d?g.draw(t,1,0,{x:0,y:0},1):g.draw(t,v,c,h,r),t.closePath&&t.closePath()),t=m,d&&(t.translate(o,s),t.rotate(c),t.scale(v,v)),(n===`filled`||n===`both`)&&(d?t.fill(p):t.fill()),(n===`hollow`||n===`both`)&&(t.lineWidth=a/(d?v:1),t.lineJoin=`miter`,d?t.stroke(p):t.stroke()),d&&(t.scale(1/v,1/v),t.rotate(-c),t.translate(-o,-s))};var _h={};_h.safeDrawImage=function(e,t,n,r,i,a,o,s,c,l){if(!(i<=0||a<=0||c<=0||l<=0))try{e.drawImage(t,n,r,i,a,o,s,c,l)}catch(e){Rn(e)}},_h.drawInscribedImage=function(e,t,n,r,i){var a=this,o=n.position(),s=o.x,c=o.y,l=n.cy().style(),u=l.getIndexedStyle.bind(l),d=u(n,`background-fit`,`value`,r),f=u(n,`background-repeat`,`value`,r),p=n.width(),m=n.height(),h=n.padding()*2,g=p+(u(n,`background-width-relative-to`,`value`,r)===`inner`?0:h),_=m+(u(n,`background-height-relative-to`,`value`,r)===`inner`?0:h),v=n._private.rscratch,y=u(n,`background-clip`,`value`,r)===`node`,b=u(n,`background-image-opacity`,`value`,r)*i,x=u(n,`background-image-smoothing`,`value`,r),S=n.pstyle(`corner-radius`).value;S!==`auto`&&(S=n.pstyle(`corner-radius`).pfValue);var C=t.width||t.cachedW,w=t.height||t.cachedH;(C==null||w==null)&&(document.body.appendChild(t),C=t.cachedW=t.width||t.offsetWidth,w=t.cachedH=t.height||t.offsetHeight,document.body.removeChild(t));var T=C,E=w;if(u(n,`background-width`,`value`,r)!==`auto`&&(T=u(n,`background-width`,`units`,r)===`%`?u(n,`background-width`,`pfValue`,r)*g:u(n,`background-width`,`pfValue`,r)),u(n,`background-height`,`value`,r)!==`auto`&&(E=u(n,`background-height`,`units`,r)===`%`?u(n,`background-height`,`pfValue`,r)*_:u(n,`background-height`,`pfValue`,r)),T!==0&&E!==0){if(d===`contain`){var D=Math.min(g/T,_/E);T*=D,E*=D}else if(d===`cover`){var D=Math.max(g/T,_/E);T*=D,E*=D}var O=s-g/2,k=u(n,`background-position-x`,`units`,r),A=u(n,`background-position-x`,`pfValue`,r);O+=k===`%`?(g-T)*A:A;var j=u(n,`background-offset-x`,`units`,r),M=u(n,`background-offset-x`,`pfValue`,r);O+=j===`%`?(g-T)*M:M;var N=c-_/2,P=u(n,`background-position-y`,`units`,r),F=u(n,`background-position-y`,`pfValue`,r);N+=P===`%`?(_-E)*F:F;var I=u(n,`background-offset-y`,`units`,r),L=u(n,`background-offset-y`,`pfValue`,r);N+=I===`%`?(_-E)*L:L,v.pathCache&&(O-=s,N-=c,s=0,c=0);var R=e.globalAlpha;e.globalAlpha=b;var z=a.getImgSmoothing(e),B=!1;x===`no`&&z?(a.setImgSmoothing(e,!1),B=!0):x===`yes`&&!z&&(a.setImgSmoothing(e,!0),B=!0),f===`no-repeat`?(y&&(e.save(),v.pathCache?e.clip(v.pathCache):(a.nodeShapes[a.getNodeShape(n)].draw(e,s,c,g,_,S,v),e.clip())),a.safeDrawImage(e,t,0,0,C,w,O,N,T,E),y&&e.restore()):(e.fillStyle=e.createPattern(t,f),a.nodeShapes[a.getNodeShape(n)].draw(e,s,c,g,_,S,v),e.translate(O,N),e.fill(),e.translate(-O,-N)),e.globalAlpha=R,B&&a.setImgSmoothing(e,z)}};var vh={};vh.eleTextBiggerThanMin=function(e,t){if(!t){var n=e.cy().zoom(),r=this.getPixelRatio();t=2**Math.ceil(Rr(n*r))}return!(e.pstyle(`font-size`).pfValue*t<e.pstyle(`min-zoomed-font-size`).pfValue)},vh.drawElementText=function(e,t,n,r,i){var a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0,o=this;if(r==null){if(a&&!o.eleTextBiggerThanMin(t))return}else if(r===!1)return;if(t.isNode()){var s=t.pstyle(`label`);if(!s||!s.value)return;var c=o.getLabelJustification(t),l=t.pstyle(`text-metrics`).strValue===`glyph`;e.textAlign=c,e.textBaseline=l?`alphabetic`:`bottom`}else{var u=t.element()._private.rscratch.badLine,d=t.pstyle(`label`),f=t.pstyle(`source-label`),p=t.pstyle(`target-label`);if(u||(!d||!d.value)&&(!f||!f.value)&&(!p||!p.value))return;e.textAlign=`center`,e.textBaseline=`bottom`}var m=!n,h;n&&(h=n,e.translate(-h.x1,-h.y1)),i==null?(o.drawText(e,t,null,m,a),t.isEdge()&&(o.drawText(e,t,`source`,m,a),o.drawText(e,t,`target`,m,a))):o.drawText(e,t,i,m,a),n&&e.translate(h.x1,h.y1)},vh.getFontCache=function(e){var t;this.fontCaches=this.fontCaches||[];for(var n=0;n<this.fontCaches.length;n++)if(t=this.fontCaches[n],t.context===e)return t;return t={context:e},this.fontCaches.push(t),t},vh.setupTextStyle=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=t.pstyle(`font-style`).strValue,i=t.pstyle(`font-size`).pfValue+`px`,a=t.pstyle(`font-family`).strValue,o=t.pstyle(`font-weight`).strValue,s=n?t.effectiveOpacity()*t.pstyle(`text-opacity`).value:1,c=t.pstyle(`text-outline-opacity`).value*s,l=t.pstyle(`color`).value,u=t.pstyle(`text-outline-color`).value;e.font=r+` `+o+` `+i+` `+a,e.lineJoin=`round`,this.colorFillStyle(e,l,s),this.colorStrokeStyle(e,u,c)};function yh(e,t,n,r,i){var a=Math.min(r,i)/2,o=t+r/2,s=n+i/2;e.beginPath(),e.arc(o,s,a,0,Math.PI*2),e.closePath()}function bh(e,t,n,r,i){var a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:5,o=Math.min(a,r/2,i/2);e.beginPath(),e.moveTo(t+o,n),e.lineTo(t+r-o,n),e.quadraticCurveTo(t+r,n,t+r,n+o),e.lineTo(t+r,n+i-o),e.quadraticCurveTo(t+r,n+i,t+r-o,n+i),e.lineTo(t+o,n+i),e.quadraticCurveTo(t,n+i,t,n+i-o),e.lineTo(t,n+o),e.quadraticCurveTo(t,n,t+o,n),e.closePath()}vh.getTextAngle=function(e,t){var n,r=e._private.rscratch,i=t?t+`-`:``,a=e.pstyle(i+`text-rotation`);if(a.strValue===`autorotate`){var o=Yn(r,`labelAngle`,t);n=e.isEdge()?o:0}else n=a.strValue===`none`?0:a.pfValue;return n},vh.drawText=function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=t._private.rscratch,o=i?t.effectiveOpacity():1;if(!i||o!==0&&t.pstyle(`text-opacity`).value!==0){n===`main`&&(n=null);var s=Yn(a,`labelX`,n),c=Yn(a,`labelY`,n),l,u,d=this.getLabelText(t,n);if(d!=null&&d!==``&&!isNaN(s)&&!isNaN(c)){this.setupTextStyle(e,t,i);var f=n?n+`-`:``,p=Yn(a,`labelWidth`,n),m=Yn(a,`labelHeight`,n),h=Yn(a,`labelActualDescent`,n),g=t.pstyle(f+`text-margin-x`).pfValue,_=t.pstyle(f+`text-margin-y`).pfValue,v=t.isEdge(),y=t.pstyle(`text-halign`).value,b=t.pstyle(`text-valign`).value;v&&(y=`center`,b=`center`),s+=g,c+=_;var x=r?this.getTextAngle(t,n):0;x!==0&&(l=s,u=c,e.translate(l,u),e.rotate(x),s=0,c=0);var S=su(y),C=cu(b);switch(C){case`top`:break;case`center`:c+=m/2;break;case`bottom`:c+=m}var w=t.pstyle(`text-background-opacity`).value,T=t.pstyle(`text-border-opacity`).value,E=t.pstyle(`text-border-width`).pfValue,D=t.pstyle(`text-background-padding`).pfValue,O=t.pstyle(`text-background-shape`).strValue,k=O===`round-rectangle`||O===`roundrectangle`,A=O===`circle`,j=2;if(w>0||E>0&&T>0){var M=e.fillStyle,N=e.strokeStyle,P=e.lineWidth,F=t.pstyle(`text-background-color`).value,I=t.pstyle(`text-border-color`).value,L=t.pstyle(`text-border-style`).value,R=w>0,z=E>0&&T>0,B=s-D;switch(S){case`left`:B-=p;break;case`center`:B-=p/2}var V=c-m-D,H=p+2*D,U=m+2*D;if(R&&this.colorFillStyle(e,F,w*o),z&&(this.colorStrokeStyle(e,I,T*o),e.lineWidth=E,e.setLineDash))switch(L){case`dotted`:e.setLineDash([1,1]);break;case`dashed`:e.setLineDash([4,2]);break;case`double`:e.lineWidth=E/4,e.setLineDash([]);break;default:e.setLineDash([])}if(k?(e.beginPath(),bh(e,B,V,H,U,j)):A?(e.beginPath(),yh(e,B,V,H,U)):(e.beginPath(),e.rect(B,V,H,U)),R&&e.fill(),z&&e.stroke(),z&&L===`double`){var W=E/2;e.beginPath(),k?bh(e,B+W,V+W,H-2*W,U-2*W,j):e.rect(B+W,V+W,H-2*W,U-2*W),e.stroke()}e.fillStyle=M,e.strokeStyle=N,e.lineWidth=P,e.setLineDash&&e.setLineDash([])}var ee=2*t.pstyle(`text-outline-width`).pfValue;if(ee>0&&(e.lineWidth=ee),c-=h,t.pstyle(`text-wrap`).value===`wrap`){var G=Yn(a,`labelWrapCachedLines`,n),K=Yn(a,`labelLineHeight`,n),q=p/2,J=this.getLabelJustification(t);switch(J===`auto`||(S===`left`?J===`left`?s+=-p:J===`center`&&(s+=-q):S===`center`?J===`left`?s+=-q:J===`right`&&(s+=q):S===`right`&&(J===`center`?s+=q:J===`right`&&(s+=p))),C){case`top`:c-=(G.length-1)*K;break;case`center`:case`bottom`:c-=(G.length-1)*K}for(var te=0;te<G.length;te++)ee>0&&e.strokeText(G[te],s,c),e.fillText(G[te],s,c),c+=K}else ee>0&&e.strokeText(d,s,c),e.fillText(d,s,c);x!==0&&(e.rotate(-x),e.translate(-l,-u))}}};var xh={};xh.drawNode=function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!0,o=this,s,c,l=t._private,u=l.rscratch,d=t.position();if(X(d.x)&&X(d.y)&&(!a||t.visible())){var f=a?t.effectiveOpacity():1,p=o.usePaths(),m,h=!1,g=t.padding();s=t.width()+2*g,c=t.height()+2*g;var _;n&&(_=n,e.translate(-_.x1,-_.y1));for(var v=t.pstyle(`background-image`).value,y=Array(v.length),b=Array(v.length),x=0,S=0;S<v.length;S++){var C=v[S];if(y[S]=C!=null&&C!==`none`){var w=t.cy().style().getIndexedStyle(t,`background-image-crossorigin`,`value`,S);x++,b[S]=o.getCachedImage(C,w,function(){l.backgroundTimestamp=Date.now(),t.emitAndNotify(`background`)})}}var T=t.pstyle(`background-blacken`).value,E=t.pstyle(`border-width`).pfValue,D=t.pstyle(`background-opacity`).value*f,O=t.pstyle(`border-color`).value,k=t.pstyle(`border-style`).value,A=t.pstyle(`border-join`).value,j=t.pstyle(`border-cap`).value,M=t.pstyle(`border-position`).value,N=t.pstyle(`border-dash-pattern`).pfValue,P=t.pstyle(`border-dash-offset`).pfValue,F=t.pstyle(`border-opacity`).value*f,I=t.pstyle(`outline-width`).pfValue,L=t.pstyle(`outline-color`).value,R=t.pstyle(`outline-style`).value,z=t.pstyle(`outline-opacity`).value*f,B=t.pstyle(`outline-offset`).value,V=t.pstyle(`corner-radius`).value;V!==`auto`&&(V=t.pstyle(`corner-radius`).pfValue);var H=function(){var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:D;o.eleFillStyle(e,t,n)},U=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:F;o.colorStrokeStyle(e,O,t)},W=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:z;o.colorStrokeStyle(e,L,t)},ee=function(e,t,n,r){var i=o.nodePathCache=o.nodePathCache||[],a=Cn(n===`polygon`?n+`,`+r.join(`,`):n,``+t,``+e,``+V),s=i[a],c,l=!1;return s==null?(c=new Path2D,i[a]=u.pathCache=c):(c=s,l=!0,u.pathCache=c),{path:c,cacheHit:l}},G=t.pstyle(`shape`).strValue,K=t.pstyle(`shape-polygon-points`).pfValue;if(p){e.translate(d.x,d.y);var q=ee(s,c,G,K);m=q.path,h=q.cacheHit}var J=function(){if(!h){var n=d;p&&(n={x:0,y:0}),o.nodeShapes[o.getNodeShape(t)].draw(m||e,n.x,n.y,s,c,V,u)}p?e.fill(m):e.fill()},te=function(){for(var n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:f,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,i=l.backgrounding,a=0,s=0;s<b.length;s++)if(y[s]){var c=t.cy().style().getIndexedStyle(t,`background-image-containment`,`value`,s);r&&c===`over`||!r&&c===`inside`?a++:y[s]&&b[s].complete&&!b[s].error&&(a++,o.drawInscribedImage(e,b[s],t,s,n))}l.backgrounding=a!==x,i!==l.backgrounding&&t.updateStyle(!1)},ne=function(){var n=arguments.length>0&&arguments[0]!==void 0&&arguments[0],r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f;o.hasPie(t)&&(o.drawPie(e,t,r),n&&(p||o.nodeShapes[o.getNodeShape(t)].draw(e,d.x,d.y,s,c,V,u)))},re=function(){var n=arguments.length>0&&arguments[0]!==void 0&&arguments[0],r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f;o.hasStripe(t)&&(e.save(),p?e.clip(u.pathCache):(o.nodeShapes[o.getNodeShape(t)].draw(e,d.x,d.y,s,c,V,u),e.clip()),o.drawStripe(e,t,r),e.restore(),n&&(p||o.nodeShapes[o.getNodeShape(t)].draw(e,d.x,d.y,s,c,V,u)))},ie=function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:f,n=(T>0?T:-T)*t,r=T>0?0:255;T!==0&&(o.colorFillStyle(e,[r,r,r],n),p?e.fill(m):e.fill())},ae=function(){if(E>0){if(e.lineWidth=E,e.lineCap=j,e.lineJoin=A,e.setLineDash)switch(k){case`dotted`:e.setLineDash([1,1]);break;case`dashed`:e.setLineDash(N),e.lineDashOffset=P;break;case`solid`:case`double`:e.setLineDash([])}if(M!==`center`){if(e.save(),e.lineWidth*=2,M===`inside`)p?e.clip(m):e.clip();else{var t=new Path2D;t.rect(-s/2-E,-c/2-E,s+2*E,c+2*E),t.addPath(m),e.clip(t,`evenodd`)}p?e.stroke(m):e.stroke(),e.restore()}else p?e.stroke(m):e.stroke();if(k===`double`){e.lineWidth=E/3;var n=e.globalCompositeOperation;e.globalCompositeOperation=`destination-out`,p?e.stroke(m):e.stroke(),e.globalCompositeOperation=n}e.setLineDash&&e.setLineDash([])}},oe=function(){if(I>0){if(e.lineWidth=I,e.lineCap=`butt`,e.setLineDash)switch(R){case`dotted`:e.setLineDash([1,1]);break;case`dashed`:e.setLineDash([4,2]);break;case`solid`:case`double`:e.setLineDash([])}var n=d;p&&(n={x:0,y:0});var r=o.getNodeShape(t),i=E;M===`inside`&&(i=0),M===`outside`&&(i*=2);var a=(s+i+(I+B))/s,l=(c+i+(I+B))/c,u=s*a,f=c*l,m=o.nodeShapes[r].points,h;if(p&&(h=ee(u,f,r,m).path),r===`ellipse`)o.drawEllipsePath(h||e,n.x,n.y,u,f);else if([`round-diamond`,`round-heptagon`,`round-hexagon`,`round-octagon`,`round-pentagon`,`round-polygon`,`round-triangle`,`round-tag`].includes(r)){var g=0,_=0,v=0;r===`round-diamond`?g=(i+B+I)*1.4:r===`round-heptagon`?(g=(i+B+I)*1.075,v=-(i/2+B+I)/35):r===`round-hexagon`?g=(i+B+I)*1.12:r===`round-pentagon`?(g=(i+B+I)*1.13,v=-(i/2+B+I)/15):r===`round-tag`?(g=(i+B+I)*1.12,_=(i/2+I+B)*.07):r===`round-triangle`&&(g=(i+B+I)*(Math.PI/2),v=-(i+B/2+I)/Math.PI),g!==0&&(a=(s+g)/s,u=s*a,[`round-hexagon`,`round-tag`].includes(r)||(l=(c+g)/c,f=c*l)),V=V===`auto`?Ni(u,f):V;for(var y=u/2,b=f/2,x=V+(i+I+B)/2,S=Array(m.length/2),C=Array(m.length/2),w=0;w<m.length/2;w++)S[w]={x:n.x+_+y*m[w*2],y:n.y+v+b*m[w*2+1]};var T,D,O,k,A=S.length;for(D=S[A-1],T=0;T<A;T++)O=S[T%A],k=S[(T+1)%A],C[T]=Lp(D,O,k,x),D=O,O=k;o.drawRoundPolygonPath(h||e,n.x+_,n.y+v,s*a,c*l,m,C)}else if([`roundrectangle`,`round-rectangle`].includes(r))V=V===`auto`?Mi(u,f):V,o.drawRoundRectanglePath(h||e,n.x,n.y,u,f,V+(i+I+B)/2);else if([`cutrectangle`,`cut-rectangle`].includes(r))V=V===`auto`?Pi():V,o.drawCutRectanglePath(h||e,n.x,n.y,u,f,null,V+(i+I+B)/4);else if([`bottomroundrectangle`,`bottom-round-rectangle`].includes(r))V=V===`auto`?Mi(u,f):V,o.drawBottomRoundRectanglePath(h||e,n.x,n.y,u,f,V+(i+I+B)/2);else if(r===`barrel`)o.drawBarrelPath(h||e,n.x,n.y,u,f);else if(r.startsWith(`polygon`)||[`rhomboid`,`right-rhomboid`,`round-tag`,`tag`,`vee`].includes(r)){var j=(i+I+B)/s;m=vi(yi(m,j)),o.drawPolygonPath(h||e,n.x,n.y,s,c,m)}else{var N=(i+I+B)/s;m=vi(yi(m,-N)),o.drawPolygonPath(h||e,n.x,n.y,s,c,m)}if(p?e.stroke(h):e.stroke(),R===`double`){e.lineWidth=i/3;var P=e.globalCompositeOperation;e.globalCompositeOperation=`destination-out`,p?e.stroke(h):e.stroke(),e.globalCompositeOperation=P}e.setLineDash&&e.setLineDash([])}},se=function(){i&&o.drawNodeOverlay(e,t,d,s,c)},ce=function(){i&&o.drawNodeUnderlay(e,t,d,s,c)},le=function(){o.drawElementText(e,t,null,r)};if(t.pstyle(`ghost`).value===`yes`){var ue=t.pstyle(`ghost-offset-x`).pfValue,de=t.pstyle(`ghost-offset-y`).pfValue,fe=t.pstyle(`ghost-opacity`).value,pe=fe*f;e.translate(ue,de),W(),oe(),H(fe*D),J(),te(pe,!0),U(fe*F),ae(),ne(T!==0||E!==0),re(T!==0||E!==0),te(pe,!1),ie(pe),e.translate(-ue,-de)}p&&e.translate(-d.x,-d.y),ce(),p&&e.translate(d.x,d.y),W(),oe(),H(),J(),te(f,!0),U(),ae(),ne(T!==0||E!==0),re(T!==0||E!==0),te(f,!1),ie(),p&&e.translate(-d.x,-d.y),le(),se(),n&&e.translate(_.x1,_.y1)}};var Sh=function(e){if(![`overlay`,`underlay`].includes(e))throw Error(`Invalid state`);return function(t,n,r,i,a){var o=this;if(n.visible()){var s=n.pstyle(`${e}-padding`).pfValue,c=n.pstyle(`${e}-opacity`).value,l=n.pstyle(`${e}-shape`).value,u=n.pstyle(`${e}-corner-radius`).value;if(c>0){if(r||=n.position(),i==null||a==null){var d=n.padding();i=n.width()+2*d,a=n.height()+2*d}var f=n.pstyle(`${e}-fill`)?.value;if(f===`linear-gradient`||f===`radial-gradient`){var p=o.createGradientStyleFor(t,e,n,f,c);if(p)t.fillStyle=p;else{var m=n.pstyle(`${e}-color`).value;o.colorFillStyle(t,m,c)}}else{var h=n.pstyle(`${e}-color`).value;o.colorFillStyle(t,h,c)}o.nodeShapes[l].draw(t,r.x,r.y,i+s*2,a+s*2,u),t.fill()}}}};xh.drawNodeOverlay=Sh(`overlay`),xh.drawNodeUnderlay=Sh(`underlay`),xh.hasPie=function(e){return e=e[0],e._private.hasPie},xh.hasStripe=function(e){return e=e[0],e._private.hasStripe},xh.drawPie=function(e,t,n,r){t=t[0],r||=t.position();var i=t.cy().style(),a=t.pstyle(`pie-size`),o=t.pstyle(`pie-hole`),s=t.pstyle(`pie-start-angle`).pfValue,c=r.x,l=r.y,u=t.width(),d=t.height(),f=Math.min(u,d)/2,p,m=0;if(this.usePaths()&&(c=0,l=0),a.units===`%`?f*=a.pfValue:a.pfValue!==void 0&&(f=a.pfValue/2),o.units===`%`?p=f*o.pfValue:o.pfValue!==void 0&&(p=o.pfValue/2),!(p>=f))for(var h=1;h<=i.pieBackgroundN;h++){var g=t.pstyle(`pie-`+h+`-background-size`).value,_=t.pstyle(`pie-`+h+`-background-color`).value,v=t.pstyle(`pie-`+h+`-background-opacity`).value*n,y=g/100;y+m>1&&(y=1-m);var b=1.5*Math.PI+2*Math.PI*m;b+=s;var x=2*Math.PI*y,S=b+x;g===0||m>=1||m+y>1||(p===0?(e.beginPath(),e.moveTo(c,l),e.arc(c,l,f,b,S),e.closePath()):(e.beginPath(),e.arc(c,l,f,b,S),e.arc(c,l,p,S,b,!0),e.closePath()),this.colorFillStyle(e,_,v),e.fill(),m+=y)}},xh.drawStripe=function(e,t,n,r){t=t[0],r||=t.position();var i=t.cy().style(),a=r.x,o=r.y,s=t.width(),c=t.height(),l=0,u=this.usePaths();e.save();var d=t.pstyle(`stripe-direction`).value,f=t.pstyle(`stripe-size`);switch(d){case`vertical`:break;case`righward`:e.rotate(-Math.PI/2)}var p=s,m=c;f.units===`%`?(p*=f.pfValue,m*=f.pfValue):f.pfValue!==void 0&&(p=f.pfValue,m=f.pfValue),u&&(a=0,o=0),o-=p/2,a-=m/2;for(var h=1;h<=i.stripeBackgroundN;h++){var g=t.pstyle(`stripe-`+h+`-background-size`).value,_=t.pstyle(`stripe-`+h+`-background-color`).value,v=t.pstyle(`stripe-`+h+`-background-opacity`).value*n,y=g/100;y+l>1&&(y=1-l),g===0||l>=1||l+y>1||(e.beginPath(),e.rect(a,o+m*l,p,m*y),e.closePath(),this.colorFillStyle(e,_,v),e.fill(),l+=y)}e.restore()};var Ch={},wh=100,Th=function(e){return e[3]==null?1:e[3]},Eh=function(e,t){return Th(e)*t};Ch.getPixelRatio=function(){var e=this.data.contexts[0];if(this.forcedPixelRatio!=null)return this.forcedPixelRatio;var t=this.cy.window(),n=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return(t.devicePixelRatio||1)/n},Ch.paintCache=function(e){for(var t=this.paintCaches=this.paintCaches||[],n=!0,r,i=0;i<t.length;i++)if(r=t[i],r.context===e){n=!1;break}return n&&(r={context:e},t.push(r)),r},Ch.createGradientStyleFor=function(e,t,n,r,i){var a,o=this.usePaths(),s=n.pstyle(t+`-gradient-stop-colors`).value,c=n.pstyle(t+`-gradient-stop-positions`).pfValue;if(r===`radial-gradient`){if(n.isEdge()){var l=n.sourceEndpoint(),u=n.targetEndpoint(),d=n.midpoint(),f=Br(l,d),p=Br(u,d);a=e.createRadialGradient(d.x,d.y,0,d.x,d.y,Math.max(f,p))}else{var m=o&&t===`background`?{x:0,y:0}:n.position(),h=n.paddedWidth(),g=n.paddedHeight();a=e.createRadialGradient(m.x,m.y,0,m.x,m.y,Math.max(h,g))}}else if(n.isEdge()){var _=n.sourceEndpoint(),v=n.targetEndpoint();a=e.createLinearGradient(_.x,_.y,v.x,v.y)}else{var y=o&&t===`background`?{x:0,y:0}:n.position(),b=n.paddedWidth(),x=n.paddedHeight(),S=b/2,C=x/2;switch(n.pstyle(t+`-gradient-direction`).value){case`to-bottom`:a=e.createLinearGradient(y.x,y.y-C,y.x,y.y+C);break;case`to-top`:a=e.createLinearGradient(y.x,y.y+C,y.x,y.y-C);break;case`to-left`:a=e.createLinearGradient(y.x+S,y.y,y.x-S,y.y);break;case`to-right`:a=e.createLinearGradient(y.x-S,y.y,y.x+S,y.y);break;case`to-bottom-right`:case`to-right-bottom`:a=e.createLinearGradient(y.x-S,y.y-C,y.x+S,y.y+C);break;case`to-top-right`:case`to-right-top`:a=e.createLinearGradient(y.x-S,y.y+C,y.x+S,y.y-C);break;case`to-bottom-left`:case`to-left-bottom`:a=e.createLinearGradient(y.x+S,y.y-C,y.x-S,y.y+C);break;case`to-top-left`:case`to-left-top`:a=e.createLinearGradient(y.x+S,y.y+C,y.x-S,y.y-C)}}if(!a)return null;for(var w=c.length===s.length,T=s.length,E=0;E<T;E++){var D=Eh(s[E],i);a.addColorStop(w?c[E]:E/(T-1),`rgba(`+s[E][0]+`,`+s[E][1]+`,`+s[E][2]+`,`+D+`)`)}return a},Ch.gradientFillStyle=function(e,t,n,r){var i=this.createGradientStyleFor(e,`background`,t,n,r);if(!i)return null;e.fillStyle=i},Ch.colorFillStyle=function(e,t,n){e.fillStyle=`rgba(`+t[0]+`,`+t[1]+`,`+t[2]+`,`+Eh(t,n)+`)`},Ch.eleFillStyle=function(e,t,n){var r=t.pstyle(`background-fill`).value;if(r===`linear-gradient`||r===`radial-gradient`)this.gradientFillStyle(e,t,r,n);else{var i=t.pstyle(`background-color`).value;this.colorFillStyle(e,i,n)}},Ch.gradientStrokeStyle=function(e,t,n,r){var i=this.createGradientStyleFor(e,`line`,t,n,r);if(!i)return null;e.strokeStyle=i},Ch.colorStrokeStyle=function(e,t,n){e.strokeStyle=`rgba(`+t[0]+`,`+t[1]+`,`+t[2]+`,`+Eh(t,n)+`)`},Ch.eleStrokeStyle=function(e,t,n){var r=t.pstyle(`line-fill`).value;if(r===`linear-gradient`||r===`radial-gradient`)this.gradientStrokeStyle(e,t,r,n);else{var i=t.pstyle(`line-color`).value;this.colorStrokeStyle(e,i,n)}},Ch.matchCanvasSize=function(e){var t=this,n=t.data,r=t.findContainerClientCoords(),i=r[2],a=r[3],o=t.getPixelRatio(),s=t.motionBlurPxRatio;(e===t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_NODE]||e===t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_DRAG])&&(o=s);var c=i*o,l=a*o,u;if(c!==t.canvasWidth||l!==t.canvasHeight){t.fontCaches=null;var d=n.canvasContainer;d.style.width=i+`px`,d.style.height=a+`px`;for(var f=0;f<t.CANVAS_LAYERS;f++)u=n.canvases[f],u.width=c,u.height=l,u.style.width=i+`px`,u.style.height=a+`px`;for(var f=0;f<t.BUFFER_COUNT;f++)u=n.bufferCanvases[f],u.width=c,u.height=l,u.style.width=i+`px`,u.style.height=a+`px`;t.textureMult=1,o<=1&&(u=n.bufferCanvases[t.TEXTURE_BUFFER],t.textureMult=2,u.width=c*t.textureMult,u.height=l*t.textureMult),t.canvasWidth=c,t.canvasHeight=l,t.pixelRatio=o}},Ch.renderTo=function(e,t,n,r){this.render({forcedContext:e,forcedZoom:t,forcedPan:n,drawAllLayers:!0,forcedPxRatio:r})},Ch.clearCanvas=function(){var e=this,t=e.data;function n(t){t.clearRect(0,0,e.canvasWidth,e.canvasHeight)}n(t.contexts[e.NODE]),n(t.contexts[e.DRAG])},Ch.render=function(e){var t=this;e||=Wn();var n=t.cy,r=e.forcedContext,i=e.drawAllLayers,a=e.drawOnlyNodeLayer,o=e.forcedZoom,s=e.forcedPan,c=e.forcedPxRatio===void 0?this.getPixelRatio():e.forcedPxRatio,l=t.data,u=l.canvasNeedsRedraw,d=t.textureOnViewport&&!r&&(t.pinching||t.hoverData.dragging||t.swipePanning||t.data.wheelZooming),f=e.motionBlur===void 0?t.motionBlur:e.motionBlur,p=t.motionBlurPxRatio,m=n.hasCompoundNodes(),h=t.hoverData.draggingEles,g=!!(t.hoverData.selecting||t.touchData.selecting);f=f&&!r&&t.motionBlurEnabled&&!g;var _=f;r||(t.prevPxRatio!==c&&(t.invalidateContainerClientCoordsCache(),t.matchCanvasSize(t.container),t.redrawHint(`eles`,!0),t.redrawHint(`drag`,!0)),t.prevPxRatio=c),!r&&t.motionBlurTimeout&&clearTimeout(t.motionBlurTimeout),f&&(t.mbFrames??=0,t.mbFrames++,t.mbFrames<3&&(_=!1),t.mbFrames>t.minMbLowQualFrames&&(t.motionBlurPxRatio=t.mbPxRBlurry)),t.clearingMotionBlur&&(t.motionBlurPxRatio=1),t.textureDrawLastFrame&&!d&&(u[t.NODE]=!0,u[t.SELECT_BOX]=!0);var v=n.style(),y=n.zoom(),b=o===void 0?y:o,x=n.pan(),S={x:x.x,y:x.y},C={zoom:y,pan:{x:x.x,y:x.y}},w=t.prevViewport;w!==void 0&&C.zoom===w.zoom&&C.pan.x===w.pan.x&&C.pan.y===w.pan.y&&(!h||m)&&(t.motionBlurPxRatio=1),s&&(S=s),b*=c,S.x*=c,S.y*=c;var T=t.getCachedZSortedEles();function E(e,n,r,i,a){var o=e.globalCompositeOperation;e.globalCompositeOperation=`destination-out`,t.colorFillStyle(e,[255,255,255],t.motionBlurTransparency),e.fillRect(n,r,i,a),e.globalCompositeOperation=o}function D(e,n){var a,c,u,d;!t.clearingMotionBlur&&(e===l.bufferContexts[t.MOTIONBLUR_BUFFER_NODE]||e===l.bufferContexts[t.MOTIONBLUR_BUFFER_DRAG])?(a={x:x.x*p,y:x.y*p},c=y*p,u=t.canvasWidth*p,d=t.canvasHeight*p):(a=S,c=b,u=t.canvasWidth,d=t.canvasHeight),e.setTransform(1,0,0,1,0,0),n===`motionBlur`?E(e,0,0,u,d):!r&&(n===void 0||n)&&e.clearRect(0,0,u,d),i||(e.translate(a.x,a.y),e.scale(c,c)),s&&e.translate(s.x,s.y),o&&e.scale(o,o)}if(d||(t.textureDrawLastFrame=!1),d){if(t.textureDrawLastFrame=!0,!t.textureCache){t.textureCache={},t.textureCache.bb=n.mutableElements().boundingBox(),t.textureCache.texture=t.data.bufferCanvases[t.TEXTURE_BUFFER];var O=t.data.bufferContexts[t.TEXTURE_BUFFER];O.setTransform(1,0,0,1,0,0),O.clearRect(0,0,t.canvasWidth*t.textureMult,t.canvasHeight*t.textureMult),t.render({forcedContext:O,drawOnlyNodeLayer:!0,forcedPxRatio:c*t.textureMult});var C=t.textureCache.viewport={zoom:n.zoom(),pan:n.pan(),width:t.canvasWidth,height:t.canvasHeight};C.mpan={x:(0-C.pan.x)/C.zoom,y:(0-C.pan.y)/C.zoom}}u[t.DRAG]=!1,u[t.NODE]=!1;var k=l.contexts[t.NODE],A=t.textureCache.texture,C=t.textureCache.viewport;k.setTransform(1,0,0,1,0,0),f?E(k,0,0,C.width,C.height):k.clearRect(0,0,C.width,C.height);var j=v.core(`outside-texture-bg-color`).value,M=v.core(`outside-texture-bg-opacity`).value;t.colorFillStyle(k,j,M),k.fillRect(0,0,C.width,C.height);var y=n.zoom();D(k,!1),k.clearRect(C.mpan.x,C.mpan.y,C.width/C.zoom/c,C.height/C.zoom/c),k.drawImage(A,C.mpan.x,C.mpan.y,C.width/C.zoom/c,C.height/C.zoom/c)}else t.textureOnViewport&&!r&&(t.textureCache=null);var N=n.extent(),P=t.pinching||t.hoverData.dragging||t.swipePanning||t.data.wheelZooming||t.hoverData.draggingEles||t.cy.animated(),F=t.hideEdgesOnViewport&&P,I=[];if(I[t.NODE]=!u[t.NODE]&&f&&!t.clearedForMotionBlur[t.NODE]||t.clearingMotionBlur,I[t.NODE]&&(t.clearedForMotionBlur[t.NODE]=!0),I[t.DRAG]=!u[t.DRAG]&&f&&!t.clearedForMotionBlur[t.DRAG]||t.clearingMotionBlur,I[t.DRAG]&&(t.clearedForMotionBlur[t.DRAG]=!0),u[t.NODE]||i||a||I[t.NODE]){var L=f&&!I[t.NODE]&&p!==1,k=r||(L?t.data.bufferContexts[t.MOTIONBLUR_BUFFER_NODE]:l.contexts[t.NODE]);D(k,f&&!L?`motionBlur`:void 0),F?t.drawCachedNodes(k,T.nondrag,c,N):t.drawLayeredElements(k,T.nondrag,c,N),t.debug&&t.drawDebugPoints(k,T.nondrag),!i&&!f&&(u[t.NODE]=!1)}if(!a&&(u[t.DRAG]||i||I[t.DRAG])){var L=f&&!I[t.DRAG]&&p!==1,k=r||(L?t.data.bufferContexts[t.MOTIONBLUR_BUFFER_DRAG]:l.contexts[t.DRAG]);D(k,f&&!L?`motionBlur`:void 0),F?t.drawCachedNodes(k,T.drag,c,N):t.drawCachedElements(k,T.drag,c,N),t.debug&&t.drawDebugPoints(k,T.drag),!i&&!f&&(u[t.DRAG]=!1)}if(this.drawSelectionRectangle(e,D),f&&p!==1){var R=l.contexts[t.NODE],z=t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_NODE],B=l.contexts[t.DRAG],V=t.data.bufferCanvases[t.MOTIONBLUR_BUFFER_DRAG],H=function(e,n,r){e.setTransform(1,0,0,1,0,0),r||!_?e.clearRect(0,0,t.canvasWidth,t.canvasHeight):E(e,0,0,t.canvasWidth,t.canvasHeight);var i=p;e.drawImage(n,0,0,t.canvasWidth*i,t.canvasHeight*i,0,0,t.canvasWidth,t.canvasHeight)};(u[t.NODE]||I[t.NODE])&&(H(R,z,I[t.NODE]),u[t.NODE]=!1),(u[t.DRAG]||I[t.DRAG])&&(H(B,V,I[t.DRAG]),u[t.DRAG]=!1)}t.prevViewport=C,t.clearingMotionBlur&&(t.clearingMotionBlur=!1,t.motionBlurCleared=!0,t.motionBlur=!0),f&&(t.motionBlurTimeout=setTimeout(function(){t.motionBlurTimeout=null,t.clearedForMotionBlur[t.NODE]=!1,t.clearedForMotionBlur[t.DRAG]=!1,t.motionBlur=!1,t.clearingMotionBlur=!d,t.mbFrames=0,u[t.NODE]=!0,u[t.DRAG]=!0,t.redraw()},wh)),r||n.emit(`render`)};var Dh;Ch.drawSelectionRectangle=function(e,t){var n=this,r=n.cy,i=n.data,a=r.style(),o=e.drawOnlyNodeLayer,s=e.drawAllLayers,c=i.canvasNeedsRedraw,l=e.forcedContext;if(n.showFps||!o&&c[n.SELECT_BOX]&&!s){var u=l||i.contexts[n.SELECT_BOX];if(t(u),n.selection[4]==1&&(n.hoverData.selecting||n.touchData.selecting)){var d=n.cy.zoom(),f=a.core(`selection-box-border-width`).value/d;u.lineWidth=f,u.fillStyle=`rgba(`+a.core(`selection-box-color`).value[0]+`,`+a.core(`selection-box-color`).value[1]+`,`+a.core(`selection-box-color`).value[2]+`,`+a.core(`selection-box-opacity`).value+`)`,u.fillRect(n.selection[0],n.selection[1],n.selection[2]-n.selection[0],n.selection[3]-n.selection[1]),f>0&&(u.strokeStyle=`rgba(`+a.core(`selection-box-border-color`).value[0]+`,`+a.core(`selection-box-border-color`).value[1]+`,`+a.core(`selection-box-border-color`).value[2]+`,`+a.core(`selection-box-opacity`).value+`)`,u.strokeRect(n.selection[0],n.selection[1],n.selection[2]-n.selection[0],n.selection[3]-n.selection[1]))}if(i.bgActivePosistion&&!n.hoverData.selecting){var d=n.cy.zoom(),p=i.bgActivePosistion;u.fillStyle=`rgba(`+a.core(`active-bg-color`).value[0]+`,`+a.core(`active-bg-color`).value[1]+`,`+a.core(`active-bg-color`).value[2]+`,`+a.core(`active-bg-opacity`).value+`)`,u.beginPath(),u.arc(p.x,p.y,a.core(`active-bg-size`).pfValue/d,0,2*Math.PI),u.fill()}var m=n.lastRedrawTime;if(n.showFps&&m){m=Math.round(m);var h=Math.round(1e3/m),g=`1 frame = `+m+` ms = `+h+` fps`;u.setTransform(1,0,0,1,0,0),u.fillStyle=`rgba(255, 0, 0, 0.75)`,u.strokeStyle=`rgba(255, 0, 0, 0.75)`,u.font=`30px Arial`,Dh||=u.measureText(g).actualBoundingBoxAscent,u.fillText(g,0,Dh),u.strokeRect(0,Dh+10,250,20),u.fillRect(0,Dh+10,250*Math.min(h/60,1),20)}s||(c[n.SELECT_BOX]=!1)}};function Oh(e,t,n){var r=e.createShader(t);if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS))throw Error(e.getShaderInfoLog(r));return r}function kh(e,t,n){var r=Oh(e,e.VERTEX_SHADER,t),i=Oh(e,e.FRAGMENT_SHADER,n),a=e.createProgram();if(e.attachShader(a,r),e.attachShader(a,i),e.linkProgram(a),!e.getProgramParameter(a,e.LINK_STATUS))throw Error(`Could not initialize shaders`);return a}function Ah(e,t,n){n===void 0&&(n=t);var r=e.makeOffscreenCanvas(t,n),i=r.context=r.getContext(`2d`);return r.clear=function(){return i.clearRect(0,0,r.width,r.height)},r.clear(),r}function jh(e){var t=e.pixelRatio,n=e.cy.zoom(),r=e.cy.pan();return{zoom:n*t,pan:{x:r.x*t,y:r.y*t}}}function Mh(e){var t=e.pixelRatio;return e.cy.zoom()*t}function Nh(e,t,n,r,i){var a=r*n+t.x,o=i*n+t.y;return o=Math.round(e.canvasHeight-o),[a,o]}function Ph(e,t){return t.picking?!0:e.pstyle(`background-fill`).value!==`solid`||e.pstyle(`background-image`).strValue!==`none`?!1:e.pstyle(`border-width`).value===0||e.pstyle(`border-opacity`).value===0||e.pstyle(`border-style`).value===`solid`}function Fh(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Ih(e,t,n){var r=e[0]/255,i=e[1]/255,a=e[2]/255,o=(e[3]==null?1:e[3])*t,s=n||[,,,,];return s[0]=r*o,s[1]=i*o,s[2]=a*o,s[3]=o,s}function Lh(e,t){var n=t||[,,,,];return n[0]=((e|0)&255)/255,n[1]=(e>>8&255)/255,n[2]=(e>>16&255)/255,n[3]=(e>>24&255)/255,n}function Rh(e){return e[0]+(e[1]<<8)+(e[2]<<16)+(e[3]<<24)}function zh(e,t){var n=e.createTexture();return n.buffer=function(t){e.bindTexture(e.TEXTURE_2D,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_NEAREST),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null)},n.deleteTexture=function(){e.deleteTexture(n)},n}function Bh(e,t){switch(t){case`float`:return[1,e.FLOAT,4];case`vec2`:return[2,e.FLOAT,4];case`vec3`:return[3,e.FLOAT,4];case`vec4`:return[4,e.FLOAT,4];case`int`:return[1,e.INT,4];case`ivec2`:return[2,e.INT,4]}}function Vh(e,t,n){switch(t){case e.FLOAT:return new Float32Array(n);case e.INT:return new Int32Array(n)}}function Hh(e,t,n,r,i,a){switch(t){case e.FLOAT:return new Float32Array(n.buffer,a*r,i);case e.INT:return new Int32Array(n.buffer,a*r,i)}}function Uh(e,t,n,r){var i=ge(Bh(e,t),2),a=i[0],o=i[1],s=Vh(e,o,r),c=e.createBuffer();return e.bindBuffer(e.ARRAY_BUFFER,c),e.bufferData(e.ARRAY_BUFFER,s,e.STATIC_DRAW),o===e.FLOAT?e.vertexAttribPointer(n,a,o,!1,0,0):o===e.INT&&e.vertexAttribIPointer(n,a,o,0,0),e.enableVertexAttribArray(n),e.bindBuffer(e.ARRAY_BUFFER,null),c}function Wh(e,t,n,r){var i=ge(Bh(e,n),3),a=i[0],o=i[1],s=i[2],c=Vh(e,o,t*a),l=a*s,u=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,u),e.bufferData(e.ARRAY_BUFFER,t*l,e.DYNAMIC_DRAW),e.enableVertexAttribArray(r),o===e.FLOAT?e.vertexAttribPointer(r,a,o,!1,l,0):o===e.INT&&e.vertexAttribIPointer(r,a,o,l,0),e.vertexAttribDivisor(r,1),e.bindBuffer(e.ARRAY_BUFFER,null);for(var d=Array(t),f=0;f<t;f++)d[f]=Hh(e,o,c,l,a,f);return u.dataArray=c,u.stride=l,u.size=a,u.getView=function(e){return d[e]},u.setPoint=function(e,t,n){var r=d[e];r[0]=t,r[1]=n},u.bufferSubData=function(t){e.bindBuffer(e.ARRAY_BUFFER,u),t?e.bufferSubData(e.ARRAY_BUFFER,0,c,0,t*a):e.bufferSubData(e.ARRAY_BUFFER,0,c)},u}function Gh(e,t,n){for(var r=9,i=new Float32Array(t*r),a=Array(t),o=0;o<t;o++){var s=o*r*4;a[o]=new Float32Array(i.buffer,s,r)}var c=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,c),e.bufferData(e.ARRAY_BUFFER,i.byteLength,e.DYNAMIC_DRAW);for(var l=0;l<3;l++){var u=n+l;e.enableVertexAttribArray(u),e.vertexAttribPointer(u,3,e.FLOAT,!1,36,l*12),e.vertexAttribDivisor(u,1)}return e.bindBuffer(e.ARRAY_BUFFER,null),c.getMatrixView=function(e){return a[e]},c.setData=function(e,t){a[t].set(e,0)},c.bufferSubData=function(){e.bindBuffer(e.ARRAY_BUFFER,c),e.bufferSubData(e.ARRAY_BUFFER,0,i)},c}function Kh(e){var t=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,t);var n=e.createTexture();return e.bindTexture(e.TEXTURE_2D,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0),e.bindFramebuffer(e.FRAMEBUFFER,null),t.setFramebufferAttachmentSizes=function(t,r){e.bindTexture(e.TEXTURE_2D,n),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t,r,0,e.RGBA,e.UNSIGNED_BYTE,null)},t}var qh=typeof Float32Array<`u`?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function Jh(){var e=new qh(9);return qh!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function Yh(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e}function Xh(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=n[0],p=n[1],m=n[2],h=n[3],g=n[4],_=n[5],v=n[6],y=n[7],b=n[8];return e[0]=f*r+p*o+m*l,e[1]=f*i+p*s+m*u,e[2]=f*a+p*c+m*d,e[3]=h*r+g*o+_*l,e[4]=h*i+g*s+_*u,e[5]=h*a+g*c+_*d,e[6]=v*r+y*o+b*l,e[7]=v*i+y*s+b*u,e[8]=v*a+y*c+b*d,e}function Zh(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=n[0],p=n[1];return e[0]=r,e[1]=i,e[2]=a,e[3]=o,e[4]=s,e[5]=c,e[6]=f*r+p*o+l,e[7]=f*i+p*s+u,e[8]=f*a+p*c+d,e}function Qh(e,t,n){var r=t[0],i=t[1],a=t[2],o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=Math.sin(n),p=Math.cos(n);return e[0]=p*r+f*o,e[1]=p*i+f*s,e[2]=p*a+f*c,e[3]=p*o-f*r,e[4]=p*s-f*i,e[5]=p*c-f*a,e[6]=l,e[7]=u,e[8]=d,e}function $h(e,t,n){var r=n[0],i=n[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=i*t[3],e[4]=i*t[4],e[5]=i*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function eg(e,t,n){return e[0]=2/t,e[1]=0,e[2]=0,e[3]=0,e[4]=-2/n,e[5]=0,e[6]=-1,e[7]=1,e[8]=1,e}var tg=function(){function e(t,n,r,i){se(this,e),this.debugID=Math.floor(Math.random()*1e4),this.r=t,this.texSize=n,this.texRows=r,this.texHeight=Math.floor(n/r),this.enableWrapping=!0,this.locked=!1,this.texture=null,this.needsBuffer=!0,this.freePointer={x:0,row:0},this.keyToLocation=new Map,this.canvas=i(t,n,n),this.scratch=i(t,n,this.texHeight,`scratch`)}return le(e,[{key:`lock`,value:function(){this.locked=!0}},{key:`getKeys`,value:function(){return new Set(this.keyToLocation.keys())}},{key:`getScale`,value:function(e){var t=e.w,n=e.h,r=this.texHeight,i=this.texSize,a=r/n,o=t*a,s=n*a;return o>i&&(a=i/t,o=t*a,s=n*a),{scale:a,texW:o,texH:s}}},{key:`draw`,value:function(e,t,n){var r=this;if(this.locked)throw Error(`can't draw, atlas is locked`);var i=this.texSize,a=this.texRows,o=this.texHeight,s=this.getScale(t),c=s.scale,l=s.texW,u=s.texH,d=function(e,r){if(n&&r){var i=r.context,a=e.x,s=e.row,l=a,u=o*s;i.save(),i.translate(l,u),i.scale(c,c),n(i,t),i.restore()}},f=[null,null],p=function(){d(r.freePointer,r.canvas),f[0]={x:r.freePointer.x,y:r.freePointer.row*o,w:l,h:u},f[1]={x:r.freePointer.x+l,y:r.freePointer.row*o,w:0,h:u},r.freePointer.x+=l,r.freePointer.x==i&&(r.freePointer.x=0,r.freePointer.row++)},m=function(){var e=r.scratch,t=r.canvas;e.clear(),d({x:0,row:0},e);var n=i-r.freePointer.x,a=l-n,s=o,c=r.freePointer.x,p=r.freePointer.row*o,m=n;t.context.drawImage(e,0,0,m,s,c,p,m,s),f[0]={x:c,y:p,w:m,h:u};var h=n,g=(r.freePointer.row+1)*o,_=a;t&&t.context.drawImage(e,h,0,_,s,0,g,_,s),f[1]={x:0,y:g,w:_,h:u},r.freePointer.x=a,r.freePointer.row++},h=function(){r.freePointer.x=0,r.freePointer.row++};if(this.freePointer.x+l<=i)p();else if(this.freePointer.row>=a-1)return!1;else this.freePointer.x===i?(h(),p()):this.enableWrapping?m():(h(),p());return this.keyToLocation.set(e,f),this.needsBuffer=!0,f}},{key:`getOffsets`,value:function(e){return this.keyToLocation.get(e)}},{key:`isEmpty`,value:function(){return this.freePointer.x===0&&this.freePointer.row===0}},{key:`canFit`,value:function(e){if(this.locked)return!1;var t=this.texSize,n=this.texRows,r=this.getScale(e).texW;return this.freePointer.x+r>t?this.freePointer.row<n-1:!0}},{key:`bufferIfNeeded`,value:function(e){this.texture||=zh(e,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(),null),this.canvas=null,this.scratch=null,this.locked=!0}}])}(),ng=function(){function e(t,n,r,i){se(this,e),this.r=t,this.texSize=n,this.texRows=r,this.createTextureCanvas=i,this.atlases=[],this.styleKeyToAtlas=new Map,this.markedKeys=new Set}return le(e,[{key:`getKeys`,value:function(){return new Set(this.styleKeyToAtlas.keys())}},{key:`_createAtlas`,value:function(){var e=this.r,t=this.texSize,n=this.texRows,r=this.createTextureCanvas;return new tg(e,t,n,r)}},{key:`_getScratchCanvas`,value:function(){if(!this.scratch){var e=this.r,t=this.texSize,n=this.texRows,r=this.createTextureCanvas,i=Math.floor(t/n);this.scratch=r(e,t,i,`scratch`)}return this.scratch}},{key:`draw`,value:function(e,t,n){var r=this.styleKeyToAtlas.get(e);return r||(r=this.atlases[this.atlases.length-1],r&&r.canFit(t)||(r&&r.lock(),r=this._createAtlas(),this.atlases.push(r)),r.draw(e,t,n),this.styleKeyToAtlas.set(e,r)),r}},{key:`getAtlas`,value:function(e){return this.styleKeyToAtlas.get(e)}},{key:`hasAtlas`,value:function(e){return this.styleKeyToAtlas.has(e)}},{key:`markKeyForGC`,value:function(e){this.markedKeys.add(e)}},{key:`gc`,value:function(){var e=this,t=this.markedKeys;if(t.size===0)console.log(`nothing to garbage collect`);else{var n=[],r=new Map,i=null,a=ue(this.atlases),o;try{var s=function(){var a=o.value,s=a.getKeys(),c=rg(t,s);if(c.size===0)return n.push(a),s.forEach(function(e){return r.set(e,a)}),1;i||(i=e._createAtlas(),n.push(i));var l=ue(s),u;try{for(l.s();!(u=l.n()).done;){var d=u.value;if(!c.has(d)){var f=ge(a.getOffsets(d),2),p=f[0],m=f[1];i.canFit({w:p.w+m.w,h:p.h})||(i.lock(),i=e._createAtlas(),n.push(i)),a.canvas&&(e._copyTextureToNewAtlas(d,a,i),r.set(d,i))}}}catch(e){l.e(e)}finally{l.f()}a.dispose()};for(a.s();!(o=a.n()).done;)if(s())continue}catch(e){a.e(e)}finally{a.f()}this.atlases=n,this.styleKeyToAtlas=r,this.markedKeys=new Set}}},{key:`_copyTextureToNewAtlas`,value:function(e,t,n){var r=ge(t.getOffsets(e),2),i=r[0],a=r[1];if(a.w===0)n.draw(e,i,function(e){e.drawImage(t.canvas,i.x,i.y,i.w,i.h,0,0,i.w,i.h)});else{var o=this._getScratchCanvas();o.clear(),o.context.drawImage(t.canvas,i.x,i.y,i.w,i.h,0,0,i.w,i.h),o.context.drawImage(t.canvas,a.x,a.y,a.w,a.h,i.w,0,a.w,a.h);var s=i.w+a.w,c=i.h;n.draw(e,{w:s,h:c},function(e){e.drawImage(o,0,0,s,c,0,0,s,c)})}}},{key:`getCounts`,value:function(){return{keyCount:this.styleKeyToAtlas.size,atlasCount:new Set(this.styleKeyToAtlas.values()).size}}}])}();function rg(e,t){return e.intersection?e.intersection(t):new Set(_e(e).filter(function(e){return t.has(e)}))}var ig=function(){function e(t,n){se(this,e),this.r=t,this.globalOptions=n,this.atlasSize=n.webglTexSize,this.maxAtlasesPerBatch=n.webglTexPerBatch,this.renderTypes=new Map,this.collections=new Map,this.typeAndIdToKey=new Map}return le(e,[{key:`getAtlasSize`,value:function(){return this.atlasSize}},{key:`addAtlasCollection`,value:function(e,t){var n=this.globalOptions,r=n.webglTexSize,i=n.createTextureCanvas,a=t.texRows,o=this._cacheScratchCanvas(i),s=new ng(this.r,r,a,o);this.collections.set(e,s)}},{key:`addRenderType`,value:function(e,t){var n=t.collection;if(!this.collections.has(n))throw Error(`invalid atlas collection name '${n}'`);var r=Z({type:e,atlasCollection:this.collections.get(n)},t);this.renderTypes.set(e,r)}},{key:`getRenderTypeOpts`,value:function(e){return this.renderTypes.get(e)}},{key:`getAtlasCollection`,value:function(e){return this.collections.get(e)}},{key:`_cacheScratchCanvas`,value:function(e){var t=-1,n=-1,r=null;return function(i,a,o,s){return s?(r&&a==t&&o==n||(t=a,n=o,r=e(i,a,o)),r):e(i,a,o)}}},{key:`_key`,value:function(e,t){return`${e}-${t}`}},{key:`invalidate`,value:function(e){var t=this,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=n.forceRedraw,i=r!==void 0&&r,a=n.filterEle,o=a===void 0?function(){return!0}:a,s=n.filterType,c=s===void 0?function(){return!0}:s,l=!1,u=!1,d=ue(e),f;try{for(d.s();!(f=d.n()).done;){var p=f.value;if(o(p)){var m=ue(this.renderTypes.values()),h;try{var g=function(){var e=h.value,n=e.type;if(c(n)){var r=t.collections.get(e.collection),a=e.getKey(p),o=Array.isArray(a)?a:[a];if(i)o.forEach(function(e){return r.markKeyForGC(e)}),u=!0;else{var s=e.getID?e.getID(p):p.id(),d=t._key(n,s),f=t.typeAndIdToKey.get(d);f!==void 0&&!Fh(o,f)&&(l=!0,t.typeAndIdToKey.delete(d),f.forEach(function(e){return r.markKeyForGC(e)}))}}};for(m.s();!(h=m.n()).done;)g()}catch(e){m.e(e)}finally{m.f()}}}}catch(e){d.e(e)}finally{d.f()}return u&&(this.gc(),l=!1),l}},{key:`gc`,value:function(){var e=ue(this.collections.values()),t;try{for(e.s();!(t=e.n()).done;)t.value.gc()}catch(t){e.e(t)}finally{e.f()}}},{key:`getOrCreateAtlas`,value:function(e,t,n,r){var i=this.renderTypes.get(t),a=this.collections.get(i.collection),o=!1,s=a.draw(r,n,function(t){i.drawClipped?(t.save(),t.beginPath(),t.rect(0,0,n.w,n.h),t.clip(),i.drawElement(t,e,n,!0,!0),t.restore()):i.drawElement(t,e,n,!0,!0),o=!0});if(o){var c=i.getID?i.getID(e):e.id(),l=this._key(t,c);this.typeAndIdToKey.has(l)?this.typeAndIdToKey.get(l).push(r):this.typeAndIdToKey.set(l,[r])}return s}},{key:`getAtlasInfo`,value:function(e,t){var n=this,r=this.renderTypes.get(t),i=r.getKey(e);return(Array.isArray(i)?i:[i]).map(function(i){var a=r.getBoundingBox(e,i),o=n.getOrCreateAtlas(e,t,a,i),s=ge(o.getOffsets(i),2),c=s[0];return{atlas:o,tex:c,tex1:c,tex2:s[1],bb:a}})}},{key:`getDebugInfo`,value:function(){var e=[],t=ue(this.collections),n;try{for(t.s();!(n=t.n()).done;){var r=ge(n.value,2),i=r[0],a=r[1].getCounts(),o=a.keyCount,s=a.atlasCount;e.push({type:i,keyCount:o,atlasCount:s})}}catch(e){t.e(e)}finally{t.f()}return e}}])}(),ag=function(){function e(t){se(this,e),this.globalOptions=t,this.atlasSize=t.webglTexSize,this.maxAtlasesPerBatch=t.webglTexPerBatch,this.batchAtlases=[]}return le(e,[{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(e,t){return t})}},{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(e){return this.batchAtlases.length!==this.maxAtlasesPerBatch||this.batchAtlases.includes(e)}},{key:`getAtlasIndexForBatch`,value:function(e){var t=this.batchAtlases.indexOf(e);if(t<0){if(this.batchAtlases.length===this.maxAtlasesPerBatch)throw Error(`cannot add more atlases to batch`);this.batchAtlases.push(e),t=this.batchAtlases.length-1}return t}}])}(),og=`
|
|
9
|
+
float circleSD(vec2 p, float r) {
|
|
10
|
+
return distance(vec2(0), p) - r; // signed distance
|
|
11
|
+
}
|
|
12
|
+
`,sg=`
|
|
13
|
+
float rectangleSD(vec2 p, vec2 b) {
|
|
14
|
+
vec2 d = abs(p)-b;
|
|
15
|
+
return distance(vec2(0),max(d,0.0)) + min(max(d.x,d.y),0.0);
|
|
16
|
+
}
|
|
17
|
+
`,cg=`
|
|
18
|
+
float roundRectangleSD(vec2 p, vec2 b, vec4 cr) {
|
|
19
|
+
cr.xy = (p.x > 0.0) ? cr.xy : cr.zw;
|
|
20
|
+
cr.x = (p.y > 0.0) ? cr.x : cr.y;
|
|
21
|
+
vec2 q = abs(p) - b + cr.x;
|
|
22
|
+
return min(max(q.x, q.y), 0.0) + distance(vec2(0), max(q, 0.0)) - cr.x;
|
|
23
|
+
}
|
|
24
|
+
`,lg=`
|
|
25
|
+
float ellipseSD(vec2 p, vec2 ab) {
|
|
26
|
+
p = abs( p ); // symmetry
|
|
27
|
+
|
|
28
|
+
// find root with Newton solver
|
|
29
|
+
vec2 q = ab*(p-ab);
|
|
30
|
+
float w = (q.x<q.y)? 1.570796327 : 0.0;
|
|
31
|
+
for( int i=0; i<5; i++ ) {
|
|
32
|
+
vec2 cs = vec2(cos(w),sin(w));
|
|
33
|
+
vec2 u = ab*vec2( cs.x,cs.y);
|
|
34
|
+
vec2 v = ab*vec2(-cs.y,cs.x);
|
|
35
|
+
w = w + dot(p-u,v)/(dot(p-u,u)+dot(v,v));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// compute final point and distance
|
|
39
|
+
float d = length(p-ab*vec2(cos(w),sin(w)));
|
|
40
|
+
|
|
41
|
+
// return signed distance
|
|
42
|
+
return (dot(p/ab,p/ab)>1.0) ? d : -d;
|
|
43
|
+
}
|
|
44
|
+
`,ug={SCREEN:{name:`screen`,screen:!0},PICKING:{name:`picking`,picking:!0}},dg={IGNORE:1,USE_BB:2},fg=0,pg=1,mg=2,hg=3,gg=4,_g=5,vg=6,yg=7,bg=function(){function e(t,n,r){se(this,e),this.r=t,this.gl=n,this.maxInstances=r.webglBatchSize,this.atlasSize=r.webglTexSize,this.bgColor=r.bgColor,this.debug=r.webglDebug,this.batchDebugInfo=[],r.enableWrapping=!0,r.createTextureCanvas=Ah,this.atlasManager=new ig(t,r),this.batchManager=new ag(r),this.simpleShapeOptions=new Map,this.program=this._createShaderProgram(ug.SCREEN),this.pickingProgram=this._createShaderProgram(ug.PICKING),this.vao=this._createVAO()}return le(e,[{key:`addAtlasCollection`,value:function(e,t){this.atlasManager.addAtlasCollection(e,t)}},{key:`addTextureAtlasRenderType`,value:function(e,t){this.atlasManager.addRenderType(e,t)}},{key:`addSimpleShapeRenderType`,value:function(e,t){this.simpleShapeOptions.set(e,t)}},{key:`invalidate`,value:function(e){var t=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}).type,n=this.atlasManager;return t?n.invalidate(e,{filterType:function(e){return e===t},forceRedraw:!0}):n.invalidate(e)}},{key:`gc`,value:function(){this.atlasManager.gc()}},{key:`_createShaderProgram`,value:function(e){var t=this.gl,n=`#version 300 es
|
|
45
|
+
precision highp float;
|
|
46
|
+
|
|
47
|
+
uniform mat3 uPanZoomMatrix;
|
|
48
|
+
uniform int uAtlasSize;
|
|
49
|
+
|
|
50
|
+
// instanced
|
|
51
|
+
in vec2 aPosition; // a vertex from the unit square
|
|
52
|
+
|
|
53
|
+
in mat3 aTransform; // used to transform verticies, eg into a bounding box
|
|
54
|
+
in int aVertType; // the type of thing we are rendering
|
|
55
|
+
|
|
56
|
+
// the z-index that is output when using picking mode
|
|
57
|
+
in vec4 aIndex;
|
|
58
|
+
|
|
59
|
+
// For textures
|
|
60
|
+
in int aAtlasId; // which shader unit/atlas to use
|
|
61
|
+
in vec4 aTex; // x/y/w/h of texture in atlas
|
|
62
|
+
|
|
63
|
+
// for edges
|
|
64
|
+
in vec4 aPointAPointB;
|
|
65
|
+
in vec4 aPointCPointD;
|
|
66
|
+
in vec2 aLineWidth; // also used for node border width
|
|
67
|
+
|
|
68
|
+
// simple shapes
|
|
69
|
+
in vec4 aCornerRadius; // for round-rectangle [top-right, bottom-right, top-left, bottom-left]
|
|
70
|
+
in vec4 aColor; // also used for edges
|
|
71
|
+
in vec4 aBorderColor; // aLineWidth is used for border width
|
|
72
|
+
|
|
73
|
+
// output values passed to the fragment shader
|
|
74
|
+
out vec2 vTexCoord;
|
|
75
|
+
out vec4 vColor;
|
|
76
|
+
out vec2 vPosition;
|
|
77
|
+
// flat values are not interpolated
|
|
78
|
+
flat out int vAtlasId;
|
|
79
|
+
flat out int vVertType;
|
|
80
|
+
flat out vec2 vTopRight;
|
|
81
|
+
flat out vec2 vBotLeft;
|
|
82
|
+
flat out vec4 vCornerRadius;
|
|
83
|
+
flat out vec4 vBorderColor;
|
|
84
|
+
flat out vec2 vBorderWidth;
|
|
85
|
+
flat out vec4 vIndex;
|
|
86
|
+
|
|
87
|
+
void main(void) {
|
|
88
|
+
int vid = gl_VertexID;
|
|
89
|
+
vec2 position = aPosition; // TODO make this a vec3, simplifies some code below
|
|
90
|
+
|
|
91
|
+
if(aVertType == ${fg}) {
|
|
92
|
+
float texX = aTex.x; // texture coordinates
|
|
93
|
+
float texY = aTex.y;
|
|
94
|
+
float texW = aTex.z;
|
|
95
|
+
float texH = aTex.w;
|
|
96
|
+
|
|
97
|
+
if(vid == 1 || vid == 2 || vid == 4) {
|
|
98
|
+
texX += texW;
|
|
99
|
+
}
|
|
100
|
+
if(vid == 2 || vid == 4 || vid == 5) {
|
|
101
|
+
texY += texH;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
float d = float(uAtlasSize);
|
|
105
|
+
vTexCoord = vec2(texX / d, texY / d); // tex coords must be between 0 and 1
|
|
106
|
+
|
|
107
|
+
gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);
|
|
108
|
+
}
|
|
109
|
+
else if(aVertType == ${gg} || aVertType == ${yg}
|
|
110
|
+
|| aVertType == ${_g} || aVertType == ${vg}) { // simple shapes
|
|
111
|
+
|
|
112
|
+
// the bounding box is needed by the fragment shader
|
|
113
|
+
vBotLeft = (aTransform * vec3(0, 0, 1)).xy; // flat
|
|
114
|
+
vTopRight = (aTransform * vec3(1, 1, 1)).xy; // flat
|
|
115
|
+
vPosition = (aTransform * vec3(position, 1)).xy; // will be interpolated
|
|
116
|
+
|
|
117
|
+
// calculations are done in the fragment shader, just pass these along
|
|
118
|
+
vColor = aColor;
|
|
119
|
+
vCornerRadius = aCornerRadius;
|
|
120
|
+
vBorderColor = aBorderColor;
|
|
121
|
+
vBorderWidth = aLineWidth;
|
|
122
|
+
|
|
123
|
+
gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);
|
|
124
|
+
}
|
|
125
|
+
else if(aVertType == ${pg}) {
|
|
126
|
+
vec2 source = aPointAPointB.xy;
|
|
127
|
+
vec2 target = aPointAPointB.zw;
|
|
128
|
+
|
|
129
|
+
// adjust the geometry so that the line is centered on the edge
|
|
130
|
+
position.y = position.y - 0.5;
|
|
131
|
+
|
|
132
|
+
// stretch the unit square into a long skinny rectangle
|
|
133
|
+
vec2 xBasis = target - source;
|
|
134
|
+
vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));
|
|
135
|
+
vec2 point = source + xBasis * position.x + yBasis * aLineWidth[0] * position.y;
|
|
136
|
+
|
|
137
|
+
gl_Position = vec4(uPanZoomMatrix * vec3(point, 1.0), 1.0);
|
|
138
|
+
vColor = aColor;
|
|
139
|
+
}
|
|
140
|
+
else if(aVertType == ${mg}) {
|
|
141
|
+
vec2 pointA = aPointAPointB.xy;
|
|
142
|
+
vec2 pointB = aPointAPointB.zw;
|
|
143
|
+
vec2 pointC = aPointCPointD.xy;
|
|
144
|
+
vec2 pointD = aPointCPointD.zw;
|
|
145
|
+
|
|
146
|
+
// adjust the geometry so that the line is centered on the edge
|
|
147
|
+
position.y = position.y - 0.5;
|
|
148
|
+
|
|
149
|
+
vec2 p0, p1, p2, pos;
|
|
150
|
+
if(position.x == 0.0) { // The left side of the unit square
|
|
151
|
+
p0 = pointA;
|
|
152
|
+
p1 = pointB;
|
|
153
|
+
p2 = pointC;
|
|
154
|
+
pos = position;
|
|
155
|
+
} else { // The right side of the unit square, use same approach but flip the geometry upside down
|
|
156
|
+
p0 = pointD;
|
|
157
|
+
p1 = pointC;
|
|
158
|
+
p2 = pointB;
|
|
159
|
+
pos = vec2(0.0, -position.y);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
vec2 p01 = p1 - p0;
|
|
163
|
+
vec2 p12 = p2 - p1;
|
|
164
|
+
vec2 p21 = p1 - p2;
|
|
165
|
+
|
|
166
|
+
// Find the normal vector.
|
|
167
|
+
vec2 tangent = normalize(normalize(p12) + normalize(p01));
|
|
168
|
+
vec2 normal = vec2(-tangent.y, tangent.x);
|
|
169
|
+
|
|
170
|
+
// Find the vector perpendicular to p0 -> p1.
|
|
171
|
+
vec2 p01Norm = normalize(vec2(-p01.y, p01.x));
|
|
172
|
+
|
|
173
|
+
// Determine the bend direction.
|
|
174
|
+
float sigma = sign(dot(p01 + p21, normal));
|
|
175
|
+
float width = aLineWidth[0];
|
|
176
|
+
|
|
177
|
+
if(sign(pos.y) == -sigma) {
|
|
178
|
+
// This is an intersecting vertex. Adjust the position so that there's no overlap.
|
|
179
|
+
vec2 point = 0.5 * width * normal * -sigma / dot(normal, p01Norm);
|
|
180
|
+
gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);
|
|
181
|
+
} else {
|
|
182
|
+
// This is a non-intersecting vertex. Treat it like a mitre join.
|
|
183
|
+
vec2 point = 0.5 * width * normal * sigma * dot(normal, p01Norm);
|
|
184
|
+
gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
vColor = aColor;
|
|
188
|
+
}
|
|
189
|
+
else if(aVertType == ${hg} && vid < 3) {
|
|
190
|
+
// massage the first triangle into an edge arrow
|
|
191
|
+
if(vid == 0)
|
|
192
|
+
position = vec2(-0.15, -0.3);
|
|
193
|
+
if(vid == 1)
|
|
194
|
+
position = vec2( 0.0, 0.0);
|
|
195
|
+
if(vid == 2)
|
|
196
|
+
position = vec2( 0.15, -0.3);
|
|
197
|
+
|
|
198
|
+
gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);
|
|
199
|
+
vColor = aColor;
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
gl_Position = vec4(2.0, 0.0, 0.0, 1.0); // discard vertex by putting it outside webgl clip space
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
vAtlasId = aAtlasId;
|
|
206
|
+
vVertType = aVertType;
|
|
207
|
+
vIndex = aIndex;
|
|
208
|
+
}
|
|
209
|
+
`,r=this.batchManager.getIndexArray(),i=kh(t,n,`#version 300 es
|
|
210
|
+
precision highp float;
|
|
211
|
+
|
|
212
|
+
// declare texture unit for each texture atlas in the batch
|
|
213
|
+
${r.map(function(e){return`uniform sampler2D uTexture${e};`}).join(`
|
|
214
|
+
`)}
|
|
215
|
+
|
|
216
|
+
uniform vec4 uBGColor;
|
|
217
|
+
uniform float uZoom;
|
|
218
|
+
|
|
219
|
+
in vec2 vTexCoord;
|
|
220
|
+
in vec4 vColor;
|
|
221
|
+
in vec2 vPosition; // model coordinates
|
|
222
|
+
|
|
223
|
+
flat in int vAtlasId;
|
|
224
|
+
flat in vec4 vIndex;
|
|
225
|
+
flat in int vVertType;
|
|
226
|
+
flat in vec2 vTopRight;
|
|
227
|
+
flat in vec2 vBotLeft;
|
|
228
|
+
flat in vec4 vCornerRadius;
|
|
229
|
+
flat in vec4 vBorderColor;
|
|
230
|
+
flat in vec2 vBorderWidth;
|
|
231
|
+
|
|
232
|
+
out vec4 outColor;
|
|
233
|
+
|
|
234
|
+
${og}
|
|
235
|
+
${sg}
|
|
236
|
+
${cg}
|
|
237
|
+
${lg}
|
|
238
|
+
|
|
239
|
+
vec4 blend(vec4 top, vec4 bot) { // blend colors with premultiplied alpha
|
|
240
|
+
return vec4(
|
|
241
|
+
top.rgb + (bot.rgb * (1.0 - top.a)),
|
|
242
|
+
top.a + (bot.a * (1.0 - top.a))
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
vec4 distInterp(vec4 cA, vec4 cB, float d) { // interpolate color using Signed Distance
|
|
247
|
+
// scale to the zoom level so that borders don't look blurry when zoomed in
|
|
248
|
+
// note 1.5 is an aribitrary value chosen because it looks good
|
|
249
|
+
return mix(cA, cB, 1.0 - smoothstep(0.0, 1.5 / uZoom, abs(d)));
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
void main(void) {
|
|
253
|
+
if(vVertType == ${fg}) {
|
|
254
|
+
// look up the texel from the texture unit
|
|
255
|
+
${r.map(function(e){return`if(vAtlasId == ${e}) outColor = texture(uTexture${e}, vTexCoord);`}).join(`
|
|
256
|
+
else `)}
|
|
257
|
+
}
|
|
258
|
+
else if(vVertType == ${hg}) {
|
|
259
|
+
// mimics how canvas renderer uses context.globalCompositeOperation = 'destination-out';
|
|
260
|
+
outColor = blend(vColor, uBGColor);
|
|
261
|
+
outColor.a = 1.0; // make opaque, masks out line under arrow
|
|
262
|
+
}
|
|
263
|
+
else if(vVertType == ${gg} && vBorderWidth == vec2(0.0)) { // simple rectangle with no border
|
|
264
|
+
outColor = vColor; // unit square is already transformed to the rectangle, nothing else needs to be done
|
|
265
|
+
}
|
|
266
|
+
else if(vVertType == ${gg} || vVertType == ${yg}
|
|
267
|
+
|| vVertType == ${_g} || vVertType == ${vg}) { // use SDF
|
|
268
|
+
|
|
269
|
+
float outerBorder = vBorderWidth[0];
|
|
270
|
+
float innerBorder = vBorderWidth[1];
|
|
271
|
+
float borderPadding = outerBorder * 2.0;
|
|
272
|
+
float w = vTopRight.x - vBotLeft.x - borderPadding;
|
|
273
|
+
float h = vTopRight.y - vBotLeft.y - borderPadding;
|
|
274
|
+
vec2 b = vec2(w/2.0, h/2.0); // half width, half height
|
|
275
|
+
vec2 p = vPosition - vec2(vTopRight.x - b[0] - outerBorder, vTopRight.y - b[1] - outerBorder); // translate to center
|
|
276
|
+
|
|
277
|
+
float d; // signed distance
|
|
278
|
+
if(vVertType == ${gg}) {
|
|
279
|
+
d = rectangleSD(p, b);
|
|
280
|
+
} else if(vVertType == ${yg} && w == h) {
|
|
281
|
+
d = circleSD(p, b.x); // faster than ellipse
|
|
282
|
+
} else if(vVertType == ${yg}) {
|
|
283
|
+
d = ellipseSD(p, b);
|
|
284
|
+
} else {
|
|
285
|
+
d = roundRectangleSD(p, b, vCornerRadius.wzyx);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// use the distance to interpolate a color to smooth the edges of the shape, doesn't need multisampling
|
|
289
|
+
// we must smooth colors inwards, because we can't change pixels outside the shape's bounding box
|
|
290
|
+
if(d > 0.0) {
|
|
291
|
+
if(d > outerBorder) {
|
|
292
|
+
discard;
|
|
293
|
+
} else {
|
|
294
|
+
outColor = distInterp(vBorderColor, vec4(0), d - outerBorder);
|
|
295
|
+
}
|
|
296
|
+
} else {
|
|
297
|
+
if(d > innerBorder) {
|
|
298
|
+
vec4 outerColor = outerBorder == 0.0 ? vec4(0) : vBorderColor;
|
|
299
|
+
vec4 innerBorderColor = blend(vBorderColor, vColor);
|
|
300
|
+
outColor = distInterp(innerBorderColor, outerColor, d);
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
vec4 outerColor;
|
|
304
|
+
if(innerBorder == 0.0 && outerBorder == 0.0) {
|
|
305
|
+
outerColor = vec4(0);
|
|
306
|
+
} else if(innerBorder == 0.0) {
|
|
307
|
+
outerColor = vBorderColor;
|
|
308
|
+
} else {
|
|
309
|
+
outerColor = blend(vBorderColor, vColor);
|
|
310
|
+
}
|
|
311
|
+
outColor = distInterp(vColor, outerColor, d - innerBorder);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
outColor = vColor;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
${e.picking?`if(outColor.a == 0.0) discard;
|
|
320
|
+
else outColor = vIndex;`:``}
|
|
321
|
+
}
|
|
322
|
+
`);i.aPosition=t.getAttribLocation(i,`aPosition`),i.aIndex=t.getAttribLocation(i,`aIndex`),i.aVertType=t.getAttribLocation(i,`aVertType`),i.aTransform=t.getAttribLocation(i,`aTransform`),i.aAtlasId=t.getAttribLocation(i,`aAtlasId`),i.aTex=t.getAttribLocation(i,`aTex`),i.aPointAPointB=t.getAttribLocation(i,`aPointAPointB`),i.aPointCPointD=t.getAttribLocation(i,`aPointCPointD`),i.aLineWidth=t.getAttribLocation(i,`aLineWidth`),i.aColor=t.getAttribLocation(i,`aColor`),i.aCornerRadius=t.getAttribLocation(i,`aCornerRadius`),i.aBorderColor=t.getAttribLocation(i,`aBorderColor`),i.uPanZoomMatrix=t.getUniformLocation(i,`uPanZoomMatrix`),i.uAtlasSize=t.getUniformLocation(i,`uAtlasSize`),i.uBGColor=t.getUniformLocation(i,`uBGColor`),i.uZoom=t.getUniformLocation(i,`uZoom`),i.uTextures=[];for(var a=0;a<this.batchManager.getMaxAtlasesPerBatch();a++)i.uTextures.push(t.getUniformLocation(i,`uTexture${a}`));return i}},{key:`_createVAO`,value:function(){var e=[0,0,1,0,1,1,0,0,1,1,0,1];this.vertexCount=e.length/2;var t=this.maxInstances,n=this.gl,r=this.program,i=n.createVertexArray();return n.bindVertexArray(i),Uh(n,`vec2`,r.aPosition,e),this.transformBuffer=Gh(n,t,r.aTransform),this.indexBuffer=Wh(n,t,`vec4`,r.aIndex),this.vertTypeBuffer=Wh(n,t,`int`,r.aVertType),this.atlasIdBuffer=Wh(n,t,`int`,r.aAtlasId),this.texBuffer=Wh(n,t,`vec4`,r.aTex),this.pointAPointBBuffer=Wh(n,t,`vec4`,r.aPointAPointB),this.pointCPointDBuffer=Wh(n,t,`vec4`,r.aPointCPointD),this.lineWidthBuffer=Wh(n,t,`vec2`,r.aLineWidth),this.colorBuffer=Wh(n,t,`vec4`,r.aColor),this.cornerRadiusBuffer=Wh(n,t,`vec4`,r.aCornerRadius),this.borderColorBuffer=Wh(n,t,`vec4`,r.aBorderColor),n.bindVertexArray(null),i}},{key:`buffers`,get:function(){var e=this;return this._buffers||=Object.keys(this).filter(function(e){return Ze(e,`Buffer`)}).map(function(t){return e[t]}),this._buffers}},{key:`startFrame`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ug.SCREEN;this.panZoomMatrix=e,this.renderTarget=t,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(e,t){return e.visible()?t&&t.isVisible?t.isVisible(e):!0:!1}},{key:`drawTexture`,value:function(e,t,n){var r=this.atlasManager,i=this.batchManager,a=r.getRenderTypeOpts(n);if(this._isVisible(e,a)&&(!e.isEdge()||this._isValidEdge(e))){if(this.renderTarget.picking&&a.getTexPickingMode){var o=a.getTexPickingMode(e);if(o===dg.IGNORE)return;if(o==dg.USE_BB){this.drawPickingRectangle(e,t,n);return}}var s=ue(r.getAtlasInfo(e,n)),c;try{for(s.s();!(c=s.n()).done;){var l=c.value,u=l.atlas,d=l.tex1,f=l.tex2;i.canAddToCurrentBatch(u)||this.endBatch();for(var p=i.getAtlasIndexForBatch(u),m=0,h=[[d,!0],[f,!1]];m<h.length;m++){var g=ge(h[m],2),_=g[0],v=g[1];if(_.w!=0){var y=this.instanceCount;this.vertTypeBuffer.getView(y)[0]=fg,Lh(t,this.indexBuffer.getView(y));var b=this.atlasIdBuffer.getView(y);b[0]=p;var x=this.texBuffer.getView(y);x[0]=_.x,x[1]=_.y,x[2]=_.w,x[3]=_.h;var S=this.transformBuffer.getMatrixView(y);this.setTransformMatrix(e,S,a,l,v),this.instanceCount++,v||this.wrappedCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}catch(e){s.e(e)}finally{s.f()}}}},{key:`setTransformMatrix`,value:function(e,t,n,r){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=0;if(n.shapeProps&&n.shapeProps.padding&&(a=e.pstyle(n.shapeProps.padding).pfValue),r){var o=r.bb,s=r.tex1,c=r.tex2,l=s.w/(s.w+c.w);i||(l=1-l);var u=this._getAdjustedBB(o,a,i,l);this._applyTransformMatrix(t,u,n,e)}else{var d=n.getBoundingBox(e),f=this._getAdjustedBB(d,a,!0,1);this._applyTransformMatrix(t,f,n,e)}}},{key:`_applyTransformMatrix`,value:function(e,t,n,r){var i,a;Yh(e);var o=n.getRotation?n.getRotation(r):0;if(o!==0){var s=n.getRotationPoint(r),c=s.x,l=s.y;Zh(e,e,[c,l]),Qh(e,e,o);var u=n.getRotationOffset(r);i=u.x+(t.xOffset||0),a=u.y+(t.yOffset||0)}else i=t.x1,a=t.y1;Zh(e,e,[i,a]),$h(e,e,[t.w,t.h])}},{key:`_getAdjustedBB`,value:function(e,t,n,r){var i=e.x1,a=e.y1,o=e.w,s=e.h,c=e.yOffset;t&&(i-=t,a-=t,o+=2*t,s+=2*t);var l=0,u=o*r;return n&&r<1?o=u:!n&&r<1&&(l=o-u,i+=l,o=u),{x1:i,y1:a,w:o,h:s,xOffset:l,yOffset:c}}},{key:`drawPickingRectangle`,value:function(e,t,n){var r=this.atlasManager.getRenderTypeOpts(n),i=this.instanceCount;this.vertTypeBuffer.getView(i)[0]=gg,Lh(t,this.indexBuffer.getView(i)),Ih([0,0,0],1,this.colorBuffer.getView(i));var a=this.transformBuffer.getMatrixView(i);this.setTransformMatrix(e,a,r),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}},{key:`drawNode`,value:function(e,t,n){var r=this.simpleShapeOptions.get(n);if(this._isVisible(e,r)){var i=r.shapeProps,a=this._getVertTypeForShape(e,i.shape);if(a===void 0||r.isSimple&&!r.isSimple(e,this.renderTarget))this.drawTexture(e,t,n);else{var o=this.instanceCount;if(this.vertTypeBuffer.getView(o)[0]=a,a===_g||a===vg){var s=r.getBoundingBox(e),c=this._getCornerRadius(e,i.radius,s),l=this.cornerRadiusBuffer.getView(o);l[0]=c,l[1]=c,l[2]=c,l[3]=c,a===vg&&(l[0]=0,l[2]=0)}Lh(t,this.indexBuffer.getView(o));var u=this.renderTarget.picking?1:n===`node-body`?e.effectiveOpacity():1,d=this.renderTarget.picking?1:e.pstyle(i.opacity).value*u,f=e.pstyle(i.color).value;Ih(f,d,this.colorBuffer.getView(o));var p=this.lineWidthBuffer.getView(o);if(p[0]=0,p[1]=0,i.border){var m=e.pstyle(`border-width`).value;if(m>0){var h=e.pstyle(`border-color`).value;Ih(h,u*e.pstyle(`border-opacity`).value,this.borderColorBuffer.getView(o));var g=e.pstyle(`border-position`).value;if(g===`inside`)p[0]=0,p[1]=-m;else if(g===`outside`)p[0]=m,p[1]=0;else{var _=m/2;p[0]=_,p[1]=-_}}}var v=this.transformBuffer.getMatrixView(o);this.setTransformMatrix(e,v,r),this.simpleCount++,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}},{key:`_getVertTypeForShape`,value:function(e,t){switch(e.pstyle(t).value){case`rectangle`:return gg;case`ellipse`:return yg;case`roundrectangle`:case`round-rectangle`:return _g;case`bottom-round-rectangle`:return vg;default:return}}},{key:`_getCornerRadius`,value:function(e,t,n){var r=n.w,i=n.h;if(e.pstyle(t).value===`auto`)return Mi(r,i);var a=e.pstyle(t).pfValue,o=r/2,s=i/2;return Math.min(a,s,o)}},{key:`drawEdgeArrow`,value:function(e,t,n){if(e.visible()){var r=e._private.rscratch,i,a,o;if(n===`source`?(i=r.arrowStartX,a=r.arrowStartY,o=r.srcArrowAngle):(i=r.arrowEndX,a=r.arrowEndY,o=r.tgtArrowAngle),!(isNaN(i)||i==null||isNaN(a)||a==null||isNaN(o)||o==null)&&e.pstyle(n+`-arrow-shape`).value!==`none`){var s=e.pstyle(n+`-arrow-color`).value,c=e.pstyle(`opacity`).value*e.pstyle(`line-opacity`).value,l=e.pstyle(`width`).pfValue,u=uf(e,n),d=this.r.getArrowWidth(l,u),f=this.instanceCount,p=this.transformBuffer.getMatrixView(f);Yh(p),Zh(p,p,[i,a]),$h(p,p,[d,d]),Qh(p,p,o),this.vertTypeBuffer.getView(f)[0]=hg,Lh(t,this.indexBuffer.getView(f)),Ih(s,c,this.colorBuffer.getView(f)),this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}},{key:`drawEdgeLine`,value:function(e,t){if(e.visible()){var n=this._getEdgePoints(e);if(n){var r=e.pstyle(`opacity`).value,i=e.pstyle(`line-opacity`).value,a=e.pstyle(`width`).pfValue,o=e.pstyle(`line-color`).value,s=r*i;if(n.length/2+this.instanceCount>this.maxInstances&&this.endBatch(),n.length==4){var c=this.instanceCount;this.vertTypeBuffer.getView(c)[0]=pg,Lh(t,this.indexBuffer.getView(c)),Ih(o,s,this.colorBuffer.getView(c));var l=this.lineWidthBuffer.getView(c);l[0]=a;var u=this.pointAPointBBuffer.getView(c);u[0]=n[0],u[1]=n[1],u[2]=n[2],u[3]=n[3],this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}else for(var d=0;d<n.length-2;d+=2){var f=this.instanceCount;this.vertTypeBuffer.getView(f)[0]=mg,Lh(t,this.indexBuffer.getView(f)),Ih(o,s,this.colorBuffer.getView(f));var p=this.lineWidthBuffer.getView(f);p[0]=a;var m=n[d-2],h=n[d-1],g=n[d],_=n[d+1],v=n[d+2],y=n[d+3],b=n[d+4],x=n[d+5];d==0&&(m=2*g-v+.001,h=2*_-y+.001),d==n.length-4&&(b=2*v-g+.001,x=2*y-_+.001);var S=this.pointAPointBBuffer.getView(f);S[0]=m,S[1]=h,S[2]=g,S[3]=_;var C=this.pointCPointDBuffer.getView(f);C[0]=v,C[1]=y,C[2]=b,C[3]=x,this.instanceCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}},{key:`_isValidEdge`,value:function(e){var t=e._private.rscratch;return!(t.badLine||t.allpts==null||isNaN(t.allpts[0]))}},{key:`_getEdgePoints`,value:function(e){var t=e._private.rscratch;if(this._isValidEdge(e)){var n=t.allpts;if(n.length==4)return n;var r=this._getNumSegments(e);return this._getCurveSegmentPoints(n,r)}}},{key:`_getNumSegments`,value:function(e){return Math.min(15,this.maxInstances)}},{key:`_getCurveSegmentPoints`,value:function(e,t){if(e.length==4)return e;for(var n=Array((t+1)*2),r=0;r<=t;r++)if(r==0)n[0]=e[0],n[1]=e[1];else if(r==t)n[r*2]=e[e.length-2],n[r*2+1]=e[e.length-1];else{var i=r/t;this._setCurvePoint(e,i,n,r*2)}return n}},{key:`_setCurvePoint`,value:function(e,t,n,r){if(e.length<=2)n[r]=e[0],n[r+1]=e[1];else{for(var i=Array(e.length-2),a=0;a<i.length;a+=2){var o=(1-t)*e[a]+t*e[a+2],s=(1-t)*e[a+1]+t*e[a+3];i[a]=o,i[a+1]=s}return this._setCurvePoint(i,t,n,r)}}},{key:`endBatch`,value:function(){var e=this.gl,t=this.vao,n=this.vertexCount,r=this.instanceCount;if(r!==0){var i=this.renderTarget.picking?this.pickingProgram:this.program;e.useProgram(i),e.bindVertexArray(t);var a=ue(this.buffers),o;try{for(a.s();!(o=a.n()).done;)o.value.bufferSubData(r)}catch(e){a.e(e)}finally{a.f()}for(var s=this.batchManager.getAtlases(),c=0;c<s.length;c++)s[c].bufferIfNeeded(e);for(var l=0;l<s.length;l++)e.activeTexture(e.TEXTURE0+l),e.bindTexture(e.TEXTURE_2D,s[l].texture),e.uniform1i(i.uTextures[l],l);e.uniform1f(i.uZoom,Mh(this.r)),e.uniformMatrix3fv(i.uPanZoomMatrix,!1,this.panZoomMatrix),e.uniform1i(i.uAtlasSize,this.batchManager.getAtlasSize());var u=Ih(this.bgColor,1);e.uniform4fv(i.uBGColor,u),e.drawArraysInstanced(e.TRIANGLES,0,n,r),e.bindVertexArray(null),e.bindTexture(e.TEXTURE_2D,null),this.debug&&this.batchDebugInfo.push({count:r,atlasCount:s.length}),this.startBatch()}}},{key:`getDebugInfo`,value:function(){var e=this.atlasManager.getDebugInfo(),t=e.reduce(function(e,t){return e+t.atlasCount},0),n=this.batchDebugInfo,r=n.reduce(function(e,t){return e+t.count},0);return{atlasInfo:e,totalAtlases:t,wrappedCount:this.wrappedCount,simpleCount:this.simpleCount,batchCount:n.length,batchInfo:n,totalInstances:r}}}])}(),xg={};xg.initWebgl=function(e,t){var n=this,r=n.data.contexts[n.WEBGL];e.bgColor=Sg(n),e.webglTexSize=Math.min(e.webglTexSize,r.getParameter(r.MAX_TEXTURE_SIZE)),e.webglTexRows=Math.min(e.webglTexRows,54),e.webglTexRowsNodes=Math.min(e.webglTexRowsNodes,54),e.webglBatchSize=Math.min(e.webglBatchSize,16384),e.webglTexPerBatch=Math.min(e.webglTexPerBatch,r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS)),n.webglDebug=e.webglDebug,n.webglDebugShowAtlases=e.webglDebugShowAtlases,n.pickingFrameBuffer=Kh(r),n.pickingFrameBuffer.needsDraw=!0,n.drawing=new bg(n,r,e);var i=function(e){return function(t){return n.getTextAngle(t,e)}},a=function(e){return function(t){var n=t.pstyle(e);return n&&n.value}},o=function(e){return function(t){return t.pstyle(`${e}-opacity`).value>0}},s=function(e){return e.pstyle(`text-events`).strValue===`yes`?dg.USE_BB:dg.IGNORE},c=function(e){var t=e.position(),n=t.x,r=t.y,i=e.outerWidth(),a=e.outerHeight();return{w:i,h:a,x1:n-i/2,y1:r-a/2}};n.drawing.addAtlasCollection(`node`,{texRows:e.webglTexRowsNodes}),n.drawing.addAtlasCollection(`label`,{texRows:e.webglTexRows}),n.drawing.addTextureAtlasRenderType(`node-body`,{collection:`node`,getKey:t.getStyleKey,getBoundingBox:t.getElementBox,drawElement:t.drawElement}),n.drawing.addSimpleShapeRenderType(`node-body`,{getBoundingBox:c,isSimple:Ph,shapeProps:{shape:`shape`,color:`background-color`,opacity:`background-opacity`,radius:`corner-radius`,border:!0}}),n.drawing.addSimpleShapeRenderType(`node-overlay`,{getBoundingBox:c,isVisible:o(`overlay`),shapeProps:{shape:`overlay-shape`,color:`overlay-color`,opacity:`overlay-opacity`,padding:`overlay-padding`,radius:`overlay-corner-radius`}}),n.drawing.addSimpleShapeRenderType(`node-underlay`,{getBoundingBox:c,isVisible:o(`underlay`),shapeProps:{shape:`underlay-shape`,color:`underlay-color`,opacity:`underlay-opacity`,padding:`underlay-padding`,radius:`underlay-corner-radius`}}),n.drawing.addTextureAtlasRenderType(`label`,{collection:`label`,getTexPickingMode:s,getKey:wg(t.getLabelKey,null),getBoundingBox:Tg(t.getLabelBox,null),drawClipped:!0,drawElement:t.drawLabel,getRotation:i(null),getRotationPoint:t.getLabelRotationPoint,getRotationOffset:t.getLabelRotationOffset,isVisible:a(`label`)}),n.drawing.addTextureAtlasRenderType(`edge-source-label`,{collection:`label`,getTexPickingMode:s,getKey:wg(t.getSourceLabelKey,`source`),getBoundingBox:Tg(t.getSourceLabelBox,`source`),drawClipped:!0,drawElement:t.drawSourceLabel,getRotation:i(`source`),getRotationPoint:t.getSourceLabelRotationPoint,getRotationOffset:t.getSourceLabelRotationOffset,isVisible:a(`source-label`)}),n.drawing.addTextureAtlasRenderType(`edge-target-label`,{collection:`label`,getTexPickingMode:s,getKey:wg(t.getTargetLabelKey,`target`),getBoundingBox:Tg(t.getTargetLabelBox,`target`),drawClipped:!0,drawElement:t.drawTargetLabel,getRotation:i(`target`),getRotationPoint:t.getTargetLabelRotationPoint,getRotationOffset:t.getTargetLabelRotationOffset,isVisible:a(`target-label`)});var l=on(function(){console.log(`garbage collect flag set`),n.data.gc=!0},1e4);n.onUpdateEleCalcs(function(e,t){var r=!1;t&&t.length>0&&(r|=n.drawing.invalidate(t)),r&&l()}),Eg(n)};function Sg(e){var t=e.cy.container();return dt(t&&t.style&&t.style.backgroundColor||`white`)}function Cg(e,t){var n=e._private.rscratch;return Yn(n,`labelWrapCachedLines`,t)||[]}var wg=function(e,t){return function(n){var r=e(n),i=Cg(n,t);return i.length>1?i.map(function(e,t){return`${r}_${t}`}):r}},Tg=function(e,t){return function(n,r){var i=e(n);if(typeof r==`string`){var a=r.indexOf(`_`);if(a>0){var o=Number(r.substring(a+1)),s=Cg(n,t),c=i.h/s.length,l=c*o,u=i.y1+l;return{x1:i.x1,w:i.w,y1:u,h:c,yOffset:l}}}return i}};function Eg(e){var t=e.render;e.render=function(n){n||={};var r=e.cy;e.webgl&&(r.zoom()>vm?(Dg(e),t.call(e,n)):(Og(e),Lg(e,n,ug.SCREEN)))};var n=e.matchCanvasSize;e.matchCanvasSize=function(t){n.call(e,t),e.pickingFrameBuffer.setFramebufferAttachmentSizes(e.canvasWidth,e.canvasHeight),e.pickingFrameBuffer.needsDraw=!0},e.findNearestElements=function(t,n,r,i){return Fg(e,t,n)};var r=e.invalidateCachedZSortedEles;e.invalidateCachedZSortedEles=function(){r.call(e),e.pickingFrameBuffer.needsDraw=!0};var i=e.notify;e.notify=function(t,n){i.call(e,t,n),t===`viewport`||t===`bounds`?e.pickingFrameBuffer.needsDraw=!0:t===`background`&&e.drawing.invalidate(n,{type:`node-body`})}}function Dg(e){var t=e.data.contexts[e.WEBGL];t.clear(t.COLOR_BUFFER_BIT|t.DEPTH_BUFFER_BIT)}function Og(e){var t=function(t){t.save(),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,e.canvasWidth,e.canvasHeight),t.restore()};t(e.data.contexts[e.NODE]),t(e.data.contexts[e.DRAG])}function kg(e){var t=e.canvasWidth,n=e.canvasHeight,r=jh(e),i=r.pan,a=r.zoom,o=Jh();Zh(o,o,[i.x,i.y]),$h(o,o,[a,a]);var s=Jh();eg(s,t,n);var c=Jh();return Xh(c,s,o),c}function Ag(e,t){var n=e.canvasWidth,r=e.canvasHeight,i=jh(e),a=i.pan,o=i.zoom;t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,n,r),t.translate(a.x,a.y),t.scale(o,o)}function jg(e,t){e.drawSelectionRectangle(t,function(t){return Ag(e,t)})}function Mg(e){var t=e.data.contexts[e.NODE];t.save(),Ag(e,t),t.strokeStyle=`rgba(0, 0, 0, 0.3)`,t.beginPath(),t.moveTo(-1e3,0),t.lineTo(1e3,0),t.stroke(),t.beginPath(),t.moveTo(0,-1e3),t.lineTo(0,1e3),t.stroke(),t.restore()}function Ng(e){var t=function(t,n,r){for(var i=t.atlasManager.getAtlasCollection(n),a=e.data.contexts[e.NODE],o=i.atlases,s=0;s<o.length;s++){var c=o[s].canvas;if(c){var l=c.width,u=c.height,d=l*s,f=c.height*r,p=.4;a.save(),a.scale(p,p),a.drawImage(c,d,f),a.strokeStyle=`black`,a.rect(d,f,l,u),a.stroke(),a.restore()}}},n=0;t(e.drawing,`node`,n++),t(e.drawing,`label`,n++)}function Pg(e,t,n,r,i){var a,o,s,c,l=jh(e),u=l.pan,d=l.zoom,f=ge(Nh(e,u,d,t,n),2),p=f[0],m=f[1],h=6;if(a=p-h/2,o=m-h/2,s=h,c=h,s===0||c===0)return[];var g=e.data.contexts[e.WEBGL];g.bindFramebuffer(g.FRAMEBUFFER,e.pickingFrameBuffer),e.pickingFrameBuffer.needsDraw&&(g.viewport(0,0,g.canvas.width,g.canvas.height),Lg(e,null,ug.PICKING),e.pickingFrameBuffer.needsDraw=!1);var _=s*c,v=new Uint8Array(_*4);g.readPixels(a,o,s,c,g.RGBA,g.UNSIGNED_BYTE,v),g.bindFramebuffer(g.FRAMEBUFFER,null);for(var y=new Set,b=0;b<_;b++){var x=Rh(v.slice(b*4,b*4+4))-1;x>=0&&y.add(x)}return y}function Fg(e,t,n){var r=Pg(e,t,n),i=e.getCachedZSortedEles(),a,o,s=ue(r),c;try{for(s.s();!(c=s.n()).done;){var l=i[c.value];if(!a&&l.isNode()&&(a=l),!o&&l.isEdge()&&(o=l),a&&o)break}}catch(e){s.e(e)}finally{s.f()}return[a,o].filter(Boolean)}function Ig(e,t,n){var r=e.drawing;t+=1,n.isNode()?(r.drawNode(n,t,`node-underlay`),r.drawNode(n,t,`node-body`),r.drawTexture(n,t,`label`),r.drawNode(n,t,`node-overlay`)):(r.drawEdgeLine(n,t),r.drawEdgeArrow(n,t,`source`),r.drawEdgeArrow(n,t,`target`),r.drawTexture(n,t,`label`),r.drawTexture(n,t,`edge-source-label`),r.drawTexture(n,t,`edge-target-label`))}function Lg(e,t,n){var r;e.webglDebug&&(r=performance.now());var i=e.drawing,a=0;if(n.screen&&e.data.canvasNeedsRedraw[e.SELECT_BOX]&&jg(e,t),e.data.canvasNeedsRedraw[e.NODE]||n.picking){var o=e.data.contexts[e.WEBGL];n.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=kg(e),c=e.getCachedZSortedEles();if(a=c.length,i.startFrame(s,n),n.screen){for(var l=0;l<c.nondrag.length;l++)Ig(e,l,c.nondrag[l]);for(var u=0;u<c.drag.length;u++)Ig(e,u,c.drag[u])}else if(n.picking)for(var d=0;d<c.length;d++)Ig(e,d,c[d]);i.endFrame(),n.screen&&e.webglDebugShowAtlases&&(Mg(e),Ng(e)),n.screen&&(e.data.canvasNeedsRedraw[e.NODE]=!1,e.data.canvasNeedsRedraw[e.DRAG]=!1)}if(e.webglDebug){var f=performance.now(),p=Math.ceil(f-r),m=i.getDebugInfo(),h=[`${a} elements`,`${m.totalInstances} instances`,`${m.batchCount} batches`,`${m.totalAtlases} atlases`,`${m.wrappedCount} wrapped textures`,`${m.simpleCount} simple shapes`].join(`, `);console.log(`WebGL (${n.name}) - frame time ${p}ms`),console.log(`Totals:`),console.log(` ${h}`),console.log(`Texture Atlases Used:`);var g=m.atlasInfo,_=ue(g),v;try{for(_.s();!(v=_.n()).done;){var y=v.value;console.log(` ${y.type}: ${y.keyCount} keys, ${y.atlasCount} atlases`)}}catch(e){_.e(e)}finally{_.f()}console.log(``)}e.data.gc&&(console.log(`Garbage Collect!`),e.data.gc=!1,i.gc())}var Rg={};Rg.drawPolygonPath=function(e,t,n,r,i,a){var o=r/2,s=i/2;e.beginPath&&e.beginPath(),e.moveTo(t+o*a[0],n+s*a[1]);for(var c=1;c<a.length/2;c++)e.lineTo(t+o*a[c*2],n+s*a[c*2+1]);e.closePath()},Rg.drawRoundPolygonPath=function(e,t,n,r,i,a,o){o.forEach(function(t){return Ip(e,t)}),e.closePath()},Rg.drawRoundRectanglePath=function(e,t,n,r,i,a){var o=r/2,s=i/2,c=a===`auto`?Mi(r,i):Math.min(a,s,o);e.beginPath&&e.beginPath(),e.moveTo(t,n-s),e.arcTo(t+o,n-s,t+o,n,c),e.arcTo(t+o,n+s,t,n+s,c),e.arcTo(t-o,n+s,t-o,n,c),e.arcTo(t-o,n-s,t,n-s,c),e.lineTo(t,n-s),e.closePath()},Rg.drawBottomRoundRectanglePath=function(e,t,n,r,i,a){var o=r/2,s=i/2,c=a===`auto`?Mi(r,i):a;e.beginPath&&e.beginPath(),e.moveTo(t,n-s),e.lineTo(t+o,n-s),e.lineTo(t+o,n),e.arcTo(t+o,n+s,t,n+s,c),e.arcTo(t-o,n+s,t-o,n,c),e.lineTo(t-o,n-s),e.lineTo(t,n-s),e.closePath()},Rg.drawCutRectanglePath=function(e,t,n,r,i,a,o){var s=r/2,c=i/2,l=o===`auto`?Pi():o;e.beginPath&&e.beginPath(),e.moveTo(t-s+l,n-c),e.lineTo(t+s-l,n-c),e.lineTo(t+s,n-c+l),e.lineTo(t+s,n+c-l),e.lineTo(t+s-l,n+c),e.lineTo(t-s+l,n+c),e.lineTo(t-s,n+c-l),e.lineTo(t-s,n-c+l),e.closePath()},Rg.drawBarrelPath=function(e,t,n,r,i){var a=r/2,o=i/2,s=t-a,c=t+a,l=n-o,u=n+o,d=Ii(r,i),f=d.widthOffset,p=d.heightOffset,m=d.ctrlPtOffsetPct*f;e.beginPath&&e.beginPath(),e.moveTo(s,l+p),e.lineTo(s,u-p),e.quadraticCurveTo(s+m,u,s+f,u),e.lineTo(c-f,u),e.quadraticCurveTo(c-m,u,c,u-p),e.lineTo(c,l+p),e.quadraticCurveTo(c-m,l,c-f,l),e.lineTo(s+f,l),e.quadraticCurveTo(s+m,l,s,l+p),e.closePath()};for(var zg=Math.sin(0),Bg=Math.cos(0),Vg={},Hg={},Ug=Math.PI/40,Wg=0*Math.PI;Wg<2*Math.PI;Wg+=Ug)Vg[Wg]=Math.sin(Wg),Hg[Wg]=Math.cos(Wg);Rg.drawEllipsePath=function(e,t,n,r,i){if(e.beginPath&&e.beginPath(),e.ellipse)e.ellipse(t,n,r/2,i/2,0,0,2*Math.PI);else for(var a,o,s=r/2,c=i/2,l=0*Math.PI;l<2*Math.PI;l+=Ug)a=t-s*Vg[l]*zg+s*Hg[l]*Bg,o=n+c*Hg[l]*zg+c*Vg[l]*Bg,l===0?e.moveTo(a,o):e.lineTo(a,o);e.closePath()};var Gg={};Gg.createBuffer=function(e,t){var n=document.createElement(`canvas`);return n.width=e,n.height=t,[n,n.getContext(`2d`)]},Gg.bufferCanvasImage=function(e){var t=this.cy,n=t.mutableElements().boundingBox(),r=this.findContainerClientCoords(),i=e.full?Math.ceil(n.w):r[2],a=e.full?Math.ceil(n.h):r[3],o=X(e.maxWidth)||X(e.maxHeight),s=this.getPixelRatio(),c=1;if(e.scale!==void 0)i*=e.scale,a*=e.scale,c=e.scale;else if(o){var l=1/0,u=1/0;X(e.maxWidth)&&(l=c*e.maxWidth/i),X(e.maxHeight)&&(u=c*e.maxHeight/a),c=Math.min(l,u),i*=c,a*=c}o||(i*=s,a*=s,c*=s);var d=document.createElement(`canvas`);d.width=i,d.height=a,d.style.width=i+`px`,d.style.height=a+`px`;var f=d.getContext(`2d`);if(i>0&&a>0){f.clearRect(0,0,i,a),f.globalCompositeOperation=`source-over`;var p=this.getCachedZSortedEles();if(e.full)f.translate(-n.x1*c,-n.y1*c),f.scale(c,c),this.drawElements(f,p);else{var m=t.pan(),h={x:m.x*c,y:m.y*c};c*=t.zoom(),f.translate(h.x,h.y),f.scale(c,c),this.drawElements(f,p)}f.setTransform(1,0,0,1,0,0),e.bg&&(f.globalCompositeOperation=`destination-over`,f.fillStyle=e.bg,f.fillRect(0,0,i,a))}return d};function Kg(e,t){for(var n=atob(e),r=new ArrayBuffer(n.length),i=new Uint8Array(r),a=0;a<n.length;a++)i[a]=n.charCodeAt(a);return new Blob([r],{type:t})}function qg(e){var t=e.indexOf(`,`);return e.substr(t+1)}function Jg(e,t,n){var r=function(){return t.toDataURL(n,e.quality)};switch(e.output){case`blob-promise`:return new vo(function(r,i){try{t.toBlob(function(e){e==null?i(Error("`canvas.toBlob()` sent a null value in its callback")):r(e)},n,e.quality)}catch(e){i(e)}});case`blob`:return Kg(qg(r()),n);case`base64`:return qg(r());default:return r()}}Gg.png=function(e){return Jg(e,this.bufferCanvasImage(e),`image/png`)},Gg.jpg=function(e){return Jg(e,this.bufferCanvasImage(e),`image/jpeg`)};var Yg={};Yg.nodeShapeImpl=function(e,t,n,r,i,a,o,s){switch(e){case`ellipse`:return this.drawEllipsePath(t,n,r,i,a);case`polygon`:return this.drawPolygonPath(t,n,r,i,a,o);case`round-polygon`:return this.drawRoundPolygonPath(t,n,r,i,a,o,s);case`roundrectangle`:case`round-rectangle`:return this.drawRoundRectanglePath(t,n,r,i,a,s);case`cutrectangle`:case`cut-rectangle`:return this.drawCutRectanglePath(t,n,r,i,a,o,s);case`bottomroundrectangle`:case`bottom-round-rectangle`:return this.drawBottomRoundRectanglePath(t,n,r,i,a,s);case`barrel`:return this.drawBarrelPath(t,n,r,i,a)}};var Xg=Zg,$=Zg.prototype;$.CANVAS_LAYERS=3,$.SELECT_BOX=0,$.DRAG=1,$.NODE=2,$.WEBGL=3,$.CANVAS_TYPES=[`2d`,`2d`,`2d`,`webgl2`],$.BUFFER_COUNT=3,$.TEXTURE_BUFFER=0,$.MOTIONBLUR_BUFFER_NODE=1,$.MOTIONBLUR_BUFFER_DRAG=2;function Zg(e){var t=this,n=t.cy.window().document;e.webgl&&($.CANVAS_LAYERS=t.CANVAS_LAYERS=4,console.log(`webgl rendering enabled`)),t.data={canvases:Array($.CANVAS_LAYERS),contexts:Array($.CANVAS_LAYERS),canvasNeedsRedraw:Array($.CANVAS_LAYERS),bufferCanvases:Array($.BUFFER_COUNT),bufferContexts:Array($.CANVAS_LAYERS)};var r=`-webkit-tap-highlight-color`,i=`rgba(0,0,0,0)`;t.data.canvasContainer=n.createElement(`div`);var a=t.data.canvasContainer.style;t.data.canvasContainer.style[r]=i,a.position=`relative`,a.zIndex=`0`,a.overflow=`hidden`;var o=e.cy.container();o.appendChild(t.data.canvasContainer),o.style[r]=i;var s={"-webkit-user-select":`none`,"-moz-user-select":`-moz-none`,"user-select":`none`,"-webkit-tap-highlight-color":`rgba(0,0,0,0)`,"outline-style":`none`};Ge()&&(s[`-ms-touch-action`]=`none`,s[`touch-action`]=`none`);for(var c=0;c<$.CANVAS_LAYERS;c++){var l=t.data.canvases[c]=n.createElement(`canvas`),u=$.CANVAS_TYPES[c];t.data.contexts[c]=l.getContext(u),t.data.contexts[c]||In(`Could not create canvas of type `+u),Object.keys(s).forEach(function(e){l.style[e]=s[e]}),l.style.position=`absolute`,l.setAttribute(`data-id`,`layer`+c),l.style.zIndex=String($.CANVAS_LAYERS-c),t.data.canvasContainer.appendChild(l),t.data.canvasNeedsRedraw[c]=!1}t.data.topCanvas=t.data.canvases[0],t.data.canvases[$.NODE].setAttribute(`data-id`,`layer`+$.NODE+`-node`),t.data.canvases[$.SELECT_BOX].setAttribute(`data-id`,`layer`+$.SELECT_BOX+`-selectbox`),t.data.canvases[$.DRAG].setAttribute(`data-id`,`layer`+$.DRAG+`-drag`),t.data.canvases[$.WEBGL]&&t.data.canvases[$.WEBGL].setAttribute(`data-id`,`layer`+$.WEBGL+`-webgl`);for(var c=0;c<$.BUFFER_COUNT;c++)t.data.bufferCanvases[c]=n.createElement(`canvas`),t.data.bufferContexts[c]=t.data.bufferCanvases[c].getContext(`2d`),t.data.bufferCanvases[c].style.position=`absolute`,t.data.bufferCanvases[c].setAttribute(`data-id`,`buffer`+c),t.data.bufferCanvases[c].style.zIndex=String(-c-1),t.data.bufferCanvases[c].style.visibility=`hidden`;t.pathsEnabled=!0;var d=qr(),f=function(e){return{x:(e.x1+e.x2)/2,y:(e.y1+e.y2)/2}},p=function(e){return{x:-e.w/2,y:-e.h/2}},m=function(e){var t=e[0]._private;return t.oldBackgroundTimestamp!==t.backgroundTimestamp},h=function(e){return e[0]._private.nodeKey},g=function(e){return e[0]._private.labelStyleKey},_=function(e){return e[0]._private.sourceLabelStyleKey},v=function(e){return e[0]._private.targetLabelStyleKey},y=function(e,n,r,i,a){return t.drawElement(e,n,r,!1,!1,a)},b=function(e,n,r,i,a){return t.drawElementText(e,n,r,i,`main`,a)},x=function(e,n,r,i,a){return t.drawElementText(e,n,r,i,`source`,a)},S=function(e,n,r,i,a){return t.drawElementText(e,n,r,i,`target`,a)},C=function(e){return e.boundingBox(),e[0]._private.bodyBounds},w=function(e){return e.boundingBox(),e[0]._private.labelBounds.main||d},T=function(e){return e.boundingBox(),e[0]._private.labelBounds.source||d},E=function(e){return e.boundingBox(),e[0]._private.labelBounds.target||d},D=function(e,t){return t},O=function(e){return f(C(e))},k=function(e,t,n){var r=e?e+`-`:``;return{x:t.x+n.pstyle(r+`text-margin-x`).pfValue,y:t.y+n.pstyle(r+`text-margin-y`).pfValue}},A=function(e,t,n){var r=e[0]._private.rscratch;return{x:r[t],y:r[n]}},j=function(e){return k(``,A(e,`labelX`,`labelY`),e)},M=function(e){return k(`source`,A(e,`sourceLabelX`,`sourceLabelY`),e)},N=function(e){return k(`target`,A(e,`targetLabelX`,`targetLabelY`),e)},P=function(e){return p(C(e))},F=function(e){return p(T(e))},I=function(e){return p(E(e))},L=function(e){var t=w(e),n=p(w(e));if(e.isNode()){switch(su(e.pstyle(`text-halign`).value)){case`left`:n.x=-t.w-(t.leftPad||0);break;case`right`:n.x=-(t.rightPad||0)}switch(cu(e.pstyle(`text-valign`).value)){case`top`:n.y=-t.h-(t.topPad||0);break;case`bottom`:n.y=-(t.botPad||0)}}return n},R=t.data.eleTxrCache=new Pm(t,{getKey:h,doesEleInvalidateKey:m,drawElement:y,getBoundingBox:C,getRotationPoint:O,getRotationOffset:P,allowEdgeTxrCaching:!1,allowParentTxrCaching:!1}),z=t.data.lblTxrCache=new Pm(t,{getKey:g,drawElement:b,getBoundingBox:w,getRotationPoint:j,getRotationOffset:L,isVisible:D}),B=t.data.slbTxrCache=new Pm(t,{getKey:_,drawElement:x,getBoundingBox:T,getRotationPoint:M,getRotationOffset:F,isVisible:D}),V=t.data.tlbTxrCache=new Pm(t,{getKey:v,drawElement:S,getBoundingBox:E,getRotationPoint:N,getRotationOffset:I,isVisible:D}),H=t.data.lyrTxrCache=new Zm(t);t.onUpdateEleCalcs(function(e,t){R.invalidateElements(t),z.invalidateElements(t),B.invalidateElements(t),V.invalidateElements(t),H.invalidateElements(t);for(var n=0;n<t.length;n++){var r=t[n]._private;r.oldBackgroundTimestamp=r.backgroundTimestamp}});var U=function(e){for(var t=0;t<e.length;t++)H.enqueueElementRefinement(e[t].ele)};R.onDequeue(U),z.onDequeue(U),B.onDequeue(U),V.onDequeue(U),e.webgl&&t.initWebgl(e,{getStyleKey:h,getLabelKey:g,getSourceLabelKey:_,getTargetLabelKey:v,drawElement:y,drawLabel:b,drawSourceLabel:x,drawTargetLabel:S,getElementBox:C,getLabelBox:w,getSourceLabelBox:T,getTargetLabelBox:E,getElementRotationPoint:O,getElementRotationOffset:P,getLabelRotationPoint:j,getSourceLabelRotationPoint:M,getTargetLabelRotationPoint:N,getLabelRotationOffset:L,getSourceLabelRotationOffset:F,getTargetLabelRotationOffset:I})}$.redrawHint=function(e,t){var n=this;switch(e){case`eles`:n.data.canvasNeedsRedraw[$.NODE]=t;break;case`drag`:n.data.canvasNeedsRedraw[$.DRAG]=t;break;case`select`:n.data.canvasNeedsRedraw[$.SELECT_BOX]=t;break;case`gc`:n.data.gc=!0}};var Qg=typeof Path2D<`u`;$.path2dEnabled=function(e){if(e===void 0)return this.pathsEnabled;this.pathsEnabled=!!e},$.usePaths=function(){return Qg&&this.pathsEnabled},$.setImgSmoothing=function(e,t){e.imageSmoothingEnabled==null?(e.webkitImageSmoothingEnabled=t,e.mozImageSmoothingEnabled=t,e.msImageSmoothingEnabled=t):e.imageSmoothingEnabled=t},$.getImgSmoothing=function(e){return e.imageSmoothingEnabled==null?e.webkitImageSmoothingEnabled||e.mozImageSmoothingEnabled||e.msImageSmoothingEnabled:e.imageSmoothingEnabled},$.makeOffscreenCanvas=function(e,t){var n;return(typeof OffscreenCanvas>`u`?`undefined`:be(OffscreenCanvas))===`undefined`?(n=this.cy.window().document.createElement(`canvas`),n.width=e,n.height=t):n=new OffscreenCanvas(e,t),n},[th,ch,hh,_h,vh,xh,Ch,xg,Rg,Gg,Yg].forEach(function(e){Z($,e)});var $g=[{type:`layout`,extensions:sp},{type:`renderer`,extensions:[{name:`null`,impl:cp},{name:`base`,impl:lm},{name:`canvas`,impl:Xg}]}],e_={},t_={};function n_(e,t,n){var r=n,i=function(n){Rn("Can not register `"+t+"` for `"+e+"` since `"+n+"` already exists in the prototype and can not be overridden")};if(e===`core`){if(yf.prototype[t])return i(t);yf.prototype[t]=n}else if(e===`collection`){if(Od.prototype[t])return i(t);Od.prototype[t]=n}else if(e===`layout`){for(var a=function(e){this.options=e,n.call(this,e),je(this._private)||(this._private={}),this._private.cy=e.cy,this._private.listeners=[],this.createEmitter()},o=a.prototype=Object.create(n.prototype),s=[],c=0;c<s.length;c++){var l=s[c];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 u=n.prototype.stop;o.stop=function(){var e=this.options;if(e&&e.animate){var t=this.animations;if(t)for(var n=0;n<t.length;n++)t[n].stop()}return u?u.call(this):this.emit(`layoutstop`),this},o.destroy||=function(){return this},o.cy=function(){return this._private.cy};var d=function(e){return e._private.cy},f={addEventFields:function(e,t){t.layout=e,t.cy=d(e),t.target=e},bubble:function(){return!0},parent:function(e){return d(e)}};Z(o,{createEmitter:function(){return this._private.emitter=new Xu(f,this),this},emitter:function(){return this._private.emitter},on:function(e,t){return this.emitter().on(e,t),this},one:function(e,t){return this.emitter().one(e,t),this},once:function(e,t){return this.emitter().one(e,t),this},removeListener:function(e,t){return this.emitter().removeListener(e,t),this},removeAllListeners:function(){return this.emitter().removeAllListeners(),this},emit:function(e,t){return this.emitter().emit(e,t),this}}),vl.eventAliasesOn(o),r=a}else if(e===`renderer`&&t!==`null`&&t!==`base`){var p=r_(`renderer`,`base`),m=p.prototype,h=n,g=n.prototype,_=function(){p.apply(this,arguments),h.apply(this,arguments)},v=_.prototype;for(var y in m){var b=m[y];if(g[y]!=null)return i(y);v[y]=b}for(var x in g)v[x]=g[x];m.clientFunctions.forEach(function(e){v[e]=v[e]||function(){In("Renderer does not implement `renderer."+e+"()` on its prototype")}}),r=_}else if(e===`__proto__`||e===`constructor`||e===`prototype`)return In(e+` is an illegal type to be registered, possibly lead to prototype pollutions`);return pt({map:e_,keys:[e,t],value:r})}function r_(e,t){return mt({map:e_,keys:[e,t]})}function i_(e,t,n,r,i){return pt({map:t_,keys:[e,t,n,r],value:i})}function a_(e,t,n,r){return mt({map:t_,keys:[e,t,n,r]})}var o_=function(){if(arguments.length===2)return r_.apply(null,arguments);if(arguments.length===3)return n_.apply(null,arguments);if(arguments.length===4)return a_.apply(null,arguments);if(arguments.length===5)return i_.apply(null,arguments);In(`Invalid extension access syntax`)};yf.prototype.extension=o_,$g.forEach(function(e){e.extensions.forEach(function(t){n_(e.type,t.name,t.impl)})});var s_=function(){if(!(this instanceof s_))return new s_;this.length=0},c_=s_.prototype;c_.instanceString=function(){return`stylesheet`},c_.selector=function(e){var t=this.length++;return this[t]={selector:e,properties:[]},this},c_.css=function(e,t){var n=this.length-1;if(Y(e))this[n].properties.push({name:e,value:t});else if(je(e))for(var r=e,i=Object.keys(r),a=0;a<i.length;a++){var o=i[a],s=r[o];if(s!=null){var c=pf.properties[o]||pf.properties[Je(o)];if(c!=null){var l=c.name,u=s;this[n].properties.push({name:l,value:u})}}}return this},c_.style=c_.css,c_.generateStyle=function(e){var t=new pf(e);return this.appendToStyle(t)},c_.appendToStyle=function(e){for(var t=0;t<this.length;t++){var n=this[t],r=n.selector,i=n.properties;e.selector(r);for(var a=0;a<i.length;a++){var o=i[a];e.css(o.name,o.value)}}return e};var l_=`3.35.0`,u_=function(e){if(e===void 0&&(e={}),je(e))return new yf(e);if(Y(e))return o_.apply(o_,arguments)};u_.use=function(e){var t=Array.prototype.slice.call(arguments,1);return t.unshift(u_),e.apply(null,t),this},u_.warnings=function(e){return Ln(e)},u_.version=l_,u_.stylesheet=u_.Stylesheet=s_;function d_(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function f_(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=m_(e))||t){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
323
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function p_(e){"@babel/helpers - typeof";return p_=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},p_(e)}function m_(e,t){if(e){if(typeof e==`string`)return d_(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d_(e,t):void 0}}var h_={nodeSep:void 0,edgeSep:void 0,rankSep:void 0,rankDir:void 0,align:void 0,acyclicer:void 0,ranker:void 0,dagreOptions:void 0,minLen:function(e){return 1},edgeWeight:function(e){return 1},fit:!0,padding:30,spacingFactor:void 0,nodeDimensionsIncludeLabels:!1,useDagreEdgeControlPoints:!1,automaticDagreEdgeStyle:!1,dagreEdgeStyle:{"curve-style":`unbundled-bezier`,"control-point-weights":function(e){return e.scratch(`controlPointWeights`)},"control-point-distances":function(e){return e.scratch(`controlPointDistances`)},"edge-distances":`intersection`,"edge-ends-overlap":!1},animate:!1,animateFilter:function(e,t){return!0},animationDuration:500,animationEasing:void 0,boundingBox:void 0,transform:function(e,t){return t},ready:function(){},sort:void 0,stop:function(){}},g_=Object.assign==null?function(e){return[...arguments].slice(1).forEach(function(t){Object.keys(t).forEach(function(n){return e[n]=t[n]})}),e}:Object.assign.bind(Object),__=Object.defineProperty,v_=(e,t,n)=>t in e?__(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,y_=(e,t)=>{for(var n in t)__(e,n,{get:t[n],enumerable:!0})},b_=(e,t,n)=>v_(e,t+``,n),x_={};y_(x_,{Graph:()=>w_,alg:()=>I_,json:()=>j_,version:()=>A_});var S_=Object.defineProperty,C_=(e,t)=>{for(var n in t)S_(e,n,{get:t[n],enumerable:!0})},w_=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected=`directed`in e?e.directed:!0,this._isMultigraph=`multigraph`in e&&e.multigraph,this._isCompound=`compound`in e&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=typeof e==`function`?e:()=>e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(e=>{t===void 0?this.setNode(e):this.setNode(e,t)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(e=>{this.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=`\0`;else{t+=``;for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e===`\0`)return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t);for(let t of this.successors(e))n.add(t);return Array.from(n.values())}}isLeaf(e){let t;return t=this.isDirected()?this.successors(e):this.neighbors(e),t.length===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([n,r])=>{e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(e=>{t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,this.edge(e))});let n={},r=e=>{let i=this.parent(e);return!i||t.hasNode(i)?(n[e]=i??void 0,i??void 0):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,r(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=typeof e==`function`?e:()=>e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((e,n)=>(t===void 0?this.setEdge(e,n):this.setEdge(e,n,t),n)),this}setEdge(e,t,n,r){let i,a,o,s,c=!1;typeof e==`object`&&e&&`v`in e?(i=e.v,a=e.w,o=e.name,arguments.length===2&&(s=t,c=!0)):(i=e,a=t,o=r,arguments.length>2&&(s=n,c=!0)),i=``+i,a=``+a,o!==void 0&&(o=``+o);let l=D_(this._isDirected,i,a,o);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=s),this;if(o!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(i),this.setNode(a),this._edgeLabels[l]=c?s:this._defaultEdgeLabelFn(i,a,o);let u=O_(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,T_(this._preds[a],i),T_(this._sucs[i],a),this._in[a][l]=u,this._out[i][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?k_(this._isDirected,e):D_(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r==`object`?r:{label:r}}hasEdge(e,t,n){return(arguments.length===1?k_(this._isDirected,e):D_(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?k_(this._isDirected,e):D_(this._isDirected,e,t,n),i=this._edgeObjs[r];if(i){let e=i.v,t=i.w;delete this._edgeLabels[r],delete this._edgeObjs[r],E_(this._preds[t],e),E_(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(e=>e.v===t&&e.w===n||e.v===n&&e.w===t):r}};function T_(e,t){e[t]?e[t]++:e[t]=1}function E_(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function D_(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}return i+``+a+``+(r===void 0?`\0`:r)}function O_(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}let o={v:i,w:a};return r&&(o.name=r),o}function k_(e,t){return D_(e,t.v,t.w,t.name)}var A_=`4.0.1`,j_={};C_(j_,{read:()=>F_,write:()=>M_});function M_(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:N_(e),edges:P_(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function N_(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function P_(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function F_(e){let t=new w_(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(e=>{t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(e=>{t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}var I_={};C_(I_,{CycleException:()=>Z_,bellmanFord:()=>R_,components:()=>B_,dijkstra:()=>U_,dijkstraAll:()=>G_,findCycles:()=>q_,floydWarshall:()=>Y_,isAcyclic:()=>$_,postorder:()=>rv,preorder:()=>iv,prim:()=>av,shortestPaths:()=>ov,tarjan:()=>K_,topsort:()=>Q_});var L_=()=>1;function R_(e,t,n,r){return z_(e,String(t),n||L_,r||function(t){return e.outEdges(t)})}function z_(e,t,n,r){let i={},a,o=0,s=e.nodes(),c=function(e){let t=n(e);i[e.v].distance+t<i[e.w].distance&&(i[e.w]={distance:i[e.v].distance+t,predecessor:e.v},a=!0)},l=function(){s.forEach(function(e){r(e).forEach(function(t){let n=t.v===e?t.v:t.w,r=n===t.v?t.w:t.v;c({v:n,w:r})})})};s.forEach(function(e){i[e]={distance:e===t?0:1/0,predecessor:``}});let u=s.length;for(let e=1;e<u&&(a=!1,o++,l(),a);e++);if(o===u-1&&(a=!1,l(),a))throw Error(`The graph contains a negative weight cycle`);return i}function B_(e){let t={},n=[],r;function i(n){n in t||(t[n]=!0,r.push(n),e.successors(n).forEach(i),e.predecessors(n).forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}var V_=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let e=this._arr,i=e.length;return n[r]=i,e.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}},H_=()=>1;function U_(e,t,n,r){return W_(e,String(t),n||H_,r||function(t){return e.outEdges(t)})}function W_(e,t,n,r){let i={},a=new V_,o,s,c=function(e){let t=e.v===o?e.w:e.v,r=i[t],c=n(e),l=s.distance+c;if(c<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+c);l<r.distance&&(r.distance=l,r.predecessor=o,a.decrease(t,l))};for(e.nodes().forEach(function(e){let n=e===t?0:1/0;i[e]={distance:n,predecessor:``},a.add(e,n)});a.size()>0&&(o=a.removeMin(),s=i[o],s.distance!==1/0);)r(o).forEach(c);return i}function G_(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=U_(e,i,t,n),r},{})}function K_(e){let t=0,n=[],r={},i=[];function a(o){let s=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),e.successors(o).forEach(function(e){e in r?r[e].onStack&&(s.lowlink=Math.min(s.lowlink,r[e].index)):(a(e),s.lowlink=Math.min(s.lowlink,r[e].lowlink))}),s.lowlink===s.index){let e=[],t;do t=n.pop(),r[t].onStack=!1,e.push(t);while(o!==t);i.push(e)}}return e.nodes().forEach(function(e){e in r||a(e)}),i}function q_(e){return K_(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var J_=()=>1;function Y_(e,t,n){return X_(e,t||J_,n||function(t){return e.outEdges(t)})}function X_(e,t,n){let r={},i=e.nodes();return i.forEach(function(e){r[e]={},r[e][e]={distance:0,predecessor:``},i.forEach(function(t){e!==t&&(r[e][t]={distance:1/0,predecessor:``})}),n(e).forEach(function(n){let i=n.v===e?n.w:n.v,a=t(n);r[e][i]={distance:a,predecessor:e}})}),i.forEach(function(e){let t=r[e];i.forEach(function(n){let a=r[n];i.forEach(function(n){let r=a[e],i=t[n],o=a[n],s=r.distance+i.distance;s<o.distance&&(o.distance=s,o.predecessor=i.predecessor)})})}),r}var Z_=class extends Error{constructor(...e){super(...e)}};function Q_(e){let t={},n={},r=[];function i(a){if(a in n)throw new Z_;a in t||(n[a]=!0,t[a]=!0,e.predecessors(a).forEach(i),delete n[a],r.push(a))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new Z_;return r}function $_(e){try{Q_(e)}catch(e){if(e instanceof Z_)return!1;throw e}return!0}function ev(e,t,n,r,i){Array.isArray(t)||(t=[t]);let a=(t=>(e.isDirected()?e.successors(t):e.neighbors(t))??[]),o={};return t.forEach(function(t){if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);i=tv(e,t,n===`post`,o,a,r,i)}),i}function tv(e,t,n,r,i,a,o){return t in r||(r[t]=!0,n||(o=a(o,t)),i(t).forEach(function(t){o=tv(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function nv(e,t,n){return ev(e,t,n,function(e,t){return e.push(t),e},[])}function rv(e,t){return nv(e,t,`post`)}function iv(e,t){return nv(e,t,`pre`)}function av(e,t){let n=new w_,r={},i=new V_,a;function o(e){let n=e.v===a?e.w:e.v,o=i.priority(n);if(o!==void 0){let s=t(e);s<o&&(r[n]=a,i.decrease(n,s))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(e){i.add(e,1/0),n.setNode(e)}),i.decrease(e.nodes()[0],0);let s=!1;for(;i.size()>0;){if(a=i.removeMin(),a in r)n.setEdge(a,r[a]);else{if(s)throw Error(`Input graph is not connected: `+e);s=!0}e.nodeEdges(a).forEach(o)}return n}function ov(e,t,n,r){return sv(e,t,n,r??(t=>e.outEdges(t)??[]))}function sv(e,t,n,r){if(n===void 0)return U_(e,t,n,r);let i=!1,a=e.nodes();for(let o=0;o<a.length;o++){let s=r(a[o]);for(let e=0;e<s.length;e++){let t=s[e],r=t.v===a[o]?t.v:t.w;n({v:r,w:r===t.v?t.w:t.v})<0&&(i=!0)}if(i)return R_(e,t,n,r)}return U_(e,t,n,r)}function cv(e,t,n,r){let i=r;for(;e.hasNode(i);)i=wv(r);return n.dummy=t,e.setNode(i,n),i}function lv(e){let t=new w_().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function uv(e){let t=new w_({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function dv(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function fv(e){let t=Tv(yv(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][r.order]=n)}),t}function pv(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=vv(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function mv(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=vv(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function hv(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),cv(e,`border`,i,t)}function gv(e,t=_v){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var _v=65535;function vv(e,t){return t.length>_v?e(...gv(t).map(t=>e(...t))):e(...t)}function yv(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return vv(Math.max,t)}function bv(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function xv(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function Sv(e,t){return t()}var Cv=0;function wv(e){return e+(``+ ++Cv)}function Tv(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function Ev(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function Dv(e,t){let n;return n=typeof t==`string`?e=>e[t]:t,Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function Ov(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var kv=`\0`,Av=`3.0.0`,jv=class{constructor(){b_(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Mv(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Mv(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,Nv)),n=n._prev;return`[`+e.join(`, `)+`]`}};function Mv(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Nv(e,t){if(e!==`_next`&&e!==`_prev`)return t}var Pv=jv,Fv=()=>1;function Iv(e,t){if(e.nodeCount()<=1)return[];let n=zv(e,t||Fv);return Lv(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function Lv(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)Rv(e,t,n,o);for(;o=i.dequeue();)Rv(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i]?.dequeue(),o){r=r.concat(Rv(e,t,n,o,!0)||[]);break}}}return r}function Rv(e,t,n,r,i){let a=[],o=i?a:void 0;return(e.inEdges(r.v)||[]).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,Bv(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,Bv(t,n,o)}),e.removeNode(r.v),o}function zv(e,t){let n=new w_,r=0,i=0;e.nodes().forEach(e=>{n.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let a=n.edge(e.v,e.w)||0,o=t(e),s=a+o;n.setEdge(e.v,e.w,s);let c=n.node(e.v),l=n.node(e.w);i=Math.max(i,c.out+=o),r=Math.max(r,l.in+=o)});let a=Vv(i+r+3).map(()=>new Pv),o=r+1;return n.nodes().forEach(e=>{Bv(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function Bv(e,t,n){var r,i,a;n.out?n.in?(a=e[n.out-n.in+t])==null||a.enqueue(n):(i=e[e.length-1])==null||i.enqueue(n):(r=e[0])==null||r.enqueue(n)}function Vv(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function Hv(e){(e.graph().acyclicer===`greedy`?Iv(e,t(e)):Uv(e)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,wv(`rev`))});function t(e){return t=>e.edge(t).weight}}function Uv(e){let t=[],n={},r={};function i(a){Object.hasOwn(r,a)||(r[a]=!0,n[a]=!0,e.outEdges(a).forEach(e=>{Object.hasOwn(n,e.w)?t.push(e):i(e.w)}),delete n[a])}return e.nodes().forEach(i),t}function Wv(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function Gv(e){e.graph().dummyChains=[],e.edges().forEach(t=>Kv(e,t))}function Kv(e,t){let n=t.v,r=e.node(n).rank,i=t.w,a=e.node(i).rank,o=t.name,s=e.edge(t),c=s.labelRank;if(a===r+1)return;e.removeEdge(t);let l,u,d=0;for(++r;r<a;++d,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},l=cv(e,`edge`,u,`_d`),r===c&&(u.width=s.width,u.height=s.height,u.dummy=`edge-label`,u.labelpos=s.labelpos),e.setEdge(n,l,{weight:s.weight},o),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,i,{weight:s.weight},o)}function qv(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}function Jv(e){let t={};function n(r){let i=e.node(r);if(Object.hasOwn(t,r))return i.rank;t[r]=!0;let a=e.outEdges(r),o=a?a.map(t=>t==null?1/0:n(t.w)-e.edge(t).minlen):[],s=vv(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function Yv(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Xv=Zv;function Zv(e){let t=new w_({directed:!1}),n=e.nodes();if(n.length===0)throw Error(`Graph must have at least one node`);let r=n[0],i=e.nodeCount();t.setNode(r,{});let a,o;for(;Qv(t,e)<i&&(a=$v(t,e),a);)o=t.hasNode(a.v)?Yv(e,a):-Yv(e,a),ey(t,e,o);return t}function Qv(e,t){function n(r){let i=t.nodeEdges(r);i&&i.forEach(i=>{let a=i.v,o=r===a?i.w:a;!e.hasNode(o)&&!Yv(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function $v(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=Yv(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function ey(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:ty,postorder:ny}=I_,ry=iy;iy.initLowLimValues=cy,iy.initCutValues=ay,iy.calcCutValue=sy,iy.leaveEdge=uy,iy.enterEdge=dy,iy.exchangeEdges=fy;function iy(e){e=lv(e),Jv(e);let t=Xv(e);cy(t),ay(t,e);let n,r;for(;n=uy(t);)r=dy(t,e,n),fy(t,e,n,r)}function ay(e,t){let n=ny(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>oy(e,t,n))}function oy(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=sy(e,t,n)}function sy(e,t,n){let r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;a||=(i=!1,t.edge(r,n)),o=a.weight;let s=t.nodeEdges(n);return s&&s.forEach(a=>{let s=a.v===n,c=s?a.w:a.v;if(c!==r){let r=s===i,l=t.edge(a).weight;if(o+=r?l:-l,my(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function cy(e,t){arguments.length<2&&(t=e.nodes()[0]),ly(e,{},1,t)}function ly(e,t,n,r,i){let a=n,o=e.node(r);t[r]=!0;let s=e.neighbors(r);return s&&s.forEach(i=>{Object.hasOwn(t,i)||(n=ly(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function uy(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function dy(e,t,n){let r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);let a=e.node(r),o=e.node(i),s=a,c=!1;return a.lim>o.lim&&(s=o,c=!0),t.edges().filter(t=>c===hy(e,e.node(t.v),s)&&c!==hy(e,e.node(t.w),s)).reduce((e,n)=>Yv(t,n)<Yv(t,e)?n:e)}function fy(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),cy(e),ay(e,t),py(e,t)}function py(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=ty(e,[n]);r=r.slice(1),r.forEach(n=>{let r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function my(e,t,n){return e.hasEdge(t,n)}function hy(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var gy=_y;function _y(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:by(e);break;case`tight-tree`:yy(e);break;case`longest-path`:vy(e);break;case`none`:break;default:by(e)}}var vy=Jv;function yy(e){Jv(e),Xv(e)}function by(e){ry(e)}var xy=Sy;function Sy(e){let t=wy(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=Cy(e,t,i.v,i.w),o=a.path,s=a.lca,c=0,l=o[c],u=!0;for(;n!==i.w;){if(r=e.node(n),u){for(;(l=o[c])!==s&&e.node(l).maxRank<r.rank;)c++;l===s&&(u=!1)}if(!u){for(;c<o.length-1&&e.node(o[c+1]).minRank<=r.rank;)c++;l=o[c]}l!==void 0&&e.setParent(n,l),n=e.successors(n)[0]}})}function Cy(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)a.push(u);return{path:i.concat(a.reverse()),lca:l}}function wy(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children(kv).forEach(r),t}function Ty(e){let t=cv(e,`root`,{},`_root`),n=Dy(e),r=Object.values(n),i=vv(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=Oy(e)+1;e.children(kv).forEach(r=>Ey(e,t,a,o,i,n,r)),e.graph().nodeRankFactor=a}function Ey(e,t,n,r,i,a,o){let s=e.children(o);if(!s.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}let c=hv(e,`_bt`),l=hv(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{Ey(e,t,n,r,i,a,s);let u=e.node(s),d=u.borderTop?u.borderTop:s,f=u.borderBottom?u.borderBottom:s,p=u.borderTop?r:2*r,m=d===f?i-(a[o]??0)+1:1;e.setEdge(c,d,{weight:p,minlen:m,nestingEdge:!0}),e.setEdge(f,l,{weight:p,minlen:m,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,c,{weight:0,minlen:i+(a[o]??0)})}function Dy(e){let t={};function n(r,i){let a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children(kv).forEach(e=>n(e,1)),t}function Oy(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function ky(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var Ay=jy;function jy(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(i,`minRank`)){i.borderLeft=[],i.borderRight=[];for(let t=i.minRank,r=i.maxRank+1;t<r;++t)My(e,`borderLeft`,`_bl`,n,i,t),My(e,`borderRight`,`_br`,n,i,t)}}e.children(kv).forEach(t)}function My(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=cv(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function Ny(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&Fy(e)}function Py(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&Ly(e),(t===`lr`||t===`rl`)&&(zy(e),Fy(e))}function Fy(e){e.nodes().forEach(t=>Iy(e.node(t))),e.edges().forEach(t=>Iy(e.edge(t)))}function Iy(e){let t=e.width;e.width=e.height,e.height=t}function Ly(e){e.nodes().forEach(t=>Ry(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Ry),Object.hasOwn(r,`y`)&&Ry(r)})}function Ry(e){e.y=-e.y}function zy(e){e.nodes().forEach(t=>By(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(By),Object.hasOwn(r,`x`)&&By(r)})}function By(e){let t=e.x;e.x=e.y,e.y=t}function Vy(e){let t={},n=e.nodes().filter(t=>!e.children(t).length),r=n.map(t=>e.node(t).rank),i=Tv(vv(Math.max,r)+1).map(()=>[]);function a(n){if(t[n])return;t[n]=!0;let r=e.node(n);i[r.rank].push(n);let o=e.successors(n);o&&o.forEach(a)}return n.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(a),i}function Hy(e,t){let n=0;for(let r=1;r<t.length;++r)n+=Uy(e,t[r-1],t[r]);return n}function Uy(e,t,n){let r=Ov(n,n.map((e,t)=>t)),i=t.flatMap(t=>{let n=e.outEdges(t);return n?n.map(t=>({pos:r[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos):[]}),a=1;for(;a<n.length;)a<<=1;let o=2*a-1;--a;let s=Array(o).fill(0),c=0;return i.forEach(e=>{let t=e.pos+a;s[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=s[t+1]),t=t-1>>1,s[t]+=e.weight;c+=e.weight*n}),c}function Wy(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(!n||!n.length)return{v:t};{let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}})}function Gy(e,t){let n={};return e.forEach((e,t)=>{let r={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight),n[e.v]=r}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(r))}),Ky(Object.values(n).filter(e=>!e.indegree))}function Ky(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&qy(e,t)}}function r(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return t.filter(e=>!e.merged).map(e=>Ev(e,[`vs`,`i`,`barycenter`,`weight`]))}function qy(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function Jy(e,t){let n=bv(e,e=>Object.hasOwn(e,`barycenter`)),r=n.lhs,i=n.rhs.sort((e,t)=>t.i-e.i),a=[],o=0,s=0,c=0;r.sort(Xy(!!t)),c=Yy(a,i,c),r.forEach(e=>{c+=e.vs.length,a.push(e.vs),o+=e.barycenter*e.weight,s+=e.weight,c=Yy(a,i,c)});let l={vs:a.flat(1)};return s&&(l.barycenter=o/s,l.weight=s),l}function Yy(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function Xy(e){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}function Zy(e,t,n,r){let i=e.children(t),a=e.node(t),o=a?a.borderLeft:void 0,s=a?a.borderRight:void 0,c={};o&&(i=i.filter(e=>e!==o&&e!==s));let l=Wy(e,i);l.forEach(t=>{if(e.children(t.v).length){let i=Zy(e,t.v,n,r);c[t.v]=i,Object.hasOwn(i,`barycenter`)&&$y(t,i)}});let u=Gy(l,n);Qy(u,c);let d=Jy(u,r);if(o&&s){d.vs=[o,d.vs,s].flat(1);let t=e.predecessors(o);if(t&&t.length){let n=e.node(t[0]),r=e.predecessors(s),i=e.node(r[0]);Object.hasOwn(d,`barycenter`)||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+n.order+i.order)/(d.weight+2),d.weight+=2}}return d}function Qy(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function $y(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}function eb(e,t,n,r){r||=e.nodes();let i=tb(e),a=new w_({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t));return r.forEach(r=>{let o=e.node(r),s=e.parent(r);if(o.rank===t||o.minRank<=t&&t<=o.maxRank){a.setNode(r),a.setParent(r,s||i);let c=e[n](r);c&&c.forEach(t=>{let n=t.v===r?t.w:t.v,i=a.edge(n,r),o=i===void 0?0:i.weight;a.setEdge(n,r,{weight:e.edge(t).weight+o})}),Object.hasOwn(o,`minRank`)&&a.setNode(r,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]})}}),a}function tb(e){let t;for(;e.hasNode(t=wv(`_root`)););return t}function nb(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}function rb(e,t={}){if(typeof t.customOrder==`function`){t.customOrder(e,rb);return}let n=yv(e),r=ib(e,Tv(1,n+1),`inEdges`),i=ib(e,Tv(n-1,-1,-1),`outEdges`),a=Vy(e);if(ob(e,a),t.disableOptimalOrderHeuristic)return;let o=1/0,s,c=t.constraints||[];for(let t=0,n=0;n<4;++t,++n){ab(t%2?r:i,t%4>=2,c),a=fv(e);let l=Hy(e,a);l<o?(n=0,s=Object.assign({},a),o=l):l===o&&(s=structuredClone(a))}ob(e,s)}function ib(e,t,n){let r=new Map,i=(e,t)=>{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return eb(e,t,n,r.get(t)||[])})}function ab(e,t,n){let r=new w_;e.forEach(function(e){n.forEach(e=>r.setEdge(e.left,e.right));let i=e.graph().root,a=Zy(e,i,r,t);a.vs.forEach((t,n)=>e.node(t).order=n),nb(e,r,a.vs)})}function ob(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function sb(e,t){let n={};function r(t,r){let i=0,a=0,o=t.length,s=r[r.length-1];return r.forEach((t,c)=>{let l=lb(e,t),u=l?e.node(l).order:o;(l||t===s)&&(r.slice(a,c+1).forEach(t=>{let r=e.predecessors(t);r&&r.forEach(r=>{let a=e.node(r),o=a.order;(o<i||u<o)&&!(a.dummy&&e.node(t).dummy)&&ub(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function cb(e,t){let n={};function r(t,r,i,a,o){Tv(r,i).forEach(r=>{let i=t[r];if(i!==void 0&&e.node(i).dummy){let t=e.predecessors(i);t&&t.forEach(t=>{if(t===void 0)return;let r=e.node(t);r.dummy&&(r.order<a||r.order>o)&&ub(n,t,i)})}})}function i(t,n){let i=-1,a=-1,o=0;return n.forEach((s,c)=>{if(e.node(s).dummy===`border`){let t=e.predecessors(s);if(t&&t.length){let s=t[0];if(s===void 0)return;a=e.node(s).order,r(n,o,c,i,a),o=c,i=a}}r(n,o,n.length,a,t.length)}),n}return t.length&&t.reduce(i),n}function lb(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function ub(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function db(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function fb(e,t,n,r){let i={},a={},o={};return t.forEach(e=>{e.forEach((e,t)=>{i[e]=e,a[e]=e,o[e]=t})}),t.forEach(e=>{let t=-1;e.forEach(e=>{let s=r(e);if(s&&s.length){let r=s.sort((e,t)=>{let n=o[e],r=o[t];return(n===void 0?0:n)-(r===void 0?0:r)}),c=(r.length-1)/2;for(let s=Math.floor(c),l=Math.ceil(c);s<=l;++s){let c=r[s];if(c===void 0)continue;let l=o[c];if(l!==void 0&&a[e]===e&&t<l&&!db(n,e,c)){let n=i[c];n!==void 0&&(a[c]=e,a[e]=i[e]=n,t=l)}}}})}),{root:i,align:a}}function pb(e,t,n,r,i=!1){let a={},o=mb(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes().slice(),r={},i=n.pop();for(;i;){if(r[i])e(i);else{r[i]=!0,n.push(i);for(let e of t(i))n.push(e)}i=n.pop()}}function l(e){let t=o.inEdges(e);t?a[e]=t.reduce((e,t)=>{let n=a[t.v]??0,r=o.edge(t);return Math.max(e,n+(r===void 0?0:r))},0):a[e]=0}function u(t){let n=o.outEdges(t),r=1/0;n&&(r=n.reduce((e,t)=>{let n=a[t.w],r=o.edge(t);return Math.min(e,(n===void 0?0:n)-(r===void 0?0:r))},1/0));let i=e.node(t);r!==1/0&&i.borderType!==s&&(a[t]=Math.max(a[t]===void 0?0:a[t],r))}function d(e){return o.predecessors(e)||[]}function f(e){return o.successors(e)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(e=>{let t=n[e];t!==void 0&&(a[e]=a[t]??0)}),a}function mb(e,t,n,r){let i=new w_,a=e.graph(),o=yb(a.nodesep,a.edgesep,r);return t.forEach(t=>{let r;t.forEach(t=>{let a=n[t];if(a!==void 0){if(i.setNode(a),r!==void 0){let s=n[r];if(s!==void 0){let n=i.edge(s,a);i.setEdge(s,a,Math.max(o(e,t,r),n||0))}}r=t}})}),i}function hb(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=bb(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function gb(e,t){let n=Object.values(t),r=vv(Math.min,n),i=vv(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(a=>{let o=n+a,s=e[o];if(!s||s===t)return;let c=Object.values(s),l=r-vv(Math.min,c);a!==`l`&&(l=i-vv(Math.max,c)),l&&(e[o]=Dv(s,e=>e+l))})})}function _b(e,t=void 0){let n=e.ul;return n?Dv(n,(n,r)=>{if(t){let n=e[t.toLowerCase()];if(n&&n[r]!==void 0)return n[r]}let i=Object.values(e).map(e=>{let t=e[r];return t===void 0?0:t}).sort((e,t)=>e-t);return((i[1]??0)+(i[2]??0))/2}):{}}function vb(e){let t=fv(e),n=Object.assign(sb(e,t),cb(e,t)),r={},i;return[`u`,`d`].forEach(a=>{i=a===`u`?t:Object.values(t).reverse(),[`l`,`r`].forEach(t=>{t===`r`&&(i=i.map(e=>Object.values(e).reverse()));let o=fb(e,i,n,t=>(a===`u`?e.predecessors(t):e.successors(t))||[]),s=pb(e,i,o.root,o.align,t===`r`);t===`r`&&(s=Dv(s,e=>-e)),r[a+t]=s})}),gb(r,hb(e,r)),_b(r,e.graph().align)}function yb(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2}if(l&&(c+=n?l:-l),l=void 0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2}return l&&(c+=n?l:-l),c}}function bb(e,t){return e.node(t).width}function xb(e){e=uv(e),Sb(e),Object.entries(vb(e)).forEach(([t,n])=>e.node(t).x=n)}function Sb(e){let t=fv(e),n=e.graph(),r=n.ranksep,i=n.rankalign,a=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height??0;return t>r?t:r},0);t.forEach(t=>{let r=e.node(t);r.y=i===`top`?a+r.height/2:i===`bottom`?a+n-r.height/2:a+n/2}),a+=n+r})}function Cb(e,t={}){let n=t.debugTiming?xv:Sv;return n(`layout`,()=>{let r=n(` buildLayoutGraph`,()=>Pb(e));return n(` runLayout`,()=>wb(r,n,t)),n(` updateInputGraph`,()=>Tb(e,r)),r})}function wb(e,t,n){t(` makeSpaceForEdgeLabels`,()=>Fb(e)),t(` removeSelfEdges`,()=>Wb(e)),t(` acyclic`,()=>Hv(e)),t(` nestingGraph.run`,()=>Ty(e)),t(` rank`,()=>gy(uv(e))),t(` injectEdgeLabelProxies`,()=>Ib(e)),t(` removeEmptyRanks`,()=>mv(e)),t(` nestingGraph.cleanup`,()=>ky(e)),t(` normalizeRanks`,()=>pv(e)),t(` assignRankMinMax`,()=>Lb(e)),t(` removeEdgeLabelProxies`,()=>Rb(e)),t(` normalize.run`,()=>Gv(e)),t(` parentDummyChains`,()=>xy(e)),t(` addBorderSegments`,()=>Ay(e)),t(` order`,()=>rb(e,n)),t(` insertSelfEdges`,()=>Gb(e)),t(` adjustCoordinateSystem`,()=>Ny(e)),t(` position`,()=>xb(e)),t(` positionSelfEdges`,()=>Kb(e)),t(` removeBorderNodes`,()=>Ub(e)),t(` normalize.undo`,()=>qv(e)),t(` fixupEdgeLabelCoords`,()=>Vb(e)),t(` undoCoordinateSystem`,()=>Py(e)),t(` translateGraph`,()=>zb(e)),t(` assignNodeIntersects`,()=>Bb(e)),t(` reversePoints`,()=>Hb(e)),t(` acyclic.undo`,()=>Wv(e))}function Tb(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.order=i.order,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var Eb=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],Db={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},Ob=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],kb=[`width`,`height`,`rank`],Ab={width:0,height:0},jb=[`minlen`,`weight`,`width`,`height`,`labeloffset`],Mb={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},Nb=[`labelpos`];function Pb(e){let t=new w_({multigraph:!0,compound:!0}),n=Jb(e.graph());return t.setGraph(Object.assign({},Db,qb(n,Eb),Ev(n,Ob))),e.nodes().forEach(n=>{let r=qb(Jb(e.node(n)),kb);Object.keys(Ab).forEach(e=>{r[e]===void 0&&(r[e]=Ab[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=Jb(e.edge(n));t.setEdge(n,Object.assign({},Mb,qb(r,jb),Ev(r,Nb)))}),t}function Fb(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function Ib(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);cv(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function Lb(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function Rb(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`edge-proxy`){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function zb(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function Bb(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(dv(r,a)),n.points.push(dv(i,o))})}function Vb(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset}})}function Hb(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Ub(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function Wb(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function Gb(e){fv(e).forEach(t=>{let n=0;t.forEach((t,r)=>{let i=e.node(t);i.order=r+n,(i.selfEdges||[]).forEach(t=>{cv(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,label:t.label},`_se`)}),delete i.selfEdges})})}function Kb(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`selfedge`){let r=n,i=e.node(r.e.v),a=i.x+i.width/2,o=i.y,s=n.x-a,c=i.height/2;e.setEdge(r.e,r.label),e.removeNode(t),r.label.points=[{x:a+2*s/3,y:o-c},{x:a+5*s/6,y:o-c},{x:a+s,y:o},{x:a+5*s/6,y:o+c},{x:a+2*s/3,y:o+c}],r.label.x=n.x,r.label.y=n.y}})}function qb(e,t){return Dv(Ev(e,t),Number)}function Jb(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}function Yb(e){let t=fv(e),n=new w_({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{n.setNode(t,{label:t}),n.setParent(t,`layer`+e.node(t).rank)}),e.edges().forEach(e=>n.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{let r=`layer`+t;n.setNode(r,{rank:`same`}),e.reduce((e,t)=>(n.setEdge(e,t,{style:`invis`}),t))}),n}var Xb={graphlib:x_,version:Av,layout:Cb,debug:Yb,util:{time:xv,notime:Sv}},Zb=function(e){return typeof e==`function`},Qb=.001;function $b(e){if(e.isParent()){var t=e.children();if(t.length>0)return $b(t[0])}return e}function ex(e){this.options=g_({},h_,e)}function tx(e,t){return{x:ox(e.x-t.x),y:ox(e.y-t.y)}}function nx(e,t){return ox(e.x*t.x)+ox(e.y*t.y)}function rx(e){var t=Math.hypot(e.x,e.y)||1;return{x:e.x/t,y:e.y/t,len:t}}function ix(e){return{x:-e.y,y:e.x}}function ax(e,t){var n=rx(tx(t,e)),r=n.x,i=n.y,a=n.len,o={x:r,y:i};return{src:e,tgt:t,dir:o,normal:ix(o),len:a}}function ox(e){return Math.abs(e)<Qb?e<0?-Qb:Qb:e}function sx(e,t){var n=tx(e,t.src);return{weight:ox(nx(n,t.dir)/t.len),distance:ox(nx(n,t.normal))}}function cx(e){var t=1/0,n=-1/0,r=f_(e),i;try{for(r.s();!(i=r.n()).done;){var a=i.value;a.weight<t&&(t=a.weight),a.weight>n&&(n=a.weight)}}catch(e){r.e(e)}finally{r.f()}var o=n-t||1;return e.map(function(e){return{distance:e.distance,weight:(e.weight-t)/o}})}function lx(e,t){var n=ax(t.source().position(),t.target().position()),r=cx(e.points.map(function(e){return sx(e,n)}));return{controlPointWeights:r.slice(1,-1).map(function(e){return e.weight}),controlPointDistances:r.slice(1,-1).map(function(e){return e.distance})}}ex.prototype.run=function(){var e=this.options,t=this,n=e.cy,r=e.eles,i=function(e,t){return Zb(t)?t.apply(e,[e]):t},a=e.boundingBox||{x1:0,y1:0,w:n.width(),h:n.height()};a.x2===void 0&&(a.x2=a.x1+a.w),a.w===void 0&&(a.w=a.x2-a.x1),a.y2===void 0&&(a.y2=a.y1+a.h),a.h===void 0&&(a.h=a.y2-a.y1);var o=new Xb.graphlib.Graph({multigraph:!0,compound:!0}),s={},c=function(e,t){t!=null&&(s[e]=t)};c(`nodesep`,e.nodeSep),c(`edgesep`,e.edgeSep),c(`ranksep`,e.rankSep),c(`rankdir`,e.rankDir),c(`align`,e.align),c(`ranker`,e.ranker),c(`acyclicer`,e.acyclicer),o.setGraph(s),o.setDefaultEdgeLabel(function(){return{}}),o.setDefaultNodeLabel(function(){return{}});var l=r.nodes();Zb(e.sort)&&(l=l.sort(e.sort));for(var u=0;u<l.length;u++){var d=l[u],f=d.layoutDimensions(e);o.setNode(d.id(),{width:f.w,height:f.h,shape:`ellipse`,name:d.id()})}for(var p=0;p<l.length;p++){var m=l[p];m.isChild()&&o.setParent(m.id(),m.parent().id())}var h=r.edges();Zb(e.sort)&&(h=h.sort(e.sort));for(var g=0;g<h.length;g++){var _=h[g],v=$b(_.source()),y=$b(_.target());o.setEdge(v.id(),y.id(),{minlen:i(_,e.minLen),weight:i(_,e.edgeWeight),name:_.id()},_.id())}Xb.layout(o,e.dagreOptions);for(var b=o.nodes(),x=0;x<b.length;x++){var S=b[x],C=o.node(S);n.getElementById(S).scratch().dagre=C}var w;e.boundingBox?(w={x1:1/0,x2:-1/0,y1:1/0,y2:-1/0},l.forEach(function(e){var t=e.scratch().dagre;w.x1=Math.min(w.x1,t.x),w.x2=Math.max(w.x2,t.x),w.y1=Math.min(w.y1,t.y),w.y2=Math.max(w.y2,t.y)}),w.w=w.x2-w.x1,w.h=w.y2-w.y1):w=a;var T=function(t){if(e.boundingBox){var n=w.w===0?0:(t.x-w.x1)/w.w,r=w.h===0?0:(t.y-w.y1)/w.h;return{x:a.x1+n*a.w,y:a.y1+r*a.h}}return t};return l.layoutPositions(t,e,function(e){e=p_(e)===`object`?e:this;var t=e.scratch().dagre;return T({x:t.x,y:t.y})}),e.useDagreEdgeControlPoints&&(e.automaticDagreEdgeStyle&&(n.edges().addClass(`useDagreEdgeControlPoints`),n.style().selector(`edge.useDagreEdgeControlPoints`).style(e.dagreEdgeStyle).update()),o.edges().forEach(function(e){var t=n.getElementById(e.name),r=o.edge(e);r&&r.points&&t.scratch(lx(r,t))})),this};var ux=function(e){e&&e(`layout`,`dagre`,ex)};typeof window<`u`&&window.cytoscape!==void 0&&ux(window.cytoscape);function dx(e,t=`auto`){if(!Number.isFinite(e)||e<=0)return``;if(t===`ns`)return`${Math.round(e)} ns`;let n=e/1e6;return t===`ms`?`${n.toFixed(2)} ms`:e<1e6?`${Math.round(e)} ns`:`${n.toFixed(2)} ms`}function fx(e,t){return t===0?`0`:(e/t).toFixed(3).replace(/\.?0+$/,``)}function px(e,t=`auto`){let n=dx(e,`ns`);if(t===`ns`)return n||`0 ns`;let r=dx(e,`ms`);return t===`ms`?r||`0.00 ms`:n?`${r} (${n})`:`0.00 ms (0 ns)`}var mx=[{stop:0,r:30,g:41,b:59},{stop:.25,r:13,g:148,b:136},{stop:.55,r:245,g:158,b:11},{stop:.8,r:234,g:88,b:12},{stop:1,r:239,g:68,b:68}];function hx(e){let t=Math.max(0,Math.min(1,e));for(let e=0;e<mx.length-1;e++){let n=mx[e],r=mx[e+1];if(n&&r&&t<=r.stop){let e=r.stop-n.stop,i=e>0?(t-n.stop)/e:0;return`rgb(${Math.round(n.r+(r.r-n.r)*i)}, ${Math.round(n.g+(r.g-n.g)*i)}, ${Math.round(n.b+(r.b-n.b)*i)})`}}let n=mx[mx.length-1];return n?`rgb(${n.r}, ${n.g}, ${n.b})`:`rgb(30, 41, 59)`}function gx(e,t){if(t<=0||e<=0)return 0;let n=Math.min(Math.max(0,e/t),1);return Math.sqrt(n)}var _x=`selected dimmed highlighted-upstream highlighted-downstream search-matched`,vx=`dimmed highlighted-upstream highlighted-downstream`,yx=class{selectedId=null;upstream=new Set;downstream=new Set;search=null;mode=null;mediaOnly=!1;groupHighlight=null;get hasLineage(){return this.selectedId!==null}get activeGroupHighlight(){return this.groupHighlight}setLineage(e,t,n){this.selectedId=e,this.upstream=new Set(t),this.downstream=new Set(n)}clearLineage(){this.selectedId=null,this.upstream.clear(),this.downstream.clear()}setSearch(e){this.search=e===null?null:new Set(e)}setModeFilter(e){this.mode=e}setMediaOnly(e){this.mediaOnly=e}setGroupHighlight(e){this.groupHighlight=e===null?null:new Set(e)}apply(e,{showLineage:t=!0}={}){e.batch(()=>{let n=e.nodes(),r=e.edges();n.removeClass(_x),r.removeClass(vx);let i=new Set,a=t&&this.selectedId!==null,o=this.groupHighlight!==null;n.forEach(e=>{let t=e.id(),n=t===this.selectedId,r=this.upstream.has(t),s=this.downstream.has(t);n&&e.addClass(`selected`),a&&(!n&&r?e.addClass(`highlighted-upstream`):!n&&s?e.addClass(`highlighted-downstream`):n||i.add(t)),this.search!==null&&(this.search.has(t)?e.addClass(`search-matched`):n||i.add(t)),n||(this.mode!==null&&e.data(`filter_mode_name`)!==this.mode&&i.add(t),this.mediaOnly&&!e.hasClass(`media-change-node`)&&i.add(t),o&&!this.groupHighlight?.has(t)&&i.add(t))}),a&&r.forEach(e=>{let t=e.source().id(),n=e.target().id(),r=n===this.selectedId&&this.upstream.has(t)||this.upstream.has(t)&&this.upstream.has(n),i=t===this.selectedId&&this.downstream.has(n)||this.downstream.has(t)&&this.downstream.has(n);r?e.addClass(`highlighted-upstream`):i&&e.addClass(`highlighted-downstream`)}),n.forEach(e=>{i.has(e.id())&&e.addClass(`dimmed`)}),r.forEach(e=>{if(e.hasClass(`highlighted-upstream`)||e.hasClass(`highlighted-downstream`)||this.mediaOnly&&e.hasClass(`media-changed`))return;let t=e.source().id(),n=e.target().id();!(this.search!==null&&this.search.has(t)&&this.search.has(n))&&(i.has(t)||i.has(n))&&e.addClass(`dimmed`)})})}};u_.use(ux);var bx=`normal bold 14px system-ui, -apple-system, sans-serif`,xx=14,Sx=8,Cx=class{cy=null;currentDirection=`TB`;_heatmapActive=!1;_autoFitOnReload=!0;showTimings=!0;timingUnit=`auto`;selectedNodeId=null;themeTokens=null;lineMeasurer=null;lineMeasurerCache=new Map;visualState=new yx;currentLayout=`dagre`;rankSeparation=60;nodeSeparation=40;showPatternStyles=!1;onNodeSelectedCallbacks=[];onSelectionClearedCallbacks=[];onEdgeSelectedCallbacks=[];onBackgroundContextMenuCallbacks=[];onViewportChangedCallbacks=[];onCanvasTappedCallbacks=[];boundPreventContextMenu=null;containerElement=null;get direction(){return this.currentDirection}set direction(e){this.currentDirection!==e&&(this.currentDirection=e,this.runLayout())}get layout(){return this.currentLayout}set layout(e){this.currentLayout!==e&&(this.currentLayout=e,this.runLayout())}get rankSep(){return this.rankSeparation}set rankSep(e){this.rankSeparation!==e&&(this.rankSeparation=e,this.runLayout())}get nodeSep(){return this.nodeSeparation}set nodeSep(e){this.nodeSeparation!==e&&(this.nodeSeparation=e,this.runLayout())}get autoFitOnReload(){return this._autoFitOnReload}set autoFitOnReload(e){this._autoFitOnReload=e}get heatmapActive(){return this._heatmapActive}set heatmapActive(e){this._heatmapActive=e,this.cy&&(e||this.cy.nodes().removeStyle(`background-color`),this.applyVisualState())}get selectedId(){return this.selectedNodeId}get activeGroupHighlight(){return this.visualState.activeGroupHighlight}init(e){this.containerElement=e,this.boundPreventContextMenu=e=>e.preventDefault(),e.addEventListener(`contextmenu`,this.boundPreventContextMenu),this.cy=u_({container:e,boxSelectionEnabled:!1,autounselectify:!0,style:[]}),this.setupEventHandlers()}applyTheme(e){this.themeTokens=e,this.cy&&(this.cy.style(this.buildStylesheet(e)).update(),this.heatmapActive&&this.applyHeatmap())}onNodeSelected(e){return this.onNodeSelectedCallbacks.push(e),K(()=>{let t=this.onNodeSelectedCallbacks.indexOf(e);t!==-1&&this.onNodeSelectedCallbacks.splice(t,1)})}onSelectionCleared(e){return this.onSelectionClearedCallbacks.push(e),K(()=>{let t=this.onSelectionClearedCallbacks.indexOf(e);t!==-1&&this.onSelectionClearedCallbacks.splice(t,1)})}setPatternStyles(e){this.showPatternStyles!==e&&(this.showPatternStyles=e,this.cy?.edges().toggleClass(`pattern-labelled`,e))}isShowingPatternStyles(){return this.showPatternStyles}onEdgeSelected(e){return this.onEdgeSelectedCallbacks.push(e),K(()=>{let t=this.onEdgeSelectedCallbacks.indexOf(e);t!==-1&&this.onEdgeSelectedCallbacks.splice(t,1)})}onBackgroundContextMenu(e){return this.onBackgroundContextMenuCallbacks.push(e),K(()=>{let t=this.onBackgroundContextMenuCallbacks.indexOf(e);t!==-1&&this.onBackgroundContextMenuCallbacks.splice(t,1)})}onViewportChanged(e){return this.onViewportChangedCallbacks.push(e),K(()=>{let t=this.onViewportChangedCallbacks.indexOf(e);t!==-1&&this.onViewportChangedCallbacks.splice(t,1)})}onCanvasTapped(e){return this.onCanvasTappedCallbacks.push(e),K(()=>{let t=this.onCanvasTappedCallbacks.indexOf(e);t!==-1&&this.onCanvasTappedCallbacks.splice(t,1)})}applyOptions(e){let t=!1;e.direction!==void 0&&e.direction!==this.currentDirection&&(this.currentDirection=e.direction,t=!0),e.layout!==void 0&&e.layout!==this.currentLayout&&(this.currentLayout=e.layout,t=!0),e.rankSep!==void 0&&e.rankSep!==this.rankSeparation&&(this.rankSeparation=e.rankSep,t=!0),e.nodeSep!==void 0&&e.nodeSep!==this.nodeSeparation&&(this.nodeSeparation=e.nodeSep,t=!0),e.autoFitOnReload!==void 0&&(this._autoFitOnReload=e.autoFitOnReload);let n=this.applyTimingDisplay(e.showTimings??this.showTimings,e.timingUnit??this.timingUnit);e.heatmap!==void 0&&e.heatmap!==this._heatmapActive&&(this.heatmapActive=e.heatmap),t?this.runLayout():n&&this.runLayout(!1)}setModeFilter(e){this.visualState.setModeFilter(e),this.cy&&this.applyVisualState()}setMediaOnly(e){this.visualState.setMediaOnly(e),this.cy&&this.applyVisualState()}highlightNodeGroup(e){this.visualState.setGroupHighlight(e),this.cy&&this.applyVisualState()}getEdges(){return this.cy?this.cy.edges().map(e=>e.data()):[]}exportPng(){let e=this.cy;return e?U.fromThrowable(()=>e.png({full:!0,scale:2,maxWidth:8192,maxHeight:8192,bg:this.themeTokens?.bg??`#000000`})).andThen(e=>e?U.ok(e):U.err(Error(`Cytoscape returned an empty PNG data URL`))):U.err(Error(`Cannot export PNG: Cytoscape canvas is not initialized`))}setGraphData(e,t=!1){if(!this.cy)return;this.lineMeasurerCache.clear();let n=this.cy.elements().length>0,r=t&&n&&!this.autoFitOnReload,i=this.selectedNodeId,a=r?this.cy.pan():null,o=r?this.cy.zoom():null;this.selectedNodeId=null,this.visualState.clearLineage(),this.cy.stop(),this.cy.elements().remove();let s=[],c=new Set(e.edges.filter(e=>!!e.data.media_label).map(e=>e.data.target));for(let t of e.nodes){let e={...t.data,source_label:t.data.label,...this.buildLabelData(t.data.label,t.data.processing_time_ns)},n=[`mode-${t.data.filter_mode_name.toLowerCase().replace(/_/g,`-`)}`,c.has(t.data.id)?`media-change-node`:``].filter(Boolean).join(` `);s.push({group:`nodes`,data:e,classes:n})}for(let t of e.edges){let e={...t.data},n=[`pattern-${t.data.pattern_name.toLowerCase().replace(/[^a-z0-9]+/g,`-`)}`,t.data.media_label?`media-changed`:``,this.showPatternStyles?`pattern-labelled`:``].filter(Boolean).join(` `);s.push({group:`edges`,data:e,classes:n})}if(this.cy.add(s),this.runLayout(),t&&a&&o&&(this.cy.zoom(o),this.cy.pan(a)),this.heatmapActive&&this.applyHeatmap(),i){let e=this.selectNodeById(i);e?this.notifyNodeSelected(e):this.notifySelectionCleared()}}updateTimings(e){let t=this.cy;if(!t)return;let n=!1;t.batch(()=>{for(let r of e){let e=t.getElementById(r.id);e.length>0&&(e.data(`processing_time_ns`,r.processing_time_ns),e.data(`processing_time_ms`,r.processing_time_ms),n=this.refreshNodeLabel(e)||n)}this.heatmapActive&&this.applyHeatmap()}),n&&this.runLayout(!1)}runLayout(e=this.autoFitOnReload){if(!this.cy)return;let t={animate:!1,fit:e,padding:40},n;switch(this.currentLayout){case`breadthfirst`:n={name:`breadthfirst`,directed:!0,spacingFactor:1.2,...t};break;case`concentric`:n={name:`concentric`,minNodeSpacing:this.nodeSeparation,...t};break;case`grid`:n={name:`grid`,avoidOverlap:!0,...t};break;default:n={name:`dagre`,rankDir:this.currentDirection,nodeSep:this.nodeSeparation,rankSep:this.rankSeparation,edgeSep:20,...t}}this.cy.layout(n).run(),this.applyVisualState()}setTimingDisplay(e,t){this.applyTimingDisplay(e,t)&&this.runLayout(!1)}isShowingTimings(){return this.showTimings}getTimingUnit(){return this.timingUnit}zoomIn(){this.cy&&this.cy.zoom({level:this.cy.zoom()*1.25,renderedPosition:{x:this.cy.width()/2,y:this.cy.height()/2}})}zoomOut(){this.cy&&this.cy.zoom({level:this.cy.zoom()*.8,renderedPosition:{x:this.cy.width()/2,y:this.cy.height()/2}})}fit(){this.cy&&this.cy.fit(void 0,40)}reset(){this.cy&&(this.cy.zoom(1),this.cy.center())}selectNodeById(e){if(!this.cy)return null;let t=this.cy.getElementById(e);return t.length===0?null:(this.selectedNodeId=e,this.highlightLineage(t),t.data())}getNodeById(e){if(!this.cy)return null;let t=this.cy.getElementById(e);return t.length===0?null:t.data()}getEdgeById(e){if(!this.cy)return null;let t=this.cy.getElementById(e);return t.empty()||!t.isEdge()?null:{edge:t.data(),source:t.source().data(),target:t.target().data()}}getIncomingConnections(e){if(!this.cy)return[];let t=this.cy.getElementById(e);if(t.length===0)return[];let n=t.incomers(`edge`),r=[];return n.forEach(e=>{let t=e.data(),n=e.source().data();n&&r.push({edge:t,source:n})}),r.sort((e,t)=>e.edge.index-t.edge.index)}centerNode(e){if(!this.cy)return;let t=this.cy.getElementById(e);t.length>0&&this.cy.animate({center:{eles:t},zoom:Math.max(this.cy.zoom(),1)},{duration:250})}clearSelection(){this.selectedNodeId=null,this.visualState.clearLineage(),this.cy&&this.applyVisualState()}highlightSearchMatches(e){this.cy&&(this.visualState.setSearch(e.length>0?e:null),this.applyVisualState())}clearSearch(){this.cy&&(this.visualState.setSearch(null),this.applyVisualState())}getNodes(){return this.cy?this.cy.nodes().map(e=>e.data()):[]}dispose(){this.containerElement&&=(this.boundPreventContextMenu&&=(this.containerElement.removeEventListener(`contextmenu`,this.boundPreventContextMenu),null),this.containerElement.title=``,null),this.onNodeSelectedCallbacks=[],this.onSelectionClearedCallbacks=[],this.onEdgeSelectedCallbacks=[],this.onBackgroundContextMenuCallbacks=[],this.onViewportChangedCallbacks=[],this.onCanvasTappedCallbacks=[],this.visualState.clearLineage(),this.visualState.setSearch(null),this.lineMeasurer=null,this.lineMeasurerCache.clear(),this.cy&&=(this.cy.destroy(),null)}setupEventHandlers(){this.cy&&(this.cy.on(`cxttap`,e=>{e.originalEvent.preventDefault(),e.target===this.cy&&this.notifyBackgroundContextMenu({x:e.originalEvent.clientX,y:e.originalEvent.clientY})}),this.cy.on(`pan zoom`,()=>{this.notifyViewportChanged()}),this.cy.on(`tap`,e=>{this.notifyCanvasTapped(),e.target===this.cy&&(this.clearLineage(),this.selectedNodeId=null,this.notifySelectionCleared())}),this.cy.on(`tap`,`node`,e=>{let t=e.target;this.highlightLineage(t);let n=t.data();this.selectedNodeId=n.id,this.notifyNodeSelected(n)}),this.cy.on(`tap`,`edge`,e=>{let t=e.target,n=t.data(),r=t.source().data(),i=t.target().data();this.notifyEdgeSelected(n,r,i)}),this.cy.on(`mouseover`,`edge`,e=>{let t=e.target,n=t.data(),r=t.source().data(),i=t.target().data(),a=`${r.name} → ${i.name} (Slot #${n.index})\nPattern: ${n.pattern_name}`;n.media_label&&(a+=`\nMedia: ${n.media_label}`),this.containerElement&&(this.containerElement.title=a)}),this.cy.on(`mouseout`,`edge`,()=>{this.containerElement&&(this.containerElement.title=``)}))}notifyNodeSelected(e){for(let t of this.onNodeSelectedCallbacks)U.fromThrowable(()=>t(e)).mapErr(e=>{console.error(`Error in node selection listener:`,e)})}notifySelectionCleared(){for(let e of this.onSelectionClearedCallbacks)U.fromThrowable(()=>e()).mapErr(e=>{console.error(`Error in selection cleared listener:`,e)})}notifyEdgeSelected(e,t,n){for(let r of this.onEdgeSelectedCallbacks)U.fromThrowable(()=>r(e,t,n)).mapErr(e=>{console.error(`Error in edge selection listener:`,e)})}notifyBackgroundContextMenu(e){for(let t of this.onBackgroundContextMenuCallbacks)U.fromThrowable(()=>t(e)).mapErr(e=>{console.error(`Error in background context menu listener:`,e)})}notifyViewportChanged(){for(let e of this.onViewportChangedCallbacks)U.fromThrowable(()=>e()).mapErr(e=>{console.error(`Error in viewport changed listener:`,e)})}notifyCanvasTapped(){for(let e of this.onCanvasTappedCallbacks)U.fromThrowable(()=>e()).mapErr(e=>{console.error(`Error in canvas tapped listener:`,e)})}highlightLineage(e){this.cy&&(this.visualState.setLineage(e.id(),e.predecessors().map(e=>e.id()),e.successors().map(e=>e.id())),this.applyVisualState())}clearLineage(){this.cy&&(this.visualState.clearLineage(),this.applyVisualState())}applyVisualState(){this.cy&&(this.visualState.apply(this.cy,{showLineage:!this.heatmapActive}),this.heatmapActive&&this.applyHeatmap())}applyHeatmap(){if(!this.cy)return;let e=this.cy.nodes(),t=0;e.forEach(e=>{let n=e.data(`processing_time_ns`);n===void 0?console.warn(`Couldn't find 'processing_time_ns' when applying heatmap`):n>t&&(t=n)}),e.forEach(e=>{let n=e.data(`processing_time_ns`);if(n===void 0){console.warn(`Couldn't find 'processing_time_ns' when applying heatmap`);return}let r=hx(gx(n,t));e.style(`background-color`,r)})}applyTimingDisplay(e,t){if(this.showTimings===e&&this.timingUnit===t)return!1;this.showTimings=e,this.timingUnit=t;let n=this.cy;if(!n)return!1;let r=!1;return n.batch(()=>{for(let e of n.nodes())r=this.refreshNodeLabel(e)||r}),r}refreshNodeLabel(e){let t=e.data(),n=this.buildLabelData(t.source_label,t.processing_time_ns),r=n.node_width!==t.node_width||n.node_height!==t.node_height;return e.data(n),r}buildLabelData(e,t){let n=this.showTimings?dx(t,this.timingUnit):``,r=n?`${e}\n${n}`:e,i=r.split(`
|
|
324
|
+
`);return{label:r,node_width:i.reduce((e,t)=>Math.max(e,Math.ceil(this.getLineMeasurer()(t))),0),node_height:i.length*xx}}getLineMeasurer(){if(this.lineMeasurer)return this.lineMeasurer;let e=U.fromThrowable(()=>document.createElement(`canvas`).getContext(`2d`)).unwrapOr(null);return e?(e.font=bx,this.lineMeasurer=t=>{let n=this.lineMeasurerCache.get(t);return n===void 0&&(n=e.measureText(t).width,this.lineMeasurerCache.set(t,n)),n},this.lineMeasurer):(this.lineMeasurer=e=>e.length*Sx,this.lineMeasurer)}buildStylesheet(e){return[{selector:`node`,style:{shape:`round-rectangle`,"background-color":e.surfaceElevated,"border-width":1.5,"border-color":e.border,label:`data(label)`,color:e.textPrimary,"font-family":`system-ui, -apple-system, sans-serif`,"font-size":`${xx}px`,"font-weight":`bold`,"text-valign":`center`,"text-halign":`center`,"text-wrap":`wrap`,width:`data(node_width)`,height:`data(node_height)`,padding:`12px`,"transition-property":`border-color, border-width, opacity`,"transition-duration":.15}},{selector:`node[?is_root]`,style:{"border-color":e.accentAmber,"border-width":2.5}},{selector:`node.mode-frame-state, node.mode-framestate`,style:{"border-style":`dashed`,"border-color":e.danger}},{selector:`node.mode-unordered`,style:{"border-style":`dotted`,"border-color":e.accent}},{selector:`node.mode-parallel-requests`,style:{"border-style":`dashed`,"border-color":e.accentEmerald}},{selector:`node.media-change-node`,style:{"underlay-color":e.accentAmber,"underlay-padding":3,"underlay-opacity":.2}},{selector:`node.selected`,style:{"border-color":e.accent,"border-width":2.5,"underlay-color":e.accent,"underlay-padding":4,"underlay-opacity":.3,opacity:1,"z-index":10}},{selector:`edge`,style:{"curve-style":`bezier`,"target-arrow-shape":`triangle`,"line-color":e.border,"target-arrow-color":e.border,"arrow-scale":1.1,width:1.5}},{selector:`edge.pattern-strict-spatial`,style:{"line-style":`dotted`}},{selector:`edge.pattern-no-frame-reuse`,style:{"line-style":`dashed`}},{selector:`edge.pattern-frame-reuse-last-only`,style:{"line-style":`dashed`,width:2}},{selector:`edge.media-changed`,style:{"line-color":e.accentAmber,"target-arrow-color":e.accentAmber,width:2.5}},{selector:`edge.pattern-labelled[label != ""]`,style:{label:`data(label)`,"font-size":`9px`,color:e.textSecondary,"text-background-opacity":1,"text-background-color":e.bg,"text-background-padding":`2px 4px`,"text-background-shape":`roundrectangle`}},{selector:`.dimmed`,style:{opacity:.15}},{selector:`.highlighted-upstream`,style:{"border-color":e.accent,"line-color":e.accent,"target-arrow-color":e.accent,opacity:1,"z-index":10}},{selector:`.highlighted-downstream`,style:{"border-color":e.accentAmber,"line-color":e.accentAmber,"target-arrow-color":e.accentAmber,opacity:1,"z-index":10}},{selector:`.search-matched`,style:{"border-color":e.accentEmerald,"border-width":3,"underlay-color":e.accentEmerald,"underlay-padding":6,"underlay-opacity":.4,opacity:1}}]}},wx={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Tx=e=>(...t)=>({_$litDirective$:e,values:t}),Ex=class{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,n){this._$Ct=e,this._$AM=t,this._$Ci=n}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}},Dx=Tx(class extends Ex{constructor(e){if(super(e),e.type!==wx.ATTRIBUTE||e.name!==`class`||e.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(e){return` `+Object.keys(e).filter(t=>e[t]).join(` `)+` `}update(e,[t]){if(this.st===void 0){this.st=new Set,e.strings!==void 0&&(this.nt=new Set(e.strings.join(` `).split(/\s/).filter(e=>e!==``)));for(let e in t)t[e]&&!this.nt?.has(e)&&this.st.add(e);return this.render(t)}let n=e.element.classList;for(let e of this.st)e in t||(n.remove(e),this.st.delete(e));for(let e in t){let r=!!t[e];r===this.st.has(e)||this.nt?.has(e)||(r?(n.add(e),this.st.add(e)):(n.remove(e),this.st.delete(e)))}return S}}),{I:Ox}=L,kx=e=>e,Ax=e=>e.strings===void 0,jx=()=>document.createComment(``),Mx=(e,t,n)=>{let r=e._$AA.parentNode,i=t===void 0?e._$AB:t._$AA;if(n===void 0)n=new Ox(r.insertBefore(jx(),i),r.insertBefore(jx(),i),e,e.options);else{let t=n._$AB.nextSibling,a=n._$AM,o=a!==e;if(o){let t;n._$AQ?.(e),n._$AM=e,n._$AP!==void 0&&(t=e._$AU)!==a._$AU&&n._$AP(t)}if(t!==i||o){let e=n._$AA;for(;e!==t;){let t=kx(e).nextSibling;kx(r).insertBefore(e,i),e=t}}}return n},Nx=(e,t,n=e)=>(e._$AI(t,n),e),Px={},Fx=(e,t=Px)=>e._$AH=t,Ix=e=>e._$AH,Lx=e=>{e._$AR(),e._$AA.remove()},Rx=Tx(class extends Ex{constructor(e){if(super(e),e.type!==wx.PROPERTY&&e.type!==wx.ATTRIBUTE&&e.type!==wx.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!Ax(e))throw Error("`live` bindings can only contain a single expression")}render(e){return e}update(e,[t]){if(t===S||t===C)return t;let n=e.element,r=e.name;if(e.type===wx.PROPERTY){if(t===n[r])return S}else if(e.type===wx.BOOLEAN_ATTRIBUTE){if(!!t===n.hasAttribute(r))return S}else if(e.type===wx.ATTRIBUTE&&n.getAttribute(r)===t+``)return S;return Fx(e),t}}),zx=(e,t,n)=>{let r=new Map;for(let i=t;i<=n;i++)r.set(e[i],i);return r},Bx=Tx(class extends Ex{constructor(e){if(super(e),e.type!==wx.CHILD)throw Error(`repeat() can only be used in text expressions`)}dt(e,t,n){let r;n===void 0?n=t:t!==void 0&&(r=t);let i=[],a=[],o=0;for(let t of e)i[o]=r?r(t,o):o,a[o]=n(t,o),o++;return{values:a,keys:i}}render(e,t,n){return this.dt(e,t,n).values}update(e,[t,n,r]){let i=Ix(e),{values:a,keys:o}=this.dt(t,n,r);if(!Array.isArray(i))return this.ut=o,a;let s=this.ut??=[],c=[],l,u,d=0,f=i.length-1,p=0,m=a.length-1;for(;d<=f&&p<=m;)if(i[d]===null)d++;else if(i[f]===null)f--;else if(s[d]===o[p])c[p]=Nx(i[d],a[p]),d++,p++;else if(s[f]===o[m])c[m]=Nx(i[f],a[m]),f--,m--;else if(s[d]===o[m])c[m]=Nx(i[d],a[m]),Mx(e,c[m+1],i[d]),d++,m--;else if(s[f]===o[p])c[p]=Nx(i[f],a[p]),Mx(e,i[d],i[f]),f--,p++;else if(l===void 0&&(l=zx(o,p,m),u=zx(s,d,f)),l.has(s[d])){if(l.has(s[f])){let t=u.get(o[p]),n=t===void 0?null:i[t];if(n===null){let t=Mx(e,i[d]);Nx(t,a[p]),c[p]=t}else c[p]=Nx(n,a[p]),Mx(e,i[d],n),i[t]=null;p++}else Lx(i[f]),f--}else Lx(i[d]),d++;for(;p<=m;){let t=Mx(e,c[m+1]);Nx(t,a[p]),c[p++]=t}for(;d<=f;){let e=i[d++];e!==null&&Lx(e)}return this.ut=o,Fx(e,c),S}});function Vx(e,t,n){return e?t(e):n?.(e)}function Hx(e){let t=e.trim();if(!t)return{raw:e,textParts:[],regex:null,error:null};if(t.startsWith(`/`)){let n=t.lastIndexOf(`/`);if(n<=0)return{raw:e,textParts:[],regex:null,error:`Invalid regular expression`};let r=t.slice(n+1).replace(/[gy]/g,``);return U.fromThrowable(()=>new RegExp(t.slice(1,n),r)).match({ok:t=>({raw:e,textParts:[],regex:t,error:null}),err:t=>({raw:e,textParts:[],regex:null,error:`Invalid regular expression: ${t.message}`})})}return{raw:e,textParts:t.toLowerCase().split(/\s+/),regex:null,error:null}}function Ux(e){return e.error===null&&e.regex===null&&e.textParts.length===0}function Wx(e){let t=[e.name,e.id,e.label];for(let n of e.call_stack){t.push(n.function,n.plugin_id,n.plugin_ns);for(let[e,r]of Object.entries(n.arguments))if(t.push(e),typeof r==`string`||typeof r==`number`||typeof r==`boolean`)t.push(String(r));else if(Array.isArray(r))for(let e of r)(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)&&t.push(String(e))}return t}function Gx(e,t){if(t.error!==null)return!1;let n=Wx(e);if(t.regex!==null){let e=t.regex;return n.some(t=>e.test(t))}return t.textParts.every(e=>n.some(t=>t.toLowerCase().includes(e)))}var Kx=`Matches against node names, IDs, labels, call stack functions, namespaces, argument names, and argument values:
|
|
325
|
+
• Words: Space-separated terms use AND matching (e.g. std crop left 8)
|
|
326
|
+
• Regex: Enclose in slashes with optional flags (e.g. /crop$/i). Invalid syntax displays !
|
|
327
|
+
• Press Enter / Shift+Enter (or ▲/▼) to cycle matches, Esc to clear`,qx=class extends J{opts;outputs=[];following=!0;direction=`TB`;heatmap=!1;patterns=!1;searchQuery=``;searchError=null;searchMatches=[];searchIndex=-1;constructor(e){super(),this.opts=e,this.render()}setOutputs(e,t){this.outputs=e,this.following=t,this.render()}syncOptions(e){this.direction=e.direction,this.heatmap=e.heatmap,this.patterns=e.patterns??!1,this.render()}focusSearch(){let e=this.opts.container.querySelector(`#hud-search-input`);e?.focus(),e?.select()}refreshSearch(e=!1){if(!this.searchQuery.trim())return;let t=this.searchMatches[this.searchIndex];if(this.performSearch(e),t){let e=this.searchMatches.indexOf(t);e>=0&&(this.searchIndex=e)}this.render()}handleOutputChange(e){let t=e.target,n=parseInt(t.value,10);Number.isNaN(n)||this.opts.onOutputSelected(n)}toggleDirection(){let e=this.opts.canvas.direction===`TB`?`LR`:`TB`;this.opts.canvas.direction=e,this.direction=e,this.render()}toggleHeatmap(){let e=!this.opts.canvas.heatmapActive;this.opts.canvas.heatmapActive=e,this.heatmap=e,this.render()}togglePatterns(){let e=!this.opts.canvas.isShowingPatternStyles();this.opts.canvas.setPatternStyles(e),this.patterns=e,this.opts.onPatternsToggled?.(e),this.render()}handleSearchInput(e){this.searchQuery=e.target.value,this.performSearch(),this.render()}handleSearchKeyDown(e){e.key===`Enter`?(e.preventDefault(),this.cycleMatch(e.shiftKey?-1:1)):e.key===`Escape`&&(this.searchQuery=``,this.performSearch(),this.render(),e.target.blur())}performSearch(e=!0){let t=Hx(this.searchQuery);if(this.searchError=t.error,t.error!==null||Ux(t))this.searchMatches=[],this.searchIndex=-1,this.opts.canvas.clearSearch();else if(this.searchMatches=this.opts.canvas.getNodes().filter(e=>Gx(e,t)).map(e=>e.id),this.opts.canvas.highlightSearchMatches(this.searchMatches),this.searchMatches.length>0){this.searchIndex=0;let t=this.searchMatches[0];t&&e&&(this.opts.onNodeMatched?this.opts.onNodeMatched(t):this.opts.canvas.centerNode(t))}else this.searchIndex=-1}cycleMatch(e){if(this.searchMatches.length===0)return;this.searchIndex=(this.searchIndex+e+this.searchMatches.length)%this.searchMatches.length,this.render();let t=this.searchMatches[this.searchIndex];t&&(this.opts.onNodeMatched?this.opts.onNodeMatched(t):this.opts.canvas.centerNode(t))}getSearchCountLabel(){return this.searchError===null?this.searchQuery.trim()?this.searchMatches.length===0?`0/0`:`${this.searchIndex+1}/${this.searchMatches.length}`:``:`!`}render(){let e=this.searchError===null&&this.searchMatches.length>0;z(x`
|
|
328
|
+
<div class="hud-bar">
|
|
329
|
+
${this.renderOutputSelect()}
|
|
330
|
+
<div class="hud-separator"></div>
|
|
331
|
+
${this.renderCanvasControls()}
|
|
332
|
+
<div class="hud-separator"></div>
|
|
333
|
+
${this.renderToolActions()}
|
|
334
|
+
<div class="hud-separator"></div>
|
|
335
|
+
${this.renderSearchBar(e)}
|
|
336
|
+
</div>
|
|
337
|
+
`,this.opts.container),this.syncOutputSelection()}syncOutputSelection(){let e=this.opts.container.querySelector(`#hud-output-select`);if(!e)return;let t=this.outputs.find(e=>e.isActive);e.value=this.following||!t?`-1`:String(t.index)}renderOutputSelect(){function e(e){return x`<option value=${String(e.index)}>
|
|
338
|
+
[${e.index}] ${e.name||`Video`}
|
|
339
|
+
</option>`}return x`
|
|
340
|
+
<div class="hud-group">
|
|
341
|
+
<select
|
|
342
|
+
id="hud-output-select"
|
|
343
|
+
class="hud-select"
|
|
344
|
+
title="Select workspace output to inspect"
|
|
345
|
+
?disabled=${this.outputs.length===0}
|
|
346
|
+
@change=${e=>this.handleOutputChange(e)}
|
|
347
|
+
>
|
|
348
|
+
${Vx(this.outputs.length===0,()=>x`<option value="-1">No outputs</option>`,()=>x`
|
|
349
|
+
<option value="-1">Follow active output</option>
|
|
350
|
+
${Bx(this.outputs,e=>e.index,t=>e(t))}
|
|
351
|
+
`)}
|
|
352
|
+
</select>
|
|
353
|
+
</div>
|
|
354
|
+
`}renderCanvasControls(){return x`
|
|
355
|
+
<div class="hud-group">
|
|
356
|
+
<button
|
|
357
|
+
id="hud-zoom-in"
|
|
358
|
+
class="hud-btn"
|
|
359
|
+
title="Zoom In"
|
|
360
|
+
@click=${()=>this.opts.canvas.zoomIn()}
|
|
361
|
+
>
|
|
362
|
+
+
|
|
363
|
+
</button>
|
|
364
|
+
<button
|
|
365
|
+
id="hud-zoom-out"
|
|
366
|
+
class="hud-btn"
|
|
367
|
+
title="Zoom Out"
|
|
368
|
+
@click=${()=>this.opts.canvas.zoomOut()}
|
|
369
|
+
>
|
|
370
|
+
−
|
|
371
|
+
</button>
|
|
372
|
+
<button
|
|
373
|
+
id="hud-fit"
|
|
374
|
+
class="hud-btn"
|
|
375
|
+
title="Fit Entire Graph"
|
|
376
|
+
@click=${()=>this.opts.canvas.fit()}
|
|
377
|
+
>
|
|
378
|
+
Fit
|
|
379
|
+
</button>
|
|
380
|
+
<button
|
|
381
|
+
id="hud-reset"
|
|
382
|
+
class="hud-btn"
|
|
383
|
+
title="Reset View (1:1)"
|
|
384
|
+
@click=${()=>this.opts.canvas.reset()}
|
|
385
|
+
>
|
|
386
|
+
1:1
|
|
387
|
+
</button>
|
|
388
|
+
<button
|
|
389
|
+
id="hud-direction"
|
|
390
|
+
class="hud-btn"
|
|
391
|
+
title="Toggle Layout Direction (Vertical / Horizontal)"
|
|
392
|
+
@click=${()=>this.toggleDirection()}
|
|
393
|
+
>
|
|
394
|
+
${this.direction===`TB`?`↕ TB`:`↔ LR`}
|
|
395
|
+
</button>
|
|
396
|
+
</div>
|
|
397
|
+
`}renderToolActions(){return x`
|
|
398
|
+
<div class="hud-group">
|
|
399
|
+
<button
|
|
400
|
+
id="hud-heatmap"
|
|
401
|
+
class=${Dx({"hud-btn":!0,active:this.heatmap})}
|
|
402
|
+
title="Toggle profiling heatmap (Teal: fast → Amber: moderate → Red: bottleneck)"
|
|
403
|
+
@click=${()=>this.toggleHeatmap()}
|
|
404
|
+
>
|
|
405
|
+
Heatmap
|
|
406
|
+
</button>
|
|
407
|
+
<button
|
|
408
|
+
id="hud-patterns"
|
|
409
|
+
class=${Dx({"hud-btn":!0,active:this.patterns})}
|
|
410
|
+
title="Show request pattern labels on edges"
|
|
411
|
+
@click=${()=>this.togglePatterns()}
|
|
412
|
+
>
|
|
413
|
+
Patterns
|
|
414
|
+
</button>
|
|
415
|
+
<button
|
|
416
|
+
id="hud-overview"
|
|
417
|
+
class="hud-btn"
|
|
418
|
+
title="Graph overview, warnings and exports"
|
|
419
|
+
@click=${()=>this.opts.onOverviewRequested?.()}
|
|
420
|
+
>
|
|
421
|
+
Overview
|
|
422
|
+
</button>
|
|
423
|
+
<button
|
|
424
|
+
id="hud-refresh"
|
|
425
|
+
class="hud-btn"
|
|
426
|
+
title="Re-inspect the graph and refresh timings"
|
|
427
|
+
@click=${()=>this.opts.onReloadRequested()}
|
|
428
|
+
>
|
|
429
|
+
↻
|
|
430
|
+
</button>
|
|
431
|
+
</div>
|
|
432
|
+
`}renderSearchBar(e){return x`
|
|
433
|
+
<div class="hud-group hud-search-group">
|
|
434
|
+
<span class="hud-search-icon" title=${Kx}>🔍</span>
|
|
435
|
+
<input
|
|
436
|
+
id="hud-search-input"
|
|
437
|
+
class=${Dx({"hud-search-input":!0,invalid:this.searchError!==null})}
|
|
438
|
+
type="text"
|
|
439
|
+
placeholder="Search filter..."
|
|
440
|
+
title=${this.searchError??`Matches against node names, IDs, labels, call stack functions, namespaces, argument names, and argument values:
|
|
441
|
+
• Words: Space-separated terms use AND matching (e.g. std crop left 8)
|
|
442
|
+
• Regex: Enclose in slashes with optional flags (e.g. /crop$/i). Invalid syntax displays !
|
|
443
|
+
• Press Enter / Shift+Enter (or ▲/▼) to cycle matches, Esc to clear`}
|
|
444
|
+
.value=${Rx(this.searchQuery)}
|
|
445
|
+
@input=${e=>this.handleSearchInput(e)}
|
|
446
|
+
@keydown=${e=>this.handleSearchKeyDown(e)}
|
|
447
|
+
/>
|
|
448
|
+
<span id="hud-search-count" class="hud-search-count"> ${this.getSearchCountLabel()} </span>
|
|
449
|
+
<button
|
|
450
|
+
id="hud-search-prev"
|
|
451
|
+
class="hud-search-btn"
|
|
452
|
+
title="Previous match"
|
|
453
|
+
?disabled=${!e}
|
|
454
|
+
@click=${()=>this.cycleMatch(-1)}
|
|
455
|
+
>
|
|
456
|
+
▲
|
|
457
|
+
</button>
|
|
458
|
+
<button
|
|
459
|
+
id="hud-search-next"
|
|
460
|
+
class="hud-search-btn"
|
|
461
|
+
title="Next match"
|
|
462
|
+
?disabled=${!e}
|
|
463
|
+
@click=${()=>this.cycleMatch(1)}
|
|
464
|
+
>
|
|
465
|
+
▼
|
|
466
|
+
</button>
|
|
467
|
+
</div>
|
|
468
|
+
`}},Jx=class e extends J{opts;static DEFAULT_WIDTH=400;static MIN_WIDTH=280;static VIEWPORT_MARGIN=80;isOpen=!1;showTimings=!0;timingUnit=`auto`;lastNode=null;lastEdge=null;openFrames=new Set([0]);dragController=null;constructor(e){super(),this.opts=e,this.render()}get opened(){return this.isOpen}dispose(){this.stopDragging(),z(C,this.opts.container),super.dispose()}inspectNode(e){this.lastNode?.id!==e.id&&(this.openFrames=new Set([0])),this.lastNode=e,this.lastEdge=null,this.render(),this.open()}inspectEdge(e,t,n){this.lastNode=null,this.lastEdge={edge:e,source:t,target:n},this.render(),this.open()}refresh(){if(this.lastNode)this.lastNode=this.opts.resolveNode(this.lastNode.id);else if(this.lastEdge)this.lastEdge=this.opts.resolveEdge(this.lastEdge.edge.id);else return;!this.lastNode&&!this.lastEdge&&this.close(),this.render()}setTimingOptions(e,t){(this.showTimings!==e||this.timingUnit!==t)&&(this.showTimings=e,this.timingUnit=t,this.lastNode&&this.render())}open(){this.isOpen||(this.isOpen=!0,this.opts.container.classList.add(`open`))}close(){this.isOpen&&(this.stopDragging(),this.isOpen=!1,this.opts.container.classList.remove(`open`))}resetWidth(){this.opts.container.style.removeProperty(`--inspector-width`)}stopDragging(){this.dragController?.abort(),this.dragController=null}handleResizerPointerDown(t){if(t.button!==0)return;t.preventDefault(),this.stopDragging();let{pointerId:n}=t,r=t.currentTarget instanceof HTMLElement?t.currentTarget:null,i=t.clientX,a=this.opts.container.getBoundingClientRect(),o=a.width>0?a.width:e.DEFAULT_WIDTH,s=this.opts.container.parentElement?.clientWidth??window.innerWidth,c=Math.max(e.MIN_WIDTH,s-e.VIEWPORT_MARGIN);this.opts.container.classList.add(`resizing`),r?.classList.add(`dragging`);let l=document.body.style.userSelect,u=document.body.style.cursor;document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`;let d=new AbortController;this.dragController=d,d.signal.addEventListener(`abort`,()=>{this.opts.container.classList.remove(`resizing`),r?.classList.remove(`dragging`),document.body.style.userSelect=l,document.body.style.cursor=u,this.dragController===d&&(this.dragController=null)},{once:!0});let f=e=>{e.pointerId===n&&d.abort()};window.addEventListener(`pointermove`,t=>{if(t.pointerId!==n)return;let r=i-t.clientX,a=Math.max(e.MIN_WIDTH,Math.min(c,Math.round(o+r)));this.opts.container.style.setProperty(`--inspector-width`,`${a}px`)},{signal:d.signal}),window.addEventListener(`pointerup`,f,{signal:d.signal}),window.addEventListener(`pointercancel`,f,{signal:d.signal})}copyNodeId(){this.lastNode&&this.opts.onCopyNode(this.lastNode.id,`id`)}copyFilterCall(e){this.lastNode&&this.opts.onCopyNode(this.lastNode.id,`call`,e)}copyReport(){this.lastNode&&this.opts.onCopyNode(this.lastNode.id,`report`)}toggleFrame(e){this.openFrames.has(e)?this.openFrames.delete(e):this.openFrames.add(e),this.render()}render(){let e=this.lastNode?this.lastNode.name:this.lastEdge?`${this.lastEdge.source.name} → ${this.lastEdge.target.name}`:`Filter`;z(x`
|
|
469
|
+
<div
|
|
470
|
+
class="inspector-resizer"
|
|
471
|
+
id="inspector-resizer"
|
|
472
|
+
title="Drag to resize inspector (double-click to reset)"
|
|
473
|
+
@pointerdown=${e=>this.handleResizerPointerDown(e)}
|
|
474
|
+
@dblclick=${()=>this.resetWidth()}
|
|
475
|
+
></div>
|
|
476
|
+
${this.renderHeader(e)}
|
|
477
|
+
<div class="inspector-body" id="inspector-content">${this.renderBody()}</div>
|
|
478
|
+
`,this.opts.container)}renderHeader(e){return x`
|
|
479
|
+
<div class="inspector-header">
|
|
480
|
+
<div class="inspector-title-row">
|
|
481
|
+
<span class="inspector-title" id="inspector-name">${e}</span>
|
|
482
|
+
<div class="inspector-title-actions">
|
|
483
|
+
${this.renderReportButton()}
|
|
484
|
+
<button
|
|
485
|
+
class="inspector-close-btn"
|
|
486
|
+
id="inspector-close"
|
|
487
|
+
title="Close inspector"
|
|
488
|
+
@click=${()=>this.close()}
|
|
489
|
+
>
|
|
490
|
+
×
|
|
491
|
+
</button>
|
|
492
|
+
</div>
|
|
493
|
+
</div>
|
|
494
|
+
<div class="inspector-badges" id="inspector-badges">${this.renderBadges()}</div>
|
|
495
|
+
</div>
|
|
496
|
+
`}renderReportButton(){return this.lastNode?x`
|
|
497
|
+
<button
|
|
498
|
+
class="inspector-header-btn"
|
|
499
|
+
id="inspector-copy-report"
|
|
500
|
+
title="Copy a full text report"
|
|
501
|
+
@click=${()=>this.copyReport()}
|
|
502
|
+
>
|
|
503
|
+
Report
|
|
504
|
+
</button>
|
|
505
|
+
`:C}renderBadges(){if(this.lastNode){let e=this.lastNode;return x`
|
|
506
|
+
<button
|
|
507
|
+
type="button"
|
|
508
|
+
class="badge badge-mono badge-clickable"
|
|
509
|
+
id="inspector-copy-id"
|
|
510
|
+
title="Click to copy node ID"
|
|
511
|
+
@click=${()=>this.copyNodeId()}
|
|
512
|
+
>
|
|
513
|
+
${e.id}
|
|
514
|
+
</button>
|
|
515
|
+
${Vx(e.is_root,()=>x`<span class="badge badge-amber">Output Root</span>`)}
|
|
516
|
+
<span class="badge badge-mode">${e.filter_mode_name}</span>
|
|
517
|
+
`}if(this.lastEdge){let{edge:e}=this.lastEdge;return x`
|
|
518
|
+
<span class="badge badge-mode">${e.pattern_name}</span>
|
|
519
|
+
${Vx(e.media_label,()=>x`<span class="badge badge-amber">${e.media_label}</span>`)}
|
|
520
|
+
`}return C}renderBody(){if(this.lastNode)return x`
|
|
521
|
+
${this.renderInputsCard(this.lastNode)} ${this.renderMediaCard(this.lastNode)}
|
|
522
|
+
${this.renderPerformanceCard(this.lastNode)}
|
|
523
|
+
${this.renderCallStackCard(this.lastNode.call_stack)}
|
|
524
|
+
`;if(this.lastEdge){let{edge:e,source:t,target:n}=this.lastEdge;return x`
|
|
525
|
+
<div class="inspector-card">
|
|
526
|
+
<div class="card-title">Connection</div>
|
|
527
|
+
<div class="specs-grid">
|
|
528
|
+
${this.gridRow(`Source`,`${t.name} [${e.source}]`)}
|
|
529
|
+
${this.gridRow(`Target`,`${n.name} [${e.target}]`)}
|
|
530
|
+
${this.gridRow(`Input Slot`,`#${e.index}`)}
|
|
531
|
+
${this.gridRow(`Request Pattern`,e.pattern_name)}
|
|
532
|
+
${this.gridRow(`Media Change`,e.media_label??`unchanged`)}
|
|
533
|
+
${this.gridRow(`Edge ID`,e.id)}
|
|
534
|
+
</div>
|
|
535
|
+
</div>
|
|
536
|
+
`}return C}gridRow(e,t){return x`<div class="spec-label">${e}</div>
|
|
537
|
+
<div class="spec-value">${t}</div>`}renderInputsCard(e){let t=this.opts.getIncomingConnections(e.id);return x`
|
|
538
|
+
<div class="inspector-card">
|
|
539
|
+
<div class="card-title">Inputs</div>
|
|
540
|
+
${Vx(t.length>0,()=>x`
|
|
541
|
+
<div class="badge-list">
|
|
542
|
+
${Bx(t,e=>e.edge.id,e=>this.renderInputBadge(e))}
|
|
543
|
+
</div>
|
|
544
|
+
`,()=>x`<span class="card-empty">None (Source)</span>`)}
|
|
545
|
+
</div>
|
|
546
|
+
`}renderInputBadge(e){let t=e.source.name,n=e.source.id;return x`
|
|
547
|
+
<button
|
|
548
|
+
type="button"
|
|
549
|
+
class="badge badge-input badge-clickable"
|
|
550
|
+
title="Navigate to ${t} [${n}] (Slot #${e.edge.index})"
|
|
551
|
+
@click=${e=>{e.stopPropagation(),this.opts.onFocusNode(n)}}
|
|
552
|
+
>
|
|
553
|
+
[#${e.edge.index}] ← ${t}
|
|
554
|
+
</button>
|
|
555
|
+
`}renderMediaCard(e){let t=e.media_info,n=fx(t.fps_num,t.fps_den);return x`
|
|
556
|
+
<div class="inspector-card">
|
|
557
|
+
<div class="card-title">Video Format Specs</div>
|
|
558
|
+
<div class="specs-grid">
|
|
559
|
+
${this.gridRow(`Resolution`,`${t.width} × ${t.height}`)}
|
|
560
|
+
${this.gridRow(`Format`,t.format.name)}
|
|
561
|
+
${this.gridRow(`Frame Rate`,`${t.fps_num}/${t.fps_den} (${n} fps)`)}
|
|
562
|
+
${this.gridRow(`Total Frames`,t.num_frames.toLocaleString())}
|
|
563
|
+
${Vx(t.gpu_resident!==void 0,()=>this.gridRow(`GPU Resident`,t.gpu_resident?`Yes`:`No`))}
|
|
564
|
+
</div>
|
|
565
|
+
</div>
|
|
566
|
+
`}renderPerformanceCard(e){return x`
|
|
567
|
+
<div class="inspector-card">
|
|
568
|
+
<div class="card-title">Execution Performance</div>
|
|
569
|
+
<div class="specs-grid">
|
|
570
|
+
${Vx(this.showTimings,()=>this.gridRow(`Processing Time`,px(e.processing_time_ns,this.timingUnit)))}
|
|
571
|
+
${this.gridRow(`Concurrency Mode`,e.filter_mode_name)}
|
|
572
|
+
</div>
|
|
573
|
+
</div>
|
|
574
|
+
`}renderCallStackCard(e){let t=`Call Stack (${e.length} frame${e.length===1?``:`s`})`;return e.length===0?x`
|
|
575
|
+
<div class="inspector-card">
|
|
576
|
+
<div class="card-title">${t}</div>
|
|
577
|
+
<div class="card-empty">No call stack information recorded.</div>
|
|
578
|
+
</div>
|
|
579
|
+
`:x`
|
|
580
|
+
<div class="inspector-card">
|
|
581
|
+
<div class="card-title">${t}</div>
|
|
582
|
+
<div class="accordion">
|
|
583
|
+
${Bx(e,e=>e.level,(e,t)=>this.renderCallFrame(e,t))}
|
|
584
|
+
</div>
|
|
585
|
+
</div>
|
|
586
|
+
`}renderCallFrame(e,t){let n=this.openFrames.has(t);return x`
|
|
587
|
+
<div class=${Dx({"accordion-item":!0,active:n})}>
|
|
588
|
+
<div class="accordion-header-row">
|
|
589
|
+
<button class="accordion-header" @click=${()=>this.toggleFrame(t)}>
|
|
590
|
+
<span class="accordion-arrow">${n?`▼`:`▶`}</span>
|
|
591
|
+
<span class="accordion-frame-lvl">#${e.level}</span>
|
|
592
|
+
<span class="accordion-frame-func">${e.plugin_ns}.${e.function} </span>
|
|
593
|
+
<span class="accordion-plugin-id">${e.plugin_id}</span>
|
|
594
|
+
</button>
|
|
595
|
+
<button
|
|
596
|
+
class="card-action-btn accordion-copy-btn"
|
|
597
|
+
data-frame-idx=${t}
|
|
598
|
+
title="Copy this frame's filter call as Python"
|
|
599
|
+
@click=${e=>{e.stopPropagation(),this.copyFilterCall(t)}}
|
|
600
|
+
>
|
|
601
|
+
Copy Call
|
|
602
|
+
</button>
|
|
603
|
+
</div>
|
|
604
|
+
<div class="accordion-body">${this.renderArgumentsTable(e.arguments)}</div>
|
|
605
|
+
</div>
|
|
606
|
+
`}renderArgumentsTable(e){let t=Object.entries(e);return t.length===0?x`<div class="no-args">No arguments</div>`:x`
|
|
607
|
+
<table class="args-table">
|
|
608
|
+
<thead>
|
|
609
|
+
<tr>
|
|
610
|
+
<th>Argument</th>
|
|
611
|
+
<th>Value</th>
|
|
612
|
+
</tr>
|
|
613
|
+
</thead>
|
|
614
|
+
<tbody>
|
|
615
|
+
${Bx(t,([e])=>e,([e,t])=>this.renderArgumentRow(e,t))}
|
|
616
|
+
</tbody>
|
|
617
|
+
</table>
|
|
618
|
+
`}renderArgumentRow(e,t){return x`
|
|
619
|
+
<tr>
|
|
620
|
+
<td class="arg-key">${e}</td>
|
|
621
|
+
<td class="arg-val">${this.renderArgumentValue(e,t)}</td>
|
|
622
|
+
</tr>
|
|
623
|
+
`}renderArgumentValue(e,t){if(Yx(t))return this.renderClipBadge(String(t.id));if(Xx(t))return x`<span class="badge badge-mono">Frame [${String(t.id)}]</span>`;if(Zx(t))return x`<span class="badge badge-mono">Func [${String(t.id)}]</span>`;if(Array.isArray(t)){if(t.length===0)return`[]`;if(t.some(e=>Yx(e)||Xx(e)||Zx(e)))return x`
|
|
624
|
+
<div class="badge-list">
|
|
625
|
+
${Bx(t,(t,n)=>`${e}[${n}]`,(t,n)=>this.renderArgumentValue(`${e}[${n}]`,t))}
|
|
626
|
+
</div>
|
|
627
|
+
`}return this.formatArgumentValue(e,t)}renderClipBadge(e){return x`
|
|
628
|
+
<button
|
|
629
|
+
type="button"
|
|
630
|
+
class="badge badge-mono badge-clickable"
|
|
631
|
+
title="Navigate to node ${e}"
|
|
632
|
+
@click=${t=>{t.stopPropagation(),this.opts.onFocusNode(e)}}
|
|
633
|
+
>
|
|
634
|
+
${this.opts.resolveNode(e)?.name??`Clip`} <span class="arg-val-id">[${e}]</span>
|
|
635
|
+
</button>
|
|
636
|
+
`}formatArgumentValue(e,t){return typeof t!=`object`||!t?String(t):U.fromThrowable(()=>JSON.stringify(t)).mapErr(t=>(console.warn(`Failed to serialize argument '${e}':`,t),t)).unwrapOr(`[unserializable]`)}};function Yx(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`vnode`&&`id`in e}function Xx(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`vframe`&&`id`in e}function Zx(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`func`&&`id`in e}var Qx=class{actions;rules=[];boundKeyDown=e=>this.handleKeyDown(e);constructor(e){this.actions=e,window.addEventListener(`keydown`,this.boundKeyDown)}get keybindings(){return[...this.rules]}set keybindings(e){this.rules=[...e]}getShortcut(e){let t=this.rules.find(t=>t.action===e);return t?eS(t):null}executeAction(e,t=!1){let n=this.actions[e];if(typeof n!=`function`){let t=Error(`Unknown keybinding action: '${e}'`);return console.warn(t.message),U.err(t)}return U.fromThrowable(()=>{e===`navigateUp`||e===`navigateDown`?n(t):n()}).mapErr(t=>(console.error(`Error executing keybinding action '${e}':`,t),t))}dispose(){window.removeEventListener(`keydown`,this.boundKeyDown)}[Symbol.dispose](){this.dispose()}handleKeyDown(e){if(e.defaultPrevented||e.isComposing)return;let t=e.target;if(!(t instanceof HTMLElement&&(t.isContentEditable||[`INPUT`,`TEXTAREA`,`SELECT`].includes(t.tagName)))){if(e.key===`Escape`&&!e.ctrlKey&&!e.altKey&&!e.metaKey)e.preventDefault(),this.actions.escape();else if(!(e.target instanceof HTMLElement&&[`BUTTON`,`A`].includes(e.target.tagName)&&(e.key===`Enter`||e.key===` `))){for(let t of this.rules)if(tS(e,t)){e.preventDefault();let n=(t.action===`navigateUp`||t.action===`navigateDown`)&&e.shiftKey;this.executeAction(t.action,n);return}}}}},$x={" ":`Space`,Escape:`Esc`,ArrowUp:`↑`,ArrowDown:`↓`,ArrowLeft:`←`,ArrowRight:`→`};function eS(e){let t=[];e.ctrl&&t.push(`Ctrl`),e.alt&&t.push(`Alt`),e.shift&&t.push(`Shift`),e.meta&&t.push(`Meta`);let n=$x[e.key];return n?t.push(n):e.key.length===1?t.push(e.key.toUpperCase()):t.push(e.key),t.join(`+`)}function tS(e,t){if(t.ctrl!==e.ctrlKey||t.alt!==e.altKey||t.meta!==e.metaKey)return!1;let n=t.action===`navigateUp`||t.action===`navigateDown`,r=e.key.length===1&&!/[\p{L}\p{N}\s]/u.test(e.key);if(t.shift){if(!e.shiftKey)return!1}else if(e.shiftKey&&!n&&!r)return!1;let i=t.key.toLowerCase();switch(i){case`arrowup`:return e.key===`ArrowUp`||e.key===`ArrowLeft`;case`arrowdown`:return e.key===`ArrowDown`||e.key===`ArrowRight`;default:return i===e.key.toLowerCase()}}function nS(e){let t=new Map,n=0,r=0;for(let i of e){n+=i.processing_time_ns,i.is_root&&(r+=i.processing_time_ns);let e=i.call_stack[0]?.plugin_ns??``,a=t.get(e)??{name:e,count:0,totalTimeNs:0};a.count+=1,a.totalTimeNs+=i.processing_time_ns,t.set(e,a)}return{totalTimeNs:n,rootTimeNs:r,namespaces:[...t.values()].sort((e,t)=>t.totalTimeNs-e.totalTimeNs||e.name.localeCompare(t.name))}}var rS=15,iS=class extends J{opts;analysis=null;timings=null;nodeNames=new Map;modeFilter=null;mediaOnly=!1;isOpen=!1;expandedGroups=new Set;expandedChips=new Set;activeHighlightKey=null;constructor(e){super(),this.opts=e,this.opts.container.classList.add(`overview-container`)}get opened(){return this.isOpen}setData(e,t){this.analysis=t,this.timings=nS(e),this.nodeNames=new Map(e.map(e=>[e.id,e.name])),this.activeHighlightKey&&this.reapplyHighlight(),this.isOpen&&this.render()}updateTimings(e){this.timings=nS(e),this.isOpen&&this.render()}setPatterns(e){this.isOpen&&(this.opts.canvas.setPatternStyles(e),this.render())}toggle(){this.isOpen?this.close():this.open()}open(){this.isOpen=!0,this.opts.container.classList.add(`open`),this.render()}close(){this.isOpen=!1,this.opts.container.classList.remove(`open`),this.activeHighlightKey&&this.clearHighlight()}dispose(){this.activeHighlightKey&&this.clearHighlight(),this.expandedGroups.clear(),this.expandedChips.clear(),this.nodeNames.clear(),super.dispose()}selectMode(e){this.modeFilter=e===`all`?null:e.toUpperCase(),this.opts.canvas.setModeFilter(this.modeFilter),this.render()}togglePatterns(){let e=!this.opts.canvas.isShowingPatternStyles();this.opts.canvas.setPatternStyles(e),this.opts.onPatternsChanged(e),this.render()}toggleMediaOnly(){this.mediaOnly=!this.mediaOnly,this.opts.canvas.setMediaOnly(this.mediaOnly),this.render()}toggleGroup(e){this.expandedGroups.has(e)?this.expandedGroups.delete(e):this.expandedGroups.add(e),this.render()}toggleChips(e){this.expandedChips.has(e)?this.expandedChips.delete(e):this.expandedChips.add(e),this.render()}toggleGroupHighlight(e,t){this.activeHighlightKey===e?this.clearHighlight():(this.activeHighlightKey=e,this.opts.canvas.highlightNodeGroup(t)),this.render()}clearHighlight(){this.activeHighlightKey=null,this.opts.canvas.highlightNodeGroup(null)}reapplyHighlight(){if(!this.analysis){this.clearHighlight();return}let e=this.analysis.warningGroups.find(e=>`w:${e.code}`===this.activeHighlightKey);if(e){this.opts.canvas.highlightNodeGroup(e.nodeIds);return}let t=this.analysis.transitionGroups.find(e=>`t:${e.signature}`===this.activeHighlightKey);t?this.opts.canvas.highlightNodeGroup(t.targetNodeIds):this.clearHighlight()}render(){!this.analysis||!this.timings?z(C,this.opts.container):z(x`
|
|
637
|
+
<div class="overview-panel" role="dialog" aria-label="Graph overview">
|
|
638
|
+
<div class="overview-header">
|
|
639
|
+
<span class="overview-title">Graph Overview</span>
|
|
640
|
+
<button class="overview-close" title="Close overview" @click=${()=>this.close()}>
|
|
641
|
+
×
|
|
642
|
+
</button>
|
|
643
|
+
</div>
|
|
644
|
+
<div class="overview-body">
|
|
645
|
+
${this.renderStats(this.analysis,this.timings)} ${this.renderModes(this.analysis)}
|
|
646
|
+
${this.renderPatterns(this.analysis)} ${this.renderWarnings(this.analysis)}
|
|
647
|
+
${this.renderTransitions(this.analysis)}
|
|
648
|
+
</div>
|
|
649
|
+
</div>
|
|
650
|
+
`,this.opts.container)}row(e,t){return x`<div class="overview-label">${e}</div>
|
|
651
|
+
<div class="overview-value">${t}</div>`}renderStats(e,t){let n=t.namespaces.slice(0,3).map(e=>`${e.name} (${e.count})`).join(`, `),r=e.formats.map(e=>`${e.name} (${e.count})`).join(`, `);return x`
|
|
652
|
+
<div class="overview-section">
|
|
653
|
+
<div class="overview-section-title">Graph</div>
|
|
654
|
+
<div class="overview-grid">
|
|
655
|
+
${this.row(`Nodes`,String(e.nodeCount))}
|
|
656
|
+
${this.row(`Edges`,String(e.edgeCount))}
|
|
657
|
+
${this.row(`Depth`,String(e.depth))}
|
|
658
|
+
${this.row(`Total time`,dx(t.totalTimeNs)||`no profiling data`)}
|
|
659
|
+
${this.row(`Root time`,dx(t.rootTimeNs)||`no profiling data`)}
|
|
660
|
+
${this.row(`Top plugins`,n||`none`)}
|
|
661
|
+
${this.row(`Formats`,r||`none`)}
|
|
662
|
+
</div>
|
|
663
|
+
</div>
|
|
664
|
+
`}renderModes(e){let t=[{value:`all`,label:`All modes`,count:e.nodeCount},...e.modes.map(e=>({value:e.name,label:e.name,count:e.count}))],n=(this.modeFilter??`all`).toLowerCase();return x`
|
|
665
|
+
<div class="overview-section">
|
|
666
|
+
<div class="overview-section-title">Filter modes</div>
|
|
667
|
+
<div class="overview-chips">
|
|
668
|
+
${Bx(t,e=>e.value,e=>this.renderModeChip(e,e.value.toLowerCase()===n))}
|
|
669
|
+
</div>
|
|
670
|
+
</div>
|
|
671
|
+
`}renderModeChip(e,t){return x`
|
|
672
|
+
<button
|
|
673
|
+
class=${Dx({"overview-chip":!0,active:t})}
|
|
674
|
+
@click=${()=>this.selectMode(e.value)}
|
|
675
|
+
>
|
|
676
|
+
${e.label} <span class="overview-chip-count">${e.count}</span>
|
|
677
|
+
</button>
|
|
678
|
+
`}renderPatterns(e){let t=e.patterns.map(e=>`${e.name} (${e.count})`).join(`, `),n=this.opts.canvas.isShowingPatternStyles();return x`
|
|
679
|
+
<div class="overview-section">
|
|
680
|
+
<div class="overview-section-title">Request patterns</div>
|
|
681
|
+
<div class="overview-empty">${t||`none`}</div>
|
|
682
|
+
<button
|
|
683
|
+
class=${Dx({"overview-chip":!0,active:n})}
|
|
684
|
+
@click=${()=>this.togglePatterns()}
|
|
685
|
+
>
|
|
686
|
+
${n?`Hide pattern labels`:`Show pattern labels`}
|
|
687
|
+
</button>
|
|
688
|
+
</div>
|
|
689
|
+
`}renderWarnings(e){return e.warningCount===0?x`
|
|
690
|
+
<div class="overview-section">
|
|
691
|
+
<div class="overview-section-title">Warnings</div>
|
|
692
|
+
<div class="overview-empty">No concurrency or request-pattern warnings.</div>
|
|
693
|
+
</div>
|
|
694
|
+
`:x`
|
|
695
|
+
<div class="overview-section">
|
|
696
|
+
<div class="overview-section-title">Warnings (${e.warningCount})</div>
|
|
697
|
+
<div class="overview-groups">
|
|
698
|
+
${Bx(e.warningGroups,e=>e.code,e=>this.renderWarningGroup(e))}
|
|
699
|
+
</div>
|
|
700
|
+
</div>
|
|
701
|
+
`}renderWarningGroup(e){return this.renderAccordionGroup({key:`w:${e.code}`,title:e.title,count:e.count,countUnit:`occurrences`,highlightLabel:`affected nodes`,nodeIds:e.nodeIds,description:e.description,severityClass:`severity-${e.severity}`,chipLabelPrefix:`Focus node`})}renderTransitions(e){return e.transitionCount===0?x`
|
|
702
|
+
<div class="overview-section">
|
|
703
|
+
<div class="overview-section-title">Media changes</div>
|
|
704
|
+
<div class="overview-empty">Media info is identical across every edge.</div>
|
|
705
|
+
</div>
|
|
706
|
+
`:x`
|
|
707
|
+
<div class="overview-section">
|
|
708
|
+
<div class="overview-section-title">Media changes (${e.transitionCount})</div>
|
|
709
|
+
<button
|
|
710
|
+
class=${Dx({"overview-chip":!0,active:this.mediaOnly})}
|
|
711
|
+
style="margin-bottom: 8px;"
|
|
712
|
+
@click=${()=>this.toggleMediaOnly()}
|
|
713
|
+
>
|
|
714
|
+
${this.mediaOnly?`Show every node`:`Dim unchanged nodes`}
|
|
715
|
+
</button>
|
|
716
|
+
<div class="overview-groups">
|
|
717
|
+
${Bx(e.transitionGroups,e=>e.signature,e=>this.renderTransitionGroup(e))}
|
|
718
|
+
</div>
|
|
719
|
+
</div>
|
|
720
|
+
`}renderTransitionGroup(e){let t=e.transitions.length;return this.renderAccordionGroup({key:`t:${e.signature}`,title:e.signature,count:t,countUnit:`transitions`,highlightLabel:`target nodes`,nodeIds:e.targetNodeIds,description:`Changes ${e.fields.join(`, `)} across ${t} edge${t>1?`s`:``}.`,chipLabelPrefix:`Focus target node`})}renderAccordionGroup(e){let t=this.expandedGroups.has(e.key),n=this.activeHighlightKey===e.key,r=n?`Clear canvas highlight`:`Highlight ${e.highlightLabel} on canvas`;return x`
|
|
721
|
+
<div
|
|
722
|
+
class=${Dx({"overview-group":!0,open:t,...e.severityClass?{[e.severityClass]:!0}:{}})}
|
|
723
|
+
>
|
|
724
|
+
<div class="overview-group-header" @click=${()=>this.toggleGroup(e.key)}>
|
|
725
|
+
<div class="overview-group-info">
|
|
726
|
+
<span class="overview-group-chevron">▶</span>
|
|
727
|
+
<span class="overview-group-title" title="${e.title}">${e.title}</span>
|
|
728
|
+
<span class="overview-group-count" title="${e.count} ${e.countUnit}"
|
|
729
|
+
>${e.count}</span
|
|
730
|
+
>
|
|
731
|
+
</div>
|
|
732
|
+
<div class="overview-group-actions" @click=${e=>e.stopPropagation()}>
|
|
733
|
+
<button
|
|
734
|
+
class=${Dx({"overview-group-action-btn":!0,active:n})}
|
|
735
|
+
title="${r}"
|
|
736
|
+
@click=${()=>this.toggleGroupHighlight(e.key,e.nodeIds)}
|
|
737
|
+
>
|
|
738
|
+
${n?`Highlighted`:`Highlight`}
|
|
739
|
+
</button>
|
|
740
|
+
</div>
|
|
741
|
+
</div>
|
|
742
|
+
${Vx(t,()=>this.renderGroupBody(e))}
|
|
743
|
+
</div>
|
|
744
|
+
`}renderGroupBody(e){return x`
|
|
745
|
+
<div class="overview-group-body">
|
|
746
|
+
<div class="overview-group-desc">${e.description}</div>
|
|
747
|
+
${this.renderNodeChips(e.key,e.nodeIds,e.chipLabelPrefix??`Focus node`)}
|
|
748
|
+
</div>
|
|
749
|
+
`}renderNodeChips(e,t,n){let r=this.expandedChips.has(e),i=r?t:t.slice(0,rS),a=t.length>rS;return x`
|
|
750
|
+
<div class="overview-node-chips">
|
|
751
|
+
${Bx(i,e=>e,e=>this.renderNodeChip(e,n))}
|
|
752
|
+
${Vx(a,()=>this.renderChipToggle(e,r,t.length-rS))}
|
|
753
|
+
</div>
|
|
754
|
+
`}renderNodeChip(e,t){let n=this.nodeNames.get(e)??e;return x`
|
|
755
|
+
<button
|
|
756
|
+
class="overview-node-chip"
|
|
757
|
+
title="${t} ${n} (${e})"
|
|
758
|
+
@click=${()=>this.opts.onFocusNode(e)}
|
|
759
|
+
>
|
|
760
|
+
${n}
|
|
761
|
+
</button>
|
|
762
|
+
`}renderChipToggle(e,t,n){return x`
|
|
763
|
+
<button class="overview-chip-more" @click=${()=>this.toggleChips(e)}>
|
|
764
|
+
${t?`Show less`:`+${n} more`}
|
|
765
|
+
</button>
|
|
766
|
+
`}},aS=class extends J{currentTokens=null;listeners=[];get tokens(){return this.currentTokens}onThemeChanged(e){return this.listeners.push(e),K(()=>{let t=this.listeners.indexOf(e);t!==-1&&this.listeners.splice(t,1)})}updateTheme(e){this.currentTokens=e,this.applyToCss(e);for(let t of this.listeners)U.fromThrowable(()=>t(e)).mapErr(e=>{console.error(`Error in theme change listener:`,e)})}applyToCss(e){let t=document.documentElement;t.style.setProperty(`--bg-color`,e.bg),t.style.setProperty(`--surface-color`,e.surface),t.style.setProperty(`--surface-elevated`,e.surfaceElevated),t.style.setProperty(`--surface-hover`,e.surfaceHover),t.style.setProperty(`--border-color`,e.border),t.style.setProperty(`--text-primary`,e.textPrimary),t.style.setProperty(`--text-secondary`,e.textSecondary),t.style.setProperty(`--text-muted`,e.textMuted),t.style.setProperty(`--accent`,e.accent),t.style.setProperty(`--accent-amber`,e.accentAmber),t.style.setProperty(`--accent-emerald`,e.accentEmerald),t.style.setProperty(`--danger`,e.danger)}};function oS(e,t){let n=new Set(t.map(e=>e.target)),r=e.filter(e=>!n.has(e.id));return(r.length>0?r:e).reduce((e,t)=>e?t.depth===e.depth?t.processing_time_ns>e.processing_time_ns?t:e:t.depth>e.depth?t:e:t,null)}function sS(e,t,n,r,i,a){if(!e)return r.find(e=>e.is_root)?.id??null;let o=[...new Set(i.filter(n=>(t===`up`?n.target:n.source)===e).map(e=>t===`up`?e.source:e.target))];if(o.length===0)return null;let s=new Map(r.map(e=>[e.id,e])),c=o.sort((e,t)=>(s.get(t)?.processing_time_ns??0)-(s.get(e)?.processing_time_ns??0)||e.localeCompare(t)),l=`${e}:${t}`,u=0;if(n){let e=a.get(l);u=e===void 0?0:(e+1)%c.length}return a.set(l,u),c[u]??null}var cS=class{cursor=new Map;lastStep=null;next(e,t,n,r,i){let a=this.lastStep,o=n&&a!==null&&a.direction===t&&a.target===e?a.anchor:e,s=sS(o,t,n,r,i,this.cursor);return s!==null&&(this.lastStep=o===null?null:{anchor:o,direction:t,target:s}),s}reset(){this.cursor.clear(),this.lastStep=null}},lS=class extends J{bridge;canvas;hud;inspector;overview;themeManager;keybindings;loadingOverlay;errorBanner;navigator=new cS;constructor(e){super(),this.loadingOverlay=e.loadingOverlay,this.errorBanner=e.errorBanner,this.themeManager=this._disposables.add(new aS),this.bridge=this._disposables.add(new re),this.canvas=this._disposables.add(new Cx),this.inspector=this._disposables.add(new Jx({container:e.inspectorContainer,onCopyNode:(e,t,n)=>this.bridge.sendEvent(`node.copy`,n===void 0?{id:e,target:t}:{id:e,target:t,frameIdx:n}),resolveNode:e=>this.canvas.getNodeById(e),resolveEdge:e=>this.canvas.getEdgeById(e),getIncomingConnections:e=>this.canvas.getIncomingConnections(e),onFocusNode:e=>this.focusNode(e)})),this.overview=this._disposables.add(new iS({container:e.overviewContainer,canvas:this.canvas,onFocusNode:e=>this.focusNode(e),onPatternsChanged:e=>this.syncHudOptions(e)})),this.keybindings=this._disposables.add(new Qx({navigateUp:e=>this.navigate(`up`,e),navigateDown:e=>this.navigate(`down`,e),selectRoot:()=>this.selectRoot(),selectDeepestLeaf:()=>this.selectDeepestLeaf(),centerSelected:()=>{let e=this.canvas.selectedId;e&&this.canvas.centerNode(e)},escape:()=>this.handleEscape(),resetView:()=>this.canvas.reset(),fit:()=>this.canvas.fit(),toggleHeatmap:()=>this.toggleHeatmap(),togglePatterns:()=>this.togglePatterns(),toggleOverview:()=>this.overview.toggle(),reload:()=>{this.bridge.sendEvent(`graph.reload`)},focusSearch:()=>this.hud.focusSearch()})),this.canvas.init(e.cyContainer),this._disposables.add(this.canvas.onBackgroundContextMenu(()=>this.bridge.sendEvent(`contextmenu.request`,{direction:this.canvas.direction}))),this.hud=this._disposables.add(new qx({container:e.hudContainer,canvas:this.canvas,onReloadRequested:()=>this.bridge.sendEvent(`graph.reload`),onOutputSelected:e=>this.bridge.sendEvent(`output.select`,{index:e}),onNodeMatched:e=>this.focusNode(e),onPatternsToggled:e=>this.overview.setPatterns(e),onOverviewRequested:()=>this.overview.toggle()})),this._disposables.add(this.canvas.onEdgeSelected((e,t,n)=>{this.inspector.inspectEdge(e,t,n)})),this.setupSubscriptions()}async start(){(await this.bridge.initBridge()).match({ok:()=>{console.debug(`Bridge initialized successfully`)},err:e=>{window.ENV?.VSVIEW?this.showErrorBanner(`Could not connect to vsview: ${e.message}`):console.warn(`Bridge initialization failed (standalone browser mode?):`,e),this.hideLoadingOverlay()}})}setupSubscriptions(){this._disposables.add(this.themeManager.onThemeChanged(e=>{this.canvas.applyTheme(e)})),this._disposables.add(this.canvas.onNodeSelected(e=>{this.inspector.inspectNode(e),this.bridge.sendEvent(`node.select`,{id:e.id})})),this._disposables.add(this.canvas.onSelectionCleared(()=>{this.inspector.close(),this.bridge.sendEvent(`node.deselect`)})),this._disposables.add(this.bridge.onCommand(`graph.setOptions`,e=>{this.canvas.applyOptions(e),this.inspector.setTimingOptions(this.canvas.isShowingTimings(),this.canvas.getTimingUnit()),this.syncHudOptions()})),this._disposables.add(this.bridge.onCommand(`graph.setData`,e=>{this.hideErrorBanner(),this.navigator.reset(),this.canvas.setGraphData(e,!0),this.inspector.refresh(),this.overview.setData(this.canvas.getNodes(),e.analysis),this.hud.refreshSearch(!1),this.hideLoadingOverlay()})),this._disposables.add(this.bridge.onCommand(`graph.updateTimings`,e=>{this.hideErrorBanner(),this.canvas.updateTimings(e.timings),this.overview.updateTimings(this.canvas.getNodes()),this.inspector.refresh()})),this._disposables.add(this.bridge.onCommand(`graph.setOutputs`,e=>this.hud.setOutputs(e.outputs,e.following))),this._disposables.add(this.bridge.onCommand(`graph.selectNode`,e=>{if(this.canvas.selectedId===e.id)return;let t=this.canvas.selectNodeById(e.id);t?this.inspector.inspectNode(t):console.warn(`Cannot select node '${e.id}': node not found in graph`)})),this._disposables.add(this.bridge.onCommand(`graph.setError`,e=>{this.showErrorBanner(e.message),this.hideLoadingOverlay()})),this._disposables.add(this.bridge.onCommand(`theme.update`,e=>this.themeManager.updateTheme(e))),this._disposables.add(this.bridge.onCommand(`graph.setKeybindings`,e=>this.keybindings.keybindings=e.keybindings)),this._disposables.add(this.bridge.onCommand(`graph.fitView`,()=>this.canvas.fit())),this._disposables.add(this.bridge.onCommand(`graph.resetView`,()=>this.canvas.reset())),this._disposables.add(this.bridge.onCommand(`graph.requestPngExport`,e=>{this.canvas.exportPng().match({ok:t=>{this.bridge.sendEvent(`graph.saveImage`,{format:`png`,dataBase64:t,destination:e.destination})},err:e=>console.error(`Failed to export graph as PNG:`,e)})}))}syncHudOptions(e){this.hud.syncOptions({direction:this.canvas.direction,heatmap:this.canvas.heatmapActive,patterns:e??this.canvas.isShowingPatternStyles()})}focusNode(e){let t=this.canvas.selectNodeById(e);t?(this.canvas.centerNode(e),this.inspector.inspectNode(t),this.bridge.sendEvent(`node.select`,{id:e})):console.warn(`Cannot focus node '${e}': node not found in graph`)}clearSelection(){this.canvas.clearSelection(),this.inspector.close(),this.bridge.sendEvent(`node.deselect`)}handleEscape(){this.overview.opened?this.overview.close():this.inspector.opened?this.inspector.close():this.clearSelection()}navigate(e,t){let n=this.navigator.next(this.canvas.selectedId,e,t,this.canvas.getNodes(),this.canvas.getEdges());n&&this.focusNode(n)}selectRoot(){let e=this.canvas.getNodes().find(e=>e.is_root)?.id;e&&this.focusNode(e)}selectDeepestLeaf(){let e=oS(this.canvas.getNodes(),this.canvas.getEdges());e&&this.focusNode(e.id)}toggleHeatmap(){this.canvas.heatmapActive=!this.canvas.heatmapActive,this.syncHudOptions()}togglePatterns(){let e=!this.canvas.isShowingPatternStyles();this.canvas.setPatternStyles(e),this.overview.setPatterns(e),this.syncHudOptions(e)}hideLoadingOverlay(){this.loadingOverlay.isConnected&&!this.loadingOverlay.classList.contains(`fade-out`)&&(this.loadingOverlay.classList.add(`fade-out`),this.loadingOverlay.addEventListener(`transitionend`,()=>this.loadingOverlay.remove(),{once:!0}))}showErrorBanner(e){this.errorBanner.textContent=e,this.errorBanner.classList.add(`visible`)}hideErrorBanner(){this.errorBanner.classList.remove(`visible`),this.errorBanner.textContent=``}},uS=`loading-overlay`,dS=[`cy`,`hud`,`inspector-drawer`,`overview`,uS,`error-banner`];async function fS(){let e=pS();if(!e.ok){mS(e.error);return}let t=U.fromThrowable(()=>new lS({cyContainer:e.value.cy,hudContainer:e.value.hud,inspectorContainer:e.value[`inspector-drawer`],overviewContainer:e.value.overview,loadingOverlay:e.value[uS],errorBanner:e.value[`error-banner`]}));if(!t.ok){mS(t.error);return}let n=t.value;window.addEventListener(`unload`,()=>n.dispose(),{once:!0}),await n.start()}function pS(){let e={};for(let t of dS){let n=document.getElementById(t);if(!n)return U.err(Error(`Required DOM element '#${t}' was not found`));e[t]=n}return U.ok(e)}function mS(e){let t=`The dependency graph failed to start.`;console.error(t,e);let n=document.getElementById(uS);n||(n=document.createElement(`div`),n.id=uS,document.body.appendChild(n)),n.classList.remove(`fade-out`),n.classList.add(`startup-error`),n.replaceChildren(),z(x`
|
|
767
|
+
<div class="loading-text" role="alert">${t}</div>
|
|
768
|
+
<div class="loading-text">${e instanceof Error?e.message:String(e)}</div>
|
|
769
|
+
`,n)}U.fromPromise(fS).mapErr(mS);
|