semiotic 3.8.2 → 3.8.3

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 (113) hide show
  1. package/CLAUDE.md +1 -1
  2. package/README.md +34 -33
  3. package/ai/schema.json +1 -1
  4. package/ai/surface-manifest.json +1 -1
  5. package/ai/system-prompt.md +1 -1
  6. package/dist/{chunk-chunk-C6EJ4IOD.module.min.js → chunk-chunk-2CCFBTQC.module.min.js} +1 -1
  7. package/dist/chunk-chunk-2RXP3FS3.module.min.js +1 -0
  8. package/dist/chunk-chunk-4TMZXLCR.module.min.js +1 -0
  9. package/dist/{chunk-chunk-H4PPRW6N.module.min.js → chunk-chunk-5APBQXZA.module.min.js} +1 -1
  10. package/dist/{chunk-chunk-NO4MCQVD.module.min.js → chunk-chunk-5RKXZQ2P.module.min.js} +1 -1
  11. package/dist/chunk-chunk-6HSGDMTA.module.min.js +2 -0
  12. package/dist/{chunk-chunk-7LHMKRKE.module.min.js → chunk-chunk-7FW6EGLP.module.min.js} +1 -1
  13. package/dist/{chunk-chunk-RH5TSQPH.module.min.js → chunk-chunk-7OEOSCBP.module.min.js} +1 -1
  14. package/dist/{chunk-chunk-FAKO3RGQ.module.min.js → chunk-chunk-A63CTACR.module.min.js} +1 -1
  15. package/dist/chunk-chunk-ANYDWOZF.module.min.js +1 -0
  16. package/dist/{chunk-chunk-ZLKRTF5N.module.min.js → chunk-chunk-AZJUDQRM.module.min.js} +1 -1
  17. package/dist/{chunk-chunk-W3DB2MN4.module.min.js → chunk-chunk-B6V35LMY.module.min.js} +1 -1
  18. package/dist/chunk-chunk-BOSVL645.module.min.js +2 -0
  19. package/dist/chunk-chunk-EMO5NUGE.module.min.js +1 -0
  20. package/dist/chunk-chunk-F25UA5HT.module.min.js +1 -0
  21. package/dist/chunk-chunk-FRIO6MCV.module.min.js +1 -0
  22. package/dist/{chunk-chunk-T27ZEV6A.module.min.js → chunk-chunk-GWSWSPXN.module.min.js} +1 -1
  23. package/dist/chunk-chunk-I6C3KR5H.module.min.js +2 -0
  24. package/dist/chunk-chunk-IP2UE74X.module.min.js +1 -0
  25. package/dist/chunk-chunk-J5RL6GXU.module.min.js +2 -0
  26. package/dist/chunk-chunk-JNCHKRIR.module.min.js +2 -0
  27. package/dist/{chunk-chunk-Z5KXAVQD.module.min.js → chunk-chunk-L3H6DQCR.module.min.js} +1 -1
  28. package/dist/{chunk-chunk-5WEFWNUW.module.min.js → chunk-chunk-M7VYYHCE.module.min.js} +1 -1
  29. package/dist/chunk-chunk-MC35ILYP.module.min.js +2 -0
  30. package/dist/{chunk-chunk-2VUEY5TH.module.min.js → chunk-chunk-N72SWNBV.module.min.js} +1 -1
  31. package/dist/chunk-chunk-OBQRFTIL.module.min.js +2 -0
  32. package/dist/chunk-chunk-OQTLSTGI.module.min.js +2 -0
  33. package/dist/{chunk-chunk-2UN3ANRN.module.min.js → chunk-chunk-SA3D43RA.module.min.js} +1 -1
  34. package/dist/chunk-chunk-SANERMIZ.module.min.js +2 -0
  35. package/dist/{chunk-chunk-DNY43POY.module.min.js → chunk-chunk-UHSZEB74.module.min.js} +1 -1
  36. package/dist/{chunk-chunk-CYIML3AV.module.min.js → chunk-chunk-XQYVEKEJ.module.min.js} +1 -1
  37. package/dist/{chunk-chunk-27HVVXS6.module.min.js → chunk-chunk-Y6AXCRVO.module.min.js} +1 -1
  38. package/dist/components/charts/custom/XYCustomChart.d.ts +3 -0
  39. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +5 -6
  40. package/dist/components/charts/realtime/temporalHistogramConfig.d.ts +11 -0
  41. package/dist/components/charts/shared/areaSeriesData.d.ts +15 -0
  42. package/dist/components/charts/shared/chartMode.d.ts +67 -0
  43. package/dist/components/charts/shared/colorUtils.d.ts +8 -0
  44. package/dist/components/charts/shared/geoStyleDefaults.d.ts +3 -0
  45. package/dist/components/charts/shared/hooks.d.ts +13 -80
  46. package/dist/components/charts/shared/useChartSetup.d.ts +3 -0
  47. package/dist/components/charts/shared/useCustomChartSetup.d.ts +3 -0
  48. package/dist/components/charts/shared/useXYLineStyle.d.ts +3 -2
  49. package/dist/components/charts/shared/xyLineStyle.d.ts +21 -0
  50. package/dist/components/charts/xy/LineChart.d.ts +3 -0
  51. package/dist/components/legendLayout.d.ts +31 -0
  52. package/dist/components/server/serverChartConfigShared.d.ts +29 -0
  53. package/dist/components/server/serverChartConfigs.d.ts +2 -13
  54. package/dist/components/server/serverChartConfigsXY.d.ts +3 -0
  55. package/dist/components/server/serverGaugeOverlay.d.ts +28 -0
  56. package/dist/components/server/staticLegend.d.ts +7 -1
  57. package/dist/components/server/staticSVGChrome.d.ts +57 -0
  58. package/dist/components/stream/GeoPipelineStore.d.ts +2 -0
  59. package/dist/components/stream/GeoSVGOverlay.d.ts +2 -0
  60. package/dist/components/stream/SceneToSVG.d.ts +8 -6
  61. package/dist/components/stream/SceneToSVGGeo.d.ts +10 -0
  62. package/dist/components/stream/SceneToSVGNetwork.d.ts +12 -0
  63. package/dist/components/stream/canvasBackground.d.ts +7 -0
  64. package/dist/components/stream/networkTypes.d.ts +2 -4
  65. package/dist/components/stream/renderBackend.d.ts +14 -0
  66. package/dist/components/stream/sceneToSVGShared.d.ts +51 -0
  67. package/dist/components/types/legendTypes.d.ts +16 -3
  68. package/dist/geo.min.js +1 -1
  69. package/dist/geo.module.min.js +1 -1
  70. package/dist/network.min.js +1 -1
  71. package/dist/network.module.min.js +1 -1
  72. package/dist/ordinal.min.js +1 -1
  73. package/dist/ordinal.module.min.js +1 -1
  74. package/dist/physics.min.js +1 -1
  75. package/dist/physics.module.min.js +1 -1
  76. package/dist/realtime.min.js +1 -1
  77. package/dist/realtime.module.min.js +1 -1
  78. package/dist/semiotic-ai-core.min.js +1 -1
  79. package/dist/semiotic-ai-core.module.min.js +1 -1
  80. package/dist/semiotic-ai.min.js +1 -1
  81. package/dist/semiotic-ai.module.min.js +1 -1
  82. package/dist/semiotic-experimental.min.js +1 -1
  83. package/dist/semiotic-experimental.module.min.js +1 -1
  84. package/dist/semiotic-realtime-core.min.js +1 -1
  85. package/dist/semiotic-realtime-core.module.min.js +1 -1
  86. package/dist/semiotic-recipes-core.module.min.js +1 -1
  87. package/dist/semiotic-recipes.module.min.js +1 -1
  88. package/dist/semiotic-server-edge.min.js +1 -1
  89. package/dist/semiotic-server-edge.module.min.js +1 -1
  90. package/dist/semiotic-server-node.min.js +1 -1
  91. package/dist/semiotic-server-node.module.min.js +1 -1
  92. package/dist/semiotic-utils-core.module.min.js +1 -1
  93. package/dist/semiotic-utils.module.min.js +1 -1
  94. package/dist/semiotic.min.js +1 -1
  95. package/dist/semiotic.module.min.js +1 -1
  96. package/dist/server.min.js +1 -1
  97. package/dist/server.module.min.js +1 -1
  98. package/dist/xy.min.js +1 -1
  99. package/dist/xy.module.min.js +1 -1
  100. package/package.json +1 -1
  101. package/dist/chunk-chunk-6F6GEAQU.module.min.js +0 -1
  102. package/dist/chunk-chunk-BHYTYMY2.module.min.js +0 -2
  103. package/dist/chunk-chunk-E7MIQX7D.module.min.js +0 -2
  104. package/dist/chunk-chunk-ES4DCG3L.module.min.js +0 -1
  105. package/dist/chunk-chunk-IFYPMWKY.module.min.js +0 -1
  106. package/dist/chunk-chunk-L6D3I3V7.module.min.js +0 -2
  107. package/dist/chunk-chunk-ODUZEEBH.module.min.js +0 -2
  108. package/dist/chunk-chunk-P6UBCMSQ.module.min.js +0 -2
  109. package/dist/chunk-chunk-STZFFTAN.module.min.js +0 -2
  110. package/dist/chunk-chunk-U3AGQ5EF.module.min.js +0 -2
  111. package/dist/chunk-chunk-WDIN4LRC.module.min.js +0 -1
  112. package/dist/chunk-chunk-XOYX77KF.module.min.js +0 -2
  113. package/dist/chunk-chunk-ZTNVDWAK.module.min.js +0 -2
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{DEFAULT_HIT_RADIUS as m,hitTargetPoint as n,hitTargetRect as u}from"./chunk-chunk-J3XWETBJ.module.min.js";import{AreaChart as o,BubbleChart as c,CandlestickChart as h,ConnectedScatterplot as i,DifferenceChart as k,Heatmap as r,LineChart as e,MinimapChart as t,MultiAxisLineChart as p,QuadrantChart as s,Scatterplot as d,ScatterplotMatrix as j,StackedAreaChart as l,XYCustomChart as E}from"./chunk-chunk-U3AGQ5EF.module.min.js";import"./chunk-chunk-YCQYG6J5.module.min.js";import"./chunk-chunk-JCG72SGW.module.min.js";import"./chunk-chunk-BHYTYMY2.module.min.js";import{StreamXYFrame_default as Y}from"./chunk-chunk-L6D3I3V7.module.min.js";import"./chunk-chunk-CYIML3AV.module.min.js";import"./chunk-chunk-ZLKRTF5N.module.min.js";import"./chunk-chunk-5WEFWNUW.module.min.js";import"./chunk-chunk-XOYX77KF.module.min.js";import"./chunk-chunk-FAKO3RGQ.module.min.js";import{useCustomLayoutSelection as W}from"./chunk-chunk-5UKL5W76.module.min.js";import{composeStyleRules as f,makeRuleValueResolver as F,makeXYRuleContext as O,matchesThreshold as U,resolveStyleRules as C,ruleMatches as G}from"./chunk-chunk-EMO5NUGE.module.min.js";import{hatchFillId as J,hatchPatternDef as X,isHatchFill as Z,resolveResponsiveRules as B,resolveSvgFill as K,responsiveRuleMatches as L}from"./chunk-chunk-ODUZEEBH.module.min.js";import"./chunk-chunk-JJ2OOIET.module.min.js";import"./chunk-chunk-WCX6U47H.module.min.js";import{glyphExtent as N,glyphPlacement as T}from"./chunk-chunk-KTWEBFMX.module.min.js";import"./chunk-chunk-ZCNBUZPL.module.min.js";import"./chunk-chunk-YHNZCPOZ.module.min.js";export{o as AreaChart,c as BubbleChart,h as CandlestickChart,i as ConnectedScatterplot,m as DEFAULT_HIT_RADIUS,k as DifferenceChart,r as Heatmap,e as LineChart,t as MinimapChart,p as MultiAxisLineChart,s as QuadrantChart,d as Scatterplot,j as ScatterplotMatrix,l as StackedAreaChart,Y as StreamXYFrame,E as XYCustomChart,f as composeStyleRules,N as glyphExtent,T as glyphPlacement,J as hatchFillId,X as hatchPatternDef,n as hitTargetPoint,u as hitTargetRect,Z as isHatchFill,F as makeRuleValueResolver,O as makeXYRuleContext,U as matchesThreshold,B as resolveResponsiveRules,C as resolveStyleRules,K as resolveSvgFill,L as responsiveRuleMatches,G as ruleMatches,W as useCustomLayoutSelection};
2
+ import{DEFAULT_HIT_RADIUS as m,hitTargetPoint as n,hitTargetRect as u}from"./chunk-chunk-J3XWETBJ.module.min.js";import{AreaChart as o,BubbleChart as c,CandlestickChart as h,ConnectedScatterplot as i,DifferenceChart as k,Heatmap as r,LineChart as e,MinimapChart as t,MultiAxisLineChart as p,QuadrantChart as s,Scatterplot as d,ScatterplotMatrix as j,StackedAreaChart as l,XYCustomChart as C}from"./chunk-chunk-MC35ILYP.module.min.js";import"./chunk-chunk-YCQYG6J5.module.min.js";import"./chunk-chunk-JCG72SGW.module.min.js";import"./chunk-chunk-I6C3KR5H.module.min.js";import{StreamXYFrame_default as J}from"./chunk-chunk-J5RL6GXU.module.min.js";import"./chunk-chunk-XQYVEKEJ.module.min.js";import"./chunk-chunk-AZJUDQRM.module.min.js";import"./chunk-chunk-M7VYYHCE.module.min.js";import"./chunk-chunk-OQTLSTGI.module.min.js";import"./chunk-chunk-A63CTACR.module.min.js";import{useCustomLayoutSelection as E}from"./chunk-chunk-5UKL5W76.module.min.js";import{composeStyleRules as Y,makeRuleValueResolver as f,makeXYRuleContext as G,matchesThreshold as T,resolveStyleRules as M,ruleMatches as U}from"./chunk-chunk-EMO5NUGE.module.min.js";import{hatchFillId as X,hatchPatternDef as H,isHatchFill as L,resolveResponsiveRules as O,resolveSvgFill as W,responsiveRuleMatches as Z}from"./chunk-chunk-6HSGDMTA.module.min.js";import"./chunk-chunk-JJ2OOIET.module.min.js";import"./chunk-chunk-WCX6U47H.module.min.js";import{glyphExtent as A,glyphPlacement as I}from"./chunk-chunk-KTWEBFMX.module.min.js";import"./chunk-chunk-ZCNBUZPL.module.min.js";import"./chunk-chunk-YHNZCPOZ.module.min.js";export{o as AreaChart,c as BubbleChart,h as CandlestickChart,i as ConnectedScatterplot,m as DEFAULT_HIT_RADIUS,k as DifferenceChart,r as Heatmap,e as LineChart,t as MinimapChart,p as MultiAxisLineChart,s as QuadrantChart,d as Scatterplot,j as ScatterplotMatrix,l as StackedAreaChart,J as StreamXYFrame,C as XYCustomChart,Y as composeStyleRules,A as glyphExtent,I as glyphPlacement,X as hatchFillId,H as hatchPatternDef,n as hitTargetPoint,u as hitTargetRect,L as isHatchFill,f as makeRuleValueResolver,G as makeXYRuleContext,T as matchesThreshold,O as resolveResponsiveRules,M as resolveStyleRules,W as resolveSvgFill,Z as responsiveRuleMatches,U as ruleMatches,E as useCustomLayoutSelection};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semiotic",
3
- "version": "3.8.2",
3
+ "version": "3.8.3",
4
4
  "mcpName": "io.github.nteract/semiotic",
5
5
  "description": "Verified generative visualization for React and agents, with deterministic chart validation, repair, rendering evidence, and MCP.",
6
6
  "main": "dist/semiotic.min.js",
@@ -1 +0,0 @@
1
- import{annotationActivationProps as e,defaultTooltipStyle as t,extractAllRows as n}from"./chunk-chunk-255KDHW5.module.min.js";import{AnnotationLabel as r,SemioticAnnotation as i,applyAnnotationEmphasis as o,isGradientLegendConfig as l,isLegendConfig as a,reserveFrameChromeMargin as s,resolveAnimateConfig as c}from"./chunk-chunk-ES4DCG3L.module.min.js";import{useReducedMotion as d}from"./chunk-chunk-XEVJDUTH.module.min.js";import{isHatchFill as u,resolveHatchCanvasPattern as h,resolveSvgFill as f}from"./chunk-chunk-2WVCH4PL.module.min.js";import{FrameRuntime as m,isInBounds as p,resolveAnchoredPosition as g,resolveX as y,resolveY as b}from"./chunk-chunk-NO4MCQVD.module.min.js";import{getMinMax as x}from"./chunk-chunk-JJ2OOIET.module.min.js";import{clearCSSColorCache as v,resolveCSSColor as w}from"./chunk-chunk-QRIBHZYW.module.min.js";import{useThemeSelector as k}from"./chunk-chunk-DSNGDNJY.module.min.js";import{memo as S,useEffect as M,useRef as C}from"react";var $={sceneGeometry:0,layout:0,domain:0};function R(e){const{domain:t,layout:n,sceneGeometry:r}=e.revisions;return{domain:t,layout:n,sceneGeometry:r}}function z(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 j="production"!==process.env.NODE_ENV,D={revisions:$,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},A=class{constructor(e="scene host"){this.hostName=e,this.lastConsumed=$,this.lastObserved=$,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}observeUpdateResult(e){j&&(this.lastObserved=z(this.lastObserved,R(e)))}beforeCompute(e,t){if(!j)return D;const n=z(R(e),this.lastObserved),r=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),i=!((o=n).sceneGeometry===(l=this.lastConsumed).sceneGeometry&&o.layout===l.layout&&o.domain===l.domain);var o,l;return{revisions:n,signature:r,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:i,warnUnconsumed:!t&&i&&this.lastUnconsumedWarning!==r}}afterCompute(e,t,n){if(j){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 I(e){return C(new A(e))}function N(e,t,n,r=!1,i=!1){const o=e.beforeCompute(t.getLastUpdateResult(),r);n(),e.afterCompute(o,!0,i)}var F=S(function({store:e,diagnostics:t}){return M(()=>{const n=()=>t.observeUpdateResult(e.getUpdateSnapshot());return n(),e.subscribeUpdateResult(n)},[t,e]),null});import{useEffect as W,useLayoutEffect as B,useRef as E,useState as O,useSyncExternalStore as G}from"react";var H="undefined"!=typeof window?B:W;function T(){const[e,t]=O(!1);return H(()=>{t(!0)},[]),e}var L=()=>()=>{},U=()=>!1,q=()=>!0;function P(){const e=G(L,U,q);return E(e).current}import{jsx as V}from"react/jsx-runtime";var Y={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function X({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 V("div",{"aria-live":"polite","aria-atomic":"true",style:Y,children:t})}import*as J from"react";import*as K from"react";import{jsx as Q}from"react/jsx-runtime";var Z=K.createContext(null);function _(){return K.useContext(Z)}import{jsx as ee,jsxs as te}from"react/jsx-runtime";function ne(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=[],i={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},o=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],l=Object.keys(n).sort((e,t)=>{const n=o.indexOf(e),r=o.indexOf(t);return(-1===n?999:n)-(-1===r?999:r)});for(const e of l)r.push(`${n[e]} ${i[e]||e}`);return`${t}, ${r.join(", ")}`}function re(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 ie=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},oe="semiotic-accessible-data-table",le=oe+" semiotic-accessible-data-table-hidden",ae=oe+" semiotic-accessible-data-table-visible",se=ae+" semiotic-accessible-data-table-network",ce={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"},de={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},ue={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)"},he={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},fe={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))"},me={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},pe={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},ge={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 ye({scene:e,chartType:t,tableId:r,chartTitle:i}){const[o,l]=J.useState(!1),[a,s]=J.useState(5),c=_(),d=c?.visible??!1,u=o||d,h=J.useRef(null),f=i?"Data summary for "+i:r?`Data summary for ${t} ${r}`:"Data summary for "+t;J.useEffect(()=>{u||s(5)},[u]);const m=J.useCallback(e=>{e.target===e.currentTarget&&(o||d||l(!0))},[o,d]),p=J.useCallback(e=>{d||h.current?.contains(e.relatedTarget)||l(!1)},[d]);if(!e||0===e.length)return r?ee("span",{id:r,tabIndex:-1,style:Y}):null;if(!u)return ee("div",{id:r,className:le,tabIndex:-1,onFocus:m,style:Y,role:"region","aria-label":f,children:te("button",{type:"button",onClick:()=>l(!0),children:["View data summary (",e.length," elements)"]})});const g=n(e),y=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=[],i=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&&i.add(e+""))}if(t.length>0){let e=t[0],i=t[0],o=0;for(const n of t)e>n&&(e=n),n>i&&(i=n),o+=n;n.push({name:r,count:t.length,numeric:!0,min:e,max:i,mean:o/t.length})}else if(i.size>0){const e=Array.from(i);n.push({name:r,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(g),b=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${ie(e.min)} to ${ie(e.max)}, mean ${ie(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(" ")}(g.length,y),x=Math.min(a,g.length),v=g.slice(0,x),w=g.length-x,k=new Set;for(const e of v)for(const t of Object.keys(e.values))k.add(t);const S=Array.from(k);return te("div",{ref:h,id:r,className:ae,tabIndex:-1,onBlur:p,style:ce,role:"region","aria-label":f,children:[ee("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{d&&c&&c.setVisible(!1),l(!1)},"aria-label":"Close data summary",style:ue,children:"×"}),ee("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:de,children:b}),te("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+t,style:he,children:[ee("caption",{className:"semiotic-accessible-data-table-caption",style:pe,children:w>0?`First ${x} of ${g.length} data points`:`All ${g.length} data points`}),ee("thead",{children:te("tr",{children:[ee("th",{style:fe,children:"type"}),S.map(e=>ee("th",{style:fe,children:e},e))]})}),ee("tbody",{children:v.map((e,t)=>te("tr",{children:[ee("td",{style:me,children:e.label}),S.map(t=>{return ee("td",{style:me,children:(n=e.values[t],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":ie(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},t);var n})]},t))})]}),w>0&&te("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>s(e=>e+25),style:ge,children:["Show ",Math.min(25,w)," more"," ",1===w?"row":"rows"," (",w," remaining)"]})]})}function be({nodes:e,edges:t,chartType:n,tableId:r,chartTitle:i}){const[o,l]=J.useState(!1),[a,s]=J.useState(5),c=_(),d=c?.visible??!1,u=o||d,h=i?"Data summary for "+i:r?`Data summary for ${n} ${r}`:"Data summary for "+n,f=J.useRef(null);J.useEffect(()=>{u||s(5)},[u]);const m=J.useCallback(e=>{e.target===e.currentTarget&&(o||d||l(!0))},[o,d]),p=J.useCallback(e=>{d||f.current?.contains(e.relatedTarget)||l(!1)},[d]);if(!e||0===e.length)return r?ee("span",{id:r,tabIndex:-1,style:Y}):null;if(!u)return ee("div",{id:r,className:le,tabIndex:-1,onFocus:m,style:Y,role:"region","aria-label":h,children:te("button",{type:"button",onClick:()=>l(!0),children:["View data summary (",e.length," nodes, ",t.length," edges)"]})});const g=Array.isArray(e)?e:[],y=Array.isArray(t)?t:[],b=new Map,x=new Map,v=new Map,w=new Map;for(const e of y){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,i="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),w.set(e,(w.get(e)??0)+i)}if(null!=r&&""!==r){const e=r+"";b.set(e,(b.get(e)??0)+1),v.set(e,(v.get(e)??0)+i)}}const k=[];for(let e=0;g.length>e;e++){const t=g[e];if(!t||"object"!=typeof t)continue;const n=t.datum?.id??t.id,r=null!=n?n+"":"node-"+e,i=b.get(r)??0,o=x.get(r)??0,l=v.get(r)??0,a=w.get(r)??0;k.push({id:r,degree:i+o,inDeg:i,outDeg:o,wDegree:l+a,wInDeg:l,wOutDeg:a})}k.sort((e,t)=>t.degree-e.degree);let S=0,M=0;if(k.length>0){let e=0;for(const t of k)e+=t.degree,t.degree>M&&(M=t.degree);S=e/k.length}const C=y.some(e=>{const t=e?.datum??{source:e?.source,target:e?.target};return"number"==typeof t?.value&&Number.isFinite(t.value)}),$=[`${k.length} nodes, ${y.length} edges.`];k.length>0&&$.push(`Mean degree: ${ie(S)}, max degree: ${M}.`);const R=Math.min(a,k.length),z=k.slice(0,R),j=k.length-R;return te("div",{ref:f,id:r,className:se,tabIndex:-1,onBlur:p,style:ce,role:"region","aria-label":h,children:[ee("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{d&&c&&c.setVisible(!1),l(!1)},"aria-label":"Close data summary",style:ue,children:"×"}),ee("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:de,children:$.join(" ")}),te("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+n,style:he,children:[ee("caption",{className:"semiotic-accessible-data-table-caption",style:pe,children:j>0?`Top ${R} of ${k.length} nodes by degree`:`All ${k.length} nodes by degree`}),ee("thead",{children:te("tr",{children:[ee("th",{style:fe,children:"id"}),ee("th",{style:fe,children:"degree"}),ee("th",{style:fe,children:"in"}),ee("th",{style:fe,children:"out"}),C&&ee("th",{style:fe,children:"w. degree"}),C&&ee("th",{style:fe,children:"w. in"}),C&&ee("th",{style:fe,children:"w. out"})]})}),ee("tbody",{children:z.map((e,t)=>te("tr",{children:[ee("td",{style:me,children:e.id}),ee("td",{style:me,children:e.degree}),ee("td",{style:me,children:e.inDeg}),ee("td",{style:me,children:e.outDeg}),C&&ee("td",{style:me,children:ie(e.wDegree)}),C&&ee("td",{style:me,children:ie(e.wInDeg)}),C&&ee("td",{style:me,children:ie(e.wOutDeg)})]},t))})]}),j>0&&te("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>s(e=>e+25),style:ge,children:["Show ",Math.min(25,j)," more"," ",1===j?"node":"nodes"," (",j," remaining)"]})]})}function xe({summary:e}){return e?ee("div",{role:"note",style:Y,children:e}):null}function ve({tableId:e}){return ee("a",{href:"#"+e,style:Y,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,Y)},children:"Skip to data table"})}import{jsx as we}from"react/jsx-runtime";var ke="var(--semiotic-focus, #005fcc)";function Se({active:e,hoverPoint:t,margin:n,size:r,shape:i="circle",width:o,height:l,pathData:a}){if(!e||!t)return null;const s=t.x+n.left,c=t.y+n.top;let d;if("geoarea"!==i&&"path"!==i||!a)if("rect"===i&&null!=o&&null!=l){const e=Math.max(o,4),t=Math.max(l,4);d=we("rect",{x:s-e/2-3,y:c-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:ke,strokeWidth:2,strokeDasharray:"4,2"})}else d=we("circle","wedge"===i?{cx:s,cy:c,r:12,fill:"none",stroke:ke,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:s,cy:c,r:8,fill:"none",stroke:ke,strokeWidth:2,strokeDasharray:"4,2"});else d=we("g",{transform:`translate(${n.left},${n.top})`,children:we("path",{d:a,fill:"none",stroke:ke,strokeWidth:2.5,strokeDasharray:"6,3"})});return we("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 Me from"react";import{jsx as Ce}from"react/jsx-runtime";function $e({x:e,y:n,containerWidth:r,containerHeight:i,margin:o,children:l,className:a="stream-frame-tooltip",zIndex:s=1}){const c=Number.isFinite(e)&&Number.isFinite(n),d=Me.useRef(null),[u,h]=Me.useState(null);Me.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()},[a,r,i,c]);let f;f=u?`translate(${u.width+12>r-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>i-n?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*r?"calc(-100% - 12px)":"12px"}, ${.3*i>n?"4px":"calc(-100% - 4px)"})`;const m=function(e){if(!Me.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}(l),p=m?null:t;return c?Ce("div",{ref:d,className:m?a:(a+" semiotic-tooltip").trim(),style:{...p||{},position:"absolute",left:o.left+e,top:o.top+n,transform:f,pointerEvents:"none",zIndex:s,width:"max-content"},children:l}):null}import*as Re from"react";import{useCallback as ze,useEffect as je,useLayoutEffect as De,useMemo as Ae,useRef as Ie}from"react";import{useRef as Ne,useState as Fe,useEffect as We}from"react";var Be="undefined"==typeof window?je:De,Ee={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function Oe(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function Ge(e){const t=d(),n=Ie(t);n.current=t;const[r,i]=function(e,t,n){const r=Ne(null),[i,o]=Fe(null);return We(()=>{if(!t&&!n)return;const e=r.current;if(!e)return;const i=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;o(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return i.observe(e),()=>i.disconnect()},[t,n]),[r,[t&&i?i.w:e[0],n&&i?i.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),o=!!e.title,l=!!e.legend&&"top"===e.legendPosition,a=Ae(()=>s({...e.marginDefault,...e.userMargin},o,l),[e.marginDefault,e.userMargin,o,l]),u=i[0]-a.left-a.right,h=i[1]-a.top-a.bottom,f=Oe(e.foregroundGraphics,i,a),p=Oe(e.backgroundGraphics,i,a),g=k(e=>e.theme),{transition:y,introEnabled:b}=c(e.animate,e.transitionProp),x="semiotic-table-"+Re.useId(),w=Ie(null);if(!w.current){const t=!e.suspendWhenHidden||"undefined"==typeof document||!document.hidden;w.current=new m({clock:e.clock,random:e.random,seed:e.seed,paused:e.paused,visible:t})}const S=w.current;S.configure({clock:e.clock,random:e.random,seed:e.seed});const M=Ie(null),C=Ie(e.frameScheduler??Ee);C.current=e.frameScheduler??Ee;const $=Ie(null),R=Ie(!1),z=Ie(()=>{}),j=ze(()=>{if(null!==M.current||R.current)return;const e=C.current;let t=!1,n=!1;const r=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&(R.current=!0),M.current=null,$.current=null;try{z.current()}finally{e&&(R.current=!1)}});n=!0,t||(M.current=r,$.current=e)},[]),D=ze(()=>{null!==M.current&&(($.current??C.current).cancelAnimationFrame(M.current),M.current=null,$.current=null)},[]);Be(()=>{S.setPaused(!0===e.paused)},[S,e.paused]),je(()=>{if(!e.suspendWhenHidden||"undefined"==typeof document)return void S.setVisible(!0);const t=()=>S.setVisible(!document.hidden);return t(),document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[S,e.suspendWhenHidden]),je(()=>()=>{D()},[D]);const A=Ie(()=>{}),I=Ie(()=>{}),N=Ie(null),F=Ie(null),W=Ie(null),B=ze(()=>{const e=N.current;N.current=null,e&&A.current(e)},[]),E=ze(e=>{if(N.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===F.current){const e=C.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,F.current=null,W.current=null,B()});t||(F.current=n,W.current=e)}},[B]),O=ze(()=>{N.current=null,null!==F.current&&((W.current??C.current).cancelAnimationFrame(F.current),F.current=null,W.current=null),I.current()},[]);je(()=>()=>{N.current=null,null!==F.current&&((W.current??C.current).cancelAnimationFrame(F.current),F.current=null,W.current=null)},[]);const G=e.themeDirtyRef;return Be(()=>{G&&(v(),G.current=!0,j())},[g,j,G]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:r,size:i,margin:a,adjustedWidth:u,adjustedHeight:h,resolvedForeground:f,resolvedBackground:p,currentTheme:g,transition:y,introEnabled:b,tableId:x,frameRuntime:S,rafRef:M,renderFnRef:z,scheduleRender:j,cancelRender:D,hoverHandlerRef:A,hoverLeaveRef:I,onPointerMove:E,onPointerLeave:O}}import{useEffect as He,useRef as Te}from"react";import{jsx as Le}from"react/jsx-runtime";function Ue(e,t){return function(e){const{cancelRender:t,dirtyRef:n,frameRuntime:r,manageFrameRuntime:i,scheduleRender:o}=e,l=Te(null),a=Te(null),s=Te(!1);return function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:r,dirtyRef:i,renderFnRef:o,cancelRender:l,cleanup:a}=e;H(()=>{t&&n&&r.current?.cancelIntroAnimation?.(),i.current=!0,l?.(),o.current()},[t,n]);const s=E(a);s.current=a,W(()=>()=>s.current?.(),[])}({hydrated:e.hydrated,wasHydratingFromSSR:e.wasHydratingFromSSR,storeRef:e.storeRef,dirtyRef:e.dirtyRef,renderFnRef:e.renderFnRef,cancelRender:e.cancelRender,cleanup:e.cleanup}),He(()=>{if(!1!==i)return r.subscribe(()=>{r.isActive?(n.current=!0,o()):t()})},[t,n,r,i,o]),He(()=>{!s.current&&(s.current=!0,e.skipInitialCanvasPaintInvalidation)||(e.dirtyRef.current=!0,e.scheduleRender())},e.canvasPaintDependencies),{canvasRef:l,interactionCanvasRef:a}}({...t,renderFnRef:e.renderFnRef,scheduleRender:e.scheduleRender,cancelRender:e.cancelRender,frameRuntime:e.frameRuntime})}function qe({children:e,size:t,margin:n,overflowVisible:r=!1}){return e?Le("svg",{style:{position:"absolute",left:0,top:0,width:t[0],height:t[1],pointerEvents:"none",overflow:r?"visible":void 0},children:Le("g",{transform:`translate(${n.left},${n.top})`,children:e})}):null}function Pe(e,t,n,r){const i=e.getContext("2d");if(!i)return null;const o=Math.round(t[0]*r),l=Math.round(t[1]*r),a=o/t[0],s=l/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===o&&e.height===l||(e.width=o,e.height=l),i.setTransform(a,0,0,s,0,0),i.translate(n.left,n.top),i}function Ve(){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))}import*as Ye from"react";import{jsx as Xe,jsxs as Je}from"react/jsx-runtime";function Ke({componentName:e,message:t,diagnosticHint:n,width:r,height:i}){return Xe("div",{role:"alert",style:{width:r,height:Math.max(i,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:Je("div",{style:{textAlign:"center",maxWidth:400},children:[Xe("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),Xe("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:t}),n&&Xe("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 Qe}from"react/jsx-runtime";var Ze=class extends Ye.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:Qe(Ke,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}};import{jsx as _e}from"react/jsx-runtime";function et({componentName:e,width:t,height:n,children:r}){return _e(Ze,{fallback:r=>_e(Ke,{componentName:e,message:r.message,width:t,height:n}),children:r})}"undefined"!=typeof process&&process;var tt={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"},nt={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function rt(e,t,n,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?_e("div",{style:{...tt,width:t,height:n},children:r||"No data available"}):null}function it(e,t,n,r){if(!e)return null;if(!1===r)return null;if(null!=r)return _e("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const i=Math.min(5,Math.floor(n/40)),o=Math.max(8,Math.floor(n/(3*i))),l=Math.max(6,Math.floor(n/(2.5*i))),a=Math.floor((n-(i*(o+l)-l))/2);return _e("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:i},(e,n)=>_e("div",{className:"semiotic-loading-bar",style:{...nt,position:"absolute",top:a+n*(o+l),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:o,opacity:.5+n%2*.2}},n))})}import{curveMonotoneX as ot,curveMonotoneY as lt,curveCardinal as at,curveCatmullRom as st,curveStep as ct,curveStepBefore as dt,curveStepAfter as ut,curveBasis as ht,curveNatural as ft}from"d3-shape";function mt(e){switch(e){case"monotoneX":return ot;case"monotoneY":return lt;case"cardinal":return at;case"catmullRom":return st;case"step":return ct;case"stepBefore":return dt;case"stepAfter":return ut;case"basis":return ht;case"natural":return ft;default:return null}}function pt(e,t,n){if(null==t)return n;if(u(t)){return h(t,e)||t.background&&w(e,t.background)||n}return"string"!=typeof t?t:w(e,t)||n}function gt(e,t){if(null==t)return;const n=pt(e,t,"");return""===n?void 0:n}function yt(e,t,n,r,i,o,l){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 a=e.createLinearGradient(r,i,o,l);for(const e of n)a.addColorStop(e.offset,e.color);return a}const{topOpacity:a,bottomOpacity:s}=t;if(!Number.isFinite(a)||!Number.isFinite(s))return null;const c=Math.max(0,Math.min(1,a)),d=Math.max(0,Math.min(1,s)),u=e.createLinearGradient(r,i,o,l),[h,f,m]=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 i=e.fillStyle;if(e.fillStyle=n,"string"!=typeof i)return[78,121,167];if(i.toLowerCase()===r&&t.trim().toLowerCase()!==r)return[78,121,167];if(i.startsWith("#"))return[parseInt(i.slice(1,3),16),parseInt(i.slice(3,5),16),parseInt(i.slice(5,7),16)];const o=i.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return o?[+o[1],+o[2],+o[3]]:[78,121,167]}(e,n);return u.addColorStop(0,`rgba(${h},${f},${m},${c})`),u.addColorStop(1,`rgba(${h},${f},${m},${d})`),u}function bt(e,t,n,r,i,o){const l=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>l.length)return null;const a=e.createLinearGradient(n,r,i,o);for(const e of l)a.addColorStop(e.offset,e.color);return a}import*as xt from"react";import{jsx as vt,jsxs as wt}from"react/jsx-runtime";var kt={fill:(e,t)=>vt("rect",{style:e,width:t,height:t}),line:(e,t)=>vt("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function St(e,t,n,r,i){let o;return o="function"==typeof n?n(e):(0,kt[n])(r(e,t),i),o}function Mt({swatchSize:e}){return vt("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 Ct(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var $t=(e,t,n,r,i,o,l,a,s,c,d)=>{const{type:u="fill",styleFn:h,items:f}=e,m=[];let p=0;const g=!(!t&&!n),y="isolate"===c||void 0===c&&null!=i,{swatchSize:b,labelGap:x,rowHeight:v}=d;return f.forEach((e,c)=>{const d=St(e,c,u,h,b),w=Ct(e,r,i),k=i&&i.size>0&&i.has(e.label);m.push(wt("g",{transform:`translate(0,${p})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:g?a===o&&c===l?0:-1:void 0,role:g?"option":void 0,"aria-selected":g&&y?k||!1:void 0,"aria-current":g&&!y&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:g?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(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:g?t=>{s(a,c),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:g?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:g?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[g&&vt("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,k&&vt(Mt,{swatchSize:b}),vt("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)),p+=v}),m};function Rt({config:e,orientation:t="vertical",width:n=100}){const{colorFn:r,domain:i,label:o,format:l}=e,a=l||(e=>Math.round(100*e)/100+""),s="grad-legend-"+xt.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),l=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(vt("stop",{offset:100*t+"%",stopColor:r(i[0]+t*(i[1]-i[0]))},e))}return wt("g",{"aria-label":o||"Gradient legend",children:[vt("defs",{children:vt("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),o&&vt("text",{x:l+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:o}),vt("rect",{x:l,y:0,width:t,height:e,fill:`url(#${s})`,rx:2}),vt("text",{x:l,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(i[0])}),vt("text",{x:l+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(i[1])})]})}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push(vt("stop",{offset:100*t+"%",stopColor:r(i[1]-t*(i[1]-i[0]))},e))}return wt("g",{"aria-label":o||"Gradient legend",children:[o&&vt("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:o}),vt("defs",{children:vt("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),vt("rect",{x:0,y:0,width:14,height:100,fill:`url(#${s})`,rx:2}),vt("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(i[1])}),vt("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(i[0])})]})}function zt(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o,legendInteraction:l,title:a="Legend",width:s=100,height:c=20,orientation:d="vertical",legendLayout:u}=e,h=function(e){const t=Math.max(1,e?.swatchSize??16),n=Math.max(t,e?.rowHeight??22);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??6),itemGap:Math.max(0,e?.itemGap??10),rowHeight:n,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}(u),[f,m]=xt.useState(0),[p,g]=xt.useState(0),y=xt.useCallback((e,t)=>{m(e),g(t)},[]),b="vertical"===d?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o,focusedGroupIndex:l,focusedItemIndex:a,onFocusedIndexChange:s,legendInteraction:c,metrics:d})=>{let u=24;const h=[];return e.forEach((e,f)=>{u+=5,h.push(vt("line",{stroke:"gray",x1:0,y1:u,x2:t,y2:u},"legend-top-line legend-symbol-"+f)),u+=8,e.label&&(u+=16,h.push(vt("text",{y:u,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),u+=8),h.push(vt("g",{className:"legend-item",transform:`translate(0,${u})`,children:$t(e,n,r,i,o,l,a,f,s,c,d)},"legend-group-"+f)),u+=e.items.length*d.rowHeight+8}),h})({legendGroups:t||[],width:s,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:y,legendInteraction:l,metrics:h}):(({legendGroups:e,height:t,width:n,customClickBehavior:r,customHoverBehavior:i,highlightedCategory:o,isolatedCategories:l,focusedGroupIndex:a,focusedItemIndex:s,onFocusedIndexChange:c,legendInteraction:d,metrics:u})=>{let h=0;const f=[];e.forEach((e,t)=>{let m=0;e.label&&(m+=16);const p=((e,t,n,r,i,o,l,a,s,c,d,u)=>{const{type:h="fill",styleFn:f,items:m}=e,p=[],{swatchSize:g,labelGap:y,itemGap:b,rowHeight:x,align:v}=d,w=!(!t&&!n),k="isolate"===c||void 0===c&&null!=i,S=m.map(e=>g+y+7*e.label.length),M=[];let C=0,$=0;S.forEach((e,t)=>{const n=0===$?e:$+b+e;u&&u>0&&$>0&&n>u?(M.push({start:C,end:t,width:$}),C=t,$=e):$=n}),m.length>0&&M.push({start:C,end:m.length,width:$}),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=m[u],v=St(e,u,h,f,g),M=Ct(e,r,i),C=i&&i.size>0&&i.has(e.label);p.push(wt("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:w?a===o&&u===l?0:-1:void 0,role:w?"option":void 0,"aria-selected":w&&k?C||!1:void 0,"aria-current":w&&!k&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:w?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)+m.length)%m.length;s(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:w?t=>{s(a,u),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:w?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:w?"pointer":"default",opacity:M,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[w&&vt("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:g+y+2+7*e.label.length,height:g+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,C&&vt(Mt,{swatchSize:g}),vt("text",{y:g/2,x:g+y,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+u)),d+=S[u]+b}});const R=Math.max(0,...M.map(e=>e.width)),z=M.length;return{items:p,offset:R,totalRows:z,totalHeight:z*x}})(e,r,i,o,l,a,s,t,c,d,u,u.maxWidth??n);m+=p.offset+5,f.push({label:e.label,...p,offset:m,totalRows:p.totalRows,totalHeight:p.totalHeight}),h+=m+12});const m=u.maxWidth??n;let p=h>m?0:"center"===u.align?Math.max(0,(m-h)/2):"end"===u.align?Math.max(0,m-h):0;const g=[];return f.forEach((n,r)=>{const i=e[r];i.label&&(g.push(vt("text",{transform:`translate(${p},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:i.label},"legend-text-"+r)),p+=16),g.push(vt("g",{className:"legend-item",transform:`translate(${p},0)`,children:n.items},"legend-group-"+r)),p+=n.offset+5,e[r+1]&&g.push(vt("line",{stroke:"gray",x1:p,y1:-8,x2:p,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+r)),p+=12}),vt("g",{children:g})})({legendGroups:t||[],title:a,height:c,width:s,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:o,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:y,legendInteraction:l,metrics:h}),x=!(!n&&!r);return wt("g",{role:x?"listbox":void 0,"aria-multiselectable":!(!x||"isolate"!==l&&(void 0!==l||null==o))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===d&&vt("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:a}),b]})}import{jsx as jt}from"react/jsx-runtime";function Dt(e){const{legend:t,totalWidth:n,totalHeight:r,margin:i,legendPosition:o="right",legendLayout:s,title:c,legendHoverBehavior:d,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:f,legendInteraction:m}=e;if(!t)return null;const p="top"===o||"bottom"===o,g=!!c,y=Math.max(0,n-i.left-i.right),b=Math.max(1,p?s?.maxWidth??y:100);let x,v;return"left"===o?(x=Math.max(4,i.left-b-10),v=i.top):"top"===o?(x=i.left,v=g?32:8):"bottom"===o?(x=i.left,v=r-i.bottom+38):(x=n-i.right+10,v=i.top),jt("g",{transform:`translate(${x}, ${v})`,children:l(t)?jt(Rt,{config:t.gradient,orientation:p?"horizontal":"vertical",width:b}):a(t)?jt(zt,{legendGroups:t.legendGroups,title:"",width:b,orientation:p?"horizontal":"vertical",legendLayout:s,customHoverBehavior:d,customClickBehavior:u,highlightedCategory:h,isolatedCategories:f,legendInteraction:m}):t})}import*as At from"react";import{packEnclose as It}from"d3-hierarchy";import{area as Nt,curveLinear as Ft,curveMonotoneX as Wt,curveMonotoneY as Bt,curveStep as Et,curveStepAfter as Ot,curveStepBefore as Gt,curveBasis as Ht,curveCardinal as Tt,curveCatmullRom as Lt}from"d3-shape";function Ut(e){return Math.round(100*e)/100}function qt(e,t=2){const n=[],r=[],i=t+1;for(let t=0;i>t;t++){let o=0;for(const[n,r]of e)null!==r&&(o+=n**t*r);n.push(o);const l=[];for(let n=0;i>n;n++){let r=0;for(const[i,o]of e)null!==o&&(r+=i**(t+n));l.push(r)}r.push(l)}r.push(n);const o=function(e,t){const n=e,r=e.length-1,i=[t];for(let e=0;r>e;e++){let t=e;for(let i=e+1;r>i;i++)Math.abs(n[e][i])>Math.abs(n[e][t])&&(t=i);for(let i=e;r+1>i;i++){const r=n[i][e];n[i][e]=n[i][t],n[i][t]=r}for(let t=e+1;r>t;t++)for(let i=r;i>=e;i--)n[i][t]-=n[i][e]*n[e][t]/n[e][e]}for(let e=r-1;e>=0;e--){let t=0;for(let o=e+1;r>o;o++)t+=n[o][e]*i[o];i[e]=(n[r][e]-t)/n[e][e]}return i}(r,i).map(Ut);return{points:e.map(([e])=>[Ut(e),Ut(o.reduce((t,n,r)=>t+n*e**r,0))]),equation:[...o].reverse()}}import{jsx as Pt,jsxs as Vt}from"react/jsx-runtime";var Yt={linear:Ft,monotoneX:Wt,monotoneY:Bt,step:Et,stepAfter:Ot,stepBefore:Gt,basis:Ht,cardinal:Tt,catmullRom:Lt};function Xt(e,t,n,r){const i=[];return e.forEach((e,o)=>{let l;if(n){const i=n(e,o,r);l=null!=i?i:t(e,o,r)}else l=t(e,o,r);l&&i.push({node:l,annotation:e})}),o(i)}function Jt(t,n={}){return function(t,o,l){switch(t.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const e=g(t,o,l);if(!e)return null;const{x:n,y:r}=e;if(!p(n,r,l))return null;const a="callout"===t.type?"callout-circle":t.type,s="callout-circle"===a?{radius:t.radius??12,radiusPadding:t.radiusPadding}:"callout-rect"===a?{width:t.width,height:t.height}:void 0;return Pt(i,{noteData:{x:n,y:r,dx:t.dx??30,dy:t.dy??-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:a,...s?{subject:s}:{},connector:t.connector||{end:"arrow"},color:t.color,disable:t.disable,opacity:t.opacity,strokeDasharray:t.strokeDasharray,className:t.className}},"ann-"+o)}case"x-threshold":{const e=y(null!=t.value?{...t,x:t.value}:t,l);if(null==e)return null;const n=t.color||"#f97316",i=t.labelPosition||"top";let a;a="bottom"===i?(l.height||0)-4:"center"===i?(l.height||0)/2:16;const s=e>.6*(l.width||0),c=s?e-4:e+4,d=s?"end":"start";return Vt("g",{opacity:t.opacity,children:[Pt("line",{x1:e,y1:0,x2:e,y2:l.height||0,stroke:n,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&Pt(r,{x:c,y:a,text:t.label,textAnchor:d,fill:n,fontSize:12,fontWeight:"bold",background:t.labelBackground??"halo"})]},"ann-"+o)}case"y-threshold":{const e=b(null!=t.value?{...t,y:t.value}:t,l);if(null==e)return null;const n=t.color||"#f97316",i=t.labelPosition||"right";let a,s;"left"===i?(a=4,s="start"):"center"===i?(a=(l.width||0)/2,s="middle"):(a=(l.width||0)-4,s="end");const d=20>(c=e)?Math.min((l.height||0)-4,c+16):c-4;return Vt("g",{opacity:t.opacity,children:[Pt("line",{x1:0,y1:e,x2:l.width||0,y2:e,stroke:n,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&Pt(r,{x:a,y:d,text:t.label,textAnchor:s,fill:n,fontSize:12,fontWeight:"bold",background:t.labelBackground??"halo"})]},"ann-"+o)}case"enclose":{const e=(t.coordinates||[]).map(e=>({x:y({...e,type:"point"},l),y:b({...e,type:"point"},l),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>e.length)return null;const n=It(e),i=t.padding||10;return Vt("g",{children:[Pt("circle",{cx:n.x,cy:n.y,r:n.r+i,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&Pt(r,{x:n.x,y:n.y-n.r-i-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:t.label,background:t.labelBackground??"none"})]},"ann-"+o)}case"rect-enclose":{const e=(t.coordinates||[]).map(e=>({x:y({...e,type:"point"},l),y:b({...e,type:"point"},l)})).filter(e=>null!=e.x&&null!=e.y);if(2>e.length)return null;const n=t.padding||10,i=e.map(e=>e.x),a=e.map(e=>e.y),[s,c]=x(i),[d,u]=x(a),h=s-n,f=c+n,m=d-n;return Vt("g",{children:[Pt("rect",{x:h,y:m,width:f-h,height:u+n-m,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&Pt(r,{x:(h+f)/2,y:m-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:t.label,background:t.labelBackground??"none"})]},"ann-"+o)}case"highlight":{const e=l.data||[],n="function"==typeof t.filter?e.filter(t.filter):t.field&&null!=t.value?e.filter(e=>e[t.field]===t.value):[],r={stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return Pt("g",{children:n.map((e,n)=>{const i=y(e,l),o=b(e,l);if(null==i||null==o)return null;const a="function"==typeof t.r?t.r(e):t.r||6,s="function"==typeof t.style?t.style(e):t.style||r;return Pt("circle",{cx:i,cy:o,r:a,...s},"hl-"+n)})},"ann-"+o)}case"bracket":{const e=y(t,l),n=b(t,l);return Pt(i,{noteData:{x:e??0,y:n??0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}},"ann-"+o)}case"trend":{const e=l.data||[];if(2>e.length)return null;const n=l.xAccessor||"x",r=l.yAccessor||"y",i="ordinal"===l.frameType,a="horizontal"===l.projection,s=i?n:null,c=i?r:null;let d;const u=[],h=new Map;if(i&&s&&c){for(const t of e){const e=t[s];if(null==e)continue;const n=e+"";h.has(n)||(h.set(n,u.length),u.push(n))}d=e.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=e.map(e=>[e[n],e[r]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>d.length)return null;const f=l.scales?.x??l.scales?.time,m=l.scales?.y??l.scales?.value;if(!f||!m)return null;const p=e=>t=>{const n=Math.max(0,Math.floor(t)),r=Math.min(u.length-1,n+1),i=t-n,o=e(u[n]);return o+(e(u[r])-o)*i},g=f,y=m;let b;if(i)if(a){const e=p(y);b=(t,n)=>[g(n),e(t)]}else{const e=p(g);b=(t,n)=>[e(t),y(n)]}else b=(e,t)=>[g(e),y(t)];const x=t.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]),i=r.map(e=>e[0]),o=r.map(e=>e[1]),l=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=i[e],r=i.map(e=>Math.abs(e-t)),s=r.slice().sort((e,t)=>e-t)[Math.min(l-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,m=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(d+=t,u+=t*i[e],h+=t*o[e],f+=t*i[e]*i[e],m+=t*i[e]*o[e])}if(0===d){a.push([t,o[e]]);continue}const p=d*f-u*u;if(1e-12>Math.abs(p))a.push([t,h/d]);else{const e=(d*m-u*h)/p;a.push([t,(h-e*u)/d+e*t])}}return a}(d,t.bandwidth??.3);else{const e="polynomial"===x?qt(d,t.order||2):function(e){const t=[0,0,0,0];let n=0;for(const[r,i]of e)null!==i&&(n++,t[0]+=r,t[1]+=i,t[2]+=r*r,t[3]+=r*i);const r=n*t[2]-t[0]*t[0],i=0===r?0:Ut((n*t[3]-t[0]*t[1])/r),o=Ut(t[1]/n-i*t[0]/n);return{points:e.map(([e])=>[Ut(e),Ut(i*e+o)]),equation:[i,o]}}(d);v=e.points}const w=v.map(([e,t])=>{const[n,r]=b(e,t);return`${n},${r}`}).join(" "),k=t.color||"#6366f1",S=v[v.length-1],[M,C]=b(S[0],S[1]);return Vt("g",{children:[Pt("polyline",{points:w,fill:"none",stroke:k,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&Pt("text",{x:M+4,y:C-4,fill:k,fontSize:11,children:t.label})]},"ann-"+o)}case"band":{const e=l.scales?.y??l.scales?.value,n=e?.(t.y0)??0,i=e?.(t.y1)??(l.height||0),c=f(t.fill,"ann-"+o,"var(--semiotic-primary, #6366f1)");return Vt("g",{opacity:t.opacity,children:[c.def&&Pt("defs",{children:c.def}),Pt("rect",{x:0,y:Math.min(n,i),width:l.width||0,height:Math.abs(i-n),fill:c.fill,fillOpacity:t.fillOpacity||.1}),t.label&&Pt(r,{x:(l.width||0)-4,y:(a=n,s=i,Math.max(Math.min(a,s),0)+16),textAnchor:"end",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:t.label,background:t.labelBackground??"halo"})]},"ann-"+o)}case"x-band":{const e=l.scales?.x??l.scales?.time,n=null!=t.x0&&e?e(t.x0):null,i=null!=t.x1&&e?e(t.x1):null;if(null==n||null==i)return null;const a=f(t.fill||t.color,"ann-"+o,"var(--semiotic-primary, #6366f1)");return Vt("g",{opacity:t.opacity,children:[a.def&&Pt("defs",{children:a.def}),Pt("rect",{x:Math.min(n,i),y:0,width:Math.abs(i-n),height:l.height||0,fill:a.fill,fillOpacity:t.fillOpacity??.1}),t.label&&Pt(r,{x:Math.min(n,i)+4,y:16,textAnchor:"start",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:t.label,background:t.labelBackground??"halo"})]},"ann-"+o)}case"envelope":{const e=l.data||[];if(2>e.length)return null;const n=l.xAccessor||"x",r=l.scales?.x??l.scales?.time,i=l.scales?.y??l.scales?.value;if(!r||!i)return null;const a=t.upperAccessor||"upperBounds",s=t.lowerAccessor||"lowerBounds",c=t.filter,d=e.filter(e=>null!=e[a]&&null!=e[s]&&!(c&&!c(e))).sort((e,t)=>e[n]-t[n]);if(2>d.length)return null;const u=Yt[l.curve||"linear"]||Ft,h=Nt().x(e=>r(e[n])).y0(e=>i(e[s])).y1(e=>i(e[a])).curve(u)(d);if(!h)return null;const f=t.fill||"#6366f1";return Vt("g",{children:[Pt("path",{d:h,fill:f,fillOpacity:t.fillOpacity??.15,stroke:"none"}),t.label&&d.length>0&&Pt("text",{x:r(d[d.length-1][n])+4,y:i(d[d.length-1][a])-4,fill:f,fontSize:11,children:t.label})]},"ann-"+o)}case"anomaly-band":{const e=l.data||[];if(2>e.length)return null;const n=l.yAccessor||"y",r=l.scales?.x??l.scales?.time,i=l.scales?.y??l.scales?.value;if(!r||!i)return null;const a=e.map(e=>e[n]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const s=a.reduce((e,t)=>e+t,0)/a.length,c=a.reduce((e,t)=>e+(t-s)**2,0)/a.length,d=Math.sqrt(c),u=t.threshold??2,h=s-u*d,f=!1!==t.showBand,m=t.fill||"#6366f1",p=t.fillOpacity??.1,g=t.anomalyColor||"#ef4444",x=t.anomalyRadius??6,v=i(s+u*d),w=i(h),k=e.filter(e=>{const t=e[n];return null!=t&&Math.abs(t-s)>u*d});return Vt("g",{children:[f&&Pt("rect",{x:0,y:Math.min(v,w),width:l.width||0,height:Math.abs(w-v),fill:m,fillOpacity:p}),k.map((e,t)=>{const n=y(e,l),r=b(e,l);return null==n||null==r?null:Pt("circle",{cx:n,cy:r,r:x,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+t)}),t.label&&Pt("text",{x:(l.width||0)-4,y:Math.min(v,w)-4,textAnchor:"end",fill:m,fontSize:11,children:t.label})]},"ann-"+o)}case"forecast":{const e=l.data||[];if(3>e.length)return null;const n=l.xAccessor||"x",r=l.yAccessor||"y",i=l.scales?.x??l.scales?.time,a=l.scales?.y??l.scales?.value;if(!i||!a)return null;const s=e.map(e=>[e[n],e[r]]).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"===(t.method||"linear")){const e=qt(s,t.order||2).equation;c=t=>e.reduce((e,n,r)=>e+n*Math.pow(t,r),0)}else{const e=s.length;let t=0,n=0,r=0,i=0;for(const[e,o]of s)t+=e,n+=o,r+=e*e,i+=e*o;const o=e*r-t*t;if(1e-12>Math.abs(o))return null;const l=(e*i-t*n)/o,a=(n-l*t)/e;c=e=>a+l*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)),m=s.reduce((e,t)=>e+t[0],0)/d,p=s.reduce((e,t)=>e+(t[0]-m)**2,0),g=t.confidence??.95,y=.99>g?.95>g?.9>g?1:1.645:1.96:2.576,b=t.steps??5,x=s[d-1][0],v=(x-s[0][0])/Math.max(d-1,1),w=[];for(let e=1;b>=e;e++)w.push(x+e*v);const k=[];for(const e of w){const t=c(e),n=f*Math.sqrt(1+1/d+(p>0?(e-m)**2/p:0))*y;k.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const S=`M${k.map(e=>`${i(e.x)},${a(e.yUpper)}`).join(" L")} L${k.slice().reverse().map(e=>`${i(e.x)},${a(e.yLower)}`).join(" L")} Z`,M=k.map(e=>`${i(e.x)},${a(e.yCenter)}`).join(" "),C=`${i(x)},${a(c(x))}`,$=t.strokeColor||"#6366f1";return Vt("g",{children:[Pt("path",{d:S,fill:t.fill||"#6366f1",fillOpacity:t.fillOpacity??.15,stroke:"none"}),Pt("polyline",{points:`${C} ${M}`,fill:"none",stroke:$,strokeWidth:t.strokeWidth??2,strokeDasharray:t.strokeDasharray??"6,3"}),t.label&&k.length>0&&Pt("text",{x:i(k[k.length-1].x)+4,y:a(k[k.length-1].yCenter)-4,fill:$,fontSize:11,children:t.label})]},"ann-"+o)}case"widget":{let r,i;if(null!=t.px&&null!=t.py)r=t.px,i=t.py;else{const e=g(t,o,l);if(!e)return null;r=e.x,i=e.y}if(!p(r,i,l))return null;const a=t.dx??0,s=t.dy??0,c=t.width??32,d=t.height??32,u=t.content??Pt("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info",children:"ℹ️"});return Pt("foreignObject",{x:r+a-c/2,y:i+s-d/2,width:c,height:d,style:{overflow:"visible",pointerEvents:"auto"},children:Pt("div",{...e(t,n),style:{width:c,height:d,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+o)}case"text":{const e=g(t,o,l);if(!e)return null;const{x:n,y:r}=e,i=n+(t.dx||0),a=r+(t.dy||0),s=t.color||"var(--semiotic-text, #333)",c=Pt("text",{x:i,y:a,fill:s,fontSize:t.fontSize||11,opacity:t.opacity,strokeDasharray:t.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:t.label});return!0!==t._redundantConnector?At.cloneElement(c,{key:"ann-text-"+o}):Vt("g",{opacity:t.opacity,strokeDasharray:t.strokeDasharray,children:[Pt("line",{x1:n,y1:r,x2:i,y2:a,stroke:s,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),At.cloneElement(c,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+o)}case"category-highlight":{const e=t.category;if(null==e)return null;const n=e=>"function"==typeof e&&"function"==typeof e.bandwidth,i=l.scales?.o,a=l.scales?.x,s=l.scales?.y,c=n(i)?i:n(a)?a:n(s)?s:null;if(!c)return null;const d=c(e+"");if(null==d)return null;const u=c.bandwidth(),h=t.color||"var(--semiotic-primary, #4589ff)",f=t.opacity??.15,m=t.label;return Vt("g",(l.projection?"vertical"===l.projection:c===a)?{children:[Pt("rect",{x:d,y:0,width:u,height:l.height||0,fill:h,fillOpacity:f}),m&&Pt(r,{x:d+u/2,y:16,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",text:m,background:t.labelBackground??"none"})]}:{children:[Pt("rect",{x:0,y:d,width:l.width||0,height:u,fill:h,fillOpacity:f}),m&&Pt(r,{x:12,y:d+u/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",text:m,background:t.labelBackground??"none"})]},"ann-"+o)}default:return null}var a,s,c}}export{I as useSceneRevisionDiagnostics,N as runSceneBuild,F as SceneRevisionDiagnosticsObserver,mt as resolveCurveFactory,pt as resolveCanvasFill,gt as coerceCanvasFill,yt as buildLinearFillGradient,bt as buildColorStopGradient,Dt as renderLegendFromConfig,Xt as renderAnnotationPass,Jt as createDefaultAnnotationRules,T as useHydration,P as useWasHydratingFromSSR,_ as useDataSummary,X as AriaLiveTooltip,ne as computeCanvasAriaLabel,re as computeNetworkAriaLabel,ye as AccessibleDataTable,be as NetworkAccessibleDataTable,xe as ScreenReaderSummary,ve as SkipToTableLink,Se as FocusRing,$e as FlippingTooltip,Ge as useFrame,Ue as useFrameCanvasHost,qe as CanvasFrameBackground,Pe as prepareCanvas,Ve as getDevicePixelRatio,et as SafeRender,rt as renderEmptyState,it as renderLoadingState};
@@ -1,2 +0,0 @@
1
- "use client";
2
- import{STREAMING_PALETTE as e,createColorScale as t,filterSparseArray as r,getCrosshairProps as o,resolveMobileInteraction as n,useCategoryColors as a,useChartLegendAndMargin as i,useChartMode as l,useChartSelection as c,useColorScale as u,useLegendInteraction as s,useThemeCategorical as d}from"./chunk-chunk-ODUZEEBH.module.min.js";import{useThemeSelector as g}from"./chunk-chunk-WCX6U47H.module.min.js";import{renderEmptyState as m,renderLoadingState as h}from"./chunk-chunk-ZCNBUZPL.module.min.js";import{useMemo as y}from"react";function p(e){const t=g(e=>e.theme.colors.selectionOpacity);return y(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}import{useCallback as f,useMemo as v,useState as b}from"react";function k(l){const{data:g,rawData:y,colorBy:k,colorScheme:L,legendInteraction:C,legendPosition:S,selection:H,linkedHover:w,fallbackFields:B,unwrapData:D=!1,onObservation:M,chartType:I,chartId:F,showLegend:A,userMargin:P,marginDefaults:R,onClick:O,hoverHighlight:T,mobileInteraction:W,mobileSemantics:x,loading:j,loadingContent:N,emptyContent:U,width:Z,height:z}=l,E=void 0===y,G=v(()=>r(g),[g]),[_,V]=b([]),X=f(e=>{V(t=>t.length===e.length&&t.every((t,r)=>t===e[r])?t:e)},[]),q="string"==typeof l.colorBy?l.colorBy:void 0,J=v(()=>n(W,{width:Z,mobileSemantics:x}),[W,Z,x]),{activeSelectionHook:K,hoverSelectionHook:Q,customHoverBehavior:Y,customClickBehavior:$,crosshairSourceId:ee}=c({selection:H,linkedHover:w,fallbackFields:B,unwrapData:D,onObservation:M,chartType:I,chartId:F,onClick:O,hoverHighlight:T,colorByField:q,mobileInteraction:J}),te=o(w,ee),re=u(G,k,L),oe=v(()=>{if(!k)return[];const e=new Set;for(const t of G){const r="function"==typeof k?k(t):t[k];null!=r&&e.add(r+"")}return Array.from(e)},[G,k]),ne=v(()=>E&&_.length>0?_:oe,[E,_,oe]),ae=s(C,k,ne),ie=v(()=>Q||(ae.legendSelectionHook?ae.legendSelectionHook:K),[Q,ae.legendSelectionHook,K]),le=p(H),ce=d(),ue=a(),se=v(()=>{if(re)return re;if(!k||0===ne.length)return;const r=Array.isArray(L)&&L.length>0||"string"==typeof L&&L.length>0?L:ce&&ce.length>0?ce:e,o="__streamCat",n=ne.map(e=>({[o]:e})),a=t(n,o,r);return e=>ue?.[e]||a(e)||"#999"},[re,k,ne,L,ce,ue]),{legend:de,margin:ge,legendPosition:me}=i({data:G,colorBy:k,colorScale:se,showLegend:A,legendPosition:S,userMargin:P,defaults:R,categories:ne}),he=v(()=>{const e={};return de&&(e.legend=de,e.legendPosition=me),C&&"none"!==C&&(e.legendHoverBehavior=ae.onLegendHover,e.legendClickBehavior=ae.onLegendClick,e.legendHighlightedCategory=ae.highlightedCategory,e.legendIsolatedCategories=ae.isolatedCategories),E&&k&&(e.legendCategoryAccessor=k,e.onCategoriesChange=X),e},[de,me,C,ae.onLegendHover,ae.onLegendClick,ae.highlightedCategory,ae.isolatedCategories,E,k,X]),ye=Array.isArray(y)?r(y):y,pe=h(j,Z,z,N),fe=pe?null:m(ye,Z,z,U);return{data:G,colorScale:re,allCategories:ne,legendState:ae,effectiveSelectionHook:ie,activeSelectionHook:K,customHoverBehavior:Y,customClickBehavior:$,mobileInteraction:J,legend:de,margin:ge,legendPosition:me,earlyReturn:pe||fe||null,legendBehaviorProps:he,crosshairProps:te,resolvedSelection:le}}import{useImperativeHandle as L}from"react";function C(e,t){const{variant:r,frameRef:o,overrides:n}=t;L(e,()=>{const e=function(e,t){if("xy"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.remove(t)??[],update:(t,r)=>e.current?.update(t,r)??[],clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getScales:()=>e.current?.getScales()??null,getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("network"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>{const r=Array.isArray(t)?t:[t],o=e.current?.getTopology()?.nodes??[],n=[];for(const t of r){const r=o.find(e=>e.id===t);r&&n.push({...r.data??{},id:t}),e.current?.removeNode(t)}return n},update:(t,r)=>(Array.isArray(t)?t:[t]).flatMap(t=>{const o=e.current?.updateNode(t,r);return o?[{...o,id:t}]:[]}),clear:()=>e.current?.clear(),getData:()=>e.current?.getTopology()?.nodes?.map(e=>e.data)??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("geo-points"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.removePoint(t)??[],update:(t,r)=>{const o=e.current?.removePoint(t)??[];for(const t of o)e.current?.push(r(t));return o},clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}const r=t;return{push:e=>r.current?.pushLine(e),pushMany:e=>r.current?.pushManyLines(e),remove:e=>r.current?.removeLine(e)??[],update:(e,t)=>{const o=r.current?.removeLine(e)??[];for(const e of o)r.current?.pushLine(t(e));return o},clear:()=>r.current?.clear(),getData:()=>r.current?.getLines()??[],getCustomLayout:()=>r.current?.getCustomLayout?.()??null,getLayoutFailure:()=>r.current?.getLayoutFailure?.()??null}}(r,o);return{...e,...n}},[o,n,r])}function S(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return e??((...e)=>({}));const r={};return void 0!==t.stroke&&(r.stroke=t.stroke),void 0!==t.strokeWidth&&(r.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(r.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...r}):(...e)=>({...r})}function H(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}import{useMemo as w,useRef as B}from"react";function D(e){const t=B(null);return C(e.imperativeRef,{variant:e.imperativeVariant,frameRef:t}),{frameRef:t,resolved:l(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),normalizedMargin:w(()=>H(e.margin),[e.margin])}}function M(e){const t=D(e),{resolved:r,normalizedMargin:o}=t,n=k({data:e.data??[],rawData:e.data,colorBy:e.colorBy,colorScheme:e.colorScheme,legendInteraction:void 0,selection:e.selection,linkedHover:e.linkedHover,fallbackFields:"string"==typeof e.colorBy?[e.colorBy]:[],unwrapData:e.unwrapData,onObservation:e.onObservation,onClick:e.onClick,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:e.chartTypeLabel,chartId:e.chartId,showLegend:r.showLegend,userMargin:o,marginDefaults:r.marginDefaults,loading:e.loading,loadingContent:e.loadingContent,emptyContent:e.emptyContent,width:r.width,height:r.height});return{...t,safeData:n.data,setup:n,earlyReturn:n.earlyReturn}}export{p as useResolvedSelection,k as useChartSetup,C as useFrameImperativeHandle,S as mergeShapeStyle,H as normalizePartialMargin,D as useCustomChartScaffold,M as useCustomChartSetup};
@@ -1,2 +0,0 @@
1
- "use client";
2
- import{validateNetworkData as e,validateObjectData as t}from"./chunk-chunk-JCG72SGW.module.min.js";import{mergeShapeStyle as o,useCustomChartScaffold as n,useFrameImperativeHandle as i,useResolvedSelection as r}from"./chunk-chunk-BHYTYMY2.module.min.js";import{StreamNetworkFrame_default as s,buildRibbonGeometry as a}from"./chunk-chunk-2UN3ANRN.module.min.js";import{buildBaseMetadataProps as l,buildCustomBehaviorProps as c}from"./chunk-chunk-FAKO3RGQ.module.min.js";import{mulberry32 as d}from"./chunk-chunk-SIRIJ3DY.module.min.js";import{composeStyleRules as m,makeNodeRuleContext as h}from"./chunk-chunk-EMO5NUGE.module.min.js";import{COLOR_SCHEMES as g,DEFAULT_COLORS as u,DEFAULT_SELECTION_OPACITY as f,DEPTH_PALETTE_COLORS as p,filterSparseArray as b,getColor as y,normalizeTooltip as v,resolveDefaultFill as k,resolveMobileInteraction as S,useChartLegendAndMargin as w,useChartMode as C,useChartSelection as T,useColorScale as A,useLegendInteraction as I,useThemeCategorical as M}from"./chunk-chunk-ODUZEEBH.module.min.js";import{getMin as H}from"./chunk-chunk-JJ2OOIET.module.min.js";import{ChartError as x,SafeRender as B,renderEmptyState as N,renderLoadingState as O}from"./chunk-chunk-ZCNBUZPL.module.min.js";import{forwardRef as D,useMemo as P}from"react";import{jsx as L}from"react/jsx-runtime";var E=D(function(e,t){const{nodes:o,edges:i,layout:r,layoutConfig:a,onLayoutError:d,nodeIDAccessor:m="id",sourceAccessor:h="source",targetAccessor:g="target",margin:u,className:f,colorBy:p,colorScheme:y,selection:v,linkedHover:k,onObservation:w,onClick:C,chartId:A,annotations:I,autoPlaceAnnotations:M,frameProps:H={}}=e,{frameRef:x,resolved:D,normalizedMargin:E}=n({imperativeRef:t,imperativeVariant:"network",margin:u,width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),W=P(()=>b(o),[o]),R=P(()=>b(i),[i]),z=P(()=>void 0===o&&void 0===i?void 0:[...W,...R],[i,o,R,W]),F=S(e.mobileInteraction,{mode:e.mode,width:D.width,mobileSemantics:e.mobileSemantics}),{customHoverBehavior:j,customClickBehavior:$,activeSelectionHook:_}=T({selection:v,linkedHover:k,fallbackFields:"string"==typeof p?[p]:[],onObservation:w,onClick:C,chartType:"NetworkCustomChart",chartId:A,colorByField:"string"==typeof p?p:void 0,mobileInteraction:F}),G=P(()=>_?.isActive?{isActive:!0,predicate:_.predicate}:null,[_?.isActive,_?.predicate]),{width:q,height:Y,enableHover:Z,title:J,description:U,summary:X,accessibleTable:K}=D,Q=O(e.loading,q,Y,e.loadingContent),V=Q?null:N(z,q,Y,e.emptyContent);if(Q||V)return Q||V;const ee={chartType:"force",...null!=o&&{nodes:W},...null!=i&&{edges:R},customNetworkLayout:r,layoutConfig:a,onLayoutError:d,nodeIDAccessor:m,sourceAccessor:h,targetAccessor:g,colorBy:p,colorScheme:y,size:[q,Y],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:E,enableHover:Z,...l({title:J,description:U,summary:X,accessibleTable:K,className:f,animate:e.animate,autoPlaceAnnotations:M}),...c({linkedHover:k,selection:v,onObservation:w,onClick:C,mobileInteraction:F,customHoverBehavior:j,customClickBehavior:$,linkedHoverInClickPredicate:!1}),layoutSelection:G,...null!=I&&{annotations:I},...H};return L(B,{componentName:"NetworkCustomChart",width:q,height:Y,children:L(s,{ref:x,...ee})})});E.displayName="NetworkCustomChart";import{useMemo as W,forwardRef as R,useRef as z}from"react";import{useMemo as F}from"react";function j(e,t){if(!e)return[];const o=[],n=e=>{o.push(e);const i="function"==typeof t?t(e):e[t];i&&Array.isArray(i)&&i.forEach(n)};return n(e),o}function $(e,t,o,n){if(e&&e.length>0)return e;const i=new Set;return t.forEach(e=>{const t="function"==typeof o?o(e):e[o],r="function"==typeof n?n(e):e[n];i.add(t),i.add(r)}),Array.from(i).map(e=>({id:e}))}function _(e){return"function"==typeof e?e:t=>t[e]||1}function G({edgeColorBy:e,colorBy:t,colorScale:o,nodeStyleFn:n,edgeOpacity:i,baseStyle:r={}}){return s=>{const a={fillOpacity:i,...r};if("function"==typeof e)a.fill=e(s);else if("source"===e){const e="object"==typeof s.source?s.source:null;t&&e?a.fill=y(e.data||e,t,o):e&&(a.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof s.target?s.target:null;t&&e?a.fill=y(e.data||e,t,o):e&&(a.fill=n(e,e.index).fill)}else"gradient"===e&&(a.fill="#999",a.fillOpacity=.7*i);return a}}function q(e){const{nodes:t,edges:o,inferNodes:n=!0,sourceAccessor:i="source",targetAccessor:r="target",colorBy:s,colorScheme:a,showLegend:l,legendPosition:c,legendInteraction:d,selection:m,linkedHover:h,onObservation:f,onClick:p,mobileInteraction:y,mobileSemantics:v,chartType:k,chartId:C,marginDefaults:H,userMargin:x,width:B,height:D,loading:P,loadingContent:L,emptyContent:E,emptyDataKey:W="edges"}=e,R=F(()=>b(o),[o]),z=F(()=>b(t),[t]),j=O(P,B,D,L),_=j?null:N("nodes"===W?void 0===t?void 0:z:void 0===o?void 0:R,B,D,E),G=F(()=>n?$(z,R,i,r):z,[n,z,R,i,r]),q=A(G,s,a),Y=M(),Z=F(()=>{if(Array.isArray(a))return a;if(Y&&Y.length>0)return Y;if("string"==typeof a){const e=g[a];if(Array.isArray(e)&&e.length>0)return e}return u},[a,Y]),J=F(()=>{if(!s)return[];const e=new Set;for(const t of G){const o="function"==typeof s?s(t):t[s];null!=o&&e.add(o+"")}return Array.from(e)},[G,s]),U=I(d,s,J),{legend:X,margin:K,legendPosition:Q}=w({data:G,colorBy:s,colorScale:q,showLegend:l,legendPosition:c,userMargin:x,defaults:H,categories:J}),V=F(()=>S(y,{width:B,mobileSemantics:v}),[y,B,v]),ee=T({selection:m,linkedHover:h,fallbackFields:s?["string"==typeof s?s:""]:[],unwrapData:!0,onObservation:f,onClick:p,mobileInteraction:V,chartType:k,chartId:C}),{customHoverBehavior:te,customClickBehavior:oe,activeSelectionHook:ne,hoverSelectionHook:ie,crosshairSourceId:re}=ee;return{safeNodes:G,safeEdges:R,colorScale:q,effectivePalette:Z,themeCategorical:Y,allCategories:J,legendState:U,legend:X,margin:K,legendPosition:Q,mobileInteraction:V,customHoverBehavior:te,customClickBehavior:oe,activeSelectionHook:ne,hoverSelectionHook:ie,crosshairSourceId:re,loadingEl:j,emptyEl:_}}import{jsx as Y}from"react/jsx-runtime";var Z=R(function(t,n){const r=z(null);i(n,{variant:"network",frameRef:r});const a=C(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules},{width:600,height:600}),{nodes:l,edges:d,margin:g,className:u,nodeIdAccessor:f,nodeIDAccessor:p,sourceAccessor:b="source",targetAccessor:S="target",nodeLabel:w,colorBy:T,colorScheme:A,styleRules:I,nodeSize:M=8,nodeSizeRange:H=[5,20],edgeWidth:N=1,edgeColor:O="#999",edgeOpacity:D=.6,iterations:P=300,forceStrength:L=.1,layoutExecution:E="auto",layoutLoadingContent:R,onLayoutStateChange:F,tooltip:j,frameProps:$={},onObservation:_,onClick:G,chartId:Z,selection:J,linkedHover:U,loading:X,loadingContent:K,emptyContent:Q,legendInteraction:V,legendPosition:ee,stroke:te,strokeWidth:oe,opacity:ne}=t,ie=f??p??"id",{width:re,height:se,enableHover:ae,showLegend:le,showLabels:ce=!1,title:de,description:me,summary:he,accessibleTable:ge}=a,ue=q({nodes:l,edges:d,inferNodes:!1,nodeIdAccessor:ie,sourceAccessor:b,targetAccessor:S,colorBy:T,colorScheme:A,showLegend:le,legendPosition:ee,legendInteraction:V,selection:J,linkedHover:U,onObservation:_,onClick:G,mobileInteraction:a.mobileInteraction,mobileSemantics:a.mobileSemantics,chartType:"ForceDirectedGraph",chartId:Z,marginDefaults:a.marginDefaults,userMargin:g,width:re,height:se,loading:X,loadingContent:K,emptyContent:Q,emptyDataKey:"nodes"}),fe=W(()=>new Map,[]),pe=W(()=>e=>{const t={};return t.fill=T?y(e.data||e,T,ue.colorScale):k(void 0,ue.themeCategorical,A,void 0,fe),"number"==typeof M&&(t.r=M),t},[T,ue.colorScale,M,ue.themeCategorical,A,fe]),be=W(()=>h(T,"number"==typeof M?void 0:M),[T,M]),ye=W(()=>o(m(pe,I,be,e=>e.data||e),{stroke:te,strokeWidth:oe,opacity:ne}),[pe,I,be,te,oe,ne]),ve=W(()=>e=>{const t=e.data||e;let o;if("number"==typeof N)o=N;else if("function"==typeof N)o=N(t);else{const e=t[N],n="number"==typeof e?e:Number(e);o=Number.isFinite(n)&&n>0?n:1}return{stroke:O,strokeWidth:o,opacity:D}},[N,O,D]),ke=W(()=>o(ve,{stroke:te,strokeWidth:oe,opacity:ne}),[ve,te,oe,ne]),Se=W(()=>{if(ce&&w)return"function"==typeof w?w:e=>e.data?.[w]??e[w]??e.id},[ce,w]),we=e({componentName:"ForceDirectedGraph",nodes:l,edges:d,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:ie}});return we?Y(x,{componentName:"ForceDirectedGraph",message:we,width:re,height:se}):ue.loadingEl?ue.loadingEl:ue.emptyEl?ue.emptyEl:Y(B,{componentName:"ForceDirectedGraph",width:re,height:se,children:Y(s,{ref:r,chartType:"force",...null!=l&&{nodes:ue.safeNodes},...null!=d&&{edges:ue.safeEdges},size:[re,se],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ue.margin,nodeIDAccessor:ie,sourceAccessor:b,targetAccessor:S,iterations:P,forceStrength:L,layoutExecution:E,layoutLoadingContent:R,onLayoutStateChange:F,nodeStyle:ye,edgeStyle:ke,colorBy:T,colorScheme:ue.effectivePalette,nodeSize:M,nodeSizeRange:H,nodeLabel:Se,showLabels:ce,enableHover:ae,tooltipContent:!1===j?()=>null:v(j)||void 0,...c({linkedHover:U,selection:J,onObservation:_,onClick:G,mobileInteraction:ue.mobileInteraction,customHoverBehavior:ue.customHoverBehavior,customClickBehavior:ue.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:ue.legend,legendPosition:ue.legendPosition,...V&&"none"!==V&&{legendHoverBehavior:ue.legendState.onLegendHover,legendClickBehavior:ue.legendState.onLegendClick,legendHighlightedCategory:ue.legendState.highlightedCategory,legendIsolatedCategories:ue.legendState.isolatedCategories},className:u,title:de,description:me,summary:he,accessibleTable:ge,...null!=t.animate&&{animate:t.animate},...$})})});Z.displayName="ForceDirectedGraph";import{useMemo as J,forwardRef as U,useRef as X}from"react";import{jsx as K}from"react/jsx-runtime";var Q=U(function(t,n){const r=X(null);i(n,{variant:"network",frameRef:r,overrides:{getData:()=>r.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const a=C(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules},{width:600,height:600}),{nodes:l,edges:d,margin:f,className:p,sourceAccessor:b="source",targetAccessor:S="target",valueAccessor:w="value",nodeIdAccessor:T="id",colorBy:A,colorScheme:I,styleRules:M,edgeColorBy:H="source",padAngle:N=.01,groupWidth:O=20,sortGroups:D,nodeLabel:P,edgeOpacity:L=.5,tooltip:E,frameProps:W={},onObservation:R,onClick:z,chartId:F,selection:j,linkedHover:$,loading:_,loadingContent:Y,emptyContent:Z,legendInteraction:U,stroke:Q,strokeWidth:V,opacity:ee}=t,{width:te,height:oe,enableHover:ne,showLabels:ie=!0,title:re,description:se,summary:ae,accessibleTable:le}=a,ce=q({nodes:l,edges:d,inferNodes:!0,nodeIdAccessor:T,sourceAccessor:b,targetAccessor:S,colorBy:A,colorScheme:I,showLegend:!1,legendInteraction:U,selection:j,linkedHover:$,onObservation:R,onClick:z,mobileInteraction:a.mobileInteraction,mobileSemantics:a.mobileSemantics,chartType:"ChordDiagram",chartId:F,marginDefaults:a.marginDefaults,userMargin:f,width:te,height:oe,loading:_,loadingContent:Y,emptyContent:Z}),de=J(()=>new Map,[]),me=ce.safeNodes.length>0,he=J(()=>{if(me)return(e,t)=>{const o={stroke:"black",strokeWidth:1};if(A)o.fill=y(e.data||e,A,ce.colorScale);else{const n=Array.isArray(I)?I:g[I]||u,i=Array.isArray(n)?n:u;o.fill=i[(e.index??t??0)%i.length]}return o}},[me,A,ce.colorScale,I]),ge=J(()=>h(A),[A]),ue=J(()=>{if(he||M&&M.length>0)return o(m(he,M,ge,e=>e.data||e),{stroke:Q,strokeWidth:V,opacity:ee})},[he,M,ge,Q,V,ee]),fe=J(()=>{if(me)return G({edgeColorBy:H,colorBy:A,colorScale:ce.colorScale,nodeStyleFn:ue||(e=>({fill:k(void 0,ce.themeCategorical,I,void 0,de)})),edgeOpacity:L,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:L}})},[me,H,A,ce.colorScale,ue,L,ce.themeCategorical,I,de]),pe=J(()=>fe?o(fe,{stroke:Q,strokeWidth:V,opacity:ee}):void 0,[fe,Q,V,ee]),be=J(()=>{if(!ie)return;const e=P||T;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[ie,P,T]),ye=e({componentName:"ChordDiagram",edges:d,edgesRequired:!0});return ye?K(x,{componentName:"ChordDiagram",message:ye,width:te,height:oe}):ce.loadingEl?ce.loadingEl:ce.emptyEl?ce.emptyEl:K(B,{componentName:"ChordDiagram",width:te,height:oe,children:K(s,{ref:r,chartType:"chord",...ce.safeNodes.length>0&&{nodes:ce.safeNodes},...null!=d&&{edges:ce.safeEdges},size:[te,oe],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ce.margin,nodeIDAccessor:T,sourceAccessor:b,targetAccessor:S,valueAccessor:w,padAngle:N,groupWidth:O,sortGroups:D,nodeStyle:ue,edgeStyle:pe,colorBy:A,colorScheme:ce.effectivePalette,edgeColorBy:H,edgeOpacity:L,nodeLabel:be,showLabels:ie,enableHover:ne,tooltipContent:!1===E?()=>null:v(E)||void 0,...c({linkedHover:$,selection:j,onObservation:R,onClick:z,mobileInteraction:ce.mobileInteraction,customHoverBehavior:ce.customHoverBehavior,customClickBehavior:ce.customClickBehavior,linkedHoverInClickPredicate:!1}),...U&&"none"!==U&&{legendHoverBehavior:ce.legendState.onLegendHover,legendClickBehavior:ce.legendState.onLegendClick,legendHighlightedCategory:ce.legendState.highlightedCategory,legendIsolatedCategories:ce.legendState.isolatedCategories},className:p,title:re,description:se,summary:ae,accessibleTable:le,...null!=t.animate&&{animate:t.animate},...W})})});Q.displayName="ChordDiagram";import{useMemo as V,forwardRef as ee,useRef as te}from"react";import{jsx as oe}from"react/jsx-runtime";var ne=ee(function(t,n){const r=te(null);i(n,{variant:"network",frameRef:r,overrides:{getData:()=>r.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const a=C(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules},{width:800,height:600}),{nodes:l,edges:d,margin:g,className:u,sourceAccessor:f="source",targetAccessor:p="target",valueAccessor:b="value",nodeIdAccessor:S="id",colorBy:w,colorScheme:T,styleRules:A,edgeColorBy:I="source",orientation:M="horizontal",nodeAlign:H="justify",nodePaddingRatio:N=.05,nodeWidth:O=15,nodeLabel:D,edgeOpacity:P=.5,edgeSort:L,tooltip:E,frameProps:W={},onObservation:R,onClick:z,chartId:F,selection:j,linkedHover:$,loading:_,loadingContent:Y,emptyContent:Z,showLegend:J,legendPosition:U,legendInteraction:X,stroke:K,strokeWidth:Q,opacity:ee}=t,{width:ne,height:ie,enableHover:re,showLabels:se=!0,title:ae,description:le,summary:ce,accessibleTable:de}=a,me=q({nodes:l,edges:d,inferNodes:!0,nodeIdAccessor:S,sourceAccessor:f,targetAccessor:p,colorBy:w,colorScheme:T,showLegend:J,legendPosition:U,legendInteraction:X,selection:j,linkedHover:$,onObservation:R,onClick:z,mobileInteraction:a.mobileInteraction,mobileSemantics:a.mobileSemantics,chartType:"SankeyDiagram",chartId:F,marginDefaults:a.marginDefaults,userMargin:g,width:ne,height:ie,loading:_,loadingContent:Y,emptyContent:Z}),he=V(()=>new Map,[]),ge=V(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=w?y(e.data||e,w,me.colorScale):k(void 0,me.themeCategorical,T,void 0,he),t},[w,me.colorScale,me.themeCategorical,T,he]),ue=V(()=>h(w,b),[w,b]),fe=V(()=>o(m(ge,A,ue,e=>e.data||e),{stroke:K,strokeWidth:Q,opacity:ee}),[ge,A,ue,K,Q,ee]),pe=V(()=>G({edgeColorBy:I,colorBy:w,colorScale:me.colorScale,nodeStyleFn:fe,edgeOpacity:P,baseStyle:{stroke:"none",strokeWidth:0}}),[I,w,me.colorScale,fe,P]),be=V(()=>o(pe,{stroke:K,strokeWidth:Q,opacity:ee}),[pe,K,Q,ee]),ye=V(()=>{if(!se)return;const e=D||S;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[se,D,S]),ve=e({componentName:"SankeyDiagram",edges:d,edgesRequired:!0});return ve?oe(x,{componentName:"SankeyDiagram",message:ve,width:ne,height:ie}):me.loadingEl?me.loadingEl:me.emptyEl?me.emptyEl:oe(B,{componentName:"SankeyDiagram",width:ne,height:ie,children:oe(s,{ref:r,chartType:"sankey",...me.safeNodes.length>0&&{nodes:me.safeNodes},...null!=d&&{edges:me.safeEdges},size:[ne,ie],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:me.margin,nodeIDAccessor:S,sourceAccessor:f,targetAccessor:p,valueAccessor:b,orientation:M,nodeAlign:H,nodePaddingRatio:N,nodeWidth:O,nodeStyle:fe,edgeStyle:be,colorBy:w,colorScheme:me.effectivePalette,edgeColorBy:I,edgeOpacity:P,edgeSort:L,nodeLabel:ye,showLabels:se,enableHover:re,tooltipContent:!1===E?()=>null:v(E)||void 0,...c({linkedHover:$,selection:j,onObservation:R,onClick:z,mobileInteraction:me.mobileInteraction,customHoverBehavior:me.customHoverBehavior,customClickBehavior:me.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:me.legend,legendPosition:me.legendPosition,...X&&"none"!==X&&{legendHoverBehavior:me.legendState.onLegendHover,legendClickBehavior:me.legendState.onLegendClick,legendHighlightedCategory:me.legendState.highlightedCategory,legendIsolatedCategories:me.legendState.isolatedCategories},className:u,title:ae,description:le,summary:ce,accessibleTable:de,...null!=t.animate&&{animate:t.animate},...W})})});function ie(e,t,o){const n=[],i=new Set(e.map(e=>e.id)),r=Array.isArray(o)&&2===o.length,s=r&&Number.isFinite(o[0])&&Number.isFinite(o[1]);r&&s&&s&&o[1]>=o[0]||n.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||n.push({kind:"invalid-node-time",id:t.id}));for(const e of t)i.has(e.source)||n.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),i.has(e.target)||n.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||n.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||n.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):n.push({kind:"invalid-edge-time",id:e.id});return n}function re(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:e.kind}function se(e,t,o){const n=t.incoming[e.id],i=t.outgoing[e.id],r=[];for(const e of n)r.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:o.get(e.id).targetSide});for(const e of i)r.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:o.get(e.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{r.sort((e,t)=>e.time-t.time||(s[e.kind]??99)-(s[t.kind]??99))},l=r.length?H(r.map(e=>e.time)):null,c=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,d=null!=c?c-1:null!=l&&Number.isFinite(l)?l-1:null,m=[...new Set(r.map(e=>e.time))].sort((e,t)=>e-t),h=new Map;for(let e=1;m.length>e;e++)h.set(m[e],m[e-1]);const g=e=>{const t=h.get(e);return null!=t?(t+e)/2:null!=d?d:e};a();const u=[];let f=0,p=0;for(const e of r)if("out"===e.kind){const t=Math.abs(e.delta);let o=t-("top"===e.side?f:p);if(o>0){const t="top"===e.side?"bot":"top",n=Math.min(o,"top"===t?f:p);if(n>0){const i=g(e.time);u.push({time:i,delta:-n,kind:"transfer-out",side:t}),u.push({time:i,delta:+n,kind:"transfer-in",side:e.side}),"top"===t?f-=n:p-=n,"top"===e.side?f+=n:p+=n,o-=n}o>0&&null!==d&&(u.push({time:d,delta:+o,kind:"create",side:e.side}),"top"===e.side?f+=o:p+=o)}"top"===e.side?f-=t:p-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?f+=t:p+=t}r.push(...u),a();let b=0,y=0,v=0,k=0,S=0;const w=[],C=new Map;for(const e of r){if(w.push({t:e.time,topMass:b,botMass:y}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?b:y;C.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta)})}"top"===e.side?b+=e.delta:y+=e.delta,b+y>v&&(v=b+y),b>k&&(k=b),y>S&&(S=y),w.push({t:e.time,topMass:b,botMass:y})}const T=[];let A=0;for(;w.length>A;){let e=A;for(;w.length>e+1&&w[e+1].t===w[A].t;)e++;T.push(w[A]);for(let t=A+1;e>=t;t++){const e=T[T.length-1];w[t].topMass===e.topMass&&w[t].botMass===e.botMass||T.push(w[t])}A=e+1}const I=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let M=null;for(const e of i)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===M||M>e.systemInTime)&&(M=e.systemInTime);let x=null;for(const e of n)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===x||e.systemOutTime>x)&&(x=e.systemOutTime);if(T.length>0){const e=T[T.length-1],t=Math.max(null!=I?I:-1/0,null!=x?x:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&T.push({t:t,topMass:e.topMass,botMass:e.botMass});const o=T[0],n=Math.min(null!=c?c:1/0,null!=M?M:1/0);Number.isFinite(n)&&o.t>n&&o.topMass+o.botMass>0&&T.unshift({t:n,topMass:o.topMass,botMass:o.botMass})}return{samples:T,peak:v,topPeak:k,botPeak:S,localAttachments:C}}function ae(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function le(e,t){return e.map(e=>({t:ae(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function ce(e,t,o){const n=e.value*o;if("out"===e.kind){const i=e.sideMassBefore*o;if("top"===e.side){const e=t-i;return[e,e+n]}const r=t+i;return[r-n,r]}const i=e.sideMassAfter*o;if("top"===e.side){const e=t-i;return[e,e+n]}const r=t+i;return[r-n,r]}function de(e,t){let o=0;for(let n=0;t.length>n;n++)for(let i=n+1;t.length>i;i++){const r=t[n],s=t[i];r.source!==s.source&&r.target!==s.target&&r.source!==s.target&&r.target!==s.source&&(Math.min(r.endTime,s.endTime)>Math.max(r.startTime,s.startTime)&&e[s.source]>e[r.source]!=e[s.target]>e[r.target]&&o++)}return o}function me(e,t){let o=0;for(const n of t)o+=Math.abs(e[n.source]-e[n.target])*(n.value||1);return o}function he(e,t){return 1e3*de(e,t)+me(e,t)}function ge(e,t){return{slots:e.map(e=>({peak:{...e.peak},occupants:e.occupants.slice()})),map:{...t}}}function ue(e,t,o){e.length>8||o.length>40?(function(e,t,o,n=6){const i=e.length;if(1>=i)return;let r=ge(e,t),s=he(t,o);for(let a=0;n>a;a++){const n=Array(i).fill(0),a=Array(i).fill(0);for(const e of o){const o=t[e.source],i=t[e.target];n[o]+=i*(e.value||1),a[o]+=e.value||1,n[i]+=o*(e.value||1),a[i]+=e.value||1}const l=Array.from({length:i},(e,t)=>t).sort((e,t)=>(a[e]>0?n[e]/a[e]:e)-(a[t]>0?n[t]/a[t]:t)),c=l.map(t=>e[t]),d=new Map;l.forEach((e,t)=>d.set(e,t));for(const e of Object.keys(t))t[e]=d.get(t[e]);e.length=0;for(const t of c)e.push(t);const m=he(t,o);if(s>m)s=m,r=ge(e,t);else if(m===s)break}!function(e,t,o){e.length=0;for(const t of o.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(o.map))t[e]=o.map[e]}(e,t,r)}(e,t,o,6),function(e,t,o,n=6){const i=e.length;if(1>=i)return;let r=he(t,o);for(let s=0;n>s;s++){let n=!1;for(let s=0;i-1>s;s++){const i=e[s];e[s]=e[s+1],e[s+1]=i;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s);const a=he(t,o);if(r>a)r=a,n=!0;else{const o=e[s];e[s]=e[s+1],e[s+1]=o;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s)}}if(!n)break}}(e,t,o,6)):function(e,t,o){const n=e.length;if(1>=n)return;const i={...t},r=Object.keys(i),s=Array.from({length:n},(e,t)=>t),a=s.slice(),l={...i};let c=s.slice(),d=1/0;const m=()=>{for(const e of r)l[e]=a[i[e]];const e=he(l,o);d>e&&(d=e,c=s.slice())},h=(e,t)=>{const o=s[e],n=s[t];s[e]=n,s[t]=o,a[o]=t,a[n]=e};m();const g=Array(n).fill(0);let u=0;for(;n>u;)u>g[u]?(h(u%2==0?0:g[u],u),m(),g[u]++,u=0):(g[u]=0,u++);const f=c.map(t=>e[t]),p=new Map;c.forEach((e,t)=>p.set(e,t));for(const e of Object.keys(t))t[e]=p.get(t[e]);e.length=0;for(const t of f)e.push(t)}(e,t,o)}function fe(e,t,o,n,i){const{plotH:r,padding:s,valueScale:a,packing:l,laneOrder:c,lifetimeMode:d="full"}=i,m={},h={};for(const t of e)m[t.id]=o[t.id].topPeak||0,h[t.id]=o[t.id].botPeak||0;const g="half"===d,u={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,o=Array.isArray(t.xExtent)?t.xExtent[1]:null;let i=null!=e&&Number.isFinite(e)?e:1/0,r=null!=o&&Number.isFinite(o)?o:-1/0;for(const e of n.outgoing[t.id]){i>e.startTime&&(i=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&i>e.systemInTime&&(i=e.systemInTime);const t=g?(e.startTime+e.endTime)/2:e.endTime;t>r&&(r=t)}for(const e of n.incoming[t.id]){const t=g?(e.startTime+e.endTime)/2:e.startTime;i>t&&(i=t),e.endTime>r&&(r=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>r&&(r=e.systemOutTime)}u[t.id]={start:Number.isFinite(i)?i:null,end:Number.isFinite(r)?r:null}}const f={},p=[];if("reuse"===l){const o=new Map;for(const t of e)o.set(t.id,0);const i=new Map;for(const t of e)i.set(t.id,0);for(const e of t)i.set(e.target,(i.get(e.target)??0)+1);const r=[];for(const t of e)0===(i.get(t.id)??0)&&r.push(t.id);for(;r.length;){const e=r.shift();for(const t of n.outgoing[e]??[]){const n=(o.get(e)??0)+1;n>(o.get(t.target)??0)&&o.set(t.target,n),i.set(t.target,i.get(t.target)-1),0===i.get(t.target)&&r.push(t.target)}}const s=[...e].filter(e=>null!==u[e.id].start).sort((e,t)=>{const n=o.get(e.id)??0,i=o.get(t.id)??0;return n!==i?n-i:u[e.id].start-u[t.id].start}),a=e.filter(e=>null===u[e.id].start);for(const e of[...s,...a]){const t=u[e.id];let o=-1;for(let e=0;p.length>e;e++){const n=p[e].occupants[p[e].occupants.length-1];if(null===t.start||void 0===n||t.start>=n.end){o=e;break}}-1===o&&(p.push({occupants:[],peak:{topPeak:0,botPeak:0}}),o=p.length-1),p[o].occupants.push({id:e.id,end:t?.end??-1/0}),p[o].peak.topPeak=Math.max(p[o].peak.topPeak,m[e.id]),p[o].peak.botPeak=Math.max(p[o].peak.botPeak,h[e.id]),f[e.id]=o}}else e.forEach((e,t)=>{p.push({occupants:[{id:e.id,end:u[e.id]?.end??-1/0}],peak:{topPeak:m[e.id],botPeak:h[e.id]}}),f[e.id]=t});let b=null,y=null,v=null,k=null;const S=()=>{b=de(f,t),v=me(f,t)},w=()=>{y=de(f,t),k=me(f,t)};"crossing-min"===c?(S(),ue(p,f,t),w()):"inside-out"===c?(S(),function(e,t){const o=e.length;if(1>=o)return;const n=e=>e.peak.topPeak+e.peak.botPeak,i=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>n(t.slot)-n(e.slot)),r=Array(o),s=Math.floor((o-1)/2);r[s]=i[0].idx;let a=s-1,l=s+1;for(let e=1;i.length>e;e++)e%2==1&&o>l||0>a?r[l++]=i[e].idx:r[a--]=i[e].idx;const c=r.map(t=>e[t]),d=new Map;r.forEach((e,t)=>d.set(e,t));for(const e of Object.keys(t))t[e]=d.get(t[e]);e.length=0;for(const t of c)e.push(t)}(p,f),w()):"crossing-min+inside-out"===c&&(S(),ue(p,f,t),function(e,t,o){const n=e.length;if(1>=n)return;const i=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),r=Math.floor((n-1)/2);let s=he(t,o);for(const{slot:a}of i){const i=e.indexOf(a);if(0>i)continue;const l=r;if(i===l)continue;const c=e[i];e.splice(i,1),e.splice(l,0,c);const d=new Map;for(let e=0;n>e;e++)d.set(e,e);if(l>i){for(let e=i+1;l>=e;e++)d.set(e,e-1);d.set(i,l)}else{for(let e=l;i>e;e++)d.set(e,e+1);d.set(i,l)}for(const e of Object.keys(t))t[e]=d.get(t[e]);const m=he(t,o);if(m>s){const o=e[l];e.splice(l,1),e.splice(i,0,o);const r=new Map;for(let e=0;n>e;e++)r.set(e,e);if(i>l){for(let e=l+1;i>=e;e++)r.set(e,e-1);r.set(l,i)}else{for(let e=i;l>e;e++)r.set(e,e+1);r.set(l,i)}for(const e of Object.keys(t))t[e]=r.get(t[e])}else s=m}}(p,f,t),w());const C=p.map(e=>{const t=new Map;for(const n of e.occupants){const e=o[n.id];if(e)for(const o of e.samples){const e=t.get(o.t)||{top:0,bot:0};t.set(o.t,{top:Math.max(e.top,o.topMass),bot:Math.max(e.bot,o.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),T=(e,t)=>{let o={top:0,bot:0};for(const[n,i]of e){if(n>t)break;o=i}return o},A=[];for(let e=0;p.length-1>e;e++){const t=C[e],o=C[e+1],n=new Set([...t.map(e=>e[0]),...o.map(e=>e[0])]);let i=0;for(const e of n){const n=T(t,e),r=T(o,e);n.bot+r.top>i&&(i=n.bot+r.top)}A.push(i)}const I=[];let M=s+(p[0]?.peak.topPeak??0)*a;p.length>0&&I.push(M);for(let e=1;p.length>e;e++)M+=A[e-1]*a+s,I.push(M);if(p.length>0&&(M+=p[p.length-1].peak.botPeak*a+s),M>r){const e=r/M;for(let t=0;I.length>t;t++)I[t]*=e}const H=0===p.length?0:p[0].peak.topPeak+A.reduce((e,t)=>e+t,0)+p[p.length-1].peak.botPeak,x={};for(const t of e)x[t.id]=I[f[t.id]];return{effectiveSlotsHeight:H,centerlines:x,laneLifetime:u,slots:p,slotByNode:f,slotCenter:I,crossingsBefore:b,crossingsAfter:y,lengthBefore:v,lengthAfter:k}}ne.displayName="SankeyDiagram";import{useMemo as pe,useState as be,useRef as ye,useCallback as ve}from"react";import{scaleTime as ke}from"d3-scale";import{forwardRef as Se}from"react";var we=e=>{const{bands:t=[],ribbons:o=[],showLabels:n=!0}=e.config,i=[];for(const e of o)i.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}});for(const e of t)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const o=e.gradientStubs[t];i.push({type:"bezier",pathD:o.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:o.x0,x1:o.x1,from:o.from,to:o.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of t)i.push({type:"bezier",pathD:e.pathD,style:{...e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86},stroke:e.stroke??e.fill,strokeWidth:e.strokeWidth??.5},datum:{__kind:"band",data:e.rawDatum,id:e.id}});const r=n?t.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:i,labels:r}};function Ce(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}import{Fragment as Te,jsx as Ae,jsxs as Ie}from"react/jsx-runtime";function Me(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function He(e,t){return"function"==typeof e?e(t):t[e]}var xe=Se(function(e,t){const{nodes:o,edges:n,domain:r,axisTicks:l=[],nodeIdAccessor:c="id",sourceAccessor:d="source",targetAccessor:m="target",valueAccessor:h="value",startTimeAccessor:g="startTime",endTimeAccessor:u="endTime",systemInTimeAccessor:f,systemOutTimeAccessor:p,xExtentAccessor:k="xExtent",edgeIdAccessor:S="id",colorBy:w,colorScheme:C,showLegend:T,legendPosition:A="right",pairing:I="temporal",packing:M="reuse",laneOrder:H="crossing-min",ribbonLane:x="both",lifetimeMode:B="half",showLaneRails:N=!1,showQualityReadout:O=!1,showLabels:D=!0,width:P=600,height:L=400,margin:E,title:W,description:R,summary:z,accessibleTable:F,responsiveWidth:j,responsiveHeight:_,loading:G,loadingContent:Y,emptyContent:Z,edgeOpacity:J=.35,timeFormat:U,valueFormat:X,tooltip:K,enableHover:Q=!0,onObservation:V,onClick:ee,showParticles:te=!1,particleStyle:oe,chartId:ne,frameProps:de={}}=e,[me,he]=be([]),[ge,ue]=be([]),Se=ye(me),xe=ye(ge);Se.current=me,xe.current=ge;const Be=ve(e=>{Se.current=e,he(e)},[]),Ne=ve(e=>{xe.current=e,ue(e)},[]),Oe=void 0!==n,De=b(Oe?n:me),Pe=pe(()=>{const e=b(o??[]),t=ge;if(0===e.length&&0===t.length)return $([],De,d,m);const n=new Set,i=[];for(const t of e){const e=He(c,t)+"";n.has(e)||(n.add(e),i.push(t))}for(const e of t){const t=He(c,e)+"";n.has(t)||(n.add(t),i.push(e))}const r=$([],De,d,m);for(const e of r)n.has(e.id)||(n.add(e.id),i.push(e));return i},[o,ge,De,c,d,m]),Le=ye(null),Ee=ve((e,t)=>{const o=He(S,e);return null!=o?o+"":`${He(d,e)}-${He(m,e)}-${t}`},[S,d,m]),We=ve(e=>{if(null==e)return!1;const t=e;return null!=He(d,t)&&null!=He(m,t)},[d,m]);i(t,{variant:"network",frameRef:Le,overrides:{push(e){if(We(e)){if(Oe)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");Be([...Se.current,e])}else Ne([...xe.current,e])},pushMany(e){const t=[],o=[];for(const n of e)We(n)?t.push(n):o.push(n);t.length>0&&(Oe?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):Be([...Se.current,...t])),o.length>0&&Ne([...xe.current,...o])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),o=[];if(!Oe){const e=Se.current,n=[];for(let i=0;e.length>i;i++){const r=e[i];t.has(Ee(r,i))?o.push(r):n.push(r)}n.length!==e.length&&Be(n)}const n=xe.current,i=[];for(const e of n){const n=He(c,e)+"";t.has(n)?o.push(e):i.push(e)}return i.length!==n.length&&Ne(i),o},update(e,t){const o=new Set(Array.isArray(e)?e:[e]),n=[];if(!Oe){let e=!1;const i=Se.current.map((i,r)=>o.has(Ee(i,r))?(n.push(i),e=!0,t(i)):i);e&&Be(i)}let i=!1;const r=xe.current.map(e=>{const r=He(c,e)+"";return o.has(r)?(n.push(e),i=!0,t(e)):e});return i&&Ne(r),n},clear(){Oe||Be([]),Ne([]),Le.current?.clear()},getData:()=>De??[],getScales:()=>null}});const Re=Ee,ze=ve(e=>He(c,e)+"",[c]),{nodes:Fe,edges:je,domain:$e,rawNodeById:_e,rawEdgeById:Ge}=pe(()=>{const e=(Pe??[]).map(e=>{const t={id:ze(e),__raw:e},o=k?He(k,e):null;if(Array.isArray(o)&&2===o.length){const e=Me(o[0]),n=Me(o[1]);Number.isFinite(e)&&Number.isFinite(n)&&(t.xExtent=[e,n])}return t}),t=(De??[]).map((e,t)=>{const o={id:Re(e,t),source:He(d,e)+"",target:He(m,e)+"",value:Number(He(h,e)),startTime:Me(He(g,e)),endTime:Me(He(u,e)),__raw:e};if(f){const t=Me(He(f,e));Number.isFinite(t)&&(o.systemInTime=t)}if(p){const t=Me(He(p,e));Number.isFinite(t)&&(o.systemOutTime=t)}return o}),o=[Me(r[0]),Me(r[1])],n=new Map;for(const t of e)null!=t.__raw&&n.set(t.id,t.__raw);const i=new Map;for(const e of t)null!=e.__raw&&i.set(e.id,e.__raw);return{nodes:e,edges:t,domain:o,rawNodeById:n,rawEdgeById:i}},[Pe,De,r,ze,Re,k,d,m,h,g,u,f,p]),qe=q({nodes:Pe,edges:De,inferNodes:!1,nodeIdAccessor:c,sourceAccessor:d,targetAccessor:m,colorBy:w,colorScheme:C,showLegend:!1,legendPosition:A,selection:void 0,linkedHover:void 0,onObservation:V,onClick:ee,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:"ProcessSankey",chartId:ne,marginDefaults:{top:30,right:80,bottom:40,left:80},userMargin:E,width:P,height:L,loading:G,loadingContent:Y,emptyContent:Z}),Ye=(T??!!w)&&!!w,Ze=ve(e=>null!=E&&("number"==typeof E||null!=E[e]),[E]),Je=pe(()=>{const e={...qe.margin};return Ye&&("right"===A&&!Ze("right")&&140>e.right?e.right=140:"bottom"===A&&!Ze("bottom")&&80>e.bottom&&(e.bottom=80)),e},[qe.margin,Ye,A,Ze]),Ue=P-Je.left-Je.right,Xe=L-Je.top-Je.bottom,Ke=pe(()=>ie(Fe,je,$e),[Fe,je,$e]),Qe=pe(()=>Ke.length>0?null:function(e,t,o){const{plotH:n,pairing:i="temporal",packing:r="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half"}=o,l=function(e,t){const o={},n={};for(const t of e)o[t.id]=[],n[t.id]=[];for(const e of t)n[e.source]&&n[e.source].push(e),o[e.target]&&o[e.target].push(e);return{incoming:o,outgoing:n}}(e,t),c=function(e,t,o,n="value"){const i="temporal"===n?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,r="temporal"===n?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,s=new Map;for(const e of t)s.set(e.id,{});const a=(e,t)=>{const o=new Map;for(const n of e){const e=n[t];o.has(e)||o.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const i=o.get(e);i.edges.push(n),i.total+=n.value,i.earliestStart=Math.min(i.earliestStart,n.startTime),i.latestEnd=Math.max(i.latestEnd,n.endTime)}const s=[...o.values()];s.sort("temporal"===n?(e,o)=>"target"===t?e.earliestStart-o.earliestStart:e.latestEnd-o.latestEnd:(e,t)=>t.total-e.total);for(const e of s)e.edges.sort("target"===t?r:i);return s};for(const t of e){const e=o.outgoing[t.id],n=o.incoming[t.id];if(0===n.length)a(e,"target").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).sourceSide=o});else if(0===e.length)a(n,"source").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).targetSide=o});else{const t=a(n,"source"),o=a(e,"target"),i=Math.max(t.length,o.length);for(let e=0;i>e;e++){const n=e%2==0?"top":"bot";if(t[e])for(const o of t[e].edges)s.get(o.id).targetSide=n;if(o[e])for(const t of o[e].edges)s.get(t.id).sourceSide=n}}}return s}(e,t,l,i);let d={};for(const t of e)d[t.id]=se(t,l,c);const m=fe(e,t,d,l,{plotH:n,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a}),h=new Set;for(const e of t){const t=m.slotByNode[e.source],o=m.slotByNode[e.target];if(void 0===t||void 0===o)continue;const n=c.get(e.id);t!==o?t>o?(n.sourceSide="top",n.targetSide="bot"):(n.sourceSide="bot",n.targetSide="top"):(h.add(e.id),n.sourceSide="bot",n.targetSide="bot")}for(const t of e){const e=l.outgoing[t.id],o=l.incoming[t.id],n=new Set(e.map(e=>c.get(e.id).sourceSide)),i=new Set(o.map(e=>c.get(e.id).targetSide));if(1===n.size&&o.length>0){const e=[...n][0];for(const t of o)m.slotByNode[t.source]===m.slotByNode[t.target]&&(c.get(t.id).targetSide=e)}if(1===i.size&&e.length>0){const t=[...i][0];for(const o of e)m.slotByNode[o.source]===m.slotByNode[o.target]&&(c.get(o.id).sourceSide=t)}}for(const t of e){const e=l.incoming[t.id],o=l.outgoing[t.id];if(0===e.length||0===o.length)continue;const n=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const o of e)"top"===c.get(o.id).targetSide?t.inTop+=o.value:t.inBot+=o.value;for(const e of o)"top"===c.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},i=(e,t)=>{const i=n(),r="top"===e?i.outTop-i.inTop:i.outBot-i.inBot,s="top"===t?i.inTop-i.outTop:i.inBot-i.outBot;if(0>=r||0>=s)return!1;const a=Math.min(r,s),l=o.filter(t=>!h.has(t.id)&&c.get(t.id).sourceSide===e&&a>=t.value).sort((e,t)=>t.value-e.value);return 0!==l.length&&(c.get(l[0].id).sourceSide=t,!0)};let r=o.length+1;for(;r-- >0&&(i("top","bot")||i("bot","top")););}d={};for(const t of e)d[t.id]=se(t,l,c);const g=fe(e,t,d,l,{plotH:n,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a}),u=g.effectiveSlotsHeight??g.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),f=Math.min(12,.35*n/Math.max(g.slots.length+1,1)),p=u>0?Math.max(0,(n-f*(g.slots.length+1))/u):1,b=fe(e,t,d,l,{plotH:n,padding:f,valueScale:p,packing:r,laneOrder:s,lifetimeMode:a});return{nodeData:d,sides:c,valueScale:p,padding:f,compressedPadding:12>f,centerlines:b.centerlines,laneLifetime:b.laneLifetime,slots:b.slots,slotByNode:b.slotByNode,crossingsBefore:b.crossingsBefore,crossingsAfter:b.crossingsAfter,lengthBefore:b.lengthBefore,lengthAfter:b.lengthAfter}}(Fe,je,{plotH:Xe,pairing:I,packing:M,laneOrder:H,lifetimeMode:B}),[Ke,Fe,je,Xe,I,M,H,B]),Ve=pe(()=>ke().domain($e).range([0,Ue]),[$e,Ue]),et=ve((e,t)=>{if(w&&Pe){const t=_e.get(e);if(t)return y(t,w,qe.colorScale)}return qe.effectivePalette[t%qe.effectivePalette.length]||"#475569"},[w,Pe,_e,qe.colorScale,qe.effectivePalette]),tt=pe(()=>{const e=new Map;return Fe.forEach((t,o)=>e.set(t.id,o)),e},[Fe]),ot=pe(()=>{if(!Qe)return{bands:[],ribbons:[]};const{centerlines:e,nodeData:t,valueScale:o}=Qe,n=[],i=[];return Fe.forEach((i,r)=>{const s=t[i.id];if(!s||0===s.samples.length)return;const a=function(e,t,o,n,i){if(0===e.length)return null;const r=le(e,i),s=e=>t-r[e].topMass*o,a=e=>t+r[e].botMass*o;let l=`M${n(r[0].t)},${s(0)}`;for(let e=1;r.length>e;e++)l+=` L${n(r[e].t)},${s(e)}`;l+=` L${n(r[r.length-1].t)},${a(r.length-1)}`;for(let e=r.length-2;e>=0;e--)l+=` L${n(r[e].t)},${a(e)}`;return l+" Z"}(s.samples,e[i.id],o,Ve,$e);if(!a)return;const l=le(s.samples,$e),c=l.find(e=>e.topMass+e.botMass>0)||l[0],d=e[i.id]+(c.botMass-c.topMass)*o/2,m=et(i.id,r),h=_e.get(i.id)??i,g=function(e,t,o,n,i){const r=o.nodeData[e];if(!r||0===r.samples.length)return[];const s=o.valueScale,a=o.centerlines[e],l=le(r.samples,i),c=l.find(e=>e.topMass+e.botMass>0)||l[0],d=[...l].reverse().find(e=>e.topMass+e.botMass>0)||l[l.length-1],m=n(c.t),h=n(d.t),g=e=>n(ae(e,i)),u=[],f=(e,t,o,n)=>`M${e},${t} L${o},${t} L${o},${n} L${e},${n} Z`;for(const o of t){if(o.source===e&&null!=o.systemInTime&&Number.isFinite(o.systemInTime)){const e=r.localAttachments.get(o.id);if(e&&"out"===e.kind&&o.startTime>o.systemInTime){const t=g(o.systemInTime),n=g(o.startTime),i=t-20,r=Math.max(m,i);if(n>r){const[o,l]=ce(e,a,s);u.push({pathD:f(r,o,n,l),x0:i,x1:t,from:0,to:1})}}}if(o.target===e&&null!=o.systemOutTime&&Number.isFinite(o.systemOutTime)){const e=r.localAttachments.get(o.id);if(e&&"in"===e.kind&&o.systemOutTime>o.endTime){const t=g(o.systemOutTime),n=g(o.endTime),i=t+20,r=Math.min(h,i);if(r>n){const[o,l]=ce(e,a,s);u.push({pathD:f(n,o,r,l),x0:t,x1:i,from:1,to:0})}}}}return u}(i.id,je,Qe,Ve,$e);n.push({id:i.id,pathD:a,fill:m,stroke:m,strokeWidth:.5,...g.length>0&&{gradientStubs:g},rawDatum:h,labelX:Ve(c.t)-4,labelY:d,labelText:i.id})}),je.forEach(n=>{const r=t[n.source]?.localAttachments.get(n.id),s=t[n.target]?.localAttachments.get(n.id);if(!r||!s)return;const l=tt.get(n.source)??0,c=et(n.source,l),d=function(e,t,o,n,i,r,s,a){const l=i,c=e=>a?Math.max(a[0],Math.min(a[1],e)):e,d=r(c(e.time)),m=r(c(o.time)),h=e.value*l,g=o.value*l,u=e.sideMassBefore*l,f=o.sideMassAfter*l;let p,b,y,v;"top"===e.side?(p=t-u,b=p+h):(b=t+u,p=b-h),"top"===o.side?(y=n-f,v=y+g):(v=n+f,y=v-g);const k="source"===s?d+.85*(m-d):"target"===s?d+.15*(m-d):(d+m)/2;return{sx:d,sTop:p,sBot:b,tx:m,tTop:y,tBot:v,cp1X:k,cp2X:k}}(r,e[n.source],s,e[n.target],o,Ve,x,$e),{pathD:m,bezier:h}=a(d),g=Ge.get(n.id)??n;i.push({id:n.id,pathD:m,fill:c,opacity:J,rawDatum:g,bezier:h})}),{bands:n,ribbons:i}},[Qe,Fe,je,Ve,$e,et,_e,Ge,x,J,tt]),nt=pe(()=>({bands:ot.bands,ribbons:ot.ribbons,showLabels:D}),[ot,D]),it=pe(()=>{if(!Ye||!w)return;const e=new Map;(Pe??[]).forEach((t,o)=>{const n=He(w,t),i=null==n?"":n+"";i&&!e.has(i)&&e.set(i,{label:i,color:et(ze(t),o)})});const t=Array.from(e.values());return 0!==t.length?{legendGroups:[{type:"fill",label:"",items:t,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0},[Ye,w,Pe,et,ze]),rt=pe(()=>!1!==K&&Q?void 0===K||!0===K?null:v(K)||null:null,[K,Q]),st=ve(e=>U?U(new Date(e)):Number.isFinite(e)?1e10>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2):new Date(e).toISOString().slice(0,10):"",[U]),at=ve(e=>X?X(e):e+"",[X]),lt=ve(e=>{if(!e||!e.data)return null;const t=e.data;if(!Ce(t))return null;const o=t.data;if(rt)return rt(o);if("band"===t.__kind){const e=t.id,o=Qe?function(e){if(!e)return[];const t=new Set,o=[];for(const n of e.samples){const e=n.topMass+n.botMass,i=`${n.t}:${e}`;t.has(i)||(t.add(i),o.push({t:n.t,total:e}))}return o}(Qe.nodeData[e]):[],n=5,i=o.length>n?o.length:null,r=function(e,t=5){if(t>=e.length)return e.slice();const o=[...e].sort((e,t)=>e.total-t.total),n=o.length-1,i=[{...o[0],mark:"min"},{...o[Math.floor(.25*n)],mark:"q25"},{...o[Math.floor(.5*n)],mark:"median"},{...o[Math.floor(.75*n)],mark:"q75"},{...o[n],mark:"max"}],r=new Set,s=[];for(const e of i)r.has(e.t)||(r.add(e.t),s.push(e));return s.sort((e,t)=>e.t-t.t)}(o,n);return Ie("div",{style:{minWidth:160},children:[Ae("div",{style:{fontWeight:600,marginBottom:4},children:e}),r.length>0&&Ie("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[Ae("thead",{children:Ie("tr",{style:{opacity:.6},children:[Ae("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),Ae("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=i&&Ae("th",{})]})}),Ae("tbody",{children:r.map((e,t)=>Ie("tr",{children:[Ae("td",{style:{paddingRight:8},children:st(e.t)}),Ae("td",{style:{textAlign:"right"},children:at(e.total)}),null!=i&&Ae("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:e.mark})]},t))})]}),null!=i&&Ie("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",r.length," of ",i," samples"]})]})}const n=o,i=He(d,n),r=He(m,n),s=He(h,n),a=He(g,n),l=He(u,n);return Ie("div",{style:{minWidth:160},children:[Ie("div",{style:{fontWeight:600,marginBottom:4},children:[i+""," → ",r+""]}),Ie("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=s&&Ie(Te,{children:[Ae("span",{style:{opacity:.6},children:"value"}),Ae("span",{style:{textAlign:"right"},children:at(Number(s))})]}),null!=a&&Ie(Te,{children:[Ae("span",{style:{opacity:.6},children:"start"}),Ae("span",{style:{textAlign:"right"},children:st(Me(a))})]}),null!=l&&Ie(Te,{children:[Ae("span",{style:{opacity:.6},children:"end"}),Ae("span",{style:{textAlign:"right"},children:st(Me(l))})]})]})]})},[Qe,rt,st,at,d,m,h,g,u]),ct=pe(()=>{if(!Qe)return null;const{centerlines:e,laneLifetime:t,nodeData:o,valueScale:n,compressedPadding:i,crossingsBefore:r,crossingsAfter:s,lengthBefore:a,lengthAfter:c}=Qe;let d=null,m=null;for(const e of Fe){const o=t[e.id];if(!o||null===o.start||null===o.end)continue;const n=Ve(o.start),i=Ve(o.end);(null===d||d>n)&&(d=n),(null===m||i>m)&&(m=i)}const h=e=>Math.max(0,Math.min(Ue,e)),g=h(d??0),u=Math.max(g,h(m??Ue));return Ie("g",{children:[O&&null!==(s??null)&&Ie("text",{x:Ue,y:-12,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:["crossings: ",r," → ",s," ","edge length: ",Math.round(a)," → ",Math.round(c)]}),i&&Ae("text",{x:Ue,y:2,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:"dense layout: lane gaps compressed"}),l.map((e,t)=>{const o=Ve(Me(e.date));return g-.5>o||o>u+.5?null:Ae("line",{x1:o,y1:0,x2:o,y2:Xe,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+t)}),N&&Fe.map((i,r)=>{const s=t[i.id];if(!s||null===s.start)return null;const a=o[i.id],l=a?{topPeak:a.topPeak,botPeak:a.botPeak}:{topPeak:0,botPeak:0},c=e[i.id]+(l.botPeak-l.topPeak)*n/2,d=Ve(s.start),m=Ve(s.end),h=et(i.id,r);return Ie("g",{children:[Ae("line",{x1:d,y1:c,x2:m,y2:c,stroke:h,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),Ae("line",{x1:d,y1:c-4,x2:d,y2:c+4,stroke:h,strokeOpacity:.5}),Ae("line",{x1:m,y1:c-4,x2:m,y2:c+4,stroke:h,strokeOpacity:.5})]},"lane-"+i.id)}),Ae("line",{x1:g,y1:Xe+4,x2:u,y2:Xe+4,stroke:"#94a3b8"}),l.map((e,t)=>{const o=Me(e.date),n=Ve(o);if(g-.5>n||n>u+.5)return null;const i=null!=e.label?e.label:U?U(new Date(o)):"";return Ie("g",{transform:`translate(${n},${Xe+4})`,children:[Ae("line",{y2:6,stroke:"#94a3b8"}),Ae("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569",children:i})]},t)})]})},[Qe,l,Ve,Ue,Xe,N,Fe,et,O,U]),dt=pe(()=>(Pe??[]).map(e=>({id:ze(e),data:e})),[Pe,ze]),mt=pe(()=>{const e=new Map;for(const t of ot.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[ot]),ht=pe(()=>(De??[]).map((e,t)=>{const o=Re(e,t),n=Number(He(h,e));return{id:o,source:He(d,e)+"",target:He(m,e)+"",value:Number.isFinite(n)?n:0,bezier:mt.get(o),data:e}}),[De,Re,d,m,h,mt]),gt=qe.loadingEl,ut=qe.emptyEl;return Ke.length>0?Ie("svg",{width:P,height:L,role:"img","aria-label":W??"Process Sankey validation failed",children:[Ae("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),Ke.map((e,t)=>Ae("text",{x:20,y:56+18*t,fontSize:12,fill:"#64748b",children:"• "+re(e)},t))]}):gt||ut||Ae(s,{ref:Le,chartType:"force",nodes:dt,edges:ht,customNetworkLayout:we,layoutConfig:nt,size:[P,L],responsiveWidth:j,responsiveHeight:_,margin:Je,title:W,description:R??"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:z,accessibleTable:F,enableHover:Q,tooltipContent:!1===K?()=>null:lt,backgroundGraphics:ct,showParticles:te,particleStyle:oe,legend:it,legendPosition:A,onObservation:V,...ee&&{customClickBehavior:e=>{if(!e||!e.data||!ee)return;const t=e.data;Ce(t)&&ee(t.data,{x:e.x,y:e.y})}},chartId:ne,colorScheme:Array.isArray(C)?C:void 0,...de})});xe.displayName="ProcessSankey";import{useMemo as Be}from"react";import{jsx as Ne}from"react/jsx-runtime";function Oe(e){const n=C(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:i,margin:r,className:a,layout:l="tree",orientation:d="vertical",childrenAccessor:m="children",valueAccessor:h="value",nodeIdAccessor:g="name",colorBy:u,colorScheme:f,colorByDepth:b=!1,edgeStyle:S="curve",nodeLabel:w,nodeSize:T=5,tooltip:A,frameProps:I={},onObservation:M,onClick:H,chartId:N,selection:O,linkedHover:D,loading:P,loadingContent:L,legendInteraction:E,stroke:W,strokeWidth:R,opacity:z}=e,{width:F,height:$,enableHover:G,showLabels:Y=!0,title:Z,description:J,summary:U,accessibleTable:X}=n,K=q({nodes:Be(()=>j(i??null,m),[i,m]),edges:void 0,inferNodes:!1,colorBy:b?void 0:u,colorScheme:f,showLegend:!1,legendInteraction:E,selection:O,linkedHover:D,onObservation:M,onClick:H,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"TreeDiagram",chartId:N,marginDefaults:n.marginDefaults,userMargin:r,width:F,height:$,loading:P,loadingContent:L}),Q=Be(()=>new Map,[]),V=Be(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=b?p[(e.depth||0)%p.length]:u?y(e.data||e,u,K.colorScale):k(void 0,K.themeCategorical,f,void 0,Q),t},[u,b,K.colorScale,K.themeCategorical,f,Q]),ee=Be(()=>o(V,{stroke:W,strokeWidth:R,opacity:z}),[V,W,R,z]),te=Be(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),oe=Be(()=>o(te,{stroke:W,strokeWidth:R,opacity:z}),[te,W,R,z]),ne=Be(()=>{if("treemap"===l||"circlepack"===l||"partition"===l)return _(h)},[l,h]),ie=t({componentName:"TreeDiagram",data:i});return ie?Ne(x,{componentName:"TreeDiagram",message:ie,width:F,height:$}):K.loadingEl?K.loadingEl:Ne(B,{componentName:"TreeDiagram",width:F,height:$,children:Ne(s,{chartType:l,...null!=i&&{data:i},size:[F,$],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:K.margin,nodeIDAccessor:g,childrenAccessor:m,hierarchySum:ne,treeOrientation:d,edgeType:S,nodeStyle:ee,edgeStyle:oe,colorBy:u,colorScheme:K.effectivePalette,colorByDepth:b,nodeSize:T,nodeLabel:Y?w||g:void 0,showLabels:Y,enableHover:G,tooltipContent:!1===A?()=>null:v(A)||void 0,...c({linkedHover:D,selection:O,onObservation:M,onClick:H,mobileInteraction:K.mobileInteraction,customHoverBehavior:K.customHoverBehavior,customClickBehavior:K.customClickBehavior,linkedHoverInClickPredicate:!1}),...E&&"none"!==E&&{legendHoverBehavior:K.legendState.onLegendHover,legendClickBehavior:K.legendState.onLegendClick,legendHighlightedCategory:K.legendState.highlightedCategory,legendIsolatedCategories:K.legendState.isolatedCategories},className:a,title:Z,description:J,summary:U,accessibleTable:X,...null!=e.animate&&{animate:e.animate},...I})})}Oe.displayName="TreeDiagram";import{useMemo as De,useCallback as Pe}from"react";import{jsx as Le}from"react/jsx-runtime";function Ee(e){const n=C(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,linkedHover:e.linkedHover,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:i,margin:a,className:l,childrenAccessor:d="children",valueAccessor:m="value",nodeIdAccessor:h="name",colorBy:g,colorScheme:u,colorByDepth:b=!1,labelMode:S="leaf",nodeLabel:w,padding:T=4,paddingTop:A,nodeStyle:I,tooltip:M,frameProps:H={},selection:N,linkedHover:O,onObservation:D,onClick:P,chartId:L,loading:E,loadingContent:W,legendInteraction:R,stroke:z,strokeWidth:F,opacity:$}=e,{nodeStyle:G,...Y}=H,{width:Z,height:J,enableHover:U,showLabels:X=!0,title:K,description:Q,summary:V,accessibleTable:ee}=n,te=q({nodes:De(()=>j(i??null,d),[i,d]),edges:void 0,inferNodes:!1,colorBy:b?void 0:g,colorScheme:u,showLegend:!1,legendInteraction:R,selection:N,linkedHover:O,onObservation:D,onClick:P,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"Treemap",chartId:L,marginDefaults:n.marginDefaults,userMargin:a,width:Z,height:J,loading:E,loadingContent:W}),oe=r(N),ne=te.customHoverBehavior,ie=Pe(e=>{if(!e)return ne(null);const t=e.data||e;ne({data:t?.data||t})},[ne]),re=De(()=>new Map,[]),se=De(()=>e=>{const t={stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8};return t.fill=b?p[(e.depth||0)%p.length]:g?y(e.data||e,g,te.colorScale):k(void 0,te.themeCategorical,u,void 0,re),t},[g,b,te.colorScale,te.themeCategorical,u,re]),ae=De(()=>I||G?e=>({...se(e),...G?G(e)??{}:{},...I?I(e)??{}:{}}):se,[se,I,G]),le=De(()=>o(ae,{stroke:z,strokeWidth:F,opacity:$}),[ae,z,F,$]),ce=De(()=>te.activeSelectionHook?e=>{const t={...le(e)};if(te.activeSelectionHook.isActive)if(te.activeSelectionHook.predicate(e.data||e))oe?.selectedStyle&&Object.assign(t,oe.selectedStyle);else{const e=oe?.unselectedOpacity??f;t.opacity=e,t.fillOpacity=e,t.strokeOpacity=e,oe?.unselectedStyle&&Object.assign(t,oe.unselectedStyle)}return t}:le,[le,te.activeSelectionHook,oe]),de=De(()=>_(m),[m]),me=void 0!==A?A:!X||"parent"!==S&&"all"!==S?void 0:18,he=t({componentName:"Treemap",data:i});return he?Le(x,{componentName:"Treemap",message:he,width:Z,height:J}):te.loadingEl?te.loadingEl:Le(B,{componentName:"Treemap",width:Z,height:J,children:Le(s,{chartType:"treemap",...null!=i&&{data:i},size:[Z,J],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:te.margin,nodeIDAccessor:h,childrenAccessor:d,hierarchySum:de,padding:T,paddingTop:me,nodeStyle:ce,colorBy:g,colorScheme:te.effectivePalette,colorByDepth:b,nodeLabel:X?w||h:void 0,showLabels:X,labelMode:S,enableHover:U,tooltipContent:!1===M?()=>null:v(M)||void 0,...c({linkedHover:O,selection:N,onObservation:D,onClick:P,mobileInteraction:te.mobileInteraction,customHoverBehavior:ie,customClickBehavior:te.customClickBehavior,linkedHoverInClickPredicate:!1}),...R&&"none"!==R&&{legendHoverBehavior:te.legendState.onLegendHover,legendClickBehavior:te.legendState.onLegendClick,legendHighlightedCategory:te.legendState.highlightedCategory,legendIsolatedCategories:te.legendState.isolatedCategories},className:l,title:K,description:Q,summary:V,accessibleTable:ee,...null!=e.animate&&{animate:e.animate},...Y})})}Ee.displayName="Treemap";import{useMemo as We}from"react";import{jsx as Re}from"react/jsx-runtime";function ze(e){const n=C(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:i,margin:r,className:a,childrenAccessor:l="children",valueAccessor:d="value",nodeIdAccessor:m="name",colorBy:h,colorScheme:g,colorByDepth:u=!1,nodeLabel:f,circleOpacity:b=.7,padding:S=4,tooltip:w,frameProps:T={},onObservation:A,onClick:I,chartId:M,selection:H,linkedHover:N,loading:O,loadingContent:D,legendInteraction:P,stroke:L,strokeWidth:E,opacity:W}=e,{width:R,height:z,enableHover:F,showLabels:$=!0,title:G,description:Y,summary:Z,accessibleTable:J}=n,U=q({nodes:We(()=>j(i??null,l),[i,l]),edges:void 0,inferNodes:!1,colorBy:u?void 0:h,colorScheme:g,showLegend:!1,legendInteraction:P,selection:H,linkedHover:N,onObservation:A,onClick:I,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"CirclePack",chartId:M,marginDefaults:n.marginDefaults,userMargin:r,width:R,height:z,loading:O,loadingContent:D}),X=We(()=>new Map,[]),K=We(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:b};return t.fill=u?p[(e.depth||0)%p.length]:h?y(e.data||e,h,U.colorScale):k(void 0,U.themeCategorical,g,void 0,X),t},[h,u,U.colorScale,b,U.themeCategorical,g,X]),Q=We(()=>o(K,{stroke:L,strokeWidth:E,opacity:W}),[K,L,E,W]),V=We(()=>_(d),[d]),ee=t({componentName:"CirclePack",data:i});return ee?Re(x,{componentName:"CirclePack",message:ee,width:R,height:z}):U.loadingEl?U.loadingEl:Re(B,{componentName:"CirclePack",width:R,height:z,children:Re(s,{chartType:"circlepack",...null!=i&&{data:i},size:[R,z],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:U.margin,nodeIDAccessor:m,childrenAccessor:l,hierarchySum:V,padding:S,nodeStyle:Q,colorBy:h,colorScheme:U.effectivePalette,colorByDepth:u,nodeLabel:$?f||m:void 0,showLabels:$,enableHover:F,tooltipContent:!1===w?()=>null:v(w)||void 0,...c({linkedHover:N,selection:H,onObservation:A,onClick:I,mobileInteraction:U.mobileInteraction,customHoverBehavior:U.customHoverBehavior,customClickBehavior:U.customClickBehavior,linkedHoverInClickPredicate:!1}),...P&&"none"!==P&&{legendHoverBehavior:U.legendState.onLegendHover,legendClickBehavior:U.legendState.onLegendClick,legendHighlightedCategory:U.legendState.highlightedCategory,legendIsolatedCategories:U.legendState.isolatedCategories},className:a,title:G,description:Y,summary:Z,accessibleTable:J,...null!=e.animate&&{animate:e.animate},...T})})}ze.displayName="CirclePack";import{useMemo as Fe}from"react";import{jsx as je}from"react/jsx-runtime";var $e=p;function _e(e){const n=C(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:i,margin:r,className:a,childrenAccessor:l="children",nodeIdAccessor:d="name",colorBy:m,colorScheme:h,colorByDepth:f=!1,orbitMode:p="flat",orbitSize:b=2.95,speed:S=.25,revolution:w,revolutionStyle:T,eccentricity:A=1,showRings:I=!0,nodeRadius:M=6,showLabels:H=!1,animated:N=!0,tooltip:O,foregroundGraphics:D,annotations:P,frameProps:L={},onObservation:E,onClick:W,chartId:R,selection:z,linkedHover:F,loading:$,loadingContent:_,stroke:G,strokeWidth:Y,opacity:Z}=e,{width:J,height:U,enableHover:X,title:K,description:Q,summary:V,accessibleTable:ee}=n,te=q({nodes:Fe(()=>j(i,l),[i,l]),edges:void 0,inferNodes:!1,colorBy:f?void 0:m,colorScheme:h,showLegend:!1,legendInteraction:void 0,selection:z,linkedHover:F,onObservation:E,onClick:W,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"OrbitDiagram",chartId:R,marginDefaults:{top:10,right:10,bottom:10,left:10},userMargin:r,width:J,height:U,loading:$,loadingContent:_}),oe=Fe(()=>new Map,[]),{colorScale:ne,customClickBehavior:ie,customHoverBehavior:re,themeCategorical:se}=te,ae=Fe(()=>{if(Array.isArray(h))return h;const e=g[h];return Array.isArray(e)?e:u},[h]),le=Fe(()=>e=>{const t={stroke:"#fff",strokeWidth:1},o=0===(e.depth??0);return t.fill=f?o?ae[0]:$e[(e.depth||0)%$e.length]:m?y(e.data||e,m,ne):k(void 0,se,h,void 0,oe),t.opacity=o?1:.85,t},[m,f,ne,ae,se,h,oe]),ce=Fe(()=>o(le,{stroke:G,strokeWidth:Y,opacity:Z}),[le,G,Y,Z]),de=Fe(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),me=Fe(()=>e=>{re(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[re]),he=Fe(()=>e=>{ie(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[ie]),ge=t({componentName:"OrbitDiagram",data:i});return ge?je(x,{componentName:"OrbitDiagram",message:ge,width:J,height:U}):te.loadingEl?te.loadingEl:je(B,{componentName:"OrbitDiagram",width:J,height:U,children:je(s,{chartType:"orbit",...null!=i&&{data:i},size:[J,U],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:te.margin,nodeIDAccessor:d,childrenAccessor:l,nodeStyle:ce,edgeStyle:de,colorBy:m,colorScheme:te.effectivePalette,colorByDepth:f,nodeSize:M,nodeLabel:H?d:void 0,showLabels:H,enableHover:!N&&X,tooltipContent:N?void 0:!1===O?()=>null:v(O)||void 0,...c({linkedHover:F,selection:z,onObservation:E,onClick:W,mobileInteraction:te.mobileInteraction,customHoverBehavior:me,customClickBehavior:he,linkedHoverInClickPredicate:!1}),foregroundGraphics:D,annotations:P,className:a,title:K,description:Q,summary:V,orbitMode:p,orbitSize:b,orbitSpeed:S,orbitRevolution:w,orbitRevolutionStyle:T,orbitEccentricity:A,orbitShowRings:I,orbitAnimated:N,accessibleTable:ee,...null!=e.animate&&{animate:e.animate},...L})})}_e.displayName="OrbitDiagram";import{forceCenter as Ge,forceCollide as qe,forceLink as Ye,forceManyBody as Ze,forceSimulation as Je,forceX as Ue,forceY as Xe}from"d3-force";function Ke(e,t,o={}){const n=o.iterations??260,i=o.repulsion??5200,r=o.linkDistance??165,s=o.linkStrength??.045,a=o.centerStrength??.018,l=o.damping??.84,c=o.nodeRadius??12,m=o.nodePadding??3,h=o.inset??.06,g=d(o.seed??1),u=new Map;for(const t of e)u.set(t.id,0);for(const e of t)u.set(e.source,(u.get(e.source)??0)+1),u.set(e.target,(u.get(e.target)??0)+1);const f=500,p=e.map(e=>({id:e.id,data:e,x:200+600*g(),y:200+600*g()})),b=new Set(e.map(e=>e.id)),y=t.filter(e=>b.has(e.source)&&b.has(e.target)).map(e=>({source:e.source,target:e.target}));if(n>0){const e=Je(p).randomSource(g).alphaDecay(1-Math.pow(.001,1/n)).velocityDecay(Math.max(0,Math.min(1,1-l))).force("charge",Ze().strength(e=>{const t=u.get(e.id)??0;return 2.5*-Math.sqrt(i)*Math.sqrt(t+1)})).force("collide",qe(e=>(e=>"function"==typeof c?c(e.data):c)(e)+m).strength(.9).iterations(2)).force("center",Ge(f,f).strength(.8)).force("x",Ue(f).strength(a)).force("y",Xe(f).strength(a));y.length>0&&e.force("link",Ye(y).id(e=>e.id).distance(r).strength(e=>{const t="string"==typeof e.target?e.target:e.target.id,o=Math.max(1,Math.min(u.get("string"==typeof e.source?e.source:e.source.id)??1,u.get(t)??1));return s/.045/o})),e.stop();for(let t=0;n>t;t+=1)e.tick()}let v=1/0,k=1/0,S=-1/0,w=-1/0;for(const e of p){const t=e.x??f,o=e.y??f;v>t&&(v=t),k>o&&(k=o),t>S&&(S=t),o>w&&(w=o)}const C=S-v,T=w-k,A={};for(const e of p)A[e.id]={x:0===C?.5:h+((e.x??f)-v)/C*(1-2*h),y:0===T?.5:h+((e.y??f)-k)/T*(1-2*h)};return A}export{E as NetworkCustomChart,Z as ForceDirectedGraph,Q as ChordDiagram,ne as SankeyDiagram,ie as validateProcessSankey,re as formatProcessSankeyIssue,xe as ProcessSankey,Oe as TreeDiagram,Ee as Treemap,ze as CirclePack,_e as OrbitDiagram,Ke as forceLayout};
@@ -1 +0,0 @@
1
- import{hatchPatternDef as t,isHatchFill as e,resolveResponsiveRules as n,useObservationSelector as r}from"./chunk-chunk-2WVCH4PL.module.min.js";import{SEQUENTIAL_INTERPOLATORS as o,glyphFractionClipRect as i,glyphPlacement as s,resolveGlyphPaint as a,schemeCategory10 as l,schemeSet3 as c,schemeTableau10 as d,symbolPathString as u}from"./chunk-chunk-NO4MCQVD.module.min.js";import{createStore as h}from"./chunk-chunk-DSNGDNJY.module.min.js";var y=Object.freeze([]);function f(t){if(!t)return y;let e=!1;for(let n=0;t.length>n;n++){const r=t[n];if(null==r||"object"!=typeof r){e=!0;break}}if(!e)return t;const n=[];for(const e of t)null!=e&&"object"==typeof e&&n.push(e);return n}var p=/^\d{4}-\d{1,2}$/;function m(t){const e=t.trim();if(!e||!Number.isNaN(Number(e)))return NaN;const n=p.test(e)?e+"-01":e;if(n===e&&10>e.length)return NaN;const r=Date.parse(n);return Number.isFinite(r)?r:NaN}function g(t){return t instanceof Date?t.getTime():"string"==typeof t?m(t):+t}function k(t,e){if(!t||!e)return{data:t,failed:!1};let n=!1,r=!1;const o=t.map(t=>{const o=t[e];if("string"!=typeof o)return t;const i=m(o);return n=!0,Number.isFinite(i)?{...t,[e]:i}:(r=!0,{...t,[e]:NaN})});return{data:n?o:t,failed:r}}var $=22;function x(t){return"string"==typeof t&&t.length>0}function b(t,e,n=!1){const r=n?e?58:34:e?36:0;return r>t.top?{...t,top:r}:t}function v(t,e){return b(t,x(e))}import*as w from"react";import{arc as M}from"d3-shape";function A(t){return(t.tl??0)>0||(t.tr??0)>0||(t.br??0)>0||(t.bl??0)>0}function W(t){const e=t.cornerRadii;if(!e)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(t.w,t.h)/2,r=t=>Math.max(0,Math.min(t??0,n));return{tl:r(e.tl),tr:r(e.tr),br:r(e.br),bl:r(e.bl)}}var L=(t,e)=>({x:t*Math.cos(e),y:t*Math.sin(e)});function P(t){const{innerRadius:e,outerRadius:n,startAngle:r,endAngle:o}=t,i=0>=e;if(0>=(t.cornerRadius??0)||!t.roundStart&&!t.roundEnd){if(i){const t=L(n,r),e=L(n,o);return`M0,0 L${t.x},${t.y} A${n},${n} 0 ${o-r>Math.PI?1:0} 1 ${e.x},${e.y} Z`}const t=L(n,r),s=L(n,o),a=L(e,o),l=L(e,r),c=o-r>Math.PI?1:0;return`M${t.x},${t.y} A${n},${n} 0 ${c} 1 ${s.x},${s.y} L${a.x},${a.y} A${e},${e} 0 ${c} 0 ${l.x},${l.y} Z`}const s=Math.max(0,Math.min(t.cornerRadius??0,(n-e)/2));if(0===s)return P({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const a=Math.asin(Math.min(1,s/Math.max(1e-9,n-s))),l=i?0:Math.asin(Math.min(1,s/Math.max(1e-9,e+s))),c=o-r,d=t.roundStart&&t.roundEnd?c/2:c,u=!!t.roundStart&&d>a,h=!!t.roundEnd&&d>a;if(!u&&!h)return P({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const y=r+(u?a:0),f=o-(h?a:0),p=r+(u?l:0),m=o-(h?l:0),g=L(n,y),k=L(n,f),$=(n-s)*Math.cos(a),x=L($,r),b=L($,o),v=i?null:L(e,m),w=i?null:L(e,p),M=i?0:(e+s)*Math.cos(l),A=i?null:L(M,r),W=i?null:L(M,o),S=f-y>Math.PI?1:0,O=i?0:m-p>Math.PI?1:0;let R="";if(u)R+=`M${x.x},${x.y}`,R+=` A${s},${s} 0 0 1 ${g.x},${g.y}`;else{const t=L(n,r);R+=`M${t.x},${t.y}`}if(h)R+=` A${n},${n} 0 ${S} 1 ${k.x},${k.y}`,R+=` A${s},${s} 0 0 1 ${b.x},${b.y}`;else{const t=L(n,o);R+=` A${n},${n} 0 ${S} 1 ${t.x},${t.y}`}if(i)R+=" L0,0";else{if(h)R+=` L${W.x},${W.y}`,R+=` A${s},${s} 0 0 1 ${v.x},${v.y}`;else{const t=L(e,o);R+=` L${t.x},${t.y}`}if(u)R+=` A${e},${e} 0 ${O} 0 ${w.x},${w.y}`,R+=` A${s},${s} 0 0 1 ${A.x},${A.y}`;else{const t=L(e,r);R+=` A${e},${e} 0 ${O} 0 ${t.x},${t.y}`}}return R+=" Z",R}import{jsx as S,jsxs as O}from"react/jsx-runtime";var R={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function T(t,n="#4e79a7"){return e(t)?t.background&&"transparent"!==t.background?t.background:n:t&&"string"==typeof t?t:n}function I(t,e,n){const r=u(t.symbolType,t.size,t.path);return S("path",{d:r,transform:t.rotation?`translate(${t.x},${t.y}) rotate(${180*t.rotation/Math.PI})`:`translate(${t.x},${t.y})`,fill:t.style.fill?T(t.style.fill):"none",opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},`${n??""}symbol-${e}`)}function N(t,e,n,r){const o=t.glyph;if(!o?.parts?.length||0>=t.size)return null;const l=s(o,t.size);if(0>=l.scale)return null;const c=`translate(${e},${n})${t.rotation?` rotate(${180*t.rotation/Math.PI})`:""} translate(${l.offsetX},${l.offsetY}) scale(${l.scale})`,d=t.color??("string"==typeof t.style.fill?t.style.fill:void 0),u=i(o,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal"),h=u?j(r+"-clip"):void 0,y=(t.style.opacity??1)*(t._decayOpacity??1)*(t.style.fillOpacity??1),f=e=>o.parts.map((n,r)=>{const o=e?"none"===n.fill?void 0:e:a(n.fill,d,t.accent),i=e?n.stroke&&"none"!==n.stroke?e:void 0:a(n.stroke??"none",d,t.accent);return o||i?S("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 O("g",{transform:c,opacity:1===y?void 0:y,children:[u&&h&&S("clipPath",{id:h,children:S("rect",{x:u.x,y:u.y,width:u.width,height:u.height})}),u&&t.ghostColor?S("g",{children:f(t.ghostColor)}):null,u&&h?S("g",{clipPath:`url(#${h})`,children:f()}):f()]},r)}function j(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}function C(n,r,o){switch(n.type){case"line":{const t=n;if(0===t.path.length)return null;const e="M"+t.path.map(([t,e])=>`${t},${e}`).join("L");return S("path",{d:e,fill:"none",stroke:t.style.stroke||"#4e79a7",strokeWidth:t.style.strokeWidth||2,strokeDasharray:t.style.strokeDasharray,opacity:t.style.opacity},"line-"+r)}case"area":{const i=n;if(0===i.topPath.length)return null;const s=`M${i.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...i.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`,a=`${o?o+"-":""}area-${r}-hatch`,l=e(i.style.fill)?t(i.style.fill,a):void 0,c=l?`url(#${a})`:T(i.style.fill);if(i.clipRect){const t=`${o?o+"-":""}area-clip-${r}`;return O("g",{children:[O("defs",{children:[l,S("clipPath",{id:t,children:S("rect",{x:i.clipRect.x,y:i.clipRect.y,width:i.clipRect.width,height:i.clipRect.height})})]}),S("path",{d:s,fill:c,fillOpacity:i.style.fillOpacity??i.style.opacity??.7,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,clipPath:`url(#${t})`})]},"area-"+r)}return O(w.Fragment,{children:[l&&S("defs",{children:l}),S("path",{d:s,fill:c,fillOpacity:i.style.fillOpacity??i.style.opacity??.7,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},"area-"+r)}case"point":{const i=n,s=`${o?o+"-":""}point-${r}-hatch`,a=e(i.style.fill)?t(i.style.fill,s):void 0;return O(w.Fragment,{children:[a&&S("defs",{children:a}),S("circle",{cx:i.x,cy:i.y,r:i.r,fill:a?`url(#${s})`:T(i.style.fill),opacity:i.style.opacity??.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},"point-"+r)}case"symbol":return I(n,r);case"glyph":return N(n,n.x,n.y,`${o??""}glyph-${n.pointId??r}`);case"rect":{const i=n,s=`${o?o+"-":""}xyrect-${r}-hatch`,a=e(i.style.fill)?t(i.style.fill,s):void 0;return O(w.Fragment,{children:[a&&S("defs",{children:a}),S("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:a?`url(#${s})`:T(i.style.fill),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},"rect-"+r)}case"heatcell":{const t=n;if(t.showValues&&null!=t.value&&t.w>=20&&t.h>=20){const e=t.valueFormat?t.valueFormat(t.value):Number.isInteger(t.value)?t.value+"":100>Math.abs(t.value)?1>Math.abs(t.value)?t.value.toPrecision(3):t.value.toFixed(1):t.value.toFixed(0),[n,o,i]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t.fill),s=.299*n+.587*o+.114*i>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h)));return O("g",{children:[S("rect",{x:t.x,y:t.y,width:t.w,height:t.h,fill:t.fill}),S("text",{x:t.x+t.w/2,y:t.y+t.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px",children:e})]},"heatcell-"+r)}return S("rect",{x:t.x,y:t.y,width:t.w,height:t.h,fill:t.fill},"heatcell-"+r)}case"candlestick":{const t=n,e=Math.min(t.openY,t.closeY),o=Math.max(Math.abs(t.openY-t.closeY),1),i=t.isUp?t.upColor:t.downColor;return O("g",{children:[S("line",{x1:t.x,y1:t.highY,x2:t.x,y2:t.lowY,stroke:t.wickColor,strokeWidth:t.wickWidth}),S("rect",{x:t.x-t.bodyWidth/2,y:e,width:t.bodyWidth,height:o,fill:i,stroke:i,strokeWidth:1})]},"candle-"+r)}default:return null}}function D(n,r){switch(n.type){case"circle":{const o=n,i=e(o.style.fill)?t(o.style.fill,`net-circle-${r}-hatch`):void 0;return O(w.Fragment,{children:[i&&S("defs",{children:i}),S("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:i?`url(#net-circle-${r}-hatch)`:T(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})]},"net-circle-"+r)}case"rect":{const o=n,i=e(o.style.fill)?t(o.style.fill,`net-rect-${r}-hatch`):void 0;return O(w.Fragment,{children:[i&&S("defs",{children:i}),S("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:i?`url(#net-rect-${r}-hatch)`:T(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})]},"net-rect-"+r)}case"arc":{const o=n,i=M().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)(R)||"",s=e(o.style.fill)?t(o.style.fill,`net-arc-${r}-hatch`):void 0;return O(w.Fragment,{children:[s&&S("defs",{children:s}),S("path",{d:i,transform:`translate(${o.cx},${o.cy})`,fill:s?`url(#net-arc-${r}-hatch)`:T(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})]},"net-arc-"+r)}case"symbol":{const t=n,e=u(t.symbolType,t.size,t.path);return S("path",{d:e,transform:t.rotation?`translate(${t.cx},${t.cy}) rotate(${180*t.rotation/Math.PI})`:`translate(${t.cx},${t.cy})`,fill:t.style.fill?T(t.style.fill):"none",stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity},"net-symbol-"+r)}case"glyph":return N(n,n.cx,n.cy,"net-glyph-"+(n.id??r));default:return null}}function F(t,e){switch(t.type){case"line":return S("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity},"net-edge-"+e);case"bezier":{const n=t;return S("path",{d:n.pathD,fill:T(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+e)}case"ribbon":{const n=t;return S("path",{d:n.pathD,fill:T(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+e)}case"curved":{const n=t;return S("path",{d:n.pathD,fill:T(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+e)}default:return null}}function q(t,e){return S("text",{x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"var(--semiotic-text, #333)",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,children:t.text},"net-label-"+e)}function z(n,r,o){const i=("category"in n?n.category:void 0)||("group"in n?n.group:void 0)||"",s=t=>`ord-${n.type}-${i}-${r}-${t}`,a=`ord-${n.type}-${i}-${r}`;switch(n.type){case"rect":{const r=n,o=j(a)+"-grad",i=function(t,e){const n=t.fillGradient;if(!n||"object"!=typeof n)return null;let r=t.x,o=t.y,i=t.x,s=t.y+t.h;"bottom"===t.roundedEdge?(o=t.y+t.h,s=t.y):"right"===t.roundedEdge?(r=t.x+t.w,o=t.y,i=t.x,s=t.y):"left"===t.roundedEdge&&(r=t.x,o=t.y,i=t.x+t.w,s=t.y);const a=[];if("colorStops"in n){const t=n.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>t.length)return null;for(let e=0;t.length>e;e++)a.push(S("stop",{offset:t[e].offset,stopColor:t[e].color},e))}else{const e=T(t.style.fill);a.push(S("stop",{offset:0,stopColor:e,stopOpacity:n.topOpacity},"0")),a.push(S("stop",{offset:1,stopColor:e,stopOpacity:n.bottomOpacity},"1"))}return S("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:r,y1:o,x2:i,y2:s,children:a})}(r,o);let s,l;if(i)l=`url(#${o})`;else if(e(r.style.fill)){const e=j(a)+"-hatch";s=t(r.style.fill,e),l=`url(#${e})`}else l=T(r.style.fill);const c=i||s?O("defs",{children:[i,s]}):null;if(r.cornerRadii&&A(r.cornerRadii)){const t=function(t){const{x:e,y:n,w:r,h:o}=t,{tl:i,tr:s,br:a,bl:l}=W(t);let c=`M${e+i},${n}`;return c+=` L${e+r-s},${n}`,s>0&&(c+=` A${s},${s} 0 0 1 ${e+r},${n+s}`),c+=` L${e+r},${n+o-a}`,a>0&&(c+=` A${a},${a} 0 0 1 ${e+r-a},${n+o}`),c+=` L${e+l},${n+o}`,l>0&&(c+=` A${l},${l} 0 0 1 ${e},${n+o-l}`),c+=` L${e},${n+i}`,i>0&&(c+=` A${i},${i} 0 0 1 ${e+i},${n}`),c+=" Z",c}(r);return O(w.Fragment,{children:[c,S("path",{d:t,fill:l,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},a)}if(r.roundedTop&&r.roundedTop>0){const t=Math.min(r.roundedTop,r.w/2,r.h/2),{x:e,y:n,w:o,h:i}=r;let s;switch(r.roundedEdge){case"right":s=`M${e},${n} L${e+o-t},${n} A${t},${t} 0 0 1 ${e+o},${n+t} L${e+o},${n+i-t} A${t},${t} 0 0 1 ${e+o-t},${n+i} L${e},${n+i} Z`;break;case"left":s=`M${e+o},${n} L${e+t},${n} A${t},${t} 0 0 0 ${e},${n+t} L${e},${n+i-t} A${t},${t} 0 0 0 ${e+t},${n+i} L${e+o},${n+i} Z`;break;case"bottom":s=`M${e},${n} L${e+o},${n} L${e+o},${n+i-t} A${t},${t} 0 0 1 ${e+o-t},${n+i} L${e+t},${n+i} A${t},${t} 0 0 1 ${e},${n+i-t} Z`;break;default:s=`M${e},${n+i} L${e},${n+t} A${t},${t} 0 0 1 ${e+t},${n} L${e+o-t},${n} A${t},${t} 0 0 1 ${e+o},${n+t} L${e+o},${n+i} Z`}return O(w.Fragment,{children:[c,S("path",{d:s,fill:l,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},a)}return O(w.Fragment,{children:[c,S("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:l,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},a)}case"point":{const t=n;return S("circle",{cx:t.x,cy:t.y,r:t.r,fill:T(t.style.fill),opacity:t.style.opacity??.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},a)}case"symbol":return I(n,r,o);case"glyph":return N(n,n.x,n.y,`${o??""}ord-glyph-${n.pointId??r}`);case"wedge":{const t=n;if(t._gradientBand&&t._gradientBand.colors.length>0){const e=j(`${o?o+"-":""}gauge-grad-${t.category||a}-${r}`),{clipPath:n,slices:i}=function(t){const e=P({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundStart,roundEnd:t.roundEnd}),n=[],r=t.colors;if(r.length>0){const e=(t.endAngle-t.startAngle)/r.length;for(let o=0;r.length>o;o++)n.push({d:P({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+o*e,endAngle:t.endAngle}),color:r[o]})}return{clipPath:e,slices:n}}({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundedEnds?.start??!0,roundEnd:t.roundedEnds?.end??!0,colors:t._gradientBand.colors});return O("g",{transform:`translate(${t.cx},${t.cy})`,opacity:t.style.opacity,fillOpacity:t.style.fillOpacity,children:[S("defs",{children:S("clipPath",{id:e,children:S("path",{d:n})})}),S("g",{clipPath:`url(#${e})`,children:i.map((t,e)=>S("path",{d:t.d,fill:T(t.color)},e))}),t.style.stroke&&"none"!==t.style.stroke&&S("path",{d:n,fill:"none",stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},a)}let e;if(t.roundedEnds)e=P({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundedEnds.start,roundEnd:t.roundedEnds.end});else{const n=M().innerRadius(t.innerRadius).outerRadius(t.outerRadius).startAngle(t.startAngle+Math.PI/2).endAngle(t.endAngle+Math.PI/2);t.cornerRadius&&n.cornerRadius(t.cornerRadius),e=n(R)||""}return S("path",{d:e,transform:`translate(${t.cx},${t.cy})`,fill:T(t.style.fill),stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity},a)}case"boxplot":{const t=n,e=t.columnWidth/2;return O("g","vertical"===t.projection?{children:[S("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1}),S("rect",{x:t.x-e,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:T(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),S("line",{x1:t.x-e,y1:t.medianPos,x2:t.x+e,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2}),S("line",{x1:t.x-.5*e,y1:t.minPos,x2:t.x+.5*e,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:1}),S("line",{x1:t.x-.5*e,y1:t.maxPos,x2:t.x+.5*e,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1})]}:{children:[S("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:1}),S("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-e,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:T(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),S("line",{x1:t.medianPos,y1:t.y-e,x2:t.medianPos,y2:t.y+e,stroke:t.style.stroke||"#333",strokeWidth:2}),S("line",{x1:t.minPos,y1:t.y-.5*e,x2:t.minPos,y2:t.y+.5*e,stroke:t.style.stroke||"#333",strokeWidth:1}),S("line",{x1:t.maxPos,y1:t.y-.5*e,x2:t.maxPos,y2:t.y+.5*e,stroke:t.style.stroke||"#333",strokeWidth:1})]},a)}case"violin":{const t=n,e=[S("path",{d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:T(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:t.style.strokeWidth||1},s("path"))];if(t.iqrLine&&t.bounds){const n=t.bounds,r=n.x+n.width/2,o=n.y+n.height/2;n.height>n.width?e.push(S("line",{x1:r,y1:t.iqrLine.q1Pos,x2:r,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2},s("iqr")),S("circle",{cx:r,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},s("med"))):e.push(S("line",{x1:t.iqrLine.q1Pos,y1:o,x2:t.iqrLine.q3Pos,y2:o,stroke:t.style.stroke||"#333",strokeWidth:2},s("iqr")),S("circle",{cx:t.iqrLine.medianPos,cy:o,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},s("med")))}return S("g",{children:e},a)}case"connector":return S("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity??.5},a);case"trapezoid":{const t=n,e=t.points.map(t=>`${t[0]},${t[1]}`).join(" ");return S("polygon",{points:e,fill:T(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},a)}default:return null}}function H(n,r){switch(n.type){case"geoarea":{const o=n;if(!o.pathData)return null;const i=e(o.style.fill)?t(o.style.fill,`geoarea-${r}-hatch`):void 0;return O(w.Fragment,{children:[i&&S("defs",{children:i}),S("path",{d:o.pathData,fill:i?`url(#geoarea-${r}-hatch)`:T(o.style.fill,"#e0e0e0"),fillOpacity:o.style.fillOpacity??1,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth||.5,strokeDasharray:o.style.strokeDasharray,opacity:o._decayOpacity??1})]},"geoarea-"+r)}case"point":{const o=n,i=e(o.style.fill)?t(o.style.fill,`geopoint-${r}-hatch`):void 0;return O(w.Fragment,{children:[i&&S("defs",{children:i}),S("circle",{cx:o.x,cy:o.y,r:o.r,fill:i?`url(#geopoint-${r}-hatch)`:T(o.style.fill),fillOpacity:o.style.fillOpacity??.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o._decayOpacity??o.style.opacity??1})]},"point-"+r)}case"line":{const t=n;if(2>t.path.length)return null;const e="M"+t.path.map(t=>`${t[0]},${t[1]}`).join("L");return S("path",{d:e,fill:"none",stroke:t.style.stroke||"#4e79a7",strokeWidth:t.style.strokeWidth||1.5,strokeDasharray:t.style.strokeDasharray,opacity:t.style.opacity??1},"line-"+r)}case"glyph":return N(n,n.x,n.y,"geo-glyph-"+(n.pointId??r));default:return null}}var E="undefined"==typeof window||"undefined"==typeof document;function B(t){return"touch"===t?"touch":"pointer"}function _(t){const e=t.target;return e instanceof Element&&e!==t.currentTarget&&null!=e.closest("button, a[href], input, select, textarea, summary, [contenteditable='true'], [role='button'], [role='link'], [role='checkbox'], [role='radio'], [role='switch']")}function G(t){const{onObservation:e,datum:n,x:r=0,y:o=0,chartType:i,chartId:s,context:a,timestamp:l=Date.now()}=t;e&&(n?(e({type:"hover",datum:n,x:r,y:o,timestamp:l,chartType:i,chartId:s}),"focus"===a?.type&&e({type:"focus",datum:n,inputType:"touch"===a.inputType?"pointer":a.inputType,timestamp:l,chartType:i,chartId:s})):e({type:"hover-end",timestamp:l,chartType:i,chartId:s}))}function V(t){const{onObservation:e,datum:n,x:r=0,y:o=0,chartType:i,chartId:s,context:a,timestamp:l=Date.now()}=t;e&&(n?(e({type:"click",datum:n,x:r,y:o,timestamp:l,chartType:i,chartId:s}),"activate"===a?.type&&e({type:"activate",datum:n,inputType:a.inputType,timestamp:l,chartType:i,chartId:s})):e({type:"click-end",timestamp:l,chartType:i,chartId:s}))}import{useId as Z,useMemo as Y,useCallback as U}from"react";function X(t){const e=[];for(const[n,r]of Object.entries(t.fields))if("point"===r.type)e.push(t=>r.values.has(t[n]));else{const[t,o]=r.range;e.push(e=>{const r=e[n];return r>=t&&o>=r})}return t=>e.every(e=>e(t))}function Q(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}function J(t,e){if(t.type!==e.type)return!1;if("interval"===t.type&&"interval"===e.type)return t.range[0]===e.range[0]&&t.range[1]===e.range[1];if("point"===t.type&&"point"===e.type){if(t.values.size!==e.values.size)return!1;for(const n of t.values)if(!e.values.has(n))return!1;return!0}return!1}var[K,tt]=h(t=>({selections:new Map,setClause(e,n){t(t=>{const r=t.selections.get(e),o=r?.clauses.get(n.clientId);if(o&&function(t,e){if(t.clientId!==e.clientId||t.type!==e.type)return!1;const n=Object.entries(t.fields);if(n.length!==function(t){let e=0;for(const n in t)e++;return e}(e.fields))return!1;for(const[t,r]of n){const n=e.fields[t];if(!n||!J(r,n))return!1}return!0}(o,n))return{};const i=new Map(t.selections),s=Q(i,e),a=new Map(s.clauses);return a.set(n.clientId,n),i.set(e,{...s,clauses:a}),{selections:i}})},clearClause(e,n){t(t=>{const r=t.selections.get(e);if(!r||!r.clauses.has(n))return{};const o=new Map(t.selections),i=new Map(r.clauses);return i.delete(n),o.set(e,{...r,clauses:i}),{selections:o}})},setResolution(e,n){t(t=>{const r=t.selections.get(e);if(r?.resolution===n)return{};const o=new Map(t.selections),i=Q(o,e);return o.set(e,{...i,resolution:n}),{selections:o}})},clearSelection(e){t(t=>{const n=t.selections.get(e);if(!n||0===n.clauses.size)return{};const r=new Map(t.selections);return r.set(e,{...n,clauses:new Map}),{selections:r}})}}));import{useSyncExternalStore as et}from"react";var nt={positions:new Map},rt=new Set;function ot(){for(const t of rt)t()}function it(t,e){const n=nt.positions.get(t);if(n?.locked)return;if(!n||n.sourceId!==e)return;const r=new Map(nt.positions);r.delete(t),nt={positions:r},ot()}function st(t,e){const n=nt.positions.get(t);if(!n?.locked)return;if(e&&n.sourceId!==e)return;const r=new Map(nt.positions);r.delete(t),nt={positions:r},ot()}function at(){return nt}function lt(t){return rt.add(t),()=>rt.delete(t)}var ct={positions:new Map};function dt(){return()=>{}}function ut(){return ct}function ht(t){const e=et(t?lt:dt,t?at:ut,t?at:ut);return t?e.positions.get(t)??null:null}function yt(t){const e=Z(),n=t.clientId||e,{name:r}=t,o=tt(t=>t.selections.get(r)),i=tt(t=>t.setClause),s=tt(t=>t.clearClause),a=Y(()=>!!o&&o.clauses.size>0,[o]);return{predicate:Y(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[r,o]of t.clauses)"crossfilter"===t.resolution&&r===e||n.push(X(o));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(o,n):()=>!0,[o,n]),isActive:a,selectPoints:U(t=>{const e={};let o=!1;for(const[n,r]of Object.entries(t))e[n]={type:"point",values:new Set(r)},o=!0;o&&i(r,{clientId:n,type:"point",fields:e})},[n,r,i]),selectInterval:U(t=>{const e={};let o=!1;for(const[n,r]of Object.entries(t))e[n]={type:"interval",range:r},o=!0;o&&i(r,{clientId:n,type:"interval",fields:e})},[n,r,i]),clear:U(()=>{s(r,n)},[s,r,n]),clientId:n}}function ft(t){return 2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]}function pt(t){const{name:e,xField:n,yField:r}=t,{predicate:o,isActive:i,selectInterval:s,clear:a}=yt({name:e,fields:[n,r].filter(Boolean)}),l=n&&r?"xyBrush":n?"xBrush":"yBrush",c=U(t=>{if(!t)return void a();const e={};"xyBrush"===l&&function(t){return 2===t.length&&Array.isArray(t[0])&&2===t[0].length&&Array.isArray(t[1])&&2===t[1].length}(t)?(n&&(e[n]=[Math.min(t[0][0],t[1][0]),Math.max(t[0][0],t[1][0])]),r&&(e[r]=[Math.min(t[0][1],t[1][1]),Math.max(t[0][1],t[1][1])])):"xBrush"===l&&ft(t)?n&&(e[n]=[Math.min(t[0],t[1]),Math.max(t[0],t[1])]):"yBrush"===l&&ft(t)&&r&&(e[r]=[Math.min(t[0],t[1]),Math.max(t[0],t[1])]),mt(e)&&s(e)},[l,n,r,s,a]);return{brushInteraction:Y(()=>({brush:l,during:c,end:c}),[l,c]),predicate:o,isActive:i,clear:a}}function mt(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}function gt(t){return t?"string"==typeof t?{name:t}:t:null}import{useMemo as kt,useCallback as $t,useState as xt,useId as bt,useEffect as vt,useRef as wt}from"react";import{scaleOrdinal as Mt}from"d3-scale";var At={category10:l,tableau10:d,set3:c,...o},Wt=l,Lt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Pt=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 St(t,e,n){if("function"==typeof e){const r=e(t);return n&&r&&"string"==typeof r&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||Pt.has(e)}(r)?n(r):r}const r=t?.[e]+"";return n?n(r):Wt[Math.abs(function(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n),e&=e;return Math.abs(e)}(r))%Wt.length]}function Ot(t,e){if(null==e||!Object.prototype.hasOwnProperty.call(t,e))return;const n=t[e];return"string"==typeof n&&n.length>0?n:void 0}function Rt(t,e,n="category10"){if(n&&"object"==typeof n&&!Array.isArray(n)){const t=n;return e=>Ot(t,e)??"#999"}const r=Array.from(new Set(t.map(t=>t?.[e]).filter(t=>null!=t).map(t=>t+""))),o=r.every(t=>!isNaN(Number(t)));if(Array.isArray(n))return Mt().domain(r).range(n).unknown("#999");const i=At[n]||At.category10;if(o&&"function"==typeof i){let t=-1/0;for(const e of r){const n=Number(e);n>t&&(t=n)}return e=>i(Number(e)/t)}{const t=Array.isArray(i)?i:Wt;return Mt().domain(r).range(t).unknown("#999")}}function Tt(t,e,n=[3,20],r){let o;if(o="function"==typeof e?e(t):t?.[e],!r)return o;const[i,s]=r,[a,l]=n;if(s===i)return(a+l)/2;let c=(o-i)/(s-i);return 0>c?c=0:c>1&&(c=1),a+c*(l-a)}function It(t,e,n){const r=t.xValue??e?.[n];if(null==r)return null;const o=Number(r);return Number.isFinite(o)?o:null}function Nt(t){let e=t.data||t.datum||t;return Array.isArray(e)&&(e=e[0]),null!=t.xValue&&e&&"object"==typeof e&&!Array.isArray(e)&&null==e.xValue?{...e,xValue:t.xValue}:e||{}}var jt="#007bff",Ct=[],Dt={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function Ft(t,e={}){const n=e.mobileSemantics?.interaction,r="number"==typeof n?.targetSize?n.targetSize:"number"==typeof e.mobileSemantics?.minimumHitTarget?e.mobileSemantics.minimumHitTarget:void 0,o="mobile"===e.mode||"number"==typeof e.width&&480>=e.width,i=!!n||void 0!==r,s=t&&"object"==typeof t?t:void 0;if(!1===t||!1===s?.enabled||void 0===t&&!o&&!i)return Dt;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??r??44,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??44,standardControls:a.standardControls??!1}}function qt({selection:t,linkedHover:e,fallbackFields:n=Ct,unwrapData:o=!1,onObservation:i,chartType:s,chartId:a,onClick:l,hoverHighlight:c,colorByField:d,mobileInteraction:u}){const h=bt(),y=kt(()=>function(t,e){return t?!0===t?{name:"hover",fields:e||[]}:"string"==typeof t?{name:t,fields:e||[]}:{name:t.name||"hover",fields:t.fields||e||[],mode:t.mode,xField:t.xField,seriesField:t.seriesField}:null}(e,n),[e,n]),f=kt(()=>"series"===y?.mode?[y.seriesField||d||n[0]].filter(t=>!!t):y?.fields||n,[y,d,n]),p=yt({name:t?.name||"__unused__",fields:f}),m=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:r,isActive:o,selectPoints:i,clear:s}=yt({name:e,fields:n});return{onHover:U(t=>{if(!t)return void s();const e={};for(const r of n){const n=t[r];void 0!==n&&(e[r]=[n])}mt(e)&&i(e)},[n,i,s]),predicate:r,isActive:o}}({name:y?.name||"hover",fields:f}),g=r(t=>t.pushObservation),k=$t(t=>{i?.(t),g?.(t)},[i,g]),$=t?{isActive:p.isActive,predicate:p.predicate}:null,[x,b]=xt(null),v=wt(!1),w=d||n[0],M=kt(()=>{if(!c||null==x||!w)return null;const t=x,e=w;return{isActive:!0,predicate:n=>("string"==typeof n[e]?n[e]:(n[e]??"")+"")===t}},[c,x,w]),A=$t((t,n)=>{const r=!t&&v.current&&!!u?.enabled&&u.tapToLockTooltip;if(e)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===y?.mode&&y.xField){const n=It(t,e,y.xField);null!=n&&function(t,e,n){const r=nt.positions.get(t);r?.locked||r&&r.xValue===e&&r.sourceId===n||(nt={positions:new Map(nt.positions).set(t,{xValue:e,sourceId:n})},ot())}(y.name||"hover",n,h)}"x-position"!==y?.mode&&m.onHover(e)}else"x-position"!==y?.mode||r||it(y.name||"hover",h),"x-position"===y?.mode||r||m.onHover(null);if(c&&w)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=e?.[w];b(null!=n?n+"":null)}else r||b(null);(i||g)&&G({onObservation:k,datum:t?Nt(t):null,x:t?.x,y:t?.y,chartType:s||"unknown",chartId:a,context:n})},[e,m,y,h,i,s,a,g,k,c,w,u]),W=$t((n=!0)=>{v.current=!1,e&&"x-position"!==y?.mode&&m.onHover(null),t&&u?.tapToSelect&&p.clear(),n&&c&&b(null),"x-position"===y?.mode&&(st(y.name||"hover",h),it(y.name||"hover",h))},[e,y,m,t,u,p,c,h]),L=$t((n,r)=>{const o=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),d=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===y?.mode&&y.xField&&n){let t=n.data||n.datum||n;Array.isArray(t)&&(t=t[0]);const e=It(n,t,y.xField);null!=e&&function(t,e,n){const r=nt.positions.get(t);if(r?.locked){const e=new Map(nt.positions);return e.delete(t),nt={positions:e},ot(),!1}nt={positions:new Map(nt.positions).set(t,{xValue:e,sourceId:n,locked:!0})},ot()}(y.name||"hover",e,h)}if(o)if(n){v.current=!0;const r=Nt(n);if(e&&"x-position"!==y?.mode&&m.onHover(r),t&&u?.tapToSelect&&f.length>0){const t={};for(const e of f){const n=r[e];void 0!==n&&(t[e]=[n])}(function(t){if(!t)return!1;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1})(t)&&p.selectPoints(t)}if(c&&w){const t=r?.[w];b(null!=t?t+"":null)}}else d&&W();if(n||d){if(n&&l){let t=n.data||n.datum||n;Array.isArray(t)&&(t=t[0]),l(t,{x:n.x??0,y:n.y??0})}(i||g)&&V({onObservation:k,datum:n?Nt(n):null,x:n?.x,y:n?.y,chartType:s||"unknown",chartId:a,context:r})}},[l,i,g,k,s,a,y,h,u,e,m,t,p,f,c,w,W]);return vt(()=>{if(!u?.enabled||"undefined"==typeof document)return;const t=t=>{"Escape"===t.key&&v.current&&W()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[u?.enabled,W]),vt(()=>()=>{v.current&&W(!1)},[W]),vt(()=>{if("x-position"!==y?.mode)return;const t=y.name||"hover";return()=>{st(t,h),it(t,h)}},[y?.mode,y?.name,h]),{activeSelectionHook:$,hoverSelectionHook:M,customHoverBehavior:A,customClickBehavior:L,crosshairSourceId:h}}var zt={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 Ht(t,e,r){const o=zt[t||"primary"],i=t&&"primary"!==t||!r?.width?o.width:r.width,s=t&&"primary"!==t||!r?.height?o.height:r.height,a={...e,mode:t},l=n(a,{width:e.width??i,height:e.height??s}).props,c=l.mode||t,d=zt[c||"primary"],u="context"===c||"sparkline"===c,h=c&&"primary"!==c||!r?.width?d.width:r.width;return{width:l.width??h,height:l.height??(c&&"primary"!==c||!r?.height?d.height:r.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:Et(d.marginDefaults,l.showCategoryTicks,l.orientation),compactMode:u,mobileInteraction:Ft(l.mobileInteraction,{mode:c,width:l.width??h,mobileSemantics:l.mobileSemantics}),mobileSemantics:l.mobileSemantics}}function Et(t,e,n){if(!1!==e)return t;const r={...t};return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}function Bt(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function _t(t,e){return Math.min((t-e.startTime)/e.duration,1)}function Gt(t,e,n){return t+(e-t)*n}function Vt(){return"undefined"!=typeof performance?performance.now():Date.now()}function Zt(t,e){if(!1===t)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:t?!0===t?{duration:300}:{duration:t.duration??300,easing:"linear"===t.easing?"linear":"ease-out"}:e,introEnabled:!(n||!t||!0!==t&&!1===t.intro)}}function Yt(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function Ut(t){return"object"==typeof t&&null!==t&&"gradient"in t}import{jsx as Xt}from"react/jsx-runtime";var Qt={secondary:0,primary:3},Jt=".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 Kt(t){return!0===t?._annotationDeferred}function te(t){return"blended"===t?.cohesion||"layer"===t?.cohesion?t.cohesion:null}function ee(t){const e=t?.provenance?.confidence;return"number"==typeof e&&Number.isFinite(e)?Math.max(0,Math.min(1,e)):null}function ne(t){return Math.max(.72,.95-.06*t)}function re(t){const e=t.map((t,e)=>{return{p:t,i:e,emphasis:(n=t.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:ee(t.annotation),readingOrder:null,rank:1};var n}),n=e.some(t=>null!=t.emphasis||null!=t.confidence),r=t.some(t=>Kt(t.annotation)),o=t.some(t=>null!=te(t.annotation)),i=t.some(t=>"layer"===te(t.annotation));if(!n&&!r&&!o)return t.map(t=>t.node);const s=e.filter(t=>null==t.emphasis&&null!=t.confidence).slice().sort((t,e)=>(e.confidence??0)-(t.confidence??0)||t.i-e.i);s.forEach((t,e)=>{t.readingOrder=e,t.rank=2-e/Math.max(1,s.length)});for(const t of e)t.emphasis&&(t.rank=Qt[t.emphasis]);const a=e.sort((t,e)=>t.rank-e.rank||t.i-e.i).map(t=>{const{p:e,i:n,emphasis:r,readingOrder:o}=t,i=Kt(e.annotation);let s=e.node;if("primary"===r||"secondary"===r||null!=o){const t=null==r&&null!=o;s=Xt("g",{className:t?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...t?{opacity:ne(o),"data-annotation-reading-order":o}:{},children:e.node},"annotation-emphasis-"+n)}const a=te(e.annotation);return a&&(s=Xt("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),i&&(s=Xt("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return r&&a.unshift(Xt("style",{children:Jt},"annotation-disclosure-style")),i&&a.unshift(Xt("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),a}function oe(t,e,n){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=Object.values(t).filter(t=>"string"==typeof t&&t.length>0);if(e.length>0)return e}if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=At[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:n}function ie(t,e){const n=e&&"object"==typeof e&&!Array.isArray(e)?e:void 0;return 0===t.length?t=>n&&Ot(n,t)||"#4e79a7":e=>{if(n){const t=Ot(n,e);if(t)return t}let r=0;for(let t=0;e.length>t;t++)r=31*r+e.charCodeAt(t)|0;return t[Math.abs(r)%t.length]??"#4e79a7"}}import{jsx as se,jsxs as ae}from"react/jsx-runtime";function le(t,e=120,n=8){if(!t)return[];const r=Math.max(1,Math.floor(e/n)),o=t.split(/\s+/),i=[];let s="";for(const t of o)s&&s.length+1+t.length>r?(i.push(s),s=t):s=s?`${s} ${t}`:t;return s&&i.push(s),i}function ce(t,e,n,r){return"curly"===t?r?`M0,0 C${.6*n},0 ${.4*n},${e/2} ${n},${e/2} C${.4*n},${e/2} ${.6*n},${e} 0,${e}`:`M0,0 C0,${.6*n} ${e/2},${.4*n} ${e/2},${n} C${e/2},${.4*n} ${e},${.6*n} ${e},0`:r?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function de(t,e,n,r){if(!t)return se("g",{className:"annotation-note"});const{label:o,title:i,orientation:s,align:a,wrap:l=120,noWrap:c}=t;if(!o&&!i)return se("g",{className:"annotation-note"});let d=s;d||(d=Math.abs(e)>Math.abs(n)?"leftRight":"topBottom");let u=a;u&&"dynamic"!==u||(u="topBottom"===d?0>e?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===d?"right"===u?h="end":"middle"===u&&(h="middle"):h=0>e?"end":"start";const y=16,f=i?c?[i]:le(i,l):[],p=o?c?[o]:le(o,l):[],m="leftRight"===d?"end"===h?-4:4:0;let g=0;const k=[],$=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";t.useHTML||t.html?k.push(se("foreignObject",{className:"annotation-note-html",x:"end"===h?m-l:"middle"===h?m-l/2:m,y:-16,width:l,height:Math.max(y,(f.length+p.length)*y+(i&&o?2:0))+y,style:{overflow:"visible"},children:ae("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:$,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===h?"right":"middle"===h?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[i&&se("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),o&&se("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html")):(f.length>0&&(k.push(se("text",{className:"annotation-note-title",fill:$,textAnchor:h,fontWeight:"bold",children:f.map((t,e)=>se("tspan",{x:m,dy:0===e?0:y,children:t},e))},"annotation-note-title")),g=f.length*y),p.length>0&&k.push(se("text",{className:"annotation-note-label",fill:$,textAnchor:h,y:g,children:p.map((t,e)=>se("tspan",{x:m,dy:0===e?0:y,children:t},e))},"annotation-note-label")));let x=null;if((i||o)&&(0!==e||0!==n))if("topBottom"===d){const t=Math.min(l,120);let e=0,n=t;"end"===h?(e=-t,n=0):"middle"===h&&(e=-t/2,n=t/2),x=se("line",{className:"note-line",x1:e,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(f.length+p.length)*y+(p.length>0?y:0);let e=0,n=t;"bottom"===u?(e=-t,n=0):"middle"===u&&(e=-t/2,n=t/2),x=se("line",{className:"note-line",x1:0,x2:0,y1:e,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const b=Math.max(0,f.length+p.length-1)*y;let v=0;return"topBottom"===d?v=0>n?-(b+2):18:"leftRight"===d&&(v="middle"===u?-(b+y+(p.length>0&&f.length>0?2:0))/2+8:"bottom"===u||0>n?-(b+2):18),ae("g",{className:"annotation-note",transform:`translate(${e},${n})`,children:[se("g",{className:"annotation-note-content",transform:0!==v?`translate(0,${v})`:void 0,children:k}),x]})}function ue(t,e,n,r,o){const i=[];switch(t){case"callout-circle":{const t=(e?.radius||0)+(e?.radiusPadding||0);t>0&&i.push(se("circle",{r:t,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const t=e?.width||0,r=e?.height||0;(t>0||r>0)&&i.push(se("rect",{width:t,height:r,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":e?.custom&&i.push(...Array.isArray(e.custom)?e.custom:[e.custom]);break;case"xy-threshold":{const t=r||0,s=o||0;if(void 0!==e?.x){const r=(e.x||0)-t;i.push(se("line",{x1:r,y1:(e.y1||0)-s,x2:r,y2:(e.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==e?.y){const r=(e.y||0)-s;i.push(se("line",{x1:(e.x1||0)-t,y1:r,x2:(e.x2||0)-t,y2:r,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==e?.x1||void 0!==e?.x2?i.push(se("line",{x1:(e.x1||0)-t,y1:0,x2:(e.x2||0)-t,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===e?.y1&&void 0===e?.y2||i.push(se("line",{x1:0,y1:(e.y1||0)-s,x2:0,y2:(e.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const t=e?.type||"curly",r=e?.width??e?.height;void 0!==r&&i.push(se("path",{d:ce(t,r,e?.depth||30,void 0===e?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return se("g",{className:"annotation-subject",children:i})}function he(t,e,n,r,o,i){const s=[];let a=0,l=0;if("callout-circle"!==o&&"label"!==o||!i?.radius){if("callout-rect"===o&&i){const n=i.width||0,r=i.height||0;if(n>0||r>0){const o=n/2,i=r/2,s=t-o,c=e-i;if(0!==s||0!==c){const t=Math.abs(s),e=Math.abs(c),d=n/2,u=r/2,h=t*u>e*d?d/t:u/e;a=o+s*h,l=i+c*h}}}else if("bracket"===o&&i){const t=i.width,e=i.height,n=i.depth||30;void 0!==t?(a=t/2,l=n):void 0!==e&&(a=n,l=e/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==t||0!==e)){const r=Math.atan2(e,t);a=Math.cos(r)*n,l=Math.sin(r)*n}}const c=Math.sqrt((t-a)**2+(e-l)**2);if(c>.5){const o=r||"var(--semiotic-text-secondary, currentColor)",i="curve"===n?.type;let d=Math.atan2(e-l,t-a);if(i){const r=(a+t)/2,i=(l+e)/2,u=-(e-l)/c,h=(t-a)/c,y=(n?.curve??.25)*c,f=r+u*y,p=i+h*y;s.push(se("path",{className:"connector-curve",d:`M${a},${l}Q${f},${p} ${t},${e}`,fill:"none",stroke:o},"connector-line")),d=Math.atan2(p-l,f-a)}else s.push(se("line",{x1:a,y1:l,x2:t,y2:e,stroke:o},"connector-line"));if("arrow"===n?.end){const t=10,e=16/180*Math.PI;s.push(se("path",{d:`M${a},${l}L${a+t*Math.cos(d+e)},${l+t*Math.sin(d+e)}L${a+t*Math.cos(d-e)},${l+t*Math.sin(d-e)}Z`,fill:o,stroke:"none"},"connector-arrow"))}}return se("g",{className:"annotation-connector",children:s})}function ye(t){const{x:e=0,y:n=0,dx:r,dy:o,nx:i,ny:s,note:a,connector:l,subject:c,type:d,color:u,className:h,disable:y,opacity:f,strokeDasharray:p,events:m={},"data-testid":g}=t,k=Array.isArray(e)?e[0]??0:e,$=Array.isArray(n)?n[0]??0:n,x=new Set(Array.isArray(y)?y:[]);let b=r||0,v=o||0;null!=i&&(b=i-k),null!=s&&(v=s-$);const w="string"==typeof d?d:"label";if("bracket"===w&&c&&0===b&&0===v)if(void 0!==c.width){b=c.width/2;const t=c.depth||30;v=t+(0>t?-5:5)}else if(void 0!==c.height){const t=c.depth||30;b=t+(0>t?-5:5),v=c.height/2}return ae("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${k},${$})`,"data-testid":g,...null!=f&&{opacity:f},...p&&{strokeDasharray:p},...m,children:[!x.has("connector")&&he(b,v,l,u,w,c),!x.has("subject")&&ue(w,c,u,k,$),!x.has("note")&&de(a,b,v,u)]})}function fe(t){const{noteData:e}=t,{screenCoordinates:n}=e,r="string"==typeof e.type?e.type:"label",o=e.eventListeners||e.events||{};if(e.coordinates&&n){const t=e.nx||n[0][0]+(e.dx??0),o=e.ny||n[0][1]+(e.dy??0),i=n.map((n,i)=>{const s=Object.assign({},e,{note:0===i?e.note:{label:""},x:n[0],y:n[1],nx:t,ny:o});return se(ye,{"data-testid":"semiotic-annotation",...s,type:r},"multi-annotation-"+i)});return se("g",{children:i})}const i=e.note||{title:"none",label:e.label},s=`${i.label}-${i.title}-${e.i}`;return se(ye,{"data-testid":"semiotic-annotation",events:o,...e,type:r},s)}import{jsx as pe,jsxs as me}from"react/jsx-runtime";var ge="var(--semiotic-bg, #ffffff)";function ke(t){const{x:e,y:n,text:r,fill:o,fontSize:i=12,fontWeight:s,fontFamily:a,textAnchor:l="start",dominantBaseline:c,background:d,className:u}=t,h=function(t){return void 0===t||!0===t||"halo"===t?{type:"halo"}:!1===t||"none"===t?null:"box"===t?{type:"box"}:{type:t.type??"halo",...t}}(d),y=t=>pe("text",{x:e,y:n,textAnchor:l,dominantBaseline:c,fill:o,fontSize:i,fontWeight:s,fontFamily:a,className:u,...t?{stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:"stroke"}:{},children:r});if(!h)return y();if("halo"===h.type)return y({stroke:h.fill??ge,strokeWidth:h.haloWidth??3});const f=h.padding??{x:6,y:3},p="number"==typeof f?f:f.x,m="number"==typeof f?f:f.y,g=function(t,e){return(t+"").length*e*.6}(r,i),k=i+2*m;let $,x;return $="middle"===l?e-g/2-p:"end"===l?e-g-p:e-p,x="middle"===c||"central"===c?n-k/2:"hanging"===c||"text-before-edge"===c?n-m:n-.8*i-m,me("g",{className:u,children:[pe("rect",{x:$,y:x,width:g+2*p,height:k,rx:h.radius??3,ry:h.radius??3,fill:h.fill??ge,fillOpacity:h.opacity??.85,stroke:h.stroke,strokeWidth:h.strokeWidth}),y()]})}export{f as filterSparseArray,m as parseDateLikeString,g as coerceDateLikeValue,k as coerceTemporalStringRows,Wt as DEFAULT_COLORS,Lt as STREAMING_PALETTE,St as getColor,Ot as resolveExplicitColor,Rt as createColorScale,Tt as getSize,Bt as computeEasing,_t as computeRawProgress,Gt as lerp,Vt as now,Zt as resolveAnimateConfig,Yt as isLegendConfig,Ut as isGradientLegendConfig,fe as SemioticAnnotation,Jt as ANNOTATION_DISCLOSURE_REVEAL_CSS,re as applyAnnotationEmphasis,ke as AnnotationLabel,st as unlockCrosshair,ht as useCrosshairPosition,$ as TITLE_BASELINE,x as hasTextTitle,b as reserveFrameChromeMargin,v as reserveTitleMargin,A as hasAnyCornerRadius,W as clampCornerRadii,C as xySceneNodeToSVG,D as networkSceneNodeToSVG,F as networkSceneEdgeToSVG,q as networkLabelToSVG,z as ordinalSceneNodeToSVG,H as geoSceneNodeToSVG,E as isServerEnvironment,B as observationInputType,_ as isInteractiveKeyboardTarget,G as emitHoverObservations,V as emitClickObservations,oe as resolveCustomLayoutPalette,ie as buildResolveColor,pt as useBrushSelection,gt as normalizeLinkedBrush,jt as DEFAULT_COLOR,qt as useChartSelection,Ht as useChartMode};
@@ -1 +0,0 @@
1
- import{contrastRatio as e,fieldForRole as t,recipeConfig as i,recipeIntentId as a}from"./chunk-chunk-M337NY6L.module.min.js";import{extractAllRows as n}from"./chunk-chunk-255KDHW5.module.min.js";import{resolveResponsiveRules as r}from"./chunk-chunk-2WVCH4PL.module.min.js";import{getMinMax as s}from"./chunk-chunk-JJ2OOIET.module.min.js";import*as o from"react";function l(e){if(null==e)return"";if("number"!=typeof e)return e+"";if(!isFinite(e))return e+"";if(0===e)return"0";const t=parseFloat(e.toPrecision(12)),i=Math.abs(t);return 1e9>i?1e6>i?1e4>i?Number.isInteger(t)?t+"":parseFloat(t.toPrecision(6))+"":parseFloat((t/1e3).toPrecision(3))+"K":parseFloat((t/1e6).toPrecision(3))+"M":parseFloat((t/1e9).toPrecision(3))+"B"}var c=864e5;function u(e){return 10>e?"0"+e:e+""}var d=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function m(e){let t,i=e;return(a,n,r)=>{const s=a instanceof Date?a:new Date(a);e||!r||2>r.length||r===t||(t=r,i=function(e){if(2>e.length)return"days";const t=[];for(let i=1;e.length>i;i++)t.push(e[i]-e[i-1]);t.sort((e,t)=>e-t);const i=t[Math.floor(t.length/2)];return 12e4>i?"seconds":72e5>i?"minutes":2*c>i?"hours":60*c>i?"days":400*c>i?"months":"years"}(r));const o=i||"days";return null!=n&&0!==n&&r&&0!==r.length?function(e,t,i){const a=e.getUTCFullYear()!==t.getUTCFullYear(),n=a||e.getUTCMonth()!==t.getUTCMonth(),r=n||e.getUTCDate()!==t.getUTCDate(),s=r||e.getUTCHours()!==t.getUTCHours(),o=s||e.getUTCMinutes()!==t.getUTCMinutes(),l=d[e.getUTCMonth()],c=e.getUTCDate(),m=e.getUTCFullYear(),h=u(e.getUTCHours()),p=u(e.getUTCMinutes()),g=u(e.getUTCSeconds());switch(i){case"seconds":return a?`${l} ${c}, ${m} ${h}:${p}:${g}`:r?`${l} ${c} ${h}:${p}:${g}`:s?`${h}:${p}:${g}`:o?`${p}:${g}`:":"+g;case"minutes":return a?`${l} ${c}, ${m} ${h}:${p}`:r?`${l} ${c} ${h}:${p}`:s?`${h}:${p}`:":"+p;case"hours":return a?`${l} ${c}, ${m} ${h}:00`:n?`${l} ${c} ${h}:${p}`:r?`${l} ${c} ${h}:00`:h+":00";case"days":return a?`${l} ${c}, ${m}`:n?`${l} ${c}`:""+c;case"months":return a?`${l} ${m}`:""+l;case"years":return""+m}}(s,new Date(r[n-1]),o):function(e,t){const i=d[e.getUTCMonth()],a=e.getUTCDate(),n=e.getUTCFullYear(),r=u(e.getUTCHours()),s=u(e.getUTCMinutes()),o=u(e.getUTCSeconds());switch(t){case"seconds":return`${i} ${a}, ${n} ${r}:${s}:${o}`;case"minutes":case"hours":return`${i} ${a}, ${n} ${r}:${s}`;case"days":return`${i} ${a}, ${n}`;case"months":return`${i} ${n}`;case"years":return""+n}}(s,o)}}function h(e,t=.5){const i=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!i)return e;const a=Math.round(parseInt(i[1],16)*(1-t)),n=Math.round(parseInt(i[2],16)*(1-t)),r=Math.round(parseInt(i[3],16)*(1-t));return`#${a.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}function p(e,t=.5){const i=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!i)return e;const a=Math.round(parseInt(i[1],16)+(255-parseInt(i[1],16))*t),n=Math.round(parseInt(i[2],16)+(255-parseInt(i[2],16))*t),r=Math.round(parseInt(i[3],16)+(255-parseInt(i[3],16))*t);return`#${a.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}var g=new Set(["LineChart","AreaChart","DifferenceChart","StackedAreaChart","Scatterplot","ConnectedScatterplot","BubbleChart","QuadrantChart","MultiAxisLineChart","CandlestickChart","Heatmap","MinimapChart","RealtimeLineChart","RealtimeHeatmap"]),f=new Set(["BarChart","StackedBarChart","GroupedBarChart","SwarmPlot","BoxPlot","Histogram","ViolinPlot","DotPlot","RidgelinePlot","FunnelChart","LikertChart","SwimlaneChart"]),y={Scatterplot:["pointRadius","hoverRadius"],BubbleChart:["pointRadius","hoverRadius"],ConnectedScatterplot:["pointRadius","hoverRadius"],QuadrantChart:["pointRadius","hoverRadius"],SwarmPlot:["pointRadius","hoverRadius"],DotPlot:["dotRadius","hoverRadius"]};function b(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function v(e){return"string"==typeof e&&e.trim().length>0}function x(e){const t=b(e.capability)?e.capability:null,i=b(e.recipe)?e.recipe:null,a=[e.mobileSemantics,e.mobileVisualization,e.mobile,t?.mobile,i?.mobile];for(const e of a)if(b(e))return e;return null}function w(e){return Array.isArray(e)&&e.length>=2&&"number"==typeof e[0]&&"number"==typeof e[1]&&Number.isFinite(e[0])&&Number.isFinite(e[1])?[e[0],e[1]]:null}function k(e){return w(e.size)||w(b(e.frameProps)?e.frameProps.size:void 0)||("number"==typeof e.width&&"number"==typeof e.height?[e.width,e.height]:null)}function $(e,t){e.push({...t,status:"pass"})}function C(e,t){e.push({...t,status:"warn"})}function A(e,t){e.push({...t,status:"manual"})}function S(e,t={},i={}){const a=i.viewportWidth??390,n=i.targetSize??44,s=k(t),o=r(t,{width:a,height:s?.[1]}),l=[],c=k(t=o.props),u=x(t),d=function(e,t){return e.includes("CustomChart")||e.includes("Custom")||null!=t.recipeId||null!=t.mobileSemantics}(e,t),m=function(e){const t=x(e);return!0===e.responsive||!0===e.mobile||!0===t?.responsive||!0===t?.supportsResponsiveLayout||Array.isArray(t?.breakpoints)||"number"==typeof t?.minViewportWidth||"responsive"===t?.strategy||"small-multiples"===t?.strategy||"summary-cards"===t?.strategy||null!=e.mobileLayout||null!=e.responsiveRules||"mobile-readable"===e.density}(t),h=!0===i.inChartContainer,p=v(t.title)||v(t.summary)||v(t.description)||!0===u?.summary||v(u?.summary);if(o.matches.length>0&&$(l,{id:"layout.responsive-rule-applied",category:"layout",impact:"medium",message:`${o.matches.length} responsive rule(s) applied for the ${a}px mobile audit.`}),c){const[t,i]=c;t>a&&!m?C(l,{id:"layout.fixed-desktop-size",category:"layout",impact:"high",message:`Chart size is ${t}px wide against a ${a}px mobile viewport with no responsive/mobile transform hint.`,fix:"Use responsive sizing, responsiveRules/mobileLayout, or an explicit mobile variant that preserves the task instead of clipping the desktop chart."}):$(l,{id:"layout.fixed-desktop-size",category:"layout",impact:"high",message:"No fixed desktop-width overflow risk is visible from the config."}),"number"==typeof u?.minViewportWidth&&u.minViewportWidth>a&&C(l,{id:"layout.mobile-min-width",category:"layout",impact:"high",message:`The declared mobile contract supports ${u.minViewportWidth}px minimum, wider than the audited ${a}px viewport.`,fix:"Add a narrower breakpoint, summary-card fallback, or explicit horizontal-scroll affordance with a non-visual equivalent."});const n=t/Math.max(1,i);430>=a&&n>2.4&&"BigNumber"!==e&&C(l,{id:"layout.wide-aspect-ratio",category:"layout",impact:"medium",message:`Chart aspect ratio is ${n.toFixed(1)}:1, which tends to compress phone charts vertically.`,fix:"Prefer stacked sections, small multiples, cards plus a sparkline, or a taller mobile-specific chart ratio."}),160>i&&"BigNumber"!==e&&C(l,{id:"layout.too-short-for-reading",category:"layout",impact:"medium",message:`Chart height is ${i}px; most phone charts need enough vertical room for marks plus readable labels.`,fix:"Reserve more vertical space, remove nonessential axes, or switch to a card/sparkline pattern with external labels."})}else A(l,{id:"layout.unknown-size",category:"layout",impact:"medium",message:"No explicit size is available to audit. This may be responsive, but static mobile overflow cannot be checked.",fix:"Audit rendered widths at 320, 360, 390, and 430px, or pass size/responsiveRules metadata into the config."});const w=function(e){const t=[e.data,e.points,e.lines,e.nodes,e.edges,e.areas,b(e.frameProps)?e.frameProps.data:void 0];let i=0;for(const e of t)Array.isArray(e)&&(i+=e.length);return i}(t);w>0&&(w>("number"==typeof u?.maxMarks?u.maxMarks:g.has(e)?1.25*a:f.has(e)?Math.max(8,Math.floor(a/34)):a)?C(l,{id:"density.mark-budget",category:"density",impact:g.has(e)?"medium":"high",message:`${w} data item(s) exceed the rough mobile density budget for ${e} at ${a}px.`,fix:"Aggregate, filter, facet into small multiples, switch to a summary-card plus detail view, or use progressive disclosure."}):$(l,{id:"density.mark-budget",category:"density",impact:"medium",message:w+" data item(s) are within the rough mobile density budget for this component."}));const S=function(e){const t=[e.tickValues,e.xTickValues,e.yTickValues,e.rTickValues,e.oTickValues];let i=0;for(const e of t)Array.isArray(e)&&(i+=e.length);return i>0?i:null}(t),M=!1!==t.showAxes&&!1!==t.axis;if(M&&null!=S){const e=Math.max(3,Math.floor(a/58));S>e&&C(l,{id:"density.explicit-tick-count",category:"density",impact:"medium",message:`${S} explicit tick(s) exceed a phone-friendly budget of about ${e} at ${a}px.`,fix:"Use adaptive ticks, fewer tickValues, direct labels, or move exact values into a tap-accessible detail panel."})}else M&&(g.has(e)||f.has(e))&&A(l,{id:"density.axis-label-collision",category:"density",impact:"medium",message:"Axes are enabled, but label collision depends on rendered tick text and cannot be checked statically.",fix:"Verify tick labels at phone widths or provide explicit mobile tick density."});!function(e){const t=b(e.frameProps)?e.frameProps:{};return(!0===e.enableHover||null!=e.tooltipContent||null!=e.tooltip||null!=t.tooltipContent||!0===t.enableHover)&&!function(e){const t=x(e),i=b(e.mobileInteraction)?e.mobileInteraction:null;return null!=e.controls||null!=e.mobileControls||!0===e.alternativeControls||null!=e.selection||null!=e.onClick||null!=e.onSelect||!0===e.mobileInteraction||!0===i?.tapToSelect||!0===i?.tapToLockTooltip||Array.isArray(t?.interaction?.alternatives)&&t.interaction.alternatives.length>0||"tap"===t?.interaction?.primary||"button"===t?.interaction?.primary||v(t?.interaction?.hoverFallback)}(e)}(t)?$(l,{id:"interaction.hover-only-detail",category:"interaction",impact:"high",message:"No hover-only detail path is visible from the config."}):C(l,{id:"interaction.hover-only-detail",category:"interaction",impact:"high",message:"The chart exposes tooltip/hover detail without an obvious tap, selection, or control alternative.",fix:"Enable tap-to-select, a persistent details panel, visible segment buttons, or another non-hover path for the same information."});const T=function(e,t){const i=y[e];if(!i)return null;let a=i.includes("hoverRadius")?30:null;for(const e of i){const i=t[e];"number"==typeof i&&Number.isFinite(i)&&i>0&&(a=null==a?i:Math.max(a,i))}return null==a?null:2*a}(e,t),R=b(t.mobileInteraction)?t.mobileInteraction:null,I=T??("number"==typeof R?.targetSize?R.targetSize:!0===t.mobileInteraction?44:"number"==typeof u?.minimumHitTarget?u.minimumHitTarget:"number"==typeof u?.interaction?.targetSize?u.interaction.targetSize:null);null!=I&&(24>I?C(l,{id:"interaction.target-size-minimum",category:"interaction",impact:"high",message:`Small interactive marks expose an estimated ${I}px pointer target, below WCAG's 24px minimum.`,fix:"Increase mark radius/hoverRadius, add tap snapping to nearest datum, or provide larger external controls."}):n>I?C(l,{id:"interaction.target-size-comfort",category:"interaction",impact:"medium",message:`Pointer target is about ${I}px, above 24px but below the ${n}px comfortable phone target.`,fix:"Use hoverRadius/tapRadius near 44px while keeping the visible mark small if needed."}):$(l,{id:"interaction.target-size-comfort",category:"interaction",impact:"medium",message:`Pointer target is about ${I}px, meeting the configured ${n}px target.`}));const z=[];null==t.brush&&null==t.onBrush||z.push("brush"),!0===t.zoomable&&z.push("pan/zoom"),"isolate"!==t.legendInteraction&&"highlight"!==t.legendInteraction||z.push("legend filtering"),z.length>0&&!function(e,t){const i=x(e),a=b(e.mobileInteraction)?e.mobileInteraction:null,n=a?.standardControls;return!!(null!=e.controls||null!=e.mobileControls||!0===e.alternativeControls||Array.isArray(i?.interaction?.alternatives)&&i.interaction.alternatives.length>0)||!0===n||"all"===n||t.every(e=>"brush"===e?Array.isArray(n)?n.includes("brush"):"brush"===n:"pan/zoom"===e?Array.isArray(n)?n.includes("zoom"):"zoom"===n:"legend filtering"===e&&(Array.isArray(n)?n.includes("legend"):"legend"===n))}(t,z)&&C(l,{id:"interaction.complex-gesture-alternative",category:"interaction",impact:"high",message:`Mobile-hostile complex interaction detected: ${z.join(", ")} without standard control alternatives.`,fix:"Pair gestures with buttons, range inputs, chips, or a details panel that works with touch and keyboard."}),!1===t.showLegend||!1===t.legend||!0!==t.showLegend&&!0!==t.legend&&null==t.colorBy&&null==t.groupBy&&null==t.lineBy&&null==t.areaBy&&null==t.stackBy||!0===t.directLabel||!0===t.showLabels||"direct"===t.labelStrategy||"direct-end"===t.labelStrategy||"direct"===u?.labels?.strategy||"inline"===u?.labels?.strategy||"external"===u?.labels?.strategy||a>430||C(l,{id:"semantics.legend-over-direct-labels",category:"semantics",impact:"medium",message:"The chart appears to rely on a legend instead of direct labels at phone width.",fix:"Prefer direct end labels, inline labels, or a compact chip selector so readers do not bounce between plot and legend."});const P=Array.isArray(t.annotations)?t.annotations.filter(e=>b(e)):[];if(P.length>("number"==typeof u?.maxAnnotations?u.maxAnnotations:3)&&430>=a&&C(l,{id:"annotation.mobile-density",category:"annotation",impact:"medium",message:P.length+" annotation(s) compete for phone plot space.",fix:"Assign annotation priority, collapse secondary notes into a callout list, or provide shorter mobileText."}),P.length>0){const e=P.filter(e=>!v(e.mobileText)&&!v(e.shortText)&&!v(e.label));e.length>0&&A(l,{id:"annotation.mobile-copy",category:"annotation",impact:"low",message:e.length+" annotation(s) lack explicit short/mobile copy.",fix:"Add mobileText or shortText for notes that need to survive narrow layouts."})}m||"BigNumber"===e||A(l,{id:"layout.no-responsive-transform",category:"layout",impact:"low",message:"No explicit responsive transformation hint is present.",fix:"Declare responsiveRules/mobileLayout or a density/label strategy so the mobile version is a designed transformation, not an accidental resize."}),d&&(u?($(l,{id:"semantics.custom-mobile-contract",category:"semantics",impact:"medium",message:"Custom chart/recipe provides a mobileSemantics/mobile contract, so the audit can inspect its authored phone behavior."}),!1===u.custom?.dataBearingSceneNodes?C(l,{id:"semantics.custom-data-bearing-scene",category:"semantics",impact:"medium",message:"Custom mobile contract says emitted scene nodes are not data-bearing.",fix:"Preserve datum references, semantic roles, or accessible-table fields so intelligence, navigation, and tap details can recover the chart's meaning."}):!0!==u.custom?.dataBearingSceneNodes&&A(l,{id:"semantics.custom-data-bearing-scene",category:"semantics",impact:"low",message:"Custom chart mobile contract does not state whether scene nodes are data-bearing.",fix:"Set mobile.custom.dataBearingSceneNodes and mobile.custom.navigationGranularity for custom layouts and interoperability adapters."})):A(l,{id:"semantics.custom-mobile-contract",category:"semantics",impact:"medium",message:"Custom chart layout is opaque to static mobile analysis because no mobileSemantics/mobile contract is present.",fix:"Declare mobileSemantics with strategy, breakpoints, mark budgets, touch target size, interaction alternatives, and custom scene semantics."})),p||h||C(l,{id:"semantics.no-mobile-summary",category:"semantics",impact:"medium",message:"No title, summary, description, or ChartContainer context is visible from the config.",fix:"Add title/summary text or wrap in ChartContainer so the small-screen reader gets the task before the chart."});const U=l.filter(e=>"warn"===e.status),N={highRisk:U.filter(e=>"high"===e.impact).length,warnings:U.length,manual:l.filter(e=>"manual"===e.status).length,passes:l.filter(e=>"pass"===e.status).length};return{component:e,viewportWidth:a,ok:0===N.highRisk,summary:N,findings:l,reference:"Mobile visualization audit: informed by MobileVisFixer, mobile exploratory interaction research, small-multiple mobile studies, responsive visualization grammars, constraint-based breakpoints, and WCAG 2.2 input modalities."}}var M={pass:"PASS",warn:"WARN",manual:"MANUAL","not-applicable":"N/A"},T=["layout","density","interaction","annotation","semantics"];function R(e){const t=[],i=e.summary,a=e.ok?`no high-risk mobile blockers at ${e.viewportWidth}px`:`${i.highRisk} high-risk mobile issue(s) at ${e.viewportWidth}px`;t.push(`${e.ok?"PASS":"WARN"} ${e.component}: mobile visualization audit`),t.push(` ${a} - ${i.warnings} warning(s) - ${i.manual} manual check(s)`);for(const i of T){const a=e.findings.filter(e=>e.category===i&&"not-applicable"!==e.status);if(0!==a.length){t.push(""),t.push(" "+i.toUpperCase());for(const e of a)t.push(` ${M[e.status]} [${e.impact}] ${e.id}: ${e.message}`),!e.fix||"warn"!==e.status&&"manual"!==e.status||t.push(" -> "+e.fix)}}return t.push(""),t.push(" Ref: "+e.reference),t.join("\n")}function I(){return["Static audit only: rendered label collision, CSS-resolved type size, and actual touch behavior still require viewport testing.","Use multiple widths, usually 320, 360, 390, 430, and 768 CSS pixels.","A mobile pass means no high-risk static warnings, not that the chart is perceptually or ergonomically optimal."]}function z(e){const t={};for(const[i,a]of e){const e=[];for(const[,t]of a.clauses){const i={};for(const[e,a]of Object.entries(t.fields))i[e]="point"===a.type?{type:"point",values:Array.from(a.values)}:{type:"interval",range:a.range};e.push({clientId:t.clientId,type:t.type,fields:i})}t[i]={name:a.name,resolution:a.resolution,clauses:e}}return t}function P(e){const t=new Map;for(const[i,a]of Object.entries(e)){const e=new Map;for(const t of a.clauses){const i={};for(const[e,a]of Object.entries(t.fields))i[e]="point"===a.type?{type:"point",values:new Set(a.values)}:{type:"interval",range:a.range};e.set(t.clientId,{clientId:t.clientId,type:t.type,fields:i})}t.set(i,{name:a.name,resolution:a.resolution,clauses:e})}return t}async function U(e,t){const{format:i="png",filename:a="chart",scale:n=2,background:r="white"}=t||{},s=e.querySelector("svg");if(!s)throw Error("No SVG element found in the container");const o=s.cloneNode(!0),l=s.getBoundingClientRect();if(o.getAttribute("width")||o.setAttribute("width",l.width+""),o.getAttribute("height")||o.setAttribute("height",l.height+""),o.getAttribute("xmlns")||o.setAttribute("xmlns","http://www.w3.org/2000/svg"),N(s,o),"svg"===i){const e=(new XMLSerializer).serializeToString(o);F(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),a+".svg")}else{const t=l.width*n,i=l.height*n,s=document.createElement("canvas");s.width=t,s.height=i;const c=s.getContext("2d");c.fillStyle=r,c.fillRect(0,0,t,i),c.scale(n,n);const u=e.querySelector("canvas");u&&c.drawImage(u,0,0,l.width,l.height);const d=(new XMLSerializer).serializeToString(o),m=new Blob([d],{type:"image/svg+xml;charset=utf-8"}),h=URL.createObjectURL(m),p=new Image;p.width=l.width,p.height=l.height,await new Promise((e,t)=>{p.onload=()=>{c.drawImage(p,0,0),s.toBlob(i=>{i?(F(i,a+".png"),e()):t(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(h)},p.onerror=()=>{URL.revokeObjectURL(h),t(Error("Failed to load SVG image"))},p.src=h})}}function N(e,t){const i=e.children,a=t.children,n=window.getComputedStyle(e),r=["fill","stroke","stroke-width","stroke-dasharray","opacity","fill-opacity","stroke-opacity","font-family","font-size","font-weight","text-anchor","dominant-baseline"];for(const e of r){const i=n.getPropertyValue(e);i&&"none"!==i&&""!==i&&t.style?.setProperty(e,i)}for(let e=0;Math.min(i.length,a.length)>e;e++)N(i[e],a[e])}function F(e,t){const i=URL.createObjectURL(e),a=document.createElement("a");a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}function L(e){const t=e.pointId??e.id??e._transitionKey;return null==t||""===t?void 0:t+""}function D(e){return e.accessibility?.tableFields??e.accessibleDatum??e.datum??null}function B(e){return"number"==typeof e&&Number.isFinite(e)}function j(e){if(B(e.x)&&B(e.y)&&B(e.w)&&B(e.h))return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y+e.h};if(B(e.x)&&B(e.y)&&B(e.r))return{x0:e.x-e.r,y0:e.y-e.r,x1:e.x+e.r,y1:e.y+e.r};if(B(e.cx)&&B(e.cy)&&B(e.r))return{x0:e.cx-e.r,y0:e.cy-e.r,x1:e.cx+e.r,y1:e.cy+e.r};if(B(e.cx)&&B(e.cy)&&B(e.outerR))return{x0:e.cx-e.outerR,y0:e.cy-e.outerR,x1:e.cx+e.outerR,y1:e.cy+e.outerR};const t=[e.path,e.topPath,e.bottomPath].filter(Array.isArray).flat().filter(e=>Array.isArray(e)&&B(e[0])&&B(e[1]));return t.length>0?{x0:Math.min(...t.map(e=>e[0])),y0:Math.min(...t.map(e=>e[1])),x1:Math.max(...t.map(e=>e[0])),y1:Math.max(...t.map(e=>e[1]))}:null}function V(e,t){const i=Math.max(0,Math.min(e.x1,t.x1)-Math.max(e.x0,t.x0))*Math.max(0,Math.min(e.y1,t.y1)-Math.max(e.y0,t.y0)),a=Math.min(Math.max(0,e.x1-e.x0)*Math.max(0,e.y1-e.y0),Math.max(0,t.x1-t.x0)*Math.max(0,t.y1-t.y0));return a>0?i/a:0}function q(e,i,a,n,r){if(e===i)return!0;const s=a.dataRoles.map(e=>t(e,n,r)).filter(e=>!!e).filter(t=>null!=e[t]&&null!=i[t]);return s.length>0&&s.every(t=>e[t]+""==i[t]+"")}function W(e,t,i,a,n,r="warn",s){return{id:e,category:t,status:i?"pass":r,message:i?a:n,...s?{evidence:s}:{}}}function E(r){const{recipe:s}=r,o=function(e){return Array.isArray(e)?e:e&&"object"==typeof e?[...e.nodes??e.sceneNodes??[],...e.sceneEdges??[]]:[]}(r.scene),l=r.layoutConfig??i({layoutConfig:r.layoutConfig}),c=r.dimensions.plot??{x:0,y:0,width:r.dimensions.width,height:r.dimensions.height},u=c.x??0,d=c.y??0,m=[],h=o.filter(e=>null!=D(e)),p=o.filter(e=>!("string"!=typeof e.pathD||!/NaN|Infinity|undefined/.test(e.pathD))||function(e){return[...[e.x,e.y,e.w,e.h,e.r,e.cx,e.cy,e.innerR,e.outerR,e.x1,e.x2,e.y1,e.y2,e.openY,e.closeY,e.highY,e.lowY,e.bodyWidth].filter(e=>void 0!==e),...[e.path,e.topPath,e.bottomPath].filter(Array.isArray).flat(2)]}(e).some(e=>"number"!=typeof e||!Number.isFinite(e)));m.push(W("geometry.finite","geometry",0===p.length,"All emitted geometry is finite.",p.length+" marks contain non-finite geometry.","fail",{count:p.length}));const g=o.map(j),f=g.filter(e=>e&&(e.x0>=e.x1||e.y0>=e.y1)).length;m.push(W("geometry.nonzero-area","geometry",0===f,"All bounded marks have positive area.",f+" marks have zero or negative area.","warn",{count:f}));const y=g.filter(e=>e&&(u>e.x0||d>e.y0||e.x1>u+c.width||e.y1>d+c.height)).length;m.push(W("geometry.bounds","geometry",0===y,"All bounded marks stay inside the plot.",y+" marks extend outside the plot bounds.","warn",{count:y}));const b=s.audit?.minimumHitTargetSize??s.accessibility.minimumHitTarget??24,v=g.filter(e=>!!e&&(b>e.x1-e.x0||b>e.y1-e.y0)).length;m.push(W("interaction.target-size","interaction",0===v,`All bounded targets meet the declared ${b}px minimum.`,`${v} targets are smaller than ${b}px in at least one dimension.`,"warn",{count:v,minimumTarget:b}));const x=h.map(L),w=x.filter(e=>!e).length,k=new Set,$=x.filter(e=>!(!e||!k.has(e)&&(k.add(e),1)));m.push(W("identity.stable-ids","identity",0===w,"Every data-bearing mark exposes a stable id.",w+" data-bearing marks have no pointId, id, or transition key.",s.audit?.requireStableIds?"fail":"warn",{missing:w})),m.push(W("identity.unique-ids","identity",0===$.length,"Stable mark ids are unique.",$.length+" duplicate stable ids were observed.","fail",{duplicates:[...new Set($)].slice(0,10)}));const C=x.filter(e=>e&&/^(datum|mark|node|point|rect)-?\d+$/.test(e)).length;C>0&&m.push({id:"identity.index-pattern",category:"identity",status:"warn",message:C+" ids look index-derived and may change when data is reordered.",remediation:"Derive ids from a declared identifier role or stable domain key."});const A=new Set;let S=0;const M=r.inputData;for(const e of h){const t=D(e),i=Array.isArray(t)?t:[t];let a=!1;for(const e of i)if(e&&"object"==typeof e)for(let t=0;M.length>t;t+=1)q(e,M[t],s,l,M)&&(A.add(t),a=!0);a||(S+=1)}const T=Math.max(0,M.length-A.size);m.push(W("coverage.input-data","coverage",0===T,"Every input datum is represented by the observed scene.",T+" input data items have no matching scene mark.",s.audit?.requireDatumCoverage?"fail":"warn",{represented:A.size,input:M.length})),m.push(W("coverage.scene-data","coverage",0===S,"Every data-bearing scene mark maps back to input data.",S+" scene marks do not map back to an input datum.","warn",{count:S}));const R=s.encodings?.some(e=>"count"===e.channel);!R&&h.length>A.size&&A.size>0&&m.push({id:"coverage.duplicate-references",category:"coverage",status:"warn",message:"Input data is referenced by multiple marks, but multiplicity is not declared as an encoding.",remediation:"Declare count/repetition semantics or preserve a one-to-one datum-to-mark mapping."});const I=h.filter(e=>!1===e.interactive).length;m.push(W("interaction.hit-targets","interaction",0===I&&h.length>0,"Every observed data-bearing scene node participates in hit testing.",0===h.length?"No data-bearing scene nodes were emitted for interaction.":I+" data-bearing marks explicitly disable interaction.","fail"));const z=(r.annotations??[]).map(e=>e.pointId).filter(e=>null!=e).map(String),P=z.filter(e=>!k.has(e));m.push(W("coverage.annotation-anchors","coverage",0===P.length,z.length?"All pointId annotation anchors resolve to observed scene nodes.":"No pointId annotations require scene resolution.",P.length+" annotations point to missing scene ids.","fail",{unresolved:P}));const U=(r.chart?.selectedIds??[]).filter(e=>!k.has(e));r.chart?.selectedIds&&m.push(W("interaction.selection-reachability","interaction",0===U.length,"Selected/highlighted states resolve to observed marks.",U.length+" selected ids are not reachable in the scene.","fail",{missing:U}));const N=n(o),F=(s.accessibility.tableFields??s.accessibility.tableRoles?.map(e=>({role:e,label:e}))??[]).map(e=>{if(e.field)return e.field;const i=e.role?s.dataRoles.find(t=>t.role===e.role):void 0;return i?t(i,l,M):void 0}).filter(e=>!!e),B=new Set(N.flatMap(e=>Object.keys(e.values))),E=F.filter(e=>!B.has(e));m.push(W("accessibility.table-fields","accessibility",0===E.length,F.length?"The accessible table preserves all recipe-declared fields.":"The recipe declares no explicit accessible table field projection.",`The accessible table loses declared fields: ${E.join(", ")}.`,"fail",{expectedFields:F,observedFields:[...B]})),new Set(M.flatMap(e=>Object.entries(e).filter(([,e])=>["string","number","boolean"].includes(typeof e)).map(([e])=>e))).size>2&&2>=B.size&&[...B].every(e=>"category"===e||"value"===e)&&m.push({id:"accessibility.generic-table-loss",category:"accessibility",status:"warn",message:"The table exposes only generic category/value fields although richer input data exists.",remediation:"Emit accessibleDatum or accessibility.tableFields on scene nodes."});const H=(s.encodings?.filter(e=>"color"===e.channel)??[]).filter(e=>!e.redundantWith||0===e.redundantWith.length);m.push(W("accessibility.color-only","accessibility",0===H.length,"Every declared color encoding names a redundant cue.",H.length+" color encodings have no declared redundant cue.","warn"));const O=r.chart;if(O){for(const[e,t]of[["title",s.accessibility.requiresTitle],["summary",s.accessibility.requiresSummary],["description","required"===s.accessibility.description]])t&&m.push(W("accessibility."+e,"accessibility","string"==typeof O[e]&&O[e].trim().length>0,`A chart ${e} is present.`,`The recipe requires a chart ${e}, but none was supplied.`,"fail"));(s.accessibility.requiresAccessibleTable||"required"===s.accessibility.accessibleTable||s.accessibility.fallbackTable)&&m.push(W("accessibility.fallback-table","accessibility",!1!==O.accessibleTable,"The accessible fallback table is enabled.","The recipe requires a fallback table, but accessibleTable is disabled.","fail")),O.navigationTree&&m.push(W("accessibility.navigation-depth","accessibility",(O.navigationTree.children?.length??0)>0,"The navigation tree exposes structure below the root.","The navigation tree is root-only.","fail"))}const Y=r.theme?.background??"#ffffff",G=o.filter(t=>{const i=t.style?.fill??t.fill;if("string"!=typeof i||!i.startsWith("#")||!Y.startsWith("#"))return!1;const a=e(i,Y);return null!=a&&3>a}).length;m.push(W("visual.contrast","visual",0===G,"All statically checkable mark fills meet 3:1 contrast.",G+" marks have fill contrast below 3:1.","warn",{background:Y}));let J=0;const X=g.filter(e=>!!e).slice(0,500);for(let e=0;X.length>e;e+=1)for(let t=e+1;X.length>t;t+=1).8>V(X[e],X[t])||(J+=1);J>X.length&&m.push({id:"visual.overlap-density",category:"visual",status:"warn",message:J+" near-total mark overlaps suggest occlusion or excessive density.",remediation:"Aggregate, jitter, layer explicitly, or declare overlap as intentional."});const K=[["manual-at.screen-reader","Verify real screen-reader behavior with the target browser/AT combinations."],["manual-at.cognitive-load","Assess cognitive load and whether the custom metaphor is understood."],["manual-at.keyboard-order","Verify that keyboard order is meaningful, not merely mechanically available."],["manual-at.animation","Verify that animation is not distracting and reduced-motion behavior is sufficient."],["manual-at.reception","Test whether the memorable form is received as intended by the target audience."],["manual-at.overlay-occlusion","Inspect labels, overlays, annotations, and important marks for clipping or occlusion."],["manual-at.observation","Exercise hover, focus, selection, and observation emission in the rendered chart."]].map(([e,t])=>({id:e,category:"manual-at",status:"manual",message:t})),Q={dataRoles:s.dataRoles.map(e=>e.role),intents:s.intents.map(a).filter(e=>!!e),accessibilityExpectations:[...s.accessibility.requirements??[],...s.accessibility.tableFields?.map(e=>"table field: "+e.label)??[]],fallbackDeclared:!0===s.accessibility.fallbackTable||"required"===s.accessibility.accessibleTable||!0===s.accessibility.requiresAccessibleTable,designContractDeclared:!!s.designContract?.whyCustom},_=[...m,...K],Z=m.filter(e=>"fail"===e.status).length;return{recipeId:s.id,ok:0===Z,summary:{marks:o.length,passes:_.filter(e=>"pass"===e.status).length,warnings:_.filter(e=>"warn"===e.status).length,failures:Z,manual:_.filter(e=>"manual"===e.status).length},declaredSemantics:Q,observedSceneEvidence:m,manualATChecks:K}}function H(e=240){const t=360-e,i=180+t/2,a=i*Math.PI/180;return{sweepRad:e*Math.PI/180,gapDeg:t,startAngleDeg:i,startAngleRad:a,offsetRad:-Math.PI/2+a}}function O(e,t,i,a,n){const r=i-t||1;return n+(Math.max(t,Math.min(i,e))-t)/r*a}function Y(e=240){const{sweepRad:t,offsetRad:i}=H(e),a=[[Math.cos(i),Math.sin(i)],[Math.cos(i+t),Math.sin(i+t)],[0,0]];for(let e=0;2*Math.PI>e;e+=Math.PI/2)((e-i)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)>t+.001||a.push([Math.cos(e),Math.sin(e)]);const n=a.map(e=>e[0]),r=a.map(e=>e[1]),[o,l]=s(n),[c,u]=s(r);return{minX:o,maxX:l,minY:c,maxY:u,width:l-o,height:u-c,cx:(o+l)/2,cy:(c+u)/2}}export{l as smartTickFormat,m as adaptiveTimeTicks,h as darkenColor,p as lightenColor,S as auditMobileVisualization,R as formatMobileVisualizationAudit,I as mobileVisualizationCaveats,z as serializeSelections,P as deserializeSelections,U as exportChart,E as auditObservedScene,H as sweepToAngles,O as valueToAngle,Y as computeArcBoundingBox};