semiotic 3.8.5 → 3.8.7
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/CLAUDE.md +37 -10
- package/README.md +83 -56
- package/ai/behaviorContracts.cjs +88 -3
- package/ai/componentMetadata.cjs +5 -10
- package/ai/dist/mcp-server.js +99 -10
- package/ai/examples.md +198 -9
- package/ai/schema.json +2002 -165
- package/ai/surface-manifest.json +14 -10
- package/ai/system-prompt.md +9 -3
- package/dist/{chunk-chartContainerDataAudit-74TLKIP6.module.min.js → chunk-chartContainerDataAudit-JDSVSKGM.module.min.js} +1 -1
- package/dist/chunk-chunk-2JGJ5GUG.module.min.js +1 -0
- package/dist/chunk-chunk-2YAZHXL4.module.min.js +2 -0
- package/dist/chunk-chunk-3NGIKFD6.module.min.js +1 -0
- package/dist/{chunk-chunk-G7WFWHAD.module.min.js → chunk-chunk-4ITOQRXM.module.min.js} +1 -1
- package/dist/chunk-chunk-5SD6BHVW.module.min.js +2 -0
- package/dist/chunk-chunk-6V5VQVCT.module.min.js +2 -0
- package/dist/chunk-chunk-7TTBHSAG.module.min.js +2 -0
- package/dist/chunk-chunk-7ZDJSYKI.module.min.js +2 -0
- package/dist/chunk-chunk-BGHPD3RA.module.min.js +1 -0
- package/dist/chunk-chunk-BMRZ2SPU.module.min.js +2 -0
- package/dist/chunk-chunk-BNGBEY7N.module.min.js +2 -0
- package/dist/chunk-chunk-C7APLVQD.module.min.js +2 -0
- package/dist/chunk-chunk-DGWFBOGB.module.min.js +1 -0
- package/dist/chunk-chunk-DIVE2DRA.module.min.js +2 -0
- package/dist/chunk-chunk-FBUNUIPV.module.min.js +2 -0
- package/dist/chunk-chunk-FQPKOAIH.module.min.js +2 -0
- package/dist/chunk-chunk-FRO4TRXK.module.min.js +2 -0
- package/dist/chunk-chunk-G7QVPZUD.module.min.js +2 -0
- package/dist/chunk-chunk-GBPYV4FP.module.min.js +2 -0
- package/dist/chunk-chunk-GU2EJIDJ.module.min.js +2 -0
- package/dist/chunk-chunk-J5QD4RAM.module.min.js +2 -0
- package/dist/{chunk-chunk-LJLS6DY7.module.min.js → chunk-chunk-JWXLNZSM.module.min.js} +1 -1
- package/dist/chunk-chunk-KXAFCCDB.module.min.js +2 -0
- package/dist/chunk-chunk-LG7YKJAK.module.min.js +2 -0
- package/dist/{chunk-chunk-I36PJ4OC.module.min.js → chunk-chunk-LVHDZAT3.module.min.js} +1 -1
- package/dist/chunk-chunk-LWITSR2O.module.min.js +2 -0
- package/dist/chunk-chunk-MX35T6RX.module.min.js +2 -0
- package/dist/chunk-chunk-NH4MEAKP.module.min.js +2 -0
- package/dist/chunk-chunk-NJETWX42.module.min.js +2 -0
- package/dist/chunk-chunk-NW25WGLS.module.min.js +2 -0
- package/dist/{chunk-chunk-TMWIZL3K.module.min.js → chunk-chunk-OI7R7EJB.module.min.js} +1 -1
- package/dist/chunk-chunk-ONMLEXHR.module.min.js +2 -0
- package/dist/chunk-chunk-OY66GCE6.module.min.js +1 -0
- package/dist/chunk-chunk-PZFT457G.module.min.js +1 -0
- package/dist/chunk-chunk-Q3WW6JGR.module.min.js +1 -0
- package/dist/chunk-chunk-Q6XKQTOQ.module.min.js +1 -0
- package/dist/chunk-chunk-RJRM2E6P.module.min.js +1 -0
- package/dist/chunk-chunk-RPL7WYXI.module.min.js +1 -0
- package/dist/chunk-chunk-SV4XAZ3Q.module.min.js +1 -0
- package/dist/chunk-chunk-TSCFL235.module.min.js +1 -0
- package/dist/chunk-chunk-UOQRPGPK.module.min.js +2 -0
- package/dist/chunk-chunk-V3OAKG32.module.min.js +1 -0
- package/dist/chunk-chunk-WLOIUMWG.module.min.js +2 -0
- package/dist/chunk-chunk-XEGXX4F7.module.min.js +1 -0
- package/dist/chunk-chunk-XFRBLXYM.module.min.js +1 -0
- package/dist/chunk-chunk-Z2AJERX5.module.min.js +2 -0
- package/dist/chunk-chunk-ZXYDYAB7.module.min.js +2 -0
- package/dist/components/ai/SemioticVACPBridge.d.ts +22 -0
- package/dist/components/ai/chartCapabilities.d.ts +5 -3
- package/dist/components/ai/conversationArc.d.ts +2 -176
- package/dist/components/ai/conversationArcTypes.d.ts +202 -0
- package/dist/components/ai/readerGrounding.d.ts +12 -0
- package/dist/components/ai/vacpAdapter.d.ts +13 -0
- package/dist/components/ai/vacpAdapterActions.d.ts +2 -0
- package/dist/components/ai/vacpAdapterModel.d.ts +7 -0
- package/dist/components/ai/vacpAdapterRuntime.d.ts +26 -0
- package/dist/components/ai/vacpAdapterState.d.ts +3 -0
- package/dist/components/ai/vacpAdapterTypes.d.ts +169 -0
- package/dist/components/ai/vacpTypes.d.ts +160 -0
- package/dist/components/charts/custom/XYCustomChart.d.ts +3 -0
- package/dist/components/charts/geo/DistanceCartogram.d.ts +1 -1
- package/dist/components/charts/index.d.ts +7 -4
- package/dist/components/charts/ordinal/BarChart.d.ts +7 -14
- package/dist/components/charts/ordinal/GaugeChart.d.ts +3 -0
- package/dist/components/charts/ordinal/GroupedBarChart.d.ts +3 -0
- package/dist/components/charts/ordinal/StackedBarChart.d.ts +3 -0
- package/dist/components/charts/ordinal/SwimlaneChart.d.ts +4 -14
- package/dist/components/charts/physics/ChainReactionChart.capability.d.ts +9 -0
- package/dist/components/charts/physics/ChainReactionChart.d.ts +29 -0
- package/dist/components/charts/physics/CollisionSwarmChart.d.ts +1 -1
- package/dist/components/charts/physics/EventDropChart.d.ts +7 -2
- package/dist/components/charts/physics/GaltonBoardChart.d.ts +1 -1
- package/dist/components/charts/physics/{PhysicsPileChart.capability.d.ts → PacketFlowChart.capability.d.ts} +1 -1
- package/dist/components/charts/physics/{PhysicalFlowChart.d.ts → PacketFlowChart.d.ts} +22 -6
- package/dist/components/charts/physics/PhysicsCustomChart.d.ts +1 -1
- package/dist/components/charts/physics/ProcessFlowChart.d.ts +7 -4
- package/dist/components/charts/physics/{PhysicalFlowChart.capability.d.ts → UnitPileChart.capability.d.ts} +1 -1
- package/dist/components/charts/physics/{PhysicsPileChart.d.ts → UnitPileChart.d.ts} +19 -6
- package/dist/components/charts/physics/crucibleChartProps.d.ts +1 -1
- package/dist/components/charts/physics/crucibleChartUtils.d.ts +9 -0
- package/dist/components/charts/physics/gauntletChartProps.d.ts +6 -1
- package/dist/components/charts/physics/gauntletTerminal.d.ts +61 -0
- package/dist/components/charts/physics/packetFlowSemantics.d.ts +6 -0
- package/dist/components/charts/physics/physicsHocUtils.d.ts +45 -2
- package/dist/components/charts/shared/auditAccessibilityStyles.d.ts +9 -0
- package/dist/components/charts/shared/chartSpecCore.d.ts +2 -4
- package/dist/components/charts/shared/gaugeGradient.d.ts +4 -8
- package/dist/components/charts/shared/gradient.d.ts +35 -0
- package/dist/components/charts/shared/hatchFill.d.ts +3 -10
- package/dist/components/charts/shared/hooks.d.ts +2 -50
- package/dist/components/charts/shared/knownChartComponents.d.ts +1 -1
- package/dist/components/charts/shared/streamPropsHelpers.d.ts +1 -2
- package/dist/components/charts/shared/useChartLegend.d.ts +65 -0
- package/dist/components/charts/shared/useChartSetup.d.ts +12 -0
- package/dist/components/charts/shared/useCustomChartSetup.d.ts +6 -1
- package/dist/components/charts/shared/useNetworkChartSetup.d.ts +1 -0
- package/dist/components/charts/shared/useStreamingLegend.d.ts +1 -1
- package/dist/components/charts/xy/AreaChart.d.ts +25 -42
- package/dist/components/charts/xy/BumpChart.capability.d.ts +11 -0
- package/dist/components/charts/xy/BumpChart.d.ts +161 -0
- package/dist/components/charts/xy/DifferenceChart.d.ts +3 -10
- package/dist/components/charts/xy/Heatmap.d.ts +3 -0
- package/dist/components/charts/xy/LineChart.d.ts +6 -8
- package/dist/components/data/portability/capabilityBinding.d.ts +41 -0
- package/dist/components/data/portability/index.d.ts +2 -0
- package/dist/components/geometry/bumpRibbonGeometry.d.ts +36 -0
- package/dist/components/legendLayout.d.ts +75 -1
- package/dist/components/recipes/geographicDotGrid.d.ts +82 -0
- package/dist/components/recipes/geographicGrid.d.ts +100 -0
- package/dist/components/recipes/physics.d.ts +2 -0
- package/dist/components/recipes/physicsStageGeography.d.ts +137 -0
- package/dist/components/semiotic-ai.d.ts +6 -4
- package/dist/components/semiotic-experimental-vacp.d.ts +11 -0
- package/dist/components/semiotic-experimental.d.ts +6 -3
- package/dist/components/semiotic-geo.d.ts +5 -0
- package/dist/components/semiotic-network.d.ts +1 -0
- package/dist/components/semiotic-ordinal.d.ts +2 -0
- package/dist/components/semiotic-physics.d.ts +10 -6
- package/dist/components/semiotic-realtime-core.d.ts +1 -0
- package/dist/components/semiotic-recipes-core.d.ts +6 -1
- package/dist/components/semiotic-server-edge.d.ts +1 -1
- package/dist/components/semiotic-server.d.ts +1 -1
- package/dist/components/semiotic-xy.d.ts +4 -0
- package/dist/components/semiotic.d.ts +4 -4
- package/dist/components/server/renderEvidence.d.ts +1 -1
- package/dist/components/server/renderToStaticSVG.d.ts +2 -1
- package/dist/components/server/serverChartConfigHeatmap.d.ts +6 -0
- package/dist/components/server/serverChartConfigNetworkStyles.d.ts +12 -0
- package/dist/components/server/serverChartConfigShared.d.ts +16 -0
- package/dist/components/server/serverChartConfigs.d.ts +3 -2
- package/dist/components/server/serverChartConfigsPhysics.d.ts +2 -2
- package/dist/components/server/serverChartConfigsXY.d.ts +1 -1
- package/dist/components/server/staticLegend.d.ts +10 -2
- package/dist/components/server/staticSVGChrome.d.ts +14 -6
- package/dist/components/server/staticValue.d.ts +8 -0
- package/dist/components/stream/GeoSVGOverlay.d.ts +4 -10
- package/dist/components/stream/NetworkSVGOverlay.d.ts +2 -6
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +2 -6
- package/dist/components/stream/SVGOverlay.d.ts +2 -6
- package/dist/components/stream/StalenessBadge.d.ts +2 -6
- package/dist/components/stream/geoPipelineConfig.d.ts +10 -0
- package/dist/components/stream/geoTypes.d.ts +3 -6
- package/dist/components/stream/legendRenderer.d.ts +10 -6
- package/dist/components/stream/ordinalTypes.d.ts +7 -31
- package/dist/components/stream/physics/PhysicsEvidence.d.ts +37 -0
- package/dist/components/stream/physics/PhysicsKernel.d.ts +1 -0
- package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +9 -0
- package/dist/components/stream/physics/PhysicsSVGOverlay.d.ts +2 -6
- package/dist/components/stream/physics/PhysicsSettledScene.d.ts +5 -0
- package/dist/components/stream/physics/StreamPhysicsTypes.d.ts +2 -6
- package/dist/components/stream/physics/physicsFramePipelineConfig.d.ts +19 -0
- package/dist/components/stream/physics/physicsPipelineSettle.d.ts +52 -0
- package/dist/components/stream/physics/physicsRegionRuntime.d.ts +23 -0
- package/dist/components/stream/pipelineConfig.d.ts +7 -15
- package/dist/components/stream/renderers/canvasRenderHelpers.d.ts +9 -69
- package/dist/components/stream/renderers/cornerRadii.d.ts +2 -9
- package/dist/components/stream/renderers/thresholdLineSegments.d.ts +12 -0
- package/dist/components/stream/sceneToSVGShared.d.ts +3 -5
- package/dist/components/stream/types.d.ts +34 -56
- package/dist/components/stream/xySceneBuilders/areaGradient.d.ts +4 -20
- package/dist/components/stream/xySceneBuilders/types.d.ts +6 -6
- package/dist/components/types/legendTypes.d.ts +31 -6
- package/dist/controls.min.js +1 -1
- package/dist/controls.module.min.js +1 -1
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/physics.min.js +1 -1
- package/dist/physics.module.min.js +1 -1
- package/dist/physicsWorker.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai-core.min.js +1 -1
- package/dist/semiotic-ai-core.module.min.js +1 -1
- package/dist/semiotic-ai.d.ts +6 -4
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-data.module.min.js +1 -1
- package/dist/semiotic-experimental-vacp.d.ts +11 -0
- package/dist/semiotic-experimental-vacp.min.js +1 -0
- package/dist/semiotic-experimental-vacp.module.min.js +1 -0
- package/dist/semiotic-experimental.d.ts +6 -3
- package/dist/semiotic-experimental.min.js +2 -1
- package/dist/semiotic-experimental.module.min.js +2 -1
- package/dist/semiotic-geo.d.ts +5 -0
- package/dist/semiotic-network.d.ts +1 -0
- package/dist/semiotic-ordinal.d.ts +2 -0
- package/dist/semiotic-physics.d.ts +10 -6
- package/dist/semiotic-realtime-core.d.ts +1 -0
- package/dist/semiotic-realtime-core.min.js +1 -1
- package/dist/semiotic-realtime-core.module.min.js +1 -1
- package/dist/semiotic-recipes-core.d.ts +6 -1
- package/dist/semiotic-recipes-core.min.js +1 -1
- package/dist/semiotic-recipes-core.module.min.js +1 -1
- package/dist/semiotic-recipes.min.js +1 -1
- package/dist/semiotic-recipes.module.min.js +1 -1
- package/dist/semiotic-server-edge.d.ts +1 -1
- package/dist/semiotic-server-edge.min.js +1 -1
- package/dist/semiotic-server-edge.module.min.js +1 -1
- package/dist/semiotic-server-node.min.js +1 -1
- package/dist/semiotic-server-node.module.min.js +1 -1
- package/dist/semiotic-server.d.ts +1 -1
- package/dist/semiotic-utils-core.min.js +1 -1
- package/dist/semiotic-utils-core.module.min.js +1 -1
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-xy.d.ts +4 -0
- package/dist/semiotic.d.ts +4 -4
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +18 -2
- package/spec/README.md +94 -2
- package/spec/bindings/README.md +14 -3
- package/spec/v0.1/examples/annotation-provenance-reviewed-revision.json +27 -0
- package/spec/v0.1/examples/annotation-provenance-watcher-threshold.json +21 -0
- package/spec/v0.1/examples/audience-profile-executive-review.json +24 -0
- package/spec/v0.1/examples/audience-profile-incident-operators.json +42 -0
- package/spec/v0.1/examples/chart-capability-bar-comparison.json +48 -0
- package/spec/v0.1/examples/chart-capability-service-flow.json +54 -0
- package/dist/chunk-chunk-4AANPFOX.module.min.js +0 -2
- package/dist/chunk-chunk-5I3UZV4Q.module.min.js +0 -2
- package/dist/chunk-chunk-5RKXZQ2P.module.min.js +0 -1
- package/dist/chunk-chunk-74CCPVXB.module.min.js +0 -1
- package/dist/chunk-chunk-7ALTGHK6.module.min.js +0 -1
- package/dist/chunk-chunk-ANYDWOZF.module.min.js +0 -1
- package/dist/chunk-chunk-AVBI6GDT.module.min.js +0 -1
- package/dist/chunk-chunk-BANTPINB.module.min.js +0 -2
- package/dist/chunk-chunk-C4YA6TDR.module.min.js +0 -1
- package/dist/chunk-chunk-C57LR3YG.module.min.js +0 -1
- package/dist/chunk-chunk-CKMD5NV3.module.min.js +0 -2
- package/dist/chunk-chunk-CO5KQMGH.module.min.js +0 -1
- package/dist/chunk-chunk-CWQ5YIHX.module.min.js +0 -2
- package/dist/chunk-chunk-E6TXX6MI.module.min.js +0 -1
- package/dist/chunk-chunk-GMQ5AYTD.module.min.js +0 -1
- package/dist/chunk-chunk-JCG72SGW.module.min.js +0 -2
- package/dist/chunk-chunk-K3DMEW22.module.min.js +0 -1
- package/dist/chunk-chunk-KT2VAZMZ.module.min.js +0 -1
- package/dist/chunk-chunk-L6EA5V3G.module.min.js +0 -2
- package/dist/chunk-chunk-LJPCLYSC.module.min.js +0 -2
- package/dist/chunk-chunk-LRIFN2HK.module.min.js +0 -1
- package/dist/chunk-chunk-N5DDKCCF.module.min.js +0 -1
- package/dist/chunk-chunk-NEVE562N.module.min.js +0 -1
- package/dist/chunk-chunk-NLO44TOS.module.min.js +0 -2
- package/dist/chunk-chunk-PZJ2SBLL.module.min.js +0 -2
- package/dist/chunk-chunk-QSQVBIJA.module.min.js +0 -1
- package/dist/chunk-chunk-QUJ6TTLY.module.min.js +0 -1
- package/dist/chunk-chunk-RBIDBUT4.module.min.js +0 -2
- package/dist/chunk-chunk-RCF52Z42.module.min.js +0 -2
- package/dist/chunk-chunk-RFLAG356.module.min.js +0 -1
- package/dist/chunk-chunk-RPU4IZAV.module.min.js +0 -2
- package/dist/chunk-chunk-SKMBCFIL.module.min.js +0 -2
- package/dist/chunk-chunk-TAE7W424.module.min.js +0 -2
- package/dist/chunk-chunk-TUBMTZMU.module.min.js +0 -2
- package/dist/chunk-chunk-UFFEXJQY.module.min.js +0 -1
- package/dist/chunk-chunk-XSCHTS4D.module.min.js +0 -2
- package/dist/chunk-chunk-XXWSHGPL.module.min.js +0 -2
- package/dist/chunk-chunk-ZOAQDIJO.module.min.js +0 -1
- package/dist/chunk-chunk-ZXIXAPRE.module.min.js +0 -2
- package/dist/chunk-statisticalOverlays-QGDLRUHX.module.min.js +0 -1
- package/dist/chunk-statisticalOverlays-T77OKLDY.module.min.js +0 -1
package/dist/network.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e,t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,a=(e,t,i,a)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let l of o(t))s.call(e,l)||l===i||n(e,l,{get:()=>t[l],enumerable:!(a=r(t,l))||a.enumerable});return e},l=(e,r,o)=>(o=null!=e?t(i(e)):{},a(!r&&e&&e.__esModule?o:n(o,"default",{value:e,enumerable:!0}),e)),c={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(c,{ChordDiagram:()=>Ll,CirclePack:()=>Wl,DEFAULT_HIT_RADIUS:()=>gc,ForceDirectedGraph:()=>dl,NetworkCustomChart:()=>hc,OrbitDiagram:()=>zl,ProcessSankey:()=>lc,SankeyDiagram:()=>Ml,StreamNetworkFrame:()=>ea,TreeDiagram:()=>El,Treemap:()=>Nl,composeStyleRules:()=>rl,formatProcessSankeyIssue:()=>Xl,glyphExtent:()=>pn,glyphPlacement:()=>yn,hatchFillId:()=>xo,hatchPatternDef:()=>wo,isHatchFill:()=>vo,makeNodeRuleContext:()=>Za,makeRuleValueResolver:()=>Qa,matchesThreshold:()=>el,networkHitTarget:()=>yc,resolveResponsiveRules:()=>La,resolveStyleRules:()=>nl,resolveSvgFill:()=>So,responsiveRuleMatches:()=>Ca,ruleMatches:()=>tl,useCustomLayoutSelection:()=>un,useForceLayout:()=>kl,validateProcessSankey:()=>Yl}),module.exports=(e=c,a(n({},"__esModule",{value:!0}),e));var u=l(require("react")),d=require("react");function h(e){return Array.isArray(e)?e[0]:e}function f(e,t,n,r){return{data:h(e),x:t,y:n,__semioticHoverData:!0,...r}}var g={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},y={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},p=class{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e,t=Math.random){const n=this._freeIndices.pop();if(void 0===n)return null;const r=this.particles[n];return r.active=!0,r.t=0,r.offset=t()-.5,r.edgeIndex=e,r.x=0,r.y=0,r}step(e,t,n,r){for(let o=0;this.capacity>o;o++){const i=this.particles[o];if(!i.active)continue;const s=n[i.edgeIndex];s&&s.bezier?(i.t+=e*t*(r?r[i.edgeIndex]??1:1)*(s.bezier.circular?.3:1),1>i.t?m(s.bezier,i.t,i.offset,i):(i.active=!1,this._freeIndices.push(o))):(i.active=!1,this._freeIndices.push(o))}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)t.length>n?this.particles[n]=t[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=e}};function m(e,t,n,r){if(e.circular&&e.segments)return void function(e,t,n,r,o){const i=e.length,s=t*i,a=Math.min(Math.floor(s),i-1),l=s-a,[c,u,d,h]=e[a];v(c,u,d,h,l,o);const f=h.x-c.x,g=h.y-c.y,y=Math.sqrt(f*f+g*g);if(y>.001){const e=f/y;o.x+=-g/y*n*r*2,o.y+=e*n*r*2}}(e.segments,t,n,e.halfWidth,r);if(!e.points)return r.x=0,void(r.y=0);const[o,i,s,a]=e.points;v(o,i,s,a,t,r);const l=a.x-o.x,c=a.y-o.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;r.x+=-c/u*n*e.halfWidth*2,r.y+=t*n*e.halfWidth*2}}function v(e,t,n,r,o,i){const s=1-o,a=s*s,l=a*s,c=o*o,u=c*o;i.x=l*e.x+3*a*o*t.x+3*s*c*n.x+u*r.x,i.y=l*e.y+3*a*o*t.y+3*s*c*n.y+u*r.y}function b(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function x(e,t){var n,r=[],o=[],i=[],s={},a=[];function l(e){i[e]=!1,s.hasOwnProperty(e)&&Object.keys(s[e]).forEach(function(t){delete s[e][t],i[t]&&l(t)})}function c(e){var t,r,d=!1;for(o.push(e),i[e]=!0,t=0;a[e].length>t;t++)(r=a[e][t])===n?(u(n,o),d=!0):i[r]||(d=c(r));if(d)l(e);else for(t=0;a[e].length>t;t++){var h=s[r=a[e][t]];h||(s[r]=h={}),h[r]=!0}return o.pop(),d}function u(e,n){var o=[].concat(n).concat(e);t?t(o):r.push(o)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,r=function(e){for(var t=e.length,n=Array(t),r=Array(t),o=Array(t),i=Array(t),s=Array(t),a=Array(t),l=0;t>l;++l)n[l]=-1,r[l]=0,o[l]=!1,i[l]=0,s[l]=-1,a[l]=[];var c,u=0,d=[],h=[];function f(t){var l=[t],c=[t];for(n[t]=r[t]=u,o[t]=!0,u+=1;c.length>0;){var f=e[t=c[c.length-1]];if(f.length>i[t]){for(var g=i[t];f.length>g;++g){var y=f[g];if(0>n[y]){n[y]=r[y]=u,o[y]=!0,u+=1,l.push(y),c.push(y);break}o[y]&&(r[t]=0|Math.min(r[t],r[y])),0>s[y]||a[t].push(s[y])}i[t]=g}else{if(r[t]===n[t]){var p=[],m=[],v=0;for(g=l.length-1;g>=0;--g){var b=l[g];if(o[b]=!1,p.push(b),m.push(a[b]),v+=a[b].length,s[b]=d.length,b===t){l.length=g;break}}d.push(p);var x=Array(v);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)x[--v]=m[g][k];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>n[l]&&f(l);for(l=0;h.length>l;l++){var g=h[l];if(0!==g.length){g.sort(function(e,t){return e-t}),c=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&c.push(g[y]);h[l]=c}}return{components:d,adjacencyList:h}}(e),o=r.components.filter(function(e){return e.length>1}),i=1/0,s=0;o.length>s;s++)for(var a=0;o[s].length>a;a++)i>o[s][a]&&(i=o[s][a],n=s);var l=o[n];return!!l&&{leastVertex:i,adjList:e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})})}}n=0;for(var h=e.length;h>n;){var f=d(n);if(n=f.leastVertex,a=f.adjList){for(var g=0;a.length>g;g++)for(var y=0;a[g].length>y;y++){var p=a[g][y];i[+p]=!1,s[p]={}}c(n),n+=1}else n=h}return t?void 0:r}function k(e){return e.y0-e.y1>0?"up":"down"}function w(e,t){return t(e.source)==t(e.target)}function S(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function M(e){return e.target.x0-e.source.x1}function A(e,t){var n=L(e),r=M(t)/Math.tan(n);return"up"==k(e)?e.y1-r:e.y1+r}function C(e,t){var n=L(e),r=M(t)/Math.tan(n);return"up"==k(e)?e.y1+r:e.y1-r}function L(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function j(e,t){return t(e)}function T(e){return D(e.source)}function E(e){return D(e.target)}function D(e){return(e.y0+e.y1)/2}function R(e){return e.virtual?0:e.value}function I(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!w(e,t)?n+1:n});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!w(e,t)?r+1:r}),n+r}function N(e){return e.target.depth}function P(e,t){return e.sourceLinks.length?e.depth:t-1}function _(e,t){return e.y0-t.y0}function W(e,t){return t.y0-e.y0}function $(e,t){return e.y1-t.y1}function O(e,t){return t.y1-e.y1}function B(e,t){return H(e.source,t.source)||e.index-t.index}function z(e,t){return H(e.target,t.target)||e.index-t.index}function H(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function F(e,t){return q(e)==q(t)?"bottom"==e.circularLinkType?W(e,t):_(e,t):q(t)-q(e)}function q(e){return e.target.column-e.source.column}function Y(e,t){return X(e)==X(t)}function X(e){return e.y0-e.y1>0?"up":"down"}var G=require("d3-array");function V(e,t,n,r,o){let i=e;var s=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var a=(0,G.min)(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=i.links.filter(function(e){return e.circular});return l.sort(function(e,t){return t.value-e.value}),l.forEach(function(e,t){e._circularStub=t>=4}),U(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),U(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+r,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,w(e,t)&&S(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var s=e.source.column,l=e.circularLinkType,c=i.links.filter(function(e){return e.source.column==s&&e.circularLinkType==l});c.sort("bottom"==e.circularLinkType?W:_);var u=0;c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),s=e.target.column,(c=i.links.filter(function(e){return e.target.column==s&&e.circularLinkType==l})).sort("bottom"==e.circularLinkType?O:$),u=0,c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=a-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,r=e.target.x0,o=e.y1,i=(t+r)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+o+" "+r+","+o}(e)}),i}function U(e,t,n){e.sort(F);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(w(e,t)&&S(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var s=0;r.length>s;s++){var a=r[s];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&K(e,a)){var l=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;i=l>i?l:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function K(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}var Q=require("d3-array");function Z(e){return function(){return e}}function J(e){return e.index}function ee(e){return e.nodes}function te(e){return e.links}function ne(e,t,n){var r=(0,Q.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(o,i){var s=o.length;if(t)o.sort(t);else if(i>0){var a=new Map;o.forEach(function(e,t){var n,r,o,i=(r=0,o=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=D(e.source)*t,r+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=D(e.target)*t,r+=t}}),r>0?o/r:NaN);a.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var n=a.get(e),r=a.get(t),o=n.bc,i=r.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?n.idx-r.idx:1:-1:o-i})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?I(t,n)-I(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){t.depth==r.length-1&&1==s||0==t.depth&&1==s?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==I(t,n)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+o,t.y1=t.y0+t.value*e.ky)})})}function re(e,t,n,r,o,i){var s=(0,Q.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var a=1,l=i;l>0;--l)c(a*=.99,n),u();function c(t,n){var r=s.length;s.forEach(function(o){var i=o.length,s=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&I(o,n)>0){var l=(0,Q.mean)(o.sourceLinks,E),c=(0,Q.mean)(o.targetLinks,T),u=l&&c?(l+c)/2:l||c;if(u){var d=(u-D(o))*t*.3;o.y0+=d,o.y1+=d}}else if(0==s&&1==i)o.y0=e.y1/2-(a=o.y1-o.y0)/2,o.y1=e.y1/2+a/2;else if(s==r-1&&1==i)o.y0=e.y1/2-(a=o.y1-o.y0)/2,o.y1=e.y1/2+a/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)a=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+a;else{var h=(0,Q.mean)(o.sourceLinks,E),f=(0,Q.mean)(o.targetLinks,T),g=((h&&f?(h+f)/2:h||f)-D(o))*t;o.y0+=g,o.y1+=g}})})}function u(){s.forEach(function(n){var i,s,a,l=e.y0,c=n.length;for(n.sort(t||H),a=0;c>a;++a)(s=l-(i=n[a]).y0)>0&&(i.y0+=s,i.y1+=s),l=i.y1+r;if((s=l-r-e.y1)>0)for(l=i.y0-=s,i.y1-=s,a=c-2;a>=0;--a)(s=(i=n[a]).y1+o-l)>0&&(i.y0-=s,i.y1-=s),l=i.y0})}}function oe(e){e.nodes.forEach(function(e){e.sourceLinks.sort(z),e.targetLinks.sort(B)}),e.nodes.forEach(function(e){var t=e.y0,n=t,r=e.y1,o=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function ie(){var e=0,t=0,n=1,r=1,o=24,i=8,s=null,a=J,l=P,c=void 0,u=32,d=2,h=ee,f=te;function g(){var g={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=n,h.y1=r,h.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return(0,Q.group)(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=b(n,r)),"object"!=typeof o&&(o=e.target=b(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(h,a),function(e,t){var n=0;if(null==t){for(var r=[],o=0;e.links.length>o;o++){var i=e.links[o],s=i.source.index,a=i.target.index;r[s]||(r[s]=[]),r[a]||(r[a]=[]),-1===r[s].indexOf(a)&&r[s].push(a)}var l=x(r);l.sort(function(e,t){return e.length-t.length});var c={};for(o=0;l.length>o;o++){var u=l[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,r=e.source.index;t===r||c[r]&&c[r][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(h,c),function(e,t){var n=0,r=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:r>n?"top":"bottom","top"==o.circularLinkType?n++:r++,e.nodes.forEach(function(e){j(e,t)!=j(o.source,t)&&j(e,t)!=j(o.target,t)||(e.circularLinkType=o.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),w(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,a),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max((0,Q.sum)(e.sourceLinks,R),(0,Q.sum)(e.targetLinks,R)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(h),function(e,t,n){var r,o,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var s=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){s=t(e)==a?s:s+1,a=t(e)==a?a:t(e),e.column=s})}for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(h,c,l);var f=i;if(null!==s){var g=(0,Q.groups)(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=(0,Q.max)(g,function(e){return e.length});y>1&&(f=Math.max(1,(r-t)*s/(y-1)))}(function(e,t,n){var r=(0,Q.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var o=(0,Q.min)(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/(0,Q.sum)(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=(0,Q.max)(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(h,f,o),ne(h,c,a),re(h,c,a,f,f,u),oe(h),V(h,a,d,10,8),ne(h,c,a),re(h,c,a,f,f,u),oe(h),V(h,a,d,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var r=n.links.filter(function(n){return j(n.source,t)==j(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Y(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=A(t,e);return e.y1-n}if(t.target.column>e.target.column)return A(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,s=0;o>i;i++)s+=r[i].width;t.y0=e.y1-s-t.width/2}})})}(h,a),function(e,t){let n=e;n.nodes.forEach(function(e){var r=n.links.filter(function(n){return j(n.target,t)==j(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Y(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=C(t,e);return e.y0-n}if(t.source.column>e.source.column)return C(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,s=0;o>i;i++)s+=r[i].width;t.y1=e.y1-s-t.width/2}})})}(h,a),function(e){var t=e.nodes,n=e.links,r=!1,o=!1;if(n.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==r||0==o){let r=function(t){return(t-i)/(s-i)*(e.y1-e.y0)+e.y0};var i=(0,Q.min)(t,function(e){return e.y0}),s=(0,Q.max)(t,function(e){return e.y1}),a=(e.y1-e.y0)/(s-i);1>a?(t.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1)}),n.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1),e.width=e.width*a})):t.forEach(function(e){var t=e.y1-e.y0,n=r(e.y0)-e.y0;e.y0=r(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(h),V(h,a,d,10,8)}(g),g}return g.update=function(e){return oe(e),V(e,a,d,10,8),e},g.nodeWidth=function(e){return arguments.length?(o=+e,g):o},g.nodePadding=function(e){return arguments.length?(i=+e,g):i},g.nodePaddingRatio=function(e){return arguments.length?(s=+e,g):s},g.nodes=function(e){return arguments.length?(h="function"==typeof e?e:Z(e),g):h},g.links=function(e){return arguments.length?(f="function"==typeof e?e:Z(e),g):f},g.nodeId=function(e){return arguments.length?(a="function"==typeof e?e:Z(e),g):a},g.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:Z(e),g):l},g.nodeSort=function(e){return arguments.length?(c=e,g):c},g.iterations=function(e){return arguments.length?(u=+e,g):u},g.circularLinkGap=function(e){return arguments.length?(d=+e,g):d},g.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],n=+o[1][0],r=+o[1][1],g):[[e,t],[n,r]]},g.size=function(o){return arguments.length?(e=t=0,n=+o[0],r=+o[1],g):[n-e,r-t]},g}function se(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function ae(e,t,n){const r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function le(e){const t=e.map(se),n=t.length-1;return e=>{if(0>=e){const[e,n,r]=t[0];return ae(e,n,r)}if(e>=1){const[e,r,o]=t[n];return ae(e,r,o)}const r=e*n,o=Math.floor(r),i=r-o,[s,a,l]=t[o],[c,u,d]=t[o+1];return ae(Math.round(s+(c-s)*i),Math.round(a+(u-a)*i),Math.round(l+(d-l)*i))}}var ce=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],ue=le(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),de=le(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),he=le(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),fe=le(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),ge=le(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),ye=le(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),pe={blues:ue,reds:de,greens:he,viridis:le(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),oranges:fe,purples:ge,greys:ye,plasma:le(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),inferno:le(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),magma:le(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),cividis:le(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),turbo:le(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"])},me=(le(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),le(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),le(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),le(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),le(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),le(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),le(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),require("d3-interpolate"));function ve(e){const{sx:t,sTop:n,sBot:r,tx:o,tTop:i,tBot:s,cp1X:a,cp2X:l}=e,c=(n+r)/2,u=(i+s)/2;return{pathD:[`M${t},${n}`,`C${a},${n} ${l},${i} ${o},${i}`,`L${o},${s}`,`C${l},${s} ${a},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:a,y:c},{x:l,y:u},{x:o,y:u}],halfWidth:(r-n)/2}}}require("d3-shape");var be=e=>{let t,n,r,o,i,s,a,l,c;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.x1,s=e.target.x0,a=(0,me.interpolateNumber)(i,s),l=a(.5),c=a(.5),`M${t},${i}C${t},${l} ${n},${c} ${n},${s}L${r},${s}C${r},${c} ${o},${l} ${o},${i}Z`;const u=e.sankeyWidth/2,d=(0,me.interpolateNumber)(e.source.x1,e.target.x0),{pathD:h}=ve({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:d(.5),cp2X:d(.5)});return h};function xe(e){const t=e.sankeyWidth/2,n=(e._circularWidth??e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const n=r.sourceX,o=r.sourceY,i=r.targetX,s=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const a=Math.max(15,Math.min(40,.33*(r.rightFullExtent-n))),l=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${n},${o-t}L${n+a},${o-t}L${n+a},${o+t}L${n},${o+t}ZM${i},${s-t}L${i-l},${s-t}L${i-l},${s+t}L${i},${s+t}Z`}const o=r.sourceX,i=r.sourceY,s=r.targetX,a=r.targetY,l=r.rightFullExtent,c=r.leftFullExtent,u=r.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(n,15));return`M${o},${i-d*t}L${l},${i-d*t}L${l+n},${i-d*t+d*h}L${l+n},${u+d*n-d*h}L${l+n-h},${u+d*n}L${c-n+h},${u+d*n}L${c-n},${u+d*n-d*h}L${c-n},${a-d*t+d*h}L${c-n+h},${a-d*t}L${s},${a-d*t}L${s},${a+d*t}L${c+n},${a+d*t}L${c+n},${u-d*n}L${l-n},${u-d*n}L${l-n},${i+d*t}L${o},${i+d*t}Z`}var ke=new Set,we=new WeakMap;function Se(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=we.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,we.set(e,n);const r=new Proxy(e,{get(e,n,r){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;ke.has(e)||(ke.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,r)}});return n.set(t,r),r}var Me={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(N))-1:0},justify:P};function Ae(e){return"string"==typeof e?e:e.id}var Ce={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o="vertical"===n.orientation?"down":"right",i=n.nodeAlign||"justify",s=n.nodeWidth??15,a=n.nodePaddingRatio??.05,l=n.iterations??100,c=e.map(e=>({...e})),u=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let d;d="down"===o?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const h=ie().extent(d).links(u).nodes(c).nodeAlign(Me[i]||P).nodeId(e=>e.id).nodeWidth(s).iterations(l);h.nodePaddingRatio&&h.nodePaddingRatio(a),h();{let e=1/0,t=-1/0,n=1/0,o=-1/0;for(const r of c)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),n>r.y0&&(n=r.y0),r.y1>o&&(o=r.y1);for(const r of u){if(!r.circular||!r.circularPathData)continue;const i=r.circularPathData,s=(r._circularWidth??r.width??0)/2;e>i.leftFullExtent-s&&(e=i.leftFullExtent-s),i.rightFullExtent+s>t&&(t=i.rightFullExtent+s),n>i.verticalFullExtent-s&&(n=i.verticalFullExtent-s),i.verticalFullExtent+s>o&&(o=i.verticalFullExtent+s)}const i=t-e,s=o-n,a=r[0],l=r[1];if(i>0&&s>0&&(0>e||0>n||t>a||o>l)){const t=Math.min(a/i,l/s),r=-e*t+(a-i*t)/2,o=-n*t+(l-s*t)/2;for(const e of c)e.x0=e.x0*t+r,e.x1=e.x1*t+r,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of u)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+r,n.targetX=n.targetX*t+r,n.sourceY=n.sourceY*t+o,n.targetY=n.targetY*t+o,n.rightFullExtent=n.rightFullExtent*t+r,n.leftFullExtent=n.leftFullExtent*t+r,n.verticalFullExtent=n.verticalFullExtent*t+o,n.rightInnerExtent=n.rightInnerExtent*t+r,n.leftInnerExtent=n.leftInnerExtent*t+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+o,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of c){const t=f.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const g=new Map;for(const e of t)g.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of u){const t=Ae(e.source),n=Ae(e.target),r=g.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(r){r.y0=e.y0,r.y1=e.y1,r.sankeyWidth=e.width??0,r.circular=!!e.circular,r.circularPathData=e.circularPathData,r._circularWidth=e._circularWidth,r._circularStub=e._circularStub,r.path=e.path,r.circularLinkType=e.circularLinkType,r.direction=o;const i=f.get(t),s=f.get(n);i&&(r.source=i),s&&(r.target=s)}}},buildScene(e,t,n,r){const o="vertical"===n.orientation?"down":"right",i=n.nodeStyle,s=n.edgeStyle,a=n.edgeOpacity??.5,l=n.edgeColorBy||"source",c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ce,u=new Map;e.forEach((e,t)=>{u.set(e.id,c[t%c.length])});const d=[],h=[],f=[],g=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const r=i?i(Se(t,"nodeStyle")):{},s={fill:r.fill||u.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};g.set(t.id,("string"==typeof s.fill?s.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===o?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:s,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:s,datum:t,id:t.id,label:t.id})}const y=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of y){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";o="function"==typeof l?l(e)||o:"target"===l?g.get(r.id)||u.get(r.id)||o:g.get(t.id)||u.get(t.id)||o;const i=s?s(Se(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,r=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),l=i.fill||o;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+r},${t.sourceY-n}L${t.sourceX+r},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:l,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+r}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-s},${t.targetY-n}L${t.targetX-s},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:l,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let c;(c=e.circular&&e.circularPathData?xe(e):be(e),c)&&h.push({type:"bezier",pathD:c,bezierCache:e.bezier,style:{fill:i.fill||o,fillOpacity:i.fillOpacity??a,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity},datum:e})}if(!1!==n.showLabels){const t=(p=n.nodeLabel)?"function"==typeof p?p:e=>e[p]||e.id:null;for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=t?t(n):n.id;if(!s)continue;let a,l,c;"down"===o?(a=n.y0+(n.y1-n.y0)/2,l=n.x1+14,c="start"):(r[0]/2>n.x0+e/2?(a=n.x0-6,c="end"):(a=n.x1+6,c="start"),l=n.y0+i/2),f.push({x:a,y:l,text:s+"",anchor:"down"===o?"middle":c,baseline:"middle",fontSize:11})}}var p;return{sceneNodes:d,sceneEdges:h,labels:f}}},Le=require("d3-force"),je=require("d3-scale");function Te(e){let t=1/0,n=-1/0;for(const r of e)t>r&&(t=r),r>n&&(n=r);return[t,n]}var Ee=()=>"undefined"!=typeof performance?performance.now():Date.now();function De(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function Re(e,t){const n=e();return Number.isFinite(n)?n:t}var Ie=class{constructor(e={}){this.randomSource=Math.random,this.subscribers=new Set,this.now=()=>this.advance(),this.random=()=>this.randomSource(),this.clock=e.clock??Ee,this.lastWallTime=Re(this.clock,0),this.logicalTime=this.lastWallTime,this.pausedValue=!0===e.paused,this.visibleValue=!1!==e.visible,this.setRandomSource(e.random,e.seed)}get isActive(){return!this.pausedValue&&this.visibleValue}get paused(){return this.pausedValue}get seed(){return this.seedValue}get visible(){return this.visibleValue}configure(e){this.setClock(e.clock),this.setRandomSource(e.random,e.seed)}setPaused(e){this.pausedValue!==e&&(this.advance(),this.pausedValue=e,this.emit())}setVisible(e){this.visibleValue!==e&&(this.advance(),this.visibleValue=e,this.emit())}snapshot(){return{now:this.now(),paused:this.pausedValue,seed:this.seedValue,visible:this.visibleValue}}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}advance(){const e=Re(this.clock,this.lastWallTime),t=Math.max(0,e-this.lastWallTime);return this.lastWallTime=e,this.isActive&&(this.logicalTime+=t),this.logicalTime}emit(){for(const e of this.subscribers)e()}setClock(e){const t=e??Ee;t!==this.clock&&(this.advance(),this.clock=t,this.lastWallTime=Re(t,this.lastWallTime))}setRandomSource(e,t){const n=function(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):void 0}(t);e===this.randomInput&&n===this.seedValue||(this.randomInput=e,this.seedValue=n,this.randomSource=e??(void 0===n?Math.random:De(n)))}},Ne={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o=n.forceStrength??.1,i=r[0]/2,s=r[1]/2,a=Math.max(.1,Math.min(1,Math.min(r[0],r[1])/200)),l=Math.min(.5,.06+1.8*(1-a)),c=n.__previousPositions;let u=0;const d=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=c?.get(t.id);e?u++:n?(t.x=n.x,t.y=n.y,u++):d.push(t)}const h=u>0&&.3>=(e.length>0?d.length/e.length:1);if(h){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of d){const r=Pe(e.id,t,n);if(r.length>0){let t=0,n=0;for(const e of r)t+=e.x,n+=e.y;const o=_e(e.id),i=o%360*(Math.PI/180),s=(10+o%20)*a;e.x=t/r.length+s*Math.cos(i),e.y=n/r.length+s*Math.sin(i)}else{const t=_e(e.id),n=t%360*(Math.PI/180),r=(15+t%30)*a;e.x=i+r*Math.cos(n),e.y=s+r*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const r=e[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(n+.5)*a,o=n*t;r.x=i+e*Math.cos(o),r.y=s+e*Math.sin(o)}}}const f=n.__skipForceSimulation||0===n.iterations?0:h?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),g=We(n.nodeSize,n.nodeSizeRange,e),y=e=>g(e);if(f>0){const c=new Map,u=new Map;for(const t of e)c.set(t.id,0),u.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id;c.set(t,(c.get(t)??0)+1),c.set(n,(c.get(n)??0)+1)}const d=(0,Le.forceLink)().strength(e=>{const t=e.weight,n="string"==typeof e.target?e.target:e.target.id,r=Math.max(1,Math.min(c.get("string"==typeof e.source?e.source:e.source.id)??1,c.get(n)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*o/(.1*r))}).distance(e=>{const t="string"==typeof e.source?u.get(e.source):e.source,n="string"==typeof e.target?u.get(e.target):e.target,r=(t?y(t):0)+(n?y(n):0)+Math.max(6,12*a);return Math.max(16,40*a,r)}).id(e=>e.id),g=(0,Le.forceSimulation)();if(void 0===n.random&&void 0===n.seed||g.randomSource(n.random??De(n.seed)),g.force("charge",(0,Le.forceManyBody)().strength(e=>{const t=c.get(e.id)??0;return-15*a*y(e)*Math.sqrt(t+1)})).force("collide",(0,Le.forceCollide)(e=>y(e)+3*a).strength(.9).iterations(2)).force("center",(0,Le.forceCenter)(i,s).strength(.8)).force("x",(0,Le.forceX)(i).strength(l)).force("y",(0,Le.forceY)(s).strength(l)).force("bounds",function(e,t,n=2,r=.6){let o=[];const i=i=>{const s=r*Math.max(i,.2);for(const r of o){const o=r.x??e[0]/2,i=r.y??e[1]/2,a=r.vx??0,l=r.vy??0,c=t(r)+n,u=Math.min(e[0]/2,c),d=Math.max(e[0]/2,e[0]-c),h=Math.min(e[1]/2,c),f=Math.max(e[1]/2,e[1]-c),g=o+a,y=i+l;u>g?r.vx=a+(u-g)*s:g>d&&(r.vx=a+(d-g)*s),h>y?r.vy=l+(h-y)*s:y>f&&(r.vy=l+(f-y)*s)}};return i.initialize=e=>{o=e},i}(r,y)),g.nodes(e),t.length>0){const e=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));d.links(e),g.force("link",d)}h?g.alpha(.3):.1>g.alpha()&&g.alpha(1),g.stop();for(let e=0;f>e;++e)g.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=y(t),n=f>0?2:0,o=Math.min(r[0]/2,e+n),i=Math.min(r[1]/2,e+n);t.x=Math.max(o,Math.min(r[0]-o,t.x)),t.y=Math.max(i,Math.min(r[1]-i,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=p.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=p.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,r){const o=n.nodeStyle,i=n.edgeStyle,s=We(n.nodeSize,n.nodeSizeRange,e),a=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ce,l=new Map;e.forEach((e,t)=>{l.set(e.id,a[t%a.length])});const c=[],u=[],d=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=s(Se(t,"nodeSize")),r=o?o(Se(t,"nodeStyle")):{},i={fill:r.fill||l.get(t.id)||n.themeSemantic?.primary||"#007bff",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity};c.push({type:"circle",cx:t.x,cy:t.y,r:e,style:i,datum:t,id:t.id,label:t.id})}const h=new Map;for(const t of e)h.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:h.get(e.source),r="object"==typeof e.target?e.target:h.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const o=i?i(Se(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:o.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6},datum:e})}if(!1!==n.showLabels){const t=(f=n.nodeLabel)?"function"==typeof f?f:e=>e[f]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const r=s(Se(n,"nodeSize"));d.push({x:n.x,y:n.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:c,sceneEdges:u,labels:d}}};function Pe(e,t,n){const r=[];for(const o of t){const t="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let s=null;if(t===e?s=i:i===e&&(s=t),s){const e=n.get(s);!e||0===e.x&&0===e.y||r.push({x:e.x,y:e.y})}}return r}function _e(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function We(e,t,n){if(n.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const r=t||[5,20],o=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&o.push(n)}if(0===o.length)return()=>r[0];const[i,s]=Te(o);if(i===s)return()=>(r[0]+r[1])/2;const a=(0,je.scaleLinear)().domain([i,s]).range(r).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?r[0]:a(n)}}var $e=require("d3-chord"),Oe=require("d3-shape"),Be=ce,ze={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:s}=n,a=Math.min(r[0],r[1])/2,l=a-i,c=r[0]/2,u=r[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:e=>e[h]??1:e=>e.value??1;var h;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const g=e.length,y=Array.from({length:g},()=>Array.from({length:g},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=f.get("string"==typeof e.source?e.source:e.source.id),r=f.get(t);if(void 0===n||void 0===r)continue;const o=d(e);y[n][r]=o}const p=(0,$e.chord)().padAngle(o);s&&p.sortGroups(s);const m=p(y),v=m.groups,b=(0,Oe.arc)().innerRadius(l).outerRadius(a);for(const t of v){const n=e[t.index],r=b.centroid({innerRadius:l,outerRadius:a,startAngle:t.startAngle,endAngle:t.endAngle});n.x=r[0]+c,n.y=r[1]+u,n.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=x.get("string"==typeof e.source?e.source:e.source.id),r=x.get(t);n&&(e.source=n),r&&(e.target=r)}const k=new Map;for(const e of t)k.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of m){const n=e[t.source.index].id,r=e[t.target.index].id,o=k.get(`${n}\0${r}`)||k.get(`${r}\0${n}`);o&&(o.__chordData=t)}},buildScene(e,t,n,r){const{groupWidth:o=20,edgeOpacity:i=.5}=n,s=Math.min(r[0],r[1])/2,a=s-o,l=r[0]/2,c=r[1]/2,u=n.nodeStyle,d=n.edgeStyle,h=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Be,g=new Map;e.forEach((e,t)=>{g.set(e.id,f[t%f.length])});const y=(0,$e.ribbon)().radius(a),p=[],m=[],v=[];for(let t=0;e.length>t;t++){const n=e[t],r=n.__arcData;if(!r)continue;let o;o=u?u(Se(n,"nodeStyle")).fill||g.get(n.id)||f[t%f.length]:g.get(n.id)||f[t%f.length];const i=u?u(Se(n,"nodeStyle")):{};p.push({type:"arc",cx:l,cy:c,innerR:a,outerR:s,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:{fill:o,stroke:i.stroke||"black",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const r=y(t);if(!r)continue;const o=He(r,l,c);let s=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(d)s=d(Se(e,"edgeStyle")).fill||s;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===h&&n?s=g.get(n.id)||s:t&&(s=g.get(t.id)||s)}const a=d?d(Se(e,"edgeStyle")):{};m.push({type:"ribbon",pathD:o,style:{fill:s,fillOpacity:a.fillOpacity??i,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:e})}if(!1!==n.showLabels){const t=(b=n.nodeLabel)?"function"==typeof b?b:e=>e[b]||e.id:null,r=s+12;for(const n of e){const e=n.__arcData;if(!e)continue;const o=t?t(n):n.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,s=i-Math.PI/2;v.push({x:l+Math.cos(s)*r,y:c+Math.sin(s)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var b;return{sceneNodes:p,sceneEdges:m,labels:v}}};function He(e,t,n){const r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;const o=[];let i=0;for(;r.length>i;){const e=r[i];if("M"===e||"L"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("C"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;3>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("Q"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;2>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("A"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&(o.push(Number(r[i])+t+""),i++),r.length>i&&(o.push(Number(r[i])+n+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(r[i]),i++)}return o.join(" ")}var Fe=require("d3-hierarchy"),qe=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Ye(e){const[t,n,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*r>150?"#222":"#fff"}function Xe(e,t,n){const r=t.nodeIDAccessor;return"function"==typeof r?r(e.data)+"":"string"==typeof r&&void 0!==e.data[r]?e.data[r]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function Ge(e){if(!e)return null;if("function"==typeof e){const t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function Ve(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:qe}function Ue(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:e.themeSemantic?.primary?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function Ke(e,t,n,r,o){if("horizontal"===o){const o=(e+n)/2;return`M ${e},${t} C ${o},${t} ${o},${r} ${n},${r}`}if("radial"===o){const o=(e+n)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+r)/2} T ${n},${r}`}{const o=(t+r)/2;return`M ${e},${t} C ${e},${o} ${n},${o} ${n},${r}`}}var Qe={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;if(!o)return;const i=n.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),a=n.hierarchySum,l="function"==typeof a?a:"string"==typeof a?e=>Number(e[a])||0:e=>Number(e.value)||0,c=(0,Fe.hierarchy)(o,s);c.sum(l),c.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=r;switch(i){case"tree":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=(0,Fe.tree)();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(c,n,u,d);break;case"cluster":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=(0,Fe.cluster)();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(c,n,u,d);break;case"treemap":!function(e,t,n,r){const o=t.padding??4,i=t.paddingTop??0,s=(0,Fe.treemap)().size([n,r]).tile(Fe.treemapBinary).padding(o);i>0&&s.paddingTop(i),s(e)}(c,n,u,d);break;case"circlepack":!function(e,t,n,r){const o=t.padding??4;(0,Fe.pack)().size([n,r]).padding(o)(e)}(c,n,u,d);break;case"partition":!function(e,t,n,r){(0,Fe.partition)().size([n,r]).padding(t.padding??1)(e)}(c,n,u,d)}const h=c.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;h.length>t;t++){const r=h[t],o={id:Xe(r,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:r.value??0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===i||"cluster"===i?Ze(o,r,n):"treemap"===i||"partition"===i?Je(o,r):"circlepack"===i&&et(o,r),o.__hierarchyNode=r,e.push(o),f.set(r,o)}if("tree"===i||"cluster"===i)for(const e of h)if(e.parent){const n=f.get(e.parent),r=f.get(e);n&&r&&t.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,r){const o=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,r,o,i){const s=[],a=[],l=[],c=n.treeOrientation||"vertical",u="radial"===c,d=r[0]/2,h=r[1]/2,f="number"==typeof(g=n.nodeSize)?g:5;var g;for(const t of e){let e=t.x,r=t.y;u&&(e+=d,r+=h);const i=o(Se(t,"nodeStyle"));let a=i.fill||Ue(n);if(n.colorByDepth&&void 0!==t.depth){const e=Ve(n);a=e[t.depth%e.length]}s.push({type:"circle",cx:e,cy:r,r:f,style:{fill:a,stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:t,id:t.id,label:t.id,depth:t.depth})}const y=n.edgeOpacity??.5;for(const e of t){const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=t.x,s=t.y,l=r.x,f=r.y;u&&(o+=d,s+=h,l+=d,f+=h);const g=Ke(o,s,l,f,c),p=i(Se(e,"edgeStyle"));a.push({type:"curved",pathD:g,style:{fill:"none",stroke:p.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:p.strokeWidth??1.5,opacity:p.opacity??y},datum:e})}if(!1!==n.showLabels){const t=Ge(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let r,o,i,s=n.x,a=n.y;if(u&&(s+=d,a+=h),u){const e=s-d,t=a-h,n=Math.sqrt(e*e+t*t);n>0?(r=s+e/n*10,o=a+t/n*10,i=0>e?"end":"start"):(r=s,o=a-12,i="middle")}else"horizontal"===c?(n.data?.children&&0!==n.data.children.length?(r=s-f-6,i="end"):(r=s+f+6,i="start"),o=a):(r=s,o=a+f+14,i="middle");l.push({x:r,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:l}}(e,t,n,r,o,i);case"treemap":case"partition":return function(e,t,n,r){const o=[],i=[];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=r(Se(n,"nodeStyle"));let a=s.fill||Ue(t);if(t.colorByDepth&&void 0!==n.depth){const e=Ve(t);a=e[n.depth%e.length]}o.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:{fill:a,stroke:s.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Ge(t.nodeLabel),o=t.labelMode||"leaf",s="partition"===t.chartType;for(const a of e){const e=a.x1-a.x0,l=a.y1-a.y0;if(0>=e||0>=l)continue;const c=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===o&&!c)continue;if("parent"===o&&c)continue}const u=n?n(a):a.id;if(!u)continue;if((c?30:40)>e||(c?16:14)>l)continue;let d=r(Se(a,"nodeStyle")).fill||Ue(t);if(t.colorByDepth&&void 0!==a.depth){const e=Ve(t);d=e[a.depth%e.length]}const h="string"==typeof d?Ye(d):t.themeSemantic?.text??"#000";i.push(c?{x:a.x0+e/2,y:a.y0+l/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,l)/6)),fill:h}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,n,0,o);case"circlepack":return function(e,t,n,r){const o=[],i=[];for(const n of e){const e=n.__radius??5;if(0>=e)continue;const i=r(Se(n,"nodeStyle"));let s=i.fill||Ue(t);if(t.colorByDepth&&void 0!==n.depth){const e=Ve(t);s=e[n.depth%e.length]}o.push({type:"circle",cx:n.x,cy:n.y,r:e,style:{fill:s,stroke:i.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Ge(t.nodeLabel);for(const o of e){const e=o.__radius??5,s=n?n(o):o.id;if(!s)continue;if(15>e)continue;const a=!(o.data?.children&&o.data.children.length>0);let l=r(Se(o,"nodeStyle")).fill||Ue(t);if(t.colorByDepth&&void 0!==o.depth){const e=Ve(t);l=e[o.depth%e.length]}if(a){const n="string"==typeof l?Ye(l):t.themeSemantic?.text??"#000";i.push({x:o.x,y:o.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else i.push({x:o.x,y:o.y-e+14,text:s+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Ze(e,t,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=t.x,r=t.y;e.x=r*Math.cos(n-Math.PI/2),e.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function Je(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function et(e,t){const n=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}var tt=require("d3-shape");function nt(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var rt={sankey:Ce,force:Ne,chord:ze,tree:Qe,cluster:Qe,treemap:Qe,circlepack:Qe,partition:Qe,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;o&&function(e,t,n,r,o){const i=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),s=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(n.nodeIDAccessor),a=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),l=n.orbitSize??2.95,c=n.orbitEccentricity??1,u="number"==typeof l?()=>l:l,d="number"==typeof c?()=>c:c,h=nt(n);h.metaMap.clear(),r.length=0,o.length=0;const f=new Map;function g(e){const t=f.get(e)??0;return f.set(e,t+1),0===t?e:`${e}__${t}`}const y=t[0]/2,p=t[1]/2,m=Math.min(t[0],t[1])/2*.85,v=g(s(e));r.push({id:v,x:y,y:p,x0:y,x1:y,y0:p,y1:p,width:0,height:0,value:0,depth:0,data:e}),h.metaMap.set(v,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,l,c,f,y,p){const m=i(t);if(!m?.length)return;const v=m.length;let b=0,x=0,k=0;for(;v>x;)x+=a[Math.min(k,a.length-1)],k++,b++;let w=0;for(let v=0;b>v;v++){const x=a[Math.min(v,a.length-1)],k=m.slice(w,w+x);if(!k.length)break;const S=(v+1)/b,M={id:n,depth:y,data:t,parentId:n},A=p?f/u(M)*S:f*S,C=(0,tt.pie)().value(e=>{const t=i(e)?.length;return t?4:1}).sort(null)(k),L=d(M);for(let t=0;k.length>t;t++){const i=(C[t].startAngle+C[t].endAngle)/2,a=k[t],u=g(s(a)),d=l+A*Math.sin(i),f=c+A*Math.cos(i)*L;r.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:y,data:a}),h.metaMap.set(u,{ring:A,angle:i,depth:y,parentId:n,eccentricity:L}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(a,u,d,f,A,y+1,!0)}w+=x}}(e,v,y,p,m,1,!1)}(o,r,n,e,t)},buildScene(e,t,n,r){const o=n.nodeStyle,i=n.nodeSize,s="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,a=[],l=[],c=[];if(!1!==n.orbitShowRings){const t=nt(n),r=new Map;for(const t of e)r.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=r.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;o.has(n)||o.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:r}]of o)for(let o=0;i>o;o++){const a=o/i*Math.PI*2,c=(o+1)/i*Math.PI*2;l.push({type:"line",x1:e+n*Math.sin(a),y1:t+n*Math.cos(a)*r,x2:e+n*Math.sin(c),y2:t+n*Math.cos(c)*r,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=s(Se(t,"nodeSize")),r=o?o(Se(t,"nodeStyle")):{};a.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:r.fill||n.themeSemantic?.primary||"#6366f1",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??(0===(t.depth??0)?1:.85)},datum:t,id:t.id,label:t.id,depth:t.depth})}const u=new Map;for(const t of e)u.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:u.get(e.source),n="object"==typeof e.target?e.target:u.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&l.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=s(Se(n,"nodeSize"));if(4>=e)continue;const r="function"==typeof t?t(n):t?n.data?.[t]??n.id:n.id;c.push({x:n.x,y:n.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:l,labels:c}},tick:(e,t,n,r,o)=>!1!==n.orbitAnimated&&(function(e,t){const n=nt(t),r=t.orbitSpeed??.25,o=t.orbitRevolution??function(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),i=(("undefined"!=typeof performance?performance.now():Date.now())-n.startTime)/1e3,s=r*(Math.PI/6),a=new Map;for(const t of e)a.set(t.id,t);for(const t of e){const e=n.metaMap.get(t.id);if(!e||!e.parentId)continue;const r=a.get(e.parentId);if(!r)continue;const l=e.angle+i*s*o({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(l),t.y=r.y+e.ring*Math.cos(l)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)}};function ot(e){return rt[e]}function it(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(it))}function st(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function at(e,t,n){return e+(t-e)*n}var lt=require("d3-quadtree");function ct(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function ut(e){if(!e||"object"!=typeof e)return!1;const t=e;if("boolean"!=typeof t.circular)return!1;if("number"!=typeof t.halfWidth||!Number.isFinite(t.halfWidth))return!1;if(t.circular){if(!Array.isArray(t.segments)||0===t.segments.length)return!1;for(const e of t.segments)if(!dt(e))return!1;return!0}return dt(t.points)}function dt(e){if(!Array.isArray(e)||4!==e.length)return!1;for(const t of e){if(!t||"object"!=typeof t)return!1;const e=t;if("number"!=typeof e.x||!Number.isFinite(e.x))return!1;if("number"!=typeof e.y||!Number.isFinite(e.y))return!1}return!0}var ht=require("d3-interpolate");function ft(e,t,n){if(1>=n)return 1;const r=n-1;return function(e){const t=Math.max(0,Math.min(1,e.minOpacity??.1));if(Number.isNaN(e.age))return 1;if(e.age===1/0)return t;if(!Number.isFinite(e.extent)||0>=e.extent)return 1;const n=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>n?1:t;if("exponential"===e.type){const r=e.halfLife??e.extent/2;return t+Math.pow(.5,n/(r>0?r:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-n/e.extent))*(1-t)}({age:r-t,extent:r,type:e.type,halfLife:e.halfLife??n/2,threshold:e.stepThreshold??.5*n,minOpacity:e.minOpacity??.1})}var gt="rgba(34, 197, 94, 0.7)",yt=2e3,pt={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"};function mt(e,t){const n={...e};for(const e of t)n[pt[e]]++;return n}function vt(e,t,n){const r=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:r,revisions:mt(n,r)}}var bt=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=vt({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){const n=vt(e,t,this.revisions);this.revisions=n.revisions,this.latest=n;for(const e of[...this.listeners])e();return n}},xt=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],kt=["scene-style","data-paint","accessibility","evidence"],wt=(e,t)=>({retainedData:e,invalidations:t}),St=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Mt=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],At=["scene-geometry","data-paint","overlay","accessibility","evidence"],Ct=["scene-style","data-paint","accessibility","evidence"],Lt=["scene-geometry","data-paint","overlay","accessibility","evidence"],jt=[],Tt={chartType:wt("rebuild",St),nodeIDAccessor:wt("rebuild",St),sourceAccessor:wt("rebuild",St),targetAccessor:wt("rebuild",St),valueAccessor:wt("rebuild",St),edgeIdAccessor:wt("rebuild",St),childrenAccessor:wt("rebuild",St),hierarchySum:wt("rebuild",St),orientation:wt("preserve",Mt),nodeAlign:wt("preserve",Mt),nodePaddingRatio:wt("preserve",Mt),nodeWidth:wt("preserve",Mt),edgeSort:wt("preserve",Mt),iterations:wt("preserve",Mt),forceStrength:wt("preserve",Mt),padAngle:wt("preserve",Mt),groupWidth:wt("preserve",Mt),sortGroups:wt("preserve",Mt),treeOrientation:wt("preserve",Mt),edgeType:wt("preserve",Mt),padding:wt("preserve",Mt),paddingTop:wt("preserve",Mt),orbitMode:wt("preserve",Mt),orbitSize:wt("preserve",Mt),orbitSpeed:wt("preserve",Mt),orbitRevolution:wt("preserve",Mt),orbitRevolutionStyle:wt("preserve",Mt),orbitEccentricity:wt("preserve",Mt),orbitShowRings:wt("preserve",Mt),orbitAnimated:wt("preserve",Mt),customNetworkLayout:wt("preserve",Mt),layoutConfig:wt("preserve",Mt),nodeSize:wt("preserve",At),nodeSizeRange:wt("preserve",At),colorByDepth:wt("preserve",At),nodeLabel:wt("preserve",Lt),showLabels:wt("preserve",Lt),labelMode:wt("preserve",Lt),nodeStyle:wt("preserve",Ct),edgeStyle:wt("preserve",Ct),colorBy:wt("preserve",Ct),colorScheme:wt("preserve",Ct),themeCategorical:wt("preserve",Ct),themeSemantic:wt("preserve",Ct),edgeColorBy:wt("preserve",Ct),edgeOpacity:wt("preserve",Ct),showParticles:wt("preserve",Ct),particleStyle:wt("preserve",Ct),decay:wt("preserve",Ct),pulse:wt("preserve",Ct),thresholds:wt("preserve",Ct),staleness:wt("preserve",Ct),layoutSelection:wt("preserve",Ct),clock:wt("preserve",jt),random:wt("preserve",jt),seed:wt("preserve",jt),tensionConfig:wt("preserve",jt),transition:wt("preserve",jt),introAnimation:wt("preserve",jt),onLayoutError:wt("preserve",jt),__skipForceSimulation:wt("preserve",jt),__hierarchyRoot:wt("preserve",jt),__orbitState:wt("preserve",jt),__previousPositions:wt("preserve",jt)},Et=wt("preserve",Mt),Dt=class{constructor(){this.tracker=new bt}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},xt)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},kt):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const r of e){const e=Tt[r]??Et;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},Rt=new WeakMap;var It=require("d3-scale"),Nt={category10:ce,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...pe},Pt=ce,_t="#007bff";function Wt(e,t,n=Pt){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=Nt[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}var $t=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Ot=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],Bt=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function zt(e,t,n){if("function"==typeof t){const r=t(e);return n&&r&&"string"==typeof r&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||Bt.has(t)}(r)?n(r):r}const r=e?.[t]+"";return n?n(r):Pt[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(r))%Pt.length]}function Ht(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;const n=e[t];return"string"==typeof n&&n.length>0?n:void 0}function Ft(e,t,n="category10"){if(n&&"object"==typeof n&&!Array.isArray(n)){const e=n;return t=>Ht(e,t)??"#999"}const r=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>e+""))),o=r.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return(0,It.scaleOrdinal)().domain(r).range(n).unknown("#999");const i=Nt[n]||Nt.category10;if(o&&"function"==typeof i){let e=-1/0;for(const t of r){const n=Number(t);n>e&&(e=n)}return t=>i(Number(t)/e)}{const e=Array.isArray(i)?i:Pt;return(0,It.scaleOrdinal)().domain(r).range(e).unknown("#999")}}function qt(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&Ht(n,e)||"#4e79a7":t=>{if(n){const e=Ht(n,t);if(e)return e}let r=0;for(let e=0;t.length>e;e++)r=31*r+t.charCodeAt(e)|0;return e[Math.abs(r)%e.length]??"#4e79a7"}}function Yt({config:e,customLayout:t,size:n,nodes:r,edges:o,previousResult:i,revision:s}){const a=Wt(e.colorScheme,e.themeCategorical,ce),l={nodes:r,edges:o,dimensions:{width:n[0],height:n[1],plot:{x:0,y:0,width:n[0],height:n[1]}},theme:{semantic:e.themeSemantic??{},categorical:[...a]},resolveColor:qt(a,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};try{return{kind:"success",result:t(l)}}catch(t){const n=null!==i,r=function(e,t,n,r){const o=function(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:e+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(t),i="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:i,message:`Semiotic ${e} ${i} failed: ${o.message}`,error:o,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:r}}("network",t,n,s);"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t);try{e.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:r,preservedLastGoodScene:n}}}var Xt=class e{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this.customLayoutHtmlMarks=[],this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,this.particlePool=null,this.updateResults=new Dt,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this._decayAgeMap=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._networkDecayCache=null,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig={...g,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new p(2e3))}currentTime(){return this.config.clock?.()??("undefined"!=typeof performance?performance.now():Date.now())}updateConfig(e){const t=this.config,n={...t,...e};t.__orbitState&&(n.__orbitState=t.__orbitState),t.__hierarchyRoot&&(n.__hierarchyRoot=t.__hierarchyRoot),void 0===e.layoutSelection&&null!=t.layoutSelection&&(n.layoutSelection=t.layoutSelection);const r=[...new Set([...Object.keys(t),...Object.keys(n)])].filter(e=>t[e]!==n[e]);this.config=n,this.tensionConfig={...g,...n.tensionConfig},!n.showParticles||"sankey"!==n.chartType&&!n.customNetworkLayout||this.particlePool||(this.particlePool=new p(2e3)),this.updateResults.recordConfig(r)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null,this.updateResults.recordData("replace",1)}ingestBounded(e,t,n,r){const{nodeIDAccessor:o="id",sourceAccessor:i="source",targetAccessor:s="target",valueAccessor:a="value"}=this.config,l="function"==typeof o?o:e=>e[o],c="function"==typeof i?i:e=>e[i],u="function"==typeof s?s:e=>e[s],d="function"==typeof a?a:e=>e[a]??1;this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const t of e){const e=l(t)+"";this.nodes.set(e,{...ct(e),data:t})}for(let e=0;t.length>e;e++){const n=t[e],r=c(n)+"",o=u(n)+"",i=d(n),s=null==i?NaN:Number(i),a=Number.isFinite(s)?s:1;this.nodes.has(r)||this.nodes.set(r,{...ct(r),data:n}),this.nodes.has(o)||this.nodes.set(o,{...ct(o),data:n});const l=`${r}\0${o}\0${e}`,h={source:r,target:o,value:a,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l};n&&"object"==typeof n&&ut(n.bezier)&&(h.bezier=n.bezier),this.edges.set(l,h)}r?.deferLayout||this.runLayout(n),this.updateResults.recordData("replace",e.length+t.length)}ingestBoundedWithResult(e,t,n,r){return this.ingestBounded(e,t,n,r),this.updateResults.last}applyForceLayoutPositions(e,t){for(const[t,n]of Object.entries(e)){const e=this.nodes.get(t);e&&(e.x=n.x,e.y=n.y)}this.config.__skipForceSimulation=!0;try{this.runLayout(t)}finally{this.config.__skipForceSimulation=void 0}}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:r}=e,o=0===this.nodes.size;let i=!1;const s=this.currentTime();this.lastIngestTime=s,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,ct(t)),this.nodeTimestamps.set(t,s),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,ct(n)),this.nodeTimestamps.set(n,s),this.tension+=this.tensionConfig.newNode,i=!0);const a=this.edgeKey(t,n),l=this.edges.get(a);let c=!1;l?(l.value+=r,this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:t,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.newEdge,i=!0);const u=o||i||c||this.tension>=this.tensionConfig.threshold;return this.updateResults.recordData("ingest",1),u}ingestEdgeWithResult(e){return this.ingestEdge(e),this.updateResults.last}runLayout(e){if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const t=ot(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values());const r=Array.from(this.edges.values());if(0===n.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.supportsStreaming&&!t.hierarchical){const e=new Map;for(const t of n)void 0!==t._prevX0?e.set(t.id,{x:(t._prevX0??0)+((t._prevX1??0)-(t._prevX0??0))/2,y:(t._prevY0??0)+((t._prevY1??0)-(t._prevY0??0))/2}):0===t.x&&0===t.y||e.set(t.id,{x:t.x,y:t.y});if(this._lastPositionSnapshot)for(const[t,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(t.computeLayout(n,r,this.config,e),this.config.__previousPositions=void 0,t.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const e of n)this.nodes.set(e.id,e);for(let e=0;r.length>e;e++){const t=r[e],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const n=e.get(t.id);n&&(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,n=Array.from(this.nodes.values())}this.finalizeLayout();const o=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||o.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=o,this.saveTargetPositions();const i=n.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),s=this.config.transition?.duration??this.tensionConfig.transitionDuration,a=["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType);if(!this._hasRenderedOnce&&this.config.introAnimation&&a&&n.length>0&&s>0){const t=e[0]/2,n=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=n,e._prevY1=n;for(const e of this.edges.values())e._prevY0=n,e._prevY1=n,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:s}}else i&&s>0&&(this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:s});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime=this.currentTime()),this.previousNodeIds=e,this.previousEdgeKeys=t}restyleScene(e){const t=function({nodes:e,edges:t,restyle:n,restyleEdge:r,baseStyles:o,selection:i}){const s=!(!n&&!r);if(n)for(const t of e){const e=o.get(t)??t.style,r=n(t,i);t.style=r?{...e,...r}:e}if(r)for(const e of t){const t=o.get(e)??e.style,n=r(e,i);e.style=n?{...t,...n}:t}return s}({nodes:this.sceneNodes,edges:this.sceneEdges,restyle:this._customRestyle,restyleEdge:this._customRestyleEdge,baseStyles:this._baseStyles,selection:e});this.markStylePaintPending(),this.updateResults.recordRestyle(t)}buildScene(e){if(this.config.customNetworkLayout){const t=Yt({config:this.config,customLayout:this.config.customNetworkLayout,size:e,nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values()),previousResult:this.lastCustomLayoutResult,revision:this.layoutVersion});if("failure"===t.kind)return this.lastCustomLayoutFailure=t.diagnostic,void(t.preservedLastGoodScene||(this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._sceneNodesRevision++));const n=t.result;return this.sceneNodes=n.sceneNodes??[],this.sceneEdges=n.sceneEdges??[],this.labels=n.labels??[],this.customLayoutOverlays=n.overlays??null,this.customLayoutHtmlMarks=n.htmlMarks??[],this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=n.restyle,this._customRestyleEdge=n.restyleEdge,this.hasCustomRestyle=!(!n.restyle&&!n.restyleEdge),this.hasCustomRestyle&&(this._baseStyles=function(e,t){const n=new WeakMap;for(const t of e)n.set(t,t.style);for(const e of t)n.set(e,e.style);return n}(this.sceneNodes,this.sceneEdges),this.restyleScene(this.config.layoutSelection??null)),void function(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:r,warned:o}=e;it(r)&&0===n.length&&st(o,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),n.length>0&&n.every(e=>null==e.datum)&&st(o,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}({label:"customNetworkLayout",nodes:this.sceneNodes,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned})}this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null;const t=ot(this.config.chartType);if(!t)return void this._sceneNodesRevision++;const n=t.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=t.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:o,sceneEdges:i,labels:s}=t.buildScene(n,r,this.config,e);this.sceneNodes=o,this.sceneEdges=i,this.labels=s,this._sceneNodesRevision++}rebuildNodeQuadtree(){let t=0,n=0;for(const e of this.sceneNodes)"circle"===e.type&&(t++,e.r>n&&(n=e.r));if(this._maxNodeRadius=n,e.QUADTREE_THRESHOLD>=t)return void(this._nodeQuadtree=null);const r=Array(t);let o=0;for(const e of this.sceneNodes)"circle"===e.type&&(r[o++]=e);this._nodeQuadtree=(0,lt.quadtree)().x(e=>e.cx).y(e=>e.cy).addAll(r)}get nodeQuadtree(){return this._nodeQuadtreeRevision!==this._sceneNodesRevision&&(this.rebuildNodeQuadtree(),this._nodeQuadtreeRevision=this._sceneNodesRevision),this._nodeQuadtree}get maxNodeRadius(){return this._maxNodeRadius}_ensureArrays(){this._arrCacheVersion===this.layoutVersion&&this._nodesArrCache&&this._edgesArrCache||(this._nodesArrCache=Array.from(this.nodes.values()),this._edgesArrCache=Array.from(this.edges.values()),this._arrCacheVersion=this.layoutVersion)}get nodesArray(){return this._ensureArrays(),this._nodesArrCache}get edgesArray(){return this._ensureArrays(),this._edgesArrCache}get isAnimating(){const e=ot(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=ot(this.config.chartType);if(!n?.tick)return!1;const r=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(r,o,this.config,e,t)}cancelIntroAnimation(){this.transition=null;for(const e of this.nodes.values())e._prevX0=void 0,e._prevX1=void 0,e._prevY0=void 0,e._prevY1=void 0;for(const e of this.edges.values())e._prevY0=void 0,e._prevY1=void 0,e._prevSankeyWidth=void 0,e._introFromZero=!1}advanceTransition(e){if(!this.transition)return!1;const t=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.transition),n=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=at(e._prevX0,e._targetX0,n),e.x1=at(e._prevX1,e._targetX1,n),e.y0=at(e._prevY0,e._targetY0,n),e.y1=at(e._prevY1,e._targetY1,n));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=at(e._prevY0,e._targetY0,n),e.y1=at(e._prevY1,e._targetY1,n),e.sankeyWidth=at(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const n=e?.get(t.id);n&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const n=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(n){e._prevY0=n.y0,e._prevY1=n.y1,e._prevSankeyWidth=n.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){!function(e,t,n=.5){const r="string"==typeof e.source?t.get(e.source):e.source,o="string"==typeof e.target?t.get(e.target):e.target;!r||!o||(e.bezier=e.circular&&e.circularPathData?function(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),r=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let r;r="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let e=0;r.length-1>e;e++){const t=r[e],n=r[e+1],i=n.x-t.x,s=n.y-t.y;o.push([t,{x:t.x+i/3,y:t.y+s/3},{x:t.x+2*i/3,y:t.y+2*s/3},n])}return{circular:!0,segments:o,halfWidth:t}}(e):function(e,t,n,r=.5){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,s=n.x0,a=(0,ht.interpolateNumber)(i,s);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:a(r)},{x:e.y1,y:a(1-r)},{x:e.y1,y:s}],halfWidth:o}}const i=t.x1,s=n.x0,a=(0,ht.interpolateNumber)(i,s);return{circular:!1,points:[{x:i,y:e.y0},{x:a(r),y:e.y0},{x:a(1-r),y:e.y1},{x:s,y:e.y1}],halfWidth:o}}(e,r,o,n))}(e,this.nodes,.5)}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){!function(e){const t=e.pulse;if(!t)return;const n=t.duration??500,r=t.color??"rgba(255,255,255,0.6)",o=t.glowRadius??4,{now:i}=e;for(const t of e.sceneNodes){const s=t.id;if(!s)continue;const a=e.nodeTimestamps.get(s);if(!a)continue;const l=i-a;n>l&&(t._pulseIntensity=1-l/n,t._pulseColor=r,t._pulseGlowRadius=o)}for(const t of e.sceneEdges){const o=t.datum;if(!o)continue;const s="object"==typeof o.source?o.source?.id:o.source,a="object"==typeof o.target?o.target?.id:o.target;if(!s||!a)continue;const l=e.edgeTimestamps.get(`${s}\0${a}`);if(!l)continue;const c=i-l;n>c&&(t._pulseIntensity=1-c/n,t._pulseColor=r)}}({sceneNodes:this.sceneNodes,sceneEdges:this.sceneEdges,nodeTimestamps:this.nodeTimestamps,edgeTimestamps:this.edgeTimestamps,pulse:this.config.pulse,now:e})}applyDecay(){this._networkDecayCache||(this._networkDecayCache={sortedNodes:null,ageMap:null}),this._decaySortedNodes||(this._networkDecayCache.sortedNodes=null,this._networkDecayCache.ageMap=null),function(e){const t=e.decay;if(!t)return;const n=e.nodeTimestamps.size;if(1>=n)return;if(!e.cache.sortedNodes){e.cache.sortedNodes=Array.from(e.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]);const t=new Map;for(let n=0;e.cache.sortedNodes.length>n;n++)t.set(e.cache.sortedNodes[n][0],n);e.cache.ageMap=t}const r=e.cache.ageMap;for(const o of e.sceneNodes){const e=o.id;if(!e)continue;const i=r.get(e);if(void 0===i)continue;const s=ft(t,i,n);o.style={...o.style,opacity:(o.style?.opacity??1)*s}}}({sceneNodes:this.sceneNodes,nodeTimestamps:this.nodeTimestamps,decay:this.config.decay,cache:this._networkDecayCache}),this._decaySortedNodes=this._networkDecayCache.sortedNodes,this._decayAgeMap=this._networkDecayCache.ageMap}applyTopologyDiff(e){!function(e){for(const t of e.sceneNodes)t._pulseColor===gt&&(t._pulseIntensity=0,t._pulseColor=void 0,t._pulseGlowRadius=void 0);if(0===e.addedNodes.size)return;const t=e.now-e.lastTopologyChangeTime;if(t>=yt)return;const n=1-t/yt;for(const t of e.sceneNodes){const r=t.id;r&&e.addedNodes.has(r)&&(t._pulseIntensity=Math.max(t._pulseIntensity??0,n),t._pulseColor=gt,t._pulseGlowRadius=8)}}({sceneNodes:this.sceneNodes,addedNodes:this.addedNodes,lastTopologyChangeTime:this.lastTopologyChangeTime,now:e})}get hasActiveTopologyDiff(){return function(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){return 0!==e.size&&yt>n-t}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(e){!function(e){const t=e.thresholds;if(!t)return;const n=t.warningColor??"#f59e0b",r=t.criticalColor??"#ef4444",o=!1!==t.pulse;for(const i of e.sceneNodes){const s=i.id;if(!s)continue;const a=e.nodes.get(s);if(!a)continue;const l=t.metric(a);let c=null;void 0===t.critical||t.critical>l?void 0===t.warning||t.warning>l||(c=n):c=r,c&&(i.style={...i.style,fill:c},o&&(i._pulseIntensity=.6+.4*Math.sin(e.now/300),i._pulseColor=c,i._pulseGlowRadius=6))}}({sceneNodes:this.sceneNodes,nodes:this.nodes,thresholds:this.config.thresholds,now:e})}get hasActiveThresholds(){return function(e,t){if(!t)return!1;for(const n of e){const e=t.metric(n);if(void 0!==t.warning&&e>=t.warning||void 0!==t.critical&&e>=t.critical)return!0}return!1}(this.nodes.values(),this.config.thresholds)}get hasActivePulses(){return function(e){const t=e.pulse;if(!t||0===e.lastIngestTime)return!1;const n=e.now??("undefined"!=typeof performance?performance.now():Date.now());return(t.duration??500)>n-e.lastIngestTime}({pulse:this.config.pulse,lastIngestTime:this.lastIngestTime})}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){const n=this.nodes.get(e);if(!n)return this.updateResults.recordNoop("update"),null;const r=n.data?{...n.data}:{};return n.data=t(n.data??{}),this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",1),r}updateEdge(e,t,n){const r=this.config.valueAccessor,o="function"==typeof r?r:r?e=>e[r]:e=>e.value,i=[];for(const[,r]of this.edges)if(("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t){i.push(r.data?{...r.data}:{}),r.data=n(r.data??{});const e=o(r.data);null!=e&&(r.value=Number(e))}return i.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",i.length)):this.updateResults.recordNoop("update"),i}removeNode(e){if(!this.nodes.has(e))return this.updateResults.recordNoop("remove"),!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",1),!0}removeEdge(e,t){const n=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const r="function"==typeof t?t:e=>e?.[t];for(const[t,o]of this.edges)o.data&&r(o.data)===e&&n.push(t)}else for(const[r,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t&&n.push(r);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",n.length)):this.updateResults.recordNoop("remove"),n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this._decayAgeMap=null,this._nodeQuadtree=null,this._nodesArrCache=null,this._edgesArrCache=null,this._sceneNodesRevision++,this.tension=0,this.layoutVersion++,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.particlePool&&this.particlePool.clear(),this.updateResults.recordData("clear")}};Xt.QUADTREE_THRESHOLD=500;var Gt=Xt;Object.assign(Gt.prototype,{getLastUpdateResult:function(){return this.updateResults.last},getUpdateSnapshot:function(){return this.updateResults.last},subscribeUpdateResult:function(e){return this.updateResults.subscribe(e)},setLayoutSelection:function(e){this.config.layoutSelection=e},markStylePaintPending:function(){Rt.set(this,!0)},consumeStylePaintPending:function(){const e=!0===Rt.get(this);return Rt.delete(this),e}});var Vt=require("react"),Ut={sceneGeometry:0,layout:0,domain:0};function Kt(e){const{domain:t,layout:n,sceneGeometry:r}=e.revisions;return{domain:t,layout:n,sceneGeometry:r}}function Qt(e,t){return{sceneGeometry:Math.max(e.sceneGeometry,t.sceneGeometry),layout:Math.max(e.layout,t.layout),domain:Math.max(e.domain,t.domain)}}var Zt="production"!==process.env.NODE_ENV,Jt={revisions:Ut,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},en=class{constructor(e="scene host"){this.hostName=e,this.lastConsumed=Ut,this.lastObserved=Ut,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}observeUpdateResult(e){Zt&&(this.lastObserved=Qt(this.lastObserved,Kt(e)))}beforeCompute(e,t){if(!Zt)return Jt;const n=Qt(Kt(e),this.lastObserved),r=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),o=!((i=n).sceneGeometry===(s=this.lastConsumed).sceneGeometry&&i.layout===s.layout&&i.domain===s.domain);var i,s;return{revisions:n,signature:r,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:o,warnUnconsumed:!t&&o&&this.lastUnconsumedWarning!==r}}afterCompute(e,t,n){if(Zt){if(t&&e.wasUnconsumed&&(this.lastConsumed=e.revisions),e.warnUnconsumed&&!t)return console.warn(`[semiotic] ${this.hostName} observed scene-affecting revisions without a scene rebuild: ${e.signature}.`),void(this.lastUnconsumedWarning=e.signature);t&&e.sawSignals&&!e.wasUnconsumed&&!n&&this.lastDuplicateWarning!==e.signature?(console.warn(`[semiotic] ${this.hostName} performed scene rebuild with unchanged scene revisions: ${e.signature}.`),this.lastDuplicateWarning=e.signature):t&&!e.sawSignals&&(this.lastDuplicateWarning="")}}},tn=(0,Vt.memo)(function({store:e,diagnostics:t}){return(0,Vt.useEffect)(()=>{const n=()=>t.observeUpdateResult(e.getUpdateSnapshot());return n(),e.subscribeUpdateResult(n)},[t,e]),null}),nn=l(require("react"));function rn(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:nn.createElement(nn.Fragment,null,...t)}var on=l(require("react")),sn=require("react/jsx-runtime"),an={isActive:!1,predicate:()=>!0},ln=on.createContext(null);function cn({value:e,children:t}){return(0,sn.jsx)(ln.Provider,{value:e,children:t})}function un(){return on.useContext(ln)??an}function dn(e,t){return null!=e?(0,sn.jsx)(cn,{value:t,children:e}):e}var hn=require("react"),fn=[40,40],gn=[.5,.5];function yn(e,t){const[n,r]=e.viewBox??fn,[o,i]=e.anchor??gn,s=r>0?r:1,a=Math.max(0,t)/s,l=(n>0?n:s)*a,c=s*a;return{width:l,height:c,scale:a,offsetX:-o*l,offsetY:-i*c}}function pn(e,t){const n=yn(e,t),r=[[n.offsetX,n.offsetY],[n.offsetX+n.width,n.offsetY],[n.offsetX,n.offsetY+n.height],[n.offsetX+n.width,n.offsetY+n.height]];let o=0;for(const[e,t]of r){const n=Math.sqrt(e*e+t*t);n>o&&(o=n)}return o}function mn(e,t,n,r){if("none"!==e)return"color"===e||null==e?t??r:"accent"===e?n:e}var vn=null;function bn(e){if("undefined"==typeof Path2D)return null;vn||(vn=new Map);const t=vn.get(e);if(t)return t;const n=new Path2D(e);return vn.size>1024&&vn.clear(),vn.set(e,n),n}function xn(e,t,n=0,r="horizontal"){const[o,i]=e.viewBox??fn,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a>s?s>0||1>a?"vertical"===r?{x:0,y:i*(1-a),width:o,height:i*(a-s)}:{x:o*s,y:0,width:o*(a-s),height:i}:null:{x:0,y:0,width:0,height:0}}function kn(e,t){const n=yn(e,t);return{centerDx:n.offsetX+n.width/2,centerDy:n.offsetY+n.height/2,halfWidth:n.width/2,halfHeight:n.height/2,radius:Math.hypot(n.width,n.height)/2}}function wn(e,t,n,r,o,i=e=>e){for(const s of t.parts){const t=bn(s.d);if(!t)continue;const a=s.opacity??1,l=e.globalAlpha;1!==a&&(e.globalAlpha=l*a);const c=o?"none"===s.fill?void 0:o:mn(s.fill,n,r);c&&(e.fillStyle=i(c),e.fill(t));const u=o?s.stroke&&"none"!==s.stroke?o:void 0:mn(s.stroke??"none",n,r);u&&(e.strokeStyle=i(u),e.lineWidth=s.strokeWidth??1,e.lineCap=s.strokeLinecap??"butt",e.lineJoin=s.strokeLinejoin??"miter",e.stroke(t)),1!==a&&(e.globalAlpha=l)}}function Sn(e,t,n){const{group:r,indexInGroup:o}=t,i=n.byGroup.get(r);switch(e){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:t.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(r);return n.groups.length-1>e?Mn(n,n.groups[e+1],i[o]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(r);return e>0?Mn(n,n.groups[e-1],i[o]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function Mn(e,t,n){const r=e.byGroup.get(t);let o=0,i=Math.abs(r[0].x-n.x);for(let e=1;r.length>e;e++){const t=Math.abs(r[e].x-n.x);i>t&&(i=t,o=e)}return r[o]._flatIndex}function An(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}var Cn=require("react/jsx-runtime"),Ln="var(--semiotic-focus, #005fcc)";function jn({active:e,hoverPoint:t,margin:n,size:r,shape:o="circle",width:i,height:s,pathData:a}){if(!e||!t)return null;const l=t.x+n.left,c=t.y+n.top;let u;if("geoarea"!==o&&"path"!==o||!a)if("rect"===o&&null!=i&&null!=s){const e=Math.max(i,4),t=Math.max(s,4);u=(0,Cn.jsx)("rect",{x:l-e/2-3,y:c-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:Ln,strokeWidth:2,strokeDasharray:"4,2"})}else u=(0,Cn.jsx)("circle","wedge"===o?{cx:l,cy:c,r:12,fill:"none",stroke:Ln,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:Ln,strokeWidth:2,strokeDasharray:"4,2"});else u=(0,Cn.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:(0,Cn.jsx)("path",{d:a,fill:"none",stroke:Ln,strokeWidth:2.5,strokeDasharray:"6,3"})});return(0,Cn.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}var Tn=l(require("react")),En=["name","label","title"],Dn=["type","kind","category","group","class","status","role","shape"],Rn=["value","amount","total","count","weight","score"],In=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function Nn(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}function Pn(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,r=!1!==t.skipPositional,o=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(r&&In.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&o.push({key:t,lower:t.toLowerCase(),value:n})}if(0===o.length)return{entries:[]};let i=o.findIndex(e=>En.includes(e.lower));const s=i>=0;0>i&&(i=o.findIndex(e=>"id"===e.lower)),0>i&&(i=o.findIndex(e=>"string"==typeof e.value));const a=0>i?void 0:o[i];let l=o.filter((e,t)=>t!==i);s&&(l=l.filter(e=>"id"!==e.lower));const c=Nn(l,Dn),u=Nn(l,Rn),d=new Set(Dn),h=new Set(Rn),f=[];c&&f.push({key:c.key,value:c.value}),u&&f.push({key:u.key,value:u.value});for(const e of l){if(f.length>=n)break;e!==c&&e!==u&&(d.has(e.lower)||h.has(e.lower)||f.push({key:e.key,value:e.value}))}return{titleKey:a?.key,title:a?.value,entries:f}}var _n=require("react/jsx-runtime"),Wn={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function $n(e,t){return"function"==typeof t?t(e):e[t]}function On(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function Bn(e={}){const{fields:t,title:n,format:r,style:o={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let s;const a=[];if(n){const t=$n(e,n);s=On(t,r)}if(t&&t.length>0)t.forEach(t=>{let n,o,i;"string"==typeof t?(n=t,o=t,i=r):(n=t.label,o=t.accessor||t.key||"",i=t.format||r);const s=$n(e,o);a.push({label:n,value:On(s,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){s=On(e[n],r);break}if(!s){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(s=On(e[t[0]],r))}}const l={...Wn,...o};return(0,_n.jsxs)("div",{className:("semiotic-tooltip "+i).trim(),style:l,children:[s&&(0,_n.jsx)("div",{style:{fontWeight:a.length>0?"bold":"normal"},children:s}),a.map((e,t)=>(0,_n.jsxs)("div",{style:{marginTop:0===t&&s?"4px":0},children:[e.label&&(0,_n.jsxs)("span",{children:[e.label,": "]}),e.value]},t))]})}}function zn(e){if(!0!==e){if("function"==typeof e){const t=e;return e=>{let n=h(!0===e?.__semioticHoverData||e&&void 0!==e.data&&"number"==typeof e.x&&"number"==typeof e.y&&e&&("node"===e.type||"edge"===e.type||void 0!==e.nodeOrEdge||void 0!==e.allSeries||void 0!==e.stats||void 0!==e.__chartType)?e.data??{}:e);if(!n)return null;if(("node"===e?.nodeOrEdge&&"number"==typeof n?.x0&&"number"==typeof n?.x1||"edge"===e?.nodeOrEdge&&"number"==typeof n?.sankeyWidth)&&n.data&&"object"==typeof n.data&&(n=n.data),!n)return null;const r=t(n);return null==r?null:(0,_n.jsx)("div",{className:"semiotic-tooltip",style:Wn,children:r})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?Bn(e):"multi"===e?("undefined"!=typeof process&&"production"!==process.env?.NODE_ENV&&console.warn('[semiotic] tooltip="multi" reached normalizeTooltip — prefer charts that set tooltipMode (LineChart, AreaChart, StackedAreaChart, DifferenceChart). Rendering MultiLineTooltip content as a fallback.'),function(e={}){const{fields:t=[],title:n,format:r,style:o={},className:i="",showLabels:s=!0,separator:a=": "}=e;return e=>{if(!e||"object"!=typeof e)return null;const l=[];if(n){const t=$n(e,n);l.push({value:On(t,r)})}if(t&&Array.isArray(t)&&t.length>0)t.forEach(t=>{let n,o,i;"string"==typeof t?(n=t,o=t,i=r):(n=t.label,o=t.accessor||t.key||"",i=t.format||r);const a=On($n(e,o),i);l.push({label:s?n:void 0,value:a})});else{const t=Pn(e,{skipPositional:!1});null!=t.title&&l.push({label:void 0,value:On(t.title,r),bold:!0}),t.entries.forEach(e=>{l.push({label:s?e.key:void 0,value:On(e.value,r)})})}const c={...Wn,...o};return Array.isArray(l)&&0!==l.length?(0,_n.jsx)("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+i).trim(),style:c,children:l.map((e,t)=>(0,_n.jsxs)("div",{style:{marginBottom:l.length-1>t?"4px":0,fontWeight:e.bold?"bold":void 0},children:[e.label&&(0,_n.jsxs)("strong",{children:[e.label,a]}),e.value]},t))}):null}}()):Bn())}}var Hn=require("react/jsx-runtime");function Fn({x:e,y:t,containerWidth:n,containerHeight:r,margin:o,children:i,className:s="stream-frame-tooltip",zIndex:a=1}){const l=Number.isFinite(e)&&Number.isFinite(t),c=Tn.useRef(null),[u,d]=Tn.useState(null);Tn.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=()=>{const t=e.getBoundingClientRect();Number.isFinite(t.width)&&Number.isFinite(t.height)&&d(e=>e&&.5>Math.abs(e.width-t.width)&&.5>Math.abs(e.height-t.height)?e:{width:t.width,height:t.height})};if(t(),"undefined"==typeof ResizeObserver)return;const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[s,n,r,l]);let h;h=u?`translate(${u.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>r-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*r>t?"4px":"calc(-100% - 4px)"})`;const f=function(e){if(!Tn.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if(!0===n["data-semiotic-tooltip-chrome"])return!0;if("true"===n["data-semiotic-tooltip-chrome"])return!0;const r=n.style;if(r&&"object"==typeof r){if(null!=r.background&&""!==r.background&&"transparent"!==r.background)return!0;if(null!=r.backgroundColor&&""!==r.backgroundColor&&"transparent"!==r.backgroundColor)return!0}return!1}(i),g=f?null:Wn;return l?(0,Hn.jsx)("div",{ref:c,className:f?s:(s+" semiotic-tooltip").trim(),style:{...g||{},position:"absolute",left:o.left+e,top:o.top+t,transform:h,pointerEvents:"none",zIndex:a,width:"max-content"},children:i}):null}var qn=l(require("react")),Yn=require("react"),Xn=require("react"),Gn=require("react/jsx-runtime");function Vn(e){let t=null;const n=()=>(t||(t=(0,Xn.createContext)(null)),t),r=Un(e);return[function({children:t,initialState:r}){const o=(0,Xn.useRef)(r),i=(0,Xn.useMemo)(()=>Un(e,o.current),[]),s=n();return(0,Gn.jsx)(s.Provider,{value:i,children:t})},(e,t)=>{const o=n(),i=(0,Xn.useContext)(o)??r,s=(0,Xn.useRef)(e);s.current=e;const a=(0,Xn.useRef)({hasValue:!1,value:void 0}),l=(0,Xn.useCallback)(()=>{const e=s.current(i.getState()),n=a.current;return n.hasValue&&t&&t(n.value,e)?n.value:(a.current={hasValue:!0,value:e},e)},[i,t]),c=(0,Xn.useCallback)(()=>s.current(i.getState()),[i]);return(0,Xn.useSyncExternalStore)(i.subscribe,l,c)}]}function Un(e,t){const n=new Set;let r={...e(function(e){const t=e(r);if(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}(t)){r={...r,...t};for(const e of n)e()}}),...t??{}};return{getState:()=>r,subscribe:function(e){return n.add(e),()=>{n.delete(e)}}}}function Kn(e){if(!e?.colors)return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function Qn(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:Zn}}),e.accessibility.highContrast){const e="dark"===t.mode;t={...t,colors:{...t.colors,text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"}}}return t}var Zn=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],Jn={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},er={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},tr={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:Zn,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function nr(e,t){if("light"===t)return Jn;if("dark"===t)return er;if("high-contrast"===t)return tr;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?er:Jn;return Qn({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return Qn({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[rr,or]=Vn(e=>({theme:Jn,setTheme(t){e(e=>({theme:nr(e.theme,t)}))}})),ir=require("react");var sr=require("react"),ar=new WeakMap,lr=0,cr=!1,ur=null,dr=null;function hr(e,t){if(!t)return t;const n=function(e){const t=e.trim();if(!t.startsWith("var(")||!t.endsWith(")"))return null;const n=t.slice(4,-1),r=n.indexOf(",");if(-1===r){const e=n.trim();return e.startsWith("--")?{name:e}:null}const o=n.slice(0,r).trim(),i=n.slice(r+1).trim();return o.startsWith("--")?{name:o,fallback:i||void 0}:null}(t);if(!n)return t;const r=()=>n.fallback?hr(e,n.fallback):t,o=e.canvas;if(!o)return r();!function(){if(cr)return;if("undefined"==typeof window||"undefined"==typeof document)return;cr=!0;const e=()=>{lr++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"],subtree:!0}),"function"==typeof window.matchMedia)try{ur=window.matchMedia("(prefers-color-scheme: dark)"),dr=e,"function"==typeof ur.addEventListener?ur.addEventListener("change",dr):"function"==typeof ur.addListener&&ur.addListener(dr)}catch{}}();let i=ar.get(o);i&&i.version===lr||(i={version:lr,map:new Map},ar.set(o,i));const s=i.map.get(t);if(void 0!==s)return s;const a=getComputedStyle(o).getPropertyValue(n.name).trim()||r()||t;return i.map.set(t,a),a}var fr="undefined"==typeof window?Yn.useEffect:Yn.useLayoutEffect,gr={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function yr(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function pr(e){const t=function(){const[e,t]=(0,ir.useState)(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return(0,ir.useEffect)(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),function(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}(e,e=>t(e.matches))},[]),e}(),n=(0,Yn.useRef)(t);n.current=t;const[r,o]=function(e,t,n){const r=(0,sr.useRef)(null),[o,i]=(0,sr.useState)(null);return(0,sr.useEffect)(()=>{if(!t&&!n)return;const e=r.current;if(!e)return;const o=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;i(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return o.observe(e),()=>o.disconnect()},[t,n]),[r,[t&&o?o.w:e[0],n&&o?o.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),i=!!e.title,s=!!e.legend&&"top"===e.legendPosition,a=(0,Yn.useMemo)(()=>function(e,t,n=!1){const r=n?t?58:34:t?36:0;return r>e.top?{...e,top:r}:e}({...e.marginDefault,...e.userMargin},i,s),[e.marginDefault,e.userMargin,i,s]),l=o[0]-a.left-a.right,c=o[1]-a.top-a.bottom,u=yr(e.foregroundGraphics,o,a),d=yr(e.backgroundGraphics,o,a),h=or(e=>e.theme),{transition:f,introEnabled:g}=function(e,t){if(!1===e)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:e?!0===e?{duration:300}:{duration:e.duration??300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(n||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),y="semiotic-table-"+qn.useId(),p=(0,Yn.useRef)(null);if(!p.current){const t=!e.suspendWhenHidden||"undefined"==typeof document||!document.hidden;p.current=new Ie({clock:e.clock,random:e.random,seed:e.seed,paused:e.paused,visible:t})}const m=p.current;m.configure({clock:e.clock,random:e.random,seed:e.seed});const v=(0,Yn.useRef)(null),b=(0,Yn.useRef)(e.frameScheduler??gr);b.current=e.frameScheduler??gr;const x=(0,Yn.useRef)(null),k=(0,Yn.useRef)(!1),w=(0,Yn.useRef)(()=>{}),S=(0,Yn.useCallback)(()=>{if(null!==v.current||k.current)return;const e=b.current;let t=!1,n=!1;const r=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&(k.current=!0),v.current=null,x.current=null;try{w.current()}finally{e&&(k.current=!1)}});n=!0,t||(v.current=r,x.current=e)},[]),M=(0,Yn.useCallback)(()=>{null!==v.current&&((x.current??b.current).cancelAnimationFrame(v.current),v.current=null,x.current=null)},[]);fr(()=>{m.setPaused(!0===e.paused)},[m,e.paused]),(0,Yn.useEffect)(()=>{if(!e.suspendWhenHidden||"undefined"==typeof document)return void m.setVisible(!0);const t=()=>m.setVisible(!document.hidden);return t(),document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[m,e.suspendWhenHidden]),(0,Yn.useEffect)(()=>()=>{M()},[M]);const A=(0,Yn.useRef)(()=>{}),C=(0,Yn.useRef)(()=>{}),L=(0,Yn.useRef)(null),j=(0,Yn.useRef)(null),T=(0,Yn.useRef)(null),E=(0,Yn.useCallback)(()=>{const e=L.current;L.current=null,e&&A.current(e)},[]),D=(0,Yn.useCallback)(e=>{if(L.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===j.current){const e=b.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,j.current=null,T.current=null,E()});t||(j.current=n,T.current=e)}},[E]),R=(0,Yn.useCallback)(()=>{L.current=null,null!==j.current&&((T.current??b.current).cancelAnimationFrame(j.current),j.current=null,T.current=null),C.current()},[]);(0,Yn.useEffect)(()=>()=>{L.current=null,null!==j.current&&((T.current??b.current).cancelAnimationFrame(j.current),j.current=null,T.current=null)},[]);const I=e.themeDirtyRef;return fr(()=>{I&&(lr++,I.current=!0,S())},[h,S,I]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:r,size:o,margin:a,adjustedWidth:l,adjustedHeight:c,resolvedForeground:u,resolvedBackground:d,currentTheme:h,transition:f,introEnabled:g,tableId:y,frameRuntime:m,rafRef:v,renderFnRef:w,scheduleRender:S,cancelRender:M,hoverHandlerRef:A,hoverLeaveRef:C,onPointerMove:D,onPointerLeave:R}}var mr=require("react"),vr={fresh:1,aging:.7,stale:.45,expired:.25},br={alpha:1,band:"fresh",isStale:!1};var xr=require("react/jsx-runtime");function kr({isStale:e,position:t}){return(0,xr.jsx)("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===t?{top:4,left:4}:"bottom-left"===t?{bottom:4,left:4}:"bottom-right"===t?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:e?"#dc3545":"#28a745",color:"white"},children:e?"STALE":"LIVE"})}var wr=l(require("react")),Sr=l(require("react")),Mr=require("react/jsx-runtime"),Ar={fill:(e,t)=>(0,Mr.jsx)("rect",{style:e,width:t,height:t}),line:(e,t)=>(0,Mr.jsx)("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function Cr(e,t,n,r,o){let i;return i="function"==typeof n?n(e):(0,Ar[n])(r(e,t),o),i}function Lr({swatchSize:e}){return(0,Mr.jsx)("path",{d:`M${.25*e},${.55*e} L${.45*e},${.75*e} L${.8*e},${.3*e}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function jr(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var Tr=(e,t,n,r,o,i,s,a,l,c,u)=>{const{type:d="fill",styleFn:h,items:f}=e,g=[];let y=0;const p=!(!t&&!n),m="isolate"===c||void 0===c&&null!=o,{swatchSize:v,labelGap:b,rowHeight:x}=u;return f.forEach((e,c)=>{const u=Cr(e,c,d,h,v),k=jr(e,r,o),w=o&&o.size>0&&o.has(e.label);g.push((0,Mr.jsxs)("g",{transform:`translate(0,${y})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:p?a===i&&c===s?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&m?w||!1:void 0,"aria-current":p&&!m&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:p?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+f.length)%f.length;l(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:p?t=>{l(a,c),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:p?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[p&&(0,Mr.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:v+b+2+7*e.label.length,height:v+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,w&&(0,Mr.jsx)(Lr,{swatchSize:v}),(0,Mr.jsx)("text",{y:v/2,x:v+b,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+c)),y+=x}),g};function Er({config:e,orientation:t="vertical",width:n=100}){const{colorFn:r,domain:o,label:i,format:s}=e,a=s||(e=>Math.round(100*e)/100+""),l="grad-legend-"+Sr.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),s=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push((0,Mr.jsx)("stop",{offset:100*t+"%",stopColor:r(o[0]+t*(o[1]-o[0]))},e))}return(0,Mr.jsxs)("g",{"aria-label":i||"Gradient legend",children:[(0,Mr.jsx)("defs",{children:(0,Mr.jsx)("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),i&&(0,Mr.jsx)("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),(0,Mr.jsx)("rect",{x:s,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),(0,Mr.jsx)("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[0])}),(0,Mr.jsx)("text",{x:s+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[1])})]})}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push((0,Mr.jsx)("stop",{offset:100*t+"%",stopColor:r(o[1]-t*(o[1]-o[0]))},e))}return(0,Mr.jsxs)("g",{"aria-label":i||"Gradient legend",children:[i&&(0,Mr.jsx)("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),(0,Mr.jsx)("defs",{children:(0,Mr.jsx)("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),(0,Mr.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),(0,Mr.jsx)("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[1])}),(0,Mr.jsx)("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[0])})]})}function Dr(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,legendInteraction:s,title:a="Legend",width:l=100,height:c=20,orientation:u="vertical",legendLayout:d}=e,h=function(e){const t=Math.max(1,e?.swatchSize??16),n=Math.max(t,e?.rowHeight??22);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??6),itemGap:Math.max(0,e?.itemGap??10),rowHeight:n,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}(d),[f,g]=Sr.useState(0),[y,p]=Sr.useState(0),m=Sr.useCallback((e,t)=>{g(e),p(t)},[]),v="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:l,legendInteraction:c,metrics:u})=>{const d=[],h=function(e,t){let n=24;return e.map(({hasLabel:e,itemCount:r})=>{n+=5;const o=n;let i;n+=8,e&&(n+=16,i=n,n+=8);const s=n;return n+=r*t+8,{lineY:o,labelY:i,itemsY:s,endY:n}})}(e.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),u.rowHeight);return e.forEach((e,f)=>{const g=h[f];d.push((0,Mr.jsx)("line",{stroke:"gray",x1:0,y1:g.lineY,x2:t,y2:g.lineY},"legend-top-line legend-symbol-"+f)),e.label&&null!=g.labelY&&d.push((0,Mr.jsx)("text",{y:g.labelY,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),d.push((0,Mr.jsx)("g",{className:"legend-item",transform:`translate(0,${g.itemsY})`,children:Tr(e,n,r,o,i,s,a,f,l,c,u)},"legend-group-"+f))}),d})({legendGroups:t||[],width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:s,metrics:h}):(({legendGroups:e,height:t,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u,metrics:d})=>{let h=0;const f=[];e.forEach((e,t)=>{let g=0;e.label&&(g+=16);const y=((e,t,n,r,o,i,s,a,l,c,u,d)=>{const{type:h="fill",styleFn:f,items:g}=e,y=[],{swatchSize:p,labelGap:m,itemGap:v,rowHeight:b,align:x}=u,k=!(!t&&!n),w="isolate"===c||void 0===c&&null!=o,S=g.map(e=>p+m+7*e.label.length),M=[];let A=0,C=0;S.forEach((e,t)=>{const n=0===C?e:C+v+e;d&&d>0&&C>0&&n>d?(M.push({start:A,end:t,width:C}),A=t,C=e):C=n}),g.length>0&&M.push({start:A,end:g.length,width:C}),M.forEach((e,c)=>{let u="center"===x?Math.max(0,((d??e.width)-e.width)/2):"end"===x?Math.max(0,(d??e.width)-e.width):0;for(let d=e.start;e.end>d;d++){const e=g[d],x=Cr(e,d,h,f,p),M=jr(e,r,o),A=o&&o.size>0&&o.has(e.label);y.push((0,Mr.jsxs)("g",{transform:`translate(${u},${c*b})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:k?a===i&&d===s?0:-1:void 0,role:k?"option":void 0,"aria-selected":k&&w?A||!1:void 0,"aria-current":k&&!w&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:k?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(d+("ArrowRight"===n.key?1:-1)+g.length)%g.length;l(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:k?t=>{l(a,d),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:k?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:k?"pointer":"default",opacity:M,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[k&&(0,Mr.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:p+m+2+7*e.label.length,height:p+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,A&&(0,Mr.jsx)(Lr,{swatchSize:p}),(0,Mr.jsx)("text",{y:p/2,x:p+m,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+d)),u+=S[d]+v}});const L=Math.max(0,...M.map(e=>e.width)),j=M.length;return{items:y,offset:L,totalRows:j,totalHeight:j*b}})(e,r,o,i,s,a,l,t,c,u,d,d.maxWidth??n);g+=y.offset+5,f.push({label:e.label,...y,offset:g,totalRows:y.totalRows,totalHeight:y.totalHeight}),h+=g+12});const g=d.maxWidth??n;let y=h>g?0:"center"===d.align?Math.max(0,(g-h)/2):"end"===d.align?Math.max(0,g-h):0;const p=[];return f.forEach((n,r)=>{const o=e[r];o.label&&(p.push((0,Mr.jsx)("text",{transform:`translate(${y},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:o.label},"legend-text-"+r)),y+=16),p.push((0,Mr.jsx)("g",{className:"legend-item",transform:`translate(${y},0)`,children:n.items},"legend-group-"+r)),y+=n.offset+5,e[r+1]&&p.push((0,Mr.jsx)("line",{stroke:"gray",x1:y,y1:-8,x2:y,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+r)),y+=12}),(0,Mr.jsx)("g",{children:p})})({legendGroups:t||[],title:a,height:c,width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:s,metrics:h}),b=!(!n&&!r);return(0,Mr.jsxs)("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"isolate"!==s&&(void 0!==s||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===u&&(0,Mr.jsx)("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),v]})}function Rr(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}var Ir=require("react/jsx-runtime");function Nr(e){const{legend:t,totalWidth:n,totalHeight:r,margin:o,legendPosition:i="right",legendLayout:s,title:a,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=e;if(!t)return null;const f="top"===i||"bottom"===i,g=!!a,y=Math.max(0,n-o.left-o.right),p=Math.max(1,f?s?.maxWidth??y:100);let m,v;return"left"===i?(m=Math.max(4,o.left-p-10),v=o.top):"top"===i?(m=o.left,v=g?32:8):"bottom"===i?(m=o.left,v=r-o.bottom+38):(m=n-o.right+10,v=o.top),(0,Ir.jsx)("g",{transform:`translate(${m}, ${v})`,children:(b=t,"object"==typeof b&&null!==b&&"gradient"in b?(0,Ir.jsx)(Er,{config:t.gradient,orientation:f?"horizontal":"vertical",width:p}):Rr(t)?(0,Ir.jsx)(Dr,{legendGroups:t.legendGroups,title:"",width:p,orientation:f?"horizontal":"vertical",legendLayout:s,customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):t)});var b}var Pr=require("react/jsx-runtime"),_r={secondary:0,primary:3},Wr=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}";function $r(e){return!0===e?._annotationDeferred}function Or(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function Br(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function zr(e){return Math.max(.72,.95-.06*e)}var Hr=l(require("react")),Fr=require("react/jsx-runtime");function qr(e,t=120,n=8){if(!e)return[];const r=Math.max(1,Math.floor(t/n)),o=e.split(/\s+/),i=[];let s="";for(const e of o)s&&s.length+1+e.length>r?(i.push(s),s=e):s=s?`${s} ${e}`:e;return s&&i.push(s),i}function Yr(e,t,n,r){return"curly"===e?r?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:r?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function Xr(e,t,n,r){if(!e)return(0,Fr.jsx)("g",{className:"annotation-note"});const{label:o,title:i,orientation:s,align:a,wrap:l=120,noWrap:c}=e;if(!o&&!i)return(0,Fr.jsx)("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=a;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const f=16,g=i?c?[i]:qr(i,l):[],y=o?c?[o]:qr(o,l):[],p="leftRight"===u?"end"===h?-4:4:0;let m=0;const v=[],b=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?v.push((0,Fr.jsx)("foreignObject",{className:"annotation-note-html",x:"end"===h?p-l:"middle"===h?p-l/2:p,y:-16,width:l,height:Math.max(f,(g.length+y.length)*f+(i&&o?2:0))+f,style:{overflow:"visible"},children:(0,Fr.jsxs)("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:b,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===h?"right":"middle"===h?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[i&&(0,Fr.jsx)("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),o&&(0,Fr.jsx)("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html")):(g.length>0&&(v.push((0,Fr.jsx)("text",{className:"annotation-note-title",fill:b,textAnchor:h,fontWeight:"bold",children:g.map((e,t)=>(0,Fr.jsx)("tspan",{x:p,dy:0===t?0:f,children:e},t))},"annotation-note-title")),m=g.length*f),y.length>0&&v.push((0,Fr.jsx)("text",{className:"annotation-note-label",fill:b,textAnchor:h,y:m,children:y.map((e,t)=>(0,Fr.jsx)("tspan",{x:p,dy:0===t?0:f,children:e},t))},"annotation-note-label")));let x=null;if((i||o)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(l,120);let t=0,n=e;"end"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),x=(0,Fr.jsx)("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(g.length+y.length)*f+(y.length>0?f:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),x=(0,Fr.jsx)("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const k=Math.max(0,g.length+y.length-1)*f;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===d?-(k+f+(y.length>0&&g.length>0?2:0))/2+8:"bottom"===d||0>n?-(k+2):18),(0,Fr.jsxs)("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[(0,Fr.jsx)("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0,children:v}),x]})}function Gr(e,t,n,r,o){const i=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&i.push((0,Fr.jsx)("circle",{r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,r=t?.height||0;(e>0||r>0)&&i.push((0,Fr.jsx)("rect",{width:e,height:r,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":t?.custom&&i.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=r||0,s=o||0;if(void 0!==t?.x){const r=(t.x||0)-e;i.push((0,Fr.jsx)("line",{x1:r,y1:(t.y1||0)-s,x2:r,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const r=(t.y||0)-s;i.push((0,Fr.jsx)("line",{x1:(t.x1||0)-e,y1:r,x2:(t.x2||0)-e,y2:r,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?i.push((0,Fr.jsx)("line",{x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===t?.y1&&void 0===t?.y2||i.push((0,Fr.jsx)("line",{x1:0,y1:(t.y1||0)-s,x2:0,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=t?.type||"curly",r=t?.width??t?.height;void 0!==r&&i.push((0,Fr.jsx)("path",{d:Yr(e,r,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return(0,Fr.jsx)("g",{className:"annotation-subject",children:i})}function Vr(e,t,n,r,o,i){const s=[];let a=0,l=0;if("callout-circle"!==o&&"label"!==o||!i?.radius){if("callout-rect"===o&&i){const n=i.width||0,r=i.height||0;if(n>0||r>0){const o=n/2,i=r/2,s=e-o,c=t-i;if(0!==s||0!==c){const e=Math.abs(s),t=Math.abs(c),u=n/2,d=r/2,h=e*d>t*u?u/e:d/t;a=o+s*h,l=i+c*h}}}else if("bracket"===o&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(a=e/2,l=n):void 0!==t&&(a=n,l=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const r=Math.atan2(t,e);a=Math.cos(r)*n,l=Math.sin(r)*n}}const c=Math.sqrt((e-a)**2+(t-l)**2);if(c>.5){const o=r||"var(--semiotic-text-secondary, currentColor)",i="curve"===n?.type;let u=Math.atan2(t-l,e-a);if(i){const r=(a+e)/2,i=(l+t)/2,d=-(t-l)/c,h=(e-a)/c,f=(n?.curve??.25)*c,g=r+d*f,y=i+h*f;s.push((0,Fr.jsx)("path",{className:"connector-curve",d:`M${a},${l}Q${g},${y} ${e},${t}`,fill:"none",stroke:o},"connector-line")),u=Math.atan2(y-l,g-a)}else s.push((0,Fr.jsx)("line",{x1:a,y1:l,x2:e,y2:t,stroke:o},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;s.push((0,Fr.jsx)("path",{d:`M${a},${l}L${a+e*Math.cos(u+t)},${l+e*Math.sin(u+t)}L${a+e*Math.cos(u-t)},${l+e*Math.sin(u-t)}Z`,fill:o,stroke:"none"},"connector-arrow"))}}return(0,Fr.jsx)("g",{className:"annotation-connector",children:s})}function Ur(e){const{x:t=0,y:n=0,dx:r,dy:o,nx:i,ny:s,note:a,connector:l,subject:c,type:u,color:d,className:h,disable:f,opacity:g,strokeDasharray:y,events:p={},"data-testid":m}=e,v=Array.isArray(t)?t[0]??0:t,b=Array.isArray(n)?n[0]??0:n,x=new Set(Array.isArray(f)?f:[]);let k=r||0,w=o||0;null!=i&&(k=i-v),null!=s&&(w=s-b);const S="string"==typeof u?u:"label";if("bracket"===S&&c&&0===k&&0===w)if(void 0!==c.width){k=c.width/2;const e=c.depth||30;w=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;k=e+(0>e?-5:5),w=c.height/2}return(0,Fr.jsxs)("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${v},${b})`,"data-testid":m,...null!=g&&{opacity:g},...y&&{strokeDasharray:y},...p,children:[!x.has("connector")&&Vr(k,w,l,d,S,c),!x.has("subject")&&Gr(S,c,d,v,b),!x.has("note")&&Xr(a,k,w,d)]})}function Kr(e){const{noteData:t}=e,{screenCoordinates:n}=t,r="string"==typeof t.type?t.type:"label",o=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),o=t.ny||n[0][1]+(t.dy??0),i=n.map((n,i)=>{const s=Object.assign({},t,{note:0===i?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:o});return(0,Fr.jsx)(Ur,{"data-testid":"semiotic-annotation",...s,type:r},"multi-annotation-"+i)});return(0,Fr.jsx)("g",{children:i})}const i=t.note||{title:"none",label:t.label},s=`${i.label}-${i.title}-${t.i}`;return(0,Fr.jsx)(Ur,{"data-testid":"semiotic-annotation",events:o,...t,type:r},s)}var Qr=require("d3-hierarchy"),Zr=require("d3-shape");function Jr(e){return Math.round(100*e)/100}function eo(e,t=2){const n=[],r=[],o=t+1;for(let t=0;o>t;t++){let i=0;for(const[n,r]of e)null!==r&&(i+=n**t*r);n.push(i);const s=[];for(let n=0;o>n;n++){let r=0;for(const[o,i]of e)null!==i&&(r+=o**(t+n));s.push(r)}r.push(s)}r.push(n);const i=function(e,t){const n=e,r=e.length-1,o=[t];for(let e=0;r>e;e++){let t=e;for(let o=e+1;r>o;o++)Math.abs(n[e][o])>Math.abs(n[e][t])&&(t=o);for(let o=e;r+1>o;o++){const r=n[o][e];n[o][e]=n[o][t],n[o][t]=r}for(let t=e+1;r>t;t++)for(let o=r;o>=e;o--)n[o][t]-=n[o][e]*n[e][t]/n[e][e]}for(let e=r-1;e>=0;e--){let t=0;for(let i=e+1;r>i;i++)t+=n[i][e]*o[i];o[e]=(n[r][e]-t)/n[e][e]}return o}(r,o).map(Jr);return{points:e.map(([e])=>[Jr(e),Jr(i.reduce((t,n,r)=>t+n*e**r,0))]),equation:[...i].reverse()}}function to(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function no(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function ro(e){return null==e?null:e+""}function oo(e,t,n){return t.stickyPositionCache?.set(e,n),n}function io(e,t,n){const r=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===r){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const o=n.pointNodes[r];if(o.pointId===e.pointId)return oo(t,n,{x:o.x,y:o.y})}const r=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],r=e.scales?.x??e.scales?.time,o=e.scales?.y??e.scales?.value;if(!r||!o)return null;const i=n[e.xAccessor||"x"],s=n[e.yAccessor||"y"];return null==i||null==s?null:{x:r(i),y:o(s)}}(n);return r?oo(t,n,r):null}if("semantic"===r){const r=function(e,t,n){const r=function(e){return ro(e.provenance?.stableId??e.stableId)}(e);if(!r)return null;const o=n.pointNodes?.find(e=>ro(e.pointId)===r);if(o)return oo(t,n,{x:o.x,y:o.y});const i=n.data?.find(e=>function(e){return ro(e.stableId??e.id??e.provenance?.stableId)}(e)===r);if(!i)return null;const s=to(i,n),a=no(i,n);return null==s||null==a?null:oo(t,n,{x:s,y:a})}(e,t,n);if(r)return r}let o=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(o=t.x,i=t.y)}if(null!=o&&null!=i||(o=to(e,n),i=no(e,n)),null!=o&&null!=i)return oo(t,n,{x:o,y:i});if("sticky"===r){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function so(e,t,n,r=50){return!(-r>e||e>(n.width||0)+r||-r>t||t>(n.height||0)+r)}var ao=l(require("react")),[lo,co]=Vn(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function uo(e,t={}){const n=function(e){const t=e.provenance,n=e.id??e.stableId??t?.stableId;return null==n||""===n?void 0:n+""}(e);return{"data-semiotic-annotation-widget":"",...n?{"data-semiotic-annotation-id":n}:{},onClickCapture(r){const o=function(e){const t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}(r);t.onAnnotationActivate?.({annotation:e,annotationId:n,chartId:t.chartId,inputType:o}),n&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:n,inputType:o,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}var ho=require("react/jsx-runtime"),fo="var(--semiotic-bg, #ffffff)";function go(e){const{x:t,y:n,text:r,fill:o,fontSize:i=12,fontWeight:s,fontFamily:a,textAnchor:l="start",dominantBaseline:c,background:u,className:d}=e,h=function(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{type:e.type??"halo",...e}}(u),f=e=>(0,ho.jsx)("text",{x:t,y:n,textAnchor:l,dominantBaseline:c,fill:o,fontSize:i,fontWeight:s,fontFamily:a,className:d,...e?{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}:{},children:r});if(!h)return f();if("halo"===h.type)return f({stroke:h.fill??fo,strokeWidth:h.haloWidth??3});const g=h.padding??{x:6,y:3},y="number"==typeof g?g:g.x,p="number"==typeof g?g:g.y,m=function(e,t){return(e+"").length*t*.6}(r,i),v=i+2*p;let b,x;return b="middle"===l?t-m/2-y:"end"===l?t-m-y:t-y,x="middle"===c||"central"===c?n-v/2:"hanging"===c||"text-before-edge"===c?n-p:n-.8*i-p,(0,ho.jsxs)("g",{className:d,children:[(0,ho.jsx)("rect",{x:b,y:x,width:m+2*y,height:v,rx:h.radius??3,ry:h.radius??3,fill:h.fill??fo,fillOpacity:h.opacity??.85,stroke:h.stroke,strokeWidth:h.strokeWidth}),f()]})}function yo(e){return{type:"hatch",background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle}}var po=null;var mo=require("react/jsx-runtime");function vo(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function bo(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}function xo(e,t){let n=2166136261;const r=bo(t);for(let e=0;r.length>e;e++)n^=r.charCodeAt(e),n=Math.imul(n,16777619);return`${e}-hatch-${(n>>>0).toString(36)}`}var ko=new Map;function wo(e,t){const{background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:s=45,lineOpacity:a=1}=e,l=Math.max(8,Math.ceil(2*i));return(0,mo.jsxs)("pattern",{id:t,width:l,height:l,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[n&&"transparent"!==n&&(0,mo.jsx)("rect",{width:l,height:l,fill:n}),(0,mo.jsx)("line",{x1:0,y1:0,x2:0,y2:l,stroke:r,strokeWidth:o,strokeOpacity:a}),(0,mo.jsx)("line",{x1:i,y1:0,x2:i,y2:l,stroke:r,strokeWidth:o,strokeOpacity:a})]},t)}function So(e,t,n="#4e79a7"){if(vo(e)){const n=xo(t,e);return{fill:`url(#${n})`,def:wo(e,n)}}return e&&"string"==typeof e?{fill:e}:{fill:n}}var Mo=require("react/jsx-runtime"),Ao={linear:Zr.curveLinear,monotoneX:Zr.curveMonotoneX,monotoneY:Zr.curveMonotoneY,step:Zr.curveStep,stepAfter:Zr.curveStepAfter,stepBefore:Zr.curveStepBefore,basis:Zr.curveBasis,cardinal:Zr.curveCardinal,catmullRom:Zr.curveCatmullRom};var Co=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function Lo(e){return!!e&&"object"==typeof e&&Co.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}function jo(e){return"primary"===e?.emphasis||!0===e?.defensive}function To(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function Eo(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const r=e?.provenance?.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(t+=15*Math.max(0,Math.min(1,r))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}new Set(["label","callout","callout-circle","callout-rect"]);var Do=32,Ro=6,Io=4,No=8,Po=72;var _o={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function Wo(e){if(!$o(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function $o(e){return Lo(e)}function Oo(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),r=e.split(/\s+/).filter(Boolean),o=[];let i="";for(const e of r)i&&i.length+e.length+1>n?(o.push(i),i=e):i=i?`${i} ${e}`:e;return i&&o.push(i),o}function Bo(e,t,n,r,o){const i=e+n,s=t+r;return Math.abs(n)>Math.abs(r)?{x:0>n?i-o.width-4:i+4,y:0>r?s-o.height:s,width:o.width,height:o.height}:{x:0>n?i-o.width:i,y:0>r?s-o.height-4:s+4,width:o.width,height:o.height}}function zo(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Ho(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function Fo(e,t,n,r,o,i,s,a){const l=zo(e,s);let c=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,r){const o=Math.max(0,r-e.x),i=Math.max(0,r-e.y);return(o+Math.max(0,e.x+e.width-(t-r)))*e.height+(i+Math.max(0,e.y+e.height-(n-r)))*e.width}(l,o,i,a);for(const e of n)c+=12*Ho(l,e);for(const e of r)c+=4*Ho(l,e);return c}function qo(e){const{annotations:t,context:n,defaultOffset:r=Do,notePadding:o=Ro,markPadding:i=Io,edgePadding:s=No,preserveManualOffsets:a=!0,routeLongConnectors:l=!0,connectorThreshold:c=Po,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:g,cohesion:y,audience:p}=e,m=n.width||0,v=n.height||0,b="object"==typeof g?g:{},x=b.breakpoint??480,k=!!g&&x>=m,w=k&&!1!==b.preferShortText?t.map(Wo):t,S=k&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,M=d||k&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),A=k&&!f?b.responsive??{minWidth:x}:f,C=k&&!y?b.cohesion:y;if(0===w.length||0>=m||0>=v)return w.slice();const L=[],j=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(n,i);let T=!1;const E=w.map((e,t)=>{if(!$o(e))return e;const i=function(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const r=e.pointId??e.nodeId;if(null!=r&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===r);if(e)return{x:e.x,y:e.y}}const o=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(o)&&o.length>=2&&i){const e=o[0],t=o[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?io(e,t,n):{x:e.x,y:e.y}}(e,t,n);if(!i)return e;const u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,n=[...Oo("string"==typeof e.title?e.title:void 0,t),...Oo("string"==typeof e.label?e.label:void 0,t)],r=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*r)+10),height:Math.max(18,16*n.length+6)}}(e);if(a&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}(e);return L.push(zo(Bo(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),o)),e}var d;let h=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(r)){const t=Fo(Bo(i.x,i.y,e.dx,e.dy,u),e,L,j,m,v,o,s);f>t&&(h=e,f=t)}if(!h)return e;const g=zo(Bo(i.x,i.y,h.dx,h.dy,u),o);L.push(g);const y=Math.hypot(h.dx,h.dy),p=l&&y>=c&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return T=!0,{...e,dx:h.dx,dy:h.dy,...p?{connector:p}:{}}}),D=T?E:w.slice();let R=D;if(h){let e=!1;const t=D.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||8>Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});R=e?t:D}{let e=!1;const t=R.map(t=>{if(!0!==t?.defensive)return t;const n=function(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?_o[t.source]??t.source:null,r="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!r)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const o=[n,r].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${o})`)?e:{...e,label:i?`${i} (${o})`:`(${o})`}}(t);return n!==t&&(e=!0),n});R=e?t:R}const I=new Set;if(S){const e="object"==typeof S?S:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return 3;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?3:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(p),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??To(m,v,e))*t))},{deferred:r}=function(e){const{annotations:t,width:n,height:r}=e,o=Math.max(0,e.minVisible??1),i=To(n,r,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,Lo(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||i>=a.length)return{visible:t.slice(),deferred:[],budget:i};const l=a.filter(e=>jo(e.annotation)),c=a.filter(e=>!jo(e.annotation)).sort((e,t)=>Eo(t.annotation)-Eo(e.annotation)||e.index-t.index),u=Math.min(c.length,Math.max(Math.max(0,i-l.length),Math.max(0,o-l.length))),d=new Set([...l.map(e=>e.index),...c.slice(0,u).map(e=>e.index)]),h=[],f=[];for(const{annotation:e,index:t,note:n}of s)!n||d.has(t)?h.push(e):f.push(e);return{visible:h,deferred:f,budget:i}}({annotations:R,width:m,height:v,...n});for(const e of r)I.add(e)}if(A&&("object"==typeof A&&"number"==typeof A.minWidth?A.minWidth:480)>=m)for(const e of R)$o(e)&&"secondary"===e.emphasis&&I.add(e);if(I.size>0)for(const e of R)!0===e?.defensive&&I.delete(e);let N;return N=0===I.size?R:M?R.map(e=>I.has(e)?{...e,_annotationDeferred:!0}:e):R.filter(e=>!I.has(e)),C?function(e,t){let n=!1;const r=e.map(e=>$o(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?r:e}(N,C):N}var Yo=require("d3-shape"),Xo={circle:Yo.symbolCircle,square:Yo.symbolSquare,triangle:Yo.symbolTriangle,diamond:Yo.symbolDiamond,star:Yo.symbolStar,cross:Yo.symbolCross,wye:Yo.symbolWye};function Go(e,t,n){if(n)return n;const r=e??"circle";return"chevron"===r?function(e){const t=1.5*Vo(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t):(0,Yo.symbol)(Xo[r]??Yo.symbolCircle,Math.max(1,t))()??""}function Vo(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var Uo=require("react/jsx-runtime");function Ko(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,labels:s,title:a,legend:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:f="right",legendLayout:g,foregroundGraphics:y,sceneNodes:p,annotations:m,onAnnotationActivate:v,onObservation:b,chartId:x,chartType:k,autoPlaceAnnotations:w,svgAnnotationRules:S}=e,M=function(e){const t=co(e=>e.pushObservation),n=ao.useCallback(n=>{e.onObservation?.(n),t?.(n)},[e,t]);return ao.useMemo(()=>({...e,onObservation:n}),[n,e])}({onAnnotationActivate:v,onObservation:b,chartId:x,chartType:k}),A=wr.useMemo(()=>{const e=(p||[]).flatMap(e=>{const t=function(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){const t=e.cx??e.x,n=e.cy??e.y;if("number"!=typeof t||"number"!=typeof n)return null;const r=kn(e.glyph,e.size);return{x:t+r.centerDx,y:n+r.centerDy,r:Math.max(1,r.radius)}}const t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),n=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof n?null:{x:t,y:n,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,Vo(e.size)):Math.max(1,e.w??0,e.h??0)/2}}(e),n=function(e){const t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}(e);return t?[{pointId:n,...t}]:[]});return{scales:null,width:t,height:n,frameType:"network",pointNodes:e,sceneNodes:p}},[n,p,t]),C=wr.useMemo(()=>{if(!m)return m;const e=function(e,t={}){const n=!0===t.showRetractedAnnotations,r=!0===t.showSupersededAnnotations,o=new Set;for(const t of e){const e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&o.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!n)return!1;const t=e?.provenance?.stableId;return!(t&&o.has(t)&&!r)})}(m);return w?qo({annotations:e,context:A,..."object"==typeof w?w:{}}):e},[m,w,A]),L=wr.useMemo(()=>function(e,t={}){return function(e,n,r){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const t=io(e,n,r);if(!t)return null;const{x:o,y:i}=t;if(!so(o,i,r))return null;const s="callout"===e.type?"callout-circle":e.type,a="callout-circle"===s?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===s?{width:e.width,height:e.height}:void 0;return(0,Mo.jsx)(Kr,{noteData:{x:o,y:i,dx:e.dx??30,dy:e.dy??-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:s,...a?{subject:a}:{},connector:e.connector||{end:"arrow"},color:e.color,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-"+n)}case"x-threshold":{const t=to(null!=e.value?{...e,x:e.value}:e,r);if(null==t)return null;const o=e.color||"#f97316",i=e.labelPosition||"top";let s;s="bottom"===i?(r.height||0)-4:"center"===i?(r.height||0)/2:16;const a=t>.6*(r.width||0),l=a?t-4:t+4,c=a?"end":"start";return(0,Mo.jsxs)("g",{opacity:e.opacity,children:[(0,Mo.jsx)("line",{x1:t,y1:0,x2:t,y2:r.height||0,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Mo.jsx)(go,{x:l,y:s,text:e.label,textAnchor:c,fill:o,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"y-threshold":{const t=no(null!=e.value?{...e,y:e.value}:e,r);if(null==t)return null;const o=e.color||"#f97316",i=e.labelPosition||"right";let a,l;"left"===i?(a=4,l="start"):"center"===i?(a=(r.width||0)/2,l="middle"):(a=(r.width||0)-4,l="end");const c=20>(s=t)?Math.min((r.height||0)-4,s+16):s-4;return(0,Mo.jsxs)("g",{opacity:e.opacity,children:[(0,Mo.jsx)("line",{x1:0,y1:t,x2:r.width||0,y2:t,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Mo.jsx)(go,{x:a,y:c,text:e.label,textAnchor:l,fill:o,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"enclose":{const t=(e.coordinates||[]).map(e=>({x:to({...e,type:"point"},r),y:no({...e,type:"point"},r),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const o=(0,Qr.packEnclose)(t),i=e.padding||10;return(0,Mo.jsxs)("g",{children:[(0,Mo.jsx)("circle",{cx:o.x,cy:o.y,r:o.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,Mo.jsx)(go,{x:o.x,y:o.y-o.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"rect-enclose":{const t=(e.coordinates||[]).map(e=>({x:to({...e,type:"point"},r),y:no({...e,type:"point"},r)})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const o=e.padding||10,i=t.map(e=>e.x),s=t.map(e=>e.y),[a,l]=Te(i),[c,u]=Te(s),d=a-o,h=l+o,f=c-o;return(0,Mo.jsxs)("g",{children:[(0,Mo.jsx)("rect",{x:d,y:f,width:h-d,height:u+o-f,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,Mo.jsx)(go,{x:(d+h)/2,y:f-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"highlight":{const t=r.data||[],o="function"==typeof e.filter?t.filter(e.filter):e.field&&null!=e.value?t.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return(0,Mo.jsx)("g",{children:o.map((t,n)=>{const o=to(t,r),s=no(t,r);if(null==o||null==s)return null;const a="function"==typeof e.r?e.r(t):e.r||6,l="function"==typeof e.style?e.style(t):e.style||i;return(0,Mo.jsx)("circle",{cx:o,cy:s,r:a,...l},"hl-"+n)})},"ann-"+n)}case"bracket":{const t=to(e,r),o=no(e,r);return(0,Mo.jsx)(Kr,{noteData:{x:t??0,y:o??0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+n)}case"trend":{const t=r.data||[];if(2>t.length)return null;const o=r.xAccessor||"x",i=r.yAccessor||"y",s="ordinal"===r.frameType,a="horizontal"===r.projection,l=s?o:null,c=s?i:null;let u;const d=[],h=new Map;if(s&&l&&c){for(const e of t){const t=e[l];if(null==t)continue;const n=t+"";h.has(n)||(h.set(n,d.length),d.push(n))}u=t.map(e=>{const t=e[l],n=e[c];if(null==t||null==n)return null;const r=h.get(t+"");return null!=r?[r,+n]:null}).filter(e=>null!==e)}else u=t.map(e=>[e[o],e[i]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const f=r.scales?.x??r.scales?.time,g=r.scales?.y??r.scales?.value;if(!f||!g)return null;const y=e=>t=>{const n=Math.max(0,Math.floor(t)),r=Math.min(d.length-1,n+1),o=t-n,i=e(d[n]);return i+(e(d[r])-i)*o},p=f,m=g;let v;if(s)if(a){const e=y(m);v=(t,n)=>[p(n),e(t)]}else{const e=y(p);v=(t,n)=>[e(t),m(n)]}else v=(e,t)=>[p(e),m(t)];const b=e.method||"linear";let x;if("loess"===b)x=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const r=e.slice().sort((e,t)=>e[0]-t[0]),o=r.map(e=>e[0]),i=r.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=o[e],r=o.map(e=>Math.abs(e-t)),l=r.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:r[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,f=0,g=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*o[e],h+=t*i[e],f+=t*o[e]*o[e],g+=t*o[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const y=u*f-d*d;if(1e-12>Math.abs(y))a.push([t,h/u]);else{const e=(u*g-d*h)/y;a.push([t,(h-e*d)/u+e*t])}}return a}(u,e.bandwidth??.3);else{const t="polynomial"===b?eo(u,e.order||2):function(e){const t=[0,0,0,0];let n=0;for(const[r,o]of e)null!==o&&(n++,t[0]+=r,t[1]+=o,t[2]+=r*r,t[3]+=r*o);const r=n*t[2]-t[0]*t[0],o=0===r?0:Jr((n*t[3]-t[0]*t[1])/r),i=Jr(t[1]/n-o*t[0]/n);return{points:e.map(([e])=>[Jr(e),Jr(o*e+i)]),equation:[o,i]}}(u);x=t.points}const k=x.map(([e,t])=>{const[n,r]=v(e,t);return`${n},${r}`}).join(" "),w=e.color||"#6366f1",S=x[x.length-1],[M,A]=v(S[0],S[1]);return(0,Mo.jsxs)("g",{children:[(0,Mo.jsx)("polyline",{points:k,fill:"none",stroke:w,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Mo.jsx)("text",{x:M+4,y:A-4,fill:w,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const t=r.scales?.y??r.scales?.value,s=t?.domain?.(),a=e.y0??s?.[0],l=e.y1??s?.[1],c=null!=a&&t?t(a):0,u=null!=l&&t?t(l):r.height||0,d=So(e.fill,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,Mo.jsxs)("g",{opacity:e.opacity,children:[d.def&&(0,Mo.jsx)("defs",{children:d.def}),(0,Mo.jsx)("rect",{x:0,y:Math.min(c,u),width:r.width||0,height:Math.abs(u-c),fill:d.fill,fillOpacity:e.fillOpacity||.1}),e.label&&(0,Mo.jsx)(go,{x:(r.width||0)-4,y:(o=c,i=u,Math.max(Math.min(o,i),0)+16),textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"x-band":{const t=r.scales?.x??r.scales?.time,o=t?.domain?.(),i=e.x0??o?.[0],s=e.x1??o?.[1],a=null!=i&&t?t(i):null,l=null!=s&&t?t(s):null;if(null==a||null==l)return null;const c=So(e.fill||e.color,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,Mo.jsxs)("g",{opacity:e.opacity,children:[c.def&&(0,Mo.jsx)("defs",{children:c.def}),(0,Mo.jsx)("rect",{x:Math.min(a,l),y:0,width:Math.abs(l-a),height:r.height||0,fill:c.fill,fillOpacity:e.fillOpacity??.1}),e.label&&(0,Mo.jsx)(go,{x:Math.min(a,l)+4,y:16,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"envelope":{const t=r.data||[];if(2>t.length)return null;const o=r.xAccessor||"x",i=r.scales?.x??r.scales?.time,s=r.scales?.y??r.scales?.value;if(!i||!s)return null;const a=e.upperAccessor||"upperBounds",l=e.lowerAccessor||"lowerBounds",c=e.filter,u=t.filter(e=>null!=e[a]&&null!=e[l]&&!(c&&!c(e))).sort((e,t)=>e[o]-t[o]);if(2>u.length)return null;const d=Ao[r.curve||"linear"]||Zr.curveLinear,h=(0,Zr.area)().x(e=>i(e[o])).y0(e=>s(e[l])).y1(e=>s(e[a])).curve(d)(u);if(!h)return null;const f=e.fill||"#6366f1";return(0,Mo.jsxs)("g",{children:[(0,Mo.jsx)("path",{d:h,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&(0,Mo.jsx)("text",{x:i(u[u.length-1][o])+4,y:s(u[u.length-1][a])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const t=r.data||[];if(2>t.length)return null;const o=r.yAccessor||"y",i=r.scales?.x??r.scales?.time,s=r.scales?.y??r.scales?.value;if(!i||!s)return null;const a=t.map(e=>e[o]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const l=a.reduce((e,t)=>e+t,0)/a.length,c=a.reduce((e,t)=>e+(t-l)**2,0)/a.length,u=Math.sqrt(c),d=e.threshold??2,h=l-d*u,f=!1!==e.showBand,g=e.fill||"#6366f1",y=e.fillOpacity??.1,p=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,v=s(l+d*u),b=s(h),x=t.filter(e=>{const t=e[o];return null!=t&&Math.abs(t-l)>d*u});return(0,Mo.jsxs)("g",{children:[f&&(0,Mo.jsx)("rect",{x:0,y:Math.min(v,b),width:r.width||0,height:Math.abs(b-v),fill:g,fillOpacity:y}),x.map((e,t)=>{const n=to(e,r),o=no(e,r);return null==n||null==o?null:(0,Mo.jsx)("circle",{cx:n,cy:o,r:m,fill:p,fillOpacity:.7,stroke:p,strokeWidth:1.5},"anomaly-"+t)}),e.label&&(0,Mo.jsx)("text",{x:(r.width||0)-4,y:Math.min(v,b)-4,textAnchor:"end",fill:g,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const t=r.data||[];if(3>t.length)return null;const o=r.xAccessor||"x",i=r.yAccessor||"y",s=r.scales?.x??r.scales?.time,a=r.scales?.y??r.scales?.value;if(!s||!a)return null;const l=t.map(e=>[e[o],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>l.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=eo(l,e.order||2).equation;c=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}else{const e=l.length;let t=0,n=0,r=0,o=0;for(const[e,i]of l)t+=e,n+=i,r+=e*e,o+=e*i;const i=e*r-t*t;if(1e-12>Math.abs(i))return null;const s=(e*o-t*n)/i,a=(n-s*t)/e;c=e=>a+s*e}const u=l.length,d=l.map(([e,t])=>t-c(e)),h=d.reduce((e,t)=>e+t*t,0),f=Math.sqrt(h/Math.max(u-2,1)),g=l.reduce((e,t)=>e+t[0],0)/u,y=l.reduce((e,t)=>e+(t[0]-g)**2,0),p=e.confidence??.95,m=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,v=e.steps??5,b=l[u-1][0],x=(b-l[0][0])/Math.max(u-1,1),k=[];for(let e=1;v>=e;e++)k.push(b+e*x);const w=[];for(const e of k){const t=c(e),n=f*Math.sqrt(1+1/u+(y>0?(e-g)**2/y:0))*m;w.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const S=`M${w.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,M=w.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),A=`${s(b)},${a(c(b))}`,C=e.strokeColor||"#6366f1";return(0,Mo.jsxs)("g",{children:[(0,Mo.jsx)("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),(0,Mo.jsx)("polyline",{points:`${A} ${M}`,fill:"none",stroke:C,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&w.length>0&&(0,Mo.jsx)("text",{x:s(w[w.length-1].x)+4,y:a(w[w.length-1].yCenter)-4,fill:C,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let o,i;if(null!=e.px&&null!=e.py)o=e.px,i=e.py;else{const t=io(e,n,r);if(!t)return null;o=t.x,i=t.y}if(!so(o,i,r))return null;const s=e.dx??0,a=e.dy??0,l=e.width??32,c=e.height??32,u=e.content??(0,Mo.jsx)("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return(0,Mo.jsx)("foreignObject",{x:o+s-l/2,y:i+a-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:(0,Mo.jsx)("div",{...uo(e,t),style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const t=io(e,n,r);if(!t)return null;const{x:o,y:i}=t,s=o+(e.dx||0),a=i+(e.dy||0),l=e.color||"var(--semiotic-text, #333)",c=(0,Mo.jsx)("text",{x:s,y:a,fill:l,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?Hr.cloneElement(c,{key:"ann-text-"+n}):(0,Mo.jsxs)("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[(0,Mo.jsx)("line",{x1:o,y1:i,x2:s,y2:a,stroke:l,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),Hr.cloneElement(c,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+n)}case"category-highlight":{const t=e.category;if(null==t)return null;const o=e=>"function"==typeof e&&"function"==typeof e.bandwidth,i=r.scales?.o,s=r.scales?.x,a=r.scales?.y,l=o(i)?i:o(s)?s:o(a)?a:null;if(!l)return null;const c=l(t+"");if(null==c)return null;const u=l.bandwidth(),d=e.color||"var(--semiotic-primary, #4589ff)",h=e.opacity??.15,f=e.label;return(0,Mo.jsxs)("g",(r.projection?"vertical"===r.projection:l===s)?{children:[(0,Mo.jsx)("rect",{x:c,y:0,width:u,height:r.height||0,fill:d,fillOpacity:h}),f&&(0,Mo.jsx)(go,{x:c+u/2,y:16,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]}:{children:[(0,Mo.jsx)("rect",{x:0,y:c,width:r.width||0,height:u,fill:d,fillOpacity:h}),f&&(0,Mo.jsx)(go,{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]},"ann-"+n)}default:return null}var o,i,s}}(),[]),j=C?function(e,t,n,r){const o=[];return e.forEach((e,i)=>{let s;if(n){const o=n(e,i,r);s=null!=o?o:t(e,i,r)}else s=t(e,i,r);s&&o.push({node:s,annotation:e})}),function(e){const t=e.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:Br(e.annotation),readingOrder:null,rank:1};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>$r(e.annotation)),o=e.some(e=>null!=Or(e.annotation)),i=e.some(e=>"layer"===Or(e.annotation));if(!n&&!r&&!o)return e.map(e=>e.node);const s=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);s.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,s.length)});for(const e of t)e.emphasis&&(e.rank=_r[e.emphasis]);const a=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:n,emphasis:r,readingOrder:o}=e,i=$r(t.annotation);let s=t.node;if("primary"===r||"secondary"===r||null!=o){const e=null==r&&null!=o;s=(0,Pr.jsx)("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:zr(o),"data-annotation-reading-order":o}:{},children:t.node},"annotation-emphasis-"+n)}const a=Or(t.annotation);return a&&(s=(0,Pr.jsx)("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),i&&(s=(0,Pr.jsx)("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return r&&a.unshift((0,Pr.jsx)("style",{children:Wr},"annotation-disclosure-style")),i&&a.unshift((0,Pr.jsx)("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),a}(o)}(C.filter(e=>"widget"!==e.type),L,S,A):null,T=!0===C?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return(0,Uo.jsxs)(Uo.Fragment,{children:[T&&(0,Uo.jsx)("style",{children:Wr},"annotation-widget-disclosure-style"),(0,Uo.jsxs)("svg",{role:"img",width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[(0,Uo.jsx)("title",{children:"string"==typeof a?a:"Network Chart"}),(0,Uo.jsx)("desc",{children:"string"==typeof a?a+" (network data visualization)":"Network data visualization"}),(0,Uo.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[s.map((e,t)=>(0,Uo.jsx)("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+t)),j,y]}),a&&"string"==typeof a?(0,Uo.jsx)("text",{x:r/2,y:22,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:a}):a?(0,Uo.jsx)("foreignObject",{x:0,y:0,width:r,height:i.top,children:a}):null,Nr({legend:l,totalWidth:r,totalHeight:o,margin:i,legendPosition:f,title:a,legendLayout:g,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})]}),C?.filter(e=>"widget"===e.type&&e.nodeId&&p).map((e,t)=>{const n=!0===e._annotationDeferred,r=p.find(t=>t.id===e.nodeId||t.datum?.id===e.nodeId||t.datum?.data?.id===e.nodeId||t.datum?.data?.name===e.nodeId);if(!r)return null;const o=i.left+(r.cx??(null!=r.x&&null!=r.w?r.x+r.w/2:r.x??0)),s=i.top+(r.cy??(null!=r.y&&null!=r.h?r.y+r.h/2:r.y??0)),a=e.dx??0,l=e.dy??-16,c=e.width??32,u=e.height??32,d=e.content??(0,Uo.jsx)("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return(0,Uo.jsx)("div",{...uo(e,M),className:n?"annotation-deferred":void 0,"data-annotation-disclosure":n?"deferred":void 0,style:{position:"absolute",left:o+a-c/2,top:s+l-u/2,width:c,height:u,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:d},"widget-"+t)})]})}Ko.displayName="NetworkSVGOverlay";var Qo=l(require("react")),Zo=require("react/jsx-runtime"),Jo={position:"absolute",top:0,left:0,pointerEvents:"none"};function ei({marks:e,margin:t,selection:n=null,overscan:r=400}){const o=Qo.useRef(null),i=function(e,t,n){const[r,o]=Qo.useState(null);return Qo.useLayoutEffect(()=>{const e=t.current,n=function(e){let t=e?.parentElement??null;for(;t;){const{overflow:e,overflowX:n,overflowY:r}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(`${e} ${r} ${n}`))return t;t=t.parentElement}return null}(e);if(!e||!n)return void o(null);let r=0;const i=()=>{r=0;const t=n.getBoundingClientRect(),i=e.getBoundingClientRect();o(0!==t.width&&0!==t.height?{scroll:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},originX:i.left,originY:i.top}:null)},s=()=>{0===r&&(r=window.requestAnimationFrame(i))};i(),n.addEventListener("scroll",s,{passive:!0});const a=new ResizeObserver(s);return a.observe(n),()=>{0!==r&&window.cancelAnimationFrame(r),n.removeEventListener("scroll",s),a.disconnect()}},[t,e,n]),Qo.useMemo(()=>{if(!e||!r)return e;const{scroll:t,originX:o,originY:i}=r,s=t.left-n,a=t.right+n,l=t.top-n,c=t.bottom+n;return e.filter(e=>{const t=o+e.x,n=i+e.y;return!(s>t+e.width||t>a||l>n+e.height||n>c)})},[e,r,n])}(e,o,r);if(!e||0===e.length)return null;const s=(0,Zo.jsx)("div",{className:"semiotic-network-html-marks",ref:o,style:{...Jo,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>(0,Zo.jsx)("div",{className:"semiotic-network-html-mark","data-mark-id":e.id,style:{position:"absolute",transform:`translate(${e.x}px, ${e.y}px)`,width:e.width,height:e.height,pointerEvents:"none"},children:e.content},e.id))});return null!=n?(0,Zo.jsx)(cn,{value:n,children:s}):s}function ti(e,t,n){if(null==t)return n;if(vo(t)){const r=function(e,t){const n="undefined"!=typeof window&&window.devicePixelRatio||1,r=`${bo(e)}@${n}`,o=ko.get(r);if(void 0!==o)return o;const i=function(e={},t){const{background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:s=45}=e,a={background:n,stroke:r,lineWidth:o,spacing:i,angle:s},l=Math.max(8,Math.ceil(2*i));let c;try{c=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(po||(po=document.createElement("canvas")),po.width=e,po.height=e,po)}(l)}catch{return yo(a)}const u=c.getContext("2d");if(!u)return yo(a);n&&"transparent"!==n?(u.fillStyle=n,u.fillRect(0,0,l,l)):u.clearRect(0,0,l,l),u.strokeStyle=r,u.lineWidth=o,u.lineCap="square";const d=s*Math.PI/180;if(45===s||-45===s){const e=s>0?1:-1;for(let t=-l;2*l>=t;t+=i)u.beginPath(),u.moveTo(t,0),u.lineTo(t+e*l,l),u.stroke()}else{u.save(),u.translate(l/2,l/2),u.rotate(d);const e=2*l;for(let t=-e;e>=t;t+=i)u.beginPath(),u.moveTo(-e,t),u.lineTo(e,t),u.stroke();u.restore()}return(t||u).createPattern(c,"repeat")}({background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle},t),s=vo(i)?null:i;return ko.set(r,s),s}(t,e);return r||t.background&&hr(e,t.background)||n}return"string"!=typeof t?t:hr(e,t)||n}l(require("react")),require("d3-shape"),require("d3-shape");var ni=require("react/jsx-runtime"),ri={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function oi(e,t="#4e79a7"){return vo(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}var ii=l(require("react")),si=require("d3-shape"),ai=require("react/jsx-runtime");require("react/jsx-runtime");var li="undefined"==typeof window||"undefined"==typeof document,ci=l(require("react")),ui=l(require("react")),di=(require("react/jsx-runtime"),ui.createContext(null)),hi=require("react/jsx-runtime"),fi={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function gi({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+n}return(0,hi.jsx)("div",{"aria-live":"polite","aria-atomic":"true",style:fi,children:t})}var yi=require("react/jsx-runtime");function pi(e,t,n){const r=[];return e>0&&r.push(e+" nodes"),t>0&&r.push(t+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}var mi=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},vi="semiotic-accessible-data-table",bi=vi+" semiotic-accessible-data-table-hidden",xi=vi+" semiotic-accessible-data-table-visible semiotic-accessible-data-table-network",ki={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},wi={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Si={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Mi={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Ai={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},Ci={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Li={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},ji={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function Ti({nodes:e,edges:t,chartType:n,tableId:r,chartTitle:o}){const[i,s]=ci.useState(!1),[a,l]=ci.useState(5),c=ui.useContext(di),u=c?.visible??!1,d=i||u,h=o?"Data summary for "+o:r?`Data summary for ${n} ${r}`:"Data summary for "+n,f=ci.useRef(null);ci.useEffect(()=>{d||l(5)},[d]);const g=ci.useCallback(e=>{e.target===e.currentTarget&&(i||u||s(!0))},[i,u]),y=ci.useCallback(e=>{u||f.current?.contains(e.relatedTarget)||s(!1)},[u]);if(!e||0===e.length)return r?(0,yi.jsx)("span",{id:r,tabIndex:-1,style:fi}):null;if(!d)return(0,yi.jsx)("div",{id:r,className:bi,tabIndex:-1,onFocus:g,style:fi,role:"region","aria-label":h,children:(0,yi.jsxs)("button",{type:"button",onClick:()=>s(!0),children:["View data summary (",e.length," nodes, ",t.length," edges)"]})});const p=Array.isArray(e)?e:[],m=Array.isArray(t)?t:[],v=new Map,b=new Map,x=new Map,k=new Map;for(const e of m){if(!e||"object"!=typeof e)continue;const t=e.datum??{source:e.source,target:e.target},n="object"==typeof t.source?t.source?.id:t.source,r="object"==typeof t.target?t.target?.id:t.target,o="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";b.set(e,(b.get(e)??0)+1),k.set(e,(k.get(e)??0)+o)}if(null!=r&&""!==r){const e=r+"";v.set(e,(v.get(e)??0)+1),x.set(e,(x.get(e)??0)+o)}}const w=[];for(let e=0;p.length>e;e++){const t=p[e];if(!t||"object"!=typeof t)continue;const n=t.datum?.id??t.id,r=null!=n?n+"":"node-"+e,o=v.get(r)??0,i=b.get(r)??0,s=x.get(r)??0,a=k.get(r)??0;w.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:s+a,wInDeg:s,wOutDeg:a})}w.sort((e,t)=>t.degree-e.degree);let S=0,M=0;if(w.length>0){let e=0;for(const t of w)e+=t.degree,t.degree>M&&(M=t.degree);S=e/w.length}const A=m.some(e=>{const t=e?.datum??{source:e?.source,target:e?.target};return"number"==typeof t?.value&&Number.isFinite(t.value)}),C=[`${w.length} nodes, ${m.length} edges.`];w.length>0&&C.push(`Mean degree: ${mi(S)}, max degree: ${M}.`);const L=Math.min(a,w.length),j=w.slice(0,L),T=w.length-L;return(0,yi.jsxs)("div",{ref:f,id:r,className:xi,tabIndex:-1,onBlur:y,style:ki,role:"region","aria-label":h,children:[(0,yi.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{u&&c&&c.setVisible(!1),s(!1)},"aria-label":"Close data summary",style:Si,children:"×"}),(0,yi.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:wi,children:C.join(" ")}),(0,yi.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+n,style:Mi,children:[(0,yi.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:Li,children:T>0?`Top ${L} of ${w.length} nodes by degree`:`All ${w.length} nodes by degree`}),(0,yi.jsx)("thead",{children:(0,yi.jsxs)("tr",{children:[(0,yi.jsx)("th",{style:Ai,children:"id"}),(0,yi.jsx)("th",{style:Ai,children:"degree"}),(0,yi.jsx)("th",{style:Ai,children:"in"}),(0,yi.jsx)("th",{style:Ai,children:"out"}),A&&(0,yi.jsx)("th",{style:Ai,children:"w. degree"}),A&&(0,yi.jsx)("th",{style:Ai,children:"w. in"}),A&&(0,yi.jsx)("th",{style:Ai,children:"w. out"})]})}),(0,yi.jsx)("tbody",{children:j.map((e,t)=>(0,yi.jsxs)("tr",{children:[(0,yi.jsx)("td",{style:Ci,children:e.id}),(0,yi.jsx)("td",{style:Ci,children:e.degree}),(0,yi.jsx)("td",{style:Ci,children:e.inDeg}),(0,yi.jsx)("td",{style:Ci,children:e.outDeg}),A&&(0,yi.jsx)("td",{style:Ci,children:mi(e.wDegree)}),A&&(0,yi.jsx)("td",{style:Ci,children:mi(e.wInDeg)}),A&&(0,yi.jsx)("td",{style:Ci,children:mi(e.wOutDeg)})]},t))})]}),T>0&&(0,yi.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>l(e=>e+25),style:ji,children:["Show ",Math.min(25,T)," more"," ",1===T?"node":"nodes"," (",T," remaining)"]})]})}function Ei({summary:e}){return e?(0,yi.jsx)("div",{role:"note",style:fi,children:e}):null}function Di({tableId:e}){return(0,yi.jsx)("a",{href:"#"+e,style:fi,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,fi)},children:"Skip to data table"})}var Ri=new Set;function Ii(e,t){const n="function"==typeof e?e(t.datum??null,t):e;return(r=n)&&"object"==typeof r&&"string"==typeof r.id&&"function"==typeof r.cacheKey&&"function"==typeof r.drawCanvas&&"function"==typeof r.renderStaticSVG?n:void 0;var r}function Ni(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const n=`${e}:${t}`;Ri.has(n)||(Ri.add(n),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function Pi(e){const{context:t,nodes:n,renderMode:r,pixelRatio:o,paintBuiltIn:i}=e;if(!r||"sketchy"===r)return void i(n);let s=[];const a=()=>{s.length&&(i(s),s=[])};for(const e of n){const n=Ii(r,e);if(!n){s.push(e);continue}let l;a(),t.save();try{l=n.drawCanvas({context:t,node:e,style:e.style??{},pixelRatio:o})}finally{t.restore()}l||(Ni(n.id,e.type??"unknown"),i([e]))}a()}function _i(e){const{node:t,index:n,renderMode:r,fallback:o}=e,i=Ii(r,t);if(!i)return o();const s=i.renderStaticSVG({node:t,style:t.style??{},key:`${i.id}-${n}`});return null!=s?s:(Ni(i.id,t.type??"unknown"),o())}var Wi=Object.freeze([]);function $i(e){if(!e)return Wi;let t=!1;for(let n=0;e.length>n;n++){const r=e[n];if(null==r||"object"!=typeof r){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}var Oi=require("react/jsx-runtime");function Bi({props:e,store:t,responsiveRef:n,size:r,margin:o,adjustedWidth:i,adjustedHeight:s,resolvedBackground:a,resolvedForeground:l}){const{chartType:c,nodes:u,edges:d,data:h,className:f,description:g,title:y,responsiveWidth:p,responsiveHeight:m,summary:v,background:b,renderMode:x,legend:k,legendPosition:w,legendLayout:S,legendHoverBehavior:M,legendClickBehavior:A,legendHighlightedCategory:C,legendIsolatedCategories:L,layoutSelection:j,annotations:T,onAnnotationActivate:E,annotationObservationCallback:D,onObservation:R,chartId:I,autoPlaceAnnotations:N,svgAnnotationRules:P}=e;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(c),n=e?h||(Array.isArray(d)?void 0:d):void 0;if(e&&n)t.ingestHierarchy(n,[i,s]),t.buildScene([i,s]);else{const e=$i(u),n=Array.isArray(d)?$i(d):[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[i,s]),t.buildScene([i,s]))}}const _=t?.sceneNodes??[],W=t?.sceneEdges??[],$=t?.labels??[];return(0,Oi.jsxs)("div",{ref:n,className:"stream-network-frame"+(f?" "+f:""),role:"img","aria-label":g||("string"==typeof y?y:"Network chart"),style:{position:"relative",width:p?"100%":r[0],height:m?"100%":r[1]},children:[(0,Oi.jsx)(Ei,{summary:v}),(0,Oi.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:r[0],height:r[1],style:{position:"absolute",left:0,top:0},children:[a&&(0,Oi.jsx)("g",{transform:`translate(${o.left},${o.top})`,children:a}),(0,Oi.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[b&&(0,Oi.jsx)("rect",{x:0,y:0,width:i,height:s,fill:b}),W.map((e,t)=>_i({node:e,index:t,renderMode:x,fallback:()=>function(e,t){switch(e.type){case"line":return(0,ai.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+t);case"bezier":{const n=e;return(0,ai.jsx)("path",{d:n.pathD,fill:oi(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"ribbon":{const n=e;return(0,ai.jsx)("path",{d:n.pathD,fill:oi(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"curved":{const n=e;return(0,ai.jsx)("path",{d:n.pathD,fill:oi(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+t)}default:return null}}(e,t)})).filter(Boolean),_.map((e,t)=>_i({node:e,index:t,renderMode:x,fallback:()=>function(e,t){switch(e.type){case"circle":{const n=e,r=vo(n.style.fill)?wo(n.style.fill,`net-circle-${t}-hatch`):void 0;return(0,ai.jsxs)(ii.Fragment,{children:[r&&(0,ai.jsx)("defs",{children:r}),(0,ai.jsx)("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:r?`url(#net-circle-${t}-hatch)`:oi(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-circle-"+t)}case"rect":{const n=e,r=vo(n.style.fill)?wo(n.style.fill,`net-rect-${t}-hatch`):void 0;return(0,ai.jsxs)(ii.Fragment,{children:[r&&(0,ai.jsx)("defs",{children:r}),(0,ai.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:r?`url(#net-rect-${t}-hatch)`:oi(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-rect-"+t)}case"arc":{const n=e,r=(0,si.arc)().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(ri)||"",o=vo(n.style.fill)?wo(n.style.fill,`net-arc-${t}-hatch`):void 0;return(0,ai.jsxs)(ii.Fragment,{children:[o&&(0,ai.jsx)("defs",{children:o}),(0,ai.jsx)("path",{d:r,transform:`translate(${n.cx},${n.cy})`,fill:o?`url(#net-arc-${t}-hatch)`:oi(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-arc-"+t)}case"symbol":{const n=e,r=Go(n.symbolType,n.size,n.path);return(0,ai.jsx)("path",{d:r,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?oi(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return function(e,t,n,r){const o=e.glyph;if(!o?.parts?.length||0>=e.size)return null;const i=yn(o,e.size);if(0>=i.scale)return null;const s=`translate(${t},${n})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${i.offsetX},${i.offsetY}) scale(${i.scale})`,a=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),l=xn(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),c=l?function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}(r+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>o.parts.map((n,r)=>{const o=t?"none"===n.fill?void 0:t:mn(n.fill,a,e.accent),i=t?n.stroke&&"none"!==n.stroke?t:void 0:mn(n.stroke??"none",a,e.accent);return o||i?(0,ni.jsx)("path",{d:n.d,fill:o??"none",stroke:i,strokeWidth:i?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},r):null});return(0,ni.jsxs)("g",{transform:s,opacity:1===u?void 0:u,children:[l&&c&&(0,ni.jsx)("clipPath",{id:c,children:(0,ni.jsx)("rect",{x:l.x,y:l.y,width:l.width,height:l.height})}),l&&e.ghostColor?(0,ni.jsx)("g",{children:d(e.ghostColor)}):null,l&&c?(0,ni.jsx)("g",{clipPath:`url(#${c})`,children:d()}):d()]},r)}(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)})).filter(Boolean),$.map((e,t)=>function(e,t){return(0,ai.jsx)("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+t)}(e,t)).filter(Boolean)]})]}),(0,Oi.jsx)(Ko,{width:i,height:s,totalWidth:r[0],totalHeight:r[1],margin:o,labels:$,sceneNodes:_,title:y,legend:k,legendPosition:w,legendLayout:S,legendHoverBehavior:M,legendClickBehavior:A,legendHighlightedCategory:C,legendIsolatedCategories:L,foregroundGraphics:rn(l,dn(t?.customLayoutOverlays,j??null)),annotations:T,onAnnotationActivate:E,onObservation:D??R,chartId:I,chartType:"StreamNetworkFrame",autoPlaceAnnotations:N,svgAnnotationRules:P,annotationFrame:0}),(0,Oi.jsx)(ei,{marks:t?.customLayoutHtmlMarks,margin:o,selection:j??null})]})}var zi=require("react"),Hi="undefined"!=typeof window?zi.useLayoutEffect:zi.useEffect,Fi=()=>()=>{},qi=()=>!1,Yi=()=>!0;function Xi(){const e=(0,zi.useSyncExternalStore)(Fi,qi,Yi);return(0,zi.useRef)(e).current}var Gi=require("react"),Vi=require("react/jsx-runtime");function Ui({children:e,size:t,margin:n,overflowVisible:r=!1}){return e?(0,Vi.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:t[0],height:t[1],pointerEvents:"none",overflow:r?"visible":void 0},children:(0,Vi.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:e})}):null}var Ki=require("react");function Qi(e){const t=(0,Ki.useRef)(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return Ji(e,t);if(!es(e)||!es(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;const n=e[r],o=t[r];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!Ji(n,o))return!1}else{if(!es(n)||!es(o))return!1;if(!Zi(n,o))return!1}}return!0}(t.current,e)||(t.current=e),t.current}function Zi(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!Object.is(e[r],t[r]))return!1}return!0}function Ji(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function es(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}var ts=l(require("react")),ns=require("react/jsx-runtime");function rs({componentName:e,message:t,diagnosticHint:n,width:r,height:o}){return(0,ns.jsx)("div",{role:"alert",style:{width:r,height:Math.max(o,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"},children:(0,ns.jsxs)("div",{style:{textAlign:"center",maxWidth:400},children:[(0,ns.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),(0,ns.jsx)("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:t}),n&&(0,ns.jsx)("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:n})]})})}var os=require("react/jsx-runtime"),is=class extends ts.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.onError?.(e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:(0,os.jsx)(rs,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}},ss=require("react/jsx-runtime");function as({componentName:e,width:t,height:n,children:r}){return(0,ss.jsx)(is,{fallback:r=>(0,ss.jsx)(rs,{componentName:e,message:r.message,width:t,height:n}),children:r})}"undefined"!=typeof process&&process;var ls={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},cs={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function us(e,t,n,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?(0,ss.jsx)("div",{style:{...ls,width:t,height:n},children:r||"No data available"}):null}function ds(e,t,n,r){if(!e)return null;if(!1===r)return null;if(null!=r)return(0,ss.jsx)("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const o=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*o))),s=Math.max(6,Math.floor(n/(2.5*o))),a=Math.floor((n-(o*(i+s)-s))/2);return(0,ss.jsx)("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:o},(e,n)=>(0,ss.jsx)("div",{className:"semiotic-loading-bar",style:{...cs,position:"absolute",top:a+n*(i+s),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2}},n))})}var hs={},fs=4e4;function gs(e,t,n,r,o=fs){return"sync"!==e&&("worker"===e||r*(t+n)>=o)}function ys(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function ps(){if("undefined"!=typeof DOMException)return new DOMException("Force layout aborted","AbortError");const e=Error("Force layout aborted");return e.name="AbortError",e}var ms=class{constructor(e=function(){const e="string"==typeof hs.url&&hs.url?new URL("./forceLayoutWorker.js",hs.url):function(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:"/"+t;return new URL("./"+e,"file:"+n)}throw Error("Cannot resolve module worker asset: "+e)}("forceLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-force-layout"})}()){this.nextRequestId=1,this.pending=new Map,this.dead=!1,this.worker=e,this.worker.onmessage=e=>{const t=e.data,n=t.requestId,r=null!=n?this.pending.get(n):this.pending.values().next().value;if(r){if(null!=n?this.pending.delete(n):this.pending.clear(),r.cleanup(),t.error){const e=Error(t.error.message);return e.name=t.error.name??"Error",t.error.stack&&(e.stack=t.error.stack),void r.reject(e)}r.resolve({positions:t.positions??{}})}},this.worker.onerror=e=>{this.rejectAll(Error(e.message||"Force layout worker failed")),this.terminate()}}get isDead(){return this.dead}request(e,t){if(this.dead)return Promise.reject(Error("Force layout worker session is closed"));if(t?.aborted)return Promise.reject(ps());const n=this.nextRequestId;this.nextRequestId+=1;const r={requestId:n,request:e};return new Promise((e,o)=>{const i=()=>{this.pending.delete(n),t?.removeEventListener("abort",i),o(ps())},s=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:s,reject:o,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(r)}catch(e){this.pending.delete(n),s(),o(e instanceof Error?e:Error(e+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error("Force layout worker terminated")),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}},vs=null;function bs(e,t){return ys()?t?.aborted?Promise.reject(ps()):(vs&&!vs.isDead||(vs=new ms),vs).request(e,t):Promise.reject(Error("Web Workers are unavailable"))}require("react/jsx-runtime");var xs=require("react/jsx-runtime"),ks=/^(value|amount|total|count|weight|score)$/i;function ws({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?(0,xs.jsxs)("div",{className:"semiotic-tooltip",style:Wn,children:[(0,xs.jsxs)("div",{style:{fontWeight:600},children:["object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target]}),null!=t.value&&(0,xs.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]})]}):null}const t=e.data;if(!t)return null;const n=t.__hierarchyNode;if(n){const e=[];let r=n;for(;r;){const n=r.data?.name??r.data?.id??t.id;null!=n&&e.unshift(n+""),r=r.parent}e.length>1&&e.shift();const o=e.length-1;return(0,xs.jsxs)("div",{className:"semiotic-tooltip",style:Wn,children:[(0,xs.jsx)("div",{children:e.map((e,t)=>(0,xs.jsxs)("span",{children:[t>0&&(0,xs.jsx)("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===o?(0,xs.jsx)("strong",{children:e}):(0,xs.jsx)("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&(0,xs.jsx)("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof t.value?t.value.toLocaleString():t.value+""})]})}const r=(t.sourceLinks?.length||0)+(t.targetLinks?.length||0),o=(t.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(t.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0),i=Pn(t.data??t),s=null!=i.title?i.title+"":t.id,a=i.entries.some(e=>ks.test(e.key));return(0,xs.jsxs)("div",{className:"semiotic-tooltip",style:Wn,children:[(0,xs.jsx)("div",{style:{fontWeight:600},children:s}),i.entries.map(e=>{return(0,xs.jsxs)("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",(t=e.value,null==t?"–":"number"==typeof t?Math.abs(t)>9999?t.toLocaleString():t+"":t instanceof Date?t.toLocaleDateString():t+"")]},e.key);var t}),!a&&null!=t.value&&t.value>0&&(0,xs.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),r>0&&(0,xs.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",r,o!==r&&` (weighted: ${o.toLocaleString()})`]})]})}function Ss(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function Ms(e,t){if(!t.pathD)return;e.save();const n=Ss(t);if(t.style.fill&&"none"!==t.style.fill){const r=t._gradient;if(r){const n=e.createLinearGradient(r.x0,0,r.x1,0),o=t.style.fillOpacity??t.style.opacity??.5,i="string"==typeof t.style.fill?t.style.fill:"#999",s=hr(e,i)||i;n.addColorStop(0,1===r.from?s:"transparent"),n.addColorStop(1,1===r.to?s:"transparent"),e.fillStyle=n,e.globalAlpha=o}else e.fillStyle=ti(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5;e.fill(n)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=hr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.5*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(n)),e.restore()}function As(e,t){e.save();const n=t.style.stroke||"#999";e.strokeStyle=hr(e,n)||n,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(t.style.strokeWidth??1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Cs(e,t){if(!t.pathD)return;e.save();const n=Ss(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=ti(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5,e.fill(n)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=hr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.3*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(n)),e.restore()}function Ls(e,t){if(!t.pathD)return;e.save();const n=Ss(t),r=t.style.stroke||"#999";e.strokeStyle=hr(e,r)||r,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(n),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=ti(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??.1,e.fill(n)),e.restore()}function js(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Ts(e,t,n=.3){js(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function Es(e,t,n=.6){if(!js(t))return;const r=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,o=t.cx??t.x??0,i=t.cy??t.y??0;e.beginPath(),e.arc(o,i,r,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}ws.ownsChrome=!0;var Ds=new Map;function Rs(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=Ds.get(t);return n||(n=new Path2D(Go(e.symbolType,e.size)),Ds.size>256&&Ds.clear(),Ds.set(t,n)),n}catch{return null}}function Is(e,t,n,r,o){if(0>=t.size)return;const i=t.glyph;if(!i||!i.parts?.length)return;const s=yn(i,t.size);if(0>=s.scale)return;const a=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=a)return;const l=t=>{const n=ti(e,t,t);return"string"==typeof n?n:t},c=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,r),t.rotation&&e.rotate(t.rotation),e.translate(s.offsetX,s.offsetY),e.scale(s.scale,s.scale),e.globalAlpha=o*a*(t.style.fillOpacity??1);const u=xn(i,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&wn(e,i,c,t.accent,t.ghostColor,l),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),wn(e,i,c,t.accent,void 0,l),e.restore()}function Ns(e){const{canvas:t,store:n,sceneRevisionDiagnostics:r,size:o,margin:i,adjustedWidth:s,adjustedHeight:a,background:l,renderMode:c,hasBackgroundGraphics:u=!1,dirtyRef:d,lastFrameTimeRef:h,now:f,random:g,reducedMotion:y,showParticles:p,isContinuous:m,animate:v,decay:b,pulse:x,thresholds:k,staleness:w,particleStyle:S,getParticleColor:M,pendingAnnotationFrameRef:A,lastAnnotationFrameTimeRef:C,setAnnotationFrame:L,scheduleNextFrame:j,syncColorMap:T}=e,E=t.getContext("2d");if(!E)return;const D=h.current?Math.min((f-h.current)/1e3,.1):.016;h.current=f;const R=n.advanceTransition(y?f+1e6:f),I=!y&&R,N=!y&&n.tickAnimation([s,a],D),P=d.current,_=r?.beforeCompute(n.getLastUpdateResult(),I),W=R||P||N;W&&(n.buildScene([s,a]),P&&T?.()),_&&r?.afterCompute(_,W,!1);const $=p&&!y&&!!n.particlePool,O=!!((B={dirtyOrRebuilt:P,transitioning:I,animationTicked:N,continuous:$||m,liveEncoding:!!b||!!x||!!k||!1!==v&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()}).dirtyOrRebuilt||B.transitioning||B.animationTicked||B.continuous||B.liveEncoding||B.forced);var B;const z=!!w&&n.lastIngestTime>0&&f-n.lastIngestTime>(w?.threshold??5e3);if(O){const e=function(){if("undefined"==typeof window)return 1;const e=window.devicePixelRatio||1,t=function(){if("undefined"==typeof window)return!1;const e="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,t=768>Math.min(window.innerWidth||1/0,window.innerHeight||1/0);return e||t}()?2:3;return Math.max(1,Math.min(e,t))}();if(!function(e,t,n,r){const o=e.getContext("2d");if(!o)return null;const i=Math.round(t[0]*r),s=Math.round(t[1]*r),a=i/t[0],l=s/t[1],c=t[0]+"px",u=t[1]+"px";return e.style.width!==c&&(e.style.width=c),e.style.height!==u&&(e.style.height=u),e.width===i&&e.height===s||(e.width=i,e.height=s),o.setTransform(a,0,0,l,0,0),o.translate(n.left,n.top),o}(t,o,i,e))return;if(E.clearRect(-i.left,-i.top,o[0],o[1]),function(e,t){const{background:n,hasBackgroundGraphics:r=!1,themeBackground:o="",x:i=0,y:s=0,width:a,height:l}=t,c=function(e){const{background:t,hasBackgroundGraphics:n=!1,themeBackground:r=""}=e;return"transparent"===t||n?null:t||(r&&"transparent"!==r?r:"")||null}({background:n,hasBackgroundGraphics:r,themeBackground:o});if(!c)return!1;const u=hr(e,c);u&&(e.fillStyle=u,e.fillRect(i,s,a,l))}(E,{background:l,hasBackgroundGraphics:u,width:s,height:a}),b&&n.applyDecay(),x&&n.applyPulse(f),k&&n.applyThresholds(f),!1!==v&&n.applyTopologyDiff(f),z&&(E.globalAlpha=w?.dimOpacity??.5),Pi({context:E,nodes:n.sceneEdges,renderMode:c,pixelRatio:e,paintBuiltIn:e=>function(e,t){for(const n of t)switch(n.type){case"bezier":Ms(e,n);break;case"line":As(e,n);break;case"ribbon":Cs(e,n);break;case"curved":Ls(e,n)}}(E,e)}),Pi({context:E,nodes:n.sceneNodes,renderMode:c,pixelRatio:e,paintBuiltIn:e=>{const t=e;!function(e,t){for(const n of t){if("rect"!==n.type)continue;const t=n;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=ti(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=hr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.strokeRect(t.x,t.y,t.w,t.h)),Ts(e,t),e.restore())}}(E,t),function(e,t){for(const n of t){if("circle"!==n.type)continue;const t=n;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=ti(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=hr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),Es(e,t),e.restore())}}(E,t),function(e,t){for(const n of t){if("arc"!==n.type)continue;const t=n;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=ti(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=hr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),e.restore()}}(E,t),function(e,t){const n=e.globalAlpha;for(const r of t){if("symbol"!==r.type)continue;const t=r;if(0>=t.size)continue;const o=Rs(t);if(!o)continue;e.save(),e.translate(t.cx,t.cy),t.rotation&&e.rotate(t.rotation);const i=t.style.opacity??1;t.style.fill&&(e.globalAlpha=n*i*(t.style.fillOpacity??1),e.fillStyle=ti(e,t.style.fill,"#007bff"),e.fill(o)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*i,e.strokeStyle=hr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(o)),e.restore()}}(E,t),function(e,t){const n=e.globalAlpha;for(const r of t)"glyph"===r.type&&Is(e,r,r.cx,r.cy,n);e.globalAlpha=n}(E,t)}}),$&&!z){const e=n.edgesArray;if(e.length>0){!function(e,t,n,r,o=Math.random){const i=r.spawnRate??.1,s=r.maxPerEdge??50;for(let r=0;t.length>r;r++){const a=t[r];if(!a.bezier)continue;if(e.countForEdge(r)>=s)continue;const l=a.value*i*n*(a.bezier.circular?.3:1),c=Math.floor(l),u=l-c;let d=c;o()<u&&d++;for(let t=0;d>t&&e.countForEdge(r)<s;t++)e.spawn(r,o)}}(n.particlePool,e,D,S,g);const t=.5*(S.speedMultiplier??1);let r;if(S.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);r=e.map(e=>.3+(e.value||1)/t*1.7)}n.particlePool.step(D,t,e,r),function(e,t,n,r,o){const i=r.radius??3;e.globalAlpha=r.opacity??.7;for(let s=0;t.particles.length>s;s++){const a=t.particles[s];if(!a.active)continue;const l=n[a.edgeIndex];if(!l)continue;let c;c="string"==typeof r.color&&"inherit"!==r.color?r.color:o(l),e.fillStyle=hr(e,c)||c,e.beginPath(),e.arc(a.x,a.y,i,0,2*Math.PI),e.fill()}e.globalAlpha=1}(E,n.particlePool,e,S,M)}}z&&(E.globalAlpha=1)}d.current=!1,(P||I||N)&&t.setAttribute("aria-label",pi(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const H=P||I||N||A.current;H&&f-C.current>=33?(L(e=>e+1),C.current=f,A.current=!1):A.current=!!H,(m||I||null!=n.transition||N||n.hasActivePulses||n.hasActiveThresholds||!1!==v&&n.hasActiveTopologyDiff||A.current)&&j()}function Ps(e,t=30){return Math.max((e??4)+5,12,t)}function _s(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function Ws(e,t,n,r=30){switch(e.type){case"circle":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,s=Math.sqrt(o*o+i*i);return s>Ps(e.r,r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,n,r);case"rect":return function(e,t,n){const r=function(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}(t,n,e);return r.hit?{type:"node",datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const r=t-e.cx,o=n-e.cy,i=Math.sqrt(r*r+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const s=_s(Math.atan2(o,r)),a=_s(e.startAngle),l=_s(e.endAngle);if(a>l?s>=a||l>=s:s>=a&&l>=s){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);case"symbol":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,s=Math.sqrt(o*o+i*i);return s>Ps(Vo(e.size),r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,n,r);case"glyph":return function(e,t,n,r=30){if(null==e.datum)return null;const o=kn(e.glyph,e.size),i=e.cx+o.centerDx,s=e.cy+o.centerDy,a=t-i,l=n-s,c=Math.sqrt(a*a+l*l);return c>Ps(o.radius,r)?null:{type:"node",datum:e.datum,x:i,y:s,distance:c}}(e,t,n,r);default:return null}}var $s=null,Os=null;function Bs(){return Os||(($s=document.createElement("canvas")).width=1,$s.height=1,Os=$s.getContext("2d")),Os}function zs(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch{return null}}function Hs(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const r=zs(e),o=Bs();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const s=o.isPointInStroke(r,t,n);if(o.lineWidth=i,s)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);case"line":return function(e,t,n){const r=e.x2-e.x1,o=e.y2-e.y1,i=r*r+o*o;if(0===i)return null;let s=((t-e.x1)*r+(n-e.y1)*o)/i;s=Math.max(0,Math.min(1,s));const a=e.x1+s*r,l=e.y1+s*o,c=Math.sqrt((t-a)**2+(n-l)**2);return c>5?null:{type:"edge",datum:e.datum,x:a,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const r=zs(e),o=Bs();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const s=o.isPointInStroke(r,t,n);if(o.lineWidth=i,s)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);default:return null}}function Fs(e){const{clientX:t,clientY:n,canvasRect:r,margin:o,adjustedWidth:i,adjustedHeight:s,sceneNodes:a,sceneEdges:l,nodeQuadtree:c,maxNodeRadius:u,hitRadius:d=30}=e,h=t-r.left-o.left,g=n-r.top-o.top;if(0>h||h>i||0>g||g>s)return{kind:"miss-outside"};const y=function(e,t,n,r,o=30,i,s=0){let a=null,l=o,c=1/0;if(i){const e=function(e,t,n,r,o,i=e=>e.x,s=e=>e.y,a=e=>e.r){const l=Math.max(r,o+5,12),c=t-l,u=t+l,d=n-l,h=n+l;let f=null,g=1/0;return e.visit((e,o,l,y,p)=>{if(o>u||c>y||l>h||d>p)return!0;if(!e.length){let o=e;do{const e=o.data,l=i(e)-t,c=s(e)-n,u=Math.sqrt(l*l+c*c);Ps(a(e),r)>=u&&g>u&&(f=e,g=u),o=o.next}while(o)}return!1}),f?{node:f,distance:g}:null}(i,n,r,o,s,e=>e.cx,e=>e.cy,e=>e.r);e&&(a={type:"node",datum:e.node.datum,x:e.node.cx,y:e.node.cy,distance:e.distance},l=e.distance)}for(const t of e){if(i&&"circle"===t.type)continue;const e=Ws(t,n,r,o);if(e)if("rect"===t.type){const n=t.w*t.h;c>n&&(a=e,c=n)}else l>e.distance&&(a=e,l=e.distance)}if(a)return a;for(const e of t){if(!1===e.interactive)continue;const t=Hs(e,n,r);t&&l>t.distance&&(a=t,l=t.distance)}return a}(a,l,h,g,d,c,u);return y?{kind:"hit",hover:f(y.datum||{},y.x,y.y,{nodeOrEdge:y.type})}:{kind:"miss"}}function qs(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:s,context:a,timestamp:l=Date.now()}=e;t&&(n?(t({type:"hover",datum:n,x:r,y:o,timestamp:l,chartType:i,chartId:s}),"focus"===a?.type&&t({type:"focus",datum:n,inputType:"touch"===a.inputType?"pointer":a.inputType,timestamp:l,chartType:i,chartId:s})):t({type:"hover-end",timestamp:l,chartType:i,chartId:s}))}function Ys(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:s,context:a,timestamp:l=Date.now()}=e;t&&(n?(t({type:"click",datum:n,x:r,y:o,timestamp:l,chartType:i,chartId:s}),"activate"===a?.type&&t({type:"activate",datum:n,inputType:a.inputType,timestamp:l,chartType:i,chartId:s})):t({type:"click-end",timestamp:l,chartType:i,chartId:s}))}var Xs=require("react"),Gs="StreamNetworkFrame",Vs=require("react/jsx-runtime"),Us={top:20,right:80,bottom:20,left:80},Ks={top:40,right:40,bottom:40,left:40},Qs=new Set(["chord","force","circlepack","orbit"]),Zs=[800,600],Js=(0,d.memo)((0,d.forwardRef)(function(e,t){const{chartType:n,nodes:r,edges:o,data:i,initialEdges:s,nodeIDAccessor:a="id",sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:h="value",edgeIdAccessor:p,childrenAccessor:m,hierarchySum:v,orientation:b="horizontal",nodeAlign:x="justify",nodePaddingRatio:k=.05,nodeWidth:w=15,iterations:S=300,forceStrength:M=.1,layoutExecution:A="auto",layoutLoadingContent:C,onLayoutStateChange:L,padAngle:j=.01,groupWidth:T=20,sortGroups:E,edgeSort:D,treeOrientation:R="vertical",edgeType:I="curve",padding:N,paddingTop:P,tensionConfig:_,showParticles:W=!1,particleStyle:$,renderMode:O,nodeStyle:B,edgeStyle:z,colorBy:H,colorScheme:F="category10",edgeColorBy:q="source",edgeOpacity:Y=.5,colorByDepth:X=!1,nodeSize:G=8,nodeSizeRange:V=[5,20],nodeLabel:U,showLabels:K=!0,labelMode:Q,size:Z=Zs,responsiveWidth:J,responsiveHeight:ee,margin:te,className:ne,background:re,enableHover:oe=!0,tooltipContent:ie,customHoverBehavior:se,customClickBehavior:ae,onObservation:le,annotationObservationCallback:ce,chartId:ue,onTopologyChange:de,annotations:he,onAnnotationActivate:fe,autoPlaceAnnotations:ge,svgAnnotationRules:ye,legend:pe,legendPosition:me,legendLayout:ve,legendHoverBehavior:be,legendClickBehavior:xe,legendHighlightedCategory:ke,legendIsolatedCategories:we,title:Se,foregroundGraphics:Me,backgroundGraphics:Ae,decay:Ce,pulse:Le,transition:je,animate:Te,staleness:Ee,frameScheduler:De,clock:Re,random:Ie,seed:Ne,paused:Pe=!1,suspendWhenHidden:_e=!0,thresholds:$e,accessibleTable:Oe=!0,description:Be,summary:ze,orbitMode:He,orbitSize:Fe,orbitSpeed:qe,orbitRevolution:Ye,orbitRevolutionStyle:Xe,orbitEccentricity:Ge,orbitShowRings:Ve,orbitAnimated:Ue,customNetworkLayout:Ke,onLayoutError:Qe,layoutConfig:Ze,layoutSelection:Je}=e,et=Qs.has(n)?Ks:Us,tt=(0,d.useRef)(!0),nt=pr({sizeProp:Z,responsiveWidth:J,responsiveHeight:ee,userMargin:te,marginDefault:et,title:Se,legend:pe,legendPosition:me,foregroundGraphics:Me,backgroundGraphics:Ae,animate:Te,transitionProp:je,frameScheduler:De,clock:Re,random:Ie,seed:Ne,paused:Pe,suspendWhenHidden:_e,themeDirtyRef:tt}),{reducedMotionRef:rt,responsiveRef:ot,size:it,margin:st,adjustedWidth:at,adjustedHeight:lt,resolvedForeground:ct,resolvedBackground:ut,transition:dt,introEnabled:ht,tableId:ft,rafRef:gt,renderFnRef:yt,scheduleRender:pt,frameRuntime:mt,currentTheme:vt}=nt,bt=function(){const[e,t]=(0,zi.useState)(!1);return Hi(()=>{t(!0)},[]),e}(),xt=Xi(),kt=(0,d.useMemo)(()=>$i(r),[r]),wt=(0,d.useMemo)(()=>Array.isArray(o)?$i(o):o,[o]),St=(0,d.useMemo)(()=>({...g,..._}),[_]),Mt=(0,d.useMemo)(()=>({...y,...$}),[$]),At=(0,d.useMemo)(()=>{return{chartType:(e={chartType:n,clock:mt.now,random:Ie,seed:Ne,nodeIDAccessor:a,sourceAccessor:l,targetAccessor:c,valueAccessor:h,edgeIdAccessor:p,childrenAccessor:m,hierarchySum:v,orientation:b,nodeAlign:x,nodePaddingRatio:k,nodeWidth:w,iterations:S,forceStrength:M,padAngle:j,groupWidth:T,sortGroups:E,edgeSort:D,treeOrientation:R,edgeType:I,padding:N,paddingTop:P,tensionConfig:St,showParticles:W,particleStyle:Mt,nodeStyle:B,edgeStyle:z,nodeLabel:U,showLabels:K,labelMode:Q,colorBy:H,colorScheme:F,edgeColorBy:q,edgeOpacity:Y,colorByDepth:X,nodeSize:G,nodeSizeRange:V,decay:Ce,pulse:Le,transition:dt,introAnimation:ht,staleness:Ee,thresholds:$e,orbitMode:He,orbitSize:Fe,orbitSpeed:qe,orbitRevolution:Ye,orbitRevolutionStyle:Xe,orbitEccentricity:Ge,orbitShowRings:Ve,orbitAnimated:Ue,customNetworkLayout:Ke,onLayoutError:Qe,layoutConfig:Ze,currentTheme:vt}).chartType,clock:e.clock,random:e.random,seed:e.seed,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,edgeIdAccessor:e.edgeIdAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,tensionConfig:e.tensionConfig,showParticles:e.showParticles,particleStyle:e.particleStyle,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme,themeCategorical:e.currentTheme?.colors?.categorical,themeSemantic:Kn(e.currentTheme),edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,decay:e.decay,pulse:e.pulse,transition:e.transition,introAnimation:e.introAnimation,staleness:e.staleness,thresholds:e.thresholds,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:e.orbitAnimated,customNetworkLayout:e.customNetworkLayout,onLayoutError:e.onLayoutError,layoutConfig:e.layoutConfig};var e},[n,mt.now,Ie,Ne,a,l,c,h,p,m,v,b,x,k,w,S,M,j,T,E,D,R,I,N,P,St,W,Mt,B,z,U,K,Q,H,F,q,Y,X,G,V,Ce,Le,dt,ht,Ee,$e,He,Fe,qe,Ye,Xe,Ge,Ve,Ue,Ke,Qe,Ze,vt]),Ct=Qi(At),Lt=Qi({chartType:(jt={chartType:n,nodeIDAccessor:a,sourceAccessor:l,targetAccessor:c,valueAccessor:h,edgeIdAccessor:p,childrenAccessor:m,hierarchySum:v,orientation:b,nodeAlign:x,nodePaddingRatio:k,nodeWidth:w,iterations:S,forceStrength:M,padAngle:j,groupWidth:T,sortGroups:E,edgeSort:D,treeOrientation:R,edgeType:I,padding:N,paddingTop:P,random:Ie,seed:Ne,tensionConfig:St,customNetworkLayout:Ke,orbitMode:He,orbitSize:Fe,orbitEccentricity:Ge}).chartType,nodeIDAccessor:jt.nodeIDAccessor,sourceAccessor:jt.sourceAccessor,targetAccessor:jt.targetAccessor,valueAccessor:jt.valueAccessor,edgeIdAccessor:jt.edgeIdAccessor,childrenAccessor:jt.childrenAccessor,hierarchySum:jt.hierarchySum,orientation:jt.orientation,nodeAlign:jt.nodeAlign,nodePaddingRatio:jt.nodePaddingRatio,nodeWidth:jt.nodeWidth,iterations:jt.iterations,forceStrength:jt.forceStrength,padAngle:jt.padAngle,groupWidth:jt.groupWidth,sortGroups:jt.sortGroups,edgeSort:jt.edgeSort,treeOrientation:jt.treeOrientation,edgeType:jt.edgeType,padding:jt.padding,paddingTop:jt.paddingTop,random:jt.random,seed:jt.seed,tensionConfig:jt.tensionConfig,customNetworkLayout:jt.customNetworkLayout,orbitMode:jt.orbitMode,orbitSize:jt.orbitSize,orbitEccentricity:jt.orbitEccentricity});var jt;const Tt=(0,d.useRef)(0),Et=(0,d.useRef)(0),Dt=(0,d.useRef)(!1),Rt=(0,d.useRef)(null);Rt.current||(Rt.current=new Gt(Ct));const It=(0,Vt.useRef)(new en("StreamNetworkFrame")),Nt=(0,d.useCallback)((e,t,n=!1)=>function(e,t,n,r=!1,o=!1){const i=e.beforeCompute(t.getLastUpdateResult(),r);n(),e.afterCompute(i,!0,o)}(It.current,e,()=>e.buildScene(t),n),[It]),[_t,Wt]=(0,d.useState)(null),[$t,Ot]=(0,d.useState)(0),[Bt,zt]=(0,d.useState)(0),[Ht,Ft]=(0,d.useState)(!1),[qt,Yt]=(0,d.useState)(!1),Xt=(0,d.useRef)(0),Ut=(0,d.useRef)(null),Kt=(0,d.useRef)(!1),Qt=(0,d.useRef)(L);Qt.current=L;const Zt=(0,d.useRef)(Ct);Zt.current=Ct;const Jt=(0,d.useRef)(null),nn=(0,d.useRef)(new Map),on=(0,d.useRef)(0),sn=(0,d.useCallback)(e=>function(e){const{node:t,colorBy:n,colorScheme:r,nodeColorMap:o,colorIndexRef:i}=e;if("function"==typeof n)return n(t)+"";if("string"==typeof n&&t.data){const e=t.data[n];if(void 0!==e){if(!o.has(e+"")){const t=Array.isArray(r)?r:Pt;o.set(e+"",t[i.current++%t.length])}return o.get(e+"")}}if(o.has(t.id))return o.get(t.id);const s=Array.isArray(r)?r:Pt,a=n?s[i.current++%s.length]:s[0];return o.set(t.id,a),a}({node:e,colorBy:H,colorScheme:F,nodeColorMap:nn.current,colorIndexRef:on}),[H,F]),an=(0,d.useCallback)(e=>{on.current=function(e){const{sceneNodes:t,nodes:n,nodeColorMap:r,colorScheme:o}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&r.set(e.id,e.style.fill);const i=Array.isArray(o)?o:Pt,s=Array.from(n);for(let e=0;s.length>e;e++){const t=s[e];r.has(t.id)||r.set(t.id,i[e%i.length])}return s.length}({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:nn.current,colorScheme:F})},[F]),ln=(0,d.useCallback)((e,t)=>{Nt(e,t),an(e),tt.current=!1,e.markStylePaintPending()},[Nt,an]),cn=(un=vt,un?.colors?.border||un?.colors?.secondary||un?.colors?.primary||"#999");var un;const fn=(0,d.useCallback)(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,Rt.current?.nodes),[]),gn=(0,d.useCallback)(e=>function(e){const{edge:t,edgeColorBy:n,getNodeColor:r,resolveEndpoint:o,fallback:i}=e;if("function"==typeof n)return n(t);const s=o(t.source),a=o(t.target);return"target"===n&&a?r(a):s?r(s):i}({edge:e,edgeColorBy:q,getNodeColor:sn,resolveEndpoint:fn,fallback:cn}),[q,sn,cn,fn]),yn=(0,d.useCallback)(e=>function(e){const{edge:t,particleStyleColor:n,particleColorBy:r,hasExplicitParticleColorBy:o,getEdgeColor:i,getNodeColor:s,resolveEndpoint:a,fallback:l}=e;if("function"==typeof n){const e=a(t.source);return e?n(t,e):l}if(!o)return i(t);const c=r,u=a(t.source),d=a(t.target);return"target"===c&&d?s(d):u?s(u):l}({edge:e,particleStyleColor:Mt.color,particleColorBy:Mt.colorBy,hasExplicitParticleColorBy:!!$?.colorBy,getEdgeColor:gn,getNodeColor:sn,resolveEndpoint:fn,fallback:cn}),[$?.colorBy,Mt.color,Mt.colorBy,sn,gn,cn,fn]),pn=function(e,t,n,r,o){return("sankey"===e||t)&&n||r||o}(n,!!Ke,W,!!Le,Rt.current?.isAnimating??!1);!function(e,t,n,r){(0,hn.useEffect)(()=>{e.current?.updateConfig(t),n.current=!0,r()},[t,r,e,n])}(Rt,Ct,tt,pt),function(e,t,n,r){const o=(0,hn.useRef)(null);(0,hn.useEffect)(()=>{const i=e.current;if(!i)return;const s=t??null;o.current!==s&&(o.current=s,i.setLayoutSelection(s),i.hasCustomRestyle?i.restyleScene(s):n.current=!0,r())},[t,r,e,n])}(Rt,Je,tt,pt),(0,d.useEffect)(()=>{const e=Rt.current;e&&(ln(e,[at,lt]),pt())},[vt,at,lt,ln,pt]);const mn=(0,d.useCallback)(()=>{const e=Rt.current;if(e&&(e.runLayout([at,lt]),ln(e,[at,lt]),Ot(e.layoutVersion),de)){const{nodes:t,edges:n}=e.getLayoutData();de(t,n)}},[at,lt,ln,de]),vn=(0,d.useRef)(!1),bn=(0,d.useCallback)((e=!1)=>!(!e&&!vn.current||(vn.current=!1,mn(),0)),[mn]),xn=(0,d.useCallback)(()=>bn(!1),[bn]),wn=(0,d.useCallback)(e=>{const t=Rt.current;if(!t)return!1;let n=!1,r=vn.current;for(const o of e)null!=o&&"object"==typeof o&&(n=!0,t.ingestEdge(o)&&(r=!0));const o=bn(r);return n||o},[bn]),Mn=(0,d.useCallback)(e=>{if(null==e||"object"!=typeof e)return;const t=Rt.current;t&&(t.ingestEdge(e)&&(vn.current=!0),mt.isActive?pt():xn())},[xn,mt,pt]),Cn=(0,d.useCallback)(e=>{wn(e)&&pt()},[wn,pt]);(0,d.useEffect)(()=>mt.subscribe(()=>{mt.isActive||xn()}),[xn,mt]);const Ln=(0,d.useCallback)(()=>{vn.current=!1,Rt.current?.clear(),nn.current.clear(),on.current=0,Ot(Rt.current?.layoutVersion??0),Wt(null),Jt.current=null,tt.current=!0,pt()},[pt]),Tn=(0,d.useCallback)(()=>{const e=Rt.current;e&&(e.tension+=999,bn(!0),pt())},[bn,pt]);(0,d.useImperativeHandle)(t,()=>({push:Mn,pushMany:Cn,removeNode:e=>{const t=Rt.current?.removeNode(e)??!1;if(t){const t=Jt.current?.data?"function"==typeof a?a(Jt.current.data):Jt.current.data[a]:void 0;Jt.current&&"node"===Jt.current.nodeOrEdge&&t===e&&(Jt.current=null,Wt(null)),nn.current.delete(e)}return bn(t)&&(tt.current=!0,pt()),t},removeEdge:(e,t)=>{const n=Rt.current?.removeEdge(e,t)??!1;if(n&&Jt.current&&"edge"===Jt.current.nodeOrEdge){const n=Jt.current.data;let r;r=void 0!==t?("object"==typeof n?.source?n.source.id:n?.source)===e&&("object"==typeof n?.target?n.target.id:n?.target)===t:!p||!n||("function"==typeof p?p:e=>e?.[p])(n)===e,r&&(Jt.current=null,Wt(null))}return bn(n)&&(tt.current=!0,pt()),n},updateNode:(e,t)=>{const n=Rt.current?.updateNode(e,t)??null;return bn(null!==n)&&(tt.current=!0,pt()),n},updateEdge:(e,t,n)=>{const r=Rt.current?.updateEdge(e,t,n)??[];return bn(r.length>0)&&(tt.current=!0,pt()),r},clear:Ln,getTopology:()=>(xn(),Rt.current?.getLayoutData()??{nodes:[],edges:[]}),getCustomLayout:()=>(xn(),Rt.current?.lastCustomLayoutResult??null),getLayoutFailure:()=>(xn(),Rt.current?.lastCustomLayoutFailure??null),getTopologyDiff:()=>{xn();const e=Rt.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:Tn,getTension:()=>(xn(),Rt.current?.tension??0)}),[Mn,Cn,Ln,Tn,xn,bn,a,pt,p]);const En=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),Dn=En?i||(Array.isArray(o)?void 0:o):void 0;(0,d.useEffect)(()=>{const e=Rt.current;if(!e)return;const t=++Xt.current;if(Ut.current?.abort(),Ut.current=null,En&&Dn)vn.current=!1,e.ingestHierarchy(Dn,[at,lt]),ln(e,[at,lt]),Yt(!1),Qt.current?.("ready"),pt();else{const i=kt,s=Array.isArray(wt)?wt:[];if(null==r&&null==o||(vn.current=!1),0===i.length&&0===s.length)return null==r&&null==o||0>=e.nodes.size&&0>=e.edges.size||Ln(),Yt(!1),void Qt.current?.("ready");const a=[at,lt],l="force"===n&&!Ke&&ys()&&!Ie&&gs(A,i.length,s.length,S);if(l&&xt&&!Kt.current&&e.sceneNodes.length>0)return Kt.current=!0,Yt(!1),Qt.current?.("ready"),tt.current=!0,void pt();if(l){const n=new AbortController;Ut.current=n;const r=e._lastPositionSnapshot;e.ingestBounded(i,s,a,{deferLayout:!0});const o=e.getLayoutData(),l=function(e,t,n,r,o){const i=We(n.nodeSize,n.nodeSizeRange,e);return{kind:"frame",nodes:e.map(e=>{const t=o?.get(e.id);return{id:e.id,x:0!==e.x||0!==e.y?e.x:t?.x??0,y:0!==e.x||0!==e.y?e.y:t?.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:e.value,__forceRadius:i(e)}}),edges:t.map(e=>{const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id,r=e.data?.weight,o="number"==typeof r&&Number.isFinite(r)?r:e.value;return{source:t,target:n,value:e.value,y0:0,y1:0,sankeyWidth:0,weight:o}}),config:{chartType:"force",iterations:n.iterations,forceStrength:n.forceStrength,seed:n.seed},size:r}}(o.nodes,o.edges,Zt.current,a,r);return Yt(!0),Qt.current?.("pending"),bs(l,n.signal).then(({positions:n})=>{t===Xt.current&&(e.applyForceLayoutPositions(n,a),ln(e,a),Yt(!1),Qt.current?.("ready"),Ot(e.layoutVersion),pt())}).catch(n=>{"AbortError"!==n.name&&t===Xt.current&&(e.runLayout(a),ln(e,a),Yt(!1),Qt.current?.("error"),Ot(e.layoutVersion),pt())}),()=>n.abort()}e.ingestBounded(i,s,a),ln(e,a),Yt(!1),Qt.current?.("ready"),pt()}},[kt,wt,r,o,i,Dn,En,at,lt,Lt,A,S,xt,n,Ke,Ie,pt,Ln,ln]);const Rn=u.useRef(!1);(0,d.useEffect)(()=>{Rn.current||s&&s.length>0&&(Rn.current=!0,Cn(s))},[s,Cn]);const{customHoverBehavior:In,customClickBehavior:Nn}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:r}){return{customHoverBehavior:(0,Xs.useCallback)((t,o)=>{e?.(t,o),qs({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:Gs,chartId:r,context:o})},[e,n,r]),customClickBehavior:(0,Xs.useCallback)((e,o)=>{t?.(e,o),Ys({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:Gs,chartId:r,context:o})},[t,n,r])}}({customHoverBehavior:se,customClickBehavior:ae,onObservation:le,chartId:ue}),{hoverHandlerRef:Pn,hoverLeaveRef:_n,onPointerMove:Wn,onPointerLeave:$n}=nt,On=()=>!Ke||(Rt.current?.hasCustomRestyle??!1);Pn.current=e=>{if(!oe)return;const t=On(),n=Vn.current;if(!n)return;const r=Rt.current;if(!r)return;const o=Fs({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:st,adjustedWidth:at,adjustedHeight:lt,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});"hit"===o.kind?(Jt.current=o.hover,Wt(o.hover),In&&(In(o.hover),t&&(tt.current=!0)),t&&pt()):Jt.current&&(Jt.current=null,Wt(null),In&&(In(null),t&&(tt.current=!0)),t&&pt())},_n.current=()=>{if(Jt.current){const e=On();Jt.current=null,Wt(null),In&&(In(null),e&&(tt.current=!0)),e&&pt()}};const Bn=(0,d.useRef)(()=>{});Bn.current=e=>{if((t=e.target)instanceof Element&&null!=t.closest("[data-semiotic-annotation-widget]"))return;var t;if(!ae&&!le)return;const n=Vn.current;if(!n)return;const r=Rt.current;if(!r)return;const o=Fs({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:st,adjustedWidth:at,adjustedHeight:lt,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});var i;"hit"===o.kind?Nn(o.hover,{type:"activate",inputType:(i=e.nativeEvent.pointerType,"touch"===i?"touch":"pointer")}):"miss"===o.kind&&Nn(null)};const zn=(0,d.useCallback)(e=>Bn.current(e),[]),Hn=(0,d.useRef)(-1),qn=(0,d.useRef)(null),Yn=(0,d.useRef)(-1),Xn=(0,d.useCallback)(e=>{if(function(e){const t=e.target;return t instanceof Element&&t!==e.currentTarget&&null!=t.closest("button, a[href], input, select, textarea, summary, [contenteditable='true'], [role='button'], [role='link'], [role='checkbox'], [role='radio'], [role='switch']")}(e))return;const t=Rt.current;if(!t)return;const n=()=>{Hn.current=-1,qn.current=null,Yn.current=-1,Jt.current=null,Wt(null),In&&(In(null),tt.current=!0),pt()},r=function(e){const t=[];for(const n of e)if("circle"===n.type&&null!=n.cx){if(0>=n.r)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("rect"===n.type&&null!=n.x){if(0>=n.w||0>=n.h)continue;t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.datum?.id??"_default"})}else if("arc"===n.type&&null!=n.cx)t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"});else if("symbol"===n.type&&null!=n.cx){if(0>=n.size)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("glyph"===n.type&&null!=n.cx){if(0>=n.size||null==n.datum)continue;const e=kn(n.glyph,n.size);t.push({x:n.cx+e.centerDx,y:n.cy+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:n.datum?.id??"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===r.length)return void(0>Hn.current||n());const o=function(e){const t=new Map;for(const n of e){const e=n.group??"_default";let r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}for(const e of t.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const n=Array.from(t.keys()).sort((e,n)=>{const r=t.get(e),o=t.get(n);return(r.length>0?r[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(t.values()).flat();r.sort((e,t)=>e.x-t.x||e.y-t.y);const o=new Map;for(let e=0;r.length>e;e++){r[e]._flatIndex=e;const t=r[e].datum?.id;null!=t&&o.set(t+"",e)}return{flat:r,groups:n,byGroup:t,idToIdx:o}}(r);let i=Hn.current;if(o.flat.length>i||(n(),i=-1)," "===e.key&&i>=0){e.preventDefault();const t=o.flat[i];return void Nn(f(t.datum||{},t.x,t.y,{nodeOrEdge:"node"}),{type:"activate",inputType:"keyboard"})}if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),Hn.current=0,Yn.current=-1;const t=o.flat[0];qn.current={shape:t.shape,w:t.w,h:t.h};const n=f(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Jt.current=n,Wt(n),In&&(In(n,{type:"focus",inputType:"keyboard"}),tt.current=!0),void pt()}const s=function(e,t){if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const n=Math.max(0,Math.min(t,e.flat.length-1)),r=e.flat[n];return{flatIndex:n,group:r.group??"_default",indexInGroup:r._groupIndex??0}}(o,i),a=function(e,t,n,r,o){const i=n.flat[t.flatIndex];if(!i)return Sn(e,t,n);const s=i.datum?.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=function(e,t,n){let r=null,o=1/0;for(let i=0;e.flat.length>i;i++){const s=e.flat[i];if(s===t)continue;const a=s.x-t.x,l=s.y-t.y;let c=!1;switch(n){case"right":c=a>0&&Math.abs(a)>=Math.abs(l);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(a);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(a)}if(!c)continue;const u=a*a+l*l;o>u&&(o=u,r=i)}return r}(n,i,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up")??t.flatIndex;return r!==t.flatIndex&&(o.current=-1),r}case"Enter":{if(null==s)return t.flatIndex;const e=function(e,t){const n=e+"",r=[];for(const e of t){const t=e.datum??e,o=An(t.source),i=An(t.target),s=null!=o,a=null!=i;s&&o+""===n&&a?r.push(i+""):a&&i+""===n&&s&&r.push(o+"")}return r}(s,r);if(0===e.length)return t.flatIndex;const i=n.idToIdx.get(e[(o.current+1)%e.length])??-1;return 0>i?t.flatIndex:(o.current=-1,i)}default:{const r=Sn(e,t,n);return null!==r&&r!==t.flatIndex&&(o.current=-1),r}}}(e.key,s,o,t.sceneEdges??[],Yn);if(null===a)return;if(e.preventDefault(),0>a)return void n();Hn.current=a;const l=o.flat[a];qn.current={shape:l.shape,w:l.w,h:l.h};const c={data:l.datum||{},x:l.x,y:l.y,__semioticHoverData:!0,nodeOrEdge:"node"};Jt.current=c,Wt(c),In&&(In(c,{type:"focus",inputType:"keyboard"}),tt.current=!0),pt()},[Nn,In,pt]),Gn=(0,d.useCallback)(e=>{Hn.current=-1,qn.current=null,Wn(e)},[Wn]);yt.current=()=>{if(gt.current=null,xn(),!mt.isActive)return;const e=Vn.current;if(!e)return;const t=Rt.current;t&&Ns({canvas:e,store:t,sceneRevisionDiagnostics:It.current,size:it,margin:st,adjustedWidth:at,adjustedHeight:lt,background:re,renderMode:O,hasBackgroundGraphics:!!Ae,dirtyRef:tt,lastFrameTimeRef:Tt,now:mt.now(),random:mt.random,reducedMotion:!!rt.current,showParticles:W,isContinuous:pn,animate:Te,decay:Ce,pulse:Le,thresholds:$e,staleness:Ee,particleStyle:Mt,getParticleColor:yn,pendingAnnotationFrameRef:Dt,lastAnnotationFrameTimeRef:Et,setAnnotationFrame:zt,scheduleNextFrame:()=>{pt()},syncColorMap:()=>an(t)})};const{canvasRef:Vn}=function(e,t){return function(e){const{cancelRender:t,dirtyRef:n,frameRuntime:r,manageFrameRuntime:o,scheduleRender:i}=e,s=(0,Gi.useRef)(null),a=(0,Gi.useRef)(null),l=(0,Gi.useRef)(!1);return function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:r,dirtyRef:o,renderFnRef:i,cancelRender:s,cleanup:a}=e;Hi(()=>{const e=r.current;t&&n&&e?.cancelIntroAnimation?.(),!n&&e?.sceneNodes&&e.sceneNodes.length>0&&e?.markStylePaintPending?e.markStylePaintPending():o.current=!0,s?.(),i.current()},[t,n]);const l=(0,zi.useRef)(a);l.current=a,(0,zi.useEffect)(()=>()=>l.current?.(),[])}({hydrated:e.hydrated,wasHydratingFromSSR:e.wasHydratingFromSSR,storeRef:e.storeRef,dirtyRef:e.dirtyRef,renderFnRef:e.renderFnRef,cancelRender:e.cancelRender,cleanup:e.cleanup}),(0,Gi.useEffect)(()=>{if(!1!==o)return r.subscribe(()=>{r.isActive?(n.current=!0,i()):t()})},[t,n,r,o,i]),(0,Gi.useEffect)(()=>{!l.current&&(l.current=!0,e.skipInitialCanvasPaintInvalidation)||(e.dirtyRef.current=!0,e.scheduleRender())},e.canvasPaintDependencies),{canvasRef:s,interactionCanvasRef:a}}({...t,renderFnRef:e.renderFnRef,scheduleRender:e.scheduleRender,cancelRender:e.cancelRender,frameRuntime:e.frameRuntime})}(nt,{hydrated:bt,wasHydratingFromSSR:xt,storeRef:Rt,dirtyRef:tt,skipInitialCanvasPaintInvalidation:!0,canvasPaintDependencies:[n,at,lt,re,Ae,O,pt]});!function(e,t,n,r,o,i){const s=(0,mr.useRef)("fresh");(0,mr.useEffect)(()=>{if(!e)return;const a=setInterval(()=>{const a=t.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=function(e,t){if(!e||0>=t)return br;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,r=e.graded;if(r){const e="object"==typeof r?r:{},o=function(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??1)>e?"fresh":t*(n.aging??1.5)>e?"aging":t*(n.stale??3)>e?"stale":"expired":"fresh"}(t,n,e.thresholds);return{alpha:{...vr,...e.opacities??{}}[o],band:o,isStale:"fresh"!==o}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:br}(e,l-a.lastIngestTime);c.band===s.current&&c.isStale===o||(s.current=c.band,c.isStale!==o&&i(c.isStale),n.current=!0,r())},1e3);return()=>clearInterval(a)},[e,o,r,t,i,n])}(Ee,Rt,tt,pt,Ht,Ft);const Un=oe&&_t?(0,Vs.jsx)(Fn,{x:_t.x,y:_t.y,containerWidth:at,containerHeight:lt,margin:st,className:"stream-network-tooltip",zIndex:2,children:ie?ie(_t):(0,Vs.jsx)(ws,{data:_t})}):null;if(li||!bt&&xt)return(0,Vs.jsx)(Bi,{props:e,store:Rt.current,responsiveRef:ot,size:it,margin:st,adjustedWidth:at,adjustedHeight:lt,resolvedBackground:ut,resolvedForeground:ct});const Qn=Rt.current;return(0,Vs.jsxs)("div",{ref:ot,className:"stream-network-frame"+(ne?" "+ne:""),role:"group","aria-label":Be||("string"==typeof Se?Se:"Network chart"),tabIndex:0,"aria-busy":qt||void 0,style:{position:"relative",width:J?"100%":it[0],height:ee?"100%":it[1],overflow:"visible"},onKeyDown:Xn,children:["production"!==process.env.NODE_ENV&&Rt.current&&(0,Vs.jsx)(tn,{store:Rt.current,diagnostics:It.current}),Oe&&(0,Vs.jsx)(Di,{tableId:ft}),Oe&&(0,Vs.jsx)(Ti,{nodes:Qn?.sceneNodes??[],edges:Qn?.sceneEdges??[],chartType:"Network chart",tableId:ft,chartTitle:"string"==typeof Se?Se:void 0}),(0,Vs.jsx)(Ei,{summary:ze}),(0,Vs.jsx)(gi,{hoverPoint:_t}),(0,Vs.jsxs)("div",{role:"img","aria-label":Be||("string"==typeof Se?Se:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:oe?Gn:void 0,onMouseLeave:oe?$n:void 0,onClick:ae||le?zn:void 0,children:[qt&&!1!==C&&(0,Vs.jsx)("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:ds(!0,it[0],it[1],C)}),(0,Vs.jsx)(Ui,{size:it,margin:st,overflowVisible:!0,children:ut}),(0,Vs.jsx)("canvas",{ref:Vn,"aria-label":pi(Qn?.sceneNodes?.length??0,Qn?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),(0,Vs.jsx)(Ko,{width:at,height:lt,totalWidth:it[0],totalHeight:it[1],margin:st,labels:Qn?.labels||[],sceneNodes:Qn?.sceneNodes,title:Se,legend:pe,legendPosition:me,legendLayout:ve,legendHoverBehavior:be,legendClickBehavior:xe,legendHighlightedCategory:ke,legendIsolatedCategories:we,foregroundGraphics:rn(ct,dn(Rt.current?.customLayoutOverlays,Je??null)),annotations:he,onAnnotationActivate:fe,onObservation:ce??le,chartId:ue,chartType:"StreamNetworkFrame",autoPlaceAnnotations:ge,svgAnnotationRules:ye,annotationFrame:Bt}),(0,Vs.jsx)(ei,{marks:Qn?.customLayoutHtmlMarks,margin:st,selection:Je??null}),(0,Vs.jsx)(jn,{active:Hn.current>=0,hoverPoint:_t,margin:st,size:it,shape:qn.current?.shape,width:qn.current?.w,height:qn.current?.h}),Un,Ee?.showBadge&&(0,Vs.jsx)(kr,{isStale:Ht,position:Ee.badgePosition})]})]})}));Js.displayName="StreamNetworkFrame";var ea=Js,ta=require("react");function na(e,t){const{variant:n,frameRef:r,overrides:o}=t,i=(0,ta.useRef)(o);i.current=o,(0,ta.useImperativeHandle)(e,()=>{const e=function(e,t){if("xy"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.remove(t)??[],update:(t,n)=>e.current?.update(t,n)??[],replace:t=>e.current?.replace?.(t),clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getScales:()=>e.current?.getScales()??null,getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("network"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>{const n=Array.isArray(t)?t:[t],r=e.current?.getTopology()?.nodes??[],o=[];for(const t of n){const n=r.find(e=>e.id===t);n&&o.push({...n.data??{},id:t}),e.current?.removeNode(t)}return o},update:(t,n)=>(Array.isArray(t)?t:[t]).flatMap(t=>{const r=e.current?.updateNode(t,n);return r?[{...r,id:t}]:[]}),clear:()=>e.current?.clear(),getData:()=>e.current?.getTopology()?.nodes?.map(e=>e.data)??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("geo-points"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.removePoint(t)??[],update:(t,n)=>{const r=e.current?.removePoint(t)??[];for(const t of r)e.current?.push(n(t));return r},clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}const n=t;return{push:e=>n.current?.pushLine(e),pushMany:e=>n.current?.pushManyLines(e),remove:e=>n.current?.removeLine(e)??[],update:(e,t)=>{const r=n.current?.removeLine(e)??[];for(const e of r)n.current?.pushLine(t(e));return r},clear:()=>n.current?.clear(),getData:()=>n.current?.getLines()??[],getCustomLayout:()=>n.current?.getCustomLayout?.()??null,getLayoutFailure:()=>n.current?.getLayoutFailure?.()??null}}(n,r);return new Proxy(e,{get(e,t,n){if("string"==typeof t){const e=i.current?.[t];if("function"==typeof e)return e}return Reflect.get(e,t,n)},has:(e,t)=>!("string"!=typeof t||!i.current||!(t in i.current))||Reflect.has(e,t)})},[])}var ra=require("react"),oa=require("react"),ia=require("react"),sa=(require("react/jsx-runtime"),(0,ia.createContext)(null)),aa=require("react");function la(e){const t=[];for(const[n,r]of Object.entries(e.fields))if("point"===r.type)t.push(e=>r.values.has(e[n]));else{const[e,o]=r.range;t.push(t=>{const r=t[n];return r>=e&&o>=r})}return e=>t.every(t=>t(e))}function ca(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function ua(e,t){if(e.type!==t.type)return!1;if("interval"===e.type&&"interval"===t.type)return e.range[0]===t.range[0]&&e.range[1]===t.range[1];if("point"===e.type&&"point"===t.type){if(e.values.size!==t.values.size)return!1;for(const n of e.values)if(!t.values.has(n))return!1;return!0}return!1}var[da,ha]=Vn(e=>({selections:new Map,setClause(t,n){e(e=>{const r=e.selections.get(t),o=r?.clauses.get(n.clientId);if(o&&function(e,t){if(e.clientId!==t.clientId||e.type!==t.type)return!1;const n=Object.entries(e.fields);if(n.length!==function(e){let t=0;for(const n in e)t++;return t}(t.fields))return!1;for(const[e,r]of n){const n=t.fields[e];if(!n||!ua(r,n))return!1}return!0}(o,n))return{};const i=new Map(e.selections),s=ca(i,t),a=new Map(s.clauses);return a.set(n.clientId,n),i.set(t,{...s,clauses:a}),{selections:i}})},clearClause(t,n){e(e=>{const r=e.selections.get(t);if(!r||!r.clauses.has(n))return{};const o=new Map(e.selections),i=new Map(r.clauses);return i.delete(n),o.set(t,{...r,clauses:i}),{selections:o}})},setResolution(t,n){e(e=>{const r=e.selections.get(t);if(r?.resolution===n)return{};const o=new Map(e.selections),i=ca(o,t);return o.set(t,{...i,resolution:n}),{selections:o}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const r=new Map(e.selections);return r.set(t,{...n,clauses:new Map}),{selections:r}})}})),fa=require("react"),ga=(require("react"),{positions:new Map}),ya=new Set;function pa(){for(const e of ya)e()}function ma(e,t){const n=ga.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const r=new Map(ga.positions);r.delete(e),ga={positions:r},pa()}function va(e,t){const n=ga.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const r=new Map(ga.positions);r.delete(e),ga={positions:r},pa()}function ba(e){const t=(0,fa.useId)(),n=e.clientId||t,{name:r}=e,o=ha(e=>e.selections.get(r)),i=ha(e=>e.setClause),s=ha(e=>e.clearClause),a=(0,fa.useMemo)(()=>!!o&&o.clauses.size>0,[o]);return{predicate:(0,fa.useMemo)(()=>o&&0!==o.clauses.size?function(e,t){const n=[];for(const[r,o]of e.clauses)"crossfilter"===e.resolution&&r===t||n.push(la(o));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(o,n):()=>!0,[o,n]),isActive:a,selectPoints:(0,fa.useCallback)(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"point",values:new Set(r)},o=!0;o&&i(r,{clientId:n,type:"point",fields:t})},[n,r,i]),selectInterval:(0,fa.useCallback)(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"interval",range:r},o=!0;o&&i(r,{clientId:n,type:"interval",fields:t})},[n,r,i]),clear:(0,fa.useCallback)(()=>{s(r,n)},[s,r,n]),clientId:n}}require("react/jsx-runtime");var xa=(0,aa.createContext)(!1);(0,aa.createContext)(!1);var ka=(0,aa.createContext)(null),wa="undefined"==typeof window?aa.useEffect:aa.useLayoutEffect;var Sa=.5,Ma=l(require("react"));function Aa(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Ca(e,t){const{when:n}=e,r=t.width,o=t.height,i=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),s=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof n.minWidth&&n.minWidth>r||"number"==typeof n.maxWidth&&r>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof o||n.minHeight>o)||"number"==typeof n.maxHeight&&("number"!=typeof o||o>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof i||n.minAspectRatio>i)||"number"==typeof n.maxAspectRatio&&("number"!=typeof i||i>n.maxAspectRatio)||n.orientation&&s!==n.orientation)}function La(e,t,n=e.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:e,matches:[]};const r=n.map((e,t)=>({rule:e,index:t})).filter(e=>Ca(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:r.reduce((e,t)=>function(e,t){const n={...e,...t};for(const r of["margin","frameProps","mobileSemantics","style"])Aa(e[r])&&Aa(t[r])&&(n[r]={...e[r],...t[r]});return"string"==typeof e.className&&"string"==typeof t.className&&(n.className=`${e.className} ${t.className}`),n}(e,t.rule.transform),e),matches:r}}require("react/jsx-runtime"),Ma.createContext(void 0);var ja=44,Ta={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:ja,snap:"nearestDatum",brushHandleSize:ja,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function Ea(e,t={}){const n=t.mobileSemantics?.interaction,r="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,o="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,i=!!n||void 0!==r,s=e&&"object"==typeof e?e:void 0;if(!1===e||!1===s?.enabled||void 0===e&&!o&&!i)return Ta;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??r??ja,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??ja,standardControls:a.standardControls??!1}}var Da={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}},Ra={top:10,bottom:10,left:10,right:10};function Ia(e){return e.compactMode?e.marginDefaults:Ra}function Na(e,t,n){if(!1!==t)return e;const r={...e};return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}function Pa(e,t,n){const r=e.xValue??t?.[n];if(null==r)return null;const o=Number(r);return Number.isFinite(o)?o:null}function _a(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?{...t,xValue:e.xValue}:t||{}}function Wa(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}var $a=[];function Oa(){const e=or(e=>e.theme),t=e?.colors?.categorical;return t&&t.length>0?t:void 0}function Ba(e,t,n,r,o){if(e)return e;if(n&&"object"==typeof n&&!Array.isArray(n)){const e=Ht(n,r);if(e)return e}let i;if(Array.isArray(n))i=n;else if(t&&t.length>0)i=t;else if("string"==typeof n){const e=Nt[n];Array.isArray(e)&&(i=e)}return i&&0!==i.length?null!=r?(o.has(r)||o.set(r,o.size),i[o.get(r)%i.length]):i[0]:_t}function za({selection:e,linkedHover:t,fallbackFields:n=$a,unwrapData:r=!1,onObservation:o,chartType:i,chartId:s,onClick:a,hoverHighlight:l,colorByField:c,mobileInteraction:u}){const d=(0,oa.useId)(),h=(0,oa.useMemo)(()=>function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField,seriesField:e.seriesField}:null}(t,n),[t,n]),f=(0,oa.useMemo)(()=>"series"===h?.mode?[h.seriesField||c||n[0]].filter(e=>!!e):h?.fields||n,[h,c,n]),g=ba({name:e?.name||"__unused__",fields:f}),y=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:r,isActive:o,selectPoints:i,clear:s}=ba({name:t,fields:n});return{onHover:(0,fa.useCallback)(e=>{if(!e)return void s();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1})(t)&&i(t)},[n,i,s]),predicate:r,isActive:o}}({name:h?.name||"hover",fields:f}),p=co(e=>e.pushObservation),m=(0,oa.useCallback)(e=>{o?.(e),p?.(e)},[o,p]),v=e?{isActive:g.isActive,predicate:g.predicate}:null,[b,x]=(0,oa.useState)(null),k=(0,oa.useRef)(!1),w=c||n[0],S=(0,oa.useMemo)(()=>{if(!l||null==b||!w)return null;const e=b,t=w;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[l,b,w]),M=(0,oa.useCallback)((e,n)=>{const r=!e&&k.current&&!!u?.enabled&&u.tapToLockTooltip;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===h?.mode&&h.xField){const n=Pa(e,t,h.xField);null!=n&&function(e,t,n){const r=ga.positions.get(e);r?.locked||r&&r.xValue===t&&r.sourceId===n||(ga={positions:new Map(ga.positions).set(e,{xValue:t,sourceId:n})},pa())}(h.name||"hover",n,d)}"x-position"!==h?.mode&&y.onHover(t)}else"x-position"!==h?.mode||r||ma(h.name||"hover",d),"x-position"===h?.mode||r||y.onHover(null);if(l&&w)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=t?.[w];x(null!=n?n+"":null)}else r||x(null);(o||p)&&qs({onObservation:m,datum:e?_a(e):null,x:e?.x,y:e?.y,chartType:i||"unknown",chartId:s,context:n})},[t,y,h,d,o,i,s,p,m,l,w,u]),A=(0,oa.useCallback)((n=!0)=>{k.current=!1,t&&"x-position"!==h?.mode&&y.onHover(null),e&&u?.tapToSelect&&g.clear(),n&&l&&x(null),"x-position"===h?.mode&&(va(h.name||"hover",d),ma(h.name||"hover",d))},[t,h,y,e,u,g,l,d]),C=(0,oa.useCallback)((n,r)=>{const c=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),v=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===h?.mode&&h.xField&&n){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]);const t=Pa(n,e,h.xField);null!=t&&function(e,t,n){const r=ga.positions.get(e);if(r?.locked){const t=new Map(ga.positions);return t.delete(e),ga={positions:t},pa(),!1}ga={positions:new Map(ga.positions).set(e,{xValue:t,sourceId:n,locked:!0})},pa()}(h.name||"hover",t,d)}if(c)if(n){k.current=!0;const r=_a(n);if(t&&"x-position"!==h?.mode&&y.onHover(r),e&&u?.tapToSelect&&f.length>0){const e={};for(const t of f){const n=r[t];void 0!==n&&(e[t]=[n])}Wa(e)&&g.selectPoints(e)}if(l&&w){const e=r?.[w];x(null!=e?e+"":null)}}else v&&A();if(n||v){if(n&&a){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]),a(e,{x:n.x??0,y:n.y??0})}(o||p)&&Ys({onObservation:m,datum:n?_a(n):null,x:n?.x,y:n?.y,chartType:i||"unknown",chartId:s,context:r})}},[a,o,p,m,i,s,h,d,u,t,y,e,g,f,l,w,A]);return(0,oa.useEffect)(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&k.current&&A()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,A]),(0,oa.useEffect)(()=>()=>{k.current&&A(!1)},[A]),(0,oa.useEffect)(()=>{if("x-position"!==h?.mode)return;const e=h.name||"hover";return()=>{va(e,d),ma(e,d)}},[h?.mode,h?.name,d]),{activeSelectionHook:v,hoverSelectionHook:S,customHoverBehavior:M,customClickBehavior:C,crosshairSourceId:d}}function Ha({data:e,colorBy:t,colorScale:n,showLegend:r,legendPosition:o="right",userMargin:i,defaults:s={top:50,bottom:60,left:70,right:40},categories:a,additionalLegend:l}){const c=(0,aa.useContext)(xa),u=null!==(0,aa.useContext)(ka),d=void 0!==r?r:!c&&!!t,h=!!t&&(d||u),f=(0,oa.useMemo)(()=>{if(!h)return[];if(void 0!==a)return a;const n=new Set;for(const r of e){const e="function"==typeof t?t(r):r[t];null!=e&&n.add(e+"")}return Array.from(n)},[a,t,e,h]);!function(e){const t=(0,aa.useContext)(ka),n=(0,aa.useId)(),r=function(e){const t=new Set,n=[];for(const r of e)t.has(r)||(t.add(r),n.push(r));return n}(e),o=(0,aa.useRef)([]);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(o.current,r)||(o.current=r);const i=o.current;wa(()=>{if(t)return()=>t.unregisterCategories(n)},[t,n]),wa(()=>{t&&t.registerCategories(n,i)},[t,n,i])}(u&&t?f:[]);const g=(0,oa.useMemo)(()=>{if(!d||!t)return;const r=function({data:e,colorBy:t,colorScale:n,getColor:r,strokeColor:o,strokeWidth:i,categories:s}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==o&&(n.stroke=o),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:(s&&s.length>0?s:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((o,i)=>{const s=e.find("function"==typeof t?e=>t(e)===o:e=>e[t]===o),a=s?r(s,t,n):n?n(o):$t[i%$t.length];return{label:o+"",color:a}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:zt,categories:f});return 0!==r.legendGroups.reduce((e,t)=>e+t.items.length,0)?r:void 0},[d,t,e,n,f]),y=(0,oa.useMemo)(()=>function(...e){let t;for(const n of e)n&&(t=Rr(t)&&Rr(n)?{legendGroups:[...t.legendGroups,...n.legendGroups]}:n);return t}(g,l),[g,l]),p=(0,oa.useMemo)(()=>{const e="number"==typeof i?{top:i,bottom:i,left:i,right:i}:i??{},t=t=>{const n=e[t];return"number"==typeof n?n:s[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},r=t=>"number"==typeof e[t];return y&&("right"===o&&!r("right")&&110>n.right?n.right=110:"left"===o&&!r("left")&&110>n.left?n.left=110:"top"===o&&!r("top")&&50>n.top?n.top=50:"bottom"===o&&!r("bottom")&&80>n.bottom&&(n.bottom=80)),n},[s,i,y,o]);return{legend:y,margin:p,legendPosition:o}}function Fa(e,t,n){return function(e,t,n){const r=Da[e||"primary"],o=e&&"primary"!==e||!n?.width?r.width:n.width,i=e&&"primary"!==e||!n?.height?r.height:n.height,s=La({...t,mode:e},{width:t.width??o,height:t.height??i}).props,a=s.mode||e||"primary",l=Da[a],c="context"===a||"sparkline"===a,u="primary"===a&&n?.width?n.width:l.width;return{mode:a,width:s.width??u,height:s.height??("primary"===a&&n?.height?n.height:l.height),showAxes:s.showAxes??l.showAxes,showGrid:s.showGrid??l.showGrid,enableHover:s.enableHover??(!!s.linkedHover||l.enableHover),showLegend:s.showLegend??l.showLegend,showLabels:s.showLabels??l.showLabels,title:c?void 0:s.title,description:s.description,summary:s.summary,accessibleTable:s.accessibleTable,xLabel:c?void 0:s.xLabel,yLabel:c?void 0:s.yLabel,categoryLabel:c?void 0:s.categoryLabel,valueLabel:c?void 0:s.valueLabel,marginDefaults:Na(l.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:c,mobileInteraction:Ea(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}(e,t,n)}var qa=require("react");function Ya(e,t){if(!e)return[];const n=[],r=e=>{n.push(e);const o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(r)};return r(e),n}function Xa(e,t,n,r){if(e&&e.length>0)return e;const o=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof r?r(e):e[r];o.add(t),o.add(i)}),Array.from(o).map(e=>({id:e}))}function Ga(e){return"function"==typeof e?e:t=>t[e]||1}function Va({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:r,edgeOpacity:o,baseStyle:i={}}){return s=>{const a={fillOpacity:o,...i};if("function"==typeof e)a.fill=e(s);else if("source"===e){const e="object"==typeof s.source?s.source:null;t&&e?a.fill=zt(e.data||e,t,n):e&&(a.fill=r(e,e.index).fill)}else if("target"===e){const e="object"==typeof s.target?s.target:null;t&&e?a.fill=zt(e.data||e,t,n):e&&(a.fill=r(e,e.index).fill)}else"gradient"===e&&(a.fill="#999",a.fillOpacity=.7*o);return a}}function Ua(e){const{nodes:t,edges:n,inferNodes:r=!0,sourceAccessor:o="source",targetAccessor:i="target",colorBy:s,colorScheme:a,showLegend:l,legendPosition:c,legendInteraction:u,selection:d,linkedHover:h,onObservation:f,onClick:g,mobileInteraction:y,mobileSemantics:p,chartType:m,chartId:v,marginDefaults:b,userMargin:x,width:k,height:w,loading:S,loadingContent:M,emptyContent:A,emptyDataKey:C="edges"}=e,L=(0,qa.useMemo)(()=>$i(n),[n]),j=(0,qa.useMemo)(()=>$i(t),[t]),T=ds(S,k,w,M),E=T?null:us("nodes"===C?void 0===t?void 0:j:void 0===n?void 0:L,k,w,A),D=(0,qa.useMemo)(()=>r?Xa(j,L,o,i):j,[r,j,L,o,i]),R=function(e,t,n){const r=(0,ia.useContext)(sa),o=Oa();return(0,oa.useMemo)(()=>{if(!t)return;const i=r??void 0,s=n??(o&&o.length>0?o:void 0)??"category10";if(0!==e.length){if("function"==typeof t){const n=Array.from(new Set(e.map(e=>t(e)+"")));if(i&&Wa(i)){const e=Ft(n.map(e=>({_cat:e})),"_cat",s);return t=>i[t]||e(t)}return Ft(n.map(e=>({_cat:e})),"_cat",s)}if(i&&Wa(i)){const n=Ft(e,t,s);return e=>i[e]||n(e)}return Ft(e,t,s)}if(i&&Wa(i)){const e=Ft([{_:"a"}],"_",s);return t=>i[t]||e(t)}},[e,t,n,r,o])}(D,s,a),I=Oa(),N=(0,qa.useMemo)(()=>Array.isArray(a)&&a.length>0?a:[...Wt(a,I,Pt)],[a,I]),P=(0,qa.useMemo)(()=>{if(!s)return[];const e=new Set;for(const t of D){const n="function"==typeof s?s(t):t[s];null!=n&&e.add(n+"")}return Array.from(e)},[D,s]),_=function(e,t,n){const[r,o]=(0,oa.useState)(null),[i,s]=(0,oa.useState)(new Set),a=(0,oa.useMemo)(()=>new Set,[]),l=(0,oa.useCallback)(t=>{"highlight"===e&&o(t?t.label:null)},[e]),c=(0,oa.useCallback)(t=>{"isolate"===e&&s(e=>{const r=new Set(e);return r.has(t.label)?r.delete(t.label):r.add(t.label),r.size===n.length?new Set:r})},[e,n.length]),u=(0,oa.useMemo)(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=r?{isActive:!0,predicate:e=>(n?e[n]:"function"==typeof t?t(e):null)===r}:"isolate"===e&&i.size>0?{isActive:!0,predicate:e=>{const r=n?e[n]:"function"==typeof t?t(e):null;return i.has(r)}}:null},[e,t,r,i]);return{highlightedCategory:"highlight"===e?r:null,isolatedCategories:"isolate"===e?i:a,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}(u,s,P),{legend:W,margin:$,legendPosition:O}=Ha({data:D,colorBy:s,colorScale:R,showLegend:l,legendPosition:c,userMargin:x,defaults:b,categories:P}),B=(0,qa.useMemo)(()=>Ea(y,{width:k,mobileSemantics:p}),[y,k,p]),z=za({selection:d,linkedHover:h,fallbackFields:s?["string"==typeof s?s:""]:[],unwrapData:!0,onObservation:f,onClick:g,mobileInteraction:B,chartType:m,chartId:v}),{customHoverBehavior:H,customClickBehavior:F,activeSelectionHook:q,hoverSelectionHook:Y,crosshairSourceId:X}=z;return{safeNodes:D,safeEdges:L,colorScale:R,effectivePalette:N,themeCategorical:I,allCategories:P,legendState:_,legend:W,margin:$,legendPosition:O,mobileInteraction:B,customHoverBehavior:H,customClickBehavior:F,activeSelectionHook:q,hoverSelectionHook:Y,crosshairSourceId:X,loadingEl:T,emptyEl:E}}function Ka(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return e??((...e)=>({}));const n={};return void 0!==t.stroke&&(n.stroke=t.stroke),void 0!==t.strokeWidth&&(n.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(n.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...n}):(...e)=>({...n})}function Qa(e){if(null==e)return()=>{};const t="function"==typeof e?e:t=>t[e];return e=>Ja(t(e))}function Za(e,t){const n=Qa(t??"value"),r=null==e?void 0:"function"==typeof e?e:t=>t[e];return e=>{const t=r?r(e):void 0;return{value:n(e),category:null==t?void 0:t+""}}}function Ja(e){if("number"==typeof e)return Number.isFinite(e)?e:void 0;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}function el(e,t,n){const r=null!=e.axis?n[e.axis]:null!=e.field?t[e.field]:n.value;if(void 0!==e.eq&&r!==e.eq)return!1;if(void 0!==e.ne&&r===e.ne)return!1;if(void 0!==e.in&&!e.in.includes(r))return!1;if(void 0===e.gt&&void 0===e.gte&&void 0===e.lt&&void 0===e.lte&&void 0===e.within&&void 0===e.outside)return!0;const o=Ja(r);if(void 0===o)return!1;if(void 0!==e.gt&&e.gt>=o)return!1;if(void 0!==e.gte&&e.gte>o)return!1;if(void 0!==e.lt&&o>=e.lt)return!1;if(void 0!==e.lte&&o>e.lte)return!1;if(void 0!==e.within){const[t,n]=e.within;if(t>o||o>n)return!1}if(void 0!==e.outside){const[t,n]=e.outside;if(o>=t&&n>=o)return!1}return!0}function tl(e,t,n){const r=e.when;return void 0===r||!0===r||!1!==r&&("function"==typeof r?r(t,n):el(r,t,n))}function nl(e,t,n){if(!t||0===t.length)return{};let r={};for(const o of t){if(!tl(o,e,n))continue;const t="function"==typeof o.style?o.style(e,n):o.style;t&&(r={...r,...t})}return r}function rl(e,t,n,r=e=>e){const o=e??(()=>({}));return t&&0!==t.length?(e,i)=>{const s=r(e),a={...o(e,i)};return Object.assign(a,nl(s,t,n(s,i))),a}:o}function ol(e,t){const n=e.length,r=t.length,o=Array(r+1);for(let e=0;r>=e;e++)o[e]=e;for(let i=1;n>=i;i++){let n=o[0];o[0]=i;for(let s=1;r>=s;s++){const r=o[s];o[s]=e[i-1]===t[s-1]?n:1+Math.min(n,o[s],o[s-1]),n=r}}return o[r]}function il(e,t){if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(function(e,t,n=3){let r,o=n+1;for(const n of t){const t=ol(e.toLowerCase(),n.toLowerCase());o>t&&(o=t,r=n)}return o>n?void 0:r}(e,t,3)??null)}function sl({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function al({componentName:e,nodes:t,edges:n,nodesRequired:r=!1,edgesRequired:o=!0,accessors:i}){if(null==t&&null==n)return null;if(o&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(r&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=(s=t,s.length>3?[s[0],s[Math.floor(s.length/2)],s[s.length-1]]:[...s]).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[r,o]of Object.entries(i))if(o&&"string"==typeof o&&!(o in n)){const n=il(o,t),i=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${o}" not found in node data. Available fields: ${t.join(", ")}.${i}`}}}var s;return null}function ll(e){const{title:t,description:n,summary:r,accessibleTable:o,className:i,animate:s,axisExtent:a,autoPlaceAnnotations:l}=e,c={};return t&&(c.title=t),n&&(c.description=n),r&&(c.summary=r),void 0!==o&&(c.accessibleTable=o),i&&(c.className=i),null!=s&&(c.animate=s),void 0!==a&&(c.axisExtent=a),void 0!==l&&(c.autoPlaceAnnotations=l),c}function cl(e){const{linkedHover:t,selection:n,onObservation:r,onClick:o,hoverRadius:i,hoverHighlight:s,forceHoverBehavior:a,forceClickBehavior:l,mobileInteraction:c,customHoverBehavior:u,customClickBehavior:d,linkedHoverInClickPredicate:h=!0}=e,f={};r&&(f.annotationObservationCallback=r);const g=c?.enabled?Math.max(i??30,Math.ceil((c.targetSize||44)/2),24):i;return(a||t||r||o||s)&&(f.customHoverBehavior=u),d&&(l||(h?r||o||t:r||o)||c?.enabled&&(c.tapToSelect||c.tapToLockTooltip)&&(t||s||n))&&(f.customClickBehavior=d),null!=g&&(f.hoverRadius=g),f}var ul=require("react/jsx-runtime"),dl=(0,ra.forwardRef)(function(e,t){const n=(0,ra.useRef)(null);na(t,{variant:"network",frameRef:n});const r=Fa(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLegend:e.showLegend,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{nodes:o,edges:i,margin:s,className:a,nodeIdAccessor:l,nodeIDAccessor:c,sourceAccessor:u="source",targetAccessor:d="target",nodeLabel:h,colorBy:f,colorScheme:g,styleRules:y,nodeSize:p=8,nodeSizeRange:m=[5,20],nodeStroke:v,nodeStrokeWidth:b,edgeWidth:x,edgeColor:k,edgeOpacity:w,iterations:S=300,forceStrength:M=.1,layoutExecution:A="auto",layoutLoadingContent:C,onLayoutStateChange:L,tooltip:j,frameProps:T={},onObservation:E,onClick:D,chartId:R,selection:I,linkedHover:N,loading:P,loadingContent:_,emptyContent:W,legendInteraction:$,legendPosition:O,stroke:B,strokeWidth:z,opacity:H}=e,F=l??c??"id",{width:q,height:Y,enableHover:X,showLegend:G,showLabels:V=!1,title:U,description:K,summary:Q,accessibleTable:Z}=r,J=Ua({nodes:o,edges:i,inferNodes:!1,nodeIdAccessor:F,sourceAccessor:u,targetAccessor:d,colorBy:f,colorScheme:g,showLegend:G,legendPosition:O,legendInteraction:$,selection:I,linkedHover:N,onObservation:E,onClick:D,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"ForceDirectedGraph",chartId:R,marginDefaults:r.marginDefaults,userMargin:s,width:q,height:Y,loading:P,loadingContent:_,emptyContent:W,emptyDataKey:"nodes"}),ee=(0,ra.useMemo)(()=>new Map,[]),te=(0,ra.useMemo)(()=>e=>{const t={};return t.fill=f?zt(e.data||e,f,J.colorScale):Ba(void 0,J.themeCategorical,g,void 0,ee),"number"==typeof p&&(t.r=p),t},[f,J.colorScale,p,J.themeCategorical,g,ee]),ne=(0,ra.useMemo)(()=>Za(f,"number"==typeof p?void 0:p),[f,p]),re=(0,ra.useMemo)(()=>Ka(rl(te,y,ne,e=>e.data||e),{stroke:v??B,strokeWidth:b??z,opacity:H}),[te,y,ne,v,B,b,z,H]),oe=k??B??"#999",ie=w??H??.6,se=z??1,ae=(0,ra.useMemo)(()=>e=>{const t=e.data||e;let n;if(void 0===x)n=se;else if("number"==typeof x)n=x;else if("function"==typeof x)n=x(t);else{const e=t[x],r="number"==typeof e?e:Number(e);n=Number.isFinite(r)&&r>0?r:se}return{stroke:oe,strokeWidth:n,opacity:ie}},[x,oe,ie,se]),le=(0,ra.useMemo)(()=>{if(V&&h)return"function"==typeof h?h:e=>e.data?.[h]??e[h]??e.id},[V,h]),ce=al({componentName:"ForceDirectedGraph",nodes:o,edges:i,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:F}});return ce?(0,ul.jsx)(rs,{componentName:"ForceDirectedGraph",message:ce,width:q,height:Y}):J.loadingEl?J.loadingEl:J.emptyEl?J.emptyEl:(0,ul.jsx)(as,{componentName:"ForceDirectedGraph",width:q,height:Y,children:(0,ul.jsx)(ea,{ref:n,chartType:"force",...null!=o&&{nodes:J.safeNodes},...null!=i&&{edges:J.safeEdges},size:[q,Y],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:J.margin,nodeIDAccessor:F,sourceAccessor:u,targetAccessor:d,iterations:S,forceStrength:M,layoutExecution:A,layoutLoadingContent:C,onLayoutStateChange:L,nodeStyle:re,edgeStyle:ae,colorBy:f,colorScheme:J.effectivePalette,nodeSize:p,nodeSizeRange:m,nodeLabel:le,showLabels:V,enableHover:X,tooltipContent:!1===j?()=>null:zn(j)||void 0,...cl({linkedHover:N,selection:I,onObservation:E,onClick:D,mobileInteraction:J.mobileInteraction,customHoverBehavior:J.customHoverBehavior,customClickBehavior:J.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:J.legend,legendPosition:J.legendPosition,...$&&"none"!==$&&{legendHoverBehavior:J.legendState.onLegendHover,legendClickBehavior:J.legendState.onLegendClick,legendHighlightedCategory:J.legendState.highlightedCategory,legendIsolatedCategories:J.legendState.isolatedCategories},className:a,title:U,description:K,summary:Q,accessibleTable:Z,...null!=e.animate&&{animate:e.animate},...T})})});dl.displayName="ForceDirectedGraph";var hl=require("react"),fl=require("d3-force"),gl=1e3;function yl(e,t,n={}){const r=n.iterations??260,o=n.repulsion??5200,i=n.linkDistance??165,s=n.linkStrength??.045,a=n.centerStrength??.018,l=n.damping??.84,c=n.nodeRadius??12,u=n.nodePadding??3,d=n.inset??.06,h=function(e){let t=e>>>0;return function(){t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}(n.seed??1),f=new Map;for(const t of e)f.set(t.id,0);for(const e of t)f.set(e.source,(f.get(e.source)??0)+1),f.set(e.target,(f.get(e.target)??0)+1);const g=gl/2,y=e.map(e=>({id:e.id,data:e,x:200+600*h(),y:200+600*h()})),p=new Set(e.map(e=>e.id)),m=t.filter(e=>p.has(e.source)&&p.has(e.target)).map(e=>({source:e.source,target:e.target}));if(r>0){const e=(0,fl.forceSimulation)(y).randomSource(h).alphaDecay(1-Math.pow(.001,1/r)).velocityDecay(Math.max(0,Math.min(1,1-l))).force("charge",(0,fl.forceManyBody)().strength(e=>{const t=f.get(e.id)??0;return 2.5*-Math.sqrt(o)*Math.sqrt(t+1)})).force("collide",(0,fl.forceCollide)(e=>(e=>"function"==typeof c?c(e.data):c)(e)+u).strength(.9).iterations(2)).force("center",(0,fl.forceCenter)(g,g).strength(.8)).force("x",(0,fl.forceX)(g).strength(a)).force("y",(0,fl.forceY)(g).strength(a));m.length>0&&e.force("link",(0,fl.forceLink)(m).id(e=>e.id).distance(i).strength(e=>{const t="string"==typeof e.target?e.target:e.target.id,n=Math.max(1,Math.min(f.get("string"==typeof e.source?e.source:e.source.id)??1,f.get(t)??1));return s/.045/n})),e.stop();for(let t=0;r>t;t+=1)e.tick()}let v=1/0,b=1/0,x=-1/0,k=-1/0;for(const e of y){const t=e.x??g,n=e.y??g;v>t&&(v=t),b>n&&(b=n),t>x&&(x=t),n>k&&(k=n)}const w=x-v,S=k-b,M={};for(const e of y)M[e.id]={x:0===w?.5:d+((e.x??g)-v)/w*(1-2*d),y:0===S?.5:d+((e.y??g)-b)/S*(1-2*d)};return M}var pl=16,ml=new WeakMap;function vl(e){const t=[];for(const n of Object.keys(e).sort()){const r=e[n];if(void 0!==r){if("function"==typeof r)return null;t.push(`${n}:${r+""}`)}}return t.join("|")}function bl(e,t,n){return null==n?null:ml.get(e)?.get(t)?.get(n)??null}function xl(e,t,n,r){if(null==n)return;let o=ml.get(e);o||(o=new WeakMap,ml.set(e,o));let i=o.get(t);if(i||(i=new Map,o.set(t,i)),!i.has(n)&&i.size>=pl){const e=i.keys().next().value;void 0!==e&&i.delete(e)}i.set(n,r)}function kl(e,t,n={}){const r=Xi(),{seed:o,iterations:i,repulsion:s,linkDistance:a,linkStrength:l,centerStrength:c,damping:u,nodeRadius:d,nodePadding:h,inset:f,execution:g,workerThreshold:y}=n,p=(0,hl.useMemo)(()=>({seed:o,iterations:i,repulsion:s,linkDistance:a,linkStrength:l,centerStrength:c,damping:u,nodeRadius:d,nodePadding:h,inset:f,execution:g,workerThreshold:y}),[o,i,s,a,l,c,u,d,h,f,g,y]),m=(0,hl.useRef)(r),[v,b]=(0,hl.useState)(()=>{if("undefined"==typeof window||r){const n=yl(e,t,p);return xl(e,t,vl(p),n),{positions:n,status:"ready",error:null}}const n=bl(e,t,vl(p));return n?{positions:n,status:"ready",error:null}:{positions:null,status:"pending",error:null}});return(0,hl.useEffect)(()=>{if(m.current)return void(m.current=!1);const n=vl(p),r=bl(e,t,n);if(r)return void b(e=>"ready"===e.status&&e.positions===r?e:{positions:r,status:"ready",error:null});const o=new AbortController;return b(e=>({positions:e.positions,status:"pending",error:null})),async function(e,t,n={}){const{execution:r="auto",signal:o,workerThreshold:i,nodeRadius:s,...a}=n,l=a.iterations??260;if(!ys()||!gs(r,e.length,t.length,l,i))return yl(e,t,{...a,nodeRadius:s});const c={kind:"normalized",nodes:e.map(e=>({...e})),edges:t.map(e=>({...e})),options:a,nodeRadii:"function"==typeof s?Object.fromEntries(e.map(e=>[e.id,s(e)])):null==s?void 0:Object.fromEntries(e.map(e=>[e.id,s]))};try{return(await bs(c,o)).positions}catch(n){if("AbortError"===n?.name)throw n;return yl(e,t,{...a,nodeRadius:s})}}(e,t,{...p,signal:o.signal}).then(r=>{xl(e,t,n,r),b({positions:r,status:"ready",error:null})}).catch(e=>{"AbortError"!==e.name&&b(t=>({positions:t.positions,status:"error",error:e}))}),()=>o.abort()},[e,t,p]),v}var wl=require("react"),Sl=require("react/jsx-runtime"),Ml=(0,wl.forwardRef)(function(e,t){const n=(0,wl.useRef)(null);na(t,{variant:"network",frameRef:n,overrides:{getData:()=>n.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const r=Fa(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:800,height:600}),{nodes:o,edges:i,margin:s,className:a,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:h,colorScheme:f,styleRules:g,edgeColorBy:y="source",orientation:p="horizontal",nodeAlign:m="justify",nodePaddingRatio:v=.05,nodeWidth:b=15,nodeLabel:x,edgeOpacity:k=.5,edgeSort:w,tooltip:S,frameProps:M={},onObservation:A,onClick:C,chartId:L,selection:j,linkedHover:T,loading:E,loadingContent:D,emptyContent:R,showLegend:I,legendPosition:N,legendInteraction:P,stroke:_,strokeWidth:W,opacity:$}=e,{width:O,height:B,enableHover:z,showLabels:H=!0,title:F,description:q,summary:Y,accessibleTable:X}=r,G=Ua({nodes:o,edges:i,inferNodes:!0,nodeIdAccessor:d,sourceAccessor:l,targetAccessor:c,colorBy:h,colorScheme:f,showLegend:I,legendPosition:N,legendInteraction:P,selection:j,linkedHover:T,onObservation:A,onClick:C,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"SankeyDiagram",chartId:L,marginDefaults:r.marginDefaults,userMargin:s,width:O,height:B,loading:E,loadingContent:D,emptyContent:R}),V=(0,wl.useMemo)(()=>new Map,[]),U=(0,wl.useMemo)(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?zt(e.data||e,h,G.colorScale):Ba(void 0,G.themeCategorical,f,void 0,V),t},[h,G.colorScale,G.themeCategorical,f,V]),K=(0,wl.useMemo)(()=>Za(h,u),[h,u]),Q=(0,wl.useMemo)(()=>Ka(rl(U,g,K,e=>e.data||e),{stroke:_,strokeWidth:W,opacity:$}),[U,g,K,_,W,$]),Z=(0,wl.useMemo)(()=>Va({edgeColorBy:y,colorBy:h,colorScale:G.colorScale,nodeStyleFn:Q,edgeOpacity:k,baseStyle:{stroke:"none",strokeWidth:0}}),[y,h,G.colorScale,Q,k]),J=(0,wl.useMemo)(()=>Ka(Z,{stroke:_,strokeWidth:W,opacity:$}),[Z,_,W,$]),ee=(0,wl.useMemo)(()=>{if(!H)return;const e=x||d;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[H,x,d]),te=al({componentName:"SankeyDiagram",edges:i,edgesRequired:!0});return te?(0,Sl.jsx)(rs,{componentName:"SankeyDiagram",message:te,width:O,height:B}):G.loadingEl?G.loadingEl:G.emptyEl?G.emptyEl:(0,Sl.jsx)(as,{componentName:"SankeyDiagram",width:O,height:B,children:(0,Sl.jsx)(ea,{ref:n,chartType:"sankey",...G.safeNodes.length>0&&{nodes:G.safeNodes},...null!=i&&{edges:G.safeEdges},size:[O,B],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:G.margin,nodeIDAccessor:d,sourceAccessor:l,targetAccessor:c,valueAccessor:u,orientation:p,nodeAlign:m,nodePaddingRatio:v,nodeWidth:b,nodeStyle:Q,edgeStyle:J,colorBy:h,colorScheme:G.effectivePalette,edgeColorBy:y,edgeOpacity:k,edgeSort:w,nodeLabel:ee,showLabels:H,enableHover:z,tooltipContent:!1===S?()=>null:zn(S)||void 0,...cl({linkedHover:T,selection:j,onObservation:A,onClick:C,mobileInteraction:G.mobileInteraction,customHoverBehavior:G.customHoverBehavior,customClickBehavior:G.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:G.legend,legendPosition:G.legendPosition,...P&&"none"!==P&&{legendHoverBehavior:G.legendState.onLegendHover,legendClickBehavior:G.legendState.onLegendClick,legendHighlightedCategory:G.legendState.highlightedCategory,legendIsolatedCategories:G.legendState.isolatedCategories},className:a,title:F,description:q,summary:Y,accessibleTable:X,...null!=e.animate&&{animate:e.animate},...M})})});Ml.displayName="SankeyDiagram";var Al=require("react"),Cl=require("react/jsx-runtime"),Ll=(0,Al.forwardRef)(function(e,t){const n=(0,Al.useRef)(null);na(t,{variant:"network",frameRef:n,overrides:{getData:()=>n.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const r=Fa(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{nodes:o,edges:i,margin:s,className:a,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:h,colorScheme:f,styleRules:g,edgeColorBy:y="source",padAngle:p=.01,groupWidth:m=20,sortGroups:v,nodeLabel:b,edgeOpacity:x=.5,tooltip:k,frameProps:w={},onObservation:S,onClick:M,chartId:A,selection:C,linkedHover:L,loading:j,loadingContent:T,emptyContent:E,legendInteraction:D,stroke:R,strokeWidth:I,opacity:N}=e,{width:P,height:_,enableHover:W,showLabels:$=!0,title:O,description:B,summary:z,accessibleTable:H}=r,F=Ua({nodes:o,edges:i,inferNodes:!0,nodeIdAccessor:d,sourceAccessor:l,targetAccessor:c,colorBy:h,colorScheme:f,showLegend:!1,legendInteraction:D,selection:C,linkedHover:L,onObservation:S,onClick:M,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"ChordDiagram",chartId:A,marginDefaults:r.marginDefaults,userMargin:s,width:P,height:_,loading:j,loadingContent:T,emptyContent:E}),q=(0,Al.useMemo)(()=>new Map,[]),Y=(0,Al.useMemo)(()=>new Map,[]),X=F.safeNodes.length>0,G=(0,Al.useMemo)(()=>{if(X)return(e,t)=>{const n={stroke:"black",strokeWidth:1};if(h)n.fill=zt(e.data||e,h,F.colorScale);else{const r=Array.isArray(f)?f:Nt[f]||Pt,o=Array.isArray(r)?r:Pt,i=(e.id??e.data?.[d]??"")+"";Y.has(i)||Y.set(i,Y.size);const s=e.index??t??Y.get(i);n.fill=o[s%o.length]}return n}},[X,h,F.colorScale,f,d,Y]),V=(0,Al.useMemo)(()=>Za(h),[h]),U=(0,Al.useMemo)(()=>{if(G||g&&g.length>0)return Ka(rl(G,g,V,e=>e.data||e),{stroke:R,strokeWidth:I,opacity:N})},[G,g,V,R,I,N]),K=(0,Al.useMemo)(()=>{if(X)return Va({edgeColorBy:y,colorBy:h,colorScale:F.colorScale,nodeStyleFn:U||(e=>({fill:Ba(void 0,F.themeCategorical,f,void 0,q)})),edgeOpacity:x,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:x}})},[X,y,h,F.colorScale,U,x,F.themeCategorical,f,q]),Q=(0,Al.useMemo)(()=>K?Ka(K,{stroke:R,strokeWidth:I,opacity:N}):void 0,[K,R,I,N]),Z=(0,Al.useMemo)(()=>{if(!$)return;const e=b||d;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[$,b,d]),J=al({componentName:"ChordDiagram",edges:i,edgesRequired:!0});return J?(0,Cl.jsx)(rs,{componentName:"ChordDiagram",message:J,width:P,height:_}):F.loadingEl?F.loadingEl:F.emptyEl?F.emptyEl:(0,Cl.jsx)(as,{componentName:"ChordDiagram",width:P,height:_,children:(0,Cl.jsx)(ea,{ref:n,chartType:"chord",...F.safeNodes.length>0&&{nodes:F.safeNodes},...null!=i&&{edges:F.safeEdges},size:[P,_],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:F.margin,nodeIDAccessor:d,sourceAccessor:l,targetAccessor:c,valueAccessor:u,padAngle:p,groupWidth:m,sortGroups:v,nodeStyle:U,edgeStyle:Q,colorBy:h,colorScheme:F.effectivePalette,edgeColorBy:y,edgeOpacity:x,nodeLabel:Z,showLabels:$,enableHover:W,tooltipContent:!1===k?()=>null:zn(k)||void 0,...cl({linkedHover:L,selection:C,onObservation:S,onClick:M,mobileInteraction:F.mobileInteraction,customHoverBehavior:F.customHoverBehavior,customClickBehavior:F.customClickBehavior,linkedHoverInClickPredicate:!1}),...D&&"none"!==D&&{legendHoverBehavior:F.legendState.onLegendHover,legendClickBehavior:F.legendState.onLegendClick,legendHighlightedCategory:F.legendState.highlightedCategory,legendIsolatedCategories:F.legendState.isolatedCategories},className:a,title:O,description:B,summary:z,accessibleTable:H,...null!=e.animate&&{animate:e.animate},...w})})});Ll.displayName="ChordDiagram";var jl=require("react"),Tl=require("react/jsx-runtime");function El(e){const t=Fa(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:r,className:o,layout:i="tree",orientation:s="vertical",childrenAccessor:a="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,colorByDepth:h=!1,edgeStyle:f="curve",nodeLabel:g,nodeSize:y=5,tooltip:p,frameProps:m={},onObservation:v,onClick:b,chartId:x,selection:k,linkedHover:w,loading:S,loadingContent:M,legendInteraction:A,stroke:C,strokeWidth:L,opacity:j}=e,{width:T,height:E,enableHover:D,showLabels:R=!0,title:I,description:N,summary:P,accessibleTable:_}=t,W=Ua({nodes:(0,jl.useMemo)(()=>Ya(n??null,a),[n,a]),edges:void 0,inferNodes:!1,colorBy:h?void 0:u,colorScheme:d,showLegend:!1,legendInteraction:A,selection:k,linkedHover:w,onObservation:v,onClick:b,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"TreeDiagram",chartId:x,marginDefaults:t.marginDefaults,userMargin:r,width:T,height:E,loading:S,loadingContent:M}),$=(0,jl.useMemo)(()=>new Map,[]),O=(0,jl.useMemo)(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?Ot[(e.depth||0)%Ot.length]:u?zt(e.data||e,u,W.colorScale):Ba(void 0,W.themeCategorical,d,void 0,$),t},[u,h,W.colorScale,W.themeCategorical,d,$]),B=(0,jl.useMemo)(()=>Ka(O,{stroke:C,strokeWidth:L,opacity:j}),[O,C,L,j]),z=(0,jl.useMemo)(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),H=(0,jl.useMemo)(()=>Ka(z,{stroke:C,strokeWidth:L,opacity:j}),[z,C,L,j]),F=(0,jl.useMemo)(()=>{if("treemap"===i||"circlepack"===i||"partition"===i)return Ga(l)},[i,l]),q=sl({componentName:"TreeDiagram",data:n});return q?(0,Tl.jsx)(rs,{componentName:"TreeDiagram",message:q,width:T,height:E}):W.loadingEl?W.loadingEl:(0,Tl.jsx)(as,{componentName:"TreeDiagram",width:T,height:E,children:(0,Tl.jsx)(ea,{chartType:i,...null!=n&&{data:n},size:[T,E],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:W.margin,nodeIDAccessor:c,childrenAccessor:a,hierarchySum:F,treeOrientation:s,edgeType:f,nodeStyle:B,edgeStyle:H,colorBy:u,colorScheme:W.effectivePalette,colorByDepth:h,nodeSize:y,nodeLabel:R?g||c:void 0,showLabels:R,enableHover:D,tooltipContent:!1===p?()=>null:zn(p)||void 0,...cl({linkedHover:w,selection:k,onObservation:v,onClick:b,mobileInteraction:W.mobileInteraction,customHoverBehavior:W.customHoverBehavior,customClickBehavior:W.customClickBehavior,linkedHoverInClickPredicate:!1}),...A&&"none"!==A&&{legendHoverBehavior:W.legendState.onLegendHover,legendClickBehavior:W.legendState.onLegendClick,legendHighlightedCategory:W.legendState.highlightedCategory,legendIsolatedCategories:W.legendState.isolatedCategories},className:o,title:I,description:N,summary:P,accessibleTable:_,...null!=e.animate&&{animate:e.animate},...m})})}El.displayName="TreeDiagram";var Dl=require("react"),Rl=require("react"),Il=require("react/jsx-runtime");function Nl(e){const t=Fa(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,linkedHover:e.linkedHover,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:r,className:o,childrenAccessor:i="children",valueAccessor:s="value",nodeIdAccessor:a="name",colorBy:l,colorScheme:c,colorByDepth:u=!1,labelMode:d="leaf",nodeLabel:h,padding:f=4,paddingTop:g,nodeStyle:y,tooltip:p,frameProps:m={},selection:v,linkedHover:b,onObservation:x,onClick:k,chartId:w,loading:S,loadingContent:M,legendInteraction:A,stroke:C,strokeWidth:L,opacity:j}=e,{nodeStyle:T,...E}=m,{width:D,height:R,enableHover:I,showLabels:N=!0,title:P,description:_,summary:W,accessibleTable:$}=t,O=Ua({nodes:(0,Dl.useMemo)(()=>Ya(n??null,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:u?void 0:l,colorScheme:c,showLegend:!1,legendInteraction:A,selection:v,linkedHover:b,onObservation:x,onClick:k,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"Treemap",chartId:w,marginDefaults:t.marginDefaults,userMargin:r,width:D,height:R,loading:S,loadingContent:M}),B=function(e){const t=or(e=>e.theme.colors.selectionOpacity);return(0,Rl.useMemo)(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}(v),z=O.customHoverBehavior,H=(0,Dl.useCallback)(e=>{if(!e)return z(null);const t=e.data||e;z({data:t?.data||t})},[z]),F=(0,Dl.useMemo)(()=>new Map,[]),q=(0,Dl.useMemo)(()=>e=>{const t={stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8};return t.fill=u?Ot[(e.depth||0)%Ot.length]:l?zt(e.data||e,l,O.colorScale):Ba(void 0,O.themeCategorical,c,void 0,F),t},[l,u,O.colorScale,O.themeCategorical,c,F]),Y=(0,Dl.useMemo)(()=>y||T?e=>({...q(e),...T?T(e)??{}:{},...y?y(e)??{}:{}}):q,[q,y,T]),X=(0,Dl.useMemo)(()=>Ka(Y,{stroke:C,strokeWidth:L,opacity:j}),[Y,C,L,j]),G=(0,Dl.useMemo)(()=>O.activeSelectionHook?e=>{const t={...X(e)};if(O.activeSelectionHook.isActive)if(O.activeSelectionHook.predicate(e.data||e))B?.selectedStyle&&Object.assign(t,B.selectedStyle);else{const e=B?.unselectedOpacity??Sa;t.opacity=e,t.fillOpacity=e,t.strokeOpacity=e,B?.unselectedStyle&&Object.assign(t,B.unselectedStyle)}return t}:X,[X,O.activeSelectionHook,B]),V=(0,Dl.useMemo)(()=>Ga(s),[s]),U=void 0!==g?g:!N||"parent"!==d&&"all"!==d?void 0:18,K=sl({componentName:"Treemap",data:n});return K?(0,Il.jsx)(rs,{componentName:"Treemap",message:K,width:D,height:R}):O.loadingEl?O.loadingEl:(0,Il.jsx)(as,{componentName:"Treemap",width:D,height:R,children:(0,Il.jsx)(ea,{chartType:"treemap",...null!=n&&{data:n},size:[D,R],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:O.margin,nodeIDAccessor:a,childrenAccessor:i,hierarchySum:V,padding:f,paddingTop:U,nodeStyle:G,colorBy:l,colorScheme:O.effectivePalette,colorByDepth:u,nodeLabel:N?h||a:void 0,showLabels:N,labelMode:d,enableHover:I,tooltipContent:!1===p?()=>null:zn(p)||void 0,...cl({linkedHover:b,selection:v,onObservation:x,onClick:k,mobileInteraction:O.mobileInteraction,customHoverBehavior:H,customClickBehavior:O.customClickBehavior,linkedHoverInClickPredicate:!1}),...A&&"none"!==A&&{legendHoverBehavior:O.legendState.onLegendHover,legendClickBehavior:O.legendState.onLegendClick,legendHighlightedCategory:O.legendState.highlightedCategory,legendIsolatedCategories:O.legendState.isolatedCategories},className:o,title:P,description:_,summary:W,accessibleTable:$,...null!=e.animate&&{animate:e.animate},...E})})}Nl.displayName="Treemap";var Pl=require("react"),_l=require("react/jsx-runtime");function Wl(e){const t=Fa(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:r,className:o,childrenAccessor:i="children",valueAccessor:s="value",nodeIdAccessor:a="name",colorBy:l,colorScheme:c,colorByDepth:u=!1,nodeLabel:d,circleOpacity:h=.7,padding:f=4,tooltip:g,frameProps:y={},onObservation:p,onClick:m,chartId:v,selection:b,linkedHover:x,loading:k,loadingContent:w,legendInteraction:S,stroke:M,strokeWidth:A,opacity:C}=e,{width:L,height:j,enableHover:T,showLabels:E=!0,title:D,description:R,summary:I,accessibleTable:N}=t,P=Ua({nodes:(0,Pl.useMemo)(()=>Ya(n??null,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:u?void 0:l,colorScheme:c,showLegend:!1,legendInteraction:S,selection:b,linkedHover:x,onObservation:p,onClick:m,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"CirclePack",chartId:v,marginDefaults:t.marginDefaults,userMargin:r,width:L,height:j,loading:k,loadingContent:w}),_=(0,Pl.useMemo)(()=>new Map,[]),W=(0,Pl.useMemo)(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:h};return t.fill=u?Ot[(e.depth||0)%Ot.length]:l?zt(e.data||e,l,P.colorScale):Ba(void 0,P.themeCategorical,c,void 0,_),t},[l,u,P.colorScale,h,P.themeCategorical,c,_]),$=(0,Pl.useMemo)(()=>Ka(W,{stroke:M,strokeWidth:A,opacity:C}),[W,M,A,C]),O=(0,Pl.useMemo)(()=>Ga(s),[s]),B=sl({componentName:"CirclePack",data:n});return B?(0,_l.jsx)(rs,{componentName:"CirclePack",message:B,width:L,height:j}):P.loadingEl?P.loadingEl:(0,_l.jsx)(as,{componentName:"CirclePack",width:L,height:j,children:(0,_l.jsx)(ea,{chartType:"circlepack",...null!=n&&{data:n},size:[L,j],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:P.margin,nodeIDAccessor:a,childrenAccessor:i,hierarchySum:O,padding:f,nodeStyle:$,colorBy:l,colorScheme:P.effectivePalette,colorByDepth:u,nodeLabel:E?d||a:void 0,showLabels:E,enableHover:T,tooltipContent:!1===g?()=>null:zn(g)||void 0,...cl({linkedHover:x,selection:b,onObservation:p,onClick:m,mobileInteraction:P.mobileInteraction,customHoverBehavior:P.customHoverBehavior,customClickBehavior:P.customClickBehavior,linkedHoverInClickPredicate:!1}),...S&&"none"!==S&&{legendHoverBehavior:P.legendState.onLegendHover,legendClickBehavior:P.legendState.onLegendClick,legendHighlightedCategory:P.legendState.highlightedCategory,legendIsolatedCategories:P.legendState.isolatedCategories},className:o,title:D,description:R,summary:I,accessibleTable:N,...null!=e.animate&&{animate:e.animate},...y})})}Wl.displayName="CirclePack";var $l=require("react"),Ol=require("react/jsx-runtime"),Bl=Ot;function zl(e){const t=Fa(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:r,className:o,childrenAccessor:i="children",nodeIdAccessor:s="name",colorBy:a,colorScheme:l,colorByDepth:c=!1,orbitMode:u="flat",orbitSize:d=2.95,speed:h=.25,revolution:f,revolutionStyle:g,eccentricity:y=1,showRings:p=!0,nodeRadius:m=6,showLabels:v=!1,animated:b=!0,tooltip:x,foregroundGraphics:k,annotations:w,frameProps:S={},onObservation:M,onClick:A,chartId:C,selection:L,linkedHover:j,loading:T,loadingContent:E,stroke:D,strokeWidth:R,opacity:I}=e,{width:N,height:P,enableHover:_,title:W,description:$,summary:O,accessibleTable:B}=t,z=Ua({nodes:(0,$l.useMemo)(()=>Ya(n,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:c?void 0:a,colorScheme:l,showLegend:!1,legendInteraction:void 0,selection:L,linkedHover:j,onObservation:M,onClick:A,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"OrbitDiagram",chartId:C,marginDefaults:Ia(t),userMargin:r,width:N,height:P,loading:T,loadingContent:E}),H=(0,$l.useMemo)(()=>new Map,[]),{colorScale:F,customClickBehavior:q,customHoverBehavior:Y,themeCategorical:X}=z,G=(0,$l.useMemo)(()=>{if(Array.isArray(l))return l;const e=Nt[l];return Array.isArray(e)?e:Pt},[l]),V=(0,$l.useMemo)(()=>e=>{const t={stroke:"#fff",strokeWidth:1},n=0===(e.depth??0);return t.fill=c?n?G[0]:Bl[(e.depth||0)%Bl.length]:a?zt(e.data||e,a,F):Ba(void 0,X,l,void 0,H),t.opacity=n?1:.85,t},[a,c,F,G,X,l,H]),U=(0,$l.useMemo)(()=>Ka(V,{stroke:D,strokeWidth:R,opacity:I}),[V,D,R,I]),K=(0,$l.useMemo)(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),Q=(0,$l.useMemo)(()=>e=>{Y(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[Y]),Z=(0,$l.useMemo)(()=>e=>{q(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[q]),J=sl({componentName:"OrbitDiagram",data:n});return J?(0,Ol.jsx)(rs,{componentName:"OrbitDiagram",message:J,width:N,height:P}):z.loadingEl?z.loadingEl:(0,Ol.jsx)(as,{componentName:"OrbitDiagram",width:N,height:P,children:(0,Ol.jsx)(ea,{chartType:"orbit",...null!=n&&{data:n},size:[N,P],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:z.margin,nodeIDAccessor:s,childrenAccessor:i,nodeStyle:U,edgeStyle:K,colorBy:a,colorScheme:z.effectivePalette,colorByDepth:c,nodeSize:m,nodeLabel:v?s:void 0,showLabels:v,enableHover:!b&&_,tooltipContent:b?void 0:!1===x?()=>null:zn(x)||void 0,...cl({linkedHover:j,selection:L,onObservation:M,onClick:A,mobileInteraction:z.mobileInteraction,customHoverBehavior:Q,customClickBehavior:Z,linkedHoverInClickPredicate:!1}),foregroundGraphics:k,annotations:w,className:o,title:W,description:$,summary:O,orbitMode:u,orbitSize:d,orbitSpeed:h,orbitRevolution:f,orbitRevolutionStyle:g,orbitEccentricity:y,orbitShowRings:p,orbitAnimated:b,accessibleTable:B,...null!=e.animate&&{animate:e.animate},...S})})}zl.displayName="OrbitDiagram";var Hl=require("react"),Fl=require("d3-scale"),ql=require("react");function Yl(e,t,n){const r=[],o=new Set(e.map(e=>e.id)),i=Array.isArray(n)&&2===n.length,s=i&&Number.isFinite(n[0])&&Number.isFinite(n[1]);i&&s&&s&&n[1]>=n[0]||r.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||r.push({kind:"invalid-node-time",id:t.id}));for(const e of t)o.has(e.source)||r.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),o.has(e.target)||r.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||r.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||r.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):r.push({kind:"invalid-edge-time",id:e.id});return r}function Xl(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:e.kind}function Gl(e,t,n){const r=t.incoming[e.id],o=t.outgoing[e.id],i=[];for(const e of r)i.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:n.get(e.id).targetSide});for(const e of o)i.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:n.get(e.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{i.sort((e,t)=>e.time-t.time||(s[e.kind]??99)-(s[t.kind]??99))},l=i.length?function(e,t=1/0){let n=t;for(const t of e)n>t&&(n=t);return n}(i.map(e=>e.time)):null,c=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,u=null!=c?c-1:null!=l&&Number.isFinite(l)?l-1:null,d=[...new Set(i.map(e=>e.time))].sort((e,t)=>e-t),h=new Map;for(let e=1;d.length>e;e++)h.set(d[e],d[e-1]);const f=e=>{const t=h.get(e);return null!=t?(t+e)/2:null!=u?u:e};a();const g=[];let y=0,p=0;for(const e of i)if("out"===e.kind){const t=Math.abs(e.delta);let n=t-("top"===e.side?y:p);if(n>0){const t="top"===e.side?"bot":"top",r=Math.min(n,"top"===t?y:p);if(r>0){const o=f(e.time);g.push({time:o,delta:-r,kind:"transfer-out",side:t}),g.push({time:o,delta:+r,kind:"transfer-in",side:e.side}),"top"===t?y-=r:p-=r,"top"===e.side?y+=r:p+=r,n-=r}n>0&&null!==u&&(g.push({time:u,delta:+n,kind:"create",side:e.side}),"top"===e.side?y+=n:p+=n)}"top"===e.side?y-=t:p-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?y+=t:p+=t}i.push(...g),a();let m=0,v=0,b=0,x=0,k=0;const w=[],S=new Map;for(const e of i){if(w.push({t:e.time,topMass:m,botMass:v}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?m:v;S.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta)})}"top"===e.side?m+=e.delta:v+=e.delta,m+v>b&&(b=m+v),m>x&&(x=m),v>k&&(k=v),w.push({t:e.time,topMass:m,botMass:v})}const M=[];let A=0;for(;w.length>A;){let e=A;for(;w.length>e+1&&w[e+1].t===w[A].t;)e++;M.push(w[A]);for(let t=A+1;e>=t;t++){const e=M[M.length-1];w[t].topMass===e.topMass&&w[t].botMass===e.botMass||M.push(w[t])}A=e+1}const C=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let L=null;for(const e of o)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===L||L>e.systemInTime)&&(L=e.systemInTime);let j=null;for(const e of r)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===j||e.systemOutTime>j)&&(j=e.systemOutTime);if(M.length>0){const e=M[M.length-1],t=Math.max(null!=C?C:-1/0,null!=j?j:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&M.push({t:t,topMass:e.topMass,botMass:e.botMass});const n=M[0],r=Math.min(null!=c?c:1/0,null!=L?L:1/0);Number.isFinite(r)&&n.t>r&&n.topMass+n.botMass>0&&M.unshift({t:r,topMass:n.topMass,botMass:n.botMass})}return{samples:M,peak:b,topPeak:x,botPeak:k,localAttachments:S}}function Vl(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Ul(e,t){return e.map(e=>({t:Vl(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function Kl(e,t,n){const r=e.value*n;if("out"===e.kind){const o=e.sideMassBefore*n;if("top"===e.side){const e=t-o;return[e,e+r]}const i=t+o;return[i-r,i]}const o=e.sideMassAfter*n;if("top"===e.side){const e=t-o;return[e,e+r]}const i=t+o;return[i-r,i]}function Ql(e,t){let n=0;for(let r=0;t.length>r;r++)for(let o=r+1;t.length>o;o++){const i=t[r],s=t[o];i.source!==s.source&&i.target!==s.target&&i.source!==s.target&&i.target!==s.source&&(Math.min(i.endTime,s.endTime)>Math.max(i.startTime,s.startTime)&&e[s.source]>e[i.source]!=e[s.target]>e[i.target]&&n++)}return n}function Zl(e,t){let n=0;for(const r of t)n+=Math.abs(e[r.source]-e[r.target])*(r.value||1);return n}function Jl(e,t){return 1e3*Ql(e,t)+Zl(e,t)}function ec(e,t){return{slots:e.map(e=>({peak:{...e.peak},occupants:e.occupants.slice()})),map:{...t}}}function tc(e,t,n){e.length>8||n.length>40?(function(e,t,n,r=6){const o=e.length;if(1>=o)return;let i=ec(e,t),s=Jl(t,n);for(let a=0;r>a;a++){const r=Array(o).fill(0),a=Array(o).fill(0);for(const e of n){const n=t[e.source],o=t[e.target];r[n]+=o*(e.value||1),a[n]+=e.value||1,r[o]+=n*(e.value||1),a[o]+=e.value||1}const l=Array.from({length:o},(e,t)=>t).sort((e,t)=>(a[e]>0?r[e]/a[e]:e)-(a[t]>0?r[t]/a[t]:t)),c=l.map(t=>e[t]),u=new Map;l.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of c)e.push(t);const d=Jl(t,n);if(s>d)s=d,i=ec(e,t);else if(d===s)break}!function(e,t,n){e.length=0;for(const t of n.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(n.map))t[e]=n.map[e]}(e,t,i)}(e,t,n,6),function(e,t,n,r=6){const o=e.length;if(1>=o)return;let i=Jl(t,n);for(let s=0;r>s;s++){let r=!1;for(let s=0;o-1>s;s++){const o=e[s];e[s]=e[s+1],e[s+1]=o;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s);const a=Jl(t,n);if(i>a)i=a,r=!0;else{const n=e[s];e[s]=e[s+1],e[s+1]=n;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s)}}if(!r)break}}(e,t,n,6)):function(e,t,n){const r=e.length;if(1>=r)return;const o={...t},i=Object.keys(o),s=Array.from({length:r},(e,t)=>t),a=s.slice(),l={...o};let c=s.slice(),u=1/0;const d=()=>{for(const e of i)l[e]=a[o[e]];const e=Jl(l,n);u>e&&(u=e,c=s.slice())},h=(e,t)=>{const n=s[e],r=s[t];s[e]=r,s[t]=n,a[n]=t,a[r]=e};d();const f=Array(r).fill(0);let g=0;for(;r>g;)g>f[g]?(h(g%2==0?0:f[g],g),d(),f[g]++,g=0):(f[g]=0,g++);const y=c.map(t=>e[t]),p=new Map;c.forEach((e,t)=>p.set(e,t));for(const e of Object.keys(t))t[e]=p.get(t[e]);e.length=0;for(const t of y)e.push(t)}(e,t,n)}function nc(e,t,n,r,o){const{plotH:i,padding:s,valueScale:a,packing:l,laneOrder:c,lifetimeMode:u="full"}=o,d={},h={};for(const t of e)d[t.id]=n[t.id].topPeak||0,h[t.id]=n[t.id].botPeak||0;const f="half"===u,g={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,n=Array.isArray(t.xExtent)?t.xExtent[1]:null;let o=null!=e&&Number.isFinite(e)?e:1/0,i=null!=n&&Number.isFinite(n)?n:-1/0;for(const e of r.outgoing[t.id]){o>e.startTime&&(o=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&o>e.systemInTime&&(o=e.systemInTime);const t=f?(e.startTime+e.endTime)/2:e.endTime;t>i&&(i=t)}for(const e of r.incoming[t.id]){const t=f?(e.startTime+e.endTime)/2:e.startTime;o>t&&(o=t),e.endTime>i&&(i=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>i&&(i=e.systemOutTime)}g[t.id]={start:Number.isFinite(o)?o:null,end:Number.isFinite(i)?i:null}}const y={},p=[];if("reuse"===l){const n=new Map;for(const t of e)n.set(t.id,0);const o=new Map;for(const t of e)o.set(t.id,0);for(const e of t)o.set(e.target,(o.get(e.target)??0)+1);const i=[];for(const t of e)0===(o.get(t.id)??0)&&i.push(t.id);for(;i.length;){const e=i.shift();for(const t of r.outgoing[e]??[]){const r=(n.get(e)??0)+1;r>(n.get(t.target)??0)&&n.set(t.target,r),o.set(t.target,o.get(t.target)-1),0===o.get(t.target)&&i.push(t.target)}}const s=[...e].filter(e=>null!==g[e.id].start).sort((e,t)=>{const r=n.get(e.id)??0,o=n.get(t.id)??0;return r!==o?r-o:g[e.id].start-g[t.id].start}),a=e.filter(e=>null===g[e.id].start);for(const e of[...s,...a]){const t=g[e.id];let n=-1;for(let e=0;p.length>e;e++){const r=p[e].occupants[p[e].occupants.length-1];if(null===t.start||void 0===r||t.start>=r.end){n=e;break}}-1===n&&(p.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=p.length-1),p[n].occupants.push({id:e.id,end:t?.end??-1/0}),p[n].peak.topPeak=Math.max(p[n].peak.topPeak,d[e.id]),p[n].peak.botPeak=Math.max(p[n].peak.botPeak,h[e.id]),y[e.id]=n}}else e.forEach((e,t)=>{p.push({occupants:[{id:e.id,end:g[e.id]?.end??-1/0}],peak:{topPeak:d[e.id],botPeak:h[e.id]}}),y[e.id]=t});let m=null,v=null,b=null,x=null;const k=()=>{m=Ql(y,t),b=Zl(y,t)},w=()=>{v=Ql(y,t),x=Zl(y,t)};"crossing-min"===c?(k(),tc(p,y,t),w()):"inside-out"===c?(k(),function(e,t){const n=e.length;if(1>=n)return;const r=e=>e.peak.topPeak+e.peak.botPeak,o=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>r(t.slot)-r(e.slot)),i=Array(n),s=Math.floor((n-1)/2);i[s]=o[0].idx;let a=s-1,l=s+1;for(let e=1;o.length>e;e++)e%2==1&&n>l||0>a?i[l++]=o[e].idx:i[a--]=o[e].idx;const c=i.map(t=>e[t]),u=new Map;i.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of c)e.push(t)}(p,y),w()):"crossing-min+inside-out"===c&&(k(),tc(p,y,t),function(e,t,n){const r=e.length;if(1>=r)return;const o=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),i=Math.floor((r-1)/2);let s=Jl(t,n);for(const{slot:a}of o){const o=e.indexOf(a);if(0>o)continue;const l=i;if(o===l)continue;const c=e[o];e.splice(o,1),e.splice(l,0,c);const u=new Map;for(let e=0;r>e;e++)u.set(e,e);if(l>o){for(let e=o+1;l>=e;e++)u.set(e,e-1);u.set(o,l)}else{for(let e=l;o>e;e++)u.set(e,e+1);u.set(o,l)}for(const e of Object.keys(t))t[e]=u.get(t[e]);const d=Jl(t,n);if(d>s){const n=e[l];e.splice(l,1),e.splice(o,0,n);const i=new Map;for(let e=0;r>e;e++)i.set(e,e);if(o>l){for(let e=l+1;o>=e;e++)i.set(e,e-1);i.set(l,o)}else{for(let e=o;l>e;e++)i.set(e,e+1);i.set(l,o)}for(const e of Object.keys(t))t[e]=i.get(t[e])}else s=d}}(p,y,t),w());const S=p.map(e=>{const t=new Map;for(const r of e.occupants){const e=n[r.id];if(e)for(const n of e.samples){const e=t.get(n.t)||{top:0,bot:0};t.set(n.t,{top:Math.max(e.top,n.topMass),bot:Math.max(e.bot,n.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),M=(e,t)=>{let n={top:0,bot:0};for(const[r,o]of e){if(r>t)break;n=o}return n},A=[];for(let e=0;p.length-1>e;e++){const t=S[e],n=S[e+1],r=new Set([...t.map(e=>e[0]),...n.map(e=>e[0])]);let o=0;for(const e of r){const r=M(t,e),i=M(n,e);r.bot+i.top>o&&(o=r.bot+i.top)}A.push(o)}const C=[];let L=s+(p[0]?.peak.topPeak??0)*a;p.length>0&&C.push(L);for(let e=1;p.length>e;e++)L+=A[e-1]*a+s,C.push(L);if(p.length>0&&(L+=p[p.length-1].peak.botPeak*a+s),L>i){const e=i/L;for(let t=0;C.length>t;t++)C[t]*=e}const j=0===p.length?0:p[0].peak.topPeak+A.reduce((e,t)=>e+t,0)+p[p.length-1].peak.botPeak,T={};for(const t of e)T[t.id]=C[y[t.id]];return{effectiveSlotsHeight:j,centerlines:T,laneLifetime:g,slots:p,slotByNode:y,slotCenter:C,crossingsBefore:m,crossingsAfter:v,lengthBefore:b,lengthAfter:x}}var rc=e=>{const{bands:t=[],ribbons:n=[],showLabels:r=!0}=e.config,o=[];for(const e of n)o.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}});for(const e of t)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const n=e.gradientStubs[t];o.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of t)o.push({type:"bezier",pathD:e.pathD,style:{...e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86},stroke:e.stroke??e.fill,strokeWidth:e.strokeWidth??.5},datum:{__kind:"band",data:e.rawDatum,id:e.id}});const i=r?t.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:o,labels:i}};function oc(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}var ic=require("react/jsx-runtime");function sc(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function ac(e,t){return"function"==typeof e?e(t):t[e]}var lc=(0,ql.forwardRef)(function(e,t){const{nodes:n,edges:r,domain:o,axisTicks:i=[],nodeIdAccessor:s="id",sourceAccessor:a="source",targetAccessor:l="target",valueAccessor:c="value",startTimeAccessor:u="startTime",endTimeAccessor:d="endTime",systemInTimeAccessor:h,systemOutTimeAccessor:f,xExtentAccessor:g="xExtent",edgeIdAccessor:y="id",colorBy:p,colorScheme:m,showLegend:v,legendPosition:b="right",pairing:x="temporal",packing:k="reuse",laneOrder:w="crossing-min",ribbonLane:S="both",lifetimeMode:M="half",showLaneRails:A=!1,showQualityReadout:C=!1,showLabels:L=!0,width:j=600,height:T=400,margin:E,title:D,description:R,summary:I,accessibleTable:N,responsiveWidth:P,responsiveHeight:_,loading:W,loadingContent:$,emptyContent:O,edgeOpacity:B=.35,timeFormat:z,valueFormat:H,tooltip:F,enableHover:q=!0,onObservation:Y,onClick:X,showParticles:G=!1,particleStyle:V,chartId:U,frameProps:K={}}=e,[Q,Z]=(0,Hl.useState)([]),[J,ee]=(0,Hl.useState)([]),te=(0,Hl.useRef)(Q),ne=(0,Hl.useRef)(J);te.current=Q,ne.current=J;const re=(0,Hl.useCallback)(e=>{te.current=e,Z(e)},[]),oe=(0,Hl.useCallback)(e=>{ne.current=e,ee(e)},[]),ie=void 0!==r,se=$i(ie?r:Q),ae=(0,Hl.useMemo)(()=>{const e=$i(n??[]),t=J;if(0===e.length&&0===t.length)return Xa([],se,a,l);const r=new Set,o=[];for(const t of e){const e=ac(s,t)+"";r.has(e)||(r.add(e),o.push(t))}for(const e of t){const t=ac(s,e)+"";r.has(t)||(r.add(t),o.push(e))}const i=Xa([],se,a,l);for(const e of i)r.has(e.id)||(r.add(e.id),o.push(e));return o},[n,J,se,s,a,l]),le=(0,Hl.useRef)(null),ce=(0,Hl.useCallback)((e,t)=>{const n=ac(y,e);return null!=n?n+"":`${ac(a,e)}-${ac(l,e)}-${t}`},[y,a,l]),ue=(0,Hl.useCallback)(e=>{if(null==e)return!1;const t=e;return null!=ac(a,t)&&null!=ac(l,t)},[a,l]);na(t,{variant:"network",frameRef:le,overrides:{push(e){if(ue(e)){if(ie)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");re([...te.current,e])}else oe([...ne.current,e])},pushMany(e){const t=[],n=[];for(const r of e)ue(r)?t.push(r):n.push(r);t.length>0&&(ie?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):re([...te.current,...t])),n.length>0&&oe([...ne.current,...n])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),n=[];if(!ie){const e=te.current,r=[];for(let o=0;e.length>o;o++){const i=e[o];t.has(ce(i,o))?n.push(i):r.push(i)}r.length!==e.length&&re(r)}const r=ne.current,o=[];for(const e of r){const r=ac(s,e)+"";t.has(r)?n.push(e):o.push(e)}return o.length!==r.length&&oe(o),n},update(e,t){const n=new Set(Array.isArray(e)?e:[e]),r=[];if(!ie){let e=!1;const o=te.current.map((o,i)=>n.has(ce(o,i))?(r.push(o),e=!0,t(o)):o);e&&re(o)}let o=!1;const i=ne.current.map(e=>{const i=ac(s,e)+"";return n.has(i)?(r.push(e),o=!0,t(e)):e});return o&&oe(i),r},clear(){ie||re([]),oe([]),le.current?.clear()},getData:()=>se??[],getScales:()=>null}});const de=ce,he=(0,Hl.useCallback)(e=>ac(s,e)+"",[s]),{nodes:fe,edges:ge,domain:ye,rawNodeById:pe,rawEdgeById:me}=(0,Hl.useMemo)(()=>{const e=(ae??[]).map(e=>{const t={id:he(e),__raw:e},n=g?ac(g,e):null;if(Array.isArray(n)&&2===n.length){const e=sc(n[0]),r=sc(n[1]);Number.isFinite(e)&&Number.isFinite(r)&&(t.xExtent=[e,r])}return t}),t=(se??[]).map((e,t)=>{const n={id:de(e,t),source:ac(a,e)+"",target:ac(l,e)+"",value:Number(ac(c,e)),startTime:sc(ac(u,e)),endTime:sc(ac(d,e)),__raw:e};if(h){const t=sc(ac(h,e));Number.isFinite(t)&&(n.systemInTime=t)}if(f){const t=sc(ac(f,e));Number.isFinite(t)&&(n.systemOutTime=t)}return n}),n=[sc(o[0]),sc(o[1])],r=new Map;for(const t of e)null!=t.__raw&&r.set(t.id,t.__raw);const i=new Map;for(const e of t)null!=e.__raw&&i.set(e.id,e.__raw);return{nodes:e,edges:t,domain:n,rawNodeById:r,rawEdgeById:i}},[ae,se,o,he,de,g,a,l,c,u,d,h,f]),be=Ua({nodes:ae,edges:se,inferNodes:!1,nodeIdAccessor:s,sourceAccessor:a,targetAccessor:l,colorBy:p,colorScheme:m,showLegend:!1,legendPosition:b,selection:void 0,linkedHover:void 0,onObservation:Y,onClick:X,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:"ProcessSankey",chartId:U,marginDefaults:{top:30,right:80,bottom:40,left:80},userMargin:E,width:j,height:T,loading:W,loadingContent:$,emptyContent:O}),xe=(v??!!p)&&!!p,ke=(0,Hl.useCallback)(e=>null!=E&&("number"==typeof E||null!=E[e]),[E]),we=(0,Hl.useMemo)(()=>{const e={...be.margin};return xe&&("right"===b&&!ke("right")&&140>e.right?e.right=140:"bottom"===b&&!ke("bottom")&&80>e.bottom&&(e.bottom=80)),e},[be.margin,xe,b,ke]),Se=j-we.left-we.right,Me=T-we.top-we.bottom,Ae=(0,Hl.useMemo)(()=>Yl(fe,ge,ye),[fe,ge,ye]),Ce=(0,Hl.useMemo)(()=>Ae.length>0?null:function(e,t,n){const{plotH:r,pairing:o="temporal",packing:i="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half"}=n,l=function(e,t){const n={},r={};for(const t of e)n[t.id]=[],r[t.id]=[];for(const e of t)r[e.source]&&r[e.source].push(e),n[e.target]&&n[e.target].push(e);return{incoming:n,outgoing:r}}(e,t),c=function(e,t,n,r="value"){const o="temporal"===r?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,i="temporal"===r?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,s=new Map;for(const e of t)s.set(e.id,{});const a=(e,t)=>{const n=new Map;for(const r of e){const e=r[t];n.has(e)||n.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const o=n.get(e);o.edges.push(r),o.total+=r.value,o.earliestStart=Math.min(o.earliestStart,r.startTime),o.latestEnd=Math.max(o.latestEnd,r.endTime)}const s=[...n.values()];s.sort("temporal"===r?(e,n)=>"target"===t?e.earliestStart-n.earliestStart:e.latestEnd-n.latestEnd:(e,t)=>t.total-e.total);for(const e of s)e.edges.sort("target"===t?i:o);return s};for(const t of e){const e=n.outgoing[t.id],r=n.incoming[t.id];if(0===r.length)a(e,"target").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).sourceSide=n});else if(0===e.length)a(r,"source").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).targetSide=n});else{const t=a(r,"source"),n=a(e,"target"),o=Math.max(t.length,n.length);for(let e=0;o>e;e++){const r=e%2==0?"top":"bot";if(t[e])for(const n of t[e].edges)s.get(n.id).targetSide=r;if(n[e])for(const t of n[e].edges)s.get(t.id).sourceSide=r}}}return s}(e,t,l,o);let u={};for(const t of e)u[t.id]=Gl(t,l,c);const d=nc(e,t,u,l,{plotH:r,padding:12,valueScale:1,packing:i,laneOrder:s,lifetimeMode:a}),h=new Set;for(const e of t){const t=d.slotByNode[e.source],n=d.slotByNode[e.target];if(void 0===t||void 0===n)continue;const r=c.get(e.id);t!==n?t>n?(r.sourceSide="top",r.targetSide="bot"):(r.sourceSide="bot",r.targetSide="top"):(h.add(e.id),r.sourceSide="bot",r.targetSide="bot")}for(const t of e){const e=l.outgoing[t.id],n=l.incoming[t.id],r=new Set(e.map(e=>c.get(e.id).sourceSide)),o=new Set(n.map(e=>c.get(e.id).targetSide));if(1===r.size&&n.length>0){const e=[...r][0];for(const t of n)d.slotByNode[t.source]===d.slotByNode[t.target]&&(c.get(t.id).targetSide=e)}if(1===o.size&&e.length>0){const t=[...o][0];for(const n of e)d.slotByNode[n.source]===d.slotByNode[n.target]&&(c.get(n.id).sourceSide=t)}}for(const t of e){const e=l.incoming[t.id],n=l.outgoing[t.id];if(0===e.length||0===n.length)continue;const r=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of e)"top"===c.get(n.id).targetSide?t.inTop+=n.value:t.inBot+=n.value;for(const e of n)"top"===c.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},o=(e,t)=>{const o=r(),i="top"===e?o.outTop-o.inTop:o.outBot-o.inBot,s="top"===t?o.inTop-o.outTop:o.inBot-o.outBot;if(0>=i||0>=s)return!1;const a=Math.min(i,s),l=n.filter(t=>!h.has(t.id)&&c.get(t.id).sourceSide===e&&a>=t.value).sort((e,t)=>t.value-e.value);return 0!==l.length&&(c.get(l[0].id).sourceSide=t,!0)};let i=n.length+1;for(;i-- >0&&(o("top","bot")||o("bot","top")););}u={};for(const t of e)u[t.id]=Gl(t,l,c);const f=nc(e,t,u,l,{plotH:r,padding:12,valueScale:1,packing:i,laneOrder:s,lifetimeMode:a}),g=f.effectiveSlotsHeight??f.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),y=Math.min(12,.35*r/Math.max(f.slots.length+1,1)),p=g>0?Math.max(0,(r-y*(f.slots.length+1))/g):1,m=nc(e,t,u,l,{plotH:r,padding:y,valueScale:p,packing:i,laneOrder:s,lifetimeMode:a});return{nodeData:u,sides:c,valueScale:p,padding:y,compressedPadding:12>y,centerlines:m.centerlines,laneLifetime:m.laneLifetime,slots:m.slots,slotByNode:m.slotByNode,crossingsBefore:m.crossingsBefore,crossingsAfter:m.crossingsAfter,lengthBefore:m.lengthBefore,lengthAfter:m.lengthAfter}}(fe,ge,{plotH:Me,pairing:x,packing:k,laneOrder:w,lifetimeMode:M}),[Ae,fe,ge,Me,x,k,w,M]),Le=(0,Hl.useMemo)(()=>(0,Fl.scaleTime)().domain(ye).range([0,Se]),[ye,Se]),je=(0,Hl.useCallback)((e,t)=>{if(p&&ae){const t=pe.get(e);if(t)return zt(t,p,be.colorScale)}return be.effectivePalette[t%be.effectivePalette.length]||"#475569"},[p,ae,pe,be.colorScale,be.effectivePalette]),Te=(0,Hl.useMemo)(()=>{const e=new Map;return fe.forEach((t,n)=>e.set(t.id,n)),e},[fe]),Ee=(0,Hl.useMemo)(()=>{if(!Ce)return{bands:[],ribbons:[]};const{centerlines:e,nodeData:t,valueScale:n}=Ce,r=[],o=[];return fe.forEach((o,i)=>{const s=t[o.id];if(!s||0===s.samples.length)return;const a=function(e,t,n,r,o){if(0===e.length)return null;const i=Ul(e,o),s=e=>t-i[e].topMass*n,a=e=>t+i[e].botMass*n;let l=`M${r(i[0].t)},${s(0)}`;for(let e=1;i.length>e;e++)l+=` L${r(i[e].t)},${s(e)}`;l+=` L${r(i[i.length-1].t)},${a(i.length-1)}`;for(let e=i.length-2;e>=0;e--)l+=` L${r(i[e].t)},${a(e)}`;return l+" Z"}(s.samples,e[o.id],n,Le,ye);if(!a)return;const l=Ul(s.samples,ye),c=l.find(e=>e.topMass+e.botMass>0)||l[0],u=e[o.id]+(c.botMass-c.topMass)*n/2,d=je(o.id,i),h=pe.get(o.id)??o,f=function(e,t,n,r,o){const i=n.nodeData[e];if(!i||0===i.samples.length)return[];const s=n.valueScale,a=n.centerlines[e],l=Ul(i.samples,o),c=l.find(e=>e.topMass+e.botMass>0)||l[0],u=[...l].reverse().find(e=>e.topMass+e.botMass>0)||l[l.length-1],d=r(c.t),h=r(u.t),f=e=>r(Vl(e,o)),g=[],y=(e,t,n,r)=>`M${e},${t} L${n},${t} L${n},${r} L${e},${r} Z`;for(const n of t){if(n.source===e&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const e=i.localAttachments.get(n.id);if(e&&"out"===e.kind&&n.startTime>n.systemInTime){const t=f(n.systemInTime),r=f(n.startTime),o=t-20,i=Math.max(d,o);if(r>i){const[n,l]=Kl(e,a,s);g.push({pathD:y(i,n,r,l),x0:o,x1:t,from:0,to:1})}}}if(n.target===e&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const e=i.localAttachments.get(n.id);if(e&&"in"===e.kind&&n.systemOutTime>n.endTime){const t=f(n.systemOutTime),r=f(n.endTime),o=t+20,i=Math.min(h,o);if(i>r){const[n,l]=Kl(e,a,s);g.push({pathD:y(r,n,i,l),x0:t,x1:o,from:1,to:0})}}}}return g}(o.id,ge,Ce,Le,ye);r.push({id:o.id,pathD:a,fill:d,stroke:d,strokeWidth:.5,...f.length>0&&{gradientStubs:f},rawDatum:h,labelX:Le(c.t)-4,labelY:u,labelText:o.id})}),ge.forEach(r=>{const i=t[r.source]?.localAttachments.get(r.id),s=t[r.target]?.localAttachments.get(r.id);if(!i||!s)return;const a=Te.get(r.source)??0,l=je(r.source,a),c=function(e,t,n,r,o,i,s,a){const l=o,c=e=>a?Math.max(a[0],Math.min(a[1],e)):e,u=i(c(e.time)),d=i(c(n.time)),h=e.value*l,f=n.value*l,g=e.sideMassBefore*l,y=n.sideMassAfter*l;let p,m,v,b;"top"===e.side?(p=t-g,m=p+h):(m=t+g,p=m-h),"top"===n.side?(v=r-y,b=v+f):(b=r+y,v=b-f);const x="source"===s?u+.85*(d-u):"target"===s?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:p,sBot:m,tx:d,tTop:v,tBot:b,cp1X:x,cp2X:x}}(i,e[r.source],s,e[r.target],n,Le,S,ye),{pathD:u,bezier:d}=ve(c),h=me.get(r.id)??r;o.push({id:r.id,pathD:u,fill:l,opacity:B,rawDatum:h,bezier:d})}),{bands:r,ribbons:o}},[Ce,fe,ge,Le,ye,je,pe,me,S,B,Te]),De=(0,Hl.useMemo)(()=>({bands:Ee.bands,ribbons:Ee.ribbons,showLabels:L}),[Ee,L]),Re=(0,Hl.useMemo)(()=>{if(!xe||!p)return;const e=new Map;(ae??[]).forEach((t,n)=>{const r=ac(p,t),o=null==r?"":r+"";o&&!e.has(o)&&e.set(o,{label:o,color:je(he(t),n)})});const t=Array.from(e.values());return 0!==t.length?{legendGroups:[{type:"fill",label:"",items:t,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0},[xe,p,ae,je,he]),Ie=(0,Hl.useMemo)(()=>!1!==F&&q?void 0===F||!0===F?null:zn(F)||null:null,[F,q]),Ne=(0,Hl.useCallback)(e=>z?z(new Date(e)):Number.isFinite(e)?1e10>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2):new Date(e).toISOString().slice(0,10):"",[z]),Pe=(0,Hl.useCallback)(e=>H?H(e):e+"",[H]),_e=(0,Hl.useCallback)(e=>{if(!e||!e.data)return null;const t=e.data;if(!oc(t))return null;const n=t.data;if(Ie)return Ie(n);if("band"===t.__kind){const e=t.id,n=Ce?function(e){if(!e)return[];const t=new Set,n=[];for(const r of e.samples){const e=r.topMass+r.botMass,o=`${r.t}:${e}`;t.has(o)||(t.add(o),n.push({t:r.t,total:e}))}return n}(Ce.nodeData[e]):[],r=5,o=n.length>r?n.length:null,i=function(e,t=5){if(t>=e.length)return e.slice();const n=[...e].sort((e,t)=>e.total-t.total),r=n.length-1,o=[{...n[0],mark:"min"},{...n[Math.floor(.25*r)],mark:"q25"},{...n[Math.floor(.5*r)],mark:"median"},{...n[Math.floor(.75*r)],mark:"q75"},{...n[r],mark:"max"}],i=new Set,s=[];for(const e of o)i.has(e.t)||(i.add(e.t),s.push(e));return s.sort((e,t)=>e.t-t.t)}(n,r);return(0,ic.jsxs)("div",{style:{minWidth:160},children:[(0,ic.jsx)("div",{style:{fontWeight:600,marginBottom:4},children:e}),i.length>0&&(0,ic.jsxs)("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[(0,ic.jsx)("thead",{children:(0,ic.jsxs)("tr",{style:{opacity:.6},children:[(0,ic.jsx)("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),(0,ic.jsx)("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=o&&(0,ic.jsx)("th",{})]})}),(0,ic.jsx)("tbody",{children:i.map((e,t)=>(0,ic.jsxs)("tr",{children:[(0,ic.jsx)("td",{style:{paddingRight:8},children:Ne(e.t)}),(0,ic.jsx)("td",{style:{textAlign:"right"},children:Pe(e.total)}),null!=o&&(0,ic.jsx)("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:e.mark})]},t))})]}),null!=o&&(0,ic.jsxs)("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",i.length," of ",o," samples"]})]})}const r=n,o=ac(a,r),i=ac(l,r),s=ac(c,r),h=ac(u,r),f=ac(d,r);return(0,ic.jsxs)("div",{style:{minWidth:160},children:[(0,ic.jsxs)("div",{style:{fontWeight:600,marginBottom:4},children:[o+""," → ",i+""]}),(0,ic.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=s&&(0,ic.jsxs)(ic.Fragment,{children:[(0,ic.jsx)("span",{style:{opacity:.6},children:"value"}),(0,ic.jsx)("span",{style:{textAlign:"right"},children:Pe(Number(s))})]}),null!=h&&(0,ic.jsxs)(ic.Fragment,{children:[(0,ic.jsx)("span",{style:{opacity:.6},children:"start"}),(0,ic.jsx)("span",{style:{textAlign:"right"},children:Ne(sc(h))})]}),null!=f&&(0,ic.jsxs)(ic.Fragment,{children:[(0,ic.jsx)("span",{style:{opacity:.6},children:"end"}),(0,ic.jsx)("span",{style:{textAlign:"right"},children:Ne(sc(f))})]})]})]})},[Ce,Ie,Ne,Pe,a,l,c,u,d]),We=(0,Hl.useMemo)(()=>{if(!Ce)return null;const{centerlines:e,laneLifetime:t,nodeData:n,valueScale:r,compressedPadding:o,crossingsBefore:s,crossingsAfter:a,lengthBefore:l,lengthAfter:c}=Ce;let u=null,d=null;for(const e of fe){const n=t[e.id];if(!n||null===n.start||null===n.end)continue;const r=Le(n.start),o=Le(n.end);(null===u||u>r)&&(u=r),(null===d||o>d)&&(d=o)}const h=e=>Math.max(0,Math.min(Se,e)),f=h(u??0),g=Math.max(f,h(d??Se));return(0,ic.jsxs)("g",{children:[C&&null!==(a??null)&&(0,ic.jsxs)("text",{x:Se,y:-12,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:["crossings: ",s," → ",a," ","edge length: ",Math.round(l)," → ",Math.round(c)]}),o&&(0,ic.jsx)("text",{x:Se,y:2,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:"dense layout: lane gaps compressed"}),i.map((e,t)=>{const n=Le(sc(e.date));return f-.5>n||n>g+.5?null:(0,ic.jsx)("line",{x1:n,y1:0,x2:n,y2:Me,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+t)}),A&&fe.map((o,i)=>{const s=t[o.id];if(!s||null===s.start)return null;const a=n[o.id],l=a?{topPeak:a.topPeak,botPeak:a.botPeak}:{topPeak:0,botPeak:0},c=e[o.id]+(l.botPeak-l.topPeak)*r/2,u=Le(s.start),d=Le(s.end),h=je(o.id,i);return(0,ic.jsxs)("g",{children:[(0,ic.jsx)("line",{x1:u,y1:c,x2:d,y2:c,stroke:h,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),(0,ic.jsx)("line",{x1:u,y1:c-4,x2:u,y2:c+4,stroke:h,strokeOpacity:.5}),(0,ic.jsx)("line",{x1:d,y1:c-4,x2:d,y2:c+4,stroke:h,strokeOpacity:.5})]},"lane-"+o.id)}),(0,ic.jsx)("line",{x1:f,y1:Me+4,x2:g,y2:Me+4,stroke:"#94a3b8"}),i.map((e,t)=>{const n=sc(e.date),r=Le(n);if(f-.5>r||r>g+.5)return null;const o=null!=e.label?e.label:z?z(new Date(n)):"";return(0,ic.jsxs)("g",{transform:`translate(${r},${Me+4})`,children:[(0,ic.jsx)("line",{y2:6,stroke:"#94a3b8"}),(0,ic.jsx)("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569",children:o})]},t)})]})},[Ce,i,Le,Se,Me,A,fe,je,C,z]),$e=(0,Hl.useMemo)(()=>(ae??[]).map(e=>({id:he(e),data:e})),[ae,he]),Oe=(0,Hl.useMemo)(()=>{const e=new Map;for(const t of Ee.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[Ee]),Be=(0,Hl.useMemo)(()=>(se??[]).map((e,t)=>{const n=de(e,t),r=Number(ac(c,e));return{id:n,source:ac(a,e)+"",target:ac(l,e)+"",value:Number.isFinite(r)?r:0,bezier:Oe.get(n),data:e}}),[se,de,a,l,c,Oe]),ze=be.loadingEl,He=be.emptyEl;return Ae.length>0?(0,ic.jsxs)("svg",{width:j,height:T,role:"img","aria-label":D??"Process Sankey validation failed",children:[(0,ic.jsx)("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),Ae.map((e,t)=>(0,ic.jsx)("text",{x:20,y:56+18*t,fontSize:12,fill:"#64748b",children:"• "+Xl(e)},t))]}):ze||He||(0,ic.jsx)(ea,{ref:le,chartType:"force",nodes:$e,edges:Be,customNetworkLayout:rc,layoutConfig:De,size:[j,T],responsiveWidth:P,responsiveHeight:_,margin:we,title:D,description:R??"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:I,accessibleTable:N,enableHover:q,tooltipContent:!1===F?()=>null:_e,backgroundGraphics:We,showParticles:G,particleStyle:V,legend:Re,legendPosition:b,onObservation:Y,...X&&{customClickBehavior:e=>{if(!e||!e.data||!X)return;const t=e.data;oc(t)&&X(t.data,{x:e.x,y:e.y})}},chartId:U,colorScheme:Array.isArray(m)?m:void 0,...K})});lc.displayName="ProcessSankey";var cc=require("react"),uc=require("react"),dc=require("react/jsx-runtime"),hc=(0,cc.forwardRef)(function(e,t){const{nodes:n,edges:r,layout:o,layoutConfig:i,onLayoutError:s,nodeIDAccessor:a="id",sourceAccessor:l="source",targetAccessor:c="target",margin:u,className:d,colorBy:h,colorScheme:f,selection:g,linkedHover:y,onObservation:p,onClick:m,chartId:v,annotations:b,autoPlaceAnnotations:x,frameProps:k={}}=e,{frameRef:w,resolved:S,normalizedMargin:M}=function(e){const t=(0,uc.useRef)(null);return na(e.imperativeRef,{variant:e.imperativeVariant,frameRef:t}),{frameRef:t,resolved:Fa(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),normalizedMargin:(0,uc.useMemo)(()=>function(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}(e.margin),[e.margin])}}({imperativeRef:t,imperativeVariant:"network",margin:u,width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),A=(0,cc.useMemo)(()=>$i(n),[n]),C=(0,cc.useMemo)(()=>$i(r),[r]),L=(0,cc.useMemo)(()=>void 0===n&&void 0===r?void 0:[...A,...C],[r,n,C,A]),j=Ea(e.mobileInteraction,{mode:e.mode,width:S.width,mobileSemantics:e.mobileSemantics}),{customHoverBehavior:T,customClickBehavior:E,activeSelectionHook:D}=za({selection:g,linkedHover:y,fallbackFields:"string"==typeof h?[h]:[],onObservation:p,onClick:m,chartType:"NetworkCustomChart",chartId:v,colorByField:"string"==typeof h?h:void 0,mobileInteraction:j}),R=(0,cc.useMemo)(()=>D?.isActive?{isActive:!0,predicate:D.predicate}:null,[D?.isActive,D?.predicate]),{width:I,height:N,enableHover:P,title:_,description:W,summary:$,accessibleTable:O}=S,B=ds(e.loading,I,N,e.loadingContent),z=B?null:us(L,I,N,e.emptyContent);if(B||z)return B||z;const H={chartType:"force",...null!=n&&{nodes:A},...null!=r&&{edges:C},customNetworkLayout:o,layoutConfig:i,onLayoutError:s,nodeIDAccessor:a,sourceAccessor:l,targetAccessor:c,colorBy:h,colorScheme:f,size:[I,N],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:M,enableHover:P,...ll({title:_,description:W,summary:$,accessibleTable:O,className:d,animate:e.animate,autoPlaceAnnotations:x}),...cl({linkedHover:y,selection:g,onObservation:p,onClick:m,mobileInteraction:j,customHoverBehavior:T,customClickBehavior:E,linkedHoverInClickPredicate:!1}),layoutSelection:R,...null!=b&&{annotations:b},...k};return(0,dc.jsx)(as,{componentName:"NetworkCustomChart",width:I,height:N,children:(0,dc.jsx)(ea,{ref:w,...H})})});hc.displayName="NetworkCustomChart";var fc={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},gc=8;function yc(e){const t=function(e){return null==e?void 0:e+""}(e.id);return"width"in e&&"height"in e?{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...fc},datum:e.datum,id:t,label:e.label}:{type:"circle",cx:e.x,cy:e.y,r:e.r??gc,style:{...fc},datum:e.datum,id:t,label:e.label}}
|
|
2
|
+
var e,t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,s=(e,t,i,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let l of o(t))a.call(e,l)||l===i||n(e,l,{get:()=>t[l],enumerable:!(s=r(t,l))||s.enumerable});return e},l=(e,r,o)=>(o=null!=e?t(i(e)):{},s(!r&&e&&e.__esModule?o:n(o,"default",{value:e,enumerable:!0}),e)),c={};((e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})})(c,{ChordDiagram:()=>Gl,CirclePack:()=>nc,DEFAULT_HIT_RADIUS:()=>Ic,ForceDirectedGraph:()=>El,NetworkCustomChart:()=>Dc,OrbitDiagram:()=>ac,ProcessSankey:()=>Lc,SankeyDiagram:()=>Fl,StreamNetworkFrame:()=>ms,TreeDiagram:()=>Ul,Treemap:()=>Jl,composeStyleRules:()=>kl,formatProcessSankeyIssue:()=>dc,glyphExtent:()=>pn,glyphPlacement:()=>yn,hatchFillId:()=>Wo,hatchPatternDef:()=>Oo,isHatchFill:()=>Po,makeNodeRuleContext:()=>pl,makeRuleValueResolver:()=>yl,matchesThreshold:()=>bl,networkHitTarget:()=>Nc,resolveResponsiveRules:()=>Bs,resolveStyleRules:()=>xl,resolveSvgFill:()=>Bo,responsiveRuleMatches:()=>Os,ruleMatches:()=>vl,useCustomLayoutSelection:()=>un,useForceLayout:()=>Bl,validateProcessSankey:()=>uc}),module.exports=(e=c,s(n({},"__esModule",{value:!0}),e));var u=l(require("react")),d=require("react");function h(e){return Array.isArray(e)?e[0]:e}function f(e,t,n,r){return{data:h(e),x:t,y:n,__semioticHoverData:!0,...r}}var g={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},y={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},p=class{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e,t=Math.random){const n=this._freeIndices.pop();if(void 0===n)return null;const r=this.particles[n];return r.active=!0,r.t=0,r.offset=t()-.5,r.edgeIndex=e,r.x=0,r.y=0,r}step(e,t,n,r){for(let o=0;this.capacity>o;o++){const i=this.particles[o];if(!i.active)continue;const a=n[i.edgeIndex];a&&a.bezier?(i.t+=e*t*(r?r[i.edgeIndex]??1:1)*(a.bezier.circular?.3:1),1>i.t?m(a.bezier,i.t,i.offset,i):(i.active=!1,this._freeIndices.push(o))):(i.active=!1,this._freeIndices.push(o))}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)t.length>n?this.particles[n]=t[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=e}};function m(e,t,n,r){if(e.circular&&e.segments)return void function(e,t,n,r,o){const i=e.length,a=t*i,s=Math.min(Math.floor(a),i-1),l=a-s,[c,u,d,h]=e[s];b(c,u,d,h,l,o);const f=h.x-c.x,g=h.y-c.y,y=Math.sqrt(f*f+g*g);if(y>.001){const e=f/y;o.x+=-g/y*n*r*2,o.y+=e*n*r*2}}(e.segments,t,n,e.halfWidth,r);if(!e.points)return r.x=0,void(r.y=0);const[o,i,a,s]=e.points;b(o,i,a,s,t,r);const l=s.x-o.x,c=s.y-o.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;r.x+=-c/u*n*e.halfWidth*2,r.y+=t*n*e.halfWidth*2}}function b(e,t,n,r,o,i){const a=1-o,s=a*a,l=s*a,c=o*o,u=c*o;i.x=l*e.x+3*s*o*t.x+3*a*c*n.x+u*r.x,i.y=l*e.y+3*s*o*t.y+3*a*c*n.y+u*r.y}function v(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function x(e,t){var n,r=[],o=[],i=[],a={},s=[];function l(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&l(t)})}function c(e){var t,r,d=!1;for(o.push(e),i[e]=!0,t=0;s[e].length>t;t++)(r=s[e][t])===n?(u(n,o),d=!0):i[r]||(d=c(r));if(d)l(e);else for(t=0;s[e].length>t;t++){var h=a[r=s[e][t]];h||(a[r]=h={}),h[r]=!0}return o.pop(),d}function u(e,n){var o=[].concat(n).concat(e);t?t(o):r.push(o)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,r=function(e){for(var t=e.length,n=Array(t),r=Array(t),o=Array(t),i=Array(t),a=Array(t),s=Array(t),l=0;t>l;++l)n[l]=-1,r[l]=0,o[l]=!1,i[l]=0,a[l]=-1,s[l]=[];var c,u=0,d=[],h=[];function f(t){var l=[t],c=[t];for(n[t]=r[t]=u,o[t]=!0,u+=1;c.length>0;){var f=e[t=c[c.length-1]];if(f.length>i[t]){for(var g=i[t];f.length>g;++g){var y=f[g];if(0>n[y]){n[y]=r[y]=u,o[y]=!0,u+=1,l.push(y),c.push(y);break}o[y]&&(r[t]=0|Math.min(r[t],r[y])),0>a[y]||s[t].push(a[y])}i[t]=g}else{if(r[t]===n[t]){var p=[],m=[],b=0;for(g=l.length-1;g>=0;--g){var v=l[g];if(o[v]=!1,p.push(v),m.push(s[v]),b+=s[v].length,a[v]=d.length,v===t){l.length=g;break}}d.push(p);var x=Array(b);for(g=0;m.length>g;g++)for(var k=0;m[g].length>k;k++)x[--b]=m[g][k];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>n[l]&&f(l);for(l=0;h.length>l;l++){var g=h[l];if(0!==g.length){g.sort(function(e,t){return e-t}),c=[g[0]];for(var y=1;g.length>y;y++)g[y]!==g[y-1]&&c.push(g[y]);h[l]=c}}return{components:d,adjacencyList:h}}(e),o=r.components.filter(function(e){return e.length>1}),i=1/0,a=0;o.length>a;a++)for(var s=0;o[a].length>s;s++)i>o[a][s]&&(i=o[a][s],n=a);var l=o[n];return!!l&&{leastVertex:i,adjList:e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})})}}n=0;for(var h=e.length;h>n;){var f=d(n);if(n=f.leastVertex,s=f.adjList){for(var g=0;s.length>g;g++)for(var y=0;s[g].length>y;y++){var p=s[g][y];i[+p]=!1,a[p]={}}c(n),n+=1}else n=h}return t?void 0:r}function k(e){return e.y0-e.y1>0?"up":"down"}function w(e,t){return t(e.source)==t(e.target)}function S(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function M(e){return e.target.x0-e.source.x1}function A(e,t){var n=L(e),r=M(t)/Math.tan(n);return"up"==k(e)?e.y1-r:e.y1+r}function C(e,t){var n=L(e),r=M(t)/Math.tan(n);return"up"==k(e)?e.y1+r:e.y1-r}function L(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function j(e,t){return t(e)}function T(e){return D(e.source)}function E(e){return D(e.target)}function D(e){return(e.y0+e.y1)/2}function R(e){return e.virtual?0:e.value}function I(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!w(e,t)?n+1:n});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!w(e,t)?r+1:r}),n+r}function N(e){return e.target.depth}function P(e,t){return e.sourceLinks.length?e.depth:t-1}function _(e,t){return e.y0-t.y0}function W(e,t){return t.y0-e.y0}function $(e,t){return e.y1-t.y1}function O(e,t){return t.y1-e.y1}function B(e,t){return H(e.source,t.source)||e.index-t.index}function z(e,t){return H(e.target,t.target)||e.index-t.index}function H(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function F(e,t){return q(e)==q(t)?"bottom"==e.circularLinkType?W(e,t):_(e,t):q(t)-q(e)}function q(e){return e.target.column-e.source.column}function Y(e,t){return G(e)==G(t)}function G(e){return e.y0-e.y1>0?"up":"down"}var X=require("d3-array");function V(e,t,n,r,o){let i=e;var a=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,a))});var s=(0,X.min)(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=i.links.filter(function(e){return e.circular});return l.sort(function(e,t){return t.value-e.value}),l.forEach(function(e,t){e._circularStub=t>=4}),U(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),U(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+r,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,w(e,t)&&S(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var a=e.source.column,l=e.circularLinkType,c=i.links.filter(function(e){return e.source.column==a&&e.circularLinkType==l});c.sort("bottom"==e.circularLinkType?W:_);var u=0;c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),a=e.target.column,(c=i.links.filter(function(e){return e.target.column==a&&e.circularLinkType==l})).sort("bottom"==e.circularLinkType?O:$),u=0,c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=s-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,r=e.target.x0,o=e.y1,i=(t+r)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+o+" "+r+","+o}(e)}),i}function U(e,t,n){e.sort(F);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(w(e,t)&&S(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;r.length>a;a++){var s=r[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&K(e,s)){var l=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+n;i=l>i?l:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function K(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}var Q=require("d3-array");function Z(e){return function(){return e}}function J(e){return e.index}function ee(e){return e.nodes}function te(e){return e.links}function ne(e,t,n){var r=(0,Q.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(o,i){var a=o.length;if(t)o.sort(t);else if(i>0){var s=new Map;o.forEach(function(e,t){var n,r,o,i=(r=0,o=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=D(e.source)*t,r+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=D(e.target)*t,r+=t}}),r>0?o/r:NaN);s.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var n=s.get(e),r=s.get(t),o=n.bc,i=r.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?n.idx-r.idx:1:-1:o-i})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?I(t,n)-I(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){t.depth==r.length-1&&1==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==I(t,n)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+o,t.y1=t.y0+t.value*e.ky)})})}function re(e,t,n,r,o,i){var a=(0,Q.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var s=1,l=i;l>0;--l)c(s*=.99,n),u();function c(t,n){var r=a.length;a.forEach(function(o){var i=o.length,a=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&I(o,n)>0){var l=(0,Q.mean)(o.sourceLinks,E),c=(0,Q.mean)(o.targetLinks,T),u=l&&c?(l+c)/2:l||c;if(u){var d=(u-D(o))*t*.3;o.y0+=d,o.y1+=d}}else if(0==a&&1==i)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(a==r-1&&1==i)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)s=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+s;else{var h=(0,Q.mean)(o.sourceLinks,E),f=(0,Q.mean)(o.targetLinks,T),g=((h&&f?(h+f)/2:h||f)-D(o))*t;o.y0+=g,o.y1+=g}})})}function u(){a.forEach(function(n){var i,a,s,l=e.y0,c=n.length;for(n.sort(t||H),s=0;c>s;++s)(a=l-(i=n[s]).y0)>0&&(i.y0+=a,i.y1+=a),l=i.y1+r;if((a=l-r-e.y1)>0)for(l=i.y0-=a,i.y1-=a,s=c-2;s>=0;--s)(a=(i=n[s]).y1+o-l)>0&&(i.y0-=a,i.y1-=a),l=i.y0})}}function oe(e){e.nodes.forEach(function(e){e.sourceLinks.sort(z),e.targetLinks.sort(B)}),e.nodes.forEach(function(e){var t=e.y0,n=t,r=e.y1,o=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function ie(){var e=0,t=0,n=1,r=1,o=24,i=8,a=null,s=J,l=P,c=void 0,u=32,d=2,h=ee,f=te;function g(){var g={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=n,h.y1=r,h.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return(0,Q.group)(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=v(n,r)),"object"!=typeof o&&(o=e.target=v(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(h,s),function(e,t){var n=0;if(null==t){for(var r=[],o=0;e.links.length>o;o++){var i=e.links[o],a=i.source.index,s=i.target.index;r[a]||(r[a]=[]),r[s]||(r[s]=[]),-1===r[a].indexOf(s)&&r[a].push(s)}var l=x(r);l.sort(function(e,t){return e.length-t.length});var c={};for(o=0;l.length>o;o++){var u=l[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,r=e.source.index;t===r||c[r]&&c[r][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(h,c),function(e,t){var n=0,r=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:r>n?"top":"bottom","top"==o.circularLinkType?n++:r++,e.nodes.forEach(function(e){j(e,t)!=j(o.source,t)&&j(e,t)!=j(o.target,t)||(e.circularLinkType=o.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),w(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max((0,Q.sum)(e.sourceLinks,R),(0,Q.sum)(e.targetLinks,R)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(h),function(e,t,n){var r,o,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(h,c,l);var f=i;if(null!==a){var g=(0,Q.groups)(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=(0,Q.max)(g,function(e){return e.length});y>1&&(f=Math.max(1,(r-t)*a/(y-1)))}(function(e,t,n){var r=(0,Q.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var o=(0,Q.min)(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/(0,Q.sum)(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=(0,Q.max)(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(h,f,o),ne(h,c,s),re(h,c,s,f,f,u),oe(h),V(h,s,d,10,8),ne(h,c,s),re(h,c,s,f,f,u),oe(h),V(h,s,d,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var r=n.links.filter(function(n){return j(n.source,t)==j(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Y(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=A(t,e);return e.y1-n}if(t.target.column>e.target.column)return A(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;o>i;i++)a+=r[i].width;t.y0=e.y1-a-t.width/2}})})}(h,s),function(e,t){let n=e;n.nodes.forEach(function(e){var r=n.links.filter(function(n){return j(n.target,t)==j(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Y(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=C(t,e);return e.y0-n}if(t.source.column>e.source.column)return C(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,a=0;o>i;i++)a+=r[i].width;t.y1=e.y1-a-t.width/2}})})}(h,s),function(e){var t=e.nodes,n=e.links,r=!1,o=!1;if(n.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==r||0==o){let r=function(t){return(t-i)/(a-i)*(e.y1-e.y0)+e.y0};var i=(0,Q.min)(t,function(e){return e.y0}),a=(0,Q.max)(t,function(e){return e.y1}),s=(e.y1-e.y0)/(a-i);1>s?(t.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1)}),n.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,n=r(e.y0)-e.y0;e.y0=r(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(h),V(h,s,d,10,8)}(g),g}return g.update=function(e){return oe(e),V(e,s,d,10,8),e},g.nodeWidth=function(e){return arguments.length?(o=+e,g):o},g.nodePadding=function(e){return arguments.length?(i=+e,g):i},g.nodePaddingRatio=function(e){return arguments.length?(a=+e,g):a},g.nodes=function(e){return arguments.length?(h="function"==typeof e?e:Z(e),g):h},g.links=function(e){return arguments.length?(f="function"==typeof e?e:Z(e),g):f},g.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:Z(e),g):s},g.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:Z(e),g):l},g.nodeSort=function(e){return arguments.length?(c=e,g):c},g.iterations=function(e){return arguments.length?(u=+e,g):u},g.circularLinkGap=function(e){return arguments.length?(d=+e,g):d},g.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],n=+o[1][0],r=+o[1][1],g):[[e,t],[n,r]]},g.size=function(o){return arguments.length?(e=t=0,n=+o[0],r=+o[1],g):[n-e,r-t]},g}function ae(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function se(e,t,n){const r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function le(e){const t=e.map(ae),n=t.length-1;return e=>{if(0>=e){const[e,n,r]=t[0];return se(e,n,r)}if(e>=1){const[e,r,o]=t[n];return se(e,r,o)}const r=e*n,o=Math.floor(r),i=r-o,[a,s,l]=t[o],[c,u,d]=t[o+1];return se(Math.round(a+(c-a)*i),Math.round(s+(u-s)*i),Math.round(l+(d-l)*i))}}var ce=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],ue=le(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),de=le(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),he=le(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),fe=le(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),ge=le(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),ye=le(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),pe={blues:ue,reds:de,greens:he,viridis:le(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),oranges:fe,purples:ge,greys:ye,plasma:le(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),inferno:le(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),magma:le(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),cividis:le(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),turbo:le(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"])},me=(le(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),le(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),le(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),le(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),le(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),le(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),le(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),require("d3-interpolate"));function be(e){const{sx:t,sTop:n,sBot:r,tx:o,tTop:i,tBot:a,cp1X:s,cp2X:l}=e,c=(n+r)/2,u=(i+a)/2;return{pathD:[`M${t},${n}`,`C${s},${n} ${l},${i} ${o},${i}`,`L${o},${a}`,`C${l},${a} ${s},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:s,y:c},{x:l,y:u},{x:o,y:u}],halfWidth:(r-n)/2}}}require("d3-shape");var ve=e=>{let t,n,r,o,i,a,s,l,c;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.x1,a=e.target.x0,s=(0,me.interpolateNumber)(i,a),l=s(.5),c=s(.5),`M${t},${i}C${t},${l} ${n},${c} ${n},${a}L${r},${a}C${r},${c} ${o},${l} ${o},${i}Z`;const u=e.sankeyWidth/2,d=(0,me.interpolateNumber)(e.source.x1,e.target.x0),{pathD:h}=be({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:d(.5),cp2X:d(.5)});return h};function xe(e){const t=e.sankeyWidth/2,n=(e._circularWidth??e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const n=r.sourceX,o=r.sourceY,i=r.targetX,a=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const s=Math.max(15,Math.min(40,.33*(r.rightFullExtent-n))),l=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${n},${o-t}L${n+s},${o-t}L${n+s},${o+t}L${n},${o+t}ZM${i},${a-t}L${i-l},${a-t}L${i-l},${a+t}L${i},${a+t}Z`}const o=r.sourceX,i=r.sourceY,a=r.targetX,s=r.targetY,l=r.rightFullExtent,c=r.leftFullExtent,u=r.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(n,15));return`M${o},${i-d*t}L${l},${i-d*t}L${l+n},${i-d*t+d*h}L${l+n},${u+d*n-d*h}L${l+n-h},${u+d*n}L${c-n+h},${u+d*n}L${c-n},${u+d*n-d*h}L${c-n},${s-d*t+d*h}L${c-n+h},${s-d*t}L${a},${s-d*t}L${a},${s+d*t}L${c+n},${s+d*t}L${c+n},${u-d*n}L${l-n},${u-d*n}L${l-n},${i+d*t}L${o},${i+d*t}Z`}var ke=new Set,we=new WeakMap;function Se(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=we.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,we.set(e,n);const r=new Proxy(e,{get(e,n,r){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;ke.has(e)||(ke.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,r)}});return n.set(t,r),r}var Me={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(N))-1:0},justify:P};function Ae(e){return"string"==typeof e?e:e.id}var Ce={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o="vertical"===n.orientation?"down":"right",i=n.nodeAlign||"justify",a=n.nodeWidth??15,s=n.nodePaddingRatio??.05,l=n.iterations??100,c=e.map(e=>({...e})),u=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let d;d="down"===o?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const h=ie().extent(d).links(u).nodes(c).nodeAlign(Me[i]||P).nodeId(e=>e.id).nodeWidth(a).iterations(l);h.nodePaddingRatio&&h.nodePaddingRatio(s),h();{let e=1/0,t=-1/0,n=1/0,o=-1/0;for(const r of c)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),n>r.y0&&(n=r.y0),r.y1>o&&(o=r.y1);for(const r of u){if(!r.circular||!r.circularPathData)continue;const i=r.circularPathData,a=(r._circularWidth??r.width??0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),n>i.verticalFullExtent-a&&(n=i.verticalFullExtent-a),i.verticalFullExtent+a>o&&(o=i.verticalFullExtent+a)}const i=t-e,a=o-n,s=r[0],l=r[1];if(i>0&&a>0&&(0>e||0>n||t>s||o>l)){const t=Math.min(s/i,l/a),r=-e*t+(s-i*t)/2,o=-n*t+(l-a*t)/2;for(const e of c)e.x0=e.x0*t+r,e.x1=e.x1*t+r,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of u)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+r,n.targetX=n.targetX*t+r,n.sourceY=n.sourceY*t+o,n.targetY=n.targetY*t+o,n.rightFullExtent=n.rightFullExtent*t+r,n.leftFullExtent=n.leftFullExtent*t+r,n.verticalFullExtent=n.verticalFullExtent*t+o,n.rightInnerExtent=n.rightInnerExtent*t+r,n.leftInnerExtent=n.leftInnerExtent*t+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+o,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of c){const t=f.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const g=new Map;for(const e of t)g.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of u){const t=Ae(e.source),n=Ae(e.target),r=g.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(r){r.y0=e.y0,r.y1=e.y1,r.sankeyWidth=e.width??0,r.circular=!!e.circular,r.circularPathData=e.circularPathData,r._circularWidth=e._circularWidth,r._circularStub=e._circularStub,r.path=e.path,r.circularLinkType=e.circularLinkType,r.direction=o;const i=f.get(t),a=f.get(n);i&&(r.source=i),a&&(r.target=a)}}},buildScene(e,t,n,r){const o="vertical"===n.orientation?"down":"right",i=n.nodeStyle,a=n.edgeStyle,s=n.edgeOpacity??.5,l=n.edgeColorBy||"source",c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ce,u=new Map;e.forEach((e,t)=>{u.set(e.id,c[t%c.length])});const d=[],h=[],f=[],g=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const r=i?i(Se(t,"nodeStyle")):{},a={fill:r.fill||u.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};g.set(t.id,("string"==typeof a.fill?a.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===o?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:a,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:a,datum:t,id:t.id,label:t.id})}const y=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of y){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";o="function"==typeof l?l(e)||o:"target"===l?g.get(r.id)||u.get(r.id)||o:g.get(t.id)||u.get(t.id)||o;const i=a?a(Se(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,r=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),a=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),l=i.fill||o;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+r},${t.sourceY-n}L${t.sourceX+r},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:l,fillOpacity:i.fillOpacity??s,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+r}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-a},${t.targetY-n}L${t.targetX-a},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:l,fillOpacity:i.fillOpacity??s,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-a,x1:t.targetX}});continue}let c;(c=e.circular&&e.circularPathData?xe(e):ve(e),c)&&h.push({type:"bezier",pathD:c,bezierCache:e.bezier,style:{fill:i.fill||o,fillOpacity:i.fillOpacity??s,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity},datum:e})}if(!1!==n.showLabels){const t=(p=n.nodeLabel)?"function"==typeof p?p:e=>e[p]||e.id:null;for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const a=t?t(n):n.id;if(!a)continue;let s,l,c;"down"===o?(s=n.y0+(n.y1-n.y0)/2,l=n.x1+14,c="start"):(r[0]/2>n.x0+e/2?(s=n.x0-6,c="end"):(s=n.x1+6,c="start"),l=n.y0+i/2),f.push({x:s,y:l,text:a+"",anchor:"down"===o?"middle":c,baseline:"middle",fontSize:11})}}var p;return{sceneNodes:d,sceneEdges:h,labels:f}}},Le=require("d3-force"),je=require("d3-scale");function Te(e){let t=1/0,n=-1/0;for(const r of e)t>r&&(t=r),r>n&&(n=r);return[t,n]}var Ee=()=>"undefined"!=typeof performance?performance.now():Date.now();function De(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function Re(e,t){const n=e();return Number.isFinite(n)?n:t}var Ie=class{constructor(e={}){this.randomSource=Math.random,this.subscribers=new Set,this.now=()=>this.advance(),this.random=()=>this.randomSource(),this.clock=e.clock??Ee,this.lastWallTime=Re(this.clock,0),this.logicalTime=this.lastWallTime,this.pausedValue=!0===e.paused,this.visibleValue=!1!==e.visible,this.setRandomSource(e.random,e.seed)}get isActive(){return!this.pausedValue&&this.visibleValue}get paused(){return this.pausedValue}get seed(){return this.seedValue}get visible(){return this.visibleValue}configure(e){this.setClock(e.clock),this.setRandomSource(e.random,e.seed)}setPaused(e){this.pausedValue!==e&&(this.advance(),this.pausedValue=e,this.emit())}setVisible(e){this.visibleValue!==e&&(this.advance(),this.visibleValue=e,this.emit())}snapshot(){return{now:this.now(),paused:this.pausedValue,seed:this.seedValue,visible:this.visibleValue}}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}advance(){const e=Re(this.clock,this.lastWallTime),t=Math.max(0,e-this.lastWallTime);return this.lastWallTime=e,this.isActive&&(this.logicalTime+=t),this.logicalTime}emit(){for(const e of this.subscribers)e()}setClock(e){const t=e??Ee;t!==this.clock&&(this.advance(),this.clock=t,this.lastWallTime=Re(t,this.lastWallTime))}setRandomSource(e,t){const n=function(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):void 0}(t);e===this.randomInput&&n===this.seedValue||(this.randomInput=e,this.seedValue=n,this.randomSource=e??(void 0===n?Math.random:De(n)))}},Ne={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o=n.forceStrength??.1,i=r[0]/2,a=r[1]/2,s=Math.max(.1,Math.min(1,Math.min(r[0],r[1])/200)),l=Math.min(.5,.06+1.8*(1-s)),c=n.__previousPositions;let u=0;const d=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=c?.get(t.id);e?u++:n?(t.x=n.x,t.y=n.y,u++):d.push(t)}const h=u>0&&.3>=(e.length>0?d.length/e.length:1);if(h){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of d){const r=Pe(e.id,t,n);if(r.length>0){let t=0,n=0;for(const e of r)t+=e.x,n+=e.y;const o=_e(e.id),i=o%360*(Math.PI/180),a=(10+o%20)*s;e.x=t/r.length+a*Math.cos(i),e.y=n/r.length+a*Math.sin(i)}else{const t=_e(e.id),n=t%360*(Math.PI/180),r=(15+t%30)*s;e.x=i+r*Math.cos(n),e.y=a+r*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const r=e[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(n+.5)*s,o=n*t;r.x=i+e*Math.cos(o),r.y=a+e*Math.sin(o)}}}const f=n.__skipForceSimulation||0===n.iterations?0:h?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),g=We(n.nodeSize,n.nodeSizeRange,e),y=e=>g(e);if(f>0){const c=new Map,u=new Map;for(const t of e)c.set(t.id,0),u.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id;c.set(t,(c.get(t)??0)+1),c.set(n,(c.get(n)??0)+1)}const d=(0,Le.forceLink)().strength(e=>{const t=e.weight,n="string"==typeof e.target?e.target:e.target.id,r=Math.max(1,Math.min(c.get("string"==typeof e.source?e.source:e.source.id)??1,c.get(n)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*o/(.1*r))}).distance(e=>{const t="string"==typeof e.source?u.get(e.source):e.source,n="string"==typeof e.target?u.get(e.target):e.target,r=(t?y(t):0)+(n?y(n):0)+Math.max(6,12*s);return Math.max(16,40*s,r)}).id(e=>e.id),g=(0,Le.forceSimulation)();if(void 0===n.random&&void 0===n.seed||g.randomSource(n.random??De(n.seed)),g.force("charge",(0,Le.forceManyBody)().strength(e=>{const t=c.get(e.id)??0;return-15*s*y(e)*Math.sqrt(t+1)})).force("collide",(0,Le.forceCollide)(e=>y(e)+3*s).strength(.9).iterations(2)).force("center",(0,Le.forceCenter)(i,a).strength(.8)).force("x",(0,Le.forceX)(i).strength(l)).force("y",(0,Le.forceY)(a).strength(l)).force("bounds",function(e,t,n=2,r=.6){let o=[];const i=i=>{const a=r*Math.max(i,.2);for(const r of o){const o=r.x??e[0]/2,i=r.y??e[1]/2,s=r.vx??0,l=r.vy??0,c=t(r)+n,u=Math.min(e[0]/2,c),d=Math.max(e[0]/2,e[0]-c),h=Math.min(e[1]/2,c),f=Math.max(e[1]/2,e[1]-c),g=o+s,y=i+l;u>g?r.vx=s+(u-g)*a:g>d&&(r.vx=s+(d-g)*a),h>y?r.vy=l+(h-y)*a:y>f&&(r.vy=l+(f-y)*a)}};return i.initialize=e=>{o=e},i}(r,y)),g.nodes(e),t.length>0){const e=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));d.links(e),g.force("link",d)}h?g.alpha(.3):.1>g.alpha()&&g.alpha(1),g.stop();for(let e=0;f>e;++e)g.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=y(t),n=f>0?2:0,o=Math.min(r[0]/2,e+n),i=Math.min(r[1]/2,e+n);t.x=Math.max(o,Math.min(r[0]-o,t.x)),t.y=Math.max(i,Math.min(r[1]-i,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const p=new Map;for(const t of e)p.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=p.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=p.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,r){const o=n.nodeStyle,i=n.edgeStyle,a=We(n.nodeSize,n.nodeSizeRange,e),s=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ce,l=new Map;e.forEach((e,t)=>{l.set(e.id,s[t%s.length])});const c=[],u=[],d=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=a(Se(t,"nodeSize")),r=o?o(Se(t,"nodeStyle")):{},i={fill:r.fill||l.get(t.id)||n.themeSemantic?.primary||"#007bff",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity};c.push({type:"circle",cx:t.x,cy:t.y,r:e,style:i,datum:t,id:t.id,label:t.id})}const h=new Map;for(const t of e)h.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:h.get(e.source),r="object"==typeof e.target?e.target:h.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const o=i?i(Se(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:o.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6},datum:e})}if(!1!==n.showLabels){const t=(f=n.nodeLabel)?"function"==typeof f?f:e=>e[f]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const r=a(Se(n,"nodeSize"));d.push({x:n.x,y:n.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:c,sceneEdges:u,labels:d}}};function Pe(e,t,n){const r=[];for(const o of t){const t="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=n.get(a);!e||0===e.x&&0===e.y||r.push({x:e.x,y:e.y})}}return r}function _e(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function We(e,t,n){if(n.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const r=t||[5,20],o=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&o.push(n)}if(0===o.length)return()=>r[0];const[i,a]=Te(o);if(i===a)return()=>(r[0]+r[1])/2;const s=(0,je.scaleLinear)().domain([i,a]).range(r).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?r[0]:s(n)}}var $e=require("d3-chord"),Oe=require("d3-shape"),Be=ce,ze={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:a}=n,s=Math.min(r[0],r[1])/2,l=s-i,c=r[0]/2,u=r[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:e=>e[h]??1:e=>e.value??1;var h;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const g=e.length,y=Array.from({length:g},()=>Array.from({length:g},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=f.get("string"==typeof e.source?e.source:e.source.id),r=f.get(t);if(void 0===n||void 0===r)continue;const o=d(e);y[n][r]=o}const p=(0,$e.chord)().padAngle(o);a&&p.sortGroups(a);const m=p(y),b=m.groups,v=(0,Oe.arc)().innerRadius(l).outerRadius(s);for(const t of b){const n=e[t.index],r=v.centroid({innerRadius:l,outerRadius:s,startAngle:t.startAngle,endAngle:t.endAngle});n.x=r[0]+c,n.y=r[1]+u,n.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=x.get("string"==typeof e.source?e.source:e.source.id),r=x.get(t);n&&(e.source=n),r&&(e.target=r)}const k=new Map;for(const e of t)k.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of m){const n=e[t.source.index].id,r=e[t.target.index].id,o=k.get(`${n}\0${r}`)||k.get(`${r}\0${n}`);o&&(o.__chordData=t)}},buildScene(e,t,n,r){const{groupWidth:o=20,edgeOpacity:i=.5}=n,a=Math.min(r[0],r[1])/2,s=a-o,l=r[0]/2,c=r[1]/2,u=n.nodeStyle,d=n.edgeStyle,h=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Be,g=new Map;e.forEach((e,t)=>{g.set(e.id,f[t%f.length])});const y=(0,$e.ribbon)().radius(s),p=[],m=[],b=[];for(let t=0;e.length>t;t++){const n=e[t],r=n.__arcData;if(!r)continue;let o;o=u?u(Se(n,"nodeStyle")).fill||g.get(n.id)||f[t%f.length]:g.get(n.id)||f[t%f.length];const i=u?u(Se(n,"nodeStyle")):{};p.push({type:"arc",cx:l,cy:c,innerR:s,outerR:a,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:{fill:o,stroke:i.stroke||"black",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const r=y(t);if(!r)continue;const o=He(r,l,c);let a=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(d)a=d(Se(e,"edgeStyle")).fill||a;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===h&&n?a=g.get(n.id)||a:t&&(a=g.get(t.id)||a)}const s=d?d(Se(e,"edgeStyle")):{};m.push({type:"ribbon",pathD:o,style:{fill:a,fillOpacity:s.fillOpacity??i,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity},datum:e})}if(!1!==n.showLabels){const t=(v=n.nodeLabel)?"function"==typeof v?v:e=>e[v]||e.id:null,r=a+12;for(const n of e){const e=n.__arcData;if(!e)continue;const o=t?t(n):n.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;b.push({x:l+Math.cos(a)*r,y:c+Math.sin(a)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var v;return{sceneNodes:p,sceneEdges:m,labels:b}}};function He(e,t,n){const r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;const o=[];let i=0;for(;r.length>i;){const e=r[i];if("M"===e||"L"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("C"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;3>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("Q"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;2>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("A"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&(o.push(Number(r[i])+t+""),i++),r.length>i&&(o.push(Number(r[i])+n+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(r[i]),i++)}return o.join(" ")}var Fe=require("d3-hierarchy"),qe=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Ye(e){const[t,n,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*r>150?"#222":"#fff"}function Ge(e,t,n){const r=t.nodeIDAccessor;return"function"==typeof r?r(e.data)+"":"string"==typeof r&&void 0!==e.data[r]?e.data[r]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function Xe(e){if(!e)return null;if("function"==typeof e){const t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function Ve(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:qe}function Ue(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:e.themeSemantic?.primary?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function Ke(e,t,n,r,o){if("horizontal"===o){const o=(e+n)/2;return`M ${e},${t} C ${o},${t} ${o},${r} ${n},${r}`}if("radial"===o){const o=(e+n)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+r)/2} T ${n},${r}`}{const o=(t+r)/2;return`M ${e},${t} C ${e},${o} ${n},${o} ${n},${r}`}}var Qe={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;if(!o)return;const i=n.chartType,a=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),s=n.hierarchySum,l="function"==typeof s?s:"string"==typeof s?e=>Number(e[s])||0:e=>Number(e.value)||0,c=(0,Fe.hierarchy)(o,a);c.sum(l),c.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=r;switch(i){case"tree":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=(0,Fe.tree)();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(c,n,u,d);break;case"cluster":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=(0,Fe.cluster)();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(c,n,u,d);break;case"treemap":!function(e,t,n,r){const o=t.padding??4,i=t.paddingTop??0,a=(0,Fe.treemap)().size([n,r]).tile(Fe.treemapBinary).padding(o);i>0&&a.paddingTop(i),a(e)}(c,n,u,d);break;case"circlepack":!function(e,t,n,r){const o=t.padding??4;(0,Fe.pack)().size([n,r]).padding(o)(e)}(c,n,u,d);break;case"partition":!function(e,t,n,r){(0,Fe.partition)().size([n,r]).padding(t.padding??1)(e)}(c,n,u,d)}const h=c.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;h.length>t;t++){const r=h[t],o={id:Ge(r,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:r.value??0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===i||"cluster"===i?Ze(o,r,n):"treemap"===i||"partition"===i?Je(o,r):"circlepack"===i&&et(o,r),o.__hierarchyNode=r,e.push(o),f.set(r,o)}if("tree"===i||"cluster"===i)for(const e of h)if(e.parent){const n=f.get(e.parent),r=f.get(e);n&&r&&t.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,r){const o=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,r,o,i){const a=[],s=[],l=[],c=n.treeOrientation||"vertical",u="radial"===c,d=r[0]/2,h=r[1]/2,f="number"==typeof(g=n.nodeSize)?g:5;var g;for(const t of e){let e=t.x,r=t.y;u&&(e+=d,r+=h);const i=o(Se(t,"nodeStyle"));let s=i.fill||Ue(n);if(n.colorByDepth&&void 0!==t.depth){const e=Ve(n);s=e[t.depth%e.length]}a.push({type:"circle",cx:e,cy:r,r:f,style:{fill:s,stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:t,id:t.id,label:t.id,depth:t.depth})}const y=n.edgeOpacity??.5;for(const e of t){const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=t.x,a=t.y,l=r.x,f=r.y;u&&(o+=d,a+=h,l+=d,f+=h);const g=Ke(o,a,l,f,c),p=i(Se(e,"edgeStyle"));s.push({type:"curved",pathD:g,style:{fill:"none",stroke:p.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:p.strokeWidth??1.5,opacity:p.opacity??y},datum:e})}if(!1!==n.showLabels){const t=Xe(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let r,o,i,a=n.x,s=n.y;if(u&&(a+=d,s+=h),u){const e=a-d,t=s-h,n=Math.sqrt(e*e+t*t);n>0?(r=a+e/n*10,o=s+t/n*10,i=0>e?"end":"start"):(r=a,o=s-12,i="middle")}else"horizontal"===c?(n.data?.children&&0!==n.data.children.length?(r=a-f-6,i="end"):(r=a+f+6,i="start"),o=s):(r=a,o=s+f+14,i="middle");l.push({x:r,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:a,sceneEdges:s,labels:l}}(e,t,n,r,o,i);case"treemap":case"partition":return function(e,t,n,r){const o=[],i=[];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const a=r(Se(n,"nodeStyle"));let s=a.fill||Ue(t);if(t.colorByDepth&&void 0!==n.depth){const e=Ve(t);s=e[n.depth%e.length]}o.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:{fill:s,stroke:a.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:a.strokeWidth??1,opacity:a.opacity},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Xe(t.nodeLabel),o=t.labelMode||"leaf",a="partition"===t.chartType;for(const s of e){const e=s.x1-s.x0,l=s.y1-s.y0;if(0>=e||0>=l)continue;const c=!(s.data?.children&&s.data.children.length>0);if(!a){if("leaf"===o&&!c)continue;if("parent"===o&&c)continue}const u=n?n(s):s.id;if(!u)continue;if((c?30:40)>e||(c?16:14)>l)continue;let d=r(Se(s,"nodeStyle")).fill||Ue(t);if(t.colorByDepth&&void 0!==s.depth){const e=Ve(t);d=e[s.depth%e.length]}const h="string"==typeof d?Ye(d):t.themeSemantic?.text??"#000";i.push(c?{x:s.x0+e/2,y:s.y0+l/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,l)/6)),fill:h}:{x:s.x0+4,y:s.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,n,0,o);case"circlepack":return function(e,t,n,r){const o=[],i=[];for(const n of e){const e=n.__radius??5;if(0>=e)continue;const i=r(Se(n,"nodeStyle"));let a=i.fill||Ue(t);if(t.colorByDepth&&void 0!==n.depth){const e=Ve(t);a=e[n.depth%e.length]}o.push({type:"circle",cx:n.x,cy:n.y,r:e,style:{fill:a,stroke:i.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Xe(t.nodeLabel);for(const o of e){const e=o.__radius??5,a=n?n(o):o.id;if(!a)continue;if(15>e)continue;const s=!(o.data?.children&&o.data.children.length>0);let l=r(Se(o,"nodeStyle")).fill||Ue(t);if(t.colorByDepth&&void 0!==o.depth){const e=Ve(t);l=e[o.depth%e.length]}if(s){const n="string"==typeof l?Ye(l):t.themeSemantic?.text??"#000";i.push({x:o.x,y:o.y,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else i.push({x:o.x,y:o.y-e+14,text:a+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Ze(e,t,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=t.x,r=t.y;e.x=r*Math.cos(n-Math.PI/2),e.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function Je(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function et(e,t){const n=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}var tt=require("d3-shape");function nt(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var rt={sankey:Ce,force:Ne,chord:ze,tree:Qe,cluster:Qe,treemap:Qe,circlepack:Qe,partition:Qe,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;o&&function(e,t,n,r,o){const i=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),a=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(n.nodeIDAccessor),s=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),l=n.orbitSize??2.95,c=n.orbitEccentricity??1,u="number"==typeof l?()=>l:l,d="number"==typeof c?()=>c:c,h=nt(n);h.metaMap.clear(),r.length=0,o.length=0;const f=new Map;function g(e){const t=f.get(e)??0;return f.set(e,t+1),0===t?e:`${e}__${t}`}const y=t[0]/2,p=t[1]/2,m=Math.min(t[0],t[1])/2*.85,b=g(a(e));r.push({id:b,x:y,y:p,x0:y,x1:y,y0:p,y1:p,width:0,height:0,value:0,depth:0,data:e}),h.metaMap.set(b,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,l,c,f,y,p){const m=i(t);if(!m?.length)return;const b=m.length;let v=0,x=0,k=0;for(;b>x;)x+=s[Math.min(k,s.length-1)],k++,v++;let w=0;for(let b=0;v>b;b++){const x=s[Math.min(b,s.length-1)],k=m.slice(w,w+x);if(!k.length)break;const S=(b+1)/v,M={id:n,depth:y,data:t,parentId:n},A=p?f/u(M)*S:f*S,C=(0,tt.pie)().value(e=>{const t=i(e)?.length;return t?4:1}).sort(null)(k),L=d(M);for(let t=0;k.length>t;t++){const i=(C[t].startAngle+C[t].endAngle)/2,s=k[t],u=g(a(s)),d=l+A*Math.sin(i),f=c+A*Math.cos(i)*L;r.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:y,data:s}),h.metaMap.set(u,{ring:A,angle:i,depth:y,parentId:n,eccentricity:L}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(s,u,d,f,A,y+1,!0)}w+=x}}(e,b,y,p,m,1,!1)}(o,r,n,e,t)},buildScene(e,t,n,r){const o=n.nodeStyle,i=n.nodeSize,a="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,s=[],l=[],c=[];if(!1!==n.orbitShowRings){const t=nt(n),r=new Map;for(const t of e)r.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=r.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;o.has(n)||o.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:r}]of o)for(let o=0;i>o;o++){const s=o/i*Math.PI*2,c=(o+1)/i*Math.PI*2;l.push({type:"line",x1:e+n*Math.sin(s),y1:t+n*Math.cos(s)*r,x2:e+n*Math.sin(c),y2:t+n*Math.cos(c)*r,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=a(Se(t,"nodeSize")),r=o?o(Se(t,"nodeStyle")):{};s.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:r.fill||n.themeSemantic?.primary||"#6366f1",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??(0===(t.depth??0)?1:.85)},datum:t,id:t.id,label:t.id,depth:t.depth})}const u=new Map;for(const t of e)u.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:u.get(e.source),n="object"==typeof e.target?e.target:u.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&l.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=a(Se(n,"nodeSize"));if(4>=e)continue;const r="function"==typeof t?t(n):t?n.data?.[t]??n.id:n.id;c.push({x:n.x,y:n.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:s,sceneEdges:l,labels:c}},tick:(e,t,n,r,o)=>!1!==n.orbitAnimated&&(function(e,t){const n=nt(t),r=t.orbitSpeed??.25,o=t.orbitRevolution??function(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),i=(("undefined"!=typeof performance?performance.now():Date.now())-n.startTime)/1e3,a=r*(Math.PI/6),s=new Map;for(const t of e)s.set(t.id,t);for(const t of e){const e=n.metaMap.get(t.id);if(!e||!e.parentId)continue;const r=s.get(e.parentId);if(!r)continue;const l=e.angle+i*a*o({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(l),t.y=r.y+e.ring*Math.cos(l)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)}};function ot(e){return rt[e]}function it(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(it))}function at(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function st(e,t,n){return e+(t-e)*n}var lt=require("d3-quadtree");function ct(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function ut(e){if(!e||"object"!=typeof e)return!1;const t=e;if("boolean"!=typeof t.circular)return!1;if("number"!=typeof t.halfWidth||!Number.isFinite(t.halfWidth))return!1;if(t.circular){if(!Array.isArray(t.segments)||0===t.segments.length)return!1;for(const e of t.segments)if(!dt(e))return!1;return!0}return dt(t.points)}function dt(e){if(!Array.isArray(e)||4!==e.length)return!1;for(const t of e){if(!t||"object"!=typeof t)return!1;const e=t;if("number"!=typeof e.x||!Number.isFinite(e.x))return!1;if("number"!=typeof e.y||!Number.isFinite(e.y))return!1}return!0}var ht=require("d3-interpolate");function ft(e,t,n){if(1>=n)return 1;const r=n-1;return function(e){const t=Math.max(0,Math.min(1,e.minOpacity??.1));if(Number.isNaN(e.age))return 1;if(e.age===1/0)return t;if(!Number.isFinite(e.extent)||0>=e.extent)return 1;const n=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>n?1:t;if("exponential"===e.type){const r=e.halfLife??e.extent/2;return t+Math.pow(.5,n/(r>0?r:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-n/e.extent))*(1-t)}({age:r-t,extent:r,type:e.type,halfLife:e.halfLife??n/2,threshold:e.stepThreshold??.5*n,minOpacity:e.minOpacity??.1})}var gt="rgba(34, 197, 94, 0.7)",yt=2e3,pt={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"};function mt(e,t){const n={...e};for(const e of t)n[pt[e]]++;return n}function bt(e,t,n){const r=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:r,revisions:mt(n,r)}}var vt=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=bt({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){const n=bt(e,t,this.revisions);this.revisions=n.revisions,this.latest=n;for(const e of[...this.listeners])e();return n}},xt=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],kt=["scene-style","data-paint","accessibility","evidence"],wt=(e,t)=>({retainedData:e,invalidations:t}),St=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Mt=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],At=["scene-geometry","data-paint","overlay","accessibility","evidence"],Ct=["scene-style","data-paint","accessibility","evidence"],Lt=["scene-geometry","data-paint","overlay","accessibility","evidence"],jt=[],Tt={chartType:wt("rebuild",St),nodeIDAccessor:wt("rebuild",St),sourceAccessor:wt("rebuild",St),targetAccessor:wt("rebuild",St),valueAccessor:wt("rebuild",St),edgeIdAccessor:wt("rebuild",St),childrenAccessor:wt("rebuild",St),hierarchySum:wt("rebuild",St),orientation:wt("preserve",Mt),nodeAlign:wt("preserve",Mt),nodePaddingRatio:wt("preserve",Mt),nodeWidth:wt("preserve",Mt),edgeSort:wt("preserve",Mt),iterations:wt("preserve",Mt),forceStrength:wt("preserve",Mt),padAngle:wt("preserve",Mt),groupWidth:wt("preserve",Mt),sortGroups:wt("preserve",Mt),treeOrientation:wt("preserve",Mt),edgeType:wt("preserve",Mt),padding:wt("preserve",Mt),paddingTop:wt("preserve",Mt),orbitMode:wt("preserve",Mt),orbitSize:wt("preserve",Mt),orbitSpeed:wt("preserve",Mt),orbitRevolution:wt("preserve",Mt),orbitRevolutionStyle:wt("preserve",Mt),orbitEccentricity:wt("preserve",Mt),orbitShowRings:wt("preserve",Mt),orbitAnimated:wt("preserve",Mt),customNetworkLayout:wt("preserve",Mt),layoutConfig:wt("preserve",Mt),nodeSize:wt("preserve",At),nodeSizeRange:wt("preserve",At),colorByDepth:wt("preserve",At),nodeLabel:wt("preserve",Lt),showLabels:wt("preserve",Lt),labelMode:wt("preserve",Lt),nodeStyle:wt("preserve",Ct),edgeStyle:wt("preserve",Ct),colorBy:wt("preserve",Ct),colorScheme:wt("preserve",Ct),themeCategorical:wt("preserve",Ct),themeSemantic:wt("preserve",Ct),edgeColorBy:wt("preserve",Ct),edgeOpacity:wt("preserve",Ct),showParticles:wt("preserve",Ct),particleStyle:wt("preserve",Ct),decay:wt("preserve",Ct),pulse:wt("preserve",Ct),thresholds:wt("preserve",Ct),staleness:wt("preserve",Ct),layoutSelection:wt("preserve",Ct),clock:wt("preserve",jt),random:wt("preserve",jt),seed:wt("preserve",jt),tensionConfig:wt("preserve",jt),transition:wt("preserve",jt),introAnimation:wt("preserve",jt),onLayoutError:wt("preserve",jt),__skipForceSimulation:wt("preserve",jt),__hierarchyRoot:wt("preserve",jt),__orbitState:wt("preserve",jt),__previousPositions:wt("preserve",jt)},Et=wt("preserve",Mt),Dt=class{constructor(){this.tracker=new vt}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},xt)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},kt):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const r of e){const e=Tt[r]??Et;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},Rt=new WeakMap;var It=require("d3-scale"),Nt={category10:ce,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...pe},Pt=ce,_t="#007bff";function Wt(e,t,n=Pt){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=Nt[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}var $t=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Ot=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],Bt=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function zt(e,t,n){if("function"==typeof t){const r=t(e);return n&&r&&"string"==typeof r&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||Bt.has(t)}(r)?n(r):r}const r=e?.[t]+"";return n?n(r):Pt[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(r))%Pt.length]}function Ht(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;const n=e[t];return"string"==typeof n&&n.length>0?n:void 0}function Ft(e,t,n="category10"){if(n&&"object"==typeof n&&!Array.isArray(n)){const e=n;return t=>Ht(e,t)??"#999"}const r=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>e+""))),o=r.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return(0,It.scaleOrdinal)().domain(r).range(n).unknown("#999");const i=Nt[n]||Nt.category10;if(o&&"function"==typeof i){let e=-1/0;for(const t of r){const n=Number(t);n>e&&(e=n)}return t=>i(Number(t)/e)}{const e=Array.isArray(i)?i:Pt;return(0,It.scaleOrdinal)().domain(r).range(e).unknown("#999")}}function qt(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&Ht(n,e)||"#4e79a7":t=>{if(n){const e=Ht(n,t);if(e)return e}let r=0;for(let e=0;t.length>e;e++)r=31*r+t.charCodeAt(e)|0;return e[Math.abs(r)%e.length]??"#4e79a7"}}function Yt({config:e,customLayout:t,size:n,nodes:r,edges:o,previousResult:i,revision:a}){const s=Wt(e.colorScheme,e.themeCategorical,ce),l={nodes:r,edges:o,dimensions:{width:n[0],height:n[1],plot:{x:0,y:0,width:n[0],height:n[1]}},theme:{semantic:e.themeSemantic??{},categorical:[...s]},resolveColor:qt(s,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};try{return{kind:"success",result:t(l)}}catch(t){const n=null!==i,r=function(e,t,n,r){const o=function(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:e+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(t),i="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:i,message:`Semiotic ${e} ${i} failed: ${o.message}`,error:o,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:r}}("network",t,n,a);"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t);try{e.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:r,preservedLastGoodScene:n}}}var Gt=class e{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this.customLayoutHtmlMarks=[],this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,this.particlePool=null,this.updateResults=new Dt,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this._decayAgeMap=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._networkDecayCache=null,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig={...g,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new p(2e3))}currentTime(){return this.config.clock?.()??("undefined"!=typeof performance?performance.now():Date.now())}updateConfig(e){const t=this.config,n={...t,...e};t.__orbitState&&(n.__orbitState=t.__orbitState),t.__hierarchyRoot&&(n.__hierarchyRoot=t.__hierarchyRoot),void 0===e.layoutSelection&&null!=t.layoutSelection&&(n.layoutSelection=t.layoutSelection);const r=[...new Set([...Object.keys(t),...Object.keys(n)])].filter(e=>t[e]!==n[e]);this.config=n,this.tensionConfig={...g,...n.tensionConfig},!n.showParticles||"sankey"!==n.chartType&&!n.customNetworkLayout||this.particlePool||(this.particlePool=new p(2e3)),this.updateResults.recordConfig(r)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null,this.updateResults.recordData("replace",1)}ingestBounded(e,t,n,r){const{nodeIDAccessor:o="id",sourceAccessor:i="source",targetAccessor:a="target",valueAccessor:s="value"}=this.config,l="function"==typeof o?o:e=>e[o],c="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>e[a],d="function"==typeof s?s:e=>e[s]??1;this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const t of e){const e=l(t)+"";this.nodes.set(e,{...ct(e),data:t})}for(let e=0;t.length>e;e++){const n=t[e],r=c(n)+"",o=u(n)+"",i=d(n),a=null==i?NaN:Number(i),s=Number.isFinite(a)?a:1;this.nodes.has(r)||this.nodes.set(r,{...ct(r),data:n}),this.nodes.has(o)||this.nodes.set(o,{...ct(o),data:n});const l=`${r}\0${o}\0${e}`,h={source:r,target:o,value:s,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l};n&&"object"==typeof n&&ut(n.bezier)&&(h.bezier=n.bezier),this.edges.set(l,h)}r?.deferLayout||this.runLayout(n),this.updateResults.recordData("replace",e.length+t.length)}ingestBoundedWithResult(e,t,n,r){return this.ingestBounded(e,t,n,r),this.updateResults.last}applyForceLayoutPositions(e,t){for(const[t,n]of Object.entries(e)){const e=this.nodes.get(t);e&&(e.x=n.x,e.y=n.y)}this.config.__skipForceSimulation=!0;try{this.runLayout(t)}finally{this.config.__skipForceSimulation=void 0}}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:r}=e,o=0===this.nodes.size;let i=!1;const a=this.currentTime();this.lastIngestTime=a,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,ct(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,ct(n)),this.nodeTimestamps.set(n,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,n),l=this.edges.get(s);let c=!1;l?(l.value+=r,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(s,{source:t,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.newEdge,i=!0);const u=o||i||c||this.tension>=this.tensionConfig.threshold;return this.updateResults.recordData("ingest",1),u}ingestEdgeWithResult(e){return this.ingestEdge(e),this.updateResults.last}runLayout(e){if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const t=ot(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values());const r=Array.from(this.edges.values());if(0===n.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.supportsStreaming&&!t.hierarchical){const e=new Map;for(const t of n)void 0!==t._prevX0?e.set(t.id,{x:(t._prevX0??0)+((t._prevX1??0)-(t._prevX0??0))/2,y:(t._prevY0??0)+((t._prevY1??0)-(t._prevY0??0))/2}):0===t.x&&0===t.y||e.set(t.id,{x:t.x,y:t.y});if(this._lastPositionSnapshot)for(const[t,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(t.computeLayout(n,r,this.config,e),this.config.__previousPositions=void 0,t.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const e of n)this.nodes.set(e.id,e);for(let e=0;r.length>e;e++){const t=r[e],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const n=e.get(t.id);n&&(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,n=Array.from(this.nodes.values())}this.finalizeLayout();const o=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||o.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=o,this.saveTargetPositions();const i=n.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),a=this.config.transition?.duration??this.tensionConfig.transitionDuration,s=["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType);if(!this._hasRenderedOnce&&this.config.introAnimation&&s&&n.length>0&&a>0){const t=e[0]/2,n=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=n,e._prevY1=n;for(const e of this.edges.values())e._prevY0=n,e._prevY1=n,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:a}}else i&&a>0&&(this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:a});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime=this.currentTime()),this.previousNodeIds=e,this.previousEdgeKeys=t}restyleScene(e){const t=function({nodes:e,edges:t,restyle:n,restyleEdge:r,baseStyles:o,selection:i}){const a=!(!n&&!r);if(n)for(const t of e){const e=o.get(t)??t.style,r=n(t,i);t.style=r?{...e,...r}:e}if(r)for(const e of t){const t=o.get(e)??e.style,n=r(e,i);e.style=n?{...t,...n}:t}return a}({nodes:this.sceneNodes,edges:this.sceneEdges,restyle:this._customRestyle,restyleEdge:this._customRestyleEdge,baseStyles:this._baseStyles,selection:e});this.markStylePaintPending(),this.updateResults.recordRestyle(t)}buildScene(e){if(this.config.customNetworkLayout){const t=Yt({config:this.config,customLayout:this.config.customNetworkLayout,size:e,nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values()),previousResult:this.lastCustomLayoutResult,revision:this.layoutVersion});if("failure"===t.kind)return this.lastCustomLayoutFailure=t.diagnostic,void(t.preservedLastGoodScene||(this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._sceneNodesRevision++));const n=t.result;return this.sceneNodes=n.sceneNodes??[],this.sceneEdges=n.sceneEdges??[],this.labels=n.labels??[],this.customLayoutOverlays=n.overlays??null,this.customLayoutHtmlMarks=n.htmlMarks??[],this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=n.restyle,this._customRestyleEdge=n.restyleEdge,this.hasCustomRestyle=!(!n.restyle&&!n.restyleEdge),this.hasCustomRestyle&&(this._baseStyles=function(e,t){const n=new WeakMap;for(const t of e)n.set(t,t.style);for(const e of t)n.set(e,e.style);return n}(this.sceneNodes,this.sceneEdges),this.restyleScene(this.config.layoutSelection??null)),void function(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:r,warned:o}=e;it(r)&&0===n.length&&at(o,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),n.length>0&&n.every(e=>null==e.datum)&&at(o,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}({label:"customNetworkLayout",nodes:this.sceneNodes,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned})}this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null;const t=ot(this.config.chartType);if(!t)return void this._sceneNodesRevision++;const n=t.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=t.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:o,sceneEdges:i,labels:a}=t.buildScene(n,r,this.config,e);this.sceneNodes=o,this.sceneEdges=i,this.labels=a,this._sceneNodesRevision++}rebuildNodeQuadtree(){let t=0,n=0;for(const e of this.sceneNodes)"circle"===e.type&&(t++,e.r>n&&(n=e.r));if(this._maxNodeRadius=n,e.QUADTREE_THRESHOLD>=t)return void(this._nodeQuadtree=null);const r=Array(t);let o=0;for(const e of this.sceneNodes)"circle"===e.type&&(r[o++]=e);this._nodeQuadtree=(0,lt.quadtree)().x(e=>e.cx).y(e=>e.cy).addAll(r)}get nodeQuadtree(){return this._nodeQuadtreeRevision!==this._sceneNodesRevision&&(this.rebuildNodeQuadtree(),this._nodeQuadtreeRevision=this._sceneNodesRevision),this._nodeQuadtree}get maxNodeRadius(){return this._maxNodeRadius}_ensureArrays(){this._arrCacheVersion===this.layoutVersion&&this._nodesArrCache&&this._edgesArrCache||(this._nodesArrCache=Array.from(this.nodes.values()),this._edgesArrCache=Array.from(this.edges.values()),this._arrCacheVersion=this.layoutVersion)}get nodesArray(){return this._ensureArrays(),this._nodesArrCache}get edgesArray(){return this._ensureArrays(),this._edgesArrCache}get isAnimating(){const e=ot(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=ot(this.config.chartType);if(!n?.tick)return!1;const r=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(r,o,this.config,e,t)}cancelIntroAnimation(){this.transition=null;for(const e of this.nodes.values())e._prevX0=void 0,e._prevX1=void 0,e._prevY0=void 0,e._prevY1=void 0;for(const e of this.edges.values())e._prevY0=void 0,e._prevY1=void 0,e._prevSankeyWidth=void 0,e._introFromZero=!1}advanceTransition(e){if(!this.transition)return!1;const t=function(e,t){return Math.min((e-t.startTime)/t.duration,1)}(e,this.transition),n=function(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=st(e._prevX0,e._targetX0,n),e.x1=st(e._prevX1,e._targetX1,n),e.y0=st(e._prevY0,e._targetY0,n),e.y1=st(e._prevY1,e._targetY1,n));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=st(e._prevY0,e._targetY0,n),e.y1=st(e._prevY1,e._targetY1,n),e.sankeyWidth=st(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const n=e?.get(t.id);n&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const n=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(n){e._prevY0=n.y0,e._prevY1=n.y1,e._prevSankeyWidth=n.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){!function(e,t,n=.5){const r="string"==typeof e.source?t.get(e.source):e.source,o="string"==typeof e.target?t.get(e.target):e.target;!r||!o||(e.bezier=e.circular&&e.circularPathData?function(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),r=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let r;r="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let e=0;r.length-1>e;e++){const t=r[e],n=r[e+1],i=n.x-t.x,a=n.y-t.y;o.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},n])}return{circular:!0,segments:o,halfWidth:t}}(e):function(e,t,n,r=.5){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,a=n.x0,s=(0,ht.interpolateNumber)(i,a);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:s(r)},{x:e.y1,y:s(1-r)},{x:e.y1,y:a}],halfWidth:o}}const i=t.x1,a=n.x0,s=(0,ht.interpolateNumber)(i,a);return{circular:!1,points:[{x:i,y:e.y0},{x:s(r),y:e.y0},{x:s(1-r),y:e.y1},{x:a,y:e.y1}],halfWidth:o}}(e,r,o,n))}(e,this.nodes,.5)}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){!function(e){const t=e.pulse;if(!t)return;const n=t.duration??500,r=t.color??"rgba(255,255,255,0.6)",o=t.glowRadius??4,{now:i}=e;for(const t of e.sceneNodes){const a=t.id;if(!a)continue;const s=e.nodeTimestamps.get(a);if(!s)continue;const l=i-s;n>l&&(t._pulseIntensity=1-l/n,t._pulseColor=r,t._pulseGlowRadius=o)}for(const t of e.sceneEdges){const o=t.datum;if(!o)continue;const a="object"==typeof o.source?o.source?.id:o.source,s="object"==typeof o.target?o.target?.id:o.target;if(!a||!s)continue;const l=e.edgeTimestamps.get(`${a}\0${s}`);if(!l)continue;const c=i-l;n>c&&(t._pulseIntensity=1-c/n,t._pulseColor=r)}}({sceneNodes:this.sceneNodes,sceneEdges:this.sceneEdges,nodeTimestamps:this.nodeTimestamps,edgeTimestamps:this.edgeTimestamps,pulse:this.config.pulse,now:e})}applyDecay(){this._networkDecayCache||(this._networkDecayCache={sortedNodes:null,ageMap:null}),this._decaySortedNodes||(this._networkDecayCache.sortedNodes=null,this._networkDecayCache.ageMap=null),function(e){const t=e.decay;if(!t)return;const n=e.nodeTimestamps.size;if(1>=n)return;if(!e.cache.sortedNodes){e.cache.sortedNodes=Array.from(e.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]);const t=new Map;for(let n=0;e.cache.sortedNodes.length>n;n++)t.set(e.cache.sortedNodes[n][0],n);e.cache.ageMap=t}const r=e.cache.ageMap;for(const o of e.sceneNodes){const e=o.id;if(!e)continue;const i=r.get(e);if(void 0===i)continue;const a=ft(t,i,n);o.style={...o.style,opacity:(o.style?.opacity??1)*a}}}({sceneNodes:this.sceneNodes,nodeTimestamps:this.nodeTimestamps,decay:this.config.decay,cache:this._networkDecayCache}),this._decaySortedNodes=this._networkDecayCache.sortedNodes,this._decayAgeMap=this._networkDecayCache.ageMap}applyTopologyDiff(e){!function(e){for(const t of e.sceneNodes)t._pulseColor===gt&&(t._pulseIntensity=0,t._pulseColor=void 0,t._pulseGlowRadius=void 0);if(0===e.addedNodes.size)return;const t=e.now-e.lastTopologyChangeTime;if(t>=yt)return;const n=1-t/yt;for(const t of e.sceneNodes){const r=t.id;r&&e.addedNodes.has(r)&&(t._pulseIntensity=Math.max(t._pulseIntensity??0,n),t._pulseColor=gt,t._pulseGlowRadius=8)}}({sceneNodes:this.sceneNodes,addedNodes:this.addedNodes,lastTopologyChangeTime:this.lastTopologyChangeTime,now:e})}get hasActiveTopologyDiff(){return function(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){return 0!==e.size&&yt>n-t}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(e){!function(e){const t=e.thresholds;if(!t)return;const n=t.warningColor??"#f59e0b",r=t.criticalColor??"#ef4444",o=!1!==t.pulse;for(const i of e.sceneNodes){const a=i.id;if(!a)continue;const s=e.nodes.get(a);if(!s)continue;const l=t.metric(s);let c=null;void 0===t.critical||t.critical>l?void 0===t.warning||t.warning>l||(c=n):c=r,c&&(i.style={...i.style,fill:c},o&&(i._pulseIntensity=.6+.4*Math.sin(e.now/300),i._pulseColor=c,i._pulseGlowRadius=6))}}({sceneNodes:this.sceneNodes,nodes:this.nodes,thresholds:this.config.thresholds,now:e})}get hasActiveThresholds(){return function(e,t){if(!t)return!1;for(const n of e){const e=t.metric(n);if(void 0!==t.warning&&e>=t.warning||void 0!==t.critical&&e>=t.critical)return!0}return!1}(this.nodes.values(),this.config.thresholds)}get hasActivePulses(){return function(e){const t=e.pulse;if(!t||0===e.lastIngestTime)return!1;const n=e.now??("undefined"!=typeof performance?performance.now():Date.now());return(t.duration??500)>n-e.lastIngestTime}({pulse:this.config.pulse,lastIngestTime:this.lastIngestTime})}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){const n=this.nodes.get(e);if(!n)return this.updateResults.recordNoop("update"),null;const r=n.data?{...n.data}:{};return n.data=t(n.data??{}),this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",1),r}updateEdge(e,t,n){const r=this.config.valueAccessor,o="function"==typeof r?r:r?e=>e[r]:e=>e.value,i=[];for(const[,r]of this.edges)if(("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t){i.push(r.data?{...r.data}:{}),r.data=n(r.data??{});const e=o(r.data);null!=e&&(r.value=Number(e))}return i.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",i.length)):this.updateResults.recordNoop("update"),i}removeNode(e){if(!this.nodes.has(e))return this.updateResults.recordNoop("remove"),!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",1),!0}removeEdge(e,t){const n=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const r="function"==typeof t?t:e=>e?.[t];for(const[t,o]of this.edges)o.data&&r(o.data)===e&&n.push(t)}else for(const[r,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t&&n.push(r);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",n.length)):this.updateResults.recordNoop("remove"),n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this._decayAgeMap=null,this._nodeQuadtree=null,this._nodesArrCache=null,this._edgesArrCache=null,this._sceneNodesRevision++,this.tension=0,this.layoutVersion++,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.particlePool&&this.particlePool.clear(),this.updateResults.recordData("clear")}};Gt.QUADTREE_THRESHOLD=500;var Xt=Gt;Object.assign(Xt.prototype,{getLastUpdateResult:function(){return this.updateResults.last},getUpdateSnapshot:function(){return this.updateResults.last},subscribeUpdateResult:function(e){return this.updateResults.subscribe(e)},setLayoutSelection:function(e){this.config.layoutSelection=e},markStylePaintPending:function(){Rt.set(this,!0)},consumeStylePaintPending:function(){const e=!0===Rt.get(this);return Rt.delete(this),e}});var Vt=require("react"),Ut={sceneGeometry:0,layout:0,domain:0};function Kt(e){const{domain:t,layout:n,sceneGeometry:r}=e.revisions;return{domain:t,layout:n,sceneGeometry:r}}function Qt(e,t){return{sceneGeometry:Math.max(e.sceneGeometry,t.sceneGeometry),layout:Math.max(e.layout,t.layout),domain:Math.max(e.domain,t.domain)}}var Zt="production"!==process.env.NODE_ENV,Jt={revisions:Ut,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},en=class{constructor(e="scene host"){this.hostName=e,this.lastConsumed=Ut,this.lastObserved=Ut,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}observeUpdateResult(e){Zt&&(this.lastObserved=Qt(this.lastObserved,Kt(e)))}beforeCompute(e,t){if(!Zt)return Jt;const n=Qt(Kt(e),this.lastObserved),r=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),o=!((i=n).sceneGeometry===(a=this.lastConsumed).sceneGeometry&&i.layout===a.layout&&i.domain===a.domain);var i,a;return{revisions:n,signature:r,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:o,warnUnconsumed:!t&&o&&this.lastUnconsumedWarning!==r}}afterCompute(e,t,n){if(Zt){if(t&&e.wasUnconsumed&&(this.lastConsumed=e.revisions),e.warnUnconsumed&&!t)return console.warn(`[semiotic] ${this.hostName} observed scene-affecting revisions without a scene rebuild: ${e.signature}.`),void(this.lastUnconsumedWarning=e.signature);t&&e.sawSignals&&!e.wasUnconsumed&&!n&&this.lastDuplicateWarning!==e.signature?(console.warn(`[semiotic] ${this.hostName} performed scene rebuild with unchanged scene revisions: ${e.signature}.`),this.lastDuplicateWarning=e.signature):t&&!e.sawSignals&&(this.lastDuplicateWarning="")}}},tn=(0,Vt.memo)(function({store:e,diagnostics:t}){return(0,Vt.useEffect)(()=>{const n=()=>t.observeUpdateResult(e.getUpdateSnapshot());return n(),e.subscribeUpdateResult(n)},[t,e]),null}),nn=l(require("react"));function rn(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:nn.createElement(nn.Fragment,null,...t)}var on=l(require("react")),an=require("react/jsx-runtime"),sn={isActive:!1,predicate:()=>!0},ln=on.createContext(null);function cn({value:e,children:t}){return(0,an.jsx)(ln.Provider,{value:e,children:t})}function un(){return on.useContext(ln)??sn}function dn(e,t){return null!=e?(0,an.jsx)(cn,{value:t,children:e}):e}var hn=require("react"),fn=[40,40],gn=[.5,.5];function yn(e,t){const[n,r]=e.viewBox??fn,[o,i]=e.anchor??gn,a=r>0?r:1,s=Math.max(0,t)/a,l=(n>0?n:a)*s,c=a*s;return{width:l,height:c,scale:s,offsetX:-o*l,offsetY:-i*c}}function pn(e,t){const n=yn(e,t),r=[[n.offsetX,n.offsetY],[n.offsetX+n.width,n.offsetY],[n.offsetX,n.offsetY+n.height],[n.offsetX+n.width,n.offsetY+n.height]];let o=0;for(const[e,t]of r){const n=Math.sqrt(e*e+t*t);n>o&&(o=n)}return o}function mn(e,t,n,r){if("none"!==e)return"color"===e||null==e?t??r:"accent"===e?n:e}var bn=null;function vn(e){if("undefined"==typeof Path2D)return null;bn||(bn=new Map);const t=bn.get(e);if(t)return t;const n=new Path2D(e);return bn.size>1024&&bn.clear(),bn.set(e,n),n}function xn(e,t,n=0,r="horizontal"){const[o,i]=e.viewBox??fn,a=Math.min(1,Math.max(0,n)),s=Math.min(1,Math.max(0,t));return s>a?a>0||1>s?"vertical"===r?{x:0,y:i*(1-s),width:o,height:i*(s-a)}:{x:o*a,y:0,width:o*(s-a),height:i}:null:{x:0,y:0,width:0,height:0}}function kn(e,t){const n=yn(e,t);return{centerDx:n.offsetX+n.width/2,centerDy:n.offsetY+n.height/2,halfWidth:n.width/2,halfHeight:n.height/2,radius:Math.hypot(n.width,n.height)/2}}function wn(e,t,n,r,o,i=e=>e){for(const a of t.parts){const t=vn(a.d);if(!t)continue;const s=a.opacity??1,l=e.globalAlpha;1!==s&&(e.globalAlpha=l*s);const c=o?"none"===a.fill?void 0:o:mn(a.fill,n,r);c&&(e.fillStyle=i(c),e.fill(t));const u=o?a.stroke&&"none"!==a.stroke?o:void 0:mn(a.stroke??"none",n,r);u&&(e.strokeStyle=i(u),e.lineWidth=a.strokeWidth??1,e.lineCap=a.strokeLinecap??"butt",e.lineJoin=a.strokeLinejoin??"miter",e.stroke(t)),1!==s&&(e.globalAlpha=l)}}function Sn(e,t,n){const{group:r,indexInGroup:o}=t,i=n.byGroup.get(r);switch(e){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:t.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(r);return n.groups.length-1>e?Mn(n,n.groups[e+1],i[o]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(r);return e>0?Mn(n,n.groups[e-1],i[o]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function Mn(e,t,n){const r=e.byGroup.get(t);let o=0,i=Math.abs(r[0].x-n.x);for(let e=1;r.length>e;e++){const t=Math.abs(r[e].x-n.x);i>t&&(i=t,o=e)}return r[o]._flatIndex}function An(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}var Cn=require("react/jsx-runtime"),Ln="var(--semiotic-focus, #005fcc)";function jn({active:e,hoverPoint:t,margin:n,size:r,shape:o="circle",width:i,height:a,pathData:s}){if(!e||!t)return null;const l=t.x+n.left,c=t.y+n.top;let u;if("geoarea"!==o&&"path"!==o||!s)if("rect"===o&&null!=i&&null!=a){const e=Math.max(i,4),t=Math.max(a,4);u=(0,Cn.jsx)("rect",{x:l-e/2-3,y:c-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:Ln,strokeWidth:2,strokeDasharray:"4,2"})}else u=(0,Cn.jsx)("circle","wedge"===o?{cx:l,cy:c,r:12,fill:"none",stroke:Ln,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:Ln,strokeWidth:2,strokeDasharray:"4,2"});else u=(0,Cn.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:(0,Cn.jsx)("path",{d:s,fill:"none",stroke:Ln,strokeWidth:2.5,strokeDasharray:"6,3"})});return(0,Cn.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}var Tn=l(require("react")),En=["name","label","title"],Dn=["type","kind","category","group","class","status","role","shape"],Rn=["value","amount","total","count","weight","score"],In=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function Nn(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}function Pn(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,r=!1!==t.skipPositional,o=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(r&&In.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&o.push({key:t,lower:t.toLowerCase(),value:n})}if(0===o.length)return{entries:[]};let i=o.findIndex(e=>En.includes(e.lower));const a=i>=0;0>i&&(i=o.findIndex(e=>"id"===e.lower)),0>i&&(i=o.findIndex(e=>"string"==typeof e.value));const s=0>i?void 0:o[i];let l=o.filter((e,t)=>t!==i);a&&(l=l.filter(e=>"id"!==e.lower));const c=Nn(l,Dn),u=Nn(l,Rn),d=new Set(Dn),h=new Set(Rn),f=[];c&&f.push({key:c.key,value:c.value}),u&&f.push({key:u.key,value:u.value});for(const e of l){if(f.length>=n)break;e!==c&&e!==u&&(d.has(e.lower)||h.has(e.lower)||f.push({key:e.key,value:e.value}))}return{titleKey:s?.key,title:s?.value,entries:f}}var _n=require("react/jsx-runtime"),Wn={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function $n(e,t){return"function"==typeof t?t(e):e[t]}function On(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function Bn(e={}){const{fields:t,title:n,format:r,style:o={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let a;const s=[];if(n){const t=$n(e,n);a=On(t,r)}if(t&&t.length>0)t.forEach(t=>{let n,o,i;"string"==typeof t?(n=t,o=t,i=r):(n=t.label,o=t.accessor||t.key||"",i=t.format||r);const a=$n(e,o);s.push({label:n,value:On(a,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){a=On(e[n],r);break}if(!a){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(a=On(e[t[0]],r))}}const l={...Wn,...o};return(0,_n.jsxs)("div",{className:("semiotic-tooltip "+i).trim(),style:l,children:[a&&(0,_n.jsx)("div",{style:{fontWeight:s.length>0?"bold":"normal"},children:a}),s.map((e,t)=>(0,_n.jsxs)("div",{style:{marginTop:0===t&&a?"4px":0},children:[e.label&&(0,_n.jsxs)("span",{children:[e.label,": "]}),e.value]},t))]})}}function zn(e){if(!0!==e){if("function"==typeof e){const t=e;return e=>{let n=h(!0===e?.__semioticHoverData||e&&void 0!==e.data&&"number"==typeof e.x&&"number"==typeof e.y&&e&&("node"===e.type||"edge"===e.type||void 0!==e.nodeOrEdge||void 0!==e.allSeries||void 0!==e.stats||void 0!==e.__chartType)?e.data??{}:e);if(!n)return null;if(("node"===e?.nodeOrEdge&&"number"==typeof n?.x0&&"number"==typeof n?.x1||"edge"===e?.nodeOrEdge&&"number"==typeof n?.sankeyWidth)&&n.data&&"object"==typeof n.data&&(n=n.data),!n)return null;const r=t(n);return null==r?null:(0,_n.jsx)("div",{className:"semiotic-tooltip",style:Wn,children:r})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?Bn(e):"multi"===e?("undefined"!=typeof process&&"production"!==process.env?.NODE_ENV&&console.warn('[semiotic] tooltip="multi" reached normalizeTooltip — prefer charts that set tooltipMode (LineChart, AreaChart, StackedAreaChart, DifferenceChart). Rendering MultiLineTooltip content as a fallback.'),function(e={}){const{fields:t=[],title:n,format:r,style:o={},className:i="",showLabels:a=!0,separator:s=": "}=e;return e=>{if(!e||"object"!=typeof e)return null;const l=[];if(n){const t=$n(e,n);l.push({value:On(t,r)})}if(t&&Array.isArray(t)&&t.length>0)t.forEach(t=>{let n,o,i;"string"==typeof t?(n=t,o=t,i=r):(n=t.label,o=t.accessor||t.key||"",i=t.format||r);const s=On($n(e,o),i);l.push({label:a?n:void 0,value:s})});else{const t=Pn(e,{skipPositional:!1});null!=t.title&&l.push({label:void 0,value:On(t.title,r),bold:!0}),t.entries.forEach(e=>{l.push({label:a?e.key:void 0,value:On(e.value,r)})})}const c={...Wn,...o};return Array.isArray(l)&&0!==l.length?(0,_n.jsx)("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+i).trim(),style:c,children:l.map((e,t)=>(0,_n.jsxs)("div",{style:{marginBottom:l.length-1>t?"4px":0,fontWeight:e.bold?"bold":void 0},children:[e.label&&(0,_n.jsxs)("strong",{children:[e.label,s]}),e.value]},t))}):null}}()):Bn())}}var Hn=require("react/jsx-runtime");function Fn({x:e,y:t,containerWidth:n,containerHeight:r,margin:o,children:i,className:a="stream-frame-tooltip",zIndex:s=1}){const l=Number.isFinite(e)&&Number.isFinite(t),c=Tn.useRef(null),[u,d]=Tn.useState(null);Tn.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=()=>{const t=e.getBoundingClientRect();Number.isFinite(t.width)&&Number.isFinite(t.height)&&d(e=>e&&.5>Math.abs(e.width-t.width)&&.5>Math.abs(e.height-t.height)?e:{width:t.width,height:t.height})};if(t(),"undefined"==typeof ResizeObserver)return;const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[a,n,r,l]);let h;h=u?`translate(${u.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>r-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*r>t?"4px":"calc(-100% - 4px)"})`;const f=function(e){if(!Tn.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if(!0===n["data-semiotic-tooltip-chrome"])return!0;if("true"===n["data-semiotic-tooltip-chrome"])return!0;const r=n.style;if(r&&"object"==typeof r){if(null!=r.background&&""!==r.background&&"transparent"!==r.background)return!0;if(null!=r.backgroundColor&&""!==r.backgroundColor&&"transparent"!==r.backgroundColor)return!0}return!1}(i),g=f?null:Wn;return l?(0,Hn.jsx)("div",{ref:c,className:f?a:(a+" semiotic-tooltip").trim(),style:{...g||{},position:"absolute",left:o.left+e,top:o.top+t,transform:h,pointerEvents:"none",zIndex:s,width:"max-content"},children:i}):null}var qn=l(require("react")),Yn=require("react"),Gn=require("react"),Xn=require("react/jsx-runtime");function Vn(e){let t=null;const n=()=>(t||(t=(0,Gn.createContext)(null)),t),r=Un(e);return[function({children:t,initialState:r}){const o=(0,Gn.useRef)(r),i=(0,Gn.useMemo)(()=>Un(e,o.current),[]),a=n();return(0,Xn.jsx)(a.Provider,{value:i,children:t})},(e,t)=>{const o=n(),i=(0,Gn.useContext)(o)??r,a=(0,Gn.useRef)(e);a.current=e;const s=(0,Gn.useRef)({hasValue:!1,value:void 0}),l=(0,Gn.useCallback)(()=>{const e=a.current(i.getState()),n=s.current;return n.hasValue&&t&&t(n.value,e)?n.value:(s.current={hasValue:!0,value:e},e)},[i,t]),c=(0,Gn.useCallback)(()=>a.current(i.getState()),[i]);return(0,Gn.useSyncExternalStore)(i.subscribe,l,c)}]}function Un(e,t){const n=new Set;let r={...e(function(e){const t=e(r);if(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}(t)){r={...r,...t};for(const e of n)e()}}),...t??{}};return{getState:()=>r,subscribe:function(e){return n.add(e),()=>{n.delete(e)}}}}function Kn(e){if(!e?.colors)return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function Qn(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:Zn}}),e.accessibility.highContrast){const e="dark"===t.mode;t={...t,colors:{...t.colors,text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"}}}return t}var Zn=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],Jn={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},er={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},tr={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:Zn,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function nr(e,t){if("light"===t)return Jn;if("dark"===t)return er;if("high-contrast"===t)return tr;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?er:Jn;return Qn({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return Qn({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[rr,or]=Vn(e=>({theme:Jn,setTheme(t){e(e=>({theme:nr(e.theme,t)}))}})),ir=require("react");var ar=require("react"),sr=new WeakMap,lr=0,cr=!1,ur=null,dr=null;function hr(e,t){if(!t)return t;const n=function(e){const t=e.trim();if(!t.startsWith("var(")||!t.endsWith(")"))return null;const n=t.slice(4,-1),r=n.indexOf(",");if(-1===r){const e=n.trim();return e.startsWith("--")?{name:e}:null}const o=n.slice(0,r).trim(),i=n.slice(r+1).trim();return o.startsWith("--")?{name:o,fallback:i||void 0}:null}(t);if(!n)return t;const r=()=>n.fallback?hr(e,n.fallback):t,o=e.canvas;if(!o)return r();!function(){if(cr)return;if("undefined"==typeof window||"undefined"==typeof document)return;cr=!0;const e=()=>{lr++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"],subtree:!0}),"function"==typeof window.matchMedia)try{ur=window.matchMedia("(prefers-color-scheme: dark)"),dr=e,"function"==typeof ur.addEventListener?ur.addEventListener("change",dr):"function"==typeof ur.addListener&&ur.addListener(dr)}catch{}}();let i=sr.get(o);i&&i.version===lr||(i={version:lr,map:new Map},sr.set(o,i));const a=i.map.get(t);if(void 0!==a)return a;const s=getComputedStyle(o).getPropertyValue(n.name).trim()||r()||t;return i.map.set(t,s),s}var fr="undefined"==typeof window?Yn.useEffect:Yn.useLayoutEffect,gr={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function yr(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function pr(e){const t=function(){const[e,t]=(0,ir.useState)(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return(0,ir.useEffect)(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),function(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}(e,e=>t(e.matches))},[]),e}(),n=(0,Yn.useRef)(t);n.current=t;const[r,o]=function(e,t,n){const r=(0,ar.useRef)(null),[o,i]=(0,ar.useState)(null);return(0,ar.useEffect)(()=>{if(!t&&!n)return;const e=r.current;if(!e)return;const o=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;i(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return o.observe(e),()=>o.disconnect()},[t,n]),[r,[t&&o?o.w:e[0],n&&o?o.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),i=!!e.title,a=!!e.legend&&"top"===e.legendPosition,s=(0,Yn.useMemo)(()=>function(e,t,n=!1){const r=n?t?58:34:t?36:0;return r>e.top?{...e,top:r}:e}({...e.marginDefault,...e.userMargin},i,a),[e.marginDefault,e.userMargin,i,a]),l=o[0]-s.left-s.right,c=o[1]-s.top-s.bottom,u=yr(e.foregroundGraphics,o,s),d=yr(e.backgroundGraphics,o,s),h=or(e=>e.theme),{transition:f,introEnabled:g}=function(e,t){if(!1===e)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:e?!0===e?{duration:300}:{duration:e.duration??300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(n||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),y="semiotic-table-"+qn.useId(),p=(0,Yn.useRef)(null);if(!p.current){const t=!e.suspendWhenHidden||"undefined"==typeof document||!document.hidden;p.current=new Ie({clock:e.clock,random:e.random,seed:e.seed,paused:e.paused,visible:t})}const m=p.current;m.configure({clock:e.clock,random:e.random,seed:e.seed});const b=(0,Yn.useRef)(null),v=(0,Yn.useRef)(e.frameScheduler??gr);v.current=e.frameScheduler??gr;const x=(0,Yn.useRef)(null),k=(0,Yn.useRef)(!1),w=(0,Yn.useRef)(()=>{}),S=(0,Yn.useCallback)(()=>{if(null!==b.current||k.current)return;const e=v.current;let t=!1,n=!1;const r=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&(k.current=!0),b.current=null,x.current=null;try{w.current()}finally{e&&(k.current=!1)}});n=!0,t||(b.current=r,x.current=e)},[]),M=(0,Yn.useCallback)(()=>{null!==b.current&&((x.current??v.current).cancelAnimationFrame(b.current),b.current=null,x.current=null)},[]);fr(()=>{m.setPaused(!0===e.paused)},[m,e.paused]),(0,Yn.useEffect)(()=>{if(!e.suspendWhenHidden||"undefined"==typeof document)return void m.setVisible(!0);const t=()=>m.setVisible(!document.hidden);return t(),document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[m,e.suspendWhenHidden]),(0,Yn.useEffect)(()=>()=>{M()},[M]);const A=(0,Yn.useRef)(()=>{}),C=(0,Yn.useRef)(()=>{}),L=(0,Yn.useRef)(null),j=(0,Yn.useRef)(null),T=(0,Yn.useRef)(null),E=(0,Yn.useCallback)(()=>{const e=L.current;L.current=null,e&&A.current(e)},[]),D=(0,Yn.useCallback)(e=>{if(L.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===j.current){const e=v.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,j.current=null,T.current=null,E()});t||(j.current=n,T.current=e)}},[E]),R=(0,Yn.useCallback)(()=>{L.current=null,null!==j.current&&((T.current??v.current).cancelAnimationFrame(j.current),j.current=null,T.current=null),C.current()},[]);(0,Yn.useEffect)(()=>()=>{L.current=null,null!==j.current&&((T.current??v.current).cancelAnimationFrame(j.current),j.current=null,T.current=null)},[]);const I=e.themeDirtyRef;return fr(()=>{I&&(lr++,I.current=!0,S())},[h,S,I]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:r,size:o,margin:s,adjustedWidth:l,adjustedHeight:c,resolvedForeground:u,resolvedBackground:d,currentTheme:h,transition:f,introEnabled:g,tableId:y,frameRuntime:m,rafRef:b,renderFnRef:w,scheduleRender:S,cancelRender:M,hoverHandlerRef:A,hoverLeaveRef:C,onPointerMove:D,onPointerLeave:R}}var mr=require("react"),br={fresh:1,aging:.7,stale:.45,expired:.25},vr={alpha:1,band:"fresh",isStale:!1};var xr=require("react/jsx-runtime");function kr({isStale:e,position:t}){return(0,xr.jsx)("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===t?{top:4,left:4}:"bottom-left"===t?{bottom:4,left:4}:"bottom-right"===t?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:e?"#dc3545":"#28a745",color:"white"},children:e?"STALE":"LIVE"})}var wr=l(require("react")),Sr=l(require("react"));function Mr(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}function Ar(e){return"object"==typeof e&&null!==e&&"gradient"in e}var Cr=16,Lr=6,jr=10,Tr=22,Er=100,Dr=10;function Rr(e){return Math.ceil(7*e.length)}function Ir(e,t){if(Mr(e)){const n=zr(t),r=e.legendGroups.flatMap(e=>[e.label?Rr(e.label):0,...e.items.map(e=>n.swatchSize+n.labelGap+Rr(e.label))]);return Math.max(Er,...r)}if(Ar(e)){const{gradient:t}=e,n=t.format||(e=>Math.round(100*e)/100+""),r=Math.max(Rr(n(t.domain[0])),Rr(n(t.domain[1]))),o=t.label?Rr(t.label):0;return Math.max(Er,19+r,o)}return Er}function Nr(e){return(Mr(e)||Ar(e))&&Number.isFinite(e.legendDistance)?Math.max(0,e.legendDistance):Dr}function Pr(e){return Math.max(0,e?.sideGutter??0)}var _r=22,Wr=46,$r=64;function Or(e,t){return null!=t?.axisGutter?Math.max(0,t.axisGutter):e?.hasAxis?e.hasAxisLabel?e.rotatedTicks?$r:Wr:_r:0}function Br(e,t,n){if(Ar(e))return e.gradient.label?34:26;if(!Mr(e))return 20;const r=zr(n),o=Math.max(1,n?.maxWidth??t);let i=r.rowHeight;for(const t of e.legendGroups){let e=0,n=0;for(const i of t.items){const t=r.swatchSize+r.labelGap+Rr(i.label),a=0===n?t:n+r.itemGap+t;n>0&&a>o?(e+=1,n=t):n=a}t.items.length>0&&(e+=1),i=Math.max(i,e*r.rowHeight,t.label?Rr(t.label):0)}return i+(e.legendGroups.length>1?16:0)}function zr(e){const t=Math.max(1,e?.swatchSize??Cr),n=Math.max(t,e?.rowHeight??Tr);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??Lr),itemGap:Math.max(0,e?.itemGap??jr),rowHeight:n,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}var Hr=require("react/jsx-runtime"),Fr={fill:(e,t)=>(0,Hr.jsx)("rect",{style:e,width:t,height:t}),line:(e,t)=>(0,Hr.jsx)("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function qr(e,t,n,r,o){let i;return i="function"==typeof n?n(e):(0,Fr[n])(r(e,t),o),i}function Yr({swatchSize:e}){return(0,Hr.jsx)("path",{d:`M${.25*e},${.55*e} L${.45*e},${.75*e} L${.8*e},${.3*e}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Gr(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var Xr=(e,t,n,r,o,i,a,s,l,c,u)=>{const{type:d="fill",styleFn:h,items:f}=e,g=[];let y=0;const p=!(!t&&!n),m="isolate"===c||void 0===c&&null!=o,{swatchSize:b,labelGap:v,rowHeight:x}=u;return f.forEach((e,c)=>{const u=qr(e,c,d,h,b),k=Gr(e,r,o),w=o&&o.size>0&&o.has(e.label);g.push((0,Hr.jsxs)("g",{transform:`translate(0,${y})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:p?s===i&&c===a?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&m?w||!1:void 0,"aria-current":p&&!m&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:p?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+f.length)%f.length;l(s,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:p?t=>{l(s,c),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:p?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[p&&(0,Hr.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:b+v+2+7*e.label.length,height:b+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,w&&(0,Hr.jsx)(Yr,{swatchSize:b}),(0,Hr.jsx)("text",{y:b/2,x:b+v,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+c)),y+=x}),g};function Vr({config:e,orientation:t="vertical",width:n=100}){const{colorFn:r,domain:o,label:i,format:a}=e,s=a||(e=>Math.round(100*e)/100+""),l="grad-legend-"+Sr.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),a=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push((0,Hr.jsx)("stop",{offset:100*t+"%",stopColor:r(o[0]+t*(o[1]-o[0]))},e))}return(0,Hr.jsxs)("g",{"aria-label":i||"Gradient legend",children:[(0,Hr.jsx)("defs",{children:(0,Hr.jsx)("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),i&&(0,Hr.jsx)("text",{x:a+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),(0,Hr.jsx)("rect",{x:a,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),(0,Hr.jsx)("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(o[0])}),(0,Hr.jsx)("text",{x:a+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(o[1])})]})}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push((0,Hr.jsx)("stop",{offset:100*t+"%",stopColor:r(o[1]-t*(o[1]-o[0]))},e))}return(0,Hr.jsxs)("g",{"aria-label":i||"Gradient legend",children:[i&&(0,Hr.jsx)("text",{x:0,y:-6,textAnchor:"start",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),(0,Hr.jsx)("defs",{children:(0,Hr.jsx)("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),(0,Hr.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),(0,Hr.jsx)("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(o[1])}),(0,Hr.jsx)("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:s(o[0])})]})}function Ur(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,legendInteraction:a,title:s="Legend",width:l=100,height:c=20,orientation:u="vertical",legendLayout:d}=e,h=zr(d),[f,g]=Sr.useState(0),[y,p]=Sr.useState(0),m=Sr.useCallback((e,t)=>{g(e),p(t)},[]),b="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:l,legendInteraction:c,metrics:u})=>{const d=[],h=function(e,t){let n=24;return e.map(({hasLabel:e,itemCount:r})=>{n+=5;const o=n;let i;n+=8,e&&(n+=16,i=n,n+=8);const a=n;return n+=r*t+8,{lineY:o,labelY:i,itemsY:a,endY:n}})}(e.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),u.rowHeight);return e.forEach((e,f)=>{const g=h[f];d.push((0,Hr.jsx)("line",{stroke:"gray",x1:0,y1:g.lineY,x2:t,y2:g.lineY},"legend-top-line legend-symbol-"+f)),e.label&&null!=g.labelY&&d.push((0,Hr.jsx)("text",{y:g.labelY,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),d.push((0,Hr.jsx)("g",{className:"legend-item",transform:`translate(0,${g.itemsY})`,children:Xr(e,n,r,o,i,a,s,f,l,c,u)},"legend-group-"+f))}),d})({legendGroups:t||[],width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:a,metrics:h}):(({legendGroups:e,height:t,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:s,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u,metrics:d})=>{let h=0;const f=[];e.forEach((e,t)=>{let g=0;e.label&&(g+=16);const y=((e,t,n,r,o,i,a,s,l,c,u,d)=>{const{type:h="fill",styleFn:f,items:g}=e,y=[],{swatchSize:p,labelGap:m,itemGap:b,rowHeight:v,align:x}=u,k=!(!t&&!n),w="isolate"===c||void 0===c&&null!=o,S=g.map(e=>p+m+7*e.label.length),M=[];let A=0,C=0;S.forEach((e,t)=>{const n=0===C?e:C+b+e;d&&d>0&&C>0&&n>d?(M.push({start:A,end:t,width:C}),A=t,C=e):C=n}),g.length>0&&M.push({start:A,end:g.length,width:C}),M.forEach((e,c)=>{let u="center"===x?Math.max(0,((d??e.width)-e.width)/2):"end"===x?Math.max(0,(d??e.width)-e.width):0;for(let d=e.start;e.end>d;d++){const e=g[d],x=qr(e,d,h,f,p),M=Gr(e,r,o),A=o&&o.size>0&&o.has(e.label);y.push((0,Hr.jsxs)("g",{transform:`translate(${u},${c*v})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:k?s===i&&d===a?0:-1:void 0,role:k?"option":void 0,"aria-selected":k&&w?A||!1:void 0,"aria-current":k&&!w&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:k?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(d+("ArrowRight"===n.key?1:-1)+g.length)%g.length;l(s,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:k?t=>{l(s,d),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:k?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:k?"pointer":"default",opacity:M,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[k&&(0,Hr.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:p+m+2+7*e.label.length,height:p+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),x,A&&(0,Hr.jsx)(Yr,{swatchSize:p}),(0,Hr.jsx)("text",{y:p/2,x:p+m,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+d)),u+=S[d]+b}});const L=Math.max(0,...M.map(e=>e.width)),j=M.length;return{items:y,offset:L,totalRows:j,totalHeight:j*v}})(e,r,o,i,a,s,l,t,c,u,d,d.maxWidth??n);g+=y.offset+5,f.push({label:e.label,...y,offset:g,totalRows:y.totalRows,totalHeight:y.totalHeight}),h+=g+12});const g=d.maxWidth??n;let y=h>g?0:"center"===d.align?Math.max(0,(g-h)/2):"end"===d.align?Math.max(0,g-h):0;const p=[];return f.forEach((n,r)=>{const o=e[r];o.label&&(p.push((0,Hr.jsx)("text",{transform:`translate(${y},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:o.label},"legend-text-"+r)),y+=16),p.push((0,Hr.jsx)("g",{className:"legend-item",transform:`translate(${y},0)`,children:n.items},"legend-group-"+r)),y+=n.offset+5,e[r+1]&&p.push((0,Hr.jsx)("line",{stroke:"gray",x1:y,y1:-8,x2:y,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+r)),y+=12}),(0,Hr.jsx)("g",{children:p})})({legendGroups:t||[],title:s,height:c,width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:a,metrics:h}),v=!(!n&&!r);return(0,Hr.jsxs)("g",{role:v?"listbox":void 0,"aria-multiselectable":!(!v||"isolate"!==a&&(void 0!==a||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==s&&""!==s&&"vertical"===u&&(0,Hr.jsx)("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:s}),b]})}var Kr=require("react/jsx-runtime");function Qr(e){const{legend:t,totalWidth:n,totalHeight:r,margin:o,legendPosition:i="right",legendLayout:a,legendHoverBehavior:s,legendClickBehavior:l,legendHighlightedCategory:c,legendIsolatedCategories:u,legendInteraction:d}=e;if(!t)return null;const h="top"===i||"bottom"===i,f=Math.max(0,n-o.left-o.right),g=Math.max(1,h?a?.maxWidth??f:Ir(t,a)),y=Nr(t),p=Pr(a),m=Or(e.axisChrome,a),b=Or(void 0,a),v=Br(t,f,a);let x,k;if("left"===i)x=o.left-p-g-y,k=o.top;else if("top"===i)x=o.left,k=o.top-b-y-v;else if("bottom"===i){x=o.left;const e=r-o.bottom;k=Math.max(e+y,Math.min(e+m+y,r-v))}else x=n-o.right+p+y,k=o.top;return(0,Kr.jsx)("g",{transform:`translate(${x}, ${k})`,children:Ar(t)?(0,Kr.jsx)(Vr,{config:t.gradient,orientation:h?"horizontal":"vertical",width:g}):Mr(t)?(0,Kr.jsx)(Ur,{legendGroups:t.legendGroups,title:"",width:g,orientation:h?"horizontal":"vertical",legendLayout:a,customHoverBehavior:s,customClickBehavior:l,highlightedCategory:c,isolatedCategories:u,legendInteraction:d}):t})}var Zr=require("react/jsx-runtime"),Jr={secondary:0,primary:3},eo=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}";function to(e){return!0===e?._annotationDeferred}function no(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function ro(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function oo(e){return Math.max(.72,.95-.06*e)}var io=l(require("react")),ao=require("react/jsx-runtime");function so(e,t=120,n=8){if(!e)return[];const r=Math.max(1,Math.floor(t/n)),o=e.split(/\s+/),i=[];let a="";for(const e of o)a&&a.length+1+e.length>r?(i.push(a),a=e):a=a?`${a} ${e}`:e;return a&&i.push(a),i}function lo(e,t,n,r){return"curly"===e?r?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:r?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function co(e,t,n,r){if(!e)return(0,ao.jsx)("g",{className:"annotation-note"});const{label:o,title:i,orientation:a,align:s,wrap:l=120,noWrap:c}=e;if(!o&&!i)return(0,ao.jsx)("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=s;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const f=16,g=i?c?[i]:so(i,l):[],y=o?c?[o]:so(o,l):[],p="leftRight"===u?"end"===h?-4:4:0;let m=0;const b=[],v=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?b.push((0,ao.jsx)("foreignObject",{className:"annotation-note-html",x:"end"===h?p-l:"middle"===h?p-l/2:p,y:-16,width:l,height:Math.max(f,(g.length+y.length)*f+(i&&o?2:0))+f,style:{overflow:"visible"},children:(0,ao.jsxs)("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:v,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===h?"right":"middle"===h?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[i&&(0,ao.jsx)("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),o&&(0,ao.jsx)("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html")):(g.length>0&&(b.push((0,ao.jsx)("text",{className:"annotation-note-title",fill:v,textAnchor:h,fontWeight:"bold",children:g.map((e,t)=>(0,ao.jsx)("tspan",{x:p,dy:0===t?0:f,children:e},t))},"annotation-note-title")),m=g.length*f),y.length>0&&b.push((0,ao.jsx)("text",{className:"annotation-note-label",fill:v,textAnchor:h,y:m,children:y.map((e,t)=>(0,ao.jsx)("tspan",{x:p,dy:0===t?0:f,children:e},t))},"annotation-note-label")));let x=null;if((i||o)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(l,120);let t=0,n=e;"end"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),x=(0,ao.jsx)("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(g.length+y.length)*f+(y.length>0?f:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),x=(0,ao.jsx)("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const k=Math.max(0,g.length+y.length-1)*f;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===d?-(k+f+(y.length>0&&g.length>0?2:0))/2+8:"bottom"===d||0>n?-(k+2):18),(0,ao.jsxs)("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[(0,ao.jsx)("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0,children:b}),x]})}function uo(e,t,n,r,o){const i=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&i.push((0,ao.jsx)("circle",{r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,r=t?.height||0;(e>0||r>0)&&i.push((0,ao.jsx)("rect",{width:e,height:r,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":t?.custom&&i.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=r||0,a=o||0;if(void 0!==t?.x){const r=(t.x||0)-e;i.push((0,ao.jsx)("line",{x1:r,y1:(t.y1||0)-a,x2:r,y2:(t.y2||0)-a,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const r=(t.y||0)-a;i.push((0,ao.jsx)("line",{x1:(t.x1||0)-e,y1:r,x2:(t.x2||0)-e,y2:r,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?i.push((0,ao.jsx)("line",{x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===t?.y1&&void 0===t?.y2||i.push((0,ao.jsx)("line",{x1:0,y1:(t.y1||0)-a,x2:0,y2:(t.y2||0)-a,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=t?.type||"curly",r=t?.width??t?.height;void 0!==r&&i.push((0,ao.jsx)("path",{d:lo(e,r,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return(0,ao.jsx)("g",{className:"annotation-subject",children:i})}function ho(e,t,n,r,o,i){const a=[];let s=0,l=0;if("callout-circle"!==o&&"label"!==o||!i?.radius){if("callout-rect"===o&&i){const n=i.width||0,r=i.height||0;if(n>0||r>0){const o=n/2,i=r/2,a=e-o,c=t-i;if(0!==a||0!==c){const e=Math.abs(a),t=Math.abs(c),u=n/2,d=r/2,h=e*d>t*u?u/e:d/t;s=o+a*h,l=i+c*h}}}else if("bracket"===o&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(s=e/2,l=n):void 0!==t&&(s=n,l=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const r=Math.atan2(t,e);s=Math.cos(r)*n,l=Math.sin(r)*n}}const c=Math.sqrt((e-s)**2+(t-l)**2);if(c>.5){const o=r||"var(--semiotic-text-secondary, currentColor)",i="curve"===n?.type;let u=Math.atan2(t-l,e-s);if(i){const r=(s+e)/2,i=(l+t)/2,d=-(t-l)/c,h=(e-s)/c,f=(n?.curve??.25)*c,g=r+d*f,y=i+h*f;a.push((0,ao.jsx)("path",{className:"connector-curve",d:`M${s},${l}Q${g},${y} ${e},${t}`,fill:"none",stroke:o},"connector-line")),u=Math.atan2(y-l,g-s)}else a.push((0,ao.jsx)("line",{x1:s,y1:l,x2:e,y2:t,stroke:o},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;a.push((0,ao.jsx)("path",{d:`M${s},${l}L${s+e*Math.cos(u+t)},${l+e*Math.sin(u+t)}L${s+e*Math.cos(u-t)},${l+e*Math.sin(u-t)}Z`,fill:o,stroke:"none"},"connector-arrow"))}}return(0,ao.jsx)("g",{className:"annotation-connector",children:a})}function fo(e){const{x:t=0,y:n=0,dx:r,dy:o,nx:i,ny:a,note:s,connector:l,subject:c,type:u,color:d,className:h,disable:f,opacity:g,strokeDasharray:y,events:p={},"data-testid":m}=e,b=Array.isArray(t)?t[0]??0:t,v=Array.isArray(n)?n[0]??0:n,x=new Set(Array.isArray(f)?f:[]);let k=r||0,w=o||0;null!=i&&(k=i-b),null!=a&&(w=a-v);const S="string"==typeof u?u:"label";if("bracket"===S&&c&&0===k&&0===w)if(void 0!==c.width){k=c.width/2;const e=c.depth||30;w=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;k=e+(0>e?-5:5),w=c.height/2}return(0,ao.jsxs)("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${b},${v})`,"data-testid":m,...null!=g&&{opacity:g},...y&&{strokeDasharray:y},...p,children:[!x.has("connector")&&ho(k,w,l,d,S,c),!x.has("subject")&&uo(S,c,d,b,v),!x.has("note")&&co(s,k,w,d)]})}function go(e){const{noteData:t}=e,{screenCoordinates:n}=t,r="string"==typeof t.type?t.type:"label",o=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),o=t.ny||n[0][1]+(t.dy??0),i=n.map((n,i)=>{const a=Object.assign({},t,{note:0===i?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:o});return(0,ao.jsx)(fo,{"data-testid":"semiotic-annotation",...a,type:r},"multi-annotation-"+i)});return(0,ao.jsx)("g",{children:i})}const i=t.note||{title:"none",label:t.label},a=`${i.label}-${i.title}-${t.i}`;return(0,ao.jsx)(fo,{"data-testid":"semiotic-annotation",events:o,...t,type:r},a)}var yo=require("d3-hierarchy"),po=require("d3-shape");function mo(e){return Math.round(100*e)/100}function bo(e,t=2){const n=[],r=[],o=t+1;for(let t=0;o>t;t++){let i=0;for(const[n,r]of e)null!==r&&(i+=n**t*r);n.push(i);const a=[];for(let n=0;o>n;n++){let r=0;for(const[o,i]of e)null!==i&&(r+=o**(t+n));a.push(r)}r.push(a)}r.push(n);const i=function(e,t){const n=e,r=e.length-1,o=[t];for(let e=0;r>e;e++){let t=e;for(let o=e+1;r>o;o++)Math.abs(n[e][o])>Math.abs(n[e][t])&&(t=o);for(let o=e;r+1>o;o++){const r=n[o][e];n[o][e]=n[o][t],n[o][t]=r}for(let t=e+1;r>t;t++)for(let o=r;o>=e;o--)n[o][t]-=n[o][e]*n[e][t]/n[e][e]}for(let e=r-1;e>=0;e--){let t=0;for(let i=e+1;r>i;i++)t+=n[i][e]*o[i];o[e]=(n[r][e]-t)/n[e][e]}return o}(r,o).map(mo);return{points:e.map(([e])=>[mo(e),mo(i.reduce((t,n,r)=>t+n*e**r,0))]),equation:[...i].reverse()}}function vo(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function xo(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function ko(e){return null==e?null:e+""}function wo(e,t,n){return t.stickyPositionCache?.set(e,n),n}function So(e,t,n){const r=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===r){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const o=n.pointNodes[r];if(o.pointId===e.pointId)return wo(t,n,{x:o.x,y:o.y})}const r=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],r=e.scales?.x??e.scales?.time,o=e.scales?.y??e.scales?.value;if(!r||!o)return null;const i=n[e.xAccessor||"x"],a=n[e.yAccessor||"y"];return null==i||null==a?null:{x:r(i),y:o(a)}}(n);return r?wo(t,n,r):null}if("semantic"===r){const r=function(e,t,n){const r=function(e){return ko(e.provenance?.stableId??e.stableId)}(e);if(!r)return null;const o=n.pointNodes?.find(e=>ko(e.pointId)===r);if(o)return wo(t,n,{x:o.x,y:o.y});const i=n.data?.find(e=>function(e){return ko(e.stableId??e.id??e.provenance?.stableId)}(e)===r);if(!i)return null;const a=vo(i,n),s=xo(i,n);return null==a||null==s?null:wo(t,n,{x:a,y:s})}(e,t,n);if(r)return r}let o=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(o=t.x,i=t.y)}if(null!=o&&null!=i||(o=vo(e,n),i=xo(e,n)),null!=o&&null!=i)return wo(t,n,{x:o,y:i});if("sticky"===r){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function Mo(e,t,n,r=50){return!(-r>e||e>(n.width||0)+r||-r>t||t>(n.height||0)+r)}var Ao=l(require("react")),[Co,Lo]=Vn(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function jo(e,t={}){const n=function(e){const t=e.provenance,n=e.id??e.stableId??t?.stableId;return null==n||""===n?void 0:n+""}(e);return{"data-semiotic-annotation-widget":"",...n?{"data-semiotic-annotation-id":n}:{},onClickCapture(r){const o=function(e){const t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}(r);t.onAnnotationActivate?.({annotation:e,annotationId:n,chartId:t.chartId,inputType:o}),n&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:n,inputType:o,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}var To=require("react/jsx-runtime"),Eo="var(--semiotic-bg, #ffffff)";function Do(e){const{x:t,y:n,text:r,fill:o,fontSize:i=12,fontWeight:a,fontFamily:s,textAnchor:l="start",dominantBaseline:c,background:u,className:d}=e,h=function(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{type:e.type??"halo",...e}}(u),f=e=>(0,To.jsx)("text",{x:t,y:n,textAnchor:l,dominantBaseline:c,fill:o,fontSize:i,fontWeight:a,fontFamily:s,className:d,...e?{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}:{},children:r});if(!h)return f();if("halo"===h.type)return f({stroke:h.fill??Eo,strokeWidth:h.haloWidth??3});const g=h.padding??{x:6,y:3},y="number"==typeof g?g:g.x,p="number"==typeof g?g:g.y,m=function(e,t){return(e+"").length*t*.6}(r,i),b=i+2*p;let v,x;return v="middle"===l?t-m/2-y:"end"===l?t-m-y:t-y,x="middle"===c||"central"===c?n-b/2:"hanging"===c||"text-before-edge"===c?n-p:n-.8*i-p,(0,To.jsxs)("g",{className:d,children:[(0,To.jsx)("rect",{x:v,y:x,width:m+2*y,height:b,rx:h.radius??3,ry:h.radius??3,fill:h.fill??Eo,fillOpacity:h.opacity??.85,stroke:h.stroke,strokeWidth:h.strokeWidth}),f()]})}function Ro(e){return{type:"hatch",background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle}}var Io=null;var No=require("react/jsx-runtime");function Po(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function _o(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}function Wo(e,t){let n=2166136261;const r=_o(t);for(let e=0;r.length>e;e++)n^=r.charCodeAt(e),n=Math.imul(n,16777619);return`${e}-hatch-${(n>>>0).toString(36)}`}var $o=new Map;function Oo(e,t){const{background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:a=45,lineOpacity:s=1}=e,l=Math.max(8,Math.ceil(2*i));return(0,No.jsxs)("pattern",{id:t,width:l,height:l,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0,children:[n&&"transparent"!==n&&(0,No.jsx)("rect",{width:l,height:l,fill:n}),(0,No.jsx)("line",{x1:0,y1:0,x2:0,y2:l,stroke:r,strokeWidth:o,strokeOpacity:s}),(0,No.jsx)("line",{x1:i,y1:0,x2:i,y2:l,stroke:r,strokeWidth:o,strokeOpacity:s})]},t)}function Bo(e,t,n="#4e79a7"){if(Po(e)){const n=Wo(t,e);return{fill:`url(#${n})`,def:Oo(e,n)}}return e&&"string"==typeof e?{fill:e}:{fill:n}}var zo=require("react/jsx-runtime"),Ho={linear:po.curveLinear,monotoneX:po.curveMonotoneX,monotoneY:po.curveMonotoneY,step:po.curveStep,stepAfter:po.curveStepAfter,stepBefore:po.curveStepBefore,basis:po.curveBasis,cardinal:po.curveCardinal,catmullRom:po.curveCatmullRom};var Fo=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function qo(e){return!!e&&"object"==typeof e&&Fo.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}function Yo(e){return"primary"===e?.emphasis||!0===e?.defensive}function Go(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function Xo(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const r=e?.provenance?.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(t+=15*Math.max(0,Math.min(1,r))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}new Set(["label","callout","callout-circle","callout-rect"]);var Vo=32,Uo=6,Ko=4,Qo=8,Zo=72;var Jo={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function ei(e){if(!ti(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function ti(e){return qo(e)}function ni(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),r=e.split(/\s+/).filter(Boolean),o=[];let i="";for(const e of r)i&&i.length+e.length+1>n?(o.push(i),i=e):i=i?`${i} ${e}`:e;return i&&o.push(i),o}function ri(e,t,n,r,o){const i=e+n,a=t+r;return Math.abs(n)>Math.abs(r)?{x:0>n?i-o.width-4:i+4,y:0>r?a-o.height:a,width:o.width,height:o.height}:{x:0>n?i-o.width:i,y:0>r?a-o.height-4:a+4,width:o.width,height:o.height}}function oi(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function ii(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function ai(e,t,n,r,o,i,a,s){const l=oi(e,a);let c=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,r){const o=Math.max(0,r-e.x),i=Math.max(0,r-e.y);return(o+Math.max(0,e.x+e.width-(t-r)))*e.height+(i+Math.max(0,e.y+e.height-(n-r)))*e.width}(l,o,i,s);for(const e of n)c+=12*ii(l,e);for(const e of r)c+=4*ii(l,e);return c}function si(e){const{annotations:t,context:n,defaultOffset:r=Vo,notePadding:o=Uo,markPadding:i=Ko,edgePadding:a=Qo,preserveManualOffsets:s=!0,routeLongConnectors:l=!0,connectorThreshold:c=Zo,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:g,cohesion:y,audience:p}=e,m=n.width||0,b=n.height||0,v="object"==typeof g?g:{},x=v.breakpoint??480,k=!!g&&x>=m,w=k&&!1!==v.preferShortText?t.map(ei):t,S=k&&!u?{maxAnnotations:v.maxAnnotations??("callout-list"===v.strategy?1:2),minVisible:v.minVisible??1}:u,M=d||k&&(!1!==v.progressiveDisclosure||"callout-list"===v.strategy),A=k&&!f?v.responsive??{minWidth:x}:f,C=k&&!y?v.cohesion:y;if(0===w.length||0>=m||0>=b)return w.slice();const L=[],j=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(n,i);let T=!1;const E=w.map((e,t)=>{if(!ti(e))return e;const i=function(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const r=e.pointId??e.nodeId;if(null!=r&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===r);if(e)return{x:e.x,y:e.y}}const o=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(o)&&o.length>=2&&i){const e=o[0],t=o[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?So(e,t,n):{x:e.x,y:e.y}}(e,t,n);if(!i)return e;const u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,n=[...ni("string"==typeof e.title?e.title:void 0,t),...ni("string"==typeof e.label?e.label:void 0,t)],r=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*r)+10),height:Math.max(18,16*n.length+6)}}(e);if(s&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}(e);return L.push(oi(ri(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),o)),e}var d;let h=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(r)){const t=ai(ri(i.x,i.y,e.dx,e.dy,u),e,L,j,m,b,o,a);f>t&&(h=e,f=t)}if(!h)return e;const g=oi(ri(i.x,i.y,h.dx,h.dy,u),o);L.push(g);const y=Math.hypot(h.dx,h.dy),p=l&&y>=c&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return T=!0,{...e,dx:h.dx,dy:h.dy,...p?{connector:p}:{}}}),D=T?E:w.slice();let R=D;if(h){let e=!1;const t=D.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||8>Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});R=e?t:D}{let e=!1;const t=R.map(t=>{if(!0!==t?.defensive)return t;const n=function(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?Jo[t.source]??t.source:null,r="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!r)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const o=[n,r].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${o})`)?e:{...e,label:i?`${i} (${o})`:`(${o})`}}(t);return n!==t&&(e=!0),n});R=e?t:R}const I=new Set;if(S){const e="object"==typeof S?S:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return 3;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?3:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(p),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??Go(m,b,e))*t))},{deferred:r}=function(e){const{annotations:t,width:n,height:r}=e,o=Math.max(0,e.minVisible??1),i=Go(n,r,e),a=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,qo(n))};var n}),s=a.filter(e=>e.note);if(0===s.length||i>=s.length)return{visible:t.slice(),deferred:[],budget:i};const l=s.filter(e=>Yo(e.annotation)),c=s.filter(e=>!Yo(e.annotation)).sort((e,t)=>Xo(t.annotation)-Xo(e.annotation)||e.index-t.index),u=Math.min(c.length,Math.max(Math.max(0,i-l.length),Math.max(0,o-l.length))),d=new Set([...l.map(e=>e.index),...c.slice(0,u).map(e=>e.index)]),h=[],f=[];for(const{annotation:e,index:t,note:n}of a)!n||d.has(t)?h.push(e):f.push(e);return{visible:h,deferred:f,budget:i}}({annotations:R,width:m,height:b,...n});for(const e of r)I.add(e)}if(A&&("object"==typeof A&&"number"==typeof A.minWidth?A.minWidth:480)>=m)for(const e of R)ti(e)&&"secondary"===e.emphasis&&I.add(e);if(I.size>0)for(const e of R)!0===e?.defensive&&I.delete(e);let N;return N=0===I.size?R:M?R.map(e=>I.has(e)?{...e,_annotationDeferred:!0}:e):R.filter(e=>!I.has(e)),C?function(e,t){let n=!1;const r=e.map(e=>ti(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?r:e}(N,C):N}var li=require("d3-shape"),ci={circle:li.symbolCircle,square:li.symbolSquare,triangle:li.symbolTriangle,diamond:li.symbolDiamond,star:li.symbolStar,cross:li.symbolCross,wye:li.symbolWye};function ui(e,t,n){if(n)return n;const r=e??"circle";return"chevron"===r?function(e){const t=1.5*di(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t):(0,li.symbol)(ci[r]??li.symbolCircle,Math.max(1,t))()??""}function di(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var hi=require("react/jsx-runtime");function fi(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,labels:a,title:s,legend:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:f="right",legendLayout:g,foregroundGraphics:y,sceneNodes:p,annotations:m,onAnnotationActivate:b,onObservation:v,chartId:x,chartType:k,autoPlaceAnnotations:w,svgAnnotationRules:S}=e,M=function(e){const t=Lo(e=>e.pushObservation),n=Ao.useCallback(n=>{e.onObservation?.(n),t?.(n)},[e,t]);return Ao.useMemo(()=>({...e,onObservation:n}),[n,e])}({onAnnotationActivate:b,onObservation:v,chartId:x,chartType:k}),A=wr.useMemo(()=>{const e=(p||[]).flatMap(e=>{const t=function(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){const t=e.cx??e.x,n=e.cy??e.y;if("number"!=typeof t||"number"!=typeof n)return null;const r=kn(e.glyph,e.size);return{x:t+r.centerDx,y:n+r.centerDy,r:Math.max(1,r.radius)}}const t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),n=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof n?null:{x:t,y:n,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,di(e.size)):Math.max(1,e.w??0,e.h??0)/2}}(e),n=function(e){const t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}(e);return t?[{pointId:n,...t}]:[]});return{scales:null,width:t,height:n,frameType:"network",pointNodes:e,sceneNodes:p}},[n,p,t]),C=wr.useMemo(()=>{if(!m)return m;const e=function(e,t={}){const n=!0===t.showRetractedAnnotations,r=!0===t.showSupersededAnnotations,o=new Set;for(const t of e){const e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&o.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!n)return!1;const t=e?.provenance?.stableId;return!(t&&o.has(t)&&!r)})}(m);return w?si({annotations:e,context:A,..."object"==typeof w?w:{}}):e},[m,w,A]),L=wr.useMemo(()=>function(e,t={}){return function(e,n,r){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const t=So(e,n,r);if(!t)return null;const{x:o,y:i}=t;if(!Mo(o,i,r))return null;const a="callout"===e.type?"callout-circle":e.type,s="callout-circle"===a?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===a?{width:e.width,height:e.height}:void 0;return(0,zo.jsx)(go,{noteData:{x:o,y:i,dx:e.dx??30,dy:e.dy??-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:a,...s?{subject:s}:{},connector:e.connector||{end:"arrow"},color:e.color,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-"+n)}case"x-threshold":{const t=vo(null!=e.value?{...e,x:e.value}:e,r);if(null==t)return null;const o=e.color||"#f97316",i=e.labelPosition||"top";let a;a="bottom"===i?(r.height||0)-4:"center"===i?(r.height||0)/2:16;const s=t>.6*(r.width||0),l=s?t-4:t+4,c=s?"end":"start";return(0,zo.jsxs)("g",{opacity:e.opacity,children:[(0,zo.jsx)("line",{x1:t,y1:0,x2:t,y2:r.height||0,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,zo.jsx)(Do,{x:l,y:a,text:e.label,textAnchor:c,fill:o,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"y-threshold":{const t=xo(null!=e.value?{...e,y:e.value}:e,r);if(null==t)return null;const o=e.color||"#f97316",i=e.labelPosition||"right";let s,l;"left"===i?(s=4,l="start"):"center"===i?(s=(r.width||0)/2,l="middle"):(s=(r.width||0)-4,l="end");const c=20>(a=t)?Math.min((r.height||0)-4,a+16):a-4;return(0,zo.jsxs)("g",{opacity:e.opacity,children:[(0,zo.jsx)("line",{x1:0,y1:t,x2:r.width||0,y2:t,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,zo.jsx)(Do,{x:s,y:c,text:e.label,textAnchor:l,fill:o,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"enclose":{const t=(e.coordinates||[]).map(e=>({x:vo({...e,type:"point"},r),y:xo({...e,type:"point"},r),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const o=(0,yo.packEnclose)(t),i=e.padding||10;return(0,zo.jsxs)("g",{children:[(0,zo.jsx)("circle",{cx:o.x,cy:o.y,r:o.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,zo.jsx)(Do,{x:o.x,y:o.y-o.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"rect-enclose":{const t=(e.coordinates||[]).map(e=>({x:vo({...e,type:"point"},r),y:xo({...e,type:"point"},r)})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const o=e.padding||10,i=t.map(e=>e.x),a=t.map(e=>e.y),[s,l]=Te(i),[c,u]=Te(a),d=s-o,h=l+o,f=c-o;return(0,zo.jsxs)("g",{children:[(0,zo.jsx)("rect",{x:d,y:f,width:h-d,height:u+o-f,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,zo.jsx)(Do,{x:(d+h)/2,y:f-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"highlight":{const t=r.data||[],o="function"==typeof e.filter?t.filter(e.filter):e.field&&null!=e.value?t.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return(0,zo.jsx)("g",{children:o.map((t,n)=>{const o=vo(t,r),a=xo(t,r);if(null==o||null==a)return null;const s="function"==typeof e.r?e.r(t):e.r||6,l="function"==typeof e.style?e.style(t):e.style||i;return(0,zo.jsx)("circle",{cx:o,cy:a,r:s,...l},"hl-"+n)})},"ann-"+n)}case"bracket":{const t=vo(e,r),o=xo(e,r);return(0,zo.jsx)(go,{noteData:{x:t??0,y:o??0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+n)}case"trend":{const t=r.data||[];if(2>t.length)return null;const o=r.xAccessor||"x",i=r.yAccessor||"y",a="ordinal"===r.frameType,s="horizontal"===r.projection,l=a?o:null,c=a?i:null;let u;const d=[],h=new Map;if(a&&l&&c){for(const e of t){const t=e[l];if(null==t)continue;const n=t+"";h.has(n)||(h.set(n,d.length),d.push(n))}u=t.map(e=>{const t=e[l],n=e[c];if(null==t||null==n)return null;const r=h.get(t+"");return null!=r?[r,+n]:null}).filter(e=>null!==e)}else u=t.map(e=>[e[o],e[i]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const f=r.scales?.x??r.scales?.time,g=r.scales?.y??r.scales?.value;if(!f||!g)return null;const y=e=>t=>{const n=Math.max(0,Math.floor(t)),r=Math.min(d.length-1,n+1),o=t-n,i=e(d[n]);return i+(e(d[r])-i)*o},p=f,m=g;let b;if(a)if(s){const e=y(m);b=(t,n)=>[p(n),e(t)]}else{const e=y(p);b=(t,n)=>[e(t),m(n)]}else b=(e,t)=>[p(e),m(t)];const v=e.method||"linear";let x;if("loess"===v)x=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const r=e.slice().sort((e,t)=>e[0]-t[0]),o=r.map(e=>e[0]),i=r.map(e=>e[1]),a=Math.max(2,Math.ceil(t*n)),s=[];for(let e=0;n>e;e++){const t=o[e],r=o.map(e=>Math.abs(e-t)),l=r.slice().sort((e,t)=>e-t)[Math.min(a-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:r[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,f=0,g=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*o[e],h+=t*i[e],f+=t*o[e]*o[e],g+=t*o[e]*i[e])}if(0===u){s.push([t,i[e]]);continue}const y=u*f-d*d;if(1e-12>Math.abs(y))s.push([t,h/u]);else{const e=(u*g-d*h)/y;s.push([t,(h-e*d)/u+e*t])}}return s}(u,e.bandwidth??.3);else{const t="polynomial"===v?bo(u,e.order||2):function(e){const t=[0,0,0,0];let n=0;for(const[r,o]of e)null!==o&&(n++,t[0]+=r,t[1]+=o,t[2]+=r*r,t[3]+=r*o);const r=n*t[2]-t[0]*t[0],o=0===r?0:mo((n*t[3]-t[0]*t[1])/r),i=mo(t[1]/n-o*t[0]/n);return{points:e.map(([e])=>[mo(e),mo(o*e+i)]),equation:[o,i]}}(u);x=t.points}const k=x.map(([e,t])=>{const[n,r]=b(e,t);return`${n},${r}`}).join(" "),w=e.color||"#6366f1",S=x[x.length-1],[M,A]=b(S[0],S[1]);return(0,zo.jsxs)("g",{children:[(0,zo.jsx)("polyline",{points:k,fill:"none",stroke:w,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,zo.jsx)("text",{x:M+4,y:A-4,fill:w,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const t=r.scales?.y??r.scales?.value,a=t?.domain?.(),s=e.y0??a?.[0],l=e.y1??a?.[1],c=null!=s&&t?t(s):0,u=null!=l&&t?t(l):r.height||0,d=Bo(e.fill,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,zo.jsxs)("g",{opacity:e.opacity,children:[d.def&&(0,zo.jsx)("defs",{children:d.def}),(0,zo.jsx)("rect",{x:0,y:Math.min(c,u),width:r.width||0,height:Math.abs(u-c),fill:d.fill,fillOpacity:e.fillOpacity||.1}),e.label&&(0,zo.jsx)(Do,{x:(r.width||0)-4,y:(o=c,i=u,Math.max(Math.min(o,i),0)+16),textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"x-band":{const t=r.scales?.x??r.scales?.time,o=t?.domain?.(),i=e.x0??o?.[0],a=e.x1??o?.[1],s=null!=i&&t?t(i):null,l=null!=a&&t?t(a):null;if(null==s||null==l)return null;const c=Bo(e.fill||e.color,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,zo.jsxs)("g",{opacity:e.opacity,children:[c.def&&(0,zo.jsx)("defs",{children:c.def}),(0,zo.jsx)("rect",{x:Math.min(s,l),y:0,width:Math.abs(l-s),height:r.height||0,fill:c.fill,fillOpacity:e.fillOpacity??.1}),e.label&&(0,zo.jsx)(Do,{x:Math.min(s,l)+4,y:16,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"envelope":{const t=r.data||[];if(2>t.length)return null;const o=r.xAccessor||"x",i=r.scales?.x??r.scales?.time,a=r.scales?.y??r.scales?.value;if(!i||!a)return null;const s=e.upperAccessor||"upperBounds",l=e.lowerAccessor||"lowerBounds",c=e.filter,u=t.filter(e=>null!=e[s]&&null!=e[l]&&!(c&&!c(e))).sort((e,t)=>e[o]-t[o]);if(2>u.length)return null;const d=Ho[r.curve||"linear"]||po.curveLinear,h=(0,po.area)().x(e=>i(e[o])).y0(e=>a(e[l])).y1(e=>a(e[s])).curve(d)(u);if(!h)return null;const f=e.fill||"#6366f1";return(0,zo.jsxs)("g",{children:[(0,zo.jsx)("path",{d:h,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&(0,zo.jsx)("text",{x:i(u[u.length-1][o])+4,y:a(u[u.length-1][s])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const t=r.data||[];if(2>t.length)return null;const o=r.yAccessor||"y",i=r.scales?.x??r.scales?.time,a=r.scales?.y??r.scales?.value;if(!i||!a)return null;const s=t.map(e=>e[o]).filter(e=>null!=e&&isFinite(e));if(2>s.length)return null;const l=s.reduce((e,t)=>e+t,0)/s.length,c=s.reduce((e,t)=>e+(t-l)**2,0)/s.length,u=Math.sqrt(c),d=e.threshold??2,h=l-d*u,f=!1!==e.showBand,g=e.fill||"#6366f1",y=e.fillOpacity??.1,p=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,b=a(l+d*u),v=a(h),x=t.filter(e=>{const t=e[o];return null!=t&&Math.abs(t-l)>d*u});return(0,zo.jsxs)("g",{children:[f&&(0,zo.jsx)("rect",{x:0,y:Math.min(b,v),width:r.width||0,height:Math.abs(v-b),fill:g,fillOpacity:y}),x.map((e,t)=>{const n=vo(e,r),o=xo(e,r);return null==n||null==o?null:(0,zo.jsx)("circle",{cx:n,cy:o,r:m,fill:p,fillOpacity:.7,stroke:p,strokeWidth:1.5},"anomaly-"+t)}),e.label&&(0,zo.jsx)("text",{x:(r.width||0)-4,y:Math.min(b,v)-4,textAnchor:"end",fill:g,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const t=r.data||[];if(3>t.length)return null;const o=r.xAccessor||"x",i=r.yAccessor||"y",a=r.scales?.x??r.scales?.time,s=r.scales?.y??r.scales?.value;if(!a||!s)return null;const l=t.map(e=>[e[o],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>l.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=bo(l,e.order||2).equation;c=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}else{const e=l.length;let t=0,n=0,r=0,o=0;for(const[e,i]of l)t+=e,n+=i,r+=e*e,o+=e*i;const i=e*r-t*t;if(1e-12>Math.abs(i))return null;const a=(e*o-t*n)/i,s=(n-a*t)/e;c=e=>s+a*e}const u=l.length,d=l.map(([e,t])=>t-c(e)),h=d.reduce((e,t)=>e+t*t,0),f=Math.sqrt(h/Math.max(u-2,1)),g=l.reduce((e,t)=>e+t[0],0)/u,y=l.reduce((e,t)=>e+(t[0]-g)**2,0),p=e.confidence??.95,m=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,b=e.steps??5,v=l[u-1][0],x=(v-l[0][0])/Math.max(u-1,1),k=[];for(let e=1;b>=e;e++)k.push(v+e*x);const w=[];for(const e of k){const t=c(e),n=f*Math.sqrt(1+1/u+(y>0?(e-g)**2/y:0))*m;w.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const S=`M${w.map(e=>`${a(e.x)},${s(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${a(e.x)},${s(e.yLower)}`).join(" L")} Z`,M=w.map(e=>`${a(e.x)},${s(e.yCenter)}`).join(" "),A=`${a(v)},${s(c(v))}`,C=e.strokeColor||"#6366f1";return(0,zo.jsxs)("g",{children:[(0,zo.jsx)("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),(0,zo.jsx)("polyline",{points:`${A} ${M}`,fill:"none",stroke:C,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&w.length>0&&(0,zo.jsx)("text",{x:a(w[w.length-1].x)+4,y:s(w[w.length-1].yCenter)-4,fill:C,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let o,i;if(null!=e.px&&null!=e.py)o=e.px,i=e.py;else{const t=So(e,n,r);if(!t)return null;o=t.x,i=t.y}if(!Mo(o,i,r))return null;const a=e.dx??0,s=e.dy??0,l=e.width??32,c=e.height??32,u=e.content??(0,zo.jsx)("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return(0,zo.jsx)("foreignObject",{x:o+a-l/2,y:i+s-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:(0,zo.jsx)("div",{...jo(e,t),style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const t=So(e,n,r);if(!t)return null;const{x:o,y:i}=t,a=o+(e.dx||0),s=i+(e.dy||0),l=e.color||"var(--semiotic-text, #333)",c=(0,zo.jsx)("text",{x:a,y:s,fill:l,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?io.cloneElement(c,{key:"ann-text-"+n}):(0,zo.jsxs)("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[(0,zo.jsx)("line",{x1:o,y1:i,x2:a,y2:s,stroke:l,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),io.cloneElement(c,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+n)}case"category-highlight":{const t=e.category;if(null==t)return null;const o=e=>"function"==typeof e&&"function"==typeof e.bandwidth,i=r.scales?.o,a=r.scales?.x,s=r.scales?.y,l=o(i)?i:o(a)?a:o(s)?s:null;if(!l)return null;const c=l(t+"");if(null==c)return null;const u=l.bandwidth(),d=e.color||"var(--semiotic-primary, #4589ff)",h=e.opacity??.15,f=e.label;return(0,zo.jsxs)("g",(r.projection?"vertical"===r.projection:l===a)?{children:[(0,zo.jsx)("rect",{x:c,y:0,width:u,height:r.height||0,fill:d,fillOpacity:h}),f&&(0,zo.jsx)(Do,{x:c+u/2,y:16,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]}:{children:[(0,zo.jsx)("rect",{x:0,y:c,width:r.width||0,height:u,fill:d,fillOpacity:h}),f&&(0,zo.jsx)(Do,{x:12,y:c+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]},"ann-"+n)}default:return null}var o,i,a}}(),[]),j=C?function(e,t,n,r){const o=[];return e.forEach((e,i)=>{let a;if(n){const o=n(e,i,r);a=null!=o?o:t(e,i,r)}else a=t(e,i,r);a&&o.push({node:a,annotation:e})}),function(e){const t=e.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:ro(e.annotation),readingOrder:null,rank:1};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>to(e.annotation)),o=e.some(e=>null!=no(e.annotation)),i=e.some(e=>"layer"===no(e.annotation));if(!n&&!r&&!o)return e.map(e=>e.node);const a=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);a.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,a.length)});for(const e of t)e.emphasis&&(e.rank=Jr[e.emphasis]);const s=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:n,emphasis:r,readingOrder:o}=e,i=to(t.annotation);let a=t.node;if("primary"===r||"secondary"===r||null!=o){const e=null==r&&null!=o;a=(0,Zr.jsx)("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:oo(o),"data-annotation-reading-order":o}:{},children:t.node},"annotation-emphasis-"+n)}const s=no(t.annotation);return s&&(a=(0,Zr.jsx)("g",{className:"annotation-cohesion--"+s,children:a},"annotation-cohesion-"+n)),i&&(a=(0,Zr.jsx)("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:a},"annotation-deferred-"+n)),a});return r&&s.unshift((0,Zr.jsx)("style",{children:eo},"annotation-disclosure-style")),i&&s.unshift((0,Zr.jsx)("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),s}(o)}(C.filter(e=>"widget"!==e.type),L,S,A):null,T=!0===C?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return(0,hi.jsxs)(hi.Fragment,{children:[T&&(0,hi.jsx)("style",{children:eo},"annotation-widget-disclosure-style"),(0,hi.jsxs)("svg",{role:"img",width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[(0,hi.jsx)("title",{children:"string"==typeof s?s:"Network Chart"}),(0,hi.jsx)("desc",{children:"string"==typeof s?s+" (network data visualization)":"Network data visualization"}),(0,hi.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[a.map((e,t)=>(0,hi.jsx)("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+t)),j,y]}),s&&"string"==typeof s?(0,hi.jsx)("text",{x:r/2,y:22,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:s}):s?(0,hi.jsx)("foreignObject",{x:0,y:0,width:r,height:i.top,children:s}):null,Qr({legend:l,totalWidth:r,totalHeight:o,margin:i,legendPosition:f,title:s,legendLayout:g,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})]}),C?.filter(e=>"widget"===e.type&&e.nodeId&&p).map((e,t)=>{const n=!0===e._annotationDeferred,r=p.find(t=>t.id===e.nodeId||t.datum?.id===e.nodeId||t.datum?.data?.id===e.nodeId||t.datum?.data?.name===e.nodeId);if(!r)return null;const o=i.left+(r.cx??(null!=r.x&&null!=r.w?r.x+r.w/2:r.x??0)),a=i.top+(r.cy??(null!=r.y&&null!=r.h?r.y+r.h/2:r.y??0)),s=e.dx??0,l=e.dy??-16,c=e.width??32,u=e.height??32,d=e.content??(0,hi.jsx)("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return(0,hi.jsx)("div",{...jo(e,M),className:n?"annotation-deferred":void 0,"data-annotation-disclosure":n?"deferred":void 0,style:{position:"absolute",left:o+s-c/2,top:a+l-u/2,width:c,height:u,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:d},"widget-"+t)})]})}fi.displayName="NetworkSVGOverlay";var gi=l(require("react")),yi=require("react/jsx-runtime"),pi={position:"absolute",top:0,left:0,pointerEvents:"none"};function mi({marks:e,margin:t,selection:n=null,overscan:r=400}){const o=gi.useRef(null),i=function(e,t,n){const[r,o]=gi.useState(null);return gi.useLayoutEffect(()=>{const e=t.current,n=function(e){let t=e?.parentElement??null;for(;t;){const{overflow:e,overflowX:n,overflowY:r}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(`${e} ${r} ${n}`))return t;t=t.parentElement}return null}(e);if(!e||!n)return void o(null);let r=0;const i=()=>{r=0;const t=n.getBoundingClientRect(),i=e.getBoundingClientRect();o(0!==t.width&&0!==t.height?{scroll:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},originX:i.left,originY:i.top}:null)},a=()=>{0===r&&(r=window.requestAnimationFrame(i))};i(),n.addEventListener("scroll",a,{passive:!0});const s=new ResizeObserver(a);return s.observe(n),()=>{0!==r&&window.cancelAnimationFrame(r),n.removeEventListener("scroll",a),s.disconnect()}},[t,e,n]),gi.useMemo(()=>{if(!e||!r)return e;const{scroll:t,originX:o,originY:i}=r,a=t.left-n,s=t.right+n,l=t.top-n,c=t.bottom+n;return e.filter(e=>{const t=o+e.x,n=i+e.y;return!(a>t+e.width||t>s||l>n+e.height||n>c)})},[e,r,n])}(e,o,r);if(!e||0===e.length)return null;const a=(0,yi.jsx)("div",{className:"semiotic-network-html-marks",ref:o,style:{...pi,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>(0,yi.jsx)("div",{className:"semiotic-network-html-mark","data-mark-id":e.id,style:{position:"absolute",transform:`translate(${e.x}px, ${e.y}px)`,width:e.width,height:e.height,pointerEvents:"none"},children:e.content},e.id))});return null!=n?(0,yi.jsx)(cn,{value:n,children:a}):a}function bi(e,t,n){if(null==t)return n;if(Po(t)){const r=function(e,t){const n="undefined"!=typeof window&&window.devicePixelRatio||1,r=`${_o(e)}@${n}`,o=$o.get(r);if(void 0!==o)return o;const i=function(e={},t){const{background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:a=45}=e,s={background:n,stroke:r,lineWidth:o,spacing:i,angle:a},l=Math.max(8,Math.ceil(2*i));let c;try{c=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Io||(Io=document.createElement("canvas")),Io.width=e,Io.height=e,Io)}(l)}catch{return Ro(s)}const u=c.getContext("2d");if(!u)return Ro(s);n&&"transparent"!==n?(u.fillStyle=n,u.fillRect(0,0,l,l)):u.clearRect(0,0,l,l),u.strokeStyle=r,u.lineWidth=o,u.lineCap="square";const d=a*Math.PI/180;if(45===a||-45===a){const e=a>0?1:-1;for(let t=-l;2*l>=t;t+=i)u.beginPath(),u.moveTo(t,0),u.lineTo(t+e*l,l),u.stroke()}else{u.save(),u.translate(l/2,l/2),u.rotate(d);const e=2*l;for(let t=-e;e>=t;t+=i)u.beginPath(),u.moveTo(-e,t),u.lineTo(e,t),u.stroke();u.restore()}return(t||u).createPattern(c,"repeat")}({background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle},t),a=Po(i)?null:i;return $o.set(r,a),a}(t,e);return r||t.background&&hr(e,t.background)||n}return"string"!=typeof t?t:hr(e,t)||n}l(require("react")),require("d3-shape"),require("d3-shape");var vi=require("react/jsx-runtime"),xi={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function ki(e,t="#4e79a7"){return Po(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}var wi=l(require("react")),Si=require("d3-shape"),Mi=require("react/jsx-runtime");require("react/jsx-runtime");var Ai="undefined"==typeof window||"undefined"==typeof document,Ci=l(require("react")),Li=l(require("react")),ji=(require("react/jsx-runtime"),Li.createContext(null)),Ti=require("react/jsx-runtime"),Ei={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Di({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+n}return(0,Ti.jsx)("div",{"aria-live":"polite","aria-atomic":"true",style:Ei,children:t})}var Ri=require("react/jsx-runtime");function Ii(e,t,n){const r=[];return e>0&&r.push(e+" nodes"),t>0&&r.push(t+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}var Ni=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Pi="semiotic-accessible-data-table",_i=Pi+" semiotic-accessible-data-table-hidden",Wi=Pi+" semiotic-accessible-data-table-visible semiotic-accessible-data-table-network",$i={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Oi={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Bi={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},zi={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Hi={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},Fi={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},qi={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Yi={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function Gi({nodes:e,edges:t,chartType:n,tableId:r,chartTitle:o}){const[i,a]=Ci.useState(!1),[s,l]=Ci.useState(5),c=Li.useContext(ji),u=c?.visible??!1,d=i||u,h=o?"Data summary for "+o:r?`Data summary for ${n} ${r}`:"Data summary for "+n,f=Ci.useRef(null);Ci.useEffect(()=>{d||l(5)},[d]);const g=Ci.useCallback(e=>{e.target===e.currentTarget&&(i||u||a(!0))},[i,u]),y=Ci.useCallback(e=>{u||f.current?.contains(e.relatedTarget)||a(!1)},[u]);if(!e||0===e.length)return r?(0,Ri.jsx)("span",{id:r,tabIndex:-1,style:Ei}):null;if(!d)return(0,Ri.jsx)("div",{id:r,className:_i,tabIndex:-1,onFocus:g,style:Ei,role:"region","aria-label":h,children:(0,Ri.jsxs)("button",{type:"button",onClick:()=>a(!0),children:["View data summary (",e.length," nodes, ",t.length," edges)"]})});const p=Array.isArray(e)?e:[],m=Array.isArray(t)?t:[],b=new Map,v=new Map,x=new Map,k=new Map;for(const e of m){if(!e||"object"!=typeof e)continue;const t=e.datum??{source:e.source,target:e.target},n="object"==typeof t.source?t.source?.id:t.source,r="object"==typeof t.target?t.target?.id:t.target,o="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";v.set(e,(v.get(e)??0)+1),k.set(e,(k.get(e)??0)+o)}if(null!=r&&""!==r){const e=r+"";b.set(e,(b.get(e)??0)+1),x.set(e,(x.get(e)??0)+o)}}const w=[];for(let e=0;p.length>e;e++){const t=p[e];if(!t||"object"!=typeof t)continue;const n=t.datum?.id??t.id,r=null!=n?n+"":"node-"+e,o=b.get(r)??0,i=v.get(r)??0,a=x.get(r)??0,s=k.get(r)??0;w.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:a+s,wInDeg:a,wOutDeg:s})}w.sort((e,t)=>t.degree-e.degree);let S=0,M=0;if(w.length>0){let e=0;for(const t of w)e+=t.degree,t.degree>M&&(M=t.degree);S=e/w.length}const A=m.some(e=>{const t=e?.datum??{source:e?.source,target:e?.target};return"number"==typeof t?.value&&Number.isFinite(t.value)}),C=[`${w.length} nodes, ${m.length} edges.`];w.length>0&&C.push(`Mean degree: ${Ni(S)}, max degree: ${M}.`);const L=Math.min(s,w.length),j=w.slice(0,L),T=w.length-L;return(0,Ri.jsxs)("div",{ref:f,id:r,className:Wi,tabIndex:-1,onBlur:y,style:$i,role:"region","aria-label":h,children:[(0,Ri.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{u&&c&&c.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:Bi,children:"×"}),(0,Ri.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Oi,children:C.join(" ")}),(0,Ri.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+n,style:zi,children:[(0,Ri.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:qi,children:T>0?`Top ${L} of ${w.length} nodes by degree`:`All ${w.length} nodes by degree`}),(0,Ri.jsx)("thead",{children:(0,Ri.jsxs)("tr",{children:[(0,Ri.jsx)("th",{style:Hi,children:"id"}),(0,Ri.jsx)("th",{style:Hi,children:"degree"}),(0,Ri.jsx)("th",{style:Hi,children:"in"}),(0,Ri.jsx)("th",{style:Hi,children:"out"}),A&&(0,Ri.jsx)("th",{style:Hi,children:"w. degree"}),A&&(0,Ri.jsx)("th",{style:Hi,children:"w. in"}),A&&(0,Ri.jsx)("th",{style:Hi,children:"w. out"})]})}),(0,Ri.jsx)("tbody",{children:j.map((e,t)=>(0,Ri.jsxs)("tr",{children:[(0,Ri.jsx)("td",{style:Fi,children:e.id}),(0,Ri.jsx)("td",{style:Fi,children:e.degree}),(0,Ri.jsx)("td",{style:Fi,children:e.inDeg}),(0,Ri.jsx)("td",{style:Fi,children:e.outDeg}),A&&(0,Ri.jsx)("td",{style:Fi,children:Ni(e.wDegree)}),A&&(0,Ri.jsx)("td",{style:Fi,children:Ni(e.wInDeg)}),A&&(0,Ri.jsx)("td",{style:Fi,children:Ni(e.wOutDeg)})]},t))})]}),T>0&&(0,Ri.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>l(e=>e+25),style:Yi,children:["Show ",Math.min(25,T)," more"," ",1===T?"node":"nodes"," (",T," remaining)"]})]})}function Xi({summary:e}){return e?(0,Ri.jsx)("div",{role:"note",style:Ei,children:e}):null}function Vi({tableId:e}){return(0,Ri.jsx)("a",{href:"#"+e,style:Ei,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Ei)},children:"Skip to data table"})}var Ui=new Set;function Ki(e,t){const n="function"==typeof e?e(t.datum??null,t):e;return(r=n)&&"object"==typeof r&&"string"==typeof r.id&&"function"==typeof r.cacheKey&&"function"==typeof r.drawCanvas&&"function"==typeof r.renderStaticSVG?n:void 0;var r}function Qi(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const n=`${e}:${t}`;Ui.has(n)||(Ui.add(n),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function Zi(e){const{context:t,nodes:n,renderMode:r,pixelRatio:o,paintBuiltIn:i}=e;if(!r||"sketchy"===r)return void i(n);let a=[];const s=()=>{a.length&&(i(a),a=[])};for(const e of n){const n=Ki(r,e);if(!n){a.push(e);continue}let l;s(),t.save();try{l=n.drawCanvas({context:t,node:e,style:e.style??{},pixelRatio:o})}finally{t.restore()}l||(Qi(n.id,e.type??"unknown"),i([e]))}s()}function Ji(e){const{node:t,index:n,renderMode:r,fallback:o}=e,i=Ki(r,t);if(!i)return o();const a=i.renderStaticSVG({node:t,style:t.style??{},key:`${i.id}-${n}`});return null!=a?a:(Qi(i.id,t.type??"unknown"),o())}var ea=Object.freeze([]);function ta(e){if(!e)return ea;let t=!1;for(let n=0;e.length>n;n++){const r=e[n];if(null==r||"object"!=typeof r){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}var na=require("react/jsx-runtime");function ra({props:e,store:t,responsiveRef:n,size:r,margin:o,adjustedWidth:i,adjustedHeight:a,resolvedBackground:s,resolvedForeground:l}){const{chartType:c,nodes:u,edges:d,data:h,className:f,description:g,title:y,responsiveWidth:p,responsiveHeight:m,summary:b,background:v,renderMode:x,legend:k,legendPosition:w,legendLayout:S,legendHoverBehavior:M,legendClickBehavior:A,legendHighlightedCategory:C,legendIsolatedCategories:L,layoutSelection:j,annotations:T,onAnnotationActivate:E,annotationObservationCallback:D,onObservation:R,chartId:I,autoPlaceAnnotations:N,svgAnnotationRules:P}=e;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(c),n=e?h||(Array.isArray(d)?void 0:d):void 0;if(e&&n)t.ingestHierarchy(n,[i,a]),t.buildScene([i,a]);else{const e=ta(u),n=Array.isArray(d)?ta(d):[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[i,a]),t.buildScene([i,a]))}}const _=t?.sceneNodes??[],W=t?.sceneEdges??[],$=t?.labels??[];return(0,na.jsxs)("div",{ref:n,className:"stream-network-frame"+(f?" "+f:""),role:"img","aria-label":g||("string"==typeof y?y:"Network chart"),style:{position:"relative",width:p?"100%":r[0],height:m?"100%":r[1]},children:[(0,na.jsx)(Xi,{summary:b}),(0,na.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:r[0],height:r[1],style:{position:"absolute",left:0,top:0},children:[s&&(0,na.jsx)("g",{transform:`translate(${o.left},${o.top})`,children:s}),(0,na.jsxs)("g",{transform:`translate(${o.left},${o.top})`,children:[v&&(0,na.jsx)("rect",{x:0,y:0,width:i,height:a,fill:v}),W.map((e,t)=>Ji({node:e,index:t,renderMode:x,fallback:()=>function(e,t){switch(e.type){case"line":return(0,Mi.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+t);case"bezier":{const n=e;return(0,Mi.jsx)("path",{d:n.pathD,fill:ki(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"ribbon":{const n=e;return(0,Mi.jsx)("path",{d:n.pathD,fill:ki(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"curved":{const n=e;return(0,Mi.jsx)("path",{d:n.pathD,fill:ki(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+t)}default:return null}}(e,t)})).filter(Boolean),_.map((e,t)=>Ji({node:e,index:t,renderMode:x,fallback:()=>function(e,t){switch(e.type){case"circle":{const n=e,r=Po(n.style.fill)?Oo(n.style.fill,`net-circle-${t}-hatch`):void 0;return(0,Mi.jsxs)(wi.Fragment,{children:[r&&(0,Mi.jsx)("defs",{children:r}),(0,Mi.jsx)("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:r?`url(#net-circle-${t}-hatch)`:ki(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-circle-"+t)}case"rect":{const n=e,r=Po(n.style.fill)?Oo(n.style.fill,`net-rect-${t}-hatch`):void 0;return(0,Mi.jsxs)(wi.Fragment,{children:[r&&(0,Mi.jsx)("defs",{children:r}),(0,Mi.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:r?`url(#net-rect-${t}-hatch)`:ki(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-rect-"+t)}case"arc":{const n=e,r=(0,Si.arc)().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(xi)||"",o=Po(n.style.fill)?Oo(n.style.fill,`net-arc-${t}-hatch`):void 0;return(0,Mi.jsxs)(wi.Fragment,{children:[o&&(0,Mi.jsx)("defs",{children:o}),(0,Mi.jsx)("path",{d:r,transform:`translate(${n.cx},${n.cy})`,fill:o?`url(#net-arc-${t}-hatch)`:ki(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-arc-"+t)}case"symbol":{const n=e,r=ui(n.symbolType,n.size,n.path);return(0,Mi.jsx)("path",{d:r,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?ki(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return function(e,t,n,r){const o=e.glyph;if(!o?.parts?.length||0>=e.size)return null;const i=yn(o,e.size);if(0>=i.scale)return null;const a=`translate(${t},${n})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${i.offsetX},${i.offsetY}) scale(${i.scale})`,s=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),l=xn(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),c=l?function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}(r+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>o.parts.map((n,r)=>{const o=t?"none"===n.fill?void 0:t:mn(n.fill,s,e.accent),i=t?n.stroke&&"none"!==n.stroke?t:void 0:mn(n.stroke??"none",s,e.accent);return o||i?(0,vi.jsx)("path",{d:n.d,fill:o??"none",stroke:i,strokeWidth:i?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},r):null});return(0,vi.jsxs)("g",{transform:a,opacity:1===u?void 0:u,children:[l&&c&&(0,vi.jsx)("clipPath",{id:c,children:(0,vi.jsx)("rect",{x:l.x,y:l.y,width:l.width,height:l.height})}),l&&e.ghostColor?(0,vi.jsx)("g",{children:d(e.ghostColor)}):null,l&&c?(0,vi.jsx)("g",{clipPath:`url(#${c})`,children:d()}):d()]},r)}(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)})).filter(Boolean),$.map((e,t)=>function(e,t){return(0,Mi.jsx)("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+t)}(e,t)).filter(Boolean)]})]}),(0,na.jsx)(fi,{width:i,height:a,totalWidth:r[0],totalHeight:r[1],margin:o,labels:$,sceneNodes:_,title:y,legend:k,legendPosition:w,legendLayout:S,legendHoverBehavior:M,legendClickBehavior:A,legendHighlightedCategory:C,legendIsolatedCategories:L,foregroundGraphics:rn(l,dn(t?.customLayoutOverlays,j??null)),annotations:T,onAnnotationActivate:E,onObservation:D??R,chartId:I,chartType:"StreamNetworkFrame",autoPlaceAnnotations:N,svgAnnotationRules:P,annotationFrame:0}),(0,na.jsx)(mi,{marks:t?.customLayoutHtmlMarks,margin:o,selection:j??null})]})}var oa=require("react"),ia="undefined"!=typeof window?oa.useLayoutEffect:oa.useEffect,aa=()=>()=>{},sa=()=>!1,la=()=>!0;function ca(){const e=(0,oa.useSyncExternalStore)(aa,sa,la);return(0,oa.useRef)(e).current}var ua=require("react"),da=require("react/jsx-runtime");function ha({children:e,size:t,margin:n,overflowVisible:r=!1}){return e?(0,da.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:t[0],height:t[1],pointerEvents:"none",overflow:r?"visible":void 0},children:(0,da.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:e})}):null}var fa=require("react");function ga(e){const t=(0,fa.useRef)(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return pa(e,t);if(!ma(e)||!ma(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;const n=e[r],o=t[r];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!pa(n,o))return!1}else{if(!ma(n)||!ma(o))return!1;if(!ya(n,o))return!1}}return!0}(t.current,e)||(t.current=e),t.current}function ya(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!Object.is(e[r],t[r]))return!1}return!0}function pa(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function ma(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}var ba=l(require("react")),va=require("react/jsx-runtime");function xa({componentName:e,message:t,diagnosticHint:n,width:r,height:o}){return(0,va.jsx)("div",{role:"alert",style:{width:r,height:Math.max(o,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"},children:(0,va.jsxs)("div",{style:{textAlign:"center",maxWidth:400},children:[(0,va.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),(0,va.jsx)("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:t}),n&&(0,va.jsx)("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:n})]})})}var ka=require("react/jsx-runtime"),wa=class extends ba.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.onError?.(e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:(0,ka.jsx)(xa,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}},Sa=require("react/jsx-runtime");function Ma({componentName:e,width:t,height:n,children:r}){return(0,Sa.jsx)(wa,{fallback:r=>(0,Sa.jsx)(xa,{componentName:e,message:r.message,width:t,height:n}),children:r})}"undefined"!=typeof process&&process;var Aa={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Ca={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function La(e,t,n,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?(0,Sa.jsx)("div",{style:{...Aa,width:t,height:n},children:r||"No data available"}):null}function ja(e,t,n,r){if(!e)return null;if(!1===r)return null;if(null!=r)return(0,Sa.jsx)("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const o=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*o))),a=Math.max(6,Math.floor(n/(2.5*o))),s=Math.floor((n-(o*(i+a)-a))/2);return(0,Sa.jsx)("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:o},(e,n)=>(0,Sa.jsx)("div",{className:"semiotic-loading-bar",style:{...Ca,position:"absolute",top:s+n*(i+a),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2}},n))})}var Ta={},Ea=4e4;function Da(e,t,n,r,o=Ea){return"sync"!==e&&("worker"===e||r*(t+n)>=o)}function Ra(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function Ia(){if("undefined"!=typeof DOMException)return new DOMException("Force layout aborted","AbortError");const e=Error("Force layout aborted");return e.name="AbortError",e}var Na=class{constructor(e=function(){const e="string"==typeof Ta.url&&Ta.url?new URL("./forceLayoutWorker.js",Ta.url):function(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:"/"+t;return new URL("./"+e,"file:"+n)}throw Error("Cannot resolve module worker asset: "+e)}("forceLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-force-layout"})}()){this.nextRequestId=1,this.pending=new Map,this.dead=!1,this.worker=e,this.worker.onmessage=e=>{const t=e.data,n=t.requestId,r=null!=n?this.pending.get(n):this.pending.values().next().value;if(r){if(null!=n?this.pending.delete(n):this.pending.clear(),r.cleanup(),t.error){const e=Error(t.error.message);return e.name=t.error.name??"Error",t.error.stack&&(e.stack=t.error.stack),void r.reject(e)}r.resolve({positions:t.positions??{}})}},this.worker.onerror=e=>{this.rejectAll(Error(e.message||"Force layout worker failed")),this.terminate()}}get isDead(){return this.dead}request(e,t){if(this.dead)return Promise.reject(Error("Force layout worker session is closed"));if(t?.aborted)return Promise.reject(Ia());const n=this.nextRequestId;this.nextRequestId+=1;const r={requestId:n,request:e};return new Promise((e,o)=>{const i=()=>{this.pending.delete(n),t?.removeEventListener("abort",i),o(Ia())},a=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:a,reject:o,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(r)}catch(e){this.pending.delete(n),a(),o(e instanceof Error?e:Error(e+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error("Force layout worker terminated")),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}},Pa=null;function _a(e,t){return Ra()?t?.aborted?Promise.reject(Ia()):(Pa&&!Pa.isDead||(Pa=new Na),Pa).request(e,t):Promise.reject(Error("Web Workers are unavailable"))}require("react/jsx-runtime");var Wa=require("react/jsx-runtime"),$a=/^(value|amount|total|count|weight|score)$/i;function Oa({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?(0,Wa.jsxs)("div",{className:"semiotic-tooltip",style:Wn,children:[(0,Wa.jsxs)("div",{style:{fontWeight:600},children:["object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target]}),null!=t.value&&(0,Wa.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]})]}):null}const t=e.data;if(!t)return null;const n=t.__hierarchyNode;if(n){const e=[];let r=n;for(;r;){const n=r.data?.name??r.data?.id??t.id;null!=n&&e.unshift(n+""),r=r.parent}e.length>1&&e.shift();const o=e.length-1;return(0,Wa.jsxs)("div",{className:"semiotic-tooltip",style:Wn,children:[(0,Wa.jsx)("div",{children:e.map((e,t)=>(0,Wa.jsxs)("span",{children:[t>0&&(0,Wa.jsx)("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===o?(0,Wa.jsx)("strong",{children:e}):(0,Wa.jsx)("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&(0,Wa.jsx)("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof t.value?t.value.toLocaleString():t.value+""})]})}const r=(t.sourceLinks?.length||0)+(t.targetLinks?.length||0),o=(t.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(t.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0),i=Pn(t.data??t),a=null!=i.title?i.title+"":t.id,s=i.entries.some(e=>$a.test(e.key));return(0,Wa.jsxs)("div",{className:"semiotic-tooltip",style:Wn,children:[(0,Wa.jsx)("div",{style:{fontWeight:600},children:a}),i.entries.map(e=>{return(0,Wa.jsxs)("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",(t=e.value,null==t?"–":"number"==typeof t?Math.abs(t)>9999?t.toLocaleString():t+"":t instanceof Date?t.toLocaleDateString():t+"")]},e.key);var t}),!s&&null!=t.value&&t.value>0&&(0,Wa.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),r>0&&(0,Wa.jsxs)("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",r,o!==r&&` (weighted: ${o.toLocaleString()})`]})]})}function Ba(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function za(e,t){if(!t.pathD)return;e.save();const n=Ba(t);if(t.style.fill&&"none"!==t.style.fill){const r=t._gradient;if(r){const n=e.createLinearGradient(r.x0,0,r.x1,0),o=t.style.fillOpacity??t.style.opacity??.5,i="string"==typeof t.style.fill?t.style.fill:"#999",a=hr(e,i)||i;n.addColorStop(0,1===r.from?a:"transparent"),n.addColorStop(1,1===r.to?a:"transparent"),e.fillStyle=n,e.globalAlpha=o}else e.fillStyle=bi(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5;e.fill(n)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=hr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.5*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(n)),e.restore()}function Ha(e,t){e.save();const n=t.style.stroke||"#999";e.strokeStyle=hr(e,n)||n,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(t.style.strokeWidth??1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Fa(e,t){if(!t.pathD)return;e.save();const n=Ba(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=bi(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5,e.fill(n)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=hr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.3*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(n)),e.restore()}function qa(e,t){if(!t.pathD)return;e.save();const n=Ba(t),r=t.style.stroke||"#999";e.strokeStyle=hr(e,r)||r,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(n),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=bi(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??.1,e.fill(n)),e.restore()}function Ya(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Ga(e,t,n=.3){Ya(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function Xa(e,t,n=.6){if(!Ya(t))return;const r=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,o=t.cx??t.x??0,i=t.cy??t.y??0;e.beginPath(),e.arc(o,i,r,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}Oa.ownsChrome=!0;var Va=new Map;function Ua(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=Va.get(t);return n||(n=new Path2D(ui(e.symbolType,e.size)),Va.size>256&&Va.clear(),Va.set(t,n)),n}catch{return null}}function Ka(e,t,n,r,o){if(0>=t.size)return;const i=t.glyph;if(!i||!i.parts?.length)return;const a=yn(i,t.size);if(0>=a.scale)return;const s=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=s)return;const l=t=>{const n=bi(e,t,t);return"string"==typeof n?n:t},c=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,r),t.rotation&&e.rotate(t.rotation),e.translate(a.offsetX,a.offsetY),e.scale(a.scale,a.scale),e.globalAlpha=o*s*(t.style.fillOpacity??1);const u=xn(i,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&wn(e,i,c,t.accent,t.ghostColor,l),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),wn(e,i,c,t.accent,void 0,l),e.restore()}function Qa(e){const{canvas:t,store:n,sceneRevisionDiagnostics:r,size:o,margin:i,adjustedWidth:a,adjustedHeight:s,background:l,renderMode:c,hasBackgroundGraphics:u=!1,dirtyRef:d,lastFrameTimeRef:h,now:f,random:g,reducedMotion:y,showParticles:p,isContinuous:m,animate:b,decay:v,pulse:x,thresholds:k,staleness:w,particleStyle:S,getParticleColor:M,pendingAnnotationFrameRef:A,lastAnnotationFrameTimeRef:C,setAnnotationFrame:L,scheduleNextFrame:j,syncColorMap:T}=e,E=t.getContext("2d");if(!E)return;const D=h.current?Math.min((f-h.current)/1e3,.1):.016;h.current=f;const R=n.advanceTransition(y?f+1e6:f),I=!y&&R,N=!y&&n.tickAnimation([a,s],D),P=d.current,_=r?.beforeCompute(n.getLastUpdateResult(),I),W=R||P||N;W&&(n.buildScene([a,s]),P&&T?.()),_&&r?.afterCompute(_,W,!1);const $=p&&!y&&!!n.particlePool,O=!!((B={dirtyOrRebuilt:P,transitioning:I,animationTicked:N,continuous:$||m,liveEncoding:!!v||!!x||!!k||!1!==b&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()}).dirtyOrRebuilt||B.transitioning||B.animationTicked||B.continuous||B.liveEncoding||B.forced);var B;const z=!!w&&n.lastIngestTime>0&&f-n.lastIngestTime>(w?.threshold??5e3);if(O){const e=function(){if("undefined"==typeof window)return 1;const e=window.devicePixelRatio||1,t=function(){if("undefined"==typeof window)return!1;const e="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,t=768>Math.min(window.innerWidth||1/0,window.innerHeight||1/0);return e||t}()?2:3;return Math.max(1,Math.min(e,t))}();if(!function(e,t,n,r){const o=e.getContext("2d");if(!o)return null;const i=Math.round(t[0]*r),a=Math.round(t[1]*r),s=i/t[0],l=a/t[1],c=t[0]+"px",u=t[1]+"px";return e.style.width!==c&&(e.style.width=c),e.style.height!==u&&(e.style.height=u),e.width===i&&e.height===a||(e.width=i,e.height=a),o.setTransform(s,0,0,l,0,0),o.translate(n.left,n.top),o}(t,o,i,e))return;if(E.clearRect(-i.left,-i.top,o[0],o[1]),function(e,t){const{background:n,hasBackgroundGraphics:r=!1,themeBackground:o="",x:i=0,y:a=0,width:s,height:l}=t,c=function(e){const{background:t,hasBackgroundGraphics:n=!1,themeBackground:r=""}=e;return"transparent"===t||n?null:t||(r&&"transparent"!==r?r:"")||null}({background:n,hasBackgroundGraphics:r,themeBackground:o});if(!c)return!1;const u=hr(e,c);u&&(e.fillStyle=u,e.fillRect(i,a,s,l))}(E,{background:l,hasBackgroundGraphics:u,width:a,height:s}),v&&n.applyDecay(),x&&n.applyPulse(f),k&&n.applyThresholds(f),!1!==b&&n.applyTopologyDiff(f),z&&(E.globalAlpha=w?.dimOpacity??.5),Zi({context:E,nodes:n.sceneEdges,renderMode:c,pixelRatio:e,paintBuiltIn:e=>function(e,t){for(const n of t)switch(n.type){case"bezier":za(e,n);break;case"line":Ha(e,n);break;case"ribbon":Fa(e,n);break;case"curved":qa(e,n)}}(E,e)}),Zi({context:E,nodes:n.sceneNodes,renderMode:c,pixelRatio:e,paintBuiltIn:e=>{const t=e;!function(e,t){for(const n of t){if("rect"!==n.type)continue;const t=n;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=bi(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=hr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.strokeRect(t.x,t.y,t.w,t.h)),Ga(e,t),e.restore())}}(E,t),function(e,t){for(const n of t){if("circle"!==n.type)continue;const t=n;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=bi(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=hr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),Xa(e,t),e.restore())}}(E,t),function(e,t){for(const n of t){if("arc"!==n.type)continue;const t=n;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=bi(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=hr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),e.restore()}}(E,t),function(e,t){const n=e.globalAlpha;for(const r of t){if("symbol"!==r.type)continue;const t=r;if(0>=t.size)continue;const o=Ua(t);if(!o)continue;e.save(),e.translate(t.cx,t.cy),t.rotation&&e.rotate(t.rotation);const i=t.style.opacity??1;t.style.fill&&(e.globalAlpha=n*i*(t.style.fillOpacity??1),e.fillStyle=bi(e,t.style.fill,"#007bff"),e.fill(o)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*i,e.strokeStyle=hr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(o)),e.restore()}}(E,t),function(e,t){const n=e.globalAlpha;for(const r of t)"glyph"===r.type&&Ka(e,r,r.cx,r.cy,n);e.globalAlpha=n}(E,t)}}),$&&!z){const e=n.edgesArray;if(e.length>0){!function(e,t,n,r,o=Math.random){const i=r.spawnRate??.1,a=r.maxPerEdge??50;for(let r=0;t.length>r;r++){const s=t[r];if(!s.bezier)continue;if(e.countForEdge(r)>=a)continue;const l=s.value*i*n*(s.bezier.circular?.3:1),c=Math.floor(l),u=l-c;let d=c;o()<u&&d++;for(let t=0;d>t&&e.countForEdge(r)<a;t++)e.spawn(r,o)}}(n.particlePool,e,D,S,g);const t=.5*(S.speedMultiplier??1);let r;if(S.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);r=e.map(e=>.3+(e.value||1)/t*1.7)}n.particlePool.step(D,t,e,r),function(e,t,n,r,o){const i=r.radius??3;e.globalAlpha=r.opacity??.7;for(let a=0;t.particles.length>a;a++){const s=t.particles[a];if(!s.active)continue;const l=n[s.edgeIndex];if(!l)continue;let c;c="string"==typeof r.color&&"inherit"!==r.color?r.color:o(l),e.fillStyle=hr(e,c)||c,e.beginPath(),e.arc(s.x,s.y,i,0,2*Math.PI),e.fill()}e.globalAlpha=1}(E,n.particlePool,e,S,M)}}z&&(E.globalAlpha=1)}d.current=!1,(P||I||N)&&t.setAttribute("aria-label",Ii(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const H=P||I||N||A.current;H&&f-C.current>=33?(L(e=>e+1),C.current=f,A.current=!1):A.current=!!H,(m||I||null!=n.transition||N||n.hasActivePulses||n.hasActiveThresholds||!1!==b&&n.hasActiveTopologyDiff||A.current)&&j()}function Za(e,t=30){return Math.max((e??4)+5,12,t)}function Ja(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function es(e,t,n,r=30){switch(e.type){case"circle":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,a=Math.sqrt(o*o+i*i);return a>Za(e.r,r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,n,r);case"rect":return function(e,t,n){const r=function(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}(t,n,e);return r.hit?{type:"node",datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const r=t-e.cx,o=n-e.cy,i=Math.sqrt(r*r+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const a=Ja(Math.atan2(o,r)),s=Ja(e.startAngle),l=Ja(e.endAngle);if(s>l?a>=s||l>=a:a>=s&&l>=a){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);case"symbol":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,a=Math.sqrt(o*o+i*i);return a>Za(di(e.size),r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,n,r);case"glyph":return function(e,t,n,r=30){if(null==e.datum)return null;const o=kn(e.glyph,e.size),i=e.cx+o.centerDx,a=e.cy+o.centerDy,s=t-i,l=n-a,c=Math.sqrt(s*s+l*l);return c>Za(o.radius,r)?null:{type:"node",datum:e.datum,x:i,y:a,distance:c}}(e,t,n,r);default:return null}}var ts=null,ns=null;function rs(){return ns||((ts=document.createElement("canvas")).width=1,ts.height=1,ns=ts.getContext("2d")),ns}function os(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch{return null}}function is(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const r=os(e),o=rs();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(r,t,n);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);case"line":return function(e,t,n){const r=e.x2-e.x1,o=e.y2-e.y1,i=r*r+o*o;if(0===i)return null;let a=((t-e.x1)*r+(n-e.y1)*o)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*r,l=e.y1+a*o,c=Math.sqrt((t-s)**2+(n-l)**2);return c>5?null:{type:"edge",datum:e.datum,x:s,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const r=os(e),o=rs();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(r,t,n);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);default:return null}}function as(e){const{clientX:t,clientY:n,canvasRect:r,margin:o,adjustedWidth:i,adjustedHeight:a,sceneNodes:s,sceneEdges:l,nodeQuadtree:c,maxNodeRadius:u,hitRadius:d=30}=e,h=t-r.left-o.left,g=n-r.top-o.top;if(0>h||h>i||0>g||g>a)return{kind:"miss-outside"};const y=function(e,t,n,r,o=30,i,a=0){let s=null,l=o,c=1/0;if(i){const e=function(e,t,n,r,o,i=e=>e.x,a=e=>e.y,s=e=>e.r){const l=Math.max(r,o+5,12),c=t-l,u=t+l,d=n-l,h=n+l;let f=null,g=1/0;return e.visit((e,o,l,y,p)=>{if(o>u||c>y||l>h||d>p)return!0;if(!e.length){let o=e;do{const e=o.data,l=i(e)-t,c=a(e)-n,u=Math.sqrt(l*l+c*c);Za(s(e),r)>=u&&g>u&&(f=e,g=u),o=o.next}while(o)}return!1}),f?{node:f,distance:g}:null}(i,n,r,o,a,e=>e.cx,e=>e.cy,e=>e.r);e&&(s={type:"node",datum:e.node.datum,x:e.node.cx,y:e.node.cy,distance:e.distance},l=e.distance)}for(const t of e){if(i&&"circle"===t.type)continue;const e=es(t,n,r,o);if(e)if("rect"===t.type){const n=t.w*t.h;c>n&&(s=e,c=n)}else l>e.distance&&(s=e,l=e.distance)}if(s)return s;for(const e of t){if(!1===e.interactive)continue;const t=is(e,n,r);t&&l>t.distance&&(s=t,l=t.distance)}return s}(s,l,h,g,d,c,u);return y?{kind:"hit",hover:f(y.datum||{},y.x,y.y,{nodeOrEdge:y.type})}:{kind:"miss"}}function ss(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:a,context:s,timestamp:l=Date.now()}=e;t&&(n?(t({type:"hover",datum:n,x:r,y:o,timestamp:l,chartType:i,chartId:a}),"focus"===s?.type&&t({type:"focus",datum:n,inputType:"touch"===s.inputType?"pointer":s.inputType,timestamp:l,chartType:i,chartId:a})):t({type:"hover-end",timestamp:l,chartType:i,chartId:a}))}function ls(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:a,context:s,timestamp:l=Date.now()}=e;t&&(n?(t({type:"click",datum:n,x:r,y:o,timestamp:l,chartType:i,chartId:a}),"activate"===s?.type&&t({type:"activate",datum:n,inputType:s.inputType,timestamp:l,chartType:i,chartId:a})):t({type:"click-end",timestamp:l,chartType:i,chartId:a}))}var cs=require("react"),us="StreamNetworkFrame",ds=require("react/jsx-runtime"),hs={top:20,right:80,bottom:20,left:80},fs={top:40,right:40,bottom:40,left:40},gs=new Set(["chord","force","circlepack","orbit"]),ys=[800,600],ps=(0,d.memo)((0,d.forwardRef)(function(e,t){const{chartType:n,nodes:r,edges:o,data:i,initialEdges:a,nodeIDAccessor:s="id",sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:h="value",edgeIdAccessor:p,childrenAccessor:m,hierarchySum:b,orientation:v="horizontal",nodeAlign:x="justify",nodePaddingRatio:k=.05,nodeWidth:w=15,iterations:S=300,forceStrength:M=.1,layoutExecution:A="auto",layoutLoadingContent:C,onLayoutStateChange:L,padAngle:j=.01,groupWidth:T=20,sortGroups:E,edgeSort:D,treeOrientation:R="vertical",edgeType:I="curve",padding:N,paddingTop:P,tensionConfig:_,showParticles:W=!1,particleStyle:$,renderMode:O,nodeStyle:B,edgeStyle:z,colorBy:H,colorScheme:F="category10",edgeColorBy:q="source",edgeOpacity:Y=.5,colorByDepth:G=!1,nodeSize:X=8,nodeSizeRange:V=[5,20],nodeLabel:U,showLabels:K=!0,labelMode:Q,size:Z=ys,responsiveWidth:J,responsiveHeight:ee,margin:te,className:ne,background:re,enableHover:oe=!0,tooltipContent:ie,customHoverBehavior:ae,customClickBehavior:se,onObservation:le,annotationObservationCallback:ce,chartId:ue,onTopologyChange:de,annotations:he,onAnnotationActivate:fe,autoPlaceAnnotations:ge,svgAnnotationRules:ye,legend:pe,legendPosition:me,legendLayout:be,legendHoverBehavior:ve,legendClickBehavior:xe,legendHighlightedCategory:ke,legendIsolatedCategories:we,title:Se,foregroundGraphics:Me,backgroundGraphics:Ae,decay:Ce,pulse:Le,transition:je,animate:Te,staleness:Ee,frameScheduler:De,clock:Re,random:Ie,seed:Ne,paused:Pe=!1,suspendWhenHidden:_e=!0,thresholds:$e,accessibleTable:Oe=!0,description:Be,summary:ze,orbitMode:He,orbitSize:Fe,orbitSpeed:qe,orbitRevolution:Ye,orbitRevolutionStyle:Ge,orbitEccentricity:Xe,orbitShowRings:Ve,orbitAnimated:Ue,customNetworkLayout:Ke,onLayoutError:Qe,layoutConfig:Ze,layoutSelection:Je}=e,et=gs.has(n)?fs:hs,tt=(0,d.useRef)(!0),nt=pr({sizeProp:Z,responsiveWidth:J,responsiveHeight:ee,userMargin:te,marginDefault:et,title:Se,legend:pe,legendPosition:me,foregroundGraphics:Me,backgroundGraphics:Ae,animate:Te,transitionProp:je,frameScheduler:De,clock:Re,random:Ie,seed:Ne,paused:Pe,suspendWhenHidden:_e,themeDirtyRef:tt}),{reducedMotionRef:rt,responsiveRef:ot,size:it,margin:at,adjustedWidth:st,adjustedHeight:lt,resolvedForeground:ct,resolvedBackground:ut,transition:dt,introEnabled:ht,tableId:ft,rafRef:gt,renderFnRef:yt,scheduleRender:pt,frameRuntime:mt,currentTheme:bt}=nt,vt=function(){const[e,t]=(0,oa.useState)(!1);return ia(()=>{t(!0)},[]),e}(),xt=ca(),kt=(0,d.useMemo)(()=>ta(r),[r]),wt=(0,d.useMemo)(()=>Array.isArray(o)?ta(o):o,[o]),St=(0,d.useMemo)(()=>({...g,..._}),[_]),Mt=(0,d.useMemo)(()=>({...y,...$}),[$]),At=(0,d.useMemo)(()=>{return{chartType:(e={chartType:n,clock:mt.now,random:Ie,seed:Ne,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:c,valueAccessor:h,edgeIdAccessor:p,childrenAccessor:m,hierarchySum:b,orientation:v,nodeAlign:x,nodePaddingRatio:k,nodeWidth:w,iterations:S,forceStrength:M,padAngle:j,groupWidth:T,sortGroups:E,edgeSort:D,treeOrientation:R,edgeType:I,padding:N,paddingTop:P,tensionConfig:St,showParticles:W,particleStyle:Mt,nodeStyle:B,edgeStyle:z,nodeLabel:U,showLabels:K,labelMode:Q,colorBy:H,colorScheme:F,edgeColorBy:q,edgeOpacity:Y,colorByDepth:G,nodeSize:X,nodeSizeRange:V,decay:Ce,pulse:Le,transition:dt,introAnimation:ht,staleness:Ee,thresholds:$e,orbitMode:He,orbitSize:Fe,orbitSpeed:qe,orbitRevolution:Ye,orbitRevolutionStyle:Ge,orbitEccentricity:Xe,orbitShowRings:Ve,orbitAnimated:Ue,customNetworkLayout:Ke,onLayoutError:Qe,layoutConfig:Ze,currentTheme:bt}).chartType,clock:e.clock,random:e.random,seed:e.seed,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,edgeIdAccessor:e.edgeIdAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,tensionConfig:e.tensionConfig,showParticles:e.showParticles,particleStyle:e.particleStyle,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme,themeCategorical:e.currentTheme?.colors?.categorical,themeSemantic:Kn(e.currentTheme),edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,decay:e.decay,pulse:e.pulse,transition:e.transition,introAnimation:e.introAnimation,staleness:e.staleness,thresholds:e.thresholds,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:e.orbitAnimated,customNetworkLayout:e.customNetworkLayout,onLayoutError:e.onLayoutError,layoutConfig:e.layoutConfig};var e},[n,mt.now,Ie,Ne,s,l,c,h,p,m,b,v,x,k,w,S,M,j,T,E,D,R,I,N,P,St,W,Mt,B,z,U,K,Q,H,F,q,Y,G,X,V,Ce,Le,dt,ht,Ee,$e,He,Fe,qe,Ye,Ge,Xe,Ve,Ue,Ke,Qe,Ze,bt]),Ct=ga(At),Lt=ga({chartType:(jt={chartType:n,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:c,valueAccessor:h,edgeIdAccessor:p,childrenAccessor:m,hierarchySum:b,orientation:v,nodeAlign:x,nodePaddingRatio:k,nodeWidth:w,iterations:S,forceStrength:M,padAngle:j,groupWidth:T,sortGroups:E,edgeSort:D,treeOrientation:R,edgeType:I,padding:N,paddingTop:P,random:Ie,seed:Ne,tensionConfig:St,customNetworkLayout:Ke,orbitMode:He,orbitSize:Fe,orbitEccentricity:Xe}).chartType,nodeIDAccessor:jt.nodeIDAccessor,sourceAccessor:jt.sourceAccessor,targetAccessor:jt.targetAccessor,valueAccessor:jt.valueAccessor,edgeIdAccessor:jt.edgeIdAccessor,childrenAccessor:jt.childrenAccessor,hierarchySum:jt.hierarchySum,orientation:jt.orientation,nodeAlign:jt.nodeAlign,nodePaddingRatio:jt.nodePaddingRatio,nodeWidth:jt.nodeWidth,iterations:jt.iterations,forceStrength:jt.forceStrength,padAngle:jt.padAngle,groupWidth:jt.groupWidth,sortGroups:jt.sortGroups,edgeSort:jt.edgeSort,treeOrientation:jt.treeOrientation,edgeType:jt.edgeType,padding:jt.padding,paddingTop:jt.paddingTop,random:jt.random,seed:jt.seed,tensionConfig:jt.tensionConfig,customNetworkLayout:jt.customNetworkLayout,orbitMode:jt.orbitMode,orbitSize:jt.orbitSize,orbitEccentricity:jt.orbitEccentricity});var jt;const Tt=(0,d.useRef)(0),Et=(0,d.useRef)(0),Dt=(0,d.useRef)(!1),Rt=(0,d.useRef)(null);Rt.current||(Rt.current=new Xt(Ct));const It=(0,Vt.useRef)(new en("StreamNetworkFrame")),Nt=(0,d.useCallback)((e,t,n=!1)=>function(e,t,n,r=!1,o=!1){const i=e.beforeCompute(t.getLastUpdateResult(),r);n(),e.afterCompute(i,!0,o)}(It.current,e,()=>e.buildScene(t),n),[It]),[_t,Wt]=(0,d.useState)(null),[$t,Ot]=(0,d.useState)(0),[Bt,zt]=(0,d.useState)(0),[Ht,Ft]=(0,d.useState)(!1),[qt,Yt]=(0,d.useState)(!1),Gt=(0,d.useRef)(0),Ut=(0,d.useRef)(null),Kt=(0,d.useRef)(!1),Qt=(0,d.useRef)(L);Qt.current=L;const Zt=(0,d.useRef)(Ct);Zt.current=Ct;const Jt=(0,d.useRef)(null),nn=(0,d.useRef)(new Map),on=(0,d.useRef)(0),an=(0,d.useCallback)(e=>function(e){const{node:t,colorBy:n,colorScheme:r,nodeColorMap:o,colorIndexRef:i}=e;if("function"==typeof n)return n(t)+"";if("string"==typeof n&&t.data){const e=t.data[n];if(void 0!==e){if(!o.has(e+"")){const t=Array.isArray(r)?r:Pt;o.set(e+"",t[i.current++%t.length])}return o.get(e+"")}}if(o.has(t.id))return o.get(t.id);const a=Array.isArray(r)?r:Pt,s=n?a[i.current++%a.length]:a[0];return o.set(t.id,s),s}({node:e,colorBy:H,colorScheme:F,nodeColorMap:nn.current,colorIndexRef:on}),[H,F]),sn=(0,d.useCallback)(e=>{on.current=function(e){const{sceneNodes:t,nodes:n,nodeColorMap:r,colorScheme:o}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&r.set(e.id,e.style.fill);const i=Array.isArray(o)?o:Pt,a=Array.from(n);for(let e=0;a.length>e;e++){const t=a[e];r.has(t.id)||r.set(t.id,i[e%i.length])}return a.length}({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:nn.current,colorScheme:F})},[F]),ln=(0,d.useCallback)((e,t)=>{Nt(e,t),sn(e),tt.current=!1,e.markStylePaintPending()},[Nt,sn]),cn=(un=bt,un?.colors?.border||un?.colors?.secondary||un?.colors?.primary||"#999");var un;const fn=(0,d.useCallback)(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,Rt.current?.nodes),[]),gn=(0,d.useCallback)(e=>function(e){const{edge:t,edgeColorBy:n,getNodeColor:r,resolveEndpoint:o,fallback:i}=e;if("function"==typeof n)return n(t);const a=o(t.source),s=o(t.target);return"target"===n&&s?r(s):a?r(a):i}({edge:e,edgeColorBy:q,getNodeColor:an,resolveEndpoint:fn,fallback:cn}),[q,an,cn,fn]),yn=(0,d.useCallback)(e=>function(e){const{edge:t,particleStyleColor:n,particleColorBy:r,hasExplicitParticleColorBy:o,getEdgeColor:i,getNodeColor:a,resolveEndpoint:s,fallback:l}=e;if("function"==typeof n){const e=s(t.source);return e?n(t,e):l}if(!o)return i(t);const c=r,u=s(t.source),d=s(t.target);return"target"===c&&d?a(d):u?a(u):l}({edge:e,particleStyleColor:Mt.color,particleColorBy:Mt.colorBy,hasExplicitParticleColorBy:!!$?.colorBy,getEdgeColor:gn,getNodeColor:an,resolveEndpoint:fn,fallback:cn}),[$?.colorBy,Mt.color,Mt.colorBy,an,gn,cn,fn]),pn=function(e,t,n,r,o){return("sankey"===e||t)&&n||r||o}(n,!!Ke,W,!!Le,Rt.current?.isAnimating??!1);!function(e,t,n,r){(0,hn.useEffect)(()=>{e.current?.updateConfig(t),n.current=!0,r()},[t,r,e,n])}(Rt,Ct,tt,pt),function(e,t,n,r){const o=(0,hn.useRef)(null);(0,hn.useEffect)(()=>{const i=e.current;if(!i)return;const a=t??null;o.current!==a&&(o.current=a,i.setLayoutSelection(a),i.hasCustomRestyle?i.restyleScene(a):n.current=!0,r())},[t,r,e,n])}(Rt,Je,tt,pt),(0,d.useEffect)(()=>{const e=Rt.current;e&&(ln(e,[st,lt]),pt())},[bt,st,lt,ln,pt]);const mn=(0,d.useCallback)(()=>{const e=Rt.current;if(e&&(e.runLayout([st,lt]),ln(e,[st,lt]),Ot(e.layoutVersion),de)){const{nodes:t,edges:n}=e.getLayoutData();de(t,n)}},[st,lt,ln,de]),bn=(0,d.useRef)(!1),vn=(0,d.useCallback)((e=!1)=>!(!e&&!bn.current||(bn.current=!1,mn(),0)),[mn]),xn=(0,d.useCallback)(()=>vn(!1),[vn]),wn=(0,d.useCallback)(e=>{const t=Rt.current;if(!t)return!1;let n=!1,r=bn.current;for(const o of e)null!=o&&"object"==typeof o&&(n=!0,t.ingestEdge(o)&&(r=!0));const o=vn(r);return n||o},[vn]),Mn=(0,d.useCallback)(e=>{if(null==e||"object"!=typeof e)return;const t=Rt.current;t&&(t.ingestEdge(e)&&(bn.current=!0),mt.isActive?pt():xn())},[xn,mt,pt]),Cn=(0,d.useCallback)(e=>{wn(e)&&pt()},[wn,pt]);(0,d.useEffect)(()=>mt.subscribe(()=>{mt.isActive||xn()}),[xn,mt]);const Ln=(0,d.useCallback)(()=>{bn.current=!1,Rt.current?.clear(),nn.current.clear(),on.current=0,Ot(Rt.current?.layoutVersion??0),Wt(null),Jt.current=null,tt.current=!0,pt()},[pt]),Tn=(0,d.useCallback)(()=>{const e=Rt.current;e&&(e.tension+=999,vn(!0),pt())},[vn,pt]);(0,d.useImperativeHandle)(t,()=>({push:Mn,pushMany:Cn,removeNode:e=>{const t=Rt.current?.removeNode(e)??!1;if(t){const t=Jt.current?.data?"function"==typeof s?s(Jt.current.data):Jt.current.data[s]:void 0;Jt.current&&"node"===Jt.current.nodeOrEdge&&t===e&&(Jt.current=null,Wt(null)),nn.current.delete(e)}return vn(t)&&(tt.current=!0,pt()),t},removeEdge:(e,t)=>{const n=Rt.current?.removeEdge(e,t)??!1;if(n&&Jt.current&&"edge"===Jt.current.nodeOrEdge){const n=Jt.current.data;let r;r=void 0!==t?("object"==typeof n?.source?n.source.id:n?.source)===e&&("object"==typeof n?.target?n.target.id:n?.target)===t:!p||!n||("function"==typeof p?p:e=>e?.[p])(n)===e,r&&(Jt.current=null,Wt(null))}return vn(n)&&(tt.current=!0,pt()),n},updateNode:(e,t)=>{const n=Rt.current?.updateNode(e,t)??null;return vn(null!==n)&&(tt.current=!0,pt()),n},updateEdge:(e,t,n)=>{const r=Rt.current?.updateEdge(e,t,n)??[];return vn(r.length>0)&&(tt.current=!0,pt()),r},clear:Ln,getTopology:()=>(xn(),Rt.current?.getLayoutData()??{nodes:[],edges:[]}),getCustomLayout:()=>(xn(),Rt.current?.lastCustomLayoutResult??null),getLayoutFailure:()=>(xn(),Rt.current?.lastCustomLayoutFailure??null),getTopologyDiff:()=>{xn();const e=Rt.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:Tn,getTension:()=>(xn(),Rt.current?.tension??0)}),[Mn,Cn,Ln,Tn,xn,vn,s,pt,p]);const En=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),Dn=En?i||(Array.isArray(o)?void 0:o):void 0;(0,d.useEffect)(()=>{const e=Rt.current;if(!e)return;const t=++Gt.current;if(Ut.current?.abort(),Ut.current=null,En&&Dn)bn.current=!1,e.ingestHierarchy(Dn,[st,lt]),ln(e,[st,lt]),Yt(!1),Qt.current?.("ready"),pt();else{const i=kt,a=Array.isArray(wt)?wt:[];if(null==r&&null==o||(bn.current=!1),0===i.length&&0===a.length)return null==r&&null==o||0>=e.nodes.size&&0>=e.edges.size||Ln(),Yt(!1),void Qt.current?.("ready");const s=[st,lt],l="force"===n&&!Ke&&Ra()&&!Ie&&Da(A,i.length,a.length,S);if(l&&xt&&!Kt.current&&e.sceneNodes.length>0)return Kt.current=!0,Yt(!1),Qt.current?.("ready"),tt.current=!0,void pt();if(l){const n=new AbortController;Ut.current=n;const r=e._lastPositionSnapshot;e.ingestBounded(i,a,s,{deferLayout:!0});const o=e.getLayoutData(),l=function(e,t,n,r,o){const i=We(n.nodeSize,n.nodeSizeRange,e);return{kind:"frame",nodes:e.map(e=>{const t=o?.get(e.id);return{id:e.id,x:0!==e.x||0!==e.y?e.x:t?.x??0,y:0!==e.x||0!==e.y?e.y:t?.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:e.value,__forceRadius:i(e)}}),edges:t.map(e=>{const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id,r=e.data?.weight,o="number"==typeof r&&Number.isFinite(r)?r:e.value;return{source:t,target:n,value:e.value,y0:0,y1:0,sankeyWidth:0,weight:o}}),config:{chartType:"force",iterations:n.iterations,forceStrength:n.forceStrength,seed:n.seed},size:r}}(o.nodes,o.edges,Zt.current,s,r);return Yt(!0),Qt.current?.("pending"),_a(l,n.signal).then(({positions:n})=>{t===Gt.current&&(e.applyForceLayoutPositions(n,s),ln(e,s),Yt(!1),Qt.current?.("ready"),Ot(e.layoutVersion),pt())}).catch(n=>{"AbortError"!==n.name&&t===Gt.current&&(e.runLayout(s),ln(e,s),Yt(!1),Qt.current?.("error"),Ot(e.layoutVersion),pt())}),()=>n.abort()}e.ingestBounded(i,a,s),ln(e,s),Yt(!1),Qt.current?.("ready"),pt()}},[kt,wt,r,o,i,Dn,En,st,lt,Lt,A,S,xt,n,Ke,Ie,pt,Ln,ln]);const Rn=u.useRef(!1);(0,d.useEffect)(()=>{Rn.current||a&&a.length>0&&(Rn.current=!0,Cn(a))},[a,Cn]);const{customHoverBehavior:In,customClickBehavior:Nn}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:r}){return{customHoverBehavior:(0,cs.useCallback)((t,o)=>{e?.(t,o),ss({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:us,chartId:r,context:o})},[e,n,r]),customClickBehavior:(0,cs.useCallback)((e,o)=>{t?.(e,o),ls({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:us,chartId:r,context:o})},[t,n,r])}}({customHoverBehavior:ae,customClickBehavior:se,onObservation:le,chartId:ue}),{hoverHandlerRef:Pn,hoverLeaveRef:_n,onPointerMove:Wn,onPointerLeave:$n}=nt,On=()=>!Ke||(Rt.current?.hasCustomRestyle??!1);Pn.current=e=>{if(!oe)return;const t=On(),n=Vn.current;if(!n)return;const r=Rt.current;if(!r)return;const o=as({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:at,adjustedWidth:st,adjustedHeight:lt,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});"hit"===o.kind?(Jt.current=o.hover,Wt(o.hover),In&&(In(o.hover),t&&(tt.current=!0)),t&&pt()):Jt.current&&(Jt.current=null,Wt(null),In&&(In(null),t&&(tt.current=!0)),t&&pt())},_n.current=()=>{if(Jt.current){const e=On();Jt.current=null,Wt(null),In&&(In(null),e&&(tt.current=!0)),e&&pt()}};const Bn=(0,d.useRef)(()=>{});Bn.current=e=>{if((t=e.target)instanceof Element&&null!=t.closest("[data-semiotic-annotation-widget]"))return;var t;if(!se&&!le)return;const n=Vn.current;if(!n)return;const r=Rt.current;if(!r)return;const o=as({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:at,adjustedWidth:st,adjustedHeight:lt,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});var i;"hit"===o.kind?Nn(o.hover,{type:"activate",inputType:(i=e.nativeEvent.pointerType,"touch"===i?"touch":"pointer")}):"miss"===o.kind&&Nn(null)};const zn=(0,d.useCallback)(e=>Bn.current(e),[]),Hn=(0,d.useRef)(-1),qn=(0,d.useRef)(null),Yn=(0,d.useRef)(-1),Gn=(0,d.useCallback)(e=>{if(function(e){const t=e.target;return t instanceof Element&&t!==e.currentTarget&&null!=t.closest("button, a[href], input, select, textarea, summary, [contenteditable='true'], [role='button'], [role='link'], [role='checkbox'], [role='radio'], [role='switch']")}(e))return;const t=Rt.current;if(!t)return;const n=()=>{Hn.current=-1,qn.current=null,Yn.current=-1,Jt.current=null,Wt(null),In&&(In(null),tt.current=!0),pt()},r=function(e){const t=[];for(const n of e)if("circle"===n.type&&null!=n.cx){if(0>=n.r)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("rect"===n.type&&null!=n.x){if(0>=n.w||0>=n.h)continue;t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.datum?.id??"_default"})}else if("arc"===n.type&&null!=n.cx)t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"});else if("symbol"===n.type&&null!=n.cx){if(0>=n.size)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("glyph"===n.type&&null!=n.cx){if(0>=n.size||null==n.datum)continue;const e=kn(n.glyph,n.size);t.push({x:n.cx+e.centerDx,y:n.cy+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:n.datum?.id??"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===r.length)return void(0>Hn.current||n());const o=function(e){const t=new Map;for(const n of e){const e=n.group??"_default";let r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}for(const e of t.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const n=Array.from(t.keys()).sort((e,n)=>{const r=t.get(e),o=t.get(n);return(r.length>0?r[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(t.values()).flat();r.sort((e,t)=>e.x-t.x||e.y-t.y);const o=new Map;for(let e=0;r.length>e;e++){r[e]._flatIndex=e;const t=r[e].datum?.id;null!=t&&o.set(t+"",e)}return{flat:r,groups:n,byGroup:t,idToIdx:o}}(r);let i=Hn.current;if(o.flat.length>i||(n(),i=-1)," "===e.key&&i>=0){e.preventDefault();const t=o.flat[i];return void Nn(f(t.datum||{},t.x,t.y,{nodeOrEdge:"node"}),{type:"activate",inputType:"keyboard"})}if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),Hn.current=0,Yn.current=-1;const t=o.flat[0];qn.current={shape:t.shape,w:t.w,h:t.h};const n=f(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Jt.current=n,Wt(n),In&&(In(n,{type:"focus",inputType:"keyboard"}),tt.current=!0),void pt()}const a=function(e,t){if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const n=Math.max(0,Math.min(t,e.flat.length-1)),r=e.flat[n];return{flatIndex:n,group:r.group??"_default",indexInGroup:r._groupIndex??0}}(o,i),s=function(e,t,n,r,o){const i=n.flat[t.flatIndex];if(!i)return Sn(e,t,n);const a=i.datum?.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=function(e,t,n){let r=null,o=1/0;for(let i=0;e.flat.length>i;i++){const a=e.flat[i];if(a===t)continue;const s=a.x-t.x,l=a.y-t.y;let c=!1;switch(n){case"right":c=s>0&&Math.abs(s)>=Math.abs(l);break;case"left":c=0>s&&Math.abs(s)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(s);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(s)}if(!c)continue;const u=s*s+l*l;o>u&&(o=u,r=i)}return r}(n,i,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up")??t.flatIndex;return r!==t.flatIndex&&(o.current=-1),r}case"Enter":{if(null==a)return t.flatIndex;const e=function(e,t){const n=e+"",r=[];for(const e of t){const t=e.datum??e,o=An(t.source),i=An(t.target),a=null!=o,s=null!=i;a&&o+""===n&&s?r.push(i+""):s&&i+""===n&&a&&r.push(o+"")}return r}(a,r);if(0===e.length)return t.flatIndex;const i=n.idToIdx.get(e[(o.current+1)%e.length])??-1;return 0>i?t.flatIndex:(o.current=-1,i)}default:{const r=Sn(e,t,n);return null!==r&&r!==t.flatIndex&&(o.current=-1),r}}}(e.key,a,o,t.sceneEdges??[],Yn);if(null===s)return;if(e.preventDefault(),0>s)return void n();Hn.current=s;const l=o.flat[s];qn.current={shape:l.shape,w:l.w,h:l.h};const c={data:l.datum||{},x:l.x,y:l.y,__semioticHoverData:!0,nodeOrEdge:"node"};Jt.current=c,Wt(c),In&&(In(c,{type:"focus",inputType:"keyboard"}),tt.current=!0),pt()},[Nn,In,pt]),Xn=(0,d.useCallback)(e=>{Hn.current=-1,qn.current=null,Wn(e)},[Wn]);yt.current=()=>{if(gt.current=null,xn(),!mt.isActive)return;const e=Vn.current;if(!e)return;const t=Rt.current;t&&Qa({canvas:e,store:t,sceneRevisionDiagnostics:It.current,size:it,margin:at,adjustedWidth:st,adjustedHeight:lt,background:re,renderMode:O,hasBackgroundGraphics:!!Ae,dirtyRef:tt,lastFrameTimeRef:Tt,now:mt.now(),random:mt.random,reducedMotion:!!rt.current,showParticles:W,isContinuous:pn,animate:Te,decay:Ce,pulse:Le,thresholds:$e,staleness:Ee,particleStyle:Mt,getParticleColor:yn,pendingAnnotationFrameRef:Dt,lastAnnotationFrameTimeRef:Et,setAnnotationFrame:zt,scheduleNextFrame:()=>{pt()},syncColorMap:()=>sn(t)})};const{canvasRef:Vn}=function(e,t){return function(e){const{cancelRender:t,dirtyRef:n,frameRuntime:r,manageFrameRuntime:o,scheduleRender:i}=e,a=(0,ua.useRef)(null),s=(0,ua.useRef)(null),l=(0,ua.useRef)(!1);return function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:r,dirtyRef:o,renderFnRef:i,cancelRender:a,cleanup:s}=e;ia(()=>{const e=r.current;t&&n&&e?.cancelIntroAnimation?.(),!n&&e?.sceneNodes&&e.sceneNodes.length>0&&e?.markStylePaintPending?e.markStylePaintPending():o.current=!0,a?.(),i.current()},[t,n]);const l=(0,oa.useRef)(s);l.current=s,(0,oa.useEffect)(()=>()=>l.current?.(),[])}({hydrated:e.hydrated,wasHydratingFromSSR:e.wasHydratingFromSSR,storeRef:e.storeRef,dirtyRef:e.dirtyRef,renderFnRef:e.renderFnRef,cancelRender:e.cancelRender,cleanup:e.cleanup}),(0,ua.useEffect)(()=>{if(!1!==o)return r.subscribe(()=>{r.isActive?(n.current=!0,i()):t()})},[t,n,r,o,i]),(0,ua.useEffect)(()=>{!l.current&&(l.current=!0,e.skipInitialCanvasPaintInvalidation)||(e.dirtyRef.current=!0,e.scheduleRender())},e.canvasPaintDependencies),{canvasRef:a,interactionCanvasRef:s}}({...t,renderFnRef:e.renderFnRef,scheduleRender:e.scheduleRender,cancelRender:e.cancelRender,frameRuntime:e.frameRuntime})}(nt,{hydrated:vt,wasHydratingFromSSR:xt,storeRef:Rt,dirtyRef:tt,skipInitialCanvasPaintInvalidation:!0,canvasPaintDependencies:[n,st,lt,re,Ae,O,pt]});!function(e,t,n,r,o,i){const a=(0,mr.useRef)("fresh");(0,mr.useEffect)(()=>{if(!e)return;const s=setInterval(()=>{const s=t.current;if(!s||0===s.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=function(e,t){if(!e||0>=t)return vr;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,r=e.graded;if(r){const e="object"==typeof r?r:{},o=function(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??1)>e?"fresh":t*(n.aging??1.5)>e?"aging":t*(n.stale??3)>e?"stale":"expired":"fresh"}(t,n,e.thresholds);return{alpha:{...br,...e.opacities??{}}[o],band:o,isStale:"fresh"!==o}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:vr}(e,l-s.lastIngestTime);c.band===a.current&&c.isStale===o||(a.current=c.band,c.isStale!==o&&i(c.isStale),n.current=!0,r())},1e3);return()=>clearInterval(s)},[e,o,r,t,i,n])}(Ee,Rt,tt,pt,Ht,Ft);const Un=oe&&_t?(0,ds.jsx)(Fn,{x:_t.x,y:_t.y,containerWidth:st,containerHeight:lt,margin:at,className:"stream-network-tooltip",zIndex:2,children:ie?ie(_t):(0,ds.jsx)(Oa,{data:_t})}):null;if(Ai||!vt&&xt)return(0,ds.jsx)(ra,{props:e,store:Rt.current,responsiveRef:ot,size:it,margin:at,adjustedWidth:st,adjustedHeight:lt,resolvedBackground:ut,resolvedForeground:ct});const Qn=Rt.current;return(0,ds.jsxs)("div",{ref:ot,className:"stream-network-frame"+(ne?" "+ne:""),role:"group","aria-label":Be||("string"==typeof Se?Se:"Network chart"),tabIndex:0,"aria-busy":qt||void 0,style:{position:"relative",width:J?"100%":it[0],height:ee?"100%":it[1],overflow:"visible"},onKeyDown:Gn,children:["production"!==process.env.NODE_ENV&&Rt.current&&(0,ds.jsx)(tn,{store:Rt.current,diagnostics:It.current}),Oe&&(0,ds.jsx)(Vi,{tableId:ft}),Oe&&(0,ds.jsx)(Gi,{nodes:Qn?.sceneNodes??[],edges:Qn?.sceneEdges??[],chartType:"Network chart",tableId:ft,chartTitle:"string"==typeof Se?Se:void 0}),(0,ds.jsx)(Xi,{summary:ze}),(0,ds.jsx)(Di,{hoverPoint:_t}),(0,ds.jsxs)("div",{role:"img","aria-label":Be||("string"==typeof Se?Se:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:oe?Xn:void 0,onMouseLeave:oe?$n:void 0,onClick:se||le?zn:void 0,children:[qt&&!1!==C&&(0,ds.jsx)("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:ja(!0,it[0],it[1],C)}),(0,ds.jsx)(ha,{size:it,margin:at,overflowVisible:!0,children:ut}),(0,ds.jsx)("canvas",{ref:Vn,"aria-label":Ii(Qn?.sceneNodes?.length??0,Qn?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),(0,ds.jsx)(fi,{width:st,height:lt,totalWidth:it[0],totalHeight:it[1],margin:at,labels:Qn?.labels||[],sceneNodes:Qn?.sceneNodes,title:Se,legend:pe,legendPosition:me,legendLayout:be,legendHoverBehavior:ve,legendClickBehavior:xe,legendHighlightedCategory:ke,legendIsolatedCategories:we,foregroundGraphics:rn(ct,dn(Rt.current?.customLayoutOverlays,Je??null)),annotations:he,onAnnotationActivate:fe,onObservation:ce??le,chartId:ue,chartType:"StreamNetworkFrame",autoPlaceAnnotations:ge,svgAnnotationRules:ye,annotationFrame:Bt}),(0,ds.jsx)(mi,{marks:Qn?.customLayoutHtmlMarks,margin:at,selection:Je??null}),(0,ds.jsx)(jn,{active:Hn.current>=0,hoverPoint:_t,margin:at,size:it,shape:qn.current?.shape,width:qn.current?.w,height:qn.current?.h}),Un,Ee?.showBadge&&(0,ds.jsx)(kr,{isStale:Ht,position:Ee.badgePosition})]})]})}));ps.displayName="StreamNetworkFrame";var ms=ps,bs=require("react");function vs(e,t){const{variant:n,frameRef:r,overrides:o}=t,i=(0,bs.useRef)(o);i.current=o,(0,bs.useImperativeHandle)(e,()=>{const e=function(e,t){if("xy"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.remove(t)??[],update:(t,n)=>e.current?.update(t,n)??[],replace:t=>e.current?.replace?.(t),clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getScales:()=>e.current?.getScales()??null,getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("network"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>{const n=Array.isArray(t)?t:[t],r=e.current?.getTopology()?.nodes??[],o=[];for(const t of n){const n=r.find(e=>e.id===t);n&&o.push({...n.data??{},id:t}),e.current?.removeNode(t)}return o},update:(t,n)=>(Array.isArray(t)?t:[t]).flatMap(t=>{const r=e.current?.updateNode(t,n);return r?[{...r,id:t}]:[]}),clear:()=>e.current?.clear(),getData:()=>e.current?.getTopology()?.nodes?.map(e=>e.data)??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("geo-points"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.removePoint(t)??[],update:(t,n)=>{const r=e.current?.removePoint(t)??[];for(const t of r)e.current?.push(n(t));return r},clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}const n=t;return{push:e=>n.current?.pushLine(e),pushMany:e=>n.current?.pushManyLines(e),remove:e=>n.current?.removeLine(e)??[],update:(e,t)=>{const r=n.current?.removeLine(e)??[];for(const e of r)n.current?.pushLine(t(e));return r},clear:()=>n.current?.clear(),getData:()=>n.current?.getLines()??[],getCustomLayout:()=>n.current?.getCustomLayout?.()??null,getLayoutFailure:()=>n.current?.getLayoutFailure?.()??null}}(n,r);return new Proxy(e,{get(e,t,n){if("string"==typeof t){const e=i.current?.[t];if("function"==typeof e)return e}return Reflect.get(e,t,n)},has:(e,t)=>!("string"!=typeof t||!i.current||!(t in i.current))||Reflect.has(e,t)})},[])}var xs=require("react"),ks=require("react"),ws=require("react"),Ss=(require("react/jsx-runtime"),(0,ws.createContext)(null)),Ms=.5,As=require("react");function Cs(e){const t=[];for(const[n,r]of Object.entries(e.fields))if("point"===r.type)t.push(e=>r.values.has(e[n]));else{const[e,o]=r.range;t.push(t=>{const r=t[n];return r>=e&&o>=r})}return e=>t.every(t=>t(e))}function Ls(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function js(e,t){if(e.type!==t.type)return!1;if("interval"===e.type&&"interval"===t.type)return e.range[0]===t.range[0]&&e.range[1]===t.range[1];if("point"===e.type&&"point"===t.type){if(e.values.size!==t.values.size)return!1;for(const n of e.values)if(!t.values.has(n))return!1;return!0}return!1}var[Ts,Es]=Vn(e=>({selections:new Map,setClause(t,n){e(e=>{const r=e.selections.get(t),o=r?.clauses.get(n.clientId);if(o&&function(e,t){if(e.clientId!==t.clientId||e.type!==t.type)return!1;const n=Object.entries(e.fields);if(n.length!==function(e){let t=0;for(const n in e)t++;return t}(t.fields))return!1;for(const[e,r]of n){const n=t.fields[e];if(!n||!js(r,n))return!1}return!0}(o,n))return{};const i=new Map(e.selections),a=Ls(i,t),s=new Map(a.clauses);return s.set(n.clientId,n),i.set(t,{...a,clauses:s}),{selections:i}})},clearClause(t,n){e(e=>{const r=e.selections.get(t);if(!r||!r.clauses.has(n))return{};const o=new Map(e.selections),i=new Map(r.clauses);return i.delete(n),o.set(t,{...r,clauses:i}),{selections:o}})},setResolution(t,n){e(e=>{const r=e.selections.get(t);if(r?.resolution===n)return{};const o=new Map(e.selections),i=Ls(o,t);return o.set(t,{...i,resolution:n}),{selections:o}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const r=new Map(e.selections);return r.set(t,{...n,clauses:new Map}),{selections:r}})}})),Ds=(require("react"),{positions:new Map}),Rs=new Set;function Is(){for(const e of Rs)e()}function Ns(e,t){const n=Ds.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const r=new Map(Ds.positions);r.delete(e),Ds={positions:r},Is()}function Ps(e,t){const n=Ds.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const r=new Map(Ds.positions);r.delete(e),Ds={positions:r},Is()}function _s(e){const t=(0,As.useId)(),n=e.clientId||t,{name:r}=e,o=Es(e=>e.selections.get(r)),i=Es(e=>e.setClause),a=Es(e=>e.clearClause),s=(0,As.useMemo)(()=>!!o&&o.clauses.size>0,[o]);return{predicate:(0,As.useMemo)(()=>o&&0!==o.clauses.size?function(e,t){const n=[];for(const[r,o]of e.clauses)"crossfilter"===e.resolution&&r===t||n.push(Cs(o));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(o,n):()=>!0,[o,n]),isActive:s,selectPoints:(0,As.useCallback)(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"point",values:new Set(r)},o=!0;o&&i(r,{clientId:n,type:"point",fields:t})},[n,r,i]),selectInterval:(0,As.useCallback)(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"interval",range:r},o=!0;o&&i(r,{clientId:n,type:"interval",fields:t})},[n,r,i]),clear:(0,As.useCallback)(()=>{a(r,n)},[a,r,n]),clientId:n}}var Ws=l(require("react"));function $s(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Os(e,t){const{when:n}=e,r=t.width,o=t.height,i=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),a=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof n.minWidth&&n.minWidth>r||"number"==typeof n.maxWidth&&r>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof o||n.minHeight>o)||"number"==typeof n.maxHeight&&("number"!=typeof o||o>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof i||n.minAspectRatio>i)||"number"==typeof n.maxAspectRatio&&("number"!=typeof i||i>n.maxAspectRatio)||n.orientation&&a!==n.orientation)}function Bs(e,t,n=e.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:e,matches:[]};const r=n.map((e,t)=>({rule:e,index:t})).filter(e=>Os(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:r.reduce((e,t)=>function(e,t){const n={...e,...t};for(const r of["margin","frameProps","mobileSemantics","style"])$s(e[r])&&$s(t[r])&&(n[r]={...e[r],...t[r]});return"string"==typeof e.className&&"string"==typeof t.className&&(n.className=`${e.className} ${t.className}`),n}(e,t.rule.transform),e),matches:r}}require("react/jsx-runtime"),Ws.createContext(void 0);var zs=44,Hs={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:zs,snap:"nearestDatum",brushHandleSize:zs,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function Fs(e,t={}){const n=t.mobileSemantics?.interaction,r="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,o="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,i=!!n||void 0!==r,a=e&&"object"==typeof e?e:void 0;if(!1===e||!1===a?.enabled||void 0===e&&!o&&!i)return Hs;const s=a??{};return{enabled:!0,tapToSelect:s.tapToSelect??!0,tapToLockTooltip:s.tapToLockTooltip??!0,clearSelection:s.clearSelection??"backgroundTap",targetSize:s.targetSize??r??zs,snap:s.snap??"nearestDatum",brushHandleSize:s.brushHandleSize??zs,standardControls:s.standardControls??!1}}var qs={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}},Ys={top:10,bottom:10,left:10,right:10};function Gs(e){return e.compactMode?e.marginDefaults:Ys}function Xs(e,t,n){if(!1!==t)return e;const r={...e};return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}function Vs(e,t,n){const r=e.xValue??t?.[n];if(null==r)return null;const o=Number(r);return Number.isFinite(o)?o:null}function Us(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?{...t,xValue:e.xValue}:t||{}}function Ks(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}var Qs=require("react"),Zs=require("react"),Js=(require("react/jsx-runtime"),(0,Zs.createContext)(!1));(0,Zs.createContext)(!1);var el=(0,Zs.createContext)(null),tl="undefined"==typeof window?Zs.useEffect:Zs.useLayoutEffect;function nl({data:e,colorBy:t,colorScale:n,showLegend:r,legendPosition:o="right",userMargin:i,defaults:a={top:50,bottom:60,left:70,right:40},categories:s,additionalLegend:l,chartWidth:c,legendLayout:u,hasTitle:d=!1,axisChrome:h}){const f=(0,Zs.useContext)(Js),g=null!==(0,Zs.useContext)(el),y=void 0!==r?r:!f&&!!t,p=!!t&&(y||g),m=(0,Qs.useMemo)(()=>{if(!p)return[];if(void 0!==s)return s;const n=new Set;for(const r of e){const e="function"==typeof t?t(r):r[t];null!=e&&n.add(e+"")}return Array.from(n)},[s,t,e,p]);!function(e){const t=(0,Zs.useContext)(el),n=(0,Zs.useId)(),r=function(e){const t=new Set,n=[];for(const r of e)t.has(r)||(t.add(r),n.push(r));return n}(e),o=(0,Zs.useRef)([]);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(o.current,r)||(o.current=r);const i=o.current;tl(()=>{if(t)return()=>t.unregisterCategories(n)},[t,n]),tl(()=>{t&&t.registerCategories(n,i)},[t,n,i])}(g&&t?m:[]);const b=(0,Qs.useMemo)(()=>{if(!y||!t)return;const r=function({data:e,colorBy:t,colorScale:n,getColor:r,strokeColor:o,strokeWidth:i,categories:a}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==o&&(n.stroke=o),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:(a&&a.length>0?a:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((o,i)=>{const a=e.find("function"==typeof t?e=>t(e)===o:e=>e[t]===o),s=a?r(a,t,n):n?n(o):$t[i%$t.length];return{label:o+"",color:s}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:zt,categories:m});return 0!==r.legendGroups.reduce((e,t)=>e+t.items.length,0)?r:void 0},[y,t,e,n,m]),v=(0,Qs.useMemo)(()=>function(...e){let t;for(const n of e)n&&(t=Mr(t)&&Mr(n)?{legendGroups:[...t.legendGroups,...n.legendGroups],legendDistance:n.legendDistance??t.legendDistance}:n);return t}(b,l),[b,l]),{hasAxis:x,hasAxisLabel:k,rotatedTicks:w}=h??{},S=(0,Qs.useMemo)(()=>{const e="number"==typeof i?{top:i,bottom:i,left:i,right:i}:i??{},t=t=>{const n=e[t];return"number"==typeof n?n:a[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},r=t=>"number"==typeof e[t];if(v){const e=function(e,t){return Ir(e,t)+Nr(e)+Pr(t)}(v,u),t=void 0===x?{hasAxis:!0,hasAxisLabel:!0}:{hasAxis:x,hasAxisLabel:k,rotatedTicks:w},i=Br(v,Math.max(1,(c??600)-n.left-n.right),u)+Nr(v)+Or("bottom"===o?t:void 0,u)+("top"===o&&d?24:0);"right"===o&&!r("right")&&e>n.right?n.right=e:"left"===o&&!r("left")&&e>n.left?n.left=e:"top"!==o||r("top")?"bottom"!==o||r("bottom")||(n.bottom=Math.max(n.bottom,80,i)):n.top=Math.max(n.top,50,i)}return n},[a,i,v,o,c,u,d,x,k,w]);return{legend:v,margin:S,legendPosition:o}}var rl=[];function ol(){const e=or(e=>e.theme),t=e?.colors?.categorical;return t&&t.length>0?t:void 0}function il(e,t,n,r,o){if(e)return e;if(n&&"object"==typeof n&&!Array.isArray(n)){const e=Ht(n,r);if(e)return e}let i;if(Array.isArray(n))i=n;else if(t&&t.length>0)i=t;else if("string"==typeof n){const e=Nt[n];Array.isArray(e)&&(i=e)}return i&&0!==i.length?null!=r?(o.has(r)||o.set(r,o.size),i[o.get(r)%i.length]):i[0]:_t}function al({selection:e,linkedHover:t,fallbackFields:n=rl,unwrapData:r=!1,onObservation:o,chartType:i,chartId:a,onClick:s,hoverHighlight:l,colorByField:c,mobileInteraction:u}){const d=(0,ks.useId)(),h=(0,ks.useMemo)(()=>function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField,seriesField:e.seriesField}:null}(t,n),[t,n]),f=(0,ks.useMemo)(()=>"series"===h?.mode?[h.seriesField||c||n[0]].filter(e=>!!e):h?.fields||n,[h,c,n]),g=_s({name:e?.name||"__unused__",fields:f}),y=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:r,isActive:o,selectPoints:i,clear:a}=_s({name:t,fields:n});return{onHover:(0,As.useCallback)(e=>{if(!e)return void a();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1})(t)&&i(t)},[n,i,a]),predicate:r,isActive:o}}({name:h?.name||"hover",fields:f}),p=Lo(e=>e.pushObservation),m=(0,ks.useCallback)(e=>{o?.(e),p?.(e)},[o,p]),b=e?{isActive:g.isActive,predicate:g.predicate}:null,[v,x]=(0,ks.useState)(null),k=(0,ks.useRef)(!1),w=c||n[0],S=(0,ks.useMemo)(()=>{if(!l||null==v||!w)return null;const e=v,t=w;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[l,v,w]),M=(0,ks.useCallback)((e,n)=>{const r=!e&&k.current&&!!u?.enabled&&u.tapToLockTooltip;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===h?.mode&&h.xField){const n=Vs(e,t,h.xField);null!=n&&function(e,t,n){const r=Ds.positions.get(e);r?.locked||r&&r.xValue===t&&r.sourceId===n||(Ds={positions:new Map(Ds.positions).set(e,{xValue:t,sourceId:n})},Is())}(h.name||"hover",n,d)}"x-position"!==h?.mode&&y.onHover(t)}else"x-position"!==h?.mode||r||Ns(h.name||"hover",d),"x-position"===h?.mode||r||y.onHover(null);if(l&&w)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=t?.[w];x(null!=n?n+"":null)}else r||x(null);(o||p)&&ss({onObservation:m,datum:e?Us(e):null,x:e?.x,y:e?.y,chartType:i||"unknown",chartId:a,context:n})},[t,y,h,d,o,i,a,p,m,l,w,u]),A=(0,ks.useCallback)((n=!0)=>{k.current=!1,t&&"x-position"!==h?.mode&&y.onHover(null),e&&u?.tapToSelect&&g.clear(),n&&l&&x(null),"x-position"===h?.mode&&(Ps(h.name||"hover",d),Ns(h.name||"hover",d))},[t,h,y,e,u,g,l,d]),C=(0,ks.useCallback)((n,r)=>{const c=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),b=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===h?.mode&&h.xField&&n){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]);const t=Vs(n,e,h.xField);null!=t&&function(e,t,n){const r=Ds.positions.get(e);if(r?.locked){const t=new Map(Ds.positions);return t.delete(e),Ds={positions:t},Is(),!1}Ds={positions:new Map(Ds.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Is()}(h.name||"hover",t,d)}if(c)if(n){k.current=!0;const r=Us(n);if(t&&"x-position"!==h?.mode&&y.onHover(r),e&&u?.tapToSelect&&f.length>0){const e={};for(const t of f){const n=r[t];void 0!==n&&(e[t]=[n])}Ks(e)&&g.selectPoints(e)}if(l&&w){const e=r?.[w];x(null!=e?e+"":null)}}else b&&A();if(n||b){if(n&&s){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]),s(e,{x:n.x??0,y:n.y??0})}(o||p)&&ls({onObservation:m,datum:n?Us(n):null,x:n?.x,y:n?.y,chartType:i||"unknown",chartId:a,context:r})}},[s,o,p,m,i,a,h,d,u,t,y,e,g,f,l,w,A]);return(0,ks.useEffect)(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&k.current&&A()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,A]),(0,ks.useEffect)(()=>()=>{k.current&&A(!1)},[A]),(0,ks.useEffect)(()=>{if("x-position"!==h?.mode)return;const e=h.name||"hover";return()=>{Ps(e,d),Ns(e,d)}},[h?.mode,h?.name,d]),{activeSelectionHook:b,hoverSelectionHook:S,customHoverBehavior:M,customClickBehavior:C,crosshairSourceId:d}}function sl(e,t,n){return function(e,t,n){const r=qs[e||"primary"],o=e&&"primary"!==e||!n?.width?r.width:n.width,i=e&&"primary"!==e||!n?.height?r.height:n.height,a=Bs({...t,mode:e},{width:t.width??o,height:t.height??i}).props,s=a.mode||e||"primary",l=qs[s],c="context"===s||"sparkline"===s,u="primary"===s&&n?.width?n.width:l.width;return{mode:s,width:a.width??u,height:a.height??("primary"===s&&n?.height?n.height:l.height),showAxes:a.showAxes??l.showAxes,showGrid:a.showGrid??l.showGrid,enableHover:a.enableHover??(!!a.linkedHover||l.enableHover),showLegend:a.showLegend??l.showLegend,showLabels:a.showLabels??l.showLabels,title:c?void 0:a.title,description:a.description,summary:a.summary,accessibleTable:a.accessibleTable,xLabel:c?void 0:a.xLabel,yLabel:c?void 0:a.yLabel,categoryLabel:c?void 0:a.categoryLabel,valueLabel:c?void 0:a.valueLabel,marginDefaults:Xs(l.marginDefaults,a.showCategoryTicks,a.orientation),compactMode:c,mobileInteraction:Fs(a.mobileInteraction,{mode:s,width:a.width??u,mobileSemantics:a.mobileSemantics}),mobileSemantics:a.mobileSemantics}}(e,t,n)}var ll=require("react");function cl(e,t){if(!e)return[];const n=[],r=e=>{n.push(e);const o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(r)};return r(e),n}function ul(e,t,n,r){if(e&&e.length>0)return e;const o=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof r?r(e):e[r];o.add(t),o.add(i)}),Array.from(o).map(e=>({id:e}))}function dl(e){return"function"==typeof e?e:t=>t[e]||1}function hl({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:r,edgeOpacity:o,baseStyle:i={}}){return a=>{const s={fillOpacity:o,...i};if("function"==typeof e)s.fill=e(a);else if("source"===e){const e="object"==typeof a.source?a.source:null;t&&e?s.fill=zt(e.data||e,t,n):e&&(s.fill=r(e,e.index).fill)}else if("target"===e){const e="object"==typeof a.target?a.target:null;t&&e?s.fill=zt(e.data||e,t,n):e&&(s.fill=r(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*o);return s}}function fl(e){const{nodes:t,edges:n,inferNodes:r=!0,sourceAccessor:o="source",targetAccessor:i="target",colorBy:a,colorScheme:s,showLegend:l,legendPosition:c,legendInteraction:u,selection:d,linkedHover:h,onObservation:f,onClick:g,mobileInteraction:y,mobileSemantics:p,chartType:m,chartId:b,marginDefaults:v,userMargin:x,width:k,height:w,hasTitle:S,loading:M,loadingContent:A,emptyContent:C,emptyDataKey:L="edges"}=e,j=(0,ll.useMemo)(()=>ta(n),[n]),T=(0,ll.useMemo)(()=>ta(t),[t]),E=ja(M,k,w,A),D=E?null:La("nodes"===L?void 0===t?void 0:T:void 0===n?void 0:j,k,w,C),R=(0,ll.useMemo)(()=>r?ul(T,j,o,i):T,[r,T,j,o,i]),I=function(e,t,n){const r=(0,ws.useContext)(Ss),o=ol();return(0,ks.useMemo)(()=>{if(!t)return;const i=r??void 0,a=n??(o&&o.length>0?o:void 0)??"category10";if(0!==e.length){if("function"==typeof t){const n=Array.from(new Set(e.map(e=>t(e)+"")));if(i&&Ks(i)){const e=Ft(n.map(e=>({_cat:e})),"_cat",a);return t=>i[t]||e(t)}return Ft(n.map(e=>({_cat:e})),"_cat",a)}if(i&&Ks(i)){const n=Ft(e,t,a);return e=>i[e]||n(e)}return Ft(e,t,a)}if(i&&Ks(i)){const e=Ft([{_:"a"}],"_",a);return t=>i[t]||e(t)}},[e,t,n,r,o])}(R,a,s),N=ol(),P=(0,ll.useMemo)(()=>Array.isArray(s)&&s.length>0?s:[...Wt(s,N,Pt)],[s,N]),_=(0,ll.useMemo)(()=>{if(!a)return[];const e=new Set;for(const t of R){const n="function"==typeof a?a(t):t[a];null!=n&&e.add(n+"")}return Array.from(e)},[R,a]),W=function(e,t,n){const[r,o]=(0,Qs.useState)(null),[i,a]=(0,Qs.useState)(new Set),s=(0,Qs.useMemo)(()=>new Set,[]),l=(0,Qs.useCallback)(t=>{"highlight"===e&&o(t?t.label:null)},[e]),c=(0,Qs.useCallback)(t=>{"isolate"===e&&a(e=>{const r=new Set(e);return r.has(t.label)?r.delete(t.label):r.add(t.label),r.size===n.length?new Set:r})},[e,n.length]),u=(0,Qs.useMemo)(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=r?{isActive:!0,predicate:e=>(n?e[n]:"function"==typeof t?t(e):null)===r}:"isolate"===e&&i.size>0?{isActive:!0,predicate:e=>{const r=n?e[n]:"function"==typeof t?t(e):null;return i.has(r)}}:null},[e,t,r,i]);return{highlightedCategory:"highlight"===e?r:null,isolatedCategories:"isolate"===e?i:s,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}(u,a,_),{legend:$,margin:O,legendPosition:B}=nl({data:R,colorBy:a,colorScale:I,showLegend:l,legendPosition:c,userMargin:x,defaults:v,categories:_,chartWidth:k,hasTitle:S}),z=(0,ll.useMemo)(()=>Fs(y,{width:k,mobileSemantics:p}),[y,k,p]),H=al({selection:d,linkedHover:h,fallbackFields:a?["string"==typeof a?a:""]:[],unwrapData:!0,onObservation:f,onClick:g,mobileInteraction:z,chartType:m,chartId:b}),{customHoverBehavior:F,customClickBehavior:q,activeSelectionHook:Y,hoverSelectionHook:G,crosshairSourceId:X}=H;return{safeNodes:R,safeEdges:j,colorScale:I,effectivePalette:P,themeCategorical:N,allCategories:_,legendState:W,legend:$,margin:O,legendPosition:B,mobileInteraction:z,customHoverBehavior:F,customClickBehavior:q,activeSelectionHook:Y,hoverSelectionHook:G,crosshairSourceId:X,loadingEl:E,emptyEl:D}}function gl(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return e??((...e)=>({}));const n={};return void 0!==t.stroke&&(n.stroke=t.stroke),void 0!==t.strokeWidth&&(n.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(n.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...n}):(...e)=>({...n})}function yl(e){if(null==e)return()=>{};const t="function"==typeof e?e:t=>t[e];return e=>ml(t(e))}function pl(e,t){const n=yl(t??"value"),r=null==e?void 0:"function"==typeof e?e:t=>t[e];return e=>{const t=r?r(e):void 0;return{value:n(e),category:null==t?void 0:t+""}}}function ml(e){if("number"==typeof e)return Number.isFinite(e)?e:void 0;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}function bl(e,t,n){const r=null!=e.axis?n[e.axis]:null!=e.field?t[e.field]:n.value;if(void 0!==e.eq&&r!==e.eq)return!1;if(void 0!==e.ne&&r===e.ne)return!1;if(void 0!==e.in&&!e.in.includes(r))return!1;if(void 0===e.gt&&void 0===e.gte&&void 0===e.lt&&void 0===e.lte&&void 0===e.within&&void 0===e.outside)return!0;const o=ml(r);if(void 0===o)return!1;if(void 0!==e.gt&&e.gt>=o)return!1;if(void 0!==e.gte&&e.gte>o)return!1;if(void 0!==e.lt&&o>=e.lt)return!1;if(void 0!==e.lte&&o>e.lte)return!1;if(void 0!==e.within){const[t,n]=e.within;if(t>o||o>n)return!1}if(void 0!==e.outside){const[t,n]=e.outside;if(o>=t&&n>=o)return!1}return!0}function vl(e,t,n){const r=e.when;return void 0===r||!0===r||!1!==r&&("function"==typeof r?r(t,n):bl(r,t,n))}function xl(e,t,n){if(!t||0===t.length)return{};let r={};for(const o of t){if(!vl(o,e,n))continue;const t="function"==typeof o.style?o.style(e,n):o.style;t&&(r={...r,...t})}return r}function kl(e,t,n,r=e=>e){const o=e??(()=>({}));return t&&0!==t.length?(e,i)=>{const a=r(e),s={...o(e,i)};return Object.assign(s,xl(a,t,n(a,i))),s}:o}function wl(e,t){const n=e.length,r=t.length,o=Array(r+1);for(let e=0;r>=e;e++)o[e]=e;for(let i=1;n>=i;i++){let n=o[0];o[0]=i;for(let a=1;r>=a;a++){const r=o[a];o[a]=e[i-1]===t[a-1]?n:1+Math.min(n,o[a],o[a-1]),n=r}}return o[r]}function Sl(e,t){if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(function(e,t,n=3){let r,o=n+1;for(const n of t){const t=wl(e.toLowerCase(),n.toLowerCase());o>t&&(o=t,r=n)}return o>n?void 0:r}(e,t,3)??null)}function Ml(e){return` Or use a function: ${e}={d => d.myValue}.`}function Al({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function Cl({componentName:e,nodes:t,edges:n,nodesRequired:r=!1,edgesRequired:o=!0,accessors:i}){if(null==t&&null==n)return null;if(o&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(r&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(i&&t&&t.length>0){const n=(a=t,a.length>3?[a[0],a[Math.floor(a.length/2)],a[a.length-1]]:[...a]).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[r,o]of Object.entries(i))if(o&&"string"==typeof o&&!(o in n)){const n=Sl(o,t),i=n?` Try ${r}="${n}".`:"";return`${e}: ${r} "${o}" not found in node data. Available fields: ${t.join(", ")}.${i}`+Ml(r)}}}var a;return null}function Ll(e){const{title:t,description:n,summary:r,accessibleTable:o,className:i,animate:a,axisExtent:s,autoPlaceAnnotations:l}=e,c={};return t&&(c.title=t),n&&(c.description=n),r&&(c.summary=r),void 0!==o&&(c.accessibleTable=o),i&&(c.className=i),null!=a&&(c.animate=a),void 0!==s&&(c.axisExtent=s),void 0!==l&&(c.autoPlaceAnnotations=l),c}function jl(e){const{linkedHover:t,selection:n,onObservation:r,onClick:o,hoverRadius:i,hoverHighlight:a,forceHoverBehavior:s,forceClickBehavior:l,mobileInteraction:c,customHoverBehavior:u,customClickBehavior:d,linkedHoverInClickPredicate:h=!0}=e,f={};r&&(f.annotationObservationCallback=r);const g=c?.enabled?Math.max(i??30,Math.ceil((c.targetSize||44)/2),24):i;return(s||t||r||o||a)&&(f.customHoverBehavior=u),d&&(l||(h?r||o||t:r||o)||c?.enabled&&(c.tapToSelect||c.tapToLockTooltip)&&(t||a||n))&&(f.customClickBehavior=d),null!=g&&(f.hoverRadius=g),f}var Tl=require("react/jsx-runtime"),El=(0,xs.forwardRef)(function(e,t){const n=(0,xs.useRef)(null);vs(t,{variant:"network",frameRef:n});const r=sl(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLegend:e.showLegend,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{nodes:o,edges:i,margin:a,className:s,nodeIdAccessor:l,nodeIDAccessor:c,sourceAccessor:u="source",targetAccessor:d="target",nodeLabel:h,colorBy:f,colorScheme:g,styleRules:y,nodeSize:p=8,nodeSizeRange:m=[5,20],nodeStroke:b,nodeStrokeWidth:v,edgeWidth:x,edgeColor:k,edgeOpacity:w,iterations:S=300,forceStrength:M=.1,layoutExecution:A="auto",layoutLoadingContent:C,onLayoutStateChange:L,tooltip:j,frameProps:T={},onObservation:E,onClick:D,chartId:R,selection:I,linkedHover:N,loading:P,loadingContent:_,emptyContent:W,legendInteraction:$,legendPosition:O,stroke:B,strokeWidth:z,opacity:H}=e,F=l??c??"id",{width:q,height:Y,enableHover:G,showLegend:X,showLabels:V=!1,title:U,description:K,summary:Q,accessibleTable:Z}=r,J=fl({nodes:o,edges:i,inferNodes:!1,nodeIdAccessor:F,sourceAccessor:u,targetAccessor:d,colorBy:f,colorScheme:g,showLegend:X,legendPosition:O,legendInteraction:$,selection:I,linkedHover:N,onObservation:E,onClick:D,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"ForceDirectedGraph",chartId:R,marginDefaults:r.marginDefaults,userMargin:a,width:q,height:Y,hasTitle:!!U,loading:P,loadingContent:_,emptyContent:W,emptyDataKey:"nodes"}),ee=(0,xs.useMemo)(()=>new Map,[]),te=(0,xs.useMemo)(()=>e=>{const t={};return t.fill=f?zt(e.data||e,f,J.colorScale):il(void 0,J.themeCategorical,g,void 0,ee),"number"==typeof p&&(t.r=p),t},[f,J.colorScale,p,J.themeCategorical,g,ee]),ne=(0,xs.useMemo)(()=>pl(f,"number"==typeof p?void 0:p),[f,p]),re=(0,xs.useMemo)(()=>gl(kl(te,y,ne,e=>e.data||e),{stroke:b??B,strokeWidth:v??z,opacity:H}),[te,y,ne,b,B,v,z,H]),oe=k??B??"#999",ie=w??H??.6,ae=z??1,se=(0,xs.useMemo)(()=>e=>{const t=e.data||e;let n;if(void 0===x)n=ae;else if("number"==typeof x)n=x;else if("function"==typeof x)n=x(t);else{const e=t[x],r="number"==typeof e?e:Number(e);n=Number.isFinite(r)&&r>0?r:ae}return{stroke:oe,strokeWidth:n,opacity:ie}},[x,oe,ie,ae]),le=(0,xs.useMemo)(()=>{if(V&&h)return"function"==typeof h?h:e=>e.data?.[h]??e[h]??e.id},[V,h]),ce=Cl({componentName:"ForceDirectedGraph",nodes:o,edges:i,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:F}});return ce?(0,Tl.jsx)(xa,{componentName:"ForceDirectedGraph",message:ce,width:q,height:Y}):J.loadingEl?J.loadingEl:J.emptyEl?J.emptyEl:(0,Tl.jsx)(Ma,{componentName:"ForceDirectedGraph",width:q,height:Y,children:(0,Tl.jsx)(ms,{ref:n,chartType:"force",...null!=o&&{nodes:J.safeNodes},...null!=i&&{edges:J.safeEdges},size:[q,Y],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:J.margin,nodeIDAccessor:F,sourceAccessor:u,targetAccessor:d,iterations:S,forceStrength:M,layoutExecution:A,layoutLoadingContent:C,onLayoutStateChange:L,nodeStyle:re,edgeStyle:se,colorBy:f,colorScheme:J.effectivePalette,nodeSize:p,nodeSizeRange:m,nodeLabel:le,showLabels:V,enableHover:G,tooltipContent:!1===j?()=>null:zn(j)||void 0,...jl({linkedHover:N,selection:I,onObservation:E,onClick:D,mobileInteraction:J.mobileInteraction,customHoverBehavior:J.customHoverBehavior,customClickBehavior:J.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:J.legend,legendPosition:J.legendPosition,...$&&"none"!==$&&{legendHoverBehavior:J.legendState.onLegendHover,legendClickBehavior:J.legendState.onLegendClick,legendHighlightedCategory:J.legendState.highlightedCategory,legendIsolatedCategories:J.legendState.isolatedCategories},className:s,title:U,description:K,summary:Q,accessibleTable:Z,...null!=e.animate&&{animate:e.animate},...T})})});El.displayName="ForceDirectedGraph";var Dl=require("react"),Rl=require("d3-force"),Il=1e3;function Nl(e,t,n={}){const r=n.iterations??260,o=n.repulsion??5200,i=n.linkDistance??165,a=n.linkStrength??.045,s=n.centerStrength??.018,l=n.damping??.84,c=n.nodeRadius??12,u=n.nodePadding??3,d=n.inset??.06,h=function(e){let t=e>>>0;return function(){t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}(n.seed??1),f=new Map;for(const t of e)f.set(t.id,0);for(const e of t)f.set(e.source,(f.get(e.source)??0)+1),f.set(e.target,(f.get(e.target)??0)+1);const g=Il/2,y=e.map(e=>({id:e.id,data:e,x:200+600*h(),y:200+600*h()})),p=new Set(e.map(e=>e.id)),m=t.filter(e=>p.has(e.source)&&p.has(e.target)).map(e=>({source:e.source,target:e.target}));if(r>0){const e=(0,Rl.forceSimulation)(y).randomSource(h).alphaDecay(1-Math.pow(.001,1/r)).velocityDecay(Math.max(0,Math.min(1,1-l))).force("charge",(0,Rl.forceManyBody)().strength(e=>{const t=f.get(e.id)??0;return 2.5*-Math.sqrt(o)*Math.sqrt(t+1)})).force("collide",(0,Rl.forceCollide)(e=>(e=>"function"==typeof c?c(e.data):c)(e)+u).strength(.9).iterations(2)).force("center",(0,Rl.forceCenter)(g,g).strength(.8)).force("x",(0,Rl.forceX)(g).strength(s)).force("y",(0,Rl.forceY)(g).strength(s));m.length>0&&e.force("link",(0,Rl.forceLink)(m).id(e=>e.id).distance(i).strength(e=>{const t="string"==typeof e.target?e.target:e.target.id,n=Math.max(1,Math.min(f.get("string"==typeof e.source?e.source:e.source.id)??1,f.get(t)??1));return a/.045/n})),e.stop();for(let t=0;r>t;t+=1)e.tick()}let b=1/0,v=1/0,x=-1/0,k=-1/0;for(const e of y){const t=e.x??g,n=e.y??g;b>t&&(b=t),v>n&&(v=n),t>x&&(x=t),n>k&&(k=n)}const w=x-b,S=k-v,M={};for(const e of y)M[e.id]={x:0===w?.5:d+((e.x??g)-b)/w*(1-2*d),y:0===S?.5:d+((e.y??g)-v)/S*(1-2*d)};return M}var Pl=16,_l=new WeakMap;function Wl(e){const t=[];for(const n of Object.keys(e).sort()){const r=e[n];if(void 0!==r){if("function"==typeof r)return null;t.push(`${n}:${r+""}`)}}return t.join("|")}function $l(e,t,n){return null==n?null:_l.get(e)?.get(t)?.get(n)??null}function Ol(e,t,n,r){if(null==n)return;let o=_l.get(e);o||(o=new WeakMap,_l.set(e,o));let i=o.get(t);if(i||(i=new Map,o.set(t,i)),!i.has(n)&&i.size>=Pl){const e=i.keys().next().value;void 0!==e&&i.delete(e)}i.set(n,r)}function Bl(e,t,n={}){const r=ca(),{seed:o,iterations:i,repulsion:a,linkDistance:s,linkStrength:l,centerStrength:c,damping:u,nodeRadius:d,nodePadding:h,inset:f,execution:g,workerThreshold:y}=n,p=(0,Dl.useMemo)(()=>({seed:o,iterations:i,repulsion:a,linkDistance:s,linkStrength:l,centerStrength:c,damping:u,nodeRadius:d,nodePadding:h,inset:f,execution:g,workerThreshold:y}),[o,i,a,s,l,c,u,d,h,f,g,y]),m=(0,Dl.useRef)(r),[b,v]=(0,Dl.useState)(()=>{if("undefined"==typeof window||r){const n=Nl(e,t,p);return Ol(e,t,Wl(p),n),{positions:n,status:"ready",error:null}}const n=$l(e,t,Wl(p));return n?{positions:n,status:"ready",error:null}:{positions:null,status:"pending",error:null}});return(0,Dl.useEffect)(()=>{if(m.current)return void(m.current=!1);const n=Wl(p),r=$l(e,t,n);if(r)return void v(e=>"ready"===e.status&&e.positions===r?e:{positions:r,status:"ready",error:null});const o=new AbortController;return v(e=>({positions:e.positions,status:"pending",error:null})),async function(e,t,n={}){const{execution:r="auto",signal:o,workerThreshold:i,nodeRadius:a,...s}=n,l=s.iterations??260;if(!Ra()||!Da(r,e.length,t.length,l,i))return Nl(e,t,{...s,nodeRadius:a});const c={kind:"normalized",nodes:e.map(e=>({...e})),edges:t.map(e=>({...e})),options:s,nodeRadii:"function"==typeof a?Object.fromEntries(e.map(e=>[e.id,a(e)])):null==a?void 0:Object.fromEntries(e.map(e=>[e.id,a]))};try{return(await _a(c,o)).positions}catch(n){if("AbortError"===n?.name)throw n;return Nl(e,t,{...s,nodeRadius:a})}}(e,t,{...p,signal:o.signal}).then(r=>{Ol(e,t,n,r),v({positions:r,status:"ready",error:null})}).catch(e=>{"AbortError"!==e.name&&v(t=>({positions:t.positions,status:"error",error:e}))}),()=>o.abort()},[e,t,p]),b}var zl=require("react"),Hl=require("react/jsx-runtime"),Fl=(0,zl.forwardRef)(function(e,t){const n=(0,zl.useRef)(null);vs(t,{variant:"network",frameRef:n,overrides:{getData:()=>n.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const r=sl(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:800,height:600}),{nodes:o,edges:i,margin:a,className:s,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:h,colorScheme:f,styleRules:g,edgeColorBy:y="source",orientation:p="horizontal",nodeAlign:m="justify",nodePaddingRatio:b=.05,nodeWidth:v=15,nodeLabel:x,edgeOpacity:k=.5,edgeSort:w,tooltip:S,frameProps:M={},onObservation:A,onClick:C,chartId:L,selection:j,linkedHover:T,loading:E,loadingContent:D,emptyContent:R,showLegend:I,legendPosition:N,legendInteraction:P,stroke:_,strokeWidth:W,opacity:$}=e,{width:O,height:B,enableHover:z,showLabels:H=!0,title:F,description:q,summary:Y,accessibleTable:G}=r,X=fl({nodes:o,edges:i,inferNodes:!0,nodeIdAccessor:d,sourceAccessor:l,targetAccessor:c,colorBy:h,colorScheme:f,showLegend:I,legendPosition:N,legendInteraction:P,selection:j,linkedHover:T,onObservation:A,onClick:C,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"SankeyDiagram",chartId:L,marginDefaults:r.marginDefaults,userMargin:a,width:O,height:B,hasTitle:!!F,loading:E,loadingContent:D,emptyContent:R}),V=(0,zl.useMemo)(()=>new Map,[]),U=(0,zl.useMemo)(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?zt(e.data||e,h,X.colorScale):il(void 0,X.themeCategorical,f,void 0,V),t},[h,X.colorScale,X.themeCategorical,f,V]),K=(0,zl.useMemo)(()=>pl(h,u),[h,u]),Q=(0,zl.useMemo)(()=>gl(kl(U,g,K,e=>e.data||e),{stroke:_,strokeWidth:W,opacity:$}),[U,g,K,_,W,$]),Z=(0,zl.useMemo)(()=>hl({edgeColorBy:y,colorBy:h,colorScale:X.colorScale,nodeStyleFn:Q,edgeOpacity:k,baseStyle:{stroke:"none",strokeWidth:0}}),[y,h,X.colorScale,Q,k]),J=(0,zl.useMemo)(()=>gl(Z,{stroke:_,strokeWidth:W,opacity:$}),[Z,_,W,$]),ee=(0,zl.useMemo)(()=>{if(!H)return;const e=x||d;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[H,x,d]),te=Cl({componentName:"SankeyDiagram",edges:i,edgesRequired:!0});return te?(0,Hl.jsx)(xa,{componentName:"SankeyDiagram",message:te,width:O,height:B}):X.loadingEl?X.loadingEl:X.emptyEl?X.emptyEl:(0,Hl.jsx)(Ma,{componentName:"SankeyDiagram",width:O,height:B,children:(0,Hl.jsx)(ms,{ref:n,chartType:"sankey",...X.safeNodes.length>0&&{nodes:X.safeNodes},...null!=i&&{edges:X.safeEdges},size:[O,B],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:X.margin,nodeIDAccessor:d,sourceAccessor:l,targetAccessor:c,valueAccessor:u,orientation:p,nodeAlign:m,nodePaddingRatio:b,nodeWidth:v,nodeStyle:Q,edgeStyle:J,colorBy:h,colorScheme:X.effectivePalette,edgeColorBy:y,edgeOpacity:k,edgeSort:w,nodeLabel:ee,showLabels:H,enableHover:z,tooltipContent:!1===S?()=>null:zn(S)||void 0,...jl({linkedHover:T,selection:j,onObservation:A,onClick:C,mobileInteraction:X.mobileInteraction,customHoverBehavior:X.customHoverBehavior,customClickBehavior:X.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:X.legend,legendPosition:X.legendPosition,...P&&"none"!==P&&{legendHoverBehavior:X.legendState.onLegendHover,legendClickBehavior:X.legendState.onLegendClick,legendHighlightedCategory:X.legendState.highlightedCategory,legendIsolatedCategories:X.legendState.isolatedCategories},className:s,title:F,description:q,summary:Y,accessibleTable:G,...null!=e.animate&&{animate:e.animate},...M})})});Fl.displayName="SankeyDiagram";var ql=require("react"),Yl=require("react/jsx-runtime"),Gl=(0,ql.forwardRef)(function(e,t){const n=(0,ql.useRef)(null);vs(t,{variant:"network",frameRef:n,overrides:{getData:()=>n.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const r=sl(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{nodes:o,edges:i,margin:a,className:s,sourceAccessor:l="source",targetAccessor:c="target",valueAccessor:u="value",nodeIdAccessor:d="id",colorBy:h,colorScheme:f,styleRules:g,edgeColorBy:y="source",padAngle:p=.01,groupWidth:m=20,sortGroups:b,nodeLabel:v,edgeOpacity:x=.5,tooltip:k,frameProps:w={},onObservation:S,onClick:M,chartId:A,selection:C,linkedHover:L,loading:j,loadingContent:T,emptyContent:E,legendInteraction:D,stroke:R,strokeWidth:I,opacity:N}=e,{width:P,height:_,enableHover:W,showLabels:$=!0,title:O,description:B,summary:z,accessibleTable:H}=r,F=fl({nodes:o,edges:i,inferNodes:!0,nodeIdAccessor:d,sourceAccessor:l,targetAccessor:c,colorBy:h,colorScheme:f,showLegend:!1,legendInteraction:D,selection:C,linkedHover:L,onObservation:S,onClick:M,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"ChordDiagram",chartId:A,marginDefaults:r.marginDefaults,userMargin:a,width:P,height:_,hasTitle:!!O,loading:j,loadingContent:T,emptyContent:E}),q=(0,ql.useMemo)(()=>new Map,[]),Y=(0,ql.useMemo)(()=>new Map,[]),G=F.safeNodes.length>0,X=(0,ql.useMemo)(()=>{if(G)return(e,t)=>{const n={stroke:"black",strokeWidth:1};if(h)n.fill=zt(e.data||e,h,F.colorScale);else{const r=Array.isArray(f)?f:Nt[f]||Pt,o=Array.isArray(r)?r:Pt,i=(e.id??e.data?.[d]??"")+"";Y.has(i)||Y.set(i,Y.size);const a=e.index??t??Y.get(i);n.fill=o[a%o.length]}return n}},[G,h,F.colorScale,f,d,Y]),V=(0,ql.useMemo)(()=>pl(h),[h]),U=(0,ql.useMemo)(()=>{if(X||g&&g.length>0)return gl(kl(X,g,V,e=>e.data||e),{stroke:R,strokeWidth:I,opacity:N})},[X,g,V,R,I,N]),K=(0,ql.useMemo)(()=>{if(G)return hl({edgeColorBy:y,colorBy:h,colorScale:F.colorScale,nodeStyleFn:U||(e=>({fill:il(void 0,F.themeCategorical,f,void 0,q)})),edgeOpacity:x,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:x}})},[G,y,h,F.colorScale,U,x,F.themeCategorical,f,q]),Q=(0,ql.useMemo)(()=>K?gl(K,{stroke:R,strokeWidth:I,opacity:N}):void 0,[K,R,I,N]),Z=(0,ql.useMemo)(()=>{if(!$)return;const e=v||d;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[$,v,d]),J=Cl({componentName:"ChordDiagram",edges:i,edgesRequired:!0});return J?(0,Yl.jsx)(xa,{componentName:"ChordDiagram",message:J,width:P,height:_}):F.loadingEl?F.loadingEl:F.emptyEl?F.emptyEl:(0,Yl.jsx)(Ma,{componentName:"ChordDiagram",width:P,height:_,children:(0,Yl.jsx)(ms,{ref:n,chartType:"chord",...F.safeNodes.length>0&&{nodes:F.safeNodes},...null!=i&&{edges:F.safeEdges},size:[P,_],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:F.margin,nodeIDAccessor:d,sourceAccessor:l,targetAccessor:c,valueAccessor:u,padAngle:p,groupWidth:m,sortGroups:b,nodeStyle:U,edgeStyle:Q,colorBy:h,colorScheme:F.effectivePalette,edgeColorBy:y,edgeOpacity:x,nodeLabel:Z,showLabels:$,enableHover:W,tooltipContent:!1===k?()=>null:zn(k)||void 0,...jl({linkedHover:L,selection:C,onObservation:S,onClick:M,mobileInteraction:F.mobileInteraction,customHoverBehavior:F.customHoverBehavior,customClickBehavior:F.customClickBehavior,linkedHoverInClickPredicate:!1}),...D&&"none"!==D&&{legendHoverBehavior:F.legendState.onLegendHover,legendClickBehavior:F.legendState.onLegendClick,legendHighlightedCategory:F.legendState.highlightedCategory,legendIsolatedCategories:F.legendState.isolatedCategories},className:s,title:O,description:B,summary:z,accessibleTable:H,...null!=e.animate&&{animate:e.animate},...w})})});Gl.displayName="ChordDiagram";var Xl=require("react"),Vl=require("react/jsx-runtime");function Ul(e){const t=sl(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:r,className:o,layout:i="tree",orientation:a="vertical",childrenAccessor:s="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,colorByDepth:h=!1,edgeStyle:f="curve",nodeLabel:g,nodeSize:y=5,tooltip:p,frameProps:m={},onObservation:b,onClick:v,chartId:x,selection:k,linkedHover:w,loading:S,loadingContent:M,legendInteraction:A,stroke:C,strokeWidth:L,opacity:j}=e,{width:T,height:E,enableHover:D,showLabels:R=!0,title:I,description:N,summary:P,accessibleTable:_}=t,W=fl({nodes:(0,Xl.useMemo)(()=>cl(n??null,s),[n,s]),edges:void 0,inferNodes:!1,colorBy:h?void 0:u,colorScheme:d,showLegend:!1,legendInteraction:A,selection:k,linkedHover:w,onObservation:b,onClick:v,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"TreeDiagram",chartId:x,marginDefaults:t.marginDefaults,userMargin:r,width:T,height:E,hasTitle:!!I,loading:S,loadingContent:M}),$=(0,Xl.useMemo)(()=>new Map,[]),O=(0,Xl.useMemo)(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=h?Ot[(e.depth||0)%Ot.length]:u?zt(e.data||e,u,W.colorScale):il(void 0,W.themeCategorical,d,void 0,$),t},[u,h,W.colorScale,W.themeCategorical,d,$]),B=(0,Xl.useMemo)(()=>gl(O,{stroke:C,strokeWidth:L,opacity:j}),[O,C,L,j]),z=(0,Xl.useMemo)(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),H=(0,Xl.useMemo)(()=>gl(z,{stroke:C,strokeWidth:L,opacity:j}),[z,C,L,j]),F=(0,Xl.useMemo)(()=>{if("treemap"===i||"circlepack"===i||"partition"===i)return dl(l)},[i,l]),q=Al({componentName:"TreeDiagram",data:n});return q?(0,Vl.jsx)(xa,{componentName:"TreeDiagram",message:q,width:T,height:E}):W.loadingEl?W.loadingEl:(0,Vl.jsx)(Ma,{componentName:"TreeDiagram",width:T,height:E,children:(0,Vl.jsx)(ms,{chartType:i,...null!=n&&{data:n},size:[T,E],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:W.margin,nodeIDAccessor:c,childrenAccessor:s,hierarchySum:F,treeOrientation:a,edgeType:f,nodeStyle:B,edgeStyle:H,colorBy:u,colorScheme:W.effectivePalette,colorByDepth:h,nodeSize:y,nodeLabel:R?g||c:void 0,showLabels:R,enableHover:D,tooltipContent:!1===p?()=>null:zn(p)||void 0,...jl({linkedHover:w,selection:k,onObservation:b,onClick:v,mobileInteraction:W.mobileInteraction,customHoverBehavior:W.customHoverBehavior,customClickBehavior:W.customClickBehavior,linkedHoverInClickPredicate:!1}),...A&&"none"!==A&&{legendHoverBehavior:W.legendState.onLegendHover,legendClickBehavior:W.legendState.onLegendClick,legendHighlightedCategory:W.legendState.highlightedCategory,legendIsolatedCategories:W.legendState.isolatedCategories},className:o,title:I,description:N,summary:P,accessibleTable:_,...null!=e.animate&&{animate:e.animate},...m})})}Ul.displayName="TreeDiagram";var Kl=require("react"),Ql=require("react"),Zl=require("react/jsx-runtime");function Jl(e){const t=sl(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,linkedHover:e.linkedHover,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:r,className:o,childrenAccessor:i="children",valueAccessor:a="value",nodeIdAccessor:s="name",colorBy:l,colorScheme:c,colorByDepth:u=!1,labelMode:d="leaf",nodeLabel:h,padding:f=4,paddingTop:g,nodeStyle:y,tooltip:p,frameProps:m={},selection:b,linkedHover:v,onObservation:x,onClick:k,chartId:w,loading:S,loadingContent:M,legendInteraction:A,stroke:C,strokeWidth:L,opacity:j}=e,{nodeStyle:T,...E}=m,{width:D,height:R,enableHover:I,showLabels:N=!0,title:P,description:_,summary:W,accessibleTable:$}=t,O=fl({nodes:(0,Kl.useMemo)(()=>cl(n??null,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:u?void 0:l,colorScheme:c,showLegend:!1,legendInteraction:A,selection:b,linkedHover:v,onObservation:x,onClick:k,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"Treemap",chartId:w,marginDefaults:t.marginDefaults,userMargin:r,width:D,height:R,hasTitle:!!P,loading:S,loadingContent:M}),B=function(e){const t=or(e=>e.theme.colors.selectionOpacity);return(0,Ql.useMemo)(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}(b),z=O.customHoverBehavior,H=(0,Kl.useCallback)(e=>{if(!e)return z(null);const t=e.data||e;z({data:t?.data||t})},[z]),F=(0,Kl.useMemo)(()=>new Map,[]),q=(0,Kl.useMemo)(()=>e=>{const t={stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8};return t.fill=u?Ot[(e.depth||0)%Ot.length]:l?zt(e.data||e,l,O.colorScale):il(void 0,O.themeCategorical,c,void 0,F),t},[l,u,O.colorScale,O.themeCategorical,c,F]),Y=(0,Kl.useMemo)(()=>y||T?e=>({...q(e),...T?T(e)??{}:{},...y?y(e)??{}:{}}):q,[q,y,T]),G=(0,Kl.useMemo)(()=>gl(Y,{stroke:C,strokeWidth:L,opacity:j}),[Y,C,L,j]),X=(0,Kl.useMemo)(()=>O.activeSelectionHook?e=>{const t={...G(e)};if(O.activeSelectionHook.isActive)if(O.activeSelectionHook.predicate(e.data||e))B?.selectedStyle&&Object.assign(t,B.selectedStyle);else{const e=B?.unselectedOpacity??Ms;t.opacity=e,t.fillOpacity=e,t.strokeOpacity=e,B?.unselectedStyle&&Object.assign(t,B.unselectedStyle)}return t}:G,[G,O.activeSelectionHook,B]),V=(0,Kl.useMemo)(()=>dl(a),[a]),U=void 0!==g?g:!N||"parent"!==d&&"all"!==d?void 0:18,K=Al({componentName:"Treemap",data:n});return K?(0,Zl.jsx)(xa,{componentName:"Treemap",message:K,width:D,height:R}):O.loadingEl?O.loadingEl:(0,Zl.jsx)(Ma,{componentName:"Treemap",width:D,height:R,children:(0,Zl.jsx)(ms,{chartType:"treemap",...null!=n&&{data:n},size:[D,R],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:O.margin,nodeIDAccessor:s,childrenAccessor:i,hierarchySum:V,padding:f,paddingTop:U,nodeStyle:X,colorBy:l,colorScheme:O.effectivePalette,colorByDepth:u,nodeLabel:N?h||s:void 0,showLabels:N,labelMode:d,enableHover:I,tooltipContent:!1===p?()=>null:zn(p)||void 0,...jl({linkedHover:v,selection:b,onObservation:x,onClick:k,mobileInteraction:O.mobileInteraction,customHoverBehavior:H,customClickBehavior:O.customClickBehavior,linkedHoverInClickPredicate:!1}),...A&&"none"!==A&&{legendHoverBehavior:O.legendState.onLegendHover,legendClickBehavior:O.legendState.onLegendClick,legendHighlightedCategory:O.legendState.highlightedCategory,legendIsolatedCategories:O.legendState.isolatedCategories},className:o,title:P,description:_,summary:W,accessibleTable:$,...null!=e.animate&&{animate:e.animate},...E})})}Jl.displayName="Treemap";var ec=require("react"),tc=require("react/jsx-runtime");function nc(e){const t=sl(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:r,className:o,childrenAccessor:i="children",valueAccessor:a="value",nodeIdAccessor:s="name",colorBy:l,colorScheme:c,colorByDepth:u=!1,nodeLabel:d,circleOpacity:h=.7,padding:f=4,tooltip:g,frameProps:y={},onObservation:p,onClick:m,chartId:b,selection:v,linkedHover:x,loading:k,loadingContent:w,legendInteraction:S,stroke:M,strokeWidth:A,opacity:C}=e,{width:L,height:j,enableHover:T,showLabels:E=!0,title:D,description:R,summary:I,accessibleTable:N}=t,P=fl({nodes:(0,ec.useMemo)(()=>cl(n??null,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:u?void 0:l,colorScheme:c,showLegend:!1,legendInteraction:S,selection:v,linkedHover:x,onObservation:p,onClick:m,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"CirclePack",chartId:b,marginDefaults:t.marginDefaults,userMargin:r,width:L,height:j,hasTitle:!!D,loading:k,loadingContent:w}),_=(0,ec.useMemo)(()=>new Map,[]),W=(0,ec.useMemo)(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:h};return t.fill=u?Ot[(e.depth||0)%Ot.length]:l?zt(e.data||e,l,P.colorScale):il(void 0,P.themeCategorical,c,void 0,_),t},[l,u,P.colorScale,h,P.themeCategorical,c,_]),$=(0,ec.useMemo)(()=>gl(W,{stroke:M,strokeWidth:A,opacity:C}),[W,M,A,C]),O=(0,ec.useMemo)(()=>dl(a),[a]),B=Al({componentName:"CirclePack",data:n});return B?(0,tc.jsx)(xa,{componentName:"CirclePack",message:B,width:L,height:j}):P.loadingEl?P.loadingEl:(0,tc.jsx)(Ma,{componentName:"CirclePack",width:L,height:j,children:(0,tc.jsx)(ms,{chartType:"circlepack",...null!=n&&{data:n},size:[L,j],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:P.margin,nodeIDAccessor:s,childrenAccessor:i,hierarchySum:O,padding:f,nodeStyle:$,colorBy:l,colorScheme:P.effectivePalette,colorByDepth:u,nodeLabel:E?d||s:void 0,showLabels:E,enableHover:T,tooltipContent:!1===g?()=>null:zn(g)||void 0,...jl({linkedHover:x,selection:v,onObservation:p,onClick:m,mobileInteraction:P.mobileInteraction,customHoverBehavior:P.customHoverBehavior,customClickBehavior:P.customClickBehavior,linkedHoverInClickPredicate:!1}),...S&&"none"!==S&&{legendHoverBehavior:P.legendState.onLegendHover,legendClickBehavior:P.legendState.onLegendClick,legendHighlightedCategory:P.legendState.highlightedCategory,legendIsolatedCategories:P.legendState.isolatedCategories},className:o,title:D,description:R,summary:I,accessibleTable:N,...null!=e.animate&&{animate:e.animate},...y})})}nc.displayName="CirclePack";var rc=require("react"),oc=require("react/jsx-runtime"),ic=Ot;function ac(e){const t=sl(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:n,margin:r,className:o,childrenAccessor:i="children",nodeIdAccessor:a="name",colorBy:s,colorScheme:l,colorByDepth:c=!1,orbitMode:u="flat",orbitSize:d=2.95,speed:h=.25,revolution:f,revolutionStyle:g,eccentricity:y=1,showRings:p=!0,nodeRadius:m=6,showLabels:b=!1,animated:v=!0,tooltip:x,foregroundGraphics:k,annotations:w,frameProps:S={},onObservation:M,onClick:A,chartId:C,selection:L,linkedHover:j,loading:T,loadingContent:E,stroke:D,strokeWidth:R,opacity:I}=e,{width:N,height:P,enableHover:_,title:W,description:$,summary:O,accessibleTable:B}=t,z=fl({nodes:(0,rc.useMemo)(()=>cl(n,i),[n,i]),edges:void 0,inferNodes:!1,colorBy:c?void 0:s,colorScheme:l,showLegend:!1,legendInteraction:void 0,selection:L,linkedHover:j,onObservation:M,onClick:A,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,chartType:"OrbitDiagram",chartId:C,marginDefaults:Gs(t),userMargin:r,width:N,height:P,hasTitle:!!W,loading:T,loadingContent:E}),H=(0,rc.useMemo)(()=>new Map,[]),{colorScale:F,customClickBehavior:q,customHoverBehavior:Y,themeCategorical:G}=z,X=(0,rc.useMemo)(()=>{if(Array.isArray(l))return l;const e=Nt[l];return Array.isArray(e)?e:Pt},[l]),V=(0,rc.useMemo)(()=>e=>{const t={stroke:"#fff",strokeWidth:1},n=0===(e.depth??0);return t.fill=c?n?X[0]:ic[(e.depth||0)%ic.length]:s?zt(e.data||e,s,F):il(void 0,G,l,void 0,H),t.opacity=n?1:.85,t},[s,c,F,X,G,l,H]),U=(0,rc.useMemo)(()=>gl(V,{stroke:D,strokeWidth:R,opacity:I}),[V,D,R,I]),K=(0,rc.useMemo)(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),Q=(0,rc.useMemo)(()=>e=>{Y(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[Y]),Z=(0,rc.useMemo)(()=>e=>{q(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[q]),J=Al({componentName:"OrbitDiagram",data:n});return J?(0,oc.jsx)(xa,{componentName:"OrbitDiagram",message:J,width:N,height:P}):z.loadingEl?z.loadingEl:(0,oc.jsx)(Ma,{componentName:"OrbitDiagram",width:N,height:P,children:(0,oc.jsx)(ms,{chartType:"orbit",...null!=n&&{data:n},size:[N,P],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:z.margin,nodeIDAccessor:a,childrenAccessor:i,nodeStyle:U,edgeStyle:K,colorBy:s,colorScheme:z.effectivePalette,colorByDepth:c,nodeSize:m,nodeLabel:b?a:void 0,showLabels:b,enableHover:!v&&_,tooltipContent:v?void 0:!1===x?()=>null:zn(x)||void 0,...jl({linkedHover:j,selection:L,onObservation:M,onClick:A,mobileInteraction:z.mobileInteraction,customHoverBehavior:Q,customClickBehavior:Z,linkedHoverInClickPredicate:!1}),foregroundGraphics:k,annotations:w,className:o,title:W,description:$,summary:O,orbitMode:u,orbitSize:d,orbitSpeed:h,orbitRevolution:f,orbitRevolutionStyle:g,orbitEccentricity:y,orbitShowRings:p,orbitAnimated:v,accessibleTable:B,...null!=e.animate&&{animate:e.animate},...S})})}ac.displayName="OrbitDiagram";var sc=require("react"),lc=require("d3-scale"),cc=require("react");function uc(e,t,n){const r=[],o=new Set(e.map(e=>e.id)),i=Array.isArray(n)&&2===n.length,a=i&&Number.isFinite(n[0])&&Number.isFinite(n[1]);i&&a&&a&&n[1]>=n[0]||r.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||r.push({kind:"invalid-node-time",id:t.id}));for(const e of t)o.has(e.source)||r.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),o.has(e.target)||r.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||r.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||r.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):r.push({kind:"invalid-edge-time",id:e.id});return r}function dc(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:e.kind}function hc(e,t,n){const r=t.incoming[e.id],o=t.outgoing[e.id],i=[];for(const e of r)i.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:n.get(e.id).targetSide});for(const e of o)i.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:n.get(e.id).sourceSide});const a={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},s=()=>{i.sort((e,t)=>e.time-t.time||(a[e.kind]??99)-(a[t.kind]??99))},l=i.length?function(e,t=1/0){let n=t;for(const t of e)n>t&&(n=t);return n}(i.map(e=>e.time)):null,c=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,u=null!=c?c-1:null!=l&&Number.isFinite(l)?l-1:null,d=[...new Set(i.map(e=>e.time))].sort((e,t)=>e-t),h=new Map;for(let e=1;d.length>e;e++)h.set(d[e],d[e-1]);const f=e=>{const t=h.get(e);return null!=t?(t+e)/2:null!=u?u:e};s();const g=[];let y=0,p=0;for(const e of i)if("out"===e.kind){const t=Math.abs(e.delta);let n=t-("top"===e.side?y:p);if(n>0){const t="top"===e.side?"bot":"top",r=Math.min(n,"top"===t?y:p);if(r>0){const o=f(e.time);g.push({time:o,delta:-r,kind:"transfer-out",side:t}),g.push({time:o,delta:+r,kind:"transfer-in",side:e.side}),"top"===t?y-=r:p-=r,"top"===e.side?y+=r:p+=r,n-=r}n>0&&null!==u&&(g.push({time:u,delta:+n,kind:"create",side:e.side}),"top"===e.side?y+=n:p+=n)}"top"===e.side?y-=t:p-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?y+=t:p+=t}i.push(...g),s();let m=0,b=0,v=0,x=0,k=0;const w=[],S=new Map;for(const e of i){if(w.push({t:e.time,topMass:m,botMass:b}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?m:b;S.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta)})}"top"===e.side?m+=e.delta:b+=e.delta,m+b>v&&(v=m+b),m>x&&(x=m),b>k&&(k=b),w.push({t:e.time,topMass:m,botMass:b})}const M=[];let A=0;for(;w.length>A;){let e=A;for(;w.length>e+1&&w[e+1].t===w[A].t;)e++;M.push(w[A]);for(let t=A+1;e>=t;t++){const e=M[M.length-1];w[t].topMass===e.topMass&&w[t].botMass===e.botMass||M.push(w[t])}A=e+1}const C=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let L=null;for(const e of o)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===L||L>e.systemInTime)&&(L=e.systemInTime);let j=null;for(const e of r)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===j||e.systemOutTime>j)&&(j=e.systemOutTime);if(M.length>0){const e=M[M.length-1],t=Math.max(null!=C?C:-1/0,null!=j?j:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&M.push({t:t,topMass:e.topMass,botMass:e.botMass});const n=M[0],r=Math.min(null!=c?c:1/0,null!=L?L:1/0);Number.isFinite(r)&&n.t>r&&n.topMass+n.botMass>0&&M.unshift({t:r,topMass:n.topMass,botMass:n.botMass})}return{samples:M,peak:v,topPeak:x,botPeak:k,localAttachments:S}}function fc(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function gc(e,t){return e.map(e=>({t:fc(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function yc(e,t,n){const r=e.value*n;if("out"===e.kind){const o=e.sideMassBefore*n;if("top"===e.side){const e=t-o;return[e,e+r]}const i=t+o;return[i-r,i]}const o=e.sideMassAfter*n;if("top"===e.side){const e=t-o;return[e,e+r]}const i=t+o;return[i-r,i]}function pc(e,t){let n=0;for(let r=0;t.length>r;r++)for(let o=r+1;t.length>o;o++){const i=t[r],a=t[o];i.source!==a.source&&i.target!==a.target&&i.source!==a.target&&i.target!==a.source&&(Math.min(i.endTime,a.endTime)>Math.max(i.startTime,a.startTime)&&e[a.source]>e[i.source]!=e[a.target]>e[i.target]&&n++)}return n}function mc(e,t){let n=0;for(const r of t)n+=Math.abs(e[r.source]-e[r.target])*(r.value||1);return n}function bc(e,t){return 1e3*pc(e,t)+mc(e,t)}function vc(e,t){return{slots:e.map(e=>({peak:{...e.peak},occupants:e.occupants.slice()})),map:{...t}}}function xc(e,t,n){e.length>8||n.length>40?(function(e,t,n,r=6){const o=e.length;if(1>=o)return;let i=vc(e,t),a=bc(t,n);for(let s=0;r>s;s++){const r=Array(o).fill(0),s=Array(o).fill(0);for(const e of n){const n=t[e.source],o=t[e.target];r[n]+=o*(e.value||1),s[n]+=e.value||1,r[o]+=n*(e.value||1),s[o]+=e.value||1}const l=Array.from({length:o},(e,t)=>t).sort((e,t)=>(s[e]>0?r[e]/s[e]:e)-(s[t]>0?r[t]/s[t]:t)),c=l.map(t=>e[t]),u=new Map;l.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of c)e.push(t);const d=bc(t,n);if(a>d)a=d,i=vc(e,t);else if(d===a)break}!function(e,t,n){e.length=0;for(const t of n.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(n.map))t[e]=n.map[e]}(e,t,i)}(e,t,n,6),function(e,t,n,r=6){const o=e.length;if(1>=o)return;let i=bc(t,n);for(let a=0;r>a;a++){let r=!1;for(let a=0;o-1>a;a++){const o=e[a];e[a]=e[a+1],e[a+1]=o;for(const e of Object.keys(t))t[e]===a?t[e]=a+1:t[e]===a+1&&(t[e]=a);const s=bc(t,n);if(i>s)i=s,r=!0;else{const n=e[a];e[a]=e[a+1],e[a+1]=n;for(const e of Object.keys(t))t[e]===a?t[e]=a+1:t[e]===a+1&&(t[e]=a)}}if(!r)break}}(e,t,n,6)):function(e,t,n){const r=e.length;if(1>=r)return;const o={...t},i=Object.keys(o),a=Array.from({length:r},(e,t)=>t),s=a.slice(),l={...o};let c=a.slice(),u=1/0;const d=()=>{for(const e of i)l[e]=s[o[e]];const e=bc(l,n);u>e&&(u=e,c=a.slice())},h=(e,t)=>{const n=a[e],r=a[t];a[e]=r,a[t]=n,s[n]=t,s[r]=e};d();const f=Array(r).fill(0);let g=0;for(;r>g;)g>f[g]?(h(g%2==0?0:f[g],g),d(),f[g]++,g=0):(f[g]=0,g++);const y=c.map(t=>e[t]),p=new Map;c.forEach((e,t)=>p.set(e,t));for(const e of Object.keys(t))t[e]=p.get(t[e]);e.length=0;for(const t of y)e.push(t)}(e,t,n)}function kc(e,t,n,r,o){const{plotH:i,padding:a,valueScale:s,packing:l,laneOrder:c,lifetimeMode:u="full"}=o,d={},h={};for(const t of e)d[t.id]=n[t.id].topPeak||0,h[t.id]=n[t.id].botPeak||0;const f="half"===u,g={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,n=Array.isArray(t.xExtent)?t.xExtent[1]:null;let o=null!=e&&Number.isFinite(e)?e:1/0,i=null!=n&&Number.isFinite(n)?n:-1/0;for(const e of r.outgoing[t.id]){o>e.startTime&&(o=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&o>e.systemInTime&&(o=e.systemInTime);const t=f?(e.startTime+e.endTime)/2:e.endTime;t>i&&(i=t)}for(const e of r.incoming[t.id]){const t=f?(e.startTime+e.endTime)/2:e.startTime;o>t&&(o=t),e.endTime>i&&(i=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>i&&(i=e.systemOutTime)}g[t.id]={start:Number.isFinite(o)?o:null,end:Number.isFinite(i)?i:null}}const y={},p=[];if("reuse"===l){const n=new Map;for(const t of e)n.set(t.id,0);const o=new Map;for(const t of e)o.set(t.id,0);for(const e of t)o.set(e.target,(o.get(e.target)??0)+1);const i=[];for(const t of e)0===(o.get(t.id)??0)&&i.push(t.id);for(;i.length;){const e=i.shift();for(const t of r.outgoing[e]??[]){const r=(n.get(e)??0)+1;r>(n.get(t.target)??0)&&n.set(t.target,r),o.set(t.target,o.get(t.target)-1),0===o.get(t.target)&&i.push(t.target)}}const a=[...e].filter(e=>null!==g[e.id].start).sort((e,t)=>{const r=n.get(e.id)??0,o=n.get(t.id)??0;return r!==o?r-o:g[e.id].start-g[t.id].start}),s=e.filter(e=>null===g[e.id].start);for(const e of[...a,...s]){const t=g[e.id];let n=-1;for(let e=0;p.length>e;e++){const r=p[e].occupants[p[e].occupants.length-1];if(null===t.start||void 0===r||t.start>=r.end){n=e;break}}-1===n&&(p.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=p.length-1),p[n].occupants.push({id:e.id,end:t?.end??-1/0}),p[n].peak.topPeak=Math.max(p[n].peak.topPeak,d[e.id]),p[n].peak.botPeak=Math.max(p[n].peak.botPeak,h[e.id]),y[e.id]=n}}else e.forEach((e,t)=>{p.push({occupants:[{id:e.id,end:g[e.id]?.end??-1/0}],peak:{topPeak:d[e.id],botPeak:h[e.id]}}),y[e.id]=t});let m=null,b=null,v=null,x=null;const k=()=>{m=pc(y,t),v=mc(y,t)},w=()=>{b=pc(y,t),x=mc(y,t)};"crossing-min"===c?(k(),xc(p,y,t),w()):"inside-out"===c?(k(),function(e,t){const n=e.length;if(1>=n)return;const r=e=>e.peak.topPeak+e.peak.botPeak,o=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>r(t.slot)-r(e.slot)),i=Array(n),a=Math.floor((n-1)/2);i[a]=o[0].idx;let s=a-1,l=a+1;for(let e=1;o.length>e;e++)e%2==1&&n>l||0>s?i[l++]=o[e].idx:i[s--]=o[e].idx;const c=i.map(t=>e[t]),u=new Map;i.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of c)e.push(t)}(p,y),w()):"crossing-min+inside-out"===c&&(k(),xc(p,y,t),function(e,t,n){const r=e.length;if(1>=r)return;const o=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),i=Math.floor((r-1)/2);let a=bc(t,n);for(const{slot:s}of o){const o=e.indexOf(s);if(0>o)continue;const l=i;if(o===l)continue;const c=e[o];e.splice(o,1),e.splice(l,0,c);const u=new Map;for(let e=0;r>e;e++)u.set(e,e);if(l>o){for(let e=o+1;l>=e;e++)u.set(e,e-1);u.set(o,l)}else{for(let e=l;o>e;e++)u.set(e,e+1);u.set(o,l)}for(const e of Object.keys(t))t[e]=u.get(t[e]);const d=bc(t,n);if(d>a){const n=e[l];e.splice(l,1),e.splice(o,0,n);const i=new Map;for(let e=0;r>e;e++)i.set(e,e);if(o>l){for(let e=l+1;o>=e;e++)i.set(e,e-1);i.set(l,o)}else{for(let e=o;l>e;e++)i.set(e,e+1);i.set(l,o)}for(const e of Object.keys(t))t[e]=i.get(t[e])}else a=d}}(p,y,t),w());const S=p.map(e=>{const t=new Map;for(const r of e.occupants){const e=n[r.id];if(e)for(const n of e.samples){const e=t.get(n.t)||{top:0,bot:0};t.set(n.t,{top:Math.max(e.top,n.topMass),bot:Math.max(e.bot,n.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),M=(e,t)=>{let n={top:0,bot:0};for(const[r,o]of e){if(r>t)break;n=o}return n},A=[];for(let e=0;p.length-1>e;e++){const t=S[e],n=S[e+1],r=new Set([...t.map(e=>e[0]),...n.map(e=>e[0])]);let o=0;for(const e of r){const r=M(t,e),i=M(n,e);r.bot+i.top>o&&(o=r.bot+i.top)}A.push(o)}const C=[];let L=a+(p[0]?.peak.topPeak??0)*s;p.length>0&&C.push(L);for(let e=1;p.length>e;e++)L+=A[e-1]*s+a,C.push(L);if(p.length>0&&(L+=p[p.length-1].peak.botPeak*s+a),L>i){const e=i/L;for(let t=0;C.length>t;t++)C[t]*=e}const j=0===p.length?0:p[0].peak.topPeak+A.reduce((e,t)=>e+t,0)+p[p.length-1].peak.botPeak,T={};for(const t of e)T[t.id]=C[y[t.id]];return{effectiveSlotsHeight:j,centerlines:T,laneLifetime:g,slots:p,slotByNode:y,slotCenter:C,crossingsBefore:m,crossingsAfter:b,lengthBefore:v,lengthAfter:x}}var wc=e=>{const{bands:t=[],ribbons:n=[],showLabels:r=!0}=e.config,o=[];for(const e of n)o.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}});for(const e of t)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const n=e.gradientStubs[t];o.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of t)o.push({type:"bezier",pathD:e.pathD,style:{...e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86},stroke:e.stroke??e.fill,strokeWidth:e.strokeWidth??.5},datum:{__kind:"band",data:e.rawDatum,id:e.id}});const i=r?t.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:o,labels:i}};function Sc(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}var Mc=require("react/jsx-runtime");function Ac(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function Cc(e,t){return"function"==typeof e?e(t):t[e]}var Lc=(0,cc.forwardRef)(function(e,t){const{nodes:n,edges:r,domain:o,axisTicks:i=[],nodeIdAccessor:a="id",sourceAccessor:s="source",targetAccessor:l="target",valueAccessor:c="value",startTimeAccessor:u="startTime",endTimeAccessor:d="endTime",systemInTimeAccessor:h,systemOutTimeAccessor:f,xExtentAccessor:g="xExtent",edgeIdAccessor:y="id",colorBy:p,colorScheme:m,showLegend:b,legendPosition:v="right",pairing:x="temporal",packing:k="reuse",laneOrder:w="crossing-min",ribbonLane:S="both",lifetimeMode:M="half",showLaneRails:A=!1,showQualityReadout:C=!1,showLabels:L=!0,width:j=600,height:T=400,margin:E,title:D,description:R,summary:I,accessibleTable:N,responsiveWidth:P,responsiveHeight:_,loading:W,loadingContent:$,emptyContent:O,edgeOpacity:B=.35,timeFormat:z,valueFormat:H,tooltip:F,enableHover:q=!0,onObservation:Y,onClick:G,showParticles:X=!1,particleStyle:V,chartId:U,frameProps:K={}}=e,[Q,Z]=(0,sc.useState)([]),[J,ee]=(0,sc.useState)([]),te=(0,sc.useRef)(Q),ne=(0,sc.useRef)(J);te.current=Q,ne.current=J;const re=(0,sc.useCallback)(e=>{te.current=e,Z(e)},[]),oe=(0,sc.useCallback)(e=>{ne.current=e,ee(e)},[]),ie=void 0!==r,ae=ta(ie?r:Q),se=(0,sc.useMemo)(()=>{const e=ta(n??[]),t=J;if(0===e.length&&0===t.length)return ul([],ae,s,l);const r=new Set,o=[];for(const t of e){const e=Cc(a,t)+"";r.has(e)||(r.add(e),o.push(t))}for(const e of t){const t=Cc(a,e)+"";r.has(t)||(r.add(t),o.push(e))}const i=ul([],ae,s,l);for(const e of i)r.has(e.id)||(r.add(e.id),o.push(e));return o},[n,J,ae,a,s,l]),le=(0,sc.useRef)(null),ce=(0,sc.useCallback)((e,t)=>{const n=Cc(y,e);return null!=n?n+"":`${Cc(s,e)}-${Cc(l,e)}-${t}`},[y,s,l]),ue=(0,sc.useCallback)(e=>{if(null==e)return!1;const t=e;return null!=Cc(s,t)&&null!=Cc(l,t)},[s,l]);vs(t,{variant:"network",frameRef:le,overrides:{push(e){if(ue(e)){if(ie)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");re([...te.current,e])}else oe([...ne.current,e])},pushMany(e){const t=[],n=[];for(const r of e)ue(r)?t.push(r):n.push(r);t.length>0&&(ie?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):re([...te.current,...t])),n.length>0&&oe([...ne.current,...n])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),n=[];if(!ie){const e=te.current,r=[];for(let o=0;e.length>o;o++){const i=e[o];t.has(ce(i,o))?n.push(i):r.push(i)}r.length!==e.length&&re(r)}const r=ne.current,o=[];for(const e of r){const r=Cc(a,e)+"";t.has(r)?n.push(e):o.push(e)}return o.length!==r.length&&oe(o),n},update(e,t){const n=new Set(Array.isArray(e)?e:[e]),r=[];if(!ie){let e=!1;const o=te.current.map((o,i)=>n.has(ce(o,i))?(r.push(o),e=!0,t(o)):o);e&&re(o)}let o=!1;const i=ne.current.map(e=>{const i=Cc(a,e)+"";return n.has(i)?(r.push(e),o=!0,t(e)):e});return o&&oe(i),r},clear(){ie||re([]),oe([]),le.current?.clear()},getData:()=>ae??[],getScales:()=>null}});const de=ce,he=(0,sc.useCallback)(e=>Cc(a,e)+"",[a]),{nodes:fe,edges:ge,domain:ye,rawNodeById:pe,rawEdgeById:me}=(0,sc.useMemo)(()=>{const e=(se??[]).map(e=>{const t={id:he(e),__raw:e},n=g?Cc(g,e):null;if(Array.isArray(n)&&2===n.length){const e=Ac(n[0]),r=Ac(n[1]);Number.isFinite(e)&&Number.isFinite(r)&&(t.xExtent=[e,r])}return t}),t=(ae??[]).map((e,t)=>{const n={id:de(e,t),source:Cc(s,e)+"",target:Cc(l,e)+"",value:Number(Cc(c,e)),startTime:Ac(Cc(u,e)),endTime:Ac(Cc(d,e)),__raw:e};if(h){const t=Ac(Cc(h,e));Number.isFinite(t)&&(n.systemInTime=t)}if(f){const t=Ac(Cc(f,e));Number.isFinite(t)&&(n.systemOutTime=t)}return n}),n=[Ac(o[0]),Ac(o[1])],r=new Map;for(const t of e)null!=t.__raw&&r.set(t.id,t.__raw);const i=new Map;for(const e of t)null!=e.__raw&&i.set(e.id,e.__raw);return{nodes:e,edges:t,domain:n,rawNodeById:r,rawEdgeById:i}},[se,ae,o,he,de,g,s,l,c,u,d,h,f]),ve=fl({nodes:se,edges:ae,inferNodes:!1,nodeIdAccessor:a,sourceAccessor:s,targetAccessor:l,colorBy:p,colorScheme:m,showLegend:!1,legendPosition:v,selection:void 0,linkedHover:void 0,onObservation:Y,onClick:G,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:"ProcessSankey",chartId:U,marginDefaults:{top:30,right:80,bottom:40,left:80},userMargin:E,width:j,height:T,hasTitle:!!D,loading:W,loadingContent:$,emptyContent:O}),xe=(b??!!p)&&!!p,ke=(0,sc.useCallback)(e=>null!=E&&("number"==typeof E||null!=E[e]),[E]),we=(0,sc.useMemo)(()=>{const e={...ve.margin};return xe&&("right"===v&&!ke("right")&&140>e.right?e.right=140:"bottom"===v&&!ke("bottom")&&80>e.bottom&&(e.bottom=80)),e},[ve.margin,xe,v,ke]),Se=j-we.left-we.right,Me=T-we.top-we.bottom,Ae=(0,sc.useMemo)(()=>uc(fe,ge,ye),[fe,ge,ye]),Ce=(0,sc.useMemo)(()=>Ae.length>0?null:function(e,t,n){const{plotH:r,pairing:o="temporal",packing:i="reuse",laneOrder:a="crossing-min",lifetimeMode:s="half"}=n,l=function(e,t){const n={},r={};for(const t of e)n[t.id]=[],r[t.id]=[];for(const e of t)r[e.source]&&r[e.source].push(e),n[e.target]&&n[e.target].push(e);return{incoming:n,outgoing:r}}(e,t),c=function(e,t,n,r="value"){const o="temporal"===r?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,i="temporal"===r?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,a=new Map;for(const e of t)a.set(e.id,{});const s=(e,t)=>{const n=new Map;for(const r of e){const e=r[t];n.has(e)||n.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const o=n.get(e);o.edges.push(r),o.total+=r.value,o.earliestStart=Math.min(o.earliestStart,r.startTime),o.latestEnd=Math.max(o.latestEnd,r.endTime)}const a=[...n.values()];a.sort("temporal"===r?(e,n)=>"target"===t?e.earliestStart-n.earliestStart:e.latestEnd-n.latestEnd:(e,t)=>t.total-e.total);for(const e of a)e.edges.sort("target"===t?i:o);return a};for(const t of e){const e=n.outgoing[t.id],r=n.incoming[t.id];if(0===r.length)s(e,"target").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).sourceSide=n});else if(0===e.length)s(r,"source").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)a.get(t.id).targetSide=n});else{const t=s(r,"source"),n=s(e,"target"),o=Math.max(t.length,n.length);for(let e=0;o>e;e++){const r=e%2==0?"top":"bot";if(t[e])for(const n of t[e].edges)a.get(n.id).targetSide=r;if(n[e])for(const t of n[e].edges)a.get(t.id).sourceSide=r}}}return a}(e,t,l,o);let u={};for(const t of e)u[t.id]=hc(t,l,c);const d=kc(e,t,u,l,{plotH:r,padding:12,valueScale:1,packing:i,laneOrder:a,lifetimeMode:s}),h=new Set;for(const e of t){const t=d.slotByNode[e.source],n=d.slotByNode[e.target];if(void 0===t||void 0===n)continue;const r=c.get(e.id);t!==n?t>n?(r.sourceSide="top",r.targetSide="bot"):(r.sourceSide="bot",r.targetSide="top"):(h.add(e.id),r.sourceSide="bot",r.targetSide="bot")}for(const t of e){const e=l.outgoing[t.id],n=l.incoming[t.id],r=new Set(e.map(e=>c.get(e.id).sourceSide)),o=new Set(n.map(e=>c.get(e.id).targetSide));if(1===r.size&&n.length>0){const e=[...r][0];for(const t of n)d.slotByNode[t.source]===d.slotByNode[t.target]&&(c.get(t.id).targetSide=e)}if(1===o.size&&e.length>0){const t=[...o][0];for(const n of e)d.slotByNode[n.source]===d.slotByNode[n.target]&&(c.get(n.id).sourceSide=t)}}for(const t of e){const e=l.incoming[t.id],n=l.outgoing[t.id];if(0===e.length||0===n.length)continue;const r=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of e)"top"===c.get(n.id).targetSide?t.inTop+=n.value:t.inBot+=n.value;for(const e of n)"top"===c.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},o=(e,t)=>{const o=r(),i="top"===e?o.outTop-o.inTop:o.outBot-o.inBot,a="top"===t?o.inTop-o.outTop:o.inBot-o.outBot;if(0>=i||0>=a)return!1;const s=Math.min(i,a),l=n.filter(t=>!h.has(t.id)&&c.get(t.id).sourceSide===e&&s>=t.value).sort((e,t)=>t.value-e.value);return 0!==l.length&&(c.get(l[0].id).sourceSide=t,!0)};let i=n.length+1;for(;i-- >0&&(o("top","bot")||o("bot","top")););}u={};for(const t of e)u[t.id]=hc(t,l,c);const f=kc(e,t,u,l,{plotH:r,padding:12,valueScale:1,packing:i,laneOrder:a,lifetimeMode:s}),g=f.effectiveSlotsHeight??f.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),y=Math.min(12,.35*r/Math.max(f.slots.length+1,1)),p=g>0?Math.max(0,(r-y*(f.slots.length+1))/g):1,m=kc(e,t,u,l,{plotH:r,padding:y,valueScale:p,packing:i,laneOrder:a,lifetimeMode:s});return{nodeData:u,sides:c,valueScale:p,padding:y,compressedPadding:12>y,centerlines:m.centerlines,laneLifetime:m.laneLifetime,slots:m.slots,slotByNode:m.slotByNode,crossingsBefore:m.crossingsBefore,crossingsAfter:m.crossingsAfter,lengthBefore:m.lengthBefore,lengthAfter:m.lengthAfter}}(fe,ge,{plotH:Me,pairing:x,packing:k,laneOrder:w,lifetimeMode:M}),[Ae,fe,ge,Me,x,k,w,M]),Le=(0,sc.useMemo)(()=>(0,lc.scaleTime)().domain(ye).range([0,Se]),[ye,Se]),je=(0,sc.useCallback)((e,t)=>{if(p&&se){const t=pe.get(e);if(t)return zt(t,p,ve.colorScale)}return ve.effectivePalette[t%ve.effectivePalette.length]||"#475569"},[p,se,pe,ve.colorScale,ve.effectivePalette]),Te=(0,sc.useMemo)(()=>{const e=new Map;return fe.forEach((t,n)=>e.set(t.id,n)),e},[fe]),Ee=(0,sc.useMemo)(()=>{if(!Ce)return{bands:[],ribbons:[]};const{centerlines:e,nodeData:t,valueScale:n}=Ce,r=[],o=[];return fe.forEach((o,i)=>{const a=t[o.id];if(!a||0===a.samples.length)return;const s=function(e,t,n,r,o){if(0===e.length)return null;const i=gc(e,o),a=e=>t-i[e].topMass*n,s=e=>t+i[e].botMass*n;let l=`M${r(i[0].t)},${a(0)}`;for(let e=1;i.length>e;e++)l+=` L${r(i[e].t)},${a(e)}`;l+=` L${r(i[i.length-1].t)},${s(i.length-1)}`;for(let e=i.length-2;e>=0;e--)l+=` L${r(i[e].t)},${s(e)}`;return l+" Z"}(a.samples,e[o.id],n,Le,ye);if(!s)return;const l=gc(a.samples,ye),c=l.find(e=>e.topMass+e.botMass>0)||l[0],u=e[o.id]+(c.botMass-c.topMass)*n/2,d=je(o.id,i),h=pe.get(o.id)??o,f=function(e,t,n,r,o){const i=n.nodeData[e];if(!i||0===i.samples.length)return[];const a=n.valueScale,s=n.centerlines[e],l=gc(i.samples,o),c=l.find(e=>e.topMass+e.botMass>0)||l[0],u=[...l].reverse().find(e=>e.topMass+e.botMass>0)||l[l.length-1],d=r(c.t),h=r(u.t),f=e=>r(fc(e,o)),g=[],y=(e,t,n,r)=>`M${e},${t} L${n},${t} L${n},${r} L${e},${r} Z`;for(const n of t){if(n.source===e&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const e=i.localAttachments.get(n.id);if(e&&"out"===e.kind&&n.startTime>n.systemInTime){const t=f(n.systemInTime),r=f(n.startTime),o=t-20,i=Math.max(d,o);if(r>i){const[n,l]=yc(e,s,a);g.push({pathD:y(i,n,r,l),x0:o,x1:t,from:0,to:1})}}}if(n.target===e&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const e=i.localAttachments.get(n.id);if(e&&"in"===e.kind&&n.systemOutTime>n.endTime){const t=f(n.systemOutTime),r=f(n.endTime),o=t+20,i=Math.min(h,o);if(i>r){const[n,l]=yc(e,s,a);g.push({pathD:y(r,n,i,l),x0:t,x1:o,from:1,to:0})}}}}return g}(o.id,ge,Ce,Le,ye);r.push({id:o.id,pathD:s,fill:d,stroke:d,strokeWidth:.5,...f.length>0&&{gradientStubs:f},rawDatum:h,labelX:Le(c.t)-4,labelY:u,labelText:o.id})}),ge.forEach(r=>{const i=t[r.source]?.localAttachments.get(r.id),a=t[r.target]?.localAttachments.get(r.id);if(!i||!a)return;const s=Te.get(r.source)??0,l=je(r.source,s),c=function(e,t,n,r,o,i,a,s){const l=o,c=e=>s?Math.max(s[0],Math.min(s[1],e)):e,u=i(c(e.time)),d=i(c(n.time)),h=e.value*l,f=n.value*l,g=e.sideMassBefore*l,y=n.sideMassAfter*l;let p,m,b,v;"top"===e.side?(p=t-g,m=p+h):(m=t+g,p=m-h),"top"===n.side?(b=r-y,v=b+f):(v=r+y,b=v-f);const x="source"===a?u+.85*(d-u):"target"===a?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:p,sBot:m,tx:d,tTop:b,tBot:v,cp1X:x,cp2X:x}}(i,e[r.source],a,e[r.target],n,Le,S,ye),{pathD:u,bezier:d}=be(c),h=me.get(r.id)??r;o.push({id:r.id,pathD:u,fill:l,opacity:B,rawDatum:h,bezier:d})}),{bands:r,ribbons:o}},[Ce,fe,ge,Le,ye,je,pe,me,S,B,Te]),De=(0,sc.useMemo)(()=>({bands:Ee.bands,ribbons:Ee.ribbons,showLabels:L}),[Ee,L]),Re=(0,sc.useMemo)(()=>{if(!xe||!p)return;const e=new Map;(se??[]).forEach((t,n)=>{const r=Cc(p,t),o=null==r?"":r+"";o&&!e.has(o)&&e.set(o,{label:o,color:je(he(t),n)})});const t=Array.from(e.values());return 0!==t.length?{legendGroups:[{type:"fill",label:"",items:t,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0},[xe,p,se,je,he]),Ie=(0,sc.useMemo)(()=>!1!==F&&q?void 0===F||!0===F?null:zn(F)||null:null,[F,q]),Ne=(0,sc.useCallback)(e=>z?z(new Date(e)):Number.isFinite(e)?1e10>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2):new Date(e).toISOString().slice(0,10):"",[z]),Pe=(0,sc.useCallback)(e=>H?H(e):e+"",[H]),_e=(0,sc.useCallback)(e=>{if(!e||!e.data)return null;const t=e.data;if(!Sc(t))return null;const n=t.data;if(Ie)return Ie(n);if("band"===t.__kind){const e=t.id,n=Ce?function(e){if(!e)return[];const t=new Set,n=[];for(const r of e.samples){const e=r.topMass+r.botMass,o=`${r.t}:${e}`;t.has(o)||(t.add(o),n.push({t:r.t,total:e}))}return n}(Ce.nodeData[e]):[],r=5,o=n.length>r?n.length:null,i=function(e,t=5){if(t>=e.length)return e.slice();const n=[...e].sort((e,t)=>e.total-t.total),r=n.length-1,o=[{...n[0],mark:"min"},{...n[Math.floor(.25*r)],mark:"q25"},{...n[Math.floor(.5*r)],mark:"median"},{...n[Math.floor(.75*r)],mark:"q75"},{...n[r],mark:"max"}],i=new Set,a=[];for(const e of o)i.has(e.t)||(i.add(e.t),a.push(e));return a.sort((e,t)=>e.t-t.t)}(n,r);return(0,Mc.jsxs)("div",{style:{minWidth:160},children:[(0,Mc.jsx)("div",{style:{fontWeight:600,marginBottom:4},children:e}),i.length>0&&(0,Mc.jsxs)("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[(0,Mc.jsx)("thead",{children:(0,Mc.jsxs)("tr",{style:{opacity:.6},children:[(0,Mc.jsx)("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),(0,Mc.jsx)("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=o&&(0,Mc.jsx)("th",{})]})}),(0,Mc.jsx)("tbody",{children:i.map((e,t)=>(0,Mc.jsxs)("tr",{children:[(0,Mc.jsx)("td",{style:{paddingRight:8},children:Ne(e.t)}),(0,Mc.jsx)("td",{style:{textAlign:"right"},children:Pe(e.total)}),null!=o&&(0,Mc.jsx)("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:e.mark})]},t))})]}),null!=o&&(0,Mc.jsxs)("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",i.length," of ",o," samples"]})]})}const r=n,o=Cc(s,r),i=Cc(l,r),a=Cc(c,r),h=Cc(u,r),f=Cc(d,r);return(0,Mc.jsxs)("div",{style:{minWidth:160},children:[(0,Mc.jsxs)("div",{style:{fontWeight:600,marginBottom:4},children:[o+""," → ",i+""]}),(0,Mc.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=a&&(0,Mc.jsxs)(Mc.Fragment,{children:[(0,Mc.jsx)("span",{style:{opacity:.6},children:"value"}),(0,Mc.jsx)("span",{style:{textAlign:"right"},children:Pe(Number(a))})]}),null!=h&&(0,Mc.jsxs)(Mc.Fragment,{children:[(0,Mc.jsx)("span",{style:{opacity:.6},children:"start"}),(0,Mc.jsx)("span",{style:{textAlign:"right"},children:Ne(Ac(h))})]}),null!=f&&(0,Mc.jsxs)(Mc.Fragment,{children:[(0,Mc.jsx)("span",{style:{opacity:.6},children:"end"}),(0,Mc.jsx)("span",{style:{textAlign:"right"},children:Ne(Ac(f))})]})]})]})},[Ce,Ie,Ne,Pe,s,l,c,u,d]),We=(0,sc.useMemo)(()=>{if(!Ce)return null;const{centerlines:e,laneLifetime:t,nodeData:n,valueScale:r,compressedPadding:o,crossingsBefore:a,crossingsAfter:s,lengthBefore:l,lengthAfter:c}=Ce;let u=null,d=null;for(const e of fe){const n=t[e.id];if(!n||null===n.start||null===n.end)continue;const r=Le(n.start),o=Le(n.end);(null===u||u>r)&&(u=r),(null===d||o>d)&&(d=o)}const h=e=>Math.max(0,Math.min(Se,e)),f=h(u??0),g=Math.max(f,h(d??Se));return(0,Mc.jsxs)("g",{children:[C&&null!==(s??null)&&(0,Mc.jsxs)("text",{x:Se,y:-12,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:["crossings: ",a," → ",s," ","edge length: ",Math.round(l)," → ",Math.round(c)]}),o&&(0,Mc.jsx)("text",{x:Se,y:2,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:"dense layout: lane gaps compressed"}),i.map((e,t)=>{const n=Le(Ac(e.date));return f-.5>n||n>g+.5?null:(0,Mc.jsx)("line",{x1:n,y1:0,x2:n,y2:Me,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+t)}),A&&fe.map((o,i)=>{const a=t[o.id];if(!a||null===a.start)return null;const s=n[o.id],l=s?{topPeak:s.topPeak,botPeak:s.botPeak}:{topPeak:0,botPeak:0},c=e[o.id]+(l.botPeak-l.topPeak)*r/2,u=Le(a.start),d=Le(a.end),h=je(o.id,i);return(0,Mc.jsxs)("g",{children:[(0,Mc.jsx)("line",{x1:u,y1:c,x2:d,y2:c,stroke:h,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),(0,Mc.jsx)("line",{x1:u,y1:c-4,x2:u,y2:c+4,stroke:h,strokeOpacity:.5}),(0,Mc.jsx)("line",{x1:d,y1:c-4,x2:d,y2:c+4,stroke:h,strokeOpacity:.5})]},"lane-"+o.id)}),(0,Mc.jsx)("line",{x1:f,y1:Me+4,x2:g,y2:Me+4,stroke:"#94a3b8"}),i.map((e,t)=>{const n=Ac(e.date),r=Le(n);if(f-.5>r||r>g+.5)return null;const o=null!=e.label?e.label:z?z(new Date(n)):"";return(0,Mc.jsxs)("g",{transform:`translate(${r},${Me+4})`,children:[(0,Mc.jsx)("line",{y2:6,stroke:"#94a3b8"}),(0,Mc.jsx)("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569",children:o})]},t)})]})},[Ce,i,Le,Se,Me,A,fe,je,C,z]),$e=(0,sc.useMemo)(()=>(se??[]).map(e=>({id:he(e),data:e})),[se,he]),Oe=(0,sc.useMemo)(()=>{const e=new Map;for(const t of Ee.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[Ee]),Be=(0,sc.useMemo)(()=>(ae??[]).map((e,t)=>{const n=de(e,t),r=Number(Cc(c,e));return{id:n,source:Cc(s,e)+"",target:Cc(l,e)+"",value:Number.isFinite(r)?r:0,bezier:Oe.get(n),data:e}}),[ae,de,s,l,c,Oe]),ze=ve.loadingEl,He=ve.emptyEl;return Ae.length>0?(0,Mc.jsxs)("svg",{width:j,height:T,role:"img","aria-label":D??"Process Sankey validation failed",children:[(0,Mc.jsx)("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),Ae.map((e,t)=>(0,Mc.jsx)("text",{x:20,y:56+18*t,fontSize:12,fill:"#64748b",children:"• "+dc(e)},t))]}):ze||He||(0,Mc.jsx)(ms,{ref:le,chartType:"force",nodes:$e,edges:Be,customNetworkLayout:wc,layoutConfig:De,size:[j,T],responsiveWidth:P,responsiveHeight:_,margin:we,title:D,description:R??"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:I,accessibleTable:N,enableHover:q,tooltipContent:!1===F?()=>null:_e,backgroundGraphics:We,showParticles:X,particleStyle:V,legend:Re,legendPosition:v,onObservation:Y,...G&&{customClickBehavior:e=>{if(!e||!e.data||!G)return;const t=e.data;Sc(t)&&G(t.data,{x:e.x,y:e.y})}},chartId:U,colorScheme:Array.isArray(m)?m:void 0,...K})});Lc.displayName="ProcessSankey";var jc=require("react"),Tc=require("react"),Ec=require("react/jsx-runtime"),Dc=(0,jc.forwardRef)(function(e,t){const{nodes:n,edges:r,layout:o,layoutConfig:i,onLayoutError:a,nodeIDAccessor:s="id",sourceAccessor:l="source",targetAccessor:c="target",margin:u,className:d,colorBy:h,colorScheme:f,selection:g,linkedHover:y,onObservation:p,onClick:m,chartId:b,annotations:v,autoPlaceAnnotations:x,frameProps:k={}}=e,{frameRef:w,resolved:S,normalizedMargin:M}=function(e){const t=(0,Tc.useRef)(null);return vs(e.imperativeRef,{variant:e.imperativeVariant,frameRef:t}),{frameRef:t,resolved:sl(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),normalizedMargin:(0,Tc.useMemo)(()=>function(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}(e.margin),[e.margin])}}({imperativeRef:t,imperativeVariant:"network",margin:u,width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),A=(0,jc.useMemo)(()=>ta(n),[n]),C=(0,jc.useMemo)(()=>ta(r),[r]),L=(0,jc.useMemo)(()=>void 0===n&&void 0===r?void 0:[...A,...C],[r,n,C,A]),j=Fs(e.mobileInteraction,{mode:e.mode,width:S.width,mobileSemantics:e.mobileSemantics}),{customHoverBehavior:T,customClickBehavior:E,activeSelectionHook:D}=al({selection:g,linkedHover:y,fallbackFields:"string"==typeof h?[h]:[],onObservation:p,onClick:m,chartType:"NetworkCustomChart",chartId:b,colorByField:"string"==typeof h?h:void 0,mobileInteraction:j}),R=(0,jc.useMemo)(()=>D?.isActive?{isActive:!0,predicate:D.predicate}:null,[D?.isActive,D?.predicate]),{width:I,height:N,enableHover:P,title:_,description:W,summary:$,accessibleTable:O}=S,B=ja(e.loading,I,N,e.loadingContent),z=B?null:La(L,I,N,e.emptyContent);if(B||z)return B||z;const H={chartType:"force",...null!=n&&{nodes:A},...null!=r&&{edges:C},customNetworkLayout:o,layoutConfig:i,onLayoutError:a,nodeIDAccessor:s,sourceAccessor:l,targetAccessor:c,colorBy:h,colorScheme:f,size:[I,N],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:M,enableHover:P,...Ll({title:_,description:W,summary:$,accessibleTable:O,className:d,animate:e.animate,autoPlaceAnnotations:x}),...jl({linkedHover:y,selection:g,onObservation:p,onClick:m,mobileInteraction:j,customHoverBehavior:T,customClickBehavior:E,linkedHoverInClickPredicate:!1}),layoutSelection:R,...null!=v&&{annotations:v},...k};return(0,Ec.jsx)(Ma,{componentName:"NetworkCustomChart",width:I,height:N,children:(0,Ec.jsx)(ms,{ref:w,...H})})});Dc.displayName="NetworkCustomChart";var Rc={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},Ic=8;function Nc(e){const t=function(e){return null==e?void 0:e+""}(e.id);return"width"in e&&"height"in e?{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...Rc},datum:e.datum,id:t,label:e.label}:{type:"circle",cx:e.x,cy:e.y,r:e.r??Ic,style:{...Rc},datum:e.datum,id:t,label:e.label}}
|