semiotic 3.8.2 → 3.8.4
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.
- package/CLAUDE.md +9 -9
- package/README.md +42 -40
- package/ai/examples.md +1 -1
- package/ai/schema.json +2726 -300
- package/ai/surface-manifest.json +1 -1
- package/ai/system-prompt.md +1 -1
- package/dist/chunk-chunk-2JGJ5GUG.module.min.js +0 -1
- package/dist/chunk-chunk-3ILKBVVQ.module.min.js +1 -0
- package/dist/{chunk-chunk-NO4MCQVD.module.min.js → chunk-chunk-5RKXZQ2P.module.min.js} +1 -1
- package/dist/{chunk-chunk-CYIML3AV.module.min.js → chunk-chunk-6TPGFL7M.module.min.js} +1 -1
- package/dist/{chunk-chunk-VVCA3DB7.module.min.js → chunk-chunk-7ALTGHK6.module.min.js} +1 -1
- package/dist/chunk-chunk-7KZJUTKP.module.min.js +2 -0
- package/dist/chunk-chunk-7RYBCTK5.module.min.js +1 -0
- package/dist/chunk-chunk-ACLDBMRH.module.min.js +2 -0
- package/dist/chunk-chunk-ANYDWOZF.module.min.js +1 -0
- package/dist/{chunk-chunk-ZLKRTF5N.module.min.js → chunk-chunk-AQPQN2HH.module.min.js} +1 -1
- package/dist/chunk-chunk-ASKSE5F5.module.min.js +1 -0
- package/dist/chunk-chunk-AVBI6GDT.module.min.js +1 -0
- package/dist/chunk-chunk-B3DRZPBK.module.min.js +2 -0
- package/dist/chunk-chunk-BFHUYEOS.module.min.js +2 -0
- package/dist/chunk-chunk-C4YA6TDR.module.min.js +1 -0
- package/dist/chunk-chunk-C57LR3YG.module.min.js +1 -0
- package/dist/chunk-chunk-EMO5NUGE.module.min.js +1 -0
- package/dist/chunk-chunk-F5V4UIE6.module.min.js +2 -0
- package/dist/chunk-chunk-F7WFPD4O.module.min.js +2 -0
- package/dist/chunk-chunk-FBGHXL72.module.min.js +2 -0
- package/dist/chunk-chunk-FP44FHFO.module.min.js +2 -0
- package/dist/chunk-chunk-HKXUAEPJ.module.min.js +2 -0
- package/dist/chunk-chunk-ICEXPNDC.module.min.js +2 -0
- package/dist/chunk-chunk-IY7RYD4S.module.min.js +1 -0
- package/dist/{chunk-chunk-7LHMKRKE.module.min.js → chunk-chunk-JDXT6ORT.module.min.js} +1 -1
- package/dist/chunk-chunk-JMVEIZXP.module.min.js +1 -0
- package/dist/chunk-chunk-KHCOJMGK.module.min.js +1 -0
- package/dist/chunk-chunk-KQ546MKE.module.min.js +2 -0
- package/dist/chunk-chunk-LQBSXO7K.module.min.js +2 -0
- package/dist/chunk-chunk-LRIFN2HK.module.min.js +1 -0
- package/dist/chunk-chunk-MFHF4J2Z.module.min.js +1 -0
- package/dist/chunk-chunk-N6VKKF3A.module.min.js +2 -0
- package/dist/chunk-chunk-NEVE562N.module.min.js +1 -0
- package/dist/chunk-chunk-NKZ75IM5.module.min.js +2 -0
- package/dist/chunk-chunk-PLIDPQNG.module.min.js +2 -0
- package/dist/{chunk-chunk-FYY2ACNJ.module.min.js → chunk-chunk-PRDGLMJT.module.min.js} +1 -1
- package/dist/chunk-chunk-QGZGZI4X.module.min.js +1 -0
- package/dist/chunk-chunk-RP7WTID5.module.min.js +1 -0
- package/dist/chunk-chunk-S7KLNUO6.module.min.js +1 -0
- package/dist/chunk-chunk-SR4ZXOWR.module.min.js +2 -0
- package/dist/chunk-chunk-ZOAQDIJO.module.min.js +1 -0
- package/dist/chunk-minimapBrushOverlay-JU57U7NM.module.min.js +2 -0
- package/dist/chunk-scatterplotMatrixBrushOverlay-SDIZSN66.module.min.js +2 -0
- package/dist/chunk-statisticalOverlays-QGDLRUHX.module.min.js +1 -0
- package/dist/chunk-statisticalOverlays-T77OKLDY.module.min.js +1 -0
- package/dist/components/ChartContainer.d.ts +2 -2
- package/dist/components/ai/chartCapabilityTypes.d.ts +5 -0
- package/dist/components/charts/custom/XYCustomChart.d.ts +3 -0
- package/dist/components/charts/geo/ChoroplethMap.d.ts +2 -0
- package/dist/components/charts/geo/DistanceCartogram.d.ts +7 -3
- package/dist/components/charts/geo/FlowMap.d.ts +4 -0
- package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +3 -1
- package/dist/components/charts/physics/CollisionSwarmChart.d.ts +6 -1
- package/dist/components/charts/physics/GaltonBoardChart.d.ts +6 -1
- package/dist/components/charts/physics/gauntletChartProps.d.ts +7 -1
- package/dist/components/charts/physics/gauntletChrome.d.ts +2 -1
- package/dist/components/charts/physics/gauntletPhysics.d.ts +19 -4
- package/dist/components/charts/physics/gauntletRuntime.d.ts +3 -0
- package/dist/components/charts/physics/physicsHocUtils.d.ts +12 -0
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +5 -6
- package/dist/components/charts/realtime/temporalHistogramConfig.d.ts +11 -0
- package/dist/components/charts/shared/areaSeriesData.d.ts +15 -0
- package/dist/components/charts/shared/chartMode.d.ts +75 -0
- package/dist/components/charts/shared/chartSpecCore.d.ts +2 -2
- package/dist/components/charts/shared/colorUtils.d.ts +8 -0
- package/dist/components/charts/shared/geoStyleDefaults.d.ts +3 -0
- package/dist/components/charts/shared/hatchPattern.d.ts +8 -3
- package/dist/components/charts/shared/hooks.d.ts +13 -80
- package/dist/components/charts/shared/lineSeriesSsr.d.ts +55 -0
- package/dist/components/charts/shared/types.d.ts +2 -2
- package/dist/components/charts/shared/useChartSetup.d.ts +3 -0
- package/dist/components/charts/shared/useCustomChartSetup.d.ts +3 -0
- package/dist/components/charts/shared/useXYLineStyle.d.ts +3 -2
- package/dist/components/charts/shared/validateProps.d.ts +1 -1
- package/dist/components/charts/shared/xyLineStyle.d.ts +21 -0
- package/dist/components/charts/xy/AreaChart.d.ts +10 -0
- package/dist/components/charts/xy/LineChart.d.ts +3 -0
- package/dist/components/charts/xy/minimapBrushOverlay.d.ts +17 -0
- package/dist/components/charts/xy/minimapBrushOverlayLazy.d.ts +4 -0
- package/dist/components/charts/xy/scatterplotMatrixBrushOverlay.d.ts +8 -0
- package/dist/components/charts/xy/scatterplotMatrixBrushOverlayLazy.d.ts +3 -0
- package/dist/components/legendLayout.d.ts +31 -0
- package/dist/components/realtime/types.d.ts +5 -0
- package/dist/components/recipes/gridObservatory.d.ts +176 -0
- package/dist/components/recipes/recipeChrome.d.ts +24 -0
- package/dist/components/recipes/sequenceLayout.d.ts +139 -0
- package/dist/components/semiotic-recipes-core.d.ts +6 -2
- package/dist/components/server/serverChartConfigShared.d.ts +29 -0
- package/dist/components/server/serverChartConfigs.d.ts +2 -13
- package/dist/components/server/serverChartConfigsXY.d.ts +3 -0
- package/dist/components/server/serverGaugeOverlay.d.ts +28 -0
- package/dist/components/server/staticAnnotations.d.ts +3 -1
- package/dist/components/server/staticLegend.d.ts +7 -1
- package/dist/components/server/staticSVGChrome.d.ts +57 -0
- package/dist/components/stream/GeoPipelineStore.d.ts +2 -0
- package/dist/components/stream/GeoSVGOverlay.d.ts +2 -0
- package/dist/components/stream/SceneToSVG.d.ts +10 -8
- package/dist/components/stream/SceneToSVGGeo.d.ts +10 -0
- package/dist/components/stream/SceneToSVGNetwork.d.ts +12 -0
- package/dist/components/stream/SceneToSVGOrdinal.d.ts +12 -0
- package/dist/components/stream/canvasBackground.d.ts +7 -0
- package/dist/components/stream/networkFramePaint.d.ts +2 -0
- package/dist/components/stream/networkTypes.d.ts +2 -4
- package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +18 -2
- package/dist/components/stream/physics/physicsBodyCanvas.d.ts +7 -0
- package/dist/components/stream/physics/physicsPipelineEviction.d.ts +15 -0
- package/dist/components/stream/physics/physicsPipelineObservations.d.ts +1 -1
- package/dist/components/stream/physics/physicsPipelineQuiescence.d.ts +20 -0
- package/dist/components/stream/renderBackend.d.ts +14 -0
- package/dist/components/stream/sceneToSVGShared.d.ts +80 -0
- package/dist/components/stream/types.d.ts +4 -0
- package/dist/components/stream/useHydration.d.ts +7 -1
- package/dist/components/stream/xySceneBuilders/candlestickScene.d.ts +1 -1
- package/dist/components/types/legendTypes.d.ts +16 -3
- package/dist/forceLayoutWorker.js +1 -1
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/physics.min.js +1 -1
- package/dist/physics.module.min.js +1 -1
- package/dist/physicsWorker.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/rough.min.js +1 -1
- package/dist/rough.module.min.js +1 -1
- package/dist/semiotic-ai-core.min.js +1 -1
- package/dist/semiotic-ai-core.module.min.js +1 -1
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-experimental.min.js +1 -1
- package/dist/semiotic-experimental.module.min.js +1 -1
- package/dist/semiotic-realtime-core.min.js +1 -1
- package/dist/semiotic-realtime-core.module.min.js +1 -1
- package/dist/semiotic-recipes-core.d.ts +6 -2
- package/dist/semiotic-recipes-core.min.js +1 -1
- package/dist/semiotic-recipes-core.module.min.js +1 -1
- package/dist/semiotic-recipes.min.js +1 -1
- package/dist/semiotic-recipes.module.min.js +1 -1
- package/dist/semiotic-server-edge.min.js +1 -1
- package/dist/semiotic-server-edge.module.min.js +1 -1
- package/dist/semiotic-server-node.min.js +1 -1
- package/dist/semiotic-server-node.module.min.js +1 -1
- package/dist/semiotic-utils-core.min.js +1 -1
- package/dist/semiotic-utils-core.module.min.js +1 -1
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-value.module.min.js +1 -1
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +3 -2
- package/dist/chunk-chunk-255KDHW5.module.min.js +0 -1
- package/dist/chunk-chunk-27HVVXS6.module.min.js +0 -1
- package/dist/chunk-chunk-2UN3ANRN.module.min.js +0 -2
- package/dist/chunk-chunk-2VUEY5TH.module.min.js +0 -1
- package/dist/chunk-chunk-2WVCH4PL.module.min.js +0 -1
- package/dist/chunk-chunk-5WEFWNUW.module.min.js +0 -2
- package/dist/chunk-chunk-6F6GEAQU.module.min.js +0 -1
- package/dist/chunk-chunk-BHYTYMY2.module.min.js +0 -2
- package/dist/chunk-chunk-C6EJ4IOD.module.min.js +0 -2
- package/dist/chunk-chunk-CP3EN6KZ.module.min.js +0 -1
- package/dist/chunk-chunk-DNY43POY.module.min.js +0 -1
- package/dist/chunk-chunk-E7MIQX7D.module.min.js +0 -2
- package/dist/chunk-chunk-ES4DCG3L.module.min.js +0 -1
- package/dist/chunk-chunk-FAKO3RGQ.module.min.js +0 -2
- package/dist/chunk-chunk-H4PPRW6N.module.min.js +0 -1
- package/dist/chunk-chunk-IFYPMWKY.module.min.js +0 -1
- package/dist/chunk-chunk-J3ELI22J.module.min.js +0 -1
- package/dist/chunk-chunk-L6D3I3V7.module.min.js +0 -2
- package/dist/chunk-chunk-M337NY6L.module.min.js +0 -1
- package/dist/chunk-chunk-ODUZEEBH.module.min.js +0 -2
- package/dist/chunk-chunk-P6UBCMSQ.module.min.js +0 -2
- package/dist/chunk-chunk-QRIBHZYW.module.min.js +0 -1
- package/dist/chunk-chunk-RH5TSQPH.module.min.js +0 -1
- package/dist/chunk-chunk-STZFFTAN.module.min.js +0 -2
- package/dist/chunk-chunk-T27ZEV6A.module.min.js +0 -1
- package/dist/chunk-chunk-U3AGQ5EF.module.min.js +0 -2
- package/dist/chunk-chunk-W3DB2MN4.module.min.js +0 -2
- package/dist/chunk-chunk-WDIN4LRC.module.min.js +0 -1
- package/dist/chunk-chunk-XOYX77KF.module.min.js +0 -2
- package/dist/chunk-chunk-Z5KXAVQD.module.min.js +0 -2
- package/dist/chunk-chunk-ZCNBUZPL.module.min.js +0 -2
- package/dist/chunk-chunk-ZTNVDWAK.module.min.js +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{makeRuleValueResolver as t,resolveStyleRules as e}from"./chunk-chunk-NEVE562N.module.min.js";import{PhysicsPipelineStore as o,absorbRegion as n,bodyGroupSpec as i,capacitatedRegion as a,collidersFromPlotBounds as r,collidersFromXScaleBins as s,forceFieldRegion as l,groupCompletionRows as c,portalRegion as u,pressureFieldRegion as p,processStageLayout as d,routeSurfaceRegion as h}from"./chunk-chunk-LRIFN2HK.module.min.js";import{buildResolveColor as g,resolveCustomLayoutPalette as m,xySceneNodeToSVG as f}from"./chunk-chunk-MFHF4J2Z.module.min.js";import{schemeCategory10 as y}from"./chunk-chunk-5RKXZQ2P.module.min.js";function x(t=[]){return t.map(t=>({id:t.id,label:t.label,count:t.count,...null!=t.secondary?{secondary:t.secondary}:{},...t.secondaryLabel?{secondaryLabel:t.secondaryLabel}:{},...null!=t.observed?{observed:t.observed}:{}}))}function w(t,e={}){const o=e.bodies??function(t){return t.world.bodies.map(t=>({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,shape:{...t.shape},sleeping:t.sleeping,datum:t.datum}))}(t),n=o.filter(t=>t.sleeping).length;return{bodyCount:o.length,sleepingCount:n,settled:"settled"===t.simulationState&&0===t.queue.length&&n===o.length,stepsRun:Math.max(0,Math.floor(e.stepsRun??0)),seed:t.world.options.seed,binCounts:x(e.projectionRows)}}var b={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function M(t){const e=t.datum;if(e&&"object"==typeof e){const t=e.label??e.name??e.id;if(null!=t&&""!==t)return t+""}return t.id}function v(t,e){const o="function"==typeof e?e(t):e;return{...b,...o??{}}}function k(t,e={}){const o=function(t){return t.datum&&"object"==typeof t.datum?t.datum:null}(t),n={label:e.getBodyLabel?.(t)??M(t)},i={style:v(t,e.bodyStyle),datum:o,accessibleDatum:o,accessibility:n,_transitionKey:t.id};return"aabb"===t.shape.type?{type:"rect",x:t.x-t.shape.width/2,y:t.y-t.shape.height/2,w:t.shape.width,h:t.shape.height,...i}:{type:"point",x:t.x,y:t.y,r:t.shape.radius,pointId:t.id,...i}}function S(t,e={}){return t.map(t=>k(t,e))}function P(t,e={}){const o=t.settle(e.maxSteps),n=t.readBodies(),i=t.snapshot();return{snapshot:i,bodies:n,sceneNodes:S(n,e),evidence:w(i,{bodies:n,projectionRows:e.projectionRows,stepsRun:o}),stepsRun:o}}import*as A from"react-dom/server";import{jsx as I,jsxs as C}from"react/jsx-runtime";function z(t,e={}){const{width:o=640,height:n=360,title:i,description:a,background:r,className:s,idPrefix:l="physics",...c}=e,u=P(t,c),p=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"physics-"+e:e}(l),d=i?p+"-title":void 0,h=a?p+"-desc":void 0,g=[d,h].filter(Boolean).join(" ")||void 0;return{svg:A.renderToStaticMarkup(C("svg",{xmlns:"http://www.w3.org/2000/svg",className:s??"stream-physics-frame",width:o,height:n,viewBox:`0 0 ${o} ${n}`,role:"img","aria-labelledby":g,children:[i&&I("title",{id:d,children:i}),a&&I("desc",{id:h,children:a}),r&&"transparent"!==r?I("rect",{x:0,y:0,width:o,height:n,fill:r}):null,I("g",{id:p+"-data-area",children:u.sceneNodes.map((t,e)=>f(t,e,p))})]})),scene:u,evidence:u.evidence}}import{scaleLinear as R}from"d3-scale";function T(t){const[e,o]=t,n=160>e||116>o,i=n?Math.min(12,Math.max(2,.08*e)):32,a=n?Math.min(8,Math.max(2,.12*o)):24,r=n?a:34;return{width:e,height:o,plot:{x:i,y:a,width:Math.max(1,e-2*i),height:Math.max(1,o-a-r)}}}function L(t){const e=(t??"")+"";if(!e)return"#4e79a7";const o=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let n=0;for(let t=0;e.length>t;t+=1)n=31*n+e.charCodeAt(t)>>>0;return o[n%o.length]}function E(o,n="#4e79a7",i){const a=i?.styleRules,r=!!a&&a.length>0,s=r?t(i?.valueAccessor):void 0;return t=>{const i=t.datum,l=i&&o?"function"==typeof o?o(i,0):i[o]:void 0,c={fill:null==l?n:L(l),stroke:"#111827",strokeWidth:1,opacity:.9};return r&&i&&Object.assign(c,e(i,a,{value:s?s(i):void 0,category:null==l?void 0:l+""})),c}}function j(t,e,o,n){return{fixedDt:1/120,maxSubsteps:8,colliders:e,observation:{chartType:o},kernel:{seed:t,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...n}}}function Y(t,e,o){return"function"==typeof o?o(t,e):t[o]}function $(t){if(t instanceof Date){const e=t.getTime();return Number.isFinite(e)?e:null}const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:null}function N(t,e,o){return Math.max(e,Math.min(o,t))}function F(t,e){const o=$(t);return null!=o&&o>0?o:e}function D(t){return((t??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function B(t){let e=t>>>0;return()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}import{scaleLinear as X}from"d3-scale";function W(t){const e=Math.max(2,Math.round(t.bins)),o=Math.max(1,Math.round(t.pegRows??e-1)),n=Math.max(1,Math.round(t.count??Math.max(64,4*e))),i=N(Number.isFinite(t.branchProbability)?t.branchProbability??.5:.5,0,1),a=B(t.seed??1),r=t.idPrefix??"mechanical";return Array.from({length:n},(t,e)=>{let n=0;for(let t=0;o>t;t+=1)a()<i&&(n+=1);const s=o/2;return{id:`${r}-${e}`,value:n,mechanical:!0,pegRows:o,branchProbability:i,pathRights:n,side:s>n?"left":n>s?"right":"center"}})}function V(t){const{data:e,valueAccessor:o,bins:n,ballRadius:i,seed:a,size:l,valueExtent:c}=t,u=T(l),p=e.map((t,e)=>$(Y(t,e,o))).filter(t=>null!=t),d=function(t){if(!t)return;const e=$(t[0]),o=$(t[1]);return null!=e&&null!=o?e>o?[o,e]:[e,o]:void 0}(c),h=d?.[0]??(p.length?Math.min(...p):0),g=d?.[1]??(p.length?Math.max(...p):1),m=g===h?1:g-h,f=X().domain([0,n]).range([u.plot.x,u.plot.x+u.plot.width]),y=Array.from({length:n},()=>0),x=[];e.forEach((t,e)=>{const a=$(Y(t,e,o));if(null==a)return;const r=Math.max(0,Math.min(n-1,Math.floor((a-h)/m*n)));y[r]+=1,x.push({id:(t.id??"galton-"+e)+"",x:f(r+.5),y:u.plot.y+i+2,vx:8*(e%5-2),vy:0,mass:1,shape:{type:"circle",radius:i},datum:{...t,value:a,bin:r}})});const w=u.plot.y+u.plot.height;return{config:j(a,[...r({x:u.plot.x,y:u.plot.y,width:u.plot.width,height:u.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...s({idPrefix:"galton-bin",count:n,domainStart:0,domainStep:1,xScale:f,yTop:u.plot.y-400,yBottom:w,wallThickness:6})],"GaltonBoardChart"),initialSpawns:x,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:y.map((t,e)=>({label:e+1+"",value:t})),metadata:{kind:"galton-board",bins:n,plot:u.plot,valueExtent:[h,g]}}}import{scaleLinear as _}from"d3-scale";function O(t){const{count:e,idPrefix:o,wallThickness:n,xScale:i,yBottom:a,yTop:r,yTopForIndex:s}=t;return Array.from({length:e+1},(t,e)=>{const l=Math.min(a-1,s?.(e)??r),c=Math.max(1,a-l);return{id:`${o}-wall-${e}`,shape:{type:"aabb",x:i(e),y:l+c/2,width:n,height:c}}})}function Z(t){const{data:e,timeAccessor:o,arrivalAccessor:n,windows:i,watermark:a,ballRadius:s,seed:l,size:c,timeExtent:u,timeScale:p=1}=t,d=T(c),h=e.map((t,e)=>$(Y(t,e,o))).filter(t=>null!=t),g=$(u?.[0]),m=$(u?.[1]),f=h.length?Math.min(...h):0,y=h.length?Math.max(...h):f+i.size,x=Math.min(g??f,f),w=Math.max(m??y,y),b=Math.floor(x/i.size)*i.size,M=Math.max(1,Math.ceil((w-b+i.size)/i.size)),v=h.length?Math.max(...h):0,k="function"==typeof a?a(v):$(a?.value)??v-(a?.delay??i.size),S=Math.max(0,Math.min(M,Array.from({length:M},(t,e)=>e).reduce((t,e)=>b+(e+1)*i.size>k?t:t+1,0))),P=function(t,e){const o=Math.max(5*e,Math.min(92,.13*t.plot.width));return{gutter:{x:t.plot.x,y:t.plot.y,width:o,height:t.plot.height},windowPlot:{x:t.plot.x+o,y:t.plot.y,width:Math.max(40,t.plot.width-o),height:t.plot.height},wallTop:t.plot.y+.48*t.plot.height}}(d,s),A=b+M*i.size,I=_().domain([b,A]).range([P.windowPlot.x,P.windowPlot.x+P.windowPlot.width]),C=Array.from({length:M},()=>({value:0,secondary:0})),z=[];e.forEach((t,e)=>{const a=$(Y(t,e,o));if(null==a)return;const r=$(Y(t,e,n))??a,l=Math.max(0,Math.min(M-1,Math.floor((a-b)/i.size))),c=k>=b+(l+1)*i.size;C[l].value+=c?0:1,C[l].secondary+=c?1:0,z.push({id:(t.id??"event-"+e)+"",x:Math.max(P.windowPlot.x+s,Math.min(P.windowPlot.x+P.windowPlot.width-s,I(a))),y:d.plot.y+s+2,vx:8*(e%3-1),vy:0,mass:1,friction:.02,spawnAt:r,shape:{type:"circle",radius:s},datum:{...t,eventTime:a,arrivalTime:r,windowIndex:l,late:c}})});const R=d.plot.y+d.plot.height,L=function(t,e){const o=Math.max(0,Math.min(t.windowCount,t.closedWindowCount));if(!o)return[];const n=t.windowStart,i=t.windowStart+t.windowCount*t.windowSize,a=_().domain([n,i]).range([t.windowPlot.x,t.windowPlot.x+t.windowPlot.width]),r=a(t.windowStart+o*t.windowSize),s=t.windowPlot.x,l=e+Math.max(18,Math.min(.3*t.windowPlot.height,r-s)),c=t=>r===s?e:l+(t-s)/(r-s)*(e-l),u=[];for(let e=0;o>e;e+=1){const o=t.windowStart+e*t.windowSize,n=o+t.windowSize,i=a(o),r=a(n);u.push({id:"eventdrop-lid-"+e,windowIndex:e,x1:i,y1:c(i),x2:r,y2:c(r)})}return u}({closedWindowCount:S,gutter:P.gutter,plot:d.plot,windowCount:M,windowPlot:P.windowPlot,windowSize:i.size,windowStart:b},d.plot.y+.28*d.plot.height);return{config:j(l,[...r({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...O({idPrefix:"eventdrop-window",count:M,xScale:t=>I(b+t*i.size),yTop:P.wallTop,yTopForIndex:t=>{const e=(t=>{if(0>t||t>S)return null;const e=0===t?L[0]?.y1:L[t-1]?.y2??L[t]?.y1;return"number"==typeof e&&Number.isFinite(e)?e:null})(t);return null==e?P.wallTop:e+1.25*s},yBottom:R,wallThickness:6}),...L.map(t=>({id:t.id,shape:{type:"segment",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,thickness:Math.max(4,.42*s)},friction:.02,restitution:.01}))],"EventDropChart",{friction:.08}),initialSpawns:z,initialSpawnPacing:{pacing:"arrival",timeAccessor:t=>t.datum?.arrivalTime,timeScale:p},projectionRows:C.map((t,e)=>({label:`${b+e*i.size}-${b+(e+1)*i.size}`,value:t.value,secondary:t.secondary})),metadata:{kind:"event-drop",closedWindowCount:S,gutter:P.gutter,lidSegments:L,lateCount:C.reduce((t,e)=>t+e.secondary,0),plot:d.plot,windowPlot:P.windowPlot,watermarkValue:k,windowCount:M,windowSize:i.size,windowStart:b}}}function U(t={}){const e=(t.categories?.length?t.categories:["Intake","Review","Build","Ship"]).map(t=>(t+"").trim()).filter(Boolean),o=e.length?e:["Intake"],n=Math.max(o.length,Math.round(t.count??Math.max(48,12*o.length))),i=F(t.unitValue,1),a=B(t.seed??1),r=t.idPrefix??"mechanical-pile",s=o.map(()=>.65+.9*a()),l=s.reduce((t,e)=>t+e,0)||1,c=n-o.length,u=s.map(t=>t/l*c),p=u.map(t=>1+Math.floor(t));let d=n-p.reduce((t,e)=>t+e,0);const h=u.map((t,e)=>({index:e,fraction:t-Math.floor(t)})).sort((t,e)=>e.fraction-t.fraction);for(let t=0;d>0;t=(t+1)%h.length)p[h[t].index]+=1,d-=1;return o.map((t,e)=>({id:`${r}-${e}`,category:t,value:p[e]*i,mechanical:!0,unitCount:p[e],unitValue:i,share:p[e]/n}))}function H(t){const{data:e,categoryAccessor:o,valueAccessor:n,unitValue:i,ballRadius:a,seed:s,size:l}=t,c=F(i,1),u=T(l),p=[],d=new Map,h=new Map,g=[];function m(t){let e=d.get(t);return null==e&&(e=p.length,p.push(t),d.set(t,e)),e}e.forEach((t,e)=>{m((Y(t,e,o)??"unknown")+"")});const f=Math.max(1,p.length),y=function(t,e,o){const n=t.width/Math.max(1,e),i=Math.max(2,2*o),a=Math.min(.7*n,Math.max(3.2*i,i+8)),r=Math.max(1,Math.floor(a/i));return{laneWidth:n,tubeWidth:a,ballDiameter:i,perRow:r,centerX:e=>t.x+(e+.5)*n,pileHeight:t=>Math.ceil(Math.max(0,t)/r)*i}}(u.plot,f,a),x=Math.max(0,y.tubeWidth/2-a-1),w=p.map(()=>[]);e.forEach((t,e)=>{const i=(Y(t,e,o)??"unknown")+"",r=m(i),s=n?$(Y(t,e,n)):1,l=Math.max(0,Math.round((s??0)/c)),p=y.centerX(r);for(let o=0;l>o;o+=1){const n=h.get(i)??0,s=y.perRow>1?((y.perRow>1?n%y.perRow:0)/(y.perRow-1)*2-1)*x:0;h.set(i,n+1),w[r].push({id:`${(t.id??"pile-"+e)+""}-${o}`,x:p+s,y:u.plot.y+a+2,vx:(o%3-1)*a/2,vy:0,mass:1,shape:{type:"circle",radius:a},datum:{...t,category:i,unitIndex:o}})}});const b=w.reduce((t,e)=>Math.max(t,e.length),0);for(let t=0;b>t;t+=1)for(const e of w)e.length>t&&g.push(e[t]);const M=u.plot.y+u.plot.height,v=[...r({x:u.plot.x,y:u.plot.y,width:u.plot.width,height:u.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],k=u.plot.y-400;for(let t=0;f>t;t+=1){const e=y.centerX(t);for(const o of[-1,1])v.push({id:`pile-tube-${t}-${0>o?"l":"r"}`,shape:{type:"aabb",x:e+o*y.tubeWidth/2,y:(k+M)/2,width:6,height:M-k}})}return{config:j(s,v,"PhysicsPileChart"),initialSpawns:g,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:p.map(t=>({label:t,value:h.get(t)??0}))}}import{scaleLinear as K}from"d3-scale";function q(t){const{data:e,xAccessor:o,groupAccessor:n,radiusAccessor:i,pointRadius:a,seed:s,size:l,xExtent:c,collisionIterations:u,settle:p}=t,d=T(l),h=B(s),g=[],m=[],f=new Map;e.forEach((t,e)=>{const r=$(Y(t,e,o));if(null==r)return;const s=n?(Y(t,e,n)??"All")+"":"All",l=i?$(Y(t,e,i)):null,c=N(null!=l&&l>0?l:a,2,18);!function(t){let e=f.get(t);null==e&&(e=m.length,m.push(t),f.set(t,e))}(s),g.push({datum:t,index:e,value:r,group:s,radius:c})});const y=g.map(t=>t.value),x=c?$(c[0]):null,w=c?$(c[1]):null,b=y.length?Math.min(...y):0,M=y.length?Math.max(...y):1;let v=x??b,k=w??M;if(v===k&&(v-=.5,k+=.5),v>k){const t=k;k=v,v=t}const S=Math.max(a,...g.map(t=>t.radius)),P=d.plot.x+S+8,A=d.plot.x+d.plot.width-S-8,I=K().domain([v,k]).range([P,A]),C=Math.max(1,m.length),z=Math.min(Math.max(28,3*S),d.plot.height/4),R=d.plot.y+z,L=Math.max(0,d.plot.y+d.plot.height-z-R),E=t=>{const e=f.get(t)??0;return 1===C?d.plot.y+.54*d.plot.height:R+e/(C-1)*L},F=new Map,D=g.map((t,e)=>{F.set(t.group,(F.get(t.group)??0)+1);const o=I(t.value),n=E(t.group),i=(h()-.5)*t.radius*1.6,a=(h()-.5)*t.radius*1.6;return{id:(t.datum.id??"collision-swarm-"+e)+"",x:p?o+i:N(o+(e%9-4)*t.radius*2.5,P,A),y:p?n+a:d.plot.y-18-e%12*t.radius,vx:p?0:22*(h()-.5),vy:p?0:24+18*h(),mass:1,shape:{type:"circle",radius:t.radius},datum:{...t.datum,xValue:t.value,group:t.group,radius:t.radius,targetX:o,targetY:n},springs:[{target:{type:"point",x:o,y:n},restLength:0,stiffness:34,damping:5.5}]}});return{config:j(s,r({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"collision-swarm",includeCeiling:!1,wallThickness:20,floorThickness:20}),"CollisionSwarmChart",{gravity:{x:0,y:0},cellSize:Math.max(24,4*S),collisionIterations:Math.max(1,Math.round(u??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:D,projectionRows:m.map(t=>({label:t,value:F.get(t)??0})),metadata:{kind:"collision-swarm",xExtent:[v,k],xRange:[P,A],groups:m.map(t=>({label:t,y:E(t),count:F.get(t)??0})),plot:d.plot}}}function G(t){if(Array.isArray(t)&&t.length>=2){const e=$(t[0]),o=$(t[1]);return null!=e&&null!=o?{x:e,y:o}:null}if(t&&"object"==typeof t){const e=t,o=$(e.x),n=$(e.y);return null!=o&&null!=n?{x:o,y:n}:null}return null}function J(t){return Array.isArray(t)?t.map(G).filter(t=>null!=t):[]}function Q(t,e,o){return"normalized"===o?{x:e.plot.x+t.x*e.plot.width,y:e.plot.y+t.y*e.plot.height}:{x:N(t.x,e.plot.x,e.plot.x+e.plot.width),y:N(t.y,e.plot.y,e.plot.y+e.plot.height)}}function tt(t){let e=0;for(let o=1;t.length>o;o+=1)e+=Math.hypot(t[o].x-t[o-1].x,t[o].y-t[o-1].y);return e}function et(t,e){if(0===t.length)return{x:0,y:0};if(1===t.length)return{...t[0]};const o=N(e,0,1)*tt(t);let n=0;for(let e=1;t.length>e;e+=1){const i=t[e-1],a=t[e],r=Math.hypot(a.x-i.x,a.y-i.y);if(r>0){if(n+r>=o){const t=(o-n)/r;return{x:i.x+(a.x-i.x)*t,y:i.y+(a.y-i.y)*t}}n+=r}}return{...t[t.length-1]}}function ot(t,e){const o=et(t,Math.max(0,e-.02)),n=et(t,Math.min(1,e+.02)),i=n.x-o.x,a=n.y-o.y,r=Math.hypot(i,a)||1;return{x:i/r,y:a/r}}function nt(t){const{coordinateMode:e,flowSpeed:o,links:n,maxParticles:i,nodeIdAccessor:a,nodeXAccessor:s,nodeYAccessor:l,nodes:c,particleRadius:u,particleRate:p,pathAccessor:d,pathConstraint:h="path",reducedMotion:g,seed:m,size:f,sourceAccessor:y,targetAccessor:x,throughputAccessor:w}=t,b=T(f),M=B(m),v=new Map,k=new Map,S=[];function P(t){if(t&&"object"==typeof t){const e=t;if("function"==typeof a){const t=a(e,0);if(null!=t)return t+""}if("string"==typeof a&&null!=e[a])return e[a]+"";if(null!=e.id)return e.id+""}return(t??"unknown")+""}c.forEach((t,e)=>{const o=(Y(t,e,a)??t.id??e)+"",n=$(Y(t,e,s)),i=$(Y(t,e,l));if(null!=n&&null!=i){const t={x:n,y:i};v.set(o,t),S.push(t)}k.set(o,(t.label??t.name??o)+"")});const A=[];n.forEach((t,e)=>{const o=P(Y(t,e,y)),n=P(Y(t,e,x)),i=Math.max(0,$(Y(t,e,w))??0),a=J(d?Y(t,e,d):void 0),r=a.length?a:J(t.path??t.points??t.route);r.forEach(t=>S.push(t)),A.push({id:(t.id??`physical-flow-${o}-${n}-${e}`)+"",link:t,index:e,source:o,target:n,throughput:i,rawPath:r})});const I=(z=S,"normalized"===(C=e)||"pixels"===C?C:z.length>0&&z.every(t=>!(0>t.x||t.x>1||0>t.y||t.y>1))?"normalized":"pixels");var C,z;const R=new Map;for(const[t,e]of v)R.set(t,Q(e,b,I));const L=[];for(const t of A){let e=t.rawPath.map(t=>Q(t,b,I));if(2>e.length){const o=R.get(t.source),n=R.get(t.target);o&&n&&(e=[o,n])}else R.has(t.source)||R.set(t.source,e[0]),R.has(t.target)||R.set(t.target,e[e.length-1]);e.length>=2&&t.throughput>0&&(k.has(t.source)||k.set(t.source,t.source),k.has(t.target)||k.set(t.target,t.target),L.push({...t,path:e,packetCount:0}))}const E=F(p,.12),X=Math.max(1,Math.round(i)),W=L.map(t=>Math.max(1,Math.round(t.throughput*E))),V=W.reduce((t,e)=>t+e,0),_=V>X?X/V:1;L.forEach((t,e)=>{t.packetCount=Math.max(1,Math.floor(W[e]*_))});let O=L.reduce((t,e)=>t+e.packetCount,0);for(;O>X;){const t=L.reduce((t,e,o)=>e.packetCount>1&&(-1===t||e.packetCount>L[t].packetCount)?o:t,-1);if(-1===t)break;L[t].packetCount-=1,O-=1}const Z=new Map,U=new Map,H=[],K=F(o,90),q=F(u,4);L.forEach((t,e)=>{Z.set(t.target,(Z.get(t.target)??0)+t.throughput),U.set(t.source,(U.get(t.source)??0)+t.throughput);const o=tt(t.path);for(let n=0;t.packetCount>n;n+=1){const i=(n+.5)/t.packetCount,a=g?i:N(.12+.84*i+.04*(M()-.5),.04,.98),r=g?a:Math.max(0,a-(.18+.12*M())),s=et(t.path,r),l=et(t.path,a),c=ot(t.path,r),u={x:-c.y,y:c.x},p=(M()-.5)*q*1.5;H.push({id:`${t.id}-packet-${n}`,x:s.x+u.x*p,y:s.y+u.y*p,vx:g?0:c.x*K+10*(M()-.5),vy:g?0:c.y*K+10*(M()-.5),mass:.8,spawnAt:g?0:.04*e+n/32,shape:{type:"circle",radius:q},datum:{...t.link,source:t.source,target:t.target,throughput:t.throughput,packetIndex:n,packetCount:t.packetCount,routeProgress:a,flowPath:t.path,flowPathLength:o,flowRouteId:t.id,flowSpeed:K,sourceLabel:k.get(t.source)??t.source,targetLabel:k.get(t.target)??t.target},springs:"none"!==h&&g?[{target:{type:"point",x:l.x,y:l.y},restLength:.7*q,stiffness:26,damping:4.25}]:void 0})}});const G=Math.max(18,5*q),nt=Array.from(R,([t,e])=>({nodeId:t,label:k.get(t)??t,sensorId:"physical-flow-node-"+D(t),point:e})),it=nt.map(t=>({id:t.sensorId,sensor:!0,shape:{type:"aabb",x:t.point.x,y:t.point.y,width:G,height:G}})),at=Object.fromEntries(nt.map(t=>[t.sensorId,{binId:t.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),rt=j(m,[...r({x:b.plot.x,y:b.plot.y,width:b.plot.width,height:b.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...it],"PhysicalFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*q),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});rt.bodyLimit=X,rt.eviction="oldest",rt.observation={...rt.observation,sensors:at};const st=Array.from(R,([t,e])=>({id:t,label:k.get(t)??t,x:e.x,y:e.y,sensorId:"physical-flow-node-"+D(t),incoming:Z.get(t)??0,outgoing:U.get(t)??0})),lt=L.map(t=>({id:t.id,source:t.source,target:t.target,sourceLabel:k.get(t.source)??t.source,targetLabel:k.get(t.target)??t.target,throughput:t.throughput,packetCount:t.packetCount,path:t.path}));return{config:rt,initialSpawns:H,projectionRows:st.filter(t=>t.incoming>0||t.outgoing>0).map(t=>({label:t.label,value:t.incoming,secondary:t.outgoing})),metadata:{kind:"physical-flow",coordinateMode:I,particleCount:H.length,totalThroughput:L.reduce((t,e)=>t+e.throughput,0),plot:b.plot,nodes:st,links:lt}}}function it(t,e=12){return"number"==typeof t?{x:t,y:0}:t&&"object"==typeof t?{x:Number.isFinite(t.x)?Number(t.x):e,y:Number.isFinite(t.y)?Number(t.y):0}:{x:e,y:0}}function at(t){const e=t.stages;if(!e.length)throw Error("buildProcessFlowPhysics requires at least one stage");const o=t.size,r=T(o),s=N(t.ballRadius??6,2,18),g=t.seed??1,m=B(g),f=t.idAccessor,y=t.stageAccessor??"stage",x=t.groupBy,w=t.groupLabelAccessor,b=t.workAccessor,M=t.radiusAccessor,v=t.groupCompletion??(x?"allAbsorbed":"none"),k=t.springStiffness??.28,S=t.springDamping??.72,P=!0===t.settle,A=e.map(t=>({id:t.id,label:t.label??t.id,description:t.description,share:t.share})),I=d({width:o[0],height:o[1],shape:"lane",padX:Math.max(28,r.plot.x),padY:Math.max(36,r.plot.y+8),stages:A,idPrefix:"process-flow",includeMembraneRegions:!1,friction:.48,restitution:.14}),C=new Map(I.stages.map((t,e)=>[t.id,e])),z=new Map(I.stages.map(t=>[t.id,t])),R=I.stages[0].id,L=I.stages[0],E=new Set(e.filter(t=>t.absorb).map(t=>t.id)),j=e.map(t=>{const e=z.get(t.id)??L;return function(t,e){const o={id:"process-stage-"+t.id,label:t.label??t.id,description:t.description,x:e.x,y:e.y,width:Math.max(12,.92*e.width),height:Math.max(40,.88*e.height),semanticItem:!1,attributes:{stageId:t.id}};if(t.absorb)return n({...o,kind:t.kind??"sink",force:it(t.force,28),damping:t.damping??.04,charge:"absorbed",attributes:{...o.attributes,primitive:"absorb"}});if(t.portal){const e=t.portal.force??t.force??{x:-40,y:0};return u({...o,kind:t.kind??"force-field",force:it(e,-40),damping:t.damping??.1,targetStage:t.portal.targetStageId,attributes:{...o.attributes,primitive:"portal",targetStage:t.portal.targetStageId}})}if(t.capacity){const e=Math.max(.1,t.capacity.unitsPerSecond);return a({...o,kind:t.kind??"force-field",capacity:e,unitsPerSecond:e,force:it(t.force,10+.8*e),damping:t.damping??Math.max(.04,.32-.01*e),attributes:{...o.attributes,unitAccessor:t.capacity.unitAccessor,reviewerCapacity:e}})}if(t.pressure){const e="object"==typeof t.pressure&&t.pressure?t.pressure:{};return p({...o,kind:t.kind??"membrane",pressure:e.pressure,occupancy:e.occupancy,baseDamping:e.baseDamping??t.damping??.1,dampingPerUnit:e.dampingPerUnit??.1,energyPerUnit:e.energyPerUnit??0,force:it(t.force,8),attributes:{...o.attributes,primitive:"pressureField"}})}return null!=t.force||null!=t.damping?h({...o,kind:t.kind??"force-field",force:it(t.force,14),damping:t.damping??.02,attributes:{...o.attributes,primitive:"routeSurface"}}):l({...o,kind:t.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...o.attributes,primitive:"forceField"}})}(t,{x:e.x,y:I.midY,width:e.width,height:I.bottomY-I.topY})});j.unshift(h({id:"process-flow-route",label:"process route",description:"Baseline conveyor along the process lane.",x:(I.left+I.right)/2,y:I.midY,width:I.right-I.left,height:I.bottomY-I.topY-12,force:8,damping:.012,semanticItem:!1}));const F=new Map;for(const t of I.stages)F.set(t.id,0);const D=[];t.data.forEach((t,e)=>{const o=(f?Y(t,e,f)??t.id??"process-flow-"+e:t.id??"process-flow-"+e)+"",n=(Y(t,e,y)??R)+"",i=C.has(n)?n:R;F.set(i,(F.get(i)??0)+1);const a=x?(Y(t,e,x)??"")+"":void 0,r=a&&w?(Y(t,e,w)??a)+"":a,l=b?$(Y(t,e,b))??1:1,c=M?$(Y(t,e,M)):null,u=N(null!=c&&c>0?c:s,2,18);D.push({datum:t,id:o,stageId:i,groupId:a||void 0,groupLabel:r||void 0,work:l,radius:u,index:e})});const X=new Map,W=new Map;for(const t of D){if(!t.groupId)continue;const e=X.get(t.groupId)??[];e.push(t.id),X.set(t.groupId,e),t.groupLabel&&W.set(t.groupId,t.groupLabel)}const V=N(t.groupAnchorAlong??.55,.15,.9),_=I.left+(I.right-I.left)*V,O=Array.from(X.keys()),Z=O.map((t,o)=>{const n=X.get(t)??[],a=O.length>1?I.topY+28+o/Math.max(1,O.length-1)*(I.bottomY-I.topY-56):I.midY;return i({id:t,label:W.get(t)??t,bodyIds:n,anchor:{x:_,y:a},x:_,y:a,completion:"allAbsorbed"===v?{mode:"allMembersAbsorbed",targetZone:e.find(t=>t.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),U=D.filter(t=>E.has(t.stageId)).map(t=>t.id),H=c(Z,U),K=new Map(Z.map(t=>[t.id,t])),q=D.map((t,e)=>{const o=z.get(t.stageId)??L,n=o.x+(m()-.5)*Math.min(24,.2*o.width),i=I.boundaryY(n,"top")+t.radius+10,a=I.boundaryY(n,"bottom")-t.radius-10,r=a>i?i+m()*Math.max(1,a-i):I.midY,s=P?n:I.left+18+e%7*4,l=P?r:I.midY+(m()-.5)*(I.bottomY-I.topY)*.35,c=[{target:{type:"point",x:n,y:r},restLength:.45*t.radius,stiffness:k,damping:S}];if(t.groupId){const e=K.get(t.groupId);e?.anchor&&!E.has(t.stageId)&&c.push({target:{type:"point",x:e.anchor.x,y:e.anchor.y},restLength:e.tether?.restLength??22,stiffness:e.tether?.stiffness??.05,damping:.8})}return{id:t.id,x:s,y:l,vx:P?0:40+40*m(),vy:P?0:20*(m()-.5),mass:1,shape:{type:"circle",radius:t.radius},spawnAt:P?0:.03*e,springs:c,datum:{...t.datum,id:t.id,stage:t.stageId,groupId:t.groupId,groupLabel:t.groupLabel,work:t.work,__processFlow:!0}}}),G={kernel:{seed:g,gravity:{x:t.gravityX??22,y:t.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:I.colliders,fixedDt:1/60,maxSubsteps:8},J=I.stages.map(t=>({label:t.label??t.id,value:F.get(t.id)??0})),Q=e.map(t=>{const e=z.get(t.id)??L;return{id:t.id,label:t.label??t.id,x:e.x,width:e.width,count:F.get(t.id)??0,capacity:t.capacity?.unitsPerSecond,absorb:!0===t.absorb,portalTarget:t.portal?.targetStageId}});return{config:G,initialSpawns:q,initialSpawnPacing:P?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:J,metadata:{kind:"process-flow",plot:r.plot,volume:I,stages:Q,groups:Z,groupCompletion:H,regionEffects:j}}}function rt(t,e){const o=e.config??{},n=(e.sensors??[]).map(t=>({...t,sensor:!0})),i=[...e.colliders??[],...n],a=[...t.colliders??[],...o.colliders??[],...i];return{...t,...o,observation:{...t.observation,...o.observation},...a.length>0&&{colliders:a}}}function st(t){const e=function(t,e,o){const n=t?.observation;return{...t,observation:{...n,chartId:e??n?.chartId??"physics-custom",chartType:n?.chartType??"PhysicsCustomChart",onObservation:o??n?.onObservation}}}(t.config,t.chartId,t.onObservation),n=m(t.colorScheme,t.themeCategorical,y),i=T(t.size),a={data:t.data,scales:{x:R().domain(t.xExtent??[0,1]).range([i.plot.x,i.plot.x+i.plot.width]),y:R().domain(t.yExtent??[0,1]).range([i.plot.y+i.plot.height,i.plot.y])},dimensions:i,theme:{semantic:t.semantic,categorical:[...n]},resolveColor:g(n,t.colorScheme),config:t.layoutConfig??{},world:new o(e)},r=t.skipLayout?{}:t.layout(a)??{},s=function(t,e){if(!e?.length)return t;const o=new Map;for(const t of e){const{bodyId:e,...n}=t,i=o.get(e)??[];i.push(n),o.set(e,i)}return t.map(t=>{const e=o.get(t.id);return e?.length?{...t,springs:[...t.springs??[],...e]}:t})}([...r.initialSpawns??r.bodies??[]],r.constraints);return{config:rt(e,r),context:a,initialSpawnPacing:r.initialSpawnPacing,initialSpawns:s,result:r}}export{E as styleFromColorAccessor,W as generateGaltonMechanicalSamples,V as buildGaltonBoardPhysics,Z as buildEventDropPhysics,U as generatePhysicsPileMechanicalSamples,H as buildPhysicsPile,q as buildCollisionSwarmPhysics,nt as buildPhysicalFlowPhysics,at as buildProcessFlowPhysics,st as resolveCustomLayout,w as buildPhysicsSettledEvidence,k as physicsBodyToXYSceneNode,S as physicsBodiesToXYSceneNodes,P as buildPhysicsSettledScene,z as renderPhysicsSettledSVG};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(t){let n=1/0,o=-1/0;for(const e of t)n>e&&(n=e),e>o&&(o=e);return[n,o]}function n(t,n=1/0){let o=n;for(const n of t)o>n&&(o=n);return o}function o(t,n=-1/0){let o=n;for(const n of t)n>o&&(o=n);return o}function e(t,n=.5){const o=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t);if(!o)return t;const e=Math.round(parseInt(o[1],16)*(1-n)),r=Math.round(parseInt(o[2],16)*(1-n)),a=Math.round(parseInt(o[3],16)*(1-n));return`#${e.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}function r(t,n=.5){const o=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(t);if(!o)return t;const e=Math.round(parseInt(o[1],16)+(255-parseInt(o[1],16))*n),r=Math.round(parseInt(o[2],16)+(255-parseInt(o[2],16))*n),a=Math.round(parseInt(o[3],16)+(255-parseInt(o[3],16))*n);return`#${e.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${a.toString(16).padStart(2,"0")}`}var a="__forecastSegment",s="__forecastOpacity";function i(n,o,e,r){const a=o.uncertaintyOpacity,i=o.confidenceAccessor;if(!a&&!i)return;const l="object"==typeof a?a:{},c=l.min??.15,f=l.max??1;if(i){const t="function"==typeof i?i:t=>t[i];for(const o of n){const n=t(o);null!=n&&Number.isFinite(n)&&(o[s]=c+Math.max(0,Math.min(1,n))*(f-c))}return}const u=n.map(t=>{const n=e(t),o=r(t);return null!=n&&null!=o&&Number.isFinite(n)&&Number.isFinite(o)?Math.abs(n-o):NaN}),p=u.filter(t=>Number.isFinite(t));if(0===p.length)return;const[h,y]=t(p),d=y-h;n.forEach((t,n)=>{const o=u[n];Number.isFinite(o)&&(t[s]=f-(d>0?(o-h)/d:0)*(f-c))})}function l(t,n){return"function"==typeof n?n(t):!!t[n]}function c(t){return[{type:"anomaly-band",threshold:t.threshold??2,showBand:!1!==t.showBand,fill:t.bandColor||"#6366f1",fillOpacity:t.bandOpacity??.1,anomalyColor:t.anomalyColor||"#ef4444",anomalyRadius:t.anomalyRadius??6,label:t.label}]}function f(t,n,e,r,s){return(c=r).isTraining||c.isForecast||c.isAnomaly||c.upperBounds||c.lowerBounds?function(t,n,o,e,r){const{isTraining:s,isForecast:c,isAnomaly:f,upperBounds:u,lowerBounds:p,color:h="#6366f1",bandOpacity:y=.15,anomalyColor:d="#ef4444",anomalyRadius:b=6,label:g}=e,m=t.map(t=>{let n="observed";return c&&l(t,c)?n="forecast":s&&l(t,s)&&(n="training"),{...t,[a]:n}}),_=e._groupBy,k=[];if(_){const t=new Map;for(const n of m){const o=n[_]??"__default";t.has(o)||t.set(o,[]),t.get(o).push(n)}const n=[];for(const[,o]of t)for(let t=0;o.length-1>t;t++)o[t][a]!==o[t+1][a]&&(n.push({...o[t+1],[a]:o[t][a]}),n.push({...o[t],[a]:o[t+1][a]}));k.push(...m,...n)}else for(let t=0;m.length>t;t++)k.push(m[t]),m.length-1>t&&m[t][a]!==m[t+1][a]&&(k.push({...m[t+1],[a]:m[t][a]}),k.push({...m[t],[a]:m[t+1][a]}));if(e.trainUnderline){const t=[];for(const n of k)"training"===n[a]&&t.push({...n,[a]:"training-base"});k.unshift(...t)}const O=[];if(u&&p){const t="string"==typeof u?u:"__envUpper",n="string"==typeof p?p:"__envLower";if("function"==typeof u||"function"==typeof p)for(const o of k)"function"==typeof u&&(o[t]=u(o)),"function"==typeof p&&(o[n]=p(o));O.push({type:"envelope",upperAccessor:t,lowerAccessor:n,fill:h,fillOpacity:y,label:g})}if(e.uncertaintyOpacity||e.confidenceAccessor){const t=u?"function"==typeof u?u:t=>t[u]:()=>{},n=p?"function"==typeof p?p:t=>t[p]:()=>{};i(k.filter(t=>"forecast"===t[a]),e,t,n)}if(f){const t=e.anomalyStyle,n={type:"highlight",filter:t=>l(t,f)};t?(n.style=t,n.r=b):"function"==typeof d?(n.style=t=>{const n=d(t);return{stroke:n,strokeWidth:1.5,fill:n,fillOpacity:.7}},n.r=b):(n.color=d,n.r=b,n.style={stroke:d,strokeWidth:1.5,fill:d,fillOpacity:.7}),O.push(n)}return r&&O.push({type:"anomaly-band",threshold:r.threshold??2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:r.bandOpacity??.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:r.anomalyRadius??6,label:r.label}),{processedData:k,annotations:O}}(t,0,0,r,s):function(t,n,e,r,s){const{trainEnd:l,steps:c=10,confidence:f=.95,color:u="#6366f1",bandOpacity:p=.15,label:h}=r;if(null==l)return{processedData:t,annotations:[]};const y=[],d=[];for(const o of t)o[n]>l?d.push({...o,[a]:"observed"}):y.push({...o,[a]:"training"});const b=y.map(t=>[t[n],t[e]]).filter(t=>null!=t[0]&&null!=t[1]&&isFinite(t[0])&&isFinite(t[1])).sort((t,n)=>t[0]-n[0]),g=[],m=[];if(b.length>=3){const s=b.length;let l=0,y=0,d=0,_=0;for(const[t,n]of b)l+=t,y+=n,d+=t*t,_+=t*n;const k=s*d-l*l;if(Math.abs(k)>1e-12){const d=(s*_-l*y)/k,O=(y-d*l)/s,w=t=>O+d*t,S=b.map(([t,n])=>n-w(t)).reduce((t,n)=>t+n*n,0),M=Math.sqrt(S/Math.max(s-2,1)),B=b.reduce((t,n)=>t+n[0],0)/s,F=b.reduce((t,n)=>t+(n[0]-B)**2,0),v=.99>f?.95>f?.9>f?1:1.645:1.96:2.576,C=o(t.map(t=>t[n]).filter(t=>null!=t&&isFinite(t))),D=b.length>1?(b[s-1][0]-b[0][0])/(s-1):1;for(let t=1;c>=t;t++){const o=C+t*D,r=w(o),i=M*Math.sqrt(1+1/s+(F>0?(o-B)**2/F:0))*v;m.push({[n]:o,[e]:r,[a]:"forecast",__forecastUpper:r+i,__forecastLower:r-i})}i(m,r,t=>t.__forecastUpper,t=>t.__forecastLower),g.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:u,fillOpacity:p,label:h})}}g.push({type:"x-threshold",x:l,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),s&&g.push({type:"anomaly-band",threshold:s.threshold??2,showBand:!1!==s.showBand,fill:s.bandColor||"#6366f1",fillOpacity:s.bandOpacity??.1,anomalyColor:s.anomalyColor||"#ef4444",anomalyRadius:s.anomalyRadius??6,label:s.label});const _=[];if(_.push(...y),y.length>0&&d.length>0&&_.push({...y[y.length-1],[a]:"observed"}),_.push(...d),m.length>0){const t=d.length>0?d[d.length-1]:y[y.length-1];t&&_.push({...t,[a]:"forecast"}),_.push(...m)}return{processedData:_,annotations:g}}(t,n,e,r,s);var c}function u(t,n){const o=n.trainDasharray??"8,4",i=n.forecastDasharray??"4,4",l=n.color||"#6366f1",c=n.trainOpacity,f=n.forecastOpacity,u=n.trainStroke,p=n.trainLinecap,h=n.trainUnderline;return n=>{const y=t(n),d=n[a];if("training"===d){let t=y.stroke;return"darken"===u?t=e(y.stroke||"#666",.5):u&&(t=u),{...y,stroke:t,strokeDasharray:o,...p&&{strokeLinecap:p},...null!=c&&{strokeOpacity:c}}}if("training-base"===d){let t=y.stroke||"#666";return"lighten"===h&&(t=r(t,.4)),{...y,stroke:t,strokeDasharray:void 0}}if("forecast"===d){const t=n[s],o=null!=t?t:f;return{...y,stroke:l,strokeDasharray:i,...null!=o&&{strokeOpacity:o}}}return y}}export{t as getMinMax,n as getMin,o as getMax,e as darkenColor,r as lightenColor,a as SEGMENT_FIELD,s as FORECAST_OPACITY_FIELD,i as stampForecastOpacity,c as buildAnomalyAnnotations,f as buildForecast,u as createSegmentLineStyle};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{lineCanvasRenderer as t,resolveNodeColor as e}from"./chunk-chunk-6TPGFL7M.module.min.js";import{DataSourceAdapter as i,IncrementalExtent as o,accessorsEquivalent as s,barCanvasRenderer as n,buildAreaNode as r,buildEnrichAnnotationData as a,buildHeatcellNode as l,buildLineNode as c,buildPointNode as h,buildRectNode as u,buildStackedAreaNodes as g,buildSymbolNode as d,computeDivergingStackExtent as f,computeStackOffsets as p,resolveAccessor as y,resolveAnnotationAccessor as m,resolveFrameGraphics as x,resolveRawAccessor as v,resolveStringAccessor as b,symbolCanvasRenderer as k,ticksForMode as w,toIdSet as A}from"./chunk-chunk-AQPQN2HH.module.min.js";import{RingBuffer as _,applyPulse as C,buildAggregateRibbons as S,buildPerSeriesRibbons as M,compactTimestampBufferForRemoval as P,createTimestampBufferForData as Y,enrichDatumWithBand as R,ensureRingBufferCapacity as T,hasActivePulses as N,partitionRibbons as O,pointCanvasRenderer as W,pushWithTimestamp as D,refreshIdlePulse as E,useLegendCategoryEmission as z,useSemanticFrameInteractions as F,useXYKeyboardNavigation as L}from"./chunk-chunk-F5V4UIE6.module.min.js";import{needsInteractionCanvasPaint as B,paintCanvasBackground as I,resolveCanvasBackground as X}from"./chunk-chunk-KQ546MKE.module.min.js";import{StalenessBadge as $,applyDecay as G,attachUpdateResultStore as V,buildDatumIndexMap as H,composeOverlays as j,computeDecayOpacity as q,createCustomLayoutFailureDiagnostic as U,filterAnnotationsByStatus as K,findHitPointInQuadtree as J,getHitRadius as Q,glyphCanvasRenderer as Z,hitTestRect as tt,isTimeLandmark as et,paintSceneWithBackend as it,renderPathPulse as ot,renderRectPulse as st,renderSceneWithBackend as nt,resolveStaleness as rt,useConfigSync as at,useLayoutSelectionSync as lt,useStableShallow as ct,useStalenessCheck as ht,warnCustomLayoutDiagnostics as ut}from"./chunk-chunk-F7WFPD4O.module.min.js";import{wrapWithCustomLayoutSelection as gt}from"./chunk-chunk-5UKL5W76.module.min.js";import{AccessibleDataTable as dt,AriaLiveTooltip as ft,CanvasFrameBackground as pt,FlippingTooltip as yt,FocusRing as mt,SEQUENTIAL_INTERPOLATORS as xt,STREAMING_PALETTE as vt,SYMBOL_SEQUENCE as bt,SceneRevisionDiagnosticsObserver as kt,ScreenReaderSummary as wt,SkipToTableLink as At,TITLE_BASELINE as _t,UpdateResultTracker as Ct,annotationLayout as St,buildColorStopGradient as Mt,buildHoverData as Pt,buildLinearFillGradient as Yt,computeCanvasAriaLabel as Rt,computeEasing as Tt,computeRawProgress as Nt,createDefaultAnnotationRules as Ot,defaultTooltipStyle as Wt,filterSparseArray as Dt,getCSSColorCacheVersion as Et,getDevicePixelRatio as zt,getPointerHitRadius as Ft,getSequentialInterpolator as Lt,isAnnotationActivationTarget as Bt,isServerEnvironment as It,lerp as Xt,now as $t,observationInputType as Gt,prepareCanvas as Vt,renderAnnotationPass as Ht,renderLegendFromConfig as jt,resolveCSSColor as qt,resolveCanvasFill as Ut,resolveCurveFactory as Kt,smartTooltipEntries as Jt,symbolRadius as Qt,unlockCrosshair as Zt,useAnnotationActivationOptions as te,useCrosshairPosition as ee,useFrame as ie,useFrameCanvasHost as oe,useSceneRevisionDiagnostics as se,xySceneNodeToSVG as ne}from"./chunk-chunk-BFHUYEOS.module.min.js";import{getMax as re}from"./chunk-chunk-JJ2OOIET.module.min.js";import{resolveThemeSemanticColors as ae}from"./chunk-chunk-WCX6U47H.module.min.js";import{glyphHitGeometry as le}from"./chunk-chunk-KTWEBFMX.module.min.js";import{useHydration as ce,useWasHydratingFromSSR as he}from"./chunk-chunk-ACLDBMRH.module.min.js";import*as ue from"react";import{useRef as ge,useState as de,useEffect as fe,useMemo as pe,useCallback as ye,useImperativeHandle as me,useId as xe,forwardRef as ve,memo as be}from"react";import*as ke from"react";import{jsx as we}from"react/jsx-runtime";var Ae=null,_e=null;function Ce(t){const[e,i]=ke.useState(()=>Ae);return ke.useEffect(()=>{if(e)return;let t=!1;return(Ae?Promise.resolve(Ae):(_e||(_e=import("./chunk-XYBrushOverlay-EP2SV3UI.module.min.js").then(t=>Ae=t.XYBrushOverlay).catch(t=>{throw _e=null,t})),_e)).then(e=>{t||i(()=>e)}),()=>{t=!0}},[e]),e?we(e,{...t}):null}var Se=/^\d{4}-\d{1,2}$/;function Me(t){const e=t.trim();if(!e||!Number.isNaN(Number(e)))return NaN;const i=Se.test(e)?e+"-01":e;if(i===e&&10>e.length)return NaN;const o=Date.parse(i);return Number.isFinite(o)?o:NaN}function Pe(t){return t instanceof Date?t.getTime():"string"==typeof t?Me(t):+t}function Ye(t,e,i){if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const i=t.getX(e.datum),o=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${i}:${o}`;if(null!=i&&null!=o)return`p:${i}:${o}`}return"p:"+i;case"glyph":return e.pointId?"g:"+e.pointId:"g:"+i;case"rect":return`r:${e.group||""}:${e.datum?.binStart??e.datum?.category??i}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+i:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function Re(t,e,i,o){if(!t.config.pointStyle)return;const s=o??t.getY;for(const o of e){const e=t.resolveGroupColor(o.key);for(const n of o.data){let o=t.config.pointStyle(n);!o.fill&&e&&(o={...o,fill:e});const r=o.r??3,a=t.getPointId?t.getPointId(n)+"":void 0,l=h(n,t.scales,t.getX,s,r,o,a);l&&i.push(l)}}}function Te(t){return"threshold"===t.type&&"string"==typeof t.color&&"number"==typeof t.value}var Ne={topOpacity:.8,bottomOpacity:.05};function Oe(t){if(t)return!0===t?Ne:"colorStops"in t?t:{topOpacity:t.topOpacity??Ne.topOpacity,bottomOpacity:t.bottomOpacity??Ne.bottomOpacity}}var We=new Map;function De(t,e,i){const o=i.config.areaStyle?.(e);return o&&(t.style=o),t}function Ee(t,e,i,o,s){const n=new Map;for(const r of t){const t=e(r),a=i(r);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const l=Math.floor(t/o)*o;let c=n.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},n.set(l,c)),c.total+=a,s){const t=s(r);c.categories.set(t,(c.categories.get(t)||0)+a)}}return n}function ze(t,e){const i="function"==typeof t?t:i=>i[t||e];return t=>{const e=i(t);return null==e?NaN:+e}}function Fe(t){const e=[],i=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,o=ze(i&&t.valueAccessor||t.yAccessor,i?"value":"y");if(t.boundsAccessor){const i=y(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const s=i(t);return Number.isFinite(s)&&0!==s?e+s:e},getBottom:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const s=i(t);return Number.isFinite(s)&&0!==s?e-s:e},style:t.boundsStyle,perSeries:!0,interactive:!1})}if(t.band){const i=Array.isArray(t.band)?t.band:[t.band];for(const t of i)e.push({kind:"band",getTop:ze(t.y1Accessor,"y1"),getBottom:ze(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}import{scaleLinear as Le,scaleLog as Be,scaleSymlog as Ie,scaleTime as Xe}from"d3-scale";function $e(t,e){return e?[e[0]??t[0],e[1]??t[1]]:t}function Ge(t,e,i){if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return Be().domain(t).range(i).clamp(!0)}return"symlog"===t?Ie().domain(e).range(i):"time"===t?Xe().domain([new Date(e[0]),new Date(e[1])]).range(i):Le().domain(e).range(i)}var Ve=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],He=["scene-style","data-paint","accessibility","evidence"],je=(t,e)=>({retainedData:t,invalidations:e}),qe=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ue=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ke=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Je=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Qe=["scene-geometry","data-paint","accessibility","evidence"],Ze=["scene-style","data-paint","accessibility","evidence"],ti=[],ei={chartType:je("rebuild",qe),runtimeMode:je("rebuild",qe),xAccessor:je("rebuild",qe),yAccessor:je("rebuild",qe),timeAccessor:je("rebuild",qe),valueAccessor:je("rebuild",qe),y0Accessor:je("rebuild",qe),boundsAccessor:je("rebuild",qe),band:je("rebuild",qe),openAccessor:je("rebuild",qe),highAccessor:je("rebuild",qe),lowAccessor:je("rebuild",qe),closeAccessor:je("rebuild",qe),candlestickRangeMode:je("rebuild",qe),accessorRevision:je("rebuild",qe),groupAccessor:je("rebuild",Ue),categoryAccessor:je("rebuild",Ue),lineDataAccessor:je("rebuild",Ue),colorAccessor:je("rebuild",Ze),sizeAccessor:je("rebuild",Qe),symbolAccessor:je("rebuild",Qe),pointIdAccessor:je("rebuild",Qe),xScaleType:je("preserve",Ke),yScaleType:je("preserve",Ke),xExtent:je("preserve",Ke),yExtent:je("preserve",Ke),extentPadding:je("preserve",Ke),scalePadding:je("preserve",Ke),axisExtent:je("preserve",Ke),binSize:je("preserve",Ke),normalize:je("preserve",Ke),heatmapAggregation:je("preserve",Ke),heatmapXBins:je("preserve",Ke),heatmapYBins:je("preserve",Ke),arrowOfTime:je("preserve",Je),baseline:je("preserve",Je),stackOrder:je("preserve",Je),sizeRange:je("preserve",Je),curve:je("preserve",Je),areaGroups:je("preserve",Je),customLayout:je("preserve",Je),layoutConfig:je("preserve",Je),layoutMargin:je("preserve",Je),symbolMap:je("preserve",Qe),showValues:je("preserve",Qe),heatmapValueFormat:je("preserve",Qe),lineStyle:je("preserve",Ze),pointStyle:je("preserve",Ze),areaStyle:je("preserve",Ze),barStyle:je("preserve",Ze),swarmStyle:je("preserve",Ze),waterfallStyle:je("preserve",Ze),candlestickStyle:je("preserve",Ze),boundsStyle:je("preserve",Ze),gradientFill:je("preserve",Ze),lineGradient:je("preserve",Ze),colorScheme:je("preserve",Ze),themeCategorical:je("preserve",Ze),themeSemantic:je("preserve",Ze),themeSequential:je("preserve",Ze),themeDiverging:je("preserve",Ze),barColors:je("preserve",Ze),decay:je("preserve",Ze),pulse:je("preserve",Ze),staleness:je("preserve",Ze),layoutSelection:je("preserve",Ze),annotations:je("preserve",["overlay","accessibility","evidence"]),windowSize:je("preserve",ti),windowMode:je("preserve",ti),maxCapacity:je("preserve",ti),clock:je("preserve",ti),transition:je("preserve",ti),introAnimation:je("preserve",ti),onLayoutError:je("preserve",ti)},ii=je("preserve",Je),oi=class{constructor(){this.tracker=new Ct}get last(){return this.tracker.last}subscribe(t){return this.tracker.subscribe(t)}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},Ve)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},He):this.recordNoop("restyle")}recordConfig(t){const e=function(t){let e="preserve";const i=new Set;for(const o of t){const t=ei[o]??ii;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}(t);return this.tracker.record({kind:"config",keys:t},e.invalidations)}};import{quadtree as si}from"d3-quadtree";var ni=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(t,e){if("scatter"!==t&&"bubble"!==t&&"custom"!==t)return void this.clear();let i=0,o=0;for(const t of e)"point"===t.type&&(i++,t.r>o&&(o=t.r));if(this.maxRadius=o,500>=i)return void(this.tree=null);const s=Array(i);let n=0;for(const t of e)"point"===t.type&&(s[n++]=t);this.tree=si().x(t=>t.x).y(t=>t.y).addAll(s)}},ri=class t{constructor(t){if(this.xExtent=new o,this.yExtent=new o,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._datumIndexCache=null,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.updateResults=new oi,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.xIsDate=!1,this.spatialIndex=new ni,this._lastBoundedInsertsRef=null,this.applyPulse=(t,e,i)=>!(!this.config.pulse||!this.timestampBuffer)&&C(this.config.pulse,t,e,this.timestampBuffer,this.getDatumIndexMap(e),i),this.config=t,this.buffer=new _(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=y(t.timeAccessor||t.xAccessor,"time"),this.getY=y(t.valueAccessor||t.yAccessor,"value")):(this.getX=y(t.xAccessor,"x"),this.getY=y(t.yAccessor,"y")),this.getGroup=b(t.groupAccessor),this.getCategory=b(t.categoryAccessor),this.getSize=t.sizeAccessor?y(t.sizeAccessor,"size"):void 0,this.getColor=b(t.colorAccessor),this.getSymbol=b(t.symbolAccessor),this.getY0=t.y0Accessor?y(t.y0Accessor,"y0"):void 0,this.resolvedRibbons=Fe(t),this.getPointId=b(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,i=null!=t.closeAccessor;this.getOpen=e?y(t.openAccessor,"open"):void 0,this.getHigh=y(t.highAccessor,"high"),this.getLow=y(t.lowAccessor,"low"),this.getClose=i?y(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!i}t.pulse&&(this.timestampBuffer=new _(t.windowSize))}currentTime(){return this.config.clock?.()??$t()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=Y(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(t)),void this.yExtent.push(this.getLow(t));this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t));for(const e of this.resolvedRibbons){const i=e.getTop(t),o=e.getBottom(t);Number.isFinite(i)&&this.yExtent.push(i),Number.isFinite(o)&&this.yExtent.push(o)}}evictDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(t)),void this.yExtent.evict(this.getLow(t));this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t));for(const e of this.resolvedRibbons){const i=e.getTop(t),o=e.getBottom(t);Number.isFinite(i)&&this.yExtent.evict(i),Number.isFinite(o)&&this.yExtent.evict(o)}}rebuildYExtent(){this.yExtent.clear();for(const t of this.buffer)this.pushDatumYExtent(t)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const t of this.buffer)this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t)}ingest(t){if(t.bounded&&this._lastBoundedInsertsRef===t.inserts)return this.updateResults.recordNoop("replace"),!1;const e=this.currentTime();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){this._lastBoundedInsertsRef=t.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=i?y(this.config.timeAccessor||this.config.xAccessor,"time"):y(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],i=this.config.xAccessor,o="function"==typeof i?i(e):e[i||"x"],s=o instanceof Date,n="string"==typeof o&&Number.isFinite(Me(o));if(this.xIsDate=s||n,n){const t="string"==typeof i?i:void 0;this.getX=t?e=>Pe(e[t]):t=>Pe(i(t))}}T(this.buffer,t.totalSize||t.inserts.length,this.timestampBuffer);for(const i of t.inserts)D(this.buffer,i,this.timestampBuffer,e),this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i)}else for(const i of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity??1e5;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"===process.env.NODE_ENV||this.growingCapacityWarned||5e4>this.growingCap||(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${t}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const t=D(this.buffer,i,this.timestampBuffer,e);this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i),null!=t&&(this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t))}return this.updateResults.recordData(t.bounded?"replace":"ingest",t.inserts.length),!0}ingestWithResult(t){return this.ingest(t),this.updateResults.last}computeScene(t){const{config:e,buffer:i}=this,o=this.scales,s=this.lastLayout;if(!this.needsFullRebuild&&!e.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);this.xExtent.dirty&&this.xExtent.recalculate(i,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const n=this.getBufferArray(),r=this.yExtent.extent;let a=$e(this.xExtent.extent,e.xExtent),l=$e(r,e.yExtent);const c=!(!(h=e.yExtent)||null==h[0]||null==h[1]);var h;const u="exact"===e.axisExtent;if("stackedarea"===e.chartType&&!c&&i.size>0){const t=function(t){const{config:e,groups:i,getX:o,getY:s}=t,n="exact"===e.axisExtent;if(e.normalize){const i=[0,n?1:1+e.extentPadding];return{yDomain:i,stackExtentCache:{key:`${t.bufferSize}:${t.ingestVersion}:norm`,yDomain:i}}}const r=`${t.bufferSize}:${t.ingestVersion}:${e.baseline??"zero"}:${e.stackOrder??"key"}`;if(t.stackExtentCache&&t.stackExtentCache.key===r)return{yDomain:t.stackExtentCache.yDomain,stackExtentCache:t.stackExtentCache};const a=new Map,l=new Set;let c=0;const h=new Map,u=new Map;for(const t of i){const e=new Map;let i=0;for(const n of t.data){const t=o(n),r=s(n);if(!Number.isFinite(t)||!Number.isFinite(r))continue;e.set(t,(e.get(t)||0)+r),l.add(t),i+=r;const a=(h.get(t)||0)+r;h.set(t,a),a>c&&(c=a)}a.set(t.key,e),u.set(t.key,i)}const g=e.stackOrder??"key",d=(t,e)=>e>t?-1:t>e?1:0;let y,m;if("input"===g)y=i.map(t=>t.key);else if("insideOut"===g){const t=[...i].map(t=>t.key).sort((t,e)=>{const i=(u.get(e)??0)-(u.get(t)??0);return 0!==i?i:d(t,e)}),e=[],o=[];let s=0,n=0;for(const i of t)n>s?(e.push(i),s+=u.get(i)??0):(o.push(i),n+=u.get(i)??0);y=[...o.reverse(),...e]}else y="asc"===g?i.map(t=>t.key).sort((t,e)=>{const i=(u.get(t)??0)-(u.get(e)??0);return 0!==i?i:d(t,e)}):"desc"===g?i.map(t=>t.key).sort((t,e)=>{const i=(u.get(e)??0)-(u.get(t)??0);return 0!==i?i:d(t,e)}):i.map(t=>t.key).sort(d);if("wiggle"===e.baseline||"silhouette"===e.baseline){const t=Array.from(l).sort((t,e)=>t-e),i=p(t,y,(t,e)=>a.get(t)?.get(e)||0,e.baseline);let o=1/0,s=-1/0;for(const e of t){const t=i.get(e)??0,n=h.get(e)??0;o>t&&(o=t),t+n>s&&(s=t+n)}Number.isFinite(o)&&Number.isFinite(s)||(o=0,s=0);const r=s-o,c=n?0:r>0?r*e.extentPadding:1;m=[o-c,s+c]}else if("diverging"===e.baseline){const t=Array.from(l).sort((t,e)=>t-e),[i,o]=f(t,y,(t,e)=>a.get(t)?.get(e)||0),s=o-i,r=n?0:s>0?s*e.extentPadding:1;m=[i-r,o+r]}else m=[0,c+(n?0:c>0?c*e.extentPadding:1)];return{yDomain:m,stackExtentCache:{key:r,yDomain:m}}}({config:e,groups:this.groupData(n),getX:this.getX,getY:this.getY,bufferSize:i.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});l=t.yDomain,this._stackExtentCache=t.stackExtentCache}else"bar"===e.chartType&&e.binSize&&!c&&i.size>0?l=function(t,e,i,o,s,n,r){const[,a]=function(t,e,i,o,s){const n=Ee(t,e,i,o,s);if(0===n.size)return[0,0];let r=0;for(const t of n.values())t.total>r&&(r=t.total);return[0,r]}(t,e,i,o,s);return[0,r?a:a+a*n]}(i,this.getX,this.getY,e.binSize,this.getCategory,e.extentPadding,u):"waterfall"===e.chartType&&!c&&i.size>0?l=function(t,e,i,o){const[s,n]=function(t,e){let i=0,o=0,s=0;for(const n of t){const t=e(n);null==t||Number.isNaN(t)||(s+=t,i>s&&(i=s),s>o&&(o=s))}return[i,o]}(t,e),r=n-s,a=o?0:r>0?r*i:1;return[Math.min(0,s-Math.abs(a)),Math.max(0,n+Math.abs(a))]}(i,this.getY,e.extentPadding,u):c||l[0]===1/0||(l=function(t,e,i){if(!i.length)return t;let[o,s]=t;for(const t of e)for(const e of i){const i=e.getTop(t),n=e.getBottom(t);Number.isFinite(i)&&(o>i&&(o=i),i>s&&(s=i)),Number.isFinite(n)&&(o>n&&(o=n),n>s&&(s=n))}return[o,s]}(l,n,this.resolvedRibbons),l=function(t,e){const i=t[1]-t[0],o=e.exactMode?0:i>0?i*e.extentPadding:1,s=[null!=e.userMin?t[0]:t[0]-o,null!=e.userMax?t[1]:t[1]+o];return"log"!==e.yScaleType||s[0]>0||0>=e.dataYDomain[0]||e.exactMode||null==e.userMin&&(s[0]=e.dataYDomain[0]/(1+e.extentPadding)),s}(l,{exactMode:u,extentPadding:e.extentPadding,userMin:e.yExtent?.[0],userMax:e.yExtent?.[1],yScaleType:e.yScaleType,dataYDomain:r}));l=function(t,e,i){if(!e||i)return t;const o=e[0],s=e[1];return null==o&&null==s?t:[null!=o?o:t[0],null!=s?s:t[1]]}(l,e.yExtent,!!c),({xDomain:a,yDomain:l}=function(t,e,i){let o=t,s=e;if(o[0]===1/0||o[1]===-1/0)if("time"===i){const t=Date.now();o=[t-864e5,t]}else o=[0,1];return s[0]!==1/0&&s[1]!==-1/0||(s=[0,1]),{xDomain:o,yDomain:s}}(a,l,e.xScaleType)),this.scales=function(t){const{config:e,layout:i,xDomain:o,yDomain:s}=t,n="streaming"===e.runtimeMode,r=Math.max(0,Math.min(e.scalePadding||0,Math.min(i.width,i.height)/2-1));if(n){if("x"==("up"===(a=e.arrowOfTime)||"down"===a?"y":"x")){const t="right"===e.arrowOfTime?[r,i.width-r]:[i.width-r,r];return{x:Le().domain(o).range(t),y:Ge(e.yScaleType,s,[i.height-r,r])}}const t="down"===e.arrowOfTime?[r,i.height-r]:[i.height-r,r];return{x:Ge(e.yScaleType,s,[r,i.width-r]),y:Le().domain(o).range(t)}}var a;return{x:Ge(e.xScaleType,o,[r,i.width-r]),y:Ge(e.yScaleType,s,[i.height-r,r])}}({config:e,layout:t,xDomain:a,yDomain:l}),this._customLayoutFailedThisBuild=!1;const g=this.buildSceneNodes(t,n);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=o,this.lastLayout=s):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=g,this.config.decay&&this.applyDecay(this.scene,n),this.config.pulse&&this.applyPulse(this.scene,n,this.currentTime()),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,i=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const o of t.path)o[0]*=e,o[1]*=i;break;case"area":for(const o of t.topPath)o[0]*=e,o[1]*=i;for(const o of t.bottomPath)o[0]*=e,o[1]*=i;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*i,width:t.clipRect.width*e,height:t.clipRect.height*i});break;case"point":case"glyph":t.x*=e,t.y*=i;break;case"rect":case"heatcell":t.x*=e,t.y*=i,t.w*=e,t.h*=i;break;case"candlestick":t.x*=e,t.openY*=i,t.closeY*=i,t.highY*=i,t.lowY*=i}const o=this.scales.x.domain(),s=this.scales.y.domain(),n=this.scales.x.range(),r=this.scales.y.range(),a=Ge,l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),c=r[1]>r[0];this.scales={x:a(this.config.xScaleType,o,n[0]>n[1]?[t.width-l,l]:[l,t.width-l]),y:a(this.config.yScaleType,s,c?[l,t.height-l]:[t.height-l,l])},this.lastLayout={width:t.width,height:t.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(t,e){const{config:i,scales:o}=this;if(!o)return[];if(i.customLayout){const s={data:e,scales:o,dimensions:{width:t.width,height:t.height,margin:i.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:i.themeSemantic??{},categorical:i.themeCategorical??vt},resolveColor:(t,e)=>{const o=this.resolveGroupColor(t);if(o)return o;const s=this.resolveLineStyle(t,e);return s.stroke?s.stroke:"string"==typeof s.fill?s.fill:i.themeSemantic?.primary??"#4e79a7"},config:i.layoutConfig??{},selection:i.layoutSelection??null};let n;try{n=i.customLayout(s)}catch(t){const e=null!==this.lastCustomLayoutResult,o=U("xy",t,e,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t);try{i.onLayoutError?.(o)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return e?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=n.overlays??null,this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null;const r=n.nodes??[];if(this._customRestyle=n.restyle,this.hasCustomRestyle=!!n.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of r)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(r,i.layoutSelection??null)}return ut({label:"customLayout",nodes:r,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),r}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===e.length)return[];const s={scales:o,config:i,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(i.chartType){case"line":return function(t,e){const i=t.groupData(e),o=[],s=t.config.annotations?.filter(Te).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.ribbons&&t.ribbons.length>0){const{perSeries:s,aggregate:n}=O(t.ribbons);if(n.length>0&&o.push(...S(t,e,n)),s.length>0)for(const e of i)o.push(...M(t,e.data,e.key,s))}for(const e of i){const i=t.resolveLineStyle(e.key,e.data[0]),n=c(e.data,t.scales,t.getX,t.getY,i,e.key);s&&s.length>0&&(n.colorThresholds=s),t.config.curve&&"linear"!==t.config.curve&&(n.curve=t.config.curve),t.config.lineGradient&&(n.strokeGradient=t.config.lineGradient),o.push(n)}return Re(t,i,o),o}(s,e);case"area":return function(t,e){const i=t.groupData(e),o=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:s,aggregate:n}=O(t.ribbons);if(n.length>0&&o.push(...S(t,e,n)),s.length>0)for(const e of i)o.push(...M(t,e.data,e.key,s))}const s=t.scales.y.domain()[0],n=t.getY0?e=>{const i=t.getY0(e);return null==i?s:i}:void 0;for(const e of i){const i=t.resolveAreaStyle(e.key,e.data[0]),a=r(e.data,t.scales,t.getX,t.getY,s,i,e.key,n),l=Oe(t.config.gradientFill);l&&(a.fillGradient=l),t.config.curve&&"linear"!==t.config.curve&&(a.curve=t.config.curve),t.config.lineGradient&&(a.strokeGradient=t.config.lineGradient),o.push(a)}return Re(t,i,o),o}(s,e);case"mixed":return function(t,e){const i=t.groupData(e),o=[],s=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:s,aggregate:n}=O(t.ribbons);if(n.length>0&&o.push(...S(t,e,n)),s.length>0)for(const e of i)o.push(...M(t,e.data,e.key,s))}const n=t.scales.y.domain()[0],a=t.getY0?e=>{const i=t.getY0(e);return null==i?n:i}:void 0;for(const e of i)if(s.has(e.key)){const i=t.resolveAreaStyle(e.key,e.data[0]),s=r(e.data,t.scales,t.getX,t.getY,n,i,e.key,a),l=Oe(t.config.gradientFill);l&&(s.fillGradient=l),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),o.push(s)}else{const i=t.resolveLineStyle(e.key,e.data[0]),s=c(e.data,t.scales,t.getX,t.getY,i,e.key);t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),o.push(s)}return Re(t,i,o),o}(s,e);case"stackedarea":return function(t,e){const i=t.groupData(e),o=t.config.stackOrder??"key",s=()=>i.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("input"===o);else if("key"===o)s();else if("asc"===o||"desc"===o||"insideOut"===o){const e=new Map;for(const o of i){let i=0;for(const e of o.data){const o=t.getX(e),s=t.getY(e);Number.isFinite(o)&&Number.isFinite(s)&&(i+=s)}e.set(o.key,i)}const s=(t,e)=>e>t?-1:t>e?1:0;if("asc"===o)i.sort((t,i)=>{const o=(e.get(t.key)??0)-(e.get(i.key)??0);return 0!==o?o:s(t.key,i.key)});else if("desc"===o)i.sort((t,i)=>{const o=(e.get(i.key)??0)-(e.get(t.key)??0);return 0!==o?o:s(t.key,i.key)});else{const t=[...i].sort((t,i)=>{const o=(e.get(i.key)??0)-(e.get(t.key)??0);return 0!==o?o:s(t.key,i.key)}),o=[],n=[];let r=0,a=0;for(const i of t)a>r?(o.push(i),r+=e.get(i.key)??0):(n.push(i),a+=e.get(i.key)??0);i.length=0,i.push(...n.reverse(),...o)}}else s();const n=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,r=t.config.normalize?"zero":t.config.baseline??"zero",{nodes:a,stackedTops:l}=g(i,t.scales,t.getX,t.getY,(e,i)=>t.resolveAreaStyle(e,i),t.config.normalize,n,r),c=a;if(t.config.pointStyle){const e=new WeakMap;for(const o of i){const i=l.get(o.key);if(i)for(const s of o.data){const o=t.getX(s),n=t.getY(s);null==o||Number.isNaN(o)||null==n||Number.isNaN(n)||!i.has(o)||e.set(s,i.get(o))}}const o=i=>e.get(i)??t.getY(i);Re(t,i,c,o)}return c}(s,e);case"scatter":case"bubble":return function(t,e){const i=[],o="bubble"===t.config.chartType?10:5,s=t.config.sizeRange||[3,15];let n=null;if(t.getSize&&!t.config.pointStyle){const i=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(i.length>0){let t=1/0,e=-1/0;for(const o of i)t>o&&(t=o),o>e&&(e=o);n=i=>t===e?(s[0]+s[1])/2:s[0]+(i-t)/(e-t)*(s[1]-s[0])}}const r=t.getColor?t.resolveColorMap(e):null,a=t.config.themeSemantic?.primary||"#4e79a7",l=t.getSymbol,c=t.config.symbolMap,u=new Map;let g=0;const f=t=>{const e=c?.[t];if(e)return e;let i=u.get(t);return i||(i=bt[g%bt.length],g++,u.set(t,i)),i};for(const s of e){let e=t.config.pointStyle?t.config.pointStyle(s):{fill:a,opacity:.8},c=e.r||o;if(n&&t.getSize){const e=t.getSize(s);null==e||Number.isNaN(e)||(c=n(e))}if(r&&t.getColor&&!e.fill){const i=t.getColor(s);i&&r.has(i)&&(e={...e,fill:r.get(i)})}const u=t.getPointId?t.getPointId(s)+"":void 0;if(l){const o=f(l(s)+""),n=d(s,t.scales,t.getX,t.getY,Math.PI*c*c,o,e,u);n&&i.push(n)}else{const o=h(s,t.scales,t.getX,t.getY,c,e,u);o&&i.push(o)}}return i}(s,e);case"heatmap":return function(t,e,i){if(t.config.heatmapAggregation)return function(t,e,i){const o=Math.max(1,Math.floor(t.config.heatmapXBins??20)),s=Math.max(1,Math.floor(t.config.heatmapYBins??20)),n=t.config.heatmapAggregation??"count",r=y(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[a,c]=t.scales.x.domain(),[h,u]=t.scales.y.domain(),g=(c-a||1)/o,d=(u-h||1)/s,f=o*s;if(f>1e6)return[];const p=new Int32Array(f),m=new Float64Array(f);for(let i=0;e.length>i;i++){const n=e[i],l=t.getX(n),c=t.getY(n);if(!isFinite(l)||!isFinite(c))continue;const u=Math.min(Math.floor((l-a)/g),o-1),f=Math.min(Math.floor((c-h)/d),s-1);if(0>u||0>f)continue;const y=f*o+u;p[y]++;const x=r(n);m[y]+=isFinite(x)?x:0}let x=1/0,v=-1/0;for(let t=0;f>t;t++){if(0===p[t])continue;let e;switch(n){case"sum":e=m[t];break;case"mean":e=m[t]/p[t];break;default:e=p[t]}x>e&&(x=e),e>v&&(v=e)}if(!isFinite(x))return[];const b=v-x||1,k=i.width/o,w=i.height/s,A=t.config.showValues,_=t.config.heatmapValueFormat,C=[];for(let e=0;s>e;e++){const i=e*o;for(let r=0;o>r;r++){const o=i+r;if(0===p[o])continue;let c;switch(n){case"sum":c=m[o];break;case"mean":c=m[o]/p[o];break;default:c=p[o]}const u=(c-x)/b,f={xi:r,yi:e,value:c,count:p[o],sum:m[o],xCenter:a+(r+.5)*g,yCenter:h+(e+.5)*d,agg:n};C.push(De(l(r*k,(s-1-e)*w,k,w,`rgb(${220-(180*u+.5)|0},${220-(100*u+.5)|0},${255-(50*u+.5)|0})`,f,A?{value:c,showValues:!0,valueFormat:_}:void 0),f,t))}}return C}(t,e,i);if(0===e.length)return[];const o=y(t.config.valueAccessor,"value"),s=v(t.config.xAccessor,"x"),n=v(t.config.yAccessor,"y"),r=new Map,a=new Map,c=Array(e.length),h=Array(e.length);for(let t=0;e.length>t;t++){const i=e[t],o=s(i),l=n(i);c[t]=o,h[t]=l,r.has(o)||r.set(o,r.size),a.has(l)||a.set(l,a.size)}const u=r.size,g=a.size;if(0===u||0===g)return[];const d=Array.from(r.keys()),f=Array.from(a.keys()),p=d.every(t=>"number"==typeof t&&!isNaN(t)),m=f.every(t=>"number"==typeof t&&!isNaN(t));if(p){d.sort((t,e)=>Number(t)-Number(e)),r.clear();for(let t=0;d.length>t;t++)r.set(d[t],t)}if(m){f.sort((t,e)=>Number(t)-Number(e)),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}const x=new Float64Array(e.length),b=new Float64Array(e.length),k=Array(e.length),w=new Map;let A=0;for(let t=0;e.length>t;t++){const i=e[t],s=r.get(c[t]),n=a.get(h[t]);if(void 0===s||void 0===n)continue;const l=o(i),g=n*u+s,d=w.get(g);let f;void 0!==d?f=d:(f=A++,w.set(g,f)),x[f]=g,b[f]=l,k[f]=i}let _=1/0,C=-1/0;for(let t=0;A>t;t++){const e=b[t];isFinite(e)&&(_>e&&(_=e),e>C&&(C=e))}if(!isFinite(_)||!isFinite(C))return[];const S=function(t){const e=t in xt?t:"blues";let i=We.get(e);if(i)return i;i=Array(256);const o=Lt(e);for(let t=0;256>t;t++)i[t]=o(t/255);return We.set(e,i),i}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),M=255/(C-_||1),P=i.width/u,Y=i.height/g,R=t.config.showValues,T=t.config.heatmapValueFormat,N=[];for(let e=0;A>e;e++){const i=b[e];if(!isFinite(i))continue;const o=x[e],s=o%u,n=k[e];N.push(De(l(s*P,(g-1-(o-s)/u)*Y,P,Y,S[Math.min((i-_)*M+.5|0,255)],n,R?{value:i,showValues:!0,valueFormat:T}:void 0),n,t))}return N}(s,e,t);case"bar":{const t=function(t,e){if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const i=Ee(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===i.size)return{nodes:[],binBoundaries:[]};let o=null;if(t.getCategory){const e=new Set;for(const t of i.values())for(const i of t.categories.keys())e.add(i);const s=t.config.barColors?Object.keys(t.config.barColors):[],n=new Set(s),r=Array.from(e).filter(t=>!n.has(t)).sort(),a=s.filter(t=>e.has(t)),l=a.join("\0")+""+r.join("\0");t.barCategoryCache&&t.barCategoryCache.key===l?o=t.barCategoryCache.order:(o=[...a,...r],t.barCategoryCache={key:l,order:o})}const s=[],n=t.scales,[r,a]=n.x.domain(),l=t.config.barStyle,c=t.config.themeSemantic?.primary,h=l?.gap,g="number"!=typeof h||0>h?1:h,d={};l?.stroke&&(d.stroke=l.stroke),"number"==typeof l?.strokeWidth&&(d.strokeWidth=l.strokeWidth),"number"==typeof l?.opacity&&(d.opacity=l.opacity);for(const e of i.values()){const i=Math.max(e.start,r),h=Math.min(e.end,a);if(i>=h)continue;const f=n.x(i),p=n.x(h),y=Math.abs(p-f),m=y>g+1?g:0,x=Math.min(f,p)+m/2,v=Math.max(y-m,1);if(v>0)if(o&&e.categories.size>0){let i=0;for(const r of o){const o=e.categories.get(r)||0;if(0===o)continue;const a=n.y(i),h=n.y(i+o);s.push(u(x,Math.min(a,h),v,Math.abs(a-h),{fill:t.config.barColors?.[r]||l?.fill||c||"#4e79a7",...d},{binStart:e.start,binEnd:e.end,total:e.total,category:r,categoryValue:o},r)),i+=o}}else{const t=n.y(0),i=n.y(e.total);s.push(u(x,Math.min(t,i),v,Math.abs(t-i),{fill:l?.fill||c||"#007bff",...d},{binStart:e.start,binEnd:e.end,total:e.total}))}}const f=new Set;for(const t of i.values())f.add(t.start),f.add(t.end);return{nodes:s,binBoundaries:Array.from(f).sort((t,e)=>t-e)}}(s,e);return this._barCategoryCache=s.barCategoryCache??null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){const i=[],o=t.config.swarmStyle||{},s=o.radius??3,n=o.fill??t.config.themeSemantic?.primary??"#007bff",r=o.opacity??.7,a=o.stroke,l=o.strokeWidth;for(const o of e){const e=t.getX(o),c=t.getY(o);if(null==c||Number.isNaN(c))continue;const h=t.scales.x(e),u=t.scales.y(c);let g=n;if(t.getCategory){const e=t.getCategory(o);g=t.config.barColors?.[e]||g}const{r:d,...f}=t.config.pointStyle?.(o)??{},p={type:"point",x:h,y:u,r:d??s,style:{fill:g,opacity:r,stroke:a,strokeWidth:l,...f},datum:o};t.getPointId&&(p.pointId=t.getPointId(o)+""),i.push(p)}return i}(s,e);case"waterfall":return function(t,e,i){const o=[],s=t.scales,n=t.config.waterfallStyle,r=e.filter(e=>{const i=t.getY(e),o=t.getX(e);return null!=i&&!Number.isNaN(i)&&null!=o&&isFinite(o)});if(0===r.length)return o;const a=n?.positiveColor??t.config.themeSemantic?.success??"#28a745",l=n?.negativeColor??t.config.themeSemantic?.danger??"#dc3545",c=n?.gap??1,h=n?.stroke,g=n?.strokeWidth,d=n?.opacity;let f=0;for(let e=0;r.length>e;e++){const p=r[e],y=t.getX(p),m=t.getY(p),x=f+m;let v;v=r.length-1>e?t.getX(r[e+1])-y:e>0?y-t.getX(r[e-1]):0;const b=s.x(y),k=0!==v?s.x(y+v):b+i.width/10,w=Math.min(b,k)+c/2,A=Math.max(b,k)-c/2-w;if(0>=A){f=x;continue}const _=s.y(f),C=s.y(x),S=Math.min(_,C),M=Math.abs(_-C),P={fill:0>m?l:a,stroke:h,strokeWidth:g};null!=d&&(P.opacity=d),o.push(u(w,S,A,M,P,{...p,baseline:f,cumEnd:x,delta:m,_connectorStroke:n?.connectorStroke,_connectorWidth:n?.connectorWidth})),f=x}return o}(s,e,t);case"candlestick":return function(t,e,i){if(!t.getHigh||!t.getLow||!t.scales)return[];const o=t.config.candlestickRangeMode??!1;if(!(o||t.getOpen&&t.getClose))return[];const s=[],n=t.config.candlestickStyle||{},r=n.rangeColor||"#6366f1",a=o?r:n.upColor||"#28a745",l=o?r:n.downColor||"#dc3545",c=o?r:n.wickColor||"#333",h=n.wickWidth||(o?2:1),u=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let g=n.bodyWidth??0;if(null==n.bodyWidth)if(u.length>1){let e=1/0;for(let i=1;u.length>i;i++){const o=Math.abs(t.scales.x(u[i])-t.scales.x(u[i-1]));o>0&&e>o&&(e=o)}g=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else g=6;for(const n of e){const e=t.getX(n);if(null==e||Number.isNaN(e))continue;const r=t.getHigh(n),u=t.getLow(n);if(null==r||Number.isNaN(r)||null==u||Number.isNaN(u))continue;const d=o?r:t.getOpen(n),f=o?u:t.getClose(n);if(!o&&[d,f].some(t=>null==t||Number.isNaN(t)))continue;const p=f>=d,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(d),closeY:t.scales.y(f),highY:t.scales.y(r),lowY:t.scales.y(u),bodyWidth:g,upColor:a,downColor:l,wickColor:c,wickWidth:h,isUp:p,datum:n};o&&(y.isRange=!0,y.dotRadius=Math.max(2,Math.min(g/2,.12*i.height))),s.push(y)}return s}(s,e,t);default:return[]}}resolveBoundsStyle(t,e){return function(t,e,i,o){const s=t.boundsStyle;return"function"==typeof s?s(i||{},e):s&&"object"==typeof s?s:{fill:o(e,i).stroke||t.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,t,e,(t,e)=>this.resolveLineStyle(t,e))}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?q(i,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const e=H(t);return this._datumIndexCache={version:this._ingestVersion,map:e},e}applyDecay(t,e){this.config.decay&&G(this.config.decay,t,e,this.getDatumIndexMap(e))}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),t)}hasActivePulsesAt(t){return!!this.config.pulse&&N(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,i,o){i.clear(),o.clear();for(let s=0;e.length>s;s++){const n=e[s],r=Ye(t,n,s);r&&("point"===n.type?i.set(r,{x:n.x,y:n.y,r:n.r,opacity:n.style.opacity}):"glyph"===n.type?i.set(r,{x:n.x,y:n.y,r:n.size,opacity:n.style.opacity,glyph:n.glyph}):"rect"===n.type?i.set(r,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style.opacity}):"heatcell"===n.type?i.set(r,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style?.opacity}):"candlestick"===n.type?i.set(r,{x:n.x,y:n.openY,w:n.bodyWidth,openY:n.openY,closeY:n.closeY,highY:n.highY,lowY:n.lowY,opacity:n.style?.opacity}):"line"===n.type?o.set(r,{path:n.path.map(t=>[t[0],t[1]]),opacity:n.style?.opacity}):"area"===n.type&&o.set(r,{topPath:n.topPath.map(t=>[t[0],t[1]]),bottomPath:n.bottomPath.map(t=>[t[0],t[1]]),opacity:n.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const t=this.scales?.y(0)??0;for(let e=0;this.scene.length>e;e++){const i=this.scene[e],o=Ye(this.transitionContext,i,e);o&&("point"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,r:0,opacity:0}):"rect"===i.type?this.prevPositionMap.set(o,{x:i.x,y:t,w:i.w,h:0,opacity:i.style.opacity??1}):"heatcell"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:0}):"line"===i.type?(i._introClipFraction=0,this.prevPathMap.set(o,{path:i.path.map(t=>[t[0],t[1]]),opacity:i.style.opacity})):"area"===i.type&&(i._introClipFraction=0,this.prevPathMap.set(o,{topPath:i.topPath.map(t=>[t[0],t[1]]),bottomPath:i.bottomPath.map(t=>[t[0],t[1]]),opacity:i.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,i,o,s,n=$t()){if(0===o.size&&0===s.size)return i;const r=e.duration??300;if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}let a=!1;const l=new Set,c=new Set;for(let e=0;i.scene.length>e;e++){const n=i.scene[e],r=Ye(t,n,e);if(!r)continue;if(n._transitionKey=r,"line"===n.type||"area"===n.type){const t=s.get(r);if(t){if(c.add(r),"line"===n.type&&t.path&&t.path.length===n.path.length){n._targetPath=n.path.map(t=>[t[0],t[1]]),n._prevPath=t.path;for(let e=0;n.path.length>e;e++)n.path[e]=[t.path[e][0],t.path[e][1]];a=!0}else if("area"===n.type&&t.topPath&&t.bottomPath&&t.topPath.length===n.topPath.length&&t.bottomPath.length===n.bottomPath.length){n._targetTopPath=n.topPath.map(t=>[t[0],t[1]]),n._targetBottomPath=n.bottomPath.map(t=>[t[0],t[1]]),n._prevTopPath=t.topPath,n._prevBottomPath=t.bottomPath;for(let e=0;n.topPath.length>e;e++)n.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;n.bottomPath.length>e;e++)n.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];a=!0}n._targetOpacity=n.style.opacity??1,n._startOpacity=t.opacity??n.style.opacity??1}else n._targetOpacity=n.style.opacity??1,n._startOpacity=0,n.style={...n.style,opacity:0},a=!0;continue}const h=o.get(r);if("point"===n.type)if(h){l.add(r);const t={x:n.x,y:n.y,r:n.r};n._targetOpacity=n.style.opacity??1,h.x===t.x&&h.y===t.y&&h.r===t.r||(n._targetX=t.x,n._targetY=t.y,n._targetR=t.r,n.x=h.x,n.y=h.y,n.r=h.r??n.r,a=!0)}else n._targetOpacity=n.style.opacity??1,n.style={...n.style,opacity:0},a=!0;else if("glyph"===n.type)if(h){l.add(r);const t={x:n.x,y:n.y,size:n.size};n._targetOpacity=n.style.opacity??1,h.x===t.x&&h.y===t.y&&h.r===t.size||(n._targetX=t.x,n._targetY=t.y,n._targetR=t.size,n.x=h.x,n.y=h.y,n.size=h.r??n.size,a=!0)}else n._targetOpacity=n.style.opacity??1,n.style={...n.style,opacity:0},a=!0;else if("rect"===n.type)if(h){l.add(r);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=n.style.opacity??1,h.x===t.x&&h.y===t.y&&h.w===t.w&&h.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=h.x,n.y=h.y,n.w=h.w??n.w,n.h=h.h??n.h,a=!0)}else n._targetOpacity=n.style.opacity??1,n.style={...n.style,opacity:0},a=!0;else if("heatcell"===n.type)if(h){l.add(r);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=n.style?.opacity??1,h.x===t.x&&h.y===t.y&&h.w===t.w&&h.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=h.x,n.y=h.y,n.w=h.w??n.w,n.h=h.h??n.h,a=!0)}else n._targetOpacity=n.style?.opacity??1,n.style={...n.style||{},opacity:0},a=!0;else if("candlestick"===n.type)if(h&&null!=h.openY){l.add(r);const t={x:n.x,openY:n.openY,closeY:n.closeY,highY:n.highY,lowY:n.lowY};n._targetOpacity=n.style?.opacity??1,(h.x!==t.x||h.openY!==t.openY||h.closeY!==t.closeY||h.highY!==t.highY||h.lowY!==t.lowY)&&(n._targetX=t.x,n._targetOpenY=t.openY,n._targetCloseY=t.closeY,n._targetHighY=t.highY,n._targetLowY=t.lowY,n.x=h.x,n.openY=h.openY,n.closeY=h.closeY??n.closeY,n.highY=h.highY??n.highY,n.lowY=h.lowY??n.lowY,a=!0)}else n._targetOpacity=n.style?.opacity??1,n.style={...n.style||{},opacity:0},a=!0}for(const[t,e]of s)if(!c.has(t))if(t.startsWith("l:")&&e.path){const o={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),a=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const o={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),a=!0}for(const[t,e]of o)if(!l.has(t)){if(t.startsWith("p:"))i.exitNodes.push({type:"point",x:e.x,y:e.y,r:e.r??3,style:{opacity:e.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("g:")&&e.glyph)i.exitNodes.push({type:"glyph",x:e.x,y:e.y,size:e.r??12,glyph:e.glyph,color:"#999",accent:"#999",style:{opacity:e.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))i.exitNodes.push({type:"rect",x:e.x,y:e.y,w:e.w??0,h:e.h??0,style:{opacity:e.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("h:"))i.exitNodes.push({type:"heatcell",x:e.x,y:e.y,w:e.w??0,h:e.h??0,fill:"#999",datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t});else if(t.startsWith("c:")){const o=e.openY??e.y;i.exitNodes.push({type:"candlestick",x:e.x,openY:o,closeY:e.closeY??o,highY:e.highY??o,lowY:e.lowY??o,bodyWidth:e.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t})}a=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),a&&(i.activeTransition={startTime:n,duration:r}),i}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},i=function(t,e,i,o){if(!i.activeTransition)return!1;const s=Nt(t,i.activeTransition),n=Tt(s,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of i.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style.opacity=Xt(i?i.opacity??1:0,t._targetOpacity,n)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Xt(i.x,t._targetX,n),t.y=Xt(i.y,t._targetY,n),void 0!==t._targetR&&void 0!==i.r&&(t.r=Xt(i.r,t._targetR,n))}else if("glyph"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style.opacity=Xt(i?i.opacity??1:0,t._targetOpacity,n)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Xt(i.x,t._targetX,n),t.y=Xt(i.y,t._targetY,n),void 0!==t._targetR&&void 0!==i.r&&(t.size=Xt(i.r,t._targetR,n))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style.opacity=Xt(i?i.opacity??1:0,t._targetOpacity,n)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Xt(i.x,t._targetX,n),t.y=Xt(i.y,t._targetY,n),void 0!==i.w&&(t.w=Xt(i.w,t._targetW,n)),void 0!==i.h&&(t.h=Xt(i.h,t._targetH,n))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style={...t.style||{},opacity:Xt(i?i.opacity??1:0,t._targetOpacity,n)}}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Xt(i.x,t._targetX,n),t.y=Xt(i.y,t._targetY,n),void 0!==i.w&&(t.w=Xt(i.w,t._targetW,n)),void 0!==i.h&&(t.h=Xt(i.h,t._targetH,n))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style={...t.style||{},opacity:Xt(i?i.opacity??1:0,t._targetOpacity,n)}}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Xt(i.x,t._targetX,n),void 0!==i.openY&&(t.openY=Xt(i.openY,t._targetOpenY,n)),void 0!==i.closeY&&(t.closeY=Xt(i.closeY,t._targetCloseY,n)),void 0!==i.highY&&(t.highY=Xt(i.highY,t._targetHighY,n)),void 0!==i.lowY&&(t.lowY=Xt(i.lowY,t._targetLowY,n))}else if("line"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:Xt(t._startOpacity??0,t._targetOpacity,n)}),void 0!==t._introClipFraction&&(t._introClipFraction=n);const e=t._prevPath,i=t._targetPath;if(e&&i&&e.length===t.path.length)for(let o=0;t.path.length>o;o++)t.path[o][0]=Xt(e[o][0],i[o][0],n),t.path[o][1]=Xt(e[o][1],i[o][1],n)}else if("area"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:Xt(t._startOpacity??0,t._targetOpacity,n)}),void 0!==t._introClipFraction&&(t._introClipFraction=n);const e=t._prevTopPath,i=t._prevBottomPath,o=t._targetTopPath,s=t._targetBottomPath;if(e&&o&&e.length===t.topPath.length)for(let i=0;t.topPath.length>i;i++)t.topPath[i][0]=Xt(e[i][0],o[i][0],n),t.topPath[i][1]=Xt(e[i][1],o[i][1],n);if(i&&s&&i.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=Xt(i[e][0],s[e][0],n),t.bottomPath[e][1]=Xt(i[e][1],s[e][1],n)}}if(s>=1){for(const t of i.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style="line"===t.type||"area"===t.type?{...t.style,opacity:0===e?0:e}:{...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("glyph"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.size=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let i=0;t.path.length>i;i++)t.path[i]=e[i];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,i=t._targetBottomPath;if(e)for(let i=0;t.topPath.length>i;i++)t.topPath[i]=e[i];if(i)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=i[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}return i.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,i}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const t of this.scene)"line"!==t.type&&"area"!==t.type||(t._introClipFraction=void 0)}groupData(t){const{result:e,cache:i}=function(t,e,i,o){if(o&&o.version===i&&o.group===e&&o.data===t)return{result:o.result,cache:o};let s;if(e){const i=new Map;for(const o of t){const t=e(o);i.has(t)||i.set(t,[]),i.get(t).push(o)}s=Array.from(i.entries()).map(([t,e])=>({key:t,data:e}))}else s=[{key:"_default",data:t}];return{result:s,cache:{version:i,group:e,data:t,result:s}}}(t,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=i,e}resolveColorMap(t){const{map:e,cache:i}=function(t,e,i,o,s){if(s&&s.version===o)return{map:s.map,cache:s};const n=new Set;if(e)for(const i of t){const t=e(i);t&&n.add(t)}const r=Array.from(n).sort(),a=r.join("\0");if(s&&s.key===a){const t={...s,version:o};return{map:t.map,cache:t}}const l=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical||vt,c=new Map;for(let t=0;r.length>t;t++)c.set(r[t],l[t%l.length]);return{map:c,cache:{key:a,map:c,version:o}}}(t,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=i,e}resolveLineStyle(t,e){return function(t,e,i,o){const s=t.lineStyle;if("function"==typeof s){const t=s(i||{},e);if(t&&!t.stroke&&e){const i=o(e);if(i)return{...t,stroke:i}}return t}const n=t.themeSemantic?.primary;return s&&"object"==typeof s?{stroke:s.stroke||n||"#007bff",strokeWidth:s.strokeWidth||2,strokeDasharray:s.strokeDasharray,fill:s.fill,fillOpacity:s.fillOpacity,opacity:s.opacity}:{stroke:o(e)||n||"#007bff",strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveAreaStyle(t,e){return function(t,e,i,o){if(t.areaStyle){const s=t.areaStyle(i||{});if(s&&!s.fill&&e){const t=o(e);if(t)return{...s,fill:t,stroke:s.stroke||t}}return s}const s=t.lineStyle;if("function"==typeof s){const t=s(i||{},e);if(t&&!t.fill&&e){const i=o(e);if(i)return{...t,fill:i,stroke:t.stroke||i}}return t}const n=t.themeSemantic?.primary;if(s&&"object"==typeof s)return{fill:s.fill||s.stroke||n||"#4e79a7",fillOpacity:s.fillOpacity??.7,stroke:s.stroke||n||"#4e79a7",strokeWidth:s.strokeWidth||2};const r=o(e)||n||"#4e79a7";return{fill:r,fillOpacity:.7,stroke:r,strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveGroupColor(e){const{color:i,groupColorCounter:o}=function(t){const{group:e,colorMapCache:i,groupColorMap:o,groupColorMapCap:s,config:n}=t;let{groupColorCounter:r}=t;if(i){const t=i.map.get(e);if(t)return{color:t,groupColorCounter:r}}const a=o.get(e);if(a)return{color:a,groupColorCounter:r};const l=(Array.isArray(n.colorScheme)&&n.colorScheme.length>0?n.colorScheme:null)||(Array.isArray(n.themeCategorical)&&n.themeCategorical.length>0?n.themeCategorical:null)||vt;if(0===l.length)return{color:null,groupColorCounter:r};const c=l[r%l.length];if(r++,o.set(e,c),o.size>s){const t=o.keys().next().value;void 0!==t&&o.delete(t)}return{color:c,groupColorCounter:r}}({group:e,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:t.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=o,i}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=A(t),i=this.getPointId,o=t=>e.has(i(t));P(this.buffer,this.timestampBuffer,o);const s=this.buffer.remove(o);if(0===s.length)return this.updateResults.recordNoop("remove"),s;for(const t of s)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",s.length),s}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const i=A(t),o=this.getPointId,s=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&s.add(e)});const n=this.buffer.update(t=>i.has(o(t)),e);if(0===n.length)return this.updateResults.recordNoop("update"),n;for(const t of n)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.buffer.forEach((t,e)=>{s.has(e)&&(this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",n.length),n}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(t,e){const i=this._customRestyle;if(i)for(const o of t){const t=this._baseStyles.get(o)??o.style??{},s=i(o,e);o.style=s?{...t,...s}:t}}restyleScene(t){this._customRestyle?(this.applyCustomRestyle(this.scene,t),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(t){const e={...this.config},i=Object.keys(t).filter(i=>t[i]!==e[i]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in t&&t.windowSize!==e.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${e.windowSize} → ${t.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"boundsAccessor"in t||"band"in t||"y0Accessor"in t||"openAccessor"in t||"highAccessor"in t||"lowAccessor"in t||"closeAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let o=!1,n=!1;Object.assign(this.config,t),"pulse"in t&&this.syncPulseTimestampBuffer();const r="chartType"in t&&t.chartType!==e.chartType||"runtimeMode"in t&&t.runtimeMode!==e.runtimeMode;if(r||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const t=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,i=t&&this.config.valueAccessor||this.config.yAccessor,a=t&&e.valueAccessor||e.yAccessor,l=r||!s(t&&this.config.timeAccessor||this.config.xAccessor,t&&e.timeAccessor||e.xAccessor),c=r||!s(i,a);(l||c)&&(t?(this.getX=y(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=y(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=y(this.config.xAccessor,"x"),this.getY=y(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=Fe(this.config)),o=!0,n=!0)}if("groupAccessor"in t&&!s(t.groupAccessor,e.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?b(this.config.groupAccessor):void 0,o=!0),"categoryAccessor"in t&&!s(t.categoryAccessor,e.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?b(this.config.categoryAccessor):void 0,o=!0),"sizeAccessor"in t&&!s(t.sizeAccessor,e.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?y(this.config.sizeAccessor,"size"):void 0,o=!0),"symbolAccessor"in t&&!s(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?b(this.config.symbolAccessor):void 0,o=!0),"colorAccessor"in t&&!s(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?b(this.config.colorAccessor):void 0,o=!0),"y0Accessor"in t&&!s(t.y0Accessor,e.y0Accessor)&&(this.getY0=this.config.y0Accessor?y(this.config.y0Accessor,"y0"):void 0,o=!0,n=!0),("boundsAccessor"in t&&!s(t.boundsAccessor,e.boundsAccessor)||"band"in t&&t.band!==e.band||"boundsStyle"in t&&t.boundsStyle!==e.boundsStyle)&&(this.resolvedRibbons=Fe(this.config),o=!0,n=!0),"pointIdAccessor"in t&&!s(t.pointIdAccessor,e.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?b(this.config.pointIdAccessor):void 0,o=!0),"candlestick"===this.config.chartType&&(r||"openAccessor"in t&&!s(t.openAccessor,e.openAccessor)||"closeAccessor"in t&&!s(t.closeAccessor,e.closeAccessor)||"highAccessor"in t&&!s(t.highAccessor,e.highAccessor)||"lowAccessor"in t&&!s(t.lowAccessor,e.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?y(this.config.openAccessor,"open"):void 0,this.getHigh=y(this.config.highAccessor,"high"),this.getLow=y(this.config.lowAccessor,"low"),this.getClose=e?y(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,o=!0,n=!0}if("accessorRevision"in t&&t.accessorRevision!==e.accessorRevision&&(o=!0,n=!0),!o){const i=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const s of i)if(t[s]!==e[s]){o=!0;break}}o&&(n&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(i)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};ri.GROUP_COLOR_MAP_CAP=1e3;var ai=ri;V(ai);import{line as li}from"d3-shape";var ci=new WeakMap;function hi(t,e){const i=Kt(e);if(!i)return t;const o=ci.get(t);if(o)return o;const s=function(t,e,i=8){if(!e||2>t.length)return t.map(([t,e])=>[t,e]);const o=[];let s=null;const n={moveTo(t,e){s=[t,e],o.push([t,e])},lineTo(t,e){s=[t,e],o.push([t,e])},bezierCurveTo(t,e,n,r,a,l){if(!s)return s=[a,l],void o.push([a,l]);const[c,h]=s;for(let s=1;i>=s;s++){const u=s/i,g=1-u;o.push([g*g*g*c+3*g*g*u*t+3*g*u*u*n+u*u*u*a,g*g*g*h+3*g*g*u*e+3*g*u*u*r+u*u*u*l])}s=[a,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(t,e,i,n){s=[i,n],o.push([i,n])}};return li().x(t=>t[0]).y(t=>t[1]).curve(e).context(n)(t),o}(t,i);return ci.set(t,s),s}function ui(t,e,i,o=30,s,n=0){let r=null;if(s){const t=J(s,e,i,o,n);t&&(r={node:t.node,datum:t.node.datum,x:t.node.x,y:t.node.y,distance:t.distance})}for(const n of t){let t=null;switch(n.type){case"point":if(s)break;t=di(n,e,i,o);break;case"symbol":t=fi(n,e,i,o);break;case"glyph":t=pi(n,e,i,o);break;case"line":t=yi(n,e,i,o);break;case"rect":if(null==n.datum)break;t=xi(n,e,i);break;case"heatcell":t=vi(n,e,i);break;case"area":if(!1===n.interactive)break;t=ki(n,e,i);break;case"candlestick":t=bi(n,e,i)}t&&o>t.distance&&(r&&t.distance>=r.distance||(r=t))}return r}function gi(t,e,i){if(0===t.length)return null;if(t[0][0]>e||e>t[t.length-1][0])return null;const o=wi(t,e);if(0>o)return null;if(Math.abs(t[o][0]-e)>i)return null;let s=o,n=o;o>0&&t[o][0]>=e?(s=o-1,n=o):t.length-1>o&&(s=o,n=o+1);const[r,a]=t[s],[l,c]=t[n];return l===r?a:a+Math.max(0,Math.min(1,(e-r)/(l-r)))*(c-a)}function di(t,e,i,o=30){const s=e-t.x,n=i-t.y,r=Math.sqrt(s*s+n*n);return r>Q(t.r,o)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:r}}function fi(t,e,i,o=30){const s=e-t.x,n=i-t.y,r=Math.sqrt(s*s+n*n);return r>Q(Qt(t.size),o)?null:{node:t,datum:t.datum,x:t.x,y:t.y,distance:r}}function pi(t,e,i,o=30){if(null==t.datum)return null;const s=le(t.glyph,t.size),n=t.x+s.centerDx,r=t.y+s.centerDy,a=e-n,l=i-r,c=Math.sqrt(a*a+l*l);return c>Q(s.radius,o)?null:{node:t,datum:t.datum,x:n,y:r,distance:c}}function yi(t,e,i,o=30){if(0===t.path.length)return null;const s=wi(t.path,e);if(0>s)return null;const[n,r]=t.path[s];let a;if(t.path.length>1){let o=1/0;const n=Math.max(0,s-1),r=Math.min(t.path.length-2,s);for(let s=n;r>=s;s++){const[n,r]=t.path[s],[a,l]=t.path[s+1],c=mi(e,i,n,r,a,l);o>c&&(o=c)}a=o}else{const t=e-n,o=i-r;a=Math.sqrt(t*t+o*o)}const l=t.style;return a>Math.max(5,(l.strokeWidth??l.lineWidth??1)/2+2,o)?null:{node:t,datum:Array.isArray(t.datum)&&t.datum[s]?t.datum[s]:t.datum,x:n,y:r,distance:a}}function mi(t,e,i,o,s,n){const r=s-i,a=n-o,l=r*r+a*a;if(0===l)return Math.sqrt((t-i)**2+(e-o)**2);let c=((t-i)*r+(e-o)*a)/l;return c=Math.max(0,Math.min(1,c)),Math.sqrt((t-(i+c*r))**2+(e-(o+c*a))**2)}function xi(t,e,i){const o=tt(e,i,t);return o.hit?{node:t,datum:t.datum,x:o.cx,y:o.cy,distance:0}:null}function vi(t,e,i){const o=tt(e,i,t);return o.hit?{node:t,datum:t.datum,x:o.cx,y:o.cy,distance:0}:null}function bi(t,e,i){const o=t.bodyWidth/2,s=Math.min(t.openY,t.closeY);if(!(t.x-o-3>e||e>t.x+o+3||t.highY-3>i||i>t.lowY+3)){const o=s+Math.max(Math.max(t.openY,t.closeY)-s,1)/2,n=e-t.x,r=i-o;return{node:t,datum:t.datum,x:t.x,y:o,distance:Math.sqrt(n*n+r*r)}}return null}function ki(t,e,i){if(0===t.topPath.length)return null;const o=wi(t.topPath,e);if(0>o)return null;const[s,n]=t.topPath[o],r=e-s,a=i-n,l=Math.sqrt(r*r+a*a);return{node:t,datum:Array.isArray(t.datum)&&t.datum[o]?t.datum[o]:t.datum,x:s,y:n,distance:l}}function wi(t,e){if(0===t.length)return-1;let i=0,o=t.length-1;for(;o>i;){const s=i+o>>1;e>t[s][0]?i=s+1:o=s}return i>0&&Math.abs(t[i][0]-e)>=Math.abs(t[i-1][0]-e)?i-1:i}import{useMemo as Ai,useRef as _i,useEffect as Ci}from"react";import{useMemo as Si}from"react";import{bin as Mi}from"d3-array";import{jsx as Pi,jsxs as Yi}from"react/jsx-runtime";function Ri(t){return"string"==typeof t?{type:t}:t}function Ti({orient:t,config:e,values:i,scale:o,size:s,length:n}){const r=function(t){return{type:t.type,bins:t.bins??20,fill:t.fill??"#4e79a7",fillOpacity:t.fillOpacity??.5,stroke:t.stroke??"none",strokeWidth:t.strokeWidth??1}}(e),a="top"===t||"bottom"===t,l=Si(()=>{if(0===i.length)return null;const e=o.domain(),l=s-8;if("boxplot"===r.type){const e=function(t){const e=[...t].sort((t,e)=>t-e),i=e.length;if(0===i)return null;const o=e[Math.floor(.25*i)],s=e[Math.floor(.5*i)],n=e[Math.floor(.75*i)],r=n-o;return{q1:o,median:s,q3:n,whiskerLow:Math.max(e[0],o-1.5*r),whiskerHigh:Math.min(e[i-1],n+1.5*r)}}(i);if(!e)return null;const{q1:s,median:n,q3:c,whiskerLow:h,whiskerHigh:u}=e,g=Math.min(.5*l,20),d=(l-g)/2+4;if(a){const e=o(s),i=o(c),a=o(n),l=o(h),f=o(u),p="top"===t?-1:1,y=0;return Yi("g",{"data-testid":"marginal-boxplot-"+t,children:[Pi("line",{x1:l,y1:y+p*(d+g/2),x2:f,y2:y+p*(d+g/2),stroke:r.fill,strokeWidth:r.strokeWidth}),Pi("line",{x1:l,y1:y+p*d,x2:l,y2:y+p*(d+g),stroke:r.fill,strokeWidth:r.strokeWidth}),Pi("line",{x1:f,y1:y+p*d,x2:f,y2:y+p*(d+g),stroke:r.fill,strokeWidth:r.strokeWidth}),Pi("rect",{x:Math.min(e,i),y:"top"===t?y-d-g:y+d,width:Math.abs(i-e),height:g,fill:r.fill,fillOpacity:r.fillOpacity,stroke:"none"===r.stroke?r.fill:r.stroke,strokeWidth:r.strokeWidth}),Pi("line",{x1:a,y1:"top"===t?y-d-g:y+d,x2:a,y2:"top"===t?y-d:y+d+g,stroke:r.fill,strokeWidth:2})]})}{const e=o(s),i=o(c),a=o(n),l=o(h),f=o(u),p="left"===t?-1:1,y=0;return Yi("g",{"data-testid":"marginal-boxplot-"+t,children:[Pi("line",{x1:y+p*(d+g/2),y1:l,x2:y+p*(d+g/2),y2:f,stroke:r.fill,strokeWidth:r.strokeWidth}),Pi("line",{x1:y+p*d,y1:l,x2:y+p*(d+g),y2:l,stroke:r.fill,strokeWidth:r.strokeWidth}),Pi("line",{x1:y+p*d,y1:f,x2:y+p*(d+g),y2:f,stroke:r.fill,strokeWidth:r.strokeWidth}),Pi("rect",{x:"left"===t?y-d-g:y+d,y:Math.min(e,i),width:g,height:Math.abs(i-e),fill:r.fill,fillOpacity:r.fillOpacity,stroke:"none"===r.stroke?r.fill:r.stroke,strokeWidth:r.strokeWidth}),Pi("line",{x1:"left"===t?y-d-g:y+d,y1:a,x2:"left"===t?y-d:y+d+g,y2:a,stroke:r.fill,strokeWidth:2})]})}}const c=Mi().domain(e).thresholds(r.bins)(i);if(0===c.length)return null;const h=re(c.map(t=>t.length));if(0===h)return null;if("histogram"===r.type)return Pi("g",{"data-testid":"marginal-histogram-"+t,children:c.map((e,i)=>{if(null==e.x0||null==e.x1)return null;const s=e.length/h*l;if(a){const n=o(e.x0),a=o(e.x1)-o(e.x0);return Pi("rect",{x:n,y:"top"===t?-4-s:4,width:Math.max(a,.5),height:s,fill:r.fill,fillOpacity:r.fillOpacity,stroke:r.stroke,strokeWidth:r.strokeWidth},i)}{const n=o(e.x0),a=o(e.x1)-o(e.x0);return Pi("rect",{x:"left"===t?-4-s:4,y:Math.min(n,n+a),width:s,height:Math.abs(a),fill:r.fill,fillOpacity:r.fillOpacity,stroke:r.stroke,strokeWidth:r.strokeWidth},i)}})});if("violin"===r.type){const e=l/2+4,i=[];for(const s of c){if(null==s.x0||null==s.x1)continue;const n=s.length/h*(l/2),r=o((s.x0+s.x1)/2);i.push(a?`${r},${"top"===t?-(e-n):e-n}`:`${"left"===t?-(e-n):e-n},${r}`)}for(let s=c.length-1;s>=0;s--){const n=c[s];if(null==n.x0||null==n.x1)continue;const r=n.length/h*(l/2),u=o((n.x0+n.x1)/2);i.push(a?`${u},${"top"===t?-(e+r):e+r}`:`${"left"===t?-(e+r):e+r},${u}`)}return Pi("g",{"data-testid":"marginal-violin-"+t,children:Pi("polygon",{points:i.join(" "),fill:r.fill,fillOpacity:r.fillOpacity,stroke:"none"===r.stroke?r.fill:r.stroke,strokeWidth:r.strokeWidth})})}if("ridgeline"===r.type){const e=[];if(a){const i=0,s=null!=c[0].x0?o(c[0].x0):0;e.push(`M${s},${i}`);for(const i of c){if(null==i.x0||null==i.x1)continue;const s=i.length/h*l,n=o((i.x0+i.x1)/2);e.push(`L${n},${"top"===t?-s-4:s+4}`)}const r=null!=c[c.length-1].x1?o(c[c.length-1].x1):n;e.push(`L${r},${i}`),e.push("Z")}else{const i=0,s=null!=c[0].x0?o(c[0].x0):0;e.push(`M${i},${s}`);for(const i of c){if(null==i.x0||null==i.x1)continue;const s=i.length/h*l,n=o((i.x0+i.x1)/2);e.push(`L${"left"===t?-s-4:s+4},${n}`)}const r=null!=c[c.length-1].x1?o(c[c.length-1].x1):n;e.push(`L${i},${r}`),e.push("Z")}return Pi("g",{"data-testid":"marginal-ridgeline-"+t,children:Pi("path",{d:e.join(" "),fill:r.fill,fillOpacity:r.fillOpacity,stroke:"none"===r.stroke?r.fill:r.stroke,strokeWidth:r.strokeWidth})})}return null},[i,o,r,s,n,t,a,4]);return l?Pi("g",{className:"marginal-"+t,"data-testid":"marginal-"+t,children:l}):null}function Ni(t,e,i){if("edges"===t){if(e)return"start";if(i)return"end"}return"middle"}function Oi(t,e,i){if("edges"===t){if(e)return"hanging";if(i)return"auto"}return"middle"}function Wi(t){if(0===t.length)return{min:null,max:null};let e=1/0,i=-1/0;for(const o of t)e>o.pixel&&(e=o.pixel),o.pixel>i&&(i=o.pixel);return{min:e,max:i}}function Di(t){if(t)return"dashed"===t?"6,4":"dotted"===t?"2,4":t}function Ei(t,e,i){if("left"===t||"right"===t){const o="left"===t?i:0,s="left"===t?-1:1,n=Math.ceil(e/8);let r="M0,"+o;for(let t=0;n>t;t++){const i=8*(t+1);r+=`L${Math.min(8*t+4,e)},${o+4*s}`,r+=`L${Math.min(i,e)},${o}`}return r}const o="bottom"===t?0:e,s="bottom"===t?1:-1,n=Math.ceil(i/8);let r=`M${o},0`;for(let t=0;n>t;t++){const e=8*(t+1);r+=`L${o+4*s},${Math.min(8*t+4,i)}`,r+=`L${o},${Math.min(e,i)}`}return r}import{Fragment as zi,jsx as Fi,jsxs as Li}from"react/jsx-runtime";function Bi(t){const{width:e,height:i,totalWidth:o,totalHeight:s,margin:n,scales:r,showAxes:a,axes:l,showGrid:c,xFormat:h,yFormat:u,axisExtent:g}=t,d=Ai(()=>{if(!r)return[];const t=l?.find(t=>"bottom"===t.orient),i=t?.tickFormat||h||Ii,o=Math.max(2,Math.floor(e/70)),s=t?.ticks??5,n="exact"===g?Math.max(2,s):Math.min(s,o),a=t?.tickValues??w(r.x,n,g),c=a.map(t=>t.valueOf()),u=a.map((t,e)=>({value:t,pixel:r.x(t),label:i(t,e,c)})),d=u.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0);return Xi(u,Math.max(55,d+8))},[r,l,h,e,g]),f=Ai(()=>{if(!r)return[];const t=l?.find(t=>"left"===t.orient),e=t?.tickFormat||u||Ii,o=Math.max(2,Math.floor(i/30)),s=t?.ticks??5,n="exact"===g?Math.max(2,s):Math.min(s,o);return Xi((t?.tickValues??w(r.y,n,g)).map(t=>({value:t,pixel:r.y(t),label:e(t)})),22)},[r,l,u,i,g]),p=c&&r,y=a&&r;if(!p&&!y)return null;const m=l?.find(t=>"bottom"===t.orient),x=l?.find(t=>"left"===t.orient),v=y&&(!m||!1!==m.baseline),b=y&&(!x||!1!==x.baseline),k=m?.jaggedBase||!1,A=x?.jaggedBase||!1,_="var(--semiotic-border, #ccc)";return Fi("svg",{width:o,height:s,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:Li("g",{transform:`translate(${n.left},${n.top})`,children:[p&&(()=>{const t=Di(l?.find(t=>"bottom"===t.orient)?.gridStyle),o=Di(l?.find(t=>"left"===t.orient)?.gridStyle);return Li("g",{className:"stream-grid",children:[d.map((e,o)=>Fi("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:t},"xgrid-"+o)),f.map((t,i)=>Fi("line",{x1:0,y1:t.pixel,x2:e,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"ygrid-"+i))]})})(),v&&!k&&Fi("line",{x1:0,y1:i,x2:e,y2:i,stroke:_,strokeWidth:1}),k&&Fi("path",{d:Ei("bottom",e,i),fill:"none",stroke:_,strokeWidth:1}),b&&!A&&Fi("line",{x1:0,y1:0,x2:0,y2:i,stroke:_,strokeWidth:1}),A&&Fi("path",{d:Ei("left",e,i),fill:"none",stroke:_,strokeWidth:1})]})})}function Ii(t,e,i){return t instanceof Date?`${t.toLocaleString("en",{month:"short"})} ${t.getDate()}`:"number"==typeof t?Math.round(100*t)/100+"":t+""}function Xi(t,e){if(2>=t.length)return t;const i=[t[0]];for(let o=1;t.length-1>o;o++)e>Math.abs(t[o].pixel-i[i.length-1].pixel)||i.push(t[o]);const o=t[t.length-1];return e>Math.abs(o.pixel-i[i.length-1].pixel)?i[i.length-1]=o:i.push(o),i}function $i(t){const{width:e,height:i,totalWidth:o,totalHeight:s,margin:n,scales:r,showAxes:a,axes:l,xLabel:c,yLabel:h,yLabelRight:u,xFormat:g,yFormat:d,axisExtent:f,showGrid:p,title:y,legend:m,legendHoverBehavior:x,legendClickBehavior:v,legendHighlightedCategory:b,legendIsolatedCategories:k,legendPosition:A="right",legendLayout:_,foregroundGraphics:C,marginalGraphics:S,xValues:M,yValues:P,annotations:Y,onAnnotationActivate:R,onObservation:T,chartId:N,chartType:O,autoPlaceAnnotations:W,svgAnnotationRules:D,xAccessor:E,yAccessor:z,annotationData:F,pointNodes:L,curve:B,underlayRendered:I,canvasObscuresUnderlay:X=!0,linkedCrosshairName:$,linkedCrosshairSourceId:G,children:V}=t,H=te({onAnnotationActivate:R,onObservation:T,chartId:N,chartType:O}),j=Ai(()=>{if(!a||!r)return[];const t=l?.find(t=>"bottom"===t.orient),i=t?.tickFormat||g||Ii,o=Math.max(2,Math.floor(e/70)),s=t?.ticks??5,n="exact"===f?Math.max(2,s):Math.min(s,o),c=t?.tickValues??w(r.x,n,f),h=c.map(t=>t.valueOf()),u=c.map((t,e)=>({value:t,pixel:r.x(t),label:i(t,e,h)})),d=u.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:"number"==typeof e.label?6.5*(e.label+"").length:60),0),p=t?.autoRotate?Math.max(20,Math.min(d+8,55)):Math.max(55,d+8);let y=Xi(u,p);if(y.length>1&&(y=y.filter((t,e)=>0===e||t.label+""!=y[e-1].label+"")),t?.includeMax&&y.length>0&&"exact"!==f&&!t?.tickValues){const t=r.x.domain()[1],e=r.x(t),o=y[y.length-1].pixel;if(Math.abs(e-o)>1){const s=i(t,y.length,h);p>e-o&&y.length>1&&(y=y.slice(0,-1)),y.push({value:t,pixel:e,label:s})}}return y},[a,r,l,g,e,f]),q=Ai(()=>{if(!a||!r)return[];const t=l?.find(t=>"left"===t.orient),e=t?.tickFormat||d||Ii,o=Math.max(2,Math.floor(i/30)),s=t?.ticks??5,n="exact"===f?Math.max(2,s):Math.min(s,o);let c=Xi((t?.tickValues??w(r.y,n,f)).map(t=>({value:t,pixel:r.y(t),label:e(t)})),22);if(c.length>1&&(c=c.filter((t,e)=>0===e||t.label+""!=c[e-1].label+"")),t?.includeMax&&c.length>0&&"exact"!==f&&!t?.tickValues){const t=r.y.domain()[1],i=r.y(t),o=c[c.length-1].pixel;if(Math.abs(i-o)>1){const s=e(t);22>Math.abs(i-o)&&c.length>1&&(c=c.slice(0,-1)),c.push({value:t,pixel:i,label:s})}}return c},[a,r,l,d,i,f]),U=Ai(()=>{if(!a||!r)return[];const t=l?.find(t=>"right"===t.orient);if(!t)return[];const e=t.tickFormat||d||Ii,o=Math.max(2,Math.floor(i/30)),s=t.ticks??5;return Xi((t.tickValues??w(r.y,"exact"===f?Math.max(2,s):Math.min(s,o),f)).map(t=>({value:t,pixel:r.y(t),label:e(t)})),22)},[a,r,l,d,i,f]),J=_i(new Map),Q=_i(Y?.length??0),Z=Y?.length??0;Q.current!==Z&&(Q.current=Z,J.current=new Map);const tt=Ai(()=>{if(!Y||0===Y.length)return null;const t=K(Y),o=Ot("xy",H),s={scales:r?{x:r.x,y:r.y,time:r.x,value:r.y}:null,timeAxis:"x",xAccessor:E,yAccessor:z,width:e,height:i,data:F,frameType:"xy",pointNodes:L,curve:B,stickyPositionCache:J.current},n=W?St({annotations:t,context:s,..."object"==typeof W?W:{}}):t;return Ht(n,o,D,s)},[Y,W,D,e,i,E,z,F,r,L,B,H]),it=ee($);return Ci(()=>{if(!it?.locked||!$)return;const t=t=>{"Escape"===t.key&&Zt($)};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[it?.locked,$]),a||y||m||C||S||tt&&tt.length>0||p||V||it?Li("svg",{role:"img",width:o,height:s,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[Fi("title",{children:"string"==typeof y?y:"XY Chart"}),Fi("desc",{children:"string"==typeof y?y+" (XY data visualization)":"XY data visualization"}),Li("g",{transform:`translate(${n.left},${n.top})`,children:[p&&r&&(!I||X)&&(()=>{const t=Di(l?.find(t=>"bottom"===t.orient)?.gridStyle),o=Di(l?.find(t=>"left"===t.orient)?.gridStyle);return Li("g",{className:"stream-grid",children:[j.map((e,o)=>Fi("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:t},"xgrid-"+o)),q.map((t,i)=>Fi("line",{x1:0,y1:t.pixel,x2:e,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"ygrid-"+i))]})})(),a&&r&&(()=>{const t=l?.find(t=>"left"===t.orient),o=l?.find(t=>"bottom"===t.orient),s=!t||!1!==t.baseline,r=!o||!1!==o.baseline,a=t?.jaggedBase||!1,g=o?.jaggedBase||!1,d=o?.landmarkTicks,f=t?.landmarkTicks,p="var(--semiotic-border, #ccc)",y="var(--semiotic-text-secondary, var(--semiotic-text, #666))",m="var(--semiotic-text, #333)",x=!!o?.autoRotate&&j.length>1&&(()=>{const t=e/Math.max(j.length-1,1);return j.reduce((t,e)=>Math.max(t,"string"==typeof e.label?6.5*e.label.length:60),0)+8>t})(),v=x?12:18,b=i+(x?58:40),k={fontSize:"var(--semiotic-tick-font-size, 12px)"},w={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},A={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},_=o?.tickAnchor,C=t?.tickAnchor,S=Wi(j),M=Wi(q);return Li("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[Li("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!I||X)&&r&&!g&&Fi("line",{x1:0,y1:i,x2:e,y2:i,stroke:p,strokeWidth:1}),(!I||X)&&g&&Fi("path",{d:Ei("bottom",e,i),fill:"none",stroke:p,strokeWidth:1}),j.map((t,e)=>{const o=!!d&&("function"==typeof d?d(t.value,e):et(t.value,e>0?j[e-1].value:void 0));return Li("g",{transform:`translate(${t.pixel},${i})`,children:[Fi("line",{y2:5,stroke:p,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?Fi("text",{y:v,textAnchor:x?"end":Ni(_,t.pixel===S.min,t.pixel===S.max),fontWeight:o?600:400,fill:y,className:"semiotic-axis-tick",style:{userSelect:"none",...o?w:k},transform:x?"rotate(-45)":void 0,children:t.label}):Fi("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:Fi("div",{style:{textAlign:"center",userSelect:"none",...k},children:t.label})})]},"xtick-"+e)}),c&&Fi("text",{x:e/2,y:b,textAnchor:"middle",fill:m,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:c})]}),Li("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!I||X)&&s&&!a&&Fi("line",{x1:0,y1:0,x2:0,y2:i,stroke:p,strokeWidth:1}),(!I||X)&&a&&Fi("path",{d:Ei("left",e,i),fill:"none",stroke:p,strokeWidth:1}),q.map((t,e)=>{const i=!!f&&("function"==typeof f?f(t.value,e):et(t.value,e>0?q[e-1].value:void 0));return Li("g",{transform:`translate(0,${t.pixel})`,children:[Fi("line",{x2:-5,stroke:p,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?Fi("text",{x:-8,textAnchor:"end",dominantBaseline:Oi(C,t.pixel===M.min,t.pixel===M.max),fontWeight:i?600:400,fill:y,className:"semiotic-axis-tick",style:{userSelect:"none",...i?w:k},children:t.label}):Fi("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:Fi("div",{style:{textAlign:"right",userSelect:"none",...k},children:t.label})})]},"ytick-"+e)}),(()=>{const e=t?.label||h;return e?Fi("text",{x:15-n.left,y:i/2,textAnchor:"middle",fill:m,transform:`rotate(-90, ${15-n.left}, ${i/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:e}):null})()]}),(()=>{const t=l?.find(t=>"right"===t.orient);if(!t||0===U.length)return null;const o=!1!==t.baseline,s=t.landmarkTicks,r=t.label||u,a=t.tickAnchor,c=Wi(U);return Li("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[o&&Fi("line",{x1:e,y1:0,x2:e,y2:i,stroke:p,strokeWidth:1}),U.map((t,i)=>{const o=!!s&&("function"==typeof s?s(t.value,i):et(t.value,i>0?U[i-1].value:void 0));return Li("g",{transform:`translate(${e},${t.pixel})`,children:[Fi("line",{x2:5,stroke:p,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?Fi("text",{x:8,textAnchor:"start",dominantBaseline:Oi(a,t.pixel===c.min,t.pixel===c.max),fontWeight:o?600:400,fill:y,className:"semiotic-axis-tick",style:{userSelect:"none",...o?w:k},children:t.label}):Fi("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:Fi("div",{style:{textAlign:"left",userSelect:"none",...k},children:t.label})})]},"ytick-r-"+i)}),r&&Fi("text",{x:e+n.right-15,y:i/2,textAnchor:"middle",fill:m,transform:`rotate(90, ${e+n.right-15}, ${i/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...A},children:r})]})})()]})})(),tt,S&&r&&M&&P&&Li(zi,{children:[S.top&&Fi("g",{transform:"translate(0, 0)",children:Fi(Ti,{orient:"top",config:Ri(S.top),values:M,scale:r.x,size:n.top,length:e})}),S.bottom&&Fi("g",{transform:`translate(0, ${i})`,children:Fi(Ti,{orient:"bottom",config:Ri(S.bottom),values:M,scale:r.x,size:n.bottom,length:e})}),S.left&&Fi("g",{transform:"translate(0, 0)",children:Fi(Ti,{orient:"left",config:Ri(S.left),values:P,scale:r.y,size:n.left,length:i})}),S.right&&Fi("g",{transform:`translate(${e}, 0)`,children:Fi(Ti,{orient:"right",config:Ri(S.right),values:P,scale:r.y,size:n.right,length:i})})]}),C,it&&it.sourceId!==G&&r?.x&&(()=>{const t=r.x(it.xValue);if(null==t||0>t||t>e)return null;const o=it.locked;return Fi("line",{x1:t,y1:0,x2:t,y2:i,stroke:o?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:o?1.5:1,strokeDasharray:o?"6,3":"4,4",pointerEvents:"none"})})(),V]}),y&&"string"==typeof y?Fi("text",{x:o/2,y:_t,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:y}):y?Fi("foreignObject",{x:0,y:0,width:o,height:n.top,children:y}):null,jt({legend:m,totalWidth:o,totalHeight:s,margin:n,legendPosition:A,title:y,legendLayout:_,legendHoverBehavior:x,legendClickBehavior:v,legendHighlightedCategory:b,legendIsolatedCategories:k})]}):null}var Gi={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white",primary:"#007bff",background:""};function Vi(t,e){const i=t.trim();if(/^#[0-9a-f]{3}$/i.test(i)){const t=i[1],o=i[2],s=i[3];return`#${t}${t}${o}${o}${s}${s}${e}`}if(/^#[0-9a-f]{6}$/i.test(i))return`${i}${e}`;const o=i.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return o?`rgba(${o[1]}, ${(parseInt(e,16)/255).toFixed(3)})`:i}var Hi=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ji=3156e7;function qi(t){const e=t[1]-t[0];return 864e5>e?t=>{const e=new Date(t);return`${(e.getUTCHours()+"").padStart(2,"0")}:${(e.getUTCMinutes()+"").padStart(2,"0")}`}:ji>e?t=>{const e=new Date(t);return`${Hi[e.getUTCMonth()]} ${e.getUTCDate()}`}:5*ji>e?t=>{const e=new Date(t);return`${Hi[e.getUTCMonth()]} ${e.getUTCFullYear()}`}:t=>new Date(t).getUTCFullYear()+""}function Ui(t){if(!t)return;const e=[];for(const i of t)if("point"===i.type)e.push(i);else if("symbol"===i.type)e.push({pointId:i.pointId,x:i.x,y:i.y,r:Qt(i.size)});else if("glyph"===i.type){const t=le(i.glyph,i.size);e.push({pointId:i.pointId,x:i.x+t.centerDx,y:i.y+t.centerDy,r:t.radius})}return e}import{area as Ki,line as Ji}from"d3-shape";function Qi(t,e){const i=Kt(e.curve);if(!i||2>e.topPath.length||2>e.bottomPath.length){t.beginPath(),t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let i=1;e.topPath.length>i;i++)t.lineTo(e.topPath[i][0],e.topPath[i][1]);for(let i=e.bottomPath.length-1;i>=0;i--)t.lineTo(e.bottomPath[i][0],e.bottomPath[i][1]);t.closePath()}else{const o=Ki().x(t=>t[0]).y0((t,i)=>e.bottomPath[i][1]).y1(t=>t[1]).curve(i).context(t);t.beginPath(),o(e.topPath)}}var Zi=(t,e,i,o)=>{const s=e.filter(t=>"area"===t.type);for(const e of s){if(2>e.topPath.length)continue;let i=!1;e.clipRect&&(t.save(),t.beginPath(),t.rect(e.clipRect.x,e.clipRect.y,e.clipRect.width,e.clipRect.height),t.clip(),i=!0);const s=e._introClipFraction;void 0!==s&&1>s&&(t.save(),t.beginPath(),t.rect(0,0,o.width*s,o.height),t.clip());const n=Ut(t,e.style.fill,"#4e79a7"),r=e._decayOpacities;if(r&&r.length===e.topPath.length){const i=e.style.fillOpacity??.7;t.fillStyle=n;for(let o=0;e.topPath.length-1>o;o++)t.globalAlpha=.5*(r[o]+r[o+1])*i,t.beginPath(),t.moveTo(e.topPath[o][0],e.topPath[o][1]),t.lineTo(e.topPath[o+1][0],e.topPath[o+1][1]),t.lineTo(e.bottomPath[o+1][0],e.bottomPath[o+1][1]),t.lineTo(e.bottomPath[o][0],e.bottomPath[o][1]),t.closePath(),t.fill();if(e.style.stroke&&"none"!==e.style.stroke){t.strokeStyle=qt(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);for(let i=0;e.topPath.length-1>i;i++)t.globalAlpha=.5*(r[i]+r[i+1]),t.beginPath(),t.moveTo(e.topPath[i][0],e.topPath[i][1]),t.lineTo(e.topPath[i+1][0],e.topPath[i+1][1]),t.stroke()}t.globalAlpha=1;continue}const a=e.style.opacity??1;if(Qi(t,e),e.fillGradient&&("colorStops"in e.fillGradient&&e.fillGradient.colorStops.length>=2||"topOpacity"in e.fillGradient)&&e.fillGradient){let i=1/0;for(const t of e.topPath)i>t[1]&&(i=t[1]);let o=-1/0;for(const t of e.bottomPath)t[1]>o&&(o=t[1]);const s=Yt(t,e.fillGradient,"string"==typeof n?n:"#4e79a7",0,i,0,o);t.fillStyle=s||n,t.globalAlpha=a}else t.globalAlpha=(e.style.fillOpacity??.7)*a,t.fillStyle=n;if(t.fill(),e._pulseIntensity&&e._pulseIntensity>0&&(Qi(t,e),ot(t,e)),e.style.stroke&&"none"!==e.style.stroke){t.globalAlpha=a;const i=e.strokeGradient&&e.topPath.length>=2?Mt(t,e.strokeGradient,e.topPath[0][0],0,e.topPath[e.topPath.length-1][0],0):null;t.strokeStyle=i||qt(t,e.style.stroke)||e.style.stroke,t.lineWidth=e.style.strokeWidth||2,t.setLineDash([]);const o=Kt(e.curve);if(t.beginPath(),o)Ji().x(t=>t[0]).y(t=>t[1]).curve(o).context(t)(e.topPath);else{t.moveTo(e.topPath[0][0],e.topPath[0][1]);for(let i=1;e.topPath.length>i;i++)t.lineTo(e.topPath[i][0],e.topPath[i][1])}t.stroke()}void 0!==s&&1>s&&t.restore(),i&&t.restore(),t.globalAlpha=1}};function to(t){const[e,i,o]=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);return.299*e+.587*i+.114*o>128?"#000":"#fff"}function eo(t){return Number.isInteger(t)?t+"":100>Math.abs(t)?1>Math.abs(t)?t.toPrecision(3):t.toFixed(1):t.toFixed(0)}var io=(t,e,i,o)=>{const s=e.filter(t=>"heatcell"===t.type);t.save();try{for(const e of s){const i=e.style;null!=i?.opacity&&(t.globalAlpha=i.opacity),t.fillStyle=e.fill,t.fillRect(e.x,e.y,e.w,e.h);const o=Math.max(0,i?.strokeWidth??1);if(o>0&&(t.strokeStyle=qt(t,i?.stroke??"var(--semiotic-surface, #fff)"),t.lineWidth=o,t.strokeRect(e.x,e.y,e.w,e.h)),st(t,e),t.globalAlpha=1,e.showValues&&null!=e.value){if(20>e.w||20>e.h)continue;const i=e.valueFormat?e.valueFormat(e.value):eo(e.value),o=Math.max(10,Math.min(16,.3*Math.min(e.w,e.h))),s=e.x+e.w/2,n=e.y+e.h/2;t.fillStyle=to(e.fill),t.font=o+"px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(i,s,n)}}}finally{t.restore()}},oo=(t,e,i,o)=>{for(const i of e){if("candlestick"!==i.type)continue;const e=i;t.save();const s=(e._decayOpacity??1)*(e.style?.opacity??1);1!==s&&(t.globalAlpha=s);const n=qt(t,e.wickColor)||e.wickColor,r=60>o.height,a=r?Math.max(e.wickWidth,2):e.wickWidth,l=()=>{t.beginPath(),t.moveTo(e.x,e.highY),t.lineTo(e.x,e.lowY),t.strokeStyle=n,t.lineWidth=a,t.stroke()};if(r||l(),e.isRange){const i=e.dotRadius??Math.max(2,Math.min(e.bodyWidth/2,.12*o.height));t.fillStyle=n,t.beginPath(),t.arc(e.x,e.highY,i,0,2*Math.PI),t.fill(),t.beginPath(),t.arc(e.x,e.lowY,i,0,2*Math.PI),t.fill()}else if(e.bodyWidth>0){const i=Math.min(e.openY,e.closeY),o=Math.abs(e.openY-e.closeY),s=e.isUp?e.upColor:e.downColor,n=qt(t,s)||s;t.fillStyle=n,t.fillRect(e.x-e.bodyWidth/2,i,e.bodyWidth,Math.max(o,1)),t.strokeStyle=n,t.lineWidth=1,t.strokeRect(e.x-e.bodyWidth/2,i,e.bodyWidth,Math.max(o,1))}r&&l(),t.restore()}},so={line:[Zi,t,W],area:[Zi,W],stackedarea:[Zi,W],scatter:[W,k],bubble:[W,k],heatmap:[io],bar:[n],swarm:[W],waterfall:[(t,e,i,o)=>{n(t,e,i,o);const s=e.filter(t=>"rect"===t.type);if(2>s.length)return;const r=s[0].datum,a=r?._connectorStroke;if(a){t.save(),t.strokeStyle=qt(t,a)||a,t.lineWidth=r?._connectorWidth??1,t.setLineDash([]);for(let e=0;s.length-1>e;e++){const o=s[e],n=s[e+1],r=o.datum,a=n.datum;if(null==r?.cumEnd||null==a?.baseline)continue;const l=i.y(r.cumEnd),c=o.x+o.w,h=n.x;t.beginPath(),t.moveTo(c,l),t.lineTo(h,l),t.stroke()}t.restore()}}],candlestick:[oo],mixed:[Zi,t,W],custom:[Zi,n,io,t,W,k,Z,oo]};import{jsx as no,jsxs as ro}from"react/jsx-runtime";function ao(t){return null==t?"":"number"==typeof t?Number.isInteger(t)?t+"":t.toFixed(2):t instanceof Date?t.toLocaleString():t+""}function lo({hover:t}){const e=t.data??{},i=e.y??e.value,o=e.x??e.time;if(void 0===i&&void 0===o){const t=Jt(e);if(null!=t.title||t.entries.length>0)return ro("div",{className:"semiotic-tooltip",style:Wt,children:[null!=t.title&&no("div",{style:{fontWeight:600,marginBottom:t.entries.length?2:0},children:t.title+""}),t.entries.map(t=>ro("div",{style:{opacity:.7,fontSize:11},children:[t.key,":"," ",no("span",{style:{fontWeight:600},children:ao(t.value)})]},t.key))]})}return ro("div",{className:"semiotic-tooltip",style:Wt,children:[no("div",{style:{fontWeight:600,marginBottom:2},children:ao(i)}),no("div",{style:{opacity:.7,fontSize:11},children:ao(o)})]})}lo.ownsChrome=!0;import{jsx as co,jsxs as ho}from"react/jsx-runtime";var uo={top:20,right:20,bottom:30,left:40},go=Gi;function fo(t){if(t)return"x"===t.dimension?"pan-y":"y"===t.dimension?"pan-x":"none"}var po=be(ve(function(t,o){const{chartType:s,runtimeMode:n,data:r,chunkThreshold:l,chunkSize:c,xAccessor:h,yAccessor:u,accessorRevision:g,colorAccessor:d,sizeAccessor:f,symbolAccessor:p,symbolMap:y,groupAccessor:v,lineDataAccessor:b,curve:k,normalize:w,baseline:A,stackOrder:_,binSize:C,valueAccessor:S,arrowOfTime:M="right",windowMode:P="sliding",windowSize:Y=200,timeAccessor:T,xExtent:N,yExtent:O,extentPadding:W=.1,scalePadding:D,sizeRange:G,size:V=[500,300],responsiveWidth:H,responsiveHeight:q,margin:U,className:K,background:J,renderMode:Q,lineStyle:Z,pointStyle:tt,areaStyle:et,barStyle:ot,waterfallStyle:st,swarmStyle:ut,barColors:xt,colorScheme:vt,boundsAccessor:bt,boundsStyle:_t,y0Accessor:Ct,band:St,gradientFill:Mt,lineGradient:Yt,areaGroups:Tt,openAccessor:Nt,highAccessor:Ot,lowAccessor:Wt,closeAccessor:Lt,candlestickStyle:Xt,showAxes:$t=!0,axes:Ht,xLabel:jt,yLabel:qt,yLabelRight:Ut,xFormat:Kt,yFormat:Jt,axisExtent:Qt,tickFormatTime:Zt,tickFormatValue:te,hoverAnnotation:ee,tooltipContent:re,customHoverBehavior:le,customClickBehavior:ve,onObservation:be,annotationObservationCallback:ke,chartId:we,enableHover:Ae,hoverRadius:_e=30,tooltipMode:Se,annotations:Me,onAnnotationActivate:Pe,autoPlaceAnnotations:Ye,svgAnnotationRules:Re,showGrid:Te,legend:Ne,legendHoverBehavior:Oe,legendClickBehavior:We,legendHighlightedCategory:De,legendIsolatedCategories:Ee,legendPosition:ze,legendLayout:Fe,legendCategoryAccessor:Le,onCategoriesChange:Be,backgroundGraphics:Ie,foregroundGraphics:Xe,canvasPreRenderers:$e,svgPreRenderers:Ge,title:Ve,categoryAccessor:He,brush:je,onBrush:qe,decay:Ue,pulse:Ke,transition:Je,animate:Qe,staleness:Ze,frameScheduler:ti,clock:ei,random:ii,seed:oi,paused:si=!1,suspendWhenHidden:ni=!0,heatmapAggregation:ri,heatmapXBins:li,heatmapYBins:ci,showValues:di,heatmapValueFormat:fi,marginalGraphics:pi,pointIdAccessor:yi,xScaleType:mi,yScaleType:xi,accessibleTable:vi=!0,description:bi,summary:ki,linkedCrosshairName:Ai,linkedCrosshairSourceId:_i,customLayout:Ci,onLayoutError:Si,layoutConfig:Mi,layoutSelection:Pi}=t,{customHoverBehavior:Yi,customClickBehavior:Ri,hasClickBehavior:Ti}=F({customHoverBehavior:le,customClickBehavior:ve,onObservation:be,chartId:we,chartType:"StreamXYFrame"}),Ni=xe().replace(/:/g,""),Oi=ge(!1),Wi=ge({w:-1,h:-1}),Di=ge(!1),Ei=ie({sizeProp:V,responsiveWidth:H,responsiveHeight:q,userMargin:U,marginDefault:uo,title:Ve,legend:Ne,legendPosition:ze,animate:Qe,transitionProp:Je,frameScheduler:ti,clock:ei,random:ii,seed:oi,paused:si,suspendWhenHidden:ni,themeDirtyRef:Oi}),zi=ce(),Fi=he(),{reducedMotionRef:Li,responsiveRef:Ii,size:Xi,currentTheme:Hi,transition:ji,introEnabled:Ki,tableId:Ji,rafRef:Qi,renderFnRef:Zi,scheduleRender:to,frameRuntime:eo}=Ei;let io=Ei.margin;if(pi){const t=60,e={...Ei.margin};pi.top&&t>e.top&&(e.top=t),pi.bottom&&t>e.bottom&&(e.bottom=t),pi.left&&t>e.left&&(e.left=t),pi.right&&t>e.right&&(e.right=t),io=e}const oo=Xi[0]-io.left-io.right,no=Xi[1]-io.top-io.bottom,ro=pe(()=>Dt(r),[r]),ao=ee??Ae,[po,yo]=de(0),mo=ge(0),[xo,vo]=de(null),bo=x(Xe,Xi,io,xo),ko=x(Ie,Xi,io,xo),wo=ge(null),Ao=ge(null),_o=ge(void 0),[Co,So]=de(null),Mo=ge(go.primary),Po=ge(function(){let t=-1,e=Gi;return{resolve(i){if(!i)return Gi;const o=Et();return o===t||(e=function(t){if(!t)return Gi;const e=getComputedStyle(t),i=e.getPropertyValue("--semiotic-border").trim(),o=e.getPropertyValue("--semiotic-text-secondary").trim(),s=e.getPropertyValue("--semiotic-bg").trim(),n=e.getPropertyValue("--semiotic-primary").trim(),r=o||e.getPropertyValue("--text-secondary").trim(),a=e.getPropertyValue("--text-primary").trim(),l=i||e.getPropertyValue("--surface-3").trim(),c=s||e.getPropertyValue("--surface-0").trim();return r||a||i||n?{axisStroke:l||Gi.axisStroke,tickText:r||Gi.tickText,crosshair:r?Vi(r,"66"):Gi.crosshair,hoverFill:c?Vi(c,"4D"):Gi.hoverFill,hoverStroke:r?Vi(r,"99"):Gi.hoverStroke,pointRing:c||Gi.pointRing,primary:n||Gi.primary,background:c||Gi.background}:Gi}(i),t=o),e},invalidate(){t=-1}}}()),Yo=ge(!1),Ro=se("StreamXYFrame"),[To,No]=de(!1),[Oo,Wo]=de([]),[Do,Eo]=de([]),zo="streaming"===n||["bar","swarm","waterfall"].includes(s),Fo=pe(()=>({chartType:s,runtimeMode:zo?"streaming":"bounded",windowSize:Y,windowMode:P,arrowOfTime:zo?M:"right",extentPadding:W,scalePadding:D,axisExtent:Qt,xAccessor:h,yAccessor:u,accessorRevision:g,timeAccessor:zo?T:void 0,valueAccessor:S,colorAccessor:d,sizeAccessor:f,symbolAccessor:p,symbolMap:y,groupAccessor:v||(b?"_lineGroup":void 0),categoryAccessor:He,lineDataAccessor:b,xScaleType:mi,yScaleType:xi,xExtent:N,yExtent:O,sizeRange:G,binSize:C,normalize:w,baseline:A,stackOrder:_,boundsAccessor:bt,boundsStyle:_t,y0Accessor:Ct,band:St,gradientFill:!0===Mt?{topOpacity:.8,bottomOpacity:.05}:!1===Mt?void 0:Mt,areaGroups:Tt?new Set(Tt):void 0,lineGradient:Yt,openAccessor:Nt,highAccessor:Ot,lowAccessor:Wt,closeAccessor:Lt,candlestickStyle:Xt,lineStyle:Z,pointStyle:tt,areaStyle:et,swarmStyle:ut,waterfallStyle:st,colorScheme:vt,barColors:xt,barStyle:ot,annotations:Me,decay:Ue,pulse:Ke,transition:ji,introAnimation:Ki,staleness:Ze,clock:eo.now,heatmapAggregation:ri,heatmapXBins:li,heatmapYBins:ci,showValues:di,heatmapValueFormat:fi,pointIdAccessor:yi,curve:k,themeCategorical:Hi?.colors?.categorical,themeSemantic:ae(Hi),themeSequential:Hi?.colors?.sequential,themeDiverging:Hi?.colors?.diverging,customLayout:Ci,onLayoutError:Si,layoutConfig:Mi,layoutMargin:io}),[s,zo,Y,P,M,W,D,Qt,h,u,g,T,S,d,f,p,y,v,b,He,mi,xi,N,O,G,C,w,A,_,bt,_t,Ct,St,Mt,Tt,Yt,Nt,Ot,Wt,Lt,Xt,Z,tt,et,ut,st,vt,xt,ot,Me,Ue,Ke,ji,Ki,Ze,eo.now,ri,li,ci,di,fi,yi,k,Hi,Ci,Si,Mi,io]),Lo=ct(Fo),Bo=ge(null);Bo.current||(Bo.current=new ai(Lo));const Io=z(Bo,Le,Be,t=>t.getData());at(Bo,Lo,Oi,to),lt(Bo,Pi,Oi,to);const Xo=ge(null);Xo.current||(Xo.current=new i(t=>{const e=Bo.current;e&&e.ingest(t)&&(Oi.current=!0,to())},{chunkThreshold:l,chunkSize:c})),fe(()=>{Xo.current?.updateChunkOptions({chunkThreshold:l,chunkSize:c})},[l,c]);const $o=ye(t=>{Xo.current?.push(t)},[]),Go=ye(t=>{Xo.current?.pushMany(t)},[]),Vo=ye(()=>{Xo.current?.clear(),Bo.current?.clear(),Oi.current=!0,to()},[to]);me(o,()=>({push:$o,pushMany:Go,remove:t=>{Xo.current?.flush();const e=Bo.current?.remove(t)??[];return e.length>0&&(wo.current&&e.some(t=>t===wo.current?.data)&&(wo.current=null,So(null)),Oi.current=!0,to()),e},update:(t,e)=>{Xo.current?.flush();const i=Bo.current?.update(t,e)??[];return i.length>0&&(Oi.current=!0,to()),i},clear:Vo,getData:()=>(Xo.current?.flush(),Bo.current?.getData()??[]),getScales:()=>Bo.current?.scales??null,getExtents:()=>Bo.current?.getExtents()??null,getCustomLayout:()=>Bo.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Bo.current?.lastCustomLayoutFailure??null}),[$o,Go,Vo,to]),fe(()=>{if(r){if(b&&ro.length>0&&"object"==typeof ro[0]&&null!==ro[0]){const t="string"==typeof b?b:"coordinates";if(Array.isArray(ro[0][t])){const e=[];for(const i of ro){const o=i[t];if(Array.isArray(o)){const t=i.label||i.id||i.key;if(null!=t)for(const i of o)e.push({...i,_lineGroup:t});else for(const t of o)e.push(t)}}return void Xo.current?.setBoundedData(e)}}Xo.current?.setBoundedData(ro)}},[r,ro,b]);const{canvasRef:Ho,interactionCanvasRef:jo}=oe(Ei,{storeRef:Bo,dirtyRef:Oi,hydrated:zi,wasHydratingFromSSR:Fi,cleanup:()=>Xo.current?.clear(),canvasPaintDependencies:[s,oo,no,$t,J,Ie,Z,Q,$e,to]}),{hoverHandlerRef:qo,hoverLeaveRef:Uo,onPointerMove:Ko,onPointerLeave:Jo}=Ei;qo.current=t=>{if(!ao)return;const e=Ho.current;if(!e)return;const i=e.getBoundingClientRect(),o=t.clientX-i.left-io.left,n=t.clientY-i.top-io.top;if(0>o||o>oo||0>n||n>no)return void(wo.current&&(wo.current=null,Ao.current=null,So(null),Yi&&(Yi(null),Oi.current=!0),to()));const r=Bo.current;if(!r||0===r.scene.length)return;const a=Ft(_e,t.pointerType),l=ui(r.scene,o,n,a,r.quadtree,r.maxPointRadius),c="multi"===Se,u=()=>{wo.current&&(wo.current=null,Ao.current=null,So(null),Yi&&Yi(null),to())};if(!l&&!c)return void u();const g=c||!l?o:l.x,d=c||!l?n:l.y,f=l?.datum?R(l.datum,r.resolvedRibbons):{},p=r.scales?.x?.invert,y="function"==typeof p?p(g):void 0;let m=Pt(f,g,d,null!=y?{xValue:y,xPx:g}:void 0);if(c&&r.scene.length>0&&r.scales){const t=function(t,e,i=30){const o=[];for(const s of t)if("line"===s.type){const t=s;if(2>t.path.length)continue;const n=gi(hi(t.path,t.curve),e,i);if(null===n)continue;const r=wi(t.path,e);o.push({node:s,datum:Array.isArray(t.datum)&&t.datum[r]?t.datum[r]:t.datum,x:t.path[r][0],y:n,group:t.group,color:t.style.stroke})}else if("area"===s.type){const t=s;if(!1===t.interactive)continue;if(2>t.topPath.length)continue;const n=hi(t.topPath,t.curve),r=hi(t.bottomPath,t.curve),a=gi(n,e,i);if(null===a)continue;const l=gi(r,e,i),c=wi(t.topPath,e);o.push({node:s,datum:Array.isArray(t.datum)&&t.datum[c]?t.datum[c]:t.datum,x:t.topPath[c][0],y:a,y0:l??void 0,group:t.group,color:"string"==typeof t.style.stroke?t.style.stroke:"string"==typeof t.style.fill?t.style.fill:void 0})}return o}(r.scene,g,Math.max(a,oo));if(t.length>0){const e=r.scales.y.invert,i=Mo.current,o=p?p(g):g;if(l)m.xValue=o,m.xPx=g;else{const t={xValue:o};"string"==typeof h&&(t[h]=o),m=Pt(t,g,d,{xValue:o,xPx:g})}m.allSeries=t.map(t=>{const o=e?e(t.y):t.y,n=null!=t.y0?e?e(t.y0):t.y0:void 0;return{group:t.group||"",value:"stackedarea"===s&&null!=n?o-n:o,valuePx:t.y,color:t.color||i,datum:R(t.datum,r.resolvedRibbons)}})}}l||m.allSeries?.length?(wo.current=m,Ao.current=l?.node??null,So(m),Yi&&(Yi(m),Oi.current=!0),to()):u()},Uo.current=()=>{wo.current&&(wo.current=null,Ao.current=null,So(null),Yi&&(Yi(null),Oi.current=!0),to())};const Qo=ge(()=>{});Qo.current=t=>{if(Bt(t.target))return;if(!Ri)return;const e=Ho.current;if(!e)return;const i=e.getBoundingClientRect(),o=t.clientX-i.left-io.left,s=t.clientY-i.top-io.top;if(0>o||o>oo||0>s||s>no)return void Ri(null);const n=Bo.current;if(!n||0===n.scene.length)return void Ri(null);const r=Ft(_e,_o.current),a=ui(n.scene,o,s,r,n.quadtree,n.maxPointRadius);if(!a)return void Ri(null);const l=a.datum||{},c=n.scales?.x?.invert,h="function"==typeof c?c(a.x):void 0;Ri(Pt(l,a.x,a.y,null!=h?{xValue:h,xPx:a.x}:void 0),{type:"activate",inputType:Gt(_o.current)})};const Zo=ye(t=>Qo.current(t),[]),{kbFocusIndexRef:ts,focusedNavPointRef:es,onKeyDown:is}=L({storeRef:Bo,hoverRef:wo,hoveredNodeRef:Ao,setHoverPoint:So,customHoverBehavior:Yi,customClickBehavior:Ri,scheduleRender:to}),os=ye(t=>{_o.current=t.pointerType,ts.current=-1,es.current=null,Ko(t)},[es,ts,Ko]),ss=ye(t=>{_o.current="mouse",ts.current=-1,es.current=null,Ko({clientX:t.clientX,clientY:t.clientY,pointerType:"mouse"})},[es,ts,Ko]),ns=ye(t=>{_o.current=t.pointerType},[]);Zi.current=()=>{if(Qi.current=null,!eo.isActive)return;const t=Ho.current,i=jo.current;if(!t||!i)return;const o=Bo.current;if(!o)return;const n=eo.now(),r=o.advanceTransition(Li.current?n+1e6:n),a=!Li.current&&r,l=Wi.current.w!==oo||Wi.current.h!==no,c=Oi.current||r||l,g=o.consumeStylePaintPending();let d=!1;const f=o.getLastUpdateResult(),p=Ro.current.beforeCompute(f,a);!c||a&&!l||(o.computeScene({width:oo,height:no}),Wi.current={w:oo,h:no},d=!0,Io()),Ro.current.afterCompute(p,d,l);const y=E(o,n,d,Di),m=zt(),x=Po.current.resolve(t);Mo.current=x.primary;const v=rt(Ze,o.lastIngestTime>0?n-o.lastIngestTime:0),b=Ze&&v.isStale;if(c||g||y.changed){const e=Vt(t,Xi,io,m);if(e){if(e.clearRect(-io.left,-io.top,Xi[0],Xi[1]),Ze&&1>v.alpha&&(e.globalAlpha=v.alpha),I(e,{background:J,hasBackgroundGraphics:!!Ie,themeBackground:x.background,x:-io.left,y:-io.top,width:Xi[0],height:Xi[1]}),e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,oo,no),e.clip()),$e&&o.scales)for(const t of $e)e.save(),t(e,o.scene,o.scales,{width:oo,height:no}),e.restore();const t=Ci?so.custom:so[s];it({context:e,nodes:o.scene,renderMode:Q,pixelRatio:m,paintBuiltIn:i=>{if(t&&o.scales)for(const s of t)s(e,i,o.scales,{width:oo,height:no})}}),e.restore(),Ze&&1>v.alpha&&(e.globalAlpha=1)}}const k=!!(ao&&wo.current&&o.scales),w=!!(Ao.current&&Array.isArray(ee)&&ee.some(t=>t&&"object"==typeof t&&"highlight"===t.type)),A=k||w;if(B(A,Yo.current)){const t=Vt(i,Xi,io,m);if(t&&(t.clearRect(-io.left,-io.top,Xi[0],Xi[1]),k&&wo.current&&function(t,i,o,s,n,r,a){if(!1===n.crosshair)return;const l=i.allSeries,c=l&&l.length>0,h=i.xPx??i.x;t.save();const u="object"==typeof n.crosshair?n.crosshair:{};if(t.strokeStyle=u.stroke||a.crosshair,t.lineWidth=u.strokeWidth||1,t.setLineDash(u.strokeDasharray?u.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),t.beginPath(),t.moveTo(c?h:i.x,0),t.lineTo(c?h:i.x,s),t.stroke(),c||(t.beginPath(),t.moveTo(0,i.y),t.lineTo(o,i.y),t.stroke()),t.restore(),c){t.lineWidth=2,t.strokeStyle=a.pointRing;for(const e of l)null!=e.valuePx&&(t.beginPath(),t.arc(h,e.valuePx,4,0,2*Math.PI),t.fillStyle=e.color||a.primary,t.fill(),t.stroke())}else{const o=n.pointColor||e(r)||a.primary;t.beginPath(),t.arc(i.x,i.y,4,0,2*Math.PI),t.fillStyle=o,t.fill(),t.strokeStyle=a.pointRing,t.lineWidth=2,t.stroke()}}(t,wo.current,oo,no,"object"==typeof ao?ao:{},Ao.current,x),w&&Ao.current&&Array.isArray(ee))){const e=ee.find(t=>t&&"object"==typeof t&&"highlight"===t.type);e&&function(t,e,i,o,s){if(!i)return;const n="group"in i?i.group:void 0;if(void 0!==n)for(const i of e){if("line"!==i.type)continue;if(i.group!==n)continue;if(2>i.path.length)continue;const e="function"==typeof o.style?i.datum?o.style(i.datum):{}:o.style||{};t.save(),t.beginPath(),t.moveTo(i.path[0][0],i.path[0][1]);for(let e=1;i.path.length>e;e++)t.lineTo(i.path[e][0],i.path[e][1]);t.strokeStyle=e.stroke||i.style.stroke||s.primary,t.lineWidth=e.strokeWidth||(i.style.strokeWidth||2)+2,t.globalAlpha=e.opacity??1,t.stroke(),t.restore()}}(t,o.scene,Ao.current,e,x)}Yo.current=A}c&&t&&t.setAttribute("aria-label",Rt(o.scene,s+" chart"));const _=Oi.current;if(Oi.current=_&&a&&!d,_&&o.scales){const t=t=>"object"==typeof t&&null!==t&&"function"==typeof t.valueOf?t.valueOf():t;if((!xo||t(xo.x.domain()[0])!==t(o.scales.x.domain()[0])||t(xo.x.domain()[1])!==t(o.scales.x.domain()[1])||t(xo.y.domain()[0])!==t(o.scales.y.domain()[0])||t(xo.y.domain()[1])!==t(o.scales.y.domain()[1])||xo.x.range()[0]!==o.scales.x.range()[0]||xo.x.range()[1]!==o.scales.x.range()[1]||xo.y.range()[0]!==o.scales.y.range()[0]||xo.y.range()[1]!==o.scales.y.range()[1])&&vo(o.scales),pi){const t=o.getData(),e="function"==typeof h?h:t=>t[h||"x"],i="function"==typeof u?u:t=>t[u||"y"];Wo(t.map(t=>e(t)).filter(t=>"number"==typeof t&&isFinite(t))),Eo(t.map(t=>i(t)).filter(t=>"number"==typeof t&&isFinite(t)))}}!((Me&&Me.length>0||Ci)&&(d||a))||!d&&33>n-mo.current||(yo(t=>t+1),mo.current=n),Ze?.showBadge&&No(!!b),(a||null!=o.activeTransition||y.pending)&&to()},ht(Ze,Bo,Oi,to,To,No);const rs=pe(()=>{if(Kt||Zt)return;const t=Bo.current;return t?.xIsDate&&xo?qi(xo.x.domain()):void 0},[Kt,Zt,xo]),as=Kt||Zt||rs,ls=ao&&Co?re?re(Co):co(lo,{hover:Co}):null,cs=ls?co(yt,{x:Co.x,y:Co.y,containerWidth:oo,containerHeight:no,margin:io,className:"stream-frame-tooltip",children:ls}):null,hs=es.current,us=co(mt,{active:ts.current>=0,hoverPoint:Co,margin:io,size:Xi,shape:hs?.shape,width:hs?.w,height:hs?.h}),gs=m(h,T,"__semiotic_resolvedX","__semiotic_resolvedTime"),ds=m(u,S,"__semiotic_resolvedY","__semiotic_resolvedValue"),fs=gs.key,ps=ds.key,ys=a(gs,ds,Me&&Me.length>0||!1);if(It||!zi&&Fi){const t=Bo.current;t&&r&&(t.ingest({inserts:ro,bounded:!0}),t.computeScene({width:oo,height:no}));const e=t?.scene??[],i=t?.scales??null,o=x(Xe,Xi,io,i),s=x(Ie,Xi,io,i),n=as||(()=>{if(t?.xIsDate&&i)return qi(i.x.domain())})();return ho("div",{ref:Ii,className:"stream-xy-frame"+(K?" "+K:""),role:"img","aria-label":bi||("string"==typeof Ve?Ve:"XY chart"),style:{position:"relative",width:H?"100%":Xi[0],height:q?"100%":Xi[1]},children:[co(wt,{summary:ki}),ho("svg",{xmlns:"http://www.w3.org/2000/svg",width:Xi[0],height:Xi[1],style:{position:"absolute",left:0,top:0},children:[co("g",{transform:`translate(${io.left},${io.top})`,children:s}),ho("g",{transform:`translate(${io.left},${io.top})`,children:[J&&co("rect",{x:0,y:0,width:oo,height:no,fill:J}),Ge&&i&&Ge.map((t,o)=>co(ue.Fragment,{children:t(e,i,{width:oo,height:no})},"svgpre-"+o)),e.map((t,e)=>nt({node:t,index:e,renderMode:Q,fallback:()=>ne(t,e,Ni)})).filter(Boolean)]})]}),co($i,{width:oo,height:no,totalWidth:Xi[0],totalHeight:Xi[1],margin:io,scales:i,showAxes:$t,axes:Ht,xLabel:jt,yLabel:qt,yLabelRight:Ut,xFormat:n,yFormat:Jt||te,axisExtent:Qt,showGrid:Te,title:Ve,legend:Ne,legendHoverBehavior:Oe,legendClickBehavior:We,legendHighlightedCategory:De,legendIsolatedCategories:Ee,legendPosition:ze,legendLayout:Fe,foregroundGraphics:j(o,gt(Bo.current?.customLayoutOverlays,Pi??null)),marginalGraphics:pi,xValues:[],yValues:[],annotations:Me,onAnnotationActivate:Pe,onObservation:ke??be,chartId:we,chartType:"StreamXYFrame",autoPlaceAnnotations:Ye,svgAnnotationRules:Re,annotationFrame:0,xAccessor:fs,yAccessor:ps,annotationData:ys(Bo.current?.getData()),pointNodes:Ui(Bo.current?.scene),curve:"string"==typeof k?k:void 0,linkedCrosshairName:Ai,linkedCrosshairSourceId:_i})]})}return ho("div",{ref:Ii,className:"stream-xy-frame"+(K?" "+K:""),role:"group","aria-label":bi||("string"==typeof Ve?Ve:"XY chart"),tabIndex:0,style:{position:"relative",width:H?"100%":Xi[0],height:q?"100%":Xi[1],overflow:"visible",touchAction:fo(je)},onKeyDown:is,children:["production"!==process.env.NODE_ENV&&Bo.current&&co(kt,{store:Bo.current,diagnostics:Ro.current}),vi&&co(At,{tableId:Ji}),vi&&co(dt,{scene:Bo.current?.scene??[],chartType:s+" chart",tableId:Ji,chartTitle:"string"==typeof Ve?Ve:void 0}),co(wt,{summary:ki}),co(ft,{hoverPoint:Co}),ho("div",{role:"img","aria-label":bi||("string"==typeof Ve?Ve:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:ao?os:void 0,onMouseMove:ao?ss:void 0,onPointerLeave:ao?Jo:void 0,onMouseLeave:ao?Jo:void 0,onPointerDown:ao||Ti?ns:void 0,onClick:Ti?Zo:void 0,children:[co(pt,{size:Xi,margin:io,children:ko}),co(Bi,{width:oo,height:no,totalWidth:Xi[0],totalHeight:Xi[1],margin:io,scales:xo,showAxes:$t,axes:Ht,showGrid:Te,xFormat:as,yFormat:Jt||te,axisExtent:Qt}),co("canvas",{ref:Ho,"aria-label":Rt(Bo.current?.scene??[],s+" chart"),style:{position:"absolute",left:0,top:0}}),co("canvas",{ref:jo,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),co($i,{width:oo,height:no,totalWidth:Xi[0],totalHeight:Xi[1],margin:io,scales:xo,showAxes:$t,axes:Ht,xLabel:jt,yLabel:qt,yLabelRight:Ut,xFormat:as,yFormat:Jt||te,axisExtent:Qt,showGrid:Te,title:Ve,legend:Ne,legendHoverBehavior:Oe,legendClickBehavior:We,legendHighlightedCategory:De,legendIsolatedCategories:Ee,legendPosition:ze,legendLayout:Fe,foregroundGraphics:j(bo,gt(Bo.current?.customLayoutOverlays,Pi??null)),marginalGraphics:pi,xValues:Oo,yValues:Do,annotations:Me,onAnnotationActivate:Pe,onObservation:ke??be,chartId:we,chartType:"StreamXYFrame",autoPlaceAnnotations:Ye,svgAnnotationRules:Re,annotationFrame:po,xAccessor:fs,yAccessor:ps,annotationData:ys(Bo.current?.getData()),pointNodes:Ui(Bo.current?.scene),curve:"string"==typeof k?k:void 0,underlayRendered:!0,canvasObscuresUnderlay:!!X({background:J,hasBackgroundGraphics:!!Ie,themeBackground:Hi?.colors.background}),linkedCrosshairName:Ai,linkedCrosshairSourceId:_i}),(je||qe)&&co(Ce,{width:oo,height:no,totalWidth:Xi[0],totalHeight:Xi[1],margin:io,dimension:je?.dimension??"xy",scales:xo,onBrush:qe??(()=>{}),binSize:C,snap:je?.snap,binBoundaries:je?.binBoundaries??("bar"===s?Bo.current?.getBinBoundaries():void 0),snapDuring:je?.snapDuring,streaming:"streaming"===n}),Ze?.showBadge&&co($,{isStale:To,position:Ze.badgePosition}),us,cs]})]})}));po.displayName="StreamXYFrame";var yo=po;export{yo as StreamXYFrame_default};
|