semiotic 3.8.4 → 3.8.5

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 (140) hide show
  1. package/CLAUDE.md +6 -3
  2. package/README.md +44 -38
  3. package/ai/componentMetadata.cjs +1 -1
  4. package/ai/dist/mcp-server.js +4 -2
  5. package/ai/examples.md +167 -0
  6. package/ai/schema.json +1004 -1
  7. package/ai/surface-manifest.json +6 -4
  8. package/ai/system-prompt.md +1 -1
  9. package/dist/chunk-chartContainerDataAudit-74TLKIP6.module.min.js +2 -0
  10. package/dist/{chunk-chunk-LQBSXO7K.module.min.js → chunk-chunk-4AANPFOX.module.min.js} +1 -1
  11. package/dist/{chunk-chunk-N6VKKF3A.module.min.js → chunk-chunk-5I3UZV4Q.module.min.js} +1 -1
  12. package/dist/chunk-chunk-74CCPVXB.module.min.js +1 -0
  13. package/dist/{chunk-chunk-6TPGFL7M.module.min.js → chunk-chunk-BANTPINB.module.min.js} +1 -1
  14. package/dist/chunk-chunk-CKMD5NV3.module.min.js +2 -0
  15. package/dist/chunk-chunk-CO5KQMGH.module.min.js +1 -0
  16. package/dist/{chunk-chunk-BFHUYEOS.module.min.js → chunk-chunk-CWQ5YIHX.module.min.js} +1 -1
  17. package/dist/chunk-chunk-E6TXX6MI.module.min.js +1 -0
  18. package/dist/{chunk-chunk-JDXT6ORT.module.min.js → chunk-chunk-I36PJ4OC.module.min.js} +1 -1
  19. package/dist/chunk-chunk-K3DMEW22.module.min.js +1 -0
  20. package/dist/chunk-chunk-KT2VAZMZ.module.min.js +1 -0
  21. package/dist/{chunk-chunk-AQPQN2HH.module.min.js → chunk-chunk-L6EA5V3G.module.min.js} +1 -1
  22. package/dist/{chunk-chunk-FBGHXL72.module.min.js → chunk-chunk-LJLS6DY7.module.min.js} +1 -1
  23. package/dist/chunk-chunk-LJPCLYSC.module.min.js +2 -0
  24. package/dist/{chunk-chunk-7RYBCTK5.module.min.js → chunk-chunk-N5DDKCCF.module.min.js} +1 -1
  25. package/dist/chunk-chunk-NLO44TOS.module.min.js +2 -0
  26. package/dist/{chunk-chunk-F5V4UIE6.module.min.js → chunk-chunk-PZJ2SBLL.module.min.js} +1 -1
  27. package/dist/chunk-chunk-QUJ6TTLY.module.min.js +1 -0
  28. package/dist/chunk-chunk-RBIDBUT4.module.min.js +2 -0
  29. package/dist/chunk-chunk-RFLAG356.module.min.js +1 -0
  30. package/dist/{chunk-chunk-7KZJUTKP.module.min.js → chunk-chunk-RPU4IZAV.module.min.js} +1 -1
  31. package/dist/{chunk-chunk-PLIDPQNG.module.min.js → chunk-chunk-SKMBCFIL.module.min.js} +1 -1
  32. package/dist/{chunk-chunk-SR4ZXOWR.module.min.js → chunk-chunk-TAE7W424.module.min.js} +1 -1
  33. package/dist/{chunk-chunk-KQ546MKE.module.min.js → chunk-chunk-TMWIZL3K.module.min.js} +1 -1
  34. package/dist/chunk-chunk-TUBMTZMU.module.min.js +2 -0
  35. package/dist/chunk-chunk-UFFEXJQY.module.min.js +1 -0
  36. package/dist/chunk-chunk-XSCHTS4D.module.min.js +2 -0
  37. package/dist/{chunk-chunk-F7WFPD4O.module.min.js → chunk-chunk-XXWSHGPL.module.min.js} +1 -1
  38. package/dist/chunk-chunk-ZXIXAPRE.module.min.js +2 -0
  39. package/dist/components/ChartContainer.d.ts +10 -0
  40. package/dist/components/ai/chartCapabilities.d.ts +2 -1
  41. package/dist/components/ai/chartCapabilityTypes.d.ts +14 -0
  42. package/dist/components/chartContainerDataAudit.d.ts +10 -0
  43. package/dist/components/charts/geo/DistanceCartogram.d.ts +29 -3
  44. package/dist/components/charts/index.d.ts +1 -0
  45. package/dist/components/charts/network/ForceDirectedGraph.d.ts +36 -1
  46. package/dist/components/charts/physics/CrucibleChart.capability.d.ts +8 -0
  47. package/dist/components/charts/physics/CrucibleChart.d.ts +63 -0
  48. package/dist/components/charts/physics/crucibleBodyRenderers.d.ts +27 -0
  49. package/dist/components/charts/physics/crucibleChartProps.d.ts +90 -0
  50. package/dist/components/charts/physics/crucibleChrome.d.ts +47 -0
  51. package/dist/components/charts/physics/crucibleController.d.ts +59 -0
  52. package/dist/components/charts/physics/crucibleEffects.d.ts +30 -0
  53. package/dist/components/charts/physics/cruciblePhysics.d.ts +54 -0
  54. package/dist/components/charts/physics/crucibleProgram.d.ts +38 -0
  55. package/dist/components/charts/physics/crucibleTypes.d.ts +415 -0
  56. package/dist/components/charts/shared/chartSpecCore.d.ts +8 -0
  57. package/dist/components/charts/shared/crucibleWireSchema.d.ts +5 -0
  58. package/dist/components/charts/shared/diagnoseTypes.d.ts +10 -0
  59. package/dist/components/charts/shared/knownChartComponents.d.ts +1 -1
  60. package/dist/components/data/auditData.d.ts +51 -0
  61. package/dist/components/data/dataAuditPresentation.d.ts +18 -0
  62. package/dist/components/data/dataAuditSources.d.ts +9 -0
  63. package/dist/components/data/numericContracts.d.ts +59 -0
  64. package/dist/components/data/numericFieldProfiler.d.ts +23 -0
  65. package/dist/components/recipes/netEnsembleLayout.d.ts +167 -0
  66. package/dist/components/recipes/netEnsembleOverlays.d.ts +20 -0
  67. package/dist/components/recipes/wordTrails.d.ts +156 -0
  68. package/dist/components/recipes/wordTrailsProgressiveReveal.d.ts +42 -0
  69. package/dist/components/semiotic-ai-core.d.ts +3 -0
  70. package/dist/components/semiotic-ai-data-audit.d.ts +4 -0
  71. package/dist/components/semiotic-ai.d.ts +7 -5
  72. package/dist/components/semiotic-physics.d.ts +1 -0
  73. package/dist/components/semiotic-recipes-core.d.ts +4 -0
  74. package/dist/components/semiotic-utils-core.d.ts +3 -0
  75. package/dist/components/semiotic.d.ts +1 -1
  76. package/dist/components/server/renderEvidence.d.ts +27 -0
  77. package/dist/components/server/serverChartConfigs.d.ts +1 -0
  78. package/dist/components/server/serverChartConfigsPhysics.d.ts +9 -0
  79. package/dist/components/server/staticAnnotations.d.ts +12 -0
  80. package/dist/components/stream/GeoPipelineStore.d.ts +1 -0
  81. package/dist/components/stream/GeoSVGOverlay.d.ts +7 -0
  82. package/dist/components/stream/geoCartogram.d.ts +7 -0
  83. package/dist/components/stream/geoTypes.d.ts +17 -2
  84. package/dist/components/stream/networkFrameHandleTypes.d.ts +4 -0
  85. package/dist/components/stream/physics/PhysicsSettledSVG.d.ts +8 -0
  86. package/dist/components/useChartContainerDataAudit.d.ts +7 -0
  87. package/dist/geo.min.js +1 -1
  88. package/dist/geo.module.min.js +1 -1
  89. package/dist/network.min.js +1 -1
  90. package/dist/network.module.min.js +1 -1
  91. package/dist/ordinal.module.min.js +1 -1
  92. package/dist/physics.min.js +1 -1
  93. package/dist/physics.module.min.js +1 -1
  94. package/dist/realtime.min.js +1 -1
  95. package/dist/realtime.module.min.js +1 -1
  96. package/dist/semiotic-ai-core.d.ts +3 -0
  97. package/dist/semiotic-ai-core.min.js +1 -1
  98. package/dist/semiotic-ai-core.module.min.js +1 -1
  99. package/dist/semiotic-ai.d.ts +7 -5
  100. package/dist/semiotic-ai.min.js +1 -1
  101. package/dist/semiotic-ai.module.min.js +1 -1
  102. package/dist/semiotic-experimental.min.js +1 -1
  103. package/dist/semiotic-experimental.module.min.js +1 -1
  104. package/dist/semiotic-physics.d.ts +1 -0
  105. package/dist/semiotic-realtime-core.min.js +1 -1
  106. package/dist/semiotic-realtime-core.module.min.js +1 -1
  107. package/dist/semiotic-recipes-core.d.ts +4 -0
  108. package/dist/semiotic-recipes-core.min.js +1 -1
  109. package/dist/semiotic-recipes-core.module.min.js +1 -1
  110. package/dist/semiotic-recipes.min.js +1 -1
  111. package/dist/semiotic-recipes.module.min.js +1 -1
  112. package/dist/semiotic-server-edge.min.js +1 -1
  113. package/dist/semiotic-server-edge.module.min.js +1 -1
  114. package/dist/semiotic-server-node.min.js +1 -1
  115. package/dist/semiotic-server-node.module.min.js +1 -1
  116. package/dist/semiotic-utils-core.d.ts +3 -0
  117. package/dist/semiotic-utils-core.min.js +1 -1
  118. package/dist/semiotic-utils-core.module.min.js +1 -1
  119. package/dist/semiotic-utils.min.js +1 -1
  120. package/dist/semiotic-utils.module.min.js +1 -1
  121. package/dist/semiotic.d.ts +1 -1
  122. package/dist/semiotic.min.js +1 -1
  123. package/dist/semiotic.module.min.js +1 -1
  124. package/dist/server.min.js +1 -1
  125. package/dist/server.module.min.js +1 -1
  126. package/dist/xy.module.min.js +1 -1
  127. package/package.json +2 -2
  128. package/dist/chunk-chunk-3ILKBVVQ.module.min.js +0 -1
  129. package/dist/chunk-chunk-ASKSE5F5.module.min.js +0 -1
  130. package/dist/chunk-chunk-B3DRZPBK.module.min.js +0 -2
  131. package/dist/chunk-chunk-FP44FHFO.module.min.js +0 -2
  132. package/dist/chunk-chunk-HKXUAEPJ.module.min.js +0 -2
  133. package/dist/chunk-chunk-ICEXPNDC.module.min.js +0 -2
  134. package/dist/chunk-chunk-JMVEIZXP.module.min.js +0 -1
  135. package/dist/chunk-chunk-KHCOJMGK.module.min.js +0 -1
  136. package/dist/chunk-chunk-MFHF4J2Z.module.min.js +0 -1
  137. package/dist/chunk-chunk-NKZ75IM5.module.min.js +0 -2
  138. package/dist/chunk-chunk-QGZGZI4X.module.min.js +0 -1
  139. package/dist/chunk-chunk-RP7WTID5.module.min.js +0 -1
  140. package/dist/chunk-chunk-S7KLNUO6.module.min.js +0 -1
@@ -0,0 +1 @@
1
+ import{useReducedMotion as e,useTheme as t}from"./chunk-chunk-XEVJDUTH.module.min.js";import{annotationActivationProps as n,defaultTooltipStyle as r,extractAllRows as o,hatchPatternDef as i,isHatchFill as a,resolveHatchCanvasPattern as l,resolveResponsiveRules as s,resolveSvgFill as c,useObservationSelector as d}from"./chunk-chunk-CO5KQMGH.module.min.js";import{FrameRuntime as u,SEQUENTIAL_INTERPOLATORS as h,glyphFractionClipRect as f,glyphPlacement as y,isInBounds as m,resolveAnchoredPosition as p,resolveGlyphPaint as g,resolveX as b,resolveY as x,schemeCategory10 as v,schemeSet3 as k,schemeTableau10 as w,symbolPathString as $}from"./chunk-chunk-5RKXZQ2P.module.min.js";import{getMinMax as M}from"./chunk-chunk-JJ2OOIET.module.min.js";import{clearCSSColorCache as S,resolveCSSColor as A}from"./chunk-chunk-IY7RYD4S.module.min.js";import{createStore as W,useThemeSelector as j}from"./chunk-chunk-DSNGDNJY.module.min.js";var C=Object.freeze([]);function R(e){if(!e)return C;let t=!1;for(let n=0;e.length>n;n++){const r=e[n];if(null==r||"object"!=typeof r){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}import{memo as O,useEffect as L,useRef as I}from"react";var N={sceneGeometry:0,layout:0,domain:0};function z(e){const{domain:t,layout:n,sceneGeometry:r}=e.revisions;return{domain:t,layout:n,sceneGeometry:r}}function F(e,t){return{sceneGeometry:Math.max(e.sceneGeometry,t.sceneGeometry),layout:Math.max(e.layout,t.layout),domain:Math.max(e.domain,t.domain)}}var D="production"!==process.env.NODE_ENV,P={revisions:N,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},T=class{constructor(e="scene host"){this.hostName=e,this.lastConsumed=N,this.lastObserved=N,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}observeUpdateResult(e){D&&(this.lastObserved=F(this.lastObserved,z(e)))}beforeCompute(e,t){if(!D)return P;const n=F(z(e),this.lastObserved),r=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),o=!((i=n).sceneGeometry===(a=this.lastConsumed).sceneGeometry&&i.layout===a.layout&&i.domain===a.domain);var i,a;return{revisions:n,signature:r,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:o,warnUnconsumed:!t&&o&&this.lastUnconsumedWarning!==r}}afterCompute(e,t,n){if(D){if(t&&e.wasUnconsumed&&(this.lastConsumed=e.revisions),e.warnUnconsumed&&!t)return console.warn(`[semiotic] ${this.hostName} observed scene-affecting revisions without a scene rebuild: ${e.signature}.`),void(this.lastUnconsumedWarning=e.signature);t&&e.sawSignals&&!e.wasUnconsumed&&!n&&this.lastDuplicateWarning!==e.signature?(console.warn(`[semiotic] ${this.hostName} performed scene rebuild with unchanged scene revisions: ${e.signature}.`),this.lastDuplicateWarning=e.signature):t&&!e.sawSignals&&(this.lastDuplicateWarning="")}}};function B(e){return I(new T(e))}function E(e,t,n,r=!1,o=!1){const i=e.beforeCompute(t.getLastUpdateResult(),r);n(),e.afterCompute(i,!0,o)}var H=O(function({store:e,diagnostics:t}){return L(()=>{const n=()=>t.observeUpdateResult(e.getUpdateSnapshot());return n(),e.subscribeUpdateResult(n)},[t,e]),null}),G=22;function q(e){return"string"==typeof e&&e.length>0}function _(e,t,n=!1){const r=n?t?58:34:t?36:0;return r>e.top?{...e,top:r}:e}function Y(e,t){return _(e,q(t))}import*as V from"react";import{arc as U}from"d3-shape";function Z(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}function X(e){const t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(e.w,e.h)/2,r=e=>Math.max(0,Math.min(e??0,n));return{tl:r(t.tl),tr:r(t.tr),br:r(t.br),bl:r(t.bl)}}var K=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)});function J(e){const{innerRadius:t,outerRadius:n,startAngle:r,endAngle:o}=e,i=0>=t;if(0>=(e.cornerRadius??0)||!e.roundStart&&!e.roundEnd){if(i){const e=K(n,r),t=K(n,o);return`M0,0 L${e.x},${e.y} A${n},${n} 0 ${o-r>Math.PI?1:0} 1 ${t.x},${t.y} Z`}const e=K(n,r),a=K(n,o),l=K(t,o),s=K(t,r),c=o-r>Math.PI?1:0;return`M${e.x},${e.y} A${n},${n} 0 ${c} 1 ${a.x},${a.y} L${l.x},${l.y} A${t},${t} 0 ${c} 0 ${s.x},${s.y} Z`}const a=Math.max(0,Math.min(e.cornerRadius??0,(n-t)/2));if(0===a)return J({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const l=Math.asin(Math.min(1,a/Math.max(1e-9,n-a))),s=i?0:Math.asin(Math.min(1,a/Math.max(1e-9,t+a))),c=o-r,d=e.roundStart&&e.roundEnd?c/2:c,u=!!e.roundStart&&d>l,h=!!e.roundEnd&&d>l;if(!u&&!h)return J({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const f=r+(u?l:0),y=o-(h?l:0),m=r+(u?s:0),p=o-(h?s:0),g=K(n,f),b=K(n,y),x=(n-a)*Math.cos(l),v=K(x,r),k=K(x,o),w=i?null:K(t,p),$=i?null:K(t,m),M=i?0:(t+a)*Math.cos(s),S=i?null:K(M,r),A=i?null:K(M,o),W=y-f>Math.PI?1:0,j=i?0:p-m>Math.PI?1:0;let C="";if(u)C+=`M${v.x},${v.y}`,C+=` A${a},${a} 0 0 1 ${g.x},${g.y}`;else{const e=K(n,r);C+=`M${e.x},${e.y}`}if(h)C+=` A${n},${n} 0 ${W} 1 ${b.x},${b.y}`,C+=` A${a},${a} 0 0 1 ${k.x},${k.y}`;else{const e=K(n,o);C+=` A${n},${n} 0 ${W} 1 ${e.x},${e.y}`}if(i)C+=" L0,0";else{if(h)C+=` L${A.x},${A.y}`,C+=` A${a},${a} 0 0 1 ${w.x},${w.y}`;else{const e=K(t,o);C+=` L${e.x},${e.y}`}if(u)C+=` A${t},${t} 0 ${j} 0 ${$.x},${$.y}`,C+=` A${a},${a} 0 0 1 ${S.x},${S.y}`;else{const e=K(t,r);C+=` A${t},${t} 0 ${j} 0 ${e.x},${e.y}`}}return C+=" Z",C}import{jsx as Q,jsxs as ee}from"react/jsx-runtime";var te={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function ne(e,t="#4e79a7"){return a(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function re(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}function oe(e,t,n,r){const o=e.glyph;if(!o?.parts?.length||0>=e.size)return null;const i=y(o,e.size);if(0>=i.scale)return null;const a=`translate(${t},${n})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${i.offsetX},${i.offsetY}) scale(${i.scale})`,l=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),s=f(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),c=s?re(r+"-clip"):void 0,d=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),u=t=>o.parts.map((n,r)=>{const o=t?"none"===n.fill?void 0:t:g(n.fill,l,e.accent),i=t?n.stroke&&"none"!==n.stroke?t:void 0:g(n.stroke??"none",l,e.accent);return o||i?Q("path",{d:n.d,fill:o??"none",stroke:i,strokeWidth:i?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},r):null});return ee("g",{transform:a,opacity:1===d?void 0:d,children:[s&&c&&Q("clipPath",{id:c,children:Q("rect",{x:s.x,y:s.y,width:s.width,height:s.height})}),s&&e.ghostColor?Q("g",{children:u(e.ghostColor)}):null,s&&c?Q("g",{clipPath:`url(#${c})`,children:u()}):u()]},r)}function ie(e){const t=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));return 2>t.length?null:t.map((e,t)=>Q("stop",{offset:e.offset,stopColor:e.color},t))}function ae(e,t,n){const r=$(e.symbolType,e.size,e.path);return Q("path",{d:r,transform:e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`,fill:e.style.fill?ne(e.style.fill):"none",fillOpacity:e.style.fillOpacity,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${n??""}symbol-${t}`)}import{jsx as le,jsxs as se}from"react/jsx-runtime";function ce(e){return 1e6>e?1e4>e?1e3>e?e+"":(e/1e3).toFixed(1)+"K":(e/1e3).toFixed(0)+"K":(e/1e6).toFixed(1)+"M"}function de(e,t){const n=e.datum;if(!n)return null;const r=[],o=n.__funnelStepLabel,i=Number(n.__funnelStepLabelX),a=Number(n.__funnelStepLabelY),l=Number(n.__funnelRowWidth);"string"!=typeof o||!Number.isFinite(i)||!Number.isFinite(a)||Number.isFinite(l)&&8.4*o.length+16>l||r.push(le("text",{x:i,y:a+3,textAnchor:"middle",dominantBaseline:"hanging",fontSize:14,fontWeight:"bold",fill:"#fff",stroke:"rgba(0,0,0,0.6)",strokeWidth:3,paintOrder:"stroke",children:o},t+"-funnel-step"));const s=Number(n.__funnelValue),c=Number(n.__funnelValueLabelX),d=Number(n.__funnelValueLabelY),u=Number(n.__funnelBarW);if(Number.isFinite(s)&&0!==s&&Number.isFinite(c)&&Number.isFinite(d)&&u>=60){const e=Number(n.__funnelPercent);let o=!0!==n.__funnelIsFirstStep&&Number.isFinite(e)?`${ce(s)} (${.05>Math.abs(e-Math.round(e))?Math.round(e):e.toFixed(1)}%)`:ce(s);7.8*o.length+16>u&&(o=ce(s)),7.8*o.length+16>u||r.push(le("text",{x:c,y:d+22,textAnchor:"middle",dominantBaseline:"hanging",fontSize:13,fontWeight:"bold",fill:"#fff",stroke:"rgba(0,0,0,0.5)",strokeWidth:3,paintOrder:"stroke",children:o},t+"-funnel-value"))}return r.length?le("g",{children:r},t+"-funnel-labels"):null}function ue(e,t,n){const r=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",o=n=>`ord-${e.type}-${r}-${t}-${n}`,l=`ord-${e.type}-${r}-${t}`;switch(e.type){case"rect":{const t=e,n=re(l)+"-grad",r=function(e,t){const n=e.fillGradient;if(!n||"object"!=typeof n)return null;let r=e.x,o=e.y,i=e.x,a=e.y+e.h;"bottom"===e.roundedEdge?(o=e.y+e.h,a=e.y):"right"===e.roundedEdge?(r=e.x+e.w,o=e.y,i=e.x,a=e.y):"left"===e.roundedEdge&&(r=e.x,o=e.y,i=e.x+e.w,a=e.y);const l=[];if("colorStops"in n){const e=ie(n.colorStops);if(!e)return null;l.push(...e)}else{const t=ne(e.style.fill);l.push(Q("stop",{offset:0,stopColor:t,stopOpacity:n.topOpacity},"0")),l.push(Q("stop",{offset:1,stopColor:t,stopOpacity:n.bottomOpacity},"1"))}return Q("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:r,y1:o,x2:i,y2:a,children:l})}(t,n);let o,s;if(r)s=`url(#${n})`;else if(a(t.style.fill)){const e=re(l)+"-hatch";o=i(t.style.fill,e),s=`url(#${e})`}else s=ne(t.style.fill);const c=r||o?se("defs",{children:[r,o]}):null;if(t.cornerRadii&&Z(t.cornerRadii)){const e=function(e){const{x:t,y:n,w:r,h:o}=e,{tl:i,tr:a,br:l,bl:s}=X(e);let c=`M${t+i},${n}`;return c+=` L${t+r-a},${n}`,a>0&&(c+=` A${a},${a} 0 0 1 ${t+r},${n+a}`),c+=` L${t+r},${n+o-l}`,l>0&&(c+=` A${l},${l} 0 0 1 ${t+r-l},${n+o}`),c+=` L${t+s},${n+o}`,s>0&&(c+=` A${s},${s} 0 0 1 ${t},${n+o-s}`),c+=` L${t},${n+i}`,i>0&&(c+=` A${i},${i} 0 0 1 ${t+i},${n}`),c+=" Z",c}(t);return se(V.Fragment,{children:[c,le("path",{d:e,fill:s,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},l)}if(t.roundedTop&&t.roundedTop>0){const e=Math.min(t.roundedTop,t.w/2,t.h/2),{x:n,y:r,w:o,h:i}=t;let a;switch(t.roundedEdge){case"right":a=`M${n},${r} L${n+o-e},${r} A${e},${e} 0 0 1 ${n+o},${r+e} L${n+o},${r+i-e} A${e},${e} 0 0 1 ${n+o-e},${r+i} L${n},${r+i} Z`;break;case"left":a=`M${n+o},${r} L${n+e},${r} A${e},${e} 0 0 0 ${n},${r+e} L${n},${r+i-e} A${e},${e} 0 0 0 ${n+e},${r+i} L${n+o},${r+i} Z`;break;case"bottom":a=`M${n},${r} L${n+o},${r} L${n+o},${r+i-e} A${e},${e} 0 0 1 ${n+o-e},${r+i} L${n+e},${r+i} A${e},${e} 0 0 1 ${n},${r+i-e} Z`;break;default:a=`M${n},${r+i} L${n},${r+e} A${e},${e} 0 0 1 ${n+e},${r} L${n+o-e},${r} A${e},${e} 0 0 1 ${n+o},${r+e} L${n+o},${r+i} Z`}return se(V.Fragment,{children:[c,le("path",{d:a,fill:s,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},l)}return se(V.Fragment,{children:[c,le("rect",{x:t.x,y:t.y,width:t.w,height:t.h,fill:s,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth}),de(t,l)]},l)}case"point":{const t=e;return le("circle",{cx:t.x,cy:t.y,r:t.r,fill:ne(t.style.fill),opacity:t.style.opacity??t.style.fillOpacity??.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},l)}case"symbol":return ae(e,t,n);case"glyph":return oe(e,e.x,e.y,`${n??""}ord-glyph-${e.pointId??t}`);case"wedge":{const r=e;if(r._gradientBand&&r._gradientBand.colors.length>0){const e=re(`${n?n+"-":""}gauge-grad-${r.category||l}-${t}`),{clipPath:o,slices:i}=function(e){const t=J({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,cornerRadius:e.cornerRadius,roundStart:e.roundStart,roundEnd:e.roundEnd}),n=[],r=e.colors;if(r.length>0){const t=(e.endAngle-e.startAngle)/r.length;for(let o=0;r.length>o;o++)n.push({d:J({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle+o*t,endAngle:e.endAngle}),color:r[o]})}return{clipPath:t,slices:n}}({innerRadius:r.innerRadius,outerRadius:r.outerRadius,startAngle:r.startAngle,endAngle:r.endAngle,cornerRadius:r.cornerRadius,roundStart:r.roundedEnds?.start??!0,roundEnd:r.roundedEnds?.end??!0,colors:r._gradientBand.colors});return se("g",{transform:`translate(${r.cx},${r.cy})`,opacity:r.style.opacity,fillOpacity:r.style.fillOpacity,children:[le("defs",{children:le("clipPath",{id:e,children:le("path",{d:o})})}),le("g",{clipPath:`url(#${e})`,children:i.map((e,t)=>le("path",{d:e.d,fill:ne(e.color)},t))}),r.style.stroke&&"none"!==r.style.stroke&&le("path",{d:o,fill:"none",stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},l)}let o;if(r.roundedEnds)o=J({innerRadius:r.innerRadius,outerRadius:r.outerRadius,startAngle:r.startAngle,endAngle:r.endAngle,cornerRadius:r.cornerRadius,roundStart:r.roundedEnds.start,roundEnd:r.roundedEnds.end});else{const e=U().innerRadius(r.innerRadius).outerRadius(r.outerRadius).startAngle(r.startAngle+Math.PI/2).endAngle(r.endAngle+Math.PI/2);r.cornerRadius&&e.cornerRadius(r.cornerRadius),o=e(te)||""}return le("path",{d:o,transform:`translate(${r.cx},${r.cy})`,fill:ne(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity},l)}case"boxplot":{const t=e,n=t.columnWidth/2;return se("g","vertical"===t.projection?{children:[le("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1}),le("rect",{x:t.x-n,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:ne(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),le("line",{x1:t.x-n,y1:t.medianPos,x2:t.x+n,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2}),le("line",{x1:t.x-.5*n,y1:t.minPos,x2:t.x+.5*n,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:1}),le("line",{x1:t.x-.5*n,y1:t.maxPos,x2:t.x+.5*n,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1})]}:{children:[le("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:1}),le("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-n,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:ne(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),le("line",{x1:t.medianPos,y1:t.y-n,x2:t.medianPos,y2:t.y+n,stroke:t.style.stroke||"#333",strokeWidth:2}),le("line",{x1:t.minPos,y1:t.y-.5*n,x2:t.minPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1}),le("line",{x1:t.maxPos,y1:t.y-.5*n,x2:t.maxPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1})]},l)}case"violin":{const t=e,n=[le("path",{d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:ne(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:t.style.strokeWidth||1},o("path"))];if(t.iqrLine&&t.bounds){const e=t.bounds,r=e.x+e.width/2,i=e.y+e.height/2;t.iqrLine.isVertical?n.push(le("line",{x1:r,y1:t.iqrLine.q1Pos,x2:r,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2},o("iqr")),le("circle",{cx:r,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},o("med"))):n.push(le("line",{x1:t.iqrLine.q1Pos,y1:i,x2:t.iqrLine.q3Pos,y2:i,stroke:t.style.stroke||"#333",strokeWidth:2},o("iqr")),le("circle",{cx:t.iqrLine.medianPos,cy:i,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},o("med")))}return le("g",{children:n},l)}case"connector":return le("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity??.5},l);case"trapezoid":{const t=e,n=t.points.map(e=>`${e[0]},${e[1]}`).join(" ");return le("polygon",{points:n,fill:ne(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},l)}default:return null}}import*as he from"react";import{area as fe,line as ye}from"d3-shape";import{curveMonotoneX as me,curveMonotoneY as pe,curveCardinal as ge,curveCatmullRom as be,curveStep as xe,curveStepBefore as ve,curveStepAfter as ke,curveBasis as we,curveNatural as $e}from"d3-shape";function Me(e){switch(e){case"monotoneX":return me;case"monotoneY":return pe;case"cardinal":return ge;case"catmullRom":return be;case"step":return xe;case"stepBefore":return ve;case"stepAfter":return ke;case"basis":return we;case"natural":return $e;default:return null}}function Se(e,t,n){if(null==t)return n;if(a(t)){return l(t,e)||t.background&&A(e,t.background)||n}return"string"!=typeof t?t:A(e,t)||n}function Ae(e,t){if(null==t)return;const n=Se(e,t,"");return""===n?void 0:n}function We(e,t,n,r,o,i,a){if("colorStops"in t){const n=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>n.length)return null;const l=e.createLinearGradient(r,o,i,a);for(const e of n)l.addColorStop(e.offset,e.color);return l}const{topOpacity:l,bottomOpacity:s}=t;if(!Number.isFinite(l)||!Number.isFinite(s))return null;const c=Math.max(0,Math.min(1,l)),d=Math.max(0,Math.min(1,s)),u=e.createLinearGradient(r,o,i,a),[h,f,y]=function(e,t){const n=e.fillStyle,r="#010203";try{e.fillStyle=r,e.fillStyle=t}catch{return e.fillStyle=n,[78,121,167]}const o=e.fillStyle;if(e.fillStyle=n,"string"!=typeof o)return[78,121,167];if(o.toLowerCase()===r&&t.trim().toLowerCase()!==r)return[78,121,167];if(o.startsWith("#"))return[parseInt(o.slice(1,3),16),parseInt(o.slice(3,5),16),parseInt(o.slice(5,7),16)];const i=o.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return i?[+i[1],+i[2],+i[3]]:[78,121,167]}(e,n);return u.addColorStop(0,`rgba(${h},${f},${y},${c})`),u.addColorStop(1,`rgba(${h},${f},${y},${d})`),u}function je(e,t,n,r,o,i){const a=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>a.length)return null;const l=e.createLinearGradient(n,r,o,i);for(const e of a)l.addColorStop(e.offset,e.color);return l}import*as Ce from"react";import{arc as Re}from"d3-shape";import{jsx as Oe,jsxs as Le}from"react/jsx-runtime";function Ie(e,t){switch(e.type){case"circle":{const n=e,r=a(n.style.fill)?i(n.style.fill,`net-circle-${t}-hatch`):void 0;return Le(Ce.Fragment,{children:[r&&Oe("defs",{children:r}),Oe("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:r?`url(#net-circle-${t}-hatch)`:ne(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-circle-"+t)}case"rect":{const n=e,r=a(n.style.fill)?i(n.style.fill,`net-rect-${t}-hatch`):void 0;return Le(Ce.Fragment,{children:[r&&Oe("defs",{children:r}),Oe("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:r?`url(#net-rect-${t}-hatch)`:ne(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-rect-"+t)}case"arc":{const n=e,r=Re().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(te)||"",o=a(n.style.fill)?i(n.style.fill,`net-arc-${t}-hatch`):void 0;return Le(Ce.Fragment,{children:[o&&Oe("defs",{children:o}),Oe("path",{d:r,transform:`translate(${n.cx},${n.cy})`,fill:o?`url(#net-arc-${t}-hatch)`:ne(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-arc-"+t)}case"symbol":{const n=e,r=$(n.symbolType,n.size,n.path);return Oe("path",{d:r,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?ne(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return oe(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}function Ne(e,t){switch(e.type){case"line":return Oe("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+t);case"bezier":{const n=e;return Oe("path",{d:n.pathD,fill:ne(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"ribbon":{const n=e;return Oe("path",{d:n.pathD,fill:ne(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"curved":{const n=e;return Oe("path",{d:n.pathD,fill:ne(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+t)}default:return null}}function ze(e,t){return Oe("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+t)}import*as Fe from"react";import{jsx as De,jsxs as Pe}from"react/jsx-runtime";function Te(e,t){switch(e.type){case"geoarea":{const n=e;if(!n.pathData)return null;const r=a(n.style.fill)?i(n.style.fill,`geoarea-${t}-hatch`):void 0;return Pe(Fe.Fragment,{children:[r&&De("defs",{children:r}),De("path",{d:n.pathData,fill:r?`url(#geoarea-${t}-hatch)`:ne(n.style.fill,"#e0e0e0"),fillOpacity:n.style.fillOpacity??1,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth||.5,strokeDasharray:n.style.strokeDasharray,opacity:n._decayOpacity??1})]},"geoarea-"+t)}case"point":{const n=e,r=a(n.style.fill)?i(n.style.fill,`geopoint-${t}-hatch`):void 0;return Pe(Fe.Fragment,{children:[r&&De("defs",{children:r}),De("circle",{cx:n.x,cy:n.y,r:n.r,fill:r?`url(#geopoint-${t}-hatch)`:ne(n.style.fill),fillOpacity:n.style.fillOpacity??.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n._decayOpacity??n.style.opacity??1})]},"point-"+t)}case"line":{const n=e;if(2>n.path.length)return null;const r="M"+n.path.map(e=>`${e[0]},${e[1]}`).join("L");return De("path",{d:r,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||1.5,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity??1},"line-"+t)}case"glyph":return oe(e,e.x,e.y,"geo-glyph-"+(e.pointId??t));default:return null}}import{jsx as Be,jsxs as Ee}from"react/jsx-runtime";function He(e,t,n){if(!e||2>t.length)return null;const r=ie(e.colorStops);return r?Be("linearGradient",{id:n,gradientUnits:"userSpaceOnUse",x1:t[0][0],y1:0,x2:t[t.length-1][0],y2:0,children:r}):null}function Ge(e,t,n){switch(e.type){case"line":{const r=e;if(0===r.path.length)return null;const o=Me(r.curve),i=o?ye().x(([e])=>e).y(([,e])=>e).curve(o)(r.path)??"":"M"+r.path.map(([e,t])=>`${e},${t}`).join("L"),a=re(`${n?n+"-":""}line-${t}-stroke-gradient`),l=He(r.strokeGradient,r.path,a);return Ee(he.Fragment,{children:[l&&Be("defs",{children:l}),Be("path",{d:i,fill:"none",stroke:l?`url(#${a})`:r.style.stroke||"#4e79a7",strokeWidth:r.style.strokeWidth||2,strokeDasharray:r.style.strokeDasharray,opacity:r.style.opacity})]},"line-"+t)}case"area":{const r=e;if(0===r.topPath.length)return null;const o=Me(r.curve),l=!o||2>r.topPath.length||2>r.bottomPath.length?`M${r.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`:fe().x(([e])=>e).y0((e,t)=>r.bottomPath[t][1]).y1(([,e])=>e).curve(o)(r.topPath)??"",s=`${n?n+"-":""}area-${t}-hatch`,c=a(r.style.fill)?i(r.style.fill,s):void 0,d=re(`${n?n+"-":""}area-${t}-gradient`),u=function(e,t){const n=e.fillGradient;if(!n||"object"!=typeof n)return null;let r=1/0;for(const[,t]of e.topPath)r=Math.min(r,t);let o=-1/0;for(const[,t]of e.bottomPath)o=Math.max(o,t);if(!Number.isFinite(r)||!Number.isFinite(o))return null;const i=[];if("colorStops"in n){const e=ie(n.colorStops);if(!e)return null;i.push(...e)}else{if(!Number.isFinite(n.topOpacity)||!Number.isFinite(n.bottomOpacity))return null;i.push(Be("stop",{offset:0,stopColor:ne(e.style.fill),stopOpacity:Math.max(0,Math.min(1,n.topOpacity))},"0")),i.push(Be("stop",{offset:1,stopColor:ne(e.style.fill),stopOpacity:Math.max(0,Math.min(1,n.bottomOpacity))},"1"))}return Be("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:0,y1:r,x2:0,y2:o,children:i})}(r,d),h=u?`url(#${d})`:c?`url(#${s})`:ne(r.style.fill),f=u?void 0:r.style.fillOpacity??r.style.opacity??.7,y=o?ye().x(([e])=>e).y(([,e])=>e).curve(o)(r.topPath)??"":"M"+r.topPath.map(([e,t])=>`${e},${t}`).join("L"),m=re(`${n?n+"-":""}area-${t}-stroke-gradient`),p=He(r.strokeGradient,r.topPath,m),g=r.style.stroke&&"none"!==r.style.stroke?Be("path",{d:y,fill:"none",stroke:p?`url(#${m})`:ne(r.style.stroke),strokeWidth:r.style.strokeWidth||2,opacity:r.style.opacity}):null;if(r.clipRect){const e=`${n?n+"-":""}area-clip-${t}`;return Ee("g",{children:[Ee("defs",{children:[u,!u&&c,p,Be("clipPath",{id:e,children:Be("rect",{x:r.clipRect.x,y:r.clipRect.y,width:r.clipRect.width,height:r.clipRect.height})})]}),Ee("g",{clipPath:`url(#${e})`,children:[Be("path",{d:l,fill:h,fillOpacity:f,opacity:u?r.style.opacity:void 0,stroke:"none"}),g]})]},"area-"+t)}return Ee(he.Fragment,{children:[(u||c||p)&&Ee("defs",{children:[u,!u&&c,p]}),Be("path",{d:l,fill:h,fillOpacity:f,opacity:u?r.style.opacity:void 0,stroke:"none"}),g]},"area-"+t)}case"point":{const r=e,o=`${n?n+"-":""}point-${t}-hatch`,l=a(r.style.fill)?i(r.style.fill,o):void 0;return Ee(he.Fragment,{children:[l&&Be("defs",{children:l}),Be("circle",{cx:r.x,cy:r.y,r:r.r,fill:l?`url(#${o})`:ne(r.style.fill),opacity:r.style.opacity??r.style.fillOpacity??.8,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},"point-"+t)}case"symbol":return ae(e,t);case"glyph":return oe(e,e.x,e.y,`${n??""}glyph-${e.pointId??t}`);case"rect":{const r=e,o=`${n?n+"-":""}xyrect-${t}-hatch`,l=a(r.style.fill)?i(r.style.fill,o):void 0;return Ee(he.Fragment,{children:[l&&Be("defs",{children:l}),Be("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:l?`url(#${o})`:ne(r.style.fill),opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},"rect-"+t)}case"heatcell":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[r,o,i]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(n.fill),a=.299*r+.587*o+.114*i>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return Ee("g",{children:[Be("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill,stroke:n.style?.stroke,strokeWidth:n.style?.strokeWidth}),Be("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:l+"px",children:e})]},"heatcell-"+t)}return Be("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill,stroke:n.style?.stroke,strokeWidth:n.style?.strokeWidth},"heatcell-"+t)}case"candlestick":{const n=e;if(n.isRange){const e=n.dotRadius??Math.max(2,n.bodyWidth/2);return Ee("g",{children:[Be("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),Be("circle",{cx:n.x,cy:n.highY,r:e,fill:n.wickColor}),Be("circle",{cx:n.x,cy:n.lowY,r:e,fill:n.wickColor})]},"candle-"+t)}const r=Math.min(n.openY,n.closeY),o=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return Ee("g",{children:[Be("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),Be("rect",{x:n.x-n.bodyWidth/2,y:r,width:n.bodyWidth,height:o,fill:i,stroke:i,strokeWidth:1})]},"candle-"+t)}default:return null}}var qe="undefined"==typeof window||"undefined"==typeof document;import{useEffect as _e,useLayoutEffect as Ye,useRef as Ve,useState as Ue,useSyncExternalStore as Ze}from"react";var Xe="undefined"!=typeof window?Ye:_e;function Ke(){const[e,t]=Ue(!1);return Xe(()=>{t(!0)},[]),e}var Je=()=>()=>{},Qe=()=>!1,et=()=>!0;function tt(){const e=Ze(Je,Qe,et);return Ve(e).current}import{jsx as nt}from"react/jsx-runtime";var rt={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function ot({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+n}return nt("div",{"aria-live":"polite","aria-atomic":"true",style:rt,children:t})}import*as it from"react";import*as at from"react";import{jsx as lt}from"react/jsx-runtime";var st=at.createContext(null);function ct(){return at.useContext(st)}import{jsx as dt,jsxs as ut}from"react/jsx-runtime";function ht(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e){if(null===t?.datum)continue;const e=t.type+"";n[e]=(n[e]||0)+1}if(0===Object.keys(n).length)return t+", empty";const r=[],o={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],a=Object.keys(n).sort((e,t)=>{const n=i.indexOf(e),r=i.indexOf(t);return(-1===n?999:n)-(-1===r?999:r)});for(const e of a)r.push(`${n[e]} ${o[e]||e}`);return`${t}, ${r.join(", ")}`}function ft(e,t,n){const r=[];return e>0&&r.push(e+" nodes"),t>0&&r.push(t+" edges"),0===r.length?n+", empty":`${n}, ${r.join(", ")}`}var yt=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},mt="semiotic-accessible-data-table",pt=mt+" semiotic-accessible-data-table-hidden",gt=mt+" semiotic-accessible-data-table-visible",bt=gt+" semiotic-accessible-data-table-network",xt={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},vt={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},kt={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},wt={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},$t={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},Mt={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},St={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},At={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function Wt({scene:e,chartType:t,tableId:n,chartTitle:r}){const[i,a]=it.useState(!1),[l,s]=it.useState(5),c=ct(),d=c?.visible??!1,u=i||d,h=it.useRef(null),f=r?"Data summary for "+r:n?`Data summary for ${t} ${n}`:"Data summary for "+t;it.useEffect(()=>{u||s(5)},[u]);const y=it.useCallback(e=>{e.target===e.currentTarget&&(i||d||a(!0))},[i,d]),m=it.useCallback(e=>{d||h.current?.contains(e.relatedTarget)||a(!1)},[d]);if(!e||0===e.length)return n?dt("span",{id:n,tabIndex:-1,style:rt}):null;if(!u)return dt("div",{id:n,className:pt,tabIndex:-1,onFocus:y,style:rt,role:"region","aria-label":f,children:ut("button",{type:"button",onClick:()=>a(!0),children:["View data summary (",e.length," elements)"]})});const p=o(e),g=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const r of t){const t=[],o=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[r];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&o.add(e+""))}if(t.length>0){let e=t[0],o=t[0],i=0;for(const n of t)e>n&&(e=n),n>o&&(o=n),i+=n;n.push({name:r,count:t.length,numeric:!0,min:e,max:o,mean:i/t.length})}else if(o.size>0){const e=Array.from(o);n.push({name:r,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(p),b=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${yt(e.min)} to ${yt(e.max)}, mean ${yt(e.mean)}.`);else{const t=e.uniqueValues,r=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${r}.`)}return n.join(" ")}(p.length,g),x=Math.min(l,p.length),v=p.slice(0,x),k=p.length-x,w=new Set;for(const e of v)for(const t of Object.keys(e.values))w.add(t);const $=Array.from(w);return ut("div",{ref:h,id:n,className:gt,tabIndex:-1,onBlur:m,style:xt,role:"region","aria-label":f,children:[dt("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{d&&c&&c.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:kt,children:"×"}),dt("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:vt,children:b}),ut("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+t,style:wt,children:[dt("caption",{className:"semiotic-accessible-data-table-caption",style:St,children:k>0?`First ${x} of ${p.length} data points`:`All ${p.length} data points`}),dt("thead",{children:ut("tr",{children:[dt("th",{style:$t,children:"type"}),$.map(e=>dt("th",{style:$t,children:e},e))]})}),dt("tbody",{children:v.map((e,t)=>ut("tr",{children:[dt("td",{style:Mt,children:e.label}),$.map(t=>{return dt("td",{style:Mt,children:(n=e.values[t],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":yt(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},t);var n})]},t))})]}),k>0&&ut("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>s(e=>e+25),style:At,children:["Show ",Math.min(25,k)," more"," ",1===k?"row":"rows"," (",k," remaining)"]})]})}function jt({nodes:e,edges:t,chartType:n,tableId:r,chartTitle:o}){const[i,a]=it.useState(!1),[l,s]=it.useState(5),c=ct(),d=c?.visible??!1,u=i||d,h=o?"Data summary for "+o:r?`Data summary for ${n} ${r}`:"Data summary for "+n,f=it.useRef(null);it.useEffect(()=>{u||s(5)},[u]);const y=it.useCallback(e=>{e.target===e.currentTarget&&(i||d||a(!0))},[i,d]),m=it.useCallback(e=>{d||f.current?.contains(e.relatedTarget)||a(!1)},[d]);if(!e||0===e.length)return r?dt("span",{id:r,tabIndex:-1,style:rt}):null;if(!u)return dt("div",{id:r,className:pt,tabIndex:-1,onFocus:y,style:rt,role:"region","aria-label":h,children:ut("button",{type:"button",onClick:()=>a(!0),children:["View data summary (",e.length," nodes, ",t.length," edges)"]})});const p=Array.isArray(e)?e:[],g=Array.isArray(t)?t:[],b=new Map,x=new Map,v=new Map,k=new Map;for(const e of g){if(!e||"object"!=typeof e)continue;const t=e.datum??{source:e.source,target:e.target},n="object"==typeof t.source?t.source?.id:t.source,r="object"==typeof t.target?t.target?.id:t.target,o="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";x.set(e,(x.get(e)??0)+1),k.set(e,(k.get(e)??0)+o)}if(null!=r&&""!==r){const e=r+"";b.set(e,(b.get(e)??0)+1),v.set(e,(v.get(e)??0)+o)}}const w=[];for(let e=0;p.length>e;e++){const t=p[e];if(!t||"object"!=typeof t)continue;const n=t.datum?.id??t.id,r=null!=n?n+"":"node-"+e,o=b.get(r)??0,i=x.get(r)??0,a=v.get(r)??0,l=k.get(r)??0;w.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:a+l,wInDeg:a,wOutDeg:l})}w.sort((e,t)=>t.degree-e.degree);let $=0,M=0;if(w.length>0){let e=0;for(const t of w)e+=t.degree,t.degree>M&&(M=t.degree);$=e/w.length}const S=g.some(e=>{const t=e?.datum??{source:e?.source,target:e?.target};return"number"==typeof t?.value&&Number.isFinite(t.value)}),A=[`${w.length} nodes, ${g.length} edges.`];w.length>0&&A.push(`Mean degree: ${yt($)}, max degree: ${M}.`);const W=Math.min(l,w.length),j=w.slice(0,W),C=w.length-W;return ut("div",{ref:f,id:r,className:bt,tabIndex:-1,onBlur:m,style:xt,role:"region","aria-label":h,children:[dt("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{d&&c&&c.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:kt,children:"×"}),dt("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:vt,children:A.join(" ")}),ut("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+n,style:wt,children:[dt("caption",{className:"semiotic-accessible-data-table-caption",style:St,children:C>0?`Top ${W} of ${w.length} nodes by degree`:`All ${w.length} nodes by degree`}),dt("thead",{children:ut("tr",{children:[dt("th",{style:$t,children:"id"}),dt("th",{style:$t,children:"degree"}),dt("th",{style:$t,children:"in"}),dt("th",{style:$t,children:"out"}),S&&dt("th",{style:$t,children:"w. degree"}),S&&dt("th",{style:$t,children:"w. in"}),S&&dt("th",{style:$t,children:"w. out"})]})}),dt("tbody",{children:j.map((e,t)=>ut("tr",{children:[dt("td",{style:Mt,children:e.id}),dt("td",{style:Mt,children:e.degree}),dt("td",{style:Mt,children:e.inDeg}),dt("td",{style:Mt,children:e.outDeg}),S&&dt("td",{style:Mt,children:yt(e.wDegree)}),S&&dt("td",{style:Mt,children:yt(e.wInDeg)}),S&&dt("td",{style:Mt,children:yt(e.wOutDeg)})]},t))})]}),C>0&&ut("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>s(e=>e+25),style:At,children:["Show ",Math.min(25,C)," more"," ",1===C?"node":"nodes"," (",C," remaining)"]})]})}function Ct({summary:e}){return e?dt("div",{role:"note",style:rt,children:e}):null}function Rt({tableId:e}){return dt("a",{href:"#"+e,style:rt,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,rt)},children:"Skip to data table"})}import{jsx as Ot}from"react/jsx-runtime";var Lt="var(--semiotic-focus, #005fcc)";function It({active:e,hoverPoint:t,margin:n,size:r,shape:o="circle",width:i,height:a,pathData:l}){if(!e||!t)return null;const s=t.x+n.left,c=t.y+n.top;let d;if("geoarea"!==o&&"path"!==o||!l)if("rect"===o&&null!=i&&null!=a){const e=Math.max(i,4),t=Math.max(a,4);d=Ot("rect",{x:s-e/2-3,y:c-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:Lt,strokeWidth:2,strokeDasharray:"4,2"})}else d=Ot("circle","wedge"===o?{cx:s,cy:c,r:12,fill:"none",stroke:Lt,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:s,cy:c,r:8,fill:"none",stroke:Lt,strokeWidth:2,strokeDasharray:"4,2"});else d=Ot("g",{transform:`translate(${n.left},${n.top})`,children:Ot("path",{d:l,fill:"none",stroke:Lt,strokeWidth:2.5,strokeDasharray:"6,3"})});return Ot("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:d})}import*as Nt from"react";import{jsx as zt}from"react/jsx-runtime";function Ft({x:e,y:t,containerWidth:n,containerHeight:o,margin:i,children:a,className:l="stream-frame-tooltip",zIndex:s=1}){const c=Number.isFinite(e)&&Number.isFinite(t),d=Nt.useRef(null),[u,h]=Nt.useState(null);Nt.useLayoutEffect(()=>{const e=d.current;if(!e)return;const t=()=>{const t=e.getBoundingClientRect();Number.isFinite(t.width)&&Number.isFinite(t.height)&&h(e=>e&&.5>Math.abs(e.width-t.width)&&.5>Math.abs(e.height-t.height)?e:{width:t.width,height:t.height})};if(t(),"undefined"==typeof ResizeObserver)return;const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[l,n,o,c]);let f;f=u?`translate(${u.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>o-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*o>t?"4px":"calc(-100% - 4px)"})`;const y=function(e){if(!Nt.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if(!0===n["data-semiotic-tooltip-chrome"])return!0;if("true"===n["data-semiotic-tooltip-chrome"])return!0;const r=n.style;if(r&&"object"==typeof r){if(null!=r.background&&""!==r.background&&"transparent"!==r.background)return!0;if(null!=r.backgroundColor&&""!==r.backgroundColor&&"transparent"!==r.backgroundColor)return!0}return!1}(a),m=y?null:r;return c?zt("div",{ref:d,className:y?l:(l+" semiotic-tooltip").trim(),style:{...m||{},position:"absolute",left:i.left+e,top:i.top+t,transform:f,pointerEvents:"none",zIndex:s,width:"max-content"},children:a}):null}import*as Dt from"react";import{useCallback as Pt,useEffect as Tt,useLayoutEffect as Bt,useMemo as Et,useRef as Ht}from"react";import{useRef as Gt,useState as qt,useEffect as _t}from"react";function Yt(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function Vt(e,t){return Math.min((e-t.startTime)/t.duration,1)}function Ut(e,t,n){return e+(t-e)*n}function Zt(){return"undefined"!=typeof performance?performance.now():Date.now()}var Xt="undefined"==typeof window?Tt:Bt,Kt={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function Jt(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function Qt(t){const n=e(),r=Ht(n);r.current=n;const[o,i]=function(e,t,n){const r=Gt(null),[o,i]=qt(null);return _t(()=>{if(!t&&!n)return;const e=r.current;if(!e)return;const o=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;i(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return o.observe(e),()=>o.disconnect()},[t,n]),[r,[t&&o?o.w:e[0],n&&o?o.h:e[1]]]}(t.sizeProp,t.responsiveWidth,t.responsiveHeight),a=!!t.title,l=!!t.legend&&"top"===t.legendPosition,s=Et(()=>_({...t.marginDefault,...t.userMargin},a,l),[t.marginDefault,t.userMargin,a,l]),c=i[0]-s.left-s.right,d=i[1]-s.top-s.bottom,h=Jt(t.foregroundGraphics,i,s),f=Jt(t.backgroundGraphics,i,s),y=j(e=>e.theme),{transition:m,introEnabled:p}=function(e,t){if(!1===e)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:e?!0===e?{duration:300}:{duration:e.duration??300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(n||!e||!0!==e&&!1===e.intro)}}(t.animate,t.transitionProp),g="semiotic-table-"+Dt.useId(),b=Ht(null);if(!b.current){const e=!t.suspendWhenHidden||"undefined"==typeof document||!document.hidden;b.current=new u({clock:t.clock,random:t.random,seed:t.seed,paused:t.paused,visible:e})}const x=b.current;x.configure({clock:t.clock,random:t.random,seed:t.seed});const v=Ht(null),k=Ht(t.frameScheduler??Kt);k.current=t.frameScheduler??Kt;const w=Ht(null),$=Ht(!1),M=Ht(()=>{}),A=Pt(()=>{if(null!==v.current||$.current)return;const e=k.current;let t=!1,n=!1;const r=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&($.current=!0),v.current=null,w.current=null;try{M.current()}finally{e&&($.current=!1)}});n=!0,t||(v.current=r,w.current=e)},[]),W=Pt(()=>{null!==v.current&&((w.current??k.current).cancelAnimationFrame(v.current),v.current=null,w.current=null)},[]);Xt(()=>{x.setPaused(!0===t.paused)},[x,t.paused]),Tt(()=>{if(!t.suspendWhenHidden||"undefined"==typeof document)return void x.setVisible(!0);const e=()=>x.setVisible(!document.hidden);return e(),document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[x,t.suspendWhenHidden]),Tt(()=>()=>{W()},[W]);const C=Ht(()=>{}),R=Ht(()=>{}),O=Ht(null),L=Ht(null),I=Ht(null),N=Pt(()=>{const e=O.current;O.current=null,e&&C.current(e)},[]),z=Pt(e=>{if(O.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===L.current){const e=k.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,L.current=null,I.current=null,N()});t||(L.current=n,I.current=e)}},[N]),F=Pt(()=>{O.current=null,null!==L.current&&((I.current??k.current).cancelAnimationFrame(L.current),L.current=null,I.current=null),R.current()},[]);Tt(()=>()=>{O.current=null,null!==L.current&&((I.current??k.current).cancelAnimationFrame(L.current),L.current=null,I.current=null)},[]);const D=t.themeDirtyRef;return Xt(()=>{D&&(S(),D.current=!0,A())},[y,A,D]),{reducedMotion:n,reducedMotionRef:r,responsiveRef:o,size:i,margin:s,adjustedWidth:c,adjustedHeight:d,resolvedForeground:h,resolvedBackground:f,currentTheme:y,transition:m,introEnabled:p,tableId:g,frameRuntime:x,rafRef:v,renderFnRef:M,scheduleRender:A,cancelRender:W,hoverHandlerRef:C,hoverLeaveRef:R,onPointerMove:z,onPointerLeave:F}}import{useEffect as en,useRef as tn}from"react";import{jsx as nn}from"react/jsx-runtime";function rn(e,t){return function(e){const{cancelRender:t,dirtyRef:n,frameRuntime:r,manageFrameRuntime:o,scheduleRender:i}=e,a=tn(null),l=tn(null),s=tn(!1);return function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:r,dirtyRef:o,renderFnRef:i,cancelRender:a,cleanup:l}=e;Xe(()=>{const e=r.current;t&&n&&e?.cancelIntroAnimation?.(),!n&&e?.sceneNodes&&e.sceneNodes.length>0&&e?.markStylePaintPending?e.markStylePaintPending():o.current=!0,a?.(),i.current()},[t,n]);const s=Ve(l);s.current=l,_e(()=>()=>s.current?.(),[])}({hydrated:e.hydrated,wasHydratingFromSSR:e.wasHydratingFromSSR,storeRef:e.storeRef,dirtyRef:e.dirtyRef,renderFnRef:e.renderFnRef,cancelRender:e.cancelRender,cleanup:e.cleanup}),en(()=>{if(!1!==o)return r.subscribe(()=>{r.isActive?(n.current=!0,i()):t()})},[t,n,r,o,i]),en(()=>{!s.current&&(s.current=!0,e.skipInitialCanvasPaintInvalidation)||(e.dirtyRef.current=!0,e.scheduleRender())},e.canvasPaintDependencies),{canvasRef:a,interactionCanvasRef:l}}({...t,renderFnRef:e.renderFnRef,scheduleRender:e.scheduleRender,cancelRender:e.cancelRender,frameRuntime:e.frameRuntime})}function on({children:e,size:t,margin:n,overflowVisible:r=!1}){return e?nn("svg",{style:{position:"absolute",left:0,top:0,width:t[0],height:t[1],pointerEvents:"none",overflow:r?"visible":void 0},children:nn("g",{transform:`translate(${n.left},${n.top})`,children:e})}):null}function an(e,t,n,r){const o=e.getContext("2d");if(!o)return null;const i=Math.round(t[0]*r),a=Math.round(t[1]*r),l=i/t[0],s=a/t[1],c=t[0]+"px",d=t[1]+"px";return e.style.width!==c&&(e.style.width=c),e.style.height!==d&&(e.style.height=d),e.width===i&&e.height===a||(e.width=i,e.height=a),o.setTransform(l,0,0,s,0,0),o.translate(n.left,n.top),o}function ln(){if("undefined"==typeof window)return 1;const e=window.devicePixelRatio||1,t=function(){if("undefined"==typeof window)return!1;const e="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,t=768>Math.min(window.innerWidth||1/0,window.innerHeight||1/0);return e||t}()?2:3;return Math.max(1,Math.min(e,t))}function sn(e){return"touch"===e?"touch":"pointer"}function cn(e){const t=e.target;return t instanceof Element&&t!==e.currentTarget&&null!=t.closest("button, a[href], input, select, textarea, summary, [contenteditable='true'], [role='button'], [role='link'], [role='checkbox'], [role='radio'], [role='switch']")}function dn(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:a,context:l,timestamp:s=Date.now()}=e;t&&(n?(t({type:"hover",datum:n,x:r,y:o,timestamp:s,chartType:i,chartId:a}),"focus"===l?.type&&t({type:"focus",datum:n,inputType:"touch"===l.inputType?"pointer":l.inputType,timestamp:s,chartType:i,chartId:a})):t({type:"hover-end",timestamp:s,chartType:i,chartId:a}))}function un(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:a,context:l,timestamp:s=Date.now()}=e;t&&(n?(t({type:"click",datum:n,x:r,y:o,timestamp:s,chartType:i,chartId:a}),"activate"===l?.type&&t({type:"activate",datum:n,inputType:l.inputType,timestamp:s,chartType:i,chartId:a})):t({type:"click-end",timestamp:s,chartType:i,chartId:a}))}import*as hn from"react";import{jsx as fn,jsxs as yn}from"react/jsx-runtime";function mn({componentName:e,message:t,diagnosticHint:n,width:r,height:o}){return fn("div",{role:"alert",style:{width:r,height:Math.max(o,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"},children:yn("div",{style:{textAlign:"center",maxWidth:400},children:[fn("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),fn("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:t}),n&&fn("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:n})]})})}import{jsx as pn}from"react/jsx-runtime";var gn=class extends hn.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.onError?.(e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:pn(mn,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}};import{jsx as bn}from"react/jsx-runtime";var xn="undefined"!=typeof process&&"production"!==process.env?.NODE_ENV;function vn({componentName:e,width:t,height:n,children:r}){return bn(gn,{fallback:r=>bn(mn,{componentName:e,message:r.message,width:t,height:n}),children:r})}var kn={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},wn={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function $n(e,t,n,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?bn("div",{style:{...kn,width:t,height:n},children:r||"No data available"}):null}function Mn(e,t,n,r){if(!e)return null;if(!1===r)return null;if(null!=r)return bn("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const o=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*o))),a=Math.max(6,Math.floor(n/(2.5*o))),l=Math.floor((n-(o*(i+a)-a))/2);return bn("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:o},(e,n)=>bn("div",{className:"semiotic-loading-bar",style:{...wn,position:"absolute",top:l+n*(i+a),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2}},n))})}function Sn(e,t,n,r){if(!xn)return;if(!t||0===t.length)return;if("string"!=typeof r)return;const o=t[0];if(!o||"object"!=typeof o)return;if(r in o)return;const i=Object.keys(o).join(", ");console.warn(`[semiotic] ${e}: ${n} "${r}" not found in data. Available keys: ${i}`)}import{useId as An,useMemo as Wn,useCallback as jn}from"react";function Cn(e){const t=[];for(const[n,r]of Object.entries(e.fields))if("point"===r.type)t.push(e=>r.values.has(e[n]));else{const[e,o]=r.range;t.push(t=>{const r=t[n];return r>=e&&o>=r})}return e=>t.every(t=>t(e))}function Rn(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function On(e,t){if(e.type!==t.type)return!1;if("interval"===e.type&&"interval"===t.type)return e.range[0]===t.range[0]&&e.range[1]===t.range[1];if("point"===e.type&&"point"===t.type){if(e.values.size!==t.values.size)return!1;for(const n of e.values)if(!t.values.has(n))return!1;return!0}return!1}var[Ln,In]=W(e=>({selections:new Map,setClause(t,n){e(e=>{const r=e.selections.get(t),o=r?.clauses.get(n.clientId);if(o&&function(e,t){if(e.clientId!==t.clientId||e.type!==t.type)return!1;const n=Object.entries(e.fields);if(n.length!==function(e){let t=0;for(const n in e)t++;return t}(t.fields))return!1;for(const[e,r]of n){const n=t.fields[e];if(!n||!On(r,n))return!1}return!0}(o,n))return{};const i=new Map(e.selections),a=Rn(i,t),l=new Map(a.clauses);return l.set(n.clientId,n),i.set(t,{...a,clauses:l}),{selections:i}})},clearClause(t,n){e(e=>{const r=e.selections.get(t);if(!r||!r.clauses.has(n))return{};const o=new Map(e.selections),i=new Map(r.clauses);return i.delete(n),o.set(t,{...r,clauses:i}),{selections:o}})},setResolution(t,n){e(e=>{const r=e.selections.get(t);if(r?.resolution===n)return{};const o=new Map(e.selections),i=Rn(o,t);return o.set(t,{...i,resolution:n}),{selections:o}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const r=new Map(e.selections);return r.set(t,{...n,clauses:new Map}),{selections:r}})}}));import{useSyncExternalStore as Nn}from"react";var zn={positions:new Map},Fn=new Set;function Dn(){for(const e of Fn)e()}function Pn(e,t){const n=zn.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const r=new Map(zn.positions);r.delete(e),zn={positions:r},Dn()}function Tn(e,t){const n=zn.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const r=new Map(zn.positions);r.delete(e),zn={positions:r},Dn()}function Bn(){return zn}function En(e){return Fn.add(e),()=>Fn.delete(e)}var Hn={positions:new Map};function Gn(){return()=>{}}function qn(){return Hn}function _n(e){const t=Nn(e?En:Gn,e?Bn:qn,e?Bn:qn);return e?t.positions.get(e)??null:null}function Yn(e){const t=An(),n=e.clientId||t,{name:r}=e,o=In(e=>e.selections.get(r)),i=In(e=>e.setClause),a=In(e=>e.clearClause),l=Wn(()=>!!o&&o.clauses.size>0,[o]);return{predicate:Wn(()=>o&&0!==o.clauses.size?function(e,t){const n=[];for(const[r,o]of e.clauses)"crossfilter"===e.resolution&&r===t||n.push(Cn(o));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(o,n):()=>!0,[o,n]),isActive:l,selectPoints:jn(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"point",values:new Set(r)},o=!0;o&&i(r,{clientId:n,type:"point",fields:t})},[n,r,i]),selectInterval:jn(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"interval",range:r},o=!0;o&&i(r,{clientId:n,type:"interval",fields:t})},[n,r,i]),clear:jn(()=>{a(r,n)},[a,r,n]),clientId:n}}function Vn(e){return 2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}function Un(e){const{name:t,xField:n,yField:r}=e,{predicate:o,isActive:i,selectInterval:a,clear:l}=Yn({name:t,fields:[n,r].filter(Boolean)}),s=n&&r?"xyBrush":n?"xBrush":"yBrush",c=jn(e=>{if(!e)return void l();const t={};"xyBrush"===s&&function(e){return 2===e.length&&Array.isArray(e[0])&&2===e[0].length&&Array.isArray(e[1])&&2===e[1].length}(e)?(n&&(t[n]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),r&&(t[r]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===s&&Vn(e)?n&&(t[n]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]):"yBrush"===s&&Vn(e)&&r&&(t[r]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]),Zn(t)&&a(t)},[s,n,r,a,l]);return{brushInteraction:Wn(()=>({brush:s,during:c,end:c}),[s,c]),predicate:o,isActive:i,clear:l}}function Zn(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function Xn(e){return e?"string"==typeof e?{name:e}:e:null}function Kn(e,t,n){return t?(r,...o)=>{const i={...e(r,...o)};if(t.isActive)if(t.predicate(r))n?.selectedStyle&&Object.assign(i,n.selectedStyle);else{const e=n?.unselectedOpacity??.5;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,n?.unselectedStyle&&Object.assign(i,n.unselectedStyle)}return i}:e}var Jn={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function Qn(e,t={}){const n=t.mobileSemantics?.interaction,r="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,o="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,i=!!n||void 0!==r,a=e&&"object"==typeof e?e:void 0;if(!1===e||!1===a?.enabled||void 0===e&&!o&&!i)return Jn;const l=a??{};return{enabled:!0,tapToSelect:l.tapToSelect??!0,tapToLockTooltip:l.tapToLockTooltip??!0,clearSelection:l.clearSelection??"backgroundTap",targetSize:l.targetSize??r??44,snap:l.snap??"nearestDatum",brushHandleSize:l.brushHandleSize??44,standardControls:l.standardControls??!1}}var er={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}};function tr(e){return"string"==typeof e&&Object.prototype.hasOwnProperty.call(er,e)}function nr(e,t,n){const r=er[e||"primary"],o=e&&"primary"!==e||!n?.width?r.width:n.width,i=e&&"primary"!==e||!n?.height?r.height:n.height,a={...t,mode:e},l=s(a,{width:t.width??o,height:t.height??i}).props,c=l.mode||e||"primary",d=er[c],u="context"===c||"sparkline"===c,h="primary"===c&&n?.width?n.width:d.width;return{mode:c,width:l.width??h,height:l.height??("primary"===c&&n?.height?n.height:d.height),showAxes:l.showAxes??d.showAxes,showGrid:l.showGrid??d.showGrid,enableHover:l.enableHover??(!!l.linkedHover||d.enableHover),showLegend:l.showLegend??d.showLegend,showLabels:l.showLabels??d.showLabels,title:u?void 0:l.title,description:l.description,summary:l.summary,accessibleTable:l.accessibleTable,xLabel:u?void 0:l.xLabel,yLabel:u?void 0:l.yLabel,categoryLabel:u?void 0:l.categoryLabel,valueLabel:u?void 0:l.valueLabel,marginDefaults:rr(d.marginDefaults,l.showCategoryTicks,l.orientation),compactMode:u,mobileInteraction:Qn(l.mobileInteraction,{mode:c,width:l.width??h,mobileSemantics:l.mobileSemantics}),mobileSemantics:l.mobileSemantics}}function rr(e,t,n){if(!1!==t)return e;const r={...e};return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}import{useMemo as or,useCallback as ir,useState as ar,useId as lr,useEffect as sr,useRef as cr}from"react";import{createContext as dr,useContext as ur,useMemo as hr}from"react";import{scaleOrdinal as fr}from"d3-scale";var yr={category10:v,tableau10:w,set3:k,...h},mr=v,pr="#007bff";function gr(e,t,n=mr){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=yr[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}var br=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],xr=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],vr=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function kr(e,t,n){if("function"==typeof t){const r=t(e);return n&&r&&"string"==typeof r&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||vr.has(t)}(r)?n(r):r}const r=e?.[t]+"";return n?n(r):mr[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(r))%mr.length]}function wr(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;const n=e[t];return"string"==typeof n&&n.length>0?n:void 0}function $r(e,t,n="category10"){if(n&&"object"==typeof n&&!Array.isArray(n)){const e=n;return t=>wr(e,t)??"#999"}const r=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>e+""))),o=r.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return fr().domain(r).range(n).unknown("#999");const i=yr[n]||yr.category10;if(o&&"function"==typeof i){let e=-1/0;for(const t of r){const n=Number(t);n>e&&(e=n)}return t=>i(Number(t)/e)}{const e=Array.isArray(i)?i:mr;return fr().domain(r).range(e).unknown("#999")}}function Mr(e,t,n=[3,20],r){let o;if(o="function"==typeof t?t(e):e?.[t],!r)return o;const[i,a]=r,[l,s]=n;if(a===i)return(l+s)/2;let c=(o-i)/(a-i);return 0>c?c=0:c>1&&(c=1),l+c*(s-l)}import{jsx as Sr}from"react/jsx-runtime";var Ar=dr(null);function Wr(){return ur(Ar)}import{createContext as jr,useContext as Cr,useEffect as Rr,useId as Or,useLayoutEffect as Lr,useMemo as Ir,useRef as Nr,useState as zr,useCallback as Fr}from"react";import*as Dr from"react";var Pr=22;function Tr(e){const t=Math.max(1,e?.swatchSize??16),n=Math.max(t,e?.rowHeight??22);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??6),itemGap:Math.max(0,e?.itemGap??10),rowHeight:n,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}function Br(e,t){let n=24;return e.map(({hasLabel:e,itemCount:r})=>{n+=5;const o=n;let i;n+=8,e&&(n+=16,i=n,n+=8);const a=n;return n+=r*t+8,{lineY:o,labelY:i,itemsY:a,endY:n}})}import{jsx as Er,jsxs as Hr}from"react/jsx-runtime";var Gr={fill:(e,t)=>Er("rect",{style:e,width:t,height:t}),line:(e,t)=>Er("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function qr(e,t,n,r,o){let i;return i="function"==typeof n?n(e):(0,Gr[n])(r(e,t),o),i}function _r({swatchSize:e}){return Er("path",{d:`M${.25*e},${.55*e} L${.45*e},${.75*e} L${.8*e},${.3*e}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Yr(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var Vr=(e,t,n,r,o,i,a,l,s,c,d)=>{const{type:u="fill",styleFn:h,items:f}=e,y=[];let m=0;const p=!(!t&&!n),g="isolate"===c||void 0===c&&null!=o,{swatchSize:b,labelGap:x,rowHeight:v}=d;return f.forEach((e,c)=>{const d=qr(e,c,u,h,b),k=Yr(e,r,o),w=o&&o.size>0&&o.has(e.label);y.push(Hr("g",{transform:`translate(0,${m})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:p?l===i&&c===a?0:-1:void 0,role:p?"option":void 0,"aria-selected":p&&g?w||!1:void 0,"aria-current":p&&!g&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:p?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(c+("ArrowDown"===n.key?1:-1)+f.length)%f.length;s(l,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:p?t=>{s(l,c),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:p?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:p?"pointer":"default",opacity:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[p&&Er("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:b+x+2+7*e.label.length,height:b+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),d,w&&Er(_r,{swatchSize:b}),Er("text",{y:b/2,x:b+x,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+c)),m+=v}),y};function Ur({config:e,orientation:t="vertical",width:n=100}){const{colorFn:r,domain:o,label:i,format:a}=e,l=a||(e=>Math.round(100*e)/100+""),s="grad-legend-"+Dr.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),a=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(Er("stop",{offset:100*t+"%",stopColor:r(o[0]+t*(o[1]-o[0]))},e))}return Hr("g",{"aria-label":i||"Gradient legend",children:[Er("defs",{children:Er("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),i&&Er("text",{x:a+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),Er("rect",{x:a,y:0,width:t,height:e,fill:`url(#${s})`,rx:2}),Er("text",{x:a,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(o[0])}),Er("text",{x:a+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(o[1])})]})}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(Er("stop",{offset:100*t+"%",stopColor:r(o[1]-t*(o[1]-o[0]))},e))}return Hr("g",{"aria-label":i||"Gradient legend",children:[i&&Er("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),Er("defs",{children:Er("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),Er("rect",{x:0,y:0,width:14,height:100,fill:`url(#${s})`,rx:2}),Er("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(o[1])}),Er("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(o[0])})]})}function Zr(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,legendInteraction:a,title:l="Legend",width:s=100,height:c=20,orientation:d="vertical",legendLayout:u}=e,h=Tr(u),[f,y]=Dr.useState(0),[m,p]=Dr.useState(0),g=Dr.useCallback((e,t)=>{y(e),p(t)},[]),b="vertical"===d?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:s,legendInteraction:c,metrics:d})=>{const u=[],h=Br(e.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),d.rowHeight);return e.forEach((e,f)=>{const y=h[f];u.push(Er("line",{stroke:"gray",x1:0,y1:y.lineY,x2:t,y2:y.lineY},"legend-top-line legend-symbol-"+f)),e.label&&null!=y.labelY&&u.push(Er("text",{y:y.labelY,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),u.push(Er("g",{className:"legend-item",transform:`translate(0,${y.itemsY})`,children:Vr(e,n,r,o,i,a,l,f,s,c,d)},"legend-group-"+f))}),u})({legendGroups:t||[],width:s,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:m,onFocusedIndexChange:g,legendInteraction:a,metrics:h}):(({legendGroups:e,height:t,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:d,metrics:u})=>{let h=0;const f=[];e.forEach((e,t)=>{let y=0;e.label&&(y+=16);const m=((e,t,n,r,o,i,a,l,s,c,d,u)=>{const{type:h="fill",styleFn:f,items:y}=e,m=[],{swatchSize:p,labelGap:g,itemGap:b,rowHeight:x,align:v}=d,k=!(!t&&!n),w="isolate"===c||void 0===c&&null!=o,$=y.map(e=>p+g+7*e.label.length),M=[];let S=0,A=0;$.forEach((e,t)=>{const n=0===A?e:A+b+e;u&&u>0&&A>0&&n>u?(M.push({start:S,end:t,width:A}),S=t,A=e):A=n}),y.length>0&&M.push({start:S,end:y.length,width:A}),M.forEach((e,c)=>{let d="center"===v?Math.max(0,((u??e.width)-e.width)/2):"end"===v?Math.max(0,(u??e.width)-e.width):0;for(let u=e.start;e.end>u;u++){const e=y[u],v=qr(e,u,h,f,p),M=Yr(e,r,o),S=o&&o.size>0&&o.has(e.label);m.push(Hr("g",{transform:`translate(${d},${c*x})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:k?l===i&&u===a?0:-1:void 0,role:k?"option":void 0,"aria-selected":k&&w?S||!1:void 0,"aria-current":k&&!w&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:k?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(u+("ArrowRight"===n.key?1:-1)+y.length)%y.length;s(l,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:k?t=>{s(l,u),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:k?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:k?"pointer":"default",opacity:M,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[k&&Er("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:p+g+2+7*e.label.length,height:p+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,S&&Er(_r,{swatchSize:p}),Er("text",{y:p/2,x:p+g,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+u)),d+=$[u]+b}});const W=Math.max(0,...M.map(e=>e.width)),j=M.length;return{items:m,offset:W,totalRows:j,totalHeight:j*x}})(e,r,o,i,a,l,s,t,c,d,u,u.maxWidth??n);y+=m.offset+5,f.push({label:e.label,...m,offset:y,totalRows:m.totalRows,totalHeight:m.totalHeight}),h+=y+12});const y=u.maxWidth??n;let m=h>y?0:"center"===u.align?Math.max(0,(y-h)/2):"end"===u.align?Math.max(0,y-h):0;const p=[];return f.forEach((n,r)=>{const o=e[r];o.label&&(p.push(Er("text",{transform:`translate(${m},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:o.label},"legend-text-"+r)),m+=16),p.push(Er("g",{className:"legend-item",transform:`translate(${m},0)`,children:n.items},"legend-group-"+r)),m+=n.offset+5,e[r+1]&&p.push(Er("line",{stroke:"gray",x1:m,y1:-8,x2:m,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+r)),m+=12}),Er("g",{children:p})})({legendGroups:t||[],title:l,height:c,width:s,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:m,onFocusedIndexChange:g,legendInteraction:a,metrics:h}),x=!(!n&&!r);return Hr("g",{role:x?"listbox":void 0,"aria-multiselectable":!(!x||"isolate"!==a&&(void 0!==a||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==l&&""!==l&&"vertical"===d&&Er("text",{className:"legend-title",y:16,x:s/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:l}),b]})}import{jsx as Xr,jsxs as Kr}from"react/jsx-runtime";var Jr=jr(!1);jr(!1);var Qr=jr(null),eo="undefined"==typeof window?Rr:Lr;function to(...e){let t;for(const n of e)n&&(t=no(t)&&no(n)?{legendGroups:[...t.legendGroups,...n.legendGroups]}:n);return t}function no(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}function ro(e){return"object"==typeof e&&null!==e&&"gradient"in e}function oo(e,t,n){const r=e.xValue??t?.[n];if(null==r)return null;const o=Number(r);return Number.isFinite(o)?o:null}function io(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?{...t,xValue:e.xValue}:t||{}}function ao(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}var lo=[];function so(){const e=t(),n=e?.colors?.categorical;return n&&n.length>0?n:void 0}function co(e,t,n,r,o){if(e)return e;if(n&&"object"==typeof n&&!Array.isArray(n)){const e=wr(n,r);if(e)return e}let i;if(Array.isArray(n))i=n;else if(t&&t.length>0)i=t;else if("string"==typeof n){const e=yr[n];Array.isArray(e)&&(i=e)}return i&&0!==i.length?null!=r?(o.has(r)||o.set(r,o.size),i[o.get(r)%i.length]):i[0]:pr}function uo(e,t,n){const r=Wr(),o=so();return or(()=>{if(!t)return;const i=r??void 0,a=n??(o&&o.length>0?o:void 0)??"category10";if(0!==e.length){if("function"==typeof t){const n=Array.from(new Set(e.map(e=>t(e)+"")));if(i&&ao(i)){const e=$r(n.map(e=>({_cat:e})),"_cat",a);return t=>i[t]||e(t)}return $r(n.map(e=>({_cat:e})),"_cat",a)}if(i&&ao(i)){const n=$r(e,t,a);return e=>i[e]||n(e)}return $r(e,t,a)}if(i&&ao(i)){const e=$r([{_:"a"}],"_",a);return t=>i[t]||e(t)}},[e,t,n,r,o])}function ho({selection:e,linkedHover:t,fallbackFields:n=lo,unwrapData:r=!1,onObservation:o,chartType:i,chartId:a,onClick:l,hoverHighlight:s,colorByField:c,mobileInteraction:u}){const h=lr(),f=or(()=>function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField,seriesField:e.seriesField}:null}(t,n),[t,n]),y=or(()=>"series"===f?.mode?[f.seriesField||c||n[0]].filter(e=>!!e):f?.fields||n,[f,c,n]),m=Yn({name:e?.name||"__unused__",fields:y}),p=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:r,isActive:o,selectPoints:i,clear:a}=Yn({name:t,fields:n});return{onHover:jn(e=>{if(!e)return void a();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}Zn(t)&&i(t)},[n,i,a]),predicate:r,isActive:o}}({name:f?.name||"hover",fields:y}),g=d(e=>e.pushObservation),b=ir(e=>{o?.(e),g?.(e)},[o,g]),x=e?{isActive:m.isActive,predicate:m.predicate}:null,[v,k]=ar(null),w=cr(!1),$=c||n[0],M=or(()=>{if(!s||null==v||!$)return null;const e=v,t=$;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[s,v,$]),S=ir((e,n)=>{const r=!e&&w.current&&!!u?.enabled&&u.tapToLockTooltip;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===f?.mode&&f.xField){const n=oo(e,t,f.xField);null!=n&&function(e,t,n){const r=zn.positions.get(e);r?.locked||r&&r.xValue===t&&r.sourceId===n||(zn={positions:new Map(zn.positions).set(e,{xValue:t,sourceId:n})},Dn())}(f.name||"hover",n,h)}"x-position"!==f?.mode&&p.onHover(t)}else"x-position"!==f?.mode||r||Pn(f.name||"hover",h),"x-position"===f?.mode||r||p.onHover(null);if(s&&$)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=t?.[$];k(null!=n?n+"":null)}else r||k(null);(o||g)&&dn({onObservation:b,datum:e?io(e):null,x:e?.x,y:e?.y,chartType:i||"unknown",chartId:a,context:n})},[t,p,f,h,o,i,a,g,b,s,$,u]),A=ir((n=!0)=>{w.current=!1,t&&"x-position"!==f?.mode&&p.onHover(null),e&&u?.tapToSelect&&m.clear(),n&&s&&k(null),"x-position"===f?.mode&&(Tn(f.name||"hover",h),Pn(f.name||"hover",h))},[t,f,p,e,u,m,s,h]),W=ir((n,r)=>{const c=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),d=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===f?.mode&&f.xField&&n){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]);const t=oo(n,e,f.xField);null!=t&&function(e,t,n){const r=zn.positions.get(e);if(r?.locked){const t=new Map(zn.positions);return t.delete(e),zn={positions:t},Dn(),!1}zn={positions:new Map(zn.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Dn()}(f.name||"hover",t,h)}if(c)if(n){w.current=!0;const r=io(n);if(t&&"x-position"!==f?.mode&&p.onHover(r),e&&u?.tapToSelect&&y.length>0){const e={};for(const t of y){const n=r[t];void 0!==n&&(e[t]=[n])}ao(e)&&m.selectPoints(e)}if(s&&$){const e=r?.[$];k(null!=e?e+"":null)}}else d&&A();if(n||d){if(n&&l){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]),l(e,{x:n.x??0,y:n.y??0})}(o||g)&&un({onObservation:b,datum:n?io(n):null,x:n?.x,y:n?.y,chartType:i||"unknown",chartId:a,context:r})}},[l,o,g,b,i,a,f,h,u,t,p,e,m,y,s,$,A]);return sr(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&w.current&&A()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,A]),sr(()=>()=>{w.current&&A(!1)},[A]),sr(()=>{if("x-position"!==f?.mode)return;const e=f.name||"hover";return()=>{Tn(e,h),Pn(e,h)}},[f?.mode,f?.name,h]),{activeSelectionHook:x,hoverSelectionHook:M,customHoverBehavior:S,customClickBehavior:W,crosshairSourceId:h}}function fo(e,t){const n="object"==typeof e&&null!==e?e:void 0;if("x-position"===n?.mode)return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:t}}function yo({data:e,colorBy:t,colorScale:n,showLegend:r,legendPosition:o="right",userMargin:i,defaults:a={top:50,bottom:60,left:70,right:40},categories:l,additionalLegend:s}){const c=Cr(Jr),d=null!==Cr(Qr),u=void 0!==r?r:!c&&!!t,h=!!t&&(u||d),f=or(()=>{if(!h)return[];if(void 0!==l)return l;const n=new Set;for(const r of e){const e="function"==typeof t?t(r):r[t];null!=e&&n.add(e+"")}return Array.from(n)},[l,t,e,h]);!function(e){const t=Cr(Qr),n=Or(),r=function(e){const t=new Set,n=[];for(const r of e)t.has(r)||(t.add(r),n.push(r));return n}(e),o=Nr([]);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(o.current,r)||(o.current=r);const i=o.current;eo(()=>{if(t)return()=>t.unregisterCategories(n)},[t,n]),eo(()=>{t&&t.registerCategories(n,i)},[t,n,i])}(d&&t?f:[]);const y=or(()=>{if(!u||!t)return;const r=function({data:e,colorBy:t,colorScale:n,getColor:r,strokeColor:o,strokeWidth:i,categories:a}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==o&&(n.stroke=o),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:(a&&a.length>0?a:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((o,i)=>{const a=e.find("function"==typeof t?e=>t(e)===o:e=>e[t]===o),l=a?r(a,t,n):n?n(o):br[i%br.length];return{label:o+"",color:l}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:kr,categories:f});return 0!==r.legendGroups.reduce((e,t)=>e+t.items.length,0)?r:void 0},[u,t,e,n,f]),m=or(()=>to(y,s),[y,s]),p=or(()=>{const e="number"==typeof i?{top:i,bottom:i,left:i,right:i}:i??{},t=t=>{const n=e[t];return"number"==typeof n?n:a[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},r=t=>"number"==typeof e[t];return m&&("right"===o&&!r("right")&&110>n.right?n.right=110:"left"===o&&!r("left")&&110>n.left?n.left=110:"top"===o&&!r("top")&&50>n.top?n.top=50:"bottom"===o&&!r("bottom")&&80>n.bottom&&(n.bottom=80)),n},[a,i,m,o]);return{legend:m,margin:p,legendPosition:o}}function mo(e,t,n){const[r,o]=ar(null),[i,a]=ar(new Set),l=or(()=>new Set,[]),s=ir(t=>{"highlight"===e&&o(t?t.label:null)},[e]),c=ir(t=>{"isolate"===e&&a(e=>{const r=new Set(e);return r.has(t.label)?r.delete(t.label):r.add(t.label),r.size===n.length?new Set:r})},[e,n.length]),d=or(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=r?{isActive:!0,predicate:e=>(n?e[n]:"function"==typeof t?t(e):null)===r}:"isolate"===e&&i.size>0?{isActive:!0,predicate:e=>{const r=n?e[n]:"function"==typeof t?t(e):null;return i.has(r)}}:null},[e,t,r,i]);return{highlightedCategory:"highlight"===e?r:null,isolatedCategories:"isolate"===e?i:l,onLegendHover:s,onLegendClick:c,legendSelectionHook:d}}function po(e,t,n){return nr(e,t,n)}import{jsx as go}from"react/jsx-runtime";function bo(e){const{legend:t,totalWidth:n,totalHeight:r,margin:o,legendPosition:i="right",legendLayout:a,title:l,legendHoverBehavior:s,legendClickBehavior:c,legendHighlightedCategory:d,legendIsolatedCategories:u,legendInteraction:h}=e;if(!t)return null;const f="top"===i||"bottom"===i,y=!!l,m=Math.max(0,n-o.left-o.right),p=Math.max(1,f?a?.maxWidth??m:100);let g,b;return"left"===i?(g=Math.max(4,o.left-p-10),b=o.top):"top"===i?(g=o.left,b=y?32:8):"bottom"===i?(g=o.left,b=r-o.bottom+38):(g=n-o.right+10,b=o.top),go("g",{transform:`translate(${g}, ${b})`,children:ro(t)?go(Ur,{config:t.gradient,orientation:f?"horizontal":"vertical",width:p}):no(t)?go(Zr,{legendGroups:t.legendGroups,title:"",width:p,orientation:f?"horizontal":"vertical",legendLayout:a,customHoverBehavior:s,customClickBehavior:c,highlightedCategory:d,isolatedCategories:u,legendInteraction:h}):t})}import{jsx as xo}from"react/jsx-runtime";var vo={secondary:0,primary:3},ko=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}";function wo(e){return!0===e?._annotationDeferred}function $o(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function Mo(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function So(e){return Math.max(.72,.95-.06*e)}import*as Ao from"react";import{jsx as Wo,jsxs as jo}from"react/jsx-runtime";function Co(e,t=120,n=8){if(!e)return[];const r=Math.max(1,Math.floor(t/n)),o=e.split(/\s+/),i=[];let a="";for(const e of o)a&&a.length+1+e.length>r?(i.push(a),a=e):a=a?`${a} ${e}`:e;return a&&i.push(a),i}function Ro(e,t,n,r){return"curly"===e?r?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:r?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function Oo(e,t,n,r){if(!e)return Wo("g",{className:"annotation-note"});const{label:o,title:i,orientation:a,align:l,wrap:s=120,noWrap:c}=e;if(!o&&!i)return Wo("g",{className:"annotation-note"});let d=a;d||(d=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let u=l;u&&"dynamic"!==u||(u="topBottom"===d?0>t?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===d?"right"===u?h="end":"middle"===u&&(h="middle"):h=0>t?"end":"start";const f=16,y=i?c?[i]:Co(i,s):[],m=o?c?[o]:Co(o,s):[],p="leftRight"===d?"end"===h?-4:4:0;let g=0;const b=[],x=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?b.push(Wo("foreignObject",{className:"annotation-note-html",x:"end"===h?p-s:"middle"===h?p-s/2:p,y:-16,width:s,height:Math.max(f,(y.length+m.length)*f+(i&&o?2:0))+f,style:{overflow:"visible"},children:jo("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:x,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===h?"right":"middle"===h?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[i&&Wo("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),o&&Wo("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html")):(y.length>0&&(b.push(Wo("text",{className:"annotation-note-title",fill:x,textAnchor:h,fontWeight:"bold",children:y.map((e,t)=>Wo("tspan",{x:p,dy:0===t?0:f,children:e},t))},"annotation-note-title")),g=y.length*f),m.length>0&&b.push(Wo("text",{className:"annotation-note-label",fill:x,textAnchor:h,y:g,children:m.map((e,t)=>Wo("tspan",{x:p,dy:0===t?0:f,children:e},t))},"annotation-note-label")));let v=null;if((i||o)&&(0!==t||0!==n))if("topBottom"===d){const e=Math.min(s,120);let t=0,n=e;"end"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),v=Wo("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(y.length+m.length)*f+(m.length>0?f:0);let t=0,n=e;"bottom"===u?(t=-e,n=0):"middle"===u&&(t=-e/2,n=e/2),v=Wo("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const k=Math.max(0,y.length+m.length-1)*f;let w=0;return"topBottom"===d?w=0>n?-(k+2):18:"leftRight"===d&&(w="middle"===u?-(k+f+(m.length>0&&y.length>0?2:0))/2+8:"bottom"===u||0>n?-(k+2):18),jo("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[Wo("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0,children:b}),v]})}function Lo(e,t,n,r,o){const i=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&i.push(Wo("circle",{r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,r=t?.height||0;(e>0||r>0)&&i.push(Wo("rect",{width:e,height:r,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":t?.custom&&i.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=r||0,a=o||0;if(void 0!==t?.x){const r=(t.x||0)-e;i.push(Wo("line",{x1:r,y1:(t.y1||0)-a,x2:r,y2:(t.y2||0)-a,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const r=(t.y||0)-a;i.push(Wo("line",{x1:(t.x1||0)-e,y1:r,x2:(t.x2||0)-e,y2:r,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?i.push(Wo("line",{x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===t?.y1&&void 0===t?.y2||i.push(Wo("line",{x1:0,y1:(t.y1||0)-a,x2:0,y2:(t.y2||0)-a,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=t?.type||"curly",r=t?.width??t?.height;void 0!==r&&i.push(Wo("path",{d:Ro(e,r,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return Wo("g",{className:"annotation-subject",children:i})}function Io(e,t,n,r,o,i){const a=[];let l=0,s=0;if("callout-circle"!==o&&"label"!==o||!i?.radius){if("callout-rect"===o&&i){const n=i.width||0,r=i.height||0;if(n>0||r>0){const o=n/2,i=r/2,a=e-o,c=t-i;if(0!==a||0!==c){const e=Math.abs(a),t=Math.abs(c),d=n/2,u=r/2,h=e*u>t*d?d/e:u/t;l=o+a*h,s=i+c*h}}}else if("bracket"===o&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(l=e/2,s=n):void 0!==t&&(l=n,s=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const r=Math.atan2(t,e);l=Math.cos(r)*n,s=Math.sin(r)*n}}const c=Math.sqrt((e-l)**2+(t-s)**2);if(c>.5){const o=r||"var(--semiotic-text-secondary, currentColor)",i="curve"===n?.type;let d=Math.atan2(t-s,e-l);if(i){const r=(l+e)/2,i=(s+t)/2,u=-(t-s)/c,h=(e-l)/c,f=(n?.curve??.25)*c,y=r+u*f,m=i+h*f;a.push(Wo("path",{className:"connector-curve",d:`M${l},${s}Q${y},${m} ${e},${t}`,fill:"none",stroke:o},"connector-line")),d=Math.atan2(m-s,y-l)}else a.push(Wo("line",{x1:l,y1:s,x2:e,y2:t,stroke:o},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;a.push(Wo("path",{d:`M${l},${s}L${l+e*Math.cos(d+t)},${s+e*Math.sin(d+t)}L${l+e*Math.cos(d-t)},${s+e*Math.sin(d-t)}Z`,fill:o,stroke:"none"},"connector-arrow"))}}return Wo("g",{className:"annotation-connector",children:a})}function No(e){const{x:t=0,y:n=0,dx:r,dy:o,nx:i,ny:a,note:l,connector:s,subject:c,type:d,color:u,className:h,disable:f,opacity:y,strokeDasharray:m,events:p={},"data-testid":g}=e,b=Array.isArray(t)?t[0]??0:t,x=Array.isArray(n)?n[0]??0:n,v=new Set(Array.isArray(f)?f:[]);let k=r||0,w=o||0;null!=i&&(k=i-b),null!=a&&(w=a-x);const $="string"==typeof d?d:"label";if("bracket"===$&&c&&0===k&&0===w)if(void 0!==c.width){k=c.width/2;const e=c.depth||30;w=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;k=e+(0>e?-5:5),w=c.height/2}return jo("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${b},${x})`,"data-testid":g,...null!=y&&{opacity:y},...m&&{strokeDasharray:m},...p,children:[!v.has("connector")&&Io(k,w,s,u,$,c),!v.has("subject")&&Lo($,c,u,b,x),!v.has("note")&&Oo(l,k,w,u)]})}function zo(e){const{noteData:t}=e,{screenCoordinates:n}=t,r="string"==typeof t.type?t.type:"label",o=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),o=t.ny||n[0][1]+(t.dy??0),i=n.map((n,i)=>{const a=Object.assign({},t,{note:0===i?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:o});return Wo(No,{"data-testid":"semiotic-annotation",...a,type:r},"multi-annotation-"+i)});return Wo("g",{children:i})}const i=t.note||{title:"none",label:t.label},a=`${i.label}-${i.title}-${t.i}`;return Wo(No,{"data-testid":"semiotic-annotation",events:o,...t,type:r},a)}import{packEnclose as Fo}from"d3-hierarchy";import{area as Do,curveLinear as Po,curveMonotoneX as To,curveMonotoneY as Bo,curveStep as Eo,curveStepAfter as Ho,curveStepBefore as Go,curveBasis as qo,curveCardinal as _o,curveCatmullRom as Yo}from"d3-shape";function Vo(e){return Math.round(100*e)/100}function Uo(e,t=2){const n=[],r=[],o=t+1;for(let t=0;o>t;t++){let i=0;for(const[n,r]of e)null!==r&&(i+=n**t*r);n.push(i);const a=[];for(let n=0;o>n;n++){let r=0;for(const[o,i]of e)null!==i&&(r+=o**(t+n));a.push(r)}r.push(a)}r.push(n);const i=function(e,t){const n=e,r=e.length-1,o=[t];for(let e=0;r>e;e++){let t=e;for(let o=e+1;r>o;o++)Math.abs(n[e][o])>Math.abs(n[e][t])&&(t=o);for(let o=e;r+1>o;o++){const r=n[o][e];n[o][e]=n[o][t],n[o][t]=r}for(let t=e+1;r>t;t++)for(let o=r;o>=e;o--)n[o][t]-=n[o][e]*n[e][t]/n[e][e]}for(let e=r-1;e>=0;e--){let t=0;for(let i=e+1;r>i;i++)t+=n[i][e]*o[i];o[e]=(n[r][e]-t)/n[e][e]}return o}(r,o).map(Vo);return{points:e.map(([e])=>[Vo(e),Vo(i.reduce((t,n,r)=>t+n*e**r,0))]),equation:[...i].reverse()}}import{jsx as Zo,jsxs as Xo}from"react/jsx-runtime";var Ko="var(--semiotic-bg, #ffffff)";function Jo(e){const{x:t,y:n,text:r,fill:o,fontSize:i=12,fontWeight:a,fontFamily:l,textAnchor:s="start",dominantBaseline:c,background:d,className:u}=e,h=function(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{type:e.type??"halo",...e}}(d),f=e=>Zo("text",{x:t,y:n,textAnchor:s,dominantBaseline:c,fill:o,fontSize:i,fontWeight:a,fontFamily:l,className:u,...e?{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}:{},children:r});if(!h)return f();if("halo"===h.type)return f({stroke:h.fill??Ko,strokeWidth:h.haloWidth??3});const y=h.padding??{x:6,y:3},m="number"==typeof y?y:y.x,p="number"==typeof y?y:y.y,g=function(e,t){return(e+"").length*t*.6}(r,i),b=i+2*p;let x,v;return x="middle"===s?t-g/2-m:"end"===s?t-g-m:t-m,v="middle"===c||"central"===c?n-b/2:"hanging"===c||"text-before-edge"===c?n-p:n-.8*i-p,Xo("g",{className:u,children:[Zo("rect",{x:x,y:v,width:g+2*m,height:b,rx:h.radius??3,ry:h.radius??3,fill:h.fill??Ko,fillOpacity:h.opacity??.85,stroke:h.stroke,strokeWidth:h.strokeWidth}),f()]})}import{jsx as Qo,jsxs as ei}from"react/jsx-runtime";var ti={linear:Po,monotoneX:To,monotoneY:Bo,step:Eo,stepAfter:Ho,stepBefore:Go,basis:qo,cardinal:_o,catmullRom:Yo};function ni(e,t,n,r){const o=[];return e.forEach((e,i)=>{let a;if(n){const o=n(e,i,r);a=null!=o?o:t(e,i,r)}else a=t(e,i,r);a&&o.push({node:a,annotation:e})}),function(e){const t=e.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:Mo(e.annotation),readingOrder:null,rank:1};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>wo(e.annotation)),o=e.some(e=>null!=$o(e.annotation)),i=e.some(e=>"layer"===$o(e.annotation));if(!n&&!r&&!o)return e.map(e=>e.node);const a=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);a.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,a.length)});for(const e of t)e.emphasis&&(e.rank=vo[e.emphasis]);const l=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:n,emphasis:r,readingOrder:o}=e,i=wo(t.annotation);let a=t.node;if("primary"===r||"secondary"===r||null!=o){const e=null==r&&null!=o;a=xo("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:So(o),"data-annotation-reading-order":o}:{},children:t.node},"annotation-emphasis-"+n)}const l=$o(t.annotation);return l&&(a=xo("g",{className:"annotation-cohesion--"+l,children:a},"annotation-cohesion-"+n)),i&&(a=xo("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:a},"annotation-deferred-"+n)),a});return r&&l.unshift(xo("style",{children:ko},"annotation-disclosure-style")),i&&l.unshift(xo("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),l}(o)}function ri(e,t={}){return function(e,r,o){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const t=p(e,r,o);if(!t)return null;const{x:n,y:i}=t;if(!m(n,i,o))return null;const a="callout"===e.type?"callout-circle":e.type,l="callout-circle"===a?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===a?{width:e.width,height:e.height}:void 0;return Qo(zo,{noteData:{x:n,y:i,dx:e.dx??30,dy:e.dy??-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:a,...l?{subject:l}:{},connector:e.connector||{end:"arrow"},color:e.color,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-"+r)}case"x-threshold":{const t=b(null!=e.value?{...e,x:e.value}:e,o);if(null==t)return null;const n=e.color||"#f97316",i=e.labelPosition||"top";let a;a="bottom"===i?(o.height||0)-4:"center"===i?(o.height||0)/2:16;const l=t>.6*(o.width||0),s=l?t-4:t+4,c=l?"end":"start";return ei("g",{opacity:e.opacity,children:[Qo("line",{x1:t,y1:0,x2:t,y2:o.height||0,stroke:n,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&Qo(Jo,{x:s,y:a,text:e.label,textAnchor:c,fill:n,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+r)}case"y-threshold":{const t=x(null!=e.value?{...e,y:e.value}:e,o);if(null==t)return null;const n=e.color||"#f97316",i=e.labelPosition||"right";let a,s;"left"===i?(a=4,s="start"):"center"===i?(a=(o.width||0)/2,s="middle"):(a=(o.width||0)-4,s="end");const c=20>(l=t)?Math.min((o.height||0)-4,l+16):l-4;return ei("g",{opacity:e.opacity,children:[Qo("line",{x1:0,y1:t,x2:o.width||0,y2:t,stroke:n,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&Qo(Jo,{x:a,y:c,text:e.label,textAnchor:s,fill:n,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+r)}case"enclose":{const t=(e.coordinates||[]).map(e=>({x:b({...e,type:"point"},o),y:x({...e,type:"point"},o),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const n=Fo(t),i=e.padding||10;return ei("g",{children:[Qo("circle",{cx:n.x,cy:n.y,r:n.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&Qo(Jo,{x:n.x,y:n.y-n.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+r)}case"rect-enclose":{const t=(e.coordinates||[]).map(e=>({x:b({...e,type:"point"},o),y:x({...e,type:"point"},o)})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const n=e.padding||10,i=t.map(e=>e.x),a=t.map(e=>e.y),[l,s]=M(i),[c,d]=M(a),u=l-n,h=s+n,f=c-n;return ei("g",{children:[Qo("rect",{x:u,y:f,width:h-u,height:d+n-f,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&Qo(Jo,{x:(u+h)/2,y:f-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+r)}case"highlight":{const t=o.data||[],n="function"==typeof e.filter?t.filter(e.filter):e.field&&null!=e.value?t.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return Qo("g",{children:n.map((t,n)=>{const r=b(t,o),a=x(t,o);if(null==r||null==a)return null;const l="function"==typeof e.r?e.r(t):e.r||6,s="function"==typeof e.style?e.style(t):e.style||i;return Qo("circle",{cx:r,cy:a,r:l,...s},"hl-"+n)})},"ann-"+r)}case"bracket":{const t=b(e,o),n=x(e,o);return Qo(zo,{noteData:{x:t??0,y:n??0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+r)}case"trend":{const t=o.data||[];if(2>t.length)return null;const n=o.xAccessor||"x",i=o.yAccessor||"y",a="ordinal"===o.frameType,l="horizontal"===o.projection,s=a?n:null,c=a?i:null;let d;const u=[],h=new Map;if(a&&s&&c){for(const e of t){const t=e[s];if(null==t)continue;const n=t+"";h.has(n)||(h.set(n,u.length),u.push(n))}d=t.map(e=>{const t=e[s],n=e[c];if(null==t||null==n)return null;const r=h.get(t+"");return null!=r?[r,+n]:null}).filter(e=>null!==e)}else d=t.map(e=>[e[n],e[i]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>d.length)return null;const f=o.scales?.x??o.scales?.time,y=o.scales?.y??o.scales?.value;if(!f||!y)return null;const m=e=>t=>{const n=Math.max(0,Math.floor(t)),r=Math.min(u.length-1,n+1),o=t-n,i=e(u[n]);return i+(e(u[r])-i)*o},p=f,g=y;let b;if(a)if(l){const e=m(g);b=(t,n)=>[p(n),e(t)]}else{const e=m(p);b=(t,n)=>[e(t),g(n)]}else b=(e,t)=>[p(e),g(t)];const x=e.method||"linear";let v;if("loess"===x)v=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const r=e.slice().sort((e,t)=>e[0]-t[0]),o=r.map(e=>e[0]),i=r.map(e=>e[1]),a=Math.max(2,Math.ceil(t*n)),l=[];for(let e=0;n>e;e++){const t=o[e],r=o.map(e=>Math.abs(e-t)),s=r.slice().sort((e,t)=>e-t)[Math.min(a-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===s?0:r[e]/s;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let d=0,u=0,h=0,f=0,y=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(d+=t,u+=t*o[e],h+=t*i[e],f+=t*o[e]*o[e],y+=t*o[e]*i[e])}if(0===d){l.push([t,i[e]]);continue}const m=d*f-u*u;if(1e-12>Math.abs(m))l.push([t,h/d]);else{const e=(d*y-u*h)/m;l.push([t,(h-e*u)/d+e*t])}}return l}(d,e.bandwidth??.3);else{const t="polynomial"===x?Uo(d,e.order||2):function(e){const t=[0,0,0,0];let n=0;for(const[r,o]of e)null!==o&&(n++,t[0]+=r,t[1]+=o,t[2]+=r*r,t[3]+=r*o);const r=n*t[2]-t[0]*t[0],o=0===r?0:Vo((n*t[3]-t[0]*t[1])/r),i=Vo(t[1]/n-o*t[0]/n);return{points:e.map(([e])=>[Vo(e),Vo(o*e+i)]),equation:[o,i]}}(d);v=t.points}const k=v.map(([e,t])=>{const[n,r]=b(e,t);return`${n},${r}`}).join(" "),w=e.color||"#6366f1",$=v[v.length-1],[M,S]=b($[0],$[1]);return ei("g",{children:[Qo("polyline",{points:k,fill:"none",stroke:w,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&Qo("text",{x:M+4,y:S-4,fill:w,fontSize:11,children:e.label})]},"ann-"+r)}case"band":{const t=o.scales?.y??o.scales?.value,n=t?.domain?.(),l=e.y0??n?.[0],s=e.y1??n?.[1],d=null!=l&&t?t(l):0,u=null!=s&&t?t(s):o.height||0,h=c(e.fill,"ann-"+r,"var(--semiotic-primary, #6366f1)");return ei("g",{opacity:e.opacity,children:[h.def&&Qo("defs",{children:h.def}),Qo("rect",{x:0,y:Math.min(d,u),width:o.width||0,height:Math.abs(u-d),fill:h.fill,fillOpacity:e.fillOpacity||.1}),e.label&&Qo(Jo,{x:(o.width||0)-4,y:(i=d,a=u,Math.max(Math.min(i,a),0)+16),textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+r)}case"x-band":{const t=o.scales?.x??o.scales?.time,n=t?.domain?.(),i=e.x0??n?.[0],a=e.x1??n?.[1],l=null!=i&&t?t(i):null,s=null!=a&&t?t(a):null;if(null==l||null==s)return null;const d=c(e.fill||e.color,"ann-"+r,"var(--semiotic-primary, #6366f1)");return ei("g",{opacity:e.opacity,children:[d.def&&Qo("defs",{children:d.def}),Qo("rect",{x:Math.min(l,s),y:0,width:Math.abs(s-l),height:o.height||0,fill:d.fill,fillOpacity:e.fillOpacity??.1}),e.label&&Qo(Jo,{x:Math.min(l,s)+4,y:16,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+r)}case"envelope":{const t=o.data||[];if(2>t.length)return null;const n=o.xAccessor||"x",i=o.scales?.x??o.scales?.time,a=o.scales?.y??o.scales?.value;if(!i||!a)return null;const l=e.upperAccessor||"upperBounds",s=e.lowerAccessor||"lowerBounds",c=e.filter,d=t.filter(e=>null!=e[l]&&null!=e[s]&&!(c&&!c(e))).sort((e,t)=>e[n]-t[n]);if(2>d.length)return null;const u=ti[o.curve||"linear"]||Po,h=Do().x(e=>i(e[n])).y0(e=>a(e[s])).y1(e=>a(e[l])).curve(u)(d);if(!h)return null;const f=e.fill||"#6366f1";return ei("g",{children:[Qo("path",{d:h,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&d.length>0&&Qo("text",{x:i(d[d.length-1][n])+4,y:a(d[d.length-1][l])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+r)}case"anomaly-band":{const t=o.data||[];if(2>t.length)return null;const n=o.yAccessor||"y",i=o.scales?.x??o.scales?.time,a=o.scales?.y??o.scales?.value;if(!i||!a)return null;const l=t.map(e=>e[n]).filter(e=>null!=e&&isFinite(e));if(2>l.length)return null;const s=l.reduce((e,t)=>e+t,0)/l.length,c=l.reduce((e,t)=>e+(t-s)**2,0)/l.length,d=Math.sqrt(c),u=e.threshold??2,h=s-u*d,f=!1!==e.showBand,y=e.fill||"#6366f1",m=e.fillOpacity??.1,p=e.anomalyColor||"#ef4444",g=e.anomalyRadius??6,v=a(s+u*d),k=a(h),w=t.filter(e=>{const t=e[n];return null!=t&&Math.abs(t-s)>u*d});return ei("g",{children:[f&&Qo("rect",{x:0,y:Math.min(v,k),width:o.width||0,height:Math.abs(k-v),fill:y,fillOpacity:m}),w.map((e,t)=>{const n=b(e,o),r=x(e,o);return null==n||null==r?null:Qo("circle",{cx:n,cy:r,r:g,fill:p,fillOpacity:.7,stroke:p,strokeWidth:1.5},"anomaly-"+t)}),e.label&&Qo("text",{x:(o.width||0)-4,y:Math.min(v,k)-4,textAnchor:"end",fill:y,fontSize:11,children:e.label})]},"ann-"+r)}case"forecast":{const t=o.data||[];if(3>t.length)return null;const n=o.xAccessor||"x",i=o.yAccessor||"y",a=o.scales?.x??o.scales?.time,l=o.scales?.y??o.scales?.value;if(!a||!l)return null;const s=t.map(e=>[e[n],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>s.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=Uo(s,e.order||2).equation;c=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}else{const e=s.length;let t=0,n=0,r=0,o=0;for(const[e,i]of s)t+=e,n+=i,r+=e*e,o+=e*i;const i=e*r-t*t;if(1e-12>Math.abs(i))return null;const a=(e*o-t*n)/i,l=(n-a*t)/e;c=e=>l+a*e}const d=s.length,u=s.map(([e,t])=>t-c(e)),h=u.reduce((e,t)=>e+t*t,0),f=Math.sqrt(h/Math.max(d-2,1)),y=s.reduce((e,t)=>e+t[0],0)/d,m=s.reduce((e,t)=>e+(t[0]-y)**2,0),p=e.confidence??.95,g=.99>p?.95>p?.9>p?1:1.645:1.96:2.576,b=e.steps??5,x=s[d-1][0],v=(x-s[0][0])/Math.max(d-1,1),k=[];for(let e=1;b>=e;e++)k.push(x+e*v);const w=[];for(const e of k){const t=c(e),n=f*Math.sqrt(1+1/d+(m>0?(e-y)**2/m:0))*g;w.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const $=`M${w.map(e=>`${a(e.x)},${l(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${a(e.x)},${l(e.yLower)}`).join(" L")} Z`,M=w.map(e=>`${a(e.x)},${l(e.yCenter)}`).join(" "),S=`${a(x)},${l(c(x))}`,A=e.strokeColor||"#6366f1";return ei("g",{children:[Qo("path",{d:$,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),Qo("polyline",{points:`${S} ${M}`,fill:"none",stroke:A,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&w.length>0&&Qo("text",{x:a(w[w.length-1].x)+4,y:l(w[w.length-1].yCenter)-4,fill:A,fontSize:11,children:e.label})]},"ann-"+r)}case"widget":{let i,a;if(null!=e.px&&null!=e.py)i=e.px,a=e.py;else{const t=p(e,r,o);if(!t)return null;i=t.x,a=t.y}if(!m(i,a,o))return null;const l=e.dx??0,s=e.dy??0,c=e.width??32,d=e.height??32,u=e.content??Qo("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return Qo("foreignObject",{x:i+l-c/2,y:a+s-d/2,width:c,height:d,style:{overflow:"visible",pointerEvents:"auto"},children:Qo("div",{...n(e,t),style:{width:c,height:d,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+r)}case"text":{const t=p(e,r,o);if(!t)return null;const{x:n,y:i}=t,a=n+(e.dx||0),l=i+(e.dy||0),s=e.color||"var(--semiotic-text, #333)",c=Qo("text",{x:a,y:l,fill:s,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?Ao.cloneElement(c,{key:"ann-text-"+r}):ei("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[Qo("line",{x1:n,y1:i,x2:a,y2:l,stroke:s,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),Ao.cloneElement(c,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+r)}case"category-highlight":{const t=e.category;if(null==t)return null;const n=e=>"function"==typeof e&&"function"==typeof e.bandwidth,i=o.scales?.o,a=o.scales?.x,l=o.scales?.y,s=n(i)?i:n(a)?a:n(l)?l:null;if(!s)return null;const c=s(t+"");if(null==c)return null;const d=s.bandwidth(),u=e.color||"var(--semiotic-primary, #4589ff)",h=e.opacity??.15,f=e.label;return ei("g",(o.projection?"vertical"===o.projection:s===a)?{children:[Qo("rect",{x:c,y:0,width:d,height:o.height||0,fill:u,fillOpacity:h}),f&&Qo(Jo,{x:c+d/2,y:16,textAnchor:"middle",fill:u,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]}:{children:[Qo("rect",{x:0,y:c,width:o.width||0,height:d,fill:u,fillOpacity:h}),f&&Qo(Jo,{x:12,y:c+d/2,dominantBaseline:"middle",fill:u,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]},"ann-"+r)}default:return null}var i,a,l}}function oi(e,t,n){return gr(e,t,n)}function ii(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&wr(n,e)||"#4e79a7":t=>{if(n){const e=wr(n,t);if(e)return e}let r=0;for(let e=0;t.length>e;e++)r=31*r+t.charCodeAt(e)|0;return e[Math.abs(r)%e.length]??"#4e79a7"}}export{R as filterSparseArray,mr as DEFAULT_COLORS,pr as DEFAULT_COLOR,gr as resolveCategoricalPalette,br as STREAMING_PALETTE,xr as DEPTH_PALETTE_COLORS,kr as getColor,wr as resolveExplicitColor,$r as createColorScale,Mr as getSize,Yt as computeEasing,Vt as computeRawProgress,Ut as lerp,Zt as now,B as useSceneRevisionDiagnostics,E as runSceneBuild,H as SceneRevisionDiagnosticsObserver,Me as resolveCurveFactory,Se as resolveCanvasFill,Ae as coerceCanvasFill,We as buildLinearFillGradient,je as buildColorStopGradient,Pr as DEFAULT_LEGEND_ROW_HEIGHT,Tr as resolveLegendMetrics,Br as layoutVerticalLegendGroups,to as composeLegendConfigs,no as isLegendConfig,ro as isGradientLegendConfig,bo as renderLegendFromConfig,zo as SemioticAnnotation,ko as ANNOTATION_DISCLOSURE_REVEAL_CSS,Jo as AnnotationLabel,ni as renderAnnotationPass,ri as createDefaultAnnotationRules,Tn as unlockCrosshair,_n as useCrosshairPosition,G as TITLE_BASELINE,q as hasTextTitle,Y as reserveTitleMargin,Z as hasAnyCornerRadius,X as clampCornerRadii,Ie as networkSceneNodeToSVG,Ne as networkSceneEdgeToSVG,ze as networkLabelToSVG,Te as geoSceneNodeToSVG,ue as ordinalSceneNodeToSVG,Ge as xySceneNodeToSVG,qe as isServerEnvironment,Ke as useHydration,tt as useWasHydratingFromSSR,ct as useDataSummary,ot as AriaLiveTooltip,ht as computeCanvasAriaLabel,ft as computeNetworkAriaLabel,Wt as AccessibleDataTable,jt as NetworkAccessibleDataTable,Ct as ScreenReaderSummary,Rt as SkipToTableLink,It as FocusRing,Ft as FlippingTooltip,Qt as useFrame,rn as useFrameCanvasHost,on as CanvasFrameBackground,an as prepareCanvas,ln as getDevicePixelRatio,sn as observationInputType,cn as isInteractiveKeyboardTarget,dn as emitHoverObservations,un as emitClickObservations,oi as resolveCustomLayoutPalette,ii as buildResolveColor,mn as ChartError,vn as SafeRender,$n as renderEmptyState,Mn as renderLoadingState,Sn as warnMissingField,Wr as useCategoryColors,Un as useBrushSelection,Xn as normalizeLinkedBrush,Kn as wrapStyleWithSelection,Qn as resolveMobileInteraction,tr as isChartMode,nr as resolveChartMode,so as useThemeCategorical,co as resolveDefaultFill,uo as useColorScale,ho as useChartSelection,fo as getCrosshairProps,yo as useChartLegendAndMargin,mo as useLegendInteraction,po as useChartMode};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{forceLayout as n}from"./chunk-chunk-NKZ75IM5.module.min.js";import{canUseForceWorker as t,runForceLayoutWorker as e,shouldUseForceWorker as o}from"./chunk-chunk-LQBSXO7K.module.min.js";import{useWasHydratingFromSSR as r}from"./chunk-chunk-ACLDBMRH.module.min.js";import{useEffect as i,useMemo as s,useRef as u,useState as a}from"react";var d=new WeakMap;function l(n){const t=[];for(const e of Object.keys(n).sort()){const o=n[e];if(void 0!==o){if("function"==typeof o)return null;t.push(`${e}:${o+""}`)}}return t.join("|")}function c(n,t,e){return null==e?null:d.get(n)?.get(t)?.get(e)??null}function p(n,t,e,o){if(null==e)return;let r=d.get(n);r||(r=new WeakMap,d.set(n,r));let i=r.get(t);if(i||(i=new Map,r.set(t,i)),!i.has(e)&&i.size>=16){const n=i.keys().next().value;void 0!==n&&i.delete(n)}i.set(e,o)}function f(d,f,m={}){const h=r(),{seed:g,iterations:k,repulsion:y,linkDistance:w,linkStrength:b,centerStrength:j,damping:v,nodeRadius:R,nodePadding:x,inset:M,execution:S,workerThreshold:A}=m,E=s(()=>({seed:g,iterations:k,repulsion:y,linkDistance:w,linkStrength:b,centerStrength:j,damping:v,nodeRadius:R,nodePadding:x,inset:M,execution:S,workerThreshold:A}),[g,k,y,w,b,j,v,R,x,M,S,A]),O=u(h),[D,T]=a(()=>{if("undefined"==typeof window||h){const t=n(d,f,E);return p(d,f,l(E),t),{positions:t,status:"ready",error:null}}const t=c(d,f,l(E));return t?{positions:t,status:"ready",error:null}:{positions:null,status:"pending",error:null}});return i(()=>{if(O.current)return void(O.current=!1);const r=l(E),i=c(d,f,r);if(i)return void T(n=>"ready"===n.status&&n.positions===i?n:{positions:i,status:"ready",error:null});const s=new AbortController;return T(n=>({positions:n.positions,status:"pending",error:null})),async function(r,i,s={}){const{execution:u="auto",signal:a,workerThreshold:d,nodeRadius:l,...c}=s,p=c.iterations??260;if(!t()||!o(u,r.length,i.length,p,d))return n(r,i,{...c,nodeRadius:l});const f={kind:"normalized",nodes:r.map(n=>({...n})),edges:i.map(n=>({...n})),options:c,nodeRadii:"function"==typeof l?Object.fromEntries(r.map(n=>[n.id,l(n)])):null==l?void 0:Object.fromEntries(r.map(n=>[n.id,l]))};try{return(await e(f,a)).positions}catch(t){if("AbortError"===t?.name)throw t;return n(r,i,{...c,nodeRadius:l})}}(d,f,{...E,signal:s.signal}).then(n=>{p(d,f,r,n),T({positions:n,status:"ready",error:null})}).catch(n=>{"AbortError"!==n.name&&T(t=>({positions:t.positions,status:"error",error:n}))}),()=>s.abort()},[d,f,E]),D}export{f as useForceLayout};
2
+ import{forceLayout as n}from"./chunk-chunk-TUBMTZMU.module.min.js";import{canUseForceWorker as t,runForceLayoutWorker as e,shouldUseForceWorker as o}from"./chunk-chunk-4AANPFOX.module.min.js";import{useWasHydratingFromSSR as r}from"./chunk-chunk-ACLDBMRH.module.min.js";import{useEffect as i,useMemo as s,useRef as u,useState as a}from"react";var d=new WeakMap;function l(n){const t=[];for(const e of Object.keys(n).sort()){const o=n[e];if(void 0!==o){if("function"==typeof o)return null;t.push(`${e}:${o+""}`)}}return t.join("|")}function c(n,t,e){return null==e?null:d.get(n)?.get(t)?.get(e)??null}function p(n,t,e,o){if(null==e)return;let r=d.get(n);r||(r=new WeakMap,d.set(n,r));let i=r.get(t);if(i||(i=new Map,r.set(t,i)),!i.has(e)&&i.size>=16){const n=i.keys().next().value;void 0!==n&&i.delete(n)}i.set(e,o)}function f(d,f,m={}){const h=r(),{seed:g,iterations:k,repulsion:y,linkDistance:w,linkStrength:b,centerStrength:j,damping:v,nodeRadius:R,nodePadding:A,inset:M,execution:x,workerThreshold:T}=m,E=s(()=>({seed:g,iterations:k,repulsion:y,linkDistance:w,linkStrength:b,centerStrength:j,damping:v,nodeRadius:R,nodePadding:A,inset:M,execution:x,workerThreshold:T}),[g,k,y,w,b,j,v,R,A,M,x,T]),O=u(h),[S,D]=a(()=>{if("undefined"==typeof window||h){const t=n(d,f,E);return p(d,f,l(E),t),{positions:t,status:"ready",error:null}}const t=c(d,f,l(E));return t?{positions:t,status:"ready",error:null}:{positions:null,status:"pending",error:null}});return i(()=>{if(O.current)return void(O.current=!1);const r=l(E),i=c(d,f,r);if(i)return void D(n=>"ready"===n.status&&n.positions===i?n:{positions:i,status:"ready",error:null});const s=new AbortController;return D(n=>({positions:n.positions,status:"pending",error:null})),async function(r,i,s={}){const{execution:u="auto",signal:a,workerThreshold:d,nodeRadius:l,...c}=s,p=c.iterations??260;if(!t()||!o(u,r.length,i.length,p,d))return n(r,i,{...c,nodeRadius:l});const f={kind:"normalized",nodes:r.map(n=>({...n})),edges:i.map(n=>({...n})),options:c,nodeRadii:"function"==typeof l?Object.fromEntries(r.map(n=>[n.id,l(n)])):null==l?void 0:Object.fromEntries(r.map(n=>[n.id,l]))};try{return(await e(f,a)).positions}catch(t){if("AbortError"===t?.name)throw t;return n(r,i,{...c,nodeRadius:l})}}(d,f,{...E,signal:s.signal}).then(n=>{p(d,f,r,n),D({positions:n,status:"ready",error:null})}).catch(n=>{"AbortError"!==n.name&&D(t=>({positions:t.positions,status:"error",error:n}))}),()=>s.abort()},[d,f,E]),S}export{f as useForceLayout};
@@ -0,0 +1 @@
1
+ import{makeRuleValueResolver as t,resolveStyleRules as e}from"./chunk-chunk-NEVE562N.module.min.js";import{PhysicsPipelineStore as o,absorbRegion as n,bodyGroupSpec as i,capacitatedRegion as a,collidersFromPlotBounds as r,collidersFromXScaleBins as s,forceFieldRegion as l,groupCompletionRows as c,portalRegion as d,pressureFieldRegion as u,processStageLayout as p,routeSurfaceRegion as h}from"./chunk-chunk-LRIFN2HK.module.min.js";import{buildResolveColor as g,resolveCustomLayoutPalette as m,xySceneNodeToSVG as y}from"./chunk-chunk-E6TXX6MI.module.min.js";import{schemeCategory10 as f}from"./chunk-chunk-5RKXZQ2P.module.min.js";function x(t){const e=t.datum;if(e&&"object"==typeof e){const t=e.label??e.name??e.id;if(null!=t&&""!==t)return t+""}return t.id}function b(t,e={}){const o=e.bodies??[],n=Math.max(0,e.recentBodyLimit??6),i=new Map;for(const t of o){const o=e.getContainerId?.(t);if(!o)continue;const n=i.get(o);n?n.push(t):i.set(o,[t])}const a=t.map(t=>{const o=i.get(t.id)??[],a=Math.max(0,Math.floor(t.count??o.length)),r=o.slice(Math.max(0,o.length-n)).map(t=>({id:t.id,label:e.getBodyLabel?.(t)??x(t),datum:t.datum}));return{id:t.id,label:t.label,count:a,share:0,secondary:t.secondary,secondaryLabel:t.secondaryLabel,observed:t.observed,bodyIds:o.map(t=>t.id),recentBodies:r,metadata:t.metadata}}),r=a.reduce((t,e)=>t+e.count,0);return a.map(t=>({...t,share:r>0?t.count/r:0}))}function w(t,e={}){const o=e.chartType??"Physics chart",n=e.chartId??"physics",i=t.reduce((t,e)=>t+e.count,0),a=t.filter(t=>t.count>0).length,r=e.projectionLabel??"settled projection",s=Math.max(0,e.maxBodiesPerContainer??6);let l=0;return{id:n,role:"chart",level:1,label:e.title??`${o}: ${i} bodies across ${t.length} containers; ${a} containers currently non-empty.`,children:t.map(t=>{const e=t.recentBodies.slice(0,s).map(e=>{return{id:`${t.id}-body-${l++}`,role:"datum",level:3,label:e.label,datum:(o=e.datum,o&&"object"==typeof o?o:null)};var o}),o=Math.max(0,t.bodyIds.length-e.length);o>0&&e.push({id:`${t.id}-more-${l++}`,role:"datum",level:3,label:`…and ${o} more recent bodies`});const n=[t.count+" bodies"];var i;return n.push(Number.isFinite(i=t.share)&&i>0?.01>i?"<1%":Math.round(100*i)+"%":"0%"),null!=t.secondary&&t.secondary>0&&n.push(`${t.secondary} ${t.secondaryLabel??"secondary"}`),null!=t.observed&&n.push(t.observed+" observed"),{id:t.id,role:"series",level:2,label:`${t.label}: ${n.join(", ")} in the ${r}.`,value:t.count,datum:t.metadata??null,children:e}})}}function v(t,e={}){const o=e.getDatumLabel?.(t.datum,t)??function(t,e){if(t&&"object"==typeof t){const e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e}(t.datum,t.bodyId);return"physics-bin-enter"===t.type?`${o??"A body"} entered ${t.binId??t.sensorId??"a bin"}.`:"physics-bin-exit"===t.type?`${o??"A body"} exited ${t.binId??t.sensorId??"a bin"}.`:"physics-proximity-enter"===t.type?`${o??"A body"} entered proximity sensor ${t.binId??t.sensorId??"a sensor"}.`:"physics-proximity-exit"===t.type?`${o??"A body"} exited proximity sensor ${t.binId??t.sensorId??"a sensor"}.`:"physics-settle"===t.type?(o??"A body")+" settled.":"physics-late"===t.type?`${o??"A body"} arrived late for ${t.binId??t.sensorId??"a closed window"}.`:"physics-barrier-cross"===t.type?`${n=t.barrierId??"Barrier",0===n.length?n:n.charAt(0).toUpperCase()+n.slice(1)} crossed ${function(t){return t.binId?t.binId:"number"==typeof t.barrierValue?""+Math.round(t.barrierValue):"a threshold"}(t)}.`:"sim-active"===t.type?"Simulation running.":"sim-idle"===t.type?"Simulation settled.":null;var n}function M(t=[]){return t.map(t=>({id:t.id,label:t.label,count:t.count,...null!=t.secondary?{secondary:t.secondary}:{},...t.secondaryLabel?{secondaryLabel:t.secondaryLabel}:{},...null!=t.observed?{observed:t.observed}:{}}))}function k(t,e={}){const o=e.bodies??function(t){return t.world.bodies.map(t=>({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,shape:{...t.shape},sleeping:t.sleeping,datum:t.datum}))}(t),n=o.filter(t=>t.sleeping).length;return{bodyCount:o.length,sleepingCount:n,settled:"settled"===t.simulationState&&0===t.queue.length&&n===o.length,stepsRun:Math.max(0,Math.floor(e.stepsRun??0)),seed:t.world.options.seed,binCounts:M(e.projectionRows)}}var S={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function I(t){const e=t.datum;if(e&&"object"==typeof e){const t=e.label??e.name??e.id;if(null!=t&&""!==t)return t+""}return t.id}function A(t,e){const o="function"==typeof e?e(t):e;return{...S,...o??{}}}function P(t,e={}){const o=function(t){return t.datum&&"object"==typeof t.datum?t.datum:null}(t),n={label:e.getBodyLabel?.(t)??I(t)},i={style:A(t,e.bodyStyle),datum:o,accessibleDatum:o,accessibility:n,_transitionKey:t.id};return"aabb"===t.shape.type?{type:"rect",x:t.x-t.shape.width/2,y:t.y-t.shape.height/2,w:t.shape.width,h:t.shape.height,...i}:{type:"point",x:t.x,y:t.y,r:t.shape.radius,pointId:t.id,...i}}function C(t,e={}){return t.map(t=>P(t,e))}function $(t,e={}){const o=t.settle(e.maxSteps),n=t.readBodies(),i=t.snapshot();return{snapshot:i,bodies:n,sceneNodes:C(n,e),evidence:k(i,{bodies:n,projectionRows:e.projectionRows,stepsRun:o}),stepsRun:o}}import*as z from"react-dom/server";import{jsx as R,jsxs as T}from"react/jsx-runtime";var L={top:0,right:0,bottom:0,left:0};function j(t,e,o){return"function"==typeof t?t({size:e,margin:o}):t}function E(t,e={}){const{width:o=640,height:n=360,title:i,description:a,background:r,backgroundGraphics:s,className:l,foregroundGraphics:c,idPrefix:d="physics",margin:u,renderBodySVG:p,...h}=e,g=$(t,h),m={...L,...u},f=[o,n],x=j(s,f,m),b=j(c,f,m),w=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"physics-"+e:e}(d),v=i?w+"-title":void 0,M=a?w+"-desc":void 0,k=[v,M].filter(Boolean).join(" ")||void 0;return{svg:z.renderToStaticMarkup(T("svg",{xmlns:"http://www.w3.org/2000/svg",className:l??"stream-physics-frame",width:o,height:n,viewBox:`0 0 ${o} ${n}`,role:"img","aria-labelledby":k,children:[i&&R("title",{id:v,children:i}),a&&R("desc",{id:M,children:a}),!s&&r&&"transparent"!==r?R("rect",{x:0,y:0,width:o,height:n,fill:r}):null,x,R("g",{id:w+"-data-area",children:g.sceneNodes.map((t,e)=>{const o=g.bodies[e];return(o&&p?p(o,t.style??{},e,w):void 0)??y(t,e,w)})}),b]})),scene:g,evidence:g.evidence}}import{scaleLinear as Y}from"d3-scale";function B(t){const[e,o]=t,n=160>e||116>o,i=n?Math.min(12,Math.max(2,.08*e)):32,a=n?Math.min(8,Math.max(2,.12*o)):24,r=n?a:34;return{width:e,height:o,plot:{x:i,y:a,width:Math.max(1,e-2*i),height:Math.max(1,o-a-r)}}}function N(t){const e=(t??"")+"";if(!e)return"#4e79a7";const o=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let n=0;for(let t=0;e.length>t;t+=1)n=31*n+e.charCodeAt(t)>>>0;return o[n%o.length]}function F(o,n="#4e79a7",i){const a=i?.styleRules,r=!!a&&a.length>0,s=r?t(i?.valueAccessor):void 0;return t=>{const i=t.datum,l=i&&o?"function"==typeof o?o(i,0):i[o]:void 0,c={fill:null==l?n:N(l),stroke:"#111827",strokeWidth:1,opacity:.9};return r&&i&&Object.assign(c,e(i,a,{value:s?s(i):void 0,category:null==l?void 0:l+""})),c}}function D(t,e,o,n){return{fixedDt:1/120,maxSubsteps:8,colliders:e,observation:{chartType:o},kernel:{seed:t,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...n}}}function X(t,e,o){return"function"==typeof o?o(t,e):t[o]}function V(t){if(t instanceof Date){const e=t.getTime();return Number.isFinite(e)?e:null}const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:null}function W(t,e,o){return Math.max(e,Math.min(o,t))}function _(t,e){const o=V(t);return null!=o&&o>0?o:e}function O(t){return((t??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function U(t){let e=t>>>0;return()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}import{scaleLinear as G}from"d3-scale";function Z(t){const e=Math.max(2,Math.round(t.bins)),o=Math.max(1,Math.round(t.pegRows??e-1)),n=Math.max(1,Math.round(t.count??Math.max(64,4*e))),i=W(Number.isFinite(t.branchProbability)?t.branchProbability??.5:.5,0,1),a=U(t.seed??1),r=t.idPrefix??"mechanical";return Array.from({length:n},(t,e)=>{let n=0;for(let t=0;o>t;t+=1)a()<i&&(n+=1);const s=o/2;return{id:`${r}-${e}`,value:n,mechanical:!0,pegRows:o,branchProbability:i,pathRights:n,side:s>n?"left":n>s?"right":"center"}})}function K(t){const{data:e,valueAccessor:o,bins:n,ballRadius:i,seed:a,size:l,valueExtent:c}=t,d=B(l),u=e.map((t,e)=>V(X(t,e,o))).filter(t=>null!=t),p=function(t){if(!t)return;const e=V(t[0]),o=V(t[1]);return null!=e&&null!=o?e>o?[o,e]:[e,o]:void 0}(c),h=p?.[0]??(u.length?Math.min(...u):0),g=p?.[1]??(u.length?Math.max(...u):1),m=g===h?1:g-h,y=G().domain([0,n]).range([d.plot.x,d.plot.x+d.plot.width]),f=Array.from({length:n},()=>0),x=[];e.forEach((t,e)=>{const a=V(X(t,e,o));if(null==a)return;const r=Math.max(0,Math.min(n-1,Math.floor((a-h)/m*n)));f[r]+=1,x.push({id:(t.id??"galton-"+e)+"",x:y(r+.5),y:d.plot.y+i+2,vx:8*(e%5-2),vy:0,mass:1,shape:{type:"circle",radius:i},datum:{...t,value:a,bin:r}})});const b=d.plot.y+d.plot.height;return{config:D(a,[...r({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...s({idPrefix:"galton-bin",count:n,domainStart:0,domainStep:1,xScale:y,yTop:d.plot.y-400,yBottom:b,wallThickness:6})],"GaltonBoardChart"),initialSpawns:x,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:f.map((t,e)=>({label:e+1+"",value:t})),metadata:{kind:"galton-board",bins:n,plot:d.plot,valueExtent:[h,g]}}}import{scaleLinear as q}from"d3-scale";function H(t){const{count:e,idPrefix:o,wallThickness:n,xScale:i,yBottom:a,yTop:r,yTopForIndex:s}=t;return Array.from({length:e+1},(t,e)=>{const l=Math.min(a-1,s?.(e)??r),c=Math.max(1,a-l);return{id:`${o}-wall-${e}`,shape:{type:"aabb",x:i(e),y:l+c/2,width:n,height:c}}})}function Q(t){const{data:e,timeAccessor:o,arrivalAccessor:n,windows:i,watermark:a,ballRadius:s,seed:l,size:c,timeExtent:d,timeScale:u=1}=t,p=B(c),h=e.map((t,e)=>V(X(t,e,o))).filter(t=>null!=t),g=V(d?.[0]),m=V(d?.[1]),y=h.length?Math.min(...h):0,f=h.length?Math.max(...h):y+i.size,x=Math.min(g??y,y),b=Math.max(m??f,f),w=Math.floor(x/i.size)*i.size,v=Math.max(1,Math.ceil((b-w+i.size)/i.size)),M=h.length?Math.max(...h):0,k="function"==typeof a?a(M):V(a?.value)??M-(a?.delay??i.size),S=Math.max(0,Math.min(v,Array.from({length:v},(t,e)=>e).reduce((t,e)=>w+(e+1)*i.size>k?t:t+1,0))),I=function(t,e){const o=Math.max(5*e,Math.min(92,.13*t.plot.width));return{gutter:{x:t.plot.x,y:t.plot.y,width:o,height:t.plot.height},windowPlot:{x:t.plot.x+o,y:t.plot.y,width:Math.max(40,t.plot.width-o),height:t.plot.height},wallTop:t.plot.y+.48*t.plot.height}}(p,s),A=w+v*i.size,P=q().domain([w,A]).range([I.windowPlot.x,I.windowPlot.x+I.windowPlot.width]),C=Array.from({length:v},()=>({value:0,secondary:0})),$=[];e.forEach((t,e)=>{const a=V(X(t,e,o));if(null==a)return;const r=V(X(t,e,n))??a,l=Math.max(0,Math.min(v-1,Math.floor((a-w)/i.size))),c=k>=w+(l+1)*i.size;C[l].value+=c?0:1,C[l].secondary+=c?1:0,$.push({id:(t.id??"event-"+e)+"",x:Math.max(I.windowPlot.x+s,Math.min(I.windowPlot.x+I.windowPlot.width-s,P(a))),y:p.plot.y+s+2,vx:8*(e%3-1),vy:0,mass:1,friction:.02,spawnAt:r,shape:{type:"circle",radius:s},datum:{...t,eventTime:a,arrivalTime:r,windowIndex:l,late:c}})});const z=p.plot.y+p.plot.height,R=function(t,e){const o=Math.max(0,Math.min(t.windowCount,t.closedWindowCount));if(!o)return[];const n=t.windowStart,i=t.windowStart+t.windowCount*t.windowSize,a=q().domain([n,i]).range([t.windowPlot.x,t.windowPlot.x+t.windowPlot.width]),r=a(t.windowStart+o*t.windowSize),s=t.windowPlot.x,l=e+Math.max(18,Math.min(.3*t.windowPlot.height,r-s)),c=t=>r===s?e:l+(t-s)/(r-s)*(e-l),d=[];for(let e=0;o>e;e+=1){const o=t.windowStart+e*t.windowSize,n=o+t.windowSize,i=a(o),r=a(n);d.push({id:"eventdrop-lid-"+e,windowIndex:e,x1:i,y1:c(i),x2:r,y2:c(r)})}return d}({closedWindowCount:S,gutter:I.gutter,plot:p.plot,windowCount:v,windowPlot:I.windowPlot,windowSize:i.size,windowStart:w},p.plot.y+.28*p.plot.height);return{config:D(l,[...r({x:p.plot.x,y:p.plot.y,width:p.plot.width,height:p.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...H({idPrefix:"eventdrop-window",count:v,xScale:t=>P(w+t*i.size),yTop:I.wallTop,yTopForIndex:t=>{const e=(t=>{if(0>t||t>S)return null;const e=0===t?R[0]?.y1:R[t-1]?.y2??R[t]?.y1;return"number"==typeof e&&Number.isFinite(e)?e:null})(t);return null==e?I.wallTop:e+1.25*s},yBottom:z,wallThickness:6}),...R.map(t=>({id:t.id,shape:{type:"segment",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,thickness:Math.max(4,.42*s)},friction:.02,restitution:.01}))],"EventDropChart",{friction:.08}),initialSpawns:$,initialSpawnPacing:{pacing:"arrival",timeAccessor:t=>t.datum?.arrivalTime,timeScale:u},projectionRows:C.map((t,e)=>({label:`${w+e*i.size}-${w+(e+1)*i.size}`,value:t.value,secondary:t.secondary})),metadata:{kind:"event-drop",closedWindowCount:S,gutter:I.gutter,lidSegments:R,lateCount:C.reduce((t,e)=>t+e.secondary,0),plot:p.plot,windowPlot:I.windowPlot,watermarkValue:k,windowCount:v,windowSize:i.size,windowStart:w}}}function J(t={}){const e=(t.categories?.length?t.categories:["Intake","Review","Build","Ship"]).map(t=>(t+"").trim()).filter(Boolean),o=e.length?e:["Intake"],n=Math.max(o.length,Math.round(t.count??Math.max(48,12*o.length))),i=_(t.unitValue,1),a=U(t.seed??1),r=t.idPrefix??"mechanical-pile",s=o.map(()=>.65+.9*a()),l=s.reduce((t,e)=>t+e,0)||1,c=n-o.length,d=s.map(t=>t/l*c),u=d.map(t=>1+Math.floor(t));let p=n-u.reduce((t,e)=>t+e,0);const h=d.map((t,e)=>({index:e,fraction:t-Math.floor(t)})).sort((t,e)=>e.fraction-t.fraction);for(let t=0;p>0;t=(t+1)%h.length)u[h[t].index]+=1,p-=1;return o.map((t,e)=>({id:`${r}-${e}`,category:t,value:u[e]*i,mechanical:!0,unitCount:u[e],unitValue:i,share:u[e]/n}))}function tt(t){const{data:e,categoryAccessor:o,valueAccessor:n,unitValue:i,ballRadius:a,seed:s,size:l}=t,c=_(i,1),d=B(l),u=[],p=new Map,h=new Map,g=[];function m(t){let e=p.get(t);return null==e&&(e=u.length,u.push(t),p.set(t,e)),e}e.forEach((t,e)=>{m((X(t,e,o)??"unknown")+"")});const y=Math.max(1,u.length),f=function(t,e,o){const n=t.width/Math.max(1,e),i=Math.max(2,2*o),a=Math.min(.7*n,Math.max(3.2*i,i+8)),r=Math.max(1,Math.floor(a/i));return{laneWidth:n,tubeWidth:a,ballDiameter:i,perRow:r,centerX:e=>t.x+(e+.5)*n,pileHeight:t=>Math.ceil(Math.max(0,t)/r)*i}}(d.plot,y,a),x=Math.max(0,f.tubeWidth/2-a-1),b=u.map(()=>[]);e.forEach((t,e)=>{const i=(X(t,e,o)??"unknown")+"",r=m(i),s=n?V(X(t,e,n)):1,l=Math.max(0,Math.round((s??0)/c)),u=f.centerX(r);for(let o=0;l>o;o+=1){const n=h.get(i)??0,s=f.perRow>1?((f.perRow>1?n%f.perRow:0)/(f.perRow-1)*2-1)*x:0;h.set(i,n+1),b[r].push({id:`${(t.id??"pile-"+e)+""}-${o}`,x:u+s,y:d.plot.y+a+2,vx:(o%3-1)*a/2,vy:0,mass:1,shape:{type:"circle",radius:a},datum:{...t,category:i,unitIndex:o}})}});const w=b.reduce((t,e)=>Math.max(t,e.length),0);for(let t=0;w>t;t+=1)for(const e of b)e.length>t&&g.push(e[t]);const v=d.plot.y+d.plot.height,M=[...r({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],k=d.plot.y-400;for(let t=0;y>t;t+=1){const e=f.centerX(t);for(const o of[-1,1])M.push({id:`pile-tube-${t}-${0>o?"l":"r"}`,shape:{type:"aabb",x:e+o*f.tubeWidth/2,y:(k+v)/2,width:6,height:v-k}})}return{config:D(s,M,"PhysicsPileChart"),initialSpawns:g,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:u.map(t=>({label:t,value:h.get(t)??0}))}}import{scaleLinear as et}from"d3-scale";function ot(t){const{data:e,xAccessor:o,groupAccessor:n,radiusAccessor:i,pointRadius:a,seed:s,size:l,xExtent:c,collisionIterations:d,settle:u}=t,p=B(l),h=U(s),g=[],m=[],y=new Map;e.forEach((t,e)=>{const r=V(X(t,e,o));if(null==r)return;const s=n?(X(t,e,n)??"All")+"":"All",l=i?V(X(t,e,i)):null,c=W(null!=l&&l>0?l:a,2,18);!function(t){let e=y.get(t);null==e&&(e=m.length,m.push(t),y.set(t,e))}(s),g.push({datum:t,index:e,value:r,group:s,radius:c})});const f=g.map(t=>t.value),x=c?V(c[0]):null,b=c?V(c[1]):null,w=f.length?Math.min(...f):0,v=f.length?Math.max(...f):1;let M=x??w,k=b??v;if(M===k&&(M-=.5,k+=.5),M>k){const t=k;k=M,M=t}const S=Math.max(a,...g.map(t=>t.radius)),I=p.plot.x+S+8,A=p.plot.x+p.plot.width-S-8,P=et().domain([M,k]).range([I,A]),C=Math.max(1,m.length),$=Math.min(Math.max(28,3*S),p.plot.height/4),z=p.plot.y+$,R=Math.max(0,p.plot.y+p.plot.height-$-z),T=t=>{const e=y.get(t)??0;return 1===C?p.plot.y+.54*p.plot.height:z+e/(C-1)*R},L=new Map,j=g.map((t,e)=>{L.set(t.group,(L.get(t.group)??0)+1);const o=P(t.value),n=T(t.group),i=(h()-.5)*t.radius*1.6,a=(h()-.5)*t.radius*1.6;return{id:(t.datum.id??"collision-swarm-"+e)+"",x:u?o+i:W(o+(e%9-4)*t.radius*2.5,I,A),y:u?n+a:p.plot.y-18-e%12*t.radius,vx:u?0:22*(h()-.5),vy:u?0:24+18*h(),mass:1,shape:{type:"circle",radius:t.radius},datum:{...t.datum,xValue:t.value,group:t.group,radius:t.radius,targetX:o,targetY:n},springs:[{target:{type:"point",x:o,y:n},restLength:0,stiffness:34,damping:5.5}]}});return{config:D(s,r({x:p.plot.x,y:p.plot.y,width:p.plot.width,height:p.plot.height},{idPrefix:"collision-swarm",includeCeiling:!1,wallThickness:20,floorThickness:20}),"CollisionSwarmChart",{gravity:{x:0,y:0},cellSize:Math.max(24,4*S),collisionIterations:Math.max(1,Math.round(d??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:j,projectionRows:m.map(t=>({label:t,value:L.get(t)??0})),metadata:{kind:"collision-swarm",xExtent:[M,k],xRange:[I,A],groups:m.map(t=>({label:t,y:T(t),count:L.get(t)??0})),plot:p.plot}}}function nt(t){if(Array.isArray(t)&&t.length>=2){const e=V(t[0]),o=V(t[1]);return null!=e&&null!=o?{x:e,y:o}:null}if(t&&"object"==typeof t){const e=t,o=V(e.x),n=V(e.y);return null!=o&&null!=n?{x:o,y:n}:null}return null}function it(t){return Array.isArray(t)?t.map(nt).filter(t=>null!=t):[]}function at(t,e,o){return"normalized"===o?{x:e.plot.x+t.x*e.plot.width,y:e.plot.y+t.y*e.plot.height}:{x:W(t.x,e.plot.x,e.plot.x+e.plot.width),y:W(t.y,e.plot.y,e.plot.y+e.plot.height)}}function rt(t){let e=0;for(let o=1;t.length>o;o+=1)e+=Math.hypot(t[o].x-t[o-1].x,t[o].y-t[o-1].y);return e}function st(t,e){if(0===t.length)return{x:0,y:0};if(1===t.length)return{...t[0]};const o=W(e,0,1)*rt(t);let n=0;for(let e=1;t.length>e;e+=1){const i=t[e-1],a=t[e],r=Math.hypot(a.x-i.x,a.y-i.y);if(r>0){if(n+r>=o){const t=(o-n)/r;return{x:i.x+(a.x-i.x)*t,y:i.y+(a.y-i.y)*t}}n+=r}}return{...t[t.length-1]}}function lt(t,e){const o=st(t,Math.max(0,e-.02)),n=st(t,Math.min(1,e+.02)),i=n.x-o.x,a=n.y-o.y,r=Math.hypot(i,a)||1;return{x:i/r,y:a/r}}function ct(t){const{coordinateMode:e,flowSpeed:o,links:n,maxParticles:i,nodeIdAccessor:a,nodeXAccessor:s,nodeYAccessor:l,nodes:c,particleRadius:d,particleRate:u,pathAccessor:p,pathConstraint:h="path",reducedMotion:g,seed:m,size:y,sourceAccessor:f,targetAccessor:x,throughputAccessor:b}=t,w=B(y),v=U(m),M=new Map,k=new Map,S=[];function I(t){if(t&&"object"==typeof t){const e=t;if("function"==typeof a){const t=a(e,0);if(null!=t)return t+""}if("string"==typeof a&&null!=e[a])return e[a]+"";if(null!=e.id)return e.id+""}return(t??"unknown")+""}c.forEach((t,e)=>{const o=(X(t,e,a)??t.id??e)+"",n=V(X(t,e,s)),i=V(X(t,e,l));if(null!=n&&null!=i){const t={x:n,y:i};M.set(o,t),S.push(t)}k.set(o,(t.label??t.name??o)+"")});const A=[];n.forEach((t,e)=>{const o=I(X(t,e,f)),n=I(X(t,e,x)),i=Math.max(0,V(X(t,e,b))??0),a=it(p?X(t,e,p):void 0),r=a.length?a:it(t.path??t.points??t.route);r.forEach(t=>S.push(t)),A.push({id:(t.id??`physical-flow-${o}-${n}-${e}`)+"",link:t,index:e,source:o,target:n,throughput:i,rawPath:r})});const P=($=S,"normalized"===(C=e)||"pixels"===C?C:$.length>0&&$.every(t=>!(0>t.x||t.x>1||0>t.y||t.y>1))?"normalized":"pixels");var C,$;const z=new Map;for(const[t,e]of M)z.set(t,at(e,w,P));const R=[];for(const t of A){let e=t.rawPath.map(t=>at(t,w,P));if(2>e.length){const o=z.get(t.source),n=z.get(t.target);o&&n&&(e=[o,n])}else z.has(t.source)||z.set(t.source,e[0]),z.has(t.target)||z.set(t.target,e[e.length-1]);e.length>=2&&t.throughput>0&&(k.has(t.source)||k.set(t.source,t.source),k.has(t.target)||k.set(t.target,t.target),R.push({...t,path:e,packetCount:0}))}const T=_(u,.12),L=Math.max(1,Math.round(i)),j=R.map(t=>Math.max(1,Math.round(t.throughput*T))),E=j.reduce((t,e)=>t+e,0),Y=E>L?L/E:1;R.forEach((t,e)=>{t.packetCount=Math.max(1,Math.floor(j[e]*Y))});let N=R.reduce((t,e)=>t+e.packetCount,0);for(;N>L;){const t=R.reduce((t,e,o)=>e.packetCount>1&&(-1===t||e.packetCount>R[t].packetCount)?o:t,-1);if(-1===t)break;R[t].packetCount-=1,N-=1}const F=new Map,G=new Map,Z=[],K=_(o,90),q=_(d,4);R.forEach((t,e)=>{F.set(t.target,(F.get(t.target)??0)+t.throughput),G.set(t.source,(G.get(t.source)??0)+t.throughput);const o=rt(t.path);for(let n=0;t.packetCount>n;n+=1){const i=(n+.5)/t.packetCount,a=g?i:W(.12+.84*i+.04*(v()-.5),.04,.98),r=g?a:Math.max(0,a-(.18+.12*v())),s=st(t.path,r),l=st(t.path,a),c=lt(t.path,r),d={x:-c.y,y:c.x},u=(v()-.5)*q*1.5;Z.push({id:`${t.id}-packet-${n}`,x:s.x+d.x*u,y:s.y+d.y*u,vx:g?0:c.x*K+10*(v()-.5),vy:g?0:c.y*K+10*(v()-.5),mass:.8,spawnAt:g?0:.04*e+n/32,shape:{type:"circle",radius:q},datum:{...t.link,source:t.source,target:t.target,throughput:t.throughput,packetIndex:n,packetCount:t.packetCount,routeProgress:a,flowPath:t.path,flowPathLength:o,flowRouteId:t.id,flowSpeed:K,sourceLabel:k.get(t.source)??t.source,targetLabel:k.get(t.target)??t.target},springs:"none"!==h&&g?[{target:{type:"point",x:l.x,y:l.y},restLength:.7*q,stiffness:26,damping:4.25}]:void 0})}});const H=Math.max(18,5*q),Q=Array.from(z,([t,e])=>({nodeId:t,label:k.get(t)??t,sensorId:"physical-flow-node-"+O(t),point:e})),J=Q.map(t=>({id:t.sensorId,sensor:!0,shape:{type:"aabb",x:t.point.x,y:t.point.y,width:H,height:H}})),tt=Object.fromEntries(Q.map(t=>[t.sensorId,{binId:t.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),et=D(m,[...r({x:w.plot.x,y:w.plot.y,width:w.plot.width,height:w.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...J],"PhysicalFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*q),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});et.bodyLimit=L,et.eviction="oldest",et.observation={...et.observation,sensors:tt};const ot=Array.from(z,([t,e])=>({id:t,label:k.get(t)??t,x:e.x,y:e.y,sensorId:"physical-flow-node-"+O(t),incoming:F.get(t)??0,outgoing:G.get(t)??0})),nt=R.map(t=>({id:t.id,source:t.source,target:t.target,sourceLabel:k.get(t.source)??t.source,targetLabel:k.get(t.target)??t.target,throughput:t.throughput,packetCount:t.packetCount,path:t.path}));return{config:et,initialSpawns:Z,projectionRows:ot.filter(t=>t.incoming>0||t.outgoing>0).map(t=>({label:t.label,value:t.incoming,secondary:t.outgoing})),metadata:{kind:"physical-flow",coordinateMode:P,particleCount:Z.length,totalThroughput:R.reduce((t,e)=>t+e.throughput,0),plot:w.plot,nodes:ot,links:nt}}}function dt(t,e=12){return"number"==typeof t?{x:t,y:0}:t&&"object"==typeof t?{x:Number.isFinite(t.x)?Number(t.x):e,y:Number.isFinite(t.y)?Number(t.y):0}:{x:e,y:0}}function ut(t){const e=t.stages;if(!e.length)throw Error("buildProcessFlowPhysics requires at least one stage");const o=t.size,r=B(o),s=W(t.ballRadius??6,2,18),g=t.seed??1,m=U(g),y=t.idAccessor,f=t.stageAccessor??"stage",x=t.groupBy,b=t.groupLabelAccessor,w=t.workAccessor,v=t.radiusAccessor,M=t.groupCompletion??(x?"allAbsorbed":"none"),k=t.springStiffness??.28,S=t.springDamping??.72,I=!0===t.settle,A=e.map(t=>({id:t.id,label:t.label??t.id,description:t.description,share:t.share})),P=p({width:o[0],height:o[1],shape:"lane",padX:Math.max(28,r.plot.x),padY:Math.max(36,r.plot.y+8),stages:A,idPrefix:"process-flow",includeMembraneRegions:!1,friction:.48,restitution:.14}),C=new Map(P.stages.map((t,e)=>[t.id,e])),$=new Map(P.stages.map(t=>[t.id,t])),z=P.stages[0].id,R=P.stages[0],T=new Set(e.filter(t=>t.absorb).map(t=>t.id)),L=e.map(t=>{const e=$.get(t.id)??R;return function(t,e){const o={id:"process-stage-"+t.id,label:t.label??t.id,description:t.description,x:e.x,y:e.y,width:Math.max(12,.92*e.width),height:Math.max(40,.88*e.height),semanticItem:!1,attributes:{stageId:t.id}};if(t.absorb)return n({...o,kind:t.kind??"sink",force:dt(t.force,28),damping:t.damping??.04,charge:"absorbed",attributes:{...o.attributes,primitive:"absorb"}});if(t.portal){const e=t.portal.force??t.force??{x:-40,y:0};return d({...o,kind:t.kind??"force-field",force:dt(e,-40),damping:t.damping??.1,targetStage:t.portal.targetStageId,attributes:{...o.attributes,primitive:"portal",targetStage:t.portal.targetStageId}})}if(t.capacity){const e=Math.max(.1,t.capacity.unitsPerSecond);return a({...o,kind:t.kind??"force-field",capacity:e,unitsPerSecond:e,force:dt(t.force,10+.8*e),damping:t.damping??Math.max(.04,.32-.01*e),attributes:{...o.attributes,unitAccessor:t.capacity.unitAccessor,reviewerCapacity:e}})}if(t.pressure){const e="object"==typeof t.pressure&&t.pressure?t.pressure:{};return u({...o,kind:t.kind??"membrane",pressure:e.pressure,occupancy:e.occupancy,baseDamping:e.baseDamping??t.damping??.1,dampingPerUnit:e.dampingPerUnit??.1,energyPerUnit:e.energyPerUnit??0,force:dt(t.force,8),attributes:{...o.attributes,primitive:"pressureField"}})}return null!=t.force||null!=t.damping?h({...o,kind:t.kind??"force-field",force:dt(t.force,14),damping:t.damping??.02,attributes:{...o.attributes,primitive:"routeSurface"}}):l({...o,kind:t.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...o.attributes,primitive:"forceField"}})}(t,{x:e.x,y:P.midY,width:e.width,height:P.bottomY-P.topY})});L.unshift(h({id:"process-flow-route",label:"process route",description:"Baseline conveyor along the process lane.",x:(P.left+P.right)/2,y:P.midY,width:P.right-P.left,height:P.bottomY-P.topY-12,force:8,damping:.012,semanticItem:!1}));const j=new Map;for(const t of P.stages)j.set(t.id,0);const E=[];t.data.forEach((t,e)=>{const o=(y?X(t,e,y)??t.id??"process-flow-"+e:t.id??"process-flow-"+e)+"",n=(X(t,e,f)??z)+"",i=C.has(n)?n:z;j.set(i,(j.get(i)??0)+1);const a=x?(X(t,e,x)??"")+"":void 0,r=a&&b?(X(t,e,b)??a)+"":a,l=w?V(X(t,e,w))??1:1,c=v?V(X(t,e,v)):null,d=W(null!=c&&c>0?c:s,2,18);E.push({datum:t,id:o,stageId:i,groupId:a||void 0,groupLabel:r||void 0,work:l,radius:d,index:e})});const Y=new Map,N=new Map;for(const t of E){if(!t.groupId)continue;const e=Y.get(t.groupId)??[];e.push(t.id),Y.set(t.groupId,e),t.groupLabel&&N.set(t.groupId,t.groupLabel)}const F=W(t.groupAnchorAlong??.55,.15,.9),D=P.left+(P.right-P.left)*F,_=Array.from(Y.keys()),O=_.map((t,o)=>{const n=Y.get(t)??[],a=_.length>1?P.topY+28+o/Math.max(1,_.length-1)*(P.bottomY-P.topY-56):P.midY;return i({id:t,label:N.get(t)??t,bodyIds:n,anchor:{x:D,y:a},x:D,y:a,completion:"allAbsorbed"===M?{mode:"allMembersAbsorbed",targetZone:e.find(t=>t.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),G=E.filter(t=>T.has(t.stageId)).map(t=>t.id),Z=c(O,G),K=new Map(O.map(t=>[t.id,t])),q=E.map((t,e)=>{const o=$.get(t.stageId)??R,n=o.x+(m()-.5)*Math.min(24,.2*o.width),i=P.boundaryY(n,"top")+t.radius+10,a=P.boundaryY(n,"bottom")-t.radius-10,r=a>i?i+m()*Math.max(1,a-i):P.midY,s=I?n:P.left+18+e%7*4,l=I?r:P.midY+(m()-.5)*(P.bottomY-P.topY)*.35,c=[{target:{type:"point",x:n,y:r},restLength:.45*t.radius,stiffness:k,damping:S}];if(t.groupId){const e=K.get(t.groupId);e?.anchor&&!T.has(t.stageId)&&c.push({target:{type:"point",x:e.anchor.x,y:e.anchor.y},restLength:e.tether?.restLength??22,stiffness:e.tether?.stiffness??.05,damping:.8})}return{id:t.id,x:s,y:l,vx:I?0:40+40*m(),vy:I?0:20*(m()-.5),mass:1,shape:{type:"circle",radius:t.radius},spawnAt:I?0:.03*e,springs:c,datum:{...t.datum,id:t.id,stage:t.stageId,groupId:t.groupId,groupLabel:t.groupLabel,work:t.work,__processFlow:!0}}}),H={kernel:{seed:g,gravity:{x:t.gravityX??22,y:t.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:P.colliders,fixedDt:1/60,maxSubsteps:8},Q=P.stages.map(t=>({label:t.label??t.id,value:j.get(t.id)??0})),J=e.map(t=>{const e=$.get(t.id)??R;return{id:t.id,label:t.label??t.id,x:e.x,width:e.width,count:j.get(t.id)??0,capacity:t.capacity?.unitsPerSecond,absorb:!0===t.absorb,portalTarget:t.portal?.targetStageId}});return{config:H,initialSpawns:q,initialSpawnPacing:I?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:Q,metadata:{kind:"process-flow",plot:r.plot,volume:P,stages:J,groups:O,groupCompletion:Z,regionEffects:L}}}function pt(t,e){const o=e.config??{},n=(e.sensors??[]).map(t=>({...t,sensor:!0})),i=[...e.colliders??[],...n],a=[...t.colliders??[],...o.colliders??[],...i];return{...t,...o,observation:{...t.observation,...o.observation},...a.length>0&&{colliders:a}}}function ht(t){const e=function(t,e,o){const n=t?.observation;return{...t,observation:{...n,chartId:e??n?.chartId??"physics-custom",chartType:n?.chartType??"PhysicsCustomChart",onObservation:o??n?.onObservation}}}(t.config,t.chartId,t.onObservation),n=m(t.colorScheme,t.themeCategorical,f),i=B(t.size),a={data:t.data,scales:{x:Y().domain(t.xExtent??[0,1]).range([i.plot.x,i.plot.x+i.plot.width]),y:Y().domain(t.yExtent??[0,1]).range([i.plot.y+i.plot.height,i.plot.y])},dimensions:i,theme:{semantic:t.semantic,categorical:[...n]},resolveColor:g(n,t.colorScheme),config:t.layoutConfig??{},world:new o(e)},r=t.skipLayout?{}:t.layout(a)??{},s=function(t,e){if(!e?.length)return t;const o=new Map;for(const t of e){const{bodyId:e,...n}=t,i=o.get(e)??[];i.push(n),o.set(e,i)}return t.map(t=>{const e=o.get(t.id);return e?.length?{...t,springs:[...t.springs??[],...e]}:t})}([...r.initialSpawns??r.bodies??[]],r.constraints);return{config:pt(e,r),context:a,initialSpawnPacing:r.initialSpawnPacing,initialSpawns:s,result:r}}export{F as styleFromColorAccessor,Z as generateGaltonMechanicalSamples,K as buildGaltonBoardPhysics,Q as buildEventDropPhysics,J as generatePhysicsPileMechanicalSamples,tt as buildPhysicsPile,ot as buildCollisionSwarmPhysics,ct as buildPhysicalFlowPhysics,ut as buildProcessFlowPhysics,ht as resolveCustomLayout,b as buildPhysicsSettledProjection,w as buildPhysicsNavigationTree,v as physicsObservationAnnouncement,k as buildPhysicsSettledEvidence,P as physicsBodyToXYSceneNode,C as physicsBodiesToXYSceneNodes,$ as buildPhysicsSettledScene,E as renderPhysicsSettledSVG};