@mcp-graph-workflow/mcp-graph 5.0.4 → 5.1.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/README.md +4 -2
- package/dist/api/routes/benchmark.d.ts.map +1 -1
- package/dist/api/routes/benchmark.js +1 -2
- package/dist/api/routes/benchmark.js.map +1 -1
- package/dist/cli/commands/doctor.d.ts +3 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +55 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/core/doctor/doctor-checks.d.ts +43 -0
- package/dist/core/doctor/doctor-checks.d.ts.map +1 -0
- package/dist/core/doctor/doctor-checks.js +313 -0
- package/dist/core/doctor/doctor-checks.js.map +1 -0
- package/dist/core/doctor/doctor-runner.d.ts +6 -0
- package/dist/core/doctor/doctor-runner.d.ts.map +1 -0
- package/dist/core/doctor/doctor-runner.js +72 -0
- package/dist/core/doctor/doctor-runner.js.map +1 -0
- package/dist/core/doctor/doctor-types.d.ts +20 -0
- package/dist/core/doctor/doctor-types.d.ts.map +1 -0
- package/dist/core/doctor/doctor-types.js +5 -0
- package/dist/core/doctor/doctor-types.js.map +1 -0
- package/dist/core/planner/lifecycle-phase.d.ts +6 -0
- package/dist/core/planner/lifecycle-phase.d.ts.map +1 -1
- package/dist/core/planner/lifecycle-phase.js +23 -0
- package/dist/core/planner/lifecycle-phase.js.map +1 -1
- package/dist/mcp/lifecycle-wrapper.d.ts +2 -1
- package/dist/mcp/lifecycle-wrapper.d.ts.map +1 -1
- package/dist/mcp/lifecycle-wrapper.js +3 -0
- package/dist/mcp/lifecycle-wrapper.js.map +1 -1
- package/dist/web/dashboard/dist/assets/benchmark-tab-CuZsNkbP.js +1 -0
- package/dist/web/dashboard/dist/assets/{gitnexus-tab-DMCU41Nr.js → gitnexus-tab-D7If6lxT.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-tab-BK8wjCuY.js → graph-tab-Dp7PfUEJ.js} +1 -1
- package/dist/web/dashboard/dist/assets/{graph-utils-qelY_PVT.js → graph-utils-D5iPoiPD.js} +1 -1
- package/dist/web/dashboard/dist/assets/{index-BBlpGofr.js → index-CN9Wi5mu.js} +2 -2
- package/dist/web/dashboard/dist/assets/{insights-tab-OQnPT7h1.js → insights-tab-CLA0OIxd.js} +1 -1
- package/dist/web/dashboard/dist/assets/{logs-tab-BCwPTvn9.js → logs-tab-CSYlvuCu.js} +1 -1
- package/dist/web/dashboard/dist/assets/{prd-backlog-tab-DkTq385t.js → prd-backlog-tab-BBLpErTk.js} +1 -1
- package/dist/web/dashboard/dist/assets/{serena-tab-CZ8Lp8yJ.js → serena-tab-BxYP8nU5.js} +1 -1
- package/dist/web/dashboard/dist/index.html +1 -1
- package/package.json +2 -2
- package/dist/web/dashboard/dist/assets/benchmark-tab-5r5wZQij.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor-types.js","sourceRoot":"","sources":["../../../src/core/doctor/doctor-types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import type { GraphDocument } from "../graph/graph-types.js";
|
|
2
2
|
export type LifecyclePhase = "ANALYZE" | "DESIGN" | "PLAN" | "IMPLEMENT" | "VALIDATE" | "REVIEW" | "HANDOFF" | "LISTENING";
|
|
3
|
+
export interface McpAgentSuggestion {
|
|
4
|
+
name: string;
|
|
5
|
+
action: string;
|
|
6
|
+
tools?: string[];
|
|
7
|
+
}
|
|
3
8
|
export interface PhaseGuidance {
|
|
4
9
|
reminder: string;
|
|
5
10
|
suggestedTools: string[];
|
|
6
11
|
principles: string[];
|
|
12
|
+
suggestedMcpAgents?: McpAgentSuggestion[];
|
|
7
13
|
}
|
|
8
14
|
export interface PhaseDetectionOptions {
|
|
9
15
|
hasSnapshots?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle-phase.d.ts","sourceRoot":"","sources":["../../../src/core/planner/lifecycle-phase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,QAAQ,GACR,MAAM,GACN,WAAW,GACX,UAAU,GACV,QAAQ,GACR,SAAS,GACT,WAAW,CAAC;AAEhB,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"lifecycle-phase.d.ts","sourceRoot":"","sources":["../../../src/core/planner/lifecycle-phase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,QAAQ,GACR,MAAM,GACN,WAAW,GACX,UAAU,GACV,QAAQ,GACR,SAAS,GACT,WAAW,CAAC;AAEhB,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,kBAAkB,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAC3C;AAMD,MAAM,WAAW,qBAAqB;IACpC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CACvC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,cAAc,CAuDtG;AAwFD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,aAAa,CAErE;AAID,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,aAAa,EAClB,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,MAAM,GACf,gBAAgB,EAAE,CA8CpB"}
|
|
@@ -84,31 +84,54 @@ const GUIDANCE = {
|
|
|
84
84
|
reminder: "Fase DESIGN: Defina a arquitetura e tome decisões técnicas. Use análise de impacto antes de definir a estrutura.",
|
|
85
85
|
suggestedTools: ["add_node", "edge", "decompose", "export"],
|
|
86
86
|
principles: ["Skeleton & Organs", "Decisões arquiteturais documentadas", "Anti-one-shot"],
|
|
87
|
+
suggestedMcpAgents: [
|
|
88
|
+
{ name: "serena", action: "Análise semântica de symbols para entender arquitetura existente", tools: ["find_symbol", "get_symbols_overview"] },
|
|
89
|
+
{ name: "gitnexus", action: "Análise de impacto e blast radius da proposta arquitetural", tools: ["impact", "context"] },
|
|
90
|
+
],
|
|
87
91
|
},
|
|
88
92
|
PLAN: {
|
|
89
93
|
reminder: "Fase PLAN: Planeje o sprint, decomponha tasks grandes e sincronize documentação das libs.",
|
|
90
94
|
suggestedTools: ["plan_sprint", "decompose", "sync_stack_docs", "edge", "dependencies"],
|
|
91
95
|
principles: ["Decomposição atômica", "Sprint planning baseado em velocidade", "Dependências explícitas"],
|
|
96
|
+
suggestedMcpAgents: [
|
|
97
|
+
{ name: "context7", action: "Consultar docs atualizadas das libs do stack", tools: ["resolve-library-id", "query-docs"] },
|
|
98
|
+
],
|
|
92
99
|
},
|
|
93
100
|
IMPLEMENT: {
|
|
94
101
|
reminder: "Fase IMPLEMENT: TDD obrigatório — Red → Green → Refactor. Escreva o teste ANTES da implementação. Use `context` para token-efficiency.",
|
|
95
102
|
suggestedTools: ["next", "context", "update_status", "rag_context", "validate_task"],
|
|
96
103
|
principles: ["TDD Red→Green→Refactor", "Anti-one-shot", "Code detachment", "Decomposição atômica"],
|
|
104
|
+
suggestedMcpAgents: [
|
|
105
|
+
{ name: "serena", action: "Edição semântica de symbols e navegação por referências", tools: ["find_symbol", "replace_symbol_body", "find_referencing_symbols"] },
|
|
106
|
+
{ name: "gitnexus", action: "Impact analysis antes de editar, detect_changes antes de commit", tools: ["impact", "detect_changes", "context"] },
|
|
107
|
+
{ name: "context7", action: "Consultar API docs das libs em uso", tools: ["query-docs"] },
|
|
108
|
+
],
|
|
97
109
|
},
|
|
98
110
|
VALIDATE: {
|
|
99
111
|
reminder: "Fase VALIDATE: Valide tasks completadas com testes E2E (Playwright). Verifique critérios de aceitação.",
|
|
100
112
|
suggestedTools: ["validate_task", "velocity", "stats", "list"],
|
|
101
113
|
principles: ["Validação automatizada", "Critérios de aceitação como contrato", "Zero tolerance para regressões"],
|
|
114
|
+
suggestedMcpAgents: [
|
|
115
|
+
{ name: "gitnexus", action: "Verificar escopo das mudanças com detect_changes", tools: ["detect_changes"] },
|
|
116
|
+
{ name: "playwright", action: "Testes E2E no browser, screenshots e validação visual", tools: ["browser_navigate", "browser_snapshot", "browser_click"] },
|
|
117
|
+
],
|
|
102
118
|
},
|
|
103
119
|
REVIEW: {
|
|
104
120
|
reminder: "Fase REVIEW: Revise o código, verifique blast radius e garanta que nada quebrou. Exporte o grafo para revisão.",
|
|
105
121
|
suggestedTools: ["export", "stats", "velocity", "dependencies"],
|
|
106
122
|
principles: ["Code review obrigatório", "Blast radius check", "Non-regression rule"],
|
|
123
|
+
suggestedMcpAgents: [
|
|
124
|
+
{ name: "serena", action: "Verificar callers e referências dos symbols modificados", tools: ["find_referencing_symbols"] },
|
|
125
|
+
{ name: "gitnexus", action: "Blast radius final e verificação de escopo", tools: ["impact", "detect_changes"] },
|
|
126
|
+
],
|
|
107
127
|
},
|
|
108
128
|
HANDOFF: {
|
|
109
129
|
reminder: "Fase HANDOFF: Crie o PR, documente decisões e exporte o grafo. Prepare para entrega.",
|
|
110
130
|
suggestedTools: ["export", "snapshot", "stats", "velocity"],
|
|
111
131
|
principles: ["Documentação como entrega", "Grafo exportado", "Knowledge base atualizada"],
|
|
132
|
+
suggestedMcpAgents: [
|
|
133
|
+
{ name: "gitnexus", action: "Scope check final antes do PR", tools: ["detect_changes"] },
|
|
134
|
+
],
|
|
112
135
|
},
|
|
113
136
|
LISTENING: {
|
|
114
137
|
reminder: "Fase LISTENING: Colete feedback e adicione novos nodes ao grafo. Inicie novo ciclo se necessário.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle-phase.js","sourceRoot":"","sources":["../../../src/core/planner/lifecycle-phase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lifecycle-phase.js","sourceRoot":"","sources":["../../../src/core/planner/lifecycle-phase.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import type { SqliteStore } from "../core/store/sqlite-store.js";
|
|
3
3
|
import type { GraphDocument } from "../core/graph/graph-types.js";
|
|
4
|
-
import { type LifecyclePhase, type LifecycleWarning } from "../core/planner/lifecycle-phase.js";
|
|
4
|
+
import { type LifecyclePhase, type LifecycleWarning, type McpAgentSuggestion } from "../core/planner/lifecycle-phase.js";
|
|
5
5
|
export interface LifecycleBlock {
|
|
6
6
|
phase: LifecyclePhase;
|
|
7
7
|
reminder: string;
|
|
8
8
|
suggestedNext: string[];
|
|
9
9
|
principles: string[];
|
|
10
10
|
warnings: LifecycleWarning[];
|
|
11
|
+
suggestedMcpAgents?: McpAgentSuggestion[];
|
|
11
12
|
}
|
|
12
13
|
export interface LifecycleBlockOptions {
|
|
13
14
|
toolName?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle-wrapper.d.ts","sourceRoot":"","sources":["../../src/mcp/lifecycle-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAwD,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"lifecycle-wrapper.d.ts","sourceRoot":"","sources":["../../src/mcp/lifecycle-wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAwD,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAG/K,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,cAAc,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,gBAAgB,EAAE,CAAC;IAC7B,kBAAkB,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAC3C;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CACvC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,cAAc,CAoBvG;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,GAAG,MAAM,CAU1F;AAaD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CA0ClF"}
|
|
@@ -18,6 +18,9 @@ export function buildLifecycleBlock(doc, options) {
|
|
|
18
18
|
suggestedNext: guidance.suggestedTools,
|
|
19
19
|
principles: guidance.principles,
|
|
20
20
|
warnings,
|
|
21
|
+
...(guidance.suggestedMcpAgents && guidance.suggestedMcpAgents.length > 0
|
|
22
|
+
? { suggestedMcpAgents: guidance.suggestedMcpAgents }
|
|
23
|
+
: {}),
|
|
21
24
|
};
|
|
22
25
|
}
|
|
23
26
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle-wrapper.js","sourceRoot":"","sources":["../../src/mcp/lifecycle-wrapper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"lifecycle-wrapper.js","sourceRoot":"","sources":["../../src/mcp/lifecycle-wrapper.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,a as x,j as e}from"./index-CN9Wi5mu.js";function m(){const[r,o]=i.useState(null),[c,s]=i.useState(!0),[n,d]=i.useState(null);return i.useEffect(()=>{async function t(){try{const l=await x.request("/benchmark");o(l)}catch(l){d(l instanceof Error?l.message:"Failed to load benchmark data")}finally{s(!1)}}t()},[]),{data:r,loading:c,error:n}}function h(){const{data:r,loading:o,error:c}=m();if(o)return e.jsx("div",{className:"flex items-center justify-center h-full text-[var(--color-text-muted)]",children:"Loading benchmark data..."});if(c)return e.jsxs("div",{className:"flex items-center justify-center h-full text-[var(--color-danger)]",children:["Failed to load: ",c]});if(!r)return e.jsx("div",{});const{tokenEconomy:s,dependencyIntelligence:n,formulas:d}=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(a,{value:`${s.avgCompressionPercent}%`,label:"Avg Compress"}),e.jsx(a,{value:s.sampleSize>0?Math.round(s.totalTokensSaved/s.sampleSize).toLocaleString():"0",label:"Tokens Saved/Task"}),e.jsx(a,{value:s.totalNodes,label:"Nodes"}),e.jsx(a,{value:s.totalEdges,label:"Edges"})]}),s.perTaskMetrics.length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-[var(--color-text-muted)] mb-2",children:"Context Compression per Task"}),e.jsx("div",{className:"space-y-1.5","data-testid":"compression-bars",children:s.perTaskMetrics.slice(0,15).map(t=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-32 truncate",title:t.title,children:t.title}),e.jsx("div",{className:"flex-1 h-3 bg-[var(--color-bg-tertiary)] rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-[var(--color-accent)]",style:{width:`${Math.min(t.compressionPercent,100)}%`}})}),e.jsxs("span",{className:"text-[var(--color-text-muted)] w-24 text-right",children:[t.compressionPercent,"% (",t.estimatedTokens," tok)"]})]},t.id))})]})]}),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(a,{value:n.inferredDeps,label:"Auto Inferred"}),e.jsx(a,{value:`${n.blockedTasks}/${s.totalNodes}`,label:"Blocked Detected"}),e.jsx(a,{value:n.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-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] text-xs space-y-1","data-testid":"formulas-section",children:Object.entries(d).map(([t,l])=>e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("span",{className:"text-[var(--color-text-muted)] font-mono w-40 shrink-0",children:[t,":"]}),e.jsx("span",{children:l})]},t))})]}),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(a,{value:`$${s.costSavings.opusPerTask.toFixed(3)}`,label:"Opus Input"}),e.jsx(a,{value:`$${s.costSavings.sonnetPerTask.toFixed(3)}`,label:"Sonnet Input"})]})]})]})}function a({value:r,label:o}){return e.jsxs("div",{className:"p-3 rounded-lg bg-[var(--color-bg-secondary)] border border-[var(--color-border)] text-center","data-testid":"metric-card",children:[e.jsx("div",{className:"text-xl font-bold",children:r}),e.jsx("div",{className:"text-[10px] text-[var(--color-text-muted)] uppercase",children:o})]})}export{h as BenchmarkTab};
|
package/dist/web/dashboard/dist/assets/{gitnexus-tab-DMCU41Nr.js → gitnexus-tab-D7If6lxT.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as Ar,r as j,t as gt,j as E,a as Se}from"./index-BBlpGofr.js";import{C as ut,b as vi}from"./constants-BIEJOBya.js";var tt={exports:{}},Mt;function yi(){if(Mt)return tt.exports;Mt=1;var n=typeof Reflect=="object"?Reflect:null,r=n&&typeof n.apply=="function"?n.apply:function(v,S,T){return Function.prototype.apply.call(v,S,T)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(v){return Object.getOwnPropertyNames(v).concat(Object.getOwnPropertySymbols(v))}:t=function(v){return Object.getOwnPropertyNames(v)};function e(m){console&&console.warn&&console.warn(m)}var i=Number.isNaN||function(v){return v!==v};function a(){a.init.call(this)}tt.exports=a,tt.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(v){if(typeof v!="number"||v<0||i(v))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+v+".");return this._maxListeners=v,this};function u(m){return m._maxListeners===void 0?a.defaultMaxListeners:m._maxListeners}a.prototype.getMaxListeners=function(){return u(this)},a.prototype.emit=function(v){for(var S=[],T=1;T<arguments.length;T++)S.push(arguments[T]);var I=v==="error",P=this._events;if(P!==void 0)I=I&&P.error===void 0;else if(!I)return!1;if(I){var N;if(S.length>0&&(N=S[0]),N instanceof Error)throw N;var q=new Error("Unhandled error."+(N?" ("+N.message+")":""));throw q.context=N,q}var U=P[v];if(U===void 0)return!1;if(typeof U=="function")r(U,this,S);else for(var f=U.length,K=b(U,f),T=0;T<f;++T)r(K[T],this,S);return!0};function h(m,v,S,T){var I,P,N;if(s(S),P=m._events,P===void 0?(P=m._events=Object.create(null),m._eventsCount=0):(P.newListener!==void 0&&(m.emit("newListener",v,S.listener?S.listener:S),P=m._events),N=P[v]),N===void 0)N=P[v]=S,++m._eventsCount;else if(typeof N=="function"?N=P[v]=T?[S,N]:[N,S]:T?N.unshift(S):N.push(S),I=u(m),I>0&&N.length>I&&!N.warned){N.warned=!0;var q=new Error("Possible EventEmitter memory leak detected. "+N.length+" "+String(v)+" listeners added. Use emitter.setMaxListeners() to increase limit");q.name="MaxListenersExceededWarning",q.emitter=m,q.type=v,q.count=N.length,e(q)}return m}a.prototype.addListener=function(v,S){return h(this,v,S,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(v,S){return h(this,v,S,!0)};function d(){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 l(m,v,S){var T={fired:!1,wrapFn:void 0,target:m,type:v,listener:S},I=d.bind(T);return I.listener=S,T.wrapFn=I,I}a.prototype.once=function(v,S){return s(S),this.on(v,l(this,v,S)),this},a.prototype.prependOnceListener=function(v,S){return s(S),this.prependListener(v,l(this,v,S)),this},a.prototype.removeListener=function(v,S){var T,I,P,N,q;if(s(S),I=this._events,I===void 0)return this;if(T=I[v],T===void 0)return this;if(T===S||T.listener===S)--this._eventsCount===0?this._events=Object.create(null):(delete I[v],I.removeListener&&this.emit("removeListener",v,T.listener||S));else if(typeof T!="function"){for(P=-1,N=T.length-1;N>=0;N--)if(T[N]===S||T[N].listener===S){q=T[N].listener,P=N;break}if(P<0)return this;P===0?T.shift():w(T,P),T.length===1&&(I[v]=T[0]),I.removeListener!==void 0&&this.emit("removeListener",v,q||S)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(v){var S,T,I;if(T=this._events,T===void 0)return this;if(T.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):T[v]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete T[v]),this;if(arguments.length===0){var P=Object.keys(T),N;for(I=0;I<P.length;++I)N=P[I],N!=="removeListener"&&this.removeAllListeners(N);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(S=T[v],typeof S=="function")this.removeListener(v,S);else if(S!==void 0)for(I=S.length-1;I>=0;I--)this.removeListener(v,S[I]);return this};function c(m,v,S){var T=m._events;if(T===void 0)return[];var I=T[v];return I===void 0?[]:typeof I=="function"?S?[I.listener||I]:[I]:S?_(I):b(I,I.length)}a.prototype.listeners=function(v){return c(this,v,!0)},a.prototype.rawListeners=function(v){return c(this,v,!1)},a.listenerCount=function(m,v){return typeof m.listenerCount=="function"?m.listenerCount(v):g.call(m,v)},a.prototype.listenerCount=g;function g(m){var v=this._events;if(v!==void 0){var S=v[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,v){for(var S=new Array(v),T=0;T<v;++T)S[T]=m[T];return S}function w(m,v){for(;v+1<m.length;v++)m[v]=m[v+1];m.pop()}function _(m){for(var v=new Array(m.length),S=0;S<v.length;++S)v[S]=m[S].listener||m[S];return v}function L(m,v){return new Promise(function(S,T){function I(N){m.removeListener(v,P),T(N)}function P(){typeof m.removeListener=="function"&&m.removeListener("error",I),S([].slice.call(arguments))}k(m,v,P,{once:!0}),v!=="error"&&C(m,I,{once:!0})})}function C(m,v,S){typeof m.on=="function"&&k(m,"error",v,S)}function k(m,v,S,T){if(typeof m.on=="function")T.once?m.once(v,S):m.on(v,S);else if(typeof m.addEventListener=="function")m.addEventListener(v,function I(P){T.once&&m.removeEventListener(v,I),S(P)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof m)}return tt.exports}var kr=yi();function bi(){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 J=bi;typeof Object.assign=="function"&&(J=Object.assign);function ue(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 te(n){return typeof n=="object"&&n!==null}function Rr(n){let r;for(r in n)return!1;return!0}function oe(n,r,t){Object.defineProperty(n,r,{enumerable:!1,configurable:!1,writable:!0,value:t})}function le(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 Bt(n){return!(!te(n)||n.attributes&&!Array.isArray(n.attributes))}function wi(){let n=Math.floor(Math.random()*256)&255;return()=>n++}function ye(){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 Ne(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Pt extends Error{constructor(r){super(),this.name="GraphError",this.message=r}}class D extends Pt{constructor(r){super(r),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,D.prototype.constructor)}}class R extends Pt{constructor(r){super(r),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,R.prototype.constructor)}}class O extends Pt{constructor(r){super(r),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,O.prototype.constructor)}}function Lr(n,r){this.key=n,this.attributes=r,this.clear()}Lr.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 Dr(n,r){this.key=n,this.attributes=r,this.clear()}Dr.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Gr(n,r){this.key=n,this.attributes=r,this.clear()}Gr.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Fe(n,r,t,e,i){this.key=r,this.attributes=i,this.undirected=n,this.source=t,this.target=e}Fe.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)};Fe.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};Fe.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]};Fe.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 Nr=0,Fr=1,Ei=2,Pr=3;function be(n,r,t,e,i,a,o){let s,u,h,d;if(e=""+e,t===Nr){if(s=n._nodes.get(e),!s)throw new R(`Graph.${r}: could not find the "${e}" node in the graph.`);h=i,d=a}else if(t===Pr){if(i=""+i,u=n._edges.get(i),!u)throw new R(`Graph.${r}: could not find the "${i}" edge in the graph.`);const l=u.source.key,c=u.target.key;if(e===l)s=u.target;else if(e===c)s=u.source;else throw new R(`Graph.${r}: the "${e}" node is not attached to the "${i}" edge (${l}, ${c}).`);h=a,d=o}else{if(u=n._edges.get(e),!u)throw new R(`Graph.${r}: could not find the "${e}" edge in the graph.`);t===Fr?s=u.source:s=u.target,h=i,d=a}return[s,h,d]}function xi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=be(this,r,t,e,i,a);return o.attributes[s]}}function _i(n,r,t){n.prototype[r]=function(e,i){const[a]=be(this,r,t,e,i);return a.attributes}}function Si(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=be(this,r,t,e,i,a);return o.attributes.hasOwnProperty(s)}}function Ci(n,r,t){n.prototype[r]=function(e,i,a,o){const[s,u,h]=be(this,r,t,e,i,a,o);return s.attributes[u]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Ti(n,r,t){n.prototype[r]=function(e,i,a,o){const[s,u,h]=be(this,r,t,e,i,a,o);if(typeof h!="function")throw new D(`Graph.${r}: updater should be a function.`);const d=s.attributes,l=h(d[u]);return d[u]=l,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Ai(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=be(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 ki(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=be(this,r,t,e,i,a);if(!te(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 Ri(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=be(this,r,t,e,i,a);if(!te(s))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return J(o.attributes,s),this.emit("nodeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:s}),this}}function Li(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=be(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 Di=[{name:n=>`get${n}Attribute`,attacher:xi},{name:n=>`get${n}Attributes`,attacher:_i},{name:n=>`has${n}Attribute`,attacher:Si},{name:n=>`set${n}Attribute`,attacher:Ci},{name:n=>`update${n}Attribute`,attacher:Ti},{name:n=>`remove${n}Attribute`,attacher:Ai},{name:n=>`replace${n}Attributes`,attacher:ki},{name:n=>`merge${n}Attributes`,attacher:Ri},{name:n=>`update${n}Attributes`,attacher:Li}];function Gi(n){Di.forEach(function({name:r,attacher:t}){t(n,r("Node"),Nr),t(n,r("Source"),Fr),t(n,r("Target"),Ei),t(n,r("Opposite"),Pr)})}function Ni(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`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=ue(this,o,s,t),!a)throw new R(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new O(`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 R(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return a.attributes[i]}}function Fi(n,r,t){n.prototype[r]=function(e){let i;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new O(`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=ue(this,a,o,t),!i)throw new R(`Graph.${r}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(t!=="mixed")throw new O(`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 R(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return i.attributes}}function Pi(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`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=ue(this,o,s,t),!a)throw new R(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new O(`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 R(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return a.attributes.hasOwnProperty(i)}}function Ii(n,r,t){n.prototype[r]=function(e,i,a){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new O(`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=ue(this,s,u,t),!o)throw new R(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new O(`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 R(`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 zi(n,r,t){n.prototype[r]=function(e,i,a){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new O(`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=ue(this,s,u,t),!o)throw new R(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new O(`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 R(`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 Oi(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`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=ue(this,o,s,t),!a)throw new R(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new O(`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 R(`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 $i(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`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=ue(this,o,s,t),!a)throw new R(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new O(`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 R(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!te(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 Ui(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`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=ue(this,o,s,t),!a)throw new R(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new O(`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 R(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!te(i))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return J(a.attributes,i),this.emit("edgeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:i}),this}}function ji(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`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=ue(this,o,s,t),!a)throw new R(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new O(`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 R(`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 Mi=[{name:n=>`get${n}Attribute`,attacher:Ni},{name:n=>`get${n}Attributes`,attacher:Fi},{name:n=>`has${n}Attribute`,attacher:Pi},{name:n=>`set${n}Attribute`,attacher:Ii},{name:n=>`update${n}Attribute`,attacher:zi},{name:n=>`remove${n}Attribute`,attacher:Oi},{name:n=>`replace${n}Attributes`,attacher:$i},{name:n=>`merge${n}Attributes`,attacher:Ui},{name:n=>`update${n}Attributes`,attacher:ji}];function Bi(n){Mi.forEach(function({name:r,attacher:t}){t(n,r("Edge"),"mixed"),t(n,r("DirectedEdge"),"directed"),t(n,r("UndirectedEdge"),"undirected")})}const Hi=[{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 Wi(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 Vi(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 pt(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 qi(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 Ki(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 mt(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 Yi(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 Ir(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 h=r._edges.values();for(;o=h.next(),o.done!==!0;){if(s=o.value,i&&s.undirected!==a)continue;const{key:d,attributes:l,source:c,target:g}=s;if(u=e(d,l,c.key,g.key,c.attributes,g.attributes,s.undirected),n&&u)return d}}function Zi(n,r){if(n.size===0)return Ne();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 It(n,r,t,e,i,a){const o=r?Vi:Wi;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 Xi(n,r,t,e){const i=[];return It(!1,n,r,t,e,function(a){i.push(a)}),i}function Qi(n,r,t){let e=Ne();return n!=="undirected"&&(r!=="out"&&typeof t.in<"u"&&(e=ye(e,pt(t.in))),r!=="in"&&typeof t.out<"u"&&(e=ye(e,pt(t.out,r?void 0:t.key)))),n!=="directed"&&typeof t.undirected<"u"&&(e=ye(e,pt(t.undirected))),e}function zt(n,r,t,e,i,a,o){const s=t?Ki:qi;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 Ji(n,r,t,e,i){const a=[];return zt(!1,n,r,t,e,i,function(o){a.push(o)}),a}function en(n,r,t,e){let i=Ne();return n!=="undirected"&&(typeof t.in<"u"&&r!=="out"&&e in t.in&&(i=ye(i,mt(t.in,e))),typeof t.out<"u"&&r!=="in"&&e in t.out&&(r||t.key!==e)&&(i=ye(i,mt(t.out,e)))),n!=="directed"&&typeof t.undirected<"u"&&e in t.undirected&&(i=ye(i,mt(t.undirected,e))),i}function tn(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 Yi(this,e);if(arguments.length===1){a=""+a;const s=this._nodes.get(a);if(typeof s>"u")throw new R(`Graph.${t}: could not find the "${a}" node in the graph.`);return Xi(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 R(`Graph.${t}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(o))throw new R(`Graph.${t}: could not find the "${o}" target node in the graph.`);return Ji(e,this.multi,i,s,o)}throw new D(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function rn(n,r){const{name:t,type:e,direction:i}=r,a="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(h,d,l){if(!(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)){if(arguments.length===1)return l=h,Ir(!1,this,e,l);if(arguments.length===2){h=""+h,l=d;const c=this._nodes.get(h);if(typeof c>"u")throw new R(`Graph.${a}: could not find the "${h}" node in the graph.`);return It(!1,this.multi,e==="mixed"?this.type:e,i,c,l)}if(arguments.length===3){h=""+h,d=""+d;const c=this._nodes.get(h);if(!c)throw new R(`Graph.${a}: could not find the "${h}" source node in the graph.`);if(!this._nodes.has(d))throw new R(`Graph.${a}: could not find the "${d}" target node in the graph.`);return zt(!1,e,this.multi,i,c,d,l)}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 h=Array.prototype.slice.call(arguments),d=h.pop();let l;if(h.length===0){let c=0;e!=="directed"&&(c+=this.undirectedSize),e!=="undirected"&&(c+=this.directedSize),l=new Array(c);let g=0;h.push((b,w,_,L,C,k,m)=>{l[g++]=d(b,w,_,L,C,k,m)})}else l=[],h.push((c,g,b,w,_,L,C)=>{l.push(d(c,g,b,w,_,L,C))});return this[a].apply(this,h),l};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(){const h=Array.prototype.slice.call(arguments),d=h.pop(),l=[];return h.push((c,g,b,w,_,L,C)=>{d(c,g,b,w,_,L,C)&&l.push(c)}),this[a].apply(this,h),l};const u="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[u]=function(){let h=Array.prototype.slice.call(arguments);if(h.length<2||h.length>4)throw new D(`Graph.${u}: invalid number of arguments (expecting 2, 3 or 4 and got ${h.length}).`);if(typeof h[h.length-1]=="function"&&typeof h[h.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 d,l;h.length===2?(d=h[0],l=h[1],h=[]):h.length===3?(d=h[1],l=h[2],h=[h[0]]):h.length===4&&(d=h[2],l=h[3],h=[h[0],h[1]]);let c=l;return h.push((g,b,w,_,L,C,k)=>{c=d(c,g,b,w,_,L,C,k)}),this[a].apply(this,h),c}}function nn(n,r){const{name:t,type:e,direction:i}=r,a="find"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(u,h,d){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return!1;if(arguments.length===1)return d=u,Ir(!0,this,e,d);if(arguments.length===2){u=""+u,d=h;const l=this._nodes.get(u);if(typeof l>"u")throw new R(`Graph.${a}: could not find the "${u}" node in the graph.`);return It(!0,this.multi,e==="mixed"?this.type:e,i,l,d)}if(arguments.length===3){u=""+u,h=""+h;const l=this._nodes.get(u);if(!l)throw new R(`Graph.${a}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(h))throw new R(`Graph.${a}: could not find the "${h}" target node in the graph.`);return zt(!0,e,this.multi,i,l,h,d)}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),h=u.pop();return u.push((l,c,g,b,w,_,L)=>h(l,c,g,b,w,_,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),h=u.pop();return u.push((l,c,g,b,w,_,L)=>!h(l,c,g,b,w,_,L)),!this[a].apply(this,u)}}function an(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 Ne();if(!arguments.length)return Zi(this,e);if(arguments.length===1){o=""+o;const u=this._nodes.get(o);if(!u)throw new R(`Graph.${a}: could not find the "${o}" node in the graph.`);return Qi(e,i,u)}if(arguments.length===2){o=""+o,s=""+s;const u=this._nodes.get(o);if(!u)throw new R(`Graph.${a}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new R(`Graph.${a}: could not find the "${s}" target node in the graph.`);return en(e,i,u,s)}throw new D(`Graph.${a}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function on(n){Hi.forEach(r=>{tn(n,r),rn(n,r),nn(n,r),an(n,r)})}const sn=[{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 ht(){this.A=null,this.B=null}ht.prototype.wrap=function(n){this.A===null?this.A=n:this.B===null&&(this.B=n)};ht.prototype.has=function(n){return this.A!==null&&n in this.A||this.B!==null&&n in this.B};function $e(n,r,t,e,i){for(const a in e){const o=e[a],s=o.source,u=o.target,h=s===t?u:s;if(r&&r.has(h.key))continue;const d=i(h.key,h.attributes);if(n&&d)return h.key}}function Ot(n,r,t,e,i){if(r!=="mixed"){if(r==="undirected")return $e(n,null,e,e.undirected,i);if(typeof t=="string")return $e(n,null,e,e[t],i)}const a=new ht;let o;if(r!=="undirected"){if(t!=="out"){if(o=$e(n,null,e,e.in,i),n&&o)return o;a.wrap(e.in)}if(t!=="in"){if(o=$e(n,a,e,e.out,i),n&&o)return o;a.wrap(e.out)}}if(r!=="directed"&&(o=$e(n,a,e,e.undirected,i),n&&o))return o}function un(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 Ot(!1,n,r,t,function(i){e.push(i)}),e}function Ue(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,h=s.target;if(o=u===r?h:u,n&&n.has(o.key)){o=null;continue}}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function hn(n,r,t){if(n!=="mixed"){if(n==="undirected")return Ue(null,t,t.undirected);if(typeof r=="string")return Ue(null,t,t[r])}let e=Ne();const i=new ht;return n!=="undirected"&&(r!=="out"&&(e=ye(e,Ue(i,t,t.in))),r!=="in"&&(e=ye(e,Ue(i,t,t.out)))),n!=="directed"&&(e=ye(e,Ue(i,t,t.undirected))),e}function dn(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 R(`Graph.${t}: could not find the "${a}" node in the graph.`);return un(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(h,d){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;h=""+h;const l=this._nodes.get(h);if(typeof l>"u")throw new R(`Graph.${a}: could not find the "${h}" node in the graph.`);Ot(!1,e==="mixed"?this.type:e,i,l,d)};const o="map"+t[0].toUpperCase()+t.slice(1);n.prototype[o]=function(h,d){const l=[];return this[a](h,(c,g)=>{l.push(d(c,g))}),l};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(h,d){const l=[];return this[a](h,(c,g)=>{d(c,g)&&l.push(c)}),l};const u="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[u]=function(h,d,l){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=l;return this[a](h,(g,b)=>{c=d(c,g,b)}),c}}function cn(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(h,d){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;h=""+h;const l=this._nodes.get(h);if(typeof l>"u")throw new R(`Graph.${o}: could not find the "${h}" node in the graph.`);return Ot(!0,e==="mixed"?this.type:e,i,l,d)};const s="some"+a;n.prototype[s]=function(h,d){return!!this[o](h,d)};const u="every"+a;n.prototype[u]=function(h,d){return!this[o](h,(c,g)=>!d(c,g))}}function fn(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 Ne();o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new R(`Graph.${a}: could not find the "${o}" node in the graph.`);return hn(e==="mixed"?this.type:e,i,s)}}function gn(n){sn.forEach(r=>{dn(n,r),ln(n,r),cn(n,r),fn(n,r)})}function rt(n,r,t,e,i){const a=e._nodes.values(),o=e.type;let s,u,h,d,l,c;for(;s=a.next(),s.done!==!0;){let g=!1;if(u=s.value,o!=="undirected"){d=u.out;for(h in d){l=d[h];do c=l.target,g=!0,i(u.key,c.key,u.attributes,c.attributes,l.key,l.attributes,l.undirected),l=l.next;while(l)}}if(o!=="directed"){d=u.undirected;for(h in d)if(!(r&&u.key>h)){l=d[h];do c=l.target,c.key!==h&&(c=l.source),g=!0,i(u.key,c.key,u.attributes,c.attributes,l.key,l.attributes,l.undirected),l=l.next;while(l)}}t&&!g&&i(u.key,null,u.attributes,null,null,null,null)}}function pn(n,r){const t={key:n};return Rr(r.attributes)||(t.attributes=J({},r.attributes)),t}function mn(n,r,t){const e={key:r,source:t.source.key,target:t.target.key};return Rr(t.attributes)||(e.attributes=J({},t.attributes)),n==="mixed"&&t.undirected&&(e.undirected=!0),e}function vn(n){if(!te(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&&(!te(n.attributes)||n.attributes===null))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function yn(n){if(!te(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&&(!te(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 bn=wi(),wn=new Set(["directed","undirected","mixed"]),Ht=new Set(["domain","_events","_eventsCount","_maxListeners"]),En=[{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"}],xn={allowSelfLoops:!0,multi:!1,type:"mixed"};function _n(n,r,t){if(t&&!te(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 O(`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 Wt(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 O(`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 O(`Graph.${r}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!te(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 O(`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),h=n._nodes.get(o);if(!u)throw new R(`Graph.${r}: source node "${a}" not found.`);if(!h)throw new R(`Graph.${r}: target node "${o}" not found.`);const d={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 O(`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 O(`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 l=new Fe(e,i,u,h,s);n._edges.set(i,l);const c=a===o;return e?(u.undirectedDegree++,h.undirectedDegree++,c&&(u.undirectedLoops++,n._undirectedSelfLoopCount++)):(u.outDegree++,h.inDegree++,c&&(u.directedLoops++,n._directedSelfLoopCount++)),n.multi?l.attachMulti():l.attach(),e?n._undirectedSize++:n._directedSize++,d.key=i,n.emit("edgeAdded",d),i}function Sn(n,r,t,e,i,a,o,s,u){if(!e&&n.type==="undirected")throw new O(`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 O(`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(!te(s))throw new D(`Graph.${r}: invalid attributes. Expecting an object but got "${s}"`)}a=""+a,o=""+o;let h;if(u&&(h=s,s=void 0),!n.allowSelfLoops&&a===o)throw new O(`Graph.${r}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let d=n._nodes.get(a),l=n._nodes.get(o),c,g;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 O(`Graph.${r}: inconsistency detected when attempting to merge the "${i}" edge with "${a}" source & "${o}" target vs. ("${c.source.key}", "${c.target.key}").`);g=c}if(!g&&!n.multi&&d&&(g=e?d.undirected[o]:d.out[o]),g){const C=[g.key,!1,!1,!1];if(u?!h:!s)return C;if(u){const k=g.attributes;g.attributes=h(k),n.emit("edgeAttributesUpdated",{type:"replace",key:g.key,attributes:g.attributes})}else J(g.attributes,s),n.emit("edgeAttributesUpdated",{type:"merge",key:g.key,attributes:g.attributes,data:s});return C}s=s||{},u&&h&&(s=h(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 O(`Graph.${r}: the "${i}" edge already exists in the graph.`);let w=!1,_=!1;d||(d=Wt(n,a,{}),w=!0,a===o&&(l=d,_=!0)),l||(l=Wt(n,o,{}),_=!0),c=new Fe(e,i,d,l,s),n._edges.set(i,c);const L=a===o;return e?(d.undirectedDegree++,l.undirectedDegree++,L&&(d.undirectedLoops++,n._undirectedSelfLoopCount++)):(d.outDegree++,l.inDegree++,L&&(d.directedLoops++,n._directedSelfLoopCount++)),n.multi?c.attachMulti():c.attach(),e?n._undirectedSize++:n._directedSize++,b.key=i,n.emit("edgeAdded",b),[i,!0,w,_]}function Re(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 V extends kr.EventEmitter{constructor(r){if(super(),r=J({},xn,r),typeof r.multi!="boolean")throw new D(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${r.multi}".`);if(!wn.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"?Lr:r.type==="directed"?Dr:Gr;oe(this,"NodeDataClass",t);const e="geid_"+bn()+"_";let i=0;const a=()=>{let o;do o=e+i++;while(this._edges.has(o));return o};oe(this,"_attributes",{}),oe(this,"_nodes",new Map),oe(this,"_edges",new Map),oe(this,"_directedSize",0),oe(this,"_undirectedSize",0),oe(this,"_directedSelfLoopCount",0),oe(this,"_undirectedSelfLoopCount",0),oe(this,"_edgeKeyGenerator",a),oe(this,"_options",r),Ht.forEach(o=>oe(this,o,this[o])),le(this,"order",()=>this._nodes.size),le(this,"size",()=>this._edges.size),le(this,"directedSize",()=>this._directedSize),le(this,"undirectedSize",()=>this._undirectedSize),le(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),le(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),le(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),le(this,"multi",this._options.multi),le(this,"type",this._options.type),le(this,"allowSelfLoops",this._options.allowSelfLoops),le(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 O("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 R(`Graph.directedEdge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new R(`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 O("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 R(`Graph.undirectedEdge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new R(`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 O("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 R(`Graph.edge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`Graph.isSelfLoop: could not find the "${r}" edge in the graph.`);return t.source===t.target}addNode(r,t){return _n(this,r,t).key}mergeNode(r,t){if(t&&!te(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&&(J(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 R(`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 Re(this,e),e=e.next;while(e)}for(const i in t.in){e=t.in[i];do Re(this,e),e=e.next;while(e)}}if(this.type!=="directed")for(const i in t.undirected){e=t.undirected[i];do Re(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=ue(this,e,i,this.type),!t)throw new R(`Graph.dropEdge: could not find the "${e}" -> "${i}" edge in the graph.`)}else if(r=""+r,t=this._edges.get(r),!t)throw new R(`Graph.dropEdge: could not find the "${r}" edge in the graph.`);return Re(this,t),this}dropDirectedEdge(r,t){if(arguments.length<2)throw new O("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 O("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=ue(this,r,t,"directed");if(!e)throw new R(`Graph.dropDirectedEdge: could not find a "${r}" -> "${t}" edge in the graph.`);return Re(this,e),this}dropUndirectedEdge(r,t){if(arguments.length<2)throw new O("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 O("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=ue(this,r,t,"undirected");if(!e)throw new R(`Graph.dropUndirectedEdge: could not find a "${r}" -> "${t}" edge in the graph.`);return Re(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(!te(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(!te(r))throw new D("Graph.mergeAttributes: provided attributes are not a plain object.");return J(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&&!Bt(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&&!Bt(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.");rt(!1,!1,!1,this,r)}forEachAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new D("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");rt(!1,!1,!0,this,r)}forEachAssymetricAdjacencyEntry(r){if(typeof r!="function")throw new D("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");rt(!1,!0,!1,this,r)}forEachAssymetricAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new D("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");rt(!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++]=pn(a,i)});const e=new Array(this._edges.size);return t=0,this._edges.forEach((i,a)=>{e[t++]=mn(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 V)return r.forEachNode((u,h)=>{t?this.mergeNode(u,h):this.addNode(u,h)}),r.forEachEdge((u,h,d,l,c,g,b)=>{t?b?this.mergeUndirectedEdgeWithKey(u,d,l,h):this.mergeDirectedEdgeWithKey(u,d,l,h):b?this.addUndirectedEdgeWithKey(u,d,l,h):this.addDirectedEdgeWithKey(u,d,l,h)}),this;if(!te(r))throw new D("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(r.attributes){if(!te(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],vn(o);const{key:u,attributes:h}=o;t?this.mergeNode(u,h):this.addNode(u,h)}}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],yn(s);const{source:h,target:d,attributes:l,undirected:c=u}=s;let g;"key"in s?(g=t?c?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:c?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,g.call(this,s.key,h,d,l)):(g=t?c?this.mergeUndirectedEdge:this.mergeDirectedEdge:c?this.addUndirectedEdge:this.addDirectedEdge,g.call(this,h,d,l))}}return this}nullCopy(r){const t=new V(J({},this._options,r));return t.replaceAttributes(J({},this.getAttributes())),t}emptyCopy(r){const t=this.nullCopy(r);return this._nodes.forEach((e,i)=>{const a=J({},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 O(`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 O("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 O("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,J({},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="",h=a.source.key,d=a.target.key,l;a.undirected&&h>d&&(l=h,h=d,d=l);const c=`(${h})${s}(${d})`;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)&&!Ht.has(a)&&typeof this[a]!="function"&&typeof a!="symbol"&&(i[a]=this[a]);return i.attributes=this._attributes,i.nodes=r,i.edges=t,oe(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(V.prototype[Symbol.for("nodejs.util.inspect.custom")]=V.prototype.inspect);En.forEach(n=>{["add","merge","update"].forEach(r=>{const t=n.name(r),e=r==="add"?zr:Sn;n.generateKey?V.prototype[t]=function(i,a,o){return e(this,t,!0,(n.type||this.type)==="undirected",null,i,a,o,r==="update")}:V.prototype[t]=function(i,a,o,s){return e(this,t,!1,(n.type||this.type)==="undirected",i,a,o,s,r==="update")}})});Gi(V);Bi(V);on(V);gn(V);class Or extends V{constructor(r){const t=J({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 $r extends V{constructor(r){const t=J({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 Ur extends V{constructor(r){const t=J({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 jr extends V{constructor(r){const t=J({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 Mr extends V{constructor(r){const t=J({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 Pe(n){n.from=function(r,t){const e=J({},r.options,t),i=new n(e);return i.import(r),i}}Pe(V);Pe(Or);Pe($r);Pe(Ur);Pe(jr);Pe(Mr);V.Graph=V;V.DirectedGraph=Or;V.UndirectedGraph=$r;V.MultiGraph=Ur;V.MultiDirectedGraph=jr;V.MultiUndirectedGraph=Mr;V.InvalidArgumentsGraphError=D;V.NotFoundGraphError=R;V.UsageGraphError=O;function Cn(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 Ve(n){var r=Cn(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 Vt(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,Ve(e.key),e)}}function ie(n,r,t){return r&&Vt(n.prototype,r),t&&Vt(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function De(n){return De=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},De(n)}function Br(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Br=function(){return!!n})()}function Tn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function An(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 Tn(n)}function he(n,r,t){return r=De(r),An(n,Br()?Reflect.construct(r,t||[],De(n).constructor):r.apply(n,t))}function Rt(n,r){return Rt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Rt(n,r)}function de(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&&Rt(n,r)}function kn(n){if(Array.isArray(n))return n}function Rn(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,h=!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(d){h=!0,i=d}finally{try{if(!u&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(h)throw i}}return s}}function Lt(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 Hr(n,r){if(n){if(typeof n=="string")return Lt(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)?Lt(n,r):void 0}}function Ln(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
1
|
+
import{g as Ar,r as j,t as gt,j as E,a as Se}from"./index-CN9Wi5mu.js";import{C as ut,b as vi}from"./constants-BIEJOBya.js";var tt={exports:{}},Mt;function yi(){if(Mt)return tt.exports;Mt=1;var n=typeof Reflect=="object"?Reflect:null,r=n&&typeof n.apply=="function"?n.apply:function(v,S,T){return Function.prototype.apply.call(v,S,T)},t;n&&typeof n.ownKeys=="function"?t=n.ownKeys:Object.getOwnPropertySymbols?t=function(v){return Object.getOwnPropertyNames(v).concat(Object.getOwnPropertySymbols(v))}:t=function(v){return Object.getOwnPropertyNames(v)};function e(m){console&&console.warn&&console.warn(m)}var i=Number.isNaN||function(v){return v!==v};function a(){a.init.call(this)}tt.exports=a,tt.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(v){if(typeof v!="number"||v<0||i(v))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+v+".");return this._maxListeners=v,this};function u(m){return m._maxListeners===void 0?a.defaultMaxListeners:m._maxListeners}a.prototype.getMaxListeners=function(){return u(this)},a.prototype.emit=function(v){for(var S=[],T=1;T<arguments.length;T++)S.push(arguments[T]);var I=v==="error",P=this._events;if(P!==void 0)I=I&&P.error===void 0;else if(!I)return!1;if(I){var N;if(S.length>0&&(N=S[0]),N instanceof Error)throw N;var q=new Error("Unhandled error."+(N?" ("+N.message+")":""));throw q.context=N,q}var U=P[v];if(U===void 0)return!1;if(typeof U=="function")r(U,this,S);else for(var f=U.length,K=b(U,f),T=0;T<f;++T)r(K[T],this,S);return!0};function h(m,v,S,T){var I,P,N;if(s(S),P=m._events,P===void 0?(P=m._events=Object.create(null),m._eventsCount=0):(P.newListener!==void 0&&(m.emit("newListener",v,S.listener?S.listener:S),P=m._events),N=P[v]),N===void 0)N=P[v]=S,++m._eventsCount;else if(typeof N=="function"?N=P[v]=T?[S,N]:[N,S]:T?N.unshift(S):N.push(S),I=u(m),I>0&&N.length>I&&!N.warned){N.warned=!0;var q=new Error("Possible EventEmitter memory leak detected. "+N.length+" "+String(v)+" listeners added. Use emitter.setMaxListeners() to increase limit");q.name="MaxListenersExceededWarning",q.emitter=m,q.type=v,q.count=N.length,e(q)}return m}a.prototype.addListener=function(v,S){return h(this,v,S,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(v,S){return h(this,v,S,!0)};function d(){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 l(m,v,S){var T={fired:!1,wrapFn:void 0,target:m,type:v,listener:S},I=d.bind(T);return I.listener=S,T.wrapFn=I,I}a.prototype.once=function(v,S){return s(S),this.on(v,l(this,v,S)),this},a.prototype.prependOnceListener=function(v,S){return s(S),this.prependListener(v,l(this,v,S)),this},a.prototype.removeListener=function(v,S){var T,I,P,N,q;if(s(S),I=this._events,I===void 0)return this;if(T=I[v],T===void 0)return this;if(T===S||T.listener===S)--this._eventsCount===0?this._events=Object.create(null):(delete I[v],I.removeListener&&this.emit("removeListener",v,T.listener||S));else if(typeof T!="function"){for(P=-1,N=T.length-1;N>=0;N--)if(T[N]===S||T[N].listener===S){q=T[N].listener,P=N;break}if(P<0)return this;P===0?T.shift():w(T,P),T.length===1&&(I[v]=T[0]),I.removeListener!==void 0&&this.emit("removeListener",v,q||S)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(v){var S,T,I;if(T=this._events,T===void 0)return this;if(T.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):T[v]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete T[v]),this;if(arguments.length===0){var P=Object.keys(T),N;for(I=0;I<P.length;++I)N=P[I],N!=="removeListener"&&this.removeAllListeners(N);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(S=T[v],typeof S=="function")this.removeListener(v,S);else if(S!==void 0)for(I=S.length-1;I>=0;I--)this.removeListener(v,S[I]);return this};function c(m,v,S){var T=m._events;if(T===void 0)return[];var I=T[v];return I===void 0?[]:typeof I=="function"?S?[I.listener||I]:[I]:S?_(I):b(I,I.length)}a.prototype.listeners=function(v){return c(this,v,!0)},a.prototype.rawListeners=function(v){return c(this,v,!1)},a.listenerCount=function(m,v){return typeof m.listenerCount=="function"?m.listenerCount(v):g.call(m,v)},a.prototype.listenerCount=g;function g(m){var v=this._events;if(v!==void 0){var S=v[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,v){for(var S=new Array(v),T=0;T<v;++T)S[T]=m[T];return S}function w(m,v){for(;v+1<m.length;v++)m[v]=m[v+1];m.pop()}function _(m){for(var v=new Array(m.length),S=0;S<v.length;++S)v[S]=m[S].listener||m[S];return v}function L(m,v){return new Promise(function(S,T){function I(N){m.removeListener(v,P),T(N)}function P(){typeof m.removeListener=="function"&&m.removeListener("error",I),S([].slice.call(arguments))}k(m,v,P,{once:!0}),v!=="error"&&C(m,I,{once:!0})})}function C(m,v,S){typeof m.on=="function"&&k(m,"error",v,S)}function k(m,v,S,T){if(typeof m.on=="function")T.once?m.once(v,S):m.on(v,S);else if(typeof m.addEventListener=="function")m.addEventListener(v,function I(P){T.once&&m.removeEventListener(v,I),S(P)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof m)}return tt.exports}var kr=yi();function bi(){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 J=bi;typeof Object.assign=="function"&&(J=Object.assign);function ue(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 te(n){return typeof n=="object"&&n!==null}function Rr(n){let r;for(r in n)return!1;return!0}function oe(n,r,t){Object.defineProperty(n,r,{enumerable:!1,configurable:!1,writable:!0,value:t})}function le(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 Bt(n){return!(!te(n)||n.attributes&&!Array.isArray(n.attributes))}function wi(){let n=Math.floor(Math.random()*256)&255;return()=>n++}function ye(){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 Ne(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Pt extends Error{constructor(r){super(),this.name="GraphError",this.message=r}}class D extends Pt{constructor(r){super(r),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,D.prototype.constructor)}}class R extends Pt{constructor(r){super(r),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,R.prototype.constructor)}}class O extends Pt{constructor(r){super(r),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,O.prototype.constructor)}}function Lr(n,r){this.key=n,this.attributes=r,this.clear()}Lr.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 Dr(n,r){this.key=n,this.attributes=r,this.clear()}Dr.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Gr(n,r){this.key=n,this.attributes=r,this.clear()}Gr.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Fe(n,r,t,e,i){this.key=r,this.attributes=i,this.undirected=n,this.source=t,this.target=e}Fe.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)};Fe.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};Fe.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]};Fe.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 Nr=0,Fr=1,Ei=2,Pr=3;function be(n,r,t,e,i,a,o){let s,u,h,d;if(e=""+e,t===Nr){if(s=n._nodes.get(e),!s)throw new R(`Graph.${r}: could not find the "${e}" node in the graph.`);h=i,d=a}else if(t===Pr){if(i=""+i,u=n._edges.get(i),!u)throw new R(`Graph.${r}: could not find the "${i}" edge in the graph.`);const l=u.source.key,c=u.target.key;if(e===l)s=u.target;else if(e===c)s=u.source;else throw new R(`Graph.${r}: the "${e}" node is not attached to the "${i}" edge (${l}, ${c}).`);h=a,d=o}else{if(u=n._edges.get(e),!u)throw new R(`Graph.${r}: could not find the "${e}" edge in the graph.`);t===Fr?s=u.source:s=u.target,h=i,d=a}return[s,h,d]}function xi(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=be(this,r,t,e,i,a);return o.attributes[s]}}function _i(n,r,t){n.prototype[r]=function(e,i){const[a]=be(this,r,t,e,i);return a.attributes}}function Si(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=be(this,r,t,e,i,a);return o.attributes.hasOwnProperty(s)}}function Ci(n,r,t){n.prototype[r]=function(e,i,a,o){const[s,u,h]=be(this,r,t,e,i,a,o);return s.attributes[u]=h,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Ti(n,r,t){n.prototype[r]=function(e,i,a,o){const[s,u,h]=be(this,r,t,e,i,a,o);if(typeof h!="function")throw new D(`Graph.${r}: updater should be a function.`);const d=s.attributes,l=h(d[u]);return d[u]=l,this.emit("nodeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:u}),this}}function Ai(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=be(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 ki(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=be(this,r,t,e,i,a);if(!te(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 Ri(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=be(this,r,t,e,i,a);if(!te(s))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return J(o.attributes,s),this.emit("nodeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:s}),this}}function Li(n,r,t){n.prototype[r]=function(e,i,a){const[o,s]=be(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 Di=[{name:n=>`get${n}Attribute`,attacher:xi},{name:n=>`get${n}Attributes`,attacher:_i},{name:n=>`has${n}Attribute`,attacher:Si},{name:n=>`set${n}Attribute`,attacher:Ci},{name:n=>`update${n}Attribute`,attacher:Ti},{name:n=>`remove${n}Attribute`,attacher:Ai},{name:n=>`replace${n}Attributes`,attacher:ki},{name:n=>`merge${n}Attributes`,attacher:Ri},{name:n=>`update${n}Attributes`,attacher:Li}];function Gi(n){Di.forEach(function({name:r,attacher:t}){t(n,r("Node"),Nr),t(n,r("Source"),Fr),t(n,r("Target"),Ei),t(n,r("Opposite"),Pr)})}function Ni(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`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=ue(this,o,s,t),!a)throw new R(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new O(`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 R(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return a.attributes[i]}}function Fi(n,r,t){n.prototype[r]=function(e){let i;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new O(`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=ue(this,a,o,t),!i)throw new R(`Graph.${r}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(t!=="mixed")throw new O(`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 R(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return i.attributes}}function Pi(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`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=ue(this,o,s,t),!a)throw new R(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new O(`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 R(`Graph.${r}: could not find the "${e}" edge in the graph.`)}return a.attributes.hasOwnProperty(i)}}function Ii(n,r,t){n.prototype[r]=function(e,i,a){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new O(`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=ue(this,s,u,t),!o)throw new R(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new O(`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 R(`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 zi(n,r,t){n.prototype[r]=function(e,i,a){let o;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new O(`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=ue(this,s,u,t),!o)throw new R(`Graph.${r}: could not find an edge for the given path ("${s}" - "${u}").`)}else{if(t!=="mixed")throw new O(`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 R(`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 Oi(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`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=ue(this,o,s,t),!a)throw new R(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new O(`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 R(`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 $i(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`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=ue(this,o,s,t),!a)throw new R(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new O(`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 R(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!te(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 Ui(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`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=ue(this,o,s,t),!a)throw new R(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new O(`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 R(`Graph.${r}: could not find the "${e}" edge in the graph.`)}if(!te(i))throw new D(`Graph.${r}: provided attributes are not a plain object.`);return J(a.attributes,i),this.emit("edgeAttributesUpdated",{key:a.key,type:"merge",attributes:a.attributes,data:i}),this}}function ji(n,r,t){n.prototype[r]=function(e,i){let a;if(this.type!=="mixed"&&t!=="mixed"&&t!==this.type)throw new O(`Graph.${r}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new O(`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=ue(this,o,s,t),!a)throw new R(`Graph.${r}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(t!=="mixed")throw new O(`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 R(`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 Mi=[{name:n=>`get${n}Attribute`,attacher:Ni},{name:n=>`get${n}Attributes`,attacher:Fi},{name:n=>`has${n}Attribute`,attacher:Pi},{name:n=>`set${n}Attribute`,attacher:Ii},{name:n=>`update${n}Attribute`,attacher:zi},{name:n=>`remove${n}Attribute`,attacher:Oi},{name:n=>`replace${n}Attributes`,attacher:$i},{name:n=>`merge${n}Attributes`,attacher:Ui},{name:n=>`update${n}Attributes`,attacher:ji}];function Bi(n){Mi.forEach(function({name:r,attacher:t}){t(n,r("Edge"),"mixed"),t(n,r("DirectedEdge"),"directed"),t(n,r("UndirectedEdge"),"undirected")})}const Hi=[{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 Wi(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 Vi(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 pt(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 qi(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 Ki(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 mt(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 Yi(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 Ir(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 h=r._edges.values();for(;o=h.next(),o.done!==!0;){if(s=o.value,i&&s.undirected!==a)continue;const{key:d,attributes:l,source:c,target:g}=s;if(u=e(d,l,c.key,g.key,c.attributes,g.attributes,s.undirected),n&&u)return d}}function Zi(n,r){if(n.size===0)return Ne();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 It(n,r,t,e,i,a){const o=r?Vi:Wi;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 Xi(n,r,t,e){const i=[];return It(!1,n,r,t,e,function(a){i.push(a)}),i}function Qi(n,r,t){let e=Ne();return n!=="undirected"&&(r!=="out"&&typeof t.in<"u"&&(e=ye(e,pt(t.in))),r!=="in"&&typeof t.out<"u"&&(e=ye(e,pt(t.out,r?void 0:t.key)))),n!=="directed"&&typeof t.undirected<"u"&&(e=ye(e,pt(t.undirected))),e}function zt(n,r,t,e,i,a,o){const s=t?Ki:qi;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 Ji(n,r,t,e,i){const a=[];return zt(!1,n,r,t,e,i,function(o){a.push(o)}),a}function en(n,r,t,e){let i=Ne();return n!=="undirected"&&(typeof t.in<"u"&&r!=="out"&&e in t.in&&(i=ye(i,mt(t.in,e))),typeof t.out<"u"&&r!=="in"&&e in t.out&&(r||t.key!==e)&&(i=ye(i,mt(t.out,e)))),n!=="directed"&&typeof t.undirected<"u"&&e in t.undirected&&(i=ye(i,mt(t.undirected,e))),i}function tn(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 Yi(this,e);if(arguments.length===1){a=""+a;const s=this._nodes.get(a);if(typeof s>"u")throw new R(`Graph.${t}: could not find the "${a}" node in the graph.`);return Xi(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 R(`Graph.${t}: could not find the "${a}" source node in the graph.`);if(!this._nodes.has(o))throw new R(`Graph.${t}: could not find the "${o}" target node in the graph.`);return Ji(e,this.multi,i,s,o)}throw new D(`Graph.${t}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function rn(n,r){const{name:t,type:e,direction:i}=r,a="forEach"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(h,d,l){if(!(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)){if(arguments.length===1)return l=h,Ir(!1,this,e,l);if(arguments.length===2){h=""+h,l=d;const c=this._nodes.get(h);if(typeof c>"u")throw new R(`Graph.${a}: could not find the "${h}" node in the graph.`);return It(!1,this.multi,e==="mixed"?this.type:e,i,c,l)}if(arguments.length===3){h=""+h,d=""+d;const c=this._nodes.get(h);if(!c)throw new R(`Graph.${a}: could not find the "${h}" source node in the graph.`);if(!this._nodes.has(d))throw new R(`Graph.${a}: could not find the "${d}" target node in the graph.`);return zt(!1,e,this.multi,i,c,d,l)}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 h=Array.prototype.slice.call(arguments),d=h.pop();let l;if(h.length===0){let c=0;e!=="directed"&&(c+=this.undirectedSize),e!=="undirected"&&(c+=this.directedSize),l=new Array(c);let g=0;h.push((b,w,_,L,C,k,m)=>{l[g++]=d(b,w,_,L,C,k,m)})}else l=[],h.push((c,g,b,w,_,L,C)=>{l.push(d(c,g,b,w,_,L,C))});return this[a].apply(this,h),l};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(){const h=Array.prototype.slice.call(arguments),d=h.pop(),l=[];return h.push((c,g,b,w,_,L,C)=>{d(c,g,b,w,_,L,C)&&l.push(c)}),this[a].apply(this,h),l};const u="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[u]=function(){let h=Array.prototype.slice.call(arguments);if(h.length<2||h.length>4)throw new D(`Graph.${u}: invalid number of arguments (expecting 2, 3 or 4 and got ${h.length}).`);if(typeof h[h.length-1]=="function"&&typeof h[h.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 d,l;h.length===2?(d=h[0],l=h[1],h=[]):h.length===3?(d=h[1],l=h[2],h=[h[0]]):h.length===4&&(d=h[2],l=h[3],h=[h[0],h[1]]);let c=l;return h.push((g,b,w,_,L,C,k)=>{c=d(c,g,b,w,_,L,C,k)}),this[a].apply(this,h),c}}function nn(n,r){const{name:t,type:e,direction:i}=r,a="find"+t[0].toUpperCase()+t.slice(1,-1);n.prototype[a]=function(u,h,d){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return!1;if(arguments.length===1)return d=u,Ir(!0,this,e,d);if(arguments.length===2){u=""+u,d=h;const l=this._nodes.get(u);if(typeof l>"u")throw new R(`Graph.${a}: could not find the "${u}" node in the graph.`);return It(!0,this.multi,e==="mixed"?this.type:e,i,l,d)}if(arguments.length===3){u=""+u,h=""+h;const l=this._nodes.get(u);if(!l)throw new R(`Graph.${a}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(h))throw new R(`Graph.${a}: could not find the "${h}" target node in the graph.`);return zt(!0,e,this.multi,i,l,h,d)}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),h=u.pop();return u.push((l,c,g,b,w,_,L)=>h(l,c,g,b,w,_,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),h=u.pop();return u.push((l,c,g,b,w,_,L)=>!h(l,c,g,b,w,_,L)),!this[a].apply(this,u)}}function an(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 Ne();if(!arguments.length)return Zi(this,e);if(arguments.length===1){o=""+o;const u=this._nodes.get(o);if(!u)throw new R(`Graph.${a}: could not find the "${o}" node in the graph.`);return Qi(e,i,u)}if(arguments.length===2){o=""+o,s=""+s;const u=this._nodes.get(o);if(!u)throw new R(`Graph.${a}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new R(`Graph.${a}: could not find the "${s}" target node in the graph.`);return en(e,i,u,s)}throw new D(`Graph.${a}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function on(n){Hi.forEach(r=>{tn(n,r),rn(n,r),nn(n,r),an(n,r)})}const sn=[{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 ht(){this.A=null,this.B=null}ht.prototype.wrap=function(n){this.A===null?this.A=n:this.B===null&&(this.B=n)};ht.prototype.has=function(n){return this.A!==null&&n in this.A||this.B!==null&&n in this.B};function $e(n,r,t,e,i){for(const a in e){const o=e[a],s=o.source,u=o.target,h=s===t?u:s;if(r&&r.has(h.key))continue;const d=i(h.key,h.attributes);if(n&&d)return h.key}}function Ot(n,r,t,e,i){if(r!=="mixed"){if(r==="undirected")return $e(n,null,e,e.undirected,i);if(typeof t=="string")return $e(n,null,e,e[t],i)}const a=new ht;let o;if(r!=="undirected"){if(t!=="out"){if(o=$e(n,null,e,e.in,i),n&&o)return o;a.wrap(e.in)}if(t!=="in"){if(o=$e(n,a,e,e.out,i),n&&o)return o;a.wrap(e.out)}}if(r!=="directed"&&(o=$e(n,a,e,e.undirected,i),n&&o))return o}function un(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 Ot(!1,n,r,t,function(i){e.push(i)}),e}function Ue(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,h=s.target;if(o=u===r?h:u,n&&n.has(o.key)){o=null;continue}}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function hn(n,r,t){if(n!=="mixed"){if(n==="undirected")return Ue(null,t,t.undirected);if(typeof r=="string")return Ue(null,t,t[r])}let e=Ne();const i=new ht;return n!=="undirected"&&(r!=="out"&&(e=ye(e,Ue(i,t,t.in))),r!=="in"&&(e=ye(e,Ue(i,t,t.out)))),n!=="directed"&&(e=ye(e,Ue(i,t,t.undirected))),e}function dn(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 R(`Graph.${t}: could not find the "${a}" node in the graph.`);return un(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(h,d){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;h=""+h;const l=this._nodes.get(h);if(typeof l>"u")throw new R(`Graph.${a}: could not find the "${h}" node in the graph.`);Ot(!1,e==="mixed"?this.type:e,i,l,d)};const o="map"+t[0].toUpperCase()+t.slice(1);n.prototype[o]=function(h,d){const l=[];return this[a](h,(c,g)=>{l.push(d(c,g))}),l};const s="filter"+t[0].toUpperCase()+t.slice(1);n.prototype[s]=function(h,d){const l=[];return this[a](h,(c,g)=>{d(c,g)&&l.push(c)}),l};const u="reduce"+t[0].toUpperCase()+t.slice(1);n.prototype[u]=function(h,d,l){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=l;return this[a](h,(g,b)=>{c=d(c,g,b)}),c}}function cn(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(h,d){if(e!=="mixed"&&this.type!=="mixed"&&e!==this.type)return;h=""+h;const l=this._nodes.get(h);if(typeof l>"u")throw new R(`Graph.${o}: could not find the "${h}" node in the graph.`);return Ot(!0,e==="mixed"?this.type:e,i,l,d)};const s="some"+a;n.prototype[s]=function(h,d){return!!this[o](h,d)};const u="every"+a;n.prototype[u]=function(h,d){return!this[o](h,(c,g)=>!d(c,g))}}function fn(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 Ne();o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new R(`Graph.${a}: could not find the "${o}" node in the graph.`);return hn(e==="mixed"?this.type:e,i,s)}}function gn(n){sn.forEach(r=>{dn(n,r),ln(n,r),cn(n,r),fn(n,r)})}function rt(n,r,t,e,i){const a=e._nodes.values(),o=e.type;let s,u,h,d,l,c;for(;s=a.next(),s.done!==!0;){let g=!1;if(u=s.value,o!=="undirected"){d=u.out;for(h in d){l=d[h];do c=l.target,g=!0,i(u.key,c.key,u.attributes,c.attributes,l.key,l.attributes,l.undirected),l=l.next;while(l)}}if(o!=="directed"){d=u.undirected;for(h in d)if(!(r&&u.key>h)){l=d[h];do c=l.target,c.key!==h&&(c=l.source),g=!0,i(u.key,c.key,u.attributes,c.attributes,l.key,l.attributes,l.undirected),l=l.next;while(l)}}t&&!g&&i(u.key,null,u.attributes,null,null,null,null)}}function pn(n,r){const t={key:n};return Rr(r.attributes)||(t.attributes=J({},r.attributes)),t}function mn(n,r,t){const e={key:r,source:t.source.key,target:t.target.key};return Rr(t.attributes)||(e.attributes=J({},t.attributes)),n==="mixed"&&t.undirected&&(e.undirected=!0),e}function vn(n){if(!te(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&&(!te(n.attributes)||n.attributes===null))throw new D("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function yn(n){if(!te(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&&(!te(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 bn=wi(),wn=new Set(["directed","undirected","mixed"]),Ht=new Set(["domain","_events","_eventsCount","_maxListeners"]),En=[{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"}],xn={allowSelfLoops:!0,multi:!1,type:"mixed"};function _n(n,r,t){if(t&&!te(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 O(`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 Wt(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 O(`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 O(`Graph.${r}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(s&&!te(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 O(`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),h=n._nodes.get(o);if(!u)throw new R(`Graph.${r}: source node "${a}" not found.`);if(!h)throw new R(`Graph.${r}: target node "${o}" not found.`);const d={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 O(`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 O(`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 l=new Fe(e,i,u,h,s);n._edges.set(i,l);const c=a===o;return e?(u.undirectedDegree++,h.undirectedDegree++,c&&(u.undirectedLoops++,n._undirectedSelfLoopCount++)):(u.outDegree++,h.inDegree++,c&&(u.directedLoops++,n._directedSelfLoopCount++)),n.multi?l.attachMulti():l.attach(),e?n._undirectedSize++:n._directedSize++,d.key=i,n.emit("edgeAdded",d),i}function Sn(n,r,t,e,i,a,o,s,u){if(!e&&n.type==="undirected")throw new O(`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 O(`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(!te(s))throw new D(`Graph.${r}: invalid attributes. Expecting an object but got "${s}"`)}a=""+a,o=""+o;let h;if(u&&(h=s,s=void 0),!n.allowSelfLoops&&a===o)throw new O(`Graph.${r}: source & target are the same ("${a}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let d=n._nodes.get(a),l=n._nodes.get(o),c,g;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 O(`Graph.${r}: inconsistency detected when attempting to merge the "${i}" edge with "${a}" source & "${o}" target vs. ("${c.source.key}", "${c.target.key}").`);g=c}if(!g&&!n.multi&&d&&(g=e?d.undirected[o]:d.out[o]),g){const C=[g.key,!1,!1,!1];if(u?!h:!s)return C;if(u){const k=g.attributes;g.attributes=h(k),n.emit("edgeAttributesUpdated",{type:"replace",key:g.key,attributes:g.attributes})}else J(g.attributes,s),n.emit("edgeAttributesUpdated",{type:"merge",key:g.key,attributes:g.attributes,data:s});return C}s=s||{},u&&h&&(s=h(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 O(`Graph.${r}: the "${i}" edge already exists in the graph.`);let w=!1,_=!1;d||(d=Wt(n,a,{}),w=!0,a===o&&(l=d,_=!0)),l||(l=Wt(n,o,{}),_=!0),c=new Fe(e,i,d,l,s),n._edges.set(i,c);const L=a===o;return e?(d.undirectedDegree++,l.undirectedDegree++,L&&(d.undirectedLoops++,n._undirectedSelfLoopCount++)):(d.outDegree++,l.inDegree++,L&&(d.directedLoops++,n._directedSelfLoopCount++)),n.multi?c.attachMulti():c.attach(),e?n._undirectedSize++:n._directedSize++,b.key=i,n.emit("edgeAdded",b),[i,!0,w,_]}function Re(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 V extends kr.EventEmitter{constructor(r){if(super(),r=J({},xn,r),typeof r.multi!="boolean")throw new D(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${r.multi}".`);if(!wn.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"?Lr:r.type==="directed"?Dr:Gr;oe(this,"NodeDataClass",t);const e="geid_"+bn()+"_";let i=0;const a=()=>{let o;do o=e+i++;while(this._edges.has(o));return o};oe(this,"_attributes",{}),oe(this,"_nodes",new Map),oe(this,"_edges",new Map),oe(this,"_directedSize",0),oe(this,"_undirectedSize",0),oe(this,"_directedSelfLoopCount",0),oe(this,"_undirectedSelfLoopCount",0),oe(this,"_edgeKeyGenerator",a),oe(this,"_options",r),Ht.forEach(o=>oe(this,o,this[o])),le(this,"order",()=>this._nodes.size),le(this,"size",()=>this._edges.size),le(this,"directedSize",()=>this._directedSize),le(this,"undirectedSize",()=>this._undirectedSize),le(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),le(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),le(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),le(this,"multi",this._options.multi),le(this,"type",this._options.type),le(this,"allowSelfLoops",this._options.allowSelfLoops),le(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 O("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 R(`Graph.directedEdge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new R(`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 O("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 R(`Graph.undirectedEdge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new R(`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 O("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 R(`Graph.edge: could not find the "${r}" source node in the graph.`);if(!this._nodes.has(t))throw new R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`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 R(`Graph.isSelfLoop: could not find the "${r}" edge in the graph.`);return t.source===t.target}addNode(r,t){return _n(this,r,t).key}mergeNode(r,t){if(t&&!te(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&&(J(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 R(`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 Re(this,e),e=e.next;while(e)}for(const i in t.in){e=t.in[i];do Re(this,e),e=e.next;while(e)}}if(this.type!=="directed")for(const i in t.undirected){e=t.undirected[i];do Re(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=ue(this,e,i,this.type),!t)throw new R(`Graph.dropEdge: could not find the "${e}" -> "${i}" edge in the graph.`)}else if(r=""+r,t=this._edges.get(r),!t)throw new R(`Graph.dropEdge: could not find the "${r}" edge in the graph.`);return Re(this,t),this}dropDirectedEdge(r,t){if(arguments.length<2)throw new O("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 O("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=ue(this,r,t,"directed");if(!e)throw new R(`Graph.dropDirectedEdge: could not find a "${r}" -> "${t}" edge in the graph.`);return Re(this,e),this}dropUndirectedEdge(r,t){if(arguments.length<2)throw new O("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 O("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=ue(this,r,t,"undirected");if(!e)throw new R(`Graph.dropUndirectedEdge: could not find a "${r}" -> "${t}" edge in the graph.`);return Re(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(!te(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(!te(r))throw new D("Graph.mergeAttributes: provided attributes are not a plain object.");return J(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&&!Bt(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&&!Bt(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.");rt(!1,!1,!1,this,r)}forEachAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new D("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");rt(!1,!1,!0,this,r)}forEachAssymetricAdjacencyEntry(r){if(typeof r!="function")throw new D("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");rt(!1,!0,!1,this,r)}forEachAssymetricAdjacencyEntryWithOrphans(r){if(typeof r!="function")throw new D("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");rt(!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++]=pn(a,i)});const e=new Array(this._edges.size);return t=0,this._edges.forEach((i,a)=>{e[t++]=mn(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 V)return r.forEachNode((u,h)=>{t?this.mergeNode(u,h):this.addNode(u,h)}),r.forEachEdge((u,h,d,l,c,g,b)=>{t?b?this.mergeUndirectedEdgeWithKey(u,d,l,h):this.mergeDirectedEdgeWithKey(u,d,l,h):b?this.addUndirectedEdgeWithKey(u,d,l,h):this.addDirectedEdgeWithKey(u,d,l,h)}),this;if(!te(r))throw new D("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(r.attributes){if(!te(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],vn(o);const{key:u,attributes:h}=o;t?this.mergeNode(u,h):this.addNode(u,h)}}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],yn(s);const{source:h,target:d,attributes:l,undirected:c=u}=s;let g;"key"in s?(g=t?c?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:c?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,g.call(this,s.key,h,d,l)):(g=t?c?this.mergeUndirectedEdge:this.mergeDirectedEdge:c?this.addUndirectedEdge:this.addDirectedEdge,g.call(this,h,d,l))}}return this}nullCopy(r){const t=new V(J({},this._options,r));return t.replaceAttributes(J({},this.getAttributes())),t}emptyCopy(r){const t=this.nullCopy(r);return this._nodes.forEach((e,i)=>{const a=J({},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 O(`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 O("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 O("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,J({},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="",h=a.source.key,d=a.target.key,l;a.undirected&&h>d&&(l=h,h=d,d=l);const c=`(${h})${s}(${d})`;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)&&!Ht.has(a)&&typeof this[a]!="function"&&typeof a!="symbol"&&(i[a]=this[a]);return i.attributes=this._attributes,i.nodes=r,i.edges=t,oe(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(V.prototype[Symbol.for("nodejs.util.inspect.custom")]=V.prototype.inspect);En.forEach(n=>{["add","merge","update"].forEach(r=>{const t=n.name(r),e=r==="add"?zr:Sn;n.generateKey?V.prototype[t]=function(i,a,o){return e(this,t,!0,(n.type||this.type)==="undirected",null,i,a,o,r==="update")}:V.prototype[t]=function(i,a,o,s){return e(this,t,!1,(n.type||this.type)==="undirected",i,a,o,s,r==="update")}})});Gi(V);Bi(V);on(V);gn(V);class Or extends V{constructor(r){const t=J({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 $r extends V{constructor(r){const t=J({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 Ur extends V{constructor(r){const t=J({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 jr extends V{constructor(r){const t=J({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 Mr extends V{constructor(r){const t=J({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 Pe(n){n.from=function(r,t){const e=J({},r.options,t),i=new n(e);return i.import(r),i}}Pe(V);Pe(Or);Pe($r);Pe(Ur);Pe(jr);Pe(Mr);V.Graph=V;V.DirectedGraph=Or;V.UndirectedGraph=$r;V.MultiGraph=Ur;V.MultiDirectedGraph=jr;V.MultiUndirectedGraph=Mr;V.InvalidArgumentsGraphError=D;V.NotFoundGraphError=R;V.UsageGraphError=O;function Cn(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 Ve(n){var r=Cn(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 Vt(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,Ve(e.key),e)}}function ie(n,r,t){return r&&Vt(n.prototype,r),t&&Vt(n,t),Object.defineProperty(n,"prototype",{writable:!1}),n}function De(n){return De=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},De(n)}function Br(){try{var n=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Br=function(){return!!n})()}function Tn(n){if(n===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return n}function An(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 Tn(n)}function he(n,r,t){return r=De(r),An(n,Br()?Reflect.construct(r,t||[],De(n).constructor):r.apply(n,t))}function Rt(n,r){return Rt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Rt(n,r)}function de(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&&Rt(n,r)}function kn(n){if(Array.isArray(n))return n}function Rn(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,h=!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(d){h=!0,i=d}finally{try{if(!u&&t.return!=null&&(o=t.return(),Object(o)!==o))return}finally{if(h)throw i}}return s}}function Lt(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 Hr(n,r){if(n){if(typeof n=="string")return Lt(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)?Lt(n,r):void 0}}function Ln(){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 Ge(n,r){return kn(n)||Rn(n,r)||Hr(n,r)||Ln()}var vt={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"},Wr=new Int8Array(4),yt=new Int32Array(Wr.buffer,0,1),Dn=new Float32Array(Wr.buffer,0,1),Gn=/^\s*rgba?\s*\(/,Nn=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Fn(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(Gn.test(n)){var a=n.match(Nn);a&&(r=+a[1],t=+a[2],e=+a[3],a[4]&&(i=+a[4]))}return{r,g:t,b:e,a:i}}var Le={};for(var it in vt)Le[it]=qe(vt[it]),Le[vt[it]]=Le[it];function Vr(n,r,t,e,i){return yt[0]=e<<24|t<<16|r<<8|n,yt[0]=yt[0]&4278190079,Dn[0]}function qe(n){if(n=n.toLowerCase(),typeof Le[n]<"u")return Le[n];var r=Fn(n),t=r.r,e=r.g,i=r.b,a=r.a;a=a*255|0;var o=Vr(t,e,i,a);return Le[n]=o,o}var bt={};function qr(n){if(typeof bt[n]<"u")return bt[n];var r=(n&16711680)>>>16,t=(n&65280)>>>8,e=n&255,i=255,a=Vr(r,t,e,i);return bt[n]=a,a}function qt(n,r,t,e){return t+(r<<8)+(n<<16)}function Kt(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 h=Ge(u,4),d=h[0],l=h[1],c=h[2],g=h[3];return[d,l,c,g]}function x(n,r,t){return(r=Ve(r))in n?Object.defineProperty(n,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[r]=t,n}function Yt(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?Yt(Object(t),!0).forEach(function(e){x(n,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Yt(Object(t)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(t,e))})}return n}function Pn(n,r){for(;!{}.hasOwnProperty.call(n,r)&&(n=De(n))!==null;);return n}function Dt(){return Dt=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(n,r,t){var e=Pn(n,r);if(e){var i=Object.getOwnPropertyDescriptor(e,r);return i.get?i.get.call(arguments.length<3?n:t):i.value}},Dt.apply(null,arguments)}function Kr(n,r,t,e){var i=Dt(De(n.prototype),r,t);return typeof i=="function"?function(a){return i.apply(t,a)}:i}function In(n){return n.normalized?1:n.size}function wt(n){var r=0;return n.forEach(function(t){return r+=In(t)}),r}function Yr(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 zn(n,r){return Yr("VERTEX",n,r)}function On(n,r){return Yr("FRAGMENT",n,r)}function $n(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 Zt(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 Xt=`#define PICKING_MODE
|