forge-openclaw-plugin 0.2.101 → 0.2.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{activity-page-CpjuNSHw.js → activity-page-CgF7K2ww.js} +1 -1
- package/dist/assets/ai-surface-workspace-xtB5RFQu.js +1 -0
- package/dist/assets/atlas-panel-B3dPHCmZ.js +1 -0
- package/dist/assets/{board-BkDRaMp6.js → board-DqHzdCPQ.js} +1 -1
- package/dist/assets/{calendar-page-DNNt6lfz.js → calendar-page-C1Wfd2Fy.js} +1 -1
- package/dist/assets/{calendar-rules-DNJFNsxi.js → calendar-rules-CaZXtlxt.js} +1 -1
- package/dist/assets/calendar-week-toolbar-BZ_-X3Wb.js +1 -0
- package/dist/assets/{charts-P7EVhIog.js → charts-FcU0F3XV.js} +8 -8
- package/dist/assets/{companion-sync-lab-page-KxEDigM6.js → companion-sync-lab-page-NgeK-O-P.js} +1 -1
- package/dist/assets/daily-metrics-dashboard-BMyL0Qr4.js +1 -0
- package/dist/assets/{entity-note-count-link-DrhjJZ4i.js → entity-note-count-link-BrS1-O0o.js} +1 -1
- package/dist/assets/entity-notes-surface-CBylYDwy.js +1 -0
- package/dist/assets/{execution-board-D07gOocB.js → execution-board-CpO2ch6v.js} +1 -1
- package/dist/assets/faceted-token-search-D7xPWfOl.js +1 -0
- package/dist/assets/flagship-signal-deck-BEFKOhvx.js +1 -0
- package/dist/assets/{floating-action-menu-Fs_ZiUMo.js → floating-action-menu-zzC2r0Ob.js} +1 -1
- package/dist/assets/{forms-BFlTgZ3W.js → forms-CmLAyGqz.js} +1 -1
- package/dist/assets/{goal-detail-page-CqLiNz4f.js → goal-detail-page-JK_Nva8e.js} +1 -1
- package/dist/assets/goals-page-yeoJ06Vw.js +1 -0
- package/dist/assets/{graph-D6JLqDbD.js → graph-BTa79qum.js} +14 -14
- package/dist/assets/{habits-page-BJxagdzx.js → habits-page-Dx5EhkJi.js} +1 -1
- package/dist/assets/index-BHIKoiZ6.js +19 -0
- package/dist/assets/index-H8R-ABM3.css +1 -0
- package/dist/assets/insight-flow-dialog-BtIQXXsS.js +1 -0
- package/dist/assets/{insights-page-D6rOa7uk.js → insights-page-CujrosD_.js} +1 -1
- package/dist/assets/{kanban-page-XQ7Se6dH.js → kanban-page-Q9NuIz5w.js} +1 -1
- package/dist/assets/knowledge-graph-page-DaJmlvvM.js +1 -0
- package/dist/assets/{life-force-page-Dy0JTS2G.js → life-force-page-BGDkKfbJ.js} +1 -1
- package/dist/assets/{life-force-workspace-OfyB9HJM.js → life-force-workspace-CLVexVnb.js} +1 -1
- package/dist/assets/{maps-ClgJoCjz.js → maps-CF1RagUX.js} +1 -1
- package/dist/assets/metric-tile-4iMd_WnJ.js +1 -0
- package/dist/assets/{motion-BeD44FeG.js → motion-CfdU2F35.js} +1 -1
- package/dist/assets/movement-page-ClaoTNuX.js +1 -0
- package/dist/assets/note-markdown-CsGQhQXF.js +3 -0
- package/dist/assets/note-tags-input-DdZi93tj.js +1 -0
- package/dist/assets/notes-page-DYI8s3NN.js +1 -0
- package/dist/assets/{open-in-graph-button-IXe9SGth.js → open-in-graph-button-C0TGev7c.js} +1 -1
- package/dist/assets/orbit-map-DVXkfQdd.js +1 -0
- package/dist/assets/overview-page-BwMlFQKX.js +1 -0
- package/dist/assets/page-hero-oFHaAjtL.js +1 -0
- package/dist/assets/pill-cluster-7UZd_lHp.js +1 -0
- package/dist/assets/{preference-entity-handoff-button-5PzUn42S.js → preference-entity-handoff-button-DOKV9bZc.js} +1 -1
- package/dist/assets/preferences-page-BrKEkmfD.js +1 -0
- package/dist/assets/{project-collections-xPz2mlRr.js → project-collections-CZagCmeH.js} +1 -1
- package/dist/assets/{project-detail-page-BXK5-4xW.js → project-detail-page-DogvVNEn.js} +1 -1
- package/dist/assets/{project-management-hierarchy-page-DtRpMABw.js → project-management-hierarchy-page-Dr7hW9PW.js} +1 -1
- package/dist/assets/{project-management-section-nav-P3ixzPa-.js → project-management-section-nav-BLdAgTge.js} +1 -1
- package/dist/assets/{projects-page-C5ViRuf4.js → projects-page-UKrby_5-.js} +1 -1
- package/dist/assets/psyche-behaviors-page-BeVlXvbj.js +5 -0
- package/dist/assets/psyche-flashcards-page-CqAWCO4E.js +1 -0
- package/dist/assets/psyche-goal-map-page-IyNnbk_W.js +1 -0
- package/dist/assets/psyche-graph-IkUQRaDK.js +1 -0
- package/dist/assets/{psyche-metrics-page-CuR9oqEy.js → psyche-metrics-page-uai0a7Lx.js} +1 -1
- package/dist/assets/psyche-mode-guide-page-C7p-ABiF.js +1 -0
- package/dist/assets/psyche-modes-page-CLQ5V3w0.js +1 -0
- package/dist/assets/psyche-page-NQBHkkpU.js +1 -0
- package/dist/assets/psyche-patterns-page-BkRiNpI_.js +5 -0
- package/dist/assets/psyche-questionnaire-builder-page-Du-7HwPC.js +1 -0
- package/dist/assets/psyche-questionnaire-detail-page-C5-yf8MF.js +1 -0
- package/dist/assets/psyche-questionnaire-run-detail-page-CoSH5O6R.js +1 -0
- package/dist/assets/psyche-questionnaire-run-page-ChI7c1wy.js +1 -0
- package/dist/assets/psyche-questionnaires-page-xUcJJzbI.js +1 -0
- package/dist/assets/psyche-report-detail-page-BPrZCFZS.js +3 -0
- package/dist/assets/psyche-reports-page-D2EXJmm6.js +1 -0
- package/dist/assets/{psyche-schemas-HFmg37Wj.js → psyche-schemas-RcZYaokx.js} +1 -1
- package/dist/assets/psyche-schemas-beliefs-page-h0ooZ1lp.js +9 -0
- package/dist/assets/psyche-screen-time-page-_3-4LikV.js +1 -0
- package/dist/assets/psyche-self-observation-page-BdbCsgR5.js +1 -0
- package/dist/assets/psyche-values-page-DuUVki5e.js +5 -0
- package/dist/assets/report-chain-fields-BBMz0sGI.js +1 -0
- package/dist/assets/{rewards-page-DmC4R_Ps.js → rewards-page-PZFPa6rR.js} +1 -1
- package/dist/assets/{scheduling-rules-editor-D02s70hr.js → scheduling-rules-editor-B9KNKsQz.js} +1 -1
- package/dist/assets/schema-badge-D93RcG36.js +1 -0
- package/dist/assets/schema-visuals-CvC9a3i6.js +1 -0
- package/dist/assets/select-menu-Cdq7foRu.js +1 -0
- package/dist/assets/{settings-agents-page-C_v_hMJF.js → settings-agents-page-DPx2F6wf.js} +3 -3
- package/dist/assets/{settings-bin-page-DY5bg81n.js → settings-bin-page-COwP3gjo.js} +1 -1
- package/dist/assets/settings-calendar-page-C-ghE0YT.js +5 -0
- package/dist/assets/{settings-data-page-CHRQFU9H.js → settings-data-page-CBubzKBw.js} +1 -1
- package/dist/assets/{settings-logs-page-B04pUwEv.js → settings-logs-page-uOuXMeBm.js} +1 -1
- package/dist/assets/{settings-mobile-page-D9kTlYDS.js → settings-mobile-page-C5rfj8_r.js} +1 -1
- package/dist/assets/settings-models-page-DijmUWdU.js +1 -0
- package/dist/assets/{settings-page-DYDTFlnv.js → settings-page-B4u5TR5g.js} +1 -1
- package/dist/assets/{settings-rewards-page-cl4vqqO_.js → settings-rewards-page-COiTwkMH.js} +1 -1
- package/dist/assets/{settings-section-nav-DSOuht_F.js → settings-section-nav-Dc4IeVBt.js} +1 -1
- package/dist/assets/{settings-users-page-BU79JB_T.js → settings-users-page-DEGa5DNn.js} +1 -1
- package/dist/assets/settings-wiki-page-Cvsiz5_e.js +1 -0
- package/dist/assets/{sleep-page-D8NbdhyS.js → sleep-page-BnSOwkEU.js} +1 -1
- package/dist/assets/{sports-page-CV4Cnzwn.js → sports-page-l1RqXzA_.js} +1 -1
- package/dist/assets/{state-B-4sS1xO.js → state-VYvD1QVP.js} +1 -1
- package/dist/assets/{strategies-page-C4qvXnql.js → strategies-page-DEnPlpAs.js} +1 -1
- package/dist/assets/{strategy-detail-page-DJLo5rfy.js → strategy-detail-page-Ls8bxKeH.js} +1 -1
- package/dist/assets/strategy-dialog-DMyRKrWf.js +1 -0
- package/dist/assets/surface-Bfz_sLX6.js +1 -0
- package/dist/assets/{table-WfAPUppN.js → table-C0VTeqw0.js} +1 -1
- package/dist/assets/task-detail-page-CgrYgQLD.js +1 -0
- package/dist/assets/{timebox-planning-dialog-DB6FLqmI.js → timebox-planning-dialog-Ww0NGLLo.js} +1 -1
- package/dist/assets/today-page-CIuFHMi1.js +1 -0
- package/dist/assets/training-load-page-BIwc648i.js +1 -0
- package/dist/assets/{ui-C13Nbgas.js → ui-CsEkP2V8.js} +4 -4
- package/dist/assets/use-psyche-focus-target-qxT5Oy_z.js +1 -0
- package/dist/assets/{vendor-DHkYh85p.js → vendor-kIz9EZnX.js} +237 -222
- package/dist/assets/{vitals-page-qre17Nw8.js → vitals-page-Dz1Jt5H8.js} +1 -1
- package/dist/assets/{weekly-review-page-Cz4vkRcx.js → weekly-review-page-BFpBe1kI.js} +1 -1
- package/dist/assets/weight-loss-page-BgMoBpBt.js +5 -0
- package/dist/assets/{wiki-article-markdown-DdiR2TJE.js → wiki-article-markdown-gsPTXTg1.js} +1 -1
- package/dist/assets/{wiki-editor-page-DqwoqVFb.js → wiki-editor-page-BpAZHooY.js} +7 -7
- package/dist/assets/{wiki-ingest-history-page--evBLbOw.js → wiki-ingest-history-page-C-ig8O22.js} +1 -1
- package/dist/assets/{wiki-ingest-modal--ohzFnj2.js → wiki-ingest-modal-BK4eQgqs.js} +1 -1
- package/dist/assets/{wiki-page-B_VJFBPA.js → wiki-page-CMTZ60Zt.js} +1 -1
- package/dist/assets/workbench-flow-page-BIpWUcLJ.js +5 -0
- package/dist/assets/workbench-page-CtCjYSRe.js +1 -0
- package/dist/assets/workout-detail-page-DD9IGN6l.js +2 -0
- package/dist/index.html +9 -9
- package/dist/openclaw/local-runtime.js +41 -14
- package/dist/server/server/migrations/067_weight_loss_daily_active_overrides.sql +13 -0
- package/dist/server/server/src/app.js +103 -30
- package/dist/server/server/src/health-weight-loss.js +457 -55
- package/dist/server/server/src/health.js +12 -4
- package/dist/server/server/src/movement.js +84 -1
- package/dist/server/server/src/openapi.js +123 -18
- package/dist/server/server/src/repositories/model-settings.js +12 -9
- package/dist/server/server/src/repositories/settings.js +19 -5
- package/dist/server/src/components/ui/info-tooltip.js +6 -6
- package/dist/server/src/lib/api.js +14 -4
- package/dist/server/src/lib/theme-system.js +8 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +3 -3
- package/server/migrations/067_weight_loss_daily_active_overrides.sql +13 -0
- package/skills/forge-openclaw/SKILL.md +13 -0
- package/skills/forge-openclaw/entity_conversation_playbooks.md +7 -1
- package/dist/assets/ai-surface-workspace-DEAFZruS.js +0 -1
- package/dist/assets/atlas-panel-CdVNPotj.js +0 -1
- package/dist/assets/calendar-week-toolbar-BbPwYeN0.js +0 -1
- package/dist/assets/daily-metrics-dashboard-B3cqJgDt.js +0 -1
- package/dist/assets/entity-notes-surface-CkcRsKJQ.js +0 -1
- package/dist/assets/faceted-token-search-BxRRcM3q.js +0 -1
- package/dist/assets/flagship-signal-deck-cmy82b8_.js +0 -1
- package/dist/assets/goals-page-BTk7mg_T.js +0 -1
- package/dist/assets/index-CF4J4R9L.js +0 -19
- package/dist/assets/index-CZbuZQjw.css +0 -1
- package/dist/assets/insight-flow-dialog-8f3D0GuC.js +0 -1
- package/dist/assets/knowledge-graph-page-BtAg8iv3.js +0 -1
- package/dist/assets/metric-tile-DKpo-8xw.js +0 -1
- package/dist/assets/movement-page-Bg_T_Stx.js +0 -1
- package/dist/assets/note-markdown-N-uxD3Xt.js +0 -3
- package/dist/assets/note-tags-input-Cdu7wiw6.js +0 -1
- package/dist/assets/notes-page-CKXnF_KU.js +0 -1
- package/dist/assets/orbit-map-Dzi6KliQ.js +0 -1
- package/dist/assets/overview-page-1miYqaVS.js +0 -1
- package/dist/assets/page-hero-DRy5b2MU.js +0 -1
- package/dist/assets/pill-cluster-C9QczVJ2.js +0 -1
- package/dist/assets/preferences-page-DtNaF5Q3.js +0 -1
- package/dist/assets/psyche-behaviors-page-Dco46sC4.js +0 -5
- package/dist/assets/psyche-flashcards-page-ZcoEB8gV.js +0 -1
- package/dist/assets/psyche-goal-map-page-CLBAQOI0.js +0 -1
- package/dist/assets/psyche-graph-k4tX2tdp.js +0 -1
- package/dist/assets/psyche-mode-guide-page-hIVXcCnE.js +0 -1
- package/dist/assets/psyche-modes-page-0lYtBlhO.js +0 -1
- package/dist/assets/psyche-page-VZ9k9ISp.js +0 -1
- package/dist/assets/psyche-patterns-page-gx5nmdGq.js +0 -5
- package/dist/assets/psyche-questionnaire-builder-page-Bn0TOISd.js +0 -1
- package/dist/assets/psyche-questionnaire-detail-page-CmVzSd_s.js +0 -1
- package/dist/assets/psyche-questionnaire-run-detail-page-BsMbmXCG.js +0 -1
- package/dist/assets/psyche-questionnaire-run-page-CgkRL2vi.js +0 -1
- package/dist/assets/psyche-questionnaires-page-D7V8uLXM.js +0 -1
- package/dist/assets/psyche-report-detail-page-OlFq57eL.js +0 -3
- package/dist/assets/psyche-reports-page-dVUZjna1.js +0 -1
- package/dist/assets/psyche-schemas-beliefs-page-BCgc8FUd.js +0 -9
- package/dist/assets/psyche-screen-time-page-B_6BT_WN.js +0 -1
- package/dist/assets/psyche-self-observation-page-CEG5mluK.js +0 -1
- package/dist/assets/psyche-values-page-DRbRfEd6.js +0 -5
- package/dist/assets/report-chain-fields-CALCV3V5.js +0 -1
- package/dist/assets/schema-badge-BZO-qNhO.js +0 -1
- package/dist/assets/schema-visuals-D6nxjbYC.js +0 -1
- package/dist/assets/select-menu-fYyreSdQ.js +0 -1
- package/dist/assets/settings-calendar-page-D1CzE6cg.js +0 -5
- package/dist/assets/settings-models-page-D26270R2.js +0 -1
- package/dist/assets/settings-wiki-page-DwAUlyA3.js +0 -1
- package/dist/assets/strategy-dialog-D3AuUlVz.js +0 -1
- package/dist/assets/task-detail-page-z-9u9rF0.js +0 -1
- package/dist/assets/today-page-BKlu6gx5.js +0 -1
- package/dist/assets/training-load-page-CyJQqo_3.js +0 -1
- package/dist/assets/use-psyche-focus-target-C1C_XjYG.js +0 -1
- package/dist/assets/weight-loss-page-BQrnOI0y.js +0 -1
- package/dist/assets/workbench-flow-page-Du62mtJU.js +0 -5
- package/dist/assets/workbench-page-4MKr3iRm.js +0 -1
- package/dist/assets/workout-detail-page-DfUbYYw1.js +0 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import{D as yr,E as Wt,F as la,G as sn,H as an,J as ha,K as vr,L as wr,r as D,j as T,N as he,O as br,P as fa}from"./vendor-DHkYh85p.js";import{u as ga,c as pa,s as ue}from"./state-B-4sS1xO.js";const Ne={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:i}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},wt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],xr=["Enter"," ","Escape"],Er={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var qe;(function(e){e.Strict="strict",e.Loose="loose"})(qe||(qe={}));var Ue;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ue||(Ue={}));var bt;(function(e){e.Partial="partial",e.Full="full"})(bt||(bt={}));const Sr={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Fe;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Fe||(Fe={}));var Ot;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ot||(Ot={}));var Y;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Y||(Y={}));const ci={[Y.Left]:Y.Right,[Y.Right]:Y.Left,[Y.Top]:Y.Bottom,[Y.Bottom]:Y.Top};function Cr(e){return e===null?null:e?"valid":"invalid"}const _r=e=>"id"in e&&"source"in e&&"target"in e,ma=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Gn=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Ct=(e,t=[0,0])=>{const{width:n,height:i}=De(e),r=e.origin??t,o=n*r[0],s=i*r[1];return{x:e.position.x-o,y:e.position.y-s}},ya=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((i,r)=>{const o=typeof r=="string";let s=!t.nodeLookup&&!o?r:void 0;t.nodeLookup&&(s=o?t.nodeLookup.get(r):Gn(r)?r:t.nodeLookup.get(r.id));const a=s?Ut(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Yt(i,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Xt(n)},_t=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=Yt(n,Ut(r)),i=!0)}),i?Xt(n):{x:0,y:0,width:0,height:0}},Fn=(e,t,[n,i,r]=[0,0,1],o=!1,s=!1)=>{const a={...Tt(t,[n,i,r]),width:t.width/r,height:t.height/r},c=[];for(const u of e.values()){const{measured:l,selectable:d=!0,hidden:h=!1}=u;if(s&&!d||h)continue;const f=l.width??u.width??u.initialWidth??null,g=l.height??u.height??u.initialHeight??null,y=xt(a,Je(u)),m=(f??0)*(g??0),v=o&&y>0;(!u.internals.handleBounds||v||y>=m||u.dragging)&&c.push(u)}return c},va=(e,t)=>{const n=new Set;return e.forEach(i=>{n.add(i.id)}),t.filter(i=>n.has(i.source)||n.has(i.target))};function wa(e,t){const n=new Map,i=t!=null&&t.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!r.hidden)&&(!i||i.has(r.id))&&n.set(r.id,r)}),n}async function ba({nodes:e,width:t,height:n,panZoom:i,minZoom:r,maxZoom:o},s){if(e.size===0)return Promise.resolve(!0);const a=wa(e,s),c=_t(a),u=$n(c,t,n,(s==null?void 0:s.minZoom)??r,(s==null?void 0:s.maxZoom)??o,(s==null?void 0:s.padding)??.1);return await i.setViewport(u,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),Promise.resolve(!0)}function Nr({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:i=[0,0],nodeExtent:r,onError:o}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:u}=a?a.internals.positionAbsolute:{x:0,y:0},l=s.origin??i;let d=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)o==null||o("005",Ne.error005());else{const f=a.measured.width,g=a.measured.height;f&&g&&(d=[[c,u],[c+f,u+g]])}else a&&et(s.extent)&&(d=[[s.extent[0][0]+c,s.extent[0][1]+u],[s.extent[1][0]+c,s.extent[1][1]+u]]);const h=et(d)?He(t,d,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(o==null||o("015",Ne.error015())),{position:{x:h.x-c+(s.measured.width??0)*l[0],y:h.y-u+(s.measured.height??0)*l[1]},positionAbsolute:h}}async function xa({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:i,onBeforeDelete:r}){const o=new Set(e.map(h=>h.id)),s=[];for(const h of n){if(h.deletable===!1)continue;const f=o.has(h.id),g=!f&&h.parentId&&s.find(y=>y.id===h.parentId);(f||g)&&s.push(h)}const a=new Set(t.map(h=>h.id)),c=i.filter(h=>h.deletable!==!1),l=va(s,c);for(const h of c)a.has(h.id)&&!l.find(g=>g.id===h.id)&&l.push(h);if(!r)return{edges:l,nodes:s};const d=await r({nodes:s,edges:l});return typeof d=="boolean"?d?{edges:l,nodes:s}:{edges:[],nodes:[]}:d}const Qe=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),He=(e={x:0,y:0},t,n)=>({x:Qe(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Qe(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Tr(e,t,n){const{width:i,height:r}=De(n),{x:o,y:s}=n.internals.positionAbsolute;return He(e,[[o,s],[o+i,s+r]],t)}const ui=(e,t,n)=>e<t?Qe(Math.abs(e-t),1,t)/t:e>n?-Qe(Math.abs(e-n),1,t)/t:0,Ar=(e,t,n=15,i=40)=>{const r=ui(e.x,i,t.width-i)*n,o=ui(e.y,i,t.height-i)*n;return[r,o]},Yt=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Cn=({x:e,y:t,width:n,height:i})=>({x:e,y:t,x2:e+n,y2:t+i}),Xt=({x:e,y:t,x2:n,y2:i})=>({x:e,y:t,width:n-e,height:i-t}),Je=(e,t=[0,0])=>{var r,o;const{x:n,y:i}=Gn(e)?e.internals.positionAbsolute:Ct(e,t);return{x:n,y:i,width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},Ut=(e,t=[0,0])=>{var r,o;const{x:n,y:i}=Gn(e)?e.internals.positionAbsolute:Ct(e,t);return{x:n,y:i,x2:n+(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0),y2:i+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},kr=(e,t)=>Xt(Yt(Cn(e),Cn(t))),xt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),i=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*i)},di=e=>Ce(e.width)&&Ce(e.height)&&Ce(e.x)&&Ce(e.y),Ce=e=>!isNaN(e)&&isFinite(e),Ea=(e,t)=>{},Nt=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Tt=({x:e,y:t},[n,i,r],o=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-i)/r};return o?Nt(a,s):a},Ht=({x:e,y:t},[n,i,r])=>({x:e*r+n,y:t*r+i});function We(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Sa(e,t,n){if(typeof e=="string"||typeof e=="number"){const i=We(e,n),r=We(e,t);return{top:i,right:r,bottom:i,left:r,x:r*2,y:i*2}}if(typeof e=="object"){const i=We(e.top??e.y??0,n),r=We(e.bottom??e.y??0,n),o=We(e.left??e.x??0,t),s=We(e.right??e.x??0,t);return{top:i,right:s,bottom:r,left:o,x:o+s,y:i+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Ca(e,t,n,i,r,o){const{x:s,y:a}=Ht(e,[t,n,i]),{x:c,y:u}=Ht({x:e.x+e.width,y:e.y+e.height},[t,n,i]),l=r-c,d=o-u;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(l),bottom:Math.floor(d)}}const $n=(e,t,n,i,r,o)=>{const s=Sa(o,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,u=Math.min(a,c),l=Qe(u,i,r),d=e.x+e.width/2,h=e.y+e.height/2,f=t/2-d*l,g=n/2-h*l,y=Ca(e,f,g,l,t,n),m={left:Math.min(y.left-s.left,0),top:Math.min(y.top-s.top,0),right:Math.min(y.right-s.right,0),bottom:Math.min(y.bottom-s.bottom,0)};return{x:f-m.left+m.right,y:g-m.top+m.bottom,zoom:l}},Et=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function et(e){return e!=null&&e!=="parent"}function De(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Rr(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function Dr(e,t={width:0,height:0},n,i,r){const o={...e},s=i.get(n);if(s){const a=s.origin||r;o.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],o.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return o}function li(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function _a(){let e,t;return{promise:new Promise((i,r)=>{e=i,t=r}),resolve:e,reject:t}}function Na(e){return{...Er,...e||{}}}function yt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:i,containerBounds:r}){const{x:o,y:s}=_e(e),a=Tt({x:o-((r==null?void 0:r.left)??0),y:s-((r==null?void 0:r.top)??0)},i),{x:c,y:u}=n?Nt(a,t):a;return{xSnapped:c,ySnapped:u,...a}}const zn=e=>({width:e.offsetWidth,height:e.offsetHeight}),Lr=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Ta=["INPUT","SELECT","TEXTAREA"];function Mr(e){var i,r;const t=((r=(i=e.composedPath)==null?void 0:i.call(e))==null?void 0:r[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:Ta.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Pr=e=>"clientX"in e,_e=(e,t)=>{var o,s;const n=Pr(e),i=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,r=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:i-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},hi=(e,t,n,i,r)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/i,y:(a.top-n.top)/i,...zn(s)}})};function Ir({sourceX:e,sourceY:t,targetX:n,targetY:i,sourceControlX:r,sourceControlY:o,targetControlX:s,targetControlY:a}){const c=e*.125+r*.375+s*.375+n*.125,u=t*.125+o*.375+a*.375+i*.125,l=Math.abs(c-e),d=Math.abs(u-t);return[c,u,l,d]}function Dt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function fi({pos:e,x1:t,y1:n,x2:i,y2:r,c:o}){switch(e){case Y.Left:return[t-Dt(t-i,o),n];case Y.Right:return[t+Dt(i-t,o),n];case Y.Top:return[t,n-Dt(n-r,o)];case Y.Bottom:return[t,n+Dt(r-n,o)]}}function Gr({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:i,targetY:r,targetPosition:o=Y.Top,curvature:s=.25}){const[a,c]=fi({pos:n,x1:e,y1:t,x2:i,y2:r,c:s}),[u,l]=fi({pos:o,x1:i,y1:r,x2:e,y2:t,c:s}),[d,h,f,g]=Ir({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:u,targetControlY:l});return[`M${e},${t} C${a},${c} ${u},${l} ${i},${r}`,d,h,f,g]}function Fr({sourceX:e,sourceY:t,targetX:n,targetY:i}){const r=Math.abs(n-e)/2,o=n<e?n+r:n-r,s=Math.abs(i-t)/2,a=i<t?i+s:i-s;return[o,a,r,s]}function Aa({sourceNode:e,targetNode:t,selected:n=!1,zIndex:i=0,elevateOnSelect:r=!1,zIndexMode:o="basic"}){if(o==="manual")return i;const s=r&&n?i+1e3:i,a=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return s+a}function ka({sourceNode:e,targetNode:t,width:n,height:i,transform:r}){const o=Yt(Ut(e),Ut(t));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const s={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:i/r[2]};return xt(s,Xt(o))>0}const Ra=({source:e,sourceHandle:t,target:n,targetHandle:i})=>`xy-edge__${e}${t||""}-${n}${i||""}`,Da=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),La=(e,t,n={})=>{if(!e.source||!e.target)return t;const i=n.getEdgeId||Ra;let r;return _r(e)?r={...e}:r={...e,id:i(e)},Da(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function $r({sourceX:e,sourceY:t,targetX:n,targetY:i}){const[r,o,s,a]=Fr({sourceX:e,sourceY:t,targetX:n,targetY:i});return[`M ${e},${t}L ${n},${i}`,r,o,s,a]}const gi={[Y.Left]:{x:-1,y:0},[Y.Right]:{x:1,y:0},[Y.Top]:{x:0,y:-1},[Y.Bottom]:{x:0,y:1}},Ma=({source:e,sourcePosition:t=Y.Bottom,target:n})=>t===Y.Left||t===Y.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},pi=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Pa({source:e,sourcePosition:t=Y.Bottom,target:n,targetPosition:i=Y.Top,center:r,offset:o,stepPosition:s}){const a=gi[t],c=gi[i],u={x:e.x+a.x*o,y:e.y+a.y*o},l={x:n.x+c.x*o,y:n.y+c.y*o},d=Ma({source:u,sourcePosition:t,target:l}),h=d.x!==0?"x":"y",f=d[h];let g=[],y,m;const v={x:0,y:0},w={x:0,y:0},[,,p,b]=Fr({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[h]*c[h]===-1){h==="x"?(y=r.x??u.x+(l.x-u.x)*s,m=r.y??(u.y+l.y)/2):(y=r.x??(u.x+l.x)/2,m=r.y??u.y+(l.y-u.y)*s);const k=[{x:y,y:u.y},{x:y,y:l.y}],N=[{x:u.x,y:m},{x:l.x,y:m}];a[h]===f?g=h==="x"?k:N:g=h==="x"?N:k}else{const k=[{x:u.x,y:l.y}],N=[{x:l.x,y:u.y}];if(h==="x"?g=a.x===f?N:k:g=a.y===f?k:N,t===i){const M=Math.abs(e[h]-n[h]);if(M<=o){const P=Math.min(o-1,o-M);a[h]===f?v[h]=(u[h]>e[h]?-1:1)*P:w[h]=(l[h]>n[h]?-1:1)*P}}if(t!==i){const M=h==="x"?"y":"x",P=a[h]===c[M],B=u[M]>l[M],$=u[M]<l[M];(a[h]===1&&(!P&&B||P&&$)||a[h]!==1&&(!P&&$||P&&B))&&(g=h==="x"?k:N)}const G={x:u.x+v.x,y:u.y+v.y},E={x:l.x+w.x,y:l.y+w.y},_=Math.max(Math.abs(G.x-g[0].x),Math.abs(E.x-g[0].x)),I=Math.max(Math.abs(G.y-g[0].y),Math.abs(E.y-g[0].y));_>=I?(y=(G.x+E.x)/2,m=g[0].y):(y=g[0].x,m=(G.y+E.y)/2)}const S={x:u.x+v.x,y:u.y+v.y},x={x:l.x+w.x,y:l.y+w.y};return[[e,...S.x!==g[0].x||S.y!==g[0].y?[S]:[],...g,...x.x!==g[g.length-1].x||x.y!==g[g.length-1].y?[x]:[],n],y,m,p,b]}function Ia(e,t,n,i){const r=Math.min(pi(e,t)/2,pi(t,n)/2,i),{x:o,y:s}=t;if(e.x===o&&o===n.x||e.y===s&&s===n.y)return`L${o} ${s}`;if(e.y===s){const u=e.x<n.x?-1:1,l=e.y<n.y?1:-1;return`L ${o+r*u},${s}Q ${o},${s} ${o},${s+r*l}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${o},${s+r*c}Q ${o},${s} ${o+r*a},${s}`}function _n({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:i,targetY:r,targetPosition:o=Y.Top,borderRadius:s=5,centerX:a,centerY:c,offset:u=20,stepPosition:l=.5}){const[d,h,f,g,y]=Pa({source:{x:e,y:t},sourcePosition:n,target:{x:i,y:r},targetPosition:o,center:{x:a,y:c},offset:u,stepPosition:l});let m=`M${d[0].x} ${d[0].y}`;for(let v=1;v<d.length-1;v++)m+=Ia(d[v-1],d[v],d[v+1],s);return m+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[m,h,f,g,y]}function mi(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Ga(e){var d;const{sourceNode:t,targetNode:n}=e;if(!mi(t)||!mi(n))return null;const i=t.internals.handleBounds||yi(t.handles),r=n.internals.handleBounds||yi(n.handles),o=vi((i==null?void 0:i.source)??[],e.sourceHandle),s=vi(e.connectionMode===qe.Strict?(r==null?void 0:r.target)??[]:((r==null?void 0:r.target)??[]).concat((r==null?void 0:r.source)??[]),e.targetHandle);if(!o||!s)return(d=e.onError)==null||d.call(e,"008",Ne.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(o==null?void 0:o.position)||Y.Bottom,c=(s==null?void 0:s.position)||Y.Top,u=je(t,o,a),l=je(n,s,c);return{sourceX:u.x,sourceY:u.y,targetX:l.x,targetY:l.y,sourcePosition:a,targetPosition:c}}function yi(e){if(!e)return null;const t=[],n=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?t.push(i):i.type==="target"&&n.push(i);return{source:t,target:n}}function je(e,t,n=Y.Left,i=!1){const r=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,o=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??De(e);if(i)return{x:r+s/2,y:o+a/2};switch((t==null?void 0:t.position)??n){case Y.Top:return{x:r+s/2,y:o};case Y.Right:return{x:r+s,y:o+a/2};case Y.Bottom:return{x:r+s/2,y:o+a};case Y.Left:return{x:r,y:o+a/2}}}function vi(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Nn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function Fa(e,{id:t,defaultColor:n,defaultMarkerStart:i,defaultMarkerEnd:r}){const o=new Set;return e.reduce((s,a)=>([a.markerStart||i,a.markerEnd||r].forEach(c=>{if(c&&typeof c=="object"){const u=Nn(c,t);o.has(u)||(s.push({id:u,color:c.color||n,...c}),o.add(u))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const zr=1e3,$a=10,Bn={nodeOrigin:[0,0],nodeExtent:wt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},za={...Bn,checkEquality:!0};function On(e,t){const n={...e};for(const i in t)t[i]!==void 0&&(n[i]=t[i]);return n}function Ba(e,t,n){const i=On(Bn,n);for(const r of e.values())if(r.parentId)Hn(r,e,t,i);else{const o=Ct(r,i.nodeOrigin),s=et(r.extent)?r.extent:i.nodeExtent,a=He(o,s,De(r));r.internals.positionAbsolute=a}}function Oa(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],i=[];for(const r of e.handles){const o={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(o):r.type==="target"&&i.push(o)}return{source:n,target:i}}function Un(e){return e==="manual"}function Tn(e,t,n,i={}){var l,d;const r=On(za,i),o={i:0},s=new Map(t),a=r!=null&&r.elevateNodesOnSelect&&!Un(r.zIndexMode)?zr:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const h of e){let f=s.get(h.id);if(r.checkEquality&&h===(f==null?void 0:f.internals.userNode))t.set(h.id,f);else{const g=Ct(h,r.nodeOrigin),y=et(h.extent)?h.extent:r.nodeExtent,m=He(g,y,De(h));f={...r.defaults,...h,measured:{width:(l=h.measured)==null?void 0:l.width,height:(d=h.measured)==null?void 0:d.height},internals:{positionAbsolute:m,handleBounds:Oa(h,f),z:Br(h,a,r.zIndexMode),userNode:h}},t.set(h.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(c=!1),h.parentId&&Hn(f,t,n,i,o),u||(u=h.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function Ua(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Hn(e,t,n,i,r){const{elevateNodesOnSelect:o,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=On(Bn,i),u=e.parentId,l=t.get(u);if(!l){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Ua(e,n),r&&!l.parentId&&l.internals.rootParentIndex===void 0&&c==="auto"&&(l.internals.rootParentIndex=++r.i,l.internals.z=l.internals.z+r.i*$a),r&&l.internals.rootParentIndex!==void 0&&(r.i=l.internals.rootParentIndex);const d=o&&!Un(c)?zr:0,{x:h,y:f,z:g}=Ha(e,l,s,a,d,c),{positionAbsolute:y}=e.internals,m=h!==y.x||f!==y.y;(m||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:m?{x:h,y:f}:y,z:g}})}function Br(e,t,n){const i=Ce(e.zIndex)?e.zIndex:0;return Un(n)?i:i+(e.selected?t:0)}function Ha(e,t,n,i,r,o){const{x:s,y:a}=t.internals.positionAbsolute,c=De(e),u=Ct(e,n),l=et(e.extent)?He(u,e.extent,c):u;let d=He({x:s+l.x,y:a+l.y},i,c);e.extent==="parent"&&(d=Tr(d,c,t));const h=Br(e,r,o),f=t.internals.z??0;return{x:d.x,y:d.y,z:f>=h?f+1:h}}function jn(e,t,n,i=[0,0]){var s;const r=[],o=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const u=((s=o.get(a.parentId))==null?void 0:s.expandedRect)??Je(c),l=kr(u,a.rect);o.set(a.parentId,{expandedRect:l,parent:c})}return o.size>0&&o.forEach(({expandedRect:a,parent:c},u)=>{var p;const l=c.internals.positionAbsolute,d=De(c),h=c.origin??i,f=a.x<l.x?Math.round(Math.abs(l.x-a.x)):0,g=a.y<l.y?Math.round(Math.abs(l.y-a.y)):0,y=Math.max(d.width,Math.round(a.width)),m=Math.max(d.height,Math.round(a.height)),v=(y-d.width)*h[0],w=(m-d.height)*h[1];(f>0||g>0||v||w)&&(r.push({id:u,type:"position",position:{x:c.position.x-f+v,y:c.position.y-g+w}}),(p=n.get(u))==null||p.forEach(b=>{e.some(S=>S.id===b.id)||r.push({id:b.id,type:"position",position:{x:b.position.x+f,y:b.position.y+g}})})),(d.width<a.width||d.height<a.height||f||g)&&r.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:y+(f?h[0]*f-v:0),height:m+(g?h[1]*g-w:0)}})}),r}function ja(e,t,n,i,r,o,s){const a=i==null?void 0:i.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const u=[],l=window.getComputedStyle(a),{m22:d}=new window.DOMMatrixReadOnly(l.transform),h=[];for(const f of e.values()){const g=t.get(f.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const y=zn(f.nodeElement),m=g.measured.width!==y.width||g.measured.height!==y.height;if(!!(y.width&&y.height&&(m||!g.internals.handleBounds||f.force))){const w=f.nodeElement.getBoundingClientRect(),p=et(g.extent)?g.extent:o;let{positionAbsolute:b}=g.internals;g.parentId&&g.extent==="parent"?b=Tr(b,y,t.get(g.parentId)):p&&(b=He(b,p,y));const S={...g,measured:y,internals:{...g.internals,positionAbsolute:b,handleBounds:{source:hi("source",f.nodeElement,w,d,g.id),target:hi("target",f.nodeElement,w,d,g.id)}}};t.set(g.id,S),g.parentId&&Hn(S,t,n,{nodeOrigin:r,zIndexMode:s}),c=!0,m&&(u.push({id:g.id,type:"dimensions",dimensions:y}),g.expandParent&&g.parentId&&h.push({id:g.id,parentId:g.parentId,rect:Je(S,r)}))}}if(h.length>0){const f=jn(h,t,n,r);u.push(...f)}return{changes:u,updatedInternals:c}}async function Va({delta:e,panZoom:t,transform:n,translateExtent:i,width:r,height:o}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,o]],i),a=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(a)}function wi(e,t,n,i,r,o){let s=r;const a=i.get(s)||new Map;i.set(s,a.set(n,t)),s=`${r}-${e}`;const c=i.get(s)||new Map;if(i.set(s,c.set(n,t)),o){s=`${r}-${e}-${o}`;const u=i.get(s)||new Map;i.set(s,u.set(n,t))}}function Or(e,t,n){e.clear(),t.clear();for(const i of n){const{source:r,target:o,sourceHandle:s=null,targetHandle:a=null}=i,c={edgeId:i.id,source:r,target:o,sourceHandle:s,targetHandle:a},u=`${r}-${s}--${o}-${a}`,l=`${o}-${a}--${r}-${s}`;wi("source",c,l,e,r,s),wi("target",c,u,e,o,a),t.set(i.id,i)}}function Ur(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ur(n,t):!1}function bi(e,t,n){var r;let i=e;do{if((r=i==null?void 0:i.matches)!=null&&r.call(i,t))return!0;if(i===n)return!1;i=i==null?void 0:i.parentElement}while(i);return!1}function Wa(e,t,n,i){const r=new Map;for(const[o,s]of e)if((s.selected||s.id===i)&&(!s.parentId||!Ur(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(o);a&&r.set(o,{id:o,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function cn({nodeId:e,dragItems:t,nodeLookup:n,dragging:i=!0}){var s,a,c;const r=[];for(const[u,l]of t){const d=(s=n.get(u))==null?void 0:s.internals.userNode;d&&r.push({...d,position:l.position,dragging:i})}if(!e)return[r[0],r];const o=(a=n.get(e))==null?void 0:a.internals.userNode;return[o?{...o,position:((c=t.get(e))==null?void 0:c.position)||o.position,dragging:i}:r[0],r]}function Ya({dragItems:e,snapGrid:t,x:n,y:i}){const r=e.values().next().value;if(!r)return null;const o={x:n-r.distance.x,y:i-r.distance.y},s=Nt(o,t);return{x:s.x-o.x,y:s.y-o.y}}function Xa({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:i,onDragStop:r}){let o={x:null,y:null},s=0,a=new Map,c=!1,u={x:0,y:0},l=null,d=!1,h=null,f=!1,g=!1,y=null;function m({noDragClassName:w,handleSelector:p,domNode:b,isSelectable:S,nodeId:x,nodeClickDistance:C=0}){h=Wt(b);function k({x:_,y:I}){const{nodeLookup:M,nodeExtent:P,snapGrid:B,snapToGrid:$,nodeOrigin:R,onNodeDrag:A,onSelectionDrag:U,onError:z,updateNodePositions:F}=t();o={x:_,y:I};let V=!1;const q=a.size>1,J=q&&P?Cn(_t(a)):null,te=q&&$?Ya({dragItems:a,snapGrid:B,x:_,y:I}):null;for(const[ne,j]of a){if(!M.has(ne))continue;let Q={x:_-j.distance.x,y:I-j.distance.y};$&&(Q=te?{x:Math.round(Q.x+te.x),y:Math.round(Q.y+te.y)}:Nt(Q,B));let ie=null;if(q&&P&&!j.extent&&J){const{positionAbsolute:Z}=j.internals,se=Z.x-J.x+P[0][0],ce=Z.x+j.measured.width-J.x2+P[1][0],oe=Z.y-J.y+P[0][1],ge=Z.y+j.measured.height-J.y2+P[1][1];ie=[[se,oe],[ce,ge]]}const{position:ee,positionAbsolute:K}=Nr({nodeId:ne,nextPosition:Q,nodeLookup:M,nodeExtent:ie||P,nodeOrigin:R,onError:z});V=V||j.position.x!==ee.x||j.position.y!==ee.y,j.position=ee,j.internals.positionAbsolute=K}if(g=g||V,!!V&&(F(a,!0),y&&(i||A||!x&&U))){const[ne,j]=cn({nodeId:x,dragItems:a,nodeLookup:M});i==null||i(y,a,ne,j),A==null||A(y,ne,j),x||U==null||U(y,j)}}async function N(){if(!l)return;const{transform:_,panBy:I,autoPanSpeed:M,autoPanOnNodeDrag:P}=t();if(!P){c=!1,cancelAnimationFrame(s);return}const[B,$]=Ar(u,l,M);(B!==0||$!==0)&&(o.x=(o.x??0)-B/_[2],o.y=(o.y??0)-$/_[2],await I({x:B,y:$})&&k(o)),s=requestAnimationFrame(N)}function G(_){var q;const{nodeLookup:I,multiSelectionActive:M,nodesDraggable:P,transform:B,snapGrid:$,snapToGrid:R,selectNodesOnDrag:A,onNodeDragStart:U,onSelectionDragStart:z,unselectNodesAndEdges:F}=t();d=!0,(!A||!S)&&!M&&x&&((q=I.get(x))!=null&&q.selected||F()),S&&A&&x&&(e==null||e(x));const V=yt(_.sourceEvent,{transform:B,snapGrid:$,snapToGrid:R,containerBounds:l});if(o=V,a=Wa(I,P,V,x),a.size>0&&(n||U||!x&&z)){const[J,te]=cn({nodeId:x,dragItems:a,nodeLookup:I});n==null||n(_.sourceEvent,a,J,te),U==null||U(_.sourceEvent,J,te),x||z==null||z(_.sourceEvent,te)}}const E=vr().clickDistance(C).on("start",_=>{const{domNode:I,nodeDragThreshold:M,transform:P,snapGrid:B,snapToGrid:$}=t();l=(I==null?void 0:I.getBoundingClientRect())||null,f=!1,g=!1,y=_.sourceEvent,M===0&&G(_),o=yt(_.sourceEvent,{transform:P,snapGrid:B,snapToGrid:$,containerBounds:l}),u=_e(_.sourceEvent,l)}).on("drag",_=>{const{autoPanOnNodeDrag:I,transform:M,snapGrid:P,snapToGrid:B,nodeDragThreshold:$,nodeLookup:R}=t(),A=yt(_.sourceEvent,{transform:M,snapGrid:P,snapToGrid:B,containerBounds:l});if(y=_.sourceEvent,(_.sourceEvent.type==="touchmove"&&_.sourceEvent.touches.length>1||x&&!R.has(x))&&(f=!0),!f){if(!c&&I&&d&&(c=!0,N()),!d){const U=_e(_.sourceEvent,l),z=U.x-u.x,F=U.y-u.y;Math.sqrt(z*z+F*F)>$&&G(_)}(o.x!==A.xSnapped||o.y!==A.ySnapped)&&a&&d&&(u=_e(_.sourceEvent,l),k(A))}}).on("end",_=>{if(!(!d||f)&&(c=!1,d=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:I,updateNodePositions:M,onNodeDragStop:P,onSelectionDragStop:B}=t();if(g&&(M(a,!1),g=!1),r||P||!x&&B){const[$,R]=cn({nodeId:x,dragItems:a,nodeLookup:I,dragging:!1});r==null||r(_.sourceEvent,a,$,R),P==null||P(_.sourceEvent,$,R),x||B==null||B(_.sourceEvent,R)}}}).filter(_=>{const I=_.target;return!_.button&&(!w||!bi(I,`.${w}`,b))&&(!p||bi(I,p,b))});h.call(E)}function v(){h==null||h.on(".drag",null)}return{update:m,destroy:v}}function Za(e,t,n){const i=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const o of t.values())xt(r,Je(o))>0&&i.push(o);return i}const Ka=250;function qa(e,t,n,i){var a,c;let r=[],o=1/0;const s=Za(e,n,t+Ka);for(const u of s){const l=[...((a=u.internals.handleBounds)==null?void 0:a.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const d of l){if(i.nodeId===d.nodeId&&i.type===d.type&&i.id===d.id)continue;const{x:h,y:f}=je(u,d,d.position,!0),g=Math.sqrt(Math.pow(h-e.x,2)+Math.pow(f-e.y,2));g>t||(g<o?(r=[{...d,x:h,y:f}],o=g):g===o&&r.push({...d,x:h,y:f}))}}if(!r.length)return null;if(r.length>1){const u=i.type==="source"?"target":"source";return r.find(l=>l.type===u)??r[0]}return r[0]}function Hr(e,t,n,i,r,o=!1){var u,l,d;const s=i.get(e);if(!s)return null;const a=r==="strict"?(u=s.internals.handleBounds)==null?void 0:u[t]:[...((l=s.internals.handleBounds)==null?void 0:l.source)??[],...((d=s.internals.handleBounds)==null?void 0:d.target)??[]],c=(n?a==null?void 0:a.find(h=>h.id===n):a==null?void 0:a[0])??null;return c&&o?{...c,...je(s,c,c.position,!0)}:c}function jr(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Qa(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Vr=()=>!0;function Ja(e,{connectionMode:t,connectionRadius:n,handleId:i,nodeId:r,edgeUpdaterType:o,isTarget:s,domNode:a,nodeLookup:c,lib:u,autoPanOnConnect:l,flowId:d,panBy:h,cancelConnection:f,onConnectStart:g,onConnect:y,onConnectEnd:m,isValidConnection:v=Vr,onReconnectEnd:w,updateConnection:p,getTransform:b,getFromHandle:S,autoPanSpeed:x,dragThreshold:C=1,handleDomNode:k}){const N=Lr(e.target);let G=0,E;const{x:_,y:I}=_e(e),M=jr(o,k),P=a==null?void 0:a.getBoundingClientRect();let B=!1;if(!P||!M)return;const $=Hr(r,M,i,c,t);if(!$)return;let R=_e(e,P),A=!1,U=null,z=!1,F=null;function V(){if(!l||!P)return;const[ee,K]=Ar(R,P,x);h({x:ee,y:K}),G=requestAnimationFrame(V)}const q={...$,nodeId:r,type:M,position:$.position},J=c.get(r);let ne={inProgress:!0,isValid:null,from:je(J,q,Y.Left,!0),fromHandle:q,fromPosition:q.position,fromNode:J,to:R,toHandle:null,toPosition:ci[q.position],toNode:null,pointer:R};function j(){B=!0,p(ne),g==null||g(e,{nodeId:r,handleId:i,handleType:M})}C===0&&j();function Q(ee){if(!B){const{x:ge,y:Me}=_e(ee),Te=ge-_,ze=Me-I;if(!(Te*Te+ze*ze>C*C))return;j()}if(!S()||!q){ie(ee);return}const K=b();R=_e(ee,P),E=qa(Tt(R,K,!1,[1,1]),n,c,q),A||(V(),A=!0);const Z=Wr(ee,{handle:E,connectionMode:t,fromNodeId:r,fromHandleId:i,fromType:s?"target":"source",isValidConnection:v,doc:N,lib:u,flowId:d,nodeLookup:c});F=Z.handleDomNode,U=Z.connection,z=Qa(!!E,Z.isValid);const se=c.get(r),ce=se?je(se,q,Y.Left,!0):ne.from,oe={...ne,from:ce,isValid:z,to:Z.toHandle&&z?Ht({x:Z.toHandle.x,y:Z.toHandle.y},K):R,toHandle:Z.toHandle,toPosition:z&&Z.toHandle?Z.toHandle.position:ci[q.position],toNode:Z.toHandle?c.get(Z.toHandle.nodeId):null,pointer:R};p(oe),ne=oe}function ie(ee){if(!("touches"in ee&&ee.touches.length>0)){if(B){(E||F)&&U&&z&&(y==null||y(U));const{inProgress:K,...Z}=ne,se={...Z,toPosition:ne.toHandle?ne.toPosition:null};m==null||m(ee,se),o&&(w==null||w(ee,se))}f(),cancelAnimationFrame(G),A=!1,z=!1,U=null,F=null,N.removeEventListener("mousemove",Q),N.removeEventListener("mouseup",ie),N.removeEventListener("touchmove",Q),N.removeEventListener("touchend",ie)}}N.addEventListener("mousemove",Q),N.addEventListener("mouseup",ie),N.addEventListener("touchmove",Q),N.addEventListener("touchend",ie)}function Wr(e,{handle:t,connectionMode:n,fromNodeId:i,fromHandleId:r,fromType:o,doc:s,lib:a,flowId:c,isValidConnection:u=Vr,nodeLookup:l}){const d=o==="target",h=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:f,y:g}=_e(e),y=s.elementFromPoint(f,g),m=y!=null&&y.classList.contains(`${a}-flow__handle`)?y:h,v={handleDomNode:m,isValid:!1,connection:null,toHandle:null};if(m){const w=jr(void 0,m),p=m.getAttribute("data-nodeid"),b=m.getAttribute("data-handleid"),S=m.classList.contains("connectable"),x=m.classList.contains("connectableend");if(!p||!w)return v;const C={source:d?p:i,sourceHandle:d?b:r,target:d?i:p,targetHandle:d?r:b};v.connection=C;const N=S&&x&&(n===qe.Strict?d&&w==="source"||!d&&w==="target":p!==i||b!==r);v.isValid=N&&u(C),v.toHandle=Hr(p,w,b,l,n,!0)}return v}const An={onPointerDown:Ja,isValid:Wr};function ec({domNode:e,panZoom:t,getTransform:n,getViewScale:i}){const r=Wt(e);function o({translateExtent:a,width:c,height:u,zoomStep:l=1,pannable:d=!0,zoomable:h=!0,inversePan:f=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const b=n(),S=p.sourceEvent.ctrlKey&&Et()?10:1,x=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*l,C=b[2]*Math.pow(2,x*S);t.scaleTo(C)};let y=[0,0];const m=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(y=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},v=p=>{const b=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const S=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],x=[S[0]-y[0],S[1]-y[1]];y=S;const C=i()*Math.max(b[2],Math.log(b[2]))*(f?-1:1),k={x:b[0]-x[0]*C,y:b[1]-x[1]*C},N=[[0,0],[c,u]];t.setViewportConstrained({x:k.x,y:k.y,zoom:b[2]},N,a)},w=yr().on("start",m).on("zoom",d?v:null).on("zoom.wheel",h?g:null);r.call(w,{})}function s(){r.on("zoom",null)}return{update:o,destroy:s,pointer:wr}}const Zt=e=>({x:e.x,y:e.y,zoom:e.k}),un=({x:e,y:t,zoom:n})=>la.translate(e,t).scale(n),Xe=(e,t)=>e.target.closest(`.${t}`),Yr=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),tc=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,dn=(e,t=0,n=tc,i=()=>{})=>{const r=typeof t=="number"&&t>0;return r||i(),r?e.transition().duration(t).ease(n).on("end",i):e},Xr=e=>{const t=e.ctrlKey&&Et()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function nc({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:i,panOnScrollMode:r,panOnScrollSpeed:o,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:u}){return l=>{if(Xe(l,t))return l.ctrlKey&&l.preventDefault(),!1;l.preventDefault(),l.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(l.ctrlKey&&s){const m=wr(l),v=Xr(l),w=d*Math.pow(2,v);i.scaleTo(n,w,m,l);return}const h=l.deltaMode===1?20:1;let f=r===Ue.Vertical?0:l.deltaX*h,g=r===Ue.Horizontal?0:l.deltaY*h;!Et()&&l.shiftKey&&r!==Ue.Vertical&&(f=l.deltaY*h,g=0),i.translateBy(n,-(f/d)*o,-(g/d)*o,{internal:!0});const y=Zt(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(l,y),e.panScrollTimeout=setTimeout(()=>{u==null||u(l,y),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a==null||a(l,y))}}function ic({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(i,r){const o=i.type==="wheel",s=!t&&o&&!i.ctrlKey,a=Xe(i,e);if(i.ctrlKey&&o&&a&&i.preventDefault(),s||a)return null;i.preventDefault(),n.call(this,i,r)}}function rc({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return i=>{var o,s,a;if((o=i.sourceEvent)!=null&&o.internal)return;const r=Zt(i.transform);e.mouseButton=((s=i.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=r,((a=i.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(i.sourceEvent,r))}}function oc({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:i,onPanZoom:r}){return o=>{var s,a;e.usedRightMouseButton=!!(n&&Yr(t,e.mouseButton??0)),(s=o.sourceEvent)!=null&&s.sync||i([o.transform.x,o.transform.y,o.transform.k]),r&&!((a=o.sourceEvent)!=null&&a.internal)&&(r==null||r(o.sourceEvent,Zt(o.transform)))}}function sc({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:i,onPanZoomEnd:r,onPaneContextMenu:o}){return s=>{var a;if(!((a=s.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,o&&Yr(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&o(s.sourceEvent),e.usedRightMouseButton=!1,i(!1),r)){const c=Zt(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(s.sourceEvent,c)},n?150:0)}}}function ac({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:i,panOnScroll:r,zoomOnDoubleClick:o,userSelectionActive:s,noWheelClassName:a,noPanClassName:c,lib:u,connectionInProgress:l}){return d=>{var m;const h=e||t,f=n&&d.ctrlKey,g=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(Xe(d,`${u}-flow__node`)||Xe(d,`${u}-flow__edge`)))return!0;if(!i&&!h&&!r&&!o&&!n||s||l&&!g||Xe(d,a)&&g||Xe(d,c)&&(!g||r&&g&&!e)||!n&&d.ctrlKey&&g)return!1;if(!n&&d.type==="touchstart"&&((m=d.touches)==null?void 0:m.length)>1)return d.preventDefault(),!1;if(!h&&!r&&!f&&g||!i&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(i)&&!i.includes(d.button)&&d.type==="mousedown")return!1;const y=Array.isArray(i)&&i.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||g)&&y}}function cc({domNode:e,minZoom:t,maxZoom:n,translateExtent:i,viewport:r,onPanZoom:o,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},l=e.getBoundingClientRect(),d=yr().scaleExtent([t,n]).translateExtent(i),h=Wt(e).call(d);w({x:r.x,y:r.y,zoom:Qe(r.zoom,t,n)},[[0,0],[l.width,l.height]],i);const f=h.on("wheel.zoom"),g=h.on("dblclick.zoom");d.wheelDelta(Xr);function y(E,_){return h?new Promise(I=>{d==null||d.interpolate((_==null?void 0:_.interpolate)==="linear"?an:sn).transform(dn(h,_==null?void 0:_.duration,_==null?void 0:_.ease,()=>I(!0)),E)}):Promise.resolve(!1)}function m({noWheelClassName:E,noPanClassName:_,onPaneContextMenu:I,userSelectionActive:M,panOnScroll:P,panOnDrag:B,panOnScrollMode:$,panOnScrollSpeed:R,preventScrolling:A,zoomOnPinch:U,zoomOnScroll:z,zoomOnDoubleClick:F,zoomActivationKeyPressed:V,lib:q,onTransformChange:J,connectionInProgress:te,paneClickDistance:ne,selectionOnDrag:j}){M&&!u.isZoomingOrPanning&&v();const Q=P&&!V&&!M;d.clickDistance(j?1/0:!Ce(ne)||ne<0?0:ne);const ie=Q?nc({zoomPanValues:u,noWheelClassName:E,d3Selection:h,d3Zoom:d,panOnScrollMode:$,panOnScrollSpeed:R,zoomOnPinch:U,onPanZoomStart:s,onPanZoom:o,onPanZoomEnd:a}):ic({noWheelClassName:E,preventScrolling:A,d3ZoomHandler:f});if(h.on("wheel.zoom",ie,{passive:!1}),!M){const K=rc({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:s});d.on("start",K);const Z=oc({zoomPanValues:u,panOnDrag:B,onPaneContextMenu:!!I,onPanZoom:o,onTransformChange:J});d.on("zoom",Z);const se=sc({zoomPanValues:u,panOnDrag:B,panOnScroll:P,onPaneContextMenu:I,onPanZoomEnd:a,onDraggingChange:c});d.on("end",se)}const ee=ac({zoomActivationKeyPressed:V,panOnDrag:B,zoomOnScroll:z,panOnScroll:P,zoomOnDoubleClick:F,zoomOnPinch:U,userSelectionActive:M,noPanClassName:_,noWheelClassName:E,lib:q,connectionInProgress:te});d.filter(ee),F?h.on("dblclick.zoom",g):h.on("dblclick.zoom",null)}function v(){d.on("zoom",null)}async function w(E,_,I){const M=un(E),P=d==null?void 0:d.constrain()(M,_,I);return P&&await y(P),new Promise(B=>B(P))}async function p(E,_){const I=un(E);return await y(I,_),new Promise(M=>M(I))}function b(E){if(h){const _=un(E),I=h.property("__zoom");(I.k!==E.zoom||I.x!==E.x||I.y!==E.y)&&(d==null||d.transform(h,_,null,{sync:!0}))}}function S(){const E=h?ha(h.node()):{x:0,y:0,k:1};return{x:E.x,y:E.y,zoom:E.k}}function x(E,_){return h?new Promise(I=>{d==null||d.interpolate((_==null?void 0:_.interpolate)==="linear"?an:sn).scaleTo(dn(h,_==null?void 0:_.duration,_==null?void 0:_.ease,()=>I(!0)),E)}):Promise.resolve(!1)}function C(E,_){return h?new Promise(I=>{d==null||d.interpolate((_==null?void 0:_.interpolate)==="linear"?an:sn).scaleBy(dn(h,_==null?void 0:_.duration,_==null?void 0:_.ease,()=>I(!0)),E)}):Promise.resolve(!1)}function k(E){d==null||d.scaleExtent(E)}function N(E){d==null||d.translateExtent(E)}function G(E){const _=!Ce(E)||E<0?0:E;d==null||d.clickDistance(_)}return{update:m,destroy:v,setViewport:p,setViewportConstrained:w,getViewport:S,scaleTo:x,scaleBy:C,setScaleExtent:k,setTranslateExtent:N,syncViewport:b,setClickDistance:G}}var tt;(function(e){e.Line="line",e.Handle="handle"})(tt||(tt={}));function uc({width:e,prevWidth:t,height:n,prevHeight:i,affectsX:r,affectsY:o}){const s=e-t,a=n-i,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(c[0]=c[0]*-1),a&&o&&(c[1]=c[1]*-1),c}function xi(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),i=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:i,affectsY:r}}function Pe(e,t){return Math.max(0,t-e)}function Ie(e,t){return Math.max(0,e-t)}function Lt(e,t,n){return Math.max(0,t-e,e-n)}function Ei(e,t){return e?!t:t}function dc(e,t,n,i,r,o,s,a){let{affectsX:c,affectsY:u}=t;const{isHorizontal:l,isVertical:d}=t,h=l&&d,{xSnapped:f,ySnapped:g}=n,{minWidth:y,maxWidth:m,minHeight:v,maxHeight:w}=i,{x:p,y:b,width:S,height:x,aspectRatio:C}=e;let k=Math.floor(l?f-e.pointerX:0),N=Math.floor(d?g-e.pointerY:0);const G=S+(c?-k:k),E=x+(u?-N:N),_=-o[0]*S,I=-o[1]*x;let M=Lt(G,y,m),P=Lt(E,v,w);if(s){let R=0,A=0;c&&k<0?R=Pe(p+k+_,s[0][0]):!c&&k>0&&(R=Ie(p+G+_,s[1][0])),u&&N<0?A=Pe(b+N+I,s[0][1]):!u&&N>0&&(A=Ie(b+E+I,s[1][1])),M=Math.max(M,R),P=Math.max(P,A)}if(a){let R=0,A=0;c&&k>0?R=Ie(p+k,a[0][0]):!c&&k<0&&(R=Pe(p+G,a[1][0])),u&&N>0?A=Ie(b+N,a[0][1]):!u&&N<0&&(A=Pe(b+E,a[1][1])),M=Math.max(M,R),P=Math.max(P,A)}if(r){if(l){const R=Lt(G/C,v,w)*C;if(M=Math.max(M,R),s){let A=0;!c&&!u||c&&!u&&h?A=Ie(b+I+G/C,s[1][1])*C:A=Pe(b+I+(c?k:-k)/C,s[0][1])*C,M=Math.max(M,A)}if(a){let A=0;!c&&!u||c&&!u&&h?A=Pe(b+G/C,a[1][1])*C:A=Ie(b+(c?k:-k)/C,a[0][1])*C,M=Math.max(M,A)}}if(d){const R=Lt(E*C,y,m)/C;if(P=Math.max(P,R),s){let A=0;!c&&!u||u&&!c&&h?A=Ie(p+E*C+_,s[1][0])/C:A=Pe(p+(u?N:-N)*C+_,s[0][0])/C,P=Math.max(P,A)}if(a){let A=0;!c&&!u||u&&!c&&h?A=Pe(p+E*C,a[1][0])/C:A=Ie(p+(u?N:-N)*C,a[0][0])/C,P=Math.max(P,A)}}}N=N+(N<0?P:-P),k=k+(k<0?M:-M),r&&(h?G>E*C?N=(Ei(c,u)?-k:k)/C:k=(Ei(c,u)?-N:N)*C:l?(N=k/C,u=c):(k=N*C,c=u));const B=c?p+k:p,$=u?b+N:b;return{width:S+(c?-k:k),height:x+(u?-N:N),x:o[0]*k*(c?-1:1)+B,y:o[1]*N*(u?-1:1)+$}}const Zr={width:0,height:0,x:0,y:0},lc={...Zr,pointerX:0,pointerY:0,aspectRatio:1};function hc(e){return[[0,0],[e.measured.width,e.measured.height]]}function fc(e,t,n){const i=t.position.x+e.position.x,r=t.position.y+e.position.y,o=e.measured.width??0,s=e.measured.height??0,a=n[0]*o,c=n[1]*s;return[[i-a,r-c],[i+o-a,r+s-c]]}function gc({domNode:e,nodeId:t,getStoreItems:n,onChange:i,onEnd:r}){const o=Wt(e);let s={controlDirection:xi("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:u,boundaries:l,keepAspectRatio:d,resizeDirection:h,onResizeStart:f,onResize:g,onResizeEnd:y,shouldResize:m}){let v={...Zr},w={...lc};s={boundaries:l,resizeDirection:h,keepAspectRatio:d,controlDirection:xi(u)};let p,b=null,S=[],x,C,k,N=!1;const G=vr().on("start",E=>{const{nodeLookup:_,transform:I,snapGrid:M,snapToGrid:P,nodeOrigin:B,paneDomNode:$}=n();if(p=_.get(t),!p)return;b=($==null?void 0:$.getBoundingClientRect())??null;const{xSnapped:R,ySnapped:A}=yt(E.sourceEvent,{transform:I,snapGrid:M,snapToGrid:P,containerBounds:b});v={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},w={...v,pointerX:R,pointerY:A,aspectRatio:v.width/v.height},x=void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(x=_.get(p.parentId),C=x&&p.extent==="parent"?hc(x):void 0),S=[],k=void 0;for(const[U,z]of _)if(z.parentId===t&&(S.push({id:U,position:{...z.position},extent:z.extent}),z.extent==="parent"||z.expandParent)){const F=fc(z,p,z.origin??B);k?k=[[Math.min(F[0][0],k[0][0]),Math.min(F[0][1],k[0][1])],[Math.max(F[1][0],k[1][0]),Math.max(F[1][1],k[1][1])]]:k=F}f==null||f(E,{...v})}).on("drag",E=>{const{transform:_,snapGrid:I,snapToGrid:M,nodeOrigin:P}=n(),B=yt(E.sourceEvent,{transform:_,snapGrid:I,snapToGrid:M,containerBounds:b}),$=[];if(!p)return;const{x:R,y:A,width:U,height:z}=v,F={},V=p.origin??P,{width:q,height:J,x:te,y:ne}=dc(w,s.controlDirection,B,s.boundaries,s.keepAspectRatio,V,C,k),j=q!==U,Q=J!==z,ie=te!==R&&j,ee=ne!==A&&Q;if(!ie&&!ee&&!j&&!Q)return;if((ie||ee||V[0]===1||V[1]===1)&&(F.x=ie?te:v.x,F.y=ee?ne:v.y,v.x=F.x,v.y=F.y,S.length>0)){const ce=te-R,oe=ne-A;for(const ge of S)ge.position={x:ge.position.x-ce+V[0]*(q-U),y:ge.position.y-oe+V[1]*(J-z)},$.push(ge)}if((j||Q)&&(F.width=j&&(!s.resizeDirection||s.resizeDirection==="horizontal")?q:v.width,F.height=Q&&(!s.resizeDirection||s.resizeDirection==="vertical")?J:v.height,v.width=F.width,v.height=F.height),x&&p.expandParent){const ce=V[0]*(F.width??0);F.x&&F.x<ce&&(v.x=ce,w.x=w.x-(F.x-ce));const oe=V[1]*(F.height??0);F.y&&F.y<oe&&(v.y=oe,w.y=w.y-(F.y-oe))}const K=uc({width:v.width,prevWidth:U,height:v.height,prevHeight:z,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),Z={...v,direction:K};(m==null?void 0:m(E,Z))!==!1&&(N=!0,g==null||g(E,Z),i(F,$))}).on("end",E=>{N&&(y==null||y(E,{...v}),r==null||r({...v}),N=!1)});o.call(G)}function c(){o.on(".drag",null)}return{update:a,destroy:c}}const Kt=D.createContext(null),pc=Kt.Provider,Kr=Ne.error001();function re(e,t){const n=D.useContext(Kt);if(n===null)throw new Error(Kr);return ga(n,e,t)}function de(){const e=D.useContext(Kt);if(e===null)throw new Error(Kr);return D.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Si={display:"none"},mc={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},qr="react-flow__node-desc",Qr="react-flow__edge-desc",yc="react-flow__aria-live",vc=e=>e.ariaLiveMessage,wc=e=>e.ariaLabelConfig;function bc({rfId:e}){const t=re(vc);return T.jsx("div",{id:`${yc}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:mc,children:t})}function xc({rfId:e,disableKeyboardA11y:t}){const n=re(wc);return T.jsxs(T.Fragment,{children:[T.jsx("div",{id:`${qr}-${e}`,style:Si,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),T.jsx("div",{id:`${Qr}-${e}`,style:Si,children:n["edge.a11yDescription.default"]}),!t&&T.jsx(bc,{rfId:e})]})}const qt=D.forwardRef(({position:e="top-left",children:t,className:n,style:i,...r},o)=>{const s=`${e}`.split("-");return T.jsx("div",{className:he(["react-flow__panel",n,...s]),style:i,ref:o,...r,children:t})});qt.displayName="Panel";function Ec({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:T.jsx(qt,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:T.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Sc=e=>{const t=[],n=[];for(const[,i]of e.nodeLookup)i.selected&&t.push(i.internals.userNode);for(const[,i]of e.edgeLookup)i.selected&&n.push(i);return{selectedNodes:t,selectedEdges:n}},Mt=e=>e.id;function Cc(e,t){return ue(e.selectedNodes.map(Mt),t.selectedNodes.map(Mt))&&ue(e.selectedEdges.map(Mt),t.selectedEdges.map(Mt))}function _c({onSelectionChange:e}){const t=de(),{selectedNodes:n,selectedEdges:i}=re(Sc,Cc);return D.useEffect(()=>{const r={nodes:n,edges:i};e==null||e(r),t.getState().onSelectionChangeHandlers.forEach(o=>o(r))},[n,i,e]),null}const Nc=e=>!!e.onSelectionChangeHandlers;function Tc({onSelectionChange:e}){const t=re(Nc);return e||t?T.jsx(_c,{onSelectionChange:e}):null}const kn=typeof window<"u"?D.useLayoutEffect:D.useEffect,Jr=[0,0],Ac={x:0,y:0,zoom:1},kc=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],Ci=[...kc,"rfId"],Rc=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),_i={translateExtent:wt,nodeOrigin:Jr,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Dc(e){const{setNodes:t,setEdges:n,setMinZoom:i,setMaxZoom:r,setTranslateExtent:o,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=re(Rc,ue),u=de();kn(()=>(c(e.defaultNodes,e.defaultEdges),()=>{l.current=_i,a()}),[]);const l=D.useRef(_i);return kn(()=>{for(const d of Ci){const h=e[d],f=l.current[d];h!==f&&(typeof e[d]>"u"||(d==="nodes"?t(h):d==="edges"?n(h):d==="minZoom"?i(h):d==="maxZoom"?r(h):d==="translateExtent"?o(h):d==="nodeExtent"?s(h):d==="ariaLabelConfig"?u.setState({ariaLabelConfig:Na(h)}):d==="fitView"?u.setState({fitViewQueued:h}):d==="fitViewOptions"?u.setState({fitViewOptions:h}):u.setState({[d]:h})))}l.current=e},Ci.map(d=>e[d])),null}function Ni(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Lc(e){var i;const[t,n]=D.useState(e==="system"?null:e);return D.useEffect(()=>{if(e!=="system"){n(e);return}const r=Ni(),o=()=>n(r!=null&&r.matches?"dark":"light");return o(),r==null||r.addEventListener("change",o),()=>{r==null||r.removeEventListener("change",o)}},[e]),t!==null?t:(i=Ni())!=null&&i.matches?"dark":"light"}const Ti=typeof document<"u"?document:null;function St(e=null,t={target:Ti,actInsideInputWithModifier:!0}){const[n,i]=D.useState(!1),r=D.useRef(!1),o=D.useRef(new Set([])),[s,a]=D.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace("+",`
|
|
1
|
+
import{z as yr,o as Wt,p as la,q as sn,v as an,x as ha,y as vr,A as wr,r as D,j as A,B as he,C as br,D as fa}from"./vendor-kIz9EZnX.js";import{u as ga,c as pa,s as ue}from"./state-VYvD1QVP.js";const Ne={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:i})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:i}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},wt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],xr=["Enter"," ","Escape"],Er={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var qe;(function(e){e.Strict="strict",e.Loose="loose"})(qe||(qe={}));var Ue;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ue||(Ue={}));var bt;(function(e){e.Partial="partial",e.Full="full"})(bt||(bt={}));const Sr={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Fe;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Fe||(Fe={}));var Ot;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ot||(Ot={}));var Y;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Y||(Y={}));const ci={[Y.Left]:Y.Right,[Y.Right]:Y.Left,[Y.Top]:Y.Bottom,[Y.Bottom]:Y.Top};function Cr(e){return e===null?null:e?"valid":"invalid"}const _r=e=>"id"in e&&"source"in e&&"target"in e,ma=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Gn=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Ct=(e,t=[0,0])=>{const{width:n,height:i}=De(e),r=e.origin??t,o=n*r[0],s=i*r[1];return{x:e.position.x-o,y:e.position.y-s}},ya=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((i,r)=>{const o=typeof r=="string";let s=!t.nodeLookup&&!o?r:void 0;t.nodeLookup&&(s=o?t.nodeLookup.get(r):Gn(r)?r:t.nodeLookup.get(r.id));const a=s?Ut(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Yt(i,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Xt(n)},_t=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},i=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=Yt(n,Ut(r)),i=!0)}),i?Xt(n):{x:0,y:0,width:0,height:0}},Fn=(e,t,[n,i,r]=[0,0,1],o=!1,s=!1)=>{const a={...At(t,[n,i,r]),width:t.width/r,height:t.height/r},c=[];for(const u of e.values()){const{measured:l,selectable:d=!0,hidden:h=!1}=u;if(s&&!d||h)continue;const f=l.width??u.width??u.initialWidth??null,g=l.height??u.height??u.initialHeight??null,y=xt(a,Je(u)),m=(f??0)*(g??0),v=o&&y>0;(!u.internals.handleBounds||v||y>=m||u.dragging)&&c.push(u)}return c},va=(e,t)=>{const n=new Set;return e.forEach(i=>{n.add(i.id)}),t.filter(i=>n.has(i.source)||n.has(i.target))};function wa(e,t){const n=new Map,i=t!=null&&t.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!r.hidden)&&(!i||i.has(r.id))&&n.set(r.id,r)}),n}async function ba({nodes:e,width:t,height:n,panZoom:i,minZoom:r,maxZoom:o},s){if(e.size===0)return Promise.resolve(!0);const a=wa(e,s),c=_t(a),u=$n(c,t,n,(s==null?void 0:s.minZoom)??r,(s==null?void 0:s.maxZoom)??o,(s==null?void 0:s.padding)??.1);return await i.setViewport(u,{duration:s==null?void 0:s.duration,ease:s==null?void 0:s.ease,interpolate:s==null?void 0:s.interpolate}),Promise.resolve(!0)}function Nr({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:i=[0,0],nodeExtent:r,onError:o}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:u}=a?a.internals.positionAbsolute:{x:0,y:0},l=s.origin??i;let d=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)o==null||o("005",Ne.error005());else{const f=a.measured.width,g=a.measured.height;f&&g&&(d=[[c,u],[c+f,u+g]])}else a&&et(s.extent)&&(d=[[s.extent[0][0]+c,s.extent[0][1]+u],[s.extent[1][0]+c,s.extent[1][1]+u]]);const h=et(d)?He(t,d,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&(o==null||o("015",Ne.error015())),{position:{x:h.x-c+(s.measured.width??0)*l[0],y:h.y-u+(s.measured.height??0)*l[1]},positionAbsolute:h}}async function xa({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:i,onBeforeDelete:r}){const o=new Set(e.map(h=>h.id)),s=[];for(const h of n){if(h.deletable===!1)continue;const f=o.has(h.id),g=!f&&h.parentId&&s.find(y=>y.id===h.parentId);(f||g)&&s.push(h)}const a=new Set(t.map(h=>h.id)),c=i.filter(h=>h.deletable!==!1),l=va(s,c);for(const h of c)a.has(h.id)&&!l.find(g=>g.id===h.id)&&l.push(h);if(!r)return{edges:l,nodes:s};const d=await r({nodes:s,edges:l});return typeof d=="boolean"?d?{edges:l,nodes:s}:{edges:[],nodes:[]}:d}const Qe=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),He=(e={x:0,y:0},t,n)=>({x:Qe(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Qe(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function Ar(e,t,n){const{width:i,height:r}=De(n),{x:o,y:s}=n.internals.positionAbsolute;return He(e,[[o,s],[o+i,s+r]],t)}const ui=(e,t,n)=>e<t?Qe(Math.abs(e-t),1,t)/t:e>n?-Qe(Math.abs(e-n),1,t)/t:0,Tr=(e,t,n=15,i=40)=>{const r=ui(e.x,i,t.width-i)*n,o=ui(e.y,i,t.height-i)*n;return[r,o]},Yt=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Cn=({x:e,y:t,width:n,height:i})=>({x:e,y:t,x2:e+n,y2:t+i}),Xt=({x:e,y:t,x2:n,y2:i})=>({x:e,y:t,width:n-e,height:i-t}),Je=(e,t=[0,0])=>{var r,o;const{x:n,y:i}=Gn(e)?e.internals.positionAbsolute:Ct(e,t);return{x:n,y:i,width:((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},Ut=(e,t=[0,0])=>{var r,o;const{x:n,y:i}=Gn(e)?e.internals.positionAbsolute:Ct(e,t);return{x:n,y:i,x2:n+(((r=e.measured)==null?void 0:r.width)??e.width??e.initialWidth??0),y2:i+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},kr=(e,t)=>Xt(Yt(Cn(e),Cn(t))),xt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),i=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*i)},di=e=>Ce(e.width)&&Ce(e.height)&&Ce(e.x)&&Ce(e.y),Ce=e=>!isNaN(e)&&isFinite(e),Ea=(e,t)=>{},Nt=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),At=({x:e,y:t},[n,i,r],o=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-i)/r};return o?Nt(a,s):a},Ht=({x:e,y:t},[n,i,r])=>({x:e*r+n,y:t*r+i});function We(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Sa(e,t,n){if(typeof e=="string"||typeof e=="number"){const i=We(e,n),r=We(e,t);return{top:i,right:r,bottom:i,left:r,x:r*2,y:i*2}}if(typeof e=="object"){const i=We(e.top??e.y??0,n),r=We(e.bottom??e.y??0,n),o=We(e.left??e.x??0,t),s=We(e.right??e.x??0,t);return{top:i,right:s,bottom:r,left:o,x:o+s,y:i+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Ca(e,t,n,i,r,o){const{x:s,y:a}=Ht(e,[t,n,i]),{x:c,y:u}=Ht({x:e.x+e.width,y:e.y+e.height},[t,n,i]),l=r-c,d=o-u;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(l),bottom:Math.floor(d)}}const $n=(e,t,n,i,r,o)=>{const s=Sa(o,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,u=Math.min(a,c),l=Qe(u,i,r),d=e.x+e.width/2,h=e.y+e.height/2,f=t/2-d*l,g=n/2-h*l,y=Ca(e,f,g,l,t,n),m={left:Math.min(y.left-s.left,0),top:Math.min(y.top-s.top,0),right:Math.min(y.right-s.right,0),bottom:Math.min(y.bottom-s.bottom,0)};return{x:f-m.left+m.right,y:g-m.top+m.bottom,zoom:l}},Et=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function et(e){return e!=null&&e!=="parent"}function De(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function Rr(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function Dr(e,t={width:0,height:0},n,i,r){const o={...e},s=i.get(n);if(s){const a=s.origin||r;o.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],o.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return o}function li(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function _a(){let e,t;return{promise:new Promise((i,r)=>{e=i,t=r}),resolve:e,reject:t}}function Na(e){return{...Er,...e||{}}}function yt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:i,containerBounds:r}){const{x:o,y:s}=_e(e),a=At({x:o-((r==null?void 0:r.left)??0),y:s-((r==null?void 0:r.top)??0)},i),{x:c,y:u}=n?Nt(a,t):a;return{xSnapped:c,ySnapped:u,...a}}const zn=e=>({width:e.offsetWidth,height:e.offsetHeight}),Lr=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Aa=["INPUT","SELECT","TEXTAREA"];function Mr(e){var i,r;const t=((r=(i=e.composedPath)==null?void 0:i.call(e))==null?void 0:r[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:Aa.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Pr=e=>"clientX"in e,_e=(e,t)=>{var o,s;const n=Pr(e),i=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,r=n?e.clientY:(s=e.touches)==null?void 0:s[0].clientY;return{x:i-((t==null?void 0:t.left)??0),y:r-((t==null?void 0:t.top)??0)}},hi=(e,t,n,i,r)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/i,y:(a.top-n.top)/i,...zn(s)}})};function Ir({sourceX:e,sourceY:t,targetX:n,targetY:i,sourceControlX:r,sourceControlY:o,targetControlX:s,targetControlY:a}){const c=e*.125+r*.375+s*.375+n*.125,u=t*.125+o*.375+a*.375+i*.125,l=Math.abs(c-e),d=Math.abs(u-t);return[c,u,l,d]}function Dt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function fi({pos:e,x1:t,y1:n,x2:i,y2:r,c:o}){switch(e){case Y.Left:return[t-Dt(t-i,o),n];case Y.Right:return[t+Dt(i-t,o),n];case Y.Top:return[t,n-Dt(n-r,o)];case Y.Bottom:return[t,n+Dt(r-n,o)]}}function Gr({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:i,targetY:r,targetPosition:o=Y.Top,curvature:s=.25}){const[a,c]=fi({pos:n,x1:e,y1:t,x2:i,y2:r,c:s}),[u,l]=fi({pos:o,x1:i,y1:r,x2:e,y2:t,c:s}),[d,h,f,g]=Ir({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:u,targetControlY:l});return[`M${e},${t} C${a},${c} ${u},${l} ${i},${r}`,d,h,f,g]}function Fr({sourceX:e,sourceY:t,targetX:n,targetY:i}){const r=Math.abs(n-e)/2,o=n<e?n+r:n-r,s=Math.abs(i-t)/2,a=i<t?i+s:i-s;return[o,a,r,s]}function Ta({sourceNode:e,targetNode:t,selected:n=!1,zIndex:i=0,elevateOnSelect:r=!1,zIndexMode:o="basic"}){if(o==="manual")return i;const s=r&&n?i+1e3:i,a=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return s+a}function ka({sourceNode:e,targetNode:t,width:n,height:i,transform:r}){const o=Yt(Ut(e),Ut(t));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const s={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:i/r[2]};return xt(s,Xt(o))>0}const Ra=({source:e,sourceHandle:t,target:n,targetHandle:i})=>`xy-edge__${e}${t||""}-${n}${i||""}`,Da=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),La=(e,t,n={})=>{if(!e.source||!e.target)return t;const i=n.getEdgeId||Ra;let r;return _r(e)?r={...e}:r={...e,id:i(e)},Da(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function $r({sourceX:e,sourceY:t,targetX:n,targetY:i}){const[r,o,s,a]=Fr({sourceX:e,sourceY:t,targetX:n,targetY:i});return[`M ${e},${t}L ${n},${i}`,r,o,s,a]}const gi={[Y.Left]:{x:-1,y:0},[Y.Right]:{x:1,y:0},[Y.Top]:{x:0,y:-1},[Y.Bottom]:{x:0,y:1}},Ma=({source:e,sourcePosition:t=Y.Bottom,target:n})=>t===Y.Left||t===Y.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},pi=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Pa({source:e,sourcePosition:t=Y.Bottom,target:n,targetPosition:i=Y.Top,center:r,offset:o,stepPosition:s}){const a=gi[t],c=gi[i],u={x:e.x+a.x*o,y:e.y+a.y*o},l={x:n.x+c.x*o,y:n.y+c.y*o},d=Ma({source:u,sourcePosition:t,target:l}),h=d.x!==0?"x":"y",f=d[h];let g=[],y,m;const v={x:0,y:0},w={x:0,y:0},[,,p,b]=Fr({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[h]*c[h]===-1){h==="x"?(y=r.x??u.x+(l.x-u.x)*s,m=r.y??(u.y+l.y)/2):(y=r.x??(u.x+l.x)/2,m=r.y??u.y+(l.y-u.y)*s);const k=[{x:y,y:u.y},{x:y,y:l.y}],N=[{x:u.x,y:m},{x:l.x,y:m}];a[h]===f?g=h==="x"?k:N:g=h==="x"?N:k}else{const k=[{x:u.x,y:l.y}],N=[{x:l.x,y:u.y}];if(h==="x"?g=a.x===f?N:k:g=a.y===f?k:N,t===i){const M=Math.abs(e[h]-n[h]);if(M<=o){const P=Math.min(o-1,o-M);a[h]===f?v[h]=(u[h]>e[h]?-1:1)*P:w[h]=(l[h]>n[h]?-1:1)*P}}if(t!==i){const M=h==="x"?"y":"x",P=a[h]===c[M],B=u[M]>l[M],$=u[M]<l[M];(a[h]===1&&(!P&&B||P&&$)||a[h]!==1&&(!P&&$||P&&B))&&(g=h==="x"?k:N)}const G={x:u.x+v.x,y:u.y+v.y},E={x:l.x+w.x,y:l.y+w.y},_=Math.max(Math.abs(G.x-g[0].x),Math.abs(E.x-g[0].x)),I=Math.max(Math.abs(G.y-g[0].y),Math.abs(E.y-g[0].y));_>=I?(y=(G.x+E.x)/2,m=g[0].y):(y=g[0].x,m=(G.y+E.y)/2)}const S={x:u.x+v.x,y:u.y+v.y},x={x:l.x+w.x,y:l.y+w.y};return[[e,...S.x!==g[0].x||S.y!==g[0].y?[S]:[],...g,...x.x!==g[g.length-1].x||x.y!==g[g.length-1].y?[x]:[],n],y,m,p,b]}function Ia(e,t,n,i){const r=Math.min(pi(e,t)/2,pi(t,n)/2,i),{x:o,y:s}=t;if(e.x===o&&o===n.x||e.y===s&&s===n.y)return`L${o} ${s}`;if(e.y===s){const u=e.x<n.x?-1:1,l=e.y<n.y?1:-1;return`L ${o+r*u},${s}Q ${o},${s} ${o},${s+r*l}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${o},${s+r*c}Q ${o},${s} ${o+r*a},${s}`}function _n({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:i,targetY:r,targetPosition:o=Y.Top,borderRadius:s=5,centerX:a,centerY:c,offset:u=20,stepPosition:l=.5}){const[d,h,f,g,y]=Pa({source:{x:e,y:t},sourcePosition:n,target:{x:i,y:r},targetPosition:o,center:{x:a,y:c},offset:u,stepPosition:l});let m=`M${d[0].x} ${d[0].y}`;for(let v=1;v<d.length-1;v++)m+=Ia(d[v-1],d[v],d[v+1],s);return m+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[m,h,f,g,y]}function mi(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Ga(e){var d;const{sourceNode:t,targetNode:n}=e;if(!mi(t)||!mi(n))return null;const i=t.internals.handleBounds||yi(t.handles),r=n.internals.handleBounds||yi(n.handles),o=vi((i==null?void 0:i.source)??[],e.sourceHandle),s=vi(e.connectionMode===qe.Strict?(r==null?void 0:r.target)??[]:((r==null?void 0:r.target)??[]).concat((r==null?void 0:r.source)??[]),e.targetHandle);if(!o||!s)return(d=e.onError)==null||d.call(e,"008",Ne.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(o==null?void 0:o.position)||Y.Bottom,c=(s==null?void 0:s.position)||Y.Top,u=je(t,o,a),l=je(n,s,c);return{sourceX:u.x,sourceY:u.y,targetX:l.x,targetY:l.y,sourcePosition:a,targetPosition:c}}function yi(e){if(!e)return null;const t=[],n=[];for(const i of e)i.width=i.width??1,i.height=i.height??1,i.type==="source"?t.push(i):i.type==="target"&&n.push(i);return{source:t,target:n}}function je(e,t,n=Y.Left,i=!1){const r=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,o=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??De(e);if(i)return{x:r+s/2,y:o+a/2};switch((t==null?void 0:t.position)??n){case Y.Top:return{x:r+s/2,y:o};case Y.Right:return{x:r+s,y:o+a/2};case Y.Bottom:return{x:r+s/2,y:o+a};case Y.Left:return{x:r,y:o+a/2}}}function vi(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Nn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`:""}function Fa(e,{id:t,defaultColor:n,defaultMarkerStart:i,defaultMarkerEnd:r}){const o=new Set;return e.reduce((s,a)=>([a.markerStart||i,a.markerEnd||r].forEach(c=>{if(c&&typeof c=="object"){const u=Nn(c,t);o.has(u)||(s.push({id:u,color:c.color||n,...c}),o.add(u))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const zr=1e3,$a=10,Bn={nodeOrigin:[0,0],nodeExtent:wt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},za={...Bn,checkEquality:!0};function On(e,t){const n={...e};for(const i in t)t[i]!==void 0&&(n[i]=t[i]);return n}function Ba(e,t,n){const i=On(Bn,n);for(const r of e.values())if(r.parentId)Hn(r,e,t,i);else{const o=Ct(r,i.nodeOrigin),s=et(r.extent)?r.extent:i.nodeExtent,a=He(o,s,De(r));r.internals.positionAbsolute=a}}function Oa(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],i=[];for(const r of e.handles){const o={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(o):r.type==="target"&&i.push(o)}return{source:n,target:i}}function Un(e){return e==="manual"}function An(e,t,n,i={}){var l,d;const r=On(za,i),o={i:0},s=new Map(t),a=r!=null&&r.elevateNodesOnSelect&&!Un(r.zIndexMode)?zr:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const h of e){let f=s.get(h.id);if(r.checkEquality&&h===(f==null?void 0:f.internals.userNode))t.set(h.id,f);else{const g=Ct(h,r.nodeOrigin),y=et(h.extent)?h.extent:r.nodeExtent,m=He(g,y,De(h));f={...r.defaults,...h,measured:{width:(l=h.measured)==null?void 0:l.width,height:(d=h.measured)==null?void 0:d.height},internals:{positionAbsolute:m,handleBounds:Oa(h,f),z:Br(h,a,r.zIndexMode),userNode:h}},t.set(h.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(c=!1),h.parentId&&Hn(f,t,n,i,o),u||(u=h.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function Ua(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Hn(e,t,n,i,r){const{elevateNodesOnSelect:o,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=On(Bn,i),u=e.parentId,l=t.get(u);if(!l){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Ua(e,n),r&&!l.parentId&&l.internals.rootParentIndex===void 0&&c==="auto"&&(l.internals.rootParentIndex=++r.i,l.internals.z=l.internals.z+r.i*$a),r&&l.internals.rootParentIndex!==void 0&&(r.i=l.internals.rootParentIndex);const d=o&&!Un(c)?zr:0,{x:h,y:f,z:g}=Ha(e,l,s,a,d,c),{positionAbsolute:y}=e.internals,m=h!==y.x||f!==y.y;(m||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:m?{x:h,y:f}:y,z:g}})}function Br(e,t,n){const i=Ce(e.zIndex)?e.zIndex:0;return Un(n)?i:i+(e.selected?t:0)}function Ha(e,t,n,i,r,o){const{x:s,y:a}=t.internals.positionAbsolute,c=De(e),u=Ct(e,n),l=et(e.extent)?He(u,e.extent,c):u;let d=He({x:s+l.x,y:a+l.y},i,c);e.extent==="parent"&&(d=Ar(d,c,t));const h=Br(e,r,o),f=t.internals.z??0;return{x:d.x,y:d.y,z:f>=h?f+1:h}}function jn(e,t,n,i=[0,0]){var s;const r=[],o=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const u=((s=o.get(a.parentId))==null?void 0:s.expandedRect)??Je(c),l=kr(u,a.rect);o.set(a.parentId,{expandedRect:l,parent:c})}return o.size>0&&o.forEach(({expandedRect:a,parent:c},u)=>{var p;const l=c.internals.positionAbsolute,d=De(c),h=c.origin??i,f=a.x<l.x?Math.round(Math.abs(l.x-a.x)):0,g=a.y<l.y?Math.round(Math.abs(l.y-a.y)):0,y=Math.max(d.width,Math.round(a.width)),m=Math.max(d.height,Math.round(a.height)),v=(y-d.width)*h[0],w=(m-d.height)*h[1];(f>0||g>0||v||w)&&(r.push({id:u,type:"position",position:{x:c.position.x-f+v,y:c.position.y-g+w}}),(p=n.get(u))==null||p.forEach(b=>{e.some(S=>S.id===b.id)||r.push({id:b.id,type:"position",position:{x:b.position.x+f,y:b.position.y+g}})})),(d.width<a.width||d.height<a.height||f||g)&&r.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:y+(f?h[0]*f-v:0),height:m+(g?h[1]*g-w:0)}})}),r}function ja(e,t,n,i,r,o,s){const a=i==null?void 0:i.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const u=[],l=window.getComputedStyle(a),{m22:d}=new window.DOMMatrixReadOnly(l.transform),h=[];for(const f of e.values()){const g=t.get(f.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const y=zn(f.nodeElement),m=g.measured.width!==y.width||g.measured.height!==y.height;if(!!(y.width&&y.height&&(m||!g.internals.handleBounds||f.force))){const w=f.nodeElement.getBoundingClientRect(),p=et(g.extent)?g.extent:o;let{positionAbsolute:b}=g.internals;g.parentId&&g.extent==="parent"?b=Ar(b,y,t.get(g.parentId)):p&&(b=He(b,p,y));const S={...g,measured:y,internals:{...g.internals,positionAbsolute:b,handleBounds:{source:hi("source",f.nodeElement,w,d,g.id),target:hi("target",f.nodeElement,w,d,g.id)}}};t.set(g.id,S),g.parentId&&Hn(S,t,n,{nodeOrigin:r,zIndexMode:s}),c=!0,m&&(u.push({id:g.id,type:"dimensions",dimensions:y}),g.expandParent&&g.parentId&&h.push({id:g.id,parentId:g.parentId,rect:Je(S,r)}))}}if(h.length>0){const f=jn(h,t,n,r);u.push(...f)}return{changes:u,updatedInternals:c}}async function Va({delta:e,panZoom:t,transform:n,translateExtent:i,width:r,height:o}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,o]],i),a=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(a)}function wi(e,t,n,i,r,o){let s=r;const a=i.get(s)||new Map;i.set(s,a.set(n,t)),s=`${r}-${e}`;const c=i.get(s)||new Map;if(i.set(s,c.set(n,t)),o){s=`${r}-${e}-${o}`;const u=i.get(s)||new Map;i.set(s,u.set(n,t))}}function Or(e,t,n){e.clear(),t.clear();for(const i of n){const{source:r,target:o,sourceHandle:s=null,targetHandle:a=null}=i,c={edgeId:i.id,source:r,target:o,sourceHandle:s,targetHandle:a},u=`${r}-${s}--${o}-${a}`,l=`${o}-${a}--${r}-${s}`;wi("source",c,l,e,r,s),wi("target",c,u,e,o,a),t.set(i.id,i)}}function Ur(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ur(n,t):!1}function bi(e,t,n){var r;let i=e;do{if((r=i==null?void 0:i.matches)!=null&&r.call(i,t))return!0;if(i===n)return!1;i=i==null?void 0:i.parentElement}while(i);return!1}function Wa(e,t,n,i){const r=new Map;for(const[o,s]of e)if((s.selected||s.id===i)&&(!s.parentId||!Ur(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(o);a&&r.set(o,{id:o,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function cn({nodeId:e,dragItems:t,nodeLookup:n,dragging:i=!0}){var s,a,c;const r=[];for(const[u,l]of t){const d=(s=n.get(u))==null?void 0:s.internals.userNode;d&&r.push({...d,position:l.position,dragging:i})}if(!e)return[r[0],r];const o=(a=n.get(e))==null?void 0:a.internals.userNode;return[o?{...o,position:((c=t.get(e))==null?void 0:c.position)||o.position,dragging:i}:r[0],r]}function Ya({dragItems:e,snapGrid:t,x:n,y:i}){const r=e.values().next().value;if(!r)return null;const o={x:n-r.distance.x,y:i-r.distance.y},s=Nt(o,t);return{x:s.x-o.x,y:s.y-o.y}}function Xa({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:i,onDragStop:r}){let o={x:null,y:null},s=0,a=new Map,c=!1,u={x:0,y:0},l=null,d=!1,h=null,f=!1,g=!1,y=null;function m({noDragClassName:w,handleSelector:p,domNode:b,isSelectable:S,nodeId:x,nodeClickDistance:C=0}){h=Wt(b);function k({x:_,y:I}){const{nodeLookup:M,nodeExtent:P,snapGrid:B,snapToGrid:$,nodeOrigin:R,onNodeDrag:T,onSelectionDrag:U,onError:z,updateNodePositions:F}=t();o={x:_,y:I};let V=!1;const q=a.size>1,J=q&&P?Cn(_t(a)):null,te=q&&$?Ya({dragItems:a,snapGrid:B,x:_,y:I}):null;for(const[ne,j]of a){if(!M.has(ne))continue;let Q={x:_-j.distance.x,y:I-j.distance.y};$&&(Q=te?{x:Math.round(Q.x+te.x),y:Math.round(Q.y+te.y)}:Nt(Q,B));let ie=null;if(q&&P&&!j.extent&&J){const{positionAbsolute:Z}=j.internals,se=Z.x-J.x+P[0][0],ce=Z.x+j.measured.width-J.x2+P[1][0],oe=Z.y-J.y+P[0][1],ge=Z.y+j.measured.height-J.y2+P[1][1];ie=[[se,oe],[ce,ge]]}const{position:ee,positionAbsolute:K}=Nr({nodeId:ne,nextPosition:Q,nodeLookup:M,nodeExtent:ie||P,nodeOrigin:R,onError:z});V=V||j.position.x!==ee.x||j.position.y!==ee.y,j.position=ee,j.internals.positionAbsolute=K}if(g=g||V,!!V&&(F(a,!0),y&&(i||T||!x&&U))){const[ne,j]=cn({nodeId:x,dragItems:a,nodeLookup:M});i==null||i(y,a,ne,j),T==null||T(y,ne,j),x||U==null||U(y,j)}}async function N(){if(!l)return;const{transform:_,panBy:I,autoPanSpeed:M,autoPanOnNodeDrag:P}=t();if(!P){c=!1,cancelAnimationFrame(s);return}const[B,$]=Tr(u,l,M);(B!==0||$!==0)&&(o.x=(o.x??0)-B/_[2],o.y=(o.y??0)-$/_[2],await I({x:B,y:$})&&k(o)),s=requestAnimationFrame(N)}function G(_){var q;const{nodeLookup:I,multiSelectionActive:M,nodesDraggable:P,transform:B,snapGrid:$,snapToGrid:R,selectNodesOnDrag:T,onNodeDragStart:U,onSelectionDragStart:z,unselectNodesAndEdges:F}=t();d=!0,(!T||!S)&&!M&&x&&((q=I.get(x))!=null&&q.selected||F()),S&&T&&x&&(e==null||e(x));const V=yt(_.sourceEvent,{transform:B,snapGrid:$,snapToGrid:R,containerBounds:l});if(o=V,a=Wa(I,P,V,x),a.size>0&&(n||U||!x&&z)){const[J,te]=cn({nodeId:x,dragItems:a,nodeLookup:I});n==null||n(_.sourceEvent,a,J,te),U==null||U(_.sourceEvent,J,te),x||z==null||z(_.sourceEvent,te)}}const E=vr().clickDistance(C).on("start",_=>{const{domNode:I,nodeDragThreshold:M,transform:P,snapGrid:B,snapToGrid:$}=t();l=(I==null?void 0:I.getBoundingClientRect())||null,f=!1,g=!1,y=_.sourceEvent,M===0&&G(_),o=yt(_.sourceEvent,{transform:P,snapGrid:B,snapToGrid:$,containerBounds:l}),u=_e(_.sourceEvent,l)}).on("drag",_=>{const{autoPanOnNodeDrag:I,transform:M,snapGrid:P,snapToGrid:B,nodeDragThreshold:$,nodeLookup:R}=t(),T=yt(_.sourceEvent,{transform:M,snapGrid:P,snapToGrid:B,containerBounds:l});if(y=_.sourceEvent,(_.sourceEvent.type==="touchmove"&&_.sourceEvent.touches.length>1||x&&!R.has(x))&&(f=!0),!f){if(!c&&I&&d&&(c=!0,N()),!d){const U=_e(_.sourceEvent,l),z=U.x-u.x,F=U.y-u.y;Math.sqrt(z*z+F*F)>$&&G(_)}(o.x!==T.xSnapped||o.y!==T.ySnapped)&&a&&d&&(u=_e(_.sourceEvent,l),k(T))}}).on("end",_=>{if(!(!d||f)&&(c=!1,d=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:I,updateNodePositions:M,onNodeDragStop:P,onSelectionDragStop:B}=t();if(g&&(M(a,!1),g=!1),r||P||!x&&B){const[$,R]=cn({nodeId:x,dragItems:a,nodeLookup:I,dragging:!1});r==null||r(_.sourceEvent,a,$,R),P==null||P(_.sourceEvent,$,R),x||B==null||B(_.sourceEvent,R)}}}).filter(_=>{const I=_.target;return!_.button&&(!w||!bi(I,`.${w}`,b))&&(!p||bi(I,p,b))});h.call(E)}function v(){h==null||h.on(".drag",null)}return{update:m,destroy:v}}function Za(e,t,n){const i=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const o of t.values())xt(r,Je(o))>0&&i.push(o);return i}const Ka=250;function qa(e,t,n,i){var a,c;let r=[],o=1/0;const s=Za(e,n,t+Ka);for(const u of s){const l=[...((a=u.internals.handleBounds)==null?void 0:a.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const d of l){if(i.nodeId===d.nodeId&&i.type===d.type&&i.id===d.id)continue;const{x:h,y:f}=je(u,d,d.position,!0),g=Math.sqrt(Math.pow(h-e.x,2)+Math.pow(f-e.y,2));g>t||(g<o?(r=[{...d,x:h,y:f}],o=g):g===o&&r.push({...d,x:h,y:f}))}}if(!r.length)return null;if(r.length>1){const u=i.type==="source"?"target":"source";return r.find(l=>l.type===u)??r[0]}return r[0]}function Hr(e,t,n,i,r,o=!1){var u,l,d;const s=i.get(e);if(!s)return null;const a=r==="strict"?(u=s.internals.handleBounds)==null?void 0:u[t]:[...((l=s.internals.handleBounds)==null?void 0:l.source)??[],...((d=s.internals.handleBounds)==null?void 0:d.target)??[]],c=(n?a==null?void 0:a.find(h=>h.id===n):a==null?void 0:a[0])??null;return c&&o?{...c,...je(s,c,c.position,!0)}:c}function jr(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Qa(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Vr=()=>!0;function Ja(e,{connectionMode:t,connectionRadius:n,handleId:i,nodeId:r,edgeUpdaterType:o,isTarget:s,domNode:a,nodeLookup:c,lib:u,autoPanOnConnect:l,flowId:d,panBy:h,cancelConnection:f,onConnectStart:g,onConnect:y,onConnectEnd:m,isValidConnection:v=Vr,onReconnectEnd:w,updateConnection:p,getTransform:b,getFromHandle:S,autoPanSpeed:x,dragThreshold:C=1,handleDomNode:k}){const N=Lr(e.target);let G=0,E;const{x:_,y:I}=_e(e),M=jr(o,k),P=a==null?void 0:a.getBoundingClientRect();let B=!1;if(!P||!M)return;const $=Hr(r,M,i,c,t);if(!$)return;let R=_e(e,P),T=!1,U=null,z=!1,F=null;function V(){if(!l||!P)return;const[ee,K]=Tr(R,P,x);h({x:ee,y:K}),G=requestAnimationFrame(V)}const q={...$,nodeId:r,type:M,position:$.position},J=c.get(r);let ne={inProgress:!0,isValid:null,from:je(J,q,Y.Left,!0),fromHandle:q,fromPosition:q.position,fromNode:J,to:R,toHandle:null,toPosition:ci[q.position],toNode:null,pointer:R};function j(){B=!0,p(ne),g==null||g(e,{nodeId:r,handleId:i,handleType:M})}C===0&&j();function Q(ee){if(!B){const{x:ge,y:Me}=_e(ee),Ae=ge-_,ze=Me-I;if(!(Ae*Ae+ze*ze>C*C))return;j()}if(!S()||!q){ie(ee);return}const K=b();R=_e(ee,P),E=qa(At(R,K,!1,[1,1]),n,c,q),T||(V(),T=!0);const Z=Wr(ee,{handle:E,connectionMode:t,fromNodeId:r,fromHandleId:i,fromType:s?"target":"source",isValidConnection:v,doc:N,lib:u,flowId:d,nodeLookup:c});F=Z.handleDomNode,U=Z.connection,z=Qa(!!E,Z.isValid);const se=c.get(r),ce=se?je(se,q,Y.Left,!0):ne.from,oe={...ne,from:ce,isValid:z,to:Z.toHandle&&z?Ht({x:Z.toHandle.x,y:Z.toHandle.y},K):R,toHandle:Z.toHandle,toPosition:z&&Z.toHandle?Z.toHandle.position:ci[q.position],toNode:Z.toHandle?c.get(Z.toHandle.nodeId):null,pointer:R};p(oe),ne=oe}function ie(ee){if(!("touches"in ee&&ee.touches.length>0)){if(B){(E||F)&&U&&z&&(y==null||y(U));const{inProgress:K,...Z}=ne,se={...Z,toPosition:ne.toHandle?ne.toPosition:null};m==null||m(ee,se),o&&(w==null||w(ee,se))}f(),cancelAnimationFrame(G),T=!1,z=!1,U=null,F=null,N.removeEventListener("mousemove",Q),N.removeEventListener("mouseup",ie),N.removeEventListener("touchmove",Q),N.removeEventListener("touchend",ie)}}N.addEventListener("mousemove",Q),N.addEventListener("mouseup",ie),N.addEventListener("touchmove",Q),N.addEventListener("touchend",ie)}function Wr(e,{handle:t,connectionMode:n,fromNodeId:i,fromHandleId:r,fromType:o,doc:s,lib:a,flowId:c,isValidConnection:u=Vr,nodeLookup:l}){const d=o==="target",h=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:f,y:g}=_e(e),y=s.elementFromPoint(f,g),m=y!=null&&y.classList.contains(`${a}-flow__handle`)?y:h,v={handleDomNode:m,isValid:!1,connection:null,toHandle:null};if(m){const w=jr(void 0,m),p=m.getAttribute("data-nodeid"),b=m.getAttribute("data-handleid"),S=m.classList.contains("connectable"),x=m.classList.contains("connectableend");if(!p||!w)return v;const C={source:d?p:i,sourceHandle:d?b:r,target:d?i:p,targetHandle:d?r:b};v.connection=C;const N=S&&x&&(n===qe.Strict?d&&w==="source"||!d&&w==="target":p!==i||b!==r);v.isValid=N&&u(C),v.toHandle=Hr(p,w,b,l,n,!0)}return v}const Tn={onPointerDown:Ja,isValid:Wr};function ec({domNode:e,panZoom:t,getTransform:n,getViewScale:i}){const r=Wt(e);function o({translateExtent:a,width:c,height:u,zoomStep:l=1,pannable:d=!0,zoomable:h=!0,inversePan:f=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const b=n(),S=p.sourceEvent.ctrlKey&&Et()?10:1,x=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*l,C=b[2]*Math.pow(2,x*S);t.scaleTo(C)};let y=[0,0];const m=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(y=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},v=p=>{const b=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const S=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],x=[S[0]-y[0],S[1]-y[1]];y=S;const C=i()*Math.max(b[2],Math.log(b[2]))*(f?-1:1),k={x:b[0]-x[0]*C,y:b[1]-x[1]*C},N=[[0,0],[c,u]];t.setViewportConstrained({x:k.x,y:k.y,zoom:b[2]},N,a)},w=yr().on("start",m).on("zoom",d?v:null).on("zoom.wheel",h?g:null);r.call(w,{})}function s(){r.on("zoom",null)}return{update:o,destroy:s,pointer:wr}}const Zt=e=>({x:e.x,y:e.y,zoom:e.k}),un=({x:e,y:t,zoom:n})=>la.translate(e,t).scale(n),Xe=(e,t)=>e.target.closest(`.${t}`),Yr=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),tc=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,dn=(e,t=0,n=tc,i=()=>{})=>{const r=typeof t=="number"&&t>0;return r||i(),r?e.transition().duration(t).ease(n).on("end",i):e},Xr=e=>{const t=e.ctrlKey&&Et()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function nc({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:i,panOnScrollMode:r,panOnScrollSpeed:o,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:u}){return l=>{if(Xe(l,t))return l.ctrlKey&&l.preventDefault(),!1;l.preventDefault(),l.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(l.ctrlKey&&s){const m=wr(l),v=Xr(l),w=d*Math.pow(2,v);i.scaleTo(n,w,m,l);return}const h=l.deltaMode===1?20:1;let f=r===Ue.Vertical?0:l.deltaX*h,g=r===Ue.Horizontal?0:l.deltaY*h;!Et()&&l.shiftKey&&r!==Ue.Vertical&&(f=l.deltaY*h,g=0),i.translateBy(n,-(f/d)*o,-(g/d)*o,{internal:!0});const y=Zt(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(l,y),e.panScrollTimeout=setTimeout(()=>{u==null||u(l,y),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a==null||a(l,y))}}function ic({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(i,r){const o=i.type==="wheel",s=!t&&o&&!i.ctrlKey,a=Xe(i,e);if(i.ctrlKey&&o&&a&&i.preventDefault(),s||a)return null;i.preventDefault(),n.call(this,i,r)}}function rc({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return i=>{var o,s,a;if((o=i.sourceEvent)!=null&&o.internal)return;const r=Zt(i.transform);e.mouseButton=((s=i.sourceEvent)==null?void 0:s.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=r,((a=i.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(i.sourceEvent,r))}}function oc({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:i,onPanZoom:r}){return o=>{var s,a;e.usedRightMouseButton=!!(n&&Yr(t,e.mouseButton??0)),(s=o.sourceEvent)!=null&&s.sync||i([o.transform.x,o.transform.y,o.transform.k]),r&&!((a=o.sourceEvent)!=null&&a.internal)&&(r==null||r(o.sourceEvent,Zt(o.transform)))}}function sc({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:i,onPanZoomEnd:r,onPaneContextMenu:o}){return s=>{var a;if(!((a=s.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,o&&Yr(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&o(s.sourceEvent),e.usedRightMouseButton=!1,i(!1),r)){const c=Zt(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r==null||r(s.sourceEvent,c)},n?150:0)}}}function ac({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:i,panOnScroll:r,zoomOnDoubleClick:o,userSelectionActive:s,noWheelClassName:a,noPanClassName:c,lib:u,connectionInProgress:l}){return d=>{var m;const h=e||t,f=n&&d.ctrlKey,g=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(Xe(d,`${u}-flow__node`)||Xe(d,`${u}-flow__edge`)))return!0;if(!i&&!h&&!r&&!o&&!n||s||l&&!g||Xe(d,a)&&g||Xe(d,c)&&(!g||r&&g&&!e)||!n&&d.ctrlKey&&g)return!1;if(!n&&d.type==="touchstart"&&((m=d.touches)==null?void 0:m.length)>1)return d.preventDefault(),!1;if(!h&&!r&&!f&&g||!i&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(i)&&!i.includes(d.button)&&d.type==="mousedown")return!1;const y=Array.isArray(i)&&i.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||g)&&y}}function cc({domNode:e,minZoom:t,maxZoom:n,translateExtent:i,viewport:r,onPanZoom:o,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},l=e.getBoundingClientRect(),d=yr().scaleExtent([t,n]).translateExtent(i),h=Wt(e).call(d);w({x:r.x,y:r.y,zoom:Qe(r.zoom,t,n)},[[0,0],[l.width,l.height]],i);const f=h.on("wheel.zoom"),g=h.on("dblclick.zoom");d.wheelDelta(Xr);function y(E,_){return h?new Promise(I=>{d==null||d.interpolate((_==null?void 0:_.interpolate)==="linear"?an:sn).transform(dn(h,_==null?void 0:_.duration,_==null?void 0:_.ease,()=>I(!0)),E)}):Promise.resolve(!1)}function m({noWheelClassName:E,noPanClassName:_,onPaneContextMenu:I,userSelectionActive:M,panOnScroll:P,panOnDrag:B,panOnScrollMode:$,panOnScrollSpeed:R,preventScrolling:T,zoomOnPinch:U,zoomOnScroll:z,zoomOnDoubleClick:F,zoomActivationKeyPressed:V,lib:q,onTransformChange:J,connectionInProgress:te,paneClickDistance:ne,selectionOnDrag:j}){M&&!u.isZoomingOrPanning&&v();const Q=P&&!V&&!M;d.clickDistance(j?1/0:!Ce(ne)||ne<0?0:ne);const ie=Q?nc({zoomPanValues:u,noWheelClassName:E,d3Selection:h,d3Zoom:d,panOnScrollMode:$,panOnScrollSpeed:R,zoomOnPinch:U,onPanZoomStart:s,onPanZoom:o,onPanZoomEnd:a}):ic({noWheelClassName:E,preventScrolling:T,d3ZoomHandler:f});if(h.on("wheel.zoom",ie,{passive:!1}),!M){const K=rc({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:s});d.on("start",K);const Z=oc({zoomPanValues:u,panOnDrag:B,onPaneContextMenu:!!I,onPanZoom:o,onTransformChange:J});d.on("zoom",Z);const se=sc({zoomPanValues:u,panOnDrag:B,panOnScroll:P,onPaneContextMenu:I,onPanZoomEnd:a,onDraggingChange:c});d.on("end",se)}const ee=ac({zoomActivationKeyPressed:V,panOnDrag:B,zoomOnScroll:z,panOnScroll:P,zoomOnDoubleClick:F,zoomOnPinch:U,userSelectionActive:M,noPanClassName:_,noWheelClassName:E,lib:q,connectionInProgress:te});d.filter(ee),F?h.on("dblclick.zoom",g):h.on("dblclick.zoom",null)}function v(){d.on("zoom",null)}async function w(E,_,I){const M=un(E),P=d==null?void 0:d.constrain()(M,_,I);return P&&await y(P),new Promise(B=>B(P))}async function p(E,_){const I=un(E);return await y(I,_),new Promise(M=>M(I))}function b(E){if(h){const _=un(E),I=h.property("__zoom");(I.k!==E.zoom||I.x!==E.x||I.y!==E.y)&&(d==null||d.transform(h,_,null,{sync:!0}))}}function S(){const E=h?ha(h.node()):{x:0,y:0,k:1};return{x:E.x,y:E.y,zoom:E.k}}function x(E,_){return h?new Promise(I=>{d==null||d.interpolate((_==null?void 0:_.interpolate)==="linear"?an:sn).scaleTo(dn(h,_==null?void 0:_.duration,_==null?void 0:_.ease,()=>I(!0)),E)}):Promise.resolve(!1)}function C(E,_){return h?new Promise(I=>{d==null||d.interpolate((_==null?void 0:_.interpolate)==="linear"?an:sn).scaleBy(dn(h,_==null?void 0:_.duration,_==null?void 0:_.ease,()=>I(!0)),E)}):Promise.resolve(!1)}function k(E){d==null||d.scaleExtent(E)}function N(E){d==null||d.translateExtent(E)}function G(E){const _=!Ce(E)||E<0?0:E;d==null||d.clickDistance(_)}return{update:m,destroy:v,setViewport:p,setViewportConstrained:w,getViewport:S,scaleTo:x,scaleBy:C,setScaleExtent:k,setTranslateExtent:N,syncViewport:b,setClickDistance:G}}var tt;(function(e){e.Line="line",e.Handle="handle"})(tt||(tt={}));function uc({width:e,prevWidth:t,height:n,prevHeight:i,affectsX:r,affectsY:o}){const s=e-t,a=n-i,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(c[0]=c[0]*-1),a&&o&&(c[1]=c[1]*-1),c}function xi(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),i=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:i,affectsY:r}}function Pe(e,t){return Math.max(0,t-e)}function Ie(e,t){return Math.max(0,e-t)}function Lt(e,t,n){return Math.max(0,t-e,e-n)}function Ei(e,t){return e?!t:t}function dc(e,t,n,i,r,o,s,a){let{affectsX:c,affectsY:u}=t;const{isHorizontal:l,isVertical:d}=t,h=l&&d,{xSnapped:f,ySnapped:g}=n,{minWidth:y,maxWidth:m,minHeight:v,maxHeight:w}=i,{x:p,y:b,width:S,height:x,aspectRatio:C}=e;let k=Math.floor(l?f-e.pointerX:0),N=Math.floor(d?g-e.pointerY:0);const G=S+(c?-k:k),E=x+(u?-N:N),_=-o[0]*S,I=-o[1]*x;let M=Lt(G,y,m),P=Lt(E,v,w);if(s){let R=0,T=0;c&&k<0?R=Pe(p+k+_,s[0][0]):!c&&k>0&&(R=Ie(p+G+_,s[1][0])),u&&N<0?T=Pe(b+N+I,s[0][1]):!u&&N>0&&(T=Ie(b+E+I,s[1][1])),M=Math.max(M,R),P=Math.max(P,T)}if(a){let R=0,T=0;c&&k>0?R=Ie(p+k,a[0][0]):!c&&k<0&&(R=Pe(p+G,a[1][0])),u&&N>0?T=Ie(b+N,a[0][1]):!u&&N<0&&(T=Pe(b+E,a[1][1])),M=Math.max(M,R),P=Math.max(P,T)}if(r){if(l){const R=Lt(G/C,v,w)*C;if(M=Math.max(M,R),s){let T=0;!c&&!u||c&&!u&&h?T=Ie(b+I+G/C,s[1][1])*C:T=Pe(b+I+(c?k:-k)/C,s[0][1])*C,M=Math.max(M,T)}if(a){let T=0;!c&&!u||c&&!u&&h?T=Pe(b+G/C,a[1][1])*C:T=Ie(b+(c?k:-k)/C,a[0][1])*C,M=Math.max(M,T)}}if(d){const R=Lt(E*C,y,m)/C;if(P=Math.max(P,R),s){let T=0;!c&&!u||u&&!c&&h?T=Ie(p+E*C+_,s[1][0])/C:T=Pe(p+(u?N:-N)*C+_,s[0][0])/C,P=Math.max(P,T)}if(a){let T=0;!c&&!u||u&&!c&&h?T=Pe(p+E*C,a[1][0])/C:T=Ie(p+(u?N:-N)*C,a[0][0])/C,P=Math.max(P,T)}}}N=N+(N<0?P:-P),k=k+(k<0?M:-M),r&&(h?G>E*C?N=(Ei(c,u)?-k:k)/C:k=(Ei(c,u)?-N:N)*C:l?(N=k/C,u=c):(k=N*C,c=u));const B=c?p+k:p,$=u?b+N:b;return{width:S+(c?-k:k),height:x+(u?-N:N),x:o[0]*k*(c?-1:1)+B,y:o[1]*N*(u?-1:1)+$}}const Zr={width:0,height:0,x:0,y:0},lc={...Zr,pointerX:0,pointerY:0,aspectRatio:1};function hc(e){return[[0,0],[e.measured.width,e.measured.height]]}function fc(e,t,n){const i=t.position.x+e.position.x,r=t.position.y+e.position.y,o=e.measured.width??0,s=e.measured.height??0,a=n[0]*o,c=n[1]*s;return[[i-a,r-c],[i+o-a,r+s-c]]}function gc({domNode:e,nodeId:t,getStoreItems:n,onChange:i,onEnd:r}){const o=Wt(e);let s={controlDirection:xi("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:u,boundaries:l,keepAspectRatio:d,resizeDirection:h,onResizeStart:f,onResize:g,onResizeEnd:y,shouldResize:m}){let v={...Zr},w={...lc};s={boundaries:l,resizeDirection:h,keepAspectRatio:d,controlDirection:xi(u)};let p,b=null,S=[],x,C,k,N=!1;const G=vr().on("start",E=>{const{nodeLookup:_,transform:I,snapGrid:M,snapToGrid:P,nodeOrigin:B,paneDomNode:$}=n();if(p=_.get(t),!p)return;b=($==null?void 0:$.getBoundingClientRect())??null;const{xSnapped:R,ySnapped:T}=yt(E.sourceEvent,{transform:I,snapGrid:M,snapToGrid:P,containerBounds:b});v={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},w={...v,pointerX:R,pointerY:T,aspectRatio:v.width/v.height},x=void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(x=_.get(p.parentId),C=x&&p.extent==="parent"?hc(x):void 0),S=[],k=void 0;for(const[U,z]of _)if(z.parentId===t&&(S.push({id:U,position:{...z.position},extent:z.extent}),z.extent==="parent"||z.expandParent)){const F=fc(z,p,z.origin??B);k?k=[[Math.min(F[0][0],k[0][0]),Math.min(F[0][1],k[0][1])],[Math.max(F[1][0],k[1][0]),Math.max(F[1][1],k[1][1])]]:k=F}f==null||f(E,{...v})}).on("drag",E=>{const{transform:_,snapGrid:I,snapToGrid:M,nodeOrigin:P}=n(),B=yt(E.sourceEvent,{transform:_,snapGrid:I,snapToGrid:M,containerBounds:b}),$=[];if(!p)return;const{x:R,y:T,width:U,height:z}=v,F={},V=p.origin??P,{width:q,height:J,x:te,y:ne}=dc(w,s.controlDirection,B,s.boundaries,s.keepAspectRatio,V,C,k),j=q!==U,Q=J!==z,ie=te!==R&&j,ee=ne!==T&&Q;if(!ie&&!ee&&!j&&!Q)return;if((ie||ee||V[0]===1||V[1]===1)&&(F.x=ie?te:v.x,F.y=ee?ne:v.y,v.x=F.x,v.y=F.y,S.length>0)){const ce=te-R,oe=ne-T;for(const ge of S)ge.position={x:ge.position.x-ce+V[0]*(q-U),y:ge.position.y-oe+V[1]*(J-z)},$.push(ge)}if((j||Q)&&(F.width=j&&(!s.resizeDirection||s.resizeDirection==="horizontal")?q:v.width,F.height=Q&&(!s.resizeDirection||s.resizeDirection==="vertical")?J:v.height,v.width=F.width,v.height=F.height),x&&p.expandParent){const ce=V[0]*(F.width??0);F.x&&F.x<ce&&(v.x=ce,w.x=w.x-(F.x-ce));const oe=V[1]*(F.height??0);F.y&&F.y<oe&&(v.y=oe,w.y=w.y-(F.y-oe))}const K=uc({width:v.width,prevWidth:U,height:v.height,prevHeight:z,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),Z={...v,direction:K};(m==null?void 0:m(E,Z))!==!1&&(N=!0,g==null||g(E,Z),i(F,$))}).on("end",E=>{N&&(y==null||y(E,{...v}),r==null||r({...v}),N=!1)});o.call(G)}function c(){o.on(".drag",null)}return{update:a,destroy:c}}const Kt=D.createContext(null),pc=Kt.Provider,Kr=Ne.error001();function re(e,t){const n=D.useContext(Kt);if(n===null)throw new Error(Kr);return ga(n,e,t)}function de(){const e=D.useContext(Kt);if(e===null)throw new Error(Kr);return D.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Si={display:"none"},mc={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},qr="react-flow__node-desc",Qr="react-flow__edge-desc",yc="react-flow__aria-live",vc=e=>e.ariaLiveMessage,wc=e=>e.ariaLabelConfig;function bc({rfId:e}){const t=re(vc);return A.jsx("div",{id:`${yc}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:mc,children:t})}function xc({rfId:e,disableKeyboardA11y:t}){const n=re(wc);return A.jsxs(A.Fragment,{children:[A.jsx("div",{id:`${qr}-${e}`,style:Si,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),A.jsx("div",{id:`${Qr}-${e}`,style:Si,children:n["edge.a11yDescription.default"]}),!t&&A.jsx(bc,{rfId:e})]})}const qt=D.forwardRef(({position:e="top-left",children:t,className:n,style:i,...r},o)=>{const s=`${e}`.split("-");return A.jsx("div",{className:he(["react-flow__panel",n,...s]),style:i,ref:o,...r,children:t})});qt.displayName="Panel";function Ec({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:A.jsx(qt,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:A.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Sc=e=>{const t=[],n=[];for(const[,i]of e.nodeLookup)i.selected&&t.push(i.internals.userNode);for(const[,i]of e.edgeLookup)i.selected&&n.push(i);return{selectedNodes:t,selectedEdges:n}},Mt=e=>e.id;function Cc(e,t){return ue(e.selectedNodes.map(Mt),t.selectedNodes.map(Mt))&&ue(e.selectedEdges.map(Mt),t.selectedEdges.map(Mt))}function _c({onSelectionChange:e}){const t=de(),{selectedNodes:n,selectedEdges:i}=re(Sc,Cc);return D.useEffect(()=>{const r={nodes:n,edges:i};e==null||e(r),t.getState().onSelectionChangeHandlers.forEach(o=>o(r))},[n,i,e]),null}const Nc=e=>!!e.onSelectionChangeHandlers;function Ac({onSelectionChange:e}){const t=re(Nc);return e||t?A.jsx(_c,{onSelectionChange:e}):null}const kn=typeof window<"u"?D.useLayoutEffect:D.useEffect,Jr=[0,0],Tc={x:0,y:0,zoom:1},kc=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],Ci=[...kc,"rfId"],Rc=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),_i={translateExtent:wt,nodeOrigin:Jr,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Dc(e){const{setNodes:t,setEdges:n,setMinZoom:i,setMaxZoom:r,setTranslateExtent:o,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=re(Rc,ue),u=de();kn(()=>(c(e.defaultNodes,e.defaultEdges),()=>{l.current=_i,a()}),[]);const l=D.useRef(_i);return kn(()=>{for(const d of Ci){const h=e[d],f=l.current[d];h!==f&&(typeof e[d]>"u"||(d==="nodes"?t(h):d==="edges"?n(h):d==="minZoom"?i(h):d==="maxZoom"?r(h):d==="translateExtent"?o(h):d==="nodeExtent"?s(h):d==="ariaLabelConfig"?u.setState({ariaLabelConfig:Na(h)}):d==="fitView"?u.setState({fitViewQueued:h}):d==="fitViewOptions"?u.setState({fitViewOptions:h}):u.setState({[d]:h})))}l.current=e},Ci.map(d=>e[d])),null}function Ni(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Lc(e){var i;const[t,n]=D.useState(e==="system"?null:e);return D.useEffect(()=>{if(e!=="system"){n(e);return}const r=Ni(),o=()=>n(r!=null&&r.matches?"dark":"light");return o(),r==null||r.addEventListener("change",o),()=>{r==null||r.removeEventListener("change",o)}},[e]),t!==null?t:(i=Ni())!=null&&i.matches?"dark":"light"}const Ai=typeof document<"u"?document:null;function St(e=null,t={target:Ai,actInsideInputWithModifier:!0}){const[n,i]=D.useState(!1),r=D.useRef(!1),o=D.useRef(new Set([])),[s,a]=D.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace("+",`
|
|
2
2
|
`).replace(`
|
|
3
3
|
|
|
4
4
|
`,`
|
|
5
5
|
+`).split(`
|
|
6
|
-
`)),l=u.reduce((d,h)=>d.concat(...h),[]);return[u,l]}return[[],[]]},[e]);return D.useEffect(()=>{const c=(t==null?void 0:t.target)??Ti,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const l=f=>{var m,v;if(r.current=f.ctrlKey||f.metaKey||f.shiftKey||f.altKey,(!r.current||r.current&&!u)&&Mr(f))return!1;const y=ki(f.code,a);if(o.current.add(f[y]),Ai(s,o.current,!1)){const w=((v=(m=f.composedPath)==null?void 0:m.call(f))==null?void 0:v[0])||f.target,p=(w==null?void 0:w.nodeName)==="BUTTON"||(w==null?void 0:w.nodeName)==="A";t.preventDefault!==!1&&(r.current||!p)&&f.preventDefault(),i(!0)}},d=f=>{const g=ki(f.code,a);Ai(s,o.current,!0)?(i(!1),o.current.clear()):o.current.delete(f[g]),f.key==="Meta"&&o.current.clear(),r.current=!1},h=()=>{o.current.clear(),i(!1)};return c==null||c.addEventListener("keydown",l),c==null||c.addEventListener("keyup",d),window.addEventListener("blur",h),window.addEventListener("contextmenu",h),()=>{c==null||c.removeEventListener("keydown",l),c==null||c.removeEventListener("keyup",d),window.removeEventListener("blur",h),window.removeEventListener("contextmenu",h)}}},[e,i]),n}function Ai(e,t,n){return e.filter(i=>n||i.length===t.size).some(i=>i.every(r=>t.has(r)))}function ki(e,t){return t.includes(e)?"code":"key"}const Mc=()=>{const e=de();return D.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:i}=e.getState();return i?i.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[i,r,o],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??i,y:t.y??r,zoom:t.zoom??o},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,i]=e.getState().transform;return{x:t,y:n,zoom:i}},setCenter:async(t,n,i)=>e.getState().setCenter(t,n,i),fitBounds:async(t,n)=>{const{width:i,height:r,minZoom:o,maxZoom:s,panZoom:a}=e.getState(),c=$n(t,i,r,o,s,(n==null?void 0:n.padding)??.1);return a?(await a.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:i,snapGrid:r,snapToGrid:o,domNode:s}=e.getState();if(!s)return t;const{x:a,y:c}=s.getBoundingClientRect(),u={x:t.x-a,y:t.y-c},l=n.snapGrid??r,d=n.snapToGrid??o;return Tt(u,i,d,l)},flowToScreenPosition:t=>{const{transform:n,domNode:i}=e.getState();if(!i)return t;const{x:r,y:o}=i.getBoundingClientRect(),s=Ht(t,n);return{x:s.x+r,y:s.y+o}}}),[])};function eo(e,t){const n=[],i=new Map,r=[];for(const o of e)if(o.type==="add"){r.push(o);continue}else if(o.type==="remove"||o.type==="replace")i.set(o.id,[o]);else{const s=i.get(o.id);s?s.push(o):i.set(o.id,[o])}for(const o of t){const s=i.get(o.id);if(!s){n.push(o);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const a={...o};for(const c of s)Pc(c,a);n.push(a)}return r.length&&r.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function Pc(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Ic(e,t){return eo(e,t)}function Gc(e,t){return eo(e,t)}function Oe(e,t){return{id:e,type:"select",selected:t}}function Ze(e,t=new Set,n=!1){const i=[];for(const[r,o]of e){const s=t.has(r);!(o.selected===void 0&&!s)&&o.selected!==s&&(n&&(o.selected=s),i.push(Oe(o.id,s)))}return i}function Ri({items:e=[],lookup:t}){var r;const n=[],i=new Map(e.map(o=>[o.id,o]));for(const[o,s]of e.entries()){const a=t.get(s.id),c=((r=a==null?void 0:a.internals)==null?void 0:r.userNode)??a;c!==void 0&&c!==s&&n.push({id:s.id,item:s,type:"replace"}),c===void 0&&n.push({item:s,type:"add",index:o})}for(const[o]of t)i.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function Di(e){return{id:e.id,type:"remove"}}const Li=e=>ma(e),Fc=e=>_r(e);function to(e){return D.forwardRef(e)}function Mi(e){const[t,n]=D.useState(BigInt(0)),[i]=D.useState(()=>$c(()=>n(r=>r+BigInt(1))));return kn(()=>{const r=i.get();r.length&&(e(r),i.reset())},[t]),i}function $c(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const no=D.createContext(null);function zc({children:e}){const t=de(),n=D.useCallback(a=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:l,onNodesChange:d,nodeLookup:h,fitViewQueued:f,onNodesChangeMiddlewareMap:g}=t.getState();let y=c;for(const v of a)y=typeof v=="function"?v(y):v;let m=Ri({items:y,lookup:h});for(const v of g.values())m=v(m);l&&u(y),m.length>0?d==null||d(m):f&&window.requestAnimationFrame(()=>{const{fitViewQueued:v,nodes:w,setNodes:p}=t.getState();v&&p(w)})},[]),i=Mi(n),r=D.useCallback(a=>{const{edges:c=[],setEdges:u,hasDefaultEdges:l,onEdgesChange:d,edgeLookup:h}=t.getState();let f=c;for(const g of a)f=typeof g=="function"?g(f):g;l?u(f):d&&d(Ri({items:f,lookup:h}))},[]),o=Mi(r),s=D.useMemo(()=>({nodeQueue:i,edgeQueue:o}),[]);return T.jsx(no.Provider,{value:s,children:e})}function Bc(){const e=D.useContext(no);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Oc=e=>!!e.panZoom;function Vn(){const e=Mc(),t=de(),n=Bc(),i=re(Oc),r=D.useMemo(()=>{const o=d=>t.getState().nodeLookup.get(d),s=d=>{n.nodeQueue.push(d)},a=d=>{n.edgeQueue.push(d)},c=d=>{var v,w;const{nodeLookup:h,nodeOrigin:f}=t.getState(),g=Li(d)?d:h.get(d.id),y=g.parentId?Dr(g.position,g.measured,g.parentId,h,f):g.position,m={...g,position:y,width:((v=g.measured)==null?void 0:v.width)??g.width,height:((w=g.measured)==null?void 0:w.height)??g.height};return Je(m)},u=(d,h,f={replace:!1})=>{s(g=>g.map(y=>{if(y.id===d){const m=typeof h=="function"?h(y):h;return f.replace&&Li(m)?m:{...y,...m}}return y}))},l=(d,h,f={replace:!1})=>{a(g=>g.map(y=>{if(y.id===d){const m=typeof h=="function"?h(y):h;return f.replace&&Fc(m)?m:{...y,...m}}return y}))};return{getNodes:()=>t.getState().nodes.map(d=>({...d})),getNode:d=>{var h;return(h=o(d))==null?void 0:h.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:d=[]}=t.getState();return d.map(h=>({...h}))},getEdge:d=>t.getState().edgeLookup.get(d),setNodes:s,setEdges:a,addNodes:d=>{const h=Array.isArray(d)?d:[d];n.nodeQueue.push(f=>[...f,...h])},addEdges:d=>{const h=Array.isArray(d)?d:[d];n.edgeQueue.push(f=>[...f,...h])},toObject:()=>{const{nodes:d=[],edges:h=[],transform:f}=t.getState(),[g,y,m]=f;return{nodes:d.map(v=>({...v})),edges:h.map(v=>({...v})),viewport:{x:g,y,zoom:m}}},deleteElements:async({nodes:d=[],edges:h=[]})=>{const{nodes:f,edges:g,onNodesDelete:y,onEdgesDelete:m,triggerNodeChanges:v,triggerEdgeChanges:w,onDelete:p,onBeforeDelete:b}=t.getState(),{nodes:S,edges:x}=await xa({nodesToRemove:d,edgesToRemove:h,nodes:f,edges:g,onBeforeDelete:b}),C=x.length>0,k=S.length>0;if(C){const N=x.map(Di);m==null||m(x),w(N)}if(k){const N=S.map(Di);y==null||y(S),v(N)}return(k||C)&&(p==null||p({nodes:S,edges:x})),{deletedNodes:S,deletedEdges:x}},getIntersectingNodes:(d,h=!0,f)=>{const g=di(d),y=g?d:c(d),m=f!==void 0;return y?(f||t.getState().nodes).filter(v=>{const w=t.getState().nodeLookup.get(v.id);if(w&&!g&&(v.id===d.id||!w.internals.positionAbsolute))return!1;const p=Je(m?v:w),b=xt(p,y);return h&&b>0||b>=p.width*p.height||b>=y.width*y.height}):[]},isNodeIntersecting:(d,h,f=!0)=>{const y=di(d)?d:c(d);if(!y)return!1;const m=xt(y,h);return f&&m>0||m>=h.width*h.height||m>=y.width*y.height},updateNode:u,updateNodeData:(d,h,f={replace:!1})=>{u(d,g=>{const y=typeof h=="function"?h(g):h;return f.replace?{...g,data:y}:{...g,data:{...g.data,...y}}},f)},updateEdge:l,updateEdgeData:(d,h,f={replace:!1})=>{l(d,g=>{const y=typeof h=="function"?h(g):h;return f.replace?{...g,data:y}:{...g,data:{...g.data,...y}}},f)},getNodesBounds:d=>{const{nodeLookup:h,nodeOrigin:f}=t.getState();return ya(d,{nodeLookup:h,nodeOrigin:f})},getHandleConnections:({type:d,id:h,nodeId:f})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${f}-${d}${h?`-${h}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:d,handleId:h,nodeId:f})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${f}${d?h?`-${d}-${h}`:`-${d}`:""}`))==null?void 0:g.values())??[])},fitView:async d=>{const h=t.getState().fitViewResolver??_a();return t.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:h}),n.nodeQueue.push(f=>[...f]),h.promise}}},[]);return D.useMemo(()=>({...r,...e,viewportInitialized:i}),[i])}const Pi=e=>e.selected,Uc=typeof window<"u"?window:void 0;function Hc({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=de(),{deleteElements:i}=Vn(),r=St(e,{actInsideInputWithModifier:!1}),o=St(t,{target:Uc});D.useEffect(()=>{if(r){const{edges:s,nodes:a}=n.getState();i({nodes:a.filter(Pi),edges:s.filter(Pi)}),n.setState({nodesSelectionActive:!1})}},[r]),D.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function jc(e){const t=de();D.useEffect(()=>{const n=()=>{var r,o,s,a;if(!e.current||!(((o=(r=e.current).checkVisibility)==null?void 0:o.call(r))??!0))return!1;const i=zn(e.current);(i.height===0||i.width===0)&&((a=(s=t.getState()).onError)==null||a.call(s,"004",Ne.error004())),t.setState({width:i.width||500,height:i.height||500})};if(e.current){n(),window.addEventListener("resize",n);const i=new ResizeObserver(()=>n());return i.observe(e.current),()=>{window.removeEventListener("resize",n),i&&e.current&&i.unobserve(e.current)}}},[])}const Qt={position:"absolute",width:"100%",height:"100%",top:0,left:0},Vc=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Wc({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:i=!1,panOnScrollSpeed:r=.5,panOnScrollMode:o=Ue.Free,zoomOnDoubleClick:s=!0,panOnDrag:a=!0,defaultViewport:c,translateExtent:u,minZoom:l,maxZoom:d,zoomActivationKeyCode:h,preventScrolling:f=!0,children:g,noWheelClassName:y,noPanClassName:m,onViewportChange:v,isControlledViewport:w,paneClickDistance:p,selectionOnDrag:b}){const S=de(),x=D.useRef(null),{userSelectionActive:C,lib:k,connectionInProgress:N}=re(Vc,ue),G=St(h),E=D.useRef();jc(x);const _=D.useCallback(I=>{v==null||v({x:I[0],y:I[1],zoom:I[2]}),w||S.setState({transform:I})},[v,w]);return D.useEffect(()=>{if(x.current){E.current=cc({domNode:x.current,minZoom:l,maxZoom:d,translateExtent:u,viewport:c,onDraggingChange:B=>S.setState($=>$.paneDragging===B?$:{paneDragging:B}),onPanZoomStart:(B,$)=>{const{onViewportChangeStart:R,onMoveStart:A}=S.getState();A==null||A(B,$),R==null||R($)},onPanZoom:(B,$)=>{const{onViewportChange:R,onMove:A}=S.getState();A==null||A(B,$),R==null||R($)},onPanZoomEnd:(B,$)=>{const{onViewportChangeEnd:R,onMoveEnd:A}=S.getState();A==null||A(B,$),R==null||R($)}});const{x:I,y:M,zoom:P}=E.current.getViewport();return S.setState({panZoom:E.current,transform:[I,M,P],domNode:x.current.closest(".react-flow")}),()=>{var B;(B=E.current)==null||B.destroy()}}},[]),D.useEffect(()=>{var I;(I=E.current)==null||I.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:i,panOnScrollSpeed:r,panOnScrollMode:o,zoomOnDoubleClick:s,panOnDrag:a,zoomActivationKeyPressed:G,preventScrolling:f,noPanClassName:m,userSelectionActive:C,noWheelClassName:y,lib:k,onTransformChange:_,connectionInProgress:N,selectionOnDrag:b,paneClickDistance:p})},[e,t,n,i,r,o,s,a,G,f,m,C,y,k,_,N,b,p]),T.jsx("div",{className:"react-flow__renderer",ref:x,style:Qt,children:g})}const Yc=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Xc(){const{userSelectionActive:e,userSelectionRect:t}=re(Yc,ue);return e&&t?T.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const ln=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Zc=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function Kc({isSelecting:e,selectionKeyPressed:t,selectionMode:n=bt.Full,panOnDrag:i,paneClickDistance:r,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:a,onPaneClick:c,onPaneContextMenu:u,onPaneScroll:l,onPaneMouseEnter:d,onPaneMouseMove:h,onPaneMouseLeave:f,children:g}){const y=de(),{userSelectionActive:m,elementsSelectable:v,dragging:w,connectionInProgress:p}=re(Zc,ue),b=v&&(e||m),S=D.useRef(null),x=D.useRef(),C=D.useRef(new Set),k=D.useRef(new Set),N=D.useRef(!1),G=R=>{if(N.current||p){N.current=!1;return}c==null||c(R),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},E=R=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){R.preventDefault();return}u==null||u(R)},_=l?R=>l(R):void 0,I=R=>{N.current&&(R.stopPropagation(),N.current=!1)},M=R=>{var J,te;const{domNode:A}=y.getState();if(x.current=A==null?void 0:A.getBoundingClientRect(),!x.current)return;const U=R.target===S.current;if(!U&&!!R.target.closest(".nokey")||!e||!(o&&U||t)||R.button!==0||!R.isPrimary)return;(te=(J=R.target)==null?void 0:J.setPointerCapture)==null||te.call(J,R.pointerId),N.current=!1;const{x:V,y:q}=_e(R.nativeEvent,x.current);y.setState({userSelectionRect:{width:0,height:0,startX:V,startY:q,x:V,y:q}}),U||(R.stopPropagation(),R.preventDefault())},P=R=>{const{userSelectionRect:A,transform:U,nodeLookup:z,edgeLookup:F,connectionLookup:V,triggerNodeChanges:q,triggerEdgeChanges:J,defaultEdgeOptions:te,resetSelectedElements:ne}=y.getState();if(!x.current||!A)return;const{x:j,y:Q}=_e(R.nativeEvent,x.current),{startX:ie,startY:ee}=A;if(!N.current){const oe=t?0:r;if(Math.hypot(j-ie,Q-ee)<=oe)return;ne(),s==null||s(R)}N.current=!0;const K={startX:ie,startY:ee,x:j<ie?j:ie,y:Q<ee?Q:ee,width:Math.abs(j-ie),height:Math.abs(Q-ee)},Z=C.current,se=k.current;C.current=new Set(Fn(z,K,U,n===bt.Partial,!0).map(oe=>oe.id)),k.current=new Set;const ce=(te==null?void 0:te.selectable)??!0;for(const oe of C.current){const ge=V.get(oe);if(ge)for(const{edgeId:Me}of ge.values()){const Te=F.get(Me);Te&&(Te.selectable??ce)&&k.current.add(Me)}}if(!li(Z,C.current)){const oe=Ze(z,C.current,!0);q(oe)}if(!li(se,k.current)){const oe=Ze(F,k.current);J(oe)}y.setState({userSelectionRect:K,userSelectionActive:!0,nodesSelectionActive:!1})},B=R=>{var A,U;R.button===0&&((U=(A=R.target)==null?void 0:A.releasePointerCapture)==null||U.call(A,R.pointerId),!m&&R.target===S.current&&y.getState().userSelectionRect&&(G==null||G(R)),y.setState({userSelectionActive:!1,userSelectionRect:null}),N.current&&(a==null||a(R),y.setState({nodesSelectionActive:C.current.size>0})))},$=i===!0||Array.isArray(i)&&i.includes(0);return T.jsxs("div",{className:he(["react-flow__pane",{draggable:$,dragging:w,selection:e}]),onClick:b?void 0:ln(G,S),onContextMenu:ln(E,S),onWheel:ln(_,S),onPointerEnter:b?void 0:d,onPointerMove:b?P:h,onPointerUp:b?B:void 0,onPointerDownCapture:b?M:void 0,onClickCapture:b?I:void 0,onPointerLeave:f,ref:S,style:Qt,children:[g,T.jsx(Xc,{})]})}function Rn({id:e,store:t,unselect:n=!1,nodeRef:i}){const{addSelectedNodes:r,unselectNodesAndEdges:o,multiSelectionActive:s,nodeLookup:a,onError:c}=t.getState(),u=a.get(e);if(!u){c==null||c("012",Ne.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&s)&&(o({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var l;return(l=i==null?void 0:i.current)==null?void 0:l.blur()})):r([e])}function io({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:i,nodeId:r,isSelectable:o,nodeClickDistance:s}){const a=de(),[c,u]=D.useState(!1),l=D.useRef();return D.useEffect(()=>{l.current=Xa({getStoreItems:()=>a.getState(),onNodeMouseDown:d=>{Rn({id:d,store:a,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),D.useEffect(()=>{if(!(t||!e.current||!l.current))return l.current.update({noDragClassName:n,handleSelector:i,domNode:e.current,isSelectable:o,nodeId:r,nodeClickDistance:s}),()=>{var d;(d=l.current)==null||d.destroy()}},[n,i,t,o,e,r,s]),c}const qc=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function ro(){const e=de();return D.useCallback(n=>{const{nodeExtent:i,snapToGrid:r,snapGrid:o,nodesDraggable:s,onError:a,updateNodePositions:c,nodeLookup:u,nodeOrigin:l}=e.getState(),d=new Map,h=qc(s),f=r?o[0]:5,g=r?o[1]:5,y=n.direction.x*f*n.factor,m=n.direction.y*g*n.factor;for(const[,v]of u){if(!h(v))continue;let w={x:v.internals.positionAbsolute.x+y,y:v.internals.positionAbsolute.y+m};r&&(w=Nt(w,o));const{position:p,positionAbsolute:b}=Nr({nodeId:v.id,nextPosition:w,nodeLookup:u,nodeExtent:i,nodeOrigin:l,onError:a});v.position=p,v.internals.positionAbsolute=b,d.set(v.id,v)}c(d)},[])}const Wn=D.createContext(null),Qc=Wn.Provider;Wn.Consumer;const oo=()=>D.useContext(Wn),Jc=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),eu=(e,t,n)=>i=>{const{connectionClickStartHandle:r,connectionMode:o,connection:s}=i,{fromHandle:a,toHandle:c,isValid:u}=s,l=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n,connectingTo:l,clickConnecting:(r==null?void 0:r.nodeId)===e&&(r==null?void 0:r.id)===t&&(r==null?void 0:r.type)===n,isPossibleEndHandle:o===qe.Strict?(a==null?void 0:a.type)!==n:e!==(a==null?void 0:a.nodeId)||t!==(a==null?void 0:a.id),connectionInProcess:!!a,clickConnectionInProcess:!!r,valid:l&&u}};function tu({type:e="source",position:t=Y.Top,isValidConnection:n,isConnectable:i=!0,isConnectableStart:r=!0,isConnectableEnd:o=!0,id:s,onConnect:a,children:c,className:u,onMouseDown:l,onTouchStart:d,...h},f){var P,B;const g=s||null,y=e==="target",m=de(),v=oo(),{connectOnClick:w,noPanClassName:p,rfId:b}=re(Jc,ue),{connectingFrom:S,connectingTo:x,clickConnecting:C,isPossibleEndHandle:k,connectionInProcess:N,clickConnectionInProcess:G,valid:E}=re(eu(v,g,e),ue);v||(B=(P=m.getState()).onError)==null||B.call(P,"010",Ne.error010());const _=$=>{const{defaultEdgeOptions:R,onConnect:A,hasDefaultEdges:U}=m.getState(),z={...R,...$};if(U){const{edges:F,setEdges:V}=m.getState();V(La(z,F))}A==null||A(z),a==null||a(z)},I=$=>{if(!v)return;const R=Pr($.nativeEvent);if(r&&(R&&$.button===0||!R)){const A=m.getState();An.onPointerDown($.nativeEvent,{handleDomNode:$.currentTarget,autoPanOnConnect:A.autoPanOnConnect,connectionMode:A.connectionMode,connectionRadius:A.connectionRadius,domNode:A.domNode,nodeLookup:A.nodeLookup,lib:A.lib,isTarget:y,handleId:g,nodeId:v,flowId:A.rfId,panBy:A.panBy,cancelConnection:A.cancelConnection,onConnectStart:A.onConnectStart,onConnectEnd:(...U)=>{var z,F;return(F=(z=m.getState()).onConnectEnd)==null?void 0:F.call(z,...U)},updateConnection:A.updateConnection,onConnect:_,isValidConnection:n||((...U)=>{var z,F;return((F=(z=m.getState()).isValidConnection)==null?void 0:F.call(z,...U))??!0}),getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,autoPanSpeed:A.autoPanSpeed,dragThreshold:A.connectionDragThreshold})}R?l==null||l($):d==null||d($)},M=$=>{const{onClickConnectStart:R,onClickConnectEnd:A,connectionClickStartHandle:U,connectionMode:z,isValidConnection:F,lib:V,rfId:q,nodeLookup:J,connection:te}=m.getState();if(!v||!U&&!r)return;if(!U){R==null||R($.nativeEvent,{nodeId:v,handleId:g,handleType:e}),m.setState({connectionClickStartHandle:{nodeId:v,type:e,id:g}});return}const ne=Lr($.target),j=n||F,{connection:Q,isValid:ie}=An.isValid($.nativeEvent,{handle:{nodeId:v,id:g,type:e},connectionMode:z,fromNodeId:U.nodeId,fromHandleId:U.id||null,fromType:U.type,isValidConnection:j,flowId:q,doc:ne,lib:V,nodeLookup:J});ie&&Q&&_(Q);const ee=structuredClone(te);delete ee.inProgress,ee.toPosition=ee.toHandle?ee.toHandle.position:null,A==null||A($,ee),m.setState({connectionClickStartHandle:null})};return T.jsx("div",{"data-handleid":g,"data-nodeid":v,"data-handlepos":t,"data-id":`${b}-${v}-${g}-${e}`,className:he(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",p,u,{source:!y,target:y,connectable:i,connectablestart:r,connectableend:o,clickconnecting:C,connectingfrom:S,connectingto:x,valid:E,connectionindicator:i&&(!N||k)&&(N||G?o:r)}]),onMouseDown:I,onTouchStart:I,onClick:w?M:void 0,ref:f,...h,children:c})}const jt=D.memo(to(tu));function nu({data:e,isConnectable:t,sourcePosition:n=Y.Bottom}){return T.jsxs(T.Fragment,{children:[e==null?void 0:e.label,T.jsx(jt,{type:"source",position:n,isConnectable:t})]})}function iu({data:e,isConnectable:t,targetPosition:n=Y.Top,sourcePosition:i=Y.Bottom}){return T.jsxs(T.Fragment,{children:[T.jsx(jt,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,T.jsx(jt,{type:"source",position:i,isConnectable:t})]})}function ru(){return null}function ou({data:e,isConnectable:t,targetPosition:n=Y.Top}){return T.jsxs(T.Fragment,{children:[T.jsx(jt,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Vt={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Ii={input:nu,default:iu,output:ou,group:ru};function su(e){var t,n,i,r;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((i=e.style)==null?void 0:i.width),height:e.height??((r=e.style)==null?void 0:r.height)}}const au=e=>{const{width:t,height:n,x:i,y:r}=_t(e.nodeLookup,{filter:o=>!!o.selected});return{width:Ce(t)?t:null,height:Ce(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${i}px,${r}px)`}};function cu({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const i=de(),{width:r,height:o,transformString:s,userSelectionActive:a}=re(au,ue),c=ro(),u=D.useRef(null);D.useEffect(()=>{var f;n||(f=u.current)==null||f.focus({preventScroll:!0})},[n]);const l=!a&&r!==null&&o!==null;if(io({nodeRef:u,disabled:!l}),!l)return null;const d=e?f=>{const g=i.getState().nodes.filter(y=>y.selected);e(f,g)}:void 0,h=f=>{Object.prototype.hasOwnProperty.call(Vt,f.key)&&(f.preventDefault(),c({direction:Vt[f.key],factor:f.shiftKey?4:1}))};return T.jsx("div",{className:he(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:T.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:r,height:o}})})}const Gi=typeof window<"u"?window:void 0,uu=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function so({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:o,onPaneScroll:s,paneClickDistance:a,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:l,selectionMode:d,onSelectionStart:h,onSelectionEnd:f,multiSelectionKeyCode:g,panActivationKeyCode:y,zoomActivationKeyCode:m,elementsSelectable:v,zoomOnScroll:w,zoomOnPinch:p,panOnScroll:b,panOnScrollSpeed:S,panOnScrollMode:x,zoomOnDoubleClick:C,panOnDrag:k,defaultViewport:N,translateExtent:G,minZoom:E,maxZoom:_,preventScrolling:I,onSelectionContextMenu:M,noWheelClassName:P,noPanClassName:B,disableKeyboardA11y:$,onViewportChange:R,isControlledViewport:A}){const{nodesSelectionActive:U,userSelectionActive:z}=re(uu,ue),F=St(u,{target:Gi}),V=St(y,{target:Gi}),q=V||k,J=V||b,te=l&&q!==!0,ne=F||z||te;return Hc({deleteKeyCode:c,multiSelectionKeyCode:g}),T.jsx(Wc,{onPaneContextMenu:o,elementsSelectable:v,zoomOnScroll:w,zoomOnPinch:p,panOnScroll:J,panOnScrollSpeed:S,panOnScrollMode:x,zoomOnDoubleClick:C,panOnDrag:!F&&q,defaultViewport:N,translateExtent:G,minZoom:E,maxZoom:_,zoomActivationKeyCode:m,preventScrolling:I,noWheelClassName:P,noPanClassName:B,onViewportChange:R,isControlledViewport:A,paneClickDistance:a,selectionOnDrag:te,children:T.jsxs(Kc,{onSelectionStart:h,onSelectionEnd:f,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:o,onPaneScroll:s,panOnDrag:q,isSelecting:!!ne,selectionMode:d,selectionKeyPressed:F,paneClickDistance:a,selectionOnDrag:te,children:[e,U&&T.jsx(cu,{onSelectionContextMenu:M,noPanClassName:B,disableKeyboardA11y:$})]})})}so.displayName="FlowRenderer";const du=D.memo(so),lu=e=>t=>e?Fn(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function hu(e){return re(D.useCallback(lu(e),[e]),ue)}const fu=e=>e.updateNodeInternals;function gu(){const e=re(fu),[t]=D.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const i=new Map;n.forEach(r=>{const o=r.target.getAttribute("data-id");i.set(o,{id:o,nodeElement:r.target,force:!0})}),e(i)}));return D.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function pu({node:e,nodeType:t,hasDimensions:n,resizeObserver:i}){const r=de(),o=D.useRef(null),s=D.useRef(null),a=D.useRef(e.sourcePosition),c=D.useRef(e.targetPosition),u=D.useRef(t),l=n&&!!e.internals.handleBounds;return D.useEffect(()=>{o.current&&!e.hidden&&(!l||s.current!==o.current)&&(s.current&&(i==null||i.unobserve(s.current)),i==null||i.observe(o.current),s.current=o.current)},[l,e.hidden]),D.useEffect(()=>()=>{s.current&&(i==null||i.unobserve(s.current),s.current=null)},[]),D.useEffect(()=>{if(o.current){const d=u.current!==t,h=a.current!==e.sourcePosition,f=c.current!==e.targetPosition;(d||h||f)&&(u.current=t,a.current=e.sourcePosition,c.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function mu({id:e,onClick:t,onMouseEnter:n,onMouseMove:i,onMouseLeave:r,onContextMenu:o,onDoubleClick:s,nodesDraggable:a,elementsSelectable:c,nodesConnectable:u,nodesFocusable:l,resizeObserver:d,noDragClassName:h,noPanClassName:f,disableKeyboardA11y:g,rfId:y,nodeTypes:m,nodeClickDistance:v,onError:w}){const{node:p,internals:b,isParent:S}=re(j=>{const Q=j.nodeLookup.get(e),ie=j.parentLookup.has(e);return{node:Q,internals:Q.internals,isParent:ie}},ue);let x=p.type||"default",C=(m==null?void 0:m[x])||Ii[x];C===void 0&&(w==null||w("003",Ne.error003(x)),x="default",C=(m==null?void 0:m.default)||Ii.default);const k=!!(p.draggable||a&&typeof p.draggable>"u"),N=!!(p.selectable||c&&typeof p.selectable>"u"),G=!!(p.connectable||u&&typeof p.connectable>"u"),E=!!(p.focusable||l&&typeof p.focusable>"u"),_=de(),I=Rr(p),M=pu({node:p,nodeType:x,hasDimensions:I,resizeObserver:d}),P=io({nodeRef:M,disabled:p.hidden||!k,noDragClassName:h,handleSelector:p.dragHandle,nodeId:e,isSelectable:N,nodeClickDistance:v}),B=ro();if(p.hidden)return null;const $=De(p),R=su(p),A=N||k||t||n||i||r,U=n?j=>n(j,{...b.userNode}):void 0,z=i?j=>i(j,{...b.userNode}):void 0,F=r?j=>r(j,{...b.userNode}):void 0,V=o?j=>o(j,{...b.userNode}):void 0,q=s?j=>s(j,{...b.userNode}):void 0,J=j=>{const{selectNodesOnDrag:Q,nodeDragThreshold:ie}=_.getState();N&&(!Q||!k||ie>0)&&Rn({id:e,store:_,nodeRef:M}),t&&t(j,{...b.userNode})},te=j=>{if(!(Mr(j.nativeEvent)||g)){if(xr.includes(j.key)&&N){const Q=j.key==="Escape";Rn({id:e,store:_,unselect:Q,nodeRef:M})}else if(k&&p.selected&&Object.prototype.hasOwnProperty.call(Vt,j.key)){j.preventDefault();const{ariaLabelConfig:Q}=_.getState();_.setState({ariaLiveMessage:Q["node.a11yDescription.ariaLiveMessage"]({direction:j.key.replace("Arrow","").toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),B({direction:Vt[j.key],factor:j.shiftKey?4:1})}}},ne=()=>{var se;if(g||!((se=M.current)!=null&&se.matches(":focus-visible")))return;const{transform:j,width:Q,height:ie,autoPanOnNodeFocus:ee,setCenter:K}=_.getState();if(!ee)return;Fn(new Map([[e,p]]),{x:0,y:0,width:Q,height:ie},j,!0).length>0||K(p.position.x+$.width/2,p.position.y+$.height/2,{zoom:j[2]})};return T.jsx("div",{className:he(["react-flow__node",`react-flow__node-${x}`,{[f]:k},p.className,{selected:p.selected,selectable:N,parent:S,draggable:k,dragging:P}]),ref:M,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:A?"all":"none",visibility:I?"visible":"hidden",...p.style,...R},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:U,onMouseMove:z,onMouseLeave:F,onContextMenu:V,onClick:J,onDoubleClick:q,onKeyDown:E?te:void 0,tabIndex:E?0:void 0,onFocus:E?ne:void 0,role:p.ariaRole??(E?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${qr}-${y}`,"aria-label":p.ariaLabel,...p.domAttributes,children:T.jsx(Qc,{value:e,children:T.jsx(C,{id:e,data:p.data,type:x,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:p.selected??!1,selectable:N,draggable:k,deletable:p.deletable??!0,isConnectable:G,sourcePosition:p.sourcePosition,targetPosition:p.targetPosition,dragging:P,dragHandle:p.dragHandle,zIndex:b.z,parentId:p.parentId,...$})})})}var yu=D.memo(mu);const vu=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function ao(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:i,elementsSelectable:r,onError:o}=re(vu,ue),s=hu(e.onlyRenderVisibleElements),a=gu();return T.jsx("div",{className:"react-flow__nodes",style:Qt,children:s.map(c=>T.jsx(yu,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:a,nodesDraggable:t,nodesConnectable:n,nodesFocusable:i,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:o},c))})}ao.displayName="NodeRenderer";const wu=D.memo(ao);function bu(e){return re(D.useCallback(n=>{if(!e)return n.edges.map(r=>r.id);const i=[];if(n.width&&n.height)for(const r of n.edges){const o=n.nodeLookup.get(r.source),s=n.nodeLookup.get(r.target);o&&s&&ka({sourceNode:o,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&i.push(r.id)}return i},[e]),ue)}const xu=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return T.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Eu=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return T.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Fi={[Ot.Arrow]:xu,[Ot.ArrowClosed]:Eu};function Su(e){const t=de();return D.useMemo(()=>{var r,o;return Object.prototype.hasOwnProperty.call(Fi,e)?Fi[e]:((o=(r=t.getState()).onError)==null||o.call(r,"009",Ne.error009(e)),null)},[e])}const Cu=({id:e,type:t,color:n,width:i=12.5,height:r=12.5,markerUnits:o="strokeWidth",strokeWidth:s,orient:a="auto-start-reverse"})=>{const c=Su(t);return c?T.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:a,refX:"0",refY:"0",children:T.jsx(c,{color:n,strokeWidth:s})}):null},co=({defaultColor:e,rfId:t})=>{const n=re(o=>o.edges),i=re(o=>o.defaultEdgeOptions),r=D.useMemo(()=>Fa(n,{id:t,defaultColor:e,defaultMarkerStart:i==null?void 0:i.markerStart,defaultMarkerEnd:i==null?void 0:i.markerEnd}),[n,i,t,e]);return r.length?T.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:T.jsx("defs",{children:r.map(o=>T.jsx(Cu,{id:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient},o.id))})}):null};co.displayName="MarkerDefinitions";var _u=D.memo(co);function uo({x:e,y:t,label:n,labelStyle:i,labelShowBg:r=!0,labelBgStyle:o,labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:c,className:u,...l}){const[d,h]=D.useState({x:1,y:0,width:0,height:0}),f=he(["react-flow__edge-textwrapper",u]),g=D.useRef(null);return D.useEffect(()=>{if(g.current){const y=g.current.getBBox();h({x:y.x,y:y.y,width:y.width,height:y.height})}},[n]),n?T.jsxs("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:f,visibility:d.width?"visible":"hidden",...l,children:[r&&T.jsx("rect",{width:d.width+2*s[0],x:-s[0],y:-s[1],height:d.height+2*s[1],className:"react-flow__edge-textbg",style:o,rx:a,ry:a}),T.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:g,style:i,children:n}),c]}):null}uo.displayName="EdgeText";const Nu=D.memo(uo);function Jt({path:e,labelX:t,labelY:n,label:i,labelStyle:r,labelShowBg:o,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c,interactionWidth:u=20,...l}){return T.jsxs(T.Fragment,{children:[T.jsx("path",{...l,d:e,fill:"none",className:he(["react-flow__edge-path",l.className])}),u?T.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,i&&Ce(t)&&Ce(n)?T.jsx(Nu,{x:t,y:n,label:i,labelStyle:r,labelShowBg:o,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c}):null]})}function $i({pos:e,x1:t,y1:n,x2:i,y2:r}){return e===Y.Left||e===Y.Right?[.5*(t+i),n]:[t,.5*(n+r)]}function lo({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:i,targetY:r,targetPosition:o=Y.Top}){const[s,a]=$i({pos:n,x1:e,y1:t,x2:i,y2:r}),[c,u]=$i({pos:o,x1:i,y1:r,x2:e,y2:t}),[l,d,h,f]=Ir({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:s,sourceControlY:a,targetControlX:c,targetControlY:u});return[`M${e},${t} C${s},${a} ${c},${u} ${i},${r}`,l,d,h,f]}function ho(e){return D.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:o,sourcePosition:s,targetPosition:a,label:c,labelStyle:u,labelShowBg:l,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:y,markerStart:m,interactionWidth:v})=>{const[w,p,b]=lo({sourceX:n,sourceY:i,sourcePosition:s,targetX:r,targetY:o,targetPosition:a}),S=e.isInternal?void 0:t;return T.jsx(Jt,{id:S,path:w,labelX:p,labelY:b,label:c,labelStyle:u,labelShowBg:l,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:y,markerStart:m,interactionWidth:v})})}const Tu=ho({isInternal:!1}),fo=ho({isInternal:!0});Tu.displayName="SimpleBezierEdge";fo.displayName="SimpleBezierEdgeInternal";function go(e){return D.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:o,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:l,labelBgBorderRadius:d,style:h,sourcePosition:f=Y.Bottom,targetPosition:g=Y.Top,markerEnd:y,markerStart:m,pathOptions:v,interactionWidth:w})=>{const[p,b,S]=_n({sourceX:n,sourceY:i,sourcePosition:f,targetX:r,targetY:o,targetPosition:g,borderRadius:v==null?void 0:v.borderRadius,offset:v==null?void 0:v.offset,stepPosition:v==null?void 0:v.stepPosition}),x=e.isInternal?void 0:t;return T.jsx(Jt,{id:x,path:p,labelX:b,labelY:S,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:l,labelBgBorderRadius:d,style:h,markerEnd:y,markerStart:m,interactionWidth:w})})}const po=go({isInternal:!1}),mo=go({isInternal:!0});po.displayName="SmoothStepEdge";mo.displayName="SmoothStepEdgeInternal";function yo(e){return D.memo(({id:t,...n})=>{var r;const i=e.isInternal?void 0:t;return T.jsx(po,{...n,id:i,pathOptions:D.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(r=n.pathOptions)==null?void 0:r.offset])})})}const Au=yo({isInternal:!1}),vo=yo({isInternal:!0});Au.displayName="StepEdge";vo.displayName="StepEdgeInternal";function wo(e){return D.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:o,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:l,labelBgBorderRadius:d,style:h,markerEnd:f,markerStart:g,interactionWidth:y})=>{const[m,v,w]=$r({sourceX:n,sourceY:i,targetX:r,targetY:o}),p=e.isInternal?void 0:t;return T.jsx(Jt,{id:p,path:m,labelX:v,labelY:w,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:l,labelBgBorderRadius:d,style:h,markerEnd:f,markerStart:g,interactionWidth:y})})}const ku=wo({isInternal:!1}),bo=wo({isInternal:!0});ku.displayName="StraightEdge";bo.displayName="StraightEdgeInternal";function xo(e){return D.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:o,sourcePosition:s=Y.Bottom,targetPosition:a=Y.Top,label:c,labelStyle:u,labelShowBg:l,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:y,markerStart:m,pathOptions:v,interactionWidth:w})=>{const[p,b,S]=Gr({sourceX:n,sourceY:i,sourcePosition:s,targetX:r,targetY:o,targetPosition:a,curvature:v==null?void 0:v.curvature}),x=e.isInternal?void 0:t;return T.jsx(Jt,{id:x,path:p,labelX:b,labelY:S,label:c,labelStyle:u,labelShowBg:l,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:y,markerStart:m,interactionWidth:w})})}const Ru=xo({isInternal:!1}),Eo=xo({isInternal:!0});Ru.displayName="BezierEdge";Eo.displayName="BezierEdgeInternal";const zi={default:Eo,straight:bo,step:vo,smoothstep:mo,simplebezier:fo},Bi={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},Du=(e,t,n)=>n===Y.Left?e-t:n===Y.Right?e+t:e,Lu=(e,t,n)=>n===Y.Top?e-t:n===Y.Bottom?e+t:e,Oi="react-flow__edgeupdater";function Ui({position:e,centerX:t,centerY:n,radius:i=10,onMouseDown:r,onMouseEnter:o,onMouseOut:s,type:a}){return T.jsx("circle",{onMouseDown:r,onMouseEnter:o,onMouseOut:s,className:he([Oi,`${Oi}-${a}`]),cx:Du(t,i,e),cy:Lu(n,i,e),r:i,stroke:"transparent",fill:"transparent"})}function Mu({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:i,sourceY:r,targetX:o,targetY:s,sourcePosition:a,targetPosition:c,onReconnect:u,onReconnectStart:l,onReconnectEnd:d,setReconnecting:h,setUpdateHover:f}){const g=de(),y=(b,S)=>{if(b.button!==0)return;const{autoPanOnConnect:x,domNode:C,connectionMode:k,connectionRadius:N,lib:G,onConnectStart:E,cancelConnection:_,nodeLookup:I,rfId:M,panBy:P,updateConnection:B}=g.getState(),$=S.type==="target",R=(z,F)=>{h(!1),d==null||d(z,n,S.type,F)},A=z=>u==null?void 0:u(n,z),U=(z,F)=>{h(!0),l==null||l(b,n,S.type),E==null||E(z,F)};An.onPointerDown(b.nativeEvent,{autoPanOnConnect:x,connectionMode:k,connectionRadius:N,domNode:C,handleId:S.id,nodeId:S.nodeId,nodeLookup:I,isTarget:$,edgeUpdaterType:S.type,lib:G,flowId:M,cancelConnection:_,panBy:P,isValidConnection:(...z)=>{var F,V;return((V=(F=g.getState()).isValidConnection)==null?void 0:V.call(F,...z))??!0},onConnect:A,onConnectStart:U,onConnectEnd:(...z)=>{var F,V;return(V=(F=g.getState()).onConnectEnd)==null?void 0:V.call(F,...z)},onReconnectEnd:R,updateConnection:B,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:b.currentTarget})},m=b=>y(b,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),v=b=>y(b,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),w=()=>f(!0),p=()=>f(!1);return T.jsxs(T.Fragment,{children:[(e===!0||e==="source")&&T.jsx(Ui,{position:a,centerX:i,centerY:r,radius:t,onMouseDown:m,onMouseEnter:w,onMouseOut:p,type:"source"}),(e===!0||e==="target")&&T.jsx(Ui,{position:c,centerX:o,centerY:s,radius:t,onMouseDown:v,onMouseEnter:w,onMouseOut:p,type:"target"})]})}function Pu({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:i,onClick:r,onDoubleClick:o,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:u,reconnectRadius:l,onReconnect:d,onReconnectStart:h,onReconnectEnd:f,rfId:g,edgeTypes:y,noPanClassName:m,onError:v,disableKeyboardA11y:w}){let p=re(K=>K.edgeLookup.get(e));const b=re(K=>K.defaultEdgeOptions);p=b?{...b,...p}:p;let S=p.type||"default",x=(y==null?void 0:y[S])||zi[S];x===void 0&&(v==null||v("011",Ne.error011(S)),S="default",x=(y==null?void 0:y.default)||zi.default);const C=!!(p.focusable||t&&typeof p.focusable>"u"),k=typeof d<"u"&&(p.reconnectable||n&&typeof p.reconnectable>"u"),N=!!(p.selectable||i&&typeof p.selectable>"u"),G=D.useRef(null),[E,_]=D.useState(!1),[I,M]=D.useState(!1),P=de(),{zIndex:B,sourceX:$,sourceY:R,targetX:A,targetY:U,sourcePosition:z,targetPosition:F}=re(D.useCallback(K=>{const Z=K.nodeLookup.get(p.source),se=K.nodeLookup.get(p.target);if(!Z||!se)return{zIndex:p.zIndex,...Bi};const ce=Ga({id:e,sourceNode:Z,targetNode:se,sourceHandle:p.sourceHandle||null,targetHandle:p.targetHandle||null,connectionMode:K.connectionMode,onError:v});return{zIndex:Aa({selected:p.selected,zIndex:p.zIndex,sourceNode:Z,targetNode:se,elevateOnSelect:K.elevateEdgesOnSelect,zIndexMode:K.zIndexMode}),...ce||Bi}},[p.source,p.target,p.sourceHandle,p.targetHandle,p.selected,p.zIndex]),ue),V=D.useMemo(()=>p.markerStart?`url('#${Nn(p.markerStart,g)}')`:void 0,[p.markerStart,g]),q=D.useMemo(()=>p.markerEnd?`url('#${Nn(p.markerEnd,g)}')`:void 0,[p.markerEnd,g]);if(p.hidden||$===null||R===null||A===null||U===null)return null;const J=K=>{var oe;const{addSelectedEdges:Z,unselectNodesAndEdges:se,multiSelectionActive:ce}=P.getState();N&&(P.setState({nodesSelectionActive:!1}),p.selected&&ce?(se({nodes:[],edges:[p]}),(oe=G.current)==null||oe.blur()):Z([e])),r&&r(K,p)},te=o?K=>{o(K,{...p})}:void 0,ne=s?K=>{s(K,{...p})}:void 0,j=a?K=>{a(K,{...p})}:void 0,Q=c?K=>{c(K,{...p})}:void 0,ie=u?K=>{u(K,{...p})}:void 0,ee=K=>{var Z;if(!w&&xr.includes(K.key)&&N){const{unselectNodesAndEdges:se,addSelectedEdges:ce}=P.getState();K.key==="Escape"?((Z=G.current)==null||Z.blur(),se({edges:[p]})):ce([e])}};return T.jsx("svg",{style:{zIndex:B},children:T.jsxs("g",{className:he(["react-flow__edge",`react-flow__edge-${S}`,p.className,m,{selected:p.selected,animated:p.animated,inactive:!N&&!r,updating:E,selectable:N}]),onClick:J,onDoubleClick:te,onContextMenu:ne,onMouseEnter:j,onMouseMove:Q,onMouseLeave:ie,onKeyDown:C?ee:void 0,tabIndex:C?0:void 0,role:p.ariaRole??(C?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":p.ariaLabel===null?void 0:p.ariaLabel||`Edge from ${p.source} to ${p.target}`,"aria-describedby":C?`${Qr}-${g}`:void 0,ref:G,...p.domAttributes,children:[!I&&T.jsx(x,{id:e,source:p.source,target:p.target,type:p.type,selected:p.selected,animated:p.animated,selectable:N,deletable:p.deletable??!0,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,sourceX:$,sourceY:R,targetX:A,targetY:U,sourcePosition:z,targetPosition:F,data:p.data,style:p.style,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerStart:V,markerEnd:q,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth}),k&&T.jsx(Mu,{edge:p,isReconnectable:k,reconnectRadius:l,onReconnect:d,onReconnectStart:h,onReconnectEnd:f,sourceX:$,sourceY:R,targetX:A,targetY:U,sourcePosition:z,targetPosition:F,setUpdateHover:_,setReconnecting:M})]})})}var Iu=D.memo(Pu);const Gu=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function So({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:i,noPanClassName:r,onReconnect:o,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:l,reconnectRadius:d,onEdgeDoubleClick:h,onReconnectStart:f,onReconnectEnd:g,disableKeyboardA11y:y}){const{edgesFocusable:m,edgesReconnectable:v,elementsSelectable:w,onError:p}=re(Gu,ue),b=bu(t);return T.jsxs("div",{className:"react-flow__edges",children:[T.jsx(_u,{defaultColor:e,rfId:n}),b.map(S=>T.jsx(Iu,{id:S,edgesFocusable:m,edgesReconnectable:v,elementsSelectable:w,noPanClassName:r,onReconnect:o,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:u,onClick:l,reconnectRadius:d,onDoubleClick:h,onReconnectStart:f,onReconnectEnd:g,rfId:n,onError:p,edgeTypes:i,disableKeyboardA11y:y},S))]})}So.displayName="EdgeRenderer";const Fu=D.memo(So),$u=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function zu({children:e}){const t=re($u);return T.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function Bu(e){const t=Vn(),n=D.useRef(!1);D.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Ou=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function Uu(e){const t=re(Ou),n=de();return D.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Hu(e){return e.connection.inProgress?{...e.connection,to:Tt(e.connection.to,e.transform)}:{...e.connection}}function ju(e){return Hu}function Vu(e){const t=ju();return re(t,ue)}const Wu=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Yu({containerStyle:e,style:t,type:n,component:i}){const{nodesConnectable:r,width:o,height:s,isValid:a,inProgress:c}=re(Wu,ue);return!(o&&r&&c)?null:T.jsx("svg",{style:e,width:o,height:s,className:"react-flow__connectionline react-flow__container",children:T.jsx("g",{className:he(["react-flow__connection",Cr(a)]),children:T.jsx(Co,{style:t,type:n,CustomComponent:i,isValid:a})})})}const Co=({style:e,type:t=Fe.Bezier,CustomComponent:n,isValid:i})=>{const{inProgress:r,from:o,fromNode:s,fromHandle:a,fromPosition:c,to:u,toNode:l,toHandle:d,toPosition:h,pointer:f}=Vu();if(!r)return;if(n)return T.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:a,fromX:o.x,fromY:o.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:h,connectionStatus:Cr(i),toNode:l,toHandle:d,pointer:f});let g="";const y={sourceX:o.x,sourceY:o.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:h};switch(t){case Fe.Bezier:[g]=Gr(y);break;case Fe.SimpleBezier:[g]=lo(y);break;case Fe.Step:[g]=_n({...y,borderRadius:0});break;case Fe.SmoothStep:[g]=_n(y);break;default:[g]=$r(y)}return T.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};Co.displayName="ConnectionLine";const Xu={};function Hi(e=Xu){D.useRef(e),de(),D.useEffect(()=>{},[e])}function Zu(){de(),D.useRef(!1),D.useEffect(()=>{},[])}function _o({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:i,onEdgeClick:r,onNodeDoubleClick:o,onEdgeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:l,onSelectionContextMenu:d,onSelectionStart:h,onSelectionEnd:f,connectionLineType:g,connectionLineStyle:y,connectionLineComponent:m,connectionLineContainerStyle:v,selectionKeyCode:w,selectionOnDrag:p,selectionMode:b,multiSelectionKeyCode:S,panActivationKeyCode:x,zoomActivationKeyCode:C,deleteKeyCode:k,onlyRenderVisibleElements:N,elementsSelectable:G,defaultViewport:E,translateExtent:_,minZoom:I,maxZoom:M,preventScrolling:P,defaultMarkerColor:B,zoomOnScroll:$,zoomOnPinch:R,panOnScroll:A,panOnScrollSpeed:U,panOnScrollMode:z,zoomOnDoubleClick:F,panOnDrag:V,onPaneClick:q,onPaneMouseEnter:J,onPaneMouseMove:te,onPaneMouseLeave:ne,onPaneScroll:j,onPaneContextMenu:Q,paneClickDistance:ie,nodeClickDistance:ee,onEdgeContextMenu:K,onEdgeMouseEnter:Z,onEdgeMouseMove:se,onEdgeMouseLeave:ce,reconnectRadius:oe,onReconnect:ge,onReconnectStart:Me,onReconnectEnd:Te,noDragClassName:ze,noWheelClassName:at,noPanClassName:ct,disableKeyboardA11y:ut,nodeExtent:nn,rfId:kt,viewport:Ve,onViewportChange:dt}){return Hi(e),Hi(t),Zu(),Bu(n),Uu(Ve),T.jsx(du,{onPaneClick:q,onPaneMouseEnter:J,onPaneMouseMove:te,onPaneMouseLeave:ne,onPaneContextMenu:Q,onPaneScroll:j,paneClickDistance:ie,deleteKeyCode:k,selectionKeyCode:w,selectionOnDrag:p,selectionMode:b,onSelectionStart:h,onSelectionEnd:f,multiSelectionKeyCode:S,panActivationKeyCode:x,zoomActivationKeyCode:C,elementsSelectable:G,zoomOnScroll:$,zoomOnPinch:R,zoomOnDoubleClick:F,panOnScroll:A,panOnScrollSpeed:U,panOnScrollMode:z,panOnDrag:V,defaultViewport:E,translateExtent:_,minZoom:I,maxZoom:M,onSelectionContextMenu:d,preventScrolling:P,noDragClassName:ze,noWheelClassName:at,noPanClassName:ct,disableKeyboardA11y:ut,onViewportChange:dt,isControlledViewport:!!Ve,children:T.jsxs(zu,{children:[T.jsx(Fu,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:s,onReconnect:ge,onReconnectStart:Me,onReconnectEnd:Te,onlyRenderVisibleElements:N,onEdgeContextMenu:K,onEdgeMouseEnter:Z,onEdgeMouseMove:se,onEdgeMouseLeave:ce,reconnectRadius:oe,defaultMarkerColor:B,noPanClassName:ct,disableKeyboardA11y:ut,rfId:kt}),T.jsx(Yu,{style:y,type:g,component:m,containerStyle:v}),T.jsx("div",{className:"react-flow__edgelabel-renderer"}),T.jsx(wu,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:o,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:l,nodeClickDistance:ee,onlyRenderVisibleElements:N,noPanClassName:ct,noDragClassName:ze,disableKeyboardA11y:ut,nodeExtent:nn,rfId:kt}),T.jsx("div",{className:"react-flow__viewport-portal"})]})})}_o.displayName="GraphView";const Ku=D.memo(_o),ji=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:o,fitView:s,fitViewOptions:a,minZoom:c=.5,maxZoom:u=2,nodeOrigin:l,nodeExtent:d,zIndexMode:h="basic"}={})=>{const f=new Map,g=new Map,y=new Map,m=new Map,v=i??t??[],w=n??e??[],p=l??[0,0],b=d??wt;Or(y,m,v);const{nodesInitialized:S}=Tn(w,f,g,{nodeOrigin:p,nodeExtent:b,zIndexMode:h});let x=[0,0,1];if(s&&r&&o){const C=_t(f,{filter:E=>!!((E.width||E.initialWidth)&&(E.height||E.initialHeight))}),{x:k,y:N,zoom:G}=$n(C,r,o,c,u,(a==null?void 0:a.padding)??.1);x=[k,N,G]}return{rfId:"1",width:r??0,height:o??0,transform:x,nodes:w,nodesInitialized:S,nodeLookup:f,parentLookup:g,edges:v,edgeLookup:m,connectionLookup:y,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:i!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:wt,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:qe.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:p,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:a,fitViewResolver:null,connection:{...Sr},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Ea,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Er,zIndexMode:h,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},qu=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:o,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:u,nodeOrigin:l,nodeExtent:d,zIndexMode:h})=>pa((f,g)=>{async function y(){const{nodeLookup:m,panZoom:v,fitViewOptions:w,fitViewResolver:p,width:b,height:S,minZoom:x,maxZoom:C}=g();v&&(await ba({nodes:m,width:b,height:S,panZoom:v,minZoom:x,maxZoom:C},w),p==null||p.resolve(!0),f({fitViewResolver:null}))}return{...ji({nodes:e,edges:t,width:r,height:o,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:u,nodeOrigin:l,nodeExtent:d,defaultNodes:n,defaultEdges:i,zIndexMode:h}),setNodes:m=>{const{nodeLookup:v,parentLookup:w,nodeOrigin:p,elevateNodesOnSelect:b,fitViewQueued:S,zIndexMode:x,nodesSelectionActive:C}=g(),{nodesInitialized:k,hasSelectedNodes:N}=Tn(m,v,w,{nodeOrigin:p,nodeExtent:d,elevateNodesOnSelect:b,checkEquality:!0,zIndexMode:x}),G=C&&N;S&&k?(y(),f({nodes:m,nodesInitialized:k,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:G})):f({nodes:m,nodesInitialized:k,nodesSelectionActive:G})},setEdges:m=>{const{connectionLookup:v,edgeLookup:w}=g();Or(v,w,m),f({edges:m})},setDefaultNodesAndEdges:(m,v)=>{if(m){const{setNodes:w}=g();w(m),f({hasDefaultNodes:!0})}if(v){const{setEdges:w}=g();w(v),f({hasDefaultEdges:!0})}},updateNodeInternals:m=>{const{triggerNodeChanges:v,nodeLookup:w,parentLookup:p,domNode:b,nodeOrigin:S,nodeExtent:x,debug:C,fitViewQueued:k,zIndexMode:N}=g(),{changes:G,updatedInternals:E}=ja(m,w,p,b,S,x,N);E&&(Ba(w,p,{nodeOrigin:S,nodeExtent:x,zIndexMode:N}),k?(y(),f({fitViewQueued:!1,fitViewOptions:void 0})):f({}),(G==null?void 0:G.length)>0&&(C&&console.log("React Flow: trigger node changes",G),v==null||v(G)))},updateNodePositions:(m,v=!1)=>{const w=[];let p=[];const{nodeLookup:b,triggerNodeChanges:S,connection:x,updateConnection:C,onNodesChangeMiddlewareMap:k}=g();for(const[N,G]of m){const E=b.get(N),_=!!(E!=null&&E.expandParent&&(E!=null&&E.parentId)&&(G!=null&&G.position)),I={id:N,type:"position",position:_?{x:Math.max(0,G.position.x),y:Math.max(0,G.position.y)}:G.position,dragging:v};if(E&&x.inProgress&&x.fromNode.id===E.id){const M=je(E,x.fromHandle,Y.Left,!0);C({...x,from:M})}_&&E.parentId&&w.push({id:N,parentId:E.parentId,rect:{...G.internals.positionAbsolute,width:G.measured.width??0,height:G.measured.height??0}}),p.push(I)}if(w.length>0){const{parentLookup:N,nodeOrigin:G}=g(),E=jn(w,b,N,G);p.push(...E)}for(const N of k.values())p=N(p);S(p)},triggerNodeChanges:m=>{const{onNodesChange:v,setNodes:w,nodes:p,hasDefaultNodes:b,debug:S}=g();if(m!=null&&m.length){if(b){const x=Ic(m,p);w(x)}S&&console.log("React Flow: trigger node changes",m),v==null||v(m)}},triggerEdgeChanges:m=>{const{onEdgesChange:v,setEdges:w,edges:p,hasDefaultEdges:b,debug:S}=g();if(m!=null&&m.length){if(b){const x=Gc(m,p);w(x)}S&&console.log("React Flow: trigger edge changes",m),v==null||v(m)}},addSelectedNodes:m=>{const{multiSelectionActive:v,edgeLookup:w,nodeLookup:p,triggerNodeChanges:b,triggerEdgeChanges:S}=g();if(v){const x=m.map(C=>Oe(C,!0));b(x);return}b(Ze(p,new Set([...m]),!0)),S(Ze(w))},addSelectedEdges:m=>{const{multiSelectionActive:v,edgeLookup:w,nodeLookup:p,triggerNodeChanges:b,triggerEdgeChanges:S}=g();if(v){const x=m.map(C=>Oe(C,!0));S(x);return}S(Ze(w,new Set([...m]))),b(Ze(p,new Set,!0))},unselectNodesAndEdges:({nodes:m,edges:v}={})=>{const{edges:w,nodes:p,nodeLookup:b,triggerNodeChanges:S,triggerEdgeChanges:x}=g(),C=m||p,k=v||w,N=[];for(const E of C){if(!E.selected)continue;const _=b.get(E.id);_&&(_.selected=!1),N.push(Oe(E.id,!1))}const G=[];for(const E of k)E.selected&&G.push(Oe(E.id,!1));S(N),x(G)},setMinZoom:m=>{const{panZoom:v,maxZoom:w}=g();v==null||v.setScaleExtent([m,w]),f({minZoom:m})},setMaxZoom:m=>{const{panZoom:v,minZoom:w}=g();v==null||v.setScaleExtent([w,m]),f({maxZoom:m})},setTranslateExtent:m=>{var v;(v=g().panZoom)==null||v.setTranslateExtent(m),f({translateExtent:m})},resetSelectedElements:()=>{const{edges:m,nodes:v,triggerNodeChanges:w,triggerEdgeChanges:p,elementsSelectable:b}=g();if(!b)return;const S=v.reduce((C,k)=>k.selected?[...C,Oe(k.id,!1)]:C,[]),x=m.reduce((C,k)=>k.selected?[...C,Oe(k.id,!1)]:C,[]);w(S),p(x)},setNodeExtent:m=>{const{nodes:v,nodeLookup:w,parentLookup:p,nodeOrigin:b,elevateNodesOnSelect:S,nodeExtent:x,zIndexMode:C}=g();m[0][0]===x[0][0]&&m[0][1]===x[0][1]&&m[1][0]===x[1][0]&&m[1][1]===x[1][1]||(Tn(v,w,p,{nodeOrigin:b,nodeExtent:m,elevateNodesOnSelect:S,checkEquality:!1,zIndexMode:C}),f({nodeExtent:m}))},panBy:m=>{const{transform:v,width:w,height:p,panZoom:b,translateExtent:S}=g();return Va({delta:m,panZoom:b,transform:v,translateExtent:S,width:w,height:p})},setCenter:async(m,v,w)=>{const{width:p,height:b,maxZoom:S,panZoom:x}=g();if(!x)return Promise.resolve(!1);const C=typeof(w==null?void 0:w.zoom)<"u"?w.zoom:S;return await x.setViewport({x:p/2-m*C,y:b/2-v*C,zoom:C},{duration:w==null?void 0:w.duration,ease:w==null?void 0:w.ease,interpolate:w==null?void 0:w.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{f({connection:{...Sr}})},updateConnection:m=>{f({connection:m})},reset:()=>f({...ji()})}},Object.is);function Qu({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:i,initialWidth:r,initialHeight:o,initialMinZoom:s,initialMaxZoom:a,initialFitViewOptions:c,fitView:u,nodeOrigin:l,nodeExtent:d,zIndexMode:h,children:f}){const[g]=D.useState(()=>qu({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:o,fitView:u,minZoom:s,maxZoom:a,fitViewOptions:c,nodeOrigin:l,nodeExtent:d,zIndexMode:h}));return T.jsx(pc,{value:g,children:T.jsx(zc,{children:f})})}function Ju({children:e,nodes:t,edges:n,defaultNodes:i,defaultEdges:r,width:o,height:s,fitView:a,fitViewOptions:c,minZoom:u,maxZoom:l,nodeOrigin:d,nodeExtent:h,zIndexMode:f}){return D.useContext(Kt)?T.jsx(T.Fragment,{children:e}):T.jsx(Qu,{initialNodes:t,initialEdges:n,defaultNodes:i,defaultEdges:r,initialWidth:o,initialHeight:s,fitView:a,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:l,nodeOrigin:d,nodeExtent:h,zIndexMode:f,children:e})}const ed={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function td({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,className:r,nodeTypes:o,edgeTypes:s,onNodeClick:a,onEdgeClick:c,onInit:u,onMove:l,onMoveStart:d,onMoveEnd:h,onConnect:f,onConnectStart:g,onConnectEnd:y,onClickConnectStart:m,onClickConnectEnd:v,onNodeMouseEnter:w,onNodeMouseMove:p,onNodeMouseLeave:b,onNodeContextMenu:S,onNodeDoubleClick:x,onNodeDragStart:C,onNodeDrag:k,onNodeDragStop:N,onNodesDelete:G,onEdgesDelete:E,onDelete:_,onSelectionChange:I,onSelectionDragStart:M,onSelectionDrag:P,onSelectionDragStop:B,onSelectionContextMenu:$,onSelectionStart:R,onSelectionEnd:A,onBeforeDelete:U,connectionMode:z,connectionLineType:F=Fe.Bezier,connectionLineStyle:V,connectionLineComponent:q,connectionLineContainerStyle:J,deleteKeyCode:te="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:j=!1,selectionMode:Q=bt.Full,panActivationKeyCode:ie="Space",multiSelectionKeyCode:ee=Et()?"Meta":"Control",zoomActivationKeyCode:K=Et()?"Meta":"Control",snapToGrid:Z,snapGrid:se,onlyRenderVisibleElements:ce=!1,selectNodesOnDrag:oe,nodesDraggable:ge,autoPanOnNodeFocus:Me,nodesConnectable:Te,nodesFocusable:ze,nodeOrigin:at=Jr,edgesFocusable:ct,edgesReconnectable:ut,elementsSelectable:nn=!0,defaultViewport:kt=Ac,minZoom:Ve=.5,maxZoom:dt=2,translateExtent:ei=wt,preventScrolling:cs=!0,nodeExtent:rn,defaultMarkerColor:us="#b1b1b7",zoomOnScroll:ds=!0,zoomOnPinch:ls=!0,panOnScroll:hs=!1,panOnScrollSpeed:fs=.5,panOnScrollMode:gs=Ue.Free,zoomOnDoubleClick:ps=!0,panOnDrag:ms=!0,onPaneClick:ys,onPaneMouseEnter:vs,onPaneMouseMove:ws,onPaneMouseLeave:bs,onPaneScroll:xs,onPaneContextMenu:Es,paneClickDistance:Ss=1,nodeClickDistance:Cs=0,children:_s,onReconnect:Ns,onReconnectStart:Ts,onReconnectEnd:As,onEdgeContextMenu:ks,onEdgeDoubleClick:Rs,onEdgeMouseEnter:Ds,onEdgeMouseMove:Ls,onEdgeMouseLeave:Ms,reconnectRadius:Ps=10,onNodesChange:Is,onEdgesChange:Gs,noDragClassName:Fs="nodrag",noWheelClassName:$s="nowheel",noPanClassName:ti="nopan",fitView:ni,fitViewOptions:ii,connectOnClick:zs,attributionPosition:Bs,proOptions:Os,defaultEdgeOptions:Us,elevateNodesOnSelect:Hs=!0,elevateEdgesOnSelect:js=!1,disableKeyboardA11y:ri=!1,autoPanOnConnect:Vs,autoPanOnNodeDrag:Ws,autoPanSpeed:Ys,connectionRadius:Xs,isValidConnection:Zs,onError:Ks,style:qs,id:oi,nodeDragThreshold:Qs,connectionDragThreshold:Js,viewport:ea,onViewportChange:ta,width:na,height:ia,colorMode:ra="light",debug:oa,onScroll:Rt,ariaLabelConfig:sa,zIndexMode:si="basic",...aa},ca){const on=oi||"1",ua=Lc(ra),da=D.useCallback(ai=>{ai.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Rt==null||Rt(ai)},[Rt]);return T.jsx("div",{"data-testid":"rf__wrapper",...aa,onScroll:da,style:{...qs,...ed},ref:ca,className:he(["react-flow",r,ua]),id:oi,role:"application",children:T.jsxs(Ju,{nodes:e,edges:t,width:na,height:ia,fitView:ni,fitViewOptions:ii,minZoom:Ve,maxZoom:dt,nodeOrigin:at,nodeExtent:rn,zIndexMode:si,children:[T.jsx(Dc,{nodes:e,edges:t,defaultNodes:n,defaultEdges:i,onConnect:f,onConnectStart:g,onConnectEnd:y,onClickConnectStart:m,onClickConnectEnd:v,nodesDraggable:ge,autoPanOnNodeFocus:Me,nodesConnectable:Te,nodesFocusable:ze,edgesFocusable:ct,edgesReconnectable:ut,elementsSelectable:nn,elevateNodesOnSelect:Hs,elevateEdgesOnSelect:js,minZoom:Ve,maxZoom:dt,nodeExtent:rn,onNodesChange:Is,onEdgesChange:Gs,snapToGrid:Z,snapGrid:se,connectionMode:z,translateExtent:ei,connectOnClick:zs,defaultEdgeOptions:Us,fitView:ni,fitViewOptions:ii,onNodesDelete:G,onEdgesDelete:E,onDelete:_,onNodeDragStart:C,onNodeDrag:k,onNodeDragStop:N,onSelectionDrag:P,onSelectionDragStart:M,onSelectionDragStop:B,onMove:l,onMoveStart:d,onMoveEnd:h,noPanClassName:ti,nodeOrigin:at,rfId:on,autoPanOnConnect:Vs,autoPanOnNodeDrag:Ws,autoPanSpeed:Ys,onError:Ks,connectionRadius:Xs,isValidConnection:Zs,selectNodesOnDrag:oe,nodeDragThreshold:Qs,connectionDragThreshold:Js,onBeforeDelete:U,debug:oa,ariaLabelConfig:sa,zIndexMode:si}),T.jsx(Ku,{onInit:u,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:w,onNodeMouseMove:p,onNodeMouseLeave:b,onNodeContextMenu:S,onNodeDoubleClick:x,nodeTypes:o,edgeTypes:s,connectionLineType:F,connectionLineStyle:V,connectionLineComponent:q,connectionLineContainerStyle:J,selectionKeyCode:ne,selectionOnDrag:j,selectionMode:Q,deleteKeyCode:te,multiSelectionKeyCode:ee,panActivationKeyCode:ie,zoomActivationKeyCode:K,onlyRenderVisibleElements:ce,defaultViewport:kt,translateExtent:ei,minZoom:Ve,maxZoom:dt,preventScrolling:cs,zoomOnScroll:ds,zoomOnPinch:ls,zoomOnDoubleClick:ps,panOnScroll:hs,panOnScrollSpeed:fs,panOnScrollMode:gs,panOnDrag:ms,onPaneClick:ys,onPaneMouseEnter:vs,onPaneMouseMove:ws,onPaneMouseLeave:bs,onPaneScroll:xs,onPaneContextMenu:Es,paneClickDistance:Ss,nodeClickDistance:Cs,onSelectionContextMenu:$,onSelectionStart:R,onSelectionEnd:A,onReconnect:Ns,onReconnectStart:Ts,onReconnectEnd:As,onEdgeContextMenu:ks,onEdgeDoubleClick:Rs,onEdgeMouseEnter:Ds,onEdgeMouseMove:Ls,onEdgeMouseLeave:Ms,reconnectRadius:Ps,defaultMarkerColor:us,noDragClassName:Fs,noWheelClassName:$s,noPanClassName:ti,rfId:on,disableKeyboardA11y:ri,nodeExtent:rn,viewport:ea,onViewportChange:ta}),T.jsx(Tc,{onSelectionChange:I}),_s,T.jsx(Ec,{proOptions:Os,position:Bs}),T.jsx(xc,{rfId:on,disableKeyboardA11y:ri})]})})}var of=to(td);function nd({dimensions:e,lineWidth:t,variant:n,className:i}){return T.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:he(["react-flow__background-pattern",n,i])})}function id({radius:e,className:t}){return T.jsx("circle",{cx:e,cy:e,r:e,className:he(["react-flow__background-pattern","dots",t])})}var $e;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})($e||($e={}));const rd={[$e.Dots]:1,[$e.Lines]:1,[$e.Cross]:6},od=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function No({id:e,variant:t=$e.Dots,gap:n=20,size:i,lineWidth:r=1,offset:o=0,color:s,bgColor:a,style:c,className:u,patternClassName:l}){const d=D.useRef(null),{transform:h,patternId:f}=re(od,ue),g=i||rd[t],y=t===$e.Dots,m=t===$e.Cross,v=Array.isArray(n)?n:[n,n],w=[v[0]*h[2]||1,v[1]*h[2]||1],p=g*h[2],b=Array.isArray(o)?o:[o,o],S=m?[p,p]:w,x=[b[0]*h[2]||1+S[0]/2,b[1]*h[2]||1+S[1]/2],C=`${f}${e||""}`;return T.jsxs("svg",{className:he(["react-flow__background",u]),style:{...c,...Qt,"--xy-background-color-props":a,"--xy-background-pattern-color-props":s},ref:d,"data-testid":"rf__background",children:[T.jsx("pattern",{id:C,x:h[0]%w[0],y:h[1]%w[1],width:w[0],height:w[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${x[0]},-${x[1]})`,children:y?T.jsx(id,{radius:p/2,className:l}):T.jsx(nd,{dimensions:S,lineWidth:r,variant:t,className:l})}),T.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${C})`})]})}No.displayName="Background";const sf=D.memo(No);function sd(){return T.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:T.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ad(){return T.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:T.jsx("path",{d:"M0 0h32v4.2H0z"})})}function cd(){return T.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:T.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function ud(){return T.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:T.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function dd(){return T.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:T.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Pt({children:e,className:t,...n}){return T.jsx("button",{type:"button",className:he(["react-flow__controls-button",t]),...n,children:e})}const ld=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function To({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:i=!0,fitViewOptions:r,onZoomIn:o,onZoomOut:s,onFitView:a,onInteractiveChange:c,className:u,children:l,position:d="bottom-left",orientation:h="vertical","aria-label":f}){const g=de(),{isInteractive:y,minZoomReached:m,maxZoomReached:v,ariaLabelConfig:w}=re(ld,ue),{zoomIn:p,zoomOut:b,fitView:S}=Vn(),x=()=>{p(),o==null||o()},C=()=>{b(),s==null||s()},k=()=>{S(r),a==null||a()},N=()=>{g.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),c==null||c(!y)},G=h==="horizontal"?"horizontal":"vertical";return T.jsxs(qt,{className:he(["react-flow__controls",G,u]),position:d,style:e,"data-testid":"rf__controls","aria-label":f??w["controls.ariaLabel"],children:[t&&T.jsxs(T.Fragment,{children:[T.jsx(Pt,{onClick:x,className:"react-flow__controls-zoomin",title:w["controls.zoomIn.ariaLabel"],"aria-label":w["controls.zoomIn.ariaLabel"],disabled:v,children:T.jsx(sd,{})}),T.jsx(Pt,{onClick:C,className:"react-flow__controls-zoomout",title:w["controls.zoomOut.ariaLabel"],"aria-label":w["controls.zoomOut.ariaLabel"],disabled:m,children:T.jsx(ad,{})})]}),n&&T.jsx(Pt,{className:"react-flow__controls-fitview",onClick:k,title:w["controls.fitView.ariaLabel"],"aria-label":w["controls.fitView.ariaLabel"],children:T.jsx(cd,{})}),i&&T.jsx(Pt,{className:"react-flow__controls-interactive",onClick:N,title:w["controls.interactive.ariaLabel"],"aria-label":w["controls.interactive.ariaLabel"],children:y?T.jsx(dd,{}):T.jsx(ud,{})}),l]})}To.displayName="Controls";const af=D.memo(To);function hd({id:e,x:t,y:n,width:i,height:r,style:o,color:s,strokeColor:a,strokeWidth:c,className:u,borderRadius:l,shapeRendering:d,selected:h,onClick:f}){const{background:g,backgroundColor:y}=o||{},m=s||g||y;return T.jsx("rect",{className:he(["react-flow__minimap-node",{selected:h},u]),x:t,y:n,rx:l,ry:l,width:i,height:r,style:{fill:m,stroke:a,strokeWidth:c},shapeRendering:d,onClick:f?v=>f(v,e):void 0})}const fd=D.memo(hd),gd=e=>e.nodes.map(t=>t.id),hn=e=>e instanceof Function?e:()=>e;function pd({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:i=5,nodeStrokeWidth:r,nodeComponent:o=fd,onClick:s}){const a=re(gd,ue),c=hn(t),u=hn(e),l=hn(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return T.jsx(T.Fragment,{children:a.map(h=>T.jsx(yd,{id:h,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:l,nodeBorderRadius:i,nodeStrokeWidth:r,NodeComponent:o,onClick:s,shapeRendering:d},h))})}function md({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:i,nodeBorderRadius:r,nodeStrokeWidth:o,shapeRendering:s,NodeComponent:a,onClick:c}){const{node:u,x:l,y:d,width:h,height:f}=re(g=>{const y=g.nodeLookup.get(e);if(!y)return{node:void 0,x:0,y:0,width:0,height:0};const m=y.internals.userNode,{x:v,y:w}=y.internals.positionAbsolute,{width:p,height:b}=De(m);return{node:m,x:v,y:w,width:p,height:b}},ue);return!u||u.hidden||!Rr(u)?null:T.jsx(a,{x:l,y:d,width:h,height:f,style:u.style,selected:!!u.selected,className:i(u),color:t(u),borderRadius:r,strokeColor:n(u),strokeWidth:o,shapeRendering:s,onClick:c,id:u.id})}const yd=D.memo(md);var vd=D.memo(pd);const wd=200,bd=150,xd=e=>!e.hidden,Ed=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?kr(_t(e.nodeLookup,{filter:xd}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Sd="react-flow__minimap-desc";function Ao({style:e,className:t,nodeStrokeColor:n,nodeColor:i,nodeClassName:r="",nodeBorderRadius:o=5,nodeStrokeWidth:s,nodeComponent:a,bgColor:c,maskColor:u,maskStrokeColor:l,maskStrokeWidth:d,position:h="bottom-right",onClick:f,onNodeClick:g,pannable:y=!1,zoomable:m=!1,ariaLabel:v,inversePan:w,zoomStep:p=1,offsetScale:b=5}){const S=de(),x=D.useRef(null),{boundingRect:C,viewBB:k,rfId:N,panZoom:G,translateExtent:E,flowWidth:_,flowHeight:I,ariaLabelConfig:M}=re(Ed,ue),P=(e==null?void 0:e.width)??wd,B=(e==null?void 0:e.height)??bd,$=C.width/P,R=C.height/B,A=Math.max($,R),U=A*P,z=A*B,F=b*A,V=C.x-(U-C.width)/2-F,q=C.y-(z-C.height)/2-F,J=U+F*2,te=z+F*2,ne=`${Sd}-${N}`,j=D.useRef(0),Q=D.useRef();j.current=A,D.useEffect(()=>{if(x.current&&G)return Q.current=ec({domNode:x.current,panZoom:G,getTransform:()=>S.getState().transform,getViewScale:()=>j.current}),()=>{var Z;(Z=Q.current)==null||Z.destroy()}},[G]),D.useEffect(()=>{var Z;(Z=Q.current)==null||Z.update({translateExtent:E,width:_,height:I,inversePan:w,pannable:y,zoomStep:p,zoomable:m})},[y,m,w,p,E,_,I]);const ie=f?Z=>{var oe;const[se,ce]=((oe=Q.current)==null?void 0:oe.pointer(Z))||[0,0];f(Z,{x:se,y:ce})}:void 0,ee=g?D.useCallback((Z,se)=>{const ce=S.getState().nodeLookup.get(se).internals.userNode;g(Z,ce)},[]):void 0,K=v??M["minimap.ariaLabel"];return T.jsx(qt,{position:h,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*A:void 0,"--xy-minimap-node-background-color-props":typeof i=="string"?i:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:he(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:T.jsxs("svg",{width:P,height:B,viewBox:`${V} ${q} ${J} ${te}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ne,ref:x,onClick:ie,children:[K&&T.jsx("title",{id:ne,children:K}),T.jsx(vd,{onClick:ee,nodeColor:i,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:r,nodeStrokeWidth:s,nodeComponent:a}),T.jsx("path",{className:"react-flow__minimap-mask",d:`M${V-F},${q-F}h${J+F*2}v${te+F*2}h${-J-F*2}z
|
|
7
|
-
M${k.x},${k.y}h${k.width}v${k.height}h${-k.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Ao.displayName="MiniMap";D.memo(Ao);const Cd=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,_d={[tt.Line]:"right",[tt.Handle]:"bottom-right"};function Nd({nodeId:e,position:t,variant:n=tt.Handle,className:i,style:r=void 0,children:o,color:s,minWidth:a=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:l=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:h,autoScale:f=!0,shouldResize:g,onResizeStart:y,onResize:m,onResizeEnd:v}){const w=oo(),p=typeof e=="string"?e:w,b=de(),S=D.useRef(null),x=n===tt.Handle,C=re(D.useCallback(Cd(x&&f),[x,f]),ue),k=D.useRef(null),N=t??_d[n];D.useEffect(()=>{if(!(!S.current||!p))return k.current||(k.current=gc({domNode:S.current,nodeId:p,getStoreItems:()=>{const{nodeLookup:E,transform:_,snapGrid:I,snapToGrid:M,nodeOrigin:P,domNode:B}=b.getState();return{nodeLookup:E,transform:_,snapGrid:I,snapToGrid:M,nodeOrigin:P,paneDomNode:B}},onChange:(E,_)=>{const{triggerNodeChanges:I,nodeLookup:M,parentLookup:P,nodeOrigin:B}=b.getState(),$=[],R={x:E.x,y:E.y},A=M.get(p);if(A&&A.expandParent&&A.parentId){const U=A.origin??B,z=E.width??A.measured.width??0,F=E.height??A.measured.height??0,V={id:A.id,parentId:A.parentId,rect:{width:z,height:F,...Dr({x:E.x??A.position.x,y:E.y??A.position.y},{width:z,height:F},A.parentId,M,U)}},q=jn([V],M,P,B);$.push(...q),R.x=E.x?Math.max(U[0]*z,E.x):void 0,R.y=E.y?Math.max(U[1]*F,E.y):void 0}if(R.x!==void 0&&R.y!==void 0){const U={id:p,type:"position",position:{...R}};$.push(U)}if(E.width!==void 0&&E.height!==void 0){const z={id:p,type:"dimensions",resizing:!0,setAttributes:h?h==="horizontal"?"width":"height":!0,dimensions:{width:E.width,height:E.height}};$.push(z)}for(const U of _){const z={...U,type:"position"};$.push(z)}I($)},onEnd:({width:E,height:_})=>{const I={id:p,type:"dimensions",resizing:!1,dimensions:{width:E,height:_}};b.getState().triggerNodeChanges([I])}})),k.current.update({controlPosition:N,boundaries:{minWidth:a,minHeight:c,maxWidth:u,maxHeight:l},keepAspectRatio:d,resizeDirection:h,onResizeStart:y,onResize:m,onResizeEnd:v,shouldResize:g}),()=>{var E;(E=k.current)==null||E.destroy()}},[N,a,c,u,l,d,y,m,v,g]);const G=N.split("-");return T.jsx("div",{className:he(["react-flow__resize-control","nodrag",...G,n,i]),ref:S,style:{...r,scale:C,...s&&{[x?"backgroundColor":"borderColor"]:s}},children:o})}D.memo(Nd);function Td(){const e=arguments[0];for(let t=1,n=arguments.length;t<n;t++)if(arguments[t])for(const i in arguments[t])e[i]=arguments[t][i];return e}let le=Td;typeof Object.assign=="function"&&(le=Object.assign);function ve(e,t,n,i){const r=e._nodes.get(t);let o=null;return r&&(i==="mixed"?o=r.out&&r.out[n]||r.undirected&&r.undirected[n]:i==="directed"?o=r.out&&r.out[n]:o=r.undirected&&r.undirected[n]),o}function fe(e){return typeof e=="object"&&e!==null}function ko(e){let t;for(t in e)return!1;return!0}function ye(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function xe(e,t,n){const i={enumerable:!0,configurable:!0};typeof n=="function"?i.get=n:(i.value=n,i.writable=!1),Object.defineProperty(e,t,i)}function Vi(e){return!(!fe(e)||e.attributes&&!Array.isArray(e.attributes))}function Ad(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function Re(){const e=arguments;let t=null,n=-1;return{[Symbol.iterator](){return this},next(){let i=null;do{if(t===null){if(n++,n>=e.length)return{done:!0};t=e[n][Symbol.iterator]()}if(i=t.next(),i.done){t=null;continue}break}while(!0);return i}}}function rt(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Yn extends Error{constructor(t){super(),this.name="GraphError",this.message=t}}class H extends Yn{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,H.prototype.constructor)}}class O extends Yn{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,O.prototype.constructor)}}class X extends Yn{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,X.prototype.constructor)}}function Ro(e,t){this.key=e,this.attributes=t,this.clear()}Ro.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 Do(e,t){this.key=e,this.attributes=t,this.clear()}Do.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function Lo(e,t){this.key=e,this.attributes=t,this.clear()}Lo.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function ot(e,t,n,i,r){this.key=t,this.attributes=r,this.undirected=e,this.source=n,this.target=i}ot.prototype.attach=function(){let e="out",t="in";this.undirected&&(e=t="undirected");const n=this.source.key,i=this.target.key;this.source[e][i]=this,!(this.undirected&&n===i)&&(this.target[t][n]=this)};ot.prototype.attachMulti=function(){let e="out",t="in";const n=this.source.key,i=this.target.key;this.undirected&&(e=t="undirected");const r=this.source[e],o=r[i];if(typeof o>"u"){r[i]=this,this.undirected&&n===i||(this.target[t][n]=this);return}o.previous=this,this.next=o,r[i]=this,this.target[t][n]=this};ot.prototype.detach=function(){const e=this.source.key,t=this.target.key;let n="out",i="in";this.undirected&&(n=i="undirected"),delete this.source[n][t],delete this.target[i][e]};ot.prototype.detachMulti=function(){const e=this.source.key,t=this.target.key;let n="out",i="in";this.undirected&&(n=i="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[n][t],delete this.target[i][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[i][e]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const Mo=0,Po=1,kd=2,Io=3;function Le(e,t,n,i,r,o,s){let a,c,u,l;if(i=""+i,n===Mo){if(a=e._nodes.get(i),!a)throw new O(`Graph.${t}: could not find the "${i}" node in the graph.`);u=r,l=o}else if(n===Io){if(r=""+r,c=e._edges.get(r),!c)throw new O(`Graph.${t}: could not find the "${r}" edge in the graph.`);const d=c.source.key,h=c.target.key;if(i===d)a=c.target;else if(i===h)a=c.source;else throw new O(`Graph.${t}: the "${i}" node is not attached to the "${r}" edge (${d}, ${h}).`);u=o,l=s}else{if(c=e._edges.get(i),!c)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`);n===Po?a=c.source:a=c.target,u=r,l=o}return[a,u,l]}function Rd(e,t,n){e.prototype[t]=function(i,r,o){const[s,a]=Le(this,t,n,i,r,o);return s.attributes[a]}}function Dd(e,t,n){e.prototype[t]=function(i,r){const[o]=Le(this,t,n,i,r);return o.attributes}}function Ld(e,t,n){e.prototype[t]=function(i,r,o){const[s,a]=Le(this,t,n,i,r,o);return s.attributes.hasOwnProperty(a)}}function Md(e,t,n){e.prototype[t]=function(i,r,o,s){const[a,c,u]=Le(this,t,n,i,r,o,s);return a.attributes[c]=u,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:c}),this}}function Pd(e,t,n){e.prototype[t]=function(i,r,o,s){const[a,c,u]=Le(this,t,n,i,r,o,s);if(typeof u!="function")throw new H(`Graph.${t}: updater should be a function.`);const l=a.attributes,d=u(l[c]);return l[c]=d,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:c}),this}}function Id(e,t,n){e.prototype[t]=function(i,r,o){const[s,a]=Le(this,t,n,i,r,o);return delete s.attributes[a],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:a}),this}}function Gd(e,t,n){e.prototype[t]=function(i,r,o){const[s,a]=Le(this,t,n,i,r,o);if(!fe(a))throw new H(`Graph.${t}: provided attributes are not a plain object.`);return s.attributes=a,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function Fd(e,t,n){e.prototype[t]=function(i,r,o){const[s,a]=Le(this,t,n,i,r,o);if(!fe(a))throw new H(`Graph.${t}: provided attributes are not a plain object.`);return le(s.attributes,a),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:a}),this}}function $d(e,t,n){e.prototype[t]=function(i,r,o){const[s,a]=Le(this,t,n,i,r,o);if(typeof a!="function")throw new H(`Graph.${t}: provided updater is not a function.`);return s.attributes=a(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}const zd=[{name:e=>`get${e}Attribute`,attacher:Rd},{name:e=>`get${e}Attributes`,attacher:Dd},{name:e=>`has${e}Attribute`,attacher:Ld},{name:e=>`set${e}Attribute`,attacher:Md},{name:e=>`update${e}Attribute`,attacher:Pd},{name:e=>`remove${e}Attribute`,attacher:Id},{name:e=>`replace${e}Attributes`,attacher:Gd},{name:e=>`merge${e}Attributes`,attacher:Fd},{name:e=>`update${e}Attributes`,attacher:$d}];function Bd(e){zd.forEach(function({name:t,attacher:n}){n(e,t("Node"),Mo),n(e,t("Source"),Po),n(e,t("Target"),kd),n(e,t("Opposite"),Io)})}function Od(e,t,n){e.prototype[t]=function(i,r){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new X(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new X(`Graph.${t}: 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=""+i,a=""+r;if(r=arguments[2],o=ve(this,s,a,n),!o)throw new O(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new X(`Graph.${t}: 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(i=""+i,o=this._edges.get(i),!o)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`)}return o.attributes[r]}}function Ud(e,t,n){e.prototype[t]=function(i){let r;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new X(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new X(`Graph.${t}: 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=""+i,s=""+arguments[1];if(r=ve(this,o,s,n),!r)throw new O(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new X(`Graph.${t}: 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(i=""+i,r=this._edges.get(i),!r)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`)}return r.attributes}}function Hd(e,t,n){e.prototype[t]=function(i,r){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new X(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new X(`Graph.${t}: 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=""+i,a=""+r;if(r=arguments[2],o=ve(this,s,a,n),!o)throw new O(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new X(`Graph.${t}: 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(i=""+i,o=this._edges.get(i),!o)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`)}return o.attributes.hasOwnProperty(r)}}function jd(e,t,n){e.prototype[t]=function(i,r,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new X(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new X(`Graph.${t}: 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=""+i,c=""+r;if(r=arguments[2],o=arguments[3],s=ve(this,a,c,n),!s)throw new O(`Graph.${t}: could not find an edge for the given path ("${a}" - "${c}").`)}else{if(n!=="mixed")throw new X(`Graph.${t}: 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(i=""+i,s=this._edges.get(i),!s)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`)}return s.attributes[r]=o,this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:r}),this}}function Vd(e,t,n){e.prototype[t]=function(i,r,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new X(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new X(`Graph.${t}: 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=""+i,c=""+r;if(r=arguments[2],o=arguments[3],s=ve(this,a,c,n),!s)throw new O(`Graph.${t}: could not find an edge for the given path ("${a}" - "${c}").`)}else{if(n!=="mixed")throw new X(`Graph.${t}: 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(i=""+i,s=this._edges.get(i),!s)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`)}if(typeof o!="function")throw new H(`Graph.${t}: updater should be a function.`);return s.attributes[r]=o(s.attributes[r]),this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:r}),this}}function Wd(e,t,n){e.prototype[t]=function(i,r){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new X(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new X(`Graph.${t}: 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=""+i,a=""+r;if(r=arguments[2],o=ve(this,s,a,n),!o)throw new O(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new X(`Graph.${t}: 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(i=""+i,o=this._edges.get(i),!o)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`)}return delete o.attributes[r],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:r}),this}}function Yd(e,t,n){e.prototype[t]=function(i,r){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new X(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new X(`Graph.${t}: 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=""+i,a=""+r;if(r=arguments[2],o=ve(this,s,a,n),!o)throw new O(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new X(`Graph.${t}: 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(i=""+i,o=this._edges.get(i),!o)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`)}if(!fe(r))throw new H(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=r,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function Xd(e,t,n){e.prototype[t]=function(i,r){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new X(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new X(`Graph.${t}: 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=""+i,a=""+r;if(r=arguments[2],o=ve(this,s,a,n),!o)throw new O(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new X(`Graph.${t}: 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(i=""+i,o=this._edges.get(i),!o)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`)}if(!fe(r))throw new H(`Graph.${t}: provided attributes are not a plain object.`);return le(o.attributes,r),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:r}),this}}function Zd(e,t,n){e.prototype[t]=function(i,r){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new X(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new X(`Graph.${t}: 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=""+i,a=""+r;if(r=arguments[2],o=ve(this,s,a,n),!o)throw new O(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new X(`Graph.${t}: 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(i=""+i,o=this._edges.get(i),!o)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`)}if(typeof r!="function")throw new H(`Graph.${t}: provided updater is not a function.`);return o.attributes=r(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const Kd=[{name:e=>`get${e}Attribute`,attacher:Od},{name:e=>`get${e}Attributes`,attacher:Ud},{name:e=>`has${e}Attribute`,attacher:Hd},{name:e=>`set${e}Attribute`,attacher:jd},{name:e=>`update${e}Attribute`,attacher:Vd},{name:e=>`remove${e}Attribute`,attacher:Wd},{name:e=>`replace${e}Attributes`,attacher:Yd},{name:e=>`merge${e}Attributes`,attacher:Xd},{name:e=>`update${e}Attributes`,attacher:Zd}];function qd(e){Kd.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}const Qd=[{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 Jd(e,t,n,i){let r=!1;for(const o in t){if(o===i)continue;const s=t[o];if(r=n(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),e&&r)return s.key}}function el(e,t,n,i){let r,o,s,a=!1;for(const c in t)if(c!==i){r=t[c];do{if(o=r.source,s=r.target,a=n(r.key,r.attributes,o.key,s.key,o.attributes,s.attributes,r.undirected),e&&a)return r.key;r=r.next}while(r!==void 0)}}function fn(e,t){const n=Object.keys(e),i=n.length;let r,o=0;return{[Symbol.iterator](){return this},next(){do if(r)r=r.next;else{if(o>=i)return{done:!0};const s=n[o++];if(s===t){r=void 0;continue}r=e[s]}while(!r);return{done:!1,value:{edge:r.key,attributes:r.attributes,source:r.source.key,target:r.target.key,sourceAttributes:r.source.attributes,targetAttributes:r.target.attributes,undirected:r.undirected}}}}}function tl(e,t,n,i){const r=t[n];if(!r)return;const o=r.source,s=r.target;if(i(r.key,r.attributes,o.key,s.key,o.attributes,s.attributes,r.undirected)&&e)return r.key}function nl(e,t,n,i){let r=t[n];if(!r)return;let o=!1;do{if(o=i(r.key,r.attributes,r.source.key,r.target.key,r.source.attributes,r.target.attributes,r.undirected),e&&o)return r.key;r=r.next}while(r!==void 0)}function gn(e,t){let n=e[t];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};const r={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:r}}};let i=!1;return{[Symbol.iterator](){return this},next(){return i===!0?{done:!0}:(i=!0,{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}})}}}function il(e,t){if(e.size===0)return[];if(t==="mixed"||t===e.type)return Array.from(e._edges.keys());const n=t==="undirected"?e.undirectedSize:e.directedSize,i=new Array(n),r=t==="undirected",o=e._edges.values();let s=0,a,c;for(;a=o.next(),a.done!==!0;)c=a.value,c.undirected===r&&(i[s++]=c.key);return i}function Go(e,t,n,i){if(t.size===0)return;const r=n!=="mixed"&&n!==t.type,o=n==="undirected";let s,a,c=!1;const u=t._edges.values();for(;s=u.next(),s.done!==!0;){if(a=s.value,r&&a.undirected!==o)continue;const{key:l,attributes:d,source:h,target:f}=a;if(c=i(l,d,h.key,f.key,h.attributes,f.attributes,a.undirected),e&&c)return l}}function rl(e,t){if(e.size===0)return rt();const n=t!=="mixed"&&t!==e.type,i=t==="undirected",r=e._edges.values();return{[Symbol.iterator](){return this},next(){let o,s;for(;;){if(o=r.next(),o.done)return o;if(s=o.value,!(n&&s.undirected!==i))break}return{value:{edge:s.key,attributes:s.attributes,source:s.source.key,target:s.target.key,sourceAttributes:s.source.attributes,targetAttributes:s.target.attributes,undirected:s.undirected},done:!1}}}}function Xn(e,t,n,i,r,o){const s=t?el:Jd;let a;if(n!=="undirected"&&(i!=="out"&&(a=s(e,r.in,o),e&&a)||i!=="in"&&(a=s(e,r.out,o,i?void 0:r.key),e&&a))||n!=="directed"&&(a=s(e,r.undirected,o),e&&a))return a}function ol(e,t,n,i){const r=[];return Xn(!1,e,t,n,i,function(o){r.push(o)}),r}function sl(e,t,n){let i=rt();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(i=Re(i,fn(n.in))),t!=="in"&&typeof n.out<"u"&&(i=Re(i,fn(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(i=Re(i,fn(n.undirected))),i}function Zn(e,t,n,i,r,o,s){const a=n?nl:tl;let c;if(t!=="undirected"&&(typeof r.in<"u"&&i!=="out"&&(c=a(e,r.in,o,s),e&&c)||typeof r.out<"u"&&i!=="in"&&(i||r.key!==o)&&(c=a(e,r.out,o,s),e&&c))||t!=="directed"&&typeof r.undirected<"u"&&(c=a(e,r.undirected,o,s),e&&c))return c}function al(e,t,n,i,r){const o=[];return Zn(!1,e,t,n,i,r,function(s){o.push(s)}),o}function cl(e,t,n,i){let r=rt();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&i in n.in&&(r=Re(r,gn(n.in,i))),typeof n.out<"u"&&t!=="in"&&i in n.out&&(t||n.key!==i)&&(r=Re(r,gn(n.out,i)))),e!=="directed"&&typeof n.undirected<"u"&&i in n.undirected&&(r=Re(r,gn(n.undirected,i))),r}function ul(e,t){const{name:n,type:i,direction:r}=t;e.prototype[n]=function(o,s){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return[];if(!arguments.length)return il(this,i);if(arguments.length===1){o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new O(`Graph.${n}: could not find the "${o}" node in the graph.`);return ol(this.multi,i==="mixed"?this.type:i,r,a)}if(arguments.length===2){o=""+o,s=""+s;const a=this._nodes.get(o);if(!a)throw new O(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new O(`Graph.${n}: could not find the "${s}" target node in the graph.`);return al(i,this.multi,r,a,s)}throw new H(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function dl(e,t){const{name:n,type:i,direction:r}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(u,l,d){if(!(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)){if(arguments.length===1)return d=u,Go(!1,this,i,d);if(arguments.length===2){u=""+u,d=l;const h=this._nodes.get(u);if(typeof h>"u")throw new O(`Graph.${o}: could not find the "${u}" node in the graph.`);return Xn(!1,this.multi,i==="mixed"?this.type:i,r,h,d)}if(arguments.length===3){u=""+u,l=""+l;const h=this._nodes.get(u);if(!h)throw new O(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(l))throw new O(`Graph.${o}: could not find the "${l}" target node in the graph.`);return Zn(!1,i,this.multi,r,h,l,d)}throw new H(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){const u=Array.prototype.slice.call(arguments),l=u.pop();let d;if(u.length===0){let h=0;i!=="directed"&&(h+=this.undirectedSize),i!=="undirected"&&(h+=this.directedSize),d=new Array(h);let f=0;u.push((g,y,m,v,w,p,b)=>{d[f++]=l(g,y,m,v,w,p,b)})}else d=[],u.push((h,f,g,y,m,v,w)=>{d.push(l(h,f,g,y,m,v,w))});return this[o].apply(this,u),d};const a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(){const u=Array.prototype.slice.call(arguments),l=u.pop(),d=[];return u.push((h,f,g,y,m,v,w)=>{l(h,f,g,y,m,v,w)&&d.push(h)}),this[o].apply(this,u),d};const c="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(){let u=Array.prototype.slice.call(arguments);if(u.length<2||u.length>4)throw new H(`Graph.${c}: invalid number of arguments (expecting 2, 3 or 4 and got ${u.length}).`);if(typeof u[u.length-1]=="function"&&typeof u[u.length-2]!="function")throw new H(`Graph.${c}: 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 l,d;u.length===2?(l=u[0],d=u[1],u=[]):u.length===3?(l=u[1],d=u[2],u=[u[0]]):u.length===4&&(l=u[2],d=u[3],u=[u[0],u[1]]);let h=d;return u.push((f,g,y,m,v,w,p)=>{h=l(h,f,g,y,m,v,w,p)}),this[o].apply(this,u),h}}function ll(e,t){const{name:n,type:i,direction:r}=t,o="find"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(c,u,l){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return!1;if(arguments.length===1)return l=c,Go(!0,this,i,l);if(arguments.length===2){c=""+c,l=u;const d=this._nodes.get(c);if(typeof d>"u")throw new O(`Graph.${o}: could not find the "${c}" node in the graph.`);return Xn(!0,this.multi,i==="mixed"?this.type:i,r,d,l)}if(arguments.length===3){c=""+c,u=""+u;const d=this._nodes.get(c);if(!d)throw new O(`Graph.${o}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(u))throw new O(`Graph.${o}: could not find the "${u}" target node in the graph.`);return Zn(!0,i,this.multi,r,d,u,l)}throw new H(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const s="some"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){const c=Array.prototype.slice.call(arguments),u=c.pop();return c.push((d,h,f,g,y,m,v)=>u(d,h,f,g,y,m,v)),!!this[o].apply(this,c)};const a="every"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(){const c=Array.prototype.slice.call(arguments),u=c.pop();return c.push((d,h,f,g,y,m,v)=>!u(d,h,f,g,y,m,v)),!this[o].apply(this,c)}}function hl(e,t){const{name:n,type:i,direction:r}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(s,a){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return rt();if(!arguments.length)return rl(this,i);if(arguments.length===1){s=""+s;const c=this._nodes.get(s);if(!c)throw new O(`Graph.${o}: could not find the "${s}" node in the graph.`);return sl(i,r,c)}if(arguments.length===2){s=""+s,a=""+a;const c=this._nodes.get(s);if(!c)throw new O(`Graph.${o}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(a))throw new O(`Graph.${o}: could not find the "${a}" target node in the graph.`);return cl(i,r,c,a)}throw new H(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function fl(e){Qd.forEach(t=>{ul(e,t),dl(e,t),ll(e,t),hl(e,t)})}const gl=[{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 en(){this.A=null,this.B=null}en.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};en.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function lt(e,t,n,i,r){for(const o in i){const s=i[o],a=s.source,c=s.target,u=a===n?c:a;if(t&&t.has(u.key))continue;const l=r(u.key,u.attributes);if(e&&l)return u.key}}function Kn(e,t,n,i,r){if(t!=="mixed"){if(t==="undirected")return lt(e,null,i,i.undirected,r);if(typeof n=="string")return lt(e,null,i,i[n],r)}const o=new en;let s;if(t!=="undirected"){if(n!=="out"){if(s=lt(e,null,i,i.in,r),e&&s)return s;o.wrap(i.in)}if(n!=="in"){if(s=lt(e,o,i,i.out,r),e&&s)return s;o.wrap(i.out)}}if(t!=="directed"&&(s=lt(e,o,i,i.undirected,r),e&&s))return s}function pl(e,t,n){if(e!=="mixed"){if(e==="undirected")return Object.keys(n.undirected);if(typeof t=="string")return Object.keys(n[t])}const i=[];return Kn(!1,e,t,n,function(r){i.push(r)}),i}function ht(e,t,n){const i=Object.keys(n),r=i.length;let o=0;return{[Symbol.iterator](){return this},next(){let s=null;do{if(o>=r)return e&&e.wrap(n),{done:!0};const a=n[i[o++]],c=a.source,u=a.target;if(s=c===t?u:c,e&&e.has(s.key)){s=null;continue}}while(s===null);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}}}}function ml(e,t,n){if(e!=="mixed"){if(e==="undirected")return ht(null,n,n.undirected);if(typeof t=="string")return ht(null,n,n[t])}let i=rt();const r=new en;return e!=="undirected"&&(t!=="out"&&(i=Re(i,ht(r,n,n.in))),t!=="in"&&(i=Re(i,ht(r,n,n.out)))),e!=="directed"&&(i=Re(i,ht(r,n,n.undirected))),i}function yl(e,t){const{name:n,type:i,direction:r}=t;e.prototype[n]=function(o){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return[];o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new O(`Graph.${n}: could not find the "${o}" node in the graph.`);return pl(i==="mixed"?this.type:i,r,s)}}function vl(e,t){const{name:n,type:i,direction:r}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(u,l){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return;u=""+u;const d=this._nodes.get(u);if(typeof d>"u")throw new O(`Graph.${o}: could not find the "${u}" node in the graph.`);Kn(!1,i==="mixed"?this.type:i,r,d,l)};const s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(u,l){const d=[];return this[o](u,(h,f)=>{d.push(l(h,f))}),d};const a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(u,l){const d=[];return this[o](u,(h,f)=>{l(h,f)&&d.push(h)}),d};const c="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(u,l,d){if(arguments.length<3)throw new H(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let h=d;return this[o](u,(f,g)=>{h=l(h,f,g)}),h}}function wl(e,t){const{name:n,type:i,direction:r}=t,o=n[0].toUpperCase()+n.slice(1,-1),s="find"+o;e.prototype[s]=function(u,l){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return;u=""+u;const d=this._nodes.get(u);if(typeof d>"u")throw new O(`Graph.${s}: could not find the "${u}" node in the graph.`);return Kn(!0,i==="mixed"?this.type:i,r,d,l)};const a="some"+o;e.prototype[a]=function(u,l){return!!this[s](u,l)};const c="every"+o;e.prototype[c]=function(u,l){return!this[s](u,(h,f)=>!l(h,f))}}function bl(e,t){const{name:n,type:i,direction:r}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(s){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return rt();s=""+s;const a=this._nodes.get(s);if(typeof a>"u")throw new O(`Graph.${o}: could not find the "${s}" node in the graph.`);return ml(i==="mixed"?this.type:i,r,a)}}function xl(e){gl.forEach(t=>{yl(e,t),vl(e,t),wl(e,t),bl(e,t)})}function It(e,t,n,i,r){const o=i._nodes.values(),s=i.type;let a,c,u,l,d,h;for(;a=o.next(),a.done!==!0;){let f=!1;if(c=a.value,s!=="undirected"){l=c.out;for(u in l){d=l[u];do h=d.target,f=!0,r(c.key,h.key,c.attributes,h.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}if(s!=="directed"){l=c.undirected;for(u in l)if(!(t&&c.key>u)){d=l[u];do h=d.target,h.key!==u&&(h=d.source),f=!0,r(c.key,h.key,c.attributes,h.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}n&&!f&&r(c.key,null,c.attributes,null,null,null,null)}}function El(e,t){const n={key:e};return ko(t.attributes)||(n.attributes=le({},t.attributes)),n}function Sl(e,t,n){const i={key:t,source:n.source.key,target:n.target.key};return ko(n.attributes)||(i.attributes=le({},n.attributes)),e==="mixed"&&n.undirected&&(i.undirected=!0),i}function Cl(e){if(!fe(e))throw new H('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in e))throw new H("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!fe(e.attributes)||e.attributes===null))throw new H("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function _l(e){if(!fe(e))throw new H('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in e))throw new H("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new H("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!fe(e.attributes)||e.attributes===null))throw new H("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!="boolean")throw new H("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const Nl=Ad(),Tl=new Set(["directed","undirected","mixed"]),Wi=new Set(["domain","_events","_eventsCount","_maxListeners"]),Al=[{name:e=>`${e}Edge`,generateKey:!0},{name:e=>`${e}DirectedEdge`,generateKey:!0,type:"directed"},{name:e=>`${e}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:e=>`${e}EdgeWithKey`},{name:e=>`${e}DirectedEdgeWithKey`,type:"directed"},{name:e=>`${e}UndirectedEdgeWithKey`,type:"undirected"}],kl={allowSelfLoops:!0,multi:!1,type:"mixed"};function Rl(e,t,n){if(n&&!fe(n))throw new H(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=""+t,n=n||{},e._nodes.has(t))throw new X(`Graph.addNode: the "${t}" node already exist in the graph.`);const i=new e.NodeDataClass(t,n);return e._nodes.set(t,i),e.emit("nodeAdded",{key:t,attributes:n}),i}function Yi(e,t,n){const i=new e.NodeDataClass(t,n);return e._nodes.set(t,i),e.emit("nodeAdded",{key:t,attributes:n}),i}function Fo(e,t,n,i,r,o,s,a){if(!i&&e.type==="undirected")throw new X(`Graph.${t}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(i&&e.type==="directed")throw new X(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(a&&!fe(a))throw new H(`Graph.${t}: invalid attributes. Expecting an object but got "${a}"`);if(o=""+o,s=""+s,a=a||{},!e.allowSelfLoops&&o===s)throw new X(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const c=e._nodes.get(o),u=e._nodes.get(s);if(!c)throw new O(`Graph.${t}: source node "${o}" not found.`);if(!u)throw new O(`Graph.${t}: target node "${s}" not found.`);const l={key:null,undirected:i,source:o,target:s,attributes:a};if(n)r=e._edgeKeyGenerator();else if(r=""+r,e._edges.has(r))throw new X(`Graph.${t}: the "${r}" edge already exists in the graph.`);if(!e.multi&&(i?typeof c.undirected[s]<"u":typeof c.out[s]<"u"))throw new X(`Graph.${t}: an edge linking "${o}" to "${s}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const d=new ot(i,r,c,u,a);e._edges.set(r,d);const h=o===s;return i?(c.undirectedDegree++,u.undirectedDegree++,h&&(c.undirectedLoops++,e._undirectedSelfLoopCount++)):(c.outDegree++,u.inDegree++,h&&(c.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),i?e._undirectedSize++:e._directedSize++,l.key=r,e.emit("edgeAdded",l),r}function Dl(e,t,n,i,r,o,s,a,c){if(!i&&e.type==="undirected")throw new X(`Graph.${t}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(i&&e.type==="directed")throw new X(`Graph.${t}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(a){if(c){if(typeof a!="function")throw new H(`Graph.${t}: invalid updater function. Expecting a function but got "${a}"`)}else if(!fe(a))throw new H(`Graph.${t}: invalid attributes. Expecting an object but got "${a}"`)}o=""+o,s=""+s;let u;if(c&&(u=a,a=void 0),!e.allowSelfLoops&&o===s)throw new X(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=e._nodes.get(o),d=e._nodes.get(s),h,f;if(!n&&(h=e._edges.get(r),h)){if((h.source.key!==o||h.target.key!==s)&&(!i||h.source.key!==s||h.target.key!==o))throw new X(`Graph.${t}: inconsistency detected when attempting to merge the "${r}" edge with "${o}" source & "${s}" target vs. ("${h.source.key}", "${h.target.key}").`);f=h}if(!f&&!e.multi&&l&&(f=i?l.undirected[s]:l.out[s]),f){const w=[f.key,!1,!1,!1];if(c?!u:!a)return w;if(c){const p=f.attributes;f.attributes=u(p),e.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else le(f.attributes,a),e.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:a});return w}a=a||{},c&&u&&(a=u(a));const g={key:null,undirected:i,source:o,target:s,attributes:a};if(n)r=e._edgeKeyGenerator();else if(r=""+r,e._edges.has(r))throw new X(`Graph.${t}: the "${r}" edge already exists in the graph.`);let y=!1,m=!1;l||(l=Yi(e,o,{}),y=!0,o===s&&(d=l,m=!0)),d||(d=Yi(e,s,{}),m=!0),h=new ot(i,r,l,d,a),e._edges.set(r,h);const v=o===s;return i?(l.undirectedDegree++,d.undirectedDegree++,v&&(l.undirectedLoops++,e._undirectedSelfLoopCount++)):(l.outDegree++,d.inDegree++,v&&(l.directedLoops++,e._directedSelfLoopCount++)),e.multi?h.attachMulti():h.attach(),i?e._undirectedSize++:e._directedSize++,g.key=r,e.emit("edgeAdded",g),[r,!0,y,m]}function Ye(e,t){e._edges.delete(t.key);const{source:n,target:i,attributes:r}=t,o=t.undirected,s=n===i;o?(n.undirectedDegree--,i.undirectedDegree--,s&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,i.inDegree--,s&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),o?e._undirectedSize--:e._directedSize--,e.emit("edgeDropped",{key:t.key,attributes:r,source:n.key,target:i.key,undirected:o})}class ae extends br.EventEmitter{constructor(t){if(super(),t=le({},kl,t),typeof t.multi!="boolean")throw new H(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!Tl.has(t.type))throw new H(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${t.type}".`);if(typeof t.allowSelfLoops!="boolean")throw new H(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${t.allowSelfLoops}".`);const n=t.type==="mixed"?Ro:t.type==="directed"?Do:Lo;ye(this,"NodeDataClass",n);const i="geid_"+Nl()+"_";let r=0;const o=()=>{let s;do s=i+r++;while(this._edges.has(s));return s};ye(this,"_attributes",{}),ye(this,"_nodes",new Map),ye(this,"_edges",new Map),ye(this,"_directedSize",0),ye(this,"_undirectedSize",0),ye(this,"_directedSelfLoopCount",0),ye(this,"_undirectedSelfLoopCount",0),ye(this,"_edgeKeyGenerator",o),ye(this,"_options",t),Wi.forEach(s=>ye(this,s,this[s])),xe(this,"order",()=>this._nodes.size),xe(this,"size",()=>this._edges.size),xe(this,"directedSize",()=>this._directedSize),xe(this,"undirectedSize",()=>this._undirectedSize),xe(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),xe(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),xe(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),xe(this,"multi",this._options.multi),xe(this,"type",this._options.type),xe(this,"allowSelfLoops",this._options.allowSelfLoops),xe(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(t){return this._nodes.has(""+t)}hasDirectedEdge(t,n){if(this.type==="undirected")return!1;if(arguments.length===1){const i=""+t,r=this._edges.get(i);return!!r&&!r.undirected}else if(arguments.length===2){t=""+t,n=""+n;const i=this._nodes.get(t);return i?i.out.hasOwnProperty(n):!1}throw new H(`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(t,n){if(this.type==="directed")return!1;if(arguments.length===1){const i=""+t,r=this._edges.get(i);return!!r&&r.undirected}else if(arguments.length===2){t=""+t,n=""+n;const i=this._nodes.get(t);return i?i.undirected.hasOwnProperty(n):!1}throw new H(`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(t,n){if(arguments.length===1){const i=""+t;return this._edges.has(i)}else if(arguments.length===2){t=""+t,n=""+n;const i=this._nodes.get(t);return i?typeof i.out<"u"&&i.out.hasOwnProperty(n)||typeof i.undirected<"u"&&i.undirected.hasOwnProperty(n):!1}throw new H(`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(t,n){if(this.type==="undirected")return;if(t=""+t,n=""+n,this.multi)throw new X("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const i=this._nodes.get(t);if(!i)throw new O(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new O(`Graph.directedEdge: could not find the "${n}" target node in the graph.`);const r=i.out&&i.out[n]||void 0;if(r)return r.key}undirectedEdge(t,n){if(this.type==="directed")return;if(t=""+t,n=""+n,this.multi)throw new X("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const i=this._nodes.get(t);if(!i)throw new O(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new O(`Graph.undirectedEdge: could not find the "${n}" target node in the graph.`);const r=i.undirected&&i.undirected[n]||void 0;if(r)return r.key}edge(t,n){if(this.multi)throw new X("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");t=""+t,n=""+n;const i=this._nodes.get(t);if(!i)throw new O(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new O(`Graph.edge: could not find the "${n}" target node in the graph.`);const r=i.out&&i.out[n]||i.undirected&&i.undirected[n]||void 0;if(r)return r.key}areDirectedNeighbors(t,n){t=""+t,n=""+n;const i=this._nodes.get(t);if(!i)throw new O(`Graph.areDirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in i.in||n in i.out}areOutNeighbors(t,n){t=""+t,n=""+n;const i=this._nodes.get(t);if(!i)throw new O(`Graph.areOutNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in i.out}areInNeighbors(t,n){t=""+t,n=""+n;const i=this._nodes.get(t);if(!i)throw new O(`Graph.areInNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in i.in}areUndirectedNeighbors(t,n){t=""+t,n=""+n;const i=this._nodes.get(t);if(!i)throw new O(`Graph.areUndirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="directed"?!1:n in i.undirected}areNeighbors(t,n){t=""+t,n=""+n;const i=this._nodes.get(t);if(!i)throw new O(`Graph.areNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&(n in i.in||n in i.out)||this.type!=="directed"&&n in i.undirected}areInboundNeighbors(t,n){t=""+t,n=""+n;const i=this._nodes.get(t);if(!i)throw new O(`Graph.areInboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in i.in||this.type!=="directed"&&n in i.undirected}areOutboundNeighbors(t,n){t=""+t,n=""+n;const i=this._nodes.get(t);if(!i)throw new O(`Graph.areOutboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in i.out||this.type!=="directed"&&n in i.undirected}inDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.inDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree}outDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.outDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree}directedDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.directedDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree}undirectedDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.undirectedDegree: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree}inboundDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.inboundDegree: could not find the "${t}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=n.undirectedDegree),this.type!=="undirected"&&(i+=n.inDegree),i}outboundDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.outboundDegree: could not find the "${t}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=n.undirectedDegree),this.type!=="undirected"&&(i+=n.outDegree),i}degree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.degree: could not find the "${t}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=n.undirectedDegree),this.type!=="undirected"&&(i+=n.inDegree+n.outDegree),i}inDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.inDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree-n.directedLoops}outDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.outDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree-n.directedLoops}directedDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.directedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree-n.directedLoops*2}undirectedDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree-n.undirectedLoops*2}inboundDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let i=0,r=0;return this.type!=="directed"&&(i+=n.undirectedDegree,r+=n.undirectedLoops*2),this.type!=="undirected"&&(i+=n.inDegree,r+=n.directedLoops),i-r}outboundDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let i=0,r=0;return this.type!=="directed"&&(i+=n.undirectedDegree,r+=n.undirectedLoops*2),this.type!=="undirected"&&(i+=n.outDegree,r+=n.directedLoops),i-r}degreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.degreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let i=0,r=0;return this.type!=="directed"&&(i+=n.undirectedDegree,r+=n.undirectedLoops*2),this.type!=="undirected"&&(i+=n.inDegree+n.outDegree,r+=n.directedLoops*2),i-r}source(t){t=""+t;const n=this._edges.get(t);if(!n)throw new O(`Graph.source: could not find the "${t}" edge in the graph.`);return n.source.key}target(t){t=""+t;const n=this._edges.get(t);if(!n)throw new O(`Graph.target: could not find the "${t}" edge in the graph.`);return n.target.key}extremities(t){t=""+t;const n=this._edges.get(t);if(!n)throw new O(`Graph.extremities: could not find the "${t}" edge in the graph.`);return[n.source.key,n.target.key]}opposite(t,n){t=""+t,n=""+n;const i=this._edges.get(n);if(!i)throw new O(`Graph.opposite: could not find the "${n}" edge in the graph.`);const r=i.source.key,o=i.target.key;if(t===r)return o;if(t===o)return r;throw new O(`Graph.opposite: the "${t}" node is not attached to the "${n}" edge (${r}, ${o}).`)}hasExtremity(t,n){t=""+t,n=""+n;const i=this._edges.get(t);if(!i)throw new O(`Graph.hasExtremity: could not find the "${t}" edge in the graph.`);return i.source.key===n||i.target.key===n}isUndirected(t){t=""+t;const n=this._edges.get(t);if(!n)throw new O(`Graph.isUndirected: could not find the "${t}" edge in the graph.`);return n.undirected}isDirected(t){t=""+t;const n=this._edges.get(t);if(!n)throw new O(`Graph.isDirected: could not find the "${t}" edge in the graph.`);return!n.undirected}isSelfLoop(t){t=""+t;const n=this._edges.get(t);if(!n)throw new O(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return n.source===n.target}addNode(t,n){return Rl(this,t,n).key}mergeNode(t,n){if(n&&!fe(n))throw new H(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);t=""+t,n=n||{};let i=this._nodes.get(t);return i?(n&&(le(i.attributes,n),this.emit("nodeAttributesUpdated",{type:"merge",key:t,attributes:i.attributes,data:n})),[t,!1]):(i=new this.NodeDataClass(t,n),this._nodes.set(t,i),this.emit("nodeAdded",{key:t,attributes:n}),[t,!0])}updateNode(t,n){if(n&&typeof n!="function")throw new H(`Graph.updateNode: invalid updater function. Expecting a function but got "${n}"`);t=""+t;let i=this._nodes.get(t);if(i){if(n){const o=i.attributes;i.attributes=n(o),this.emit("nodeAttributesUpdated",{type:"replace",key:t,attributes:i.attributes})}return[t,!1]}const r=n?n({}):{};return i=new this.NodeDataClass(t,r),this._nodes.set(t,i),this.emit("nodeAdded",{key:t,attributes:r}),[t,!0]}dropNode(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.dropNode: could not find the "${t}" node in the graph.`);let i;if(this.type!=="undirected"){for(const r in n.out){i=n.out[r];do Ye(this,i),i=i.next;while(i)}for(const r in n.in){i=n.in[r];do Ye(this,i),i=i.next;while(i)}}if(this.type!=="directed")for(const r in n.undirected){i=n.undirected[r];do Ye(this,i),i=i.next;while(i)}this._nodes.delete(t),this.emit("nodeDropped",{key:t,attributes:n.attributes})}dropEdge(t){let n;if(arguments.length>1){const i=""+arguments[0],r=""+arguments[1];if(n=ve(this,i,r,this.type),!n)throw new O(`Graph.dropEdge: could not find the "${i}" -> "${r}" edge in the graph.`)}else if(t=""+t,n=this._edges.get(t),!n)throw new O(`Graph.dropEdge: could not find the "${t}" edge in the graph.`);return Ye(this,n),this}dropDirectedEdge(t,n){if(arguments.length<2)throw new X("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 X("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.");t=""+t,n=""+n;const i=ve(this,t,n,"directed");if(!i)throw new O(`Graph.dropDirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Ye(this,i),this}dropUndirectedEdge(t,n){if(arguments.length<2)throw new X("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 X("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 i=ve(this,t,n,"undirected");if(!i)throw new O(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Ye(this,i),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const t=this._nodes.values();let n;for(;n=t.next(),n.done!==!0;)n.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(t){return this._attributes[t]}getAttributes(){return this._attributes}hasAttribute(t){return this._attributes.hasOwnProperty(t)}setAttribute(t,n){return this._attributes[t]=n,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}updateAttribute(t,n){if(typeof n!="function")throw new H("Graph.updateAttribute: updater should be a function.");const i=this._attributes[t];return this._attributes[t]=n(i),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}removeAttribute(t){return delete this._attributes[t],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:t}),this}replaceAttributes(t){if(!fe(t))throw new H("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=t,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(t){if(!fe(t))throw new H("Graph.mergeAttributes: provided attributes are not a plain object.");return le(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this}updateAttributes(t){if(typeof t!="function")throw new H("Graph.updateAttributes: provided updater is not a function.");return this._attributes=t(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(t,n){if(typeof t!="function")throw new H("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!Vi(n))throw new H("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const i=this._nodes.values();let r,o;for(;r=i.next(),r.done!==!0;)o=r.value,o.attributes=t(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:n||null})}updateEachEdgeAttributes(t,n){if(typeof t!="function")throw new H("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!Vi(n))throw new H("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const i=this._edges.values();let r,o,s,a;for(;r=i.next(),r.done!==!0;)o=r.value,s=o.source,a=o.target,o.attributes=t(o.key,o.attributes,s.key,a.key,s.attributes,a.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:n||null})}forEachAdjacencyEntry(t){if(typeof t!="function")throw new H("Graph.forEachAdjacencyEntry: expecting a callback.");It(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new H("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");It(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new H("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");It(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new H("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");It(!1,!0,!0,this,t)}nodes(){return Array.from(this._nodes.keys())}forEachNode(t){if(typeof t!="function")throw new H("Graph.forEachNode: expecting a callback.");const n=this._nodes.values();let i,r;for(;i=n.next(),i.done!==!0;)r=i.value,t(r.key,r.attributes)}findNode(t){if(typeof t!="function")throw new H("Graph.findNode: expecting a callback.");const n=this._nodes.values();let i,r;for(;i=n.next(),i.done!==!0;)if(r=i.value,t(r.key,r.attributes))return r.key}mapNodes(t){if(typeof t!="function")throw new H("Graph.mapNode: expecting a callback.");const n=this._nodes.values();let i,r;const o=new Array(this.order);let s=0;for(;i=n.next(),i.done!==!0;)r=i.value,o[s++]=t(r.key,r.attributes);return o}someNode(t){if(typeof t!="function")throw new H("Graph.someNode: expecting a callback.");const n=this._nodes.values();let i,r;for(;i=n.next(),i.done!==!0;)if(r=i.value,t(r.key,r.attributes))return!0;return!1}everyNode(t){if(typeof t!="function")throw new H("Graph.everyNode: expecting a callback.");const n=this._nodes.values();let i,r;for(;i=n.next(),i.done!==!0;)if(r=i.value,!t(r.key,r.attributes))return!1;return!0}filterNodes(t){if(typeof t!="function")throw new H("Graph.filterNodes: expecting a callback.");const n=this._nodes.values();let i,r;const o=[];for(;i=n.next(),i.done!==!0;)r=i.value,t(r.key,r.attributes)&&o.push(r.key);return o}reduceNodes(t,n){if(typeof t!="function")throw new H("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new H("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 i=n;const r=this._nodes.values();let o,s;for(;o=r.next(),o.done!==!0;)s=o.value,i=t(i,s.key,s.attributes);return i}nodeEntries(){const t=this._nodes.values();return{[Symbol.iterator](){return this},next(){const n=t.next();if(n.done)return n;const i=n.value;return{value:{node:i.key,attributes:i.attributes},done:!1}}}}export(){const t=new Array(this._nodes.size);let n=0;this._nodes.forEach((r,o)=>{t[n++]=El(o,r)});const i=new Array(this._edges.size);return n=0,this._edges.forEach((r,o)=>{i[n++]=Sl(this.type,o,r)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:t,edges:i}}import(t,n=!1){if(t instanceof ae)return t.forEachNode((c,u)=>{n?this.mergeNode(c,u):this.addNode(c,u)}),t.forEachEdge((c,u,l,d,h,f,g)=>{n?g?this.mergeUndirectedEdgeWithKey(c,l,d,u):this.mergeDirectedEdgeWithKey(c,l,d,u):g?this.addUndirectedEdgeWithKey(c,l,d,u):this.addDirectedEdgeWithKey(c,l,d,u)}),this;if(!fe(t))throw new H("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!fe(t.attributes))throw new H("Graph.import: invalid attributes. Expecting a plain object.");n?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}let i,r,o,s,a;if(t.nodes){if(o=t.nodes,!Array.isArray(o))throw new H("Graph.import: invalid nodes. Expecting an array.");for(i=0,r=o.length;i<r;i++){s=o[i],Cl(s);const{key:c,attributes:u}=s;n?this.mergeNode(c,u):this.addNode(c,u)}}if(t.edges){let c=!1;if(this.type==="undirected"&&(c=!0),o=t.edges,!Array.isArray(o))throw new H("Graph.import: invalid edges. Expecting an array.");for(i=0,r=o.length;i<r;i++){a=o[i],_l(a);const{source:u,target:l,attributes:d,undirected:h=c}=a;let f;"key"in a?(f=n?h?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:h?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,a.key,u,l,d)):(f=n?h?this.mergeUndirectedEdge:this.mergeDirectedEdge:h?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,u,l,d))}}return this}nullCopy(t){const n=new ae(le({},this._options,t));return n.replaceAttributes(le({},this.getAttributes())),n}emptyCopy(t){const n=this.nullCopy(t);return this._nodes.forEach((i,r)=>{const o=le({},i.attributes);i=new n.NodeDataClass(r,o),n._nodes.set(r,i)}),n}copy(t){if(t=t||{},typeof t.type=="string"&&t.type!==this.type&&t.type!=="mixed")throw new X(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${t.type}" because this would mean losing information about the current graph.`);if(typeof t.multi=="boolean"&&t.multi!==this.multi&&t.multi!==!0)throw new X("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 t.allowSelfLoops=="boolean"&&t.allowSelfLoops!==this.allowSelfLoops&&t.allowSelfLoops!==!0)throw new X("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 n=this.emptyCopy(t),i=this._edges.values();let r,o;for(;r=i.next(),r.done!==!0;)o=r.value,Fo(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,le({},o.attributes));return n}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const t={};this._nodes.forEach((o,s)=>{t[s]=o.attributes});const n={},i={};this._edges.forEach((o,s)=>{const a=o.undirected?"--":"->";let c="",u=o.source.key,l=o.target.key,d;o.undirected&&u>l&&(d=u,u=l,l=d);const h=`(${u})${a}(${l})`;s.startsWith("geid_")?this.multi&&(typeof i[h]>"u"?i[h]=0:i[h]++,c+=`${i[h]}. `):c+=`[${s}]: `,c+=h,n[c]=o.attributes});const r={};for(const o in this)this.hasOwnProperty(o)&&!Wi.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(r[o]=this[o]);return r.attributes=this._attributes,r.nodes=t,r.edges=n,ye(r,"constructor",this.constructor),r}}typeof Symbol<"u"&&(ae.prototype[Symbol.for("nodejs.util.inspect.custom")]=ae.prototype.inspect);Al.forEach(e=>{["add","merge","update"].forEach(t=>{const n=e.name(t),i=t==="add"?Fo:Dl;e.generateKey?ae.prototype[n]=function(r,o,s){return i(this,n,!0,(e.type||this.type)==="undirected",null,r,o,s,t==="update")}:ae.prototype[n]=function(r,o,s,a){return i(this,n,!1,(e.type||this.type)==="undirected",r,o,s,a,t==="update")}})});Bd(ae);qd(ae);fl(ae);xl(ae);class $o extends ae{constructor(t){const n=le({type:"directed"},t);if("multi"in n&&n.multi!==!1)throw new H("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new H('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class zo extends ae{constructor(t){const n=le({type:"undirected"},t);if("multi"in n&&n.multi!==!1)throw new H("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new H('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class Bo extends ae{constructor(t){const n=le({multi:!0},t);if("multi"in n&&n.multi!==!0)throw new H("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}}class Oo extends ae{constructor(t){const n=le({type:"directed",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new H("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new H('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class Uo extends ae{constructor(t){const n=le({type:"undirected",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new H("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new H('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}function st(e){e.from=function(t,n){const i=le({},t.options,n),r=new e(i);return r.import(t),r}}st(ae);st($o);st(zo);st(Bo);st(Oo);st(Uo);ae.Graph=ae;ae.DirectedGraph=$o;ae.UndirectedGraph=zo;ae.MultiGraph=Bo;ae.MultiDirectedGraph=Oo;ae.MultiUndirectedGraph=Uo;ae.InvalidArgumentsGraphError=H;ae.NotFoundGraphError=O;ae.UsageGraphError=X;function Ll(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function vt(e){var t=Ll(e,"string");return typeof t=="symbol"?t:t+""}function pe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Xi(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,vt(i.key),i)}}function me(e,t,n){return t&&Xi(e.prototype,t),n&&Xi(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function nt(e){return nt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},nt(e)}function Ho(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ho=function(){return!!e})()}function Ml(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Pl(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ml(e)}function we(e,t,n){return t=nt(t),Pl(e,Ho()?Reflect.construct(t,n||[],nt(e).constructor):t.apply(e,n))}function Dn(e,t){return Dn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Dn(e,t)}function be(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Dn(e,t)}function Il(e){if(Array.isArray(e))return e}function Gl(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var i,r,o,s,a=[],c=!0,u=!1;try{if(o=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(i=o.call(n)).done)&&(a.push(i.value),a.length!==t);c=!0);}catch(l){u=!0,r=l}finally{try{if(!c&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw r}}return a}}function Ln(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function jo(e,t){if(e){if(typeof e=="string")return Ln(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ln(e,t):void 0}}function Fl(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
8
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function it(e,t){return
|
|
6
|
+
`)),l=u.reduce((d,h)=>d.concat(...h),[]);return[u,l]}return[[],[]]},[e]);return D.useEffect(()=>{const c=(t==null?void 0:t.target)??Ai,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const l=f=>{var m,v;if(r.current=f.ctrlKey||f.metaKey||f.shiftKey||f.altKey,(!r.current||r.current&&!u)&&Mr(f))return!1;const y=ki(f.code,a);if(o.current.add(f[y]),Ti(s,o.current,!1)){const w=((v=(m=f.composedPath)==null?void 0:m.call(f))==null?void 0:v[0])||f.target,p=(w==null?void 0:w.nodeName)==="BUTTON"||(w==null?void 0:w.nodeName)==="A";t.preventDefault!==!1&&(r.current||!p)&&f.preventDefault(),i(!0)}},d=f=>{const g=ki(f.code,a);Ti(s,o.current,!0)?(i(!1),o.current.clear()):o.current.delete(f[g]),f.key==="Meta"&&o.current.clear(),r.current=!1},h=()=>{o.current.clear(),i(!1)};return c==null||c.addEventListener("keydown",l),c==null||c.addEventListener("keyup",d),window.addEventListener("blur",h),window.addEventListener("contextmenu",h),()=>{c==null||c.removeEventListener("keydown",l),c==null||c.removeEventListener("keyup",d),window.removeEventListener("blur",h),window.removeEventListener("contextmenu",h)}}},[e,i]),n}function Ti(e,t,n){return e.filter(i=>n||i.length===t.size).some(i=>i.every(r=>t.has(r)))}function ki(e,t){return t.includes(e)?"code":"key"}const Mc=()=>{const e=de();return D.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:i}=e.getState();return i?i.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[i,r,o],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??i,y:t.y??r,zoom:t.zoom??o},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,i]=e.getState().transform;return{x:t,y:n,zoom:i}},setCenter:async(t,n,i)=>e.getState().setCenter(t,n,i),fitBounds:async(t,n)=>{const{width:i,height:r,minZoom:o,maxZoom:s,panZoom:a}=e.getState(),c=$n(t,i,r,o,s,(n==null?void 0:n.padding)??.1);return a?(await a.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:i,snapGrid:r,snapToGrid:o,domNode:s}=e.getState();if(!s)return t;const{x:a,y:c}=s.getBoundingClientRect(),u={x:t.x-a,y:t.y-c},l=n.snapGrid??r,d=n.snapToGrid??o;return At(u,i,d,l)},flowToScreenPosition:t=>{const{transform:n,domNode:i}=e.getState();if(!i)return t;const{x:r,y:o}=i.getBoundingClientRect(),s=Ht(t,n);return{x:s.x+r,y:s.y+o}}}),[])};function eo(e,t){const n=[],i=new Map,r=[];for(const o of e)if(o.type==="add"){r.push(o);continue}else if(o.type==="remove"||o.type==="replace")i.set(o.id,[o]);else{const s=i.get(o.id);s?s.push(o):i.set(o.id,[o])}for(const o of t){const s=i.get(o.id);if(!s){n.push(o);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const a={...o};for(const c of s)Pc(c,a);n.push(a)}return r.length&&r.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function Pc(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Ic(e,t){return eo(e,t)}function Gc(e,t){return eo(e,t)}function Oe(e,t){return{id:e,type:"select",selected:t}}function Ze(e,t=new Set,n=!1){const i=[];for(const[r,o]of e){const s=t.has(r);!(o.selected===void 0&&!s)&&o.selected!==s&&(n&&(o.selected=s),i.push(Oe(o.id,s)))}return i}function Ri({items:e=[],lookup:t}){var r;const n=[],i=new Map(e.map(o=>[o.id,o]));for(const[o,s]of e.entries()){const a=t.get(s.id),c=((r=a==null?void 0:a.internals)==null?void 0:r.userNode)??a;c!==void 0&&c!==s&&n.push({id:s.id,item:s,type:"replace"}),c===void 0&&n.push({item:s,type:"add",index:o})}for(const[o]of t)i.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function Di(e){return{id:e.id,type:"remove"}}const Li=e=>ma(e),Fc=e=>_r(e);function to(e){return D.forwardRef(e)}function Mi(e){const[t,n]=D.useState(BigInt(0)),[i]=D.useState(()=>$c(()=>n(r=>r+BigInt(1))));return kn(()=>{const r=i.get();r.length&&(e(r),i.reset())},[t]),i}function $c(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const no=D.createContext(null);function zc({children:e}){const t=de(),n=D.useCallback(a=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:l,onNodesChange:d,nodeLookup:h,fitViewQueued:f,onNodesChangeMiddlewareMap:g}=t.getState();let y=c;for(const v of a)y=typeof v=="function"?v(y):v;let m=Ri({items:y,lookup:h});for(const v of g.values())m=v(m);l&&u(y),m.length>0?d==null||d(m):f&&window.requestAnimationFrame(()=>{const{fitViewQueued:v,nodes:w,setNodes:p}=t.getState();v&&p(w)})},[]),i=Mi(n),r=D.useCallback(a=>{const{edges:c=[],setEdges:u,hasDefaultEdges:l,onEdgesChange:d,edgeLookup:h}=t.getState();let f=c;for(const g of a)f=typeof g=="function"?g(f):g;l?u(f):d&&d(Ri({items:f,lookup:h}))},[]),o=Mi(r),s=D.useMemo(()=>({nodeQueue:i,edgeQueue:o}),[]);return A.jsx(no.Provider,{value:s,children:e})}function Bc(){const e=D.useContext(no);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Oc=e=>!!e.panZoom;function Vn(){const e=Mc(),t=de(),n=Bc(),i=re(Oc),r=D.useMemo(()=>{const o=d=>t.getState().nodeLookup.get(d),s=d=>{n.nodeQueue.push(d)},a=d=>{n.edgeQueue.push(d)},c=d=>{var v,w;const{nodeLookup:h,nodeOrigin:f}=t.getState(),g=Li(d)?d:h.get(d.id),y=g.parentId?Dr(g.position,g.measured,g.parentId,h,f):g.position,m={...g,position:y,width:((v=g.measured)==null?void 0:v.width)??g.width,height:((w=g.measured)==null?void 0:w.height)??g.height};return Je(m)},u=(d,h,f={replace:!1})=>{s(g=>g.map(y=>{if(y.id===d){const m=typeof h=="function"?h(y):h;return f.replace&&Li(m)?m:{...y,...m}}return y}))},l=(d,h,f={replace:!1})=>{a(g=>g.map(y=>{if(y.id===d){const m=typeof h=="function"?h(y):h;return f.replace&&Fc(m)?m:{...y,...m}}return y}))};return{getNodes:()=>t.getState().nodes.map(d=>({...d})),getNode:d=>{var h;return(h=o(d))==null?void 0:h.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:d=[]}=t.getState();return d.map(h=>({...h}))},getEdge:d=>t.getState().edgeLookup.get(d),setNodes:s,setEdges:a,addNodes:d=>{const h=Array.isArray(d)?d:[d];n.nodeQueue.push(f=>[...f,...h])},addEdges:d=>{const h=Array.isArray(d)?d:[d];n.edgeQueue.push(f=>[...f,...h])},toObject:()=>{const{nodes:d=[],edges:h=[],transform:f}=t.getState(),[g,y,m]=f;return{nodes:d.map(v=>({...v})),edges:h.map(v=>({...v})),viewport:{x:g,y,zoom:m}}},deleteElements:async({nodes:d=[],edges:h=[]})=>{const{nodes:f,edges:g,onNodesDelete:y,onEdgesDelete:m,triggerNodeChanges:v,triggerEdgeChanges:w,onDelete:p,onBeforeDelete:b}=t.getState(),{nodes:S,edges:x}=await xa({nodesToRemove:d,edgesToRemove:h,nodes:f,edges:g,onBeforeDelete:b}),C=x.length>0,k=S.length>0;if(C){const N=x.map(Di);m==null||m(x),w(N)}if(k){const N=S.map(Di);y==null||y(S),v(N)}return(k||C)&&(p==null||p({nodes:S,edges:x})),{deletedNodes:S,deletedEdges:x}},getIntersectingNodes:(d,h=!0,f)=>{const g=di(d),y=g?d:c(d),m=f!==void 0;return y?(f||t.getState().nodes).filter(v=>{const w=t.getState().nodeLookup.get(v.id);if(w&&!g&&(v.id===d.id||!w.internals.positionAbsolute))return!1;const p=Je(m?v:w),b=xt(p,y);return h&&b>0||b>=p.width*p.height||b>=y.width*y.height}):[]},isNodeIntersecting:(d,h,f=!0)=>{const y=di(d)?d:c(d);if(!y)return!1;const m=xt(y,h);return f&&m>0||m>=h.width*h.height||m>=y.width*y.height},updateNode:u,updateNodeData:(d,h,f={replace:!1})=>{u(d,g=>{const y=typeof h=="function"?h(g):h;return f.replace?{...g,data:y}:{...g,data:{...g.data,...y}}},f)},updateEdge:l,updateEdgeData:(d,h,f={replace:!1})=>{l(d,g=>{const y=typeof h=="function"?h(g):h;return f.replace?{...g,data:y}:{...g,data:{...g.data,...y}}},f)},getNodesBounds:d=>{const{nodeLookup:h,nodeOrigin:f}=t.getState();return ya(d,{nodeLookup:h,nodeOrigin:f})},getHandleConnections:({type:d,id:h,nodeId:f})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${f}-${d}${h?`-${h}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:d,handleId:h,nodeId:f})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${f}${d?h?`-${d}-${h}`:`-${d}`:""}`))==null?void 0:g.values())??[])},fitView:async d=>{const h=t.getState().fitViewResolver??_a();return t.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:h}),n.nodeQueue.push(f=>[...f]),h.promise}}},[]);return D.useMemo(()=>({...r,...e,viewportInitialized:i}),[i])}const Pi=e=>e.selected,Uc=typeof window<"u"?window:void 0;function Hc({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=de(),{deleteElements:i}=Vn(),r=St(e,{actInsideInputWithModifier:!1}),o=St(t,{target:Uc});D.useEffect(()=>{if(r){const{edges:s,nodes:a}=n.getState();i({nodes:a.filter(Pi),edges:s.filter(Pi)}),n.setState({nodesSelectionActive:!1})}},[r]),D.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function jc(e){const t=de();D.useEffect(()=>{const n=()=>{var r,o,s,a;if(!e.current||!(((o=(r=e.current).checkVisibility)==null?void 0:o.call(r))??!0))return!1;const i=zn(e.current);(i.height===0||i.width===0)&&((a=(s=t.getState()).onError)==null||a.call(s,"004",Ne.error004())),t.setState({width:i.width||500,height:i.height||500})};if(e.current){n(),window.addEventListener("resize",n);const i=new ResizeObserver(()=>n());return i.observe(e.current),()=>{window.removeEventListener("resize",n),i&&e.current&&i.unobserve(e.current)}}},[])}const Qt={position:"absolute",width:"100%",height:"100%",top:0,left:0},Vc=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Wc({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:i=!1,panOnScrollSpeed:r=.5,panOnScrollMode:o=Ue.Free,zoomOnDoubleClick:s=!0,panOnDrag:a=!0,defaultViewport:c,translateExtent:u,minZoom:l,maxZoom:d,zoomActivationKeyCode:h,preventScrolling:f=!0,children:g,noWheelClassName:y,noPanClassName:m,onViewportChange:v,isControlledViewport:w,paneClickDistance:p,selectionOnDrag:b}){const S=de(),x=D.useRef(null),{userSelectionActive:C,lib:k,connectionInProgress:N}=re(Vc,ue),G=St(h),E=D.useRef();jc(x);const _=D.useCallback(I=>{v==null||v({x:I[0],y:I[1],zoom:I[2]}),w||S.setState({transform:I})},[v,w]);return D.useEffect(()=>{if(x.current){E.current=cc({domNode:x.current,minZoom:l,maxZoom:d,translateExtent:u,viewport:c,onDraggingChange:B=>S.setState($=>$.paneDragging===B?$:{paneDragging:B}),onPanZoomStart:(B,$)=>{const{onViewportChangeStart:R,onMoveStart:T}=S.getState();T==null||T(B,$),R==null||R($)},onPanZoom:(B,$)=>{const{onViewportChange:R,onMove:T}=S.getState();T==null||T(B,$),R==null||R($)},onPanZoomEnd:(B,$)=>{const{onViewportChangeEnd:R,onMoveEnd:T}=S.getState();T==null||T(B,$),R==null||R($)}});const{x:I,y:M,zoom:P}=E.current.getViewport();return S.setState({panZoom:E.current,transform:[I,M,P],domNode:x.current.closest(".react-flow")}),()=>{var B;(B=E.current)==null||B.destroy()}}},[]),D.useEffect(()=>{var I;(I=E.current)==null||I.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:i,panOnScrollSpeed:r,panOnScrollMode:o,zoomOnDoubleClick:s,panOnDrag:a,zoomActivationKeyPressed:G,preventScrolling:f,noPanClassName:m,userSelectionActive:C,noWheelClassName:y,lib:k,onTransformChange:_,connectionInProgress:N,selectionOnDrag:b,paneClickDistance:p})},[e,t,n,i,r,o,s,a,G,f,m,C,y,k,_,N,b,p]),A.jsx("div",{className:"react-flow__renderer",ref:x,style:Qt,children:g})}const Yc=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Xc(){const{userSelectionActive:e,userSelectionRect:t}=re(Yc,ue);return e&&t?A.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const ln=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},Zc=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function Kc({isSelecting:e,selectionKeyPressed:t,selectionMode:n=bt.Full,panOnDrag:i,paneClickDistance:r,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:a,onPaneClick:c,onPaneContextMenu:u,onPaneScroll:l,onPaneMouseEnter:d,onPaneMouseMove:h,onPaneMouseLeave:f,children:g}){const y=de(),{userSelectionActive:m,elementsSelectable:v,dragging:w,connectionInProgress:p}=re(Zc,ue),b=v&&(e||m),S=D.useRef(null),x=D.useRef(),C=D.useRef(new Set),k=D.useRef(new Set),N=D.useRef(!1),G=R=>{if(N.current||p){N.current=!1;return}c==null||c(R),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},E=R=>{if(Array.isArray(i)&&(i!=null&&i.includes(2))){R.preventDefault();return}u==null||u(R)},_=l?R=>l(R):void 0,I=R=>{N.current&&(R.stopPropagation(),N.current=!1)},M=R=>{var J,te;const{domNode:T}=y.getState();if(x.current=T==null?void 0:T.getBoundingClientRect(),!x.current)return;const U=R.target===S.current;if(!U&&!!R.target.closest(".nokey")||!e||!(o&&U||t)||R.button!==0||!R.isPrimary)return;(te=(J=R.target)==null?void 0:J.setPointerCapture)==null||te.call(J,R.pointerId),N.current=!1;const{x:V,y:q}=_e(R.nativeEvent,x.current);y.setState({userSelectionRect:{width:0,height:0,startX:V,startY:q,x:V,y:q}}),U||(R.stopPropagation(),R.preventDefault())},P=R=>{const{userSelectionRect:T,transform:U,nodeLookup:z,edgeLookup:F,connectionLookup:V,triggerNodeChanges:q,triggerEdgeChanges:J,defaultEdgeOptions:te,resetSelectedElements:ne}=y.getState();if(!x.current||!T)return;const{x:j,y:Q}=_e(R.nativeEvent,x.current),{startX:ie,startY:ee}=T;if(!N.current){const oe=t?0:r;if(Math.hypot(j-ie,Q-ee)<=oe)return;ne(),s==null||s(R)}N.current=!0;const K={startX:ie,startY:ee,x:j<ie?j:ie,y:Q<ee?Q:ee,width:Math.abs(j-ie),height:Math.abs(Q-ee)},Z=C.current,se=k.current;C.current=new Set(Fn(z,K,U,n===bt.Partial,!0).map(oe=>oe.id)),k.current=new Set;const ce=(te==null?void 0:te.selectable)??!0;for(const oe of C.current){const ge=V.get(oe);if(ge)for(const{edgeId:Me}of ge.values()){const Ae=F.get(Me);Ae&&(Ae.selectable??ce)&&k.current.add(Me)}}if(!li(Z,C.current)){const oe=Ze(z,C.current,!0);q(oe)}if(!li(se,k.current)){const oe=Ze(F,k.current);J(oe)}y.setState({userSelectionRect:K,userSelectionActive:!0,nodesSelectionActive:!1})},B=R=>{var T,U;R.button===0&&((U=(T=R.target)==null?void 0:T.releasePointerCapture)==null||U.call(T,R.pointerId),!m&&R.target===S.current&&y.getState().userSelectionRect&&(G==null||G(R)),y.setState({userSelectionActive:!1,userSelectionRect:null}),N.current&&(a==null||a(R),y.setState({nodesSelectionActive:C.current.size>0})))},$=i===!0||Array.isArray(i)&&i.includes(0);return A.jsxs("div",{className:he(["react-flow__pane",{draggable:$,dragging:w,selection:e}]),onClick:b?void 0:ln(G,S),onContextMenu:ln(E,S),onWheel:ln(_,S),onPointerEnter:b?void 0:d,onPointerMove:b?P:h,onPointerUp:b?B:void 0,onPointerDownCapture:b?M:void 0,onClickCapture:b?I:void 0,onPointerLeave:f,ref:S,style:Qt,children:[g,A.jsx(Xc,{})]})}function Rn({id:e,store:t,unselect:n=!1,nodeRef:i}){const{addSelectedNodes:r,unselectNodesAndEdges:o,multiSelectionActive:s,nodeLookup:a,onError:c}=t.getState(),u=a.get(e);if(!u){c==null||c("012",Ne.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&s)&&(o({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var l;return(l=i==null?void 0:i.current)==null?void 0:l.blur()})):r([e])}function io({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:i,nodeId:r,isSelectable:o,nodeClickDistance:s}){const a=de(),[c,u]=D.useState(!1),l=D.useRef();return D.useEffect(()=>{l.current=Xa({getStoreItems:()=>a.getState(),onNodeMouseDown:d=>{Rn({id:d,store:a,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),D.useEffect(()=>{if(!(t||!e.current||!l.current))return l.current.update({noDragClassName:n,handleSelector:i,domNode:e.current,isSelectable:o,nodeId:r,nodeClickDistance:s}),()=>{var d;(d=l.current)==null||d.destroy()}},[n,i,t,o,e,r,s]),c}const qc=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function ro(){const e=de();return D.useCallback(n=>{const{nodeExtent:i,snapToGrid:r,snapGrid:o,nodesDraggable:s,onError:a,updateNodePositions:c,nodeLookup:u,nodeOrigin:l}=e.getState(),d=new Map,h=qc(s),f=r?o[0]:5,g=r?o[1]:5,y=n.direction.x*f*n.factor,m=n.direction.y*g*n.factor;for(const[,v]of u){if(!h(v))continue;let w={x:v.internals.positionAbsolute.x+y,y:v.internals.positionAbsolute.y+m};r&&(w=Nt(w,o));const{position:p,positionAbsolute:b}=Nr({nodeId:v.id,nextPosition:w,nodeLookup:u,nodeExtent:i,nodeOrigin:l,onError:a});v.position=p,v.internals.positionAbsolute=b,d.set(v.id,v)}c(d)},[])}const Wn=D.createContext(null),Qc=Wn.Provider;Wn.Consumer;const oo=()=>D.useContext(Wn),Jc=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),eu=(e,t,n)=>i=>{const{connectionClickStartHandle:r,connectionMode:o,connection:s}=i,{fromHandle:a,toHandle:c,isValid:u}=s,l=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n,connectingTo:l,clickConnecting:(r==null?void 0:r.nodeId)===e&&(r==null?void 0:r.id)===t&&(r==null?void 0:r.type)===n,isPossibleEndHandle:o===qe.Strict?(a==null?void 0:a.type)!==n:e!==(a==null?void 0:a.nodeId)||t!==(a==null?void 0:a.id),connectionInProcess:!!a,clickConnectionInProcess:!!r,valid:l&&u}};function tu({type:e="source",position:t=Y.Top,isValidConnection:n,isConnectable:i=!0,isConnectableStart:r=!0,isConnectableEnd:o=!0,id:s,onConnect:a,children:c,className:u,onMouseDown:l,onTouchStart:d,...h},f){var P,B;const g=s||null,y=e==="target",m=de(),v=oo(),{connectOnClick:w,noPanClassName:p,rfId:b}=re(Jc,ue),{connectingFrom:S,connectingTo:x,clickConnecting:C,isPossibleEndHandle:k,connectionInProcess:N,clickConnectionInProcess:G,valid:E}=re(eu(v,g,e),ue);v||(B=(P=m.getState()).onError)==null||B.call(P,"010",Ne.error010());const _=$=>{const{defaultEdgeOptions:R,onConnect:T,hasDefaultEdges:U}=m.getState(),z={...R,...$};if(U){const{edges:F,setEdges:V}=m.getState();V(La(z,F))}T==null||T(z),a==null||a(z)},I=$=>{if(!v)return;const R=Pr($.nativeEvent);if(r&&(R&&$.button===0||!R)){const T=m.getState();Tn.onPointerDown($.nativeEvent,{handleDomNode:$.currentTarget,autoPanOnConnect:T.autoPanOnConnect,connectionMode:T.connectionMode,connectionRadius:T.connectionRadius,domNode:T.domNode,nodeLookup:T.nodeLookup,lib:T.lib,isTarget:y,handleId:g,nodeId:v,flowId:T.rfId,panBy:T.panBy,cancelConnection:T.cancelConnection,onConnectStart:T.onConnectStart,onConnectEnd:(...U)=>{var z,F;return(F=(z=m.getState()).onConnectEnd)==null?void 0:F.call(z,...U)},updateConnection:T.updateConnection,onConnect:_,isValidConnection:n||((...U)=>{var z,F;return((F=(z=m.getState()).isValidConnection)==null?void 0:F.call(z,...U))??!0}),getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,autoPanSpeed:T.autoPanSpeed,dragThreshold:T.connectionDragThreshold})}R?l==null||l($):d==null||d($)},M=$=>{const{onClickConnectStart:R,onClickConnectEnd:T,connectionClickStartHandle:U,connectionMode:z,isValidConnection:F,lib:V,rfId:q,nodeLookup:J,connection:te}=m.getState();if(!v||!U&&!r)return;if(!U){R==null||R($.nativeEvent,{nodeId:v,handleId:g,handleType:e}),m.setState({connectionClickStartHandle:{nodeId:v,type:e,id:g}});return}const ne=Lr($.target),j=n||F,{connection:Q,isValid:ie}=Tn.isValid($.nativeEvent,{handle:{nodeId:v,id:g,type:e},connectionMode:z,fromNodeId:U.nodeId,fromHandleId:U.id||null,fromType:U.type,isValidConnection:j,flowId:q,doc:ne,lib:V,nodeLookup:J});ie&&Q&&_(Q);const ee=structuredClone(te);delete ee.inProgress,ee.toPosition=ee.toHandle?ee.toHandle.position:null,T==null||T($,ee),m.setState({connectionClickStartHandle:null})};return A.jsx("div",{"data-handleid":g,"data-nodeid":v,"data-handlepos":t,"data-id":`${b}-${v}-${g}-${e}`,className:he(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",p,u,{source:!y,target:y,connectable:i,connectablestart:r,connectableend:o,clickconnecting:C,connectingfrom:S,connectingto:x,valid:E,connectionindicator:i&&(!N||k)&&(N||G?o:r)}]),onMouseDown:I,onTouchStart:I,onClick:w?M:void 0,ref:f,...h,children:c})}const jt=D.memo(to(tu));function nu({data:e,isConnectable:t,sourcePosition:n=Y.Bottom}){return A.jsxs(A.Fragment,{children:[e==null?void 0:e.label,A.jsx(jt,{type:"source",position:n,isConnectable:t})]})}function iu({data:e,isConnectable:t,targetPosition:n=Y.Top,sourcePosition:i=Y.Bottom}){return A.jsxs(A.Fragment,{children:[A.jsx(jt,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,A.jsx(jt,{type:"source",position:i,isConnectable:t})]})}function ru(){return null}function ou({data:e,isConnectable:t,targetPosition:n=Y.Top}){return A.jsxs(A.Fragment,{children:[A.jsx(jt,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Vt={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Ii={input:nu,default:iu,output:ou,group:ru};function su(e){var t,n,i,r;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((i=e.style)==null?void 0:i.width),height:e.height??((r=e.style)==null?void 0:r.height)}}const au=e=>{const{width:t,height:n,x:i,y:r}=_t(e.nodeLookup,{filter:o=>!!o.selected});return{width:Ce(t)?t:null,height:Ce(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${i}px,${r}px)`}};function cu({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const i=de(),{width:r,height:o,transformString:s,userSelectionActive:a}=re(au,ue),c=ro(),u=D.useRef(null);D.useEffect(()=>{var f;n||(f=u.current)==null||f.focus({preventScroll:!0})},[n]);const l=!a&&r!==null&&o!==null;if(io({nodeRef:u,disabled:!l}),!l)return null;const d=e?f=>{const g=i.getState().nodes.filter(y=>y.selected);e(f,g)}:void 0,h=f=>{Object.prototype.hasOwnProperty.call(Vt,f.key)&&(f.preventDefault(),c({direction:Vt[f.key],factor:f.shiftKey?4:1}))};return A.jsx("div",{className:he(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:A.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:r,height:o}})})}const Gi=typeof window<"u"?window:void 0,uu=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function so({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:o,onPaneScroll:s,paneClickDistance:a,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:l,selectionMode:d,onSelectionStart:h,onSelectionEnd:f,multiSelectionKeyCode:g,panActivationKeyCode:y,zoomActivationKeyCode:m,elementsSelectable:v,zoomOnScroll:w,zoomOnPinch:p,panOnScroll:b,panOnScrollSpeed:S,panOnScrollMode:x,zoomOnDoubleClick:C,panOnDrag:k,defaultViewport:N,translateExtent:G,minZoom:E,maxZoom:_,preventScrolling:I,onSelectionContextMenu:M,noWheelClassName:P,noPanClassName:B,disableKeyboardA11y:$,onViewportChange:R,isControlledViewport:T}){const{nodesSelectionActive:U,userSelectionActive:z}=re(uu,ue),F=St(u,{target:Gi}),V=St(y,{target:Gi}),q=V||k,J=V||b,te=l&&q!==!0,ne=F||z||te;return Hc({deleteKeyCode:c,multiSelectionKeyCode:g}),A.jsx(Wc,{onPaneContextMenu:o,elementsSelectable:v,zoomOnScroll:w,zoomOnPinch:p,panOnScroll:J,panOnScrollSpeed:S,panOnScrollMode:x,zoomOnDoubleClick:C,panOnDrag:!F&&q,defaultViewport:N,translateExtent:G,minZoom:E,maxZoom:_,zoomActivationKeyCode:m,preventScrolling:I,noWheelClassName:P,noPanClassName:B,onViewportChange:R,isControlledViewport:T,paneClickDistance:a,selectionOnDrag:te,children:A.jsxs(Kc,{onSelectionStart:h,onSelectionEnd:f,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:i,onPaneMouseLeave:r,onPaneContextMenu:o,onPaneScroll:s,panOnDrag:q,isSelecting:!!ne,selectionMode:d,selectionKeyPressed:F,paneClickDistance:a,selectionOnDrag:te,children:[e,U&&A.jsx(cu,{onSelectionContextMenu:M,noPanClassName:B,disableKeyboardA11y:$})]})})}so.displayName="FlowRenderer";const du=D.memo(so),lu=e=>t=>e?Fn(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function hu(e){return re(D.useCallback(lu(e),[e]),ue)}const fu=e=>e.updateNodeInternals;function gu(){const e=re(fu),[t]=D.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const i=new Map;n.forEach(r=>{const o=r.target.getAttribute("data-id");i.set(o,{id:o,nodeElement:r.target,force:!0})}),e(i)}));return D.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function pu({node:e,nodeType:t,hasDimensions:n,resizeObserver:i}){const r=de(),o=D.useRef(null),s=D.useRef(null),a=D.useRef(e.sourcePosition),c=D.useRef(e.targetPosition),u=D.useRef(t),l=n&&!!e.internals.handleBounds;return D.useEffect(()=>{o.current&&!e.hidden&&(!l||s.current!==o.current)&&(s.current&&(i==null||i.unobserve(s.current)),i==null||i.observe(o.current),s.current=o.current)},[l,e.hidden]),D.useEffect(()=>()=>{s.current&&(i==null||i.unobserve(s.current),s.current=null)},[]),D.useEffect(()=>{if(o.current){const d=u.current!==t,h=a.current!==e.sourcePosition,f=c.current!==e.targetPosition;(d||h||f)&&(u.current=t,a.current=e.sourcePosition,c.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function mu({id:e,onClick:t,onMouseEnter:n,onMouseMove:i,onMouseLeave:r,onContextMenu:o,onDoubleClick:s,nodesDraggable:a,elementsSelectable:c,nodesConnectable:u,nodesFocusable:l,resizeObserver:d,noDragClassName:h,noPanClassName:f,disableKeyboardA11y:g,rfId:y,nodeTypes:m,nodeClickDistance:v,onError:w}){const{node:p,internals:b,isParent:S}=re(j=>{const Q=j.nodeLookup.get(e),ie=j.parentLookup.has(e);return{node:Q,internals:Q.internals,isParent:ie}},ue);let x=p.type||"default",C=(m==null?void 0:m[x])||Ii[x];C===void 0&&(w==null||w("003",Ne.error003(x)),x="default",C=(m==null?void 0:m.default)||Ii.default);const k=!!(p.draggable||a&&typeof p.draggable>"u"),N=!!(p.selectable||c&&typeof p.selectable>"u"),G=!!(p.connectable||u&&typeof p.connectable>"u"),E=!!(p.focusable||l&&typeof p.focusable>"u"),_=de(),I=Rr(p),M=pu({node:p,nodeType:x,hasDimensions:I,resizeObserver:d}),P=io({nodeRef:M,disabled:p.hidden||!k,noDragClassName:h,handleSelector:p.dragHandle,nodeId:e,isSelectable:N,nodeClickDistance:v}),B=ro();if(p.hidden)return null;const $=De(p),R=su(p),T=N||k||t||n||i||r,U=n?j=>n(j,{...b.userNode}):void 0,z=i?j=>i(j,{...b.userNode}):void 0,F=r?j=>r(j,{...b.userNode}):void 0,V=o?j=>o(j,{...b.userNode}):void 0,q=s?j=>s(j,{...b.userNode}):void 0,J=j=>{const{selectNodesOnDrag:Q,nodeDragThreshold:ie}=_.getState();N&&(!Q||!k||ie>0)&&Rn({id:e,store:_,nodeRef:M}),t&&t(j,{...b.userNode})},te=j=>{if(!(Mr(j.nativeEvent)||g)){if(xr.includes(j.key)&&N){const Q=j.key==="Escape";Rn({id:e,store:_,unselect:Q,nodeRef:M})}else if(k&&p.selected&&Object.prototype.hasOwnProperty.call(Vt,j.key)){j.preventDefault();const{ariaLabelConfig:Q}=_.getState();_.setState({ariaLiveMessage:Q["node.a11yDescription.ariaLiveMessage"]({direction:j.key.replace("Arrow","").toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),B({direction:Vt[j.key],factor:j.shiftKey?4:1})}}},ne=()=>{var se;if(g||!((se=M.current)!=null&&se.matches(":focus-visible")))return;const{transform:j,width:Q,height:ie,autoPanOnNodeFocus:ee,setCenter:K}=_.getState();if(!ee)return;Fn(new Map([[e,p]]),{x:0,y:0,width:Q,height:ie},j,!0).length>0||K(p.position.x+$.width/2,p.position.y+$.height/2,{zoom:j[2]})};return A.jsx("div",{className:he(["react-flow__node",`react-flow__node-${x}`,{[f]:k},p.className,{selected:p.selected,selectable:N,parent:S,draggable:k,dragging:P}]),ref:M,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:T?"all":"none",visibility:I?"visible":"hidden",...p.style,...R},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:U,onMouseMove:z,onMouseLeave:F,onContextMenu:V,onClick:J,onDoubleClick:q,onKeyDown:E?te:void 0,tabIndex:E?0:void 0,onFocus:E?ne:void 0,role:p.ariaRole??(E?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${qr}-${y}`,"aria-label":p.ariaLabel,...p.domAttributes,children:A.jsx(Qc,{value:e,children:A.jsx(C,{id:e,data:p.data,type:x,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:p.selected??!1,selectable:N,draggable:k,deletable:p.deletable??!0,isConnectable:G,sourcePosition:p.sourcePosition,targetPosition:p.targetPosition,dragging:P,dragHandle:p.dragHandle,zIndex:b.z,parentId:p.parentId,...$})})})}var yu=D.memo(mu);const vu=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function ao(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:i,elementsSelectable:r,onError:o}=re(vu,ue),s=hu(e.onlyRenderVisibleElements),a=gu();return A.jsx("div",{className:"react-flow__nodes",style:Qt,children:s.map(c=>A.jsx(yu,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:a,nodesDraggable:t,nodesConnectable:n,nodesFocusable:i,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:o},c))})}ao.displayName="NodeRenderer";const wu=D.memo(ao);function bu(e){return re(D.useCallback(n=>{if(!e)return n.edges.map(r=>r.id);const i=[];if(n.width&&n.height)for(const r of n.edges){const o=n.nodeLookup.get(r.source),s=n.nodeLookup.get(r.target);o&&s&&ka({sourceNode:o,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&i.push(r.id)}return i},[e]),ue)}const xu=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return A.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Eu=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return A.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Fi={[Ot.Arrow]:xu,[Ot.ArrowClosed]:Eu};function Su(e){const t=de();return D.useMemo(()=>{var r,o;return Object.prototype.hasOwnProperty.call(Fi,e)?Fi[e]:((o=(r=t.getState()).onError)==null||o.call(r,"009",Ne.error009(e)),null)},[e])}const Cu=({id:e,type:t,color:n,width:i=12.5,height:r=12.5,markerUnits:o="strokeWidth",strokeWidth:s,orient:a="auto-start-reverse"})=>{const c=Su(t);return c?A.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:a,refX:"0",refY:"0",children:A.jsx(c,{color:n,strokeWidth:s})}):null},co=({defaultColor:e,rfId:t})=>{const n=re(o=>o.edges),i=re(o=>o.defaultEdgeOptions),r=D.useMemo(()=>Fa(n,{id:t,defaultColor:e,defaultMarkerStart:i==null?void 0:i.markerStart,defaultMarkerEnd:i==null?void 0:i.markerEnd}),[n,i,t,e]);return r.length?A.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:A.jsx("defs",{children:r.map(o=>A.jsx(Cu,{id:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient},o.id))})}):null};co.displayName="MarkerDefinitions";var _u=D.memo(co);function uo({x:e,y:t,label:n,labelStyle:i,labelShowBg:r=!0,labelBgStyle:o,labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:c,className:u,...l}){const[d,h]=D.useState({x:1,y:0,width:0,height:0}),f=he(["react-flow__edge-textwrapper",u]),g=D.useRef(null);return D.useEffect(()=>{if(g.current){const y=g.current.getBBox();h({x:y.x,y:y.y,width:y.width,height:y.height})}},[n]),n?A.jsxs("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:f,visibility:d.width?"visible":"hidden",...l,children:[r&&A.jsx("rect",{width:d.width+2*s[0],x:-s[0],y:-s[1],height:d.height+2*s[1],className:"react-flow__edge-textbg",style:o,rx:a,ry:a}),A.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:g,style:i,children:n}),c]}):null}uo.displayName="EdgeText";const Nu=D.memo(uo);function Jt({path:e,labelX:t,labelY:n,label:i,labelStyle:r,labelShowBg:o,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c,interactionWidth:u=20,...l}){return A.jsxs(A.Fragment,{children:[A.jsx("path",{...l,d:e,fill:"none",className:he(["react-flow__edge-path",l.className])}),u?A.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,i&&Ce(t)&&Ce(n)?A.jsx(Nu,{x:t,y:n,label:i,labelStyle:r,labelShowBg:o,labelBgStyle:s,labelBgPadding:a,labelBgBorderRadius:c}):null]})}function $i({pos:e,x1:t,y1:n,x2:i,y2:r}){return e===Y.Left||e===Y.Right?[.5*(t+i),n]:[t,.5*(n+r)]}function lo({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:i,targetY:r,targetPosition:o=Y.Top}){const[s,a]=$i({pos:n,x1:e,y1:t,x2:i,y2:r}),[c,u]=$i({pos:o,x1:i,y1:r,x2:e,y2:t}),[l,d,h,f]=Ir({sourceX:e,sourceY:t,targetX:i,targetY:r,sourceControlX:s,sourceControlY:a,targetControlX:c,targetControlY:u});return[`M${e},${t} C${s},${a} ${c},${u} ${i},${r}`,l,d,h,f]}function ho(e){return D.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:o,sourcePosition:s,targetPosition:a,label:c,labelStyle:u,labelShowBg:l,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:y,markerStart:m,interactionWidth:v})=>{const[w,p,b]=lo({sourceX:n,sourceY:i,sourcePosition:s,targetX:r,targetY:o,targetPosition:a}),S=e.isInternal?void 0:t;return A.jsx(Jt,{id:S,path:w,labelX:p,labelY:b,label:c,labelStyle:u,labelShowBg:l,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:y,markerStart:m,interactionWidth:v})})}const Au=ho({isInternal:!1}),fo=ho({isInternal:!0});Au.displayName="SimpleBezierEdge";fo.displayName="SimpleBezierEdgeInternal";function go(e){return D.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:o,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:l,labelBgBorderRadius:d,style:h,sourcePosition:f=Y.Bottom,targetPosition:g=Y.Top,markerEnd:y,markerStart:m,pathOptions:v,interactionWidth:w})=>{const[p,b,S]=_n({sourceX:n,sourceY:i,sourcePosition:f,targetX:r,targetY:o,targetPosition:g,borderRadius:v==null?void 0:v.borderRadius,offset:v==null?void 0:v.offset,stepPosition:v==null?void 0:v.stepPosition}),x=e.isInternal?void 0:t;return A.jsx(Jt,{id:x,path:p,labelX:b,labelY:S,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:l,labelBgBorderRadius:d,style:h,markerEnd:y,markerStart:m,interactionWidth:w})})}const po=go({isInternal:!1}),mo=go({isInternal:!0});po.displayName="SmoothStepEdge";mo.displayName="SmoothStepEdgeInternal";function yo(e){return D.memo(({id:t,...n})=>{var r;const i=e.isInternal?void 0:t;return A.jsx(po,{...n,id:i,pathOptions:D.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(r=n.pathOptions)==null?void 0:r.offset])})})}const Tu=yo({isInternal:!1}),vo=yo({isInternal:!0});Tu.displayName="StepEdge";vo.displayName="StepEdgeInternal";function wo(e){return D.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:o,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:l,labelBgBorderRadius:d,style:h,markerEnd:f,markerStart:g,interactionWidth:y})=>{const[m,v,w]=$r({sourceX:n,sourceY:i,targetX:r,targetY:o}),p=e.isInternal?void 0:t;return A.jsx(Jt,{id:p,path:m,labelX:v,labelY:w,label:s,labelStyle:a,labelShowBg:c,labelBgStyle:u,labelBgPadding:l,labelBgBorderRadius:d,style:h,markerEnd:f,markerStart:g,interactionWidth:y})})}const ku=wo({isInternal:!1}),bo=wo({isInternal:!0});ku.displayName="StraightEdge";bo.displayName="StraightEdgeInternal";function xo(e){return D.memo(({id:t,sourceX:n,sourceY:i,targetX:r,targetY:o,sourcePosition:s=Y.Bottom,targetPosition:a=Y.Top,label:c,labelStyle:u,labelShowBg:l,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:y,markerStart:m,pathOptions:v,interactionWidth:w})=>{const[p,b,S]=Gr({sourceX:n,sourceY:i,sourcePosition:s,targetX:r,targetY:o,targetPosition:a,curvature:v==null?void 0:v.curvature}),x=e.isInternal?void 0:t;return A.jsx(Jt,{id:x,path:p,labelX:b,labelY:S,label:c,labelStyle:u,labelShowBg:l,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:g,markerEnd:y,markerStart:m,interactionWidth:w})})}const Ru=xo({isInternal:!1}),Eo=xo({isInternal:!0});Ru.displayName="BezierEdge";Eo.displayName="BezierEdgeInternal";const zi={default:Eo,straight:bo,step:vo,smoothstep:mo,simplebezier:fo},Bi={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},Du=(e,t,n)=>n===Y.Left?e-t:n===Y.Right?e+t:e,Lu=(e,t,n)=>n===Y.Top?e-t:n===Y.Bottom?e+t:e,Oi="react-flow__edgeupdater";function Ui({position:e,centerX:t,centerY:n,radius:i=10,onMouseDown:r,onMouseEnter:o,onMouseOut:s,type:a}){return A.jsx("circle",{onMouseDown:r,onMouseEnter:o,onMouseOut:s,className:he([Oi,`${Oi}-${a}`]),cx:Du(t,i,e),cy:Lu(n,i,e),r:i,stroke:"transparent",fill:"transparent"})}function Mu({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:i,sourceY:r,targetX:o,targetY:s,sourcePosition:a,targetPosition:c,onReconnect:u,onReconnectStart:l,onReconnectEnd:d,setReconnecting:h,setUpdateHover:f}){const g=de(),y=(b,S)=>{if(b.button!==0)return;const{autoPanOnConnect:x,domNode:C,connectionMode:k,connectionRadius:N,lib:G,onConnectStart:E,cancelConnection:_,nodeLookup:I,rfId:M,panBy:P,updateConnection:B}=g.getState(),$=S.type==="target",R=(z,F)=>{h(!1),d==null||d(z,n,S.type,F)},T=z=>u==null?void 0:u(n,z),U=(z,F)=>{h(!0),l==null||l(b,n,S.type),E==null||E(z,F)};Tn.onPointerDown(b.nativeEvent,{autoPanOnConnect:x,connectionMode:k,connectionRadius:N,domNode:C,handleId:S.id,nodeId:S.nodeId,nodeLookup:I,isTarget:$,edgeUpdaterType:S.type,lib:G,flowId:M,cancelConnection:_,panBy:P,isValidConnection:(...z)=>{var F,V;return((V=(F=g.getState()).isValidConnection)==null?void 0:V.call(F,...z))??!0},onConnect:T,onConnectStart:U,onConnectEnd:(...z)=>{var F,V;return(V=(F=g.getState()).onConnectEnd)==null?void 0:V.call(F,...z)},onReconnectEnd:R,updateConnection:B,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:b.currentTarget})},m=b=>y(b,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),v=b=>y(b,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),w=()=>f(!0),p=()=>f(!1);return A.jsxs(A.Fragment,{children:[(e===!0||e==="source")&&A.jsx(Ui,{position:a,centerX:i,centerY:r,radius:t,onMouseDown:m,onMouseEnter:w,onMouseOut:p,type:"source"}),(e===!0||e==="target")&&A.jsx(Ui,{position:c,centerX:o,centerY:s,radius:t,onMouseDown:v,onMouseEnter:w,onMouseOut:p,type:"target"})]})}function Pu({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:i,onClick:r,onDoubleClick:o,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:u,reconnectRadius:l,onReconnect:d,onReconnectStart:h,onReconnectEnd:f,rfId:g,edgeTypes:y,noPanClassName:m,onError:v,disableKeyboardA11y:w}){let p=re(K=>K.edgeLookup.get(e));const b=re(K=>K.defaultEdgeOptions);p=b?{...b,...p}:p;let S=p.type||"default",x=(y==null?void 0:y[S])||zi[S];x===void 0&&(v==null||v("011",Ne.error011(S)),S="default",x=(y==null?void 0:y.default)||zi.default);const C=!!(p.focusable||t&&typeof p.focusable>"u"),k=typeof d<"u"&&(p.reconnectable||n&&typeof p.reconnectable>"u"),N=!!(p.selectable||i&&typeof p.selectable>"u"),G=D.useRef(null),[E,_]=D.useState(!1),[I,M]=D.useState(!1),P=de(),{zIndex:B,sourceX:$,sourceY:R,targetX:T,targetY:U,sourcePosition:z,targetPosition:F}=re(D.useCallback(K=>{const Z=K.nodeLookup.get(p.source),se=K.nodeLookup.get(p.target);if(!Z||!se)return{zIndex:p.zIndex,...Bi};const ce=Ga({id:e,sourceNode:Z,targetNode:se,sourceHandle:p.sourceHandle||null,targetHandle:p.targetHandle||null,connectionMode:K.connectionMode,onError:v});return{zIndex:Ta({selected:p.selected,zIndex:p.zIndex,sourceNode:Z,targetNode:se,elevateOnSelect:K.elevateEdgesOnSelect,zIndexMode:K.zIndexMode}),...ce||Bi}},[p.source,p.target,p.sourceHandle,p.targetHandle,p.selected,p.zIndex]),ue),V=D.useMemo(()=>p.markerStart?`url('#${Nn(p.markerStart,g)}')`:void 0,[p.markerStart,g]),q=D.useMemo(()=>p.markerEnd?`url('#${Nn(p.markerEnd,g)}')`:void 0,[p.markerEnd,g]);if(p.hidden||$===null||R===null||T===null||U===null)return null;const J=K=>{var oe;const{addSelectedEdges:Z,unselectNodesAndEdges:se,multiSelectionActive:ce}=P.getState();N&&(P.setState({nodesSelectionActive:!1}),p.selected&&ce?(se({nodes:[],edges:[p]}),(oe=G.current)==null||oe.blur()):Z([e])),r&&r(K,p)},te=o?K=>{o(K,{...p})}:void 0,ne=s?K=>{s(K,{...p})}:void 0,j=a?K=>{a(K,{...p})}:void 0,Q=c?K=>{c(K,{...p})}:void 0,ie=u?K=>{u(K,{...p})}:void 0,ee=K=>{var Z;if(!w&&xr.includes(K.key)&&N){const{unselectNodesAndEdges:se,addSelectedEdges:ce}=P.getState();K.key==="Escape"?((Z=G.current)==null||Z.blur(),se({edges:[p]})):ce([e])}};return A.jsx("svg",{style:{zIndex:B},children:A.jsxs("g",{className:he(["react-flow__edge",`react-flow__edge-${S}`,p.className,m,{selected:p.selected,animated:p.animated,inactive:!N&&!r,updating:E,selectable:N}]),onClick:J,onDoubleClick:te,onContextMenu:ne,onMouseEnter:j,onMouseMove:Q,onMouseLeave:ie,onKeyDown:C?ee:void 0,tabIndex:C?0:void 0,role:p.ariaRole??(C?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":p.ariaLabel===null?void 0:p.ariaLabel||`Edge from ${p.source} to ${p.target}`,"aria-describedby":C?`${Qr}-${g}`:void 0,ref:G,...p.domAttributes,children:[!I&&A.jsx(x,{id:e,source:p.source,target:p.target,type:p.type,selected:p.selected,animated:p.animated,selectable:N,deletable:p.deletable??!0,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,sourceX:$,sourceY:R,targetX:T,targetY:U,sourcePosition:z,targetPosition:F,data:p.data,style:p.style,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerStart:V,markerEnd:q,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth}),k&&A.jsx(Mu,{edge:p,isReconnectable:k,reconnectRadius:l,onReconnect:d,onReconnectStart:h,onReconnectEnd:f,sourceX:$,sourceY:R,targetX:T,targetY:U,sourcePosition:z,targetPosition:F,setUpdateHover:_,setReconnecting:M})]})})}var Iu=D.memo(Pu);const Gu=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function So({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:i,noPanClassName:r,onReconnect:o,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:l,reconnectRadius:d,onEdgeDoubleClick:h,onReconnectStart:f,onReconnectEnd:g,disableKeyboardA11y:y}){const{edgesFocusable:m,edgesReconnectable:v,elementsSelectable:w,onError:p}=re(Gu,ue),b=bu(t);return A.jsxs("div",{className:"react-flow__edges",children:[A.jsx(_u,{defaultColor:e,rfId:n}),b.map(S=>A.jsx(Iu,{id:S,edgesFocusable:m,edgesReconnectable:v,elementsSelectable:w,noPanClassName:r,onReconnect:o,onContextMenu:s,onMouseEnter:a,onMouseMove:c,onMouseLeave:u,onClick:l,reconnectRadius:d,onDoubleClick:h,onReconnectStart:f,onReconnectEnd:g,rfId:n,onError:p,edgeTypes:i,disableKeyboardA11y:y},S))]})}So.displayName="EdgeRenderer";const Fu=D.memo(So),$u=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function zu({children:e}){const t=re($u);return A.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function Bu(e){const t=Vn(),n=D.useRef(!1);D.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Ou=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function Uu(e){const t=re(Ou),n=de();return D.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Hu(e){return e.connection.inProgress?{...e.connection,to:At(e.connection.to,e.transform)}:{...e.connection}}function ju(e){return Hu}function Vu(e){const t=ju();return re(t,ue)}const Wu=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Yu({containerStyle:e,style:t,type:n,component:i}){const{nodesConnectable:r,width:o,height:s,isValid:a,inProgress:c}=re(Wu,ue);return!(o&&r&&c)?null:A.jsx("svg",{style:e,width:o,height:s,className:"react-flow__connectionline react-flow__container",children:A.jsx("g",{className:he(["react-flow__connection",Cr(a)]),children:A.jsx(Co,{style:t,type:n,CustomComponent:i,isValid:a})})})}const Co=({style:e,type:t=Fe.Bezier,CustomComponent:n,isValid:i})=>{const{inProgress:r,from:o,fromNode:s,fromHandle:a,fromPosition:c,to:u,toNode:l,toHandle:d,toPosition:h,pointer:f}=Vu();if(!r)return;if(n)return A.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:a,fromX:o.x,fromY:o.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:h,connectionStatus:Cr(i),toNode:l,toHandle:d,pointer:f});let g="";const y={sourceX:o.x,sourceY:o.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:h};switch(t){case Fe.Bezier:[g]=Gr(y);break;case Fe.SimpleBezier:[g]=lo(y);break;case Fe.Step:[g]=_n({...y,borderRadius:0});break;case Fe.SmoothStep:[g]=_n(y);break;default:[g]=$r(y)}return A.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};Co.displayName="ConnectionLine";const Xu={};function Hi(e=Xu){D.useRef(e),de(),D.useEffect(()=>{},[e])}function Zu(){de(),D.useRef(!1),D.useEffect(()=>{},[])}function _o({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:i,onEdgeClick:r,onNodeDoubleClick:o,onEdgeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:l,onSelectionContextMenu:d,onSelectionStart:h,onSelectionEnd:f,connectionLineType:g,connectionLineStyle:y,connectionLineComponent:m,connectionLineContainerStyle:v,selectionKeyCode:w,selectionOnDrag:p,selectionMode:b,multiSelectionKeyCode:S,panActivationKeyCode:x,zoomActivationKeyCode:C,deleteKeyCode:k,onlyRenderVisibleElements:N,elementsSelectable:G,defaultViewport:E,translateExtent:_,minZoom:I,maxZoom:M,preventScrolling:P,defaultMarkerColor:B,zoomOnScroll:$,zoomOnPinch:R,panOnScroll:T,panOnScrollSpeed:U,panOnScrollMode:z,zoomOnDoubleClick:F,panOnDrag:V,onPaneClick:q,onPaneMouseEnter:J,onPaneMouseMove:te,onPaneMouseLeave:ne,onPaneScroll:j,onPaneContextMenu:Q,paneClickDistance:ie,nodeClickDistance:ee,onEdgeContextMenu:K,onEdgeMouseEnter:Z,onEdgeMouseMove:se,onEdgeMouseLeave:ce,reconnectRadius:oe,onReconnect:ge,onReconnectStart:Me,onReconnectEnd:Ae,noDragClassName:ze,noWheelClassName:at,noPanClassName:ct,disableKeyboardA11y:ut,nodeExtent:nn,rfId:kt,viewport:Ve,onViewportChange:dt}){return Hi(e),Hi(t),Zu(),Bu(n),Uu(Ve),A.jsx(du,{onPaneClick:q,onPaneMouseEnter:J,onPaneMouseMove:te,onPaneMouseLeave:ne,onPaneContextMenu:Q,onPaneScroll:j,paneClickDistance:ie,deleteKeyCode:k,selectionKeyCode:w,selectionOnDrag:p,selectionMode:b,onSelectionStart:h,onSelectionEnd:f,multiSelectionKeyCode:S,panActivationKeyCode:x,zoomActivationKeyCode:C,elementsSelectable:G,zoomOnScroll:$,zoomOnPinch:R,zoomOnDoubleClick:F,panOnScroll:T,panOnScrollSpeed:U,panOnScrollMode:z,panOnDrag:V,defaultViewport:E,translateExtent:_,minZoom:I,maxZoom:M,onSelectionContextMenu:d,preventScrolling:P,noDragClassName:ze,noWheelClassName:at,noPanClassName:ct,disableKeyboardA11y:ut,onViewportChange:dt,isControlledViewport:!!Ve,children:A.jsxs(zu,{children:[A.jsx(Fu,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:s,onReconnect:ge,onReconnectStart:Me,onReconnectEnd:Ae,onlyRenderVisibleElements:N,onEdgeContextMenu:K,onEdgeMouseEnter:Z,onEdgeMouseMove:se,onEdgeMouseLeave:ce,reconnectRadius:oe,defaultMarkerColor:B,noPanClassName:ct,disableKeyboardA11y:ut,rfId:kt}),A.jsx(Yu,{style:y,type:g,component:m,containerStyle:v}),A.jsx("div",{className:"react-flow__edgelabel-renderer"}),A.jsx(wu,{nodeTypes:e,onNodeClick:i,onNodeDoubleClick:o,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:l,nodeClickDistance:ee,onlyRenderVisibleElements:N,noPanClassName:ct,noDragClassName:ze,disableKeyboardA11y:ut,nodeExtent:nn,rfId:kt}),A.jsx("div",{className:"react-flow__viewport-portal"})]})})}_o.displayName="GraphView";const Ku=D.memo(_o),ji=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:o,fitView:s,fitViewOptions:a,minZoom:c=.5,maxZoom:u=2,nodeOrigin:l,nodeExtent:d,zIndexMode:h="basic"}={})=>{const f=new Map,g=new Map,y=new Map,m=new Map,v=i??t??[],w=n??e??[],p=l??[0,0],b=d??wt;Or(y,m,v);const{nodesInitialized:S}=An(w,f,g,{nodeOrigin:p,nodeExtent:b,zIndexMode:h});let x=[0,0,1];if(s&&r&&o){const C=_t(f,{filter:E=>!!((E.width||E.initialWidth)&&(E.height||E.initialHeight))}),{x:k,y:N,zoom:G}=$n(C,r,o,c,u,(a==null?void 0:a.padding)??.1);x=[k,N,G]}return{rfId:"1",width:r??0,height:o??0,transform:x,nodes:w,nodesInitialized:S,nodeLookup:f,parentLookup:g,edges:v,edgeLookup:m,connectionLookup:y,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:i!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:wt,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:qe.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:p,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:a,fitViewResolver:null,connection:{...Sr},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Ea,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Er,zIndexMode:h,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},qu=({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:o,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:u,nodeOrigin:l,nodeExtent:d,zIndexMode:h})=>pa((f,g)=>{async function y(){const{nodeLookup:m,panZoom:v,fitViewOptions:w,fitViewResolver:p,width:b,height:S,minZoom:x,maxZoom:C}=g();v&&(await ba({nodes:m,width:b,height:S,panZoom:v,minZoom:x,maxZoom:C},w),p==null||p.resolve(!0),f({fitViewResolver:null}))}return{...ji({nodes:e,edges:t,width:r,height:o,fitView:s,fitViewOptions:a,minZoom:c,maxZoom:u,nodeOrigin:l,nodeExtent:d,defaultNodes:n,defaultEdges:i,zIndexMode:h}),setNodes:m=>{const{nodeLookup:v,parentLookup:w,nodeOrigin:p,elevateNodesOnSelect:b,fitViewQueued:S,zIndexMode:x,nodesSelectionActive:C}=g(),{nodesInitialized:k,hasSelectedNodes:N}=An(m,v,w,{nodeOrigin:p,nodeExtent:d,elevateNodesOnSelect:b,checkEquality:!0,zIndexMode:x}),G=C&&N;S&&k?(y(),f({nodes:m,nodesInitialized:k,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:G})):f({nodes:m,nodesInitialized:k,nodesSelectionActive:G})},setEdges:m=>{const{connectionLookup:v,edgeLookup:w}=g();Or(v,w,m),f({edges:m})},setDefaultNodesAndEdges:(m,v)=>{if(m){const{setNodes:w}=g();w(m),f({hasDefaultNodes:!0})}if(v){const{setEdges:w}=g();w(v),f({hasDefaultEdges:!0})}},updateNodeInternals:m=>{const{triggerNodeChanges:v,nodeLookup:w,parentLookup:p,domNode:b,nodeOrigin:S,nodeExtent:x,debug:C,fitViewQueued:k,zIndexMode:N}=g(),{changes:G,updatedInternals:E}=ja(m,w,p,b,S,x,N);E&&(Ba(w,p,{nodeOrigin:S,nodeExtent:x,zIndexMode:N}),k?(y(),f({fitViewQueued:!1,fitViewOptions:void 0})):f({}),(G==null?void 0:G.length)>0&&(C&&console.log("React Flow: trigger node changes",G),v==null||v(G)))},updateNodePositions:(m,v=!1)=>{const w=[];let p=[];const{nodeLookup:b,triggerNodeChanges:S,connection:x,updateConnection:C,onNodesChangeMiddlewareMap:k}=g();for(const[N,G]of m){const E=b.get(N),_=!!(E!=null&&E.expandParent&&(E!=null&&E.parentId)&&(G!=null&&G.position)),I={id:N,type:"position",position:_?{x:Math.max(0,G.position.x),y:Math.max(0,G.position.y)}:G.position,dragging:v};if(E&&x.inProgress&&x.fromNode.id===E.id){const M=je(E,x.fromHandle,Y.Left,!0);C({...x,from:M})}_&&E.parentId&&w.push({id:N,parentId:E.parentId,rect:{...G.internals.positionAbsolute,width:G.measured.width??0,height:G.measured.height??0}}),p.push(I)}if(w.length>0){const{parentLookup:N,nodeOrigin:G}=g(),E=jn(w,b,N,G);p.push(...E)}for(const N of k.values())p=N(p);S(p)},triggerNodeChanges:m=>{const{onNodesChange:v,setNodes:w,nodes:p,hasDefaultNodes:b,debug:S}=g();if(m!=null&&m.length){if(b){const x=Ic(m,p);w(x)}S&&console.log("React Flow: trigger node changes",m),v==null||v(m)}},triggerEdgeChanges:m=>{const{onEdgesChange:v,setEdges:w,edges:p,hasDefaultEdges:b,debug:S}=g();if(m!=null&&m.length){if(b){const x=Gc(m,p);w(x)}S&&console.log("React Flow: trigger edge changes",m),v==null||v(m)}},addSelectedNodes:m=>{const{multiSelectionActive:v,edgeLookup:w,nodeLookup:p,triggerNodeChanges:b,triggerEdgeChanges:S}=g();if(v){const x=m.map(C=>Oe(C,!0));b(x);return}b(Ze(p,new Set([...m]),!0)),S(Ze(w))},addSelectedEdges:m=>{const{multiSelectionActive:v,edgeLookup:w,nodeLookup:p,triggerNodeChanges:b,triggerEdgeChanges:S}=g();if(v){const x=m.map(C=>Oe(C,!0));S(x);return}S(Ze(w,new Set([...m]))),b(Ze(p,new Set,!0))},unselectNodesAndEdges:({nodes:m,edges:v}={})=>{const{edges:w,nodes:p,nodeLookup:b,triggerNodeChanges:S,triggerEdgeChanges:x}=g(),C=m||p,k=v||w,N=[];for(const E of C){if(!E.selected)continue;const _=b.get(E.id);_&&(_.selected=!1),N.push(Oe(E.id,!1))}const G=[];for(const E of k)E.selected&&G.push(Oe(E.id,!1));S(N),x(G)},setMinZoom:m=>{const{panZoom:v,maxZoom:w}=g();v==null||v.setScaleExtent([m,w]),f({minZoom:m})},setMaxZoom:m=>{const{panZoom:v,minZoom:w}=g();v==null||v.setScaleExtent([w,m]),f({maxZoom:m})},setTranslateExtent:m=>{var v;(v=g().panZoom)==null||v.setTranslateExtent(m),f({translateExtent:m})},resetSelectedElements:()=>{const{edges:m,nodes:v,triggerNodeChanges:w,triggerEdgeChanges:p,elementsSelectable:b}=g();if(!b)return;const S=v.reduce((C,k)=>k.selected?[...C,Oe(k.id,!1)]:C,[]),x=m.reduce((C,k)=>k.selected?[...C,Oe(k.id,!1)]:C,[]);w(S),p(x)},setNodeExtent:m=>{const{nodes:v,nodeLookup:w,parentLookup:p,nodeOrigin:b,elevateNodesOnSelect:S,nodeExtent:x,zIndexMode:C}=g();m[0][0]===x[0][0]&&m[0][1]===x[0][1]&&m[1][0]===x[1][0]&&m[1][1]===x[1][1]||(An(v,w,p,{nodeOrigin:b,nodeExtent:m,elevateNodesOnSelect:S,checkEquality:!1,zIndexMode:C}),f({nodeExtent:m}))},panBy:m=>{const{transform:v,width:w,height:p,panZoom:b,translateExtent:S}=g();return Va({delta:m,panZoom:b,transform:v,translateExtent:S,width:w,height:p})},setCenter:async(m,v,w)=>{const{width:p,height:b,maxZoom:S,panZoom:x}=g();if(!x)return Promise.resolve(!1);const C=typeof(w==null?void 0:w.zoom)<"u"?w.zoom:S;return await x.setViewport({x:p/2-m*C,y:b/2-v*C,zoom:C},{duration:w==null?void 0:w.duration,ease:w==null?void 0:w.ease,interpolate:w==null?void 0:w.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{f({connection:{...Sr}})},updateConnection:m=>{f({connection:m})},reset:()=>f({...ji()})}},Object.is);function Qu({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:i,initialWidth:r,initialHeight:o,initialMinZoom:s,initialMaxZoom:a,initialFitViewOptions:c,fitView:u,nodeOrigin:l,nodeExtent:d,zIndexMode:h,children:f}){const[g]=D.useState(()=>qu({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,width:r,height:o,fitView:u,minZoom:s,maxZoom:a,fitViewOptions:c,nodeOrigin:l,nodeExtent:d,zIndexMode:h}));return A.jsx(pc,{value:g,children:A.jsx(zc,{children:f})})}function Ju({children:e,nodes:t,edges:n,defaultNodes:i,defaultEdges:r,width:o,height:s,fitView:a,fitViewOptions:c,minZoom:u,maxZoom:l,nodeOrigin:d,nodeExtent:h,zIndexMode:f}){return D.useContext(Kt)?A.jsx(A.Fragment,{children:e}):A.jsx(Qu,{initialNodes:t,initialEdges:n,defaultNodes:i,defaultEdges:r,initialWidth:o,initialHeight:s,fitView:a,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:l,nodeOrigin:d,nodeExtent:h,zIndexMode:f,children:e})}const ed={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function td({nodes:e,edges:t,defaultNodes:n,defaultEdges:i,className:r,nodeTypes:o,edgeTypes:s,onNodeClick:a,onEdgeClick:c,onInit:u,onMove:l,onMoveStart:d,onMoveEnd:h,onConnect:f,onConnectStart:g,onConnectEnd:y,onClickConnectStart:m,onClickConnectEnd:v,onNodeMouseEnter:w,onNodeMouseMove:p,onNodeMouseLeave:b,onNodeContextMenu:S,onNodeDoubleClick:x,onNodeDragStart:C,onNodeDrag:k,onNodeDragStop:N,onNodesDelete:G,onEdgesDelete:E,onDelete:_,onSelectionChange:I,onSelectionDragStart:M,onSelectionDrag:P,onSelectionDragStop:B,onSelectionContextMenu:$,onSelectionStart:R,onSelectionEnd:T,onBeforeDelete:U,connectionMode:z,connectionLineType:F=Fe.Bezier,connectionLineStyle:V,connectionLineComponent:q,connectionLineContainerStyle:J,deleteKeyCode:te="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:j=!1,selectionMode:Q=bt.Full,panActivationKeyCode:ie="Space",multiSelectionKeyCode:ee=Et()?"Meta":"Control",zoomActivationKeyCode:K=Et()?"Meta":"Control",snapToGrid:Z,snapGrid:se,onlyRenderVisibleElements:ce=!1,selectNodesOnDrag:oe,nodesDraggable:ge,autoPanOnNodeFocus:Me,nodesConnectable:Ae,nodesFocusable:ze,nodeOrigin:at=Jr,edgesFocusable:ct,edgesReconnectable:ut,elementsSelectable:nn=!0,defaultViewport:kt=Tc,minZoom:Ve=.5,maxZoom:dt=2,translateExtent:ei=wt,preventScrolling:cs=!0,nodeExtent:rn,defaultMarkerColor:us="#b1b1b7",zoomOnScroll:ds=!0,zoomOnPinch:ls=!0,panOnScroll:hs=!1,panOnScrollSpeed:fs=.5,panOnScrollMode:gs=Ue.Free,zoomOnDoubleClick:ps=!0,panOnDrag:ms=!0,onPaneClick:ys,onPaneMouseEnter:vs,onPaneMouseMove:ws,onPaneMouseLeave:bs,onPaneScroll:xs,onPaneContextMenu:Es,paneClickDistance:Ss=1,nodeClickDistance:Cs=0,children:_s,onReconnect:Ns,onReconnectStart:As,onReconnectEnd:Ts,onEdgeContextMenu:ks,onEdgeDoubleClick:Rs,onEdgeMouseEnter:Ds,onEdgeMouseMove:Ls,onEdgeMouseLeave:Ms,reconnectRadius:Ps=10,onNodesChange:Is,onEdgesChange:Gs,noDragClassName:Fs="nodrag",noWheelClassName:$s="nowheel",noPanClassName:ti="nopan",fitView:ni,fitViewOptions:ii,connectOnClick:zs,attributionPosition:Bs,proOptions:Os,defaultEdgeOptions:Us,elevateNodesOnSelect:Hs=!0,elevateEdgesOnSelect:js=!1,disableKeyboardA11y:ri=!1,autoPanOnConnect:Vs,autoPanOnNodeDrag:Ws,autoPanSpeed:Ys,connectionRadius:Xs,isValidConnection:Zs,onError:Ks,style:qs,id:oi,nodeDragThreshold:Qs,connectionDragThreshold:Js,viewport:ea,onViewportChange:ta,width:na,height:ia,colorMode:ra="light",debug:oa,onScroll:Rt,ariaLabelConfig:sa,zIndexMode:si="basic",...aa},ca){const on=oi||"1",ua=Lc(ra),da=D.useCallback(ai=>{ai.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Rt==null||Rt(ai)},[Rt]);return A.jsx("div",{"data-testid":"rf__wrapper",...aa,onScroll:da,style:{...qs,...ed},ref:ca,className:he(["react-flow",r,ua]),id:oi,role:"application",children:A.jsxs(Ju,{nodes:e,edges:t,width:na,height:ia,fitView:ni,fitViewOptions:ii,minZoom:Ve,maxZoom:dt,nodeOrigin:at,nodeExtent:rn,zIndexMode:si,children:[A.jsx(Dc,{nodes:e,edges:t,defaultNodes:n,defaultEdges:i,onConnect:f,onConnectStart:g,onConnectEnd:y,onClickConnectStart:m,onClickConnectEnd:v,nodesDraggable:ge,autoPanOnNodeFocus:Me,nodesConnectable:Ae,nodesFocusable:ze,edgesFocusable:ct,edgesReconnectable:ut,elementsSelectable:nn,elevateNodesOnSelect:Hs,elevateEdgesOnSelect:js,minZoom:Ve,maxZoom:dt,nodeExtent:rn,onNodesChange:Is,onEdgesChange:Gs,snapToGrid:Z,snapGrid:se,connectionMode:z,translateExtent:ei,connectOnClick:zs,defaultEdgeOptions:Us,fitView:ni,fitViewOptions:ii,onNodesDelete:G,onEdgesDelete:E,onDelete:_,onNodeDragStart:C,onNodeDrag:k,onNodeDragStop:N,onSelectionDrag:P,onSelectionDragStart:M,onSelectionDragStop:B,onMove:l,onMoveStart:d,onMoveEnd:h,noPanClassName:ti,nodeOrigin:at,rfId:on,autoPanOnConnect:Vs,autoPanOnNodeDrag:Ws,autoPanSpeed:Ys,onError:Ks,connectionRadius:Xs,isValidConnection:Zs,selectNodesOnDrag:oe,nodeDragThreshold:Qs,connectionDragThreshold:Js,onBeforeDelete:U,debug:oa,ariaLabelConfig:sa,zIndexMode:si}),A.jsx(Ku,{onInit:u,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:w,onNodeMouseMove:p,onNodeMouseLeave:b,onNodeContextMenu:S,onNodeDoubleClick:x,nodeTypes:o,edgeTypes:s,connectionLineType:F,connectionLineStyle:V,connectionLineComponent:q,connectionLineContainerStyle:J,selectionKeyCode:ne,selectionOnDrag:j,selectionMode:Q,deleteKeyCode:te,multiSelectionKeyCode:ee,panActivationKeyCode:ie,zoomActivationKeyCode:K,onlyRenderVisibleElements:ce,defaultViewport:kt,translateExtent:ei,minZoom:Ve,maxZoom:dt,preventScrolling:cs,zoomOnScroll:ds,zoomOnPinch:ls,zoomOnDoubleClick:ps,panOnScroll:hs,panOnScrollSpeed:fs,panOnScrollMode:gs,panOnDrag:ms,onPaneClick:ys,onPaneMouseEnter:vs,onPaneMouseMove:ws,onPaneMouseLeave:bs,onPaneScroll:xs,onPaneContextMenu:Es,paneClickDistance:Ss,nodeClickDistance:Cs,onSelectionContextMenu:$,onSelectionStart:R,onSelectionEnd:T,onReconnect:Ns,onReconnectStart:As,onReconnectEnd:Ts,onEdgeContextMenu:ks,onEdgeDoubleClick:Rs,onEdgeMouseEnter:Ds,onEdgeMouseMove:Ls,onEdgeMouseLeave:Ms,reconnectRadius:Ps,defaultMarkerColor:us,noDragClassName:Fs,noWheelClassName:$s,noPanClassName:ti,rfId:on,disableKeyboardA11y:ri,nodeExtent:rn,viewport:ea,onViewportChange:ta}),A.jsx(Ac,{onSelectionChange:I}),_s,A.jsx(Ec,{proOptions:Os,position:Bs}),A.jsx(xc,{rfId:on,disableKeyboardA11y:ri})]})})}var of=to(td);function nd({dimensions:e,lineWidth:t,variant:n,className:i}){return A.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:he(["react-flow__background-pattern",n,i])})}function id({radius:e,className:t}){return A.jsx("circle",{cx:e,cy:e,r:e,className:he(["react-flow__background-pattern","dots",t])})}var $e;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})($e||($e={}));const rd={[$e.Dots]:1,[$e.Lines]:1,[$e.Cross]:6},od=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function No({id:e,variant:t=$e.Dots,gap:n=20,size:i,lineWidth:r=1,offset:o=0,color:s,bgColor:a,style:c,className:u,patternClassName:l}){const d=D.useRef(null),{transform:h,patternId:f}=re(od,ue),g=i||rd[t],y=t===$e.Dots,m=t===$e.Cross,v=Array.isArray(n)?n:[n,n],w=[v[0]*h[2]||1,v[1]*h[2]||1],p=g*h[2],b=Array.isArray(o)?o:[o,o],S=m?[p,p]:w,x=[b[0]*h[2]||1+S[0]/2,b[1]*h[2]||1+S[1]/2],C=`${f}${e||""}`;return A.jsxs("svg",{className:he(["react-flow__background",u]),style:{...c,...Qt,"--xy-background-color-props":a,"--xy-background-pattern-color-props":s},ref:d,"data-testid":"rf__background",children:[A.jsx("pattern",{id:C,x:h[0]%w[0],y:h[1]%w[1],width:w[0],height:w[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${x[0]},-${x[1]})`,children:y?A.jsx(id,{radius:p/2,className:l}):A.jsx(nd,{dimensions:S,lineWidth:r,variant:t,className:l})}),A.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${C})`})]})}No.displayName="Background";const sf=D.memo(No);function sd(){return A.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:A.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function ad(){return A.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:A.jsx("path",{d:"M0 0h32v4.2H0z"})})}function cd(){return A.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:A.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function ud(){return A.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:A.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function dd(){return A.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:A.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Pt({children:e,className:t,...n}){return A.jsx("button",{type:"button",className:he(["react-flow__controls-button",t]),...n,children:e})}const ld=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Ao({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:i=!0,fitViewOptions:r,onZoomIn:o,onZoomOut:s,onFitView:a,onInteractiveChange:c,className:u,children:l,position:d="bottom-left",orientation:h="vertical","aria-label":f}){const g=de(),{isInteractive:y,minZoomReached:m,maxZoomReached:v,ariaLabelConfig:w}=re(ld,ue),{zoomIn:p,zoomOut:b,fitView:S}=Vn(),x=()=>{p(),o==null||o()},C=()=>{b(),s==null||s()},k=()=>{S(r),a==null||a()},N=()=>{g.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),c==null||c(!y)},G=h==="horizontal"?"horizontal":"vertical";return A.jsxs(qt,{className:he(["react-flow__controls",G,u]),position:d,style:e,"data-testid":"rf__controls","aria-label":f??w["controls.ariaLabel"],children:[t&&A.jsxs(A.Fragment,{children:[A.jsx(Pt,{onClick:x,className:"react-flow__controls-zoomin",title:w["controls.zoomIn.ariaLabel"],"aria-label":w["controls.zoomIn.ariaLabel"],disabled:v,children:A.jsx(sd,{})}),A.jsx(Pt,{onClick:C,className:"react-flow__controls-zoomout",title:w["controls.zoomOut.ariaLabel"],"aria-label":w["controls.zoomOut.ariaLabel"],disabled:m,children:A.jsx(ad,{})})]}),n&&A.jsx(Pt,{className:"react-flow__controls-fitview",onClick:k,title:w["controls.fitView.ariaLabel"],"aria-label":w["controls.fitView.ariaLabel"],children:A.jsx(cd,{})}),i&&A.jsx(Pt,{className:"react-flow__controls-interactive",onClick:N,title:w["controls.interactive.ariaLabel"],"aria-label":w["controls.interactive.ariaLabel"],children:y?A.jsx(dd,{}):A.jsx(ud,{})}),l]})}Ao.displayName="Controls";const af=D.memo(Ao);function hd({id:e,x:t,y:n,width:i,height:r,style:o,color:s,strokeColor:a,strokeWidth:c,className:u,borderRadius:l,shapeRendering:d,selected:h,onClick:f}){const{background:g,backgroundColor:y}=o||{},m=s||g||y;return A.jsx("rect",{className:he(["react-flow__minimap-node",{selected:h},u]),x:t,y:n,rx:l,ry:l,width:i,height:r,style:{fill:m,stroke:a,strokeWidth:c},shapeRendering:d,onClick:f?v=>f(v,e):void 0})}const fd=D.memo(hd),gd=e=>e.nodes.map(t=>t.id),hn=e=>e instanceof Function?e:()=>e;function pd({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:i=5,nodeStrokeWidth:r,nodeComponent:o=fd,onClick:s}){const a=re(gd,ue),c=hn(t),u=hn(e),l=hn(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return A.jsx(A.Fragment,{children:a.map(h=>A.jsx(yd,{id:h,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:l,nodeBorderRadius:i,nodeStrokeWidth:r,NodeComponent:o,onClick:s,shapeRendering:d},h))})}function md({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:i,nodeBorderRadius:r,nodeStrokeWidth:o,shapeRendering:s,NodeComponent:a,onClick:c}){const{node:u,x:l,y:d,width:h,height:f}=re(g=>{const y=g.nodeLookup.get(e);if(!y)return{node:void 0,x:0,y:0,width:0,height:0};const m=y.internals.userNode,{x:v,y:w}=y.internals.positionAbsolute,{width:p,height:b}=De(m);return{node:m,x:v,y:w,width:p,height:b}},ue);return!u||u.hidden||!Rr(u)?null:A.jsx(a,{x:l,y:d,width:h,height:f,style:u.style,selected:!!u.selected,className:i(u),color:t(u),borderRadius:r,strokeColor:n(u),strokeWidth:o,shapeRendering:s,onClick:c,id:u.id})}const yd=D.memo(md);var vd=D.memo(pd);const wd=200,bd=150,xd=e=>!e.hidden,Ed=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?kr(_t(e.nodeLookup,{filter:xd}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Sd="react-flow__minimap-desc";function To({style:e,className:t,nodeStrokeColor:n,nodeColor:i,nodeClassName:r="",nodeBorderRadius:o=5,nodeStrokeWidth:s,nodeComponent:a,bgColor:c,maskColor:u,maskStrokeColor:l,maskStrokeWidth:d,position:h="bottom-right",onClick:f,onNodeClick:g,pannable:y=!1,zoomable:m=!1,ariaLabel:v,inversePan:w,zoomStep:p=1,offsetScale:b=5}){const S=de(),x=D.useRef(null),{boundingRect:C,viewBB:k,rfId:N,panZoom:G,translateExtent:E,flowWidth:_,flowHeight:I,ariaLabelConfig:M}=re(Ed,ue),P=(e==null?void 0:e.width)??wd,B=(e==null?void 0:e.height)??bd,$=C.width/P,R=C.height/B,T=Math.max($,R),U=T*P,z=T*B,F=b*T,V=C.x-(U-C.width)/2-F,q=C.y-(z-C.height)/2-F,J=U+F*2,te=z+F*2,ne=`${Sd}-${N}`,j=D.useRef(0),Q=D.useRef();j.current=T,D.useEffect(()=>{if(x.current&&G)return Q.current=ec({domNode:x.current,panZoom:G,getTransform:()=>S.getState().transform,getViewScale:()=>j.current}),()=>{var Z;(Z=Q.current)==null||Z.destroy()}},[G]),D.useEffect(()=>{var Z;(Z=Q.current)==null||Z.update({translateExtent:E,width:_,height:I,inversePan:w,pannable:y,zoomStep:p,zoomable:m})},[y,m,w,p,E,_,I]);const ie=f?Z=>{var oe;const[se,ce]=((oe=Q.current)==null?void 0:oe.pointer(Z))||[0,0];f(Z,{x:se,y:ce})}:void 0,ee=g?D.useCallback((Z,se)=>{const ce=S.getState().nodeLookup.get(se).internals.userNode;g(Z,ce)},[]):void 0,K=v??M["minimap.ariaLabel"];return A.jsx(qt,{position:h,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*T:void 0,"--xy-minimap-node-background-color-props":typeof i=="string"?i:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:he(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:A.jsxs("svg",{width:P,height:B,viewBox:`${V} ${q} ${J} ${te}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ne,ref:x,onClick:ie,children:[K&&A.jsx("title",{id:ne,children:K}),A.jsx(vd,{onClick:ee,nodeColor:i,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:r,nodeStrokeWidth:s,nodeComponent:a}),A.jsx("path",{className:"react-flow__minimap-mask",d:`M${V-F},${q-F}h${J+F*2}v${te+F*2}h${-J-F*2}z
|
|
7
|
+
M${k.x},${k.y}h${k.width}v${k.height}h${-k.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}To.displayName="MiniMap";D.memo(To);const Cd=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,_d={[tt.Line]:"right",[tt.Handle]:"bottom-right"};function Nd({nodeId:e,position:t,variant:n=tt.Handle,className:i,style:r=void 0,children:o,color:s,minWidth:a=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:l=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:h,autoScale:f=!0,shouldResize:g,onResizeStart:y,onResize:m,onResizeEnd:v}){const w=oo(),p=typeof e=="string"?e:w,b=de(),S=D.useRef(null),x=n===tt.Handle,C=re(D.useCallback(Cd(x&&f),[x,f]),ue),k=D.useRef(null),N=t??_d[n];D.useEffect(()=>{if(!(!S.current||!p))return k.current||(k.current=gc({domNode:S.current,nodeId:p,getStoreItems:()=>{const{nodeLookup:E,transform:_,snapGrid:I,snapToGrid:M,nodeOrigin:P,domNode:B}=b.getState();return{nodeLookup:E,transform:_,snapGrid:I,snapToGrid:M,nodeOrigin:P,paneDomNode:B}},onChange:(E,_)=>{const{triggerNodeChanges:I,nodeLookup:M,parentLookup:P,nodeOrigin:B}=b.getState(),$=[],R={x:E.x,y:E.y},T=M.get(p);if(T&&T.expandParent&&T.parentId){const U=T.origin??B,z=E.width??T.measured.width??0,F=E.height??T.measured.height??0,V={id:T.id,parentId:T.parentId,rect:{width:z,height:F,...Dr({x:E.x??T.position.x,y:E.y??T.position.y},{width:z,height:F},T.parentId,M,U)}},q=jn([V],M,P,B);$.push(...q),R.x=E.x?Math.max(U[0]*z,E.x):void 0,R.y=E.y?Math.max(U[1]*F,E.y):void 0}if(R.x!==void 0&&R.y!==void 0){const U={id:p,type:"position",position:{...R}};$.push(U)}if(E.width!==void 0&&E.height!==void 0){const z={id:p,type:"dimensions",resizing:!0,setAttributes:h?h==="horizontal"?"width":"height":!0,dimensions:{width:E.width,height:E.height}};$.push(z)}for(const U of _){const z={...U,type:"position"};$.push(z)}I($)},onEnd:({width:E,height:_})=>{const I={id:p,type:"dimensions",resizing:!1,dimensions:{width:E,height:_}};b.getState().triggerNodeChanges([I])}})),k.current.update({controlPosition:N,boundaries:{minWidth:a,minHeight:c,maxWidth:u,maxHeight:l},keepAspectRatio:d,resizeDirection:h,onResizeStart:y,onResize:m,onResizeEnd:v,shouldResize:g}),()=>{var E;(E=k.current)==null||E.destroy()}},[N,a,c,u,l,d,y,m,v,g]);const G=N.split("-");return A.jsx("div",{className:he(["react-flow__resize-control","nodrag",...G,n,i]),ref:S,style:{...r,scale:C,...s&&{[x?"backgroundColor":"borderColor"]:s}},children:o})}D.memo(Nd);function Ad(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function vt(e){var t=Ad(e,"string");return typeof t=="symbol"?t:t+""}function pe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Vi(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,vt(i.key),i)}}function me(e,t,n){return t&&Vi(e.prototype,t),n&&Vi(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function nt(e){return nt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},nt(e)}function ko(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ko=function(){return!!e})()}function Td(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function kd(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Td(e)}function we(e,t,n){return t=nt(t),kd(e,ko()?Reflect.construct(t,n||[],nt(e).constructor):t.apply(e,n))}function Dn(e,t){return Dn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,i){return n.__proto__=i,n},Dn(e,t)}function be(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Dn(e,t)}function Rd(e){if(Array.isArray(e))return e}function Dd(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var i,r,o,s,a=[],c=!0,u=!1;try{if(o=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(i=o.call(n)).done)&&(a.push(i.value),a.length!==t);c=!0);}catch(l){u=!0,r=l}finally{try{if(!c&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw r}}return a}}function Ln(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function Ro(e,t){if(e){if(typeof e=="string")return Ln(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ln(e,t):void 0}}function Ld(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
8
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function it(e,t){return Rd(e)||Dd(e,t)||Ro(e,t)||Ld()}var fn={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"},Do=new Int8Array(4),gn=new Int32Array(Do.buffer,0,1),Md=new Float32Array(Do.buffer,0,1),Pd=/^\s*rgba?\s*\(/,Id=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Gd(e){var t=0,n=0,i=0,r=1;if(e[0]==="#")e.length===4?(t=parseInt(e.charAt(1)+e.charAt(1),16),n=parseInt(e.charAt(2)+e.charAt(2),16),i=parseInt(e.charAt(3)+e.charAt(3),16)):(t=parseInt(e.charAt(1)+e.charAt(2),16),n=parseInt(e.charAt(3)+e.charAt(4),16),i=parseInt(e.charAt(5)+e.charAt(6),16)),e.length===9&&(r=parseInt(e.charAt(7)+e.charAt(8),16)/255);else if(Pd.test(e)){var o=e.match(Id);o&&(t=+o[1],n=+o[2],i=+o[3],o[4]&&(r=+o[4]))}return{r:t,g:n,b:i,a:r}}var Ke={};for(var It in fn)Ke[It]=Tt(fn[It]),Ke[fn[It]]=Ke[It];function Lo(e,t,n,i,r){return gn[0]=i<<24|n<<16|t<<8|e,gn[0]=gn[0]&4278190079,Md[0]}function Tt(e){if(e=e.toLowerCase(),typeof Ke[e]<"u")return Ke[e];var t=Gd(e),n=t.r,i=t.g,r=t.b,o=t.a;o=o*255|0;var s=Lo(n,i,r,o);return Ke[e]=s,s}var pn={};function Mo(e){if(typeof pn[e]<"u")return pn[e];var t=(e&16711680)>>>16,n=(e&65280)>>>8,i=e&255,r=255,o=Lo(t,n,i,r);return pn[e]=o,o}function Wi(e,t,n,i){return n+(t<<8)+(e<<16)}function Yi(e,t,n,i,r,o){var s=Math.floor(n/o*r),a=Math.floor(e.drawingBufferHeight/o-i/o*r),c=new Uint8Array(4);e.bindFramebuffer(e.FRAMEBUFFER,t),e.readPixels(s,a,1,1,e.RGBA,e.UNSIGNED_BYTE,c);var u=it(c,4),l=u[0],d=u[1],h=u[2],f=u[3];return[l,d,h,f]}function L(e,t,n){return(t=vt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Xi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),n.push.apply(n,i)}return n}function W(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Xi(Object(n),!0).forEach(function(i){L(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xi(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function Fd(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=nt(e))!==null;);return e}function Mn(){return Mn=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=Fd(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(arguments.length<3?e:n):r.value}},Mn.apply(null,arguments)}function Po(e,t,n,i){var r=Mn(nt(e.prototype),t,n);return typeof r=="function"?function(o){return r.apply(n,o)}:r}function $d(e){return e.normalized?1:e.size}function mn(e){var t=0;return e.forEach(function(n){return t+=$d(n)}),t}function Io(e,t,n){var i=e==="VERTEX"?t.VERTEX_SHADER:t.FRAGMENT_SHADER,r=t.createShader(i);if(r===null)throw new Error("loadShader: error while creating the shader");t.shaderSource(r,n),t.compileShader(r);var o=t.getShaderParameter(r,t.COMPILE_STATUS);if(!o){var s=t.getShaderInfoLog(r);throw t.deleteShader(r),new Error(`loadShader: error while compiling the shader:
|
|
9
9
|
`.concat(s,`
|
|
10
|
-
`).concat(n))}return r}function
|
|
11
|
-
`,
|
|
10
|
+
`).concat(n))}return r}function zd(e,t){return Io("VERTEX",e,t)}function Bd(e,t){return Io("FRAGMENT",e,t)}function Od(e,t){var n=e.createProgram();if(n===null)throw new Error("loadProgram: error while creating the program.");var i,r;for(i=0,r=t.length;i<r;i++)e.attachShader(n,t[i]);e.linkProgram(n);var o=e.getProgramParameter(n,e.LINK_STATUS);if(!o)throw e.deleteProgram(n),new Error("loadProgram: error while linking the program.");return n}function Zi(e){var t=e.gl,n=e.buffer,i=e.program,r=e.vertexShader,o=e.fragmentShader;t.deleteShader(r),t.deleteShader(o),t.deleteProgram(i),t.deleteBuffer(n)}var Ki=`#define PICKING_MODE
|
|
11
|
+
`,Ud=L(L(L(L(L(L(L(L({},WebGL2RenderingContext.BOOL,1),WebGL2RenderingContext.BYTE,1),WebGL2RenderingContext.UNSIGNED_BYTE,1),WebGL2RenderingContext.SHORT,2),WebGL2RenderingContext.UNSIGNED_SHORT,2),WebGL2RenderingContext.INT,4),WebGL2RenderingContext.UNSIGNED_INT,4),WebGL2RenderingContext.FLOAT,4),Go=(function(){function e(t,n,i){pe(this,e),L(this,"array",new Float32Array),L(this,"constantArray",new Float32Array),L(this,"capacity",0),L(this,"verticesCount",0);var r=this.getDefinition();if(this.VERTICES=r.VERTICES,this.VERTEX_SHADER_SOURCE=r.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=r.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=r.UNIFORMS,this.ATTRIBUTES=r.ATTRIBUTES,this.METHOD=r.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in r?r.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in r?r.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in r,this.ATTRIBUTES_ITEMS_COUNT=mn(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=i,this.normalProgram=this.getProgramInfo("normal",t,r.VERTEX_SHADER_SOURCE,r.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=n?this.getProgramInfo("pick",t,Ki+r.VERTEX_SHADER_SOURCE,Ki+r.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var o=mn(this.CONSTANT_ATTRIBUTES);if(this.CONSTANT_DATA.length!==this.VERTICES)throw new Error("Program: error while getting constant data (expected ".concat(this.VERTICES," items, received ").concat(this.CONSTANT_DATA.length," instead)"));this.constantArray=new Float32Array(this.CONSTANT_DATA.length*o);for(var s=0;s<this.CONSTANT_DATA.length;s++){var a=this.CONSTANT_DATA[s];if(a.length!==o)throw new Error("Program: error while getting constant data (one vector has ".concat(a.length," items instead of ").concat(o,")"));for(var c=0;c<a.length;c++)this.constantArray[s*o+c]=a[c]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}return me(e,[{key:"kill",value:function(){Zi(this.normalProgram),this.pickProgram&&(Zi(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(n,i,r,o,s){var a=this.getDefinition(),c=i.createBuffer();if(c===null)throw new Error("Program: error while creating the WebGL buffer.");var u=zd(i,r),l=Bd(i,o),d=Od(i,[u,l]),h={};a.UNIFORMS.forEach(function(y){var m=i.getUniformLocation(d,y);m&&(h[y]=m)});var f={};a.ATTRIBUTES.forEach(function(y){f[y.name]=i.getAttribLocation(d,y.name)});var g;if("CONSTANT_ATTRIBUTES"in a&&(a.CONSTANT_ATTRIBUTES.forEach(function(y){f[y.name]=i.getAttribLocation(d,y.name)}),g=i.createBuffer(),g===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:n,program:d,gl:i,frameBuffer:s,buffer:c,constantBuffer:g||{},uniformLocations:h,attributeLocations:f,isPicking:n==="pick",vertexShader:u,fragmentShader:l}}},{key:"bindProgram",value:function(n){var i=this,r=0,o=n.gl,s=n.buffer;this.isInstanced?(o.bindBuffer(o.ARRAY_BUFFER,n.constantBuffer),r=0,this.CONSTANT_ATTRIBUTES.forEach(function(a){return r+=i.bindAttribute(a,n,r,!1)}),o.bufferData(o.ARRAY_BUFFER,this.constantArray,o.STATIC_DRAW),o.bindBuffer(o.ARRAY_BUFFER,n.buffer),r=0,this.ATTRIBUTES.forEach(function(a){return r+=i.bindAttribute(a,n,r,!0)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)):(o.bindBuffer(o.ARRAY_BUFFER,s),r=0,this.ATTRIBUTES.forEach(function(a){return r+=i.bindAttribute(a,n,r)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)),o.bindBuffer(o.ARRAY_BUFFER,null)}},{key:"unbindProgram",value:function(n){var i=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(r){return i.unbindAttribute(r,n,!1)}),this.ATTRIBUTES.forEach(function(r){return i.unbindAttribute(r,n,!0)})):this.ATTRIBUTES.forEach(function(r){return i.unbindAttribute(r,n)})}},{key:"bindAttribute",value:function(n,i,r,o){var s=Ud[n.type];if(typeof s!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(n.type,'"'));var a=i.attributeLocations[n.name],c=i.gl;if(a!==-1){c.enableVertexAttribArray(a);var u=this.isInstanced?(o?this.ATTRIBUTES_ITEMS_COUNT:mn(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(c.vertexAttribPointer(a,n.size,n.type,n.normalized||!1,u,r),this.isInstanced&&o)if(c instanceof WebGL2RenderingContext)c.vertexAttribDivisor(a,1);else{var l=c.getExtension("ANGLE_instanced_arrays");l&&l.vertexAttribDivisorANGLE(a,1)}}return n.size*s}},{key:"unbindAttribute",value:function(n,i,r){var o=i.attributeLocations[n.name],s=i.gl;if(o!==-1&&(s.disableVertexAttribArray(o),this.isInstanced&&r))if(s instanceof WebGL2RenderingContext)s.vertexAttribDivisor(o,0);else{var a=s.getExtension("ANGLE_instanced_arrays");a&&a.vertexAttribDivisorANGLE(o,0)}}},{key:"reallocate",value:function(n){n!==this.capacity&&(this.capacity=n,this.verticesCount=this.VERTICES*n,this.array=new Float32Array(this.isInstanced?this.capacity*this.ATTRIBUTES_ITEMS_COUNT:this.verticesCount*this.ATTRIBUTES_ITEMS_COUNT))}},{key:"hasNothingToRender",value:function(){return this.verticesCount===0}},{key:"renderProgram",value:function(n,i){var r=i.gl,o=i.program;r.enable(r.BLEND),r.useProgram(o),this.setUniforms(n,i),this.drawWebGL(this.METHOD,i)}},{key:"render",value:function(n){this.hasNothingToRender()||(this.pickProgram&&(this.pickProgram.gl.viewport(0,0,n.width*n.pixelRatio/n.downSizingRatio,n.height*n.pixelRatio/n.downSizingRatio),this.bindProgram(this.pickProgram),this.renderProgram(W(W({},n),{},{pixelRatio:n.pixelRatio/n.downSizingRatio}),this.pickProgram),this.unbindProgram(this.pickProgram)),this.normalProgram.gl.viewport(0,0,n.width*n.pixelRatio,n.height*n.pixelRatio),this.bindProgram(this.normalProgram),this.renderProgram(n,this.normalProgram),this.unbindProgram(this.normalProgram))}},{key:"drawWebGL",value:function(n,i){var r=i.gl,o=i.frameBuffer;if(r.bindFramebuffer(r.FRAMEBUFFER,o),!this.isInstanced)r.drawArrays(n,0,this.verticesCount);else if(r instanceof WebGL2RenderingContext)r.drawArraysInstanced(n,0,this.VERTICES,this.capacity);else{var s=r.getExtension("ANGLE_instanced_arrays");s&&s.drawArraysInstancedANGLE(n,0,this.VERTICES,this.capacity)}}}])})(),Hd=(function(e){function t(){return pe(this,t),we(this,t,arguments)}return be(t,e),me(t,[{key:"kill",value:function(){Po(t,"kill",this)([])}},{key:"process",value:function(i,r,o){var s=r*this.STRIDE;if(o.hidden){for(var a=s+this.STRIDE;s<a;s++)this.array[s]=0;return}return this.processVisibleItem(Mo(i),s,o)}}])})(Go),Yn=(function(e){function t(){var n;pe(this,t);for(var i=arguments.length,r=new Array(i),o=0;o<i;o++)r[o]=arguments[o];return n=we(this,t,[].concat(r)),L(n,"drawLabel",void 0),n}return be(t,e),me(t,[{key:"kill",value:function(){Po(t,"kill",this)([])}},{key:"process",value:function(i,r,o,s,a){var c=r*this.STRIDE;if(a.hidden||o.hidden||s.hidden){for(var u=c+this.STRIDE;c<u;c++)this.array[c]=0;return}return this.processVisibleItem(Mo(i),c,o,s,a)}}])})(Go);function jd(e,t){return(function(){function n(i,r,o){pe(this,n),L(this,"drawLabel",t),this.programs=e.map(function(s){return new s(i,r,o)})}return me(n,[{key:"reallocate",value:function(r){this.programs.forEach(function(o){return o.reallocate(r)})}},{key:"process",value:function(r,o,s,a,c){this.programs.forEach(function(u){return u.process(r,o,s,a,c)})}},{key:"render",value:function(r){this.programs.forEach(function(o){return o.render(r)})}},{key:"kill",value:function(){this.programs.forEach(function(r){return r.kill()})}}])})()}function Vd(e,t,n,i,r){var o=r.edgeLabelSize,s=r.edgeLabelFont,a=r.edgeLabelWeight,c=r.edgeLabelColor.attribute?t[r.edgeLabelColor.attribute]||r.edgeLabelColor.color||"#000":r.edgeLabelColor.color,u=t.label;if(u){e.fillStyle=c,e.font="".concat(a," ").concat(o,"px ").concat(s);var l=n.size,d=i.size,h=n.x,f=n.y,g=i.x,y=i.y,m=(h+g)/2,v=(f+y)/2,w=g-h,p=y-f,b=Math.sqrt(w*w+p*p);if(!(b<l+d)){h+=w*l/b,f+=p*l/b,g-=w*d/b,y-=p*d/b,m=(h+g)/2,v=(f+y)/2,w=g-h,p=y-f,b=Math.sqrt(w*w+p*p);var S=e.measureText(u).width;if(S>b){var x="…";for(u=u+x,S=e.measureText(u).width;S>b&&u.length>1;)u=u.slice(0,-2)+x,S=e.measureText(u).width;if(u.length<4)return}var C;w>0?p>0?C=Math.acos(w/b):C=Math.asin(p/b):p>0?C=Math.acos(w/b)+Math.PI:C=Math.asin(w/b)+Math.PI/2,e.save(),e.translate(m,v),e.rotate(C),e.fillText(u,-S/2,t.size/2+o),e.restore()}}}function Fo(e,t,n){if(t.label){var i=n.labelSize,r=n.labelFont,o=n.labelWeight,s=n.labelColor.attribute?t[n.labelColor.attribute]||n.labelColor.color||"#000":n.labelColor.color;e.fillStyle=s,e.font="".concat(o," ").concat(i,"px ").concat(r),e.fillText(t.label,t.x+t.size+3,t.y+i/3)}}function Wd(e,t,n){var i=n.labelSize,r=n.labelFont,o=n.labelWeight;e.font="".concat(o," ").concat(i,"px ").concat(r),e.fillStyle="#FFF",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=8,e.shadowColor="#000";var s=2;if(typeof t.label=="string"){var a=e.measureText(t.label).width,c=Math.round(a+5),u=Math.round(i+2*s),l=Math.max(t.size,i/2)+s,d=Math.asin(u/2/l),h=Math.sqrt(Math.abs(Math.pow(l,2)-Math.pow(u/2,2)));e.beginPath(),e.moveTo(t.x+h,t.y+u/2),e.lineTo(t.x+l+c,t.y+u/2),e.lineTo(t.x+l+c,t.y-u/2),e.lineTo(t.x+h,t.y-u/2),e.arc(t.x,t.y,l,d,-d),e.closePath(),e.fill()}else e.beginPath(),e.arc(t.x,t.y,t.size+s,0,Math.PI*2),e.closePath(),e.fill();e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,Fo(e,t,n)}var Yd=`
|
|
12
12
|
precision highp float;
|
|
13
13
|
|
|
14
14
|
varying vec4 v_color;
|
|
@@ -40,7 +40,7 @@ void main(void) {
|
|
|
40
40
|
gl_FragColor = mix(v_color, transparent, t);
|
|
41
41
|
#endif
|
|
42
42
|
}
|
|
43
|
-
`,
|
|
43
|
+
`,Xd=Yd,Zd=`
|
|
44
44
|
attribute vec4 a_id;
|
|
45
45
|
attribute vec4 a_color;
|
|
46
46
|
attribute vec2 a_position;
|
|
@@ -81,7 +81,7 @@ void main() {
|
|
|
81
81
|
|
|
82
82
|
v_color.a *= bias;
|
|
83
83
|
}
|
|
84
|
-
`,
|
|
84
|
+
`,Kd=Zd,$o=WebGLRenderingContext,qi=$o.UNSIGNED_BYTE,yn=$o.FLOAT,qd=["u_sizeRatio","u_correctionRatio","u_matrix"],en=(function(e){function t(){return pe(this,t),we(this,t,arguments)}return be(t,e),me(t,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:Kd,FRAGMENT_SHADER_SOURCE:Xd,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:qd,ATTRIBUTES:[{name:"a_position",size:2,type:yn},{name:"a_size",size:1,type:yn},{name:"a_color",size:4,type:qi,normalized:!0},{name:"a_id",size:4,type:qi,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:yn}],CONSTANT_DATA:[[t.ANGLE_1],[t.ANGLE_2],[t.ANGLE_3]]}}},{key:"processVisibleItem",value:function(i,r,o){var s=this.array,a=Tt(o.color);s[r++]=o.x,s[r++]=o.y,s[r++]=o.size,s[r++]=a,s[r++]=i}},{key:"setUniforms",value:function(i,r){var o=r.gl,s=r.uniformLocations,a=s.u_sizeRatio,c=s.u_correctionRatio,u=s.u_matrix;o.uniform1f(c,i.correctionRatio),o.uniform1f(a,i.sizeRatio),o.uniformMatrix3fv(u,!1,i.matrix)}}])})(Hd);L(en,"ANGLE_1",0);L(en,"ANGLE_2",2*Math.PI/3);L(en,"ANGLE_3",4*Math.PI/3);var Qd=`
|
|
85
85
|
precision mediump float;
|
|
86
86
|
|
|
87
87
|
varying vec4 v_color;
|
|
@@ -89,7 +89,7 @@ varying vec4 v_color;
|
|
|
89
89
|
void main(void) {
|
|
90
90
|
gl_FragColor = v_color;
|
|
91
91
|
}
|
|
92
|
-
`,
|
|
92
|
+
`,Jd=Qd,el=`
|
|
93
93
|
attribute vec2 a_position;
|
|
94
94
|
attribute vec2 a_normal;
|
|
95
95
|
attribute float a_radius;
|
|
@@ -155,7 +155,7 @@ void main() {
|
|
|
155
155
|
|
|
156
156
|
v_color.a *= bias;
|
|
157
157
|
}
|
|
158
|
-
`,
|
|
158
|
+
`,tl=el,zo=WebGLRenderingContext,Qi=zo.UNSIGNED_BYTE,Gt=zo.FLOAT,nl=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],Bo={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function Oo(e){var t=W(W({},Bo),{});return(function(n){function i(){return pe(this,i),we(this,i,arguments)}return be(i,n),me(i,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:tl,FRAGMENT_SHADER_SOURCE:Jd,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:nl,ATTRIBUTES:[{name:"a_position",size:2,type:Gt},{name:"a_normal",size:2,type:Gt},{name:"a_radius",size:1,type:Gt},{name:"a_color",size:4,type:Qi,normalized:!0},{name:"a_id",size:4,type:Qi,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:Gt}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(o,s,a,c,u){if(t.extremity==="source"){var l=[c,a];a=l[0],c=l[1]}var d=u.size||1,h=c.size||1,f=a.x,g=a.y,y=c.x,m=c.y,v=Tt(u.color),w=y-f,p=m-g,b=w*w+p*p,S=0,x=0;b&&(b=1/Math.sqrt(b),S=-p*b*d,x=w*b*d);var C=this.array;C[s++]=y,C[s++]=m,C[s++]=-S,C[s++]=-x,C[s++]=h,C[s++]=v,C[s++]=o}},{key:"setUniforms",value:function(o,s){var a=s.gl,c=s.uniformLocations,u=c.u_matrix,l=c.u_sizeRatio,d=c.u_correctionRatio,h=c.u_minEdgeThickness,f=c.u_lengthToThicknessRatio,g=c.u_widenessToThicknessRatio;a.uniformMatrix3fv(u,!1,o.matrix),a.uniform1f(l,o.sizeRatio),a.uniform1f(d,o.correctionRatio),a.uniform1f(h,o.minEdgeThickness),a.uniform1f(f,t.lengthToThicknessRatio),a.uniform1f(g,t.widenessToThicknessRatio)}}])})(Yn)}Oo();var il=`
|
|
159
159
|
precision mediump float;
|
|
160
160
|
|
|
161
161
|
varying vec4 v_color;
|
|
@@ -181,7 +181,7 @@ void main(void) {
|
|
|
181
181
|
gl_FragColor = mix(v_color, transparent, t);
|
|
182
182
|
#endif
|
|
183
183
|
}
|
|
184
|
-
`,
|
|
184
|
+
`,Uo=il,rl=`
|
|
185
185
|
attribute vec4 a_id;
|
|
186
186
|
attribute vec4 a_color;
|
|
187
187
|
attribute vec2 a_normal;
|
|
@@ -249,7 +249,7 @@ void main() {
|
|
|
249
249
|
|
|
250
250
|
v_color.a *= bias;
|
|
251
251
|
}
|
|
252
|
-
`,
|
|
252
|
+
`,ol=rl,Ho=WebGLRenderingContext,Ji=Ho.UNSIGNED_BYTE,Be=Ho.FLOAT,sl=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],al={lengthToThicknessRatio:Bo.lengthToThicknessRatio};function jo(e){var t=W(W({},al),{});return(function(n){function i(){return pe(this,i),we(this,i,arguments)}return be(i,n),me(i,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:ol,FRAGMENT_SHADER_SOURCE:Uo,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:sl,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Be},{name:"a_positionEnd",size:2,type:Be},{name:"a_normal",size:2,type:Be},{name:"a_color",size:4,type:Ji,normalized:!0},{name:"a_id",size:4,type:Ji,normalized:!0},{name:"a_radius",size:1,type:Be}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Be},{name:"a_normalCoef",size:1,type:Be},{name:"a_radiusCoef",size:1,type:Be}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(o,s,a,c,u){var l=u.size||1,d=a.x,h=a.y,f=c.x,g=c.y,y=Tt(u.color),m=f-d,v=g-h,w=c.size||1,p=m*m+v*v,b=0,S=0;p&&(p=1/Math.sqrt(p),b=-v*p*l,S=m*p*l);var x=this.array;x[s++]=d,x[s++]=h,x[s++]=f,x[s++]=g,x[s++]=b,x[s++]=S,x[s++]=y,x[s++]=o,x[s++]=w}},{key:"setUniforms",value:function(o,s){var a=s.gl,c=s.uniformLocations,u=c.u_matrix,l=c.u_zoomRatio,d=c.u_feather,h=c.u_pixelRatio,f=c.u_correctionRatio,g=c.u_sizeRatio,y=c.u_minEdgeThickness,m=c.u_lengthToThicknessRatio;a.uniformMatrix3fv(u,!1,o.matrix),a.uniform1f(l,o.zoomRatio),a.uniform1f(g,o.sizeRatio),a.uniform1f(f,o.correctionRatio),a.uniform1f(h,o.pixelRatio),a.uniform1f(d,o.antiAliasingFeather),a.uniform1f(y,o.minEdgeThickness),a.uniform1f(m,t.lengthToThicknessRatio)}}])})(Yn)}jo();function cl(e){return jd([jo(),Oo()])}var ul=cl(),dl=ul,ll=`
|
|
253
253
|
attribute vec4 a_id;
|
|
254
254
|
attribute vec4 a_color;
|
|
255
255
|
attribute vec2 a_normal;
|
|
@@ -314,5 +314,5 @@ void main() {
|
|
|
314
314
|
|
|
315
315
|
v_color.a *= bias;
|
|
316
316
|
}
|
|
317
|
-
`,yh=mh,os=WebGLRenderingContext,ir=os.UNSIGNED_BYTE,ft=os.FLOAT,vh=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],wh=(function(e){function t(){return pe(this,t),we(this,t,arguments)}return be(t,e),me(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:yh,FRAGMENT_SHADER_SOURCE:ns,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:vh,ATTRIBUTES:[{name:"a_positionStart",size:2,type:ft},{name:"a_positionEnd",size:2,type:ft},{name:"a_normal",size:2,type:ft},{name:"a_color",size:4,type:ir,normalized:!0},{name:"a_id",size:4,type:ir,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:ft},{name:"a_normalCoef",size:1,type:ft}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(i,r,o,s,a){var c=a.size||1,u=o.x,l=o.y,d=s.x,h=s.y,f=At(a.color),g=d-u,y=h-l,m=g*g+y*y,v=0,w=0;m&&(m=1/Math.sqrt(m),v=-y*m*c,w=g*m*c);var p=this.array;p[r++]=u,p[r++]=l,p[r++]=d,p[r++]=h,p[r++]=v,p[r++]=w,p[r++]=f,p[r++]=i}},{key:"setUniforms",value:function(i,r){var o=r.gl,s=r.uniformLocations,a=s.u_matrix,c=s.u_zoomRatio,u=s.u_feather,l=s.u_pixelRatio,d=s.u_correctionRatio,h=s.u_sizeRatio,f=s.u_minEdgeThickness;o.uniformMatrix3fv(a,!1,i.matrix),o.uniform1f(c,i.zoomRatio),o.uniform1f(h,i.sizeRatio),o.uniform1f(d,i.correctionRatio),o.uniform1f(l,i.pixelRatio),o.uniform1f(u,i.antiAliasingFeather),o.uniform1f(f,i.minEdgeThickness)}}])})(qn),Qn=(function(e){function t(){var n;return pe(this,t),n=we(this,t),n.rawEmitter=n,n}return be(t,e),me(t)})(br.EventEmitter),bn,rr;function bh(){return rr||(rr=1,bn=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}),bn}var xh=bh();const Eh=fa(xh);var Sh=function(t){return t},Ch=function(t){return t*t},_h=function(t){return t*(2-t)},Nh=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},Th=function(t){return t*t*t},Ah=function(t){return--t*t*t+1},kh=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},Rh={linear:Sh,quadraticIn:Ch,quadraticOut:_h,quadraticInOut:Nh,cubicIn:Th,cubicOut:Ah,cubicInOut:kh},Dh={easing:"quadraticInOut",duration:150};function Ee(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function $t(e,t,n){return e[0]=t,e[4]=typeof n=="number"?n:t,e}function or(e,t){var n=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=n,e[3]=-n,e[4]=i,e}function sr(e,t,n){return e[6]=t,e[7]=n,e}function Ge(e,t){var n=e[0],i=e[1],r=e[2],o=e[3],s=e[4],a=e[5],c=e[6],u=e[7],l=e[8],d=t[0],h=t[1],f=t[2],g=t[3],y=t[4],m=t[5],v=t[6],w=t[7],p=t[8];return e[0]=d*n+h*o+f*c,e[1]=d*i+h*s+f*u,e[2]=d*r+h*a+f*l,e[3]=g*n+y*o+m*c,e[4]=g*i+y*s+m*u,e[5]=g*r+y*a+m*l,e[6]=v*n+w*o+p*c,e[7]=v*i+w*s+p*u,e[8]=v*r+w*a+p*l,e}function Pn(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,i=e[0],r=e[1],o=e[3],s=e[4],a=e[6],c=e[7],u=t.x,l=t.y;return{x:u*i+l*o+a*n,y:u*r+l*s+c*n}}function Lh(e,t){var n=e.height/e.width,i=t.height/t.width;return n<1&&i>1||n>1&&i<1?1:Math.min(Math.max(i,1/i),Math.max(1/n,n))}function gt(e,t,n,i,r){var o=e.angle,s=e.ratio,a=e.x,c=e.y,u=t.width,l=t.height,d=Ee(),h=Math.min(u,l)-2*i,f=Lh(t,n);return r?(Ge(d,sr(Ee(),a,c)),Ge(d,$t(Ee(),s)),Ge(d,or(Ee(),o)),Ge(d,$t(Ee(),u/h/2/f,l/h/2/f))):(Ge(d,$t(Ee(),2*(h/u)*f,2*(h/l)*f)),Ge(d,or(Ee(),-o)),Ge(d,$t(Ee(),1/s)),Ge(d,sr(Ee(),-a,-c))),d}function Mh(e,t,n){var i=Pn(e,{x:Math.cos(t.angle),y:Math.sin(t.angle)},0),r=i.x,o=i.y;return 1/Math.sqrt(Math.pow(r,2)+Math.pow(o,2))/n.width}function Ph(e){if(!e.order)return{x:[0,1],y:[0,1]};var t=1/0,n=-1/0,i=1/0,r=-1/0;return e.forEachNode(function(o,s){var a=s.x,c=s.y;a<t&&(t=a),a>n&&(n=a),c<i&&(i=c),c>r&&(r=c)}),{x:[t,n],y:[i,r]}}function Ih(e){if(!Eh(e))throw new Error("Sigma: invalid graph instance.");e.forEachNode(function(t,n){if(!Number.isFinite(n.x)||!Number.isFinite(n.y))throw new Error("Sigma: Coordinates of node ".concat(t," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function Gh(e,t,n){var i=document.createElement(e);if(t)for(var r in t)i.style[r]=t[r];if(n)for(var o in n)i.setAttribute(o,n[o]);return i}function ar(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function cr(e,t,n){return n.sort(function(i,r){var o=t(i)||0,s=t(r)||0;return o<s?-1:o>s?1:0})}function ur(e){var t=it(e.x,2),n=t[0],i=t[1],r=it(e.y,2),o=r[0],s=r[1],a=Math.max(i-n,s-o),c=(i+n)/2,u=(s+o)/2;(a===0||Math.abs(a)===1/0||isNaN(a))&&(a=1),isNaN(c)&&(c=0),isNaN(u)&&(u=0);var l=function(h){return{x:.5+(h.x-c)/a,y:.5+(h.y-u)/a}};return l.applyTo=function(d){d.x=.5+(d.x-c)/a,d.y=.5+(d.y-u)/a},l.inverse=function(d){return{x:c+a*(d.x-.5),y:u+a*(d.y-.5)}},l.ratio=a,l}function In(e){"@babel/helpers - typeof";return In=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},In(e)}function dr(e,t){var n=t.size;if(n!==0){var i=e.length;e.length+=n;var r=0;t.forEach(function(o){e[i+r]=o,r++})}}function xn(e){e=e||{};for(var t=0,n=arguments.length<=1?0:arguments.length-1;t<n;t++){var i=t+1<1||arguments.length<=t+1?void 0:arguments[t+1];i&&Object.assign(e,i)}return e}var Jn={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,renderEdgeLabels:!1,enableEdgeEvents:!1,defaultNodeColor:"#999",defaultNodeType:"circle",defaultEdgeColor:"#ccc",defaultEdgeType:"line",labelFont:"Arial",labelSize:14,labelWeight:"normal",labelColor:{color:"#000"},edgeLabelFont:"Arial",edgeLabelSize:14,edgeLabelWeight:"normal",edgeLabelColor:{attribute:"color"},stagePadding:30,defaultDrawEdgeLabel:Kl,defaultDrawNodeLabel:qo,defaultDrawNodeHover:ql,minEdgeThickness:1.7,antiAliasingFeather:1,dragTimeout:100,draggedEventsTolerance:3,inertiaDuration:200,inertiaRatio:3,zoomDuration:250,zoomingRatio:1.7,doubleClickTimeout:300,doubleClickZoomingRatio:2.2,doubleClickZoomingDuration:200,tapMoveTolerance:10,zoomToSizeRatioFunction:Math.sqrt,itemSizesReference:"screen",autoRescale:!0,autoCenter:!0,labelDensity:1,labelGridCellSize:100,labelRenderedSizeThreshold:6,nodeReducer:null,edgeReducer:null,zIndex:!1,minCameraRatio:null,maxCameraRatio:null,enableCameraZooming:!0,enableCameraPanning:!0,enableCameraRotation:!0,cameraPanBoundaries:null,allowInvalidContainer:!1,nodeProgramClasses:{},nodeHoverProgramClasses:{},edgeProgramClasses:{}},Fh={circle:tn},$h={arrow:ph,line:wh};function En(e){if(typeof e.labelDensity!="number"||e.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var t=e.minCameraRatio,n=e.maxCameraRatio;if(typeof t=="number"&&typeof n=="number"&&n<t)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function zh(e){var t=xn({},Jn,e);return t.nodeProgramClasses=xn({},Fh,t.nodeProgramClasses),t.edgeProgramClasses=xn({},$h,t.edgeProgramClasses),t}var zt=1.5,lr=(function(e){function t(){var n;return pe(this,t),n=we(this,t),L(n,"x",.5),L(n,"y",.5),L(n,"angle",0),L(n,"ratio",1),L(n,"minRatio",null),L(n,"maxRatio",null),L(n,"enabledZooming",!0),L(n,"enabledPanning",!0),L(n,"enabledRotation",!0),L(n,"clean",null),L(n,"nextFrame",null),L(n,"previousState",null),L(n,"enabled",!0),n.previousState=n.getState(),n}return be(t,e),me(t,[{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"getState",value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:"hasState",value:function(i){return this.x===i.x&&this.y===i.y&&this.ratio===i.ratio&&this.angle===i.angle}},{key:"getPreviousState",value:function(){var i=this.previousState;return i?{x:i.x,y:i.y,angle:i.angle,ratio:i.ratio}:null}},{key:"getBoundedRatio",value:function(i){var r=i;return typeof this.minRatio=="number"&&(r=Math.max(r,this.minRatio)),typeof this.maxRatio=="number"&&(r=Math.min(r,this.maxRatio)),r}},{key:"validateState",value:function(i){var r={};return this.enabledPanning&&typeof i.x=="number"&&(r.x=i.x),this.enabledPanning&&typeof i.y=="number"&&(r.y=i.y),this.enabledZooming&&typeof i.ratio=="number"&&(r.ratio=this.getBoundedRatio(i.ratio)),this.enabledRotation&&typeof i.angle=="number"&&(r.angle=i.angle),this.clean?this.clean(W(W({},this.getState()),r)):r}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(i){if(!this.enabled)return this;this.previousState=this.getState();var r=this.validateState(i);return typeof r.x=="number"&&(this.x=r.x),typeof r.y=="number"&&(this.y=r.y),typeof r.ratio=="number"&&(this.ratio=r.ratio),typeof r.angle=="number"&&(this.angle=r.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(i){return this.setState(i(this.getState())),this}},{key:"animate",value:function(i){var r=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;if(!s)return new Promise(function(f){return r.animate(i,o,f)});if(this.enabled){var a=W(W({},Dh),o),c=this.validateState(i),u=typeof a.easing=="function"?a.easing:Rh[a.easing],l=Date.now(),d=this.getState(),h=function(){var g=(Date.now()-l)/a.duration;if(g>=1){r.nextFrame=null,r.setState(c),r.animationCallback&&(r.animationCallback.call(null),r.animationCallback=void 0);return}var y=u(g),m={};typeof c.x=="number"&&(m.x=d.x+(c.x-d.x)*y),typeof c.y=="number"&&(m.y=d.y+(c.y-d.y)*y),r.enabledRotation&&typeof c.angle=="number"&&(m.angle=d.angle+(c.angle-d.angle)*y),typeof c.ratio=="number"&&(m.ratio=d.ratio+(c.ratio-d.ratio)*y),r.setState(m),r.nextFrame=requestAnimationFrame(h)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(h)):h(),this.animationCallback=s}}},{key:"animatedZoom",value:function(i){return i?typeof i=="number"?this.animate({ratio:this.ratio/i}):this.animate({ratio:this.ratio/(i.factor||zt)},i):this.animate({ratio:this.ratio/zt})}},{key:"animatedUnzoom",value:function(i){return i?typeof i=="number"?this.animate({ratio:this.ratio*i}):this.animate({ratio:this.ratio*(i.factor||zt)},i):this.animate({ratio:this.ratio*zt})}},{key:"animatedReset",value:function(i){return this.animate({x:.5,y:.5,ratio:1,angle:0},i)}},{key:"copy",value:function(){return t.from(this.getState())}}],[{key:"from",value:function(i){var r=new t;return r.setState(i)}}])})(Qn);function Se(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function Ae(e,t){var n=W(W({},Se(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function pt(e){var t="x"in e?e:W(W({},e.touches[0]||e.previousTouches[0]),{},{original:e.original,sigmaDefaultPrevented:e.sigmaDefaultPrevented,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0,t.sigmaDefaultPrevented=!0}});return t}function Bh(e,t){return W(W({},Ae(e,t)),{},{delta:ss(e)})}var Oh=2;function Bt(e){for(var t=[],n=0,i=Math.min(e.length,Oh);n<i;n++)t.push(e[n]);return t}function mt(e,t,n){var i={touches:Bt(e.touches).map(function(r){return Se(r,n)}),previousTouches:t.map(function(r){return Se(r,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){i.sigmaDefaultPrevented=!0},original:e};return i}function ss(e){if(typeof e.deltaY<"u")return e.deltaY*-3/360;if(typeof e.detail<"u")return e.detail/-9;throw new Error("Captor: could not extract delta from event.")}var as=(function(e){function t(n,i){var r;return pe(this,t),r=we(this,t),r.container=n,r.renderer=i,r}return be(t,e),me(t)})(Qn),Uh=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],Hh=Uh.reduce(function(e,t){return W(W({},e),{},L({},t,Jn[t]))},{}),jh=(function(e){function t(n,i){var r;return pe(this,t),r=we(this,t,[n,i]),L(r,"enabled",!0),L(r,"draggedEvents",0),L(r,"downStartTime",null),L(r,"lastMouseX",null),L(r,"lastMouseY",null),L(r,"isMouseDown",!1),L(r,"isMoving",!1),L(r,"movingTimeout",null),L(r,"startCameraState",null),L(r,"clicks",0),L(r,"doubleClickTimeout",null),L(r,"currentWheelDirection",0),L(r,"settings",Hh),r.handleClick=r.handleClick.bind(r),r.handleRightClick=r.handleRightClick.bind(r),r.handleDown=r.handleDown.bind(r),r.handleUp=r.handleUp.bind(r),r.handleMove=r.handleMove.bind(r),r.handleWheel=r.handleWheel.bind(r),r.handleLeave=r.handleLeave.bind(r),r.handleEnter=r.handleEnter.bind(r),n.addEventListener("click",r.handleClick,{capture:!1}),n.addEventListener("contextmenu",r.handleRightClick,{capture:!1}),n.addEventListener("mousedown",r.handleDown,{capture:!1}),n.addEventListener("wheel",r.handleWheel,{capture:!1}),n.addEventListener("mouseleave",r.handleLeave,{capture:!1}),n.addEventListener("mouseenter",r.handleEnter,{capture:!1}),document.addEventListener("mousemove",r.handleMove,{capture:!1}),document.addEventListener("mouseup",r.handleUp,{capture:!1}),r}return be(t,e),me(t,[{key:"kill",value:function(){var i=this.container;i.removeEventListener("click",this.handleClick),i.removeEventListener("contextmenu",this.handleRightClick),i.removeEventListener("mousedown",this.handleDown),i.removeEventListener("wheel",this.handleWheel),i.removeEventListener("mouseleave",this.handleLeave),i.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(i){var r=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(i);setTimeout(function(){r.clicks=0,r.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",Ae(i,this.container))}}},{key:"handleRightClick",value:function(i){this.enabled&&this.emit("rightClick",Ae(i,this.container))}},{key:"handleDoubleClick",value:function(i){if(this.enabled){i.preventDefault(),i.stopPropagation();var r=Ae(i,this.container);if(this.emit("doubleClick",r),!r.sigmaDefaultPrevented){var o=this.renderer.getCamera(),s=o.getBoundedRatio(o.getState().ratio/this.settings.doubleClickZoomingRatio);o.animate(this.renderer.getViewportZoomedState(Se(i,this.container),s),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(i){if(this.enabled){if(i.button===0){this.startCameraState=this.renderer.getCamera().getState();var r=Se(i,this.container),o=r.x,s=r.y;this.lastMouseX=o,this.lastMouseY=s,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",Ae(i,this.container))}}},{key:"handleUp",value:function(i){var r=this;if(!(!this.enabled||!this.isMouseDown)){var o=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var s=Se(i,this.container),a=s.x,c=s.y,u=o.getState(),l=o.getPreviousState()||{x:0,y:0};this.isMoving?o.animate({x:u.x+this.settings.inertiaRatio*(u.x-l.x),y:u.y+this.settings.inertiaRatio*(u.y-l.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==a||this.lastMouseY!==c)&&o.setState({x:u.x,y:u.y}),this.isMoving=!1,setTimeout(function(){var d=r.draggedEvents>0;r.draggedEvents=0,d&&r.renderer.getSetting("hideEdgesOnMove")&&r.renderer.refresh()},0),this.emit("mouseup",Ae(i,this.container))}}},{key:"handleMove",value:function(i){var r=this;if(this.enabled){var o=Ae(i,this.container);if(this.emit("mousemovebody",o),(i.target===this.container||i.composedPath()[0]===this.container)&&this.emit("mousemove",o),!o.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){r.movingTimeout=null,r.isMoving=!1},this.settings.dragTimeout);var s=this.renderer.getCamera(),a=Se(i,this.container),c=a.x,u=a.y,l=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),d=this.renderer.viewportToFramedGraph({x:c,y:u}),h=l.x-d.x,f=l.y-d.y,g=s.getState(),y=g.x+h,m=g.y+f;s.setState({x:y,y:m}),this.lastMouseX=c,this.lastMouseY=u,i.preventDefault(),i.stopPropagation()}}}},{key:"handleLeave",value:function(i){this.emit("mouseleave",Ae(i,this.container))}},{key:"handleEnter",value:function(i){this.emit("mouseenter",Ae(i,this.container))}},{key:"handleWheel",value:function(i){var r=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var s=ss(i);if(s){var a=Bh(i,this.container);if(this.emit("wheel",a),a.sigmaDefaultPrevented){i.preventDefault(),i.stopPropagation();return}var c=o.getState().ratio,u=s>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,l=o.getBoundedRatio(c*u),d=s>0?1:-1,h=Date.now();c!==l&&(i.preventDefault(),i.stopPropagation(),!(this.currentWheelDirection===d&&this.lastWheelTriggerTime&&h-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(Se(i,this.container),l),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){r.currentWheelDirection=0}),this.currentWheelDirection=d,this.lastWheelTriggerTime=h))}}}},{key:"setSettings",value:function(i){this.settings=i}}])})(as),Vh=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],Wh=Vh.reduce(function(e,t){return W(W({},e),{},L({},t,Jn[t]))},{}),Yh=(function(e){function t(n,i){var r;return pe(this,t),r=we(this,t,[n,i]),L(r,"enabled",!0),L(r,"isMoving",!1),L(r,"hasMoved",!1),L(r,"touchMode",0),L(r,"startTouchesPositions",[]),L(r,"lastTouches",[]),L(r,"lastTap",null),L(r,"settings",Wh),r.handleStart=r.handleStart.bind(r),r.handleLeave=r.handleLeave.bind(r),r.handleMove=r.handleMove.bind(r),n.addEventListener("touchstart",r.handleStart,{capture:!1}),n.addEventListener("touchcancel",r.handleLeave,{capture:!1}),document.addEventListener("touchend",r.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",r.handleMove,{capture:!1,passive:!1}),r}return be(t,e),me(t,[{key:"kill",value:function(){var i=this.container;i.removeEventListener("touchstart",this.handleStart),i.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(i){var r=this;if(this.enabled){i.preventDefault();var o=Bt(i.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(f){return Se(f,r.container)}),this.touchMode===2){var s=it(this.startTouchesPositions,2),a=s[0],c=a.x,u=a.y,l=s[1],d=l.x,h=l.y;this.startTouchesAngle=Math.atan2(h-u,d-c),this.startTouchesDistance=Math.sqrt(Math.pow(d-c,2)+Math.pow(h-u,2))}this.emit("touchdown",mt(i,this.lastTouches,this.container)),this.lastTouches=o,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(i){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(i.cancelable&&i.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(i.touches.length===1){this.handleStart(i),i.preventDefault();break}case 1:if(this.isMoving){var r=this.renderer.getCamera(),o=r.getState(),s=r.getPreviousState()||{x:0,y:0};r.animate({x:o.x+this.settings.inertiaRatio*(o.x-s.x),y:o.y+this.settings.inertiaRatio*(o.y-s.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",mt(i,this.lastTouches,this.container)),!i.touches.length){var a=Se(this.lastTouches[0],this.container),c=this.startTouchesPositions[0],u=Math.pow(a.x-c.x,2)+Math.pow(a.y-c.y,2);if(!i.touches.length&&u<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var l=mt(i,this.lastTouches,this.container);if(this.emit("doubletap",l),this.lastTap=null,!l.sigmaDefaultPrevented){var d=this.renderer.getCamera(),h=d.getBoundedRatio(d.getState().ratio/this.settings.doubleClickZoomingRatio);d.animate(this.renderer.getViewportZoomedState(a,h),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var f=mt(i,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=Bt(i.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(i){var r=this;if(!(!this.enabled||!this.startTouchesPositions.length)){i.preventDefault();var o=Bt(i.touches),s=o.map(function(z){return Se(z,r.container)}),a=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=s;var c=mt(i,a,this.container);if(this.emit("touchmove",c),!c.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=s.some(function(z,F){var V=r.startTouchesPositions[F];return V&&(z.x!==V.x||z.y!==V.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){r.isMoving=!1},this.settings.dragTimeout);var u=this.renderer.getCamera(),l=this.startCameraState,d=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var h=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),f=h.x,g=h.y,y=this.renderer.viewportToFramedGraph(s[0]),m=y.x,v=y.y;u.setState({x:l.x+f-m,y:l.y+g-v});break}case 2:{var w={x:.5,y:.5,angle:0,ratio:1},p=s[0],b=p.x,S=p.y,x=s[1],C=x.x,k=x.y,N=Math.atan2(k-S,C-b)-this.startTouchesAngle,G=Math.hypot(k-S,C-b)/this.startTouchesDistance,E=u.getBoundedRatio(l.ratio/G);w.ratio=E,w.angle=l.angle+N;var _=this.getDimensions(),I=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:l}),M=Math.min(_.width,_.height)-2*d,P=M/_.width,B=M/_.height,$=E/M,R=b-M/2/P,A=S-M/2/B,U=[R*Math.cos(-w.angle)-A*Math.sin(-w.angle),A*Math.cos(-w.angle)+R*Math.sin(-w.angle)];R=U[0],A=U[1],w.x=I.x-R*$,w.y=I.y+A*$,u.setState(w);break}}}}}},{key:"setSettings",value:function(i){this.settings=i}}])})(as);function Xh(e){if(Array.isArray(e))return Ln(e)}function Zh(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Kh(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
318
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hr(e){return Xh(e)||Zh(e)||jo(e)||Kh()}function qh(e,t){if(e==null)return{};var n={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(t.indexOf(i)!==-1)continue;n[i]=e[i]}return n}function Sn(e,t){if(e==null)return{};var n,i,r=qh(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var fr=(function(){function e(t,n){pe(this,e),this.key=t,this.size=n}return me(e,null,[{key:"compare",value:function(n,i){return n.size>i.size?-1:n.size<i.size||n.key>i.key?1:-1}}])})(),gr=(function(){function e(){pe(this,e),L(this,"width",0),L(this,"height",0),L(this,"cellSize",0),L(this,"columns",0),L(this,"rows",0),L(this,"cells",{})}return me(e,[{key:"resizeAndClear",value:function(n,i){this.width=n.width,this.height=n.height,this.cellSize=i,this.columns=Math.ceil(n.width/i),this.rows=Math.ceil(n.height/i),this.cells={}}},{key:"getIndex",value:function(n){var i=Math.floor(n.x/this.cellSize),r=Math.floor(n.y/this.cellSize);return r*this.columns+i}},{key:"add",value:function(n,i,r){var o=new fr(n,i),s=this.getIndex(r),a=this.cells[s];a||(a=[],this.cells[s]=a),a.push(o)}},{key:"organize",value:function(){for(var n in this.cells){var i=this.cells[n];i.sort(fr.compare)}}},{key:"getLabelsToDisplay",value:function(n,i){var r=this.cellSize*this.cellSize,o=r/n/n,s=o*i/r,a=Math.ceil(s),c=[];for(var u in this.cells)for(var l=this.cells[u],d=0;d<Math.min(a,l.length);d++)c.push(l[d].key);return c}}])})();function Qh(e){var t=e.graph,n=e.hoveredNode,i=e.highlightedNodes,r=e.displayedNodeLabels,o=[];return t.forEachEdge(function(s,a,c,u){(c===n||u===n||i.has(c)||i.has(u)||r.has(c)&&r.has(u))&&o.push(s)}),o}var pr=150,mr=50,ke=Object.prototype.hasOwnProperty;function Jh(e,t,n){if(!ke.call(n,"x")||!ke.call(n,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(t,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return n.color||(n.color=e.defaultNodeColor),!n.label&&n.label!==""&&(n.label=null),n.label!==void 0&&n.label!==null?n.label=""+n.label:n.label=null,n.size||(n.size=2),ke.call(n,"hidden")||(n.hidden=!1),ke.call(n,"highlighted")||(n.highlighted=!1),ke.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultNodeType),n.zIndex||(n.zIndex=0),n}function ef(e,t,n){return n.color||(n.color=e.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),ke.call(n,"hidden")||(n.hidden=!1),ke.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var tf=(function(e){function t(n,i){var r,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(pe(this,t),r=we(this,t),L(r,"elements",{}),L(r,"canvasContexts",{}),L(r,"webGLContexts",{}),L(r,"pickingLayers",new Set),L(r,"textures",{}),L(r,"frameBuffers",{}),L(r,"activeListeners",{}),L(r,"labelGrid",new gr),L(r,"nodeDataCache",{}),L(r,"edgeDataCache",{}),L(r,"nodeProgramIndex",{}),L(r,"edgeProgramIndex",{}),L(r,"nodesWithForcedLabels",new Set),L(r,"edgesWithForcedLabels",new Set),L(r,"nodeExtent",{x:[0,1],y:[0,1]}),L(r,"nodeZExtent",[1/0,-1/0]),L(r,"edgeZExtent",[1/0,-1/0]),L(r,"matrix",Ee()),L(r,"invMatrix",Ee()),L(r,"correctionRatio",1),L(r,"customBBox",null),L(r,"normalizationFunction",ur({x:[0,1],y:[0,1]})),L(r,"graphToViewportRatio",1),L(r,"itemIDsIndex",{}),L(r,"nodeIndices",{}),L(r,"edgeIndices",{}),L(r,"width",0),L(r,"height",0),L(r,"pixelRatio",ar()),L(r,"pickingDownSizingRatio",2*r.pixelRatio),L(r,"displayedNodeLabels",new Set),L(r,"displayedEdgeLabels",new Set),L(r,"highlightedNodes",new Set),L(r,"hoveredNode",null),L(r,"hoveredEdge",null),L(r,"renderFrame",null),L(r,"renderHighlightedNodesFrame",null),L(r,"needToProcess",!1),L(r,"checkEdgesEventsFrame",null),L(r,"nodePrograms",{}),L(r,"nodeHoverPrograms",{}),L(r,"edgePrograms",{}),r.settings=zh(o),En(r.settings),Ih(n),!(i instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");r.graph=n,r.container=i,r.createWebGLContext("edges",{picking:o.enableEdgeEvents}),r.createCanvasContext("edgeLabels"),r.createWebGLContext("nodes",{picking:!0}),r.createCanvasContext("labels"),r.createCanvasContext("hovers"),r.createWebGLContext("hoverNodes"),r.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),r.resize();for(var s in r.settings.nodeProgramClasses)r.registerNodeProgram(s,r.settings.nodeProgramClasses[s],r.settings.nodeHoverProgramClasses[s]);for(var a in r.settings.edgeProgramClasses)r.registerEdgeProgram(a,r.settings.edgeProgramClasses[a]);return r.camera=new lr,r.bindCameraHandlers(),r.mouseCaptor=new jh(r.elements.mouse,r),r.mouseCaptor.setSettings(r.settings),r.touchCaptor=new Yh(r.elements.mouse,r),r.touchCaptor.setSettings(r.settings),r.bindEventHandlers(),r.bindGraphHandlers(),r.handleSettingsUpdate(),r.refresh(),r}return be(t,e),me(t,[{key:"registerNodeProgram",value:function(i,r,o){return this.nodePrograms[i]&&this.nodePrograms[i].kill(),this.nodeHoverPrograms[i]&&this.nodeHoverPrograms[i].kill(),this.nodePrograms[i]=new r(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[i]=new(o||r)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(i,r){return this.edgePrograms[i]&&this.edgePrograms[i].kill(),this.edgePrograms[i]=new r(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(i){if(this.nodePrograms[i]){var r=this.nodePrograms,o=r[i],s=Sn(r,[i].map(vt));o.kill(),this.nodePrograms=s}if(this.nodeHoverPrograms[i]){var a=this.nodeHoverPrograms,c=a[i],u=Sn(a,[i].map(vt));c.kill(),this.nodePrograms=u}return this}},{key:"unregisterEdgeProgram",value:function(i){if(this.edgePrograms[i]){var r=this.edgePrograms,o=r[i],s=Sn(r,[i].map(vt));o.kill(),this.edgePrograms=s}return this}},{key:"resetWebGLTexture",value:function(i){var r=this.webGLContexts[i],o=this.frameBuffers[i],s=this.textures[i];s&&r.deleteTexture(s);var a=r.createTexture();return r.bindFramebuffer(r.FRAMEBUFFER,o),r.bindTexture(r.TEXTURE_2D,a),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,this.width,this.height,0,r.RGBA,r.UNSIGNED_BYTE,null),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,a,0),this.textures[i]=a,this}},{key:"bindCameraHandlers",value:function(){var i=this;return this.activeListeners.camera=function(){i.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(i){var r=i.x,o=i.y,s=Ki(this.webGLContexts.nodes,this.frameBuffers.nodes,r,o,this.pixelRatio,this.pickingDownSizingRatio),a=Zi.apply(void 0,hr(s)),c=this.itemIDsIndex[a];return c&&c.type==="node"?c.id:null}},{key:"bindEventHandlers",value:function(){var i=this;this.activeListeners.handleResize=function(){i.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(o){var s=pt(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}},c=i.getNodeAtPosition(s);if(c&&i.hoveredNode!==c&&!i.nodeDataCache[c].hidden){i.hoveredNode&&i.emit("leaveNode",W(W({},a),{},{node:i.hoveredNode})),i.hoveredNode=c,i.emit("enterNode",W(W({},a),{},{node:c})),i.scheduleHighlightedNodesRender();return}if(i.hoveredNode&&i.getNodeAtPosition(s)!==i.hoveredNode){var u=i.hoveredNode;i.hoveredNode=null,i.emit("leaveNode",W(W({},a),{},{node:u})),i.scheduleHighlightedNodesRender();return}if(i.settings.enableEdgeEvents){var l=i.hoveredNode?null:i.getEdgeAtPoint(a.event.x,a.event.y);l!==i.hoveredEdge&&(i.hoveredEdge&&i.emit("leaveEdge",W(W({},a),{},{edge:i.hoveredEdge})),l&&i.emit("enterEdge",W(W({},a),{},{edge:l})),i.hoveredEdge=l)}},this.activeListeners.handleMoveBody=function(o){var s=pt(o);i.emit("moveBody",{event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var s=pt(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};i.hoveredNode&&(i.emit("leaveNode",W(W({},a),{},{node:i.hoveredNode})),i.scheduleHighlightedNodesRender()),i.settings.enableEdgeEvents&&i.hoveredEdge&&(i.emit("leaveEdge",W(W({},a),{},{edge:i.hoveredEdge})),i.scheduleHighlightedNodesRender()),i.emit("leaveStage",W({},a))},this.activeListeners.handleEnter=function(o){var s=pt(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};i.emit("enterStage",W({},a))};var r=function(s){return function(a){var c=pt(a),u={event:c,preventSigmaDefault:function(){c.preventSigmaDefault()}},l=i.getNodeAtPosition(c);if(l)return i.emit("".concat(s,"Node"),W(W({},u),{},{node:l}));if(i.settings.enableEdgeEvents){var d=i.getEdgeAtPoint(c.x,c.y);if(d)return i.emit("".concat(s,"Edge"),W(W({},u),{},{edge:d}))}return i.emit("".concat(s,"Stage"),u)}};return this.activeListeners.handleClick=r("click"),this.activeListeners.handleRightClick=r("rightClick"),this.activeListeners.handleDoubleClick=r("doubleClick"),this.activeListeners.handleWheel=r("wheel"),this.activeListeners.handleDown=r("down"),this.activeListeners.handleUp=r("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var i=this,r=this.graph,o=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(s){var a,c=(a=s.hints)===null||a===void 0?void 0:a.attributes;i.graph.forEachNode(function(l){return i.updateNode(l)});var u=!c||c.some(function(l){return o.has(l)});i.refresh({partialGraph:{nodes:r.nodes()},skipIndexation:!u,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(s){var a,c=(a=s.hints)===null||a===void 0?void 0:a.attributes;i.graph.forEachEdge(function(l){return i.updateEdge(l)});var u=c&&["zIndex","type"].some(function(l){return c==null?void 0:c.includes(l)});i.refresh({partialGraph:{edges:r.edges()},skipIndexation:!u,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(s){var a=s.key;i.addNode(a),i.refresh({partialGraph:{nodes:[a]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(s){var a=s.key;i.refresh({partialGraph:{nodes:[a]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(s){var a=s.key;i.removeNode(a),i.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(s){var a=s.key;i.addEdge(a),i.refresh({partialGraph:{edges:[a]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(s){var a=s.key;i.refresh({partialGraph:{edges:[a]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(s){var a=s.key;i.removeEdge(a),i.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){i.clearEdgeState(),i.clearEdgeIndices(),i.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){i.clearEdgeState(),i.clearNodeState(),i.clearEdgeIndices(),i.clearNodeIndices(),i.refresh({schedule:!0})},r.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),r.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),r.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),r.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),r.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),r.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),r.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),r.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),r.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),r.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var i=this.graph;i.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(i,r){var o=Ki(this.webGLContexts.edges,this.frameBuffers.edges,i,r,this.pixelRatio,this.pickingDownSizingRatio),s=Zi.apply(void 0,hr(o)),a=this.itemIDsIndex[s];return a&&a.type==="edge"?a.id:null}},{key:"process",value:function(){var i=this;this.emit("beforeProcess");var r=this.graph,o=this.settings,s=this.getDimensions();if(this.nodeExtent=Ph(this.graph),!this.settings.autoRescale){var a=s.width,c=s.height,u=this.nodeExtent,l=u.x,d=u.y;this.nodeExtent={x:[(l[0]+l[1])/2-a/2,(l[0]+l[1])/2+a/2],y:[(d[0]+d[1])/2-c/2,(d[0]+d[1])/2+c/2]}}this.normalizationFunction=ur(this.customBBox||this.nodeExtent);var h=new lr,f=gt(h.getState(),s,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(s,o.labelGridCellSize);for(var g={},y={},m={},v={},w=1,p=r.nodes(),b=0,S=p.length;b<S;b++){var x=p[b],C=this.nodeDataCache[x],k=r.getNodeAttributes(x);C.x=k.x,C.y=k.y,this.normalizationFunction.applyTo(C),typeof C.label=="string"&&!C.hidden&&this.labelGrid.add(x,C.size,this.framedGraphToViewport(C,{matrix:f})),g[C.type]=(g[C.type]||0)+1}this.labelGrid.organize();for(var N in this.nodePrograms){if(!ke.call(this.nodePrograms,N))throw new Error('Sigma: could not find a suitable program for node type "'.concat(N,'"!'));this.nodePrograms[N].reallocate(g[N]||0),g[N]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(p=cr(this.nodeZExtent,function(J){return i.nodeDataCache[J].zIndex},p));for(var G=0,E=p.length;G<E;G++){var _=p[G];y[_]=w,v[y[_]]={type:"node",id:_},w++;var I=this.nodeDataCache[_];this.addNodeToProgram(_,y[_],g[I.type]++)}for(var M={},P=r.edges(),B=0,$=P.length;B<$;B++){var R=P[B],A=this.edgeDataCache[R];M[A.type]=(M[A.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(P=cr(this.edgeZExtent,function(J){return i.edgeDataCache[J].zIndex},P));for(var U in this.edgePrograms){if(!ke.call(this.edgePrograms,U))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(U,'"!'));this.edgePrograms[U].reallocate(M[U]||0),M[U]=0}for(var z=0,F=P.length;z<F;z++){var V=P[z];m[V]=w,v[m[V]]={type:"edge",id:V},w++;var q=this.edgeDataCache[V];this.addEdgeToProgram(V,m[V],M[q.type]++)}return this.itemIDsIndex=v,this.nodeIndices=y,this.edgeIndices=m,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(i){var r=this,o=this.settings;if(this.camera.minRatio=o.minCameraRatio,this.camera.maxRatio=o.maxCameraRatio,this.camera.enabledZooming=o.enableCameraZooming,this.camera.enabledPanning=o.enableCameraPanning,this.camera.enabledRotation=o.enableCameraRotation,o.cameraPanBoundaries?this.camera.clean=function(l){return r.cleanCameraState(l,o.cameraPanBoundaries&&In(o.cameraPanBoundaries)==="object"?o.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),i){if(i.edgeProgramClasses!==o.edgeProgramClasses){for(var s in o.edgeProgramClasses)o.edgeProgramClasses[s]!==i.edgeProgramClasses[s]&&this.registerEdgeProgram(s,o.edgeProgramClasses[s]);for(var a in i.edgeProgramClasses)o.edgeProgramClasses[a]||this.unregisterEdgeProgram(a)}if(i.nodeProgramClasses!==o.nodeProgramClasses||i.nodeHoverProgramClasses!==o.nodeHoverProgramClasses){for(var c in o.nodeProgramClasses)(o.nodeProgramClasses[c]!==i.nodeProgramClasses[c]||o.nodeHoverProgramClasses[c]!==i.nodeHoverProgramClasses[c])&&this.registerNodeProgram(c,o.nodeProgramClasses[c],o.nodeHoverProgramClasses[c]);for(var u in i.nodeProgramClasses)o.nodeProgramClasses[u]||this.unregisterNodeProgram(u)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=r.tolerance,s=o===void 0?0:o,a=r.boundaries,c=W({},i),u=a||this.nodeExtent,l=it(u.x,2),d=l[0],h=l[1],f=it(u.y,2),g=f[0],y=f[1],m=[this.graphToViewport({x:d,y:g},{cameraState:i}),this.graphToViewport({x:h,y:g},{cameraState:i}),this.graphToViewport({x:d,y},{cameraState:i}),this.graphToViewport({x:h,y},{cameraState:i})],v=1/0,w=-1/0,p=1/0,b=-1/0;m.forEach(function(M){var P=M.x,B=M.y;v=Math.min(v,P),w=Math.max(w,P),p=Math.min(p,B),b=Math.max(b,B)});var S=w-v,x=b-p,C=this.getDimensions(),k=C.width,N=C.height,G=0,E=0;if(S>=k?w<k-s?G=w-(k-s):v>s&&(G=v-s):w>k+s?G=w-(k+s):v<-s&&(G=v+s),x>=N?b<N-s?E=b-(N-s):p>s&&(E=p-s):b>N+s?E=b-(N+s):p<-s&&(E=p+s),G||E){var _=this.viewportToFramedGraph({x:0,y:0},{cameraState:i}),I=this.viewportToFramedGraph({x:G,y:E},{cameraState:i});G=I.x-_.x,E=I.y-_.y,c.x+=G,c.y+=E}return c}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var i=this.camera.getState(),r=this.labelGrid.getLabelsToDisplay(i.ratio,this.settings.labelDensity);dr(r,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var o=this.canvasContexts.labels,s=0,a=r.length;s<a;s++){var c=r[s],u=this.nodeDataCache[c];if(!this.displayedNodeLabels.has(c)&&!u.hidden){var l=this.framedGraphToViewport(u),d=l.x,h=l.y,f=this.scaleSize(u.size);if(!(!u.forceLabel&&f<this.settings.labelRenderedSizeThreshold)&&!(d<-pr||d>this.width+pr||h<-mr||h>this.height+mr)){this.displayedNodeLabels.add(c);var g=this.settings.defaultDrawNodeLabel,y=this.nodePrograms[u.type],m=(y==null?void 0:y.drawLabel)||g;m(o,W(W({key:c},u),{},{size:f,x:d,y:h}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var i=this.canvasContexts.edgeLabels;i.clearRect(0,0,this.width,this.height);var r=Qh({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});dr(r,this.edgesWithForcedLabels);for(var o=new Set,s=0,a=r.length;s<a;s++){var c=r[s],u=this.graph.extremities(c),l=this.nodeDataCache[u[0]],d=this.nodeDataCache[u[1]],h=this.edgeDataCache[c];if(!o.has(c)&&!(h.hidden||l.hidden||d.hidden)){var f=this.settings.defaultDrawEdgeLabel,g=this.edgePrograms[h.type],y=(g==null?void 0:g.drawLabel)||f;y(i,W(W({key:c},h),{},{size:this.scaleSize(h.size)}),W(W(W({key:u[0]},l),this.framedGraphToViewport(l)),{},{size:this.scaleSize(l.size)}),W(W(W({key:u[1]},d),this.framedGraphToViewport(d)),{},{size:this.scaleSize(d.size)}),this.settings),o.add(c)}}return this.displayedEdgeLabels=o,this}},{key:"renderHighlightedNodes",value:function(){var i=this,r=this.canvasContexts.hovers;r.clearRect(0,0,this.width,this.height);var o=function(f){var g=i.nodeDataCache[f],y=i.framedGraphToViewport(g),m=y.x,v=y.y,w=i.scaleSize(g.size),p=i.settings.defaultDrawNodeHover,b=i.nodePrograms[g.type],S=(b==null?void 0:b.drawHover)||p;S(r,W(W({key:f},g),{},{size:w,x:m,y:v}),i.settings)},s=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&s.push(this.hoveredNode),this.highlightedNodes.forEach(function(h){h!==i.hoveredNode&&s.push(h)}),s.forEach(function(h){return o(h)});var a={};s.forEach(function(h){var f=i.nodeDataCache[h].type;a[f]=(a[f]||0)+1});for(var c in this.nodeHoverPrograms)this.nodeHoverPrograms[c].reallocate(a[c]||0),a[c]=0;s.forEach(function(h){var f=i.nodeDataCache[h];i.nodeHoverPrograms[f.type].process(0,a[f.type]++,f)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var u=this.getRenderParams();for(var l in this.nodeHoverPrograms){var d=this.nodeHoverPrograms[l];d.render(u)}}},{key:"scheduleHighlightedNodesRender",value:function(){var i=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){i.renderHighlightedNodesFrame=null,i.renderHighlightedNodes(),i.renderEdgeLabels()}))}},{key:"render",value:function(){var i=this;this.emit("beforeRender");var r=function(){return i.emit("afterRender"),i};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(m){return i.resetWebGLTexture(m)}),!this.graph.order)return r();var o=this.mouseCaptor,s=this.camera.isAnimated()||o.isMoving||o.draggedEvents||o.currentWheelDirection,a=this.camera.getState(),c=this.getDimensions(),u=this.getGraphDimensions(),l=this.getStagePadding();this.matrix=gt(a,c,u,l),this.invMatrix=gt(a,c,u,l,!0),this.correctionRatio=Mh(this.matrix,a,c),this.graphToViewportRatio=this.getGraphToViewportRatio();var d=this.getRenderParams();for(var h in this.nodePrograms){var f=this.nodePrograms[h];f.render(d)}if(!this.settings.hideEdgesOnMove||!s)for(var g in this.edgePrograms){var y=this.edgePrograms[g];y.render(d)}return this.settings.hideLabelsOnMove&&s||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),r()}},{key:"addNode",value:function(i){var r=Object.assign({},this.graph.getNodeAttributes(i));this.settings.nodeReducer&&(r=this.settings.nodeReducer(i,r));var o=Jh(this.settings,i,r);this.nodeDataCache[i]=o,this.nodesWithForcedLabels.delete(i),o.forceLabel&&!o.hidden&&this.nodesWithForcedLabels.add(i),this.highlightedNodes.delete(i),o.highlighted&&!o.hidden&&this.highlightedNodes.add(i),this.settings.zIndex&&(o.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=o.zIndex),o.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=o.zIndex))}},{key:"updateNode",value:function(i){this.addNode(i);var r=this.nodeDataCache[i];this.normalizationFunction.applyTo(r)}},{key:"removeNode",value:function(i){delete this.nodeDataCache[i],delete this.nodeProgramIndex[i],this.highlightedNodes.delete(i),this.hoveredNode===i&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(i)}},{key:"addEdge",value:function(i){var r=Object.assign({},this.graph.getEdgeAttributes(i));this.settings.edgeReducer&&(r=this.settings.edgeReducer(i,r));var o=ef(this.settings,i,r);this.edgeDataCache[i]=o,this.edgesWithForcedLabels.delete(i),o.forceLabel&&!o.hidden&&this.edgesWithForcedLabels.add(i),this.settings.zIndex&&(o.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=o.zIndex),o.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=o.zIndex))}},{key:"updateEdge",value:function(i){this.addEdge(i)}},{key:"removeEdge",value:function(i){delete this.edgeDataCache[i],delete this.edgeProgramIndex[i],this.hoveredEdge===i&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(i)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new gr,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(i,r,o){var s=this.nodeDataCache[i],a=this.nodePrograms[s.type];if(!a)throw new Error('Sigma: could not find a suitable program for node type "'.concat(s.type,'"!'));a.process(r,o,s),this.nodeProgramIndex[i]=o}},{key:"addEdgeToProgram",value:function(i,r,o){var s=this.edgeDataCache[i],a=this.edgePrograms[s.type];if(!a)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(s.type,'"!'));var c=this.graph.extremities(i),u=this.nodeDataCache[c[0]],l=this.nodeDataCache[c[1]];a.process(r,o,u,l,s),this.edgeProgramIndex[i]=o}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var i=this.settings,r=i.stagePadding,o=i.autoRescale;return o&&r||0}},{key:"createLayer",value:function(i,r){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[i])throw new Error('Sigma: a layer named "'.concat(i,'" already exists'));var s=Gh(r,{position:"absolute"},{class:"sigma-".concat(i)});return o.style&&Object.assign(s.style,o.style),this.elements[i]=s,"beforeLayer"in o&&o.beforeLayer?this.elements[o.beforeLayer].before(s):"afterLayer"in o&&o.afterLayer?this.elements[o.afterLayer].after(s):this.container.appendChild(s),s}},{key:"createCanvas",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(i,"canvas",r)}},{key:"createCanvasContext",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.createCanvas(i,r),s={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[i]=o.getContext("2d",s),this}},{key:"createWebGLContext",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=(r==null?void 0:r.canvas)||this.createCanvas(i,r);r.hidden&&o.remove();var s=W({preserveDrawingBuffer:!1,antialias:!1},r),a;a=o.getContext("webgl2",s),a||(a=o.getContext("webgl",s)),a||(a=o.getContext("experimental-webgl",s));var c=a;if(this.webGLContexts[i]=c,c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA),r.picking){this.pickingLayers.add(i);var u=c.createFramebuffer();if(!u)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(i));this.frameBuffers[i]=u}return c}},{key:"killLayer",value:function(i){var r=this.elements[i];if(!r)throw new Error("Sigma: cannot kill layer ".concat(i,", which does not exist"));if(this.webGLContexts[i]){var o,s=this.webGLContexts[i];(o=s.getExtension("WEBGL_lose_context"))===null||o===void 0||o.loseContext(),delete this.webGLContexts[i]}else this.canvasContexts[i]&&delete this.canvasContexts[i];return r.remove(),delete this.elements[i],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(i){this.unbindCameraHandlers(),this.camera=i,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(i){i!==this.graph&&(this.hoveredNode&&!i.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!i.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=i,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var i=this.customBBox||this.nodeExtent;return{width:i.x[1]-i.x[0]||1,height:i.y[1]-i.y[0]||1}}},{key:"getNodeDisplayData",value:function(i){var r=this.nodeDataCache[i];return r?Object.assign({},r):void 0}},{key:"getEdgeDisplayData",value:function(i){var r=this.edgeDataCache[i];return r?Object.assign({},r):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return W({},this.settings)}},{key:"getSetting",value:function(i){return this.settings[i]}},{key:"setSetting",value:function(i,r){var o=W({},this.settings);return this.settings[i]=r,En(this.settings),this.handleSettingsUpdate(o),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(i,r){return this.setSetting(i,r(this.settings[i])),this}},{key:"setSettings",value:function(i){var r=W({},this.settings);return this.settings=W(W({},this.settings),i),En(this.settings),this.handleSettingsUpdate(r),this.scheduleRefresh(),this}},{key:"resize",value:function(i){var r=this.width,o=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=ar(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!i&&r===this.width&&o===this.height)return this;for(var s in this.elements){var a=this.elements[s];a.style.width=this.width+"px",a.style.height=this.height+"px"}for(var c in this.canvasContexts)this.elements[c].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[c].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[c].scale(this.pixelRatio,this.pixelRatio);for(var u in this.webGLContexts){this.elements[u].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[u].setAttribute("height",this.height*this.pixelRatio+"px");var l=this.webGLContexts[u];if(l.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(u)){var d=this.textures[u];d&&l.deleteTexture(d)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(i){var r=this,o=(i==null?void 0:i.skipIndexation)!==void 0?i==null?void 0:i.skipIndexation:!1,s=(i==null?void 0:i.schedule)!==void 0?i.schedule:!1,a=!i||!i.partialGraph;if(a)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(b){return r.addNode(b)}),this.graph.forEachEdge(function(b){return r.addEdge(b)});else{for(var c,u,l=((c=i.partialGraph)===null||c===void 0?void 0:c.nodes)||[],d=0,h=(l==null?void 0:l.length)||0;d<h;d++){var f=l[d];if(this.updateNode(f),o){var g=this.nodeProgramIndex[f];if(g===void 0)throw new Error('Sigma: node "'.concat(f,`" can't be repaint`));this.addNodeToProgram(f,this.nodeIndices[f],g)}}for(var y=(i==null||(u=i.partialGraph)===null||u===void 0?void 0:u.edges)||[],m=0,v=y.length;m<v;m++){var w=y[m];if(this.updateEdge(w),o){var p=this.edgeProgramIndex[w];if(p===void 0)throw new Error('Sigma: edge "'.concat(w,`" can't be repaint`));this.addEdgeToProgram(w,this.edgeIndices[w],p)}}}return(a||!o)&&(this.needToProcess=!0),s?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var i=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){i.render()})),this}},{key:"scheduleRefresh",value:function(i){return this.refresh(W(W({},i),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(i,r){var o=this.camera.getState(),s=o.ratio,a=o.angle,c=o.x,u=o.y,l=this.settings,d=l.minCameraRatio,h=l.maxCameraRatio;typeof h=="number"&&(r=Math.min(r,h)),typeof d=="number"&&(r=Math.max(r,d));var f=r/s,g={x:this.width/2,y:this.height/2},y=this.viewportToFramedGraph(i),m=this.viewportToFramedGraph(g);return{angle:a,x:(y.x-m.x)*(1-f)+c,y:(y.y-m.y)*(1-f)+u,ratio:r}}},{key:"viewRectangle",value:function(){var i=this.viewportToFramedGraph({x:0,y:0}),r=this.viewportToFramedGraph({x:this.width,y:0}),o=this.viewportToFramedGraph({x:0,y:this.height});return{x1:i.x,y1:i.y,x2:r.x,y2:r.y,height:r.y-o.y}}},{key:"framedGraphToViewport",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!r.cameraState||!!r.viewportDimensions||!!r.graphDimensions,s=r.matrix?r.matrix:o?gt(r.cameraState||this.camera.getState(),r.viewportDimensions||this.getDimensions(),r.graphDimensions||this.getGraphDimensions(),r.padding||this.getStagePadding()):this.matrix,a=Pn(s,i);return{x:(1+a.x)*this.width/2,y:(1-a.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!r.cameraState||!!r.viewportDimensions||!r.graphDimensions,s=r.matrix?r.matrix:o?gt(r.cameraState||this.camera.getState(),r.viewportDimensions||this.getDimensions(),r.graphDimensions||this.getGraphDimensions(),r.padding||this.getStagePadding(),!0):this.invMatrix,a=Pn(s,{x:i.x/this.width*2-1,y:1-i.y/this.height*2});return isNaN(a.x)&&(a.x=0),isNaN(a.y)&&(a.y=0),a}},{key:"viewportToGraph",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(i,r))}},{key:"graphToViewport",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(i),r)}},{key:"getGraphToViewportRatio",value:function(){var i={x:0,y:0},r={x:1,y:1},o=Math.sqrt(Math.pow(i.x-r.x,2)+Math.pow(i.y-r.y,2)),s=this.graphToViewport(i),a=this.graphToViewport(r),c=Math.sqrt(Math.pow(s.x-a.x,2)+Math.pow(s.y-a.y,2));return c/o}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(i){return this.customBBox=i,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var i=this.container;i.firstChild;)i.removeChild(i.firstChild);for(var r in this.nodePrograms)this.nodePrograms[r].kill();for(var o in this.nodeHoverPrograms)this.nodeHoverPrograms[o].kill();for(var s in this.edgePrograms)this.edgePrograms[s].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var a in this.elements)this.killLayer(a);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return i/this.settings.zoomToSizeRatioFunction(r)*(this.getSetting("itemSizesReference")==="positions"?r*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var i={};for(var r in this.elements)this.elements[r]instanceof HTMLCanvasElement&&(i[r]=this.elements[r]);return i}}])})(Qn),cf=tf;export{sf as B,af as C,ae as G,jt as H,Ot as M,Y as P,cf as S,La as a,Gc as b,Ic as c,of as i};
|
|
317
|
+
`,hl=ll,Vo=WebGLRenderingContext,er=Vo.UNSIGNED_BYTE,lt=Vo.FLOAT,fl=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],gl=(function(e){function t(){return pe(this,t),we(this,t,arguments)}return be(t,e),me(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:hl,FRAGMENT_SHADER_SOURCE:Uo,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:fl,ATTRIBUTES:[{name:"a_positionStart",size:2,type:lt},{name:"a_positionEnd",size:2,type:lt},{name:"a_normal",size:2,type:lt},{name:"a_color",size:4,type:er,normalized:!0},{name:"a_id",size:4,type:er,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:lt},{name:"a_normalCoef",size:1,type:lt}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(i,r,o,s,a){var c=a.size||1,u=o.x,l=o.y,d=s.x,h=s.y,f=Tt(a.color),g=d-u,y=h-l,m=g*g+y*y,v=0,w=0;m&&(m=1/Math.sqrt(m),v=-y*m*c,w=g*m*c);var p=this.array;p[r++]=u,p[r++]=l,p[r++]=d,p[r++]=h,p[r++]=v,p[r++]=w,p[r++]=f,p[r++]=i}},{key:"setUniforms",value:function(i,r){var o=r.gl,s=r.uniformLocations,a=s.u_matrix,c=s.u_zoomRatio,u=s.u_feather,l=s.u_pixelRatio,d=s.u_correctionRatio,h=s.u_sizeRatio,f=s.u_minEdgeThickness;o.uniformMatrix3fv(a,!1,i.matrix),o.uniform1f(c,i.zoomRatio),o.uniform1f(h,i.sizeRatio),o.uniform1f(d,i.correctionRatio),o.uniform1f(l,i.pixelRatio),o.uniform1f(u,i.antiAliasingFeather),o.uniform1f(f,i.minEdgeThickness)}}])})(Yn),Xn=(function(e){function t(){var n;return pe(this,t),n=we(this,t),n.rawEmitter=n,n}return be(t,e),me(t)})(br.EventEmitter),vn,tr;function pl(){return tr||(tr=1,vn=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}),vn}var ml=pl();const yl=fa(ml);var vl=function(t){return t},wl=function(t){return t*t},bl=function(t){return t*(2-t)},xl=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},El=function(t){return t*t*t},Sl=function(t){return--t*t*t+1},Cl=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},_l={linear:vl,quadraticIn:wl,quadraticOut:bl,quadraticInOut:xl,cubicIn:El,cubicOut:Sl,cubicInOut:Cl},Nl={easing:"quadraticInOut",duration:150};function Ee(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Ft(e,t,n){return e[0]=t,e[4]=typeof n=="number"?n:t,e}function nr(e,t){var n=Math.sin(t),i=Math.cos(t);return e[0]=i,e[1]=n,e[3]=-n,e[4]=i,e}function ir(e,t,n){return e[6]=t,e[7]=n,e}function Ge(e,t){var n=e[0],i=e[1],r=e[2],o=e[3],s=e[4],a=e[5],c=e[6],u=e[7],l=e[8],d=t[0],h=t[1],f=t[2],g=t[3],y=t[4],m=t[5],v=t[6],w=t[7],p=t[8];return e[0]=d*n+h*o+f*c,e[1]=d*i+h*s+f*u,e[2]=d*r+h*a+f*l,e[3]=g*n+y*o+m*c,e[4]=g*i+y*s+m*u,e[5]=g*r+y*a+m*l,e[6]=v*n+w*o+p*c,e[7]=v*i+w*s+p*u,e[8]=v*r+w*a+p*l,e}function Pn(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,i=e[0],r=e[1],o=e[3],s=e[4],a=e[6],c=e[7],u=t.x,l=t.y;return{x:u*i+l*o+a*n,y:u*r+l*s+c*n}}function Al(e,t){var n=e.height/e.width,i=t.height/t.width;return n<1&&i>1||n>1&&i<1?1:Math.min(Math.max(i,1/i),Math.max(1/n,n))}function ht(e,t,n,i,r){var o=e.angle,s=e.ratio,a=e.x,c=e.y,u=t.width,l=t.height,d=Ee(),h=Math.min(u,l)-2*i,f=Al(t,n);return r?(Ge(d,ir(Ee(),a,c)),Ge(d,Ft(Ee(),s)),Ge(d,nr(Ee(),o)),Ge(d,Ft(Ee(),u/h/2/f,l/h/2/f))):(Ge(d,Ft(Ee(),2*(h/u)*f,2*(h/l)*f)),Ge(d,nr(Ee(),-o)),Ge(d,Ft(Ee(),1/s)),Ge(d,ir(Ee(),-a,-c))),d}function Tl(e,t,n){var i=Pn(e,{x:Math.cos(t.angle),y:Math.sin(t.angle)},0),r=i.x,o=i.y;return 1/Math.sqrt(Math.pow(r,2)+Math.pow(o,2))/n.width}function kl(e){if(!e.order)return{x:[0,1],y:[0,1]};var t=1/0,n=-1/0,i=1/0,r=-1/0;return e.forEachNode(function(o,s){var a=s.x,c=s.y;a<t&&(t=a),a>n&&(n=a),c<i&&(i=c),c>r&&(r=c)}),{x:[t,n],y:[i,r]}}function Rl(e){if(!yl(e))throw new Error("Sigma: invalid graph instance.");e.forEachNode(function(t,n){if(!Number.isFinite(n.x)||!Number.isFinite(n.y))throw new Error("Sigma: Coordinates of node ".concat(t," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function Dl(e,t,n){var i=document.createElement(e);if(t)for(var r in t)i.style[r]=t[r];if(n)for(var o in n)i.setAttribute(o,n[o]);return i}function rr(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function or(e,t,n){return n.sort(function(i,r){var o=t(i)||0,s=t(r)||0;return o<s?-1:o>s?1:0})}function sr(e){var t=it(e.x,2),n=t[0],i=t[1],r=it(e.y,2),o=r[0],s=r[1],a=Math.max(i-n,s-o),c=(i+n)/2,u=(s+o)/2;(a===0||Math.abs(a)===1/0||isNaN(a))&&(a=1),isNaN(c)&&(c=0),isNaN(u)&&(u=0);var l=function(h){return{x:.5+(h.x-c)/a,y:.5+(h.y-u)/a}};return l.applyTo=function(d){d.x=.5+(d.x-c)/a,d.y=.5+(d.y-u)/a},l.inverse=function(d){return{x:c+a*(d.x-.5),y:u+a*(d.y-.5)}},l.ratio=a,l}function In(e){"@babel/helpers - typeof";return In=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},In(e)}function ar(e,t){var n=t.size;if(n!==0){var i=e.length;e.length+=n;var r=0;t.forEach(function(o){e[i+r]=o,r++})}}function wn(e){e=e||{};for(var t=0,n=arguments.length<=1?0:arguments.length-1;t<n;t++){var i=t+1<1||arguments.length<=t+1?void 0:arguments[t+1];i&&Object.assign(e,i)}return e}var Zn={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,renderEdgeLabels:!1,enableEdgeEvents:!1,defaultNodeColor:"#999",defaultNodeType:"circle",defaultEdgeColor:"#ccc",defaultEdgeType:"line",labelFont:"Arial",labelSize:14,labelWeight:"normal",labelColor:{color:"#000"},edgeLabelFont:"Arial",edgeLabelSize:14,edgeLabelWeight:"normal",edgeLabelColor:{attribute:"color"},stagePadding:30,defaultDrawEdgeLabel:Vd,defaultDrawNodeLabel:Fo,defaultDrawNodeHover:Wd,minEdgeThickness:1.7,antiAliasingFeather:1,dragTimeout:100,draggedEventsTolerance:3,inertiaDuration:200,inertiaRatio:3,zoomDuration:250,zoomingRatio:1.7,doubleClickTimeout:300,doubleClickZoomingRatio:2.2,doubleClickZoomingDuration:200,tapMoveTolerance:10,zoomToSizeRatioFunction:Math.sqrt,itemSizesReference:"screen",autoRescale:!0,autoCenter:!0,labelDensity:1,labelGridCellSize:100,labelRenderedSizeThreshold:6,nodeReducer:null,edgeReducer:null,zIndex:!1,minCameraRatio:null,maxCameraRatio:null,enableCameraZooming:!0,enableCameraPanning:!0,enableCameraRotation:!0,cameraPanBoundaries:null,allowInvalidContainer:!1,nodeProgramClasses:{},nodeHoverProgramClasses:{},edgeProgramClasses:{}},Ll={circle:en},Ml={arrow:dl,line:gl};function bn(e){if(typeof e.labelDensity!="number"||e.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var t=e.minCameraRatio,n=e.maxCameraRatio;if(typeof t=="number"&&typeof n=="number"&&n<t)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function Pl(e){var t=wn({},Zn,e);return t.nodeProgramClasses=wn({},Ll,t.nodeProgramClasses),t.edgeProgramClasses=wn({},Ml,t.edgeProgramClasses),t}var $t=1.5,cr=(function(e){function t(){var n;return pe(this,t),n=we(this,t),L(n,"x",.5),L(n,"y",.5),L(n,"angle",0),L(n,"ratio",1),L(n,"minRatio",null),L(n,"maxRatio",null),L(n,"enabledZooming",!0),L(n,"enabledPanning",!0),L(n,"enabledRotation",!0),L(n,"clean",null),L(n,"nextFrame",null),L(n,"previousState",null),L(n,"enabled",!0),n.previousState=n.getState(),n}return be(t,e),me(t,[{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"getState",value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:"hasState",value:function(i){return this.x===i.x&&this.y===i.y&&this.ratio===i.ratio&&this.angle===i.angle}},{key:"getPreviousState",value:function(){var i=this.previousState;return i?{x:i.x,y:i.y,angle:i.angle,ratio:i.ratio}:null}},{key:"getBoundedRatio",value:function(i){var r=i;return typeof this.minRatio=="number"&&(r=Math.max(r,this.minRatio)),typeof this.maxRatio=="number"&&(r=Math.min(r,this.maxRatio)),r}},{key:"validateState",value:function(i){var r={};return this.enabledPanning&&typeof i.x=="number"&&(r.x=i.x),this.enabledPanning&&typeof i.y=="number"&&(r.y=i.y),this.enabledZooming&&typeof i.ratio=="number"&&(r.ratio=this.getBoundedRatio(i.ratio)),this.enabledRotation&&typeof i.angle=="number"&&(r.angle=i.angle),this.clean?this.clean(W(W({},this.getState()),r)):r}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(i){if(!this.enabled)return this;this.previousState=this.getState();var r=this.validateState(i);return typeof r.x=="number"&&(this.x=r.x),typeof r.y=="number"&&(this.y=r.y),typeof r.ratio=="number"&&(this.ratio=r.ratio),typeof r.angle=="number"&&(this.angle=r.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(i){return this.setState(i(this.getState())),this}},{key:"animate",value:function(i){var r=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;if(!s)return new Promise(function(f){return r.animate(i,o,f)});if(this.enabled){var a=W(W({},Nl),o),c=this.validateState(i),u=typeof a.easing=="function"?a.easing:_l[a.easing],l=Date.now(),d=this.getState(),h=function(){var g=(Date.now()-l)/a.duration;if(g>=1){r.nextFrame=null,r.setState(c),r.animationCallback&&(r.animationCallback.call(null),r.animationCallback=void 0);return}var y=u(g),m={};typeof c.x=="number"&&(m.x=d.x+(c.x-d.x)*y),typeof c.y=="number"&&(m.y=d.y+(c.y-d.y)*y),r.enabledRotation&&typeof c.angle=="number"&&(m.angle=d.angle+(c.angle-d.angle)*y),typeof c.ratio=="number"&&(m.ratio=d.ratio+(c.ratio-d.ratio)*y),r.setState(m),r.nextFrame=requestAnimationFrame(h)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(h)):h(),this.animationCallback=s}}},{key:"animatedZoom",value:function(i){return i?typeof i=="number"?this.animate({ratio:this.ratio/i}):this.animate({ratio:this.ratio/(i.factor||$t)},i):this.animate({ratio:this.ratio/$t})}},{key:"animatedUnzoom",value:function(i){return i?typeof i=="number"?this.animate({ratio:this.ratio*i}):this.animate({ratio:this.ratio*(i.factor||$t)},i):this.animate({ratio:this.ratio*$t})}},{key:"animatedReset",value:function(i){return this.animate({x:.5,y:.5,ratio:1,angle:0},i)}},{key:"copy",value:function(){return t.from(this.getState())}}],[{key:"from",value:function(i){var r=new t;return r.setState(i)}}])})(Xn);function Se(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function Te(e,t){var n=W(W({},Se(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function ft(e){var t="x"in e?e:W(W({},e.touches[0]||e.previousTouches[0]),{},{original:e.original,sigmaDefaultPrevented:e.sigmaDefaultPrevented,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0,t.sigmaDefaultPrevented=!0}});return t}function Il(e,t){return W(W({},Te(e,t)),{},{delta:Wo(e)})}var Gl=2;function Bt(e){for(var t=[],n=0,i=Math.min(e.length,Gl);n<i;n++)t.push(e[n]);return t}function gt(e,t,n){var i={touches:Bt(e.touches).map(function(r){return Se(r,n)}),previousTouches:t.map(function(r){return Se(r,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){i.sigmaDefaultPrevented=!0},original:e};return i}function Wo(e){if(typeof e.deltaY<"u")return e.deltaY*-3/360;if(typeof e.detail<"u")return e.detail/-9;throw new Error("Captor: could not extract delta from event.")}var Yo=(function(e){function t(n,i){var r;return pe(this,t),r=we(this,t),r.container=n,r.renderer=i,r}return be(t,e),me(t)})(Xn),Fl=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],$l=Fl.reduce(function(e,t){return W(W({},e),{},L({},t,Zn[t]))},{}),zl=(function(e){function t(n,i){var r;return pe(this,t),r=we(this,t,[n,i]),L(r,"enabled",!0),L(r,"draggedEvents",0),L(r,"downStartTime",null),L(r,"lastMouseX",null),L(r,"lastMouseY",null),L(r,"isMouseDown",!1),L(r,"isMoving",!1),L(r,"movingTimeout",null),L(r,"startCameraState",null),L(r,"clicks",0),L(r,"doubleClickTimeout",null),L(r,"currentWheelDirection",0),L(r,"settings",$l),r.handleClick=r.handleClick.bind(r),r.handleRightClick=r.handleRightClick.bind(r),r.handleDown=r.handleDown.bind(r),r.handleUp=r.handleUp.bind(r),r.handleMove=r.handleMove.bind(r),r.handleWheel=r.handleWheel.bind(r),r.handleLeave=r.handleLeave.bind(r),r.handleEnter=r.handleEnter.bind(r),n.addEventListener("click",r.handleClick,{capture:!1}),n.addEventListener("contextmenu",r.handleRightClick,{capture:!1}),n.addEventListener("mousedown",r.handleDown,{capture:!1}),n.addEventListener("wheel",r.handleWheel,{capture:!1}),n.addEventListener("mouseleave",r.handleLeave,{capture:!1}),n.addEventListener("mouseenter",r.handleEnter,{capture:!1}),document.addEventListener("mousemove",r.handleMove,{capture:!1}),document.addEventListener("mouseup",r.handleUp,{capture:!1}),r}return be(t,e),me(t,[{key:"kill",value:function(){var i=this.container;i.removeEventListener("click",this.handleClick),i.removeEventListener("contextmenu",this.handleRightClick),i.removeEventListener("mousedown",this.handleDown),i.removeEventListener("wheel",this.handleWheel),i.removeEventListener("mouseleave",this.handleLeave),i.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(i){var r=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(i);setTimeout(function(){r.clicks=0,r.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",Te(i,this.container))}}},{key:"handleRightClick",value:function(i){this.enabled&&this.emit("rightClick",Te(i,this.container))}},{key:"handleDoubleClick",value:function(i){if(this.enabled){i.preventDefault(),i.stopPropagation();var r=Te(i,this.container);if(this.emit("doubleClick",r),!r.sigmaDefaultPrevented){var o=this.renderer.getCamera(),s=o.getBoundedRatio(o.getState().ratio/this.settings.doubleClickZoomingRatio);o.animate(this.renderer.getViewportZoomedState(Se(i,this.container),s),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(i){if(this.enabled){if(i.button===0){this.startCameraState=this.renderer.getCamera().getState();var r=Se(i,this.container),o=r.x,s=r.y;this.lastMouseX=o,this.lastMouseY=s,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",Te(i,this.container))}}},{key:"handleUp",value:function(i){var r=this;if(!(!this.enabled||!this.isMouseDown)){var o=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var s=Se(i,this.container),a=s.x,c=s.y,u=o.getState(),l=o.getPreviousState()||{x:0,y:0};this.isMoving?o.animate({x:u.x+this.settings.inertiaRatio*(u.x-l.x),y:u.y+this.settings.inertiaRatio*(u.y-l.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==a||this.lastMouseY!==c)&&o.setState({x:u.x,y:u.y}),this.isMoving=!1,setTimeout(function(){var d=r.draggedEvents>0;r.draggedEvents=0,d&&r.renderer.getSetting("hideEdgesOnMove")&&r.renderer.refresh()},0),this.emit("mouseup",Te(i,this.container))}}},{key:"handleMove",value:function(i){var r=this;if(this.enabled){var o=Te(i,this.container);if(this.emit("mousemovebody",o),(i.target===this.container||i.composedPath()[0]===this.container)&&this.emit("mousemove",o),!o.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){r.movingTimeout=null,r.isMoving=!1},this.settings.dragTimeout);var s=this.renderer.getCamera(),a=Se(i,this.container),c=a.x,u=a.y,l=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),d=this.renderer.viewportToFramedGraph({x:c,y:u}),h=l.x-d.x,f=l.y-d.y,g=s.getState(),y=g.x+h,m=g.y+f;s.setState({x:y,y:m}),this.lastMouseX=c,this.lastMouseY=u,i.preventDefault(),i.stopPropagation()}}}},{key:"handleLeave",value:function(i){this.emit("mouseleave",Te(i,this.container))}},{key:"handleEnter",value:function(i){this.emit("mouseenter",Te(i,this.container))}},{key:"handleWheel",value:function(i){var r=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var s=Wo(i);if(s){var a=Il(i,this.container);if(this.emit("wheel",a),a.sigmaDefaultPrevented){i.preventDefault(),i.stopPropagation();return}var c=o.getState().ratio,u=s>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,l=o.getBoundedRatio(c*u),d=s>0?1:-1,h=Date.now();c!==l&&(i.preventDefault(),i.stopPropagation(),!(this.currentWheelDirection===d&&this.lastWheelTriggerTime&&h-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(Se(i,this.container),l),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){r.currentWheelDirection=0}),this.currentWheelDirection=d,this.lastWheelTriggerTime=h))}}}},{key:"setSettings",value:function(i){this.settings=i}}])})(Yo),Bl=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],Ol=Bl.reduce(function(e,t){return W(W({},e),{},L({},t,Zn[t]))},{}),Ul=(function(e){function t(n,i){var r;return pe(this,t),r=we(this,t,[n,i]),L(r,"enabled",!0),L(r,"isMoving",!1),L(r,"hasMoved",!1),L(r,"touchMode",0),L(r,"startTouchesPositions",[]),L(r,"lastTouches",[]),L(r,"lastTap",null),L(r,"settings",Ol),r.handleStart=r.handleStart.bind(r),r.handleLeave=r.handleLeave.bind(r),r.handleMove=r.handleMove.bind(r),n.addEventListener("touchstart",r.handleStart,{capture:!1}),n.addEventListener("touchcancel",r.handleLeave,{capture:!1}),document.addEventListener("touchend",r.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",r.handleMove,{capture:!1,passive:!1}),r}return be(t,e),me(t,[{key:"kill",value:function(){var i=this.container;i.removeEventListener("touchstart",this.handleStart),i.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(i){var r=this;if(this.enabled){i.preventDefault();var o=Bt(i.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(f){return Se(f,r.container)}),this.touchMode===2){var s=it(this.startTouchesPositions,2),a=s[0],c=a.x,u=a.y,l=s[1],d=l.x,h=l.y;this.startTouchesAngle=Math.atan2(h-u,d-c),this.startTouchesDistance=Math.sqrt(Math.pow(d-c,2)+Math.pow(h-u,2))}this.emit("touchdown",gt(i,this.lastTouches,this.container)),this.lastTouches=o,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(i){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(i.cancelable&&i.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(i.touches.length===1){this.handleStart(i),i.preventDefault();break}case 1:if(this.isMoving){var r=this.renderer.getCamera(),o=r.getState(),s=r.getPreviousState()||{x:0,y:0};r.animate({x:o.x+this.settings.inertiaRatio*(o.x-s.x),y:o.y+this.settings.inertiaRatio*(o.y-s.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",gt(i,this.lastTouches,this.container)),!i.touches.length){var a=Se(this.lastTouches[0],this.container),c=this.startTouchesPositions[0],u=Math.pow(a.x-c.x,2)+Math.pow(a.y-c.y,2);if(!i.touches.length&&u<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var l=gt(i,this.lastTouches,this.container);if(this.emit("doubletap",l),this.lastTap=null,!l.sigmaDefaultPrevented){var d=this.renderer.getCamera(),h=d.getBoundedRatio(d.getState().ratio/this.settings.doubleClickZoomingRatio);d.animate(this.renderer.getViewportZoomedState(a,h),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var f=gt(i,this.lastTouches,this.container);this.emit("tap",f),this.lastTap={time:Date.now(),position:f.touches[0]||f.previousTouches[0]}}}this.lastTouches=Bt(i.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(i){var r=this;if(!(!this.enabled||!this.startTouchesPositions.length)){i.preventDefault();var o=Bt(i.touches),s=o.map(function(z){return Se(z,r.container)}),a=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=s;var c=gt(i,a,this.container);if(this.emit("touchmove",c),!c.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=s.some(function(z,F){var V=r.startTouchesPositions[F];return V&&(z.x!==V.x||z.y!==V.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){r.isMoving=!1},this.settings.dragTimeout);var u=this.renderer.getCamera(),l=this.startCameraState,d=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var h=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),f=h.x,g=h.y,y=this.renderer.viewportToFramedGraph(s[0]),m=y.x,v=y.y;u.setState({x:l.x+f-m,y:l.y+g-v});break}case 2:{var w={x:.5,y:.5,angle:0,ratio:1},p=s[0],b=p.x,S=p.y,x=s[1],C=x.x,k=x.y,N=Math.atan2(k-S,C-b)-this.startTouchesAngle,G=Math.hypot(k-S,C-b)/this.startTouchesDistance,E=u.getBoundedRatio(l.ratio/G);w.ratio=E,w.angle=l.angle+N;var _=this.getDimensions(),I=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:l}),M=Math.min(_.width,_.height)-2*d,P=M/_.width,B=M/_.height,$=E/M,R=b-M/2/P,T=S-M/2/B,U=[R*Math.cos(-w.angle)-T*Math.sin(-w.angle),T*Math.cos(-w.angle)+R*Math.sin(-w.angle)];R=U[0],T=U[1],w.x=I.x-R*$,w.y=I.y+T*$,u.setState(w);break}}}}}},{key:"setSettings",value:function(i){this.settings=i}}])})(Yo);function Hl(e){if(Array.isArray(e))return Ln(e)}function jl(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Vl(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
318
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ur(e){return Hl(e)||jl(e)||Ro(e)||Vl()}function Wl(e,t){if(e==null)return{};var n={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(t.indexOf(i)!==-1)continue;n[i]=e[i]}return n}function xn(e,t){if(e==null)return{};var n,i,r=Wl(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var dr=(function(){function e(t,n){pe(this,e),this.key=t,this.size=n}return me(e,null,[{key:"compare",value:function(n,i){return n.size>i.size?-1:n.size<i.size||n.key>i.key?1:-1}}])})(),lr=(function(){function e(){pe(this,e),L(this,"width",0),L(this,"height",0),L(this,"cellSize",0),L(this,"columns",0),L(this,"rows",0),L(this,"cells",{})}return me(e,[{key:"resizeAndClear",value:function(n,i){this.width=n.width,this.height=n.height,this.cellSize=i,this.columns=Math.ceil(n.width/i),this.rows=Math.ceil(n.height/i),this.cells={}}},{key:"getIndex",value:function(n){var i=Math.floor(n.x/this.cellSize),r=Math.floor(n.y/this.cellSize);return r*this.columns+i}},{key:"add",value:function(n,i,r){var o=new dr(n,i),s=this.getIndex(r),a=this.cells[s];a||(a=[],this.cells[s]=a),a.push(o)}},{key:"organize",value:function(){for(var n in this.cells){var i=this.cells[n];i.sort(dr.compare)}}},{key:"getLabelsToDisplay",value:function(n,i){var r=this.cellSize*this.cellSize,o=r/n/n,s=o*i/r,a=Math.ceil(s),c=[];for(var u in this.cells)for(var l=this.cells[u],d=0;d<Math.min(a,l.length);d++)c.push(l[d].key);return c}}])})();function Yl(e){var t=e.graph,n=e.hoveredNode,i=e.highlightedNodes,r=e.displayedNodeLabels,o=[];return t.forEachEdge(function(s,a,c,u){(c===n||u===n||i.has(c)||i.has(u)||r.has(c)&&r.has(u))&&o.push(s)}),o}var hr=150,fr=50,ke=Object.prototype.hasOwnProperty;function Xl(e,t,n){if(!ke.call(n,"x")||!ke.call(n,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(t,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return n.color||(n.color=e.defaultNodeColor),!n.label&&n.label!==""&&(n.label=null),n.label!==void 0&&n.label!==null?n.label=""+n.label:n.label=null,n.size||(n.size=2),ke.call(n,"hidden")||(n.hidden=!1),ke.call(n,"highlighted")||(n.highlighted=!1),ke.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultNodeType),n.zIndex||(n.zIndex=0),n}function Zl(e,t,n){return n.color||(n.color=e.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),ke.call(n,"hidden")||(n.hidden=!1),ke.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var Kl=(function(e){function t(n,i){var r,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(pe(this,t),r=we(this,t),L(r,"elements",{}),L(r,"canvasContexts",{}),L(r,"webGLContexts",{}),L(r,"pickingLayers",new Set),L(r,"textures",{}),L(r,"frameBuffers",{}),L(r,"activeListeners",{}),L(r,"labelGrid",new lr),L(r,"nodeDataCache",{}),L(r,"edgeDataCache",{}),L(r,"nodeProgramIndex",{}),L(r,"edgeProgramIndex",{}),L(r,"nodesWithForcedLabels",new Set),L(r,"edgesWithForcedLabels",new Set),L(r,"nodeExtent",{x:[0,1],y:[0,1]}),L(r,"nodeZExtent",[1/0,-1/0]),L(r,"edgeZExtent",[1/0,-1/0]),L(r,"matrix",Ee()),L(r,"invMatrix",Ee()),L(r,"correctionRatio",1),L(r,"customBBox",null),L(r,"normalizationFunction",sr({x:[0,1],y:[0,1]})),L(r,"graphToViewportRatio",1),L(r,"itemIDsIndex",{}),L(r,"nodeIndices",{}),L(r,"edgeIndices",{}),L(r,"width",0),L(r,"height",0),L(r,"pixelRatio",rr()),L(r,"pickingDownSizingRatio",2*r.pixelRatio),L(r,"displayedNodeLabels",new Set),L(r,"displayedEdgeLabels",new Set),L(r,"highlightedNodes",new Set),L(r,"hoveredNode",null),L(r,"hoveredEdge",null),L(r,"renderFrame",null),L(r,"renderHighlightedNodesFrame",null),L(r,"needToProcess",!1),L(r,"checkEdgesEventsFrame",null),L(r,"nodePrograms",{}),L(r,"nodeHoverPrograms",{}),L(r,"edgePrograms",{}),r.settings=Pl(o),bn(r.settings),Rl(n),!(i instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");r.graph=n,r.container=i,r.createWebGLContext("edges",{picking:o.enableEdgeEvents}),r.createCanvasContext("edgeLabels"),r.createWebGLContext("nodes",{picking:!0}),r.createCanvasContext("labels"),r.createCanvasContext("hovers"),r.createWebGLContext("hoverNodes"),r.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),r.resize();for(var s in r.settings.nodeProgramClasses)r.registerNodeProgram(s,r.settings.nodeProgramClasses[s],r.settings.nodeHoverProgramClasses[s]);for(var a in r.settings.edgeProgramClasses)r.registerEdgeProgram(a,r.settings.edgeProgramClasses[a]);return r.camera=new cr,r.bindCameraHandlers(),r.mouseCaptor=new zl(r.elements.mouse,r),r.mouseCaptor.setSettings(r.settings),r.touchCaptor=new Ul(r.elements.mouse,r),r.touchCaptor.setSettings(r.settings),r.bindEventHandlers(),r.bindGraphHandlers(),r.handleSettingsUpdate(),r.refresh(),r}return be(t,e),me(t,[{key:"registerNodeProgram",value:function(i,r,o){return this.nodePrograms[i]&&this.nodePrograms[i].kill(),this.nodeHoverPrograms[i]&&this.nodeHoverPrograms[i].kill(),this.nodePrograms[i]=new r(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[i]=new(o||r)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(i,r){return this.edgePrograms[i]&&this.edgePrograms[i].kill(),this.edgePrograms[i]=new r(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(i){if(this.nodePrograms[i]){var r=this.nodePrograms,o=r[i],s=xn(r,[i].map(vt));o.kill(),this.nodePrograms=s}if(this.nodeHoverPrograms[i]){var a=this.nodeHoverPrograms,c=a[i],u=xn(a,[i].map(vt));c.kill(),this.nodePrograms=u}return this}},{key:"unregisterEdgeProgram",value:function(i){if(this.edgePrograms[i]){var r=this.edgePrograms,o=r[i],s=xn(r,[i].map(vt));o.kill(),this.edgePrograms=s}return this}},{key:"resetWebGLTexture",value:function(i){var r=this.webGLContexts[i],o=this.frameBuffers[i],s=this.textures[i];s&&r.deleteTexture(s);var a=r.createTexture();return r.bindFramebuffer(r.FRAMEBUFFER,o),r.bindTexture(r.TEXTURE_2D,a),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,this.width,this.height,0,r.RGBA,r.UNSIGNED_BYTE,null),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,a,0),this.textures[i]=a,this}},{key:"bindCameraHandlers",value:function(){var i=this;return this.activeListeners.camera=function(){i.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(i){var r=i.x,o=i.y,s=Yi(this.webGLContexts.nodes,this.frameBuffers.nodes,r,o,this.pixelRatio,this.pickingDownSizingRatio),a=Wi.apply(void 0,ur(s)),c=this.itemIDsIndex[a];return c&&c.type==="node"?c.id:null}},{key:"bindEventHandlers",value:function(){var i=this;this.activeListeners.handleResize=function(){i.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(o){var s=ft(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}},c=i.getNodeAtPosition(s);if(c&&i.hoveredNode!==c&&!i.nodeDataCache[c].hidden){i.hoveredNode&&i.emit("leaveNode",W(W({},a),{},{node:i.hoveredNode})),i.hoveredNode=c,i.emit("enterNode",W(W({},a),{},{node:c})),i.scheduleHighlightedNodesRender();return}if(i.hoveredNode&&i.getNodeAtPosition(s)!==i.hoveredNode){var u=i.hoveredNode;i.hoveredNode=null,i.emit("leaveNode",W(W({},a),{},{node:u})),i.scheduleHighlightedNodesRender();return}if(i.settings.enableEdgeEvents){var l=i.hoveredNode?null:i.getEdgeAtPoint(a.event.x,a.event.y);l!==i.hoveredEdge&&(i.hoveredEdge&&i.emit("leaveEdge",W(W({},a),{},{edge:i.hoveredEdge})),l&&i.emit("enterEdge",W(W({},a),{},{edge:l})),i.hoveredEdge=l)}},this.activeListeners.handleMoveBody=function(o){var s=ft(o);i.emit("moveBody",{event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var s=ft(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};i.hoveredNode&&(i.emit("leaveNode",W(W({},a),{},{node:i.hoveredNode})),i.scheduleHighlightedNodesRender()),i.settings.enableEdgeEvents&&i.hoveredEdge&&(i.emit("leaveEdge",W(W({},a),{},{edge:i.hoveredEdge})),i.scheduleHighlightedNodesRender()),i.emit("leaveStage",W({},a))},this.activeListeners.handleEnter=function(o){var s=ft(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};i.emit("enterStage",W({},a))};var r=function(s){return function(a){var c=ft(a),u={event:c,preventSigmaDefault:function(){c.preventSigmaDefault()}},l=i.getNodeAtPosition(c);if(l)return i.emit("".concat(s,"Node"),W(W({},u),{},{node:l}));if(i.settings.enableEdgeEvents){var d=i.getEdgeAtPoint(c.x,c.y);if(d)return i.emit("".concat(s,"Edge"),W(W({},u),{},{edge:d}))}return i.emit("".concat(s,"Stage"),u)}};return this.activeListeners.handleClick=r("click"),this.activeListeners.handleRightClick=r("rightClick"),this.activeListeners.handleDoubleClick=r("doubleClick"),this.activeListeners.handleWheel=r("wheel"),this.activeListeners.handleDown=r("down"),this.activeListeners.handleUp=r("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var i=this,r=this.graph,o=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(s){var a,c=(a=s.hints)===null||a===void 0?void 0:a.attributes;i.graph.forEachNode(function(l){return i.updateNode(l)});var u=!c||c.some(function(l){return o.has(l)});i.refresh({partialGraph:{nodes:r.nodes()},skipIndexation:!u,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(s){var a,c=(a=s.hints)===null||a===void 0?void 0:a.attributes;i.graph.forEachEdge(function(l){return i.updateEdge(l)});var u=c&&["zIndex","type"].some(function(l){return c==null?void 0:c.includes(l)});i.refresh({partialGraph:{edges:r.edges()},skipIndexation:!u,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(s){var a=s.key;i.addNode(a),i.refresh({partialGraph:{nodes:[a]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(s){var a=s.key;i.refresh({partialGraph:{nodes:[a]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(s){var a=s.key;i.removeNode(a),i.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(s){var a=s.key;i.addEdge(a),i.refresh({partialGraph:{edges:[a]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(s){var a=s.key;i.refresh({partialGraph:{edges:[a]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(s){var a=s.key;i.removeEdge(a),i.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){i.clearEdgeState(),i.clearEdgeIndices(),i.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){i.clearEdgeState(),i.clearNodeState(),i.clearEdgeIndices(),i.clearNodeIndices(),i.refresh({schedule:!0})},r.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),r.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),r.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),r.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),r.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),r.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),r.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),r.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),r.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),r.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var i=this.graph;i.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(i,r){var o=Yi(this.webGLContexts.edges,this.frameBuffers.edges,i,r,this.pixelRatio,this.pickingDownSizingRatio),s=Wi.apply(void 0,ur(o)),a=this.itemIDsIndex[s];return a&&a.type==="edge"?a.id:null}},{key:"process",value:function(){var i=this;this.emit("beforeProcess");var r=this.graph,o=this.settings,s=this.getDimensions();if(this.nodeExtent=kl(this.graph),!this.settings.autoRescale){var a=s.width,c=s.height,u=this.nodeExtent,l=u.x,d=u.y;this.nodeExtent={x:[(l[0]+l[1])/2-a/2,(l[0]+l[1])/2+a/2],y:[(d[0]+d[1])/2-c/2,(d[0]+d[1])/2+c/2]}}this.normalizationFunction=sr(this.customBBox||this.nodeExtent);var h=new cr,f=ht(h.getState(),s,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(s,o.labelGridCellSize);for(var g={},y={},m={},v={},w=1,p=r.nodes(),b=0,S=p.length;b<S;b++){var x=p[b],C=this.nodeDataCache[x],k=r.getNodeAttributes(x);C.x=k.x,C.y=k.y,this.normalizationFunction.applyTo(C),typeof C.label=="string"&&!C.hidden&&this.labelGrid.add(x,C.size,this.framedGraphToViewport(C,{matrix:f})),g[C.type]=(g[C.type]||0)+1}this.labelGrid.organize();for(var N in this.nodePrograms){if(!ke.call(this.nodePrograms,N))throw new Error('Sigma: could not find a suitable program for node type "'.concat(N,'"!'));this.nodePrograms[N].reallocate(g[N]||0),g[N]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(p=or(this.nodeZExtent,function(J){return i.nodeDataCache[J].zIndex},p));for(var G=0,E=p.length;G<E;G++){var _=p[G];y[_]=w,v[y[_]]={type:"node",id:_},w++;var I=this.nodeDataCache[_];this.addNodeToProgram(_,y[_],g[I.type]++)}for(var M={},P=r.edges(),B=0,$=P.length;B<$;B++){var R=P[B],T=this.edgeDataCache[R];M[T.type]=(M[T.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(P=or(this.edgeZExtent,function(J){return i.edgeDataCache[J].zIndex},P));for(var U in this.edgePrograms){if(!ke.call(this.edgePrograms,U))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(U,'"!'));this.edgePrograms[U].reallocate(M[U]||0),M[U]=0}for(var z=0,F=P.length;z<F;z++){var V=P[z];m[V]=w,v[m[V]]={type:"edge",id:V},w++;var q=this.edgeDataCache[V];this.addEdgeToProgram(V,m[V],M[q.type]++)}return this.itemIDsIndex=v,this.nodeIndices=y,this.edgeIndices=m,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(i){var r=this,o=this.settings;if(this.camera.minRatio=o.minCameraRatio,this.camera.maxRatio=o.maxCameraRatio,this.camera.enabledZooming=o.enableCameraZooming,this.camera.enabledPanning=o.enableCameraPanning,this.camera.enabledRotation=o.enableCameraRotation,o.cameraPanBoundaries?this.camera.clean=function(l){return r.cleanCameraState(l,o.cameraPanBoundaries&&In(o.cameraPanBoundaries)==="object"?o.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),i){if(i.edgeProgramClasses!==o.edgeProgramClasses){for(var s in o.edgeProgramClasses)o.edgeProgramClasses[s]!==i.edgeProgramClasses[s]&&this.registerEdgeProgram(s,o.edgeProgramClasses[s]);for(var a in i.edgeProgramClasses)o.edgeProgramClasses[a]||this.unregisterEdgeProgram(a)}if(i.nodeProgramClasses!==o.nodeProgramClasses||i.nodeHoverProgramClasses!==o.nodeHoverProgramClasses){for(var c in o.nodeProgramClasses)(o.nodeProgramClasses[c]!==i.nodeProgramClasses[c]||o.nodeHoverProgramClasses[c]!==i.nodeHoverProgramClasses[c])&&this.registerNodeProgram(c,o.nodeProgramClasses[c],o.nodeHoverProgramClasses[c]);for(var u in i.nodeProgramClasses)o.nodeProgramClasses[u]||this.unregisterNodeProgram(u)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=r.tolerance,s=o===void 0?0:o,a=r.boundaries,c=W({},i),u=a||this.nodeExtent,l=it(u.x,2),d=l[0],h=l[1],f=it(u.y,2),g=f[0],y=f[1],m=[this.graphToViewport({x:d,y:g},{cameraState:i}),this.graphToViewport({x:h,y:g},{cameraState:i}),this.graphToViewport({x:d,y},{cameraState:i}),this.graphToViewport({x:h,y},{cameraState:i})],v=1/0,w=-1/0,p=1/0,b=-1/0;m.forEach(function(M){var P=M.x,B=M.y;v=Math.min(v,P),w=Math.max(w,P),p=Math.min(p,B),b=Math.max(b,B)});var S=w-v,x=b-p,C=this.getDimensions(),k=C.width,N=C.height,G=0,E=0;if(S>=k?w<k-s?G=w-(k-s):v>s&&(G=v-s):w>k+s?G=w-(k+s):v<-s&&(G=v+s),x>=N?b<N-s?E=b-(N-s):p>s&&(E=p-s):b>N+s?E=b-(N+s):p<-s&&(E=p+s),G||E){var _=this.viewportToFramedGraph({x:0,y:0},{cameraState:i}),I=this.viewportToFramedGraph({x:G,y:E},{cameraState:i});G=I.x-_.x,E=I.y-_.y,c.x+=G,c.y+=E}return c}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var i=this.camera.getState(),r=this.labelGrid.getLabelsToDisplay(i.ratio,this.settings.labelDensity);ar(r,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var o=this.canvasContexts.labels,s=0,a=r.length;s<a;s++){var c=r[s],u=this.nodeDataCache[c];if(!this.displayedNodeLabels.has(c)&&!u.hidden){var l=this.framedGraphToViewport(u),d=l.x,h=l.y,f=this.scaleSize(u.size);if(!(!u.forceLabel&&f<this.settings.labelRenderedSizeThreshold)&&!(d<-hr||d>this.width+hr||h<-fr||h>this.height+fr)){this.displayedNodeLabels.add(c);var g=this.settings.defaultDrawNodeLabel,y=this.nodePrograms[u.type],m=(y==null?void 0:y.drawLabel)||g;m(o,W(W({key:c},u),{},{size:f,x:d,y:h}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var i=this.canvasContexts.edgeLabels;i.clearRect(0,0,this.width,this.height);var r=Yl({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});ar(r,this.edgesWithForcedLabels);for(var o=new Set,s=0,a=r.length;s<a;s++){var c=r[s],u=this.graph.extremities(c),l=this.nodeDataCache[u[0]],d=this.nodeDataCache[u[1]],h=this.edgeDataCache[c];if(!o.has(c)&&!(h.hidden||l.hidden||d.hidden)){var f=this.settings.defaultDrawEdgeLabel,g=this.edgePrograms[h.type],y=(g==null?void 0:g.drawLabel)||f;y(i,W(W({key:c},h),{},{size:this.scaleSize(h.size)}),W(W(W({key:u[0]},l),this.framedGraphToViewport(l)),{},{size:this.scaleSize(l.size)}),W(W(W({key:u[1]},d),this.framedGraphToViewport(d)),{},{size:this.scaleSize(d.size)}),this.settings),o.add(c)}}return this.displayedEdgeLabels=o,this}},{key:"renderHighlightedNodes",value:function(){var i=this,r=this.canvasContexts.hovers;r.clearRect(0,0,this.width,this.height);var o=function(f){var g=i.nodeDataCache[f],y=i.framedGraphToViewport(g),m=y.x,v=y.y,w=i.scaleSize(g.size),p=i.settings.defaultDrawNodeHover,b=i.nodePrograms[g.type],S=(b==null?void 0:b.drawHover)||p;S(r,W(W({key:f},g),{},{size:w,x:m,y:v}),i.settings)},s=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&s.push(this.hoveredNode),this.highlightedNodes.forEach(function(h){h!==i.hoveredNode&&s.push(h)}),s.forEach(function(h){return o(h)});var a={};s.forEach(function(h){var f=i.nodeDataCache[h].type;a[f]=(a[f]||0)+1});for(var c in this.nodeHoverPrograms)this.nodeHoverPrograms[c].reallocate(a[c]||0),a[c]=0;s.forEach(function(h){var f=i.nodeDataCache[h];i.nodeHoverPrograms[f.type].process(0,a[f.type]++,f)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var u=this.getRenderParams();for(var l in this.nodeHoverPrograms){var d=this.nodeHoverPrograms[l];d.render(u)}}},{key:"scheduleHighlightedNodesRender",value:function(){var i=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){i.renderHighlightedNodesFrame=null,i.renderHighlightedNodes(),i.renderEdgeLabels()}))}},{key:"render",value:function(){var i=this;this.emit("beforeRender");var r=function(){return i.emit("afterRender"),i};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(m){return i.resetWebGLTexture(m)}),!this.graph.order)return r();var o=this.mouseCaptor,s=this.camera.isAnimated()||o.isMoving||o.draggedEvents||o.currentWheelDirection,a=this.camera.getState(),c=this.getDimensions(),u=this.getGraphDimensions(),l=this.getStagePadding();this.matrix=ht(a,c,u,l),this.invMatrix=ht(a,c,u,l,!0),this.correctionRatio=Tl(this.matrix,a,c),this.graphToViewportRatio=this.getGraphToViewportRatio();var d=this.getRenderParams();for(var h in this.nodePrograms){var f=this.nodePrograms[h];f.render(d)}if(!this.settings.hideEdgesOnMove||!s)for(var g in this.edgePrograms){var y=this.edgePrograms[g];y.render(d)}return this.settings.hideLabelsOnMove&&s||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),r()}},{key:"addNode",value:function(i){var r=Object.assign({},this.graph.getNodeAttributes(i));this.settings.nodeReducer&&(r=this.settings.nodeReducer(i,r));var o=Xl(this.settings,i,r);this.nodeDataCache[i]=o,this.nodesWithForcedLabels.delete(i),o.forceLabel&&!o.hidden&&this.nodesWithForcedLabels.add(i),this.highlightedNodes.delete(i),o.highlighted&&!o.hidden&&this.highlightedNodes.add(i),this.settings.zIndex&&(o.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=o.zIndex),o.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=o.zIndex))}},{key:"updateNode",value:function(i){this.addNode(i);var r=this.nodeDataCache[i];this.normalizationFunction.applyTo(r)}},{key:"removeNode",value:function(i){delete this.nodeDataCache[i],delete this.nodeProgramIndex[i],this.highlightedNodes.delete(i),this.hoveredNode===i&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(i)}},{key:"addEdge",value:function(i){var r=Object.assign({},this.graph.getEdgeAttributes(i));this.settings.edgeReducer&&(r=this.settings.edgeReducer(i,r));var o=Zl(this.settings,i,r);this.edgeDataCache[i]=o,this.edgesWithForcedLabels.delete(i),o.forceLabel&&!o.hidden&&this.edgesWithForcedLabels.add(i),this.settings.zIndex&&(o.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=o.zIndex),o.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=o.zIndex))}},{key:"updateEdge",value:function(i){this.addEdge(i)}},{key:"removeEdge",value:function(i){delete this.edgeDataCache[i],delete this.edgeProgramIndex[i],this.hoveredEdge===i&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(i)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new lr,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(i,r,o){var s=this.nodeDataCache[i],a=this.nodePrograms[s.type];if(!a)throw new Error('Sigma: could not find a suitable program for node type "'.concat(s.type,'"!'));a.process(r,o,s),this.nodeProgramIndex[i]=o}},{key:"addEdgeToProgram",value:function(i,r,o){var s=this.edgeDataCache[i],a=this.edgePrograms[s.type];if(!a)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(s.type,'"!'));var c=this.graph.extremities(i),u=this.nodeDataCache[c[0]],l=this.nodeDataCache[c[1]];a.process(r,o,u,l,s),this.edgeProgramIndex[i]=o}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var i=this.settings,r=i.stagePadding,o=i.autoRescale;return o&&r||0}},{key:"createLayer",value:function(i,r){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[i])throw new Error('Sigma: a layer named "'.concat(i,'" already exists'));var s=Dl(r,{position:"absolute"},{class:"sigma-".concat(i)});return o.style&&Object.assign(s.style,o.style),this.elements[i]=s,"beforeLayer"in o&&o.beforeLayer?this.elements[o.beforeLayer].before(s):"afterLayer"in o&&o.afterLayer?this.elements[o.afterLayer].after(s):this.container.appendChild(s),s}},{key:"createCanvas",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(i,"canvas",r)}},{key:"createCanvasContext",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.createCanvas(i,r),s={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[i]=o.getContext("2d",s),this}},{key:"createWebGLContext",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=(r==null?void 0:r.canvas)||this.createCanvas(i,r);r.hidden&&o.remove();var s=W({preserveDrawingBuffer:!1,antialias:!1},r),a;a=o.getContext("webgl2",s),a||(a=o.getContext("webgl",s)),a||(a=o.getContext("experimental-webgl",s));var c=a;if(this.webGLContexts[i]=c,c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA),r.picking){this.pickingLayers.add(i);var u=c.createFramebuffer();if(!u)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(i));this.frameBuffers[i]=u}return c}},{key:"killLayer",value:function(i){var r=this.elements[i];if(!r)throw new Error("Sigma: cannot kill layer ".concat(i,", which does not exist"));if(this.webGLContexts[i]){var o,s=this.webGLContexts[i];(o=s.getExtension("WEBGL_lose_context"))===null||o===void 0||o.loseContext(),delete this.webGLContexts[i]}else this.canvasContexts[i]&&delete this.canvasContexts[i];return r.remove(),delete this.elements[i],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(i){this.unbindCameraHandlers(),this.camera=i,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(i){i!==this.graph&&(this.hoveredNode&&!i.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!i.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=i,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var i=this.customBBox||this.nodeExtent;return{width:i.x[1]-i.x[0]||1,height:i.y[1]-i.y[0]||1}}},{key:"getNodeDisplayData",value:function(i){var r=this.nodeDataCache[i];return r?Object.assign({},r):void 0}},{key:"getEdgeDisplayData",value:function(i){var r=this.edgeDataCache[i];return r?Object.assign({},r):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return W({},this.settings)}},{key:"getSetting",value:function(i){return this.settings[i]}},{key:"setSetting",value:function(i,r){var o=W({},this.settings);return this.settings[i]=r,bn(this.settings),this.handleSettingsUpdate(o),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(i,r){return this.setSetting(i,r(this.settings[i])),this}},{key:"setSettings",value:function(i){var r=W({},this.settings);return this.settings=W(W({},this.settings),i),bn(this.settings),this.handleSettingsUpdate(r),this.scheduleRefresh(),this}},{key:"resize",value:function(i){var r=this.width,o=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=rr(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!i&&r===this.width&&o===this.height)return this;for(var s in this.elements){var a=this.elements[s];a.style.width=this.width+"px",a.style.height=this.height+"px"}for(var c in this.canvasContexts)this.elements[c].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[c].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[c].scale(this.pixelRatio,this.pixelRatio);for(var u in this.webGLContexts){this.elements[u].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[u].setAttribute("height",this.height*this.pixelRatio+"px");var l=this.webGLContexts[u];if(l.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(u)){var d=this.textures[u];d&&l.deleteTexture(d)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(i){var r=this,o=(i==null?void 0:i.skipIndexation)!==void 0?i==null?void 0:i.skipIndexation:!1,s=(i==null?void 0:i.schedule)!==void 0?i.schedule:!1,a=!i||!i.partialGraph;if(a)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(b){return r.addNode(b)}),this.graph.forEachEdge(function(b){return r.addEdge(b)});else{for(var c,u,l=((c=i.partialGraph)===null||c===void 0?void 0:c.nodes)||[],d=0,h=(l==null?void 0:l.length)||0;d<h;d++){var f=l[d];if(this.updateNode(f),o){var g=this.nodeProgramIndex[f];if(g===void 0)throw new Error('Sigma: node "'.concat(f,`" can't be repaint`));this.addNodeToProgram(f,this.nodeIndices[f],g)}}for(var y=(i==null||(u=i.partialGraph)===null||u===void 0?void 0:u.edges)||[],m=0,v=y.length;m<v;m++){var w=y[m];if(this.updateEdge(w),o){var p=this.edgeProgramIndex[w];if(p===void 0)throw new Error('Sigma: edge "'.concat(w,`" can't be repaint`));this.addEdgeToProgram(w,this.edgeIndices[w],p)}}}return(a||!o)&&(this.needToProcess=!0),s?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var i=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){i.render()})),this}},{key:"scheduleRefresh",value:function(i){return this.refresh(W(W({},i),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(i,r){var o=this.camera.getState(),s=o.ratio,a=o.angle,c=o.x,u=o.y,l=this.settings,d=l.minCameraRatio,h=l.maxCameraRatio;typeof h=="number"&&(r=Math.min(r,h)),typeof d=="number"&&(r=Math.max(r,d));var f=r/s,g={x:this.width/2,y:this.height/2},y=this.viewportToFramedGraph(i),m=this.viewportToFramedGraph(g);return{angle:a,x:(y.x-m.x)*(1-f)+c,y:(y.y-m.y)*(1-f)+u,ratio:r}}},{key:"viewRectangle",value:function(){var i=this.viewportToFramedGraph({x:0,y:0}),r=this.viewportToFramedGraph({x:this.width,y:0}),o=this.viewportToFramedGraph({x:0,y:this.height});return{x1:i.x,y1:i.y,x2:r.x,y2:r.y,height:r.y-o.y}}},{key:"framedGraphToViewport",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!r.cameraState||!!r.viewportDimensions||!!r.graphDimensions,s=r.matrix?r.matrix:o?ht(r.cameraState||this.camera.getState(),r.viewportDimensions||this.getDimensions(),r.graphDimensions||this.getGraphDimensions(),r.padding||this.getStagePadding()):this.matrix,a=Pn(s,i);return{x:(1+a.x)*this.width/2,y:(1-a.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!r.cameraState||!!r.viewportDimensions||!r.graphDimensions,s=r.matrix?r.matrix:o?ht(r.cameraState||this.camera.getState(),r.viewportDimensions||this.getDimensions(),r.graphDimensions||this.getGraphDimensions(),r.padding||this.getStagePadding(),!0):this.invMatrix,a=Pn(s,{x:i.x/this.width*2-1,y:1-i.y/this.height*2});return isNaN(a.x)&&(a.x=0),isNaN(a.y)&&(a.y=0),a}},{key:"viewportToGraph",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(i,r))}},{key:"graphToViewport",value:function(i){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(i),r)}},{key:"getGraphToViewportRatio",value:function(){var i={x:0,y:0},r={x:1,y:1},o=Math.sqrt(Math.pow(i.x-r.x,2)+Math.pow(i.y-r.y,2)),s=this.graphToViewport(i),a=this.graphToViewport(r),c=Math.sqrt(Math.pow(s.x-a.x,2)+Math.pow(s.y-a.y,2));return c/o}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(i){return this.customBBox=i,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var i=this.container;i.firstChild;)i.removeChild(i.firstChild);for(var r in this.nodePrograms)this.nodePrograms[r].kill();for(var o in this.nodeHoverPrograms)this.nodeHoverPrograms[o].kill();for(var s in this.edgePrograms)this.edgePrograms[s].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var a in this.elements)this.killLayer(a);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return i/this.settings.zoomToSizeRatioFunction(r)*(this.getSetting("itemSizesReference")==="positions"?r*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var i={};for(var r in this.elements)this.elements[r]instanceof HTMLCanvasElement&&(i[r]=this.elements[r]);return i}}])})(Xn),cf=Kl;function ql(){const e=arguments[0];for(let t=1,n=arguments.length;t<n;t++)if(arguments[t])for(const i in arguments[t])e[i]=arguments[t][i];return e}let le=ql;typeof Object.assign=="function"&&(le=Object.assign);function ve(e,t,n,i){const r=e._nodes.get(t);let o=null;return r&&(i==="mixed"?o=r.out&&r.out[n]||r.undirected&&r.undirected[n]:i==="directed"?o=r.out&&r.out[n]:o=r.undirected&&r.undirected[n]),o}function fe(e){return typeof e=="object"&&e!==null}function Xo(e){let t;for(t in e)return!1;return!0}function ye(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function xe(e,t,n){const i={enumerable:!0,configurable:!0};typeof n=="function"?i.get=n:(i.value=n,i.writable=!1),Object.defineProperty(e,t,i)}function gr(e){return!(!fe(e)||e.attributes&&!Array.isArray(e.attributes))}function Ql(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function Re(){const e=arguments;let t=null,n=-1;return{[Symbol.iterator](){return this},next(){let i=null;do{if(t===null){if(n++,n>=e.length)return{done:!0};t=e[n][Symbol.iterator]()}if(i=t.next(),i.done){t=null;continue}break}while(!0);return i}}}function rt(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Kn extends Error{constructor(t){super(),this.name="GraphError",this.message=t}}class H extends Kn{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,H.prototype.constructor)}}class O extends Kn{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,O.prototype.constructor)}}class X extends Kn{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,X.prototype.constructor)}}function Zo(e,t){this.key=e,this.attributes=t,this.clear()}Zo.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 Ko(e,t){this.key=e,this.attributes=t,this.clear()}Ko.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function qo(e,t){this.key=e,this.attributes=t,this.clear()}qo.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function ot(e,t,n,i,r){this.key=t,this.attributes=r,this.undirected=e,this.source=n,this.target=i}ot.prototype.attach=function(){let e="out",t="in";this.undirected&&(e=t="undirected");const n=this.source.key,i=this.target.key;this.source[e][i]=this,!(this.undirected&&n===i)&&(this.target[t][n]=this)};ot.prototype.attachMulti=function(){let e="out",t="in";const n=this.source.key,i=this.target.key;this.undirected&&(e=t="undirected");const r=this.source[e],o=r[i];if(typeof o>"u"){r[i]=this,this.undirected&&n===i||(this.target[t][n]=this);return}o.previous=this,this.next=o,r[i]=this,this.target[t][n]=this};ot.prototype.detach=function(){const e=this.source.key,t=this.target.key;let n="out",i="in";this.undirected&&(n=i="undirected"),delete this.source[n][t],delete this.target[i][e]};ot.prototype.detachMulti=function(){const e=this.source.key,t=this.target.key;let n="out",i="in";this.undirected&&(n=i="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[n][t],delete this.target[i][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[i][e]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const Qo=0,Jo=1,Jl=2,es=3;function Le(e,t,n,i,r,o,s){let a,c,u,l;if(i=""+i,n===Qo){if(a=e._nodes.get(i),!a)throw new O(`Graph.${t}: could not find the "${i}" node in the graph.`);u=r,l=o}else if(n===es){if(r=""+r,c=e._edges.get(r),!c)throw new O(`Graph.${t}: could not find the "${r}" edge in the graph.`);const d=c.source.key,h=c.target.key;if(i===d)a=c.target;else if(i===h)a=c.source;else throw new O(`Graph.${t}: the "${i}" node is not attached to the "${r}" edge (${d}, ${h}).`);u=o,l=s}else{if(c=e._edges.get(i),!c)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`);n===Jo?a=c.source:a=c.target,u=r,l=o}return[a,u,l]}function eh(e,t,n){e.prototype[t]=function(i,r,o){const[s,a]=Le(this,t,n,i,r,o);return s.attributes[a]}}function th(e,t,n){e.prototype[t]=function(i,r){const[o]=Le(this,t,n,i,r);return o.attributes}}function nh(e,t,n){e.prototype[t]=function(i,r,o){const[s,a]=Le(this,t,n,i,r,o);return s.attributes.hasOwnProperty(a)}}function ih(e,t,n){e.prototype[t]=function(i,r,o,s){const[a,c,u]=Le(this,t,n,i,r,o,s);return a.attributes[c]=u,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:c}),this}}function rh(e,t,n){e.prototype[t]=function(i,r,o,s){const[a,c,u]=Le(this,t,n,i,r,o,s);if(typeof u!="function")throw new H(`Graph.${t}: updater should be a function.`);const l=a.attributes,d=u(l[c]);return l[c]=d,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:c}),this}}function oh(e,t,n){e.prototype[t]=function(i,r,o){const[s,a]=Le(this,t,n,i,r,o);return delete s.attributes[a],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:a}),this}}function sh(e,t,n){e.prototype[t]=function(i,r,o){const[s,a]=Le(this,t,n,i,r,o);if(!fe(a))throw new H(`Graph.${t}: provided attributes are not a plain object.`);return s.attributes=a,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function ah(e,t,n){e.prototype[t]=function(i,r,o){const[s,a]=Le(this,t,n,i,r,o);if(!fe(a))throw new H(`Graph.${t}: provided attributes are not a plain object.`);return le(s.attributes,a),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:a}),this}}function ch(e,t,n){e.prototype[t]=function(i,r,o){const[s,a]=Le(this,t,n,i,r,o);if(typeof a!="function")throw new H(`Graph.${t}: provided updater is not a function.`);return s.attributes=a(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}const uh=[{name:e=>`get${e}Attribute`,attacher:eh},{name:e=>`get${e}Attributes`,attacher:th},{name:e=>`has${e}Attribute`,attacher:nh},{name:e=>`set${e}Attribute`,attacher:ih},{name:e=>`update${e}Attribute`,attacher:rh},{name:e=>`remove${e}Attribute`,attacher:oh},{name:e=>`replace${e}Attributes`,attacher:sh},{name:e=>`merge${e}Attributes`,attacher:ah},{name:e=>`update${e}Attributes`,attacher:ch}];function dh(e){uh.forEach(function({name:t,attacher:n}){n(e,t("Node"),Qo),n(e,t("Source"),Jo),n(e,t("Target"),Jl),n(e,t("Opposite"),es)})}function lh(e,t,n){e.prototype[t]=function(i,r){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new X(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new X(`Graph.${t}: 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=""+i,a=""+r;if(r=arguments[2],o=ve(this,s,a,n),!o)throw new O(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new X(`Graph.${t}: 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(i=""+i,o=this._edges.get(i),!o)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`)}return o.attributes[r]}}function hh(e,t,n){e.prototype[t]=function(i){let r;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new X(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new X(`Graph.${t}: 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=""+i,s=""+arguments[1];if(r=ve(this,o,s,n),!r)throw new O(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new X(`Graph.${t}: 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(i=""+i,r=this._edges.get(i),!r)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`)}return r.attributes}}function fh(e,t,n){e.prototype[t]=function(i,r){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new X(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new X(`Graph.${t}: 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=""+i,a=""+r;if(r=arguments[2],o=ve(this,s,a,n),!o)throw new O(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new X(`Graph.${t}: 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(i=""+i,o=this._edges.get(i),!o)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`)}return o.attributes.hasOwnProperty(r)}}function gh(e,t,n){e.prototype[t]=function(i,r,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new X(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new X(`Graph.${t}: 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=""+i,c=""+r;if(r=arguments[2],o=arguments[3],s=ve(this,a,c,n),!s)throw new O(`Graph.${t}: could not find an edge for the given path ("${a}" - "${c}").`)}else{if(n!=="mixed")throw new X(`Graph.${t}: 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(i=""+i,s=this._edges.get(i),!s)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`)}return s.attributes[r]=o,this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:r}),this}}function ph(e,t,n){e.prototype[t]=function(i,r,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new X(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new X(`Graph.${t}: 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=""+i,c=""+r;if(r=arguments[2],o=arguments[3],s=ve(this,a,c,n),!s)throw new O(`Graph.${t}: could not find an edge for the given path ("${a}" - "${c}").`)}else{if(n!=="mixed")throw new X(`Graph.${t}: 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(i=""+i,s=this._edges.get(i),!s)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`)}if(typeof o!="function")throw new H(`Graph.${t}: updater should be a function.`);return s.attributes[r]=o(s.attributes[r]),this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:r}),this}}function mh(e,t,n){e.prototype[t]=function(i,r){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new X(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new X(`Graph.${t}: 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=""+i,a=""+r;if(r=arguments[2],o=ve(this,s,a,n),!o)throw new O(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new X(`Graph.${t}: 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(i=""+i,o=this._edges.get(i),!o)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`)}return delete o.attributes[r],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:r}),this}}function yh(e,t,n){e.prototype[t]=function(i,r){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new X(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new X(`Graph.${t}: 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=""+i,a=""+r;if(r=arguments[2],o=ve(this,s,a,n),!o)throw new O(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new X(`Graph.${t}: 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(i=""+i,o=this._edges.get(i),!o)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`)}if(!fe(r))throw new H(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=r,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function vh(e,t,n){e.prototype[t]=function(i,r){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new X(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new X(`Graph.${t}: 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=""+i,a=""+r;if(r=arguments[2],o=ve(this,s,a,n),!o)throw new O(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new X(`Graph.${t}: 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(i=""+i,o=this._edges.get(i),!o)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`)}if(!fe(r))throw new H(`Graph.${t}: provided attributes are not a plain object.`);return le(o.attributes,r),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:r}),this}}function wh(e,t,n){e.prototype[t]=function(i,r){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new X(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new X(`Graph.${t}: 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=""+i,a=""+r;if(r=arguments[2],o=ve(this,s,a,n),!o)throw new O(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new X(`Graph.${t}: 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(i=""+i,o=this._edges.get(i),!o)throw new O(`Graph.${t}: could not find the "${i}" edge in the graph.`)}if(typeof r!="function")throw new H(`Graph.${t}: provided updater is not a function.`);return o.attributes=r(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const bh=[{name:e=>`get${e}Attribute`,attacher:lh},{name:e=>`get${e}Attributes`,attacher:hh},{name:e=>`has${e}Attribute`,attacher:fh},{name:e=>`set${e}Attribute`,attacher:gh},{name:e=>`update${e}Attribute`,attacher:ph},{name:e=>`remove${e}Attribute`,attacher:mh},{name:e=>`replace${e}Attributes`,attacher:yh},{name:e=>`merge${e}Attributes`,attacher:vh},{name:e=>`update${e}Attributes`,attacher:wh}];function xh(e){bh.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}const Eh=[{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 Sh(e,t,n,i){let r=!1;for(const o in t){if(o===i)continue;const s=t[o];if(r=n(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),e&&r)return s.key}}function Ch(e,t,n,i){let r,o,s,a=!1;for(const c in t)if(c!==i){r=t[c];do{if(o=r.source,s=r.target,a=n(r.key,r.attributes,o.key,s.key,o.attributes,s.attributes,r.undirected),e&&a)return r.key;r=r.next}while(r!==void 0)}}function En(e,t){const n=Object.keys(e),i=n.length;let r,o=0;return{[Symbol.iterator](){return this},next(){do if(r)r=r.next;else{if(o>=i)return{done:!0};const s=n[o++];if(s===t){r=void 0;continue}r=e[s]}while(!r);return{done:!1,value:{edge:r.key,attributes:r.attributes,source:r.source.key,target:r.target.key,sourceAttributes:r.source.attributes,targetAttributes:r.target.attributes,undirected:r.undirected}}}}}function _h(e,t,n,i){const r=t[n];if(!r)return;const o=r.source,s=r.target;if(i(r.key,r.attributes,o.key,s.key,o.attributes,s.attributes,r.undirected)&&e)return r.key}function Nh(e,t,n,i){let r=t[n];if(!r)return;let o=!1;do{if(o=i(r.key,r.attributes,r.source.key,r.target.key,r.source.attributes,r.target.attributes,r.undirected),e&&o)return r.key;r=r.next}while(r!==void 0)}function Sn(e,t){let n=e[t];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};const r={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:r}}};let i=!1;return{[Symbol.iterator](){return this},next(){return i===!0?{done:!0}:(i=!0,{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}})}}}function Ah(e,t){if(e.size===0)return[];if(t==="mixed"||t===e.type)return Array.from(e._edges.keys());const n=t==="undirected"?e.undirectedSize:e.directedSize,i=new Array(n),r=t==="undirected",o=e._edges.values();let s=0,a,c;for(;a=o.next(),a.done!==!0;)c=a.value,c.undirected===r&&(i[s++]=c.key);return i}function ts(e,t,n,i){if(t.size===0)return;const r=n!=="mixed"&&n!==t.type,o=n==="undirected";let s,a,c=!1;const u=t._edges.values();for(;s=u.next(),s.done!==!0;){if(a=s.value,r&&a.undirected!==o)continue;const{key:l,attributes:d,source:h,target:f}=a;if(c=i(l,d,h.key,f.key,h.attributes,f.attributes,a.undirected),e&&c)return l}}function Th(e,t){if(e.size===0)return rt();const n=t!=="mixed"&&t!==e.type,i=t==="undirected",r=e._edges.values();return{[Symbol.iterator](){return this},next(){let o,s;for(;;){if(o=r.next(),o.done)return o;if(s=o.value,!(n&&s.undirected!==i))break}return{value:{edge:s.key,attributes:s.attributes,source:s.source.key,target:s.target.key,sourceAttributes:s.source.attributes,targetAttributes:s.target.attributes,undirected:s.undirected},done:!1}}}}function qn(e,t,n,i,r,o){const s=t?Ch:Sh;let a;if(n!=="undirected"&&(i!=="out"&&(a=s(e,r.in,o),e&&a)||i!=="in"&&(a=s(e,r.out,o,i?void 0:r.key),e&&a))||n!=="directed"&&(a=s(e,r.undirected,o),e&&a))return a}function kh(e,t,n,i){const r=[];return qn(!1,e,t,n,i,function(o){r.push(o)}),r}function Rh(e,t,n){let i=rt();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(i=Re(i,En(n.in))),t!=="in"&&typeof n.out<"u"&&(i=Re(i,En(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(i=Re(i,En(n.undirected))),i}function Qn(e,t,n,i,r,o,s){const a=n?Nh:_h;let c;if(t!=="undirected"&&(typeof r.in<"u"&&i!=="out"&&(c=a(e,r.in,o,s),e&&c)||typeof r.out<"u"&&i!=="in"&&(i||r.key!==o)&&(c=a(e,r.out,o,s),e&&c))||t!=="directed"&&typeof r.undirected<"u"&&(c=a(e,r.undirected,o,s),e&&c))return c}function Dh(e,t,n,i,r){const o=[];return Qn(!1,e,t,n,i,r,function(s){o.push(s)}),o}function Lh(e,t,n,i){let r=rt();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&i in n.in&&(r=Re(r,Sn(n.in,i))),typeof n.out<"u"&&t!=="in"&&i in n.out&&(t||n.key!==i)&&(r=Re(r,Sn(n.out,i)))),e!=="directed"&&typeof n.undirected<"u"&&i in n.undirected&&(r=Re(r,Sn(n.undirected,i))),r}function Mh(e,t){const{name:n,type:i,direction:r}=t;e.prototype[n]=function(o,s){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return[];if(!arguments.length)return Ah(this,i);if(arguments.length===1){o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new O(`Graph.${n}: could not find the "${o}" node in the graph.`);return kh(this.multi,i==="mixed"?this.type:i,r,a)}if(arguments.length===2){o=""+o,s=""+s;const a=this._nodes.get(o);if(!a)throw new O(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new O(`Graph.${n}: could not find the "${s}" target node in the graph.`);return Dh(i,this.multi,r,a,s)}throw new H(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Ph(e,t){const{name:n,type:i,direction:r}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(u,l,d){if(!(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)){if(arguments.length===1)return d=u,ts(!1,this,i,d);if(arguments.length===2){u=""+u,d=l;const h=this._nodes.get(u);if(typeof h>"u")throw new O(`Graph.${o}: could not find the "${u}" node in the graph.`);return qn(!1,this.multi,i==="mixed"?this.type:i,r,h,d)}if(arguments.length===3){u=""+u,l=""+l;const h=this._nodes.get(u);if(!h)throw new O(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(l))throw new O(`Graph.${o}: could not find the "${l}" target node in the graph.`);return Qn(!1,i,this.multi,r,h,l,d)}throw new H(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){const u=Array.prototype.slice.call(arguments),l=u.pop();let d;if(u.length===0){let h=0;i!=="directed"&&(h+=this.undirectedSize),i!=="undirected"&&(h+=this.directedSize),d=new Array(h);let f=0;u.push((g,y,m,v,w,p,b)=>{d[f++]=l(g,y,m,v,w,p,b)})}else d=[],u.push((h,f,g,y,m,v,w)=>{d.push(l(h,f,g,y,m,v,w))});return this[o].apply(this,u),d};const a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(){const u=Array.prototype.slice.call(arguments),l=u.pop(),d=[];return u.push((h,f,g,y,m,v,w)=>{l(h,f,g,y,m,v,w)&&d.push(h)}),this[o].apply(this,u),d};const c="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(){let u=Array.prototype.slice.call(arguments);if(u.length<2||u.length>4)throw new H(`Graph.${c}: invalid number of arguments (expecting 2, 3 or 4 and got ${u.length}).`);if(typeof u[u.length-1]=="function"&&typeof u[u.length-2]!="function")throw new H(`Graph.${c}: 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 l,d;u.length===2?(l=u[0],d=u[1],u=[]):u.length===3?(l=u[1],d=u[2],u=[u[0]]):u.length===4&&(l=u[2],d=u[3],u=[u[0],u[1]]);let h=d;return u.push((f,g,y,m,v,w,p)=>{h=l(h,f,g,y,m,v,w,p)}),this[o].apply(this,u),h}}function Ih(e,t){const{name:n,type:i,direction:r}=t,o="find"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(c,u,l){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return!1;if(arguments.length===1)return l=c,ts(!0,this,i,l);if(arguments.length===2){c=""+c,l=u;const d=this._nodes.get(c);if(typeof d>"u")throw new O(`Graph.${o}: could not find the "${c}" node in the graph.`);return qn(!0,this.multi,i==="mixed"?this.type:i,r,d,l)}if(arguments.length===3){c=""+c,u=""+u;const d=this._nodes.get(c);if(!d)throw new O(`Graph.${o}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(u))throw new O(`Graph.${o}: could not find the "${u}" target node in the graph.`);return Qn(!0,i,this.multi,r,d,u,l)}throw new H(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const s="some"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){const c=Array.prototype.slice.call(arguments),u=c.pop();return c.push((d,h,f,g,y,m,v)=>u(d,h,f,g,y,m,v)),!!this[o].apply(this,c)};const a="every"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(){const c=Array.prototype.slice.call(arguments),u=c.pop();return c.push((d,h,f,g,y,m,v)=>!u(d,h,f,g,y,m,v)),!this[o].apply(this,c)}}function Gh(e,t){const{name:n,type:i,direction:r}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(s,a){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return rt();if(!arguments.length)return Th(this,i);if(arguments.length===1){s=""+s;const c=this._nodes.get(s);if(!c)throw new O(`Graph.${o}: could not find the "${s}" node in the graph.`);return Rh(i,r,c)}if(arguments.length===2){s=""+s,a=""+a;const c=this._nodes.get(s);if(!c)throw new O(`Graph.${o}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(a))throw new O(`Graph.${o}: could not find the "${a}" target node in the graph.`);return Lh(i,r,c,a)}throw new H(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Fh(e){Eh.forEach(t=>{Mh(e,t),Ph(e,t),Ih(e,t),Gh(e,t)})}const $h=[{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 tn(){this.A=null,this.B=null}tn.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};tn.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function pt(e,t,n,i,r){for(const o in i){const s=i[o],a=s.source,c=s.target,u=a===n?c:a;if(t&&t.has(u.key))continue;const l=r(u.key,u.attributes);if(e&&l)return u.key}}function Jn(e,t,n,i,r){if(t!=="mixed"){if(t==="undirected")return pt(e,null,i,i.undirected,r);if(typeof n=="string")return pt(e,null,i,i[n],r)}const o=new tn;let s;if(t!=="undirected"){if(n!=="out"){if(s=pt(e,null,i,i.in,r),e&&s)return s;o.wrap(i.in)}if(n!=="in"){if(s=pt(e,o,i,i.out,r),e&&s)return s;o.wrap(i.out)}}if(t!=="directed"&&(s=pt(e,o,i,i.undirected,r),e&&s))return s}function zh(e,t,n){if(e!=="mixed"){if(e==="undirected")return Object.keys(n.undirected);if(typeof t=="string")return Object.keys(n[t])}const i=[];return Jn(!1,e,t,n,function(r){i.push(r)}),i}function mt(e,t,n){const i=Object.keys(n),r=i.length;let o=0;return{[Symbol.iterator](){return this},next(){let s=null;do{if(o>=r)return e&&e.wrap(n),{done:!0};const a=n[i[o++]],c=a.source,u=a.target;if(s=c===t?u:c,e&&e.has(s.key)){s=null;continue}}while(s===null);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}}}}function Bh(e,t,n){if(e!=="mixed"){if(e==="undirected")return mt(null,n,n.undirected);if(typeof t=="string")return mt(null,n,n[t])}let i=rt();const r=new tn;return e!=="undirected"&&(t!=="out"&&(i=Re(i,mt(r,n,n.in))),t!=="in"&&(i=Re(i,mt(r,n,n.out)))),e!=="directed"&&(i=Re(i,mt(r,n,n.undirected))),i}function Oh(e,t){const{name:n,type:i,direction:r}=t;e.prototype[n]=function(o){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return[];o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new O(`Graph.${n}: could not find the "${o}" node in the graph.`);return zh(i==="mixed"?this.type:i,r,s)}}function Uh(e,t){const{name:n,type:i,direction:r}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(u,l){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return;u=""+u;const d=this._nodes.get(u);if(typeof d>"u")throw new O(`Graph.${o}: could not find the "${u}" node in the graph.`);Jn(!1,i==="mixed"?this.type:i,r,d,l)};const s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(u,l){const d=[];return this[o](u,(h,f)=>{d.push(l(h,f))}),d};const a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(u,l){const d=[];return this[o](u,(h,f)=>{l(h,f)&&d.push(h)}),d};const c="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(u,l,d){if(arguments.length<3)throw new H(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let h=d;return this[o](u,(f,g)=>{h=l(h,f,g)}),h}}function Hh(e,t){const{name:n,type:i,direction:r}=t,o=n[0].toUpperCase()+n.slice(1,-1),s="find"+o;e.prototype[s]=function(u,l){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return;u=""+u;const d=this._nodes.get(u);if(typeof d>"u")throw new O(`Graph.${s}: could not find the "${u}" node in the graph.`);return Jn(!0,i==="mixed"?this.type:i,r,d,l)};const a="some"+o;e.prototype[a]=function(u,l){return!!this[s](u,l)};const c="every"+o;e.prototype[c]=function(u,l){return!this[s](u,(h,f)=>!l(h,f))}}function jh(e,t){const{name:n,type:i,direction:r}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(s){if(i!=="mixed"&&this.type!=="mixed"&&i!==this.type)return rt();s=""+s;const a=this._nodes.get(s);if(typeof a>"u")throw new O(`Graph.${o}: could not find the "${s}" node in the graph.`);return Bh(i==="mixed"?this.type:i,r,a)}}function Vh(e){$h.forEach(t=>{Oh(e,t),Uh(e,t),Hh(e,t),jh(e,t)})}function zt(e,t,n,i,r){const o=i._nodes.values(),s=i.type;let a,c,u,l,d,h;for(;a=o.next(),a.done!==!0;){let f=!1;if(c=a.value,s!=="undirected"){l=c.out;for(u in l){d=l[u];do h=d.target,f=!0,r(c.key,h.key,c.attributes,h.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}if(s!=="directed"){l=c.undirected;for(u in l)if(!(t&&c.key>u)){d=l[u];do h=d.target,h.key!==u&&(h=d.source),f=!0,r(c.key,h.key,c.attributes,h.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}n&&!f&&r(c.key,null,c.attributes,null,null,null,null)}}function Wh(e,t){const n={key:e};return Xo(t.attributes)||(n.attributes=le({},t.attributes)),n}function Yh(e,t,n){const i={key:t,source:n.source.key,target:n.target.key};return Xo(n.attributes)||(i.attributes=le({},n.attributes)),e==="mixed"&&n.undirected&&(i.undirected=!0),i}function Xh(e){if(!fe(e))throw new H('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in e))throw new H("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!fe(e.attributes)||e.attributes===null))throw new H("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function Zh(e){if(!fe(e))throw new H('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in e))throw new H("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new H("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!fe(e.attributes)||e.attributes===null))throw new H("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!="boolean")throw new H("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const Kh=Ql(),qh=new Set(["directed","undirected","mixed"]),pr=new Set(["domain","_events","_eventsCount","_maxListeners"]),Qh=[{name:e=>`${e}Edge`,generateKey:!0},{name:e=>`${e}DirectedEdge`,generateKey:!0,type:"directed"},{name:e=>`${e}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:e=>`${e}EdgeWithKey`},{name:e=>`${e}DirectedEdgeWithKey`,type:"directed"},{name:e=>`${e}UndirectedEdgeWithKey`,type:"undirected"}],Jh={allowSelfLoops:!0,multi:!1,type:"mixed"};function ef(e,t,n){if(n&&!fe(n))throw new H(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=""+t,n=n||{},e._nodes.has(t))throw new X(`Graph.addNode: the "${t}" node already exist in the graph.`);const i=new e.NodeDataClass(t,n);return e._nodes.set(t,i),e.emit("nodeAdded",{key:t,attributes:n}),i}function mr(e,t,n){const i=new e.NodeDataClass(t,n);return e._nodes.set(t,i),e.emit("nodeAdded",{key:t,attributes:n}),i}function ns(e,t,n,i,r,o,s,a){if(!i&&e.type==="undirected")throw new X(`Graph.${t}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(i&&e.type==="directed")throw new X(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(a&&!fe(a))throw new H(`Graph.${t}: invalid attributes. Expecting an object but got "${a}"`);if(o=""+o,s=""+s,a=a||{},!e.allowSelfLoops&&o===s)throw new X(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const c=e._nodes.get(o),u=e._nodes.get(s);if(!c)throw new O(`Graph.${t}: source node "${o}" not found.`);if(!u)throw new O(`Graph.${t}: target node "${s}" not found.`);const l={key:null,undirected:i,source:o,target:s,attributes:a};if(n)r=e._edgeKeyGenerator();else if(r=""+r,e._edges.has(r))throw new X(`Graph.${t}: the "${r}" edge already exists in the graph.`);if(!e.multi&&(i?typeof c.undirected[s]<"u":typeof c.out[s]<"u"))throw new X(`Graph.${t}: an edge linking "${o}" to "${s}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const d=new ot(i,r,c,u,a);e._edges.set(r,d);const h=o===s;return i?(c.undirectedDegree++,u.undirectedDegree++,h&&(c.undirectedLoops++,e._undirectedSelfLoopCount++)):(c.outDegree++,u.inDegree++,h&&(c.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),i?e._undirectedSize++:e._directedSize++,l.key=r,e.emit("edgeAdded",l),r}function tf(e,t,n,i,r,o,s,a,c){if(!i&&e.type==="undirected")throw new X(`Graph.${t}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(i&&e.type==="directed")throw new X(`Graph.${t}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(a){if(c){if(typeof a!="function")throw new H(`Graph.${t}: invalid updater function. Expecting a function but got "${a}"`)}else if(!fe(a))throw new H(`Graph.${t}: invalid attributes. Expecting an object but got "${a}"`)}o=""+o,s=""+s;let u;if(c&&(u=a,a=void 0),!e.allowSelfLoops&&o===s)throw new X(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=e._nodes.get(o),d=e._nodes.get(s),h,f;if(!n&&(h=e._edges.get(r),h)){if((h.source.key!==o||h.target.key!==s)&&(!i||h.source.key!==s||h.target.key!==o))throw new X(`Graph.${t}: inconsistency detected when attempting to merge the "${r}" edge with "${o}" source & "${s}" target vs. ("${h.source.key}", "${h.target.key}").`);f=h}if(!f&&!e.multi&&l&&(f=i?l.undirected[s]:l.out[s]),f){const w=[f.key,!1,!1,!1];if(c?!u:!a)return w;if(c){const p=f.attributes;f.attributes=u(p),e.emit("edgeAttributesUpdated",{type:"replace",key:f.key,attributes:f.attributes})}else le(f.attributes,a),e.emit("edgeAttributesUpdated",{type:"merge",key:f.key,attributes:f.attributes,data:a});return w}a=a||{},c&&u&&(a=u(a));const g={key:null,undirected:i,source:o,target:s,attributes:a};if(n)r=e._edgeKeyGenerator();else if(r=""+r,e._edges.has(r))throw new X(`Graph.${t}: the "${r}" edge already exists in the graph.`);let y=!1,m=!1;l||(l=mr(e,o,{}),y=!0,o===s&&(d=l,m=!0)),d||(d=mr(e,s,{}),m=!0),h=new ot(i,r,l,d,a),e._edges.set(r,h);const v=o===s;return i?(l.undirectedDegree++,d.undirectedDegree++,v&&(l.undirectedLoops++,e._undirectedSelfLoopCount++)):(l.outDegree++,d.inDegree++,v&&(l.directedLoops++,e._directedSelfLoopCount++)),e.multi?h.attachMulti():h.attach(),i?e._undirectedSize++:e._directedSize++,g.key=r,e.emit("edgeAdded",g),[r,!0,y,m]}function Ye(e,t){e._edges.delete(t.key);const{source:n,target:i,attributes:r}=t,o=t.undirected,s=n===i;o?(n.undirectedDegree--,i.undirectedDegree--,s&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,i.inDegree--,s&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),o?e._undirectedSize--:e._directedSize--,e.emit("edgeDropped",{key:t.key,attributes:r,source:n.key,target:i.key,undirected:o})}class ae extends br.EventEmitter{constructor(t){if(super(),t=le({},Jh,t),typeof t.multi!="boolean")throw new H(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!qh.has(t.type))throw new H(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${t.type}".`);if(typeof t.allowSelfLoops!="boolean")throw new H(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${t.allowSelfLoops}".`);const n=t.type==="mixed"?Zo:t.type==="directed"?Ko:qo;ye(this,"NodeDataClass",n);const i="geid_"+Kh()+"_";let r=0;const o=()=>{let s;do s=i+r++;while(this._edges.has(s));return s};ye(this,"_attributes",{}),ye(this,"_nodes",new Map),ye(this,"_edges",new Map),ye(this,"_directedSize",0),ye(this,"_undirectedSize",0),ye(this,"_directedSelfLoopCount",0),ye(this,"_undirectedSelfLoopCount",0),ye(this,"_edgeKeyGenerator",o),ye(this,"_options",t),pr.forEach(s=>ye(this,s,this[s])),xe(this,"order",()=>this._nodes.size),xe(this,"size",()=>this._edges.size),xe(this,"directedSize",()=>this._directedSize),xe(this,"undirectedSize",()=>this._undirectedSize),xe(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),xe(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),xe(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),xe(this,"multi",this._options.multi),xe(this,"type",this._options.type),xe(this,"allowSelfLoops",this._options.allowSelfLoops),xe(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(t){return this._nodes.has(""+t)}hasDirectedEdge(t,n){if(this.type==="undirected")return!1;if(arguments.length===1){const i=""+t,r=this._edges.get(i);return!!r&&!r.undirected}else if(arguments.length===2){t=""+t,n=""+n;const i=this._nodes.get(t);return i?i.out.hasOwnProperty(n):!1}throw new H(`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(t,n){if(this.type==="directed")return!1;if(arguments.length===1){const i=""+t,r=this._edges.get(i);return!!r&&r.undirected}else if(arguments.length===2){t=""+t,n=""+n;const i=this._nodes.get(t);return i?i.undirected.hasOwnProperty(n):!1}throw new H(`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(t,n){if(arguments.length===1){const i=""+t;return this._edges.has(i)}else if(arguments.length===2){t=""+t,n=""+n;const i=this._nodes.get(t);return i?typeof i.out<"u"&&i.out.hasOwnProperty(n)||typeof i.undirected<"u"&&i.undirected.hasOwnProperty(n):!1}throw new H(`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(t,n){if(this.type==="undirected")return;if(t=""+t,n=""+n,this.multi)throw new X("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const i=this._nodes.get(t);if(!i)throw new O(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new O(`Graph.directedEdge: could not find the "${n}" target node in the graph.`);const r=i.out&&i.out[n]||void 0;if(r)return r.key}undirectedEdge(t,n){if(this.type==="directed")return;if(t=""+t,n=""+n,this.multi)throw new X("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const i=this._nodes.get(t);if(!i)throw new O(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new O(`Graph.undirectedEdge: could not find the "${n}" target node in the graph.`);const r=i.undirected&&i.undirected[n]||void 0;if(r)return r.key}edge(t,n){if(this.multi)throw new X("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");t=""+t,n=""+n;const i=this._nodes.get(t);if(!i)throw new O(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new O(`Graph.edge: could not find the "${n}" target node in the graph.`);const r=i.out&&i.out[n]||i.undirected&&i.undirected[n]||void 0;if(r)return r.key}areDirectedNeighbors(t,n){t=""+t,n=""+n;const i=this._nodes.get(t);if(!i)throw new O(`Graph.areDirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in i.in||n in i.out}areOutNeighbors(t,n){t=""+t,n=""+n;const i=this._nodes.get(t);if(!i)throw new O(`Graph.areOutNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in i.out}areInNeighbors(t,n){t=""+t,n=""+n;const i=this._nodes.get(t);if(!i)throw new O(`Graph.areInNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in i.in}areUndirectedNeighbors(t,n){t=""+t,n=""+n;const i=this._nodes.get(t);if(!i)throw new O(`Graph.areUndirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="directed"?!1:n in i.undirected}areNeighbors(t,n){t=""+t,n=""+n;const i=this._nodes.get(t);if(!i)throw new O(`Graph.areNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&(n in i.in||n in i.out)||this.type!=="directed"&&n in i.undirected}areInboundNeighbors(t,n){t=""+t,n=""+n;const i=this._nodes.get(t);if(!i)throw new O(`Graph.areInboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in i.in||this.type!=="directed"&&n in i.undirected}areOutboundNeighbors(t,n){t=""+t,n=""+n;const i=this._nodes.get(t);if(!i)throw new O(`Graph.areOutboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in i.out||this.type!=="directed"&&n in i.undirected}inDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.inDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree}outDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.outDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree}directedDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.directedDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree}undirectedDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.undirectedDegree: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree}inboundDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.inboundDegree: could not find the "${t}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=n.undirectedDegree),this.type!=="undirected"&&(i+=n.inDegree),i}outboundDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.outboundDegree: could not find the "${t}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=n.undirectedDegree),this.type!=="undirected"&&(i+=n.outDegree),i}degree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.degree: could not find the "${t}" node in the graph.`);let i=0;return this.type!=="directed"&&(i+=n.undirectedDegree),this.type!=="undirected"&&(i+=n.inDegree+n.outDegree),i}inDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.inDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree-n.directedLoops}outDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.outDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree-n.directedLoops}directedDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.directedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree-n.directedLoops*2}undirectedDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree-n.undirectedLoops*2}inboundDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let i=0,r=0;return this.type!=="directed"&&(i+=n.undirectedDegree,r+=n.undirectedLoops*2),this.type!=="undirected"&&(i+=n.inDegree,r+=n.directedLoops),i-r}outboundDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let i=0,r=0;return this.type!=="directed"&&(i+=n.undirectedDegree,r+=n.undirectedLoops*2),this.type!=="undirected"&&(i+=n.outDegree,r+=n.directedLoops),i-r}degreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.degreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let i=0,r=0;return this.type!=="directed"&&(i+=n.undirectedDegree,r+=n.undirectedLoops*2),this.type!=="undirected"&&(i+=n.inDegree+n.outDegree,r+=n.directedLoops*2),i-r}source(t){t=""+t;const n=this._edges.get(t);if(!n)throw new O(`Graph.source: could not find the "${t}" edge in the graph.`);return n.source.key}target(t){t=""+t;const n=this._edges.get(t);if(!n)throw new O(`Graph.target: could not find the "${t}" edge in the graph.`);return n.target.key}extremities(t){t=""+t;const n=this._edges.get(t);if(!n)throw new O(`Graph.extremities: could not find the "${t}" edge in the graph.`);return[n.source.key,n.target.key]}opposite(t,n){t=""+t,n=""+n;const i=this._edges.get(n);if(!i)throw new O(`Graph.opposite: could not find the "${n}" edge in the graph.`);const r=i.source.key,o=i.target.key;if(t===r)return o;if(t===o)return r;throw new O(`Graph.opposite: the "${t}" node is not attached to the "${n}" edge (${r}, ${o}).`)}hasExtremity(t,n){t=""+t,n=""+n;const i=this._edges.get(t);if(!i)throw new O(`Graph.hasExtremity: could not find the "${t}" edge in the graph.`);return i.source.key===n||i.target.key===n}isUndirected(t){t=""+t;const n=this._edges.get(t);if(!n)throw new O(`Graph.isUndirected: could not find the "${t}" edge in the graph.`);return n.undirected}isDirected(t){t=""+t;const n=this._edges.get(t);if(!n)throw new O(`Graph.isDirected: could not find the "${t}" edge in the graph.`);return!n.undirected}isSelfLoop(t){t=""+t;const n=this._edges.get(t);if(!n)throw new O(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return n.source===n.target}addNode(t,n){return ef(this,t,n).key}mergeNode(t,n){if(n&&!fe(n))throw new H(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);t=""+t,n=n||{};let i=this._nodes.get(t);return i?(n&&(le(i.attributes,n),this.emit("nodeAttributesUpdated",{type:"merge",key:t,attributes:i.attributes,data:n})),[t,!1]):(i=new this.NodeDataClass(t,n),this._nodes.set(t,i),this.emit("nodeAdded",{key:t,attributes:n}),[t,!0])}updateNode(t,n){if(n&&typeof n!="function")throw new H(`Graph.updateNode: invalid updater function. Expecting a function but got "${n}"`);t=""+t;let i=this._nodes.get(t);if(i){if(n){const o=i.attributes;i.attributes=n(o),this.emit("nodeAttributesUpdated",{type:"replace",key:t,attributes:i.attributes})}return[t,!1]}const r=n?n({}):{};return i=new this.NodeDataClass(t,r),this._nodes.set(t,i),this.emit("nodeAdded",{key:t,attributes:r}),[t,!0]}dropNode(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new O(`Graph.dropNode: could not find the "${t}" node in the graph.`);let i;if(this.type!=="undirected"){for(const r in n.out){i=n.out[r];do Ye(this,i),i=i.next;while(i)}for(const r in n.in){i=n.in[r];do Ye(this,i),i=i.next;while(i)}}if(this.type!=="directed")for(const r in n.undirected){i=n.undirected[r];do Ye(this,i),i=i.next;while(i)}this._nodes.delete(t),this.emit("nodeDropped",{key:t,attributes:n.attributes})}dropEdge(t){let n;if(arguments.length>1){const i=""+arguments[0],r=""+arguments[1];if(n=ve(this,i,r,this.type),!n)throw new O(`Graph.dropEdge: could not find the "${i}" -> "${r}" edge in the graph.`)}else if(t=""+t,n=this._edges.get(t),!n)throw new O(`Graph.dropEdge: could not find the "${t}" edge in the graph.`);return Ye(this,n),this}dropDirectedEdge(t,n){if(arguments.length<2)throw new X("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 X("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.");t=""+t,n=""+n;const i=ve(this,t,n,"directed");if(!i)throw new O(`Graph.dropDirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Ye(this,i),this}dropUndirectedEdge(t,n){if(arguments.length<2)throw new X("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 X("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 i=ve(this,t,n,"undirected");if(!i)throw new O(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Ye(this,i),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const t=this._nodes.values();let n;for(;n=t.next(),n.done!==!0;)n.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(t){return this._attributes[t]}getAttributes(){return this._attributes}hasAttribute(t){return this._attributes.hasOwnProperty(t)}setAttribute(t,n){return this._attributes[t]=n,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}updateAttribute(t,n){if(typeof n!="function")throw new H("Graph.updateAttribute: updater should be a function.");const i=this._attributes[t];return this._attributes[t]=n(i),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}removeAttribute(t){return delete this._attributes[t],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:t}),this}replaceAttributes(t){if(!fe(t))throw new H("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=t,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(t){if(!fe(t))throw new H("Graph.mergeAttributes: provided attributes are not a plain object.");return le(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this}updateAttributes(t){if(typeof t!="function")throw new H("Graph.updateAttributes: provided updater is not a function.");return this._attributes=t(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(t,n){if(typeof t!="function")throw new H("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!gr(n))throw new H("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const i=this._nodes.values();let r,o;for(;r=i.next(),r.done!==!0;)o=r.value,o.attributes=t(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:n||null})}updateEachEdgeAttributes(t,n){if(typeof t!="function")throw new H("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!gr(n))throw new H("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const i=this._edges.values();let r,o,s,a;for(;r=i.next(),r.done!==!0;)o=r.value,s=o.source,a=o.target,o.attributes=t(o.key,o.attributes,s.key,a.key,s.attributes,a.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:n||null})}forEachAdjacencyEntry(t){if(typeof t!="function")throw new H("Graph.forEachAdjacencyEntry: expecting a callback.");zt(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new H("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");zt(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new H("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");zt(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new H("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");zt(!1,!0,!0,this,t)}nodes(){return Array.from(this._nodes.keys())}forEachNode(t){if(typeof t!="function")throw new H("Graph.forEachNode: expecting a callback.");const n=this._nodes.values();let i,r;for(;i=n.next(),i.done!==!0;)r=i.value,t(r.key,r.attributes)}findNode(t){if(typeof t!="function")throw new H("Graph.findNode: expecting a callback.");const n=this._nodes.values();let i,r;for(;i=n.next(),i.done!==!0;)if(r=i.value,t(r.key,r.attributes))return r.key}mapNodes(t){if(typeof t!="function")throw new H("Graph.mapNode: expecting a callback.");const n=this._nodes.values();let i,r;const o=new Array(this.order);let s=0;for(;i=n.next(),i.done!==!0;)r=i.value,o[s++]=t(r.key,r.attributes);return o}someNode(t){if(typeof t!="function")throw new H("Graph.someNode: expecting a callback.");const n=this._nodes.values();let i,r;for(;i=n.next(),i.done!==!0;)if(r=i.value,t(r.key,r.attributes))return!0;return!1}everyNode(t){if(typeof t!="function")throw new H("Graph.everyNode: expecting a callback.");const n=this._nodes.values();let i,r;for(;i=n.next(),i.done!==!0;)if(r=i.value,!t(r.key,r.attributes))return!1;return!0}filterNodes(t){if(typeof t!="function")throw new H("Graph.filterNodes: expecting a callback.");const n=this._nodes.values();let i,r;const o=[];for(;i=n.next(),i.done!==!0;)r=i.value,t(r.key,r.attributes)&&o.push(r.key);return o}reduceNodes(t,n){if(typeof t!="function")throw new H("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new H("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 i=n;const r=this._nodes.values();let o,s;for(;o=r.next(),o.done!==!0;)s=o.value,i=t(i,s.key,s.attributes);return i}nodeEntries(){const t=this._nodes.values();return{[Symbol.iterator](){return this},next(){const n=t.next();if(n.done)return n;const i=n.value;return{value:{node:i.key,attributes:i.attributes},done:!1}}}}export(){const t=new Array(this._nodes.size);let n=0;this._nodes.forEach((r,o)=>{t[n++]=Wh(o,r)});const i=new Array(this._edges.size);return n=0,this._edges.forEach((r,o)=>{i[n++]=Yh(this.type,o,r)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:t,edges:i}}import(t,n=!1){if(t instanceof ae)return t.forEachNode((c,u)=>{n?this.mergeNode(c,u):this.addNode(c,u)}),t.forEachEdge((c,u,l,d,h,f,g)=>{n?g?this.mergeUndirectedEdgeWithKey(c,l,d,u):this.mergeDirectedEdgeWithKey(c,l,d,u):g?this.addUndirectedEdgeWithKey(c,l,d,u):this.addDirectedEdgeWithKey(c,l,d,u)}),this;if(!fe(t))throw new H("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!fe(t.attributes))throw new H("Graph.import: invalid attributes. Expecting a plain object.");n?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}let i,r,o,s,a;if(t.nodes){if(o=t.nodes,!Array.isArray(o))throw new H("Graph.import: invalid nodes. Expecting an array.");for(i=0,r=o.length;i<r;i++){s=o[i],Xh(s);const{key:c,attributes:u}=s;n?this.mergeNode(c,u):this.addNode(c,u)}}if(t.edges){let c=!1;if(this.type==="undirected"&&(c=!0),o=t.edges,!Array.isArray(o))throw new H("Graph.import: invalid edges. Expecting an array.");for(i=0,r=o.length;i<r;i++){a=o[i],Zh(a);const{source:u,target:l,attributes:d,undirected:h=c}=a;let f;"key"in a?(f=n?h?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:h?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,f.call(this,a.key,u,l,d)):(f=n?h?this.mergeUndirectedEdge:this.mergeDirectedEdge:h?this.addUndirectedEdge:this.addDirectedEdge,f.call(this,u,l,d))}}return this}nullCopy(t){const n=new ae(le({},this._options,t));return n.replaceAttributes(le({},this.getAttributes())),n}emptyCopy(t){const n=this.nullCopy(t);return this._nodes.forEach((i,r)=>{const o=le({},i.attributes);i=new n.NodeDataClass(r,o),n._nodes.set(r,i)}),n}copy(t){if(t=t||{},typeof t.type=="string"&&t.type!==this.type&&t.type!=="mixed")throw new X(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${t.type}" because this would mean losing information about the current graph.`);if(typeof t.multi=="boolean"&&t.multi!==this.multi&&t.multi!==!0)throw new X("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 t.allowSelfLoops=="boolean"&&t.allowSelfLoops!==this.allowSelfLoops&&t.allowSelfLoops!==!0)throw new X("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 n=this.emptyCopy(t),i=this._edges.values();let r,o;for(;r=i.next(),r.done!==!0;)o=r.value,ns(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,le({},o.attributes));return n}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const t={};this._nodes.forEach((o,s)=>{t[s]=o.attributes});const n={},i={};this._edges.forEach((o,s)=>{const a=o.undirected?"--":"->";let c="",u=o.source.key,l=o.target.key,d;o.undirected&&u>l&&(d=u,u=l,l=d);const h=`(${u})${a}(${l})`;s.startsWith("geid_")?this.multi&&(typeof i[h]>"u"?i[h]=0:i[h]++,c+=`${i[h]}. `):c+=`[${s}]: `,c+=h,n[c]=o.attributes});const r={};for(const o in this)this.hasOwnProperty(o)&&!pr.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(r[o]=this[o]);return r.attributes=this._attributes,r.nodes=t,r.edges=n,ye(r,"constructor",this.constructor),r}}typeof Symbol<"u"&&(ae.prototype[Symbol.for("nodejs.util.inspect.custom")]=ae.prototype.inspect);Qh.forEach(e=>{["add","merge","update"].forEach(t=>{const n=e.name(t),i=t==="add"?ns:tf;e.generateKey?ae.prototype[n]=function(r,o,s){return i(this,n,!0,(e.type||this.type)==="undirected",null,r,o,s,t==="update")}:ae.prototype[n]=function(r,o,s,a){return i(this,n,!1,(e.type||this.type)==="undirected",r,o,s,a,t==="update")}})});dh(ae);xh(ae);Fh(ae);Vh(ae);class is extends ae{constructor(t){const n=le({type:"directed"},t);if("multi"in n&&n.multi!==!1)throw new H("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new H('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class rs extends ae{constructor(t){const n=le({type:"undirected"},t);if("multi"in n&&n.multi!==!1)throw new H("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new H('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class os extends ae{constructor(t){const n=le({multi:!0},t);if("multi"in n&&n.multi!==!0)throw new H("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}}class ss extends ae{constructor(t){const n=le({type:"directed",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new H("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new H('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class as extends ae{constructor(t){const n=le({type:"undirected",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new H("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new H('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}function st(e){e.from=function(t,n){const i=le({},t.options,n),r=new e(i);return r.import(t),r}}st(ae);st(is);st(rs);st(os);st(ss);st(as);ae.Graph=ae;ae.DirectedGraph=is;ae.UndirectedGraph=rs;ae.MultiGraph=os;ae.MultiDirectedGraph=ss;ae.MultiUndirectedGraph=as;ae.InvalidArgumentsGraphError=H;ae.NotFoundGraphError=O;ae.UsageGraphError=X;export{sf as B,af as C,ae as G,jt as H,Ot as M,Y as P,cf as S,La as a,Gc as b,Ic as c,of as i};
|