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
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{needsDataCanvasPaint as e,paintCanvasBackground as t}from"./chunk-chunk-OQTLSTGI.module.min.js";import{StalenessBadge as r,attachUpdateResultStore as n,buildNavGraph as o,composeOverlays as i,computeDecayOpacity as a,createCustomLayoutFailureDiagnostic as s,extractNetworkNavPoints as c,findHitPointInQuadtree as l,formatVal as u,getHitRadius as d,hitTestRect as h,networkGlyphRenderer as y,nextNetworkIndex as f,normalizeAngle as g,paintSceneWithBackend as p,renderCirclePulse as m,renderRectPulse as v,renderSceneWithBackend as x,resolvePosition as k,useConfigSync as b,useLayoutSelectionSync as S,useStableShallow as _,useStalenessCheck as w,warnCustomLayoutDiagnostics as A}from"./chunk-chunk-A63CTACR.module.min.js";import{CustomLayoutSelectionProvider as L,wrapWithCustomLayoutSelection as E}from"./chunk-chunk-5UKL5W76.module.min.js";import{commonJsWorkerModuleUrl as P}from"./chunk-chunk-SV4XAZ3Q.module.min.js";import{buildResolveColor as D,resolveCustomLayoutPalette as N}from"./chunk-chunk-SANERMIZ.module.min.js";import{ANNOTATION_DISCLOSURE_REVEAL_CSS as R,AriaLiveTooltip as M,CanvasFrameBackground as T,DEFAULT_COLORS as C,FlippingTooltip as W,FocusRing as I,NetworkAccessibleDataTable as $,SceneRevisionDiagnosticsObserver as z,ScreenReaderSummary as F,SkipToTableLink as B,TITLE_BASELINE as O,UpdateResultTracker as Y,annotationActivationProps as X,annotationLayout as j,buildHoverData as H,computeEasing as G,computeNetworkAriaLabel as V,computeRawProgress as q,createDefaultAnnotationRules as Q,createSeededFrameRandom as K,defaultTooltipStyle as Z,emitClickObservations as U,emitHoverObservations as J,filterSparseArray as ee,getDevicePixelRatio as te,isAnnotationActivationTarget as re,isInteractiveKeyboardTarget as ne,isServerEnvironment as oe,lerp as ie,networkLabelToSVG as ae,networkSceneEdgeToSVG as se,networkSceneNodeToSVG as ce,now as le,observationInputType as ue,prepareCanvas as de,renderAnnotationPass as he,renderLegendFromConfig as ye,resolveCSSColor as fe,resolveCanvasFill as ge,runSceneBuild as pe,schemeCategory10 as me,smartTooltipEntries as ve,symbolPathString as xe,symbolRadius as ke,useAnnotationActivationOptions as be,useFrame as Se,useFrameCanvasHost as _e,useSceneRevisionDiagnostics as we}from"./chunk-chunk-6HSGDMTA.module.min.js";import{getMinMax as Ae}from"./chunk-chunk-JJ2OOIET.module.min.js";import{resolveThemeSemanticColors as Le}from"./chunk-chunk-WCX6U47H.module.min.js";import{glyphHitGeometry as Ee}from"./chunk-chunk-KTWEBFMX.module.min.js";import{renderLoadingState as Pe,useHydration as De,useWasHydratingFromSSR as Ne}from"./chunk-chunk-ZCNBUZPL.module.min.js";import{useRef as Re,useState as Me,useEffect as Te,useMemo as Ce,useCallback as We,useImperativeHandle as Ie,forwardRef as $e,memo as ze}from"react";var Fe={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Be={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1},Oe=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 r=this._freeIndices.pop();if(void 0===r)return null;const n=this.particles[r];return n.active=!0,n.t=0,n.offset=t()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}step(e,t,r,n){for(let o=0;this.capacity>o;o++){const i=this.particles[o];if(!i.active)continue;const a=r[i.edgeIndex];a&&a.bezier?(i.t+=e*t*(n?n[i.edgeIndex]??1:1)*(a.bezier.circular?.3:1),1>i.t?Ye(a.bezier,i.t,i.offset,i):(i.active=!1,this._freeIndices.push(o))):(i.active=!1,this._freeIndices.push(o))}}countForEdge(e){let t=0;for(let r=0;this.capacity>r;r++)this.particles[r].active&&this.particles[r].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 r=0;e>r;r++)t.length>r?this.particles[r]=t[r]:(this.particles[r]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(r));this.capacity=e}};function Ye(e,t,r,n){if(e.circular&&e.segments)return void function(e,t,r,n,o){const i=e.length,a=t*i,s=Math.min(Math.floor(a),i-1),c=a-s,[l,u,d,h]=e[s];Xe(l,u,d,h,c,o);const y=h.x-l.x,f=h.y-l.y,g=Math.sqrt(y*y+f*f);if(g>.001){const e=y/g;o.x+=-f/g*r*n*2,o.y+=e*r*n*2}}(e.segments,t,r,e.halfWidth,n);if(!e.points)return n.x=0,void(n.y=0);const[o,i,a,s]=e.points;Xe(o,i,a,s,t,n);const c=s.x-o.x,l=s.y-o.y,u=Math.sqrt(c*c+l*l);if(u>.001){const t=c/u;n.x+=-l/u*r*e.halfWidth*2,n.y+=t*r*e.halfWidth*2}}function Xe(e,t,r,n,o,i){const a=1-o,s=a*a,c=s*a,l=o*o,u=l*o;i.x=c*e.x+3*s*o*t.x+3*a*l*r.x+u*n.x,i.y=c*e.y+3*s*o*t.y+3*a*l*r.y+u*n.y}function je(e,t){var r=e.get(t);if(!r)throw Error("missing: "+t);return r}function He(e,t){var r,n=[],o=[],i=[],a={},s=[];function c(e){i[e]=!1,a.hasOwnProperty(e)&&Object.keys(a[e]).forEach(function(t){delete a[e][t],i[t]&&c(t)})}function l(e){var t,n,d=!1;for(o.push(e),i[e]=!0,t=0;s[e].length>t;t++)(n=s[e][t])===r?(u(r,o),d=!0):i[n]||(d=l(n));if(d)c(e);else for(t=0;s[e].length>t;t++){var h=a[n=s[e][t]];h||(a[n]=h={}),h[n]=!0}return o.pop(),d}function u(e,r){var o=[].concat(r).concat(e);t?t(o):n.push(o)}function d(t){!function(t){for(var r=0;e.length>r;r++)r>=t&&e[r]||(e[r]=[]),e[r]=e[r].filter(function(e){return e>=t})}(t);for(var r,n=function(e){for(var t=e.length,r=Array(t),n=Array(t),o=Array(t),i=Array(t),a=Array(t),s=Array(t),c=0;t>c;++c)r[c]=-1,n[c]=0,o[c]=!1,i[c]=0,a[c]=-1,s[c]=[];var l,u=0,d=[],h=[];function y(t){var c=[t],l=[t];for(r[t]=n[t]=u,o[t]=!0,u+=1;l.length>0;){var y=e[t=l[l.length-1]];if(y.length>i[t]){for(var f=i[t];y.length>f;++f){var g=y[f];if(0>r[g]){r[g]=n[g]=u,o[g]=!0,u+=1,c.push(g),l.push(g);break}o[g]&&(n[t]=0|Math.min(n[t],n[g])),0>a[g]||s[t].push(a[g])}i[t]=f}else{if(n[t]===r[t]){var p=[],m=[],v=0;for(f=c.length-1;f>=0;--f){var x=c[f];if(o[x]=!1,p.push(x),m.push(s[x]),v+=s[x].length,a[x]=d.length,x===t){c.length=f;break}}d.push(p);var k=Array(v);for(f=0;m.length>f;f++)for(var b=0;m[f].length>b;b++)k[--v]=m[f][b];h.push(k)}l.pop()}}}for(c=0;t>c;++c)0>r[c]&&y(c);for(c=0;h.length>c;c++){var f=h[c];if(0!==f.length){f.sort(function(e,t){return e-t}),l=[f[0]];for(var g=1;f.length>g;g++)f[g]!==f[g-1]&&l.push(f[g]);h[c]=l}}return{components:d,adjacencyList:h}}(e),o=n.components.filter(function(e){return e.length>1}),i=1/0,a=0;o.length>a;a++)for(var s=0;o[a].length>s;s++)i>o[a][s]&&(i=o[a][s],r=a);var c=o[r];return!!c&&{leastVertex:i,adjList:e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})})}}r=0;for(var h=e.length;h>r;){var y=d(r);if(r=y.leastVertex,s=y.adjList){for(var f=0;s.length>f;f++)for(var g=0;s[f].length>g;g++){var p=s[f][g];i[+p]=!1,a[p]={}}l(r),r+=1}else r=h}return t?void 0:n}function Ge(e){return e.y0-e.y1>0?"up":"down"}function Ve(e,t){return t(e.source)==t(e.target)}function qe(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var r=0;return e.target.targetLinks.forEach(function(e){r=e.circular?r+1:r}),1>=t&&1>=r}function Qe(e){return e.target.x0-e.source.x1}function Ke(e,t){var r=Ue(e),n=Qe(t)/Math.tan(r);return"up"==Ge(e)?e.y1-n:e.y1+n}function Ze(e,t){var r=Ue(e),n=Qe(t)/Math.tan(r);return"up"==Ge(e)?e.y1+n:e.y1-n}function Ue(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Je(e,t){return t(e)}function et(e){return rt(e.source)}function tt(e){return rt(e.target)}function rt(e){return(e.y0+e.y1)/2}function nt(e){return e.virtual?0:e.value}function ot(e,t){var r=0;e.sourceLinks.forEach(function(e){r=e.circular&&!Ve(e,t)?r+1:r});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!Ve(e,t)?n+1:n}),r+n}function it(e){return e.target.depth}function at(e,t){return e.sourceLinks.length?e.depth:t-1}function st(e,t){return e.y0-t.y0}function ct(e,t){return t.y0-e.y0}function lt(e,t){return e.y1-t.y1}function ut(e,t){return t.y1-e.y1}function dt(e,t){return yt(e.source,t.source)||e.index-t.index}function ht(e,t){return yt(e.target,t.target)||e.index-t.index}function yt(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function ft(e,t){return gt(e)==gt(t)?"bottom"==e.circularLinkType?ct(e,t):st(e,t):gt(t)-gt(e)}function gt(e){return e.target.column-e.source.column}function pt(e,t){return mt(e)==mt(t)}function mt(e){return e.y0-e.y1>0?"up":"down"}import{min as vt}from"d3-array";function xt(e,t,r,n,o){let i=e;var a=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,a))});var s=vt(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}),kt(i.links.filter(function(e){return"top"==e.circularLinkType}),t,r),kt(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,r),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+n,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,Ve(e,t)&&qe(e))e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=n+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var a=e.source.column,c=e.circularLinkType,l=i.links.filter(function(e){return e.source.column==a&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?ct:st);var u=0;l.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2+o*r+u),u+=t._circularWidth||t.width}),a=e.target.column,(l=i.links.filter(function(e){return e.target.column==a&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?ut:lt),u=0,l.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=n+e._circularWidth/2+o*r+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=s-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,r=e.y0,n=e.target.x0,o=e.y1,i=(t+n)/2;return"M"+t+","+r+"C"+i+","+r+" "+i+","+o+" "+n+","+o}(e)}),i}function kt(e,t,r){e.sort(ft);var n=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(Ve(e,t)&&qe(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var a=0;n.length>a;a++){var s=n[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&bt(e,s)){var c=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+r;i=c>i?c:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function bt(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}import{min as St,max as _t,sum as wt,mean as At,group as Lt,groups as Et}from"d3-array";function Pt(e){return function(){return e}}function Dt(e){return e.index}function Nt(e){return e.nodes}function Rt(e){return e.links}function Mt(e,t,r){var n=Et(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});n.forEach(function(o,i){var a=o.length;if(t)o.sort(t);else if(i>0){var s=new Map;o.forEach(function(e,t){var r,n,o,i=(n=0,o=0,(r=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=rt(e.source)*t,n+=t}}),r.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=rt(e.target)*t,n+=t}}),n>0?o/n:NaN);s.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var r=s.get(e),n=s.get(t),o=r.bc,i=n.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)?r.idx-n.idx:1:-1:o-i})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?ot(t,r)-ot(e,r):"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==n.length-1&&1==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==ot(t,r)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/a*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+o,t.y1=t.y0+t.value*e.ky)})})}function Tt(e,t,r,n,o,i){var a=Et(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var s=1,c=i;c>0;--c)l(s*=.99,r),u();function l(t,r){var n=a.length;a.forEach(function(o){var i=o.length,a=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&ot(o,r)>0){var c=At(o.sourceLinks,tt),l=At(o.targetLinks,et),u=c&&l?(c+l)/2:c||l;if(u){var d=(u-rt(o))*t*.3;o.y0+=d,o.y1+=d}}else if(0==a&&1==i)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(a==n-1&&1==i)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)s=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+s;else{var h=At(o.sourceLinks,tt),y=At(o.targetLinks,et),f=((h&&y?(h+y)/2:h||y)-rt(o))*t;o.y0+=f,o.y1+=f}})})}function u(){a.forEach(function(r){var i,a,s,c=e.y0,l=r.length;for(r.sort(t||yt),s=0;l>s;++s)(a=c-(i=r[s]).y0)>0&&(i.y0+=a,i.y1+=a),c=i.y1+n;if((a=c-n-e.y1)>0)for(c=i.y0-=a,i.y1-=a,s=l-2;s>=0;--s)(a=(i=r[s]).y1+o-c)>0&&(i.y0-=a,i.y1-=a),c=i.y0})}}function Ct(e){e.nodes.forEach(function(e){e.sourceLinks.sort(ht),e.targetLinks.sort(dt)}),e.nodes.forEach(function(e){var t=e.y0,r=t,n=e.y1,o=n;e.sourceLinks.forEach(function(e){e.circular?(e.y0=n-e.width/2,n-=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=r+e.width/2,r+=e.width)})})}function Wt(){var e=0,t=0,r=1,n=1,o=24,i=8,a=null,s=Dt,c=at,l=void 0,u=32,d=2,h=Nt,y=Rt;function f(){var f={nodes:h.apply(null,arguments),links:y.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=r,h.y1=n,h.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var r=function(e,t){var r=new Map;return Lt(e,t).forEach(function(e,t){r.set(t,e[0])}),r}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var n=e.source,o=e.target;"object"!=typeof n&&(n=e.source=je(r,n)),"object"!=typeof o&&(o=e.target=je(r,o)),n.sourceLinks.push(e),o.targetLinks.push(e)})}(h,s),function(e,t){var r=0;if(null==t){for(var n=[],o=0;e.links.length>o;o++){var i=e.links[o],a=i.source.index,s=i.target.index;n[a]||(n[a]=[]),n[s]||(n[s]=[]),-1===n[a].indexOf(s)&&n[a].push(s)}var c=He(n);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,n=e.source.index;t===n||l[n]&&l[n][t]?(e.circular=!0,e.circularLinkID=r++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=r++)})}(h,l),function(e,t){var r=0,n=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:n>r?"top":"bottom","top"==o.circularLinkType?r++:n++,e.nodes.forEach(function(e){Je(e,t)!=Je(o.source,t)&&Je(e,t)!=Je(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),Ve(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,s),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(wt(e.sourceLinks,nt),wt(e.targetLinks,nt)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(h),function(e,t,r){var n,o,i;if(null!=t){e.nodes.sort(function(e,r){return t(e)<t(r)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(n=e.nodes,o=[],i=0;n.length;++i,n=o,o=[])n.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?r(e,i):e.column})}(h,l,c);var y=i;if(null!==a){var f=Et(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),g=_t(f,function(e){return e.length});g>1&&(y=Math.max(1,(n-t)*a/(g-1)))}(function(e,t,r){var n=Et(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=St(n,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/wt(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=_t(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-r)/i),t.x1=t.x0+r}:function(t){t.x0=e.x0,t.x1=t.x0+r})})(h,y,o),Mt(h,l,s),Tt(h,l,s,y,y,u),Ct(h),xt(h,s,d,10,8),Mt(h,l,s),Tt(h,l,s,y,y,u),Ct(h),xt(h,s,d,10,8),function(e,t){let r=e;r.nodes.forEach(function(e){e.y+(e.y1-e.y0)>r.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-r.y1));var n=r.links.filter(function(r){return Je(r.source,t)==Je(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!pt(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var r=Ke(t,e);return e.y1-r}if(t.target.column>e.target.column)return Ke(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;n.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var i=r+1,a=0;o>i;i++)a+=n[i].width;t.y0=e.y1-a-t.width/2}})})}(h,s),function(e,t){let r=e;r.nodes.forEach(function(e){var n=r.links.filter(function(r){return Je(r.target,t)==Je(e,t)}),o=n.length;o>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!pt(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var r=Ze(t,e);return e.y0-r}if(t.source.column>e.source.column)return Ze(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;n.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),n.forEach(function(t,r){if("bottom"==t.circularLinkType){for(var i=r+1,a=0;o>i;i++)a+=n[i].width;t.y1=e.y1-a-t.width/2}})})}(h,s),function(e){var t=e.nodes,r=e.links,n=!1,o=!1;if(r.forEach(function(e){"top"==e.circularLinkType?n=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==n||0==o){let n=function(t){return(t-i)/(a-i)*(e.y1-e.y0)+e.y0};var i=St(t,function(e){return e.y0}),a=_t(t,function(e){return e.y1}),s=(e.y1-e.y0)/(a-i);1>s?(t.forEach(function(e){e.y0=n(e.y0),e.y1=n(e.y1)}),r.forEach(function(e){e.y0=n(e.y0),e.y1=n(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,r=n(e.y0)-e.y0;e.y0=n(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+r}),e.targetLinks.forEach(function(e){e.y1=e.y1+r})})}}(h),xt(h,s,d,10,8)}(f),f}return f.update=function(e){return Ct(e),xt(e,s,d,10,8),e},f.nodeWidth=function(e){return arguments.length?(o=+e,f):o},f.nodePadding=function(e){return arguments.length?(i=+e,f):i},f.nodePaddingRatio=function(e){return arguments.length?(a=+e,f):a},f.nodes=function(e){return arguments.length?(h="function"==typeof e?e:Pt(e),f):h},f.links=function(e){return arguments.length?(y="function"==typeof e?e:Pt(e),f):y},f.nodeId=function(e){return arguments.length?(s="function"==typeof e?e:Pt(e),f):s},f.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:Pt(e),f):c},f.nodeSort=function(e){return arguments.length?(l=e,f):l},f.iterations=function(e){return arguments.length?(u=+e,f):u},f.circularLinkGap=function(e){return arguments.length?(d=+e,f):d},f.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],r=+o[1][0],n=+o[1][1],f):[[e,t],[r,n]]},f.size=function(o){return arguments.length?(e=t=0,r=+o[0],n=+o[1],f):[r-e,n-t]},f}import{interpolateNumber as It}from"d3-interpolate";import{line as $t,curveLinearClosed as zt}from"d3-shape";function Ft(e){const{sx:t,sTop:r,sBot:n,tx:o,tTop:i,tBot:a,cp1X:s,cp2X:c}=e,l=(r+n)/2,u=(i+a)/2;return{pathD:[`M${t},${r}`,`C${s},${r} ${c},${i} ${o},${i}`,`L${o},${a}`,`C${c},${a} ${s},${n} ${t},${n}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:l},{x:s,y:l},{x:c,y:u},{x:o,y:u}],halfWidth:(n-r)/2}}}var Bt=e=>{let t,r,n,o,i,a,s,c,l;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,r=e.y1-e.sankeyWidth/2,n=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.x1,a=e.target.x0,s=It(i,a),c=s(.5),l=s(.5),`M${t},${i}C${t},${c} ${r},${l} ${r},${a}L${n},${a}C${n},${l} ${o},${c} ${o},${i}Z`;const u=e.sankeyWidth/2,d=It(e.source.x1,e.target.x0),{pathD:h}=Ft({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:d(.5),cp2X:d(.5)});return h};function Ot(e){const t=e.sankeyWidth/2,r=(e._circularWidth??e.sankeyWidth)/2,n=e.circularPathData;if(!n)return null;if("down"===e.direction)return null;if(e._circularStub){const r=n.sourceX,o=n.sourceY,i=n.targetX,a=n.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const s=Math.max(15,Math.min(40,.33*(n.rightFullExtent-r))),c=Math.max(15,Math.min(40,.33*(i-n.leftFullExtent)));return`M${r},${o-t}L${r+s},${o-t}L${r+s},${o+t}L${r},${o+t}ZM${i},${a-t}L${i-c},${a-t}L${i-c},${a+t}L${i},${a+t}Z`}const o=n.sourceX,i=n.sourceY,a=n.targetX,s=n.targetY,c=n.rightFullExtent,l=n.leftFullExtent,u=n.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(r,15));return`M${o},${i-d*t}L${c},${i-d*t}L${c+r},${i-d*t+d*h}L${c+r},${u+d*r-d*h}L${c+r-h},${u+d*r}L${l-r+h},${u+d*r}L${l-r},${u+d*r-d*h}L${l-r},${s-d*t+d*h}L${l-r+h},${s-d*t}L${a},${s-d*t}L${a},${s+d*t}L${l+r},${s+d*t}L${l+r},${u-d*r}L${c-r},${u-d*r}L${c-r},${i+d*t}L${o},${i+d*t}Z`}var Yt=new Set,Xt=new WeakMap;function jt(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let r=Xt.get(e);if(r){const e=r.get(t);if(e)return e}else r=new Map,Xt.set(e,r);const n=new Proxy(e,{get(e,r,n){if("string"==typeof r&&!(r in e)&&e.data&&r in e.data){const e=`${t}:${r}`;Yt.has(e)||(Yt.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${r}" on the wrapper object, but it only exists on ".data". Use d.data.${r} (or d.data?.${r}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,r,n)}});return r.set(t,n),n}var Ht={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(it))-1:0},justify:at};function Gt(e){return"string"==typeof e?e:e.id}var Vt={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const o="vertical"===r.orientation?"down":"right",i=r.nodeAlign||"justify",a=r.nodeWidth??15,s=r.nodePaddingRatio??.05,c=r.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 d;d="down"===o?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const h=Wt().extent(d).links(u).nodes(l).nodeAlign(Ht[i]||at).nodeId(e=>e.id).nodeWidth(a).iterations(c);h.nodePaddingRatio&&h.nodePaddingRatio(s),h();{let e=1/0,t=-1/0,r=1/0,o=-1/0;for(const n of l)e>n.x0&&(e=n.x0),n.x1>t&&(t=n.x1),r>n.y0&&(r=n.y0),n.y1>o&&(o=n.y1);for(const n of u){if(!n.circular||!n.circularPathData)continue;const i=n.circularPathData,a=(n._circularWidth??n.width??0)/2;e>i.leftFullExtent-a&&(e=i.leftFullExtent-a),i.rightFullExtent+a>t&&(t=i.rightFullExtent+a),r>i.verticalFullExtent-a&&(r=i.verticalFullExtent-a),i.verticalFullExtent+a>o&&(o=i.verticalFullExtent+a)}const i=t-e,a=o-r,s=n[0],c=n[1];if(i>0&&a>0&&(0>e||0>r||t>s||o>c)){const t=Math.min(s/i,c/a),n=-e*t+(s-i*t)/2,o=-r*t+(c-a*t)/2;for(const e of l)e.x0=e.x0*t+n,e.x1=e.x1*t+n,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 r=e.circularPathData;r.sourceX=r.sourceX*t+n,r.targetX=r.targetX*t+n,r.sourceY=r.sourceY*t+o,r.targetY=r.targetY*t+o,r.rightFullExtent=r.rightFullExtent*t+n,r.leftFullExtent=r.leftFullExtent*t+n,r.verticalFullExtent=r.verticalFullExtent*t+o,r.rightInnerExtent=r.rightInnerExtent*t+n,r.leftInnerExtent=r.leftInnerExtent*t+n,r.verticalRightInnerExtent=r.verticalRightInnerExtent*t+o,r.verticalLeftInnerExtent=r.verticalLeftInnerExtent*t+o,r.rightSmallArcRadius*=t,r.rightLargeArcRadius*=t,r.leftSmallArcRadius*=t,r.leftLargeArcRadius*=t,r.sourceWidth*=t,r.rightNodeBuffer*=t,r.leftNodeBuffer*=t,r.arcRadius*=t}}}const y=new Map;for(const t of e)y.set(t.id,t);for(const e of l){const t=y.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 f=new Map;for(const e of t)f.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=Gt(e.source),r=Gt(e.target),n=f.get(e._edgeKey?e._edgeKey:`${t}\0${r}`);if(n){n.y0=e.y0,n.y1=e.y1,n.sankeyWidth=e.width??0,n.circular=!!e.circular,n.circularPathData=e.circularPathData,n._circularWidth=e._circularWidth,n._circularStub=e._circularStub,n.path=e.path,n.circularLinkType=e.circularLinkType,n.direction=o;const i=y.get(t),a=y.get(r);i&&(n.source=i),a&&(n.target=a)}}},buildScene(e,t,r,n){const o="vertical"===r.orientation?"down":"right",i=r.nodeStyle,a=r.edgeStyle,s=r.edgeOpacity??.5,c=r.edgeColorBy||"source",l=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical&&r.themeCategorical.length>0?r.themeCategorical:me,u=new Map;e.forEach((e,t)=>{u.set(e.id,l[t%l.length])});const d=[],h=[],y=[],f=new Map;for(const t of e){const e=t.x1-t.x0,r=t.y1-t.y0;if(0>=e||0>=r)continue;const n=i?i(jt(t,"nodeStyle")):{},a={fill:n.fill||u.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};f.set(t.id,("string"==typeof a.fill?a.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===o?{type:"rect",x:t.y0,y:t.x0,w:r,h:e,style:a,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:r,style:a,datum:t,id:t.id,label:t.id})}const g=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of g){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o=r.themeSemantic?.border||r.themeSemantic?.secondary||"#999";o="function"==typeof c?c(e)||o:"target"===c?f.get(n.id)||u.get(n.id)||o:f.get(t.id)||u.get(t.id)||o;const i=a?a(jt(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,r=e.sankeyWidth/2,n=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),a=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=i.fill||o;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-r}L${t.sourceX+n},${t.sourceY-r}L${t.sourceX+n},${t.sourceY+r}L${t.sourceX},${t.sourceY+r}Z`,style:{fill:c,fillOpacity:i.fillOpacity??s,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+n}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-r}L${t.targetX-a},${t.targetY-r}L${t.targetX-a},${t.targetY+r}L${t.targetX},${t.targetY+r}Z`,style:{fill:c,fillOpacity:i.fillOpacity??s,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-a,x1:t.targetX}});continue}let l;(l=e.circular&&e.circularPathData?Ot(e):Bt(e),l)&&h.push({type:"bezier",pathD:l,bezierCache:e.bezier,style:{fill:i.fill||o,fillOpacity:i.fillOpacity??s,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity},datum:e})}if(!1!==r.showLabels){const t=(p=r.nodeLabel)?"function"==typeof p?p:e=>e[p]||e.id:null;for(const r of e){const e=r.x1-r.x0,i=r.y1-r.y0;if(0>=e||0>=i)continue;const a=t?t(r):r.id;if(!a)continue;let s,c,l;"down"===o?(s=r.y0+(r.y1-r.y0)/2,c=r.x1+14,l="start"):(n[0]/2>r.x0+e/2?(s=r.x0-6,l="end"):(s=r.x1+6,l="start"),c=r.y0+i/2),y.push({x:s,y:c,text:a+"",anchor:"down"===o?"middle":l,baseline:"middle",fontSize:11})}}var p;return{sceneNodes:d,sceneEdges:h,labels:y}}};import{forceSimulation as qt,forceCenter as Qt,forceX as Kt,forceY as Zt,forceLink as Ut,forceManyBody as Jt,forceCollide as er}from"d3-force";import{scaleLinear as tr}from"d3-scale";var rr={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const o=r.forceStrength??.1,i=n[0]/2,a=n[1]/2,s=r.__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),r=s?.get(t.id);e?c++:r?(t.x=r.x,t.y=r.y,c++):l.push(t)}const u=c>0&&.3>=(e.length>0?l.length/e.length:1);if(u){const r=new Map;for(const t of e)r.set(t.id,t);for(const e of l){const n=nr(e.id,t,r);if(n.length>0){let t=0,r=0;for(const e of n)t+=e.x,r+=e.y;const o=or(e.id),i=o%360*(Math.PI/180),a=10+o%20;e.x=t/n.length+a*Math.cos(i),e.y=r/n.length+a*Math.sin(i)}else{const t=or(e.id),r=t%360*(Math.PI/180),n=15+t%30;e.x=i+n*Math.cos(r),e.y=a+n*Math.sin(r)}}}else{const t=2.399963229728653;for(let r=0;e.length>r;r++){const n=e[r];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(r+.5),o=r*t;n.x=i+e*Math.cos(o),n.y=a+e*Math.sin(o)}}}const d=r.__skipForceSimulation||0===r.iterations?0:u?40:r.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),h=ir(r.nodeSize,r.nodeSizeRange,e),y=e=>h(e);if(d>0){const n=new Map,s=new Map;for(const t of e)n.set(t.id,0),s.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,r="string"==typeof e.target?e.target:e.target.id;n.set(t,(n.get(t)??0)+1),n.set(r,(n.get(r)??0)+1)}const c=Ut().strength(e=>{const t=e.weight,r="string"==typeof e.target?e.target:e.target.id,i=Math.max(1,Math.min(n.get("string"==typeof e.source?e.source:e.source.id)??1,n.get(r)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*o/(.1*i))}).distance(e=>{const t="string"==typeof e.source?s.get(e.source):e.source,r="string"==typeof e.target?s.get(e.target):e.target,n=(t?y(t):0)+(r?y(r):0)+12;return Math.max(40,n)}).id(e=>e.id),l=qt();if(void 0===r.random&&void 0===r.seed||l.randomSource(r.random??K(r.seed)),l.force("charge",Jt().strength(e=>{const t=n.get(e.id)??0;return-15*y(e)*Math.sqrt(t+1)})).force("collide",er(e=>y(e)+3).strength(.9).iterations(2)).force("center",Qt(i,a).strength(.8)).force("x",Kt(i).strength(.06)).force("y",Zt(a).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;d>e;++e)l.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=y(t);t.x=Math.max(e,Math.min(n[0]-e,t.x)),t.y=Math.max(e,Math.min(n[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=f.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=f.get(e.target);t&&(e.target=t)}}},buildScene(e,t,r,n){const o=r.nodeStyle,i=r.edgeStyle,a=ir(r.nodeSize,r.nodeSizeRange,e),s=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical&&r.themeCategorical.length>0?r.themeCategorical:me,c=new Map;e.forEach((e,t)=>{c.set(e.id,s[t%s.length])});const l=[],u=[],d=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=a(jt(t,"nodeSize")),n=o?o(jt(t,"nodeStyle")):{},i={fill:n.fill||c.get(t.id)||r.themeSemantic?.primary||"#007bff",stroke:n.stroke||r.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??2,opacity:n.opacity};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:i,datum:t,id:t.id,label:t.id})}const h=new Map;for(const t of e)h.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:h.get(e.source),n="object"==typeof e.target?e.target:h.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const o=i?i(jt(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:o.stroke||r.themeSemantic?.border||r.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6},datum:e})}if(!1!==r.showLabels){const t=(y=r.nodeLabel)?"function"==typeof y?y:e=>e[y]||e.id:null;for(const r of e){if(null==r.x||null==r.y)continue;const e=t?t(r):r.id;if(!e)continue;const n=a(jt(r,"nodeSize"));d.push({x:r.x,y:r.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var y;return{sceneNodes:l,sceneEdges:u,labels:d}}};function nr(e,t,r){const n=[];for(const o of t){const t="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let a=null;if(t===e?a=i:i===e&&(a=t),a){const e=r.get(a);!e||0===e.x&&0===e.y||n.push({x:e.x,y:e.y})}}return n}function or(e){let t=0;for(let r=0;e.length>r;r++)t=(t<<5)-t+e.charCodeAt(r)|0;return Math.abs(t)}function ir(e,t,r){if(r.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 n=t||[5,20],o=[];for(const t of r){const r=t.data?.[e];"number"==typeof r&&o.push(r)}if(0===o.length)return()=>n[0];const[i,a]=Ae(o);if(i===a)return()=>(n[0]+n[1])/2;const s=tr().domain([i,a]).range(n).clamp(!0);return t=>{const r=t.data?.[e];return null==r||"number"!=typeof r?n[0]:s(r)}}import{chord as ar,ribbon as sr}from"d3-chord";import{arc as cr}from"d3-shape";var lr=me,ur={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,r,n){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:a}=r,s=Math.min(n[0],n[1])/2,c=s-i,l=n[0]/2,u=n[1]/2,d=(h=r.valueAccessor)?"function"==typeof h?h:e=>e[h]??1:e=>e.value??1;var h;const y=new Map;for(let t=0;e.length>t;t++)y.set(e[t].id,t);const f=e.length,g=Array.from({length:f},()=>Array.from({length:f},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=y.get("string"==typeof e.source?e.source:e.source.id),n=y.get(t);if(void 0===r||void 0===n)continue;const o=d(e);g[r][n]=o}const p=ar().padAngle(o);a&&p.sortGroups(a);const m=p(g),v=m.groups,x=cr().innerRadius(c).outerRadius(s);for(const t of v){const r=e[t.index],n=x.centroid({innerRadius:c,outerRadius:s,startAngle:t.startAngle,endAngle:t.endAngle});r.x=n[0]+l,r.y=n[1]+u,r.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const k=new Map;for(const t of e)k.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,r=k.get("string"==typeof e.source?e.source:e.source.id),n=k.get(t);r&&(e.source=r),n&&(e.target=n)}const b=new Map;for(const e of t)b.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 r=e[t.source.index].id,n=e[t.target.index].id,o=b.get(`${r}\0${n}`)||b.get(`${n}\0${r}`);o&&(o.__chordData=t)}},buildScene(e,t,r,n){const{groupWidth:o=20,edgeOpacity:i=.5}=r,a=Math.min(n[0],n[1])/2,s=a-o,c=n[0]/2,l=n[1]/2,u=r.nodeStyle,d=r.edgeStyle,h=r.edgeColorBy||"source",y=Array.isArray(r.colorScheme)?r.colorScheme:r.themeCategorical&&r.themeCategorical.length>0?r.themeCategorical:lr,f=new Map;e.forEach((e,t)=>{f.set(e.id,y[t%y.length])});const g=sr().radius(s),p=[],m=[],v=[];for(let t=0;e.length>t;t++){const r=e[t],n=r.__arcData;if(!n)continue;let o;o=u?u(jt(r,"nodeStyle")).fill||f.get(r.id)||y[t%y.length]:f.get(r.id)||y[t%y.length];const i=u?u(jt(r,"nodeStyle")):{};p.push({type:"arc",cx:c,cy:l,innerR:s,outerR:a,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:{fill:o,stroke:i.stroke||"black",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:r,id:r.id,label:r.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const n=g(t);if(!n)continue;const o=dr(n,c,l);let a=r.themeSemantic?.border||r.themeSemantic?.secondary||"#999";if(d)a=d(jt(e,"edgeStyle")).fill||a;else{const t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;"target"===h&&r?a=f.get(r.id)||a:t&&(a=f.get(t.id)||a)}const s=d?d(jt(e,"edgeStyle")):{};m.push({type:"ribbon",pathD:o,style:{fill:a,fillOpacity:s.fillOpacity??i,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity},datum:e})}if(!1!==r.showLabels){const t=(x=r.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null,n=a+12;for(const r of e){const e=r.__arcData;if(!e)continue;const o=t?t(r):r.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,a=i-Math.PI/2;v.push({x:c+Math.cos(a)*n,y:l+Math.sin(a)*n,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var x;return{sceneNodes:p,sceneEdges:m,labels:v}}};function dr(e,t,r){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const o=[];let i=0;for(;n.length>i;){const e=n[i];if("M"===e||"L"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("C"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;3>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("Q"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)for(let e=0;2>e&&n.length>i&&!isNaN(Number(n[i]));e++)o.push(Number(n[i])+t+""),i++,n.length>i&&!isNaN(Number(n[i]))&&(o.push(Number(n[i])+r+""),i++);else if("A"===e)for(o.push(e),i++;n.length>i&&!isNaN(Number(n[i]));)o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&o.push(n[i++]),n.length>i&&(o.push(Number(n[i])+t+""),i++),n.length>i&&(o.push(Number(n[i])+r+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(n[i]),i++)}return o.join(" ")}import{hierarchy as hr,tree as yr,cluster as fr,treemap as gr,pack as pr,partition as mr,treemapBinary as vr}from"d3-hierarchy";var xr=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function kr(e){const[t,r,n]=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*r+.114*n>150?"#222":"#fff"}function br(e,t,r){const n=t.nodeIDAccessor;return"function"==typeof n?n(e.data)+"":"string"==typeof n&&void 0!==e.data[n]?e.data[n]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+r}function Sr(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 _r(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:xr}function wr(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 Ar(e,t,r,n,o){if("horizontal"===o){const o=(e+r)/2;return`M ${e},${t} C ${o},${t} ${o},${n} ${r},${n}`}if("radial"===o){const o=(e+r)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+n)/2} T ${r},${n}`}{const o=(t+n)/2;return`M ${e},${t} C ${e},${o} ${r},${o} ${r},${n}`}}var Lr={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,r,n){const o=r.__hierarchyRoot;if(!o)return;const i=r.chartType,a=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(r.childrenAccessor),s=r.hierarchySum,c="function"==typeof s?s:"string"==typeof s?e=>Number(e[s])||0:e=>Number(e.value)||0,l=hr(o,a);l.sum(c),l.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=n;switch(i){case"tree":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=yr();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(l,r,u,d);break;case"cluster":!function(e,t,r,n){const o=t.treeOrientation||"vertical",i=fr();i.size("horizontal"===o?[n,r]:"radial"===o?[2*Math.PI,Math.min(r,n)/2*.8]:[r,n]),i(e)}(l,r,u,d);break;case"treemap":!function(e,t,r,n){const o=t.padding??4,i=t.paddingTop??0,a=gr().size([r,n]).tile(vr).padding(o);i>0&&a.paddingTop(i),a(e)}(l,r,u,d);break;case"circlepack":!function(e,t,r,n){const o=t.padding??4;pr().size([r,n]).padding(o)(e)}(l,r,u,d);break;case"partition":!function(e,t,r,n){mr().size([r,n]).padding(t.padding??1)(e)}(l,r,u,d)}const h=l.descendants();e.length=0,t.length=0;const y=new Map;for(let t=0;h.length>t;t++){const n=h[t],o={id:br(n,r,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:n.value??0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===i||"cluster"===i?Er(o,n,r):"treemap"===i||"partition"===i?Pr(o,n):"circlepack"===i&&Dr(o,n),o.__hierarchyNode=n,e.push(o),y.set(n,o)}if("tree"===i||"cluster"===i)for(const e of h)if(e.parent){const r=y.get(e.parent),n=y.get(e);r&&n&&t.push({source:r,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,r,n){const o=r.nodeStyle||(()=>({})),i=r.edgeStyle||(()=>({}));switch(r.chartType){case"tree":case"cluster":return function(e,t,r,n,o,i){const a=[],s=[],c=[],l=r.treeOrientation||"vertical",u="radial"===l,d=n[0]/2,h=n[1]/2,y="number"==typeof(f=r.nodeSize)?f:5;var f;for(const t of e){let e=t.x,n=t.y;u&&(e+=d,n+=h);const i=o(jt(t,"nodeStyle"));let s=i.fill||wr(r);if(r.colorByDepth&&void 0!==t.depth){const e=_r(r);s=e[t.depth%e.length]}a.push({type:"circle",cx:e,cy:n,r:y,style:{fill:s,stroke:i.stroke||r.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:t,id:t.id,label:t.id,depth:t.depth})}const g=r.edgeOpacity??.5;for(const e of t){const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let o=t.x,a=t.y,c=n.x,y=n.y;u&&(o+=d,a+=h,c+=d,y+=h);const f=Ar(o,a,c,y,l),p=i(jt(e,"edgeStyle"));s.push({type:"curved",pathD:f,style:{fill:"none",stroke:p.stroke||r.themeSemantic?.border||r.themeSemantic?.secondary||"#999",strokeWidth:p.strokeWidth??1.5,opacity:p.opacity??g},datum:e})}if(!1!==r.showLabels){const t=Sr(r.nodeLabel);for(const r of e){const e=t?t(r):r.id;if(!e)continue;let n,o,i,a=r.x,s=r.y;if(u&&(a+=d,s+=h),u){const e=a-d,t=s-h,r=Math.sqrt(e*e+t*t);r>0?(n=a+e/r*10,o=s+t/r*10,i=0>e?"end":"start"):(n=a,o=s-12,i="middle")}else"horizontal"===l?(r.data?.children&&0!==r.data.children.length?(n=a-y-6,i="end"):(n=a+y+6,i="start"),o=s):(n=a,o=s+y+14,i="middle");c.push({x:n,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:a,sceneEdges:s,labels:c}}(e,t,r,n,o,i);case"treemap":case"partition":return function(e,t,r,n){const o=[],i=[];for(const r of e){const e=r.x1-r.x0,i=r.y1-r.y0;if(0>=e||0>=i)continue;const a=n(jt(r,"nodeStyle"));let s=a.fill||wr(t);if(t.colorByDepth&&void 0!==r.depth){const e=_r(t);s=e[r.depth%e.length]}o.push({type:"rect",x:r.x0,y:r.y0,w:e,h:i,style:{fill:s,stroke:a.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:a.strokeWidth??1,opacity:a.opacity},datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=Sr(t.nodeLabel),o=t.labelMode||"leaf",a="partition"===t.chartType;for(const s of e){const e=s.x1-s.x0,c=s.y1-s.y0;if(0>=e||0>=c)continue;const l=!(s.data?.children&&s.data.children.length>0);if(!a){if("leaf"===o&&!l)continue;if("parent"===o&&l)continue}const u=r?r(s):s.id;if(!u)continue;if((l?30:40)>e||(l?16:14)>c)continue;let d=n(jt(s,"nodeStyle")).fill||wr(t);if(t.colorByDepth&&void 0!==s.depth){const e=_r(t);d=e[s.depth%e.length]}const h="string"==typeof d?kr(d):t.themeSemantic?.text??"#000";i.push(l?{x:s.x0+e/2,y:s.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/6)),fill:h}:{x:s.x0+4,y:s.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,r,0,o);case"circlepack":return function(e,t,r,n){const o=[],i=[];for(const r of e){const e=r.__radius??5;if(0>=e)continue;const i=n(jt(r,"nodeStyle"));let a=i.fill||wr(t);if(t.colorByDepth&&void 0!==r.depth){const e=_r(t);a=e[r.depth%e.length]}o.push({type:"circle",cx:r.x,cy:r.y,r:e,style:{fill:a,stroke:i.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.7},datum:r,id:r.id,label:r.id,depth:r.depth})}if(!1!==t.showLabels){const r=Sr(t.nodeLabel);for(const o of e){const e=o.__radius??5,a=r?r(o):o.id;if(!a)continue;if(15>e)continue;const s=!(o.data?.children&&o.data.children.length>0);let c=n(jt(o,"nodeStyle")).fill||wr(t);if(t.colorByDepth&&void 0!==o.depth){const e=_r(t);c=e[o.depth%e.length]}if(s){const r="string"==typeof c?kr(c):t.themeSemantic?.text??"#000";i.push({x:o.x,y:o.y,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:r})}else i.push({x:o.x,y:o.y-e+14,text:a+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,r,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Er(e,t,r){const n=r.treeOrientation||"vertical";if("radial"===n){const r=t.x,n=t.y;e.x=n*Math.cos(r-Math.PI/2),e.y=n*Math.sin(r-Math.PI/2)}else"horizontal"===n?(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 Pr(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 Dr(e,t){const r=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-r,e.x1=t.x+r,e.y0=t.y-r,e.y1=t.y+r,e.width=2*r,e.height=2*r,e.__radius=r}import{pie as Nr}from"d3-shape";function Rr(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var Mr={sankey:Vt,force:rr,chord:ur,tree:Lr,cluster:Lr,treemap:Lr,circlepack:Lr,partition:Lr,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,r,n){const o=r.__hierarchyRoot;o&&function(e,t,r,n,o){const i=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(r.childrenAccessor),a=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(r.nodeIDAccessor),s=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(r.orbitMode),c=r.orbitSize??2.95,l=r.orbitEccentricity??1,u="number"==typeof c?()=>c:c,d="number"==typeof l?()=>l:l,h=Rr(r);h.metaMap.clear(),n.length=0,o.length=0;const y=new Map;function f(e){const t=y.get(e)??0;return y.set(e,t+1),0===t?e:`${e}__${t}`}const g=t[0]/2,p=t[1]/2,m=Math.min(t[0],t[1])/2*.85,v=f(a(e));n.push({id:v,x:g,y:p,x0:g,x1:g,y0:p,y1:p,width:0,height:0,value:0,depth:0,data:e}),h.metaMap.set(v,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,r,c,l,y,g,p){const m=i(t);if(!m?.length)return;const v=m.length;let x=0,k=0,b=0;for(;v>k;)k+=s[Math.min(b,s.length-1)],b++,x++;let S=0;for(let v=0;x>v;v++){const k=s[Math.min(v,s.length-1)],b=m.slice(S,S+k);if(!b.length)break;const _=(v+1)/x,w={id:r,depth:g,data:t,parentId:r},A=p?y/u(w)*_:y*_,L=Nr().value(e=>{const t=i(e)?.length;return t?4:1}).sort(null)(b),E=d(w);for(let t=0;b.length>t;t++){const i=(L[t].startAngle+L[t].endAngle)/2,s=b[t],u=f(a(s)),d=c+A*Math.sin(i),y=l+A*Math.cos(i)*E;n.push({id:u,x:d,y:y,x0:d,x1:d,y0:y,y1:y,width:0,height:0,value:0,depth:g,data:s}),h.metaMap.set(u,{ring:A,angle:i,depth:g,parentId:r,eccentricity:E}),o.push({source:r,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:r,target:u}}),e(s,u,d,y,A,g+1,!0)}S+=k}}(e,v,g,p,m,1,!1)}(o,n,r,e,t)},buildScene(e,t,r,n){const o=r.nodeStyle,i=r.nodeSize,a="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,s=[],c=[],l=[];if(!1!==r.orbitShowRings){const t=Rr(r),n=new Map;for(const t of e)n.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=n.get(e.parentId);if(!t)continue;const r=`${e.parentId}:${e.ring}`;o.has(r)||o.set(r,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:r,ecc:n}]of o)for(let o=0;i>o;o++){const s=o/i*Math.PI*2,l=(o+1)/i*Math.PI*2;c.push({type:"line",x1:e+r*Math.sin(s),y1:t+r*Math.cos(s)*n,x2:e+r*Math.sin(l),y2:t+r*Math.cos(l)*n,style:a,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=a(jt(t,"nodeSize")),n=o?o(jt(t,"nodeStyle")):{};s.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:n.fill||r.themeSemantic?.primary||"#6366f1",stroke:n.stroke||r.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??1,opacity:n.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),r="object"==typeof e.target?e.target:u.get(e.target);t&&r&&(null!=t.x&&null!=r.x&&c.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(r.showLabels){const t=r.nodeLabel;for(const r of e){const e=a(jt(r,"nodeSize"));if(4>=e)continue;const n="function"==typeof t?t(r):t?r.data?.[t]??r.id:r.id;l.push({x:r.x,y:r.y+e+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:s,sceneEdges:c,labels:l}},tick:(e,t,r,n,o)=>!1!==r.orbitAnimated&&(function(e,t){const r=Rr(t),n=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())-r.startTime)/1e3,a=n*(Math.PI/6),s=new Map;for(const t of e)s.set(t.id,t);for(const t of e){const e=r.metaMap.get(t.id);if(!e||!e.parentId)continue;const n=s.get(e.parentId);if(!n)continue;const c=e.angle+i*a*o({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=n.x+e.ring*Math.sin(c),t.y=n.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,r),!0)}};function Tr(e){return Mr[e]}import{quadtree as Cr}from"d3-quadtree";function Wr(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 Ir(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(!$r(e))return!1;return!0}return $r(t.points)}function $r(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 zr}from"d3-interpolate";var Fr="rgba(34, 197, 94, 0.7)",Br=2e3,Or=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Yr=["scene-style","data-paint","accessibility","evidence"],Xr=(e,t)=>({retainedData:e,invalidations:t}),jr=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Hr=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Gr=["scene-geometry","data-paint","overlay","accessibility","evidence"],Vr=["scene-style","data-paint","accessibility","evidence"],qr=["scene-geometry","data-paint","overlay","accessibility","evidence"],Qr=[],Kr={chartType:Xr("rebuild",jr),nodeIDAccessor:Xr("rebuild",jr),sourceAccessor:Xr("rebuild",jr),targetAccessor:Xr("rebuild",jr),valueAccessor:Xr("rebuild",jr),edgeIdAccessor:Xr("rebuild",jr),childrenAccessor:Xr("rebuild",jr),hierarchySum:Xr("rebuild",jr),orientation:Xr("preserve",Hr),nodeAlign:Xr("preserve",Hr),nodePaddingRatio:Xr("preserve",Hr),nodeWidth:Xr("preserve",Hr),edgeSort:Xr("preserve",Hr),iterations:Xr("preserve",Hr),forceStrength:Xr("preserve",Hr),padAngle:Xr("preserve",Hr),groupWidth:Xr("preserve",Hr),sortGroups:Xr("preserve",Hr),treeOrientation:Xr("preserve",Hr),edgeType:Xr("preserve",Hr),padding:Xr("preserve",Hr),paddingTop:Xr("preserve",Hr),orbitMode:Xr("preserve",Hr),orbitSize:Xr("preserve",Hr),orbitSpeed:Xr("preserve",Hr),orbitRevolution:Xr("preserve",Hr),orbitRevolutionStyle:Xr("preserve",Hr),orbitEccentricity:Xr("preserve",Hr),orbitShowRings:Xr("preserve",Hr),orbitAnimated:Xr("preserve",Hr),customNetworkLayout:Xr("preserve",Hr),layoutConfig:Xr("preserve",Hr),nodeSize:Xr("preserve",Gr),nodeSizeRange:Xr("preserve",Gr),colorByDepth:Xr("preserve",Gr),nodeLabel:Xr("preserve",qr),showLabels:Xr("preserve",qr),labelMode:Xr("preserve",qr),nodeStyle:Xr("preserve",Vr),edgeStyle:Xr("preserve",Vr),colorBy:Xr("preserve",Vr),colorScheme:Xr("preserve",Vr),themeCategorical:Xr("preserve",Vr),themeSemantic:Xr("preserve",Vr),edgeColorBy:Xr("preserve",Vr),edgeOpacity:Xr("preserve",Vr),showParticles:Xr("preserve",Vr),particleStyle:Xr("preserve",Vr),decay:Xr("preserve",Vr),pulse:Xr("preserve",Vr),thresholds:Xr("preserve",Vr),staleness:Xr("preserve",Vr),layoutSelection:Xr("preserve",Vr),clock:Xr("preserve",Qr),random:Xr("preserve",Qr),seed:Xr("preserve",Qr),tensionConfig:Xr("preserve",Qr),transition:Xr("preserve",Qr),introAnimation:Xr("preserve",Qr),onLayoutError:Xr("preserve",Qr),__skipForceSimulation:Xr("preserve",Qr),__hierarchyRoot:Xr("preserve",Qr),__orbitState:Xr("preserve",Qr),__previousPositions:Xr("preserve",Qr)},Zr=Xr("preserve",Hr),Ur=class{constructor(){this.tracker=new Y}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}},Or)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Yr):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const r=new Set;for(const n of e){const e=Kr[n]??Zr;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)r.add(t)}return{retainedData:t,invalidations:r}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},Jr=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 Ur,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={...Fe,...e.tensionConfig},e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new Oe(2e3))}currentTime(){return this.config.clock?.()??le()}updateConfig(e){const t=this.config,r={...t,...e};t.__orbitState&&(r.__orbitState=t.__orbitState),t.__hierarchyRoot&&(r.__hierarchyRoot=t.__hierarchyRoot),void 0===e.layoutSelection&&null!=t.layoutSelection&&(r.layoutSelection=t.layoutSelection);const n=[...new Set([...Object.keys(t),...Object.keys(r)])].filter(e=>t[e]!==r[e]);this.config=r,this.tensionConfig={...Fe,...r.tensionConfig},!r.showParticles||"sankey"!==r.chartType&&!r.customNetworkLayout||this.particlePool||(this.particlePool=new Oe(2e3)),this.updateResults.recordConfig(n)}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,r,n){const{nodeIDAccessor:o="id",sourceAccessor:i="source",targetAccessor:a="target",valueAccessor:s="value"}=this.config,c="function"==typeof o?o:e=>e[o],l="function"==typeof i?i:e=>e[i],u="function"==typeof a?a:e=>e[a],d="function"==typeof s?s:e=>e[s]??1;this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const t of e){const e=c(t)+"";this.nodes.set(e,{...Wr(e),data:t})}for(let e=0;t.length>e;e++){const r=t[e],n=l(r)+"",o=u(r)+"",i=d(r),a=null==i?NaN:Number(i),s=Number.isFinite(a)?a:1;this.nodes.has(n)||this.nodes.set(n,{...Wr(n),data:r}),this.nodes.has(o)||this.nodes.set(o,{...Wr(o),data:r});const c=`${n}\0${o}\0${e}`,h={source:n,target:o,value:s,y0:0,y1:0,sankeyWidth:0,data:r,_edgeKey:c};r&&"object"==typeof r&&Ir(r.bezier)&&(h.bezier=r.bezier),this.edges.set(c,h)}n?.deferLayout||this.runLayout(r),this.updateResults.recordData("replace",e.length+t.length)}ingestBoundedWithResult(e,t,r,n){return this.ingestBounded(e,t,r,n),this.updateResults.last}applyForceLayoutPositions(e,t){for(const[t,r]of Object.entries(e)){const e=this.nodes.get(t);e&&(e.x=r.x,e.y=r.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:r,value:n}=e,o=0===this.nodes.size;let i=!1;const a=this.currentTime();this.lastIngestTime=a,this._decaySortedNodes=null,this._networkDecayCache=null,this.nodes.has(t)||(this.nodes.set(t,Wr(t)),this.nodeTimestamps.set(t,a),this.tension+=this.tensionConfig.newNode,i=!0),this.nodes.has(r)||(this.nodes.set(r,Wr(r)),this.nodeTimestamps.set(r,a),this.tension+=this.tensionConfig.newNode,i=!0);const s=this.edgeKey(t,r),c=this.edges.get(s);let l=!1;c?(c.value+=n,this.edgeTimestamps.set(s,a),this.tension+=this.tensionConfig.weightChange,l=!0):(this.edges.set(s,{source:t,target:r,value:n,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(s,a),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=Tr(this.config.chartType);if(!t)return;let r=Array.from(this.nodes.values());const n=Array.from(this.edges.values());if(0===r.length&&!t.hierarchical)return;if(this.prepareForRelayout(),t.supportsStreaming&&!t.hierarchical){const e=new Map;for(const t of r)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,r]of this._lastPositionSnapshot)e.has(t)||e.set(t,r);this.config.__previousPositions=e.size>0?e:void 0}if(t.computeLayout(r,n,this.config,e),this.config.__previousPositions=void 0,t.hierarchical&&r.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this._networkDecayCache=null;for(const e of r)this.nodes.set(e.id,e);for(let e=0;n.length>e;e++){const t=n[e],r=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=r,this.edges.set(r,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const r=e.get(t.id);r&&(t._prevX0=r.x0,t._prevX1=r.x1,t._prevY0=r.y0,t._prevY1=r.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,r=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=r.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),a=this.config.transition?.duration??this.tensionConfig.transitionDuration,s=["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType);if(!this._hasRenderedOnce&&this.config.introAnimation&&s&&r.length>0&&a>0){const t=e[0]/2,r=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=r,e._prevY1=r;for(const e of this.edges.values())e._prevY0=r,e._prevY1=r,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:a}}else i&&a>0&&(this.restorePreviousPositions(),this.transition={startTime:this.currentTime(),duration:a});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime=this.currentTime()),this.previousNodeIds=e,this.previousEdgeKeys=t}restyleScene(e){const t=function({nodes:e,edges:t,restyle:r,restyleEdge:n,baseStyles:o,selection:i}){const a=!(!r&&!n);if(r)for(const t of e){const e=o.get(t)??t.style,n=r(t,i);t.style=n?{...e,...n}:e}if(n)for(const e of t){const t=o.get(e)??e.style,r=n(e,i);e.style=r?{...t,...r}:t}return a}({nodes:this.sceneNodes,edges:this.sceneEdges,restyle:this._customRestyle,restyleEdge:this._customRestyleEdge,baseStyles:this._baseStyles,selection:e});this.markStylePaintPending(),this.updateResults.recordRestyle(t)}buildScene(e){if(this.config.customNetworkLayout){const t=function({config:e,customLayout:t,size:r,nodes:n,edges:o,previousResult:i,revision:a}){const c=N(e.colorScheme,e.themeCategorical,me),l={nodes:n,edges:o,dimensions:{width:r[0],height:r[1],plot:{x:0,y:0,width:r[0],height:r[1]}},theme:{semantic:e.themeSemantic??{},categorical:[...c]},resolveColor:D(c,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};try{return{kind:"success",result:t(l)}}catch(t){const r=null!==i,n=s("network",t,r,a);"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",t);try{e.onLayoutError?.(n)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:n,preservedLastGoodScene:r}}}({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 r=t.result;return this.sceneNodes=r.sceneNodes??[],this.sceneEdges=r.sceneEdges??[],this.labels=r.labels??[],this.customLayoutOverlays=r.overlays??null,this.customLayoutHtmlMarks=r.htmlMarks??[],this.lastCustomLayoutResult=r,this.lastCustomLayoutFailure=null,this._sceneNodesRevision++,this._customRestyle=r.restyle,this._customRestyleEdge=r.restyleEdge,this.hasCustomRestyle=!(!r.restyle&&!r.restyleEdge),this.hasCustomRestyle&&(this._baseStyles=function(e,t){const r=new WeakMap;for(const t of e)r.set(t,t.style);for(const e of t)r.set(e,e.style);return r}(this.sceneNodes,this.sceneEdges),this.restyleScene(this.config.layoutSelection??null)),void A({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=Tr(this.config.chartType);if(!t)return void this._sceneNodesRevision++;const r=t.hierarchical?Array.from(this.nodes.values()):this.nodesArray,n=t.hierarchical?Array.from(this.edges.values()):this.edgesArray,{sceneNodes:o,sceneEdges:i,labels:a}=t.buildScene(r,n,this.config,e);this.sceneNodes=o,this.sceneEdges=i,this.labels=a,this._sceneNodesRevision++}rebuildNodeQuadtree(){let t=0,r=0;for(const e of this.sceneNodes)"circle"===e.type&&(t++,e.r>r&&(r=e.r));if(this._maxNodeRadius=r,e.QUADTREE_THRESHOLD>=t)return void(this._nodeQuadtree=null);const n=Array(t);let o=0;for(const e of this.sceneNodes)"circle"===e.type&&(n[o++]=e);this._nodeQuadtree=Cr().x(e=>e.cx).y(e=>e.cy).addAll(n)}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=Tr(this.config.chartType);return!!e?.supportsAnimation&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const r=Tr(this.config.chartType);if(!r?.tick)return!1;const n=r.hierarchical?Array.from(this.nodes.values()):this.nodesArray,o=r.hierarchical?Array.from(this.edges.values()):this.edgesArray;return r.tick(n,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=q(e,this.transition),r=G(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=ie(e._prevX0,e._targetX0,r),e.x1=ie(e._prevX1,e._targetX1,r),e.y0=ie(e._prevY0,e._targetY0,r),e.y1=ie(e._prevY1,e._targetY1,r));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=ie(e._prevY0,e._targetY0,r),e.y1=ie(e._prevY1,e._targetY1,r),e.sankeyWidth=ie(e._prevSankeyWidth,e._targetSankeyWidth,r));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const r=e?.get(t.id);r&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=r.x0,t._prevX1=r.x1,t._prevY0=r.y0,t._prevY1=r.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 r=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(r){e._prevY0=r.y0,e._prevY1=r.y1,e._prevSankeyWidth=r.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,r=.5){const n="string"==typeof e.source?t.get(e.source):e.source,o="string"==typeof e.target?t.get(e.target):e.target;!n||!o||(e.bezier=e.circular&&e.circularPathData?function(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,r=e.circularPathData;if(!r)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(r.rightFullExtent-r.sourceX))),n=Math.max(15,Math.min(40,.33*(r.targetX-r.leftFullExtent)));return{circular:!0,segments:[[{x:r.sourceX,y:r.sourceY},{x:r.sourceX+.33*e,y:r.sourceY},{x:r.sourceX+.66*e,y:r.sourceY},{x:r.sourceX+e,y:r.sourceY}],[{x:r.targetX-n,y:r.targetY},{x:r.targetX-.66*n,y:r.targetY},{x:r.targetX-.33*n,y:r.targetY},{x:r.targetX,y:r.targetY}]],halfWidth:t}}let n;n="down"===e.direction?[{x:r.sourceY,y:r.sourceX},{x:r.sourceY,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.rightFullExtent},{x:r.verticalFullExtent,y:r.leftFullExtent},{x:r.targetY,y:r.leftFullExtent},{x:r.targetY,y:r.targetX}]:[{x:r.sourceX,y:r.sourceY},{x:r.rightFullExtent,y:r.sourceY},{x:r.rightFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.verticalFullExtent},{x:r.leftFullExtent,y:r.targetY},{x:r.targetX,y:r.targetY}];const o=[];for(let e=0;n.length-1>e;e++){const t=n[e],r=n[e+1],i=r.x-t.x,a=r.y-t.y;o.push([t,{x:t.x+i/3,y:t.y+a/3},{x:t.x+2*i/3,y:t.y+2*a/3},r])}return{circular:!0,segments:o,halfWidth:t}}(e):function(e,t,r,n=.5){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,a=r.x0,s=zr(i,a);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:s(n)},{x:e.y1,y:s(1-n)},{x:e.y1,y:a}],halfWidth:o}}const i=t.x1,a=r.x0,s=zr(i,a);return{circular:!1,points:[{x:i,y:e.y0},{x:s(n),y:e.y0},{x:s(1-n),y:e.y1},{x:a,y:e.y1}],halfWidth:o}}(e,n,o,r))}(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 r=t.duration??500,n=t.color??"rgba(255,255,255,0.6)",o=t.glowRadius??4,{now:i}=e;for(const t of e.sceneNodes){const a=t.id;if(!a)continue;const s=e.nodeTimestamps.get(a);if(!s)continue;const c=i-s;r>c&&(t._pulseIntensity=1-c/r,t._pulseColor=n,t._pulseGlowRadius=o)}for(const t of e.sceneEdges){const o=t.datum;if(!o)continue;const a="object"==typeof o.source?o.source?.id:o.source,s="object"==typeof o.target?o.target?.id:o.target;if(!a||!s)continue;const c=e.edgeTimestamps.get(`${a}\0${s}`);if(!c)continue;const l=i-c;r>l&&(t._pulseIntensity=1-l/r,t._pulseColor=n)}}({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 r=e.nodeTimestamps.size;if(1>=r)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 r=0;e.cache.sortedNodes.length>r;r++)t.set(e.cache.sortedNodes[r][0],r);e.cache.ageMap=t}const n=e.cache.ageMap;for(const o of e.sceneNodes){const e=o.id;if(!e)continue;const i=n.get(e);if(void 0===i)continue;const s=a(t,i,r);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===Fr&&(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>=Br)return;const r=1-t/Br;for(const t of e.sceneNodes){const n=t.id;n&&e.addedNodes.has(n)&&(t._pulseIntensity=Math.max(t._pulseIntensity??0,r),t._pulseColor=Fr,t._pulseGlowRadius=8)}}({sceneNodes:this.sceneNodes,addedNodes:this.addedNodes,lastTopologyChangeTime:this.lastTopologyChangeTime,now:e})}get hasActiveTopologyDiff(){return function(e,t,r=("undefined"!=typeof performance?performance.now():Date.now())){return 0!==e.size&&Br>r-t}(this.addedNodes,this.lastTopologyChangeTime)}applyThresholds(e){!function(e){const t=e.thresholds;if(!t)return;const r=t.warningColor??"#f59e0b",n=t.criticalColor??"#ef4444",o=!1!==t.pulse;for(const i of e.sceneNodes){const a=i.id;if(!a)continue;const s=e.nodes.get(a);if(!s)continue;const c=t.metric(s);let l=null;void 0===t.critical||t.critical>c?void 0===t.warning||t.warning>c||(l=r):l=n,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 r of e){const e=t.metric(r);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 r=e.now??("undefined"!=typeof performance?performance.now():Date.now());return(t.duration??500)>r-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 r=this.nodes.get(e);if(!r)return this.updateResults.recordNoop("update"),null;const n=r.data?{...r.data}:{};return r.data=t(r.data??{}),this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",1),n}updateEdge(e,t,r){const n=this.config.valueAccessor,o="function"==typeof n?n:n?e=>e[n]:e=>e.value,i=[];for(const[,n]of this.edges)if(("string"==typeof n.source?n.source:n.source.id)===e&&("string"==typeof n.target?n.target:n.target.id)===t){i.push(n.data?{...n.data}:{}),n.data=r(n.data??{});const e=o(n.data);null!=e&&(n.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,r]of this.edges)("string"==typeof r.source?r.source:r.source.id)!==e&&("string"==typeof r.target?r.target:r.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 r=[];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 n="function"==typeof t?t:e=>e?.[t];for(const[t,o]of this.edges)o.data&&n(o.data)===e&&r.push(t)}else for(const[n,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)===e&&("string"==typeof o.target?o.target:o.target.id)===t&&r.push(n);for(const e of r)this.edges.delete(e),this.edgeTimestamps.delete(e);return r.length>0?(this.layoutVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",r.length)):this.updateResults.recordNoop("remove"),r.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")}};Jr.QUADTREE_THRESHOLD=500;var en=Jr;n(en);import*as tn from"react";import{Fragment as rn,jsx as nn,jsxs as on}from"react/jsx-runtime";function an(e){const{width:t,height:r,totalWidth:n,totalHeight:o,margin:i,labels:a,title:s,legend:c,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h,legendPosition:y="right",legendLayout:f,foregroundGraphics:g,sceneNodes:p,annotations:m,onAnnotationActivate:v,onObservation:x,chartId:k,chartType:b,autoPlaceAnnotations:S,svgAnnotationRules:_}=e,w=be({onAnnotationActivate:v,onObservation:x,chartId:k,chartType:b}),A=tn.useMemo(()=>{const e=(p||[]).flatMap(e=>{const t=function(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){const t=e.cx??e.x,r=e.cy??e.y;if("number"!=typeof t||"number"!=typeof r)return null;const n=Ee(e.glyph,e.size);return{x:t+n.centerDx,y:r+n.centerDy,r:Math.max(1,n.radius)}}const t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),r=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof r?null:{x:t,y:r,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,ke(e.size)):Math.max(1,e.w??0,e.h??0)/2}}(e),r=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:r,...t}]:[]});return{scales:null,width:t,height:r,frameType:"network",pointNodes:e,sceneNodes:p}},[r,p,t]),L=tn.useMemo(()=>m&&S?j({annotations:m,context:A,..."object"==typeof S?S:{}}):m,[m,S,A]),E=tn.useMemo(()=>Q("network"),[]),P=L?he(L.filter(e=>"widget"!==e.type),E,_,A):null,D=!0===L?.some(e=>"widget"===e.type&&!0===e._annotationDeferred);return on(rn,{children:[D&&nn("style",{children:R},"annotation-widget-disclosure-style"),on("svg",{role:"img",width:n,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[nn("title",{children:"string"==typeof s?s:"Network Chart"}),nn("desc",{children:"string"==typeof s?s+" (network data visualization)":"Network data visualization"}),on("g",{transform:`translate(${i.left},${i.top})`,children:[a.map((e,t)=>nn("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,g]}),s&&"string"==typeof s?nn("text",{x:n/2,y:O,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:s}):s?nn("foreignObject",{x:0,y:0,width:n,height:i.top,children:s}):null,ye({legend:c,totalWidth:n,totalHeight:o,margin:i,legendPosition:y,title:s,legendLayout:f,legendHoverBehavior:l,legendClickBehavior:u,legendHighlightedCategory:d,legendIsolatedCategories:h})]}),L?.filter(e=>"widget"===e.type&&e.nodeId&&p).map((e,t)=>{const r=!0===e._annotationDeferred,n=p.find(t=>t.id===e.nodeId||t.datum?.id===e.nodeId||t.datum?.data?.id===e.nodeId||t.datum?.data?.name===e.nodeId);if(!n)return null;const o=i.left+(n.cx??(null!=n.x&&null!=n.w?n.x+n.w/2:n.x??0)),a=i.top+(n.cy??(null!=n.y&&null!=n.h?n.y+n.h/2:n.y??0)),s=e.dx??0,c=e.dy??-16,l=e.width??32,u=e.height??32,d=e.content??nn("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return nn("div",{...X(e,w),className:r?"annotation-deferred":void 0,"data-annotation-disclosure":r?"deferred":void 0,style:{position:"absolute",left:o+s-l/2,top:a+c-u/2,width:l,height:u,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:d},"widget-"+t)})]})}an.displayName="NetworkSVGOverlay";import*as sn from"react";import{jsx as cn}from"react/jsx-runtime";var ln={position:"absolute",top:0,left:0,pointerEvents:"none"};function un({marks:e,margin:t,selection:r=null,overscan:n=400}){const o=sn.useRef(null),i=function(e,t,r){const[n,o]=sn.useState(null);return sn.useLayoutEffect(()=>{const e=t.current,r=function(e){let t=e?.parentElement??null;for(;t;){const{overflow:e,overflowX:r,overflowY:n}=window.getComputedStyle(t);if(/(auto|scroll|overlay)/.test(`${e} ${n} ${r}`))return t;t=t.parentElement}return null}(e);if(!e||!r)return void o(null);let n=0;const i=()=>{n=0;const t=r.getBoundingClientRect(),i=e.getBoundingClientRect();o(0!==t.width&&0!==t.height?{scroll:{left:t.left,top:t.top,right:t.right,bottom:t.bottom},originX:i.left,originY:i.top}:null)},a=()=>{0===n&&(n=window.requestAnimationFrame(i))};i(),r.addEventListener("scroll",a,{passive:!0});const s=new ResizeObserver(a);return s.observe(r),()=>{0!==n&&window.cancelAnimationFrame(n),r.removeEventListener("scroll",a),s.disconnect()}},[t,e,r]),sn.useMemo(()=>{if(!e||!n)return e;const{scroll:t,originX:o,originY:i}=n,a=t.left-r,s=t.right+r,c=t.top-r,l=t.bottom+r;return e.filter(e=>{const t=o+e.x,r=i+e.y;return!(a>t+e.width||t>s||c>r+e.height||r>l)})},[e,n,r])}(e,o,n);if(!e||0===e.length)return null;const a=cn("div",{className:"semiotic-network-html-marks",ref:o,style:{...ln,transform:`translate(${t.left}px, ${t.top}px)`},children:(i??e).map(e=>cn("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!=r?cn(L,{value:r,children:a}):a}import{jsx as dn,jsxs as hn}from"react/jsx-runtime";function yn({props:e,store:t,responsiveRef:r,size:n,margin:o,adjustedWidth:a,adjustedHeight:s,resolvedBackground:c,resolvedForeground:l}){const{chartType:u,nodes:d,edges:h,data:y,className:f,description:g,title:p,responsiveWidth:m,responsiveHeight:v,summary:k,background:b,renderMode:S,legend:_,legendPosition:w,legendLayout:A,legendHoverBehavior:L,legendClickBehavior:P,legendHighlightedCategory:D,legendIsolatedCategories:N,layoutSelection:R,annotations:M,onAnnotationActivate:T,annotationObservationCallback:C,onObservation:W,chartId:I,autoPlaceAnnotations:$,svgAnnotationRules:z}=e;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(u),r=e?y||(Array.isArray(h)?void 0:h):void 0;if(e&&r)t.ingestHierarchy(r,[a,s]),t.buildScene([a,s]);else{const e=ee(d),r=Array.isArray(h)?ee(h):[];(e.length>0||r.length>0)&&(t.ingestBounded(e,r,[a,s]),t.buildScene([a,s]))}}const B=t?.sceneNodes??[],O=t?.sceneEdges??[],Y=t?.labels??[];return hn("div",{ref:r,className:"stream-network-frame"+(f?" "+f:""),role:"img","aria-label":g||("string"==typeof p?p:"Network chart"),style:{position:"relative",width:m?"100%":n[0],height:v?"100%":n[1]},children:[dn(F,{summary:k}),hn("svg",{xmlns:"http://www.w3.org/2000/svg",width:n[0],height:n[1],style:{position:"absolute",left:0,top:0},children:[c&&dn("g",{transform:`translate(${o.left},${o.top})`,children:c}),hn("g",{transform:`translate(${o.left},${o.top})`,children:[b&&dn("rect",{x:0,y:0,width:a,height:s,fill:b}),O.map((e,t)=>x({node:e,index:t,renderMode:S,fallback:()=>se(e,t)})).filter(Boolean),B.map((e,t)=>x({node:e,index:t,renderMode:S,fallback:()=>ce(e,t)})).filter(Boolean),Y.map((e,t)=>ae(e,t)).filter(Boolean)]})]}),dn(an,{width:a,height:s,totalWidth:n[0],totalHeight:n[1],margin:o,labels:Y,sceneNodes:B,title:p,legend:_,legendPosition:w,legendLayout:A,legendHoverBehavior:L,legendClickBehavior:P,legendHighlightedCategory:D,legendIsolatedCategories:N,foregroundGraphics:i(l,E(t?.customLayoutOverlays,R??null)),annotations:M,onAnnotationActivate:T,onObservation:C??W,chartId:I,chartType:"StreamNetworkFrame",autoPlaceAnnotations:$,svgAnnotationRules:z,annotationFrame:0}),dn(un,{marks:t?.customLayoutHtmlMarks,margin:o,selection:R??null})]})}function fn(e,t,r,n,o=4e4){return"sync"!==e&&("worker"===e||n*(t+r)>=o)}function gn(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function pn(){if("undefined"!=typeof DOMException)return new DOMException("Force layout aborted","AbortError");const e=Error("Force layout aborted");return e.name="AbortError",e}var mn=class{constructor(e=function(){const e="string"==typeof import.meta.url&&import.meta.url?new URL("./forceLayoutWorker.js",import.meta.url):P("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,r=t.requestId,n=null!=r?this.pending.get(r):this.pending.values().next().value;if(n){if(null!=r?this.pending.delete(r):this.pending.clear(),n.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 n.reject(e)}n.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(pn());const r=this.nextRequestId;this.nextRequestId+=1;const n={requestId:r,request:e};return new Promise((e,o)=>{const i=()=>{this.pending.delete(r),t?.removeEventListener("abort",i),o(pn())},a=()=>t?.removeEventListener("abort",i);this.pending.set(r,{cleanup:a,reject:o,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(n)}catch(e){this.pending.delete(r),a(),o(e instanceof Error?e:Error(e+""))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(Error("Force layout worker terminated")),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}},vn=null;function xn(e,t){return gn()?t?.aborted?Promise.reject(pn()):(vn&&!vn.isDead||(vn=new mn),vn).request(e,t):Promise.reject(Error("Web Workers are unavailable"))}import{jsx as kn,jsxs as bn}from"react/jsx-runtime";var Sn=/^(value|amount|total|count|weight|score)$/i;function _n({data:e}){if("edge"===e.nodeOrEdge){const t=e.data;return t?bn("div",{className:"semiotic-tooltip",style:Z,children:[bn("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&&bn("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 r=t.__hierarchyNode;if(r){const e=[];let n=r;for(;n;){const r=n.data?.name??n.data?.id??t.id;null!=r&&e.unshift(r+""),n=n.parent}e.length>1&&e.shift();const o=e.length-1;return bn("div",{className:"semiotic-tooltip",style:Z,children:[kn("div",{children:e.map((e,t)=>bn("span",{children:[t>0&&kn("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),t===o?kn("strong",{children:e}):kn("span",{style:{opacity:.7},children:e})]},t))}),null!=t.value&&t.value>0&&kn("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof t.value?t.value.toLocaleString():t.value+""})]})}const n=(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=ve(t.data??t),a=null!=i.title?i.title+"":t.id,s=i.entries.some(e=>Sn.test(e.key));return bn("div",{className:"semiotic-tooltip",style:Z,children:[kn("div",{style:{fontWeight:600},children:a}),i.entries.map(e=>bn("div",{style:{marginTop:4,opacity:.8},children:[e.key,": ",u(e.value)]},e.key)),!s&&null!=t.value&&t.value>0&&bn("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof t.value?t.value.toLocaleString():t.value+""]}),n>0&&bn("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",n,o!==n&&` (weighted: ${o.toLocaleString()})`]})]})}function wn(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function An(e,t){if(!t.pathD)return;e.save();const r=wn(t);if(t.style.fill&&"none"!==t.style.fill){const n=t._gradient;if(n){const r=e.createLinearGradient(n.x0,0,n.x1,0),o=t.style.fillOpacity??t.style.opacity??.5,i="string"==typeof t.style.fill?t.style.fill:"#999",a=fe(e,i)||i;r.addColorStop(0,1===n.from?a:"transparent"),r.addColorStop(1,1===n.to?a:"transparent"),e.fillStyle=r,e.globalAlpha=o}else e.fillStyle=ge(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5;e.fill(r)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=fe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.5*(t.style.opacity??1),e.stroke(r)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(r)),e.restore()}function Ln(e,t){e.save();const r=t.style.stroke||"#999";e.strokeStyle=fe(e,r)||r,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 En(e,t){if(!t.pathD)return;e.save();const r=wn(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=ge(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??t.style.opacity??.5,e.fill(r)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=fe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??.5,e.globalAlpha=.3*(t.style.opacity??1),e.stroke(r)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(r)),e.restore()}function Pn(e,t){if(!t.pathD)return;e.save();const r=wn(t),n=t.style.stroke||"#999";e.strokeStyle=fe(e,n)||n,e.lineWidth=t.style.strokeWidth??1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(r),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle=ge(e,t.style.fill,"#007bff"),e.globalAlpha=t.style.fillOpacity??.1,e.fill(r)),e.restore()}_n.ownsChrome=!0;var Dn=new Map;function Nn(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let r=Dn.get(t);return r||(r=new Path2D(xe(e.symbolType,e.size)),Dn.size>256&&Dn.clear(),Dn.set(t,r)),r}catch{return null}}function Rn(e){const{sceneNodes:t,nodes:r,nodeColorMap:n,colorScheme:o}=e;for(const e of t)e.id&&"string"==typeof e.style?.fill&&n.set(e.id,e.style.fill);const i=Array.isArray(o)?o:C,a=Array.from(r);for(let e=0;a.length>e;e++){const t=a[e];n.has(t.id)||n.set(t.id,i[e%i.length])}return a.length}function Mn(e,t,r,n=30){switch(e.type){case"circle":return function(e,t,r,n=30){const o=t-e.cx,i=r-e.cy,a=Math.sqrt(o*o+i*i);return a>d(e.r,n)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,r,n);case"rect":return function(e,t,r){const n=h(t,r,e);return n.hit?{type:"node",datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}(e,t,r);case"arc":return function(e,t,r){const n=t-e.cx,o=r-e.cy,i=Math.sqrt(n*n+o*o);if(e.innerR-2>i||i>e.outerR+2)return null;const a=g(Math.atan2(o,n)),s=g(e.startAngle),c=g(e.endAngle);if(s>c?a>=s||c>=a:a>=s&&c>=a){const t=(e.startAngle+e.endAngle)/2,r=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+r*Math.cos(t),y:e.cy+r*Math.sin(t),distance:0}}return null}(e,t,r);case"symbol":return function(e,t,r,n=30){const o=t-e.cx,i=r-e.cy,a=Math.sqrt(o*o+i*i);return a>d(ke(e.size),n)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:a}}(e,t,r,n);case"glyph":return function(e,t,r,n=30){if(null==e.datum)return null;const o=Ee(e.glyph,e.size),i=e.cx+o.centerDx,a=e.cy+o.centerDy,s=t-i,c=r-a,l=Math.sqrt(s*s+c*c);return l>d(o.radius,n)?null:{type:"node",datum:e.datum,x:i,y:a,distance:l}}(e,t,r,n);default:return null}}var Tn=null,Cn=null;function Wn(){return Cn||((Tn=document.createElement("canvas")).width=1,Tn.height=1,Cn=Tn.getContext("2d")),Cn}function In(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 $n(e,t,r){switch(e.type){case"bezier":return function(e,t,r){if(!e.pathD)return null;const n=In(e),o=Wn();if(!n||!o)return null;try{if(o.isPointInPath(n,t,r))return{type:"edge",datum:e.datum,x:t,y:r,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(n,t,r);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:r,distance:4}}catch{}return null}(e,t,r);case"line":return function(e,t,r){const n=e.x2-e.x1,o=e.y2-e.y1,i=n*n+o*o;if(0===i)return null;let a=((t-e.x1)*n+(r-e.y1)*o)/i;a=Math.max(0,Math.min(1,a));const s=e.x1+a*n,c=e.y1+a*o,l=Math.sqrt((t-s)**2+(r-c)**2);return l>5?null:{type:"edge",datum:e.datum,x:s,y:c,distance:l}}(e,t,r);case"ribbon":case"curved":return function(e,t,r){if(!e.pathD)return null;const n=In(e),o=Wn();if(!n||!o)return null;try{if(o.isPointInPath(n,t,r))return{type:"edge",datum:e.datum,x:t,y:r,distance:0};const i=o.lineWidth;o.lineWidth=10;const a=o.isPointInStroke(n,t,r);if(o.lineWidth=i,a)return{type:"edge",datum:e.datum,x:t,y:r,distance:4}}catch{}return null}(e,t,r);default:return null}}function zn(e){const{clientX:t,clientY:r,canvasRect:n,margin:o,adjustedWidth:i,adjustedHeight:a,sceneNodes:s,sceneEdges:c,nodeQuadtree:u,maxNodeRadius:d,hitRadius:h=30}=e,y=t-n.left-o.left,f=r-n.top-o.top;if(0>y||y>i||0>f||f>a)return{kind:"miss-outside"};const g=function(e,t,r,n,o=30,i,a=0){let s=null,c=o,u=1/0;if(i){const e=l(i,r,n,o,a,e=>e.cx,e=>e.cy,e=>e.r);e&&(s={type:"node",datum:e.node.datum,x:e.node.cx,y:e.node.cy,distance:e.distance},c=e.distance)}for(const t of e){if(i&&"circle"===t.type)continue;const e=Mn(t,r,n,o);if(e)if("rect"===t.type){const r=t.w*t.h;u>r&&(s=e,u=r)}else c>e.distance&&(s=e,c=e.distance)}if(s)return s;for(const e of t){if(!1===e.interactive)continue;const t=$n(e,r,n);t&&c>t.distance&&(s=t,c=t.distance)}return s}(s,c,y,f,h,u,d);return g?{kind:"hit",hover:H(g.datum||{},g.x,g.y,{nodeOrEdge:g.type})}:{kind:"miss"}}import{useCallback as Fn}from"react";var Bn="StreamNetworkFrame";import{jsx as On,jsxs as Yn}from"react/jsx-runtime";var Xn={top:20,right:80,bottom:20,left:80},jn={top:40,right:40,bottom:40,left:40},Hn=new Set(["chord","force","circlepack","orbit"]),Gn=[800,600],Vn=ze($e(function(n,a){const{chartType:s,nodes:l,edges:u,data:d,initialEdges:h,nodeIDAccessor:g="id",sourceAccessor:x="source",targetAccessor:A="target",valueAccessor:L="value",edgeIdAccessor:P,childrenAccessor:D,hierarchySum:N,orientation:R="horizontal",nodeAlign:O="justify",nodePaddingRatio:Y=.05,nodeWidth:X=15,iterations:j=300,forceStrength:G=.1,layoutExecution:q="auto",layoutLoadingContent:Q,onLayoutStateChange:K,padAngle:Z=.01,groupWidth:ie=20,sortGroups:ae,edgeSort:se,treeOrientation:ce="vertical",edgeType:le="curve",padding:he,paddingTop:ye,tensionConfig:me,showParticles:ve=!1,particleStyle:xe,renderMode:ke,nodeStyle:be,edgeStyle:Ae,colorBy:Ee,colorScheme:$e="category10",edgeColorBy:ze="source",edgeOpacity:Oe=.5,colorByDepth:Ye=!1,nodeSize:Xe=8,nodeSizeRange:je=[5,20],nodeLabel:He,showLabels:Ge=!0,labelMode:Ve,size:qe=Gn,responsiveWidth:Qe,responsiveHeight:Ke,margin:Ze,className:Ue,background:Je,enableHover:et=!0,tooltipContent:tt,customHoverBehavior:rt,customClickBehavior:nt,onObservation:ot,annotationObservationCallback:it,chartId:at,onTopologyChange:st,annotations:ct,onAnnotationActivate:lt,autoPlaceAnnotations:ut,svgAnnotationRules:dt,legend:ht,legendPosition:yt,legendLayout:ft,legendHoverBehavior:gt,legendClickBehavior:pt,legendHighlightedCategory:mt,legendIsolatedCategories:vt,title:xt,foregroundGraphics:kt,backgroundGraphics:bt,decay:St,pulse:_t,transition:wt,animate:At,staleness:Lt,frameScheduler:Et,clock:Pt,random:Dt,seed:Nt,paused:Rt=!1,suspendWhenHidden:Mt=!0,thresholds:Tt,accessibleTable:Ct=!0,description:Wt,summary:It,orbitMode:$t,orbitSize:zt,orbitSpeed:Ft,orbitRevolution:Bt,orbitRevolutionStyle:Ot,orbitEccentricity:Yt,orbitShowRings:Xt,orbitAnimated:jt,customNetworkLayout:Ht,onLayoutError:Gt,layoutConfig:Vt,layoutSelection:qt}=n,Qt=Hn.has(s)?jn:Xn,Kt=Re(!0),Zt=Se({sizeProp:qe,responsiveWidth:Qe,responsiveHeight:Ke,userMargin:Ze,marginDefault:Qt,title:xt,legend:ht,legendPosition:yt,foregroundGraphics:kt,backgroundGraphics:bt,animate:At,transitionProp:wt,frameScheduler:Et,clock:Pt,random:Dt,seed:Nt,paused:Rt,suspendWhenHidden:Mt,themeDirtyRef:Kt}),{reducedMotionRef:Ut,responsiveRef:Jt,size:er,margin:tr,adjustedWidth:rr,adjustedHeight:nr,resolvedForeground:or,resolvedBackground:ar,transition:sr,introEnabled:cr,tableId:lr,rafRef:ur,renderFnRef:dr,scheduleRender:hr,frameRuntime:yr,currentTheme:fr}=Zt,gr=De(),pr=Ne(),mr=Ce(()=>ee(l),[l]),vr=Ce(()=>Array.isArray(u)?ee(u):u,[u]),xr=Ce(()=>({...Fe,...me}),[me]),kr=Ce(()=>({...Be,...xe}),[xe]),br=Ce(()=>{return{chartType:(e={chartType:s,clock:yr.now,random:Dt,seed:Nt,nodeIDAccessor:g,sourceAccessor:x,targetAccessor:A,valueAccessor:L,edgeIdAccessor:P,childrenAccessor:D,hierarchySum:N,orientation:R,nodeAlign:O,nodePaddingRatio:Y,nodeWidth:X,iterations:j,forceStrength:G,padAngle:Z,groupWidth:ie,sortGroups:ae,edgeSort:se,treeOrientation:ce,edgeType:le,padding:he,paddingTop:ye,tensionConfig:xr,showParticles:ve,particleStyle:kr,nodeStyle:be,edgeStyle:Ae,nodeLabel:He,showLabels:Ge,labelMode:Ve,colorBy:Ee,colorScheme:$e,edgeColorBy:ze,edgeOpacity:Oe,colorByDepth:Ye,nodeSize:Xe,nodeSizeRange:je,decay:St,pulse:_t,transition:sr,introAnimation:cr,staleness:Lt,thresholds:Tt,orbitMode:$t,orbitSize:zt,orbitSpeed:Ft,orbitRevolution:Bt,orbitRevolutionStyle:Ot,orbitEccentricity:Yt,orbitShowRings:Xt,orbitAnimated:jt,customNetworkLayout:Ht,onLayoutError:Gt,layoutConfig:Vt,currentTheme:fr}).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:Le(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},[s,yr.now,Dt,Nt,g,x,A,L,P,D,N,R,O,Y,X,j,G,Z,ie,ae,se,ce,le,he,ye,xr,ve,kr,be,Ae,He,Ge,Ve,Ee,$e,ze,Oe,Ye,Xe,je,St,_t,sr,cr,Lt,Tt,$t,zt,Ft,Bt,Ot,Yt,Xt,jt,Ht,Gt,Vt,fr]),Sr=_(br),_r=_({chartType:(wr={chartType:s,nodeIDAccessor:g,sourceAccessor:x,targetAccessor:A,valueAccessor:L,edgeIdAccessor:P,childrenAccessor:D,hierarchySum:N,orientation:R,nodeAlign:O,nodePaddingRatio:Y,nodeWidth:X,iterations:j,forceStrength:G,padAngle:Z,groupWidth:ie,sortGroups:ae,edgeSort:se,treeOrientation:ce,edgeType:le,padding:he,paddingTop:ye,random:Dt,seed:Nt,tensionConfig:xr,customNetworkLayout:Ht,orbitMode:$t,orbitSize:zt,orbitEccentricity:Yt}).chartType,nodeIDAccessor:wr.nodeIDAccessor,sourceAccessor:wr.sourceAccessor,targetAccessor:wr.targetAccessor,valueAccessor:wr.valueAccessor,edgeIdAccessor:wr.edgeIdAccessor,childrenAccessor:wr.childrenAccessor,hierarchySum:wr.hierarchySum,orientation:wr.orientation,nodeAlign:wr.nodeAlign,nodePaddingRatio:wr.nodePaddingRatio,nodeWidth:wr.nodeWidth,iterations:wr.iterations,forceStrength:wr.forceStrength,padAngle:wr.padAngle,groupWidth:wr.groupWidth,sortGroups:wr.sortGroups,edgeSort:wr.edgeSort,treeOrientation:wr.treeOrientation,edgeType:wr.edgeType,padding:wr.padding,paddingTop:wr.paddingTop,random:wr.random,seed:wr.seed,tensionConfig:wr.tensionConfig,customNetworkLayout:wr.customNetworkLayout,orbitMode:wr.orbitMode,orbitSize:wr.orbitSize,orbitEccentricity:wr.orbitEccentricity});var wr;const Ar=Re(0),Lr=Re(0),Er=Re(!1),Pr=Re(null);Pr.current||(Pr.current=new en(Sr));const Dr=we("StreamNetworkFrame"),Nr=We((e,t,r=!1)=>pe(Dr.current,e,()=>e.buildScene(t),r),[Dr]),[Rr,Mr]=Me(null),[Tr,Cr]=Me(0),[Wr,Ir]=Me(0),[$r,zr]=Me(!1),[Fr,Br]=Me(!1),Or=Re(0),Yr=Re(null),Xr=Re(!1),jr=Re(K);jr.current=K;const Hr=Re(Sr);Hr.current=Sr;const Gr=Re(null),Vr=Re(new Map),qr=Re(0),Qr=We(e=>function(e){const{node:t,colorBy:r,colorScheme:n,nodeColorMap:o,colorIndexRef:i}=e;if("function"==typeof r)return r(t)+"";if("string"==typeof r&&t.data){const e=t.data[r];if(void 0!==e){if(!o.has(e+"")){const t=Array.isArray(n)?n:C;o.set(e+"",t[i.current++%t.length])}return o.get(e+"")}}if(o.has(t.id))return o.get(t.id);const a=Array.isArray(n)?n:C,s=r?a[i.current++%a.length]:a[0];return o.set(t.id,s),s}({node:e,colorBy:Ee,colorScheme:$e,nodeColorMap:Vr.current,colorIndexRef:qr}),[Ee,$e]),Kr=(Zr=fr,Zr?.colors?.border||Zr?.colors?.secondary||Zr?.colors?.primary||"#999");var Zr;const Ur=We(e=>function(e,t){return e?"object"==typeof e?e:t?.get(e)??null:null}(e,Pr.current?.nodes),[]),Jr=We(e=>function(e){const{edge:t,edgeColorBy:r,getNodeColor:n,resolveEndpoint:o,fallback:i}=e;if("function"==typeof r)return r(t);const a=o(t.source),s=o(t.target);return"target"===r&&s?n(s):a?n(a):i}({edge:e,edgeColorBy:ze,getNodeColor:Qr,resolveEndpoint:Ur,fallback:Kr}),[ze,Qr,Kr,Ur]),tn=We(e=>function(e){const{edge:t,particleStyleColor:r,particleColorBy:n,hasExplicitParticleColorBy:o,getEdgeColor:i,getNodeColor:a,resolveEndpoint:s,fallback:c}=e;if("function"==typeof r){const e=s(t.source);return e?r(t,e):c}if(!o)return i(t);const l=n,u=s(t.source),d=s(t.target);return"target"===l&&d?a(d):u?a(u):c}({edge:e,particleStyleColor:kr.color,particleColorBy:kr.colorBy,hasExplicitParticleColorBy:!!xe?.colorBy,getEdgeColor:Jr,getNodeColor:Qr,resolveEndpoint:Ur,fallback:Kr}),[xe?.colorBy,kr.color,kr.colorBy,Qr,Jr,Kr,Ur]),rn=function(e,t,r,n,o){return("sankey"===e||t)&&r||n||o}(s,!!Ht,ve,!!_t,Pr.current?.isAnimating??!1);b(Pr,Sr,Kt,hr),S(Pr,qt,Kt,hr),Te(()=>{const e=Pr.current;e&&(Nr(e,[rr,nr]),qr.current=Rn({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vr.current,colorScheme:$e}),Kt.current=!0,hr())},[fr,rr,nr,Nr,hr,$e]);const nn=We(()=>{const e=Pr.current;if(e&&(e.runLayout([rr,nr]),Nr(e,[rr,nr]),Kt.current=!0,qr.current=Rn({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vr.current,colorScheme:$e}),Cr(e.layoutVersion),st)){const{nodes:t,edges:r}=e.getLayoutData();st(t,r)}},[rr,nr,Nr,st,$e]),on=We(e=>{if(null==e||"object"!=typeof e)return;const t=Pr.current;t&&(t.ingestEdge(e)&&nn(),hr())},[nn,hr]),sn=We(e=>{const t=Pr.current;if(!t)return;let r=!1;for(const n of e)null!=n&&"object"==typeof n&&t.ingestEdge(n)&&(r=!0);r&&nn(),hr()},[nn,hr]),cn=We(()=>{Pr.current?.clear(),Vr.current.clear(),qr.current=0,Cr(Pr.current?.layoutVersion??0),Mr(null),Gr.current=null,Kt.current=!0,hr()},[hr]),ln=We(()=>{const e=Pr.current;e&&(e.tension+=999,nn(),hr())},[nn,hr]);Ie(a,()=>({push:on,pushMany:sn,removeNode:e=>{const t=Pr.current?.removeNode(e)??!1;if(t){const t=Gr.current?.data?"function"==typeof g?g(Gr.current.data):Gr.current.data[g]:void 0;Gr.current&&"node"===Gr.current.nodeOrEdge&&t===e&&(Gr.current=null,Mr(null)),Vr.current.delete(e),nn(),Kt.current=!0,hr()}return t},removeEdge:(e,t)=>{const r=Pr.current?.removeEdge(e,t)??!1;if(r){if(Gr.current&&"edge"===Gr.current.nodeOrEdge){const r=Gr.current.data;let n;n=void 0!==t?("object"==typeof r?.source?r.source.id:r?.source)===e&&("object"==typeof r?.target?r.target.id:r?.target)===t:!P||!r||("function"==typeof P?P:e=>e?.[P])(r)===e,n&&(Gr.current=null,Mr(null))}nn(),Kt.current=!0,hr()}return r},updateNode:(e,t)=>{const r=Pr.current?.updateNode(e,t)??null;return r&&(Kt.current=!0,hr()),r},updateEdge:(e,t,r)=>{const n=Pr.current?.updateEdge(e,t,r)??[];return n.length>0&&(nn(),Kt.current=!0,hr()),n},clear:cn,getTopology:()=>Pr.current?.getLayoutData()??{nodes:[],edges:[]},getCustomLayout:()=>Pr.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Pr.current?.lastCustomLayoutFailure??null,getTopologyDiff:()=>{const e=Pr.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:ln,getTension:()=>Pr.current?.tension??0}),[on,sn,cn,ln,g,nn,hr,P]);const dn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(s),hn=dn?d||(Array.isArray(u)?void 0:u):void 0;Te(()=>{const e=Pr.current;if(!e)return;const t=++Or.current;if(Yr.current?.abort(),Yr.current=null,dn&&hn)e.ingestHierarchy(hn,[rr,nr]),Nr(e,[rr,nr]),Br(!1),jr.current?.("ready"),Kt.current=!0,hr();else{const r=mr,n=Array.isArray(vr)?vr:[];if(0===r.length&&0===n.length)return null==l&&null==u||0>=e.nodes.size&&0>=e.edges.size||cn(),Br(!1),void jr.current?.("ready");const o=[rr,nr],i="force"===s&&!Ht&&gn()&&!Dt&&fn(q,r.length,n.length,j);if(i&&pr&&!Xr.current&&e.sceneNodes.length>0)return Xr.current=!0,Br(!1),jr.current?.("ready"),Kt.current=!0,void hr();if(i){const i=new AbortController;Yr.current=i;const a=e._lastPositionSnapshot;e.ingestBounded(r,n,o,{deferLayout:!0});const s=e.getLayoutData(),c=function(e,t,r,n,o){const i=ir(r.nodeSize,r.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,r="string"==typeof e.target?e.target:e.target.id,n=e.data?.weight,o="number"==typeof n&&Number.isFinite(n)?n:e.value;return{source:t,target:r,value:e.value,y0:0,y1:0,sankeyWidth:0,weight:o}}),config:{chartType:"force",iterations:r.iterations,forceStrength:r.forceStrength,seed:r.seed},size:n}}(s.nodes,s.edges,Hr.current,o,a);return Br(!0),jr.current?.("pending"),xn(c,i.signal).then(({positions:r})=>{t===Or.current&&(e.applyForceLayoutPositions(r,o),Nr(e,o),qr.current=Rn({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vr.current,colorScheme:$e}),Br(!1),jr.current?.("ready"),Cr(e.layoutVersion),Kt.current=!0,hr())}).catch(r=>{"AbortError"!==r.name&&t===Or.current&&(e.runLayout(o),Nr(e,o),qr.current=Rn({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vr.current,colorScheme:$e}),Br(!1),jr.current?.("error"),Cr(e.layoutVersion),Kt.current=!0,hr())}),()=>i.abort()}e.ingestBounded(r,n,o),Nr(e,o),Br(!1),jr.current?.("ready"),qr.current=Rn({sceneNodes:e.sceneNodes,nodes:e.nodes.values(),nodeColorMap:Vr.current,colorScheme:$e}),Kt.current=!0,hr()}},[mr,vr,l,u,d,hn,dn,rr,nr,_r,q,j,pr,s,Ht,Dt,hr,cn,$e,Nr]),Te(()=>{h&&h.length>0&&sn(h)},[h,sn]);const{customHoverBehavior:pn,customClickBehavior:mn}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:r,chartId:n}){return{customHoverBehavior:Fn((t,o)=>{e?.(t,o),J({onObservation:r,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:Bn,chartId:n,context:o})},[e,r,n]),customClickBehavior:Fn((e,o)=>{t?.(e,o),U({onObservation:r,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:Bn,chartId:n,context:o})},[t,r,n])}}({customHoverBehavior:rt,customClickBehavior:nt,onObservation:ot,chartId:at}),{hoverHandlerRef:vn,hoverLeaveRef:kn,onPointerMove:bn,onPointerLeave:Sn}=Zt,wn=()=>!Ht||(Pr.current?.hasCustomRestyle??!1);vn.current=e=>{if(!et)return;const t=wn(),r=Vn.current;if(!r)return;const n=Pr.current;if(!n)return;const o=zn({clientX:e.clientX,clientY:e.clientY,canvasRect:r.getBoundingClientRect(),margin:tr,adjustedWidth:rr,adjustedHeight:nr,sceneNodes:n.sceneNodes,sceneEdges:n.sceneEdges,nodeQuadtree:n.nodeQuadtree,maxNodeRadius:n.maxNodeRadius});"hit"===o.kind?(Gr.current=o.hover,Mr(o.hover),pn&&(pn(o.hover),t&&(Kt.current=!0)),t&&hr()):Gr.current&&(Gr.current=null,Mr(null),pn&&(pn(null),t&&(Kt.current=!0)),t&&hr())},kn.current=()=>{if(Gr.current){const e=wn();Gr.current=null,Mr(null),pn&&(pn(null),e&&(Kt.current=!0)),e&&hr()}};const Dn=Re(()=>{});Dn.current=e=>{if(re(e.target))return;if(!nt&&!ot)return;const t=Vn.current;if(!t)return;const r=Pr.current;if(!r)return;const n=zn({clientX:e.clientX,clientY:e.clientY,canvasRect:t.getBoundingClientRect(),margin:tr,adjustedWidth:rr,adjustedHeight:nr,sceneNodes:r.sceneNodes,sceneEdges:r.sceneEdges,nodeQuadtree:r.nodeQuadtree,maxNodeRadius:r.maxNodeRadius});"hit"===n.kind?mn(n.hover,{type:"activate",inputType:ue(e.nativeEvent.pointerType)}):"miss"===n.kind&&mn(null)};const Mn=We(e=>Dn.current(e),[]),Tn=Re(-1),Cn=Re(null),Wn=Re(-1),In=We(e=>{if(ne(e))return;const t=Pr.current;if(!t)return;const r=()=>{Tn.current=-1,Cn.current=null,Wn.current=-1,Gr.current=null,Mr(null),pn&&(pn(null),Kt.current=!0),hr()},n=c(t.sceneNodes);if(0===n.length)return void(0>Tn.current||r());const i=o(n);let a=Tn.current;if(i.flat.length>a||(r(),a=-1)," "===e.key&&a>=0){e.preventDefault();const t=i.flat[a];return void mn(H(t.datum||{},t.x,t.y,{nodeOrEdge:"node"}),{type:"activate",inputType:"keyboard"})}if(0>a){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),Tn.current=0,Wn.current=-1;const t=i.flat[0];Cn.current={shape:t.shape,w:t.w,h:t.h};const r=H(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Gr.current=r,Mr(r),pn&&(pn(r,{type:"focus",inputType:"keyboard"}),Kt.current=!0),void hr()}const s=k(i,a),l=f(e.key,s,i,t.sceneEdges??[],Wn);if(null===l)return;if(e.preventDefault(),0>l)return void r();Tn.current=l;const u=i.flat[l];Cn.current={shape:u.shape,w:u.w,h:u.h};const d={data:u.datum||{},x:u.x,y:u.y,__semioticHoverData:!0,nodeOrEdge:"node"};Gr.current=d,Mr(d),pn&&(pn(d,{type:"focus",inputType:"keyboard"}),Kt.current=!0),hr()},[mn,pn,hr]),$n=We(e=>{Tn.current=-1,Cn.current=null,bn(e)},[bn]);dr.current=()=>{if(ur.current=null,!yr.isActive)return;const r=Vn.current;if(!r)return;const n=Pr.current;n&&function(r){const{canvas:n,store:o,sceneRevisionDiagnostics:i,size:a,margin:s,adjustedWidth:c,adjustedHeight:l,background:u,renderMode:d,hasBackgroundGraphics:h=!1,dirtyRef:f,lastFrameTimeRef:g,now:x,random:k,reducedMotion:b,showParticles:S,isContinuous:_,animate:w,decay:A,pulse:L,thresholds:E,staleness:P,particleStyle:D,getParticleColor:N,pendingAnnotationFrameRef:R,lastAnnotationFrameTimeRef:M,setAnnotationFrame:T,scheduleNextFrame:C}=r,W=n.getContext("2d");if(!W)return;const I=g.current?Math.min((x-g.current)/1e3,.1):.016;g.current=x;const $=o.advanceTransition(b?x+1e6:x),z=!b&&$,F=!b&&o.tickAnimation([c,l],I),B=f.current,O=i?.beforeCompute(o.getLastUpdateResult(),z),Y=$||B||F;Y&&o.buildScene([c,l]),O&&i?.afterCompute(O,Y,!1);const X=S&&!b&&!!o.particlePool,j=!!A||!!L||!!E||!1!==w&&o.hasActiveTopologyDiff||o.hasActivePulses||o.hasActiveThresholds,H=o.consumeStylePaintPending(),G=e({dirtyOrRebuilt:B,transitioning:z,animationTicked:F,continuous:X||_,liveEncoding:j,forced:H}),q=!!P&&o.lastIngestTime>0&&x-o.lastIngestTime>(P?.threshold??5e3);if(G){const e=te();if(!de(n,a,s,e))return;if(W.clearRect(-s.left,-s.top,a[0],a[1]),t(W,{background:u,hasBackgroundGraphics:h,width:c,height:l}),A&&o.applyDecay(),L&&o.applyPulse(x),E&&o.applyThresholds(x),!1!==w&&o.applyTopologyDiff(x),q&&(W.globalAlpha=P?.dimOpacity??.5),p({context:W,nodes:o.sceneEdges,renderMode:d,pixelRatio:e,paintBuiltIn:e=>function(e,t){for(const r of t)switch(r.type){case"bezier":An(e,r);break;case"line":Ln(e,r);break;case"ribbon":En(e,r);break;case"curved":Pn(e,r)}}(W,e)}),p({context:W,nodes:o.sceneNodes,renderMode:d,pixelRatio:e,paintBuiltIn:e=>{const t=e;!function(e,t){for(const r of t){if("rect"!==r.type)continue;const t=r;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle=ge(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=fe(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)),v(e,t),e.restore())}}(W,t),function(e,t){for(const r of t){if("circle"!==r.type)continue;const t=r;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=ge(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=fe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),m(e,t),e.restore())}}(W,t),function(e,t){for(const r of t){if("arc"!==r.type)continue;const t=r;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=ge(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=fe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.globalAlpha=t.style.opacity??1,e.stroke()),e.restore()}}(W,t),function(e,t){const r=e.globalAlpha;for(const n of t){if("symbol"!==n.type)continue;const t=n;if(0>=t.size)continue;const o=Nn(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=r*i*(t.style.fillOpacity??1),e.fillStyle=ge(e,t.style.fill,"#007bff"),e.fill(o)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=r*i,e.strokeStyle=fe(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(o)),e.restore()}}(W,t),y(W,t)}}),X&&!q){const e=o.edgesArray;if(e.length>0){!function(e,t,r,n,o=Math.random){const i=n.spawnRate??.1,a=n.maxPerEdge??50;for(let n=0;t.length>n;n++){const s=t[n];if(!s.bezier)continue;if(e.countForEdge(n)>=a)continue;const c=s.value*i*r*(s.bezier.circular?.3:1),l=Math.floor(c),u=c-l;let d=l;o()<u&&d++;for(let t=0;d>t&&e.countForEdge(n)<a;t++)e.spawn(n,o)}}(o.particlePool,e,I,D,k);const t=.5*(D.speedMultiplier??1);let r;if(D.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)}o.particlePool.step(I,t,e,r),function(e,t,r,n,o){const i=n.radius??3;e.globalAlpha=n.opacity??.7;for(let a=0;t.particles.length>a;a++){const s=t.particles[a];if(!s.active)continue;const c=r[s.edgeIndex];if(!c)continue;let l;l="string"==typeof n.color&&"inherit"!==n.color?n.color:o(c),e.fillStyle=fe(e,l)||l,e.beginPath(),e.arc(s.x,s.y,i,0,2*Math.PI),e.fill()}e.globalAlpha=1}(W,o.particlePool,e,D,N)}}q&&(W.globalAlpha=1)}f.current=!1,(B||z||F)&&n.setAttribute("aria-label",V(o.sceneNodes?.length??0,o.sceneEdges?.length??0,"Network chart"));const Q=B||z||F||R.current;Q&&x-M.current>=33?(T(e=>e+1),M.current=x,R.current=!1):R.current=!!Q,(_||z||null!=o.transition||F||o.hasActivePulses||o.hasActiveThresholds||!1!==w&&o.hasActiveTopologyDiff||R.current)&&C()}({canvas:r,store:n,sceneRevisionDiagnostics:Dr.current,size:er,margin:tr,adjustedWidth:rr,adjustedHeight:nr,background:Je,renderMode:ke,hasBackgroundGraphics:!!bt,dirtyRef:Kt,lastFrameTimeRef:Ar,now:yr.now(),random:yr.random,reducedMotion:!!Ut.current,showParticles:ve,isContinuous:rn,animate:At,decay:St,pulse:_t,thresholds:Tt,staleness:Lt,particleStyle:kr,getParticleColor:tn,pendingAnnotationFrameRef:Er,lastAnnotationFrameTimeRef:Lr,setAnnotationFrame:Ir,scheduleNextFrame:()=>{hr()}})};const{canvasRef:Vn}=_e(Zt,{hydrated:gr,wasHydratingFromSSR:pr,storeRef:Pr,dirtyRef:Kt,canvasPaintDependencies:[s,rr,nr,Je,bt,ke,hr]});w(Lt,Pr,Kt,hr,$r,zr);const qn=et&&Rr?On(W,{x:Rr.x,y:Rr.y,containerWidth:rr,containerHeight:nr,margin:tr,className:"stream-network-tooltip",zIndex:2,children:tt?tt(Rr):On(_n,{data:Rr})}):null;if(oe||!gr&&pr)return On(yn,{props:n,store:Pr.current,responsiveRef:Jt,size:er,margin:tr,adjustedWidth:rr,adjustedHeight:nr,resolvedBackground:ar,resolvedForeground:or});const Qn=Pr.current;return Yn("div",{ref:Jt,className:"stream-network-frame"+(Ue?" "+Ue:""),role:"group","aria-label":Wt||("string"==typeof xt?xt:"Network chart"),tabIndex:0,"aria-busy":Fr||void 0,style:{position:"relative",width:Qe?"100%":er[0],height:Ke?"100%":er[1],overflow:"visible"},onKeyDown:In,children:["production"!==process.env.NODE_ENV&&Pr.current&&On(z,{store:Pr.current,diagnostics:Dr.current}),Ct&&On(B,{tableId:lr}),Ct&&On($,{nodes:Qn?.sceneNodes??[],edges:Qn?.sceneEdges??[],chartType:"Network chart",tableId:lr,chartTitle:"string"==typeof xt?xt:void 0}),On(F,{summary:It}),On(M,{hoverPoint:Rr}),Yn("div",{role:"img","aria-label":Wt||("string"==typeof xt?xt:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:et?$n:void 0,onMouseLeave:et?Sn:void 0,onClick:nt||ot?Mn:void 0,children:[Fr&&!1!==Q&&On("div",{style:{position:"absolute",inset:0,zIndex:3,background:"var(--semiotic-bg, #fff)"},children:Pe(!0,er[0],er[1],Q)}),On(T,{size:er,margin:tr,overflowVisible:!0,children:ar}),On("canvas",{ref:Vn,"aria-label":V(Qn?.sceneNodes?.length??0,Qn?.sceneEdges?.length??0,"Network chart"),style:{position:"absolute",top:0,left:0}}),On(an,{width:rr,height:nr,totalWidth:er[0],totalHeight:er[1],margin:tr,labels:Qn?.labels||[],sceneNodes:Qn?.sceneNodes,title:xt,legend:ht,legendPosition:yt,legendLayout:ft,legendHoverBehavior:gt,legendClickBehavior:pt,legendHighlightedCategory:mt,legendIsolatedCategories:vt,foregroundGraphics:i(or,E(Pr.current?.customLayoutOverlays,qt??null)),annotations:ct,onAnnotationActivate:lt,onObservation:it??ot,chartId:at,chartType:"StreamNetworkFrame",autoPlaceAnnotations:ut,svgAnnotationRules:dt,annotationFrame:Wr}),On(un,{marks:Qn?.customLayoutHtmlMarks,margin:tr,selection:qt??null}),On(I,{active:Tn.current>=0,hoverPoint:Rr,margin:tr,size:er,shape:Cn.current?.shape,width:Cn.current?.w,height:Cn.current?.h}),qn,Lt?.showBadge&&On(r,{isStale:$r,position:Lt.badgePosition})]})]})}));Vn.displayName="StreamNetworkFrame";var qn=Vn;export{Ft as buildRibbonGeometry,fn as shouldUseForceWorker,gn as canUseForceWorker,xn as runForceLayoutWorker,qn as StreamNetworkFrame_default};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{resolveCategoricalPalette as t,resolveExplicitColor as r}from"./chunk-chunk-6HSGDMTA.module.min.js";function e(r,e,n){return t(r,e,n)}function n(t,e){const n=e&&"object"==typeof e&&!Array.isArray(e)?e:void 0;return 0===t.length?t=>n&&r(n,t)||"#4e79a7":e=>{if(n){const t=r(n,e);if(t)return t}let o=0;for(let t=0;e.length>t;t++)o=31*o+e.charCodeAt(t)|0;return t[Math.abs(o)%t.length]??"#4e79a7"}}export{e as resolveCustomLayoutPalette,n as buildResolveColor};
@@ -0,0 +1 @@
1
+ function t(t){let n=t>>>0;return function(){n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}export{t as mulberry32};
@@ -0,0 +1 @@
1
+ function e(e){if("undefined"!=typeof __filename){const r=__filename.replace(/\\/g,"/"),n=r.startsWith("/")?r:"/"+r;return new URL("./"+e,"file:"+n)}throw Error("Cannot resolve module worker asset: "+e)}export{e as commonJsWorkerModuleUrl};
@@ -0,0 +1 @@
1
+ var e=new Set(["label","callout","callout-circle","callout-rect","text","widget"]),n=new Set(["label","callout","callout-circle","callout-rect"]);function t(e){return"string"==typeof e?.type?e.type:""}function a(n){return!!n&&"object"==typeof n&&e.has(t(n))}function i(e){return n.has(t(e))&&!function(e){return Array.isArray(e?.disable)&&e.disable.includes("connector")}(e)}var r=2e4;function o(e){return"primary"===e?.emphasis||!0===e?.defensive}function s(e,n,t={}){return"number"==typeof t.maxAnnotations&&Number.isFinite(t.maxAnnotations)?Math.max(0,Math.floor(t.maxAnnotations)):e>0&&n>0?Math.max(1,Math.round(e*n/(t.areaPerAnnotation&&t.areaPerAnnotation>0?t.areaPerAnnotation:2e4))):1/0}function c(e){let n;const t=e?.emphasis;n="primary"===t?100:"secondary"===t?10:50;const a=e?.provenance?.confidence;switch("number"==typeof a&&Number.isFinite(a)&&(n+=15*Math.max(0,Math.min(1,a))),e?.lifecycle?.freshness){case"fresh":n+=8;break;case"aging":n+=4;break;case"stale":n+=1;break;case"expired":n-=200}return n}function l(e){const{annotations:n,width:t,height:i}=e,r=Math.max(0,e.minVisible??1),l=s(t,i,e),u=n.map((e,n)=>{return{annotation:e,index:n,note:(t=e,a(t))};var t}),h=u.filter(e=>e.note);if(0===h.length||l>=h.length)return{visible:n.slice(),deferred:[],budget:l};const f=h.filter(e=>o(e.annotation)),m=h.filter(e=>!o(e.annotation)).sort((e,n)=>c(n.annotation)-c(e.annotation)||e.index-n.index),d=Math.min(m.length,Math.max(Math.max(0,l-f.length),Math.max(0,r-f.length))),x=new Set([...f.map(e=>e.index),...m.slice(0,d).map(e=>e.index)]),p=[],b=[];for(const{annotation:e,index:n,note:t}of u)!t||x.has(n)?p.push(e):b.push(e);return{visible:p,deferred:b,budget:l}}export{t as annotationType,a as isNoteAnnotation,i as annotationDrawsConnector,r as DEFAULT_AREA_PER_ANNOTATION,s as annotationBudget,l as annotationDensity};
@@ -0,0 +1 @@
1
+ import{mulberry32 as t}from"./chunk-chunk-SIRIJ3DY.module.min.js";import{UpdateResultTracker as e}from"./chunk-chunk-5RKXZQ2P.module.min.js";var i={seed:1,gravity:{x:0,y:980},fixedDt:1/120,cellSize:64,collisionIterations:6,velocityDamping:.995,sleepSpeed:8,sleepAfter:.35,restitution:.1,friction:.35,maxVelocity:1600,contactWakeSpeed:200},s=1e-9,n=.005;function o(t){return"circle"===t.type?{type:"circle",radius:t.radius}:{type:"aabb",width:t.width,height:t.height}}function r(t){return"aabb"===t.type?{type:"aabb",x:t.x,y:t.y,width:t.width,height:t.height}:{type:"segment",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,thickness:t.thickness}}function a(t,e,i){return Math.max(e,Math.min(i,t))}function d(t){return 0>t?-1:1}function h(t){if("circle"===t.shape.type){const e=t.shape.radius;return{minX:t.x-e,minY:t.y-e,maxX:t.x+e,maxY:t.y+e}}const e=t.shape.width/2,i=t.shape.height/2;return{minX:t.x-e,minY:t.y-i,maxX:t.x+e,maxY:t.y+i}}function l(t){const e=t.shape;if("aabb"===e.type){const t=e.width/2,i=e.height/2;return{minX:e.x-t,minY:e.y-i,maxX:e.x+t,maxY:e.y+i}}const i=(e.thickness??0)/2;return{minX:Math.min(e.x1,e.x2)-i,minY:Math.min(e.y1,e.y2)-i,maxX:Math.max(e.x1,e.x2)+i,maxY:Math.max(e.y1,e.y2)+i}}function c(t,e){return!(t.minX>e.maxX||e.minX>t.maxX||t.minY>e.maxY||e.minY>t.maxY)}function u(t,e,i,s,n,o,r,a){const h=n-t,l=(i+r)/2-Math.abs(h);if(0>=l)return null;const c=o-e,u=(s+a)/2-Math.abs(c);return u>0?u>l?{nx:d(h),ny:0,penetration:l}:{nx:0,ny:d(c),penetration:u}:null}function p(t,e,i,n,o,r,d){const h=r/2,l=d/2;let c=t-a(t,n-h,n+h),u=e-a(e,o-l,o+l);const p=c*c+u*u;if(p>i*i)return null;if(s>=p){const s=Math.abs(t-(n-h)),r=Math.abs(t-(n+h)),a=Math.abs(e-(o-l)),d=Math.abs(e-(o+l)),p=Math.min(s,r,a,d);return p===s?(c=-1,u=0,{nx:c,ny:u,penetration:i+s}):p===r?(c=1,u=0,{nx:c,ny:u,penetration:i+r}):p===a?(c=0,u=-1,{nx:c,ny:u,penetration:i+a}):(c=0,u=1,{nx:c,ny:u,penetration:i+d})}const m=Math.sqrt(p);return{nx:c/m,ny:u/m,penetration:i-m}}function m(t,e){if("circle"===t.shape.type&&"circle"===e.shape.type)return function(t,e,i,n,o,r){const a=n-t,d=o-e,h=i+r,l=a*a+d*d;if(l>=h*h)return null;if(s>=l)return{nx:1,ny:0,penetration:h};const c=Math.sqrt(l);return{nx:a/c,ny:d/c,penetration:h-c}}(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.radius);if("aabb"===t.shape.type&&"aabb"===e.shape.type)return u(t.x,t.y,t.shape.width,t.shape.height,e.x,e.y,e.shape.width,e.shape.height);if("circle"===t.shape.type&&"aabb"===e.shape.type){const i=p(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height);return i?{nx:-i.nx,ny:-i.ny,penetration:i.penetration}:null}return"aabb"===t.shape.type&&"circle"===e.shape.type?p(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height):null}function y(t,e){const i=e.shape;return"aabb"===i.type?"circle"===t.shape.type?p(t.x,t.y,t.shape.radius,i.x,i.y,i.width,i.height):u(i.x,i.y,i.width,i.height,t.x,t.y,t.shape.width,t.shape.height):function(t,e,i,n,o,r,d,h=0){const l=r-n,c=d-o,u=l*l+c*c,p=u>s?a(((t-n)*l+(e-o)*c)/u,0,1):0,m=i+h/2,y=t-(n+l*p),f=e-(o+c*p),b=y*y+f*f;if(b>=m*m)return null;if(s>=b){const t=Math.sqrt(u);return t>s?{nx:-c/t,ny:l/t,penetration:m}:{nx:1,ny:0,penetration:m}}const v=Math.sqrt(b);return{nx:y/v,ny:f/v,penetration:m-v}}(t.x,t.y,"circle"===t.shape.type?t.shape.radius:Math.sqrt(t.shape.width*t.shape.width+t.shape.height*t.shape.height)/2,i.x1,i.y1,i.x2,i.y2,i.thickness??0)}function f(t,e){return`${t}\0${e}`}function b(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function v(t){return{id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,bodyCollisions:t.bodyCollisions,shape:o(t.shape),sleeping:t.sleeping,datum:t.datum,index:t.index,sleepTime:t.sleepTime,restitution:t.restitution,friction:t.friction}}function g(t){return t&&"function"!=typeof t?{property:t.property,equals:t.equals,notEquals:t.notEquals,oneOf:t.oneOf?.slice(),notOneOf:t.notOneOf?.slice()}:t}function x(t){return{id:t.id,shape:r(t.shape),sensor:t.sensor,restitution:t.restitution,friction:t.friction,bodyFilter:g(t.bodyFilter),index:t.index}}function S(t,e){return!!e?.some(e=>Object.is(t,e))}function w(t,e){const i=t.bodyFilter;if(!i)return!0;if("function"==typeof i)return i(e);const s=function(t,e){if(!e)return;let i=t;for(const t of e.split(".")){if(null==i||"object"!=typeof i)return;i=i[t]}return i}(e,i.property);return!("equals"in i&&!Object.is(s,i.equals)||"notEquals"in i&&Object.is(s,i.notEquals)||i.oneOf&&!S(s,i.oneOf)||i.notOneOf&&S(s,i.notOneOf))}var I=class{constructor(e={}){this.capabilities={determinism:"strict",sensors:!0,joints:!1,ccd:!1,maxBodiesHint:5e3,worker:!1},this.bodies=new Map,this.colliders=new Map,this.springs=new Map,this.activeSensors=new Set,this.supportedThisStep=new Set,this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0,this.options={...i,...e},this.random=t(this.options.seed)}init(e={}){this.options={...i,...e},this.random=t(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0}spawn(t){const e={id:t.id,x:t.x,y:t.y,prevX:t.x,prevY:t.y,vx:t.vx??0,vy:t.vy??0,angle:t.angle??0,mass:Math.max(s,t.mass??1),bodyCollisions:t.bodyCollisions??!0,shape:o(t.shape),sleeping:!1,datum:t.datum,restitution:t.restitution,friction:t.friction,index:this.nextBodyIndex,sleepTime:0};this.nextBodyIndex+=1,this.bodies.set(t.id,e)}remove(t){for(const e of t){this.bodies.delete(e);for(const t of Array.from(this.activeSensors))b(t).bodyId===e&&this.activeSensors.delete(t)}}setColliders(t){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(const e of t)this.colliders.set(e.id,{...e,shape:r(e.shape),bodyFilter:g(e.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(t){const e=t.id??"spring-"+this.nextSpringIndex;return this.springs.set(e,{id:e,bodyId:t.bodyId,target:t.target,restLength:t.restLength??0,stiffness:t.stiffness??40,damping:t.damping??3}),this.nextSpringIndex+=1,e}removeConstraint(t){this.springs.delete(t)}applyImpulse(t,e,i){const s=this.bodies.get(t);s&&(s.vx+=e/s.mass,s.vy+=i/s.mass,this.wake(s))}step(t=this.options.fixedDt){const e=Math.max(0,t);if(this.lastEvents=[],0===e)return;const i=this.sortedBodies();for(const t of i)t.prevX=t.x,t.prevY=t.y;this.applySprings(e);const s=this.options.maxVelocity;for(const t of i)if(!t.sleeping){if(t.vx+=this.options.gravity.x*e,t.vy+=this.options.gravity.y*e,t.vx*=this.options.velocityDamping,t.vy*=this.options.velocityDamping,s>0){const e=Math.sqrt(t.vx*t.vx+t.vy*t.vy);if(e>s){const i=s/e;t.vx*=i,t.vy*=i}}t.x+=t.vx*e,t.y+=t.vy*e}this.supportedThisStep.clear();const n=this.bodyPairKeys(i),o=this.sortedColliders().filter(t=>!t.sensor);for(let t=0;this.options.collisionIterations>t;t+=1)this.resolveBodyPairs(i,n,0===t),this.resolveColliders(i,o,0===t);this.updateSensors(i),this.updateSleeping(i,e)}settle(t=1200,e=this.options.fixedDt){let i=0;for(;t>i&&!this.allSleeping();)this.step(e),i+=1;return i}readState(t=[]){t.length=0;for(const e of this.sortedBodies())t.push({id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,shape:o(e.shape),sleeping:e.sleeping,datum:e.datum});return t}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(b)}allSleeping(){for(const t of this.bodies.values())if(!t.sleeping)return!1;return!0}snapshot(){return{options:{...this.options,gravity:{...this.options.gravity}},bodies:this.sortedBodies().map(v),colliders:this.sortedColliders().map(x),springs:Array.from(this.springs.values()).map(t=>({...t,target:{...t.target}})),activeSensors:Array.from(this.activeSensors).sort()}}restore(e){this.options={...e.options,gravity:{...e.options.gravity}},this.random=t(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(e.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(const t of e.bodies){const e=v(t);this.bodies.set(e.id,e),this.nextBodyIndex=Math.max(this.nextBodyIndex,e.index+1)}this.nextColliderIndex=0;for(const t of e.colliders){const e=x(t);this.colliders.set(e.id,e),this.nextColliderIndex=Math.max(this.nextColliderIndex,e.index+1)}this.nextSpringIndex=0;for(const t of e.springs){this.springs.set(t.id,{...t,target:{...t.target}});const e=/^spring-(\d+)$/.exec(t.id);e&&(this.nextSpringIndex=Math.max(this.nextSpringIndex,Number(e[1])+1))}}dispose(){this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[]}sortedBodies(){return Array.from(this.bodies.values()).sort((t,e)=>t.index-e.index)}sortedColliders(){return Array.from(this.colliders.values()).sort((t,e)=>t.index-e.index)}applySprings(t){for(const e of Array.from(this.springs.values()).sort((t,e)=>t.id.localeCompare(e.id))){const i=this.bodies.get(e.bodyId);if(!i||i.sleeping)continue;const n="point"===e.target.type?e.target:this.bodies.get(e.target.bodyId);if(!n)continue;const o=n.x-i.x,r=n.y-i.y,a=Math.sqrt(o*o+r*r);if(s>=a)continue;const d=o/a,h=r/a,l=(a-e.restLength)*e.stiffness+((("vx"in n?n.vx:0)-i.vx)*d+(("vy"in n?n.vy:0)-i.vy)*h)*e.damping;i.vx+=l*d*t/i.mass,i.vy+=l*h*t/i.mass}}resolveBodyPairs(t,e,i){for(const s of e){const[e,n]=s.split(":").map(Number),o=t[e],r=t[n];if(!o||!r)continue;const a=m(o,r);a&&(this.resolveDynamicCollision(o,r,a),i&&this.lastEvents.push({type:"contact",bodyId:o.id,otherId:r.id,sensor:!1}))}}bodyPairKeys(t){const e=Math.max(1,this.options.cellSize),i=new Map;for(let s=0;t.length>s;s+=1){if(!1===t[s].bodyCollisions)continue;const n=h(t[s]),o=Math.floor(n.minX/e),r=Math.floor(n.maxX/e),a=Math.floor(n.minY/e),d=Math.floor(n.maxY/e);for(let t=o;r>=t;t+=1)for(let e=a;d>=e;e+=1){const n=`${t}:${e}`,o=i.get(n);o?o.push(s):i.set(n,[s])}}const s=new Set;for(const e of Array.from(i.keys()).sort()){const n=i.get(e)??[];n.sort((t,e)=>t-e);for(let e=0;n.length>e;e+=1)for(let i=e+1;n.length>i;i+=1){const o=n[e],r=n[i];!1!==t[o].bodyCollisions&&!1!==t[r].bodyCollisions&&c(h(t[o]),h(t[r]))&&s.add(`${o}:${r}`)}}return Array.from(s).sort((t,e)=>{const[i,s]=t.split(":").map(Number),[n,o]=e.split(":").map(Number);return i===n?s-o:i-n})}resolveDynamicCollision(t,e,i){t.sleeping&&this.supportedThisStep.add(e.id),e.sleeping&&this.supportedThisStep.add(t.id);const o=t.sleeping?0:1/t.mass,r=e.sleeping?0:1/e.mass,a=o+r;if(s>=a)return;const d=Math.max(0,i.penetration-n)/a;t.x-=i.nx*d*o,t.y-=i.ny*d*o,e.x+=i.nx*d*r,e.y+=i.ny*d*r;const h=(e.vx-t.vx)*i.nx+(e.vy-t.vy)*i.ny;if(h>0)return;const l=Math.abs(h),c=-(1+Math.min(t.restitution??this.options.restitution,e.restitution??this.options.restitution))*h/a,u=c*i.nx,p=c*i.ny;t.vx-=u*o,t.vy-=p*o,e.vx+=u*r,e.vy+=p*r,this.applyFriction(t,e,i,c,o,r),l>this.options.contactWakeSpeed&&(this.wake(t),this.wake(e))}applyFriction(t,e,i,n,o,r){const d=-i.ny,h=i.nx,l=(e.vx-t.vx)*d+(e.vy-t.vy)*h,c=o+r;if(s>=Math.abs(l)||s>=c)return;const u=Math.max(0,Math.min(1,Math.max(t.friction??this.options.friction,e.friction??this.options.friction))),p=a(-l/c,-n*u,n*u),m=p*d,y=p*h;t.vx-=m*o,t.vy-=y*o,e.vx+=m*r,e.vy+=y*r}resolveColliders(t,e,i){for(const s of t)for(const t of e){if(!w(t,s))continue;if(!c(h(s),l(t)))continue;const e=y(s,t);e&&(this.resolveStaticCollision(s,t,e),this.supportedThisStep.add(s.id),i&&this.lastEvents.push({type:"contact",bodyId:s.id,otherId:t.id,sensor:!1}))}}resolveStaticCollision(t,e,i){t.x+=i.nx*Math.max(0,i.penetration-n),t.y+=i.ny*Math.max(0,i.penetration-n);const s=t.vx*i.nx+t.vy*i.ny;if(0>s){const n=Math.min(t.restitution??this.options.restitution,e.restitution??this.options.restitution);t.vx-=(1+n)*s*i.nx,t.vy-=(1+n)*s*i.ny;const o=-i.ny,r=i.nx,a=t.vx*o+t.vy*r,d=Math.max(0,Math.min(1,Math.max(t.friction??this.options.friction,e.friction??this.options.friction)));t.vx-=a*o*d,t.vy-=a*r*d}}updateSensors(t){const e=new Set,i=this.sortedColliders().filter(t=>t.sensor);for(const s of t){const t=h(s);for(const n of i){if(!w(n,s))continue;if(!c(t,l(n)))continue;if(!y(s,n))continue;const i=f(n.id,s.id);e.add(i),this.activeSensors.has(i)||this.lastEvents.push({type:"sensor-enter",bodyId:s.id,sensorId:n.id})}}for(const t of Array.from(this.activeSensors).sort()){if(e.has(t))continue;const{sensorId:i,bodyId:s}=b(t);this.lastEvents.push({type:"sensor-exit",bodyId:s,sensorId:i})}this.activeSensors=e}updateSleeping(t,e){const i=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const s of t)Math.sqrt(s.vx*s.vx+s.vy*s.vy)>=this.options.sleepSpeed||Math.sqrt((s.x-s.prevX)*(s.x-s.prevX)+(s.y-s.prevY)*(s.y-s.prevY))>=this.options.sleepSpeed*e||i&&!this.supportedThisStep.has(s.id)?s.sleeping?this.wake(s):s.sleepTime=0:(s.sleepTime+=e,s.sleeping||this.options.sleepAfter>s.sleepTime||(s.sleeping=!0,s.vx=0,s.vy=0,this.lastEvents.push({type:"sleep",bodyId:s.id})))}wake(t){t.sleeping&&this.lastEvents.push({type:"wake",bodyId:t.id}),t.sleeping=!1,t.sleepTime=0}nextRandom(){return this.random()}},M=class{constructor(t={}){this.id="builtin",this.capabilities={...(new I).capabilities,engine:"builtin"},this.world=new I(t)}init(t={}){this.world.init(t)}spawn(t){this.world.spawn(t)}remove(t){this.world.remove(t)}setColliders(t){this.world.setColliders(t)}setConstraint(t){return this.world.setConstraint(t)}removeConstraint(t){this.world.removeConstraint(t)}applyImpulse(t,e,i){this.world.applyImpulse(t,e,i)}step(t){this.world.step(t)}settle(t,e){return this.world.settle(t,e)}readState(t){return this.world.readState(t)}events(){return this.world.events()}activeSensorPairs(){return this.world.activeSensorPairs()}allSleeping(){return this.world.allSleeping()}snapshot(){return this.world.snapshot()}restore(t){this.world.restore(t)}nextRandom(){return this.world.nextRandom()}dispose(){this.world.dispose()}};function B(t={}){return new M(t)}function k(t,e={}){return t?"function"==typeof t?t(e):(t.init(e),t):B(e)}var O=["binId","targetBin","category","windowIndex","lane","group"];function q(t,e){if(!Number.isFinite(e))return;t.count+=1,t.total+=e,t.min=Math.min(t.min,e),t.max=Math.max(t.max,e);const i=e-t.mean;t.mean+=i/t.count,t.m2+=i*(e-t.mean)}function C(t){return{count:t.count,total:t.total,mean:t.count>0?t.mean:0,min:t.count>0?t.min:0,max:t.count>0?t.max:0,variance:t.count>1?t.m2/(t.count-1):0}}function T(t){return{count:t.count,total:t.total,mean:t.mean,m2:t.variance*Math.max(0,t.count-1),min:t.count>0?t.min:1/0,max:t.count>0?t.max:-1/0}}function A(t,e){if(null!=t[e])return t[e];const i=t.datum;return i&&"object"==typeof i?i[e]:void 0}function D(t,e,i){return"function"==typeof t?t(e,i):"string"==typeof t?A(e,t):void 0}function R(t){if(null==t)return;const e=t+"";return e.trim()?e:void 0}function Y(t){const e=C(t.value);return{id:t.id,label:t.label,count:e.count,total:e.total,bodyIds:t.bodyIds.slice(),lastBodyId:t.lastBodyId,lastDatum:t.lastDatum,x:C(t.x),y:C(t.y),value:e}}var E=class{constructor(t=!1){this.bins=new Map,this.nextIndex=0,this.config=t}updateConfig(t){void 0!==t&&(this.config=t,!1===t&&this.clear())}isEnabled(){return!1!==this.config}add(t){if(!1===this.config)return null;const e=this.nextIndex;this.nextIndex+=1;const i=R(D(this.config.binAccessor,t,e))??function(t){for(const e of O){const i=R(A(t,e));if(i)return i}return"sediment"}(t),s=R(D(this.config.labelAccessor,t,e))??i,n=function(t,e,i){if("number"==typeof t)return t;const s="function"==typeof t?t(e,i):"string"==typeof t?A(e,t):1,n="number"==typeof s?s:Number(s);return Number.isFinite(n)?n:1}(this.config.valueAccessor,t,e),o=Math.max(0,Math.floor(this.config.retainBodyIds??12));let r=this.bins.get(i);return r||(r={id:i,label:s,bodyIds:[],x:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},y:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},value:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0}},this.bins.set(i,r)),r.label=s,r.lastBodyId=t.id,r.lastDatum=t.datum,q(r.x,t.x),q(r.y,t.y),q(r.value,n),o>0&&(r.bodyIds.push(t.id),r.bodyIds.length>o&&(r.bodyIds=r.bodyIds.slice(r.bodyIds.length-o))),Y(r)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(Y)}restore(t=[]){this.bins.clear();for(const e of t)this.bins.set(e.id,{id:e.id,label:e.label,bodyIds:e.bodyIds.slice(),lastBodyId:e.lastBodyId,lastDatum:e.lastDatum,x:T(e.x),y:T(e.y),value:T(e.value)});this.nextIndex=t.reduce((t,e)=>t+e.count,0)}totals(){const t=this.snapshot();return{bins:t.length,count:t.reduce((t,e)=>t+e.count,0),total:t.reduce((t,e)=>t+e.total,0)}}};function F(t,e={}){const{baselineY:i=0,binWidth:s=24,gap:n=2,maxHeight:o=80,value:r="count",x:a}=e,d=Math.max(1,...t.map(t=>t[r]));return t.map((t,e)=>{const h=Math.max(0,t[r]/d*o),l=a?.(t,e)??e*(s+n);return{binId:t.id,label:t.label,index:e,count:t.count,total:t.total,x:l,y:i-h,width:s,height:h,meanX:t.x.mean,meanY:t.y.mean}})}function P(t){const e=Number(t);if(Number.isFinite(e)&&e>0)return Math.floor(e)}function L(t){const e=Math.max(0,Math.floor(t.liveBodies)),i=Math.max(0,Math.floor(t.queuedBodies??0)),s=e+i,n=P(t.bodyLimit),o=P(t.engineMaxBodiesHint),r=function(t,e,i){if(!1===i)return;const s=P(i?.warnAt);return null!=s?s:null!=t?Math.max(1,Math.floor(.8*t)):null!=e?Math.max(1,Math.floor(.8*e)):void 0}(n,o,t.options),a=null==n?0:Math.max(0,e-n),d=a>0?"overflow":null==r||r>s?"ok":"warning";return{action:"overflow"!==d?"continue":t.sedimentEnabled?"sediment":t.evictionEnabled?"evict":"retain",bodyLimit:n,engineMaxBodiesHint:o,liveBodies:e,overflow:a,projectedBodies:s,queuedBodies:i,state:d,warnAt:r}}var X={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},j={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function N(t={},e=j){return{chartId:t.chartId??e.chartId,chartType:t.chartType??e.chartType,sensors:t.sensors??e.sensors,onObservation:t.onObservation??e.onObservation,onSimulationStateChange:t.onSimulationStateChange??e.onSimulationStateChange}}function $(t){return{...t,shape:{...t.shape},datum:t.datum,springs:t.springs?.map(t=>({...t,target:{...t.target}}))}}function W(t){if(t instanceof Date){const e=t.getTime();return Number.isFinite(e)?e:void 0}const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:void 0}function H(t,e){if(null!=t[e])return t[e];const i=t.datum;return i&&"object"==typeof i?i[e]:void 0}function K(t,e={}){const i=W(e.startAt)??0,s=e.pacing??"immediate";if("arrival"===s){const s=t.map((t,i)=>function(t,e,i){return"function"==typeof i?W(i(t,e)):"string"==typeof i?W(H(t,i)):W(t.spawnAt)??W(H(t,"arrivalTime"))??W(H(t,"timestamp"))??W(H(t,"time"))??W(H(t,"eventTime"))}(t,i,e.timeAccessor)),n=s.filter(t=>null!=t),o=n.length>0?Math.min(...n):0,r=W(e.timeScale)??1,a=r>0?r:1;return t.map((t,e)=>{const n=s[e],r=null==n?0:Math.max(0,n-o);return{...$(t),spawnAt:i+r/a}})}if("object"==typeof s){const e=W(s.ratePerSec);if(e&&e>0)return t.map((t,s)=>({...$(t),spawnAt:i+s/e}))}return t.map(t=>({...$(t),spawnAt:i}))}function z(t){return{...$(t),sequence:t.sequence,spawnAt:t.spawnAt}}function V(t){return t.map(t=>({...t,shape:{...t.shape},bodyFilter:t.bodyFilter&&"function"!=typeof t.bodyFilter?{...t.bodyFilter,oneOf:t.bodyFilter.oneOf?.slice(),notOneOf:t.bodyFilter.notOneOf?.slice()}:t.bodyFilter}))}function U(t){return!1!==t&&{...t}}function G(t,e){return t.spawnAt===e.spawnAt?t.sequence-e.sequence:t.spawnAt-e.spawnAt}function J(t){return{...t,gravity:{...t.gravity}}}function Q(t,e,i,s){if("circle"===t.shape.type){const n=t.x-e,o=t.y-i,r=t.shape.radius+s,a=n*n+o*o;return a>r*r?null:a}const n=Math.max(Math.abs(e-t.x)-t.shape.width/2,0),o=Math.max(Math.abs(i-t.y)-t.shape.height/2,0),r=n*n+o*o;return r>s*s?null:r}function Z(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function _(t,e={}){const{idPrefix:i="plot",includeFloor:s=!0,includeCeiling:n=!1,includeLeftWall:o=!0,includeRightWall:r=!0,wallThickness:a=20,floorThickness:d=a}=e,h=[],l=t.x+t.width/2,c=t.y+t.height/2;return s&&h.push({id:i+"-floor",shape:{type:"aabb",x:l,y:t.y+t.height+d/2,width:t.width+2*a,height:d}}),n&&h.push({id:i+"-ceiling",shape:{type:"aabb",x:l,y:t.y-d/2,width:t.width+2*a,height:d}}),o&&h.push({id:i+"-left-wall",shape:{type:"aabb",x:t.x-a/2,y:c,width:a,height:t.height+2*d}}),r&&h.push({id:i+"-right-wall",shape:{type:"aabb",x:t.x+t.width+a/2,y:c,width:a,height:t.height+2*d}}),h}function tt(t){const{idPrefix:e="bin",count:i,domainStart:s,domainStep:n,xScale:o,yTop:r,yBottom:a,wallThickness:d=4,includeBoundaryWalls:h=!0,includeInteriorWalls:l=!0,closedBefore:c,lidY:u=r,lidThickness:p=Math.max(2,d)}=t,m=[],y=r+(a-r)/2,f=Math.abs(a-r),b=h?i:i-1;if(l||h)for(let t=h?0:1;b>=t;t+=1){if(!l&&t>0&&i>t)continue;const r=o(s+t*n);m.push({id:`${e}-wall-${t}`,shape:{type:"aabb",x:r,y:y,width:d,height:f}})}if(null!=c)for(let t=0;i>t;t+=1){const i=s+t*n,r=i+n;if(r>=c)continue;const a=o(i),h=o(r);m.push({id:`${e}-lid-${t}`,shape:{type:"segment",x1:Math.min(a,h)+d/2,y1:u,x2:Math.max(a,h)-d/2,y2:u,thickness:p}})}return m}import{quadtree as et}from"d3-quadtree";var it=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(t,e,i,s,n,o=0){const r=this.ensure(t,e);if(!r)return null;let a=null,d=1/0;const h=Math.max(0,o)+this.maxSearchRadius,l=s-h,c=s+h,u=n-h,p=n+h;return r.visit((t,e,r,h,m)=>{if(l>h||e>c||u>m||r>p)return!0;if(t.length)return!1;let y=t;for(;y;){const t=y.data;if(t){const e=Q(t,s,n,Math.max(0,o));null!=e&&(d>e||e===d&&i.indexOf(t.id)>i.indexOf(a?.id??""))&&(a=t,d=e)}y=y.next}return!1}),a}ensure(t,e){if(this.tree&&this.revision===e)return this.tree;const i=t.readState();return 0===i.length?(this.tree=null,this.maxSearchRadius=0,this.revision=e,null):(this.maxSearchRadius=i.reduce((t,e)=>Math.max(t,function(t){return"circle"===t.shape.type?t.shape.radius:Math.hypot(t.shape.width,t.shape.height)/2}(e)),0),this.tree=et().x(t=>t.x).y(t=>t.y).addAll(i),this.revision=e,this.tree)}},st=["data","scene-geometry","data-paint","accessibility","evidence"],nt=["scene-geometry","data-paint","accessibility","evidence"],ot=["overlay","accessibility","evidence"],rt=(t,e)=>({retainedData:t,invalidations:e}),at=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],dt=["scene-geometry","data-paint","accessibility","evidence"],ht=[],lt={engine:rt("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:rt("preserve",dt),colliders:rt("preserve",dt),sediment:rt("preserve",dt),bodyBudget:rt("preserve",at),bodyLimit:rt("preserve",at),eviction:rt("preserve",at),fixedDt:rt("preserve",ht),maxDeltaSeconds:rt("preserve",ht),maxSubsteps:rt("preserve",ht),settleStepLimit:rt("preserve",ht),timeScale:rt("preserve",ht),observation:rt("preserve",ht)},ct=rt("preserve",at);function ut(t){let e="preserve";const i=new Set;for(const s of t){const t=lt[s]??ct;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}var pt=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function mt(t,e){return t===e||!(!t||!e)&&t.gravity?.x===e.gravity?.x&&t.gravity?.y===e.gravity?.y&&pt.every(i=>t[i]===e[i])}function yt(t,e,i,s){return t||!e?"paused":i||!s?"running":"settled"}var ft=class{constructor(t={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new it,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new e,this.simulationState="settled",this.visible=!0;const{bodyBudget:i,colliders:s,engine:n,kernel:o,observation:r,sediment:a,...d}=t;this.config={...X,...d},this.configInput={...t},this.bodyBudget=i??{},this.engineInput=n,this.observation=N(r),this.sediment=new E(a??!1),this.world=k(n,{fixedDt:this.config.fixedDt,...o}),s&&this.world.setColliders(V(s))}updateConfig(t){const e=function(t,e){return Object.keys(t).filter(i=>"kernel"===i?!mt(t.kernel,e.kernel):t[i]!==e[i])}(t,this.configInput),{colliders:i,bodyBudget:s,engine:n,kernel:o,observation:r,sediment:a,...d}=t;if(this.config={...this.config,...d},void 0!==s&&(this.bodyBudget=s,!1===s&&(this.bodyBudgetObservationKey="ok")),n&&n!==this.engineInput){const t=this.world.snapshot();this.world.dispose(),this.engineInput=n,this.world=k(n,t.options),this.world.restore(t),this.revision+=1}if(o&&!mt(o,this.configInput.kernel)){const t=this.world.snapshot(),e={...t.options,...o,gravity:{...t.options.gravity,...o.gravity}};this.world.restore({...t,options:e}),this.revision+=1}r&&(this.observation=N(r,this.observation)),this.sediment.updateConfig(a),i&&(this.world.setColliders(V(i)),this.revision+=1),this.configInput={...this.configInput,...t};const h=ut(e);this.updateResults.record({kind:"config",keys:e},h.invalidations)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}setColliders(t){this.world.setColliders(V(t)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},ut(["colliders"]).invalidations)}enqueue(t,e){const i=Array.isArray(t)?t:[t],s=e?K(i,{...e,startAt:e.startAt??this.elapsedSeconds}):i;for(const t of s)this.queue.push({...$(t),sequence:this.nextSequence,spawnAt:t.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(G),s.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:s.length},s.length?st:[])}enqueueWithResult(t,e){return this.enqueue(t,e),this.updateResults.last}spawnNow(t){this.spawnOne($(t)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},st)}clear(){const t=this.world.snapshot().options;this.world.init({...t,fixedDt:this.config.fixedDt}),this.activeSensorPairs.clear(),this.liveBodyOrder=[],this.queue=[],this.accumulator=0,this.elapsedSeconds=0,this.nextSequence=0,this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},st)}tick(t){const e=this.revision,i=[],s=[],n=[],o=[],r=[];if(this.paused||!this.visible){const t=this.result(0,i,s,n,o,r,!1);return this.updateResults.record({kind:"tick",count:0},[]),t}const a=Math.max(0,Math.min(t,this.config.maxDeltaSeconds))*this.config.timeScale;this.elapsedSeconds+=a,this.spawnDue(i,r);const d=this.observeBodyBudget(r),h=this.evictOverflow(r);s.push(...h.evicted),n.push(...h.sedimented),this.syncSimulationState(r),this.accumulator+=a;let l=0;for(;this.accumulator>=this.config.fixedDt&&this.config.maxSubsteps>l;){this.world.step(this.config.fixedDt);const t=this.world.events();o.push(...t),this.observeKernelEvents(t,r),this.observeSensorTransitions(r),this.accumulator-=this.config.fixedDt,l+=1}l===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),(l>0||i.length>0||s.length>0||n.length>0||o.length>0)&&(this.revision+=1);const c=this.result(l,i,s,n,o,r,void 0,d);return this.updateResults.record({kind:"tick",count:l},this.revision!==e?i.length||s.length||n.length?st:nt:[]),c}settle(t=this.config.settleStepLimit){const e=this.revision;this.spawnDue([],[]);const i=this.world.settle(t,this.config.fixedDt);return i>0&&(this.revision+=1),this.syncSimulationState(),this.updateResults.record({kind:"settle",count:i},this.revision!==e?nt:[]),i}settleWithObservations(t=this.config.settleStepLimit){const e=this.revision,i=[],s=[],n=[],o=[],r=[];if(this.paused||!this.visible){const t=this.result(0,i,s,n,o,r,!1);return this.updateResults.record({kind:"settle",count:0},[]),t}this.spawnDue(i,r);const a=this.observeBodyBudget(r),d=this.evictOverflow(r);s.push(...d.evicted),n.push(...d.sedimented),this.syncSimulationState(r);let h=0;for(;t>h&&!this.world.allSleeping();){this.world.step(this.config.fixedDt);const t=this.world.events();o.push(...t),this.observeKernelEvents(t,r),this.observeSensorTransitions(r),h+=1}(h>0||i.length>0||s.length>0||n.length>0||o.length>0)&&(this.revision+=1);const l=this.result(h,i,s,n,o,r,void 0,a);return this.updateResults.record({kind:"settle",count:h},this.revision!==e?i.length||s.length||n.length?st:nt:[]),l}readBodies(t=[]){return this.world.readState(t)}readSediment(){return this.sediment.snapshot()}bodyBudgetStatus(){return this.evaluateBodyBudget()}sedimentTotals(){return this.sediment.totals()}sedimentHeightfield(t={}){return F(this.readSediment(),t)}hitTest(t,e,i=0){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,t,e,i)}events(){return this.world.events()}allSleeping(){return this.world.allSleeping()}hasPendingWork(){return this.queue.length>0||!this.world.allSleeping()}queueSize(){return this.queue.length}liveBodyCount(){return this.liveBodyOrder.length}elapsed(){return this.elapsedSeconds}recordObservation(t){const{timestamp:e,chartType:i,chartId:s,...n}=t,o={...n,timestamp:e??this.elapsedSeconds,chartType:i??this.observation.chartType,chartId:s??this.observation.chartId};return this.emitObservation(o),this.updateResults.record({kind:"update",count:1},["evidence"]),o}getLastUpdateResult(){return this.updateResults.last}getUpdateSnapshot(){return this.updateResults.last}subscribeUpdateResult(t){return this.updateResults.subscribe(t)}version(){return this.revision}setPaused(t){const e=this.paused!==t;this.paused=t,this.syncSimulationState(),this.updateResults.record({kind:"pause"},e?ot:[])}setVisible(t){const e=this.visible!==t;this.visible=t,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},e?ot:[])}remove(t){const e=new Set(t),i=new Set(this.liveBodyOrder),s=new Set(this.queue.map(t=>t.id));this.queue=this.queue.filter(t=>!e.has(t.id)),this.liveBodyOrder=this.liveBodyOrder.filter(t=>!e.has(t)),this.world.remove(t),this.removeActiveSensorPairsForBodies(e);const n=t.filter(t=>i.has(t)||s.has(t));return n.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:n,count:n.length},n.length?st:[]),n}setConstraint(t){const e=this.world.setConstraint(t);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},nt),e}removeConstraint(t){this.world.removeConstraint(t),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},nt)}applyImpulse(t,e,i){this.world.applyImpulse(t,e,i),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[t]},nt)}nextRandom(){return this.world.nextRandom()}controls(){return t=this,{applyImpulse:(e,i,s)=>t.applyImpulse(e,i,s),clear:()=>t.clear(),hitTest:(e,i,s)=>t.hitTest(e,i,s),pause:()=>t.setPaused(!0),push:(e,i)=>t.enqueue(e,i),pushMany:(e,i)=>t.enqueue(e,i),bodyBudgetStatus:()=>t.bodyBudgetStatus(),readBodies:e=>t.readBodies(e),readSediment:()=>t.readSediment(),recordObservation:e=>t.recordObservation(e),remove:e=>t.remove(e),restore:e=>t.restore(e),resume:()=>t.setPaused(!1),settle:e=>t.settle(e),settleWithObservations:e=>t.settleWithObservations(e),snapshot:()=>t.snapshot(),sedimentHeightfield:e=>t.sedimentHeightfield(e),sedimentTotals:()=>t.sedimentTotals(),step:e=>t.tick(e)};var t}snapshot(){const t=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:U(this.bodyBudget),config:{...this.config,kernel:J(t.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(z),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:t}}restore(t){this.config={bodyLimit:t.config.bodyLimit,eviction:t.config.eviction,fixedDt:t.config.fixedDt,maxDeltaSeconds:t.config.maxDeltaSeconds,maxSubsteps:t.config.maxSubsteps,settleStepLimit:t.config.settleStepLimit,timeScale:t.config.timeScale},this.configInput={...t.config,bodyBudget:U(t.bodyBudget??{}),kernel:J(t.world.options)},this.bodyBudget=U(t.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.activeSensorPairs=new Set(t.activeSensorPairs),this.accumulator=t.accumulator,this.elapsedSeconds=t.elapsedSeconds,this.paused=t.paused,this.queue=t.queue.map(z).sort(G),this.revision=t.revision,this.sediment.restore(t.sediment??[]),this.simulationState=t.simulationState??yt(t.paused,t.visible,t.queue.length>0,t.world.bodies.every(t=>t.sleeping)),this.liveBodyOrder=t.liveBodyOrder.slice(),this.visible=t.visible,this.nextSequence=this.queue.reduce((t,e)=>Math.max(t,e.sequence),-1)+1,this.world.restore(t.world),this.updateResults.record({kind:"restore"},st)}spawnDue(t,e){for(;this.queue.length>0&&this.elapsedSeconds>=this.queue[0].spawnAt;){const i=this.queue.shift();if(!i)return;this.spawnOne(i,e),t.push(i.id)}}spawnOne(t,e){this.liveBodyOrder=this.liveBodyOrder.filter(e=>e!==t.id),this.removeActiveSensorPairsForBodies(new Set([t.id])),this.world.spawn(t),this.liveBodyOrder.push(t.id);for(const e of t.springs??[])this.world.setConstraint({...e,bodyId:t.id});const i=this.world.readState().find(e=>e.id===t.id);this.emitObservation({type:"physics-spawn",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:t.id,datum:i?.datum??t.datum,x:i?.x??t.x,y:i?.y??t.y},e)}result(t,e,i,s,n,o,r,a=this.evaluateBodyBudget()){this.syncSimulationState(o);const d=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:i,events:n,observations:o,queueSize:this.queue.length,revision:this.revision,shouldContinue:r??(this.queue.length>0||!d),sleeping:d,sedimented:s,spawned:e,steps:t}}observeKernelEvents(t,e){!function(t,e,i){if(0===e.length)return;const s=new Map(t.readState().map(t=>[t.id,t]));for(const t of e){if("sleep"!==t.type)continue;const e=s.get(t.bodyId);i.emit({type:"physics-settle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:t.bodyId,datum:e?.datum,x:e?.x,y:e?.y})}}(this.world,t,this.observationContext(e))}observeSensorTransitions(t){this.activeSensorPairs=function(t,e,i){const s=new Set(t.activeSensorPairs().map(t=>`${t.sensorId}\0${t.bodyId}`));if(0===s.size&&0===e.size)return s;const n=new Map(t.readState().map(t=>[t.id,t])),o=(t,e)=>{const{sensorId:s,bodyId:o}=Z(e),r=i.observation.sensors[s],a=n.get(o);i.emit({type:"enter"===t?r?.enterType??"physics-bin-enter":r?.exitType??"physics-bin-exit",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:o,datum:a?.datum,x:a?.x,y:a?.y,sensorId:s,binId:r?.binId??s})};for(const t of Array.from(s).sort())e.has(t)||o("enter",t);for(const t of Array.from(e).sort())s.has(t)||o("exit",t);return s}(this.world,this.activeSensorPairs,this.observationContext(t))}removeActiveSensorPairsForBodies(t){!function(t,e){for(const i of t)e.has(Z(i).bodyId)&&t.delete(i)}(this.activeSensorPairs,t)}observationContext(t){return{elapsedSeconds:this.elapsedSeconds,observation:this.observation,emit:e=>this.emitObservation(e,t)}}emitObservation(t,e){e?.push(t),this.observation.onObservation?.(t)}evaluateBodyBudget(){return L({bodyLimit:this.config.bodyLimit,engineMaxBodiesHint:this.world.capabilities.maxBodiesHint,evictionEnabled:!1!==this.config.eviction,liveBodies:this.liveBodyOrder.length,queuedBodies:this.queue.length,sedimentEnabled:this.sediment.isEnabled(),options:this.bodyBudget})}observeBodyBudget(t){const e=this.evaluateBodyBudget();if("ok"===e.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",e;const i=`${e.state}:${e.action}`;return i===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=i,this.emitObservation({type:"overflow"===e.state?"physics-budget-overflow":"physics-budget-warning",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,budgetAction:e.action,bodyLimit:e.bodyLimit,engineMaxBodiesHint:e.engineMaxBodiesHint,liveBodies:e.liveBodies,overflow:e.overflow,projectedBodies:e.projectedBodies,queuedBodies:e.queuedBodies,warnAt:e.warnAt},t)),e}syncSimulationState(t){const e=yt(this.paused,this.visible,this.queue.length>0,this.world.allSleeping());if(e===this.simulationState)return;const i=this.simulationState;this.simulationState=e,function(t,e,i){i.observation.onSimulationStateChange?.(e,t),"running"!==e&&"settled"!==e||i.emit({type:"running"===e?"sim-active":"sim-idle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,simulationState:e,previousSimulationState:t})}(i,e,this.observationContext(t))}evictOverflow(t){if(!1===this.config.eviction)return{evicted:[],sedimented:[]};const e=Math.max(0,Math.floor(this.config.bodyLimit));if(!Number.isFinite(e))return{evicted:[],sedimented:[]};const i=this.liveBodyOrder.length-e;if(0>=i)return{evicted:[],sedimented:[]};const s=("sleeping-first"===this.config.eviction?this.sleepingFirstEvictionOrder():this.liveBodyOrder.slice()).slice(0,i);if(0===s.length)return{evicted:[],sedimented:[]};const n=this.absorbSediment(s,t);this.world.remove(s);const o=new Set(s);return this.liveBodyOrder=this.liveBodyOrder.filter(t=>!o.has(t)),this.removeActiveSensorPairsForBodies(o),{evicted:s,sedimented:n}}absorbSediment(t,e){const i=new Map(this.world.readState().map(t=>[t.id,t])),s=[];for(const n of t){const t=i.get(n);if(!t)continue;const o=this.sediment.add(t);o&&(s.push(n),this.emitObservation({type:"physics-sediment",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:n,datum:t.datum,x:t.x,y:t.y,binId:o.id,count:o.count,total:o.total},e))}return s}sleepingFirstEvictionOrder(){const t=new Map(this.world.readState().map(t=>[t.id,t.sleeping])),e=[],i=[];for(const s of this.liveBodyOrder)t.get(s)?e.push(s):i.push(s);return[...e,...i]}};function bt(t,e){if("region-enter"!==e.type)return t;const i=e.region.id,s=t[i]??{id:i,label:e.region.label??i,count:0,bodyIds:[]};if(s.bodyIds.includes(e.bodyId))return t;const n=[...s.bodyIds,e.bodyId];return{...t,[i]:{...s,count:n.length,bodyIds:n}}}function vt(t,e){return(e??Object.keys(t)).map(e=>t[e]).filter(t=>null!=t).map(t=>({label:t.label??t.id,value:t.count}))}function gt(t,e){const i=e instanceof Set?e:new Set(e);return t.map(t=>{const e=t.bodyIds??[],s=e.filter(t=>!i.has(t)),n=e.length-s.length,o=t.completion?.mode??"allMembersAbsorbed",r=t.completion?.valueByBodyId,a=t=>{const e=r?.[t];return Number.isFinite(e)&&Number(e)>=0?Number(e):1},d=e.reduce((t,e)=>t+a(e),0),h=e.reduce((t,e)=>t+(i.has(e)?a(e):0),0),l=t.completion?.threshold,c="threshold"===o?Number.isFinite(l)&&Number(l)>=0?Number(l):d:void 0;return{id:t.id,label:t.label??t.id,mode:o,complete:e.length>0&&("anyAbsorbed"===o?n>0:"threshold"===o?h>=(c??d):0===s.length),absorbed:n,total:e.length,absorbedValue:h,totalValue:d,threshold:c,missing:s}})}function xt(t,e,i){return Math.max(e,Math.min(i,t))}function St(t,e,i={}){const s=i.random??Math.random,n=t.stages.find(t=>t.id===e)??t.stages[t.stages.length-1],o=xt(i.along??.5,.05,.95),r=i.jitterX??0,a=i.padY??20,d=n.x0+(n.x1-n.x0)*o+(2*s()-1)*r,h=Math.min(1,n.width/2),l=xt(d,n.x0+h,n.x1-h),c=t.boundaryY(l,"top")+a,u=t.boundaryY(l,"bottom")-a;return{x:l,y:u>c?c+s()*Math.max(1,u-c):t.midY}}function wt(t){return"bowtie"===t.shape?[{id:"incoming",role:"incoming",points:[[t.left,t.topY],[t.centerLeft,t.pinchTop],[t.centerLeft,t.pinchBottom],[t.left,t.bottomY]]},{id:"center",role:"center",points:[[t.centerLeft,t.pinchTop],[t.centerRight,t.pinchTop],[t.centerRight,t.pinchBottom],[t.centerLeft,t.pinchBottom]]},{id:"outgoing",role:"outgoing",points:[[t.centerRight,t.pinchTop],[t.right,t.topY],[t.right,t.bottomY],[t.centerRight,t.pinchBottom]]}]:[{id:"volume",role:"volume",points:[[t.left,t.topY],[t.right,"funnel"===t.shape?t.pinchTop:t.topY],[t.right,"funnel"===t.shape?t.pinchBottom:t.bottomY],[t.left,t.bottomY]]}]}function It(t,e,i){return Math.max(e,Math.min(i,t))}function Mt(t,e,i,s,n,o={}){return{id:t,friction:o.friction,restitution:o.restitution,bodyFilter:o.bodyFilter,shape:{type:"segment",x1:e,y1:i,x2:s,y2:n,thickness:o.thickness??8}}}function Bt(t){const e=t.shape??"lane",i=Math.max(1,Math.round(t.width)),s=Math.max(1,Math.round(t.height)),n=t.padX??46,o=t.padY??72,r=n,a=i-n,d=o,h=s-Math.max(24,Math.round(.45*o)),l=(d+h)/2,c=Math.max(1,h-d),u=It(t.pinchRatio??.18,.06,.5),p=Number(t.pinchHeightOffset??0),m=Number.isFinite(p)?p:0,y=It(c*u+m,.06*c,.5*c),f=y/2,b=l-f,v=l+f,g=t.idPrefix??"process",x=t.friction??.58,S=t.restitution??.18,w=t.wallThickness??8,I=t.stages;if(!I.length)throw Error("processStageLayout requires at least one stage");const M=It(t.centerStageIndex??Math.floor(I.length/2),0,I.length-1),B=function(t){const e=t.reduce((t,e)=>t+(e.share??1),0);return e>0?e:t.length}(I),k=a-r;let O=r;const q=I.map((t,e)=>{const i=O,s=e===I.length-1?a:O+(t.share??1)/B*k;return O=s,{id:t.id,label:t.label,description:t.description,kind:t.kind??"stage",index:e,x0:i,x1:s,x:(i+s)/2,width:s-i,y:l,height:c}}),C=q[M],T=C.x0,A=C.x1,D=(t,i)=>{if("lane"===e)return"top"===i?d:h;if("funnel"===e){const e=It((t-r)/Math.max(1,a-r),0,1);return"top"===i?d+(b-d)*e:h+(v-h)*e}if(T>=t){const e=It((t-r)/Math.max(1,T-r),0,1);return"top"===i?d+(b-d)*e:h+(v-h)*e}if(A>=t)return"top"===i?b:v;const s=It((t-A)/Math.max(1,a-A),0,1);return"top"===i?b+(d-b)*s:v+(h-v)*s},R=q.map(t=>{const e=Math.min(D(t.x0,"top"),D(t.x1,"top")),i=Math.max(D(t.x0,"bottom"),D(t.x1,"bottom"));return{...t,y:(e+i)/2,height:Math.max(1,i-e)}}),Y={thickness:w,friction:x,restitution:S},E=[];"lane"===e?E.push(Mt(g+"-top",r,d,a,d,Y),Mt(g+"-bottom",r,h,a,h,Y),Mt(g+"-left",r,d,r,h,{...Y,thickness:Math.max(6,w-2)}),Mt(g+"-right",a,d,a,h,{...Y,thickness:Math.max(6,w)})):"funnel"===e?E.push(Mt(g+"-top",r,d,a,b,Y),Mt(g+"-bottom",r,h,a,v,Y),Mt(g+"-left",r,d,r,h,{...Y,thickness:Math.max(6,w-2)}),Mt(g+"-right",a,b,a,v,{...Y,thickness:Math.max(6,w)})):E.push(Mt(g+"-left-top",r,d,T,b,Y),Mt(g+"-left-bottom",r,h,T,v,Y),Mt(g+"-center-top",T,b,A,b,Y),Mt(g+"-center-bottom",T,v,A,v,Y),Mt(g+"-right-top",A,b,a,d,Y),Mt(g+"-right-bottom",A,v,a,h,Y),Mt(g+"-left",r,d,r,h,{...Y,thickness:Math.max(6,w-2)}),Mt(g+"-right",a,d,a,h,{...Y,thickness:Math.max(6,w)}));const F=t.membraneDampingScale??.5,P=r,L=Math.max(1,("bowtie"===e?T:a)-P),X=(t.membranes??[]).map(t=>{const e=P+It(t.offset,0,1)*L,i=t.width??18+18*t.cost,s=c-16,n=l+.25*(t.wobble??0);return{...t,x:e,y:n,width:i,height:s}}),j=!1===t.includeMembraneRegions?[]:X.map(t=>qt({id:t.id,label:t.label??t.id,description:t.description??(t.label??t.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:t.x,y:t.y,width:t.width,height:t.height,cost:t.cost,dampingScale:t.dampingScale??F,bodyStyle:t.bodyStyle,metadata:t.metadata,semanticItem:t.semanticItem,color:t.color}));return{shape:e,width:i,height:s,padX:n,padY:o,left:r,right:a,topY:d,bottomY:h,midY:l,centerLeft:T,centerRight:A,pinchHeight:y,pinchTop:b,pinchBottom:v,stages:R,membranes:X,colliders:E,regionEffects:j,boundaryY:D}}function kt(t){return{id:t.id,label:t.label,description:t.description,kind:t.kind,shape:(e=t.x,i=t.y,s=t.width,n=t.height,{type:"aabb",x:e,y:i,width:s,height:n}),bodyFilter:t.bodyFilter,collider:t.collider,colliderThickness:t.colliderThickness,friction:t.friction,restitution:t.restitution,semanticItem:t.semanticItem,metadata:t.metadata,bodyStyle:t.bodyStyle,attributes:t.attributes,onEnter:t.onEnter,onExit:t.onExit};var e,i,s,n}function Ot(t,e={}){const i=e.idPrefix??"stage",s=Math.max(0,e.insetX??0),n=Math.max(0,e.insetY??1);return t.stages.map(t=>{const o="function"==typeof e.metadata?e.metadata(t):e.metadata??{};return{...kt({id:i?`${i}:${t.id}`:t.id,label:t.label??t.id,description:t.description,kind:"region",x:t.x,y:t.y,width:Math.max(1,t.width-2*s),height:Math.max(1,t.height-2*n),bodyFilter:e.bodyFilter,semanticItem:e.semanticItem,attributes:{primitive:"processStage",stageId:t.id,stageIndex:t.index},metadata:{...o,primitive:"processStage",stageId:t.id,stageIndex:t.index}})}})}function qt(t){const e=t.dampingScale??.5,i=t.energyScale??1,s=It(t.cost,0,2);return{...kt({...t,kind:t.kind??"membrane",attributes:{primitive:"membrane",membraneCost:s,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:s*e,energyDelta:-s*i}}function Ct(t){return{...kt({...t,kind:t.kind??"charge-gate",attributes:{primitive:"chargeGate",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),charge:t.charge??!0,energyDelta:t.energyDelta,impulseOnEnter:t.impulseOnEnter}}function Tt(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:12,y:0};return{...kt({...t,kind:t.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.015}}function At(t){const e=t.pressure??t.occupancy??0,i=t.baseDamping??.08,s=t.dampingPerUnit??.12,n=t.energyPerUnit??0;return{...kt({...t,kind:t.kind??"membrane",attributes:{primitive:"pressureField",pressure:e,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:i+e*s,energyDelta:n?-e*n:void 0,force:t.force}}function Dt(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force;return{...kt({...t,kind:t.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:t.capacity,unitsPerSecond:t.unitsPerSecond??t.capacity,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping,charge:t.charge??t.capacity}}function Rt(t){return{...kt({...t,kind:t.kind??"force-field",attributes:{primitive:"portal",targetStage:t.targetStage,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:t.force,impulseOnEnter:t.impulseOnEnter,damping:t.damping??.08}}function Yt(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:24,y:0};return{...kt({...t,kind:t.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.02,charge:t.charge??"absorbed"}}function Et(t){return{...kt({...t,kind:t.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:t.force,damping:t.damping,energyDelta:t.energyDelta}}function Ft(t){const e=t.x??t.anchor?.x??0,i=t.y??t.anchor?.y??0;return{id:t.id,label:t.label,description:t.description,group:t.group,bodyIds:t.bodyIds,datum:t.datum,state:t.state,x:e,y:i,width:t.width,height:t.height,anchor:t.anchor??{x:e,y:i},completion:t.completion,tether:t.tether,semanticItem:t.semanticItem}}function Pt(t){const e=t.idPrefix??"lane",i={thickness:t.thickness??8,friction:t.friction??.5,restitution:t.restitution??.16},s=[Mt(e+"-top",t.left,t.top,t.right,t.top,i),Mt(e+"-bottom",t.left,t.bottom,t.right,t.bottom,i)];return t.openEnds||s.push(Mt(e+"-left",t.left,t.top,t.left,t.bottom,i),Mt(e+"-right",t.right,t.top,t.right,t.bottom,i)),s}export{M as BuiltInPhysicsEngineAdapter,B as createDefaultPhysicsEngineAdapter,E as PhysicsSedimentAccumulator,F as sedimentHeightfield,L as evaluatePhysicsBodyBudget,K as schedulePhysicsSpawns,_ as collidersFromPlotBounds,tt as collidersFromXScaleBins,ft as PhysicsPipelineStore,bt as aggregateRegionCounts,vt as regionCountsToProjectionRows,gt as groupCompletionRows,St as stageTargetInVolume,wt as processVolumePolygons,Bt as processStageLayout,Ot as processStageRegions,qt as membraneRegion,Ct as chargeGateRegion,Tt as routeSurfaceRegion,At as pressureFieldRegion,Dt as capacitatedRegion,Rt as portalRegion,Yt as absorbRegion,Et as forceFieldRegion,Ft as bodyGroupSpec,Pt as processLaneWalls};
@@ -0,0 +1 @@
1
+ var t=class{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let i;return this._size===this._capacity?i=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,i}pushMany(t){const i=[];for(const s of t){const t=this.push(s);void 0!==t&&i.push(t)}return i}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+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 t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const i=(this.head-this._size+this._capacity)%this._capacity;for(let s=0;this._size>s;s++)t(this.buffer[(i+s)%this._capacity],s)}toArray(){const t=Array(this._size),i=(this.head-this._size+this._capacity)%this._capacity;for(let s=0;this._size>s;s++)t[s]=this.buffer[(i+s)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const i=this.toArray();let s=0,h=[];i.length>t&&(s=i.length-t,h=i.slice(0,s)),this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(let t=s;i.length>t;t++)this.push(i[t]);return h}update(t,i){const s=[],h=(this.head-this._size+this._capacity)%this._capacity;for(let e=0;this._size>e;e++){const r=(h+e)%this._capacity,a=this.buffer[r];if(t(a)){let t;t="object"!=typeof a||null===a?a:Array.isArray(a)?[...a]:{...a},s.push(t),this.buffer[r]=i(a)}}return s}remove(t){const i=[],s=[];if(this.forEach(h=>{t(h)?s.push(h):i.push(h)}),0===s.length)return s;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of i)this.push(t);return s}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}},i=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,i){this._min=1/0,this._max=-1/0;for(const s of t){const t=i?i(s):s;Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}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}};export{t as RingBuffer,i as IncrementalExtent};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{addMqlListener as e}from"./chunk-chunk-YHNZCPOZ.module.min.js";import{createContext as o,useCallback as r,useContext as t,useMemo as a,useRef as i,useSyncExternalStore as c}from"react";import{jsx as s}from"react/jsx-runtime";function n(e){let n=null;const d=()=>(n||(n=o(null)),n),f=l(e);return[function({children:o,initialState:r}){const t=i(r),c=a(()=>l(e,t.current),[]),n=d();return s(n.Provider,{value:c,children:o})},(e,o)=>{const a=d(),s=t(a)??f,n=i(e);n.current=e;const l=i({hasValue:!1,value:void 0}),u=r(()=>{const e=n.current(s.getState()),r=l.current;return r.hasValue&&o&&o(r.value,e)?r.value:(l.current={hasValue:!0,value:e},e)},[s,o]),p=r(()=>n.current(s.getState()),[s]);return c(s.subscribe,u,p)}]}function l(e,o){const r=new Set;let t={...e(function(e){const o=e(t);if(function(e){for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o))return!0;return!1}(o)){t={...t,...o};for(const e of r)e()}}),...o??{}};return{getState:()=>t,subscribe:function(e){return r.add(e),()=>{r.delete(e)}}}}function d(e){if(!e?.colors)return;const o=e.colors;return{primary:o.primary,secondary:o.secondary||o.primary,surface:o.surface||o.background,success:o.success,danger:o.danger,warning:o.warning,error:o.error,info:o.info,text:o.text,textSecondary:o.textSecondary,border:o.border,grid:o.grid}}function f(e){if(!e.accessibility)return e;let o=e;if(e.accessibility.colorBlindSafe&&(o={...o,colors:{...o.colors,categorical:u}}),e.accessibility.highContrast){const e="dark"===o.mode;o={...o,colors:{...o.colors,text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"}}}return o}var u=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],p={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}},g={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}},y={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:u,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 b(e,o){if("light"===o)return p;if("dark"===o)return g;if("high-contrast"===o)return y;if("string"==typeof o)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${o}". Keeping current theme.`),e;if(o.mode&&"auto"!==o.mode){const e="dark"===o.mode?g:p;return f({...e,...o,colors:{...e.colors,...o.colors||{}},typography:{...e.typography,...o.typography||{}}})}return f({...e,...o,colors:{...e.colors,...o.colors||{}},typography:{...e.typography,...o.typography||{}}})}var[m,h]=n(e=>({theme:p,setTheme(o){e(e=>({theme:b(e.theme,o)}))}}));function x(e,o=":root"){const r=[];return r.push(` --semiotic-bg: ${e.colors.background};`),r.push(` --semiotic-text: ${e.colors.text};`),r.push(` --semiotic-text-secondary: ${e.colors.textSecondary};`),r.push(` --semiotic-grid: ${e.colors.grid};`),r.push(` --semiotic-border: ${e.colors.border};`),r.push(` --semiotic-primary: ${e.colors.primary};`),r.push(` --semiotic-font-family: ${e.typography.fontFamily};`),e.colors.focus&&r.push(` --semiotic-focus: ${e.colors.focus};`),e.colors.selection&&r.push(` --semiotic-selection-color: ${e.colors.selection};`),null!=e.colors.selectionOpacity&&r.push(` --semiotic-selection-opacity: ${e.colors.selectionOpacity};`),e.colors.diverging&&r.push(` --semiotic-diverging: ${e.colors.diverging};`),e.tooltip?.background&&r.push(` --semiotic-tooltip-bg: ${e.tooltip.background};`),e.tooltip?.text&&r.push(` --semiotic-tooltip-text: ${e.tooltip.text};`),e.tooltip?.borderRadius&&r.push(` --semiotic-tooltip-radius: ${e.tooltip.borderRadius};`),e.tooltip?.fontSize&&r.push(` --semiotic-tooltip-font-size: ${e.tooltip.fontSize};`),e.tooltip?.shadow&&r.push(` --semiotic-tooltip-shadow: ${e.tooltip.shadow};`),e.borderRadius&&r.push(` --semiotic-border-radius: ${e.borderRadius};`),e.colors.annotation&&r.push(` --semiotic-annotation-color: ${e.colors.annotation};`),null!=e.typography.legendSize&&r.push(` --semiotic-legend-font-size: ${e.typography.legendSize}px;`),null!=e.typography.titleFontSize&&r.push(` --semiotic-title-font-size: ${e.typography.titleFontSize}px;`),null!=e.typography.tickFontFamily&&r.push(` --semiotic-tick-font-family: ${e.typography.tickFontFamily};`),null!=e.typography.tickSize&&r.push(` --semiotic-tick-font-size: ${e.typography.tickSize}px;`),null!=e.typography.labelSize&&r.push(` --semiotic-axis-label-font-size: ${e.typography.labelSize}px;`),r.push(` --semiotic-secondary: ${e.colors.secondary||e.colors.primary};`),r.push(` --semiotic-surface: ${e.colors.surface||e.colors.background};`),e.colors.success&&r.push(` --semiotic-success: ${e.colors.success};`),e.colors.danger&&r.push(` --semiotic-danger: ${e.colors.danger};`),e.colors.warning&&r.push(` --semiotic-warning: ${e.colors.warning};`),e.colors.error&&r.push(` --semiotic-error: ${e.colors.error};`),e.colors.info&&r.push(` --semiotic-info: ${e.colors.info};`),`${o} {\n${r.join("\n")}\n}`}function S(e){return{semiotic:{bg:{$value:e.colors.background,$type:"color"},text:{$value:e.colors.text,$type:"color"},"text-secondary":{$value:e.colors.textSecondary,$type:"color"},grid:{$value:e.colors.grid,$type:"color"},border:{$value:e.colors.border,$type:"color"},primary:{$value:e.colors.primary,$type:"color"},focus:{$value:e.colors.focus||e.colors.primary,$type:"color"},"font-family":{$value:e.typography.fontFamily,$type:"fontFamily"},"border-radius":{$value:e.borderRadius||"8px",$type:"dimension"},tooltip:{bg:{$value:e.tooltip?.background||e.colors.background,$type:"color"},text:{$value:e.tooltip?.text||e.colors.text,$type:"color"},radius:{$value:e.tooltip?.borderRadius||"6px",$type:"dimension"},"font-size":{$value:e.tooltip?.fontSize||"14px",$type:"dimension"},shadow:{$value:e.tooltip?.shadow||"0 2px 8px rgba(0,0,0,0.15)",$type:"shadow"}},selection:{color:{$value:e.colors.selection||e.colors.primary,$type:"color"},opacity:{$value:e.colors.selectionOpacity??.2,$type:"number"}},categorical:{$value:e.colors.categorical,$type:"color",$description:"Categorical color palette"},sequential:{$value:e.colors.sequential,$type:"string",$description:"d3-scale-chromatic sequential scheme name"},...e.colors.diverging?{diverging:{$value:e.colors.diverging,$type:"string",$description:"d3-scale-chromatic diverging scheme name"}}:{},...e.colors.annotation?{"annotation-color":{$value:e.colors.annotation,$type:"color"}}:{},...null!=e.typography.legendSize?{"legend-font-size":{$value:e.typography.legendSize+"px",$type:"dimension"}}:{},...null!=e.typography.titleFontSize?{"title-font-size":{$value:e.typography.titleFontSize+"px",$type:"dimension"}}:{},...null!=e.typography.tickFontFamily?{"tick-font-family":{$value:e.typography.tickFontFamily,$type:"fontFamily"}}:{},...null!=e.typography.tickSize?{"tick-font-size":{$value:e.typography.tickSize+"px",$type:"dimension"}}:{},...null!=e.typography.labelSize?{"axis-label-font-size":{$value:e.typography.labelSize+"px",$type:"dimension"}}:{},secondary:{$value:e.colors.secondary||e.colors.primary,$type:"color"},surface:{$value:e.colors.surface||e.colors.background,$type:"color"},...e.colors.success?{success:{$value:e.colors.success,$type:"color"}}:{},...e.colors.danger?{danger:{$value:e.colors.danger,$type:"color"}}:{},...e.colors.warning?{warning:{$value:e.colors.warning,$type:"color"}}:{},...e.colors.error?{error:{$value:e.colors.error,$type:"color"}}:{},...e.colors.info?{info:{$value:e.colors.info,$type:"color"}}:{}}}}var k=["#6929c4","#1192e8","#005d5d","#9f1853","#fa4d56","#570408","#198038","#002d9c","#ee538b","#b28600","#009d9a","#012749","#8a3800","#a56eff"],$={danger:"#da1e28",warning:"#f1c21b",success:"#24a148",info:"#0043ce"},z={light:p,dark:g,"high-contrast":y,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#7a644a",grid:"#e8d5c4",border:"#e8d5c4",focus:"#8a5fae",annotation:"#8a5fae",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#64717f",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#d06a6a",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#c63b3b",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#7a47e8",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function v(e){return z[e]}import*as w from"react";import{jsx as F,jsxs as R}from"react/jsx-runtime";var q=w.createContext(void 0),B="undefined"==typeof window?w.useEffect:w.useLayoutEffect;function C(e){if("string"!=typeof e)return e;if("light"===e||"dark"===e||"high-contrast"===e)return e;return v(e)||(void 0!==console&&console.warn(`[ThemeProvider] Unknown theme preset "${e}". Falling back to light theme.`),"light")}function M({theme:o}){const r=h(e=>e.setTheme),t=h(e=>e.theme),a=w.useRef(t);a.current=t;const i=w.useRef(null);w.useEffect(()=>{if(void 0!==o)return;if("undefined"==typeof window||!window.matchMedia)return;const t=window.matchMedia("(forced-colors: active)");return t.matches&&(i.current=a.current===y?p:a.current,r("high-contrast")),e(t,e=>{e.matches?(i.current=a.current===y?i.current??p:a.current,r("high-contrast")):(function(e,o){e(o===p?"light":o===g?"dark":o===y?"high-contrast":o)}(r,i.current??p),i.current=null)})},[o,r]);const c=w.useRef(!1);return B(()=>{c.current?void 0!==o&&r(C(o)):c.current=!0},[o,r]),null}function N({children:e}){const o=h(e=>e.theme),r={position:"relative","--semiotic-bg":o.colors.background,"--semiotic-text":o.colors.text,"--semiotic-text-secondary":o.colors.textSecondary,"--semiotic-grid":o.colors.grid,"--semiotic-border":o.colors.border,"--semiotic-cell-border":o.colors.cellBorder||o.colors.border,"--semiotic-primary":o.colors.primary,"--semiotic-font-family":o.typography.fontFamily,...o.colors.focus?{"--semiotic-focus":o.colors.focus}:{},...o.tooltip?.background?{"--semiotic-tooltip-bg":o.tooltip.background}:{},...o.tooltip?.text?{"--semiotic-tooltip-text":o.tooltip.text}:{},...o.tooltip?.borderRadius?{"--semiotic-tooltip-radius":o.tooltip.borderRadius}:{},...o.tooltip?.fontSize?{"--semiotic-tooltip-font-size":o.tooltip.fontSize}:{},...o.tooltip?.shadow?{"--semiotic-tooltip-shadow":o.tooltip.shadow}:{},...o.borderRadius?{"--semiotic-border-radius":o.borderRadius}:{},...o.colors.selection?{"--semiotic-selection-color":o.colors.selection}:{},...null!=o.colors.selectionOpacity?{"--semiotic-selection-opacity":o.colors.selectionOpacity+""}:{},...o.colors.diverging?{"--semiotic-diverging":o.colors.diverging}:{},...o.colors.annotation?{"--semiotic-annotation-color":o.colors.annotation}:{},...null!=o.typography.legendSize?{"--semiotic-legend-font-size":o.typography.legendSize+"px"}:{},...null!=o.typography.titleFontSize?{"--semiotic-title-font-size":o.typography.titleFontSize+"px"}:{},...null!=o.typography.tickFontFamily?{"--semiotic-tick-font-family":o.typography.tickFontFamily}:{},...null!=o.typography.tickSize?{"--semiotic-tick-font-size":o.typography.tickSize+"px"}:{},...null!=o.typography.labelSize?{"--semiotic-axis-label-font-size":o.typography.labelSize+"px"}:{},"--semiotic-secondary":o.colors.secondary||o.colors.primary,"--semiotic-surface":o.colors.surface||o.colors.background,...o.colors.success?{"--semiotic-success":o.colors.success}:{},...o.colors.danger?{"--semiotic-danger":o.colors.danger}:{},...o.colors.warning?{"--semiotic-warning":o.colors.warning}:{},...o.colors.error?{"--semiotic-error":o.colors.error}:{},...o.colors.info?{"--semiotic-info":o.colors.info}:{}},t=w.useContext(q),a={};return t&&(a["data-semiotic-theme"]=t),F("div",{style:r,...a,children:e})}function O({theme:e,children:o}){const r="string"==typeof e&&v(e)?e:void 0,t=w.useMemo(()=>function(e){return void 0!==e?b(p,C(e)):"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(forced-colors: active)").matches?y:p}(e),[e]);return F(m,{initialState:{theme:t},children:R(q.Provider,{value:r,children:[F(M,{theme:e}),F(N,{children:o})]})})}function P(){return h(e=>e.theme)}export{n as createStore,d as resolveThemeSemanticColors,u as COLOR_BLIND_SAFE_CATEGORICAL,p as LIGHT_THEME,g as DARK_THEME,y as HIGH_CONTRAST_THEME,h as useThemeSelector,x as themeToCSS,S as themeToTokens,k as CARBON_CATEGORICAL_14,$ as CARBON_ALERT,z as THEME_PRESETS,v as resolveThemePreset,O as ThemeProviderWrapper,P as useTheme};
@@ -0,0 +1 @@
1
+ import{DARK_THEME as o,HIGH_CONTRAST_THEME as e,LIGHT_THEME as t,ThemeProvider as i,resolveThemePreset as r,resolveThemeUpdate as n,useThemeSelector as c}from"./chunk-chunk-DSNGDNJY.module.min.js";import{useState as s,useEffect as l}from"react";function a(o,e){if("function"==typeof o.addEventListener)return o.addEventListener("change",e),()=>o.removeEventListener("change",e);const t=o;return t.addListener(e),()=>t.removeListener(e)}function d(o){return!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia(o).matches}function u(){const[o,e]=s(()=>d("(prefers-reduced-motion: reduce)"));return l(()=>{if("undefined"==typeof window||!window.matchMedia)return;const o=window.matchMedia("(prefers-reduced-motion: reduce)");return e(o.matches),a(o,o=>e(o.matches))},[]),o}function m(){const[o,e]=s(()=>d("(forced-colors: active)"));return l(()=>{if("undefined"==typeof window||!window.matchMedia)return;const o=window.matchMedia("(forced-colors: active)");return e(o.matches),a(o,o=>e(o.matches))},[]),o}import*as f from"react";import{jsx as h,jsxs as p}from"react/jsx-runtime";var y=f.createContext(void 0),g="undefined"==typeof window?f.useEffect:f.useLayoutEffect;function w(o){if("string"!=typeof o)return o;if("light"===o||"dark"===o||"high-contrast"===o)return o;return r(o)||(void 0!==console&&console.warn(`[ThemeProvider] Unknown theme preset "${o}". Falling back to light theme.`),"light")}function v({theme:i}){const r=c(o=>o.setTheme),n=c(o=>o.theme),s=f.useRef(n);s.current=n;const l=f.useRef(null);f.useEffect(()=>{if(void 0!==i)return;if("undefined"==typeof window||!window.matchMedia)return;const n=window.matchMedia("(forced-colors: active)");return n.matches&&(l.current=s.current===e?t:s.current,r("high-contrast")),a(n,i=>{i.matches?(l.current=s.current===e?l.current??t:s.current,r("high-contrast")):(function(i,r){i(r===t?"light":r===o?"dark":r===e?"high-contrast":r)}(r,l.current??t),l.current=null)})},[i,r]);const d=f.useRef(!1);return g(()=>{d.current?void 0!==i&&r(w(i)):d.current=!0},[i,r]),null}function b({children:o}){const e=c(o=>o.theme),t={position:"relative","--semiotic-bg":e.colors.background,"--semiotic-text":e.colors.text,"--semiotic-text-secondary":e.colors.textSecondary,"--semiotic-grid":e.colors.grid,"--semiotic-border":e.colors.border,"--semiotic-cell-border":e.colors.cellBorder||e.colors.border,"--semiotic-primary":e.colors.primary,"--semiotic-font-family":e.typography.fontFamily,...e.colors.focus?{"--semiotic-focus":e.colors.focus}:{},...e.tooltip?.background?{"--semiotic-tooltip-bg":e.tooltip.background}:{},...e.tooltip?.text?{"--semiotic-tooltip-text":e.tooltip.text}:{},...e.tooltip?.borderRadius?{"--semiotic-tooltip-radius":e.tooltip.borderRadius}:{},...e.tooltip?.fontSize?{"--semiotic-tooltip-font-size":e.tooltip.fontSize}:{},...e.tooltip?.shadow?{"--semiotic-tooltip-shadow":e.tooltip.shadow}:{},...e.borderRadius?{"--semiotic-border-radius":e.borderRadius}:{},...e.colors.selection?{"--semiotic-selection-color":e.colors.selection}:{},...null!=e.colors.selectionOpacity?{"--semiotic-selection-opacity":e.colors.selectionOpacity+""}:{},...e.colors.diverging?{"--semiotic-diverging":e.colors.diverging}:{},...e.colors.annotation?{"--semiotic-annotation-color":e.colors.annotation}:{},...null!=e.typography.legendSize?{"--semiotic-legend-font-size":e.typography.legendSize+"px"}:{},...null!=e.typography.titleFontSize?{"--semiotic-title-font-size":e.typography.titleFontSize+"px"}:{},...null!=e.typography.tickFontFamily?{"--semiotic-tick-font-family":e.typography.tickFontFamily}:{},...null!=e.typography.tickSize?{"--semiotic-tick-font-size":e.typography.tickSize+"px"}:{},...null!=e.typography.labelSize?{"--semiotic-axis-label-font-size":e.typography.labelSize+"px"}:{},"--semiotic-secondary":e.colors.secondary||e.colors.primary,"--semiotic-surface":e.colors.surface||e.colors.background,...e.colors.success?{"--semiotic-success":e.colors.success}:{},...e.colors.danger?{"--semiotic-danger":e.colors.danger}:{},...e.colors.warning?{"--semiotic-warning":e.colors.warning}:{},...e.colors.error?{"--semiotic-error":e.colors.error}:{},...e.colors.info?{"--semiotic-info":e.colors.info}:{}},i=f.useContext(y),r={};return i&&(r["data-semiotic-theme"]=i),h("div",{style:t,...r,children:o})}function k({theme:o,children:c}){const s="string"==typeof o&&r(o)?o:void 0,l=f.useMemo(()=>function(o){return void 0!==o?n(t,w(o)):"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(forced-colors: active)").matches?e:t}(o),[o]);return h(i,{initialState:{theme:l},children:p(y.Provider,{value:s,children:[h(v,{theme:o}),h(b,{children:c})]})})}function x(){return c(o=>o.theme)}export{u as useReducedMotion,m as useHighContrast,k as ThemeProviderWrapper,x as useTheme};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{buildColorStopGradient as t,resolveCSSColor as e,resolveCanvasFill as l,resolveCurveFactory as n}from"./chunk-chunk-6HSGDMTA.module.min.js";import{line as o}from"d3-shape";function i(t,e,l){let n=l;for(const l of e)"lesser"===l.thresholdType?l.value>t&&(n=l.color):t>l.value&&(n=l.color);return n}function s(t,e,l,n,o,i){if(2>e.length)return;const s=[0];for(let t=1;e.length>t;t++){const l=e[t][0]-e[t-1][0],n=e[t][1]-e[t-1][1];s.push(s[t-1]+Math.sqrt(l*l+n*n))}const a=s[s.length-1];if(0===a)return;const h=Math.min(.2*a,40);t.strokeStyle=l,t.lineWidth=n,t.lineCap=i;for(let l=0;e.length-1>l;l++){const n=(s[l]+s[l+1])/2;let i=o;h>n&&(i*=n/h),h>a-n&&(i*=(a-n)/h),t.globalAlpha=Math.max(0,i),t.beginPath(),t.moveTo(e[l][0],e[l][1]),t.lineTo(e[l+1][0],e[l+1][1]),t.stroke()}}var a=(a,h,r,p)=>{const c=h.filter(t=>"line"===t.type);for(const h of c){if(2>h.path.length)continue;const r=h._introClipFraction;void 0!==r&&1>r&&(a.save(),a.beginPath(),a.rect(0,0,p.width*r,p.height),a.clip());const c=h.style.stroke||"#007bff",f=e(a,c)||c,u=h.style.strokeWidth||2,y=h.colorThresholds,g=h.rawValues;if(a.setLineDash(h.style.strokeDasharray?h.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=h.style.opacity&&(a.globalAlpha=h.style.opacity),a.lineWidth=u,a.lineCap=h.style.strokeLinecap||"butt",h.style._edgeFade){s(a,h.path,f,u,h.style.opacity??1,h.style.strokeLinecap||"butt"),a.globalAlpha=1,a.setLineDash([]),a.lineCap="butt";continue}const k=n(h.curve),b=y&&y.length>0&&g&&g.length===h.path.length,d=h._decayOpacities;if(d&&d.length===h.path.length&&!b){a.strokeStyle=f;const t=h.style.opacity??1;for(let e=0;h.path.length-1>e;e++)a.globalAlpha=.5*(d[e]+d[e+1])*t,a.beginPath(),a.moveTo(h.path[e][0],h.path[e][1]),a.lineTo(h.path[e+1][0],h.path[e+1][1]),a.stroke()}else if(b){let t=function(t,e,l){a.beginPath(),a.strokeStyle=t,a.moveTo(e,l),r=!0},e=function(){r&&(a.stroke(),r=!1)},l=null,n=null,o=null,s=null,r=!1;for(let r=0;h.path.length>r;r++){const[p,c]=h.path[r],u=g[r],k=i(u,y,f);if(null!==l&&null!==s&&null!==o){if(k===s)a.lineTo(p,c);else{const s=[];for(const t of y){const e=t.value;(o>e||e>u)&&(e>o||u>e)||o===e||u===e||s.push({t:(e-o)/(u-o)})}s.sort((t,e)=>t.t-e.t);for(const h of s){const s=l+(p-l)*h.t,r=n+(c-n)*h.t,g=i(o+(u-o)*Math.min(h.t+1e-4,1),y,f);a.lineTo(s,r),e(),t(g,s,r)}a.lineTo(p,c)}l=p,n=c,o=u,s=k}else t(k,p,c),l=p,n=c,o=u,s=k}e()}else{a.beginPath();const e=h.strokeGradient&&h.path.length>=2?t(a,h.strokeGradient,h.path[0][0],0,h.path[h.path.length-1][0],0):null;if(a.strokeStyle=e||f,k)o().x(t=>t[0]).y(t=>t[1]).curve(k).context(a)(h.path);else{const[t,e]=h.path[0];a.moveTo(t,e);for(let t=1;h.path.length>t;t++)a.lineTo(h.path[t][0],h.path[t][1])}a.stroke()}if(h.style.fill&&h.style.fillOpacity&&h.style.fillOpacity>0){if(a.beginPath(),a.globalAlpha=h.style.fillOpacity,a.fillStyle=l(a,h.style.fill,h.style.fill),k&&!b)o().x(t=>t[0]).y(t=>t[1]).curve(k).context(a)(h.path);else{const[t,e]=h.path[0];a.moveTo(t,e);for(let t=1;h.path.length>t;t++)a.lineTo(h.path[t][0],h.path[t][1])}const t=h.path[0][0];a.lineTo(h.path[h.path.length-1][0],p.height),a.lineTo(t,p.height),a.closePath(),a.fill()}void 0!==r&&1>r&&a.restore(),a.globalAlpha=1,a.setLineDash([]),a.lineCap="butt"}};function h(t){if(!t)return null;if("heatcell"===t.type)return t.fill||null;if("candlestick"===t.type)return t.isUp?t.upColor:t.downColor;const{style:e}=t;if(!e)return null;const l="string"==typeof e.fill?e.fill:null;return"line"===t.type||"area"===t.type?e.stroke||l||null:l||e.stroke||null}export{a as lineCanvasRenderer,h as resolveNodeColor};