semiotic 3.8.1 → 3.8.2

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 (147) hide show
  1. package/CLAUDE.md +3 -1
  2. package/README.md +53 -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-27HVVXS6.module.min.js +1 -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-2UN3ANRN.module.min.js +2 -0
  16. package/dist/chunk-chunk-2VUEY5TH.module.min.js +1 -0
  17. package/dist/chunk-chunk-2WVCH4PL.module.min.js +1 -0
  18. package/dist/chunk-chunk-5UKL5W76.module.min.js +2 -0
  19. package/dist/chunk-chunk-5WEFWNUW.module.min.js +2 -0
  20. package/dist/chunk-chunk-6F6GEAQU.module.min.js +1 -0
  21. package/dist/chunk-chunk-7LHMKRKE.module.min.js +2 -0
  22. package/dist/chunk-chunk-BHYTYMY2.module.min.js +2 -0
  23. package/dist/chunk-chunk-C6EJ4IOD.module.min.js +2 -0
  24. package/dist/chunk-chunk-CA3YDW6F.module.min.js +1 -0
  25. package/dist/chunk-chunk-CP3EN6KZ.module.min.js +1 -0
  26. package/dist/chunk-chunk-CYIML3AV.module.min.js +2 -0
  27. package/dist/chunk-chunk-DNY43POY.module.min.js +1 -0
  28. package/dist/chunk-chunk-DSNGDNJY.module.min.js +1 -0
  29. package/dist/chunk-chunk-E7MIQX7D.module.min.js +2 -0
  30. package/dist/chunk-chunk-EMO5NUGE.module.min.js +1 -0
  31. package/dist/chunk-chunk-ES4DCG3L.module.min.js +1 -0
  32. package/dist/chunk-chunk-FAKO3RGQ.module.min.js +2 -0
  33. package/dist/chunk-chunk-FYY2ACNJ.module.min.js +2 -0
  34. package/dist/chunk-chunk-G7WFWHAD.module.min.js +2 -0
  35. package/dist/chunk-chunk-GMQ5AYTD.module.min.js +1 -0
  36. package/dist/chunk-chunk-H4PPRW6N.module.min.js +1 -0
  37. package/dist/chunk-chunk-IFYPMWKY.module.min.js +1 -0
  38. package/dist/chunk-chunk-J3ELI22J.module.min.js +1 -0
  39. package/dist/chunk-chunk-J3QOW4OE.module.min.js +0 -0
  40. package/dist/chunk-chunk-J3XWETBJ.module.min.js +2 -0
  41. package/dist/chunk-chunk-JCG72SGW.module.min.js +2 -0
  42. package/dist/{semiotic-ai-chunk-OG7BQUUW.module.min.js → chunk-chunk-JJ2OOIET.module.min.js} +0 -1
  43. package/dist/chunk-chunk-KTWEBFMX.module.min.js +2 -0
  44. package/dist/chunk-chunk-L6D3I3V7.module.min.js +2 -0
  45. package/dist/chunk-chunk-M337NY6L.module.min.js +1 -0
  46. package/dist/chunk-chunk-NO4MCQVD.module.min.js +1 -0
  47. package/dist/chunk-chunk-ODUZEEBH.module.min.js +2 -0
  48. package/dist/chunk-chunk-P6UBCMSQ.module.min.js +2 -0
  49. package/dist/chunk-chunk-Q2YADC2V.module.min.js +2 -0
  50. package/dist/chunk-chunk-QRIBHZYW.module.min.js +1 -0
  51. package/dist/chunk-chunk-QSQVBIJA.module.min.js +1 -0
  52. package/dist/chunk-chunk-RCF52Z42.module.min.js +2 -0
  53. package/dist/chunk-chunk-RH5TSQPH.module.min.js +1 -0
  54. package/dist/chunk-chunk-ROP4HI7H.module.min.js +2 -0
  55. package/dist/chunk-chunk-RZH7VZYS.module.min.js +2 -0
  56. package/dist/chunk-chunk-SIRIJ3DY.module.min.js +1 -0
  57. package/dist/chunk-chunk-STZFFTAN.module.min.js +2 -0
  58. package/dist/chunk-chunk-SV4XAZ3Q.module.min.js +1 -0
  59. package/dist/chunk-chunk-T27ZEV6A.module.min.js +1 -0
  60. package/dist/chunk-chunk-U3AGQ5EF.module.min.js +2 -0
  61. package/dist/chunk-chunk-U66USBWU.module.min.js +1 -0
  62. package/dist/chunk-chunk-VVCA3DB7.module.min.js +1 -0
  63. package/dist/chunk-chunk-W3DB2MN4.module.min.js +2 -0
  64. package/dist/chunk-chunk-WCX6U47H.module.min.js +2 -0
  65. package/dist/chunk-chunk-WDIN4LRC.module.min.js +1 -0
  66. package/dist/chunk-chunk-XEVJDUTH.module.min.js +1 -0
  67. package/dist/chunk-chunk-XOYX77KF.module.min.js +2 -0
  68. package/dist/chunk-chunk-YCQYG6J5.module.min.js +2 -0
  69. package/dist/chunk-chunk-YHNZCPOZ.module.min.js +2 -0
  70. package/dist/chunk-chunk-YWZB3KPI.module.min.js +2 -0
  71. package/dist/chunk-chunk-Z5KXAVQD.module.min.js +2 -0
  72. package/dist/chunk-chunk-ZCNBUZPL.module.min.js +2 -0
  73. package/dist/chunk-chunk-ZLKRTF5N.module.min.js +2 -0
  74. package/dist/chunk-chunk-ZTNVDWAK.module.min.js +2 -0
  75. package/dist/chunk-statisticalOverlays-6MVAK5RW.module.min.js +2 -0
  76. package/dist/components/charts/physics/PhysicalFlowChart.d.ts +7 -0
  77. package/dist/components/charts/shared/auditAccessibilityText.d.ts +13 -0
  78. package/dist/components/server/staticSVGChrome.d.ts +3 -2
  79. package/dist/components/stream/OrdinalBrushOverlay.d.ts +1 -2
  80. package/dist/components/stream/OrdinalBrushOverlayLazy.d.ts +9 -0
  81. package/dist/components/stream/XYBrushOverlayLazy.d.ts +17 -0
  82. package/dist/controls.min.js +1 -1
  83. package/dist/controls.module.min.js +1 -1
  84. package/dist/geo.min.js +1 -1
  85. package/dist/geo.module.min.js +1 -1
  86. package/dist/network.min.js +1 -1
  87. package/dist/network.module.min.js +1 -1
  88. package/dist/ordinal.min.js +1 -1
  89. package/dist/ordinal.module.min.js +1 -1
  90. package/dist/physics-matter.min.js +1 -1
  91. package/dist/physics-matter.module.min.js +1 -1
  92. package/dist/physics-rapier.min.js +1 -1
  93. package/dist/physics-rapier.module.min.js +1 -1
  94. package/dist/physics.min.js +1 -1
  95. package/dist/physics.module.min.js +1 -1
  96. package/dist/realtime.min.js +1 -1
  97. package/dist/realtime.module.min.js +1 -1
  98. package/dist/rough.min.js +1 -1
  99. package/dist/rough.module.min.js +1 -1
  100. package/dist/semiotic-ai-core.min.js +1 -1
  101. package/dist/semiotic-ai-core.module.min.js +1 -1
  102. package/dist/semiotic-ai.min.js +1 -1
  103. package/dist/semiotic-ai.module.min.js +1 -1
  104. package/dist/semiotic-data.min.js +1 -1
  105. package/dist/semiotic-data.module.min.js +1 -1
  106. package/dist/semiotic-experimental.min.js +1 -1
  107. package/dist/semiotic-experimental.module.min.js +1 -1
  108. package/dist/semiotic-realtime-core.min.js +1 -1
  109. package/dist/semiotic-realtime-core.module.min.js +1 -1
  110. package/dist/semiotic-realtime-react.min.js +1 -1
  111. package/dist/semiotic-realtime-react.module.min.js +1 -1
  112. package/dist/semiotic-recipes-core.min.js +1 -1
  113. package/dist/semiotic-recipes-core.module.min.js +1 -1
  114. package/dist/semiotic-recipes-react.min.js +1 -1
  115. package/dist/semiotic-recipes-react.module.min.js +1 -1
  116. package/dist/semiotic-recipes.min.js +1 -1
  117. package/dist/semiotic-recipes.module.min.js +1 -1
  118. package/dist/semiotic-server-edge.min.js +1 -1
  119. package/dist/semiotic-server-edge.module.min.js +1 -1
  120. package/dist/semiotic-server-node.min.js +1 -1
  121. package/dist/semiotic-server-node.module.min.js +1 -1
  122. package/dist/semiotic-themes-core.min.js +1 -1
  123. package/dist/semiotic-themes-core.module.min.js +1 -1
  124. package/dist/semiotic-themes-react.min.js +1 -1
  125. package/dist/semiotic-themes-react.module.min.js +1 -1
  126. package/dist/semiotic-themes.min.js +1 -1
  127. package/dist/semiotic-themes.module.min.js +1 -1
  128. package/dist/semiotic-utils-core.min.js +1 -1
  129. package/dist/semiotic-utils-core.module.min.js +1 -1
  130. package/dist/semiotic-utils-react.min.js +1 -1
  131. package/dist/semiotic-utils-react.module.min.js +1 -1
  132. package/dist/semiotic-utils.min.js +1 -1
  133. package/dist/semiotic-utils.module.min.js +1 -1
  134. package/dist/semiotic-value.min.js +1 -1
  135. package/dist/semiotic-value.module.min.js +1 -1
  136. package/dist/semiotic.min.js +1 -1
  137. package/dist/semiotic.module.min.js +1 -1
  138. package/dist/server.min.js +1 -1
  139. package/dist/server.module.min.js +1 -1
  140. package/dist/xy.min.js +1 -1
  141. package/dist/xy.module.min.js +1 -1
  142. package/package.json +4 -4
  143. package/dist/semiotic-ai-statisticalOverlays-CY4WKR4A.module.min.js +0 -2
  144. package/dist/semiotic-chunk-3FSVZ46U.module.min.js +0 -2
  145. package/dist/semiotic-statisticalOverlays-UOMSFKVJ.module.min.js +0 -2
  146. package/dist/xy-chunk-IWD6IB6V.module.min.js +0 -2
  147. package/dist/xy-statisticalOverlays-7RWG6LJT.module.min.js +0 -2
@@ -0,0 +1 @@
1
+ import{mulberry32 as t}from"./chunk-chunk-SIRIJ3DY.module.min.js";import{UpdateResultTracker as e}from"./chunk-chunk-NO4MCQVD.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 D(t,e){if(null!=t[e])return t[e];const i=t.datum;return i&&"object"==typeof i?i[e]:void 0}function A(t,e,i){return"function"==typeof t?t(e,i):"string"==typeof t?D(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(A(this.config.binAccessor,t,e))??function(t){for(const e of O){const i=R(D(t,e));if(i)return i}return"sediment"}(t),s=R(A(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?D(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},N={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function j(t={},e=N){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=j(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=j(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,D=C.x1,A=(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(D>=t)return"top"===i?b:v;const s=It((t-D)/Math.max(1,a-D),0,1);return"top"===i?b+(d-b)*s:v+(h-v)*s},R=q.map(t=>{const e=Math.min(A(t.x0,"top"),A(t.x1,"top")),i=Math.max(A(t.x0,"bottom"),A(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,D,b,Y),Mt(g+"-center-bottom",T,v,D,v,Y),Mt(g+"-right-top",D,b,a,d,Y),Mt(g+"-right-bottom",D,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}}),N=!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:D,pinchHeight:y,pinchTop:b,pinchBottom:v,stages:R,membranes:X,colliders:E,regionEffects:N,boundaryY:A}}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 Dt(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 At(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,Dt as pressureFieldRegion,At as capacitatedRegion,Rt as portalRegion,Yt as absorbRegion,Et as forceFieldRegion,Ft as bodyGroupSpec,Pt as processLaneWalls};
@@ -0,0 +1 @@
1
+ import{createContext as e,useCallback as o,useContext as r,useMemo as a,useRef as t,useSyncExternalStore as i}from"react";import{jsx as c}from"react/jsx-runtime";function n(n){let l=null;const f=()=>(l||(l=e(null)),l),d=s(n);return[function({children:e,initialState:o}){const r=t(o),i=a(()=>s(n,r.current),[]),l=f();return c(l.Provider,{value:i,children:e})},(e,a)=>{const c=f(),n=r(c)??d,s=t(e);s.current=e;const l=t({hasValue:!1,value:void 0}),u=o(()=>{const e=s.current(n.getState()),o=l.current;return o.hasValue&&a&&a(o.value,e)?o.value:(l.current={hasValue:!0,value:e},e)},[n,a]),p=o(()=>s.current(n.getState()),[n]);return i(n.subscribe,u,p)}]}function s(e,o){const r=new Set;let a={...e(function(e){const o=e(a);if(function(e){for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o))return!0;return!1}(o)){a={...a,...o};for(const e of r)e()}}),...o??{}};return{getState:()=>a,subscribe:function(e){return r.add(e),()=>{r.delete(e)}}}}function l(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:d}}),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 d=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],u={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}},p={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}},g={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:d,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function y(e,o){if("light"===o)return u;if("dark"===o)return p;if("high-contrast"===o)return g;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?p:u;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[b,m]=n(e=>({theme:u,setTheme(o){e(e=>({theme:y(e.theme,o)}))}}));function h(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 x(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 $=/^\{([^}]+)\}$/,S={bg:"background",text:"text","text-secondary":"textSecondary",grid:"grid",border:"border",primary:"primary",focus:"focus",secondary:"secondary",surface:"surface",annotation:"annotation",success:"success",danger:"danger",warning:"warning",error:"error",info:"info"},k=[["textSecondary",/^(text-?secondary|secondary-?text|muted|subtle|text-?muted|fg-?muted)$/],["text",/^(text|foreground|fg|ink|on-?background|on-?surface|text-?default|fg-?default)$/],["background",/^(background|bg|canvas|base|page|backdrop|bg-?default)$/],["surface",/^(surface|card|elevated|panel|sheet)$/],["border",/^(border|divider|outline|stroke|hairline)$/],["grid",/^(grid|gridline|gridlines)$/],["primary",/^(primary|brand|accent|brand-?primary)$/],["secondary",/^(secondary|brand-?secondary)$/],["focus",/^(focus|ring|focus-?ring)$/],["error",/^(error|critical)$/],["danger",/^(danger|negative|destructive|fail|alert)$/],["success",/^(success|positive|ok|good|pass)$/],["warning",/^(warning|warn|caution)$/],["info",/^(info|information|note)$/],["annotation",/^(annotation|callout)$/]],v=/^rgba?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)(?:\s*,\s*[\d.]+)?\s*\)$/i;function z(e){return"string"==typeof e.value&&("color"===e.type||function(e){const o=e.trim();return/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(o)||v.test(o)||/^hsla?\(/i.test(o)}(e.value))}function w(e,o={}){const r=function(e){const o=new Map(e.map(e=>[e.path,e])),r=(e,a)=>{if(a>8||"string"!=typeof e)return e;const t=e.match($);if(!t)return e;const i=o.get(t[1]);return i?r(i.value,a+1):e};return e.map(e=>({...e,value:r(e.value,0)}))}(function(e){const o=[],r=(e,a,t)=>{if(!e||"object"!=typeof e)return;const i=e,c=i.$type??t;if(function(e){return!!e&&"object"==typeof e&&"$value"in e}(i))o.push({path:a.join("."),leaf:a[a.length-1]??"",value:i.$value,type:i.$type??t});else for(const[e,o]of Object.entries(i))e.startsWith("$")||r(o,[...a,e],c)};return r(e,[]),o}(e)),a=new Map(r.map(e=>[e.path,e])),t=new Set,i={};for(const[e,r]of Object.entries(o.mapping??{})){if("fontFamily"===e||"categorical"===e)continue;const o=r?a.get(r):void 0;o&&"string"==typeof o.value&&(i[e]=o.value,t.add(o.path))}for(const e of r){const o=e.path.match(/^semiotic\.([^.]+)$/),r=o?S[o[1]]:void 0;r&&!(r in i)&&"string"==typeof e.value&&(i[r]=e.value,t.add(e.path))}for(const[e,o]of k){if(e in i)continue;const a=r.find(e=>!t.has(e.path)&&z(e)&&o.test(e.leaf.toLowerCase()));a&&"string"==typeof a.value&&(i[e]=a.value,t.add(a.path))}let c;const n=o.mapping?.categorical,s=(n?a.get(n):void 0)??a.get("semiotic.categorical")??r.find(e=>Array.isArray(e.value)&&/categor|chart|palette|qualitative|series/i.test(e.path));if(s&&Array.isArray(s.value))c=s.value.filter(e=>"string"==typeof e);else{const e=r.filter(e=>z(e)&&/(^|\.)(categorical|chart|palette|qualitative|series)\b/i.test(e.path));2>e.length||(c=e.map(e=>e.value))}const l=(o.mapping?.fontFamily?a.get(o.mapping.fontFamily):void 0)??a.get("semiotic.font-family")??r.find(e=>("fontFamily"===e.type||/font-?family|typeface/i.test(e.leaf))&&("string"==typeof e.value||Array.isArray(e.value))),f=l?Array.isArray(l.value)?l.value.join(", "):"string"==typeof l.value?l.value:void 0:void 0,d=function(e){if("string"!=typeof e)return null;const o=e.trim();let r=o.replace(/^#/,"");if(3===r.length&&(r=r.split("").map(e=>e+e).join("")),/^[0-9a-f]{6}$/i.test(r))return parseInt(r.slice(0,2),16)/255*.2126+parseInt(r.slice(2,4),16)/255*.7152+parseInt(r.slice(4,6),16)/255*.0722;const a=o.match(v);if(a){const e=Number(a[1])/255,o=Number(a[2])/255,r=Number(a[3])/255;return[e,o,r].some(e=>Number.isNaN(e)||0>e||e>1)?null:.2126*e+.7152*o+.0722*r}return null}(i.background),g=o.base?.mode??(null!=d?.5>d?"dark":"light":u.mode),y=o.base??("dark"===g?p:u);return{...y,mode:g,colors:{...y.colors,...i,...c&&c.length>0?{categorical:c}:{}},typography:{...y.typography,...f?{fontFamily:f}:{}}}}var F={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"},R={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"},q={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"},N={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"},A={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"},j={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"},B={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"},O={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"},C={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"},I={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"},M={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"},H={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"},P=["#6929c4","#1192e8","#005d5d","#9f1853","#fa4d56","#570408","#198038","#002d9c","#ee538b","#b28600","#009d9a","#012749","#8a3800","#a56eff"],E={danger:"#da1e28",warning:"#f1c21b",success:"#24a148",info:"#0043ce"},G={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"},T={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"},L={light:u,dark:p,"high-contrast":g,pastels:F,"pastels-dark":R,"bi-tool":q,"bi-tool-dark":N,italian:A,"italian-dark":j,tufte:B,"tufte-dark":O,journalist:C,"journalist-dark":I,playful:M,"playful-dark":H,carbon:G,"carbon-dark":T};function U(e){return L[e]}export{n as createStore,l as resolveThemeSemanticColors,f as applyThemeAccessibility,d as COLOR_BLIND_SAFE_CATEGORICAL,u as LIGHT_THEME,p as DARK_THEME,g as HIGH_CONTRAST_THEME,y as resolveThemeUpdate,b as ThemeProvider,m as useThemeSelector,h as themeToCSS,x as themeToTokens,w as designTokensToTheme,F as PASTELS_LIGHT,R as PASTELS_DARK,q as BI_TOOL_LIGHT,N as BI_TOOL_DARK,A as ITALIAN_LIGHT,j as ITALIAN_DARK,B as TUFTE_LIGHT,O as TUFTE_DARK,C as JOURNALIST_LIGHT,I as JOURNALIST_DARK,M as PLAYFUL_LIGHT,H as PLAYFUL_DARK,P as CARBON_CATEGORICAL_14,E as CARBON_ALERT,G as CARBON_LIGHT,T as CARBON_DARK,L as THEME_PRESETS,U as resolveThemePreset};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{validateNetworkData as e,validateObjectData as t}from"./chunk-chunk-JCG72SGW.module.min.js";import{mergeShapeStyle as o,useCustomChartScaffold as n,useFrameImperativeHandle as i,useResolvedSelection as r}from"./chunk-chunk-BHYTYMY2.module.min.js";import{StreamNetworkFrame_default as s,buildRibbonGeometry as a}from"./chunk-chunk-2UN3ANRN.module.min.js";import{buildBaseMetadataProps as l,buildCustomBehaviorProps as c}from"./chunk-chunk-FAKO3RGQ.module.min.js";import{mulberry32 as d}from"./chunk-chunk-SIRIJ3DY.module.min.js";import{composeStyleRules as m,makeNodeRuleContext as h}from"./chunk-chunk-EMO5NUGE.module.min.js";import{COLOR_SCHEMES as g,DEFAULT_COLORS as u,DEFAULT_SELECTION_OPACITY as f,DEPTH_PALETTE_COLORS as p,filterSparseArray as b,getColor as y,normalizeTooltip as v,resolveDefaultFill as k,resolveMobileInteraction as S,useChartLegendAndMargin as w,useChartMode as C,useChartSelection as T,useColorScale as A,useLegendInteraction as I,useThemeCategorical as M}from"./chunk-chunk-ODUZEEBH.module.min.js";import{getMin as H}from"./chunk-chunk-JJ2OOIET.module.min.js";import{ChartError as x,SafeRender as B,renderEmptyState as N,renderLoadingState as O}from"./chunk-chunk-ZCNBUZPL.module.min.js";import{forwardRef as D,useMemo as P}from"react";import{jsx as L}from"react/jsx-runtime";var E=D(function(e,t){const{nodes:o,edges:i,layout:r,layoutConfig:a,onLayoutError:d,nodeIDAccessor:m="id",sourceAccessor:h="source",targetAccessor:g="target",margin:u,className:f,colorBy:p,colorScheme:y,selection:v,linkedHover:k,onObservation:w,onClick:C,chartId:A,annotations:I,autoPlaceAnnotations:M,frameProps:H={}}=e,{frameRef:x,resolved:D,normalizedMargin:E}=n({imperativeRef:t,imperativeVariant:"network",margin:u,width:e.width,height:e.height,enableHover:e.enableHover,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),W=P(()=>b(o),[o]),R=P(()=>b(i),[i]),z=P(()=>void 0===o&&void 0===i?void 0:[...W,...R],[i,o,R,W]),F=S(e.mobileInteraction,{mode:e.mode,width:D.width,mobileSemantics:e.mobileSemantics}),{customHoverBehavior:j,customClickBehavior:$,activeSelectionHook:_}=T({selection:v,linkedHover:k,fallbackFields:"string"==typeof p?[p]:[],onObservation:w,onClick:C,chartType:"NetworkCustomChart",chartId:A,colorByField:"string"==typeof p?p:void 0,mobileInteraction:F}),G=P(()=>_?.isActive?{isActive:!0,predicate:_.predicate}:null,[_?.isActive,_?.predicate]),{width:q,height:Y,enableHover:Z,title:J,description:U,summary:X,accessibleTable:K}=D,Q=O(e.loading,q,Y,e.loadingContent),V=Q?null:N(z,q,Y,e.emptyContent);if(Q||V)return Q||V;const ee={chartType:"force",...null!=o&&{nodes:W},...null!=i&&{edges:R},customNetworkLayout:r,layoutConfig:a,onLayoutError:d,nodeIDAccessor:m,sourceAccessor:h,targetAccessor:g,colorBy:p,colorScheme:y,size:[q,Y],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:E,enableHover:Z,...l({title:J,description:U,summary:X,accessibleTable:K,className:f,animate:e.animate,autoPlaceAnnotations:M}),...c({linkedHover:k,selection:v,onObservation:w,onClick:C,mobileInteraction:F,customHoverBehavior:j,customClickBehavior:$,linkedHoverInClickPredicate:!1}),layoutSelection:G,...null!=I&&{annotations:I},...H};return L(B,{componentName:"NetworkCustomChart",width:q,height:Y,children:L(s,{ref:x,...ee})})});E.displayName="NetworkCustomChart";import{useMemo as W,forwardRef as R,useRef as z}from"react";import{useMemo as F}from"react";function j(e,t){if(!e)return[];const o=[],n=e=>{o.push(e);const i="function"==typeof t?t(e):e[t];i&&Array.isArray(i)&&i.forEach(n)};return n(e),o}function $(e,t,o,n){if(e&&e.length>0)return e;const i=new Set;return t.forEach(e=>{const t="function"==typeof o?o(e):e[o],r="function"==typeof n?n(e):e[n];i.add(t),i.add(r)}),Array.from(i).map(e=>({id:e}))}function _(e){return"function"==typeof e?e:t=>t[e]||1}function G({edgeColorBy:e,colorBy:t,colorScale:o,nodeStyleFn:n,edgeOpacity:i,baseStyle:r={}}){return s=>{const a={fillOpacity:i,...r};if("function"==typeof e)a.fill=e(s);else if("source"===e){const e="object"==typeof s.source?s.source:null;t&&e?a.fill=y(e.data||e,t,o):e&&(a.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof s.target?s.target:null;t&&e?a.fill=y(e.data||e,t,o):e&&(a.fill=n(e,e.index).fill)}else"gradient"===e&&(a.fill="#999",a.fillOpacity=.7*i);return a}}function q(e){const{nodes:t,edges:o,inferNodes:n=!0,sourceAccessor:i="source",targetAccessor:r="target",colorBy:s,colorScheme:a,showLegend:l,legendPosition:c,legendInteraction:d,selection:m,linkedHover:h,onObservation:f,onClick:p,mobileInteraction:y,mobileSemantics:v,chartType:k,chartId:C,marginDefaults:H,userMargin:x,width:B,height:D,loading:P,loadingContent:L,emptyContent:E,emptyDataKey:W="edges"}=e,R=F(()=>b(o),[o]),z=F(()=>b(t),[t]),j=O(P,B,D,L),_=j?null:N("nodes"===W?void 0===t?void 0:z:void 0===o?void 0:R,B,D,E),G=F(()=>n?$(z,R,i,r):z,[n,z,R,i,r]),q=A(G,s,a),Y=M(),Z=F(()=>{if(Array.isArray(a))return a;if(Y&&Y.length>0)return Y;if("string"==typeof a){const e=g[a];if(Array.isArray(e)&&e.length>0)return e}return u},[a,Y]),J=F(()=>{if(!s)return[];const e=new Set;for(const t of G){const o="function"==typeof s?s(t):t[s];null!=o&&e.add(o+"")}return Array.from(e)},[G,s]),U=I(d,s,J),{legend:X,margin:K,legendPosition:Q}=w({data:G,colorBy:s,colorScale:q,showLegend:l,legendPosition:c,userMargin:x,defaults:H,categories:J}),V=F(()=>S(y,{width:B,mobileSemantics:v}),[y,B,v]),ee=T({selection:m,linkedHover:h,fallbackFields:s?["string"==typeof s?s:""]:[],unwrapData:!0,onObservation:f,onClick:p,mobileInteraction:V,chartType:k,chartId:C}),{customHoverBehavior:te,customClickBehavior:oe,activeSelectionHook:ne,hoverSelectionHook:ie,crosshairSourceId:re}=ee;return{safeNodes:G,safeEdges:R,colorScale:q,effectivePalette:Z,themeCategorical:Y,allCategories:J,legendState:U,legend:X,margin:K,legendPosition:Q,mobileInteraction:V,customHoverBehavior:te,customClickBehavior:oe,activeSelectionHook:ne,hoverSelectionHook:ie,crosshairSourceId:re,loadingEl:j,emptyEl:_}}import{jsx as Y}from"react/jsx-runtime";var Z=R(function(t,n){const r=z(null);i(n,{variant:"network",frameRef:r});const a=C(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLegend:t.showLegend,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules},{width:600,height:600}),{nodes:l,edges:d,margin:g,className:u,nodeIdAccessor:f,nodeIDAccessor:p,sourceAccessor:b="source",targetAccessor:S="target",nodeLabel:w,colorBy:T,colorScheme:A,styleRules:I,nodeSize:M=8,nodeSizeRange:H=[5,20],edgeWidth:N=1,edgeColor:O="#999",edgeOpacity:D=.6,iterations:P=300,forceStrength:L=.1,layoutExecution:E="auto",layoutLoadingContent:R,onLayoutStateChange:F,tooltip:j,frameProps:$={},onObservation:_,onClick:G,chartId:Z,selection:J,linkedHover:U,loading:X,loadingContent:K,emptyContent:Q,legendInteraction:V,legendPosition:ee,stroke:te,strokeWidth:oe,opacity:ne}=t,ie=f??p??"id",{width:re,height:se,enableHover:ae,showLegend:le,showLabels:ce=!1,title:de,description:me,summary:he,accessibleTable:ge}=a,ue=q({nodes:l,edges:d,inferNodes:!1,nodeIdAccessor:ie,sourceAccessor:b,targetAccessor:S,colorBy:T,colorScheme:A,showLegend:le,legendPosition:ee,legendInteraction:V,selection:J,linkedHover:U,onObservation:_,onClick:G,mobileInteraction:a.mobileInteraction,mobileSemantics:a.mobileSemantics,chartType:"ForceDirectedGraph",chartId:Z,marginDefaults:a.marginDefaults,userMargin:g,width:re,height:se,loading:X,loadingContent:K,emptyContent:Q,emptyDataKey:"nodes"}),fe=W(()=>new Map,[]),pe=W(()=>e=>{const t={};return t.fill=T?y(e.data||e,T,ue.colorScale):k(void 0,ue.themeCategorical,A,void 0,fe),"number"==typeof M&&(t.r=M),t},[T,ue.colorScale,M,ue.themeCategorical,A,fe]),be=W(()=>h(T,"number"==typeof M?void 0:M),[T,M]),ye=W(()=>o(m(pe,I,be,e=>e.data||e),{stroke:te,strokeWidth:oe,opacity:ne}),[pe,I,be,te,oe,ne]),ve=W(()=>e=>{const t=e.data||e;let o;if("number"==typeof N)o=N;else if("function"==typeof N)o=N(t);else{const e=t[N],n="number"==typeof e?e:Number(e);o=Number.isFinite(n)&&n>0?n:1}return{stroke:O,strokeWidth:o,opacity:D}},[N,O,D]),ke=W(()=>o(ve,{stroke:te,strokeWidth:oe,opacity:ne}),[ve,te,oe,ne]),Se=W(()=>{if(ce&&w)return"function"==typeof w?w:e=>e.data?.[w]??e[w]??e.id},[ce,w]),we=e({componentName:"ForceDirectedGraph",nodes:l,edges:d,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:ie}});return we?Y(x,{componentName:"ForceDirectedGraph",message:we,width:re,height:se}):ue.loadingEl?ue.loadingEl:ue.emptyEl?ue.emptyEl:Y(B,{componentName:"ForceDirectedGraph",width:re,height:se,children:Y(s,{ref:r,chartType:"force",...null!=l&&{nodes:ue.safeNodes},...null!=d&&{edges:ue.safeEdges},size:[re,se],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ue.margin,nodeIDAccessor:ie,sourceAccessor:b,targetAccessor:S,iterations:P,forceStrength:L,layoutExecution:E,layoutLoadingContent:R,onLayoutStateChange:F,nodeStyle:ye,edgeStyle:ke,colorBy:T,colorScheme:ue.effectivePalette,nodeSize:M,nodeSizeRange:H,nodeLabel:Se,showLabels:ce,enableHover:ae,tooltipContent:!1===j?()=>null:v(j)||void 0,...c({linkedHover:U,selection:J,onObservation:_,onClick:G,mobileInteraction:ue.mobileInteraction,customHoverBehavior:ue.customHoverBehavior,customClickBehavior:ue.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:ue.legend,legendPosition:ue.legendPosition,...V&&"none"!==V&&{legendHoverBehavior:ue.legendState.onLegendHover,legendClickBehavior:ue.legendState.onLegendClick,legendHighlightedCategory:ue.legendState.highlightedCategory,legendIsolatedCategories:ue.legendState.isolatedCategories},className:u,title:de,description:me,summary:he,accessibleTable:ge,...null!=t.animate&&{animate:t.animate},...$})})});Z.displayName="ForceDirectedGraph";import{useMemo as J,forwardRef as U,useRef as X}from"react";import{jsx as K}from"react/jsx-runtime";var Q=U(function(t,n){const r=X(null);i(n,{variant:"network",frameRef:r,overrides:{getData:()=>r.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const a=C(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules},{width:600,height:600}),{nodes:l,edges:d,margin:f,className:p,sourceAccessor:b="source",targetAccessor:S="target",valueAccessor:w="value",nodeIdAccessor:T="id",colorBy:A,colorScheme:I,styleRules:M,edgeColorBy:H="source",padAngle:N=.01,groupWidth:O=20,sortGroups:D,nodeLabel:P,edgeOpacity:L=.5,tooltip:E,frameProps:W={},onObservation:R,onClick:z,chartId:F,selection:j,linkedHover:$,loading:_,loadingContent:Y,emptyContent:Z,legendInteraction:U,stroke:Q,strokeWidth:V,opacity:ee}=t,{width:te,height:oe,enableHover:ne,showLabels:ie=!0,title:re,description:se,summary:ae,accessibleTable:le}=a,ce=q({nodes:l,edges:d,inferNodes:!0,nodeIdAccessor:T,sourceAccessor:b,targetAccessor:S,colorBy:A,colorScheme:I,showLegend:!1,legendInteraction:U,selection:j,linkedHover:$,onObservation:R,onClick:z,mobileInteraction:a.mobileInteraction,mobileSemantics:a.mobileSemantics,chartType:"ChordDiagram",chartId:F,marginDefaults:a.marginDefaults,userMargin:f,width:te,height:oe,loading:_,loadingContent:Y,emptyContent:Z}),de=J(()=>new Map,[]),me=ce.safeNodes.length>0,he=J(()=>{if(me)return(e,t)=>{const o={stroke:"black",strokeWidth:1};if(A)o.fill=y(e.data||e,A,ce.colorScale);else{const n=Array.isArray(I)?I:g[I]||u,i=Array.isArray(n)?n:u;o.fill=i[(e.index??t??0)%i.length]}return o}},[me,A,ce.colorScale,I]),ge=J(()=>h(A),[A]),ue=J(()=>{if(he||M&&M.length>0)return o(m(he,M,ge,e=>e.data||e),{stroke:Q,strokeWidth:V,opacity:ee})},[he,M,ge,Q,V,ee]),fe=J(()=>{if(me)return G({edgeColorBy:H,colorBy:A,colorScale:ce.colorScale,nodeStyleFn:ue||(e=>({fill:k(void 0,ce.themeCategorical,I,void 0,de)})),edgeOpacity:L,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:L}})},[me,H,A,ce.colorScale,ue,L,ce.themeCategorical,I,de]),pe=J(()=>fe?o(fe,{stroke:Q,strokeWidth:V,opacity:ee}):void 0,[fe,Q,V,ee]),be=J(()=>{if(!ie)return;const e=P||T;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[ie,P,T]),ye=e({componentName:"ChordDiagram",edges:d,edgesRequired:!0});return ye?K(x,{componentName:"ChordDiagram",message:ye,width:te,height:oe}):ce.loadingEl?ce.loadingEl:ce.emptyEl?ce.emptyEl:K(B,{componentName:"ChordDiagram",width:te,height:oe,children:K(s,{ref:r,chartType:"chord",...ce.safeNodes.length>0&&{nodes:ce.safeNodes},...null!=d&&{edges:ce.safeEdges},size:[te,oe],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:ce.margin,nodeIDAccessor:T,sourceAccessor:b,targetAccessor:S,valueAccessor:w,padAngle:N,groupWidth:O,sortGroups:D,nodeStyle:ue,edgeStyle:pe,colorBy:A,colorScheme:ce.effectivePalette,edgeColorBy:H,edgeOpacity:L,nodeLabel:be,showLabels:ie,enableHover:ne,tooltipContent:!1===E?()=>null:v(E)||void 0,...c({linkedHover:$,selection:j,onObservation:R,onClick:z,mobileInteraction:ce.mobileInteraction,customHoverBehavior:ce.customHoverBehavior,customClickBehavior:ce.customClickBehavior,linkedHoverInClickPredicate:!1}),...U&&"none"!==U&&{legendHoverBehavior:ce.legendState.onLegendHover,legendClickBehavior:ce.legendState.onLegendClick,legendHighlightedCategory:ce.legendState.highlightedCategory,legendIsolatedCategories:ce.legendState.isolatedCategories},className:p,title:re,description:se,summary:ae,accessibleTable:le,...null!=t.animate&&{animate:t.animate},...W})})});Q.displayName="ChordDiagram";import{useMemo as V,forwardRef as ee,useRef as te}from"react";import{jsx as oe}from"react/jsx-runtime";var ne=ee(function(t,n){const r=te(null);i(n,{variant:"network",frameRef:r,overrides:{getData:()=>r.current?.getTopology()?.edges?.map(e=>e.data)??[]}});const a=C(t.mode,{width:t.width,height:t.height,enableHover:t.enableHover,showLabels:t.showLabels,title:t.title,description:t.description,accessibleTable:t.accessibleTable,summary:t.summary,mobileInteraction:t.mobileInteraction,mobileSemantics:t.mobileSemantics,responsiveRules:t.responsiveRules},{width:800,height:600}),{nodes:l,edges:d,margin:g,className:u,sourceAccessor:f="source",targetAccessor:p="target",valueAccessor:b="value",nodeIdAccessor:S="id",colorBy:w,colorScheme:T,styleRules:A,edgeColorBy:I="source",orientation:M="horizontal",nodeAlign:H="justify",nodePaddingRatio:N=.05,nodeWidth:O=15,nodeLabel:D,edgeOpacity:P=.5,edgeSort:L,tooltip:E,frameProps:W={},onObservation:R,onClick:z,chartId:F,selection:j,linkedHover:$,loading:_,loadingContent:Y,emptyContent:Z,showLegend:J,legendPosition:U,legendInteraction:X,stroke:K,strokeWidth:Q,opacity:ee}=t,{width:ne,height:ie,enableHover:re,showLabels:se=!0,title:ae,description:le,summary:ce,accessibleTable:de}=a,me=q({nodes:l,edges:d,inferNodes:!0,nodeIdAccessor:S,sourceAccessor:f,targetAccessor:p,colorBy:w,colorScheme:T,showLegend:J,legendPosition:U,legendInteraction:X,selection:j,linkedHover:$,onObservation:R,onClick:z,mobileInteraction:a.mobileInteraction,mobileSemantics:a.mobileSemantics,chartType:"SankeyDiagram",chartId:F,marginDefaults:a.marginDefaults,userMargin:g,width:ne,height:ie,loading:_,loadingContent:Y,emptyContent:Z}),he=V(()=>new Map,[]),ge=V(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=w?y(e.data||e,w,me.colorScale):k(void 0,me.themeCategorical,T,void 0,he),t},[w,me.colorScale,me.themeCategorical,T,he]),ue=V(()=>h(w,b),[w,b]),fe=V(()=>o(m(ge,A,ue,e=>e.data||e),{stroke:K,strokeWidth:Q,opacity:ee}),[ge,A,ue,K,Q,ee]),pe=V(()=>G({edgeColorBy:I,colorBy:w,colorScale:me.colorScale,nodeStyleFn:fe,edgeOpacity:P,baseStyle:{stroke:"none",strokeWidth:0}}),[I,w,me.colorScale,fe,P]),be=V(()=>o(pe,{stroke:K,strokeWidth:Q,opacity:ee}),[pe,K,Q,ee]),ye=V(()=>{if(!se)return;const e=D||S;return"function"==typeof e?e:t=>t.data?.[e]??t[e]??t.id},[se,D,S]),ve=e({componentName:"SankeyDiagram",edges:d,edgesRequired:!0});return ve?oe(x,{componentName:"SankeyDiagram",message:ve,width:ne,height:ie}):me.loadingEl?me.loadingEl:me.emptyEl?me.emptyEl:oe(B,{componentName:"SankeyDiagram",width:ne,height:ie,children:oe(s,{ref:r,chartType:"sankey",...me.safeNodes.length>0&&{nodes:me.safeNodes},...null!=d&&{edges:me.safeEdges},size:[ne,ie],responsiveWidth:t.responsiveWidth,responsiveHeight:t.responsiveHeight,margin:me.margin,nodeIDAccessor:S,sourceAccessor:f,targetAccessor:p,valueAccessor:b,orientation:M,nodeAlign:H,nodePaddingRatio:N,nodeWidth:O,nodeStyle:fe,edgeStyle:be,colorBy:w,colorScheme:me.effectivePalette,edgeColorBy:I,edgeOpacity:P,edgeSort:L,nodeLabel:ye,showLabels:se,enableHover:re,tooltipContent:!1===E?()=>null:v(E)||void 0,...c({linkedHover:$,selection:j,onObservation:R,onClick:z,mobileInteraction:me.mobileInteraction,customHoverBehavior:me.customHoverBehavior,customClickBehavior:me.customClickBehavior,linkedHoverInClickPredicate:!1}),legend:me.legend,legendPosition:me.legendPosition,...X&&"none"!==X&&{legendHoverBehavior:me.legendState.onLegendHover,legendClickBehavior:me.legendState.onLegendClick,legendHighlightedCategory:me.legendState.highlightedCategory,legendIsolatedCategories:me.legendState.isolatedCategories},className:u,title:ae,description:le,summary:ce,accessibleTable:de,...null!=t.animate&&{animate:t.animate},...W})})});function ie(e,t,o){const n=[],i=new Set(e.map(e=>e.id)),r=Array.isArray(o)&&2===o.length,s=r&&Number.isFinite(o[0])&&Number.isFinite(o[1]);r&&s&&s&&o[1]>=o[0]||n.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||n.push({kind:"invalid-node-time",id:t.id}));for(const e of t)i.has(e.source)||n.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),i.has(e.target)||n.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||n.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||n.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):n.push({kind:"invalid-edge-time",id:e.id});return n}function re(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:e.kind}function se(e,t,o){const n=t.incoming[e.id],i=t.outgoing[e.id],r=[];for(const e of n)r.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:o.get(e.id).targetSide});for(const e of i)r.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:o.get(e.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{r.sort((e,t)=>e.time-t.time||(s[e.kind]??99)-(s[t.kind]??99))},l=r.length?H(r.map(e=>e.time)):null,c=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,d=null!=c?c-1:null!=l&&Number.isFinite(l)?l-1:null,m=[...new Set(r.map(e=>e.time))].sort((e,t)=>e-t),h=new Map;for(let e=1;m.length>e;e++)h.set(m[e],m[e-1]);const g=e=>{const t=h.get(e);return null!=t?(t+e)/2:null!=d?d:e};a();const u=[];let f=0,p=0;for(const e of r)if("out"===e.kind){const t=Math.abs(e.delta);let o=t-("top"===e.side?f:p);if(o>0){const t="top"===e.side?"bot":"top",n=Math.min(o,"top"===t?f:p);if(n>0){const i=g(e.time);u.push({time:i,delta:-n,kind:"transfer-out",side:t}),u.push({time:i,delta:+n,kind:"transfer-in",side:e.side}),"top"===t?f-=n:p-=n,"top"===e.side?f+=n:p+=n,o-=n}o>0&&null!==d&&(u.push({time:d,delta:+o,kind:"create",side:e.side}),"top"===e.side?f+=o:p+=o)}"top"===e.side?f-=t:p-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?f+=t:p+=t}r.push(...u),a();let b=0,y=0,v=0,k=0,S=0;const w=[],C=new Map;for(const e of r){if(w.push({t:e.time,topMass:b,botMass:y}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?b:y;C.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta)})}"top"===e.side?b+=e.delta:y+=e.delta,b+y>v&&(v=b+y),b>k&&(k=b),y>S&&(S=y),w.push({t:e.time,topMass:b,botMass:y})}const T=[];let A=0;for(;w.length>A;){let e=A;for(;w.length>e+1&&w[e+1].t===w[A].t;)e++;T.push(w[A]);for(let t=A+1;e>=t;t++){const e=T[T.length-1];w[t].topMass===e.topMass&&w[t].botMass===e.botMass||T.push(w[t])}A=e+1}const I=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let M=null;for(const e of i)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===M||M>e.systemInTime)&&(M=e.systemInTime);let x=null;for(const e of n)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===x||e.systemOutTime>x)&&(x=e.systemOutTime);if(T.length>0){const e=T[T.length-1],t=Math.max(null!=I?I:-1/0,null!=x?x:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&T.push({t:t,topMass:e.topMass,botMass:e.botMass});const o=T[0],n=Math.min(null!=c?c:1/0,null!=M?M:1/0);Number.isFinite(n)&&o.t>n&&o.topMass+o.botMass>0&&T.unshift({t:n,topMass:o.topMass,botMass:o.botMass})}return{samples:T,peak:v,topPeak:k,botPeak:S,localAttachments:C}}function ae(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function le(e,t){return e.map(e=>({t:ae(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function ce(e,t,o){const n=e.value*o;if("out"===e.kind){const i=e.sideMassBefore*o;if("top"===e.side){const e=t-i;return[e,e+n]}const r=t+i;return[r-n,r]}const i=e.sideMassAfter*o;if("top"===e.side){const e=t-i;return[e,e+n]}const r=t+i;return[r-n,r]}function de(e,t){let o=0;for(let n=0;t.length>n;n++)for(let i=n+1;t.length>i;i++){const r=t[n],s=t[i];r.source!==s.source&&r.target!==s.target&&r.source!==s.target&&r.target!==s.source&&(Math.min(r.endTime,s.endTime)>Math.max(r.startTime,s.startTime)&&e[s.source]>e[r.source]!=e[s.target]>e[r.target]&&o++)}return o}function me(e,t){let o=0;for(const n of t)o+=Math.abs(e[n.source]-e[n.target])*(n.value||1);return o}function he(e,t){return 1e3*de(e,t)+me(e,t)}function ge(e,t){return{slots:e.map(e=>({peak:{...e.peak},occupants:e.occupants.slice()})),map:{...t}}}function ue(e,t,o){e.length>8||o.length>40?(function(e,t,o,n=6){const i=e.length;if(1>=i)return;let r=ge(e,t),s=he(t,o);for(let a=0;n>a;a++){const n=Array(i).fill(0),a=Array(i).fill(0);for(const e of o){const o=t[e.source],i=t[e.target];n[o]+=i*(e.value||1),a[o]+=e.value||1,n[i]+=o*(e.value||1),a[i]+=e.value||1}const l=Array.from({length:i},(e,t)=>t).sort((e,t)=>(a[e]>0?n[e]/a[e]:e)-(a[t]>0?n[t]/a[t]:t)),c=l.map(t=>e[t]),d=new Map;l.forEach((e,t)=>d.set(e,t));for(const e of Object.keys(t))t[e]=d.get(t[e]);e.length=0;for(const t of c)e.push(t);const m=he(t,o);if(s>m)s=m,r=ge(e,t);else if(m===s)break}!function(e,t,o){e.length=0;for(const t of o.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(o.map))t[e]=o.map[e]}(e,t,r)}(e,t,o,6),function(e,t,o,n=6){const i=e.length;if(1>=i)return;let r=he(t,o);for(let s=0;n>s;s++){let n=!1;for(let s=0;i-1>s;s++){const i=e[s];e[s]=e[s+1],e[s+1]=i;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s);const a=he(t,o);if(r>a)r=a,n=!0;else{const o=e[s];e[s]=e[s+1],e[s+1]=o;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s)}}if(!n)break}}(e,t,o,6)):function(e,t,o){const n=e.length;if(1>=n)return;const i={...t},r=Object.keys(i),s=Array.from({length:n},(e,t)=>t),a=s.slice(),l={...i};let c=s.slice(),d=1/0;const m=()=>{for(const e of r)l[e]=a[i[e]];const e=he(l,o);d>e&&(d=e,c=s.slice())},h=(e,t)=>{const o=s[e],n=s[t];s[e]=n,s[t]=o,a[o]=t,a[n]=e};m();const g=Array(n).fill(0);let u=0;for(;n>u;)u>g[u]?(h(u%2==0?0:g[u],u),m(),g[u]++,u=0):(g[u]=0,u++);const f=c.map(t=>e[t]),p=new Map;c.forEach((e,t)=>p.set(e,t));for(const e of Object.keys(t))t[e]=p.get(t[e]);e.length=0;for(const t of f)e.push(t)}(e,t,o)}function fe(e,t,o,n,i){const{plotH:r,padding:s,valueScale:a,packing:l,laneOrder:c,lifetimeMode:d="full"}=i,m={},h={};for(const t of e)m[t.id]=o[t.id].topPeak||0,h[t.id]=o[t.id].botPeak||0;const g="half"===d,u={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,o=Array.isArray(t.xExtent)?t.xExtent[1]:null;let i=null!=e&&Number.isFinite(e)?e:1/0,r=null!=o&&Number.isFinite(o)?o:-1/0;for(const e of n.outgoing[t.id]){i>e.startTime&&(i=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&i>e.systemInTime&&(i=e.systemInTime);const t=g?(e.startTime+e.endTime)/2:e.endTime;t>r&&(r=t)}for(const e of n.incoming[t.id]){const t=g?(e.startTime+e.endTime)/2:e.startTime;i>t&&(i=t),e.endTime>r&&(r=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>r&&(r=e.systemOutTime)}u[t.id]={start:Number.isFinite(i)?i:null,end:Number.isFinite(r)?r:null}}const f={},p=[];if("reuse"===l){const o=new Map;for(const t of e)o.set(t.id,0);const i=new Map;for(const t of e)i.set(t.id,0);for(const e of t)i.set(e.target,(i.get(e.target)??0)+1);const r=[];for(const t of e)0===(i.get(t.id)??0)&&r.push(t.id);for(;r.length;){const e=r.shift();for(const t of n.outgoing[e]??[]){const n=(o.get(e)??0)+1;n>(o.get(t.target)??0)&&o.set(t.target,n),i.set(t.target,i.get(t.target)-1),0===i.get(t.target)&&r.push(t.target)}}const s=[...e].filter(e=>null!==u[e.id].start).sort((e,t)=>{const n=o.get(e.id)??0,i=o.get(t.id)??0;return n!==i?n-i:u[e.id].start-u[t.id].start}),a=e.filter(e=>null===u[e.id].start);for(const e of[...s,...a]){const t=u[e.id];let o=-1;for(let e=0;p.length>e;e++){const n=p[e].occupants[p[e].occupants.length-1];if(null===t.start||void 0===n||t.start>=n.end){o=e;break}}-1===o&&(p.push({occupants:[],peak:{topPeak:0,botPeak:0}}),o=p.length-1),p[o].occupants.push({id:e.id,end:t?.end??-1/0}),p[o].peak.topPeak=Math.max(p[o].peak.topPeak,m[e.id]),p[o].peak.botPeak=Math.max(p[o].peak.botPeak,h[e.id]),f[e.id]=o}}else e.forEach((e,t)=>{p.push({occupants:[{id:e.id,end:u[e.id]?.end??-1/0}],peak:{topPeak:m[e.id],botPeak:h[e.id]}}),f[e.id]=t});let b=null,y=null,v=null,k=null;const S=()=>{b=de(f,t),v=me(f,t)},w=()=>{y=de(f,t),k=me(f,t)};"crossing-min"===c?(S(),ue(p,f,t),w()):"inside-out"===c?(S(),function(e,t){const o=e.length;if(1>=o)return;const n=e=>e.peak.topPeak+e.peak.botPeak,i=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>n(t.slot)-n(e.slot)),r=Array(o),s=Math.floor((o-1)/2);r[s]=i[0].idx;let a=s-1,l=s+1;for(let e=1;i.length>e;e++)e%2==1&&o>l||0>a?r[l++]=i[e].idx:r[a--]=i[e].idx;const c=r.map(t=>e[t]),d=new Map;r.forEach((e,t)=>d.set(e,t));for(const e of Object.keys(t))t[e]=d.get(t[e]);e.length=0;for(const t of c)e.push(t)}(p,f),w()):"crossing-min+inside-out"===c&&(S(),ue(p,f,t),function(e,t,o){const n=e.length;if(1>=n)return;const i=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),r=Math.floor((n-1)/2);let s=he(t,o);for(const{slot:a}of i){const i=e.indexOf(a);if(0>i)continue;const l=r;if(i===l)continue;const c=e[i];e.splice(i,1),e.splice(l,0,c);const d=new Map;for(let e=0;n>e;e++)d.set(e,e);if(l>i){for(let e=i+1;l>=e;e++)d.set(e,e-1);d.set(i,l)}else{for(let e=l;i>e;e++)d.set(e,e+1);d.set(i,l)}for(const e of Object.keys(t))t[e]=d.get(t[e]);const m=he(t,o);if(m>s){const o=e[l];e.splice(l,1),e.splice(i,0,o);const r=new Map;for(let e=0;n>e;e++)r.set(e,e);if(i>l){for(let e=l+1;i>=e;e++)r.set(e,e-1);r.set(l,i)}else{for(let e=i;l>e;e++)r.set(e,e+1);r.set(l,i)}for(const e of Object.keys(t))t[e]=r.get(t[e])}else s=m}}(p,f,t),w());const C=p.map(e=>{const t=new Map;for(const n of e.occupants){const e=o[n.id];if(e)for(const o of e.samples){const e=t.get(o.t)||{top:0,bot:0};t.set(o.t,{top:Math.max(e.top,o.topMass),bot:Math.max(e.bot,o.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),T=(e,t)=>{let o={top:0,bot:0};for(const[n,i]of e){if(n>t)break;o=i}return o},A=[];for(let e=0;p.length-1>e;e++){const t=C[e],o=C[e+1],n=new Set([...t.map(e=>e[0]),...o.map(e=>e[0])]);let i=0;for(const e of n){const n=T(t,e),r=T(o,e);n.bot+r.top>i&&(i=n.bot+r.top)}A.push(i)}const I=[];let M=s+(p[0]?.peak.topPeak??0)*a;p.length>0&&I.push(M);for(let e=1;p.length>e;e++)M+=A[e-1]*a+s,I.push(M);if(p.length>0&&(M+=p[p.length-1].peak.botPeak*a+s),M>r){const e=r/M;for(let t=0;I.length>t;t++)I[t]*=e}const H=0===p.length?0:p[0].peak.topPeak+A.reduce((e,t)=>e+t,0)+p[p.length-1].peak.botPeak,x={};for(const t of e)x[t.id]=I[f[t.id]];return{effectiveSlotsHeight:H,centerlines:x,laneLifetime:u,slots:p,slotByNode:f,slotCenter:I,crossingsBefore:b,crossingsAfter:y,lengthBefore:v,lengthAfter:k}}ne.displayName="SankeyDiagram";import{useMemo as pe,useState as be,useRef as ye,useCallback as ve}from"react";import{scaleTime as ke}from"d3-scale";import{forwardRef as Se}from"react";var we=e=>{const{bands:t=[],ribbons:o=[],showLabels:n=!0}=e.config,i=[];for(const e of o)i.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}});for(const e of t)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const o=e.gradientStubs[t];i.push({type:"bezier",pathD:o.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:o.x0,x1:o.x1,from:o.from,to:o.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of t)i.push({type:"bezier",pathD:e.pathD,style:{...e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86},stroke:e.stroke??e.fill,strokeWidth:e.strokeWidth??.5},datum:{__kind:"band",data:e.rawDatum,id:e.id}});const r=n?t.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:i,labels:r}};function Ce(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}import{Fragment as Te,jsx as Ae,jsxs as Ie}from"react/jsx-runtime";function Me(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function He(e,t){return"function"==typeof e?e(t):t[e]}var xe=Se(function(e,t){const{nodes:o,edges:n,domain:r,axisTicks:l=[],nodeIdAccessor:c="id",sourceAccessor:d="source",targetAccessor:m="target",valueAccessor:h="value",startTimeAccessor:g="startTime",endTimeAccessor:u="endTime",systemInTimeAccessor:f,systemOutTimeAccessor:p,xExtentAccessor:k="xExtent",edgeIdAccessor:S="id",colorBy:w,colorScheme:C,showLegend:T,legendPosition:A="right",pairing:I="temporal",packing:M="reuse",laneOrder:H="crossing-min",ribbonLane:x="both",lifetimeMode:B="half",showLaneRails:N=!1,showQualityReadout:O=!1,showLabels:D=!0,width:P=600,height:L=400,margin:E,title:W,description:R,summary:z,accessibleTable:F,responsiveWidth:j,responsiveHeight:_,loading:G,loadingContent:Y,emptyContent:Z,edgeOpacity:J=.35,timeFormat:U,valueFormat:X,tooltip:K,enableHover:Q=!0,onObservation:V,onClick:ee,showParticles:te=!1,particleStyle:oe,chartId:ne,frameProps:de={}}=e,[me,he]=be([]),[ge,ue]=be([]),Se=ye(me),xe=ye(ge);Se.current=me,xe.current=ge;const Be=ve(e=>{Se.current=e,he(e)},[]),Ne=ve(e=>{xe.current=e,ue(e)},[]),Oe=void 0!==n,De=b(Oe?n:me),Pe=pe(()=>{const e=b(o??[]),t=ge;if(0===e.length&&0===t.length)return $([],De,d,m);const n=new Set,i=[];for(const t of e){const e=He(c,t)+"";n.has(e)||(n.add(e),i.push(t))}for(const e of t){const t=He(c,e)+"";n.has(t)||(n.add(t),i.push(e))}const r=$([],De,d,m);for(const e of r)n.has(e.id)||(n.add(e.id),i.push(e));return i},[o,ge,De,c,d,m]),Le=ye(null),Ee=ve((e,t)=>{const o=He(S,e);return null!=o?o+"":`${He(d,e)}-${He(m,e)}-${t}`},[S,d,m]),We=ve(e=>{if(null==e)return!1;const t=e;return null!=He(d,t)&&null!=He(m,t)},[d,m]);i(t,{variant:"network",frameRef:Le,overrides:{push(e){if(We(e)){if(Oe)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");Be([...Se.current,e])}else Ne([...xe.current,e])},pushMany(e){const t=[],o=[];for(const n of e)We(n)?t.push(n):o.push(n);t.length>0&&(Oe?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):Be([...Se.current,...t])),o.length>0&&Ne([...xe.current,...o])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),o=[];if(!Oe){const e=Se.current,n=[];for(let i=0;e.length>i;i++){const r=e[i];t.has(Ee(r,i))?o.push(r):n.push(r)}n.length!==e.length&&Be(n)}const n=xe.current,i=[];for(const e of n){const n=He(c,e)+"";t.has(n)?o.push(e):i.push(e)}return i.length!==n.length&&Ne(i),o},update(e,t){const o=new Set(Array.isArray(e)?e:[e]),n=[];if(!Oe){let e=!1;const i=Se.current.map((i,r)=>o.has(Ee(i,r))?(n.push(i),e=!0,t(i)):i);e&&Be(i)}let i=!1;const r=xe.current.map(e=>{const r=He(c,e)+"";return o.has(r)?(n.push(e),i=!0,t(e)):e});return i&&Ne(r),n},clear(){Oe||Be([]),Ne([]),Le.current?.clear()},getData:()=>De??[],getScales:()=>null}});const Re=Ee,ze=ve(e=>He(c,e)+"",[c]),{nodes:Fe,edges:je,domain:$e,rawNodeById:_e,rawEdgeById:Ge}=pe(()=>{const e=(Pe??[]).map(e=>{const t={id:ze(e),__raw:e},o=k?He(k,e):null;if(Array.isArray(o)&&2===o.length){const e=Me(o[0]),n=Me(o[1]);Number.isFinite(e)&&Number.isFinite(n)&&(t.xExtent=[e,n])}return t}),t=(De??[]).map((e,t)=>{const o={id:Re(e,t),source:He(d,e)+"",target:He(m,e)+"",value:Number(He(h,e)),startTime:Me(He(g,e)),endTime:Me(He(u,e)),__raw:e};if(f){const t=Me(He(f,e));Number.isFinite(t)&&(o.systemInTime=t)}if(p){const t=Me(He(p,e));Number.isFinite(t)&&(o.systemOutTime=t)}return o}),o=[Me(r[0]),Me(r[1])],n=new Map;for(const t of e)null!=t.__raw&&n.set(t.id,t.__raw);const i=new Map;for(const e of t)null!=e.__raw&&i.set(e.id,e.__raw);return{nodes:e,edges:t,domain:o,rawNodeById:n,rawEdgeById:i}},[Pe,De,r,ze,Re,k,d,m,h,g,u,f,p]),qe=q({nodes:Pe,edges:De,inferNodes:!1,nodeIdAccessor:c,sourceAccessor:d,targetAccessor:m,colorBy:w,colorScheme:C,showLegend:!1,legendPosition:A,selection:void 0,linkedHover:void 0,onObservation:V,onClick:ee,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:"ProcessSankey",chartId:ne,marginDefaults:{top:30,right:80,bottom:40,left:80},userMargin:E,width:P,height:L,loading:G,loadingContent:Y,emptyContent:Z}),Ye=(T??!!w)&&!!w,Ze=ve(e=>null!=E&&("number"==typeof E||null!=E[e]),[E]),Je=pe(()=>{const e={...qe.margin};return Ye&&("right"===A&&!Ze("right")&&140>e.right?e.right=140:"bottom"===A&&!Ze("bottom")&&80>e.bottom&&(e.bottom=80)),e},[qe.margin,Ye,A,Ze]),Ue=P-Je.left-Je.right,Xe=L-Je.top-Je.bottom,Ke=pe(()=>ie(Fe,je,$e),[Fe,je,$e]),Qe=pe(()=>Ke.length>0?null:function(e,t,o){const{plotH:n,pairing:i="temporal",packing:r="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half"}=o,l=function(e,t){const o={},n={};for(const t of e)o[t.id]=[],n[t.id]=[];for(const e of t)n[e.source]&&n[e.source].push(e),o[e.target]&&o[e.target].push(e);return{incoming:o,outgoing:n}}(e,t),c=function(e,t,o,n="value"){const i="temporal"===n?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,r="temporal"===n?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,s=new Map;for(const e of t)s.set(e.id,{});const a=(e,t)=>{const o=new Map;for(const n of e){const e=n[t];o.has(e)||o.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const i=o.get(e);i.edges.push(n),i.total+=n.value,i.earliestStart=Math.min(i.earliestStart,n.startTime),i.latestEnd=Math.max(i.latestEnd,n.endTime)}const s=[...o.values()];s.sort("temporal"===n?(e,o)=>"target"===t?e.earliestStart-o.earliestStart:e.latestEnd-o.latestEnd:(e,t)=>t.total-e.total);for(const e of s)e.edges.sort("target"===t?r:i);return s};for(const t of e){const e=o.outgoing[t.id],n=o.incoming[t.id];if(0===n.length)a(e,"target").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).sourceSide=o});else if(0===e.length)a(n,"source").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).targetSide=o});else{const t=a(n,"source"),o=a(e,"target"),i=Math.max(t.length,o.length);for(let e=0;i>e;e++){const n=e%2==0?"top":"bot";if(t[e])for(const o of t[e].edges)s.get(o.id).targetSide=n;if(o[e])for(const t of o[e].edges)s.get(t.id).sourceSide=n}}}return s}(e,t,l,i);let d={};for(const t of e)d[t.id]=se(t,l,c);const m=fe(e,t,d,l,{plotH:n,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a}),h=new Set;for(const e of t){const t=m.slotByNode[e.source],o=m.slotByNode[e.target];if(void 0===t||void 0===o)continue;const n=c.get(e.id);t!==o?t>o?(n.sourceSide="top",n.targetSide="bot"):(n.sourceSide="bot",n.targetSide="top"):(h.add(e.id),n.sourceSide="bot",n.targetSide="bot")}for(const t of e){const e=l.outgoing[t.id],o=l.incoming[t.id],n=new Set(e.map(e=>c.get(e.id).sourceSide)),i=new Set(o.map(e=>c.get(e.id).targetSide));if(1===n.size&&o.length>0){const e=[...n][0];for(const t of o)m.slotByNode[t.source]===m.slotByNode[t.target]&&(c.get(t.id).targetSide=e)}if(1===i.size&&e.length>0){const t=[...i][0];for(const o of e)m.slotByNode[o.source]===m.slotByNode[o.target]&&(c.get(o.id).sourceSide=t)}}for(const t of e){const e=l.incoming[t.id],o=l.outgoing[t.id];if(0===e.length||0===o.length)continue;const n=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const o of e)"top"===c.get(o.id).targetSide?t.inTop+=o.value:t.inBot+=o.value;for(const e of o)"top"===c.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},i=(e,t)=>{const i=n(),r="top"===e?i.outTop-i.inTop:i.outBot-i.inBot,s="top"===t?i.inTop-i.outTop:i.inBot-i.outBot;if(0>=r||0>=s)return!1;const a=Math.min(r,s),l=o.filter(t=>!h.has(t.id)&&c.get(t.id).sourceSide===e&&a>=t.value).sort((e,t)=>t.value-e.value);return 0!==l.length&&(c.get(l[0].id).sourceSide=t,!0)};let r=o.length+1;for(;r-- >0&&(i("top","bot")||i("bot","top")););}d={};for(const t of e)d[t.id]=se(t,l,c);const g=fe(e,t,d,l,{plotH:n,padding:12,valueScale:1,packing:r,laneOrder:s,lifetimeMode:a}),u=g.effectiveSlotsHeight??g.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),f=Math.min(12,.35*n/Math.max(g.slots.length+1,1)),p=u>0?Math.max(0,(n-f*(g.slots.length+1))/u):1,b=fe(e,t,d,l,{plotH:n,padding:f,valueScale:p,packing:r,laneOrder:s,lifetimeMode:a});return{nodeData:d,sides:c,valueScale:p,padding:f,compressedPadding:12>f,centerlines:b.centerlines,laneLifetime:b.laneLifetime,slots:b.slots,slotByNode:b.slotByNode,crossingsBefore:b.crossingsBefore,crossingsAfter:b.crossingsAfter,lengthBefore:b.lengthBefore,lengthAfter:b.lengthAfter}}(Fe,je,{plotH:Xe,pairing:I,packing:M,laneOrder:H,lifetimeMode:B}),[Ke,Fe,je,Xe,I,M,H,B]),Ve=pe(()=>ke().domain($e).range([0,Ue]),[$e,Ue]),et=ve((e,t)=>{if(w&&Pe){const t=_e.get(e);if(t)return y(t,w,qe.colorScale)}return qe.effectivePalette[t%qe.effectivePalette.length]||"#475569"},[w,Pe,_e,qe.colorScale,qe.effectivePalette]),tt=pe(()=>{const e=new Map;return Fe.forEach((t,o)=>e.set(t.id,o)),e},[Fe]),ot=pe(()=>{if(!Qe)return{bands:[],ribbons:[]};const{centerlines:e,nodeData:t,valueScale:o}=Qe,n=[],i=[];return Fe.forEach((i,r)=>{const s=t[i.id];if(!s||0===s.samples.length)return;const a=function(e,t,o,n,i){if(0===e.length)return null;const r=le(e,i),s=e=>t-r[e].topMass*o,a=e=>t+r[e].botMass*o;let l=`M${n(r[0].t)},${s(0)}`;for(let e=1;r.length>e;e++)l+=` L${n(r[e].t)},${s(e)}`;l+=` L${n(r[r.length-1].t)},${a(r.length-1)}`;for(let e=r.length-2;e>=0;e--)l+=` L${n(r[e].t)},${a(e)}`;return l+" Z"}(s.samples,e[i.id],o,Ve,$e);if(!a)return;const l=le(s.samples,$e),c=l.find(e=>e.topMass+e.botMass>0)||l[0],d=e[i.id]+(c.botMass-c.topMass)*o/2,m=et(i.id,r),h=_e.get(i.id)??i,g=function(e,t,o,n,i){const r=o.nodeData[e];if(!r||0===r.samples.length)return[];const s=o.valueScale,a=o.centerlines[e],l=le(r.samples,i),c=l.find(e=>e.topMass+e.botMass>0)||l[0],d=[...l].reverse().find(e=>e.topMass+e.botMass>0)||l[l.length-1],m=n(c.t),h=n(d.t),g=e=>n(ae(e,i)),u=[],f=(e,t,o,n)=>`M${e},${t} L${o},${t} L${o},${n} L${e},${n} Z`;for(const o of t){if(o.source===e&&null!=o.systemInTime&&Number.isFinite(o.systemInTime)){const e=r.localAttachments.get(o.id);if(e&&"out"===e.kind&&o.startTime>o.systemInTime){const t=g(o.systemInTime),n=g(o.startTime),i=t-20,r=Math.max(m,i);if(n>r){const[o,l]=ce(e,a,s);u.push({pathD:f(r,o,n,l),x0:i,x1:t,from:0,to:1})}}}if(o.target===e&&null!=o.systemOutTime&&Number.isFinite(o.systemOutTime)){const e=r.localAttachments.get(o.id);if(e&&"in"===e.kind&&o.systemOutTime>o.endTime){const t=g(o.systemOutTime),n=g(o.endTime),i=t+20,r=Math.min(h,i);if(r>n){const[o,l]=ce(e,a,s);u.push({pathD:f(n,o,r,l),x0:t,x1:i,from:1,to:0})}}}}return u}(i.id,je,Qe,Ve,$e);n.push({id:i.id,pathD:a,fill:m,stroke:m,strokeWidth:.5,...g.length>0&&{gradientStubs:g},rawDatum:h,labelX:Ve(c.t)-4,labelY:d,labelText:i.id})}),je.forEach(n=>{const r=t[n.source]?.localAttachments.get(n.id),s=t[n.target]?.localAttachments.get(n.id);if(!r||!s)return;const l=tt.get(n.source)??0,c=et(n.source,l),d=function(e,t,o,n,i,r,s,a){const l=i,c=e=>a?Math.max(a[0],Math.min(a[1],e)):e,d=r(c(e.time)),m=r(c(o.time)),h=e.value*l,g=o.value*l,u=e.sideMassBefore*l,f=o.sideMassAfter*l;let p,b,y,v;"top"===e.side?(p=t-u,b=p+h):(b=t+u,p=b-h),"top"===o.side?(y=n-f,v=y+g):(v=n+f,y=v-g);const k="source"===s?d+.85*(m-d):"target"===s?d+.15*(m-d):(d+m)/2;return{sx:d,sTop:p,sBot:b,tx:m,tTop:y,tBot:v,cp1X:k,cp2X:k}}(r,e[n.source],s,e[n.target],o,Ve,x,$e),{pathD:m,bezier:h}=a(d),g=Ge.get(n.id)??n;i.push({id:n.id,pathD:m,fill:c,opacity:J,rawDatum:g,bezier:h})}),{bands:n,ribbons:i}},[Qe,Fe,je,Ve,$e,et,_e,Ge,x,J,tt]),nt=pe(()=>({bands:ot.bands,ribbons:ot.ribbons,showLabels:D}),[ot,D]),it=pe(()=>{if(!Ye||!w)return;const e=new Map;(Pe??[]).forEach((t,o)=>{const n=He(w,t),i=null==n?"":n+"";i&&!e.has(i)&&e.set(i,{label:i,color:et(ze(t),o)})});const t=Array.from(e.values());return 0!==t.length?{legendGroups:[{type:"fill",label:"",items:t,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0},[Ye,w,Pe,et,ze]),rt=pe(()=>!1!==K&&Q?void 0===K||!0===K?null:v(K)||null:null,[K,Q]),st=ve(e=>U?U(new Date(e)):Number.isFinite(e)?1e10>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2):new Date(e).toISOString().slice(0,10):"",[U]),at=ve(e=>X?X(e):e+"",[X]),lt=ve(e=>{if(!e||!e.data)return null;const t=e.data;if(!Ce(t))return null;const o=t.data;if(rt)return rt(o);if("band"===t.__kind){const e=t.id,o=Qe?function(e){if(!e)return[];const t=new Set,o=[];for(const n of e.samples){const e=n.topMass+n.botMass,i=`${n.t}:${e}`;t.has(i)||(t.add(i),o.push({t:n.t,total:e}))}return o}(Qe.nodeData[e]):[],n=5,i=o.length>n?o.length:null,r=function(e,t=5){if(t>=e.length)return e.slice();const o=[...e].sort((e,t)=>e.total-t.total),n=o.length-1,i=[{...o[0],mark:"min"},{...o[Math.floor(.25*n)],mark:"q25"},{...o[Math.floor(.5*n)],mark:"median"},{...o[Math.floor(.75*n)],mark:"q75"},{...o[n],mark:"max"}],r=new Set,s=[];for(const e of i)r.has(e.t)||(r.add(e.t),s.push(e));return s.sort((e,t)=>e.t-t.t)}(o,n);return Ie("div",{style:{minWidth:160},children:[Ae("div",{style:{fontWeight:600,marginBottom:4},children:e}),r.length>0&&Ie("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[Ae("thead",{children:Ie("tr",{style:{opacity:.6},children:[Ae("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),Ae("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=i&&Ae("th",{})]})}),Ae("tbody",{children:r.map((e,t)=>Ie("tr",{children:[Ae("td",{style:{paddingRight:8},children:st(e.t)}),Ae("td",{style:{textAlign:"right"},children:at(e.total)}),null!=i&&Ae("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:e.mark})]},t))})]}),null!=i&&Ie("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",r.length," of ",i," samples"]})]})}const n=o,i=He(d,n),r=He(m,n),s=He(h,n),a=He(g,n),l=He(u,n);return Ie("div",{style:{minWidth:160},children:[Ie("div",{style:{fontWeight:600,marginBottom:4},children:[i+""," → ",r+""]}),Ie("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=s&&Ie(Te,{children:[Ae("span",{style:{opacity:.6},children:"value"}),Ae("span",{style:{textAlign:"right"},children:at(Number(s))})]}),null!=a&&Ie(Te,{children:[Ae("span",{style:{opacity:.6},children:"start"}),Ae("span",{style:{textAlign:"right"},children:st(Me(a))})]}),null!=l&&Ie(Te,{children:[Ae("span",{style:{opacity:.6},children:"end"}),Ae("span",{style:{textAlign:"right"},children:st(Me(l))})]})]})]})},[Qe,rt,st,at,d,m,h,g,u]),ct=pe(()=>{if(!Qe)return null;const{centerlines:e,laneLifetime:t,nodeData:o,valueScale:n,compressedPadding:i,crossingsBefore:r,crossingsAfter:s,lengthBefore:a,lengthAfter:c}=Qe;let d=null,m=null;for(const e of Fe){const o=t[e.id];if(!o||null===o.start||null===o.end)continue;const n=Ve(o.start),i=Ve(o.end);(null===d||d>n)&&(d=n),(null===m||i>m)&&(m=i)}const h=e=>Math.max(0,Math.min(Ue,e)),g=h(d??0),u=Math.max(g,h(m??Ue));return Ie("g",{children:[O&&null!==(s??null)&&Ie("text",{x:Ue,y:-12,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:["crossings: ",r," → ",s," ","edge length: ",Math.round(a)," → ",Math.round(c)]}),i&&Ae("text",{x:Ue,y:2,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:"dense layout: lane gaps compressed"}),l.map((e,t)=>{const o=Ve(Me(e.date));return g-.5>o||o>u+.5?null:Ae("line",{x1:o,y1:0,x2:o,y2:Xe,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+t)}),N&&Fe.map((i,r)=>{const s=t[i.id];if(!s||null===s.start)return null;const a=o[i.id],l=a?{topPeak:a.topPeak,botPeak:a.botPeak}:{topPeak:0,botPeak:0},c=e[i.id]+(l.botPeak-l.topPeak)*n/2,d=Ve(s.start),m=Ve(s.end),h=et(i.id,r);return Ie("g",{children:[Ae("line",{x1:d,y1:c,x2:m,y2:c,stroke:h,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),Ae("line",{x1:d,y1:c-4,x2:d,y2:c+4,stroke:h,strokeOpacity:.5}),Ae("line",{x1:m,y1:c-4,x2:m,y2:c+4,stroke:h,strokeOpacity:.5})]},"lane-"+i.id)}),Ae("line",{x1:g,y1:Xe+4,x2:u,y2:Xe+4,stroke:"#94a3b8"}),l.map((e,t)=>{const o=Me(e.date),n=Ve(o);if(g-.5>n||n>u+.5)return null;const i=null!=e.label?e.label:U?U(new Date(o)):"";return Ie("g",{transform:`translate(${n},${Xe+4})`,children:[Ae("line",{y2:6,stroke:"#94a3b8"}),Ae("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569",children:i})]},t)})]})},[Qe,l,Ve,Ue,Xe,N,Fe,et,O,U]),dt=pe(()=>(Pe??[]).map(e=>({id:ze(e),data:e})),[Pe,ze]),mt=pe(()=>{const e=new Map;for(const t of ot.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[ot]),ht=pe(()=>(De??[]).map((e,t)=>{const o=Re(e,t),n=Number(He(h,e));return{id:o,source:He(d,e)+"",target:He(m,e)+"",value:Number.isFinite(n)?n:0,bezier:mt.get(o),data:e}}),[De,Re,d,m,h,mt]),gt=qe.loadingEl,ut=qe.emptyEl;return Ke.length>0?Ie("svg",{width:P,height:L,role:"img","aria-label":W??"Process Sankey validation failed",children:[Ae("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),Ke.map((e,t)=>Ae("text",{x:20,y:56+18*t,fontSize:12,fill:"#64748b",children:"• "+re(e)},t))]}):gt||ut||Ae(s,{ref:Le,chartType:"force",nodes:dt,edges:ht,customNetworkLayout:we,layoutConfig:nt,size:[P,L],responsiveWidth:j,responsiveHeight:_,margin:Je,title:W,description:R??"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:z,accessibleTable:F,enableHover:Q,tooltipContent:!1===K?()=>null:lt,backgroundGraphics:ct,showParticles:te,particleStyle:oe,legend:it,legendPosition:A,onObservation:V,...ee&&{customClickBehavior:e=>{if(!e||!e.data||!ee)return;const t=e.data;Ce(t)&&ee(t.data,{x:e.x,y:e.y})}},chartId:ne,colorScheme:Array.isArray(C)?C:void 0,...de})});xe.displayName="ProcessSankey";import{useMemo as Be}from"react";import{jsx as Ne}from"react/jsx-runtime";function Oe(e){const n=C(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:i,margin:r,className:a,layout:l="tree",orientation:d="vertical",childrenAccessor:m="children",valueAccessor:h="value",nodeIdAccessor:g="name",colorBy:u,colorScheme:f,colorByDepth:b=!1,edgeStyle:S="curve",nodeLabel:w,nodeSize:T=5,tooltip:A,frameProps:I={},onObservation:M,onClick:H,chartId:N,selection:O,linkedHover:D,loading:P,loadingContent:L,legendInteraction:E,stroke:W,strokeWidth:R,opacity:z}=e,{width:F,height:$,enableHover:G,showLabels:Y=!0,title:Z,description:J,summary:U,accessibleTable:X}=n,K=q({nodes:Be(()=>j(i??null,m),[i,m]),edges:void 0,inferNodes:!1,colorBy:b?void 0:u,colorScheme:f,showLegend:!1,legendInteraction:E,selection:O,linkedHover:D,onObservation:M,onClick:H,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"TreeDiagram",chartId:N,marginDefaults:n.marginDefaults,userMargin:r,width:F,height:$,loading:P,loadingContent:L}),Q=Be(()=>new Map,[]),V=Be(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=b?p[(e.depth||0)%p.length]:u?y(e.data||e,u,K.colorScale):k(void 0,K.themeCategorical,f,void 0,Q),t},[u,b,K.colorScale,K.themeCategorical,f,Q]),ee=Be(()=>o(V,{stroke:W,strokeWidth:R,opacity:z}),[V,W,R,z]),te=Be(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),oe=Be(()=>o(te,{stroke:W,strokeWidth:R,opacity:z}),[te,W,R,z]),ne=Be(()=>{if("treemap"===l||"circlepack"===l||"partition"===l)return _(h)},[l,h]),ie=t({componentName:"TreeDiagram",data:i});return ie?Ne(x,{componentName:"TreeDiagram",message:ie,width:F,height:$}):K.loadingEl?K.loadingEl:Ne(B,{componentName:"TreeDiagram",width:F,height:$,children:Ne(s,{chartType:l,...null!=i&&{data:i},size:[F,$],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:K.margin,nodeIDAccessor:g,childrenAccessor:m,hierarchySum:ne,treeOrientation:d,edgeType:S,nodeStyle:ee,edgeStyle:oe,colorBy:u,colorScheme:K.effectivePalette,colorByDepth:b,nodeSize:T,nodeLabel:Y?w||g:void 0,showLabels:Y,enableHover:G,tooltipContent:!1===A?()=>null:v(A)||void 0,...c({linkedHover:D,selection:O,onObservation:M,onClick:H,mobileInteraction:K.mobileInteraction,customHoverBehavior:K.customHoverBehavior,customClickBehavior:K.customClickBehavior,linkedHoverInClickPredicate:!1}),...E&&"none"!==E&&{legendHoverBehavior:K.legendState.onLegendHover,legendClickBehavior:K.legendState.onLegendClick,legendHighlightedCategory:K.legendState.highlightedCategory,legendIsolatedCategories:K.legendState.isolatedCategories},className:a,title:Z,description:J,summary:U,accessibleTable:X,...null!=e.animate&&{animate:e.animate},...I})})}Oe.displayName="TreeDiagram";import{useMemo as De,useCallback as Pe}from"react";import{jsx as Le}from"react/jsx-runtime";function Ee(e){const n=C(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,linkedHover:e.linkedHover,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:i,margin:a,className:l,childrenAccessor:d="children",valueAccessor:m="value",nodeIdAccessor:h="name",colorBy:g,colorScheme:u,colorByDepth:b=!1,labelMode:S="leaf",nodeLabel:w,padding:T=4,paddingTop:A,nodeStyle:I,tooltip:M,frameProps:H={},selection:N,linkedHover:O,onObservation:D,onClick:P,chartId:L,loading:E,loadingContent:W,legendInteraction:R,stroke:z,strokeWidth:F,opacity:$}=e,{nodeStyle:G,...Y}=H,{width:Z,height:J,enableHover:U,showLabels:X=!0,title:K,description:Q,summary:V,accessibleTable:ee}=n,te=q({nodes:De(()=>j(i??null,d),[i,d]),edges:void 0,inferNodes:!1,colorBy:b?void 0:g,colorScheme:u,showLegend:!1,legendInteraction:R,selection:N,linkedHover:O,onObservation:D,onClick:P,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"Treemap",chartId:L,marginDefaults:n.marginDefaults,userMargin:a,width:Z,height:J,loading:E,loadingContent:W}),oe=r(N),ne=te.customHoverBehavior,ie=Pe(e=>{if(!e)return ne(null);const t=e.data||e;ne({data:t?.data||t})},[ne]),re=De(()=>new Map,[]),se=De(()=>e=>{const t={stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8};return t.fill=b?p[(e.depth||0)%p.length]:g?y(e.data||e,g,te.colorScale):k(void 0,te.themeCategorical,u,void 0,re),t},[g,b,te.colorScale,te.themeCategorical,u,re]),ae=De(()=>I||G?e=>({...se(e),...G?G(e)??{}:{},...I?I(e)??{}:{}}):se,[se,I,G]),le=De(()=>o(ae,{stroke:z,strokeWidth:F,opacity:$}),[ae,z,F,$]),ce=De(()=>te.activeSelectionHook?e=>{const t={...le(e)};if(te.activeSelectionHook.isActive)if(te.activeSelectionHook.predicate(e.data||e))oe?.selectedStyle&&Object.assign(t,oe.selectedStyle);else{const e=oe?.unselectedOpacity??f;t.opacity=e,t.fillOpacity=e,t.strokeOpacity=e,oe?.unselectedStyle&&Object.assign(t,oe.unselectedStyle)}return t}:le,[le,te.activeSelectionHook,oe]),de=De(()=>_(m),[m]),me=void 0!==A?A:!X||"parent"!==S&&"all"!==S?void 0:18,he=t({componentName:"Treemap",data:i});return he?Le(x,{componentName:"Treemap",message:he,width:Z,height:J}):te.loadingEl?te.loadingEl:Le(B,{componentName:"Treemap",width:Z,height:J,children:Le(s,{chartType:"treemap",...null!=i&&{data:i},size:[Z,J],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:te.margin,nodeIDAccessor:h,childrenAccessor:d,hierarchySum:de,padding:T,paddingTop:me,nodeStyle:ce,colorBy:g,colorScheme:te.effectivePalette,colorByDepth:b,nodeLabel:X?w||h:void 0,showLabels:X,labelMode:S,enableHover:U,tooltipContent:!1===M?()=>null:v(M)||void 0,...c({linkedHover:O,selection:N,onObservation:D,onClick:P,mobileInteraction:te.mobileInteraction,customHoverBehavior:ie,customClickBehavior:te.customClickBehavior,linkedHoverInClickPredicate:!1}),...R&&"none"!==R&&{legendHoverBehavior:te.legendState.onLegendHover,legendClickBehavior:te.legendState.onLegendClick,legendHighlightedCategory:te.legendState.highlightedCategory,legendIsolatedCategories:te.legendState.isolatedCategories},className:l,title:K,description:Q,summary:V,accessibleTable:ee,...null!=e.animate&&{animate:e.animate},...Y})})}Ee.displayName="Treemap";import{useMemo as We}from"react";import{jsx as Re}from"react/jsx-runtime";function ze(e){const n=C(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:i,margin:r,className:a,childrenAccessor:l="children",valueAccessor:d="value",nodeIdAccessor:m="name",colorBy:h,colorScheme:g,colorByDepth:u=!1,nodeLabel:f,circleOpacity:b=.7,padding:S=4,tooltip:w,frameProps:T={},onObservation:A,onClick:I,chartId:M,selection:H,linkedHover:N,loading:O,loadingContent:D,legendInteraction:P,stroke:L,strokeWidth:E,opacity:W}=e,{width:R,height:z,enableHover:F,showLabels:$=!0,title:G,description:Y,summary:Z,accessibleTable:J}=n,U=q({nodes:We(()=>j(i??null,l),[i,l]),edges:void 0,inferNodes:!1,colorBy:u?void 0:h,colorScheme:g,showLegend:!1,legendInteraction:P,selection:H,linkedHover:N,onObservation:A,onClick:I,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"CirclePack",chartId:M,marginDefaults:n.marginDefaults,userMargin:r,width:R,height:z,loading:O,loadingContent:D}),X=We(()=>new Map,[]),K=We(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:b};return t.fill=u?p[(e.depth||0)%p.length]:h?y(e.data||e,h,U.colorScale):k(void 0,U.themeCategorical,g,void 0,X),t},[h,u,U.colorScale,b,U.themeCategorical,g,X]),Q=We(()=>o(K,{stroke:L,strokeWidth:E,opacity:W}),[K,L,E,W]),V=We(()=>_(d),[d]),ee=t({componentName:"CirclePack",data:i});return ee?Re(x,{componentName:"CirclePack",message:ee,width:R,height:z}):U.loadingEl?U.loadingEl:Re(B,{componentName:"CirclePack",width:R,height:z,children:Re(s,{chartType:"circlepack",...null!=i&&{data:i},size:[R,z],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:U.margin,nodeIDAccessor:m,childrenAccessor:l,hierarchySum:V,padding:S,nodeStyle:Q,colorBy:h,colorScheme:U.effectivePalette,colorByDepth:u,nodeLabel:$?f||m:void 0,showLabels:$,enableHover:F,tooltipContent:!1===w?()=>null:v(w)||void 0,...c({linkedHover:N,selection:H,onObservation:A,onClick:I,mobileInteraction:U.mobileInteraction,customHoverBehavior:U.customHoverBehavior,customClickBehavior:U.customClickBehavior,linkedHoverInClickPredicate:!1}),...P&&"none"!==P&&{legendHoverBehavior:U.legendState.onLegendHover,legendClickBehavior:U.legendState.onLegendClick,legendHighlightedCategory:U.legendState.highlightedCategory,legendIsolatedCategories:U.legendState.isolatedCategories},className:a,title:G,description:Y,summary:Z,accessibleTable:J,...null!=e.animate&&{animate:e.animate},...T})})}ze.displayName="CirclePack";import{useMemo as Fe}from"react";import{jsx as je}from"react/jsx-runtime";var $e=p;function _e(e){const n=C(e.mode,{width:e.width,height:e.height,enableHover:e.enableHover,showLabels:e.showLabels,title:e.title,description:e.description,accessibleTable:e.accessibleTable,summary:e.summary,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},{width:600,height:600}),{data:i,margin:r,className:a,childrenAccessor:l="children",nodeIdAccessor:d="name",colorBy:m,colorScheme:h,colorByDepth:f=!1,orbitMode:p="flat",orbitSize:b=2.95,speed:S=.25,revolution:w,revolutionStyle:T,eccentricity:A=1,showRings:I=!0,nodeRadius:M=6,showLabels:H=!1,animated:N=!0,tooltip:O,foregroundGraphics:D,annotations:P,frameProps:L={},onObservation:E,onClick:W,chartId:R,selection:z,linkedHover:F,loading:$,loadingContent:_,stroke:G,strokeWidth:Y,opacity:Z}=e,{width:J,height:U,enableHover:X,title:K,description:Q,summary:V,accessibleTable:ee}=n,te=q({nodes:Fe(()=>j(i,l),[i,l]),edges:void 0,inferNodes:!1,colorBy:f?void 0:m,colorScheme:h,showLegend:!1,legendInteraction:void 0,selection:z,linkedHover:F,onObservation:E,onClick:W,mobileInteraction:n.mobileInteraction,mobileSemantics:n.mobileSemantics,chartType:"OrbitDiagram",chartId:R,marginDefaults:{top:10,right:10,bottom:10,left:10},userMargin:r,width:J,height:U,loading:$,loadingContent:_}),oe=Fe(()=>new Map,[]),{colorScale:ne,customClickBehavior:ie,customHoverBehavior:re,themeCategorical:se}=te,ae=Fe(()=>{if(Array.isArray(h))return h;const e=g[h];return Array.isArray(e)?e:u},[h]),le=Fe(()=>e=>{const t={stroke:"#fff",strokeWidth:1},o=0===(e.depth??0);return t.fill=f?o?ae[0]:$e[(e.depth||0)%$e.length]:m?y(e.data||e,m,ne):k(void 0,se,h,void 0,oe),t.opacity=o?1:.85,t},[m,f,ne,ae,se,h,oe]),ce=Fe(()=>o(le,{stroke:G,strokeWidth:Y,opacity:Z}),[le,G,Y,Z]),de=Fe(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),me=Fe(()=>e=>{re(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[re]),he=Fe(()=>e=>{ie(e&&e.data&&void 0!==e.data.data?{...e,data:e.data.data}:e)},[ie]),ge=t({componentName:"OrbitDiagram",data:i});return ge?je(x,{componentName:"OrbitDiagram",message:ge,width:J,height:U}):te.loadingEl?te.loadingEl:je(B,{componentName:"OrbitDiagram",width:J,height:U,children:je(s,{chartType:"orbit",...null!=i&&{data:i},size:[J,U],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:te.margin,nodeIDAccessor:d,childrenAccessor:l,nodeStyle:ce,edgeStyle:de,colorBy:m,colorScheme:te.effectivePalette,colorByDepth:f,nodeSize:M,nodeLabel:H?d:void 0,showLabels:H,enableHover:!N&&X,tooltipContent:N?void 0:!1===O?()=>null:v(O)||void 0,...c({linkedHover:F,selection:z,onObservation:E,onClick:W,mobileInteraction:te.mobileInteraction,customHoverBehavior:me,customClickBehavior:he,linkedHoverInClickPredicate:!1}),foregroundGraphics:D,annotations:P,className:a,title:K,description:Q,summary:V,orbitMode:p,orbitSize:b,orbitSpeed:S,orbitRevolution:w,orbitRevolutionStyle:T,orbitEccentricity:A,orbitShowRings:I,orbitAnimated:N,accessibleTable:ee,...null!=e.animate&&{animate:e.animate},...L})})}_e.displayName="OrbitDiagram";import{forceCenter as Ge,forceCollide as qe,forceLink as Ye,forceManyBody as Ze,forceSimulation as Je,forceX as Ue,forceY as Xe}from"d3-force";function Ke(e,t,o={}){const n=o.iterations??260,i=o.repulsion??5200,r=o.linkDistance??165,s=o.linkStrength??.045,a=o.centerStrength??.018,l=o.damping??.84,c=o.nodeRadius??12,m=o.nodePadding??3,h=o.inset??.06,g=d(o.seed??1),u=new Map;for(const t of e)u.set(t.id,0);for(const e of t)u.set(e.source,(u.get(e.source)??0)+1),u.set(e.target,(u.get(e.target)??0)+1);const f=500,p=e.map(e=>({id:e.id,data:e,x:200+600*g(),y:200+600*g()})),b=new Set(e.map(e=>e.id)),y=t.filter(e=>b.has(e.source)&&b.has(e.target)).map(e=>({source:e.source,target:e.target}));if(n>0){const e=Je(p).randomSource(g).alphaDecay(1-Math.pow(.001,1/n)).velocityDecay(Math.max(0,Math.min(1,1-l))).force("charge",Ze().strength(e=>{const t=u.get(e.id)??0;return 2.5*-Math.sqrt(i)*Math.sqrt(t+1)})).force("collide",qe(e=>(e=>"function"==typeof c?c(e.data):c)(e)+m).strength(.9).iterations(2)).force("center",Ge(f,f).strength(.8)).force("x",Ue(f).strength(a)).force("y",Xe(f).strength(a));y.length>0&&e.force("link",Ye(y).id(e=>e.id).distance(r).strength(e=>{const t="string"==typeof e.target?e.target:e.target.id,o=Math.max(1,Math.min(u.get("string"==typeof e.source?e.source:e.source.id)??1,u.get(t)??1));return s/.045/o})),e.stop();for(let t=0;n>t;t+=1)e.tick()}let v=1/0,k=1/0,S=-1/0,w=-1/0;for(const e of p){const t=e.x??f,o=e.y??f;v>t&&(v=t),k>o&&(k=o),t>S&&(S=t),o>w&&(w=o)}const C=S-v,T=w-k,A={};for(const e of p)A[e.id]={x:0===C?.5:h+((e.x??f)-v)/C*(1-2*h),y:0===T?.5:h+((e.y??f)-k)/T*(1-2*h)};return A}export{E as NetworkCustomChart,Z as ForceDirectedGraph,Q as ChordDiagram,ne as SankeyDiagram,ie as validateProcessSankey,re as formatProcessSankeyIssue,xe as ProcessSankey,Oe as TreeDiagram,Ee as Treemap,ze as CirclePack,_e as OrbitDiagram,Ke as forceLayout};
@@ -0,0 +1 @@
1
+ function t(t){if(null==t)return()=>{};const n="function"==typeof t?t:n=>n[t];return t=>e(n(t))}function n(n,i){const e=t(n),o=t(i);return(t,n)=>{const i=o(t);return{value:i,x:e(t),y:i,category:n}}}function i(n,i){const e=t(i??"value"),o=null==n?void 0:"function"==typeof n?n:t=>t[n];return t=>{const n=o?o(t):void 0;return{value:e(t),category:null==n?void 0:n+""}}}function e(t){if("number"==typeof t)return Number.isFinite(t)?t:void 0;if("string"==typeof t&&""!==t.trim()){const n=Number(t);return Number.isFinite(n)?n:void 0}}function o(t,n,i){const o=null!=t.axis?i[t.axis]:null!=t.field?n[t.field]:i.value;if(void 0!==t.eq&&o!==t.eq)return!1;if(void 0!==t.ne&&o===t.ne)return!1;if(void 0!==t.in&&!t.in.includes(o))return!1;if(void 0===t.gt&&void 0===t.gte&&void 0===t.lt&&void 0===t.lte&&void 0===t.within&&void 0===t.outside)return!0;const r=e(o);if(void 0===r)return!1;if(void 0!==t.gt&&t.gt>=r)return!1;if(void 0!==t.gte&&t.gte>r)return!1;if(void 0!==t.lt&&r>=t.lt)return!1;if(void 0!==t.lte&&r>t.lte)return!1;if(void 0!==t.within){const[n,i]=t.within;if(n>r||r>i)return!1}if(void 0!==t.outside){const[n,i]=t.outside;if(r>=n&&i>=r)return!1}return!0}function r(t,n,i){const e=t.when;return void 0===e||!0===e||!1!==e&&("function"==typeof e?e(n,i):o(e,n,i))}function u(t,n,i){if(!n||0===n.length)return{};let e={};for(const o of n){if(!r(o,t,i))continue;const n="function"==typeof o.style?o.style(t,i):o.style;n&&(e={...e,...n})}return e}function f(t,n,i,e=t=>t){const o=t??(()=>({}));return n&&0!==n.length?(t,r)=>{const f=e(t),c={...o(t,r)};return Object.assign(c,u(f,n,i(f,r))),c}:o}function c(t,n,i){return t&&0!==t.length?(e,o)=>{const r=u(e,t,n(e,o)),f=i?i(e,o):void 0;return f?{...r,...f}:r}:i}function s(t,n,e,o){if(!t||0===t.length)return o;const r=i(n,e);return(n,i)=>{const e=n&&n.data||n,f=u(e,t,r(e)),c=o?o(n,i):void 0;return c?{...f,...c}:f}}function l(t,i,e,o){return c(t,n(i,e),o)}function d(n,i,e){const o=t(i);return c(n,(t,n)=>({value:o(t),category:n}),e)}export{t as makeRuleValueResolver,n as makeXYRuleContext,i as makeNodeRuleContext,o as matchesThreshold,r as ruleMatches,u as resolveStyleRules,f as composeStyleRules,c as makeStyleRuleStyleFn,s as styleRulesToNodeStyle,l as styleRulesToXYStyle,d as styleRulesToPieceStyle};
@@ -0,0 +1 @@
1
+ import{hatchPatternDef as t,isHatchFill as e,resolveResponsiveRules as n,useObservationSelector as r}from"./chunk-chunk-2WVCH4PL.module.min.js";import{SEQUENTIAL_INTERPOLATORS as o,glyphFractionClipRect as i,glyphPlacement as s,resolveGlyphPaint as a,schemeCategory10 as l,schemeSet3 as c,schemeTableau10 as d,symbolPathString as u}from"./chunk-chunk-NO4MCQVD.module.min.js";import{createStore as h}from"./chunk-chunk-DSNGDNJY.module.min.js";var y=Object.freeze([]);function f(t){if(!t)return y;let e=!1;for(let n=0;t.length>n;n++){const r=t[n];if(null==r||"object"!=typeof r){e=!0;break}}if(!e)return t;const n=[];for(const e of t)null!=e&&"object"==typeof e&&n.push(e);return n}var p=/^\d{4}-\d{1,2}$/;function m(t){const e=t.trim();if(!e||!Number.isNaN(Number(e)))return NaN;const n=p.test(e)?e+"-01":e;if(n===e&&10>e.length)return NaN;const r=Date.parse(n);return Number.isFinite(r)?r:NaN}function g(t){return t instanceof Date?t.getTime():"string"==typeof t?m(t):+t}function k(t,e){if(!t||!e)return{data:t,failed:!1};let n=!1,r=!1;const o=t.map(t=>{const o=t[e];if("string"!=typeof o)return t;const i=m(o);return n=!0,Number.isFinite(i)?{...t,[e]:i}:(r=!0,{...t,[e]:NaN})});return{data:n?o:t,failed:r}}var $=22;function x(t){return"string"==typeof t&&t.length>0}function b(t,e,n=!1){const r=n?e?58:34:e?36:0;return r>t.top?{...t,top:r}:t}function v(t,e){return b(t,x(e))}import*as w from"react";import{arc as M}from"d3-shape";function A(t){return(t.tl??0)>0||(t.tr??0)>0||(t.br??0)>0||(t.bl??0)>0}function W(t){const e=t.cornerRadii;if(!e)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(t.w,t.h)/2,r=t=>Math.max(0,Math.min(t??0,n));return{tl:r(e.tl),tr:r(e.tr),br:r(e.br),bl:r(e.bl)}}var L=(t,e)=>({x:t*Math.cos(e),y:t*Math.sin(e)});function P(t){const{innerRadius:e,outerRadius:n,startAngle:r,endAngle:o}=t,i=0>=e;if(0>=(t.cornerRadius??0)||!t.roundStart&&!t.roundEnd){if(i){const t=L(n,r),e=L(n,o);return`M0,0 L${t.x},${t.y} A${n},${n} 0 ${o-r>Math.PI?1:0} 1 ${e.x},${e.y} Z`}const t=L(n,r),s=L(n,o),a=L(e,o),l=L(e,r),c=o-r>Math.PI?1:0;return`M${t.x},${t.y} A${n},${n} 0 ${c} 1 ${s.x},${s.y} L${a.x},${a.y} A${e},${e} 0 ${c} 0 ${l.x},${l.y} Z`}const s=Math.max(0,Math.min(t.cornerRadius??0,(n-e)/2));if(0===s)return P({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const a=Math.asin(Math.min(1,s/Math.max(1e-9,n-s))),l=i?0:Math.asin(Math.min(1,s/Math.max(1e-9,e+s))),c=o-r,d=t.roundStart&&t.roundEnd?c/2:c,u=!!t.roundStart&&d>a,h=!!t.roundEnd&&d>a;if(!u&&!h)return P({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const y=r+(u?a:0),f=o-(h?a:0),p=r+(u?l:0),m=o-(h?l:0),g=L(n,y),k=L(n,f),$=(n-s)*Math.cos(a),x=L($,r),b=L($,o),v=i?null:L(e,m),w=i?null:L(e,p),M=i?0:(e+s)*Math.cos(l),A=i?null:L(M,r),W=i?null:L(M,o),S=f-y>Math.PI?1:0,O=i?0:m-p>Math.PI?1:0;let R="";if(u)R+=`M${x.x},${x.y}`,R+=` A${s},${s} 0 0 1 ${g.x},${g.y}`;else{const t=L(n,r);R+=`M${t.x},${t.y}`}if(h)R+=` A${n},${n} 0 ${S} 1 ${k.x},${k.y}`,R+=` A${s},${s} 0 0 1 ${b.x},${b.y}`;else{const t=L(n,o);R+=` A${n},${n} 0 ${S} 1 ${t.x},${t.y}`}if(i)R+=" L0,0";else{if(h)R+=` L${W.x},${W.y}`,R+=` A${s},${s} 0 0 1 ${v.x},${v.y}`;else{const t=L(e,o);R+=` L${t.x},${t.y}`}if(u)R+=` A${e},${e} 0 ${O} 0 ${w.x},${w.y}`,R+=` A${s},${s} 0 0 1 ${A.x},${A.y}`;else{const t=L(e,r);R+=` A${e},${e} 0 ${O} 0 ${t.x},${t.y}`}}return R+=" Z",R}import{jsx as S,jsxs as O}from"react/jsx-runtime";var R={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function T(t,n="#4e79a7"){return e(t)?t.background&&"transparent"!==t.background?t.background:n:t&&"string"==typeof t?t:n}function I(t,e,n){const r=u(t.symbolType,t.size,t.path);return S("path",{d:r,transform:t.rotation?`translate(${t.x},${t.y}) rotate(${180*t.rotation/Math.PI})`:`translate(${t.x},${t.y})`,fill:t.style.fill?T(t.style.fill):"none",opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},`${n??""}symbol-${e}`)}function N(t,e,n,r){const o=t.glyph;if(!o?.parts?.length||0>=t.size)return null;const l=s(o,t.size);if(0>=l.scale)return null;const c=`translate(${e},${n})${t.rotation?` rotate(${180*t.rotation/Math.PI})`:""} translate(${l.offsetX},${l.offsetY}) scale(${l.scale})`,d=t.color??("string"==typeof t.style.fill?t.style.fill:void 0),u=i(o,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal"),h=u?j(r+"-clip"):void 0,y=(t.style.opacity??1)*(t._decayOpacity??1)*(t.style.fillOpacity??1),f=e=>o.parts.map((n,r)=>{const o=e?"none"===n.fill?void 0:e:a(n.fill,d,t.accent),i=e?n.stroke&&"none"!==n.stroke?e:void 0:a(n.stroke??"none",d,t.accent);return o||i?S("path",{d:n.d,fill:o??"none",stroke:i,strokeWidth:i?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},r):null});return O("g",{transform:c,opacity:1===y?void 0:y,children:[u&&h&&S("clipPath",{id:h,children:S("rect",{x:u.x,y:u.y,width:u.width,height:u.height})}),u&&t.ghostColor?S("g",{children:f(t.ghostColor)}):null,u&&h?S("g",{clipPath:`url(#${h})`,children:f()}):f()]},r)}function j(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}function C(n,r,o){switch(n.type){case"line":{const t=n;if(0===t.path.length)return null;const e="M"+t.path.map(([t,e])=>`${t},${e}`).join("L");return S("path",{d:e,fill:"none",stroke:t.style.stroke||"#4e79a7",strokeWidth:t.style.strokeWidth||2,strokeDasharray:t.style.strokeDasharray,opacity:t.style.opacity},"line-"+r)}case"area":{const i=n;if(0===i.topPath.length)return null;const s=`M${i.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...i.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`,a=`${o?o+"-":""}area-${r}-hatch`,l=e(i.style.fill)?t(i.style.fill,a):void 0,c=l?`url(#${a})`:T(i.style.fill);if(i.clipRect){const t=`${o?o+"-":""}area-clip-${r}`;return O("g",{children:[O("defs",{children:[l,S("clipPath",{id:t,children:S("rect",{x:i.clipRect.x,y:i.clipRect.y,width:i.clipRect.width,height:i.clipRect.height})})]}),S("path",{d:s,fill:c,fillOpacity:i.style.fillOpacity??i.style.opacity??.7,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,clipPath:`url(#${t})`})]},"area-"+r)}return O(w.Fragment,{children:[l&&S("defs",{children:l}),S("path",{d:s,fill:c,fillOpacity:i.style.fillOpacity??i.style.opacity??.7,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},"area-"+r)}case"point":{const i=n,s=`${o?o+"-":""}point-${r}-hatch`,a=e(i.style.fill)?t(i.style.fill,s):void 0;return O(w.Fragment,{children:[a&&S("defs",{children:a}),S("circle",{cx:i.x,cy:i.y,r:i.r,fill:a?`url(#${s})`:T(i.style.fill),opacity:i.style.opacity??.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},"point-"+r)}case"symbol":return I(n,r);case"glyph":return N(n,n.x,n.y,`${o??""}glyph-${n.pointId??r}`);case"rect":{const i=n,s=`${o?o+"-":""}xyrect-${r}-hatch`,a=e(i.style.fill)?t(i.style.fill,s):void 0;return O(w.Fragment,{children:[a&&S("defs",{children:a}),S("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:a?`url(#${s})`:T(i.style.fill),opacity:i.style.opacity,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},"rect-"+r)}case"heatcell":{const t=n;if(t.showValues&&null!=t.value&&t.w>=20&&t.h>=20){const e=t.valueFormat?t.valueFormat(t.value):Number.isInteger(t.value)?t.value+"":100>Math.abs(t.value)?1>Math.abs(t.value)?t.value.toPrecision(3):t.value.toFixed(1):t.value.toFixed(0),[n,o,i]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t.fill),s=.299*n+.587*o+.114*i>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h)));return O("g",{children:[S("rect",{x:t.x,y:t.y,width:t.w,height:t.h,fill:t.fill}),S("text",{x:t.x+t.w/2,y:t.y+t.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px",children:e})]},"heatcell-"+r)}return S("rect",{x:t.x,y:t.y,width:t.w,height:t.h,fill:t.fill},"heatcell-"+r)}case"candlestick":{const t=n,e=Math.min(t.openY,t.closeY),o=Math.max(Math.abs(t.openY-t.closeY),1),i=t.isUp?t.upColor:t.downColor;return O("g",{children:[S("line",{x1:t.x,y1:t.highY,x2:t.x,y2:t.lowY,stroke:t.wickColor,strokeWidth:t.wickWidth}),S("rect",{x:t.x-t.bodyWidth/2,y:e,width:t.bodyWidth,height:o,fill:i,stroke:i,strokeWidth:1})]},"candle-"+r)}default:return null}}function D(n,r){switch(n.type){case"circle":{const o=n,i=e(o.style.fill)?t(o.style.fill,`net-circle-${r}-hatch`):void 0;return O(w.Fragment,{children:[i&&S("defs",{children:i}),S("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:i?`url(#net-circle-${r}-hatch)`:T(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})]},"net-circle-"+r)}case"rect":{const o=n,i=e(o.style.fill)?t(o.style.fill,`net-rect-${r}-hatch`):void 0;return O(w.Fragment,{children:[i&&S("defs",{children:i}),S("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:i?`url(#net-rect-${r}-hatch)`:T(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})]},"net-rect-"+r)}case"arc":{const o=n,i=M().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)(R)||"",s=e(o.style.fill)?t(o.style.fill,`net-arc-${r}-hatch`):void 0;return O(w.Fragment,{children:[s&&S("defs",{children:s}),S("path",{d:i,transform:`translate(${o.cx},${o.cy})`,fill:s?`url(#net-arc-${r}-hatch)`:T(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity})]},"net-arc-"+r)}case"symbol":{const t=n,e=u(t.symbolType,t.size,t.path);return S("path",{d:e,transform:t.rotation?`translate(${t.cx},${t.cy}) rotate(${180*t.rotation/Math.PI})`:`translate(${t.cx},${t.cy})`,fill:t.style.fill?T(t.style.fill):"none",stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity},"net-symbol-"+r)}case"glyph":return N(n,n.cx,n.cy,"net-glyph-"+(n.id??r));default:return null}}function F(t,e){switch(t.type){case"line":return S("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity},"net-edge-"+e);case"bezier":{const n=t;return S("path",{d:n.pathD,fill:T(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+e)}case"ribbon":{const n=t;return S("path",{d:n.pathD,fill:T(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+e)}case"curved":{const n=t;return S("path",{d:n.pathD,fill:T(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+e)}default:return null}}function q(t,e){return S("text",{x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"var(--semiotic-text, #333)",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,children:t.text},"net-label-"+e)}function z(n,r,o){const i=("category"in n?n.category:void 0)||("group"in n?n.group:void 0)||"",s=t=>`ord-${n.type}-${i}-${r}-${t}`,a=`ord-${n.type}-${i}-${r}`;switch(n.type){case"rect":{const r=n,o=j(a)+"-grad",i=function(t,e){const n=t.fillGradient;if(!n||"object"!=typeof n)return null;let r=t.x,o=t.y,i=t.x,s=t.y+t.h;"bottom"===t.roundedEdge?(o=t.y+t.h,s=t.y):"right"===t.roundedEdge?(r=t.x+t.w,o=t.y,i=t.x,s=t.y):"left"===t.roundedEdge&&(r=t.x,o=t.y,i=t.x+t.w,s=t.y);const a=[];if("colorStops"in n){const t=n.colorStops.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));if(2>t.length)return null;for(let e=0;t.length>e;e++)a.push(S("stop",{offset:t[e].offset,stopColor:t[e].color},e))}else{const e=T(t.style.fill);a.push(S("stop",{offset:0,stopColor:e,stopOpacity:n.topOpacity},"0")),a.push(S("stop",{offset:1,stopColor:e,stopOpacity:n.bottomOpacity},"1"))}return S("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:r,y1:o,x2:i,y2:s,children:a})}(r,o);let s,l;if(i)l=`url(#${o})`;else if(e(r.style.fill)){const e=j(a)+"-hatch";s=t(r.style.fill,e),l=`url(#${e})`}else l=T(r.style.fill);const c=i||s?O("defs",{children:[i,s]}):null;if(r.cornerRadii&&A(r.cornerRadii)){const t=function(t){const{x:e,y:n,w:r,h:o}=t,{tl:i,tr:s,br:a,bl:l}=W(t);let c=`M${e+i},${n}`;return c+=` L${e+r-s},${n}`,s>0&&(c+=` A${s},${s} 0 0 1 ${e+r},${n+s}`),c+=` L${e+r},${n+o-a}`,a>0&&(c+=` A${a},${a} 0 0 1 ${e+r-a},${n+o}`),c+=` L${e+l},${n+o}`,l>0&&(c+=` A${l},${l} 0 0 1 ${e},${n+o-l}`),c+=` L${e},${n+i}`,i>0&&(c+=` A${i},${i} 0 0 1 ${e+i},${n}`),c+=" Z",c}(r);return O(w.Fragment,{children:[c,S("path",{d:t,fill:l,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},a)}if(r.roundedTop&&r.roundedTop>0){const t=Math.min(r.roundedTop,r.w/2,r.h/2),{x:e,y:n,w:o,h:i}=r;let s;switch(r.roundedEdge){case"right":s=`M${e},${n} L${e+o-t},${n} A${t},${t} 0 0 1 ${e+o},${n+t} L${e+o},${n+i-t} A${t},${t} 0 0 1 ${e+o-t},${n+i} L${e},${n+i} Z`;break;case"left":s=`M${e+o},${n} L${e+t},${n} A${t},${t} 0 0 0 ${e},${n+t} L${e},${n+i-t} A${t},${t} 0 0 0 ${e+t},${n+i} L${e+o},${n+i} Z`;break;case"bottom":s=`M${e},${n} L${e+o},${n} L${e+o},${n+i-t} A${t},${t} 0 0 1 ${e+o-t},${n+i} L${e+t},${n+i} A${t},${t} 0 0 1 ${e},${n+i-t} Z`;break;default:s=`M${e},${n+i} L${e},${n+t} A${t},${t} 0 0 1 ${e+t},${n} L${e+o-t},${n} A${t},${t} 0 0 1 ${e+o},${n+t} L${e+o},${n+i} Z`}return O(w.Fragment,{children:[c,S("path",{d:s,fill:l,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},a)}return O(w.Fragment,{children:[c,S("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:l,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},a)}case"point":{const t=n;return S("circle",{cx:t.x,cy:t.y,r:t.r,fill:T(t.style.fill),opacity:t.style.opacity??.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},a)}case"symbol":return I(n,r,o);case"glyph":return N(n,n.x,n.y,`${o??""}ord-glyph-${n.pointId??r}`);case"wedge":{const t=n;if(t._gradientBand&&t._gradientBand.colors.length>0){const e=j(`${o?o+"-":""}gauge-grad-${t.category||a}-${r}`),{clipPath:n,slices:i}=function(t){const e=P({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundStart,roundEnd:t.roundEnd}),n=[],r=t.colors;if(r.length>0){const e=(t.endAngle-t.startAngle)/r.length;for(let o=0;r.length>o;o++)n.push({d:P({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+o*e,endAngle:t.endAngle}),color:r[o]})}return{clipPath:e,slices:n}}({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundedEnds?.start??!0,roundEnd:t.roundedEnds?.end??!0,colors:t._gradientBand.colors});return O("g",{transform:`translate(${t.cx},${t.cy})`,opacity:t.style.opacity,fillOpacity:t.style.fillOpacity,children:[S("defs",{children:S("clipPath",{id:e,children:S("path",{d:n})})}),S("g",{clipPath:`url(#${e})`,children:i.map((t,e)=>S("path",{d:t.d,fill:T(t.color)},e))}),t.style.stroke&&"none"!==t.style.stroke&&S("path",{d:n,fill:"none",stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},a)}let e;if(t.roundedEnds)e=P({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundedEnds.start,roundEnd:t.roundedEnds.end});else{const n=M().innerRadius(t.innerRadius).outerRadius(t.outerRadius).startAngle(t.startAngle+Math.PI/2).endAngle(t.endAngle+Math.PI/2);t.cornerRadius&&n.cornerRadius(t.cornerRadius),e=n(R)||""}return S("path",{d:e,transform:`translate(${t.cx},${t.cy})`,fill:T(t.style.fill),stroke:t.style.stroke,strokeWidth:t.style.strokeWidth,opacity:t.style.opacity},a)}case"boxplot":{const t=n,e=t.columnWidth/2;return O("g","vertical"===t.projection?{children:[S("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1}),S("rect",{x:t.x-e,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:T(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),S("line",{x1:t.x-e,y1:t.medianPos,x2:t.x+e,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2}),S("line",{x1:t.x-.5*e,y1:t.minPos,x2:t.x+.5*e,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:1}),S("line",{x1:t.x-.5*e,y1:t.maxPos,x2:t.x+.5*e,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1})]}:{children:[S("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:1}),S("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-e,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:T(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),S("line",{x1:t.medianPos,y1:t.y-e,x2:t.medianPos,y2:t.y+e,stroke:t.style.stroke||"#333",strokeWidth:2}),S("line",{x1:t.minPos,y1:t.y-.5*e,x2:t.minPos,y2:t.y+.5*e,stroke:t.style.stroke||"#333",strokeWidth:1}),S("line",{x1:t.maxPos,y1:t.y-.5*e,x2:t.maxPos,y2:t.y+.5*e,stroke:t.style.stroke||"#333",strokeWidth:1})]},a)}case"violin":{const t=n,e=[S("path",{d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:T(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:t.style.strokeWidth||1},s("path"))];if(t.iqrLine&&t.bounds){const n=t.bounds,r=n.x+n.width/2,o=n.y+n.height/2;n.height>n.width?e.push(S("line",{x1:r,y1:t.iqrLine.q1Pos,x2:r,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2},s("iqr")),S("circle",{cx:r,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},s("med"))):e.push(S("line",{x1:t.iqrLine.q1Pos,y1:o,x2:t.iqrLine.q3Pos,y2:o,stroke:t.style.stroke||"#333",strokeWidth:2},s("iqr")),S("circle",{cx:t.iqrLine.medianPos,cy:o,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},s("med")))}return S("g",{children:e},a)}case"connector":return S("line",{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity??.5},a);case"trapezoid":{const t=n,e=t.points.map(t=>`${t[0]},${t[1]}`).join(" ");return S("polygon",{points:e,fill:T(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},a)}default:return null}}function H(n,r){switch(n.type){case"geoarea":{const o=n;if(!o.pathData)return null;const i=e(o.style.fill)?t(o.style.fill,`geoarea-${r}-hatch`):void 0;return O(w.Fragment,{children:[i&&S("defs",{children:i}),S("path",{d:o.pathData,fill:i?`url(#geoarea-${r}-hatch)`:T(o.style.fill,"#e0e0e0"),fillOpacity:o.style.fillOpacity??1,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth||.5,strokeDasharray:o.style.strokeDasharray,opacity:o._decayOpacity??1})]},"geoarea-"+r)}case"point":{const o=n,i=e(o.style.fill)?t(o.style.fill,`geopoint-${r}-hatch`):void 0;return O(w.Fragment,{children:[i&&S("defs",{children:i}),S("circle",{cx:o.x,cy:o.y,r:o.r,fill:i?`url(#geopoint-${r}-hatch)`:T(o.style.fill),fillOpacity:o.style.fillOpacity??.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o._decayOpacity??o.style.opacity??1})]},"point-"+r)}case"line":{const t=n;if(2>t.path.length)return null;const e="M"+t.path.map(t=>`${t[0]},${t[1]}`).join("L");return S("path",{d:e,fill:"none",stroke:t.style.stroke||"#4e79a7",strokeWidth:t.style.strokeWidth||1.5,strokeDasharray:t.style.strokeDasharray,opacity:t.style.opacity??1},"line-"+r)}case"glyph":return N(n,n.x,n.y,"geo-glyph-"+(n.pointId??r));default:return null}}var E="undefined"==typeof window||"undefined"==typeof document;function B(t){return"touch"===t?"touch":"pointer"}function _(t){const e=t.target;return e instanceof Element&&e!==t.currentTarget&&null!=e.closest("button, a[href], input, select, textarea, summary, [contenteditable='true'], [role='button'], [role='link'], [role='checkbox'], [role='radio'], [role='switch']")}function G(t){const{onObservation:e,datum:n,x:r=0,y:o=0,chartType:i,chartId:s,context:a,timestamp:l=Date.now()}=t;e&&(n?(e({type:"hover",datum:n,x:r,y:o,timestamp:l,chartType:i,chartId:s}),"focus"===a?.type&&e({type:"focus",datum:n,inputType:"touch"===a.inputType?"pointer":a.inputType,timestamp:l,chartType:i,chartId:s})):e({type:"hover-end",timestamp:l,chartType:i,chartId:s}))}function V(t){const{onObservation:e,datum:n,x:r=0,y:o=0,chartType:i,chartId:s,context:a,timestamp:l=Date.now()}=t;e&&(n?(e({type:"click",datum:n,x:r,y:o,timestamp:l,chartType:i,chartId:s}),"activate"===a?.type&&e({type:"activate",datum:n,inputType:a.inputType,timestamp:l,chartType:i,chartId:s})):e({type:"click-end",timestamp:l,chartType:i,chartId:s}))}import{useId as Z,useMemo as Y,useCallback as U}from"react";function X(t){const e=[];for(const[n,r]of Object.entries(t.fields))if("point"===r.type)e.push(t=>r.values.has(t[n]));else{const[t,o]=r.range;e.push(e=>{const r=e[n];return r>=t&&o>=r})}return t=>e.every(e=>e(t))}function Q(t,e){let n=t.get(e);return n||(n={name:e,resolution:"union",clauses:new Map},t.set(e,n)),n}function J(t,e){if(t.type!==e.type)return!1;if("interval"===t.type&&"interval"===e.type)return t.range[0]===e.range[0]&&t.range[1]===e.range[1];if("point"===t.type&&"point"===e.type){if(t.values.size!==e.values.size)return!1;for(const n of t.values)if(!e.values.has(n))return!1;return!0}return!1}var[K,tt]=h(t=>({selections:new Map,setClause(e,n){t(t=>{const r=t.selections.get(e),o=r?.clauses.get(n.clientId);if(o&&function(t,e){if(t.clientId!==e.clientId||t.type!==e.type)return!1;const n=Object.entries(t.fields);if(n.length!==function(t){let e=0;for(const n in t)e++;return e}(e.fields))return!1;for(const[t,r]of n){const n=e.fields[t];if(!n||!J(r,n))return!1}return!0}(o,n))return{};const i=new Map(t.selections),s=Q(i,e),a=new Map(s.clauses);return a.set(n.clientId,n),i.set(e,{...s,clauses:a}),{selections:i}})},clearClause(e,n){t(t=>{const r=t.selections.get(e);if(!r||!r.clauses.has(n))return{};const o=new Map(t.selections),i=new Map(r.clauses);return i.delete(n),o.set(e,{...r,clauses:i}),{selections:o}})},setResolution(e,n){t(t=>{const r=t.selections.get(e);if(r?.resolution===n)return{};const o=new Map(t.selections),i=Q(o,e);return o.set(e,{...i,resolution:n}),{selections:o}})},clearSelection(e){t(t=>{const n=t.selections.get(e);if(!n||0===n.clauses.size)return{};const r=new Map(t.selections);return r.set(e,{...n,clauses:new Map}),{selections:r}})}}));import{useSyncExternalStore as et}from"react";var nt={positions:new Map},rt=new Set;function ot(){for(const t of rt)t()}function it(t,e){const n=nt.positions.get(t);if(n?.locked)return;if(!n||n.sourceId!==e)return;const r=new Map(nt.positions);r.delete(t),nt={positions:r},ot()}function st(t,e){const n=nt.positions.get(t);if(!n?.locked)return;if(e&&n.sourceId!==e)return;const r=new Map(nt.positions);r.delete(t),nt={positions:r},ot()}function at(){return nt}function lt(t){return rt.add(t),()=>rt.delete(t)}var ct={positions:new Map};function dt(){return()=>{}}function ut(){return ct}function ht(t){const e=et(t?lt:dt,t?at:ut,t?at:ut);return t?e.positions.get(t)??null:null}function yt(t){const e=Z(),n=t.clientId||e,{name:r}=t,o=tt(t=>t.selections.get(r)),i=tt(t=>t.setClause),s=tt(t=>t.clearClause),a=Y(()=>!!o&&o.clauses.size>0,[o]);return{predicate:Y(()=>o&&0!==o.clauses.size?function(t,e){const n=[];for(const[r,o]of t.clauses)"crossfilter"===t.resolution&&r===e||n.push(X(o));return 0===n.length?()=>!0:"intersect"===t.resolution?t=>n.every(e=>e(t)):t=>n.some(e=>e(t))}(o,n):()=>!0,[o,n]),isActive:a,selectPoints:U(t=>{const e={};let o=!1;for(const[n,r]of Object.entries(t))e[n]={type:"point",values:new Set(r)},o=!0;o&&i(r,{clientId:n,type:"point",fields:e})},[n,r,i]),selectInterval:U(t=>{const e={};let o=!1;for(const[n,r]of Object.entries(t))e[n]={type:"interval",range:r},o=!0;o&&i(r,{clientId:n,type:"interval",fields:e})},[n,r,i]),clear:U(()=>{s(r,n)},[s,r,n]),clientId:n}}function ft(t){return 2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1]}function pt(t){const{name:e,xField:n,yField:r}=t,{predicate:o,isActive:i,selectInterval:s,clear:a}=yt({name:e,fields:[n,r].filter(Boolean)}),l=n&&r?"xyBrush":n?"xBrush":"yBrush",c=U(t=>{if(!t)return void a();const e={};"xyBrush"===l&&function(t){return 2===t.length&&Array.isArray(t[0])&&2===t[0].length&&Array.isArray(t[1])&&2===t[1].length}(t)?(n&&(e[n]=[Math.min(t[0][0],t[1][0]),Math.max(t[0][0],t[1][0])]),r&&(e[r]=[Math.min(t[0][1],t[1][1]),Math.max(t[0][1],t[1][1])])):"xBrush"===l&&ft(t)?n&&(e[n]=[Math.min(t[0],t[1]),Math.max(t[0],t[1])]):"yBrush"===l&&ft(t)&&r&&(e[r]=[Math.min(t[0],t[1]),Math.max(t[0],t[1])]),mt(e)&&s(e)},[l,n,r,s,a]);return{brushInteraction:Y(()=>({brush:l,during:c,end:c}),[l,c]),predicate:o,isActive:i,clear:a}}function mt(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}function gt(t){return t?"string"==typeof t?{name:t}:t:null}import{useMemo as kt,useCallback as $t,useState as xt,useId as bt,useEffect as vt,useRef as wt}from"react";import{scaleOrdinal as Mt}from"d3-scale";var At={category10:l,tableau10:d,set3:c,...o},Wt=l,Lt=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Pt=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function St(t,e,n){if("function"==typeof e){const r=e(t);return n&&r&&"string"==typeof r&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||Pt.has(e)}(r)?n(r):r}const r=t?.[e]+"";return n?n(r):Wt[Math.abs(function(t){let e=0;for(let n=0;t.length>n;n++)e=(e<<5)-e+t.charCodeAt(n),e&=e;return Math.abs(e)}(r))%Wt.length]}function Ot(t,e){if(null==e||!Object.prototype.hasOwnProperty.call(t,e))return;const n=t[e];return"string"==typeof n&&n.length>0?n:void 0}function Rt(t,e,n="category10"){if(n&&"object"==typeof n&&!Array.isArray(n)){const t=n;return e=>Ot(t,e)??"#999"}const r=Array.from(new Set(t.map(t=>t?.[e]).filter(t=>null!=t).map(t=>t+""))),o=r.every(t=>!isNaN(Number(t)));if(Array.isArray(n))return Mt().domain(r).range(n).unknown("#999");const i=At[n]||At.category10;if(o&&"function"==typeof i){let t=-1/0;for(const e of r){const n=Number(e);n>t&&(t=n)}return e=>i(Number(e)/t)}{const t=Array.isArray(i)?i:Wt;return Mt().domain(r).range(t).unknown("#999")}}function Tt(t,e,n=[3,20],r){let o;if(o="function"==typeof e?e(t):t?.[e],!r)return o;const[i,s]=r,[a,l]=n;if(s===i)return(a+l)/2;let c=(o-i)/(s-i);return 0>c?c=0:c>1&&(c=1),a+c*(l-a)}function It(t,e,n){const r=t.xValue??e?.[n];if(null==r)return null;const o=Number(r);return Number.isFinite(o)?o:null}function Nt(t){let e=t.data||t.datum||t;return Array.isArray(e)&&(e=e[0]),null!=t.xValue&&e&&"object"==typeof e&&!Array.isArray(e)&&null==e.xValue?{...e,xValue:t.xValue}:e||{}}var jt="#007bff",Ct=[],Dt={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function Ft(t,e={}){const n=e.mobileSemantics?.interaction,r="number"==typeof n?.targetSize?n.targetSize:"number"==typeof e.mobileSemantics?.minimumHitTarget?e.mobileSemantics.minimumHitTarget:void 0,o="mobile"===e.mode||"number"==typeof e.width&&480>=e.width,i=!!n||void 0!==r,s=t&&"object"==typeof t?t:void 0;if(!1===t||!1===s?.enabled||void 0===t&&!o&&!i)return Dt;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??r??44,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??44,standardControls:a.standardControls??!1}}function qt({selection:t,linkedHover:e,fallbackFields:n=Ct,unwrapData:o=!1,onObservation:i,chartType:s,chartId:a,onClick:l,hoverHighlight:c,colorByField:d,mobileInteraction:u}){const h=bt(),y=kt(()=>function(t,e){return t?!0===t?{name:"hover",fields:e||[]}:"string"==typeof t?{name:t,fields:e||[]}:{name:t.name||"hover",fields:t.fields||e||[],mode:t.mode,xField:t.xField,seriesField:t.seriesField}:null}(e,n),[e,n]),f=kt(()=>"series"===y?.mode?[y.seriesField||d||n[0]].filter(t=>!!t):y?.fields||n,[y,d,n]),p=yt({name:t?.name||"__unused__",fields:f}),m=function(t){const e=t.name||"hover",{fields:n}=t,{predicate:r,isActive:o,selectPoints:i,clear:s}=yt({name:e,fields:n});return{onHover:U(t=>{if(!t)return void s();const e={};for(const r of n){const n=t[r];void 0!==n&&(e[r]=[n])}mt(e)&&i(e)},[n,i,s]),predicate:r,isActive:o}}({name:y?.name||"hover",fields:f}),g=r(t=>t.pushObservation),k=$t(t=>{i?.(t),g?.(t)},[i,g]),$=t?{isActive:p.isActive,predicate:p.predicate}:null,[x,b]=xt(null),v=wt(!1),w=d||n[0],M=kt(()=>{if(!c||null==x||!w)return null;const t=x,e=w;return{isActive:!0,predicate:n=>("string"==typeof n[e]?n[e]:(n[e]??"")+"")===t}},[c,x,w]),A=$t((t,n)=>{const r=!t&&v.current&&!!u?.enabled&&u.tapToLockTooltip;if(e)if(t){let e=t.data||t.datum||t;if(Array.isArray(e)&&(e=e[0]),"x-position"===y?.mode&&y.xField){const n=It(t,e,y.xField);null!=n&&function(t,e,n){const r=nt.positions.get(t);r?.locked||r&&r.xValue===e&&r.sourceId===n||(nt={positions:new Map(nt.positions).set(t,{xValue:e,sourceId:n})},ot())}(y.name||"hover",n,h)}"x-position"!==y?.mode&&m.onHover(e)}else"x-position"!==y?.mode||r||it(y.name||"hover",h),"x-position"===y?.mode||r||m.onHover(null);if(c&&w)if(t){let e=t.data||t.datum||t;Array.isArray(e)&&(e=e[0]);const n=e?.[w];b(null!=n?n+"":null)}else r||b(null);(i||g)&&G({onObservation:k,datum:t?Nt(t):null,x:t?.x,y:t?.y,chartType:s||"unknown",chartId:a,context:n})},[e,m,y,h,i,s,a,g,k,c,w,u]),W=$t((n=!0)=>{v.current=!1,e&&"x-position"!==y?.mode&&m.onHover(null),t&&u?.tapToSelect&&p.clear(),n&&c&&b(null),"x-position"===y?.mode&&(st(y.name||"hover",h),it(y.name||"hover",h))},[e,y,m,t,u,p,c,h]),L=$t((n,r)=>{const o=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),d=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===y?.mode&&y.xField&&n){let t=n.data||n.datum||n;Array.isArray(t)&&(t=t[0]);const e=It(n,t,y.xField);null!=e&&function(t,e,n){const r=nt.positions.get(t);if(r?.locked){const e=new Map(nt.positions);return e.delete(t),nt={positions:e},ot(),!1}nt={positions:new Map(nt.positions).set(t,{xValue:e,sourceId:n,locked:!0})},ot()}(y.name||"hover",e,h)}if(o)if(n){v.current=!0;const r=Nt(n);if(e&&"x-position"!==y?.mode&&m.onHover(r),t&&u?.tapToSelect&&f.length>0){const t={};for(const e of f){const n=r[e];void 0!==n&&(t[e]=[n])}(function(t){if(!t)return!1;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1})(t)&&p.selectPoints(t)}if(c&&w){const t=r?.[w];b(null!=t?t+"":null)}}else d&&W();if(n||d){if(n&&l){let t=n.data||n.datum||n;Array.isArray(t)&&(t=t[0]),l(t,{x:n.x??0,y:n.y??0})}(i||g)&&V({onObservation:k,datum:n?Nt(n):null,x:n?.x,y:n?.y,chartType:s||"unknown",chartId:a,context:r})}},[l,i,g,k,s,a,y,h,u,e,m,t,p,f,c,w,W]);return vt(()=>{if(!u?.enabled||"undefined"==typeof document)return;const t=t=>{"Escape"===t.key&&v.current&&W()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[u?.enabled,W]),vt(()=>()=>{v.current&&W(!1)},[W]),vt(()=>{if("x-position"!==y?.mode)return;const t=y.name||"hover";return()=>{st(t,h),it(t,h)}},[y?.mode,y?.name,h]),{activeSelectionHook:$,hoverSelectionHook:M,customHoverBehavior:A,customClickBehavior:L,crosshairSourceId:h}}var zt={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}};function Ht(t,e,r){const o=zt[t||"primary"],i=t&&"primary"!==t||!r?.width?o.width:r.width,s=t&&"primary"!==t||!r?.height?o.height:r.height,a={...e,mode:t},l=n(a,{width:e.width??i,height:e.height??s}).props,c=l.mode||t,d=zt[c||"primary"],u="context"===c||"sparkline"===c,h=c&&"primary"!==c||!r?.width?d.width:r.width;return{width:l.width??h,height:l.height??(c&&"primary"!==c||!r?.height?d.height:r.height),showAxes:l.showAxes??d.showAxes,showGrid:l.showGrid??d.showGrid,enableHover:l.enableHover??(!!l.linkedHover||d.enableHover),showLegend:l.showLegend??d.showLegend,showLabels:l.showLabels??d.showLabels,title:u?void 0:l.title,description:l.description,summary:l.summary,accessibleTable:l.accessibleTable,xLabel:u?void 0:l.xLabel,yLabel:u?void 0:l.yLabel,categoryLabel:u?void 0:l.categoryLabel,valueLabel:u?void 0:l.valueLabel,marginDefaults:Et(d.marginDefaults,l.showCategoryTicks,l.orientation),compactMode:u,mobileInteraction:Ft(l.mobileInteraction,{mode:c,width:l.width??h,mobileSemantics:l.mobileSemantics}),mobileSemantics:l.mobileSemantics}}function Et(t,e,n){if(!1!==e)return t;const r={...t};return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}function Bt(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function _t(t,e){return Math.min((t-e.startTime)/e.duration,1)}function Gt(t,e,n){return t+(e-t)*n}function Vt(){return"undefined"!=typeof performance?performance.now():Date.now()}function Zt(t,e){if(!1===t)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:t?!0===t?{duration:300}:{duration:t.duration??300,easing:"linear"===t.easing?"linear":"ease-out"}:e,introEnabled:!(n||!t||!0!==t&&!1===t.intro)}}function Yt(t){return"object"==typeof t&&null!==t&&"legendGroups"in t}function Ut(t){return"object"==typeof t&&null!==t&&"gradient"in t}import{jsx as Xt}from"react/jsx-runtime";var Qt={secondary:0,primary:3},Jt=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}";function Kt(t){return!0===t?._annotationDeferred}function te(t){return"blended"===t?.cohesion||"layer"===t?.cohesion?t.cohesion:null}function ee(t){const e=t?.provenance?.confidence;return"number"==typeof e&&Number.isFinite(e)?Math.max(0,Math.min(1,e)):null}function ne(t){return Math.max(.72,.95-.06*t)}function re(t){const e=t.map((t,e)=>{return{p:t,i:e,emphasis:(n=t.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:ee(t.annotation),readingOrder:null,rank:1};var n}),n=e.some(t=>null!=t.emphasis||null!=t.confidence),r=t.some(t=>Kt(t.annotation)),o=t.some(t=>null!=te(t.annotation)),i=t.some(t=>"layer"===te(t.annotation));if(!n&&!r&&!o)return t.map(t=>t.node);const s=e.filter(t=>null==t.emphasis&&null!=t.confidence).slice().sort((t,e)=>(e.confidence??0)-(t.confidence??0)||t.i-e.i);s.forEach((t,e)=>{t.readingOrder=e,t.rank=2-e/Math.max(1,s.length)});for(const t of e)t.emphasis&&(t.rank=Qt[t.emphasis]);const a=e.sort((t,e)=>t.rank-e.rank||t.i-e.i).map(t=>{const{p:e,i:n,emphasis:r,readingOrder:o}=t,i=Kt(e.annotation);let s=e.node;if("primary"===r||"secondary"===r||null!=o){const t=null==r&&null!=o;s=Xt("g",{className:t?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...t?{opacity:ne(o),"data-annotation-reading-order":o}:{},children:e.node},"annotation-emphasis-"+n)}const a=te(e.annotation);return a&&(s=Xt("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),i&&(s=Xt("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return r&&a.unshift(Xt("style",{children:Jt},"annotation-disclosure-style")),i&&a.unshift(Xt("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),a}function oe(t,e,n){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=Object.values(t).filter(t=>"string"==typeof t&&t.length>0);if(e.length>0)return e}if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=At[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:n}function ie(t,e){const n=e&&"object"==typeof e&&!Array.isArray(e)?e:void 0;return 0===t.length?t=>n&&Ot(n,t)||"#4e79a7":e=>{if(n){const t=Ot(n,e);if(t)return t}let r=0;for(let t=0;e.length>t;t++)r=31*r+e.charCodeAt(t)|0;return t[Math.abs(r)%t.length]??"#4e79a7"}}import{jsx as se,jsxs as ae}from"react/jsx-runtime";function le(t,e=120,n=8){if(!t)return[];const r=Math.max(1,Math.floor(e/n)),o=t.split(/\s+/),i=[];let s="";for(const t of o)s&&s.length+1+t.length>r?(i.push(s),s=t):s=s?`${s} ${t}`:t;return s&&i.push(s),i}function ce(t,e,n,r){return"curly"===t?r?`M0,0 C${.6*n},0 ${.4*n},${e/2} ${n},${e/2} C${.4*n},${e/2} ${.6*n},${e} 0,${e}`:`M0,0 C0,${.6*n} ${e/2},${.4*n} ${e/2},${n} C${e/2},${.4*n} ${e},${.6*n} ${e},0`:r?`M0,0 L${n},0 L${n},${e} L0,${e}`:`M0,0 L0,${n} L${e},${n} L${e},0`}function de(t,e,n,r){if(!t)return se("g",{className:"annotation-note"});const{label:o,title:i,orientation:s,align:a,wrap:l=120,noWrap:c}=t;if(!o&&!i)return se("g",{className:"annotation-note"});let d=s;d||(d=Math.abs(e)>Math.abs(n)?"leftRight":"topBottom");let u=a;u&&"dynamic"!==u||(u="topBottom"===d?0>e?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===d?"right"===u?h="end":"middle"===u&&(h="middle"):h=0>e?"end":"start";const y=16,f=i?c?[i]:le(i,l):[],p=o?c?[o]:le(o,l):[],m="leftRight"===d?"end"===h?-4:4:0;let g=0;const k=[],$=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";t.useHTML||t.html?k.push(se("foreignObject",{className:"annotation-note-html",x:"end"===h?m-l:"middle"===h?m-l/2:m,y:-16,width:l,height:Math.max(y,(f.length+p.length)*y+(i&&o?2:0))+y,style:{overflow:"visible"},children:ae("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:$,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===h?"right":"middle"===h?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[i&&se("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),o&&se("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html")):(f.length>0&&(k.push(se("text",{className:"annotation-note-title",fill:$,textAnchor:h,fontWeight:"bold",children:f.map((t,e)=>se("tspan",{x:m,dy:0===e?0:y,children:t},e))},"annotation-note-title")),g=f.length*y),p.length>0&&k.push(se("text",{className:"annotation-note-label",fill:$,textAnchor:h,y:g,children:p.map((t,e)=>se("tspan",{x:m,dy:0===e?0:y,children:t},e))},"annotation-note-label")));let x=null;if((i||o)&&(0!==e||0!==n))if("topBottom"===d){const t=Math.min(l,120);let e=0,n=t;"end"===h?(e=-t,n=0):"middle"===h&&(e=-t/2,n=t/2),x=se("line",{className:"note-line",x1:e,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(f.length+p.length)*y+(p.length>0?y:0);let e=0,n=t;"bottom"===u?(e=-t,n=0):"middle"===u&&(e=-t/2,n=t/2),x=se("line",{className:"note-line",x1:0,x2:0,y1:e,y2:n,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}const b=Math.max(0,f.length+p.length-1)*y;let v=0;return"topBottom"===d?v=0>n?-(b+2):18:"leftRight"===d&&(v="middle"===u?-(b+y+(p.length>0&&f.length>0?2:0))/2+8:"bottom"===u||0>n?-(b+2):18),ae("g",{className:"annotation-note",transform:`translate(${e},${n})`,children:[se("g",{className:"annotation-note-content",transform:0!==v?`translate(0,${v})`:void 0,children:k}),x]})}function ue(t,e,n,r,o){const i=[];switch(t){case"callout-circle":{const t=(e?.radius||0)+(e?.radiusPadding||0);t>0&&i.push(se("circle",{r:t,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const t=e?.width||0,r=e?.height||0;(t>0||r>0)&&i.push(se("rect",{width:t,height:r,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":e?.custom&&i.push(...Array.isArray(e.custom)?e.custom:[e.custom]);break;case"xy-threshold":{const t=r||0,s=o||0;if(void 0!==e?.x){const r=(e.x||0)-t;i.push(se("line",{x1:r,y1:(e.y1||0)-s,x2:r,y2:(e.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==e?.y){const r=(e.y||0)-s;i.push(se("line",{x1:(e.x1||0)-t,y1:r,x2:(e.x2||0)-t,y2:r,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==e?.x1||void 0!==e?.x2?i.push(se("line",{x1:(e.x1||0)-t,y1:0,x2:(e.x2||0)-t,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===e?.y1&&void 0===e?.y2||i.push(se("line",{x1:0,y1:(e.y1||0)-s,x2:0,y2:(e.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const t=e?.type||"curly",r=e?.width??e?.height;void 0!==r&&i.push(se("path",{d:ce(t,r,e?.depth||30,void 0===e?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return se("g",{className:"annotation-subject",children:i})}function he(t,e,n,r,o,i){const s=[];let a=0,l=0;if("callout-circle"!==o&&"label"!==o||!i?.radius){if("callout-rect"===o&&i){const n=i.width||0,r=i.height||0;if(n>0||r>0){const o=n/2,i=r/2,s=t-o,c=e-i;if(0!==s||0!==c){const t=Math.abs(s),e=Math.abs(c),d=n/2,u=r/2,h=t*u>e*d?d/t:u/e;a=o+s*h,l=i+c*h}}}else if("bracket"===o&&i){const t=i.width,e=i.height,n=i.depth||30;void 0!==t?(a=t/2,l=n):void 0!==e&&(a=n,l=e/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==t||0!==e)){const r=Math.atan2(e,t);a=Math.cos(r)*n,l=Math.sin(r)*n}}const c=Math.sqrt((t-a)**2+(e-l)**2);if(c>.5){const o=r||"var(--semiotic-text-secondary, currentColor)",i="curve"===n?.type;let d=Math.atan2(e-l,t-a);if(i){const r=(a+t)/2,i=(l+e)/2,u=-(e-l)/c,h=(t-a)/c,y=(n?.curve??.25)*c,f=r+u*y,p=i+h*y;s.push(se("path",{className:"connector-curve",d:`M${a},${l}Q${f},${p} ${t},${e}`,fill:"none",stroke:o},"connector-line")),d=Math.atan2(p-l,f-a)}else s.push(se("line",{x1:a,y1:l,x2:t,y2:e,stroke:o},"connector-line"));if("arrow"===n?.end){const t=10,e=16/180*Math.PI;s.push(se("path",{d:`M${a},${l}L${a+t*Math.cos(d+e)},${l+t*Math.sin(d+e)}L${a+t*Math.cos(d-e)},${l+t*Math.sin(d-e)}Z`,fill:o,stroke:"none"},"connector-arrow"))}}return se("g",{className:"annotation-connector",children:s})}function ye(t){const{x:e=0,y:n=0,dx:r,dy:o,nx:i,ny:s,note:a,connector:l,subject:c,type:d,color:u,className:h,disable:y,opacity:f,strokeDasharray:p,events:m={},"data-testid":g}=t,k=Array.isArray(e)?e[0]??0:e,$=Array.isArray(n)?n[0]??0:n,x=new Set(Array.isArray(y)?y:[]);let b=r||0,v=o||0;null!=i&&(b=i-k),null!=s&&(v=s-$);const w="string"==typeof d?d:"label";if("bracket"===w&&c&&0===b&&0===v)if(void 0!==c.width){b=c.width/2;const t=c.depth||30;v=t+(0>t?-5:5)}else if(void 0!==c.height){const t=c.depth||30;b=t+(0>t?-5:5),v=c.height/2}return ae("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${k},${$})`,"data-testid":g,...null!=f&&{opacity:f},...p&&{strokeDasharray:p},...m,children:[!x.has("connector")&&he(b,v,l,u,w,c),!x.has("subject")&&ue(w,c,u,k,$),!x.has("note")&&de(a,b,v,u)]})}function fe(t){const{noteData:e}=t,{screenCoordinates:n}=e,r="string"==typeof e.type?e.type:"label",o=e.eventListeners||e.events||{};if(e.coordinates&&n){const t=e.nx||n[0][0]+(e.dx??0),o=e.ny||n[0][1]+(e.dy??0),i=n.map((n,i)=>{const s=Object.assign({},e,{note:0===i?e.note:{label:""},x:n[0],y:n[1],nx:t,ny:o});return se(ye,{"data-testid":"semiotic-annotation",...s,type:r},"multi-annotation-"+i)});return se("g",{children:i})}const i=e.note||{title:"none",label:e.label},s=`${i.label}-${i.title}-${e.i}`;return se(ye,{"data-testid":"semiotic-annotation",events:o,...e,type:r},s)}import{jsx as pe,jsxs as me}from"react/jsx-runtime";var ge="var(--semiotic-bg, #ffffff)";function ke(t){const{x:e,y:n,text:r,fill:o,fontSize:i=12,fontWeight:s,fontFamily:a,textAnchor:l="start",dominantBaseline:c,background:d,className:u}=t,h=function(t){return void 0===t||!0===t||"halo"===t?{type:"halo"}:!1===t||"none"===t?null:"box"===t?{type:"box"}:{type:t.type??"halo",...t}}(d),y=t=>pe("text",{x:e,y:n,textAnchor:l,dominantBaseline:c,fill:o,fontSize:i,fontWeight:s,fontFamily:a,className:u,...t?{stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:"stroke"}:{},children:r});if(!h)return y();if("halo"===h.type)return y({stroke:h.fill??ge,strokeWidth:h.haloWidth??3});const f=h.padding??{x:6,y:3},p="number"==typeof f?f:f.x,m="number"==typeof f?f:f.y,g=function(t,e){return(t+"").length*e*.6}(r,i),k=i+2*m;let $,x;return $="middle"===l?e-g/2-p:"end"===l?e-g-p:e-p,x="middle"===c||"central"===c?n-k/2:"hanging"===c||"text-before-edge"===c?n-m:n-.8*i-m,me("g",{className:u,children:[pe("rect",{x:$,y:x,width:g+2*p,height:k,rx:h.radius??3,ry:h.radius??3,fill:h.fill??ge,fillOpacity:h.opacity??.85,stroke:h.stroke,strokeWidth:h.strokeWidth}),y()]})}export{f as filterSparseArray,m as parseDateLikeString,g as coerceDateLikeValue,k as coerceTemporalStringRows,Wt as DEFAULT_COLORS,Lt as STREAMING_PALETTE,St as getColor,Ot as resolveExplicitColor,Rt as createColorScale,Tt as getSize,Bt as computeEasing,_t as computeRawProgress,Gt as lerp,Vt as now,Zt as resolveAnimateConfig,Yt as isLegendConfig,Ut as isGradientLegendConfig,fe as SemioticAnnotation,Jt as ANNOTATION_DISCLOSURE_REVEAL_CSS,re as applyAnnotationEmphasis,ke as AnnotationLabel,st as unlockCrosshair,ht as useCrosshairPosition,$ as TITLE_BASELINE,x as hasTextTitle,b as reserveFrameChromeMargin,v as reserveTitleMargin,A as hasAnyCornerRadius,W as clampCornerRadii,C as xySceneNodeToSVG,D as networkSceneNodeToSVG,F as networkSceneEdgeToSVG,q as networkLabelToSVG,z as ordinalSceneNodeToSVG,H as geoSceneNodeToSVG,E as isServerEnvironment,B as observationInputType,_ as isInteractiveKeyboardTarget,G as emitHoverObservations,V as emitClickObservations,oe as resolveCustomLayoutPalette,ie as buildResolveColor,pt as useBrushSelection,gt as normalizeLinkedBrush,jt as DEFAULT_COLOR,qt as useChartSelection,Ht as useChartMode};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{bandFromAge as t,defaultTooltipStyle as e,normalizeTooltip as n,opacityFromAge as r,resolveCanvasFill as o}from"./chunk-chunk-ODUZEEBH.module.min.js";import{drawGlyphParts as a,glyphFractionClipRect as s,glyphHitGeometry as l,glyphPlacement as i}from"./chunk-chunk-KTWEBFMX.module.min.js";import{jsx as c,jsxs as u}from"react/jsx-runtime";function f(t){return"string"==typeof t?t:"value"}function h(t){return null==t?"–":"number"==typeof t?Math.abs(t)>9999?t.toLocaleString():t+"":t instanceof Date?t.toLocaleDateString():t+""}function d(t,e){if(!e)return h(t);try{const n=e(t);return null==n?h(t):n}catch{return h(t)}}function p(t,e){return"function"==typeof e?e(t):t[e]}function y(t,e){if(!t)return[];const n=[];return(Array.isArray(t)?t:[t]).forEach((t,r)=>{const o="string"==typeof t?.y0Accessor?t.y0Accessor:"low",a="string"==typeof t?.y1Accessor?t.y1Accessor:"high";n.push({label:o,accessor:t=>t.bands?.[r]?.y0??(0===r?t.band?.y0:void 0),format:e}),n.push({label:a,accessor:t=>t.bands?.[r]?.y1??(0===r?t.band?.y1:void 0),format:e})}),n}function g(t){const n=t.find(t=>"title"===t.role),r=t.filter(t=>"title"!==t.role);return t=>{const o=t.data;if(!o)return null;const a=n?d(p(o,n.accessor),n.format):null;return u("div",{className:"semiotic-tooltip",style:e,children:[null!=a&&c("div",{style:{fontWeight:"bold",marginBottom:r.length>0?4:0},children:a}),r.map((t,e)=>{const n=d(p(o,t.accessor),t.format);return u("div",{style:e>0?{marginTop:2}:void 0,children:[u("span",{style:{opacity:.7},children:[t.label,": "]}),c("span",{children:n})]},e)})]})}}function m({categoryAccessor:t,valueAccessor:n,groupAccessor:r,groupLabel:o,pieData:a=!1,valueFormat:s}){return l=>{const i=a?l.data?.[0]||l.data||l:l.data||l,y=p(i,t),g=p(i,n),m=r?p(i,r):void 0;return u("div",{className:"semiotic-tooltip",style:e,children:[c("div",{style:{fontWeight:"bold"},children:h(y)}),c("div",{style:{marginTop:4},children:d(g,s)}),null!=m&&u("div",{style:{marginTop:2,opacity:.8},children:[o||f(r),": ",h(m)]})]})}}import*as x from"react";function b(...t){const e=t.filter(t=>null!=t);return 0===e.length?null:1===e.length?e[0]:x.createElement(x.Fragment,null,...e)}import{useEffect as v,useRef as w}from"react";function A(t,e,n,r){v(()=>{t.current?.updateConfig(e),n.current=!0,r()},[e,r,t,n])}function _(t,e,n,r){const o=w(null);v(()=>{const a=t.current;if(!a)return;const s=e??null;o.current!==s&&(o.current=s,a.setLayoutSelection(s),a.hasCustomRestyle?a.restyleScene(s):n.current=!0,r())},[e,r,t,n])}var k={fresh:1,aging:.7,stale:.45,expired:.25},I={alpha:1,band:"fresh",isStale:!1};function M(e,n){if(!e||0>=n)return I;const r=null!=e.threshold&&e.threshold>0?e.threshold:5e3,o=e.graded;if(o){const e="object"==typeof o?o:{},a=t(n,r,e.thresholds);return{alpha:{...k,...e.opacities??{}}[a],band:a,isStale:"fresh"!==a}}return n>r?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:I}import{useEffect as O,useRef as S}from"react";function E(t,e,n,r,o,a){const s=S("fresh");O(()=>{if(!t)return;const l=setInterval(()=>{const l=e.current;if(!l||0===l.lastIngestTime)return;const i="undefined"!=typeof performance?performance.now():Date.now(),c=M(t,i-l.lastIngestTime);c.band===s.current&&c.isStale===o||(s.current=c.band,c.isStale!==o&&a(c.isStale),n.current=!0,r())},1e3);return()=>clearInterval(l)},[t,o,r,e,a,n])}import{jsx as D}from"react/jsx-runtime";function R({isStale:t,position:e}){return D("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===e?{top:4,left:4}:"bottom-left"===e?{bottom:4,left:4}:"bottom-right"===e?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:t?"#dc3545":"#28a745",color:"white"},children:t?"STALE":"LIVE"})}import{useRef as P}from"react";function j(t){const e=P(t);return function(t,e){if(Object.is(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return L(t,e);if(!T(t)||!T(e))return!1;const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(e,r))return!1;const n=t[r],o=e[r];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!L(n,o))return!1}else{if(!T(n)||!T(o))return!1;if(!C(n,o))return!1}}return!0}(e.current,t)||(e.current=t),e.current}function C(t,e){const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(e,r))return!1;if(!Object.is(t[r],e[r]))return!1}return!0}function L(t,e){if(t.length!==e.length)return!1;for(let n=0;t.length>n;n++)if(!Object.is(t[n],e[n]))return!1;return!0}function T(t){if(null===t||"object"!=typeof t)return!1;if(Array.isArray(t))return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||null===e}function z(t,e,n,r,l){if(0>=e.size)return;const c=e.glyph;if(!c||!c.parts?.length)return;const u=i(c,e.size);if(0>=u.scale)return;const f=(e.style.opacity??1)*(e._decayOpacity??1);if(0>=f)return;const h=e=>{const n=o(t,e,e);return"string"==typeof n?n:e},d=e.color??("string"==typeof e.style.fill?e.style.fill:void 0);t.save(),t.translate(n,r),e.rotation&&t.rotate(e.rotation),t.translate(u.offsetX,u.offsetY),t.scale(u.scale,u.scale),t.globalAlpha=l*f*(e.style.fillOpacity??1);const p=s(c,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal");p&&e.ghostColor&&a(t,c,d,e.accent,e.ghostColor,h),p&&(t.beginPath(),t.rect(p.x,p.y,p.width,p.height),t.clip()),a(t,c,d,e.accent,void 0,h),t.restore()}var H=(t,e)=>{const n=t.globalAlpha;for(const r of e)"glyph"===r.type&&z(t,r,r.x,r.y,n);t.globalAlpha=n};function U(t,e){const n=t.globalAlpha;for(const r of e)"glyph"===r.type&&z(t,r,r.cx,r.cy,n);t.globalAlpha=n}var $=new Set;function B(t,e){const n="function"==typeof t?t(e.datum??null,e):t;return(r=n)&&"object"==typeof r&&"string"==typeof r.id&&"function"==typeof r.cacheKey&&"function"==typeof r.drawCanvas&&"function"==typeof r.renderStaticSVG?n:void 0;var r}function G(t,e){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const n=`${t}:${e}`;$.has(n)||($.add(n),console.warn(`[Semiotic] Render backend "${t}" does not support scene node "${e}"; using the built-in renderer.`))}function N(t){const{context:e,nodes:n,renderMode:r,pixelRatio:o,paintBuiltIn:a}=t;if(!r||"sketchy"===r)return void a(n);let s=[];const l=()=>{s.length&&(a(s),s=[])};for(const t of n){const n=B(r,t);if(!n){s.push(t);continue}let i;l(),e.save();try{i=n.drawCanvas({context:e,node:t,style:t.style??{},pixelRatio:o})}finally{e.restore()}i||(G(n.id,t.type??"unknown"),a([t]))}l()}function W(t){const{node:e,index:n,renderMode:r,fallback:o}=t,a=B(r,e);if(!a)return o();const s=a.renderStaticSVG({node:e,style:e.style??{},key:`${a.id}-${n}`});return null!=s?s:(G(a.id,e.type??"unknown"),o())}function F(t){const e=new Map;for(const n of t){const t=n.group??"_default";let r=e.get(t);r||(r=[],e.set(t,r)),r.push(n)}for(const t of e.values()){t.sort((t,e)=>t.x-e.x||t.y-e.y);for(let e=0;t.length>e;e++)t[e]._groupIndex=e}const n=Array.from(e.keys()).sort((t,n)=>{const r=e.get(t),o=e.get(n);return(r.length>0?r[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(e.values()).flat();r.sort((t,e)=>t.x-e.x||t.y-e.y);const o=new Map;for(let t=0;r.length>t;t++){r[t]._flatIndex=t;const e=r[t].datum?.id;null!=e&&o.set(e+"",t)}return{flat:r,groups:n,byGroup:e,idToIdx:o}}function V(t,e){if(0===t.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const n=Math.max(0,Math.min(e,t.flat.length-1)),r=t.flat[n];return{flatIndex:n,group:r.group??"_default",indexInGroup:r._groupIndex??0}}function Y(t,e,n){const{group:r,indexInGroup:o}=e,a=n.byGroup.get(r);switch(t){case"ArrowRight":return a.length-1>o?a[o+1]._flatIndex:e.flatIndex;case"ArrowLeft":return o>0?a[o-1]._flatIndex:e.flatIndex;case"ArrowDown":{const t=n.groups.indexOf(r);return n.groups.length-1>t?K(n,n.groups[t+1],a[o]):e.flatIndex}case"ArrowUp":{const t=n.groups.indexOf(r);return t>0?K(n,n.groups[t-1],a[o]):e.flatIndex}case"PageDown":return Math.min(e.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(e.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function K(t,e,n){const r=t.byGroup.get(e);let o=0,a=Math.abs(r[0].x-n.x);for(let t=1;r.length>t;t++){const e=Math.abs(r[t].x-n.x);a>e&&(a=e,o=t)}return r[o]._flatIndex}function X(t){const e=[];for(const n of t)switch(n.type){case"point":e.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=n.size)break;e.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"glyph":{if(0>=n.size||null==n.datum)break;const t=l(n.glyph,n.size);e.push({x:n.x+t.centerDx,y:n.y+t.centerDy,datum:n.datum,shape:"rect",w:2*t.halfWidth,h:2*t.halfHeight,group:"_default"});break}case"line":{const t=n,r=Array.isArray(t.datum)?t.datum:[],o=t.group??"_default";for(let n=0;t.path.length>n&&r.length>n;n++)e.push({x:t.path[n][0],y:t.path[n][1],datum:r[n],shape:"circle",group:o});break}case"area":{const t=n,r=Array.isArray(t.datum)?t.datum:[],o=t.group??"_default";for(let n=0;t.topPath.length>n&&r.length>n;n++)e.push({x:t.topPath[n][0],y:t.topPath[n][1],datum:r[n],shape:"circle",group:o});break}case"rect":e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.group??"_default"});break;case"heatcell":e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:"_default"})}return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}function q(t){const e=[];for(const n of t)if("rect"===n.type&&null!=n.x){if(null==n.datum)continue;e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.group??n.datum?.category??""})}else if("point"===n.type)e.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});else if("symbol"===n.type){if(0>=n.size)continue;e.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"})}else if("glyph"===n.type){if(0>=n.size||null==n.datum)continue;const t=l(n.glyph,n.size);e.push({x:n.x+t.centerDx,y:n.y+t.centerDy,datum:n.datum,shape:"rect",w:2*t.halfWidth,h:2*t.halfHeight,group:"_default"})}else if("wedge"===n.type&&null!=n.cx){if(null===n.datum)continue;const t=((n.startAngle||0)+(n.endAngle||0))/2,r=((n.innerRadius||0)+(n.outerRadius||50))/2;e.push({x:n.cx+Math.cos(t)*r,y:n.cy+Math.sin(t)*r,datum:n.datum,shape:"wedge",group:"_default"})}return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}function Z(t){const e=[];for(const n of t)if("circle"===n.type&&null!=n.cx){if(0>=n.r)continue;e.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("rect"===n.type&&null!=n.x){if(0>=n.w||0>=n.h)continue;e.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.datum?.id??"_default"})}else if("arc"===n.type&&null!=n.cx)e.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"});else if("symbol"===n.type&&null!=n.cx){if(0>=n.size)continue;e.push({x:n.cx,y:n.cy,datum:n.datum,shape:"circle",group:n.datum?.id??"_default"})}else if("glyph"===n.type&&null!=n.cx){if(0>=n.size||null==n.datum)continue;const t=l(n.glyph,n.size);e.push({x:n.cx+t.centerDx,y:n.cy+t.centerDy,datum:n.datum,shape:"rect",w:2*t.halfWidth,h:2*t.halfHeight,group:n.datum?.id??"_default"})}return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}function J(t,e,n,r,o){const a=n.flat[e.flatIndex];if(!a)return Y(t,e,n);const s=a.datum?.id;switch(t){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const r=function(t,e,n){let r=null,o=1/0;for(let a=0;t.flat.length>a;a++){const s=t.flat[a];if(s===e)continue;const l=s.x-e.x,i=s.y-e.y;let c=!1;switch(n){case"right":c=l>0&&Math.abs(l)>=Math.abs(i);break;case"left":c=0>l&&Math.abs(l)>=Math.abs(i);break;case"down":c=i>0&&Math.abs(i)>=Math.abs(l);break;case"up":c=0>i&&Math.abs(i)>=Math.abs(l)}if(!c)continue;const u=l*l+i*i;o>u&&(o=u,r=a)}return r}(n,a,"ArrowRight"===t?"right":"ArrowLeft"===t?"left":"ArrowDown"===t?"down":"up")??e.flatIndex;return r!==e.flatIndex&&(o.current=-1),r}case"Enter":{if(null==s)return e.flatIndex;const t=function(t,e){const n=t+"",r=[];for(const t of e){const e=t.datum??t,o=Q(e.source),a=Q(e.target),s=null!=o,l=null!=a;s&&o+""===n&&l?r.push(a+""):l&&a+""===n&&s&&r.push(o+"")}return r}(s,r);if(0===t.length)return e.flatIndex;const a=n.idToIdx.get(t[(o.current+1)%t.length])??-1;return 0>a?e.flatIndex:(o.current=-1,a)}default:{const r=Y(t,e,n);return null!==r&&r!==e.flatIndex&&(o.current=-1),r}}}function Q(t){return"object"==typeof t&&null!==t&&"id"in t?t.id:t}function tt(t){const e=[];for(const n of t)if("point"===n.type&&null!=n.x)e.push({x:n.x,y:n.y,datum:n.datum,shape:"circle"});else if("glyph"===n.type){if(0>=n.size||null==n.datum)continue;const t=l(n.glyph,n.size);e.push({x:n.x+t.centerDx,y:n.y+t.centerDy,datum:n.datum,shape:"rect",w:2*t.halfWidth,h:2*t.halfHeight})}else"geoarea"===n.type&&n.centroid&&!1!==n.interactive&&e.push({x:n.centroid[0],y:n.centroid[1],datum:n.datum,shape:"geoarea",pathData:n.pathData});return e.sort((t,e)=>t.x-e.x||t.y-e.y),e}function et(t,e,n){switch(t){case"ArrowRight":case"ArrowDown":return n-1>e?e+1:e;case"ArrowLeft":case"ArrowUp":return e>0?e-1:e;case"PageDown":return Math.min(e+Math.max(1,Math.floor(.1*n)),n-1);case"PageUp":return Math.max(e-Math.max(1,Math.floor(.1*n)),0);case"Home":return 0;case"End":return n-1;case"Escape":return-1;default:return null}}function nt(t){return{data:t.datum||{},x:t.x,y:t.y,__semioticHoverData:!0}}function rt(t){const{title:e,description:n,summary:r,accessibleTable:o,className:a,animate:s,axisExtent:l,autoPlaceAnnotations:i}=t,c={};return e&&(c.title=e),n&&(c.description=n),r&&(c.summary=r),void 0!==o&&(c.accessibleTable=o),a&&(c.className=a),null!=s&&(c.animate=s),void 0!==l&&(c.axisExtent=l),void 0!==i&&(c.autoPlaceAnnotations=i),c}function ot(t){const{linkedHover:e,selection:n,onObservation:r,onClick:o,hoverRadius:a,hoverHighlight:s,forceHoverBehavior:l,forceClickBehavior:i,mobileInteraction:c,customHoverBehavior:u,customClickBehavior:f,linkedHoverInClickPredicate:h=!0}=t,d={};r&&(d.annotationObservationCallback=r);const p=c?.enabled?Math.max(a??30,Math.ceil((c.targetSize||44)/2),24):a;return(l||e||r||o||s)&&(d.customHoverBehavior=u),f&&(i||(h?r||o||e:r||o)||c?.enabled&&(c.tapToSelect||c.tapToLockTooltip)&&(e||s||n))&&(d.customClickBehavior=f),null!=p&&(d.hoverRadius=p),d}function at(t){const{tooltip:e,defaultTooltipContent:r}=t;return{tooltipContent:!1===e?()=>null:n(e)||r}}function st(t,e,n){if(1>=n)return 1;const o=n-1;return r({age:o-e,extent:o,type:t.type,halfLife:t.halfLife??n/2,threshold:t.stepThreshold??.5*n,minOpacity:t.minOpacity??.1})}function lt(t){const e=new Map;for(let n=0;t.length>n;n++)e.set(t[n],n);return e}function it(t,e,n,r=lt(n)){const o=n.length;if(o>1)for(const n of e){if("line"===n.type){const e=Array.isArray(n.datum)?n.datum:[];if(2>e.length)continue;const a=Array(e.length);let s=!1;for(let n=0;e.length>n;n++){const l=r.get(e[n]);null!=l?(a[n]=st(t,l,o),1>a[n]&&(s=!0)):a[n]=1}s&&(n._decayOpacities=a);continue}if("area"===n.type){const e=Array.isArray(n.datum)?n.datum:[],a=n.topPath?n.topPath.length:e.length;if(2>a)continue;if(e.length===a){const s=Array(a);let l=!1;for(let n=0;e.length>n;n++){const a=r.get(e[n]);null!=a?(s[n]=st(t,a,o),1>s[n]&&(l=!0)):s[n]=1}l&&(n._decayOpacities=s)}else{let s=1;for(const n of e){const e=r.get(n);if(null!=e){const n=st(t,e,o);s>n&&(s=n)}}if(1>s){const t=Array(a);t.fill(s),n._decayOpacities=t}}continue}const e=r.get(n.datum);if(null==e)continue;const a=st(t,e,o);"heatcell"===n.type?n.style={opacity:a}:"candlestick"===n.type?n._decayOpacity=a:n.style={...n.style,opacity:(n.style?.opacity??1)*a}}}function ct(t){if("production"===process.env.NODE_ENV)return;const{label:e,nodes:n,overlays:r,warned:o}=t;ut(r)&&0===n.length&&ft(o,"overlay-only",`[semiotic] ${e} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),n.length>0&&n.every(t=>null==t.datum)&&ft(o,"null-datums",`[semiotic] ${e} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function ut(t){return null!=t&&!1!==t&&""!==t&&(!Array.isArray(t)||t.some(ut))}function ft(t,e,n){t.has(e)||(t.add(e),console.warn(n))}function ht(t,e,n,r){const o=function(t){if(t instanceof Error)return{name:t.name||"Error",message:t.message||"Custom layout threw."};if("string"==typeof t)return{name:"Error",message:t};if(null==t)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:t+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(e),a="network"===t?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:t,source:a,message:`Semiotic ${t} ${a} failed: ${o.message}`,error:o,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:r}}var dt=new WeakMap;function pt(){return this.updateResults.last}function yt(){return this.updateResults.last}function gt(t){return this.updateResults.subscribe(t)}function mt(t){this.config.layoutSelection=t}function xt(){dt.set(this,!0)}function bt(){const t=!0===dt.get(this);return dt.delete(this),t}function vt(t){Object.assign(t.prototype,{getLastUpdateResult:pt,getUpdateSnapshot:yt,subscribeUpdateResult:gt,setLayoutSelection:mt,markStylePaintPending:xt,consumeStylePaintPending:bt})}function wt(t,e,n){return n.x>t||t>n.x+n.w||n.y>e||e>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function At(t,e=30){return Math.max((t??4)+5,12,e)}function _t(t){return t instanceof Date?t:"number"==typeof t&&t>1e9?new Date(t):null}function kt(t,e){const n=_t(t);if(!n)return!1;const r=_t(e);return!r||n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()}function It(t){let e=t%(2*Math.PI);return 0>e&&(e+=2*Math.PI),e}function Mt(t,e,n,r,o,a=t=>t.x,s=t=>t.y,l=t=>t.r){const i=Math.max(r,o+5,12),c=e-i,u=e+i,f=n-i,h=n+i;let d=null,p=1/0;return t.visit((t,o,i,y,g)=>{if(o>u||c>y||i>h||f>g)return!0;if(!t.length){let o=t;do{const t=o.data,i=a(t)-e,c=s(t)-n,u=Math.sqrt(i*i+c*c);At(l(t),r)>=u&&p>u&&(d=t,p=u),o=o.next}while(o)}return!1}),d?{node:d,distance:p}:null}function Ot(t){return!(!t._pulseIntensity||0>=t._pulseIntensity)}function St(t,e,n=.3){Ot(e)&&(t.globalAlpha=e._pulseIntensity*n,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.fillRect(e.x,e.y,e.w,e.h))}function Et(t,e,n=.6){if(!Ot(e))return;const r=e.r+(e._pulseGlowRadius??4)*e._pulseIntensity,o=e.cx??e.x??0,a=e.cy??e.y??0;t.beginPath(),t.arc(o,a,r,0,2*Math.PI),t.strokeStyle=e._pulseColor||"rgba(255,255,255,0.6)",t.lineWidth=2*e._pulseIntensity,t.globalAlpha=e._pulseIntensity*n,t.stroke()}function Dt(t,e,n,r=.35){Ot(e)&&(t.globalAlpha=e._pulseIntensity*r,t.fillStyle=e._pulseColor||"rgba(255,255,255,0.6)",n?t.fill(n):t.fill())}export{st as computeDecayOpacity,lt as buildDatumIndexMap,it as applyDecay,ct as warnCustomLayoutDiagnostics,ht as createCustomLayoutFailureDiagnostic,vt as attachUpdateResultStore,b as composeOverlays,A as useConfigSync,_ as useLayoutSelectionSync,wt as hitTestRect,At as getHitRadius,kt as isTimeLandmark,It as normalizeAngle,Mt as findHitPointInQuadtree,M as resolveStaleness,E as useStalenessCheck,R as StalenessBadge,j as useStableShallow,St as renderRectPulse,Et as renderCirclePulse,Dt as renderPathPulse,H as glyphCanvasRenderer,U as networkGlyphRenderer,N as paintSceneWithBackend,W as renderSceneWithBackend,f as accessorName,h as formatVal,y as bandTooltipFields,g as buildDefaultTooltip,m as buildOrdinalTooltip,F as buildNavGraph,V as resolvePosition,Y as nextGraphIndex,X as extractXYNavPoints,q as extractOrdinalNavPoints,Z as extractNetworkNavPoints,J as nextNetworkIndex,tt as extractGeoNavPoints,et as nextIndex,nt as navPointToHover,rt as buildBaseMetadataProps,ot as buildCustomBehaviorProps,at as buildTooltipProps};