semiotic 3.8.1 → 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 (178) hide show
  1. package/CLAUDE.md +3 -1
  2. package/README.md +54 -52
  3. package/ai/behaviorContracts.cjs +9 -0
  4. package/ai/dist/mcp-server.js +142 -13
  5. package/ai/schema.json +616 -42
  6. package/ai/surface-manifest.json +1 -1
  7. package/ai/system-prompt.md +5 -2
  8. package/dist/chunk-OrdinalBrushOverlay-PXHQYDB2.module.min.js +2 -0
  9. package/dist/chunk-XYBrushOverlay-ECZJJLAJ.module.min.js +1 -0
  10. package/dist/chunk-XYBrushOverlay-EP2SV3UI.module.min.js +2 -0
  11. package/dist/chunk-chunk-255KDHW5.module.min.js +1 -0
  12. package/dist/chunk-chunk-2CCFBTQC.module.min.js +2 -0
  13. package/dist/chunk-chunk-2CXCXRB4.module.min.js +1 -0
  14. package/dist/chunk-chunk-2JGJ5GUG.module.min.js +2 -0
  15. package/dist/chunk-chunk-2RXP3FS3.module.min.js +1 -0
  16. package/dist/chunk-chunk-2WVCH4PL.module.min.js +1 -0
  17. package/dist/chunk-chunk-4TMZXLCR.module.min.js +1 -0
  18. package/dist/chunk-chunk-5APBQXZA.module.min.js +1 -0
  19. package/dist/chunk-chunk-5RKXZQ2P.module.min.js +1 -0
  20. package/dist/chunk-chunk-5UKL5W76.module.min.js +2 -0
  21. package/dist/chunk-chunk-6HSGDMTA.module.min.js +2 -0
  22. package/dist/chunk-chunk-7FW6EGLP.module.min.js +2 -0
  23. package/dist/chunk-chunk-7OEOSCBP.module.min.js +1 -0
  24. package/dist/chunk-chunk-A63CTACR.module.min.js +2 -0
  25. package/dist/chunk-chunk-ANYDWOZF.module.min.js +1 -0
  26. package/dist/chunk-chunk-AZJUDQRM.module.min.js +2 -0
  27. package/dist/chunk-chunk-B6V35LMY.module.min.js +2 -0
  28. package/dist/chunk-chunk-BOSVL645.module.min.js +2 -0
  29. package/dist/chunk-chunk-CA3YDW6F.module.min.js +1 -0
  30. package/dist/chunk-chunk-CP3EN6KZ.module.min.js +1 -0
  31. package/dist/chunk-chunk-DSNGDNJY.module.min.js +1 -0
  32. package/dist/chunk-chunk-EMO5NUGE.module.min.js +2 -0
  33. package/dist/chunk-chunk-F25UA5HT.module.min.js +1 -0
  34. package/dist/chunk-chunk-FRIO6MCV.module.min.js +1 -0
  35. package/dist/chunk-chunk-FYY2ACNJ.module.min.js +2 -0
  36. package/dist/chunk-chunk-G7WFWHAD.module.min.js +2 -0
  37. package/dist/chunk-chunk-GMQ5AYTD.module.min.js +1 -0
  38. package/dist/chunk-chunk-GWSWSPXN.module.min.js +1 -0
  39. package/dist/chunk-chunk-I6C3KR5H.module.min.js +2 -0
  40. package/dist/chunk-chunk-IP2UE74X.module.min.js +1 -0
  41. package/dist/chunk-chunk-J3ELI22J.module.min.js +1 -0
  42. package/dist/chunk-chunk-J3QOW4OE.module.min.js +0 -0
  43. package/dist/chunk-chunk-J3XWETBJ.module.min.js +2 -0
  44. package/dist/chunk-chunk-J5RL6GXU.module.min.js +2 -0
  45. package/dist/chunk-chunk-JCG72SGW.module.min.js +2 -0
  46. package/dist/{semiotic-ai-chunk-OG7BQUUW.module.min.js → chunk-chunk-JJ2OOIET.module.min.js} +0 -1
  47. package/dist/chunk-chunk-JNCHKRIR.module.min.js +2 -0
  48. package/dist/chunk-chunk-KTWEBFMX.module.min.js +2 -0
  49. package/dist/chunk-chunk-L3H6DQCR.module.min.js +2 -0
  50. package/dist/chunk-chunk-M337NY6L.module.min.js +1 -0
  51. package/dist/chunk-chunk-M7VYYHCE.module.min.js +2 -0
  52. package/dist/chunk-chunk-MC35ILYP.module.min.js +2 -0
  53. package/dist/chunk-chunk-N72SWNBV.module.min.js +1 -0
  54. package/dist/chunk-chunk-OBQRFTIL.module.min.js +2 -0
  55. package/dist/chunk-chunk-OQTLSTGI.module.min.js +2 -0
  56. package/dist/chunk-chunk-Q2YADC2V.module.min.js +2 -0
  57. package/dist/chunk-chunk-QRIBHZYW.module.min.js +1 -0
  58. package/dist/chunk-chunk-QSQVBIJA.module.min.js +1 -0
  59. package/dist/chunk-chunk-RCF52Z42.module.min.js +2 -0
  60. package/dist/chunk-chunk-ROP4HI7H.module.min.js +2 -0
  61. package/dist/chunk-chunk-RZH7VZYS.module.min.js +2 -0
  62. package/dist/chunk-chunk-SA3D43RA.module.min.js +2 -0
  63. package/dist/chunk-chunk-SANERMIZ.module.min.js +2 -0
  64. package/dist/chunk-chunk-SIRIJ3DY.module.min.js +1 -0
  65. package/dist/chunk-chunk-SV4XAZ3Q.module.min.js +1 -0
  66. package/dist/chunk-chunk-U66USBWU.module.min.js +1 -0
  67. package/dist/chunk-chunk-UHSZEB74.module.min.js +1 -0
  68. package/dist/chunk-chunk-VVCA3DB7.module.min.js +1 -0
  69. package/dist/chunk-chunk-WCX6U47H.module.min.js +2 -0
  70. package/dist/chunk-chunk-XEVJDUTH.module.min.js +1 -0
  71. package/dist/chunk-chunk-XQYVEKEJ.module.min.js +2 -0
  72. package/dist/chunk-chunk-Y6AXCRVO.module.min.js +1 -0
  73. package/dist/chunk-chunk-YCQYG6J5.module.min.js +2 -0
  74. package/dist/chunk-chunk-YHNZCPOZ.module.min.js +2 -0
  75. package/dist/chunk-chunk-YWZB3KPI.module.min.js +2 -0
  76. package/dist/chunk-chunk-ZCNBUZPL.module.min.js +2 -0
  77. package/dist/chunk-statisticalOverlays-6MVAK5RW.module.min.js +2 -0
  78. package/dist/components/charts/custom/XYCustomChart.d.ts +3 -0
  79. package/dist/components/charts/physics/PhysicalFlowChart.d.ts +7 -0
  80. package/dist/components/charts/realtime/RealtimeHistogram.d.ts +5 -6
  81. package/dist/components/charts/realtime/temporalHistogramConfig.d.ts +11 -0
  82. package/dist/components/charts/shared/areaSeriesData.d.ts +15 -0
  83. package/dist/components/charts/shared/auditAccessibilityText.d.ts +13 -0
  84. package/dist/components/charts/shared/chartMode.d.ts +67 -0
  85. package/dist/components/charts/shared/colorUtils.d.ts +8 -0
  86. package/dist/components/charts/shared/geoStyleDefaults.d.ts +3 -0
  87. package/dist/components/charts/shared/hooks.d.ts +13 -80
  88. package/dist/components/charts/shared/useChartSetup.d.ts +3 -0
  89. package/dist/components/charts/shared/useCustomChartSetup.d.ts +3 -0
  90. package/dist/components/charts/shared/useXYLineStyle.d.ts +3 -2
  91. package/dist/components/charts/shared/xyLineStyle.d.ts +21 -0
  92. package/dist/components/charts/xy/LineChart.d.ts +3 -0
  93. package/dist/components/legendLayout.d.ts +31 -0
  94. package/dist/components/server/serverChartConfigShared.d.ts +29 -0
  95. package/dist/components/server/serverChartConfigs.d.ts +2 -13
  96. package/dist/components/server/serverChartConfigsXY.d.ts +3 -0
  97. package/dist/components/server/serverGaugeOverlay.d.ts +28 -0
  98. package/dist/components/server/staticLegend.d.ts +7 -1
  99. package/dist/components/server/staticSVGChrome.d.ts +60 -2
  100. package/dist/components/stream/GeoPipelineStore.d.ts +2 -0
  101. package/dist/components/stream/GeoSVGOverlay.d.ts +2 -0
  102. package/dist/components/stream/OrdinalBrushOverlay.d.ts +1 -2
  103. package/dist/components/stream/OrdinalBrushOverlayLazy.d.ts +9 -0
  104. package/dist/components/stream/SceneToSVG.d.ts +8 -6
  105. package/dist/components/stream/SceneToSVGGeo.d.ts +10 -0
  106. package/dist/components/stream/SceneToSVGNetwork.d.ts +12 -0
  107. package/dist/components/stream/XYBrushOverlayLazy.d.ts +17 -0
  108. package/dist/components/stream/canvasBackground.d.ts +7 -0
  109. package/dist/components/stream/networkTypes.d.ts +2 -4
  110. package/dist/components/stream/renderBackend.d.ts +14 -0
  111. package/dist/components/stream/sceneToSVGShared.d.ts +51 -0
  112. package/dist/components/types/legendTypes.d.ts +16 -3
  113. package/dist/controls.min.js +1 -1
  114. package/dist/controls.module.min.js +1 -1
  115. package/dist/geo.min.js +1 -1
  116. package/dist/geo.module.min.js +1 -1
  117. package/dist/network.min.js +1 -1
  118. package/dist/network.module.min.js +1 -1
  119. package/dist/ordinal.min.js +1 -1
  120. package/dist/ordinal.module.min.js +1 -1
  121. package/dist/physics-matter.min.js +1 -1
  122. package/dist/physics-matter.module.min.js +1 -1
  123. package/dist/physics-rapier.min.js +1 -1
  124. package/dist/physics-rapier.module.min.js +1 -1
  125. package/dist/physics.min.js +1 -1
  126. package/dist/physics.module.min.js +1 -1
  127. package/dist/realtime.min.js +1 -1
  128. package/dist/realtime.module.min.js +1 -1
  129. package/dist/rough.min.js +1 -1
  130. package/dist/rough.module.min.js +1 -1
  131. package/dist/semiotic-ai-core.min.js +1 -1
  132. package/dist/semiotic-ai-core.module.min.js +1 -1
  133. package/dist/semiotic-ai.min.js +1 -1
  134. package/dist/semiotic-ai.module.min.js +1 -1
  135. package/dist/semiotic-data.min.js +1 -1
  136. package/dist/semiotic-data.module.min.js +1 -1
  137. package/dist/semiotic-experimental.min.js +1 -1
  138. package/dist/semiotic-experimental.module.min.js +1 -1
  139. package/dist/semiotic-realtime-core.min.js +1 -1
  140. package/dist/semiotic-realtime-core.module.min.js +1 -1
  141. package/dist/semiotic-realtime-react.min.js +1 -1
  142. package/dist/semiotic-realtime-react.module.min.js +1 -1
  143. package/dist/semiotic-recipes-core.min.js +1 -1
  144. package/dist/semiotic-recipes-core.module.min.js +1 -1
  145. package/dist/semiotic-recipes-react.min.js +1 -1
  146. package/dist/semiotic-recipes-react.module.min.js +1 -1
  147. package/dist/semiotic-recipes.min.js +1 -1
  148. package/dist/semiotic-recipes.module.min.js +1 -1
  149. package/dist/semiotic-server-edge.min.js +1 -1
  150. package/dist/semiotic-server-edge.module.min.js +1 -1
  151. package/dist/semiotic-server-node.min.js +1 -1
  152. package/dist/semiotic-server-node.module.min.js +1 -1
  153. package/dist/semiotic-themes-core.min.js +1 -1
  154. package/dist/semiotic-themes-core.module.min.js +1 -1
  155. package/dist/semiotic-themes-react.min.js +1 -1
  156. package/dist/semiotic-themes-react.module.min.js +1 -1
  157. package/dist/semiotic-themes.min.js +1 -1
  158. package/dist/semiotic-themes.module.min.js +1 -1
  159. package/dist/semiotic-utils-core.min.js +1 -1
  160. package/dist/semiotic-utils-core.module.min.js +1 -1
  161. package/dist/semiotic-utils-react.min.js +1 -1
  162. package/dist/semiotic-utils-react.module.min.js +1 -1
  163. package/dist/semiotic-utils.min.js +1 -1
  164. package/dist/semiotic-utils.module.min.js +1 -1
  165. package/dist/semiotic-value.min.js +1 -1
  166. package/dist/semiotic-value.module.min.js +1 -1
  167. package/dist/semiotic.min.js +1 -1
  168. package/dist/semiotic.module.min.js +1 -1
  169. package/dist/server.min.js +1 -1
  170. package/dist/server.module.min.js +1 -1
  171. package/dist/xy.min.js +1 -1
  172. package/dist/xy.module.min.js +1 -1
  173. package/package.json +4 -4
  174. package/dist/semiotic-ai-statisticalOverlays-CY4WKR4A.module.min.js +0 -2
  175. package/dist/semiotic-chunk-3FSVZ46U.module.min.js +0 -2
  176. package/dist/semiotic-statisticalOverlays-UOMSFKVJ.module.min.js +0 -2
  177. package/dist/xy-chunk-IWD6IB6V.module.min.js +0 -2
  178. package/dist/xy-statisticalOverlays-7RWG6LJT.module.min.js +0 -2
@@ -1 +1 @@
1
- import*as e from"react";import{useRef as t,useState as n,useEffect as r,useMemo as o,useCallback as i,useImperativeHandle as s,useId as a,forwardRef as c,memo as l}from"react";import{useRef as u,useEffect as h,useMemo as d}from"react";import{select as f}from"d3-selection";import{brush as y,brushX as p,brushY as g}from"d3-brush";import*as m from"react";import{jsx as v,jsxs as x}from"react/jsx-runtime";function b(e,t,n,r){const[o,i]=[Math.min(...t),Math.max(...t)],s=(i-o)/20;let[a,c]=e;if(r)0>n?a=Math.max(o,a-s):c=Math.min(i,c+s);else{const e=c-a;a=Math.max(o,Math.min(i-e,a+n*s)),c=a+e}return[a,c]}function k(e,t){let n=0,r=t.length-1;for(;r>n;){const o=n+r+1>>1;t[o]>e?r=o-1:n=o}return t[n]}function w(e,t){let n=0,r=t.length-1;for(;r>n;){const o=n+r>>1;e>t[o]?n=o+1:r=o}return t[n]}function A({width:e,height:t,totalWidth:n,totalHeight:r,margin:o,dimension:i,scales:s,onBrush:a,binSize:c,snap:l,binBoundaries:A,snapDuring:S,streaming:_}){const M=u(null),C=u(null),P=u(a);P.current=a;const T=u(s);T.current=s;const R=d(()=>A?[...A].sort((e,t)=>e-t):void 0,[A]),N=u(R);N.current=R;const D=u(!1),L=u(null),E=function({label:e="Data range brush",description:t="Use arrow keys to move the selected range, Shift plus an arrow key to resize it, and Escape to clear it.",onAction:n}={}){const r=m.useId().replace(/:/g,""),o=m.useRef(n);return o.current=n,{description:t,descriptionId:"semiotic-brush-description-"+r,svgProps:{role:"region",tabIndex:0,"aria-label":e,"aria-describedby":"semiotic-brush-description-"+r,onKeyDown:m.useCallback(e=>{const t=function(e){return"Escape"===e.key?{type:"clear"}:"ArrowLeft"===e.key?{type:"nudge",direction:"left",resize:e.shiftKey}:"ArrowRight"===e.key?{type:"nudge",direction:"right",resize:e.shiftKey}:"ArrowUp"===e.key?{type:"nudge",direction:"up",resize:e.shiftKey}:"ArrowDown"===e.key?{type:"nudge",direction:"down",resize:e.shiftKey}:null}(e);t&&(e.preventDefault(),o.current?.(t))},[])}}}({label:"xy"===i?"Two-dimensional data range brush":i.toUpperCase()+" data range brush",onAction:e=>{const t=T.current,n=C.current;if(!t||!n||!M.current)return;const r=f(M.current).select(".brush-g");if("clear"===e.type)return D.current=!0,r.call(n.move,null),D.current=!1,L.current=null,void P.current(null);const o=t.x.domain(),s=t.y.domain(),a=L.current;let c=a?.x??[o[0]+.4*(o[1]-o[0]),o[0]+.6*(o[1]-o[0])],l=a?.y??[s[0]+.4*(s[1]-s[0]),s[0]+.6*(s[1]-s[0])];const u="left"===e.direction||"right"===e.direction,h="left"===e.direction||"down"===e.direction?-1:1;if(u&&"y"!==i&&(c=b(c,o,h,e.resize)),u||"x"===i||(l=b(l,s,h,e.resize)),u&&"y"===i||!u&&"x"===i)return;const d={x:c,y:l};D.current=!0,r.call(n.move,"x"===i?[t.x(c[0]),t.x(c[1])]:"y"===i?[t.y(l[1]),t.y(l[0])]:[[t.x(c[0]),t.y(l[1])],[t.x(c[1]),t.y(l[0])]]),D.current=!1,L.current=d,P.current(d)}});return h(()=>{if(!M.current)return;const n=f(M.current).select(".brush-g"),r="x"===i?p():"y"===i?g():y();return r.extent([[0,0],[e,t]]),r.on("brush end",o=>{if(D.current)return;const s=T.current;if(!s)return;if(!o.selection)return L.current=null,void P.current(null);let a,u;if("x"===i){const[e,n]=o.selection;a=[s.x.invert(e),s.x.invert(n)],u=[s.y.invert(t),s.y.invert(0)]}else if("y"===i){const[t,n]=o.selection;a=[s.x.invert(0),s.x.invert(e)],u=[s.y.invert(n),s.y.invert(t)]}else{const[[e,t],[n,r]]=o.selection;a=[s.x.invert(e),s.x.invert(n)],u=[s.y.invert(r),s.y.invert(t)]}if("bin"===l&&"y"!==i&&("end"===o.type||"brush"===o.type&&S)){const e=N.current;e&&e.length>0?a=function(e,t){return 0===t.length?e:[k(e[0],t),w(e[1],t)]}(a,e):c&&c>0&&(a=[Math.floor(a[0]/c)*c,Math.ceil(a[1]/c)*c]);const t=s.x(a[0]),l=s.x(a[1]);if(D.current=!0,"x"===i)n.call(r.move,[t,l]);else if("xy"===i){const e=o.selection;n.call(r.move,[[t,e[0][1]],[l,e[1][1]]])}D.current=!1}const h={x:a,y:u};L.current=h,P.current(h)}),n.call(r),C.current=r,n.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null),C.current=null}},[e,t,i,l,c,S]),h(()=>{if(!(_&&s&&C.current&&L.current))return;if(!M.current)return;if("y"===i)return;const e=L.current,t=s.x.domain()[0],n=f(M.current).select(".brush-g");if(t>=e.x[1])return D.current=!0,n.call(C.current.move,null),D.current=!1,L.current=null,void P.current(null);let r=e.x[0],o=!1;if(t>e.x[0]){if(r=t,"bin"===l){const e=N.current;e&&e.length>0?r=w(t,e):c&&c>0&&(r=Math.ceil(t/c)*c)}if(r>=e.x[1])return D.current=!0,n.call(C.current.move,null),D.current=!1,L.current=null,void P.current(null);o=!0}const a=s.x(r),u=s.x(e.x[1]);if(D.current=!0,"x"===i)n.call(C.current.move,[a,u]);else{const t=s.y(e.y[1]),r=s.y(e.y[0]);n.call(C.current.move,[[a,t],[u,r]])}if(D.current=!1,o){const t={x:[r,e.x[1]],y:e.y};L.current=t,P.current(t)}},[s,_,i,l,c]),x("svg",{ref:M,width:n,height:r,...E.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:[v("title",{children:E.svgProps["aria-label"]}),v("desc",{id:E.descriptionId,children:E.description}),v("g",{className:"brush-g",transform:`translate(${o.left},${o.top})`})]})}var S=Object.freeze([]);function _(e){if(!e)return S;let t=!1;for(let n=0;e.length>n;n++){const r=e[n];if(null==r||"object"!=typeof r){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}var M=class{constructor(e,t){this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=t?.chunkThreshold??5e3,this.chunkSize=t?.chunkSize??5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(e=_(e),this.lastBoundedData===e)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const r=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,r),bounded:!1}),t=r,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(e){if(e=_(e),this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const r=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,r),bounded:!1}),t=r,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){null!=e&&"object"==typeof e&&(this.pushBuffer.push(e),this.scheduleFlush())}pushMany(e){if(0===e.length)return;let t=0;for(let n=0;e.length>n;n++){const r=e[n];null!=r&&"object"==typeof r&&(this.pushBuffer.push(r),t++)}0!==t&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}};import{createContext as C,useCallback as P,useContext as T,useMemo as R,useRef as N,useSyncExternalStore as D}from"react";import{jsx as L}from"react/jsx-runtime";function E(e){let t=null;const n=()=>(t||(t=C(null)),t),r=I(e);return[function({children:t,initialState:r}){const o=N(r),i=R(()=>I(e,o.current),[]),s=n();return L(s.Provider,{value:i,children:t})},(e,t)=>{const o=n(),i=T(o)??r,s=N(e);s.current=e;const a=N({hasValue:!1,value:void 0}),c=P(()=>{const e=s.current(i.getState()),n=a.current;return n.hasValue&&t&&t(n.value,e)?n.value:(a.current={hasValue:!0,value:e},e)},[i,t]),l=P(()=>s.current(i.getState()),[i]);return D(i.subscribe,c,l)}]}function I(e,t){const n=new Set;let r={...e(function(e){const t=e(r);if(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}(t)){r={...r,...t};for(const e of n)e()}}),...t??{}};return{getState:()=>r,subscribe:function(e){return n.add(e),()=>{n.delete(e)}}}}function W(e){if(!e?.colors)return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function $(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:z}}),e.accessibility.highContrast){const e="dark"===t.mode;t={...t,colors:{...t.colors,text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"}}}return t}var z=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],O={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},F={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},B={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:z,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function Y(e,t){if("light"===t)return O;if("dark"===t)return F;if("high-contrast"===t)return B;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?F:O;return $({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return $({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[j,H]=E(e=>({theme:O,setTheme(t){e(e=>({theme:Y(e.theme,t)}))}})),X=class{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;return{next:()=>this._size>e?{done:!1,value:this.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray();let n=0,r=[];t.length>e&&(n=t.length-e,r=t.slice(0,n)),this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(let e=n;t.length>e;e++)this.push(t[e]);return r}update(e,t){const n=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const i=(r+o)%this._capacity,s=this.buffer[i];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},n.push(e),this.buffer[i]=t(s)}}return n}remove(e){const t=[],n=[];if(this.forEach(r=>{e(r)?n.push(r):t.push(r)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}},G=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}};function V(e,t){return e===t}function q(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function U(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function K(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}var Q=/^\d{4}-\d{1,2}$/;function Z(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const n=Q.test(t)?t+"-01":t;if(n===t&&10>t.length)return NaN;const r=Date.parse(n);return Number.isFinite(r)?r:NaN}function J(e){return e instanceof Date?e.getTime():"string"==typeof e?Z(e):+e}function ee(e){return new Set(Array.isArray(e)?e:[e])}import{scaleOrdinal as te}from"d3-scale";function ne(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function re(e,t,n){const r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function oe(e){const t=e.map(ne),n=t.length-1;return e=>{if(0>=e){const[e,n,r]=t[0];return re(e,n,r)}if(e>=1){const[e,r,o]=t[n];return re(e,r,o)}const r=e*n,o=Math.floor(r),i=r-o,[s,a,c]=t[o],[l,u,h]=t[o+1];return re(Math.round(s+(l-s)*i),Math.round(a+(u-a)*i),Math.round(c+(h-c)*i))}}var ie=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],se=oe(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),ae=oe(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),ce=oe(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),le=oe(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),ue=oe(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),he=oe(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),de=oe(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),fe=oe(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),ye=oe(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),pe=oe(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),ge=oe(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),me=oe(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),ve={blues:se,reds:ae,greens:ce,viridis:de,oranges:le,purples:ue,greys:he,plasma:fe,inferno:ye,magma:pe,cividis:ge,turbo:me};oe(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),oe(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),oe(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),oe(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),oe(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),oe(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),oe(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]);var xe={category10:ie,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...ve},be=ie,ke=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];function we(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;const n=e[t];return"string"==typeof n&&n.length>0?n:void 0}function Ae(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function Se(e,t){return Math.min((e-t.startTime)/t.duration,1)}function _e(e,t,n){return e+(t-e)*n}function Me(){return"undefined"!=typeof performance?performance.now():Date.now()}var Ce={fresh:1,aging:1.5,stale:3};function Pe(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??1)>e?"fresh":t*(n.aging??1.5)>e?"aging":t*(n.stale??3)>e?"stale":"expired":"fresh"}function Te(e,t,n){if(null!=e)return"function"==typeof e?e(t,n):"object"==typeof e&&null!==e&&"constant"in e?e.constant:t[e]}function Re(e){const{data:t,encoding:n}=e,r=[],o=new Map;return t.forEach((e,t)=>{const i=Te(n.id,e,t);if(null==i||""===i)throw Error(`[semiotic] Motion encoding row ${t} resolved an empty id.`);const s=i+"";if(o.has(s))throw Error(`[semiotic] Duplicate motion encoding id "${s}".`);const a=Te(n.process?.group,e,t),c=Te(n.process?.stage,e,t),l=Te(n.accessible?.group,e,t)??(null!=a?a+"":null!=c?c+"":void 0),u={};for(const r of Object.keys(n.evidence??{}))u[r]=Te(n.evidence?.[r],e,t);const h={id:s,datum:e,time:{arrival:Te(n.time?.arrival,e,t),basis:n.time?.basis,unit:n.time?.unit},placement:{x:Te(n.placement?.x,e,t),y:Te(n.placement?.y,e,t),lane:Te(n.placement?.lane,e,t),space:n.placement?.space},kinematics:{velocityX:Te(n.kinematics?.velocityX,e,t),velocityY:Te(n.kinematics?.velocityY,e,t),space:n.kinematics?.space},process:{group:a,stage:c,target:Te(n.process?.target,e,t),work:Te(n.process?.work,e,t)},evidence:u,accessible:{description:Te(n.accessible?.description,e,t),group:l,label:Te(n.accessible?.label,e,t)??s}};r.push(h),o.set(s,h)}),{rows:r,byId:o}}function Ne(e){const t=Math.max(0,Math.min(1,e.minOpacity??.1));if(Number.isNaN(e.age))return 1;if(e.age===1/0)return t;if(!Number.isFinite(e.extent)||0>=e.extent)return 1;const n=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>n?1:t;if("exponential"===e.type){const r=e.halfLife??e.extent/2;return t+Math.pow(.5,n/(r>0?r:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-n/e.extent))*(1-t)}function De(e,t){const n=Number.isFinite(e)?e:0,r=Number.isFinite(t)?t:0;return{velocityX:n,velocityY:r,speed:Math.hypot(n,r),direction:Math.atan2(r,n)}}function Le(e,t,n){return Number.isFinite(n)&&n>0?De((t.x-e.x)/n,(t.y-e.y)/n):De(0,0)}function Ee(e,t,n){if(1>=n)return 1;const r=n-1;return Ne({age:r-t,extent:r,type:e.type,halfLife:e.halfLife??n/2,threshold:e.stepThreshold??.5*n,minOpacity:e.minOpacity??.1})}function Ie(e){const t=new Map;for(let n=0;e.length>n;n++)t.set(e[n],n);return t}function We(e,t,n){const r=e.duration??500,o=n-t;return r>o?1-o/r:0}function $e(e,t,n,r){let o=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,o=!0),e._pulseColor!==n&&(e._pulseColor=n,o=!0),e._pulseGlowRadius!==r&&(e._pulseGlowRadius=r,o=!0),o):(0!==e._pulseIntensity&&(e._pulseIntensity=0,o=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,o=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,o=!0),o)}function ze(e,t,n){if(t._transitionKey)return t._transitionKey;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const n=e.getX(t.datum),r=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${r}`;if(null!=n&&null!=r)return`p:${n}:${r}`}return"p:"+n;case"glyph":return t.pointId?"g:"+t.pointId:"g:"+n;case"rect":return`r:${t.group||""}:${t.datum?.binStart??t.datum?.category??n}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+n:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function Oe(e,t,n,r,o,i){const s=[];for(const o of e){const e=n(o),i=r(o);Number.isFinite(e)&&Number.isFinite(i)&&s.push({px:t.x(e),py:t.y(i),rawY:i,d:o})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],c[e]=t.rawY,l[e]=t.d}return{type:"line",path:a,rawValues:c,style:o,datum:l,group:i}}function Fe(e,t,n,r,o,i,s,a){const c=[];for(const i of e){const e=n(i),s=r(i);if(!Number.isFinite(e)||!Number.isFinite(s))continue;const l=t.x(e),u=a?a(i):o;c.push({px:l,topY:t.y(s),botY:t.y(u)})}c.sort((e,t)=>e.px-t.px);const l=Array(c.length),u=Array(c.length);for(let e=0;c.length>e;e++){const t=c[e];l[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:l,bottomPath:u,style:i,datum:e,group:s}}function Be(e,t,n,r){const o=new Map;if("silhouette"===r)for(const r of e){let e=0;for(const o of t)e+=n(o,r)||0;o.set(r,-e/2)}else if("wiggle"===r){e.length>0&&o.set(e[0],0);for(let r=1;e.length>r;r++){const i=e[r-1],s=e[r];let a=0,c=0,l=0;for(const e of t){const t=n(e,s)||0;a+=(2*l+t)*(t-(n(e,i)||0)),c+=t,l+=t}const u=o.get(i)??0;o.set(s,u-(c>0?a/(2*c):0))}if(e.length>0){let r=0;for(const i of e){let e=0;for(const r of t)e+=n(r,i)||0;r+=(o.get(i)??0)+e/2}const i=r/e.length;for(const t of e)o.set(t,(o.get(t)??0)-i)}}else for(const t of e)o.set(t,0);return o}function Ye(e,t,n,r,o,i,s){const a=n(e),c=r(e);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:t.x(a),y:t.y(c),r:o,style:i,datum:e};return void 0!==s&&(l.pointId=s),l}function je(e,t,n,r,o,i,s,a){const c=n(e),l=r(e);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:t.x(c),y:t.y(l),size:o,symbolType:i,style:s,datum:e};return void 0!==a&&(u.pointId=a),u}function He(e,t,n,r,o,i,s){return{type:"rect",x:e,y:t,w:n,h:r,style:o,datum:i,group:s}}function Xe(e,t,n,r,o,i,s){const a={type:"heatcell",x:e,y:t,w:n,h:r,fill:o,datum:i};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function Ge(e,t,n,r){return"function"==typeof t.style?t.style(r||{},n):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(n,r)}function Ve(e,t,n,r){if(!e.scales)return null;const o=[],i=[];for(const n of t){const t=e.getX(n);if(!Number.isFinite(t))continue;const s=r.getTop(n),a=r.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const c=e.scales.x(t),l=e.scales.y(s),u=e.scales.y(a);Number.isFinite(c)&&Number.isFinite(l)&&Number.isFinite(u)&&(o.push([c,l]),i.push([c,u]))}return 2>o.length?null:{type:"area",topPath:o,bottomPath:i,style:Ge(e,r,n,t[0]),datum:t,group:n,interactive:r.interactive}}function qe(e){const t=[],n=[];if(!e)return{perSeries:t,aggregate:n};for(const r of e)r.perSeries?t.push(r):n.push(r);return{perSeries:t,aggregate:n}}function Ue(e,t,n){const r=[];for(const o of n){const n=Ve(e,t,"__ribbon_aggregate",o);n&&r.push(n)}return r}function Ke(e,t,n,r){const o=[];for(const i of r){const r=Ve(e,t,n,i);r&&o.push(r)}return o}function Qe(e,t){if(!e)return{};if(!t||0===t.length)return e;const n=[];for(const r of t){if("band"!==r.kind)continue;const t=r.getTop(e),o=r.getBottom(e);Number.isFinite(o)&&Number.isFinite(t)&&n.push({y0:o,y1:t})}return 0===n.length?e:{...e,band:n[0],bands:n}}function Ze(e,t,n,r){if(!e.config.pointStyle)return;const o=r??e.getY;for(const r of t){const t=e.resolveGroupColor(r.key);for(const i of r.data){let r=e.config.pointStyle(i);!r.fill&&t&&(r={...r,fill:t});const s=r.r??3,a=e.getPointId?e.getPointId(i)+"":void 0,c=Ye(i,e.scales,e.getX,o,s,r,a);c&&n.push(c)}}}function Je(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}var et={topOpacity:.8,bottomOpacity:.05};function tt(e){if(e)return!0===e?et:"colorStops"in e?e:{topOpacity:e.topOpacity??et.topOpacity,bottomOpacity:e.bottomOpacity??et.bottomOpacity}}import{symbol as nt,symbolCircle as rt,symbolCross as ot,symbolDiamond as it,symbolSquare as st,symbolStar as at,symbolTriangle as ct,symbolWye as lt}from"d3-shape";var ut={circle:rt,square:st,triangle:ct,diamond:it,star:at,cross:ot,wye:lt},ht=["circle","triangle","diamond","star","square","chevron","cross","wye"];function dt(e,t,n){if(n)return n;const r=e??"circle";return"chevron"===r?function(e){const t=1.5*ft(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t):nt(ut[r]??rt,Math.max(1,t))()??""}function ft(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var yt=new Map;function pt(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){const r=Math.max(1,Math.floor(e.config.heatmapXBins??20)),o=Math.max(1,Math.floor(e.config.heatmapYBins??20)),i=e.config.heatmapAggregation??"count",s=q(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[a,c]=e.scales.x.domain(),[l,u]=e.scales.y.domain(),h=(c-a||1)/r,d=(u-l||1)/o,f=r*o;if(f>1e6)return[];const y=new Int32Array(f),p=new Float64Array(f);for(let n=0;t.length>n;n++){const i=t[n],c=e.getX(i),u=e.getY(i);if(!isFinite(c)||!isFinite(u))continue;const f=Math.min(Math.floor((c-a)/h),r-1),g=Math.min(Math.floor((u-l)/d),o-1);if(0>f||0>g)continue;const m=g*r+f;y[m]++;const v=s(i);p[m]+=isFinite(v)?v:0}let g=1/0,m=-1/0;for(let e=0;f>e;e++){if(0===y[e])continue;let t;switch(i){case"sum":t=p[e];break;case"mean":t=p[e]/y[e];break;default:t=y[e]}g>t&&(g=t),t>m&&(m=t)}if(!isFinite(g))return[];const v=m-g||1,x=n.width/r,b=n.height/o,k=e.config.showValues,w=e.config.heatmapValueFormat,A=[];for(let e=0;o>e;e++){const t=e*r;for(let n=0;r>n;n++){const r=t+n;if(0===y[r])continue;let s;switch(i){case"sum":s=p[r];break;case"mean":s=p[r]/y[r];break;default:s=y[r]}const c=(s-g)/v;A.push(Xe(n*x,(o-1-e)*b,x,b,`rgb(${220-(180*c+.5)|0},${220-(100*c+.5)|0},${255-(50*c+.5)|0})`,{xi:n,yi:e,value:s,count:y[r],sum:p[r],xCenter:a+(n+.5)*h,yCenter:l+(e+.5)*d,agg:i},k?{value:s,showValues:!0,valueFormat:w}:void 0))}}return A}(e,t,n);if(0===t.length)return[];const r=q(e.config.valueAccessor,"value"),o=U(e.config.xAccessor,"x"),i=U(e.config.yAccessor,"y"),s=new Map,a=new Map,c=Array(t.length),l=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],r=o(n),u=i(n);c[e]=r,l[e]=u,s.has(r)||s.set(r,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,h=a.size;if(0===u||0===h)return[];const d=Array.from(s.keys()),f=Array.from(a.keys()),y=d.every(e=>"number"==typeof e&&!isNaN(e)),p=f.every(e=>"number"==typeof e&&!isNaN(e));if(y){d.sort((e,t)=>Number(e)-Number(t)),s.clear();for(let e=0;d.length>e;e++)s.set(d[e],e)}if(p){f.sort((e,t)=>Number(e)-Number(t)),a.clear();for(let e=0;f.length>e;e++)a.set(f[e],e)}const g=new Float64Array(t.length),m=new Float64Array(t.length),v=Array(t.length),x=new Map;let b=0;for(let e=0;t.length>e;e++){const n=t[e],o=s.get(c[e]),i=a.get(l[e]);if(void 0===o||void 0===i)continue;const h=r(n),d=i*u+o,f=x.get(d);let y;void 0!==f?y=f:(y=b++,x.set(d,y)),g[y]=d,m[y]=h,v[y]=n}let k=1/0,w=-1/0;for(let e=0;b>e;e++){const t=m[e];isFinite(t)&&(k>t&&(k=t),t>w&&(w=t))}if(!isFinite(k)||!isFinite(w))return[];const A=function(e){const t=e in ve?e:"blues";let n=yt.get(t);if(n)return n;n=Array(256);const r=(o=t)&&ve[o]||se;var o;for(let e=0;256>e;e++)n[e]=r(e/255);return yt.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),S=255/(w-k||1),_=n.width/u,M=n.height/h,C=e.config.showValues,P=e.config.heatmapValueFormat,T=[];for(let e=0;b>e;e++){const t=m[e];if(!isFinite(t))continue;const n=g[e],r=n%u;T.push(Xe(r*_,(h-1-(n-r)/u)*M,_,M,A[Math.min((t-k)*S+.5|0,255)],v[e],C?{value:t,showValues:!0,valueFormat:P}:void 0))}return T}function gt(e,t,n,r,o){const i=new Map;for(const s of e){const e=t(s),a=n(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const c=Math.floor(e/r)*r;let l=i.get(c);if(l||(l={start:c,end:c+r,total:0,categories:new Map},i.set(c,l)),l.total+=a,o){const e=o(s);l.categories.set(e,(l.categories.get(e)||0)+a)}}return i}function mt(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:r,warned:o}=e;vt(r)&&0===n.length&&xt(o,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),n.length>0&&n.every(e=>null==e.datum)&&xt(o,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function vt(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(vt))}function xt(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function bt(e,t,n,r){const o=function(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:e+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(t),i="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:i,message:`Semiotic ${e} ${i} failed: ${o.message}`,error:o,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:r}}function kt(e,t){const n="function"==typeof e?e:n=>n[e||t];return e=>{const t=n(e);return null==t?NaN:+t}}function wt(e){const t=[],n=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,r=kt(n&&e.valueAccessor||e.yAccessor,n?"value":"y");if(e.boundsAccessor){const n=q(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{const t=r(e);if(!Number.isFinite(t))return NaN;const o=n(e);return Number.isFinite(o)&&0!==o?t+o:t},getBottom:e=>{const t=r(e);if(!Number.isFinite(t))return NaN;const o=n(e);return Number.isFinite(o)&&0!==o?t-o:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){const n=Array.isArray(e.band)?e.band:[e.band];for(const e of n)t.push({kind:"band",getTop:kt(e.y1Accessor,"y1"),getBottom:kt(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}import{scaleLinear as At,scaleLog as St,scaleSymlog as _t,scaleTime as Mt}from"d3-scale";function Ct(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function Pt(e,t,n){if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return St().domain(e).range(n).clamp(!0)}return"symlog"===e?_t().domain(t).range(n):"time"===e?Mt().domain([new Date(t[0]),new Date(t[1])]).range(n):At().domain(t).range(n)}function Tt(e,t,n,r){const o=e.push(t);return n&&n.push(r),o}var Rt=new WeakMap;function Nt(){return this.updateResults.last}function Dt(){return this.updateResults.last}function Lt(e){return this.updateResults.subscribe(e)}function Et(e){this.config.layoutSelection=e}function It(){Rt.set(this,!0)}function Wt(){const e=!0===Rt.get(this);return Rt.delete(this),e}function $t(e){Object.assign(e.prototype,{getLastUpdateResult:Nt,getUpdateSnapshot:Dt,subscribeUpdateResult:Lt,setLayoutSelection:Et,markStylePaintPending:It,consumeStylePaintPending:Wt})}var zt={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"};function Ot(e,t){const n={...e};for(const e of t)n[zt[e]]++;return n}function Ft(e,t,n){const r=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:r,revisions:Ot(n,r)}}var Bt=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=Ft({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){const n=Ft(e,t,this.revisions);this.revisions=n.revisions,this.latest=n;for(const e of[...this.listeners])e();return n}},Yt=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],jt=["scene-style","data-paint","accessibility","evidence"],Ht=(e,t)=>({retainedData:e,invalidations:t}),Xt=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Gt=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Vt=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],qt=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ut=["scene-geometry","data-paint","accessibility","evidence"],Kt=["scene-style","data-paint","accessibility","evidence"],Qt=[],Zt={chartType:Ht("rebuild",Xt),runtimeMode:Ht("rebuild",Xt),xAccessor:Ht("rebuild",Xt),yAccessor:Ht("rebuild",Xt),timeAccessor:Ht("rebuild",Xt),valueAccessor:Ht("rebuild",Xt),y0Accessor:Ht("rebuild",Xt),boundsAccessor:Ht("rebuild",Xt),band:Ht("rebuild",Xt),openAccessor:Ht("rebuild",Xt),highAccessor:Ht("rebuild",Xt),lowAccessor:Ht("rebuild",Xt),closeAccessor:Ht("rebuild",Xt),candlestickRangeMode:Ht("rebuild",Xt),accessorRevision:Ht("rebuild",Xt),groupAccessor:Ht("rebuild",Gt),categoryAccessor:Ht("rebuild",Gt),lineDataAccessor:Ht("rebuild",Gt),colorAccessor:Ht("rebuild",Kt),sizeAccessor:Ht("rebuild",Ut),symbolAccessor:Ht("rebuild",Ut),pointIdAccessor:Ht("rebuild",Ut),xScaleType:Ht("preserve",Vt),yScaleType:Ht("preserve",Vt),xExtent:Ht("preserve",Vt),yExtent:Ht("preserve",Vt),extentPadding:Ht("preserve",Vt),scalePadding:Ht("preserve",Vt),axisExtent:Ht("preserve",Vt),binSize:Ht("preserve",Vt),normalize:Ht("preserve",Vt),heatmapAggregation:Ht("preserve",Vt),heatmapXBins:Ht("preserve",Vt),heatmapYBins:Ht("preserve",Vt),arrowOfTime:Ht("preserve",qt),baseline:Ht("preserve",qt),stackOrder:Ht("preserve",qt),sizeRange:Ht("preserve",qt),curve:Ht("preserve",qt),areaGroups:Ht("preserve",qt),customLayout:Ht("preserve",qt),layoutConfig:Ht("preserve",qt),layoutMargin:Ht("preserve",qt),symbolMap:Ht("preserve",Ut),showValues:Ht("preserve",Ut),heatmapValueFormat:Ht("preserve",Ut),lineStyle:Ht("preserve",Kt),pointStyle:Ht("preserve",Kt),areaStyle:Ht("preserve",Kt),barStyle:Ht("preserve",Kt),swarmStyle:Ht("preserve",Kt),waterfallStyle:Ht("preserve",Kt),candlestickStyle:Ht("preserve",Kt),boundsStyle:Ht("preserve",Kt),gradientFill:Ht("preserve",Kt),lineGradient:Ht("preserve",Kt),colorScheme:Ht("preserve",Kt),themeCategorical:Ht("preserve",Kt),themeSemantic:Ht("preserve",Kt),themeSequential:Ht("preserve",Kt),themeDiverging:Ht("preserve",Kt),barColors:Ht("preserve",Kt),decay:Ht("preserve",Kt),pulse:Ht("preserve",Kt),staleness:Ht("preserve",Kt),layoutSelection:Ht("preserve",Kt),annotations:Ht("preserve",["overlay","accessibility","evidence"]),windowSize:Ht("preserve",Qt),windowMode:Ht("preserve",Qt),maxCapacity:Ht("preserve",Qt),clock:Ht("preserve",Qt),transition:Ht("preserve",Qt),introAnimation:Ht("preserve",Qt),onLayoutError:Ht("preserve",Qt)},Jt=Ht("preserve",qt),en=class{constructor(){this.tracker=new Bt}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},Yt)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},jt):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const r of e){const e=Zt[r]??Jt;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}};import{quadtree as tn}from"d3-quadtree";var nn=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(e,t){if("scatter"!==e&&"bubble"!==e&&"custom"!==e)return void this.clear();let n=0,r=0;for(const e of t)"point"===e.type&&(n++,e.r>r&&(r=e.r));if(this.maxRadius=r,500>=n)return void(this.tree=null);const o=Array(n);let i=0;for(const e of t)"point"===e.type&&(o[i++]=e);this.tree=tn().x(e=>e.x).y(e=>e.y).addAll(o)}},rn=class e{constructor(e){if(this.xExtent=new G,this.yExtent=new G,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._datumIndexCache=null,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.updateResults=new en,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.xIsDate=!1,this.spatialIndex=new nn,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,n)=>!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,r,o,i=("undefined"!=typeof performance?performance.now():Date.now())){const s=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let c=!1;const l=o??(()=>{const e=new Map;for(let t=0;n.length>t;t++)e.set(n[t],t);return e})();for(const n of t){if("line"===n.type)continue;if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[n.datum];let o=0,a=!1;for(const n of t){const t=l.get(n);if(null==t)continue;a=!0;const s=r.get(t);if(null==s)continue;const c=We(e,s,i);c>o&&(o=c)}a&&(c=$e(n,o,s)||c);continue}const t=l.get(n.datum);if(null==t)continue;const o=r.get(t);c=$e(n,null==o?0:We(e,o,i),s,a)||c}return c}(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),n),this.config=e,this.buffer=new X(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=q(e.timeAccessor||e.xAccessor,"time"),this.getY=q(e.valueAccessor||e.yAccessor,"value")):(this.getX=q(e.xAccessor,"x"),this.getY=q(e.yAccessor,"y")),this.getGroup=K(e.groupAccessor),this.getCategory=K(e.categoryAccessor),this.getSize=e.sizeAccessor?q(e.sizeAccessor,"size"):void 0,this.getColor=K(e.colorAccessor),this.getSymbol=K(e.symbolAccessor),this.getY0=e.y0Accessor?q(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=wt(e),this.getPointId=K(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?q(e.openAccessor,"open"):void 0,this.getHigh=q(e.highAccessor,"high"),this.getLow=q(e.lowAccessor,"low"),this.getClose=n?q(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new X(e.windowSize))}currentTime(){return this.config.clock?.()??Me()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=function(e,t){const n=new X(e.capacity);return e.forEach(()=>n.push(t)),n}(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(e)),void this.yExtent.push(this.getLow(e));this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e));for(const t of this.resolvedRibbons){const n=t.getTop(e),r=t.getBottom(e);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(r)&&this.yExtent.push(r)}}evictDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(e)),void this.yExtent.evict(this.getLow(e));this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e));for(const t of this.resolvedRibbons){const n=t.getTop(e),r=t.getBottom(e);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(r)&&this.yExtent.evict(r)}}rebuildYExtent(){this.yExtent.clear();for(const e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const e of this.buffer)this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e)}ingest(e){if(e.bounded&&this._lastBoundedInsertsRef===e.inserts)return this.updateResults.recordNoop("replace"),!1;const t=this.currentTime();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){this._lastBoundedInsertsRef=e.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=i?q(this.config.timeAccessor||this.config.xAccessor,"time"):q(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,r="function"==typeof n?n(t):t[n||"x"],o=r instanceof Date,i="string"==typeof r&&Number.isFinite(Z(r));if(this.xIsDate=o||i,i){const e="string"==typeof n?n:void 0;this.getX=e?t=>J(t[e]):e=>J(n(e))}}o=this.timestampBuffer,(r=e.totalSize||e.inserts.length)>(n=this.buffer).capacity&&(n.resize(r),o&&r>o.capacity&&o.resize(r));for(const n of e.inserts)Tt(this.buffer,n,this.timestampBuffer,t),this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n)}else for(const n of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity??1e5;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"===process.env.NODE_ENV||this.growingCapacityWarned||5e4>this.growingCap||(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${e}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const e=Tt(this.buffer,n,this.timestampBuffer,t);this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n),null!=e&&(this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e))}var n,r,o;return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}computeScene(e){const{config:t,buffer:n}=this,r=this.scales,o=this.lastLayout;if(!this.needsFullRebuild&&!t.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);this.xExtent.dirty&&this.xExtent.recalculate(n,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const i=this.getBufferArray(),s=this.yExtent.extent;let a=Ct(this.xExtent.extent,t.xExtent),c=Ct(s,t.yExtent);const l=!(!(u=t.yExtent)||null==u[0]||null==u[1]);var u;const h="exact"===t.axisExtent;if("stackedarea"===t.chartType&&!l&&n.size>0){const e=function(e){const{config:t,groups:n,getX:r,getY:o}=e,i="exact"===t.axisExtent;if(t.normalize){const n=[0,i?1:1+t.extentPadding];return{yDomain:n,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:n}}}const s=`${e.bufferSize}:${e.ingestVersion}:${t.baseline??"zero"}:${t.stackOrder??"key"}`;if(e.stackExtentCache&&e.stackExtentCache.key===s)return{yDomain:e.stackExtentCache.yDomain,stackExtentCache:e.stackExtentCache};const a=new Map,c=new Set;let l=0;const u=new Map,h=new Map;for(const e of n){const t=new Map;let n=0;for(const i of e.data){const e=r(i),s=o(i);if(!Number.isFinite(e)||!Number.isFinite(s))continue;t.set(e,(t.get(e)||0)+s),c.add(e),n+=s;const a=(u.get(e)||0)+s;u.set(e,a),a>l&&(l=a)}a.set(e.key,t),h.set(e.key,n)}const d=t.stackOrder??"key",f=(e,t)=>t>e?-1:e>t?1:0;let y,p;if("input"===d)y=n.map(e=>e.key);else if("insideOut"===d){const e=[...n].map(e=>e.key).sort((e,t)=>{const n=(h.get(t)??0)-(h.get(e)??0);return 0!==n?n:f(e,t)}),t=[],r=[];let o=0,i=0;for(const n of e)i>o?(t.push(n),o+=h.get(n)??0):(r.push(n),i+=h.get(n)??0);y=[...r.reverse(),...t]}else y="asc"===d?n.map(e=>e.key).sort((e,t)=>{const n=(h.get(e)??0)-(h.get(t)??0);return 0!==n?n:f(e,t)}):"desc"===d?n.map(e=>e.key).sort((e,t)=>{const n=(h.get(t)??0)-(h.get(e)??0);return 0!==n?n:f(e,t)}):n.map(e=>e.key).sort(f);if("wiggle"===t.baseline||"silhouette"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),n=Be(e,y,(e,t)=>a.get(e)?.get(t)||0,t.baseline);let r=1/0,o=-1/0;for(const t of e){const e=n.get(t)??0,i=u.get(t)??0;r>e&&(r=e),e+i>o&&(o=e+i)}Number.isFinite(r)&&Number.isFinite(o)||(r=0,o=0);const s=o-r,l=i?0:s>0?s*t.extentPadding:1;p=[r-l,o+l]}else if("diverging"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),[n,r]=function(e,t,n){let r=0,o=0;for(const i of e){let e=0,s=0;for(const r of t){const t=n(r,i)||0;0>t?s+=t:e+=t}r>s&&(r=s),e>o&&(o=e)}return[r,o]}(e,y,(e,t)=>a.get(e)?.get(t)||0),o=r-n,s=i?0:o>0?o*t.extentPadding:1;p=[n-s,r+s]}else p=[0,l+(i?0:l>0?l*t.extentPadding:1)];return{yDomain:p,stackExtentCache:{key:s,yDomain:p}}}({config:t,groups:this.groupData(i),getX:this.getX,getY:this.getY,bufferSize:n.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!l&&n.size>0?c=function(e,t,n,r,o,i,s){const[,a]=function(e,t,n,r,o){const i=gt(e,t,n,r,o);if(0===i.size)return[0,0];let s=0;for(const e of i.values())e.total>s&&(s=e.total);return[0,s]}(e,t,n,r,o);return[0,s?a:a+a*i]}(n,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,h):"waterfall"===t.chartType&&!l&&n.size>0?c=function(e,t,n,r){const[o,i]=function(e,t){let n=0,r=0,o=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(o+=e,n>o&&(n=o),o>r&&(r=o))}return[n,r]}(e,t),s=i-o,a=r?0:s>0?s*n:1;return[Math.min(0,o-Math.abs(a)),Math.max(0,i+Math.abs(a))]}(n,this.getY,t.extentPadding,h):l||c[0]===1/0||(c=function(e,t,n){if(!n.length)return e;let[r,o]=e;for(const e of t)for(const t of n){const n=t.getTop(e),i=t.getBottom(e);Number.isFinite(n)&&(r>n&&(r=n),n>o&&(o=n)),Number.isFinite(i)&&(r>i&&(r=i),i>o&&(o=i))}return[r,o]}(c,i,this.resolvedRibbons),c=function(e,t){const n=e[1]-e[0],r=t.exactMode?0:n>0?n*t.extentPadding:1,o=[null!=t.userMin?e[0]:e[0]-r,null!=t.userMax?e[1]:e[1]+r];return"log"!==t.yScaleType||o[0]>0||0>=t.dataYDomain[0]||t.exactMode||null==t.userMin&&(o[0]=t.dataYDomain[0]/(1+t.extentPadding)),o}(c,{exactMode:h,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:s}));c=function(e,t,n){if(!t||n)return e;const r=t[0],o=t[1];return null==r&&null==o?e:[null!=r?r:e[0],null!=o?o:e[1]]}(c,t.yExtent,!!l),({xDomain:a,yDomain:c}=function(e,t,n){let r=e,o=t;if(r[0]===1/0||r[1]===-1/0)if("time"===n){const e=Date.now();r=[e-864e5,e]}else r=[0,1];return o[0]!==1/0&&o[1]!==-1/0||(o=[0,1]),{xDomain:r,yDomain:o}}(a,c,t.xScaleType)),this.scales=function(e){const{config:t,layout:n,xDomain:r,yDomain:o}=e,i="streaming"===t.runtimeMode,s=Math.max(0,Math.min(t.scalePadding||0,Math.min(n.width,n.height)/2-1));if(i){if("x"==("up"===(a=t.arrowOfTime)||"down"===a?"y":"x")){const e="right"===t.arrowOfTime?[s,n.width-s]:[n.width-s,s];return{x:At().domain(r).range(e),y:Pt(t.yScaleType,o,[n.height-s,s])}}const e="down"===t.arrowOfTime?[s,n.height-s]:[n.height-s,s];return{x:Pt(t.yScaleType,o,[s,n.width-s]),y:At().domain(r).range(e)}}var a;return{x:Pt(t.xScaleType,r,[s,n.width-s]),y:Pt(t.yScaleType,o,[n.height-s,s])}}({config:t,layout:e,xDomain:a,yDomain:c}),this._customLayoutFailedThisBuild=!1;const d=this.buildSceneNodes(e,i);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.lastLayout=o):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=d,this.config.decay&&this.applyDecay(this.scene,i),this.config.pulse&&this.applyPulse(this.scene,i,this.currentTime()),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const r of e.path)r[0]*=t,r[1]*=n;break;case"area":for(const r of e.topPath)r[0]*=t,r[1]*=n;for(const r of e.bottomPath)r[0]*=t,r[1]*=n;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*n,width:e.clipRect.width*t,height:e.clipRect.height*n});break;case"point":case"glyph":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const r=this.scales.x.domain(),o=this.scales.y.domain(),i=this.scales.x.range(),s=this.scales.y.range(),a=Pt,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),l=s[1]>s[0];this.scales={x:a(this.config.xScaleType,r,i[0]>i[1]?[e.width-c,c]:[c,e.width-c]),y:a(this.config.yScaleType,o,l?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(e,t){const{config:n,scales:r}=this;if(!r)return[];if(n.customLayout){const o={data:t,scales:r,dimensions:{width:e.width,height:e.height,margin:n.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:n.themeSemantic??{},categorical:n.themeCategorical??ke},resolveColor:(e,t)=>{const r=this.resolveGroupColor(e);if(r)return r;const o=this.resolveLineStyle(e,t);return o.stroke?o.stroke:"string"==typeof o.fill?o.fill:n.themeSemantic?.primary??"#4e79a7"},config:n.layoutConfig??{},selection:n.layoutSelection??null};let i;try{i=n.customLayout(o)}catch(e){const t=null!==this.lastCustomLayoutResult,r=bt("xy",e,t,this.version);this.lastCustomLayoutFailure=r,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",e);try{n.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return t?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=i.overlays??null,this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null;const s=i.nodes??[];if(this._customRestyle=i.restyle,this.hasCustomRestyle=!!i.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const e of s)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(s,n.layoutSelection??null)}return mt({label:"customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===t.length)return[];const o={scales:r,config:n,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(n.chartType){case"line":return function(e,t){const n=e.groupData(t),r=[],o=e.config.annotations?.filter(Je).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:i}=qe(e.ribbons);if(i.length>0&&r.push(...Ue(e,t,i)),o.length>0)for(const t of n)r.push(...Ke(e,t.data,t.key,o))}for(const t of n){const n=e.resolveLineStyle(t.key,t.data[0]),i=Oe(t.data,e.scales,e.getX,e.getY,n,t.key);o&&o.length>0&&(i.colorThresholds=o),e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),r.push(i)}return Ze(e,n,r),r}(o,t);case"area":return function(e,t){const n=e.groupData(t),r=[];if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:i}=qe(e.ribbons);if(i.length>0&&r.push(...Ue(e,t,i)),o.length>0)for(const t of n)r.push(...Ke(e,t.data,t.key,o))}const o=e.scales.y.domain()[0],i=e.getY0?t=>{const n=e.getY0(t);return null==n?o:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),s=Fe(t.data,e.scales,e.getX,e.getY,o,n,t.key,i),a=tt(e.config.gradientFill);a&&(s.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(s.curve=e.config.curve),e.config.lineGradient&&(s.strokeGradient=e.config.lineGradient),r.push(s)}return Ze(e,n,r),r}(o,t);case"mixed":return function(e,t){const n=e.groupData(t),r=[],o=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:i}=qe(e.ribbons);if(i.length>0&&r.push(...Ue(e,t,i)),o.length>0)for(const t of n)r.push(...Ke(e,t.data,t.key,o))}const i=e.scales.y.domain()[0],s=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n)if(o.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),o=Fe(t.data,e.scales,e.getX,e.getY,i,n,t.key,s),a=tt(e.config.gradientFill);a&&(o.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}else{const n=e.resolveLineStyle(t.key,t.data[0]),o=Oe(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}return Ze(e,n,r),r}(o,t);case"stackedarea":return function(e,t){const n=e.groupData(t),r=e.config.stackOrder??"key",o=()=>n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"===r);else if("key"===r)o();else if("asc"===r||"desc"===r||"insideOut"===r){const t=new Map;for(const r of n){let n=0;for(const t of r.data){const r=e.getX(t),o=e.getY(t);Number.isFinite(r)&&Number.isFinite(o)&&(n+=o)}t.set(r.key,n)}const o=(e,t)=>t>e?-1:e>t?1:0;if("asc"===r)n.sort((e,n)=>{const r=(t.get(e.key)??0)-(t.get(n.key)??0);return 0!==r?r:o(e.key,n.key)});else if("desc"===r)n.sort((e,n)=>{const r=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,n.key)});else{const e=[...n].sort((e,n)=>{const r=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,n.key)}),r=[],i=[];let s=0,a=0;for(const n of e)a>s?(r.push(n),s+=t.get(n.key)??0):(i.push(n),a+=t.get(n.key)??0);n.length=0,n.push(...i.reverse(),...r)}}else o();const i=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,s=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:a,stackedTops:c}=function(e,t,n,r,o,i,s,a="zero"){const c=new Set;for(const t of e)for(const e of t.data){const t=n(e);Number.isFinite(t)&&c.add(t)}const l=Array.from(c).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const o of t.data){const t=n(o),i=r(o);Number.isFinite(t)&&Number.isFinite(i)&&e.set(t,(e.get(t)||0)+i)}u.set(t.key,e)}let h;if(i){h=new Map;for(const t of l){let n=0;for(const r of e)n+=u.get(r.key)?.get(t)||0;h.set(t,n||1)}}const d=Be(l,e.map(e=>e.key),(e,t)=>u.get(e)?.get(t)||0,a),f="diverging"===a&&!i,y=[],p=new Map,g=new Map,m=new Map,v=new Map;for(const e of l)g.set(e,d.get(e)??0),m.set(e,0),v.set(e,0);for(const n of e){const e=u.get(n.key),r=new Map;let a=[],c=[];const d=()=>{if(a.length>=2){const e={type:"area",topPath:a,bottomPath:c,style:o(n.key,n.data[0]),datum:n.data,group:n.key};s&&(e.curve=s),y.push(e)}a=[],c=[]};for(const n of l){const o=e.has(n);let s,l,u=o?e.get(n):0;if(i&&o&&(u/=h.get(n)),!o||!Number.isFinite(u)||0===u){d();continue}f?u>0?(s=m.get(n),l=s+u,m.set(n,l)):(s=v.get(n),l=s+u,v.set(n,l)):(s=g.get(n),l=s+u,g.set(n,l));const y=t.x(n);c.push([y,t.y(s)]),a.push([y,t.y(l)]),r.set(n,l)}d(),p.set(n.key,r)}return{nodes:y,stackedTops:p}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,i,s),l=a;if(e.config.pointStyle){const t=new WeakMap;for(const r of n){const n=c.get(r.key);if(n)for(const o of r.data){const r=e.getX(o),i=e.getY(o);null==r||Number.isNaN(r)||null==i||Number.isNaN(i)||!n.has(r)||t.set(o,n.get(r))}}const r=n=>t.get(n)??e.getY(n);Ze(e,n,l,r)}return l}(o,t);case"scatter":case"bubble":return function(e,t){const n=[],r="bubble"===e.config.chartType?10:5,o=e.config.sizeRange||[3,15];let i=null;if(e.getSize&&!e.config.pointStyle){const n=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(n.length>0){let e=1/0,t=-1/0;for(const r of n)e>r&&(e=r),r>t&&(t=r);i=n=>e===t?(o[0]+o[1])/2:o[0]+(n-e)/(t-e)*(o[1]-o[0])}}const s=e.getColor?e.resolveColorMap(t):null,a=e.config.themeSemantic?.primary||"#4e79a7",c=e.getSymbol,l=e.config.symbolMap,u=new Map;let h=0;const d=e=>{const t=l?.[e];if(t)return t;let n=u.get(e);return n||(n=ht[h%ht.length],h++,u.set(e,n)),n};for(const o of t){let t=e.config.pointStyle?e.config.pointStyle(o):{fill:a,opacity:.8},l=t.r||r;if(i&&e.getSize){const t=e.getSize(o);null==t||Number.isNaN(t)||(l=i(t))}if(s&&e.getColor&&!t.fill){const n=e.getColor(o);n&&s.has(n)&&(t={...t,fill:s.get(n)})}const u=e.getPointId?e.getPointId(o)+"":void 0;if(c){const r=d(c(o)+""),i=je(o,e.scales,e.getX,e.getY,Math.PI*l*l,r,t,u);i&&n.push(i)}else{const r=Ye(o,e.scales,e.getX,e.getY,l,t,u);r&&n.push(r)}}return n}(o,t);case"heatmap":return pt(o,t,e);case"bar":{const e=function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const n=gt(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===n.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){const t=new Set;for(const e of n.values())for(const n of e.categories.keys())t.add(n);const o=e.config.barColors?Object.keys(e.config.barColors):[],i=new Set(o),s=Array.from(t).filter(e=>!i.has(e)).sort(),a=o.filter(e=>t.has(e)),c=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===c?r=e.barCategoryCache.order:(r=[...a,...s],e.barCategoryCache={key:c,order:r})}const o=[],i=e.scales,[s,a]=i.x.domain(),c=e.config.barStyle,l=e.config.themeSemantic?.primary,u=c?.gap,h="number"!=typeof u||0>u?1:u,d={};c?.stroke&&(d.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(d.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(d.opacity=c.opacity);for(const t of n.values()){const n=Math.max(t.start,s),u=Math.min(t.end,a);if(n>=u)continue;const f=i.x(n),y=i.x(u),p=Math.abs(y-f),g=p>h+1?h:0,m=Math.min(f,y)+g/2,v=Math.max(p-g,1);if(v>0)if(r&&t.categories.size>0){let n=0;for(const s of r){const r=t.categories.get(s)||0;if(0===r)continue;const a=i.y(n),u=i.y(n+r);o.push(He(m,Math.min(a,u),v,Math.abs(a-u),{fill:e.config.barColors?.[s]||c?.fill||l||"#4e79a7",...d},{binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:r},s)),n+=r}}else{const e=i.y(0),n=i.y(t.total);o.push(He(m,Math.min(e,n),v,Math.abs(e-n),{fill:c?.fill||l||"#007bff",...d},{binStart:t.start,binEnd:t.end,total:t.total}))}}const f=new Set;for(const e of n.values())f.add(e.start),f.add(e.end);return{nodes:o,binBoundaries:Array.from(f).sort((e,t)=>e-t)}}(o,t);return this._barCategoryCache=o.barCategoryCache??null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){const n=[],r=e.config.swarmStyle||{},o=r.radius??3,i=r.fill??e.config.themeSemantic?.primary??"#007bff",s=r.opacity??.7,a=r.stroke,c=r.strokeWidth;for(const r of t){const t=e.getX(r),l=e.getY(r);if(null==l||Number.isNaN(l))continue;const u=e.scales.x(t),h=e.scales.y(l);let d=i;if(e.getCategory){const t=e.getCategory(r);d=e.config.barColors?.[t]||d}const{r:f,...y}=e.config.pointStyle?.(r)??{},p={type:"point",x:u,y:h,r:f??o,style:{fill:d,opacity:s,stroke:a,strokeWidth:c,...y},datum:r};e.getPointId&&(p.pointId=e.getPointId(r)+""),n.push(p)}return n}(o,t);case"waterfall":return function(e,t,n){const r=[],o=e.scales,i=e.config.waterfallStyle,s=t.filter(t=>{const n=e.getY(t),r=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=r&&isFinite(r)});if(0===s.length)return r;const a=i?.positiveColor??e.config.themeSemantic?.success??"#28a745",c=i?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",l=i?.gap??1,u=i?.stroke,h=i?.strokeWidth,d=i?.opacity;let f=0;for(let t=0;s.length>t;t++){const y=s[t],p=e.getX(y),g=e.getY(y),m=f+g;let v;v=s.length-1>t?e.getX(s[t+1])-p:t>0?p-e.getX(s[t-1]):0;const x=o.x(p),b=0!==v?o.x(p+v):x+n.width/10,k=Math.min(x,b)+l/2,w=Math.max(x,b)-l/2-k;if(0>=w){f=m;continue}const A=o.y(f),S=o.y(m),_=Math.min(A,S),M=Math.abs(A-S),C={fill:0>g?c:a,stroke:u,strokeWidth:h};null!=d&&(C.opacity=d),r.push(He(k,_,w,M,C,{...y,baseline:f,cumEnd:m,delta:g,_connectorStroke:i?.connectorStroke,_connectorWidth:i?.connectorWidth})),f=m}return r}(o,t,e);case"candlestick":return function(e,t){if(!e.getHigh||!e.getLow||!e.scales)return[];const n=e.config.candlestickRangeMode??!1;if(!(n||e.getOpen&&e.getClose))return[];const r=[],o=e.config.candlestickStyle||{},i=o.rangeColor||"#6366f1",s=n?i:o.upColor||"#28a745",a=n?i:o.downColor||"#dc3545",c=n?i:o.wickColor||"#333",l=o.wickWidth||(n?2:1),u=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let h=o.bodyWidth??0;if(null==o.bodyWidth)if(u.length>1){let t=1/0;for(let n=1;u.length>n;n++){const r=Math.abs(e.scales.x(u[n])-e.scales.x(u[n-1]));r>0&&t>r&&(t=r)}h=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else h=6;for(const o of t){const t=e.getX(o);if(null==t||Number.isNaN(t))continue;const i=e.getHigh(o),u=e.getLow(o);if(null==i||Number.isNaN(i)||null==u||Number.isNaN(u))continue;const d=n?i:e.getOpen(o),f=n?u:e.getClose(o);if(!n&&[d,f].some(e=>null==e||Number.isNaN(e)))continue;const y=f>=d,p={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(d),closeY:e.scales.y(f),highY:e.scales.y(i),lowY:e.scales.y(u),bodyWidth:h,upColor:s,downColor:a,wickColor:c,wickWidth:l,isUp:y,datum:o};n&&(p.isRange=!0),r.push(p)}return r}(o,t);default:return[]}}resolveBoundsStyle(e,t){return function(e,t,n,r){const o=e.boundsStyle;return"function"==typeof o?o(n||{},t):o&&"object"==typeof o?o:{fill:r(t,n).stroke||e.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?Ee(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const t=Ie(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&function(e,t,n,r=Ie(n)){const o=n.length;if(o>1)for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const i=Array(t.length);let s=!1;for(let n=0;t.length>n;n++){const a=r.get(t[n]);null!=a?(i[n]=Ee(e,a,o),1>i[n]&&(s=!0)):i[n]=1}s&&(n._decayOpacities=i);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],i=n.topPath?n.topPath.length:t.length;if(2>i)continue;if(t.length===i){const s=Array(i);let a=!1;for(let n=0;t.length>n;n++){const i=r.get(t[n]);null!=i?(s[n]=Ee(e,i,o),1>s[n]&&(a=!0)):s[n]=1}a&&(n._decayOpacities=s)}else{let s=1;for(const n of t){const t=r.get(n);if(null!=t){const n=Ee(e,t,o);s>n&&(s=n)}}if(1>s){const e=Array(i);e.fill(s),n._decayOpacities=e}}continue}const t=r.get(n.datum);if(null==t)continue;const i=Ee(e,t,o);"heatcell"===n.type?n.style={opacity:i}:"candlestick"===n.type?n._decayOpacity=i:n.style={...n.style,opacity:(n.style?.opacity??1)*i}}}(this.config.decay,e,t,this.getDatumIndexMap(t))}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&function(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;const r=e.duration??500,o=t.peek();return null!=o&&r>n-o}(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,r){n.clear(),r.clear();for(let o=0;t.length>o;o++){const i=t[o],s=ze(e,i,o);s&&("point"===i.type?n.set(s,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"glyph"===i.type?n.set(s,{x:i.x,y:i.y,r:i.size,opacity:i.style.opacity,glyph:i.glyph}):"rect"===i.type?n.set(s,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}):"heatcell"===i.type?n.set(s,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style?.opacity}):"candlestick"===i.type?n.set(s,{x:i.x,y:i.openY,w:i.bodyWidth,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY,opacity:i.style?.opacity}):"line"===i.type?r.set(s,{path:i.path.map(e=>[e[0],e[1]]),opacity:i.style?.opacity}):"area"===i.type&&r.set(s,{topPath:i.topPath.map(e=>[e[0],e[1]]),bottomPath:i.bottomPath.map(e=>[e[0],e[1]]),opacity:i.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const e=this.scales?.y(0)??0;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],r=ze(this.transitionContext,n,t);r&&("point"===n.type?this.prevPositionMap.set(r,{x:n.x,y:n.y,r:0,opacity:0}):"rect"===n.type?this.prevPositionMap.set(r,{x:n.x,y:e,w:n.w,h:0,opacity:n.style.opacity??1}):"heatcell"===n.type?this.prevPositionMap.set(r,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:0}):"line"===n.type?(n._introClipFraction=0,this.prevPathMap.set(r,{path:n.path.map(e=>[e[0],e[1]]),opacity:n.style.opacity})):"area"===n.type&&(n._introClipFraction=0,this.prevPathMap.set(r,{topPath:n.topPath.map(e=>[e[0],e[1]]),bottomPath:n.bottomPath.map(e=>[e[0],e[1]]),opacity:n.style.opacity})))}}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,r,o,i=Me()){if(0===r.size&&0===o.size)return n;const s=t.duration??300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let a=!1;const c=new Set,l=new Set;for(let t=0;n.scene.length>t;t++){const i=n.scene[t],s=ze(e,i,t);if(!s)continue;if(i._transitionKey=s,"line"===i.type||"area"===i.type){const e=o.get(s);if(e){if(l.add(s),"line"===i.type&&e.path&&e.path.length===i.path.length){i._targetPath=i.path.map(e=>[e[0],e[1]]),i._prevPath=e.path;for(let t=0;i.path.length>t;t++)i.path[t]=[e.path[t][0],e.path[t][1]];a=!0}else if("area"===i.type&&e.topPath&&e.bottomPath&&e.topPath.length===i.topPath.length&&e.bottomPath.length===i.bottomPath.length){i._targetTopPath=i.topPath.map(e=>[e[0],e[1]]),i._targetBottomPath=i.bottomPath.map(e=>[e[0],e[1]]),i._prevTopPath=e.topPath,i._prevBottomPath=e.bottomPath;for(let t=0;i.topPath.length>t;t++)i.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;i.bottomPath.length>t;t++)i.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];a=!0}i._targetOpacity=i.style.opacity??1,i._startOpacity=e.opacity??i.style.opacity??1}else i._targetOpacity=i.style.opacity??1,i._startOpacity=0,i.style={...i.style,opacity:0},a=!0;continue}const u=r.get(s);if("point"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,r:i.r};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.r||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.r,i.x=u.x,i.y=u.y,i.r=u.r??i.r,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("glyph"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,size:i.size};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.size||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.size,i.x=u.x,i.y=u.y,i.size=u.r??i.size,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("rect"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("heatcell"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=i.style?.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,a=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},a=!0;else if("candlestick"===i.type)if(u&&null!=u.openY){c.add(s);const e={x:i.x,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY};i._targetOpacity=i.style?.opacity??1,(u.x!==e.x||u.openY!==e.openY||u.closeY!==e.closeY||u.highY!==e.highY||u.lowY!==e.lowY)&&(i._targetX=e.x,i._targetOpenY=e.openY,i._targetCloseY=e.closeY,i._targetHighY=e.highY,i._targetLowY=e.lowY,i.x=u.x,i.openY=u.openY,i.closeY=u.closeY??i.closeY,i.highY=u.highY??i.highY,i.lowY=u.lowY??i.lowY,a=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},a=!0}for(const[e,t]of o)if(!l.has(e))if(e.startsWith("l:")&&t.path){const r={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(r),a=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const r={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(r),a=!0}for(const[e,t]of r)if(!c.has(e)){if(e.startsWith("p:"))n.exitNodes.push({type:"point",x:t.x,y:t.y,r:t.r??3,style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("g:")&&t.glyph)n.exitNodes.push({type:"glyph",x:t.x,y:t.y,size:t.r??12,glyph:t.glyph,color:"#999",accent:"#999",style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))n.exitNodes.push({type:"rect",x:t.x,y:t.y,w:t.w??0,h:t.h??0,style:{opacity:t.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("h:"))n.exitNodes.push({type:"heatcell",x:t.x,y:t.y,w:t.w??0,h:t.h??0,fill:"#999",datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e});else if(e.startsWith("c:")){const r=t.openY??t.y;n.exitNodes.push({type:"candlestick",x:t.x,openY:r,closeY:t.closeY??r,highY:t.highY??r,lowY:t.lowY??r,bodyWidth:t.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e})}a=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),a&&(n.activeTransition={startTime:i,duration:s}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(e,t,n,r){if(!n.activeTransition)return!1;const o=Se(e,n.activeTransition),i=Ae(o,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of n.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style.opacity=_e(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=_e(n.x,e._targetX,i),e.y=_e(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.r=_e(n.r,e._targetR,i))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style.opacity=_e(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=_e(n.x,e._targetX,i),e.y=_e(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.size=_e(n.r,e._targetR,i))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style.opacity=_e(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=_e(n.x,e._targetX,i),e.y=_e(n.y,e._targetY,i),void 0!==n.w&&(e.w=_e(n.w,e._targetW,i)),void 0!==n.h&&(e.h=_e(n.h,e._targetH,i))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style={...e.style||{},opacity:_e(n?n.opacity??1:0,e._targetOpacity,i)}}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=_e(n.x,e._targetX,i),e.y=_e(n.y,e._targetY,i),void 0!==n.w&&(e.w=_e(n.w,e._targetW,i)),void 0!==n.h&&(e.h=_e(n.h,e._targetH,i))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style={...e.style||{},opacity:_e(n?n.opacity??1:0,e._targetOpacity,i)}}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=_e(n.x,e._targetX,i),void 0!==n.openY&&(e.openY=_e(n.openY,e._targetOpenY,i)),void 0!==n.closeY&&(e.closeY=_e(n.closeY,e._targetCloseY,i)),void 0!==n.highY&&(e.highY=_e(n.highY,e._targetHighY,i)),void 0!==n.lowY&&(e.lowY=_e(n.lowY,e._targetLowY,i))}else if("line"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:_e(e._startOpacity??0,e._targetOpacity,i)}),void 0!==e._introClipFraction&&(e._introClipFraction=i);const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let r=0;e.path.length>r;r++)e.path[r][0]=_e(t[r][0],n[r][0],i),e.path[r][1]=_e(t[r][1],n[r][1],i)}else if("area"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:_e(e._startOpacity??0,e._targetOpacity,i)}),void 0!==e._introClipFraction&&(e._introClipFraction=i);const t=e._prevTopPath,n=e._prevBottomPath,r=e._targetTopPath,o=e._targetBottomPath;if(t&&r&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=_e(t[n][0],r[n][0],i),e.topPath[n][1]=_e(t[n][1],r[n][1],i);if(n&&o&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=_e(n[t][0],o[t][0],i),e.bottomPath[t][1]=_e(n[t][1],o[t][1],i)}}if(o>=1){for(const e of n.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style="line"===e.type||"area"===e.type?{...e.style,opacity:0===t?0:t}:{...e.style||{},opacity:0===t?0:t},e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("glyph"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.size=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("candlestick"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,void 0!==e._targetOpenY&&(e.openY=e._targetOpenY),void 0!==e._targetCloseY&&(e.closeY=e._targetCloseY),void 0!==e._targetHighY&&(e.highY=e._targetHighY),void 0!==e._targetLowY&&(e.lowY=e._targetLowY),e._targetX=void 0,e._targetOpenY=void 0,e._targetCloseY=void 0,e._targetHighY=void 0,e._targetLowY=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,n}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const e of this.scene)"line"!==e.type&&"area"!==e.type||(e._introClipFraction=void 0)}groupData(e){const{result:t,cache:n}=function(e,t,n,r){if(r&&r.version===n&&r.group===t&&r.data===e)return{result:r.result,cache:r};let o;if(t){const n=new Map;for(const r of e){const e=t(r);n.has(e)||n.set(e,[]),n.get(e).push(r)}o=Array.from(n.entries()).map(([e,t])=>({key:e,data:t}))}else o=[{key:"_default",data:e}];return{result:o,cache:{version:n,group:t,data:e,result:o}}}(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=n,t}resolveColorMap(e){const{map:t,cache:n}=function(e,t,n,r,o){if(o&&o.version===r)return{map:o.map,cache:o};const i=new Set;if(t)for(const n of e){const e=t(n);e&&i.add(e)}const s=Array.from(i).sort(),a=s.join("\0");if(o&&o.key===a){const e={...o,version:r};return{map:e.map,cache:e}}const c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical||ke,l=new Map;for(let e=0;s.length>e;e++)l.set(s[e],c[e%c.length]);return{map:l,cache:{key:a,map:l,version:r}}}(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=n,t}resolveLineStyle(e,t){return function(e,t,n,r){const o=e.lineStyle;if("function"==typeof o){const e=o(n||{},t);if(e&&!e.stroke&&t){const n=r(t);if(n)return{...e,stroke:n}}return e}const i=e.themeSemantic?.primary;return o&&"object"==typeof o?{stroke:o.stroke||i||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:r(t)||i||"#007bff",strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return function(e,t,n,r){if(e.areaStyle){const o=e.areaStyle(n||{});if(o&&!o.fill&&t){const e=r(t);if(e)return{...o,fill:e,stroke:o.stroke||e}}return o}const o=e.lineStyle;if("function"==typeof o){const e=o(n||{},t);if(e&&!e.fill&&t){const n=r(t);if(n)return{...e,fill:n,stroke:e.stroke||n}}return e}const i=e.themeSemantic?.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||i||"#4e79a7",fillOpacity:o.fillOpacity??.7,stroke:o.stroke||i||"#4e79a7",strokeWidth:o.strokeWidth||2};const s=r(t)||i||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(t){const{color:n,groupColorCounter:r}=function(e){const{group:t,colorMapCache:n,groupColorMap:r,groupColorMapCap:o,config:i}=e;let{groupColorCounter:s}=e;if(n){const e=n.map.get(t);if(e)return{color:e,groupColorCounter:s}}const a=r.get(t);if(a)return{color:a,groupColorCounter:s};const c=(Array.isArray(i.colorScheme)&&i.colorScheme.length>0?i.colorScheme:null)||(Array.isArray(i.themeCategorical)&&i.themeCategorical.length>0?i.themeCategorical:null)||ke;if(0===c.length)return{color:null,groupColorCounter:s};const l=c[s%c.length];if(s++,r.set(t,l),r.size>o){const e=r.keys().next().value;void 0!==e&&r.delete(e)}return{color:l,groupColorCounter:s}}({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:e.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=r,n}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=ee(e),n=this.getPointId,r=e=>t.has(n(e));!function(e,t,n){if(!t||0===t.size)return;const r=new Set;if(e.forEach((e,t)=>{n(e)&&r.add(t)}),0===r.size)return;const o=t.toArray();t.clear();for(let e=0;o.length>e;e++)r.has(e)||t.push(o[e])}(this.buffer,this.timestampBuffer,r);const o=this.buffer.remove(r);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(const e of o)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",o.length),o}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=ee(e),r=this.getPointId,o=new Set;this.buffer.forEach((e,t)=>{n.has(r(e))&&o.add(t)});const i=this.buffer.update(e=>n.has(r(e)),t);if(0===i.length)return this.updateResults.recordNoop("update"),i;for(const e of i)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.buffer.forEach((e,t)=>{o.has(t)&&(this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",i.length),i}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(e,t){const n=this._customRestyle;if(n)for(const r of e){const e=this._baseStyles.get(r)??r.style??{},o=n(r,t);r.style=o?{...e,...o}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(e){const t={...this.config},n=Object.keys(e).filter(n=>e[n]!==t[n]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in e||"colorScheme"in e)&&(this._barCategoryCache=null),("normalize"in e||"extentPadding"in e||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e||"boundsAccessor"in e||"band"in e||"y0Accessor"in e||"openAccessor"in e||"highAccessor"in e||"lowAccessor"in e||"closeAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let r=!1,o=!1;Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();const i="chartType"in e&&e.chartType!==t.chartType||"runtimeMode"in e&&e.runtimeMode!==t.runtimeMode;if(i||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){const e=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,n=e&&this.config.valueAccessor||this.config.yAccessor,s=e&&t.valueAccessor||t.yAccessor,a=i||!V(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),c=i||!V(n,s);(a||c)&&(e?(this.getX=q(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=q(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=q(this.config.xAccessor,"x"),this.getY=q(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=wt(this.config)),r=!0,o=!0)}if("groupAccessor"in e&&!V(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?K(this.config.groupAccessor):void 0,r=!0),"categoryAccessor"in e&&!V(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?K(this.config.categoryAccessor):void 0,r=!0),"sizeAccessor"in e&&!V(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?q(this.config.sizeAccessor,"size"):void 0,r=!0),"symbolAccessor"in e&&!V(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?K(this.config.symbolAccessor):void 0,r=!0),"colorAccessor"in e&&!V(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?K(this.config.colorAccessor):void 0,r=!0),"y0Accessor"in e&&!V(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?q(this.config.y0Accessor,"y0"):void 0,r=!0,o=!0),("boundsAccessor"in e&&!V(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=wt(this.config),r=!0,o=!0),"pointIdAccessor"in e&&!V(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?K(this.config.pointIdAccessor):void 0,r=!0),"candlestick"===this.config.chartType&&(i||"openAccessor"in e&&!V(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!V(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!V(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!V(e.lowAccessor,t.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?q(this.config.openAccessor,"open"):void 0,this.getHigh=q(this.config.highAccessor,"high"),this.getLow=q(this.config.lowAccessor,"low"),this.getClose=t?q(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,r=!0,o=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(r=!0,o=!0),!r){const n=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const o of n)if(e[o]!==t[o]){r=!0;break}}r&&(o&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(n)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};rn.GROUP_COLOR_MAP_CAP=1e3;var on=rn;$t(on);import{memo as sn,useEffect as an,useRef as cn}from"react";var ln={sceneGeometry:0,layout:0,domain:0};function un(e){const{domain:t,layout:n,sceneGeometry:r}=e.revisions;return{domain:t,layout:n,sceneGeometry:r}}function hn(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 dn="production"!==process.env.NODE_ENV,fn={revisions:ln,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},yn=class{constructor(e="scene host"){this.hostName=e,this.lastConsumed=ln,this.lastObserved=ln,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}observeUpdateResult(e){dn&&(this.lastObserved=hn(this.lastObserved,un(e)))}beforeCompute(e,t){if(!dn)return fn;const n=hn(un(e),this.lastObserved),r=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),o=!((i=n).sceneGeometry===(s=this.lastConsumed).sceneGeometry&&i.layout===s.layout&&i.domain===s.domain);var i,s;return{revisions:n,signature:r,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:o,warnUnconsumed:!t&&o&&this.lastUnconsumedWarning!==r}}afterCompute(e,t,n){if(dn){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 pn(e){return cn(new yn(e))}var gn=sn(function({store:e,diagnostics:t}){return an(()=>{const n=()=>t.observeUpdateResult(e.getUpdateSnapshot());return n(),e.subscribeUpdateResult(n)},[t,e]),null});import*as mn from"react";function vn(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:mn.createElement(mn.Fragment,null,...t)}import*as xn from"react";import{jsx as bn}from"react/jsx-runtime";var kn=xn.createContext(null);function wn({value:e,children:t}){return bn(kn.Provider,{value:e,children:t})}function An(e,t){return null!=e?bn(wn,{value:t,children:e}):e}import{useEffect as Sn,useRef as _n}from"react";function Mn(e,t,n,r){Sn(()=>{e.current?.updateConfig(t),n.current=!0,r()},[t,r,e,n])}function Cn(e,t,n,r){const o=_n(null);Sn(()=>{const i=e.current;if(!i)return;const s=t??null;o.current!==s&&(o.current=s,i.setLayoutSelection(s),i.hasCustomRestyle?i.restyleScene(s):n.current=!0,r())},[t,r,e,n])}function Pn(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function Tn(e,t=30){return Math.max((e??4)+5,12,t)}function Rn(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function Nn(e,t){const n=Rn(e);if(!n)return!1;const r=Rn(t);return!r||n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()}function Dn(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}var Ln=[40,40],En=[.5,.5];function In(e,t){const[n,r]=e.viewBox??Ln,[o,i]=e.anchor??En,s=r>0?r:1,a=Math.max(0,t)/s,c=(n>0?n:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-o*c,offsetY:-i*l}}function Wn(e,t,n,r){if("none"!==e)return"color"===e||null==e?t??r:"accent"===e?n:e}var $n=null;function zn(e){if("undefined"==typeof Path2D)return null;$n||($n=new Map);const t=$n.get(e);if(t)return t;const n=new Path2D(e);return $n.size>1024&&$n.clear(),$n.set(e,n),n}function On(e,t,n=0,r="horizontal"){const[o,i]=e.viewBox??Ln,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a>s?s>0||1>a?"vertical"===r?{x:0,y:i*(1-a),width:o,height:i*(a-s)}:{x:o*s,y:0,width:o*(a-s),height:i}:null:{x:0,y:0,width:0,height:0}}function Fn(e,t){const n=In(e,t);return{centerDx:n.offsetX+n.width/2,centerDy:n.offsetY+n.height/2,halfWidth:n.width/2,halfHeight:n.height/2,radius:Math.hypot(n.width,n.height)/2}}function Bn(e,t,n,r,o,i=e=>e){for(const s of t.parts){const t=zn(s.d);if(!t)continue;const a=s.opacity??1,c=e.globalAlpha;1!==a&&(e.globalAlpha=c*a);const l=o?"none"===s.fill?void 0:o:Wn(s.fill,n,r);l&&(e.fillStyle=i(l),e.fill(t));const u=o?s.stroke&&"none"!==s.stroke?o:void 0:Wn(s.stroke??"none",n,r);u&&(e.strokeStyle=i(u),e.lineWidth=s.strokeWidth??1,e.lineCap=s.strokeLinecap??"butt",e.lineJoin=s.strokeLinejoin??"miter",e.stroke(t)),1!==a&&(e.globalAlpha=c)}}function Yn(e,t,n,r,o,i=e=>e.x,s=e=>e.y,a=e=>e.r){const c=Math.max(r,o+5,12),l=t-c,u=t+c,h=n-c,d=n+c;let f=null,y=1/0;return e.visit((e,o,c,p,g)=>{if(o>u||l>p||c>d||h>g)return!0;if(!e.length){let o=e;do{const e=o.data,c=i(e)-t,l=s(e)-n,u=Math.sqrt(c*c+l*l);Tn(a(e),r)>=u&&y>u&&(f=e,y=u),o=o.next}while(o)}return!1}),f?{node:f,distance:y}:null}var jn=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Hn=new WeakMap,Xn=0,Gn=!1,Vn=null,qn=null;function Un(e,t){if(!t)return t;const n=jn.exec(t);if(!n)return t;const r=e.canvas;if(!r)return n[2]?.trim()||t;!function(){if(Gn)return;if("undefined"==typeof window||"undefined"==typeof document)return;Gn=!0;const e=()=>{Xn++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]}),"function"==typeof window.matchMedia)try{Vn=window.matchMedia("(prefers-color-scheme: dark)"),qn=e,"function"==typeof Vn.addEventListener?Vn.addEventListener("change",qn):"function"==typeof Vn.addListener&&Vn.addListener(qn)}catch{}}();let o=Hn.get(r);o&&o.version===Xn||(o={version:Xn,map:new Map},Hn.set(r,o));const i=o.map.get(t);if(void 0!==i)return i;const s=getComputedStyle(r).getPropertyValue(n[1]).trim()||n[2]?.trim()||t;return o.map.set(t,s),s}var Kn=null;import{jsx as Qn,jsxs as Zn}from"react/jsx-runtime";function Jn(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function er(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}var tr=new Map;function nr(e,t){const{background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:s=45,lineOpacity:a=1}=e,c=Math.max(8,Math.ceil(2*i));return Zn("pattern",{id:t,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[n&&"transparent"!==n&&Qn("rect",{width:c,height:c,fill:n}),Qn("line",{x1:0,y1:0,x2:0,y2:c,stroke:r,strokeWidth:o,strokeOpacity:a}),Qn("line",{x1:i,y1:0,x2:i,y2:c,stroke:r,strokeWidth:o,strokeOpacity:a})]},t)}function rr(e,t,n="#4e79a7"){if(Jn(e)){const n=function(e,t){let n=2166136261;const r=er(t);for(let e=0;r.length>e;e++)n^=r.charCodeAt(e),n=Math.imul(n,16777619);return`${e}-hatch-${(n>>>0).toString(36)}`}(t,e);return{fill:`url(#${n})`,def:nr(e,n)}}return e&&"string"==typeof e?{fill:e}:{fill:n}}import{curveMonotoneX as or,curveMonotoneY as ir,curveCardinal as sr,curveCatmullRom as ar,curveStep as cr,curveStepBefore as lr,curveStepAfter as ur,curveBasis as hr,curveNatural as dr}from"d3-shape";function fr(e){switch(e){case"monotoneX":return or;case"monotoneY":return ir;case"cardinal":return sr;case"catmullRom":return ar;case"step":return cr;case"stepBefore":return lr;case"stepAfter":return ur;case"basis":return hr;case"natural":return dr;default:return null}}function yr(e,t,n){if(null==t)return n;if(Jn(t)){const r=function(e,t){const n="undefined"!=typeof window&&window.devicePixelRatio||1,r=`${er(e)}@${n}`,o=tr.get(r);if(void 0!==o)return o;const i=function(e={},t){const{background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:s=45}=e,a=Math.max(8,Math.ceil(2*i));let c;try{c=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Kn||(Kn=document.createElement("canvas")),Kn.width=e,Kn.height=e,Kn)}(a)}catch{return null}const l=c.getContext("2d");if(!l)return null;n&&"transparent"!==n?(l.fillStyle=n,l.fillRect(0,0,a,a)):l.clearRect(0,0,a,a),l.strokeStyle=r,l.lineWidth=o,l.lineCap="square";const u=s*Math.PI/180;if(45===s||-45===s){const e=s>0?1:-1;for(let t=-a;2*a>=t;t+=i)l.beginPath(),l.moveTo(t,0),l.lineTo(t+e*a,a),l.stroke()}else{l.save(),l.translate(a/2,a/2),l.rotate(u);const e=2*a;for(let t=-e;e>=t;t+=i)l.beginPath(),l.moveTo(-e,t),l.lineTo(e,t),l.stroke();l.restore()}return(t||l).createPattern(c,"repeat")}({background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle},t);return tr.set(r,i),i}(t,e);return r||t.background&&Un(e,t.background)||n}return"string"!=typeof t?t:Un(e,t)||n}function pr(e,t,n,r,o,i,s){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,o,i,s);for(const e of n)a.addColorStop(e.offset,e.color);return a}const{topOpacity:a,bottomOpacity:c}=t;if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l=Math.max(0,Math.min(1,a)),u=Math.max(0,Math.min(1,c)),h=e.createLinearGradient(r,o,i,s),[d,f,y]=function(e,t){const n=e.fillStyle,r="#010203";try{e.fillStyle=r,e.fillStyle=t}catch{return e.fillStyle=n,[78,121,167]}const o=e.fillStyle;if(e.fillStyle=n,"string"!=typeof o)return[78,121,167];if(o.toLowerCase()===r&&t.trim().toLowerCase()!==r)return[78,121,167];if(o.startsWith("#"))return[parseInt(o.slice(1,3),16),parseInt(o.slice(3,5),16),parseInt(o.slice(5,7),16)];const i=o.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return i?[+i[1],+i[2],+i[3]]:[78,121,167]}(e,n);return h.addColorStop(0,`rgba(${d},${f},${y},${l})`),h.addColorStop(1,`rgba(${d},${f},${y},${u})`),h}function gr(e,t,n,r,o,i){const s=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>s.length)return null;const a=e.createLinearGradient(n,r,o,i);for(const e of s)a.addColorStop(e.offset,e.color);return a}import{line as mr}from"d3-shape";var vr=new WeakMap;function xr(e,t){const n=fr(t);if(!n)return e;const r=vr.get(e);if(r)return r;const o=function(e,t,n=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const r=[];let o=null;const i={moveTo(e,t){o=[e,t],r.push([e,t])},lineTo(e,t){o=[e,t],r.push([e,t])},bezierCurveTo(e,t,i,s,a,c){if(!o)return o=[a,c],void r.push([a,c]);const[l,u]=o;for(let o=1;n>=o;o++){const h=o/n,d=1-h;r.push([d*d*d*l+3*d*d*h*e+3*d*h*h*i+h*h*h*a,d*d*d*u+3*d*d*h*t+3*d*h*h*s+h*h*h*c])}o=[a,c]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,n,i){o=[n,i],r.push([n,i])}};return mr().x(e=>e[0]).y(e=>e[1]).curve(t).context(i)(e),r}(e,n);return vr.set(e,o),o}function br(e,t,n,r=30,o,i=0){let s=null;if(o){const e=Yn(o,t,n,r,i);e&&(s={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const i of e){let e=null;switch(i.type){case"point":if(o)break;e=wr(i,t,n,r);break;case"symbol":e=Ar(i,t,n,r);break;case"glyph":e=Sr(i,t,n,r);break;case"line":e=_r(i,t,n,r);break;case"rect":if(null==i.datum)break;e=Cr(i,t,n);break;case"heatcell":e=Pr(i,t,n);break;case"area":if(!1===i.interactive)break;e=Rr(i,t,n);break;case"candlestick":e=Tr(i,t,n)}e&&r>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function kr(e,t,n){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const r=Nr(e,t);if(0>r)return null;if(Math.abs(e[r][0]-t)>n)return null;let o=r,i=r;r>0&&e[r][0]>=t?(o=r-1,i=r):e.length-1>r&&(o=r,i=r+1);const[s,a]=e[o],[c,l]=e[i];return c===s?a:a+Math.max(0,Math.min(1,(t-s)/(c-s)))*(l-a)}function wr(e,t,n,r=30){const o=t-e.x,i=n-e.y,s=Math.sqrt(o*o+i*i);return s>Tn(e.r,r)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function Ar(e,t,n,r=30){const o=t-e.x,i=n-e.y,s=Math.sqrt(o*o+i*i);return s>Tn(ft(e.size),r)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function Sr(e,t,n,r=30){if(null==e.datum)return null;const o=Fn(e.glyph,e.size),i=e.x+o.centerDx,s=e.y+o.centerDy,a=t-i,c=n-s,l=Math.sqrt(a*a+c*c);return l>Tn(o.radius,r)?null:{node:e,datum:e.datum,x:i,y:s,distance:l}}function _r(e,t,n,r=30){if(0===e.path.length)return null;const o=Nr(e.path,t);if(0>o)return null;const[i,s]=e.path[o];let a;if(e.path.length>1){let r=1/0;const i=Math.max(0,o-1),s=Math.min(e.path.length-2,o);for(let o=i;s>=o;o++){const[i,s]=e.path[o],[a,c]=e.path[o+1],l=Mr(t,n,i,s,a,c);r>l&&(r=l)}a=r}else{const e=t-i,r=n-s;a=Math.sqrt(e*e+r*r)}const c=e.style;return a>Math.max(5,(c.strokeWidth??c.lineWidth??1)/2+2,r)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:i,y:s,distance:a}}function Mr(e,t,n,r,o,i){const s=o-n,a=i-r,c=s*s+a*a;if(0===c)return Math.sqrt((e-n)**2+(t-r)**2);let l=((e-n)*s+(t-r)*a)/c;return l=Math.max(0,Math.min(1,l)),Math.sqrt((e-(n+l*s))**2+(t-(r+l*a))**2)}function Cr(e,t,n){const r=Pn(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function Pr(e,t,n){const r=Pn(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function Tr(e,t,n){const r=e.bodyWidth/2,o=Math.min(e.openY,e.closeY);if(!(e.x-r-3>t||t>e.x+r+3||e.highY-3>n||n>e.lowY+3)){const r=o+Math.max(Math.max(e.openY,e.closeY)-o,1)/2,i=t-e.x,s=n-r;return{node:e,datum:e.datum,x:e.x,y:r,distance:Math.sqrt(i*i+s*s)}}return null}function Rr(e,t,n){if(0===e.topPath.length)return null;const r=Nr(e.topPath,t);if(0>r)return null;const[o,i]=e.topPath[r],s=t-o,a=n-i,c=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:o,y:i,distance:c}}function Nr(e,t){if(0===e.length)return-1;let n=0,r=e.length-1;for(;r>n;){const o=n+r>>1;t>e[o][0]?n=o+1:r=o}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}import{useEffect as Dr,useRef as Lr}from"react";var Er={fresh:1,aging:.7,stale:.45,expired:.25},Ir={alpha:1,band:"fresh",isStale:!1};function Wr(e,t){if(!e||0>=t)return Ir;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,r=e.graded;if(r){const e="object"==typeof r?r:{},o=Pe(t,n,e.thresholds);return{alpha:{...Er,...e.opacities??{}}[o],band:o,isStale:"fresh"!==o}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:Ir}function $r(e,t,n,r,o,i){const s=Lr("fresh");Dr(()=>{if(!e)return;const a=setInterval(()=>{const a=t.current;if(!a||0===a.lastIngestTime)return;const c="undefined"!=typeof performance?performance.now():Date.now(),l=Wr(e,c-a.lastIngestTime);l.band===s.current&&l.isStale===o||(s.current=l.band,l.isStale!==o&&i(l.isStale),n.current=!0,r())},1e3);return()=>clearInterval(a)},[e,o,r,t,i,n])}import{jsx as zr}from"react/jsx-runtime";function Or({isStale:e,position:t}){return zr("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===t?{top:4,left:4}:"bottom-left"===t?{bottom:4,left:4}:"bottom-right"===t?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:e?"#dc3545":"#28a745",color:"white"},children:e?"STALE":"LIVE"})}import{useMemo as Fr,useRef as Br,useEffect as Yr}from"react";import*as jr from"react";import{jsx as Hr,jsxs as Xr}from"react/jsx-runtime";var Gr={fill:(e,t)=>Hr("rect",{style:e,width:t,height:t}),line:(e,t)=>Hr("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function Vr(e,t,n,r,o){let i;return i="function"==typeof n?n(e):(0,Gr[n])(r(e,t),o),i}function qr({swatchSize:e}){return Hr("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 Ur(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var Kr=(e,t,n,r,o,i,s,a,c,l,u)=>{const{type:h="fill",styleFn:d,items:f}=e,y=[];let p=0;const g=!(!t&&!n),m="isolate"===l||void 0===l&&null!=o,{swatchSize:v,labelGap:x,rowHeight:b}=u;return f.forEach((e,l)=>{const u=Vr(e,l,h,d,v),k=Ur(e,r,o),w=o&&o.size>0&&o.has(e.label);y.push(Xr("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===i&&l===s?0:-1:void 0,role:g?"option":void 0,"aria-selected":g&&m?w||!1:void 0,"aria-current":g&&!m&&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=(l+("ArrowDown"===n.key?1:-1)+f.length)%f.length;c(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:g?t=>{c(a,l),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:k,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[g&&Hr("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:v+x+2+7*e.label.length,height:v+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,w&&Hr(qr,{swatchSize:v}),Hr("text",{y:v/2,x:v+x,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+l)),p+=b}),y};function Qr({config:e,orientation:t="vertical",width:n=100}){const{colorFn:r,domain:o,label:i,format:s}=e,a=s||(e=>Math.round(100*e)/100+""),c="grad-legend-"+jr.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),s=Math.max(0,(n-t)/2),l=[];for(let e=0;64>=e;e++){const t=e/64;l.push(Hr("stop",{offset:100*t+"%",stopColor:r(o[0]+t*(o[1]-o[0]))},e))}return Xr("g",{"aria-label":i||"Gradient legend",children:[Hr("defs",{children:Hr("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:l})}),i&&Hr("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),Hr("rect",{x:s,y:0,width:t,height:e,fill:`url(#${c})`,rx:2}),Hr("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[0])}),Hr("text",{x:s+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[1])})]})}const l=[];for(let e=0;64>=e;e++){const t=e/64;l.push(Hr("stop",{offset:100*t+"%",stopColor:r(o[1]-t*(o[1]-o[0]))},e))}return Xr("g",{"aria-label":i||"Gradient legend",children:[i&&Hr("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),Hr("defs",{children:Hr("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:l})}),Hr("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),Hr("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[1])}),Hr("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[0])})]})}function Zr(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,legendInteraction:s,title:a="Legend",width:c=100,height:l=20,orientation:u="vertical",legendLayout:h}=e,d=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}}(h),[f,y]=jr.useState(0),[p,g]=jr.useState(0),m=jr.useCallback((e,t)=>{y(e),g(t)},[]),v="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:l,metrics:u})=>{let h=24;const d=[];return e.forEach((e,f)=>{h+=5,d.push(Hr("line",{stroke:"gray",x1:0,y1:h,x2:t,y2:h},"legend-top-line legend-symbol-"+f)),h+=8,e.label&&(h+=16,d.push(Hr("text",{y:h,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),h+=8),d.push(Hr("g",{className:"legend-item",transform:`translate(0,${h})`,children:Kr(e,n,r,o,i,s,a,f,c,l,u)},"legend-group-"+f)),h+=e.items.length*u.rowHeight+8}),d})({legendGroups:t||[],width:c,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:s,metrics:d}):(({legendGroups:e,height:t,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:c,onFocusedIndexChange:l,legendInteraction:u,metrics:h})=>{let d=0;const f=[];e.forEach((e,t)=>{let y=0;e.label&&(y+=16);const p=((e,t,n,r,o,i,s,a,c,l,u,h)=>{const{type:d="fill",styleFn:f,items:y}=e,p=[],{swatchSize:g,labelGap:m,itemGap:v,rowHeight:x,align:b}=u,k=!(!t&&!n),w="isolate"===l||void 0===l&&null!=o,A=y.map(e=>g+m+7*e.label.length),S=[];let _=0,M=0;A.forEach((e,t)=>{const n=0===M?e:M+v+e;h&&h>0&&M>0&&n>h?(S.push({start:_,end:t,width:M}),_=t,M=e):M=n}),y.length>0&&S.push({start:_,end:y.length,width:M}),S.forEach((e,l)=>{let u="center"===b?Math.max(0,((h??e.width)-e.width)/2):"end"===b?Math.max(0,(h??e.width)-e.width):0;for(let h=e.start;e.end>h;h++){const e=y[h],b=Vr(e,h,d,f,g),S=Ur(e,r,o),_=o&&o.size>0&&o.has(e.label);p.push(Xr("g",{transform:`translate(${u},${l*x})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:k?a===i&&h===s?0:-1:void 0,role:k?"option":void 0,"aria-selected":k&&w?_||!1:void 0,"aria-current":k&&!w&&null!=r&&e.label===r||void 0,"aria-label":e.label,onKeyDown:k?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(h+("ArrowRight"===n.key?1:-1)+y.length)%y.length;c(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:k?t=>{c(a,h),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.setAttribute("visibility","visible")}:void 0,onBlur:k?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:k?"pointer":"default",opacity:S,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[k&&Hr("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:g+m+2+7*e.label.length,height:g+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),b,_&&Hr(qr,{swatchSize:g}),Hr("text",{y:g/2,x:g+m,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+h)),u+=A[h]+v}});const C=Math.max(0,...S.map(e=>e.width)),P=S.length;return{items:p,offset:C,totalRows:P,totalHeight:P*x}})(e,r,o,i,s,a,c,t,l,u,h,h.maxWidth??n);y+=p.offset+5,f.push({label:e.label,...p,offset:y,totalRows:p.totalRows,totalHeight:p.totalHeight}),d+=y+12});const y=h.maxWidth??n;let p=d>y?0:"center"===h.align?Math.max(0,(y-d)/2):"end"===h.align?Math.max(0,y-d):0;const g=[];return f.forEach((n,r)=>{const o=e[r];o.label&&(g.push(Hr("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:o.label},"legend-text-"+r)),p+=16),g.push(Hr("g",{className:"legend-item",transform:`translate(${p},0)`,children:n.items},"legend-group-"+r)),p+=n.offset+5,e[r+1]&&g.push(Hr("line",{stroke:"gray",x1:p,y1:-8,x2:p,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+r)),p+=12}),Hr("g",{children:g})})({legendGroups:t||[],title:a,height:l,width:c,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:p,onFocusedIndexChange:m,legendInteraction:s,metrics:d}),x=!(!n&&!r);return Xr("g",{role:x?"listbox":void 0,"aria-multiselectable":!(!x||"isolate"!==s&&(void 0!==s||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===u&&Hr("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),v]})}function Jr(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}import{jsx as eo}from"react/jsx-runtime";function to(e){const{legend:t,totalWidth:n,totalHeight:r,margin:o,legendPosition:i="right",legendLayout:s,title:a,legendHoverBehavior:c,legendClickBehavior:l,legendHighlightedCategory:u,legendIsolatedCategories:h,legendInteraction:d}=e;if(!t)return null;const f="top"===i||"bottom"===i,y=!!a,p=Math.max(0,n-o.left-o.right),g=Math.max(1,f?s?.maxWidth??p:100);let m,v;return"left"===i?(m=Math.max(4,o.left-g-10),v=o.top):"top"===i?(m=o.left,v=y?32:8):"bottom"===i?(m=o.left,v=r-o.bottom+38):(m=n-o.right+10,v=o.top),eo("g",{transform:`translate(${m}, ${v})`,children:(x=t,"object"==typeof x&&null!==x&&"gradient"in x?eo(Qr,{config:t.gradient,orientation:f?"horizontal":"vertical",width:g}):Jr(t)?eo(Zr,{legendGroups:t.legendGroups,title:"",width:g,orientation:f?"horizontal":"vertical",legendLayout:s,customHoverBehavior:c,customClickBehavior:l,highlightedCategory:u,isolatedCategories:h,legendInteraction:d}):t)});var x}import{useMemo as no}from"react";import{bin as ro}from"d3-array";function oo(e){let t=1/0,n=-1/0;for(const r of e)t>r&&(t=r),r>n&&(n=r);return[t,n]}import{jsx as io,jsxs as so}from"react/jsx-runtime";function ao(e){return"string"==typeof e?{type:e}:e}function co({orient:e,config:t,values:n,scale:r,size:o,length:i}){const s=function(e){return{type:e.type,bins:e.bins??20,fill:e.fill??"#4e79a7",fillOpacity:e.fillOpacity??.5,stroke:e.stroke??"none",strokeWidth:e.strokeWidth??1}}(t),a="top"===e||"bottom"===e,c=no(()=>{if(0===n.length)return null;const t=r.domain(),c=o-8;if("boxplot"===s.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const r=t[Math.floor(.25*n)],o=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],s=i-r;return{q1:r,median:o,q3:i,whiskerLow:Math.max(t[0],r-1.5*s),whiskerHigh:Math.min(t[n-1],i+1.5*s)}}(n);if(!t)return null;const{q1:o,median:i,q3:l,whiskerLow:u,whiskerHigh:h}=t,d=Math.min(.5*c,20),f=(c-d)/2+4;if(a){const t=r(o),n=r(l),a=r(i),c=r(u),y=r(h),p="top"===e?-1:1,g=0;return so("g",{"data-testid":"marginal-boxplot-"+e,children:[io("line",{x1:c,y1:g+p*(f+d/2),x2:y,y2:g+p*(f+d/2),stroke:s.fill,strokeWidth:s.strokeWidth}),io("line",{x1:c,y1:g+p*f,x2:c,y2:g+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),io("line",{x1:y,y1:g+p*f,x2:y,y2:g+p*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),io("rect",{x:Math.min(t,n),y:"top"===e?g-f-d:g+f,width:Math.abs(n-t),height:d,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),io("line",{x1:a,y1:"top"===e?g-f-d:g+f,x2:a,y2:"top"===e?g-f:g+f+d,stroke:s.fill,strokeWidth:2})]})}{const t=r(o),n=r(l),a=r(i),c=r(u),y=r(h),p="left"===e?-1:1,g=0;return so("g",{"data-testid":"marginal-boxplot-"+e,children:[io("line",{x1:g+p*(f+d/2),y1:c,x2:g+p*(f+d/2),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),io("line",{x1:g+p*f,y1:c,x2:g+p*(f+d),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),io("line",{x1:g+p*f,y1:y,x2:g+p*(f+d),y2:y,stroke:s.fill,strokeWidth:s.strokeWidth}),io("rect",{x:"left"===e?g-f-d:g+f,y:Math.min(t,n),width:d,height:Math.abs(n-t),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),io("line",{x1:"left"===e?g-f-d:g+f,y1:a,x2:"left"===e?g-f:g+f+d,y2:a,stroke:s.fill,strokeWidth:2})]})}}const l=ro().domain(t).thresholds(s.bins)(n);if(0===l.length)return null;const u=function(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}(l.map(e=>e.length));if(0===u)return null;if("histogram"===s.type)return io("g",{"data-testid":"marginal-histogram-"+e,children:l.map((t,n)=>{if(null==t.x0||null==t.x1)return null;const o=t.length/u*c;if(a){const i=r(t.x0),a=r(t.x1)-r(t.x0);return io("rect",{x:i,y:"top"===e?-4-o:4,width:Math.max(a,.5),height:o,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}{const i=r(t.x0),a=r(t.x1)-r(t.x0);return io("rect",{x:"left"===e?-4-o:4,y:Math.min(i,i+a),width:o,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}})});if("violin"===s.type){const t=c/2+4,n=[];for(const o of l){if(null==o.x0||null==o.x1)continue;const i=o.length/u*(c/2),s=r((o.x0+o.x1)/2);n.push(a?`${s},${"top"===e?-(t-i):t-i}`:`${"left"===e?-(t-i):t-i},${s}`)}for(let o=l.length-1;o>=0;o--){const i=l[o];if(null==i.x0||null==i.x1)continue;const s=i.length/u*(c/2),h=r((i.x0+i.x1)/2);n.push(a?`${h},${"top"===e?-(t+s):t+s}`:`${"left"===e?-(t+s):t+s},${h}`)}return io("g",{"data-testid":"marginal-violin-"+e,children:io("polygon",{points:n.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}if("ridgeline"===s.type){const t=[];if(a){const n=0,o=null!=l[0].x0?r(l[0].x0):0;t.push(`M${o},${n}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const o=n.length/u*c,i=r((n.x0+n.x1)/2);t.push(`L${i},${"top"===e?-o-4:o+4}`)}const s=null!=l[l.length-1].x1?r(l[l.length-1].x1):i;t.push(`L${s},${n}`),t.push("Z")}else{const n=0,o=null!=l[0].x0?r(l[0].x0):0;t.push(`M${n},${o}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const o=n.length/u*c,i=r((n.x0+n.x1)/2);t.push(`L${"left"===e?-o-4:o+4},${i}`)}const s=null!=l[l.length-1].x1?r(l[l.length-1].x1):i;t.push(`L${n},${s}`),t.push("Z")}return io("g",{"data-testid":"marginal-ridgeline-"+e,children:io("path",{d:t.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}return null},[n,r,s,o,i,e,a,4]);return c?io("g",{className:"marginal-"+e,"data-testid":"marginal-"+e,children:c}):null}import*as lo from"react";import{jsx as uo,jsxs as ho}from"react/jsx-runtime";function fo(e,t=120,n=8){if(!e)return[];const r=Math.max(1,Math.floor(t/n)),o=e.split(/\s+/),i=[];let s="";for(const e of o)s&&s.length+1+e.length>r?(i.push(s),s=e):s=s?`${s} ${e}`:e;return s&&i.push(s),i}function yo(e,t,n,r){return"curly"===e?r?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:r?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function po(e,t,n,r){if(!e)return uo("g",{className:"annotation-note"});const{label:o,title:i,orientation:s,align:a,wrap:c=120,noWrap:l}=e;if(!o&&!i)return uo("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let d="start";"topBottom"===u?"right"===h?d="end":"middle"===h&&(d="middle"):d=0>t?"end":"start";const f=16,y=i?l?[i]:fo(i,c):[],p=o?l?[o]:fo(o,c):[],g="leftRight"===u?"end"===d?-4:4:0;let m=0;const v=[],x=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?v.push(uo("foreignObject",{className:"annotation-note-html",x:"end"===d?g-c:"middle"===d?g-c/2:g,y:-16,width:c,height:Math.max(f,(y.length+p.length)*f+(i&&o?2:0))+f,style:{overflow:"visible"},children:ho("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:x,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===d?"right":"middle"===d?"center":"left",whiteSpace:l?"nowrap":"normal",wordBreak:"break-word"},children:[i&&uo("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),o&&uo("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html")):(y.length>0&&(v.push(uo("text",{className:"annotation-note-title",fill:x,textAnchor:d,fontWeight:"bold",children:y.map((e,t)=>uo("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-title")),m=y.length*f),p.length>0&&v.push(uo("text",{className:"annotation-note-label",fill:x,textAnchor:d,y:m,children:p.map((e,t)=>uo("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-label")));let b=null;if((i||o)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(c,120);let t=0,n=e;"end"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),b=uo("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(y.length+p.length)*f+(p.length>0?f:0);let t=0,n=e;"bottom"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),b=uo("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const k=Math.max(0,y.length+p.length-1)*f;let w=0;return"topBottom"===u?w=0>n?-(k+2):18:"leftRight"===u&&(w="middle"===h?-(k+f+(p.length>0&&y.length>0?2:0))/2+8:"bottom"===h||0>n?-(k+2):18),ho("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[uo("g",{className:"annotation-note-content",transform:0!==w?`translate(0,${w})`:void 0,children:v}),b]})}function go(e,t,n,r,o){const i=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&i.push(uo("circle",{r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,r=t?.height||0;(e>0||r>0)&&i.push(uo("rect",{width:e,height:r,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":t?.custom&&i.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=r||0,s=o||0;if(void 0!==t?.x){const r=(t.x||0)-e;i.push(uo("line",{x1:r,y1:(t.y1||0)-s,x2:r,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const r=(t.y||0)-s;i.push(uo("line",{x1:(t.x1||0)-e,y1:r,x2:(t.x2||0)-e,y2:r,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?i.push(uo("line",{x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===t?.y1&&void 0===t?.y2||i.push(uo("line",{x1:0,y1:(t.y1||0)-s,x2:0,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=t?.type||"curly",r=t?.width??t?.height;void 0!==r&&i.push(uo("path",{d:yo(e,r,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return uo("g",{className:"annotation-subject",children:i})}function mo(e,t,n,r,o,i){const s=[];let a=0,c=0;if("callout-circle"!==o&&"label"!==o||!i?.radius){if("callout-rect"===o&&i){const n=i.width||0,r=i.height||0;if(n>0||r>0){const o=n/2,i=r/2,s=e-o,l=t-i;if(0!==s||0!==l){const e=Math.abs(s),t=Math.abs(l),u=n/2,h=r/2,d=e*h>t*u?u/e:h/t;a=o+s*d,c=i+l*d}}}else if("bracket"===o&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(a=e/2,c=n):void 0!==t&&(a=n,c=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const r=Math.atan2(t,e);a=Math.cos(r)*n,c=Math.sin(r)*n}}const l=Math.sqrt((e-a)**2+(t-c)**2);if(l>.5){const o=r||"var(--semiotic-text-secondary, currentColor)",i="curve"===n?.type;let u=Math.atan2(t-c,e-a);if(i){const r=(a+e)/2,i=(c+t)/2,h=-(t-c)/l,d=(e-a)/l,f=(n?.curve??.25)*l,y=r+h*f,p=i+d*f;s.push(uo("path",{className:"connector-curve",d:`M${a},${c}Q${y},${p} ${e},${t}`,fill:"none",stroke:o},"connector-line")),u=Math.atan2(p-c,y-a)}else s.push(uo("line",{x1:a,y1:c,x2:e,y2:t,stroke:o},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;s.push(uo("path",{d:`M${a},${c}L${a+e*Math.cos(u+t)},${c+e*Math.sin(u+t)}L${a+e*Math.cos(u-t)},${c+e*Math.sin(u-t)}Z`,fill:o,stroke:"none"},"connector-arrow"))}}return uo("g",{className:"annotation-connector",children:s})}function vo(e){const{x:t=0,y:n=0,dx:r,dy:o,nx:i,ny:s,note:a,connector:c,subject:l,type:u,color:h,className:d,disable:f,opacity:y,strokeDasharray:p,events:g={},"data-testid":m}=e,v=Array.isArray(t)?t[0]??0:t,x=Array.isArray(n)?n[0]??0:n,b=new Set(Array.isArray(f)?f:[]);let k=r||0,w=o||0;null!=i&&(k=i-v),null!=s&&(w=s-x);const A="string"==typeof u?u:"label";if("bracket"===A&&l&&0===k&&0===w)if(void 0!==l.width){k=l.width/2;const e=l.depth||30;w=e+(0>e?-5:5)}else if(void 0!==l.height){const e=l.depth||30;k=e+(0>e?-5:5),w=l.height/2}return ho("g",{className:("annotation "+(d||"")).trim(),transform:`translate(${v},${x})`,"data-testid":m,...null!=y&&{opacity:y},...p&&{strokeDasharray:p},...g,children:[!b.has("connector")&&mo(k,w,c,h,A,l),!b.has("subject")&&go(A,l,h,v,x),!b.has("note")&&po(a,k,w,h)]})}function xo(e){const{noteData:t}=e,{screenCoordinates:n}=t,r="string"==typeof t.type?t.type:"label",o=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),o=t.ny||n[0][1]+(t.dy??0),i=n.map((n,i)=>{const s=Object.assign({},t,{note:0===i?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:o});return uo(vo,{"data-testid":"semiotic-annotation",...s,type:r},"multi-annotation-"+i)});return uo("g",{children:i})}const i=t.note||{title:"none",label:t.label},s=`${i.label}-${i.title}-${t.i}`;return uo(vo,{"data-testid":"semiotic-annotation",events:o,...t,type:r},s)}import{packEnclose as bo}from"d3-hierarchy";import{area as ko,curveLinear as wo,curveMonotoneX as Ao,curveMonotoneY as So,curveStep as _o,curveStepAfter as Mo,curveStepBefore as Co,curveBasis as Po,curveCardinal as To,curveCatmullRom as Ro}from"d3-shape";function No(e){return Math.round(100*e)/100}function Do(e,t=2){const n=[],r=[],o=t+1;for(let t=0;o>t;t++){let i=0;for(const[n,r]of e)null!==r&&(i+=n**t*r);n.push(i);const s=[];for(let n=0;o>n;n++){let r=0;for(const[o,i]of e)null!==i&&(r+=o**(t+n));s.push(r)}r.push(s)}r.push(n);const i=function(e,t){const n=e,r=e.length-1,o=[t];for(let e=0;r>e;e++){let t=e;for(let o=e+1;r>o;o++)Math.abs(n[e][o])>Math.abs(n[e][t])&&(t=o);for(let o=e;r+1>o;o++){const r=n[o][e];n[o][e]=n[o][t],n[o][t]=r}for(let t=e+1;r>t;t++)for(let o=r;o>=e;o--)n[o][t]-=n[o][e]*n[e][t]/n[e][e]}for(let e=r-1;e>=0;e--){let t=0;for(let i=e+1;r>i;i++)t+=n[i][e]*o[i];o[e]=(n[r][e]-t)/n[e][e]}return o}(r,o).map(No);return{points:e.map(([e])=>[No(e),No(i.reduce((t,n,r)=>t+n*e**r,0))]),equation:[...i].reverse()}}function Lo(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function Eo(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function Io(e){return null==e?null:e+""}function Wo(e,t,n){return t.stickyPositionCache?.set(e,n),n}function $o(e,t,n){const r=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===r){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const o=n.pointNodes[r];if(o.pointId===e.pointId)return Wo(t,n,{x:o.x,y:o.y})}const r=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],r=e.scales?.x??e.scales?.time,o=e.scales?.y??e.scales?.value;if(!r||!o)return null;const i=n[e.xAccessor||"x"],s=n[e.yAccessor||"y"];return null==i||null==s?null:{x:r(i),y:o(s)}}(n);return r?Wo(t,n,r):null}if("semantic"===r){const r=function(e,t,n){const r=function(e){return Io(e.provenance?.stableId??e.stableId)}(e);if(!r)return null;const o=n.pointNodes?.find(e=>Io(e.pointId)===r);if(o)return Wo(t,n,{x:o.x,y:o.y});const i=n.data?.find(e=>function(e){return Io(e.stableId??e.id??e.provenance?.stableId)}(e)===r);if(!i)return null;const s=Lo(i,n),a=Eo(i,n);return null==s||null==a?null:Wo(t,n,{x:s,y:a})}(e,t,n);if(r)return r}let o=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(o=t.x,i=t.y)}if(null!=o&&null!=i||(o=Lo(e,n),i=Eo(e,n)),null!=o&&null!=i)return Wo(t,n,{x:o,y:i});if("sticky"===r){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function zo(e,t,n,r=50){return!(-r>e||e>(n.width||0)+r||-r>t||t>(n.height||0)+r)}import{jsx as Oo}from"react/jsx-runtime";var Fo={secondary:0,primary:3},Bo=".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 Yo(e){return!0===e?._annotationDeferred}function jo(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function Ho(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function Xo(e){return Math.max(.72,.95-.06*e)}import*as Go from"react";var[Vo,qo]=E(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function Uo(e){const t=qo(e=>e.pushObservation),n=Go.useCallback(n=>{e.onObservation?.(n),t?.(n)},[e,t]);return Go.useMemo(()=>({...e,onObservation:n}),[n,e])}function Ko(e,t={}){const n=function(e){const t=e.provenance,n=e.id??e.stableId??t?.stableId;return null==n||""===n?void 0:n+""}(e);return{"data-semiotic-annotation-widget":"",...n?{"data-semiotic-annotation-id":n}:{},onClickCapture(r){const o=function(e){const t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}(r);t.onAnnotationActivate?.({annotation:e,annotationId:n,chartId:t.chartId,inputType:o}),n&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:n,inputType:o,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}function Qo(e){return e instanceof Element&&null!=e.closest("[data-semiotic-annotation-widget]")}import{jsx as Zo,jsxs as Jo}from"react/jsx-runtime";var ei="var(--semiotic-bg, #ffffff)";function ti(e){const{x:t,y:n,text:r,fill:o,fontSize:i=12,fontWeight:s,fontFamily:a,textAnchor:c="start",dominantBaseline:l,background:u,className:h}=e,d=function(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{type:e.type??"halo",...e}}(u),f=e=>Zo("text",{x:t,y:n,textAnchor:c,dominantBaseline:l,fill:o,fontSize:i,fontWeight:s,fontFamily:a,className:h,...e?{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}:{},children:r});if(!d)return f();if("halo"===d.type)return f({stroke:d.fill??ei,strokeWidth:d.haloWidth??3});const y=d.padding??{x:6,y:3},p="number"==typeof y?y:y.x,g="number"==typeof y?y:y.y,m=function(e,t){return(e+"").length*t*.6}(r,i),v=i+2*g;let x,b;return x="middle"===c?t-m/2-p:"end"===c?t-m-p:t-p,b="middle"===l||"central"===l?n-v/2:"hanging"===l||"text-before-edge"===l?n-g:n-.8*i-g,Jo("g",{className:h,children:[Zo("rect",{x:x,y:b,width:m+2*p,height:v,rx:d.radius??3,ry:d.radius??3,fill:d.fill??ei,fillOpacity:d.opacity??.85,stroke:d.stroke,strokeWidth:d.strokeWidth}),f()]})}import{jsx as ni,jsxs as ri}from"react/jsx-runtime";var oi={linear:wo,monotoneX:Ao,monotoneY:So,step:_o,stepAfter:Mo,stepBefore:Co,basis:Po,cardinal:To,catmullRom:Ro};function ii(e,t,n,r){const o=[];return e.forEach((e,i)=>{let s;if(n){const o=n(e,i,r);s=null!=o?o:t(e,i,r)}else s=t(e,i,r);s&&o.push({node:s,annotation:e})}),function(e){const t=e.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:Ho(e.annotation),readingOrder:null,rank:1};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>Yo(e.annotation)),o=e.some(e=>null!=jo(e.annotation)),i=e.some(e=>"layer"===jo(e.annotation));if(!n&&!r&&!o)return e.map(e=>e.node);const s=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);s.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,s.length)});for(const e of t)e.emphasis&&(e.rank=Fo[e.emphasis]);const a=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:n,emphasis:r,readingOrder:o}=e,i=Yo(t.annotation);let s=t.node;if("primary"===r||"secondary"===r||null!=o){const e=null==r&&null!=o;s=Oo("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:Xo(o),"data-annotation-reading-order":o}:{},children:t.node},"annotation-emphasis-"+n)}const a=jo(t.annotation);return a&&(s=Oo("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),i&&(s=Oo("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return r&&a.unshift(Oo("style",{children:Bo},"annotation-disclosure-style")),i&&a.unshift(Oo("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),a}(o)}function si(e,t={}){return function(e,n,r){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const t=$o(e,n,r);if(!t)return null;const{x:o,y:i}=t;if(!zo(o,i,r))return null;const s="callout"===e.type?"callout-circle":e.type,a="callout-circle"===s?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===s?{width:e.width,height:e.height}:void 0;return ni(xo,{noteData:{x:o,y:i,dx:e.dx??30,dy:e.dy??-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:s,...a?{subject:a}:{},connector:e.connector||{end:"arrow"},color:e.color,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-"+n)}case"x-threshold":{const t=Lo(null!=e.value?{...e,x:e.value}:e,r);if(null==t)return null;const o=e.color||"#f97316",i=e.labelPosition||"top";let s;s="bottom"===i?(r.height||0)-4:"center"===i?(r.height||0)/2:16;const a=t>.6*(r.width||0),c=a?t-4:t+4,l=a?"end":"start";return ri("g",{opacity:e.opacity,children:[ni("line",{x1:t,y1:0,x2:t,y2:r.height||0,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&ni(ti,{x:c,y:s,text:e.label,textAnchor:l,fill:o,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"y-threshold":{const t=Eo(null!=e.value?{...e,y:e.value}:e,r);if(null==t)return null;const o=e.color||"#f97316",i=e.labelPosition||"right";let a,c;"left"===i?(a=4,c="start"):"center"===i?(a=(r.width||0)/2,c="middle"):(a=(r.width||0)-4,c="end");const l=20>(s=t)?Math.min((r.height||0)-4,s+16):s-4;return ri("g",{opacity:e.opacity,children:[ni("line",{x1:0,y1:t,x2:r.width||0,y2:t,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&ni(ti,{x:a,y:l,text:e.label,textAnchor:c,fill:o,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"enclose":{const t=(e.coordinates||[]).map(e=>({x:Lo({...e,type:"point"},r),y:Eo({...e,type:"point"},r),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const o=bo(t),i=e.padding||10;return ri("g",{children:[ni("circle",{cx:o.x,cy:o.y,r:o.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&ni(ti,{x:o.x,y:o.y-o.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"rect-enclose":{const t=(e.coordinates||[]).map(e=>({x:Lo({...e,type:"point"},r),y:Eo({...e,type:"point"},r)})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const o=e.padding||10,i=t.map(e=>e.x),s=t.map(e=>e.y),[a,c]=oo(i),[l,u]=oo(s),h=a-o,d=c+o,f=l-o;return ri("g",{children:[ni("rect",{x:h,y:f,width:d-h,height:u+o-f,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&ni(ti,{x:(h+d)/2,y:f-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"highlight":{const t=r.data||[],o="function"==typeof e.filter?t.filter(e.filter):e.field&&null!=e.value?t.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return ni("g",{children:o.map((t,n)=>{const o=Lo(t,r),s=Eo(t,r);if(null==o||null==s)return null;const a="function"==typeof e.r?e.r(t):e.r||6,c="function"==typeof e.style?e.style(t):e.style||i;return ni("circle",{cx:o,cy:s,r:a,...c},"hl-"+n)})},"ann-"+n)}case"bracket":{const t=Lo(e,r),o=Eo(e,r);return ni(xo,{noteData:{x:t??0,y:o??0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+n)}case"trend":{const t=r.data||[];if(2>t.length)return null;const o=r.xAccessor||"x",i=r.yAccessor||"y",s="ordinal"===r.frameType,a="horizontal"===r.projection,c=s?o:null,l=s?i:null;let u;const h=[],d=new Map;if(s&&c&&l){for(const e of t){const t=e[c];if(null==t)continue;const n=t+"";d.has(n)||(d.set(n,h.length),h.push(n))}u=t.map(e=>{const t=e[c],n=e[l];if(null==t||null==n)return null;const r=d.get(t+"");return null!=r?[r,+n]:null}).filter(e=>null!==e)}else u=t.map(e=>[e[o],e[i]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const f=r.scales?.x??r.scales?.time,y=r.scales?.y??r.scales?.value;if(!f||!y)return null;const p=e=>t=>{const n=Math.max(0,Math.floor(t)),r=Math.min(h.length-1,n+1),o=t-n,i=e(h[n]);return i+(e(h[r])-i)*o},g=f,m=y;let v;if(s)if(a){const e=p(m);v=(t,n)=>[g(n),e(t)]}else{const e=p(g);v=(t,n)=>[e(t),m(n)]}else v=(e,t)=>[g(e),m(t)];const x=e.method||"linear";let b;if("loess"===x)b=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const r=e.slice().sort((e,t)=>e[0]-t[0]),o=r.map(e=>e[0]),i=r.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=o[e],r=o.map(e=>Math.abs(e-t)),c=r.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,l=[];for(let e=0;n>e;e++){const t=0===c?0:r[e]/c;l[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,h=0,d=0,f=0,y=0;for(let e=0;n>e;e++){const t=l[e];0!==t&&(u+=t,h+=t*o[e],d+=t*i[e],f+=t*o[e]*o[e],y+=t*o[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const p=u*f-h*h;if(1e-12>Math.abs(p))a.push([t,d/u]);else{const e=(u*y-h*d)/p;a.push([t,(d-e*h)/u+e*t])}}return a}(u,e.bandwidth??.3);else{const t="polynomial"===x?Do(u,e.order||2):function(e){const t=[0,0,0,0];let n=0;for(const[r,o]of e)null!==o&&(n++,t[0]+=r,t[1]+=o,t[2]+=r*r,t[3]+=r*o);const r=n*t[2]-t[0]*t[0],o=0===r?0:No((n*t[3]-t[0]*t[1])/r),i=No(t[1]/n-o*t[0]/n);return{points:e.map(([e])=>[No(e),No(o*e+i)]),equation:[o,i]}}(u);b=t.points}const k=b.map(([e,t])=>{const[n,r]=v(e,t);return`${n},${r}`}).join(" "),w=e.color||"#6366f1",A=b[b.length-1],[S,_]=v(A[0],A[1]);return ri("g",{children:[ni("polyline",{points:k,fill:"none",stroke:w,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&ni("text",{x:S+4,y:_-4,fill:w,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const t=r.scales?.y??r.scales?.value,s=t?.(e.y0)??0,a=t?.(e.y1)??(r.height||0),c=rr(e.fill,"ann-"+n,"var(--semiotic-primary, #6366f1)");return ri("g",{opacity:e.opacity,children:[c.def&&ni("defs",{children:c.def}),ni("rect",{x:0,y:Math.min(s,a),width:r.width||0,height:Math.abs(a-s),fill:c.fill,fillOpacity:e.fillOpacity||.1}),e.label&&ni(ti,{x:(r.width||0)-4,y:(o=s,i=a,Math.max(Math.min(o,i),0)+16),textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"x-band":{const t=r.scales?.x??r.scales?.time,o=null!=e.x0&&t?t(e.x0):null,i=null!=e.x1&&t?t(e.x1):null;if(null==o||null==i)return null;const s=rr(e.fill||e.color,"ann-"+n,"var(--semiotic-primary, #6366f1)");return ri("g",{opacity:e.opacity,children:[s.def&&ni("defs",{children:s.def}),ni("rect",{x:Math.min(o,i),y:0,width:Math.abs(i-o),height:r.height||0,fill:s.fill,fillOpacity:e.fillOpacity??.1}),e.label&&ni(ti,{x:Math.min(o,i)+4,y:16,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"envelope":{const t=r.data||[];if(2>t.length)return null;const o=r.xAccessor||"x",i=r.scales?.x??r.scales?.time,s=r.scales?.y??r.scales?.value;if(!i||!s)return null;const a=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",l=e.filter,u=t.filter(e=>null!=e[a]&&null!=e[c]&&!(l&&!l(e))).sort((e,t)=>e[o]-t[o]);if(2>u.length)return null;const h=oi[r.curve||"linear"]||wo,d=ko().x(e=>i(e[o])).y0(e=>s(e[c])).y1(e=>s(e[a])).curve(h)(u);if(!d)return null;const f=e.fill||"#6366f1";return ri("g",{children:[ni("path",{d:d,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&ni("text",{x:i(u[u.length-1][o])+4,y:s(u[u.length-1][a])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const t=r.data||[];if(2>t.length)return null;const o=r.yAccessor||"y",i=r.scales?.x??r.scales?.time,s=r.scales?.y??r.scales?.value;if(!i||!s)return null;const a=t.map(e=>e[o]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const c=a.reduce((e,t)=>e+t,0)/a.length,l=a.reduce((e,t)=>e+(t-c)**2,0)/a.length,u=Math.sqrt(l),h=e.threshold??2,d=c-h*u,f=!1!==e.showBand,y=e.fill||"#6366f1",p=e.fillOpacity??.1,g=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,v=s(c+h*u),x=s(d),b=t.filter(e=>{const t=e[o];return null!=t&&Math.abs(t-c)>h*u});return ri("g",{children:[f&&ni("rect",{x:0,y:Math.min(v,x),width:r.width||0,height:Math.abs(x-v),fill:y,fillOpacity:p}),b.map((e,t)=>{const n=Lo(e,r),o=Eo(e,r);return null==n||null==o?null:ni("circle",{cx:n,cy:o,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+t)}),e.label&&ni("text",{x:(r.width||0)-4,y:Math.min(v,x)-4,textAnchor:"end",fill:y,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const t=r.data||[];if(3>t.length)return null;const o=r.xAccessor||"x",i=r.yAccessor||"y",s=r.scales?.x??r.scales?.time,a=r.scales?.y??r.scales?.value;if(!s||!a)return null;const c=t.map(e=>[e[o],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let l;if("polynomial"===(e.method||"linear")){const t=Do(c,e.order||2).equation;l=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}else{const e=c.length;let t=0,n=0,r=0,o=0;for(const[e,i]of c)t+=e,n+=i,r+=e*e,o+=e*i;const i=e*r-t*t;if(1e-12>Math.abs(i))return null;const s=(e*o-t*n)/i,a=(n-s*t)/e;l=e=>a+s*e}const u=c.length,h=c.map(([e,t])=>t-l(e)),d=h.reduce((e,t)=>e+t*t,0),f=Math.sqrt(d/Math.max(u-2,1)),y=c.reduce((e,t)=>e+t[0],0)/u,p=c.reduce((e,t)=>e+(t[0]-y)**2,0),g=e.confidence??.95,m=.99>g?.95>g?.9>g?1:1.645:1.96:2.576,v=e.steps??5,x=c[u-1][0],b=(x-c[0][0])/Math.max(u-1,1),k=[];for(let e=1;v>=e;e++)k.push(x+e*b);const w=[];for(const e of k){const t=l(e),n=f*Math.sqrt(1+1/u+(p>0?(e-y)**2/p:0))*m;w.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const A=`M${w.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${w.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,S=w.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),_=`${s(x)},${a(l(x))}`,M=e.strokeColor||"#6366f1";return ri("g",{children:[ni("path",{d:A,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),ni("polyline",{points:`${_} ${S}`,fill:"none",stroke:M,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&w.length>0&&ni("text",{x:s(w[w.length-1].x)+4,y:a(w[w.length-1].yCenter)-4,fill:M,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let o,i;if(null!=e.px&&null!=e.py)o=e.px,i=e.py;else{const t=$o(e,n,r);if(!t)return null;o=t.x,i=t.y}if(!zo(o,i,r))return null;const s=e.dx??0,a=e.dy??0,c=e.width??32,l=e.height??32,u=e.content??ni("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return ni("foreignObject",{x:o+s-c/2,y:i+a-l/2,width:c,height:l,style:{overflow:"visible",pointerEvents:"auto"},children:ni("div",{...Ko(e,t),style:{width:c,height:l,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const t=$o(e,n,r);if(!t)return null;const{x:o,y:i}=t,s=o+(e.dx||0),a=i+(e.dy||0),c=e.color||"var(--semiotic-text, #333)",l=ni("text",{x:s,y:a,fill:c,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?lo.cloneElement(l,{key:"ann-text-"+n}):ri("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[ni("line",{x1:o,y1:i,x2:s,y2:a,stroke:c,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),lo.cloneElement(l,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+n)}case"category-highlight":{const t=e.category;if(null==t)return null;const o=e=>"function"==typeof e&&"function"==typeof e.bandwidth,i=r.scales?.o,s=r.scales?.x,a=r.scales?.y,c=o(i)?i:o(s)?s:o(a)?a:null;if(!c)return null;const l=c(t+"");if(null==l)return null;const u=c.bandwidth(),h=e.color||"var(--semiotic-primary, #4589ff)",d=e.opacity??.15,f=e.label;return ri("g",(r.projection?"vertical"===r.projection:c===s)?{children:[ni("rect",{x:l,y:0,width:u,height:r.height||0,fill:h,fillOpacity:d}),f&&ni(ti,{x:l+u/2,y:16,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]}:{children:[ni("rect",{x:0,y:l,width:r.width||0,height:u,fill:h,fillOpacity:d}),f&&ni(ti,{x:12,y:l+u/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]},"ann-"+n)}default:return null}var o,i,s}}var ai=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function ci(e){return!!e&&"object"==typeof e&&ai.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}function li(e){return"primary"===e?.emphasis||!0===e?.defensive}function ui(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function hi(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const r=e?.provenance?.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(t+=15*Math.max(0,Math.min(1,r))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}new Set(["label","callout","callout-circle","callout-rect"]);var di=32,fi=6,yi=4,pi=8,gi=72;var mi={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function vi(e){if(!xi(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function xi(e){return ci(e)}function bi(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),r=e.split(/\s+/).filter(Boolean),o=[];let i="";for(const e of r)i&&i.length+e.length+1>n?(o.push(i),i=e):i=i?`${i} ${e}`:e;return i&&o.push(i),o}function ki(e,t,n,r,o){const i=e+n,s=t+r;return Math.abs(n)>Math.abs(r)?{x:0>n?i-o.width-4:i+4,y:0>r?s-o.height:s,width:o.width,height:o.height}:{x:0>n?i-o.width:i,y:0>r?s-o.height-4:s+4,width:o.width,height:o.height}}function wi(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Ai(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function Si(e,t,n,r,o,i,s,a){const c=wi(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,r){const o=Math.max(0,r-e.x),i=Math.max(0,r-e.y);return(o+Math.max(0,e.x+e.width-(t-r)))*e.height+(i+Math.max(0,e.y+e.height-(n-r)))*e.width}(c,o,i,a);for(const e of n)l+=12*Ai(c,e);for(const e of r)l+=4*Ai(c,e);return l}function _i(e){const{annotations:t,context:n,defaultOffset:r=di,notePadding:o=fi,markPadding:i=yi,edgePadding:s=pi,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=gi,density:u,progressiveDisclosure:h=!1,redundantCues:d=!1,responsive:f,mobile:y,cohesion:p,audience:g}=e,m=n.width||0,v=n.height||0,x="object"==typeof y?y:{},b=x.breakpoint??480,k=!!y&&b>=m,w=k&&!1!==x.preferShortText?t.map(vi):t,A=k&&!u?{maxAnnotations:x.maxAnnotations??("callout-list"===x.strategy?1:2),minVisible:x.minVisible??1}:u,S=h||k&&(!1!==x.progressiveDisclosure||"callout-list"===x.strategy),_=k&&!f?x.responsive??{minWidth:b}:f,M=k&&!p?x.cohesion:p;if(0===w.length||0>=m||0>=v)return w.slice();const C=[],P=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(n,i);let T=!1;const R=w.map((e,t)=>{if(!xi(e))return e;const i=function(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const r=e.pointId??e.nodeId;if(null!=r&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===r);if(e)return{x:e.x,y:e.y}}const o=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(o)&&o.length>=2&&i){const e=o[0],t=o[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?$o(e,t,n):{x:e.x,y:e.y}}(e,t,n);if(!i)return e;const u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,n=[...bi("string"==typeof e.title?e.title:void 0,t),...bi("string"==typeof e.label?e.label:void 0,t)],r=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*r)+10),height:Math.max(18,16*n.length+6)}}(e);if(a&&("number"==typeof(h=e).dx||"number"==typeof h.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}(e);return C.push(wi(ki(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),o)),e}var h;let d=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(r)){const t=Si(ki(i.x,i.y,e.dx,e.dy,u),e,C,P,m,v,o,s);f>t&&(d=e,f=t)}if(!d)return e;const y=wi(ki(i.x,i.y,d.dx,d.dy,u),o);C.push(y);const p=Math.hypot(d.dx,d.dy),g=c&&p>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return T=!0,{...e,dx:d.dx,dy:d.dy,...g?{connector:g}:{}}}),N=T?R:w.slice();let D=N;if(d){let e=!1;const t=N.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||8>Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});D=e?t:N}{let e=!1;const t=D.map(t=>{if(!0!==t?.defensive)return t;const n=function(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?mi[t.source]??t.source:null,r="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!r)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const o=[n,r].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${o})`)?e:{...e,label:i?`${i} (${o})`:`(${o})`}}(t);return n!==t&&(e=!0),n});D=e?t:D}const L=new Set;if(A){const e="object"==typeof A?A:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return 3;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?3:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(g),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??ui(m,v,e))*t))},{deferred:r}=function(e){const{annotations:t,width:n,height:r}=e,o=Math.max(0,e.minVisible??1),i=ui(n,r,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,ci(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||i>=a.length)return{visible:t.slice(),deferred:[],budget:i};const c=a.filter(e=>li(e.annotation)),l=a.filter(e=>!li(e.annotation)).sort((e,t)=>hi(t.annotation)-hi(e.annotation)||e.index-t.index),u=Math.min(l.length,Math.max(Math.max(0,i-c.length),Math.max(0,o-c.length))),h=new Set([...c.map(e=>e.index),...l.slice(0,u).map(e=>e.index)]),d=[],f=[];for(const{annotation:e,index:t,note:n}of s)!n||h.has(t)?d.push(e):f.push(e);return{visible:d,deferred:f,budget:i}}({annotations:D,width:m,height:v,...n});for(const e of r)L.add(e)}if(_&&("object"==typeof _&&"number"==typeof _.minWidth?_.minWidth:480)>=m)for(const e of D)xi(e)&&"secondary"===e.emphasis&&L.add(e);if(L.size>0)for(const e of D)!0===e?.defensive&&L.delete(e);let E;return E=0===L.size?D:S?D.map(e=>L.has(e)?{...e,_annotationDeferred:!0}:e):D.filter(e=>!L.has(e)),M?function(e,t){let n=!1;const r=e.map(e=>xi(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?r:e}(E,M):E}import{useSyncExternalStore as Mi}from"react";var Ci={positions:new Map},Pi=new Set;function Ti(){for(const e of Pi)e()}function Ri(e,t){const n=Ci.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const r=new Map(Ci.positions);r.delete(e),Ci={positions:r},Ti()}function Ni(e,t){const n=Ci.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const r=new Map(Ci.positions);r.delete(e),Ci={positions:r},Ti()}function Di(){return Ci}function Li(e){return Pi.add(e),()=>Pi.delete(e)}var Ei={positions:new Map};function Ii(){return()=>{}}function Wi(){return Ei}function $i(e,t,n){return"exact"===n?function(e,t){const n=e.domain(),r=n[0],o=n[n.length-1],i=r instanceof Date,s=r instanceof Date?r.getTime():r,a=o instanceof Date?o.getTime():o;if(2>t||s===a)return i?[new Date(s),new Date(a)]:[s,a];const c=(a-s)/(t-1),l=Array(t);for(let e=0;t>e;e++){const n=e===t-1?a:s+e*c;l[e]=i?new Date(n):n}return l}(e,t):e.ticks(t)}function zi(e,t,n){if("edges"===e){if(t)return"start";if(n)return"end"}return"middle"}function Oi(e,t,n){if("edges"===e){if(t)return"hanging";if(n)return"auto"}return"middle"}function Fi(e){if(0===e.length)return{min:null,max:null};let t=1/0,n=-1/0;for(const r of e)t>r.pixel&&(t=r.pixel),r.pixel>n&&(n=r.pixel);return{min:t,max:n}}function Bi(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Yi(e,t,n){if("left"===e||"right"===e){const r="left"===e?n:0,o="left"===e?-1:1,i=Math.ceil(t/8);let s="M0,"+r;for(let e=0;i>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${r+4*o}`,s+=`L${Math.min(n,t)},${r}`}return s}const r="bottom"===e?0:t,o="bottom"===e?1:-1,i=Math.ceil(n/8);let s=`M${r},0`;for(let e=0;i>e;e++){const t=8*(e+1);s+=`L${r+4*o},${Math.min(8*e+4,n)}`,s+=`L${r},${Math.min(t,n)}`}return s}import{Fragment as ji,jsx as Hi,jsxs as Xi}from"react/jsx-runtime";function Gi(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,scales:s,showAxes:a,axes:c,showGrid:l,xFormat:u,yFormat:h,axisExtent:d}=e,f=Fr(()=>{if(!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||u||Vi,r=Math.max(2,Math.floor(t/70)),o=e?.ticks??5,i="exact"===d?Math.max(2,o):Math.min(o,r),a=e?.tickValues??$i(s.x,i,d),l=a.map(e=>e.valueOf()),h=a.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,l)})),f=h.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return qi(h,Math.max(55,f+8))},[s,c,u,t,d]),y=Fr(()=>{if(!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||h||Vi,r=Math.max(2,Math.floor(n/30)),o=e?.ticks??5,i="exact"===d?Math.max(2,o):Math.min(o,r);return qi((e?.tickValues??$i(s.y,i,d)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[s,c,h,n,d]),p=l&&s,g=a&&s;if(!p&&!g)return null;const m=c?.find(e=>"bottom"===e.orient),v=c?.find(e=>"left"===e.orient),x=g&&(!m||!1!==m.baseline),b=g&&(!v||!1!==v.baseline),k=m?.jaggedBase||!1,w=v?.jaggedBase||!1,A="var(--semiotic-border, #ccc)";return Hi("svg",{width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:Xi("g",{transform:`translate(${i.left},${i.top})`,children:[p&&(()=>{const e=Bi(c?.find(e=>"bottom"===e.orient)?.gridStyle),r=Bi(c?.find(e=>"left"===e.orient)?.gridStyle);return Xi("g",{className:"stream-grid",children:[f.map((t,r)=>Hi("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+r)),y.map((e,n)=>Hi("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),x&&!k&&Hi("line",{x1:0,y1:n,x2:t,y2:n,stroke:A,strokeWidth:1}),k&&Hi("path",{d:Yi("bottom",t,n),fill:"none",stroke:A,strokeWidth:1}),b&&!w&&Hi("line",{x1:0,y1:0,x2:0,y2:n,stroke:A,strokeWidth:1}),w&&Hi("path",{d:Yi("left",t,n),fill:"none",stroke:A,strokeWidth:1})]})})}function Vi(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function qi(e,t){if(2>=e.length)return e;const n=[e[0]];for(let r=1;e.length-1>r;r++)t>Math.abs(e[r].pixel-n[n.length-1].pixel)||n.push(e[r]);const r=e[e.length-1];return t>Math.abs(r.pixel-n[n.length-1].pixel)?n[n.length-1]=r:n.push(r),n}function Ui(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,scales:s,showAxes:a,axes:c,xLabel:l,yLabel:u,yLabelRight:h,xFormat:d,yFormat:f,axisExtent:y,showGrid:p,title:g,legend:m,legendHoverBehavior:v,legendClickBehavior:x,legendHighlightedCategory:b,legendIsolatedCategories:k,legendPosition:w="right",legendLayout:A,foregroundGraphics:S,marginalGraphics:_,xValues:M,yValues:C,annotations:P,onAnnotationActivate:T,onObservation:R,chartId:N,chartType:D,autoPlaceAnnotations:L,svgAnnotationRules:E,xAccessor:I,yAccessor:W,annotationData:$,pointNodes:z,curve:O,underlayRendered:F,canvasObscuresUnderlay:B=!0,linkedCrosshairName:Y,linkedCrosshairSourceId:j,children:H}=e,X=Uo({onAnnotationActivate:T,onObservation:R,chartId:N,chartType:D}),G=Fr(()=>{if(!a||!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||d||Vi,r=Math.max(2,Math.floor(t/70)),o=e?.ticks??5,i="exact"===y?Math.max(2,o):Math.min(o,r),l=e?.tickValues??$i(s.x,i,y),u=l.map(e=>e.valueOf()),h=l.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,u)})),f=h.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),p=e?.autoRotate?Math.max(20,Math.min(f+8,55)):Math.max(55,f+8);let g=qi(h,p);if(g.length>1&&(g=g.filter((e,t)=>0===t||e.label+""!=g[t-1].label+"")),e?.includeMax&&g.length>0&&"exact"!==y&&!e?.tickValues){const e=s.x.domain()[1],t=s.x(e),r=g[g.length-1].pixel;if(Math.abs(t-r)>1){const o=n(e,g.length,u);p>t-r&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:o})}}return g},[a,s,c,d,t,y]),V=Fr(()=>{if(!a||!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||f||Vi,r=Math.max(2,Math.floor(n/30)),o=e?.ticks??5,i="exact"===y?Math.max(2,o):Math.min(o,r);let l=qi((e?.tickValues??$i(s.y,i,y)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22);if(l.length>1&&(l=l.filter((e,t)=>0===t||e.label+""!=l[t-1].label+"")),e?.includeMax&&l.length>0&&"exact"!==y&&!e?.tickValues){const e=s.y.domain()[1],n=s.y(e),r=l[l.length-1].pixel;if(Math.abs(n-r)>1){const o=t(e);22>Math.abs(n-r)&&l.length>1&&(l=l.slice(0,-1)),l.push({value:e,pixel:n,label:o})}}return l},[a,s,c,f,n,y]),q=Fr(()=>{if(!a||!s)return[];const e=c?.find(e=>"right"===e.orient);if(!e)return[];const t=e.tickFormat||f||Vi,r=Math.max(2,Math.floor(n/30)),o=e.ticks??5;return qi((e.tickValues??$i(s.y,"exact"===y?Math.max(2,o):Math.min(o,r),y)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[a,s,c,f,n,y]),U=Br(new Map),K=Br(P?.length??0),Q=P?.length??0;K.current!==Q&&(K.current=Q,U.current=new Map);const Z=Fr(()=>{if(!P||0===P.length)return null;const e=si(0,X),r={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:I,yAccessor:W,width:t,height:n,data:$,frameType:"xy",pointNodes:z,curve:O,stickyPositionCache:U.current};return ii(L?_i({annotations:P,context:r,..."object"==typeof L?L:{}}):P,e,E,r)},[P,L,E,t,n,I,W,$,s,z,O,X]),J=function(e){const t=Mi(e?Li:Ii,e?Di:Wi,e?Di:Wi);return e?t.positions.get(e)??null:null}(Y);return Yr(()=>{if(!J?.locked||!Y)return;const e=e=>{"Escape"===e.key&&Ni(Y)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[J?.locked,Y]),a||g||m||S||_||Z&&Z.length>0||p||H||J?Xi("svg",{role:"img",width:r,height:o,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[Hi("title",{children:"string"==typeof g?g:"XY Chart"}),Hi("desc",{children:"string"==typeof g?g+" — XY data visualization":"XY data visualization"}),Xi("g",{transform:`translate(${i.left},${i.top})`,children:[p&&s&&(!F||B)&&(()=>{const e=Bi(c?.find(e=>"bottom"===e.orient)?.gridStyle),r=Bi(c?.find(e=>"left"===e.orient)?.gridStyle);return Xi("g",{className:"stream-grid",children:[G.map((t,r)=>Hi("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+r)),V.map((e,n)=>Hi("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),a&&s&&(()=>{const e=c?.find(e=>"left"===e.orient),r=c?.find(e=>"bottom"===e.orient),o=!e||!1!==e.baseline,s=!r||!1!==r.baseline,a=e?.jaggedBase||!1,d=r?.jaggedBase||!1,f=r?.landmarkTicks,y=e?.landmarkTicks,p="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, var(--semiotic-text, #666))",m="var(--semiotic-text, #333)",v=!!r?.autoRotate&&G.length>1&&(()=>{const e=t/Math.max(G.length-1,1);return G.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})(),x=v?12:18,b=n+(v?58:40),k={fontSize:"var(--semiotic-tick-font-size, 12px)"},w={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},A={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},S=r?.tickAnchor,_=e?.tickAnchor,M=Fi(G),C=Fi(V);return Xi("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[Xi("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!F||B)&&s&&!d&&Hi("line",{x1:0,y1:n,x2:t,y2:n,stroke:p,strokeWidth:1}),(!F||B)&&d&&Hi("path",{d:Yi("bottom",t,n),fill:"none",stroke:p,strokeWidth:1}),G.map((e,t)=>{const r=!!f&&("function"==typeof f?f(e.value,t):Nn(e.value,t>0?G[t-1].value:void 0));return Xi("g",{transform:`translate(${e.pixel},${n})`,children:[Hi("line",{y2:5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?Hi("text",{y:x,textAnchor:v?"end":zi(S,e.pixel===M.min,e.pixel===M.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?w:k},transform:v?"rotate(-45)":void 0,children:e.label}):Hi("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:Hi("div",{style:{textAlign:"center",userSelect:"none",...k},children:e.label})})]},"xtick-"+t)}),l&&Hi("text",{x:t/2,y:b,textAnchor:"middle",fill:m,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:l})]}),Xi("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!F||B)&&o&&!a&&Hi("line",{x1:0,y1:0,x2:0,y2:n,stroke:p,strokeWidth:1}),(!F||B)&&a&&Hi("path",{d:Yi("left",t,n),fill:"none",stroke:p,strokeWidth:1}),V.map((e,t)=>{const n=!!y&&("function"==typeof y?y(e.value,t):Nn(e.value,t>0?V[t-1].value:void 0));return Xi("g",{transform:`translate(0,${e.pixel})`,children:[Hi("line",{x2:-5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?Hi("text",{x:-8,textAnchor:"end",dominantBaseline:Oi(_,e.pixel===C.min,e.pixel===C.max),fontWeight:n?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...n?w:k},children:e.label}):Hi("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:Hi("div",{style:{textAlign:"right",userSelect:"none",...k},children:e.label})})]},"ytick-"+t)}),(()=>{const t=e?.label||u;return t?Hi("text",{x:15-i.left,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(-90, ${15-i.left}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:t}):null})()]}),(()=>{const e=c?.find(e=>"right"===e.orient);if(!e||0===q.length)return null;const r=!1!==e.baseline,o=e.landmarkTicks,s=e.label||h,a=e.tickAnchor,l=Fi(q);return Xi("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[r&&Hi("line",{x1:t,y1:0,x2:t,y2:n,stroke:p,strokeWidth:1}),q.map((e,n)=>{const r=!!o&&("function"==typeof o?o(e.value,n):Nn(e.value,n>0?q[n-1].value:void 0));return Xi("g",{transform:`translate(${t},${e.pixel})`,children:[Hi("line",{x2:5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?Hi("text",{x:8,textAnchor:"start",dominantBaseline:Oi(a,e.pixel===l.min,e.pixel===l.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?w:k},children:e.label}):Hi("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:Hi("div",{style:{textAlign:"left",userSelect:"none",...k},children:e.label})})]},"ytick-r-"+n)}),s&&Hi("text",{x:t+i.right-15,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(90, ${t+i.right-15}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:s})]})})()]})})(),Z,_&&s&&M&&C&&Xi(ji,{children:[_.top&&Hi("g",{transform:"translate(0, 0)",children:Hi(co,{orient:"top",config:ao(_.top),values:M,scale:s.x,size:i.top,length:t})}),_.bottom&&Hi("g",{transform:`translate(0, ${n})`,children:Hi(co,{orient:"bottom",config:ao(_.bottom),values:M,scale:s.x,size:i.bottom,length:t})}),_.left&&Hi("g",{transform:"translate(0, 0)",children:Hi(co,{orient:"left",config:ao(_.left),values:C,scale:s.y,size:i.left,length:n})}),_.right&&Hi("g",{transform:`translate(${t}, 0)`,children:Hi(co,{orient:"right",config:ao(_.right),values:C,scale:s.y,size:i.right,length:n})})]}),S,J&&J.sourceId!==j&&s?.x&&(()=>{const e=s.x(J.xValue);if(null==e||0>e||e>t)return null;const r=J.locked;return Hi("line",{x1:e,y1:0,x2:e,y2:n,stroke:r?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:r?1.5:1,strokeDasharray:r?"6,3":"4,4",pointerEvents:"none"})})(),H]}),g&&"string"==typeof g?Hi("text",{x:r/2,y:22,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:g}):g?Hi("foreignObject",{x:0,y:0,width:r,height:i.top,children:g}):null,to({legend:m,totalWidth:r,totalHeight:o,margin:i,legendPosition:w,title:g,legendLayout:A,legendHoverBehavior:v,legendClickBehavior:x,legendHighlightedCategory:b,legendIsolatedCategories:k})]}):null}import*as Ki from"react";import{arc as Qi}from"d3-shape";function Zi(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}import{jsx as Ji,jsxs as es}from"react/jsx-runtime";var ts={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function ns(e,t="#4e79a7"){return Jn(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function rs(e,t,n,r){const o=e.glyph;if(!o?.parts?.length||0>=e.size)return null;const i=In(o,e.size);if(0>=i.scale)return null;const s=`translate(${t},${n})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${i.offsetX},${i.offsetY}) scale(${i.scale})`,a=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),c=On(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),l=c?function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}(r+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),h=t=>o.parts.map((n,r)=>{const o=t?"none"===n.fill?void 0:t:Wn(n.fill,a,e.accent),i=t?n.stroke&&"none"!==n.stroke?t:void 0:Wn(n.stroke??"none",a,e.accent);return o||i?Ji("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 es("g",{transform:s,opacity:1===u?void 0:u,children:[c&&l&&Ji("clipPath",{id:l,children:Ji("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&e.ghostColor?Ji("g",{children:h(e.ghostColor)}):null,c&&l?Ji("g",{clipPath:`url(#${l})`,children:h()}):h()]},r)}var os="undefined"==typeof window||"undefined"==typeof document;import{useEffect as is,useLayoutEffect as ss,useRef as as,useState as cs,useSyncExternalStore as ls}from"react";var us="undefined"!=typeof window?ss:is;function hs(){const[e,t]=cs(!1);return us(()=>{t(!0)},[]),e}var ds=()=>()=>{},fs=()=>!1,ys=()=>!0;function ps(){const e=ls(ds,fs,ys);return as(e).current}import{useRef as gs}from"react";function ms(e){const t=gs(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return xs(e,t);if(!bs(e)||!bs(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;const n=e[r],o=t[r];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!xs(n,o))return!1}else{if(!bs(n)||!bs(o))return!1;if(!vs(n,o))return!1}}return!0}(t.current,e)||(t.current=e),t.current}function vs(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!Object.is(e[r],t[r]))return!1}return!0}function xs(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function bs(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function ks(e,t){const{background:n,hasBackgroundGraphics:r=!1,themeBackground:o="",x:i=0,y:s=0,width:a,height:c}=t;if("transparent"===n)return!1;if(r)return!1;const l=n||(o&&"transparent"!==o?o:"")||null;if(!l)return!1;const u=Un(e,l);return!!u&&(e.fillStyle=u,e.fillRect(i,s,a,c),!0)}var ws={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white",primary:"#007bff",background:""};function As(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],r=n[2],o=n[3];return`#${e}${e}${r}${r}${o}${o}${t}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${t}`;const r=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return r?`rgba(${r[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:n}import*as Ss from"react";import*as _s from"react";import{jsx as Ms}from"react/jsx-runtime";var Cs=_s.createContext(null);function Ps(){return _s.useContext(Cs)}import{jsx as Ts}from"react/jsx-runtime";var Rs={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Ns({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 Ts("div",{"aria-live":"polite","aria-atomic":"true",style:Rs,children:t})}function Ds(e){const t={};if(null==e||"object"!=typeof e)return t;for(const[n,r]of Object.entries(e))n.startsWith("_")||null!=r&&""!==r&&("number"==typeof r?Number.isFinite(r)&&(t[n]=r):"string"==typeof r?t[n]=r:"boolean"==typeof r?t[n]=r+"":r instanceof Date&&(t[n]=r.toISOString().slice(0,10)));return t}function Ls(e){return e&&"object"==typeof e?e:{}}function Es(e){return Ls(e.accessibility).tableFields??e.accessibleDatum??e.datum}import{jsx as Is,jsxs as Ws}from"react/jsx-runtime";function $s(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e){if(null===t?.datum)continue;const e=t.type+"";n[e]=(n[e]||0)+1}if(0===Object.keys(n).length)return t+", empty";const r=[],o={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((e,t)=>{const n=i.indexOf(e),r=i.indexOf(t);return(-1===n?999:n)-(-1===r?999:r)});for(const e of s)r.push(`${n[e]} ${o[e]||e}`);return`${t}, ${r.join(", ")}`}function zs(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 Os=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Fs="semiotic-accessible-data-table",Bs=Fs+" semiotic-accessible-data-table-hidden",Ys=Fs+" semiotic-accessible-data-table-visible",js=Ys+" semiotic-accessible-data-table-network",Hs={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"},Xs={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Gs={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)"},Vs={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},qs={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))"},Us={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Ks={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Qs={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 Zs({scene:e,chartType:t,tableId:n,chartTitle:r}){const[o,i]=Ss.useState(!1),[s,a]=Ss.useState(5),c=Ps(),l=c?.visible??!1,u=o||l,h=Ss.useRef(null),d=r?"Data summary for "+r:n?`Data summary for ${t} ${n}`:"Data summary for "+t;Ss.useEffect(()=>{u||a(5)},[u]);const f=Ss.useCallback(e=>{e.target===e.currentTarget&&(o||l||i(!0))},[o,l]),y=Ss.useCallback(e=>{l||h.current?.contains(e.relatedTarget)||i(!1)},[l]);if(!e||0===e.length)return n?Is("span",{id:n,tabIndex:-1,style:Rs}):null;if(!u)return Is("div",{id:n,className:Bs,tabIndex:-1,onFocus:f,style:Rs,role:"region","aria-label":d,children:Ws("button",{type:"button",onClick:()=>i(!0),children:["View data summary (",e.length," elements)"]})});const p=function(e){const t=[];if(!Array.isArray(e))return t;const n=e.some(e=>e&&("line"===e.type||"area"===e.type));for(const r of e)if(r&&"object"==typeof r&&null!==r.datum)try{switch(r.type){case"point":if(n)break;t.push({label:"Point",values:Ds(Es(r))});break;case"line":case"area":{const e=Es(r),n=Array.isArray(e)?e:[],o="line"===r.type?"Line point":"Area point";for(const e of n)t.push({label:o,values:Ds(e)});break}case"rect":{const e=Es(r),n=null!=e&&"object"==typeof e?e:{},o=n.category??r.group??"",i=n.value??n.__aggregateValue??n.total,s=Ds(n);null==s.category&&""!==o&&(s.category=o+""),null==s.value&&null!=i&&(s.value="number"==typeof i||"string"==typeof i?i:i+""),t.push({label:"Bar",values:s});break}case"heatcell":{const e=Ds(Es(r));null==e.value&&"number"==typeof r.value&&Number.isFinite(r.value)&&(e.value=r.value),t.push({label:"Cell",values:e});break}case"wedge":{const e=Es(r),n=Ds(e);if(null==n.category){const t=Ls(e),r=t.category??t.label;null!=r&&(n.category=r+"")}t.push({label:"Wedge",values:n});break}case"circle":t.push({label:"Node",values:Ds(Es(r))});break;case"arc":t.push({label:"Arc",values:Ds(Es(r))});break;case"candlestick":t.push({label:"Candlestick",values:Ds(Es(r))});break;case"geoarea":{const e=Ls(Es(r)),n=Ds(e);if(null==n.name){const t=Ls(e.properties).name??e.name;null!=t&&(n.name=t+"")}t.push({label:"Region",values:n});break}}}catch{}return t}(e),g=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const r of t){const t=[],o=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[r];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&o.add(e+""))}if(t.length>0){let e=t[0],o=t[0],i=0;for(const n of t)e>n&&(e=n),n>o&&(o=n),i+=n;n.push({name:r,count:t.length,numeric:!0,min:e,max:o,mean:i/t.length})}else if(o.size>0){const e=Array.from(o);n.push({name:r,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(p),m=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${Os(e.min)} to ${Os(e.max)}, mean ${Os(e.mean)}.`);else{const t=e.uniqueValues,r=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${r}.`)}return n.join(" ")}(p.length,g),v=Math.min(s,p.length),x=p.slice(0,v),b=p.length-v,k=new Set;for(const e of x)for(const t of Object.keys(e.values))k.add(t);const w=Array.from(k);return Ws("div",{ref:h,id:n,className:Ys,tabIndex:-1,onBlur:y,style:Hs,role:"region","aria-label":d,children:[Is("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{l&&c&&c.setVisible(!1),i(!1)},"aria-label":"Close data summary",style:Gs,children:"×"}),Is("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Xs,children:m}),Ws("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+t,style:Vs,children:[Is("caption",{className:"semiotic-accessible-data-table-caption",style:Ks,children:b>0?`First ${v} of ${p.length} data points`:`All ${p.length} data points`}),Is("thead",{children:Ws("tr",{children:[Is("th",{style:qs,children:"type"}),w.map(e=>Is("th",{style:qs,children:e},e))]})}),Is("tbody",{children:x.map((e,t)=>Ws("tr",{children:[Is("td",{style:Us,children:e.label}),w.map(t=>{return Is("td",{style:Us,children:(n=e.values[t],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":Os(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},t);var n})]},t))})]}),b>0&&Ws("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(e=>e+25),style:Qs,children:["Show ",Math.min(25,b)," more"," ",1===b?"row":"rows"," (",b," remaining)"]})]})}function Js({nodes:e,edges:t,chartType:n,tableId:r,chartTitle:o}){const[i,s]=Ss.useState(!1),[a,c]=Ss.useState(5),l=Ps(),u=l?.visible??!1,h=i||u,d=o?"Data summary for "+o:r?`Data summary for ${n} ${r}`:"Data summary for "+n,f=Ss.useRef(null);Ss.useEffect(()=>{h||c(5)},[h]);const y=Ss.useCallback(e=>{e.target===e.currentTarget&&(i||u||s(!0))},[i,u]),p=Ss.useCallback(e=>{u||f.current?.contains(e.relatedTarget)||s(!1)},[u]);if(!e||0===e.length)return r?Is("span",{id:r,tabIndex:-1,style:Rs}):null;if(!h)return Is("div",{id:r,className:Bs,tabIndex:-1,onFocus:y,style:Rs,role:"region","aria-label":d,children:Ws("button",{type:"button",onClick:()=>s(!0),children:["View data summary (",e.length," nodes, ",t.length," edges)"]})});const g=Array.isArray(e)?e:[],m=Array.isArray(t)?t:[],v=new Map,x=new Map,b=new Map,k=new Map;for(const e of m){if(!e||"object"!=typeof e)continue;const t=e.datum??{source:e.source,target:e.target},n="object"==typeof t.source?t.source?.id:t.source,r="object"==typeof t.target?t.target?.id:t.target,o="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=n&&""!==n){const e=n+"";x.set(e,(x.get(e)??0)+1),k.set(e,(k.get(e)??0)+o)}if(null!=r&&""!==r){const e=r+"";v.set(e,(v.get(e)??0)+1),b.set(e,(b.get(e)??0)+o)}}const w=[];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,o=v.get(r)??0,i=x.get(r)??0,s=b.get(r)??0,a=k.get(r)??0;w.push({id:r,degree:o+i,inDeg:o,outDeg:i,wDegree:s+a,wInDeg:s,wOutDeg:a})}w.sort((e,t)=>t.degree-e.degree);let A=0,S=0;if(w.length>0){let e=0;for(const t of w)e+=t.degree,t.degree>S&&(S=t.degree);A=e/w.length}const _=m.some(e=>{const t=e?.datum??{source:e?.source,target:e?.target};return"number"==typeof t?.value&&Number.isFinite(t.value)}),M=[`${w.length} nodes, ${m.length} edges.`];w.length>0&&M.push(`Mean degree: ${Os(A)}, max degree: ${S}.`);const C=Math.min(a,w.length),P=w.slice(0,C),T=w.length-C;return Ws("div",{ref:f,id:r,className:js,tabIndex:-1,onBlur:p,style:Hs,role:"region","aria-label":d,children:[Is("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{u&&l&&l.setVisible(!1),s(!1)},"aria-label":"Close data summary",style:Gs,children:"×"}),Is("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Xs,children:M.join(" ")}),Ws("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+n,style:Vs,children:[Is("caption",{className:"semiotic-accessible-data-table-caption",style:Ks,children:T>0?`Top ${C} of ${w.length} nodes by degree`:`All ${w.length} nodes by degree`}),Is("thead",{children:Ws("tr",{children:[Is("th",{style:qs,children:"id"}),Is("th",{style:qs,children:"degree"}),Is("th",{style:qs,children:"in"}),Is("th",{style:qs,children:"out"}),_&&Is("th",{style:qs,children:"w. degree"}),_&&Is("th",{style:qs,children:"w. in"}),_&&Is("th",{style:qs,children:"w. out"})]})}),Is("tbody",{children:P.map((e,t)=>Ws("tr",{children:[Is("td",{style:Us,children:e.id}),Is("td",{style:Us,children:e.degree}),Is("td",{style:Us,children:e.inDeg}),Is("td",{style:Us,children:e.outDeg}),_&&Is("td",{style:Us,children:Os(e.wDegree)}),_&&Is("td",{style:Us,children:Os(e.wInDeg)}),_&&Is("td",{style:Us,children:Os(e.wOutDeg)})]},t))})]}),T>0&&Ws("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>c(e=>e+25),style:Qs,children:["Show ",Math.min(25,T)," more"," ",1===T?"node":"nodes"," (",T," remaining)"]})]})}function ea({summary:e}){return e?Is("div",{role:"note",style:Rs,children:e}):null}function ta({tableId:e}){return Is("a",{href:"#"+e,style:Rs,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,Rs)},children:"Skip to data table"})}import{jsx as na}from"react/jsx-runtime";var ra="var(--semiotic-focus, #005fcc)";function oa({active:e,hoverPoint:t,margin:n,size:r,shape:o="circle",width:i,height:s,pathData:a}){if(!e||!t)return null;const c=t.x+n.left,l=t.y+n.top;let u;if("geoarea"!==o&&"path"!==o||!a)if("rect"===o&&null!=i&&null!=s){const e=Math.max(i,4),t=Math.max(s,4);u=na("rect",{x:c-e/2-3,y:l-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:ra,strokeWidth:2,strokeDasharray:"4,2"})}else u=na("circle","wedge"===o?{cx:c,cy:l,r:12,fill:"none",stroke:ra,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:c,cy:l,r:8,fill:"none",stroke:ra,strokeWidth:2,strokeDasharray:"4,2"});else u=na("g",{transform:`translate(${n.left},${n.top})`,children:na("path",{d:a,fill:"none",stroke:ra,strokeWidth:2.5,strokeDasharray:"6,3"})});return na("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}import*as ia from"react";function sa(e,t){return"touch"===t?Math.max(e,24):e}function aa(e){return Array.isArray(e)?e[0]:e}function ca(e,t,n,r){return{data:aa(e),x:t,y:n,__semioticHoverData:!0,...r}}var la=["name","label","title"],ua=["type","kind","category","group","class","status","role","shape"],ha=["value","amount","total","count","weight","score"],da=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function fa(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}function ya(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,r=!1!==t.skipPositional,o=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(r&&da.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&o.push({key:t,lower:t.toLowerCase(),value:n})}if(0===o.length)return{entries:[]};let i=o.findIndex(e=>la.includes(e.lower));const s=i>=0;0>i&&(i=o.findIndex(e=>"id"===e.lower)),0>i&&(i=o.findIndex(e=>"string"==typeof e.value));const a=0>i?void 0:o[i];let c=o.filter((e,t)=>t!==i);s&&(c=c.filter(e=>"id"!==e.lower));const l=fa(c,ua),u=fa(c,ha),h=new Set(ua),d=new Set(ha),f=[];l&&f.push({key:l.key,value:l.value}),u&&f.push({key:u.key,value:u.value});for(const e of c){if(f.length>=n)break;e!==l&&e!==u&&(h.has(e.lower)||d.has(e.lower)||f.push({key:e.key,value:e.value}))}return{titleKey:a?.key,title:a?.value,entries:f}}import{jsx as pa,jsxs as ga}from"react/jsx-runtime";var ma={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};import{jsx as va}from"react/jsx-runtime";function xa({x:e,y:t,containerWidth:n,containerHeight:r,margin:o,children:i,className:s="stream-frame-tooltip",zIndex:a=1}){const c=Number.isFinite(e)&&Number.isFinite(t),l=ia.useRef(null),[u,h]=ia.useState(null);ia.useLayoutEffect(()=>{const e=l.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()},[s,n,r,c]);let d;d=u?`translate(${u.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>r-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*r>t?"4px":"calc(-100% - 4px)"})`;const f=function(e){if(!ia.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if(!0===n["data-semiotic-tooltip-chrome"])return!0;if("true"===n["data-semiotic-tooltip-chrome"])return!0;const r=n.style;if(r&&"object"==typeof r){if(null!=r.background&&""!==r.background&&"transparent"!==r.background)return!0;if(null!=r.backgroundColor&&""!==r.backgroundColor&&"transparent"!==r.backgroundColor)return!0}return!1}(i),y=f?null:ma;return c?va("div",{ref:l,className:f?s:(s+" semiotic-tooltip").trim(),style:{...y||{},position:"absolute",left:o.left+e,top:o.top+t,transform:d,pointerEvents:"none",zIndex:a,width:"max-content"},children:i}):null}import*as ba from"react";import{useCallback as ka,useEffect as wa,useLayoutEffect as Aa,useMemo as Sa,useRef as _a}from"react";import{useState as Ma,useEffect as Ca}from"react";import{useRef as Pa,useState as Ta,useEffect as Ra}from"react";var Na=()=>"undefined"!=typeof performance?performance.now():Date.now();function Da(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function La(e,t){const n=e();return Number.isFinite(n)?n:t}var Ea=class{constructor(e={}){this.randomSource=Math.random,this.subscribers=new Set,this.now=()=>this.advance(),this.random=()=>this.randomSource(),this.clock=e.clock??Na,this.lastWallTime=La(this.clock,0),this.logicalTime=this.lastWallTime,this.pausedValue=!0===e.paused,this.visibleValue=!1!==e.visible,this.setRandomSource(e.random,e.seed)}get isActive(){return!this.pausedValue&&this.visibleValue}get paused(){return this.pausedValue}get seed(){return this.seedValue}get visible(){return this.visibleValue}configure(e){this.setClock(e.clock),this.setRandomSource(e.random,e.seed)}setPaused(e){this.pausedValue!==e&&(this.advance(),this.pausedValue=e,this.emit())}setVisible(e){this.visibleValue!==e&&(this.advance(),this.visibleValue=e,this.emit())}snapshot(){return{now:this.now(),paused:this.pausedValue,seed:this.seedValue,visible:this.visibleValue}}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}advance(){const e=La(this.clock,this.lastWallTime),t=Math.max(0,e-this.lastWallTime);return this.lastWallTime=e,this.isActive&&(this.logicalTime+=t),this.logicalTime}emit(){for(const e of this.subscribers)e()}setClock(e){const t=e??Na;t!==this.clock&&(this.advance(),this.clock=t,this.lastWallTime=La(t,this.lastWallTime))}setRandomSource(e,t){const n=function(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):void 0}(t);e===this.randomInput&&n===this.seedValue||(this.randomInput=e,this.seedValue=n,this.randomSource=e??(void 0===n?Math.random:Da(n)))}},Ia="undefined"==typeof window?wa:Aa,Wa={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function $a(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function za(e){const t=function(){const[e,t]=Ma(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return Ca(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),function(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}(e,e=>t(e.matches))},[]),e}(),n=_a(t);n.current=t;const[r,o]=function(e,t,n){const r=Pa(null),[o,i]=Ta(null);return Ra(()=>{if(!t&&!n)return;const e=r.current;if(!e)return;const o=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;i(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return o.observe(e),()=>o.disconnect()},[t,n]),[r,[t&&o?o.w:e[0],n&&o?o.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),i=!!e.title,s=!!e.legend&&"top"===e.legendPosition,a=Sa(()=>function(e,t,n=!1){const r=n?t?58:34:t?36:0;return r>e.top?{...e,top:r}:e}({...e.marginDefault,...e.userMargin},i,s),[e.marginDefault,e.userMargin,i,s]),c=o[0]-a.left-a.right,l=o[1]-a.top-a.bottom,u=$a(e.foregroundGraphics,o,a),h=$a(e.backgroundGraphics,o,a),d=H(e=>e.theme),{transition:f,introEnabled:y}=function(e,t){if(!1===e)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:e?!0===e?{duration:300}:{duration:e.duration??300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(n||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),p="semiotic-table-"+ba.useId(),g=_a(null);if(!g.current){const t=!e.suspendWhenHidden||"undefined"==typeof document||!document.hidden;g.current=new Ea({clock:e.clock,random:e.random,seed:e.seed,paused:e.paused,visible:t})}const m=g.current;m.configure({clock:e.clock,random:e.random,seed:e.seed});const v=_a(null),x=_a(e.frameScheduler??Wa);x.current=e.frameScheduler??Wa;const b=_a(null),k=_a(!1),w=_a(()=>{}),A=ka(()=>{if(null!==v.current||k.current)return;const e=x.current;let t=!1,n=!1;const r=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&(k.current=!0),v.current=null,b.current=null;try{w.current()}finally{e&&(k.current=!1)}});n=!0,t||(v.current=r,b.current=e)},[]),S=ka(()=>{null!==v.current&&((b.current??x.current).cancelAnimationFrame(v.current),v.current=null,b.current=null)},[]);Ia(()=>{m.setPaused(!0===e.paused)},[m,e.paused]),wa(()=>{if(!e.suspendWhenHidden||"undefined"==typeof document)return void m.setVisible(!0);const t=()=>m.setVisible(!document.hidden);return t(),document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[m,e.suspendWhenHidden]),wa(()=>()=>{S()},[S]);const _=_a(()=>{}),M=_a(()=>{}),C=_a(null),P=_a(null),T=_a(null),R=ka(()=>{const e=C.current;C.current=null,e&&_.current(e)},[]),N=ka(e=>{if(C.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===P.current){const e=x.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,P.current=null,T.current=null,R()});t||(P.current=n,T.current=e)}},[R]),D=ka(()=>{C.current=null,null!==P.current&&((T.current??x.current).cancelAnimationFrame(P.current),P.current=null,T.current=null),M.current()},[]);wa(()=>()=>{C.current=null,null!==P.current&&((T.current??x.current).cancelAnimationFrame(P.current),P.current=null,T.current=null)},[]);const L=e.themeDirtyRef;return Ia(()=>{L&&(Xn++,L.current=!0,A())},[d,A,L]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:r,size:o,margin:a,adjustedWidth:c,adjustedHeight:l,resolvedForeground:u,resolvedBackground:h,currentTheme:d,transition:f,introEnabled:y,tableId:p,frameRuntime:m,rafRef:v,renderFnRef:w,scheduleRender:A,cancelRender:S,hoverHandlerRef:_,hoverLeaveRef:M,onPointerMove:N,onPointerLeave:D}}import{useEffect as Oa,useRef as Fa}from"react";import{jsx as Ba}from"react/jsx-runtime";function Ya(e,t){return function(e){const{cancelRender:t,dirtyRef:n,frameRuntime:r,manageFrameRuntime:o,scheduleRender:i}=e,s=Fa(null),a=Fa(null),c=Fa(!1);return function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:r,dirtyRef:o,renderFnRef:i,cancelRender:s,cleanup:a}=e;us(()=>{t&&n&&r.current?.cancelIntroAnimation?.(),o.current=!0,s?.(),i.current()},[t,n]);const c=as(a);c.current=a,is(()=>()=>c.current?.(),[])}({hydrated:e.hydrated,wasHydratingFromSSR:e.wasHydratingFromSSR,storeRef:e.storeRef,dirtyRef:e.dirtyRef,renderFnRef:e.renderFnRef,cancelRender:e.cancelRender,cleanup:e.cleanup}),Oa(()=>{if(!1!==o)return r.subscribe(()=>{r.isActive?(n.current=!0,i()):t()})},[t,n,r,o,i]),Oa(()=>{!c.current&&(c.current=!0,e.skipInitialCanvasPaintInvalidation)||(e.dirtyRef.current=!0,e.scheduleRender())},e.canvasPaintDependencies),{canvasRef:s,interactionCanvasRef:a}}({...t,renderFnRef:e.renderFnRef,scheduleRender:e.scheduleRender,cancelRender:e.cancelRender,frameRuntime:e.frameRuntime})}function ja({children:e,size:t,margin:n,overflowVisible:r=!1}){return e?Ba("svg",{style:{position:"absolute",left:0,top:0,width:t[0],height:t[1],pointerEvents:"none",overflow:r?"visible":void 0},children:Ba("g",{transform:`translate(${n.left},${n.top})`,children:e})}):null}function Ha(e,t,n,r){return"function"==typeof e?e({size:t,margin:n,scales:r}):e}function Xa(e,t,n,r){const o=e.getContext("2d");if(!o)return null;const i=Math.round(t[0]*r),s=Math.round(t[1]*r),a=i/t[0],c=s/t[1],l=t[0]+"px",u=t[1]+"px";return e.style.width!==l&&(e.style.width=l),e.style.height!==u&&(e.style.height=u),e.width===i&&e.height===s||(e.width=i,e.height=s),o.setTransform(a,0,0,c,0,0),o.translate(n.left,n.top),o}function Ga(){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{useCallback as Va,useRef as qa}from"react";function Ua(e,t,n,r){return"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:r,fn:t}:{key:void 0,fn:null}}var Ka=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Qa=3156e7;function Za(e){const t=e[1]-e[0];return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:Qa>t?e=>{const t=new Date(e);return`${Ka[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*Qa>t?e=>{const t=new Date(e);return`${Ka[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function Ja(e){if(!e)return;const t=[];for(const n of e)if("point"===n.type)t.push(n);else if("symbol"===n.type)t.push({pointId:n.pointId,x:n.x,y:n.y,r:ft(n.size)});else if("glyph"===n.type){const e=Fn(n.glyph,n.size);t.push({pointId:n.pointId,x:n.x+e.centerDx,y:n.y+e.centerDy,r:e.radius})}return t}import{line as ec}from"d3-shape";function tc(e,t,n){let r=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(r=n.color):e>n.value&&(r=n.color);return r}function nc(e,t,n,r,o,i){if(2>t.length)return;const s=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],r=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(n*n+r*r))}const a=s[s.length-1];if(0===a)return;const c=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=r,e.lineCap=i;for(let n=0;t.length-1>n;n++){const r=(s[n]+s[n+1])/2;let i=o;c>r&&(i*=r/c),c>a-r&&(i*=(a-r)/c),e.globalAlpha=Math.max(0,i),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}var rc=(e,t,n,r)=>{const o=t.filter(e=>"line"===e.type);for(const t of o){if(2>t.path.length)continue;const n=t._introClipFraction;void 0!==n&&1>n&&(e.save(),e.beginPath(),e.rect(0,0,r.width*n,r.height),e.clip());const o=t.style.stroke||"#007bff",i=Un(e,o)||o,s=t.style.strokeWidth||2,a=t.colorThresholds,c=t.rawValues;if(e.setLineDash(t.style.strokeDasharray?t.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),e.lineWidth=s,e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade){nc(e,t.path,i,s,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const l=fr(t.curve),u=a&&a.length>0&&c&&c.length===t.path.length,h=t._decayOpacities;if(h&&h.length===t.path.length&&!u){e.strokeStyle=i;const n=t.style.opacity??1;for(let r=0;t.path.length-1>r;r++)e.globalAlpha=.5*(h[r]+h[r+1])*n,e.beginPath(),e.moveTo(t.path[r][0],t.path[r][1]),e.lineTo(t.path[r+1][0],t.path[r+1][1]),e.stroke()}else if(u){let n=function(t,n,r){e.beginPath(),e.strokeStyle=t,e.moveTo(n,r),h=!0},r=function(){h&&(e.stroke(),h=!1)},o=null,s=null,l=null,u=null,h=!1;for(let h=0;t.path.length>h;h++){const[d,f]=t.path[h],y=c[h],p=tc(y,a,i);if(null!==o&&null!==u&&null!==l){if(p===u)e.lineTo(d,f);else{const t=[];for(const e of a){const n=e.value;(l>n||n>y)&&(n>l||y>n)||l===n||y===n||t.push({t:(n-l)/(y-l)})}t.sort((e,t)=>e.t-t.t);for(const c of t){const t=o+(d-o)*c.t,u=s+(f-s)*c.t,h=tc(l+(y-l)*Math.min(c.t+1e-4,1),a,i);e.lineTo(t,u),r(),n(h,t,u)}e.lineTo(d,f)}o=d,s=f,l=y,u=p}else n(p,d,f),o=d,s=f,l=y,u=p}r()}else{e.beginPath();const n=t.strokeGradient&&t.path.length>=2?gr(e,t.strokeGradient,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=n||i,l)ec().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,r]=t.path[0];e.moveTo(n,r);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}e.stroke()}if(t.style.fill&&t.style.fillOpacity&&t.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=t.style.fillOpacity,e.fillStyle=yr(e,t.style.fill,t.style.fill),l&&!u)ec().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,r]=t.path[0];e.moveTo(n,r);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}const n=t.path[0][0];e.lineTo(t.path[t.path.length-1][0],r.height),e.lineTo(n,r.height),e.closePath(),e.fill()}void 0!==n&&1>n&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function oc(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function ic(e,t,n=.3){oc(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function sc(e,t,n=.6){if(!oc(t))return;const r=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,o=t.cx??t.x??0,i=t.cy??t.y??0;e.beginPath(),e.arc(o,i,r,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function ac(e,t,n,r=.35){oc(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}import{area as cc,line as lc}from"d3-shape";function uc(e,t){const n=fr(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const r=cc().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),r(t.topPath)}}var hc=(e,t,n,r)=>{const o=t.filter(e=>"area"===e.type);for(const t of o){if(2>t.topPath.length)continue;let n=!1;t.clipRect&&(e.save(),e.beginPath(),e.rect(t.clipRect.x,t.clipRect.y,t.clipRect.width,t.clipRect.height),e.clip(),n=!0);const o=t._introClipFraction;void 0!==o&&1>o&&(e.save(),e.beginPath(),e.rect(0,0,r.width*o,r.height),e.clip());const i=yr(e,t.style.fill,"#4e79a7"),s=t._decayOpacities;if(s&&s.length===t.topPath.length){const n=t.style.fillOpacity??.7;e.fillStyle=i;for(let r=0;t.topPath.length-1>r;r++)e.globalAlpha=.5*(s[r]+s[r+1])*n,e.beginPath(),e.moveTo(t.topPath[r][0],t.topPath[r][1]),e.lineTo(t.topPath[r+1][0],t.topPath[r+1][1]),e.lineTo(t.bottomPath[r+1][0],t.bottomPath[r+1][1]),e.lineTo(t.bottomPath[r][0],t.bottomPath[r][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(s[n]+s[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const a=t.style.opacity??1;if(uc(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let n=1/0;for(const e of t.topPath)n>e[1]&&(n=e[1]);let r=-1/0;for(const e of t.bottomPath)e[1]>r&&(r=e[1]);const o=pr(e,t.fillGradient,"string"==typeof i?i:"#4e79a7",0,n,0,r);e.fillStyle=o||i,e.globalAlpha=a}else e.globalAlpha=(t.style.fillOpacity??.7)*a,e.fillStyle=i;if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(uc(e,t),ac(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=a;const n=t.strokeGradient&&t.topPath.length>=2?gr(e,t.strokeGradient,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0):null;e.strokeStyle=n||Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const r=fr(t.curve);if(e.beginPath(),r)lc().x(e=>e[0]).y(e=>e[1]).curve(r).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1])}e.stroke()}void 0!==o&&1>o&&e.restore(),n&&e.restore(),e.globalAlpha=1}},dc=(e,t,n,r)=>{const o=t.filter(e=>"point"===e.type);if(0!==o.length){e.save();try{const t=e.globalAlpha;for(const n of o)e.beginPath(),e.arc(n.x,n.y,n.r,0,2*Math.PI),e.globalAlpha=t*(n.style.opacity??n.style.fillOpacity??1),e.fillStyle=yr(e,n.style.fill,"#4e79a7"),e.fill(),n.style.stroke&&(e.strokeStyle=yr(e,n.style.stroke,n.style.stroke),e.lineWidth=n.style.strokeWidth||1,e.stroke()),sc(e,n)}finally{e.restore()}}},fc=new Map;function yc(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=fc.get(t);return n||(n=new Path2D(dt(e.symbolType,e.size)),fc.size>256&&fc.clear(),fc.set(t,n)),n}catch{return null}}var pc=(e,t)=>{const n=e.globalAlpha;for(const r of t){if("symbol"!==r.type)continue;const t=r;if(0>=t.size)continue;const o=yc(t);if(!o)continue;e.save(),e.translate(t.x,t.y),t.rotation&&e.rotate(t.rotation);const i=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=n*i*(t.style.fillOpacity??1),e.fillStyle=yr(e,t.style.fill,"#4e79a7"),e.fill(o)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*i,e.strokeStyle=yr(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth??1,e.stroke(o)),e.restore()}e.globalAlpha=n};function gc(e,t,n,r,o){if(0>=t.size)return;const i=t.glyph;if(!i||!i.parts?.length)return;const s=In(i,t.size);if(0>=s.scale)return;const a=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=a)return;const c=t=>{const n=yr(e,t,t);return"string"==typeof n?n:t},l=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,r),t.rotation&&e.rotate(t.rotation),e.translate(s.offsetX,s.offsetY),e.scale(s.scale,s.scale),e.globalAlpha=o*a*(t.style.fillOpacity??1);const u=On(i,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&Bn(e,i,l,t.accent,t.ghostColor,c),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),Bn(e,i,l,t.accent,void 0,c),e.restore()}function mc(e,t){const{x:n,y:r,w:o,h:i}=t,{tl:s,tr:a,br:c,bl:l}=function(e){const t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(e.w,e.h)/2,r=e=>Math.max(0,Math.min(e??0,n));return{tl:r(t.tl),tr:r(t.tr),br:r(t.br),bl:r(t.bl)}}(t);e.beginPath(),e.moveTo(n+s,r),e.lineTo(n+o-a,r),a>0&&e.arcTo(n+o,r,n+o,r+a,a),e.lineTo(n+o,r+i-c),c>0&&e.arcTo(n+o,r+i,n+o-c,r+i,c),e.lineTo(n+l,r+i),l>0&&e.arcTo(n,r+i,n,r+i-l,l),e.lineTo(n,r+s),s>0&&e.arcTo(n,r,n+s,r,s),e.closePath()}function vc(e){switch(e.roundedEdge){case"bottom":return{x0:e.x,y0:e.y+e.h,x1:e.x,y1:e.y};case"right":return{x0:e.x+e.w,y0:e.y,x1:e.x,y1:e.y};case"left":return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y};default:return{x0:e.x,y0:e.y,x1:e.x,y1:e.y+e.h}}}var xc=(e,t,n,r)=>{const o=t.filter(e=>"rect"===e.type);for(const t of o){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)bc(e,t);else if(t.cornerRadii&&Zi(t.cornerRadii)){const n=yr(e,t.style.fill,Un(e,"var(--semiotic-primary, #007bff)")),r=vc(t),o=t.fillGradient&&"string"==typeof n?pr(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=o||n,mc(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else if(t.roundedTop&&t.roundedTop>0){const n=yr(e,t.style.fill,Un(e,"var(--semiotic-primary, #007bff)")),r=vc(t),o=t.fillGradient&&"string"==typeof n?pr(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=o||n;const i=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:s,y:a,w:c,h:l}=t;switch(t.roundedEdge){case"right":e.moveTo(s,a),e.lineTo(s+c-i,a),e.arcTo(s+c,a,s+c,a+i,i),e.lineTo(s+c,a+l-i),e.arcTo(s+c,a+l,s+c-i,a+l,i),e.lineTo(s,a+l);break;case"left":e.moveTo(s+c,a),e.lineTo(s+i,a),e.arcTo(s,a,s,a+i,i),e.lineTo(s,a+l-i),e.arcTo(s,a+l,s+i,a+l,i),e.lineTo(s+c,a+l);break;case"bottom":e.moveTo(s,a),e.lineTo(s+c,a),e.lineTo(s+c,a+l-i),e.arcTo(s+c,a+l,s+c-i,a+l,i),e.lineTo(s+i,a+l),e.arcTo(s,a+l,s,a+l-i,i);break;default:e.moveTo(s,a+l),e.lineTo(s,a+i),e.arcTo(s,a,s+i,a,i),e.lineTo(s+c-i,a),e.arcTo(s+c,a,s+c,a+i,i),e.lineTo(s+c,a+l)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const n=yr(e,t.style.fill,Un(e,"var(--semiotic-primary, #007bff)")),r=vc(t),o=t.fillGradient&&"string"==typeof n?pr(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=o||n,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}ic(e,t),e.globalAlpha=1}};function bc(e,t){const n=t.style.icon,r=t.style.iconPadding||2,o=Math.min(t.w,t.h)-r;if(0>=o)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=o+r,s=t.x+(t.w-o)/2;for(let r=t.y+t.h-o;r>=t.y-o;r-=i)e.drawImage(n,s,r,o,o)}else{const i=o+r,s=t.y+(t.h-o)/2;for(let r=t.x;t.x+t.w>r;r+=i)e.drawImage(n,r,s,o,o)}e.restore()}function kc(e){const[t,n,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*r>128?"#000":"#fff"}function wc(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var Ac=(e,t,n,r)=>{const o=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of o){const n=t.style;if(null!=n?.opacity&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle=Un(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),ic(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):wc(t.value),r=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),o=t.x+t.w/2,i=t.y+t.h/2;e.fillStyle=kc(t.fill),e.font=r+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,o,i)}}}finally{e.restore()}},Sc=(e,t,n,r)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const o=(t._decayOpacity??1)*(t.style?.opacity??1);1!==o&&(e.globalAlpha=o);const i=Un(e,t.wickColor)||t.wickColor,s=60>r.height,a=s?Math.max(t.wickWidth,2):t.wickWidth,c=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=i,e.lineWidth=a,e.stroke()};if(s||c(),t.isRange){const n=Math.max(2,Math.min(t.bodyWidth/2,.12*r.height));e.fillStyle=i,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),r=Math.abs(t.openY-t.closeY),o=t.isUp?t.upColor:t.downColor,i=Un(e,o)||o;e.fillStyle=i,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1)),e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1))}s&&c(),e.restore()}},_c={line:[hc,rc,dc],area:[hc,dc],stackedarea:[hc,dc],scatter:[dc,pc],bubble:[dc,pc],heatmap:[Ac],bar:[xc],swarm:[dc],waterfall:[(e,t,n,r)=>{xc(e,t);const o=t.filter(e=>"rect"===e.type);if(2>o.length)return;const i=o[0].datum,s=i?._connectorStroke;if(s){e.save(),e.strokeStyle=Un(e,s)||s,e.lineWidth=i?._connectorWidth??1,e.setLineDash([]);for(let t=0;o.length-1>t;t++){const r=o[t],i=o[t+1],s=r.datum,a=i.datum;if(null==s?.cumEnd||null==a?.baseline)continue;const c=n.y(s.cumEnd),l=r.x+r.w,u=i.x;e.beginPath(),e.moveTo(l,c),e.lineTo(u,c),e.stroke()}e.restore()}}],candlestick:[Sc],mixed:[hc,rc,dc],custom:[hc,xc,Ac,rc,dc,pc,(e,t)=>{const n=e.globalAlpha;for(const r of t)"glyph"===r.type&&gc(e,r,r.x,r.y,n);e.globalAlpha=n},Sc]},Mc=new Set;function Cc(e,t){const n="function"==typeof e?e(t.datum??null,t):e;return(r=n)&&"object"==typeof r&&"string"==typeof r.id&&"function"==typeof r.cacheKey&&"function"==typeof r.drawCanvas&&"function"==typeof r.renderStaticSVG?n:void 0;var r}function Pc(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const n=`${e}:${t}`;Mc.has(n)||(Mc.add(n),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function Tc(e){const{context:t,nodes:n,renderMode:r,pixelRatio:o,paintBuiltIn:i}=e;if(!r||"sketchy"===r)return void i(n);let s=[];const a=()=>{s.length&&(i(s),s=[])};for(const e of n){const n=Cc(r,e);if(!n){s.push(e);continue}let c;a(),t.save();try{c=n.drawCanvas({context:t,node:e,style:e.style??{},pixelRatio:o})}finally{t.restore()}c||(Pc(n.id,e.type??"unknown"),i([e]))}a()}function Rc(e){const{node:t,index:n,renderMode:r,fallback:o}=e,i=Cc(r,t);if(!i)return o();const s=i.renderStaticSVG({node:t,style:t.style??{},key:`${i.id}-${n}`});return null!=s?s:(Pc(i.id,t.type??"unknown"),o())}import{jsx as Nc,jsxs as Dc}from"react/jsx-runtime";import{jsx as Lc,jsxs as Ec}from"react/jsx-runtime";function Ic(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function Wc({hover:e}){const t=e.data??{},n=t.y??t.value,r=t.x??t.time;if(void 0===n&&void 0===r){const e=ya(t);if(null!=e.title||e.entries.length>0)return Ec("div",{className:"semiotic-tooltip",style:ma,children:[null!=e.title&&Lc("div",{style:{fontWeight:600,marginBottom:e.entries.length?2:0},children:e.title+""}),e.entries.map(e=>Ec("div",{style:{opacity:.7,fontSize:11},children:[e.key,":"," ",Lc("span",{style:{fontWeight:600},children:Ic(e.value)})]},e.key))]})}return Ec("div",{className:"semiotic-tooltip",style:ma,children:[Lc("div",{style:{fontWeight:600,marginBottom:2},children:Ic(n)}),Lc("div",{style:{opacity:.7,fontSize:11},children:Ic(r)})]})}function $c(e){return"touch"===e?"touch":"pointer"}function zc(e){const t=e.target;return t instanceof Element&&t!==e.currentTarget&&null!=t.closest("button, a[href], input, select, textarea, summary, [contenteditable='true'], [role='button'], [role='link'], [role='checkbox'], [role='radio'], [role='switch']")}function Oc(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:s,context:a,timestamp:c=Date.now()}=e;t&&(n?(t({type:"hover",datum:n,x:r,y:o,timestamp:c,chartType:i,chartId:s}),"focus"===a?.type&&t({type:"focus",datum:n,inputType:"touch"===a.inputType?"pointer":a.inputType,timestamp:c,chartType:i,chartId:s})):t({type:"hover-end",timestamp:c,chartType:i,chartId:s}))}function Fc(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:s,context:a,timestamp:c=Date.now()}=e;t&&(n?(t({type:"click",datum:n,x:r,y:o,timestamp:c,chartType:i,chartId:s}),"activate"===a?.type&&t({type:"activate",datum:n,inputType:a.inputType,timestamp:c,chartType:i,chartId:s})):t({type:"click-end",timestamp:c,chartType:i,chartId:s}))}Wc.ownsChrome=!0;import{useCallback as Bc}from"react";import{useCallback as Yc,useRef as jc}from"react";function Hc(e){const t=new Map;for(const n of e){const e=n.group??"_default";let r=t.get(e);r||(r=[],t.set(e,r)),r.push(n)}for(const e of t.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const n=Array.from(t.keys()).sort((e,n)=>{const r=t.get(e),o=t.get(n);return(r.length>0?r[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(t.values()).flat();r.sort((e,t)=>e.x-t.x||e.y-t.y);const o=new Map;for(let e=0;r.length>e;e++){r[e]._flatIndex=e;const t=r[e].datum?.id;null!=t&&o.set(t+"",e)}return{flat:r,groups:n,byGroup:t,idToIdx:o}}function Xc(e,t){if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const n=Math.max(0,Math.min(t,e.flat.length-1)),r=e.flat[n];return{flatIndex:n,group:r.group??"_default",indexInGroup:r._groupIndex??0}}function Gc(e,t,n){const{group:r,indexInGroup:o}=t,i=n.byGroup.get(r);switch(e){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:t.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(r);return n.groups.length-1>e?Vc(n,n.groups[e+1],i[o]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(r);return e>0?Vc(n,n.groups[e-1],i[o]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function Vc(e,t,n){const r=e.byGroup.get(t);let o=0,i=Math.abs(r[0].x-n.x);for(let e=1;r.length>e;e++){const t=Math.abs(r[e].x-n.x);i>t&&(i=t,o=e)}return r[o]._flatIndex}function qc(e){const t=[];for(const n of e)switch(n.type){case"point":t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=n.size)break;t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"glyph":{if(0>=n.size||null==n.datum)break;const e=Fn(n.glyph,n.size);t.push({x:n.x+e.centerDx,y:n.y+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:"_default"});break}case"line":{const e=n,r=Array.isArray(e.datum)?e.datum:[],o=e.group??"_default";for(let n=0;e.path.length>n&&r.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:r[n],shape:"circle",group:o});break}case"area":{const e=n,r=Array.isArray(e.datum)?e.datum:[],o=e.group??"_default";for(let n=0;e.topPath.length>n&&r.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:r[n],shape:"circle",group:o});break}case"rect":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.group??"_default"});break;case"heatcell":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}function Uc(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}import{jsx as Kc,jsxs as Qc}from"react/jsx-runtime";var Zc={top:20,right:20,bottom:30,left:40},Jc=ws;function el(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var tl=l(c(function(c,l){const{chartType:u,runtimeMode:h,data:d,chunkThreshold:f,chunkSize:y,xAccessor:p,yAccessor:g,accessorRevision:m,colorAccessor:v,sizeAccessor:x,symbolAccessor:b,symbolMap:k,groupAccessor:w,lineDataAccessor:S,curve:C,normalize:P,baseline:T,stackOrder:R,binSize:N,valueAccessor:D,arrowOfTime:L="right",windowMode:E="sliding",windowSize:I=200,timeAccessor:$,xExtent:z,yExtent:O,extentPadding:F=.1,scalePadding:B,sizeRange:Y,size:j=[500,300],responsiveWidth:H,responsiveHeight:X,margin:G,className:V,background:q,renderMode:U,lineStyle:K,pointStyle:Q,areaStyle:Z,barStyle:J,waterfallStyle:ee,swarmStyle:te,barColors:ne,colorScheme:re,boundsAccessor:oe,boundsStyle:ie,y0Accessor:se,band:ae,gradientFill:ce,lineGradient:le,areaGroups:ue,openAccessor:he,highAccessor:de,lowAccessor:fe,closeAccessor:ye,candlestickStyle:pe,showAxes:ge=!0,axes:me,xLabel:ve,yLabel:xe,yLabelRight:be,xFormat:ke,yFormat:we,axisExtent:Ae,tickFormatTime:Se,tickFormatValue:_e,hoverAnnotation:Me,tooltipContent:Ce,customHoverBehavior:Pe,customClickBehavior:Te,onObservation:Re,annotationObservationCallback:Ne,chartId:De,enableHover:Le,hoverRadius:Ee=30,tooltipMode:Ie,annotations:We,onAnnotationActivate:$e,autoPlaceAnnotations:ze,svgAnnotationRules:Oe,showGrid:Fe,legend:Be,legendHoverBehavior:Ye,legendClickBehavior:je,legendHighlightedCategory:He,legendIsolatedCategories:Xe,legendPosition:Ge,legendLayout:Ve,legendCategoryAccessor:qe,onCategoriesChange:Ue,backgroundGraphics:Ke,foregroundGraphics:Ze,canvasPreRenderers:Je,svgPreRenderers:et,title:tt,categoryAccessor:nt,brush:rt,onBrush:ot,decay:it,pulse:st,transition:at,animate:ct,staleness:lt,frameScheduler:ut,clock:ht,random:ft,seed:yt,paused:pt=!1,suspendWhenHidden:gt=!0,heatmapAggregation:mt,heatmapXBins:vt,heatmapYBins:xt,showValues:bt,heatmapValueFormat:kt,marginalGraphics:wt,pointIdAccessor:At,xScaleType:St,yScaleType:_t,accessibleTable:Mt=!0,description:Ct,summary:Pt,linkedCrosshairName:Tt,linkedCrosshairSourceId:Rt,customLayout:Nt,onLayoutError:Dt,layoutConfig:Lt,layoutSelection:Et}=c,{customHoverBehavior:It,customClickBehavior:Wt,hasClickBehavior:$t}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:r,chartType:o}){return{customHoverBehavior:Bc((t,i)=>{e?.(t,i),Oc({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:o,chartId:r,context:i})},[r,o,e,n]),customClickBehavior:Bc((e,i)=>{t?.(e,i),Fc({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:o,chartId:r,context:i})},[r,o,t,n]),hasClickBehavior:!(!t&&!n)}}({customHoverBehavior:Pe,customClickBehavior:Te,onObservation:Re,chartId:De,chartType:"StreamXYFrame"}),zt=a().replace(/:/g,""),Ot=t(!1),Ft=t({w:-1,h:-1}),Bt=t(!1),Yt=za({sizeProp:j,responsiveWidth:H,responsiveHeight:X,userMargin:G,marginDefault:Zc,title:tt,legend:Be,legendPosition:Ge,animate:ct,transitionProp:at,frameScheduler:ut,clock:ht,random:ft,seed:yt,paused:pt,suspendWhenHidden:gt,themeDirtyRef:Ot}),jt=hs(),Ht=ps(),{reducedMotionRef:Xt,responsiveRef:Gt,size:Vt,currentTheme:qt,transition:Ut,introEnabled:Kt,tableId:Qt,rafRef:Zt,renderFnRef:Jt,scheduleRender:en,frameRuntime:tn}=Yt;let nn=Yt.margin;if(wt){const e=60,t={...Yt.margin};wt.top&&e>t.top&&(t.top=e),wt.bottom&&e>t.bottom&&(t.bottom=e),wt.left&&e>t.left&&(t.left=e),wt.right&&e>t.right&&(t.right=e),nn=t}const rn=Vt[0]-nn.left-nn.right,sn=Vt[1]-nn.top-nn.bottom,an=o(()=>_(d),[d]),cn=Me??Le,[ln,un]=n(0),hn=t(0),[dn,fn]=n(null),yn=Ha(Ze,Vt,nn,dn),mn=Ha(Ke,Vt,nn,dn),xn=t(null),bn=t(null),kn=t(void 0),[wn,Sn]=n(null),_n=t(Jc.primary),Pn=t(function(){let e=-1,t=ws;return{resolve(n){if(!n)return ws;const r=Xn;return r===e||(t=function(e){if(!e)return ws;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),r=t.getPropertyValue("--semiotic-text-secondary").trim(),o=t.getPropertyValue("--semiotic-bg").trim(),i=t.getPropertyValue("--semiotic-primary").trim(),s=r||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),c=n||t.getPropertyValue("--surface-3").trim(),l=o||t.getPropertyValue("--surface-0").trim();return s||a||n||i?{axisStroke:c||ws.axisStroke,tickText:s||ws.tickText,crosshair:s?As(s,"66"):ws.crosshair,hoverFill:l?As(l,"4D"):ws.hoverFill,hoverStroke:s?As(s,"99"):ws.hoverStroke,pointRing:l||ws.pointRing,primary:i||ws.primary,background:l||ws.background}:ws}(n),e=r),t},invalidate(){e=-1}}}()),Tn=t(!1),Rn=pn("StreamXYFrame"),[Nn,Dn]=n(!1),[Ln,En]=n([]),[In,Wn]=n([]),$n="streaming"===h||["bar","swarm","waterfall"].includes(u),zn=ms(o(()=>({chartType:u,runtimeMode:$n?"streaming":"bounded",windowSize:I,windowMode:E,arrowOfTime:$n?L:"right",extentPadding:F,scalePadding:B,axisExtent:Ae,xAccessor:p,yAccessor:g,accessorRevision:m,timeAccessor:$n?$:void 0,valueAccessor:D,colorAccessor:v,sizeAccessor:x,symbolAccessor:b,symbolMap:k,groupAccessor:w||(S?"_lineGroup":void 0),categoryAccessor:nt,lineDataAccessor:S,xScaleType:St,yScaleType:_t,xExtent:z,yExtent:O,sizeRange:Y,binSize:N,normalize:P,baseline:T,stackOrder:R,boundsAccessor:oe,boundsStyle:ie,y0Accessor:se,band:ae,gradientFill:!0===ce?{topOpacity:.8,bottomOpacity:.05}:!1===ce?void 0:ce,areaGroups:ue?new Set(ue):void 0,lineGradient:le,openAccessor:he,highAccessor:de,lowAccessor:fe,closeAccessor:ye,candlestickStyle:pe,lineStyle:K,pointStyle:Q,areaStyle:Z,swarmStyle:te,waterfallStyle:ee,colorScheme:re,barColors:ne,barStyle:J,annotations:We,decay:it,pulse:st,transition:Ut,introAnimation:Kt,staleness:lt,clock:tn.now,heatmapAggregation:mt,heatmapXBins:vt,heatmapYBins:xt,showValues:bt,heatmapValueFormat:kt,pointIdAccessor:At,curve:C,themeCategorical:qt?.colors?.categorical,themeSemantic:W(qt),themeSequential:qt?.colors?.sequential,themeDiverging:qt?.colors?.diverging,customLayout:Nt,onLayoutError:Dt,layoutConfig:Lt,layoutMargin:nn}),[u,$n,I,E,L,F,B,Ae,p,g,m,$,D,v,x,b,k,w,S,nt,St,_t,z,O,Y,N,P,T,R,oe,ie,se,ae,ce,ue,le,he,de,fe,ye,pe,K,Q,Z,te,ee,re,ne,J,We,it,st,Ut,Kt,lt,tn.now,mt,vt,xt,bt,kt,At,C,qt,Nt,Dt,Lt,nn])),On=t(null);On.current||(On.current=new on(zn));const Fn=function(e,t,n,r){const o=qa({accessor:t,onChange:n,readData:r}),i=qa([]);return o.current={accessor:t,onChange:n,readData:r},Va(()=>{const{accessor:t,onChange:n,readData:r}=o.current;if(!n||!t)return;const s=function(e,t){if(!t)return[];const n=new Set,r=[];for(const o of e){if(!o||"object"!=typeof o)continue;const e="function"==typeof t?t(o):o[t];if(null==e)continue;const i=e+"";n.has(i)||(n.add(i),r.push(i))}return r}(e.current?r(e.current):[],t);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(s,i.current)||(i.current=s,n(s))},[e])}(On,qe,Ue,e=>e.getData());Mn(On,zn,Ot,en),Cn(On,Et,Ot,en);const Bn=t(null);Bn.current||(Bn.current=new M(e=>{const t=On.current;t&&t.ingest(e)&&(Ot.current=!0,en())},{chunkThreshold:f,chunkSize:y})),r(()=>{Bn.current?.updateChunkOptions({chunkThreshold:f,chunkSize:y})},[f,y]);const Yn=i(e=>{Bn.current?.push(e)},[]),jn=i(e=>{Bn.current?.pushMany(e)},[]),Hn=i(()=>{Bn.current?.clear(),On.current?.clear(),Ot.current=!0,en()},[en]);s(l,()=>({push:Yn,pushMany:jn,remove:e=>{Bn.current?.flush();const t=On.current?.remove(e)??[];return t.length>0&&(xn.current&&t.some(e=>e===xn.current?.data)&&(xn.current=null,Sn(null)),Ot.current=!0,en()),t},update:(e,t)=>{Bn.current?.flush();const n=On.current?.update(e,t)??[];return n.length>0&&(Ot.current=!0,en()),n},clear:Hn,getData:()=>(Bn.current?.flush(),On.current?.getData()??[]),getScales:()=>On.current?.scales??null,getExtents:()=>On.current?.getExtents()??null,getCustomLayout:()=>On.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>On.current?.lastCustomLayoutFailure??null}),[Yn,jn,Hn,en]),r(()=>{if(d){if(S&&an.length>0&&"object"==typeof an[0]&&null!==an[0]){const e="string"==typeof S?S:"coordinates";if(Array.isArray(an[0][e])){const t=[];for(const n of an){const r=n[e];if(Array.isArray(r)){const e=n.label||n.id||n.key;if(null!=e)for(const n of r)t.push({...n,_lineGroup:e});else for(const e of r)t.push(e)}}return void Bn.current?.setBoundedData(t)}}Bn.current?.setBoundedData(an)}},[d,an,S]);const{canvasRef:Gn,interactionCanvasRef:Vn}=Ya(Yt,{storeRef:On,dirtyRef:Ot,hydrated:jt,wasHydratingFromSSR:Ht,cleanup:()=>Bn.current?.clear(),canvasPaintDependencies:[u,rn,sn,ge,q,Ke,K,U,Je,en]}),{hoverHandlerRef:qn,hoverLeaveRef:Un,onPointerMove:Kn,onPointerLeave:Qn}=Yt;qn.current=e=>{if(!cn)return;const t=Gn.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-nn.left,o=e.clientY-n.top-nn.top;if(0>r||r>rn||0>o||o>sn)return void(xn.current&&(xn.current=null,bn.current=null,Sn(null),It&&(It(null),Ot.current=!0),en()));const i=On.current;if(!i||0===i.scene.length)return;const s=sa(Ee,e.pointerType),a=br(i.scene,r,o,s,i.quadtree,i.maxPointRadius),c="multi"===Ie,l=()=>{xn.current&&(xn.current=null,bn.current=null,Sn(null),It&&It(null),en())};if(!a&&!c)return void l();const h=c||!a?r:a.x,d=c||!a?o:a.y,f=a?.datum?Qe(a.datum,i.resolvedRibbons):{},y=i.scales?.x?.invert,g="function"==typeof y?y(h):void 0;let m=ca(f,h,d,null!=g?{xValue:g,xPx:h}:void 0);if(c&&i.scene.length>0&&i.scales){const e=function(e,t,n=30){const r=[];for(const o of e)if("line"===o.type){const e=o;if(2>e.path.length)continue;const i=kr(xr(e.path,e.curve),t,n);if(null===i)continue;const s=Nr(e.path,t);r.push({node:o,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.path[s][0],y:i,group:e.group,color:e.style.stroke})}else if("area"===o.type){const e=o;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const i=xr(e.topPath,e.curve),s=xr(e.bottomPath,e.curve),a=kr(i,t,n);if(null===a)continue;const c=kr(s,t,n),l=Nr(e.topPath,t);r.push({node:o,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:e.topPath[l][0],y:a,y0:c??void 0,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return r}(i.scene,h,Math.max(s,rn));if(e.length>0){const t=i.scales.y.invert,n=_n.current,r=y?y(h):h;if(a)m.xValue=r,m.xPx=h;else{const e={xValue:r};"string"==typeof p&&(e[p]=r),m=ca(e,h,d,{xValue:r,xPx:h})}m.allSeries=e.map(e=>{const r=t?t(e.y):e.y,o=null!=e.y0?t?t(e.y0):e.y0:void 0;return{group:e.group||"",value:"stackedarea"===u&&null!=o?r-o:r,valuePx:e.y,color:e.color||n,datum:Qe(e.datum,i.resolvedRibbons)}})}}a||m.allSeries?.length?(xn.current=m,bn.current=a?.node??null,Sn(m),It&&(It(m),Ot.current=!0),en()):l()},Un.current=()=>{xn.current&&(xn.current=null,bn.current=null,Sn(null),It&&(It(null),Ot.current=!0),en())};const Zn=t(()=>{});Zn.current=e=>{if(Qo(e.target))return;if(!Wt)return;const t=Gn.current;if(!t)return;const n=t.getBoundingClientRect(),r=e.clientX-n.left-nn.left,o=e.clientY-n.top-nn.top;if(0>r||r>rn||0>o||o>sn)return void Wt(null);const i=On.current;if(!i||0===i.scene.length)return void Wt(null);const s=sa(Ee,kn.current),a=br(i.scene,r,o,s,i.quadtree,i.maxPointRadius);if(!a)return void Wt(null);const c=a.datum||{},l=i.scales?.x?.invert,u="function"==typeof l?l(a.x):void 0;Wt(ca(c,a.x,a.y,null!=u?{xValue:u,xPx:a.x}:void 0),{type:"activate",inputType:$c(kn.current)})};const er=i(e=>Zn.current(e),[]),{kbFocusIndexRef:tr,focusedNavPointRef:rr,onKeyDown:or}=(cr={storeRef:On,hoverRef:xn,hoveredNodeRef:bn,setHoverPoint:Sn,customHoverBehavior:It,customClickBehavior:Wt,scheduleRender:en},function({storeRef:e,hoverRef:t,hoveredNodeRef:n,setHoverPoint:r,customHoverBehavior:o,customClickBehavior:i,scheduleRender:s,extractPoints:a,toHover:c}){const l=jc(-1),u=jc(null),h=jc(null),d=Yc(d=>{if(zc(d))return;const f=e.current;if(!f)return;const y=()=>{l.current=-1,u.current=null,t.current=null,n&&(n.current=null),r(null),o(null),s()};if(0===f.scene.length)return void(0>l.current||y());let p;if(h.current?.version===f.version)p=h.current.graph;else{const e=a(f.scene);if(0===e.length)return void(0>l.current||y());p=Hc(e),h.current={version:f.version,graph:p}}let g=l.current;if(p.flat.length>g||(y(),g=-1),("Enter"===d.key||" "===d.key)&&g>=0)return d.preventDefault(),void i(c(p.flat[g],f),{type:"activate",inputType:"keyboard"});if(0>g){if("Escape"===d.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(d.key))return;d.preventDefault(),l.current=0;const e=p.flat[0];u.current=e;const n=c(e,f);return t.current=n,r(n),o(n,{type:"focus",inputType:"keyboard"}),void s()}const m=Gc(d.key,Xc(p,g),p);if(null===m)return;if(d.preventDefault(),0>m)return void y();l.current=m;const v=p.flat[m];u.current=v;const x=c(v,f);t.current=x,r(x),o(x,{type:"focus",inputType:"keyboard"}),s()},[i,o,a,t,n,s,r,e,c]);return{kbFocusIndexRef:l,focusedNavPointRef:u,onKeyDown:d}}({...cr,extractPoints:qc,toHover:(e,t)=>function(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}({...e,datum:Qe(e.datum,t.resolvedRibbons)})})),ir=i(e=>{kn.current=e.pointerType,tr.current=-1,rr.current=null,Kn(e)},[rr,tr,Kn]),sr=i(e=>{kn.current="mouse",tr.current=-1,rr.current=null,Kn({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[rr,tr,Kn]),ar=i(e=>{kn.current=e.pointerType},[]);var cr;Jt.current=()=>{if(Zt.current=null,!tn.isActive)return;const e=Gn.current,t=Vn.current;if(!e||!t)return;const n=On.current;if(!n)return;const r=tn.now(),o=n.advanceTransition(Xt.current?r+1e6:r),i=!Xt.current&&o,s=Ft.current.w!==rn||Ft.current.h!==sn,a=Ot.current||o||s,c=n.consumeStylePaintPending();let l=!1;const h=n.getLastUpdateResult(),d=Rn.current.beforeCompute(h,i);!a||i&&!s||(n.computeScene({width:rn,height:sn}),Ft.current={w:rn,h:sn},l=!0,Fn()),Rn.current.afterCompute(d,l,s);const f=function(e,t,n,r){const o=r.current,i=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,s=!i&&e.hasActivePulsesAt(t),a=!(n||i||!s&&!o)&&e.refreshPulse(t);return r.current=s,{changed:a,pending:s}}(n,r,l,Bt),y=Ga(),m=Pn.current.resolve(e);_n.current=m.primary;const v=Wr(lt,n.lastIngestTime>0?r-n.lastIngestTime:0),x=lt&&v.isStale;if(a||c||f.changed){const t=Xa(e,Vt,nn,y);if(t){if(t.clearRect(-nn.left,-nn.top,Vt[0],Vt[1]),lt&&1>v.alpha&&(t.globalAlpha=v.alpha),ks(t,{background:q,hasBackgroundGraphics:!!Ke,themeBackground:m.background,x:-nn.left,y:-nn.top,width:Vt[0],height:Vt[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,rn,sn),t.clip()),Je&&n.scales)for(const e of Je)t.save(),e(t,n.scene,n.scales,{width:rn,height:sn}),t.restore();const e=Nt?_c.custom:_c[u];Tc({context:t,nodes:n.scene,renderMode:U,pixelRatio:y,paintBuiltIn:r=>{if(e&&n.scales)for(const o of e)o(t,r,n.scales,{width:rn,height:sn})}}),t.restore(),lt&&1>v.alpha&&(t.globalAlpha=1)}}const b=!!(cn&&xn.current&&n.scales),k=!!(bn.current&&Array.isArray(Me)&&Me.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),w=b||k;if(w||Tn.current){const e=Xa(t,Vt,nn,y);if(e&&(e.clearRect(-nn.left,-nn.top,Vt[0],Vt[1]),b&&xn.current&&function(e,t,n,r,o,i,s){if(!1===o.crosshair)return;const a=t.allSeries,c=a&&a.length>0,l=t.xPx??t.x;e.save();const u="object"==typeof o.crosshair?o.crosshair:{};if(e.strokeStyle=u.stroke||s.crosshair,e.lineWidth=u.strokeWidth||1,e.setLineDash(u.strokeDasharray?u.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(c?l:t.x,0),e.lineTo(c?l:t.x,r),e.stroke(),c||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),c){e.lineWidth=2,e.strokeStyle=s.pointRing;for(const t of a)null!=t.valuePx&&(e.beginPath(),e.arc(l,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||s.primary,e.fill(),e.stroke())}else{const n=o.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(i)||s.primary;e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=n,e.fill(),e.strokeStyle=s.pointRing,e.lineWidth=2,e.stroke()}}(e,xn.current,rn,sn,"object"==typeof cn?cn:{},bn.current,m),k&&bn.current&&Array.isArray(Me))){const t=Me.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,r,o){if(!n)return;const i="group"in n?n.group:void 0;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof r.style?n.datum?r.style(n.datum):{}:r.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||o.primary,e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=t.opacity??1,e.stroke(),e.restore()}}(e,n.scene,bn.current,t,m)}Tn.current=w}a&&e&&e.setAttribute("aria-label",$s(n.scene,u+" chart"));const A=Ot.current;if(Ot.current=A&&i&&!l,A&&n.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!dn||e(dn.x.domain()[0])!==e(n.scales.x.domain()[0])||e(dn.x.domain()[1])!==e(n.scales.x.domain()[1])||e(dn.y.domain()[0])!==e(n.scales.y.domain()[0])||e(dn.y.domain()[1])!==e(n.scales.y.domain()[1])||dn.x.range()[0]!==n.scales.x.range()[0]||dn.x.range()[1]!==n.scales.x.range()[1]||dn.y.range()[0]!==n.scales.y.range()[0]||dn.y.range()[1]!==n.scales.y.range()[1])&&fn(n.scales),wt){const e=n.getData(),t="function"==typeof p?p:e=>e[p||"x"],r="function"==typeof g?g:e=>e[g||"y"];En(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Wn(e.map(e=>r(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((We&&We.length>0||Nt)&&(l||i))||!l&&33>r-hn.current||(un(e=>e+1),hn.current=r),lt?.showBadge&&Dn(!!x),(i||null!=n.activeTransition||f.pending)&&en()},$r(lt,On,Ot,en,Nn,Dn);const lr=o(()=>{if(ke||Se)return;const e=On.current;return e?.xIsDate&&dn?Za(dn.x.domain()):void 0},[ke,Se,dn]),ur=ke||Se||lr,hr=cn&&wn?Ce?Ce(wn):Kc(Wc,{hover:wn}):null,dr=hr?Kc(xa,{x:wn.x,y:wn.y,containerWidth:rn,containerHeight:sn,margin:nn,className:"stream-frame-tooltip",children:hr}):null,fr=rr.current,yr=Kc(oa,{active:tr.current>=0,hoverPoint:wn,margin:nn,size:Vt,shape:fr?.shape,width:fr?.w,height:fr?.h}),pr=Ua(p,$,"__semiotic_resolvedX","__semiotic_resolvedTime"),gr=Ua(g,D,"__semiotic_resolvedY","__semiotic_resolvedValue"),mr=pr.key,vr=gr.key,wr=function(e,t,n){return r=>{if(!r||!n||!e.fn&&!t.fn)return r;let o=!1;const i=r.map(n=>{const r=e.fn&&e.key&&!(e.key in n),i=t.fn&&t.key&&!(t.key in n);if(!r&&!i)return n;o=!0;const s={...n};return r&&(s[e.key]=e.fn(n)),i&&(s[t.key]=t.fn(n)),s});return o?i:r}}(pr,gr,We&&We.length>0||!1);if(os||!jt&&Ht){const t=On.current;t&&d&&(t.ingest({inserts:an,bounded:!0}),t.computeScene({width:rn,height:sn}));const n=t?.scene??[],r=t?.scales??null,o=Ha(Ze,Vt,nn,r),i=Ha(Ke,Vt,nn,r),s=ur||(()=>{if(t?.xIsDate&&r)return Za(r.x.domain())})();return Qc("div",{ref:Gt,className:"stream-xy-frame"+(V?" "+V:""),role:"img","aria-label":Ct||("string"==typeof tt?tt:"XY chart"),style:{position:"relative",width:H?"100%":Vt[0],height:X?"100%":Vt[1]},children:[Kc(ea,{summary:Pt}),Qc("svg",{xmlns:"http://www.w3.org/2000/svg",width:Vt[0],height:Vt[1],style:{position:"absolute",left:0,top:0},children:[Kc("g",{transform:`translate(${nn.left},${nn.top})`,children:i}),Qc("g",{transform:`translate(${nn.left},${nn.top})`,children:[q&&Kc("rect",{x:0,y:0,width:rn,height:sn,fill:q}),et&&r&&et.map((t,o)=>Kc(e.Fragment,{children:t(n,r,{width:rn,height:sn})},"svgpre-"+o)),n.map((e,t)=>Rc({node:e,index:t,renderMode:U,fallback:()=>function(e,t,n){switch(e.type){case"line":{const n=e;if(0===n.path.length)return null;const r="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return Ji("path",{d:r,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity},"line-"+t)}case"area":{const r=e;if(0===r.topPath.length)return null;const o=`M${r.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`,i=`${n?n+"-":""}area-${t}-hatch`,s=Jn(r.style.fill)?nr(r.style.fill,i):void 0,a=s?`url(#${i})`:ns(r.style.fill);if(r.clipRect){const e=`${n?n+"-":""}area-clip-${t}`;return es("g",{children:[es("defs",{children:[s,Ji("clipPath",{id:e,children:Ji("rect",{x:r.clipRect.x,y:r.clipRect.y,width:r.clipRect.width,height:r.clipRect.height})})]}),Ji("path",{d:o,fill:a,fillOpacity:r.style.fillOpacity??r.style.opacity??.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,clipPath:`url(#${e})`})]},"area-"+t)}return es(Ki.Fragment,{children:[s&&Ji("defs",{children:s}),Ji("path",{d:o,fill:a,fillOpacity:r.style.fillOpacity??r.style.opacity??.7,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},"area-"+t)}case"point":{const r=e,o=`${n?n+"-":""}point-${t}-hatch`,i=Jn(r.style.fill)?nr(r.style.fill,o):void 0;return es(Ki.Fragment,{children:[i&&Ji("defs",{children:i}),Ji("circle",{cx:r.x,cy:r.y,r:r.r,fill:i?`url(#${o})`:ns(r.style.fill),opacity:r.style.opacity??.8,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},"point-"+t)}case"symbol":return function(e,t){const n=dt(e.symbolType,e.size,e.path);return Ji("path",{d:n,transform:e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`,fill:e.style.fill?ns(e.style.fill):"none",opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},"symbol-"+t)}(e,t);case"glyph":return rs(e,e.x,e.y,`${n??""}glyph-${e.pointId??t}`);case"rect":{const r=e,o=`${n?n+"-":""}xyrect-${t}-hatch`,i=Jn(r.style.fill)?nr(r.style.fill,o):void 0;return es(Ki.Fragment,{children:[i&&Ji("defs",{children:i}),Ji("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:i?`url(#${o})`:ns(r.style.fill),opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},"rect-"+t)}case"heatcell":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[r,o,i]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(n.fill),s=.299*r+.587*o+.114*i>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return es("g",{children:[Ji("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),Ji("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px",children:e})]},"heatcell-"+t)}return Ji("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill},"heatcell-"+t)}case"candlestick":{const n=e,r=Math.min(n.openY,n.closeY),o=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return es("g",{children:[Ji("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),Ji("rect",{x:n.x-n.bodyWidth/2,y:r,width:n.bodyWidth,height:o,fill:i,stroke:i,strokeWidth:1})]},"candle-"+t)}default:return null}}(e,t,zt)})).filter(Boolean)]})]}),Kc(Ui,{width:rn,height:sn,totalWidth:Vt[0],totalHeight:Vt[1],margin:nn,scales:r,showAxes:ge,axes:me,xLabel:ve,yLabel:xe,yLabelRight:be,xFormat:s,yFormat:we||_e,axisExtent:Ae,showGrid:Fe,title:tt,legend:Be,legendHoverBehavior:Ye,legendClickBehavior:je,legendHighlightedCategory:He,legendIsolatedCategories:Xe,legendPosition:Ge,legendLayout:Ve,foregroundGraphics:vn(o,An(On.current?.customLayoutOverlays,Et??null)),marginalGraphics:wt,xValues:[],yValues:[],annotations:We,onAnnotationActivate:$e,onObservation:Ne??Re,chartId:De,chartType:"StreamXYFrame",autoPlaceAnnotations:ze,svgAnnotationRules:Oe,annotationFrame:0,xAccessor:mr,yAccessor:vr,annotationData:wr(On.current?.getData()),pointNodes:Ja(On.current?.scene),curve:"string"==typeof C?C:void 0,linkedCrosshairName:Tt,linkedCrosshairSourceId:Rt})]})}return Qc("div",{ref:Gt,className:"stream-xy-frame"+(V?" "+V:""),role:"group","aria-label":Ct||("string"==typeof tt?tt:"XY chart"),tabIndex:0,style:{position:"relative",width:H?"100%":Vt[0],height:X?"100%":Vt[1],overflow:"visible",touchAction:el(rt)},onKeyDown:or,children:["production"!==process.env.NODE_ENV&&On.current&&Kc(gn,{store:On.current,diagnostics:Rn.current}),Mt&&Kc(ta,{tableId:Qt}),Mt&&Kc(Zs,{scene:On.current?.scene??[],chartType:u+" chart",tableId:Qt,chartTitle:"string"==typeof tt?tt:void 0}),Kc(ea,{summary:Pt}),Kc(Ns,{hoverPoint:wn}),Qc("div",{role:"img","aria-label":Ct||("string"==typeof tt?tt:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:cn?ir:void 0,onMouseMove:cn?sr:void 0,onPointerLeave:cn?Qn:void 0,onMouseLeave:cn?Qn:void 0,onPointerDown:cn||$t?ar:void 0,onClick:$t?er:void 0,children:[Kc(ja,{size:Vt,margin:nn,children:mn}),Kc(Gi,{width:rn,height:sn,totalWidth:Vt[0],totalHeight:Vt[1],margin:nn,scales:dn,showAxes:ge,axes:me,showGrid:Fe,xFormat:ur,yFormat:we||_e,axisExtent:Ae}),Kc("canvas",{ref:Gn,"aria-label":$s(On.current?.scene??[],u+" chart"),style:{position:"absolute",left:0,top:0}}),Kc("canvas",{ref:Vn,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),Kc(Ui,{width:rn,height:sn,totalWidth:Vt[0],totalHeight:Vt[1],margin:nn,scales:dn,showAxes:ge,axes:me,xLabel:ve,yLabel:xe,yLabelRight:be,xFormat:ur,yFormat:we||_e,axisExtent:Ae,showGrid:Fe,title:tt,legend:Be,legendHoverBehavior:Ye,legendClickBehavior:je,legendHighlightedCategory:He,legendIsolatedCategories:Xe,legendPosition:Ge,legendLayout:Ve,foregroundGraphics:vn(yn,An(On.current?.customLayoutOverlays,Et??null)),marginalGraphics:wt,xValues:Ln,yValues:In,annotations:We,onAnnotationActivate:$e,onObservation:Ne??Re,chartId:De,chartType:"StreamXYFrame",autoPlaceAnnotations:ze,svgAnnotationRules:Oe,annotationFrame:ln,xAccessor:mr,yAccessor:vr,annotationData:wr(On.current?.getData()),pointNodes:Ja(On.current?.scene),curve:"string"==typeof C?C:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==q&&!Ke,linkedCrosshairName:Tt,linkedCrosshairSourceId:Rt}),(rt||ot)&&Kc(A,{width:rn,height:sn,totalWidth:Vt[0],totalHeight:Vt[1],margin:nn,dimension:rt?.dimension??"xy",scales:dn,onBrush:ot??(()=>{}),binSize:N,snap:rt?.snap,binBoundaries:rt?.binBoundaries??("bar"===u?On.current?.getBinBoundaries():void 0),snapDuring:rt?.snapDuring,streaming:"streaming"===h}),lt?.showBadge&&Kc(Or,{isStale:Nn,position:lt.badgePosition}),yr,dr]})]})}));tl.displayName="StreamXYFrame";var nl=tl;import{useRef as rl,useState as ol,useEffect as il,useMemo as sl,useCallback as al,useImperativeHandle as cl,forwardRef as ll,memo as ul}from"react";var hl={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},dl={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},fl=class{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e,t=Math.random){const n=this._freeIndices.pop();if(void 0===n)return null;const r=this.particles[n];return r.active=!0,r.t=0,r.offset=t()-.5,r.edgeIndex=e,r.x=0,r.y=0,r}step(e,t,n,r){for(let o=0;this.capacity>o;o++){const i=this.particles[o];if(!i.active)continue;const s=n[i.edgeIndex];s&&s.bezier?(i.t+=e*t*(r?r[i.edgeIndex]??1:1)*(s.bezier.circular?.3:1),1>i.t?yl(s.bezier,i.t,i.offset,i):(i.active=!1,this._freeIndices.push(o))):(i.active=!1,this._freeIndices.push(o))}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)t.length>n?this.particles[n]=t[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=e}};function yl(e,t,n,r){if(e.circular&&e.segments)return void function(e,t,n,r,o){const i=e.length,s=t*i,a=Math.min(Math.floor(s),i-1),c=s-a,[l,u,h,d]=e[a];pl(l,u,h,d,c,o);const f=d.x-l.x,y=d.y-l.y,p=Math.sqrt(f*f+y*y);if(p>.001){const e=f/p;o.x+=-y/p*n*r*2,o.y+=e*n*r*2}}(e.segments,t,n,e.halfWidth,r);if(!e.points)return r.x=0,void(r.y=0);const[o,i,s,a]=e.points;pl(o,i,s,a,t,r);const c=a.x-o.x,l=a.y-o.y,u=Math.sqrt(c*c+l*l);if(u>.001){const t=c/u;r.x+=-l/u*n*e.halfWidth*2,r.y+=t*n*e.halfWidth*2}}function pl(e,t,n,r,o,i){const s=1-o,a=s*s,c=a*s,l=o*o,u=l*o;i.x=c*e.x+3*a*o*t.x+3*s*l*n.x+u*r.x,i.y=c*e.y+3*a*o*t.y+3*s*l*n.y+u*r.y}function gl(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function ml(e,t){var n,r=[],o=[],i=[],s={},a=[];function c(e){i[e]=!1,s.hasOwnProperty(e)&&Object.keys(s[e]).forEach(function(t){delete s[e][t],i[t]&&c(t)})}function l(e){var t,r,h=!1;for(o.push(e),i[e]=!0,t=0;a[e].length>t;t++)(r=a[e][t])===n?(u(n,o),h=!0):i[r]||(h=l(r));if(h)c(e);else for(t=0;a[e].length>t;t++){var d=s[r=a[e][t]];d||(s[r]=d={}),d[r]=!0}return o.pop(),h}function u(e,n){var o=[].concat(n).concat(e);t?t(o):r.push(o)}function h(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,r=function(e){for(var t=e.length,n=Array(t),r=Array(t),o=Array(t),i=Array(t),s=Array(t),a=Array(t),c=0;t>c;++c)n[c]=-1,r[c]=0,o[c]=!1,i[c]=0,s[c]=-1,a[c]=[];var l,u=0,h=[],d=[];function f(t){var c=[t],l=[t];for(n[t]=r[t]=u,o[t]=!0,u+=1;l.length>0;){var f=e[t=l[l.length-1]];if(f.length>i[t]){for(var y=i[t];f.length>y;++y){var p=f[y];if(0>n[p]){n[p]=r[p]=u,o[p]=!0,u+=1,c.push(p),l.push(p);break}o[p]&&(r[t]=0|Math.min(r[t],r[p])),0>s[p]||a[t].push(s[p])}i[t]=y}else{if(r[t]===n[t]){var g=[],m=[],v=0;for(y=c.length-1;y>=0;--y){var x=c[y];if(o[x]=!1,g.push(x),m.push(a[x]),v+=a[x].length,s[x]=h.length,x===t){c.length=y;break}}h.push(g);var b=Array(v);for(y=0;m.length>y;y++)for(var k=0;m[y].length>k;k++)b[--v]=m[y][k];d.push(b)}l.pop()}}}for(c=0;t>c;++c)0>n[c]&&f(c);for(c=0;d.length>c;c++){var y=d[c];if(0!==y.length){y.sort(function(e,t){return e-t}),l=[y[0]];for(var p=1;y.length>p;p++)y[p]!==y[p-1]&&l.push(y[p]);d[c]=l}}return{components:h,adjacencyList:d}}(e),o=r.components.filter(function(e){return e.length>1}),i=1/0,s=0;o.length>s;s++)for(var a=0;o[s].length>a;a++)i>o[s][a]&&(i=o[s][a],n=s);var c=o[n];return!!c&&{leastVertex:i,adjList:e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})})}}n=0;for(var d=e.length;d>n;){var f=h(n);if(n=f.leastVertex,a=f.adjList){for(var y=0;a.length>y;y++)for(var p=0;a[y].length>p;p++){var g=a[y][p];i[+g]=!1,s[g]={}}l(n),n+=1}else n=d}return t?void 0:r}function vl(e){return e.y0-e.y1>0?"up":"down"}function xl(e,t){return t(e.source)==t(e.target)}function bl(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function kl(e){return e.target.x0-e.source.x1}function wl(e,t){var n=Sl(e),r=kl(t)/Math.tan(n);return"up"==vl(e)?e.y1-r:e.y1+r}function Al(e,t){var n=Sl(e),r=kl(t)/Math.tan(n);return"up"==vl(e)?e.y1+r:e.y1-r}function Sl(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function _l(e,t){return t(e)}function Ml(e){return Pl(e.source)}function Cl(e){return Pl(e.target)}function Pl(e){return(e.y0+e.y1)/2}function Tl(e){return e.virtual?0:e.value}function Rl(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!xl(e,t)?n+1:n});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!xl(e,t)?r+1:r}),n+r}function Nl(e){return e.target.depth}function Dl(e,t){return e.sourceLinks.length?e.depth:t-1}function Ll(e,t){return e.y0-t.y0}function El(e,t){return t.y0-e.y0}function Il(e,t){return e.y1-t.y1}function Wl(e,t){return t.y1-e.y1}function $l(e,t){return Ol(e.source,t.source)||e.index-t.index}function zl(e,t){return Ol(e.target,t.target)||e.index-t.index}function Ol(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Fl(e,t){return Bl(e)==Bl(t)?"bottom"==e.circularLinkType?El(e,t):Ll(e,t):Bl(t)-Bl(e)}function Bl(e){return e.target.column-e.source.column}function Yl(e,t){return jl(e)==jl(t)}function jl(e){return e.y0-e.y1>0?"up":"down"}import{min as Hl}from"d3-array";function Xl(e,t,n,r,o){let i=e;var s=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var a=Hl(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=i.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),Gl(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),Gl(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+r,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,xl(e,t)&&bl(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var s=e.source.column,c=e.circularLinkType,l=i.links.filter(function(e){return e.source.column==s&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?El:Ll);var u=0;l.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),s=e.target.column,(l=i.links.filter(function(e){return e.target.column==s&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?Wl:Il),u=0,l.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=a-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,r=e.target.x0,o=e.y1,i=(t+r)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+o+" "+r+","+o}(e)}),i}function Gl(e,t,n){e.sort(Fl);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(xl(e,t)&&bl(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var s=0;r.length>s;s++){var a=r[s];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Vl(e,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;i=c>i?c:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function Vl(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}import{min as ql,max as Ul,sum as Kl,mean as Ql,group as Zl,groups as Jl}from"d3-array";function eu(e){return function(){return e}}function tu(e){return e.index}function nu(e){return e.nodes}function ru(e){return e.links}function ou(e,t,n){var r=Jl(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(o,i){var s=o.length;if(t)o.sort(t);else if(i>0){var a=new Map;o.forEach(function(e,t){var n,r,o,i=(r=0,o=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=Pl(e.source)*t,r+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=Pl(e.target)*t,r+=t}}),r>0?o/r:NaN);a.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var n=a.get(e),r=a.get(t),o=n.bc,i=r.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?n.idx-r.idx:1:-1:o-i})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Rl(t,n)-Rl(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){t.depth==r.length-1&&1==s||0==t.depth&&1==s?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==Rl(t,n)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+o,t.y1=t.y0+t.value*e.ky)})})}function iu(e,t,n,r,o,i){var s=Jl(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var a=1,c=i;c>0;--c)l(a*=.99,n),u();function l(t,n){var r=s.length;s.forEach(function(o){var i=o.length,s=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Rl(o,n)>0){var c=Ql(o.sourceLinks,Cl),l=Ql(o.targetLinks,Ml),u=c&&l?(c+l)/2:c||l;if(u){var h=(u-Pl(o))*t*.3;o.y0+=h,o.y1+=h}}else if(0==s&&1==i)o.y0=e.y1/2-(a=o.y1-o.y0)/2,o.y1=e.y1/2+a/2;else if(s==r-1&&1==i)o.y0=e.y1/2-(a=o.y1-o.y0)/2,o.y1=e.y1/2+a/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)a=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+a;else{var d=Ql(o.sourceLinks,Cl),f=Ql(o.targetLinks,Ml),y=((d&&f?(d+f)/2:d||f)-Pl(o))*t;o.y0+=y,o.y1+=y}})})}function u(){s.forEach(function(n){var i,s,a,c=e.y0,l=n.length;for(n.sort(t||Ol),a=0;l>a;++a)(s=c-(i=n[a]).y0)>0&&(i.y0+=s,i.y1+=s),c=i.y1+r;if((s=c-r-e.y1)>0)for(c=i.y0-=s,i.y1-=s,a=l-2;a>=0;--a)(s=(i=n[a]).y1+o-c)>0&&(i.y0-=s,i.y1-=s),c=i.y0})}}function su(e){e.nodes.forEach(function(e){e.sourceLinks.sort(zl),e.targetLinks.sort($l)}),e.nodes.forEach(function(e){var t=e.y0,n=t,r=e.y1,o=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function au(){var e=0,t=0,n=1,r=1,o=24,i=8,s=null,a=tu,c=Dl,l=void 0,u=32,h=2,d=nu,f=ru;function y(){var y={nodes:d.apply(null,arguments),links:f.apply(null,arguments)};return function(d){d.x0=e,d.y0=t,d.x1=n,d.y1=r,d.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return Zl(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=gl(n,r)),"object"!=typeof o&&(o=e.target=gl(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(d,a),function(e,t){var n=0;if(null==t){for(var r=[],o=0;e.links.length>o;o++){var i=e.links[o],s=i.source.index,a=i.target.index;r[s]||(r[s]=[]),r[a]||(r[a]=[]),-1===r[s].indexOf(a)&&r[s].push(a)}var c=ml(r);c.sort(function(e,t){return e.length-t.length});var l={};for(o=0;c.length>o;o++){var u=c[o].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,r=e.source.index;t===r||l[r]&&l[r][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(d,l),function(e,t){var n=0,r=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:r>n?"top":"bottom","top"==o.circularLinkType?n++:r++,e.nodes.forEach(function(e){_l(e,t)!=_l(o.source,t)&&_l(e,t)!=_l(o.target,t)||(e.circularLinkType=o.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),xl(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(d,a),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(Kl(e.sourceLinks,Tl),Kl(e.targetLinks,Tl)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(d),function(e,t,n){var r,o,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var s=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){s=t(e)==a?s:s+1,a=t(e)==a?a:t(e),e.column=s})}for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(d,l,c);var f=i;if(null!==s){var y=Jl(d.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),p=Ul(y,function(e){return e.length});p>1&&(f=Math.max(1,(r-t)*s/(p-1)))}(function(e,t,n){var r=Jl(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var o=ql(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/Kl(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=Ul(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(d,f,o),ou(d,l,a),iu(d,l,a,f,f,u),su(d),Xl(d,a,h,10,8),ou(d,l,a),iu(d,l,a,f,f,u),su(d),Xl(d,a,h,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var r=n.links.filter(function(n){return _l(n.source,t)==_l(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Yl(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=wl(t,e);return e.y1-n}if(t.target.column>e.target.column)return wl(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,s=0;o>i;i++)s+=r[i].width;t.y0=e.y1-s-t.width/2}})})}(d,a),function(e,t){let n=e;n.nodes.forEach(function(e){var r=n.links.filter(function(n){return _l(n.target,t)==_l(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Yl(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=Al(t,e);return e.y0-n}if(t.source.column>e.source.column)return Al(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;r.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,s=0;o>i;i++)s+=r[i].width;t.y1=e.y1-s-t.width/2}})})}(d,a),function(e){var t=e.nodes,n=e.links,r=!1,o=!1;if(n.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==r||0==o){let r=function(t){return(t-i)/(s-i)*(e.y1-e.y0)+e.y0};var i=ql(t,function(e){return e.y0}),s=Ul(t,function(e){return e.y1}),a=(e.y1-e.y0)/(s-i);1>a?(t.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1)}),n.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1),e.width=e.width*a})):t.forEach(function(e){var t=e.y1-e.y0,n=r(e.y0)-e.y0;e.y0=r(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(d),Xl(d,a,h,10,8)}(y),y}return y.update=function(e){return su(e),Xl(e,a,h,10,8),e},y.nodeWidth=function(e){return arguments.length?(o=+e,y):o},y.nodePadding=function(e){return arguments.length?(i=+e,y):i},y.nodePaddingRatio=function(e){return arguments.length?(s=+e,y):s},y.nodes=function(e){return arguments.length?(d="function"==typeof e?e:eu(e),y):d},y.links=function(e){return arguments.length?(f="function"==typeof e?e:eu(e),y):f},y.nodeId=function(e){return arguments.length?(a="function"==typeof e?e:eu(e),y):a},y.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:eu(e),y):c},y.nodeSort=function(e){return arguments.length?(l=e,y):l},y.iterations=function(e){return arguments.length?(u=+e,y):u},y.circularLinkGap=function(e){return arguments.length?(h=+e,y):h},y.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],n=+o[1][0],r=+o[1][1],y):[[e,t],[n,r]]},y.size=function(o){return arguments.length?(e=t=0,n=+o[0],r=+o[1],y):[n-e,r-t]},y}import{interpolateNumber as cu}from"d3-interpolate";import{line as lu,curveLinearClosed as uu}from"d3-shape";var hu=e=>{let t,n,r,o,i,s,a,c,l;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.x1,s=e.target.x0,a=cu(i,s),c=a(.5),l=a(.5),`M${t},${i}C${t},${c} ${n},${l} ${n},${s}L${r},${s}C${r},${l} ${o},${c} ${o},${i}Z`;const u=e.sankeyWidth/2,h=cu(e.source.x1,e.target.x0),{pathD:d}=function(e){const{sx:t,sTop:n,sBot:r,tx:o,tTop:i,tBot:s,cp1X:a,cp2X:c}=e,l=(n+r)/2,u=(i+s)/2;return{pathD:[`M${t},${n}`,`C${a},${n} ${c},${i} ${o},${i}`,`L${o},${s}`,`C${c},${s} ${a},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:l},{x:a,y:l},{x:c,y:u},{x:o,y:u}],halfWidth:(r-n)/2}}}({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:h(.5),cp2X:h(.5)});return d};function du(e){const t=e.sankeyWidth/2,n=(e._circularWidth??e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const n=r.sourceX,o=r.sourceY,i=r.targetX,s=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const a=Math.max(15,Math.min(40,.33*(r.rightFullExtent-n))),c=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${n},${o-t}L${n+a},${o-t}L${n+a},${o+t}L${n},${o+t}ZM${i},${s-t}L${i-c},${s-t}L${i-c},${s+t}L${i},${s+t}Z`}const o=r.sourceX,i=r.sourceY,s=r.targetX,a=r.targetY,c=r.rightFullExtent,l=r.leftFullExtent,u=r.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,d=Math.max(4,Math.min(n,15));return`M${o},${i-h*t}L${c},${i-h*t}L${c+n},${i-h*t+h*d}L${c+n},${u+h*n-h*d}L${c+n-d},${u+h*n}L${l-n+d},${u+h*n}L${l-n},${u+h*n-h*d}L${l-n},${a-h*t+h*d}L${l-n+d},${a-h*t}L${s},${a-h*t}L${s},${a+h*t}L${l+n},${a+h*t}L${l+n},${u-h*n}L${c-n},${u-h*n}L${c-n},${i+h*t}L${o},${i+h*t}Z`}var fu=new Set,yu=new WeakMap;function pu(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=yu.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,yu.set(e,n);const r=new Proxy(e,{get(e,n,r){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;fu.has(e)||(fu.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,r)}});return n.set(t,r),r}var gu={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(Nl))-1:0},justify:Dl};function mu(e){return"string"==typeof e?e:e.id}var vu={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o="vertical"===n.orientation?"down":"right",i=n.nodeAlign||"justify",s=n.nodeWidth??15,a=n.nodePaddingRatio??.05,c=n.iterations??100,l=e.map(e=>({...e})),u=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let h;h="down"===o?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const d=au().extent(h).links(u).nodes(l).nodeAlign(gu[i]||Dl).nodeId(e=>e.id).nodeWidth(s).iterations(c);d.nodePaddingRatio&&d.nodePaddingRatio(a),d();{let e=1/0,t=-1/0,n=1/0,o=-1/0;for(const r of l)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),n>r.y0&&(n=r.y0),r.y1>o&&(o=r.y1);for(const r of u){if(!r.circular||!r.circularPathData)continue;const i=r.circularPathData,s=(r._circularWidth??r.width??0)/2;e>i.leftFullExtent-s&&(e=i.leftFullExtent-s),i.rightFullExtent+s>t&&(t=i.rightFullExtent+s),n>i.verticalFullExtent-s&&(n=i.verticalFullExtent-s),i.verticalFullExtent+s>o&&(o=i.verticalFullExtent+s)}const i=t-e,s=o-n,a=r[0],c=r[1];if(i>0&&s>0&&(0>e||0>n||t>a||o>c)){const t=Math.min(a/i,c/s),r=-e*t+(a-i*t)/2,o=-n*t+(c-s*t)/2;for(const e of l)e.x0=e.x0*t+r,e.x1=e.x1*t+r,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of u)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+r,n.targetX=n.targetX*t+r,n.sourceY=n.sourceY*t+o,n.targetY=n.targetY*t+o,n.rightFullExtent=n.rightFullExtent*t+r,n.leftFullExtent=n.leftFullExtent*t+r,n.verticalFullExtent=n.verticalFullExtent*t+o,n.rightInnerExtent=n.rightInnerExtent*t+r,n.leftInnerExtent=n.leftInnerExtent*t+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+o,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of l){const t=f.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const y=new Map;for(const e of t)y.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of u){const t=mu(e.source),n=mu(e.target),r=y.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(r){r.y0=e.y0,r.y1=e.y1,r.sankeyWidth=e.width??0,r.circular=!!e.circular,r.circularPathData=e.circularPathData,r._circularWidth=e._circularWidth,r._circularStub=e._circularStub,r.path=e.path,r.circularLinkType=e.circularLinkType,r.direction=o;const i=f.get(t),s=f.get(n);i&&(r.source=i),s&&(r.target=s)}}},buildScene(e,t,n,r){const o="vertical"===n.orientation?"down":"right",i=n.nodeStyle,s=n.edgeStyle,a=n.edgeOpacity??.5,c=n.edgeColorBy||"source",l=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ie,u=new Map;e.forEach((e,t)=>{u.set(e.id,l[t%l.length])});const h=[],d=[],f=[],y=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const r=i?i(pu(t,"nodeStyle")):{},s={fill:r.fill||u.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};y.set(t.id,("string"==typeof s.fill?s.fill:null)||u.get(t.id)||"#4d430c"),h.push("down"===o?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:s,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:s,datum:t,id:t.id,label:t.id})}const p=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of p){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";o="function"==typeof c?c(e)||o:"target"===c?y.get(r.id)||u.get(r.id)||o:y.get(t.id)||u.get(t.id)||o;const i=s?s(pu(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,r=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=i.fill||o;d.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+r},${t.sourceY-n}L${t.sourceX+r},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+r}}),d.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-s},${t.targetY-n}L${t.targetX-s},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let l;(l=e.circular&&e.circularPathData?du(e):hu(e),l)&&d.push({type:"bezier",pathD:l,bezierCache:e.bezier,style:{fill:i.fill||o,fillOpacity:i.fillOpacity??a,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity},datum:e})}if(!1!==n.showLabels){const t=(g=n.nodeLabel)?"function"==typeof g?g:e=>e[g]||e.id:null;for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=t?t(n):n.id;if(!s)continue;let a,c,l;"down"===o?(a=n.y0+(n.y1-n.y0)/2,c=n.x1+14,l="start"):(r[0]/2>n.x0+e/2?(a=n.x0-6,l="end"):(a=n.x1+6,l="start"),c=n.y0+i/2),f.push({x:a,y:c,text:s+"",anchor:"down"===o?"middle":l,baseline:"middle",fontSize:11})}}var g;return{sceneNodes:h,sceneEdges:d,labels:f}}};import{forceSimulation as xu,forceCenter as bu,forceX as ku,forceY as wu,forceLink as Au,forceManyBody as Su,forceCollide as _u}from"d3-force";import{scaleLinear as Mu}from"d3-scale";var Cu={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o=n.forceStrength??.1,i=r[0]/2,s=r[1]/2,a=n.__previousPositions;let c=0;const l=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=a?.get(t.id);e?c++:n?(t.x=n.x,t.y=n.y,c++):l.push(t)}const u=c>0&&.3>=(e.length>0?l.length/e.length:1);if(u){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of l){const r=Pu(e.id,t,n);if(r.length>0){let t=0,n=0;for(const e of r)t+=e.x,n+=e.y;const o=Tu(e.id),i=o%360*(Math.PI/180),s=10+o%20;e.x=t/r.length+s*Math.cos(i),e.y=n/r.length+s*Math.sin(i)}else{const t=Tu(e.id),n=t%360*(Math.PI/180),r=15+t%30;e.x=i+r*Math.cos(n),e.y=s+r*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const r=e[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(n+.5),o=n*t;r.x=i+e*Math.cos(o),r.y=s+e*Math.sin(o)}}}const h=n.__skipForceSimulation||0===n.iterations?0:u?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),d=Ru(n.nodeSize,n.nodeSizeRange,e),f=e=>d(e);if(h>0){const r=new Map,a=new Map;for(const t of e)r.set(t.id,0),a.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id;r.set(t,(r.get(t)??0)+1),r.set(n,(r.get(n)??0)+1)}const c=Au().strength(e=>{const t=e.weight,n="string"==typeof e.target?e.target:e.target.id,i=Math.max(1,Math.min(r.get("string"==typeof e.source?e.source:e.source.id)??1,r.get(n)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*o/(.1*i))}).distance(e=>{const t="string"==typeof e.source?a.get(e.source):e.source,n="string"==typeof e.target?a.get(e.target):e.target,r=(t?f(t):0)+(n?f(n):0)+12;return Math.max(40,r)}).id(e=>e.id),l=xu();if(void 0===n.random&&void 0===n.seed||l.randomSource(n.random??Da(n.seed)),l.force("charge",Su().strength(e=>{const t=r.get(e.id)??0;return-15*f(e)*Math.sqrt(t+1)})).force("collide",_u(e=>f(e)+3).strength(.9).iterations(2)).force("center",bu(i,s).strength(.8)).force("x",ku(i).strength(.06)).force("y",wu(s).strength(.06)),l.nodes(e),t.length>0){const e=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));c.links(e),l.force("link",c)}u?l.alpha(.3):.1>l.alpha()&&l.alpha(1),l.stop();for(let e=0;h>e;++e)l.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=f(t);t.x=Math.max(e,Math.min(r[0]-e,t.x)),t.y=Math.max(e,Math.min(r[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const y=new Map;for(const t of e)y.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=y.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=y.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,r){const o=n.nodeStyle,i=n.edgeStyle,s=Ru(n.nodeSize,n.nodeSizeRange,e),a=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ie,c=new Map;e.forEach((e,t)=>{c.set(e.id,a[t%a.length])});const l=[],u=[],h=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=s(pu(t,"nodeSize")),r=o?o(pu(t,"nodeStyle")):{},i={fill:r.fill||c.get(t.id)||n.themeSemantic?.primary||"#007bff",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:i,datum:t,id:t.id,label:t.id})}const d=new Map;for(const t of e)d.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:d.get(e.source),r="object"==typeof e.target?e.target:d.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const o=i?i(pu(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:o.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6},datum:e})}if(!1!==n.showLabels){const t=(f=n.nodeLabel)?"function"==typeof f?f:e=>e[f]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const r=s(pu(n,"nodeSize"));h.push({x:n.x,y:n.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:l,sceneEdges:u,labels:h}}};function Pu(e,t,n){const r=[];for(const o of t){const t="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let s=null;if(t===e?s=i:i===e&&(s=t),s){const e=n.get(s);!e||0===e.x&&0===e.y||r.push({x:e.x,y:e.y})}}return r}function Tu(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function Ru(e,t,n){if(n.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const r=t||[5,20],o=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&o.push(n)}if(0===o.length)return()=>r[0];const[i,s]=oo(o);if(i===s)return()=>(r[0]+r[1])/2;const a=Mu().domain([i,s]).range(r).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?r[0]:a(n)}}import{chord as Nu,ribbon as Du}from"d3-chord";import{arc as Lu}from"d3-shape";var Eu=ie,Iu={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:s}=n,a=Math.min(r[0],r[1])/2,c=a-i,l=r[0]/2,u=r[1]/2,h=(d=n.valueAccessor)?"function"==typeof d?d:e=>e[d]??1:e=>e.value??1;var d;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const y=e.length,p=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=f.get("string"==typeof e.source?e.source:e.source.id),r=f.get(t);if(void 0===n||void 0===r)continue;const o=h(e);p[n][r]=o}const g=Nu().padAngle(o);s&&g.sortGroups(s);const m=g(p),v=m.groups,x=Lu().innerRadius(c).outerRadius(a);for(const t of v){const n=e[t.index],r=x.centroid({innerRadius:c,outerRadius:a,startAngle:t.startAngle,endAngle:t.endAngle});n.x=r[0]+l,n.y=r[1]+u,n.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const b=new Map;for(const t of e)b.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=b.get("string"==typeof e.source?e.source:e.source.id),r=b.get(t);n&&(e.source=n),r&&(e.target=r)}const k=new Map;for(const e of t)k.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of m){const n=e[t.source.index].id,r=e[t.target.index].id,o=k.get(`${n}\0${r}`)||k.get(`${r}\0${n}`);o&&(o.__chordData=t)}},buildScene(e,t,n,r){const{groupWidth:o=20,edgeOpacity:i=.5}=n,s=Math.min(r[0],r[1])/2,a=s-o,c=r[0]/2,l=r[1]/2,u=n.nodeStyle,h=n.edgeStyle,d=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Eu,y=new Map;e.forEach((e,t)=>{y.set(e.id,f[t%f.length])});const p=Du().radius(a),g=[],m=[],v=[];for(let t=0;e.length>t;t++){const n=e[t],r=n.__arcData;if(!r)continue;let o;o=u?u(pu(n,"nodeStyle")).fill||y.get(n.id)||f[t%f.length]:y.get(n.id)||f[t%f.length];const i=u?u(pu(n,"nodeStyle")):{};g.push({type:"arc",cx:c,cy:l,innerR:a,outerR:s,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:{fill:o,stroke:i.stroke||"black",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const r=p(t);if(!r)continue;const o=Wu(r,c,l);let s=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(h)s=h(pu(e,"edgeStyle")).fill||s;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===d&&n?s=y.get(n.id)||s:t&&(s=y.get(t.id)||s)}const a=h?h(pu(e,"edgeStyle")):{};m.push({type:"ribbon",pathD:o,style:{fill:s,fillOpacity:a.fillOpacity??i,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:e})}if(!1!==n.showLabels){const t=(x=n.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null,r=s+12;for(const n of e){const e=n.__arcData;if(!e)continue;const o=t?t(n):n.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,s=i-Math.PI/2;v.push({x:c+Math.cos(s)*r,y:l+Math.sin(s)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var x;return{sceneNodes:g,sceneEdges:m,labels:v}}};function Wu(e,t,n){const r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;const o=[];let i=0;for(;r.length>i;){const e=r[i];if("M"===e||"L"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("C"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;3>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("Q"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;2>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("A"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&(o.push(Number(r[i])+t+""),i++),r.length>i&&(o.push(Number(r[i])+n+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(r[i]),i++)}return o.join(" ")}import{hierarchy as $u,tree as zu,cluster as Ou,treemap as Fu,pack as Bu,partition as Yu,treemapBinary as ju}from"d3-hierarchy";var Hu=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Xu(e){const[t,n,r]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*r>150?"#222":"#fff"}function Gu(e,t,n){const r=t.nodeIDAccessor;return"function"==typeof r?r(e.data)+"":"string"==typeof r&&void 0!==e.data[r]?e.data[r]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function Vu(e){if(!e)return null;if("function"==typeof e){const t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function qu(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:Hu}function Uu(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:e.themeSemantic?.primary?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function Ku(e,t,n,r,o){if("horizontal"===o){const o=(e+n)/2;return`M ${e},${t} C ${o},${t} ${o},${r} ${n},${r}`}if("radial"===o){const o=(e+n)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+r)/2} T ${n},${r}`}{const o=(t+r)/2;return`M ${e},${t} C ${e},${o} ${n},${o} ${n},${r}`}}var Qu={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;if(!o)return;const i=n.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),a=n.hierarchySum,c="function"==typeof a?a:"string"==typeof a?e=>Number(e[a])||0:e=>Number(e.value)||0,l=$u(o,s);l.sum(c),l.sort((e,t)=>(t.value??0)-(e.value??0));const[u,h]=r;switch(i){case"tree":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=zu();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(l,n,u,h);break;case"cluster":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=Ou();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(l,n,u,h);break;case"treemap":!function(e,t,n,r){const o=t.padding??4,i=t.paddingTop??0,s=Fu().size([n,r]).tile(ju).padding(o);i>0&&s.paddingTop(i),s(e)}(l,n,u,h);break;case"circlepack":!function(e,t,n,r){const o=t.padding??4;Bu().size([n,r]).padding(o)(e)}(l,n,u,h);break;case"partition":!function(e,t,n,r){Yu().size([n,r]).padding(t.padding??1)(e)}(l,n,u,h)}const d=l.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;d.length>t;t++){const r=d[t],o={id:Gu(r,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:r.value??0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===i||"cluster"===i?Zu(o,r,n):"treemap"===i||"partition"===i?Ju(o,r):"circlepack"===i&&eh(o,r),o.__hierarchyNode=r,e.push(o),f.set(r,o)}if("tree"===i||"cluster"===i)for(const e of d)if(e.parent){const n=f.get(e.parent),r=f.get(e);n&&r&&t.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,r){const o=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,r,o,i){const s=[],a=[],c=[],l=n.treeOrientation||"vertical",u="radial"===l,h=r[0]/2,d=r[1]/2,f="number"==typeof(y=n.nodeSize)?y:5;var y;for(const t of e){let e=t.x,r=t.y;u&&(e+=h,r+=d);const i=o(pu(t,"nodeStyle"));let a=i.fill||Uu(n);if(n.colorByDepth&&void 0!==t.depth){const e=qu(n);a=e[t.depth%e.length]}s.push({type:"circle",cx:e,cy:r,r:f,style:{fill:a,stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:t,id:t.id,label:t.id,depth:t.depth})}const p=n.edgeOpacity??.5;for(const e of t){const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=t.x,s=t.y,c=r.x,f=r.y;u&&(o+=h,s+=d,c+=h,f+=d);const y=Ku(o,s,c,f,l),g=i(pu(e,"edgeStyle"));a.push({type:"curved",pathD:y,style:{fill:"none",stroke:g.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??p},datum:e})}if(!1!==n.showLabels){const t=Vu(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let r,o,i,s=n.x,a=n.y;if(u&&(s+=h,a+=d),u){const e=s-h,t=a-d,n=Math.sqrt(e*e+t*t);n>0?(r=s+e/n*10,o=a+t/n*10,i=0>e?"end":"start"):(r=s,o=a-12,i="middle")}else"horizontal"===l?(n.data?.children&&0!==n.data.children.length?(r=s-f-6,i="end"):(r=s+f+6,i="start"),o=a):(r=s,o=a+f+14,i="middle");c.push({x:r,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:c}}(e,t,n,r,o,i);case"treemap":case"partition":return function(e,t,n,r){const o=[],i=[];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=r(pu(n,"nodeStyle"));let a=s.fill||Uu(t);if(t.colorByDepth&&void 0!==n.depth){const e=qu(t);a=e[n.depth%e.length]}o.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:{fill:a,stroke:s.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Vu(t.nodeLabel),o=t.labelMode||"leaf",s="partition"===t.chartType;for(const a of e){const e=a.x1-a.x0,c=a.y1-a.y0;if(0>=e||0>=c)continue;const l=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===o&&!l)continue;if("parent"===o&&l)continue}const u=n?n(a):a.id;if(!u)continue;if((l?30:40)>e||(l?16:14)>c)continue;let h=r(pu(a,"nodeStyle")).fill||Uu(t);if(t.colorByDepth&&void 0!==a.depth){const e=qu(t);h=e[a.depth%e.length]}const d="string"==typeof h?Xu(h):t.themeSemantic?.text??"#000";i.push(l?{x:a.x0+e/2,y:a.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/6)),fill:d}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,n,0,o);case"circlepack":return function(e,t,n,r){const o=[],i=[];for(const n of e){const e=n.__radius??5;if(0>=e)continue;const i=r(pu(n,"nodeStyle"));let s=i.fill||Uu(t);if(t.colorByDepth&&void 0!==n.depth){const e=qu(t);s=e[n.depth%e.length]}o.push({type:"circle",cx:n.x,cy:n.y,r:e,style:{fill:s,stroke:i.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Vu(t.nodeLabel);for(const o of e){const e=o.__radius??5,s=n?n(o):o.id;if(!s)continue;if(15>e)continue;const a=!(o.data?.children&&o.data.children.length>0);let c=r(pu(o,"nodeStyle")).fill||Uu(t);if(t.colorByDepth&&void 0!==o.depth){const e=qu(t);c=e[o.depth%e.length]}if(a){const n="string"==typeof c?Xu(c):t.themeSemantic?.text??"#000";i.push({x:o.x,y:o.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else i.push({x:o.x,y:o.y-e+14,text:s+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Zu(e,t,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=t.x,r=t.y;e.x=r*Math.cos(n-Math.PI/2),e.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function Ju(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function eh(e,t){const n=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}import{pie as th}from"d3-shape";function nh(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var rh={sankey:vu,force:Cu,chord:Iu,tree:Qu,cluster:Qu,treemap:Qu,circlepack:Qu,partition:Qu,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;o&&function(e,t,n,r,o){const i=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),s=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(n.nodeIDAccessor),a=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),c=n.orbitSize??2.95,l=n.orbitEccentricity??1,u="number"==typeof c?()=>c:c,h="number"==typeof l?()=>l:l,d=nh(n);d.metaMap.clear(),r.length=0,o.length=0;const f=new Map;function y(e){const t=f.get(e)??0;return f.set(e,t+1),0===t?e:`${e}__${t}`}const p=t[0]/2,g=t[1]/2,m=Math.min(t[0],t[1])/2*.85,v=y(s(e));r.push({id:v,x:p,y:g,x0:p,x1:p,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:e}),d.metaMap.set(v,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,c,l,f,p,g){const m=i(t);if(!m?.length)return;const v=m.length;let x=0,b=0,k=0;for(;v>b;)b+=a[Math.min(k,a.length-1)],k++,x++;let w=0;for(let v=0;x>v;v++){const b=a[Math.min(v,a.length-1)],k=m.slice(w,w+b);if(!k.length)break;const A=(v+1)/x,S={id:n,depth:p,data:t,parentId:n},_=g?f/u(S)*A:f*A,M=th().value(e=>{const t=i(e)?.length;return t?4:1}).sort(null)(k),C=h(S);for(let t=0;k.length>t;t++){const i=(M[t].startAngle+M[t].endAngle)/2,a=k[t],u=y(s(a)),h=c+_*Math.sin(i),f=l+_*Math.cos(i)*C;r.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:p,data:a}),d.metaMap.set(u,{ring:_,angle:i,depth:p,parentId:n,eccentricity:C}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(a,u,h,f,_,p+1,!0)}w+=b}}(e,v,p,g,m,1,!1)}(o,r,n,e,t)},buildScene(e,t,n,r){const o=n.nodeStyle,i=n.nodeSize,s="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,a=[],c=[],l=[];if(!1!==n.orbitShowRings){const t=nh(n),r=new Map;for(const t of e)r.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=r.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;o.has(n)||o.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:r}]of o)for(let o=0;i>o;o++){const a=o/i*Math.PI*2,l=(o+1)/i*Math.PI*2;c.push({type:"line",x1:e+n*Math.sin(a),y1:t+n*Math.cos(a)*r,x2:e+n*Math.sin(l),y2:t+n*Math.cos(l)*r,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=s(pu(t,"nodeSize")),r=o?o(pu(t,"nodeStyle")):{};a.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:r.fill||n.themeSemantic?.primary||"#6366f1",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??(0===(t.depth??0)?1:.85)},datum:t,id:t.id,label:t.id,depth:t.depth})}const u=new Map;for(const t of e)u.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:u.get(e.source),n="object"==typeof e.target?e.target:u.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&c.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=s(pu(n,"nodeSize"));if(4>=e)continue;const r="function"==typeof t?t(n):t?n.data?.[t]??n.id:n.id;l.push({x:n.x,y:n.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:c,labels:l}},tick:(e,t,n,r,o)=>!1!==n.orbitAnimated&&(function(e,t){const n=nh(t),r=t.orbitSpeed??.25,o=t.orbitRevolution??function(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),i=(("undefined"!=typeof performance?performance.now():Date.now())-n.startTime)/1e3,s=r*(Math.PI/6),a=new Map;for(const t of e)a.set(t.id,t);for(const t of e){const e=n.metaMap.get(t.id);if(!e||!e.parentId)continue;const r=a.get(e.parentId);if(!r)continue;const c=e.angle+i*s*o({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(c),t.y=r.y+e.ring*Math.cos(c)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)}};function oh(e){return rh[e]}import{quadtree as ih}from"d3-quadtree";function sh(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function ah(e){if(!e||"object"!=typeof e)return!1;const t=e;if("boolean"!=typeof t.circular)return!1;if("number"!=typeof t.halfWidth||!Number.isFinite(t.halfWidth))return!1;if(t.circular){if(!Array.isArray(t.segments)||0===t.segments.length)return!1;for(const e of t.segments)if(!ch(e))return!1;return!0}return ch(t.points)}function ch(e){if(!Array.isArray(e)||4!==e.length)return!1;for(const t of e){if(!t||"object"!=typeof t)return!1;const e=t;if("number"!=typeof e.x||!Number.isFinite(e.x))return!1;if("number"!=typeof e.y||!Number.isFinite(e.y))return!1}return!0}import{interpolateNumber as lh}from"d3-interpolate";var uh="rgba(34, 197, 94, 0.7)",hh=2e3,dh=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],fh=["scene-style","data-paint","accessibility","evidence"],yh=(e,t)=>({retainedData:e,invalidations:t}),ph=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],gh=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],mh=["scene-geometry","data-paint","overlay","accessibility","evidence"],vh=["scene-style","data-paint","accessibility","evidence"],xh=["scene-geometry","data-paint","overlay","accessibility","evidence"],bh=[],kh={chartType:yh("rebuild",ph),nodeIDAccessor:yh("rebuild",ph),sourceAccessor:yh("rebuild",ph),targetAccessor:yh("rebuild",ph),valueAccessor:yh("rebuild",ph),edgeIdAccessor:yh("rebuild",ph),childrenAccessor:yh("rebuild",ph),hierarchySum:yh("rebuild",ph),orientation:yh("preserve",gh),nodeAlign:yh("preserve",gh),nodePaddingRatio:yh("preserve",gh),nodeWidth:yh("preserve",gh),edgeSort:yh("preserve",gh),iterations:yh("preserve",gh),forceStrength:yh("preserve",gh),padAngle:yh("preserve",gh),groupWidth:yh("preserve",gh),sortGroups:yh("preserve",gh),treeOrientation:yh("preserve",gh),edgeType:yh("preserve",gh),padding:yh("preserve",gh),paddingTop:yh("preserve",gh),orbitMode:yh("preserve",gh),orbitSize:yh("preserve",gh),orbitSpeed:yh("preserve",gh),orbitRevolution:yh("preserve",gh),orbitRevolutionStyle:yh("preserve",gh),orbitEccentricity:yh("preserve",gh),orbitShowRings:yh("preserve",gh),orbitAnimated:yh("preserve",gh),customNetworkLayout:yh("preserve",gh),layoutConfig:yh("preserve",gh),nodeSize:yh("preserve",mh),nodeSizeRange:yh("preserve",mh),colorByDepth:yh("preserve",mh),nodeLabel:yh("preserve",xh),showLabels:yh("preserve",xh),labelMode:yh("preserve",xh),nodeStyle:yh("preserve",vh),edgeStyle:yh("preserve",vh),colorBy:yh("preserve",vh),colorScheme:yh("preserve",vh),themeCategorical:yh("preserve",vh),themeSemantic:yh("preserve",vh),edgeColorBy:yh("preserve",vh),edgeOpacity:yh("preserve",vh),showParticles:yh("preserve",vh),particleStyle:yh("preserve",vh),decay:yh("preserve",vh),pulse:yh("preserve",vh),thresholds:yh("preserve",vh),staleness:yh("preserve",vh),layoutSelection:yh("preserve",vh),clock:yh("preserve",bh),random:yh("preserve",bh),seed:yh("preserve",bh),tensionConfig:yh("preserve",bh),transition:yh("preserve",bh),introAnimation:yh("preserve",bh),onLayoutError:yh("preserve",bh),__skipForceSimulation:yh("preserve",bh),__hierarchyRoot:yh("preserve",bh),__orbitState:yh("preserve",bh),__previousPositions:yh("preserve",bh)},wh=yh("preserve",gh),Ah=class{constructor(){this.tracker=new Bt}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},dh)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},fh):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const r of e){const e=kh[r]??wh;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}};function Sh(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&we(n,e)||"#4e79a7":t=>{if(n){const e=we(n,t);if(e)return e}let r=0;for(let e=0;t.length>e;e++)r=31*r+t.charCodeAt(e)|0;return e[Math.abs(r)%e.length]??"#4e79a7"}}var _h=class e{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this.customLayoutHtmlMarks=[],this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,this.particlePool=null,this.updateResults=new Ah,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this._decayAgeMap=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._networkDecayCache=null,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig={...hl,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new fl(2e3))}currentTime(){return this.config.clock?.()??Me()}updateConfig(e){const t=this.config,n={...t,...e};t.__orbitState&&(n.__orbitState=t.__orbitState),t.__hierarchyRoot&&(n.__hierarchyRoot=t.__hierarchyRoot),void 0===e.layoutSelection&&null!=t.layoutSelection&&(n.layoutSelection=t.layoutSelection);const r=[...new Set([...Object.keys(t),...Object.keys(n)])].filter(e=>t[e]!==n[e]);this.config=n,this.tensionConfig={...hl,...n.tensionConfig},!n.showParticles||"sankey"!==n.chartType&&!n.customNetworkLayout||this.particlePool||(this.particlePool=new fl(2e3)),this.updateResults.recordConfig(r)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null,this.updateResults.recordData("replace",1)}ingestBounded(e,t,n,r){const{nodeIDAccessor:o="id",sourceAccessor:i="source",targetAccessor:s="target",valueAccessor:a="value"}=this.config,c="function"==typeof o?o:e=>e[o],l="function"==typeof i?i:e=>e[i],u="function"==typeof s?s:e=>e[s],h="function"==typeof a?a:e=>e[a]??1;this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const t of e){const e=c(t)+"";this.nodes.set(e,{...sh(e),data:t})}for(let e=0;t.length>e;e++){const n=t[e],r=l(n)+"",o=u(n)+"",i=h(n),s=null==i?NaN:Number(i),a=Number.isFinite(s)?s:1;this.nodes.has(r)||this.nodes.set(r,{...sh(r),data:n}),this.nodes.has(o)||this.nodes.set(o,{...sh(o),data:n});const c=`${r}\0${o}\0${e}`,d={source:r,target:o,value:a,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:c};n&&"object"==typeof n&&ah(n.bezier)&&(d.bezier=n.bezier),this.edges.set(c,d)}r?.deferLayout||this.runLayout(n),this.updateResults.recordData("replace",e.length+t.length)}ingestBoundedWithResult(e,t,n,r){return this.ingestBounded(e,t,n,r),this.updateResults.last}applyForceLayoutPositions(e,t){for(const[t,n]of Object.entries(e)){const e=this.nodes.get(t);e&&(e.x=n.x,e.y=n.y)}this.config.__skipForceSimulation=!0;try{this.runLayout(t)}finally{this.config.__skipForceSimulation=void 0}}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:r}=e,o=0===this.nodes.size;let i=!1;const s=this.currentTime();this.lastIngestTime=s,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,sh(t)),this.nodeTimestamps.set(t,s),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(n)||(this.nodes.set(n,sh(n)),this.nodeTimestamps.set(n,s),this.tension+=this.tensionConfig.newNode,i=!0);const a=this.edgeKey(t,n),c=this.edges.get(a);let l=!1;c?(c.value+=r,this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.weightChange,l=!0):(this.edges.set(a,{source:t,target:n,value:r,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.newEdge,i=!0);const u=o||i||l||this.tension>=this.tensionConfig.threshold;return this.updateResults.recordData("ingest",1),u}ingestEdgeWithResult(e){return this.ingestEdge(e),this.updateResults.last}runLayout(e){if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const t=oh(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values());const r=Array.from(this.edges.values());if(0===n.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.supportsStreaming&&!t.hierarchical){const e=new Map;for(const t of n)void 0!==t._prevX0?e.set(t.id,{x:(t._prevX0??0)+((t._prevX1??0)-(t._prevX0??0))/2,y:(t._prevY0??0)+((t._prevY1??0)-(t._prevY0??0))/2}):0===t.x&&0===t.y||e.set(t.id,{x:t.x,y:t.y});if(this._lastPositionSnapshot)for(const[t,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(t.computeLayout(n,r,this.config,e),this.config.__previousPositions=void 0,t.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const e of n)this.nodes.set(e.id,e);for(let e=0;r.length>e;e++){const t=r[e],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const n=e.get(t.id);n&&(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,n=Array.from(this.nodes.values())}this.finalizeLayout();const o=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||o.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=o,this.saveTargetPositions();const i=n.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),s=this.config.transition?.duration??this.tensionConfig.transitionDuration,a=["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType);if(!this._hasRenderedOnce&&this.config.introAnimation&&a&&n.length>0&&s>0){const t=e[0]/2,n=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=n,e._prevY1=n;for(const e of this.edges.values())e._prevY0=n,e._prevY1=n,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:s}}else i&&s>0&&(this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:s});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime=this.currentTime()),this.previousNodeIds=e,this.previousEdgeKeys=t}restyleScene(e){const t=function({nodes:e,edges:t,restyle:n,restyleEdge:r,baseStyles:o,selection:i}){const s=!(!n&&!r);if(n)for(const t of e){const e=o.get(t)??t.style,r=n(t,i);t.style=r?{...e,...r}:e}if(r)for(const e of t){const t=o.get(e)??e.style,n=r(e,i);e.style=n?{...t,...n}:t}return s}({nodes:this.sceneNodes,edges:this.sceneEdges,restyle:this._customRestyle,restyleEdge:this._customRestyleEdge,baseStyles:this._baseStyles,selection:e});this.markStylePaintPending(),this.updateResults.recordRestyle(t)}buildScene(e){if(this.config.customNetworkLayout){const t=function({config:e,customLayout:t,size:n,nodes:r,edges:o,previousResult:i,revision:s}){const a=function(e,t,n){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=xe[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}(e.colorScheme,e.themeCategorical,ie),c={nodes:r,edges:o,dimensions:{width:n[0],height:n[1],plot:{x:0,y:0,width:n[0],height:n[1]}},theme:{semantic:e.themeSemantic??{},categorical:[...a]},resolveColor:Sh(a,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};try{return{kind:"success",result:t(c)}}catch(t){const n=null!==i,r=bt("network",t,n,s);"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t);try{e.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:r,preservedLastGoodScene:n}}}({config:this.config,customLayout:this.config.customNetworkLayout,size:e,nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values()),previousResult:this.lastCustomLayoutResult,revision:this.layoutVersion});if("failure"===t.kind)return this.lastCustomLayoutFailure=t.diagnostic,void(t.preservedLastGoodScene||(this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._sceneNodesRevision++));const n=t.result;return this.sceneNodes=n.sceneNodes??[],this.sceneEdges=n.sceneEdges??[],this.labels=n.labels??[],this.customLayoutOverlays=n.overlays??null,this.customLayoutHtmlMarks=n.htmlMarks??[],this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=n.restyle,this._customRestyleEdge=n.restyleEdge,this.hasCustomRestyle=!(!n.restyle&&!n.restyleEdge),this.hasCustomRestyle&&(this._baseStyles=function(e,t){const n=new WeakMap;for(const t of e)n.set(t,t.style);for(const e of t)n.set(e,e.style);return n}(this.sceneNodes,this.sceneEdges),this.restyleScene(this.config.layoutSelection??null)),void mt({label:"customNetworkLayout",nodes:this.sceneNodes,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned})}this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null;const t=oh(this.config.chartType);if(!t)return void this._sceneNodesRevision++;const n=t.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=t.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:o,sceneEdges:i,labels:s}=t.buildScene(n,r,this.config,e);this.sceneNodes=o,this.sceneEdges=i,this.labels=s,this._sceneNodesRevision++}rebuildNodeQuadtree(){let t=0,n=0;for(const e of this.sceneNodes)"circle"===e.type&&(t++,e.r>n&&(n=e.r));if(this._maxNodeRadius=n,e.QUADTREE_THRESHOLD>=t)return void(this._nodeQuadtree=null);const r=Array(t);let o=0;for(const e of this.sceneNodes)"circle"===e.type&&(r[o++]=e);this._nodeQuadtree=ih().x(e=>e.cx).y(e=>e.cy).addAll(r)}get nodeQuadtree(){return this._nodeQuadtreeRevision!==this._sceneNodesRevision&&(this.rebuildNodeQuadtree(),this._nodeQuadtreeRevision=this._sceneNodesRevision),this._nodeQuadtree}get maxNodeRadius(){return this._maxNodeRadius}_ensureArrays(){this._arrCacheVersion===this.layoutVersion&&this._nodesArrCache&&this._edgesArrCache||(this._nodesArrCache=Array.from(this.nodes.values()),this._edgesArrCache=Array.from(this.edges.values()),this._arrCacheVersion=this.layoutVersion)}get nodesArray(){return this._ensureArrays(),this._nodesArrCache}get edgesArray(){return this._ensureArrays(),this._edgesArrCache}get isAnimating(){const e=oh(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=oh(this.config.chartType);if(!n?.tick)return!1;const r=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(r,o,this.config,e,t)}cancelIntroAnimation(){this.transition=null;for(const e of this.nodes.values())e._prevX0=void 0,e._prevX1=void 0,e._prevY0=void 0,e._prevY1=void 0;for(const e of this.edges.values())e._prevY0=void 0,e._prevY1=void 0,e._prevSankeyWidth=void 0,e._introFromZero=!1}advanceTransition(e){if(!this.transition)return!1;const t=Se(e,this.transition),n=Ae(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=_e(e._prevX0,e._targetX0,n),e.x1=_e(e._prevX1,e._targetX1,n),e.y0=_e(e._prevY0,e._targetY0,n),e.y1=_e(e._prevY1,e._targetY1,n));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=_e(e._prevY0,e._targetY0,n),e.y1=_e(e._prevY1,e._targetY1,n),e.sankeyWidth=_e(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const n=e?.get(t.id);n&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const n=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(n){e._prevY0=n.y0,e._prevY1=n.y1,e._prevSankeyWidth=n.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){!function(e,t,n=.5){const r="string"==typeof e.source?t.get(e.source):e.source,o="string"==typeof e.target?t.get(e.target):e.target;!r||!o||(e.bezier=e.circular&&e.circularPathData?function(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),r=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-r,y:n.targetY},{x:n.targetX-.66*r,y:n.targetY},{x:n.targetX-.33*r,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let r;r="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const o=[];for(let e=0;r.length-1>e;e++){const t=r[e],n=r[e+1],i=n.x-t.x,s=n.y-t.y;o.push([t,{x:t.x+i/3,y:t.y+s/3},{x:t.x+2*i/3,y:t.y+2*s/3},n])}return{circular:!0,segments:o,halfWidth:t}}(e):function(e,t,n,r=.5){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,s=n.x0,a=lh(i,s);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:a(r)},{x:e.y1,y:a(1-r)},{x:e.y1,y:s}],halfWidth:o}}const i=t.x1,s=n.x0,a=lh(i,s);return{circular:!1,points:[{x:i,y:e.y0},{x:a(r),y:e.y0},{x:a(1-r),y:e.y1},{x:s,y:e.y1}],halfWidth:o}}(e,r,o,n))}(e,this.nodes,.5)}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){!function(e){const t=e.pulse;if(!t)return;const n=t.duration??500,r=t.color??"rgba(255,255,255,0.6)",o=t.glowRadius??4,{now:i}=e;for(const t of e.sceneNodes){const s=t.id;if(!s)continue;const a=e.nodeTimestamps.get(s);if(!a)continue;const c=i-a;n>c&&(t._pulseIntensity=1-c/n,t._pulseColor=r,t._pulseGlowRadius=o)}for(const t of e.sceneEdges){const o=t.datum;if(!o)continue;const s="object"==typeof o.source?o.source?.id:o.source,a="object"==typeof o.target?o.target?.id:o.target;if(!s||!a)continue;const c=e.edgeTimestamps.get(`${s}\0${a}`);if(!c)continue;const l=i-c;n>l&&(t._pulseIntensity=1-l/n,t._pulseColor=r)}}({sceneNodes:this.sceneNodes,sceneEdges:this.sceneEdges,nodeTimestamps:this.nodeTimestamps,edgeTimestamps:this.edgeTimestamps,pulse:this.config.pulse,now:e})}applyDecay(){this._networkDecayCache||(this._networkDecayCache={sortedNodes:null,ageMap:null}),this._decaySortedNodes||(this._networkDecayCache.sortedNodes=null,this._networkDecayCache.ageMap=null),function(e){const t=e.decay;if(!t)return;const n=e.nodeTimestamps.size;if(1>=n)return;if(!e.cache.sortedNodes){e.cache.sortedNodes=Array.from(e.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]);const t=new Map;for(let n=0;e.cache.sortedNodes.length>n;n++)t.set(e.cache.sortedNodes[n][0],n);e.cache.ageMap=t}const r=e.cache.ageMap;for(const o of e.sceneNodes){const e=o.id;if(!e)continue;const i=r.get(e);if(void 0===i)continue;const s=Ee(t,i,n);o.style={...o.style,opacity:(o.style?.opacity??1)*s}}}({sceneNodes:this.sceneNodes,nodeTimestamps:this.nodeTimestamps,decay:this.config.decay,cache:this._networkDecayCache}),this._decaySortedNodes=this._networkDecayCache.sortedNodes,this._decayAgeMap=this._networkDecayCache.ageMap}applyTopologyDiff(e){!function(e){for(const t of e.sceneNodes)t._pulseColor===uh&&(t._pulseIntensity=0,t._pulseColor=void 0,t._pulseGlowRadius=void 0);if(0===e.addedNodes.size)return;const t=e.now-e.lastTopologyChangeTime;if(t>=hh)return;const n=1-t/hh;for(const t of e.sceneNodes){const r=t.id;r&&e.addedNodes.has(r)&&(t._pulseIntensity=Math.max(t._pulseIntensity??0,n),t._pulseColor=uh,t._pulseGlowRadius=8)}}({sceneNodes:this.sceneNodes,addedNodes:this.addedNodes,lastTopologyChangeTime:this.lastTopologyChangeTime,now:e})}get hasActiveTopologyDiff(){return function(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){return 0!==e.size&&hh>n-t}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(e){!function(e){const t=e.thresholds;if(!t)return;const n=t.warningColor??"#f59e0b",r=t.criticalColor??"#ef4444",o=!1!==t.pulse;for(const i of e.sceneNodes){const s=i.id;if(!s)continue;const a=e.nodes.get(s);if(!a)continue;const c=t.metric(a);let l=null;void 0===t.critical||t.critical>c?void 0===t.warning||t.warning>c||(l=n):l=r,l&&(i.style={...i.style,fill:l},o&&(i._pulseIntensity=.6+.4*Math.sin(e.now/300),i._pulseColor=l,i._pulseGlowRadius=6))}}({sceneNodes:this.sceneNodes,nodes:this.nodes,thresholds:this.config.thresholds,now:e})}get hasActiveThresholds(){return function(e,t){if(!t)return!1;for(const n of e){const e=t.metric(n);if(void 0!==t.warning&&e>=t.warning||void 0!==t.critical&&e>=t.critical)return!0}return!1}(this.nodes.values(),this.config.thresholds)}get hasActivePulses(){return function(e){const t=e.pulse;if(!t||0===e.lastIngestTime)return!1;const n=e.now??("undefined"!=typeof performance?performance.now():Date.now());return(t.duration??500)>n-e.lastIngestTime}({pulse:this.config.pulse,lastIngestTime:this.lastIngestTime})}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){const n=this.nodes.get(e);if(!n)return this.updateResults.recordNoop("update"),null;const r=n.data?{...n.data}:{};return n.data=t(n.data??{}),this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",1),r}updateEdge(e,t,n){const r=this.config.valueAccessor,o="function"==typeof r?r:r?e=>e[r]:e=>e.value,i=[];for(const[,r]of this.edges)if(("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t){i.push(r.data?{...r.data}:{}),r.data=n(r.data??{});const e=o(r.data);null!=e&&(r.value=Number(e))}return i.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",i.length)):this.updateResults.recordNoop("update"),i}removeNode(e){if(!this.nodes.has(e))return this.updateResults.recordNoop("remove"),!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",1),!0}removeEdge(e,t){const n=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const r="function"==typeof t?t:e=>e?.[t];for(const[t,o]of this.edges)o.data&&r(o.data)===e&&n.push(t)}else for(const[r,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t&&n.push(r);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",n.length)):this.updateResults.recordNoop("remove"),n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this._decayAgeMap=null,this._nodeQuadtree=null,this._nodesArrCache=null,this._edgesArrCache=null,this._sceneNodesRevision++,this.tension=0,this.layoutVersion++,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.particlePool&&this.particlePool.clear(),this.updateResults.recordData("clear")}};_h.QUADTREE_THRESHOLD=500;var Mh=_h;$t(Mh);import*as Ch from"react";import{Fragment as Ph,jsx as Th,jsxs as Rh}from"react/jsx-runtime";function Nh(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,labels:s,title:a,legend:c,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d,legendPosition:f="right",legendLayout:y,foregroundGraphics:p,sceneNodes:g,annotations:m,onAnnotationActivate:v,onObservation:x,chartId:b,chartType:k,autoPlaceAnnotations:w,svgAnnotationRules:A}=e,S=Uo({onAnnotationActivate:v,onObservation:x,chartId:b,chartType:k}),_=Ch.useMemo(()=>{const e=(g||[]).flatMap(e=>{const t=function(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){const t=e.cx??e.x,n=e.cy??e.y;if("number"!=typeof t||"number"!=typeof n)return null;const r=Fn(e.glyph,e.size);return{x:t+r.centerDx,y:n+r.centerDy,r:Math.max(1,r.radius)}}const t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),n=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof n?null:{x:t,y:n,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,ft(e.size)):Math.max(1,e.w??0,e.h??0)/2}}(e),n=function(e){const t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}(e);return t?[{pointId:n,...t}]:[]});return{scales:null,width:t,height:n,frameType:"network",pointNodes:e,sceneNodes:g}},[n,g,t]),M=Ch.useMemo(()=>m&&w?_i({annotations:m,context:_,..."object"==typeof w?w:{}}):m,[m,w,_]),C=Ch.useMemo(()=>si(),[]),P=M?ii(M.filter(e=>"widget"!==e.type),C,A,_):null,T=!0===M?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return Rh(Ph,{children:[T&&Th("style",{children:Bo},"annotation-widget-disclosure-style"),Rh("svg",{role:"img",width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[Th("title",{children:"string"==typeof a?a:"Network Chart"}),Th("desc",{children:"string"==typeof a?a+" — network data visualization":"Network data visualization"}),Rh("g",{transform:`translate(${i.left},${i.top})`,children:[s.map((e,t)=>Th("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+t)),P,p]}),a&&"string"==typeof a?Th("text",{x:r/2,y:22,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:a}):a?Th("foreignObject",{x:0,y:0,width:r,height:i.top,children:a}):null,to({legend:c,totalWidth:r,totalHeight:o,margin:i,legendPosition:f,title:a,legendLayout:y,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:h,legendIsolatedCategories:d})]}),M?.filter(e=>"widget"===e.type&&e.nodeId&&g).map((e,t)=>{const n=!0===e._annotationDeferred,r=g.find(t=>t.id===e.nodeId||t.datum?.id===e.nodeId||t.datum?.data?.id===e.nodeId||t.datum?.data?.name===e.nodeId);if(!r)return null;const o=i.left+(r.cx??(null!=r.x&&null!=r.w?r.x+r.w/2:r.x??0)),s=i.top+(r.cy??(null!=r.y&&null!=r.h?r.y+r.h/2:r.y??0)),a=e.dx??0,c=e.dy??-16,l=e.width??32,u=e.height??32,h=e.content??Th("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return Th("div",{...Ko(e,S),className:n?"annotation-deferred":void 0,"data-annotation-disclosure":n?"deferred":void 0,style:{position:"absolute",left:o+a-l/2,top:s+c-u/2,width:l,height:u,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:h},"widget-"+t)})]})}Nh.displayName="NetworkSVGOverlay";import*as Dh from"react";import{jsx as Lh}from"react/jsx-runtime";var Eh={position:"absolute",top:0,left:0,pointerEvents:"none"};function Ih({marks:e,margin:t,selection:n=null,overscan:r=400}){const o=Dh.useRef(null),i=function(e,t,n){const[r,o]=Dh.useState(null);return Dh.useLayoutEffect(()=>{const e=t.current,n=function(e){let t=e?.parentElement??null;for(;t;){const{overflow:e,overflowX:n,overflowY:r}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(`${e} ${r} ${n}`))return t;t=t.parentElement}return null}(e);if(!e||!n)return void o(null);let r=0;const i=()=>{r=0;const t=n.getBoundingClientRect(),i=e.getBoundingClientRect();o(0!==t.width&&0!==t.height?{scroll:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},originX:i.left,originY:i.top}:null)},s=()=>{0===r&&(r=window.requestAnimationFrame(i))};i(),n.addEventListener("scroll",s,{passive:!0});const a=new ResizeObserver(s);return a.observe(n),()=>{0!==r&&window.cancelAnimationFrame(r),n.removeEventListener("scroll",s),a.disconnect()}},[t,e,n]),Dh.useMemo(()=>{if(!e||!r)return e;const{scroll:t,originX:o,originY:i}=r,s=t.left-n,a=t.right+n,c=t.top-n,l=t.bottom+n;return e.filter(e=>{const t=o+e.x,n=i+e.y;return!(s>t+e.width||t>a||c>n+e.height||n>l)})},[e,r,n])}(e,o,r);if(!e||0===e.length)return null;const s=Lh("div",{className:"semiotic-network-html-marks",ref:o,style:{...Eh,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>Lh("div",{className:"semiotic-network-html-mark","data-mark-id":e.id,style:{position:"absolute",transform:`translate(${e.x}px, ${e.y}px)`,width:e.width,height:e.height,pointerEvents:"none"},children:e.content},e.id))});return null!=n?Lh(wn,{value:n,children:s}):s}import{jsx as Wh,jsxs as $h}from"react/jsx-runtime";function zh({props:e,store:t,responsiveRef:n,size:r,margin:o,adjustedWidth:i,adjustedHeight:s,resolvedBackground:a,resolvedForeground:c}){const{chartType:l,nodes:u,edges:h,data:d,className:f,description:y,title:p,responsiveWidth:g,responsiveHeight:m,summary:v,background:x,renderMode:b,legend:k,legendPosition:w,legendLayout:A,legendHoverBehavior:S,legendClickBehavior:M,legendHighlightedCategory:C,legendIsolatedCategories:P,layoutSelection:T,annotations:R,onAnnotationActivate:N,annotationObservationCallback:D,onObservation:L,chartId:E,autoPlaceAnnotations:I,svgAnnotationRules:W}=e;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(l),n=e?d||(Array.isArray(h)?void 0:h):void 0;if(e&&n)t.ingestHierarchy(n,[i,s]),t.buildScene([i,s]);else{const e=_(u),n=Array.isArray(h)?_(h):[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[i,s]),t.buildScene([i,s]))}}const $=t?.sceneNodes??[],z=t?.sceneEdges??[],O=t?.labels??[];return $h("div",{ref:n,className:"stream-network-frame"+(f?" "+f:""),role:"img","aria-label":y||("string"==typeof p?p:"Network chart"),style:{position:"relative",width:g?"100%":r[0],height:m?"100%":r[1]},children:[Wh(ea,{summary:v}),$h("svg",{xmlns:"http://www.w3.org/2000/svg",width:r[0],height:r[1],style:{position:"absolute",left:0,top:0},children:[a&&Wh("g",{transform:`translate(${o.left},${o.top})`,children:a}),$h("g",{transform:`translate(${o.left},${o.top})`,children:[x&&Wh("rect",{x:0,y:0,width:i,height:s,fill:x}),z.map((e,t)=>Rc({node:e,index:t,renderMode:b,fallback:()=>function(e,t){switch(e.type){case"line":return Ji("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+t);case"bezier":{const n=e;return Ji("path",{d:n.pathD,fill:ns(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"ribbon":{const n=e;return Ji("path",{d:n.pathD,fill:ns(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"curved":{const n=e;return Ji("path",{d:n.pathD,fill:ns(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+t)}default:return null}}(e,t)})).filter(Boolean),$.map((e,t)=>Rc({node:e,index:t,renderMode:b,fallback:()=>function(e,t){switch(e.type){case"circle":{const n=e,r=Jn(n.style.fill)?nr(n.style.fill,`net-circle-${t}-hatch`):void 0;return es(Ki.Fragment,{children:[r&&Ji("defs",{children:r}),Ji("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:r?`url(#net-circle-${t}-hatch)`:ns(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-circle-"+t)}case"rect":{const n=e,r=Jn(n.style.fill)?nr(n.style.fill,`net-rect-${t}-hatch`):void 0;return es(Ki.Fragment,{children:[r&&Ji("defs",{children:r}),Ji("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:r?`url(#net-rect-${t}-hatch)`:ns(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-rect-"+t)}case"arc":{const n=e,r=Qi().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(ts)||"",o=Jn(n.style.fill)?nr(n.style.fill,`net-arc-${t}-hatch`):void 0;return es(Ki.Fragment,{children:[o&&Ji("defs",{children:o}),Ji("path",{d:r,transform:`translate(${n.cx},${n.cy})`,fill:o?`url(#net-arc-${t}-hatch)`:ns(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-arc-"+t)}case"symbol":{const n=e,r=dt(n.symbolType,n.size,n.path);return Ji("path",{d:r,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?ns(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return rs(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)})).filter(Boolean),O.map((e,t)=>function(e,t){return Ji("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+t)}(e,t)).filter(Boolean)]})]}),Wh(Nh,{width:i,height:s,totalWidth:r[0],totalHeight:r[1],margin:o,labels:O,sceneNodes:$,title:p,legend:k,legendPosition:w,legendLayout:A,legendHoverBehavior:S,legendClickBehavior:M,legendHighlightedCategory:C,legendIsolatedCategories:P,foregroundGraphics:vn(c,An(t?.customLayoutOverlays,T??null)),annotations:R,onAnnotationActivate:N,onObservation:D??L,chartId:E,chartType:"StreamNetworkFrame",autoPlaceAnnotations:I,svgAnnotationRules:W,annotationFrame:0}),Wh(Ih,{marks:t?.customLayoutHtmlMarks,margin:o,selection:T??null})]})}import{jsx as Oh}from"react/jsx-runtime";"undefined"!=typeof process&&process;var Fh={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"},Bh={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Yh(e,t,n,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?Oh("div",{style:{...Fh,width:t,height:n},children:r||"No data available"}):null}function jh(e,t,n,r){if(!e)return null;if(!1===r)return null;if(null!=r)return Oh("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const o=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*o))),s=Math.max(6,Math.floor(n/(2.5*o))),a=Math.floor((n-(o*(i+s)-s))/2);return Oh("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:o},(e,n)=>Oh("div",{className:"semiotic-loading-bar",style:{...Bh,position:"absolute",top:a+n*(i+s),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2}},n))})}function Hh(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function Xh(){if("undefined"!=typeof DOMException)return new DOMException("Force layout aborted","AbortError");const e=Error("Force layout aborted");return e.name="AbortError",e}var Gh=class{constructor(e=function(){const e="string"==typeof import.meta.url&&import.meta.url?new URL("./forceLayoutWorker.js",import.meta.url):function(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:"/"+t;return new URL("./"+e,"file:"+n)}throw Error("Cannot resolve module worker asset: "+e)}("forceLayoutWorker.js");return new Worker(e,{type:"module",name:"semiotic-force-layout"})}()){this.nextRequestId=1,this.pending=new Map,this.dead=!1,this.worker=e,this.worker.onmessage=e=>{const t=e.data,n=t.requestId,r=null!=n?this.pending.get(n):this.pending.values().next().value;if(r){if(null!=n?this.pending.delete(n):this.pending.clear(),r.cleanup(),t.error){const e=Error(t.error.message);return e.name=t.error.name??"Error",t.error.stack&&(e.stack=t.error.stack),void r.reject(e)}r.resolve({positions:t.positions??{}})}},this.worker.onerror=e=>{this.rejectAll(Error(e.message||"Force layout worker failed")),this.terminate()}}get isDead(){return this.dead}request(e,t){if(this.dead)return Promise.reject(Error("Force layout worker session is closed"));if(t?.aborted)return Promise.reject(Xh());const n=this.nextRequestId;this.nextRequestId+=1;const r={requestId:n,request:e};return new Promise((e,o)=>{const i=()=>{this.pending.delete(n),t?.removeEventListener("abort",i),o(Xh())},s=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:s,reject:o,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(r)}catch(e){this.pending.delete(n),s(),o(e instanceof Error?e:Error(e+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error("Force layout worker terminated")),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}},Vh=null;import{jsx as qh,jsxs as Uh}from"react/jsx-runtime";var Kh=/^(value|amount|total|count|weight|score)$/i;function Qh({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?Uh("div",{className:"semiotic-tooltip",style:ma,children:[Uh("div",{style:{fontWeight:600},children:["object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target]}),null!=t.value&&Uh("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]})]}):null}const t=e.data;if(!t)return null;const n=t.__hierarchyNode;if(n){const e=[];let r=n;for(;r;){const n=r.data?.name??r.data?.id??t.id;null!=n&&e.unshift(n+""),r=r.parent}e.length>1&&e.shift();const o=e.length-1;return Uh("div",{className:"semiotic-tooltip",style:ma,children:[qh("div",{children:e.map((e,t)=>Uh("span",{children:[t>0&&qh("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===o?qh("strong",{children:e}):qh("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&qh("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof t.value?t.value.toLocaleString():t.value+""})]})}const r=(t.sourceLinks?.length||0)+(t.targetLinks?.length||0),o=(t.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(t.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0),i=ya(t.data??t),s=null!=i.title?i.title+"":t.id,a=i.entries.some(e=>Kh.test(e.key));return Uh("div",{className:"semiotic-tooltip",style:ma,children:[qh("div",{style:{fontWeight:600},children:s}),i.entries.map(e=>{return Uh("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",(t=e.value,null==t?"–":"number"==typeof t?Math.abs(t)>9999?t.toLocaleString():t+"":t instanceof Date?t.toLocaleDateString():t+"")]},e.key);var t}),!a&&null!=t.value&&t.value>0&&Uh("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),r>0&&Uh("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",r,o!==r&&` (weighted: ${o.toLocaleString()})`]})]})}function Zh(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function Jh(e,t){if(!t.pathD)return;e.save();const n=Zh(t);if(t.style.fill&&"none"!==t.style.fill){const r=t._gradient;if(r){const n=e.createLinearGradient(r.x0,0,r.x1,0),o=t.style.fillOpacity??t.style.opacity??.5,i="string"==typeof t.style.fill?t.style.fill:"#999",s=Un(e,i)||i;n.addColorStop(0,1===r.from?s:"transparent"),n.addColorStop(1,1===r.to?s:"transparent"),e.fillStyle=n,e.globalAlpha=o}else e.fillStyle=yr(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5;e.fill(n)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.5*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(n)),e.restore()}function ed(e,t){e.save();const n=t.style.stroke||"#999";e.strokeStyle=Un(e,n)||n,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(t.style.strokeWidth??1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function td(e,t){if(!t.pathD)return;e.save();const n=Zh(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=yr(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5,e.fill(n)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.3*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(n)),e.restore()}function nd(e,t){if(!t.pathD)return;e.save();const n=Zh(t),r=t.style.stroke||"#999";e.strokeStyle=Un(e,r)||r,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(n),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=yr(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??.1,e.fill(n)),e.restore()}Qh.ownsChrome=!0;var rd=new Map;function od(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=rd.get(t);return n||(n=new Path2D(dt(e.symbolType,e.size)),rd.size>256&&rd.clear(),rd.set(t,n)),n}catch{return null}}function id(e){const{sceneNodes:t,nodes:n,nodeColorMap:r,colorScheme:o}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&r.set(e.id,e.style.fill);const i=Array.isArray(o)?o:be,s=Array.from(n);for(let e=0;s.length>e;e++){const t=s[e];r.has(t.id)||r.set(t.id,i[e%i.length])}return s.length}function sd(e,t,n,r=30){switch(e.type){case"circle":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,s=Math.sqrt(o*o+i*i);return s>Tn(e.r,r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,n,r);case"rect":return function(e,t,n){const r=Pn(t,n,e);return r.hit?{type:"node",datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const r=t-e.cx,o=n-e.cy,i=Math.sqrt(r*r+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const s=Dn(Math.atan2(o,r)),a=Dn(e.startAngle),c=Dn(e.endAngle);if(a>c?s>=a||c>=s:s>=a&&c>=s){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);case"symbol":return function(e,t,n,r=30){const o=t-e.cx,i=n-e.cy,s=Math.sqrt(o*o+i*i);return s>Tn(ft(e.size),r)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,n,r);case"glyph":return function(e,t,n,r=30){if(null==e.datum)return null;const o=Fn(e.glyph,e.size),i=e.cx+o.centerDx,s=e.cy+o.centerDy,a=t-i,c=n-s,l=Math.sqrt(a*a+c*c);return l>Tn(o.radius,r)?null:{type:"node",datum:e.datum,x:i,y:s,distance:l}}(e,t,n,r);default:return null}}var ad=null,cd=null;function ld(){return cd||((ad=document.createElement("canvas")).width=1,ad.height=1,cd=ad.getContext("2d")),cd}function ud(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch{return null}}function hd(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const r=ud(e),o=ld();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const s=o.isPointInStroke(r,t,n);if(o.lineWidth=i,s)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);case"line":return function(e,t,n){const r=e.x2-e.x1,o=e.y2-e.y1,i=r*r+o*o;if(0===i)return null;let s=((t-e.x1)*r+(n-e.y1)*o)/i;s=Math.max(0,Math.min(1,s));const a=e.x1+s*r,c=e.y1+s*o,l=Math.sqrt((t-a)**2+(n-c)**2);return l>5?null:{type:"edge",datum:e.datum,x:a,y:c,distance:l}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const r=ud(e),o=ld();if(!r||!o)return null;try{if(o.isPointInPath(r,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const i=o.lineWidth;o.lineWidth=10;const s=o.isPointInStroke(r,t,n);if(o.lineWidth=i,s)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);default:return null}}function dd(e){const{clientX:t,clientY:n,canvasRect:r,margin:o,adjustedWidth:i,adjustedHeight:s,sceneNodes:a,sceneEdges:c,nodeQuadtree:l,maxNodeRadius:u,hitRadius:h=30}=e,d=t-r.left-o.left,f=n-r.top-o.top;if(0>d||d>i||0>f||f>s)return{kind:"miss-outside"};const y=function(e,t,n,r,o=30,i,s=0){let a=null,c=o,l=1/0;if(i){const e=Yn(i,n,r,o,s,e=>e.cx,e=>e.cy,e=>e.r);e&&(a={type:"node",datum:e.node.datum,x:e.node.cx,y:e.node.cy,distance:e.distance},c=e.distance)}for(const t of e){if(i&&"circle"===t.type)continue;const e=sd(t,n,r,o);if(e)if("rect"===t.type){const n=t.w*t.h;l>n&&(a=e,l=n)}else c>e.distance&&(a=e,c=e.distance)}if(a)return a;for(const e of t){if(!1===e.interactive)continue;const t=hd(e,n,r);t&&c>t.distance&&(a=t,c=t.distance)}return a}(a,c,d,f,h,l,u);return y?{kind:"hit",hover:ca(y.datum||{},y.x,y.y,{nodeOrEdge:y.type})}:{kind:"miss"}}import{useCallback as fd}from"react";var yd="StreamNetworkFrame";import{jsx as pd,jsxs as gd}from"react/jsx-runtime";var md={top:20,right:80,bottom:20,left:80},vd={top:40,right:40,bottom:40,left:40},xd=new Set(["chord","force","circlepack","orbit"]),bd=[800,600],kd=ul(ll(function(e,t){const{chartType:n,nodes:r,edges:o,data:i,initialEdges:s,nodeIDAccessor:a="id",sourceAccessor:c="source",targetAccessor:l="target",valueAccessor:u="value",edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y="horizontal",nodeAlign:p="justify",nodePaddingRatio:g=.05,nodeWidth:m=15,iterations:v=300,forceStrength:x=.1,layoutExecution:b="auto",layoutLoadingContent:k,onLayoutStateChange:w,padAngle:A=.01,groupWidth:S=20,sortGroups:M,edgeSort:C,treeOrientation:P="vertical",edgeType:T="curve",padding:R,paddingTop:N,tensionConfig:D,showParticles:L=!1,particleStyle:E,renderMode:I,nodeStyle:$,edgeStyle:z,colorBy:O,colorScheme:F="category10",edgeColorBy:B="source",edgeOpacity:Y=.5,colorByDepth:j=!1,nodeSize:H=8,nodeSizeRange:X=[5,20],nodeLabel:G,showLabels:V=!0,labelMode:q,size:U=bd,responsiveWidth:K,responsiveHeight:Q,margin:Z,className:J,background:ee,enableHover:te=!0,tooltipContent:ne,customHoverBehavior:re,customClickBehavior:oe,onObservation:ie,annotationObservationCallback:se,chartId:ae,onTopologyChange:ce,annotations:le,onAnnotationActivate:ue,autoPlaceAnnotations:he,svgAnnotationRules:de,legend:fe,legendPosition:ye,legendLayout:pe,legendHoverBehavior:ge,legendClickBehavior:me,legendHighlightedCategory:ve,legendIsolatedCategories:xe,title:ke,foregroundGraphics:we,backgroundGraphics:Ae,decay:Se,pulse:_e,transition:Me,animate:Ce,staleness:Pe,frameScheduler:Te,clock:Re,random:Ne,seed:De,paused:Le=!1,suspendWhenHidden:Ee=!0,thresholds:Ie,accessibleTable:We=!0,description:$e,summary:ze,orbitMode:Oe,orbitSize:Fe,orbitSpeed:Be,orbitRevolution:Ye,orbitRevolutionStyle:je,orbitEccentricity:He,orbitShowRings:Xe,orbitAnimated:Ge,customNetworkLayout:Ve,onLayoutError:qe,layoutConfig:Ue,layoutSelection:Ke}=e,Qe=xd.has(n)?vd:md,Ze=rl(!0),Je=za({sizeProp:U,responsiveWidth:K,responsiveHeight:Q,userMargin:Z,marginDefault:Qe,title:ke,legend:fe,legendPosition:ye,foregroundGraphics:we,backgroundGraphics:Ae,animate:Ce,transitionProp:Me,frameScheduler:Te,clock:Re,random:Ne,seed:De,paused:Le,suspendWhenHidden:Ee,themeDirtyRef:Ze}),{reducedMotionRef:et,responsiveRef:tt,size:nt,margin:rt,adjustedWidth:ot,adjustedHeight:it,resolvedForeground:st,resolvedBackground:at,transition:ct,introEnabled:lt,tableId:ut,rafRef:ht,renderFnRef:dt,scheduleRender:ft,frameRuntime:yt,currentTheme:pt}=Je,gt=hs(),mt=ps(),vt=sl(()=>_(r),[r]),xt=sl(()=>Array.isArray(o)?_(o):o,[o]),bt=sl(()=>({...hl,...D}),[D]),kt=sl(()=>({...dl,...E}),[E]),wt=sl(()=>{return{chartType:(e={chartType:n,clock:yt.now,random:Ne,seed:De,nodeIDAccessor:a,sourceAccessor:c,targetAccessor:l,valueAccessor:u,edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y,nodeAlign:p,nodePaddingRatio:g,nodeWidth:m,iterations:v,forceStrength:x,padAngle:A,groupWidth:S,sortGroups:M,edgeSort:C,treeOrientation:P,edgeType:T,padding:R,paddingTop:N,tensionConfig:bt,showParticles:L,particleStyle:kt,nodeStyle:$,edgeStyle:z,nodeLabel:G,showLabels:V,labelMode:q,colorBy:O,colorScheme:F,edgeColorBy:B,edgeOpacity:Y,colorByDepth:j,nodeSize:H,nodeSizeRange:X,decay:Se,pulse:_e,transition:ct,introAnimation:lt,staleness:Pe,thresholds:Ie,orbitMode:Oe,orbitSize:Fe,orbitSpeed:Be,orbitRevolution:Ye,orbitRevolutionStyle:je,orbitEccentricity:He,orbitShowRings:Xe,orbitAnimated:Ge,customNetworkLayout:Ve,onLayoutError:qe,layoutConfig:Ue,currentTheme:pt}).chartType,clock:e.clock,random:e.random,seed:e.seed,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,edgeIdAccessor:e.edgeIdAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,tensionConfig:e.tensionConfig,showParticles:e.showParticles,particleStyle:e.particleStyle,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme,themeCategorical:e.currentTheme?.colors?.categorical,themeSemantic:W(e.currentTheme),edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,decay:e.decay,pulse:e.pulse,transition:e.transition,introAnimation:e.introAnimation,staleness:e.staleness,thresholds:e.thresholds,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:e.orbitAnimated,customNetworkLayout:e.customNetworkLayout,onLayoutError:e.onLayoutError,layoutConfig:e.layoutConfig};var e},[n,yt.now,Ne,De,a,c,l,u,h,d,f,y,p,g,m,v,x,A,S,M,C,P,T,R,N,bt,L,kt,$,z,G,V,q,O,F,B,Y,j,H,X,Se,_e,ct,lt,Pe,Ie,Oe,Fe,Be,Ye,je,He,Xe,Ge,Ve,qe,Ue,pt]),At=ms(wt),St=ms({chartType:(_t={chartType:n,nodeIDAccessor:a,sourceAccessor:c,targetAccessor:l,valueAccessor:u,edgeIdAccessor:h,childrenAccessor:d,hierarchySum:f,orientation:y,nodeAlign:p,nodePaddingRatio:g,nodeWidth:m,iterations:v,forceStrength:x,padAngle:A,groupWidth:S,sortGroups:M,edgeSort:C,treeOrientation:P,edgeType:T,padding:R,paddingTop:N,random:Ne,seed:De,tensionConfig:bt,customNetworkLayout:Ve,orbitMode:Oe,orbitSize:Fe,orbitEccentricity:He}).chartType,nodeIDAccessor:_t.nodeIDAccessor,sourceAccessor:_t.sourceAccessor,targetAccessor:_t.targetAccessor,valueAccessor:_t.valueAccessor,edgeIdAccessor:_t.edgeIdAccessor,childrenAccessor:_t.childrenAccessor,hierarchySum:_t.hierarchySum,orientation:_t.orientation,nodeAlign:_t.nodeAlign,nodePaddingRatio:_t.nodePaddingRatio,nodeWidth:_t.nodeWidth,iterations:_t.iterations,forceStrength:_t.forceStrength,padAngle:_t.padAngle,groupWidth:_t.groupWidth,sortGroups:_t.sortGroups,edgeSort:_t.edgeSort,treeOrientation:_t.treeOrientation,edgeType:_t.edgeType,padding:_t.padding,paddingTop:_t.paddingTop,random:_t.random,seed:_t.seed,tensionConfig:_t.tensionConfig,customNetworkLayout:_t.customNetworkLayout,orbitMode:_t.orbitMode,orbitSize:_t.orbitSize,orbitEccentricity:_t.orbitEccentricity});var _t;const Mt=rl(0),Ct=rl(0),Pt=rl(!1),Tt=rl(null);Tt.current||(Tt.current=new Mh(At));const Rt=pn("StreamNetworkFrame"),Nt=al((e,t,n=!1)=>function(e,t,n,r=!1,o=!1){const i=e.beforeCompute(t.getLastUpdateResult(),r);n(),e.afterCompute(i,!0,o)}(Rt.current,e,()=>e.buildScene(t),n),[Rt]),[Dt,Lt]=ol(null),[Et,It]=ol(0),[Wt,$t]=ol(0),[zt,Ot]=ol(!1),[Ft,Bt]=ol(!1),Yt=rl(0),jt=rl(null),Ht=rl(!1),Xt=rl(w);Xt.current=w;const Gt=rl(At);Gt.current=At;const Vt=rl(null),qt=rl(new Map),Ut=rl(0),Kt=al(e=>function(e){const{node:t,colorBy:n,colorScheme:r,nodeColorMap:o,colorIndexRef:i}=e;if("function"==typeof n)return n(t)+"";if("string"==typeof n&&t.data){const e=t.data[n];if(void 0!==e){if(!o.has(e+"")){const t=Array.isArray(r)?r:be;o.set(e+"",t[i.current++%t.length])}return o.get(e+"")}}if(o.has(t.id))return o.get(t.id);const s=Array.isArray(r)?r:be,a=n?s[i.current++%s.length]:s[0];return o.set(t.id,a),a}({node:e,colorBy:O,colorScheme:F,nodeColorMap:qt.current,colorIndexRef:Ut}),[O,F]),Qt=(Zt=pt,Zt?.colors?.border||Zt?.colors?.secondary||Zt?.colors?.primary||"#999");var Zt;const Jt=al(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,Tt.current?.nodes),[]),en=al(e=>function(e){const{edge:t,edgeColorBy:n,getNodeColor:r,resolveEndpoint:o,fallback:i}=e;if("function"==typeof n)return n(t);const s=o(t.source),a=o(t.target);return"target"===n&&a?r(a):s?r(s):i}({edge:e,edgeColorBy:B,getNodeColor:Kt,resolveEndpoint:Jt,fallback:Qt}),[B,Kt,Qt,Jt]),tn=al(e=>function(e){const{edge:t,particleStyleColor:n,particleColorBy:r,hasExplicitParticleColorBy:o,getEdgeColor:i,getNodeColor:s,resolveEndpoint:a,fallback:c}=e;if("function"==typeof n){const e=a(t.source);return e?n(t,e):c}if(!o)return i(t);const l=r,u=a(t.source),h=a(t.target);return"target"===l&&h?s(h):u?s(u):c}({edge:e,particleStyleColor:kt.color,particleColorBy:kt.colorBy,hasExplicitParticleColorBy:!!E?.colorBy,getEdgeColor:en,getNodeColor:Kt,resolveEndpoint:Jt,fallback:Qt}),[E?.colorBy,kt.color,kt.colorBy,Kt,en,Qt,Jt]),nn=function(e,t,n,r,o){return("sankey"===e||t)&&n||r||o}(n,!!Ve,L,!!_e,Tt.current?.isAnimating??!1);Mn(Tt,At,Ze,ft),Cn(Tt,Ke,Ze,ft),il(()=>{const e=Tt.current;e&&(Nt(e,[ot,it]),Ut.current=id({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:qt.current,colorScheme:F}),Ze.current=!0,ft())},[pt,ot,it,Nt,ft,F]);const rn=al(()=>{const e=Tt.current;if(e&&(e.runLayout([ot,it]),Nt(e,[ot,it]),Ze.current=!0,Ut.current=id({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:qt.current,colorScheme:F}),It(e.layoutVersion),ce)){const{nodes:t,edges:n}=e.getLayoutData();ce(t,n)}},[ot,it,Nt,ce,F]),on=al(e=>{if(null==e||"object"!=typeof e)return;const t=Tt.current;t&&(t.ingestEdge(e)&&rn(),ft())},[rn,ft]),sn=al(e=>{const t=Tt.current;if(!t)return;let n=!1;for(const r of e)null!=r&&"object"==typeof r&&t.ingestEdge(r)&&(n=!0);n&&rn(),ft()},[rn,ft]),an=al(()=>{Tt.current?.clear(),qt.current.clear(),Ut.current=0,It(Tt.current?.layoutVersion??0),Lt(null),Vt.current=null,Ze.current=!0,ft()},[ft]),cn=al(()=>{const e=Tt.current;e&&(e.tension+=999,rn(),ft())},[rn,ft]);cl(t,()=>({push:on,pushMany:sn,removeNode:e=>{const t=Tt.current?.removeNode(e)??!1;if(t){const t=Vt.current?.data?"function"==typeof a?a(Vt.current.data):Vt.current.data[a]:void 0;Vt.current&&"node"===Vt.current.nodeOrEdge&&t===e&&(Vt.current=null,Lt(null)),qt.current.delete(e),rn(),Ze.current=!0,ft()}return t},removeEdge:(e,t)=>{const n=Tt.current?.removeEdge(e,t)??!1;if(n){if(Vt.current&&"edge"===Vt.current.nodeOrEdge){const n=Vt.current.data;let r;r=void 0!==t?("object"==typeof n?.source?n.source.id:n?.source)===e&&("object"==typeof n?.target?n.target.id:n?.target)===t:!h||!n||("function"==typeof h?h:e=>e?.[h])(n)===e,r&&(Vt.current=null,Lt(null))}rn(),Ze.current=!0,ft()}return n},updateNode:(e,t)=>{const n=Tt.current?.updateNode(e,t)??null;return n&&(Ze.current=!0,ft()),n},updateEdge:(e,t,n)=>{const r=Tt.current?.updateEdge(e,t,n)??[];return r.length>0&&(rn(),Ze.current=!0,ft()),r},clear:an,getTopology:()=>Tt.current?.getLayoutData()??{nodes:[],edges:[]},getCustomLayout:()=>Tt.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Tt.current?.lastCustomLayoutFailure??null,getTopologyDiff:()=>{const e=Tt.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:cn,getTension:()=>Tt.current?.tension??0}),[on,sn,an,cn,a,rn,ft,h]);const ln=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),un=ln?i||(Array.isArray(o)?void 0:o):void 0;il(()=>{const e=Tt.current;if(!e)return;const t=++Yt.current;if(jt.current?.abort(),jt.current=null,ln&&un)e.ingestHierarchy(un,[ot,it]),Nt(e,[ot,it]),Bt(!1),Xt.current?.("ready"),Ze.current=!0,ft();else{const i=vt,s=Array.isArray(xt)?xt:[];if(0===i.length&&0===s.length)return null==r&&null==o||0>=e.nodes.size&&0>=e.edges.size||an(),Bt(!1),void Xt.current?.("ready");const a=[ot,it],c="force"===n&&!Ve&&Hh()&&!Ne&&function(e,t,n,r,o=4e4){return"sync"!==e&&("worker"===e||r*(t+n)>=o)}(b,i.length,s.length,v);if(c&&mt&&!Ht.current&&e.sceneNodes.length>0)return Ht.current=!0,Bt(!1),Xt.current?.("ready"),Ze.current=!0,void ft();if(c){const n=new AbortController;jt.current=n;const r=e._lastPositionSnapshot;e.ingestBounded(i,s,a,{deferLayout:!0});const o=e.getLayoutData(),c=function(e,t,n,r,o){const i=Ru(n.nodeSize,n.nodeSizeRange,e);return{kind:"frame",nodes:e.map(e=>{const t=o?.get(e.id);return{id:e.id,x:0!==e.x||0!==e.y?e.x:t?.x??0,y:0!==e.x||0!==e.y?e.y:t?.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:e.value,__forceRadius:i(e)}}),edges:t.map(e=>{const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id,r=e.data?.weight,o="number"==typeof r&&Number.isFinite(r)?r:e.value;return{source:t,target:n,value:e.value,y0:0,y1:0,sankeyWidth:0,weight:o}}),config:{chartType:"force",iterations:n.iterations,forceStrength:n.forceStrength,seed:n.seed},size:r}}(o.nodes,o.edges,Gt.current,a,r);return Bt(!0),Xt.current?.("pending"),function(e,t){return Hh()?t?.aborted?Promise.reject(Xh()):(Vh&&!Vh.isDead||(Vh=new Gh),Vh).request(e,t):Promise.reject(Error("Web Workers are unavailable"))}(c,n.signal).then(({positions:n})=>{t===Yt.current&&(e.applyForceLayoutPositions(n,a),Nt(e,a),Ut.current=id({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:qt.current,colorScheme:F}),Bt(!1),Xt.current?.("ready"),It(e.layoutVersion),Ze.current=!0,ft())}).catch(n=>{"AbortError"!==n.name&&t===Yt.current&&(e.runLayout(a),Nt(e,a),Ut.current=id({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:qt.current,colorScheme:F}),Bt(!1),Xt.current?.("error"),It(e.layoutVersion),Ze.current=!0,ft())}),()=>n.abort()}e.ingestBounded(i,s,a),Nt(e,a),Bt(!1),Xt.current?.("ready"),Ut.current=id({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:qt.current,colorScheme:F}),Ze.current=!0,ft()}},[vt,xt,r,o,i,un,ln,ot,it,St,b,v,mt,n,Ve,Ne,ft,an,F,Nt]),il(()=>{s&&s.length>0&&sn(s)},[s,sn]);const{customHoverBehavior:hn,customClickBehavior:dn}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:r}){return{customHoverBehavior:fd((t,o)=>{e?.(t,o),Oc({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:yd,chartId:r,context:o})},[e,n,r]),customClickBehavior:fd((e,o)=>{t?.(e,o),Fc({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:yd,chartId:r,context:o})},[t,n,r])}}({customHoverBehavior:re,customClickBehavior:oe,onObservation:ie,chartId:ae}),{hoverHandlerRef:fn,hoverLeaveRef:yn,onPointerMove:mn,onPointerLeave:xn}=Je,bn=()=>!Ve||(Tt.current?.hasCustomRestyle??!1);fn.current=e=>{if(!te)return;const t=bn(),n=Nn.current;if(!n)return;const r=Tt.current;if(!r)return;const o=dd({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:rt,adjustedWidth:ot,adjustedHeight:it,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});"hit"===o.kind?(Vt.current=o.hover,Lt(o.hover),hn&&(hn(o.hover),t&&(Ze.current=!0)),t&&ft()):Vt.current&&(Vt.current=null,Lt(null),hn&&(hn(null),t&&(Ze.current=!0)),t&&ft())},yn.current=()=>{if(Vt.current){const e=bn();Vt.current=null,Lt(null),hn&&(hn(null),e&&(Ze.current=!0)),e&&ft()}};const kn=rl(()=>{});kn.current=e=>{if(Qo(e.target))return;if(!oe&&!ie)return;const t=Nn.current;if(!t)return;const n=Tt.current;if(!n)return;const r=dd({clientX:e.clientX,clientY:e.clientY,canvasRect:t.getBoundingClientRect(),margin:rt,adjustedWidth:ot,adjustedHeight:it,sceneNodes:n.sceneNodes,sceneEdges:n.sceneEdges,nodeQuadtree:n.nodeQuadtree,maxNodeRadius:n.maxNodeRadius});"hit"===r.kind?dn(r.hover,{type:"activate",inputType:$c(e.nativeEvent.pointerType)}):"miss"===r.kind&&dn(null)};const wn=al(e=>kn.current(e),[]),Sn=rl(-1),_n=rl(null),Pn=rl(-1),Tn=al(e=>{if(zc(e))return;const t=Tt.current;if(!t)return;const n=()=>{Sn.current=-1,_n.current=null,Pn.current=-1,Vt.current=null,Lt(null),hn&&(hn(null),Ze.current=!0),ft()},r=function(e){const t=[];for(const n of e)if("circle"===n.type&&null!=n.cx){if(0>=n.r)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("rect"===n.type&&null!=n.x){if(0>=n.w||0>=n.h)continue;t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.datum?.id??"_default"})}else if("arc"===n.type&&null!=n.cx)t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"});else if("symbol"===n.type&&null!=n.cx){if(0>=n.size)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("glyph"===n.type&&null!=n.cx){if(0>=n.size||null==n.datum)continue;const e=Fn(n.glyph,n.size);t.push({x:n.cx+e.centerDx,y:n.cy+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:n.datum?.id??"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===r.length)return void(0>Sn.current||n());const o=Hc(r);let i=Sn.current;if(o.flat.length>i||(n(),i=-1)," "===e.key&&i>=0){e.preventDefault();const t=o.flat[i];return void dn(ca(t.datum||{},t.x,t.y,{nodeOrEdge:"node"}),{type:"activate",inputType:"keyboard"})}if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),Sn.current=0,Pn.current=-1;const t=o.flat[0];_n.current={shape:t.shape,w:t.w,h:t.h};const n=ca(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Vt.current=n,Lt(n),hn&&(hn(n,{type:"focus",inputType:"keyboard"}),Ze.current=!0),void ft()}const s=Xc(o,i),a=function(e,t,n,r,o){const i=n.flat[t.flatIndex];if(!i)return Gc(e,t,n);const s=i.datum?.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=function(e,t,n){let r=null,o=1/0;for(let i=0;e.flat.length>i;i++){const s=e.flat[i];if(s===t)continue;const a=s.x-t.x,c=s.y-t.y;let l=!1;switch(n){case"right":l=a>0&&Math.abs(a)>=Math.abs(c);break;case"left":l=0>a&&Math.abs(a)>=Math.abs(c);break;case"down":l=c>0&&Math.abs(c)>=Math.abs(a);break;case"up":l=0>c&&Math.abs(c)>=Math.abs(a)}if(!l)continue;const u=a*a+c*c;o>u&&(o=u,r=i)}return r}(n,i,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up")??t.flatIndex;return r!==t.flatIndex&&(o.current=-1),r}case"Enter":{if(null==s)return t.flatIndex;const e=function(e,t){const n=e+"",r=[];for(const e of t){const t=e.datum??e,o=Uc(t.source),i=Uc(t.target),s=null!=o,a=null!=i;s&&o+""===n&&a?r.push(i+""):a&&i+""===n&&s&&r.push(o+"")}return r}(s,r);if(0===e.length)return t.flatIndex;const i=n.idToIdx.get(e[(o.current+1)%e.length])??-1;return 0>i?t.flatIndex:(o.current=-1,i)}default:{const r=Gc(e,t,n);return null!==r&&r!==t.flatIndex&&(o.current=-1),r}}}(e.key,s,o,t.sceneEdges??[],Pn);if(null===a)return;if(e.preventDefault(),0>a)return void n();Sn.current=a;const c=o.flat[a];_n.current={shape:c.shape,w:c.w,h:c.h};const l={data:c.datum||{},x:c.x,y:c.y,__semioticHoverData:!0,nodeOrEdge:"node"};Vt.current=l,Lt(l),hn&&(hn(l,{type:"focus",inputType:"keyboard"}),Ze.current=!0),ft()},[dn,hn,ft]),Rn=al(e=>{Sn.current=-1,_n.current=null,mn(e)},[mn]);dt.current=()=>{if(ht.current=null,!yt.isActive)return;const e=Nn.current;if(!e)return;const t=Tt.current;t&&function(e){const{canvas:t,store:n,sceneRevisionDiagnostics:r,size:o,margin:i,adjustedWidth:s,adjustedHeight:a,background:c,renderMode:l,hasBackgroundGraphics:u=!1,dirtyRef:h,lastFrameTimeRef:d,now:f,random:y,reducedMotion:p,showParticles:g,isContinuous:m,animate:v,decay:x,pulse:b,thresholds:k,staleness:w,particleStyle:A,getParticleColor:S,pendingAnnotationFrameRef:_,lastAnnotationFrameTimeRef:M,setAnnotationFrame:C,scheduleNextFrame:P}=e,T=t.getContext("2d");if(!T)return;const R=d.current?Math.min((f-d.current)/1e3,.1):.016;d.current=f;const N=n.advanceTransition(p?f+1e6:f),D=!p&&N,L=!p&&n.tickAnimation([s,a],R),E=h.current,I=r?.beforeCompute(n.getLastUpdateResult(),D),W=N||E||L;W&&n.buildScene([s,a]),I&&r?.afterCompute(I,W,!1);const $=g&&!p&&!!n.particlePool,z=!!((O={dirtyOrRebuilt:E,transitioning:D,animationTicked:L,continuous:$||m,liveEncoding:!!x||!!b||!!k||!1!==v&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()}).dirtyOrRebuilt||O.transitioning||O.animationTicked||O.continuous||O.liveEncoding||O.forced);var O;const F=!!w&&n.lastIngestTime>0&&f-n.lastIngestTime>(w?.threshold??5e3);if(z){const e=Ga();if(!Xa(t,o,i,e))return;if(T.clearRect(-i.left,-i.top,o[0],o[1]),ks(T,{background:c,hasBackgroundGraphics:u,width:s,height:a}),x&&n.applyDecay(),b&&n.applyPulse(f),k&&n.applyThresholds(f),!1!==v&&n.applyTopologyDiff(f),F&&(T.globalAlpha=w?.dimOpacity??.5),Tc({context:T,nodes:n.sceneEdges,renderMode:l,pixelRatio:e,paintBuiltIn:e=>function(e,t){for(const n of t)switch(n.type){case"bezier":Jh(e,n);break;case"line":ed(e,n);break;case"ribbon":td(e,n);break;case"curved":nd(e,n)}}(T,e)}),Tc({context:T,nodes:n.sceneNodes,renderMode:l,pixelRatio:e,paintBuiltIn:e=>{const t=e;!function(e,t){for(const n of t){if("rect"!==n.type)continue;const t=n;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=yr(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.strokeRect(t.x,t.y,t.w,t.h)),ic(e,t),e.restore())}}(T,t),function(e,t){for(const n of t){if("circle"!==n.type)continue;const t=n;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=yr(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),sc(e,t),e.restore())}}(T,t),function(e,t){for(const n of t){if("arc"!==n.type)continue;const t=n;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=yr(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),e.restore()}}(T,t),function(e,t){const n=e.globalAlpha;for(const r of t){if("symbol"!==r.type)continue;const t=r;if(0>=t.size)continue;const o=od(t);if(!o)continue;e.save(),e.translate(t.cx,t.cy),t.rotation&&e.rotate(t.rotation);const i=t.style.opacity??1;t.style.fill&&(e.globalAlpha=n*i*(t.style.fillOpacity??1),e.fillStyle=yr(e,t.style.fill,"#007bff"),e.fill(o)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*i,e.strokeStyle=Un(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(o)),e.restore()}}(T,t),function(e,t){const n=e.globalAlpha;for(const r of t)"glyph"===r.type&&gc(e,r,r.cx,r.cy,n);e.globalAlpha=n}(T,t)}}),$&&!F){const e=n.edgesArray;if(e.length>0){!function(e,t,n,r,o=Math.random){const i=r.spawnRate??.1,s=r.maxPerEdge??50;for(let r=0;t.length>r;r++){const a=t[r];if(!a.bezier)continue;if(e.countForEdge(r)>=s)continue;const c=a.value*i*n*(a.bezier.circular?.3:1),l=Math.floor(c),u=c-l;let h=l;o()<u&&h++;for(let t=0;h>t&&e.countForEdge(r)<s;t++)e.spawn(r,o)}}(n.particlePool,e,R,A,y);const t=.5*(A.speedMultiplier??1);let r;if(A.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);r=e.map(e=>.3+(e.value||1)/t*1.7)}n.particlePool.step(R,t,e,r),function(e,t,n,r,o){const i=r.radius??3;e.globalAlpha=r.opacity??.7;for(let s=0;t.particles.length>s;s++){const a=t.particles[s];if(!a.active)continue;const c=n[a.edgeIndex];if(!c)continue;let l;l="string"==typeof r.color&&"inherit"!==r.color?r.color:o(c),e.fillStyle=Un(e,l)||l,e.beginPath(),e.arc(a.x,a.y,i,0,2*Math.PI),e.fill()}e.globalAlpha=1}(T,n.particlePool,e,A,S)}}F&&(T.globalAlpha=1)}h.current=!1,(E||D||L)&&t.setAttribute("aria-label",zs(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const B=E||D||L||_.current;B&&f-M.current>=33?(C(e=>e+1),M.current=f,_.current=!1):_.current=!!B,(m||D||null!=n.transition||L||n.hasActivePulses||n.hasActiveThresholds||!1!==v&&n.hasActiveTopologyDiff||_.current)&&P()}({canvas:e,store:t,sceneRevisionDiagnostics:Rt.current,size:nt,margin:rt,adjustedWidth:ot,adjustedHeight:it,background:ee,renderMode:I,hasBackgroundGraphics:!!Ae,dirtyRef:Ze,lastFrameTimeRef:Mt,now:yt.now(),random:yt.random,reducedMotion:!!et.current,showParticles:L,isContinuous:nn,animate:Ce,decay:Se,pulse:_e,thresholds:Ie,staleness:Pe,particleStyle:kt,getParticleColor:tn,pendingAnnotationFrameRef:Pt,lastAnnotationFrameTimeRef:Ct,setAnnotationFrame:$t,scheduleNextFrame:()=>{ft()}})};const{canvasRef:Nn}=Ya(Je,{hydrated:gt,wasHydratingFromSSR:mt,storeRef:Tt,dirtyRef:Ze,canvasPaintDependencies:[n,ot,it,ee,Ae,I,ft]});$r(Pe,Tt,Ze,ft,zt,Ot);const Dn=te&&Dt?pd(xa,{x:Dt.x,y:Dt.y,containerWidth:ot,containerHeight:it,margin:rt,className:"stream-network-tooltip",zIndex:2,children:ne?ne(Dt):pd(Qh,{data:Dt})}):null;if(os||!gt&&mt)return pd(zh,{props:e,store:Tt.current,responsiveRef:tt,size:nt,margin:rt,adjustedWidth:ot,adjustedHeight:it,resolvedBackground:at,resolvedForeground:st});const Ln=Tt.current;return gd("div",{ref:tt,className:"stream-network-frame"+(J?" "+J:""),role:"group","aria-label":$e||("string"==typeof ke?ke:"Network chart"),tabIndex:0,"aria-busy":Ft||void 0,style:{position:"relative",width:K?"100%":nt[0],height:Q?"100%":nt[1],overflow:"visible"},onKeyDown:Tn,children:["production"!==process.env.NODE_ENV&&Tt.current&&pd(gn,{store:Tt.current,diagnostics:Rt.current}),We&&pd(ta,{tableId:ut}),We&&pd(Js,{nodes:Ln?.sceneNodes??[],edges:Ln?.sceneEdges??[],chartType:"Network chart",tableId:ut,chartTitle:"string"==typeof ke?ke:void 0}),pd(ea,{summary:ze}),pd(Ns,{hoverPoint:Dt}),gd("div",{role:"img","aria-label":$e||("string"==typeof ke?ke:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:te?Rn:void 0,onMouseLeave:te?xn:void 0,onClick:oe||ie?wn:void 0,children:[Ft&&!1!==k&&pd("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:jh(!0,nt[0],nt[1],k)}),pd(ja,{size:nt,margin:rt,overflowVisible:!0,children:at}),pd("canvas",{ref:Nn,"aria-label":zs(Ln?.sceneNodes?.length??0,Ln?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),pd(Nh,{width:ot,height:it,totalWidth:nt[0],totalHeight:nt[1],margin:rt,labels:Ln?.labels||[],sceneNodes:Ln?.sceneNodes,title:ke,legend:fe,legendPosition:ye,legendLayout:pe,legendHoverBehavior:ge,legendClickBehavior:me,legendHighlightedCategory:ve,legendIsolatedCategories:xe,foregroundGraphics:vn(st,An(Tt.current?.customLayoutOverlays,Ke??null)),annotations:le,onAnnotationActivate:ue,onObservation:se??ie,chartId:ae,chartType:"StreamNetworkFrame",autoPlaceAnnotations:he,svgAnnotationRules:de,annotationFrame:Wt}),pd(Ih,{marks:Ln?.customLayoutHtmlMarks,margin:rt,selection:Ke??null}),pd(oa,{active:Sn.current>=0,hoverPoint:Dt,margin:rt,size:nt,shape:_n.current?.shape,width:_n.current?.w,height:_n.current?.h}),Dn,Pe?.showBadge&&pd(Or,{isStale:zt,position:Pe.badgePosition})]})]})}));kd.displayName="StreamNetworkFrame";var wd=kd,Ad=class e{constructor(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}push(e){if(!Number.isFinite(e))return;this._count+=1;const t=e-this._mean;this._mean+=t/this._count,this._m2+=t*(e-this._mean),this._min>e&&(this._min=e),e>this._max&&(this._max=e)}merge(e){if(0===e._count)return;if(0===this._count)return this._count=e._count,this._mean=e._mean,this._m2=e._m2,this._min=e._min,void(this._max=e._max);const t=this._count+e._count,n=e._mean-this._mean;this._mean+=n*e._count/t,this._m2+=e._m2+n*n*this._count*e._count/t,this._count=t,this._min>e._min&&(this._min=e._min),e._max>this._max&&(this._max=e._max)}clear(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}clone(){const t=new e;return t._count=this._count,t._mean=this._mean,t._m2=this._m2,t._min=this._min,t._max=this._max,t}get count(){return this._count}get mean(){return 0===this._count?0:this._mean}get sum(){return 0===this._count?0:this._mean*this._count}get variance(){return 2>this._count?0:this._m2/this._count}get stddev(){return Math.sqrt(this.variance)}get sampleVariance(){return 2>this._count?0:this._m2/(this._count-1)}get sampleStddev(){return Math.sqrt(this.sampleVariance)}get min(){return this._min}get max(){return this._max}},Sd=class{constructor(e){this.windows=new Map,this.sessions=[],this.latest=-1/0,this.type=e.window??"tumbling",this.size=e.size;const t=e.hop??e.size;this.hop=t>0&&e.size>=t?t:e.size,this.gap=e.gap??e.size,this.retain=null!=e.retain&&e.retain>0?e.retain:1/0}push(e,t){Number.isFinite(e)&&Number.isFinite(t)&&(e>this.latest&&(this.latest=e),"session"===this.type?this.pushSession(e,t):this.pushFixed(e,t),this.prune())}pushFixed(e,t){if("tumbling"===this.type||this.hop>=this.size)return void this.bump(Math.floor(e/this.size)*this.size,t);const n=this.hop,r=Math.floor(e/n);for(let o=Math.floor((e-this.size)/n)+1;r>=o;o++)this.bump(o*n,t)}bump(e,t){let n=this.windows.get(e);n||(n=new Ad,this.windows.set(e,n)),n.push(t)}pushSession(e,t){const n=this.gap,r=new Ad;r.push(t);let o=e,i=e;const s=[],a={start:o,end:i,stats:r};for(const t of this.sessions)e-n>t.end||t.start>e+n?s.push(t):(a.stats.merge(t.stats),o>t.start&&(o=t.start),t.end>i&&(i=t.end));a.start=o,a.end=i,s.push(a),s.sort((e,t)=>e.start-t.start),this.sessions=s}prune(){if(this.retain===1/0)return;if("session"===this.type)return void(this.sessions.length>this.retain&&(this.sessions=this.sessions.slice(this.sessions.length-this.retain)));if(this.retain>=this.windows.size)return;const e=[...this.windows.keys()].sort((e,t)=>e-t),t=e.length-this.retain;for(let n=0;t>n;n++)this.windows.delete(e[n])}emit(){return"session"===this.type?this.emitSessions():this.emitFixed()}emitFixed(){const e=[];for(const[t,n]of this.windows){const r=t+this.size;e.push(this.row(t,r,n,r>this.latest))}return e.sort((e,t)=>e.start-t.start),e}emitSessions(){return this.sessions.map(e=>this.row(e.start,e.end,e.stats,this.gap>this.latest-e.end))}row(e,t,n,r){return{start:e,end:t,count:n.count,mean:n.mean,sum:n.sum,min:n.min,max:n.max,stddev:n.stddev,partial:r}}get windowCount(){return"session"===this.type?this.sessions.length:this.windows.size}get watermark(){return this.latest}clear(){this.windows.clear(),this.sessions=[],this.latest=-1/0}};function _d(e,t){switch(t){case"sum":return e.sum;case"min":return e.min;case"max":return e.max;case"count":return e.count;default:return e.mean}}function Md(e,t,n,r=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const o=_d(e,n),i=e.stddev*r;return[o-i,o+i]}var Cd={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},Pd=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function Td(e){if("number"==typeof e)return Number.isFinite(e)&&e>0?e:null;if("string"!=typeof e)return null;const t=e.trim();if(""===t)return null;Pd.lastIndex=0;let n,r=0,o=0;for(;null!==(n=Pd.exec(t));){const e=parseFloat(n[1]),t=Cd[n[2]];if(null==t||!Number.isFinite(e))return null;r+=e*t,o+=n[0].length}return o!==t.length?null:r>0?r:null}var Rd=class{constructor(e){this.held=[],this._watermark=-1/0,this._lateCount=0,this.lateness=e.lateness>0?e.lateness:0,this.getTime=e.getTime,this.latePolicy=e.latePolicy??"drop"}push(e){const t=this.getTime(e);if(!Number.isFinite(t))return{released:[e],late:[]};const n=[];return this._watermark!==-1/0&&this._watermark-this.lateness>t?(this._lateCount+=1,n.push(e),"drop"===this.latePolicy?{released:[],late:n}:{released:[e],late:n}):(t>this._watermark&&(this._watermark=t),this.held.push(e),{released:this.drain(),late:n})}drain(){const e=this._watermark-this.lateness;if(0===this.held.length)return[];const t=[],n=[];for(const r of this.held)this.getTime(r)>e?n.push(r):t.push(r);return this.held=n,t.sort((e,t)=>this.getTime(e)-this.getTime(t)),t}flush(){const e=this.held;return this.held=[],e.sort((e,t)=>this.getTime(e)-this.getTime(t)),e}clear(){this.held=[],this._watermark=-1/0,this._lateCount=0}get watermark(){return this._watermark}get lateCount(){return this._lateCount}get heldCount(){return this.held.length}};import{useRef as Nd,useImperativeHandle as Dd,forwardRef as Ld,useCallback as Ed,useState as Id,useEffect as Wd}from"react";import{useMemo as $d,useCallback as zd,useState as Od,useId as Fd,useEffect as Bd,useRef as Yd}from"react";function jd(e){const t=[];for(const[n,r]of Object.entries(e.fields))if("point"===r.type)t.push(e=>r.values.has(e[n]));else{const[e,o]=r.range;t.push(t=>{const r=t[n];return r>=e&&o>=r})}return e=>t.every(t=>t(e))}function Hd(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function Xd(e,t){if(e.type!==t.type)return!1;if("interval"===e.type&&"interval"===t.type)return e.range[0]===t.range[0]&&e.range[1]===t.range[1];if("point"===e.type&&"point"===t.type){if(e.values.size!==t.values.size)return!1;for(const n of e.values)if(!t.values.has(n))return!1;return!0}return!1}var[Gd,Vd]=E(e=>({selections:new Map,setClause(t,n){e(e=>{const r=e.selections.get(t),o=r?.clauses.get(n.clientId);if(o&&function(e,t){if(e.clientId!==t.clientId||e.type!==t.type)return!1;const n=Object.entries(e.fields);if(n.length!==function(e){let t=0;for(const n in e)t++;return t}(t.fields))return!1;for(const[e,r]of n){const n=t.fields[e];if(!n||!Xd(r,n))return!1}return!0}(o,n))return{};const i=new Map(e.selections),s=Hd(i,t),a=new Map(s.clauses);return a.set(n.clientId,n),i.set(t,{...s,clauses:a}),{selections:i}})},clearClause(t,n){e(e=>{const r=e.selections.get(t);if(!r||!r.clauses.has(n))return{};const o=new Map(e.selections),i=new Map(r.clauses);return i.delete(n),o.set(t,{...r,clauses:i}),{selections:o}})},setResolution(t,n){e(e=>{const r=e.selections.get(t);if(r?.resolution===n)return{};const o=new Map(e.selections),i=Hd(o,t);return o.set(t,{...i,resolution:n}),{selections:o}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const r=new Map(e.selections);return r.set(t,{...n,clauses:new Map}),{selections:r}})}}));import{useId as qd,useMemo as Ud,useCallback as Kd}from"react";function Qd(e){const t=qd(),n=e.clientId||t,{name:r}=e,o=Vd(e=>e.selections.get(r)),i=Vd(e=>e.setClause),s=Vd(e=>e.clearClause),a=Ud(()=>!!o&&o.clauses.size>0,[o]);return{predicate:Ud(()=>o&&0!==o.clauses.size?function(e,t){const n=[];for(const[r,o]of e.clauses)"crossfilter"===e.resolution&&r===t||n.push(jd(o));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(o,n):()=>!0,[o,n]),isActive:a,selectPoints:Kd(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"point",values:new Set(r)},o=!0;o&&i(r,{clientId:n,type:"point",fields:t})},[n,r,i]),selectInterval:Kd(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"interval",range:r},o=!0;o&&i(r,{clientId:n,type:"interval",fields:t})},[n,r,i]),clear:Kd(()=>{s(r,n)},[s,r,n]),clientId:n}}function Zd(e){return 2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}function Jd(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}function ef(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function tf(e,t,n){const r=e.xValue??t?.[n];if(null==r)return null;const o=Number(r);return Number.isFinite(o)?o:null}function nf(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?{...t,xValue:e.xValue}:t||{}}var rf=[],of={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function sf(e,t={}){const n=t.mobileSemantics?.interaction,r="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,o="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,i=!!n||void 0!==r,s=e&&"object"==typeof e?e:void 0;if(!1===e||!1===s?.enabled||void 0===e&&!o&&!i)return of;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 af({selection:e,linkedHover:t,fallbackFields:n=rf,unwrapData:r=!1,onObservation:o,chartType:i,chartId:s,onClick:a,hoverHighlight:c,colorByField:l,mobileInteraction:u}){const h=Fd(),d=$d(()=>function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField,seriesField:e.seriesField}:null}(t,n),[t,n]),f=$d(()=>"series"===d?.mode?[d.seriesField||l||n[0]].filter(e=>!!e):d?.fields||n,[d,l,n]),y=Qd({name:e?.name||"__unused__",fields:f}),p=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:r,isActive:o,selectPoints:i,clear:s}=Qd({name:t,fields:n});return{onHover:Kd(e=>{if(!e)return void s();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[n])}Jd(t)&&i(t)},[n,i,s]),predicate:r,isActive:o}}({name:d?.name||"hover",fields:f}),g=qo(e=>e.pushObservation),m=zd(e=>{o?.(e),g?.(e)},[o,g]),v=e?{isActive:y.isActive,predicate:y.predicate}:null,[x,b]=Od(null),k=Yd(!1),w=l||n[0],A=$d(()=>{if(!c||null==x||!w)return null;const e=x,t=w;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[c,x,w]),S=zd((e,n)=>{const r=!e&&k.current&&!!u?.enabled&&u.tapToLockTooltip;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===d?.mode&&d.xField){const n=tf(e,t,d.xField);null!=n&&function(e,t,n){const r=Ci.positions.get(e);r?.locked||r&&r.xValue===t&&r.sourceId===n||(Ci={positions:new Map(Ci.positions).set(e,{xValue:t,sourceId:n})},Ti())}(d.name||"hover",n,h)}"x-position"!==d?.mode&&p.onHover(t)}else"x-position"!==d?.mode||r||Ri(d.name||"hover",h),"x-position"===d?.mode||r||p.onHover(null);if(c&&w)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=t?.[w];b(null!=n?n+"":null)}else r||b(null);(o||g)&&Oc({onObservation:m,datum:e?nf(e):null,x:e?.x,y:e?.y,chartType:i||"unknown",chartId:s,context:n})},[t,p,d,h,o,i,s,g,m,c,w,u]),_=zd((n=!0)=>{k.current=!1,t&&"x-position"!==d?.mode&&p.onHover(null),e&&u?.tapToSelect&&y.clear(),n&&c&&b(null),"x-position"===d?.mode&&(Ni(d.name||"hover",h),Ri(d.name||"hover",h))},[t,d,p,e,u,y,c,h]),M=zd((n,r)=>{const l=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),v=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===d?.mode&&d.xField&&n){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]);const t=tf(n,e,d.xField);null!=t&&function(e,t,n){const r=Ci.positions.get(e);if(r?.locked){const t=new Map(Ci.positions);return t.delete(e),Ci={positions:t},Ti(),!1}Ci={positions:new Map(Ci.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Ti()}(d.name||"hover",t,h)}if(l)if(n){k.current=!0;const r=nf(n);if(t&&"x-position"!==d?.mode&&p.onHover(r),e&&u?.tapToSelect&&f.length>0){const e={};for(const t of f){const n=r[t];void 0!==n&&(e[t]=[n])}(function(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1})(e)&&y.selectPoints(e)}if(c&&w){const e=r?.[w];b(null!=e?e+"":null)}}else v&&_();if(n||v){if(n&&a){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]),a(e,{x:n.x??0,y:n.y??0})}(o||g)&&Fc({onObservation:m,datum:n?nf(n):null,x:n?.x,y:n?.y,chartType:i||"unknown",chartId:s,context:r})}},[a,o,g,m,i,s,d,h,u,t,p,e,y,f,c,w,_]);return Bd(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&k.current&&_()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,_]),Bd(()=>()=>{k.current&&_(!1)},[_]),Bd(()=>{if("x-position"!==d?.mode)return;const e=d.name||"hover";return()=>{Ni(e,h),Ri(e,h)}},[d?.mode,d?.name,h]),{activeSelectionHook:v,hoverSelectionHook:A,customHoverBehavior:S,customClickBehavior:M,crosshairSourceId:h}}var cf={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 lf(e,t,n){const r=cf[e||"primary"],o=e&&"primary"!==e||!n?.width?r.width:n.width,i=e&&"primary"!==e||!n?.height?r.height:n.height,s=function(e,t,n=e.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:e,matches:[]};const r=n.map((e,t)=>({rule:e,index:t})).filter(e=>function(e,t){const{when:n}=e,r=t.width,o=t.height,i=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),s=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof n.minWidth&&n.minWidth>r||"number"==typeof n.maxWidth&&r>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof o||n.minHeight>o)||"number"==typeof n.maxHeight&&("number"!=typeof o||o>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof i||n.minAspectRatio>i)||"number"==typeof n.maxAspectRatio&&("number"!=typeof i||i>n.maxAspectRatio)||n.orientation&&s!==n.orientation)}(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:r.reduce((e,t)=>function(e,t){const n={...e,...t};for(const r of["margin","frameProps","mobileSemantics","style"])ef(e[r])&&ef(t[r])&&(n[r]={...e[r],...t[r]});return"string"==typeof e.className&&"string"==typeof t.className&&(n.className=`${e.className} ${t.className}`),n}(e,t.rule.transform),e),matches:r}}({...t,mode:e},{width:t.width??o,height:t.height??i}).props,a=s.mode||e,c=cf[a||"primary"],l="context"===a||"sparkline"===a,u=a&&"primary"!==a||!n?.width?c.width:n.width;return{width:s.width??u,height:s.height??(a&&"primary"!==a||!n?.height?c.height:n.height),showAxes:s.showAxes??c.showAxes,showGrid:s.showGrid??c.showGrid,enableHover:s.enableHover??(!!s.linkedHover||c.enableHover),showLegend:s.showLegend??c.showLegend,showLabels:s.showLabels??c.showLabels,title:l?void 0:s.title,description:s.description,summary:s.summary,accessibleTable:s.accessibleTable,xLabel:l?void 0:s.xLabel,yLabel:l?void 0:s.yLabel,categoryLabel:l?void 0:s.categoryLabel,valueLabel:l?void 0:s.valueLabel,marginDefaults:uf(c.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:l,mobileInteraction:sf(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}function uf(e,t,n){if(!1!==t)return e;const r={...e};return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}import{jsx as hf,jsxs as df}from"react/jsx-runtime";var ff={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, #f3f4f6)",padding:"6px 10px",borderRadius:"var(--semiotic-tooltip-radius, 4px)",fontSize:"var(--semiotic-tooltip-font-size, 12px)",fontFamily:"var(--semiotic-tick-font-family, var(--semiotic-font-family, sans-serif))",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.25))",lineHeight:1.4,pointerEvents:"none",whiteSpace:"nowrap"},yf={opacity:.7,marginRight:4};function pf(e,t,n){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:n]}function gf(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function mf(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:r="x",yLabel:o="y"}=e;return e=>{const i=e?.data??null,s=pf(i,t,"time"),a=pf(i,n,"value");return df("div",{className:"semiotic-tooltip",style:ff,children:[df("div",{children:[df("span",{style:yf,children:[r,":"]}),gf(s)]}),df("div",{children:[df("span",{style:yf,children:[o,":"]}),gf(a)]})]})}}function vf(e,t){return null!=e?e:Math.max(t?.length??0,200)}var xf="time",bf="value",kf="__aggLower",wf="__aggUpper",Af="__aggPartial",Sf="count",_f="__aggStart",Mf="__aggEnd";function Cf(e,t){const n=t.stat??"mean",r=t.band??"none",o=t.sigma??1;return e.emit().map(e=>{const t={[xf]:(e.start+e.end)/2,[bf]:_d(e,n),[Sf]:e.count,[Af]:e.partial,[_f]:e.start,[Mf]:e.end},i=Md(e,r,n,o);return i&&(t[kf]=i[0],t[wf]=i[1]),t})}function Pf(e){const{linkedHover:t,selection:n,onObservation:r,onClick:o,hoverRadius:i,hoverHighlight:s,forceHoverBehavior:a,forceClickBehavior:c,mobileInteraction:l,customHoverBehavior:u,customClickBehavior:h,linkedHoverInClickPredicate:d=!0}=e,f={};r&&(f.annotationObservationCallback=r);const y=l?.enabled?Math.max(i??30,Math.ceil((l.targetSize||44)/2),24):i;return(a||t||r||o||s)&&(f.customHoverBehavior=u),h&&(c||(d?r||o||t:r||o)||l?.enabled&&(l.tapToSelect||l.tapToLockTooltip)&&(t||s||n))&&(f.customClickBehavior=h),null!=y&&(f.hoverRadius=y),f}import{jsx as Tf}from"react/jsx-runtime";function Rf(e,t,n){const r="function"==typeof t?t(e):e[t??n];if(null==r)return null;if(r instanceof Date)return r.getTime();const o=Number(r);return Number.isFinite(o)?o:null}var Nf=Ld(function(e,t){const n=lf(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,extentPadding:y,stroke:p="#007bff",strokeWidth:g=2,strokeDasharray:m,opacity:v,background:x,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:T,staleness:R,transition:N,linkedHover:D,selection:L,onObservation:E,chartId:I,loading:W,loadingContent:$,emptyContent:z,emphasis:O,legendPosition:F,aggregate:B,eventTime:Y}=e,j=n.showAxes,H=n.enableHover,X=o??n.marginDefaults,G=r??[n.width,n.height],V=b??k??mf({timeAccessor:u,valueAccessor:h}),q=Nd(null),{customHoverBehavior:U}=af({selection:L,linkedHover:D,unwrapData:!0,onObservation:E,chartType:"RealtimeLineChart",chartId:I}),K=Ed(e=>{w&&w(e),U(e)},[w,U]),Q=null!=B,[Z,J]=Id([]),ee=Nd(null),te=Nd(B);te.current=B;const ne=Nd(Q);ne.current=Q;const re=Nd(Z);re.current=Z;const oe=Nd({timeAccessor:u,valueAccessor:h});oe.current={timeAccessor:u,valueAccessor:h},Wd(()=>{if(!Q)return void(ee.current=null);const e=te.current,t=function(e){const t=e.window??"tumbling",n=Td("session"===t?e.gap??e.size:e.size);if(null==n)return null;const r=null!=e.hop?Td(e.hop):void 0,o=null!=e.gap?Td(e.gap):void 0;return new Sd({window:t,size:n,hop:r??void 0,gap:o??void 0,retain:e.retain})}(e);if(ee.current=t,t&&l){const{timeAccessor:e,valueAccessor:n}=oe.current;for(const r of l){const o=Rf(r,e,"time"),i=Rf(r,n,"value");null!=o&&null!=i&&t.push(o,i)}}J(t?Cf(t,e):[])},[Q?[B.window??"tumbling",B.size,B.hop??"",B.gap??"",B.retain??""].join("|"):"",Q,l]),Wd(()=>{Q&&ee.current&&J(Cf(ee.current,te.current))},[B?.stat,B?.band,B?.sigma]);const ie=Ed(e=>{const t=ee.current,n=te.current;if(!t||!n)return;const{timeAccessor:r,valueAccessor:o}=oe.current;for(const n of e){const e=Rf(n,r,"time"),i=Rf(n,o,"value");null!=e&&null!=i&&t.push(e,i)}J(Cf(t,n))},[]),se=null!=Y,ae=Nd(null),ce=Nd(Y);ce.current=Y;const le=Nd(se);le.current=se;const ue=Nd(E);ue.current=E;const he=Nd(I);he.current=I,Wd(()=>{ae.current=se?function(e){const t=Td(e.lateness);return null==t?null:new Rd({lateness:t,getTime:e=>Rf(e,oe.current.timeAccessor,"time")??NaN,latePolicy:e.latePolicy??"drop"})}(ce.current):null},[se?`${Y.lateness}|${Y.latePolicy??"drop"}`:"",se]);const de=Ed(e=>{0!==e.length&&(ne.current?ie(e):q.current?.pushMany(e))},[ie]),fe=Ed(e=>{const t=ae.current;if(!le.current||!t)return void de(e);const n=[];for(const r of e){const e=t.push(r);if(e.released.length&&n.push(...e.released),e.late.length){const n=ue.current;if(n){const{timeAccessor:r}=oe.current,o=ce.current?.latePolicy??"drop";for(const i of e.late)n({type:"late-data",datum:i,eventTime:Rf(i,r,"time")??NaN,watermark:t.watermark,policy:o,lateCount:t.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:he.current})}}}de(n)},[de]);Dd(t,()=>({push:e=>fe([e]),pushMany:e=>fe(e),remove:e=>ne.current?[]:q.current?.remove(e)??[],update:(e,t)=>ne.current?[]:q.current?.update(e,t)??[],clear:()=>{ae.current?.clear(),ne.current?(ee.current?.clear(),J([])):q.current?.clear()},getData:()=>ne.current?re.current:q.current?.getData()??[],getScales:()=>q.current?.getScales()??null}),[fe]);const ye=jh(W,G[0],G[1],$),pe=ye?null:Yh(Q?void 0:l,G[0],G[1],z),ge={stroke:p,strokeWidth:g,strokeDasharray:m};null!=v&&(ge.opacity=v);const me=vf(c,l),ve=Q?Z:l,xe=Q?xf:u,be=Q?bf:h,ke=Q&&B&&"none"!==(B.band??"none")?{y0Accessor:kf,y1Accessor:wf,perSeries:!1}:void 0;return ye||pe||Tf(nl,{ref:q,chartType:"line",runtimeMode:"streaming",size:G,margin:X,className:O?`${i||""} semiotic-emphasis-${O}`.trim():i,arrowOfTime:s,windowMode:Q?"growing":a,windowSize:Q?Math.max(1,B?.retain??Math.max(Z.length,600)):me,data:ve,timeAccessor:xe,valueAccessor:be,xExtent:d,yExtent:f,extentPadding:y,band:ke,lineStyle:ge,showAxes:j,background:x,hoverAnnotation:H,tooltipContent:V,...Pf({linkedHover:D,selection:L,onObservation:E,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:K}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:T,staleness:R,transition:N,pointIdAccessor:e.pointIdAccessor,legendPosition:F})});Nf.displayName="RealtimeLineChart";import{useRef as Df,useImperativeHandle as Lf,forwardRef as Ef,useCallback as If,useMemo as Wf}from"react";import{jsx as $f}from"react/jsx-runtime";function zf(e,t,n){const r="function"==typeof t?t(e):e[t??n];if(null==r)return null;if(r instanceof Date)return r.getTime();if("string"==typeof r&&""===r.trim())return null;const o=Number(r);return Number.isFinite(o)?o:null}var Of=Ef(function(e,t){const n=lf(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,showAxes:e.showAxes,enableHover:null!=e.enableHover?!!e.enableHover:void 0,linkedHover:e.linkedHover,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{binSize:r,size:o,margin:i,className:s,arrowOfTime:a="right",windowMode:c="sliding",windowSize:l,data:u,timeAccessor:h,valueAccessor:d,direction:f="up",timeExtent:y,valueExtent:p,extentPadding:g,categoryAccessor:m,colors:v,fill:x,stroke:b,strokeWidth:k,opacity:w,gap:A,background:S,tooltipContent:_,tooltip:M,onHover:C,annotations:P,autoPlaceAnnotations:T,svgAnnotationRules:R,tickFormatTime:N,tickFormatValue:D,linkedHover:L,selection:E,decay:I,pulse:W,staleness:$,transition:z,onObservation:O,chartId:F,loading:B,loadingContent:Y,emptyContent:j,emphasis:H,legendPosition:X,brush:G,onBrush:V,linkedBrush:q}=e,U=n.showAxes,K=n.enableHover,Q=i??n.marginDefaults,Z=o??[n.width,n.height],J=_??M??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const r=e?.data??null;if(null==r?.binStart||null==r?.binEnd){const e=pf(r,t,"time"),o=pf(r,n,"value");return df("div",{className:"semiotic-tooltip",style:ff,children:[df("div",{children:[hf("span",{style:yf,children:"x:"}),gf(e)]}),df("div",{children:[hf("span",{style:yf,children:"y:"}),gf(o)]})]})}return df("div",{className:"semiotic-tooltip",style:ff,children:[df("div",{children:[hf("span",{style:yf,children:"range:"}),gf(r.binStart),"–",gf(r.binEnd)]}),null!=r.total&&df("div",{children:[hf("span",{style:yf,children:"count:"}),gf(r.total)]}),null!=r.category&&df("div",{children:[hf("span",{style:yf,children:"category:"}),gf(r.category)]})]})}}({timeAccessor:h,valueAccessor:d}),ee=Df(null),{customHoverBehavior:te}=af({selection:E,linkedHover:L,unwrapData:!0,onObservation:O,chartType:"RealtimeHistogram",chartId:F}),ne=If(e=>{C&&C(e),te(e)},[C,te]),re=!0===G?{dimension:"x",snap:"bin"}:"x"===G?{dimension:"x"}:"object"==typeof G?G:void 0,oe=(ie=q)?"string"==typeof ie?{name:ie}:ie:null;var ie;const se="string"==typeof h?h:"time",ae=function(e){const{name:t,xField:n,yField:r}=e,{predicate:o,isActive:i,selectInterval:s,clear:a}=Qd({name:t,fields:[n,r].filter(Boolean)}),c=n&&r?"xyBrush":n?"xBrush":"yBrush",l=Kd(e=>{if(!e)return void a();const t={};"xyBrush"===c&&function(e){return 2===e.length&&Array.isArray(e[0])&&2===e[0].length&&Array.isArray(e[1])&&2===e[1].length}(e)?(n&&(t[n]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),r&&(t[r]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Zd(e)?n&&(t[n]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]):"yBrush"===c&&Zd(e)&&r&&(t[r]=[Math.min(e[0],e[1]),Math.max(e[0],e[1])]),Jd(t)&&s(t)},[c,n,r,s,a]);return{brushInteraction:Ud(()=>({brush:c,during:l,end:l}),[c,l]),predicate:o,isActive:i,clear:a}}({name:oe?.name||"__unused_hist_brush__",xField:oe?.xField||se,...oe?.yField?{yField:oe.yField}:{}}),ce=Df(ae.brushInteraction);ce.current=ae.brushInteraction;const le=If(e=>{if(V&&V(e),O&&O(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:F}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:F}),oe){const t=ce.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[V,O,F,oe]);Lf(t,()=>({push:e=>ee.current?.push(e),pushMany:e=>ee.current?.pushMany(e),remove:e=>ee.current?.remove(e)??[],update:(e,t)=>ee.current?.update(e,t)??[],clear:()=>ee.current?.clear(),getData:()=>ee.current?.getData()??[],getScales:()=>ee.current?.getScales()??null}),[]);const ue=jh(B,Z[0],Z[1],Y),he=ue?null:Yh(u,Z[0],Z[1],j),de={};null!=x&&(de.fill=x),null!=b&&(de.stroke=b),null!=k&&(de.strokeWidth=k),null!=w&&(de.opacity=w),null!=A&&(de.gap=A);const fe=H?`${s||""} semiotic-emphasis-${H}`.trim():s,ye=vf(l,u),pe=Wf(()=>"down"!==f?p:function({data:e,valueAccessor:t,timeAccessor:n,binSize:r,valueExtent:o,extentPadding:i}){if(o)return[o[1],o[0]];if(!e||0===e.length)return;const s=new Map;for(const o of e){const e=zf(o,n,"time"),i=zf(o,t,"value");if(null==e||null==i)continue;const a=Math.floor(e/r)*r;s.set(a,(s.get(a)??0)+i)}let a=0;for(const e of s.values())e>a&&(a=e);return[a>0?a+a*(i??.1):1,0]}({data:u,valueAccessor:d,timeAccessor:h,binSize:r,valueExtent:p,extentPadding:g}),[f,u,d,h,r,p,g]);return ue||he||$f(nl,{ref:ee,chartType:"bar",runtimeMode:"streaming",size:Z,margin:Q,className:fe,arrowOfTime:a,windowMode:c,windowSize:ye,data:u,timeAccessor:h,valueAccessor:d,xExtent:y,yExtent:pe,extentPadding:g,binSize:r,categoryAccessor:m,barColors:v,barStyle:de,showAxes:U,background:S,hoverAnnotation:K,tooltipContent:J,...Pf({linkedHover:L,selection:E,onObservation:O,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:ne}),annotations:P,autoPlaceAnnotations:T,svgAnnotationRules:R,tickFormatTime:N,tickFormatValue:D,decay:I,pulse:W,staleness:$,transition:z,pointIdAccessor:e.pointIdAccessor,legendPosition:X,brush:re||(q?{dimension:"x"}:void 0),onBrush:re||q?le:void 0})});function Ff(e){return $f(Of,{...e,windowMode:"growing"})}Of.displayName="RealtimeHistogram",Ff.displayName="TemporalHistogram";import{useRef as Bf,useImperativeHandle as Yf,forwardRef as jf,useCallback as Hf}from"react";import{jsx as Xf}from"react/jsx-runtime";var Gf=jf(function(e,t){const n=lf(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,yScaleType:y,extentPadding:p,categoryAccessor:g,colors:m,radius:v,fill:x,opacity:b,stroke:k,strokeWidth:w,pointStyle:A,background:S,tooltipContent:_,tooltip:M,onHover:C,annotations:P,autoPlaceAnnotations:T,svgAnnotationRules:R,tickFormatTime:N,tickFormatValue:D,linkedHover:L,selection:E,onObservation:I,chartId:W,loading:$,loadingContent:z,emptyContent:O,emphasis:F,legendPosition:B}=e,Y=n.showAxes,j=n.enableHover,H=o??n.marginDefaults,X=r??[n.width,n.height],G=_??M??mf({timeAccessor:u,valueAccessor:h}),V=Bf(null),{customHoverBehavior:q}=af({selection:E,linkedHover:L,unwrapData:!0,onObservation:I,chartType:"RealtimeSwarmChart",chartId:W}),U=Hf(e=>{C&&C(e),q(e)},[C,q]);Yf(t,()=>({push:e=>V.current?.push(e),pushMany:e=>V.current?.pushMany(e),remove:e=>V.current?.remove(e)??[],update:(e,t)=>V.current?.update(e,t)??[],clear:()=>V.current?.clear(),getData:()=>V.current?.getData()??[],getScales:()=>V.current?.getScales()??null}),[]);const K=jh($,X[0],X[1],z),Q=K?null:Yh(l,X[0],X[1],O),Z={};null!=v&&(Z.radius=v),null!=x&&(Z.fill=x),null!=b&&(Z.opacity=b),null!=k&&(Z.stroke=k),null!=w&&(Z.strokeWidth=w);const J=A,ee=F?`${i||""} semiotic-emphasis-${F}`.trim():i,te=vf(c,l);return K||Q||Xf(nl,{ref:V,chartType:"swarm",runtimeMode:"streaming",size:X,margin:H,className:ee,arrowOfTime:s,windowMode:a,windowSize:te,data:l,timeAccessor:u,valueAccessor:h,xExtent:d,yExtent:f,yScaleType:y,extentPadding:p,categoryAccessor:g,barColors:m,swarmStyle:Z,pointStyle:J,showAxes:Y,background:S,hoverAnnotation:j,tooltipContent:G,...Pf({linkedHover:L,selection:E,onObservation:I,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:U}),annotations:P,autoPlaceAnnotations:T,svgAnnotationRules:R,tickFormatTime:N,tickFormatValue:D,legendPosition:B,pointIdAccessor:e.pointIdAccessor})});Gf.displayName="RealtimeSwarmChart";import{useRef as Vf,useImperativeHandle as qf,forwardRef as Uf,useCallback as Kf}from"react";import{jsx as Qf}from"react/jsx-runtime";var Zf=Uf(function(e,t){const n=lf(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:h,timeExtent:d,valueExtent:f,extentPadding:y,positiveColor:p,negativeColor:g,connectorStroke:m,connectorWidth:v,gap:x,stroke:b,strokeWidth:k,opacity:w,background:A,tooltipContent:S,tooltip:_,onHover:M,annotations:C,autoPlaceAnnotations:P,svgAnnotationRules:T,tickFormatTime:R,tickFormatValue:N,linkedHover:D,selection:L,onObservation:E,chartId:I,loading:W,loadingContent:$,emptyContent:z,emphasis:O,legendPosition:F}=e,B=n.showAxes,Y=n.enableHover,j=o??n.marginDefaults,H=r??[n.width,n.height],X=S??_??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const r=e?.data??null,o=pf(r,t,"time"),i=r?.delta??pf(r,n,"value"),s=r?.cumEnd,a="number"==typeof i?0>i?gf(i):"+"+gf(i):gf(i);return df("div",{className:"semiotic-tooltip",style:ff,children:[df("div",{children:[hf("span",{style:yf,children:"x:"}),gf(o)]}),df("div",{children:[hf("span",{style:yf,children:"Δ:"}),a]}),null!=s&&df("div",{children:[hf("span",{style:yf,children:"total:"}),gf(s)]})]})}}({timeAccessor:u,valueAccessor:h}),G=Vf(null),{customHoverBehavior:V}=af({selection:L,linkedHover:D,unwrapData:!0,onObservation:E,chartType:"RealtimeWaterfallChart",chartId:I}),q=Kf(e=>{M&&M(e),V(e)},[M,V]);qf(t,()=>({push:e=>G.current?.push(e),pushMany:e=>G.current?.pushMany(e),remove:e=>G.current?.remove(e)??[],update:(e,t)=>G.current?.update(e,t)??[],clear:()=>G.current?.clear(),getData:()=>G.current?.getData()??[],getScales:()=>G.current?.getScales()??null}),[]);const U=jh(W,H[0],H[1],$),K=U?null:Yh(l,H[0],H[1],z),Q={};null!=p&&(Q.positiveColor=p),null!=g&&(Q.negativeColor=g),null!=m&&(Q.connectorStroke=m),null!=v&&(Q.connectorWidth=v),null!=x&&(Q.gap=x),null!=b&&(Q.stroke=b),null!=k&&(Q.strokeWidth=k),null!=w&&(Q.opacity=w);const Z=O?`${i||""} semiotic-emphasis-${O}`.trim():i,J=vf(c,l);return U||K||Qf(nl,{ref:G,chartType:"waterfall",runtimeMode:"streaming",size:H,margin:j,className:Z,arrowOfTime:s,windowMode:a,windowSize:J,data:l,timeAccessor:u,valueAccessor:h,xExtent:d,yExtent:f,extentPadding:y,waterfallStyle:Q,showAxes:B,background:A,hoverAnnotation:Y,tooltipContent:X,...Pf({linkedHover:D,selection:L,onObservation:E,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:q}),annotations:C,autoPlaceAnnotations:P,svgAnnotationRules:T,tickFormatTime:R,tickFormatValue:N,legendPosition:F,pointIdAccessor:e.pointIdAccessor})});Zf.displayName="RealtimeWaterfallChart";import{useRef as Jf,useImperativeHandle as ey,forwardRef as ty,useCallback as ny}from"react";import{jsx as ry}from"react/jsx-runtime";var oy=ty(function(e,t){const n=lf(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:r,margin:o,className:i,arrowOfTime:s="right",windowMode:a="sliding",windowSize:c,data:l,timeAccessor:u,valueAccessor:h,categoryAccessor:d,timeExtent:f,valueExtent:y,extentPadding:p,heatmapXBins:g=20,heatmapYBins:m=20,aggregation:v="count",background:x,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:T,staleness:R,linkedHover:N,selection:D,onObservation:L,chartId:E,loading:I,loadingContent:W,emptyContent:$,emphasis:z,legendPosition:O}=e,F=n.showAxes,B=n.enableHover,Y=o??n.marginDefaults,j=r??[n.width,n.height],H=b??k??function(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:r="x",yLabel:o="y"}=e;return e=>{const i=e?.data??null,s=i?.xCenter??pf(i,t,"time"),a=i?.yCenter??pf(i,n,"value"),c=i?.count,l=i?.sum,u=i?.value,h=i?.agg??"count";return df("div",{className:"semiotic-tooltip",style:ff,children:[df("div",{children:[df("span",{style:yf,children:[r,":"]}),gf(s)]}),df("div",{children:[df("span",{style:yf,children:[o,":"]}),gf(a)]}),null!=c&&df("div",{children:[hf("span",{style:yf,children:"count:"}),gf(c)]}),"sum"===h&&null!=l&&df("div",{children:[hf("span",{style:yf,children:"sum:"}),gf(l)]}),"mean"===h&&null!=u&&df("div",{children:[hf("span",{style:yf,children:"mean:"}),gf(u)]})]})}}({timeAccessor:u,valueAccessor:h}),X=Jf(null),{customHoverBehavior:G}=af({selection:D,linkedHover:N,unwrapData:!0,onObservation:L,chartType:"RealtimeHeatmap",chartId:E}),V=ny(e=>{w&&w(e),G(e)},[w,G]);ey(t,()=>({push:e=>X.current?.push(e),pushMany:e=>X.current?.pushMany(e),remove:e=>X.current?.remove(e)??[],update:(e,t)=>X.current?.update(e,t)??[],clear:()=>X.current?.clear(),getData:()=>X.current?.getData()??[],getScales:()=>X.current?.getScales()??null}),[]);const q=jh(I,j[0],j[1],W),U=q?null:Yh(l,j[0],j[1],$),K=z?`${i||""} semiotic-emphasis-${z}`.trim():i,Q=vf(c,l);return q||U||ry(nl,{ref:X,chartType:"heatmap",runtimeMode:"streaming",size:j,margin:Y,className:K,arrowOfTime:s,windowMode:a,windowSize:Q,data:l,timeAccessor:u,valueAccessor:h,categoryAccessor:d,xExtent:f,yExtent:y,extentPadding:p,heatmapXBins:g,heatmapYBins:m,heatmapAggregation:v,showAxes:F,background:x,hoverAnnotation:B,tooltipContent:H,...Pf({linkedHover:N,selection:D,onObservation:L,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:V}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:_,tickFormatTime:M,tickFormatValue:C,decay:P,pulse:T,staleness:R,legendPosition:O,pointIdAccessor:e.pointIdAccessor})});oy.displayName="RealtimeHeatmap";export{Ce as DEFAULT_LIFECYCLE_THRESHOLDS,G as IncrementalExtent,oy as RealtimeHeatmap,Of as RealtimeHistogram,Nf as RealtimeLineChart,Gf as RealtimeSwarmChart,Zf as RealtimeWaterfallChart,Rd as ReorderBuffer,X as RingBuffer,Ad as RunningStats,wd as StreamNetworkFrame,nl as StreamXYFrame,Ff as TemporalHistogram,Sd as WindowAccumulator,Md as bandBounds,Pe as bandFromAge,Re as compileMotionEncoding,Le as deriveMotionVector,Ne as opacityFromAge,Td as parseWindowDuration,Te as resolveMotionAccessor,De as resolveMotionVector,_d as statValue};
1
+ import{getHitRadius as e,hitTestRect as t,isTimeLandmark as n,normalizeAngle as o}from"./chunk-chunk-CP3EN6KZ.module.min.js";import{CustomLayoutSelectionProvider as r,canUseForceWorker as s,createFrameForceWorkerRequest as i,runForceLayoutWorker as a,shouldUseForceWorker as l,wrapWithCustomLayoutSelection as c}from"./chunk-chunk-7OEOSCBP.module.min.js";import{AccessibleDataTable as u,AriaLiveTooltip as d,CanvasFrameBackground as h,FlippingTooltip as p,FocusRing as f,NetworkAccessibleDataTable as y,SceneRevisionDiagnosticsObserver as g,ScreenReaderSummary as m,SkipToTableLink as v,computeCanvasAriaLabel as x,computeNetworkAriaLabel as b,createDefaultAnnotationRules as k,getDevicePixelRatio as w,prepareCanvas as A,renderAnnotationPass as S,renderEmptyState as _,renderLegendFromConfig as T,renderLoadingState as C,runSceneBuild as P,useFrame as R,useFrameCanvasHost as M,useHydration as N,useSceneRevisionDiagnostics as I,useWasHydratingFromSSR as W}from"./chunk-chunk-FRIO6MCV.module.min.js";import{annotationActivationProps as D,buildHoverData as E,defaultTooltipStyle as z,getPointerHitRadius as B,isAnnotationActivationTarget as L,smartTooltipEntries as O,useAnnotationActivationOptions as H}from"./chunk-chunk-255KDHW5.module.min.js";import"./chunk-chunk-SV4XAZ3Q.module.min.js";import{PipelineStore as F,attachUpdateResultStore as j,compileMotionEncoding as $,computeDecayOpacity as Y,createCustomLayoutFailureDiagnostic as X,deriveMotionVector as V,enrichDatumWithBand as G,getLayoutPlugin as q,opacityFromAge as U,paintSceneWithBackend as Q,renderSceneWithBackend as K,resolveDownwardHistogramExtent as Z,resolveMotionAccessor as J,resolveMotionVector as ee,ticksForMode as te,warnCustomLayoutDiagnostics as ne}from"./chunk-chunk-GWSWSPXN.module.min.js";import{IncrementalExtent as oe,RingBuffer as re}from"./chunk-chunk-VVCA3DB7.module.min.js";import"./chunk-chunk-5APBQXZA.module.min.js";import{ANNOTATION_DISCLOSURE_REVEAL_CSS as se,DEFAULT_COLORS as ie,TITLE_BASELINE as ae,buildColorStopGradient as le,buildLinearFillGradient as ce,buildResolveColor as ue,clampCornerRadii as de,computeEasing as he,computeRawProgress as pe,emitClickObservations as fe,emitHoverObservations as ye,filterSparseArray as ge,hasAnyCornerRadius as me,isInteractiveKeyboardTarget as ve,isServerEnvironment as xe,lerp as be,networkLabelToSVG as ke,networkSceneEdgeToSVG as we,networkSceneNodeToSVG as Ae,normalizeLinkedBrush as Se,now as _e,observationInputType as Te,resolveCanvasFill as Ce,resolveCurveFactory as Pe,resolveCustomLayoutPalette as Re,unlockCrosshair as Me,useBrushSelection as Ne,useChartLegendAndMargin as Ie,useChartMode as We,useChartSelection as De,useCrosshairPosition as Ee,xySceneNodeToSVG as ze}from"./chunk-chunk-F25UA5HT.module.min.js";import"./chunk-chunk-XEVJDUTH.module.min.js";import{DEFAULT_LIFECYCLE_THRESHOLDS as Be,bandFromAge as Le}from"./chunk-chunk-2WVCH4PL.module.min.js";import{UpdateResultTracker as Oe,annotationLayout as He,drawGlyphParts as Fe,glyphFractionClipRect as je,glyphHitGeometry as $e,glyphPlacement as Ye,schemeCategory10 as Xe,symbolPathString as Ve,symbolRadius as Ge}from"./chunk-chunk-5RKXZQ2P.module.min.js";import"./chunk-chunk-U66USBWU.module.min.js";import{getMax as qe}from"./chunk-chunk-JJ2OOIET.module.min.js";import{getCSSColorCacheVersion as Ue,resolveCSSColor as Qe}from"./chunk-chunk-QRIBHZYW.module.min.js";import"./chunk-chunk-J3QOW4OE.module.min.js";import{resolveThemeSemanticColors as Ke}from"./chunk-chunk-DSNGDNJY.module.min.js";import*as Ze from"react";import{useRef as Je,useState as et,useEffect as tt,useMemo as nt,useCallback as ot,useImperativeHandle as rt,useId as st,forwardRef as it,memo as at}from"react";import*as lt from"react";import{jsx as ct}from"react/jsx-runtime";var ut=null,dt=null;function ht(e){const[t,n]=lt.useState(()=>ut);return lt.useEffect(()=>{if(t)return;let e=!1;return(ut?Promise.resolve(ut):(dt||(dt=import("./chunk-XYBrushOverlay-ECZJJLAJ.module.min.js").then(e=>ut=e.XYBrushOverlay)),dt)).then(t=>{e||n(()=>t)}),()=>{e=!0}},[t]),t?ct(t,{...e}):null}var pt=class{constructor(e,t){this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=t?.chunkThreshold??5e3,this.chunkSize=t?.chunkSize??5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(e=ge(e),this.lastBoundedData===e)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(e){if(e=ge(e),this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){null!=e&&"object"==typeof e&&(this.pushBuffer.push(e),this.scheduleFlush())}pushMany(e){if(0===e.length)return;let t=0;for(let n=0;e.length>n;n++){const o=e[n];null!=o&&"object"==typeof o&&(this.pushBuffer.push(o),t++)}0!==t&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}};import*as ft from"react";function yt(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:ft.createElement(ft.Fragment,null,...t)}import{useEffect as gt,useRef as mt}from"react";function vt(e,t,n,o){gt(()=>{e.current?.updateConfig(t),n.current=!0,o()},[t,o,e,n])}function xt(e,t,n,o){const r=mt(null);gt(()=>{const s=e.current;if(!s)return;const i=t??null;r.current!==i&&(r.current=i,s.setLayoutSelection(i),s.hasCustomRestyle?s.restyleScene(i):n.current=!0,o())},[t,o,e,n])}function bt(t,n,o,r,s,i=e=>e.x,a=e=>e.y,l=e=>e.r){const c=Math.max(r,s+5,12),u=n-c,d=n+c,h=o-c,p=o+c;let f=null,y=1/0;return t.visit((t,s,c,g,m)=>{if(s>d||u>g||c>p||h>m)return!0;if(!t.length){let s=t;do{const t=s.data,c=i(t)-n,u=a(t)-o,d=Math.sqrt(c*c+u*u);e(l(t),r)>=d&&y>d&&(f=t,y=d),s=s.next}while(s)}return!1}),f?{node:f,distance:y}:null}import{line as kt}from"d3-shape";var wt=new WeakMap;function At(e,t){const n=Pe(t);if(!n)return e;const o=wt.get(e);if(o)return o;const r=function(e,t,n=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const o=[];let r=null;const s={moveTo(e,t){r=[e,t],o.push([e,t])},lineTo(e,t){r=[e,t],o.push([e,t])},bezierCurveTo(e,t,s,i,a,l){if(!r)return r=[a,l],void o.push([a,l]);const[c,u]=r;for(let r=1;n>=r;r++){const d=r/n,h=1-d;o.push([h*h*h*c+3*h*h*d*e+3*h*d*d*s+d*d*d*a,h*h*h*u+3*h*h*d*t+3*h*d*d*i+d*d*d*l])}r=[a,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,n,s){r=[n,s],o.push([n,s])}};return kt().x(e=>e[0]).y(e=>e[1]).curve(t).context(s)(e),o}(e,n);return wt.set(e,r),r}function St(e,t,n,o=30,r,s=0){let i=null;if(r){const e=bt(r,t,n,o,s);e&&(i={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const s of e){let e=null;switch(s.type){case"point":if(r)break;e=Tt(s,t,n,o);break;case"symbol":e=Ct(s,t,n,o);break;case"glyph":e=Pt(s,t,n,o);break;case"line":e=Rt(s,t,n,o);break;case"rect":if(null==s.datum)break;e=Nt(s,t,n);break;case"heatcell":e=It(s,t,n);break;case"area":if(!1===s.interactive)break;e=Dt(s,t,n);break;case"candlestick":e=Wt(s,t,n)}e&&o>e.distance&&(i&&e.distance>=i.distance||(i=e))}return i}function _t(e,t,n){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const o=Et(e,t);if(0>o)return null;if(Math.abs(e[o][0]-t)>n)return null;let r=o,s=o;o>0&&e[o][0]>=t?(r=o-1,s=o):e.length-1>o&&(r=o,s=o+1);const[i,a]=e[r],[l,c]=e[s];return l===i?a:a+Math.max(0,Math.min(1,(t-i)/(l-i)))*(c-a)}function Tt(t,n,o,r=30){const s=n-t.x,i=o-t.y,a=Math.sqrt(s*s+i*i);return a>e(t.r,r)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:a}}function Ct(t,n,o,r=30){const s=n-t.x,i=o-t.y,a=Math.sqrt(s*s+i*i);return a>e(Ge(t.size),r)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:a}}function Pt(t,n,o,r=30){if(null==t.datum)return null;const s=$e(t.glyph,t.size),i=t.x+s.centerDx,a=t.y+s.centerDy,l=n-i,c=o-a,u=Math.sqrt(l*l+c*c);return u>e(s.radius,r)?null:{node:t,datum:t.datum,x:i,y:a,distance:u}}function Rt(e,t,n,o=30){if(0===e.path.length)return null;const r=Et(e.path,t);if(0>r)return null;const[s,i]=e.path[r];let a;if(e.path.length>1){let o=1/0;const s=Math.max(0,r-1),i=Math.min(e.path.length-2,r);for(let r=s;i>=r;r++){const[s,i]=e.path[r],[a,l]=e.path[r+1],c=Mt(t,n,s,i,a,l);o>c&&(o=c)}a=o}else{const e=t-s,o=n-i;a=Math.sqrt(e*e+o*o)}const l=e.style;return a>Math.max(5,(l.strokeWidth??l.lineWidth??1)/2+2,o)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:s,y:i,distance:a}}function Mt(e,t,n,o,r,s){const i=r-n,a=s-o,l=i*i+a*a;if(0===l)return Math.sqrt((e-n)**2+(t-o)**2);let c=((e-n)*i+(t-o)*a)/l;return c=Math.max(0,Math.min(1,c)),Math.sqrt((e-(n+c*i))**2+(t-(o+c*a))**2)}function Nt(e,n,o){const r=t(n,o,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function It(e,n,o){const r=t(n,o,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function Wt(e,t,n){const o=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,s=t-e.x,i=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(s*s+i*i)}}return null}function Dt(e,t,n){if(0===e.topPath.length)return null;const o=Et(e.topPath,t);if(0>o)return null;const[r,s]=e.topPath[o],i=t-r,a=n-s,l=Math.sqrt(i*i+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:s,distance:l}}function Et(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}import{useEffect as zt,useRef as Bt}from"react";var Lt={fresh:1,aging:.7,stale:.45,expired:.25},Ot={alpha:1,band:"fresh",isStale:!1};function Ht(e,t){if(!e||0>=t)return Ot;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,o=e.graded;if(o){const e="object"==typeof o?o:{},r=Le(t,n,e.thresholds);return{alpha:{...Lt,...e.opacities??{}}[r],band:r,isStale:"fresh"!==r}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:Ot}function Ft(e,t,n,o,r,s){const i=Bt("fresh");zt(()=>{if(!e)return;const a=setInterval(()=>{const a=t.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=Ht(e,l-a.lastIngestTime);c.band===i.current&&c.isStale===r||(i.current=c.band,c.isStale!==r&&s(c.isStale),n.current=!0,o())},1e3);return()=>clearInterval(a)},[e,r,o,t,s,n])}import{jsx as jt}from"react/jsx-runtime";function $t({isStale:e,position:t}){return jt("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===t?{top:4,left:4}:"bottom-left"===t?{bottom:4,left:4}:"bottom-right"===t?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:e?"#dc3545":"#28a745",color:"white"},children:e?"STALE":"LIVE"})}import{useMemo as Yt,useRef as Xt,useEffect as Vt}from"react";import{useMemo as Gt}from"react";import{bin as qt}from"d3-array";import{jsx as Ut,jsxs as Qt}from"react/jsx-runtime";function Kt(e){return"string"==typeof e?{type:e}:e}function Zt({orient:e,config:t,values:n,scale:o,size:r,length:s}){const i=function(e){return{type:e.type,bins:e.bins??20,fill:e.fill??"#4e79a7",fillOpacity:e.fillOpacity??.5,stroke:e.stroke??"none",strokeWidth:e.strokeWidth??1}}(t),a="top"===e||"bottom"===e,l=Gt(()=>{if(0===n.length)return null;const t=o.domain(),l=r-8;if("boxplot"===i.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],s=t[Math.floor(.75*n)],i=s-o;return{q1:o,median:r,q3:s,whiskerLow:Math.max(t[0],o-1.5*i),whiskerHigh:Math.min(t[n-1],s+1.5*i)}}(n);if(!t)return null;const{q1:r,median:s,q3:c,whiskerLow:u,whiskerHigh:d}=t,h=Math.min(.5*l,20),p=(l-h)/2+4;if(a){const t=o(r),n=o(c),a=o(s),l=o(u),f=o(d),y="top"===e?-1:1,g=0;return Qt("g",{"data-testid":"marginal-boxplot-"+e,children:[Ut("line",{x1:l,y1:g+y*(p+h/2),x2:f,y2:g+y*(p+h/2),stroke:i.fill,strokeWidth:i.strokeWidth}),Ut("line",{x1:l,y1:g+y*p,x2:l,y2:g+y*(p+h),stroke:i.fill,strokeWidth:i.strokeWidth}),Ut("line",{x1:f,y1:g+y*p,x2:f,y2:g+y*(p+h),stroke:i.fill,strokeWidth:i.strokeWidth}),Ut("rect",{x:Math.min(t,n),y:"top"===e?g-p-h:g+p,width:Math.abs(n-t),height:h,fill:i.fill,fillOpacity:i.fillOpacity,stroke:"none"===i.stroke?i.fill:i.stroke,strokeWidth:i.strokeWidth}),Ut("line",{x1:a,y1:"top"===e?g-p-h:g+p,x2:a,y2:"top"===e?g-p:g+p+h,stroke:i.fill,strokeWidth:2})]})}{const t=o(r),n=o(c),a=o(s),l=o(u),f=o(d),y="left"===e?-1:1,g=0;return Qt("g",{"data-testid":"marginal-boxplot-"+e,children:[Ut("line",{x1:g+y*(p+h/2),y1:l,x2:g+y*(p+h/2),y2:f,stroke:i.fill,strokeWidth:i.strokeWidth}),Ut("line",{x1:g+y*p,y1:l,x2:g+y*(p+h),y2:l,stroke:i.fill,strokeWidth:i.strokeWidth}),Ut("line",{x1:g+y*p,y1:f,x2:g+y*(p+h),y2:f,stroke:i.fill,strokeWidth:i.strokeWidth}),Ut("rect",{x:"left"===e?g-p-h:g+p,y:Math.min(t,n),width:h,height:Math.abs(n-t),fill:i.fill,fillOpacity:i.fillOpacity,stroke:"none"===i.stroke?i.fill:i.stroke,strokeWidth:i.strokeWidth}),Ut("line",{x1:"left"===e?g-p-h:g+p,y1:a,x2:"left"===e?g-p:g+p+h,y2:a,stroke:i.fill,strokeWidth:2})]})}}const c=qt().domain(t).thresholds(i.bins)(n);if(0===c.length)return null;const u=qe(c.map(e=>e.length));if(0===u)return null;if("histogram"===i.type)return Ut("g",{"data-testid":"marginal-histogram-"+e,children:c.map((t,n)=>{if(null==t.x0||null==t.x1)return null;const r=t.length/u*l;if(a){const s=o(t.x0),a=o(t.x1)-o(t.x0);return Ut("rect",{x:s,y:"top"===e?-4-r:4,width:Math.max(a,.5),height:r,fill:i.fill,fillOpacity:i.fillOpacity,stroke:i.stroke,strokeWidth:i.strokeWidth},n)}{const s=o(t.x0),a=o(t.x1)-o(t.x0);return Ut("rect",{x:"left"===e?-4-r:4,y:Math.min(s,s+a),width:r,height:Math.abs(a),fill:i.fill,fillOpacity:i.fillOpacity,stroke:i.stroke,strokeWidth:i.strokeWidth},n)}})});if("violin"===i.type){const t=l/2+4,n=[];for(const r of c){if(null==r.x0||null==r.x1)continue;const s=r.length/u*(l/2),i=o((r.x0+r.x1)/2);n.push(a?`${i},${"top"===e?-(t-s):t-s}`:`${"left"===e?-(t-s):t-s},${i}`)}for(let r=c.length-1;r>=0;r--){const s=c[r];if(null==s.x0||null==s.x1)continue;const i=s.length/u*(l/2),d=o((s.x0+s.x1)/2);n.push(a?`${d},${"top"===e?-(t+i):t+i}`:`${"left"===e?-(t+i):t+i},${d}`)}return Ut("g",{"data-testid":"marginal-violin-"+e,children:Ut("polygon",{points:n.join(" "),fill:i.fill,fillOpacity:i.fillOpacity,stroke:"none"===i.stroke?i.fill:i.stroke,strokeWidth:i.strokeWidth})})}if("ridgeline"===i.type){const t=[];if(a){const n=0,r=null!=c[0].x0?o(c[0].x0):0;t.push(`M${r},${n}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const r=n.length/u*l,s=o((n.x0+n.x1)/2);t.push(`L${s},${"top"===e?-r-4:r+4}`)}const i=null!=c[c.length-1].x1?o(c[c.length-1].x1):s;t.push(`L${i},${n}`),t.push("Z")}else{const n=0,r=null!=c[0].x0?o(c[0].x0):0;t.push(`M${n},${r}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const r=n.length/u*l,s=o((n.x0+n.x1)/2);t.push(`L${"left"===e?-r-4:r+4},${s}`)}const i=null!=c[c.length-1].x1?o(c[c.length-1].x1):s;t.push(`L${n},${i}`),t.push("Z")}return Ut("g",{"data-testid":"marginal-ridgeline-"+e,children:Ut("path",{d:t.join(" "),fill:i.fill,fillOpacity:i.fillOpacity,stroke:"none"===i.stroke?i.fill:i.stroke,strokeWidth:i.strokeWidth})})}return null},[n,o,i,r,s,e,a,4]);return l?Ut("g",{className:"marginal-"+e,"data-testid":"marginal-"+e,children:l}):null}function Jt(e,t,n){if("edges"===e){if(t)return"start";if(n)return"end"}return"middle"}function en(e,t,n){if("edges"===e){if(t)return"hanging";if(n)return"auto"}return"middle"}function tn(e){if(0===e.length)return{min:null,max:null};let t=1/0,n=-1/0;for(const o of e)t>o.pixel&&(t=o.pixel),o.pixel>n&&(n=o.pixel);return{min:t,max:n}}function nn(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function on(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,s=Math.ceil(t/8);let i="M0,"+o;for(let e=0;s>e;e++){const n=8*(e+1);i+=`L${Math.min(8*e+4,t)},${o+4*r}`,i+=`L${Math.min(n,t)},${o}`}return i}const o="bottom"===e?0:t,r="bottom"===e?1:-1,s=Math.ceil(n/8);let i=`M${o},0`;for(let e=0;s>e;e++){const t=8*(e+1);i+=`L${o+4*r},${Math.min(8*e+4,n)}`,i+=`L${o},${Math.min(t,n)}`}return i}import{Fragment as rn,jsx as sn,jsxs as an}from"react/jsx-runtime";function ln(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:s,scales:i,showAxes:a,axes:l,showGrid:c,xFormat:u,yFormat:d,axisExtent:h}=e,p=Yt(()=>{if(!i)return[];const e=l?.find(e=>"bottom"===e.orient),n=e?.tickFormat||u||cn,o=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,s="exact"===h?Math.max(2,r):Math.min(r,o),a=e?.tickValues??te(i.x,s,h),c=a.map(e=>e.valueOf()),d=a.map((e,t)=>({value:e,pixel:i.x(e),label:n(e,t,c)})),p=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return un(d,Math.max(55,p+8))},[i,l,u,t,h]),f=Yt(()=>{if(!i)return[];const e=l?.find(e=>"left"===e.orient),t=e?.tickFormat||d||cn,o=Math.max(2,Math.floor(n/30)),r=e?.ticks??5,s="exact"===h?Math.max(2,r):Math.min(r,o);return un((e?.tickValues??te(i.y,s,h)).map(e=>({value:e,pixel:i.y(e),label:t(e)})),22)},[i,l,d,n,h]),y=c&&i,g=a&&i;if(!y&&!g)return null;const m=l?.find(e=>"bottom"===e.orient),v=l?.find(e=>"left"===e.orient),x=g&&(!m||!1!==m.baseline),b=g&&(!v||!1!==v.baseline),k=m?.jaggedBase||!1,w=v?.jaggedBase||!1,A="var(--semiotic-border, #ccc)";return sn("svg",{width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:an("g",{transform:`translate(${s.left},${s.top})`,children:[y&&(()=>{const e=nn(l?.find(e=>"bottom"===e.orient)?.gridStyle),o=nn(l?.find(e=>"left"===e.orient)?.gridStyle);return an("g",{className:"stream-grid",children:[p.map((t,o)=>sn("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+o)),f.map((e,n)=>sn("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"ygrid-"+n))]})})(),x&&!k&&sn("line",{x1:0,y1:n,x2:t,y2:n,stroke:A,strokeWidth:1}),k&&sn("path",{d:on("bottom",t,n),fill:"none",stroke:A,strokeWidth:1}),b&&!w&&sn("line",{x1:0,y1:0,x2:0,y2:n,stroke:A,strokeWidth:1}),w&&sn("path",{d:on("left",t,n),fill:"none",stroke:A,strokeWidth:1})]})})}function cn(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function un(e,t){if(2>=e.length)return e;const n=[e[0]];for(let o=1;e.length-1>o;o++)t>Math.abs(e[o].pixel-n[n.length-1].pixel)||n.push(e[o]);const o=e[e.length-1];return t>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function dn(e){const{width:t,height:o,totalWidth:r,totalHeight:s,margin:i,scales:a,showAxes:l,axes:c,xLabel:u,yLabel:d,yLabelRight:h,xFormat:p,yFormat:f,axisExtent:y,showGrid:g,title:m,legend:v,legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:w,legendIsolatedCategories:A,legendPosition:_="right",legendLayout:C,foregroundGraphics:P,marginalGraphics:R,xValues:M,yValues:N,annotations:I,onAnnotationActivate:W,onObservation:D,chartId:E,chartType:z,autoPlaceAnnotations:B,svgAnnotationRules:L,xAccessor:O,yAccessor:F,annotationData:j,pointNodes:$,curve:Y,underlayRendered:X,canvasObscuresUnderlay:V=!0,linkedCrosshairName:G,linkedCrosshairSourceId:q,children:U}=e,Q=H({onAnnotationActivate:W,onObservation:D,chartId:E,chartType:z}),K=Yt(()=>{if(!l||!a)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||p||cn,o=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,s="exact"===y?Math.max(2,r):Math.min(r,o),i=e?.tickValues??te(a.x,s,y),u=i.map(e=>e.valueOf()),d=i.map((e,t)=>({value:e,pixel:a.x(e),label:n(e,t,u)})),h=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),f=e?.autoRotate?Math.max(20,Math.min(h+8,55)):Math.max(55,h+8);let g=un(d,f);if(g.length>1&&(g=g.filter((e,t)=>0===t||e.label+""!=g[t-1].label+"")),e?.includeMax&&g.length>0&&"exact"!==y&&!e?.tickValues){const e=a.x.domain()[1],t=a.x(e),o=g[g.length-1].pixel;if(Math.abs(t-o)>1){const r=n(e,g.length,u);f>t-o&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:r})}}return g},[l,a,c,p,t,y]),Z=Yt(()=>{if(!l||!a)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||f||cn,n=Math.max(2,Math.floor(o/30)),r=e?.ticks??5,s="exact"===y?Math.max(2,r):Math.min(r,n);let i=un((e?.tickValues??te(a.y,s,y)).map(e=>({value:e,pixel:a.y(e),label:t(e)})),22);if(i.length>1&&(i=i.filter((e,t)=>0===t||e.label+""!=i[t-1].label+"")),e?.includeMax&&i.length>0&&"exact"!==y&&!e?.tickValues){const e=a.y.domain()[1],n=a.y(e),o=i[i.length-1].pixel;if(Math.abs(n-o)>1){const r=t(e);22>Math.abs(n-o)&&i.length>1&&(i=i.slice(0,-1)),i.push({value:e,pixel:n,label:r})}}return i},[l,a,c,f,o,y]),J=Yt(()=>{if(!l||!a)return[];const e=c?.find(e=>"right"===e.orient);if(!e)return[];const t=e.tickFormat||f||cn,n=Math.max(2,Math.floor(o/30)),r=e.ticks??5;return un((e.tickValues??te(a.y,"exact"===y?Math.max(2,r):Math.min(r,n),y)).map(e=>({value:e,pixel:a.y(e),label:t(e)})),22)},[l,a,c,f,o,y]),ee=Xt(new Map),ne=Xt(I?.length??0),oe=I?.length??0;ne.current!==oe&&(ne.current=oe,ee.current=new Map);const re=Yt(()=>{if(!I||0===I.length)return null;const e=k("xy",Q),n={scales:a?{x:a.x,y:a.y,time:a.x,value:a.y}:null,timeAxis:"x",xAccessor:O,yAccessor:F,width:t,height:o,data:j,frameType:"xy",pointNodes:$,curve:Y,stickyPositionCache:ee.current},r=B?He({annotations:I,context:n,..."object"==typeof B?B:{}}):I;return S(r,e,L,n)},[I,B,L,t,o,O,F,j,a,$,Y,Q]),se=Ee(G);return Vt(()=>{if(!se?.locked||!G)return;const e=e=>{"Escape"===e.key&&Me(G)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[se?.locked,G]),l||m||v||P||R||re&&re.length>0||g||U||se?an("svg",{role:"img",width:r,height:s,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[sn("title",{children:"string"==typeof m?m:"XY Chart"}),sn("desc",{children:"string"==typeof m?m+" (XY data visualization)":"XY data visualization"}),an("g",{transform:`translate(${i.left},${i.top})`,children:[g&&a&&(!X||V)&&(()=>{const e=nn(c?.find(e=>"bottom"===e.orient)?.gridStyle),n=nn(c?.find(e=>"left"===e.orient)?.gridStyle);return an("g",{className:"stream-grid",children:[K.map((t,n)=>sn("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:o,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+n)),Z.map((e,o)=>sn("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:n},"ygrid-"+o))]})})(),l&&a&&(()=>{const e=c?.find(e=>"left"===e.orient),r=c?.find(e=>"bottom"===e.orient),s=!e||!1!==e.baseline,a=!r||!1!==r.baseline,l=e?.jaggedBase||!1,p=r?.jaggedBase||!1,f=r?.landmarkTicks,y=e?.landmarkTicks,g="var(--semiotic-border, #ccc)",m="var(--semiotic-text-secondary, var(--semiotic-text, #666))",v="var(--semiotic-text, #333)",x=!!r?.autoRotate&&K.length>1&&(()=>{const e=t/Math.max(K.length-1,1);return K.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})(),b=x?12:18,k=o+(x?58:40),w={fontSize:"var(--semiotic-tick-font-size, 12px)"},A={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},S={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},_=r?.tickAnchor,T=e?.tickAnchor,C=tn(K),P=tn(Z);return an("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[an("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!X||V)&&a&&!p&&sn("line",{x1:0,y1:o,x2:t,y2:o,stroke:g,strokeWidth:1}),(!X||V)&&p&&sn("path",{d:on("bottom",t,o),fill:"none",stroke:g,strokeWidth:1}),K.map((e,t)=>{const r=!!f&&("function"==typeof f?f(e.value,t):n(e.value,t>0?K[t-1].value:void 0));return an("g",{transform:`translate(${e.pixel},${o})`,children:[sn("line",{y2:5,stroke:g,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?sn("text",{y:b,textAnchor:x?"end":Jt(_,e.pixel===C.min,e.pixel===C.max),fontWeight:r?600:400,fill:m,className:"semiotic-axis-tick",style:{userSelect:"none",...r?A:w},transform:x?"rotate(-45)":void 0,children:e.label}):sn("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:sn("div",{style:{textAlign:"center",userSelect:"none",...w},children:e.label})})]},"xtick-"+t)}),u&&sn("text",{x:t/2,y:k,textAnchor:"middle",fill:v,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:u})]}),an("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!X||V)&&s&&!l&&sn("line",{x1:0,y1:0,x2:0,y2:o,stroke:g,strokeWidth:1}),(!X||V)&&l&&sn("path",{d:on("left",t,o),fill:"none",stroke:g,strokeWidth:1}),Z.map((e,t)=>{const o=!!y&&("function"==typeof y?y(e.value,t):n(e.value,t>0?Z[t-1].value:void 0));return an("g",{transform:`translate(0,${e.pixel})`,children:[sn("line",{x2:-5,stroke:g,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?sn("text",{x:-8,textAnchor:"end",dominantBaseline:en(T,e.pixel===P.min,e.pixel===P.max),fontWeight:o?600:400,fill:m,className:"semiotic-axis-tick",style:{userSelect:"none",...o?A:w},children:e.label}):sn("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:sn("div",{style:{textAlign:"right",userSelect:"none",...w},children:e.label})})]},"ytick-"+t)}),(()=>{const t=e?.label||d;return t?sn("text",{x:15-i.left,y:o/2,textAnchor:"middle",fill:v,transform:`rotate(-90, ${15-i.left}, ${o/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:t}):null})()]}),(()=>{const e=c?.find(e=>"right"===e.orient);if(!e||0===J.length)return null;const r=!1!==e.baseline,s=e.landmarkTicks,a=e.label||h,l=e.tickAnchor,u=tn(J);return an("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[r&&sn("line",{x1:t,y1:0,x2:t,y2:o,stroke:g,strokeWidth:1}),J.map((e,o)=>{const r=!!s&&("function"==typeof s?s(e.value,o):n(e.value,o>0?J[o-1].value:void 0));return an("g",{transform:`translate(${t},${e.pixel})`,children:[sn("line",{x2:5,stroke:g,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?sn("text",{x:8,textAnchor:"start",dominantBaseline:en(l,e.pixel===u.min,e.pixel===u.max),fontWeight:r?600:400,fill:m,className:"semiotic-axis-tick",style:{userSelect:"none",...r?A:w},children:e.label}):sn("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:sn("div",{style:{textAlign:"left",userSelect:"none",...w},children:e.label})})]},"ytick-r-"+o)}),a&&sn("text",{x:t+i.right-15,y:o/2,textAnchor:"middle",fill:v,transform:`rotate(90, ${t+i.right-15}, ${o/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:a})]})})()]})})(),re,R&&a&&M&&N&&an(rn,{children:[R.top&&sn("g",{transform:"translate(0, 0)",children:sn(Zt,{orient:"top",config:Kt(R.top),values:M,scale:a.x,size:i.top,length:t})}),R.bottom&&sn("g",{transform:`translate(0, ${o})`,children:sn(Zt,{orient:"bottom",config:Kt(R.bottom),values:M,scale:a.x,size:i.bottom,length:t})}),R.left&&sn("g",{transform:"translate(0, 0)",children:sn(Zt,{orient:"left",config:Kt(R.left),values:N,scale:a.y,size:i.left,length:o})}),R.right&&sn("g",{transform:`translate(${t}, 0)`,children:sn(Zt,{orient:"right",config:Kt(R.right),values:N,scale:a.y,size:i.right,length:o})})]}),P,se&&se.sourceId!==q&&a?.x&&(()=>{const e=a.x(se.xValue);if(null==e||0>e||e>t)return null;const n=se.locked;return sn("line",{x1:e,y1:0,x2:e,y2:o,stroke:n?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:n?1.5:1,strokeDasharray:n?"6,3":"4,4",pointerEvents:"none"})})(),U]}),m&&"string"==typeof m?sn("text",{x:r/2,y:ae,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:m}):m?sn("foreignObject",{x:0,y:0,width:r,height:i.top,children:m}):null,T({legend:v,totalWidth:r,totalHeight:s,margin:i,legendPosition:_,title:m,legendLayout:C,legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:w,legendIsolatedCategories:A})]}):null}import{useRef as hn}from"react";function pn(e){const t=hn(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return yn(e,t);if(!gn(e)||!gn(t))return!1;const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;const n=e[o],r=t[o];if(!Object.is(n,r))if(Array.isArray(n)&&Array.isArray(r)){if(!yn(n,r))return!1}else{if(!gn(n)||!gn(r))return!1;if(!fn(n,r))return!1}}return!0}(t.current,e)||(t.current=e),t.current}function fn(e,t){const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;if(!Object.is(e[o],t[o]))return!1}return!0}function yn(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function gn(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function mn(e){const{background:t,hasBackgroundGraphics:n=!1,themeBackground:o=""}=e;return"transparent"===t||n?null:t||(o&&"transparent"!==o?o:"")||null}function vn(e,t){const{background:n,hasBackgroundGraphics:o=!1,themeBackground:r="",x:s=0,y:i=0,width:a,height:l}=t,c=mn({background:n,hasBackgroundGraphics:o,themeBackground:r});if(!c)return!1;const u=Qe(e,c);return!!u&&(e.fillStyle=u,e.fillRect(s,i,a,l),!0)}var xn={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white",primary:"#007bff",background:""};function bn(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],o=n[2],r=n[3];return`#${e}${e}${o}${o}${r}${r}${t}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${t}`;const o=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return o?`rgba(${o[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:n}function kn(e,t,n,o){return"function"==typeof e?e({size:t,margin:n,scales:o}):e}import{useCallback as wn,useRef as An}from"react";function Sn(e,t,n,o){return"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:o,fn:t}:{key:void 0,fn:null}}var _n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Tn=3156e7;function Cn(e){const t=e[1]-e[0];return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:Tn>t?e=>{const t=new Date(e);return`${_n[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*Tn>t?e=>{const t=new Date(e);return`${_n[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function Pn(e){if(!e)return;const t=[];for(const n of e)if("point"===n.type)t.push(n);else if("symbol"===n.type)t.push({pointId:n.pointId,x:n.x,y:n.y,r:Ge(n.size)});else if("glyph"===n.type){const e=$e(n.glyph,n.size);t.push({pointId:n.pointId,x:n.x+e.centerDx,y:n.y+e.centerDy,r:e.radius})}return t}import{line as Rn}from"d3-shape";function Mn(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function Nn(e,t,n,o,r,s){if(2>t.length)return;const i=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],o=t[e][1]-t[e-1][1];i.push(i[e-1]+Math.sqrt(n*n+o*o))}const a=i[i.length-1];if(0===a)return;const l=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=s;for(let n=0;t.length-1>n;n++){const o=(i[n]+i[n+1])/2;let s=r;l>o&&(s*=o/l),l>a-o&&(s*=(a-o)/l),e.globalAlpha=Math.max(0,s),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}var In=(e,t,n,o)=>{const r=t.filter(e=>"line"===e.type);for(const t of r){if(2>t.path.length)continue;const n=t._introClipFraction;void 0!==n&&1>n&&(e.save(),e.beginPath(),e.rect(0,0,o.width*n,o.height),e.clip());const r=t.style.stroke||"#007bff",s=Qe(e,r)||r,i=t.style.strokeWidth||2,a=t.colorThresholds,l=t.rawValues;if(e.setLineDash(t.style.strokeDasharray?t.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),e.lineWidth=i,e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade){Nn(e,t.path,s,i,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const c=Pe(t.curve),u=a&&a.length>0&&l&&l.length===t.path.length,d=t._decayOpacities;if(d&&d.length===t.path.length&&!u){e.strokeStyle=s;const n=t.style.opacity??1;for(let o=0;t.path.length-1>o;o++)e.globalAlpha=.5*(d[o]+d[o+1])*n,e.beginPath(),e.moveTo(t.path[o][0],t.path[o][1]),e.lineTo(t.path[o+1][0],t.path[o+1][1]),e.stroke()}else if(u){let n=function(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),d=!0},o=function(){d&&(e.stroke(),d=!1)},r=null,i=null,c=null,u=null,d=!1;for(let d=0;t.path.length>d;d++){const[h,p]=t.path[d],f=l[d],y=Mn(f,a,s);if(null!==r&&null!==u&&null!==c){if(y===u)e.lineTo(h,p);else{const t=[];for(const e of a){const n=e.value;(c>n||n>f)&&(n>c||f>n)||c===n||f===n||t.push({t:(n-c)/(f-c)})}t.sort((e,t)=>e.t-t.t);for(const l of t){const t=r+(h-r)*l.t,u=i+(p-i)*l.t,d=Mn(c+(f-c)*Math.min(l.t+1e-4,1),a,s);e.lineTo(t,u),o(),n(d,t,u)}e.lineTo(h,p)}r=h,i=p,c=f,u=y}else n(y,h,p),r=h,i=p,c=f,u=y}o()}else{e.beginPath();const n=t.strokeGradient&&t.path.length>=2?le(e,t.strokeGradient,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=n||s,c)Rn().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{const[n,o]=t.path[0];e.moveTo(n,o);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}e.stroke()}if(t.style.fill&&t.style.fillOpacity&&t.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=t.style.fillOpacity,e.fillStyle=Ce(e,t.style.fill,t.style.fill),c&&!u)Rn().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{const[n,o]=t.path[0];e.moveTo(n,o);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}const n=t.path[0][0];e.lineTo(t.path[t.path.length-1][0],o.height),e.lineTo(n,o.height),e.closePath(),e.fill()}void 0!==n&&1>n&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function Wn(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Dn(e,t,n=.3){Wn(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function En(e,t,n=.6){if(!Wn(t))return;const o=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,r=t.cx??t.x??0,s=t.cy??t.y??0;e.beginPath(),e.arc(r,s,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function zn(e,t,n,o=.35){Wn(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}import{area as Bn,line as Ln}from"d3-shape";function On(e,t){const n=Pe(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const o=Bn().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),o(t.topPath)}}var Hn=(e,t,n,o)=>{const r=t.filter(e=>"area"===e.type);for(const t of r){if(2>t.topPath.length)continue;let n=!1;t.clipRect&&(e.save(),e.beginPath(),e.rect(t.clipRect.x,t.clipRect.y,t.clipRect.width,t.clipRect.height),e.clip(),n=!0);const r=t._introClipFraction;void 0!==r&&1>r&&(e.save(),e.beginPath(),e.rect(0,0,o.width*r,o.height),e.clip());const s=Ce(e,t.style.fill,"#4e79a7"),i=t._decayOpacities;if(i&&i.length===t.topPath.length){const n=t.style.fillOpacity??.7;e.fillStyle=s;for(let o=0;t.topPath.length-1>o;o++)e.globalAlpha=.5*(i[o]+i[o+1])*n,e.beginPath(),e.moveTo(t.topPath[o][0],t.topPath[o][1]),e.lineTo(t.topPath[o+1][0],t.topPath[o+1][1]),e.lineTo(t.bottomPath[o+1][0],t.bottomPath[o+1][1]),e.lineTo(t.bottomPath[o][0],t.bottomPath[o][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(i[n]+i[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const a=t.style.opacity??1;if(On(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let n=1/0;for(const e of t.topPath)n>e[1]&&(n=e[1]);let o=-1/0;for(const e of t.bottomPath)e[1]>o&&(o=e[1]);const r=ce(e,t.fillGradient,"string"==typeof s?s:"#4e79a7",0,n,0,o);e.fillStyle=r||s,e.globalAlpha=a}else e.globalAlpha=(t.style.fillOpacity??.7)*a,e.fillStyle=s;if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(On(e,t),zn(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=a;const n=t.strokeGradient&&t.topPath.length>=2?le(e,t.strokeGradient,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0):null;e.strokeStyle=n||Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const o=Pe(t.curve);if(e.beginPath(),o)Ln().x(e=>e[0]).y(e=>e[1]).curve(o).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1])}e.stroke()}void 0!==r&&1>r&&e.restore(),n&&e.restore(),e.globalAlpha=1}},Fn=(e,t,n,o)=>{const r=t.filter(e=>"point"===e.type);if(0!==r.length){e.save();try{const t=e.globalAlpha;for(const n of r)e.beginPath(),e.arc(n.x,n.y,n.r,0,2*Math.PI),e.globalAlpha=t*(n.style.opacity??n.style.fillOpacity??1),e.fillStyle=Ce(e,n.style.fill,"#4e79a7"),e.fill(),n.style.stroke&&(e.strokeStyle=Ce(e,n.style.stroke,n.style.stroke),e.lineWidth=n.style.strokeWidth||1,e.stroke()),En(e,n)}finally{e.restore()}}},jn=new Map;function $n(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=jn.get(t);return n||(n=new Path2D(Ve(e.symbolType,e.size)),jn.size>256&&jn.clear(),jn.set(t,n)),n}catch{return null}}var Yn=(e,t)=>{const n=e.globalAlpha;for(const o of t){if("symbol"!==o.type)continue;const t=o;if(0>=t.size)continue;const r=$n(t);if(!r)continue;e.save(),e.translate(t.x,t.y),t.rotation&&e.rotate(t.rotation);const s=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=n*s*(t.style.fillOpacity??1),e.fillStyle=Ce(e,t.style.fill,"#4e79a7"),e.fill(r)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*s,e.strokeStyle=Ce(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth??1,e.stroke(r)),e.restore()}e.globalAlpha=n};function Xn(e,t,n,o,r){if(0>=t.size)return;const s=t.glyph;if(!s||!s.parts?.length)return;const i=Ye(s,t.size);if(0>=i.scale)return;const a=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=a)return;const l=t=>{const n=Ce(e,t,t);return"string"==typeof n?n:t},c=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,o),t.rotation&&e.rotate(t.rotation),e.translate(i.offsetX,i.offsetY),e.scale(i.scale,i.scale),e.globalAlpha=r*a*(t.style.fillOpacity??1);const u=je(s,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&Fe(e,s,c,t.accent,t.ghostColor,l),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),Fe(e,s,c,t.accent,void 0,l),e.restore()}function Vn(e,t){const{x:n,y:o,w:r,h:s}=t,{tl:i,tr:a,br:l,bl:c}=de(t);e.beginPath(),e.moveTo(n+i,o),e.lineTo(n+r-a,o),a>0&&e.arcTo(n+r,o,n+r,o+a,a),e.lineTo(n+r,o+s-l),l>0&&e.arcTo(n+r,o+s,n+r-l,o+s,l),e.lineTo(n+c,o+s),c>0&&e.arcTo(n,o+s,n,o+s-c,c),e.lineTo(n,o+i),i>0&&e.arcTo(n,o,n+i,o,i),e.closePath()}function Gn(e){switch(e.roundedEdge){case"bottom":return{x0:e.x,y0:e.y+e.h,x1:e.x,y1:e.y};case"right":return{x0:e.x+e.w,y0:e.y,x1:e.x,y1:e.y};case"left":return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y};default:return{x0:e.x,y0:e.y,x1:e.x,y1:e.y+e.h}}}var qn=(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)Un(e,t);else if(t.cornerRadii&&me(t.cornerRadii)){const n=Ce(e,t.style.fill,Qe(e,"var(--semiotic-primary, #007bff)")),o=Gn(t),r=t.fillGradient&&"string"==typeof n?ce(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n,Vn(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else if(t.roundedTop&&t.roundedTop>0){const n=Ce(e,t.style.fill,Qe(e,"var(--semiotic-primary, #007bff)")),o=Gn(t),r=t.fillGradient&&"string"==typeof n?ce(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n;const s=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:i,y:a,w:l,h:c}=t;switch(t.roundedEdge){case"right":e.moveTo(i,a),e.lineTo(i+l-s,a),e.arcTo(i+l,a,i+l,a+s,s),e.lineTo(i+l,a+c-s),e.arcTo(i+l,a+c,i+l-s,a+c,s),e.lineTo(i,a+c);break;case"left":e.moveTo(i+l,a),e.lineTo(i+s,a),e.arcTo(i,a,i,a+s,s),e.lineTo(i,a+c-s),e.arcTo(i,a+c,i+s,a+c,s),e.lineTo(i+l,a+c);break;case"bottom":e.moveTo(i,a),e.lineTo(i+l,a),e.lineTo(i+l,a+c-s),e.arcTo(i+l,a+c,i+l-s,a+c,s),e.lineTo(i+s,a+c),e.arcTo(i,a+c,i,a+c-s,s);break;default:e.moveTo(i,a+c),e.lineTo(i,a+s),e.arcTo(i,a,i+s,a,s),e.lineTo(i+l-s,a),e.arcTo(i+l,a,i+l,a+s,s),e.lineTo(i+l,a+c)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const n=Ce(e,t.style.fill,Qe(e,"var(--semiotic-primary, #007bff)")),o=Gn(t),r=t.fillGradient&&"string"==typeof n?ce(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}Dn(e,t),e.globalAlpha=1}};function Un(e,t){const n=t.style.icon,o=t.style.iconPadding||2,r=Math.min(t.w,t.h)-o;if(0>=r)return;const s=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),s){const s=r+o,i=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=s)e.drawImage(n,i,o,r,r)}else{const s=r+o,i=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=s)e.drawImage(n,o,i,r,r)}e.restore()}function Qn(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>128?"#000":"#fff"}function Kn(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var Zn=(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of r){const n=t.style;if(null!=n?.opacity&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle=Qe(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),Dn(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):Kn(t.value),o=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),r=t.x+t.w/2,s=t.y+t.h/2;e.fillStyle=Qn(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,s)}}}finally{e.restore()}},Jn=(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const r=(t._decayOpacity??1)*(t.style?.opacity??1);1!==r&&(e.globalAlpha=r);const s=Qe(e,t.wickColor)||t.wickColor,i=60>o.height,a=i?Math.max(t.wickWidth,2):t.wickWidth,l=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=s,e.lineWidth=a,e.stroke()};if(i||l(),t.isRange){const n=Math.max(2,Math.min(t.bodyWidth/2,.12*o.height));e.fillStyle=s,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),o=Math.abs(t.openY-t.closeY),r=t.isUp?t.upColor:t.downColor,s=Qe(e,r)||r;e.fillStyle=s,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1)),e.strokeStyle=s,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1))}i&&l(),e.restore()}},eo={line:[Hn,In,Fn],area:[Hn,Fn],stackedarea:[Hn,Fn],scatter:[Fn,Yn],bubble:[Fn,Yn],heatmap:[Zn],bar:[qn],swarm:[Fn],waterfall:[(e,t,n,o)=>{qn(e,t);const r=t.filter(e=>"rect"===e.type);if(2>r.length)return;const s=r[0].datum,i=s?._connectorStroke;if(i){e.save(),e.strokeStyle=Qe(e,i)||i,e.lineWidth=s?._connectorWidth??1,e.setLineDash([]);for(let t=0;r.length-1>t;t++){const o=r[t],s=r[t+1],i=o.datum,a=s.datum;if(null==i?.cumEnd||null==a?.baseline)continue;const l=n.y(i.cumEnd),c=o.x+o.w,u=s.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[Jn],mixed:[Hn,In,Fn],custom:[Hn,qn,Zn,In,Fn,Yn,(e,t)=>{const n=e.globalAlpha;for(const o of t)"glyph"===o.type&&Xn(e,o,o.x,o.y,n);e.globalAlpha=n},Jn]};import{jsx as to,jsxs as no}from"react/jsx-runtime";import{jsx as oo,jsxs as ro}from"react/jsx-runtime";function so(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function io({hover:e}){const t=e.data??{},n=t.y??t.value,o=t.x??t.time;if(void 0===n&&void 0===o){const e=O(t);if(null!=e.title||e.entries.length>0)return ro("div",{className:"semiotic-tooltip",style:z,children:[null!=e.title&&oo("div",{style:{fontWeight:600,marginBottom:e.entries.length?2:0},children:e.title+""}),e.entries.map(e=>ro("div",{style:{opacity:.7,fontSize:11},children:[e.key,":"," ",oo("span",{style:{fontWeight:600},children:so(e.value)})]},e.key))]})}return ro("div",{className:"semiotic-tooltip",style:z,children:[oo("div",{style:{fontWeight:600,marginBottom:2},children:so(n)}),oo("div",{style:{opacity:.7,fontSize:11},children:so(o)})]})}io.ownsChrome=!0;import{useCallback as ao}from"react";import{useCallback as lo,useRef as co}from"react";function uo(e){const t=new Map;for(const n of e){const e=n.group??"_default";let o=t.get(e);o||(o=[],t.set(e,o)),o.push(n)}for(const e of t.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const n=Array.from(t.keys()).sort((e,n)=>{const o=t.get(e),r=t.get(n);return(o.length>0?o[0].y:0)-(r.length>0?r[0].y:0)}),o=Array.from(t.values()).flat();o.sort((e,t)=>e.x-t.x||e.y-t.y);const r=new Map;for(let e=0;o.length>e;e++){o[e]._flatIndex=e;const t=o[e].datum?.id;null!=t&&r.set(t+"",e)}return{flat:o,groups:n,byGroup:t,idToIdx:r}}function ho(e,t){if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const n=Math.max(0,Math.min(t,e.flat.length-1)),o=e.flat[n];return{flatIndex:n,group:o.group??"_default",indexInGroup:o._groupIndex??0}}function po(e,t,n){const{group:o,indexInGroup:r}=t,s=n.byGroup.get(o);switch(e){case"ArrowRight":return s.length-1>r?s[r+1]._flatIndex:t.flatIndex;case"ArrowLeft":return r>0?s[r-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(o);return n.groups.length-1>e?fo(n,n.groups[e+1],s[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(o);return e>0?fo(n,n.groups[e-1],s[r]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function fo(e,t,n){const o=e.byGroup.get(t);let r=0,s=Math.abs(o[0].x-n.x);for(let e=1;o.length>e;e++){const t=Math.abs(o[e].x-n.x);s>t&&(s=t,r=e)}return o[r]._flatIndex}function yo(e){const t=[];for(const n of e)switch(n.type){case"point":t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=n.size)break;t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"glyph":{if(0>=n.size||null==n.datum)break;const e=$e(n.glyph,n.size);t.push({x:n.x+e.centerDx,y:n.y+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:"_default"});break}case"line":{const e=n,o=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.path.length>n&&o.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:o[n],shape:"circle",group:r});break}case"area":{const e=n,o=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.topPath.length>n&&o.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:o[n],shape:"circle",group:r});break}case"rect":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.group??"_default"});break;case"heatcell":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}function go(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}import{jsx as mo,jsxs as vo}from"react/jsx-runtime";var xo={top:20,right:20,bottom:30,left:40},bo=xn;function ko(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var wo=at(it(function(e,t){const{chartType:n,runtimeMode:o,data:r,chunkThreshold:s,chunkSize:i,xAccessor:a,yAccessor:l,accessorRevision:y,colorAccessor:b,sizeAccessor:k,symbolAccessor:S,symbolMap:_,groupAccessor:T,lineDataAccessor:C,curve:P,normalize:D,baseline:z,stackOrder:O,binSize:H,valueAccessor:j,arrowOfTime:$="right",windowMode:Y="sliding",windowSize:X=200,timeAccessor:V,xExtent:q,yExtent:U,extentPadding:Z=.1,scalePadding:J,sizeRange:ee,size:te=[500,300],responsiveWidth:ne,responsiveHeight:oe,margin:re,className:se,background:ie,renderMode:ae,lineStyle:le,pointStyle:ce,areaStyle:ue,barStyle:de,waterfallStyle:he,swarmStyle:pe,barColors:me,colorScheme:be,boundsAccessor:ke,boundsStyle:we,y0Accessor:Ae,band:Se,gradientFill:_e,lineGradient:Ce,areaGroups:Pe,openAccessor:Re,highAccessor:Me,lowAccessor:Ne,closeAccessor:Ie,candlestickStyle:We,showAxes:De=!0,axes:Ee,xLabel:Be,yLabel:Le,yLabelRight:Oe,xFormat:He,yFormat:Fe,axisExtent:je,tickFormatTime:$e,tickFormatValue:Ye,hoverAnnotation:Xe,tooltipContent:Ve,customHoverBehavior:Ge,customClickBehavior:qe,onObservation:Qe,annotationObservationCallback:it,chartId:at,enableHover:lt,hoverRadius:ct=30,tooltipMode:ut,annotations:dt,onAnnotationActivate:ft,autoPlaceAnnotations:gt,svgAnnotationRules:mt,showGrid:bt,legend:kt,legendHoverBehavior:wt,legendClickBehavior:Tt,legendHighlightedCategory:Ct,legendIsolatedCategories:Pt,legendPosition:Rt,legendLayout:Mt,legendCategoryAccessor:Nt,onCategoriesChange:It,backgroundGraphics:Wt,foregroundGraphics:Dt,canvasPreRenderers:zt,svgPreRenderers:Bt,title:Lt,categoryAccessor:Ot,brush:jt,onBrush:Yt,decay:Xt,pulse:Vt,transition:Gt,animate:qt,staleness:Ut,frameScheduler:Qt,clock:Kt,random:Zt,seed:Jt,paused:en=!1,suspendWhenHidden:tn=!0,heatmapAggregation:nn,heatmapXBins:on,heatmapYBins:rn,showValues:sn,heatmapValueFormat:an,marginalGraphics:cn,pointIdAccessor:un,xScaleType:hn,yScaleType:fn,accessibleTable:yn=!0,description:gn,summary:_n,linkedCrosshairName:Tn,linkedCrosshairSourceId:Rn,customLayout:Mn,onLayoutError:Nn,layoutConfig:In,layoutSelection:Wn}=e,{customHoverBehavior:Dn,customClickBehavior:En,hasClickBehavior:zn}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:o,chartType:r}){return{customHoverBehavior:ao((t,s)=>{e?.(t,s),ye({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:r,chartId:o,context:s})},[o,r,e,n]),customClickBehavior:ao((e,s)=>{t?.(e,s),fe({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:r,chartId:o,context:s})},[o,r,t,n]),hasClickBehavior:!(!t&&!n)}}({customHoverBehavior:Ge,customClickBehavior:qe,onObservation:Qe,chartId:at,chartType:"StreamXYFrame"}),Bn=st().replace(/:/g,""),Ln=Je(!1),On=Je({w:-1,h:-1}),Hn=Je(!1),Fn=R({sizeProp:te,responsiveWidth:ne,responsiveHeight:oe,userMargin:re,marginDefault:xo,title:Lt,legend:kt,legendPosition:Rt,animate:qt,transitionProp:Gt,frameScheduler:Qt,clock:Kt,random:Zt,seed:Jt,paused:en,suspendWhenHidden:tn,themeDirtyRef:Ln}),jn=N(),$n=W(),{reducedMotionRef:Yn,responsiveRef:Xn,size:Vn,currentTheme:Gn,transition:qn,introEnabled:Un,tableId:Qn,rafRef:Kn,renderFnRef:Zn,scheduleRender:Jn,frameRuntime:to}=Fn;let no=Fn.margin;if(cn){const e=60,t={...Fn.margin};cn.top&&e>t.top&&(t.top=e),cn.bottom&&e>t.bottom&&(t.bottom=e),cn.left&&e>t.left&&(t.left=e),cn.right&&e>t.right&&(t.right=e),no=t}const oo=Vn[0]-no.left-no.right,ro=Vn[1]-no.top-no.bottom,so=nt(()=>ge(r),[r]),fo=Xe??lt,[go,wo]=et(0),Ao=Je(0),[So,_o]=et(null),To=kn(Dt,Vn,no,So),Co=kn(Wt,Vn,no,So),Po=Je(null),Ro=Je(null),Mo=Je(void 0),[No,Io]=et(null),Wo=Je(bo.primary),Do=Je(function(){let e=-1,t=xn;return{resolve(n){if(!n)return xn;const o=Ue();return o===e||(t=function(e){if(!e)return xn;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),s=t.getPropertyValue("--semiotic-primary").trim(),i=o||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),l=n||t.getPropertyValue("--surface-3").trim(),c=r||t.getPropertyValue("--surface-0").trim();return i||a||n||s?{axisStroke:l||xn.axisStroke,tickText:i||xn.tickText,crosshair:i?bn(i,"66"):xn.crosshair,hoverFill:c?bn(c,"4D"):xn.hoverFill,hoverStroke:i?bn(i,"99"):xn.hoverStroke,pointRing:c||xn.pointRing,primary:s||xn.primary,background:c||xn.background}:xn}(n),e=o),t},invalidate(){e=-1}}}()),Eo=Je(!1),zo=I("StreamXYFrame"),[Bo,Lo]=et(!1),[Oo,Ho]=et([]),[Fo,jo]=et([]),$o="streaming"===o||["bar","swarm","waterfall"].includes(n),Yo=pn(nt(()=>({chartType:n,runtimeMode:$o?"streaming":"bounded",windowSize:X,windowMode:Y,arrowOfTime:$o?$:"right",extentPadding:Z,scalePadding:J,axisExtent:je,xAccessor:a,yAccessor:l,accessorRevision:y,timeAccessor:$o?V:void 0,valueAccessor:j,colorAccessor:b,sizeAccessor:k,symbolAccessor:S,symbolMap:_,groupAccessor:T||(C?"_lineGroup":void 0),categoryAccessor:Ot,lineDataAccessor:C,xScaleType:hn,yScaleType:fn,xExtent:q,yExtent:U,sizeRange:ee,binSize:H,normalize:D,baseline:z,stackOrder:O,boundsAccessor:ke,boundsStyle:we,y0Accessor:Ae,band:Se,gradientFill:!0===_e?{topOpacity:.8,bottomOpacity:.05}:!1===_e?void 0:_e,areaGroups:Pe?new Set(Pe):void 0,lineGradient:Ce,openAccessor:Re,highAccessor:Me,lowAccessor:Ne,closeAccessor:Ie,candlestickStyle:We,lineStyle:le,pointStyle:ce,areaStyle:ue,swarmStyle:pe,waterfallStyle:he,colorScheme:be,barColors:me,barStyle:de,annotations:dt,decay:Xt,pulse:Vt,transition:qn,introAnimation:Un,staleness:Ut,clock:to.now,heatmapAggregation:nn,heatmapXBins:on,heatmapYBins:rn,showValues:sn,heatmapValueFormat:an,pointIdAccessor:un,curve:P,themeCategorical:Gn?.colors?.categorical,themeSemantic:Ke(Gn),themeSequential:Gn?.colors?.sequential,themeDiverging:Gn?.colors?.diverging,customLayout:Mn,onLayoutError:Nn,layoutConfig:In,layoutMargin:no}),[n,$o,X,Y,$,Z,J,je,a,l,y,V,j,b,k,S,_,T,C,Ot,hn,fn,q,U,ee,H,D,z,O,ke,we,Ae,Se,_e,Pe,Ce,Re,Me,Ne,Ie,We,le,ce,ue,pe,he,be,me,de,dt,Xt,Vt,qn,Un,Ut,to.now,nn,on,rn,sn,an,un,P,Gn,Mn,Nn,In,no])),Xo=Je(null);Xo.current||(Xo.current=new F(Yo));const Vo=function(e,t,n,o){const r=An({accessor:t,onChange:n,readData:o}),s=An([]);return r.current={accessor:t,onChange:n,readData:o},wn(()=>{const{accessor:t,onChange:n,readData:o}=r.current;if(!n||!t)return;const i=function(e,t){if(!t)return[];const n=new Set,o=[];for(const r of e){if(!r||"object"!=typeof r)continue;const e="function"==typeof t?t(r):r[t];if(null==e)continue;const s=e+"";n.has(s)||(n.add(s),o.push(s))}return o}(e.current?o(e.current):[],t);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(i,s.current)||(s.current=i,n(i))},[e])}(Xo,Nt,It,e=>e.getData());vt(Xo,Yo,Ln,Jn),xt(Xo,Wn,Ln,Jn);const Go=Je(null);Go.current||(Go.current=new pt(e=>{const t=Xo.current;t&&t.ingest(e)&&(Ln.current=!0,Jn())},{chunkThreshold:s,chunkSize:i})),tt(()=>{Go.current?.updateChunkOptions({chunkThreshold:s,chunkSize:i})},[s,i]);const qo=ot(e=>{Go.current?.push(e)},[]),Uo=ot(e=>{Go.current?.pushMany(e)},[]),Qo=ot(()=>{Go.current?.clear(),Xo.current?.clear(),Ln.current=!0,Jn()},[Jn]);rt(t,()=>({push:qo,pushMany:Uo,remove:e=>{Go.current?.flush();const t=Xo.current?.remove(e)??[];return t.length>0&&(Po.current&&t.some(e=>e===Po.current?.data)&&(Po.current=null,Io(null)),Ln.current=!0,Jn()),t},update:(e,t)=>{Go.current?.flush();const n=Xo.current?.update(e,t)??[];return n.length>0&&(Ln.current=!0,Jn()),n},clear:Qo,getData:()=>(Go.current?.flush(),Xo.current?.getData()??[]),getScales:()=>Xo.current?.scales??null,getExtents:()=>Xo.current?.getExtents()??null,getCustomLayout:()=>Xo.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Xo.current?.lastCustomLayoutFailure??null}),[qo,Uo,Qo,Jn]),tt(()=>{if(r){if(C&&so.length>0&&"object"==typeof so[0]&&null!==so[0]){const e="string"==typeof C?C:"coordinates";if(Array.isArray(so[0][e])){const t=[];for(const n of so){const o=n[e];if(Array.isArray(o)){const e=n.label||n.id||n.key;if(null!=e)for(const n of o)t.push({...n,_lineGroup:e});else for(const e of o)t.push(e)}}return void Go.current?.setBoundedData(t)}}Go.current?.setBoundedData(so)}},[r,so,C]);const{canvasRef:Ko,interactionCanvasRef:Zo}=M(Fn,{storeRef:Xo,dirtyRef:Ln,hydrated:jn,wasHydratingFromSSR:$n,cleanup:()=>Go.current?.clear(),canvasPaintDependencies:[n,oo,ro,De,ie,Wt,le,ae,zt,Jn]}),{hoverHandlerRef:Jo,hoverLeaveRef:er,onPointerMove:tr,onPointerLeave:nr}=Fn;Jo.current=e=>{if(!fo)return;const t=Ko.current;if(!t)return;const o=t.getBoundingClientRect(),r=e.clientX-o.left-no.left,s=e.clientY-o.top-no.top;if(0>r||r>oo||0>s||s>ro)return void(Po.current&&(Po.current=null,Ro.current=null,Io(null),Dn&&(Dn(null),Ln.current=!0),Jn()));const i=Xo.current;if(!i||0===i.scene.length)return;const l=B(ct,e.pointerType),c=St(i.scene,r,s,l,i.quadtree,i.maxPointRadius),u="multi"===ut,d=()=>{Po.current&&(Po.current=null,Ro.current=null,Io(null),Dn&&Dn(null),Jn())};if(!c&&!u)return void d();const h=u||!c?r:c.x,p=u||!c?s:c.y,f=c?.datum?G(c.datum,i.resolvedRibbons):{},y=i.scales?.x?.invert,g="function"==typeof y?y(h):void 0;let m=E(f,h,p,null!=g?{xValue:g,xPx:h}:void 0);if(u&&i.scene.length>0&&i.scales){const e=function(e,t,n=30){const o=[];for(const r of e)if("line"===r.type){const e=r;if(2>e.path.length)continue;const s=_t(At(e.path,e.curve),t,n);if(null===s)continue;const i=Et(e.path,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[i]?e.datum[i]:e.datum,x:e.path[i][0],y:s,group:e.group,color:e.style.stroke})}else if("area"===r.type){const e=r;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const s=At(e.topPath,e.curve),i=At(e.bottomPath,e.curve),a=_t(s,t,n);if(null===a)continue;const l=_t(i,t,n),c=Et(e.topPath,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[c]?e.datum[c]:e.datum,x:e.topPath[c][0],y:a,y0:l??void 0,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return o}(i.scene,h,Math.max(l,oo));if(e.length>0){const t=i.scales.y.invert,o=Wo.current,r=y?y(h):h;if(c)m.xValue=r,m.xPx=h;else{const e={xValue:r};"string"==typeof a&&(e[a]=r),m=E(e,h,p,{xValue:r,xPx:h})}m.allSeries=e.map(e=>{const r=t?t(e.y):e.y,s=null!=e.y0?t?t(e.y0):e.y0:void 0;return{group:e.group||"",value:"stackedarea"===n&&null!=s?r-s:r,valuePx:e.y,color:e.color||o,datum:G(e.datum,i.resolvedRibbons)}})}}c||m.allSeries?.length?(Po.current=m,Ro.current=c?.node??null,Io(m),Dn&&(Dn(m),Ln.current=!0),Jn()):d()},er.current=()=>{Po.current&&(Po.current=null,Ro.current=null,Io(null),Dn&&(Dn(null),Ln.current=!0),Jn())};const or=Je(()=>{});or.current=e=>{if(L(e.target))return;if(!En)return;const t=Ko.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-no.left,r=e.clientY-n.top-no.top;if(0>o||o>oo||0>r||r>ro)return void En(null);const s=Xo.current;if(!s||0===s.scene.length)return void En(null);const i=B(ct,Mo.current),a=St(s.scene,o,r,i,s.quadtree,s.maxPointRadius);if(!a)return void En(null);const l=a.datum||{},c=s.scales?.x?.invert,u="function"==typeof c?c(a.x):void 0;En(E(l,a.x,a.y,null!=u?{xValue:u,xPx:a.x}:void 0),{type:"activate",inputType:Te(Mo.current)})};const rr=ot(e=>or.current(e),[]),{kbFocusIndexRef:sr,focusedNavPointRef:ir,onKeyDown:ar}=(dr={storeRef:Xo,hoverRef:Po,hoveredNodeRef:Ro,setHoverPoint:Io,customHoverBehavior:Dn,customClickBehavior:En,scheduleRender:Jn},function({storeRef:e,hoverRef:t,hoveredNodeRef:n,setHoverPoint:o,customHoverBehavior:r,customClickBehavior:s,scheduleRender:i,extractPoints:a,toHover:l}){const c=co(-1),u=co(null),d=co(null),h=lo(h=>{if(ve(h))return;const p=e.current;if(!p)return;const f=()=>{c.current=-1,u.current=null,t.current=null,n&&(n.current=null),o(null),r(null),i()};if(0===p.scene.length)return void(0>c.current||f());let y;if(d.current?.version===p.version)y=d.current.graph;else{const e=a(p.scene);if(0===e.length)return void(0>c.current||f());y=uo(e),d.current={version:p.version,graph:y}}let g=c.current;if(y.flat.length>g||(f(),g=-1),("Enter"===h.key||" "===h.key)&&g>=0)return h.preventDefault(),void s(l(y.flat[g],p),{type:"activate",inputType:"keyboard"});if(0>g){if("Escape"===h.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(h.key))return;h.preventDefault(),c.current=0;const e=y.flat[0];u.current=e;const n=l(e,p);return t.current=n,o(n),r(n,{type:"focus",inputType:"keyboard"}),void i()}const m=po(h.key,ho(y,g),y);if(null===m)return;if(h.preventDefault(),0>m)return void f();c.current=m;const v=y.flat[m];u.current=v;const x=l(v,p);t.current=x,o(x),r(x,{type:"focus",inputType:"keyboard"}),i()},[s,r,a,t,n,i,o,e,l]);return{kbFocusIndexRef:c,focusedNavPointRef:u,onKeyDown:h}}({...dr,extractPoints:yo,toHover:(e,t)=>function(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}({...e,datum:G(e.datum,t.resolvedRibbons)})})),lr=ot(e=>{Mo.current=e.pointerType,sr.current=-1,ir.current=null,tr(e)},[ir,sr,tr]),cr=ot(e=>{Mo.current="mouse",sr.current=-1,ir.current=null,tr({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[ir,sr,tr]),ur=ot(e=>{Mo.current=e.pointerType},[]);var dr;Zn.current=()=>{if(Kn.current=null,!to.isActive)return;const e=Ko.current,t=Zo.current;if(!e||!t)return;const o=Xo.current;if(!o)return;const r=to.now(),s=o.advanceTransition(Yn.current?r+1e6:r),i=!Yn.current&&s,c=On.current.w!==oo||On.current.h!==ro,u=Ln.current||s||c,d=o.consumeStylePaintPending();let h=!1;const p=o.getLastUpdateResult(),f=zo.current.beforeCompute(p,i);!u||i&&!c||(o.computeScene({width:oo,height:ro}),On.current={w:oo,h:ro},h=!0,Vo()),zo.current.afterCompute(f,h,c);const y=function(e,t,n,o){const r=o.current,s=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,i=!s&&e.hasActivePulsesAt(t),a=!(n||s||!i&&!r)&&e.refreshPulse(t);return o.current=i,{changed:a,pending:i}}(o,r,h,Hn),g=w(),m=Do.current.resolve(e);Wo.current=m.primary;const v=Ht(Ut,o.lastIngestTime>0?r-o.lastIngestTime:0),b=Ut&&v.isStale;if(u||d||y.changed){const t=A(e,Vn,no,g);if(t){if(t.clearRect(-no.left,-no.top,Vn[0],Vn[1]),Ut&&1>v.alpha&&(t.globalAlpha=v.alpha),vn(t,{background:ie,hasBackgroundGraphics:!!Wt,themeBackground:m.background,x:-no.left,y:-no.top,width:Vn[0],height:Vn[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,oo,ro),t.clip()),zt&&o.scales)for(const e of zt)t.save(),e(t,o.scene,o.scales,{width:oo,height:ro}),t.restore();const e=Mn?eo.custom:eo[n];Q({context:t,nodes:o.scene,renderMode:ae,pixelRatio:g,paintBuiltIn:n=>{if(e&&o.scales)for(const r of e)r(t,n,o.scales,{width:oo,height:ro})}}),t.restore(),Ut&&1>v.alpha&&(t.globalAlpha=1)}}const k=!!(fo&&Po.current&&o.scales),S=!!(Ro.current&&Array.isArray(Xe)&&Xe.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),_=k||S;if(_||Eo.current){const e=A(t,Vn,no,g);if(e&&(e.clearRect(-no.left,-no.top,Vn[0],Vn[1]),k&&Po.current&&function(e,t,n,o,r,s,i){if(!1===r.crosshair)return;const a=t.allSeries,l=a&&a.length>0,c=t.xPx??t.x;e.save();const u="object"==typeof r.crosshair?r.crosshair:{};if(e.strokeStyle=u.stroke||i.crosshair,e.lineWidth=u.strokeWidth||1,e.setLineDash(u.strokeDasharray?u.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(l?c:t.x,0),e.lineTo(l?c:t.x,o),e.stroke(),l||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),l){e.lineWidth=2,e.strokeStyle=i.pointRing;for(const t of a)null!=t.valuePx&&(e.beginPath(),e.arc(c,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||i.primary,e.fill(),e.stroke())}else{const n=r.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(s)||i.primary;e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=n,e.fill(),e.strokeStyle=i.pointRing,e.lineWidth=2,e.stroke()}}(e,Po.current,oo,ro,"object"==typeof fo?fo:{},Ro.current,m),S&&Ro.current&&Array.isArray(Xe))){const t=Xe.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o,r){if(!n)return;const s="group"in n?n.group:void 0;if(void 0!==s)for(const n of t){if("line"!==n.type)continue;if(n.group!==s)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?n.datum?o.style(n.datum):{}:o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||r.primary,e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=t.opacity??1,e.stroke(),e.restore()}}(e,o.scene,Ro.current,t,m)}Eo.current=_}u&&e&&e.setAttribute("aria-label",x(o.scene,n+" chart"));const T=Ln.current;if(Ln.current=T&&i&&!h,T&&o.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!So||e(So.x.domain()[0])!==e(o.scales.x.domain()[0])||e(So.x.domain()[1])!==e(o.scales.x.domain()[1])||e(So.y.domain()[0])!==e(o.scales.y.domain()[0])||e(So.y.domain()[1])!==e(o.scales.y.domain()[1])||So.x.range()[0]!==o.scales.x.range()[0]||So.x.range()[1]!==o.scales.x.range()[1]||So.y.range()[0]!==o.scales.y.range()[0]||So.y.range()[1]!==o.scales.y.range()[1])&&_o(o.scales),cn){const e=o.getData(),t="function"==typeof a?a:e=>e[a||"x"],n="function"==typeof l?l:e=>e[l||"y"];Ho(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),jo(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((dt&&dt.length>0||Mn)&&(h||i))||!h&&33>r-Ao.current||(wo(e=>e+1),Ao.current=r),Ut?.showBadge&&Lo(!!b),(i||null!=o.activeTransition||y.pending)&&Jn()},Ft(Ut,Xo,Ln,Jn,Bo,Lo);const hr=nt(()=>{if(He||$e)return;const e=Xo.current;return e?.xIsDate&&So?Cn(So.x.domain()):void 0},[He,$e,So]),pr=He||$e||hr,fr=fo&&No?Ve?Ve(No):mo(io,{hover:No}):null,yr=fr?mo(p,{x:No.x,y:No.y,containerWidth:oo,containerHeight:ro,margin:no,className:"stream-frame-tooltip",children:fr}):null,gr=ir.current,mr=mo(f,{active:sr.current>=0,hoverPoint:No,margin:no,size:Vn,shape:gr?.shape,width:gr?.w,height:gr?.h}),vr=Sn(a,V,"__semiotic_resolvedX","__semiotic_resolvedTime"),xr=Sn(l,j,"__semiotic_resolvedY","__semiotic_resolvedValue"),br=vr.key,kr=xr.key,wr=function(e,t,n){return o=>{if(!o||!n||!e.fn&&!t.fn)return o;let r=!1;const s=o.map(n=>{const o=e.fn&&e.key&&!(e.key in n),s=t.fn&&t.key&&!(t.key in n);if(!o&&!s)return n;r=!0;const i={...n};return o&&(i[e.key]=e.fn(n)),s&&(i[t.key]=t.fn(n)),i});return r?s:o}}(vr,xr,dt&&dt.length>0||!1);if(xe||!jn&&$n){const e=Xo.current;e&&r&&(e.ingest({inserts:so,bounded:!0}),e.computeScene({width:oo,height:ro}));const t=e?.scene??[],n=e?.scales??null,o=kn(Dt,Vn,no,n),s=kn(Wt,Vn,no,n),i=pr||(()=>{if(e?.xIsDate&&n)return Cn(n.x.domain())})();return vo("div",{ref:Xn,className:"stream-xy-frame"+(se?" "+se:""),role:"img","aria-label":gn||("string"==typeof Lt?Lt:"XY chart"),style:{position:"relative",width:ne?"100%":Vn[0],height:oe?"100%":Vn[1]},children:[mo(m,{summary:_n}),vo("svg",{xmlns:"http://www.w3.org/2000/svg",width:Vn[0],height:Vn[1],style:{position:"absolute",left:0,top:0},children:[mo("g",{transform:`translate(${no.left},${no.top})`,children:s}),vo("g",{transform:`translate(${no.left},${no.top})`,children:[ie&&mo("rect",{x:0,y:0,width:oo,height:ro,fill:ie}),Bt&&n&&Bt.map((e,o)=>mo(Ze.Fragment,{children:e(t,n,{width:oo,height:ro})},"svgpre-"+o)),t.map((e,t)=>K({node:e,index:t,renderMode:ae,fallback:()=>ze(e,t,Bn)})).filter(Boolean)]})]}),mo(dn,{width:oo,height:ro,totalWidth:Vn[0],totalHeight:Vn[1],margin:no,scales:n,showAxes:De,axes:Ee,xLabel:Be,yLabel:Le,yLabelRight:Oe,xFormat:i,yFormat:Fe||Ye,axisExtent:je,showGrid:bt,title:Lt,legend:kt,legendHoverBehavior:wt,legendClickBehavior:Tt,legendHighlightedCategory:Ct,legendIsolatedCategories:Pt,legendPosition:Rt,legendLayout:Mt,foregroundGraphics:yt(o,c(Xo.current?.customLayoutOverlays,Wn??null)),marginalGraphics:cn,xValues:[],yValues:[],annotations:dt,onAnnotationActivate:ft,onObservation:it??Qe,chartId:at,chartType:"StreamXYFrame",autoPlaceAnnotations:gt,svgAnnotationRules:mt,annotationFrame:0,xAccessor:br,yAccessor:kr,annotationData:wr(Xo.current?.getData()),pointNodes:Pn(Xo.current?.scene),curve:"string"==typeof P?P:void 0,linkedCrosshairName:Tn,linkedCrosshairSourceId:Rn})]})}return vo("div",{ref:Xn,className:"stream-xy-frame"+(se?" "+se:""),role:"group","aria-label":gn||("string"==typeof Lt?Lt:"XY chart"),tabIndex:0,style:{position:"relative",width:ne?"100%":Vn[0],height:oe?"100%":Vn[1],overflow:"visible",touchAction:ko(jt)},onKeyDown:ar,children:["production"!==process.env.NODE_ENV&&Xo.current&&mo(g,{store:Xo.current,diagnostics:zo.current}),yn&&mo(v,{tableId:Qn}),yn&&mo(u,{scene:Xo.current?.scene??[],chartType:n+" chart",tableId:Qn,chartTitle:"string"==typeof Lt?Lt:void 0}),mo(m,{summary:_n}),mo(d,{hoverPoint:No}),vo("div",{role:"img","aria-label":gn||("string"==typeof Lt?Lt:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:fo?lr:void 0,onMouseMove:fo?cr:void 0,onPointerLeave:fo?nr:void 0,onMouseLeave:fo?nr:void 0,onPointerDown:fo||zn?ur:void 0,onClick:zn?rr:void 0,children:[mo(h,{size:Vn,margin:no,children:Co}),mo(ln,{width:oo,height:ro,totalWidth:Vn[0],totalHeight:Vn[1],margin:no,scales:So,showAxes:De,axes:Ee,showGrid:bt,xFormat:pr,yFormat:Fe||Ye,axisExtent:je}),mo("canvas",{ref:Ko,"aria-label":x(Xo.current?.scene??[],n+" chart"),style:{position:"absolute",left:0,top:0}}),mo("canvas",{ref:Zo,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),mo(dn,{width:oo,height:ro,totalWidth:Vn[0],totalHeight:Vn[1],margin:no,scales:So,showAxes:De,axes:Ee,xLabel:Be,yLabel:Le,yLabelRight:Oe,xFormat:pr,yFormat:Fe||Ye,axisExtent:je,showGrid:bt,title:Lt,legend:kt,legendHoverBehavior:wt,legendClickBehavior:Tt,legendHighlightedCategory:Ct,legendIsolatedCategories:Pt,legendPosition:Rt,legendLayout:Mt,foregroundGraphics:yt(To,c(Xo.current?.customLayoutOverlays,Wn??null)),marginalGraphics:cn,xValues:Oo,yValues:Fo,annotations:dt,onAnnotationActivate:ft,onObservation:it??Qe,chartId:at,chartType:"StreamXYFrame",autoPlaceAnnotations:gt,svgAnnotationRules:mt,annotationFrame:go,xAccessor:br,yAccessor:kr,annotationData:wr(Xo.current?.getData()),pointNodes:Pn(Xo.current?.scene),curve:"string"==typeof P?P:void 0,underlayRendered:!0,canvasObscuresUnderlay:!!mn({background:ie,hasBackgroundGraphics:!!Wt,themeBackground:Gn?.colors.background}),linkedCrosshairName:Tn,linkedCrosshairSourceId:Rn}),(jt||Yt)&&mo(ht,{width:oo,height:ro,totalWidth:Vn[0],totalHeight:Vn[1],margin:no,dimension:jt?.dimension??"xy",scales:So,onBrush:Yt??(()=>{}),binSize:H,snap:jt?.snap,binBoundaries:jt?.binBoundaries??("bar"===n?Xo.current?.getBinBoundaries():void 0),snapDuring:jt?.snapDuring,streaming:"streaming"===o}),Ut?.showBadge&&mo($t,{isStale:Bo,position:Ut.badgePosition}),mr,yr]})]})}));wo.displayName="StreamXYFrame";var Ao=wo;import{useRef as So,useState as _o,useEffect as To,useMemo as Co,useCallback as Po,useImperativeHandle as Ro,forwardRef as Mo,memo as No}from"react";var Io={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Wo={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},Do=class{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e,t=Math.random){const n=this._freeIndices.pop();if(void 0===n)return null;const o=this.particles[n];return o.active=!0,o.t=0,o.offset=t()-.5,o.edgeIndex=e,o.x=0,o.y=0,o}step(e,t,n,o){for(let r=0;this.capacity>r;r++){const s=this.particles[r];if(!s.active)continue;const i=n[s.edgeIndex];i&&i.bezier?(s.t+=e*t*(o?o[s.edgeIndex]??1:1)*(i.bezier.circular?.3:1),1>s.t?Eo(i.bezier,s.t,s.offset,s):(s.active=!1,this._freeIndices.push(r))):(s.active=!1,this._freeIndices.push(r))}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)t.length>n?this.particles[n]=t[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=e}};function Eo(e,t,n,o){if(e.circular&&e.segments)return void function(e,t,n,o,r){const s=e.length,i=t*s,a=Math.min(Math.floor(i),s-1),l=i-a,[c,u,d,h]=e[a];zo(c,u,d,h,l,r);const p=h.x-c.x,f=h.y-c.y,y=Math.sqrt(p*p+f*f);if(y>.001){const e=p/y;r.x+=-f/y*n*o*2,r.y+=e*n*o*2}}(e.segments,t,n,e.halfWidth,o);if(!e.points)return o.x=0,void(o.y=0);const[r,s,i,a]=e.points;zo(r,s,i,a,t,o);const l=a.x-r.x,c=a.y-r.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;o.x+=-c/u*n*e.halfWidth*2,o.y+=t*n*e.halfWidth*2}}function zo(e,t,n,o,r,s){const i=1-r,a=i*i,l=a*i,c=r*r,u=c*r;s.x=l*e.x+3*a*r*t.x+3*i*c*n.x+u*o.x,s.y=l*e.y+3*a*r*t.y+3*i*c*n.y+u*o.y}import{quadtree as Bo}from"d3-quadtree";function Lo(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function Oo(e){if(!e||"object"!=typeof e)return!1;const t=e;if("boolean"!=typeof t.circular)return!1;if("number"!=typeof t.halfWidth||!Number.isFinite(t.halfWidth))return!1;if(t.circular){if(!Array.isArray(t.segments)||0===t.segments.length)return!1;for(const e of t.segments)if(!Ho(e))return!1;return!0}return Ho(t.points)}function Ho(e){if(!Array.isArray(e)||4!==e.length)return!1;for(const t of e){if(!t||"object"!=typeof t)return!1;const e=t;if("number"!=typeof e.x||!Number.isFinite(e.x))return!1;if("number"!=typeof e.y||!Number.isFinite(e.y))return!1}return!0}import{interpolateNumber as Fo}from"d3-interpolate";var jo="rgba(34, 197, 94, 0.7)",$o=2e3,Yo=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Xo=["scene-style","data-paint","accessibility","evidence"],Vo=(e,t)=>({retainedData:e,invalidations:t}),Go=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],qo=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Uo=["scene-geometry","data-paint","overlay","accessibility","evidence"],Qo=["scene-style","data-paint","accessibility","evidence"],Ko=["scene-geometry","data-paint","overlay","accessibility","evidence"],Zo=[],Jo={chartType:Vo("rebuild",Go),nodeIDAccessor:Vo("rebuild",Go),sourceAccessor:Vo("rebuild",Go),targetAccessor:Vo("rebuild",Go),valueAccessor:Vo("rebuild",Go),edgeIdAccessor:Vo("rebuild",Go),childrenAccessor:Vo("rebuild",Go),hierarchySum:Vo("rebuild",Go),orientation:Vo("preserve",qo),nodeAlign:Vo("preserve",qo),nodePaddingRatio:Vo("preserve",qo),nodeWidth:Vo("preserve",qo),edgeSort:Vo("preserve",qo),iterations:Vo("preserve",qo),forceStrength:Vo("preserve",qo),padAngle:Vo("preserve",qo),groupWidth:Vo("preserve",qo),sortGroups:Vo("preserve",qo),treeOrientation:Vo("preserve",qo),edgeType:Vo("preserve",qo),padding:Vo("preserve",qo),paddingTop:Vo("preserve",qo),orbitMode:Vo("preserve",qo),orbitSize:Vo("preserve",qo),orbitSpeed:Vo("preserve",qo),orbitRevolution:Vo("preserve",qo),orbitRevolutionStyle:Vo("preserve",qo),orbitEccentricity:Vo("preserve",qo),orbitShowRings:Vo("preserve",qo),orbitAnimated:Vo("preserve",qo),customNetworkLayout:Vo("preserve",qo),layoutConfig:Vo("preserve",qo),nodeSize:Vo("preserve",Uo),nodeSizeRange:Vo("preserve",Uo),colorByDepth:Vo("preserve",Uo),nodeLabel:Vo("preserve",Ko),showLabels:Vo("preserve",Ko),labelMode:Vo("preserve",Ko),nodeStyle:Vo("preserve",Qo),edgeStyle:Vo("preserve",Qo),colorBy:Vo("preserve",Qo),colorScheme:Vo("preserve",Qo),themeCategorical:Vo("preserve",Qo),themeSemantic:Vo("preserve",Qo),edgeColorBy:Vo("preserve",Qo),edgeOpacity:Vo("preserve",Qo),showParticles:Vo("preserve",Qo),particleStyle:Vo("preserve",Qo),decay:Vo("preserve",Qo),pulse:Vo("preserve",Qo),thresholds:Vo("preserve",Qo),staleness:Vo("preserve",Qo),layoutSelection:Vo("preserve",Qo),clock:Vo("preserve",Zo),random:Vo("preserve",Zo),seed:Vo("preserve",Zo),tensionConfig:Vo("preserve",Zo),transition:Vo("preserve",Zo),introAnimation:Vo("preserve",Zo),onLayoutError:Vo("preserve",Zo),__skipForceSimulation:Vo("preserve",Zo),__hierarchyRoot:Vo("preserve",Zo),__orbitState:Vo("preserve",Zo),__previousPositions:Vo("preserve",Zo)},er=Vo("preserve",qo),tr=class{constructor(){this.tracker=new Oe}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},Yo)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Xo):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const o of e){const e=Jo[o]??er;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},nr=class e{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this.customLayoutHtmlMarks=[],this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._nodeQuadtree=null,this._maxNodeRadius=0,this._sceneNodesRevision=0,this._nodeQuadtreeRevision=-1,this._nodesArrCache=null,this._edgesArrCache=null,this._arrCacheVersion=-1,this.particlePool=null,this.updateResults=new tr,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this._decayAgeMap=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._networkDecayCache=null,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig={...Io,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new Do(2e3))}currentTime(){return this.config.clock?.()??_e()}updateConfig(e){const t=this.config,n={...t,...e};t.__orbitState&&(n.__orbitState=t.__orbitState),t.__hierarchyRoot&&(n.__hierarchyRoot=t.__hierarchyRoot),void 0===e.layoutSelection&&null!=t.layoutSelection&&(n.layoutSelection=t.layoutSelection);const o=[...new Set([...Object.keys(t),...Object.keys(n)])].filter(e=>t[e]!==n[e]);this.config=n,this.tensionConfig={...Io,...n.tensionConfig},!n.showParticles||"sankey"!==n.chartType&&!n.customNetworkLayout||this.particlePool||(this.particlePool=new Do(2e3)),this.updateResults.recordConfig(o)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null,this.updateResults.recordData("replace",1)}ingestBounded(e,t,n,o){const{nodeIDAccessor:r="id",sourceAccessor:s="source",targetAccessor:i="target",valueAccessor:a="value"}=this.config,l="function"==typeof r?r:e=>e[r],c="function"==typeof s?s:e=>e[s],u="function"==typeof i?i:e=>e[i],d="function"==typeof a?a:e=>e[a]??1;this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const t of e){const e=l(t)+"";this.nodes.set(e,{...Lo(e),data:t})}for(let e=0;t.length>e;e++){const n=t[e],o=c(n)+"",r=u(n)+"",s=d(n),i=null==s?NaN:Number(s),a=Number.isFinite(i)?i:1;this.nodes.has(o)||this.nodes.set(o,{...Lo(o),data:n}),this.nodes.has(r)||this.nodes.set(r,{...Lo(r),data:n});const l=`${o}\0${r}\0${e}`,h={source:o,target:r,value:a,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:l};n&&"object"==typeof n&&Oo(n.bezier)&&(h.bezier=n.bezier),this.edges.set(l,h)}o?.deferLayout||this.runLayout(n),this.updateResults.recordData("replace",e.length+t.length)}ingestBoundedWithResult(e,t,n,o){return this.ingestBounded(e,t,n,o),this.updateResults.last}applyForceLayoutPositions(e,t){for(const[t,n]of Object.entries(e)){const e=this.nodes.get(t);e&&(e.x=n.x,e.y=n.y)}this.config.__skipForceSimulation=!0;try{this.runLayout(t)}finally{this.config.__skipForceSimulation=void 0}}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:o}=e,r=0===this.nodes.size;let s=!1;const i=this.currentTime();this.lastIngestTime=i,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,Lo(t)),this.nodeTimestamps.set(t,i),this.tension+=this.tensionConfig.newNode,s=!0),this.nodes.has(n)||(this.nodes.set(n,Lo(n)),this.nodeTimestamps.set(n,i),this.tension+=this.tensionConfig.newNode,s=!0);const a=this.edgeKey(t,n),l=this.edges.get(a);let c=!1;l?(l.value+=o,this.edgeTimestamps.set(a,i),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:t,target:n,value:o,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,i),this.tension+=this.tensionConfig.newEdge,s=!0);const u=r||s||c||this.tension>=this.tensionConfig.threshold;return this.updateResults.recordData("ingest",1),u}ingestEdgeWithResult(e){return this.ingestEdge(e),this.updateResults.last}runLayout(e){if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const t=q(this.config.chartType);if(!t)return;let n=Array.from(this.nodes.values());const o=Array.from(this.edges.values());if(0===n.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.supportsStreaming&&!t.hierarchical){const e=new Map;for(const t of n)void 0!==t._prevX0?e.set(t.id,{x:(t._prevX0??0)+((t._prevX1??0)-(t._prevX0??0))/2,y:(t._prevY0??0)+((t._prevY1??0)-(t._prevY0??0))/2}):0===t.x&&0===t.y||e.set(t.id,{x:t.x,y:t.y});if(this._lastPositionSnapshot)for(const[t,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);this.config.__previousPositions=e.size>0?e:void 0}if(t.computeLayout(n,o,this.config,e),this.config.__previousPositions=void 0,t.hierarchical&&n.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const e of n)this.nodes.set(e.id,e);for(let e=0;o.length>e;e++){const t=o[e],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const n=e.get(t.id);n&&(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,n=Array.from(this.nodes.values())}this.finalizeLayout();const r=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||r.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=r,this.saveTargetPositions();const s=n.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),i=this.config.transition?.duration??this.tensionConfig.transitionDuration,a=["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType);if(!this._hasRenderedOnce&&this.config.introAnimation&&a&&n.length>0&&i>0){const t=e[0]/2,n=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=n,e._prevY1=n;for(const e of this.edges.values())e._prevY0=n,e._prevY1=n,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:i}}else s&&i>0&&(this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:i});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime=this.currentTime()),this.previousNodeIds=e,this.previousEdgeKeys=t}restyleScene(e){const t=function({nodes:e,edges:t,restyle:n,restyleEdge:o,baseStyles:r,selection:s}){const i=!(!n&&!o);if(n)for(const t of e){const e=r.get(t)??t.style,o=n(t,s);t.style=o?{...e,...o}:e}if(o)for(const e of t){const t=r.get(e)??e.style,n=o(e,s);e.style=n?{...t,...n}:t}return i}({nodes:this.sceneNodes,edges:this.sceneEdges,restyle:this._customRestyle,restyleEdge:this._customRestyleEdge,baseStyles:this._baseStyles,selection:e});this.markStylePaintPending(),this.updateResults.recordRestyle(t)}buildScene(e){if(this.config.customNetworkLayout){const t=function({config:e,customLayout:t,size:n,nodes:o,edges:r,previousResult:s,revision:i}){const a=Re(e.colorScheme,e.themeCategorical,Xe),l={nodes:o,edges:r,dimensions:{width:n[0],height:n[1],plot:{x:0,y:0,width:n[0],height:n[1]}},theme:{semantic:e.themeSemantic??{},categorical:[...a]},resolveColor:ue(a,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};try{return{kind:"success",result:t(l)}}catch(t){const n=null!==s,o=X("network",t,n,i);"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t);try{e.onLayoutError?.(o)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:o,preservedLastGoodScene:n}}}({config:this.config,customLayout:this.config.customNetworkLayout,size:e,nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values()),previousResult:this.lastCustomLayoutResult,revision:this.layoutVersion});if("failure"===t.kind)return this.lastCustomLayoutFailure=t.diagnostic,void(t.preservedLastGoodScene||(this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._sceneNodesRevision++));const n=t.result;return this.sceneNodes=n.sceneNodes??[],this.sceneEdges=n.sceneEdges??[],this.labels=n.labels??[],this.customLayoutOverlays=n.overlays??null,this.customLayoutHtmlMarks=n.htmlMarks??[],this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=n.restyle,this._customRestyleEdge=n.restyleEdge,this.hasCustomRestyle=!(!n.restyle&&!n.restyleEdge),this.hasCustomRestyle&&(this._baseStyles=function(e,t){const n=new WeakMap;for(const t of e)n.set(t,t.style);for(const e of t)n.set(e,e.style);return n}(this.sceneNodes,this.sceneEdges),this.restyleScene(this.config.layoutSelection??null)),void ne({label:"customNetworkLayout",nodes:this.sceneNodes,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned})}this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null;const t=q(this.config.chartType);if(!t)return void this._sceneNodesRevision++;const n=t.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=t.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:r,sceneEdges:s,labels:i}=t.buildScene(n,o,this.config,e);this.sceneNodes=r,this.sceneEdges=s,this.labels=i,this._sceneNodesRevision++}rebuildNodeQuadtree(){let t=0,n=0;for(const e of this.sceneNodes)"circle"===e.type&&(t++,e.r>n&&(n=e.r));if(this._maxNodeRadius=n,e.QUADTREE_THRESHOLD>=t)return void(this._nodeQuadtree=null);const o=Array(t);let r=0;for(const e of this.sceneNodes)"circle"===e.type&&(o[r++]=e);this._nodeQuadtree=Bo().x(e=>e.cx).y(e=>e.cy).addAll(o)}get nodeQuadtree(){return this._nodeQuadtreeRevision!==this._sceneNodesRevision&&(this.rebuildNodeQuadtree(),this._nodeQuadtreeRevision=this._sceneNodesRevision),this._nodeQuadtree}get maxNodeRadius(){return this._maxNodeRadius}_ensureArrays(){this._arrCacheVersion===this.layoutVersion&&this._nodesArrCache&&this._edgesArrCache||(this._nodesArrCache=Array.from(this.nodes.values()),this._edgesArrCache=Array.from(this.edges.values()),this._arrCacheVersion=this.layoutVersion)}get nodesArray(){return this._ensureArrays(),this._nodesArrCache}get edgesArray(){return this._ensureArrays(),this._edgesArrCache}get isAnimating(){const e=q(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=q(this.config.chartType);if(!n?.tick)return!1;const o=n.hierarchical?Array.from(this.nodes.values()):this.nodesArray,r=n.hierarchical?Array.from(this.edges.values()):this.edgesArray;return n.tick(o,r,this.config,e,t)}cancelIntroAnimation(){this.transition=null;for(const e of this.nodes.values())e._prevX0=void 0,e._prevX1=void 0,e._prevY0=void 0,e._prevY1=void 0;for(const e of this.edges.values())e._prevY0=void 0,e._prevY1=void 0,e._prevSankeyWidth=void 0,e._introFromZero=!1}advanceTransition(e){if(!this.transition)return!1;const t=pe(e,this.transition),n=he(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=be(e._prevX0,e._targetX0,n),e.x1=be(e._prevX1,e._targetX1,n),e.y0=be(e._prevY0,e._targetY0,n),e.y1=be(e._prevY1,e._targetY1,n));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=be(e._prevY0,e._targetY0,n),e.y1=be(e._prevY1,e._targetY1,n),e.sankeyWidth=be(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const n=e?.get(t.id);n&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const n=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(n){e._prevY0=n.y0,e._prevY1=n.y1,e._prevSankeyWidth=n.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){!function(e,t,n=.5){const o="string"==typeof e.source?t.get(e.source):e.source,r="string"==typeof e.target?t.get(e.target):e.target;!o||!r||(e.bezier=e.circular&&e.circularPathData?function(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),o=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-o,y:n.targetY},{x:n.targetX-.66*o,y:n.targetY},{x:n.targetX-.33*o,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let o;o="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const r=[];for(let e=0;o.length-1>e;e++){const t=o[e],n=o[e+1],s=n.x-t.x,i=n.y-t.y;r.push([t,{x:t.x+s/3,y:t.y+i/3},{x:t.x+2*s/3,y:t.y+2*i/3},n])}return{circular:!0,segments:r,halfWidth:t}}(e):function(e,t,n,o=.5){const r=(e.sankeyWidth||1)/2;if("down"===e.direction){const s=t.x1,i=n.x0,a=Fo(s,i);return{circular:!1,points:[{x:e.y0,y:s},{x:e.y0,y:a(o)},{x:e.y1,y:a(1-o)},{x:e.y1,y:i}],halfWidth:r}}const s=t.x1,i=n.x0,a=Fo(s,i);return{circular:!1,points:[{x:s,y:e.y0},{x:a(o),y:e.y0},{x:a(1-o),y:e.y1},{x:i,y:e.y1}],halfWidth:r}}(e,o,r,n))}(e,this.nodes,.5)}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){!function(e){const t=e.pulse;if(!t)return;const n=t.duration??500,o=t.color??"rgba(255,255,255,0.6)",r=t.glowRadius??4,{now:s}=e;for(const t of e.sceneNodes){const i=t.id;if(!i)continue;const a=e.nodeTimestamps.get(i);if(!a)continue;const l=s-a;n>l&&(t._pulseIntensity=1-l/n,t._pulseColor=o,t._pulseGlowRadius=r)}for(const t of e.sceneEdges){const r=t.datum;if(!r)continue;const i="object"==typeof r.source?r.source?.id:r.source,a="object"==typeof r.target?r.target?.id:r.target;if(!i||!a)continue;const l=e.edgeTimestamps.get(`${i}\0${a}`);if(!l)continue;const c=s-l;n>c&&(t._pulseIntensity=1-c/n,t._pulseColor=o)}}({sceneNodes:this.sceneNodes,sceneEdges:this.sceneEdges,nodeTimestamps:this.nodeTimestamps,edgeTimestamps:this.edgeTimestamps,pulse:this.config.pulse,now:e})}applyDecay(){this._networkDecayCache||(this._networkDecayCache={sortedNodes:null,ageMap:null}),this._decaySortedNodes||(this._networkDecayCache.sortedNodes=null,this._networkDecayCache.ageMap=null),function(e){const t=e.decay;if(!t)return;const n=e.nodeTimestamps.size;if(1>=n)return;if(!e.cache.sortedNodes){e.cache.sortedNodes=Array.from(e.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]);const t=new Map;for(let n=0;e.cache.sortedNodes.length>n;n++)t.set(e.cache.sortedNodes[n][0],n);e.cache.ageMap=t}const o=e.cache.ageMap;for(const r of e.sceneNodes){const e=r.id;if(!e)continue;const s=o.get(e);if(void 0===s)continue;const i=Y(t,s,n);r.style={...r.style,opacity:(r.style?.opacity??1)*i}}}({sceneNodes:this.sceneNodes,nodeTimestamps:this.nodeTimestamps,decay:this.config.decay,cache:this._networkDecayCache}),this._decaySortedNodes=this._networkDecayCache.sortedNodes,this._decayAgeMap=this._networkDecayCache.ageMap}applyTopologyDiff(e){!function(e){for(const t of e.sceneNodes)t._pulseColor===jo&&(t._pulseIntensity=0,t._pulseColor=void 0,t._pulseGlowRadius=void 0);if(0===e.addedNodes.size)return;const t=e.now-e.lastTopologyChangeTime;if(t>=$o)return;const n=1-t/$o;for(const t of e.sceneNodes){const o=t.id;o&&e.addedNodes.has(o)&&(t._pulseIntensity=Math.max(t._pulseIntensity??0,n),t._pulseColor=jo,t._pulseGlowRadius=8)}}({sceneNodes:this.sceneNodes,addedNodes:this.addedNodes,lastTopologyChangeTime:this.lastTopologyChangeTime,now:e})}get hasActiveTopologyDiff(){return function(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){return 0!==e.size&&$o>n-t}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(e){!function(e){const t=e.thresholds;if(!t)return;const n=t.warningColor??"#f59e0b",o=t.criticalColor??"#ef4444",r=!1!==t.pulse;for(const s of e.sceneNodes){const i=s.id;if(!i)continue;const a=e.nodes.get(i);if(!a)continue;const l=t.metric(a);let c=null;void 0===t.critical||t.critical>l?void 0===t.warning||t.warning>l||(c=n):c=o,c&&(s.style={...s.style,fill:c},r&&(s._pulseIntensity=.6+.4*Math.sin(e.now/300),s._pulseColor=c,s._pulseGlowRadius=6))}}({sceneNodes:this.sceneNodes,nodes:this.nodes,thresholds:this.config.thresholds,now:e})}get hasActiveThresholds(){return function(e,t){if(!t)return!1;for(const n of e){const e=t.metric(n);if(void 0!==t.warning&&e>=t.warning||void 0!==t.critical&&e>=t.critical)return!0}return!1}(this.nodes.values(),this.config.thresholds)}get hasActivePulses(){return function(e){const t=e.pulse;if(!t||0===e.lastIngestTime)return!1;const n=e.now??("undefined"!=typeof performance?performance.now():Date.now());return(t.duration??500)>n-e.lastIngestTime}({pulse:this.config.pulse,lastIngestTime:this.lastIngestTime})}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){const n=this.nodes.get(e);if(!n)return this.updateResults.recordNoop("update"),null;const o=n.data?{...n.data}:{};return n.data=t(n.data??{}),this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",1),o}updateEdge(e,t,n){const o=this.config.valueAccessor,r="function"==typeof o?o:o?e=>e[o]:e=>e.value,s=[];for(const[,o]of this.edges)if(("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t){s.push(o.data?{...o.data}:{}),o.data=n(o.data??{});const e=r(o.data);null!=e&&(o.value=Number(e))}return s.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",s.length)):this.updateResults.recordNoop("update"),s}removeNode(e){if(!this.nodes.has(e))return this.updateResults.recordNoop("remove"),!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",1),!0}removeEdge(e,t){const n=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const o="function"==typeof t?t:e=>e?.[t];for(const[t,r]of this.edges)r.data&&o(r.data)===e&&n.push(t)}else for(const[o,r]of this.edges)("string"==typeof r.source?r.source:r.source.id)===e&&("string"==typeof r.target?r.target:r.target.id)===t&&n.push(o);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",n.length)):this.updateResults.recordNoop("remove"),n.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null,this._decayAgeMap=null,this._nodeQuadtree=null,this._nodesArrCache=null,this._edgesArrCache=null,this._sceneNodesRevision++,this.tension=0,this.layoutVersion++,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.customLayoutHtmlMarks=[],this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this._customRestyleEdge=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.particlePool&&this.particlePool.clear(),this.updateResults.recordData("clear")}};nr.QUADTREE_THRESHOLD=500;var or=nr;j(or);import*as rr from"react";import{Fragment as sr,jsx as ir,jsxs as ar}from"react/jsx-runtime";function lr(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:s,labels:i,title:a,legend:l,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:p="right",legendLayout:f,foregroundGraphics:y,sceneNodes:g,annotations:m,onAnnotationActivate:v,onObservation:x,chartId:b,chartType:w,autoPlaceAnnotations:A,svgAnnotationRules:_}=e,C=H({onAnnotationActivate:v,onObservation:x,chartId:b,chartType:w}),P=rr.useMemo(()=>{const e=(g||[]).flatMap(e=>{const t=function(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){const t=e.cx??e.x,n=e.cy??e.y;if("number"!=typeof t||"number"!=typeof n)return null;const o=$e(e.glyph,e.size);return{x:t+o.centerDx,y:n+o.centerDy,r:Math.max(1,o.radius)}}const t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),n=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof n?null:{x:t,y:n,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,Ge(e.size)):Math.max(1,e.w??0,e.h??0)/2}}(e),n=function(e){const t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}(e);return t?[{pointId:n,...t}]:[]});return{scales:null,width:t,height:n,frameType:"network",pointNodes:e,sceneNodes:g}},[n,g,t]),R=rr.useMemo(()=>m&&A?He({annotations:m,context:P,..."object"==typeof A?A:{}}):m,[m,A,P]),M=rr.useMemo(()=>k("network"),[]),N=R?S(R.filter(e=>"widget"!==e.type),M,_,P):null,I=!0===R?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return ar(sr,{children:[I&&ir("style",{children:se},"annotation-widget-disclosure-style"),ar("svg",{role:"img",width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[ir("title",{children:"string"==typeof a?a:"Network Chart"}),ir("desc",{children:"string"==typeof a?a+" (network data visualization)":"Network data visualization"}),ar("g",{transform:`translate(${s.left},${s.top})`,children:[i.map((e,t)=>ir("text",{x:e.x,y:e.y,textAnchor:e.anchor||"start",dominantBaseline:e.baseline||"middle",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,style:{pointerEvents:"none"},children:e.text},"label-"+t)),N,y]}),a&&"string"==typeof a?ir("text",{x:o/2,y:ae,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:a}):a?ir("foreignObject",{x:0,y:0,width:o,height:s.top,children:a}):null,T({legend:l,totalWidth:o,totalHeight:r,margin:s,legendPosition:p,title:a,legendLayout:f,legendHoverBehavior:c,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})]}),R?.filter(e=>"widget"===e.type&&e.nodeId&&g).map((e,t)=>{const n=!0===e._annotationDeferred,o=g.find(t=>t.id===e.nodeId||t.datum?.id===e.nodeId||t.datum?.data?.id===e.nodeId||t.datum?.data?.name===e.nodeId);if(!o)return null;const r=s.left+(o.cx??(null!=o.x&&null!=o.w?o.x+o.w/2:o.x??0)),i=s.top+(o.cy??(null!=o.y&&null!=o.h?o.y+o.h/2:o.y??0)),a=e.dx??0,l=e.dy??-16,c=e.width??32,u=e.height??32,d=e.content??ir("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return ir("div",{...D(e,C),className:n?"annotation-deferred":void 0,"data-annotation-disclosure":n?"deferred":void 0,style:{position:"absolute",left:r+a-c/2,top:i+l-u/2,width:c,height:u,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:d},"widget-"+t)})]})}lr.displayName="NetworkSVGOverlay";import*as cr from"react";import{jsx as ur}from"react/jsx-runtime";var dr={position:"absolute",top:0,left:0,pointerEvents:"none"};function hr({marks:e,margin:t,selection:n=null,overscan:o=400}){const s=cr.useRef(null),i=function(e,t,n){const[o,r]=cr.useState(null);return cr.useLayoutEffect(()=>{const e=t.current,n=function(e){let t=e?.parentElement??null;for(;t;){const{overflow:e,overflowX:n,overflowY:o}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(`${e} ${o} ${n}`))return t;t=t.parentElement}return null}(e);if(!e||!n)return void r(null);let o=0;const s=()=>{o=0;const t=n.getBoundingClientRect(),s=e.getBoundingClientRect();r(0!==t.width&&0!==t.height?{scroll:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},originX:s.left,originY:s.top}:null)},i=()=>{0===o&&(o=window.requestAnimationFrame(s))};s(),n.addEventListener("scroll",i,{passive:!0});const a=new ResizeObserver(i);return a.observe(n),()=>{0!==o&&window.cancelAnimationFrame(o),n.removeEventListener("scroll",i),a.disconnect()}},[t,e,n]),cr.useMemo(()=>{if(!e||!o)return e;const{scroll:t,originX:r,originY:s}=o,i=t.left-n,a=t.right+n,l=t.top-n,c=t.bottom+n;return e.filter(e=>{const t=r+e.x,n=s+e.y;return!(i>t+e.width||t>a||l>n+e.height||n>c)})},[e,o,n])}(e,s,o);if(!e||0===e.length)return null;const a=ur("div",{className:"semiotic-network-html-marks",ref:s,style:{...dr,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>ur("div",{className:"semiotic-network-html-mark","data-mark-id":e.id,style:{position:"absolute",transform:`translate(${e.x}px, ${e.y}px)`,width:e.width,height:e.height,pointerEvents:"none"},children:e.content},e.id))});return null!=n?ur(r,{value:n,children:a}):a}import{jsx as pr,jsxs as fr}from"react/jsx-runtime";function yr({props:e,store:t,responsiveRef:n,size:o,margin:r,adjustedWidth:s,adjustedHeight:i,resolvedBackground:a,resolvedForeground:l}){const{chartType:u,nodes:d,edges:h,data:p,className:f,description:y,title:g,responsiveWidth:v,responsiveHeight:x,summary:b,background:k,renderMode:w,legend:A,legendPosition:S,legendLayout:_,legendHoverBehavior:T,legendClickBehavior:C,legendHighlightedCategory:P,legendIsolatedCategories:R,layoutSelection:M,annotations:N,onAnnotationActivate:I,annotationObservationCallback:W,onObservation:D,chartId:E,autoPlaceAnnotations:z,svgAnnotationRules:B}=e;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(u),n=e?p||(Array.isArray(h)?void 0:h):void 0;if(e&&n)t.ingestHierarchy(n,[s,i]),t.buildScene([s,i]);else{const e=ge(d),n=Array.isArray(h)?ge(h):[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[s,i]),t.buildScene([s,i]))}}const L=t?.sceneNodes??[],O=t?.sceneEdges??[],H=t?.labels??[];return fr("div",{ref:n,className:"stream-network-frame"+(f?" "+f:""),role:"img","aria-label":y||("string"==typeof g?g:"Network chart"),style:{position:"relative",width:v?"100%":o[0],height:x?"100%":o[1]},children:[pr(m,{summary:b}),fr("svg",{xmlns:"http://www.w3.org/2000/svg",width:o[0],height:o[1],style:{position:"absolute",left:0,top:0},children:[a&&pr("g",{transform:`translate(${r.left},${r.top})`,children:a}),fr("g",{transform:`translate(${r.left},${r.top})`,children:[k&&pr("rect",{x:0,y:0,width:s,height:i,fill:k}),O.map((e,t)=>K({node:e,index:t,renderMode:w,fallback:()=>we(e,t)})).filter(Boolean),L.map((e,t)=>K({node:e,index:t,renderMode:w,fallback:()=>Ae(e,t)})).filter(Boolean),H.map((e,t)=>ke(e,t)).filter(Boolean)]})]}),pr(lr,{width:s,height:i,totalWidth:o[0],totalHeight:o[1],margin:r,labels:H,sceneNodes:L,title:g,legend:A,legendPosition:S,legendLayout:_,legendHoverBehavior:T,legendClickBehavior:C,legendHighlightedCategory:P,legendIsolatedCategories:R,foregroundGraphics:yt(l,c(t?.customLayoutOverlays,M??null)),annotations:N,onAnnotationActivate:I,onObservation:W??D,chartId:E,chartType:"StreamNetworkFrame",autoPlaceAnnotations:z,svgAnnotationRules:B,annotationFrame:0}),pr(hr,{marks:t?.customLayoutHtmlMarks,margin:r,selection:M??null})]})}import{jsx as gr,jsxs as mr}from"react/jsx-runtime";var vr=/^(value|amount|total|count|weight|score)$/i;function xr({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?mr("div",{className:"semiotic-tooltip",style:z,children:[mr("div",{style:{fontWeight:600},children:["object"==typeof t.source?t.source.id:t.source," → ","object"==typeof t.target?t.target.id:t.target]}),null!=t.value&&mr("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]})]}):null}const t=e.data;if(!t)return null;const n=t.__hierarchyNode;if(n){const e=[];let o=n;for(;o;){const n=o.data?.name??o.data?.id??t.id;null!=n&&e.unshift(n+""),o=o.parent}e.length>1&&e.shift();const r=e.length-1;return mr("div",{className:"semiotic-tooltip",style:z,children:[gr("div",{children:e.map((e,t)=>mr("span",{children:[t>0&&gr("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===r?gr("strong",{children:e}):gr("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&gr("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof t.value?t.value.toLocaleString():t.value+""})]})}const o=(t.sourceLinks?.length||0)+(t.targetLinks?.length||0),r=(t.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(t.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0),s=O(t.data??t),i=null!=s.title?s.title+"":t.id,a=s.entries.some(e=>vr.test(e.key));return mr("div",{className:"semiotic-tooltip",style:z,children:[gr("div",{style:{fontWeight:600},children:i}),s.entries.map(e=>{return mr("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",(t=e.value,null==t?"–":"number"==typeof t?Math.abs(t)>9999?t.toLocaleString():t+"":t instanceof Date?t.toLocaleDateString():t+"")]},e.key);var t}),!a&&null!=t.value&&t.value>0&&mr("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),o>0&&mr("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",o,r!==o&&` (weighted: ${r.toLocaleString()})`]})]})}function br(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function kr(e,t){if(!t.pathD)return;e.save();const n=br(t);if(t.style.fill&&"none"!==t.style.fill){const o=t._gradient;if(o){const n=e.createLinearGradient(o.x0,0,o.x1,0),r=t.style.fillOpacity??t.style.opacity??.5,s="string"==typeof t.style.fill?t.style.fill:"#999",i=Qe(e,s)||s;n.addColorStop(0,1===o.from?i:"transparent"),n.addColorStop(1,1===o.to?i:"transparent"),e.fillStyle=n,e.globalAlpha=r}else e.fillStyle=Ce(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5;e.fill(n)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.5*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(n)),e.restore()}function wr(e,t){e.save();const n=t.style.stroke||"#999";e.strokeStyle=Qe(e,n)||n,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(t.style.strokeWidth??1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Ar(e,t){if(!t.pathD)return;e.save();const n=br(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=Ce(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5,e.fill(n)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.3*(t.style.opacity??1),e.stroke(n)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(n)),e.restore()}function Sr(e,t){if(!t.pathD)return;e.save();const n=br(t),o=t.style.stroke||"#999";e.strokeStyle=Qe(e,o)||o,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(n),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=Ce(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??.1,e.fill(n)),e.restore()}xr.ownsChrome=!0;var _r=new Map;function Tr(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=_r.get(t);return n||(n=new Path2D(Ve(e.symbolType,e.size)),_r.size>256&&_r.clear(),_r.set(t,n)),n}catch{return null}}function Cr(e){const{sceneNodes:t,nodes:n,nodeColorMap:o,colorScheme:r}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&o.set(e.id,e.style.fill);const s=Array.isArray(r)?r:ie,i=Array.from(n);for(let e=0;i.length>e;e++){const t=i[e];o.has(t.id)||o.set(t.id,s[e%s.length])}return i.length}function Pr(n,r,s,i=30){switch(n.type){case"circle":return function(t,n,o,r=30){const s=n-t.cx,i=o-t.cy,a=Math.sqrt(s*s+i*i);return a>e(t.r,r)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:a}}(n,r,s,i);case"rect":return function(e,n,o){const r=t(n,o,e);return r.hit?{type:"node",datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}(n,r,s);case"arc":return function(e,t,n){const r=t-e.cx,s=n-e.cy,i=Math.sqrt(r*r+s*s);if(e.innerR-2>i||i>e.outerR+2)return null;const a=o(Math.atan2(s,r)),l=o(e.startAngle),c=o(e.endAngle);if(l>c?a>=l||c>=a:a>=l&&c>=a){const t=(e.startAngle+e.endAngle)/2,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(n,r,s);case"symbol":return function(t,n,o,r=30){const s=n-t.cx,i=o-t.cy,a=Math.sqrt(s*s+i*i);return a>e(Ge(t.size),r)?null:{type:"node",datum:t.datum,x:t.cx,y:t.cy,distance:a}}(n,r,s,i);case"glyph":return function(t,n,o,r=30){if(null==t.datum)return null;const s=$e(t.glyph,t.size),i=t.cx+s.centerDx,a=t.cy+s.centerDy,l=n-i,c=o-a,u=Math.sqrt(l*l+c*c);return u>e(s.radius,r)?null:{type:"node",datum:t.datum,x:i,y:a,distance:u}}(n,r,s,i);default:return null}}var Rr=null,Mr=null;function Nr(){return Mr||((Rr=document.createElement("canvas")).width=1,Rr.height=1,Mr=Rr.getContext("2d")),Mr}function Ir(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch{return null}}function Wr(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const o=Ir(e),r=Nr();if(!o||!r)return null;try{if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const s=r.lineWidth;r.lineWidth=10;const i=r.isPointInStroke(o,t,n);if(r.lineWidth=s,i)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);case"line":return function(e,t,n){const o=e.x2-e.x1,r=e.y2-e.y1,s=o*o+r*r;if(0===s)return null;let i=((t-e.x1)*o+(n-e.y1)*r)/s;i=Math.max(0,Math.min(1,i));const a=e.x1+i*o,l=e.y1+i*r,c=Math.sqrt((t-a)**2+(n-l)**2);return c>5?null:{type:"edge",datum:e.datum,x:a,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const o=Ir(e),r=Nr();if(!o||!r)return null;try{if(r.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const s=r.lineWidth;r.lineWidth=10;const i=r.isPointInStroke(o,t,n);if(r.lineWidth=s,i)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch{}return null}(e,t,n);default:return null}}function Dr(e){const{clientX:t,clientY:n,canvasRect:o,margin:r,adjustedWidth:s,adjustedHeight:i,sceneNodes:a,sceneEdges:l,nodeQuadtree:c,maxNodeRadius:u,hitRadius:d=30}=e,h=t-o.left-r.left,p=n-o.top-r.top;if(0>h||h>s||0>p||p>i)return{kind:"miss-outside"};const f=function(e,t,n,o,r=30,s,i=0){let a=null,l=r,c=1/0;if(s){const e=bt(s,n,o,r,i,e=>e.cx,e=>e.cy,e=>e.r);e&&(a={type:"node",datum:e.node.datum,x:e.node.cx,y:e.node.cy,distance:e.distance},l=e.distance)}for(const t of e){if(s&&"circle"===t.type)continue;const e=Pr(t,n,o,r);if(e)if("rect"===t.type){const n=t.w*t.h;c>n&&(a=e,c=n)}else l>e.distance&&(a=e,l=e.distance)}if(a)return a;for(const e of t){if(!1===e.interactive)continue;const t=Wr(e,n,o);t&&l>t.distance&&(a=t,l=t.distance)}return a}(a,l,h,p,d,c,u);return f?{kind:"hit",hover:E(f.datum||{},f.x,f.y,{nodeOrEdge:f.type})}:{kind:"miss"}}import{useCallback as Er}from"react";var zr="StreamNetworkFrame";import{jsx as Br,jsxs as Lr}from"react/jsx-runtime";var Or={top:20,right:80,bottom:20,left:80},Hr={top:40,right:40,bottom:40,left:40},Fr=new Set(["chord","force","circlepack","orbit"]),jr=[800,600],$r=No(Mo(function(e,t){const{chartType:n,nodes:o,edges:r,data:u,initialEdges:x,nodeIDAccessor:k="id",sourceAccessor:S="source",targetAccessor:_="target",valueAccessor:T="value",edgeIdAccessor:D,childrenAccessor:z,hierarchySum:B,orientation:O="horizontal",nodeAlign:H="justify",nodePaddingRatio:F=.05,nodeWidth:j=15,iterations:$=300,forceStrength:Y=.1,layoutExecution:X="auto",layoutLoadingContent:V,onLayoutStateChange:G,padAngle:q=.01,groupWidth:U=20,sortGroups:K,edgeSort:Z,treeOrientation:J="vertical",edgeType:ee="curve",padding:te,paddingTop:ne,tensionConfig:oe,showParticles:re=!1,particleStyle:se,renderMode:ae,nodeStyle:le,edgeStyle:ce,colorBy:ue,colorScheme:de="category10",edgeColorBy:he="source",edgeOpacity:pe=.5,colorByDepth:me=!1,nodeSize:be=8,nodeSizeRange:ke=[5,20],nodeLabel:we,showLabels:Ae=!0,labelMode:Se,size:_e=jr,responsiveWidth:Pe,responsiveHeight:Re,margin:Me,className:Ne,background:Ie,enableHover:We=!0,tooltipContent:De,customHoverBehavior:Ee,customClickBehavior:ze,onObservation:Be,annotationObservationCallback:Le,chartId:Oe,onTopologyChange:He,annotations:Fe,onAnnotationActivate:je,autoPlaceAnnotations:Ye,svgAnnotationRules:Xe,legend:Ve,legendPosition:Ge,legendLayout:qe,legendHoverBehavior:Ue,legendClickBehavior:Ze,legendHighlightedCategory:Je,legendIsolatedCategories:et,title:tt,foregroundGraphics:nt,backgroundGraphics:ot,decay:rt,pulse:st,transition:it,animate:at,staleness:lt,frameScheduler:ct,clock:ut,random:dt,seed:ht,paused:pt=!1,suspendWhenHidden:ft=!0,thresholds:gt,accessibleTable:mt=!0,description:bt,summary:kt,orbitMode:wt,orbitSize:At,orbitSpeed:St,orbitRevolution:_t,orbitRevolutionStyle:Tt,orbitEccentricity:Ct,orbitShowRings:Pt,orbitAnimated:Rt,customNetworkLayout:Mt,onLayoutError:Nt,layoutConfig:It,layoutSelection:Wt}=e,Dt=Fr.has(n)?Hr:Or,Et=So(!0),zt=R({sizeProp:_e,responsiveWidth:Pe,responsiveHeight:Re,userMargin:Me,marginDefault:Dt,title:tt,legend:Ve,legendPosition:Ge,foregroundGraphics:nt,backgroundGraphics:ot,animate:at,transitionProp:it,frameScheduler:ct,clock:ut,random:dt,seed:ht,paused:pt,suspendWhenHidden:ft,themeDirtyRef:Et}),{reducedMotionRef:Bt,responsiveRef:Lt,size:Ot,margin:Ht,adjustedWidth:jt,adjustedHeight:Yt,resolvedForeground:Xt,resolvedBackground:Vt,transition:Gt,introEnabled:qt,tableId:Ut,rafRef:Qt,renderFnRef:Kt,scheduleRender:Zt,frameRuntime:Jt,currentTheme:en}=zt,tn=N(),nn=W(),on=Co(()=>ge(o),[o]),rn=Co(()=>Array.isArray(r)?ge(r):r,[r]),sn=Co(()=>({...Io,...oe}),[oe]),an=Co(()=>({...Wo,...se}),[se]),ln=Co(()=>{return{chartType:(e={chartType:n,clock:Jt.now,random:dt,seed:ht,nodeIDAccessor:k,sourceAccessor:S,targetAccessor:_,valueAccessor:T,edgeIdAccessor:D,childrenAccessor:z,hierarchySum:B,orientation:O,nodeAlign:H,nodePaddingRatio:F,nodeWidth:j,iterations:$,forceStrength:Y,padAngle:q,groupWidth:U,sortGroups:K,edgeSort:Z,treeOrientation:J,edgeType:ee,padding:te,paddingTop:ne,tensionConfig:sn,showParticles:re,particleStyle:an,nodeStyle:le,edgeStyle:ce,nodeLabel:we,showLabels:Ae,labelMode:Se,colorBy:ue,colorScheme:de,edgeColorBy:he,edgeOpacity:pe,colorByDepth:me,nodeSize:be,nodeSizeRange:ke,decay:rt,pulse:st,transition:Gt,introAnimation:qt,staleness:lt,thresholds:gt,orbitMode:wt,orbitSize:At,orbitSpeed:St,orbitRevolution:_t,orbitRevolutionStyle:Tt,orbitEccentricity:Ct,orbitShowRings:Pt,orbitAnimated:Rt,customNetworkLayout:Mt,onLayoutError:Nt,layoutConfig:It,currentTheme:en}).chartType,clock:e.clock,random:e.random,seed:e.seed,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,edgeIdAccessor:e.edgeIdAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,tensionConfig:e.tensionConfig,showParticles:e.showParticles,particleStyle:e.particleStyle,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme,themeCategorical:e.currentTheme?.colors?.categorical,themeSemantic:Ke(e.currentTheme),edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,decay:e.decay,pulse:e.pulse,transition:e.transition,introAnimation:e.introAnimation,staleness:e.staleness,thresholds:e.thresholds,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:e.orbitAnimated,customNetworkLayout:e.customNetworkLayout,onLayoutError:e.onLayoutError,layoutConfig:e.layoutConfig};var e},[n,Jt.now,dt,ht,k,S,_,T,D,z,B,O,H,F,j,$,Y,q,U,K,Z,J,ee,te,ne,sn,re,an,le,ce,we,Ae,Se,ue,de,he,pe,me,be,ke,rt,st,Gt,qt,lt,gt,wt,At,St,_t,Tt,Ct,Pt,Rt,Mt,Nt,It,en]),cn=pn(ln),un=pn({chartType:(dn={chartType:n,nodeIDAccessor:k,sourceAccessor:S,targetAccessor:_,valueAccessor:T,edgeIdAccessor:D,childrenAccessor:z,hierarchySum:B,orientation:O,nodeAlign:H,nodePaddingRatio:F,nodeWidth:j,iterations:$,forceStrength:Y,padAngle:q,groupWidth:U,sortGroups:K,edgeSort:Z,treeOrientation:J,edgeType:ee,padding:te,paddingTop:ne,random:dt,seed:ht,tensionConfig:sn,customNetworkLayout:Mt,orbitMode:wt,orbitSize:At,orbitEccentricity:Ct}).chartType,nodeIDAccessor:dn.nodeIDAccessor,sourceAccessor:dn.sourceAccessor,targetAccessor:dn.targetAccessor,valueAccessor:dn.valueAccessor,edgeIdAccessor:dn.edgeIdAccessor,childrenAccessor:dn.childrenAccessor,hierarchySum:dn.hierarchySum,orientation:dn.orientation,nodeAlign:dn.nodeAlign,nodePaddingRatio:dn.nodePaddingRatio,nodeWidth:dn.nodeWidth,iterations:dn.iterations,forceStrength:dn.forceStrength,padAngle:dn.padAngle,groupWidth:dn.groupWidth,sortGroups:dn.sortGroups,edgeSort:dn.edgeSort,treeOrientation:dn.treeOrientation,edgeType:dn.edgeType,padding:dn.padding,paddingTop:dn.paddingTop,random:dn.random,seed:dn.seed,tensionConfig:dn.tensionConfig,customNetworkLayout:dn.customNetworkLayout,orbitMode:dn.orbitMode,orbitSize:dn.orbitSize,orbitEccentricity:dn.orbitEccentricity});var dn;const hn=So(0),fn=So(0),yn=So(!1),gn=So(null);gn.current||(gn.current=new or(cn));const mn=I("StreamNetworkFrame"),xn=Po((e,t,n=!1)=>P(mn.current,e,()=>e.buildScene(t),n),[mn]),[bn,kn]=_o(null),[wn,An]=_o(0),[Sn,_n]=_o(0),[Tn,Cn]=_o(!1),[Pn,Rn]=_o(!1),Mn=So(0),Nn=So(null),In=So(!1),Wn=So(G);Wn.current=G;const zn=So(cn);zn.current=cn;const Bn=So(null),Ln=So(new Map),On=So(0),Hn=Po(e=>function(e){const{node:t,colorBy:n,colorScheme:o,nodeColorMap:r,colorIndexRef:s}=e;if("function"==typeof n)return n(t)+"";if("string"==typeof n&&t.data){const e=t.data[n];if(void 0!==e){if(!r.has(e+"")){const t=Array.isArray(o)?o:ie;r.set(e+"",t[s.current++%t.length])}return r.get(e+"")}}if(r.has(t.id))return r.get(t.id);const i=Array.isArray(o)?o:ie,a=n?i[s.current++%i.length]:i[0];return r.set(t.id,a),a}({node:e,colorBy:ue,colorScheme:de,nodeColorMap:Ln.current,colorIndexRef:On}),[ue,de]),Fn=(jn=en,jn?.colors?.border||jn?.colors?.secondary||jn?.colors?.primary||"#999");var jn;const $n=Po(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,gn.current?.nodes),[]),Yn=Po(e=>function(e){const{edge:t,edgeColorBy:n,getNodeColor:o,resolveEndpoint:r,fallback:s}=e;if("function"==typeof n)return n(t);const i=r(t.source),a=r(t.target);return"target"===n&&a?o(a):i?o(i):s}({edge:e,edgeColorBy:he,getNodeColor:Hn,resolveEndpoint:$n,fallback:Fn}),[he,Hn,Fn,$n]),Vn=Po(e=>function(e){const{edge:t,particleStyleColor:n,particleColorBy:o,hasExplicitParticleColorBy:r,getEdgeColor:s,getNodeColor:i,resolveEndpoint:a,fallback:l}=e;if("function"==typeof n){const e=a(t.source);return e?n(t,e):l}if(!r)return s(t);const c=o,u=a(t.source),d=a(t.target);return"target"===c&&d?i(d):u?i(u):l}({edge:e,particleStyleColor:an.color,particleColorBy:an.colorBy,hasExplicitParticleColorBy:!!se?.colorBy,getEdgeColor:Yn,getNodeColor:Hn,resolveEndpoint:$n,fallback:Fn}),[se?.colorBy,an.color,an.colorBy,Hn,Yn,Fn,$n]),Gn=function(e,t,n,o,r){return("sankey"===e||t)&&n||o||r}(n,!!Mt,re,!!st,gn.current?.isAnimating??!1);vt(gn,cn,Et,Zt),xt(gn,Wt,Et,Zt),To(()=>{const e=gn.current;e&&(xn(e,[jt,Yt]),On.current=Cr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:de}),Et.current=!0,Zt())},[en,jt,Yt,xn,Zt,de]);const qn=Po(()=>{const e=gn.current;if(e&&(e.runLayout([jt,Yt]),xn(e,[jt,Yt]),Et.current=!0,On.current=Cr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:de}),An(e.layoutVersion),He)){const{nodes:t,edges:n}=e.getLayoutData();He(t,n)}},[jt,Yt,xn,He,de]),Un=Po(e=>{if(null==e||"object"!=typeof e)return;const t=gn.current;t&&(t.ingestEdge(e)&&qn(),Zt())},[qn,Zt]),Qn=Po(e=>{const t=gn.current;if(!t)return;let n=!1;for(const o of e)null!=o&&"object"==typeof o&&t.ingestEdge(o)&&(n=!0);n&&qn(),Zt()},[qn,Zt]),Kn=Po(()=>{gn.current?.clear(),Ln.current.clear(),On.current=0,An(gn.current?.layoutVersion??0),kn(null),Bn.current=null,Et.current=!0,Zt()},[Zt]),Zn=Po(()=>{const e=gn.current;e&&(e.tension+=999,qn(),Zt())},[qn,Zt]);Ro(t,()=>({push:Un,pushMany:Qn,removeNode:e=>{const t=gn.current?.removeNode(e)??!1;if(t){const t=Bn.current?.data?"function"==typeof k?k(Bn.current.data):Bn.current.data[k]:void 0;Bn.current&&"node"===Bn.current.nodeOrEdge&&t===e&&(Bn.current=null,kn(null)),Ln.current.delete(e),qn(),Et.current=!0,Zt()}return t},removeEdge:(e,t)=>{const n=gn.current?.removeEdge(e,t)??!1;if(n){if(Bn.current&&"edge"===Bn.current.nodeOrEdge){const n=Bn.current.data;let o;o=void 0!==t?("object"==typeof n?.source?n.source.id:n?.source)===e&&("object"==typeof n?.target?n.target.id:n?.target)===t:!D||!n||("function"==typeof D?D:e=>e?.[D])(n)===e,o&&(Bn.current=null,kn(null))}qn(),Et.current=!0,Zt()}return n},updateNode:(e,t)=>{const n=gn.current?.updateNode(e,t)??null;return n&&(Et.current=!0,Zt()),n},updateEdge:(e,t,n)=>{const o=gn.current?.updateEdge(e,t,n)??[];return o.length>0&&(qn(),Et.current=!0,Zt()),o},clear:Kn,getTopology:()=>gn.current?.getLayoutData()??{nodes:[],edges:[]},getCustomLayout:()=>gn.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>gn.current?.lastCustomLayoutFailure??null,getTopologyDiff:()=>{const e=gn.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:Zn,getTension:()=>gn.current?.tension??0}),[Un,Qn,Kn,Zn,k,qn,Zt,D]);const Jn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(n),eo=Jn?u||(Array.isArray(r)?void 0:r):void 0;To(()=>{const e=gn.current;if(!e)return;const t=++Mn.current;if(Nn.current?.abort(),Nn.current=null,Jn&&eo)e.ingestHierarchy(eo,[jt,Yt]),xn(e,[jt,Yt]),Rn(!1),Wn.current?.("ready"),Et.current=!0,Zt();else{const c=on,u=Array.isArray(rn)?rn:[];if(0===c.length&&0===u.length)return null==o&&null==r||0>=e.nodes.size&&0>=e.edges.size||Kn(),Rn(!1),void Wn.current?.("ready");const d=[jt,Yt],h="force"===n&&!Mt&&s()&&!dt&&l(X,c.length,u.length,$);if(h&&nn&&!In.current&&e.sceneNodes.length>0)return In.current=!0,Rn(!1),Wn.current?.("ready"),Et.current=!0,void Zt();if(h){const n=new AbortController;Nn.current=n;const o=e._lastPositionSnapshot;e.ingestBounded(c,u,d,{deferLayout:!0});const r=e.getLayoutData(),s=i(r.nodes,r.edges,zn.current,d,o);return Rn(!0),Wn.current?.("pending"),a(s,n.signal).then(({positions:n})=>{t===Mn.current&&(e.applyForceLayoutPositions(n,d),xn(e,d),On.current=Cr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:de}),Rn(!1),Wn.current?.("ready"),An(e.layoutVersion),Et.current=!0,Zt())}).catch(n=>{"AbortError"!==n.name&&t===Mn.current&&(e.runLayout(d),xn(e,d),On.current=Cr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:de}),Rn(!1),Wn.current?.("error"),An(e.layoutVersion),Et.current=!0,Zt())}),()=>n.abort()}e.ingestBounded(c,u,d),xn(e,d),Rn(!1),Wn.current?.("ready"),On.current=Cr({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Ln.current,colorScheme:de}),Et.current=!0,Zt()}},[on,rn,o,r,u,eo,Jn,jt,Yt,un,X,$,nn,n,Mt,dt,Zt,Kn,de,xn]),To(()=>{x&&x.length>0&&Qn(x)},[x,Qn]);const{customHoverBehavior:to,customClickBehavior:no}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:o}){return{customHoverBehavior:Er((t,r)=>{e?.(t,r),ye({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:zr,chartId:o,context:r})},[e,n,o]),customClickBehavior:Er((e,r)=>{t?.(e,r),fe({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:zr,chartId:o,context:r})},[t,n,o])}}({customHoverBehavior:Ee,customClickBehavior:ze,onObservation:Be,chartId:Oe}),{hoverHandlerRef:oo,hoverLeaveRef:ro,onPointerMove:so,onPointerLeave:io}=zt,ao=()=>!Mt||(gn.current?.hasCustomRestyle??!1);oo.current=e=>{if(!We)return;const t=ao(),n=bo.current;if(!n)return;const o=gn.current;if(!o)return;const r=Dr({clientX:e.clientX,clientY:e.clientY,canvasRect:n.getBoundingClientRect(),margin:Ht,adjustedWidth:jt,adjustedHeight:Yt,sceneNodes:o.sceneNodes,sceneEdges:o.sceneEdges,nodeQuadtree:o.nodeQuadtree,maxNodeRadius:o.maxNodeRadius});"hit"===r.kind?(Bn.current=r.hover,kn(r.hover),to&&(to(r.hover),t&&(Et.current=!0)),t&&Zt()):Bn.current&&(Bn.current=null,kn(null),to&&(to(null),t&&(Et.current=!0)),t&&Zt())},ro.current=()=>{if(Bn.current){const e=ao();Bn.current=null,kn(null),to&&(to(null),e&&(Et.current=!0)),e&&Zt()}};const lo=So(()=>{});lo.current=e=>{if(L(e.target))return;if(!ze&&!Be)return;const t=bo.current;if(!t)return;const n=gn.current;if(!n)return;const o=Dr({clientX:e.clientX,clientY:e.clientY,canvasRect:t.getBoundingClientRect(),margin:Ht,adjustedWidth:jt,adjustedHeight:Yt,sceneNodes:n.sceneNodes,sceneEdges:n.sceneEdges,nodeQuadtree:n.nodeQuadtree,maxNodeRadius:n.maxNodeRadius});"hit"===o.kind?no(o.hover,{type:"activate",inputType:Te(e.nativeEvent.pointerType)}):"miss"===o.kind&&no(null)};const co=Po(e=>lo.current(e),[]),fo=So(-1),yo=So(null),mo=So(-1),vo=Po(e=>{if(ve(e))return;const t=gn.current;if(!t)return;const n=()=>{fo.current=-1,yo.current=null,mo.current=-1,Bn.current=null,kn(null),to&&(to(null),Et.current=!0),Zt()},o=function(e){const t=[];for(const n of e)if("circle"===n.type&&null!=n.cx){if(0>=n.r)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("rect"===n.type&&null!=n.x){if(0>=n.w||0>=n.h)continue;t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.datum?.id??"_default"})}else if("arc"===n.type&&null!=n.cx)t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"});else if("symbol"===n.type&&null!=n.cx){if(0>=n.size)continue;t.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("glyph"===n.type&&null!=n.cx){if(0>=n.size||null==n.datum)continue;const e=$e(n.glyph,n.size);t.push({x:n.cx+e.centerDx,y:n.cy+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:n.datum?.id??"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}(t.sceneNodes);if(0===o.length)return void(0>fo.current||n());const r=uo(o);let s=fo.current;if(r.flat.length>s||(n(),s=-1)," "===e.key&&s>=0){e.preventDefault();const t=r.flat[s];return void no(E(t.datum||{},t.x,t.y,{nodeOrEdge:"node"}),{type:"activate",inputType:"keyboard"})}if(0>s){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),fo.current=0,mo.current=-1;const t=r.flat[0];yo.current={shape:t.shape,w:t.w,h:t.h};const n=E(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Bn.current=n,kn(n),to&&(to(n,{type:"focus",inputType:"keyboard"}),Et.current=!0),void Zt()}const i=ho(r,s),a=function(e,t,n,o,r){const s=n.flat[t.flatIndex];if(!s)return po(e,t,n);const i=s.datum?.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const o=function(e,t,n){let o=null,r=1/0;for(let s=0;e.flat.length>s;s++){const i=e.flat[s];if(i===t)continue;const a=i.x-t.x,l=i.y-t.y;let c=!1;switch(n){case"right":c=a>0&&Math.abs(a)>=Math.abs(l);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(a);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(a)}if(!c)continue;const u=a*a+l*l;r>u&&(r=u,o=s)}return o}(n,s,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up")??t.flatIndex;return o!==t.flatIndex&&(r.current=-1),o}case"Enter":{if(null==i)return t.flatIndex;const e=function(e,t){const n=e+"",o=[];for(const e of t){const t=e.datum??e,r=go(t.source),s=go(t.target),i=null!=r,a=null!=s;i&&r+""===n&&a?o.push(s+""):a&&s+""===n&&i&&o.push(r+"")}return o}(i,o);if(0===e.length)return t.flatIndex;const s=n.idToIdx.get(e[(r.current+1)%e.length])??-1;return 0>s?t.flatIndex:(r.current=-1,s)}default:{const o=po(e,t,n);return null!==o&&o!==t.flatIndex&&(r.current=-1),o}}}(e.key,i,r,t.sceneEdges??[],mo);if(null===a)return;if(e.preventDefault(),0>a)return void n();fo.current=a;const l=r.flat[a];yo.current={shape:l.shape,w:l.w,h:l.h};const c={data:l.datum||{},x:l.x,y:l.y,__semioticHoverData:!0,nodeOrEdge:"node"};Bn.current=c,kn(c),to&&(to(c,{type:"focus",inputType:"keyboard"}),Et.current=!0),Zt()},[no,to,Zt]),xo=Po(e=>{fo.current=-1,yo.current=null,so(e)},[so]);Kt.current=()=>{if(Qt.current=null,!Jt.isActive)return;const e=bo.current;if(!e)return;const t=gn.current;t&&function(e){const{canvas:t,store:n,sceneRevisionDiagnostics:o,size:r,margin:s,adjustedWidth:i,adjustedHeight:a,background:l,renderMode:c,hasBackgroundGraphics:u=!1,dirtyRef:d,lastFrameTimeRef:h,now:p,random:f,reducedMotion:y,showParticles:g,isContinuous:m,animate:v,decay:x,pulse:k,thresholds:S,staleness:_,particleStyle:T,getParticleColor:C,pendingAnnotationFrameRef:P,lastAnnotationFrameTimeRef:R,setAnnotationFrame:M,scheduleNextFrame:N}=e,I=t.getContext("2d");if(!I)return;const W=h.current?Math.min((p-h.current)/1e3,.1):.016;h.current=p;const D=n.advanceTransition(y?p+1e6:p),E=!y&&D,z=!y&&n.tickAnimation([i,a],W),B=d.current,L=o?.beforeCompute(n.getLastUpdateResult(),E),O=D||B||z;O&&n.buildScene([i,a]),L&&o?.afterCompute(L,O,!1);const H=g&&!y&&!!n.particlePool,F=!!((j={dirtyOrRebuilt:B,transitioning:E,animationTicked:z,continuous:H||m,liveEncoding:!!x||!!k||!!S||!1!==v&&n.hasActiveTopologyDiff||n.hasActivePulses||n.hasActiveThresholds,forced:n.consumeStylePaintPending()}).dirtyOrRebuilt||j.transitioning||j.animationTicked||j.continuous||j.liveEncoding||j.forced);var j;const $=!!_&&n.lastIngestTime>0&&p-n.lastIngestTime>(_?.threshold??5e3);if(F){const e=w();if(!A(t,r,s,e))return;if(I.clearRect(-s.left,-s.top,r[0],r[1]),vn(I,{background:l,hasBackgroundGraphics:u,width:i,height:a}),x&&n.applyDecay(),k&&n.applyPulse(p),S&&n.applyThresholds(p),!1!==v&&n.applyTopologyDiff(p),$&&(I.globalAlpha=_?.dimOpacity??.5),Q({context:I,nodes:n.sceneEdges,renderMode:c,pixelRatio:e,paintBuiltIn:e=>function(e,t){for(const n of t)switch(n.type){case"bezier":kr(e,n);break;case"line":wr(e,n);break;case"ribbon":Ar(e,n);break;case"curved":Sr(e,n)}}(I,e)}),Q({context:I,nodes:n.sceneNodes,renderMode:c,pixelRatio:e,paintBuiltIn:e=>{const t=e;!function(e,t){for(const n of t){if("rect"!==n.type)continue;const t=n;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=Ce(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.strokeRect(t.x,t.y,t.w,t.h)),Dn(e,t),e.restore())}}(I,t),function(e,t){for(const n of t){if("circle"!==n.type)continue;const t=n;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle=Ce(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),En(e,t),e.restore())}}(I,t),function(e,t){for(const n of t){if("arc"!==n.type)continue;const t=n;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle=Ce(e,t.style.fill,"#007bff"),void 0!==t.style.fillOpacity&&(e.globalAlpha=(t.style.opacity??1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),e.restore()}}(I,t),function(e,t){const n=e.globalAlpha;for(const o of t){if("symbol"!==o.type)continue;const t=o;if(0>=t.size)continue;const r=Tr(t);if(!r)continue;e.save(),e.translate(t.cx,t.cy),t.rotation&&e.rotate(t.rotation);const s=t.style.opacity??1;t.style.fill&&(e.globalAlpha=n*s*(t.style.fillOpacity??1),e.fillStyle=Ce(e,t.style.fill,"#007bff"),e.fill(r)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*s,e.strokeStyle=Qe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(r)),e.restore()}}(I,t),function(e,t){const n=e.globalAlpha;for(const o of t)"glyph"===o.type&&Xn(e,o,o.cx,o.cy,n);e.globalAlpha=n}(I,t)}}),H&&!$){const e=n.edgesArray;if(e.length>0){!function(e,t,n,o,r=Math.random){const s=o.spawnRate??.1,i=o.maxPerEdge??50;for(let o=0;t.length>o;o++){const a=t[o];if(!a.bezier)continue;if(e.countForEdge(o)>=i)continue;const l=a.value*s*n*(a.bezier.circular?.3:1),c=Math.floor(l),u=l-c;let d=c;r()<u&&d++;for(let t=0;d>t&&e.countForEdge(o)<i;t++)e.spawn(o,r)}}(n.particlePool,e,W,T,f);const t=.5*(T.speedMultiplier??1);let o;if(T.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);o=e.map(e=>.3+(e.value||1)/t*1.7)}n.particlePool.step(W,t,e,o),function(e,t,n,o,r){const s=o.radius??3;e.globalAlpha=o.opacity??.7;for(let i=0;t.particles.length>i;i++){const a=t.particles[i];if(!a.active)continue;const l=n[a.edgeIndex];if(!l)continue;let c;c="string"==typeof o.color&&"inherit"!==o.color?o.color:r(l),e.fillStyle=Qe(e,c)||c,e.beginPath(),e.arc(a.x,a.y,s,0,2*Math.PI),e.fill()}e.globalAlpha=1}(I,n.particlePool,e,T,C)}}$&&(I.globalAlpha=1)}d.current=!1,(B||E||z)&&t.setAttribute("aria-label",b(n.sceneNodes?.length??0,n.sceneEdges?.length??0,"Network chart"));const Y=B||E||z||P.current;Y&&p-R.current>=33?(M(e=>e+1),R.current=p,P.current=!1):P.current=!!Y,(m||E||null!=n.transition||z||n.hasActivePulses||n.hasActiveThresholds||!1!==v&&n.hasActiveTopologyDiff||P.current)&&N()}({canvas:e,store:t,sceneRevisionDiagnostics:mn.current,size:Ot,margin:Ht,adjustedWidth:jt,adjustedHeight:Yt,background:Ie,renderMode:ae,hasBackgroundGraphics:!!ot,dirtyRef:Et,lastFrameTimeRef:hn,now:Jt.now(),random:Jt.random,reducedMotion:!!Bt.current,showParticles:re,isContinuous:Gn,animate:at,decay:rt,pulse:st,thresholds:gt,staleness:lt,particleStyle:an,getParticleColor:Vn,pendingAnnotationFrameRef:yn,lastAnnotationFrameTimeRef:fn,setAnnotationFrame:_n,scheduleNextFrame:()=>{Zt()}})};const{canvasRef:bo}=M(zt,{hydrated:tn,wasHydratingFromSSR:nn,storeRef:gn,dirtyRef:Et,canvasPaintDependencies:[n,jt,Yt,Ie,ot,ae,Zt]});Ft(lt,gn,Et,Zt,Tn,Cn);const ko=We&&bn?Br(p,{x:bn.x,y:bn.y,containerWidth:jt,containerHeight:Yt,margin:Ht,className:"stream-network-tooltip",zIndex:2,children:De?De(bn):Br(xr,{data:bn})}):null;if(xe||!tn&&nn)return Br(yr,{props:e,store:gn.current,responsiveRef:Lt,size:Ot,margin:Ht,adjustedWidth:jt,adjustedHeight:Yt,resolvedBackground:Vt,resolvedForeground:Xt});const wo=gn.current;return Lr("div",{ref:Lt,className:"stream-network-frame"+(Ne?" "+Ne:""),role:"group","aria-label":bt||("string"==typeof tt?tt:"Network chart"),tabIndex:0,"aria-busy":Pn||void 0,style:{position:"relative",width:Pe?"100%":Ot[0],height:Re?"100%":Ot[1],overflow:"visible"},onKeyDown:vo,children:["production"!==process.env.NODE_ENV&&gn.current&&Br(g,{store:gn.current,diagnostics:mn.current}),mt&&Br(v,{tableId:Ut}),mt&&Br(y,{nodes:wo?.sceneNodes??[],edges:wo?.sceneEdges??[],chartType:"Network chart",tableId:Ut,chartTitle:"string"==typeof tt?tt:void 0}),Br(m,{summary:kt}),Br(d,{hoverPoint:bn}),Lr("div",{role:"img","aria-label":bt||("string"==typeof tt?tt:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:We?xo:void 0,onMouseLeave:We?io:void 0,onClick:ze||Be?co:void 0,children:[Pn&&!1!==V&&Br("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:C(!0,Ot[0],Ot[1],V)}),Br(h,{size:Ot,margin:Ht,overflowVisible:!0,children:Vt}),Br("canvas",{ref:bo,"aria-label":b(wo?.sceneNodes?.length??0,wo?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),Br(lr,{width:jt,height:Yt,totalWidth:Ot[0],totalHeight:Ot[1],margin:Ht,labels:wo?.labels||[],sceneNodes:wo?.sceneNodes,title:tt,legend:Ve,legendPosition:Ge,legendLayout:qe,legendHoverBehavior:Ue,legendClickBehavior:Ze,legendHighlightedCategory:Je,legendIsolatedCategories:et,foregroundGraphics:yt(Xt,c(gn.current?.customLayoutOverlays,Wt??null)),annotations:Fe,onAnnotationActivate:je,onObservation:Le??Be,chartId:Oe,chartType:"StreamNetworkFrame",autoPlaceAnnotations:Ye,svgAnnotationRules:Xe,annotationFrame:Sn}),Br(hr,{marks:wo?.customLayoutHtmlMarks,margin:Ht,selection:Wt??null}),Br(f,{active:fo.current>=0,hoverPoint:bn,margin:Ht,size:Ot,shape:yo.current?.shape,width:yo.current?.w,height:yo.current?.h}),ko,lt?.showBadge&&Br($t,{isStale:Tn,position:lt.badgePosition})]})]})}));$r.displayName="StreamNetworkFrame";var Yr=$r,Xr=class e{constructor(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}push(e){if(!Number.isFinite(e))return;this._count+=1;const t=e-this._mean;this._mean+=t/this._count,this._m2+=t*(e-this._mean),this._min>e&&(this._min=e),e>this._max&&(this._max=e)}merge(e){if(0===e._count)return;if(0===this._count)return this._count=e._count,this._mean=e._mean,this._m2=e._m2,this._min=e._min,void(this._max=e._max);const t=this._count+e._count,n=e._mean-this._mean;this._mean+=n*e._count/t,this._m2+=e._m2+n*n*this._count*e._count/t,this._count=t,this._min>e._min&&(this._min=e._min),e._max>this._max&&(this._max=e._max)}clear(){this._count=0,this._mean=0,this._m2=0,this._min=1/0,this._max=-1/0}clone(){const t=new e;return t._count=this._count,t._mean=this._mean,t._m2=this._m2,t._min=this._min,t._max=this._max,t}get count(){return this._count}get mean(){return 0===this._count?0:this._mean}get sum(){return 0===this._count?0:this._mean*this._count}get variance(){return 2>this._count?0:this._m2/this._count}get stddev(){return Math.sqrt(this.variance)}get sampleVariance(){return 2>this._count?0:this._m2/(this._count-1)}get sampleStddev(){return Math.sqrt(this.sampleVariance)}get min(){return this._min}get max(){return this._max}},Vr=class{constructor(e){this.windows=new Map,this.sessions=[],this.latest=-1/0,this.type=e.window??"tumbling",this.size=e.size;const t=e.hop??e.size;this.hop=t>0&&e.size>=t?t:e.size,this.gap=e.gap??e.size,this.retain=null!=e.retain&&e.retain>0?e.retain:1/0}push(e,t){Number.isFinite(e)&&Number.isFinite(t)&&(e>this.latest&&(this.latest=e),"session"===this.type?this.pushSession(e,t):this.pushFixed(e,t),this.prune())}pushFixed(e,t){if("tumbling"===this.type||this.hop>=this.size)return void this.bump(Math.floor(e/this.size)*this.size,t);const n=this.hop,o=Math.floor(e/n);for(let r=Math.floor((e-this.size)/n)+1;o>=r;r++)this.bump(r*n,t)}bump(e,t){let n=this.windows.get(e);n||(n=new Xr,this.windows.set(e,n)),n.push(t)}pushSession(e,t){const n=this.gap,o=new Xr;o.push(t);let r=e,s=e;const i=[],a={start:r,end:s,stats:o};for(const t of this.sessions)e-n>t.end||t.start>e+n?i.push(t):(a.stats.merge(t.stats),r>t.start&&(r=t.start),t.end>s&&(s=t.end));a.start=r,a.end=s,i.push(a),i.sort((e,t)=>e.start-t.start),this.sessions=i}prune(){if(this.retain===1/0)return;if("session"===this.type)return void(this.sessions.length>this.retain&&(this.sessions=this.sessions.slice(this.sessions.length-this.retain)));if(this.retain>=this.windows.size)return;const e=[...this.windows.keys()].sort((e,t)=>e-t),t=e.length-this.retain;for(let n=0;t>n;n++)this.windows.delete(e[n])}emit(){return"session"===this.type?this.emitSessions():this.emitFixed()}emitFixed(){const e=[];for(const[t,n]of this.windows){const o=t+this.size;e.push(this.row(t,o,n,o>this.latest))}return e.sort((e,t)=>e.start-t.start),e}emitSessions(){return this.sessions.map(e=>this.row(e.start,e.end,e.stats,this.gap>this.latest-e.end))}row(e,t,n,o){return{start:e,end:t,count:n.count,mean:n.mean,sum:n.sum,min:n.min,max:n.max,stddev:n.stddev,partial:o}}get windowCount(){return"session"===this.type?this.sessions.length:this.windows.size}get watermark(){return this.latest}clear(){this.windows.clear(),this.sessions=[],this.latest=-1/0}};function Gr(e,t){switch(t){case"sum":return e.sum;case"min":return e.min;case"max":return e.max;case"count":return e.count;default:return e.mean}}function qr(e,t,n,o=1){if("none"===t)return null;if("minmax"===t)return[e.min,e.max];const r=Gr(e,n),s=e.stddev*o;return[r-s,r+s]}var Ur={ms:1,s:1e3,m:6e4,h:36e5,d:864e5},Qr=/(\d+(?:\.\d+)?)(ms|s|m|h|d)/g;function Kr(e){if("number"==typeof e)return Number.isFinite(e)&&e>0?e:null;if("string"!=typeof e)return null;const t=e.trim();if(""===t)return null;Qr.lastIndex=0;let n,o=0,r=0;for(;null!==(n=Qr.exec(t));){const e=parseFloat(n[1]),t=Ur[n[2]];if(null==t||!Number.isFinite(e))return null;o+=e*t,r+=n[0].length}return r!==t.length?null:o>0?o:null}var Zr=class{constructor(e){this.held=[],this._watermark=-1/0,this._lateCount=0,this.lateness=e.lateness>0?e.lateness:0,this.getTime=e.getTime,this.latePolicy=e.latePolicy??"drop"}push(e){const t=this.getTime(e);if(!Number.isFinite(t))return{released:[e],late:[]};const n=[];return this._watermark!==-1/0&&this._watermark-this.lateness>t?(this._lateCount+=1,n.push(e),"drop"===this.latePolicy?{released:[],late:n}:{released:[e],late:n}):(t>this._watermark&&(this._watermark=t),this.held.push(e),{released:this.drain(),late:n})}drain(){const e=this._watermark-this.lateness;if(0===this.held.length)return[];const t=[],n=[];for(const o of this.held)this.getTime(o)>e?n.push(o):t.push(o);return this.held=n,t.sort((e,t)=>this.getTime(e)-this.getTime(t)),t}flush(){const e=this.held;return this.held=[],e.sort((e,t)=>this.getTime(e)-this.getTime(t)),e}clear(){this.held=[],this._watermark=-1/0,this._lateCount=0}get watermark(){return this._watermark}get lateCount(){return this._lateCount}get heldCount(){return this.held.length}};import{useRef as Jr,useImperativeHandle as es,forwardRef as ts,useCallback as ns,useState as os,useEffect as rs}from"react";import{jsx as ss,jsxs as is}from"react/jsx-runtime";var as={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, #f3f4f6)",padding:"6px 10px",borderRadius:"var(--semiotic-tooltip-radius, 4px)",fontSize:"var(--semiotic-tooltip-font-size, 12px)",fontFamily:"var(--semiotic-tick-font-family, var(--semiotic-font-family, sans-serif))",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.25))",lineHeight:1.4,pointerEvents:"none",whiteSpace:"nowrap"},ls={opacity:.7,marginRight:4};function cs(e,t,n){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:n]}function us(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function ds(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:o="x",yLabel:r="y"}=e;return e=>{const s=e?.data??null,i=cs(s,t,"time"),a=cs(s,n,"value");return is("div",{className:"semiotic-tooltip",style:as,children:[is("div",{children:[is("span",{style:ls,children:[o,":"]}),us(i)]}),is("div",{children:[is("span",{style:ls,children:[r,":"]}),us(a)]})]})}}function hs(e,t){return null!=e?e:Math.max(t?.length??0,200)}var ps="time",fs="value",ys="__aggLower",gs="__aggUpper",ms="__aggPartial",vs="count",xs="__aggStart",bs="__aggEnd";function ks(e,t){const n=t.stat??"mean",o=t.band??"none",r=t.sigma??1;return e.emit().map(e=>{const t={[ps]:(e.start+e.end)/2,[fs]:Gr(e,n),[vs]:e.count,[ms]:e.partial,[xs]:e.start,[bs]:e.end},s=qr(e,o,n,r);return s&&(t[ys]=s[0],t[gs]=s[1]),t})}function ws(e){const{linkedHover:t,selection:n,onObservation:o,onClick:r,hoverRadius:s,hoverHighlight:i,forceHoverBehavior:a,forceClickBehavior:l,mobileInteraction:c,customHoverBehavior:u,customClickBehavior:d,linkedHoverInClickPredicate:h=!0}=e,p={};o&&(p.annotationObservationCallback=o);const f=c?.enabled?Math.max(s??30,Math.ceil((c.targetSize||44)/2),24):s;return(a||t||o||r||i)&&(p.customHoverBehavior=u),d&&(l||(h?o||r||t:o||r)||c?.enabled&&(c.tapToSelect||c.tapToLockTooltip)&&(t||i||n))&&(p.customClickBehavior=d),null!=f&&(p.hoverRadius=f),p}import{jsx as As}from"react/jsx-runtime";function Ss(e,t,n){const o="function"==typeof t?t(e):e[t??n];if(null==o)return null;if(o instanceof Date)return o.getTime();const r=Number(o);return Number.isFinite(r)?r:null}var _s=ts(function(e,t){const n=We(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:o,margin:r,className:s,arrowOfTime:i="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:p,extentPadding:f,stroke:y="#007bff",strokeWidth:g=2,strokeDasharray:m,opacity:v,background:x,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:T,tickFormatTime:P,tickFormatValue:R,decay:M,pulse:N,staleness:I,transition:W,linkedHover:D,selection:E,onObservation:z,chartId:B,loading:L,loadingContent:O,emptyContent:H,emphasis:F,legendPosition:j,aggregate:$,eventTime:Y}=e,X=n.showAxes,V=n.enableHover,G=r??n.marginDefaults,q=o??[n.width,n.height],U=b??k??ds({timeAccessor:u,valueAccessor:d}),Q=Jr(null),{customHoverBehavior:K}=De({selection:E,linkedHover:D,unwrapData:!0,onObservation:z,chartType:"RealtimeLineChart",chartId:B}),Z=ns(e=>{w&&w(e),K(e)},[w,K]),J=null!=$,[ee,te]=os([]),ne=Jr(null),oe=Jr($);oe.current=$;const re=Jr(J);re.current=J;const se=Jr(ee);se.current=ee;const ie=Jr({timeAccessor:u,valueAccessor:d});ie.current={timeAccessor:u,valueAccessor:d},rs(()=>{if(!J)return void(ne.current=null);const e=oe.current,t=function(e){const t=e.window??"tumbling",n=Kr("session"===t?e.gap??e.size:e.size);if(null==n)return null;const o=null!=e.hop?Kr(e.hop):void 0,r=null!=e.gap?Kr(e.gap):void 0;return new Vr({window:t,size:n,hop:o??void 0,gap:r??void 0,retain:e.retain})}(e);if(ne.current=t,t&&c){const{timeAccessor:e,valueAccessor:n}=ie.current;for(const o of c){const r=Ss(o,e,"time"),s=Ss(o,n,"value");null!=r&&null!=s&&t.push(r,s)}}te(t?ks(t,e):[])},[J?[$.window??"tumbling",$.size,$.hop??"",$.gap??"",$.retain??""].join("|"):"",J,c]),rs(()=>{J&&ne.current&&te(ks(ne.current,oe.current))},[$?.stat,$?.band,$?.sigma]);const ae=ns(e=>{const t=ne.current,n=oe.current;if(!t||!n)return;const{timeAccessor:o,valueAccessor:r}=ie.current;for(const n of e){const e=Ss(n,o,"time"),s=Ss(n,r,"value");null!=e&&null!=s&&t.push(e,s)}te(ks(t,n))},[]),le=null!=Y,ce=Jr(null),ue=Jr(Y);ue.current=Y;const de=Jr(le);de.current=le;const he=Jr(z);he.current=z;const pe=Jr(B);pe.current=B,rs(()=>{ce.current=le?function(e){const t=Kr(e.lateness);return null==t?null:new Zr({lateness:t,getTime:e=>Ss(e,ie.current.timeAccessor,"time")??NaN,latePolicy:e.latePolicy??"drop"})}(ue.current):null},[le?`${Y.lateness}|${Y.latePolicy??"drop"}`:"",le]);const fe=ns(e=>{0!==e.length&&(re.current?ae(e):Q.current?.pushMany(e))},[ae]),ye=ns(e=>{const t=ce.current;if(!de.current||!t)return void fe(e);const n=[];for(const o of e){const e=t.push(o);if(e.released.length&&n.push(...e.released),e.late.length){const n=he.current;if(n){const{timeAccessor:o}=ie.current,r=ue.current?.latePolicy??"drop";for(const s of e.late)n({type:"late-data",datum:s,eventTime:Ss(s,o,"time")??NaN,watermark:t.watermark,policy:r,lateCount:t.lateCount,timestamp:Date.now(),chartType:"RealtimeLineChart",chartId:pe.current})}}}fe(n)},[fe]);es(t,()=>({push:e=>ye([e]),pushMany:e=>ye(e),remove:e=>re.current?[]:Q.current?.remove(e)??[],update:(e,t)=>re.current?[]:Q.current?.update(e,t)??[],clear:()=>{ce.current?.clear(),re.current?(ne.current?.clear(),te([])):Q.current?.clear()},getData:()=>re.current?se.current:Q.current?.getData()??[],getScales:()=>Q.current?.getScales()??null}),[ye]);const ge=C(L,q[0],q[1],O),me=ge?null:_(J?void 0:c,q[0],q[1],H),ve={stroke:y,strokeWidth:g,strokeDasharray:m};null!=v&&(ve.opacity=v);const xe=hs(l,c),be=J?ee:c,ke=J?ps:u,we=J?fs:d,Ae=J&&$&&"none"!==($.band??"none")?{y0Accessor:ys,y1Accessor:gs,perSeries:!1}:void 0;return ge||me||As(Ao,{ref:Q,chartType:"line",runtimeMode:"streaming",size:q,margin:G,className:F?`${s||""} semiotic-emphasis-${F}`.trim():s,arrowOfTime:i,windowMode:J?"growing":a,windowSize:J?Math.max(1,$?.retain??Math.max(ee.length,600)):xe,data:be,timeAccessor:ke,valueAccessor:we,xExtent:h,yExtent:p,extentPadding:f,band:Ae,lineStyle:ve,showAxes:X,background:x,hoverAnnotation:V,tooltipContent:U,...ws({linkedHover:D,selection:E,onObservation:z,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:Z}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:T,tickFormatTime:P,tickFormatValue:R,decay:M,pulse:N,staleness:I,transition:W,pointIdAccessor:e.pointIdAccessor,legendPosition:j})});_s.displayName="RealtimeLineChart";import{useRef as Ts,useImperativeHandle as Cs,forwardRef as Ps,useCallback as Rs,useMemo as Ms}from"react";import{jsx as Ns}from"react/jsx-runtime";var Is=Ps(function(e,t){const n=We(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,showAxes:e.showAxes,showLegend:e.showLegend,enableHover:null!=e.enableHover?!!e.enableHover:void 0,linkedHover:e.linkedHover,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{binSize:o,size:r,margin:s,className:i,arrowOfTime:a="right",windowMode:l="sliding",windowSize:c,data:u,timeAccessor:d,valueAccessor:h,direction:p="up",timeExtent:f,valueExtent:y,extentPadding:g,categoryAccessor:m,colors:v,fill:x,stroke:b,strokeWidth:k,opacity:w,gap:A,background:S,tooltipContent:T,tooltip:P,onHover:R,annotations:M,autoPlaceAnnotations:N,svgAnnotationRules:I,tickFormatTime:W,tickFormatValue:D,linkedHover:E,selection:z,decay:B,pulse:L,staleness:O,transition:H,onObservation:F,chartId:j,loading:$,loadingContent:Y,emptyContent:X,emphasis:V,legendPosition:G,legend:q,brush:U,onBrush:Q,linkedBrush:K}=e,J=n.showAxes,ee=n.enableHover,te=r??[n.width,n.height],ne=Ms(()=>v?e=>v[e]??x??"#999":void 0,[v,x]),{legend:oe,margin:re,legendPosition:se}=Ie({data:u??[],colorBy:m,colorScale:ne,showLegend:n.showLegend,legendPosition:G,userMargin:s,defaults:n.marginDefaults,additionalLegend:q}),ie=T??P??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const o=e?.data??null;if(null==o?.binStart||null==o?.binEnd){const e=cs(o,t,"time"),r=cs(o,n,"value");return is("div",{className:"semiotic-tooltip",style:as,children:[is("div",{children:[ss("span",{style:ls,children:"x:"}),us(e)]}),is("div",{children:[ss("span",{style:ls,children:"y:"}),us(r)]})]})}return is("div",{className:"semiotic-tooltip",style:as,children:[is("div",{children:[ss("span",{style:ls,children:"range:"}),us(o.binStart),"–",us(o.binEnd)]}),null!=o.total&&is("div",{children:[ss("span",{style:ls,children:"count:"}),us(o.total)]}),null!=o.category&&is("div",{children:[ss("span",{style:ls,children:"category:"}),us(o.category)]})]})}}({timeAccessor:d,valueAccessor:h}),ae=Ts(null),{customHoverBehavior:le}=De({selection:z,linkedHover:E,unwrapData:!0,onObservation:F,chartType:"RealtimeHistogram",chartId:j}),ce=Rs(e=>{R&&R(e),le(e)},[R,le]),ue=!0===U?{dimension:"x",snap:"bin"}:"x"===U?{dimension:"x"}:"object"==typeof U?U:void 0,de=Se(K),he="string"==typeof d?d:"time",pe=Ne({name:de?.name||"__unused_hist_brush__",xField:de?.xField||he,...de?.yField?{yField:de.yField}:{}}),fe=Ts(pe.brushInteraction);fe.current=pe.brushInteraction;const ye=Rs(e=>{if(Q&&Q(e),F&&F(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:j}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:j}),de){const t=fe.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[Q,F,j,de]);Cs(t,()=>({push:e=>ae.current?.push(e),pushMany:e=>ae.current?.pushMany(e),remove:e=>ae.current?.remove(e)??[],update:(e,t)=>ae.current?.update(e,t)??[],clear:()=>ae.current?.clear(),getData:()=>ae.current?.getData()??[],getScales:()=>ae.current?.getScales()??null}),[]);const ge=C($,te[0],te[1],Y),me=ge?null:_(u,te[0],te[1],X),ve={};null!=x&&(ve.fill=x),null!=b&&(ve.stroke=b),null!=k&&(ve.strokeWidth=k),null!=w&&(ve.opacity=w),null!=A&&(ve.gap=A);const xe=V?`${i||""} semiotic-emphasis-${V}`.trim():i,be=hs(c,u),ke=Ms(()=>"down"!==p?y:Z({data:u,valueAccessor:h,timeAccessor:d,binSize:o,valueExtent:y,extentPadding:g}),[p,u,h,d,o,y,g]);return ge||me||Ns(Ao,{ref:ae,chartType:"bar",runtimeMode:"streaming",size:te,margin:re,className:xe,arrowOfTime:a,windowMode:l,windowSize:be,data:u,timeAccessor:d,valueAccessor:h,xExtent:f,yExtent:ke,extentPadding:g,binSize:o,categoryAccessor:m,barColors:v,barStyle:ve,showAxes:J,background:S,hoverAnnotation:ee,tooltipContent:ie,...ws({linkedHover:E,selection:z,onObservation:F,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:ce}),annotations:M,autoPlaceAnnotations:N,svgAnnotationRules:I,tickFormatTime:W,tickFormatValue:D,decay:B,pulse:L,staleness:O,transition:H,pointIdAccessor:e.pointIdAccessor,legend:oe,legendPosition:se,brush:ue||(K?{dimension:"x"}:void 0),onBrush:ue||K?ye:void 0})});function Ws(e){return Ns(Is,{...e,windowMode:"growing"})}Is.displayName="RealtimeHistogram",Ws.displayName="TemporalHistogram";import{useRef as Ds,useImperativeHandle as Es,forwardRef as zs,useCallback as Bs}from"react";import{jsx as Ls}from"react/jsx-runtime";var Os=zs(function(e,t){const n=We(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:o,margin:r,className:s,arrowOfTime:i="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:p,yScaleType:f,extentPadding:y,categoryAccessor:g,colors:m,radius:v,fill:x,opacity:b,stroke:k,strokeWidth:w,pointStyle:A,background:S,tooltipContent:T,tooltip:P,onHover:R,annotations:M,autoPlaceAnnotations:N,svgAnnotationRules:I,tickFormatTime:W,tickFormatValue:D,linkedHover:E,selection:z,onObservation:B,chartId:L,loading:O,loadingContent:H,emptyContent:F,emphasis:j,legendPosition:$}=e,Y=n.showAxes,X=n.enableHover,V=r??n.marginDefaults,G=o??[n.width,n.height],q=T??P??ds({timeAccessor:u,valueAccessor:d}),U=Ds(null),{customHoverBehavior:Q}=De({selection:z,linkedHover:E,unwrapData:!0,onObservation:B,chartType:"RealtimeSwarmChart",chartId:L}),K=Bs(e=>{R&&R(e),Q(e)},[R,Q]);Es(t,()=>({push:e=>U.current?.push(e),pushMany:e=>U.current?.pushMany(e),remove:e=>U.current?.remove(e)??[],update:(e,t)=>U.current?.update(e,t)??[],clear:()=>U.current?.clear(),getData:()=>U.current?.getData()??[],getScales:()=>U.current?.getScales()??null}),[]);const Z=C(O,G[0],G[1],H),J=Z?null:_(c,G[0],G[1],F),ee={};null!=v&&(ee.radius=v),null!=x&&(ee.fill=x),null!=b&&(ee.opacity=b),null!=k&&(ee.stroke=k),null!=w&&(ee.strokeWidth=w);const te=A,ne=j?`${s||""} semiotic-emphasis-${j}`.trim():s,oe=hs(l,c);return Z||J||Ls(Ao,{ref:U,chartType:"swarm",runtimeMode:"streaming",size:G,margin:V,className:ne,arrowOfTime:i,windowMode:a,windowSize:oe,data:c,timeAccessor:u,valueAccessor:d,xExtent:h,yExtent:p,yScaleType:f,extentPadding:y,categoryAccessor:g,barColors:m,swarmStyle:ee,pointStyle:te,showAxes:Y,background:S,hoverAnnotation:X,tooltipContent:q,...ws({linkedHover:E,selection:z,onObservation:B,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:K}),annotations:M,autoPlaceAnnotations:N,svgAnnotationRules:I,tickFormatTime:W,tickFormatValue:D,legendPosition:$,pointIdAccessor:e.pointIdAccessor})});Os.displayName="RealtimeSwarmChart";import{useRef as Hs,useImperativeHandle as Fs,forwardRef as js,useCallback as $s}from"react";import{jsx as Ys}from"react/jsx-runtime";var Xs=js(function(e,t){const n=We(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:o,margin:r,className:s,arrowOfTime:i="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,timeExtent:h,valueExtent:p,extentPadding:f,positiveColor:y,negativeColor:g,connectorStroke:m,connectorWidth:v,gap:x,stroke:b,strokeWidth:k,opacity:w,background:A,tooltipContent:S,tooltip:T,onHover:P,annotations:R,autoPlaceAnnotations:M,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:W,linkedHover:D,selection:E,onObservation:z,chartId:B,loading:L,loadingContent:O,emptyContent:H,emphasis:F,legendPosition:j}=e,$=n.showAxes,Y=n.enableHover,X=r??n.marginDefaults,V=o??[n.width,n.height],G=S??T??function(e={}){const{timeAccessor:t,valueAccessor:n}=e;return e=>{const o=e?.data??null,r=cs(o,t,"time"),s=o?.delta??cs(o,n,"value"),i=o?.cumEnd,a="number"==typeof s?0>s?us(s):"+"+us(s):us(s);return is("div",{className:"semiotic-tooltip",style:as,children:[is("div",{children:[ss("span",{style:ls,children:"x:"}),us(r)]}),is("div",{children:[ss("span",{style:ls,children:"Δ:"}),a]}),null!=i&&is("div",{children:[ss("span",{style:ls,children:"total:"}),us(i)]})]})}}({timeAccessor:u,valueAccessor:d}),q=Hs(null),{customHoverBehavior:U}=De({selection:E,linkedHover:D,unwrapData:!0,onObservation:z,chartType:"RealtimeWaterfallChart",chartId:B}),Q=$s(e=>{P&&P(e),U(e)},[P,U]);Fs(t,()=>({push:e=>q.current?.push(e),pushMany:e=>q.current?.pushMany(e),remove:e=>q.current?.remove(e)??[],update:(e,t)=>q.current?.update(e,t)??[],clear:()=>q.current?.clear(),getData:()=>q.current?.getData()??[],getScales:()=>q.current?.getScales()??null}),[]);const K=C(L,V[0],V[1],O),Z=K?null:_(c,V[0],V[1],H),J={};null!=y&&(J.positiveColor=y),null!=g&&(J.negativeColor=g),null!=m&&(J.connectorStroke=m),null!=v&&(J.connectorWidth=v),null!=x&&(J.gap=x),null!=b&&(J.stroke=b),null!=k&&(J.strokeWidth=k),null!=w&&(J.opacity=w);const ee=F?`${s||""} semiotic-emphasis-${F}`.trim():s,te=hs(l,c);return K||Z||Ys(Ao,{ref:q,chartType:"waterfall",runtimeMode:"streaming",size:V,margin:X,className:ee,arrowOfTime:i,windowMode:a,windowSize:te,data:c,timeAccessor:u,valueAccessor:d,xExtent:h,yExtent:p,extentPadding:f,waterfallStyle:J,showAxes:$,background:A,hoverAnnotation:Y,tooltipContent:G,...ws({linkedHover:D,selection:E,onObservation:z,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:Q}),annotations:R,autoPlaceAnnotations:M,svgAnnotationRules:N,tickFormatTime:I,tickFormatValue:W,legendPosition:j,pointIdAccessor:e.pointIdAccessor})});Xs.displayName="RealtimeWaterfallChart";import{useRef as Vs,useImperativeHandle as Gs,forwardRef as qs,useCallback as Us}from"react";import{jsx as Qs}from"react/jsx-runtime";var Ks=qs(function(e,t){const n=We(e.mode,{width:e.size?.[0]??e.width,height:e.size?.[1]??e.height,enableHover:null!=e.enableHover?!!e.enableHover:void 0,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{size:o,margin:r,className:s,arrowOfTime:i="right",windowMode:a="sliding",windowSize:l,data:c,timeAccessor:u,valueAccessor:d,categoryAccessor:h,timeExtent:p,valueExtent:f,extentPadding:y,heatmapXBins:g=20,heatmapYBins:m=20,aggregation:v="count",background:x,tooltipContent:b,tooltip:k,onHover:w,annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:T,tickFormatTime:P,tickFormatValue:R,decay:M,pulse:N,staleness:I,linkedHover:W,selection:D,onObservation:E,chartId:z,loading:B,loadingContent:L,emptyContent:O,emphasis:H,legendPosition:F}=e,j=n.showAxes,$=n.enableHover,Y=r??n.marginDefaults,X=o??[n.width,n.height],V=b??k??function(e={}){const{timeAccessor:t,valueAccessor:n,xLabel:o="x",yLabel:r="y"}=e;return e=>{const s=e?.data??null,i=s?.xCenter??cs(s,t,"time"),a=s?.yCenter??cs(s,n,"value"),l=s?.count,c=s?.sum,u=s?.value,d=s?.agg??"count";return is("div",{className:"semiotic-tooltip",style:as,children:[is("div",{children:[is("span",{style:ls,children:[o,":"]}),us(i)]}),is("div",{children:[is("span",{style:ls,children:[r,":"]}),us(a)]}),null!=l&&is("div",{children:[ss("span",{style:ls,children:"count:"}),us(l)]}),"sum"===d&&null!=c&&is("div",{children:[ss("span",{style:ls,children:"sum:"}),us(c)]}),"mean"===d&&null!=u&&is("div",{children:[ss("span",{style:ls,children:"mean:"}),us(u)]})]})}}({timeAccessor:u,valueAccessor:d}),G=Vs(null),{customHoverBehavior:q}=De({selection:D,linkedHover:W,unwrapData:!0,onObservation:E,chartType:"RealtimeHeatmap",chartId:z}),U=Us(e=>{w&&w(e),q(e)},[w,q]);Gs(t,()=>({push:e=>G.current?.push(e),pushMany:e=>G.current?.pushMany(e),remove:e=>G.current?.remove(e)??[],update:(e,t)=>G.current?.update(e,t)??[],clear:()=>G.current?.clear(),getData:()=>G.current?.getData()??[],getScales:()=>G.current?.getScales()??null}),[]);const Q=C(B,X[0],X[1],L),K=Q?null:_(c,X[0],X[1],O),Z=H?`${s||""} semiotic-emphasis-${H}`.trim():s,J=hs(l,c);return Q||K||Qs(Ao,{ref:G,chartType:"heatmap",runtimeMode:"streaming",size:X,margin:Y,className:Z,arrowOfTime:i,windowMode:a,windowSize:J,data:c,timeAccessor:u,valueAccessor:d,categoryAccessor:h,xExtent:p,yExtent:f,extentPadding:y,heatmapXBins:g,heatmapYBins:m,heatmapAggregation:v,showAxes:j,background:x,hoverAnnotation:$,tooltipContent:V,...ws({linkedHover:W,selection:D,onObservation:E,forceHoverBehavior:!0,mobileInteraction:n.mobileInteraction,customHoverBehavior:U}),annotations:A,autoPlaceAnnotations:S,svgAnnotationRules:T,tickFormatTime:P,tickFormatValue:R,decay:M,pulse:N,staleness:I,legendPosition:F,pointIdAccessor:e.pointIdAccessor})});Ks.displayName="RealtimeHeatmap";export{Be as DEFAULT_LIFECYCLE_THRESHOLDS,oe as IncrementalExtent,Ks as RealtimeHeatmap,Is as RealtimeHistogram,_s as RealtimeLineChart,Os as RealtimeSwarmChart,Xs as RealtimeWaterfallChart,Zr as ReorderBuffer,re as RingBuffer,Xr as RunningStats,Yr as StreamNetworkFrame,Ao as StreamXYFrame,Ws as TemporalHistogram,Vr as WindowAccumulator,qr as bandBounds,Le as bandFromAge,$ as compileMotionEncoding,V as deriveMotionVector,U as opacityFromAge,Kr as parseWindowDuration,J as resolveMotionAccessor,ee as resolveMotionVector,Gr as statValue};