semiotic 3.8.6 → 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.
Files changed (213) hide show
  1. package/CLAUDE.md +33 -7
  2. package/README.md +82 -55
  3. package/ai/behaviorContracts.cjs +86 -1
  4. package/ai/componentMetadata.cjs +4 -9
  5. package/ai/dist/mcp-server.js +97 -10
  6. package/ai/examples.md +154 -7
  7. package/ai/schema.json +1611 -145
  8. package/ai/surface-manifest.json +12 -10
  9. package/ai/system-prompt.md +9 -3
  10. package/dist/{chunk-chartContainerDataAudit-FEOD5GTQ.module.min.js → chunk-chartContainerDataAudit-JDSVSKGM.module.min.js} +1 -1
  11. package/dist/chunk-chunk-2YAZHXL4.module.min.js +2 -0
  12. package/dist/{chunk-chunk-G7WFWHAD.module.min.js → chunk-chunk-4ITOQRXM.module.min.js} +1 -1
  13. package/dist/chunk-chunk-5SD6BHVW.module.min.js +2 -0
  14. package/dist/chunk-chunk-6V5VQVCT.module.min.js +2 -0
  15. package/dist/chunk-chunk-7TTBHSAG.module.min.js +2 -0
  16. package/dist/chunk-chunk-7ZDJSYKI.module.min.js +2 -0
  17. package/dist/chunk-chunk-BGHPD3RA.module.min.js +1 -0
  18. package/dist/chunk-chunk-BMRZ2SPU.module.min.js +2 -0
  19. package/dist/chunk-chunk-BNGBEY7N.module.min.js +2 -0
  20. package/dist/chunk-chunk-C7APLVQD.module.min.js +2 -0
  21. package/dist/chunk-chunk-DGWFBOGB.module.min.js +1 -0
  22. package/dist/{chunk-chunk-Q2BS46W2.module.min.js → chunk-chunk-DIVE2DRA.module.min.js} +1 -1
  23. package/dist/chunk-chunk-FBUNUIPV.module.min.js +2 -0
  24. package/dist/chunk-chunk-FQPKOAIH.module.min.js +2 -0
  25. package/dist/chunk-chunk-FRO4TRXK.module.min.js +2 -0
  26. package/dist/chunk-chunk-G7QVPZUD.module.min.js +2 -0
  27. package/dist/chunk-chunk-GBPYV4FP.module.min.js +2 -0
  28. package/dist/chunk-chunk-GU2EJIDJ.module.min.js +2 -0
  29. package/dist/chunk-chunk-J5QD4RAM.module.min.js +2 -0
  30. package/dist/{chunk-chunk-RA7JCG7D.module.min.js → chunk-chunk-JWXLNZSM.module.min.js} +1 -1
  31. package/dist/chunk-chunk-KXAFCCDB.module.min.js +2 -0
  32. package/dist/chunk-chunk-LG7YKJAK.module.min.js +2 -0
  33. package/dist/{chunk-chunk-XP3OHHFX.module.min.js → chunk-chunk-LVHDZAT3.module.min.js} +1 -1
  34. package/dist/chunk-chunk-LWITSR2O.module.min.js +2 -0
  35. package/dist/{chunk-chunk-SMVD3EQJ.module.min.js → chunk-chunk-MX35T6RX.module.min.js} +1 -1
  36. package/dist/chunk-chunk-NH4MEAKP.module.min.js +2 -0
  37. package/dist/chunk-chunk-NJETWX42.module.min.js +2 -0
  38. package/dist/chunk-chunk-NW25WGLS.module.min.js +2 -0
  39. package/dist/{chunk-chunk-GFTVACTO.module.min.js → chunk-chunk-OI7R7EJB.module.min.js} +1 -1
  40. package/dist/{chunk-chunk-OM6NWS4H.module.min.js → chunk-chunk-ONMLEXHR.module.min.js} +1 -1
  41. package/dist/chunk-chunk-OY66GCE6.module.min.js +1 -0
  42. package/dist/chunk-chunk-PZFT457G.module.min.js +1 -0
  43. package/dist/chunk-chunk-Q3WW6JGR.module.min.js +1 -0
  44. package/dist/chunk-chunk-Q6XKQTOQ.module.min.js +1 -0
  45. package/dist/chunk-chunk-RJRM2E6P.module.min.js +1 -0
  46. package/dist/chunk-chunk-RPL7WYXI.module.min.js +1 -0
  47. package/dist/chunk-chunk-SV4XAZ3Q.module.min.js +1 -0
  48. package/dist/chunk-chunk-TSCFL235.module.min.js +1 -0
  49. package/dist/chunk-chunk-UOQRPGPK.module.min.js +2 -0
  50. package/dist/chunk-chunk-V3OAKG32.module.min.js +1 -0
  51. package/dist/chunk-chunk-WLOIUMWG.module.min.js +2 -0
  52. package/dist/chunk-chunk-XEGXX4F7.module.min.js +1 -0
  53. package/dist/chunk-chunk-XFRBLXYM.module.min.js +1 -0
  54. package/dist/chunk-chunk-Z2AJERX5.module.min.js +2 -0
  55. package/dist/chunk-chunk-ZXYDYAB7.module.min.js +2 -0
  56. package/dist/components/ai/SemioticVACPBridge.d.ts +22 -0
  57. package/dist/components/ai/chartCapabilities.d.ts +4 -3
  58. package/dist/components/ai/conversationArc.d.ts +2 -176
  59. package/dist/components/ai/conversationArcTypes.d.ts +202 -0
  60. package/dist/components/ai/readerGrounding.d.ts +12 -0
  61. package/dist/components/ai/vacpAdapter.d.ts +13 -0
  62. package/dist/components/ai/vacpAdapterActions.d.ts +2 -0
  63. package/dist/components/ai/vacpAdapterModel.d.ts +7 -0
  64. package/dist/components/ai/vacpAdapterRuntime.d.ts +26 -0
  65. package/dist/components/ai/vacpAdapterState.d.ts +3 -0
  66. package/dist/components/ai/vacpAdapterTypes.d.ts +169 -0
  67. package/dist/components/ai/vacpTypes.d.ts +160 -0
  68. package/dist/components/charts/index.d.ts +4 -4
  69. package/dist/components/charts/physics/ChainReactionChart.capability.d.ts +9 -0
  70. package/dist/components/charts/physics/ChainReactionChart.d.ts +29 -0
  71. package/dist/components/charts/physics/CollisionSwarmChart.d.ts +1 -1
  72. package/dist/components/charts/physics/EventDropChart.d.ts +7 -2
  73. package/dist/components/charts/physics/GaltonBoardChart.d.ts +1 -1
  74. package/dist/components/charts/physics/{PhysicsPileChart.capability.d.ts → PacketFlowChart.capability.d.ts} +1 -1
  75. package/dist/components/charts/physics/{PhysicalFlowChart.d.ts → PacketFlowChart.d.ts} +22 -6
  76. package/dist/components/charts/physics/PhysicsCustomChart.d.ts +1 -1
  77. package/dist/components/charts/physics/ProcessFlowChart.d.ts +7 -4
  78. package/dist/components/charts/physics/{PhysicalFlowChart.capability.d.ts → UnitPileChart.capability.d.ts} +1 -1
  79. package/dist/components/charts/physics/{PhysicsPileChart.d.ts → UnitPileChart.d.ts} +19 -6
  80. package/dist/components/charts/physics/crucibleChartProps.d.ts +1 -1
  81. package/dist/components/charts/physics/crucibleChartUtils.d.ts +9 -0
  82. package/dist/components/charts/physics/gauntletChartProps.d.ts +6 -1
  83. package/dist/components/charts/physics/gauntletTerminal.d.ts +61 -0
  84. package/dist/components/charts/physics/packetFlowSemantics.d.ts +6 -0
  85. package/dist/components/charts/physics/physicsHocUtils.d.ts +45 -2
  86. package/dist/components/charts/shared/auditAccessibilityStyles.d.ts +9 -0
  87. package/dist/components/charts/shared/knownChartComponents.d.ts +1 -1
  88. package/dist/components/charts/shared/useChartLegend.d.ts +8 -1
  89. package/dist/components/charts/shared/useChartSetup.d.ts +7 -0
  90. package/dist/components/data/portability/capabilityBinding.d.ts +41 -0
  91. package/dist/components/data/portability/index.d.ts +2 -0
  92. package/dist/components/legendLayout.d.ts +56 -0
  93. package/dist/components/recipes/geographicDotGrid.d.ts +82 -0
  94. package/dist/components/recipes/geographicGrid.d.ts +100 -0
  95. package/dist/components/recipes/physics.d.ts +2 -0
  96. package/dist/components/recipes/physicsStageGeography.d.ts +137 -0
  97. package/dist/components/semiotic-ai.d.ts +4 -3
  98. package/dist/components/semiotic-experimental-vacp.d.ts +11 -0
  99. package/dist/components/semiotic-experimental.d.ts +6 -3
  100. package/dist/components/semiotic-geo.d.ts +4 -0
  101. package/dist/components/semiotic-physics.d.ts +9 -6
  102. package/dist/components/semiotic-recipes-core.d.ts +6 -1
  103. package/dist/components/server/renderEvidence.d.ts +1 -1
  104. package/dist/components/server/renderToStaticSVG.d.ts +2 -1
  105. package/dist/components/server/serverChartConfigHeatmap.d.ts +6 -0
  106. package/dist/components/server/serverChartConfigNetworkStyles.d.ts +12 -0
  107. package/dist/components/server/serverChartConfigShared.d.ts +16 -0
  108. package/dist/components/server/serverChartConfigs.d.ts +2 -2
  109. package/dist/components/server/serverChartConfigsPhysics.d.ts +2 -2
  110. package/dist/components/server/serverChartConfigsXY.d.ts +0 -1
  111. package/dist/components/server/staticLegend.d.ts +6 -0
  112. package/dist/components/server/staticSVGChrome.d.ts +10 -2
  113. package/dist/components/server/staticValue.d.ts +8 -0
  114. package/dist/components/stream/geoPipelineConfig.d.ts +10 -0
  115. package/dist/components/stream/legendRenderer.d.ts +8 -0
  116. package/dist/components/stream/physics/PhysicsEvidence.d.ts +37 -0
  117. package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +9 -0
  118. package/dist/components/stream/physics/PhysicsSettledScene.d.ts +5 -0
  119. package/dist/components/stream/physics/physicsFramePipelineConfig.d.ts +19 -0
  120. package/dist/components/stream/physics/physicsPipelineSettle.d.ts +52 -0
  121. package/dist/components/stream/physics/physicsRegionRuntime.d.ts +23 -0
  122. package/dist/components/stream/types.d.ts +2 -0
  123. package/dist/components/types/legendTypes.d.ts +17 -1
  124. package/dist/controls.min.js +1 -1
  125. package/dist/controls.module.min.js +1 -1
  126. package/dist/geo.min.js +1 -1
  127. package/dist/geo.module.min.js +1 -1
  128. package/dist/network.min.js +1 -1
  129. package/dist/network.module.min.js +1 -1
  130. package/dist/ordinal.min.js +1 -1
  131. package/dist/ordinal.module.min.js +1 -1
  132. package/dist/physics.min.js +1 -1
  133. package/dist/physics.module.min.js +1 -1
  134. package/dist/physicsWorker.js +1 -1
  135. package/dist/realtime.min.js +1 -1
  136. package/dist/realtime.module.min.js +1 -1
  137. package/dist/semiotic-ai-core.min.js +1 -1
  138. package/dist/semiotic-ai-core.module.min.js +1 -1
  139. package/dist/semiotic-ai.d.ts +4 -3
  140. package/dist/semiotic-ai.min.js +1 -1
  141. package/dist/semiotic-ai.module.min.js +1 -1
  142. package/dist/semiotic-data.module.min.js +1 -1
  143. package/dist/semiotic-experimental-vacp.d.ts +11 -0
  144. package/dist/semiotic-experimental-vacp.min.js +1 -0
  145. package/dist/semiotic-experimental-vacp.module.min.js +1 -0
  146. package/dist/semiotic-experimental.d.ts +6 -3
  147. package/dist/semiotic-experimental.min.js +2 -1
  148. package/dist/semiotic-experimental.module.min.js +2 -1
  149. package/dist/semiotic-geo.d.ts +4 -0
  150. package/dist/semiotic-physics.d.ts +9 -6
  151. package/dist/semiotic-realtime-core.min.js +1 -1
  152. package/dist/semiotic-realtime-core.module.min.js +1 -1
  153. package/dist/semiotic-recipes-core.d.ts +6 -1
  154. package/dist/semiotic-recipes-core.min.js +1 -1
  155. package/dist/semiotic-recipes-core.module.min.js +1 -1
  156. package/dist/semiotic-recipes.min.js +1 -1
  157. package/dist/semiotic-recipes.module.min.js +1 -1
  158. package/dist/semiotic-server-edge.min.js +1 -1
  159. package/dist/semiotic-server-edge.module.min.js +1 -1
  160. package/dist/semiotic-server-node.min.js +1 -1
  161. package/dist/semiotic-server-node.module.min.js +1 -1
  162. package/dist/semiotic-utils-core.min.js +1 -1
  163. package/dist/semiotic-utils-core.module.min.js +1 -1
  164. package/dist/semiotic-utils.min.js +1 -1
  165. package/dist/semiotic-utils.module.min.js +1 -1
  166. package/dist/semiotic.min.js +1 -1
  167. package/dist/semiotic.module.min.js +1 -1
  168. package/dist/server.min.js +1 -1
  169. package/dist/server.module.min.js +1 -1
  170. package/dist/xy.min.js +1 -1
  171. package/dist/xy.module.min.js +1 -1
  172. package/package.json +18 -2
  173. package/spec/README.md +94 -2
  174. package/spec/bindings/README.md +14 -3
  175. package/spec/v0.1/examples/annotation-provenance-reviewed-revision.json +27 -0
  176. package/spec/v0.1/examples/annotation-provenance-watcher-threshold.json +21 -0
  177. package/spec/v0.1/examples/audience-profile-executive-review.json +24 -0
  178. package/spec/v0.1/examples/audience-profile-incident-operators.json +42 -0
  179. package/spec/v0.1/examples/chart-capability-bar-comparison.json +48 -0
  180. package/spec/v0.1/examples/chart-capability-service-flow.json +54 -0
  181. package/dist/chunk-chunk-2CHN2TA3.module.min.js +0 -1
  182. package/dist/chunk-chunk-3SHB24AG.module.min.js +0 -1
  183. package/dist/chunk-chunk-4MMOOYTX.module.min.js +0 -2
  184. package/dist/chunk-chunk-5RKXZQ2P.module.min.js +0 -1
  185. package/dist/chunk-chunk-75OTQSXS.module.min.js +0 -1
  186. package/dist/chunk-chunk-7ALTGHK6.module.min.js +0 -1
  187. package/dist/chunk-chunk-A5GRQUOF.module.min.js +0 -1
  188. package/dist/chunk-chunk-AAF5LZAU.module.min.js +0 -2
  189. package/dist/chunk-chunk-ARZGA4LJ.module.min.js +0 -2
  190. package/dist/chunk-chunk-C4YA6TDR.module.min.js +0 -1
  191. package/dist/chunk-chunk-CAFLML4L.module.min.js +0 -2
  192. package/dist/chunk-chunk-CO5KQMGH.module.min.js +0 -1
  193. package/dist/chunk-chunk-FHBN7OEB.module.min.js +0 -2
  194. package/dist/chunk-chunk-GMQ5AYTD.module.min.js +0 -1
  195. package/dist/chunk-chunk-IP2UE74X.module.min.js +0 -1
  196. package/dist/chunk-chunk-ITDWLZXV.module.min.js +0 -2
  197. package/dist/chunk-chunk-JCG72SGW.module.min.js +0 -2
  198. package/dist/chunk-chunk-LPSPATPC.module.min.js +0 -1
  199. package/dist/chunk-chunk-PX5YQGDP.module.min.js +0 -2
  200. package/dist/chunk-chunk-QSQVBIJA.module.min.js +0 -1
  201. package/dist/chunk-chunk-RCF52Z42.module.min.js +0 -2
  202. package/dist/chunk-chunk-RNUHEXZA.module.min.js +0 -2
  203. package/dist/chunk-chunk-ROZWKEUG.module.min.js +0 -1
  204. package/dist/chunk-chunk-T2FKJD4O.module.min.js +0 -2
  205. package/dist/chunk-chunk-UDREYOLV.module.min.js +0 -1
  206. package/dist/chunk-chunk-VOWE3SAP.module.min.js +0 -2
  207. package/dist/chunk-chunk-VQPNBUSW.module.min.js +0 -2
  208. package/dist/chunk-chunk-WAWCIHFJ.module.min.js +0 -1
  209. package/dist/chunk-chunk-WYARAXHR.module.min.js +0 -2
  210. package/dist/chunk-chunk-XV3KGYTR.module.min.js +0 -2
  211. package/dist/chunk-chunk-YC2IVEPX.module.min.js +0 -1
  212. package/dist/chunk-chunk-ZOAQDIJO.module.min.js +0 -1
  213. package/dist/chunk-chunk-ZXIXAPRE.module.min.js +0 -2
@@ -1 +1 @@
1
- var e,t=Object.create,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,s=(e,t,i,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of r(t))a.call(e,c)||c===i||n(e,c,{get:()=>t[c],enumerable:!(s=o(t,c))||s.enumerable});return e},c=(e,o,r)=>(r=null!=e?t(i(e)):{},s(!o&&e&&e.__esModule?r:n(r,"default",{value:e,enumerable:!0}),e)),l={};((e,t)=>{for(var o in t)n(e,o,{get:t[o],enumerable:!0})})(l,{DEFAULT_AREA_PER_ANNOTATION:()=>dn,DEFAULT_GLYPH_ANCHOR:()=>lr,DEFAULT_GLYPH_VIEWBOX:()=>cr,DEFAULT_HIT_RADIUS:()=>jo,DEFAULT_ISOMETRIC_SPRITE_SIZES:()=>We,GRID_FUEL_KEYS:()=>Wn,GRID_FUEL_LABELS:()=>Pn,Glyph:()=>Ra,LayoutCache:()=>b,SYMBOL_SEQUENCE:()=>J,TAU:()=>Ko,absorbRegion:()=>ci,activeCountOverDomain:()=>to,addPoints:()=>or,adjacencyMatrix:()=>ma,aggregateRegionCounts:()=>Hr,allocateCells:()=>C,analyzeNetEnsemble:()=>wt,angleScale:()=>Jo,annotationBudget:()=>mn,annotationDensity:()=>gn,annotationLayout:()=>Rn,arcLayout:()=>da,arcPath:()=>ha,arrivalReplay:()=>la,axisFixedForceLayout:()=>go,axisFixedForcePositions:()=>po,bandLabel:()=>pt,betweenness:()=>Tr,bfsDistances:()=>Nr,bobaLayout:()=>on,bodyGroupSpec:()=>ui,boundsOf:()=>ft,boxEdgeAnchors:()=>ao,buildAdjacency:()=>jr,buildTooltipEntries:()=>kr,bulletLayout:()=>Bt,calendarLayout:()=>Ce,capacitatedRegion:()=>ai,chargeGateRegion:()=>oi,circularLayout:()=>fa,clamp:()=>$,closeness:()=>Er,clustering:()=>Fr,collidersFromScales:()=>ia,comparePhysicsTrace:()=>Si,composePhysicsControllers:()=>Gi,createCapacityQueueController:()=>Ri,createDependencyGateController:()=>Bi,createPortalController:()=>Hi,createProcessJourneyLedger:()=>ji,createServiceLevelController:()=>Di,createServiceResourcePoolController:()=>Oi,cubicPath:()=>uo,cubicPoint:()=>co,cubicTangent:()=>lo,curvedEdgePath:()=>ro,cyclicRangeContains:()=>Oo,dagreLayout:()=>et,degree:()=>Cr,demandForecastRows:()=>Bn,diagnoseTokenEncoding:()=>V,dimFor:()=>y,egoNetwork:()=>zr,estimateLabelWidth:()=>Yo,extractTooltipDatum:()=>vr,fanOutBend:()=>so,flextreeLayout:()=>Je,forceFieldRegion:()=>li,forceLayout:()=>W,forceLayoutAsync:()=>Gr,formatMw:()=>Kn,formatReservePct:()=>Qn,formatTooltipValue:()=>$r,galtonPegs:()=>aa,generateTokens:()=>H,geoAreaHitTarget:()=>zo,geoHitTarget:()=>Lo,glyphExtent:()=>dr,glyphFractionClipRect:()=>fr,glyphPlacement:()=>ur,gridEventAnnotations:()=>Xn,groupBy:()=>m,groupCompletionRows:()=>Vr,hatchFill:()=>gt,hitTargetPoint:()=>No,hitTargetRect:()=>To,hullFromBoxes:()=>mt,intervalLanesLayout:()=>oo,isometricLandmarkLayout:()=>Ve,isotypeBoltGlyph:()=>le,isotypeBusGlyph:()=>ue,isotypeChipGlyph:()=>ce,isotypeGhost:()=>ae,isotypeInk:()=>re,isotypeNetworkGlyphs:()=>fe,isotypePaper:()=>ie,isotypePersonGlyph:()=>he,isotypePersonPath:()=>de,isotypeServerGlyph:()=>se,layoutChipStrip:()=>Bo,layoutSequence:()=>Do,layoutTokenGrid:()=>_,legendGroupsFrom:()=>xr,legendSwatches:()=>br,lineageDagLayout:()=>it,linearAxis:()=>yt,makeShade:()=>w,marimekkoLayout:()=>Ot,markCallout:()=>xt,matchesHighlight:()=>g,mean:()=>S,membraneRegion:()=>ni,mermaidDagLayout:()=>ut,mobileAnnotationStrategy:()=>wa,mobileAreaChartRecipe:()=>Aa,mobileBrushAlternatives:()=>za,mobileChartFamilyRecipe:()=>La,mobileGeoChartRecipe:()=>Ca,mobileLineChartRecipe:()=>$a,mobileNetworkChartRecipe:()=>ja,mobileOrdinalChartRecipe:()=>Sa,mobileScatterplotRecipe:()=>Ia,mobileSmallMultipleRecipe:()=>Na,mulberry32:()=>F,netEnsembleLayout:()=>Ct,networkHitTarget:()=>Eo,nonNegativeFinite:()=>A,normalizePoint:()=>sr,normalizeScores:()=>Rr,normalizeTokenEncoding:()=>B,orderByGroupDegree:()=>ua,orthogonalEdgePath:()=>io,packIntervals:()=>eo,packSpanLevels:()=>Go,packedClusterMatrix:()=>Ft,parallelCoordinatesLayout:()=>Ht,partitionSharedEdges:()=>Xo,physicsReferenceEnvelope:()=>Mi,pointMagnitude:()=>ar,polarToXY:()=>Qo,portalRegion:()=>si,pressureFieldRegion:()=>ii,processChrome:()=>Ji,processJourneyRows:()=>Ni,processLaneWalls:()=>di,processStageLayout:()=>Jr,processStageRegions:()=>ti,processVolumePolygons:()=>Kr,proximityProblem:()=>Wr,radiusScale:()=>er,readField:()=>h,rectCollide:()=>ho,regionCountsToProjectionRows:()=>_r,reserveAnnotationBands:()=>_n,reserveMarginPct:()=>Yn,reserveSeries:()=>Gn,ringArcPath:()=>tr,roundedEnclosure:()=>ht,routeSurfaceRegion:()=>ri,runLengthEncode:()=>Ro,runs:()=>Fo,scaleArcBand:()=>Ho,scalePoint:()=>ir,sedimentBake:()=>ca,selectCyclicRange:()=>qo,selectIsometricLandmarks:()=>_e,shade:()=>M,shortestArcDelta:()=>Po,shortestPath:()=>Lr,signatureKey:()=>x,spanArcPath:()=>_o,spanArcPeakY:()=>Vo,spawnFromTokens:()=>sa,stackFuelSeries:()=>Dn,stageTargetInVolume:()=>Ur,subtractPoints:()=>rr,suggestTokenEncoding:()=>K,summarizeOperatingPoint:()=>Vn,symbolExtent:()=>oe,symbolPathString:()=>ee,symbolRadius:()=>te,thresholdBandsForReserve:()=>Hn,tightestHours:()=>Un,tokenLayer:()=>Se,tokenTaskIntentToCapabilityIntents:()=>U,unitize:()=>z,unitizeRange:()=>T,unwrapDatum:()=>f,updateProcessJourney:()=>Ci,useCustomLayoutSelection:()=>Fe,waffleLayout:()=>j,withAlpha:()=>I,wordTrailsLayout:()=>Ao,wordTrailsProgressiveReveal:()=>yo,wrapValue:()=>Wo,xyToAngle:()=>Zo}),module.exports=(e=l,s(n({},"__esModule",{value:!0}),e));var u=require("d3-interpolate");function d(e){return"function"==typeof e?e:t=>t[e]}function h(e,t,n){const o=e?.data,r=o?o[t]:void 0;if(null!=r)return r;const i=e?.[t];return null==i?n:i}function f(e){return null==e?null:e.data??e.datum??e}function m(e,t){const n=new Map;for(const o of e){const e=t(o),r=n.get(e);r?r.push(o):n.set(e,[o])}return n}function p(e){const t=Object.create(null);return e((e,n)=>{t[e]=n}),t}function g(e,t){if(!t)return!0;const n=Array.isArray(t)?t:[t],o=e;for(const e of n)if(null!=e.value&&o[e.field]+""!=e.value+"")return!1;return!0}function y(e,t={}){const n=t.baseOpacity??1;return t.highlight||t.predicate?!g(e,t.highlight)||t.predicate&&!t.predicate(e)?t.dimOpacity??.16:Math.min(1,n+(t.brighten??0)):n}function x(e){return e.join("|")}var b=class{constructor(e=12){this.maxSize=e,this.store=new Map}get(e){return this.store.get(e)}set(e,t){this.maxSize>this.store.size||this.store.clear(),this.store.set(e,t)}getOrCompute(e,t){const n=this.store.get(e);if(void 0!==n)return n;const o=t();return this.set(e,o),o}clear(){this.store.clear()}get size(){return this.store.size}};function w(e,t=.72){const n=(0,u.interpolateLab)(e,"#ffffff"),o=(0,u.interpolateLab)(e,"#000000"),r=(0,u.interpolateLab)(e,e)(0);return e=>{const i=0>e?0:e>1?1:e;return.5===i?r:.5>i?n(2*(.5-i)*t):o(2*(i-.5)*t)}}function M(e,t,n=.72){return w(e,n)(t)}function v(e){return p(t=>{for(const[n,o]of Object.entries(e))t(n,o)})}function k(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"item"}function $(e,t,n){return Math.max(t,Math.min(n,e))}function A(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}function S(e){if(0===e.length)return 0;let t=0;for(const n of e)t+=n;return t/e.length}function I(e,t){const n=$(t,0,1),o=e.trim().replace(/^#/,""),r=3===o.length?o.split("").map(e=>e+e).join(""):o;return/^[0-9a-fA-F]{6}$/.test(r)?`rgba(${parseInt(r.slice(0,2),16)}, ${parseInt(r.slice(2,4),16)}, ${parseInt(r.slice(4,6),16)}, ${n})`:e}var j=e=>{const t=e.config,n=t.rows??10,o=t.columns??10,r=t.gutter??2,i=n*o;if(0>=n||0>=o||0>=i)return{nodes:[]};const{plot:a}=e.dimensions;if(0>=a.width||0>=a.height)return{nodes:[]};const s=(a.width-r*(o-1))/o,c=(a.height-r*(n-1))/n;if(0>=s||0>=c)return{nodes:[]};const l=(null==(u=t.categoryAccessor)?null:"function"==typeof u?u:e=>e[u])??(()=>"_default");var u;const d=function(e){return null==e?null:"function"==typeof e?e:t=>Number(t[e])}(t.valueAccessor)??(()=>1),h=new Map,f=[];for(const t of e.data){const e=l(t)+"",n=Number(d(t)),o=Number.isFinite(n)?Math.max(0,n):0;h.has(e)||f.push(e),h.set(e,(h.get(e)??0)+o)}const m=Array.from(h.values()).reduce((e,t)=>e+t,0);if(0>=m)return{nodes:[]};let g;if(t.categoryOrder&&t.categoryOrder.length>0){const e=new Set,n=[];for(const o of t.categoryOrder)h.has(o)&&!e.has(o)&&(e.add(o),n.push(o));g=[...n,...f.filter(t=>!e.has(t))]}else g=f;if(0===g.length)return{nodes:[]};const y=g.map(e=>({cat:e,exact:(h.get(e)??0)/m*i})).map(e=>({...e,count:Math.floor(e.exact)})),x=y.reduce((e,t)=>e+t.count,0),b=y.map((e,t)=>({i:t,rem:e.exact-e.count})).sort((e,t)=>t.rem-e.rem);for(let e=0;i-x>e;e++)y[b[e%b.length].i].count+=1;const w="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",M="string"==typeof t.valueAccessor?t.valueAccessor:"value",v=(e,t,n)=>p(o=>{o("category",e),o("value",h.get(e)??0),o("share",(h.get(e)??0)/m),"category"!==w&&o(w,e),"value"!==M&&o(M,h.get(e)??0),o("cells",n),o("_waffleCategory",e),o("_waffleIndex",t)}),k=[];let $=0;for(const t of y){const i=e.resolveColor(t.cat);for(let e=0;t.count>e;e++)k.push({type:"rect",x:a.x+$%o*(s+r),y:a.y+(n-1-Math.floor($/o))*(c+r),w:s,h:c,style:{fill:i,stroke:"none"},datum:v(t.cat,$,t.count),group:t.cat,_transitionKey:`waffle-${t.cat}-${e}`}),$++}return{nodes:k}};function C(e,t,n){const o=Math.max(0,Math.floor(n?.minPerCategory??0)),r=e.reduce((e,t)=>e+Math.max(0,t.weight),0);if(0>=t||0>=r)return e.map(e=>({...e,exact:0,cells:0,remainder:0}));const i=e.map(e=>{const n=Math.max(0,e.weight)/r*t;return{...e,exact:n,cells:Math.max(o,Math.floor(n)),remainder:n-Math.floor(n)}});let a=i.reduce((e,t)=>e+t.cells,0);for(;a>t;){const e=i.filter(e=>e.cells>o).sort((e,t)=>t.cells-e.cells||e.remainder-t.remainder||e.key.localeCompare(t.key))[0];if(!e)break;e.cells--,a--}const s=[...i].sort((e,t)=>t.remainder-e.remainder||t.weight-e.weight||e.key.localeCompare(t.key));for(let e=0;t>a;e++)s[e%s.length].cells++,a++;return i}var N=1e-6;function L(e){return Number.isFinite(e)?Math.max(0,e):0}function z(e,t){const n=Number(t.unit),o=L(e),r=t.maxUnits??1/0,i=t.minFraction??0;if(0>=n||0>=r||0>=o)return{units:[],unit:n>0?n:0,total:o,shown:0,overflow:o>0&&!(r>0)};const a=Math.ceil(o/n-N),s=Math.min(r,a),c=a>r,l=[];for(let e=0;s>e;e+=1){const t=e*n;let r=Math.min(1,Math.max(0,(Math.min(o,t+n)-t)/n));N>1-r&&(r=1),l.push({index:e,fraction:r,start:t,end:t+r*n,value:r*n})}const u=l[l.length-1];u&&i>u.fraction&&1>u.fraction&&l.pop();const d=l.reduce((e,t)=>e+t.value,0);return{units:l,unit:n,total:o,shown:d,overflow:c}}function T(e,t,n){const o=z(e,n),r=Math.max(L(t),o.total);if(o.total>=r)return{...o,rangeUnits:[],rangeTotal:o.total};const i=z(r,{unit:n.unit,maxUnits:n.maxUnits}),a=i.unit>0?o.total/i.unit:0,s=Math.floor(a+N);let c=Math.min(1,Math.max(0,a-s));N>c&&(c=0);const l=[];for(const e of i.units)s>e.index||(e.index===s&&c>0?e.fraction-c>N&&l.push({...e,startFraction:c,start:e.index*i.unit+c*i.unit,value:(e.fraction-c)*i.unit}):l.push({...e,startFraction:0}));return{...o,overflow:o.overflow||i.overflow,rangeUnits:l,rangeTotal:r}}var E=require("d3-force");function F(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}}var R=1e3;function W(e,t,n={}){const o=n.iterations??260,r=n.repulsion??5200,i=n.linkDistance??165,a=n.linkStrength??.045,s=n.centerStrength??.018,c=n.damping??.84,l=n.nodeRadius??12,u=n.nodePadding??3,d=n.inset??.06,h=F(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 m=R/2,p=e.map(e=>({id:e.id,data:e,x:200+600*h(),y:200+600*h()})),g=new Set(e.map(e=>e.id)),y=t.filter(e=>g.has(e.source)&&g.has(e.target)).map(e=>({source:e.source,target:e.target}));if(o>0){const e=(0,E.forceSimulation)(p).randomSource(h).alphaDecay(1-Math.pow(.001,1/o)).velocityDecay(Math.max(0,Math.min(1,1-c))).force("charge",(0,E.forceManyBody)().strength(e=>{const t=f.get(e.id)??0;return 2.5*-Math.sqrt(r)*Math.sqrt(t+1)})).force("collide",(0,E.forceCollide)(e=>(e=>"function"==typeof l?l(e.data):l)(e)+u).strength(.9).iterations(2)).force("center",(0,E.forceCenter)(m,m).strength(.8)).force("x",(0,E.forceX)(m).strength(s)).force("y",(0,E.forceY)(m).strength(s));y.length>0&&e.force("link",(0,E.forceLink)(y).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;o>t;t+=1)e.tick()}let x=1/0,b=1/0,w=-1/0,M=-1/0;for(const e of p){const t=e.x??m,n=e.y??m;x>t&&(x=t),b>n&&(b=n),t>w&&(w=t),n>M&&(M=n)}const v=w-x,k=M-b,$={};for(const e of p)$[e.id]={x:0===v?.5:d+((e.x??m)-x)/v*(1-2*d),y:0===k?.5:d+((e.y??m)-b)/k*(1-2*d)};return $}var P=80,O=100;function q(e){return e?e.map(Number).filter(Number.isFinite):[]}function D(e){if("fixed-denominator"===e.countStrategy)return 1/0;const t=e.maxTokens??1/0;return t>0?Math.floor(t):0}function B(e){const t=e.unitValue??e.unit,n=e.icon??e.token;return{...e,...null!=t&&{unitValue:t},...null!=n&&{icon:n}}}function Y(e){if(e.samples)return q(e.samples);if(!e.data||!e.valueAccessor)return[];const t=e.valueAccessor;return e.data.map(e=>"function"==typeof t?t(e):Number(e[t])).filter(Number.isFinite)}function G(e,t,n,o={}){return{index:t,tokenType:e.tokenType,tokenSemantics:e.tokenSemantics,countStrategy:e.countStrategy,fraction:1,startFraction:0,value:n,start:t,end:t+n,unitValue:e.unitValue,unitMeaning:e.unitMeaning,...o}}function H(e,t){const n=B(t),o=function(e){return"number"==typeof e?{value:e}:Array.isArray(e)?{samples:q(e),data:e}:e}(e);let r,i,a,s,c,l,u,d=0,h=!1;if("unitized"===n.countStrategy){c=n.unitValue??1;const e={unit:c,maxUnits:n.maxTokens,minFraction:n.minFraction},t=null==o.rangeValue?z(A(o.value),e):T(A(o.value),A(o.rangeValue),e);r=t.units.map(e=>G(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:t.unit})),i=t.total,d=t.shown,h=t.overflow,null!=o.rangeValue&&(l=t.rangeTotal,u=t.rangeUnits.map(e=>G(n,e.index,e.value,{fraction:e.fraction,startFraction:e.startFraction,start:e.start,end:e.end,unitValue:t.unit,range:"scenario"})))}else if("fixed-denominator"===n.countStrategy){s=Math.floor(A(o.denominator??n.denominator)),a=A(o.numerator??n.numerator??o.value);const e=Math.min(s,Math.max(0,Math.round(a)));r=Array.from({length:s},(t,o)=>G(n,o,1,{highlighted:e>o,start:o,end:o+1})),i=s,d=r.length,h=!1}else if("quantile"===n.countStrategy){const e=Y(o).sort((e,t)=>e-t),t=Math.max(0,Math.floor(n.tokenCount??50)),a=e.length>0?Math.min(t,D(n)):0;r=Array.from({length:a},(t,o)=>{const r=(o+.5)/a,i=function(e,t){const n=e.length;if(0===n)return 0;if(1===n)return e[0];const o=(n-1)*Math.min(1,Math.max(0,t)),r=Math.floor(o),i=o-r;return e[r]*(1-i)+e[Math.ceil(o)]*i}(e,r);return G(n,o,i,{sample:i,quantile:r,start:i,end:i})}),i=e.length,d=r.length,h=e.length>0&&t>r.length}else if("sample"===n.countStrategy||"posterior-sample"===n.countStrategy||"random-sample"===n.countStrategy){const e=Y(o),t=Math.min(e.length,Math.max(0,Math.floor(n.tokenCount??e.length))),a=Math.min(t,D(n));r=("random-sample"===n.countStrategy?function(e,t=1){const n=Array.from({length:e},(e,t)=>t),o=F(Math.floor(t)||1);for(let e=n.length-1;e>0;e-=1){const t=Math.floor(o()*(e+1)),r=n[e];n[e]=n[t],n[t]=r}return n}(e.length,n.seed).slice(0,a):Array.from({length:a},(t,n)=>Math.floor(n/Math.max(1,a-1)*(e.length-1)))).map((t,o)=>{const r=e[t];return G(n,o,r,{sample:r,start:r,end:r})}),i=e.length,d=r.length,h=t>r.length}else{const e=o.data;if(e&&null==o.value)r=e.map((e,t)=>G(n,t,1,{datum:e})),i=e.length;else{const e=z(A(o.value),{unit:1,maxUnits:n.maxTokens,minFraction:n.minFraction});r=e.units.map(e=>G(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:1})),i=e.total,d=e.shown,h=e.overflow}if(e&&null==o.value){const e=function(e,t){const n=D(t);return e.length>n?{tokens:e.slice(0,n),overflow:!0}:{tokens:e,overflow:!1}}(r,n);r=e.tokens,d=r.length,h=e.overflow}}return{tokens:r,encoding:n,total:i,shown:d,overflow:h,numerator:a,denominator:s,unitValue:c,rangeTotal:l,rangeTokens:u,diagnostics:V(n,{visibleTokens:r.length+(u?.length??0)})}}function _(e,t={}){const n=Array.isArray(e)?e:e.tokens,o=n.length;if(0===o)return[];const r=t.flow??"row",i=t.cellWidth??16,a=t.cellHeight??i,s=t.gutter??2,c=t.anchor??[.5,.5],l=Math.max(1,Math.floor(t.columns??Math.ceil(t.rows?o/t.rows:Math.sqrt(o)))),u=Math.max(1,Math.floor(t.rows??Math.ceil(o/l))),d="row"===r?Math.max(u,Math.ceil(o/l)):u,h="column"===r?Math.max(l,Math.ceil(o/u)):l,f=t.x??0,m=t.y??0;return n.map((e,n)=>{let o,p;return"column"===r?(p=Math.floor(n/u),o=n%u):(o=Math.floor(n/l),p=n%l),"left"===t.columnDirection&&(p=h-1-p),"up"===t.rowDirection&&(o=d-1-o),{...e,row:o,column:p,x:f+p*(i+s)+c[0]*i,y:m+o*(a+s)+c[1]*a}})}function V(e,t={}){const n=[],o=e.tokenSemantics,r=e.countStrategy,i=t.maxRecommendedTokens??("fixed-denominator"!==r||A(e.denominator)>O?P:O);return o||n.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),r||n.push({code:"MISSING_COUNT_STRATEGY",severity:"warning",message:"Every tokenized encoding should state how token counts are produced."}),"icon"!==e.tokenType&&"glyph"!==e.tokenType||"icon-only"!==e.labelPolicy&&"token-only"!==e.labelPolicy||n.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=t.visibleTokens&&t.visibleTokens>i&&n.push({code:"TOO_MANY_VISIBLE_TOKENS",severity:"warning",message:`This encoding renders ${t.visibleTokens} visible tokens. Consider unitizing, sampling, or a hybrid bar/token view.`}),"decorative"!==o||"icon"!==e.tokenType&&"glyph"!==e.tokenType||n.push({code:"DECORATIVE_PICTOGRAPHS",severity:"warning",message:"Decorative pictographs can harm recall and speed when they do not clarify the data."}),"unitized-measure"===o&&r&&"unitized"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Unitized measures should use the unitized count strategy so each token has a stable value."}),"risk-case"===o&&r&&"fixed-denominator"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),"possible-outcome"!==o&&"posterior-sample"!==o&&"hypothetical-case"!==o||!r||"quantile"===r||"sample"===r||"posterior-sample"===r||"random-sample"===r||n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===o&&"unitized"===r&&null==e.unitValue&&null==e.unit&&n.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"!==o||"unitized"!==r||e.unitMeaning||n.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),n}function X(e){return"measure"===e?"precise-comparison":"estimate probability"===e?"probability-estimation":"understand risk"===e?"risk-communication":"remember"===e?"memory":"decide"===e?"support-decision":e}function U(e){const t=X(e);return"precise-comparison"===t?["compare-categories","rank"]:"probability-estimation"===t?["distribution"]:"risk-communication"===t?["part-to-whole","distribution"]:"frequency-reasoning"===t?["distribution","compare-categories"]:"memory"===t||"editorial-engagement"===t?["compare-categories"]:"public-explanation"===t||"support-decision"===t?["distribution","compare-categories"]:["compare-categories"]}function K(e){const t=X(e.taskIntent),n="small"===(o=e.availableSpace)?25:"large"===o?100:50;var o;if("precise-comparison"===t)return{recommendedEncoding:"bar-or-line",rationale:"Use continuous position/length encodings when precise magnitude comparison is the primary task.",warnings:[],alternatives:["hybrid-bar-token","unitized-measure"]};if("probability-estimation"===t){const e={tokenType:"dot",tokenSemantics:"possible-outcome",countStrategy:"quantile",tokenCount:n,layout:"dotplot",labelPolicy:"text-plus-token"};return{recommendedEncoding:"quantile-dotplot",tokenEncoding:e,rationale:"This task asks readers to estimate probability from a distribution. Quantile tokens turn probability mass into countable possible outcomes.",warnings:V(e),alternatives:["cdf-with-threshold","density-with-threshold"]}}if("risk-communication"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"risk-case",countStrategy:"fixed-denominator",denominator:100,layout:"waffle",labelPolicy:"text-plus-token"};return{recommendedEncoding:"fixed-denominator-icon-array",tokenEncoding:t,rationale:"Risk is often clearer as natural frequency: highlighted cases out of a fixed denominator.",warnings:V(t,{visibleTokens:100,maxRecommendedTokens:100}),alternatives:["labeled-percent","bar-with-risk-threshold"]}}if("memory"===t||"editorial-engagement"===t){const t={tokenType:e.concreteEntity?"glyph":"icon",icon:e.concreteEntity,tokenSemantics:"unitized-measure",countStrategy:"unitized",unitValue:1,layout:"grid",labelPolicy:"text-plus-token",unitMeaning:e.concreteEntity?"one token represents a unit of "+e.concreteEntity:"one token represents one unit"};return{recommendedEncoding:"semantic-isotype",tokenEncoding:t,rationale:"Semantic tokens are useful when the chart needs to make a topic concrete and memorable.",warnings:V(t),alternatives:["labeled-bar","hybrid-bar-token"]}}if("frequency-reasoning"===t||"public-explanation"===t||"support-decision"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"distribution"===e.dataType?"possible-outcome":"unitized-measure",countStrategy:"distribution"===e.dataType?"quantile":"unitized",unitValue:"distribution"===e.dataType?void 0:1,tokenCount:n,layout:"distribution"===e.dataType?"dotplot":"bar-segment",labelPolicy:"text-plus-token",unitMeaning:"distribution"===e.dataType?void 0:"one token represents one unit interval"};return{recommendedEncoding:"hybrid-continuous-token",tokenEncoding:t,rationale:"A hybrid view preserves measurement while adding countable tokens for explanation and decisions.",warnings:V(t),alternatives:["bar-or-line","quantile-dotplot","fixed-denominator-icon-array"]}}return{recommendedEncoding:"bar-or-line",rationale:"Use continuous encodings unless the task needs frequency, risk, memory, or outcome reasoning.",warnings:[],alternatives:["unitized-measure","quantile-dotplot","fixed-denominator-icon-array"]}}var Q=require("d3-shape"),Z={circle:Q.symbolCircle,square:Q.symbolSquare,triangle:Q.symbolTriangle,diamond:Q.symbolDiamond,star:Q.symbolStar,cross:Q.symbolCross,wye:Q.symbolWye},J=["circle","triangle","diamond","star","square","chevron","cross","wye"];function ee(e,t,n){if(n)return n;const o=e??"circle";return"chevron"===o?function(e){const t=1.5*te(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,Q.symbol)(Z[o]??Q.symbolCircle,Math.max(1,t))()??""}function te(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var ne=new Map;function oe(e,t,n){if(!n&&"circle"===(e??"circle"))return te(t);const o=n?"p:"+n:`${e}:${Math.round(t)}`,r=ne.get(o);if(null!=r)return r;const i=(n??ee(e,t)).match(/-?\d*\.?\d+(?:e-?\d+)?/gi);let a=0;if(i)for(let e=0;i.length>e+1;e+=2){const t=+i[e],n=+i[e+1],o=Math.sqrt(t*t+n*n);o>a&&(a=o)}return a>0||(a=te(t)),ne.size>512&&ne.clear(),ne.set(o,a),a}var re="#334155",ie="#f8fafc",ae="#cbd5e1",se={viewBox:[40,40],anchor:[.5,1],parts:[{d:"M8 3h24v34H8z",fill:"color"},{d:"M12 9h16v5H12zM12 18h16v5H12zM12 27h16v5H12z",fill:"accent"},{d:"M23.8 11.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 20.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 29.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0",fill:"color"}]},ce={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M10 8h20a2 2 0 0 1 2 2v20a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2z",fill:"color"},{d:"M15 15h10v10H15z",fill:"accent"},{d:"M7 2v6M14 2v6M21 2v6M28 2v6M7 32v6M14 32v6M21 32v6M28 32v6M2 7h6M2 14h6M2 21h6M2 28h6M32 7h6M32 14h6M32 21h6M32 28h6",fill:"none",stroke:"color",strokeWidth:3}]},le={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M23 1L7 23h10l-3 16 19-25H22z",fill:"color"}]},ue={viewBox:[48,40],anchor:[.5,.78],parts:[{d:"M7 12c0-4 3-7 7-7h20c4 0 7 3 7 7v15H7z",fill:"color"},{d:"M11 15h26v8H11z",fill:"accent",opacity:.9},{d:"M12 27h7v4h-7zM29 27h7v4h-7z",fill:"accent",opacity:.95},{d:"M12 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0M28 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0",fill:"color",stroke:"accent",strokeWidth:1.8},{d:"M5 13h4v8H5zM39 13h4v8h-4z",fill:"color"}]},de="M 9.12,3.34 C 8.28,3.29 7.44,3.40 6.64,3.69 4.17,3.63 1.97,5.37 0.91,7.51 -1.32,11.80 2.55,17.76 8.19,16.55 11.62,16.13 15.55,14.04 16.17,10.33 16.38,6.53 12.77,3.52 9.12,3.34 Z M 9.35,19.86 C 8.89,19.84 8.41,19.92 7.92,20.11 5.12,21.55 3.72,24.68 2.79,27.54 2.32,29.86 0.87,32.04 1.36,34.49 1.63,37.60 8.04,38.95 8.04,38.95 8.04,38.95 14.67,39.65 16.50,36.33 17.16,31.95 16.34,27.23 14.01,23.42 13.07,21.69 11.36,19.92 9.35,19.86 Z",he={viewBox:[18,40],anchor:[.5,1],parts:[{d:de,fill:"color",stroke:"color",strokeWidth:1.4}]},fe={server:se,chip:ce,bolt:le,bus:ue,person:he},me="var(--semiotic-primary, #4e79a7)",pe="var(--semiotic-border, #d1d5db)",ge="var(--semiotic-secondary, #9ca3af)",ye="var(--semiotic-bg, #ffffff)";function xe(e){return"object"==typeof e&&null!==e&&"tokens"in e&&"encoding"in e}function be(e,t,n){return"function"==typeof e?e(t)??n:e??n}function we(e,t){return"function"==typeof e?e(t):e}function Me(e){return e.sample??e.value??e.index}var ve=new Set(J);function ke(e,t){return void 0!==t.datum?be(t.datum,e,null):e.datum??null}function $e(e,t){return{fill:!1!==e.highlighted?"scenario"===e.range?be(t.rangeColor,e,ge):be(t.color,e,me):be(t.inactiveColor,e,pe),stroke:"none",...we(t.style,e)??{}}}function Ae(e,t){const n=we(t.pointId,e)??(t.idPrefix?`${t.idPrefix}-${"scenario"===e.range?"range-":""}${e.index}`:void 0);return{datum:ke(e,t),accessibleDatum:we(t.accessibleDatum,e),accessibility:we(t.accessibility,e),pointId:n,_transitionKey:n}}function Se({input:e,encoding:t,options:n={}}){if(!xe(e)&&!t)throw Error("tokenLayer requires an encoding when input is not a TokenSet.");const o=xe(e)?{...e,encoding:B(e.encoding)}:H(e,t),r=function(e,t){const n=t.includeRange&&e.rangeTokens?[...e.tokens,...e.rangeTokens]:e.tokens;if(t.positionToken)return function(e,t){const n=t.positionToken;return n?e.map((t,o)=>{const r=n(t,o,e);return{...t,x:r.x,y:r.y,row:r.row??o,column:r.column??0}}):[]}(n,t);const o=t.layout??e.encoding.layout??"grid";if("quantile-strip"===o)return function(e,t){if(0===e.length)return[];const n=t.x??0,o=t.y??0,r=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),i=t.gutter??2,a=Math.max(1,Math.floor(t.rows??1)),s=e.map(Me),c=Math.min(...s),l=Math.max(...s)-c||1;return e.map((s,u)=>{const d=Me(s),h=u%a,f=t.valueToX?t.valueToX(d,s):n+(d-c)/l*(t.width??12*Math.max(1,e.length-1)),m=t.valueToY?t.valueToY(d,s):o+h*(r+i);return{...s,x:f,y:m,row:h,column:u}})}(n,t);if("dotplot"===o)return function(e,t){if(0===e.length)return[];const n=t.x??0,o=t.y??0,r="number"==typeof t.tokenSize?t.tokenSize:12,i=t.gutter??2,a=t.cellWidth??r+i,s=t.cellHeight??r+i,c=e.map(Me),l=Math.min(...c),u=Math.max(...c)-l||1,d=new Map;return e.map(r=>{const i=Me(r),c=t.valueToX?t.valueToX(i,r):n+(i-l)/u*(t.width??Math.max(1,e.length-1)*a),h=Math.round((c-n)/Math.max(1,a)),f=d.get(h)??0;d.set(h,f+1);const m=t.valueToY?t.valueToY(i,r):o+f*s;return{...r,x:n+h*a,y:m,row:f,column:h}})}(n,t);if("bar-segment"===o){if(!t.valueToX)throw Error('tokenLayer layout "bar-segment" requires valueToX and optionally valueToY.');return function(e,t){if(!t.valueToX)return[];const n=t.y??0,o=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),r=t.anchor??[.5,.5];return e.map((e,i)=>{const a=Number.isFinite(e.start)?e.start:Me(e),s=(a+(Number.isFinite(e.end)?e.end:a+e.value))/2,c=t.valueToY?t.valueToY(s,e):n+r[1]*o;return{...e,x:t.valueToX(s,e),y:c,row:0,column:i}})}(n,t)}if("beeswarm"===o||"small-multiple"===o)throw Error(`tokenLayer layout "${o}" is not implemented yet; use row, column, stack, grid, waffle, dotplot, quantile-strip, bar-segment with valueToX, or positionToken.`);const r="number"==typeof t.tokenSize?t.tokenSize:void 0,i=t.cellWidth??r??12,a=t.cellHeight??r??i,s="row"===o?Math.max(1,n.length):"column"===o||"stack"===o?1:"waffle"===o&&"fixed-denominator"===e.encoding.countStrategy&&100===e.denominator?10:function(e,t,n){if(t.columns)return t.columns;if(t.width&&n>0){const e=t.gutter??2;return Math.max(1,Math.floor((t.width+e)/(n+e)))}return e.length>0?Math.ceil(Math.sqrt(e.length)):1}(n,t,i);return _(n,{...t,columns:s,cellWidth:i,cellHeight:a})}(o,n).filter(e=>!n.include||n.include(e));return{tokenSet:o,positionedTokens:r,nodes:r.map(e=>function(e,t,n){if("dot"===n.tokenType)return function(e,t){const n=be(t.tokenSize,e,12);return{type:"point",x:e.x,y:e.y,r:be(t.radius,e,n/2),style:$e(e,t),...Ae(e,t)}}(e,t);const o=we(t.glyph,e)??function(e){if(e)return fe[e]}(n.icon);if(o)return function(e,t,n){const o=$e(e,n),r=be(n.tokenSize,e,12);return{type:"glyph",x:e.x,y:e.y,size:r,glyph:t,color:(o.fill??me)+"",accent:be(n.accent,e,ye),fraction:1>e.fraction?e.fraction:void 0,fractionStart:e.startFraction>0?e.startFraction:void 0,fractionDirection:be(n.fractionDirection,e,"horizontal"),ghostColor:1>e.fraction?we(n.ghostColor,e)??pe:void 0,rotation:we(n.rotation,e),style:o,...Ae(e,n)}}(e,o,t);const r=(i=n.icon)&&ve.has(i)?i:void 0;var i;return function(e,t){const n=be(t.tokenSize,e,12);return{type:"symbol",x:e.x,y:e.y,size:Math.PI*Math.max(1,n/2)**2,symbolType:be(t.symbolType,e,"circle"),path:we(t.symbolPath,e),rotation:we(t.rotation,e),style:$e(e,t),...Ae(e,t)}}(e,r&&null==t.symbolType?{...t,symbolType:r}:t)}(e,n,o.encoding))}}var Ie=require("d3-interpolate"),je=864e5,Ce=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height)return{nodes:[]};const o=e=>{const n="function"==typeof t.dateAccessor?t.dateAccessor(e):e[t.dateAccessor];return n instanceof Date?n:new Date(n)},r=e=>{const n="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor];return Number(n)},i=new Map;let a=null;for(const t of e.data){const e=o(t);if(!isFinite(e.getTime()))continue;null==a&&(a=e.getUTCFullYear());const n=Ne(e),s=r(t);i.set(n,(i.get(n)??0)+(Number.isFinite(s)?s:0))}const s=t.year??a??(new Date).getUTCFullYear();let c=1/0,l=-1/0;for(const e of i.values())c>e&&(c=e),e>l&&(l=e);c===1/0&&(c=0,l=0);const[u,d]=t.colorRamp??[e.theme.semantic.surface??"#ebedf0",e.theme.semantic.primary??"#216e39"],h=e=>{if(l===c)return u;const t=(e-c)/(l-c);return(0,Ie.interpolateRgb)(u,d)(t)},f=t.gutter??2,m=t.labelInset??0,p=Math.min((n.width-m-53*f)/54,(n.height-6*f)/7);if(0>=p)return{nodes:[]};const g=new Date(Date.UTC(s,0,1)),y=g.getUTCDay(),x=new Date(g.getTime()-y*je),b=[];for(let e=0;54>e;e++)for(let t=0;7>t;t++){const o=new Date(x.getTime()+(7*e+t)*je);if(o.getUTCFullYear()!==s)continue;const r=Ne(o),a=i.get(r),c=null==a?u:h(a);b.push({type:"rect",x:n.x+m+e*(p+f),y:n.y+t*(p+f),w:p,h:p,style:{fill:c,stroke:"none"},datum:{date:o,value:a??0}})}return{nodes:b}};function Ne(e){return`${e.getUTCFullYear()}-${Le(e.getUTCMonth()+1)}-${Le(e.getUTCDate())}`}function Le(e){return 10>e?"0"+e:e+""}var ze=c(require("react")),Te=(require("react/jsx-runtime"),{isActive:!1,predicate:()=>!0}),Ee=ze.createContext(null);function Fe(){return ze.useContext(Ee)??Te}var Re=require("react/jsx-runtime"),We={resource:32,city:64},Pe=["#739b58","#83a964","#668d52","#8baa68"],Oe={land:"#78985c",ocean:"#4d8192",forest:"#4f7c4b",grassland:"#8eaa68",cropland:"#a6a568",wetland:"#668f79",urban:"#8d8a72",scrub:"#9b9665",bare:"#aa906a",snow:"#d8ddcf"},qe={land:"Open land",ocean:"Open ocean",forest:"Forest",grassland:"Grassland",cropland:"Cropland",wetland:"Wetland",urban:"Urban district",scrub:"Scrubland",bare:"Bare ground",snow:"Snow cover"},De=new Set(["city","culture","monument","faith","nature","knowledge","defense","arena","transport"]);function Be(e,t){if("function"==typeof e)return e;const n=e??t;return e=>e[n]}function Ye(e,t,n){return[111.32*(e-n.lon)*Math.cos((t+n.lat)/2*(Math.PI/180)),110.574*(t-n.lat)]}function Ge(e){const t=Math.max(3,Math.round(e??5));return t%2==0?t+1:t}function He(e){return De.has(e)?e:"monument"}function _e(e,t){const n=Ge(t.gridSize),o=Math.max(1,t.gridRadiusKm??75),r=2*o/n,i=Math.floor(n/2),a=Be(t.idAccessor,"id"),s=Be(t.nameAccessor,"name"),c=Be(t.longitudeAccessor,"lon"),l=Be(t.latitudeAccessor,"lat"),u=Be(t.kindAccessor,"kind"),d=t.candidatePriorityAccessor?Be(t.candidatePriorityAccessor,"priority"):()=>0,h=new Map;let f=null;for(const m of e){const e=Number(c(m)),p=Number(l(m));if(!Number.isFinite(e)||!Number.isFinite(p))continue;const g=(a(m)??`${e},${p}`)+"",y=(s(m)??g)+"",x=He(u(m)),[b,w]=Ye(e,p,t.center);if(Math.abs(b)>o||Math.abs(w)>o)continue;const M=Math.min(n-1,Math.max(0,Math.floor((b+o)/r))),v=Math.min(n-1,Math.max(0,Math.floor((o-w)/r))),k=(M+.5)*r-o,$=o-(v+.5)*r,A={...m,id:g,name:y,kind:x,lon:e,lat:p,distanceKm:Math.sqrt(b*b+w*w),row:v,column:M,cellDistanceSq:(b-k)**2+(w-$)**2,candidatePriority:Number(d(m))||0};(null!=t.centerId&&g===t.centerId||!f&&"city"===x||!f&&v===i&&M===i)&&(f=A);const S=`${v}:${M}`,I=h.get(S)??[];I.push(A),h.set(S,I)}const m=new Map;f&&m.set("city",1);const p=[];for(let e=0;n>e;e++)for(let t=0;n>t;t++){const n=`tile-${e}-${t}`,a=(t+.5)*r-o,s=o-(e+.5)*r;let c,l;if(e===i&&t===i&&f){c=f;const n=(h.get(`${e}:${t}`)??[]).filter(e=>e.id!==f?.id).sort((e,t)=>e.candidatePriority-t.candidatePriority||e.cellDistanceSq-t.cellDistanceSq||e.name.localeCompare(t.name));l=[f,...n]}else{const n=(h.get(`${e}:${t}`)??[]).filter(e=>e.id!==f?.id);n.sort((e,t)=>{const n=e.candidatePriority-t.candidatePriority;if(0!==n)return n;const o=m.get(e.kind)??0,i=m.get(t.kind)??0,a=r*r*.35;return e.cellDistanceSq+o*a-(t.cellDistanceSq+i*a)||e.name.localeCompare(t.name)}),c=n[0]??null,l=n}c&&m.set(c.kind,(m.get(c.kind)??0)+1),p.push({id:n,row:e,column:t,centerXKm:a,centerYKm:s,terrainIndex:Math.abs((17*e+31*t)%Pe.length),landmark:c,landmarks:l})}return p}var Ve=e=>{const t=Ge(e.config.gridSize),n=Math.max(20,e.config.tileWidth??80),o=Math.max(10,e.config.tileHeight??40),r=e.config.terrainColors?.length?e.config.terrainColors:Pe,i=e.dimensions.width/2,a=(e.dimensions.height-t*o)/2+o/2,s=_e(e.points,e.config).map(e=>({...e,x:i+n/2*(e.column-e.row),y:a+(e.column+e.row)*(o/2)}));return{nodes:s.map(t=>{const i=e.config.terrainByCell?.[t.id],a="string"==typeof i?{kind:i}:i,s="city"===t.landmark?.kind?"urban":a?.kind??"land",c=a?.fill??e.config.terrainPalette?.[s]??Oe[s],l=t.landmark?{...t.landmark,gridRow:t.row,gridColumn:t.column,cellId:t.id,terrainKind:s,terrainCoverage:a?.coverage,features:t.landmarks,featureCount:t.landmarks.length}:{id:t.id,name:qe[s],kind:"terrain",terrainKind:s,terrainCoverage:a?.coverage,gridRow:t.row,gridColumn:t.column,cellId:t.id,features:[],featureCount:0};return{type:"geoarea",pathData:(u=t.x,d=t.y,h=n,f=o,`M${u},${d-f/2}L${u+h/2},${d}L${u},${d+f/2}L${u-h/2},${d}Z`),centroid:[t.x,t.y],bounds:[[t.x-n/2,t.y-o/2],[t.x+n/2,t.y+o/2]],screenArea:n*o/2,style:{fill:a||"urban"===s?c:r[t.terrainIndex%r.length],stroke:"ocean"===s?"#315d6c":e.config.tileStroke??"#314934",strokeWidth:1},datum:l,group:t.landmark?.kind??s,interactive:!0};var u,d,h,f}),overlays:(0,Re.jsx)(Xe,{tiles:s,tileWidth:n,tileHeight:o,sprites:e.config.sprites,resourceSize:e.config.resourceSpriteSize??We.resource,citySize:e.config.citySpriteSize??We.city,showCityLabel:!1!==e.config.showCityLabel}),restyle:(e,t)=>t?.isActive&&e.datum&&"terrain"!==e.datum.kind?{fillOpacity:t.predicate(e.datum)?1:.28}:{fillOpacity:1}}};function Xe({tiles:e,tileWidth:t,tileHeight:n,sprites:o,resourceSize:r,citySize:i,showCityLabel:a}){const s=Fe(),c=e.filter(e=>e.landmark).sort((e,t)=>e.y-t.y||e.x-t.x);return(0,Re.jsxs)("g",{"aria-hidden":"true",pointerEvents:"none",children:[c.map(e=>{const a=e.landmark,c="city"===a.kind?i:r,l=e.y+n/2,u=s.isActive&&!s.predicate(a)?.28:1;return(0,Re.jsxs)("g",{opacity:u,children:[(0,Re.jsx)("ellipse",{cx:e.x,cy:e.y+.15*n,rx:.28*c,ry:.1*c,fill:"#17251d",opacity:.32}),(0,Re.jsx)(Ze,{kind:a.kind,href:o?.[a.kind],x:e.x-c/2,y:l-c,size:c}),e.landmarks.length>1&&(0,Re.jsx)(Ue,{x:e.x+.3*t,y:e.y-.19*n,count:e.landmarks.length-1,tileHeight:n})]},a.id)}),a&&c.filter(e=>"city"===e.landmark?.kind).map(e=>{const t=e.landmark.name.toUpperCase(),o=Math.max(56,6.4*t.length+14);return(0,Re.jsxs)("g",{transform:`translate(${e.x},${e.y+.72*n})`,children:[(0,Re.jsx)("rect",{x:-o/2,y:-7,width:o,height:14,rx:1,fill:"#17251d",opacity:.92}),(0,Re.jsx)("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:9,fontWeight:700,letterSpacing:.8,children:t})]},e.landmark.id+"-label")})]})}function Ue({x:e,y:t,count:n,tileHeight:o}){const r=Math.max(10,Math.min(15,.34*o)),i="+"+n,a=Math.max(r,i.length*r*.58);return(0,Re.jsxs)("g",{transform:`translate(${e},${t})`,children:[(0,Re.jsx)("rect",{x:-a/2,y:-r/2,width:a,height:r,rx:1,fill:"#17251d",stroke:"#f0d36d",strokeWidth:1}),(0,Re.jsx)("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:Math.max(7,.62*r),fontWeight:700,children:i})]})}var Ke={city:["..1111..","..1221..",".111111.",".133331.","11111111","13311331","14411441","11111111"],culture:["..1111..",".122221.","11111111",".133331.",".133331.",".133331.","11111111",".444444."],monument:["...11...","..1221..","..1221..","..1331..",".113311.",".133331.","11111111",".444444."],faith:["...11...","...11...","..1111..","...11...","..1221..",".133331.","11111111",".444444."],nature:["...11...","..1221..",".122221.","12222221",".133331.","...11...","..1441..",".144441."],knowledge:[".111111.","12211221","12211221","13311331","13311331","13311331","11111111",".444444."],defense:["11.11.11","11111111","12222221","12211221","13311331","13333331","11111111",".444444."],arena:["..1111..",".122221.","12333321","12344321","12344321","12333321",".122221.","..1111.."],transport:["...11...","..1221..",".122221.","11111111","..1331..","..1331..",".114411.","11444411"]},Qe={city:{1:"#29364a",2:"#d8b45b",3:"#b7693c",4:"#6d9fc5"},culture:{1:"#29364a",2:"#d5c9a3",3:"#9c6fb2",4:"#ece3c4"},monument:{1:"#29364a",2:"#d8cba8",3:"#9c8f79",4:"#ece3c4"},faith:{1:"#29364a",2:"#d9c36d",3:"#a877a5",4:"#ece3c4"},nature:{1:"#29364a",2:"#4f8a4e",3:"#79aa56",4:"#79583a"},knowledge:{1:"#29364a",2:"#d5c9a3",3:"#4f7da0",4:"#ece3c4"},defense:{1:"#29364a",2:"#a6a298",3:"#777b7f",4:"#d5c9a3"},arena:{1:"#29364a",2:"#cb8056",3:"#d8cba8",4:"#6d9fc5"},transport:{1:"#29364a",2:"#d8b45b",3:"#6d9fc5",4:"#ece3c4"}};function Ze({kind:e,href:t,x:n,y:o,size:r}){if(t)return(0,Re.jsx)("image",{href:t,x:n,y:o,width:r,height:r,preserveAspectRatio:"xMidYMax meet",style:{imageRendering:"pixelated"}});const i=Qe[e];return(0,Re.jsx)("svg",{x:n,y:o,width:r,height:r,viewBox:"0 0 8 8",shapeRendering:"crispEdges",children:Ke[e].flatMap((e,t)=>[...e].map((e,n)=>"."===e?null:(0,Re.jsx)("rect",{x:n,y:t,width:1,height:1,fill:i[e]},`${t}-${n}`)))})}var Je=e=>{const t=e.config,n=t.nodeWidth??80,o=t.nodeHeight??30,r=t.orientation??"vertical",i=t.edgeCurve??"curved",a=!1!==t.showLabels,s=t.labelAccessor??"id",c="function"==typeof s?s:e=>h(e,s,e.id??"")+"",l=new Map,u=[],d=[],f=e=>{const t=e.data??{};return{x:"number"==typeof t.x?t.x:e.x,y:"number"==typeof t.y?t.y:e.y,w:("number"==typeof t.width?t.width:e.width)??n,h:("number"==typeof t.height?t.height:e.height)??o}};for(const n of e.nodes){const{x:o,y:r,w:i,h:s}=f(n);null!=o&&null!=r&&(l.set(n.id,{x:o,y:r,w:i,h:s}),u.push({type:"rect",x:o-i/2,y:r-s/2,w:i,h:s,style:{fill:t.nodeFill??e.resolveColor(n.id),stroke:`var(--semiotic-surface, ${e.theme.semantic.surface??"#fff"})`,strokeWidth:1.5},datum:n,id:n.id,label:c(n)+""}),a&&d.push({x:o,y:r,text:c(n)+"",anchor:"middle",baseline:"middle",fontSize:11}))}const m=[];for(const t of e.edges){const n="string"==typeof t.target?t.target:t.target.id,o=l.get("string"==typeof t.source?t.source:t.source.id),a=l.get(n);if(!o||!a)continue;const s="vertical"===r?{x:o.x,y:o.y+o.h/2}:{x:o.x+o.w/2,y:o.y},c="vertical"===r?{x:a.x,y:a.y-a.h/2}:{x:a.x-a.w/2,y:a.y};if("line"===i)m.push({type:"line",x1:s.x,y1:s.y,x2:c.x,y2:c.y,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1},datum:t});else{const n=(s.y+c.y)/2,o=(s.x+c.x)/2;m.push({type:"curved",pathD:"vertical"===r?`M${s.x},${s.y} C${s.x},${n} ${c.x},${n} ${c.x},${c.y}`:`M${s.x},${s.y} C${o},${s.y} ${o},${c.y} ${c.x},${c.y}`,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1,fill:"none"},datum:t})}}return{sceneNodes:u,sceneEdges:m,labels:d}},et=e=>{const t=e.config,n=t.nodeWidth??100,o=t.nodeHeight??36,r=t.edgeStyle??"polyline",i=!1!==t.showLabels,a=t.labelAccessor??"label",s="function"==typeof a?a:e=>h(e,a,e.id??"")+"",c=new Map,l=[],u=[],d=e=>{const t=e.data??{};return{x:"number"==typeof t.x?t.x:e.x,y:"number"==typeof t.y?t.y:e.y,w:("number"==typeof t.width?t.width:e.width)??n,h:("number"==typeof t.height?t.height:e.height)??o}};for(const n of e.nodes){const{x:o,y:r,w:a,h:h}=d(n);null!=o&&null!=r&&(c.set(n.id,{x:o,y:r,w:a,h:h}),l.push({type:"rect",x:o-a/2,y:r-h/2,w:a,h:h,style:{fill:t.nodeFill??e.resolveColor(n.id),stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#888"})`,strokeWidth:1.5},datum:n,id:n.id,label:s(n)+""}),i&&u.push({x:o,y:r,text:s(n)+"",anchor:"middle",baseline:"middle",fontSize:11}))}const f=t.edgeStroke??`var(--semiotic-border, ${e.theme.semantic.border??"#666"})`,m=[];for(const t of e.edges){const e="string"==typeof t.target?t.target:t.target.id,n=c.get("string"==typeof t.source?t.source:t.source.id),o=c.get(e);if(!n||!o)continue;const i=t.data??{},a=Array.isArray(i.points)?i.points:t.points;if(a&&a.length>=2)if("smooth"!==r||3>a.length){const e="M"+a.map(e=>`${e.x},${e.y}`).join(" L ");m.push({type:"curved",pathD:e,style:{stroke:f,strokeWidth:1,fill:"none"},datum:t})}else{let e=`M${a[0].x},${a[0].y}`;for(let t=1;a.length-1>t;t++)e+=` Q${a[t].x},${a[t].y} ${(a[t].x+a[t+1].x)/2},${(a[t].y+a[t+1].y)/2}`;const n=a[a.length-1];e+=` T${n.x},${n.y}`,m.push({type:"curved",pathD:e,style:{stroke:f,strokeWidth:1,fill:"none"},datum:t})}else m.push({type:"line",x1:n.x,y1:n.y,x2:o.x,y2:o.y,style:{stroke:f,strokeWidth:1},datum:t})}return{sceneNodes:l,sceneEdges:m,labels:u}},tt=require("react/jsx-runtime"),nt={"topic-source":"#1f7a8c","topic-sink":"#b4451f","topic-bridge":"#4b5a82",processor:"#34344a",unknown:"#5a5a6a"},ot={internal:"var(--semiotic-border, #6b6b7d)","cross-subtopology":"var(--semiotic-info, #6a8caf)","topic-bridge":"var(--semiotic-secondary, #8b78c4)",back:"var(--semiotic-danger, #e0556b)"};function rt(e){return Array.isArray(e)?e.map((e,t)=>"string"==typeof e?{storeName:e,slotIndex:t}:{storeName:(e.storeName??"")+"",slotIndex:e.slotIndex??t}):[]}var it=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.layerAccessor??"x",r=t.rowAccessor??"y",i=t.partitionAccessor??"partition",a=t.semanticAccessor??"semantic",s=t.labelAccessor??"label",c=t.storesAccessor??"stores",l=t.backEdgeAccessor??"isBackEdge",u=t.edgeTypeAccessor??"edgeType",d={...nt,...t.partitionColors},f={...ot,...t.edgeColors},m=t.accentColor??"var(--semiotic-focus, #ffcc33)",p=t.borderColor??"var(--semiotic-border, #555)",g=t.dimOpacity??.14,y=t.edgeOpacity??.5,x=t.edgeWidth??1.25,b=t.backEdgeWidth??t.edgeWidth??1.5,w=!1!==t.showStoreChips,M=t.storeChipColor??"var(--semiotic-info, #6a8caf)";let v=t.layerCount,k=t.maxLayerSize;if(null==v||null==k){let t=0;const n=new Map;for(const r of e.nodes){const e=Math.round(Number(h(r,o,0)));t=Math.max(t,e),n.set(e,(n.get(e)??0)+1)}v=v??t+1,k=k??Math.max(1,...n.values())}const $=n.width/Math.max(1,v),A=n.height/Math.max(1,k);let S=Math.min(t.nodeWidth??172,Math.max(8,$-(t.minGapX??26))),I=Math.min(t.nodeHeight??54,Math.max(8,A-(t.minGapY??18)));const j=t.lod&&"auto"!==t.lod?t.lod:16>S?"dot":48>S?"icon":108>S?"compact":"full";if("dot"===j){const e=Math.min(S,I,11);S=e,I=e}const C=Math.max(1,n.width-S),N=Math.max(1,n.height-I),L=Math.max(1,k-1),z=e=>n.x+S/2+(v>1?e/(v-1):.5)*C,T=e=>n.y+I/2+(e+L/2)/L*N,E=t.reachableIds?new Set(t.reachableIds):null,F=t.selectedId??null,R=e.selection,W=new Map,P=new Map,O=[],q=[];for(const t of e.nodes){const e=t.id,n=Number(h(t,o,0)),l=Number(h(t,r,0)),u=h(t,i,"processor")+"",f=h(t,a,"processor")+"",y=h(t,s,e)+"",x=rt(h(t,c,[])),b=t.data??t,w=z(n),M=T(l);W.set(e,{cx:w,cy:M});const v=E?E.has(e):null,k=R?.isActive?R.predicate(b):null,$=null!==v?!v:null!==k&&!k;P.set(e,$);const A=null!=F&&e===F,C=$&&!A?g:1,N=d[u]??d.unknown;"dot"===j?O.push({type:"circle",cx:w,cy:M,r:S/2,style:{fill:N,opacity:C,stroke:A?m:"transparent",strokeWidth:A?2:0},datum:t,id:e,label:y}):(O.push({type:"rect",x:w-S/2,y:M-I/2,w:S,h:I,style:{fill:N,opacity:C,stroke:A?m:p,strokeWidth:A?3:1},datum:t,id:e,label:y}),q.push({id:e,cx:w,cy:M,partition:u,semantic:f,label:y,stores:x,opacity:C,selected:A,node:b}))}const D=[];for(const t of e.edges){const e="string"==typeof t.source?t.source:t.source.id,n="string"==typeof t.target?t.target:t.target.id,o=W.get(e),r=W.get(n);if(!o||!r)continue;const i=!!h(t,l,!1),a=h(t,u,"internal")+"",s=P.get(e)||P.get(n)?Math.min(y,1.4*g):y,c=i?f.back:f[a]??f.internal;let d;if(i){const e=o.cx,t=o.cy+I/2,n=r.cx,i=r.cy+I/2,a=Math.max(48,.28*Math.abs(e-n))+I;d=`M${e},${t} C${e},${t+a} ${n},${i+a} ${n},${i}`}else{const e=o.cx+S/2,t=o.cy,n=r.cx-S/2,i=r.cy,a=(e+n)/2;d=`M${e},${t} C${a},${t} ${a},${i} ${n},${i}`}const m={type:"curved",pathD:d,style:{stroke:c,strokeWidth:i?b:x,fill:"none",opacity:s,...i?{strokeDasharray:"5 4",strokeLinecap:"round"}:{}},datum:t};D.push(m)}const B=0===q.length?null:(0,tt.jsx)("g",{className:"lineage-dag-glyphs",children:q.map(e=>function(e,t){const{w:n,h:o,lod:r}=t,i="icon"===r?Math.min(n,o):Math.min(o-14,26),a="icon"===r?0:8+i+8,s=null!=t.renderIcon?t.renderIcon({semantic:e.semantic,partition:e.partition,size:i,color:t.partColors[e.partition]??t.partColors.unknown??"#5a5a6a",node:e.node}):function(e,t,n){const o=t.startsWith("topic")?"T":{source:"SR",sink:"SK",filter:"FL",map:"MP",aggregate:"AG",reduce:"RD","join-this":"JN","join-other":"JN",merge:"MG",suppress:"SP",select:"SE",tostream:"TS"}[e]??"PR";return(0,tt.jsxs)("g",{children:[(0,tt.jsx)("rect",{width:n,height:n,rx:4,fill:"rgba(255,255,255,0.08)",stroke:"rgba(255,255,255,0.18)"}),(0,tt.jsx)("text",{x:n/2,y:n/2+.5,textAnchor:"middle",dominantBaseline:"middle",fontSize:.42*n,fontWeight:700,fill:"var(--semiotic-text, #fff)",children:o})]})}(e.semantic,e.partition,i),c="full"===r,l="icon"!==r,u="full"===r&&t.showChips&&e.stores.length>0;return(0,tt.jsxs)("g",{transform:`translate(${e.cx-n/2}, ${e.cy-o/2})`,opacity:e.opacity,style:{pointerEvents:"none"},children:[(0,tt.jsx)("g",{transform:`translate(${"icon"===r?(n-i)/2:8}, ${(o-i)/2})`,children:s}),l&&(0,tt.jsx)("foreignObject",{x:a,y:c?o/2-12:o/2-9,width:Math.max(8,n-a-8),height:18,style:{pointerEvents:"none"},children:(0,tt.jsx)("div",{title:e.label,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, inherit)",fontSize:"full"===r?12.5:11.5,fontWeight:600,color:"var(--semiotic-text, #f4f4f8)",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.label})}),c&&(0,tt.jsx)("text",{x:a,y:o/2-16,dominantBaseline:"middle",fontSize:9.5,fontWeight:500,fill:"var(--semiotic-text-secondary, #b9b9c8)",style:{textTransform:"uppercase",letterSpacing:"0.04em"},children:t.typeLabel?t.typeLabel({semantic:e.semantic,partition:e.partition,node:e.node}):e.partition.startsWith("topic")?"topic":e.semantic}),u&&e.stores.map((e,n)=>(0,tt.jsx)("rect",{x:a+15*n,y:o-10,width:12,height:5,rx:1.5,fill:t.chipColor,children:(0,tt.jsx)("title",{children:e.storeName})},e.storeName+n))]},e.id)}(e,{w:S,h:I,lod:j,partColors:d,chipColor:M,showChips:w,renderIcon:t.renderIcon,typeLabel:t.typeLabel}))});return{sceneNodes:O,sceneEdges:D,overlays:B}},at=require("react/jsx-runtime");function st(e,t){return e.length>t?e.slice(0,Math.max(1,t-1))+"…":e}var ct={rect:"process",round:"process",stadium:"terminal",subroutine:"subprocess",cylinder:"database",circle:"connector",diamond:"decision",hexagon:"preparation",flag:"process"};function lt(e,t,n,o,r,i,a,s){const c=t-o/2,l=n-r/2,u={fill:i,stroke:a,strokeWidth:s};switch(e){case"diamond":return(0,at.jsx)("polygon",{points:`${t},${l} ${t+o/2},${n} ${t},${n+r/2} ${c},${n}`,...u});case"circle":return(0,at.jsx)("circle",{cx:t,cy:n,r:Math.min(o,r)/2,...u});case"stadium":case"round":return(0,at.jsx)("rect",{x:c,y:l,width:o,height:r,rx:"stadium"===e?r/2:8,ry:"stadium"===e?r/2:8,...u});case"hexagon":{const e=Math.min(.18*o,16);return(0,at.jsx)("polygon",{points:`${c+e},${l} ${t+o/2-e},${l} ${t+o/2},${n} ${t+o/2-e},${n+r/2} ${c+e},${n+r/2} ${c},${n}`,...u})}case"cylinder":{const e=Math.min(.16*r,8),t=`M${c},${l+e} a${o/2},${e} 0 0 1 ${o},0`;return(0,at.jsxs)("g",{children:[(0,at.jsx)("path",{d:`M${c},${l+e} a${o/2},${e} 0 0 0 ${o},0 v${r-2*e} a${o/2},${e} 0 0 1 ${-o},0 z`,...u}),(0,at.jsx)("path",{d:t,fill:"none",stroke:a,strokeWidth:s})]})}case"subroutine":{const e=Math.min(8,.08*o);return(0,at.jsxs)("g",{children:[(0,at.jsx)("rect",{x:c,y:l,width:o,height:r,rx:3,...u}),(0,at.jsx)("line",{x1:c+e,y1:l,x2:c+e,y2:l+r,stroke:a,strokeWidth:s}),(0,at.jsx)("line",{x1:c+o-e,y1:l,x2:c+o-e,y2:l+r,stroke:a,strokeWidth:s})]})}default:return(0,at.jsx)("rect",{x:c,y:l,width:o,height:r,rx:4,...u})}}var ut=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.direction??"TD",r="LR"===o||"RL"===o,i="BT"===o||"RL"===o,a=t.layerAccessor??"layer",s=t.rowAccessor??"row",c=t.labelAccessor??"label",l=t.shapeAccessor??"shape",u=t.edgeLabelAccessor??"label",d=t.nodeFill??"var(--semiotic-surface, #20242d)",f=t.nodeStroke??"var(--semiotic-border, #5a6573)",m=t.textColor??"var(--semiotic-text, #e6e6e6)",p=t.edgeColor??"var(--semiotic-text-secondary, #9aa0a6)",g=t.accentColor??"var(--semiotic-warning, #d49a00)";if(0===e.nodes.length)return{sceneNodes:[],overlays:null};const y=new Map;let x=0;for(const t of e.nodes){const e=Math.round(Number(h(t,a,0)));x=Math.max(x,e);const n=y.get(e)||[];n.push(t),y.set(e,n)}const b=x+1;let w=1;for(const e of y.values())e.sort((e,t)=>Number(h(e,s,0))-Number(h(t,s,0))),w=Math.max(w,e.length);const M=r?n.width:n.height,v=r?n.height:n.width,k=M/b,$=v/(w+1),A=Math.max(44,Math.min(t.nodeWidth??150,r?k-36:.92*$)),S=Math.max(26,Math.min(t.nodeHeight??46,r?.7*$:.5*k)),I=(r?A:S)/2+6,j=Math.max(1,M-2*I),C=e=>(r?n.x:n.y)+I+(b>1?(i?b-1-e:e)/(b-1)*j:j/2),N=new Map,L=[],z=[];for(const[e,t]of y)t.forEach((o,i)=>{const a=C(e),s=(r?n.y:n.x)+(i+1)/(t.length+1)*v,u=r?a:s,p=r?s:a,y=h(o,l,"rect")+"",x=h(o,c,o.id)+"";N.set(o.id,{cx:u,cy:p,shape:y}),L.push({type:"rect",x:u-A/2,y:p-S/2,w:A,h:S,style:{fill:"transparent",stroke:"transparent"},datum:{id:o.id,name:x,type:ct[y]??"process",shape:y},id:o.id,label:x}),z.push((0,at.jsxs)("g",{children:[lt(y,u,p,A,S,d,"diamond"===y?g:f,1.5),(0,at.jsx)("text",{x:u,y:p,textAnchor:"middle",dominantBaseline:"central",fontSize:13,fill:m,style:{pointerEvents:"none"},children:st(x,Math.max(4,Math.floor((A-12)/7)))})]},"n-"+o.id))});const T=[];return e.edges.forEach((e,t)=>{const n="string"==typeof e.target?e.target:e.target.id,o=N.get("string"==typeof e.source?e.source:e.source.id),i=N.get(n);if(!o||!i)return;const a=r?o.cx+A/2:o.cx,s=r?o.cy:o.cy+S/2,c=r?i.cx-A/2:i.cx,l=r?i.cy:i.cy-S/2,d=r?`M${a},${s} C${(a+c)/2},${s} ${(a+c)/2},${l} ${c},${l}`:`M${a},${s} C${a},${(s+l)/2} ${c},${(s+l)/2} ${c},${l}`,g=Math.atan2(l-s,c-a),y=c-9*Math.cos(g),x=l-9*Math.sin(g),b=4.5*-Math.sin(g),w=4.5*Math.cos(g),M=`${c},${l} ${y+b},${x+w} ${y-b},${x-w}`,v=h(e,u,void 0),k=(a+c)/2,$=(s+l)/2;T.push((0,at.jsxs)("g",{children:[(0,at.jsx)("path",{d:d,fill:"none",stroke:p,strokeWidth:1.4}),(0,at.jsx)("polygon",{points:M,fill:p}),"string"==typeof v&&v.length>0&&(0,at.jsxs)("g",{children:[(0,at.jsx)("rect",{x:k-6.5*v.length/2-4,y:$-9,width:6.5*v.length+8,height:18,rx:3,fill:"var(--semiotic-bg, #11151c)",stroke:f,strokeWidth:.75}),(0,at.jsx)("text",{x:k,y:$,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fill:m,style:{pointerEvents:"none"},children:v})]})]},"e-"+t))}),{sceneNodes:L,overlays:(0,at.jsxs)("g",{className:"mermaid-dag",children:[T,z]})}},dt=require("react/jsx-runtime");function ht(e){return(0,dt.jsx)("rect",{className:e.className,x:e.x,y:e.y,width:Math.max(0,e.width),height:Math.max(0,e.height),rx:e.radius??10,ry:e.radius??10,fill:e.fill??"none",stroke:e.stroke,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray,opacity:e.opacity??.6,style:{pointerEvents:"none"}},e.keyId)}function ft(e,t=0){let n=1/0,o=1/0,r=-1/0,i=-1/0;for(const t of e){const e=t.r??0;n>t.x-e&&(n=t.x-e),t.x+e>r&&(r=t.x+e),o>t.y-e&&(o=t.y-e),t.y+e>i&&(i=t.y+e)}return Number.isFinite(n)?{x:n-t,y:o-t,width:r-n+2*t,height:i-o+2*t}:null}function mt(e,t=0){if(!e.length)return null;const n="number"==typeof t?t:t.x??0,o="number"==typeof t?t:t.y??0;let r=1/0,i=1/0,a=-1/0,s=-1/0;for(const t of e){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))continue;if(!Number.isFinite(t.width)||!Number.isFinite(t.height))continue;const e=Math.max(0,t.width),n=Math.max(0,t.height);r>t.x&&(r=t.x),i>t.y&&(i=t.y),t.x+e>a&&(a=t.x+e),t.y+n>s&&(s=t.y+n)}return Number.isFinite(r)?{x:r-n,y:i-o,width:a-r+2*n,height:s-i+2*o}:null}function pt(e){const t=e.fontSize??12;return null!=e.maxWidth&&e.text.length*t*.56>e.maxWidth?null:(0,dt.jsx)("text",{className:e.className,x:e.x,y:e.y,textAnchor:e.anchor??"middle",dominantBaseline:e.baseline??"middle",fontSize:t,fontWeight:e.fontWeight,fill:e.color,style:{pointerEvents:"none"},children:e.text},e.keyId)}function gt(e){const t=e.spacing??8;return{def:(0,dt.jsx)("pattern",{id:e.id,width:t,height:t,patternUnits:"userSpaceOnUse",patternTransform:`rotate(${e.angle??45})`,children:(0,dt.jsx)("line",{x1:0,y1:0,x2:0,y2:t,stroke:e.color??"currentColor",strokeWidth:e.strokeWidth??1,opacity:e.opacity??.5})},e.id),fill:`url(#${e.id})`}}function yt(e){const t=e.orient??"bottom",n="bottom"===t||"top"===t,o=e.offset??0,r=e.tickLength??6,i=e.gridLength??0,a=e.labelGap??4,s=e.fontSize??11,c=e.color??"var(--semiotic-text-secondary, #888)",l=e.gridColor??c,u=e.format??(e=>e+""),d="top"===t||"left"===t?-1:1,h=e.ticks.length-1,f=e.ticks.map((f,m)=>{const p=e.scale(f),g=o+d*r,y=o-d*i,x=g+d*a;let b;b=e.labelAnchor?e.labelAnchor:n?e.edgeAnchor&&0===m?"start":e.edgeAnchor&&m===h?"end":"middle":"left"===t?"end":"start";const w=n?"top"===t?"auto":"hanging":"middle",M=n?{x:p,y:x}:{x:x,y:p};return(0,dt.jsxs)("g",{children:[(r>0||i>0)&&(0,dt.jsx)("line",{...n?{x1:p,x2:p,y1:g,y2:y}:{x1:g,x2:y,y1:p,y2:p},stroke:i>0?l:c,strokeWidth:1,strokeDasharray:i>0?e.gridDasharray:void 0,opacity:i>0?.7:1}),(0,dt.jsx)("text",{x:M.x,y:M.y,textAnchor:b,dominantBaseline:w,fontSize:s,fontWeight:e.fontWeight,fill:c,children:u(f)})]},`tick-${f}-${m}`)});return(0,dt.jsx)("g",{className:e.className,style:{pointerEvents:"none"},children:f},e.keyId)}function xt(e){const t=e.stroke??"var(--semiotic-text, #f4f4f8)",n=e.strokeWidth??1,o=e.markRadius??0,r=e.labelX-e.markX,i=e.labelY-e.markY,a=Math.hypot(r,i)||1,s=e.markX+r/a*o,c=e.markY+i/a*o;let l;return l="elbow"===e.connector?`M${s},${c} L${s},${e.labelY} L${e.labelX},${e.labelY}`:"curve"===e.connector?`M${s},${c} Q${(s+e.labelX)/2},${c} ${e.labelX},${e.labelY}`:`M${s},${c} L${e.labelX},${e.labelY}`,(0,dt.jsxs)("g",{className:e.className,style:{pointerEvents:"none"},children:[o>0&&(0,dt.jsx)("circle",{cx:e.markX,cy:e.markY,r:o,fill:"none",stroke:t,strokeWidth:n}),(0,dt.jsx)("path",{d:l,fill:"none",stroke:t,strokeWidth:n}),(0,dt.jsx)("text",{x:e.labelX,y:e.labelY,textAnchor:e.labelAnchor??"middle",dominantBaseline:e.labelBaseline??"hanging",fontSize:e.fontSize??11,fontWeight:e.fontWeight,fill:e.color??t,children:e.label})]},e.keyId)}var bt=require("react/jsx-runtime");function wt(e,t,n={}){const o=n.fingerprintRounds??3,r=[],i=new Set;for(const t of e)null==t.id||i.has(t.id)||(i.add(t.id),r.push(t.id));const{outAdj:a,inAdj:s,undirected:c}=St(r,t),l=It(r,a,s,c,o).map(e=>({ids:e.ids,nodeCount:e.nodeCount,edgeCount:e.edgeCount,sinkCount:e.sinkCount,sourceCount:e.sourceCount,directed:e.directed,motif:e.motif,descriptor:At(e)})),u=new Map;for(const e of l){const t=u.get(e.motif);t?t.count+=1:u.set(e.motif,{motif:e.motif,descriptor:e.descriptor,count:1,directed:e.directed})}return{components:l,motifs:[...u.values()].sort((e,t)=>t.count-e.count),directedCount:l.filter(e=>e.directed).length,branchingCount:l.filter(e=>!e.directed).length}}function Mt(e){let t=2166136261;for(let n=0;e.length>n;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function vt(e){return"string"==typeof e?e:e?.id}function kt(e,t,n,o,r){const i=new Set(e);let a=new Map;for(const o of e){let e=0,r=0;for(const e of t.get(o)??[])i.has(e)&&(r+=1);for(const t of n.get(o)??[])i.has(t)&&(e+=1);a.set(o,`${e}:${r}`)}for(let o=0;r>o;o+=1){const o=new Map;for(const r of e){const e=[];for(const n of t.get(r)??[])i.has(n)&&e.push(a.get(n));const s=[];for(const e of n.get(r)??[])i.has(e)&&s.push(a.get(e));e.sort(),s.sort(),o.set(r,Mt(`${a.get(r)}>${e.join(",")}<${s.join(",")}`))}a=o}const s=e.map(e=>a.get(e)).sort();return Mt(`${e.length}#${o}#${s.join(";")}`)}function $t(e,t,n,o,r,i,a){const{layer:s,layerCount:c}=function(e,t){const n=new Set(e),o=new Map,r=new Set,i=e=>{const a=o.get(e);if(void 0!==a)return a;if(r.has(e))return 0;r.add(e);let s=0;for(const o of t.get(e)??[])n.has(o)&&(s=Math.max(s,1+i(o)));return r.delete(e),o.set(e,s),s};let a=0;for(const t of e)a=Math.max(a,i(t));const s=new Map;for(const t of e)s.set(t,a-o.get(t));return{layer:s,layerCount:a+1}}(e.ids,o),l=Array.from({length:c},()=>[]);for(const t of e.ids)l[s.get(t)].push(t);const u=.14*Math.min(i.width,i.height),d=Math.max(1,i.width-2*u),h=Math.max(1,i.height-2*u),f=new Map,m=new Set(e.ids);for(let e=0;c>e;e+=1){let t=l[e];e>0&&(t=[...t].sort((e,t)=>p(e)-p(t)));const n=t.length,o=i.y+u+(1===c?.5:e/(c-1))*h;t.forEach((e,t)=>{f.set(e,{x:i.x+u+(1===n?.5:t/(n-1))*d,y:o})})}function p(e){let t=0,n=0;for(const o of r.get(e)??[]){const e=f.get(o);m.has(o)&&e&&(t+=e.x,n+=1)}return n>0?t/n:i.x+d/2}const g=l.reduce((e,t)=>Math.max(e,t.length),1),y=$(Math.min(a,d/(2.4*g),h/(2.4*c)),1.4,a),x=e.ids.map(e=>{const o=f.get(e);return{id:e,cx:o.x,cy:o.y,r:y,datum:t.get(e)??v({id:e}),category:n.get(e)??""}}),b=[];for(const t of e.ids){const e=f.get(t);for(const n of o.get(t)??[]){if(!m.has(n))continue;const t=f.get(n);b.push({x1:e.x,y1:e.y,x2:t.x,y2:t.y})}}return{nodes:x,edges:b}}function At(e){const{nodeCount:t,edgeCount:n,sinkCount:o,sourceCount:r}=e;return 1===t?"isolate":2===t&&1===n?"pair":1===r&&1===o&&n===t-1?"chain of "+t:e.directed&&1===r&&n>t-1?"diamond / mesh":e.directed?`converging (${t})`:"branching → "+o}function St(e,t){const n=new Set(e),o=new Map,r=new Map,i=new Map;for(const t of e)o.set(t,new Set),r.set(t,new Set),i.set(t,new Set);for(const e of t){const t=e.source,a=e.target;n.has(t)&&n.has(a)&&t!==a&&(o.get(t).has(a)||(o.get(t).add(a),r.get(a).add(t),i.get(t).add(a),i.get(a).add(t)))}return{outAdj:o,inAdj:r,undirected:i}}function It(e,t,n,o,r){const i=new Set,a=[];for(const s of e){if(i.has(s))continue;const e=[s];i.add(s);const c=[];for(;e.length;){const t=e.pop();c.push(t);for(const n of o.get(t)??[])i.has(n)||(i.add(n),e.push(n))}const l=new Set(c);let u=0,d=0,h=0;for(const e of c){let o=0,r=0;for(const n of t.get(e)??[])l.has(n)&&(o+=1);for(const t of n.get(e)??[])l.has(t)&&(r+=1);h+=o,0===o&&(u+=1),0===r&&(d+=1)}a.push({ids:c,nodeCount:c.length,edgeCount:h,sinkCount:u,sourceCount:d,directed:1===u,motif:kt(c,t,n,h,r)})}return a}var jt=new b(8),Ct=e=>{const t=e.config||{},n=e.dimensions.plot;if(!e.nodes.length)return{sceneNodes:[]};const o=t.sourceAccessor??"source",r=t.targetAccessor??"target",i=t.labelAccessor??"label",a=t.categoryAccessor??"category",s=t.nodeRadius??4,c=t.cellGap??16,l=t.bandGap??22,u=t.headerHeight??34,d=t.minCellForFull??38,f=t.maxCellSize??120,m=t.minCellSize??12,p=t.fingerprintRounds??3,g=!1!==t.groupByMotif,b=t.sort??"frequency",w=new Map,M=new Map,k=[];for(const t of e.nodes){const e=t.id;null==e||w.has(e)||(k.push(e),w.set(e,t.data??t),M.set(e,h(t,a,"")+""))}const $=[];for(const t of e.edges){const e=vt(t.source??h(t,o,void 0)),n=vt(t.target??h(t,r,void 0));null!=e&&null!=n&&$.push({source:e,target:n})}const{outAdj:A,inAdj:S,undirected:I}=St(k,$),j=It(k,A,S,I,p),C=new Map;if(g)for(const e of j){const t=C.get(e.motif);t?t.push(e):C.set(e.motif,[e])}else C.set("all",[...j].sort((e,t)=>t.nodeCount-e.nodeCount));const N=[...C.entries()];N.sort((e,t)=>"size"===b?t[1][0].nodeCount-e[1][0].nodeCount:"directedness"===b?Number(t[1][0].directed)-Number(e[1][0].directed):t[1].length-e[1].length);const L=Mt(k.join(",")+"|"+[...A.entries()].map(([e,t])=>e+">"+[...t].sort().join(".")).join(";")),z=x([Math.round(n.x),Math.round(n.y),Math.round(n.width),Math.round(n.height),c,l,u,d,f,m,p,g,b,s,N.map(([e,t])=>e+":"+t.length).join(","),L]),T=jt.getOrCompute(z,()=>function(e,t){const{plot:n}=t,o=Math.max(40,n.width),{cell:r,cols:i}=(()=>{for(let r=t.maxCellSize;r>=t.minCellSize;r-=2){const i=Math.max(1,Math.floor((o+t.cellGap)/(r+t.cellGap)));let a=0;for(const[,n]of e)a+=t.headerHeight+Math.ceil(n.length/i)*(r+t.cellGap)+t.bandGap;if(n.height>=a)return{cell:r,cols:i}}return{cell:t.minCellSize,cols:Math.max(1,Math.floor((o+t.cellGap)/(t.minCellSize+t.cellGap)))}})(),a=[],s=[];let c=n.y;for(const[l,u]of e){const e=Math.ceil(u.length/i),d=c,h=d+t.headerHeight,f=r>=t.minCellForFull;u.forEach((e,o)=>{const s=n.x+o%i*(r+t.cellGap),c=h+Math.floor(o/i)*(r+t.cellGap);if(f){const n=$t(e,t.nodeDatum,t.nodeCategory,t.outAdj,t.inAdj,{x:s,y:c,width:r,height:r},t.nodeRadius);a.push({component:e,lod:"full",cx:s+r/2,cy:c+r/2,glyphR:0,nodes:n.nodes,edges:n.edges})}else a.push({component:e,lod:"glyph",cx:s+r/2,cy:c+r/2,glyphR:Math.max(2.5,.36*r),nodes:[],edges:[]})});const m=Nt(u[0],t,{x:n.x,y:d+2,width:Math.min(t.headerHeight-6,40),height:t.headerHeight-6});s.push({motif:l,descriptor:At(u[0]),count:u.length,directed:u[0].directed,x:n.x,y:d,width:o,height:t.headerHeight+e*(r+t.cellGap),exemplar:m}),c=h+e*(r+t.cellGap)+t.bandGap}return{cells:a,bands:s}}(N,{plot:n,cellGap:c,bandGap:l,headerHeight:u,minCellForFull:d,maxCellSize:f,minCellSize:m,nodeRadius:s,nodeDatum:w,nodeCategory:M,outAdj:A,inAdj:S})),E=e.theme.semantic||{},F=t.convergeColor??E.info??"#4c78a8",R=t.branchColor??E.warning??"#e8853a",W=t.edgeColor??E.border??"#9aa0aa",P=t.colorMode??"directedness",O={predicate:e.selection?.isActive?e.selection.predicate:null,highlight:t.highlight??null,dimOpacity:.14},q=t=>"motif"===P?e.resolveColor(t.motif):"category"===P||t.directed?F:R,D=[],B=[];for(const t of T.cells){const n=t.component,o=q(n);if("full"===t.lod){for(const e of t.edges)B.push({type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,style:{stroke:W,strokeWidth:1,opacity:.5},datum:null});for(const n of t.nodes){const t="category"===P&&n.category?e.resolveColor(n.category):o,r={type:"symbol",cx:n.cx,cy:n.cy,size:Math.PI*n.r*n.r,symbolType:"circle",style:{fill:t,opacity:y(n.datum,O)},datum:n.datum,id:n.id,label:h(n.datum,i,n.id)+""};D.push(r)}}else{const e=v({id:`motif-${n.motif}-${t.cx.toFixed(0)}-${t.cy.toFixed(0)}`,motif:n.motif,shape:At(n),nodes:n.nodeCount,edges:n.edgeCount,sinks:n.sinkCount,sources:n.sourceCount,directedness:n.directed?"converging":"branching"}),r={type:"symbol",cx:t.cx,cy:t.cy,size:Math.PI*t.glyphR*t.glyphR,symbolType:n.directed?"circle":"diamond",style:{fill:o,opacity:y(e,O),stroke:W,strokeWidth:.75},datum:e,id:e.id+"",label:At(n)};D.push(r)}}return{sceneNodes:D,sceneEdges:B,overlays:function(e,t){const n=[];for(const o of e){const e=o.directed?t.convergeColor:t.branchColor;if(n.push(ht({keyId:"band-"+o.motif,x:o.x-6,y:o.y-4,width:o.width+12,height:o.height+4,radius:8,stroke:e,strokeWidth:1,opacity:.28})),t.showExemplars&&o.exemplar){const r=o.exemplar;n.push((0,bt.jsxs)("g",{style:{pointerEvents:"none"},children:[r.edges.map((e,n)=>(0,bt.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:t.edgeColor,strokeWidth:.75,opacity:.55},"exe-"+n)),r.nodes.map(t=>(0,bt.jsx)("circle",{cx:t.cx,cy:t.cy,r:Math.max(1.6,t.r),fill:e},"exn-"+t.id))]},"ex-"+o.motif))}if(t.showBandLabels){const e=o.x+(t.showExemplars?48:4);n.push((0,bt.jsx)("text",{x:e,y:o.y+12,fontSize:13,fontWeight:600,fill:t.textColor,style:{pointerEvents:"none"},children:o.descriptor},"bl-"+o.motif)),n.push((0,bt.jsx)("text",{x:e,y:o.y+27,fontSize:11,fill:t.subText,style:{pointerEvents:"none"},children:`×${o.count} · ${o.directed?"converges to 1 sink":"branches to ≥2 sinks"}`},"bc-"+o.motif))}}if(t.showLegend){const e=t.plot.x+t.plot.width-168,i=t.plot.y-2;n.push((0,bt.jsxs)("g",{style:{pointerEvents:"none"},children:[(0,bt.jsx)("circle",{cx:e,cy:i,r:5,fill:t.convergeColor}),(0,bt.jsx)("text",{x:e+10,y:i+4,fontSize:11,fill:t.subText,children:"converges (1 sink)"}),(0,bt.jsx)("path",{d:(o=e,r=i+18,`M${o},${r-5} L${o+5},${r} L${o},${r+5} L${o-5},${r} Z`),fill:t.branchColor}),(0,bt.jsx)("text",{x:e+10,y:i+22,fontSize:11,fill:t.subText,children:"branches (≥2 sinks)"})]},"net-legend"))}var o,r;return(0,bt.jsx)("g",{className:"net-ensemble-overlays",children:n})}(T.bands,{convergeColor:F,branchColor:R,edgeColor:W,plot:n,showBandLabels:!1!==t.showBandLabels,showExemplars:!1!==t.showExemplars,showLegend:!1!==t.showLegend&&"directedness"===P,textColor:E.text??"var(--semiotic-text, #1a1a1a)",subText:E.textSecondary??"var(--semiotic-text-secondary, #888)"})}};function Nt(e,t,n){return e?$t(e,t.nodeDatum,t.nodeCategory,t.outAdj,t.inAdj,n,3):null}var Lt=require("react/jsx-runtime"),zt=new b(12);function Tt(e){if(null==e)return NaN;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();const t=e+"",n=Number(t);if(!Number.isNaN(n)&&""!==t.trim())return n;const o=Date.parse(t);return Number.isNaN(o)?NaN:o}function Et(e,t,n){return t>e?t:e>n?n:e}var Ft=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.columnAccessor??"column",r=t.rowAccessor??"row",i=t.sizeAccessor,a=t.colorAccessor,s=t.symbolAccessor,c=t.shadeAccessor,l=t.markerAccessor,u=t.iconAccessor,d=t.defaultSymbol??"circle",[f,p]=t.sizeRange??[2,8],g=t.shadeStrength??.72,b=t.shadeReverse??!1,M=t.rowMode??"banded",v=t.cellSizing??"proportional",k=t.proportionExponent??1,$=t.columnGap??16,A=t.rowGap??12,S=t.packPadding??1,I=t.iterations??12,j=!1!==t.showEnclosures,C=!1!==t.showColumnHeaders,N=!1!==t.showRowLabels,L=C?t.headerHeight??26:0,z=N?t.labelWidth??66:0,T=t.callouts&&t.callouts.length>0?t.footerHeight??30:0,E=n.x+z,F=n.y+L,R=Math.max(1,n.width-z),W=Math.max(1,n.height-L-T),P=[];for(const t of e.nodes){const e=t.data??t;P.push({id:t.id,col:h(t,o,"—")+"",row:h(t,r,"—")+"",sizeVal:i?Number(h(t,i,1)):1,colorKey:a?h(t,a,"")+"":"",symVal:s?h(t,s,"")+"":"",shadeVal:c?Tt(h(t,c,null)):NaN,marker:!!l&&!!h(t,l,!1),iconVal:u?h(t,u,"")+"":"",datum:e,size:0,packR:0,baseShape:"circle",iconShape:null})}if(0===P.length)return{sceneNodes:[]};let O=1/0,q=-1/0;if(i)for(const e of P)Number.isFinite(e.sizeVal)&&(O>e.sizeVal&&(O=e.sizeVal),e.sizeVal>q&&(q=e.sizeVal));t.sizeDomain&&([O,q]=t.sizeDomain),Number.isFinite(O)&&Number.isFinite(q)||(O=0,q=1);const D=e=>{if(O>=q)return(f+p)/2;const t=Math.sqrt(Et((e-O)/(q-O),0,1));return f+t*(p-f)};let B=1/0,Y=-1/0;if(c)for(const e of P)Number.isFinite(e.shadeVal)&&(B>e.shadeVal&&(B=e.shadeVal),e.shadeVal>Y&&(Y=e.shadeVal));t.shadeDomain&&([B,Y]=t.shadeDomain);const G=e=>{if(!c||!Number.isFinite(e)||B>=Y)return.5;const t=Et((e-B)/(Y-B),0,1);return b?1-t:t},H=t.colorMap,_=new Map,V=(t,n)=>{let o=_.get(t);return o||(o=w(H&&H[t]||e.resolveColor(t),g),_.set(t,o)),o(n)},X=new Map;if(t.symbolMap)for(const[e,n]of Object.entries(t.symbolMap))X.set(e,n);let U=0;const K=t.iconMap,Q=e=>u&&K&&K[e]?K[e]:null,Z=e=>u?"circle":(e=>{if(!s)return d;let t=X.get(e);return t||(t=J[U%J.length],U++,X.set(e,t)),t})(e.symVal),te=t.maxAreaFraction??.4;let ne=0;const re=Array(P.length),ie=Array(P.length);for(let e=0;P.length>e;e++){const t=P[e],n=D(t.sizeVal);re[e]=n,t.baseShape=Z(t),t.iconShape=Q(t.iconVal);const o=oe(t.baseShape,Math.PI*n*n);ie[e]=o,ne+=Math.PI*o*o}const ae=te*R*W,se=ne>ae?Math.sqrt(ae/ne):1;for(let e=0;P.length>e;e++){const t=P[e],n=re[e]*se;t.size=Math.PI*n*n,t.packR=ie[e]*se}const ce=new Map,le=new Map;for(const e of P)ce.set(e.col,(ce.get(e.col)??0)+1),le.set(e.row,(le.get(e.row)??0)+1);const ue=t.columnOrder?.filter(e=>ce.has(e))??[...ce.keys()].sort((e,t)=>(ce.get(t)??0)-(ce.get(e)??0)),de=t.rowOrder?.filter(e=>le.has(e))??[...le.keys()].sort((e,t)=>(le.get(t)??0)-(le.get(e)??0)),he=x([Math.round(n.x),Math.round(n.y),Math.round(n.width),Math.round(n.height),L,z,T,M,v,k,$,A,S,I,f,p,O,q,te,ue.join(","),de.join(","),P.length,Wt(P)]),fe=zt.getOrCompute(he,()=>function(e,t){const n=new Map;for(const t of e){let e=n.get(t.col);e||(e=[],n.set(t.col,e)),e.push(t)}const o=t.columnOrder.filter(e=>n.has(e)),r=Math.max(1,t.innerW-t.columnGap*Math.max(0,o.length-1)),i=t.proportionExponent,a=o.map(e=>Math.pow(n.get(e).length,i)),s=a.reduce((e,t)=>e+t,0)||1,c=e=>"uniform"===t.cellSizing?r/o.length:a[e]/s*r,l=new Map,u=[];let d=t.innerX;for(let e=0;o.length>e;e++)u.push({col:o[e],x:d,w:c(e)}),d+=c(e)+t.columnGap;let h=1;const f=new Map,p=[],g=(e,t,n,o)=>{let r=f.get(e);r||(r={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},f.set(e,r)),r.minX>t-o&&(r.minX=t-o),t+o>r.maxX&&(r.maxX=t+o),r.minY>n-o&&(r.minY=n-o),n+o>r.maxY&&(r.maxY=n+o)},y=(e,n,o,r,i,a)=>{const s=e.map(e=>({id:e.id,r:e.packR})),c=function(e,t,n,o,r,i,a,s){const c=t+o/2,l=n+r/2,u=new Map,d=e.length;if(0===d)return u;if(1===d)return u.set(e[0].id,{px:c,py:l}),u;const h=function(e){let t=e>>>0||1;return()=>(t=Math.imul(t,1664525)+1013904223>>>0,t/4294967296)}(s),f=new Float64Array(d);let m=0;for(let t=0;d>t;t++)f[t]=e[t].r+i,f[t]>m&&(m=f[t]);const p=Math.max(1,Math.round(Math.sqrt(d*o/Math.max(1,r)))),g=new Float64Array(d),y=new Float64Array(d),x=o/p,b=r/Math.ceil(d/p);for(let e=0;d>e;e++){const o=e%p,r=Math.floor(e/p);g[e]=t+(o+.3+.4*h())*x,y[e]=n+(r+.3+.4*h())*b}const w=Math.max(0,Math.min(a,14)),M=Math.max(1,2*m),v=new Map,k=Math.max(1,Math.ceil(o/M)+3),$=(e,t)=>(t+1)*k+(e+1);for(let e=0;w>e;e++){v.clear();for(let e=0;d>e;e++){const o=$(Math.floor((g[e]-t)/M),Math.floor((y[e]-n)/M)),r=v.get(o);r?r.push(e):v.set(o,[e])}for(let e=0;d>e;e++){const o=Math.floor((g[e]-t)/M),r=Math.floor((y[e]-n)/M);for(let t=-1;1>=t;t++)for(let n=-1;1>=n;n++){const i=v.get($(o+t,r+n));if(i)for(let t=0;i.length>t;t++){const n=i[t];if(e>=n)continue;let o=g[n]-g[e],r=y[n]-y[e];const a=f[e]+f[n],s=o*o+r*r;if(a*a>s)if(s>1e-9){const t=Math.sqrt(s),i=(a-t)/2;o/=t,r/=t,g[e]-=o*i,y[e]-=r*i,g[n]+=o*i,y[n]+=r*i}else{const t=2.39996323*e;g[e]+=Math.cos(t)*f[e],y[e]+=Math.sin(t)*f[e]}}}}for(let e=0;d>e;e++){const i=f[e],a=t+i,s=t+o-i,u=n+i,d=n+r-i;g[e]=s>a?Et(g[e],a,s):c,y[e]=d>u?Et(y[e],u,d):l}}for(let t=0;d>t;t++)u.set(e[t].id,{px:g[t],py:y[t]});return u}(s,n,o,r,i,t.packPadding,t.iterations,h++);let u=1/0,d=1/0,f=-1/0,m=-1/0;for(const e of s){const t=c.get(e.id);l.set(e.id,{px:t.px,py:t.py}),g(a,t.px,t.py,e.r),u>t.px-e.r&&(u=t.px-e.r),t.px+e.r>f&&(f=t.px+e.r),d>t.py-e.r&&(d=t.py-e.r),t.py+e.r>m&&(m=t.py+e.r)}return Number.isFinite(u)?{x:u-Rt,y:d-Rt,w:f-u+2*Rt,h:m-d+2*Rt}:null};if("banded"===t.rowMode){const r=new Map;for(const t of e)r.set(t.row,(r.get(t.row)??0)+1);const a=t.rowOrder.filter(e=>r.has(e)),s=Math.max(1,t.innerH-t.rowGap*Math.max(0,a.length-1)),c=a.map(e=>Math.pow(r.get(e),i)),d=c.reduce((e,t)=>e+t,0)||1,h=new Map;let p=t.innerY+t.innerH;for(let e=0;a.length>e;e++){const n="uniform"===t.cellSizing?s/a.length:c[e]/d*s,o=p-n;h.set(a[e],{y:o,h:n}),p=o-t.rowGap}o.forEach((e,t)=>{const o=m(n.get(e),e=>e.row);for(const e of a){const n=o.get(e),r=h.get(e);n&&r&&y(n,u[t].x,r.y,u[t].w,r.h,e)}});const g=[],x=new Map;for(const e of a){const t=h.get(e);x.set(e,t.y+t.h/2);const n=f.get(e);n&&Number.isFinite(n.minX)&&g.push({x:n.minX-Rt,y:n.minY-Rt,w:n.maxX-n.minX+2*Rt,h:n.maxY-n.minY+2*Rt})}return{positions:l,enclosures:g,colBands:u,rowLabelY:x}}const x=new Map;o.forEach((e,o)=>{const r=m(n.get(e),e=>e.row),a=t.rowOrder.filter(e=>r.has(e)),s=Math.max(1,t.innerH-t.rowGap*Math.max(0,a.length-1)),c=a.map(e=>Math.pow(r.get(e).length,i)),l=c.reduce((e,t)=>e+t,0)||1;let d=t.innerY+t.innerH;a.forEach((e,n)=>{const i="uniform"===t.cellSizing?s/a.length:c[n]/l*s,h=d-i,f=y(r.get(e),u[o].x,h,u[o].w,i,e);if(f){p.push(f);const t=x.get(e)??{sum:0,n:0};t.sum+=f.y+f.h/2,t.n+=1,x.set(e,t)}d=h-t.rowGap})});const b=new Map;for(const[e,t]of x)b.set(e,t.sum/t.n);return{positions:l,enclosures:p,colBands:u,rowLabelY:b}}(P,{columnOrder:ue,rowOrder:de,innerX:E,innerY:F,innerW:R,innerH:W,rowMode:M,cellSizing:v,proportionExponent:k,columnGap:$,rowGap:A,packPadding:S,iterations:I})),me=e.selection,pe=me?.isActive?me.predicate:null,ge=t.highlight??null,ye=t.dimOpacity??.16,xe=t.markStroke,be=t.markStrokeWidth??0,we=t.markerColor??"#ffffff",Me=t.iconColor??"rgba(255,255,255,0.92)",ve=t.iconStrokeWidth??1,ke=t.iconScale??.72,$e=[],Ae=[],Se=[];for(const e of P){const t=fe.positions.get(e.id);if(!t)continue;const n=y(e.datum,{highlight:ge,predicate:pe,dimOpacity:ye}),o={type:"symbol",cx:t.px,cy:t.py,size:e.size,symbolType:e.baseShape,style:{fill:V(e.colorKey,G(e.shadeVal)),opacity:n,...xe?{stroke:xe,strokeWidth:be}:{}},datum:e.datum,id:e.id,label:e.id+""};if($e.push(o),e.iconShape){const o=Math.sqrt(e.size/Math.PI)*ke,r=oe(e.iconShape,100);Se.push({x:t.px,y:t.py,size:r>0?o/r*100*(o/r):Math.PI*o*o,shape:e.iconShape,opacity:n})}e.marker&&n>ye+.001&&Ae.push({x:t.px,y:t.py,r:Math.max(1,.4*Math.sqrt(e.size/Math.PI))})}const Ie=[];if(t.callouts&&t.callouts.length>0){const e=t.calloutColor??"var(--semiotic-text, #f4f4f8)",o=n.y+n.height-(T>0?.45*T:9),r=[];for(let e=0;t.callouts.length>e;e++){const n=t.callouts[e],o=P.find(e=>e.datum[n.field]+""==n.value+"");if(!o)continue;const i=fe.positions.get(o.id);i&&r.push({c:n,ci:e,px:i.px,py:i.py,markR:Math.sqrt(o.size/Math.PI)})}const i=r.filter(e=>null==e.c.at).sort((e,t)=>e.px-t.px),a=new Map;i.forEach((e,t)=>{a.set(e.ci,E+(t+.5)/i.length*R)});for(const t of r){const r=t.c;let i=a.get(t.ci)??t.px,s=o;const c=r.connector??(a.has(t.ci)?"elbow":"straight");"object"==typeof r.at&&r.at?(i=r.at.x,s=r.at.y):"number"==typeof r.at&&(s=n.y+r.at*n.height),Ie.push({keyId:"callout-"+t.ci,markX:t.px,markY:t.py,labelX:i,labelY:s,label:r.label,connector:c,markRadius:Math.max(t.markR+3,7),stroke:e,color:e,fontSize:11,labelAnchor:"middle",labelBaseline:"auto"})}}const je=function(e,t){const n=t.columnLabel??(e=>e),o=t.rowLabel??(e=>e);return(0,Lt.jsxs)("g",{className:"packed-cluster-matrix-chrome",style:{pointerEvents:"none"},children:[t.showEnclosures&&e.enclosures.map((e,n)=>ht({keyId:"enc-"+n,x:e.x,y:e.y,width:e.w,height:e.h,radius:t.enclosureRadius,stroke:t.enclosureColor,strokeWidth:t.enclosureWidth,opacity:t.enclosureOpacity})),t.iconMarks.length>0&&(0,Lt.jsx)("g",{className:"packed-cluster-matrix-icons",children:t.iconMarks.map((e,n)=>(0,Lt.jsx)("path",{d:ee(e.shape,e.size),transform:`translate(${e.x},${e.y})`,fill:"none",stroke:t.iconColor,strokeWidth:t.iconStrokeWidth,opacity:e.opacity},"ic-"+n))}),t.markerDots.length>0&&(0,Lt.jsx)("g",{className:"packed-cluster-matrix-markers",children:t.markerDots.map((e,n)=>(0,Lt.jsx)("circle",{cx:e.x,cy:e.y,r:e.r,fill:t.markerColor},"mk-"+n))}),t.showColumnHeaders&&e.colBands.map((e,o)=>pt({keyId:"col-"+o,text:n(e.col),x:e.x+e.w/2,y:t.headerY,anchor:"middle",fontSize:t.headerFontSize,fontWeight:700,color:t.headerColor})),t.showRowLabels&&[...e.rowLabelY].map(([e,n])=>pt({keyId:"row-"+e,text:o(e),x:t.labelX,y:n,anchor:"end",fontSize:t.labelFontSize,fontWeight:600,color:t.labelColor})),t.callouts.map(e=>xt(e))]})}(fe,{markerDots:Ae,markerColor:we,iconMarks:Se,iconColor:Me,iconStrokeWidth:ve,callouts:Ie,plot:n,showEnclosures:j,showColumnHeaders:C,showRowLabels:N,enclosureColor:t.enclosureColor??"var(--semiotic-text, #f4f4f8)",enclosureRadius:t.enclosureRadius??9,enclosureOpacity:t.enclosureOpacity??.5,enclosureWidth:t.enclosureWidth??1.5,headerColor:t.headerColor??"var(--semiotic-text, #f4f4f8)",labelColor:t.labelColor??"var(--semiotic-text-secondary, #b9b9c8)",headerFontSize:t.headerFontSize??13,labelFontSize:t.labelFontSize??11,headerY:n.y+.62*L,labelX:n.x+z-10,columnLabel:t.columnLabel,rowLabel:t.rowLabel});return{sceneNodes:$e,overlays:je}},Rt=4;function Wt(e){let t=2166136261;const n=e=>{for(let n=0;e.length>n;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)};for(const o of e)n(o.id),n(o.col),n(o.row),t^=Math.round(8*o.packR),t=Math.imul(t,16777619);return(t>>>0).toString(36)}var Pt=c(require("react")),Ot=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height)return{nodes:[]};const o=d(t.categoryAccessor),r=d(t.stackBy),i=e=>{const n="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor],o=Number(n);return Number.isFinite(o)&&o>0?o:0},a=t.gutter??2,s="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",c="string"==typeof t.stackBy?t.stackBy:"stack",l="string"==typeof t.valueAccessor?t.valueAccessor:"value",u=(e,t,n)=>p(o=>{o("category",e),o("stack",t),o("value",n),"category"!==s&&o(s,e),"stack"!==c&&o(c,t),"value"!==l&&o(l,n)}),h=!1!==t.showCategoryLabels,f=Math.max(0,n.height-(t.labelPadding??(h?22:0))),m=[],g=new Map,y=[],x=new Set,b=new Map;for(const t of e.data){const e=o(t)+"",n=r(t)+"",a=i(t);g.has(e)||(m.push(e),g.set(e,0),b.set(e,new Map)),x.has(n)||(x.add(n),y.push(n)),g.set(e,(g.get(e)??0)+a);const s=b.get(e);s.set(n,(s.get(n)??0)+a)}const w=t.categoryOrder?qt(t.categoryOrder,m,e=>g.has(e)):m,M=t.stackOrder?qt(t.stackOrder,y,()=>!0):y,v=w.reduce((e,t)=>e+(g.get(t)??0),0);if(0>=v)return{nodes:[]};const k=Math.max(0,n.width-a*Math.max(0,w.length-1)),$=[],A=[];let S=n.x;for(const t of w){const o=g.get(t)??0,r=o/v*k;if(0>=r)continue;A.push({cat:t,x:S,w:r});const i=b.get(t);let s=n.y;for(const n of M){const a=i.get(n)??0;if(0>=a)continue;const c=a/o*f;$.push({type:"rect",x:S,y:s,w:r,h:c,style:{fill:e.resolveColor(n),stroke:"none"},datum:u(t,n,a),group:n}),s+=c}S+=r+a}return{nodes:$,overlays:h&&A.length>0?function(e,t,n){const o=e.map((e,o)=>pt({keyId:"marimekko-label-"+o,text:e.cat,x:e.x+e.w/2,y:t+12,anchor:"middle",baseline:"auto",maxWidth:e.w-4,fontSize:12,color:n}));return Pt.createElement(Pt.Fragment,null,...o)}(A,n.y+f+4,`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`):null}};function qt(e,t,n){const o=new Set,r=[];for(const t of e)n(t)&&!o.has(t)&&(o.add(t),r.push(t));for(const e of t)o.has(e)||r.push(e);return r}var Dt=c(require("react")),Bt=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height||0===e.data.length)return{nodes:[]};const o=t.rowHeight??28,r=t.rowGap??12,i=!1!==t.showLabels,a=i?t.labelWidth??120:0,s=!1!==t.showTicks,c=s?14:0,l=t.tickFormat??(e=>e.toLocaleString()),u=n.x+a,h=Math.max(0,n.width-a);if(0>=h)return{nodes:[]};const f=d(t.categoryAccessor),m=e=>{const t=Number(e);return Number.isFinite(t)&&t>0?t:0},g=e=>m("function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor]),y=e=>m("function"==typeof t.targetAccessor?t.targetAccessor(e):e[t.targetAccessor]),x=e=>{const n="function"==typeof t.rangesAccessor?t.rangesAccessor(e):e[t.rangesAccessor];return Array.isArray(n)?n.map(m).sort((e,t)=>e-t):[]},b="string"==typeof t.categoryAccessor?t.categoryAccessor:"metric",w="string"==typeof t.valueAccessor?t.valueAccessor:"value",M="string"==typeof t.targetAccessor?t.targetAccessor:"target",v=t.actualColor??e.theme.semantic.primary??"#3b6cb1",k=e.theme.semantic.text??"currentColor",$=t.targetColor??`var(--semiotic-text, ${k})`,A=[`var(--semiotic-surface, ${e.theme.semantic.surface??"#e8eaed"})`,`var(--semiotic-grid, ${e.theme.semantic.grid??"#cdd1d6"})`,`var(--semiotic-border, ${e.theme.semantic.border??"#a3a8af"})`],S=`var(--semiotic-text, ${k})`,I=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,j=[],C=[];for(let t=0;e.data.length>t;t++){const i=e.data[t],a=x(i),s=g(i),l=y(i),d=Math.max(s,l,...a.length?a:[0]);if(0>=d)continue;const m=n.y+t*(o+r+c);if(m+o+c>n.y+n.height)break;C.push({yTop:m,label:f(i),actual:s,target:l,maxVal:d});const k=e=>u+e/d*h,S=f(i),I=e=>p(t=>{t("metric",S),"metric"!==b&&t(b,S),e(t)});let N=u;for(let e=0;a.length>e;e++){const t=k(a[e]),n=t-N;n>0&&j.push({type:"rect",x:N,y:m,w:n,h:o,style:{fill:A[Math.min(e,A.length-1)],stroke:"none"},datum:I(t=>{t("range",e),t("rangeValue",a[e]),t("kind","range")}),group:"range-"+e}),N=t}const L=Math.max(6,Math.floor(.45*o));j.push({type:"rect",x:u,y:m+(o-L)/2,w:k(s)-u,h:L,style:{fill:v,stroke:"none"},datum:I(e=>{e("value",s),e("kind","actual"),"value"!==w&&e(w,s)}),group:"actual"});const z=3,T=Math.floor(.8*o);j.push({type:"rect",x:k(l)-z/2,y:m+(o-T)/2,w:z,h:T,style:{fill:$,stroke:"none"},datum:I(e=>{e("target",l),e("kind","target"),"target"!==M&&e(M,l)}),group:"target"})}const N=[];for(let e=0;C.length>e;e++){const t=C[e];if(i&&N.push(pt({keyId:"bullet-label-"+e,text:t.label,x:n.x+a-8,y:t.yTop+o/2,anchor:"end",baseline:"middle",fontSize:13,fontWeight:500,color:S})),s){const n=5,r=t.yTop+o+2;for(let o=0;n>o;o++){const i=t.maxVal*o/(n-1),a=u+i/t.maxVal*h;N.push(Dt.createElement("line",{key:`bullet-tick-${e}-${o}`,x1:a,x2:a,y1:r,y2:r+3,stroke:I,strokeWidth:1}),pt({keyId:`bullet-ticktext-${e}-${o}`,text:l(i),x:a,y:r+12,anchor:0===o?"start":o===n-1?"end":"middle",baseline:"auto",fontSize:10,color:I}))}}}return{nodes:j,overlays:N.length>0?Dt.createElement(Dt.Fragment,null,...N):null}},Yt=c(require("react")),Gt=require("d3-scale"),Ht=e=>{const t=e.config,{plot:n}=e.dimensions,o=t.fields??[];if(2>o.length||0>=n.width||0>=n.height)return{nodes:[]};if(0===e.data.length)return{nodes:[]};const r={};for(const n of o){if(t.domains?.[n]){r[n]=t.domains[n];continue}let o=1/0,i=-1/0;for(const t of e.data){const e=Number(t[n]);Number.isFinite(e)&&(o>e&&(o=e),e>i&&(i=e))}r[n]=Number.isFinite(o)&&Number.isFinite(i)&&o!==i?[o,i]:[0,1]}const i=!1!==t.showAxes,a=i?t.axisLabelPadding??24:8,s=i?18:8,c=o.map(e=>(0,Gt.scaleLinear)().domain(r[e]).range([n.y+n.height-s,n.y+a])),l=o.map((e,t)=>1===o.length?n.x+n.width/2:n.x+t/(o.length-1)*n.width),u=t.colorBy?"function"==typeof t.colorBy?t.colorBy:e=>(e[t.colorBy]??"")+"":null,d=t.opacity??.45,h=t.strokeWidth??1.25,f=e.theme.semantic.primary??"#3b6cb1",m=t.dimmedOpacity??.08,p=t.highlightFn,g=[],x=[];for(const n of e.data){const r=u?e.resolveColor(u(n)+""):f,i=!p||p(n),a=y(n,{predicate:p,baseOpacity:d,dimOpacity:m,brighten:.4}),s=i?x:g;for(let e=0;o.length-1>e;e++){const t=Number(n[o[e]]),u=Number(n[o[e+1]]);if(!Number.isFinite(t)||!Number.isFinite(u))continue;const d={type:"connector",x1:l[e],y1:c[e](t),x2:l[e+1],y2:c[e+1](u),style:{stroke:r,strokeWidth:p&&i?h+.75:h,opacity:a,fill:"none"},datum:n};s.push(d)}if(t.showPoints)for(let e=0;o.length>e;e++){const t=Number(n[o[e]]);if(!Number.isFinite(t))continue;const i={type:"point",x:l[e],y:c[e](t),r:2.5,style:{fill:r,stroke:"none",opacity:Math.min(1,a+.3)},datum:n};s.push(i)}}let b=null;if(i){const i=`var(--semiotic-border, ${e.theme.semantic.border??"#aaa"})`,u=`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`,d=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,h=n.y+a,f=n.y+n.height-s,m=[];for(let e=0;o.length>e;e++){const s=o[e],p=l[e],g=t.tickFormat?.[s]??(e=>e.toLocaleString());m.push(Yt.createElement("line",{key:"pc-axis-line-"+e,x1:p,x2:p,y1:h,y2:f,stroke:i,strokeWidth:1})),m.push(pt({keyId:"pc-axis-label-"+e,text:s,x:p,y:n.y+a-8,anchor:"middle",baseline:"auto",fontSize:12,fontWeight:600,color:u}));const[y,x]=r[s],b=5;for(let t=0;b>t;t++){const n=y+(x-y)*t/(b-1),o=c[e](n);m.push(Yt.createElement("line",{key:`pc-tick-${e}-${t}`,x1:p-3,x2:p+3,y1:o,y2:o,stroke:i,strokeWidth:1}),pt({keyId:`pc-ticktext-${e}-${t}`,text:g(n),x:p+6,y:o+3,anchor:"start",baseline:"auto",fontSize:10,color:d}))}}b=Yt.createElement(Yt.Fragment,null,...m)}return{nodes:g.concat(x),overlays:b}},_t=require("react/jsx-runtime"),Vt=1.75,Xt="#222222";function Ut(e,t){return e.topRadius+(t-e.height)/e.height*(e.topRadius-e.bottomRadius)}function Kt(e,t){return function(e,t,n){return Math.PI*n/3*(e*e+e*t+t*t)}(Ut(e,t),e.bottomRadius,t)}function Qt(e,t){const n=(e.topRadius+e.bottomRadius)/2,o=Math.PI*n*n;let r=t/o,i=t-Kt(e,r),a=0;for(;100>a&&Math.abs(i)>1e-4;)r+=i/o,i=t-Kt(e,r),a++;return r}function Zt(e,t){const n=43758.5453*Math.sin(12.9898*e+78.233);return 2*(n-Math.floor(n)-.5)*t}function Jt(e,t){if(t>e||2*t>e)return[{x:0,y:0}];const n=[],o=e=>{let r=Math.floor(2*Math.PI*e/(2*t));1>r&&(r=1);const i=0*e,a=Math.hypot(1*e-e*Math.cos(2*Math.PI/r),i-e*Math.sin(2*Math.PI/r));2*t>a&&r>1&&r--;for(let t=0;r>t;t++)n.push({x:e*Math.cos(2*t*Math.PI/r),y:e*Math.sin(2*t*Math.PI/r)});const s=e-2*t;t>s?e>2*t&&n.push({x:0,y:0}):o(s)};return o(e-t),n}function en(e,t,n){const o=[];let r=n,i=0;for(;r>0&&60>i;){const n=t*(1+2*i),a=Jt(Ut(e,n),t),s=a.length-r,c=s>1?a.slice(Math.floor(s/2),Math.floor(s/2)+r):a,l=e.height-n;if(c.forEach((e,t)=>{o.push({x:e.x+Zt(97*i+t,.15),z:l+Zt(31*i+t,.05)})}),r-=c.length,i++,0===c.length)break}return{pearls:o,layers:i}}function tn(e,t,n,o){if(0>=o)return[];const r=function(e,t,n){let o=n,r=0;for(;o>0&&60>r;){const n=Ut(e,t+.875*(1+2*r));o-=Math.max(1,Math.floor(2*n/Vt)),r++}return r}(e,t,o),i=Math.max(t,n-r*Vt)+.875,a=[];let s=0;for(let t=0;r>t&&o>s;t++){const n=i+Vt*t,r=Ut(e,n),c=Math.max(1,Math.floor(2*r/Vt)),l=(2*r-c*Vt)/(c+1),u=-r+l,d=e.height-n-.875-.1;for(let e=0;c>e&&o>s;e++)a.push({cx:u+(l+Vt)*e+.875,cy:d+.875,rotation:Zt(53*t+e,10)}),s++}return a}function nn(e,t){const n=Number(e);return Number.isFinite(n)?n:t}var on=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height)return{nodes:[]};const o=d(t.categoryAccessor??"name"),r=d(t.teaVolumeAccessor??"teaVolume"),i=d(t.bobaVolumeAccessor??"bobaVolume"),a=d(t.iceVolumeAccessor??"iceVolume"),s=d(t.cupHeightAccessor??"cupHeight"),c=d(t.cupTopRadiusAccessor??"cupTopRadius"),l=d(t.cupBottomRadiusAccessor??"cupBottomRadius"),u=d(t.bobaRadiusAccessor??"bobaRadius"),h=t.cupWidthRatio??.82,f=e.scales.o,m=f.bandwidth(),p=Math.max(1,n.height-26-8),g=n.y+8,y=[],x=[];for(const t of e.data){const n=o(t)+"",d=f(n);if(null==d)continue;const b={height:nn(s(t),15.5),topRadius:nn(c(t),4.75),bottomRadius:nn(l(t),3.75)},w=nn(u(t),.6),M=Math.max(0,nn(r(t),450)),$=Math.max(0,nn(i(t),110)),A=Math.max(0,nn(a(t),135)),S=Math.PI*w*w,I=Math.floor($/S),j=I*S,C=Math.floor(A/5.359375),N=C*Vt*Vt*Vt,L=M+j+N,z=Qt(b,L),T=Math.min(b.height,Math.max(0,z)),E=Ut(b,T),{pearls:F,layers:R}=en(b,w,I),W=T,P=tn(b,R*w*2,W,C),O=b.height-20.32,q=Math.min(0,O),D=Math.min(m*h/(2*(b.topRadius+1)),p/(b.height-q)),B=d+m/2,Y=e=>B+e*D,G=e=>g+(e-q)*D,H=Y(-(b.topRadius+1)),_=Y(b.topRadius+1),V=G(q),X=G(b.height),U=v({name:n,teaVolume:M,bobaVolume:Math.round(j),iceVolume:Math.round(N),totalVolume:Math.round(L),numBobas:I,numIce:C,kind:"boba cup"});y.push({type:"rect",x:H,y:V,w:Math.max(1,_-H),h:Math.max(1,X-V),style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:U,group:n,_transitionKey:"boba-"+k(n)});const K=b.height-W,Q=k(n),Z=e.resolveColor(n);x.push((0,_t.jsxs)("g",{children:[M>0?(0,_t.jsx)("path",{d:`M${Y(-E)},${G(K)} L${Y(-b.bottomRadius)},${G(b.height)} L${Y(b.bottomRadius)},${G(b.height)} L${Y(E)},${G(K)} z`,fill:"#D2B799"}):null,F.map((e,t)=>(0,_t.jsx)("circle",{cx:Y(e.x),cy:G(e.z),r:w*D,fill:"#222222",opacity:.5},"p-"+t)),P.map((e,t)=>(0,_t.jsx)("rect",{x:Y(e.cx)-.95*Vt*D/2,y:G(e.cy)-.95*Vt*D/2,width:.95*Vt*D,height:.95*Vt*D,rx:2,fill:"#a5f2f3",opacity:.85,transform:`rotate(${e.rotation} ${Y(e.cx)} ${G(e.cy)})`},"i-"+t)),(0,_t.jsx)("path",{d:`M${Y(-b.topRadius)},${G(0)} L${Y(-b.bottomRadius)},${G(b.height)} L${Y(b.bottomRadius)},${G(b.height)} L${Y(b.topRadius)},${G(0)}`,fill:"none",stroke:Xt,strokeWidth:2.5}),(0,_t.jsx)("line",{x1:Y(-(b.topRadius+1)),y1:G(0),x2:Y(b.topRadius+1),y2:G(0),stroke:Xt,strokeWidth:3,strokeLinecap:"round"}),M>0?(0,_t.jsx)("path",{d:`M${Y(-.635)},${G(O)} L${Y(-.635)},${G(b.height-.4)} L${Y(.635)},${G(b.height-1.27-.4)} L${Y(.635)},${G(O)} z`,fill:"#4F91CB",stroke:Xt,strokeWidth:1,opacity:.78}):null,(0,_t.jsx)("text",{x:B,y:X+16,textAnchor:"middle",fontSize:12,fontWeight:600,fill:"var(--semiotic-text, #333)",children:n}),(0,_t.jsx)("text",{x:B,y:X+30,textAnchor:"middle",fontSize:10,fill:Z,children:`${I} pearls · ${Math.round(L)} cm³`})]},"boba-"+Q))}return{nodes:y,overlays:(0,_t.jsx)("g",{className:"semiotic-boba",style:{pointerEvents:"none"},children:x})}};function rn(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 an(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 sn(e){return null==e?null:e+""}function cn(e,t,n){return t.stickyPositionCache?.set(e,n),n}var ln=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function un(e){return!!e&&"object"==typeof e&&ln.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}new Set(["label","callout","callout-circle","callout-rect"]);var dn=2e4,hn=1;function fn(e){return"primary"===e?.emphasis||!0===e?.defensive}function mn(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:dn))):1/0}function pn(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const o=e?.provenance?.confidence;switch("number"==typeof o&&Number.isFinite(o)&&(t+=15*Math.max(0,Math.min(1,o))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}function gn(e){const{annotations:t,width:n,height:o}=e,r=Math.max(0,e.minVisible??hn),i=mn(n,o,e),a=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,un(n))};var n}),s=a.filter(e=>e.note);if(0===s.length||i>=s.length)return{visible:t.slice(),deferred:[],budget:i};const c=s.filter(e=>fn(e.annotation)),l=s.filter(e=>!fn(e.annotation)).sort((e,t)=>pn(t.annotation)-pn(e.annotation)||e.index-t.index),u=Math.min(l.length,Math.max(Math.max(0,i-c.length),Math.max(0,r-c.length))),d=new Set([...c.map(e=>e.index),...l.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}}var yn=32,xn=6,bn=4,wn=8,Mn=72,vn=30,kn=-30,$n=8,An=480,Sn=3;var In={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function jn(e){if(!Cn(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 Cn(e){return un(e)}function Nn(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),o=e.split(/\s+/).filter(Boolean),r=[];let i="";for(const e of o)i&&i.length+e.length+1>n?(r.push(i),i=e):i=i?`${i} ${e}`:e;return i&&r.push(i),r}function Ln(e,t,n,o,r){const i=e+n,a=t+o;return Math.abs(n)>Math.abs(o)?{x:0>n?i-r.width-4:i+4,y:0>o?a-r.height:a,width:r.width,height:r.height}:{x:0>n?i-r.width:i,y:0>o?a-r.height-4:a+4,width:r.width,height:r.height}}function zn(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Tn(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 En(e,t,n,o,r,i,a,s){const c=zn(e,a);let l=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,o){const r=Math.max(0,o-e.x),i=Math.max(0,o-e.y);return(r+Math.max(0,e.x+e.width-(t-o)))*e.height+(i+Math.max(0,e.y+e.height-(n-o)))*e.width}(c,r,i,s);for(const e of n)l+=12*Tn(c,e);for(const e of o)l+=4*Tn(c,e);return l}function Fn(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const o=e.pointId??e.nodeId;if(null!=o&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===o);if(e)return{x:e.x,y:e.y}}const r=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(r)&&r.length>=2&&i){const e=r[0],t=r[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?function(e,t,n){const o=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===e.pointId)return cn(t,n,{x:r.x,y:r.y})}const o=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],o=e.scales?.x??e.scales?.time,r=e.scales?.y??e.scales?.value;if(!o||!r)return null;const i=n[e.xAccessor||"x"],a=n[e.yAccessor||"y"];return null==i||null==a?null:{x:o(i),y:r(a)}}(n);return o?cn(t,n,o):null}if("semantic"===o){const o=function(e,t,n){const o=function(e){return sn(e.provenance?.stableId??e.stableId)}(e);if(!o)return null;const r=n.pointNodes?.find(e=>sn(e.pointId)===o);if(r)return cn(t,n,{x:r.x,y:r.y});const i=n.data?.find(e=>function(e){return sn(e.stableId??e.id??e.provenance?.stableId)}(e)===o);if(!i)return null;const a=rn(i,n),s=an(i,n);return null==a||null==s?null:cn(t,n,{x:a,y:s})}(e,t,n);if(o)return o}let r=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(r=t.x,i=t.y)}if(null!=r&&null!=i||(r=rn(e,n),i=an(e,n)),null!=r&&null!=i)return cn(t,n,{x:r,y:i});if("sticky"===o){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}(e,t,n):{x:e.x,y:e.y}}function Rn(e){const{annotations:t,context:n,defaultOffset:o=yn,notePadding:r=xn,markPadding:i=bn,edgePadding:a=wn,preserveManualOffsets:s=!0,routeLongConnectors:c=!0,connectorThreshold:l=Mn,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:m,cohesion:p,audience:g}=e,y=n.width||0,x=n.height||0,b="object"==typeof m?m:{},w=b.breakpoint??An,M=!!m&&w>=y,v=M&&!1!==b.preferShortText?t.map(jn):t,k=M&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,$=d||M&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),A=M&&!f?b.responsive??{minWidth:w}:f,S=M&&!p?b.cohesion:p;if(0===v.length||0>=y||0>=x)return v.slice();const I=[],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 C=!1;const N=v.map((e,t)=>{if(!Cn(e))return e;const i=Fn(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=[...Nn("string"==typeof e.title?e.title:void 0,t),...Nn("string"==typeof e.label?e.label:void 0,t)],o=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*o)+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:vn,dy:kn}}(e);return I.push(zn(Ln(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),r)),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}]}(o)){const t=En(Ln(i.x,i.y,e.dx,e.dy,u),e,I,j,y,x,r,a);f>t&&(h=e,f=t)}if(!h)return e;const m=zn(Ln(i.x,i.y,h.dx,h.dy,u),r);I.push(m);const p=Math.hypot(h.dx,h.dy),g=c&&p>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return C=!0,{...e,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),L=C?N:v.slice();let z=L;if(h){let e=!1;const t=L.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)<$n?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});z=e?t:L}{let e=!1;const t=z.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?In[t.source]??t.source:null,o="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!o)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const r=[n,o].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${r})`)?e:{...e,label:i?`${i} (${r})`:`(${r})`}}(t);return n!==t&&(e=!0),n});z=e?t:z}const T=new Set;if(k){const e="object"==typeof k?k:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return Sn;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?Sn:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(g),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??mn(y,x,e))*t))},{deferred:o}=gn({annotations:z,width:y,height:x,...n});for(const e of o)T.add(e)}if(A&&("object"==typeof A&&"number"==typeof A.minWidth?A.minWidth:An)>=y)for(const e of z)Cn(e)&&"secondary"===e.emphasis&&T.add(e);if(T.size>0)for(const e of z)!0===e?.defensive&&T.delete(e);let E;return E=0===T.size?z:$?z.map(e=>T.has(e)?{...e,_annotationDeferred:!0}:e):z.filter(e=>!T.has(e)),S?function(e,t){let n=!1;const o=e.map(e=>Cn(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?o:e}(E,S):E}var Wn=["naturalGas","coal","nuclear","hydro","wind","solar","other"],Pn={naturalGas:"Natural gas",coal:"Coal",nuclear:"Nuclear",hydro:"Hydro",wind:"Wind",solar:"Solar",other:"Other"},On={tight:5,watch:12,comfortable:20};function qn(e,t=0){return"number"==typeof e&&Number.isFinite(e)?e:t}function Dn(e,t={}){const n=t.fuels??Wn,o=!0===t.includeZero,r=[];for(const t of e)if(t&&"number"==typeof t.t)for(const e of n){const n=qn(t.fuels?.[e]);(o||n>0)&&r.push({t:t.t,fuel:e,fuelLabel:Pn[e],mw:n,ba:t.ba})}return r}function Bn(e){const t=[];for(const n of e){if(!n||"number"!=typeof n.t)continue;const e=qn(n.demandMw),o=n.forecastMw;"number"==typeof o&&Number.isFinite(o)&&t.push({t:n.t,a:e,b:o,demandMw:e,forecastMw:o,errorMw:e-o,ba:n.ba})}return t}function Yn(e){const t=qn(e.demand);if(0>=t)return 0;const n=qn(e.capacityOrNetGen),o=qn(e.interchange);return(n+(0>o?-o:0)-t)/t*100}function Gn(e){return e.filter(e=>e&&"number"==typeof e.t).map(e=>{const t=qn(e.demandMw),n=qn(e.netGenMw),o=Yn({demand:t,capacityOrNetGen:n,interchange:e.interchangeMw});return{t:e.t,ba:e.ba,reserveMarginPct:o,netLoadMw:t,demandMw:t,netGenMw:n}})}function Hn(e={},t={}){const{watch:n,comfortable:o}={...On,...e},r=t.field,i=r?{field:r}:{},a=t.tightHatch??{type:"hatch",background:"var(--semiotic-danger, #c2410c)",stroke:"rgba(255, 240, 200, 0.55)",spacing:5,angle:-35,lineWidth:1.25,lineOpacity:.9};return[{id:"reserve-comfortable",label:`Comfortable (≥ ${o}%)`,when:{...i,gte:o},style:{fill:t.comfortableFill??"var(--semiotic-success, #16a34a)",fillOpacity:.85}},{id:"reserve-watch",label:`Watch (< ${o}%, ≥ ${n}%)`,when:{...i,lt:o,gte:n},style:{fill:t.watchFill??"var(--semiotic-warning, #d97706)",fillOpacity:.9}},{id:"reserve-tight",label:`Tight (< ${n}%)`,when:{...i,lt:n},style:{fill:a,stroke:t.tightFill??"var(--semiotic-danger, #c2410c)",strokeWidth:1,fillOpacity:1}}]}function _n(e={}){const{tight:t,watch:n,comfortable:o}={...On,...e};return[{type:"band",y0:-50,y1:t,label:"Tight",color:"var(--semiotic-danger, #c2410c)",fillOpacity:.12,emphasis:"secondary"},{type:"band",y0:t,y1:n,label:"Watch",color:"var(--semiotic-warning, #d97706)",fillOpacity:.1,emphasis:"secondary"},{type:"band",y0:n,y1:Math.max(o+30,40),label:"Headroom",color:"var(--semiotic-success, #16a34a)",fillOpacity:.06,emphasis:"secondary"}]}function Vn(e,t){if(!e.length)return null;const n=[...e].filter(e=>e&&"number"==typeof e.t).sort((e,t)=>e.t-t.t);if(!n.length)return null;let o=n[n.length-1];if("number"==typeof t&&Number.isFinite(t)){const e=n.filter(e=>t>=e.t);o=e.length?e[e.length-1]:n[0]}const r=qn(o.demandMw),i=qn(o.netGenMw),a="number"==typeof o.forecastMw&&Number.isFinite(o.forecastMw)?o.forecastMw:null,s=Yn({demand:r,capacityOrNetGen:i,interchange:o.interchangeMw}),c={};let l=null,u=0,d=0;for(const e of Wn){const t=qn(o.fuels?.[e]);t>0&&(d+=t,c[e]=t,t>u&&(u=t,l=e))}if(d>0)for(const e of Object.keys(c))c[e]=c[e]/d;return{t:o.t,ba:o.ba,demandMw:r,forecastMw:a,forecastErrorMw:null==a?null:r-a,netGenMw:i,reserveMarginPct:s,topFuel:l,topFuelShare:d>0?u/d:0,topFuelMw:u,fuelShares:c}}function Xn(e,t={}){const n=t.now??Date.now(),o=t.author??"system",r=t.source??"authored-scenario";return e.map(e=>{const t=(e.start+e.end)/2,i=new Date(e.start).toISOString();return{type:"x-band",x0:e.start,x1:e.end,label:e.label,color:"outage"===e.kind?"var(--semiotic-danger)":"var(--semiotic-warning)",fillOpacity:.12,emphasis:"secondary",x:t,y:e.y??e.value,note:e.note,provenance:{author:o,authorKind:"system",source:r,basis:"rule",confidence:.85,createdAt:i,stableId:e.id,dataVersion:e.start+""},lifecycle:{status:"accepted",ttlHint:e.ttlHint??"P14D",anchor:"fixed"},_eventKind:e.kind,_createdAtMs:e.start,_nowMs:n}})}function Un(e,t=12){return[...e].filter(e=>Number.isFinite(e.reserveMarginPct)).sort((e,t)=>e.reserveMarginPct-t.reserveMarginPct).slice(0,Math.max(0,t))}function Kn(e,t=0){return Number.isFinite(e)?e.toLocaleString(void 0,{maximumFractionDigits:t,minimumFractionDigits:t})+" MW":"—"}function Qn(e,t=1){return Number.isFinite(e)?`${e>0?"+":""}${e.toFixed(t)}%`:"—"}var Zn=c(require("react"));function Jn(e,t){if("function"==typeof e)return e;const n=e??t;return e=>Number(e[n])}function eo(e,t={}){const n=Jn(t.start,"start"),o=Jn(t.end,"end"),r=!1===t.sort?e.slice():e.slice().sort((e,t)=>n(e)-n(t)||o(t)-o(e)),i=[];return{packed:r.map(e=>{const t=n(e);let r=i.findIndex(e=>t>=e);return-1===r&&(r=i.length),i[r]=o(e),{item:e,track:r}}),trackCount:Math.max(1,i.length)}}function to(e,t){const n=Jn(t.start,"start"),o=Jn(t.end,"end"),[r,i]=t.domain,a=t.step??1,s="half-open"===t.bounds,c=[];for(let t=r;i>=t;t+=a){let r=0;for(const i of e){const e=n(i),a=o(i);e>t||(s?t>=a:t>a)||r++}c.push({value:t,count:r})}return c}function no(e){return"function"==typeof e?e:t=>t[e]}var oo=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height||0===e.data.length||!t?.domain)return{nodes:[]};const o=no(t.laneAccessor),r=no(t.startAccessor),i=no(t.endAccessor),a=t.idAccessor?no(t.idAccessor):null,s=t.unit??0,c=t.barGap??1.5,l=Math.max(0,t.minBarWidth??2),u=t.minBarHeight??3.5,d=t.maxBarHeight??10,h=t.lanePadding??7,f=t.cornerRadius??2,m=t.bottomInset??0,p=t.color??((t,n)=>e.resolveColor(n)),[g,y]=t.domain,x=y-g||1,b=e=>n.x+(e-g)/x*n.width,w=e.scales?.o?.domain?.()??[],M=t.lanes??(w.length>0?w:[...new Set(e.data.map(o))]),v=Math.max(0,n.height-m)/Math.max(1,M.length),k=e=>b(r(e)),$=e=>Math.max(k(e)+l,b(i(e)+s)),A=[];M.forEach((t,r)=>{const i=n.y+r*v,s=e.data.filter(e=>o(e)===t);if(0===s.length)return;const{packed:l,trackCount:m}=eo(s,{start:k,end:$}),g=new Map,y=new Map;for(const{item:e,track:t}of l){const n=y.get(t);n?n.push(e):y.set(t,[e])}for(const e of y.values()){e.sort((e,t)=>k(e)-k(t));for(let t=0;e.length-1>t;t++)g.set(e[t],k(e[t+1]))}const x=(v-2*h)/m,b=Math.min(d,Math.max(Math.min(u,x),x-c));for(const{item:e,track:n}of l){const o=k(e),r=g.get(e),s=$(e)-o;A.push({type:"rect",x:o,y:i+h+n*x,w:void 0!==r&&o+s>r-1?Math.max(1,r-1-o):s,h:b,cornerRadii:f>0?{tl:f,tr:f,br:f,bl:f}:void 0,style:{fill:p(e,t),stroke:"none"},datum:e,group:t,_transitionKey:a?a(e)+"":void 0})}});const S=`var(--semiotic-text, ${e.theme.semantic.text??"#1a1a1a"})`,I=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,j=`var(--semiotic-border, ${e.theme.semantic.border??"#94a3b8"})`,C=[];(t.periods??[]).forEach((e,t)=>{const o=b(e.start),r=Math.max(1,b(e.end+s)-o);C.push(Zn.createElement("rect",{key:"period-"+t,x:o,y:n.y,width:r,height:n.height,fill:j,opacity:t%2==0?.06:.025,pointerEvents:"none"})),e.name&&C.push(pt({keyId:"period-label-"+t,text:e.name,x:o+4,y:n.y+12,anchor:"start",baseline:"hanging",fontSize:13,fontWeight:700,color:I}))});const N=!1!==t.showLaneLabels,L=t.laneLabelGap??12;if(M.forEach((e,t)=>{const o=n.y+t*v;C.push(Zn.createElement("line",{key:"lane-sep-"+t,x1:n.x,x2:n.x+n.width,y1:o,y2:o,stroke:j,opacity:.45})),N&&C.push(pt({keyId:"lane-label-"+t,text:e,x:n.x-L,y:o+v/2,anchor:"end",baseline:"middle",fontSize:12,fontWeight:600,color:S}))}),!1!==t.showAxis){const e=t.axisTicks??Array.from({length:8},(e,t)=>Math.round(g+t/7*x));C.push(yt({keyId:"interval-axis",scale:b,ticks:e,orient:"top",offset:n.y,tickLength:0,gridLength:n.height,gridDasharray:"3 5",edgeAnchor:!0,format:t.tickFormat,color:I}))}return{nodes:A,overlays:Zn.createElement(Zn.Fragment,null,...C)}};function ro(e,t,n){const o=n?.orientation??"vertical",r=n?.bend??0,i=n?.minAlong??18,a=(e,t)=>(e+t)/2;if("vertical"===o){if(i>Math.abs(t.y-e.y)){const n=e.x>t.x?-1:1,o=a(e.x,t.x)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${o},${a(e.y,t.y)} ${t.x},${t.y}`}const n=a(e.y,t.y)+r;return`M${e.x},${e.y} C${e.x},${n} ${t.x},${n} ${t.x},${t.y}`}if(i>Math.abs(t.x-e.x)){const n=e.y>t.y?-1:1,o=a(e.y,t.y)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${a(e.x,t.x)},${o} ${t.x},${t.y}`}const s=a(e.x,t.x)+r;return`M${e.x},${e.y} C${s},${e.y} ${s},${t.y} ${t.x},${t.y}`}function io(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=(e.y+t.y)/2;return`M${e.x},${e.y} L${e.x},${n} L${t.x},${n} L${t.x},${t.y}`}const o=(e.x+t.x)/2;return`M${e.x},${e.y} L${o},${e.y} L${o},${t.y} L${t.x},${t.y}`}function ao(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=t.cy>=e.cy;return{from:{x:e.cx,y:e.cy+(n?e.height/2:-e.height/2)},to:{x:t.cx,y:t.cy+(n?-t.height/2:t.height/2)}}}const o=t.cx>=e.cx;return{from:{x:e.cx+(o?e.width/2:-e.width/2),y:e.cy},to:{x:t.cx+(o?-t.width/2:t.width/2),y:t.cy}}}function so(e,t){const n=t?.spread??5;return t?.modulo&&t.modulo>0?(e%t.modulo-(t.modulo-1)/2)*n:(e-((t?.count??1)-1)/2)*n}function co(e,t){const n=1-t,o=n*n*n,r=3*n*n*t,i=3*n*t*t,a=t*t*t;return{x:o*e.p0.x+r*e.p1.x+i*e.p2.x+a*e.p3.x,y:o*e.p0.y+r*e.p1.y+i*e.p2.y+a*e.p3.y}}function lo(e,t){const n=1-t,o=3*n*n,r=6*n*t,i=3*t*t;return{x:o*(e.p1.x-e.p0.x)+r*(e.p2.x-e.p1.x)+i*(e.p3.x-e.p2.x),y:o*(e.p1.y-e.p0.y)+r*(e.p2.y-e.p1.y)+i*(e.p3.y-e.p2.y)}}function uo(e){return`M${e.p0.x},${e.p0.y} C${e.p1.x},${e.p1.y} ${e.p2.x},${e.p2.y} ${e.p3.x},${e.p3.y}`}function ho(e,t){const n=t?.axis??"x",o=t?.padding??0,r=t?.strength??.5,i="x"===n?"y":"x",a="x"===n?"width":"height",s="x"===n?"height":"width",c=new Map;for(const t of e)c.set(t.id,0);for(let t=0;e.length>t;t++)for(let l=t+1;e.length>l;l++){const u=e[t],d=e[l];if(Math.abs(u[i]-d[i])>(u[s]+d[s])/2+o)continue;const h=d[n]-u[n]||(d.id>u.id?-.5:.5),f=(u[a]+d[a])/2+o-Math.abs(h);if(0>=f)continue;const m=f*r*Math.sign(h);c.set(u.id,(c.get(u.id)??0)-m),c.set(d.id,(c.get(d.id)??0)+m)}return c}var fo={width:60,height:34};function mo(e,t){if("function"==typeof e)return e;const n=e??t;return e=>h(e,n,void 0)}function po(e,t,n,o){const r=o.fixedAxis??"y",i=e=>mo(o.sourceAccessor,"source")(e)+"",a=e=>mo(o.targetAccessor,"target")(e)+"",s=o.size??(()=>fo),c=o.iterations??180,l=o.attraction??.012,u=o.anchorStrength??.003,d=o.collisionStrength??.12,h=o.collisionPadding??15,m=o.edgePadding??42,p=o.fixedPadding??16,g=o.damping??.72,y=o.spread??1,[x,b]=o.fixedDomain,w=b-x||1,M=("y"===r?n.y:n.x)+p,v=("y"===r?n.y+n.height:n.x+n.width)-p,k=("y"===r?n.x:n.y)+m,$=("y"===r?n.x+n.width:n.y+n.height)-m,A=Math.max(1,$-k),S=e.map(e=>{const t=f(e)??e,n=(r=e,mo(o.idAccessor,"id")(r)+"");var r;const{width:i,height:a}=s(t),c=(e=>Number(mo(o.fixedAccessor,"fixed")(e)))(e),l=k+function(e){let t=2166136261;for(let n=0;e.length>n;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0)/4294967295}(n)*A;return{data:t,id:n,width:i,height:a,fixedValue:c,fixed:(u=c,M+(u-x)/w*(v-M)),free:l,anchor:l};var u}),I=new Map(S.map(e=>[e.id,e])),j=e=>"y"===r?e.width:e.height;for(let e=0;c>e;e++){const e=new Map;for(const t of S)e.set(t.id,0);for(const n of t){const t=I.get(i(n)),o=I.get(a(n));if(!t||!o)continue;const r=(o.free-t.free)*l;e.set(t.id,(e.get(t.id)??0)+r),e.set(o.id,(e.get(o.id)??0)-r)}for(const t of S)e.set(t.id,(e.get(t.id)??0)+(t.anchor-t.free)*u);const n=ho(S.map(e=>({id:e.id,x:"y"===r?e.free:e.fixed,y:"y"===r?e.fixed:e.free,width:e.width,height:e.height})),{axis:"y"===r?"x":"y",padding:h,strength:d});for(const t of S)e.set(t.id,(e.get(t.id)??0)+(n.get(t.id)??0));for(const t of S){t.free+=(e.get(t.id)??0)*g;const n=j(t)/2;t.free=Math.max(k+n,Math.min($-n,t.free))}}if(1!==y){const e=(k+$)/2;for(const t of S){const n=j(t)/2;t.free=Math.max(k+n,Math.min($-n,e+(t.free-e)*y))}}const C=S.map(e=>({data:e.data,id:e.id,x:"y"===r?e.free:e.fixed,y:"y"===r?e.fixed:e.free,width:e.width,height:e.height,fixedValue:e.fixedValue}));return{positioned:C,byId:new Map(C.map(e=>[e.id,e]))}}var go=e=>{const{plot:t}=e.dimensions;if(0>=t.width||0>=t.height||0===e.nodes.length||!e.config?.fixedDomain)return{sceneNodes:[]};const n=e.config.fixedAxis??"y",{positioned:o,byId:r}=po(e.nodes,e.edges,t,e.config),i=o.map(t=>({type:"rect",x:t.x-t.width/2,y:t.y-t.height/2,w:t.width,h:t.height,style:{fill:e.resolveColor(t.id),stroke:"none"},datum:t.data,id:t.id,label:t.id})),a=[];e.edges.forEach((t,o)=>{const i=r.get((s=t,("function"==typeof e.config.sourceAccessor?e.config.sourceAccessor(s):h(s,e.config.sourceAccessor??"source",void 0))+""));var s;const c=r.get((t=>("function"==typeof e.config.targetAccessor?e.config.targetAccessor(t):h(t,e.config.targetAccessor??"target",void 0))+"")(t));if(!i||!c)return;const{from:l,to:u}=ao({cx:i.x,cy:i.y,width:i.width,height:i.height},{cx:c.x,cy:c.y,width:c.width,height:c.height},{orientation:"y"===n?"vertical":"horizontal"});a.push({type:"curved",pathD:ro(l,u,{orientation:"y"===n?"vertical":"horizontal",bend:so(o,{modulo:5,spread:5})}),style:{stroke:"var(--semiotic-border, #888)",fill:"none",strokeWidth:1.4},datum:f(t)??t})});const s=o.map(e=>({x:e.x,y:e.y,text:e.id}));return{sceneNodes:i,sceneEdges:a,labels:s}};function yo(e){const t=Number(e.segmentDomain?.[0]),n=Number(e.segmentDomain?.[1]),o=Number.isFinite(t)?t:0,r=Number.isFinite(n)?n:o,i=o>r?-1:1,a=Math.abs(r-o),s=Number(e.currentSegment),c=Number.isFinite(s)?$((s-o)*i,0,a):0,l=(e,t)=>{const n=Number(e);return Number.isFinite(n)?$(n,0,1):t},u=l(e.oldestOpacity,.25),d=l(e.currentOpacity,1),h=l(e.futureOpacity,0);return{weightOpacity:!0===e.combineWeightOpacity,wordOpacity:({segment:e})=>{const t=Number(e);if(!Number.isFinite(t))return h;const n=(t-o)*i;if(n>c)return h;if(0===c)return d;const r=$(n/c,0,1);return u+(d-u)*r}}}var xo=require("react/jsx-runtime");function bo(e){let t=2166136261;for(let n=0;e.length>n;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0)/4294967295}var wo=1.15,Mo={a:.556,b:.556,c:.5,d:.556,e:.556,f:.278,g:.556,h:.556,i:.222,j:.222,k:.5,l:.222,m:.833,n:.556,o:.556,p:.556,q:.556,r:.333,s:.5,t:.278,u:.556,v:.5,w:.722,x:.5,y:.5,z:.5,"'":.191,"-":.333,".":.278," ":.278};function vo(e){let t=0;for(const n of e)t+=Mo[n]??.6;return t}function ko(e,t){return Math.max(8,vo(e)*t*1.05+1)}function $o(e,t,n){for(const o of t)if((e.w+o.w)/2+n>Math.abs(e.x-o.x)&&(e.h+o.h)/2+n>Math.abs(e.y-o.y))return!0;return!1}var Ao=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height||0===e.data.length)return{nodes:[]};const o=d(t.textAccessor),r=e=>{const n=Number(d(t.weightAccessor)(e));return Number.isFinite(n)&&n>0?n:0},i=d(t.columnAccessor),a=e=>Number(d(t.segmentAccessor)(e)),s=t.minFontSize??11,c=t.maxFontSize??42,l=t.columnGutter??18,u=t.collisionPadding??2,h=!1!==t.showColumnLabels,f=!1!==t.showSegmentAxis,m=t.segmentTickCount??6,g=t.segmentTickFormat??(e=>Math.round(e)+""),y=t.rotate??0,x=!0===t.repeatWords,b=!1!==t.scaleToFit,w=t.packingDensity??.6,M="string"==typeof t.textAccessor?t.textAccessor:"word",v="string"==typeof t.weightAccessor?t.weightAccessor:"weight",k="string"==typeof t.columnAccessor?t.columnAccessor:"column",A="string"==typeof t.segmentAccessor?t.segmentAccessor:"segment",S=[],I=new Map;let j=1/0,C=-1/0;for(let t=0;e.data.length>t;t++){const n=e.data[t],s=i(n)+"",c=o(n)+"",l=r(n),u=a(n);c&&Number.isFinite(u)&&(I.has(s)||(S.push(s),I.set(s,[])),I.get(s).push({col:s,text:c,weight:l,segment:u,datum:n,dataIndex:t}),j>u&&(j=u),u>C&&(C=u))}if(0===S.length)return{nodes:[]};if(!x)for(const[e,t]of I){const n=new Map;for(const e of t){const t=n.get(e.text);t&&t.weight>=e.weight||n.set(e.text,e)}I.set(e,[...n.values()])}let N=1/0,L=-1/0;for(const e of I.values())for(const t of e)N>t.weight&&(N=t.weight),t.weight>L&&(L=t.weight);if(!Number.isFinite(N))return{nodes:[]};const z=t.columnOrder?[...t.columnOrder.filter(e=>I.has(e)),...S.filter(e=>!t.columnOrder.includes(e))]:S,T=new Map(z.map(n=>[n,t.columnColor?.(n)||e.resolveColor(n)])),[E,F]=t.segmentDomain??[j,C],R=F-E||1,W=L-N||1,P=h?22:0,O=f?52:0,q=n.x+O,D=n.y+P,B=Math.max(0,n.width-O),Y=Math.max(0,n.height-P),G=z.length,H=G>0?Math.max(0,B-l*Math.max(0,G-1))/G:0,_=D+14,V=D+Y-14,X=e=>_+(e-E)/R*(V-_),U=H*Y;let K=1/0,Q=1/0;const Z=z.map((e,n)=>{const o=T.get(e),r=(I.get(e)??[]).map(e=>{const r={word:e.text,column:e.col,weight:e.weight,segment:e.segment,datum:e.datum,dataIndex:e.dataIndex,columnIndex:n,resolvedColumnColor:o},i=t.wordOpacity?Number(t.wordOpacity(r)):1,a=t.wordColor?.(r);return{text:e.text,weight:e.weight,segment:e.segment,baseFont:(l=e.weight,s+Math.sqrt((l-N)/W)*(c-s)),opacity:Number.isFinite(i)?$(i,0,1):0,color:a||o,info:r};var l});if(0===r.length)return null;let i=0;for(const e of r){const t=1.05*vo(e.text);i+=t*wo*e.baseFont*e.baseFont,Q=Math.min(Q,(H-8-1)/(t*e.baseFont))}return i>0&&(K=Math.min(K,Math.sqrt(w*U/i))),{col:e,colLeft:q+n*(H+l),center:q+n*(H+l)+H/2,rows:r}}).filter(e=>null!==e),J=e=>{const t=[];let n=0;for(const o of Z){if(0>=H)continue;const r=o.colLeft+4,i=o.colLeft+H-4,a=o.rows.map((t,n)=>{const r=Math.max(5,e*t.baseFont),i=`${o.col}::${t.text}::${n}`;return{id:i,text:t.text,weight:t.weight,segment:t.segment,font:r,w:ko(t.text,r),h:r*wo+2,anchorY:X(t.segment),seed:(bo(i)-.5)*Math.min(.5*H,80),opacity:t.opacity,color:t.color,info:t.info}}).sort((e,t)=>t.font-e.font||(t.id>e.id?-1:1)),s=[];for(const e of a){const a=e.w/2,c=e.h/2,l=$(o.center+e.seed,r+a,i-a),d=e.anchorY;let h=l,f=$(d,_+c,V-c),m=!1;for(let t=0;2600>t;t++){const n=3.2*Math.sqrt(t),o=2.399963229728653*t,p={x:$(l+n*Math.cos(o),r+a,i-a),y:$(d+n*Math.sin(o),_+c,V-c),w:e.w,h:e.h};if(!$o(p,s,u)){h=p.x,f=p.y,m=!0;break}}m||n++,s.push({x:h,y:f,w:e.w,h:e.h});const g=Math.sqrt((e.weight-N)/W),x=y>0?2*(bo(e.id+"r")-.5)*y:0;t.push({id:e.id,text:e.text,x:h,y:f,fontSize:e.font,rotation:x,color:e.color,opacity:e.opacity,datum:p(t=>{for(const n of Object.keys(e.info.datum))t(n,e.info.datum[n]);t("word",e.text),t("weight",e.weight),t("column",o.col),t("segment",e.segment),"word"!==M&&t(M,e.text),"weight"!==v&&t(v,e.weight),"column"!==k&&t(k,o.col),"segment"!==A&&t(A,e.segment),t("__strength",.5+.5*g)})})}}return{placed:t,unplaced:n}};let ee=b?Math.min(1,K,Q):Math.min(1,Q),te=J(ee);if(b)for(let e=0;6>e&&te.unplaced>0&&ee>.1;e++)ee*=.88,te=J(ee);const ne=te.placed.filter(e=>e.opacity>0);return{nodes:ne.map(e=>{const t=ko(e.text,e.fontSize)/2,n=e.fontSize*wo/2;return{type:"rect",x:e.x-t,y:e.y-n,w:2*t,h:2*n,style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:e.datum,group:e.datum.column+"",_transitionKey:e.id}}),overlays:(0,xo.jsxs)("g",{className:"semiotic-word-trails",children:[f&&So({x:n.x+O-10,yTop:_,yBot:V,segLo:E,segHi:F,segToY:X,tickCount:m,tickFormat:g,color:`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,label:t.segmentAxisLabel,labelX:n.x}),h&&z.map((e,t)=>H>0?(0,xo.jsx)("text",{x:q+t*(H+l)+H/2,y:n.y+14,textAnchor:"middle",fontSize:13,fontWeight:600,fill:T.get(e),style:{pointerEvents:"none"},children:e},"wt-col-"+t):null),ne.map(e=>(0,xo.jsx)("text",{x:e.x,y:e.y,textAnchor:"middle",dominantBaseline:"central",fontSize:e.fontSize,fontWeight:600,fill:e.color,opacity:(!1===t.weightOpacity?1:Number(e.datum.__strength))*e.opacity,transform:e.rotation?`rotate(${e.rotation} ${e.x} ${e.y})`:void 0,style:{pointerEvents:"none"},children:e.text},"wt-"+e.id))]})}};function So(e){const t=[],n=e.segHi-e.segLo||1;for(let o=0;e.tickCount>o;o++)t.push(e.segLo+n*o/Math.max(1,e.tickCount-1));return(0,xo.jsxs)("g",{className:"semiotic-word-trails-axis",style:{pointerEvents:"none"},children:[(0,xo.jsx)("line",{x1:e.x,y1:e.yTop,x2:e.x,y2:e.yBot,stroke:e.color,strokeWidth:1,opacity:.5}),t.map((t,n)=>{const o=e.segToY(t);return(0,xo.jsxs)("g",{children:[(0,xo.jsx)("line",{x1:e.x-4,y1:o,x2:e.x,y2:o,stroke:e.color,strokeWidth:1,opacity:.6}),(0,xo.jsx)("text",{x:e.x-7,y:o,textAnchor:"end",dominantBaseline:"central",fontSize:11,fill:e.color,children:e.tickFormat(t)})]},"wt-tick-"+n)}),e.label&&(0,xo.jsx)("text",{transform:`rotate(-90 ${e.labelX+10} ${(e.yTop+e.yBot)/2})`,x:e.labelX+10,y:(e.yTop+e.yBot)/2,textAnchor:"middle",fontSize:11,fontWeight:600,fill:e.color,children:e.label})]})}var Io={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},jo=8;function Co(e){return null==e?void 0:e+""}function No(e){const t=Co(e.id);return{type:"point",x:e.x,y:e.y,r:e.r??jo,style:{...Io},datum:e.datum,pointId:t,_transitionKey:t}}function Lo(e){return No(e)}function zo(e){const[[t,n],[o,r]]=e.bounds;return{type:"geoarea",pathData:e.pathData,centroid:e.centroid,bounds:e.bounds,screenArea:e.screenArea??Math.abs((o-t)*(r-n)),style:{...Io},datum:e.datum,group:e.group,interactive:!0}}function To(e){return{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...Io},datum:e.datum,group:e.group,_transitionKey:Co(e.id)}}function Eo(e){const t=Co(e.id);return"width"in e&&"height"in e?{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...Io},datum:e.datum,id:t,label:e.label}:{type:"circle",cx:e.x,cy:e.y,r:e.r??jo,style:{...Io},datum:e.datum,id:t,label:e.label}}function Fo(e,t,n={}){const{coord:o,step:r=1,equals:i=Object.is,truthyOnly:a=!1}=n,s=[],c=t=>o?o(e[t],t):t,l=(e,t,n)=>{e.endIndex=t,e.count=t-e.startIndex+1,e.end=o?null==n||c(n)-c(t)>r?c(t)+r:c(n):t+1,s.push(e)};let u=null;for(let n=0;e.length>n;n++){const s=t(e[n],n);if(a&&!s){u&&(l(u,u.endIndex,n),u=null);continue}const d=!o||0>=n||c(n)-c(n-1)<=r;u&&d&&i(u.value,s)?u.endIndex=n:(u&&l(u,u.endIndex,n),u={value:s,start:c(n),end:c(n),count:1,startIndex:n,endIndex:n})}return u&&l(u,u.endIndex,null),s}var Ro=Fo;function Wo(e,t,n=0){return t>0?((e-n)%t+t)%t+n:e}function Po(e,t,n){if(0>=n)return t-e;let o=(t-e)%n;return o>n/2?o-=n:-n/2>o&&(o+=n),o}function Oo(e,t,n){return t>n?e>=t||n>=e:e>=t&&n>=e}function qo(e,t,n,o){return n>o?[...e.filter(e=>t(e)>=n),...e.filter(e=>t(e)<=o)]:e.filter(e=>Oo(t(e),n,o))}function Do(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,a=e.length>1?Math.max(0,n-i-(t.paddingRight??r))/(e.length-1):0,s=new Map;return e.forEach((e,t)=>{s.set(e.id,{id:e.id,x:i+a*t,y:o,index:t})}),s}function Bo(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,a=t.paddingRight??r,s=t.gap??8,c=!1!==t.distribute,l=t.estimateWidth??(e=>Yo(e.label??e.id)),u=e.map((e,t)=>Math.max(1,l(e,t))),d=u.reduce((e,t)=>e+t,0)+s*Math.max(0,e.length-1),h=Math.max(0,n-i-a),f=c&&e.length>1?Math.max(0,h-d)/(e.length-1):0,m=new Map;let p=i;return c||1!==e.length||(p=i+Math.max(0,(h-u[0])/2)),e.forEach((e,t)=>{const n=u[t];m.set(e.id,{id:e.id,x:p+n/2,y:o,index:t,width:n}),p+=n+s+f}),m}function Yo(e,t=38,n=7.4,o=20){return Math.max(t,((e??"")+"").length*n+o)}function Go(e){const t=e.map(e=>{const t=Math.min(e.a,e.b),n=Math.max(e.a,e.b);return{span:e,a:t,b:n,width:n-t}}).sort((e,t)=>e.width-t.width||e.a-t.a),n=[],o=t.map(e=>{let t=n.findIndex(t=>e.a>=t);return 0>t?(t=n.length,n.push(e.b)):n[t]=e.b,{span:e.span,level:t}}),r=o.reduce((e,t)=>Math.max(e,t.level),0);return{packed:o,maxLevel:r,levelCount:o.length?r+1:1}}function Ho(e){const t=e.labelRoom??18,n=Math.max(48,e.baselineY-e.ceilingY-28),o=Math.max(1,e.levelCount),r=Math.min(42,Math.max(26,.18*n)),i=Math.max(24,n-r-t);return{arcLift:r,levelStep:Math.min(72,Math.max(28,o>1?i/Math.max(1,o-1):i))}}function _o(e,t,n,o,r={}){const i=n-(r.footLift??26);return`M${e} ${i}Q${(e+t)/2} ${o} ${t} ${i}`}function Vo(e,t,n){return e-n.arcLift-t*n.levelStep}function Xo(e,t=Uo){if(!e.length)return{shared:[],exclusive:[]};if(1===e.length)return{shared:[...e[0]],exclusive:[[]]};const n=e.map(e=>new Set(e.map(e=>t(e)))),o=new Set;for(const e of n[0])n.every(t=>t.has(e))&&o.add(e);const r=[],i=new Set;for(const n of e[0]){const e=t(n);o.has(e)&&!i.has(e)&&(r.push(n),i.add(e))}return{shared:r,exclusive:e.map(e=>e.filter(e=>!o.has(t(e))))}}function Uo(e){return null==e||"object"!=typeof e?e+"":null!=e.id?e.id+"":`${(e.sourceTokenId??e.source)+""}|${(e.targetTokenId??e.target)+""}|${(e.relation??e.label??"")+""}`}var Ko=2*Math.PI;function Qo(e,t,n){const o=n?.center?.x??0,r=n?.center?.y??0;return{x:o+Math.sin(e)*t,y:r-Math.cos(e)*t}}function Zo(e,t,n){return(Math.atan2(e-(n?.center?.x??0),-(t-(n?.center?.y??0)))+Ko)%Ko}function Jo(e,t){const[n,o]=e,r=o-n||1,i=t?.startAngle??0,a=t?.endAngle??Ko;return e=>i+(e-n)/r*(a-i)}function er(e,t){const[n,o]=e,[r,i]=t,a=o-n||1;return e=>r+(e-n)/a*(i-r)}function tr(e,t,n,o,r){const i=r?.center,a=(e,t)=>{const{x:n,y:o}=Qo(e,t,{center:i});return`${nr(n)},${nr(o)}`},s=Math.max(0,n),c=Math.max(s,o),l=Math.abs(t-e),u=e>t?0:1;if(l>=Ko-1e-6){const e=i?.x??0,t=i?.y??0,n=`${nr(e)},${nr(t-c)}`,o=`${nr(e)},${nr(t+c)}`;let r=`M${n} A${nr(c)},${nr(c)} 0 1 1 ${o} A${nr(c)},${nr(c)} 0 1 1 ${n} Z`;if(s>0){const n=`${nr(e)},${nr(t-s)}`,o=`${nr(e)},${nr(t+s)}`;r+=` M${n} A${nr(s)},${nr(s)} 0 1 0 ${o} A${nr(s)},${nr(s)} 0 1 0 ${n} Z`}return r}const d=l>Math.PI?1:0,h=a(e,c),f=a(t,c);if(0>=s){const e=i?.x??0,t=i?.y??0;return`M${nr(e)},${nr(t)} L${h} A${nr(c)},${nr(c)} 0 ${d} ${u} ${f} Z`}const m=a(t,s),p=a(e,s);return`M${h} A${nr(c)},${nr(c)} 0 ${d} ${u} ${f} L${m} A${nr(s)},${nr(s)} 0 ${d} ${1===u?0:1} ${p} Z`}function nr(e){return Math.round(1e3*e)/1e3}function or(e,t){return{x:e.x+t.x,y:e.y+t.y}}function rr(e,t){return{x:e.x-t.x,y:e.y-t.y}}function ir(e,t){return{x:e.x*t,y:e.y*t}}function ar(e){return Math.hypot(e.x,e.y)}function sr(e){const t=ar(e)||1;return{x:e.x/t,y:e.y/t}}var cr=[40,40],lr=[.5,.5];function ur(e,t){const[n,o]=e.viewBox??cr,[r,i]=e.anchor??lr,a=o>0?o:1,s=Math.max(0,t)/a,c=(n>0?n:a)*s,l=a*s;return{width:c,height:l,scale:s,offsetX:-r*c,offsetY:-i*l}}function dr(e,t){const n=ur(e,t),o=[[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 r=0;for(const[e,t]of o){const n=Math.sqrt(e*e+t*t);n>r&&(r=n)}return r}function hr(e,t,n,o){if("none"!==e)return"color"===e||null==e?t??o:"accent"===e?n:e}function fr(e,t,n=0,o="horizontal"){const[r,i]=e.viewBox??cr,a=Math.min(1,Math.max(0,n)),s=Math.min(1,Math.max(0,t));return s>a?a>0||1>s?"vertical"===o?{x:0,y:i*(1-s),width:r,height:i*(s-a)}:{x:r*a,y:0,width:r*(s-a),height:i}:null:{x:0,y:0,width:0,height:0}}var mr=require("react/jsx-runtime"),pr="var(--semiotic-text, currentColor)",gr=8;function yr(e,t){const n=oe(e,100);return n>0?t/n*100*(t/n):Math.PI*t*t}function xr(e){const t=[],n=e.colorMap?Object.entries(e.colorMap):e.keys?e.keys.map(t=>[t,e.color?e.color(t):void 0]):[];if(n.length>0){const o=e.colorType??"fill",r=n.map(([e,t])=>({label:e,color:t}));t.push({type:o,label:e.colorLabel??"",items:r,styleFn:"line"===o?e=>({stroke:e.color??pr,strokeWidth:2,fill:"none"}):e=>({fill:e.color??pr,stroke:e.color??pr})})}if(e.symbolMap&&Object.keys(e.symbolMap).length>0){const n=e.symbolColor??pr,o=Object.entries(e.symbolMap).map(([e,t])=>({label:e,shape:t,color:n}));t.push({label:e.symbolLabel??"",items:o,styleFn:()=>({}),type:e=>{const t=e.shape;return(0,mr.jsx)("path",{d:ee(t,yr(t,gr-1)),transform:`translate(${gr},${gr})`,fill:e.color??n})}})}if(e.sizeStops&&e.sizeStops.length>0&&e.sizeRadius){const n=e.sizeRadius,o=e.sizeFormat??(e=>e+""),r=e.sizeColor??pr,i=e.sizeStops.map(e=>({label:o(e),r:Math.max(.5,n(e)),color:r}));t.push({label:e.sizeLabel??"",items:i,styleFn:()=>({}),type:e=>(0,mr.jsx)("circle",{cx:gr,cy:gr,r:e.r,fill:e.color??r})})}return t}function br(e){const t=e.orientation??"vertical",n=e.swatchSize??14,o=e.gap??8,r=e.labelGap??6,i=e.fontSize??12,a=e.color??"var(--semiotic-text-secondary, #888)",s=n+o;let c=0;const l=[];return e.entries.forEach((e,u)=>{l.push((0,mr.jsxs)("g",{transform:`translate(${"vertical"===t?0:c},${"vertical"===t?c:0})`,children:[wr(e,n,e.color??e.line??a,a),(0,mr.jsx)("text",{x:n+r,y:n/2,dominantBaseline:"middle",fontSize:i,fill:a,children:e.label})]},"legend-"+u)),c+="vertical"===t?s:n+r+e.label.length*i*.58+o+8}),(0,mr.jsx)("g",{className:e.className,transform:`translate(${e.x},${e.y})`,style:{pointerEvents:"none"},children:l},e.keyId)}function wr(e,t,n,o){if(e.shape){const o=yr(e.shape,t/2-1);return(0,mr.jsx)("path",{d:ee(e.shape,o),transform:`translate(${t/2},${t/2})`,fill:n})}if(e.hatch){const n=e.color??o;return(0,mr.jsxs)("g",{children:[(0,mr.jsx)("svg",{width:t,height:t,style:{overflow:"hidden"},children:[-t,-t/2,0,t/2].map((e,o)=>(0,mr.jsx)("line",{x1:e,y1:t,x2:e+t,y2:0,stroke:n,strokeWidth:1,opacity:.7},o))}),(0,mr.jsx)("rect",{width:t,height:t,fill:"none",stroke:n,strokeWidth:1,opacity:.5,rx:2})]})}return(0,mr.jsx)("rect",e.line?{y:t/2-1.5,width:t,height:3,rx:1.5,fill:e.line}:{width:t,height:t,rx:2,fill:n})}var Mr=new Set(["rows"]);function vr(e){const t=e,n=[Sr(t,["datum","data"]),Sr(t,["datum"]),Sr(t,["data","data"]),Sr(t,["data"]),Sr(t,["node","datum","data"]),Sr(t,["node","datum"]),e];for(const e of n){if(!Ir(e))continue;const t={};for(const[n,o]of Object.entries(e))n.startsWith("_")||"function"==typeof o||(t[n]=o);if(Object.keys(t).length>0)return t}return null}function kr(e,t={}){const n=vr(e);if(!n)return[];const o=new Set(Mr);if(t.excludeKeys)for(const e of t.excludeKeys)o.add(e);const r=[];for(const[e,i]of Object.entries(n))if((t.includeInternal||!e.startsWith("_"))&&!o.has(e)&&(t.includeEmpty||null!=i&&""!==i)&&"function"!=typeof i&&(r.push({key:e,label:Ar(e,t.labels),value:i,formatted:t.valueFormat?t.valueFormat(i,e,n):$r(i)}),r.length>=(t.maxEntries??8)))break;return r}function $r(e){if(null==e)return"";if(e instanceof Date)return e.toISOString();if("number"==typeof e)return Number.isInteger(e)?e+"":e.toLocaleString(void 0,{maximumFractionDigits:2});if("boolean"==typeof e)return e?"true":"false";if(Array.isArray(e))return e.length+" items";if("object"==typeof e)try{return JSON.stringify(e)}catch{return e+""}return e+""}function Ar(e,t){return"function"==typeof t?t(e):t&&t[e]?t[e]:e}function Sr(e,t){let n=e;for(const e of t){if(!Ir(n))return;n=n[e]}return n}function Ir(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function jr(e,t){const n=new Map;for(const t of e)n.set(t.id,new Set);for(const e of t)n.has(e.source)||n.set(e.source,new Set),n.has(e.target)||n.set(e.target,new Set),n.get(e.source).add(e.target),n.get(e.target).add(e.source);return n}function Cr(e,t){const n={};for(const t of e)n[t.id]=0;for(const e of t)n[e.source]=(n[e.source]||0)+1,n[e.target]=(n[e.target]||0)+1;return n}function Nr(e,t){const n={[t]:0},o=[t];let r=0;for(;o.length>r;){const t=o[r];r+=1;for(const r of e.get(t)||[])void 0===n[r]&&(n[r]=n[t]+1,o.push(r))}return n}function Lr(e,t,n,o){if(n===o)return n?[n]:[];const r=jr(e,t),i={[n]:null},a=[n];let s=0;for(;a.length>s;){const e=a[s];if(s+=1,e===o)break;for(const t of r.get(e)||[])void 0===i[t]&&(i[t]=e,a.push(t))}if(void 0===i[o])return[];const c=[];let l=o;for(;null!=l;)c.unshift(l),l=i[l];return c}function zr(e,t,n,o=1){const r=jr(e,t);if(!r.has(n))return new Set;const i=Nr(r,n),a=new Set;for(const e in i)i[e]>o||a.add(e);return a}function Tr(e,t){const n=jr(e,t),o={};for(const t of e)o[t.id]=0;for(const t of e.map(e=>e.id)){const r=[],i={},a={},s={};for(const t of e)i[t.id]=[],a[t.id]=0,s[t.id]=-1;a[t]=1,s[t]=0;const c=[t];let l=0;for(;c.length>l;){const e=c[l];l+=1,r.push(e);for(const t of n.get(e)||[])0>s[t]&&(s[t]=s[e]+1,c.push(t)),s[t]===s[e]+1&&(a[t]+=a[e],i[t].push(e))}const u={};for(const t of e)u[t.id]=0;for(;r.length;){const e=r.pop();for(const t of i[e])u[t]+=a[t]/a[e]*(1+u[e]);e!==t&&(o[e]+=u[e])}}for(const e in o)o[e]/=2;return o}function Er(e,t){const n=jr(e,t),o={};for(const t of e){const e=Nr(n,t.id);let r=0,i=0;for(const t in e)r+=e[t],i+=1;o[t.id]=r>0?(i-1)/r:0}return o}function Fr(e,t){const n=jr(e,t),o={};for(const t of e){const e=[...n.get(t.id)||[]],r=e.length;if(2>r){o[t.id]=0;continue}let i=0;for(let t=0;e.length>t;t+=1)for(let o=t+1;e.length>o;o+=1)n.get(e[t])?.has(e[o])&&(i+=1);o[t.id]=2*i/(r*(r-1))}return o}function Rr(e){let t=0;for(const n in e)e[n]>t&&(t=e[n]);const n={};for(const o in e)n[o]=t>0?e[o]/t:0;return n}function Wr(e,t,n,o={}){const r=jr(e,t),i={};for(const t of e)i[t.id]=Nr(r,t.id);let a=o.minHops??4,s=o.startThreshold??.08;const c=o.maxThreshold??.2,l=new Set;let u=0;for(;0===l.size&&40>u;){for(let t=0;e.length>t;t+=1)for(let o=t+1;e.length>o;o+=1){const r=e[t].id,c=e[o].id,u=n[r],d=n[c];if(!u||!d)continue;const h=u.x-d.x,f=u.y-d.y;(void 0===i[r][c]?1/0:i[r][c])>=a&&s>Math.sqrt(h*h+f*f)&&(l.add(r),l.add(c))}0===l.size&&(s+=.02,s>c&&(s=o.startThreshold??.08,a=Math.max(2,a-1))),u+=1}return{problemIds:l,threshold:s,minHops:a}}var Pr={},Or=4e4;function qr(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function Dr(){if("undefined"!=typeof DOMException)return new DOMException("Force layout aborted","AbortError");const e=Error("Force layout aborted");return e.name="AbortError",e}var Br=class{constructor(e=function(){const e="string"==typeof Pr.url&&Pr.url?new URL("./forceLayoutWorker.js",Pr.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,o=null!=n?this.pending.get(n):this.pending.values().next().value;if(o){if(null!=n?this.pending.delete(n):this.pending.clear(),o.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 o.reject(e)}o.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(Dr());const n=this.nextRequestId;this.nextRequestId+=1;const o={requestId:n,request:e};return new Promise((e,r)=>{const i=()=>{this.pending.delete(n),t?.removeEventListener("abort",i),r(Dr())},a=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:a,reject:r,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(o)}catch(e){this.pending.delete(n),a(),r(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()}},Yr=null;async function Gr(e,t,n={}){const{execution:o="auto",signal:r,workerThreshold:i,nodeRadius:a,...s}=n,c=s.iterations??260,l=qr()&&function(e,t,n,o,r=Or){return"sync"!==e&&("worker"===e||o*(t+n)>=r)}(o,e.length,t.length,c,i);if(!l)return W(e,t,{...s,nodeRadius:a});const u={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 function(e,t){return qr()?t?.aborted?Promise.reject(Dr()):(Yr&&!Yr.isDead||(Yr=new Br),Yr).request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(u,r)).positions}catch(n){if("AbortError"===n?.name)throw n;return W(e,t,{...s,nodeRadius:a})}}function Hr(e,t){if("region-enter"!==t.type)return e;const n=t.region.id,o=e[n]??{id:n,label:t.region.label??n,count:0,bodyIds:[]};if(o.bodyIds.includes(t.bodyId))return e;const r=[...o.bodyIds,t.bodyId];return{...e,[n]:{...o,count:r.length,bodyIds:r}}}function _r(e,t){return(t??Object.keys(e)).map(t=>e[t]).filter(e=>null!=e).map(e=>({label:e.label??e.id,value:e.count}))}function Vr(e,t){const n=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],o=t.filter(e=>!n.has(e)),r=t.length-o.length,i=e.completion?.mode??"allMembersAbsorbed",a=e.completion?.valueByBodyId,s=e=>{const t=a?.[e];return Number.isFinite(t)&&Number(t)>=0?Number(t):1},c=t.reduce((e,t)=>e+s(t),0),l=t.reduce((e,t)=>e+(n.has(t)?s(t):0),0),u=e.completion?.threshold,d="threshold"===i?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:e.id,label:e.label??e.id,mode:i,complete:t.length>0&&("anyAbsorbed"===i?r>0:"threshold"===i?l>=(d??c):0===o.length),absorbed:r,total:t.length,absorbedValue:l,totalValue:c,threshold:d,missing:o}})}function Xr(e,t,n){return Math.max(t,Math.min(n,e))}function Ur(e,t,n={}){const o=n.random??Math.random,r=e.stages.find(e=>e.id===t)??e.stages[e.stages.length-1],i=Xr(n.along??.5,.05,.95),a=n.jitterX??0,s=n.padY??20,c=r.x0+(r.x1-r.x0)*i+(2*o()-1)*a,l=Math.min(1,r.width/2),u=Xr(c,r.x0+l,r.x1-l),d=e.boundaryY(u,"top")+s,h=e.boundaryY(u,"bottom")-s;return{x:u,y:h>d?d+o()*Math.max(1,h-d):e.midY}}function Kr(e){return"bowtie"===e.shape?[{id:"incoming",role:"incoming",points:[[e.left,e.topY],[e.centerLeft,e.pinchTop],[e.centerLeft,e.pinchBottom],[e.left,e.bottomY]]},{id:"center",role:"center",points:[[e.centerLeft,e.pinchTop],[e.centerRight,e.pinchTop],[e.centerRight,e.pinchBottom],[e.centerLeft,e.pinchBottom]]},{id:"outgoing",role:"outgoing",points:[[e.centerRight,e.pinchTop],[e.right,e.topY],[e.right,e.bottomY],[e.centerRight,e.pinchBottom]]}]:[{id:"volume",role:"volume",points:[[e.left,e.topY],[e.right,"funnel"===e.shape?e.pinchTop:e.topY],[e.right,"funnel"===e.shape?e.pinchBottom:e.bottomY],[e.left,e.bottomY]]}]}function Qr(e,t,n){return Math.max(t,Math.min(n,e))}function Zr(e,t,n,o,r,i={}){return{id:e,friction:i.friction,restitution:i.restitution,bodyFilter:i.bodyFilter,shape:{type:"segment",x1:t,y1:n,x2:o,y2:r,thickness:i.thickness??8}}}function Jr(e){const t=e.shape??"lane",n=Math.max(1,Math.round(e.width)),o=Math.max(1,Math.round(e.height)),r=e.padX??46,i=e.padY??72,a=r,s=n-r,c=i,l=o-Math.max(24,Math.round(.45*i)),u=(c+l)/2,d=Math.max(1,l-c),h=Qr(e.pinchRatio??.18,.06,.5),f=Number(e.pinchHeightOffset??0),m=Number.isFinite(f)?f:0,p=Qr(d*h+m,.06*d,.5*d),g=p/2,y=u-g,x=u+g,b=e.idPrefix??"process",w=e.friction??.58,M=e.restitution??.18,v=e.wallThickness??8,k=e.stages;if(!k.length)throw Error("processStageLayout requires at least one stage");const $=Qr(e.centerStageIndex??Math.floor(k.length/2),0,k.length-1),A=function(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}(k),S=s-a;let I=a;const j=k.map((e,t)=>{const n=I,o=t===k.length-1?s:I+(e.share??1)/A*S;return I=o,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:n,x1:o,x:(n+o)/2,width:o-n,y:u,height:d}}),C=j[$],N=C.x0,L=C.x1,z=(e,n)=>{if("lane"===t)return"top"===n?c:l;if("funnel"===t){const t=Qr((e-a)/Math.max(1,s-a),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(N>=e){const t=Qr((e-a)/Math.max(1,N-a),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(L>=e)return"top"===n?y:x;const o=Qr((e-L)/Math.max(1,s-L),0,1);return"top"===n?y+(c-y)*o:x+(l-x)*o},T=j.map(e=>{const t=Math.min(z(e.x0,"top"),z(e.x1,"top")),n=Math.max(z(e.x0,"bottom"),z(e.x1,"bottom"));return{...e,y:(t+n)/2,height:Math.max(1,n-t)}}),E={thickness:v,friction:w,restitution:M},F=[];"lane"===t?F.push(Zr(b+"-top",a,c,s,c,E),Zr(b+"-bottom",a,l,s,l,E),Zr(b+"-left",a,c,a,l,{...E,thickness:Math.max(6,v-2)}),Zr(b+"-right",s,c,s,l,{...E,thickness:Math.max(6,v)})):"funnel"===t?F.push(Zr(b+"-top",a,c,s,y,E),Zr(b+"-bottom",a,l,s,x,E),Zr(b+"-left",a,c,a,l,{...E,thickness:Math.max(6,v-2)}),Zr(b+"-right",s,y,s,x,{...E,thickness:Math.max(6,v)})):F.push(Zr(b+"-left-top",a,c,N,y,E),Zr(b+"-left-bottom",a,l,N,x,E),Zr(b+"-center-top",N,y,L,y,E),Zr(b+"-center-bottom",N,x,L,x,E),Zr(b+"-right-top",L,y,s,c,E),Zr(b+"-right-bottom",L,x,s,l,E),Zr(b+"-left",a,c,a,l,{...E,thickness:Math.max(6,v-2)}),Zr(b+"-right",s,c,s,l,{...E,thickness:Math.max(6,v)}));const R=e.membraneDampingScale??.5,W=a,P=Math.max(1,("bowtie"===t?N:s)-W),O=(e.membranes??[]).map(e=>{const t=W+Qr(e.offset,0,1)*P,n=e.width??18+18*e.cost,o=d-16,r=u+.25*(e.wobble??0);return{...e,x:t,y:r,width:n,height:o}}),q=!1===e.includeMembraneRegions?[]:O.map(e=>ni({id:e.id,label:e.label??e.id,description:e.description??(e.label??e.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??R,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:n,height:o,padX:r,padY:i,left:a,right:s,topY:c,bottomY:l,midY:u,centerLeft:N,centerRight:L,pinchHeight:p,pinchTop:y,pinchBottom:x,stages:T,membranes:O,colliders:F,regionEffects:q,boundaryY:z}}function ei(e){return{id:e.id,label:e.label,description:e.description,kind:e.kind,shape:(t=e.x,n=e.y,o=e.width,r=e.height,{type:"aabb",x:t,y:n,width:o,height:r}),bodyFilter:e.bodyFilter,collider:e.collider,colliderThickness:e.colliderThickness,friction:e.friction,restitution:e.restitution,semanticItem:e.semanticItem,metadata:e.metadata,bodyStyle:e.bodyStyle,attributes:e.attributes,onEnter:e.onEnter,onExit:e.onExit};var t,n,o,r}function ti(e,t={}){const n=t.idPrefix??"stage",o=Math.max(0,t.insetX??0),r=Math.max(0,t.insetY??1);return e.stages.map(e=>{const i="function"==typeof t.metadata?t.metadata(e):t.metadata??{};return{...ei({id:n?`${n}:${e.id}`:e.id,label:e.label??e.id,description:e.description,kind:"region",x:e.x,y:e.y,width:Math.max(1,e.width-2*o),height:Math.max(1,e.height-2*r),bodyFilter:t.bodyFilter,semanticItem:t.semanticItem,attributes:{primitive:"processStage",stageId:e.id,stageIndex:e.index},metadata:{...i,primitive:"processStage",stageId:e.id,stageIndex:e.index}})}})}function ni(e){const t=e.dampingScale??.5,n=e.energyScale??1,o=Qr(e.cost,0,2);return{...ei({...e,kind:e.kind??"membrane",attributes:{primitive:"membrane",membraneCost:o,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:o*t,energyDelta:-o*n}}function oi(e){return{...ei({...e,kind:e.kind??"charge-gate",attributes:{primitive:"chargeGate",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),charge:e.charge??!0,energyDelta:e.energyDelta,impulseOnEnter:e.impulseOnEnter}}function ri(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...ei({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function ii(e){const t=e.pressure??e.occupancy??0,n=e.baseDamping??.08,o=e.dampingPerUnit??.12,r=e.energyPerUnit??0;return{...ei({...e,kind:e.kind??"membrane",attributes:{primitive:"pressureField",pressure:t,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:n+t*o,energyDelta:r?-t*r:void 0,force:e.force}}function ai(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...ei({...e,kind:e.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:e.capacity,unitsPerSecond:e.unitsPerSecond??e.capacity,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping,charge:e.charge??e.capacity}}function si(e){return{...ei({...e,kind:e.kind??"force-field",attributes:{primitive:"portal",targetStage:e.targetStage,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:e.force,impulseOnEnter:e.impulseOnEnter,damping:e.damping??.08}}function ci(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...ei({...e,kind:e.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.02,charge:e.charge??"absorbed"}}function li(e){return{...ei({...e,kind:e.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:e.force,damping:e.damping,energyDelta:e.energyDelta}}function ui(e){const t=e.x??e.anchor?.x??0,n=e.y??e.anchor?.y??0;return{id:e.id,label:e.label,description:e.description,group:e.group,bodyIds:e.bodyIds,datum:e.datum,state:e.state,x:t,y:n,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:n},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}function di(e){const t=e.idPrefix??"lane",n={thickness:e.thickness??8,friction:e.friction??.5,restitution:e.restitution??.16},o=[Zr(t+"-top",e.left,e.top,e.right,e.top,n),Zr(t+"-bottom",e.left,e.bottom,e.right,e.bottom,n)];return e.openEnds||o.push(Zr(t+"-left",e.left,e.top,e.left,e.bottom,n),Zr(t+"-right",e.right,e.top,e.right,e.bottom,n)),o}var hi=[.1,.5,.9],fi=1e6,mi=12;function pi(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function gi(e,t,n,o,r){return"function"==typeof o?o(e,t,n):function(e,t){let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;n=n[e]}return n}(e,o??r)}function yi(e){const t=Number(e.toFixed(mi));return Object.is(t,-0)?0:t}function xi(e,t,n,o){const r=e.flatMap((e,r)=>{const i=pi(gi(e,r,t,n,"time")),a=pi(gi(e,r,t,o,"value"));return null==i||null==a?[]:[{time:yi(i),value:a,index:r}]});r.sort((e,t)=>e.time-t.time||e.index-t.index);const i=[];for(const e of r){const t=i[i.length-1];t?.time===e.time?t.value=e.value:i.push({time:e.time,value:e.value})}return i}function bi(e,t,n,o){if(!e.length)return null;const r=e[0],i=e[e.length-1];if(r.time>t)return"clamp"===o?r.value:null;if(t>i.time)return"clamp"===o?i.value:null;const a=function(e,t){let n=0,o=e.length;for(;o>n;){const r=n+o>>>1;t>e[r].time?n=r+1:o=r}return n}(e,t),s=e[a];if(s?.time===t)return s.value;const c=e[Math.max(0,a-1)];return"step"!==n&&s&&s.time!==c.time?c.value+(t-c.time)/(s.time-c.time)*(s.value-c.value):c.value}function wi(e,t){if(1===e.length)return e[0];const n=(e.length-1)*t,o=Math.floor(n),r=Math.ceil(n);return o===r?e[o]:e[o]+(e[r]-e[o])*(n-o)}function Mi(e){const t=e.interpolation??"step",n=e.outsideDomain??"omit",o=function(e){const t=(e??hi).map(e=>{const t=pi(e);if(null==t||0>t||t>1)throw new RangeError("physicsReferenceEnvelope quantiles must be finite values from 0 to 1; received "+e);return yi(t)});return Array.from(new Set(t)).sort((e,t)=>e-t)}(e.quantiles),r=function(e){if(Array.isArray(e)){if(e.length>fi)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${fi} points`);return Array.from(new Set(e.map(pi).filter(e=>null!=e).map(yi))).sort((e,t)=>e-t)}const t=e,n=pi(t.start),o=pi(t.end),r=pi(t.step);if(null==n||null==o||null==r||0>=r||n>o)throw new RangeError("physicsReferenceEnvelope sampleAt requires finite start/end values with end >= start and step > 0");const i=Math.floor((o-n)/r)+1;if(i>fi)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${fi} points`);const a=[],s=1e-10*Math.max(1,Math.abs(o),Math.abs(n));for(let e=0;i>e;e+=1){const t=n+e*r;if(t>o+s)break;a.push(yi(Math.min(t,o)))}if(a.length&&s>=Math.abs(a[a.length-1]-o)||a.push(yi(o)),a.length>fi)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${fi} points`);return Array.from(new Set(a)).sort((e,t)=>e-t)}(e.sampleAt),i=e.runs.map(t=>xi(t.samples,t.id,e.timeAccessor,e.valueAccessor));return{points:r.map(e=>{const r=i.map(o=>bi(o,e,t,n)).filter(e=>null!=e).sort((e,t)=>e-t),a={};for(const e of o)a[e]=r.length?wi(r,e):null;return{time:e,count:r.length,min:r.length?r[0]:null,max:r.length?r[r.length-1]:null,median:r.length?wi(r,.5):null,quantiles:a}}),quantiles:o,interpolation:t,outsideDomain:n,runCount:e.runs.length}}function vi(e,t){return e.quantiles.length?"lower"===t?e.quantiles[0]:e.quantiles[e.quantiles.length-1]:"lower"===t?"min":"max"}function ki(e,t){if("min"===t||"median"===t||"max"===t)return e[t];const n=pi(t);if(null==n||0>n||n>1)throw new RangeError("comparePhysicsTrace quantile selectors must be from 0 to 1; received "+t);const o=yi(n);if(!Object.prototype.hasOwnProperty.call(e.quantiles,o))throw Error(`comparePhysicsTrace could not find quantile ${o} in the reference envelope`);return e.quantiles[o]??null}function $i(e,t,n){return t>e?"below":e>n?"above":"inside"}function Ai(e,t){const n=Math.max(0,t.time-e.time);if(0>=n||null==e.value||null==e.lower||null==e.upper||null==t.value||null==t.lower||null==t.upper)return{below:0,inside:0,above:0,observed:0};const o=e.value-e.lower,r=t.value-t.lower,i=e.value-e.upper,a=t.value-t.upper,s=[0,1];for(const[e,t]of[[o,r],[i,a]])(0>e&&t>0||e>0&&0>t)&&s.push(-e/(t-e));s.sort((e,t)=>e-t);let c=0,l=0,u=0;for(let o=0;s.length-1>o;o+=1){const r=s[o],i=s[o+1];if(r>=i)continue;const a=(r+i)/2,d=(i-r)*n,h=$i(e.value+(t.value-e.value)*a,e.lower+(t.lower-e.lower)*a,e.upper+(t.upper-e.upper)*a);"below"===h?c+=d:"above"===h?u+=d:l+=d}return{below:c,inside:l,above:u,observed:n}}function Si(e,t,n={}){const o=n.interpolation??t.interpolation,r=n.outsideDomain??t.outsideDomain,i=xi(e,n.traceId??"trace",n.timeAccessor,n.valueAccessor),a=n.lower??vi(t,"lower"),s=n.upper??vi(t,"upper"),c=t.points.map(e=>{const t=bi(i,e.time,o,r),n=ki(e,a),c=ki(e,s);if(null!=n&&null!=c&&n>c)throw new RangeError("comparePhysicsTrace lower band exceeds upper band at time "+e.time);return{time:e.time,value:t,lower:n,upper:c,status:null==t||null==n||null==c?"unobserved":$i(t,n,c)}});let l=0,u=0,d=0,h=0,f=null,m=0,p=null;for(const e of c){if("below"===e.status?l+=1:"inside"===e.status?u+=1:"above"===e.status&&(d+=1),null==e.value||null==e.lower||null==e.upper)continue;const t=Math.max(0,e.value-e.upper),n=Math.max(0,e.lower-e.value);t>h&&(h=t,f=e.time),n>m&&(m=n,p=e.time)}let g=0,y=0,x=0,b=0;for(let e=0;c.length-1>e;e+=1){const t=c[e],n=c[e+1],r=Math.max(0,n.time-t.time);if(r>0){if("linear"===o){const e=Ai(t,n);g+=e.below,y+=e.inside,x+=e.above,b+=e.observed;continue}"unobserved"!==t.status&&(b+=r,"below"===t.status?g+=r:"above"===t.status?x+=r:y+=r)}}const w=c[0]?.time,M=c[c.length-1]?.time,v=null==w||null==M?0:Math.max(0,M-w);return{points:c,sampleCount:c.length,observedSamples:l+u+d,belowSamples:l,insideSamples:u,aboveSamples:d,totalDuration:v,observedDuration:b,unobservedDuration:Math.max(0,v-b),belowDuration:g,insideDuration:y,aboveDuration:x,peakExcess:h,peakExcessAt:f,peakDeficit:m,peakDeficitAt:p}}function Ii(e){return{id:e,furthestStageIndex:-1,visitedStageIds:[],visitsByStage:{},firstEnteredAt:{},lastEnteredAt:{},regressionCount:0}}function ji(e){const t=Array.from(new Set(e.bodyIds??[]));return{stages:e.stages.map(e=>({...e})),bodyIds:t,entities:Object.fromEntries(t.map(e=>[e,Ii(e)]))}}function Ci(e,t,n={}){if("region-enter"!==t.type)return e;const o=function(e,t){const n=t.stageId?.(e);if(n)return n;const o=e.region.metadata;if(o&&"object"==typeof o){const e=o.stageId;if("string"==typeof e)return e}return e.region.id}(t,n),r=e.stages.findIndex(e=>e.id===o);if(0>r)return e;const i=n.entityId?.(t)??t.bodyId;if(!i)return e;const a=e.entities[i]??Ii(i),s=a.currentStageId?e.stages.findIndex(e=>e.id===a.currentStageId):-1,c=!a.visitedStageIds.includes(o),l=Number(t.observation.timestamp),u=Number.isFinite(l)?l:0,d={...a,currentStageId:o,furthestStageId:r>a.furthestStageIndex?o:a.furthestStageId,furthestStageIndex:Math.max(a.furthestStageIndex,r),visitedStageIds:c?[...a.visitedStageIds,o]:a.visitedStageIds,visitsByStage:{...a.visitsByStage,[o]:(a.visitsByStage[o]??0)+1},firstEnteredAt:c?{...a.firstEnteredAt,[o]:u}:a.firstEnteredAt,lastEnteredAt:{...a.lastEnteredAt,[o]:u},regressionCount:s>=0&&s>r?a.regressionCount+1:a.regressionCount};return{...e,bodyIds:e.bodyIds.includes(i)?e.bodyIds:[...e.bodyIds,i],entities:{...e.entities,[i]:d}}}function Ni(e){const t=e.bodyIds.map(t=>e.entities[t]??Ii(t)),n=t.length;let o=n;return e.stages.map((e,r)=>{const i=t.filter(e=>e.furthestStageIndex>=r).length,a=t.filter(t=>t.visitedStageIds.includes(e.id)).length,s=t.reduce((t,n)=>t+(n.visitsByStage[e.id]??0),0),c={id:e.id,label:e.label??e.id,reached:i,entered:a,total:n,conversion:n>0?i/n:0,fromPrevious:o>0?i/o:0,dropoff:Math.max(0,o-i),visits:s,repeatVisits:Math.max(0,s-a)};return o=i,c})}function Li(e,t){if("function"==typeof t){const n=t(e);return Number.isFinite(n)&&n>0?Number(n):1}const n=e.datum;if(t&&n&&"object"==typeof n){const e=Number(n[t]);if(Number.isFinite(e)&&e>0)return e}const o=Number(n?.work??n?.reviewWork??n?.value);return Number.isFinite(o)&&o>0?o:1}function zi(e,t){if("function"==typeof t){const n=t(e);if(null!=n&&(n+"").length>0)return n+""}else if(t){const n=Ei(e.datum,t),o=Ei(e,t),r=n??o;if(null!=r&&(r+"").length>0)return r+""}return e.id}function Ti(e,t){if(0===e.length)return 0;if(1===e.length)return e[0];const n=Math.max(0,Math.min(1,t))*(e.length-1),o=Math.floor(n);return e[o]+(e[Math.ceil(n)]-e[o])*(n-o)}function Ei(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;n=n[e]}return n}function Fi(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const n=Ei(e,t.property);return!("equals"in t&&!Object.is(n,t.equals)||"notEquals"in t&&Object.is(n,t.notEquals)||t.oneOf&&!t.oneOf.some(e=>Object.is(n,e))||t.notOneOf&&t.notOneOf.some(e=>Object.is(n,e)))}function Ri(e){const t=e.regionId,n=Math.max(0,e.unitsPerSecond),o=e.queueLayout??"lane",r=e.queueSlotSpacing??14,i=e.queueStiffness??.35,a=Number.isFinite(e.maxQueue)?Math.max(0,Math.floor(Number(e.maxQueue))):1/0,s=Math.max(.25,e.metricWindowSeconds??30),c=Math.max(1/60,e.snapshotIntervalSeconds??.25),l=e.releaseImpulse??{x:90,y:0},u=new Map,d=new Map,h=new Map,f=new Map,m=new Map,p=new Map,g=new Map,y=[];let x=0,b=new Map,w=new Map,M=0,v=0,k=0,$=null,A=0,S=0,I=0,j=0,C=0,N=0,L=0,z=0,T=0,E=0,F=0,R=0,W=-1,P=!1;function O(e,n){const o=n(e);return!!o&&o.activeRegionIds.includes(t)}function q(){R+=1}function D(e){return{bodyId:e.bodyId,jobId:e.jobId,visitId:e.visitId,visit:e.visit,regionId:t,work:e.total,queuedAt:e.queuedAt}}function B(n,o,r,i){const a={bodyId:n.id,jobId:o.jobId,visitId:o.visitId,visit:o.visit,remaining:o.work,total:o.work,queuedAt:o.queuedAt,sequence:i};return u.set(o.jobId,a),g.delete(n.id),p.set(n.id,o.jobId),S+=1,I+=o.work,q(),function(n,o,r){const i=D(o);e.onQueued?.(n,i),r.controls.recordObservation({type:"physics-capacity-queued",bodyId:n.id,datum:n.datum,x:n.x,y:n.y,regionId:t,work:o.total,jobId:o.jobId,visitId:o.visitId,visit:o.visit,queuedAt:o.queuedAt,queueDepth:u.size})}(n,a,r),a}function Y(e){if(u.size>=a||0===d.size)return;const t=Array.from(d.values()).sort((e,t)=>e.sequence-t.sequence);for(const n of t){if(u.size>=a)break;const t=m.get(n.jobId);t&&h.has(n.jobId)?(d.delete(n.jobId),g.delete(n.bodyId),B(t,n,e,n.sequence)):d.delete(n.jobId)}}function G(){let e=0;for(const t of u.values())e+=t.remaining;return e}function H(){T=Math.max(T,u.size),E=Math.max(E,G())}function _(){const e=k-s,t=Math.max(0,Math.min(s,k-($??k)));let o=0,r=0,i=0,a=0,c=0;for(const t of y){if(e>t.end)continue;o+=t.arrivals,r+=t.arrivalWork,i+=t.completions,a+=t.completedWork;const n=t.end-t.start;c+=n>0&&e>t.start?t.processedWork*Math.min(1,Math.max(0,t.end-e)/n):t.processedWork}const l=t>0?r/t:0;return{seconds:t,arrivals:o,arrivalWork:r,completions:i,completedWork:a,processedWork:c,arrivalsPerSecond:t>0?o/t:0,throughputPerSecond:t>0?i/t:0,utilization:t>0&&n>0?Math.max(0,Math.min(1,c/(n*t))):0,pressure:n>0?l/n:0}}return{id:e.id??"capacity-queue:"+t,continuous:!1!==e.continuous,tick:o=>{const r=o.controls.readBodies(),i=new Map,S=new Map;for(const t of r){if(i.set(t.id,t),!O(t.id,o.getRegionState))continue;if(!Fi(t,e.bodyFilter))continue;const n=zi(t,e.jobKey),r=S.get(n)??[];r.push(t),S.set(n,r)}const I=Number.isFinite(o.dt)?Math.max(0,o.dt):0;if(!P){const e=Number.isFinite(o.elapsed)?Math.max(0,o.elapsed):I;k=Math.max(0,e-I),P=!0}const T=k,E=T+I;k=E,$=null==$?T:Math.min($,T);const R={start:T,end:E,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},G=new Map;for(const[e,t]of S){const n=h.get(e)?.bodyId,o=t.find(e=>e.id===n)??t[0];G.set(e,o),m.set(e,o)}for(const[n,r]of h){if(G.has(n))continue;const a=u.get(n),s=i.get(r.bodyId)??m.get(n);if(a){u.delete(n),p.delete(a.bodyId),L+=1,z+=a.remaining,q();const i={...D(a),abandonedAt:k,remainingWork:a.remaining,queueSeconds:Math.max(0,k-a.queuedAt)};s&&e.onAbandoned?.(s,i),o.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:r.bodyId,datum:s?.datum,x:s?.x,y:s?.y,regionId:t,work:a.total,remainingWork:a.remaining,jobId:n,visitId:a.visitId,visit:a.visit,queuedAt:a.queuedAt,abandonedAt:k,queueSeconds:i.queueSeconds,queueDepth:u.size})}d.delete(n),g.delete(r.bodyId),h.delete(n),m.delete(n)}for(const[n,r]of G){if(h.has(n))continue;const i=(f.get(n)??0)+1;f.set(n,i);const s=Li(r,e.unitAccessor),c={bodyId:r.id,jobId:n,visitId:`${t}:${n}:${i}`,visit:i,regionId:t,work:s,queuedAt:k};h.set(n,c),A+=1,R.arrivals+=1,R.arrivalWork+=s;const l=x++;if(a>u.size)B(r,c,o,l);else{const a={...c,blockedAt:k,sequence:l};d.set(n,a),g.set(r.id,n),N+=1,q(),e.onBlocked?.(r,a),o.controls.recordObservation({type:"physics-capacity-blocked",bodyId:r.id,datum:r.datum,x:r.x,y:r.y,regionId:t,work:s,jobId:n,visitId:c.visitId,visit:i,queuedAt:k,blockedAt:k,queueDepth:u.size,blockedDepth:d.size})}}Y(o),H();const _=Array.from(u.values()).sort((e,t)=>e.sequence-t.sequence);let V=n*I;for(const n of _){if(0>=V)break;const r=Math.min(n.remaining,V);if(n.remaining-=r,V-=r,j+=r,R.processedWork+=r,n.remaining>1e-6)continue;u.delete(n.jobId),p.delete(n.bodyId),v+=1,C+=n.total,R.completions+=1,R.completedWork+=n.total;const a=Math.max(0,k-n.queuedAt);F+=a,q();const s=i.get(n.bodyId);if(!s)continue;o.controls.applyImpulse(n.bodyId,l.x??0,l.y??0);const c={...D(n),completedAt:k,queueSeconds:a};e.onProcessed?.(s,c),o.controls.recordObservation({type:"physics-capacity-processed",bodyId:n.bodyId,datum:s.datum,x:s.x,y:s.y,regionId:t,work:n.total,jobId:n.jobId,visitId:n.visitId,visit:n.visit,queuedAt:n.queuedAt,completedAt:k,queueSeconds:a,queueDepth:u.size})}Y(o),H(),function(){const e=Array.from(u.values()).sort((e,t)=>e.sequence-t.sequence);b=new Map(e.map((e,t)=>[e.bodyId,t]));const t=Array.from(d.values()).sort((e,t)=>e.sequence-t.sequence);w=new Map(t.map((e,t)=>[e.bodyId,t])),M=e.length}(),function(e){(e.end>e.start||e.arrivals>0||e.completions>0||e.processedWork>0)&&y.push(e);const t=k-s;for(;y.length>0&&t>y[0].end;)y.shift()}(R);const X=Math.floor(k/c);X!==W&&(W=X,q())},getSnapshot:()=>{const e=G(),o=function(){let e=0;for(const t of d.values())e+=t.work;return e}(),r=u.size,i=Array.from(u.values()).map(e=>Math.max(0,k-e.queuedAt)).sort((e,t)=>e-t),a=i.reduce((e,t)=>e+t,0);return{regionId:t,queueDepth:r,processedCount:v,unitsPerSecond:n,remainingWork:e,meanRemainingWork:r>0?e/r:0,waitingWork:e+o,blockedDepth:d.size,blockedWork:o,arrivalCount:A,admittedCount:S,admittedWork:I,processedWork:j,completedWork:C,blockedCount:N,abandonedCount:L,abandonedWork:z,peakQueueDepth:T,peakRemainingWork:E,queueAge:{count:i.length,meanSeconds:i.length>0?a/i.length:0,p50Seconds:Ti(i,.5),p95Seconds:Ti(i,.95),oldestSeconds:i.at(-1)??0},meanCompletedQueueSeconds:v>0?F/v:0,window:_(),simulatedAt:k,metricRevision:R}},bodyForce:e=>{if("none"===o)return null;const n=p.get(e.body.id),a=g.get(e.body.id),s=n?u.get(n):void 0,c=a?d.get(a):void 0;if(!s&&!c)return null;const l=s?b.get(e.body.id):w.get(e.body.id);if(null==l)return null;let h;const f=e.regions;if(f)for(let e=0;f.length>e;e+=1)if(f[e].id===t){const t=f[e].shape;t&&"aabb"===t.type&&(h=t);break}return h?{x:((c?h.x-.44*h.width:h.x-.22*h.width-l*(.15*r))-e.body.x)*i,y:(h.y-(l-((c?d.size:M)-1)/2)*r/Math.max(1,Math.sqrt(c?d.size:M))-e.body.y)*i*.85}:{x:8*-Math.sign(e.body.vx||1),y:0}}}}function Wi(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;n=n[e]}return n}function Pi(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const n=Wi(e,t.property);return!("equals"in t&&!Object.is(n,t.equals)||"notEquals"in t&&Object.is(n,t.notEquals)||t.oneOf&&!t.oneOf.some(e=>Object.is(n,e))||t.notOneOf&&t.notOneOf.some(e=>Object.is(n,e)))}function Oi(e){const t=e.resources.map(e=>({...e,bodyId:e.bodyId??e.id})),n=new Map(t.map(e=>[e.bodyId,e])),o=new Map,r=new Map,i=e.assignmentForce??.45,a=e.returnForce??.35,s=e.caseAttraction??.08,c=e.assignmentOffset??{x:0,y:0};let l=new Map,u=0,d=0;return{id:e.id??"service-resource-pool",continuous:!0,assign:e=>{const n=o.get(e);if(n)return n;const i=t.find(e=>!r.has(e.id));if(!i)return null;const a={resourceId:i.id,resourceBodyId:i.bodyId,caseBodyId:e,assignedAt:u};return o.set(e,a),r.set(i.id,a),d+=1,a},release:e=>{const t=o.get(e);return!!t&&(o.delete(e),r.delete(t.resourceId),d+=1,!0)},getAssignment:e=>o.get(e),tick:e=>{u=Math.max(u,e.elapsed),l=new Map(e.controls.readBodies().map(e=>[e.id,e]));for(const[e,t]of o)l.has(e)&&l.has(t.resourceBodyId)||(o.delete(e),r.delete(t.resourceId),d+=1)},getSnapshot:()=>({total:t.length,available:t.length-r.size,assigned:r.size,assignments:Array.from(o.values()),simulatedAt:u,metricRevision:d}),bodyForce:e=>{const t=n.get(e.body.id);if(t){const n=r.get(t.id),o=n?l.get(n.caseBodyId):void 0,s=n?i:a;return{x:((o?o.x+(c.x??0):t.home.x)-e.body.x)*s,y:((o?o.y+(c.y??0):t.home.y)-e.body.y)*s}}const u=o.get(e.body.id);if(!u||0>=s)return null;const d=l.get(u.resourceBodyId);return d?{x:(d.x-e.body.x)*s,y:(d.y-e.body.y)*s}:null}}}function qi(e,t){const n="function"==typeof t.deadlineAccessor?t.deadlineAccessor(e):Wi(e.datum,t.deadlineAccessor)??Wi(e,t.deadlineAccessor);return Number.isFinite(Number(n))?Math.max(0,Number(n)):0}function Di(e){const t=new Map;let n=0,o=0;function r(n){t.set(n.bodyId,n),o+=1,e.onStateChange?.({...n})}function i(e){const o=t.get(e);return!(!o||null!=o.completedAt||(r({...o,completedAt:n,state:"unhappy"===o.state?"resolved-unhappy":"resolved"}),0))}return{id:e.id??"service-level",continuous:!0,protect:e=>{const o=t.get(e);return!(!o||null!=o.completedAt||"unhappy"===o.state||(r({...o,state:"protected",protectedAt:n}),0))},complete:i,getCase:e=>t.get(e),tick:o=>{n=Math.max(n,o.elapsed);for(const a of o.controls.readBodies()){if(!Pi(a,e.bodyFilter))continue;if(!t.has(a.id)){const t=qi(a,e);r({bodyId:a.id,openedAt:n,deadlineAt:n+t,state:"waiting"})}const s=t.get(a.id);s&&null==s.completedAt&&(e.completionRegionId&&o.getRegionState(a.id)?.activeRegionIds.includes(e.completionRegionId)?i(a.id):"waiting"!==s.state||s.deadlineAt>n||r({...s,state:"unhappy"}))}},getSnapshot:()=>{const e=Array.from(t.values()),r=t=>e.filter(e=>e.state===t).length;return{total:e.length,waiting:r("waiting"),protected:r("protected"),unhappy:r("unhappy"),resolved:r("resolved"),resolvedUnhappy:r("resolved-unhappy"),simulatedAt:n,metricRevision:o}}}}function Bi(e){const t=new Set;let n=0,o=0,r=0,i=!1;return{id:e.id??"dependency-gate:"+e.regionId,continuous:!0,tick:a=>{n=Math.max(n,a.elapsed);const s=i;var c;c=n,i=e.isOpen?e.isOpen(c):null!=e.opensAt&&c>=e.opensAt;const l=a.controls.readBodies(),u=new Map(l.map(e=>[e.id,e]));for(const n of l){const o=a.getRegionState(n.id)?.activeRegionIds.includes(e.regionId);o&&Pi(n,e.bodyFilter)&&(i||t.has(n.id)||(t.add(n.id),r+=1,e.onHeld?.(n)))}if(i&&!s){for(const n of t){const t=u.get(n);t&&(a.controls.applyImpulse(n,e.releaseImpulse?.x??86,e.releaseImpulse?.y??0),o+=1,e.onReleased?.(t))}t.clear(),r+=1}for(const e of t)u.has(e)||(t.delete(e),r+=1)},getSnapshot:()=>({regionId:e.regionId,isOpen:i,blocked:t.size,released:o,simulatedAt:n,metricRevision:r}),bodyForce:n=>{if(i||!t.has(n.body.id))return null;const o=n.regions?.find(t=>t.id===e.regionId),r=o?.shape;if(!r||"aabb"!==r.type)return{x:.8*-n.body.vx,y:.8*-n.body.vy};const a=e.holdForce??.4;return{x:(r.x-n.body.x)*a-.45*n.body.vx,y:(r.y-n.body.y)*a-.45*n.body.vy}}}}function Yi(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}function Gi(e){if(!e?.length)return null;const t=e.slice(),n=t.some(e=>!1!==e.continuous);return{controllers:t,continuous:n,onTick:(e,n,o)=>{const r={result:e,controls:n,dt:o.dt,elapsed:o.elapsed,getRegionState:o.getRegionState};for(const e of t)e.tick(r)},bodyForce:e=>{let n=null;for(const o of t)o.bodyForce&&(n=Yi(n,o.bodyForce(e)));return n}}}function Hi(e){const t=new Set,n=e.impulse??{x:-60,y:0};return{id:e.id??"portal:"+e.fromRegionId,continuous:!0===e.continuous,tick:o=>{const r=o.controls.readBodies();for(const i of r){const r=o.getRegionState(i.id),a=r?.activeRegionIds.includes(e.fromRegionId);a?t.has(i.id)||(t.add(i.id),o.controls.applyImpulse(i.id,n.x??0,n.y??0),e.onPortal?.(i)):t.delete(i.id)}}}}var _i=require("react/jsx-runtime"),Vi={flow:{fill:"rgba(59, 130, 246, 0.14)",stroke:"rgba(96, 165, 250, 0.7)",accent:"#60a5fa"},capacity:{fill:"rgba(251, 146, 60, 0.18)",stroke:"rgba(251, 146, 60, 0.85)",accent:"#fb923c"},portal:{fill:"rgba(244, 114, 182, 0.14)",stroke:"rgba(244, 114, 182, 0.7)",accent:"#f472b6"},absorb:{fill:"rgba(52, 211, 153, 0.18)",stroke:"rgba(52, 211, 153, 0.8)",accent:"#34d399"}},Xi=6.2;function Ui(e,t,n){return Math.max(t,Math.min(n,e))}function Ki(e){return e.length*Xi}function Qi(e,t){const n=e.trim();if(t>=n.length)return n;if(1>=t)return n.slice(0,1);const o=n.split(/\s+/).filter(Boolean).map(e=>e[0]).join("").toUpperCase();return o.length>1&&t>=o.length?o:t>3?n.slice(0,Math.max(1,t-2))+"..":n.slice(0,t).toUpperCase()}function Zi(e,t,n="auto"){const o=Math.max(1,Math.floor(t/Xi)),r="compact"===n?Qi(e,o):"full"===n?e:Ki(e)>t?Qi(e,o):e;return{text:r,textLength:Ki(r)>t?Math.max(4,t):void 0}}function Ji(e,t={}){const{showFlowSpine:n=!0,showStageCounts:o=!0,showCapacityBadges:r=!0,showGroupSockets:i=!0,stageLabelMode:a="auto",outlineStages:s=!1,testId:c="process-flow-chrome"}=t,{width:l,height:u,left:d,right:h,topY:f,bottomY:m,midY:p,stages:g,groups:y=[]}=e,x=m-f;return(0,_i.jsxs)("svg",{"aria-hidden":"true","data-testid":c,"data-outline-stages":s?"true":void 0,width:l,height:u,viewBox:`0 0 ${l} ${u}`,style:{position:"absolute",inset:0,pointerEvents:"none"},className:["semiotic-process-chrome",s?"semiotic-process-chrome--outline-stages":null].filter(Boolean).join(" "),children:[(0,_i.jsx)("defs",{children:(0,_i.jsxs)("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,_i.jsx)("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),(0,_i.jsx)("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),(0,_i.jsx)("rect",{x:0,y:0,width:l,height:u,fill:"url(#semiotic-process-floor)"}),(0,_i.jsx)("rect",{x:d-6,y:f-8,width:h-d+12,height:x+16,rx:14,fill:"var(--semiotic-process-lane, var(--semiotic-surface, #111827))",fillOpacity:.45,stroke:"var(--semiotic-process-border, var(--semiotic-border, #334155))",strokeOpacity:.95}),n?(0,_i.jsx)("line",{x1:d+8,x2:h-8,y1:p,y2:p,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,g.map((e,t)=>{const n=function(e){return e.absorb?"absorb":e.portalTarget?"portal":null!=e.capacity?"capacity":"flow"}(e),i=Vi[n],c=Math.max(12,e.width-8),l=Ui(c-8,22,88),d=Zi(e.label,Math.max(8,l-10),a),h="none"!==a&&c-8>=22,y=function(e){if(null!=e.capacity){const t=null!=e.queueDepth?" · q "+e.queueDepth:"";return e.capacityLabel?`${e.capacityLabel}${t}`:`cap ${Number.isInteger(e.capacity)?e.capacity+"":e.capacity.toFixed(1)}${t}`}return e.absorb?"absorb":e.portalTarget?"portal":"flow"}(e),b=Zi(y,Math.max(16,c-10),"auto"),w=r&&!1!==e.showBadge&&c>=32,M=null!=e.count?`n=${e.count}${null!=e.processed?" done "+e.processed:""}`:"",v=Zi(M,Math.max(16,c-8),"auto"),k=Math.max(30,f-15),$=k-13;return(0,_i.jsxs)("g",{"data-stage":e.id,"data-role":n,children:[(0,_i.jsx)("rect",{className:"semiotic-process-chrome__stage-bay",x:e.x0+4,y:f+6,width:c,height:x-12,rx:10,fill:s?"none":i.fill,stroke:i.stroke,strokeWidth:s?1.85:"flow"===n?1:1.6}),g.length-1>t?(0,_i.jsx)("polygon",{points:`${e.x1-2},${p-7} ${e.x1+8},${p} ${e.x1-2},${p+7}`,fill:i.accent,opacity:.85}):null,h?(0,_i.jsxs)(_i.Fragment,{children:[(0,_i.jsx)("rect",{className:"semiotic-process-chrome__stage-label-bg",x:e.x-l/2,y:$,width:l,height:18,rx:9,fill:"var(--semiotic-bg, #0f172a)",fillOpacity:.75,stroke:i.stroke}),(0,_i.jsxs)("text",{x:e.x,y:k,textAnchor:"middle",fill:i.accent,fontSize:10,fontWeight:800,className:"semiotic-process-chrome__stage-label",textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[(0,_i.jsx)("title",{children:e.label}),d.text]})]}):null,w?(0,_i.jsxs)("text",{x:e.x,y:f+22,textAnchor:"middle",fill:"var(--semiotic-process-muted, var(--semiotic-text-secondary, #94a3b8))",fontSize:9,fontWeight:700,textLength:b.textLength,lengthAdjust:b.textLength?"spacingAndGlyphs":void 0,children:[(0,_i.jsx)("title",{children:y}),b.text]}):null,o&&null!=e.count?(0,_i.jsxs)("text",{x:e.x,y:Math.min(u-8,m+16),textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #e2e8f0))",fontSize:11,fontWeight:800,textLength:v.textLength,lengthAdjust:v.textLength?"spacingAndGlyphs":void 0,children:[(0,_i.jsx)("title",{children:M}),v.text]}):null]},e.id)}),i?y.map((e,t)=>{const n=e.total??0,o=e.absorbed??0,r=e.complete??(n>0&&o>=n),i=!r&&n>0&&o/n>=.75,a=r?"rgba(52, 211, 153, 0.35)":i?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",s=r?"#34d399":i?"#fbbf24":"var(--semiotic-border, #64748b)",c=n>0?`${o}/${n}${r?" shipped":i?" almost":""}`:"feature "+(t+1),l=Ui(Math.max(54,Ki(e.label)+18,Ki(c)+16),54,104),u=Zi(e.label,l-12,"auto"),d=Zi(c,l-12,"auto");return(0,_i.jsxs)("g",{"data-group":e.id,children:[(0,_i.jsx)("rect",{x:e.x-l/2,y:e.y-22,width:l,height:44,rx:10,fill:a,stroke:s,strokeWidth:1.5}),(0,_i.jsxs)("text",{x:e.x,y:e.y-4,textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #f8fafc))",fontSize:10,fontWeight:800,textLength:u.textLength,lengthAdjust:u.textLength?"spacingAndGlyphs":void 0,children:[(0,_i.jsx)("title",{children:e.label}),u.text]}),(0,_i.jsxs)("text",{x:e.x,y:e.y+12,textAnchor:"middle",fill:s,fontSize:9,fontWeight:700,textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[(0,_i.jsx)("title",{children:c}),d.text]})]},e.id)}):null]})}function ea(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function ta(e,t,n,o){const r="function"==typeof e?e(t,n):e;return Number.isFinite(r)?Number(r):o}function na(e,t,n){return ea(e[t])??n}function oa(e,t){return"number"==typeof e?e:e?.[t]??0}function ra(e){const{band:t,idPrefix:n,plot:o,projection:r}=e,{includeBoundaryWalls:i=!0,includeInteriorWalls:a=!0,wallThickness:s=4}=t,c=function(e){const t=e.bandwidth??e.scale.bandwidth?.()??0,n=new Set;for(const o of e.values){const r=e.scale(o);Number.isFinite(r)&&(n.add(Number(r)),n.add(Number(r)+t))}return Array.from(n).sort((e,t)=>e-t)}(t);if(2>c.length)return[];const l=i?c.length-1:c.length-2,u=[];for(let e=i?0:1;l>=e;e+=1){if(!a&&e>0&&c.length-1>e)continue;const t=c[e];u.push({id:`${n}-wall-${e}`,shape:"x"===r?{type:"aabb",x:t,y:o.y+o.height/2,width:s,height:o.height}:{type:"aabb",x:o.x+o.width/2,y:t,width:o.width,height:s}})}return u}function ia(e){const{plot:t,idPrefix:n="physics-scale",bounds:o={},xBins:r,xBands:i,yBands:a}=e,s=[];if(!1!==o&&s.push(...function(e,t={}){const{idPrefix:n="plot",includeFloor:o=!0,includeCeiling:r=!1,includeLeftWall:i=!0,includeRightWall:a=!0,wallThickness:s=20,floorThickness:c=s}=t,l=[],u=e.x+e.width/2,d=e.y+e.height/2;return o&&l.push({id:n+"-floor",shape:{type:"aabb",x:u,y:e.y+e.height+c/2,width:e.width+2*s,height:c}}),r&&l.push({id:n+"-ceiling",shape:{type:"aabb",x:u,y:e.y-c/2,width:e.width+2*s,height:c}}),i&&l.push({id:n+"-left-wall",shape:{type:"aabb",x:e.x-s/2,y:d,width:s,height:e.height+2*c}}),a&&l.push({id:n+"-right-wall",shape:{type:"aabb",x:e.x+e.width+s/2,y:d,width:s,height:e.height+2*c}}),l}(t,{idPrefix:n,...o})),r){const{idPrefix:e,yTop:o,yBottom:i,...a}=r;s.push(...function(e){const{idPrefix:t="bin",count:n,domainStart:o,domainStep:r,xScale:i,yTop:a,yBottom:s,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=a,lidThickness:f=Math.max(2,c)}=e,m=[],p=a+(s-a)/2,g=Math.abs(s-a),y=l?n:n-1;if(u||l)for(let e=l?0:1;y>=e;e+=1){if(!u&&e>0&&n>e)continue;const a=i(o+e*r);m.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:a,y:p,width:c,height:g}})}if(null!=d)for(let e=0;n>e;e+=1){const n=o+e*r,a=n+r;if(a>=d)continue;const s=i(n),l=i(a);m.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(s,l)+c/2,y1:h,x2:Math.max(s,l)-c/2,y2:h,thickness:f}})}return m}({...a,idPrefix:e??n+"-xbin",yTop:o??t.y,yBottom:i??t.y+t.height}))}return i&&s.push(...ra({band:i,idPrefix:i.idPrefix??n+"-xband",plot:t,projection:"x"})),a&&s.push(...ra({band:a,idPrefix:a.idPrefix??n+"-yband",plot:t,projection:"y"})),s}function aa(e){const{plot:t,rows:n,columns:o=n+1,pegRadius:r=3,idPrefix:i="galton-peg",yStart:a=t.y+.18*t.height,yEnd:s=t.y+.58*t.height,stagger:c=!0,restitution:l=.2,friction:u=.04}=e,d=Math.max(0,Math.floor(n)),h=Math.max(1,Math.floor(o));if(0===d)return[];const f=d>1?(s-a)/(d-1):0,m=t.width/h,p=[];for(let e=0;d>e;e+=1){const n=c&&e%2==1?m/2:0;for(let o=0;h>o;o+=1){const s=t.x+m*(o+.5)+n;t.x+r>s||s>t.x+t.width-r||p.push({id:`${i}-${e}-${o}`,shape:{type:"aabb",x:s,y:a+e*f,width:2*r,height:2*r},restitution:l,friction:u})}}return p}function sa(e,t={}){const{idPrefix:n="physics-token",radius:o=5,shape:r,mass:i,vx:a,vy:s,spawnAt:c,seed:l=1,jitter:u,datum:d}=t,h=F(l),f=oa(u,"x"),m=oa(u,"y");return e.map((e,l)=>{const u=ta(t.x,e,l,na(e,"x",0)),p=ta(t.y,e,l,na(e,"y",0)),g=ta(o,e,l,5),y="function"==typeof r?r(e,l):r??{type:"circle",radius:g};return{id:`${n}-${e.index??l}`,x:u+(h()-.5)*f,y:p+(h()-.5)*m,vx:ta(a,e,l,0),vy:ta(s,e,l,0),mass:ta(i,e,l,1),spawnAt:ta(c,e,l,void 0),shape:y,datum:d?d(e,l):e.datum??e}}).map(e=>{if(Number.isFinite(e.spawnAt))return e;const{spawnAt:t,...n}=e;return n})}function ca(e,t={}){const{idPrefix:n="sediment",collider:o=!0,colliderThickness:r=1,restitution:i=.05,friction:a=.2,...s}=t,c=function(e,t={}){const{baselineY:n=0,binWidth:o=24,gap:r=2,maxHeight:i=80,value:a="count",x:s}=t,c=Math.max(1,...e.map(e=>e[a]));return e.map((e,t)=>{const l=Math.max(0,e[a]/c*i),u=s?.(e,t)??t*(o+r);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:n-l,width:o,height:l,meanX:e.x.mean,meanY:e.y.mean}})}(e,s),l=o?c.filter(e=>e.height>0).map(e=>({id:`${n}-${e.binId}`,shape:{type:"aabb",x:e.x+e.width/2,y:e.y+r/2,width:e.width,height:r},restitution:i,friction:a})):[];return{columns:c,colliders:l}}function la(e,t={}){const{timeAccessor:n="arrivalTime",timeScale:o=1,startAt:r=0,rebase:i=!0,sort:a=!0}=t,s=e.map((e,t)=>({spawn:e,time:function(e,t,n){return ea("function"==typeof n?n(e,t):e[n]??e.datum?.[n])}(e,t,n)??e.spawnAt??t})),c=s.length?Math.min(...s.map(e=>e.time)):0;return{initialSpawns:s.map(({spawn:e,time:t})=>({...e,spawnAt:r+(i?t-c:t)})).sort((e,t)=>a?(e.spawnAt??0)-(t.spawnAt??0):0),initialSpawnPacing:{pacing:"arrival",startAt:r,timeAccessor:"spawnAt",timeScale:o}}}function ua(e,t,n="group"){const o=Cr(e,t),r=e=>"function"==typeof n?n(e):e[n]??0;return e.slice().sort((e,t)=>{const n=r(e),i=r(t);return i>n?-1:n>i?1:(o[t.id]||0)-(o[e.id]||0)}).map(e=>e.id)}function da(e,t={}){const n=t.baseline??.62,o=t.inset??.06,r={},i=e.length;return e.forEach((e,t)=>{r[e]={x:i>1?o+t/(i-1)*(1-2*o):.5,y:n}}),r}function ha(e,t,n=.55){return`M${e.x},${e.y} Q${(e.x+t.x)/2},${e.y-Math.abs(t.x-e.x)*n} ${t.x},${t.y}`}function fa(e,t={}){const n=t.radius??.42,o=t.center?.x??.5,r=t.center?.y??.5,i=t.startAngle??0,a={},s=e.length;return e.forEach((e,t)=>{const c=i+t/s*Math.PI*2-Math.PI/2;a[e]={x:o+Math.cos(c)*n,y:r+Math.sin(c)*n}}),a}function ma(e,t,n={}){const o=(n.order??ua(e,t,n.groupAccessor??"group")).slice(),r=new Map(o.map((e,t)=>[e,t])),i=new Map;for(const e of t){if(!r.has(e.source)||!r.has(e.target)||e.source===e.target)continue;const t=e.target>e.source?`${e.source}\0${e.target}`:`${e.target}\0${e.source}`;i.set(t,(i.get(t)||0)+(e.value??1))}const a=[];let s=0;for(const[e,t]of i){const[n,o]=e.split("\0"),i=r.get(n),c=r.get(o);t>s&&(s=t),a.push({row:i,col:c,source:n,target:o,value:t}),a.push({row:c,col:i,source:o,target:n,value:t})}return{order:o,cells:a,size:o.length,maxValue:s}}function pa(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function ga(e){if("string"!=typeof e)return;const t=e.trim();return t.length?t:void 0}function ya(e,t){const n=pa(e.note)?e.note:void 0;return t?ga(e.mobileText)||ga(e.shortText)||ga(e.label)||ga(n?.mobileText)||ga(n?.shortText)||ga(n?.label)||ga(n?.title):ga(e.label)||ga(e.mobileText)||ga(e.shortText)||ga(n?.label)||ga(n?.title)}function xa(e,t,n){const o=function(e,t,n){if(!n)return;const o="function"==typeof n?n(e,t):e[n];return"number"==typeof o&&Number.isFinite(o)?o:void 0}(e,t,n.priorityAccessor);if(void 0!==o)return o;let r=1e3-t;const i=((e.emphasis??"")+"").toLowerCase();"primary"!==i&&"critical"!==i||(r+=1e4),"secondary"===i&&(r-=1e3),"high"===e.priority&&(r+=5e3),"low"===e.priority&&(r-=1500),"number"==typeof e.priority&&(r+=100*e.priority);const a=pa(e.provenance)?e.provenance:void 0;"number"==typeof a?.confidence&&(r+=100*a.confidence);const s=pa(e.lifecycle)?e.lifecycle:void 0,c=((s?.freshness??"")+"").toLowerCase();return"expired"!==c&&"stale"!==c||(r-=3e3),r}function ba(e,t){if(!t)return e;const n=ya(e,!0);return n&&"string"==typeof e.label?{...e,label:n}:e}function wa(e,t={}){const n=Array.isArray(e)?e.filter(pa):[],o=t.active??(null==t.width||(t.breakpoint??480)>=t.width),r=t.strategy??"hybrid",i=!1!==t.preferShortText,a=!1!==t.preservePrimary,s=Math.max(0,t.maxPlotAnnotations??t.maxAnnotations??("callout-list"===r?1:2)),c=Math.max(0,t.minPlotAnnotations??t.minVisible??1);if(!o||"plot"===r)return{active:o,strategy:r,budget:n.length,visible:i?n.map(e=>ba(e,i)):n,deferred:[],calloutList:[],hidden:[]};const l=[],u=n.map((e,n)=>({annotation:e,index:n,priority:xa(e,n,t)})).filter(e=>!!un(e.annotation)||(l.push(e.annotation),!1)).sort((e,t)=>t.priority-e.priority),d=a?u.filter(e=>"primary"===((e.annotation.emphasis??"")+"").toLowerCase()):[],h=new Set(d.map(e=>e.index)),f=u.filter(e=>!h.has(e.index)),m=[...d,...f].slice(0,Math.max(s,c)),p=new Set(m.map(e=>e.index)),g=u.filter(e=>!p.has(e.index)),y=[...l,...m.sort((e,t)=>e.index-t.index).map(e=>ba(e.annotation,i))],x=g.sort((e,t)=>e.index-t.index).map(e=>e.annotation),b=Math.max(0,t.maxCalloutItems??6),w=g.filter(e=>!t.calloutFilter||t.calloutFilter(e.annotation,e.index)).map(e=>function(e,t,n,o){const r=ya(e,o);if(!r)return null;const i=ga(e.id)||ga(e.key)||ga(e.pointId)||"annotation-"+(t+1),a=pa(e.provenance)?ga(e.provenance.source)||ga(e.provenance.authorKind):void 0;return{id:i,label:r,shortLabel:ga(e.shortText),pointId:e.pointId,emphasis:"string"==typeof e.emphasis?e.emphasis:void 0,source:a,priority:n,annotation:e}}(e.annotation,e.index,e.priority,i)).filter(e=>!!e).slice(0,b),M=new Set(w.map(e=>e.annotation)),v=x.filter(e=>!M.has(e));return{active:o,strategy:r,budget:s,visible:y,deferred:x,calloutList:w,hidden:v}}function Ma(e){return"dense"===e.density?.75:"compact"===e.density?.9:1}function va(e,t){const n=!1!==t.keepAxes,o=!1===t.directLabel?12:28;return"ordinal"===e?{top:12,right:o,bottom:n?44:12,left:n?48:12}:"geo"===e||"network"===e?{top:12,right:12,bottom:12,left:12}:{top:12,right:o,bottom:n?42:14,left:n?44:14}}function ka(e,t,n,o={}){const r={...n},i={mode:!1===t.mode?void 0:"mobile",...r,margin:va(e,t),...o},a=Object.fromEntries(Object.entries(r).filter(([,e])=>void 0!==e)),s=Object.fromEntries(Object.entries(i).filter(([,e])=>void 0!==e)),c=function(e,t){const n=t.targetSize??44,o=[],r=t.standardControls,i=e=>!0===r||"all"===r||r===e||Array.isArray(r)&&r.includes(e);return i("brush")&&o.push("range-inputs","clear-brush"),i("zoom")&&o.push("zoom-buttons","reset-view"),i("legend")&&o.push("legend-chips","show-all-series"),{strategy:`${e}-${t.transformProfile??"overview"}-mobile-recipe`,supportsResponsiveLayout:!0,breakpoints:[320,360,390,430,t.breakpoint??480,768],maxAnnotations:t.maxAnnotations??2,minimumHitTarget:n,summary:t.summary??!0,interaction:{primary:"tap",hoverFallback:"tap-to-lock",targetSize:n,...o.length>0&&{alternatives:o}},labels:{strategy:!1===t.directLabel?"compact":"direct",minFontSize:12}}}(e,t),l=function(e){return{tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:e.targetSize??44,snap:e.snap??"nearestDatum",brushHandleSize:e.targetSize??44,standardControls:e.standardControls??!1}}(t);return{family:e,props:a,responsiveRules:[{id:e+"-mobile",description:`Apply Semiotic's mobile ${e} recipe at phone width.`,when:{maxWidth:t.breakpoint??480},transform:{...s,mobileInteraction:l,mobileSemantics:c}}],mobileInteraction:l,mobileSemantics:c}}function $a(e={}){const t=Ma(e);return ka("line",e,{showLegend:e.showLegend??!1,directLabel:e.directLabel??!0,lineWidth:"inspect"===e.transformProfile?3:Math.max(1.5,2.5*t),showPoints:"inspect"===e.transformProfile,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function Aa(e={}){const t=Ma(e);return ka("area",e,{showLegend:e.showLegend??!1,showPoints:!1,areaOpacity:"compare"===e.transformProfile?.55:.42,lineWidth:Math.max(1.25,2*t),autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function Sa(e={}){return ka("ordinal",e,{showLegend:e.showLegend??!1,showCategoryTicks:e.keepAxes??!0,sort:"compare"===e.transformProfile?"desc":void 0},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function Ia(e={}){const t=Ma(e);return ka("scatter",e,{showLegend:e.showLegend??!1,pointRadius:Math.max(4,Math.round((e.targetSize??44)/8*t)),hoverRadius:Math.ceil((e.targetSize??44)/2),pointOpacity:"dense"===e.density?.42:.68,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??1,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function ja(e={}){const t=Ma(e);return ka("network",e,{showLegend:e.showLegend??!1,nodeSizeRange:[Math.max(4,Math.round(6*t)),Math.max(12,Math.round((e.targetSize??44)/2*t))],showLabels:"inspect"===e.transformProfile,edgeOpacity:"dense"===e.density?.28:.44})}function Ca(e={}){return ka("geo",e,{showLegend:e.showLegend??!1})}function Na(e={}){return ka("small-multiple",e,{mobileColumns:e.mobileColumns??1,tabletColumns:e.tabletColumns??2,chartHeight:e.chartHeight??180,sharedExtent:!0})}function La(e,t={}){switch(e){case"line":return $a(t);case"area":return Aa(t);case"ordinal":return Sa(t);case"scatter":return Ia(t);case"network":return ja(t);case"geo":return Ca(t);case"small-multiple":return Na(t)}}function za(e={}){const t=e.controls??["range-inputs","chip-filter","clear"];return{mobileInteraction:{enabled:!0,targetSize:e.targetSize??44,tapToSelect:!0,tapToLockTooltip:!0,standardControls:"brush"},mobileSemantics:{interaction:{primary:"filter",alternatives:t,summary:e.summary??"Expose brushable ranges through touch-sized controls in addition to drag gestures."}},controls:t}}var Ta=c(require("react")),Ea=require("react/jsx-runtime");function Fa({def:e,color:t,accent:n,paintOverride:o}){return(0,Ea.jsx)(Ea.Fragment,{children:e.parts.map((e,r)=>{const i=o?"none"===e.fill?void 0:o:hr(e.fill,t,n),a=o?e.stroke&&"none"!==e.stroke?o:void 0:hr(e.stroke??"none",t,n);return i||a?(0,Ea.jsx)("path",{d:e.d,fill:i??"none",stroke:a,strokeWidth:a?e.strokeWidth??1:void 0,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin,opacity:e.opacity},r):null})})}function Ra({def:e,size:t=24,color:n="currentColor",accent:o="#ffffff",fraction:r=1,fractionStart:i=0,fractionDirection:a="horizontal",ghostColor:s,x:c=0,y:l=0,opacity:u,className:d}){const h=Ta.useId();if(!e?.parts?.length)return null;const[,f]=e.viewBox??cr,m=t/(f>0?f:1);if(0>=m)return null;const p=fr(e,r,i,a),g=p?"glyph-clip"+h.replace(/[^A-Za-z0-9_-]/g,"_"):void 0;return(0,Ea.jsxs)("g",{className:d,transform:`translate(${c} ${l}) scale(${m})`,opacity:u,"aria-hidden":"true",children:[p&&g&&(0,Ea.jsx)("clipPath",{id:g,children:(0,Ea.jsx)("rect",{x:p.x,y:p.y,width:p.width,height:p.height})}),p&&s?(0,Ea.jsx)(Fa,{def:e,color:n,accent:o,paintOverride:s}):null,p&&g?(0,Ea.jsx)("g",{clipPath:`url(#${g})`,children:(0,Ea.jsx)(Fa,{def:e,color:n,accent:o})}):(0,Ea.jsx)(Fa,{def:e,color:n,accent:o})]})}
1
+ var e,t=Object.create,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,s=(e,t,i,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of r(t))a.call(e,c)||c===i||n(e,c,{get:()=>t[c],enumerable:!(s=o(t,c))||s.enumerable});return e},c=(e,o,r)=>(r=null!=e?t(i(e)):{},s(!o&&e&&e.__esModule?r:n(r,"default",{value:e,enumerable:!0}),e)),l={};((e,t)=>{for(var o in t)n(e,o,{get:t[o],enumerable:!0})})(l,{DEFAULT_AREA_PER_ANNOTATION:()=>Xn,DEFAULT_GLYPH_ANCHOR:()=>_r,DEFAULT_GLYPH_VIEWBOX:()=>Hr,DEFAULT_HIT_RADIUS:()=>dr,DEFAULT_ISOMETRIC_SPRITE_SIZES:()=>Pe,GRID_FUEL_KEYS:()=>Mo,GRID_FUEL_LABELS:()=>vo,Glyph:()=>As,LayoutCache:()=>b,SYMBOL_SEQUENCE:()=>J,TAU:()=>Lr,absorbRegion:()=>Hi,activeCountOverDomain:()=>Oo,addPoints:()=>qr,adjacencyMatrix:()=>os,aggregateRegionCounts:()=>ji,allocateCells:()=>C,analyzeNetEnsemble:()=>on,angleScale:()=>Rr,annotationBudget:()=>Qn,annotationDensity:()=>Jn,annotationLayout:()=>wo,arcLayout:()=>es,arcPath:()=>ts,arrivalReplay:()=>Za,axisFixedForceLayout:()=>Jo,axisFixedForcePositions:()=>Zo,bandLabel:()=>Zt,betweenness:()=>gi,bfsDistances:()=>fi,bobaLayout:()=>Dn,bodyGroupSpec:()=>Vi,boundsOf:()=>Kt,boxEdgeAnchors:()=>Go,buildAdjacency:()=>di,buildTooltipEntries:()=>ai,bulletLayout:()=>Sn,calendarLayout:()=>Ce,capacitatedRegion:()=>Yi,chargeGateRegion:()=>qi,circularLayout:()=>ns,clamp:()=>$,closeness:()=>yi,clustering:()=>xi,collidersFromScales:()=>Xa,comparePhysicsTrace:()=>la,composePhysicsControllers:()=>Ia,createCapacityQueueController:()=>ba,createDependencyGateController:()=>Aa,createPortalController:()=>ja,createProcessJourneyLedger:()=>da,createServiceLevelController:()=>$a,createServiceResourcePoolController:()=>va,cubicPath:()=>Xo,cubicPoint:()=>_o,cubicTangent:()=>Vo,curvedEdgePath:()=>Bo,cyclicRangeContains:()=>vr,dagreLayout:()=>Pt,degree:()=>hi,demandForecastRows:()=>So,describePhysicsStageGeography:()=>Ba,diagnoseTokenEncoding:()=>V,dimFor:()=>y,egoNetwork:()=>pi,estimateLabelWidth:()=>Sr,extractTooltipDatum:()=>ii,fanOutBend:()=>Ho,flextreeLayout:()=>Rt,forceFieldRegion:()=>_i,forceLayout:()=>P,forceLayoutAsync:()=>Ii,formatMw:()=>Eo,formatReservePct:()=>To,formatTooltipValue:()=>si,galtonPegs:()=>Ua,generateTokens:()=>H,geoAreaHitTarget:()=>pr,geoHitTarget:()=>mr,geographicDotGridLayout:()=>Tt,geographicGridLayout:()=>lt,glyphExtent:()=>Xr,glyphFractionClipRect:()=>Kr,glyphPlacement:()=>Vr,gridEventAnnotations:()=>zo,gridifyGeographicPoints:()=>at,groupBy:()=>m,groupCompletionRows:()=>Ni,hatchFill:()=>Jt,hitTargetPoint:()=>fr,hitTargetRect:()=>gr,hullFromBoxes:()=>Qt,intervalLanesLayout:()=>Do,isometricLandmarkLayout:()=>Ve,isotypeBoltGlyph:()=>le,isotypeBusGlyph:()=>ue,isotypeChipGlyph:()=>ce,isotypeGhost:()=>ae,isotypeInk:()=>re,isotypeNetworkGlyphs:()=>fe,isotypePaper:()=>ie,isotypePersonGlyph:()=>he,isotypePersonPath:()=>de,isotypeServerGlyph:()=>se,layoutChipStrip:()=>Ar,layoutSequence:()=>$r,layoutTokenGrid:()=>_,legendGroupsFrom:()=>ti,legendSwatches:()=>ni,lineageDagLayout:()=>Bt,linearAxis:()=>en,makeShade:()=>w,marimekkoLayout:()=>kn,markCallout:()=>tn,matchesHighlight:()=>g,mean:()=>S,membraneRegion:()=>Oi,mermaidDagLayout:()=>Vt,mobileAnnotationStrategy:()=>ls,mobileAreaChartRecipe:()=>ms,mobileBrushAlternatives:()=>Ms,mobileChartFamilyRecipe:()=>ws,mobileGeoChartRecipe:()=>xs,mobileLineChartRecipe:()=>fs,mobileNetworkChartRecipe:()=>ys,mobileOrdinalChartRecipe:()=>ps,mobileScatterplotRecipe:()=>gs,mobileSmallMultipleRecipe:()=>bs,mulberry32:()=>T,netEnsembleLayout:()=>fn,networkHitTarget:()=>yr,nonNegativeFinite:()=>A,normalizePoint:()=>Gr,normalizeScores:()=>bi,normalizeTokenEncoding:()=>B,orderByGroupDegree:()=>Ja,orthogonalEdgePath:()=>Yo,packIntervals:()=>Wo,packSpanLevels:()=>Ir,packedClusterMatrix:()=>bn,parallelCoordinatesLayout:()=>Cn,partitionSharedEdges:()=>Fr,physicsChargePoint:()=>qa,physicsDestination:()=>Oa,physicsReferenceEnvelope:()=>ra,physicsStageColliders:()=>Da,physicsStageGeography:()=>Wa,pointMagnitude:()=>Yr,polarToXY:()=>Er,portalRegion:()=>Gi,pressureFieldRegion:()=>Bi,processChrome:()=>Ra,processJourneyRows:()=>fa,processLaneWalls:()=>Xi,processStageLayout:()=>Ri,processStageRegions:()=>Wi,processVolumePolygons:()=>Li,proximityProblem:()=>wi,radiusScale:()=>Pr,readField:()=>h,rectCollide:()=>Uo,regionCountsToProjectionRows:()=>Ci,reserveAnnotationBands:()=>No,reserveMarginPct:()=>Io,reserveSeries:()=>jo,ringArcPath:()=>Wr,roundedEnclosure:()=>Ut,routeSurfaceRegion:()=>Di,runLengthEncode:()=>br,runs:()=>xr,sampleGeographicDotGrid:()=>jt,scaleArcBand:()=>jr,scalePoint:()=>Br,sedimentBake:()=>Qa,selectCyclicRange:()=>kr,selectIsometricLandmarks:()=>_e,shade:()=>M,shortestArcDelta:()=>Mr,shortestPath:()=>mi,signatureKey:()=>x,spanArcPath:()=>Cr,spanArcPeakY:()=>Nr,spawnFromTokens:()=>Ka,stackFuelSeries:()=>Ao,stageTargetInVolume:()=>zi,subtractPoints:()=>Dr,suggestTokenEncoding:()=>K,summarizeOperatingPoint:()=>Fo,symbolExtent:()=>oe,symbolPathString:()=>ee,symbolRadius:()=>te,thresholdBandsForReserve:()=>Co,tightestHours:()=>Lo,tokenLayer:()=>Se,tokenTaskIntentToCapabilityIntents:()=>U,unitize:()=>z,unitizeRange:()=>L,unwrapDatum:()=>f,updateProcessJourney:()=>ha,useCustomLayoutSelection:()=>Te,waffleLayout:()=>j,withAlpha:()=>I,wordTrailsLayout:()=>cr,wordTrailsProgressiveReveal:()=>er,wrapValue:()=>wr,xyToAngle:()=>Tr}),module.exports=(e=l,s(n({},"__esModule",{value:!0}),e));var u=require("d3-interpolate");function d(e){return"function"==typeof e?e:t=>t[e]}function h(e,t,n){const o=e?.data,r=o?o[t]:void 0;if(null!=r)return r;const i=e?.[t];return null==i?n:i}function f(e){return null==e?null:e.data??e.datum??e}function m(e,t){const n=new Map;for(const o of e){const e=t(o),r=n.get(e);r?r.push(o):n.set(e,[o])}return n}function p(e){const t=Object.create(null);return e((e,n)=>{t[e]=n}),t}function g(e,t){if(!t)return!0;const n=Array.isArray(t)?t:[t],o=e;for(const e of n)if(null!=e.value&&o[e.field]+""!=e.value+"")return!1;return!0}function y(e,t={}){const n=t.baseOpacity??1;return t.highlight||t.predicate?!g(e,t.highlight)||t.predicate&&!t.predicate(e)?t.dimOpacity??.16:Math.min(1,n+(t.brighten??0)):n}function x(e){return e.join("|")}var b=class{constructor(e=12){this.maxSize=e,this.store=new Map}get(e){return this.store.get(e)}set(e,t){this.maxSize>this.store.size||this.store.clear(),this.store.set(e,t)}getOrCompute(e,t){const n=this.store.get(e);if(void 0!==n)return n;const o=t();return this.set(e,o),o}clear(){this.store.clear()}get size(){return this.store.size}};function w(e,t=.72){const n=(0,u.interpolateLab)(e,"#ffffff"),o=(0,u.interpolateLab)(e,"#000000"),r=(0,u.interpolateLab)(e,e)(0);return e=>{const i=0>e?0:e>1?1:e;return.5===i?r:.5>i?n(2*(.5-i)*t):o(2*(i-.5)*t)}}function M(e,t,n=.72){return w(e,n)(t)}function v(e){return p(t=>{for(const[n,o]of Object.entries(e))t(n,o)})}function k(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"item"}function $(e,t,n){return Math.max(t,Math.min(n,e))}function A(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}function S(e){if(0===e.length)return 0;let t=0;for(const n of e)t+=n;return t/e.length}function I(e,t){const n=$(t,0,1),o=e.trim().replace(/^#/,""),r=3===o.length?o.split("").map(e=>e+e).join(""):o;return/^[0-9a-fA-F]{6}$/.test(r)?`rgba(${parseInt(r.slice(0,2),16)}, ${parseInt(r.slice(2,4),16)}, ${parseInt(r.slice(4,6),16)}, ${n})`:e}var j=e=>{const t=e.config,n=t.rows??10,o=t.columns??10,r=t.gutter??2,i=n*o;if(0>=n||0>=o||0>=i)return{nodes:[]};const{plot:a}=e.dimensions;if(0>=a.width||0>=a.height)return{nodes:[]};const s=(a.width-r*(o-1))/o,c=(a.height-r*(n-1))/n;if(0>=s||0>=c)return{nodes:[]};const l=(null==(u=t.categoryAccessor)?null:"function"==typeof u?u:e=>e[u])??(()=>"_default");var u;const d=function(e){return null==e?null:"function"==typeof e?e:t=>Number(t[e])}(t.valueAccessor)??(()=>1),h=new Map,f=[];for(const t of e.data){const e=l(t)+"",n=Number(d(t)),o=Number.isFinite(n)?Math.max(0,n):0;h.has(e)||f.push(e),h.set(e,(h.get(e)??0)+o)}const m=Array.from(h.values()).reduce((e,t)=>e+t,0);if(0>=m)return{nodes:[]};let g;if(t.categoryOrder&&t.categoryOrder.length>0){const e=new Set,n=[];for(const o of t.categoryOrder)h.has(o)&&!e.has(o)&&(e.add(o),n.push(o));g=[...n,...f.filter(t=>!e.has(t))]}else g=f;if(0===g.length)return{nodes:[]};const y=g.map(e=>({cat:e,exact:(h.get(e)??0)/m*i})).map(e=>({...e,count:Math.floor(e.exact)})),x=y.reduce((e,t)=>e+t.count,0),b=y.map((e,t)=>({i:t,rem:e.exact-e.count})).sort((e,t)=>t.rem-e.rem);for(let e=0;i-x>e;e++)y[b[e%b.length].i].count+=1;const w="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",M="string"==typeof t.valueAccessor?t.valueAccessor:"value",v=(e,t,n)=>p(o=>{o("category",e),o("value",h.get(e)??0),o("share",(h.get(e)??0)/m),"category"!==w&&o(w,e),"value"!==M&&o(M,h.get(e)??0),o("cells",n),o("_waffleCategory",e),o("_waffleIndex",t)}),k=[];let $=0;for(const t of y){const i=e.resolveColor(t.cat);for(let e=0;t.count>e;e++)k.push({type:"rect",x:a.x+$%o*(s+r),y:a.y+(n-1-Math.floor($/o))*(c+r),w:s,h:c,style:{fill:i,stroke:"none"},datum:v(t.cat,$,t.count),group:t.cat,_transitionKey:`waffle-${t.cat}-${e}`}),$++}return{nodes:k}};function C(e,t,n){const o=Math.max(0,Math.floor(n?.minPerCategory??0)),r=e.reduce((e,t)=>e+Math.max(0,t.weight),0);if(0>=t||0>=r)return e.map(e=>({...e,exact:0,cells:0,remainder:0}));const i=e.map(e=>{const n=Math.max(0,e.weight)/r*t;return{...e,exact:n,cells:Math.max(o,Math.floor(n)),remainder:n-Math.floor(n)}});let a=i.reduce((e,t)=>e+t.cells,0);for(;a>t;){const e=i.filter(e=>e.cells>o).sort((e,t)=>t.cells-e.cells||e.remainder-t.remainder||e.key.localeCompare(t.key))[0];if(!e)break;e.cells--,a--}const s=[...i].sort((e,t)=>t.remainder-e.remainder||t.weight-e.weight||e.key.localeCompare(t.key));for(let e=0;t>a;e++)s[e%s.length].cells++,a++;return i}var N=1e-6;function F(e){return Number.isFinite(e)?Math.max(0,e):0}function z(e,t){const n=Number(t.unit),o=F(e),r=t.maxUnits??1/0,i=t.minFraction??0;if(0>=n||0>=r||0>=o)return{units:[],unit:n>0?n:0,total:o,shown:0,overflow:o>0&&!(r>0)};const a=Math.ceil(o/n-N),s=Math.min(r,a),c=a>r,l=[];for(let e=0;s>e;e+=1){const t=e*n;let r=Math.min(1,Math.max(0,(Math.min(o,t+n)-t)/n));N>1-r&&(r=1),l.push({index:e,fraction:r,start:t,end:t+r*n,value:r*n})}const u=l[l.length-1];u&&i>u.fraction&&1>u.fraction&&l.pop();const d=l.reduce((e,t)=>e+t.value,0);return{units:l,unit:n,total:o,shown:d,overflow:c}}function L(e,t,n){const o=z(e,n),r=Math.max(F(t),o.total);if(o.total>=r)return{...o,rangeUnits:[],rangeTotal:o.total};const i=z(r,{unit:n.unit,maxUnits:n.maxUnits}),a=i.unit>0?o.total/i.unit:0,s=Math.floor(a+N);let c=Math.min(1,Math.max(0,a-s));N>c&&(c=0);const l=[];for(const e of i.units)s>e.index||(e.index===s&&c>0?e.fraction-c>N&&l.push({...e,startFraction:c,start:e.index*i.unit+c*i.unit,value:(e.fraction-c)*i.unit}):l.push({...e,startFraction:0}));return{...o,overflow:o.overflow||i.overflow,rangeUnits:l,rangeTotal:r}}var E=require("d3-force");function T(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}}var R=1e3;function P(e,t,n={}){const o=n.iterations??260,r=n.repulsion??5200,i=n.linkDistance??165,a=n.linkStrength??.045,s=n.centerStrength??.018,c=n.damping??.84,l=n.nodeRadius??12,u=n.nodePadding??3,d=n.inset??.06,h=T(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 m=R/2,p=e.map(e=>({id:e.id,data:e,x:200+600*h(),y:200+600*h()})),g=new Set(e.map(e=>e.id)),y=t.filter(e=>g.has(e.source)&&g.has(e.target)).map(e=>({source:e.source,target:e.target}));if(o>0){const e=(0,E.forceSimulation)(p).randomSource(h).alphaDecay(1-Math.pow(.001,1/o)).velocityDecay(Math.max(0,Math.min(1,1-c))).force("charge",(0,E.forceManyBody)().strength(e=>{const t=f.get(e.id)??0;return 2.5*-Math.sqrt(r)*Math.sqrt(t+1)})).force("collide",(0,E.forceCollide)(e=>(e=>"function"==typeof l?l(e.data):l)(e)+u).strength(.9).iterations(2)).force("center",(0,E.forceCenter)(m,m).strength(.8)).force("x",(0,E.forceX)(m).strength(s)).force("y",(0,E.forceY)(m).strength(s));y.length>0&&e.force("link",(0,E.forceLink)(y).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;o>t;t+=1)e.tick()}let x=1/0,b=1/0,w=-1/0,M=-1/0;for(const e of p){const t=e.x??m,n=e.y??m;x>t&&(x=t),b>n&&(b=n),t>w&&(w=t),n>M&&(M=n)}const v=w-x,k=M-b,$={};for(const e of p)$[e.id]={x:0===v?.5:d+((e.x??m)-x)/v*(1-2*d),y:0===k?.5:d+((e.y??m)-b)/k*(1-2*d)};return $}var W=80,O=100;function q(e){return e?e.map(Number).filter(Number.isFinite):[]}function D(e){if("fixed-denominator"===e.countStrategy)return 1/0;const t=e.maxTokens??1/0;return t>0?Math.floor(t):0}function B(e){const t=e.unitValue??e.unit,n=e.icon??e.token;return{...e,...null!=t&&{unitValue:t},...null!=n&&{icon:n}}}function Y(e){if(e.samples)return q(e.samples);if(!e.data||!e.valueAccessor)return[];const t=e.valueAccessor;return e.data.map(e=>"function"==typeof t?t(e):Number(e[t])).filter(Number.isFinite)}function G(e,t,n,o={}){return{index:t,tokenType:e.tokenType,tokenSemantics:e.tokenSemantics,countStrategy:e.countStrategy,fraction:1,startFraction:0,value:n,start:t,end:t+n,unitValue:e.unitValue,unitMeaning:e.unitMeaning,...o}}function H(e,t){const n=B(t),o=function(e){return"number"==typeof e?{value:e}:Array.isArray(e)?{samples:q(e),data:e}:e}(e);let r,i,a,s,c,l,u,d=0,h=!1;if("unitized"===n.countStrategy){c=n.unitValue??1;const e={unit:c,maxUnits:n.maxTokens,minFraction:n.minFraction},t=null==o.rangeValue?z(A(o.value),e):L(A(o.value),A(o.rangeValue),e);r=t.units.map(e=>G(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:t.unit})),i=t.total,d=t.shown,h=t.overflow,null!=o.rangeValue&&(l=t.rangeTotal,u=t.rangeUnits.map(e=>G(n,e.index,e.value,{fraction:e.fraction,startFraction:e.startFraction,start:e.start,end:e.end,unitValue:t.unit,range:"scenario"})))}else if("fixed-denominator"===n.countStrategy){s=Math.floor(A(o.denominator??n.denominator)),a=A(o.numerator??n.numerator??o.value);const e=Math.min(s,Math.max(0,Math.round(a)));r=Array.from({length:s},(t,o)=>G(n,o,1,{highlighted:e>o,start:o,end:o+1})),i=s,d=r.length,h=!1}else if("quantile"===n.countStrategy){const e=Y(o).sort((e,t)=>e-t),t=Math.max(0,Math.floor(n.tokenCount??50)),a=e.length>0?Math.min(t,D(n)):0;r=Array.from({length:a},(t,o)=>{const r=(o+.5)/a,i=function(e,t){const n=e.length;if(0===n)return 0;if(1===n)return e[0];const o=(n-1)*Math.min(1,Math.max(0,t)),r=Math.floor(o),i=o-r;return e[r]*(1-i)+e[Math.ceil(o)]*i}(e,r);return G(n,o,i,{sample:i,quantile:r,start:i,end:i})}),i=e.length,d=r.length,h=e.length>0&&t>r.length}else if("sample"===n.countStrategy||"posterior-sample"===n.countStrategy||"random-sample"===n.countStrategy){const e=Y(o),t=Math.min(e.length,Math.max(0,Math.floor(n.tokenCount??e.length))),a=Math.min(t,D(n));r=("random-sample"===n.countStrategy?function(e,t=1){const n=Array.from({length:e},(e,t)=>t),o=T(Math.floor(t)||1);for(let e=n.length-1;e>0;e-=1){const t=Math.floor(o()*(e+1)),r=n[e];n[e]=n[t],n[t]=r}return n}(e.length,n.seed).slice(0,a):Array.from({length:a},(t,n)=>Math.floor(n/Math.max(1,a-1)*(e.length-1)))).map((t,o)=>{const r=e[t];return G(n,o,r,{sample:r,start:r,end:r})}),i=e.length,d=r.length,h=t>r.length}else{const e=o.data;if(e&&null==o.value)r=e.map((e,t)=>G(n,t,1,{datum:e})),i=e.length;else{const e=z(A(o.value),{unit:1,maxUnits:n.maxTokens,minFraction:n.minFraction});r=e.units.map(e=>G(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:1})),i=e.total,d=e.shown,h=e.overflow}if(e&&null==o.value){const e=function(e,t){const n=D(t);return e.length>n?{tokens:e.slice(0,n),overflow:!0}:{tokens:e,overflow:!1}}(r,n);r=e.tokens,d=r.length,h=e.overflow}}return{tokens:r,encoding:n,total:i,shown:d,overflow:h,numerator:a,denominator:s,unitValue:c,rangeTotal:l,rangeTokens:u,diagnostics:V(n,{visibleTokens:r.length+(u?.length??0)})}}function _(e,t={}){const n=Array.isArray(e)?e:e.tokens,o=n.length;if(0===o)return[];const r=t.flow??"row",i=t.cellWidth??16,a=t.cellHeight??i,s=t.gutter??2,c=t.anchor??[.5,.5],l=Math.max(1,Math.floor(t.columns??Math.ceil(t.rows?o/t.rows:Math.sqrt(o)))),u=Math.max(1,Math.floor(t.rows??Math.ceil(o/l))),d="row"===r?Math.max(u,Math.ceil(o/l)):u,h="column"===r?Math.max(l,Math.ceil(o/u)):l,f=t.x??0,m=t.y??0;return n.map((e,n)=>{let o,p;return"column"===r?(p=Math.floor(n/u),o=n%u):(o=Math.floor(n/l),p=n%l),"left"===t.columnDirection&&(p=h-1-p),"up"===t.rowDirection&&(o=d-1-o),{...e,row:o,column:p,x:f+p*(i+s)+c[0]*i,y:m+o*(a+s)+c[1]*a}})}function V(e,t={}){const n=[],o=e.tokenSemantics,r=e.countStrategy,i=t.maxRecommendedTokens??("fixed-denominator"!==r||A(e.denominator)>O?W:O);return o||n.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),r||n.push({code:"MISSING_COUNT_STRATEGY",severity:"warning",message:"Every tokenized encoding should state how token counts are produced."}),"icon"!==e.tokenType&&"glyph"!==e.tokenType||"icon-only"!==e.labelPolicy&&"token-only"!==e.labelPolicy||n.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=t.visibleTokens&&t.visibleTokens>i&&n.push({code:"TOO_MANY_VISIBLE_TOKENS",severity:"warning",message:`This encoding renders ${t.visibleTokens} visible tokens. Consider unitizing, sampling, or a hybrid bar/token view.`}),"decorative"!==o||"icon"!==e.tokenType&&"glyph"!==e.tokenType||n.push({code:"DECORATIVE_PICTOGRAPHS",severity:"warning",message:"Decorative pictographs can harm recall and speed when they do not clarify the data."}),"unitized-measure"===o&&r&&"unitized"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Unitized measures should use the unitized count strategy so each token has a stable value."}),"risk-case"===o&&r&&"fixed-denominator"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),"possible-outcome"!==o&&"posterior-sample"!==o&&"hypothetical-case"!==o||!r||"quantile"===r||"sample"===r||"posterior-sample"===r||"random-sample"===r||n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===o&&"unitized"===r&&null==e.unitValue&&null==e.unit&&n.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"!==o||"unitized"!==r||e.unitMeaning||n.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),n}function X(e){return"measure"===e?"precise-comparison":"estimate probability"===e?"probability-estimation":"understand risk"===e?"risk-communication":"remember"===e?"memory":"decide"===e?"support-decision":e}function U(e){const t=X(e);return"precise-comparison"===t?["compare-categories","rank"]:"probability-estimation"===t?["distribution"]:"risk-communication"===t?["part-to-whole","distribution"]:"frequency-reasoning"===t?["distribution","compare-categories"]:"memory"===t||"editorial-engagement"===t?["compare-categories"]:"public-explanation"===t||"support-decision"===t?["distribution","compare-categories"]:["compare-categories"]}function K(e){const t=X(e.taskIntent),n="small"===(o=e.availableSpace)?25:"large"===o?100:50;var o;if("precise-comparison"===t)return{recommendedEncoding:"bar-or-line",rationale:"Use continuous position/length encodings when precise magnitude comparison is the primary task.",warnings:[],alternatives:["hybrid-bar-token","unitized-measure"]};if("probability-estimation"===t){const e={tokenType:"dot",tokenSemantics:"possible-outcome",countStrategy:"quantile",tokenCount:n,layout:"dotplot",labelPolicy:"text-plus-token"};return{recommendedEncoding:"quantile-dotplot",tokenEncoding:e,rationale:"This task asks readers to estimate probability from a distribution. Quantile tokens turn probability mass into countable possible outcomes.",warnings:V(e),alternatives:["cdf-with-threshold","density-with-threshold"]}}if("risk-communication"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"risk-case",countStrategy:"fixed-denominator",denominator:100,layout:"waffle",labelPolicy:"text-plus-token"};return{recommendedEncoding:"fixed-denominator-icon-array",tokenEncoding:t,rationale:"Risk is often clearer as natural frequency: highlighted cases out of a fixed denominator.",warnings:V(t,{visibleTokens:100,maxRecommendedTokens:100}),alternatives:["labeled-percent","bar-with-risk-threshold"]}}if("memory"===t||"editorial-engagement"===t){const t={tokenType:e.concreteEntity?"glyph":"icon",icon:e.concreteEntity,tokenSemantics:"unitized-measure",countStrategy:"unitized",unitValue:1,layout:"grid",labelPolicy:"text-plus-token",unitMeaning:e.concreteEntity?"one token represents a unit of "+e.concreteEntity:"one token represents one unit"};return{recommendedEncoding:"semantic-isotype",tokenEncoding:t,rationale:"Semantic tokens are useful when the chart needs to make a topic concrete and memorable.",warnings:V(t),alternatives:["labeled-bar","hybrid-bar-token"]}}if("frequency-reasoning"===t||"public-explanation"===t||"support-decision"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"distribution"===e.dataType?"possible-outcome":"unitized-measure",countStrategy:"distribution"===e.dataType?"quantile":"unitized",unitValue:"distribution"===e.dataType?void 0:1,tokenCount:n,layout:"distribution"===e.dataType?"dotplot":"bar-segment",labelPolicy:"text-plus-token",unitMeaning:"distribution"===e.dataType?void 0:"one token represents one unit interval"};return{recommendedEncoding:"hybrid-continuous-token",tokenEncoding:t,rationale:"A hybrid view preserves measurement while adding countable tokens for explanation and decisions.",warnings:V(t),alternatives:["bar-or-line","quantile-dotplot","fixed-denominator-icon-array"]}}return{recommendedEncoding:"bar-or-line",rationale:"Use continuous encodings unless the task needs frequency, risk, memory, or outcome reasoning.",warnings:[],alternatives:["unitized-measure","quantile-dotplot","fixed-denominator-icon-array"]}}var Q=require("d3-shape"),Z={circle:Q.symbolCircle,square:Q.symbolSquare,triangle:Q.symbolTriangle,diamond:Q.symbolDiamond,star:Q.symbolStar,cross:Q.symbolCross,wye:Q.symbolWye},J=["circle","triangle","diamond","star","square","chevron","cross","wye"];function ee(e,t,n){if(n)return n;const o=e??"circle";return"chevron"===o?function(e){const t=1.5*te(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,Q.symbol)(Z[o]??Q.symbolCircle,Math.max(1,t))()??""}function te(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var ne=new Map;function oe(e,t,n){if(!n&&"circle"===(e??"circle"))return te(t);const o=n?"p:"+n:`${e}:${Math.round(t)}`,r=ne.get(o);if(null!=r)return r;const i=(n??ee(e,t)).match(/-?\d*\.?\d+(?:e-?\d+)?/gi);let a=0;if(i)for(let e=0;i.length>e+1;e+=2){const t=+i[e],n=+i[e+1],o=Math.sqrt(t*t+n*n);o>a&&(a=o)}return a>0||(a=te(t)),ne.size>512&&ne.clear(),ne.set(o,a),a}var re="#334155",ie="#f8fafc",ae="#cbd5e1",se={viewBox:[40,40],anchor:[.5,1],parts:[{d:"M8 3h24v34H8z",fill:"color"},{d:"M12 9h16v5H12zM12 18h16v5H12zM12 27h16v5H12z",fill:"accent"},{d:"M23.8 11.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 20.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 29.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0",fill:"color"}]},ce={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M10 8h20a2 2 0 0 1 2 2v20a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2z",fill:"color"},{d:"M15 15h10v10H15z",fill:"accent"},{d:"M7 2v6M14 2v6M21 2v6M28 2v6M7 32v6M14 32v6M21 32v6M28 32v6M2 7h6M2 14h6M2 21h6M2 28h6M32 7h6M32 14h6M32 21h6M32 28h6",fill:"none",stroke:"color",strokeWidth:3}]},le={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M23 1L7 23h10l-3 16 19-25H22z",fill:"color"}]},ue={viewBox:[48,40],anchor:[.5,.78],parts:[{d:"M7 12c0-4 3-7 7-7h20c4 0 7 3 7 7v15H7z",fill:"color"},{d:"M11 15h26v8H11z",fill:"accent",opacity:.9},{d:"M12 27h7v4h-7zM29 27h7v4h-7z",fill:"accent",opacity:.95},{d:"M12 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0M28 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0",fill:"color",stroke:"accent",strokeWidth:1.8},{d:"M5 13h4v8H5zM39 13h4v8h-4z",fill:"color"}]},de="M 9.12,3.34 C 8.28,3.29 7.44,3.40 6.64,3.69 4.17,3.63 1.97,5.37 0.91,7.51 -1.32,11.80 2.55,17.76 8.19,16.55 11.62,16.13 15.55,14.04 16.17,10.33 16.38,6.53 12.77,3.52 9.12,3.34 Z M 9.35,19.86 C 8.89,19.84 8.41,19.92 7.92,20.11 5.12,21.55 3.72,24.68 2.79,27.54 2.32,29.86 0.87,32.04 1.36,34.49 1.63,37.60 8.04,38.95 8.04,38.95 8.04,38.95 14.67,39.65 16.50,36.33 17.16,31.95 16.34,27.23 14.01,23.42 13.07,21.69 11.36,19.92 9.35,19.86 Z",he={viewBox:[18,40],anchor:[.5,1],parts:[{d:de,fill:"color",stroke:"color",strokeWidth:1.4}]},fe={server:se,chip:ce,bolt:le,bus:ue,person:he},me="var(--semiotic-primary, #4e79a7)",pe="var(--semiotic-border, #d1d5db)",ge="var(--semiotic-secondary, #9ca3af)",ye="var(--semiotic-bg, #ffffff)";function xe(e){return"object"==typeof e&&null!==e&&"tokens"in e&&"encoding"in e}function be(e,t,n){return"function"==typeof e?e(t)??n:e??n}function we(e,t){return"function"==typeof e?e(t):e}function Me(e){return e.sample??e.value??e.index}var ve=new Set(J);function ke(e,t){return void 0!==t.datum?be(t.datum,e,null):e.datum??null}function $e(e,t){return{fill:!1!==e.highlighted?"scenario"===e.range?be(t.rangeColor,e,ge):be(t.color,e,me):be(t.inactiveColor,e,pe),stroke:"none",...we(t.style,e)??{}}}function Ae(e,t){const n=we(t.pointId,e)??(t.idPrefix?`${t.idPrefix}-${"scenario"===e.range?"range-":""}${e.index}`:void 0);return{datum:ke(e,t),accessibleDatum:we(t.accessibleDatum,e),accessibility:we(t.accessibility,e),pointId:n,_transitionKey:n}}function Se({input:e,encoding:t,options:n={}}){if(!xe(e)&&!t)throw Error("tokenLayer requires an encoding when input is not a TokenSet.");const o=xe(e)?{...e,encoding:B(e.encoding)}:H(e,t),r=function(e,t){const n=t.includeRange&&e.rangeTokens?[...e.tokens,...e.rangeTokens]:e.tokens;if(t.positionToken)return function(e,t){const n=t.positionToken;return n?e.map((t,o)=>{const r=n(t,o,e);return{...t,x:r.x,y:r.y,row:r.row??o,column:r.column??0}}):[]}(n,t);const o=t.layout??e.encoding.layout??"grid";if("quantile-strip"===o)return function(e,t){if(0===e.length)return[];const n=t.x??0,o=t.y??0,r=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),i=t.gutter??2,a=Math.max(1,Math.floor(t.rows??1)),s=e.map(Me),c=Math.min(...s),l=Math.max(...s)-c||1;return e.map((s,u)=>{const d=Me(s),h=u%a,f=t.valueToX?t.valueToX(d,s):n+(d-c)/l*(t.width??12*Math.max(1,e.length-1)),m=t.valueToY?t.valueToY(d,s):o+h*(r+i);return{...s,x:f,y:m,row:h,column:u}})}(n,t);if("dotplot"===o)return function(e,t){if(0===e.length)return[];const n=t.x??0,o=t.y??0,r="number"==typeof t.tokenSize?t.tokenSize:12,i=t.gutter??2,a=t.cellWidth??r+i,s=t.cellHeight??r+i,c=e.map(Me),l=Math.min(...c),u=Math.max(...c)-l||1,d=new Map;return e.map(r=>{const i=Me(r),c=t.valueToX?t.valueToX(i,r):n+(i-l)/u*(t.width??Math.max(1,e.length-1)*a),h=Math.round((c-n)/Math.max(1,a)),f=d.get(h)??0;d.set(h,f+1);const m=t.valueToY?t.valueToY(i,r):o+f*s;return{...r,x:n+h*a,y:m,row:f,column:h}})}(n,t);if("bar-segment"===o){if(!t.valueToX)throw Error('tokenLayer layout "bar-segment" requires valueToX and optionally valueToY.');return function(e,t){if(!t.valueToX)return[];const n=t.y??0,o=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),r=t.anchor??[.5,.5];return e.map((e,i)=>{const a=Number.isFinite(e.start)?e.start:Me(e),s=(a+(Number.isFinite(e.end)?e.end:a+e.value))/2,c=t.valueToY?t.valueToY(s,e):n+r[1]*o;return{...e,x:t.valueToX(s,e),y:c,row:0,column:i}})}(n,t)}if("beeswarm"===o||"small-multiple"===o)throw Error(`tokenLayer layout "${o}" is not implemented yet; use row, column, stack, grid, waffle, dotplot, quantile-strip, bar-segment with valueToX, or positionToken.`);const r="number"==typeof t.tokenSize?t.tokenSize:void 0,i=t.cellWidth??r??12,a=t.cellHeight??r??i,s="row"===o?Math.max(1,n.length):"column"===o||"stack"===o?1:"waffle"===o&&"fixed-denominator"===e.encoding.countStrategy&&100===e.denominator?10:function(e,t,n){if(t.columns)return t.columns;if(t.width&&n>0){const e=t.gutter??2;return Math.max(1,Math.floor((t.width+e)/(n+e)))}return e.length>0?Math.ceil(Math.sqrt(e.length)):1}(n,t,i);return _(n,{...t,columns:s,cellWidth:i,cellHeight:a})}(o,n).filter(e=>!n.include||n.include(e));return{tokenSet:o,positionedTokens:r,nodes:r.map(e=>function(e,t,n){if("dot"===n.tokenType)return function(e,t){const n=be(t.tokenSize,e,12);return{type:"point",x:e.x,y:e.y,r:be(t.radius,e,n/2),style:$e(e,t),...Ae(e,t)}}(e,t);const o=we(t.glyph,e)??function(e){if(e)return fe[e]}(n.icon);if(o)return function(e,t,n){const o=$e(e,n),r=be(n.tokenSize,e,12);return{type:"glyph",x:e.x,y:e.y,size:r,glyph:t,color:(o.fill??me)+"",accent:be(n.accent,e,ye),fraction:1>e.fraction?e.fraction:void 0,fractionStart:e.startFraction>0?e.startFraction:void 0,fractionDirection:be(n.fractionDirection,e,"horizontal"),ghostColor:1>e.fraction?we(n.ghostColor,e)??pe:void 0,rotation:we(n.rotation,e),style:o,...Ae(e,n)}}(e,o,t);const r=(i=n.icon)&&ve.has(i)?i:void 0;var i;return function(e,t){const n=be(t.tokenSize,e,12);return{type:"symbol",x:e.x,y:e.y,size:Math.PI*Math.max(1,n/2)**2,symbolType:be(t.symbolType,e,"circle"),path:we(t.symbolPath,e),rotation:we(t.rotation,e),style:$e(e,t),...Ae(e,t)}}(e,r&&null==t.symbolType?{...t,symbolType:r}:t)}(e,n,o.encoding))}}var Ie=require("d3-interpolate"),je=864e5,Ce=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height)return{nodes:[]};const o=e=>{const n="function"==typeof t.dateAccessor?t.dateAccessor(e):e[t.dateAccessor];return n instanceof Date?n:new Date(n)},r=e=>{const n="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor];return Number(n)},i=new Map;let a=null;for(const t of e.data){const e=o(t);if(!isFinite(e.getTime()))continue;null==a&&(a=e.getUTCFullYear());const n=Ne(e),s=r(t);i.set(n,(i.get(n)??0)+(Number.isFinite(s)?s:0))}const s=t.year??a??(new Date).getUTCFullYear();let c=1/0,l=-1/0;for(const e of i.values())c>e&&(c=e),e>l&&(l=e);c===1/0&&(c=0,l=0);const[u,d]=t.colorRamp??[e.theme.semantic.surface??"#ebedf0",e.theme.semantic.primary??"#216e39"],h=e=>{if(l===c)return u;const t=(e-c)/(l-c);return(0,Ie.interpolateRgb)(u,d)(t)},f=t.gutter??2,m=t.labelInset??0,p=Math.min((n.width-m-53*f)/54,(n.height-6*f)/7);if(0>=p)return{nodes:[]};const g=new Date(Date.UTC(s,0,1)),y=g.getUTCDay(),x=new Date(g.getTime()-y*je),b=[];for(let e=0;54>e;e++)for(let t=0;7>t;t++){const o=new Date(x.getTime()+(7*e+t)*je);if(o.getUTCFullYear()!==s)continue;const r=Ne(o),a=i.get(r),c=null==a?u:h(a);b.push({type:"rect",x:n.x+m+e*(p+f),y:n.y+t*(p+f),w:p,h:p,style:{fill:c,stroke:"none"},datum:{date:o,value:a??0}})}return{nodes:b}};function Ne(e){return`${e.getUTCFullYear()}-${Fe(e.getUTCMonth()+1)}-${Fe(e.getUTCDate())}`}function Fe(e){return 10>e?"0"+e:e+""}var ze=c(require("react")),Le=(require("react/jsx-runtime"),{isActive:!1,predicate:()=>!0}),Ee=ze.createContext(null);function Te(){return ze.useContext(Ee)??Le}var Re=require("react/jsx-runtime"),Pe={resource:32,city:64},We=["#739b58","#83a964","#668d52","#8baa68"],Oe={land:"#78985c",ocean:"#4d8192",forest:"#4f7c4b",grassland:"#8eaa68",cropland:"#a6a568",wetland:"#668f79",urban:"#8d8a72",scrub:"#9b9665",bare:"#aa906a",snow:"#d8ddcf"},qe={land:"Open land",ocean:"Open ocean",forest:"Forest",grassland:"Grassland",cropland:"Cropland",wetland:"Wetland",urban:"Urban district",scrub:"Scrubland",bare:"Bare ground",snow:"Snow cover"},De=new Set(["city","culture","monument","faith","nature","knowledge","defense","arena","transport"]);function Be(e,t){if("function"==typeof e)return e;const n=e??t;return e=>e[n]}function Ye(e,t,n){return[111.32*(e-n.lon)*Math.cos((t+n.lat)/2*(Math.PI/180)),110.574*(t-n.lat)]}function Ge(e){const t=Math.max(3,Math.round(e??5));return t%2==0?t+1:t}function He(e){return De.has(e)?e:"monument"}function _e(e,t){const n=Ge(t.gridSize),o=Math.max(1,t.gridRadiusKm??75),r=2*o/n,i=Math.floor(n/2),a=Be(t.idAccessor,"id"),s=Be(t.nameAccessor,"name"),c=Be(t.longitudeAccessor,"lon"),l=Be(t.latitudeAccessor,"lat"),u=Be(t.kindAccessor,"kind"),d=t.candidatePriorityAccessor?Be(t.candidatePriorityAccessor,"priority"):()=>0,h=new Map;let f=null;for(const m of e){const e=Number(c(m)),p=Number(l(m));if(!Number.isFinite(e)||!Number.isFinite(p))continue;const g=(a(m)??`${e},${p}`)+"",y=(s(m)??g)+"",x=He(u(m)),[b,w]=Ye(e,p,t.center);if(Math.abs(b)>o||Math.abs(w)>o)continue;const M=Math.min(n-1,Math.max(0,Math.floor((b+o)/r))),v=Math.min(n-1,Math.max(0,Math.floor((o-w)/r))),k=(M+.5)*r-o,$=o-(v+.5)*r,A={...m,id:g,name:y,kind:x,lon:e,lat:p,distanceKm:Math.sqrt(b*b+w*w),row:v,column:M,cellDistanceSq:(b-k)**2+(w-$)**2,candidatePriority:Number(d(m))||0};(null!=t.centerId&&g===t.centerId||!f&&"city"===x||!f&&v===i&&M===i)&&(f=A);const S=`${v}:${M}`,I=h.get(S)??[];I.push(A),h.set(S,I)}const m=new Map;f&&m.set("city",1);const p=[];for(let e=0;n>e;e++)for(let t=0;n>t;t++){const n=`tile-${e}-${t}`,a=(t+.5)*r-o,s=o-(e+.5)*r;let c,l;if(e===i&&t===i&&f){c=f;const n=(h.get(`${e}:${t}`)??[]).filter(e=>e.id!==f?.id).sort((e,t)=>e.candidatePriority-t.candidatePriority||e.cellDistanceSq-t.cellDistanceSq||e.name.localeCompare(t.name));l=[f,...n]}else{const n=(h.get(`${e}:${t}`)??[]).filter(e=>e.id!==f?.id);n.sort((e,t)=>{const n=e.candidatePriority-t.candidatePriority;if(0!==n)return n;const o=m.get(e.kind)??0,i=m.get(t.kind)??0,a=r*r*.35;return e.cellDistanceSq+o*a-(t.cellDistanceSq+i*a)||e.name.localeCompare(t.name)}),c=n[0]??null,l=n}c&&m.set(c.kind,(m.get(c.kind)??0)+1),p.push({id:n,row:e,column:t,centerXKm:a,centerYKm:s,terrainIndex:Math.abs((17*e+31*t)%We.length),landmark:c,landmarks:l})}return p}var Ve=e=>{const t=Ge(e.config.gridSize),n=Math.max(20,e.config.tileWidth??80),o=Math.max(10,e.config.tileHeight??40),r=e.config.terrainColors?.length?e.config.terrainColors:We,i=e.dimensions.width/2,a=(e.dimensions.height-t*o)/2+o/2,s=_e(e.points,e.config).map(e=>({...e,x:i+n/2*(e.column-e.row),y:a+(e.column+e.row)*(o/2)}));return{nodes:s.map(t=>{const i=e.config.terrainByCell?.[t.id],a="string"==typeof i?{kind:i}:i,s="city"===t.landmark?.kind?"urban":a?.kind??"land",c=a?.fill??e.config.terrainPalette?.[s]??Oe[s],l=t.landmark?{...t.landmark,gridRow:t.row,gridColumn:t.column,cellId:t.id,terrainKind:s,terrainCoverage:a?.coverage,features:t.landmarks,featureCount:t.landmarks.length}:{id:t.id,name:qe[s],kind:"terrain",terrainKind:s,terrainCoverage:a?.coverage,gridRow:t.row,gridColumn:t.column,cellId:t.id,features:[],featureCount:0};return{type:"geoarea",pathData:(u=t.x,d=t.y,h=n,f=o,`M${u},${d-f/2}L${u+h/2},${d}L${u},${d+f/2}L${u-h/2},${d}Z`),centroid:[t.x,t.y],bounds:[[t.x-n/2,t.y-o/2],[t.x+n/2,t.y+o/2]],screenArea:n*o/2,style:{fill:a||"urban"===s?c:r[t.terrainIndex%r.length],stroke:"ocean"===s?"#315d6c":e.config.tileStroke??"#314934",strokeWidth:1},datum:l,group:t.landmark?.kind??s,interactive:!0};var u,d,h,f}),overlays:(0,Re.jsx)(Xe,{tiles:s,tileWidth:n,tileHeight:o,sprites:e.config.sprites,resourceSize:e.config.resourceSpriteSize??Pe.resource,citySize:e.config.citySpriteSize??Pe.city,showCityLabel:!1!==e.config.showCityLabel}),restyle:(e,t)=>t?.isActive&&e.datum&&"terrain"!==e.datum.kind?{fillOpacity:t.predicate(e.datum)?1:.28}:{fillOpacity:1}}};function Xe({tiles:e,tileWidth:t,tileHeight:n,sprites:o,resourceSize:r,citySize:i,showCityLabel:a}){const s=Te(),c=e.filter(e=>e.landmark).sort((e,t)=>e.y-t.y||e.x-t.x);return(0,Re.jsxs)("g",{"aria-hidden":"true",pointerEvents:"none",children:[c.map(e=>{const a=e.landmark,c="city"===a.kind?i:r,l=e.y+n/2,u=s.isActive&&!s.predicate(a)?.28:1;return(0,Re.jsxs)("g",{opacity:u,children:[(0,Re.jsx)("ellipse",{cx:e.x,cy:e.y+.15*n,rx:.28*c,ry:.1*c,fill:"#17251d",opacity:.32}),(0,Re.jsx)(Ze,{kind:a.kind,href:o?.[a.kind],x:e.x-c/2,y:l-c,size:c}),e.landmarks.length>1&&(0,Re.jsx)(Ue,{x:e.x+.3*t,y:e.y-.19*n,count:e.landmarks.length-1,tileHeight:n})]},a.id)}),a&&c.filter(e=>"city"===e.landmark?.kind).map(e=>{const t=e.landmark.name.toUpperCase(),o=Math.max(56,6.4*t.length+14);return(0,Re.jsxs)("g",{transform:`translate(${e.x},${e.y+.72*n})`,children:[(0,Re.jsx)("rect",{x:-o/2,y:-7,width:o,height:14,rx:1,fill:"#17251d",opacity:.92}),(0,Re.jsx)("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:9,fontWeight:700,letterSpacing:.8,children:t})]},e.landmark.id+"-label")})]})}function Ue({x:e,y:t,count:n,tileHeight:o}){const r=Math.max(10,Math.min(15,.34*o)),i="+"+n,a=Math.max(r,i.length*r*.58);return(0,Re.jsxs)("g",{transform:`translate(${e},${t})`,children:[(0,Re.jsx)("rect",{x:-a/2,y:-r/2,width:a,height:r,rx:1,fill:"#17251d",stroke:"#f0d36d",strokeWidth:1}),(0,Re.jsx)("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:Math.max(7,.62*r),fontWeight:700,children:i})]})}var Ke={city:["..1111..","..1221..",".111111.",".133331.","11111111","13311331","14411441","11111111"],culture:["..1111..",".122221.","11111111",".133331.",".133331.",".133331.","11111111",".444444."],monument:["...11...","..1221..","..1221..","..1331..",".113311.",".133331.","11111111",".444444."],faith:["...11...","...11...","..1111..","...11...","..1221..",".133331.","11111111",".444444."],nature:["...11...","..1221..",".122221.","12222221",".133331.","...11...","..1441..",".144441."],knowledge:[".111111.","12211221","12211221","13311331","13311331","13311331","11111111",".444444."],defense:["11.11.11","11111111","12222221","12211221","13311331","13333331","11111111",".444444."],arena:["..1111..",".122221.","12333321","12344321","12344321","12333321",".122221.","..1111.."],transport:["...11...","..1221..",".122221.","11111111","..1331..","..1331..",".114411.","11444411"]},Qe={city:{1:"#29364a",2:"#d8b45b",3:"#b7693c",4:"#6d9fc5"},culture:{1:"#29364a",2:"#d5c9a3",3:"#9c6fb2",4:"#ece3c4"},monument:{1:"#29364a",2:"#d8cba8",3:"#9c8f79",4:"#ece3c4"},faith:{1:"#29364a",2:"#d9c36d",3:"#a877a5",4:"#ece3c4"},nature:{1:"#29364a",2:"#4f8a4e",3:"#79aa56",4:"#79583a"},knowledge:{1:"#29364a",2:"#d5c9a3",3:"#4f7da0",4:"#ece3c4"},defense:{1:"#29364a",2:"#a6a298",3:"#777b7f",4:"#d5c9a3"},arena:{1:"#29364a",2:"#cb8056",3:"#d8cba8",4:"#6d9fc5"},transport:{1:"#29364a",2:"#d8b45b",3:"#6d9fc5",4:"#ece3c4"}};function Ze({kind:e,href:t,x:n,y:o,size:r}){if(t)return(0,Re.jsx)("image",{href:t,x:n,y:o,width:r,height:r,preserveAspectRatio:"xMidYMax meet",style:{imageRendering:"pixelated"}});const i=Qe[e];return(0,Re.jsx)("svg",{x:n,y:o,width:r,height:r,viewBox:"0 0 8 8",shapeRendering:"crispEdges",children:Ke[e].flatMap((e,t)=>[...e].map((e,n)=>"."===e?null:(0,Re.jsx)("rect",{x:n,y:t,width:1,height:1,fill:i[e]},`${t}-${n}`)))})}var Je=require("react/jsx-runtime"),et=.72,tt=1.8;function nt(e){if(Number.isFinite(e))return Math.max(1,Math.round(e))}function ot(e,t,n){return Math.max(t,Math.min(n,e))}function rt(e){let t=1/0,n=-1/0;for(const o of e)Number.isFinite(o)&&(t>o&&(t=o),o>n&&(n=o));return t===1/0?[0,0]:[t,n]}function it(e,t){const n=t[1]-t[0];return 0===n?.5:(e-t[0])/n}function at(e,t={}){const n=e.map((e,t)=>({...e,index:t})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));if(0===n.length)return[];const o=ot(Number.isFinite(t.occupancy)?Number(t.occupancy):et,.2,1),r=Number.isFinite(t.aspectRatio)&&Number(t.aspectRatio)>0?Number(t.aspectRatio):tt;let i=nt(t.columns)??Math.max(1,Math.ceil(Math.sqrt(n.length*r/o))),a=nt(t.rows)??Math.max(1,Math.ceil(n.length/(i*o)));n.length>i*a&&(null!=t.columns&&null==t.rows?a=Math.ceil(n.length/i):null!=t.rows&&null==t.columns?i=Math.ceil(n.length/a):a=Math.ceil(n.length/i));const s=rt(n.map(e=>e.x)),c=rt(n.map(e=>e.y)),l=n.map(e=>({...e,desiredColumn:it(e.x,s)*Math.max(0,i-1),desiredRow:it(e.y,c)*Math.max(0,a-1)})),u=(i-1)/2,d=(a-1)/2;l.sort((e,t)=>(t.desiredColumn-u)**2+(t.desiredRow-d)**2-((e.desiredColumn-u)**2+(e.desiredRow-d)**2)||e.desiredRow-t.desiredRow||e.desiredColumn-t.desiredColumn||e.index-t.index);const h=new Set;for(let e=0;a>e;e+=1)for(let t=0;i>t;t+=1)h.add(e*i+t);const f=[];for(const e of l){let t=-1,n=1/0;for(const o of h){const r=(o%i-e.desiredColumn)**2+(Math.floor(o/i)-e.desiredRow)**2;(n>r||r===n&&t>o)&&(t=o,n=r)}0>t||(h.delete(t),f.push({datum:e.datum,x:e.x,y:e.y,row:Math.floor(t/i),column:t%i,index:e.index}))}return f.sort((e,t)=>e.index-t.index),f.map(({index:e,...t})=>t)}function st(e,t,n=[]){if("function"==typeof t)return t(e);if("string"==typeof t)return e[t];for(const t of n)if(null!=e[t])return e[t]}function ct(e){return e.map(([e,t],n)=>`${0===n?"M":"L"}${e},${t}`).join("")+"Z"}var lt=e=>{const t=e.config,n=t.source??"auto",o="areas"===n||"auto"===n&&e.areas.length>0,r=o?function(e){return e.areas.map((t,n)=>{const o=function(e,t){const n=e.properties&&"object"==typeof e.properties?e.properties:{},o=e.id??n.id??n.name??"area-"+t;return{...n,id:o+""}}(t,n),r=e.scales.geoPath.centroid(t),i=Number.isFinite(r[0])&&Number.isFinite(r[1])?e.scales.invertedPoint(r[0],r[1]):null;return{datum:{...o,gridLongitude:i?.[0],gridLatitude:i?.[1]},x:r[0],y:r[1]}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}(e):e.points.map((e,t)=>({datum:e,x:t,y:t})),i=r.filter((e,n)=>!t.filter||t.filter(e.datum,n)),a=function(e,t){if(!t.rowAccessor||!t.columnAccessor)return null;const n=e.map(e=>({datum:e,x:Number(st(e,t.columnAccessor)),y:Number(st(e,t.rowAccessor))})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));return n.length!==e.length?null:n.map(e=>({...e,row:e.y,column:e.x}))}(i.map(e=>e.datum),t),s=o?i:function(e){return e.points.map(t=>{const n=Number(st(t,e.config.longitudeAccessor,["lon","longitude"])),o=Number(st(t,e.config.latitudeAccessor,["lat","latitude"])),r=Number.isFinite(n)&&Number.isFinite(o)?e.scales.projectedPoint(n,o):null;return{datum:t,x:r?.[0]??NaN,y:r?.[1]??NaN}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}({...e,points:i.map(e=>e.datum)}),c=a??at(s,{columns:t.columns,rows:t.rows,occupancy:t.occupancy,aspectRatio:e.dimensions.width/Math.max(1,e.dimensions.height)});if(0===c.length)return{nodes:[]};const l=rt(c.map(e=>e.row)),u=rt(c.map(e=>e.column)),d=Math.max(1,Math.round(l[1]-l[0])+1),h=Math.max(1,Math.round(u[1]-u[0])+1),f=Math.max(0,t.layoutPadding??8),m=Math.max(1,e.dimensions.width-2*f)/h,p=Math.max(1,e.dimensions.height-2*f)/d,g=(e.dimensions.width-m*h)/2,y=(e.dimensions.height-p*d)/2,x=ot(t.cellPadding??.12,0,.8),b=Math.max(1,.5*Math.min(m,p)*(1-x)),w=t.sizeAccessor?c.map(e=>Number(st(e.datum,t.sizeAccessor))):[],M=t.sizeDomain??rt(w),v=t.sizeRange??[.36,1],k=ot(Math.min(v[0],v[1]),.05,1),$=ot(Math.max(v[0],v[1]),k,1),A=c.map((n,o)=>{const r={...n.datum,gridRow:n.row,gridColumn:n.column},i=(st(r,t.idAccessor,["id","key","name"])??"grid-"+o)+"",a=(st(r,t.labelAccessor,["abbr","code","label","name","id"])??i)+"",s=Math.max(1,t.maxLabelLength??4),c=a.length>s?a.slice(0,s):a,d=st(r,t.categoryAccessor),h=null==d?void 0:d+"",f=st(r,t.fillAccessor),x=null!=f?f+"":h?e.resolveColor(h):e.theme.categorical[0]??"#4f86c6",w=t.sizeAccessor?Number(st(r,t.sizeAccessor)):NaN,v=t.sizeAccessor&&Number.isFinite(w)?Math.sqrt(ot(it(w,M),0,1)):1,A=b*(k+v*($-k)),S="function"==typeof t.markStyle?t.markStyle(r,o):t.markStyle;return{datum:r,id:i,label:c,category:h,row:n.row,column:n.column,x:g+(n.column-u[0]+.5)*m,y:y+(n.row-l[0]+.5)*p,radius:A,style:{fill:x,fillOpacity:.94,stroke:"rgba(255,255,255,0.9)",strokeWidth:1,...S}}}),S=t.shape??"circle";return{nodes:A.map(e=>{return"circle"===S?{type:"point",x:e.x,y:e.y,r:e.radius,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},pointId:e.id,_transitionKey:e.id}:{type:"geoarea",pathData:"hexagon"===S?function(e,t,n){const o=[];for(let r=0;6>r;r+=1){const i=-Math.PI/2+r*(Math.PI/3);o.push([e+Math.cos(i)*n,t+Math.sin(i)*n])}return ct(o)}(e.x,e.y,e.radius):ct([[(t=e.x)-(o=e.radius),(n=e.y)-o],[t+o,n-o],[t+o,n+o],[t-o,n+o]]),centroid:[e.x,e.y],bounds:[[e.x-e.radius,e.y-e.radius],[e.x+e.radius,e.y+e.radius]],screenArea:"hexagon"===S?3*Math.sqrt(3)*e.radius*e.radius/2:(2*e.radius)**2,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},group:e.category,interactive:!0};var t,n,o}),overlays:!1===t.showLabels?null:(0,Je.jsx)(ut,{marks:A,color:t.labelColor??"#ffffff",fontSize:t.labelFontSize??ot(.23*Math.min(m,p),7,14),fontFamily:t.labelFontFamily,fontWeight:t.labelFontWeight??700}),restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.18}:{opacity:1}}};function ut({marks:e,color:t,fontSize:n,fontFamily:o,fontWeight:r}){const i=Te();return(0,Je.jsx)("g",{"aria-hidden":"true",pointerEvents:"none",children:e.map(e=>{const a=!i.isActive||i.predicate(e.datum);return(0,Je.jsx)("text",{x:e.x,y:e.y,fill:t,fontFamily:o,fontSize:n,fontWeight:r,opacity:a?1:.18,textAnchor:"middle",dominantBaseline:"central",children:e.label},e.id)})})}var dt=require("d3-geo"),ht=require("react/jsx-runtime"),ft=10,mt=25e3,pt=new WeakMap,gt=new WeakMap,yt=new WeakMap,xt=1;function bt(e,t,n){return Math.max(t,Math.min(n,e))}function wt(e){if(Number.isFinite(e)&&Number(e)>0)return Number(e)}function Mt(e,t){return"function"==typeof t?t(e,e.dotIndex):"string"==typeof t?e[t]:void 0}function vt(e){return e.properties&&"object"==typeof e.properties?{...e.properties}:{}}function kt(e,t){const n=vt(e);return(e.id??n.id??n.name??"feature-"+t)+""}function $t(e,t,n,o){return[Math.ceil((e-n)/o-.5),Math.floor((t-n)/o-.5)]}function At(e){if(!e)return 0;const t=yt.get(e);if(t)return t;const n=xt;return xt+=1,yt.set(e,n),n}function St(e,t){return!t||!(t[0][1]>e[1]||e[1]>t[1][1]||(n=e[0],o=t[0][0],r=t[1][0],o>r?o>n&&n>r:o>n||n>r));var n,o,r}function It(e,t){for(const n of e){const{feature:e,index:o}=n;if(e.geometry&&St(t,n.bounds))try{if((0,dt.geoContains)(e,t))return{feature:e,index:o}}catch{}}return null}function jt(e,t,n,o={}){const r=e.filter((e,t)=>e.geometry&&(!o.featureFilter||o.featureFilter(e,t))),i=function(e,t){if(0===e.length)return null;const n=t.bounds({type:"FeatureCollection",features:e});return Number.isFinite(n[0][0])&&Number.isFinite(n[0][1])&&Number.isFinite(n[1][0])&&Number.isFinite(n[1][1])?n:null}(r,t.geoPath);if(!i)return{dots:[],cellSize:ft,features:r};const a=Math.max(0,o.layoutPadding??0),s=[[bt(i[0][0],a,Math.max(a,n.width-a)),bt(i[0][1],a,Math.max(a,n.height-a))],[bt(i[1][0],a,Math.max(a,n.width-a)),bt(i[1][1],a,Math.max(a,n.height-a))]],c=Math.max(0,s[1][0]-s[0][0]),l=Math.max(0,s[1][1]-s[0][1]);if(0===c||0===l)return{dots:[],cellSize:ft,features:r};const u=wt(o.columns);let d=Math.max(2,u?c/u:wt(o.cellSize)??ft);const h=Math.max(100,Math.round(wt(o.maxSamples)??mt)),f=Math.ceil(c/d)*Math.ceil(l/d);f>h&&(d*=Math.sqrt(f/h));const m=o.gridOrigin?.[0]??0,p=o.gridOrigin?.[1]??0,[g,y]=$t(s[0][0],s[1][0],m,d),[x,b]=$t(s[0][1],s[1][1],p,d),w=[],M=function(e){return e.map((e,t)=>{if(gt.has(e))return{feature:e,index:t,bounds:gt.get(e)??null};try{const n=(0,dt.geoBounds)(e);return gt.set(e,n),{feature:e,index:t,bounds:n}}catch{return gt.set(e,null),{feature:e,index:t,bounds:null}}})}(r);for(let e=x;b>=e;e+=1){const n=p+(e+.5)*d;for(let r=g;y>=r;r+=1){const i=t.invertedPoint(m+(r+.5)*d,n);if(!i||!Number.isFinite(i[0])||!Number.isFinite(i[1]))continue;const a=It(M,i);if(!a)continue;const s={...vt(a.feature),featureId:kt(a.feature,a.index),featureIndex:a.index,gridRow:e,gridColumn:r,longitude:i[0],latitude:i[1],dotIndex:w.length};o.dotFilter&&!o.dotFilter(s,w.length)||w.push(s)}}return{dots:w,cellSize:d,features:r}}function Ct(e){return Math.round(1e4*e)/1e4}function Nt(e){return Array.isArray(e)&&e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1])?`${Ct(Number(e[0]))},${Ct(Number(e[1]))}`:"null"}function Ft(e,t){const n=e[t];return"function"==typeof n?n.call(e):void 0}function zt(e){return"number"==typeof e&&Number.isFinite(e)?Ct(e)+"":null===e?"null":"unavailable"}function Lt(e){const t=e.scales.projection;return[zt(Ft(t,"scale")),Nt(Ft(t,"translate")),Nt(Ft(t,"center")),(n=Ft(t,"rotate"),Array.isArray(n)&&n.every(Number.isFinite)?n.map(e=>Ct(Number(e))).join(","):"unavailable"),zt(Ft(t,"clipAngle")),zt(Ft(t,"precision")),...[[0,0],[-120,35],[45,45],[120,-30]].map(([t,n])=>Nt(e.scales.projectedPoint(t,n)))].join("|");var n}function Et(e){return e.map(([e,t],n)=>`${0===n?"M":"L"}${e},${t}`).join("")+"Z"}var Tt=e=>{const t=function(e){let t=pt.get(e.areas);t||(t=new Map,pt.set(e.areas,t));const n=function(e){const t=e.config;return[e.areas.length,e.dimensions.width,e.dimensions.height,t.cellSize??"",t.columns??"",t.layoutPadding??"",t.gridOrigin?.join(",")??"",t.maxSamples??"",At(t.featureFilter),At(t.dotFilter),Lt(e)].join("::")}(e),o=t.get(n);if(o)return o;const r=jt(e.areas,e.scales,e.dimensions,e.config);if(t.size>=12){const e=t.keys().next().value;void 0!==e&&t.delete(e)}return t.set(n,r),r}(e),n=e.config,o=n.shape??"circle",r=Math.max(.5,wt(n.dotRadius)??t.cellSize*bt(n.radiusRatio??.24,.05,.5)),i=n.gridOrigin?.[0]??0,a=n.gridOrigin?.[1]??0;return{nodes:t.dots.map((s,c)=>{const l=i+(s.gridColumn+.5)*t.cellSize,u=a+(s.gridRow+.5)*t.cellSize,d=Mt(s,n.categoryAccessor),h=Mt(s,n.fillAccessor),f={fill:null!=h?h+"":null!=d?e.resolveColor(d+""):e.theme.categorical[0]??"#4f86c6",fillOpacity:.92,strokeWidth:0,..."function"==typeof n.markStyle?n.markStyle(s,c):n.markStyle},m=`dot-${s.gridRow}-${s.gridColumn}`;if("circle"===o)return{type:"point",x:l,y:u,r:r,style:f,datum:s,interactive:!1,pointId:m,_transitionKey:m};const p="hexagon"===o?function(e,t,n){return Et(Array.from({length:6},(o,r)=>{const i=-Math.PI/2+r*(Math.PI/3);return[e+Math.cos(i)*n,t+Math.sin(i)*n]}))}(l,u,r):function(e,t,n){return Et([[e-n,t-n],[e+n,t-n],[e+n,t+n],[e-n,t+n]])}(l,u,r);return{type:"geoarea",pathData:p,centroid:[l,u],bounds:[[l-r,u-r],[l+r,u+r]],screenArea:"hexagon"===o?3*Math.sqrt(3)*r*r/2:(2*r)**2,style:f,datum:s,group:s.featureId,interactive:!1}}),overlays:n.showOutline?(0,ht.jsx)("g",{"aria-hidden":"true",pointerEvents:"none",children:t.features.map((t,o)=>{const r=e.scales.geoPath(t);return r?(0,ht.jsx)("path",{d:r,fill:"none",stroke:n.outlineStyle?.stroke??"currentColor",strokeOpacity:n.outlineStyle?.opacity??n.outlineStyle?.fillOpacity??.22,strokeWidth:n.outlineStyle?.strokeWidth??.7,strokeDasharray:n.outlineStyle?.strokeDasharray,strokeLinecap:n.outlineStyle?.strokeLinecap,vectorEffect:"non-scaling-stroke"},kt(t,o)):null})}):null,restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.14}:{opacity:1}}},Rt=e=>{const t=e.config,n=t.nodeWidth??80,o=t.nodeHeight??30,r=t.orientation??"vertical",i=t.edgeCurve??"curved",a=!1!==t.showLabels,s=t.labelAccessor??"id",c="function"==typeof s?s:e=>h(e,s,e.id??"")+"",l=new Map,u=[],d=[],f=e=>{const t=e.data??{};return{x:"number"==typeof t.x?t.x:e.x,y:"number"==typeof t.y?t.y:e.y,w:("number"==typeof t.width?t.width:e.width)??n,h:("number"==typeof t.height?t.height:e.height)??o}};for(const n of e.nodes){const{x:o,y:r,w:i,h:s}=f(n);null!=o&&null!=r&&(l.set(n.id,{x:o,y:r,w:i,h:s}),u.push({type:"rect",x:o-i/2,y:r-s/2,w:i,h:s,style:{fill:t.nodeFill??e.resolveColor(n.id),stroke:`var(--semiotic-surface, ${e.theme.semantic.surface??"#fff"})`,strokeWidth:1.5},datum:n,id:n.id,label:c(n)+""}),a&&d.push({x:o,y:r,text:c(n)+"",anchor:"middle",baseline:"middle",fontSize:11}))}const m=[];for(const t of e.edges){const n="string"==typeof t.target?t.target:t.target.id,o=l.get("string"==typeof t.source?t.source:t.source.id),a=l.get(n);if(!o||!a)continue;const s="vertical"===r?{x:o.x,y:o.y+o.h/2}:{x:o.x+o.w/2,y:o.y},c="vertical"===r?{x:a.x,y:a.y-a.h/2}:{x:a.x-a.w/2,y:a.y};if("line"===i)m.push({type:"line",x1:s.x,y1:s.y,x2:c.x,y2:c.y,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1},datum:t});else{const n=(s.y+c.y)/2,o=(s.x+c.x)/2;m.push({type:"curved",pathD:"vertical"===r?`M${s.x},${s.y} C${s.x},${n} ${c.x},${n} ${c.x},${c.y}`:`M${s.x},${s.y} C${o},${s.y} ${o},${c.y} ${c.x},${c.y}`,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1,fill:"none"},datum:t})}}return{sceneNodes:u,sceneEdges:m,labels:d}},Pt=e=>{const t=e.config,n=t.nodeWidth??100,o=t.nodeHeight??36,r=t.edgeStyle??"polyline",i=!1!==t.showLabels,a=t.labelAccessor??"label",s="function"==typeof a?a:e=>h(e,a,e.id??"")+"",c=new Map,l=[],u=[],d=e=>{const t=e.data??{};return{x:"number"==typeof t.x?t.x:e.x,y:"number"==typeof t.y?t.y:e.y,w:("number"==typeof t.width?t.width:e.width)??n,h:("number"==typeof t.height?t.height:e.height)??o}};for(const n of e.nodes){const{x:o,y:r,w:a,h:h}=d(n);null!=o&&null!=r&&(c.set(n.id,{x:o,y:r,w:a,h:h}),l.push({type:"rect",x:o-a/2,y:r-h/2,w:a,h:h,style:{fill:t.nodeFill??e.resolveColor(n.id),stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#888"})`,strokeWidth:1.5},datum:n,id:n.id,label:s(n)+""}),i&&u.push({x:o,y:r,text:s(n)+"",anchor:"middle",baseline:"middle",fontSize:11}))}const f=t.edgeStroke??`var(--semiotic-border, ${e.theme.semantic.border??"#666"})`,m=[];for(const t of e.edges){const e="string"==typeof t.target?t.target:t.target.id,n=c.get("string"==typeof t.source?t.source:t.source.id),o=c.get(e);if(!n||!o)continue;const i=t.data??{},a=Array.isArray(i.points)?i.points:t.points;if(a&&a.length>=2)if("smooth"!==r||3>a.length){const e="M"+a.map(e=>`${e.x},${e.y}`).join(" L ");m.push({type:"curved",pathD:e,style:{stroke:f,strokeWidth:1,fill:"none"},datum:t})}else{let e=`M${a[0].x},${a[0].y}`;for(let t=1;a.length-1>t;t++)e+=` Q${a[t].x},${a[t].y} ${(a[t].x+a[t+1].x)/2},${(a[t].y+a[t+1].y)/2}`;const n=a[a.length-1];e+=` T${n.x},${n.y}`,m.push({type:"curved",pathD:e,style:{stroke:f,strokeWidth:1,fill:"none"},datum:t})}else m.push({type:"line",x1:n.x,y1:n.y,x2:o.x,y2:o.y,style:{stroke:f,strokeWidth:1},datum:t})}return{sceneNodes:l,sceneEdges:m,labels:u}},Wt=require("react/jsx-runtime"),Ot={"topic-source":"#1f7a8c","topic-sink":"#b4451f","topic-bridge":"#4b5a82",processor:"#34344a",unknown:"#5a5a6a"},qt={internal:"var(--semiotic-border, #6b6b7d)","cross-subtopology":"var(--semiotic-info, #6a8caf)","topic-bridge":"var(--semiotic-secondary, #8b78c4)",back:"var(--semiotic-danger, #e0556b)"};function Dt(e){return Array.isArray(e)?e.map((e,t)=>"string"==typeof e?{storeName:e,slotIndex:t}:{storeName:(e.storeName??"")+"",slotIndex:e.slotIndex??t}):[]}var Bt=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.layerAccessor??"x",r=t.rowAccessor??"y",i=t.partitionAccessor??"partition",a=t.semanticAccessor??"semantic",s=t.labelAccessor??"label",c=t.storesAccessor??"stores",l=t.backEdgeAccessor??"isBackEdge",u=t.edgeTypeAccessor??"edgeType",d={...Ot,...t.partitionColors},f={...qt,...t.edgeColors},m=t.accentColor??"var(--semiotic-focus, #ffcc33)",p=t.borderColor??"var(--semiotic-border, #555)",g=t.dimOpacity??.14,y=t.edgeOpacity??.5,x=t.edgeWidth??1.25,b=t.backEdgeWidth??t.edgeWidth??1.5,w=!1!==t.showStoreChips,M=t.storeChipColor??"var(--semiotic-info, #6a8caf)";let v=t.layerCount,k=t.maxLayerSize;if(null==v||null==k){let t=0;const n=new Map;for(const r of e.nodes){const e=Math.round(Number(h(r,o,0)));t=Math.max(t,e),n.set(e,(n.get(e)??0)+1)}v=v??t+1,k=k??Math.max(1,...n.values())}const $=n.width/Math.max(1,v),A=n.height/Math.max(1,k);let S=Math.min(t.nodeWidth??172,Math.max(8,$-(t.minGapX??26))),I=Math.min(t.nodeHeight??54,Math.max(8,A-(t.minGapY??18)));const j=t.lod&&"auto"!==t.lod?t.lod:16>S?"dot":48>S?"icon":108>S?"compact":"full";if("dot"===j){const e=Math.min(S,I,11);S=e,I=e}const C=Math.max(1,n.width-S),N=Math.max(1,n.height-I),F=Math.max(1,k-1),z=e=>n.x+S/2+(v>1?e/(v-1):.5)*C,L=e=>n.y+I/2+(e+F/2)/F*N,E=t.reachableIds?new Set(t.reachableIds):null,T=t.selectedId??null,R=e.selection,P=new Map,W=new Map,O=[],q=[];for(const t of e.nodes){const e=t.id,n=Number(h(t,o,0)),l=Number(h(t,r,0)),u=h(t,i,"processor")+"",f=h(t,a,"processor")+"",y=h(t,s,e)+"",x=Dt(h(t,c,[])),b=t.data??t,w=z(n),M=L(l);P.set(e,{cx:w,cy:M});const v=E?E.has(e):null,k=R?.isActive?R.predicate(b):null,$=null!==v?!v:null!==k&&!k;W.set(e,$);const A=null!=T&&e===T,C=$&&!A?g:1,N=d[u]??d.unknown;"dot"===j?O.push({type:"circle",cx:w,cy:M,r:S/2,style:{fill:N,opacity:C,stroke:A?m:"transparent",strokeWidth:A?2:0},datum:t,id:e,label:y}):(O.push({type:"rect",x:w-S/2,y:M-I/2,w:S,h:I,style:{fill:N,opacity:C,stroke:A?m:p,strokeWidth:A?3:1},datum:t,id:e,label:y}),q.push({id:e,cx:w,cy:M,partition:u,semantic:f,label:y,stores:x,opacity:C,selected:A,node:b}))}const D=[];for(const t of e.edges){const e="string"==typeof t.source?t.source:t.source.id,n="string"==typeof t.target?t.target:t.target.id,o=P.get(e),r=P.get(n);if(!o||!r)continue;const i=!!h(t,l,!1),a=h(t,u,"internal")+"",s=W.get(e)||W.get(n)?Math.min(y,1.4*g):y,c=i?f.back:f[a]??f.internal;let d;if(i){const e=o.cx,t=o.cy+I/2,n=r.cx,i=r.cy+I/2,a=Math.max(48,.28*Math.abs(e-n))+I;d=`M${e},${t} C${e},${t+a} ${n},${i+a} ${n},${i}`}else{const e=o.cx+S/2,t=o.cy,n=r.cx-S/2,i=r.cy,a=(e+n)/2;d=`M${e},${t} C${a},${t} ${a},${i} ${n},${i}`}const m={type:"curved",pathD:d,style:{stroke:c,strokeWidth:i?b:x,fill:"none",opacity:s,...i?{strokeDasharray:"5 4",strokeLinecap:"round"}:{}},datum:t};D.push(m)}const B=0===q.length?null:(0,Wt.jsx)("g",{className:"lineage-dag-glyphs",children:q.map(e=>function(e,t){const{w:n,h:o,lod:r}=t,i="icon"===r?Math.min(n,o):Math.min(o-14,26),a="icon"===r?0:8+i+8,s=null!=t.renderIcon?t.renderIcon({semantic:e.semantic,partition:e.partition,size:i,color:t.partColors[e.partition]??t.partColors.unknown??"#5a5a6a",node:e.node}):function(e,t,n){const o=t.startsWith("topic")?"T":{source:"SR",sink:"SK",filter:"FL",map:"MP",aggregate:"AG",reduce:"RD","join-this":"JN","join-other":"JN",merge:"MG",suppress:"SP",select:"SE",tostream:"TS"}[e]??"PR";return(0,Wt.jsxs)("g",{children:[(0,Wt.jsx)("rect",{width:n,height:n,rx:4,fill:"rgba(255,255,255,0.08)",stroke:"rgba(255,255,255,0.18)"}),(0,Wt.jsx)("text",{x:n/2,y:n/2+.5,textAnchor:"middle",dominantBaseline:"middle",fontSize:.42*n,fontWeight:700,fill:"var(--semiotic-text, #fff)",children:o})]})}(e.semantic,e.partition,i),c="full"===r,l="icon"!==r,u="full"===r&&t.showChips&&e.stores.length>0;return(0,Wt.jsxs)("g",{transform:`translate(${e.cx-n/2}, ${e.cy-o/2})`,opacity:e.opacity,style:{pointerEvents:"none"},children:[(0,Wt.jsx)("g",{transform:`translate(${"icon"===r?(n-i)/2:8}, ${(o-i)/2})`,children:s}),l&&(0,Wt.jsx)("foreignObject",{x:a,y:c?o/2-12:o/2-9,width:Math.max(8,n-a-8),height:18,style:{pointerEvents:"none"},children:(0,Wt.jsx)("div",{title:e.label,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, inherit)",fontSize:"full"===r?12.5:11.5,fontWeight:600,color:"var(--semiotic-text, #f4f4f8)",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.label})}),c&&(0,Wt.jsx)("text",{x:a,y:o/2-16,dominantBaseline:"middle",fontSize:9.5,fontWeight:500,fill:"var(--semiotic-text-secondary, #b9b9c8)",style:{textTransform:"uppercase",letterSpacing:"0.04em"},children:t.typeLabel?t.typeLabel({semantic:e.semantic,partition:e.partition,node:e.node}):e.partition.startsWith("topic")?"topic":e.semantic}),u&&e.stores.map((e,n)=>(0,Wt.jsx)("rect",{x:a+15*n,y:o-10,width:12,height:5,rx:1.5,fill:t.chipColor,children:(0,Wt.jsx)("title",{children:e.storeName})},e.storeName+n))]},e.id)}(e,{w:S,h:I,lod:j,partColors:d,chipColor:M,showChips:w,renderIcon:t.renderIcon,typeLabel:t.typeLabel}))});return{sceneNodes:O,sceneEdges:D,overlays:B}},Yt=require("react/jsx-runtime");function Gt(e,t){return e.length>t?e.slice(0,Math.max(1,t-1))+"…":e}var Ht={rect:"process",round:"process",stadium:"terminal",subroutine:"subprocess",cylinder:"database",circle:"connector",diamond:"decision",hexagon:"preparation",flag:"process"};function _t(e,t,n,o,r,i,a,s){const c=t-o/2,l=n-r/2,u={fill:i,stroke:a,strokeWidth:s};switch(e){case"diamond":return(0,Yt.jsx)("polygon",{points:`${t},${l} ${t+o/2},${n} ${t},${n+r/2} ${c},${n}`,...u});case"circle":return(0,Yt.jsx)("circle",{cx:t,cy:n,r:Math.min(o,r)/2,...u});case"stadium":case"round":return(0,Yt.jsx)("rect",{x:c,y:l,width:o,height:r,rx:"stadium"===e?r/2:8,ry:"stadium"===e?r/2:8,...u});case"hexagon":{const e=Math.min(.18*o,16);return(0,Yt.jsx)("polygon",{points:`${c+e},${l} ${t+o/2-e},${l} ${t+o/2},${n} ${t+o/2-e},${n+r/2} ${c+e},${n+r/2} ${c},${n}`,...u})}case"cylinder":{const e=Math.min(.16*r,8),t=`M${c},${l+e} a${o/2},${e} 0 0 1 ${o},0`;return(0,Yt.jsxs)("g",{children:[(0,Yt.jsx)("path",{d:`M${c},${l+e} a${o/2},${e} 0 0 0 ${o},0 v${r-2*e} a${o/2},${e} 0 0 1 ${-o},0 z`,...u}),(0,Yt.jsx)("path",{d:t,fill:"none",stroke:a,strokeWidth:s})]})}case"subroutine":{const e=Math.min(8,.08*o);return(0,Yt.jsxs)("g",{children:[(0,Yt.jsx)("rect",{x:c,y:l,width:o,height:r,rx:3,...u}),(0,Yt.jsx)("line",{x1:c+e,y1:l,x2:c+e,y2:l+r,stroke:a,strokeWidth:s}),(0,Yt.jsx)("line",{x1:c+o-e,y1:l,x2:c+o-e,y2:l+r,stroke:a,strokeWidth:s})]})}default:return(0,Yt.jsx)("rect",{x:c,y:l,width:o,height:r,rx:4,...u})}}var Vt=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.direction??"TD",r="LR"===o||"RL"===o,i="BT"===o||"RL"===o,a=t.layerAccessor??"layer",s=t.rowAccessor??"row",c=t.labelAccessor??"label",l=t.shapeAccessor??"shape",u=t.edgeLabelAccessor??"label",d=t.nodeFill??"var(--semiotic-surface, #20242d)",f=t.nodeStroke??"var(--semiotic-border, #5a6573)",m=t.textColor??"var(--semiotic-text, #e6e6e6)",p=t.edgeColor??"var(--semiotic-text-secondary, #9aa0a6)",g=t.accentColor??"var(--semiotic-warning, #d49a00)";if(0===e.nodes.length)return{sceneNodes:[],overlays:null};const y=new Map;let x=0;for(const t of e.nodes){const e=Math.round(Number(h(t,a,0)));x=Math.max(x,e);const n=y.get(e)||[];n.push(t),y.set(e,n)}const b=x+1;let w=1;for(const e of y.values())e.sort((e,t)=>Number(h(e,s,0))-Number(h(t,s,0))),w=Math.max(w,e.length);const M=r?n.width:n.height,v=r?n.height:n.width,k=M/b,$=v/(w+1),A=Math.max(44,Math.min(t.nodeWidth??150,r?k-36:.92*$)),S=Math.max(26,Math.min(t.nodeHeight??46,r?.7*$:.5*k)),I=(r?A:S)/2+6,j=Math.max(1,M-2*I),C=e=>(r?n.x:n.y)+I+(b>1?(i?b-1-e:e)/(b-1)*j:j/2),N=new Map,F=[],z=[];for(const[e,t]of y)t.forEach((o,i)=>{const a=C(e),s=(r?n.y:n.x)+(i+1)/(t.length+1)*v,u=r?a:s,p=r?s:a,y=h(o,l,"rect")+"",x=h(o,c,o.id)+"";N.set(o.id,{cx:u,cy:p,shape:y}),F.push({type:"rect",x:u-A/2,y:p-S/2,w:A,h:S,style:{fill:"transparent",stroke:"transparent"},datum:{id:o.id,name:x,type:Ht[y]??"process",shape:y},id:o.id,label:x}),z.push((0,Yt.jsxs)("g",{children:[_t(y,u,p,A,S,d,"diamond"===y?g:f,1.5),(0,Yt.jsx)("text",{x:u,y:p,textAnchor:"middle",dominantBaseline:"central",fontSize:13,fill:m,style:{pointerEvents:"none"},children:Gt(x,Math.max(4,Math.floor((A-12)/7)))})]},"n-"+o.id))});const L=[];return e.edges.forEach((e,t)=>{const n="string"==typeof e.target?e.target:e.target.id,o=N.get("string"==typeof e.source?e.source:e.source.id),i=N.get(n);if(!o||!i)return;const a=r?o.cx+A/2:o.cx,s=r?o.cy:o.cy+S/2,c=r?i.cx-A/2:i.cx,l=r?i.cy:i.cy-S/2,d=r?`M${a},${s} C${(a+c)/2},${s} ${(a+c)/2},${l} ${c},${l}`:`M${a},${s} C${a},${(s+l)/2} ${c},${(s+l)/2} ${c},${l}`,g=Math.atan2(l-s,c-a),y=c-9*Math.cos(g),x=l-9*Math.sin(g),b=4.5*-Math.sin(g),w=4.5*Math.cos(g),M=`${c},${l} ${y+b},${x+w} ${y-b},${x-w}`,v=h(e,u,void 0),k=(a+c)/2,$=(s+l)/2;L.push((0,Yt.jsxs)("g",{children:[(0,Yt.jsx)("path",{d:d,fill:"none",stroke:p,strokeWidth:1.4}),(0,Yt.jsx)("polygon",{points:M,fill:p}),"string"==typeof v&&v.length>0&&(0,Yt.jsxs)("g",{children:[(0,Yt.jsx)("rect",{x:k-6.5*v.length/2-4,y:$-9,width:6.5*v.length+8,height:18,rx:3,fill:"var(--semiotic-bg, #11151c)",stroke:f,strokeWidth:.75}),(0,Yt.jsx)("text",{x:k,y:$,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fill:m,style:{pointerEvents:"none"},children:v})]})]},"e-"+t))}),{sceneNodes:F,overlays:(0,Yt.jsxs)("g",{className:"mermaid-dag",children:[L,z]})}},Xt=require("react/jsx-runtime");function Ut(e){return(0,Xt.jsx)("rect",{className:e.className,x:e.x,y:e.y,width:Math.max(0,e.width),height:Math.max(0,e.height),rx:e.radius??10,ry:e.radius??10,fill:e.fill??"none",stroke:e.stroke,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray,opacity:e.opacity??.6,style:{pointerEvents:"none"}},e.keyId)}function Kt(e,t=0){let n=1/0,o=1/0,r=-1/0,i=-1/0;for(const t of e){const e=t.r??0;n>t.x-e&&(n=t.x-e),t.x+e>r&&(r=t.x+e),o>t.y-e&&(o=t.y-e),t.y+e>i&&(i=t.y+e)}return Number.isFinite(n)?{x:n-t,y:o-t,width:r-n+2*t,height:i-o+2*t}:null}function Qt(e,t=0){if(!e.length)return null;const n="number"==typeof t?t:t.x??0,o="number"==typeof t?t:t.y??0;let r=1/0,i=1/0,a=-1/0,s=-1/0;for(const t of e){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))continue;if(!Number.isFinite(t.width)||!Number.isFinite(t.height))continue;const e=Math.max(0,t.width),n=Math.max(0,t.height);r>t.x&&(r=t.x),i>t.y&&(i=t.y),t.x+e>a&&(a=t.x+e),t.y+n>s&&(s=t.y+n)}return Number.isFinite(r)?{x:r-n,y:i-o,width:a-r+2*n,height:s-i+2*o}:null}function Zt(e){const t=e.fontSize??12;return null!=e.maxWidth&&e.text.length*t*.56>e.maxWidth?null:(0,Xt.jsx)("text",{className:e.className,x:e.x,y:e.y,textAnchor:e.anchor??"middle",dominantBaseline:e.baseline??"middle",fontSize:t,fontWeight:e.fontWeight,fill:e.color,style:{pointerEvents:"none"},children:e.text},e.keyId)}function Jt(e){const t=e.spacing??8;return{def:(0,Xt.jsx)("pattern",{id:e.id,width:t,height:t,patternUnits:"userSpaceOnUse",patternTransform:`rotate(${e.angle??45})`,children:(0,Xt.jsx)("line",{x1:0,y1:0,x2:0,y2:t,stroke:e.color??"currentColor",strokeWidth:e.strokeWidth??1,opacity:e.opacity??.5})},e.id),fill:`url(#${e.id})`}}function en(e){const t=e.orient??"bottom",n="bottom"===t||"top"===t,o=e.offset??0,r=e.tickLength??6,i=e.gridLength??0,a=e.labelGap??4,s=e.fontSize??11,c=e.color??"var(--semiotic-text-secondary, #888)",l=e.gridColor??c,u=e.format??(e=>e+""),d="top"===t||"left"===t?-1:1,h=e.ticks.length-1,f=e.ticks.map((f,m)=>{const p=e.scale(f),g=o+d*r,y=o-d*i,x=g+d*a;let b;b=e.labelAnchor?e.labelAnchor:n?e.edgeAnchor&&0===m?"start":e.edgeAnchor&&m===h?"end":"middle":"left"===t?"end":"start";const w=n?"top"===t?"auto":"hanging":"middle",M=n?{x:p,y:x}:{x:x,y:p};return(0,Xt.jsxs)("g",{children:[(r>0||i>0)&&(0,Xt.jsx)("line",{...n?{x1:p,x2:p,y1:g,y2:y}:{x1:g,x2:y,y1:p,y2:p},stroke:i>0?l:c,strokeWidth:1,strokeDasharray:i>0?e.gridDasharray:void 0,opacity:i>0?.7:1}),(0,Xt.jsx)("text",{x:M.x,y:M.y,textAnchor:b,dominantBaseline:w,fontSize:s,fontWeight:e.fontWeight,fill:c,children:u(f)})]},`tick-${f}-${m}`)});return(0,Xt.jsx)("g",{className:e.className,style:{pointerEvents:"none"},children:f},e.keyId)}function tn(e){const t=e.stroke??"var(--semiotic-text, #f4f4f8)",n=e.strokeWidth??1,o=e.markRadius??0,r=e.labelX-e.markX,i=e.labelY-e.markY,a=Math.hypot(r,i)||1,s=e.markX+r/a*o,c=e.markY+i/a*o;let l;return l="elbow"===e.connector?`M${s},${c} L${s},${e.labelY} L${e.labelX},${e.labelY}`:"curve"===e.connector?`M${s},${c} Q${(s+e.labelX)/2},${c} ${e.labelX},${e.labelY}`:`M${s},${c} L${e.labelX},${e.labelY}`,(0,Xt.jsxs)("g",{className:e.className,style:{pointerEvents:"none"},children:[o>0&&(0,Xt.jsx)("circle",{cx:e.markX,cy:e.markY,r:o,fill:"none",stroke:t,strokeWidth:n}),(0,Xt.jsx)("path",{d:l,fill:"none",stroke:t,strokeWidth:n}),(0,Xt.jsx)("text",{x:e.labelX,y:e.labelY,textAnchor:e.labelAnchor??"middle",dominantBaseline:e.labelBaseline??"hanging",fontSize:e.fontSize??11,fontWeight:e.fontWeight,fill:e.color??t,children:e.label})]},e.keyId)}var nn=require("react/jsx-runtime");function on(e,t,n={}){const o=n.fingerprintRounds??3,r=[],i=new Set;for(const t of e)null==t.id||i.has(t.id)||(i.add(t.id),r.push(t.id));const{outAdj:a,inAdj:s,undirected:c}=un(r,t),l=dn(r,a,s,c,o).map(e=>({ids:e.ids,nodeCount:e.nodeCount,edgeCount:e.edgeCount,sinkCount:e.sinkCount,sourceCount:e.sourceCount,directed:e.directed,motif:e.motif,descriptor:ln(e)})),u=new Map;for(const e of l){const t=u.get(e.motif);t?t.count+=1:u.set(e.motif,{motif:e.motif,descriptor:e.descriptor,count:1,directed:e.directed})}return{components:l,motifs:[...u.values()].sort((e,t)=>t.count-e.count),directedCount:l.filter(e=>e.directed).length,branchingCount:l.filter(e=>!e.directed).length}}function rn(e){let t=2166136261;for(let n=0;e.length>n;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function an(e){return"string"==typeof e?e:e?.id}function sn(e,t,n,o,r){const i=new Set(e);let a=new Map;for(const o of e){let e=0,r=0;for(const e of t.get(o)??[])i.has(e)&&(r+=1);for(const t of n.get(o)??[])i.has(t)&&(e+=1);a.set(o,`${e}:${r}`)}for(let o=0;r>o;o+=1){const o=new Map;for(const r of e){const e=[];for(const n of t.get(r)??[])i.has(n)&&e.push(a.get(n));const s=[];for(const e of n.get(r)??[])i.has(e)&&s.push(a.get(e));e.sort(),s.sort(),o.set(r,rn(`${a.get(r)}>${e.join(",")}<${s.join(",")}`))}a=o}const s=e.map(e=>a.get(e)).sort();return rn(`${e.length}#${o}#${s.join(";")}`)}function cn(e,t,n,o,r,i,a){const{layer:s,layerCount:c}=function(e,t){const n=new Set(e),o=new Map,r=new Set,i=e=>{const a=o.get(e);if(void 0!==a)return a;if(r.has(e))return 0;r.add(e);let s=0;for(const o of t.get(e)??[])n.has(o)&&(s=Math.max(s,1+i(o)));return r.delete(e),o.set(e,s),s};let a=0;for(const t of e)a=Math.max(a,i(t));const s=new Map;for(const t of e)s.set(t,a-o.get(t));return{layer:s,layerCount:a+1}}(e.ids,o),l=Array.from({length:c},()=>[]);for(const t of e.ids)l[s.get(t)].push(t);const u=.14*Math.min(i.width,i.height),d=Math.max(1,i.width-2*u),h=Math.max(1,i.height-2*u),f=new Map,m=new Set(e.ids);for(let e=0;c>e;e+=1){let t=l[e];e>0&&(t=[...t].sort((e,t)=>p(e)-p(t)));const n=t.length,o=i.y+u+(1===c?.5:e/(c-1))*h;t.forEach((e,t)=>{f.set(e,{x:i.x+u+(1===n?.5:t/(n-1))*d,y:o})})}function p(e){let t=0,n=0;for(const o of r.get(e)??[]){const e=f.get(o);m.has(o)&&e&&(t+=e.x,n+=1)}return n>0?t/n:i.x+d/2}const g=l.reduce((e,t)=>Math.max(e,t.length),1),y=$(Math.min(a,d/(2.4*g),h/(2.4*c)),1.4,a),x=e.ids.map(e=>{const o=f.get(e);return{id:e,cx:o.x,cy:o.y,r:y,datum:t.get(e)??v({id:e}),category:n.get(e)??""}}),b=[];for(const t of e.ids){const e=f.get(t);for(const n of o.get(t)??[]){if(!m.has(n))continue;const t=f.get(n);b.push({x1:e.x,y1:e.y,x2:t.x,y2:t.y})}}return{nodes:x,edges:b}}function ln(e){const{nodeCount:t,edgeCount:n,sinkCount:o,sourceCount:r}=e;return 1===t?"isolate":2===t&&1===n?"pair":1===r&&1===o&&n===t-1?"chain of "+t:e.directed&&1===r&&n>t-1?"diamond / mesh":e.directed?`converging (${t})`:"branching → "+o}function un(e,t){const n=new Set(e),o=new Map,r=new Map,i=new Map;for(const t of e)o.set(t,new Set),r.set(t,new Set),i.set(t,new Set);for(const e of t){const t=e.source,a=e.target;n.has(t)&&n.has(a)&&t!==a&&(o.get(t).has(a)||(o.get(t).add(a),r.get(a).add(t),i.get(t).add(a),i.get(a).add(t)))}return{outAdj:o,inAdj:r,undirected:i}}function dn(e,t,n,o,r){const i=new Set,a=[];for(const s of e){if(i.has(s))continue;const e=[s];i.add(s);const c=[];for(;e.length;){const t=e.pop();c.push(t);for(const n of o.get(t)??[])i.has(n)||(i.add(n),e.push(n))}const l=new Set(c);let u=0,d=0,h=0;for(const e of c){let o=0,r=0;for(const n of t.get(e)??[])l.has(n)&&(o+=1);for(const t of n.get(e)??[])l.has(t)&&(r+=1);h+=o,0===o&&(u+=1),0===r&&(d+=1)}a.push({ids:c,nodeCount:c.length,edgeCount:h,sinkCount:u,sourceCount:d,directed:1===u,motif:sn(c,t,n,h,r)})}return a}var hn=new b(8),fn=e=>{const t=e.config||{},n=e.dimensions.plot;if(!e.nodes.length)return{sceneNodes:[]};const o=t.sourceAccessor??"source",r=t.targetAccessor??"target",i=t.labelAccessor??"label",a=t.categoryAccessor??"category",s=t.nodeRadius??4,c=t.cellGap??16,l=t.bandGap??22,u=t.headerHeight??34,d=t.minCellForFull??38,f=t.maxCellSize??120,m=t.minCellSize??12,p=t.fingerprintRounds??3,g=!1!==t.groupByMotif,b=t.sort??"frequency",w=new Map,M=new Map,k=[];for(const t of e.nodes){const e=t.id;null==e||w.has(e)||(k.push(e),w.set(e,t.data??t),M.set(e,h(t,a,"")+""))}const $=[];for(const t of e.edges){const e=an(t.source??h(t,o,void 0)),n=an(t.target??h(t,r,void 0));null!=e&&null!=n&&$.push({source:e,target:n})}const{outAdj:A,inAdj:S,undirected:I}=un(k,$),j=dn(k,A,S,I,p),C=new Map;if(g)for(const e of j){const t=C.get(e.motif);t?t.push(e):C.set(e.motif,[e])}else C.set("all",[...j].sort((e,t)=>t.nodeCount-e.nodeCount));const N=[...C.entries()];N.sort((e,t)=>"size"===b?t[1][0].nodeCount-e[1][0].nodeCount:"directedness"===b?Number(t[1][0].directed)-Number(e[1][0].directed):t[1].length-e[1].length);const F=rn(k.join(",")+"|"+[...A.entries()].map(([e,t])=>e+">"+[...t].sort().join(".")).join(";")),z=x([Math.round(n.x),Math.round(n.y),Math.round(n.width),Math.round(n.height),c,l,u,d,f,m,p,g,b,s,N.map(([e,t])=>e+":"+t.length).join(","),F]),L=hn.getOrCompute(z,()=>function(e,t){const{plot:n}=t,o=Math.max(40,n.width),{cell:r,cols:i}=(()=>{for(let r=t.maxCellSize;r>=t.minCellSize;r-=2){const i=Math.max(1,Math.floor((o+t.cellGap)/(r+t.cellGap)));let a=0;for(const[,n]of e)a+=t.headerHeight+Math.ceil(n.length/i)*(r+t.cellGap)+t.bandGap;if(n.height>=a)return{cell:r,cols:i}}return{cell:t.minCellSize,cols:Math.max(1,Math.floor((o+t.cellGap)/(t.minCellSize+t.cellGap)))}})(),a=[],s=[];let c=n.y;for(const[l,u]of e){const e=Math.ceil(u.length/i),d=c,h=d+t.headerHeight,f=r>=t.minCellForFull;u.forEach((e,o)=>{const s=n.x+o%i*(r+t.cellGap),c=h+Math.floor(o/i)*(r+t.cellGap);if(f){const n=cn(e,t.nodeDatum,t.nodeCategory,t.outAdj,t.inAdj,{x:s,y:c,width:r,height:r},t.nodeRadius);a.push({component:e,lod:"full",cx:s+r/2,cy:c+r/2,glyphR:0,nodes:n.nodes,edges:n.edges})}else a.push({component:e,lod:"glyph",cx:s+r/2,cy:c+r/2,glyphR:Math.max(2.5,.36*r),nodes:[],edges:[]})});const m=mn(u[0],t,{x:n.x,y:d+2,width:Math.min(t.headerHeight-6,40),height:t.headerHeight-6});s.push({motif:l,descriptor:ln(u[0]),count:u.length,directed:u[0].directed,x:n.x,y:d,width:o,height:t.headerHeight+e*(r+t.cellGap),exemplar:m}),c=h+e*(r+t.cellGap)+t.bandGap}return{cells:a,bands:s}}(N,{plot:n,cellGap:c,bandGap:l,headerHeight:u,minCellForFull:d,maxCellSize:f,minCellSize:m,nodeRadius:s,nodeDatum:w,nodeCategory:M,outAdj:A,inAdj:S})),E=e.theme.semantic||{},T=t.convergeColor??E.info??"#4c78a8",R=t.branchColor??E.warning??"#e8853a",P=t.edgeColor??E.border??"#9aa0aa",W=t.colorMode??"directedness",O={predicate:e.selection?.isActive?e.selection.predicate:null,highlight:t.highlight??null,dimOpacity:.14},q=t=>"motif"===W?e.resolveColor(t.motif):"category"===W||t.directed?T:R,D=[],B=[];for(const t of L.cells){const n=t.component,o=q(n);if("full"===t.lod){for(const e of t.edges)B.push({type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,style:{stroke:P,strokeWidth:1,opacity:.5},datum:null});for(const n of t.nodes){const t="category"===W&&n.category?e.resolveColor(n.category):o,r={type:"symbol",cx:n.cx,cy:n.cy,size:Math.PI*n.r*n.r,symbolType:"circle",style:{fill:t,opacity:y(n.datum,O)},datum:n.datum,id:n.id,label:h(n.datum,i,n.id)+""};D.push(r)}}else{const e=v({id:`motif-${n.motif}-${t.cx.toFixed(0)}-${t.cy.toFixed(0)}`,motif:n.motif,shape:ln(n),nodes:n.nodeCount,edges:n.edgeCount,sinks:n.sinkCount,sources:n.sourceCount,directedness:n.directed?"converging":"branching"}),r={type:"symbol",cx:t.cx,cy:t.cy,size:Math.PI*t.glyphR*t.glyphR,symbolType:n.directed?"circle":"diamond",style:{fill:o,opacity:y(e,O),stroke:P,strokeWidth:.75},datum:e,id:e.id+"",label:ln(n)};D.push(r)}}return{sceneNodes:D,sceneEdges:B,overlays:function(e,t){const n=[];for(const o of e){const e=o.directed?t.convergeColor:t.branchColor;if(n.push(Ut({keyId:"band-"+o.motif,x:o.x-6,y:o.y-4,width:o.width+12,height:o.height+4,radius:8,stroke:e,strokeWidth:1,opacity:.28})),t.showExemplars&&o.exemplar){const r=o.exemplar;n.push((0,nn.jsxs)("g",{style:{pointerEvents:"none"},children:[r.edges.map((e,n)=>(0,nn.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:t.edgeColor,strokeWidth:.75,opacity:.55},"exe-"+n)),r.nodes.map(t=>(0,nn.jsx)("circle",{cx:t.cx,cy:t.cy,r:Math.max(1.6,t.r),fill:e},"exn-"+t.id))]},"ex-"+o.motif))}if(t.showBandLabels){const e=o.x+(t.showExemplars?48:4);n.push((0,nn.jsx)("text",{x:e,y:o.y+12,fontSize:13,fontWeight:600,fill:t.textColor,style:{pointerEvents:"none"},children:o.descriptor},"bl-"+o.motif)),n.push((0,nn.jsx)("text",{x:e,y:o.y+27,fontSize:11,fill:t.subText,style:{pointerEvents:"none"},children:`×${o.count} · ${o.directed?"converges to 1 sink":"branches to ≥2 sinks"}`},"bc-"+o.motif))}}if(t.showLegend){const e=t.plot.x+t.plot.width-168,i=t.plot.y-2;n.push((0,nn.jsxs)("g",{style:{pointerEvents:"none"},children:[(0,nn.jsx)("circle",{cx:e,cy:i,r:5,fill:t.convergeColor}),(0,nn.jsx)("text",{x:e+10,y:i+4,fontSize:11,fill:t.subText,children:"converges (1 sink)"}),(0,nn.jsx)("path",{d:(o=e,r=i+18,`M${o},${r-5} L${o+5},${r} L${o},${r+5} L${o-5},${r} Z`),fill:t.branchColor}),(0,nn.jsx)("text",{x:e+10,y:i+22,fontSize:11,fill:t.subText,children:"branches (≥2 sinks)"})]},"net-legend"))}var o,r;return(0,nn.jsx)("g",{className:"net-ensemble-overlays",children:n})}(L.bands,{convergeColor:T,branchColor:R,edgeColor:P,plot:n,showBandLabels:!1!==t.showBandLabels,showExemplars:!1!==t.showExemplars,showLegend:!1!==t.showLegend&&"directedness"===W,textColor:E.text??"var(--semiotic-text, #1a1a1a)",subText:E.textSecondary??"var(--semiotic-text-secondary, #888)"})}};function mn(e,t,n){return e?cn(e,t.nodeDatum,t.nodeCategory,t.outAdj,t.inAdj,n,3):null}var pn=require("react/jsx-runtime"),gn=new b(12);function yn(e){if(null==e)return NaN;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();const t=e+"",n=Number(t);if(!Number.isNaN(n)&&""!==t.trim())return n;const o=Date.parse(t);return Number.isNaN(o)?NaN:o}function xn(e,t,n){return t>e?t:e>n?n:e}var bn=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.columnAccessor??"column",r=t.rowAccessor??"row",i=t.sizeAccessor,a=t.colorAccessor,s=t.symbolAccessor,c=t.shadeAccessor,l=t.markerAccessor,u=t.iconAccessor,d=t.defaultSymbol??"circle",[f,p]=t.sizeRange??[2,8],g=t.shadeStrength??.72,b=t.shadeReverse??!1,M=t.rowMode??"banded",v=t.cellSizing??"proportional",k=t.proportionExponent??1,$=t.columnGap??16,A=t.rowGap??12,S=t.packPadding??1,I=t.iterations??12,j=!1!==t.showEnclosures,C=!1!==t.showColumnHeaders,N=!1!==t.showRowLabels,F=C?t.headerHeight??26:0,z=N?t.labelWidth??66:0,L=t.callouts&&t.callouts.length>0?t.footerHeight??30:0,E=n.x+z,T=n.y+F,R=Math.max(1,n.width-z),P=Math.max(1,n.height-F-L),W=[];for(const t of e.nodes){const e=t.data??t;W.push({id:t.id,col:h(t,o,"—")+"",row:h(t,r,"—")+"",sizeVal:i?Number(h(t,i,1)):1,colorKey:a?h(t,a,"")+"":"",symVal:s?h(t,s,"")+"":"",shadeVal:c?yn(h(t,c,null)):NaN,marker:!!l&&!!h(t,l,!1),iconVal:u?h(t,u,"")+"":"",datum:e,size:0,packR:0,baseShape:"circle",iconShape:null})}if(0===W.length)return{sceneNodes:[]};let O=1/0,q=-1/0;if(i)for(const e of W)Number.isFinite(e.sizeVal)&&(O>e.sizeVal&&(O=e.sizeVal),e.sizeVal>q&&(q=e.sizeVal));t.sizeDomain&&([O,q]=t.sizeDomain),Number.isFinite(O)&&Number.isFinite(q)||(O=0,q=1);const D=e=>{if(O>=q)return(f+p)/2;const t=Math.sqrt(xn((e-O)/(q-O),0,1));return f+t*(p-f)};let B=1/0,Y=-1/0;if(c)for(const e of W)Number.isFinite(e.shadeVal)&&(B>e.shadeVal&&(B=e.shadeVal),e.shadeVal>Y&&(Y=e.shadeVal));t.shadeDomain&&([B,Y]=t.shadeDomain);const G=e=>{if(!c||!Number.isFinite(e)||B>=Y)return.5;const t=xn((e-B)/(Y-B),0,1);return b?1-t:t},H=t.colorMap,_=new Map,V=(t,n)=>{let o=_.get(t);return o||(o=w(H&&H[t]||e.resolveColor(t),g),_.set(t,o)),o(n)},X=new Map;if(t.symbolMap)for(const[e,n]of Object.entries(t.symbolMap))X.set(e,n);let U=0;const K=t.iconMap,Q=e=>u&&K&&K[e]?K[e]:null,Z=e=>u?"circle":(e=>{if(!s)return d;let t=X.get(e);return t||(t=J[U%J.length],U++,X.set(e,t)),t})(e.symVal),te=t.maxAreaFraction??.4;let ne=0;const re=Array(W.length),ie=Array(W.length);for(let e=0;W.length>e;e++){const t=W[e],n=D(t.sizeVal);re[e]=n,t.baseShape=Z(t),t.iconShape=Q(t.iconVal);const o=oe(t.baseShape,Math.PI*n*n);ie[e]=o,ne+=Math.PI*o*o}const ae=te*R*P,se=ne>ae?Math.sqrt(ae/ne):1;for(let e=0;W.length>e;e++){const t=W[e],n=re[e]*se;t.size=Math.PI*n*n,t.packR=ie[e]*se}const ce=new Map,le=new Map;for(const e of W)ce.set(e.col,(ce.get(e.col)??0)+1),le.set(e.row,(le.get(e.row)??0)+1);const ue=t.columnOrder?.filter(e=>ce.has(e))??[...ce.keys()].sort((e,t)=>(ce.get(t)??0)-(ce.get(e)??0)),de=t.rowOrder?.filter(e=>le.has(e))??[...le.keys()].sort((e,t)=>(le.get(t)??0)-(le.get(e)??0)),he=x([Math.round(n.x),Math.round(n.y),Math.round(n.width),Math.round(n.height),F,z,L,M,v,k,$,A,S,I,f,p,O,q,te,ue.join(","),de.join(","),W.length,Mn(W)]),fe=gn.getOrCompute(he,()=>function(e,t){const n=new Map;for(const t of e){let e=n.get(t.col);e||(e=[],n.set(t.col,e)),e.push(t)}const o=t.columnOrder.filter(e=>n.has(e)),r=Math.max(1,t.innerW-t.columnGap*Math.max(0,o.length-1)),i=t.proportionExponent,a=o.map(e=>Math.pow(n.get(e).length,i)),s=a.reduce((e,t)=>e+t,0)||1,c=e=>"uniform"===t.cellSizing?r/o.length:a[e]/s*r,l=new Map,u=[];let d=t.innerX;for(let e=0;o.length>e;e++)u.push({col:o[e],x:d,w:c(e)}),d+=c(e)+t.columnGap;let h=1;const f=new Map,p=[],g=(e,t,n,o)=>{let r=f.get(e);r||(r={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},f.set(e,r)),r.minX>t-o&&(r.minX=t-o),t+o>r.maxX&&(r.maxX=t+o),r.minY>n-o&&(r.minY=n-o),n+o>r.maxY&&(r.maxY=n+o)},y=(e,n,o,r,i,a)=>{const s=e.map(e=>({id:e.id,r:e.packR})),c=function(e,t,n,o,r,i,a,s){const c=t+o/2,l=n+r/2,u=new Map,d=e.length;if(0===d)return u;if(1===d)return u.set(e[0].id,{px:c,py:l}),u;const h=function(e){let t=e>>>0||1;return()=>(t=Math.imul(t,1664525)+1013904223>>>0,t/4294967296)}(s),f=new Float64Array(d);let m=0;for(let t=0;d>t;t++)f[t]=e[t].r+i,f[t]>m&&(m=f[t]);const p=Math.max(1,Math.round(Math.sqrt(d*o/Math.max(1,r)))),g=new Float64Array(d),y=new Float64Array(d),x=o/p,b=r/Math.ceil(d/p);for(let e=0;d>e;e++){const o=e%p,r=Math.floor(e/p);g[e]=t+(o+.3+.4*h())*x,y[e]=n+(r+.3+.4*h())*b}const w=Math.max(0,Math.min(a,14)),M=Math.max(1,2*m),v=new Map,k=Math.max(1,Math.ceil(o/M)+3),$=(e,t)=>(t+1)*k+(e+1);for(let e=0;w>e;e++){v.clear();for(let e=0;d>e;e++){const o=$(Math.floor((g[e]-t)/M),Math.floor((y[e]-n)/M)),r=v.get(o);r?r.push(e):v.set(o,[e])}for(let e=0;d>e;e++){const o=Math.floor((g[e]-t)/M),r=Math.floor((y[e]-n)/M);for(let t=-1;1>=t;t++)for(let n=-1;1>=n;n++){const i=v.get($(o+t,r+n));if(i)for(let t=0;i.length>t;t++){const n=i[t];if(e>=n)continue;let o=g[n]-g[e],r=y[n]-y[e];const a=f[e]+f[n],s=o*o+r*r;if(a*a>s)if(s>1e-9){const t=Math.sqrt(s),i=(a-t)/2;o/=t,r/=t,g[e]-=o*i,y[e]-=r*i,g[n]+=o*i,y[n]+=r*i}else{const t=2.39996323*e;g[e]+=Math.cos(t)*f[e],y[e]+=Math.sin(t)*f[e]}}}}for(let e=0;d>e;e++){const i=f[e],a=t+i,s=t+o-i,u=n+i,d=n+r-i;g[e]=s>a?xn(g[e],a,s):c,y[e]=d>u?xn(y[e],u,d):l}}for(let t=0;d>t;t++)u.set(e[t].id,{px:g[t],py:y[t]});return u}(s,n,o,r,i,t.packPadding,t.iterations,h++);let u=1/0,d=1/0,f=-1/0,m=-1/0;for(const e of s){const t=c.get(e.id);l.set(e.id,{px:t.px,py:t.py}),g(a,t.px,t.py,e.r),u>t.px-e.r&&(u=t.px-e.r),t.px+e.r>f&&(f=t.px+e.r),d>t.py-e.r&&(d=t.py-e.r),t.py+e.r>m&&(m=t.py+e.r)}return Number.isFinite(u)?{x:u-wn,y:d-wn,w:f-u+2*wn,h:m-d+2*wn}:null};if("banded"===t.rowMode){const r=new Map;for(const t of e)r.set(t.row,(r.get(t.row)??0)+1);const a=t.rowOrder.filter(e=>r.has(e)),s=Math.max(1,t.innerH-t.rowGap*Math.max(0,a.length-1)),c=a.map(e=>Math.pow(r.get(e),i)),d=c.reduce((e,t)=>e+t,0)||1,h=new Map;let p=t.innerY+t.innerH;for(let e=0;a.length>e;e++){const n="uniform"===t.cellSizing?s/a.length:c[e]/d*s,o=p-n;h.set(a[e],{y:o,h:n}),p=o-t.rowGap}o.forEach((e,t)=>{const o=m(n.get(e),e=>e.row);for(const e of a){const n=o.get(e),r=h.get(e);n&&r&&y(n,u[t].x,r.y,u[t].w,r.h,e)}});const g=[],x=new Map;for(const e of a){const t=h.get(e);x.set(e,t.y+t.h/2);const n=f.get(e);n&&Number.isFinite(n.minX)&&g.push({x:n.minX-wn,y:n.minY-wn,w:n.maxX-n.minX+2*wn,h:n.maxY-n.minY+2*wn})}return{positions:l,enclosures:g,colBands:u,rowLabelY:x}}const x=new Map;o.forEach((e,o)=>{const r=m(n.get(e),e=>e.row),a=t.rowOrder.filter(e=>r.has(e)),s=Math.max(1,t.innerH-t.rowGap*Math.max(0,a.length-1)),c=a.map(e=>Math.pow(r.get(e).length,i)),l=c.reduce((e,t)=>e+t,0)||1;let d=t.innerY+t.innerH;a.forEach((e,n)=>{const i="uniform"===t.cellSizing?s/a.length:c[n]/l*s,h=d-i,f=y(r.get(e),u[o].x,h,u[o].w,i,e);if(f){p.push(f);const t=x.get(e)??{sum:0,n:0};t.sum+=f.y+f.h/2,t.n+=1,x.set(e,t)}d=h-t.rowGap})});const b=new Map;for(const[e,t]of x)b.set(e,t.sum/t.n);return{positions:l,enclosures:p,colBands:u,rowLabelY:b}}(W,{columnOrder:ue,rowOrder:de,innerX:E,innerY:T,innerW:R,innerH:P,rowMode:M,cellSizing:v,proportionExponent:k,columnGap:$,rowGap:A,packPadding:S,iterations:I})),me=e.selection,pe=me?.isActive?me.predicate:null,ge=t.highlight??null,ye=t.dimOpacity??.16,xe=t.markStroke,be=t.markStrokeWidth??0,we=t.markerColor??"#ffffff",Me=t.iconColor??"rgba(255,255,255,0.92)",ve=t.iconStrokeWidth??1,ke=t.iconScale??.72,$e=[],Ae=[],Se=[];for(const e of W){const t=fe.positions.get(e.id);if(!t)continue;const n=y(e.datum,{highlight:ge,predicate:pe,dimOpacity:ye}),o={type:"symbol",cx:t.px,cy:t.py,size:e.size,symbolType:e.baseShape,style:{fill:V(e.colorKey,G(e.shadeVal)),opacity:n,...xe?{stroke:xe,strokeWidth:be}:{}},datum:e.datum,id:e.id,label:e.id+""};if($e.push(o),e.iconShape){const o=Math.sqrt(e.size/Math.PI)*ke,r=oe(e.iconShape,100);Se.push({x:t.px,y:t.py,size:r>0?o/r*100*(o/r):Math.PI*o*o,shape:e.iconShape,opacity:n})}e.marker&&n>ye+.001&&Ae.push({x:t.px,y:t.py,r:Math.max(1,.4*Math.sqrt(e.size/Math.PI))})}const Ie=[];if(t.callouts&&t.callouts.length>0){const e=t.calloutColor??"var(--semiotic-text, #f4f4f8)",o=n.y+n.height-(L>0?.45*L:9),r=[];for(let e=0;t.callouts.length>e;e++){const n=t.callouts[e],o=W.find(e=>e.datum[n.field]+""==n.value+"");if(!o)continue;const i=fe.positions.get(o.id);i&&r.push({c:n,ci:e,px:i.px,py:i.py,markR:Math.sqrt(o.size/Math.PI)})}const i=r.filter(e=>null==e.c.at).sort((e,t)=>e.px-t.px),a=new Map;i.forEach((e,t)=>{a.set(e.ci,E+(t+.5)/i.length*R)});for(const t of r){const r=t.c;let i=a.get(t.ci)??t.px,s=o;const c=r.connector??(a.has(t.ci)?"elbow":"straight");"object"==typeof r.at&&r.at?(i=r.at.x,s=r.at.y):"number"==typeof r.at&&(s=n.y+r.at*n.height),Ie.push({keyId:"callout-"+t.ci,markX:t.px,markY:t.py,labelX:i,labelY:s,label:r.label,connector:c,markRadius:Math.max(t.markR+3,7),stroke:e,color:e,fontSize:11,labelAnchor:"middle",labelBaseline:"auto"})}}const je=function(e,t){const n=t.columnLabel??(e=>e),o=t.rowLabel??(e=>e);return(0,pn.jsxs)("g",{className:"packed-cluster-matrix-chrome",style:{pointerEvents:"none"},children:[t.showEnclosures&&e.enclosures.map((e,n)=>Ut({keyId:"enc-"+n,x:e.x,y:e.y,width:e.w,height:e.h,radius:t.enclosureRadius,stroke:t.enclosureColor,strokeWidth:t.enclosureWidth,opacity:t.enclosureOpacity})),t.iconMarks.length>0&&(0,pn.jsx)("g",{className:"packed-cluster-matrix-icons",children:t.iconMarks.map((e,n)=>(0,pn.jsx)("path",{d:ee(e.shape,e.size),transform:`translate(${e.x},${e.y})`,fill:"none",stroke:t.iconColor,strokeWidth:t.iconStrokeWidth,opacity:e.opacity},"ic-"+n))}),t.markerDots.length>0&&(0,pn.jsx)("g",{className:"packed-cluster-matrix-markers",children:t.markerDots.map((e,n)=>(0,pn.jsx)("circle",{cx:e.x,cy:e.y,r:e.r,fill:t.markerColor},"mk-"+n))}),t.showColumnHeaders&&e.colBands.map((e,o)=>Zt({keyId:"col-"+o,text:n(e.col),x:e.x+e.w/2,y:t.headerY,anchor:"middle",fontSize:t.headerFontSize,fontWeight:700,color:t.headerColor})),t.showRowLabels&&[...e.rowLabelY].map(([e,n])=>Zt({keyId:"row-"+e,text:o(e),x:t.labelX,y:n,anchor:"end",fontSize:t.labelFontSize,fontWeight:600,color:t.labelColor})),t.callouts.map(e=>tn(e))]})}(fe,{markerDots:Ae,markerColor:we,iconMarks:Se,iconColor:Me,iconStrokeWidth:ve,callouts:Ie,plot:n,showEnclosures:j,showColumnHeaders:C,showRowLabels:N,enclosureColor:t.enclosureColor??"var(--semiotic-text, #f4f4f8)",enclosureRadius:t.enclosureRadius??9,enclosureOpacity:t.enclosureOpacity??.5,enclosureWidth:t.enclosureWidth??1.5,headerColor:t.headerColor??"var(--semiotic-text, #f4f4f8)",labelColor:t.labelColor??"var(--semiotic-text-secondary, #b9b9c8)",headerFontSize:t.headerFontSize??13,labelFontSize:t.labelFontSize??11,headerY:n.y+.62*F,labelX:n.x+z-10,columnLabel:t.columnLabel,rowLabel:t.rowLabel});return{sceneNodes:$e,overlays:je}},wn=4;function Mn(e){let t=2166136261;const n=e=>{for(let n=0;e.length>n;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)};for(const o of e)n(o.id),n(o.col),n(o.row),t^=Math.round(8*o.packR),t=Math.imul(t,16777619);return(t>>>0).toString(36)}var vn=c(require("react")),kn=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height)return{nodes:[]};const o=d(t.categoryAccessor),r=d(t.stackBy),i=e=>{const n="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor],o=Number(n);return Number.isFinite(o)&&o>0?o:0},a=t.gutter??2,s="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",c="string"==typeof t.stackBy?t.stackBy:"stack",l="string"==typeof t.valueAccessor?t.valueAccessor:"value",u=(e,t,n)=>p(o=>{o("category",e),o("stack",t),o("value",n),"category"!==s&&o(s,e),"stack"!==c&&o(c,t),"value"!==l&&o(l,n)}),h=!1!==t.showCategoryLabels,f=Math.max(0,n.height-(t.labelPadding??(h?22:0))),m=[],g=new Map,y=[],x=new Set,b=new Map;for(const t of e.data){const e=o(t)+"",n=r(t)+"",a=i(t);g.has(e)||(m.push(e),g.set(e,0),b.set(e,new Map)),x.has(n)||(x.add(n),y.push(n)),g.set(e,(g.get(e)??0)+a);const s=b.get(e);s.set(n,(s.get(n)??0)+a)}const w=t.categoryOrder?$n(t.categoryOrder,m,e=>g.has(e)):m,M=t.stackOrder?$n(t.stackOrder,y,()=>!0):y,v=w.reduce((e,t)=>e+(g.get(t)??0),0);if(0>=v)return{nodes:[]};const k=Math.max(0,n.width-a*Math.max(0,w.length-1)),$=[],A=[];let S=n.x;for(const t of w){const o=g.get(t)??0,r=o/v*k;if(0>=r)continue;A.push({cat:t,x:S,w:r});const i=b.get(t);let s=n.y;for(const n of M){const a=i.get(n)??0;if(0>=a)continue;const c=a/o*f;$.push({type:"rect",x:S,y:s,w:r,h:c,style:{fill:e.resolveColor(n),stroke:"none"},datum:u(t,n,a),group:n}),s+=c}S+=r+a}return{nodes:$,overlays:h&&A.length>0?function(e,t,n){const o=e.map((e,o)=>Zt({keyId:"marimekko-label-"+o,text:e.cat,x:e.x+e.w/2,y:t+12,anchor:"middle",baseline:"auto",maxWidth:e.w-4,fontSize:12,color:n}));return vn.createElement(vn.Fragment,null,...o)}(A,n.y+f+4,`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`):null}};function $n(e,t,n){const o=new Set,r=[];for(const t of e)n(t)&&!o.has(t)&&(o.add(t),r.push(t));for(const e of t)o.has(e)||r.push(e);return r}var An=c(require("react")),Sn=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height||0===e.data.length)return{nodes:[]};const o=t.rowHeight??28,r=t.rowGap??12,i=!1!==t.showLabels,a=i?t.labelWidth??120:0,s=!1!==t.showTicks,c=s?14:0,l=t.tickFormat??(e=>e.toLocaleString()),u=n.x+a,h=Math.max(0,n.width-a);if(0>=h)return{nodes:[]};const f=d(t.categoryAccessor),m=e=>{const t=Number(e);return Number.isFinite(t)&&t>0?t:0},g=e=>m("function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor]),y=e=>m("function"==typeof t.targetAccessor?t.targetAccessor(e):e[t.targetAccessor]),x=e=>{const n="function"==typeof t.rangesAccessor?t.rangesAccessor(e):e[t.rangesAccessor];return Array.isArray(n)?n.map(m).sort((e,t)=>e-t):[]},b="string"==typeof t.categoryAccessor?t.categoryAccessor:"metric",w="string"==typeof t.valueAccessor?t.valueAccessor:"value",M="string"==typeof t.targetAccessor?t.targetAccessor:"target",v=t.actualColor??e.theme.semantic.primary??"#3b6cb1",k=e.theme.semantic.text??"currentColor",$=t.targetColor??`var(--semiotic-text, ${k})`,A=[`var(--semiotic-surface, ${e.theme.semantic.surface??"#e8eaed"})`,`var(--semiotic-grid, ${e.theme.semantic.grid??"#cdd1d6"})`,`var(--semiotic-border, ${e.theme.semantic.border??"#a3a8af"})`],S=`var(--semiotic-text, ${k})`,I=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,j=[],C=[];for(let t=0;e.data.length>t;t++){const i=e.data[t],a=x(i),s=g(i),l=y(i),d=Math.max(s,l,...a.length?a:[0]);if(0>=d)continue;const m=n.y+t*(o+r+c);if(m+o+c>n.y+n.height)break;C.push({yTop:m,label:f(i),actual:s,target:l,maxVal:d});const k=e=>u+e/d*h,S=f(i),I=e=>p(t=>{t("metric",S),"metric"!==b&&t(b,S),e(t)});let N=u;for(let e=0;a.length>e;e++){const t=k(a[e]),n=t-N;n>0&&j.push({type:"rect",x:N,y:m,w:n,h:o,style:{fill:A[Math.min(e,A.length-1)],stroke:"none"},datum:I(t=>{t("range",e),t("rangeValue",a[e]),t("kind","range")}),group:"range-"+e}),N=t}const F=Math.max(6,Math.floor(.45*o));j.push({type:"rect",x:u,y:m+(o-F)/2,w:k(s)-u,h:F,style:{fill:v,stroke:"none"},datum:I(e=>{e("value",s),e("kind","actual"),"value"!==w&&e(w,s)}),group:"actual"});const z=3,L=Math.floor(.8*o);j.push({type:"rect",x:k(l)-z/2,y:m+(o-L)/2,w:z,h:L,style:{fill:$,stroke:"none"},datum:I(e=>{e("target",l),e("kind","target"),"target"!==M&&e(M,l)}),group:"target"})}const N=[];for(let e=0;C.length>e;e++){const t=C[e];if(i&&N.push(Zt({keyId:"bullet-label-"+e,text:t.label,x:n.x+a-8,y:t.yTop+o/2,anchor:"end",baseline:"middle",fontSize:13,fontWeight:500,color:S})),s){const n=5,r=t.yTop+o+2;for(let o=0;n>o;o++){const i=t.maxVal*o/(n-1),a=u+i/t.maxVal*h;N.push(An.createElement("line",{key:`bullet-tick-${e}-${o}`,x1:a,x2:a,y1:r,y2:r+3,stroke:I,strokeWidth:1}),Zt({keyId:`bullet-ticktext-${e}-${o}`,text:l(i),x:a,y:r+12,anchor:0===o?"start":o===n-1?"end":"middle",baseline:"auto",fontSize:10,color:I}))}}}return{nodes:j,overlays:N.length>0?An.createElement(An.Fragment,null,...N):null}},In=c(require("react")),jn=require("d3-scale"),Cn=e=>{const t=e.config,{plot:n}=e.dimensions,o=t.fields??[];if(2>o.length||0>=n.width||0>=n.height)return{nodes:[]};if(0===e.data.length)return{nodes:[]};const r={};for(const n of o){if(t.domains?.[n]){r[n]=t.domains[n];continue}let o=1/0,i=-1/0;for(const t of e.data){const e=Number(t[n]);Number.isFinite(e)&&(o>e&&(o=e),e>i&&(i=e))}r[n]=Number.isFinite(o)&&Number.isFinite(i)&&o!==i?[o,i]:[0,1]}const i=!1!==t.showAxes,a=i?t.axisLabelPadding??24:8,s=i?18:8,c=o.map(e=>(0,jn.scaleLinear)().domain(r[e]).range([n.y+n.height-s,n.y+a])),l=o.map((e,t)=>1===o.length?n.x+n.width/2:n.x+t/(o.length-1)*n.width),u=t.colorBy?"function"==typeof t.colorBy?t.colorBy:e=>(e[t.colorBy]??"")+"":null,d=t.opacity??.45,h=t.strokeWidth??1.25,f=e.theme.semantic.primary??"#3b6cb1",m=t.dimmedOpacity??.08,p=t.highlightFn,g=[],x=[];for(const n of e.data){const r=u?e.resolveColor(u(n)+""):f,i=!p||p(n),a=y(n,{predicate:p,baseOpacity:d,dimOpacity:m,brighten:.4}),s=i?x:g;for(let e=0;o.length-1>e;e++){const t=Number(n[o[e]]),u=Number(n[o[e+1]]);if(!Number.isFinite(t)||!Number.isFinite(u))continue;const d={type:"connector",x1:l[e],y1:c[e](t),x2:l[e+1],y2:c[e+1](u),style:{stroke:r,strokeWidth:p&&i?h+.75:h,opacity:a,fill:"none"},datum:n};s.push(d)}if(t.showPoints)for(let e=0;o.length>e;e++){const t=Number(n[o[e]]);if(!Number.isFinite(t))continue;const i={type:"point",x:l[e],y:c[e](t),r:2.5,style:{fill:r,stroke:"none",opacity:Math.min(1,a+.3)},datum:n};s.push(i)}}let b=null;if(i){const i=`var(--semiotic-border, ${e.theme.semantic.border??"#aaa"})`,u=`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`,d=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,h=n.y+a,f=n.y+n.height-s,m=[];for(let e=0;o.length>e;e++){const s=o[e],p=l[e],g=t.tickFormat?.[s]??(e=>e.toLocaleString());m.push(In.createElement("line",{key:"pc-axis-line-"+e,x1:p,x2:p,y1:h,y2:f,stroke:i,strokeWidth:1})),m.push(Zt({keyId:"pc-axis-label-"+e,text:s,x:p,y:n.y+a-8,anchor:"middle",baseline:"auto",fontSize:12,fontWeight:600,color:u}));const[y,x]=r[s],b=5;for(let t=0;b>t;t++){const n=y+(x-y)*t/(b-1),o=c[e](n);m.push(In.createElement("line",{key:`pc-tick-${e}-${t}`,x1:p-3,x2:p+3,y1:o,y2:o,stroke:i,strokeWidth:1}),Zt({keyId:`pc-ticktext-${e}-${t}`,text:g(n),x:p+6,y:o+3,anchor:"start",baseline:"auto",fontSize:10,color:d}))}}b=In.createElement(In.Fragment,null,...m)}return{nodes:g.concat(x),overlays:b}},Nn=require("react/jsx-runtime"),Fn=1.75,zn="#222222";function Ln(e,t){return e.topRadius+(t-e.height)/e.height*(e.topRadius-e.bottomRadius)}function En(e,t){return function(e,t,n){return Math.PI*n/3*(e*e+e*t+t*t)}(Ln(e,t),e.bottomRadius,t)}function Tn(e,t){const n=(e.topRadius+e.bottomRadius)/2,o=Math.PI*n*n;let r=t/o,i=t-En(e,r),a=0;for(;100>a&&Math.abs(i)>1e-4;)r+=i/o,i=t-En(e,r),a++;return r}function Rn(e,t){const n=43758.5453*Math.sin(12.9898*e+78.233);return 2*(n-Math.floor(n)-.5)*t}function Pn(e,t){if(t>e||2*t>e)return[{x:0,y:0}];const n=[],o=e=>{let r=Math.floor(2*Math.PI*e/(2*t));1>r&&(r=1);const i=0*e,a=Math.hypot(1*e-e*Math.cos(2*Math.PI/r),i-e*Math.sin(2*Math.PI/r));2*t>a&&r>1&&r--;for(let t=0;r>t;t++)n.push({x:e*Math.cos(2*t*Math.PI/r),y:e*Math.sin(2*t*Math.PI/r)});const s=e-2*t;t>s?e>2*t&&n.push({x:0,y:0}):o(s)};return o(e-t),n}function Wn(e,t,n){const o=[];let r=n,i=0;for(;r>0&&60>i;){const n=t*(1+2*i),a=Pn(Ln(e,n),t),s=a.length-r,c=s>1?a.slice(Math.floor(s/2),Math.floor(s/2)+r):a,l=e.height-n;if(c.forEach((e,t)=>{o.push({x:e.x+Rn(97*i+t,.15),z:l+Rn(31*i+t,.05)})}),r-=c.length,i++,0===c.length)break}return{pearls:o,layers:i}}function On(e,t,n,o){if(0>=o)return[];const r=function(e,t,n){let o=n,r=0;for(;o>0&&60>r;){const n=Ln(e,t+.875*(1+2*r));o-=Math.max(1,Math.floor(2*n/Fn)),r++}return r}(e,t,o),i=Math.max(t,n-r*Fn)+.875,a=[];let s=0;for(let t=0;r>t&&o>s;t++){const n=i+Fn*t,r=Ln(e,n),c=Math.max(1,Math.floor(2*r/Fn)),l=(2*r-c*Fn)/(c+1),u=-r+l,d=e.height-n-.875-.1;for(let e=0;c>e&&o>s;e++)a.push({cx:u+(l+Fn)*e+.875,cy:d+.875,rotation:Rn(53*t+e,10)}),s++}return a}function qn(e,t){const n=Number(e);return Number.isFinite(n)?n:t}var Dn=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height)return{nodes:[]};const o=d(t.categoryAccessor??"name"),r=d(t.teaVolumeAccessor??"teaVolume"),i=d(t.bobaVolumeAccessor??"bobaVolume"),a=d(t.iceVolumeAccessor??"iceVolume"),s=d(t.cupHeightAccessor??"cupHeight"),c=d(t.cupTopRadiusAccessor??"cupTopRadius"),l=d(t.cupBottomRadiusAccessor??"cupBottomRadius"),u=d(t.bobaRadiusAccessor??"bobaRadius"),h=t.cupWidthRatio??.82,f=e.scales.o,m=f.bandwidth(),p=Math.max(1,n.height-26-8),g=n.y+8,y=[],x=[];for(const t of e.data){const n=o(t)+"",d=f(n);if(null==d)continue;const b={height:qn(s(t),15.5),topRadius:qn(c(t),4.75),bottomRadius:qn(l(t),3.75)},w=qn(u(t),.6),M=Math.max(0,qn(r(t),450)),$=Math.max(0,qn(i(t),110)),A=Math.max(0,qn(a(t),135)),S=Math.PI*w*w,I=Math.floor($/S),j=I*S,C=Math.floor(A/5.359375),N=C*Fn*Fn*Fn,F=M+j+N,z=Tn(b,F),L=Math.min(b.height,Math.max(0,z)),E=Ln(b,L),{pearls:T,layers:R}=Wn(b,w,I),P=L,W=On(b,R*w*2,P,C),O=b.height-20.32,q=Math.min(0,O),D=Math.min(m*h/(2*(b.topRadius+1)),p/(b.height-q)),B=d+m/2,Y=e=>B+e*D,G=e=>g+(e-q)*D,H=Y(-(b.topRadius+1)),_=Y(b.topRadius+1),V=G(q),X=G(b.height),U=v({name:n,teaVolume:M,bobaVolume:Math.round(j),iceVolume:Math.round(N),totalVolume:Math.round(F),numBobas:I,numIce:C,kind:"boba cup"});y.push({type:"rect",x:H,y:V,w:Math.max(1,_-H),h:Math.max(1,X-V),style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:U,group:n,_transitionKey:"boba-"+k(n)});const K=b.height-P,Q=k(n),Z=e.resolveColor(n);x.push((0,Nn.jsxs)("g",{children:[M>0?(0,Nn.jsx)("path",{d:`M${Y(-E)},${G(K)} L${Y(-b.bottomRadius)},${G(b.height)} L${Y(b.bottomRadius)},${G(b.height)} L${Y(E)},${G(K)} z`,fill:"#D2B799"}):null,T.map((e,t)=>(0,Nn.jsx)("circle",{cx:Y(e.x),cy:G(e.z),r:w*D,fill:"#222222",opacity:.5},"p-"+t)),W.map((e,t)=>(0,Nn.jsx)("rect",{x:Y(e.cx)-.95*Fn*D/2,y:G(e.cy)-.95*Fn*D/2,width:.95*Fn*D,height:.95*Fn*D,rx:2,fill:"#a5f2f3",opacity:.85,transform:`rotate(${e.rotation} ${Y(e.cx)} ${G(e.cy)})`},"i-"+t)),(0,Nn.jsx)("path",{d:`M${Y(-b.topRadius)},${G(0)} L${Y(-b.bottomRadius)},${G(b.height)} L${Y(b.bottomRadius)},${G(b.height)} L${Y(b.topRadius)},${G(0)}`,fill:"none",stroke:zn,strokeWidth:2.5}),(0,Nn.jsx)("line",{x1:Y(-(b.topRadius+1)),y1:G(0),x2:Y(b.topRadius+1),y2:G(0),stroke:zn,strokeWidth:3,strokeLinecap:"round"}),M>0?(0,Nn.jsx)("path",{d:`M${Y(-.635)},${G(O)} L${Y(-.635)},${G(b.height-.4)} L${Y(.635)},${G(b.height-1.27-.4)} L${Y(.635)},${G(O)} z`,fill:"#4F91CB",stroke:zn,strokeWidth:1,opacity:.78}):null,(0,Nn.jsx)("text",{x:B,y:X+16,textAnchor:"middle",fontSize:12,fontWeight:600,fill:"var(--semiotic-text, #333)",children:n}),(0,Nn.jsx)("text",{x:B,y:X+30,textAnchor:"middle",fontSize:10,fill:Z,children:`${I} pearls · ${Math.round(F)} cm³`})]},"boba-"+Q))}return{nodes:y,overlays:(0,Nn.jsx)("g",{className:"semiotic-boba",style:{pointerEvents:"none"},children:x})}};function Bn(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 Yn(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 Gn(e){return null==e?null:e+""}function Hn(e,t,n){return t.stickyPositionCache?.set(e,n),n}var _n=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function Vn(e){return!!e&&"object"==typeof e&&_n.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}new Set(["label","callout","callout-circle","callout-rect"]);var Xn=2e4,Un=1;function Kn(e){return"primary"===e?.emphasis||!0===e?.defensive}function Qn(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:Xn))):1/0}function Zn(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const o=e?.provenance?.confidence;switch("number"==typeof o&&Number.isFinite(o)&&(t+=15*Math.max(0,Math.min(1,o))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}function Jn(e){const{annotations:t,width:n,height:o}=e,r=Math.max(0,e.minVisible??Un),i=Qn(n,o,e),a=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,Vn(n))};var n}),s=a.filter(e=>e.note);if(0===s.length||i>=s.length)return{visible:t.slice(),deferred:[],budget:i};const c=s.filter(e=>Kn(e.annotation)),l=s.filter(e=>!Kn(e.annotation)).sort((e,t)=>Zn(t.annotation)-Zn(e.annotation)||e.index-t.index),u=Math.min(l.length,Math.max(Math.max(0,i-c.length),Math.max(0,r-c.length))),d=new Set([...c.map(e=>e.index),...l.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}}var eo=32,to=6,no=4,oo=8,ro=72,io=30,ao=-30,so=8,co=480,lo=3;var uo={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function ho(e){if(!fo(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 fo(e){return Vn(e)}function mo(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),o=e.split(/\s+/).filter(Boolean),r=[];let i="";for(const e of o)i&&i.length+e.length+1>n?(r.push(i),i=e):i=i?`${i} ${e}`:e;return i&&r.push(i),r}function po(e,t,n,o,r){const i=e+n,a=t+o;return Math.abs(n)>Math.abs(o)?{x:0>n?i-r.width-4:i+4,y:0>o?a-r.height:a,width:r.width,height:r.height}:{x:0>n?i-r.width:i,y:0>o?a-r.height-4:a+4,width:r.width,height:r.height}}function go(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function yo(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 xo(e,t,n,o,r,i,a,s){const c=go(e,a);let l=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,o){const r=Math.max(0,o-e.x),i=Math.max(0,o-e.y);return(r+Math.max(0,e.x+e.width-(t-o)))*e.height+(i+Math.max(0,e.y+e.height-(n-o)))*e.width}(c,r,i,s);for(const e of n)l+=12*yo(c,e);for(const e of o)l+=4*yo(c,e);return l}function bo(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const o=e.pointId??e.nodeId;if(null!=o&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===o);if(e)return{x:e.x,y:e.y}}const r=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(r)&&r.length>=2&&i){const e=r[0],t=r[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?function(e,t,n){const o=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===e.pointId)return Hn(t,n,{x:r.x,y:r.y})}const o=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],o=e.scales?.x??e.scales?.time,r=e.scales?.y??e.scales?.value;if(!o||!r)return null;const i=n[e.xAccessor||"x"],a=n[e.yAccessor||"y"];return null==i||null==a?null:{x:o(i),y:r(a)}}(n);return o?Hn(t,n,o):null}if("semantic"===o){const o=function(e,t,n){const o=function(e){return Gn(e.provenance?.stableId??e.stableId)}(e);if(!o)return null;const r=n.pointNodes?.find(e=>Gn(e.pointId)===o);if(r)return Hn(t,n,{x:r.x,y:r.y});const i=n.data?.find(e=>function(e){return Gn(e.stableId??e.id??e.provenance?.stableId)}(e)===o);if(!i)return null;const a=Bn(i,n),s=Yn(i,n);return null==a||null==s?null:Hn(t,n,{x:a,y:s})}(e,t,n);if(o)return o}let r=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(r=t.x,i=t.y)}if(null!=r&&null!=i||(r=Bn(e,n),i=Yn(e,n)),null!=r&&null!=i)return Hn(t,n,{x:r,y:i});if("sticky"===o){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}(e,t,n):{x:e.x,y:e.y}}function wo(e){const{annotations:t,context:n,defaultOffset:o=eo,notePadding:r=to,markPadding:i=no,edgePadding:a=oo,preserveManualOffsets:s=!0,routeLongConnectors:c=!0,connectorThreshold:l=ro,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:m,cohesion:p,audience:g}=e,y=n.width||0,x=n.height||0,b="object"==typeof m?m:{},w=b.breakpoint??co,M=!!m&&w>=y,v=M&&!1!==b.preferShortText?t.map(ho):t,k=M&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,$=d||M&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),A=M&&!f?b.responsive??{minWidth:w}:f,S=M&&!p?b.cohesion:p;if(0===v.length||0>=y||0>=x)return v.slice();const I=[],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 C=!1;const N=v.map((e,t)=>{if(!fo(e))return e;const i=bo(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=[...mo("string"==typeof e.title?e.title:void 0,t),...mo("string"==typeof e.label?e.label:void 0,t)],o=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*o)+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:io,dy:ao}}(e);return I.push(go(po(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),r)),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}]}(o)){const t=xo(po(i.x,i.y,e.dx,e.dy,u),e,I,j,y,x,r,a);f>t&&(h=e,f=t)}if(!h)return e;const m=go(po(i.x,i.y,h.dx,h.dy,u),r);I.push(m);const p=Math.hypot(h.dx,h.dy),g=c&&p>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return C=!0,{...e,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),F=C?N:v.slice();let z=F;if(h){let e=!1;const t=F.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)<so?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});z=e?t:F}{let e=!1;const t=z.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?uo[t.source]??t.source:null,o="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!o)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const r=[n,o].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${r})`)?e:{...e,label:i?`${i} (${r})`:`(${r})`}}(t);return n!==t&&(e=!0),n});z=e?t:z}const L=new Set;if(k){const e="object"==typeof k?k:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return lo;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?lo:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(g),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??Qn(y,x,e))*t))},{deferred:o}=Jn({annotations:z,width:y,height:x,...n});for(const e of o)L.add(e)}if(A&&("object"==typeof A&&"number"==typeof A.minWidth?A.minWidth:co)>=y)for(const e of z)fo(e)&&"secondary"===e.emphasis&&L.add(e);if(L.size>0)for(const e of z)!0===e?.defensive&&L.delete(e);let E;return E=0===L.size?z:$?z.map(e=>L.has(e)?{...e,_annotationDeferred:!0}:e):z.filter(e=>!L.has(e)),S?function(e,t){let n=!1;const o=e.map(e=>fo(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?o:e}(E,S):E}var Mo=["naturalGas","coal","nuclear","hydro","wind","solar","other"],vo={naturalGas:"Natural gas",coal:"Coal",nuclear:"Nuclear",hydro:"Hydro",wind:"Wind",solar:"Solar",other:"Other"},ko={tight:5,watch:12,comfortable:20};function $o(e,t=0){return"number"==typeof e&&Number.isFinite(e)?e:t}function Ao(e,t={}){const n=t.fuels??Mo,o=!0===t.includeZero,r=[];for(const t of e)if(t&&"number"==typeof t.t)for(const e of n){const n=$o(t.fuels?.[e]);(o||n>0)&&r.push({t:t.t,fuel:e,fuelLabel:vo[e],mw:n,ba:t.ba})}return r}function So(e){const t=[];for(const n of e){if(!n||"number"!=typeof n.t)continue;const e=$o(n.demandMw),o=n.forecastMw;"number"==typeof o&&Number.isFinite(o)&&t.push({t:n.t,a:e,b:o,demandMw:e,forecastMw:o,errorMw:e-o,ba:n.ba})}return t}function Io(e){const t=$o(e.demand);if(0>=t)return 0;const n=$o(e.capacityOrNetGen),o=$o(e.interchange);return(n+(0>o?-o:0)-t)/t*100}function jo(e){return e.filter(e=>e&&"number"==typeof e.t).map(e=>{const t=$o(e.demandMw),n=$o(e.netGenMw),o=Io({demand:t,capacityOrNetGen:n,interchange:e.interchangeMw});return{t:e.t,ba:e.ba,reserveMarginPct:o,netLoadMw:t,demandMw:t,netGenMw:n}})}function Co(e={},t={}){const{watch:n,comfortable:o}={...ko,...e},r=t.field,i=r?{field:r}:{},a=t.tightHatch??{type:"hatch",background:"var(--semiotic-danger, #c2410c)",stroke:"rgba(255, 240, 200, 0.55)",spacing:5,angle:-35,lineWidth:1.25,lineOpacity:.9};return[{id:"reserve-comfortable",label:`Comfortable (≥ ${o}%)`,when:{...i,gte:o},style:{fill:t.comfortableFill??"var(--semiotic-success, #16a34a)",fillOpacity:.85}},{id:"reserve-watch",label:`Watch (< ${o}%, ≥ ${n}%)`,when:{...i,lt:o,gte:n},style:{fill:t.watchFill??"var(--semiotic-warning, #d97706)",fillOpacity:.9}},{id:"reserve-tight",label:`Tight (< ${n}%)`,when:{...i,lt:n},style:{fill:a,stroke:t.tightFill??"var(--semiotic-danger, #c2410c)",strokeWidth:1,fillOpacity:1}}]}function No(e={}){const{tight:t,watch:n,comfortable:o}={...ko,...e};return[{type:"band",y0:-50,y1:t,label:"Tight",color:"var(--semiotic-danger, #c2410c)",fillOpacity:.12,emphasis:"secondary"},{type:"band",y0:t,y1:n,label:"Watch",color:"var(--semiotic-warning, #d97706)",fillOpacity:.1,emphasis:"secondary"},{type:"band",y0:n,y1:Math.max(o+30,40),label:"Headroom",color:"var(--semiotic-success, #16a34a)",fillOpacity:.06,emphasis:"secondary"}]}function Fo(e,t){if(!e.length)return null;const n=[...e].filter(e=>e&&"number"==typeof e.t).sort((e,t)=>e.t-t.t);if(!n.length)return null;let o=n[n.length-1];if("number"==typeof t&&Number.isFinite(t)){const e=n.filter(e=>t>=e.t);o=e.length?e[e.length-1]:n[0]}const r=$o(o.demandMw),i=$o(o.netGenMw),a="number"==typeof o.forecastMw&&Number.isFinite(o.forecastMw)?o.forecastMw:null,s=Io({demand:r,capacityOrNetGen:i,interchange:o.interchangeMw}),c={};let l=null,u=0,d=0;for(const e of Mo){const t=$o(o.fuels?.[e]);t>0&&(d+=t,c[e]=t,t>u&&(u=t,l=e))}if(d>0)for(const e of Object.keys(c))c[e]=c[e]/d;return{t:o.t,ba:o.ba,demandMw:r,forecastMw:a,forecastErrorMw:null==a?null:r-a,netGenMw:i,reserveMarginPct:s,topFuel:l,topFuelShare:d>0?u/d:0,topFuelMw:u,fuelShares:c}}function zo(e,t={}){const n=t.now??Date.now(),o=t.author??"system",r=t.source??"authored-scenario";return e.map(e=>{const t=(e.start+e.end)/2,i=new Date(e.start).toISOString();return{type:"x-band",x0:e.start,x1:e.end,label:e.label,color:"outage"===e.kind?"var(--semiotic-danger)":"var(--semiotic-warning)",fillOpacity:.12,emphasis:"secondary",x:t,y:e.y??e.value,note:e.note,provenance:{author:o,authorKind:"system",source:r,basis:"rule",confidence:.85,createdAt:i,stableId:e.id,dataVersion:e.start+""},lifecycle:{status:"accepted",ttlHint:e.ttlHint??"P14D",anchor:"fixed"},_eventKind:e.kind,_createdAtMs:e.start,_nowMs:n}})}function Lo(e,t=12){return[...e].filter(e=>Number.isFinite(e.reserveMarginPct)).sort((e,t)=>e.reserveMarginPct-t.reserveMarginPct).slice(0,Math.max(0,t))}function Eo(e,t=0){return Number.isFinite(e)?e.toLocaleString(void 0,{maximumFractionDigits:t,minimumFractionDigits:t})+" MW":"—"}function To(e,t=1){return Number.isFinite(e)?`${e>0?"+":""}${e.toFixed(t)}%`:"—"}var Ro=c(require("react"));function Po(e,t){if("function"==typeof e)return e;const n=e??t;return e=>Number(e[n])}function Wo(e,t={}){const n=Po(t.start,"start"),o=Po(t.end,"end"),r=!1===t.sort?e.slice():e.slice().sort((e,t)=>n(e)-n(t)||o(t)-o(e)),i=[];return{packed:r.map(e=>{const t=n(e);let r=i.findIndex(e=>t>=e);return-1===r&&(r=i.length),i[r]=o(e),{item:e,track:r}}),trackCount:Math.max(1,i.length)}}function Oo(e,t){const n=Po(t.start,"start"),o=Po(t.end,"end"),[r,i]=t.domain,a=t.step??1,s="half-open"===t.bounds,c=[];for(let t=r;i>=t;t+=a){let r=0;for(const i of e){const e=n(i),a=o(i);e>t||(s?t>=a:t>a)||r++}c.push({value:t,count:r})}return c}function qo(e){return"function"==typeof e?e:t=>t[e]}var Do=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height||0===e.data.length||!t?.domain)return{nodes:[]};const o=qo(t.laneAccessor),r=qo(t.startAccessor),i=qo(t.endAccessor),a=t.idAccessor?qo(t.idAccessor):null,s=t.unit??0,c=t.barGap??1.5,l=Math.max(0,t.minBarWidth??2),u=t.minBarHeight??3.5,d=t.maxBarHeight??10,h=t.lanePadding??7,f=t.cornerRadius??2,m=t.bottomInset??0,p=t.color??((t,n)=>e.resolveColor(n)),[g,y]=t.domain,x=y-g||1,b=e=>n.x+(e-g)/x*n.width,w=e.scales?.o?.domain?.()??[],M=t.lanes??(w.length>0?w:[...new Set(e.data.map(o))]),v=Math.max(0,n.height-m)/Math.max(1,M.length),k=e=>b(r(e)),$=e=>Math.max(k(e)+l,b(i(e)+s)),A=[];M.forEach((t,r)=>{const i=n.y+r*v,s=e.data.filter(e=>o(e)===t);if(0===s.length)return;const{packed:l,trackCount:m}=Wo(s,{start:k,end:$}),g=new Map,y=new Map;for(const{item:e,track:t}of l){const n=y.get(t);n?n.push(e):y.set(t,[e])}for(const e of y.values()){e.sort((e,t)=>k(e)-k(t));for(let t=0;e.length-1>t;t++)g.set(e[t],k(e[t+1]))}const x=(v-2*h)/m,b=Math.min(d,Math.max(Math.min(u,x),x-c));for(const{item:e,track:n}of l){const o=k(e),r=g.get(e),s=$(e)-o;A.push({type:"rect",x:o,y:i+h+n*x,w:void 0!==r&&o+s>r-1?Math.max(1,r-1-o):s,h:b,cornerRadii:f>0?{tl:f,tr:f,br:f,bl:f}:void 0,style:{fill:p(e,t),stroke:"none"},datum:e,group:t,_transitionKey:a?a(e)+"":void 0})}});const S=`var(--semiotic-text, ${e.theme.semantic.text??"#1a1a1a"})`,I=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,j=`var(--semiotic-border, ${e.theme.semantic.border??"#94a3b8"})`,C=[];(t.periods??[]).forEach((e,t)=>{const o=b(e.start),r=Math.max(1,b(e.end+s)-o);C.push(Ro.createElement("rect",{key:"period-"+t,x:o,y:n.y,width:r,height:n.height,fill:j,opacity:t%2==0?.06:.025,pointerEvents:"none"})),e.name&&C.push(Zt({keyId:"period-label-"+t,text:e.name,x:o+4,y:n.y+12,anchor:"start",baseline:"hanging",fontSize:13,fontWeight:700,color:I}))});const N=!1!==t.showLaneLabels,F=t.laneLabelGap??12;if(M.forEach((e,t)=>{const o=n.y+t*v;C.push(Ro.createElement("line",{key:"lane-sep-"+t,x1:n.x,x2:n.x+n.width,y1:o,y2:o,stroke:j,opacity:.45})),N&&C.push(Zt({keyId:"lane-label-"+t,text:e,x:n.x-F,y:o+v/2,anchor:"end",baseline:"middle",fontSize:12,fontWeight:600,color:S}))}),!1!==t.showAxis){const e=t.axisTicks??Array.from({length:8},(e,t)=>Math.round(g+t/7*x));C.push(en({keyId:"interval-axis",scale:b,ticks:e,orient:"top",offset:n.y,tickLength:0,gridLength:n.height,gridDasharray:"3 5",edgeAnchor:!0,format:t.tickFormat,color:I}))}return{nodes:A,overlays:Ro.createElement(Ro.Fragment,null,...C)}};function Bo(e,t,n){const o=n?.orientation??"vertical",r=n?.bend??0,i=n?.minAlong??18,a=(e,t)=>(e+t)/2;if("vertical"===o){if(i>Math.abs(t.y-e.y)){const n=e.x>t.x?-1:1,o=a(e.x,t.x)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${o},${a(e.y,t.y)} ${t.x},${t.y}`}const n=a(e.y,t.y)+r;return`M${e.x},${e.y} C${e.x},${n} ${t.x},${n} ${t.x},${t.y}`}if(i>Math.abs(t.x-e.x)){const n=e.y>t.y?-1:1,o=a(e.y,t.y)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${a(e.x,t.x)},${o} ${t.x},${t.y}`}const s=a(e.x,t.x)+r;return`M${e.x},${e.y} C${s},${e.y} ${s},${t.y} ${t.x},${t.y}`}function Yo(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=(e.y+t.y)/2;return`M${e.x},${e.y} L${e.x},${n} L${t.x},${n} L${t.x},${t.y}`}const o=(e.x+t.x)/2;return`M${e.x},${e.y} L${o},${e.y} L${o},${t.y} L${t.x},${t.y}`}function Go(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=t.cy>=e.cy;return{from:{x:e.cx,y:e.cy+(n?e.height/2:-e.height/2)},to:{x:t.cx,y:t.cy+(n?-t.height/2:t.height/2)}}}const o=t.cx>=e.cx;return{from:{x:e.cx+(o?e.width/2:-e.width/2),y:e.cy},to:{x:t.cx+(o?-t.width/2:t.width/2),y:t.cy}}}function Ho(e,t){const n=t?.spread??5;return t?.modulo&&t.modulo>0?(e%t.modulo-(t.modulo-1)/2)*n:(e-((t?.count??1)-1)/2)*n}function _o(e,t){const n=1-t,o=n*n*n,r=3*n*n*t,i=3*n*t*t,a=t*t*t;return{x:o*e.p0.x+r*e.p1.x+i*e.p2.x+a*e.p3.x,y:o*e.p0.y+r*e.p1.y+i*e.p2.y+a*e.p3.y}}function Vo(e,t){const n=1-t,o=3*n*n,r=6*n*t,i=3*t*t;return{x:o*(e.p1.x-e.p0.x)+r*(e.p2.x-e.p1.x)+i*(e.p3.x-e.p2.x),y:o*(e.p1.y-e.p0.y)+r*(e.p2.y-e.p1.y)+i*(e.p3.y-e.p2.y)}}function Xo(e){return`M${e.p0.x},${e.p0.y} C${e.p1.x},${e.p1.y} ${e.p2.x},${e.p2.y} ${e.p3.x},${e.p3.y}`}function Uo(e,t){const n=t?.axis??"x",o=t?.padding??0,r=t?.strength??.5,i="x"===n?"y":"x",a="x"===n?"width":"height",s="x"===n?"height":"width",c=new Map;for(const t of e)c.set(t.id,0);for(let t=0;e.length>t;t++)for(let l=t+1;e.length>l;l++){const u=e[t],d=e[l];if(Math.abs(u[i]-d[i])>(u[s]+d[s])/2+o)continue;const h=d[n]-u[n]||(d.id>u.id?-.5:.5),f=(u[a]+d[a])/2+o-Math.abs(h);if(0>=f)continue;const m=f*r*Math.sign(h);c.set(u.id,(c.get(u.id)??0)-m),c.set(d.id,(c.get(d.id)??0)+m)}return c}var Ko={width:60,height:34};function Qo(e,t){if("function"==typeof e)return e;const n=e??t;return e=>h(e,n,void 0)}function Zo(e,t,n,o){const r=o.fixedAxis??"y",i=e=>Qo(o.sourceAccessor,"source")(e)+"",a=e=>Qo(o.targetAccessor,"target")(e)+"",s=o.size??(()=>Ko),c=o.iterations??180,l=o.attraction??.012,u=o.anchorStrength??.003,d=o.collisionStrength??.12,h=o.collisionPadding??15,m=o.edgePadding??42,p=o.fixedPadding??16,g=o.damping??.72,y=o.spread??1,[x,b]=o.fixedDomain,w=b-x||1,M=("y"===r?n.y:n.x)+p,v=("y"===r?n.y+n.height:n.x+n.width)-p,k=("y"===r?n.x:n.y)+m,$=("y"===r?n.x+n.width:n.y+n.height)-m,A=Math.max(1,$-k),S=e.map(e=>{const t=f(e)??e,n=(r=e,Qo(o.idAccessor,"id")(r)+"");var r;const{width:i,height:a}=s(t),c=(e=>Number(Qo(o.fixedAccessor,"fixed")(e)))(e),l=k+function(e){let t=2166136261;for(let n=0;e.length>n;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0)/4294967295}(n)*A;return{data:t,id:n,width:i,height:a,fixedValue:c,fixed:(u=c,M+(u-x)/w*(v-M)),free:l,anchor:l};var u}),I=new Map(S.map(e=>[e.id,e])),j=e=>"y"===r?e.width:e.height;for(let e=0;c>e;e++){const e=new Map;for(const t of S)e.set(t.id,0);for(const n of t){const t=I.get(i(n)),o=I.get(a(n));if(!t||!o)continue;const r=(o.free-t.free)*l;e.set(t.id,(e.get(t.id)??0)+r),e.set(o.id,(e.get(o.id)??0)-r)}for(const t of S)e.set(t.id,(e.get(t.id)??0)+(t.anchor-t.free)*u);const n=Uo(S.map(e=>({id:e.id,x:"y"===r?e.free:e.fixed,y:"y"===r?e.fixed:e.free,width:e.width,height:e.height})),{axis:"y"===r?"x":"y",padding:h,strength:d});for(const t of S)e.set(t.id,(e.get(t.id)??0)+(n.get(t.id)??0));for(const t of S){t.free+=(e.get(t.id)??0)*g;const n=j(t)/2;t.free=Math.max(k+n,Math.min($-n,t.free))}}if(1!==y){const e=(k+$)/2;for(const t of S){const n=j(t)/2;t.free=Math.max(k+n,Math.min($-n,e+(t.free-e)*y))}}const C=S.map(e=>({data:e.data,id:e.id,x:"y"===r?e.free:e.fixed,y:"y"===r?e.fixed:e.free,width:e.width,height:e.height,fixedValue:e.fixedValue}));return{positioned:C,byId:new Map(C.map(e=>[e.id,e]))}}var Jo=e=>{const{plot:t}=e.dimensions;if(0>=t.width||0>=t.height||0===e.nodes.length||!e.config?.fixedDomain)return{sceneNodes:[]};const n=e.config.fixedAxis??"y",{positioned:o,byId:r}=Zo(e.nodes,e.edges,t,e.config),i=o.map(t=>({type:"rect",x:t.x-t.width/2,y:t.y-t.height/2,w:t.width,h:t.height,style:{fill:e.resolveColor(t.id),stroke:"none"},datum:t.data,id:t.id,label:t.id})),a=[];e.edges.forEach((t,o)=>{const i=r.get((s=t,("function"==typeof e.config.sourceAccessor?e.config.sourceAccessor(s):h(s,e.config.sourceAccessor??"source",void 0))+""));var s;const c=r.get((t=>("function"==typeof e.config.targetAccessor?e.config.targetAccessor(t):h(t,e.config.targetAccessor??"target",void 0))+"")(t));if(!i||!c)return;const{from:l,to:u}=Go({cx:i.x,cy:i.y,width:i.width,height:i.height},{cx:c.x,cy:c.y,width:c.width,height:c.height},{orientation:"y"===n?"vertical":"horizontal"});a.push({type:"curved",pathD:Bo(l,u,{orientation:"y"===n?"vertical":"horizontal",bend:Ho(o,{modulo:5,spread:5})}),style:{stroke:"var(--semiotic-border, #888)",fill:"none",strokeWidth:1.4},datum:f(t)??t})});const s=o.map(e=>({x:e.x,y:e.y,text:e.id}));return{sceneNodes:i,sceneEdges:a,labels:s}};function er(e){const t=Number(e.segmentDomain?.[0]),n=Number(e.segmentDomain?.[1]),o=Number.isFinite(t)?t:0,r=Number.isFinite(n)?n:o,i=o>r?-1:1,a=Math.abs(r-o),s=Number(e.currentSegment),c=Number.isFinite(s)?$((s-o)*i,0,a):0,l=(e,t)=>{const n=Number(e);return Number.isFinite(n)?$(n,0,1):t},u=l(e.oldestOpacity,.25),d=l(e.currentOpacity,1),h=l(e.futureOpacity,0);return{weightOpacity:!0===e.combineWeightOpacity,wordOpacity:({segment:e})=>{const t=Number(e);if(!Number.isFinite(t))return h;const n=(t-o)*i;if(n>c)return h;if(0===c)return d;const r=$(n/c,0,1);return u+(d-u)*r}}}var tr=require("react/jsx-runtime");function nr(e){let t=2166136261;for(let n=0;e.length>n;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0)/4294967295}var or=1.15,rr={a:.556,b:.556,c:.5,d:.556,e:.556,f:.278,g:.556,h:.556,i:.222,j:.222,k:.5,l:.222,m:.833,n:.556,o:.556,p:.556,q:.556,r:.333,s:.5,t:.278,u:.556,v:.5,w:.722,x:.5,y:.5,z:.5,"'":.191,"-":.333,".":.278," ":.278};function ir(e){let t=0;for(const n of e)t+=rr[n]??.6;return t}function ar(e,t){return Math.max(8,ir(e)*t*1.05+1)}function sr(e,t,n){for(const o of t)if((e.w+o.w)/2+n>Math.abs(e.x-o.x)&&(e.h+o.h)/2+n>Math.abs(e.y-o.y))return!0;return!1}var cr=e=>{const t=e.config,{plot:n}=e.dimensions;if(0>=n.width||0>=n.height||0===e.data.length)return{nodes:[]};const o=d(t.textAccessor),r=e=>{const n=Number(d(t.weightAccessor)(e));return Number.isFinite(n)&&n>0?n:0},i=d(t.columnAccessor),a=e=>Number(d(t.segmentAccessor)(e)),s=t.minFontSize??11,c=t.maxFontSize??42,l=t.columnGutter??18,u=t.collisionPadding??2,h=!1!==t.showColumnLabels,f=!1!==t.showSegmentAxis,m=t.segmentTickCount??6,g=t.segmentTickFormat??(e=>Math.round(e)+""),y=t.rotate??0,x=!0===t.repeatWords,b=!1!==t.scaleToFit,w=t.packingDensity??.6,M="string"==typeof t.textAccessor?t.textAccessor:"word",v="string"==typeof t.weightAccessor?t.weightAccessor:"weight",k="string"==typeof t.columnAccessor?t.columnAccessor:"column",A="string"==typeof t.segmentAccessor?t.segmentAccessor:"segment",S=[],I=new Map;let j=1/0,C=-1/0;for(let t=0;e.data.length>t;t++){const n=e.data[t],s=i(n)+"",c=o(n)+"",l=r(n),u=a(n);c&&Number.isFinite(u)&&(I.has(s)||(S.push(s),I.set(s,[])),I.get(s).push({col:s,text:c,weight:l,segment:u,datum:n,dataIndex:t}),j>u&&(j=u),u>C&&(C=u))}if(0===S.length)return{nodes:[]};if(!x)for(const[e,t]of I){const n=new Map;for(const e of t){const t=n.get(e.text);t&&t.weight>=e.weight||n.set(e.text,e)}I.set(e,[...n.values()])}let N=1/0,F=-1/0;for(const e of I.values())for(const t of e)N>t.weight&&(N=t.weight),t.weight>F&&(F=t.weight);if(!Number.isFinite(N))return{nodes:[]};const z=t.columnOrder?[...t.columnOrder.filter(e=>I.has(e)),...S.filter(e=>!t.columnOrder.includes(e))]:S,L=new Map(z.map(n=>[n,t.columnColor?.(n)||e.resolveColor(n)])),[E,T]=t.segmentDomain??[j,C],R=T-E||1,P=F-N||1,W=h?22:0,O=f?52:0,q=n.x+O,D=n.y+W,B=Math.max(0,n.width-O),Y=Math.max(0,n.height-W),G=z.length,H=G>0?Math.max(0,B-l*Math.max(0,G-1))/G:0,_=D+14,V=D+Y-14,X=e=>_+(e-E)/R*(V-_),U=H*Y;let K=1/0,Q=1/0;const Z=z.map((e,n)=>{const o=L.get(e),r=(I.get(e)??[]).map(e=>{const r={word:e.text,column:e.col,weight:e.weight,segment:e.segment,datum:e.datum,dataIndex:e.dataIndex,columnIndex:n,resolvedColumnColor:o},i=t.wordOpacity?Number(t.wordOpacity(r)):1,a=t.wordColor?.(r);return{text:e.text,weight:e.weight,segment:e.segment,baseFont:(l=e.weight,s+Math.sqrt((l-N)/P)*(c-s)),opacity:Number.isFinite(i)?$(i,0,1):0,color:a||o,info:r};var l});if(0===r.length)return null;let i=0;for(const e of r){const t=1.05*ir(e.text);i+=t*or*e.baseFont*e.baseFont,Q=Math.min(Q,(H-8-1)/(t*e.baseFont))}return i>0&&(K=Math.min(K,Math.sqrt(w*U/i))),{col:e,colLeft:q+n*(H+l),center:q+n*(H+l)+H/2,rows:r}}).filter(e=>null!==e),J=e=>{const t=[];let n=0;for(const o of Z){if(0>=H)continue;const r=o.colLeft+4,i=o.colLeft+H-4,a=o.rows.map((t,n)=>{const r=Math.max(5,e*t.baseFont),i=`${o.col}::${t.text}::${n}`;return{id:i,text:t.text,weight:t.weight,segment:t.segment,font:r,w:ar(t.text,r),h:r*or+2,anchorY:X(t.segment),seed:(nr(i)-.5)*Math.min(.5*H,80),opacity:t.opacity,color:t.color,info:t.info}}).sort((e,t)=>t.font-e.font||(t.id>e.id?-1:1)),s=[];for(const e of a){const a=e.w/2,c=e.h/2,l=$(o.center+e.seed,r+a,i-a),d=e.anchorY;let h=l,f=$(d,_+c,V-c),m=!1;for(let t=0;2600>t;t++){const n=3.2*Math.sqrt(t),o=2.399963229728653*t,p={x:$(l+n*Math.cos(o),r+a,i-a),y:$(d+n*Math.sin(o),_+c,V-c),w:e.w,h:e.h};if(!sr(p,s,u)){h=p.x,f=p.y,m=!0;break}}m||n++,s.push({x:h,y:f,w:e.w,h:e.h});const g=Math.sqrt((e.weight-N)/P),x=y>0?2*(nr(e.id+"r")-.5)*y:0;t.push({id:e.id,text:e.text,x:h,y:f,fontSize:e.font,rotation:x,color:e.color,opacity:e.opacity,datum:p(t=>{for(const n of Object.keys(e.info.datum))t(n,e.info.datum[n]);t("word",e.text),t("weight",e.weight),t("column",o.col),t("segment",e.segment),"word"!==M&&t(M,e.text),"weight"!==v&&t(v,e.weight),"column"!==k&&t(k,o.col),"segment"!==A&&t(A,e.segment),t("__strength",.5+.5*g)})})}}return{placed:t,unplaced:n}};let ee=b?Math.min(1,K,Q):Math.min(1,Q),te=J(ee);if(b)for(let e=0;6>e&&te.unplaced>0&&ee>.1;e++)ee*=.88,te=J(ee);const ne=te.placed.filter(e=>e.opacity>0);return{nodes:ne.map(e=>{const t=ar(e.text,e.fontSize)/2,n=e.fontSize*or/2;return{type:"rect",x:e.x-t,y:e.y-n,w:2*t,h:2*n,style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:e.datum,group:e.datum.column+"",_transitionKey:e.id}}),overlays:(0,tr.jsxs)("g",{className:"semiotic-word-trails",children:[f&&lr({x:n.x+O-10,yTop:_,yBot:V,segLo:E,segHi:T,segToY:X,tickCount:m,tickFormat:g,color:`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,label:t.segmentAxisLabel,labelX:n.x}),h&&z.map((e,t)=>H>0?(0,tr.jsx)("text",{x:q+t*(H+l)+H/2,y:n.y+14,textAnchor:"middle",fontSize:13,fontWeight:600,fill:L.get(e),style:{pointerEvents:"none"},children:e},"wt-col-"+t):null),ne.map(e=>(0,tr.jsx)("text",{x:e.x,y:e.y,textAnchor:"middle",dominantBaseline:"central",fontSize:e.fontSize,fontWeight:600,fill:e.color,opacity:(!1===t.weightOpacity?1:Number(e.datum.__strength))*e.opacity,transform:e.rotation?`rotate(${e.rotation} ${e.x} ${e.y})`:void 0,style:{pointerEvents:"none"},children:e.text},"wt-"+e.id))]})}};function lr(e){const t=[],n=e.segHi-e.segLo||1;for(let o=0;e.tickCount>o;o++)t.push(e.segLo+n*o/Math.max(1,e.tickCount-1));return(0,tr.jsxs)("g",{className:"semiotic-word-trails-axis",style:{pointerEvents:"none"},children:[(0,tr.jsx)("line",{x1:e.x,y1:e.yTop,x2:e.x,y2:e.yBot,stroke:e.color,strokeWidth:1,opacity:.5}),t.map((t,n)=>{const o=e.segToY(t);return(0,tr.jsxs)("g",{children:[(0,tr.jsx)("line",{x1:e.x-4,y1:o,x2:e.x,y2:o,stroke:e.color,strokeWidth:1,opacity:.6}),(0,tr.jsx)("text",{x:e.x-7,y:o,textAnchor:"end",dominantBaseline:"central",fontSize:11,fill:e.color,children:e.tickFormat(t)})]},"wt-tick-"+n)}),e.label&&(0,tr.jsx)("text",{transform:`rotate(-90 ${e.labelX+10} ${(e.yTop+e.yBot)/2})`,x:e.labelX+10,y:(e.yTop+e.yBot)/2,textAnchor:"middle",fontSize:11,fontWeight:600,fill:e.color,children:e.label})]})}var ur={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},dr=8;function hr(e){return null==e?void 0:e+""}function fr(e){const t=hr(e.id);return{type:"point",x:e.x,y:e.y,r:e.r??dr,style:{...ur},datum:e.datum,pointId:t,_transitionKey:t}}function mr(e){return fr(e)}function pr(e){const[[t,n],[o,r]]=e.bounds;return{type:"geoarea",pathData:e.pathData,centroid:e.centroid,bounds:e.bounds,screenArea:e.screenArea??Math.abs((o-t)*(r-n)),style:{...ur},datum:e.datum,group:e.group,interactive:!0}}function gr(e){return{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...ur},datum:e.datum,group:e.group,_transitionKey:hr(e.id)}}function yr(e){const t=hr(e.id);return"width"in e&&"height"in e?{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...ur},datum:e.datum,id:t,label:e.label}:{type:"circle",cx:e.x,cy:e.y,r:e.r??dr,style:{...ur},datum:e.datum,id:t,label:e.label}}function xr(e,t,n={}){const{coord:o,step:r=1,equals:i=Object.is,truthyOnly:a=!1}=n,s=[],c=t=>o?o(e[t],t):t,l=(e,t,n)=>{e.endIndex=t,e.count=t-e.startIndex+1,e.end=o?null==n||c(n)-c(t)>r?c(t)+r:c(n):t+1,s.push(e)};let u=null;for(let n=0;e.length>n;n++){const s=t(e[n],n);if(a&&!s){u&&(l(u,u.endIndex,n),u=null);continue}const d=!o||0>=n||c(n)-c(n-1)<=r;u&&d&&i(u.value,s)?u.endIndex=n:(u&&l(u,u.endIndex,n),u={value:s,start:c(n),end:c(n),count:1,startIndex:n,endIndex:n})}return u&&l(u,u.endIndex,null),s}var br=xr;function wr(e,t,n=0){return t>0?((e-n)%t+t)%t+n:e}function Mr(e,t,n){if(0>=n)return t-e;let o=(t-e)%n;return o>n/2?o-=n:-n/2>o&&(o+=n),o}function vr(e,t,n){return t>n?e>=t||n>=e:e>=t&&n>=e}function kr(e,t,n,o){return n>o?[...e.filter(e=>t(e)>=n),...e.filter(e=>t(e)<=o)]:e.filter(e=>vr(t(e),n,o))}function $r(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,a=e.length>1?Math.max(0,n-i-(t.paddingRight??r))/(e.length-1):0,s=new Map;return e.forEach((e,t)=>{s.set(e.id,{id:e.id,x:i+a*t,y:o,index:t})}),s}function Ar(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,a=t.paddingRight??r,s=t.gap??8,c=!1!==t.distribute,l=t.estimateWidth??(e=>Sr(e.label??e.id)),u=e.map((e,t)=>Math.max(1,l(e,t))),d=u.reduce((e,t)=>e+t,0)+s*Math.max(0,e.length-1),h=Math.max(0,n-i-a),f=c&&e.length>1?Math.max(0,h-d)/(e.length-1):0,m=new Map;let p=i;return c||1!==e.length||(p=i+Math.max(0,(h-u[0])/2)),e.forEach((e,t)=>{const n=u[t];m.set(e.id,{id:e.id,x:p+n/2,y:o,index:t,width:n}),p+=n+s+f}),m}function Sr(e,t=38,n=7.4,o=20){return Math.max(t,((e??"")+"").length*n+o)}function Ir(e){const t=e.map(e=>{const t=Math.min(e.a,e.b),n=Math.max(e.a,e.b);return{span:e,a:t,b:n,width:n-t}}).sort((e,t)=>e.width-t.width||e.a-t.a),n=[],o=t.map(e=>{let t=n.findIndex(t=>e.a>=t);return 0>t?(t=n.length,n.push(e.b)):n[t]=e.b,{span:e.span,level:t}}),r=o.reduce((e,t)=>Math.max(e,t.level),0);return{packed:o,maxLevel:r,levelCount:o.length?r+1:1}}function jr(e){const t=e.labelRoom??18,n=Math.max(48,e.baselineY-e.ceilingY-28),o=Math.max(1,e.levelCount),r=Math.min(42,Math.max(26,.18*n)),i=Math.max(24,n-r-t);return{arcLift:r,levelStep:Math.min(72,Math.max(28,o>1?i/Math.max(1,o-1):i))}}function Cr(e,t,n,o,r={}){const i=n-(r.footLift??26);return`M${e} ${i}Q${(e+t)/2} ${o} ${t} ${i}`}function Nr(e,t,n){return e-n.arcLift-t*n.levelStep}function Fr(e,t=zr){if(!e.length)return{shared:[],exclusive:[]};if(1===e.length)return{shared:[...e[0]],exclusive:[[]]};const n=e.map(e=>new Set(e.map(e=>t(e)))),o=new Set;for(const e of n[0])n.every(t=>t.has(e))&&o.add(e);const r=[],i=new Set;for(const n of e[0]){const e=t(n);o.has(e)&&!i.has(e)&&(r.push(n),i.add(e))}return{shared:r,exclusive:e.map(e=>e.filter(e=>!o.has(t(e))))}}function zr(e){return null==e||"object"!=typeof e?e+"":null!=e.id?e.id+"":`${(e.sourceTokenId??e.source)+""}|${(e.targetTokenId??e.target)+""}|${(e.relation??e.label??"")+""}`}var Lr=2*Math.PI;function Er(e,t,n){const o=n?.center?.x??0,r=n?.center?.y??0;return{x:o+Math.sin(e)*t,y:r-Math.cos(e)*t}}function Tr(e,t,n){return(Math.atan2(e-(n?.center?.x??0),-(t-(n?.center?.y??0)))+Lr)%Lr}function Rr(e,t){const[n,o]=e,r=o-n||1,i=t?.startAngle??0,a=t?.endAngle??Lr;return e=>i+(e-n)/r*(a-i)}function Pr(e,t){const[n,o]=e,[r,i]=t,a=o-n||1;return e=>r+(e-n)/a*(i-r)}function Wr(e,t,n,o,r){const i=r?.center,a=(e,t)=>{const{x:n,y:o}=Er(e,t,{center:i});return`${Or(n)},${Or(o)}`},s=Math.max(0,n),c=Math.max(s,o),l=Math.abs(t-e),u=e>t?0:1;if(l>=Lr-1e-6){const e=i?.x??0,t=i?.y??0,n=`${Or(e)},${Or(t-c)}`,o=`${Or(e)},${Or(t+c)}`;let r=`M${n} A${Or(c)},${Or(c)} 0 1 1 ${o} A${Or(c)},${Or(c)} 0 1 1 ${n} Z`;if(s>0){const n=`${Or(e)},${Or(t-s)}`,o=`${Or(e)},${Or(t+s)}`;r+=` M${n} A${Or(s)},${Or(s)} 0 1 0 ${o} A${Or(s)},${Or(s)} 0 1 0 ${n} Z`}return r}const d=l>Math.PI?1:0,h=a(e,c),f=a(t,c);if(0>=s){const e=i?.x??0,t=i?.y??0;return`M${Or(e)},${Or(t)} L${h} A${Or(c)},${Or(c)} 0 ${d} ${u} ${f} Z`}const m=a(t,s),p=a(e,s);return`M${h} A${Or(c)},${Or(c)} 0 ${d} ${u} ${f} L${m} A${Or(s)},${Or(s)} 0 ${d} ${1===u?0:1} ${p} Z`}function Or(e){return Math.round(1e3*e)/1e3}function qr(e,t){return{x:e.x+t.x,y:e.y+t.y}}function Dr(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Br(e,t){return{x:e.x*t,y:e.y*t}}function Yr(e){return Math.hypot(e.x,e.y)}function Gr(e){const t=Yr(e)||1;return{x:e.x/t,y:e.y/t}}var Hr=[40,40],_r=[.5,.5];function Vr(e,t){const[n,o]=e.viewBox??Hr,[r,i]=e.anchor??_r,a=o>0?o:1,s=Math.max(0,t)/a,c=(n>0?n:a)*s,l=a*s;return{width:c,height:l,scale:s,offsetX:-r*c,offsetY:-i*l}}function Xr(e,t){const n=Vr(e,t),o=[[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 r=0;for(const[e,t]of o){const n=Math.sqrt(e*e+t*t);n>r&&(r=n)}return r}function Ur(e,t,n,o){if("none"!==e)return"color"===e||null==e?t??o:"accent"===e?n:e}function Kr(e,t,n=0,o="horizontal"){const[r,i]=e.viewBox??Hr,a=Math.min(1,Math.max(0,n)),s=Math.min(1,Math.max(0,t));return s>a?a>0||1>s?"vertical"===o?{x:0,y:i*(1-s),width:r,height:i*(s-a)}:{x:r*a,y:0,width:r*(s-a),height:i}:null:{x:0,y:0,width:0,height:0}}var Qr=require("react/jsx-runtime"),Zr="var(--semiotic-text, currentColor)",Jr=8;function ei(e,t){const n=oe(e,100);return n>0?t/n*100*(t/n):Math.PI*t*t}function ti(e){const t=[],n=e.colorMap?Object.entries(e.colorMap):e.keys?e.keys.map(t=>[t,e.color?e.color(t):void 0]):[];if(n.length>0){const o=e.colorType??"fill",r=n.map(([e,t])=>({label:e,color:t}));t.push({type:o,label:e.colorLabel??"",items:r,styleFn:"line"===o?e=>({stroke:e.color??Zr,strokeWidth:2,fill:"none"}):e=>({fill:e.color??Zr,stroke:e.color??Zr})})}if(e.symbolMap&&Object.keys(e.symbolMap).length>0){const n=e.symbolColor??Zr,o=Object.entries(e.symbolMap).map(([e,t])=>({label:e,shape:t,color:n}));t.push({label:e.symbolLabel??"",items:o,styleFn:()=>({}),type:e=>{const t=e.shape;return(0,Qr.jsx)("path",{d:ee(t,ei(t,Jr-1)),transform:`translate(${Jr},${Jr})`,fill:e.color??n})}})}if(e.sizeStops&&e.sizeStops.length>0&&e.sizeRadius){const n=e.sizeRadius,o=e.sizeFormat??(e=>e+""),r=e.sizeColor??Zr,i=e.sizeStops.map(e=>({label:o(e),r:Math.max(.5,n(e)),color:r}));t.push({label:e.sizeLabel??"",items:i,styleFn:()=>({}),type:e=>(0,Qr.jsx)("circle",{cx:Jr,cy:Jr,r:e.r,fill:e.color??r})})}return t}function ni(e){const t=e.orientation??"vertical",n=e.swatchSize??14,o=e.gap??8,r=e.labelGap??6,i=e.fontSize??12,a=e.color??"var(--semiotic-text-secondary, #888)",s=n+o;let c=0;const l=[];return e.entries.forEach((e,u)=>{l.push((0,Qr.jsxs)("g",{transform:`translate(${"vertical"===t?0:c},${"vertical"===t?c:0})`,children:[oi(e,n,e.color??e.line??a,a),(0,Qr.jsx)("text",{x:n+r,y:n/2,dominantBaseline:"middle",fontSize:i,fill:a,children:e.label})]},"legend-"+u)),c+="vertical"===t?s:n+r+e.label.length*i*.58+o+8}),(0,Qr.jsx)("g",{className:e.className,transform:`translate(${e.x},${e.y})`,style:{pointerEvents:"none"},children:l},e.keyId)}function oi(e,t,n,o){if(e.shape){const o=ei(e.shape,t/2-1);return(0,Qr.jsx)("path",{d:ee(e.shape,o),transform:`translate(${t/2},${t/2})`,fill:n})}if(e.hatch){const n=e.color??o;return(0,Qr.jsxs)("g",{children:[(0,Qr.jsx)("svg",{width:t,height:t,style:{overflow:"hidden"},children:[-t,-t/2,0,t/2].map((e,o)=>(0,Qr.jsx)("line",{x1:e,y1:t,x2:e+t,y2:0,stroke:n,strokeWidth:1,opacity:.7},o))}),(0,Qr.jsx)("rect",{width:t,height:t,fill:"none",stroke:n,strokeWidth:1,opacity:.5,rx:2})]})}return(0,Qr.jsx)("rect",e.line?{y:t/2-1.5,width:t,height:3,rx:1.5,fill:e.line}:{width:t,height:t,rx:2,fill:n})}var ri=new Set(["rows"]);function ii(e){const t=e,n=[li(t,["datum","data"]),li(t,["datum"]),li(t,["data","data"]),li(t,["data"]),li(t,["node","datum","data"]),li(t,["node","datum"]),e];for(const e of n){if(!ui(e))continue;const t={};for(const[n,o]of Object.entries(e))n.startsWith("_")||"function"==typeof o||(t[n]=o);if(Object.keys(t).length>0)return t}return null}function ai(e,t={}){const n=ii(e);if(!n)return[];const o=new Set(ri);if(t.excludeKeys)for(const e of t.excludeKeys)o.add(e);const r=[];for(const[e,i]of Object.entries(n))if((t.includeInternal||!e.startsWith("_"))&&!o.has(e)&&(t.includeEmpty||null!=i&&""!==i)&&"function"!=typeof i&&(r.push({key:e,label:ci(e,t.labels),value:i,formatted:t.valueFormat?t.valueFormat(i,e,n):si(i)}),r.length>=(t.maxEntries??8)))break;return r}function si(e){if(null==e)return"";if(e instanceof Date)return e.toISOString();if("number"==typeof e)return Number.isInteger(e)?e+"":e.toLocaleString(void 0,{maximumFractionDigits:2});if("boolean"==typeof e)return e?"true":"false";if(Array.isArray(e))return e.length+" items";if("object"==typeof e)try{return JSON.stringify(e)}catch{return e+""}return e+""}function ci(e,t){return"function"==typeof t?t(e):t&&t[e]?t[e]:e}function li(e,t){let n=e;for(const e of t){if(!ui(n))return;n=n[e]}return n}function ui(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function di(e,t){const n=new Map;for(const t of e)n.set(t.id,new Set);for(const e of t)n.has(e.source)||n.set(e.source,new Set),n.has(e.target)||n.set(e.target,new Set),n.get(e.source).add(e.target),n.get(e.target).add(e.source);return n}function hi(e,t){const n={};for(const t of e)n[t.id]=0;for(const e of t)n[e.source]=(n[e.source]||0)+1,n[e.target]=(n[e.target]||0)+1;return n}function fi(e,t){const n={[t]:0},o=[t];let r=0;for(;o.length>r;){const t=o[r];r+=1;for(const r of e.get(t)||[])void 0===n[r]&&(n[r]=n[t]+1,o.push(r))}return n}function mi(e,t,n,o){if(n===o)return n?[n]:[];const r=di(e,t),i={[n]:null},a=[n];let s=0;for(;a.length>s;){const e=a[s];if(s+=1,e===o)break;for(const t of r.get(e)||[])void 0===i[t]&&(i[t]=e,a.push(t))}if(void 0===i[o])return[];const c=[];let l=o;for(;null!=l;)c.unshift(l),l=i[l];return c}function pi(e,t,n,o=1){const r=di(e,t);if(!r.has(n))return new Set;const i=fi(r,n),a=new Set;for(const e in i)i[e]>o||a.add(e);return a}function gi(e,t){const n=di(e,t),o={};for(const t of e)o[t.id]=0;for(const t of e.map(e=>e.id)){const r=[],i={},a={},s={};for(const t of e)i[t.id]=[],a[t.id]=0,s[t.id]=-1;a[t]=1,s[t]=0;const c=[t];let l=0;for(;c.length>l;){const e=c[l];l+=1,r.push(e);for(const t of n.get(e)||[])0>s[t]&&(s[t]=s[e]+1,c.push(t)),s[t]===s[e]+1&&(a[t]+=a[e],i[t].push(e))}const u={};for(const t of e)u[t.id]=0;for(;r.length;){const e=r.pop();for(const t of i[e])u[t]+=a[t]/a[e]*(1+u[e]);e!==t&&(o[e]+=u[e])}}for(const e in o)o[e]/=2;return o}function yi(e,t){const n=di(e,t),o={};for(const t of e){const e=fi(n,t.id);let r=0,i=0;for(const t in e)r+=e[t],i+=1;o[t.id]=r>0?(i-1)/r:0}return o}function xi(e,t){const n=di(e,t),o={};for(const t of e){const e=[...n.get(t.id)||[]],r=e.length;if(2>r){o[t.id]=0;continue}let i=0;for(let t=0;e.length>t;t+=1)for(let o=t+1;e.length>o;o+=1)n.get(e[t])?.has(e[o])&&(i+=1);o[t.id]=2*i/(r*(r-1))}return o}function bi(e){let t=0;for(const n in e)e[n]>t&&(t=e[n]);const n={};for(const o in e)n[o]=t>0?e[o]/t:0;return n}function wi(e,t,n,o={}){const r=di(e,t),i={};for(const t of e)i[t.id]=fi(r,t.id);let a=o.minHops??4,s=o.startThreshold??.08;const c=o.maxThreshold??.2,l=new Set;let u=0;for(;0===l.size&&40>u;){for(let t=0;e.length>t;t+=1)for(let o=t+1;e.length>o;o+=1){const r=e[t].id,c=e[o].id,u=n[r],d=n[c];if(!u||!d)continue;const h=u.x-d.x,f=u.y-d.y;(void 0===i[r][c]?1/0:i[r][c])>=a&&s>Math.sqrt(h*h+f*f)&&(l.add(r),l.add(c))}0===l.size&&(s+=.02,s>c&&(s=o.startThreshold??.08,a=Math.max(2,a-1))),u+=1}return{problemIds:l,threshold:s,minHops:a}}var Mi={},vi=4e4;function ki(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function $i(){if("undefined"!=typeof DOMException)return new DOMException("Force layout aborted","AbortError");const e=Error("Force layout aborted");return e.name="AbortError",e}var Ai=class{constructor(e=function(){const e="string"==typeof Mi.url&&Mi.url?new URL("./forceLayoutWorker.js",Mi.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,o=null!=n?this.pending.get(n):this.pending.values().next().value;if(o){if(null!=n?this.pending.delete(n):this.pending.clear(),o.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 o.reject(e)}o.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($i());const n=this.nextRequestId;this.nextRequestId+=1;const o={requestId:n,request:e};return new Promise((e,r)=>{const i=()=>{this.pending.delete(n),t?.removeEventListener("abort",i),r($i())},a=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:a,reject:r,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(o)}catch(e){this.pending.delete(n),a(),r(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()}},Si=null;async function Ii(e,t,n={}){const{execution:o="auto",signal:r,workerThreshold:i,nodeRadius:a,...s}=n,c=s.iterations??260,l=ki()&&function(e,t,n,o,r=vi){return"sync"!==e&&("worker"===e||o*(t+n)>=r)}(o,e.length,t.length,c,i);if(!l)return P(e,t,{...s,nodeRadius:a});const u={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 function(e,t){return ki()?t?.aborted?Promise.reject($i()):(Si&&!Si.isDead||(Si=new Ai),Si).request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(u,r)).positions}catch(n){if("AbortError"===n?.name)throw n;return P(e,t,{...s,nodeRadius:a})}}function ji(e,t){if("region-enter"!==t.type)return e;const n=t.region.id,o=e[n]??{id:n,label:t.region.label??n,count:0,bodyIds:[]};if(o.bodyIds.includes(t.bodyId))return e;const r=[...o.bodyIds,t.bodyId];return{...e,[n]:{...o,count:r.length,bodyIds:r}}}function Ci(e,t){return(t??Object.keys(e)).map(t=>e[t]).filter(e=>null!=e).map(e=>({label:e.label??e.id,value:e.count}))}function Ni(e,t){const n=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],o=t.filter(e=>!n.has(e)),r=t.length-o.length,i=e.completion?.mode??"allMembersAbsorbed",a=e.completion?.valueByBodyId,s=e=>{const t=a?.[e];return Number.isFinite(t)&&Number(t)>=0?Number(t):1},c=t.reduce((e,t)=>e+s(t),0),l=t.reduce((e,t)=>e+(n.has(t)?s(t):0),0),u=e.completion?.threshold,d="threshold"===i?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:e.id,label:e.label??e.id,mode:i,complete:t.length>0&&("anyAbsorbed"===i?r>0:"threshold"===i?l>=(d??c):0===o.length),absorbed:r,total:t.length,absorbedValue:l,totalValue:c,threshold:d,missing:o}})}function Fi(e,t,n){return Math.max(t,Math.min(n,e))}function zi(e,t,n={}){const o=n.random??Math.random,r=e.stages.find(e=>e.id===t)??e.stages[e.stages.length-1],i=Fi(n.along??.5,.05,.95),a=n.jitterX??0,s=n.padY??20,c=r.x0+(r.x1-r.x0)*i+(2*o()-1)*a,l=Math.min(1,r.width/2),u=Fi(c,r.x0+l,r.x1-l),d=e.boundaryY(u,"top")+s,h=e.boundaryY(u,"bottom")-s;return{x:u,y:h>d?d+o()*Math.max(1,h-d):e.midY}}function Li(e){return"bowtie"===e.shape?[{id:"incoming",role:"incoming",points:[[e.left,e.topY],[e.centerLeft,e.pinchTop],[e.centerLeft,e.pinchBottom],[e.left,e.bottomY]]},{id:"center",role:"center",points:[[e.centerLeft,e.pinchTop],[e.centerRight,e.pinchTop],[e.centerRight,e.pinchBottom],[e.centerLeft,e.pinchBottom]]},{id:"outgoing",role:"outgoing",points:[[e.centerRight,e.pinchTop],[e.right,e.topY],[e.right,e.bottomY],[e.centerRight,e.pinchBottom]]}]:[{id:"volume",role:"volume",points:[[e.left,e.topY],[e.right,"funnel"===e.shape?e.pinchTop:e.topY],[e.right,"funnel"===e.shape?e.pinchBottom:e.bottomY],[e.left,e.bottomY]]}]}function Ei(e,t,n){return Math.max(t,Math.min(n,e))}function Ti(e,t,n,o,r,i={}){return{id:e,friction:i.friction,restitution:i.restitution,bodyFilter:i.bodyFilter,shape:{type:"segment",x1:t,y1:n,x2:o,y2:r,thickness:i.thickness??8}}}function Ri(e){const t=e.shape??"lane",n=Math.max(1,Math.round(e.width)),o=Math.max(1,Math.round(e.height)),r=e.padX??46,i=e.padY??72,a=r,s=n-r,c=i,l=o-Math.max(24,Math.round(.45*i)),u=(c+l)/2,d=Math.max(1,l-c),h=Ei(e.pinchRatio??.18,.06,.5),f=Number(e.pinchHeightOffset??0),m=Number.isFinite(f)?f:0,p=Ei(d*h+m,.06*d,.5*d),g=p/2,y=u-g,x=u+g,b=e.idPrefix??"process",w=e.friction??.58,M=e.restitution??.18,v=e.wallThickness??8,k=e.stages;if(!k.length)throw Error("processStageLayout requires at least one stage");const $=Ei(e.centerStageIndex??Math.floor(k.length/2),0,k.length-1),A=function(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}(k),S=s-a;let I=a;const j=k.map((e,t)=>{const n=I,o=t===k.length-1?s:I+(e.share??1)/A*S;return I=o,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:n,x1:o,x:(n+o)/2,width:o-n,y:u,height:d}}),C=j[$],N=C.x0,F=C.x1,z=(e,n)=>{if("lane"===t)return"top"===n?c:l;if("funnel"===t){const t=Ei((e-a)/Math.max(1,s-a),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(N>=e){const t=Ei((e-a)/Math.max(1,N-a),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(F>=e)return"top"===n?y:x;const o=Ei((e-F)/Math.max(1,s-F),0,1);return"top"===n?y+(c-y)*o:x+(l-x)*o},L=j.map(e=>{const t=Math.min(z(e.x0,"top"),z(e.x1,"top")),n=Math.max(z(e.x0,"bottom"),z(e.x1,"bottom"));return{...e,y:(t+n)/2,height:Math.max(1,n-t)}}),E={thickness:v,friction:w,restitution:M},T=[];"lane"===t?T.push(Ti(b+"-top",a,c,s,c,E),Ti(b+"-bottom",a,l,s,l,E),Ti(b+"-left",a,c,a,l,{...E,thickness:Math.max(6,v-2)}),Ti(b+"-right",s,c,s,l,{...E,thickness:Math.max(6,v)})):"funnel"===t?T.push(Ti(b+"-top",a,c,s,y,E),Ti(b+"-bottom",a,l,s,x,E),Ti(b+"-left",a,c,a,l,{...E,thickness:Math.max(6,v-2)}),Ti(b+"-right",s,y,s,x,{...E,thickness:Math.max(6,v)})):T.push(Ti(b+"-left-top",a,c,N,y,E),Ti(b+"-left-bottom",a,l,N,x,E),Ti(b+"-center-top",N,y,F,y,E),Ti(b+"-center-bottom",N,x,F,x,E),Ti(b+"-right-top",F,y,s,c,E),Ti(b+"-right-bottom",F,x,s,l,E),Ti(b+"-left",a,c,a,l,{...E,thickness:Math.max(6,v-2)}),Ti(b+"-right",s,c,s,l,{...E,thickness:Math.max(6,v)}));const R=e.membraneDampingScale??.5,P=a,W=Math.max(1,("bowtie"===t?N:s)-P),O=(e.membranes??[]).map(e=>{const t=P+Ei(e.offset,0,1)*W,n=e.width??18+18*e.cost,o=d-16,r=u+.25*(e.wobble??0);return{...e,x:t,y:r,width:n,height:o}}),q=!1===e.includeMembraneRegions?[]:O.map(e=>Oi({id:e.id,label:e.label??e.id,description:e.description??(e.label??e.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??R,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:n,height:o,padX:r,padY:i,left:a,right:s,topY:c,bottomY:l,midY:u,centerLeft:N,centerRight:F,pinchHeight:p,pinchTop:y,pinchBottom:x,stages:L,membranes:O,colliders:T,regionEffects:q,boundaryY:z}}function Pi(e){return{id:e.id,label:e.label,description:e.description,kind:e.kind,shape:(t=e.x,n=e.y,o=e.width,r=e.height,{type:"aabb",x:t,y:n,width:o,height:r}),bodyFilter:e.bodyFilter,collider:e.collider,colliderThickness:e.colliderThickness,friction:e.friction,restitution:e.restitution,semanticItem:e.semanticItem,metadata:e.metadata,bodyStyle:e.bodyStyle,attributes:e.attributes,onEnter:e.onEnter,onExit:e.onExit};var t,n,o,r}function Wi(e,t={}){const n=t.idPrefix??"stage",o=Math.max(0,t.insetX??0),r=Math.max(0,t.insetY??1);return e.stages.map(e=>{const i="function"==typeof t.metadata?t.metadata(e):t.metadata??{};return{...Pi({id:n?`${n}:${e.id}`:e.id,label:e.label??e.id,description:e.description,kind:"region",x:e.x,y:e.y,width:Math.max(1,e.width-2*o),height:Math.max(1,e.height-2*r),bodyFilter:t.bodyFilter,semanticItem:t.semanticItem,attributes:{primitive:"processStage",stageId:e.id,stageIndex:e.index},metadata:{...i,primitive:"processStage",stageId:e.id,stageIndex:e.index}})}})}function Oi(e){const t=e.dampingScale??.5,n=e.energyScale??1,o=Ei(e.cost,0,2);return{...Pi({...e,kind:e.kind??"membrane",attributes:{primitive:"membrane",membraneCost:o,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:o*t,energyDelta:-o*n}}function qi(e){return{...Pi({...e,kind:e.kind??"charge-gate",attributes:{primitive:"chargeGate",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),charge:e.charge??!0,energyDelta:e.energyDelta,impulseOnEnter:e.impulseOnEnter}}function Di(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...Pi({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function Bi(e){const t=e.pressure??e.occupancy??0,n=e.baseDamping??.08,o=e.dampingPerUnit??.12,r=e.energyPerUnit??0;return{...Pi({...e,kind:e.kind??"membrane",attributes:{primitive:"pressureField",pressure:t,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:n+t*o,energyDelta:r?-t*r:void 0,force:e.force}}function Yi(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...Pi({...e,kind:e.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:e.capacity,unitsPerSecond:e.unitsPerSecond??e.capacity,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping,charge:e.charge??e.capacity}}function Gi(e){return{...Pi({...e,kind:e.kind??"force-field",attributes:{primitive:"portal",targetStage:e.targetStage,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:e.force,impulseOnEnter:e.impulseOnEnter,damping:e.damping??.08}}function Hi(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...Pi({...e,kind:e.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.02,charge:e.charge??"absorbed"}}function _i(e){return{...Pi({...e,kind:e.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:e.force,damping:e.damping,energyDelta:e.energyDelta}}function Vi(e){const t=e.x??e.anchor?.x??0,n=e.y??e.anchor?.y??0;return{id:e.id,label:e.label,description:e.description,group:e.group,bodyIds:e.bodyIds,datum:e.datum,state:e.state,x:t,y:n,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:n},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}function Xi(e){const t=e.idPrefix??"lane",n={thickness:e.thickness??8,friction:e.friction??.5,restitution:e.restitution??.16},o=[Ti(t+"-top",e.left,e.top,e.right,e.top,n),Ti(t+"-bottom",e.left,e.bottom,e.right,e.bottom,n)];return e.openEnds||o.push(Ti(t+"-left",e.left,e.top,e.left,e.bottom,n),Ti(t+"-right",e.right,e.top,e.right,e.bottom,n)),o}var Ui=[.1,.5,.9],Ki=1e6,Qi=12;function Zi(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Ji(e,t,n,o,r){return"function"==typeof o?o(e,t,n):function(e,t){let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;n=n[e]}return n}(e,o??r)}function ea(e){const t=Number(e.toFixed(Qi));return Object.is(t,-0)?0:t}function ta(e,t,n,o){const r=e.flatMap((e,r)=>{const i=Zi(Ji(e,r,t,n,"time")),a=Zi(Ji(e,r,t,o,"value"));return null==i||null==a?[]:[{time:ea(i),value:a,index:r}]});r.sort((e,t)=>e.time-t.time||e.index-t.index);const i=[];for(const e of r){const t=i[i.length-1];t?.time===e.time?t.value=e.value:i.push({time:e.time,value:e.value})}return i}function na(e,t,n,o){if(!e.length)return null;const r=e[0],i=e[e.length-1];if(r.time>t)return"clamp"===o?r.value:null;if(t>i.time)return"clamp"===o?i.value:null;const a=function(e,t){let n=0,o=e.length;for(;o>n;){const r=n+o>>>1;t>e[r].time?n=r+1:o=r}return n}(e,t),s=e[a];if(s?.time===t)return s.value;const c=e[Math.max(0,a-1)];return"step"!==n&&s&&s.time!==c.time?c.value+(t-c.time)/(s.time-c.time)*(s.value-c.value):c.value}function oa(e,t){if(1===e.length)return e[0];const n=(e.length-1)*t,o=Math.floor(n),r=Math.ceil(n);return o===r?e[o]:e[o]+(e[r]-e[o])*(n-o)}function ra(e){const t=e.interpolation??"step",n=e.outsideDomain??"omit",o=function(e){const t=(e??Ui).map(e=>{const t=Zi(e);if(null==t||0>t||t>1)throw new RangeError("physicsReferenceEnvelope quantiles must be finite values from 0 to 1; received "+e);return ea(t)});return Array.from(new Set(t)).sort((e,t)=>e-t)}(e.quantiles),r=function(e){if(Array.isArray(e)){if(e.length>Ki)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Ki} points`);return Array.from(new Set(e.map(Zi).filter(e=>null!=e).map(ea))).sort((e,t)=>e-t)}const t=e,n=Zi(t.start),o=Zi(t.end),r=Zi(t.step);if(null==n||null==o||null==r||0>=r||n>o)throw new RangeError("physicsReferenceEnvelope sampleAt requires finite start/end values with end >= start and step > 0");const i=Math.floor((o-n)/r)+1;if(i>Ki)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Ki} points`);const a=[],s=1e-10*Math.max(1,Math.abs(o),Math.abs(n));for(let e=0;i>e;e+=1){const t=n+e*r;if(t>o+s)break;a.push(ea(Math.min(t,o)))}if(a.length&&s>=Math.abs(a[a.length-1]-o)||a.push(ea(o)),a.length>Ki)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${Ki} points`);return Array.from(new Set(a)).sort((e,t)=>e-t)}(e.sampleAt),i=e.runs.map(t=>ta(t.samples,t.id,e.timeAccessor,e.valueAccessor));return{points:r.map(e=>{const r=i.map(o=>na(o,e,t,n)).filter(e=>null!=e).sort((e,t)=>e-t),a={};for(const e of o)a[e]=r.length?oa(r,e):null;return{time:e,count:r.length,min:r.length?r[0]:null,max:r.length?r[r.length-1]:null,median:r.length?oa(r,.5):null,quantiles:a}}),quantiles:o,interpolation:t,outsideDomain:n,runCount:e.runs.length}}function ia(e,t){return e.quantiles.length?"lower"===t?e.quantiles[0]:e.quantiles[e.quantiles.length-1]:"lower"===t?"min":"max"}function aa(e,t){if("min"===t||"median"===t||"max"===t)return e[t];const n=Zi(t);if(null==n||0>n||n>1)throw new RangeError("comparePhysicsTrace quantile selectors must be from 0 to 1; received "+t);const o=ea(n);if(!Object.prototype.hasOwnProperty.call(e.quantiles,o))throw Error(`comparePhysicsTrace could not find quantile ${o} in the reference envelope`);return e.quantiles[o]??null}function sa(e,t,n){return t>e?"below":e>n?"above":"inside"}function ca(e,t){const n=Math.max(0,t.time-e.time);if(0>=n||null==e.value||null==e.lower||null==e.upper||null==t.value||null==t.lower||null==t.upper)return{below:0,inside:0,above:0,observed:0};const o=e.value-e.lower,r=t.value-t.lower,i=e.value-e.upper,a=t.value-t.upper,s=[0,1];for(const[e,t]of[[o,r],[i,a]])(0>e&&t>0||e>0&&0>t)&&s.push(-e/(t-e));s.sort((e,t)=>e-t);let c=0,l=0,u=0;for(let o=0;s.length-1>o;o+=1){const r=s[o],i=s[o+1];if(r>=i)continue;const a=(r+i)/2,d=(i-r)*n,h=sa(e.value+(t.value-e.value)*a,e.lower+(t.lower-e.lower)*a,e.upper+(t.upper-e.upper)*a);"below"===h?c+=d:"above"===h?u+=d:l+=d}return{below:c,inside:l,above:u,observed:n}}function la(e,t,n={}){const o=n.interpolation??t.interpolation,r=n.outsideDomain??t.outsideDomain,i=ta(e,n.traceId??"trace",n.timeAccessor,n.valueAccessor),a=n.lower??ia(t,"lower"),s=n.upper??ia(t,"upper"),c=t.points.map(e=>{const t=na(i,e.time,o,r),n=aa(e,a),c=aa(e,s);if(null!=n&&null!=c&&n>c)throw new RangeError("comparePhysicsTrace lower band exceeds upper band at time "+e.time);return{time:e.time,value:t,lower:n,upper:c,status:null==t||null==n||null==c?"unobserved":sa(t,n,c)}});let l=0,u=0,d=0,h=0,f=null,m=0,p=null;for(const e of c){if("below"===e.status?l+=1:"inside"===e.status?u+=1:"above"===e.status&&(d+=1),null==e.value||null==e.lower||null==e.upper)continue;const t=Math.max(0,e.value-e.upper),n=Math.max(0,e.lower-e.value);t>h&&(h=t,f=e.time),n>m&&(m=n,p=e.time)}let g=0,y=0,x=0,b=0;for(let e=0;c.length-1>e;e+=1){const t=c[e],n=c[e+1],r=Math.max(0,n.time-t.time);if(r>0){if("linear"===o){const e=ca(t,n);g+=e.below,y+=e.inside,x+=e.above,b+=e.observed;continue}"unobserved"!==t.status&&(b+=r,"below"===t.status?g+=r:"above"===t.status?x+=r:y+=r)}}const w=c[0]?.time,M=c[c.length-1]?.time,v=null==w||null==M?0:Math.max(0,M-w);return{points:c,sampleCount:c.length,observedSamples:l+u+d,belowSamples:l,insideSamples:u,aboveSamples:d,totalDuration:v,observedDuration:b,unobservedDuration:Math.max(0,v-b),belowDuration:g,insideDuration:y,aboveDuration:x,peakExcess:h,peakExcessAt:f,peakDeficit:m,peakDeficitAt:p}}function ua(e){return{id:e,furthestStageIndex:-1,visitedStageIds:[],visitsByStage:{},firstEnteredAt:{},lastEnteredAt:{},regressionCount:0}}function da(e){const t=Array.from(new Set(e.bodyIds??[]));return{stages:e.stages.map(e=>({...e})),bodyIds:t,entities:Object.fromEntries(t.map(e=>[e,ua(e)]))}}function ha(e,t,n={}){if("region-enter"!==t.type)return e;const o=function(e,t){const n=t.stageId?.(e);if(n)return n;const o=e.region.metadata;if(o&&"object"==typeof o){const e=o.stageId;if("string"==typeof e)return e}return e.region.id}(t,n),r=e.stages.findIndex(e=>e.id===o);if(0>r)return e;const i=n.entityId?.(t)??t.bodyId;if(!i)return e;const a=e.entities[i]??ua(i),s=a.currentStageId?e.stages.findIndex(e=>e.id===a.currentStageId):-1,c=!a.visitedStageIds.includes(o),l=Number(t.observation.timestamp),u=Number.isFinite(l)?l:0,d={...a,currentStageId:o,furthestStageId:r>a.furthestStageIndex?o:a.furthestStageId,furthestStageIndex:Math.max(a.furthestStageIndex,r),visitedStageIds:c?[...a.visitedStageIds,o]:a.visitedStageIds,visitsByStage:{...a.visitsByStage,[o]:(a.visitsByStage[o]??0)+1},firstEnteredAt:c?{...a.firstEnteredAt,[o]:u}:a.firstEnteredAt,lastEnteredAt:{...a.lastEnteredAt,[o]:u},regressionCount:s>=0&&s>r?a.regressionCount+1:a.regressionCount};return{...e,bodyIds:e.bodyIds.includes(i)?e.bodyIds:[...e.bodyIds,i],entities:{...e.entities,[i]:d}}}function fa(e){const t=e.bodyIds.map(t=>e.entities[t]??ua(t)),n=t.length;let o=n;return e.stages.map((e,r)=>{const i=t.filter(e=>e.furthestStageIndex>=r).length,a=t.filter(t=>t.visitedStageIds.includes(e.id)).length,s=t.reduce((t,n)=>t+(n.visitsByStage[e.id]??0),0),c={id:e.id,label:e.label??e.id,reached:i,entered:a,total:n,conversion:n>0?i/n:0,fromPrevious:o>0?i/o:0,dropoff:Math.max(0,o-i),visits:s,repeatVisits:Math.max(0,s-a)};return o=i,c})}function ma(e,t){if("function"==typeof t){const n=t(e);return Number.isFinite(n)&&n>0?Number(n):1}const n=e.datum;if(t&&n&&"object"==typeof n){const e=Number(n[t]);if(Number.isFinite(e)&&e>0)return e}const o=Number(n?.work??n?.reviewWork??n?.value);return Number.isFinite(o)&&o>0?o:1}function pa(e,t){if("function"==typeof t){const n=t(e);if(null!=n&&(n+"").length>0)return n+""}else if(t){const n=ya(e.datum,t),o=ya(e,t),r=n??o;if(null!=r&&(r+"").length>0)return r+""}return e.id}function ga(e,t){if(0===e.length)return 0;if(1===e.length)return e[0];const n=Math.max(0,Math.min(1,t))*(e.length-1),o=Math.floor(n);return e[o]+(e[Math.ceil(n)]-e[o])*(n-o)}function ya(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;n=n[e]}return n}function xa(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const n=ya(e,t.property);return!("equals"in t&&!Object.is(n,t.equals)||"notEquals"in t&&Object.is(n,t.notEquals)||t.oneOf&&!t.oneOf.some(e=>Object.is(n,e))||t.notOneOf&&t.notOneOf.some(e=>Object.is(n,e)))}function ba(e){const t=e.regionId,n=Math.max(0,e.unitsPerSecond),o=e.queueLayout??"lane",r=e.queueSlotSpacing??14,i=e.queueStiffness??.35,a=Number.isFinite(e.maxQueue)?Math.max(0,Math.floor(Number(e.maxQueue))):1/0,s=Math.max(.25,e.metricWindowSeconds??30),c=Math.max(1/60,e.snapshotIntervalSeconds??.25),l=e.releaseImpulse??{x:90,y:0},u=new Map,d=new Map,h=new Map,f=new Map,m=new Map,p=new Map,g=new Map,y=[];let x=0,b=new Map,w=new Map,M=0,v=0,k=0,$=null,A=0,S=0,I=0,j=0,C=0,N=0,F=0,z=0,L=0,E=0,T=0,R=0,P=-1,W=!1;function O(e,n){const o=n(e);return!!o&&o.activeRegionIds.includes(t)}function q(){R+=1}function D(e){return{bodyId:e.bodyId,jobId:e.jobId,visitId:e.visitId,visit:e.visit,regionId:t,work:e.total,queuedAt:e.queuedAt}}function B(n,o,r,i){const a={bodyId:n.id,jobId:o.jobId,visitId:o.visitId,visit:o.visit,remaining:o.work,total:o.work,queuedAt:o.queuedAt,sequence:i};return u.set(o.jobId,a),g.delete(n.id),p.set(n.id,o.jobId),S+=1,I+=o.work,q(),function(n,o,r){const i=D(o);e.onQueued?.(n,i),r.controls.recordObservation({type:"physics-capacity-queued",bodyId:n.id,datum:n.datum,x:n.x,y:n.y,regionId:t,work:o.total,jobId:o.jobId,visitId:o.visitId,visit:o.visit,queuedAt:o.queuedAt,queueDepth:u.size})}(n,a,r),a}function Y(e){if(u.size>=a||0===d.size)return;const t=Array.from(d.values()).sort((e,t)=>e.sequence-t.sequence);for(const n of t){if(u.size>=a)break;const t=m.get(n.jobId);t&&h.has(n.jobId)?(d.delete(n.jobId),g.delete(n.bodyId),B(t,n,e,n.sequence)):d.delete(n.jobId)}}function G(){let e=0;for(const t of u.values())e+=t.remaining;return e}function H(){L=Math.max(L,u.size),E=Math.max(E,G())}function _(){const e=k-s,t=Math.max(0,Math.min(s,k-($??k)));let o=0,r=0,i=0,a=0,c=0;for(const t of y){if(e>t.end)continue;o+=t.arrivals,r+=t.arrivalWork,i+=t.completions,a+=t.completedWork;const n=t.end-t.start;c+=n>0&&e>t.start?t.processedWork*Math.min(1,Math.max(0,t.end-e)/n):t.processedWork}const l=t>0?r/t:0;return{seconds:t,arrivals:o,arrivalWork:r,completions:i,completedWork:a,processedWork:c,arrivalsPerSecond:t>0?o/t:0,throughputPerSecond:t>0?i/t:0,utilization:t>0&&n>0?Math.max(0,Math.min(1,c/(n*t))):0,pressure:n>0?l/n:0}}return{id:e.id??"capacity-queue:"+t,continuous:!1!==e.continuous,tick:o=>{const r=o.controls.readBodies(),i=new Map,S=new Map;for(const t of r){if(i.set(t.id,t),!O(t.id,o.getRegionState))continue;if(!xa(t,e.bodyFilter))continue;const n=pa(t,e.jobKey),r=S.get(n)??[];r.push(t),S.set(n,r)}const I=Number.isFinite(o.dt)?Math.max(0,o.dt):0;if(!W){const e=Number.isFinite(o.elapsed)?Math.max(0,o.elapsed):I;k=Math.max(0,e-I),W=!0}const L=k,E=L+I;k=E,$=null==$?L:Math.min($,L);const R={start:L,end:E,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},G=new Map;for(const[e,t]of S){const n=h.get(e)?.bodyId,o=t.find(e=>e.id===n)??t[0];G.set(e,o),m.set(e,o)}for(const[n,r]of h){if(G.has(n))continue;const a=u.get(n),s=i.get(r.bodyId)??m.get(n);if(a){u.delete(n),p.delete(a.bodyId),F+=1,z+=a.remaining,q();const i={...D(a),abandonedAt:k,remainingWork:a.remaining,queueSeconds:Math.max(0,k-a.queuedAt)};s&&e.onAbandoned?.(s,i),o.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:r.bodyId,datum:s?.datum,x:s?.x,y:s?.y,regionId:t,work:a.total,remainingWork:a.remaining,jobId:n,visitId:a.visitId,visit:a.visit,queuedAt:a.queuedAt,abandonedAt:k,queueSeconds:i.queueSeconds,queueDepth:u.size})}d.delete(n),g.delete(r.bodyId),h.delete(n),m.delete(n)}for(const[n,r]of G){if(h.has(n))continue;const i=(f.get(n)??0)+1;f.set(n,i);const s=ma(r,e.unitAccessor),c={bodyId:r.id,jobId:n,visitId:`${t}:${n}:${i}`,visit:i,regionId:t,work:s,queuedAt:k};h.set(n,c),A+=1,R.arrivals+=1,R.arrivalWork+=s;const l=x++;if(a>u.size)B(r,c,o,l);else{const a={...c,blockedAt:k,sequence:l};d.set(n,a),g.set(r.id,n),N+=1,q(),e.onBlocked?.(r,a),o.controls.recordObservation({type:"physics-capacity-blocked",bodyId:r.id,datum:r.datum,x:r.x,y:r.y,regionId:t,work:s,jobId:n,visitId:c.visitId,visit:i,queuedAt:k,blockedAt:k,queueDepth:u.size,blockedDepth:d.size})}}Y(o),H();const _=Array.from(u.values()).sort((e,t)=>e.sequence-t.sequence);let V=n*I;for(const n of _){if(0>=V)break;const r=Math.min(n.remaining,V);if(n.remaining-=r,V-=r,j+=r,R.processedWork+=r,n.remaining>1e-6)continue;u.delete(n.jobId),p.delete(n.bodyId),v+=1,C+=n.total,R.completions+=1,R.completedWork+=n.total;const a=Math.max(0,k-n.queuedAt);T+=a,q();const s=i.get(n.bodyId);if(!s)continue;o.controls.applyImpulse(n.bodyId,l.x??0,l.y??0);const c={...D(n),completedAt:k,queueSeconds:a};e.onProcessed?.(s,c),o.controls.recordObservation({type:"physics-capacity-processed",bodyId:n.bodyId,datum:s.datum,x:s.x,y:s.y,regionId:t,work:n.total,jobId:n.jobId,visitId:n.visitId,visit:n.visit,queuedAt:n.queuedAt,completedAt:k,queueSeconds:a,queueDepth:u.size})}Y(o),H(),function(){const e=Array.from(u.values()).sort((e,t)=>e.sequence-t.sequence);b=new Map(e.map((e,t)=>[e.bodyId,t]));const t=Array.from(d.values()).sort((e,t)=>e.sequence-t.sequence);w=new Map(t.map((e,t)=>[e.bodyId,t])),M=e.length}(),function(e){(e.end>e.start||e.arrivals>0||e.completions>0||e.processedWork>0)&&y.push(e);const t=k-s;for(;y.length>0&&t>y[0].end;)y.shift()}(R);const X=Math.floor(k/c);X!==P&&(P=X,q())},getSnapshot:()=>{const e=G(),o=function(){let e=0;for(const t of d.values())e+=t.work;return e}(),r=u.size,i=Array.from(u.values()).map(e=>Math.max(0,k-e.queuedAt)).sort((e,t)=>e-t),a=i.reduce((e,t)=>e+t,0);return{regionId:t,queueDepth:r,processedCount:v,unitsPerSecond:n,remainingWork:e,meanRemainingWork:r>0?e/r:0,waitingWork:e+o,blockedDepth:d.size,blockedWork:o,arrivalCount:A,admittedCount:S,admittedWork:I,processedWork:j,completedWork:C,blockedCount:N,abandonedCount:F,abandonedWork:z,peakQueueDepth:L,peakRemainingWork:E,queueAge:{count:i.length,meanSeconds:i.length>0?a/i.length:0,p50Seconds:ga(i,.5),p95Seconds:ga(i,.95),oldestSeconds:i.at(-1)??0},meanCompletedQueueSeconds:v>0?T/v:0,window:_(),simulatedAt:k,metricRevision:R}},bodyForce:e=>{if("none"===o)return null;const n=p.get(e.body.id),a=g.get(e.body.id),s=n?u.get(n):void 0,c=a?d.get(a):void 0;if(!s&&!c)return null;const l=s?b.get(e.body.id):w.get(e.body.id);if(null==l)return null;let h;const f=e.regions;if(f)for(let e=0;f.length>e;e+=1)if(f[e].id===t){const t=f[e].shape;t&&"aabb"===t.type&&(h=t);break}return h?{x:((c?h.x-.44*h.width:h.x-.22*h.width-l*(.15*r))-e.body.x)*i,y:(h.y-(l-((c?d.size:M)-1)/2)*r/Math.max(1,Math.sqrt(c?d.size:M))-e.body.y)*i*.85}:{x:8*-Math.sign(e.body.vx||1),y:0}}}}function wa(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;n=n[e]}return n}function Ma(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const n=wa(e,t.property);return!("equals"in t&&!Object.is(n,t.equals)||"notEquals"in t&&Object.is(n,t.notEquals)||t.oneOf&&!t.oneOf.some(e=>Object.is(n,e))||t.notOneOf&&t.notOneOf.some(e=>Object.is(n,e)))}function va(e){const t=e.resources.map(e=>({...e,bodyId:e.bodyId??e.id})),n=new Map(t.map(e=>[e.bodyId,e])),o=new Map,r=new Map,i=e.assignmentForce??.45,a=e.returnForce??.35,s=e.caseAttraction??.08,c=e.assignmentOffset??{x:0,y:0};let l=new Map,u=0,d=0;return{id:e.id??"service-resource-pool",continuous:!0,assign:e=>{const n=o.get(e);if(n)return n;const i=t.find(e=>!r.has(e.id));if(!i)return null;const a={resourceId:i.id,resourceBodyId:i.bodyId,caseBodyId:e,assignedAt:u};return o.set(e,a),r.set(i.id,a),d+=1,a},release:e=>{const t=o.get(e);return!!t&&(o.delete(e),r.delete(t.resourceId),d+=1,!0)},getAssignment:e=>o.get(e),tick:e=>{u=Math.max(u,e.elapsed),l=new Map(e.controls.readBodies().map(e=>[e.id,e]));for(const[e,t]of o)l.has(e)&&l.has(t.resourceBodyId)||(o.delete(e),r.delete(t.resourceId),d+=1)},getSnapshot:()=>({total:t.length,available:t.length-r.size,assigned:r.size,assignments:Array.from(o.values()),simulatedAt:u,metricRevision:d}),bodyForce:e=>{const t=n.get(e.body.id);if(t){const n=r.get(t.id),o=n?l.get(n.caseBodyId):void 0,s=n?i:a;return{x:((o?o.x+(c.x??0):t.home.x)-e.body.x)*s,y:((o?o.y+(c.y??0):t.home.y)-e.body.y)*s}}const u=o.get(e.body.id);if(!u||0>=s)return null;const d=l.get(u.resourceBodyId);return d?{x:(d.x-e.body.x)*s,y:(d.y-e.body.y)*s}:null}}}function ka(e,t){const n="function"==typeof t.deadlineAccessor?t.deadlineAccessor(e):wa(e.datum,t.deadlineAccessor)??wa(e,t.deadlineAccessor);return Number.isFinite(Number(n))?Math.max(0,Number(n)):0}function $a(e){const t=new Map;let n=0,o=0;function r(n){t.set(n.bodyId,n),o+=1,e.onStateChange?.({...n})}function i(e){const o=t.get(e);return!(!o||null!=o.completedAt||(r({...o,completedAt:n,state:"unhappy"===o.state?"resolved-unhappy":"resolved"}),0))}return{id:e.id??"service-level",continuous:!0,protect:e=>{const o=t.get(e);return!(!o||null!=o.completedAt||"unhappy"===o.state||(r({...o,state:"protected",protectedAt:n}),0))},complete:i,getCase:e=>t.get(e),tick:o=>{n=Math.max(n,o.elapsed);for(const a of o.controls.readBodies()){if(!Ma(a,e.bodyFilter))continue;if(!t.has(a.id)){const t=ka(a,e);r({bodyId:a.id,openedAt:n,deadlineAt:n+t,state:"waiting"})}const s=t.get(a.id);s&&null==s.completedAt&&(e.completionRegionId&&o.getRegionState(a.id)?.activeRegionIds.includes(e.completionRegionId)?i(a.id):"waiting"!==s.state||s.deadlineAt>n||r({...s,state:"unhappy"}))}},getSnapshot:()=>{const e=Array.from(t.values()),r=t=>e.filter(e=>e.state===t).length;return{total:e.length,waiting:r("waiting"),protected:r("protected"),unhappy:r("unhappy"),resolved:r("resolved"),resolvedUnhappy:r("resolved-unhappy"),simulatedAt:n,metricRevision:o}}}}function Aa(e){const t=new Set;let n=0,o=0,r=0,i=!1;return{id:e.id??"dependency-gate:"+e.regionId,continuous:!0,tick:a=>{n=Math.max(n,a.elapsed);const s=i;var c;c=n,i=e.isOpen?e.isOpen(c):null!=e.opensAt&&c>=e.opensAt;const l=a.controls.readBodies(),u=new Map(l.map(e=>[e.id,e]));for(const n of l){const o=a.getRegionState(n.id)?.activeRegionIds.includes(e.regionId);o&&Ma(n,e.bodyFilter)&&(i||t.has(n.id)||(t.add(n.id),r+=1,e.onHeld?.(n)))}if(i&&!s){for(const n of t){const t=u.get(n);t&&(a.controls.applyImpulse(n,e.releaseImpulse?.x??86,e.releaseImpulse?.y??0),o+=1,e.onReleased?.(t))}t.clear(),r+=1}for(const e of t)u.has(e)||(t.delete(e),r+=1)},getSnapshot:()=>({regionId:e.regionId,isOpen:i,blocked:t.size,released:o,simulatedAt:n,metricRevision:r}),bodyForce:n=>{if(i||!t.has(n.body.id))return null;const o=n.regions?.find(t=>t.id===e.regionId),r=o?.shape;if(!r||"aabb"!==r.type)return{x:.8*-n.body.vx,y:.8*-n.body.vy};const a=e.holdForce??.4;return{x:(r.x-n.body.x)*a-.45*n.body.vx,y:(r.y-n.body.y)*a-.45*n.body.vy}}}}function Sa(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}function Ia(e){if(!e?.length)return null;const t=e.slice(),n=t.some(e=>!1!==e.continuous);return{controllers:t,continuous:n,onTick:(e,n,o)=>{const r={result:e,controls:n,dt:o.dt,elapsed:o.elapsed,getRegionState:o.getRegionState};for(const e of t)e.tick(r)},bodyForce:e=>{let n=null;for(const o of t)o.bodyForce&&(n=Sa(n,o.bodyForce(e)));return n}}}function ja(e){const t=new Set,n=e.impulse??{x:-60,y:0};return{id:e.id??"portal:"+e.fromRegionId,continuous:!0===e.continuous,tick:o=>{const r=o.controls.readBodies();for(const i of r){const r=o.getRegionState(i.id),a=r?.activeRegionIds.includes(e.fromRegionId);a?t.has(i.id)||(t.add(i.id),o.controls.applyImpulse(i.id,n.x??0,n.y??0),e.onPortal?.(i)):t.delete(i.id)}}}}var Ca=require("react/jsx-runtime"),Na={flow:{fill:"rgba(59, 130, 246, 0.14)",stroke:"rgba(96, 165, 250, 0.7)",accent:"#60a5fa"},capacity:{fill:"rgba(251, 146, 60, 0.18)",stroke:"rgba(251, 146, 60, 0.85)",accent:"#fb923c"},portal:{fill:"rgba(244, 114, 182, 0.14)",stroke:"rgba(244, 114, 182, 0.7)",accent:"#f472b6"},absorb:{fill:"rgba(52, 211, 153, 0.18)",stroke:"rgba(52, 211, 153, 0.8)",accent:"#34d399"}},Fa=6.2;function za(e,t,n){return Math.max(t,Math.min(n,e))}function La(e){return e.length*Fa}function Ea(e,t){const n=e.trim();if(t>=n.length)return n;if(1>=t)return n.slice(0,1);const o=n.split(/\s+/).filter(Boolean).map(e=>e[0]).join("").toUpperCase();return o.length>1&&t>=o.length?o:t>3?n.slice(0,Math.max(1,t-2))+"..":n.slice(0,t).toUpperCase()}function Ta(e,t,n="auto"){const o=Math.max(1,Math.floor(t/Fa)),r="compact"===n?Ea(e,o):"full"===n?e:La(e)>t?Ea(e,o):e;return{text:r,textLength:La(r)>t?Math.max(4,t):void 0}}function Ra(e,t={}){const{showFlowSpine:n=!0,showStageCounts:o=!0,showCapacityBadges:r=!0,showGroupSockets:i=!0,stageLabelMode:a="auto",outlineStages:s=!1,testId:c="process-flow-chrome"}=t,{width:l,height:u,left:d,right:h,topY:f,bottomY:m,midY:p,stages:g,groups:y=[]}=e,x=m-f;return(0,Ca.jsxs)("svg",{"aria-hidden":"true","data-testid":c,"data-outline-stages":s?"true":void 0,width:l,height:u,viewBox:`0 0 ${l} ${u}`,style:{position:"absolute",inset:0,pointerEvents:"none"},className:["semiotic-process-chrome",s?"semiotic-process-chrome--outline-stages":null].filter(Boolean).join(" "),children:[(0,Ca.jsx)("defs",{children:(0,Ca.jsxs)("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,Ca.jsx)("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),(0,Ca.jsx)("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),(0,Ca.jsx)("rect",{x:0,y:0,width:l,height:u,fill:"url(#semiotic-process-floor)"}),(0,Ca.jsx)("rect",{x:d-6,y:f-8,width:h-d+12,height:x+16,rx:14,fill:"var(--semiotic-process-lane, var(--semiotic-surface, #111827))",fillOpacity:.45,stroke:"var(--semiotic-process-border, var(--semiotic-border, #334155))",strokeOpacity:.95}),n?(0,Ca.jsx)("line",{x1:d+8,x2:h-8,y1:p,y2:p,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,g.map((e,t)=>{const n=function(e){return e.absorb?"absorb":e.portalTarget?"portal":null!=e.capacity?"capacity":"flow"}(e),i=Na[n],c=Math.max(12,e.width-8),l=za(c-8,22,88),d=Ta(e.label,Math.max(8,l-10),a),h="none"!==a&&c-8>=22,y=function(e){if(null!=e.capacity){const t=null!=e.queueDepth?" · q "+e.queueDepth:"";return e.capacityLabel?`${e.capacityLabel}${t}`:`cap ${Number.isInteger(e.capacity)?e.capacity+"":e.capacity.toFixed(1)}${t}`}return e.absorb?"absorb":e.portalTarget?"portal":"flow"}(e),b=Ta(y,Math.max(16,c-10),"auto"),w=r&&!1!==e.showBadge&&c>=32,M=null!=e.count?`n=${e.count}${null!=e.processed?" done "+e.processed:""}`:"",v=Ta(M,Math.max(16,c-8),"auto"),k=Math.max(30,f-15),$=k-13;return(0,Ca.jsxs)("g",{"data-stage":e.id,"data-role":n,children:[(0,Ca.jsx)("rect",{className:"semiotic-process-chrome__stage-bay",x:e.x0+4,y:f+6,width:c,height:x-12,rx:10,fill:s?"none":i.fill,stroke:i.stroke,strokeWidth:s?1.85:"flow"===n?1:1.6}),g.length-1>t?(0,Ca.jsx)("polygon",{points:`${e.x1-2},${p-7} ${e.x1+8},${p} ${e.x1-2},${p+7}`,fill:i.accent,opacity:.85}):null,h?(0,Ca.jsxs)(Ca.Fragment,{children:[(0,Ca.jsx)("rect",{className:"semiotic-process-chrome__stage-label-bg",x:e.x-l/2,y:$,width:l,height:18,rx:9,fill:"var(--semiotic-bg, #0f172a)",fillOpacity:.75,stroke:i.stroke}),(0,Ca.jsxs)("text",{x:e.x,y:k,textAnchor:"middle",fill:i.accent,fontSize:10,fontWeight:800,className:"semiotic-process-chrome__stage-label",textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[(0,Ca.jsx)("title",{children:e.label}),d.text]})]}):null,w?(0,Ca.jsxs)("text",{x:e.x,y:f+22,textAnchor:"middle",fill:"var(--semiotic-process-muted, var(--semiotic-text-secondary, #94a3b8))",fontSize:9,fontWeight:700,textLength:b.textLength,lengthAdjust:b.textLength?"spacingAndGlyphs":void 0,children:[(0,Ca.jsx)("title",{children:y}),b.text]}):null,o&&null!=e.count?(0,Ca.jsxs)("text",{x:e.x,y:Math.min(u-8,m+16),textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #e2e8f0))",fontSize:11,fontWeight:800,textLength:v.textLength,lengthAdjust:v.textLength?"spacingAndGlyphs":void 0,children:[(0,Ca.jsx)("title",{children:M}),v.text]}):null]},e.id)}),i?y.map((e,t)=>{const n=e.total??0,o=e.absorbed??0,r=e.complete??(n>0&&o>=n),i=!r&&n>0&&o/n>=.75,a=r?"rgba(52, 211, 153, 0.35)":i?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",s=r?"#34d399":i?"#fbbf24":"var(--semiotic-border, #64748b)",c=n>0?`${o}/${n}${r?" shipped":i?" almost":""}`:"feature "+(t+1),l=za(Math.max(54,La(e.label)+18,La(c)+16),54,104),u=Ta(e.label,l-12,"auto"),d=Ta(c,l-12,"auto");return(0,Ca.jsxs)("g",{"data-group":e.id,children:[(0,Ca.jsx)("rect",{x:e.x-l/2,y:e.y-22,width:l,height:44,rx:10,fill:a,stroke:s,strokeWidth:1.5}),(0,Ca.jsxs)("text",{x:e.x,y:e.y-4,textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #f8fafc))",fontSize:10,fontWeight:800,textLength:u.textLength,lengthAdjust:u.textLength?"spacingAndGlyphs":void 0,children:[(0,Ca.jsx)("title",{children:e.label}),u.text]}),(0,Ca.jsxs)("text",{x:e.x,y:e.y+12,textAnchor:"middle",fill:s,fontSize:9,fontWeight:700,textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[(0,Ca.jsx)("title",{children:c}),d.text]})]},e.id)}):null]})}var Pa={flow:"down",padding:24,chargeExtent:.12,destinationExtent:.55,projectionExtent:0,channelRatio:1};function Wa(e){const[t,n]=e.size,o=e.flow??Pa.flow,r=function(e){if(null==e){const e=Pa.padding;return{top:e,right:e,bottom:e,left:e}}return"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}(e.padding),i=Math.max(.05,Math.min(1,e.channelRatio??Pa.channelRatio)),a={x:r.left,y:r.top,width:Math.max(1,t-r.left-r.right),height:Math.max(1,n-r.top-r.bottom)},s="down"===o?a.height:a.width,c=s*Math.max(0,e.chargeExtent??Pa.chargeExtent),l=s*Math.max(0,e.projectionExtent??Pa.projectionExtent),u=s*Math.max(0,e.destinationExtent??Pa.destinationExtent),d=Math.max(0,s-c-u-l),h=function(e){return"number"==typeof e?Array.from({length:Math.max(1,Math.round(e))},(e,t)=>({id:"bin-"+t,label:t+""})):0===e.length?[{id:"bin-0",label:"0"}]:e.map((e,t)=>({id:e.id,label:e.label??e.id??t+""}))}(e.destinations),f=("down"===o?a.width:a.height)/h.length,m="down"===o?(e,t)=>({x:a.x,y:a.y+e,width:a.width,height:t}):(e,t)=>({x:a.x+e,y:a.y,width:t,height:a.height}),p=m(0,c),g=m(c,d),y=c+d,x=m(y,u),b=m(y+u,l),w=h.map((e,t)=>{const n=t*f,r=f*i,s=(f-r)/2;return"down"===o?{id:e.id,label:e.label,order:t,x:a.x+n+s,y:x.y,width:r,height:x.height,centerX:a.x+(t+.5)*f,centerY:x.y+x.height/2}:{id:e.id,label:e.label,order:t,x:x.x,y:a.y+n+s,width:x.width,height:r,centerX:x.x+x.width/2,centerY:a.y+(t+.5)*f}});return{width:t,height:n,flow:o,charge:p,apparatus:g,destinations:w,projection:b}}function Oa(e,t){return e.destinations.find(e=>e.id===t)}function qa(e,t,n){const{charge:o,flow:r}=e,i=Math.max(1,n),a=(t%i+.5)/i;return"down"===r?{x:o.x+o.width*a,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height*a}}function Da(e,t={}){const n=t.thickness??4,o=t.idPrefix??"stage",{destinations:r,flow:i,width:a,height:s}=e,c=[];if(r.length>0){const t=r[0];if("down"===i){const i=t.y+t.height;c.push({id:o+"-floor",shape:{type:"segment",x1:e.charge.x,y1:i,x2:e.charge.x+e.charge.width,y2:i,thickness:n}});for(let e=1;r.length>e;e+=1){const a=r[e].centerX-(r[e].centerX-r[e-1].centerX)/2;c.push({id:`${o}-divider-${e}`,shape:{type:"segment",x1:a,y1:t.y,x2:a,y2:i,thickness:n}})}}else{const i=t.x+t.width;c.push({id:o+"-floor",shape:{type:"segment",x1:i,y1:e.charge.y,x2:i,y2:e.charge.y+e.charge.height,thickness:n}});for(let e=1;r.length>e;e+=1){const a=r[e].centerY-(r[e].centerY-r[e-1].centerY)/2;c.push({id:`${o}-divider-${e}`,shape:{type:"segment",x1:t.x,y1:a,x2:i,y2:a,thickness:n}})}}}return!1!==t.walls&&c.push({id:o+"-wall-left",shape:{type:"segment",x1:1,y1:0,x2:1,y2:s,thickness:n}},{id:o+"-wall-right",shape:{type:"segment",x1:a-1,y1:0,x2:a-1,y2:s,thickness:n}}),c}function Ba(e,t={}){return`${t.charge??"bodies"} enter at the ${"down"===e.flow?"top":"left"}, travel ${"down"===e.flow?"downward":"left to right"} through ${t.apparatus??"the apparatus"}, and come to rest in ${e.destinations.length} ${t.destination??"destinations"}: ${e.destinations.map(e=>e.label).join(", ")}.`}function Ya(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Ga(e,t,n,o){const r="function"==typeof e?e(t,n):e;return Number.isFinite(r)?Number(r):o}function Ha(e,t,n){return Ya(e[t])??n}function _a(e,t){return"number"==typeof e?e:e?.[t]??0}function Va(e){const{band:t,idPrefix:n,plot:o,projection:r}=e,{includeBoundaryWalls:i=!0,includeInteriorWalls:a=!0,wallThickness:s=4}=t,c=function(e){const t=e.bandwidth??e.scale.bandwidth?.()??0,n=new Set;for(const o of e.values){const r=e.scale(o);Number.isFinite(r)&&(n.add(Number(r)),n.add(Number(r)+t))}return Array.from(n).sort((e,t)=>e-t)}(t);if(2>c.length)return[];const l=i?c.length-1:c.length-2,u=[];for(let e=i?0:1;l>=e;e+=1){if(!a&&e>0&&c.length-1>e)continue;const t=c[e];u.push({id:`${n}-wall-${e}`,shape:"x"===r?{type:"aabb",x:t,y:o.y+o.height/2,width:s,height:o.height}:{type:"aabb",x:o.x+o.width/2,y:t,width:o.width,height:s}})}return u}function Xa(e){const{plot:t,idPrefix:n="physics-scale",bounds:o={},xBins:r,xBands:i,yBands:a}=e,s=[];if(!1!==o&&s.push(...function(e,t={}){const{idPrefix:n="plot",includeFloor:o=!0,includeCeiling:r=!1,includeLeftWall:i=!0,includeRightWall:a=!0,wallThickness:s=20,floorThickness:c=s}=t,l=[],u=e.x+e.width/2,d=e.y+e.height/2;return o&&l.push({id:n+"-floor",shape:{type:"aabb",x:u,y:e.y+e.height+c/2,width:e.width+2*s,height:c}}),r&&l.push({id:n+"-ceiling",shape:{type:"aabb",x:u,y:e.y-c/2,width:e.width+2*s,height:c}}),i&&l.push({id:n+"-left-wall",shape:{type:"aabb",x:e.x-s/2,y:d,width:s,height:e.height+2*c}}),a&&l.push({id:n+"-right-wall",shape:{type:"aabb",x:e.x+e.width+s/2,y:d,width:s,height:e.height+2*c}}),l}(t,{idPrefix:n,...o})),r){const{idPrefix:e,yTop:o,yBottom:i,...a}=r;s.push(...function(e){const{idPrefix:t="bin",count:n,domainStart:o,domainStep:r,xScale:i,yTop:a,yBottom:s,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=a,lidThickness:f=Math.max(2,c)}=e,m=[],p=a+(s-a)/2,g=Math.abs(s-a),y=l?n:n-1;if(u||l)for(let e=l?0:1;y>=e;e+=1){if(!u&&e>0&&n>e)continue;const a=i(o+e*r);m.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:a,y:p,width:c,height:g}})}if(null!=d)for(let e=0;n>e;e+=1){const n=o+e*r,a=n+r;if(a>=d)continue;const s=i(n),l=i(a);m.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(s,l)+c/2,y1:h,x2:Math.max(s,l)-c/2,y2:h,thickness:f}})}return m}({...a,idPrefix:e??n+"-xbin",yTop:o??t.y,yBottom:i??t.y+t.height}))}return i&&s.push(...Va({band:i,idPrefix:i.idPrefix??n+"-xband",plot:t,projection:"x"})),a&&s.push(...Va({band:a,idPrefix:a.idPrefix??n+"-yband",plot:t,projection:"y"})),s}function Ua(e){const{plot:t,rows:n,columns:o=n+1,pegRadius:r=3,idPrefix:i="galton-peg",yStart:a=t.y+.18*t.height,yEnd:s=t.y+.58*t.height,stagger:c=!0,restitution:l=.2,friction:u=.04}=e,d=Math.max(0,Math.floor(n)),h=Math.max(1,Math.floor(o));if(0===d)return[];const f=d>1?(s-a)/(d-1):0,m=t.width/h,p=[];for(let e=0;d>e;e+=1){const n=c&&e%2==1?m/2:0;for(let o=0;h>o;o+=1){const s=t.x+m*(o+.5)+n;t.x+r>s||s>t.x+t.width-r||p.push({id:`${i}-${e}-${o}`,shape:{type:"aabb",x:s,y:a+e*f,width:2*r,height:2*r},restitution:l,friction:u})}}return p}function Ka(e,t={}){const{idPrefix:n="physics-token",radius:o=5,shape:r,mass:i,vx:a,vy:s,spawnAt:c,seed:l=1,jitter:u,datum:d}=t,h=T(l),f=_a(u,"x"),m=_a(u,"y");return e.map((e,l)=>{const u=Ga(t.x,e,l,Ha(e,"x",0)),p=Ga(t.y,e,l,Ha(e,"y",0)),g=Ga(o,e,l,5),y="function"==typeof r?r(e,l):r??{type:"circle",radius:g};return{id:`${n}-${e.index??l}`,x:u+(h()-.5)*f,y:p+(h()-.5)*m,vx:Ga(a,e,l,0),vy:Ga(s,e,l,0),mass:Ga(i,e,l,1),spawnAt:Ga(c,e,l,void 0),shape:y,datum:d?d(e,l):e.datum??e}}).map(e=>{if(Number.isFinite(e.spawnAt))return e;const{spawnAt:t,...n}=e;return n})}function Qa(e,t={}){const{idPrefix:n="sediment",collider:o=!0,colliderThickness:r=1,restitution:i=.05,friction:a=.2,...s}=t,c=function(e,t={}){const{baselineY:n=0,binWidth:o=24,gap:r=2,maxHeight:i=80,value:a="count",x:s}=t,c=Math.max(1,...e.map(e=>e[a]));return e.map((e,t)=>{const l=Math.max(0,e[a]/c*i),u=s?.(e,t)??t*(o+r);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:n-l,width:o,height:l,meanX:e.x.mean,meanY:e.y.mean}})}(e,s),l=o?c.filter(e=>e.height>0).map(e=>({id:`${n}-${e.binId}`,shape:{type:"aabb",x:e.x+e.width/2,y:e.y+r/2,width:e.width,height:r},restitution:i,friction:a})):[];return{columns:c,colliders:l}}function Za(e,t={}){const{timeAccessor:n="arrivalTime",timeScale:o=1,startAt:r=0,rebase:i=!0,sort:a=!0}=t,s=e.map((e,t)=>({spawn:e,time:function(e,t,n){return Ya("function"==typeof n?n(e,t):e[n]??e.datum?.[n])}(e,t,n)??e.spawnAt??t})),c=s.length?Math.min(...s.map(e=>e.time)):0;return{initialSpawns:s.map(({spawn:e,time:t})=>({...e,spawnAt:r+(i?t-c:t)})).sort((e,t)=>a?(e.spawnAt??0)-(t.spawnAt??0):0),initialSpawnPacing:{pacing:"arrival",startAt:r,timeAccessor:"spawnAt",timeScale:o}}}function Ja(e,t,n="group"){const o=hi(e,t),r=e=>"function"==typeof n?n(e):e[n]??0;return e.slice().sort((e,t)=>{const n=r(e),i=r(t);return i>n?-1:n>i?1:(o[t.id]||0)-(o[e.id]||0)}).map(e=>e.id)}function es(e,t={}){const n=t.baseline??.62,o=t.inset??.06,r={},i=e.length;return e.forEach((e,t)=>{r[e]={x:i>1?o+t/(i-1)*(1-2*o):.5,y:n}}),r}function ts(e,t,n=.55){return`M${e.x},${e.y} Q${(e.x+t.x)/2},${e.y-Math.abs(t.x-e.x)*n} ${t.x},${t.y}`}function ns(e,t={}){const n=t.radius??.42,o=t.center?.x??.5,r=t.center?.y??.5,i=t.startAngle??0,a={},s=e.length;return e.forEach((e,t)=>{const c=i+t/s*Math.PI*2-Math.PI/2;a[e]={x:o+Math.cos(c)*n,y:r+Math.sin(c)*n}}),a}function os(e,t,n={}){const o=(n.order??Ja(e,t,n.groupAccessor??"group")).slice(),r=new Map(o.map((e,t)=>[e,t])),i=new Map;for(const e of t){if(!r.has(e.source)||!r.has(e.target)||e.source===e.target)continue;const t=e.target>e.source?`${e.source}\0${e.target}`:`${e.target}\0${e.source}`;i.set(t,(i.get(t)||0)+(e.value??1))}const a=[];let s=0;for(const[e,t]of i){const[n,o]=e.split("\0"),i=r.get(n),c=r.get(o);t>s&&(s=t),a.push({row:i,col:c,source:n,target:o,value:t}),a.push({row:c,col:i,source:o,target:n,value:t})}return{order:o,cells:a,size:o.length,maxValue:s}}function rs(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function is(e){if("string"!=typeof e)return;const t=e.trim();return t.length?t:void 0}function as(e,t){const n=rs(e.note)?e.note:void 0;return t?is(e.mobileText)||is(e.shortText)||is(e.label)||is(n?.mobileText)||is(n?.shortText)||is(n?.label)||is(n?.title):is(e.label)||is(e.mobileText)||is(e.shortText)||is(n?.label)||is(n?.title)}function ss(e,t,n){const o=function(e,t,n){if(!n)return;const o="function"==typeof n?n(e,t):e[n];return"number"==typeof o&&Number.isFinite(o)?o:void 0}(e,t,n.priorityAccessor);if(void 0!==o)return o;let r=1e3-t;const i=((e.emphasis??"")+"").toLowerCase();"primary"!==i&&"critical"!==i||(r+=1e4),"secondary"===i&&(r-=1e3),"high"===e.priority&&(r+=5e3),"low"===e.priority&&(r-=1500),"number"==typeof e.priority&&(r+=100*e.priority);const a=rs(e.provenance)?e.provenance:void 0;"number"==typeof a?.confidence&&(r+=100*a.confidence);const s=rs(e.lifecycle)?e.lifecycle:void 0,c=((s?.freshness??"")+"").toLowerCase();return"expired"!==c&&"stale"!==c||(r-=3e3),r}function cs(e,t){if(!t)return e;const n=as(e,!0);return n&&"string"==typeof e.label?{...e,label:n}:e}function ls(e,t={}){const n=Array.isArray(e)?e.filter(rs):[],o=t.active??(null==t.width||(t.breakpoint??480)>=t.width),r=t.strategy??"hybrid",i=!1!==t.preferShortText,a=!1!==t.preservePrimary,s=Math.max(0,t.maxPlotAnnotations??t.maxAnnotations??("callout-list"===r?1:2)),c=Math.max(0,t.minPlotAnnotations??t.minVisible??1);if(!o||"plot"===r)return{active:o,strategy:r,budget:n.length,visible:i?n.map(e=>cs(e,i)):n,deferred:[],calloutList:[],hidden:[]};const l=[],u=n.map((e,n)=>({annotation:e,index:n,priority:ss(e,n,t)})).filter(e=>!!Vn(e.annotation)||(l.push(e.annotation),!1)).sort((e,t)=>t.priority-e.priority),d=a?u.filter(e=>"primary"===((e.annotation.emphasis??"")+"").toLowerCase()):[],h=new Set(d.map(e=>e.index)),f=u.filter(e=>!h.has(e.index)),m=[...d,...f].slice(0,Math.max(s,c)),p=new Set(m.map(e=>e.index)),g=u.filter(e=>!p.has(e.index)),y=[...l,...m.sort((e,t)=>e.index-t.index).map(e=>cs(e.annotation,i))],x=g.sort((e,t)=>e.index-t.index).map(e=>e.annotation),b=Math.max(0,t.maxCalloutItems??6),w=g.filter(e=>!t.calloutFilter||t.calloutFilter(e.annotation,e.index)).map(e=>function(e,t,n,o){const r=as(e,o);if(!r)return null;const i=is(e.id)||is(e.key)||is(e.pointId)||"annotation-"+(t+1),a=rs(e.provenance)?is(e.provenance.source)||is(e.provenance.authorKind):void 0;return{id:i,label:r,shortLabel:is(e.shortText),pointId:e.pointId,emphasis:"string"==typeof e.emphasis?e.emphasis:void 0,source:a,priority:n,annotation:e}}(e.annotation,e.index,e.priority,i)).filter(e=>!!e).slice(0,b),M=new Set(w.map(e=>e.annotation)),v=x.filter(e=>!M.has(e));return{active:o,strategy:r,budget:s,visible:y,deferred:x,calloutList:w,hidden:v}}function us(e){return"dense"===e.density?.75:"compact"===e.density?.9:1}function ds(e,t){const n=!1!==t.keepAxes,o=!1===t.directLabel?12:28;return"ordinal"===e?{top:12,right:o,bottom:n?44:12,left:n?48:12}:"geo"===e||"network"===e?{top:12,right:12,bottom:12,left:12}:{top:12,right:o,bottom:n?42:14,left:n?44:14}}function hs(e,t,n,o={}){const r={...n},i={mode:!1===t.mode?void 0:"mobile",...r,margin:ds(e,t),...o},a=Object.fromEntries(Object.entries(r).filter(([,e])=>void 0!==e)),s=Object.fromEntries(Object.entries(i).filter(([,e])=>void 0!==e)),c=function(e,t){const n=t.targetSize??44,o=[],r=t.standardControls,i=e=>!0===r||"all"===r||r===e||Array.isArray(r)&&r.includes(e);return i("brush")&&o.push("range-inputs","clear-brush"),i("zoom")&&o.push("zoom-buttons","reset-view"),i("legend")&&o.push("legend-chips","show-all-series"),{strategy:`${e}-${t.transformProfile??"overview"}-mobile-recipe`,supportsResponsiveLayout:!0,breakpoints:[320,360,390,430,t.breakpoint??480,768],maxAnnotations:t.maxAnnotations??2,minimumHitTarget:n,summary:t.summary??!0,interaction:{primary:"tap",hoverFallback:"tap-to-lock",targetSize:n,...o.length>0&&{alternatives:o}},labels:{strategy:!1===t.directLabel?"compact":"direct",minFontSize:12}}}(e,t),l=function(e){return{tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:e.targetSize??44,snap:e.snap??"nearestDatum",brushHandleSize:e.targetSize??44,standardControls:e.standardControls??!1}}(t);return{family:e,props:a,responsiveRules:[{id:e+"-mobile",description:`Apply Semiotic's mobile ${e} recipe at phone width.`,when:{maxWidth:t.breakpoint??480},transform:{...s,mobileInteraction:l,mobileSemantics:c}}],mobileInteraction:l,mobileSemantics:c}}function fs(e={}){const t=us(e);return hs("line",e,{showLegend:e.showLegend??!1,directLabel:e.directLabel??!0,lineWidth:"inspect"===e.transformProfile?3:Math.max(1.5,2.5*t),showPoints:"inspect"===e.transformProfile,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function ms(e={}){const t=us(e);return hs("area",e,{showLegend:e.showLegend??!1,showPoints:!1,areaOpacity:"compare"===e.transformProfile?.55:.42,lineWidth:Math.max(1.25,2*t),autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function ps(e={}){return hs("ordinal",e,{showLegend:e.showLegend??!1,showCategoryTicks:e.keepAxes??!0,sort:"compare"===e.transformProfile?"desc":void 0},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function gs(e={}){const t=us(e);return hs("scatter",e,{showLegend:e.showLegend??!1,pointRadius:Math.max(4,Math.round((e.targetSize??44)/8*t)),hoverRadius:Math.ceil((e.targetSize??44)/2),pointOpacity:"dense"===e.density?.42:.68,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??1,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function ys(e={}){const t=us(e);return hs("network",e,{showLegend:e.showLegend??!1,nodeSizeRange:[Math.max(4,Math.round(6*t)),Math.max(12,Math.round((e.targetSize??44)/2*t))],showLabels:"inspect"===e.transformProfile,edgeOpacity:"dense"===e.density?.28:.44})}function xs(e={}){return hs("geo",e,{showLegend:e.showLegend??!1})}function bs(e={}){return hs("small-multiple",e,{mobileColumns:e.mobileColumns??1,tabletColumns:e.tabletColumns??2,chartHeight:e.chartHeight??180,sharedExtent:!0})}function ws(e,t={}){switch(e){case"line":return fs(t);case"area":return ms(t);case"ordinal":return ps(t);case"scatter":return gs(t);case"network":return ys(t);case"geo":return xs(t);case"small-multiple":return bs(t)}}function Ms(e={}){const t=e.controls??["range-inputs","chip-filter","clear"];return{mobileInteraction:{enabled:!0,targetSize:e.targetSize??44,tapToSelect:!0,tapToLockTooltip:!0,standardControls:"brush"},mobileSemantics:{interaction:{primary:"filter",alternatives:t,summary:e.summary??"Expose brushable ranges through touch-sized controls in addition to drag gestures."}},controls:t}}var vs=c(require("react")),ks=require("react/jsx-runtime");function $s({def:e,color:t,accent:n,paintOverride:o}){return(0,ks.jsx)(ks.Fragment,{children:e.parts.map((e,r)=>{const i=o?"none"===e.fill?void 0:o:Ur(e.fill,t,n),a=o?e.stroke&&"none"!==e.stroke?o:void 0:Ur(e.stroke??"none",t,n);return i||a?(0,ks.jsx)("path",{d:e.d,fill:i??"none",stroke:a,strokeWidth:a?e.strokeWidth??1:void 0,strokeLinecap:e.strokeLinecap,strokeLinejoin:e.strokeLinejoin,opacity:e.opacity},r):null})})}function As({def:e,size:t=24,color:n="currentColor",accent:o="#ffffff",fraction:r=1,fractionStart:i=0,fractionDirection:a="horizontal",ghostColor:s,x:c=0,y:l=0,opacity:u,className:d}){const h=vs.useId();if(!e?.parts?.length)return null;const[,f]=e.viewBox??Hr,m=t/(f>0?f:1);if(0>=m)return null;const p=Kr(e,r,i,a),g=p?"glyph-clip"+h.replace(/[^A-Za-z0-9_-]/g,"_"):void 0;return(0,ks.jsxs)("g",{className:d,transform:`translate(${c} ${l}) scale(${m})`,opacity:u,"aria-hidden":"true",children:[p&&g&&(0,ks.jsx)("clipPath",{id:g,children:(0,ks.jsx)("rect",{x:p.x,y:p.y,width:p.width,height:p.height})}),p&&s?(0,ks.jsx)($s,{def:e,color:n,accent:o,paintOverride:s}):null,p&&g?(0,ks.jsx)("g",{clipPath:`url(#${g})`,children:(0,ks.jsx)($s,{def:e,color:n,accent:o})}):(0,ks.jsx)($s,{def:e,color:n,accent:o})]})}