@mcp-graph-workflow/mcp-graph 5.20.1 → 5.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web/dashboard/dist/assets/{benchmark-tab-BxKC16Rh.js → benchmark-tab-CA0tgawW.js} +1 -1
- package/dist/web/dashboard/dist/assets/{context-tab-CyTA0xHn.js → context-tab-CwKPhEgw.js} +1 -1
- package/dist/web/dashboard/dist/assets/{gitnexus-tab-Caz7v7Mn.js → gitnexus-tab-D6MEUR3O.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-section-B2T_NMja.js → graph-section-CyaVBqJB.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-tab-H8UjUBJg.js → graph-tab-xMRobj4G.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-utils-CpifDP5W.js → graph-utils-dWjSQUrT.js} +1 -1
- package/dist/web/dashboard/dist/assets/{index-C9AGF8Ai.js → index-BKNOfKcX.js} +1 -1
- package/dist/web/dashboard/dist/assets/{index-BPPSD6wP.js → index-BpSI95md.js} +1 -1
- package/dist/web/dashboard/dist/assets/{index-CW7bjrwy.js → index-DUIBILM9.js} +2 -2
- package/dist/web/dashboard/dist/assets/index-QMfM-nWT.css +1 -0
- package/dist/web/dashboard/dist/assets/{insights-tab-8XuKAe-4.js → insights-tab-qfYmJM2I.js} +1 -1
- package/dist/web/dashboard/dist/assets/{journey-tab-L-g_jwf1.js → journey-tab-BB5ei9Re.js} +1 -1
- package/dist/web/dashboard/dist/assets/languages-tab-CrgWsmId.js +75 -0
- package/dist/web/dashboard/dist/assets/{logs-tab-Y5DvtoGU.js → logs-tab-CQ8bSvRy.js} +1 -1
- package/dist/web/dashboard/dist/assets/{lsp-tab-Dprc5zKc.js → lsp-tab-BKKSyuSj.js} +12 -22
- package/dist/web/dashboard/dist/assets/{memories-tab-DvgKhmWu.js → memories-tab-BshQ8DL8.js} +1 -1
- package/dist/web/dashboard/dist/assets/{prd-backlog-tab-OHV_0-dF.js → prd-backlog-tab-nfXaOLTF.js} +1 -1
- package/dist/web/dashboard/dist/assets/{siebel-tab-Bkeox_-_.js → siebel-tab-rX5raaJc.js} +3 -3
- package/dist/web/dashboard/dist/assets/{skills-tab-DCHjQiA2.js → skills-tab-DyX_XWmC.js} +1 -1
- package/dist/web/dashboard/dist/assets/{style-Cca8j3c-.js → style-D_2CfpkF.js} +1 -1
- package/dist/web/dashboard/dist/assets/triangle-alert-T9o21Q4O.js +21 -0
- package/dist/web/dashboard/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/dashboard/dist/assets/index-DDQD2WTj.css +0 -1
- package/dist/web/dashboard/dist/assets/languages-tab-171i5Bxw.js +0 -63
- package/dist/web/dashboard/dist/assets/triangle-alert-uww45pBS.js +0 -11
package/dist/web/dashboard/dist/assets/{benchmark-tab-BxKC16Rh.js → benchmark-tab-CA0tgawW.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as u,a as h,j as e}from"./index-
|
|
1
|
+
import{r as u,a as h,j as e}from"./index-DUIBILM9.js";function v(){const[r,d]=u.useState(null),[x,t]=u.useState(!0),[a,m]=u.useState(null);return u.useEffect(()=>{async function n(){try{const i=await h.request("/benchmark");d(i)}catch(i){m(i instanceof Error?i.message:"Failed to load benchmark data")}finally{t(!1)}}n()},[]),{data:r,loading:x,error:a}}function j(){const{data:r,loading:d,error:x}=v();if(d)return e.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:"Loading benchmark data..."});if(x)return e.jsxs("div",{className:"flex items-center justify-center h-full text-danger",children:["Failed to load: ",x]});if(!r)return e.jsx("div",{});const{tokenEconomy:t,layeredCompression:a,dependencyIntelligence:m,toolTokenUsage:n,formulas:i}=r;return e.jsxs("div",{className:"p-6 max-w-5xl mx-auto space-y-6 overflow-y-auto h-full",children:[e.jsxs("section",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-3",children:"Token Economy"}),e.jsxs("div",{className:"grid grid-cols-4 gap-3 mb-4",children:[e.jsx(s,{value:`${t.avgCompressionPercent}%`,label:"Avg Compress"}),e.jsx(s,{value:t.sampleSize>0?Math.round(t.totalTokensSaved/t.sampleSize).toLocaleString():"0",label:"Tokens Saved/Task"}),e.jsx(s,{value:t.totalNodes,label:"Nodes"}),e.jsx(s,{value:t.totalEdges,label:"Edges"})]}),t.perTaskMetrics.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-muted mb-2",children:"Context Compression per Task (vs Full Graph)"}),e.jsx("div",{className:"space-y-1.5","data-testid":"compression-bars",children:t.perTaskMetrics.slice(0,15).map(l=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-32 truncate",title:l.title,children:l.title}),e.jsx("div",{className:"flex-1 h-3 bg-surface-elevated rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-accent",style:{width:`${Math.min(l.compressionPercent,100)}%`}})}),e.jsxs("span",{className:"text-muted w-24 text-right",children:[l.compressionPercent,"% (",l.estimatedTokens," tok)"]})]},l.id))})]})]}),a&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-3",children:"Real Token Savings (Per-Layer)"}),e.jsxs("div",{className:"grid grid-cols-5 gap-3 mb-4",children:[e.jsx(s,{value:`${a.avgLayer1SavingsPercent}%`,label:"L1: Field Strip"}),e.jsx(s,{value:`${a.avgLayer2SavingsPercent}%`,label:"L2: Desc Truncate"}),e.jsx(s,{value:`${a.avgLayer3SavingsPercent}%`,label:"L3: Default Omit"}),e.jsx(s,{value:`${a.avgLayer4SavingsPercent}%`,label:"L4: Short Keys"}),e.jsx(s,{value:`${a.avgTotalRealSavingsPercent}%`,label:"Total Real Savings"})]}),(()=>{const l=Math.max(a.avgNaiveNeighborhoodTokens,1),o=[{label:"Naive Neighborhood",tokens:a.avgNaiveNeighborhoodTokens,color:"#ef4444"},{label:"L1: Field Stripping",tokens:a.avgCompactContextTokens,color:"#f97316"},{label:"L2: Desc Truncation",tokens:a.avgNeighborTruncatedTokens,color:"#eab308"},{label:"L3: Default Omission",tokens:a.avgDefaultOmittedTokens,color:"#22c55e"},{label:"L4: Short Keys",tokens:a.avgShortKeysTokens,color:"#3b82f6"},{label:"Summary Tier",tokens:a.avgSummaryTierTokens,color:"#8b5cf6"}];return e.jsx("div",{className:"space-y-1.5","data-testid":"waterfall-bars",children:o.map(c=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-40 truncate",title:c.label,children:c.label}),e.jsx("div",{className:"flex-1 h-3 bg-surface-elevated rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.min(c.tokens/l*100,100)}%`,backgroundColor:c.color}})}),e.jsxs("span",{className:"text-muted w-20 text-right",children:[c.tokens.toLocaleString()," tok"]})]},c.label))})})()]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-3",children:"Dependency Intelligence"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(s,{value:m.inferredDeps,label:"Auto Inferred"}),e.jsx(s,{value:`${m.blockedTasks}/${t.totalNodes}`,label:"Blocked Detected"}),e.jsx(s,{value:m.cycles,label:"Cycles Detected"})]})]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-3",children:"Formulas & Justification"}),e.jsx("div",{className:"px-3 py-2 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt text-xs space-y-1","data-testid":"formulas-section",children:Object.entries(i).map(([l,o])=>e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("span",{className:"text-muted font-mono w-40 shrink-0",children:[l,":"]}),e.jsx("span",{children:o})]},l))})]}),n&&n.totalCalls>0&&e.jsxs("section",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-3",children:"Tool Token Usage"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 mb-4",children:[e.jsx(s,{value:n.totalCalls.toLocaleString(),label:"Total Calls"}),e.jsx(s,{value:n.totalInputTokens.toLocaleString(),label:"Total Input Tokens"}),e.jsx(s,{value:n.totalOutputTokens.toLocaleString(),label:"Total Output Tokens"})]}),n.perTool.length>0&&(()=>{const l=Math.max(...n.perTool.map(o=>o.totalTokens),1);return e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-muted mb-2",children:"Token Usage per Tool"}),e.jsx("div",{className:"space-y-1.5","data-testid":"tool-token-bars",children:n.perTool.slice(0,15).map(o=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-32 truncate font-mono",title:o.toolName,children:o.toolName}),e.jsx("div",{className:"flex-1 h-3 bg-surface-elevated rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-accent",style:{width:`${Math.min(o.totalTokens/l*100,100)}%`}})}),e.jsxs("span",{className:"text-muted w-32 text-right",children:[o.callCount," calls, ",o.totalTokens.toLocaleString()," tok"]})]},o.toolName))})]})})()]}),e.jsxs("section",{children:[e.jsx("h3",{className:"text-sm font-semibold mb-3",children:"Cost Savings per Task"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(s,{value:`$${t.costSavings.opusPerTask.toFixed(3)}`,label:"Opus Input"}),e.jsx(s,{value:`$${t.costSavings.sonnetPerTask.toFixed(3)}`,label:"Sonnet Input"})]})]})]})}function s({value:r,label:d}){return e.jsxs("div",{className:"p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt text-center","data-testid":"metric-card",children:[e.jsx("div",{className:"text-xl font-bold",children:r}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:d})]})}export{j as BenchmarkTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,a as x,j as e}from"./index-
|
|
1
|
+
import{r,a as x,j as e}from"./index-DUIBILM9.js";function h(){const[t,c]=r.useState(null),[o,l]=r.useState(!0),[d,n]=r.useState(null),s=r.useCallback(async()=>{l(!0),n(null);try{const a=await x.getContextBudget();c(a)}catch(a){n(a instanceof Error?a.message:"Failed to load context budget")}finally{l(!1)}},[]);return r.useEffect(()=>{s()},[s]),{budget:t,loading:o,error:d,refresh:s}}const i={green:{bg:"bg-green-500/10",text:"text-green-500",border:"border-green-500/30"},yellow:{bg:"bg-yellow-500/10",text:"text-yellow-500",border:"border-yellow-500/30"},red:{bg:"bg-red-500/10",text:"text-red-500",border:"border-red-500/30"}};function m(){const{budget:t,loading:c,error:o,refresh:l}=h();if(o)return e.jsxs("div",{className:"flex items-center justify-center h-full text-danger",children:["Failed to load context budget: ",o]});if(c||!t)return e.jsx("div",{className:"flex items-center justify-center h-full text-muted",children:"Loading context budget..."});const d=i[t.health]??i.green,n=async s=>{await x.toggleSkill(s,!1),l()};return e.jsxs("div",{className:"p-6 max-w-6xl mx-auto space-y-6 overflow-y-auto h-full",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Context Management"}),e.jsx("button",{onClick:()=>l(),className:"text-xs px-3 py-1.5 rounded-lg bg-accent text-white hover:opacity-90 transition-opacity",children:"Refresh"})]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt text-center",children:[e.jsx("div",{className:"text-xl font-bold",children:t.activeTokens.toLocaleString()}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:"Active Tokens"})]}),e.jsxs("div",{className:"p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt text-center",children:[e.jsx("div",{className:"text-xl font-bold",children:t.totalTokens.toLocaleString()}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:"Total Tokens"})]}),e.jsxs("div",{className:"p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt text-center",children:[e.jsx("div",{className:"text-xl font-bold",children:t.activeCount}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:"Active Skills"})]}),e.jsxs("div",{className:"p-3 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt text-center",children:[e.jsx("div",{className:"text-xl font-bold",children:t.totalCount}),e.jsx("div",{className:"text-[10px] text-muted uppercase",children:"Total Skills"})]})]}),e.jsxs("div",{className:`p-4 rounded-lg border ${d.bg} ${d.border}`,children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-3 h-3 rounded-full ${t.health==="green"?"bg-green-500":t.health==="yellow"?"bg-yellow-500":"bg-red-500"}`}),e.jsxs("div",{children:[e.jsxs("div",{className:`text-sm font-medium ${d.text}`,children:["Session Health: ",t.health.charAt(0).toUpperCase()+t.health.slice(1)]}),e.jsx("div",{className:"text-xs text-muted mt-0.5",children:t.healthMessage})]})]}),t.recommendations.length>0&&e.jsx("div",{className:"mt-3 space-y-1",children:t.recommendations.map((s,a)=>e.jsx("div",{className:"text-xs text-muted",children:s},a))})]}),e.jsxs("div",{className:"p-4 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Token Budget"}),e.jsxs("span",{className:"text-xs text-muted",children:[t.activeTokens.toLocaleString()," / 4,000 (",Math.round(t.activeTokens/40),"%)"]})]}),e.jsxs("div",{className:"w-full h-3 rounded-full bg-edge relative",children:[e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 opacity-20",style:{width:`${Math.min(Math.round(t.totalTokens/40),100)}%`,background:"#6b7280"}}),e.jsx("div",{className:"h-full rounded-full absolute top-0 left-0 transition-all",style:{width:`${Math.min(Math.round(t.activeTokens/40),100)}%`,background:t.health==="red"?"#ef4444":t.health==="yellow"?"#f59e0b":"#10b981"}})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold text-muted uppercase",children:"Token Breakdown by Skill"}),e.jsx("div",{className:"space-y-1",children:t.breakdown.map(s=>{const a=t.totalTokens>0?Math.round(s.tokens/t.totalTokens*100):0;return e.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-xl border border-edge shadow-sm hover:shadow-md transition-shadow bg-surface-alt ${s.enabled?"":"opacity-40"}`,children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium truncate",children:s.name}),e.jsx("span",{className:`px-1 py-0.5 rounded text-[9px] ${s.source==="custom"?"bg-purple-500/10 text-purple-500":"bg-blue-500/10 text-blue-500"}`,children:s.source})]}),e.jsx("div",{className:"w-full h-1 rounded-full bg-edge mt-1",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${a}%`,background:s.enabled?"#3b82f6":"#6b7280"}})})]}),e.jsxs("span",{className:"text-[10px] text-muted shrink-0 w-16 text-right",children:[s.tokens.toLocaleString()," tok"]}),s.enabled&&e.jsx("button",{onClick:()=>void n(s.name),className:"text-[10px] px-1.5 py-0.5 rounded border border-edge text-muted hover:text-red-500 hover:border-red-500/50 shrink-0",children:"Disable"})]},s.name)})})]})]})}export{m as ContextTab};
|
package/dist/web/dashboard/dist/assets/{gitnexus-tab-Caz7v7Mn.js → gitnexus-tab-D6MEUR3O.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as $r,r as G,t as Et,j as g,a as Oe,O as Ii}from"./index-CW7bjrwy.js";import{C as we,b as pt,c as Ur}from"./constants-lq4BIQN3.js";var st={exports:{}},Xt;function Oi(){if(Xt)return st.exports;Xt=1;var n=typeof Reflect=="object"?Reflect:null,r=n&&typeof n.apply=="function"?n.apply:function(y,S,C){return Function.prototype.apply.call(y,S,C)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(y){return Object.getOwnPropertyNames(y).concat(Object.getOwnPropertySymbols(y))}:t=function(y){return Object.getOwnPropertyNames(y)};function e(m){console&&console.warn&&console.warn(m)}var i=Number.isNaN||function(y){return y!==y};function a(){a.init.call(this)}st.exports=a,st.exports.once=L,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var o=10;function s(m){if(typeof m!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof m)}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(m){if(typeof m!="number"||m<0||i(m))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+m+".");o=m}}),a.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(y){if(typeof y!="number"||y<0||i(y))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+y+".");return this._maxListeners=y,this};function u(m){return m._maxListeners===void 0?a.defaultMaxListeners:m._maxListeners}a.prototype.getMaxListeners=function(){return u(this)},a.prototype.emit=function(y){for(var S=[],C=1;C<arguments.length;C++)S.push(arguments[C]);var P=y==="error",O=this._events;if(O!==void 0)P=P&&O.error===void 0;else if(!P)return!1;if(P){var z;if(S.length>0&&(z=S[0]),z instanceof Error)throw z;var Y=new Error("Unhandled error."+(z?" ("+z.message+")":""));throw Y.context=z,Y}var j=O[y];if(j===void 0)return!1;if(typeof j=="function")r(j,this,S);else for(var p=j.length,Q=b(j,p),C=0;C<p;++C)r(Q[C],this,S);return!0};function l(m,y,S,C){var P,O,z;if(s(S),O=m._events,O===void 0?(O=m._events=Object.create(null),m._eventsCount=0):(O.newListener!==void 0&&(m.emit("newListener",y,S.listener?S.listener:S),O=m._events),z=O[y]),z===void 0)z=O[y]=S,++m._eventsCount;else if(typeof z=="function"?z=O[y]=C?[S,z]:[z,S]:C?z.unshift(S):z.push(S),P=u(m),P>0&&z.length>P&&!z.warned){z.warned=!0;var Y=new Error("Possible EventEmitter memory leak detected. "+z.length+" "+String(y)+" listeners added. Use emitter.setMaxListeners() to increase limit");Y.name="MaxListenersExceededWarning",Y.emitter=m,Y.type=y,Y.count=z.length,e(Y)}return m}a.prototype.addListener=function(y,S){return l(this,y,S,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(y,S){return l(this,y,S,!0)};function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(m,y,S){var C={fired:!1,wrapFn:void 0,target:m,type:y,listener:S},P=h.bind(C);return P.listener=S,C.wrapFn=P,P}a.prototype.once=function(y,S){return s(S),this.on(y,d(this,y,S)),this},a.prototype.prependOnceListener=function(y,S){return s(S),this.prependListener(y,d(this,y,S)),this},a.prototype.removeListener=function(y,S){var C,P,O,z,Y;if(s(S),P=this._events,P===void 0)return this;if(C=P[y],C===void 0)return this;if(C===S||C.listener===S)--this._eventsCount===0?this._events=Object.create(null):(delete P[y],P.removeListener&&this.emit("removeListener",y,C.listener||S));else if(typeof C!="function"){for(O=-1,z=C.length-1;z>=0;z--)if(C[z]===S||C[z].listener===S){Y=C[z].listener,O=z;break}if(O<0)return this;O===0?C.shift():w(C,O),C.length===1&&(P[y]=C[0]),P.removeListener!==void 0&&this.emit("removeListener",y,Y||S)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(y){var S,C,P;if(C=this._events,C===void 0)return this;if(C.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):C[y]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete C[y]),this;if(arguments.length===0){var O=Object.keys(C),z;for(P=0;P<O.length;++P)z=O[P],z!=="removeListener"&&this.removeAllListeners(z);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(S=C[y],typeof S=="function")this.removeListener(y,S);else if(S!==void 0)for(P=S.length-1;P>=0;P--)this.removeListener(y,S[P]);return this};function c(m,y,S){var C=m._events;if(C===void 0)return[];var P=C[y];return P===void 0?[]:typeof P=="function"?S?[P.listener||P]:[P]:S?E(P):b(P,P.length)}a.prototype.listeners=function(y){return c(this,y,!0)},a.prototype.rawListeners=function(y){return c(this,y,!1)},a.listenerCount=function(m,y){return typeof m.listenerCount=="function"?m.listenerCount(y):f.call(m,y)},a.prototype.listenerCount=f;function f(m){var y=this._events;if(y!==void 0){var S=y[m];if(typeof S=="function")return 1;if(S!==void 0)return S.length}return 0}a.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function b(m,y){for(var S=new Array(y),C=0;C<y;++C)S[C]=m[C];return S}function w(m,y){for(;y+1<m.length;y++)m[y]=m[y+1];m.pop()}function E(m){for(var y=new Array(m.length),S=0;S<y.length;++S)y[S]=m[S].listener||m[S];return y}function L(m,y){return new Promise(function(S,C){function P(z){m.removeListener(y,O),C(z)}function O(){typeof m.removeListener=="function"&&m.removeListener("error",P),S([].slice.call(arguments))}R(m,y,O,{once:!0}),y!=="error"&&_(m,P,{once:!0})})}function _(m,y,S){typeof m.on=="function"&&R(m,"error",y,S)}function R(m,y,S,C){if(typeof m.on=="function")C.once?m.once(y,S):m.on(y,S);else if(typeof m.addEventListener=="function")m.addEventListener(y,function P(O){C.once&&m.removeEventListener(y,P),S(O)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof m)}return st.exports}var jr=Oi();function zi(){const n=arguments[0];for(let r=1,t=arguments.length;r<t;r++)if(arguments[r])for(const e in arguments[r])n[e]=arguments[r][e];return n}let te=zi;typeof Object.assign=="function"&&(te=Object.assign);function fe(n,r,t,e){const i=n._nodes.get(r);let a=null;return i&&(e==="mixed"?a=i.out&&i.out[t]||i.undirected&&i.undirected[t]:e==="directed"?a=i.out&&i.out[t]:a=i.undirected&&i.undirected[t]),a}function oe(n){return typeof n=="object"&&n!==null}function Mr(n){let r;for(r in n)return!1;return!0}function de(n,r,t){Object.defineProperty(n,r,{enumerable:!1,configurable:!1,writable:!0,value:t})}function ve(n,r,t){const e={enumerable:!0,configurable:!0};typeof t=="function"?e.get=t:(e.value=t,e.writable=!1),Object.defineProperty(n,r,e)}function Qt(n){return!(!oe(n)||n.attributes&&!Array.isArray(n.attributes))}function $i(){let n=Math.floor(Math.random()*256)&255;return()=>n++}function ke(){const n=arguments;let r=null,t=-1;return{[Symbol.iterator](){return this},next(){let e=null;do{if(r===null){if(t++,t>=n.length)return{done:!0};r=n[t][Symbol.iterator]()}if(e=r.next(),e.done){r=null;continue}break}while(!0);return e}}}function Ve(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Bt extends Error{constructor(r){super(),this.name="GraphError",this.message=r}}class D extends Bt{constructor(r){super(r),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,D.prototype.constructor)}}class A extends Bt{constructor(r){super(r),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,A.prototype.constructor)}}class U extends Bt{constructor(r){super(r),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,U.prototype.constructor)}}function Br(n,r){this.key=n,this.attributes=r,this.clear()}Br.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Hr(n,r){this.key=n,this.attributes=r,this.clear()}Hr.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Wr(n,r){this.key=n,this.attributes=r,this.clear()}Wr.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function qe(n,r,t,e,i){this.key=r,this.attributes=i,this.undirected=n,this.source=t,this.target=e}qe.prototype.attach=function(){let n="out",r="in";this.undirected&&(n=r="undirected");const t=this.source.key,e=this.target.key;this.source[n][e]=this,!(this.undirected&&t===e)&&(this.target[r][t]=this)};qe.prototype.attachMulti=function(){let n="out",r="in";const t=this.source.key,e=this.target.key;this.undirected&&(n=r="undirected");const i=this.source[n],a=i[e];if(typeof a>"u"){i[e]=this,this.undirected&&t===e||(this.target[r][t]=this);return}a.previous=this,this.next=a,i[e]=this,this.target[r][t]=this};qe.prototype.detach=function(){const n=this.source.key,r=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),delete this.source[t][r],delete this.target[e][n]};qe.prototype.detachMulti=function(){const n=this.source.key,r=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][r],delete this.target[e][n]):(this.next.previous=void 0,this.source[t][r]=this.next,this.target[e][n]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const Vr=0,qr=1,Ui=2,Kr=3;function Ae(n,r,t,e,i,a,o){let s,u,l,h;if(e=""+e,t===Vr){if(s=n._nodes.get(e),!s)throw new A(`Graph.${r}: could not find the "${e}" node in the graph.`);l=i,h=a}else if(t===Kr){if(i=""+i,u=n._edges.get(i),!u)throw new A(`Graph.${r}: could not find the "${i}" edge in the graph.`);const d=u.source.key,c=u.target.key;if(e===d)s=u.target;else if(e===c)s=u.source;else throw new A(`Graph.${r}: the "${e}" node is not attached to the "${i}" edge (${d}, ${c}).`);l=a,h=o}else{if(u=n._edges.get(e),!u)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`);t===qr?s=u.source:s=u.target,l=i,h=a}return[s,l,h]}function ji(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);return o.attributes[s]}}function Mi(n,r,t){n.prototype[r]=function(e,i){const[a]=Ae(this,r,t,e,i);return a.attributes}}function Bi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);return o.attributes.hasOwnProperty(s)}}function Hi(n,r,t){n.prototype[r]=function(e,i,a,o){const[s,u,l]=Ae(this,r,t,e,i,a,o);return s.attributes[u]=l,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Wi(n,r,t){n.prototype[r]=function(e,i,a,o){const[s,u,l]=Ae(this,r,t,e,i,a,o);if(typeof l!="function")throw new D(`Graph.${r}: updater should be a function.`);const h=s.attributes,d=l(h[u]);return h[u]=d,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Vi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);return delete o.attributes[s],this.emit("nodeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:s}),this}}function qi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);if(!oe(s))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return o.attributes=s,this.emit("nodeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Ki(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);if(!oe(s))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return te(o.attributes,s),this.emit("nodeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:s}),this}}function Yi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);if(typeof s!="function")throw new D(`Graph.${r}: provided updater is not a function.`);return o.attributes=s(o.attributes),this.emit("nodeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const Zi=[{name:n=>`get${n}Attribute`,attacher:ji},{name:n=>`get${n}Attributes`,attacher:Mi},{name:n=>`has${n}Attribute`,attacher:Bi},{name:n=>`set${n}Attribute`,attacher:Hi},{name:n=>`update${n}Attribute`,attacher:Wi},{name:n=>`remove${n}Attribute`,attacher:Vi},{name:n=>`replace${n}Attributes`,attacher:qi},{name:n=>`merge${n}Attributes`,attacher:Ki},{name:n=>`update${n}Attributes`,attacher:Yi}];function Xi(n){Zi.forEach(function({name:r,attacher:t}){t(n,r("Node"),Vr),t(n,r("Source"),qr),t(n,r("Target"),Ui),t(n,r("Opposite"),Kr)})}function Qi(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return a.attributes[i]}}function Ji(n,r,t){n.prototype[r]=function(e){let i;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,o=""+arguments[1];if(i=fe(this,a,o,t),!i)throw new A(`Graph.${r}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,i=this._edges.get(e),!i)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return i.attributes}}function en(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return a.attributes.hasOwnProperty(i)}}function tn(n,r,t){n.prototype[r]=function(e,i,a){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+e,u=""+i;if(i=arguments[2],a=arguments[3],o=fe(this,s,u,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return o.attributes[i]=a,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function rn(n,r,t){n.prototype[r]=function(e,i,a){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+e,u=""+i;if(i=arguments[2],a=arguments[3],o=fe(this,s,u,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(typeof a!="function")throw new D(`Graph.${r}: updater should be a function.`);return o.attributes[i]=a(o.attributes[i]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function nn(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return delete a.attributes[i],this.emit("edgeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:i}),this}}function an(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!oe(i))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return a.attributes=i,this.emit("edgeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function on(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!oe(i))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return te(a.attributes,i),this.emit("edgeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:i}),this}}function sn(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(typeof i!="function")throw new D(`Graph.${r}: provided updater is not a function.`);return a.attributes=i(a.attributes),this.emit("edgeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}const un=[{name:n=>`get${n}Attribute`,attacher:Qi},{name:n=>`get${n}Attributes`,attacher:Ji},{name:n=>`has${n}Attribute`,attacher:en},{name:n=>`set${n}Attribute`,attacher:tn},{name:n=>`update${n}Attribute`,attacher:rn},{name:n=>`remove${n}Attribute`,attacher:nn},{name:n=>`replace${n}Attributes`,attacher:an},{name:n=>`merge${n}Attributes`,attacher:on},{name:n=>`update${n}Attributes`,attacher:sn}];function ln(n){un.forEach(function({name:r,attacher:t}){t(n,r("Edge"),"mixed"),t(n,r("DirectedEdge"),"directed"),t(n,r("UndirectedEdge"),"undirected")})}const hn=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function dn(n,r,t,e){let i=!1;for(const a in r){if(a===e)continue;const o=r[a];if(i=t(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),n&&i)return o.key}}function cn(n,r,t,e){let i,a,o,s=!1;for(const u in r)if(u!==e){i=r[u];do{if(a=i.source,o=i.target,s=t(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected),n&&s)return i.key;i=i.next}while(i!==void 0)}}function xt(n,r){const t=Object.keys(n),e=t.length;let i,a=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(a>=e)return{done:!0};const o=t[a++];if(o===r){i=void 0;continue}i=n[o]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function fn(n,r,t,e){const i=r[t];if(!i)return;const a=i.source,o=i.target;if(e(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected)&&n)return i.key}function gn(n,r,t,e){let i=r[t];if(!i)return;let a=!1;do{if(a=e(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),n&&a)return i.key;i=i.next}while(i!==void 0)}function _t(n,r){let t=n[r];if(t.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!t)return{done:!0};const i={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:i}}};let e=!1;return{[Symbol.iterator](){return this},next(){return e===!0?{done:!0}:(e=!0,{done:!1,value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected}})}}}function pn(n,r){if(n.size===0)return[];if(r==="mixed"||r===n.type)return Array.from(n._edges.keys());const t=r==="undirected"?n.undirectedSize:n.directedSize,e=new Array(t),i=r==="undirected",a=n._edges.values();let o=0,s,u;for(;s=a.next(),s.done!==!0;)u=s.value,u.undirected===i&&(e[o++]=u.key);return e}function Yr(n,r,t,e){if(r.size===0)return;const i=t!=="mixed"&&t!==r.type,a=t==="undirected";let o,s,u=!1;const l=r._edges.values();for(;o=l.next(),o.done!==!0;){if(s=o.value,i&&s.undirected!==a)continue;const{key:h,attributes:d,source:c,target:f}=s;if(u=e(h,d,c.key,f.key,c.attributes,f.attributes,s.undirected),n&&u)return h}}function mn(n,r){if(n.size===0)return Ve();const t=r!=="mixed"&&r!==n.type,e=r==="undirected",i=n._edges.values();return{[Symbol.iterator](){return this},next(){let a,o;for(;;){if(a=i.next(),a.done)return a;if(o=a.value,!(t&&o.undirected!==e))break}return{value:{edge:o.key,attributes:o.attributes,source:o.source.key,target:o.target.key,sourceAttributes:o.source.attributes,targetAttributes:o.target.attributes,undirected:o.undirected},done:!1}}}}function Ht(n,r,t,e,i,a){const o=r?cn:dn;let s;if(t!=="undirected"&&(e!=="out"&&(s=o(n,i.in,a),n&&s)||e!=="in"&&(s=o(n,i.out,a,e?void 0:i.key),n&&s))||t!=="directed"&&(s=o(n,i.undirected,a),n&&s))return s}function vn(n,r,t,e){const i=[];return Ht(!1,n,r,t,e,function(a){i.push(a)}),i}function yn(n,r,t){let e=Ve();return n!=="undirected"&&(r!=="out"&&typeof t.in<"u"&&(e=ke(e,xt(t.in))),r!=="in"&&typeof t.out<"u"&&(e=ke(e,xt(t.out,r?void 0:t.key)))),n!=="directed"&&typeof t.undirected<"u"&&(e=ke(e,xt(t.undirected))),e}function Wt(n,r,t,e,i,a,o){const s=t?gn:fn;let u;if(r!=="undirected"&&(typeof i.in<"u"&&e!=="out"&&(u=s(n,i.in,a,o),n&&u)||typeof i.out<"u"&&e!=="in"&&(e||i.key!==a)&&(u=s(n,i.out,a,o),n&&u))||r!=="directed"&&typeof i.undirected<"u"&&(u=s(n,i.undirected,a,o),n&&u))return u}function bn(n,r,t,e,i){const a=[];return Wt(!1,n,r,t,e,i,function(o){a.push(o)}),a}function wn(n,r,t,e){let i=Ve();return n!=="undirected"&&(typeof t.in<"u"&&r!=="out"&&e in t.in&&(i=ke(i,_t(t.in,e))),typeof t.out<"u"&&r!=="in"&&e in t.out&&(r||t.key!==e)&&(i=ke(i,_t(t.out,e)))),n!=="directed"&&typeof t.undirected<"u"&&e in t.undirected&&(i=ke(i,_t(t.undirected,e))),i}function En(n,r){const{name:t,type:e,direction:i}=r;n.prototype[t]=function(a,o){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];if(!arguments.length)return pn(this,e);if(arguments.length===1){a=""+a;const s=this._nodes.get(a);if(typeof s>"u")throw new A(`Graph.${t}: could not find the "${a}" node in the graph.`);return vn(this.multi,e==="mixed"?this.type:e,i,s)}if(arguments.length===2){a=""+a,o=""+o;const s=this._nodes.get(a);if(!s)throw new A(`Graph.${t}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(o))throw new A(`Graph.${t}: could not find the "${o}" target node in the graph.`);return bn(e,this.multi,i,s,o)}throw new D(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function xn(n,r){const{name:t,type:e,direction:i}=r,a="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(l,h,d){if(!(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)){if(arguments.length===1)return d=l,Yr(!1,this,e,d);if(arguments.length===2){l=""+l,d=h;const c=this._nodes.get(l);if(typeof c>"u")throw new A(`Graph.${a}: could not find the "${l}" node in the graph.`);return Ht(!1,this.multi,e==="mixed"?this.type:e,i,c,d)}if(arguments.length===3){l=""+l,h=""+h;const c=this._nodes.get(l);if(!c)throw new A(`Graph.${a}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(h))throw new A(`Graph.${a}: could not find the "${h}" target node in the graph.`);return Wt(!1,e,this.multi,i,c,h,d)}throw new D(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const o="map"+t[0].toUpperCase()+t.slice(1);n.prototype[o]=function(){const l=Array.prototype.slice.call(arguments),h=l.pop();let d;if(l.length===0){let c=0;e!=="directed"&&(c+=this.undirectedSize),e!=="undirected"&&(c+=this.directedSize),d=new Array(c);let f=0;l.push((b,w,E,L,_,R,m)=>{d[f++]=h(b,w,E,L,_,R,m)})}else d=[],l.push((c,f,b,w,E,L,_)=>{d.push(h(c,f,b,w,E,L,_))});return this[a].apply(this,l),d};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(){const l=Array.prototype.slice.call(arguments),h=l.pop(),d=[];return l.push((c,f,b,w,E,L,_)=>{h(c,f,b,w,E,L,_)&&d.push(c)}),this[a].apply(this,l),d};const u="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[u]=function(){let l=Array.prototype.slice.call(arguments);if(l.length<2||l.length>4)throw new D(`Graph.${u}: invalid number of arguments (expecting 2, 3 or 4 and got ${l.length}).`);if(typeof l[l.length-1]=="function"&&typeof l[l.length-2]!="function")throw new D(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let h,d;l.length===2?(h=l[0],d=l[1],l=[]):l.length===3?(h=l[1],d=l[2],l=[l[0]]):l.length===4&&(h=l[2],d=l[3],l=[l[0],l[1]]);let c=d;return l.push((f,b,w,E,L,_,R)=>{c=h(c,f,b,w,E,L,_,R)}),this[a].apply(this,l),c}}function _n(n,r){const{name:t,type:e,direction:i}=r,a="find"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(u,l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return!1;if(arguments.length===1)return h=u,Yr(!0,this,e,h);if(arguments.length===2){u=""+u,h=l;const d=this._nodes.get(u);if(typeof d>"u")throw new A(`Graph.${a}: could not find the "${u}" node in the graph.`);return Ht(!0,this.multi,e==="mixed"?this.type:e,i,d,h)}if(arguments.length===3){u=""+u,l=""+l;const d=this._nodes.get(u);if(!d)throw new A(`Graph.${a}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(l))throw new A(`Graph.${a}: could not find the "${l}" target node in the graph.`);return Wt(!0,e,this.multi,i,d,l,h)}throw new D(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const o="some"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[o]=function(){const u=Array.prototype.slice.call(arguments),l=u.pop();return u.push((d,c,f,b,w,E,L)=>l(d,c,f,b,w,E,L)),!!this[a].apply(this,u)};const s="every"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[s]=function(){const u=Array.prototype.slice.call(arguments),l=u.pop();return u.push((d,c,f,b,w,E,L)=>!l(d,c,f,b,w,E,L)),!this[a].apply(this,u)}}function Cn(n,r){const{name:t,type:e,direction:i}=r,a=t.slice(0,-1)+"Entries";n.prototype[a]=function(o,s){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return Ve();if(!arguments.length)return mn(this,e);if(arguments.length===1){o=""+o;const u=this._nodes.get(o);if(!u)throw new A(`Graph.${a}: could not find the "${o}" node in the graph.`);return yn(e,i,u)}if(arguments.length===2){o=""+o,s=""+s;const u=this._nodes.get(o);if(!u)throw new A(`Graph.${a}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new A(`Graph.${a}: could not find the "${s}" target node in the graph.`);return wn(e,i,u,s)}throw new D(`Graph.${a}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Sn(n){hn.forEach(r=>{En(n,r),xn(n,r),_n(n,r),Cn(n,r)})}const Tn=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function mt(){this.A=null,this.B=null}mt.prototype.wrap=function(n){this.A===null?this.A=n:this.B===null&&(this.B=n)};mt.prototype.has=function(n){return this.A!==null&&n in this.A||this.B!==null&&n in this.B};function Ze(n,r,t,e,i){for(const a in e){const o=e[a],s=o.source,u=o.target,l=s===t?u:s;if(r&&r.has(l.key))continue;const h=i(l.key,l.attributes);if(n&&h)return l.key}}function Vt(n,r,t,e,i){if(r!=="mixed"){if(r==="undirected")return Ze(n,null,e,e.undirected,i);if(typeof t=="string")return Ze(n,null,e,e[t],i)}const a=new mt;let o;if(r!=="undirected"){if(t!=="out"){if(o=Ze(n,null,e,e.in,i),n&&o)return o;a.wrap(e.in)}if(t!=="in"){if(o=Ze(n,a,e,e.out,i),n&&o)return o;a.wrap(e.out)}}if(r!=="directed"&&(o=Ze(n,a,e,e.undirected,i),n&&o))return o}function Rn(n,r,t){if(n!=="mixed"){if(n==="undirected")return Object.keys(t.undirected);if(typeof r=="string")return Object.keys(t[r])}const e=[];return Vt(!1,n,r,t,function(i){e.push(i)}),e}function Xe(n,r,t){const e=Object.keys(t),i=e.length;let a=0;return{[Symbol.iterator](){return this},next(){let o=null;do{if(a>=i)return n&&n.wrap(t),{done:!0};const s=t[e[a++]],u=s.source,l=s.target;if(o=u===r?l:u,n&&n.has(o.key)){o=null;continue}}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function kn(n,r,t){if(n!=="mixed"){if(n==="undirected")return Xe(null,t,t.undirected);if(typeof r=="string")return Xe(null,t,t[r])}let e=Ve();const i=new mt;return n!=="undirected"&&(r!=="out"&&(e=ke(e,Xe(i,t,t.in))),r!=="in"&&(e=ke(e,Xe(i,t,t.out)))),n!=="directed"&&(e=ke(e,Xe(i,t,t.undirected))),e}function An(n,r){const{name:t,type:e,direction:i}=r;n.prototype[t]=function(a){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];a=""+a;const o=this._nodes.get(a);if(typeof o>"u")throw new A(`Graph.${t}: could not find the "${a}" node in the graph.`);return Rn(e==="mixed"?this.type:e,i,o)}}function Ln(n,r){const{name:t,type:e,direction:i}=r,a="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;l=""+l;const d=this._nodes.get(l);if(typeof d>"u")throw new A(`Graph.${a}: could not find the "${l}" node in the graph.`);Vt(!1,e==="mixed"?this.type:e,i,d,h)};const o="map"+t[0].toUpperCase()+t.slice(1);n.prototype[o]=function(l,h){const d=[];return this[a](l,(c,f)=>{d.push(h(c,f))}),d};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(l,h){const d=[];return this[a](l,(c,f)=>{h(c,f)&&d.push(c)}),d};const u="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[u]=function(l,h,d){if(arguments.length<3)throw new D(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let c=d;return this[a](l,(f,b)=>{c=h(c,f,b)}),c}}function Dn(n,r){const{name:t,type:e,direction:i}=r,a=t[0].toUpperCase()+t.slice(1,-1),o="find"+a;n.prototype[o]=function(l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;l=""+l;const d=this._nodes.get(l);if(typeof d>"u")throw new A(`Graph.${o}: could not find the "${l}" node in the graph.`);return Vt(!0,e==="mixed"?this.type:e,i,d,h)};const s="some"+a;n.prototype[s]=function(l,h){return!!this[o](l,h)};const u="every"+a;n.prototype[u]=function(l,h){return!this[o](l,(c,f)=>!h(c,f))}}function Gn(n,r){const{name:t,type:e,direction:i}=r,a=t.slice(0,-1)+"Entries";n.prototype[a]=function(o){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return Ve();o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new A(`Graph.${a}: could not find the "${o}" node in the graph.`);return kn(e==="mixed"?this.type:e,i,s)}}function Nn(n){Tn.forEach(r=>{An(n,r),Ln(n,r),Dn(n,r),Gn(n,r)})}function ut(n,r,t,e,i){const a=e._nodes.values(),o=e.type;let s,u,l,h,d,c;for(;s=a.next(),s.done!==!0;){let f=!1;if(u=s.value,o!=="undirected"){h=u.out;for(l in h){d=h[l];do c=d.target,f=!0,i(u.key,c.key,u.attributes,c.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}if(o!=="directed"){h=u.undirected;for(l in h)if(!(r&&u.key>l)){d=h[l];do c=d.target,c.key!==l&&(c=d.source),f=!0,i(u.key,c.key,u.attributes,c.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}t&&!f&&i(u.key,null,u.attributes,null,null,null,null)}}function Fn(n,r){const t={key:n};return Mr(r.attributes)||(t.attributes=te({},r.attributes)),t}function Pn(n,r,t){const e={key:r,source:t.source.key,target:t.target.key};return Mr(t.attributes)||(e.attributes=te({},t.attributes)),n==="mixed"&&t.undirected&&(e.undirected=!0),e}function In(n){if(!oe(n))throw new D('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in n))throw new D("Graph.import: serialized node is missing its key.");if("attributes"in n&&(!oe(n.attributes)||n.attributes===null))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function On(n){if(!oe(n))throw new D('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in n))throw new D("Graph.import: serialized edge is missing its source.");if(!("target"in n))throw new D("Graph.import: serialized edge is missing its target.");if("attributes"in n&&(!oe(n.attributes)||n.attributes===null))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in n&&typeof n.undirected!="boolean")throw new D("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const zn=$i(),$n=new Set(["directed","undirected","mixed"]),Jt=new Set(["domain","_events","_eventsCount","_maxListeners"]),Un=[{name:n=>`${n}Edge`,generateKey:!0},{name:n=>`${n}DirectedEdge`,generateKey:!0,type:"directed"},{name:n=>`${n}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:n=>`${n}EdgeWithKey`},{name:n=>`${n}DirectedEdgeWithKey`,type:"directed"},{name:n=>`${n}UndirectedEdgeWithKey`,type:"undirected"}],jn={allowSelfLoops:!0,multi:!1,type:"mixed"};function Mn(n,r,t){if(t&&!oe(t))throw new D(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(r=""+r,t=t||{},n._nodes.has(r))throw new U(`Graph.addNode: the "${r}" node already exist in the graph.`);const e=new n.NodeDataClass(r,t);return n._nodes.set(r,e),n.emit("nodeAdded",{key:r,attributes:t}),e}function er(n,r,t){const e=new n.NodeDataClass(r,t);return n._nodes.set(r,e),n.emit("nodeAdded",{key:r,attributes:t}),e}function Zr(n,r,t,e,i,a,o,s){if(!e&&n.type==="undirected")throw new U(`Graph.${r}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(e&&n.type==="directed")throw new U(`Graph.${r}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!oe(s))throw new D(`Graph.${r}: invalid attributes. Expecting an object but got "${s}"`);if(a=""+a,o=""+o,s=s||{},!n.allowSelfLoops&&a===o)throw new U(`Graph.${r}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const u=n._nodes.get(a),l=n._nodes.get(o);if(!u)throw new A(`Graph.${r}: source node "${a}" not found.`);if(!l)throw new A(`Graph.${r}: target node "${o}" not found.`);const h={key:null,undirected:e,source:a,target:o,attributes:s};if(t)i=n._edgeKeyGenerator();else if(i=""+i,n._edges.has(i))throw new U(`Graph.${r}: the "${i}" edge already exists in the graph.`);if(!n.multi&&(e?typeof u.undirected[o]<"u":typeof u.out[o]<"u"))throw new U(`Graph.${r}: an edge linking "${a}" to "${o}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const d=new qe(e,i,u,l,s);n._edges.set(i,d);const c=a===o;return e?(u.undirectedDegree++,l.undirectedDegree++,c&&(u.undirectedLoops++,n._undirectedSelfLoopCount++)):(u.outDegree++,l.inDegree++,c&&(u.directedLoops++,n._directedSelfLoopCount++)),n.multi?d.attachMulti():d.attach(),e?n._undirectedSize++:n._directedSize++,h.key=i,n.emit("edgeAdded",h),i}function Bn(n,r,t,e,i,a,o,s,u){if(!e&&n.type==="undirected")throw new U(`Graph.${r}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(e&&n.type==="directed")throw new U(`Graph.${r}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(s){if(u){if(typeof s!="function")throw new D(`Graph.${r}: invalid updater function. Expecting a function but got "${s}"`)}else if(!oe(s))throw new D(`Graph.${r}: invalid attributes. Expecting an object but got "${s}"`)}a=""+a,o=""+o;let l;if(u&&(l=s,s=void 0),!n.allowSelfLoops&&a===o)throw new U(`Graph.${r}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let h=n._nodes.get(a),d=n._nodes.get(o),c,f;if(!t&&(c=n._edges.get(i),c)){if((c.source.key!==a||c.target.key!==o)&&(!e||c.source.key!==o||c.target.key!==a))throw new U(`Graph.${r}: inconsistency detected when attempting to merge the "${i}" edge with "${a}" source & "${o}" target vs. ("${c.source.key}", "${c.target.key}").`);f=c}if(!f&&!n.multi&&h&&(f=e?h.undirected[o]:h.out[o]),f){const _=[f.key,!1,!1,!1];if(u?!l:!s)return _;if(u){const R=f.attributes;f.attributes=l(R),n.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else te(f.attributes,s),n.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:s});return _}s=s||{},u&&l&&(s=l(s));const b={key:null,undirected:e,source:a,target:o,attributes:s};if(t)i=n._edgeKeyGenerator();else if(i=""+i,n._edges.has(i))throw new U(`Graph.${r}: the "${i}" edge already exists in the graph.`);let w=!1,E=!1;h||(h=er(n,a,{}),w=!0,a===o&&(d=h,E=!0)),d||(d=er(n,o,{}),E=!0),c=new qe(e,i,h,d,s),n._edges.set(i,c);const L=a===o;return e?(h.undirectedDegree++,d.undirectedDegree++,L&&(h.undirectedLoops++,n._undirectedSelfLoopCount++)):(h.outDegree++,d.inDegree++,L&&(h.directedLoops++,n._directedSelfLoopCount++)),n.multi?c.attachMulti():c.attach(),e?n._undirectedSize++:n._directedSize++,b.key=i,n.emit("edgeAdded",b),[i,!0,w,E]}function Me(n,r){n._edges.delete(r.key);const{source:t,target:e,attributes:i}=r,a=r.undirected,o=t===e;a?(t.undirectedDegree--,e.undirectedDegree--,o&&(t.undirectedLoops--,n._undirectedSelfLoopCount--)):(t.outDegree--,e.inDegree--,o&&(t.directedLoops--,n._directedSelfLoopCount--)),n.multi?r.detachMulti():r.detach(),a?n._undirectedSize--:n._directedSize--,n.emit("edgeDropped",{key:r.key,attributes:i,source:t.key,target:e.key,undirected:a})}class X extends jr.EventEmitter{constructor(r){if(super(),r=te({},jn,r),typeof r.multi!="boolean")throw new D(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${r.multi}".`);if(!$n.has(r.type))throw new D(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${r.type}".`);if(typeof r.allowSelfLoops!="boolean")throw new D(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${r.allowSelfLoops}".`);const t=r.type==="mixed"?Br:r.type==="directed"?Hr:Wr;de(this,"NodeDataClass",t);const e="geid_"+zn()+"_";let i=0;const a=()=>{let o;do o=e+i++;while(this._edges.has(o));return o};de(this,"_attributes",{}),de(this,"_nodes",new Map),de(this,"_edges",new Map),de(this,"_directedSize",0),de(this,"_undirectedSize",0),de(this,"_directedSelfLoopCount",0),de(this,"_undirectedSelfLoopCount",0),de(this,"_edgeKeyGenerator",a),de(this,"_options",r),Jt.forEach(o=>de(this,o,this[o])),ve(this,"order",()=>this._nodes.size),ve(this,"size",()=>this._edges.size),ve(this,"directedSize",()=>this._directedSize),ve(this,"undirectedSize",()=>this._undirectedSize),ve(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),ve(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),ve(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),ve(this,"multi",this._options.multi),ve(this,"type",this._options.type),ve(this,"allowSelfLoops",this._options.allowSelfLoops),ve(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(r){return this._nodes.has(""+r)}hasDirectedEdge(r,t){if(this.type==="undirected")return!1;if(arguments.length===1){const e=""+r,i=this._edges.get(e);return!!i&&!i.undirected}else if(arguments.length===2){r=""+r,t=""+t;const e=this._nodes.get(r);return e?e.out.hasOwnProperty(t):!1}throw new D(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(r,t){if(this.type==="directed")return!1;if(arguments.length===1){const e=""+r,i=this._edges.get(e);return!!i&&i.undirected}else if(arguments.length===2){r=""+r,t=""+t;const e=this._nodes.get(r);return e?e.undirected.hasOwnProperty(t):!1}throw new D(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(r,t){if(arguments.length===1){const e=""+r;return this._edges.has(e)}else if(arguments.length===2){r=""+r,t=""+t;const e=this._nodes.get(r);return e?typeof e.out<"u"&&e.out.hasOwnProperty(t)||typeof e.undirected<"u"&&e.undirected.hasOwnProperty(t):!1}throw new D(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(r,t){if(this.type==="undirected")return;if(r=""+r,t=""+t,this.multi)throw new U("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const e=this._nodes.get(r);if(!e)throw new A(`Graph.directedEdge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new A(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);const i=e.out&&e.out[t]||void 0;if(i)return i.key}undirectedEdge(r,t){if(this.type==="directed")return;if(r=""+r,t=""+t,this.multi)throw new U("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const e=this._nodes.get(r);if(!e)throw new A(`Graph.undirectedEdge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new A(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);const i=e.undirected&&e.undirected[t]||void 0;if(i)return i.key}edge(r,t){if(this.multi)throw new U("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.edge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new A(`Graph.edge: could not find the "${t}" target node in the graph.`);const i=e.out&&e.out[t]||e.undirected&&e.undirected[t]||void 0;if(i)return i.key}areDirectedNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areDirectedNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.in||t in e.out}areOutNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areOutNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.out}areInNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areInNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.in}areUndirectedNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areUndirectedNeighbors: could not find the "${r}" node in the graph.`);return this.type==="directed"?!1:t in e.undirected}areNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&(t in e.in||t in e.out)||this.type!=="directed"&&t in e.undirected}areInboundNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areInboundNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&t in e.in||this.type!=="directed"&&t in e.undirected}areOutboundNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areOutboundNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&t in e.out||this.type!=="directed"&&t in e.undirected}inDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.directedDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.undirectedDegree: could not find the "${r}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inboundDegree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree),e}outboundDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outboundDegree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.outDegree),e}degree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.degree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree),e}inDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.directedDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree,i+=t.directedLoops),e-i}outboundDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.outDegree,i+=t.directedLoops),e-i}degreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.degreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree,i+=t.directedLoops*2),e-i}source(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.source: could not find the "${r}" edge in the graph.`);return t.source.key}target(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.target: could not find the "${r}" edge in the graph.`);return t.target.key}extremities(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.extremities: could not find the "${r}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(r,t){r=""+r,t=""+t;const e=this._edges.get(t);if(!e)throw new A(`Graph.opposite: could not find the "${t}" edge in the graph.`);const i=e.source.key,a=e.target.key;if(r===i)return a;if(r===a)return i;throw new A(`Graph.opposite: the "${r}" node is not attached to the "${t}" edge (${i}, ${a}).`)}hasExtremity(r,t){r=""+r,t=""+t;const e=this._edges.get(r);if(!e)throw new A(`Graph.hasExtremity: could not find the "${r}" edge in the graph.`);return e.source.key===t||e.target.key===t}isUndirected(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isUndirected: could not find the "${r}" edge in the graph.`);return t.undirected}isDirected(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isDirected: could not find the "${r}" edge in the graph.`);return!t.undirected}isSelfLoop(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isSelfLoop: could not find the "${r}" edge in the graph.`);return t.source===t.target}addNode(r,t){return Mn(this,r,t).key}mergeNode(r,t){if(t&&!oe(t))throw new D(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);r=""+r,t=t||{};let e=this._nodes.get(r);return e?(t&&(te(e.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:r,attributes:e.attributes,data:t})),[r,!1]):(e=new this.NodeDataClass(r,t),this._nodes.set(r,e),this.emit("nodeAdded",{key:r,attributes:t}),[r,!0])}updateNode(r,t){if(t&&typeof t!="function")throw new D(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);r=""+r;let e=this._nodes.get(r);if(e){if(t){const a=e.attributes;e.attributes=t(a),this.emit("nodeAttributesUpdated",{type:"replace",key:r,attributes:e.attributes})}return[r,!1]}const i=t?t({}):{};return e=new this.NodeDataClass(r,i),this._nodes.set(r,e),this.emit("nodeAdded",{key:r,attributes:i}),[r,!0]}dropNode(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.dropNode: could not find the "${r}" node in the graph.`);let e;if(this.type!=="undirected"){for(const i in t.out){e=t.out[i];do Me(this,e),e=e.next;while(e)}for(const i in t.in){e=t.in[i];do Me(this,e),e=e.next;while(e)}}if(this.type!=="directed")for(const i in t.undirected){e=t.undirected[i];do Me(this,e),e=e.next;while(e)}this._nodes.delete(r),this.emit("nodeDropped",{key:r,attributes:t.attributes})}dropEdge(r){let t;if(arguments.length>1){const e=""+arguments[0],i=""+arguments[1];if(t=fe(this,e,i,this.type),!t)throw new A(`Graph.dropEdge: could not find the "${e}" -> "${i}" edge in the graph.`)}else if(r=""+r,t=this._edges.get(r),!t)throw new A(`Graph.dropEdge: could not find the "${r}" edge in the graph.`);return Me(this,t),this}dropDirectedEdge(r,t){if(arguments.length<2)throw new U("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new U("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");r=""+r,t=""+t;const e=fe(this,r,t,"directed");if(!e)throw new A(`Graph.dropDirectedEdge: could not find a "${r}" -> "${t}" edge in the graph.`);return Me(this,e),this}dropUndirectedEdge(r,t){if(arguments.length<2)throw new U("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new U("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const e=fe(this,r,t,"undirected");if(!e)throw new A(`Graph.dropUndirectedEdge: could not find a "${r}" -> "${t}" edge in the graph.`);return Me(this,e),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const r=this._nodes.values();let t;for(;t=r.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(r){return this._attributes[r]}getAttributes(){return this._attributes}hasAttribute(r){return this._attributes.hasOwnProperty(r)}setAttribute(r,t){return this._attributes[r]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:r}),this}updateAttribute(r,t){if(typeof t!="function")throw new D("Graph.updateAttribute: updater should be a function.");const e=this._attributes[r];return this._attributes[r]=t(e),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:r}),this}removeAttribute(r){return delete this._attributes[r],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:r}),this}replaceAttributes(r){if(!oe(r))throw new D("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=r,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(r){if(!oe(r))throw new D("Graph.mergeAttributes: provided attributes are not a plain object.");return te(this._attributes,r),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:r}),this}updateAttributes(r){if(typeof r!="function")throw new D("Graph.updateAttributes: provided updater is not a function.");return this._attributes=r(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(r,t){if(typeof r!="function")throw new D("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!Qt(t))throw new D("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._nodes.values();let i,a;for(;i=e.next(),i.done!==!0;)a=i.value,a.attributes=r(a.key,a.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(r,t){if(typeof r!="function")throw new D("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!Qt(t))throw new D("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._edges.values();let i,a,o,s;for(;i=e.next(),i.done!==!0;)a=i.value,o=a.source,s=a.target,a.attributes=r(a.key,a.attributes,o.key,s.key,o.attributes,s.attributes,a.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(r){if(typeof r!="function")throw new D("Graph.forEachAdjacencyEntry: expecting a callback.");ut(!1,!1,!1,this,r)}forEachAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new D("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");ut(!1,!1,!0,this,r)}forEachAssymetricAdjacencyEntry(r){if(typeof r!="function")throw new D("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");ut(!1,!0,!1,this,r)}forEachAssymetricAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new D("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");ut(!1,!0,!0,this,r)}nodes(){return Array.from(this._nodes.keys())}forEachNode(r){if(typeof r!="function")throw new D("Graph.forEachNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)i=e.value,r(i.key,i.attributes)}findNode(r){if(typeof r!="function")throw new D("Graph.findNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)if(i=e.value,r(i.key,i.attributes))return i.key}mapNodes(r){if(typeof r!="function")throw new D("Graph.mapNode: expecting a callback.");const t=this._nodes.values();let e,i;const a=new Array(this.order);let o=0;for(;e=t.next(),e.done!==!0;)i=e.value,a[o++]=r(i.key,i.attributes);return a}someNode(r){if(typeof r!="function")throw new D("Graph.someNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)if(i=e.value,r(i.key,i.attributes))return!0;return!1}everyNode(r){if(typeof r!="function")throw new D("Graph.everyNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)if(i=e.value,!r(i.key,i.attributes))return!1;return!0}filterNodes(r){if(typeof r!="function")throw new D("Graph.filterNodes: expecting a callback.");const t=this._nodes.values();let e,i;const a=[];for(;e=t.next(),e.done!==!0;)i=e.value,r(i.key,i.attributes)&&a.push(i.key);return a}reduceNodes(r,t){if(typeof r!="function")throw new D("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new D("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let e=t;const i=this._nodes.values();let a,o;for(;a=i.next(),a.done!==!0;)o=a.value,e=r(e,o.key,o.attributes);return e}nodeEntries(){const r=this._nodes.values();return{[Symbol.iterator](){return this},next(){const t=r.next();if(t.done)return t;const e=t.value;return{value:{node:e.key,attributes:e.attributes},done:!1}}}}export(){const r=new Array(this._nodes.size);let t=0;this._nodes.forEach((i,a)=>{r[t++]=Fn(a,i)});const e=new Array(this._edges.size);return t=0,this._edges.forEach((i,a)=>{e[t++]=Pn(this.type,a,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:r,edges:e}}import(r,t=!1){if(r instanceof X)return r.forEachNode((u,l)=>{t?this.mergeNode(u,l):this.addNode(u,l)}),r.forEachEdge((u,l,h,d,c,f,b)=>{t?b?this.mergeUndirectedEdgeWithKey(u,h,d,l):this.mergeDirectedEdgeWithKey(u,h,d,l):b?this.addUndirectedEdgeWithKey(u,h,d,l):this.addDirectedEdgeWithKey(u,h,d,l)}),this;if(!oe(r))throw new D("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(r.attributes){if(!oe(r.attributes))throw new D("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(r.attributes):this.replaceAttributes(r.attributes)}let e,i,a,o,s;if(r.nodes){if(a=r.nodes,!Array.isArray(a))throw new D("Graph.import: invalid nodes. Expecting an array.");for(e=0,i=a.length;e<i;e++){o=a[e],In(o);const{key:u,attributes:l}=o;t?this.mergeNode(u,l):this.addNode(u,l)}}if(r.edges){let u=!1;if(this.type==="undirected"&&(u=!0),a=r.edges,!Array.isArray(a))throw new D("Graph.import: invalid edges. Expecting an array.");for(e=0,i=a.length;e<i;e++){s=a[e],On(s);const{source:l,target:h,attributes:d,undirected:c=u}=s;let f;"key"in s?(f=t?c?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:c?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,s.key,l,h,d)):(f=t?c?this.mergeUndirectedEdge:this.mergeDirectedEdge:c?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,l,h,d))}}return this}nullCopy(r){const t=new X(te({},this._options,r));return t.replaceAttributes(te({},this.getAttributes())),t}emptyCopy(r){const t=this.nullCopy(r);return this._nodes.forEach((e,i)=>{const a=te({},e.attributes);e=new t.NodeDataClass(i,a),t._nodes.set(i,e)}),t}copy(r){if(r=r||{},typeof r.type=="string"&&r.type!==this.type&&r.type!=="mixed")throw new U(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${r.type}" because this would mean losing information about the current graph.`);if(typeof r.multi=="boolean"&&r.multi!==this.multi&&r.multi!==!0)throw new U("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof r.allowSelfLoops=="boolean"&&r.allowSelfLoops!==this.allowSelfLoops&&r.allowSelfLoops!==!0)throw new U("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const t=this.emptyCopy(r),e=this._edges.values();let i,a;for(;i=e.next(),i.done!==!0;)a=i.value,Zr(t,"copy",!1,a.undirected,a.key,a.source.key,a.target.key,te({},a.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const r={};this._nodes.forEach((a,o)=>{r[o]=a.attributes});const t={},e={};this._edges.forEach((a,o)=>{const s=a.undirected?"--":"->";let u="",l=a.source.key,h=a.target.key,d;a.undirected&&l>h&&(d=l,l=h,h=d);const c=`(${l})${s}(${h})`;o.startsWith("geid_")?this.multi&&(typeof e[c]>"u"?e[c]=0:e[c]++,u+=`${e[c]}. `):u+=`[${o}]: `,u+=c,t[u]=a.attributes});const i={};for(const a in this)this.hasOwnProperty(a)&&!Jt.has(a)&&typeof this[a]!="function"&&typeof a!="symbol"&&(i[a]=this[a]);return i.attributes=this._attributes,i.nodes=r,i.edges=t,de(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(X.prototype[Symbol.for("nodejs.util.inspect.custom")]=X.prototype.inspect);Un.forEach(n=>{["add","merge","update"].forEach(r=>{const t=n.name(r),e=r==="add"?Zr:Bn;n.generateKey?X.prototype[t]=function(i,a,o){return e(this,t,!0,(n.type||this.type)==="undirected",null,i,a,o,r==="update")}:X.prototype[t]=function(i,a,o,s){return e(this,t,!1,(n.type||this.type)==="undirected",i,a,o,s,r==="update")}})});Xi(X);ln(X);Sn(X);Nn(X);class Xr extends X{constructor(r){const t=te({type:"directed"},r);if("multi"in t&&t.multi!==!1)throw new D("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new D('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Qr extends X{constructor(r){const t=te({type:"undirected"},r);if("multi"in t&&t.multi!==!1)throw new D("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new D('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Jr extends X{constructor(r){const t=te({multi:!0},r);if("multi"in t&&t.multi!==!0)throw new D("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}}class ei extends X{constructor(r){const t=te({type:"directed",multi:!0},r);if("multi"in t&&t.multi!==!0)throw new D("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new D('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class ti extends X{constructor(r){const t=te({type:"undirected",multi:!0},r);if("multi"in t&&t.multi!==!0)throw new D("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new D('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}function Ke(n){n.from=function(r,t){const e=te({},r.options,t),i=new n(e);return i.import(r),i}}Ke(X);Ke(Xr);Ke(Qr);Ke(Jr);Ke(ei);Ke(ti);X.Graph=X;X.DirectedGraph=Xr;X.UndirectedGraph=Qr;X.MultiGraph=Jr;X.MultiDirectedGraph=ei;X.MultiUndirectedGraph=ti;X.InvalidArgumentsGraphError=D;X.NotFoundGraphError=A;X.UsageGraphError=U;function Hn(n,r){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var e=t.call(n,r);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function it(n){var r=Hn(n,"string");return typeof r=="symbol"?r:r+""}function re(n,r){if(!(n instanceof r))throw new TypeError("Cannot call a class as a function")}function tr(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,it(e.key),e)}}function ie(n,r,t){return r&&tr(n.prototype,r),t&&tr(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function He(n){return He=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},He(n)}function ri(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ri=function(){return!!n})()}function Wn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function Vn(n,r){if(r&&(typeof r=="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Wn(n)}function le(n,r,t){return r=He(r),Vn(n,ri()?Reflect.construct(r,t||[],He(n).constructor):r.apply(n,t))}function It(n,r){return It=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},It(n,r)}function he(n,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(r&&r.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),r&&It(n,r)}function qn(n){if(Array.isArray(n))return n}function Kn(n,r){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var e,i,a,o,s=[],u=!0,l=!1;try{if(a=(t=t.call(n)).next,r===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(e=a.call(t)).done)&&(s.push(e.value),s.length!==r);u=!0);}catch(h){l=!0,i=h}finally{try{if(!u&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Ot(n,r){(r==null||r>n.length)&&(r=n.length);for(var t=0,e=Array(r);t<r;t++)e[t]=n[t];return e}function ii(n,r){if(n){if(typeof n=="string")return Ot(n,r);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ot(n,r):void 0}}function Yn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
1
|
+
import{g as $r,r as G,t as Et,j as g,a as Oe,O as Ii}from"./index-DUIBILM9.js";import{C as we,b as pt,c as Ur}from"./constants-lq4BIQN3.js";var st={exports:{}},Xt;function Oi(){if(Xt)return st.exports;Xt=1;var n=typeof Reflect=="object"?Reflect:null,r=n&&typeof n.apply=="function"?n.apply:function(y,S,C){return Function.prototype.apply.call(y,S,C)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(y){return Object.getOwnPropertyNames(y).concat(Object.getOwnPropertySymbols(y))}:t=function(y){return Object.getOwnPropertyNames(y)};function e(m){console&&console.warn&&console.warn(m)}var i=Number.isNaN||function(y){return y!==y};function a(){a.init.call(this)}st.exports=a,st.exports.once=L,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var o=10;function s(m){if(typeof m!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof m)}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(m){if(typeof m!="number"||m<0||i(m))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+m+".");o=m}}),a.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(y){if(typeof y!="number"||y<0||i(y))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+y+".");return this._maxListeners=y,this};function u(m){return m._maxListeners===void 0?a.defaultMaxListeners:m._maxListeners}a.prototype.getMaxListeners=function(){return u(this)},a.prototype.emit=function(y){for(var S=[],C=1;C<arguments.length;C++)S.push(arguments[C]);var P=y==="error",O=this._events;if(O!==void 0)P=P&&O.error===void 0;else if(!P)return!1;if(P){var z;if(S.length>0&&(z=S[0]),z instanceof Error)throw z;var Y=new Error("Unhandled error."+(z?" ("+z.message+")":""));throw Y.context=z,Y}var j=O[y];if(j===void 0)return!1;if(typeof j=="function")r(j,this,S);else for(var p=j.length,Q=b(j,p),C=0;C<p;++C)r(Q[C],this,S);return!0};function l(m,y,S,C){var P,O,z;if(s(S),O=m._events,O===void 0?(O=m._events=Object.create(null),m._eventsCount=0):(O.newListener!==void 0&&(m.emit("newListener",y,S.listener?S.listener:S),O=m._events),z=O[y]),z===void 0)z=O[y]=S,++m._eventsCount;else if(typeof z=="function"?z=O[y]=C?[S,z]:[z,S]:C?z.unshift(S):z.push(S),P=u(m),P>0&&z.length>P&&!z.warned){z.warned=!0;var Y=new Error("Possible EventEmitter memory leak detected. "+z.length+" "+String(y)+" listeners added. Use emitter.setMaxListeners() to increase limit");Y.name="MaxListenersExceededWarning",Y.emitter=m,Y.type=y,Y.count=z.length,e(Y)}return m}a.prototype.addListener=function(y,S){return l(this,y,S,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(y,S){return l(this,y,S,!0)};function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(m,y,S){var C={fired:!1,wrapFn:void 0,target:m,type:y,listener:S},P=h.bind(C);return P.listener=S,C.wrapFn=P,P}a.prototype.once=function(y,S){return s(S),this.on(y,d(this,y,S)),this},a.prototype.prependOnceListener=function(y,S){return s(S),this.prependListener(y,d(this,y,S)),this},a.prototype.removeListener=function(y,S){var C,P,O,z,Y;if(s(S),P=this._events,P===void 0)return this;if(C=P[y],C===void 0)return this;if(C===S||C.listener===S)--this._eventsCount===0?this._events=Object.create(null):(delete P[y],P.removeListener&&this.emit("removeListener",y,C.listener||S));else if(typeof C!="function"){for(O=-1,z=C.length-1;z>=0;z--)if(C[z]===S||C[z].listener===S){Y=C[z].listener,O=z;break}if(O<0)return this;O===0?C.shift():w(C,O),C.length===1&&(P[y]=C[0]),P.removeListener!==void 0&&this.emit("removeListener",y,Y||S)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(y){var S,C,P;if(C=this._events,C===void 0)return this;if(C.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):C[y]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete C[y]),this;if(arguments.length===0){var O=Object.keys(C),z;for(P=0;P<O.length;++P)z=O[P],z!=="removeListener"&&this.removeAllListeners(z);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(S=C[y],typeof S=="function")this.removeListener(y,S);else if(S!==void 0)for(P=S.length-1;P>=0;P--)this.removeListener(y,S[P]);return this};function c(m,y,S){var C=m._events;if(C===void 0)return[];var P=C[y];return P===void 0?[]:typeof P=="function"?S?[P.listener||P]:[P]:S?E(P):b(P,P.length)}a.prototype.listeners=function(y){return c(this,y,!0)},a.prototype.rawListeners=function(y){return c(this,y,!1)},a.listenerCount=function(m,y){return typeof m.listenerCount=="function"?m.listenerCount(y):f.call(m,y)},a.prototype.listenerCount=f;function f(m){var y=this._events;if(y!==void 0){var S=y[m];if(typeof S=="function")return 1;if(S!==void 0)return S.length}return 0}a.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]};function b(m,y){for(var S=new Array(y),C=0;C<y;++C)S[C]=m[C];return S}function w(m,y){for(;y+1<m.length;y++)m[y]=m[y+1];m.pop()}function E(m){for(var y=new Array(m.length),S=0;S<y.length;++S)y[S]=m[S].listener||m[S];return y}function L(m,y){return new Promise(function(S,C){function P(z){m.removeListener(y,O),C(z)}function O(){typeof m.removeListener=="function"&&m.removeListener("error",P),S([].slice.call(arguments))}R(m,y,O,{once:!0}),y!=="error"&&_(m,P,{once:!0})})}function _(m,y,S){typeof m.on=="function"&&R(m,"error",y,S)}function R(m,y,S,C){if(typeof m.on=="function")C.once?m.once(y,S):m.on(y,S);else if(typeof m.addEventListener=="function")m.addEventListener(y,function P(O){C.once&&m.removeEventListener(y,P),S(O)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof m)}return st.exports}var jr=Oi();function zi(){const n=arguments[0];for(let r=1,t=arguments.length;r<t;r++)if(arguments[r])for(const e in arguments[r])n[e]=arguments[r][e];return n}let te=zi;typeof Object.assign=="function"&&(te=Object.assign);function fe(n,r,t,e){const i=n._nodes.get(r);let a=null;return i&&(e==="mixed"?a=i.out&&i.out[t]||i.undirected&&i.undirected[t]:e==="directed"?a=i.out&&i.out[t]:a=i.undirected&&i.undirected[t]),a}function oe(n){return typeof n=="object"&&n!==null}function Mr(n){let r;for(r in n)return!1;return!0}function de(n,r,t){Object.defineProperty(n,r,{enumerable:!1,configurable:!1,writable:!0,value:t})}function ve(n,r,t){const e={enumerable:!0,configurable:!0};typeof t=="function"?e.get=t:(e.value=t,e.writable=!1),Object.defineProperty(n,r,e)}function Qt(n){return!(!oe(n)||n.attributes&&!Array.isArray(n.attributes))}function $i(){let n=Math.floor(Math.random()*256)&255;return()=>n++}function ke(){const n=arguments;let r=null,t=-1;return{[Symbol.iterator](){return this},next(){let e=null;do{if(r===null){if(t++,t>=n.length)return{done:!0};r=n[t][Symbol.iterator]()}if(e=r.next(),e.done){r=null;continue}break}while(!0);return e}}}function Ve(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Bt extends Error{constructor(r){super(),this.name="GraphError",this.message=r}}class D extends Bt{constructor(r){super(r),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,D.prototype.constructor)}}class A extends Bt{constructor(r){super(r),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,A.prototype.constructor)}}class U extends Bt{constructor(r){super(r),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,U.prototype.constructor)}}function Br(n,r){this.key=n,this.attributes=r,this.clear()}Br.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function Hr(n,r){this.key=n,this.attributes=r,this.clear()}Hr.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Wr(n,r){this.key=n,this.attributes=r,this.clear()}Wr.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function qe(n,r,t,e,i){this.key=r,this.attributes=i,this.undirected=n,this.source=t,this.target=e}qe.prototype.attach=function(){let n="out",r="in";this.undirected&&(n=r="undirected");const t=this.source.key,e=this.target.key;this.source[n][e]=this,!(this.undirected&&t===e)&&(this.target[r][t]=this)};qe.prototype.attachMulti=function(){let n="out",r="in";const t=this.source.key,e=this.target.key;this.undirected&&(n=r="undirected");const i=this.source[n],a=i[e];if(typeof a>"u"){i[e]=this,this.undirected&&t===e||(this.target[r][t]=this);return}a.previous=this,this.next=a,i[e]=this,this.target[r][t]=this};qe.prototype.detach=function(){const n=this.source.key,r=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),delete this.source[t][r],delete this.target[e][n]};qe.prototype.detachMulti=function(){const n=this.source.key,r=this.target.key;let t="out",e="in";this.undirected&&(t=e="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[t][r],delete this.target[e][n]):(this.next.previous=void 0,this.source[t][r]=this.next,this.target[e][n]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const Vr=0,qr=1,Ui=2,Kr=3;function Ae(n,r,t,e,i,a,o){let s,u,l,h;if(e=""+e,t===Vr){if(s=n._nodes.get(e),!s)throw new A(`Graph.${r}: could not find the "${e}" node in the graph.`);l=i,h=a}else if(t===Kr){if(i=""+i,u=n._edges.get(i),!u)throw new A(`Graph.${r}: could not find the "${i}" edge in the graph.`);const d=u.source.key,c=u.target.key;if(e===d)s=u.target;else if(e===c)s=u.source;else throw new A(`Graph.${r}: the "${e}" node is not attached to the "${i}" edge (${d}, ${c}).`);l=a,h=o}else{if(u=n._edges.get(e),!u)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`);t===qr?s=u.source:s=u.target,l=i,h=a}return[s,l,h]}function ji(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);return o.attributes[s]}}function Mi(n,r,t){n.prototype[r]=function(e,i){const[a]=Ae(this,r,t,e,i);return a.attributes}}function Bi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);return o.attributes.hasOwnProperty(s)}}function Hi(n,r,t){n.prototype[r]=function(e,i,a,o){const[s,u,l]=Ae(this,r,t,e,i,a,o);return s.attributes[u]=l,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Wi(n,r,t){n.prototype[r]=function(e,i,a,o){const[s,u,l]=Ae(this,r,t,e,i,a,o);if(typeof l!="function")throw new D(`Graph.${r}: updater should be a function.`);const h=s.attributes,d=l(h[u]);return h[u]=d,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Vi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);return delete o.attributes[s],this.emit("nodeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:s}),this}}function qi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);if(!oe(s))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return o.attributes=s,this.emit("nodeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Ki(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);if(!oe(s))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return te(o.attributes,s),this.emit("nodeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:s}),this}}function Yi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=Ae(this,r,t,e,i,a);if(typeof s!="function")throw new D(`Graph.${r}: provided updater is not a function.`);return o.attributes=s(o.attributes),this.emit("nodeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const Zi=[{name:n=>`get${n}Attribute`,attacher:ji},{name:n=>`get${n}Attributes`,attacher:Mi},{name:n=>`has${n}Attribute`,attacher:Bi},{name:n=>`set${n}Attribute`,attacher:Hi},{name:n=>`update${n}Attribute`,attacher:Wi},{name:n=>`remove${n}Attribute`,attacher:Vi},{name:n=>`replace${n}Attributes`,attacher:qi},{name:n=>`merge${n}Attributes`,attacher:Ki},{name:n=>`update${n}Attributes`,attacher:Yi}];function Xi(n){Zi.forEach(function({name:r,attacher:t}){t(n,r("Node"),Vr),t(n,r("Source"),qr),t(n,r("Target"),Ui),t(n,r("Opposite"),Kr)})}function Qi(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return a.attributes[i]}}function Ji(n,r,t){n.prototype[r]=function(e){let i;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+e,o=""+arguments[1];if(i=fe(this,a,o,t),!i)throw new A(`Graph.${r}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,i=this._edges.get(e),!i)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return i.attributes}}function en(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return a.attributes.hasOwnProperty(i)}}function tn(n,r,t){n.prototype[r]=function(e,i,a){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+e,u=""+i;if(i=arguments[2],a=arguments[3],o=fe(this,s,u,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return o.attributes[i]=a,this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function rn(n,r,t){n.prototype[r]=function(e,i,a){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+e,u=""+i;if(i=arguments[2],a=arguments[3],o=fe(this,s,u,t),!o)throw new A(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,o=this._edges.get(e),!o)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(typeof a!="function")throw new D(`Graph.${r}: updater should be a function.`);return o.attributes[i]=a(o.attributes[i]),this.emit("edgeAttributesUpdated",{key:o.key,type:"set",attributes:o.attributes,name:i}),this}}function nn(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return delete a.attributes[i],this.emit("edgeAttributesUpdated",{key:a.key,type:"remove",attributes:a.attributes,name:i}),this}}function an(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!oe(i))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return a.attributes=i,this.emit("edgeAttributesUpdated",{key:a.key,type:"replace",attributes:a.attributes}),this}}function on(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!oe(i))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return te(a.attributes,i),this.emit("edgeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:i}),this}}function sn(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new U(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new U(`Graph.${r}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+e,s=""+i;if(i=arguments[2],a=fe(this,o,s,t),!a)throw new A(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new U(`Graph.${r}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=""+e,a=this._edges.get(e),!a)throw new A(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(typeof i!="function")throw new D(`Graph.${r}: provided updater is not a function.`);return a.attributes=i(a.attributes),this.emit("edgeAttributesUpdated",{key:a.key,type:"update",attributes:a.attributes}),this}}const un=[{name:n=>`get${n}Attribute`,attacher:Qi},{name:n=>`get${n}Attributes`,attacher:Ji},{name:n=>`has${n}Attribute`,attacher:en},{name:n=>`set${n}Attribute`,attacher:tn},{name:n=>`update${n}Attribute`,attacher:rn},{name:n=>`remove${n}Attribute`,attacher:nn},{name:n=>`replace${n}Attributes`,attacher:an},{name:n=>`merge${n}Attributes`,attacher:on},{name:n=>`update${n}Attributes`,attacher:sn}];function ln(n){un.forEach(function({name:r,attacher:t}){t(n,r("Edge"),"mixed"),t(n,r("DirectedEdge"),"directed"),t(n,r("UndirectedEdge"),"undirected")})}const hn=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function dn(n,r,t,e){let i=!1;for(const a in r){if(a===e)continue;const o=r[a];if(i=t(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),n&&i)return o.key}}function cn(n,r,t,e){let i,a,o,s=!1;for(const u in r)if(u!==e){i=r[u];do{if(a=i.source,o=i.target,s=t(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected),n&&s)return i.key;i=i.next}while(i!==void 0)}}function xt(n,r){const t=Object.keys(n),e=t.length;let i,a=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(a>=e)return{done:!0};const o=t[a++];if(o===r){i=void 0;continue}i=n[o]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function fn(n,r,t,e){const i=r[t];if(!i)return;const a=i.source,o=i.target;if(e(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected)&&n)return i.key}function gn(n,r,t,e){let i=r[t];if(!i)return;let a=!1;do{if(a=e(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),n&&a)return i.key;i=i.next}while(i!==void 0)}function _t(n,r){let t=n[r];if(t.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!t)return{done:!0};const i={edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected};return t=t.next,{done:!1,value:i}}};let e=!1;return{[Symbol.iterator](){return this},next(){return e===!0?{done:!0}:(e=!0,{done:!1,value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected}})}}}function pn(n,r){if(n.size===0)return[];if(r==="mixed"||r===n.type)return Array.from(n._edges.keys());const t=r==="undirected"?n.undirectedSize:n.directedSize,e=new Array(t),i=r==="undirected",a=n._edges.values();let o=0,s,u;for(;s=a.next(),s.done!==!0;)u=s.value,u.undirected===i&&(e[o++]=u.key);return e}function Yr(n,r,t,e){if(r.size===0)return;const i=t!=="mixed"&&t!==r.type,a=t==="undirected";let o,s,u=!1;const l=r._edges.values();for(;o=l.next(),o.done!==!0;){if(s=o.value,i&&s.undirected!==a)continue;const{key:h,attributes:d,source:c,target:f}=s;if(u=e(h,d,c.key,f.key,c.attributes,f.attributes,s.undirected),n&&u)return h}}function mn(n,r){if(n.size===0)return Ve();const t=r!=="mixed"&&r!==n.type,e=r==="undirected",i=n._edges.values();return{[Symbol.iterator](){return this},next(){let a,o;for(;;){if(a=i.next(),a.done)return a;if(o=a.value,!(t&&o.undirected!==e))break}return{value:{edge:o.key,attributes:o.attributes,source:o.source.key,target:o.target.key,sourceAttributes:o.source.attributes,targetAttributes:o.target.attributes,undirected:o.undirected},done:!1}}}}function Ht(n,r,t,e,i,a){const o=r?cn:dn;let s;if(t!=="undirected"&&(e!=="out"&&(s=o(n,i.in,a),n&&s)||e!=="in"&&(s=o(n,i.out,a,e?void 0:i.key),n&&s))||t!=="directed"&&(s=o(n,i.undirected,a),n&&s))return s}function vn(n,r,t,e){const i=[];return Ht(!1,n,r,t,e,function(a){i.push(a)}),i}function yn(n,r,t){let e=Ve();return n!=="undirected"&&(r!=="out"&&typeof t.in<"u"&&(e=ke(e,xt(t.in))),r!=="in"&&typeof t.out<"u"&&(e=ke(e,xt(t.out,r?void 0:t.key)))),n!=="directed"&&typeof t.undirected<"u"&&(e=ke(e,xt(t.undirected))),e}function Wt(n,r,t,e,i,a,o){const s=t?gn:fn;let u;if(r!=="undirected"&&(typeof i.in<"u"&&e!=="out"&&(u=s(n,i.in,a,o),n&&u)||typeof i.out<"u"&&e!=="in"&&(e||i.key!==a)&&(u=s(n,i.out,a,o),n&&u))||r!=="directed"&&typeof i.undirected<"u"&&(u=s(n,i.undirected,a,o),n&&u))return u}function bn(n,r,t,e,i){const a=[];return Wt(!1,n,r,t,e,i,function(o){a.push(o)}),a}function wn(n,r,t,e){let i=Ve();return n!=="undirected"&&(typeof t.in<"u"&&r!=="out"&&e in t.in&&(i=ke(i,_t(t.in,e))),typeof t.out<"u"&&r!=="in"&&e in t.out&&(r||t.key!==e)&&(i=ke(i,_t(t.out,e)))),n!=="directed"&&typeof t.undirected<"u"&&e in t.undirected&&(i=ke(i,_t(t.undirected,e))),i}function En(n,r){const{name:t,type:e,direction:i}=r;n.prototype[t]=function(a,o){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];if(!arguments.length)return pn(this,e);if(arguments.length===1){a=""+a;const s=this._nodes.get(a);if(typeof s>"u")throw new A(`Graph.${t}: could not find the "${a}" node in the graph.`);return vn(this.multi,e==="mixed"?this.type:e,i,s)}if(arguments.length===2){a=""+a,o=""+o;const s=this._nodes.get(a);if(!s)throw new A(`Graph.${t}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(o))throw new A(`Graph.${t}: could not find the "${o}" target node in the graph.`);return bn(e,this.multi,i,s,o)}throw new D(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function xn(n,r){const{name:t,type:e,direction:i}=r,a="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(l,h,d){if(!(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)){if(arguments.length===1)return d=l,Yr(!1,this,e,d);if(arguments.length===2){l=""+l,d=h;const c=this._nodes.get(l);if(typeof c>"u")throw new A(`Graph.${a}: could not find the "${l}" node in the graph.`);return Ht(!1,this.multi,e==="mixed"?this.type:e,i,c,d)}if(arguments.length===3){l=""+l,h=""+h;const c=this._nodes.get(l);if(!c)throw new A(`Graph.${a}: could not find the "${l}" source node in the graph.`);if(!this._nodes.has(h))throw new A(`Graph.${a}: could not find the "${h}" target node in the graph.`);return Wt(!1,e,this.multi,i,c,h,d)}throw new D(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const o="map"+t[0].toUpperCase()+t.slice(1);n.prototype[o]=function(){const l=Array.prototype.slice.call(arguments),h=l.pop();let d;if(l.length===0){let c=0;e!=="directed"&&(c+=this.undirectedSize),e!=="undirected"&&(c+=this.directedSize),d=new Array(c);let f=0;l.push((b,w,E,L,_,R,m)=>{d[f++]=h(b,w,E,L,_,R,m)})}else d=[],l.push((c,f,b,w,E,L,_)=>{d.push(h(c,f,b,w,E,L,_))});return this[a].apply(this,l),d};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(){const l=Array.prototype.slice.call(arguments),h=l.pop(),d=[];return l.push((c,f,b,w,E,L,_)=>{h(c,f,b,w,E,L,_)&&d.push(c)}),this[a].apply(this,l),d};const u="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[u]=function(){let l=Array.prototype.slice.call(arguments);if(l.length<2||l.length>4)throw new D(`Graph.${u}: invalid number of arguments (expecting 2, 3 or 4 and got ${l.length}).`);if(typeof l[l.length-1]=="function"&&typeof l[l.length-2]!="function")throw new D(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let h,d;l.length===2?(h=l[0],d=l[1],l=[]):l.length===3?(h=l[1],d=l[2],l=[l[0]]):l.length===4&&(h=l[2],d=l[3],l=[l[0],l[1]]);let c=d;return l.push((f,b,w,E,L,_,R)=>{c=h(c,f,b,w,E,L,_,R)}),this[a].apply(this,l),c}}function _n(n,r){const{name:t,type:e,direction:i}=r,a="find"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(u,l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return!1;if(arguments.length===1)return h=u,Yr(!0,this,e,h);if(arguments.length===2){u=""+u,h=l;const d=this._nodes.get(u);if(typeof d>"u")throw new A(`Graph.${a}: could not find the "${u}" node in the graph.`);return Ht(!0,this.multi,e==="mixed"?this.type:e,i,d,h)}if(arguments.length===3){u=""+u,l=""+l;const d=this._nodes.get(u);if(!d)throw new A(`Graph.${a}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(l))throw new A(`Graph.${a}: could not find the "${l}" target node in the graph.`);return Wt(!0,e,this.multi,i,d,l,h)}throw new D(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const o="some"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[o]=function(){const u=Array.prototype.slice.call(arguments),l=u.pop();return u.push((d,c,f,b,w,E,L)=>l(d,c,f,b,w,E,L)),!!this[a].apply(this,u)};const s="every"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[s]=function(){const u=Array.prototype.slice.call(arguments),l=u.pop();return u.push((d,c,f,b,w,E,L)=>!l(d,c,f,b,w,E,L)),!this[a].apply(this,u)}}function Cn(n,r){const{name:t,type:e,direction:i}=r,a=t.slice(0,-1)+"Entries";n.prototype[a]=function(o,s){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return Ve();if(!arguments.length)return mn(this,e);if(arguments.length===1){o=""+o;const u=this._nodes.get(o);if(!u)throw new A(`Graph.${a}: could not find the "${o}" node in the graph.`);return yn(e,i,u)}if(arguments.length===2){o=""+o,s=""+s;const u=this._nodes.get(o);if(!u)throw new A(`Graph.${a}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new A(`Graph.${a}: could not find the "${s}" target node in the graph.`);return wn(e,i,u,s)}throw new D(`Graph.${a}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Sn(n){hn.forEach(r=>{En(n,r),xn(n,r),_n(n,r),Cn(n,r)})}const Tn=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function mt(){this.A=null,this.B=null}mt.prototype.wrap=function(n){this.A===null?this.A=n:this.B===null&&(this.B=n)};mt.prototype.has=function(n){return this.A!==null&&n in this.A||this.B!==null&&n in this.B};function Ze(n,r,t,e,i){for(const a in e){const o=e[a],s=o.source,u=o.target,l=s===t?u:s;if(r&&r.has(l.key))continue;const h=i(l.key,l.attributes);if(n&&h)return l.key}}function Vt(n,r,t,e,i){if(r!=="mixed"){if(r==="undirected")return Ze(n,null,e,e.undirected,i);if(typeof t=="string")return Ze(n,null,e,e[t],i)}const a=new mt;let o;if(r!=="undirected"){if(t!=="out"){if(o=Ze(n,null,e,e.in,i),n&&o)return o;a.wrap(e.in)}if(t!=="in"){if(o=Ze(n,a,e,e.out,i),n&&o)return o;a.wrap(e.out)}}if(r!=="directed"&&(o=Ze(n,a,e,e.undirected,i),n&&o))return o}function Rn(n,r,t){if(n!=="mixed"){if(n==="undirected")return Object.keys(t.undirected);if(typeof r=="string")return Object.keys(t[r])}const e=[];return Vt(!1,n,r,t,function(i){e.push(i)}),e}function Xe(n,r,t){const e=Object.keys(t),i=e.length;let a=0;return{[Symbol.iterator](){return this},next(){let o=null;do{if(a>=i)return n&&n.wrap(t),{done:!0};const s=t[e[a++]],u=s.source,l=s.target;if(o=u===r?l:u,n&&n.has(o.key)){o=null;continue}}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function kn(n,r,t){if(n!=="mixed"){if(n==="undirected")return Xe(null,t,t.undirected);if(typeof r=="string")return Xe(null,t,t[r])}let e=Ve();const i=new mt;return n!=="undirected"&&(r!=="out"&&(e=ke(e,Xe(i,t,t.in))),r!=="in"&&(e=ke(e,Xe(i,t,t.out)))),n!=="directed"&&(e=ke(e,Xe(i,t,t.undirected))),e}function An(n,r){const{name:t,type:e,direction:i}=r;n.prototype[t]=function(a){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return[];a=""+a;const o=this._nodes.get(a);if(typeof o>"u")throw new A(`Graph.${t}: could not find the "${a}" node in the graph.`);return Rn(e==="mixed"?this.type:e,i,o)}}function Ln(n,r){const{name:t,type:e,direction:i}=r,a="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;l=""+l;const d=this._nodes.get(l);if(typeof d>"u")throw new A(`Graph.${a}: could not find the "${l}" node in the graph.`);Vt(!1,e==="mixed"?this.type:e,i,d,h)};const o="map"+t[0].toUpperCase()+t.slice(1);n.prototype[o]=function(l,h){const d=[];return this[a](l,(c,f)=>{d.push(h(c,f))}),d};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(l,h){const d=[];return this[a](l,(c,f)=>{h(c,f)&&d.push(c)}),d};const u="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[u]=function(l,h,d){if(arguments.length<3)throw new D(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let c=d;return this[a](l,(f,b)=>{c=h(c,f,b)}),c}}function Dn(n,r){const{name:t,type:e,direction:i}=r,a=t[0].toUpperCase()+t.slice(1,-1),o="find"+a;n.prototype[o]=function(l,h){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;l=""+l;const d=this._nodes.get(l);if(typeof d>"u")throw new A(`Graph.${o}: could not find the "${l}" node in the graph.`);return Vt(!0,e==="mixed"?this.type:e,i,d,h)};const s="some"+a;n.prototype[s]=function(l,h){return!!this[o](l,h)};const u="every"+a;n.prototype[u]=function(l,h){return!this[o](l,(c,f)=>!h(c,f))}}function Gn(n,r){const{name:t,type:e,direction:i}=r,a=t.slice(0,-1)+"Entries";n.prototype[a]=function(o){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return Ve();o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new A(`Graph.${a}: could not find the "${o}" node in the graph.`);return kn(e==="mixed"?this.type:e,i,s)}}function Nn(n){Tn.forEach(r=>{An(n,r),Ln(n,r),Dn(n,r),Gn(n,r)})}function ut(n,r,t,e,i){const a=e._nodes.values(),o=e.type;let s,u,l,h,d,c;for(;s=a.next(),s.done!==!0;){let f=!1;if(u=s.value,o!=="undirected"){h=u.out;for(l in h){d=h[l];do c=d.target,f=!0,i(u.key,c.key,u.attributes,c.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}if(o!=="directed"){h=u.undirected;for(l in h)if(!(r&&u.key>l)){d=h[l];do c=d.target,c.key!==l&&(c=d.source),f=!0,i(u.key,c.key,u.attributes,c.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}t&&!f&&i(u.key,null,u.attributes,null,null,null,null)}}function Fn(n,r){const t={key:n};return Mr(r.attributes)||(t.attributes=te({},r.attributes)),t}function Pn(n,r,t){const e={key:r,source:t.source.key,target:t.target.key};return Mr(t.attributes)||(e.attributes=te({},t.attributes)),n==="mixed"&&t.undirected&&(e.undirected=!0),e}function In(n){if(!oe(n))throw new D('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in n))throw new D("Graph.import: serialized node is missing its key.");if("attributes"in n&&(!oe(n.attributes)||n.attributes===null))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function On(n){if(!oe(n))throw new D('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in n))throw new D("Graph.import: serialized edge is missing its source.");if(!("target"in n))throw new D("Graph.import: serialized edge is missing its target.");if("attributes"in n&&(!oe(n.attributes)||n.attributes===null))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in n&&typeof n.undirected!="boolean")throw new D("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const zn=$i(),$n=new Set(["directed","undirected","mixed"]),Jt=new Set(["domain","_events","_eventsCount","_maxListeners"]),Un=[{name:n=>`${n}Edge`,generateKey:!0},{name:n=>`${n}DirectedEdge`,generateKey:!0,type:"directed"},{name:n=>`${n}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:n=>`${n}EdgeWithKey`},{name:n=>`${n}DirectedEdgeWithKey`,type:"directed"},{name:n=>`${n}UndirectedEdgeWithKey`,type:"undirected"}],jn={allowSelfLoops:!0,multi:!1,type:"mixed"};function Mn(n,r,t){if(t&&!oe(t))throw new D(`Graph.addNode: invalid attributes. Expecting an object but got "${t}"`);if(r=""+r,t=t||{},n._nodes.has(r))throw new U(`Graph.addNode: the "${r}" node already exist in the graph.`);const e=new n.NodeDataClass(r,t);return n._nodes.set(r,e),n.emit("nodeAdded",{key:r,attributes:t}),e}function er(n,r,t){const e=new n.NodeDataClass(r,t);return n._nodes.set(r,e),n.emit("nodeAdded",{key:r,attributes:t}),e}function Zr(n,r,t,e,i,a,o,s){if(!e&&n.type==="undirected")throw new U(`Graph.${r}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(e&&n.type==="directed")throw new U(`Graph.${r}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!oe(s))throw new D(`Graph.${r}: invalid attributes. Expecting an object but got "${s}"`);if(a=""+a,o=""+o,s=s||{},!n.allowSelfLoops&&a===o)throw new U(`Graph.${r}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const u=n._nodes.get(a),l=n._nodes.get(o);if(!u)throw new A(`Graph.${r}: source node "${a}" not found.`);if(!l)throw new A(`Graph.${r}: target node "${o}" not found.`);const h={key:null,undirected:e,source:a,target:o,attributes:s};if(t)i=n._edgeKeyGenerator();else if(i=""+i,n._edges.has(i))throw new U(`Graph.${r}: the "${i}" edge already exists in the graph.`);if(!n.multi&&(e?typeof u.undirected[o]<"u":typeof u.out[o]<"u"))throw new U(`Graph.${r}: an edge linking "${a}" to "${o}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const d=new qe(e,i,u,l,s);n._edges.set(i,d);const c=a===o;return e?(u.undirectedDegree++,l.undirectedDegree++,c&&(u.undirectedLoops++,n._undirectedSelfLoopCount++)):(u.outDegree++,l.inDegree++,c&&(u.directedLoops++,n._directedSelfLoopCount++)),n.multi?d.attachMulti():d.attach(),e?n._undirectedSize++:n._directedSize++,h.key=i,n.emit("edgeAdded",h),i}function Bn(n,r,t,e,i,a,o,s,u){if(!e&&n.type==="undirected")throw new U(`Graph.${r}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(e&&n.type==="directed")throw new U(`Graph.${r}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(s){if(u){if(typeof s!="function")throw new D(`Graph.${r}: invalid updater function. Expecting a function but got "${s}"`)}else if(!oe(s))throw new D(`Graph.${r}: invalid attributes. Expecting an object but got "${s}"`)}a=""+a,o=""+o;let l;if(u&&(l=s,s=void 0),!n.allowSelfLoops&&a===o)throw new U(`Graph.${r}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let h=n._nodes.get(a),d=n._nodes.get(o),c,f;if(!t&&(c=n._edges.get(i),c)){if((c.source.key!==a||c.target.key!==o)&&(!e||c.source.key!==o||c.target.key!==a))throw new U(`Graph.${r}: inconsistency detected when attempting to merge the "${i}" edge with "${a}" source & "${o}" target vs. ("${c.source.key}", "${c.target.key}").`);f=c}if(!f&&!n.multi&&h&&(f=e?h.undirected[o]:h.out[o]),f){const _=[f.key,!1,!1,!1];if(u?!l:!s)return _;if(u){const R=f.attributes;f.attributes=l(R),n.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else te(f.attributes,s),n.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:s});return _}s=s||{},u&&l&&(s=l(s));const b={key:null,undirected:e,source:a,target:o,attributes:s};if(t)i=n._edgeKeyGenerator();else if(i=""+i,n._edges.has(i))throw new U(`Graph.${r}: the "${i}" edge already exists in the graph.`);let w=!1,E=!1;h||(h=er(n,a,{}),w=!0,a===o&&(d=h,E=!0)),d||(d=er(n,o,{}),E=!0),c=new qe(e,i,h,d,s),n._edges.set(i,c);const L=a===o;return e?(h.undirectedDegree++,d.undirectedDegree++,L&&(h.undirectedLoops++,n._undirectedSelfLoopCount++)):(h.outDegree++,d.inDegree++,L&&(h.directedLoops++,n._directedSelfLoopCount++)),n.multi?c.attachMulti():c.attach(),e?n._undirectedSize++:n._directedSize++,b.key=i,n.emit("edgeAdded",b),[i,!0,w,E]}function Me(n,r){n._edges.delete(r.key);const{source:t,target:e,attributes:i}=r,a=r.undirected,o=t===e;a?(t.undirectedDegree--,e.undirectedDegree--,o&&(t.undirectedLoops--,n._undirectedSelfLoopCount--)):(t.outDegree--,e.inDegree--,o&&(t.directedLoops--,n._directedSelfLoopCount--)),n.multi?r.detachMulti():r.detach(),a?n._undirectedSize--:n._directedSize--,n.emit("edgeDropped",{key:r.key,attributes:i,source:t.key,target:e.key,undirected:a})}class X extends jr.EventEmitter{constructor(r){if(super(),r=te({},jn,r),typeof r.multi!="boolean")throw new D(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${r.multi}".`);if(!$n.has(r.type))throw new D(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${r.type}".`);if(typeof r.allowSelfLoops!="boolean")throw new D(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${r.allowSelfLoops}".`);const t=r.type==="mixed"?Br:r.type==="directed"?Hr:Wr;de(this,"NodeDataClass",t);const e="geid_"+zn()+"_";let i=0;const a=()=>{let o;do o=e+i++;while(this._edges.has(o));return o};de(this,"_attributes",{}),de(this,"_nodes",new Map),de(this,"_edges",new Map),de(this,"_directedSize",0),de(this,"_undirectedSize",0),de(this,"_directedSelfLoopCount",0),de(this,"_undirectedSelfLoopCount",0),de(this,"_edgeKeyGenerator",a),de(this,"_options",r),Jt.forEach(o=>de(this,o,this[o])),ve(this,"order",()=>this._nodes.size),ve(this,"size",()=>this._edges.size),ve(this,"directedSize",()=>this._directedSize),ve(this,"undirectedSize",()=>this._undirectedSize),ve(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),ve(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),ve(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),ve(this,"multi",this._options.multi),ve(this,"type",this._options.type),ve(this,"allowSelfLoops",this._options.allowSelfLoops),ve(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(r){return this._nodes.has(""+r)}hasDirectedEdge(r,t){if(this.type==="undirected")return!1;if(arguments.length===1){const e=""+r,i=this._edges.get(e);return!!i&&!i.undirected}else if(arguments.length===2){r=""+r,t=""+t;const e=this._nodes.get(r);return e?e.out.hasOwnProperty(t):!1}throw new D(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(r,t){if(this.type==="directed")return!1;if(arguments.length===1){const e=""+r,i=this._edges.get(e);return!!i&&i.undirected}else if(arguments.length===2){r=""+r,t=""+t;const e=this._nodes.get(r);return e?e.undirected.hasOwnProperty(t):!1}throw new D(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(r,t){if(arguments.length===1){const e=""+r;return this._edges.has(e)}else if(arguments.length===2){r=""+r,t=""+t;const e=this._nodes.get(r);return e?typeof e.out<"u"&&e.out.hasOwnProperty(t)||typeof e.undirected<"u"&&e.undirected.hasOwnProperty(t):!1}throw new D(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(r,t){if(this.type==="undirected")return;if(r=""+r,t=""+t,this.multi)throw new U("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const e=this._nodes.get(r);if(!e)throw new A(`Graph.directedEdge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new A(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);const i=e.out&&e.out[t]||void 0;if(i)return i.key}undirectedEdge(r,t){if(this.type==="directed")return;if(r=""+r,t=""+t,this.multi)throw new U("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const e=this._nodes.get(r);if(!e)throw new A(`Graph.undirectedEdge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new A(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);const i=e.undirected&&e.undirected[t]||void 0;if(i)return i.key}edge(r,t){if(this.multi)throw new U("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.edge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new A(`Graph.edge: could not find the "${t}" target node in the graph.`);const i=e.out&&e.out[t]||e.undirected&&e.undirected[t]||void 0;if(i)return i.key}areDirectedNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areDirectedNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.in||t in e.out}areOutNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areOutNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.out}areInNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areInNeighbors: could not find the "${r}" node in the graph.`);return this.type==="undirected"?!1:t in e.in}areUndirectedNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areUndirectedNeighbors: could not find the "${r}" node in the graph.`);return this.type==="directed"?!1:t in e.undirected}areNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&(t in e.in||t in e.out)||this.type!=="directed"&&t in e.undirected}areInboundNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areInboundNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&t in e.in||this.type!=="directed"&&t in e.undirected}areOutboundNeighbors(r,t){r=""+r,t=""+t;const e=this._nodes.get(r);if(!e)throw new A(`Graph.areOutboundNeighbors: could not find the "${r}" node in the graph.`);return this.type!=="undirected"&&t in e.out||this.type!=="directed"&&t in e.undirected}inDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree}outDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.outDegree}directedDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.directedDegree: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree}undirectedDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.undirectedDegree: could not find the "${r}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree}inboundDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inboundDegree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree),e}outboundDegree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outboundDegree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.outDegree),e}degree(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.degree: could not find the "${r}" node in the graph.`);let e=0;return this.type!=="directed"&&(e+=t.undirectedDegree),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree),e}inDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.directedDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="undirected"?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);return this.type==="directed"?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree,i+=t.directedLoops),e-i}outboundDegreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.outDegree,i+=t.directedLoops),e-i}degreeWithoutSelfLoops(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.degreeWithoutSelfLoops: could not find the "${r}" node in the graph.`);let e=0,i=0;return this.type!=="directed"&&(e+=t.undirectedDegree,i+=t.undirectedLoops*2),this.type!=="undirected"&&(e+=t.inDegree+t.outDegree,i+=t.directedLoops*2),e-i}source(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.source: could not find the "${r}" edge in the graph.`);return t.source.key}target(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.target: could not find the "${r}" edge in the graph.`);return t.target.key}extremities(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.extremities: could not find the "${r}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(r,t){r=""+r,t=""+t;const e=this._edges.get(t);if(!e)throw new A(`Graph.opposite: could not find the "${t}" edge in the graph.`);const i=e.source.key,a=e.target.key;if(r===i)return a;if(r===a)return i;throw new A(`Graph.opposite: the "${r}" node is not attached to the "${t}" edge (${i}, ${a}).`)}hasExtremity(r,t){r=""+r,t=""+t;const e=this._edges.get(r);if(!e)throw new A(`Graph.hasExtremity: could not find the "${r}" edge in the graph.`);return e.source.key===t||e.target.key===t}isUndirected(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isUndirected: could not find the "${r}" edge in the graph.`);return t.undirected}isDirected(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isDirected: could not find the "${r}" edge in the graph.`);return!t.undirected}isSelfLoop(r){r=""+r;const t=this._edges.get(r);if(!t)throw new A(`Graph.isSelfLoop: could not find the "${r}" edge in the graph.`);return t.source===t.target}addNode(r,t){return Mn(this,r,t).key}mergeNode(r,t){if(t&&!oe(t))throw new D(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);r=""+r,t=t||{};let e=this._nodes.get(r);return e?(t&&(te(e.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:r,attributes:e.attributes,data:t})),[r,!1]):(e=new this.NodeDataClass(r,t),this._nodes.set(r,e),this.emit("nodeAdded",{key:r,attributes:t}),[r,!0])}updateNode(r,t){if(t&&typeof t!="function")throw new D(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);r=""+r;let e=this._nodes.get(r);if(e){if(t){const a=e.attributes;e.attributes=t(a),this.emit("nodeAttributesUpdated",{type:"replace",key:r,attributes:e.attributes})}return[r,!1]}const i=t?t({}):{};return e=new this.NodeDataClass(r,i),this._nodes.set(r,e),this.emit("nodeAdded",{key:r,attributes:i}),[r,!0]}dropNode(r){r=""+r;const t=this._nodes.get(r);if(!t)throw new A(`Graph.dropNode: could not find the "${r}" node in the graph.`);let e;if(this.type!=="undirected"){for(const i in t.out){e=t.out[i];do Me(this,e),e=e.next;while(e)}for(const i in t.in){e=t.in[i];do Me(this,e),e=e.next;while(e)}}if(this.type!=="directed")for(const i in t.undirected){e=t.undirected[i];do Me(this,e),e=e.next;while(e)}this._nodes.delete(r),this.emit("nodeDropped",{key:r,attributes:t.attributes})}dropEdge(r){let t;if(arguments.length>1){const e=""+arguments[0],i=""+arguments[1];if(t=fe(this,e,i,this.type),!t)throw new A(`Graph.dropEdge: could not find the "${e}" -> "${i}" edge in the graph.`)}else if(r=""+r,t=this._edges.get(r),!t)throw new A(`Graph.dropEdge: could not find the "${r}" edge in the graph.`);return Me(this,t),this}dropDirectedEdge(r,t){if(arguments.length<2)throw new U("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new U("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");r=""+r,t=""+t;const e=fe(this,r,t,"directed");if(!e)throw new A(`Graph.dropDirectedEdge: could not find a "${r}" -> "${t}" edge in the graph.`);return Me(this,e),this}dropUndirectedEdge(r,t){if(arguments.length<2)throw new U("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new U("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const e=fe(this,r,t,"undirected");if(!e)throw new A(`Graph.dropUndirectedEdge: could not find a "${r}" -> "${t}" edge in the graph.`);return Me(this,e),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const r=this._nodes.values();let t;for(;t=r.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(r){return this._attributes[r]}getAttributes(){return this._attributes}hasAttribute(r){return this._attributes.hasOwnProperty(r)}setAttribute(r,t){return this._attributes[r]=t,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:r}),this}updateAttribute(r,t){if(typeof t!="function")throw new D("Graph.updateAttribute: updater should be a function.");const e=this._attributes[r];return this._attributes[r]=t(e),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:r}),this}removeAttribute(r){return delete this._attributes[r],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:r}),this}replaceAttributes(r){if(!oe(r))throw new D("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=r,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(r){if(!oe(r))throw new D("Graph.mergeAttributes: provided attributes are not a plain object.");return te(this._attributes,r),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:r}),this}updateAttributes(r){if(typeof r!="function")throw new D("Graph.updateAttributes: provided updater is not a function.");return this._attributes=r(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(r,t){if(typeof r!="function")throw new D("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!Qt(t))throw new D("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._nodes.values();let i,a;for(;i=e.next(),i.done!==!0;)a=i.value,a.attributes=r(a.key,a.attributes);this.emit("eachNodeAttributesUpdated",{hints:t||null})}updateEachEdgeAttributes(r,t){if(typeof r!="function")throw new D("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!Qt(t))throw new D("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const e=this._edges.values();let i,a,o,s;for(;i=e.next(),i.done!==!0;)a=i.value,o=a.source,s=a.target,a.attributes=r(a.key,a.attributes,o.key,s.key,o.attributes,s.attributes,a.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t||null})}forEachAdjacencyEntry(r){if(typeof r!="function")throw new D("Graph.forEachAdjacencyEntry: expecting a callback.");ut(!1,!1,!1,this,r)}forEachAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new D("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");ut(!1,!1,!0,this,r)}forEachAssymetricAdjacencyEntry(r){if(typeof r!="function")throw new D("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");ut(!1,!0,!1,this,r)}forEachAssymetricAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new D("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");ut(!1,!0,!0,this,r)}nodes(){return Array.from(this._nodes.keys())}forEachNode(r){if(typeof r!="function")throw new D("Graph.forEachNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)i=e.value,r(i.key,i.attributes)}findNode(r){if(typeof r!="function")throw new D("Graph.findNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)if(i=e.value,r(i.key,i.attributes))return i.key}mapNodes(r){if(typeof r!="function")throw new D("Graph.mapNode: expecting a callback.");const t=this._nodes.values();let e,i;const a=new Array(this.order);let o=0;for(;e=t.next(),e.done!==!0;)i=e.value,a[o++]=r(i.key,i.attributes);return a}someNode(r){if(typeof r!="function")throw new D("Graph.someNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)if(i=e.value,r(i.key,i.attributes))return!0;return!1}everyNode(r){if(typeof r!="function")throw new D("Graph.everyNode: expecting a callback.");const t=this._nodes.values();let e,i;for(;e=t.next(),e.done!==!0;)if(i=e.value,!r(i.key,i.attributes))return!1;return!0}filterNodes(r){if(typeof r!="function")throw new D("Graph.filterNodes: expecting a callback.");const t=this._nodes.values();let e,i;const a=[];for(;e=t.next(),e.done!==!0;)i=e.value,r(i.key,i.attributes)&&a.push(i.key);return a}reduceNodes(r,t){if(typeof r!="function")throw new D("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new D("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let e=t;const i=this._nodes.values();let a,o;for(;a=i.next(),a.done!==!0;)o=a.value,e=r(e,o.key,o.attributes);return e}nodeEntries(){const r=this._nodes.values();return{[Symbol.iterator](){return this},next(){const t=r.next();if(t.done)return t;const e=t.value;return{value:{node:e.key,attributes:e.attributes},done:!1}}}}export(){const r=new Array(this._nodes.size);let t=0;this._nodes.forEach((i,a)=>{r[t++]=Fn(a,i)});const e=new Array(this._edges.size);return t=0,this._edges.forEach((i,a)=>{e[t++]=Pn(this.type,a,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:r,edges:e}}import(r,t=!1){if(r instanceof X)return r.forEachNode((u,l)=>{t?this.mergeNode(u,l):this.addNode(u,l)}),r.forEachEdge((u,l,h,d,c,f,b)=>{t?b?this.mergeUndirectedEdgeWithKey(u,h,d,l):this.mergeDirectedEdgeWithKey(u,h,d,l):b?this.addUndirectedEdgeWithKey(u,h,d,l):this.addDirectedEdgeWithKey(u,h,d,l)}),this;if(!oe(r))throw new D("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(r.attributes){if(!oe(r.attributes))throw new D("Graph.import: invalid attributes. Expecting a plain object.");t?this.mergeAttributes(r.attributes):this.replaceAttributes(r.attributes)}let e,i,a,o,s;if(r.nodes){if(a=r.nodes,!Array.isArray(a))throw new D("Graph.import: invalid nodes. Expecting an array.");for(e=0,i=a.length;e<i;e++){o=a[e],In(o);const{key:u,attributes:l}=o;t?this.mergeNode(u,l):this.addNode(u,l)}}if(r.edges){let u=!1;if(this.type==="undirected"&&(u=!0),a=r.edges,!Array.isArray(a))throw new D("Graph.import: invalid edges. Expecting an array.");for(e=0,i=a.length;e<i;e++){s=a[e],On(s);const{source:l,target:h,attributes:d,undirected:c=u}=s;let f;"key"in s?(f=t?c?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:c?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,s.key,l,h,d)):(f=t?c?this.mergeUndirectedEdge:this.mergeDirectedEdge:c?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,l,h,d))}}return this}nullCopy(r){const t=new X(te({},this._options,r));return t.replaceAttributes(te({},this.getAttributes())),t}emptyCopy(r){const t=this.nullCopy(r);return this._nodes.forEach((e,i)=>{const a=te({},e.attributes);e=new t.NodeDataClass(i,a),t._nodes.set(i,e)}),t}copy(r){if(r=r||{},typeof r.type=="string"&&r.type!==this.type&&r.type!=="mixed")throw new U(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${r.type}" because this would mean losing information about the current graph.`);if(typeof r.multi=="boolean"&&r.multi!==this.multi&&r.multi!==!0)throw new U("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof r.allowSelfLoops=="boolean"&&r.allowSelfLoops!==this.allowSelfLoops&&r.allowSelfLoops!==!0)throw new U("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const t=this.emptyCopy(r),e=this._edges.values();let i,a;for(;i=e.next(),i.done!==!0;)a=i.value,Zr(t,"copy",!1,a.undirected,a.key,a.source.key,a.target.key,te({},a.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const r={};this._nodes.forEach((a,o)=>{r[o]=a.attributes});const t={},e={};this._edges.forEach((a,o)=>{const s=a.undirected?"--":"->";let u="",l=a.source.key,h=a.target.key,d;a.undirected&&l>h&&(d=l,l=h,h=d);const c=`(${l})${s}(${h})`;o.startsWith("geid_")?this.multi&&(typeof e[c]>"u"?e[c]=0:e[c]++,u+=`${e[c]}. `):u+=`[${o}]: `,u+=c,t[u]=a.attributes});const i={};for(const a in this)this.hasOwnProperty(a)&&!Jt.has(a)&&typeof this[a]!="function"&&typeof a!="symbol"&&(i[a]=this[a]);return i.attributes=this._attributes,i.nodes=r,i.edges=t,de(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(X.prototype[Symbol.for("nodejs.util.inspect.custom")]=X.prototype.inspect);Un.forEach(n=>{["add","merge","update"].forEach(r=>{const t=n.name(r),e=r==="add"?Zr:Bn;n.generateKey?X.prototype[t]=function(i,a,o){return e(this,t,!0,(n.type||this.type)==="undirected",null,i,a,o,r==="update")}:X.prototype[t]=function(i,a,o,s){return e(this,t,!1,(n.type||this.type)==="undirected",i,a,o,s,r==="update")}})});Xi(X);ln(X);Sn(X);Nn(X);class Xr extends X{constructor(r){const t=te({type:"directed"},r);if("multi"in t&&t.multi!==!1)throw new D("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new D('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Qr extends X{constructor(r){const t=te({type:"undirected"},r);if("multi"in t&&t.multi!==!1)throw new D("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new D('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Jr extends X{constructor(r){const t=te({multi:!0},r);if("multi"in t&&t.multi!==!0)throw new D("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}}class ei extends X{constructor(r){const t=te({type:"directed",multi:!0},r);if("multi"in t&&t.multi!==!0)throw new D("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new D('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class ti extends X{constructor(r){const t=te({type:"undirected",multi:!0},r);if("multi"in t&&t.multi!==!0)throw new D("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new D('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}function Ke(n){n.from=function(r,t){const e=te({},r.options,t),i=new n(e);return i.import(r),i}}Ke(X);Ke(Xr);Ke(Qr);Ke(Jr);Ke(ei);Ke(ti);X.Graph=X;X.DirectedGraph=Xr;X.UndirectedGraph=Qr;X.MultiGraph=Jr;X.MultiDirectedGraph=ei;X.MultiUndirectedGraph=ti;X.InvalidArgumentsGraphError=D;X.NotFoundGraphError=A;X.UsageGraphError=U;function Hn(n,r){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var e=t.call(n,r);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function it(n){var r=Hn(n,"string");return typeof r=="symbol"?r:r+""}function re(n,r){if(!(n instanceof r))throw new TypeError("Cannot call a class as a function")}function tr(n,r){for(var t=0;t<r.length;t++){var e=r[t];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(n,it(e.key),e)}}function ie(n,r,t){return r&&tr(n.prototype,r),t&&tr(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function He(n){return He=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},He(n)}function ri(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ri=function(){return!!n})()}function Wn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function Vn(n,r){if(r&&(typeof r=="object"||typeof r=="function"))return r;if(r!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Wn(n)}function le(n,r,t){return r=He(r),Vn(n,ri()?Reflect.construct(r,t||[],He(n).constructor):r.apply(n,t))}function It(n,r){return It=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},It(n,r)}function he(n,r){if(typeof r!="function"&&r!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(r&&r.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),r&&It(n,r)}function qn(n){if(Array.isArray(n))return n}function Kn(n,r){var t=n==null?null:typeof Symbol<"u"&&n[Symbol.iterator]||n["@@iterator"];if(t!=null){var e,i,a,o,s=[],u=!0,l=!1;try{if(a=(t=t.call(n)).next,r===0){if(Object(t)!==t)return;u=!1}else for(;!(u=(e=a.call(t)).done)&&(s.push(e.value),s.length!==r);u=!0);}catch(h){l=!0,i=h}finally{try{if(!u&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function Ot(n,r){(r==null||r>n.length)&&(r=n.length);for(var t=0,e=Array(r);t<r;t++)e[t]=n[t];return e}function ii(n,r){if(n){if(typeof n=="string")return Ot(n,r);var t={}.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ot(n,r):void 0}}function Yn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function We(n,r){return qn(n)||Kn(n,r)||ii(n,r)||Yn()}var Ct={black:"#000000",silver:"#C0C0C0",gray:"#808080",grey:"#808080",white:"#FFFFFF",maroon:"#800000",red:"#FF0000",purple:"#800080",fuchsia:"#FF00FF",green:"#008000",lime:"#00FF00",olive:"#808000",yellow:"#FFFF00",navy:"#000080",blue:"#0000FF",teal:"#008080",aqua:"#00FFFF",darkblue:"#00008B",mediumblue:"#0000CD",darkgreen:"#006400",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",springgreen:"#00FF7F",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",rebeccapurple:"#663399",mediumaquamarine:"#66CDAA",dimgray:"#696969",dimgrey:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",slategrey:"#708090",lightslategray:"#778899",lightslategrey:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370DB",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",palevioletred:"#DB7093",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",lightyellow:"#FFFFE0",ivory:"#FFFFF0"},ni=new Int8Array(4),St=new Int32Array(ni.buffer,0,1),Zn=new Float32Array(ni.buffer,0,1),Xn=/^\s*rgba?\s*\(/,Qn=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Jn(n){var r=0,t=0,e=0,i=1;if(n[0]==="#")n.length===4?(r=parseInt(n.charAt(1)+n.charAt(1),16),t=parseInt(n.charAt(2)+n.charAt(2),16),e=parseInt(n.charAt(3)+n.charAt(3),16)):(r=parseInt(n.charAt(1)+n.charAt(2),16),t=parseInt(n.charAt(3)+n.charAt(4),16),e=parseInt(n.charAt(5)+n.charAt(6),16)),n.length===9&&(i=parseInt(n.charAt(7)+n.charAt(8),16)/255);else if(Xn.test(n)){var a=n.match(Qn);a&&(r=+a[1],t=+a[2],e=+a[3],a[4]&&(i=+a[4]))}return{r,g:t,b:e,a:i}}var Be={};for(var lt in Ct)Be[lt]=$e(Ct[lt]),Be[Ct[lt]]=Be[lt];function ai(n,r,t,e,i){return St[0]=e<<24|t<<16|r<<8|n,St[0]=St[0]&4278190079,Zn[0]}function $e(n){if(n=n.toLowerCase(),typeof Be[n]<"u")return Be[n];var r=Jn(n),t=r.r,e=r.g,i=r.b,a=r.a;a=a*255|0;var o=ai(t,e,i,a);return Be[n]=o,o}var Tt={};function oi(n){if(typeof Tt[n]<"u")return Tt[n];var r=(n&16711680)>>>16,t=(n&65280)>>>8,e=n&255,i=255,a=ai(r,t,e,i);return Tt[n]=a,a}function rr(n,r,t,e){return t+(r<<8)+(n<<16)}function ir(n,r,t,e,i,a){var o=Math.floor(t/a*i),s=Math.floor(n.drawingBufferHeight/a-e/a*i),u=new Uint8Array(4);n.bindFramebuffer(n.FRAMEBUFFER,r),n.readPixels(o,s,1,1,n.RGBA,n.UNSIGNED_BYTE,u);var l=We(u,4),h=l[0],d=l[1],c=l[2],f=l[3];return[h,d,c,f]}function T(n,r,t){return(r=it(r))in n?Object.defineProperty(n,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[r]=t,n}function nr(n,r){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(n);r&&(e=e.filter(function(i){return Object.getOwnPropertyDescriptor(n,i).enumerable})),t.push.apply(t,e)}return t}function F(n){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};r%2?nr(Object(t),!0).forEach(function(e){T(n,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):nr(Object(t)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))})}return n}function ea(n,r){for(;!{}.hasOwnProperty.call(n,r)&&(n=He(n))!==null;);return n}function zt(){return zt=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(n,r,t){var e=ea(n,r);if(e){var i=Object.getOwnPropertyDescriptor(e,r);return i.get?i.get.call(arguments.length<3?n:t):i.value}},zt.apply(null,arguments)}function si(n,r,t,e){var i=zt(He(n.prototype),r,t);return typeof i=="function"?function(a){return i.apply(t,a)}:i}function ta(n){return n.normalized?1:n.size}function Rt(n){var r=0;return n.forEach(function(t){return r+=ta(t)}),r}function ui(n,r,t){var e=n==="VERTEX"?r.VERTEX_SHADER:r.FRAGMENT_SHADER,i=r.createShader(e);if(i===null)throw new Error("loadShader: error while creating the shader");r.shaderSource(i,t),r.compileShader(i);var a=r.getShaderParameter(i,r.COMPILE_STATUS);if(!a){var o=r.getShaderInfoLog(i);throw r.deleteShader(i),new Error(`loadShader: error while compiling the shader:
|
|
3
3
|
`.concat(o,`
|
|
4
4
|
`).concat(t))}return i}function ra(n,r){return ui("VERTEX",n,r)}function ia(n,r){return ui("FRAGMENT",n,r)}function na(n,r){var t=n.createProgram();if(t===null)throw new Error("loadProgram: error while creating the program.");var e,i;for(e=0,i=r.length;e<i;e++)n.attachShader(t,r[e]);n.linkProgram(t);var a=n.getProgramParameter(t,n.LINK_STATUS);if(!a)throw n.deleteProgram(t),new Error("loadProgram: error while linking the program.");return t}function ar(n){var r=n.gl,t=n.buffer,e=n.program,i=n.vertexShader,a=n.fragmentShader;r.deleteShader(i),r.deleteShader(a),r.deleteProgram(e),r.deleteBuffer(t)}var or=`#define PICKING_MODE
|
package/dist/web/dashboard/dist/assets/{graph-section-B2T_NMja.js → graph-section-CyaVBqJB.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as x,j as e}from"./index-CW7bjrwy.js";import{H as E,P as T,g as V,c as W,E as Y,u as K,a as Z,i as q,B as U,C as X}from"./style-Cca8j3c-.js";import{e as b,f as L}from"./constants-lq4BIQN3.js";import{d as $}from"./index-BPPSD6wP.js";import"./index-C9AGF8Ai.js";const J=x.memo(function({data:r}){const a=b[r.siebelType]||"#6b7280";return e.jsxs(e.Fragment,{children:[e.jsx(E,{type:"target",position:T.Top,className:"!w-2 !h-2"}),e.jsx("div",{className:`bg-surface border border-edge rounded-lg shadow-sm hover:shadow-md transition-shadow cursor-pointer min-w-[200px] ${r.isImpacted?r.impactLevel==="direct"?"ring-2 ring-red-500/60":"ring-2 ring-orange-400/50":""} ${r.inactive?"opacity-50":""}`,children:e.jsxs("div",{className:"p-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase px-1.5 py-0.5 rounded",style:{background:`${a}20`,color:a},children:r.siebelType.replace(/_/g," ")}),r.inactive&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-surface-alt text-muted",children:"inactive"})]}),e.jsx("div",{className:"text-sm font-medium leading-tight line-clamp-2 mb-1",children:r.label}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-muted",children:[r.project&&e.jsx("span",{children:r.project}),e.jsxs("span",{children:[r.propertyCount," props"]}),r.childCount>0&&e.jsxs("span",{children:[r.childCount," children"]})]})]})}),e.jsx(E,{type:"source",position:T.Bottom,className:"!w-2 !h-2"})]})}),Q=x.memo(function({id:r,sourceX:a,sourceY:n,targetX:i,targetY:d,sourcePosition:o,targetPosition:h,style:l,data:t}){const[c,m,g]=V({sourceX:a,sourceY:n,sourcePosition:o,targetX:i,targetY:d,targetPosition:h});return e.jsxs(e.Fragment,{children:[e.jsx(W,{id:r,path:c,style:l}),(t==null?void 0:t.relationType)&&e.jsx(Y,{children:e.jsx("div",{className:"absolute text-[9px] px-1 py-0.5 rounded bg-surface border border-edge text-muted pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${m}px, ${g}px)`},children:t.relationType.replace(/_/g," ")})})]})});function ee({object:s,dependencies:r,onClose:a,onShowImpact:n,impactTarget:i}){const d=b[s.type]||"#6b7280",o=x.useMemo(()=>r.filter(t=>t.from.name===s.name&&t.from.type===s.type),[r,s]),h=x.useMemo(()=>r.filter(t=>t.to.name===s.name&&t.to.type===s.type),[r,s]),l=(i==null?void 0:i.name)===s.name&&(i==null?void 0:i.type)===s.type;return e.jsxs("aside",{className:"w-80 flex-shrink-0 border-l border-edge bg-surface-alt overflow-y-auto",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase px-1.5 py-0.5 rounded flex-shrink-0",style:{background:`${d}20`,color:d},children:s.type.replace(/_/g," ")}),s.inactive&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-surface text-muted",children:"inactive"})]}),e.jsx("h3",{className:"text-sm font-semibold truncate",children:s.name}),s.project&&e.jsx("p",{className:"text-xs text-muted",children:s.project})]}),e.jsx("button",{onClick:a,"aria-label":"Close detail panel",className:"p-1 text-muted hover:text-foreground cursor-pointer transition-colors",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"px-4 py-2 border-b border-edge",children:e.jsx("button",{onClick:()=>{l||n(s.type,s.name)},disabled:l,"aria-label":"Show impact analysis",className:`w-full px-3 py-1.5 text-xs font-medium rounded-md transition-opacity cursor-pointer ${l?"bg-orange-500/20 text-orange-400 cursor-default":"bg-accent text-white hover:opacity-90"}`,children:l?"Impact Analysis Active":"Show Impact"})}),s.properties.length>0&&e.jsxs("div",{className:"px-4 py-3 border-b border-edge",children:[e.jsxs("h4",{className:"text-[10px] font-semibold uppercase text-muted mb-2 tracking-wider",children:["Properties (",s.properties.length,")"]}),e.jsx("div",{className:"space-y-1 max-h-48 overflow-y-auto",children:s.properties.map((t,c)=>e.jsxs("div",{className:"flex gap-2 text-[11px]",children:[e.jsx("span",{className:"font-mono text-muted flex-shrink-0",children:t.name}),e.jsx("span",{className:"text-foreground truncate",children:t.value})]},c))})]}),s.children.length>0&&e.jsxs("div",{className:"px-4 py-3 border-b border-edge",children:[e.jsxs("h4",{className:"text-[10px] font-semibold uppercase text-muted mb-2 tracking-wider",children:["Children (",s.children.length,")"]}),e.jsx("div",{className:"space-y-1 max-h-48 overflow-y-auto",children:s.children.map((t,c)=>{const m=b[t.type]||"#6b7280";return e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"text-[9px] font-semibold uppercase px-1 py-0.5 rounded flex-shrink-0",style:{background:`${m}20`,color:m},children:t.type}),e.jsx("span",{className:"truncate",children:t.name})]},c)})})]}),o.length>0&&e.jsxs("div",{className:"px-4 py-3 border-b border-edge",children:[e.jsxs("h4",{className:"text-[10px] font-semibold uppercase text-muted mb-2 tracking-wider",children:["Depends On (",o.length,")"]}),e.jsx("div",{className:"space-y-1",children:o.map((t,c)=>{const m=b[t.to.type]||"#6b7280";return e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"text-[9px] font-semibold uppercase px-1 py-0.5 rounded flex-shrink-0",style:{background:`${m}20`,color:m},children:t.to.type.replace(/_/g," ")}),e.jsx("span",{className:"truncate",children:t.to.name}),e.jsx("span",{className:"text-[9px] text-muted ml-auto flex-shrink-0",children:t.relationType})]},c)})})]}),h.length>0&&e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("h4",{className:"text-[10px] font-semibold uppercase text-muted mb-2 tracking-wider",children:["Referenced By (",h.length,")"]}),e.jsx("div",{className:"space-y-1",children:h.map((t,c)=>{const m=b[t.from.type]||"#6b7280";return e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"text-[9px] font-semibold uppercase px-1 py-0.5 rounded flex-shrink-0",style:{background:`${m}20`,color:m},children:t.from.type.replace(/_/g," ")}),e.jsx("span",{className:"truncate",children:t.from.name}),e.jsx("span",{className:"text-[9px] text-muted ml-auto flex-shrink-0",children:t.relationType})]},c)})})]})]})}const w=220,B=72;function v(s,r){return`siebel:${s}:${r}`}function te(s,r,a){return s.filter(n=>{var i;return!((i=r==null?void 0:r.types)!=null&&i.size&&!r.types.has(n.type)||!(r!=null&&r.showInactive)&&n.inactive)}).map(n=>{const i=v(n.type,n.name),d=b[n.type]||"#6b7280",o=a==null?void 0:a.get(i);return{id:i,type:"siebelNode",position:{x:0,y:0},data:{label:n.name,siebelType:n.type,project:n.project,propertyCount:n.properties.length,childCount:n.children.length,inactive:n.inactive,sourceObject:n,isImpacted:!!o,impactLevel:o},style:{width:w,borderLeft:`4px solid ${d}`}}})}function se(s,r){return s.map((a,n)=>{const i=v(a.from.type,a.from.name),d=v(a.to.type,a.to.name);if(!r.has(i)||!r.has(d))return null;const o=L[a.relationType]||L.references;return{id:`siebel-edge-${n}`,source:i,target:d,label:o.label,type:"siebelEdge",data:{relationType:a.relationType,inferred:a.inferred},style:{stroke:o.color,strokeDasharray:o.dashed?"5 5":void 0},labelStyle:{fontSize:10,fill:"#6c757d"}}}).filter(a=>a!==null)}let j=null;function re(s,r,a){let n=0;const i=[a,...s,"|",...r];for(const d of i)for(let o=0;o<d.length;o++)n=(n<<5)-n+d.charCodeAt(o)|0;return n}function ne(s,r,a="TB"){const n=s.map(l=>l.id),i=r.map(l=>`${l.source}-${l.target}`),d=re(n,i,a);let o;if(j&&j.key===d)o=j.positions;else{const l=new $.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:a,ranksep:80,nodesep:50});for(const t of s)l.setNode(t.id,{width:w,height:B});for(const t of r)l.setEdge(t.source,t.target);$.layout(l),o=new Map;for(const t of s){const c=l.node(t.id);o.set(t.id,{x:c.x-w/2,y:c.y-B/2})}j={key:d,positions:o}}return{nodes:s.map(l=>{const t=o.get(l.id)??{x:0,y:0};return{...l,position:t}}),edges:r}}function oe(s,r,a){const n=v(r,a),i=new Map,d=new Map;for(const t of s){const c=v(t.to.type,t.to.name),m=v(t.from.type,t.from.name);d.has(c)||d.set(c,[]),d.get(c).push(m)}const o=[n],h=new Set([n]);let l=0;for(;o.length>0;){const t=o.length;l++;for(let c=0;c<t;c++){const m=o.shift(),g=d.get(m)||[];for(const N of g)h.has(N)||(h.add(N),i.set(N,l===1?"direct":"transitive"),o.push(N))}}return i}const ae={siebelNode:J},le={siebelEdge:Q},ie={hideAttribution:!0};function ue({objects:s,dependencies:r}){const[a,n,i]=K([]),[d,o,h]=Z([]),[l,t]=x.useState(null),[c,m]=x.useState("TB"),[g,N]=x.useState(new Set),[k,_]=x.useState(!1),[y,C]=x.useState(null),S=x.useDeferredValue(g),D=x.useMemo(()=>{const p=new Set;for(const u of s)p.add(u.type);return[...p].sort()},[s]),I=x.useMemo(()=>{if(y)return oe(r,y.type,y.name)},[r,y]);x.useEffect(()=>{if(s.length===0){n([]),o([]);return}const u=te(s,{types:S,showInactive:k},I),f=new Set(u.map(G=>G.id)),F=se(r,f),{nodes:R,edges:H}=ne(u,F,c);n(R),o(H)},[s,r,S,k,c,I,n,o]);const M=x.useCallback((p,u)=>{t(u.data.sourceObject)},[]),A=x.useCallback(()=>{t(null)},[]),P=x.useCallback(p=>{N(u=>{const f=new Set(u);return f.has(p)?f.delete(p):f.add(p),f})},[]),O=x.useCallback((p,u)=>{C({type:p,name:u})},[]),z=x.useCallback(()=>{C(null)},[]);return s.length===0?e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("svg",{className:"w-12 h-12 mx-auto text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:1,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7.5 14.25v2.25m3-4.5v4.5m3-6.75v6.75m3-9v9M6 20.25h12A2.25 2.25 0 0020.25 18V6A2.25 2.25 0 0018 3.75H6A2.25 2.25 0 003.75 6v12A2.25 2.25 0 006 20.25z"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"SIF Dependency Graph"}),e.jsx("p",{className:"text-xs text-muted mt-1",children:"Upload a .sif file to visualize Siebel object relationships"})]})]})}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 border-b border-edge bg-surface-alt",children:[e.jsx("div",{className:"flex flex-wrap gap-1 flex-1",children:D.map(p=>{const u=b[p]||"#6b7280",f=g.size===0||g.has(p);return e.jsx("button",{onClick:()=>P(p),"aria-label":`Filter ${p}`,"aria-pressed":g.has(p),className:"px-2 py-0.5 text-[10px] rounded-md border transition-colors cursor-pointer",style:{borderColor:f?u:"var(--color-border)",backgroundColor:f?`${u}15`:"transparent",color:f?u:"var(--color-text-muted)",opacity:f?1:.5},children:p.replace(/_/g," ")},p)})}),e.jsxs("div",{className:"flex items-center gap-1 border-l border-edge pl-3",children:[e.jsx("button",{onClick:()=>m("TB"),"aria-label":"Top to bottom layout",className:`px-2 py-0.5 text-[10px] rounded cursor-pointer transition-colors ${c==="TB"?"bg-accent/10 text-accent":"text-muted"}`,children:"TB"}),e.jsx("button",{onClick:()=>m("LR"),"aria-label":"Left to right layout",className:`px-2 py-0.5 text-[10px] rounded cursor-pointer transition-colors ${c==="LR"?"bg-accent/10 text-accent":"text-muted"}`,children:"LR"})]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] text-muted cursor-pointer border-l border-edge pl-3",children:[e.jsx("input",{type:"checkbox",checked:k,onChange:p=>_(p.target.checked),className:"rounded"}),"Inactive"]}),y&&e.jsxs("div",{className:"flex items-center gap-1.5 border-l border-edge pl-3",children:[e.jsxs("span",{className:"text-[10px] text-orange-400",children:["Impact: ",y.name]}),e.jsx("button",{onClick:z,"aria-label":"Clear impact analysis",className:"text-[10px] px-1.5 py-0.5 rounded bg-surface text-muted hover:text-foreground cursor-pointer transition-colors",children:"Clear"})]}),e.jsxs("span",{className:"text-[10px] text-muted",children:[a.length," nodes"]})]}),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsx("div",{className:"flex-1",children:e.jsxs(q,{nodes:a,edges:d,onNodesChange:i,onEdgesChange:h,onNodeClick:M,onPaneClick:A,nodeTypes:ae,edgeTypes:le,proOptions:ie,fitView:!0,fitViewOptions:{padding:.2},minZoom:.1,maxZoom:2,children:[e.jsx(U,{gap:16,size:1}),e.jsx(X,{showInteractive:!1})]})}),l&&e.jsx(ee,{object:l,dependencies:r,onClose:()=>t(null),onShowImpact:O,impactTarget:y})]})]})}export{ue as GraphSection};
|
|
1
|
+
import{r as x,j as e}from"./index-DUIBILM9.js";import{H as E,P as T,g as V,c as W,E as Y,u as K,a as Z,i as q,B as U,C as X}from"./style-D_2CfpkF.js";import{e as b,f as L}from"./constants-lq4BIQN3.js";import{d as $}from"./index-BpSI95md.js";import"./index-BKNOfKcX.js";const J=x.memo(function({data:r}){const a=b[r.siebelType]||"#6b7280";return e.jsxs(e.Fragment,{children:[e.jsx(E,{type:"target",position:T.Top,className:"!w-2 !h-2"}),e.jsx("div",{className:`bg-surface border border-edge rounded-lg shadow-sm hover:shadow-md transition-shadow cursor-pointer min-w-[200px] ${r.isImpacted?r.impactLevel==="direct"?"ring-2 ring-red-500/60":"ring-2 ring-orange-400/50":""} ${r.inactive?"opacity-50":""}`,children:e.jsxs("div",{className:"p-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase px-1.5 py-0.5 rounded",style:{background:`${a}20`,color:a},children:r.siebelType.replace(/_/g," ")}),r.inactive&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-surface-alt text-muted",children:"inactive"})]}),e.jsx("div",{className:"text-sm font-medium leading-tight line-clamp-2 mb-1",children:r.label}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-muted",children:[r.project&&e.jsx("span",{children:r.project}),e.jsxs("span",{children:[r.propertyCount," props"]}),r.childCount>0&&e.jsxs("span",{children:[r.childCount," children"]})]})]})}),e.jsx(E,{type:"source",position:T.Bottom,className:"!w-2 !h-2"})]})}),Q=x.memo(function({id:r,sourceX:a,sourceY:n,targetX:i,targetY:d,sourcePosition:o,targetPosition:h,style:l,data:t}){const[c,m,g]=V({sourceX:a,sourceY:n,sourcePosition:o,targetX:i,targetY:d,targetPosition:h});return e.jsxs(e.Fragment,{children:[e.jsx(W,{id:r,path:c,style:l}),(t==null?void 0:t.relationType)&&e.jsx(Y,{children:e.jsx("div",{className:"absolute text-[9px] px-1 py-0.5 rounded bg-surface border border-edge text-muted pointer-events-none",style:{transform:`translate(-50%, -50%) translate(${m}px, ${g}px)`},children:t.relationType.replace(/_/g," ")})})]})});function ee({object:s,dependencies:r,onClose:a,onShowImpact:n,impactTarget:i}){const d=b[s.type]||"#6b7280",o=x.useMemo(()=>r.filter(t=>t.from.name===s.name&&t.from.type===s.type),[r,s]),h=x.useMemo(()=>r.filter(t=>t.to.name===s.name&&t.to.type===s.type),[r,s]),l=(i==null?void 0:i.name)===s.name&&(i==null?void 0:i.type)===s.type;return e.jsxs("aside",{className:"w-80 flex-shrink-0 border-l border-edge bg-surface-alt overflow-y-auto",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-edge flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase px-1.5 py-0.5 rounded flex-shrink-0",style:{background:`${d}20`,color:d},children:s.type.replace(/_/g," ")}),s.inactive&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-surface text-muted",children:"inactive"})]}),e.jsx("h3",{className:"text-sm font-semibold truncate",children:s.name}),s.project&&e.jsx("p",{className:"text-xs text-muted",children:s.project})]}),e.jsx("button",{onClick:a,"aria-label":"Close detail panel",className:"p-1 text-muted hover:text-foreground cursor-pointer transition-colors",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"px-4 py-2 border-b border-edge",children:e.jsx("button",{onClick:()=>{l||n(s.type,s.name)},disabled:l,"aria-label":"Show impact analysis",className:`w-full px-3 py-1.5 text-xs font-medium rounded-md transition-opacity cursor-pointer ${l?"bg-orange-500/20 text-orange-400 cursor-default":"bg-accent text-white hover:opacity-90"}`,children:l?"Impact Analysis Active":"Show Impact"})}),s.properties.length>0&&e.jsxs("div",{className:"px-4 py-3 border-b border-edge",children:[e.jsxs("h4",{className:"text-[10px] font-semibold uppercase text-muted mb-2 tracking-wider",children:["Properties (",s.properties.length,")"]}),e.jsx("div",{className:"space-y-1 max-h-48 overflow-y-auto",children:s.properties.map((t,c)=>e.jsxs("div",{className:"flex gap-2 text-[11px]",children:[e.jsx("span",{className:"font-mono text-muted flex-shrink-0",children:t.name}),e.jsx("span",{className:"text-foreground truncate",children:t.value})]},c))})]}),s.children.length>0&&e.jsxs("div",{className:"px-4 py-3 border-b border-edge",children:[e.jsxs("h4",{className:"text-[10px] font-semibold uppercase text-muted mb-2 tracking-wider",children:["Children (",s.children.length,")"]}),e.jsx("div",{className:"space-y-1 max-h-48 overflow-y-auto",children:s.children.map((t,c)=>{const m=b[t.type]||"#6b7280";return e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"text-[9px] font-semibold uppercase px-1 py-0.5 rounded flex-shrink-0",style:{background:`${m}20`,color:m},children:t.type}),e.jsx("span",{className:"truncate",children:t.name})]},c)})})]}),o.length>0&&e.jsxs("div",{className:"px-4 py-3 border-b border-edge",children:[e.jsxs("h4",{className:"text-[10px] font-semibold uppercase text-muted mb-2 tracking-wider",children:["Depends On (",o.length,")"]}),e.jsx("div",{className:"space-y-1",children:o.map((t,c)=>{const m=b[t.to.type]||"#6b7280";return e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"text-[9px] font-semibold uppercase px-1 py-0.5 rounded flex-shrink-0",style:{background:`${m}20`,color:m},children:t.to.type.replace(/_/g," ")}),e.jsx("span",{className:"truncate",children:t.to.name}),e.jsx("span",{className:"text-[9px] text-muted ml-auto flex-shrink-0",children:t.relationType})]},c)})})]}),h.length>0&&e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("h4",{className:"text-[10px] font-semibold uppercase text-muted mb-2 tracking-wider",children:["Referenced By (",h.length,")"]}),e.jsx("div",{className:"space-y-1",children:h.map((t,c)=>{const m=b[t.from.type]||"#6b7280";return e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"text-[9px] font-semibold uppercase px-1 py-0.5 rounded flex-shrink-0",style:{background:`${m}20`,color:m},children:t.from.type.replace(/_/g," ")}),e.jsx("span",{className:"truncate",children:t.from.name}),e.jsx("span",{className:"text-[9px] text-muted ml-auto flex-shrink-0",children:t.relationType})]},c)})})]})]})}const w=220,B=72;function v(s,r){return`siebel:${s}:${r}`}function te(s,r,a){return s.filter(n=>{var i;return!((i=r==null?void 0:r.types)!=null&&i.size&&!r.types.has(n.type)||!(r!=null&&r.showInactive)&&n.inactive)}).map(n=>{const i=v(n.type,n.name),d=b[n.type]||"#6b7280",o=a==null?void 0:a.get(i);return{id:i,type:"siebelNode",position:{x:0,y:0},data:{label:n.name,siebelType:n.type,project:n.project,propertyCount:n.properties.length,childCount:n.children.length,inactive:n.inactive,sourceObject:n,isImpacted:!!o,impactLevel:o},style:{width:w,borderLeft:`4px solid ${d}`}}})}function se(s,r){return s.map((a,n)=>{const i=v(a.from.type,a.from.name),d=v(a.to.type,a.to.name);if(!r.has(i)||!r.has(d))return null;const o=L[a.relationType]||L.references;return{id:`siebel-edge-${n}`,source:i,target:d,label:o.label,type:"siebelEdge",data:{relationType:a.relationType,inferred:a.inferred},style:{stroke:o.color,strokeDasharray:o.dashed?"5 5":void 0},labelStyle:{fontSize:10,fill:"#6c757d"}}}).filter(a=>a!==null)}let j=null;function re(s,r,a){let n=0;const i=[a,...s,"|",...r];for(const d of i)for(let o=0;o<d.length;o++)n=(n<<5)-n+d.charCodeAt(o)|0;return n}function ne(s,r,a="TB"){const n=s.map(l=>l.id),i=r.map(l=>`${l.source}-${l.target}`),d=re(n,i,a);let o;if(j&&j.key===d)o=j.positions;else{const l=new $.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:a,ranksep:80,nodesep:50});for(const t of s)l.setNode(t.id,{width:w,height:B});for(const t of r)l.setEdge(t.source,t.target);$.layout(l),o=new Map;for(const t of s){const c=l.node(t.id);o.set(t.id,{x:c.x-w/2,y:c.y-B/2})}j={key:d,positions:o}}return{nodes:s.map(l=>{const t=o.get(l.id)??{x:0,y:0};return{...l,position:t}}),edges:r}}function oe(s,r,a){const n=v(r,a),i=new Map,d=new Map;for(const t of s){const c=v(t.to.type,t.to.name),m=v(t.from.type,t.from.name);d.has(c)||d.set(c,[]),d.get(c).push(m)}const o=[n],h=new Set([n]);let l=0;for(;o.length>0;){const t=o.length;l++;for(let c=0;c<t;c++){const m=o.shift(),g=d.get(m)||[];for(const N of g)h.has(N)||(h.add(N),i.set(N,l===1?"direct":"transitive"),o.push(N))}}return i}const ae={siebelNode:J},le={siebelEdge:Q},ie={hideAttribution:!0};function ue({objects:s,dependencies:r}){const[a,n,i]=K([]),[d,o,h]=Z([]),[l,t]=x.useState(null),[c,m]=x.useState("TB"),[g,N]=x.useState(new Set),[k,_]=x.useState(!1),[y,C]=x.useState(null),S=x.useDeferredValue(g),D=x.useMemo(()=>{const p=new Set;for(const u of s)p.add(u.type);return[...p].sort()},[s]),I=x.useMemo(()=>{if(y)return oe(r,y.type,y.name)},[r,y]);x.useEffect(()=>{if(s.length===0){n([]),o([]);return}const u=te(s,{types:S,showInactive:k},I),f=new Set(u.map(G=>G.id)),F=se(r,f),{nodes:R,edges:H}=ne(u,F,c);n(R),o(H)},[s,r,S,k,c,I,n,o]);const M=x.useCallback((p,u)=>{t(u.data.sourceObject)},[]),A=x.useCallback(()=>{t(null)},[]),P=x.useCallback(p=>{N(u=>{const f=new Set(u);return f.has(p)?f.delete(p):f.add(p),f})},[]),O=x.useCallback((p,u)=>{C({type:p,name:u})},[]),z=x.useCallback(()=>{C(null)},[]);return s.length===0?e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("svg",{className:"w-12 h-12 mx-auto text-muted",fill:"none",viewBox:"0 0 24 24",strokeWidth:1,stroke:"currentColor","aria-hidden":"true",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M7.5 14.25v2.25m3-4.5v4.5m3-6.75v6.75m3-9v9M6 20.25h12A2.25 2.25 0 0020.25 18V6A2.25 2.25 0 0018 3.75H6A2.25 2.25 0 003.75 6v12A2.25 2.25 0 006 20.25z"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-foreground",children:"SIF Dependency Graph"}),e.jsx("p",{className:"text-xs text-muted mt-1",children:"Upload a .sif file to visualize Siebel object relationships"})]})]})}):e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 border-b border-edge bg-surface-alt",children:[e.jsx("div",{className:"flex flex-wrap gap-1 flex-1",children:D.map(p=>{const u=b[p]||"#6b7280",f=g.size===0||g.has(p);return e.jsx("button",{onClick:()=>P(p),"aria-label":`Filter ${p}`,"aria-pressed":g.has(p),className:"px-2 py-0.5 text-[10px] rounded-md border transition-colors cursor-pointer",style:{borderColor:f?u:"var(--color-border)",backgroundColor:f?`${u}15`:"transparent",color:f?u:"var(--color-text-muted)",opacity:f?1:.5},children:p.replace(/_/g," ")},p)})}),e.jsxs("div",{className:"flex items-center gap-1 border-l border-edge pl-3",children:[e.jsx("button",{onClick:()=>m("TB"),"aria-label":"Top to bottom layout",className:`px-2 py-0.5 text-[10px] rounded cursor-pointer transition-colors ${c==="TB"?"bg-accent/10 text-accent":"text-muted"}`,children:"TB"}),e.jsx("button",{onClick:()=>m("LR"),"aria-label":"Left to right layout",className:`px-2 py-0.5 text-[10px] rounded cursor-pointer transition-colors ${c==="LR"?"bg-accent/10 text-accent":"text-muted"}`,children:"LR"})]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] text-muted cursor-pointer border-l border-edge pl-3",children:[e.jsx("input",{type:"checkbox",checked:k,onChange:p=>_(p.target.checked),className:"rounded"}),"Inactive"]}),y&&e.jsxs("div",{className:"flex items-center gap-1.5 border-l border-edge pl-3",children:[e.jsxs("span",{className:"text-[10px] text-orange-400",children:["Impact: ",y.name]}),e.jsx("button",{onClick:z,"aria-label":"Clear impact analysis",className:"text-[10px] px-1.5 py-0.5 rounded bg-surface text-muted hover:text-foreground cursor-pointer transition-colors",children:"Clear"})]}),e.jsxs("span",{className:"text-[10px] text-muted",children:[a.length," nodes"]})]}),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsx("div",{className:"flex-1",children:e.jsxs(q,{nodes:a,edges:d,onNodesChange:i,onEdgesChange:h,onNodeClick:M,onPaneClick:A,nodeTypes:ae,edgeTypes:le,proOptions:ie,fitView:!0,fitViewOptions:{padding:.2},minZoom:.1,maxZoom:2,children:[e.jsx(U,{gap:16,size:1}),e.jsx(X,{showInteractive:!1})]})}),l&&e.jsx(ee,{object:l,dependencies:r,onClose:()=>t(null),onShowImpact:O,impactTarget:y})]})]})}export{ue as GraphSection};
|