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
|
@@ -1 +1 @@
|
|
|
1
|
-
import{buildCollisionSwarmPhysics as e,buildEventDropPhysics as t,buildGaltonBoardPhysics as o,buildPhysicalFlowPhysics as i,buildPhysicsPile as s,buildProcessFlowPhysics as r,generateGaltonMechanicalSamples as n,generatePhysicsPileMechanicalSamples as a,physicsBodiesToXYSceneNodes as c,renderPhysicsSettledSVG as l,resolveCustomLayout as h,styleFromColorAccessor as d}from"./chunk-chunk-2VUEY5TH.module.min.js";import{composeStyleRules as u,makeNodeRuleContext as g,styleRulesToNodeStyle as p,styleRulesToPieceStyle as f,styleRulesToXYStyle as y}from"./chunk-chunk-EMO5NUGE.module.min.js";import{PhysicsPipelineStore as m}from"./chunk-chunk-DNY43POY.module.min.js";import"./chunk-chunk-SIRIJ3DY.module.min.js";import{PipelineStore as x,attachUpdateResultStore as b,buildDatumIndexMap as A,buildRectNode as v,buildRibbonGeometry as S,compactTimestampBufferForRemoval as w,computeDecayOpacity as k,computePulseIntensity as _,createCustomLayoutFailureDiagnostic as M,createTimestampBufferForData as T,ensureRingBufferCapacity as P,getLayoutPlugin as R,hasActivePulses as z,pushWithTimestamp as L,renderSceneWithBackend as F,setPulseState as C,ticksForMode as B,toIdSet as D,warnCustomLayoutDiagnostics as E}from"./chunk-chunk-T27ZEV6A.module.min.js";import{IncrementalExtent as O,RingBuffer as j}from"./chunk-chunk-VVCA3DB7.module.min.js";import"./chunk-chunk-H4PPRW6N.module.min.js";import{AnnotationLabel as N,DEFAULT_COLOR as W,STREAMING_PALETTE as $,SemioticAnnotation as I,TITLE_BASELINE as G,applyAnnotationEmphasis as V,buildResolveColor as Y,computeEasing as H,computeRawProgress as X,createColorScale as q,filterSparseArray as Q,geoSceneNodeToSVG as Z,getColor as U,getSize as K,hasTextTitle as J,isGradientLegendConfig as ee,isLegendConfig as te,lerp as oe,networkLabelToSVG as ie,networkSceneEdgeToSVG as se,networkSceneNodeToSVG as re,now as ne,ordinalSceneNodeToSVG as ae,reserveTitleMargin as ce,resolveCustomLayoutPalette as le,resolveExplicitColor as he,xySceneNodeToSVG as de}from"./chunk-chunk-ES4DCG3L.module.min.js";import"./chunk-chunk-XEVJDUTH.module.min.js";import{accessorsEquivalent as ue,resolveAccessor as ge,resolveStringAccessor as pe,resolveSvgFill as fe}from"./chunk-chunk-2WVCH4PL.module.min.js";import{SYMBOL_SEQUENCE as ye,UpdateResultTracker as me,annotationLayout as xe,getSequentialInterpolator as be,interpolateViridis as Ae,schemeCategory10 as ve}from"./chunk-chunk-NO4MCQVD.module.min.js";import"./chunk-chunk-U66USBWU.module.min.js";import{getMax as Se,getMin as we,getMinMax as ke}from"./chunk-chunk-JJ2OOIET.module.min.js";import"./chunk-chunk-J3QOW4OE.module.min.js";import{DARK_THEME as _e,HIGH_CONTRAST_THEME as Me,LIGHT_THEME as Te,THEME_PRESETS as Pe,applyThemeAccessibility as Re,resolveThemeSemanticColors as ze}from"./chunk-chunk-DSNGDNJY.module.min.js";import*as Le from"react-dom/server";import*as Fe from"react";function Ce(e,t,o){return"function"==typeof e?e(o):o[e||t]}function Be(e){return e instanceof Date?e.getTime():Number(e)}function De(e,t){return Ae(1===t?.5:e/(t-1))}function Ee(e){return Math.max(0,Math.min(1,e))}function Oe(e){const t=e.trim();if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e.split("").map(e=>e+e).join("")),6===e.length&&/^[0-9a-f]{6}$/i.test(e))return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const o=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(o){const e=[Number(o[1]),Number(o[2]),Number(o[3])];if(e.every(Number.isFinite))return e}return null}function je(e,t,o){const i=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${i(e)}${i(t)}${i(o)}`}function Ne(e,t){const o=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Ee(e.offset),color:e.color})).sort((e,t)=>e.offset-t.offset);if(0===o.length)return"#999999";if(1===o.length)return o[0].color;const i=Ee(t);if(o[0].offset>=i)return o[0].color;if(i>=o[o.length-1].offset)return o[o.length-1].color;for(let e=0;o.length-1>e;e++){const t=o[e],s=o[e+1];if(t.offset>i||i>s.offset)continue;const r=s.offset-t.offset,n=r>0?(i-t.offset)/r:0,a=Oe(t.color),c=Oe(s.color);if(!a||!c)return.5>n?t.color:s.color;const[l,h,d]=a,[u,g,p]=c;return je(l+(u-l)*n,h+(g-h)*n,d+(p-d)*n)}return o[o.length-1].color}function We(e,t,o){return null==o?`${e}-${t}`:`${e}-${t}-${o}`}function $e(e){return!0===e?{topOpacity:.8,bottomOpacity:.05}:!1===e?void 0:e}import{scaleTime as Ie}from"d3-scale";function Ge(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:e.kind}function Ve(e,t,o){const i=t.incoming[e.id],s=t.outgoing[e.id],r=[];for(const e of i)r.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:o.get(e.id).targetSide});for(const e of s)r.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:o.get(e.id).sourceSide});const n={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{r.sort((e,t)=>e.time-t.time||(n[e.kind]??99)-(n[t.kind]??99))},c=r.length?we(r.map(e=>e.time)):null,l=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,h=null!=l?l-1:null!=c&&Number.isFinite(c)?c-1:null,d=[...new Set(r.map(e=>e.time))].sort((e,t)=>e-t),u=new Map;for(let e=1;d.length>e;e++)u.set(d[e],d[e-1]);const g=e=>{const t=u.get(e);return null!=t?(t+e)/2:null!=h?h:e};a();const p=[];let f=0,y=0;for(const e of r)if("out"===e.kind){const t=Math.abs(e.delta);let o=t-("top"===e.side?f:y);if(o>0){const t="top"===e.side?"bot":"top",i=Math.min(o,"top"===t?f:y);if(i>0){const s=g(e.time);p.push({time:s,delta:-i,kind:"transfer-out",side:t}),p.push({time:s,delta:+i,kind:"transfer-in",side:e.side}),"top"===t?f-=i:y-=i,"top"===e.side?f+=i:y+=i,o-=i}o>0&&null!==h&&(p.push({time:h,delta:+o,kind:"create",side:e.side}),"top"===e.side?f+=o:y+=o)}"top"===e.side?f-=t:y-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?f+=t:y+=t}r.push(...p),a();let m=0,x=0,b=0,A=0,v=0;const S=[],w=new Map;for(const e of r){if(S.push({t:e.time,topMass:m,botMass:x}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?m:x;w.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta)})}"top"===e.side?m+=e.delta:x+=e.delta,m+x>b&&(b=m+x),m>A&&(A=m),x>v&&(v=x),S.push({t:e.time,topMass:m,botMass:x})}const k=[];let _=0;for(;S.length>_;){let e=_;for(;S.length>e+1&&S[e+1].t===S[_].t;)e++;k.push(S[_]);for(let t=_+1;e>=t;t++){const e=k[k.length-1];S[t].topMass===e.topMass&&S[t].botMass===e.botMass||k.push(S[t])}_=e+1}const M=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let T=null;for(const e of s)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===T||T>e.systemInTime)&&(T=e.systemInTime);let P=null;for(const e of i)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===P||e.systemOutTime>P)&&(P=e.systemOutTime);if(k.length>0){const e=k[k.length-1],t=Math.max(null!=M?M:-1/0,null!=P?P:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&k.push({t:t,topMass:e.topMass,botMass:e.botMass});const o=k[0],i=Math.min(null!=l?l:1/0,null!=T?T:1/0);Number.isFinite(i)&&o.t>i&&o.topMass+o.botMass>0&&k.unshift({t:i,topMass:o.topMass,botMass:o.botMass})}return{samples:k,peak:b,topPeak:A,botPeak:v,localAttachments:w}}function Ye(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function He(e,t){return e.map(e=>({t:Ye(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function Xe(e,t,o){const i=e.value*o;if("out"===e.kind){const s=e.sideMassBefore*o;if("top"===e.side){const e=t-s;return[e,e+i]}const r=t+s;return[r-i,r]}const s=e.sideMassAfter*o;if("top"===e.side){const e=t-s;return[e,e+i]}const r=t+s;return[r-i,r]}function qe(e,t){let o=0;for(let i=0;t.length>i;i++)for(let s=i+1;t.length>s;s++){const r=t[i],n=t[s];r.source!==n.source&&r.target!==n.target&&r.source!==n.target&&r.target!==n.source&&(Math.min(r.endTime,n.endTime)>Math.max(r.startTime,n.startTime)&&e[n.source]>e[r.source]!=e[n.target]>e[r.target]&&o++)}return o}function Qe(e,t){let o=0;for(const i of t)o+=Math.abs(e[i.source]-e[i.target])*(i.value||1);return o}function Ze(e,t){return 1e3*qe(e,t)+Qe(e,t)}function Ue(e,t){return{slots:e.map(e=>({peak:{...e.peak},occupants:e.occupants.slice()})),map:{...t}}}function Ke(e,t,o){e.length>8||o.length>40?(function(e,t,o,i=6){const s=e.length;if(1>=s)return;let r=Ue(e,t),n=Ze(t,o);for(let a=0;i>a;a++){const i=Array(s).fill(0),a=Array(s).fill(0);for(const e of o){const o=t[e.source],s=t[e.target];i[o]+=s*(e.value||1),a[o]+=e.value||1,i[s]+=o*(e.value||1),a[s]+=e.value||1}const c=Array.from({length:s},(e,t)=>t).sort((e,t)=>(a[e]>0?i[e]/a[e]:e)-(a[t]>0?i[t]/a[t]:t)),l=c.map(t=>e[t]),h=new Map;c.forEach((e,t)=>h.set(e,t));for(const e of Object.keys(t))t[e]=h.get(t[e]);e.length=0;for(const t of l)e.push(t);const d=Ze(t,o);if(n>d)n=d,r=Ue(e,t);else if(d===n)break}!function(e,t,o){e.length=0;for(const t of o.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(o.map))t[e]=o.map[e]}(e,t,r)}(e,t,o,6),function(e,t,o,i=6){const s=e.length;if(1>=s)return;let r=Ze(t,o);for(let n=0;i>n;n++){let i=!1;for(let n=0;s-1>n;n++){const s=e[n];e[n]=e[n+1],e[n+1]=s;for(const e of Object.keys(t))t[e]===n?t[e]=n+1:t[e]===n+1&&(t[e]=n);const a=Ze(t,o);if(r>a)r=a,i=!0;else{const o=e[n];e[n]=e[n+1],e[n+1]=o;for(const e of Object.keys(t))t[e]===n?t[e]=n+1:t[e]===n+1&&(t[e]=n)}}if(!i)break}}(e,t,o,6)):function(e,t,o){const i=e.length;if(1>=i)return;const s={...t},r=Object.keys(s),n=Array.from({length:i},(e,t)=>t),a=n.slice(),c={...s};let l=n.slice(),h=1/0;const d=()=>{for(const e of r)c[e]=a[s[e]];const e=Ze(c,o);h>e&&(h=e,l=n.slice())},u=(e,t)=>{const o=n[e],i=n[t];n[e]=i,n[t]=o,a[o]=t,a[i]=e};d();const g=Array(i).fill(0);let p=0;for(;i>p;)p>g[p]?(u(p%2==0?0:g[p],p),d(),g[p]++,p=0):(g[p]=0,p++);const f=l.map(t=>e[t]),y=new Map;l.forEach((e,t)=>y.set(e,t));for(const e of Object.keys(t))t[e]=y.get(t[e]);e.length=0;for(const t of f)e.push(t)}(e,t,o)}function Je(e,t,o,i,s){const{plotH:r,padding:n,valueScale:a,packing:c,laneOrder:l,lifetimeMode:h="full"}=s,d={},u={};for(const t of e)d[t.id]=o[t.id].topPeak||0,u[t.id]=o[t.id].botPeak||0;const g="half"===h,p={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,o=Array.isArray(t.xExtent)?t.xExtent[1]:null;let s=null!=e&&Number.isFinite(e)?e:1/0,r=null!=o&&Number.isFinite(o)?o:-1/0;for(const e of i.outgoing[t.id]){s>e.startTime&&(s=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&s>e.systemInTime&&(s=e.systemInTime);const t=g?(e.startTime+e.endTime)/2:e.endTime;t>r&&(r=t)}for(const e of i.incoming[t.id]){const t=g?(e.startTime+e.endTime)/2:e.startTime;s>t&&(s=t),e.endTime>r&&(r=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>r&&(r=e.systemOutTime)}p[t.id]={start:Number.isFinite(s)?s:null,end:Number.isFinite(r)?r:null}}const f={},y=[];if("reuse"===c){const o=new Map;for(const t of e)o.set(t.id,0);const s=new Map;for(const t of e)s.set(t.id,0);for(const e of t)s.set(e.target,(s.get(e.target)??0)+1);const r=[];for(const t of e)0===(s.get(t.id)??0)&&r.push(t.id);for(;r.length;){const e=r.shift();for(const t of i.outgoing[e]??[]){const i=(o.get(e)??0)+1;i>(o.get(t.target)??0)&&o.set(t.target,i),s.set(t.target,s.get(t.target)-1),0===s.get(t.target)&&r.push(t.target)}}const n=[...e].filter(e=>null!==p[e.id].start).sort((e,t)=>{const i=o.get(e.id)??0,s=o.get(t.id)??0;return i!==s?i-s:p[e.id].start-p[t.id].start}),a=e.filter(e=>null===p[e.id].start);for(const e of[...n,...a]){const t=p[e.id];let o=-1;for(let e=0;y.length>e;e++){const i=y[e].occupants[y[e].occupants.length-1];if(null===t.start||void 0===i||t.start>=i.end){o=e;break}}-1===o&&(y.push({occupants:[],peak:{topPeak:0,botPeak:0}}),o=y.length-1),y[o].occupants.push({id:e.id,end:t?.end??-1/0}),y[o].peak.topPeak=Math.max(y[o].peak.topPeak,d[e.id]),y[o].peak.botPeak=Math.max(y[o].peak.botPeak,u[e.id]),f[e.id]=o}}else e.forEach((e,t)=>{y.push({occupants:[{id:e.id,end:p[e.id]?.end??-1/0}],peak:{topPeak:d[e.id],botPeak:u[e.id]}}),f[e.id]=t});let m=null,x=null,b=null,A=null;const v=()=>{m=qe(f,t),b=Qe(f,t)},S=()=>{x=qe(f,t),A=Qe(f,t)};"crossing-min"===l?(v(),Ke(y,f,t),S()):"inside-out"===l?(v(),function(e,t){const o=e.length;if(1>=o)return;const i=e=>e.peak.topPeak+e.peak.botPeak,s=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>i(t.slot)-i(e.slot)),r=Array(o),n=Math.floor((o-1)/2);r[n]=s[0].idx;let a=n-1,c=n+1;for(let e=1;s.length>e;e++)e%2==1&&o>c||0>a?r[c++]=s[e].idx:r[a--]=s[e].idx;const l=r.map(t=>e[t]),h=new Map;r.forEach((e,t)=>h.set(e,t));for(const e of Object.keys(t))t[e]=h.get(t[e]);e.length=0;for(const t of l)e.push(t)}(y,f),S()):"crossing-min+inside-out"===l&&(v(),Ke(y,f,t),function(e,t,o){const i=e.length;if(1>=i)return;const s=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),r=Math.floor((i-1)/2);let n=Ze(t,o);for(const{slot:a}of s){const s=e.indexOf(a);if(0>s)continue;const c=r;if(s===c)continue;const l=e[s];e.splice(s,1),e.splice(c,0,l);const h=new Map;for(let e=0;i>e;e++)h.set(e,e);if(c>s){for(let e=s+1;c>=e;e++)h.set(e,e-1);h.set(s,c)}else{for(let e=c;s>e;e++)h.set(e,e+1);h.set(s,c)}for(const e of Object.keys(t))t[e]=h.get(t[e]);const d=Ze(t,o);if(d>n){const o=e[c];e.splice(c,1),e.splice(s,0,o);const r=new Map;for(let e=0;i>e;e++)r.set(e,e);if(s>c){for(let e=c+1;s>=e;e++)r.set(e,e-1);r.set(c,s)}else{for(let e=s;c>e;e++)r.set(e,e+1);r.set(c,s)}for(const e of Object.keys(t))t[e]=r.get(t[e])}else n=d}}(y,f,t),S());const w=y.map(e=>{const t=new Map;for(const i of e.occupants){const e=o[i.id];if(e)for(const o of e.samples){const e=t.get(o.t)||{top:0,bot:0};t.set(o.t,{top:Math.max(e.top,o.topMass),bot:Math.max(e.bot,o.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),k=(e,t)=>{let o={top:0,bot:0};for(const[i,s]of e){if(i>t)break;o=s}return o},_=[];for(let e=0;y.length-1>e;e++){const t=w[e],o=w[e+1],i=new Set([...t.map(e=>e[0]),...o.map(e=>e[0])]);let s=0;for(const e of i){const i=k(t,e),r=k(o,e);i.bot+r.top>s&&(s=i.bot+r.top)}_.push(s)}const M=[];let T=n+(y[0]?.peak.topPeak??0)*a;y.length>0&&M.push(T);for(let e=1;y.length>e;e++)T+=_[e-1]*a+n,M.push(T);if(y.length>0&&(T+=y[y.length-1].peak.botPeak*a+n),T>r){const e=r/T;for(let t=0;M.length>t;t++)M[t]*=e}const P=0===y.length?0:y[0].peak.topPeak+_.reduce((e,t)=>e+t,0)+y[y.length-1].peak.botPeak,R={};for(const t of e)R[t.id]=M[f[t.id]];return{effectiveSlotsHeight:P,centerlines:R,laneLifetime:p,slots:y,slotByNode:f,slotCenter:M,crossingsBefore:m,crossingsAfter:x,lengthBefore:b,lengthAfter:A}}function et(e){const{nodes:t,edges:o,domain:i,plotW:s,plotH:r,ribbonLane:n,edgeOpacity:a,colorOf:c,layoutOpts:l}=e,h=function(e,t,o){const i=[],s=new Set(e.map(e=>e.id)),r=Array.isArray(o)&&2===o.length,n=r&&Number.isFinite(o[0])&&Number.isFinite(o[1]);r&&n&&n&&o[1]>=o[0]||i.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||i.push({kind:"invalid-node-time",id:t.id}));for(const e of t)s.has(e.source)||i.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),s.has(e.target)||i.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||i.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||i.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):i.push({kind:"invalid-edge-time",id:e.id});return i}(t,o,i),d=Ie().domain(i).range([0,s]);if(h.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:h,xScale:d};const u=function(e,t,o){const{plotH:i,pairing:s="temporal",packing:r="reuse",laneOrder:n="crossing-min",lifetimeMode:a="half"}=o,c=function(e,t){const o={},i={};for(const t of e)o[t.id]=[],i[t.id]=[];for(const e of t)i[e.source]&&i[e.source].push(e),o[e.target]&&o[e.target].push(e);return{incoming:o,outgoing:i}}(e,t),l=function(e,t,o,i="value"){const s="temporal"===i?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,r="temporal"===i?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,n=new Map;for(const e of t)n.set(e.id,{});const a=(e,t)=>{const o=new Map;for(const i of e){const e=i[t];o.has(e)||o.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const s=o.get(e);s.edges.push(i),s.total+=i.value,s.earliestStart=Math.min(s.earliestStart,i.startTime),s.latestEnd=Math.max(s.latestEnd,i.endTime)}const n=[...o.values()];n.sort("temporal"===i?(e,o)=>"target"===t?e.earliestStart-o.earliestStart:e.latestEnd-o.latestEnd:(e,t)=>t.total-e.total);for(const e of n)e.edges.sort("target"===t?r:s);return n};for(const t of e){const e=o.outgoing[t.id],i=o.incoming[t.id];if(0===i.length)a(e,"target").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)n.get(t.id).sourceSide=o});else if(0===e.length)a(i,"source").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)n.get(t.id).targetSide=o});else{const t=a(i,"source"),o=a(e,"target"),s=Math.max(t.length,o.length);for(let e=0;s>e;e++){const i=e%2==0?"top":"bot";if(t[e])for(const o of t[e].edges)n.get(o.id).targetSide=i;if(o[e])for(const t of o[e].edges)n.get(t.id).sourceSide=i}}}return n}(e,t,c,s);let h={};for(const t of e)h[t.id]=Ve(t,c,l);const d=Je(e,t,h,c,{plotH:i,padding:12,valueScale:1,packing:r,laneOrder:n,lifetimeMode:a}),u=new Set;for(const e of t){const t=d.slotByNode[e.source],o=d.slotByNode[e.target];if(void 0===t||void 0===o)continue;const i=l.get(e.id);t!==o?t>o?(i.sourceSide="top",i.targetSide="bot"):(i.sourceSide="bot",i.targetSide="top"):(u.add(e.id),i.sourceSide="bot",i.targetSide="bot")}for(const t of e){const e=c.outgoing[t.id],o=c.incoming[t.id],i=new Set(e.map(e=>l.get(e.id).sourceSide)),s=new Set(o.map(e=>l.get(e.id).targetSide));if(1===i.size&&o.length>0){const e=[...i][0];for(const t of o)d.slotByNode[t.source]===d.slotByNode[t.target]&&(l.get(t.id).targetSide=e)}if(1===s.size&&e.length>0){const t=[...s][0];for(const o of e)d.slotByNode[o.source]===d.slotByNode[o.target]&&(l.get(o.id).sourceSide=t)}}for(const t of e){const e=c.incoming[t.id],o=c.outgoing[t.id];if(0===e.length||0===o.length)continue;const i=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const o of e)"top"===l.get(o.id).targetSide?t.inTop+=o.value:t.inBot+=o.value;for(const e of o)"top"===l.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},s=(e,t)=>{const s=i(),r="top"===e?s.outTop-s.inTop:s.outBot-s.inBot,n="top"===t?s.inTop-s.outTop:s.inBot-s.outBot;if(0>=r||0>=n)return!1;const a=Math.min(r,n),c=o.filter(t=>!u.has(t.id)&&l.get(t.id).sourceSide===e&&a>=t.value).sort((e,t)=>t.value-e.value);return 0!==c.length&&(l.get(c[0].id).sourceSide=t,!0)};let r=o.length+1;for(;r-- >0&&(s("top","bot")||s("bot","top")););}h={};for(const t of e)h[t.id]=Ve(t,c,l);const g=Je(e,t,h,c,{plotH:i,padding:12,valueScale:1,packing:r,laneOrder:n,lifetimeMode:a}),p=g.effectiveSlotsHeight??g.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),f=Math.min(12,.35*i/Math.max(g.slots.length+1,1)),y=p>0?Math.max(0,(i-f*(g.slots.length+1))/p):1,m=Je(e,t,h,c,{plotH:i,padding:f,valueScale:y,packing:r,laneOrder:n,lifetimeMode:a});return{nodeData:h,sides:l,valueScale:y,padding:f,compressedPadding:12>f,centerlines:m.centerlines,laneLifetime:m.laneLifetime,slots:m.slots,slotByNode:m.slotByNode,crossingsBefore:m.crossingsBefore,crossingsAfter:m.crossingsAfter,lengthBefore:m.lengthBefore,lengthAfter:m.lengthAfter}}(t,o,{plotH:r,...l}),{centerlines:g,nodeData:p,valueScale:f}=u,y=[],m=[];t.forEach((e,t)=>{const s=p[e.id];if(!s||0===s.samples.length)return;const r=function(e,t,o,i,s){if(0===e.length)return null;const r=He(e,s),n=e=>t-r[e].topMass*o,a=e=>t+r[e].botMass*o;let c=`M${i(r[0].t)},${n(0)}`;for(let e=1;r.length>e;e++)c+=` L${i(r[e].t)},${n(e)}`;c+=` L${i(r[r.length-1].t)},${a(r.length-1)}`;for(let e=r.length-2;e>=0;e--)c+=` L${i(r[e].t)},${a(e)}`;return c+" Z"}(s.samples,g[e.id],f,d,i);if(!r)return;const n=He(s.samples,i),a=n.find(e=>e.topMass+e.botMass>0)||n[0],l=g[e.id]+(a.botMass-a.topMass)*f/2,h=c(e.id,t),m=function(e,t,o,i,s){const r=o.nodeData[e];if(!r||0===r.samples.length)return[];const n=o.valueScale,a=o.centerlines[e],c=He(r.samples,s),l=c.find(e=>e.topMass+e.botMass>0)||c[0],h=[...c].reverse().find(e=>e.topMass+e.botMass>0)||c[c.length-1],d=i(l.t),u=i(h.t),g=e=>i(Ye(e,s)),p=[],f=(e,t,o,i)=>`M${e},${t} L${o},${t} L${o},${i} L${e},${i} Z`;for(const o of t){if(o.source===e&&null!=o.systemInTime&&Number.isFinite(o.systemInTime)){const e=r.localAttachments.get(o.id);if(e&&"out"===e.kind&&o.startTime>o.systemInTime){const t=g(o.systemInTime),i=g(o.startTime),s=t-20,r=Math.max(d,s);if(i>r){const[o,c]=Xe(e,a,n);p.push({pathD:f(r,o,i,c),x0:s,x1:t,from:0,to:1})}}}if(o.target===e&&null!=o.systemOutTime&&Number.isFinite(o.systemOutTime)){const e=r.localAttachments.get(o.id);if(e&&"in"===e.kind&&o.systemOutTime>o.endTime){const t=g(o.systemOutTime),i=g(o.endTime),s=t+20,r=Math.min(u,s);if(r>i){const[o,c]=Xe(e,a,n);p.push({pathD:f(i,o,r,c),x0:t,x1:s,from:1,to:0})}}}}return p}(e.id,o,u,d,i);y.push({id:e.id,pathD:r,fill:h,stroke:h,strokeWidth:.5,...m.length>0&&{gradientStubs:m},rawDatum:e.__raw??e,labelX:d(a.t)-4,labelY:l,labelText:e.id})});const x=new Map;return t.forEach((e,t)=>x.set(e.id,t)),o.forEach(e=>{const t=p[e.source]?.localAttachments.get(e.id),o=p[e.target]?.localAttachments.get(e.id);if(!t||!o)return;const s=x.get(e.source)??0,r=c(e.source,s),l=function(e,t,o,i,s,r,n,a){const c=s,l=e=>a?Math.max(a[0],Math.min(a[1],e)):e,h=r(l(e.time)),d=r(l(o.time)),u=e.value*c,g=o.value*c,p=e.sideMassBefore*c,f=o.sideMassAfter*c;let y,m,x,b;"top"===e.side?(y=t-p,m=y+u):(m=t+p,y=m-u),"top"===o.side?(x=i-f,b=x+g):(b=i+f,x=b-g);const A="source"===n?h+.85*(d-h):"target"===n?h+.15*(d-h):(h+d)/2;return{sx:h,sTop:y,sBot:m,tx:d,tTop:x,tBot:b,cp1X:A,cp2X:A}}(t,g[e.source],o,g[e.target],f,d,n,i),{pathD:h,bezier:u}=S(l);m.push({id:e.id,pathD:h,fill:r,opacity:a,rawDatum:e.__raw??e,bezier:u})}),{layout:u,layoutConfig:{bands:y,ribbons:m,showLabels:!0},issues:[],xScale:d}}var tt=e=>{const{bands:t=[],ribbons:o=[],showLabels:i=!0}=e.config,s=[];for(const e of o)s.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}});for(const e of t)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const o=e.gradientStubs[t];s.push({type:"bezier",pathD:o.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:o.x0,x1:o.x1,from:o.from,to:o.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of t)s.push({type:"bezier",pathD:e.pathD,style:{...e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86},stroke:e.stroke??e.fill,strokeWidth:e.strokeWidth??.5},datum:{__kind:"band",data:e.rawDatum,id:e.id}});const r=i?t.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:s,labels:r}};import{scaleSequential as ot}from"d3-scale";function it(e){return e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e}function st(e){return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:28,y2:e.floorY,thickness:8}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:e.width-30,y2:76,thickness:8}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:e.floorY,x2:e.width-30,y2:e.floorY,thickness:8}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:e.width-30,y1:76,x2:e.width-30,y2:e.floorY,thickness:8}}]}function rt(e,t,o,i){return o?"function"==typeof o?o(e,t):e[o]??i:i}function nt(e){return`gauntlet:${e}:core`}function at(e,t){return`gauntlet:${e}:positive:${t}`}function ct(e,t,o){return`gauntlet:${e}:negative:${t}:${o}`}function lt(e,t,o,i){const s=Math.max(2,o+2),r=80+s,n=i.floorY-s;return{x:Math.max(32+s,Math.min(i.width-30-4-s,e)),y:Math.max(r,Math.min(n,t))}}function ht(e,t){const o=[...e].sort((e,t)=>e.localeCompare(t)),i=Math.max(0,o.indexOf(t));return{angle:.82*-Math.PI+(o.length>1?i/(o.length-1):.5)*Math.PI*.64,index:i,radius:48+i%2*6}}function dt(e,t,o){const i=e.activePositiveIds.reduce((e,o)=>e+(t.get(o)?.value??1),0),s=e.missingPositiveIds.length+e.poppedPositiveIds.length,r=e.negativeIds.reduce((e,t)=>e+(o.get(t)?.load??1),0);return Math.max(0,Math.min(100,75+3*i-8*r-1.2*e.delay-5*s))}function ut(e){const t=function(e,t,o){const[i,s]=e,r=Math.round(.48*s),n=s-36,a=(t??[]).filter(e=>!1!==e.enabled),c=Math.max(1,a.length),l=.22*i,h=c>1?(.78*i-l)/(c-1):0,d=Math.max(Math.round(.14*i),110);return{crashY:n-o,floorY:n,gates:a.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(l+t*h),width:e.width??Math.max(54,Math.round(.07*i))})),graveyardX:Math.round(.84*i),graveyardY:n-4,height:s,routeY:r,socketX:Math.round(.92*i),startX:d,width:i}}(e.size??[900,520],e.gates,e.crashOffset??30),o=e.positiveProperties??[],i=new Map(o.map(e=>[e.id,e])),s=new Map((e.negativeProperties??[]).map(e=>[e.id,e])),r={idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor},n=(e.data??[]).map((t,n)=>{const a=function(e,t,o,i,s){const r=rt(e,t,o.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",n=i.map(e=>e.id),a=[...rt(e,t,o.positiveAccessor,n)],c=[...rt(e,t,o.negativeAccessor,[])].filter(e=>s.has(e));return{id:r,activePositiveIds:a,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...rt(e,t,o.metricsAccessor,{})},missingPositiveIds:n.filter(e=>!a.includes(e)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(rt(e,t,o.startTimeAccessor,0))||0),stage:"project filed",viability:rt(e,t,o.initialViability,100)}}(t,n,r,o,s);return{...a,viability:e.viability?.(a,{negativeProperties:s,positiveProperties:i})??dt(a,i,s)}}),a=n.flatMap((o,r)=>{const n=function(e,t,o,i){const s=function(e){return{graveyardX:e.graveyardX,graveyardY:e.graveyardY,routeY:e.routeY,socketX:e.socketX,socketY:e.routeY-4,startX:e.startX,startY:e.routeY}}(o),r=i?.(e,t,o)??{};return{...s,...r,startY:r.startY??r.routeY??s.startY,socketY:r.socketY??r.routeY??s.socketY,graveyardY:r.graveyardY??s.graveyardY}}(o,r,t,e.projectPlacement);return function(e,t,o,i,s,r,n){const a=i.startX,c=i.startY+(i.startY===o.routeY?38*t:0),l=n?.(e,t,o,i)??{},h={__gauntlet:!0,kind:"gauntlet-core",projectId:e.id,sourceDatum:e.datum},d=[{...l,id:nt(e.id),x:l.x??a,y:l.y??c,vx:l.vx??42,vy:l.vy??0,mass:l.mass??7,bodyCollisions:l.bodyCollisions??!0,shape:l.shape??{type:"circle",radius:28},spawnAt:l.spawnAt??e.startedAt,datum:h}],u=lt(a,c,l.shape&&"radius"in l.shape&&Number(l.shape.radius)||28,o);d[0].x=u.x,d[0].y=u.y;for(const t of e.activePositiveIds){const i=s.get(t);if(!i)continue;const r=ht(e.activePositiveIds,t),n=i.radius??10,a=lt(u.x+Math.cos(r.angle)*r.radius,u.y+Math.sin(r.angle)*r.radius,n,o);d.push({id:at(e.id,t),x:a.x,y:a.y,vx:18*Math.cos(r.angle),vy:18*Math.sin(r.angle),mass:i.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:n},spawnAt:l.spawnAt??e.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:e.id,property:i,sourceDatum:e.datum},springs:!1===i.spring?[]:[{target:{type:"body",bodyId:nt(e.id)},stiffness:.56,damping:.9,restLength:52+r.index%2*4,...i.spring??{}}]})}return e.negativeIds.forEach((t,i)=>{const s=r.get(t);s&&d.push(function(e,t,o,i,s,r,n){const a=t.radius??7.2,c=lt(i-12+o%4*12,s+54+12*Math.floor(o/4),a,r);return{id:ct(e.id,t.id,o),x:c.x,y:c.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:a},spawnAt:n,datum:{__gauntlet:!0,kind:"gauntlet-negative",projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:nt(e.id)},stiffness:.62,damping:.92,restLength:52+o%4*3,...t.spring??{}}]}}(e,s,i,u.x,u.y,o,l.spawnAt??e.startedAt))}),d}(o,r,t,n,i,s,e.coreBody)});return{layout:t,initialSpawns:a,config:{fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7},colliders:st(t)}}}function gt(e){return e.map(e=>({...e,spawnAt:void 0}))}var pt={Sparkline:{frameType:"xy",buildProps:(e,t,o,i,s)=>({chartType:"line",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",groupAccessor:s.lineBy||t,colorAccessor:t,...i,showAxes:!1,margin:i.margin||{top:2,right:2,bottom:2,left:2},showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>({chartType:"line",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",groupAccessor:s.lineBy||t,colorAccessor:t,colorScheme:o,lineStyle:s.lineStyle,...i,...s.styleRules&&{lineStyle:y(s.styleRules,s.xAccessor||"x",s.yAccessor||"y",i.lineStyle||s.lineStyle)}})},AreaChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>({chartType:"area",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",y0Accessor:s.y0Accessor,groupAccessor:s.areaBy||t,colorAccessor:t,colorScheme:o,...i,...s.styleRules&&{lineStyle:y(s.styleRules,s.xAccessor||"x",s.yAccessor||"y",i.lineStyle)}})},DifferenceChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>{const r=s.xAccessor||"x",n=s.seriesAAccessor||"a",a=s.seriesBAccessor||"b",c=e=>Be(Ce(r,"x",e)),l=e=>Be(Ce(n,"a",e)),h=e=>Be(Ce(a,"b",e)),d=s.seriesAColor||"var(--semiotic-danger, #dc2626)",u=s.seriesBColor||"var(--semiotic-info, #2563eb)",g=s.areaOpacity??.6,p=s.lineWidth??1.5,f=!1!==s.showLines,y=function(e,t,o,i){if(!e.length)return[];const s=e.filter(e=>Number.isFinite(t(e))).sort((e,o)=>t(e)-t(o)),r=[];let n=0,a=null,c=null,l=[];const h=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${n}-${e}`,u=e=>r.push(e),g=(e,t)=>{u({__x:e.x,__y:e.y,__y0:e.y,__diffSegment:d(t),__diffWinner:t,__valA:e.y,__valB:e.y,__sourceDatum:e.datum})};for(let e=0;s.length>e;e++){const r=s[e],p=t(r),f=o(r),y=i(r);if(!Number.isFinite(p)||!Number.isFinite(f)||!Number.isFinite(y))continue;const m=h(f,y);if(null!==m)if(null!=a){if(c&&c.w!==m){let e,t;if(l.length>0)e=l[0].x,t=l[0].y;else{const o=f-c.a-(y-c.b);if(0!==o){const i=Math.max(0,Math.min(1,(c.b-c.a)/o));e=c.x+i*(p-c.x),t=c.a+i*(f-c.a)}else e=c.x,t=c.a}u({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t}),n++,a=m,u({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t});for(let e=1;l.length>e;e++)g(l[e],a)}else for(const e of l)g(e,a);l=[],u({__x:p,__y:y>f?y:f,__y0:y>f?f:y,__diffSegment:d(a),__diffWinner:a,__valA:f,__valB:y,__sourceDatum:r}),c={x:p,a:f,b:y,w:m}}else{a=m;for(const e of l)g(e,a);l=[],u({__x:p,__y:y>f?y:f,__y0:y>f?f:y,__diffSegment:d(a),__diffWinner:a,__valA:f,__valB:y,__sourceDatum:r}),c={x:p,a:f,b:y,w:m}}else l.push({x:p,y:f,datum:r})}for(const e of l)g(e,a??"A");return r}(Array.isArray(e)?e:[],c,l,h),m=[];if(f&&Array.isArray(e)){const t=e.filter(e=>Number.isFinite(c(e))).sort((e,t)=>c(e)-c(t));for(const e of t){const t=c(e),o=l(e),i=h(e);Number.isFinite(o)&&m.push({__x:t,__y:o,__diffSegment:"line-A"}),Number.isFinite(i)&&m.push({__x:t,__y:i,__diffSegment:"line-B"})}}return{chartType:"mixed",data:[...y,...m],xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:Array.from(new Set(y.map(e=>e.__diffSegment))),areaStyle:e=>{const t=e.__diffSegment;return{fill:"A"==(t?.endsWith("-A")?"A":"B")?d:u,stroke:"none",fillOpacity:g}},lineStyle:e=>({stroke:"A"==("line-A"===e.__diffSegment?"A":"B")?d:u,strokeWidth:p,fill:"none"}),curve:s.curve||"linear",...i}}},StackedAreaChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>{const r=t||s.areaBy,n="string"==typeof r&&Array.isArray(e)?q(e,r,o):void 0;return{chartType:"stackedarea",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",groupAccessor:s.areaBy,colorAccessor:r,colorScheme:o,normalize:s.normalize,stackOrder:s.stackOrder,lineStyle:null==s.areaOpacity?void 0:e=>{const t=null==r?void 0:U(e,r,n),o=s.showLine??!0;return{fill:s.color??t,stroke:o?s.stroke??t:"none",...o?{strokeWidth:s.strokeWidth??s.lineWidth??2}:{},fillOpacity:s.areaOpacity,...null==s.opacity?{}:{opacity:s.opacity}}},...i}}},Scatterplot:{frameType:"xy",buildProps:(e,t,o,i,s)=>({chartType:"scatter",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",colorAccessor:t,sizeAccessor:s.sizeBy,...s.symbolBy&&{symbolAccessor:s.symbolBy},...s.symbolMap&&{symbolMap:s.symbolMap},colorScheme:o,...i,...s.styleRules&&{pointStyle:y(s.styleRules,s.xAccessor||"x",s.yAccessor||"y",i.pointStyle)}})},CandlestickChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>({chartType:"candlestick",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.highAccessor||"high",highAccessor:s.highAccessor||"high",lowAccessor:s.lowAccessor||"low",openAccessor:s.openAccessor,closeAccessor:s.closeAccessor,candlestickStyle:s.candlestickStyle,...i})},BubbleChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>({chartType:"scatter",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",colorAccessor:t,sizeAccessor:s.sizeBy,sizeRange:s.sizeRange||[5,40],colorScheme:o,...i})},ConnectedScatterplot:{frameType:"xy",buildProps:(e,t,o,i,s)=>{const r=function(e,t){if(!Array.isArray(e))return{data:e,orderMap:new WeakMap};const o=t.xAccessor||"x",i=t.yAccessor||"y",s=t.orderAccessor?[...e].sort((e,o)=>null==e||"object"!=typeof e?1:null==o||"object"!=typeof o?-1:Be(Ce(t.orderAccessor,"order",e))-Be(Ce(t.orderAccessor,"order",o))):e,r=new WeakMap;let n=0;for(const e of s){if(null==e||"object"!=typeof e)continue;const t=Be(Ce(o,"x",e)),s=Be(Ce(i,"y",e));Number.isFinite(t)&&Number.isFinite(s)&&n++}let a=0;for(const e of s){if(null==e||"object"!=typeof e)continue;const t=Be(Ce(o,"x",e)),s=Be(Ce(i,"y",e));Number.isFinite(t)&&Number.isFinite(s)&&r.set(e,{idx:a++,total:n})}return{data:s,orderMap:r}}(e,s),n=s.pointRadius??4;return{chartType:"line",data:r.data,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",colorAccessor:t,colorScheme:o,lineStyle:s.lineStyle||{stroke:s.stroke||"#6366f1",strokeWidth:s.strokeWidth??n,opacity:s.opacity},pointStyle:e=>{const t=r.orderMap.get(e),o=t?.idx??0,i=t?.total??1;return{fill:i>0?De(o,i):"#6366f1",stroke:"white",strokeWidth:1,r:n,fillOpacity:1}},...i}}},QuadrantChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>{const r=s.xCenter,n=s.yCenter,a=s.quadrants,c=s.centerlineStyle||{},l=!1!==s.showQuadrantLabels,h=s.quadrantLabelSize??12,d=c.stroke||"#999",u=c.strokeWidth??1,g=Array.isArray(c.strokeDasharray)?c.strokeDasharray.join(","):c.strokeDasharray,p=Fe.createElement,f=a?[(e,t,o)=>{if(!t?.x||!t?.y)return null;const i=o.width,s=o.height,c=null!=r?t.x(r):i/2,f=null!=n?t.y(n):s/2;if(null!=r&&!Number.isFinite(c))return null;if(null!=n&&!Number.isFinite(f))return null;const y=Math.max(0,Math.min(i,c)),m=Math.max(0,Math.min(s,f)),x=[{c:a.topLeft,x:0,y:0,w:y,h:m},{c:a.topRight,x:y,y:0,w:i-y,h:m},{c:a.bottomLeft,x:0,y:m,w:y,h:s-m},{c:a.bottomRight,x:y,y:m,w:i-y,h:s-m}],b=l?[p("text",{key:"ltl",x:8,y:8+h,fill:a.topLeft.color,fontWeight:600,fontSize:h,opacity:.5},a.topLeft.label),p("text",{key:"ltr",x:i-8,y:8+h,fill:a.topRight.color,fontWeight:600,fontSize:h,opacity:.5,textAnchor:"end"},a.topRight.label),p("text",{key:"lbl",x:8,y:s-8,fill:a.bottomLeft.color,fontWeight:600,fontSize:h,opacity:.5},a.bottomLeft.label),p("text",{key:"lbr",x:i-8,y:s-8,fill:a.bottomRight.color,fontWeight:600,fontSize:h,opacity:.5,textAnchor:"end"},a.bottomRight.label)]:[];return p(Fe.Fragment,null,...x.map((e,t)=>e.w>0&&e.h>0?p("rect",{key:"qf-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.c.color,opacity:e.c.opacity??.08}):null),p("line",{key:"vc",x1:y,y1:0,x2:y,y2:s,stroke:d,strokeWidth:u,strokeDasharray:g}),p("line",{key:"hc",x1:0,y1:m,x2:i,y2:m,stroke:d,strokeWidth:u,strokeDasharray:g}),...b)}]:void 0;return{chartType:"scatter",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",colorAccessor:t,sizeAccessor:s.sizeBy,sizeRange:s.sizeRange,colorScheme:o,pointStyle:s.pointStyle,...i,...f&&{svgPreRenderers:f}}}},Heatmap:{frameType:"xy",buildProps:(e,t,o,i,s)=>({chartType:"heatmap",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",valueAccessor:s.valueAccessor,colorScheme:o||s.colorScheme||"blues",showValues:s.showValues,cellBorderColor:s.cellBorderColor,...i})},XYCustomChart:{frameType:"xy",buildProps:(e,t,o,i,s)=>({chartType:"custom",data:e,xAccessor:s.xAccessor||"x",yAccessor:s.yAccessor||"y",colorAccessor:t,colorScheme:o,customLayout:s.layout||s.customLayout,layoutConfig:s.layoutConfig,...i,showAxes:i.showAxes??!1})},BarChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"bar",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",projection:"horizontal"===s.orientation?"horizontal":"vertical",oSort:s.sort??!1,colorAccessor:t,colorScheme:o,barPadding:s.barPadding,...null!=s.roundedTop&&{roundedTop:s.roundedTop},...i,gradientFill:$e(i.gradientFill),...s.styleRules&&{pieceStyle:f(s.styleRules,s.valueAccessor||"value",i.pieceStyle)}})},StackedBarChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"bar",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",stackBy:s.stackBy,colorAccessor:t||s.stackBy,colorScheme:o,projection:"horizontal"===s.orientation?"horizontal":"vertical",normalize:s.normalize,oSort:s.sort??!1,barPadding:s.barPadding,...null!=s.roundedTop&&{roundedTop:s.roundedTop},...i,gradientFill:$e(i.gradientFill),...s.styleRules&&{pieceStyle:f(s.styleRules,s.valueAccessor||"value",i.pieceStyle)}})},GroupedBarChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"clusterbar",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",groupBy:s.groupBy,colorAccessor:t||s.groupBy,colorScheme:o,projection:"horizontal"===s.orientation?"horizontal":"vertical",oSort:s.sort??!1,barPadding:s.barPadding,...null!=s.roundedTop&&{roundedTop:s.roundedTop},...i,gradientFill:$e(i.gradientFill),...s.styleRules&&{pieceStyle:f(s.styleRules,s.valueAccessor||"value",i.pieceStyle)}})},PieChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"pie",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",projection:"radial",colorAccessor:t||s.categoryAccessor,colorScheme:o,...null!=s.cornerRadius&&{cornerRadius:s.cornerRadius},...i})},DonutChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"donut",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",projection:"radial",innerRadius:s.innerRadius||60,colorAccessor:t||s.categoryAccessor,colorScheme:o,...null!=s.cornerRadius&&{cornerRadius:s.cornerRadius},...i})},Histogram:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"histogram",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",projection:"horizontal",bins:s.bins,colorAccessor:t,colorScheme:o,...i})},BoxPlot:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"boxplot",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",colorScheme:o,...i})},ViolinPlot:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"violin",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",bins:s.bins,colorScheme:o,...i})},SwarmPlot:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"swarm",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",colorAccessor:t,...s.symbolBy&&{symbolAccessor:s.symbolBy},...s.symbolMap&&{symbolMap:s.symbolMap},colorScheme:o,...i})},DotPlot:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"point",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",colorAccessor:t,colorScheme:o,...i,showGrid:i.showGrid??!0})},SwimlaneChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"swimlane",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",stackBy:s.subcategoryAccessor,colorAccessor:t||s.subcategoryAccessor,categoryAccessor:s.categoryAccessor,subcategoryAccessor:s.subcategoryAccessor,colorScheme:o,projection:"horizontal"===s.orientation?"horizontal":"vertical",...null!=s.trackFill&&{trackFill:s.trackFill},...i,gradientFill:$e(i.gradientFill)})},RidgelinePlot:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"ridgeline",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",bins:s.bins,amplitude:s.amplitude,...i})},LikertChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"bar",data:e,oAccessor:s.categoryAccessor||"category",rAccessor:s.valueAccessor||"value",stackBy:s.levelAccessor||"level",colorAccessor:t||s.levelAccessor||"level",colorScheme:o,normalize:!0,projection:"vertical"===s.orientation?"vertical":"horizontal",...i})},FunnelChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>{const r="vertical"===s.orientation;return{chartType:r?"bar-funnel":"funnel",data:e,oAccessor:s.stepAccessor||"step",rAccessor:s.valueAccessor||"value",colorAccessor:t||s.categoryAccessor,categoryAccessor:s.categoryAccessor,projection:r?"vertical":"horizontal",connectorAccessor:s.connectorAccessor,connectorStyle:s.connectorStyle,...!r&&null!=s.connectorOpacity&&{connectorOpacity:s.connectorOpacity},barPadding:r?40:0,showAxes:r,showGrid:r,colorScheme:o,...i}}},GaugeChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>{const r=s.min??0,n=s.max??100,a=s.sweep??240,c=s.arcWidth??.3,l=180+(360-a)/2,h=s.thresholds||[{value:n,color:s.color||"#4e79a7"}],d=i.gradientFill,u=function(e){const{min:t,max:o,value:i,thresholds:s,fillColor:r,backgroundColor:n,fillZones:a,showScaleLabels:c,gradientFill:l,gradientSteps:h=240}=e,d=o-t||1,u=(Math.max(t,Math.min(o,i))-t)/d;let g=s&&s.length>0?[...s].sort((e,t)=>e.value-t.value):[{value:o,color:r||"#007bff"}];g=g.map(e=>({...e,value:Math.max(t,Math.min(o,e.value))})),o>g[g.length-1].value&&g.push({value:o,color:g[g.length-1].color});const p=!!l&&l.colorStops.length>=2,f=[],y=new Map,m=[];if(p){const e=a?u:1,t=We("bg",0);if(f.push({category:t,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),y.set(t,{fill:n,opacity:.4}),e>0){const t=Math.max(1,Math.floor(h)),o=Math.max(1,Math.min(t,Math.round(e*t))),i=[];for(let t=0;o>t;t++)i.push(Ne(l.colorStops,e*(t+.5)/o));const s=We("fill",0);f.push({category:s,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:i}}),y.set(s,{fill:i[0]||n})}}else{let e=t;for(let o=0;g.length>o;o++){const i=g[o],s=(i.value-e)/d,r=(e-t)/d,c=(i.value-t)/d,l=Math.max(0,(a?Math.min(u,c):c)-r),h=a?Math.max(0,s-l):0;if(l>0){const e=We("fill",o);f.push({category:e,value:l,_zone:i.label||"Zone "+(o+1),_isFill:!0}),y.set(e,{fill:i.color})}if(h>0){const e=We("bg",o);f.push({category:e,value:h,_zone:i.label||"Zone "+(o+1),_isFill:!1}),y.set(e,{fill:n,opacity:.4})}e=i.value}}if(c&&s&&s.length>0)for(const e of s)e.value>t&&o>e.value&&m.push({type:"gauge-label",value:e.value,label:e.label||e.value+""});return{gaugeData:f,pieceStyle:(e,t)=>y.get(t||e.category)||{fill:n},gaugeAnnotations:m}}({min:r,max:n,value:s.value,thresholds:h,fillColor:s.color,backgroundColor:s.backgroundColor||"#e0e0e0",fillZones:!1!==s.fillZones,showScaleLabels:!1!==s.showScaleLabels,gradientFill:d&&"object"==typeof d&&"colorStops"in d?d:void 0}),g=i.margin||{top:20,right:20,bottom:30,left:40},[p,f]=i.size||[300,300];return{chartType:"donut",data:u.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:Math.max(10,Math.min(p-(g.left||0)-(g.right||0),f-(g.top||0)-(g.bottom||0))/2*(1-c)),sweepAngle:a,startAngle:l,oSort:!1,pieceStyle:u.pieceStyle,...null!=s.cornerRadius&&{cornerRadius:s.cornerRadius},...i,showAxes:!1,annotations:[...Array.isArray(i.annotations)?i.annotations:[],...u.gaugeAnnotations],__gauge:{gMin:r,gMax:n,sweep:a,arcWidth:c,value:s.value,startAngleDeg:l,thresholds:h}}}},OrdinalCustomChart:{frameType:"ordinal",buildProps:(e,t,o,i,s)=>({chartType:"custom",data:e,oAccessor:s.categoryAccessor||s.oAccessor||"category",rAccessor:s.valueAccessor||s.rAccessor||"value",projection:s.projection||"vertical",colorAccessor:t,colorScheme:o,customLayout:s.layout||s.customLayout,layoutConfig:s.layoutConfig,...i,showAxes:i.showAxes??!1})},ForceDirectedGraph:{frameType:"network",buildProps:(e,t,o,i,s)=>{const{edgeWidth:r,edgeColor:n,edgeOpacity:a}=s,c=s.edgeStyle??(void 0!==r||void 0!==n||void 0!==a?e=>{const t=e?.data||e;let o=1;if("number"==typeof r)o=r;else if("function"==typeof r)o=r(t);else if("string"==typeof r){const e=t?.[r],i="number"==typeof e?e:Number(e);o=Number.isFinite(i)&&i>0?i:1}return{stroke:n??"#999",strokeWidth:o,opacity:a??.6}}:void 0);return{chartType:"force",nodes:s.nodes,edges:s.edges,nodeIDAccessor:s.nodeIdAccessor||s.nodeIDAccessor,sourceAccessor:s.sourceAccessor,targetAccessor:s.targetAccessor,colorBy:t,colorScheme:o,iterations:s.iterations,forceStrength:s.forceStrength,showLabels:s.showLabels,nodeLabel:s.nodeLabel,nodeSize:s.nodeSize,nodeSizeRange:s.nodeSizeRange,nodeStyle:p(s.styleRules,t,"number"==typeof s.nodeSize?void 0:s.nodeSize,s.nodeStyle)??s.nodeStyle,edgeStyle:c,...i}}},NetworkCustomChart:{frameType:"network",buildProps:(e,t,o,i,s)=>({chartType:"force",nodes:s.nodes||e||[],edges:s.edges||[],nodeIDAccessor:s.nodeIdAccessor||s.nodeIDAccessor||"id",sourceAccessor:s.sourceAccessor||"source",targetAccessor:s.targetAccessor||"target",valueAccessor:s.valueAccessor||"value",colorBy:t,colorScheme:o,customNetworkLayout:s.layout||s.customNetworkLayout,layoutConfig:s.layoutConfig,...i})},SankeyDiagram:{frameType:"network",buildProps:(e,t,o,i,s)=>({chartType:"sankey",nodes:s.nodes,edges:s.edges,nodeIDAccessor:s.nodeIdAccessor||s.nodeIDAccessor,sourceAccessor:s.sourceAccessor,targetAccessor:s.targetAccessor,valueAccessor:s.valueAccessor,orientation:s.orientation,nodeAlign:s.nodeAlign,nodeWidth:s.nodeWidth,nodePaddingRatio:s.nodePaddingRatio,showLabels:s.showLabels,nodeLabel:s.nodeLabel,colorBy:t,edgeColorBy:s.edgeColorBy,edgeOpacity:s.edgeOpacity,nodeStyle:s.nodeStyle,edgeStyle:s.edgeStyle,colorScheme:o,...i})},ProcessSankey:{frameType:"network",buildProps:(e,t,o,i,s)=>{const r=e=>null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime(),n=s.sourceAccessor||"source",a=s.targetAccessor||"target",c=s.valueAccessor||"value",l=s.nodeIdAccessor||"id",h=s.startTimeAccessor||"startTime",d=s.endTimeAccessor||"endTime",u=s.systemInTimeAccessor,g=s.systemOutTimeAccessor,p=s.xExtentAccessor||"xExtent",f=s.edgeIdAccessor||"id",y=(e,t)=>"function"==typeof e?e(t):t[e],m=Array.isArray(s.edges)?s.edges:[],x=Array.isArray(s.nodes)?s.nodes:[],b=x.length>0?x:function(e,t,o,i){const s=new Set;return t.forEach(e=>{const t="function"==typeof o?o(e):e[o],r="function"==typeof i?i(e):e[i];s.add(t),s.add(r)}),Array.from(s).map(e=>({id:e}))}(0,m,n,a),A=[r(s.domain?.[0]),r(s.domain?.[1])],v=b.map(e=>{const t=y(l,e)+"",o=y(p,e),i={id:t,__raw:e};if(Array.isArray(o)&&2===o.length){const e=r(o[0]),t=r(o[1]);Number.isFinite(e)&&Number.isFinite(t)&&(i.xExtent=[e,t])}return i}),S=m.map((e,t)=>{const o=y(f,e),i={id:null!=o?o+"":`${y(n,e)}-${y(a,e)}-${t}`,source:y(n,e)+"",target:y(a,e)+"",value:Number(y(c,e)),startTime:r(y(h,e)),endTime:r(y(d,e)),__raw:e};if(u){const t=r(y(u,e));Number.isFinite(t)&&(i.systemInTime=t)}if(g){const t=r(y(g,e));Number.isFinite(t)&&(i.systemOutTime=t)}return i}),[w,k]=i.size??[600,400],_={top:20,right:20,bottom:20,left:20,...i.margin},M=i.legendPosition??"right";i.showLegend&&("right"===M?_.right=Math.max(_.right,100):"left"===M?_.left=Math.max(_.left,100):"bottom"===M?_.bottom=Math.max(_.bottom,70):"top"===M&&(_.top=Math.max(_.top,40)));const T=_,P=w-T.left-T.right,R=k-T.top-T.bottom,z=Array.isArray(o)?o:null,L=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],F="function"==typeof t?t:null,C=F?b.map(e=>({_cat:F(e)})):b,B=F?"_cat":"string"==typeof t?t:void 0,D=B?q(C,B,o):null,E=new Map;for(const e of v)E.set(e.id,e.__raw);const{layoutConfig:O,issues:j}=et({nodes:v,edges:S,domain:A,plotW:P,plotH:R,ribbonLane:s.ribbonLane||"both",edgeOpacity:"number"==typeof s.edgeOpacity?s.edgeOpacity:.35,colorOf:(e,o)=>{if(t&&E.has(e)){const o=E.get(e);return F?U({_cat:F(o)},"_cat",D??void 0):U(o,"string"==typeof t?t:"id",D??void 0)}const i=z||L;return i[o%i.length]},layoutOpts:{pairing:s.pairing||"temporal",packing:s.packing||"reuse",laneOrder:s.laneOrder||"crossing-min",lifetimeMode:s.lifetimeMode||"half"}});if(j.length>0){const e=j.map(Ge).join("; ");throw Error("ProcessSankey: data invalid — "+e)}return{chartType:"force",nodes:b,edges:m,customNetworkLayout:tt,layoutConfig:O,sourceAccessor:n,targetAccessor:a,valueAccessor:c,nodeIDAccessor:l,colorBy:t,colorScheme:o,...i,margin:T}}},ChordDiagram:{frameType:"network",buildProps:(e,t,o,i,s)=>({chartType:"chord",nodes:s.nodes,edges:s.edges,valueAccessor:s.valueAccessor,padAngle:s.padAngle,groupWidth:s.groupWidth,showLabels:s.showLabels,colorBy:t,edgeColorBy:s.edgeColorBy,colorScheme:o,...i})},TreeDiagram:{frameType:"network",buildProps:(e,t,o,i,s)=>({chartType:"cluster"===s.layout?"cluster":"tree",data:e,childrenAccessor:s.childrenAccessor,colorBy:t,colorByDepth:s.colorByDepth,orientation:s.orientation,showLabels:s.showLabels,colorScheme:o,...i})},Treemap:{frameType:"network",buildProps:(e,t,o,i,s)=>({chartType:"treemap",data:e,childrenAccessor:s.childrenAccessor,hierarchySum:s.valueAccessor,colorBy:t,colorByDepth:s.colorByDepth,showLabels:s.showLabels,colorScheme:o,...i})},CirclePack:{frameType:"network",buildProps:(e,t,o,i,s)=>({chartType:"circlepack",data:e,childrenAccessor:s.childrenAccessor,hierarchySum:s.valueAccessor,colorBy:t,colorByDepth:s.colorByDepth,colorScheme:o,...i})},ChoroplethMap:{frameType:"geo",buildProps:(e,t,o,i,s)=>{const r="string"==typeof o?o:"blues",n=s.areaStyle??function(e,t,o,i){if(!Array.isArray(e))return;const s=e=>"function"==typeof t?t(e):null!=t?e?.properties?.[t]??e?.[t]:void 0;let r=1/0,n=-1/0;for(const t of e){const e=s(t);null!=e&&isFinite(e)&&(r>e&&(r=e),e>n&&(n=e))}const a=ot(be(o)).domain([Number.isFinite(r)?r:0,Number.isFinite(n)?n:1]);return e=>{const t=s(e);return{fill:null!=t&&isFinite(t)?a(t):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:i}}}(s.areas,s.valueAccessor,r,s.areaOpacity??1),a=s.styleRules?u(n,s.styleRules,e=>{return{value:(t=e,"function"==typeof s.valueAccessor?s.valueAccessor(t):null!=s.valueAccessor?t?.properties?.[s.valueAccessor]??t?.[s.valueAccessor]:void 0)};var t},it):n;return{areas:s.areas,projection:s.projection||"equalEarth",areaStyle:a,valueAccessor:s.valueAccessor,colorScheme:r,graticule:s.graticule,fitPadding:s.fitPadding,...i}}},ProportionalSymbolMap:{frameType:"geo",buildProps:(e,t,o,i,s)=>{const r=e||s.points,n=s.pointStyle??function(e,t,o,i){const s=Array.isArray(e)?e:[];let r,n;if(t){const e="string"==typeof t?t:"__geoColorBy",i="string"==typeof t?s:s.map(e=>({...e,__geoColorBy:t(e)}));r=q(i,e,o)}if(i.sizeBy){const e=s.map("function"==typeof i.sizeBy?i.sizeBy:e=>e?.[i.sizeBy]).filter(e=>null!=e&&isFinite(e));e.length>0&&(n=ke(e))}return e=>({fill:t&&r?U(e,t,r):W,fillOpacity:i.fillOpacity,stroke:"#fff",strokeWidth:i.strokeWidth,r:i.sizeBy?K(e,i.sizeBy,i.sizeRange,n):i.pointRadius??6})}(r,t,o,{sizeBy:s.sizeBy,sizeRange:s.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),a=s.styleRules?u(n,s.styleRules,g(t,s.sizeBy)):n;return{points:r,xAccessor:s.xAccessor||"lon",yAccessor:s.yAccessor||"lat",areas:s.areas,areaStyle:s.areaStyle,pointStyle:a,sizeBy:s.sizeBy,colorBy:t,colorScheme:o,projection:s.projection||"equalEarth",graticule:s.graticule,fitPadding:s.fitPadding,...i}}},FlowMap:{frameType:"geo",buildProps:(e,t,o,i,s)=>{const r=(Array.isArray(e)?e:null)||s.flows||[],n=s.nodeIdAccessor||"id",a=s.valueAccessor||"value",c=s.xAccessor||"lon",l=s.yAccessor||"lat",h="function"==typeof c?c:e=>e[c],d="function"==typeof l?l:e=>e[l],u=(s.nodes||[]).map(e=>({...e,x:h(e),y:d(e)})),g=new Map;for(const e of u)g.set(e[n]+"",e);const p=s.edgeColorBy??t,f="function"==typeof p,y=r.map(e=>{if(!e||null==e.source||null==e.target)return null;const t=g.get(e.source+""),o=g.get(e.target+"");return t&&o?{...e,coordinates:[{x:t.x,y:t.y},{x:o.x,y:o.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=(()=>{if(!p)return null;if(f){const e=y.map(e=>({[m]:p(e)}));return q(e,m,o||"category10")}return q(y,p,o||"category10")})(),b=e=>p&&x?U(e,p,x):"#007bff";let A=1/0,v=-1/0;for(const e of y){const t=Number(e[a]??0);isFinite(t)&&(A>t&&(A=t),t>v&&(v=t))}const S=v>A?v-A:0,[w,k]=s.edgeWidthRange??[1,8],_=k-w,M=s.edgeOpacity??.6,T=s.edgeLinecap??"round";return{lines:y,points:u,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:s.lineType||"geo",flowStyle:s.flowStyle||"basic",areas:s.areas,areaStyle:s.areaStyle,projection:s.projection||"equalEarth",graticule:s.graticule,fitPadding:s.fitPadding,colorScheme:o,lineStyle:e=>{const t=Number(e?.[a]),o=Number.isFinite(t)?t:A,i=w+Math.max(0,Math.min(1,S>0?(o-A)/S:0))*_;return{stroke:b(e),strokeWidth:i,strokeLinecap:T,opacity:M,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...i}}},GeoCustomChart:{frameType:"geo",buildProps:(e,t,o,i,s)=>({points:s.points||e||[],areas:s.areas||[],lines:s.lines||[],projection:s.projection||"equirectangular",xAccessor:s.xAccessor||"lon",yAccessor:s.yAccessor||"lat",lineDataAccessor:s.lineDataAccessor,colorBy:t,colorScheme:o,customLayout:s.layout||s.customLayout,layoutConfig:s.layoutConfig,...i})},GaltonBoardChart:{frameType:"physics",buildProps:(e,t,i,s,r)=>{const a=s.size??[600,400],c=r.bins??21,l=r.seed??1,h=Math.max(1,Math.round(r.pegRows??c-1)),u="mechanical"===r.mode,g=u?n({bins:c,branchProbability:r.branchProbability,count:r.mechanicalCount,pegRows:h,seed:l}):Array.isArray(e)?e:[],p=o({data:g,valueAccessor:r.valueAccessor||"value",bins:c,ballRadius:r.ballRadius??4,seed:l,size:a,valueExtent:u?[0,h]:void 0});return{...s,config:p.config,initialSpawns:gt(p.initialSpawns),projectionRows:p.projectionRows,bodyStyle:d(t||r.colorBy||(u?"side":void 0),"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.valueAccessor||"value"})}}},EventDropChart:{frameType:"physics",buildProps:(e,o,i,s,r)=>{const n=s.size??[600,400],a=t({data:Array.isArray(e)?e:[],timeAccessor:r.timeAccessor||"time",arrivalAccessor:r.arrivalAccessor||"arrivalTime",windows:r.windows||{size:10},watermark:r.watermark,ballRadius:r.ballRadius??5,seed:r.seed??1,size:n,timeExtent:r.timeExtent,timeScale:r.timeScale??1});return{...s,config:a.config,initialSpawns:gt(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:d(o||r.colorBy,"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.valueAccessor||r.timeAccessor||"time"})}}},PhysicsPileChart:{frameType:"physics",buildProps:(e,t,o,i,r)=>{const n=i.size??[600,400],c="mechanical"===r.mode,l=c?a({categories:r.mechanicalCategories,count:r.mechanicalCount,seed:r.seed??1,unitValue:r.unitValue??1}):Array.isArray(e)?e:[],h=s({data:l,categoryAccessor:r.categoryAccessor||"category",valueAccessor:r.valueAccessor||(c?"value":void 0),unitValue:r.unitValue??1,ballRadius:r.ballRadius??5,seed:r.seed??1,size:n});return{...i,config:h.config,initialSpawns:gt(h.initialSpawns),projectionRows:h.projectionRows,bodyStyle:d(t||r.colorBy||(c?"category":void 0),"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.valueAccessor||"value"})}}},CollisionSwarmChart:{frameType:"physics",buildProps:(t,o,i,s,r)=>{const n=s.size??[600,360],a=e({data:Array.isArray(t)?t:[],xAccessor:r.xAccessor||"x",groupAccessor:r.groupAccessor,radiusAccessor:r.radiusAccessor,pointRadius:r.pointRadius??5,seed:r.seed??1,size:n,xExtent:r.xExtent,collisionIterations:r.collisionIterations,settle:r.settle});return{...s,config:a.config,initialSpawns:gt(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:d(o||r.colorBy||r.groupAccessor,"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.xAccessor||"x"})}}},ProcessFlowChart:{frameType:"physics",buildProps:(e,t,o,i,s)=>{const n=i.size??[900,420],a=Array.isArray(s.stages)?s.stages:[],c=r({data:Array.isArray(e)?e:[],stages:a,size:n,idAccessor:s.idAccessor,stageAccessor:s.stageAccessor||"stage",groupBy:s.groupBy,groupLabelAccessor:s.groupLabelAccessor,workAccessor:s.workAccessor,radiusAccessor:s.radiusAccessor,ballRadius:s.ballRadius??6,seed:s.seed??1,groupCompletion:s.groupCompletion,groupAnchorAlong:s.groupAnchorAlong,settle:s.settle??!0,gravityX:s.gravityX,gravityY:s.gravityY}),l=c.metadata;return{...i,config:c.config,initialSpawns:gt(c.initialSpawns),projectionRows:c.projectionRows,regionEffects:l?.regionEffects,bodyStyle:d(t||s.colorBy||s.groupBy)}}},GauntletChart:{frameType:"physics",buildProps:(e,t,o,i,s)=>{const r=i.size??[900,520],n=ut({data:Array.isArray(e)?e:[],size:r,gates:s.gates,positiveProperties:s.positiveProperties,negativeProperties:s.negativeProperties,crashOffset:s.crashOffset,idAccessor:s.idAccessor,positiveAccessor:s.positiveAccessor,negativeAccessor:s.negativeAccessor,metricsAccessor:s.metricsAccessor,initialViability:s.initialViability,projectPlacement:s.projectPlacement,coreBody:s.coreBody,viability:s.viability});return{...i,config:n.config,initialSpawns:gt(n.initialSpawns),projectionRows:[],bodyStyle:d(t||s.colorBy)}}},PhysicalFlowChart:{frameType:"physics",buildProps:(e,t,o,s,r)=>{const n=s.size??[760,420],a=i({nodes:Array.isArray(r.nodes)?r.nodes:[],links:Array.isArray(r.links)?r.links:Array.isArray(r.edges)?r.edges:Array.isArray(e)?e:[],nodeIdAccessor:r.nodeIdAccessor||"id",nodeXAccessor:r.nodeXAccessor||"x",nodeYAccessor:r.nodeYAccessor||"y",sourceAccessor:r.sourceAccessor||"source",targetAccessor:r.targetAccessor||"target",throughputAccessor:r.throughputAccessor||"value",pathAccessor:r.pathAccessor||"path",coordinateMode:r.coordinateMode||"auto",particleRate:r.particleRate??.16,maxParticles:r.maxParticles??180,particleRadius:r.particleRadius??4,flowSpeed:r.flowSpeed??90,pathConstraint:r.pathConstraint||"path",reducedMotion:!0,seed:r.seed??1,size:n});return{...s,config:a.config,initialSpawns:gt(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:d(t||r.colorBy||"source")}}},PhysicsCustomChart:{frameType:"physics",buildProps:(e,t,o,i,s)=>{const r=i.size??[700,380],n=h({chartId:s.chartId,colorScheme:o,config:s.config,data:Array.isArray(e)?e:[],layout:s.layout,layoutConfig:s.layoutConfig,semantic:ze(Te)??{},size:r,themeCategorical:Te.colors.categorical,xExtent:s.xExtent,yExtent:s.yExtent});return{...i,config:n.config,initialSpawns:gt(n.initialSpawns),projectionRows:[],bodyStyle:n.result.bodyStyle??d(t||s.colorBy)}}}};function ft(e){if(!e)return Te;if("string"==typeof e){if("light"===e)return Te;if("dark"===e)return _e;if("high-contrast"===e)return Me;return Pe[e]||Te}const t="dark"===e.mode?_e:Te,o={...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}},tooltip:{...t.tooltip,...e.tooltip||{}}};return Re(o)}function yt(e){return{background:e.colors.background,text:e.colors.text,textSecondary:e.colors.textSecondary,grid:e.colors.grid,border:e.colors.border,primary:e.colors.primary,fontFamily:e.typography.fontFamily,titleSize:e.typography.titleSize,labelSize:e.typography.labelSize,tickSize:e.typography.tickSize,categorical:e.colors.categorical,annotation:e.colors.annotation??e.colors.text,legendSize:e.typography.legendSize??e.typography.labelSize,titleFontSize:e.typography.titleFontSize??e.typography.titleSize,tickFontFamily:e.typography.tickFontFamily??e.typography.fontFamily}}function mt(e){const t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function xt(e){if(!e||2>e.length)return;const t=mt(e[0]),o=mt(e[e.length-1]);return null!==t&&null!==o?[t,o]:void 0}function bt(e){const{count:t,byType:o}=function(e){const t={};for(const o of e){const e="string"==typeof o?.type&&o.type.length>0?o.type:"node";t[e]=(t[e]??0)+1}return{count:e.length,byType:t}}(e.marks),i=0===t,s=[...e.extraWarnings??[]];return i&&!s.includes("EMPTY_SCENE")&&s.push("EMPTY_SCENE"),{component:"",frameType:e.frameType,status:i?"empty":"ok",empty:i,markCount:t,markCountByType:o,width:e.width,height:e.height,...e.xDomain?{xDomain:e.xDomain}:{},...e.yDomain?{yDomain:e.yDomain}:{},...e.categories?{categories:e.categories}:{},...void 0!==e.nodeCount?{nodeCount:e.nodeCount}:{},...void 0!==e.edgeCount?{edgeCount:e.edgeCount}:{},...void 0!==e.legendItems?{legendItems:e.legendItems}:{},annotationCount:Array.isArray(e.annotations)?e.annotations.length:0,ariaLabel:"string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${t} marks`,warnings:s}}import*as At from"react";import*as vt from"react-dom/server";import{scaleOrdinal as St}from"d3-scale";import{jsx as wt,jsxs as kt}from"react/jsx-runtime";function _t(e){return"left"===e?"start":"right"===e?"end":e??"start"}function Mt(e){return Number(e.typography.legendSize??e.typography.labelSize??e.typography.tickSize)||11}function Tt(e,t,o,i){const s=Mt(i);return t+o+Math.ceil(e.length*s*.58)}function Pt(e){const{categories:t,theme:o,position:i="right",totalWidth:s,totalHeight:r,margin:n,legendLayout:a}=e,c=Math.max(1,a?.swatchSize??14),l=Math.max(0,a?.labelGap??6),h=Math.max(0,a?.itemGap??8),d=Math.max(c,a?.rowHeight??20),u=c+l,g=Math.min(2,c/2),p="top"===i||"bottom"===i,f=Math.max(c,s-n.left-n.right),y=Math.max(d,r-n.top-n.bottom),m=t.map(e=>Tt(e,c,l,o));if(p){const e=Math.max(c,a?.maxWidth??f),o=[];let i=0,s=0;m.forEach((t,r)=>{const n=0===s?t:s+h+t;s>0&&n>e?(o.push({start:i,end:r,width:s}),i=r,s=t):s=n}),t.length>0&&o.push({start:i,end:t.length,width:s});const r=_t(a?.align),n=[];return o.forEach((o,i)=>{let s="center"===r?Math.max(0,(e-o.width)/2):"end"===r?Math.max(0,e-o.width):0;for(let e=o.start;o.end>e;e++)n.push({category:t[e],width:m[e],x:s,y:i*d}),s+=m[e]+h}),{items:n,width:Math.max(0,...o.map(e=>e.width)),height:o.length*d,swatchSize:c,labelOffset:u,swatchRadius:g}}const x=Math.max(0,...m),b=Math.max(1,Math.floor(y/d)),A=Math.max(1,Math.ceil(t.length/b));return{items:t.map((e,t)=>({category:e,width:m[t],x:Math.floor(t/b)*(x+h),y:t%b*d})),width:A*x+Math.max(0,A-1)*h,height:Math.min(t.length,b)*d,swatchSize:c,labelOffset:u,swatchRadius:g}}function Rt(e){const{legendGroups:t,theme:o,position:i="right",totalWidth:s,totalHeight:r,margin:n,legendLayout:a}=e,c=Math.max(1,a?.swatchSize??14),l=Math.max(0,a?.labelGap??6),h=Math.max(0,a?.itemGap??8),d=Math.max(c,a?.rowHeight??20),u=c+l,g=Math.min(2,c/2),p=Math.max(12,Mt(o)),f="top"===i||"bottom"===i,y=Math.max(c,s-n.left-n.right),m=Math.max(d,r-n.top-n.bottom);if(f){const i=Math.max(c,a?.maxWidth??y),s=_t(a?.align);let r=0,n=0;const l=[];for(const s of t){const t=s.items.map(e=>e.label),h=Pt({...e,categories:t,legendLayout:{...a,maxWidth:Math.max(c,i-p-8),align:"start"}}),d=s.label?p:0,u=s.label?Tt(s.label,0,0,o):0,g=d>0?d+8:0,f=g+h.width,y=Math.max(h.height,u);l.push({group:s,x:r,y:0,itemOffsetX:g,itemOffsetY:0,width:f,height:y,items:h.items}),r+=f+12,n=Math.max(n,y)}const h=l.length>0?r-12:0,d=h>i?0:"center"===s?Math.max(0,(i-h)/2):"end"===s?Math.max(0,i-h):0;return{groups:l.map(e=>({...e,x:e.x+d})),width:h,height:n,swatchSize:c,labelOffset:u,swatchRadius:g}}let x=0,b=0;const A=[];for(const e of t){const t=e.items.map(e=>e.label).map(e=>Tt(e,c,l,o)),i=Math.max(0,...t),s=Math.max(1,Math.min(e.items.length||1,Math.max(1,Math.floor(Math.max(d,m-x)/d)))),r=Math.max(1,Math.ceil(e.items.length/s)),n=e.items.map((e,o)=>({category:e.label,width:t[o],x:Math.floor(o/s)*(i+h),y:o%s*d})),a=r*i+Math.max(0,r-1)*h,u=Math.min(e.items.length,s)*d,g=e.label?Tt(e.label,0,0,o):0,f=e.label?p+8:0,y=f+u+12,v=Math.max(a,g);A.push({group:e,x:0,y:x,itemOffsetX:0,itemOffsetY:f,width:v,height:y,items:n}),b=Math.max(b,v),x+=y}return{groups:A,width:b,height:Math.max(0,x),swatchSize:c,labelOffset:u,swatchRadius:g}}function zt(e){const t="top"===e.position||"bottom"===e.position,o=Math.max(1,e.totalWidth-e.margin.left-e.margin.right);return t?{width:Math.min(e.legendLayout?.maxWidth??o,200),height:e.gradient.label?34:26,swatchSize:12}:{width:e.gradient.label?86:72,height:e.gradient.label?124:108,swatchSize:14}}function Lt(e){const{categories:t,colorScheme:o,theme:i,position:s="right",totalWidth:r,totalHeight:n,margin:a,hasTitle:c=!1}=e;if(!t||0===t.length)return null;const l=function(e,t,o){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;return t=>he(e,t)??"#999"}const i=Array.isArray(t)?t:o.colors.categorical.length>0?o.colors.categorical:ve;return St().domain(e).range(i)}(t,o,i),h="top"===s||"bottom"===s,d=Pt(e);let u,g;if("left"===s?(u=Math.max(4,a.left-d.width-10),g=a.top):"top"===s?(u=a.left,g=c?32:8):"bottom"===s?(u=a.left,g=Math.min(n-a.bottom+38,n-d.height-2)):(u=Math.min(r-d.width-4,r-a.right+10),g=a.top),h){const e=d.items.map((e,t)=>kt("g",{transform:`translate(${e.x},${e.y})`,children:[wt("rect",{width:d.swatchSize,height:d.swatchSize,fill:l(e.category),rx:d.swatchRadius}),wt("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:Mt(i),fill:i.colors.text,fontFamily:i.typography.fontFamily,children:e.category})]},"legend-"+t));return wt("g",{className:"semiotic-legend",transform:`translate(${u},${g})`,children:e})}const p=d.items.map((e,t)=>kt("g",{transform:`translate(${e.x},${e.y})`,children:[wt("rect",{width:d.swatchSize,height:d.swatchSize,fill:l(e.category),rx:d.swatchRadius}),wt("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:Mt(i),fill:i.colors.text,fontFamily:i.typography.fontFamily,children:e.category})]},"legend-"+t));return wt("g",{className:"semiotic-legend",transform:`translate(${u},${g})`,children:p})}function Ft(e,t){if(!t||!e||0===e.length)return[];const o="function"==typeof t?t:e=>e[t],i=new Set;for(const t of e){const e=o(t);null!=e&&i.add(e+"")}return Array.from(i)}import{jsx as Ct,jsxs as Bt}from"react/jsx-runtime";var Dt=16;function Et(e,t){return e.color||t.colors.annotation||t.colors.text}function Ot(e,t,o){const i=e.labelBackground,s=t.colors.background;return void 0===i?"none"===o?"none":{type:"halo",fill:s}:!1===i||"none"===i?"none":!0===i||"halo"===i?{type:"halo",fill:s}:"box"===i?{type:"box",fill:s}:{fill:s,...i}}function jt(e,t,o){return null!=e.x&&t.x?t.x(e.x):o&&null!=e[o]&&t.x?t.x(e[o]):"number"==typeof e.x?e.x:null}function Nt(e,t,o){return null!=e.y&&t.y?t.y(e.y):o&&null!=e[o]&&t.y?t.y(e[o]):"number"==typeof e.y?e.y:null}function Wt(e){const{annotations:t}=e;if(!t||0===t.length)return null;const o=e.autoPlaceAnnotations?xe({annotations:t,context:{scales:{x:e.scales.x,y:e.scales.y,time:e.scales.x,value:e.scales.y,o:e.scales.o,geoProjection:e.scales.geoProjection},width:e.layout.width,height:e.layout.height,xAccessor:e.xAccessor,yAccessor:e.yAccessor,frameType:e.projection?"ordinal":"xy",projection:"horizontal"===e.projection?"horizontal":"vertical"},..."object"==typeof e.autoPlaceAnnotations?e.autoPlaceAnnotations:{}}):t,i=[];for(let t=0;o.length>t;t++){const s=$t(o[t],t,e);s&&i.push({node:s,annotation:o[t]})}const s=V(i);return s.length>0?Ct("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:s}):null}function $t(e,t,o){const{scales:i,layout:s,theme:r,xAccessor:n,yAccessor:a}=o;switch(e.type){case"y-threshold":{const n=e.value;if(null==n)return null;const a=Et(e,r),c=e.label,l=e.labelPosition||"right",h=e.strokeDasharray||"6,4",d=e.strokeWidth??1.5;if("horizontal"===o.projection&&i.r){const o=i.r(n);return null==o?null:Bt("g",{opacity:e.opacity,children:[Ct("line",{x1:o,y1:0,x2:o,y2:s.height,stroke:a,strokeWidth:d,strokeDasharray:h}),c&&Ct(N,{x:o+4,y:Dt,textAnchor:"start",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:c,background:Ot(e,r,"halo")})]},"ann-ythresh-"+t)}const u=i.y?i.y(n):i.r?i.r(n):null;return null==u?null:Bt("g",{children:[Ct("line",{x1:0,y1:u,x2:s.width,y2:u,stroke:a,strokeWidth:d,strokeDasharray:h}),c&&Ct(N,{x:"left"===l?4:"center"===l?s.width/2:s.width-4,y:20>u?Math.min(s.height-4,u+Dt):u-6,textAnchor:"left"===l?"start":"center"===l?"middle":"end",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:c,background:Ot(e,r,"halo")})]},"ann-ythresh-"+t)}case"x-threshold":{const o=e.value;if(null==o||!i.x)return null;const n=i.x(o);if(null==n)return null;const a=Et(e,r),c=e.label,l=e.labelPosition||"top";return Bt("g",{opacity:e.opacity,children:[Ct("line",{x1:n,y1:0,x2:n,y2:s.height,stroke:a,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray||"6,4"}),c&&Ct(N,{x:n>.6*s.width?n-4:n+4,y:"bottom"===l?s.height-4:"center"===l?s.height/2:Dt,textAnchor:n>.6*s.width?"end":"start",fontSize:r.typography.tickSize,fill:a,fontFamily:r.typography.fontFamily,text:c,background:Ot(e,r,"halo")})]},"ann-xthresh-"+t)}case"band":{const o=null!=e.y0&&i.y?i.y(e.y0):null,n=null!=e.y1&&i.y?i.y(e.y1):null;if(null==o||null==n)return null;const a=Math.min(o,n),c=Math.abs(n-o),l=fe(e.fill||Et(e,r),"ssr-band-"+t),h=e.fillOpacity??.1;return Bt("g",{opacity:e.opacity,children:[l.def&&Ct("defs",{children:l.def}),Ct("rect",{x:0,y:a,width:s.width,height:c,fill:l.fill,fillOpacity:h}),e.label&&Ct(N,{x:s.width-4,y:Math.max(a,0)+Dt,textAnchor:"end",fontSize:r.typography.tickSize,fill:e.color||Et(e,r),fontFamily:r.typography.fontFamily,fontWeight:"bold",text:e.label,background:Ot(e,r,"halo")})]},"ann-band-"+t)}case"x-band":{const o=null!=e.x0&&i.x?i.x(e.x0):null,n=null!=e.x1&&i.x?i.x(e.x1):null;if(null==o||null==n)return null;const a=Math.min(o,n),c=Math.abs(n-o),l=fe(e.fill||Et(e,r),"ssr-xband-"+t),h=e.fillOpacity??.1;return Bt("g",{opacity:e.opacity,children:[l.def&&Ct("defs",{children:l.def}),Ct("rect",{x:a,y:0,width:c,height:s.height,fill:l.fill,fillOpacity:h}),e.label&&Ct(N,{x:a+4,y:Dt,textAnchor:"start",fontSize:r.typography.tickSize,fill:e.color||Et(e,r),fontFamily:r.typography.fontFamily,fontWeight:"bold",text:e.label,background:Ot(e,r,"halo")})]},"ann-xband-"+t)}case"category-highlight":{if(null==e.category||!i.o)return null;const n=i.o(e.category+"");if(null==n)return null;const a=i.o.bandwidth?i.o.bandwidth():40,c=Et(e,r),l=e.opacity??.1,h=e.label;return Bt("g","horizontal"===o.projection?{children:[Ct("rect",{x:0,y:n,width:s.width,height:a,fill:c,opacity:l}),h&&Ct(N,{x:12,y:n+a/2,dominantBaseline:"middle",fill:c,fontSize:r.typography.tickSize,fontWeight:"bold",fontFamily:r.typography.fontFamily,text:h,background:Ot(e,r,"none")})]}:{children:[Ct("rect",{x:n,y:0,width:a,height:s.height,fill:c,opacity:l}),h&&Ct(N,{x:n+a/2,y:Dt,textAnchor:"middle",fill:c,fontSize:r.typography.tickSize,fontWeight:"bold",fontFamily:r.typography.fontFamily,text:h,background:Ot(e,r,"none")})]},"ann-cathighlight-"+t)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:o,y:s}=function(e,t,o,i){if(Array.isArray(e.coordinates)&&e.coordinates.length>=2&&t.geoProjection){const o=t.geoProjection([e.coordinates[0],e.coordinates[1]]);if(o)return{x:o[0],y:o[1]}}return{x:jt(e,t,o),y:Nt(e,t,i)}}(e,i,n,a);if(null==o||null==s)return null;const c="text"===e.type,l=e.dx??(c?0:30),h=e.dy??(c?0:-30),d=e.color||r.colors.text;if(!c){const i="callout"===e.type?"callout-circle":e.type,r="callout-circle"===i?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===i?{width:e.width,height:e.height}:void 0;return Ct(I,{noteData:{x:o,y:s,dx:l,dy:h,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:i,...r?{subject:r}:{},connector:e.connector||{end:"arrow"},color:d,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-label-"+t)}return Ct("g",{children:Ct("text",{x:o+l,y:s+h,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||r.typography.labelSize,fill:d,fontFamily:r.typography.fontFamily,fontWeight:e.fontWeight,opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:e.label||e.title})},"ann-label-"+t)}default:return null}}import{jsx as It,jsxs as Gt}from"react/jsx-runtime";function Vt(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){const t=e.id;return null==t?null:t+""}return null}function Yt(e,t){if(0===t.categories.length)return;const o=t.position||"right",i=function(e){const{width:t,height:o,swatchSize:i}=Pt(e);return{width:t,height:o,swatchSize:i}}({categories:t.categories,colorScheme:t.colorScheme,theme:t.theme,position:o,totalWidth:t.size[0],totalHeight:t.size[1],margin:e,hasTitle:t.hasTitle,legendLayout:t.legendLayout});"right"===o?e.right=Math.max(e.right,i.width+14):"left"===o?e.left=Math.max(e.left,i.width+14):"top"===o?e.top=Math.max(e.top,(t.hasTitle?32:8)+i.height+4):e.bottom=Math.max(e.bottom,38+i.height+4)}function Ht(e,t){const o=t.position||"right",i={theme:t.theme,position:o,totalWidth:t.size[0],totalHeight:t.size[1],margin:e,hasTitle:t.hasTitle,legendLayout:t.legendLayout},s=te(t.legend)?function(e){const{width:t,height:o,swatchSize:i}=Rt(e);return{width:t,height:o,swatchSize:i}}({...i,legendGroups:t.legend.legendGroups}):ee(t.legend)?zt({...i,gradient:t.legend.gradient}):null;s&&("right"===o?e.right=Math.max(e.right,s.width+14):"left"===o?e.left=Math.max(e.left,s.width+14):"top"===o?e.top=Math.max(e.top,(t.hasTitle?32:8)+s.height+4):e.bottom=Math.max(e.bottom,38+s.height+4))}function Xt(e,t){const o={theme:t.theme,position:t.position||"right",totalWidth:t.size[0],totalHeight:t.size[1],margin:t.margin,hasTitle:t.hasTitle,legendLayout:t.legendLayout,idPrefix:t.idPrefix};return te(e)?function(e){if(0===(t=e.legendGroups,t.flatMap(e=>e.items.map((t,o)=>({group:e,item:t,itemIndex:o,label:t.label})))).length)return null;var t;const o=Rt(e),i="top"===e.position||"bottom"===e.position,s=e.theme.colors.grid||e.theme.colors.textSecondary;let r,n;"left"===e.position?(r=Math.max(4,e.margin.left-o.width-10),n=e.margin.top):"top"===e.position?(r=e.margin.left,n=e.hasTitle?32:8):"bottom"===e.position?(r=e.margin.left,n=Math.min(e.totalHeight-e.margin.bottom+38,e.totalHeight-o.height-2)):(r=Math.min(e.totalWidth-o.width-4,e.totalWidth-e.margin.right+10),n=e.margin.top);const a=o.groups.flatMap((t,r)=>{const{group:n}=t,a=n.type??"fill",c=[];if(n.label&&c.push(wt("text",i?{transform:`translate(${t.x},${t.y}) rotate(90)`,textAnchor:"start",fontSize:Mt(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:n.label}:{x:t.x,y:t.y+Mt(e.theme),fontSize:Mt(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:n.label},"legend-group-label-"+r)),c.push(...t.items.map((i,s)=>{const c=n.items[s],l=n.styleFn(c,s),h="function"==typeof a?a(c):"line"===a?wt("line",{x1:0,y1:0,x2:o.swatchSize,y2:o.swatchSize,style:l}):wt("rect",{width:o.swatchSize,height:o.swatchSize,rx:o.swatchRadius,style:l});return kt("g",{transform:`translate(${t.x+t.itemOffsetX+i.x},${t.y+t.itemOffsetY+i.y})`,children:[h,wt("text",{x:o.labelOffset,y:o.swatchSize/2,dominantBaseline:"central",fontSize:Mt(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:i.category})]},`legend-${r}-${s}`)})),!i&&o.groups.length-1>r)c.push(wt("line",{x1:0,y1:t.y+t.height-6,x2:o.width,y2:t.y+t.height-6,stroke:s},"legend-group-separator-"+r));else if(i&&o.groups.length-1>r){const e=t.x+t.width+6;c.push(wt("line",{x1:e,y1:0,x2:e,y2:o.height,stroke:s},"legend-group-separator-"+r))}return c});return wt("g",{className:"semiotic-legend",transform:`translate(${r},${n})`,"data-orientation":i?"horizontal":"vertical",children:a})}({...o,legendGroups:e.legendGroups}):ee(e)?function(e){const t=zt(e),o="top"===e.position||"bottom"===e.position,i=(e.idPrefix?e.idPrefix+"-":"")+"semiotic-static-gradient-legend",s=e.gradient.format||(e=>Math.round(100*e)/100+"");let r,n;"left"===e.position?(r=Math.max(4,e.margin.left-t.width-10),n=e.margin.top):"top"===e.position?(r=e.margin.left,n=e.hasTitle?32:8):"bottom"===e.position?(r=e.margin.left,n=Math.min(e.totalHeight-e.margin.bottom+38,e.totalHeight-t.height-2)):(r=Math.min(e.totalWidth-t.width-4,e.totalWidth-e.margin.right+10),n=e.margin.top);const a=Array.from({length:17},(t,i)=>{const s=i/16;return wt("stop",{offset:100*s+"%",stopColor:e.gradient.colorFn(o?e.gradient.domain[0]+s*(e.gradient.domain[1]-e.gradient.domain[0]):e.gradient.domain[1]-s*(e.gradient.domain[1]-e.gradient.domain[0]))},i)});if(o){const o=12,c=e.gradient.label?0:void 0,l=e.gradient.label?8:0;return kt("g",{className:"semiotic-legend",transform:`translate(${r},${n})`,children:[wt("defs",{children:wt("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:a})}),e.gradient.label&&wt("text",{x:t.width/2,y:c,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),wt("rect",{x:0,y:l,width:t.width,height:o,fill:`url(#${i})`,rx:2}),wt("text",{x:0,y:l+o+12,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:s(e.gradient.domain[0])}),wt("text",{x:t.width,y:l+o+12,textAnchor:"end",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:s(e.gradient.domain[1])})]})}const c=e.gradient.label?-6:void 0;return kt("g",{className:"semiotic-legend",transform:`translate(${r},${n+(e.gradient.label?12:0)})`,children:[wt("defs",{children:wt("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:a})}),e.gradient.label&&wt("text",{x:7,y:c,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),wt("rect",{x:0,y:0,width:14,height:100,fill:`url(#${i})`,rx:2}),wt("text",{x:19,y:10,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:s(e.gradient.domain[1])}),wt("text",{x:19,y:100,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:s(e.gradient.domain[0])})]})}({...o,gradient:e.gradient}):null}function qt(e){return Math.round(100*e)/100+""}function Qt(e,t){const o=yt(t.theme),i=t.idPrefix?t.idPrefix+"-":"",s="string"==typeof t.title?t.title:void 0,r=s?i+"semiotic-title":void 0,n=t.description?i+"semiotic-desc":void 0,a=[r,n].filter(Boolean).join(" ")||void 0;return Gt("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className,width:t.width,height:t.height,role:"img","aria-labelledby":a,style:{fontFamily:o.fontFamily},children:[s&&It("title",{id:r,children:s}),t.description&&It("desc",{id:n,children:t.description}),t.defs&&It("defs",{children:t.defs}),t.background&&"transparent"!==t.background&&It("rect",{x:0,y:0,width:t.width,height:t.height,fill:t.background}),It("g",{id:i+"data-area",transform:t.innerTransform,children:e}),s&&It("text",{id:i+"chart-title",x:t.width/2,y:G,textAnchor:"middle",fontSize:o.titleSize,fontWeight:"bold",fill:o.text,fontFamily:o.fontFamily,children:s}),t.legend&&It("g",{id:i+"legend",children:t.legend}),t.outerElements]})}import{Fragment as Zt,jsx as Ut,jsxs as Kt}from"react/jsx-runtime";function Jt(e,t){const o=ft(e.theme),i=e.size||[500,300],s=ce({top:20,right:20,bottom:30,left:40,...e.margin},e.title),r=J(e.title),n=Q(e.data),a=e.showLegend?Ft(n,e.colorAccessor||e.groupAccessor):[],c=e.legendPosition;te(e.legend)||ee(e.legend)?Ht(s,{legend:e.legend,theme:o,position:c||"right",size:i,hasTitle:r,legendLayout:e.legendLayout}):e.showLegend&&a.length>0&&Yt(s,{categories:a,colorScheme:e.colorScheme,theme:o,position:c||"right",size:i,hasTitle:r,legendLayout:e.legendLayout});const l=i[0]-s.left-s.right,h=i[1]-s.top-s.bottom,d="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),u=e.colorScheme||o.colors.categorical,g={chartType:e.chartType,windowSize:e.windowSize??200,windowMode:e.windowMode??"sliding",arrowOfTime:d?e.arrowOfTime??"right":"right",extentPadding:e.extentPadding??.1,xAccessor:d?void 0:e.xAccessor,yAccessor:d?void 0:e.yAccessor,timeAccessor:d?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,axisExtent:e.axisExtent,sizeRange:e.sizeRange,xScaleType:e.xScaleType,yScaleType:e.yScaleType,scalePadding:e.scalePadding,binSize:e.binSize,normalize:e.normalize,stackOrder:e.stackOrder,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,y0Accessor:e.y0Accessor,areaGroups:e.areaGroups?e.areaGroups instanceof Set?e.areaGroups:new Set(e.areaGroups):void 0,curve:e.curve,gradientFill:!0===e.gradientFill?{topOpacity:.8,bottomOpacity:.05}:!1===e.gradientFill?void 0:e.gradientFill,lineGradient:e.lineGradient,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,barStyle:e.barStyle,waterfallStyle:e.waterfallStyle,swarmStyle:e.swarmStyle,colorScheme:u,themeCategorical:o.colors.categorical,themeSemantic:ze(o),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:s,layoutSelection:e.layoutSelection,barColors:e.barColors},p=new x(g);if(e.data&&p.ingest({inserts:n,bounded:!0}),p.computeScene({width:l,height:h}),!p.scales||0===p.scene.length)return t&&(t.evidence=bt({frameType:"xy",width:i[0],height:i[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:p.scales?[]:["NO_SCALES"]})),vt.renderToStaticMarkup(Qt(null,{width:i[0],height:i[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:h,idPrefix:e._idPrefix}));t&&(t.evidence=bt({frameType:"xy",width:i[0],height:i[1],marks:p.scene,title:e.title,description:e.description,annotations:e.annotations,xDomain:xt(p.scales.x?.domain?.()),yDomain:xt(p.scales.y?.domain?.()),legendItems:a.length>0?a.length:void 0}));const f=e._idPrefix,y=e.showGrid?function(e,t,o,i,s){const{grid:r}=yt(o),n=i?i+"-":"",a=B(e.x,5,s),c=B(e.y,5,s);return Gt("g",{id:n+"grid",className:"semiotic-grid",opacity:.8,children:[a.map((o,i)=>{const s=e.x(o);return It("line",{x1:s,y1:0,x2:s,y2:t.height,stroke:r,strokeWidth:.5},"gx-"+i)}),c.map((o,i)=>{const s=e.y(o);return It("line",{x1:0,y1:s,x2:t.width,y2:s,stroke:r,strokeWidth:.5},"gy-"+i)})]})}(p.scales,{width:l,height:h},o,f,e.axisExtent):null,m=p.scene.map((t,o)=>F({node:t,index:o,renderMode:e.renderMode,fallback:()=>de(t,o,f)})).filter(Boolean),b=!1!==e.showAxes?function(e,t,o,i,s){const r=yt(i),n=B(e.x,5,o.axisExtent).map(t=>({pixel:e.x(t),label:(o.xFormat||o.tickFormatTime||qt)(t)})),a=B(e.y,5,o.axisExtent).map(t=>({pixel:e.y(t),label:(o.yFormat||o.tickFormatValue||qt)(t)}));return Gt("g",{id:(s?s+"-":"")+"axes",className:"stream-axes",children:[It("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:r.border,strokeWidth:1}),n.map((e,o)=>Gt("g",{transform:`translate(${e.pixel},${t.height})`,children:[It("line",{y2:5,stroke:r.border,strokeWidth:1}),It("text",{y:18,textAnchor:"middle",fontSize:r.tickSize,fill:r.textSecondary,fontFamily:r.fontFamily,children:e.label})]},"xtick-"+o)),o.xLabel&&It("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:r.labelSize,fill:r.text,fontFamily:r.fontFamily,children:o.xLabel}),It("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:r.border,strokeWidth:1}),a.map((e,t)=>Gt("g",{transform:`translate(0,${e.pixel})`,children:[It("line",{x2:-5,stroke:r.border,strokeWidth:1}),It("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:r.tickSize,fill:r.textSecondary,fontFamily:r.fontFamily,children:e.label})]},"ytick-"+t)),o.yLabel&&It("text",{x:15-(o.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:r.labelSize,fill:r.text,fontFamily:r.fontFamily,transform:`rotate(-90, ${15-(o.margin?.left??40)}, ${t.height/2})`,children:o.yLabel})]})}(p.scales,{width:l,height:h},e,o,f):null,A=e.annotations?Wt({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{x:p.scales.x,y:p.scales.y},layout:{width:l,height:h},theme:o,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:f}):null,v=e.svgPreRenderers&&p.scales?e.svgPreRenderers.map((e,t)=>{try{return Ut(At.Fragment,{children:e(p.scene,p.scales,{width:l,height:h})},"pre-"+t)}catch{return null}}).filter(Boolean):null,S=e.showLegend?0===a.length?null:Lt({categories:a,colorScheme:e.colorScheme,theme:o,position:e.legendPosition||"right",totalWidth:i[0],totalHeight:i[1],margin:s,hasTitle:r,legendLayout:e.legendLayout}):null,w=At.isValidElement(e.legend)?e.legend:Xt(e.legend,{theme:o,position:e.legendPosition||"right",size:i,margin:s,hasTitle:r,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||S;return vt.renderToStaticMarkup(Qt(Kt(Zt,{children:[e.backgroundGraphics,v,y,m,b,A,e.foregroundGraphics,p.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:h,legend:w,idPrefix:e._idPrefix}))}import*as eo from"react";import*as to from"react-dom/server";import{scaleBand as oo,scaleLinear as io}from"d3-scale";var so=class{constructor(){this.colorSchemeMap=new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(e,t,o){if(t&&"function"==typeof e.pieceStyle){const i=e.pieceStyle(t,o);return i&&!i.fill&&o?{...i,fill:this.getColorFromScheme(e,o)}:i}return e.pieceStyle&&"object"==typeof e.pieceStyle?e.pieceStyle:e.barColors&&o?{fill:e.barColors[o]||"#007bff"}:{fill:o?this.getColorFromScheme(e,o):"#007bff"}}resolveSummaryStyle(e,t,o){return t&&"function"==typeof e.summaryStyle?e.summaryStyle(t,o):e.summaryStyle&&"object"==typeof e.summaryStyle?e.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(e,t){const o=this.colorSchemeMap.get(t);if(o)return o;const i=Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical||$,s=i[this.colorSchemeIndex%i.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(t,s),s}};function ro(e){const t=e.getSymbol;if(!t)return null;const o=e.config.symbolMap,i=new Map;let s=0;return e=>{const r=t(e)+"",n=o?.[r];if(n)return n;let a=i.get(r);return a||(a=ye[s%ye.length],s++,i.set(r,a)),a}}function no(e,t,o,i,s,r,n){e.push(t?{type:"symbol",x:i,y:s,size:Math.PI*r*r,symbolType:t(o),style:n,datum:o}:{type:"point",x:i,y:s,r:r,style:n,datum:o})}function ao(e,t){const{columns:o,config:i,resolvePieceStyle:s}=e,r=[],n=Math.min(t.width,t.height)/2-4,a="donut"===i.chartType?i.innerRadius||60:0,c=-Math.PI/2+(i.startAngle||0)*Math.PI/180,l=null!=i.sweepAngle?i.sweepAngle*Math.PI/180:2*Math.PI,h=null!=i.sweepAngle&&360>i.sweepAngle,d=Object.values(o),u=d.some(e=>{const t=e.pieceData[0];return t&&("number"==typeof t._pct||"number"==typeof t._pctStart||null!=t._roundedEnds)}),g=h&&!u&&d.length>1&&(i.cornerRadius??0)>0;for(let e=0;d.length>e;e++){const t=d[e],o=t.pieceData[0],h="number"==typeof o?._pctStart?o._pctStart:t.pctStart,u=c+h*l,p=c+(h+("number"==typeof o?._pct?o._pct:t.pct))*l,f=s(t.pieceData[0],t.name),y=0===e,m=e===d.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:n,startAngle:u,endAngle:p,...i.cornerRadius&&{cornerRadius:i.cornerRadius},style:f,datum:o?._nonInteractive?null:t.pieceData,category:t.name};o?._roundedEnds?x.roundedEnds=o._roundedEnds:g&&(x.roundedEnds={start:y,end:m}),o?._gradientBand&&(x._gradientBand=o._gradientBand),r.push(x)}return r}import{quantile as co}from"d3-array";function lo(e){const t=e.length,o=e[0],i=e[t-1];return{n:t,min:o,q1:co(e,.25)??o,median:co(e,.5)??(o+i)/2,q3:co(e,.75)??i,max:i,mean:e.reduce((e,t)=>e+t,0)/t}}import{scaleLinear as ho}from"d3-scale";var uo={bar:function(e,t){const{scales:o,columns:i,config:s,getR:r,getStack:n,resolvePieceStyle:a}=e,{r:c,projection:l}=o,h=[],d="vertical"===l,u="horizontal"===l,g=s.normalize,p=[];if(n){const e=new Set;for(const t of Object.values(i))for(const o of t.pieceData){const t=n(o);e.has(t)||(e.add(t),p.push(t))}}else p.push("_default");for(const e of Object.values(i)){const t=new Map;for(const o of e.pieceData){const e=n?n(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const i=t.get(e);i.total+=r(o),i.pieces.push(o)}let o=0;if(g)for(const e of t.values())o+=Math.abs(e.total);let i=0,s=0;for(const r of p){const l=t.get(r);if(!l)continue;let p=l.total;g&&o>0&&(p/=o);const f=a(l.pieces[0],n?r:e.name),y={...l.pieces[0],__aggregateValue:l.total,__pieceCount:l.pieces.length,category:e.name};if(d){const t=c(0>p?s:i+p),o=0>p?c(s+p)-c(s):c(i)-c(i+p);h.push(v(e.x,t,e.width,Math.abs(o),f,y,r)),0>p?s+=p:i+=p}else if(u){const t=c(0>p?s+p:i),o=0>p?c(s)-c(s+p):c(i+p)-c(i);h.push(v(t,e.x,Math.abs(o),e.width,f,y,r)),0>p?s+=p:i+=p}}}const f="vertical"===l,y=s.roundedTop&&s.roundedTop>0?Math.max(0,s.roundedTop):0;for(const e of h){if("rect"!==e.type)continue;const t=e.datum?.__aggregateValue??0;e.roundedEdge=f?0>t?"bottom":"top":0>t?"left":"right",s.gradientFill&&(e.fillGradient=s.gradientFill)}if(y>0){const e=new Map;for(const t of h){if("rect"!==t.type)continue;const o=t.datum?.category||"";e.has(o)||e.set(o,[]),e.get(o).push(t)}for(const t of e.values()){if(0===t.length)continue;const e=t.filter(e=>(e.datum?.__aggregateValue??0)>=0),o=t.filter(e=>0>(e.datum?.__aggregateValue??0));e.length>0&&(e.reduce(f?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t).roundedTop=y),o.length>0&&(o.reduce(f?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t).roundedTop=y)}}return h},clusterbar:function(e,t){const{scales:o,columns:i,config:s,getR:r,getGroup:n,resolvePieceStyle:a}=e,{r:c,projection:l}=o,h=[],d="vertical"===l,u=[],g=new Set;for(const e of Object.values(i))for(const t of e.pieceData){const e=n?n(t):"_default";g.has(e)||(g.add(e),u.push(e))}const p=u.length||1;for(const e of Object.values(i)){const t=e.width/p,o=.2*t,i=t-o,s=new Map;for(const t of e.pieceData){const e=n?n(t):"_default";s.has(e)||s.set(e,[]),s.get(e).push(t)}for(let n=0;u.length>n;n++){const l=s.get(u[n])||[];for(const s of l){const l=r(s),g=a(s,u[n]);if(d){const r=e.x+n*t+o/2,a=c(0),d=c(l);h.push(v(r,Math.min(a,d),i,Math.abs(a-d),g,s,u[n]))}else{const r=e.x+n*t+o/2,a=c(0),d=c(l);h.push(v(Math.min(a,d),r,Math.abs(d-a),i,g,s,u[n]))}}}}const f=s.roundedTop&&s.roundedTop>0?Math.max(0,s.roundedTop):0;for(const e of h){if("rect"!==e.type)continue;if(null==e.datum)continue;const t=r(e.datum);f>0&&(e.roundedTop=f),e.roundedEdge=d?0>t?"bottom":"top":0>t?"left":"right",s.gradientFill&&(e.fillGradient=s.gradientFill)}return h},point:function(e,t){const{scales:o,columns:i,getR:s,multiScales:r,resolvePieceStyle:n}=e,{r:a,projection:c}=o,l=[],h="vertical"===c,d="radial"===c,u=r.length>0,g=ro(e),p=2*Math.PI,f=-Math.PI/2;for(const e of Object.values(i))for(const t of e.pieceData){const o=t.__rIndex??0,i=t.__rValue??s(t),c=u&&r[o]||a,y=n(t,e.name),m=y.r||5;let x,b;if(d){const t=f+(e.pctStart+e.pct/2)*p,o=c(i);x=Math.cos(t)*o,b=Math.sin(t)*o}else h?(x=e.middle,b=c(i)):(x=c(i),b=e.middle);no(l,g,t,x,b,m,y)}return l},swarm:function(e,t){const{scales:o,columns:i,getR:s,resolvePieceStyle:r}=e,{r:n,projection:a}=o,c=[],l="vertical"===a,h=ro(e);for(const e of Object.values(i)){const t=e.width/2;for(let o=0;e.pieceData.length>o;o++){const i=e.pieceData[o],a=s(i),d=r(i,e.name),u=d.r||4,g=(7919*o%100/100-.5)*t*.8;no(c,h,i,l?e.middle+g:n(a),l?n(a):e.middle+g,u,d)}}return c},pie:ao,donut:ao,boxplot:function(e,t){const{scales:o,columns:i,config:s,getR:r,resolveSummaryStyle:n}=e,{r:a,projection:c}=o,l=[],h="vertical"===c,d=!1!==s.showOutliers;for(const t of Object.values(i)){const o=t.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===o.length)continue;const i=o[0],s=o[o.length-1],c=co(o,.25)??i,u=co(o,.5)??(i+s)/2,g=co(o,.75)??s,p=g-c,f=c-1.5*p,y=g+1.5*p,m=o.find(e=>e>=f)??i,x=[...o].reverse().find(e=>y>=e)??s,b=n(t.pieceData[0],t.name),A=[];if(d)for(const e of t.pieceData){const o=r(e);if(f>o||o>y){const i=h?t.middle:a(o),s=h?a(o):t.middle;A.push({px:i,py:s,value:o,datum:e})}}if(l.push({type:"boxplot",x:h?t.middle:0,y:h?0:t.middle,projection:h?"vertical":"horizontal",columnWidth:.6*t.width,minPos:a(m),q1Pos:a(c),medianPos:a(u),q3Pos:a(g),maxPos:a(x),stats:{n:o.length,min:m,q1:c,median:u,q3:g,max:x,mean:o.reduce((e,t)=>e+t,0)/o.length},style:b,datum:t.pieceData,category:t.name,outliers:A}),d)for(const t of A)l.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:b.fill||e.config.themeSemantic?.secondary||"#999",opacity:.6},datum:t.datum})}return l},violin:function(e,t){const{scales:o,columns:i,config:s,getR:r,resolveSummaryStyle:n}=e,{r:a,projection:c}=o,l=[],h="vertical"===c,d=s.bins||20,u=!1!==s.showIQR;for(const e of Object.values(i)){const t=e.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const o=t[0],i=t[t.length-1],s=(i-o)/d||1,c=Array(d).fill(0);for(const e of t)c[Math.min(Math.floor((e-o)/s),d-1)]++;const g=Se(c,1),p=e.width/2*.9;let f;if(h){f=`M ${e.middle} ${a(o)}`;for(let t=0;d>t;t++){const i=a(o+(t+.5)*s);f+=` L ${e.middle+c[t]/g*p} ${i}`}f+=` L ${e.middle} ${a(i)}`;for(let t=d-1;t>=0;t--){const i=a(o+(t+.5)*s);f+=` L ${e.middle-c[t]/g*p} ${i}`}f+=" Z"}else{f=`M ${a(o)} ${e.middle}`;for(let t=0;d>t;t++)f+=` L ${a(o+(t+.5)*s)} ${e.middle-c[t]/g*p}`;f+=` L ${a(i)} ${e.middle}`;for(let t=d-1;t>=0;t--)f+=` L ${a(o+(t+.5)*s)} ${e.middle+c[t]/g*p}`;f+=" Z"}const y=n(e.pieceData[0],e.name);let m;if(u&&t.length>=4){const s=co(t,.25)??o,r=co(t,.5)??(o+i)/2,n=co(t,.75)??i;m={q1Pos:a(s),medianPos:a(r),q3Pos:a(n),centerPos:e.middle,isVertical:h}}const x=h?{x:e.x,y:Math.min(a(i),a(o)),width:e.width,height:Math.abs(a(i)-a(o))}:{x:Math.min(a(o),a(i)),y:e.x,width:Math.abs(a(i)-a(o)),height:e.width};l.push({type:"violin",pathString:f,translateX:0,translateY:0,bounds:x,iqrLine:m,stats:lo(t),style:y,datum:e.pieceData,category:e.name})}return l},histogram:function(e,t){const{scales:o,columns:i,config:s,getR:r,resolveSummaryStyle:n}=e,{r:a}=o,c=[],l=s.bins||25,h=s.normalize,d=a.domain?.(),u=d?+d[0]:void 0,g=d?+d[1]:void 0;for(const e of Object.values(i)){const t=e.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const[o,i]=ke(t),s=null!=u&&isFinite(u)?u:o,d=null!=g&&isFinite(g)?g:i,p=(d-s)/l||1,f=Array(l).fill(0);for(const e of t)s>e||e>d||f[Math.min(Math.floor((e-s)/p),l-1)]++;const y=t.length,m=Se(f,1),x=n(e.pieceData[0],e.name);for(let t=0;l>t;t++){if(0===f[t])continue;const o=(h?f[t]/y:f[t]/m)*e.width*.9,i=a(s+t*p),r=a(s+(t+1)*p);c.push(v(Math.min(i,r),e.x+e.width-o,Math.abs(r-i),o,x,{bin:t,count:f[t],range:[s+t*p,s+(t+1)*p],category:e.name},e.name))}}return c},ridgeline:function(e,t){const{scales:o,columns:i,config:s,getR:r,resolveSummaryStyle:n}=e,{r:a,projection:c}=o,l=[],h=s.bins||20,d="horizontal"===c,u=s.amplitude||1.5;for(const e of Object.values(i)){const t=e.pieceData.map(e=>r(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const o=t[0],i=t[t.length-1],s=(i-o)/h||1,c=Array(h).fill(0);for(const e of t)o>e||e>i||c[Math.min(Math.floor((e-o)/s),h-1)]++;const g=Se(c,1),p=n(e.pieceData[0],e.name),f=e.width*u;let y;if(d){const t=e.x+e.width;y=`M ${a(o)} ${t}`;for(let e=0;h>e;e++)y+=` L ${a(o+(e+.5)*s)} ${t-c[e]/g*f}`;y+=` L ${a(i)} ${t} Z`}else{const t=e.x;y=`M ${t} ${a(o)}`;for(let e=0;h>e;e++){const i=a(o+(e+.5)*s);y+=` L ${t+c[e]/g*f} ${i}`}y+=` L ${t} ${a(i)} Z`}const m=d?{x:Math.min(a(o),a(i)),y:e.x,width:Math.abs(a(i)-a(o)),height:e.width}:{x:e.x,y:Math.min(a(i),a(o)),width:e.width,height:Math.abs(a(i)-a(o))};l.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:m,stats:lo(t),style:{...p,fillOpacity:p.fillOpacity??.5},datum:e.pieceData,category:e.name})}return l},timeline:function(e,t){const{scales:o,columns:i,getRawRange:s,resolvePieceStyle:r}=e,{r:n,projection:a}=o,c=[],l="horizontal"===a;for(const e of Object.values(i))for(const t of e.pieceData){const o=s(t);if(!o)continue;const[i,a]=o,h=r(t,e.name);if(l){const o=n(Math.min(i,a)),s=n(Math.max(i,a));c.push(v(o,e.x,s-o,e.width,h,t,e.name))}else{const o=n(Math.max(i,a)),s=n(Math.min(i,a));c.push(v(e.x,o,e.width,s-o,h,t,e.name))}}return c},funnel:function(e,t){const{columns:o,getR:i,getStack:s,resolvePieceStyle:r}=e,n=[],a=t.width/2,c=!1!==e.config.showLabels,l=e.scales.o.domain().map(e=>o[e]).filter(Boolean);if(0===l.length)return n;const h=[],d=new Set;for(const e of l)for(const t of e.pieceData){const e=s?s(t):"_default";d.has(e)||(d.add(e),h.push(e))}const u=h.length>1&&"_default"!==h[0],g=[];let p=0;for(const e of l){const t=new Map;let o=0;for(const r of e.pieceData){const e=s?s(r):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const n=t.get(e),a=i(r);n.total+=a,n.pieces.push(r),o+=a}g.push({col:e,groups:t,stepTotal:o}),u||o>p&&(p=o)}if(u)for(const e of g){let t=0,o=0;for(let i=0;h.length>i;i++){const s=e.groups.get(h[i]);s&&(i%2==0?t+=s.total:o+=s.total)}const i=Math.max(t,o);i>p&&(p=i)}if(0===p)return n;const f=new Map;for(const e of h){const t=g[0].groups.get(e);f.set(e,t?.total??0)}const y=g[0].stepTotal,m=u?.95*a:.9*t.width,x=ho().domain([0,p]).range([0,m]),b=e.config.connectorOpacity??.3;let A=new Map;for(let t=0;g.length>t;t++){const o=g[t],i=o.col,s=0===t,l=i.width,d=.55*l,p=i.x+(l-d)/2,m=new Map;if(u){let e=0;for(const t of h){const i=o.groups.get(t);i&&(e+=x(i.total))}let t=a,l=a;for(let u=0;h.length>u;u++){const g=h[u],y=o.groups.get(g);if(!y)continue;const b=x(y.total),A=u%2==0,S=A?t:l-b;A?t+=b:l-=b;const w=r(y.pieces[0],g),k=f.get(g)??y.total,_={...y.pieces[0],__funnelValue:y.total,__funnelPercent:k>0?y.total/k*100:0,__funnelStep:i.name,__funnelIsFirstStep:s,__aggregateValue:y.total,__pieceCount:y.pieces.length,category:g};c&&(0===u&&(_.__funnelStepLabel=i.name,_.__funnelStepLabelX=a,_.__funnelStepLabelY=p,_.__funnelRowWidth=e),_.__funnelValueLabelX=S+b/2,_.__funnelValueLabelY=p,_.__funnelBarW=b),n.push(v(S,p,b,d,w,_,g)),m.set(g,{x:S,y:p,w:b,h:d})}}else{const e=o.stepTotal,t=x(e),l=a-t/2,u=h[0],g="_default"!==u,f=o.groups.get(u)?.pieces[0]??i.pieceData[0],b=g?u:i.name,A=r(f,b),S=y>0?e/y*100:0,w={...f,__funnelValue:e,__funnelPercent:S,__funnelStep:i.name,__funnelIsFirstStep:s,category:g?u:i.name};c&&(w.__funnelStepLabel=i.name,w.__funnelStepLabelX=a,w.__funnelStepLabelY=p,w.__funnelRowWidth=t,w.__funnelValueLabelX=a,w.__funnelValueLabelY=p,w.__funnelBarW=t),n.push(v(l,p,t,d,A,w,b)),m.set(u,{x:l,y:p,w:t,h:d})}if(t>0&&A.size>0){const t=u?h:[h[0]];for(const s of t){const t=A.get(s),a=m.get(s);if(!t||!a)continue;const c=(()=>{const e=o.groups.get(s);return r(e?e.pieces[0]:i.pieceData[0],"_default"===s?i.name:s)})(),l={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[a.x+a.w,a.y],[a.x,a.y]],style:{fill:c.fill||e.config.themeSemantic?.secondary||"#999",opacity:b},datum:o.groups.get(s)?.pieces[0]??i.pieceData[0],category:"_default"===s?i.name:s};n.push(l)}}A=m}return n},"bar-funnel":function(e,t){const{columns:o,getR:i,getStack:s,resolvePieceStyle:r,scales:n}=e,a=[],c=n.o.domain().map(e=>o[e]).filter(Boolean);if(0===c.length)return a;const l=[],h=new Set;for(const e of c)for(const t of e.pieceData){const e=s?s(t):"_default";h.has(e)||(h.add(e),l.push(e))}const d=l.length>1&&"_default"!==l[0],u=[];for(const e of c){const t=new Map;let o=0;for(const r of e.pieceData){const e=s?s(r):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const n=t.get(e),a=i(r);n.total+=a,n.pieces.push(r),o+=a}u.push({col:e,groups:t,stepTotal:o})}const g=new Map;for(const e of l){const t=u[0]?.groups.get(e);g.set(e,t?.total??0)}const p=n.r,f=d?l.length:1,y=d?.15:0;for(let e=0;u.length>e;e++){const t=u[e],o=t.col,i=0===e,s=e>0?u[e-1]:null,n=o.width/f,c=n*y,h=n-c;for(let e=0;l.length>e;e++){const u=l[e],f=t.groups.get(u);if(!f)continue;const y=f.total,m=g.get(u)??y,x=m>0?y/m*100:0,b=s?.groups.get(u),A=i?0:Math.max(0,(b?.total??y)-y),S=o.x+e*n+c/2,w=p(y),k=p(0)-w,_=r(f.pieces[0],d?u:o.name),M={...f.pieces[0],__barFunnelValue:y,__barFunnelPercent:x,__barFunnelIsFirstStep:i,__barFunnelIsDropoff:!1,__barFunnelStep:o.name,__barFunnelDropoffValue:A,__barFunnelCategory:"_default"===u?void 0:u,category:d?u:o.name,__barFunnelLabelX:S+h/2,__barFunnelLabelY:p(y+A)};if(a.push(v(S,w,h,k,_,M,d?u:o.name)),A>0){const e=p(y+A),t=w-e,i={..._},s={...f.pieces[0],__barFunnelValue:A,__barFunnelPercent:m>0?A/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:o.name,__barFunnelCategory:"_default"===u?void 0:u,category:d?u:o.name};a.push(v(S,e,h,t,i,s,d?u:o.name))}}}return a},swimlane:function(e,t){const{scales:o,columns:i,getR:s,getStack:r,resolvePieceStyle:n}=e,{r:a,projection:c}=o,l=[],h="horizontal"===c,d=e.config.gradientFill,u=h?"left":"bottom",g=e.config.trackFill;if(g){const e="string"==typeof g?g:g.color,t="string"==typeof g?1:g.opacity??1,[o,s]=a.range(),r=Math.min(o,s),n=Math.abs(s-o);for(const o of Object.values(i)){const i={fill:e,opacity:t},s=h?v(r,o.x,n,o.width,i,null,"__track__"):v(o.x,r,o.width,n,i,null,"__track__");l.push(s)}}const p=e.config.roundedTop&&e.config.roundedTop>0?Math.max(0,e.config.roundedTop):0;for(const e of Object.values(i)){let t=0;const o=l.length;for(const o of e.pieceData){const i=Math.abs(s(o));if(0===i)continue;const c=r?r(o):e.name,g=n(o,c);let p;if(h){const s=a(t),r=a(t+i);p=v(s,e.x,r-s,e.width,g,o,c)}else{const s=a(t+i),r=a(t);p=v(e.x,s,e.width,r-s,g,o,c)}d&&(p.fillGradient=d,p.roundedEdge=u),l.push(p),t+=i}if(p>0&&l.length>o){const e=l.slice(o),t=e[0],i=e[e.length-1];1===e.length?t.cornerRadii={tl:p,tr:p,br:p,bl:p}:h?(t.cornerRadii={tl:p,bl:p},i.cornerRadii={tr:p,br:p}):(t.cornerRadii={bl:p,br:p},i.cornerRadii={tl:p,tr:p})}}return l}},go=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],po=["scene-style","data-paint","accessibility","evidence"],fo=(e,t)=>({retainedData:e,invalidations:t}),yo=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],mo=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],xo=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],bo=["scene-geometry","data-paint","accessibility","evidence"],Ao=["scene-style","data-paint","accessibility","evidence"],vo=[],So={chartType:fo("rebuild",yo),runtimeMode:fo("rebuild",yo),categoryAccessor:fo("rebuild",yo),valueAccessor:fo("rebuild",yo),oAccessor:fo("rebuild",yo),rAccessor:fo("rebuild",yo),stackBy:fo("rebuild",yo),groupBy:fo("rebuild",yo),timeAccessor:fo("rebuild",yo),accessorRevision:fo("rebuild",yo),colorAccessor:fo("rebuild",Ao),symbolAccessor:fo("rebuild",bo),connectorAccessor:fo("rebuild",bo),dataIdAccessor:fo("rebuild",bo),projection:fo("preserve",mo),extentPadding:fo("preserve",mo),axisExtent:fo("preserve",mo),rExtent:fo("preserve",mo),oExtent:fo("preserve",mo),multiAxis:fo("preserve",mo),normalize:fo("preserve",mo),bins:fo("preserve",mo),oSort:fo("preserve",xo),barPadding:fo("preserve",xo),roundedTop:fo("preserve",xo),baselinePadding:fo("preserve",xo),innerRadius:fo("preserve",xo),cornerRadius:fo("preserve",xo),startAngle:fo("preserve",xo),sweepAngle:fo("preserve",xo),trackFill:fo("preserve",xo),showOutliers:fo("preserve",xo),showIQR:fo("preserve",xo),amplitude:fo("preserve",xo),connectorOpacity:fo("preserve",xo),showLabels:fo("preserve",xo),dynamicColumnWidth:fo("rebuild",xo),customLayout:fo("preserve",xo),layoutConfig:fo("preserve",xo),layoutMargin:fo("preserve",xo),symbolMap:fo("preserve",bo),pieceStyle:fo("preserve",Ao),summaryStyle:fo("preserve",Ao),connectorStyle:fo("preserve",Ao),gradientFill:fo("preserve",Ao),colorScheme:fo("preserve",Ao),themeCategorical:fo("preserve",Ao),themeSemantic:fo("preserve",Ao),themeSequential:fo("preserve",Ao),themeDiverging:fo("preserve",Ao),barColors:fo("preserve",Ao),decay:fo("preserve",Ao),pulse:fo("preserve",Ao),staleness:fo("preserve",Ao),layoutSelection:fo("preserve",Ao),windowSize:fo("preserve",vo),windowMode:fo("preserve",vo),clock:fo("preserve",vo),transition:fo("preserve",vo),introAnimation:fo("preserve",vo),onLayoutError:fo("preserve",vo)},wo=fo("preserve",xo),ko=class{constructor(){this.tracker=new me}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},go)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},po):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const o=new Set;for(const i of e){const e=So[i]??wo;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)o.add(t)}return{retainedData:t,invalidations:o}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}};import{quadtree as _o}from"d3-quadtree";var Mo=class{constructor(e){this.rExtent=new O,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new ko,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new so,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},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.version=0,this._dataVersion=0,this._bufferArrayCache=null,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=e,this.buffer=new j(e.windowSize),this.getO=pe(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>ge(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new O)):(this.getR=ge(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=pe(e.stackBy),this.getGroup=pe(e.groupBy),this.getColor=pe(e.colorAccessor),this.getSymbol=pe(e.symbolAccessor),this.getConnector=pe(e.connectorAccessor),this.getDataId=pe(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new j(e.windowSize))}syncPulseTimestampBuffer(){var e,t,o,i;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,o=this.timestampBuffer,i=this.currentTime(),e?null!=o&&o.capacity===t.capacity&&o.size===t.size?o:T(t,i):null)}currentTime(){return this.config.clock?.()??ne()}ingest(e){const t=this.currentTime();if(this.lastIngestTime=t,this._dataVersion++,e.bounded){this.buffer.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();e.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),P(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const o of e.inserts)L(this.buffer,o,this.timestampBuffer,t),this.categories.add(this.getO(o)),this.pushValueExtent(o)}else{this._hasStreamingData=!0;for(const o of e.inserts){const e=L(this.buffer,o,this.timestampBuffer,t);this.categories.add(this.getO(o)),this.pushValueExtent(o),null!=e&&this.evictValueExtent(e)}}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.valueAccessor||this.config.rAccessor;if(!t)return null;const o="function"==typeof t?t(e):e[t];return Array.isArray(o)&&o.length>=2?[+o[0],+o[1]]:null}computeScene(e){const{config:t,buffer:o}=this,i=this.scales,s=this.multiScales,r=this.columns;if(0===o.size)return this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(o,this.getR);const n=this.getBufferArray(),a=t.projection||"vertical",c=t.oExtent||this.resolveCategories(n),l=this.computeValueDomain(n,c),h="horizontal"===a,d="radial"===a,u=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===a?e.width:e.height):.1));let g,p;if(d){g=oo().domain(c).range([0,1]).padding(0);const o=Math.min(e.width,e.height)/2,i=t.innerRadius||0;p=io().domain(l).range([i,o])}else h?(g=oo().domain(c).range([0,e.height]).padding(u),p=io().domain(l).range([0,e.width])):(g=oo().domain(c).range([0,e.width]).padding(u),p=io().domain(l).range([e.height,0]));this.scales={o:g,r:p,projection:a},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((i,s)=>{const r=this.rExtents[s];r.dirty&&r.recalculate(o,i);let[n,a]=r.extent;n===1/0&&(n=0,a=1);const c=a-n,l=c>0?c*(t.extentPadding??.05):1;return n-=l,a+=l,n>0&&(n=0),h?io().domain([n,a]).range([0,e.width]):io().domain([n,a]).range([e.height,0])}):[];let f=n;this.rAccessors.length>1&&(f=n.flatMap(e=>this.rAccessors.map((t,o)=>({...e,__rIndex:o,__rValue:t(e),__rName:this.resolveRAccessorName(o)})))),this.columns=this.buildColumns(f,c,g,a,e),this._customLayoutFailedThisBuild=!1;const y=this.buildSceneNodes(f,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=i,this.multiScales=s,this.columns=r):(this.scene=[],this.rebuildPointQuadtree()):(this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=y,this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,n),this.config.pulse&&this.applyPulse(this.scene,n),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.startTransition(),this.version++)}resolveRAccessorName(e){const t=this.config.valueAccessor||this.config.rAccessor,o=Array.isArray(t)?t[e]:t;return"string"==typeof o?o:"value"+e}resolveCategories(e){const t=this.config.oSort,o="streaming"===this.config.runtimeMode||this._hasStreamingData,i="auto"===t?void 0:t;let s=null;if(o){s=new Set;for(const t of e)s.add(this.getO(t))}const r=s?Array.from(this.categories).filter(e=>s.has(e)):Array.from(this.categories);if(o&&void 0===i){const e=Math.max(50,3*s.size);if(this.categories.size>e){let t=this.categories.size-e;for(const e of this.categories){if(0>=t)break;s.has(e)||(this.categories.delete(e),t--)}}return r}if(!1===i)return r;if("function"==typeof i)return r.sort(i);const n=new Map;for(const t of e){const e=this.getO(t);n.set(e,(n.get(e)||0)+Math.abs(this.getR(t)))}return r.sort("asc"===i?(e,t)=>(n.get(e)||0)-(n.get(t)||0):(e,t)=>(n.get(t)||0)-(n.get(e)||0))}computeValueDomain(e,t){return function(e){const{data:t,chartType:o,projection:i,normalize:s,rExtent:r,extentPadding:n=.05,baselinePadding:a,axisExtent:c,getO:l,getR:h,getStack:d,rawRExtent:u}=e,g=n;if("radial"===i&&("pie"===o||"donut"===o))return[0,1];let p=0,f=0;if("bar"===o&&d&&s)p=0,f=1;else if("bar"===o&&d){const e=new Map,o=new Map;for(const i of t){const t=l(i),s=h(i);0>s?o.set(t,(o.get(t)||0)+s):e.set(t,(e.get(t)||0)+s)}for(const t of e.values())t>f&&(f=t);for(const e of o.values())p>e&&(p=e)}else if("bar"===o){const e=new Map;for(const o of t){const t=l(o),i=h(o);e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>f&&(f=t),p>t&&(p=t)}else if("swimlane"===o){const e=new Map;for(const o of t){const t=l(o),i=Math.abs(h(o));e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>f&&(f=t)}else if("clusterbar"===o||"bar-funnel"===o)for(const e of t){const t=h(e);t>f&&(f=t),p>t&&(p=t)}else{const e=u[0],t=u[1];e!==1/0&&(p=e),t!==-1/0&&(f=t)}r&&(null!=r[0]&&(p=r[0]),null!=r[1]&&(f=r[1]));const y="bar"===o||"clusterbar"===o||"bar-funnel"===o||"swimlane"===o;if(y&&null==r?.[0]&&null==r?.[1]&&(p>0&&(p=0),0>f&&(f=0)),"bar-funnel"!==o&&"exact"!==c){const e=f-p,t=e>0?e*g:1,i=y&&!a&&0===p,s=y&&!a&&0===f||"swimlane"===o;null!=r?.[0]||i||(p-=t),null!=r?.[1]||s||(f+=t)}return[p,f]}({data:e,chartType:this.config.chartType,projection:this.config.projection,normalize:this.config.normalize,rExtent:this.config.rExtent,extentPadding:this.config.extentPadding,baselinePadding:this.config.baselinePadding,axisExtent:this.config.axisExtent,getO:this.getO,getR:this.getR,getStack:this.getStack,rawRExtent:this.rExtent.extent})}buildColumns(e,t,o,i,s){return function(e){const{data:t,oExtent:o,oScale:i,projection:s,layout:r,dynamicColumnWidth:n,getO:a,getR:c}=e,l={},h=new Map;for(const e of t){const t=a(e);h.has(t)||h.set(t,[]),h.get(t).push(e)}let d=0;if("radial"===s)for(const e of t)d+=Math.abs(c(e));let u=null;if(n&&"radial"!==s){u=new Map;let e=0;for(const t of o){const o=h.get(t)||[];let i;i="string"==typeof n?o.reduce((e,t)=>e+(Number(t[n])||0),0):n(o),u.set(t,i),e+=i}const t=("horizontal"===s?r.height:r.width)-i.padding()*i.step()*o.length;if(e>0)for(const[o,i]of u)u.set(o,i/e*t)}let g=0,p=0;for(const e of o){const t=h.get(e)||[],o=t.reduce((e,t)=>e+Math.abs(c(t)),0),s=d>0?o/d:0;let r,n;u?(r=p,n=u.get(e)||i.bandwidth(),p+=n+i.padding()*i.step()):(r=i(e)??0,n=i.bandwidth()),l[e]={name:e,x:r,y:0,width:n,middle:r+n/2,padding:i.padding()*i.step(),pieceData:t,pct:s,pctStart:g},g+=s}return l}({data:e,oExtent:t,oScale:o,projection:i,layout:s,dynamicColumnWidth:this.config.dynamicColumnWidth,getO:this.getO,getR:this.getR})}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getSymbol:this.getSymbol,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.styleResolver.resolvePieceStyle(this.config,e,t),resolveSummaryStyle:(e,t)=>this.styleResolver.resolveSummaryStyle(this.config,e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];if(this.config.customLayout){const o=this.buildLayoutContext(e,t);let i;try{i=this.config.customLayout(o)}catch(e){const t=null!==this.lastCustomLayoutResult,o=M("ordinal",e,t,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",e);try{this.config.onLayoutError?.(o)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return t?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=i.overlays??null,this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null;const s=i.nodes??[];if(this._customRestyle=i.restyle,this.hasCustomRestyle=!!i.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const e of s)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(s,this.config.layoutSelection??null)}return E({label:"ordinal customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const o=this.getSceneContext(),i=uo[this.config.chartType];let s=i?i(o,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:o,config:i,getConnector:s,getO:r}=e;if(!s||!o)return[];const n=[],{projection:a}=o,c=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const o=s(t);if(!o)continue;let i,n;"point"===e.type?(i=e.x,n=e.y):(i=e.x+e.w/2,n=e.y+("vertical"===a?0:e.h/2)),c.has(o)||c.set(o,[]),c.get(o).push({x:i,y:n,datum:t,category:r(t)})}const l=o.o.domain(),h=i.connectorStyle;for(const[t,o]of c)if(o.length>=2){o.sort((e,t)=>l.indexOf(e.category)-l.indexOf(t.category));for(let i=0;o.length-1>i;i++){const s=o[i],r=o[i+1],a="function"==typeof h?h(s.datum):h||{stroke:e.config.themeSemantic?.border||e.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5};n.push({type:"connector",x1:s.x,y1:s.y,x2:r.x,y2:r.y,style:a,datum:s.datum,group:t})}}return n}(o,s);s=[...e,...s]}return s}buildLayoutContext(e,t){const o=this.config,i=o.layoutMargin??{top:0,right:0,bottom:0,left:0},s=le(o.colorScheme,o.themeCategorical,$),r=this.scales;return{data:e,scales:{o:r.o,r:r.r,projection:r.projection},dimensions:{width:t.width,height:t.height,margin:i,plot:"radial"===r.projection?{x:-t.width/2,y:-t.height/2,width:t.width,height:t.height}:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:o.themeSemantic??{},categorical:[...s]},resolveColor:Y(s,o.colorScheme),config:o.layoutConfig??{},selection:o.layoutSelection??null}}computeDecayOpacity(e,t){const o=this.config.decay;return o&&t>1?k(o,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=A(e);return this._datumIndexCache={version:this._dataVersion,map:t},t}getCategoryIndexMap(e){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const t=function(e,t){const o="function"==typeof t,i=o?null:t||"category",s=new Map;for(let r=0;e.length>r;r++){const n=e[r],a=o?t(n):n[i],c=s.get(a);c?c.push(r):s.set(a,[r])}return s}(e,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:t},t}rebuildPointQuadtree(){const e=function(e){let t=0,o=0;for(const i of e)"point"===i.type&&(t++,i.r>o&&(o=i.r));if(500>=t)return{quadtree:null,maxRadius:o};const i=Array(t);let s=0;for(const t of e)"point"===t.type&&(i[s++]=t);return{maxRadius:o,quadtree:_o().x(e=>e.x).y(e=>e.y).addAll(i)}}(this.scene);this._pointQuadtree=e.quadtree,this._maxPointRadius=e.maxRadius}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(e,t){if(!this.config.decay)return;const o=t.length;if(1>=o)return;const i=this.getDatumIndexMap(t);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;if(!t.datum)continue;const e=i.get(t.datum);if(null==e)continue;const s=this.computeDecayOpacity(e,o);t.style={...t.style,opacity:(t.style?.opacity??1)*s}}}applyPulse(e,t,o=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,o,i,s,r){const n=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let c=!1;for(const l of t){if("connector"===l.type||"violin"===l.type||"boxplot"===l.type)continue;if("wedge"===l.type){const t=l.category;if(!t)continue;let i=0;for(const n of s(t)??[]){const t=o.get(n);null!=t&&(i=Math.max(i,_(e,t,r)))}c=C(l,i,n)||c;continue}if(null==l.datum)continue;const t=i.get(l.datum);if(null==t)continue;const h=o.get(t),d=null==h?0:_(e,h,r);c=C(l,d,n,a)||c}return c}(this.config.pulse,e,this.timestampBuffer,this.getDatumIndexMap(t),e=>this.getCategoryIndexMap(t).get(e),o)}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&z(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}synthesizeIntroPositions(){this.prevPositionMap.clear();const e=new Map,t=this.scales?.r(0)??0,o="horizontal"!==this.scales?.projection;let i;for(let s=0;this.scene.length>s;s++){const r=this.scene[s],n=this.getNodeKey(r,e);n&&("rect"===r.type?this.prevPositionMap.set(n,o?{x:r.x,y:t,w:r.w,h:0,opacity:r.style.opacity??1}:{x:t,y:r.y,w:0,h:r.h,opacity:r.style.opacity??1}):"point"===r.type?this.prevPositionMap.set(n,{x:r.x,y:r.y,r:0,opacity:0}):"wedge"===r.type&&(void 0===i&&(i=r.startAngle),this.prevPositionMap.set(n,{x:r.cx,y:r.cy,startAngle:i,endAngle:i,innerRadius:r.innerRadius,outerRadius:r.outerRadius,opacity:0})))}}getNodeKey(e,t){if("point"===e.type){const o=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,i=t.get(o)||0;return t.set(o,i+1),`${o}:${i}`}return"rect"===e.type?`r:${e.group||""}:${e.datum?.category??""}`:"wedge"===e.type?"w:"+(e.category??""):null}snapshotPositions(){this.prevPositionMap.clear();const e=new Map;for(let t=0;this.scene.length>t;t++){const o=this.scene[t],i=this.getNodeKey(o,e);i&&("point"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"rect"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"wedge"===o.type&&this.prevPositionMap.set(i,{x:o.cx,y:o.cy,startAngle:o.startAngle,endAngle:o.endAngle,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:o.style.opacity??1}))}}startTransition(){if(!this.config.transition||0===this.prevPositionMap.size)return;const e=this.config.transition.duration??300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let t=!1;const o=new Set,i=new Map;for(let e=0;this.scene.length>e;e++){const s=this.scene[e],r=this.getNodeKey(s,i);if(!r)continue;s._transitionKey=r;const n=this.prevPositionMap.get(r);if("point"===s.type)n?(o.add(r),s._targetOpacity=s.style.opacity??1,(n.x!==s.x||n.y!==s.y||void 0!==n.r&&n.r!==s.r)&&(s._targetX=s.x,s._targetY=s.y,s._targetR=s.r,s.x=n.x,s.y=n.y,void 0!==n.r&&(s.r=n.r),t=!0)):(s._targetOpacity=s.style.opacity??1,s._targetR=s.r,s.r=0,s.style={...s.style,opacity:0},t=!0);else if("rect"===s.type)n?(o.add(r),s._targetOpacity=s.style.opacity??1,n.x===s.x&&n.y===s.y&&n.w===s.w&&n.h===s.h||(s._targetX=s.x,s._targetY=s.y,s._targetW=s.w,s._targetH=s.h,s.x=n.x,s.y=n.y,s.w=n.w??s.w,s.h=n.h??s.h,t=!0)):(s._targetOpacity=s.style.opacity??1,s.style={...s.style,opacity:0},t=!0);else if("wedge"===s.type)if(n)o.add(r),s._targetOpacity=s.style.opacity??1,n.startAngle===s.startAngle&&n.endAngle===s.endAngle||(s._targetStartAngle=s.startAngle,s._targetEndAngle=s.endAngle,s.startAngle=n.startAngle,s.endAngle=n.endAngle,t=!0);else{s._targetOpacity=s.style.opacity??1,s._targetStartAngle=s.startAngle,s._targetEndAngle=s.endAngle;const e=s.startAngle;s.startAngle=e,s.endAngle=e,s.style={...s.style,opacity:0},this.prevPositionMap.set(r,{x:s.cx,y:s.cy,startAngle:e,endAngle:e,innerRadius:s.innerRadius,outerRadius:s.outerRadius,opacity:0}),t=!0}}this.exitNodes=[];for(const[e,i]of this.prevPositionMap)if(!o.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:i.x,y:i.y,r:i.r??3,style:{opacity:i.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:i.x,y:i.y,w:i.w??0,h:i.h??0,style:{opacity:i.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){const t=((i.startAngle??0)+(i.endAngle??0))/2,o={type:"wedge",cx:i.x,cy:i.y,innerRadius:i.innerRadius??0,outerRadius:i.outerRadius??100,startAngle:i.startAngle??0,endAngle:i.endAngle??0,style:{opacity:i.opacity??1},datum:null,category:e.slice(2),_targetStartAngle:t,_targetEndAngle:t,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(o)}t=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),t&&(this.activeTransition={startTime:this.currentTime(),duration:e})}advanceTransition(e){if(!this.activeTransition)return!1;const t=X(e,this.activeTransition),o=H(t,"linear"===this.config.transition?.easing?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style.opacity=oe(i?i.opacity??1:0,e._targetOpacity,o)}const i=this.prevPositionMap.get(t);void 0!==e._targetX&&i&&(e.x=oe(i.x,e._targetX,o),e.y=oe(i.y,e._targetY,o)),void 0!==e._targetR&&void 0!==i?.r&&(e.r=oe(i.r,e._targetR,o))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style.opacity=oe(i?i.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;const i=this.prevPositionMap.get(t);if(!i)continue;e.x=oe(i.x,e._targetX,o),e.y=oe(i.y,e._targetY,o),void 0!==i.w&&(e.w=oe(i.w,e._targetW,o),e.h=oe(i.h,e._targetH,o))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style={...e.style,opacity:oe(i?i.opacity??1:0,e._targetOpacity,o)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){const i=this.prevPositionMap.get(t);i&&void 0!==i.startAngle&&(e.startAngle=oe(i.startAngle,e._targetStartAngle,o),e.endAngle=oe(i.endAngle,e._targetEndAngle,o))}}}if(t>=1){for(const e of this.scene)if(void 0!==e._targetOpacity&&(e.style={...e.style||{},opacity:0===e._targetOpacity?0:e._targetOpacity},e._targetOpacity=void 0),"point"===e.type){if(void 0===e._targetX&&void 0===e._targetR)continue;void 0!==e._targetX&&(e.x=e._targetX,e.y=e._targetY),void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else"wedge"===e.type&&void 0!==e._targetStartAngle&&(e.startAngle=e._targetStartAngle,e.endAngle=e._targetEndAngle,e._targetStartAngle=void 0,e._targetEndAngle=void 0);if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null}getBufferArray(){return this._bufferArrayCache?.version!==this._dataVersion&&(this._bufferArrayCache={version:this._dataVersion,data:this.buffer.toArray()}),this._bufferArrayCache.data}getData(){return this.buffer.toArray()}remove(e){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=D(e),o=this.getDataId,i=e=>t.has(o(e));w(this.buffer,this.timestampBuffer,i);const s=this.buffer.remove(i);if(0===s.length)return this.updateResults.recordNoop("remove"),s;for(const e of s)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",s.length),s}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const o=D(e),i=this.getDataId,s=new Set;this.buffer.forEach((e,t)=>{o.has(i(e))&&s.add(t)});const r=this.buffer.update(e=>o.has(i(e)),t);if(0===r.length)return this.updateResults.recordNoop("update"),r;for(const e of r)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),s.has(t)&&this.pushValueExtent(e)}),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",r.length),r}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.multiScales=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._pointQuadtree=null,this._maxPointRadius=0,this.styleResolver.resetColors(),this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}applyCustomRestyle(e,t){const o=this._customRestyle;if(o)for(const i of e){const e=this._baseStyles.get(i)??i.style??{},s=o(i,t);i.style=s?{...e,...s}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();this._categoryIndexCache=null,this.buffer.forEach(e=>{this.categories.add(this.getO(e)),this.pushValueExtent(e)})}updateConfig(e){const t={...this.config},o=Object.keys(e).filter(o=>e[o]!==t[o]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e&&e.colorScheme!==t.colorScheme||"themeCategorical"in e&&e.themeCategorical!==t.themeCategorical||"colorAccessor"in e&&!ue(e.colorAccessor,t.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!ue(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!ue(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let i=!1;("categoryAccessor"in e||"oAccessor"in e)&&(ue(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=pe(this.config.categoryAccessor||this.config.oAccessor,"category"),i=!0));let s=!1;if("valueAccessor"in e||"rAccessor"in e){const e=this.config.valueAccessor||this.config.rAccessor,o=t.valueAccessor||t.rAccessor,i=Array.isArray(e)?e:[e],r=Array.isArray(o)?o:[o];if(s=i.length!==r.length||i.some((e,t)=>!ue(e,r[t])),s){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>ge(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new O)):(this.getR=ge(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!ue(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?pe(this.config.stackBy):void 0),"groupBy"in e&&!ue(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?pe(this.config.groupBy):void 0),"colorAccessor"in e&&!ue(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?pe(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!ue(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?pe(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!ue(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?pe(this.config.connectorAccessor):void 0),(i||s||"accessorRevision"in e&&e.accessorRevision!==t.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(o)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};b(Mo);import{jsx as To,jsxs as Po}from"react/jsx-runtime";import{Fragment as Ro,jsx as zo,jsxs as Lo}from"react/jsx-runtime";function Fo(e,t){const o=ft(e.theme),i=e.size||[500,400],s=ce({top:20,right:20,bottom:30,left:40,...e.margin},e.title),r=J(e.title),n=Q(e.data),a=e.showLegend?Ft(n,e.colorAccessor||e.stackBy||e.groupBy):[],c=e.legendPosition;te(e.legend)||ee(e.legend)?Ht(s,{legend:e.legend,theme:o,position:c||"right",size:i,hasTitle:r,legendLayout:e.legendLayout}):e.showLegend&&a.length>0&&Yt(s,{categories:a,colorScheme:e.colorScheme,theme:o,position:c||"right",size:i,hasTitle:r,legendLayout:e.legendLayout});const l=i[0]-s.left-s.right,h=i[1]-s.top-s.bottom,d=e.projection||"vertical",u="radial"===d,g={chartType:e.chartType,windowSize:e.windowSize??1e4,windowMode:e.windowMode??"sliding",extentPadding:e.extentPadding??.05,projection:d,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,axisExtent:e.axisExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,gradientFill:e.gradientFill,symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,multiAxis:e.multiAxis,baselinePadding:e.baselinePadding,trackFill:e.trackFill,connectorOpacity:e.connectorOpacity,showLabels:e.showLabels,colorScheme:e.colorScheme||o.colors.categorical,themeCategorical:o.colors.categorical,themeSemantic:ze(o),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:s,layoutSelection:e.layoutSelection,barColors:e.barColors},p=new Mo(g);if(e.data&&p.ingest({inserts:n,bounded:!0}),p.computeScene({width:l,height:h}),!p.scales||0===p.scene.length)return t&&(t.evidence=bt({frameType:"ordinal",width:i[0],height:i[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:p.scales?[]:["NO_SCALES"]})),to.renderToStaticMarkup(Qt(null,{width:i[0],height:i[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:h,idPrefix:e._idPrefix}));if(t){const o=p.scales.o?.domain?.();t.evidence=bt({frameType:"ordinal",width:i[0],height:i[1],marks:p.scene,title:e.title,description:e.description,annotations:e.annotations,yDomain:xt(p.scales.r?.domain?.()),categories:Array.isArray(o)?o.map(String):void 0})}const f=e._idPrefix,y=e.showGrid?function(e,t,o,i,s){const r=e.scales;if(!r||"radial"===r.projection)return null;const{grid:n}=yt(o),a=i?i+"-":"",c="vertical"===r.projection,l=B(r.r,5,s);return It("g",c?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const i=r.r(e);return It("line",{x1:0,y1:i,x2:t.width,y2:i,stroke:n,strokeWidth:.5},"gr-"+o)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const i=r.r(e);return It("line",{x1:i,y1:0,x2:i,y2:t.height,stroke:n,strokeWidth:.5},"gr-"+o)})})}(p,{width:l,height:h},o,f,e.axisExtent):null;let m=null;if(p.scene.some(e=>"rect"===e.type&&e.datum?.__barFunnelIsDropoff)){const t=function(e){const t=e._idPrefix||e.chartId;if(t){const e=(t+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(e)?e:"c"+e}const o=`${e.chartType||""}:${e.title||""}:${Array.isArray(e.data)?e.data.length:0}`;let i=0;for(let e=0;o.length>e;e++)i=31*i+o.charCodeAt(e)|0;return"c"+(i>>>0).toString(36)}(e),i=new Set;for(const e of p.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&i.add("string"==typeof e.style.fill?e.style.fill:"#666");m=Array.from(i).map((e,i)=>function(e){const{id:t,background:o="transparent",stroke:i="#000",lineWidth:s=1.5,spacing:r=6,angle:n=45}=e,a=Math.max(8,Math.ceil(2*r));return Po("pattern",{id:t,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==n?`rotate(${n})`:void 0,children:[o&&"transparent"!==o&&To("rect",{width:a,height:a,fill:o}),To("line",{x1:0,y1:0,x2:0,y2:a,stroke:i,strokeWidth:s}),To("line",{x1:r,y1:0,x2:r,y2:a,stroke:i,strokeWidth:s})]},t)}({id:`funnel-hatch-${t}-${i}`,background:e,stroke:"transparent"===o.colors.background?"#fff":o.colors.background,lineWidth:1.5,spacing:5,angle:45}));const s=new Map;Array.from(i).forEach((e,o)=>s.set(e,`funnel-hatch-${t}-${o}`));for(const e of p.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&(e.style={...e.style,fill:`url(#${s.get("string"==typeof e.style.fill?e.style.fill:"#666")})`})}const x=p.scene.map((t,o)=>F({node:t,index:o,renderMode:e.renderMode,fallback:()=>ae(t,o,f)})).filter(Boolean),b=!1!==e.showAxes?function(e,t,o,i,s){const r=e.scales;if(!r)return null;if("radial"===r.projection)return null;const n=yt(i),a="vertical"===r.projection,c=o.categoryFormat||o.oFormat,l=o.valueFormat||o.rFormat,h=o.categoryLabel||o.oLabel,d=o.valueLabel||o.rLabel,u=Object.values(e.columns).map(e=>({pixel:e.middle,label:(c||String)(e.name)})),g=B(r.r,5,o.axisExtent).map(e=>({pixel:r.r(e),label:(l||qt)(e)}));return Lo("g",a?{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[zo("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:n.border,strokeWidth:1}),u.map((e,o)=>Lo("g",{transform:`translate(${e.pixel},${t.height})`,children:[zo("line",{y2:5,stroke:n.border,strokeWidth:1}),zo("text",{y:18,textAnchor:"middle",fontSize:n.tickSize,fill:n.textSecondary,fontFamily:n.fontFamily,children:e.label})]},"oxtick-"+o)),h&&zo("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:n.labelSize,fill:n.text,fontFamily:n.fontFamily,children:h}),zo("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:n.border,strokeWidth:1}),g.map((e,t)=>Lo("g",{transform:`translate(0,${e.pixel})`,children:[zo("line",{x2:-5,stroke:n.border,strokeWidth:1}),zo("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n.tickSize,fill:n.textSecondary,fontFamily:n.fontFamily,children:e.label})]},"oytick-"+t)),d&&zo("text",{x:15-(o.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:n.labelSize,fill:n.text,fontFamily:n.fontFamily,transform:`rotate(-90, ${15-(o.margin?.left??40)}, ${t.height/2})`,children:d})]}:{id:(s?s+"-":"")+"axes",className:"ordinal-axes",children:[zo("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:n.border,strokeWidth:1}),g.map((e,o)=>Lo("g",{transform:`translate(${e.pixel},${t.height})`,children:[zo("line",{y2:5,stroke:n.border,strokeWidth:1}),zo("text",{y:18,textAnchor:"middle",fontSize:n.tickSize,fill:n.textSecondary,fontFamily:n.fontFamily,children:e.label})]},"oxtick-"+o)),d&&zo("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:n.labelSize,fill:n.text,fontFamily:n.fontFamily,children:d}),zo("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:n.border,strokeWidth:1}),u.map((e,t)=>Lo("g",{transform:`translate(0,${e.pixel})`,children:[zo("line",{x2:-5,stroke:n.border,strokeWidth:1}),zo("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n.tickSize,fill:n.textSecondary,fontFamily:n.fontFamily,children:e.label})]},"oytick-"+t)),h&&zo("text",{x:15-(o.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:n.labelSize,fill:n.text,fontFamily:n.fontFamily,transform:`rotate(-90, ${15-(o.margin?.left??40)}, ${t.height/2})`,children:h})]})}(p,{width:l,height:h},e,o,f):null,A=e.annotations?Wt({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{o:p.scales.o,r:p.scales.r,y:"vertical"===p.scales.projection?p.scales.r:void 0},layout:{width:l,height:h},theme:o,projection:d,idPrefix:f}):null,v=e.showLegend?0===a.length?null:Lt({categories:a,colorScheme:e.colorScheme,theme:o,position:e.legendPosition||"right",totalWidth:i[0],totalHeight:i[1],margin:s,hasTitle:r,legendLayout:e.legendLayout}):null,S=eo.isValidElement(e.legend)?e.legend:Xt(e.legend,{theme:o,position:e.legendPosition||"right",size:i,margin:s,hasTitle:r,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||v,w=u?s.left+l/2:s.left,k=u?s.top+h/2:s.top;return to.renderToStaticMarkup(Qt(Lo(Ro,{children:[e.backgroundGraphics,y,x,b,A,e.foregroundGraphics,p.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${w},${k})`,innerWidth:l,innerHeight:h,legend:S,defs:m,idPrefix:e._idPrefix}))}import*as Co from"react";import*as Bo from"react-dom/server";import{Fragment as Do,jsxs as Eo}from"react/jsx-runtime";function Oo(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}var jo=new Set(["tree","cluster","treemap","circlepack","partition"]);function No(e,t){const o=ft(e.theme),i=e.chartType||"force",s=()=>bt({frameType:"network",width:r[0],height:r[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,nodeCount:0,edgeCount:0}),r=e.size||[500,500],n=ce({top:20,right:20,bottom:20,left:20,...e.margin},e.title),a=J(e.title),c=e.showLegend?(()=>{const t="string"==typeof(o=e.colorBy)||"function"==typeof o?e.colorBy:void 0;var o;if(!t)return[];const i=Q(e.nodes||[]);if(i.length>0)return Ft(i,t);const s=Array.isArray(e.edges)?Q(e.edges):[];if(0===s.length)return[];const r=Oo(e.sourceAccessor,"source"),n=Oo(e.targetAccessor,"target");return Ft(Array.from(new Set(s.flatMap(e=>[r(e),n(e)]).filter(e=>null!=e).map(String))).map(e=>({id:e})),t)})():[],l=e.legendPosition;te(e.legend)||ee(e.legend)?Ht(n,{legend:e.legend,theme:o,position:l||"right",size:r,hasTitle:a,legendLayout:e.legendLayout}):e.showLegend&&c.length>0&&Yt(n,{categories:c,colorScheme:e.colorScheme,theme:o,position:l||"right",size:r,hasTitle:a,legendLayout:e.legendLayout});const h=r[0]-n.left-n.right,d=r[1]-n.top-n.bottom,u=R(i);if(!u&&!e.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${i}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const g={chartType:i,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,colorBy:e.colorBy,colorScheme:e.colorScheme||o.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig};let p,f;if(jo.has(i)){const i=e.data||e.edges;if(!i||Array.isArray(i))return t&&(t.evidence=s()),Bo.renderToStaticMarkup(Qt(null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${n.left},${n.top})`,innerWidth:h,innerHeight:d,idPrefix:e._idPrefix}));g.__hierarchyRoot=i,p=[],f=[]}else{const i=Q(e.nodes||[]),a=Array.isArray(e.edges)?Q(e.edges):[];if(0===i.length&&0===a.length)return t&&(t.evidence=s()),Bo.renderToStaticMarkup(Qt(null,{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${n.left},${n.top})`,innerWidth:h,innerHeight:d,idPrefix:e._idPrefix}));if(f=function(e,t){const o=Oo(t.sourceAccessor,"source"),i=Oo(t.targetAccessor,"target"),s=Oo(t.valueAccessor,"value");return e.map(e=>({source:o(e)+"",target:i(e)+"",value:Number(s(e))||1,y0:0,y1:0,sankeyWidth:0,data:e}))}(a,g),0===i.length&&f.length>0){const e=new Set;for(const t of f){const o=Vt(t.source),i=Vt(t.target);o&&e.add(o),i&&e.add(i)}p=Array.from(e).map(e=>({id:e,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:e}}))}else p=function(e,t){const o=Oo(t.nodeIDAccessor,"id");return e.map(e=>({id:o(e)+"",x:e.x??0,y:e.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:e}))}(i,g)}let y=[],m=[],x=[],b=null;if(g.customNetworkLayout){const e=g.colorScheme,t=le(e,o.colors.categorical,ve),i=Y(t,e),s={nodes:p,edges:f,dimensions:{width:h,height:d,plot:{x:0,y:0,width:h,height:d}},theme:{semantic:o.colors,categorical:[...t]},resolveColor:i,config:g.layoutConfig??{}},r=g.customNetworkLayout(s);y=r.sceneNodes??[],m=r.sceneEdges??[],x=r.labels??[],b=r.overlays??null}else if(u){u.computeLayout(p,f,g,[h,d]);const e=u.buildScene(p,f,g,[h,d]);y=e.sceneNodes,m=e.sceneEdges,x=e.labels}const A=yt(o);for(const e of x)e.fill||(e.fill=A.text);t&&(t.evidence=bt({frameType:"network",width:r[0],height:r[1],marks:[...y.map(e=>({type:"node:"+(e.type??"node")})),...m.map(e=>({type:"edge:"+(e.type??"edge")}))],title:e.title,description:e.description,annotations:e.annotations,nodeCount:y.length,edgeCount:m.length}));const v=m.map((t,o)=>F({node:t,index:o,renderMode:e.renderMode,fallback:()=>se(t,o)})).filter(Boolean),S=y.map((t,o)=>F({node:t,index:o,renderMode:e.renderMode,fallback:()=>re(t,o)})).filter(Boolean),w=x.map((e,t)=>ie(e,t)).filter(Boolean),k=e.annotations?Wt({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{},layout:{width:h,height:d},theme:o,idPrefix:e._idPrefix}):null,_=e.showLegend?(()=>{const t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;if(!t)return[];const s=Ft(p.length>0?p.map(e=>e.data||{id:e.id}):Array.from(new Set(f.flatMap(e=>[Vt(e.source),Vt(e.target)]).filter(Boolean))).map(e=>({id:e})),t);return 0===s.length?null:Lt({categories:s,colorScheme:e.colorScheme,theme:o,position:e.legendPosition||"right",totalWidth:r[0],totalHeight:r[1],margin:n,hasTitle:a,legendLayout:e.legendLayout})})():null,M=Co.isValidElement(e.legend)?e.legend:Xt(e.legend,{theme:o,position:e.legendPosition||"right",size:r,margin:n,hasTitle:a,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||_;return Bo.renderToStaticMarkup(Qt(Eo(Do,{children:[e.backgroundGraphics,v,S,w,k,e.foregroundGraphics,b]}),{width:r[0],height:r[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${n.left},${n.top})`,innerWidth:h,innerHeight:d,legend:M,idPrefix:e._idPrefix}))}import*as Wo from"react";import*as $o from"react-dom/server";import{geoPath as Io}from"d3-geo";import{quadtree as Go}from"d3-quadtree";import{geoMercator as Vo,geoEqualEarth as Yo,geoAlbersUsa as Ho,geoOrthographic as Xo,geoNaturalEarth1 as qo,geoEquirectangular as Qo}from"d3-geo";var Zo={mercator:Vo,equalEarth:Yo,albersUsa:Ho,orthographic:Xo,naturalEarth:qo,equirectangular:Qo};function Uo(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function Ko(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function Jo(e,t,o){return e?"function"==typeof e?{...o,...e(t)}:{...o,...e}:{...o}}function ei(e,t){if(2>e.length)return[e];const o=.4*t,i=[];let s=[e[0]];for(let t=1;e.length>t;t++){const r=e[t];Math.abs(r[0]-e[t-1][0])>o?(2>s.length||i.push(s),s=[r]):s.push(r)}return 2>s.length||i.push(s),i}function ti(e,t,o=24){const i=t[0]-e[0],s=t[1]-e[1],r=Math.sqrt(i*i+s*s);if(0===r)return[e,t];const n=-s/r,a=i/r,c=Math.min(.3*r,80),l=(e[0]+t[0])/2+n*c,h=(e[1]+t[1])/2+a*c,d=[];for(let i=0;o>=i;i++){const s=i/o,r=1-s;d.push([r*r*e[0]+2*r*s*l+s*s*t[0],r*r*e[1]+2*r*s*h+s*s*t[1]])}return d}function oi(e,t){if(2>e.length)return e;const o=t/2+1,i=[];for(let t=0;e.length>t;t++){const s=e[t];let r,n;0===t?(r=e[1][0]-s[0],n=e[1][1]-s[1]):t===e.length-1?(r=s[0]-e[t-1][0],n=s[1]-e[t-1][1]):(r=e[t+1][0]-e[t-1][0],n=e[t+1][1]-e[t-1][1]);const a=Math.sqrt(r*r+n*n)||1;i.push([s[0]+n/a*o,s[1]+-r/a*o])}return i}function ii(e,t,o,i,s){const r=t[0]-e[0],n=t[1]-e[1],a=Math.sqrt(r*r+n*n);if(0===a)return[e,t];const c=n/a,l=-r/a,h=s/2+1;return[[e[0]+c*h,e[1]+l*h],[t[0]+c*h,t[1]+l*h]]}import{scaleLinear as si}from"d3-scale";var ri=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ni=["scene-style","data-paint","accessibility","evidence"],ai=(e,t)=>({retainedData:e,invalidations:t}),ci=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],li=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],hi=["scene-geometry","data-paint","accessibility","evidence"],di=["scene-style","data-paint","accessibility","evidence"],ui=["overlay","accessibility","evidence"],gi=[],pi={xAccessor:ai("rebuild",ci),yAccessor:ai("rebuild",ci),lineDataAccessor:ai("rebuild",ci),pointIdAccessor:ai("rebuild",hi),lineIdAccessor:ai("rebuild",hi),windowSize:ai("rebuild",ci),projection:ai("preserve",li),projectionExtent:ai("preserve",li),fitPadding:ai("preserve",li),lineType:ai("preserve",li),flowStyle:ai("preserve",li),graticule:ai("preserve",li),projectionTransform:ai("preserve",li),customLayout:ai("preserve",li),layoutConfig:ai("preserve",li),layoutMargin:ai("preserve",li),areaStyle:ai("preserve",di),pointStyle:ai("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:ai("preserve",di),colorScheme:ai("preserve",di),themeCategorical:ai("preserve",di),themeDiverging:ai("preserve",di),themeSemantic:ai("preserve",di),themeSequential:ai("preserve",di),decay:ai("preserve",di),pulse:ai("preserve",di),layoutSelection:ai("preserve",di),annotations:ai("preserve",ui),autoPlaceAnnotations:ai("preserve",ui),clock:ai("preserve",gi),transition:ai("preserve",gi),introAnimation:ai("preserve",gi),onLayoutError:ai("preserve",gi)},fi=ai("preserve",li),yi=class{constructor(){this.tracker=new me}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},ri)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},ni):this.recordNoop("restyle")}recordConfig(e,t={}){const o=function(e){let t="preserve";const o=new Set;for(const i of e){const e=pi[i]??fi;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)o.add(t)}return{retainedData:t,invalidations:o}}(e),i=new Set(o.invalidations);return t.retainedDataChanged&&i.add("data"),this.tracker.record({kind:"config",keys:e},i)}};import{geoDistance as mi,geoGraticule as xi,geoInterpolate as bi}from"d3-geo";function Ai(e){if(null==e)return 0;if("number"==typeof e&&Number.isFinite(e)&&e>=0&&.5>e)return e;throw new RangeError(`[semiotic] fitPadding must be a finite fraction in [0, 0.5); received ${e+""}.`)}var vi=class e{constructor(e){this.updateResults=new yi,this.scene=[],this.scales=null,this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=function(e){return{...e,fitPadding:Ai(e.fitPadding)}}(e)}currentTime(){return this.config.clock?.()??ne()}getConfiguredWindowSize(){const e=this.config.windowSize??500;if(!Number.isInteger(e)||1>e)throw Error("GeoPipelineStore windowSize must be a positive integer");return e}retainNewestLines(e=this.getConfiguredWindowSize()){this.lineData.length>e&&(this.lineData=this.lineData.slice(-e))}resizeStreamingWindow(e){if(this.pointBuffer){const t=this.pointBuffer.toArray(),o=this.timestampBuffer?.toArray()??[],i=t.slice(-e),s=o.slice(-i.length),r=this.currentTime();this.pointBuffer=new j(e),this.timestampBuffer=new j(e),i.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(s[t]??r)})}this.retainNewestLines(e)}updateConfig(e){const t=function(e){return"fitPadding"in e?{...e,fitPadding:Ai(e.fitPadding)}:e}(e),o=this.config,i=this.getConfiguredWindowSize(),s=Object.keys(t).filter(e=>t[e]!==o[e]);this.config={...this.config,...t};const r=this.getConfiguredWindowSize(),n=this.streaming&&r!==i;n&&(this.resizeStreamingWindow(r),this.version++),"customLayout"in t&&!t.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(s,{retainedDataChanged:n})}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setAreas(e){this.areas=e,this.updateResults.recordData("replace",e.length)}setAreasWithResult(e){return this.setAreas(e),this.updateResults.last}setPoints(e){this.pointData=e.slice(),this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.updateResults.recordData("replace",e.length)}setPointsWithResult(e){return this.setPoints(e),this.updateResults.last}setLines(e){this.lineData=e.slice(),this.streaming&&this.retainNewestLines(),this.updateResults.recordData("replace",e.length)}setLinesWithResult(e){return this.setLines(e),this.updateResults.last}initStreaming(e){void 0!==e&&e!==this.config.windowSize&&(this.config={...this.config,windowSize:e});const t=this.getConfiguredWindowSize(),o=this.pointBuffer?this.pointBuffer.toArray():this.pointData,i=this.timestampBuffer?.toArray()??[],s=o.slice(-t),r=i.slice(-s.length),n=this.currentTime();this.pointBuffer=new j(t),this.timestampBuffer=new j(t),s.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(r[t]??n)}),this.pointData=[],this.retainNewestLines(t),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();const t=this.currentTime();L(this.pointBuffer,e,this.timestampBuffer,t),this.lastIngestTime=t,this.updateResults.recordData("ingest",1)}pushPointWithResult(e){return this.pushPoint(e),this.updateResults.last}pushMany(e){this.pointBuffer||this.initStreaming();const t=this.currentTime();for(const o of e)L(this.pointBuffer,o,this.timestampBuffer,t);this.lastIngestTime=t,this.updateResults.recordData("ingest",e.length)}pushManyWithResult(e){return this.pushMany(e),this.updateResults.last}pushLine(e){null!=e&&"object"==typeof e?(this.streaming||this.initStreaming(),this.lineData.push(e),this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",1)):this.updateResults.recordNoop("ingest")}pushManyLines(e){if(!Array.isArray(e)||0===e.length)return void this.updateResults.recordNoop("ingest");const t=e.filter(e=>null!=e&&"object"==typeof e);if(0!==t.length){this.streaming||this.initStreaming();for(const e of t)this.lineData.push(e);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",t.length)}else this.updateResults.recordNoop("ingest")}removeLine(e){const{lineIdAccessor:t}=this.config;if(!t)throw Error("removeLine() requires lineIdAccessor to be configured");const o="function"==typeof t?t:e=>e[t],i=new Set(Array.isArray(e)?e:[e]),s=[];return this.lineData=this.lineData.filter(e=>!i.has(o(e)+"")||(s.push(e),!1)),s.length>0?(this.version++,this.updateResults.recordData("remove",s.length)):this.updateResults.recordNoop("remove"),s}getLines(){return this.lineData.slice()}removePoint(e){const{pointIdAccessor:t}=this.config;if(!t)throw Error("removePoint() requires pointIdAccessor to be configured");const o="function"==typeof t?t:e=>e[t],i=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){const e=e=>i.has(o(e)+"");w(this.pointBuffer,this.timestampBuffer,e);const t=this.pointBuffer.remove(e);return t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}{const e=[];return this.pointData=this.pointData.filter(t=>!i.has(o(t)+"")||(e.push(t),!1)),e.length>0?(this.version++,this.updateResults.recordData("remove",e.length)):this.updateResults.recordNoop("remove"),e}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++,this.updateResults.recordData("clear")}restyleScene(e){const t=this._customRestyle;if(t){for(const o of this.scene){const i=this._baseStyles.get(o)??o.style,s=t(o,e);o.style=s?{...i,...s}:i}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(e){const{config:t}=this,o=this.projection,i=this.geoPath,s=this.scales,r=this.baseScale,n=[...this.baseTranslate],a=[...this.baseRotation],c=this.scene;this.projection=function(e){if(!e)return Yo();if("string"==typeof e){const t=Zo[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),Yo())}if("object"==typeof e&&"type"in e){const t=Zo[e.type],o=t?t():Yo();return e.rotate&&"rotate"in o&&o.rotate(e.rotate),e.center&&"center"in o&&o.center(e.center),o}return e}(t.projection),this.geoPath=Io(this.projection),this.fitProjection(e),this.geoPath=Io(this.projection);const l=this.projection;this.scales={projection:l,geoPath:this.geoPath,projectedPoint:(e,t)=>l([e,t]),invertedPoint:(e,t)=>l.invert?l.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const h=this.buildSceneNodes(e);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=o,this.geoPath=i,this.scales=s,this.baseScale=r,this.baseTranslate=n,this.baseRotation=a):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=h,this.rebuildQuadtree(),t.projectionTransform&&this.applyCartogramTransform(t.projectionTransform,e),t.decay&&this.streaming&&this.applyDecay(),t.pulse&&this.streaming&&this.applyPulse(),t.transition&&!this._hasRenderedOnce&&this.scene.length>0&&t.introAnimation){const t=e.width/2,o=e.height/2,i=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:o}));i.length>0&&this.startTransition(i)}this._hasRenderedOnce=!0,t.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(e){const t=this.projection,o=this.config,i=[...this.areas],s=Uo(o.xAccessor,"lon"),r=Uo(o.yAccessor,"lat"),n=this.getPoints();if(n.length>0){const e=n.map(e=>[s(e),r(e)]);i.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const a=Ko(o.lineDataAccessor);for(const e of this.lineData){const t=a(e);if(t&&t.length>0){const e=t.map(e=>[s(e),r(e)]);i.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==i.length){if(o.projectionExtent){const[[i,s],[r,n]]=o.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[i,s],[r,s],[r,n],[i,n],[i,s]]]}})}else if(t.clipAngle&&(t.clipAngle()??0)>0){const i=o.fitPadding??0,s=Math.min(e.width,e.height);t.scale(s/2-s*i),t.translate([e.width/2,e.height/2])}else{const s=o.fitPadding??0,r=e.width*s,n=e.height*s;t.fitExtent([[r,n],[e.width-r,e.height-n]],{type:"FeatureCollection",features:i})}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){const o=this.projection;if(!o)return;const i=this.geoPath,s=this.scales,r=o.scale(),n=[...o.translate()],a=this.currentZoom;o.scale(this.baseScale*e.k),o.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=Io(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.scale(r),o.translate(n),this.currentZoom=a,this.geoPath=i,this.scales=s):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){const o=this.projection;if(!o)return;const i=this.geoPath,s=this.scales,r=o.scale(),n=[...o.translate()],a=this.currentZoom;o.scale(this.baseScale*e),o.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=Io(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.scale(r),o.translate(n),this.currentZoom=a,this.geoPath=i,this.scales=s):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){const o=this.projection;if(!o||!o.rotate)return;const i=this.geoPath,s=this.scales,r=[...o.rotate()];o.rotate(e),this.geoPath=Io(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const n=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.rotate(r),this.geoPath=i,this.scales=s):(this.scene=[],this.rebuildQuadtree()):(this.scene=n,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){const t=this.projection;t&&t.rotate&&t.rotate(e)}getRotation(){return this.projection?.rotate?.()??this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let t=0,o=0;for(const e of this.scene)"point"===e.type&&(o++,e.r>t&&(t=e.r));if(this._maxPointRadius=t,e.QUADTREE_THRESHOLD>=o)return void(this._quadtree=null);const i=Array(o);let s=0;for(const e of this.scene)"point"===e.type&&(i[s++]=e);this._quadtree=Go().x(e=>e.x).y(e=>e.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){this._customLayoutFailedThisBuild=!1;const{config:t}=this,o=this.projection,i=this.geoPath;if(t.customLayout&&this.scales){const o=t.layoutMargin??{top:0,right:0,bottom:0,left:0},i=le(t.colorScheme,t.themeCategorical,$),s={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:o,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...i]},resolveColor:Y(i,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null};let r;try{r=t.customLayout(s)}catch(e){const o=null!==this.lastCustomLayoutResult,i=M("geo",e,o,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",e);try{t.onLayoutError?.(i)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return o?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}const n=r.nodes??[];if(this.customLayoutOverlays=r.overlays??null,this.lastCustomLayoutResult=r,this.lastCustomLayoutFailure=null,this._customRestyle=r.restyle,this.hasCustomRestyle=!!r.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(const e of n)this._baseStyles.set(e,e.style);this.restyleScene(t.layoutSelection??null)}return E({label:"geo customLayout",nodes:n,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),n}return this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,function({config:e,projection:t,path:o,areas:i,points:s,lines:r,layout:n}){const a=Uo(e.xAccessor,"lon"),c=Uo(e.yAccessor,"lat"),l=[],h=function(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(e),d=function(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(e),u=function(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(e);if(e.graticule){const t=!0===e.graticule?{}:e.graticule,i=xi();t.step&&i.step(t.step);const s=o(i())||"";s&&l.push({type:"geoarea",pathData:s,centroid:[n.width/2,n.height/2],bounds:[[0,0],[n.width,n.height]],screenArea:0,style:{fill:"none",stroke:t.stroke||"#e0e0e0",strokeWidth:t.strokeWidth||.5,strokeDasharray:t.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of i){const i=o(t);if(!i)continue;const s=o.centroid(t),r=o.bounds(t),n=o.area(t);l.push({type:"geoarea",pathData:i,centroid:s,bounds:r,screenArea:n,style:Jo(e.areaStyle,t,h),datum:t,interactive:!0})}const g=Ko(e.lineDataAccessor);for(const o of r){const i=g(o);if(!i||2>i.length)continue;let s=[];if("geo"===e.lineType){const e=Array(i.length);for(let t=0;i.length>t;t++)e[t]=[a(i[t]),c(i[t])];for(let o=0;e.length-1>o;o++){const i=e[o],r=e[o+1],n=mi(i,r)||0,a=Math.max(2,Math.ceil(n/(Math.PI/180))),c=bi(i,r);for(let e=0;a>=e;e++){if(o>0&&0===e)continue;const i=t(c(e/a));null!=i&&s.push(i)}}}else for(let e=0;i.length>e;e++){const o=i[e],r=t([a(o),c(o)]);null!=r&&s.push(r)}if(2>s.length)continue;const r=Jo(e.lineStyle,o,d),h="number"==typeof r.strokeWidth?r.strokeWidth:1;2!==i.length||2>s.length||"arc"!==e.flowStyle?2!==i.length||2>s.length||"offset"!==e.flowStyle||(s="geo"===e.lineType?oi(s,h):ii(s[0],s[s.length-1],0,0,h)):s=ti(s[0],s[s.length-1]);const u=ei(s,n.width);if(u.length>1)for(const e of u)2>e.length||l.push({type:"line",path:e,style:{...r,_edgeFade:!0},datum:o});else l.push({type:"line",path:2>s.length&&u[0]||s,style:r,datum:o})}const p=e.pointIdAccessor?"function"==typeof e.pointIdAccessor?e.pointIdAccessor:t=>t[e.pointIdAccessor]:null,f=t.clipAngle?t.clipAngle()??0:0,y=f>0?f*Math.PI/180:null,m=t.rotate?t.rotate():[0,0,0],x="function"==typeof t.center?t.center():[0,0],b=[(x[0]??0)-m[0],(x[1]??0)-m[1]];for(const o of s){const i=a(o),s=c(o);if(null!=y&&mi([i,s],b)>y)continue;const r=t([i,s]);if(!r)continue;const n=e.pointStyle?e.pointStyle(o):{...u},h={type:"point",x:r[0],y:r[1],r:n.r||4,style:n,datum:o,pointId:p?p(o)+"":void 0};l.push(h)}return l}({config:t,projection:o,path:i,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:e})}applyCartogramTransform(e,t){const o=function(e,t,o,i){const s=e.filter(e=>"point"===e.type);if(2>s.length)return null;const r=t.strength??1;if(0===r)return null;const n=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,a="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],c=s.find(e=>e.datum&&n(e.datum)+""==t.center+"");if(!c)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;const l=c.x,h=c.y,d=s.map(e=>e.datum?a(e.datum):NaN).filter(e=>isFinite(e)&&e>=0),u=Se(d,1),g=Math.min(o.width,o.height)/2,p=si().domain([0,u]).range([0,g]);i>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them.");for(let t=e.length-1;t>=0;t--){const o=e[t];"geoarea"===o.type&&o.interactive&&e.splice(t,1)}for(const e of s){if(e===c)continue;if(!e.datum)continue;const t=Math.atan2(e.y-h,e.x-l),o=Math.sqrt((e.x-l)**2+(e.y-h)**2),i=a(e.datum),s=o+((isFinite(i)?p(i):o)-o)*r;e.x=l+Math.cos(t)*s,e.y=h+Math.sin(t)*s}const f=o.width/2,y=o.height/2,m=f-c.x,x=y-c.y;if(Math.abs(m)>.5||Math.abs(x)>.5)for(const e of s)e.x+=m,e.y+=x;const b={cx:f,cy:y,maxCost:u,availableRadius:g},A=e.filter(e=>"line"===e.type);if(A.length>0&&"fractional"!==t.lineMode){const e=new Map;for(const t of s)t.pointId&&e.set(t.pointId,[t.x,t.y]);for(const t of A){const o=t.datum?.source,i=t.datum?.target;if(o&&i){const s=e.get(o+""),r=e.get(i+"");s&&r&&(t.path=[s,r])}}}return b}(this.scene,e,t,this.areas.length);o&&(this.cartogramLayout=o)}applyDecay(){const e=this.config.decay;if(!e||!this.pointBuffer)return;const t=this.pointBuffer.size;if(0===t)return;const o=this.scene.filter(e=>"point"===e.type);for(let i=0;o.length>i;i++){const s=k(e,i,t);o[i]._decayOpacity=s,o[i].style={...o[i].style,opacity:s}}}applyPulse(e=this.currentTime()){const t=this.config.pulse;if(!t||!this.timestampBuffer)return!1;const o=this.scene.filter(e=>"point"===e.type),i=this.timestampBuffer.toArray(),s=t.color||"rgba(255,255,255,0.6)",r=t.glowRadius??4;let n=!1;for(let a=0;o.length>a&&i.length>a;a++){const c=_(t,i[a],e);n=C(o[a],c,s,r)||n}return n}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&z(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(e){const t=this.config.transition?.duration??300;if(0>=t)return;const o=new Map;for(const t of e)"point"===t.type&&t.pointId&&o.set(t.pointId,[t.x,t.y]);const i=this.scene.filter(e=>"point"===e.type);let s=!1;for(const e of i)if(e.pointId){const t=o.get(e.pointId);t&&(e._targetX=e.x,e._targetY=e.y,e.x=t[0],e.y=t[1],(Math.abs(t[0]-e._targetX)>.5||Math.abs(t[1]-e._targetY)>.5)&&(s=!0))}for(const e of i)e.pointId&&!o.has(e.pointId)&&(e._targetOpacity=e.style?.opacity??1,e.style={...e.style,opacity:0},s=!0);s&&(this.activeTransition={startTime:this.currentTime(),duration:t})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(e){if(!this.activeTransition)return!1;const t=X(e,this.activeTransition),o=H(t),i=this.scene.filter(e=>"point"===e.type);for(const e of i){if(null!=e._targetX&&null!=e._targetY){const t=e.y;e.x=oe(e.x,e._targetX,o),e.y=oe(t,e._targetY,o)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*o})}if(t>=1){for(const e of i)null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0),null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};vi.QUADTREE_THRESHOLD=500;var Si=vi;b(Si);import{Fragment as wi,jsxs as ki}from"react/jsx-runtime";function _i(e,t){const o=ft(e.theme),i=e.size||[e.width||600,e.height||400],s=ce({top:10,right:10,bottom:10,left:10,...e.margin},e.title),r=J(e.title),n=Array.isArray(e.areas)?Q(e.areas):e.areas,a=Q(e.points),c=Q(e.lines),l=e.showLegend?(()=>{const t="string"==typeof(o=e.colorBy)||"function"==typeof o?e.colorBy:void 0;var o;return Ft(a.length>0?a:Array.isArray(n)&&n.length>0?"string"==typeof t?n.map(e=>({...e.properties||{},...e})):n:[],t)})():[],h=e.legendPosition;te(e.legend)||ee(e.legend)?Ht(s,{legend:e.legend,theme:o,position:h||"right",size:i,hasTitle:r,legendLayout:e.legendLayout}):e.showLegend&&l.length>0&&Yt(s,{categories:l,colorScheme:e.colorScheme,theme:o,position:h||"right",size:i,hasTitle:r,legendLayout:e.legendLayout});const d=i[0]-(s.left??0)-(s.right??0),u=i[1]-(s.top??0)-(s.bottom??0),g={projection:e.projection||"equalEarth",xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineType:e.lineType,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform,customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:s,themeCategorical:o.colors.categorical,themeSemantic:ze(o)},p=new Si(g);if(n){if("string"==typeof n)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${n}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${n}')\` before calling renderGeoToStaticSVG.`);p.setAreas(n)}if(e.points&&p.setPoints(a),e.lines&&p.setLines(c),p.computeScene({width:d,height:u}),t&&(t.evidence=bt({frameType:"geo",width:i[0],height:i[1],marks:p.scene,title:e.title,description:e.description,annotations:e.annotations,legendItems:l.length>0?l.length:void 0})),0===p.scene.length){const t=e.backgroundGraphics||e.foregroundGraphics||e.annotations||p.customLayoutOverlays?ki(wi,{children:[e.backgroundGraphics,e.annotations?Wt({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:p.scales?.projectedPoint?([e,t])=>p.scales.projectedPoint(e,t):void 0},layout:{width:d,height:u},theme:o,idPrefix:e._idPrefix}):null,e.foregroundGraphics,p.customLayoutOverlays]}):null;return $o.renderToStaticMarkup(Qt(t,{width:i[0],height:i[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${s.left??0},${s.top??0})`,innerWidth:d,innerHeight:u,idPrefix:e._idPrefix}))}const f=p.scene.map((t,o)=>F({node:t,index:o,renderMode:e.renderMode,fallback:()=>Z(t,o)})).filter(Boolean),y=e.annotations?Wt({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:p.scales?.projectedPoint?([e,t])=>p.scales.projectedPoint(e,t):void 0},layout:{width:d,height:u},theme:o,idPrefix:e._idPrefix}):null,m=e.showLegend?0===l.length?null:Lt({categories:l,colorScheme:e.colorScheme,theme:o,position:e.legendPosition||"right",totalWidth:i[0],totalHeight:i[1],margin:s,hasTitle:r,legendLayout:e.legendLayout}):null,x=Wo.isValidElement(e.legend)?e.legend:Xt(e.legend,{theme:o,position:e.legendPosition||"right",size:i,margin:s,hasTitle:r,legendLayout:e.legendLayout,idPrefix:e._idPrefix})||m;return $o.renderToStaticMarkup(Qt(ki(wi,{children:[e.backgroundGraphics,f,y,e.foregroundGraphics,p.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${s.left??0},${s.top??0})`,innerWidth:d,innerHeight:u,legend:x,idPrefix:e._idPrefix}))}function Mi(e,t){const o=e.size??[e.width??600,e.height??400],i=new m(e.config);Array.isArray(e.initialSpawns)&&e.initialSpawns.length>0&&i.enqueue(e.initialSpawns.map(e=>({...e,spawnAt:void 0})));const s=l(i,{...e,width:o[0],height:o[1],idPrefix:e.idPrefix??e._idPrefix??"physics"});return t&&(t.evidence=bt({frameType:"physics",width:o[0],height:o[1],marks:s.scene.sceneNodes,title:e.title,description:e.description,annotations:[],extraWarnings:0===s.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[]})),s.svg}import{Fragment as Ti,jsx as Pi,jsxs as Ri}from"react/jsx-runtime";function zi(e,t){switch(e){case"xy":return Jt(t);case"ordinal":return Fo(t);case"network":return No(t);case"geo":return _i(t);case"physics":return Mi(t);default:throw Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function Li(e){return Jt(e)}function Fi(e){return Fo(e)}function Ci(e){return No(e)}function Bi(e){return _i(e)}var Di=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","scalePadding","sizeRange","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","barColors","legend","legendLayout"];function Ei(e,t,o){return ji(e,t).svg}function Oi(e,t,o){const i={},{svg:s,frameType:r}=ji(e,t,0,i),n=i.evidence??bt({frameType:r,width:"number"==typeof t.width?t.width:600,height:"number"==typeof t.height?t.height:400,marks:[],title:"string"==typeof t.title?t.title:void 0,description:"string"==typeof t.description?t.description:void 0,annotations:t.annotations,extraWarnings:["NO_EVIDENCE"]});return n.component=e,{svg:s,evidence:n}}function ji(e,t,o,i){const{data:s,width:r=600,height:n=400,theme:a,title:c,description:l,showLegend:h,showGrid:d,background:u,className:g,annotations:p,margin:f,colorScheme:y,colorBy:m,legendPosition:x,...b}=t,A=[r,n],v={...b.frameProps||{},...function(e,t){const o={};for(const i of t)void 0!==e[i]&&(o[i]=e[i]);return o}(b,Di),theme:a,title:c,description:l,showLegend:h,showGrid:d,background:u,className:g,annotations:p,size:A,...void 0!==f&&{margin:f},...void 0!==y&&{colorScheme:y},...void 0!==x&&{legendPosition:x},_idPrefix:b._idPrefix},S=pt[e];if(!S)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);const w=S.buildProps(s,m,y,v,b);let k;switch(S.frameType){case"xy":k=Jt(w,i);break;case"ordinal":k=Fo(w,i);break;case"network":k=No(w,i);break;case"geo":k=_i(w,i);break;case"physics":k=Mi(w,i)}if("GaugeChart"===e&&w.__gauge){const e=w.__gauge,t=v.margin||{top:20,right:20,bottom:30,left:40},o=(r||300)-t.left-t.right,i=(n||300)-t.top-t.bottom,s=Math.min(o,i)/2*.85,c=t.left+o/2,l=t.top+i/2,h=(e.startAngleDeg+(e.gMax===e.gMin?0:(Math.max(e.gMin,Math.min(e.gMax,e.value??e.gMin))-e.gMin)/(e.gMax-e.gMin))*e.sweep-90)*Math.PI/180,d=ft(a).colors.text,u=Le.renderToStaticMarkup(Ri(Ti,{children:[Pi("line",{x1:c,y1:l,x2:c+s*Math.cos(h),y2:l+s*Math.sin(h),stroke:d,strokeWidth:2.5,strokeLinecap:"round"}),Pi("circle",{cx:c,cy:l,r:4,fill:d})]}));k=k.replace("</svg>",u+"</svg>")}return{svg:k,frameType:S.frameType}}function Ni(e,t={}){const{title:o,subtitle:i,theme:s,width:r=1200,height:n,layout:a={},background:c}=t,l=yt(ft(s)),h=a.columns||2,d=a.gap??16;let u=0;o&&(u+=30),i&&(u+=20),u>0&&(u+=10);const g=Math.floor((r-d-d*(h-1))/h),p=[];let f=0,y=u+d,m=0;for(const t of e){const e=Math.min(t.colSpan||1,h),o=t.props.height||300;f+e>h&&(y+=m+d,f=0,m=0),p.push({chart:t,x:d/2+f*(g+d),y:y,w:g*e+d*(e-1),h:o}),m=Math.max(m,o),f+=e}const x=n||y+m+d,b=p.map((e,t)=>{const{chart:o,x:i,y:r,w:n,h:a}=e,c={...o.props,width:n,height:a,theme:s,_idPrefix:"chart-"+t};let l;return l=o.component?Ei(o.component,c):o.frameType?zi(o.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${a}"></svg>`,Pi("g",{transform:`translate(${i},${r})`,children:Pi("foreignObject",{width:n,height:a,children:Pi("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:l}})})},"dashboard-chart-"+t)});return Le.renderToStaticMarkup(Ri("svg",{xmlns:"http://www.w3.org/2000/svg",width:r,height:x,role:"img","aria-label":o||"Dashboard",style:{fontFamily:l.fontFamily},children:[o&&Pi("title",{children:o}),c&&Pi("rect",{x:0,y:0,width:r,height:x,fill:c}),o&&Pi("text",{x:r/2,y:24,textAnchor:"middle",fontSize:l.titleSize+4,fontWeight:"bold",fill:l.text,fontFamily:l.fontFamily,children:o}),i&&Pi("text",{x:r/2,y:o?46:20,textAnchor:"middle",fontSize:l.labelSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:i}),b]}))}import*as Wi from"react-dom/server";import{Fragment as $i,jsx as Ii,jsxs as Gi}from"react/jsx-runtime";function Vi(e,t,o,i={}){const{stepSize:s,windowSize:r,frameCount:n,xExtent:a,yExtent:c,transitionFrames:l=4,fps:h=12,easing:d="ease-out",decay:u}=i,g=o.width||600,p=o.height||400,f=ft(o.theme),y={...o,...a&&{xExtent:a},...c&&{yExtent:c}};if(!t||0===t.length)return[];const m=s||Math.max(1,Math.ceil(t.length/(n||Math.min(60,Math.max(10,t.length))))),b=[];for(let e=m;t.length>=e;e+=m)b.push(e);b[b.length-1]!==t.length&&b.push(t.length);const A=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(e),v=ce({top:20,right:20,bottom:30,left:40,...o.margin},o.title),S=g-v.left-v.right,w=p-v.top-v.bottom,k=[];if(A)for(let i=0;b.length>i;i++){const s=b[i],n=t.slice(r?Math.max(0,s-r):0,s),a={chartType:e,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:o.projection||"vertical",oAccessor:o.oAccessor||o.categoryAccessor||"category",rAccessor:o.rAccessor||o.valueAccessor||"value",colorAccessor:o.colorAccessor||o.colorBy,stackBy:o.stackBy,groupBy:o.groupBy,barPadding:o.barPadding,innerRadius:o.innerRadius,normalize:o.normalize,bins:o.bins,colorScheme:o.colorScheme||f.colors.categorical,...u&&{decay:u}},c=new Mo(a);c.ingest({inserts:n,bounded:!0}),c.computeScene({width:S,height:w}),c.scene.length>0&&k.push(Zi(c.scene,g,p,f,y))}else for(let i=0;b.length>i;i++){const s=b[i],n=t.slice(r?Math.max(0,s-r):0,s),m={chartType:e,windowSize:n.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:o.colorAccessor||o.colorBy,groupAccessor:o.groupAccessor||o.lineBy,lineDataAccessor:o.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:o.colorScheme||f.colors.categorical,lineStyle:o.lineStyle,pointStyle:o.pointStyle,areaStyle:o.areaStyle,sizeAccessor:o.sizeAccessor||o.sizeBy,sizeRange:o.sizeRange,...u&&{decay:u},...l>0&&{transition:{duration:l*(1e3/h),easing:d}}},A=new x(m);if(A.ingest({inserts:n,bounded:!0}),A.computeScene({width:S,height:w}),0===A.scene.length)continue;const v=A.scales?{y:A.scales.y}:void 0;if(k.push(Qi(A.scene,g,p,f,y,v)),l>0&&i>0&&A.activeTransition){const e=l*(1e3/h);for(let t=1;l>=t;t++)A.advanceTransition(A.activeTransition.startTime+t/l*e),k.push(Qi(A.scene,g,p,f,y,v))}}return k}function Yi(e,t,o={}){return t.map(t=>{try{return Ei(e,{...o,...t})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${o.width||t.width||600}" height="${o.height||t.height||400}"></svg>`}})}function Hi(e,t,o){const i=t.size??[t.width??600,t.height??400],s=ft(t.theme),r=yt(s),n=t.background||s.colors.background,a=t.idPrefix??"physics-gif",l=t.title?`${a}-title-${o}`:void 0,h=t.description?`${a}-desc-${o}`:void 0,d=[l,h].filter(Boolean).join(" ")||void 0,u=c(e.readBodies(),{bodyStyle:t.bodyStyle,getBodyLabel:t.getBodyLabel}),g=Gi("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className??"stream-physics-frame",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,role:"img","aria-labelledby":d,style:{fontFamily:r.fontFamily},children:[t.title&&Ii("title",{id:l,children:t.title}),t.description&&Ii("desc",{id:h,children:t.description}),n&&"transparent"!==n?Ii("rect",{x:0,y:0,width:i[0],height:i[1],fill:n}):null,Ii("g",{id:`${a}-frame-${o}`,children:u.map((e,t)=>de(e,t,`${a}-${o}`))})]});return Wi.renderToStaticMarkup(g)}function Xi(e,t={}){const{fps:o=12,frameCount:i,durationSeconds:s=2,includeInitialFrame:r=!0,stepDt:n,stepsPerFrame:a,background:c}=t,l=Math.max(.001,n??e.config?.fixedDt??1/120),h=a??Math.max(1,Math.round(1/Math.max(1,o)/l)),d=i??Math.max(1,Math.ceil(s*Math.max(1,o))),u=c?{...e,background:c}:e,g=new m(e.config);e.initialSpawns?.length&&g.enqueue(e.initialSpawns,e.initialSpawnPacing);const p=[];for(r&&(g.tick(0),p.push(Hi(g,u,0)));d>p.length;){for(let e=0;h>e;e+=1)g.tick(l);p.push(Hi(g,u,p.length))}return p}function qi(e,t){const o=e.background||t.colors.background;return o&&"transparent"!==o?o:null}function Qi(e,t,o,i,s,r){const n=yt(i),a=ce({top:20,right:20,bottom:30,left:40,...s.margin},s.title),c=t-a.left-a.right,l=o-a.top-a.bottom,h=qi(s,i),d=s.renderMode,u=e.map((e,t)=>F({node:e,index:t,renderMode:d,fallback:()=>de(e,t)})).filter(Boolean),g=function(e,t,o,i,s,r){if(!e||0===e.length)return null;const n=yt(i),a=[];for(let i=0;e.length>i;i++){const c=e[i];if("y-threshold"===c.type&&null!=c.value){let e=null;if(r)e=r(c.value);else if(s){const[t,i]=s,r=i-t;if(0===r)continue;e=o-(c.value-t)/r*o}if(null==e)continue;const l=c.color||n.primary,h=c.labelPosition||"right";a.push(Gi("g",{children:[Ii("line",{x1:0,y1:e,x2:t,y2:e,stroke:l,strokeWidth:c.strokeWidth??1.5,strokeDasharray:c.strokeDasharray||"6,4"}),c.label&&Ii("text",{x:"left"===h?4:"center"===h?t/2:t-4,y:20>e?Math.min(o-4,e+16):e-5,textAnchor:"left"===h?"start":"center"===h?"middle":"end",fontSize:n.tickSize,fill:l,fontFamily:n.fontFamily,children:c.label})]},"ann-"+i))}}return a.length>0?Ii($i,{children:a}):null}(s.annotations,c,l,i,s.yExtent,r?.y),p="string"==typeof s.title?s.title:void 0,f="string"==typeof s.description?s.description:void 0,y=p?"semiotic-title":void 0,m=f?"semiotic-desc":void 0,x=[y,m].filter(Boolean).join(" ")||void 0;return Wi.renderToStaticMarkup(Gi("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:o,role:"img","aria-labelledby":x,style:{fontFamily:n.fontFamily},children:[p&&Ii("title",{id:y,children:p}),f&&Ii("desc",{id:m,children:f}),h&&Ii("rect",{x:0,y:0,width:t,height:o,fill:h}),Gi("g",{transform:`translate(${a.left},${a.top})`,children:[g,u]}),p&&Ii("text",{x:t/2,y:G,textAnchor:"middle",fontSize:n.titleSize,fontWeight:"bold",fill:n.text,fontFamily:n.fontFamily,children:p})]}))}function Zi(e,t,o,i,s){const r=yt(i),n=ce({top:20,right:20,bottom:30,left:40,...s.margin},s.title),a="radial"===s.projection,c=a?n.left+(t-n.left-n.right)/2:n.left,l=a?n.top+(o-n.top-n.bottom)/2:n.top,h=qi(s,i),d=s.renderMode,u=e.map((e,t)=>F({node:e,index:t,renderMode:d,fallback:()=>ae(e,t)})).filter(Boolean),g="string"==typeof s.title?s.title:void 0,p="string"==typeof s.description?s.description:void 0,f=g?"semiotic-title":void 0,y=p?"semiotic-desc":void 0,m=[f,y].filter(Boolean).join(" ")||void 0;return Wi.renderToStaticMarkup(Gi("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:o,role:"img","aria-labelledby":m,style:{fontFamily:r.fontFamily},children:[g&&Ii("title",{id:f,children:g}),p&&Ii("desc",{id:y,children:p}),h&&Ii("rect",{x:0,y:0,width:t,height:o,fill:h}),Ii("g",{transform:`translate(${c},${l})`,children:u}),g&&Ii("text",{x:t/2,y:G,textAnchor:"middle",fontSize:r.titleSize,fontWeight:"bold",fill:r.text,fontFamily:r.fontFamily,children:g})]}))}export{Vi as generateFrameSVGs,Yi as generateFrameSequence,Xi as generatePhysicsFrameSVGs,Ei as renderChart,Oi as renderChartWithEvidence,Ni as renderDashboard,Bi as renderGeoToStaticSVG,Ci as renderNetworkToStaticSVG,Fi as renderOrdinalToStaticSVG,zi as renderToStaticSVG,Li as renderXYToStaticSVG,ft as resolveTheme,yt as themeStyles};
|
|
1
|
+
import{computeArcBoundingBox as e,sweepToAngles as t}from"./chunk-chunk-ANYDWOZF.module.min.js";import{buildCollisionSwarmPhysics as o,buildEventDropPhysics as i,buildGaltonBoardPhysics as r,buildPhysicalFlowPhysics as s,buildPhysicsPile as n,buildProcessFlowPhysics as a,generateGaltonMechanicalSamples as c,generatePhysicsPileMechanicalSamples as l,physicsBodiesToXYSceneNodes as u,renderPhysicsSettledSVG as h,resolveCustomLayout as d,styleFromColorAccessor as g}from"./chunk-chunk-ASKSE5F5.module.min.js";import{composeStyleRules as p,makeNodeRuleContext as f,makeRuleValueResolver as y,makeXYRuleContext as m,resolveStyleRules as b,styleRulesToNodeStyle as x,styleRulesToXYStyle as v,validateArrayData as A}from"./chunk-chunk-NEVE562N.module.min.js";import{PhysicsPipelineStore as S}from"./chunk-chunk-LRIFN2HK.module.min.js";import"./chunk-chunk-SIRIJ3DY.module.min.js";import{SEGMENT_FIELD as w,buildAnomalyAnnotations as k,buildForecast as _,createSegmentLineStyle as M}from"./chunk-chunk-C57LR3YG.module.min.js";import"./chunk-chunk-2JGJ5GUG.module.min.js";import{PipelineStore as P,StreamXYFrame_default as T,accessorName as L,attachUpdateResultStore as R,bandTooltipFields as C,buildBaseMetadataProps as z,buildCustomBehaviorProps as F,buildDatumIndexMap as B,buildDefaultTooltip as O,buildRectNode as E,buildRibbonGeometry as D,buildTooltipProps as j,compactTimestampBufferForRemoval as N,computeDecayOpacity as W,computePulseIntensity as I,createCustomLayoutFailureDiagnostic as $,createTimestampBufferForData as G,ensureRingBufferCapacity as Y,getLayoutPlugin as H,hasActivePulses as V,pushWithTimestamp as X,renderSceneListWithBackend as q,renderSceneWithBackend as Q,resolveDownwardHistogramExtent as K,setPulseState as Z,ticksForMode as U,toIdSet as J,warnCustomLayoutDiagnostics as ee}from"./chunk-chunk-3ILKBVVQ.module.min.js";import{IncrementalExtent as te,RingBuffer as oe}from"./chunk-chunk-7ALTGHK6.module.min.js";import"./chunk-chunk-C4YA6TDR.module.min.js";import{AnnotationLabel as ie,ChartError as re,DEFAULT_COLOR as se,DEFAULT_LEGEND_ROW_HEIGHT as ne,DEPTH_PALETTE_COLORS as ae,STREAMING_PALETTE as ce,SafeRender as le,SemioticAnnotation as ue,TITLE_BASELINE as he,applyAnnotationEmphasis as de,buildResolveColor as ge,composeLegendConfigs as pe,computeEasing as fe,computeRawProgress as ye,createColorScale as me,filterSparseArray as be,geoSceneNodeToSVG as xe,getColor as ve,getCrosshairProps as Ae,getSize as Se,hasTextTitle as we,isChartMode as ke,isGradientLegendConfig as _e,isLegendConfig as Me,layoutVerticalLegendGroups as Pe,lerp as Te,networkLabelToSVG as Le,networkSceneEdgeToSVG as Re,networkSceneNodeToSVG as Ce,now as ze,ordinalSceneNodeToSVG as Fe,renderEmptyState as Be,renderLoadingState as Oe,reserveTitleMargin as Ee,resolveCategoricalPalette as De,resolveChartMode as je,resolveCustomLayoutPalette as Ne,resolveDefaultFill as We,resolveExplicitColor as Ie,resolveLegendMetrics as $e,resolveMobileInteraction as Ge,useCategoryColors as Ye,useChartLegendAndMargin as He,useChartMode as Ve,useChartSelection as Xe,useColorScale as qe,useLegendInteraction as Qe,useThemeCategorical as Ke,warnMissingField as Ze,wrapStyleWithSelection as Ue,xySceneNodeToSVG as Je}from"./chunk-chunk-MFHF4J2Z.module.min.js";import"./chunk-chunk-XEVJDUTH.module.min.js";import{MultiPointTooltip as et,accessorsEquivalent as tt,filterAnnotationsByStatus as ot,resolveAccessor as it,resolveStringAccessor as rt,resolveSvgFill as st}from"./chunk-chunk-JMVEIZXP.module.min.js";import{SYMBOL_SEQUENCE as nt,UpdateResultTracker as at,annotationLayout as ct,getSequentialInterpolator as lt,interpolateBrBG as ut,interpolatePRGn as ht,interpolatePiYG as dt,interpolateRdBu as gt,interpolateRdYlBu as pt,interpolateRdYlGn as ft,interpolateSpectral as yt,interpolateViridis as mt,schemeCategory10 as bt}from"./chunk-chunk-5RKXZQ2P.module.min.js";import"./chunk-chunk-U66USBWU.module.min.js";import{getMax as xt,getMin as vt,getMinMax as At}from"./chunk-chunk-JJ2OOIET.module.min.js";import"./chunk-chunk-IY7RYD4S.module.min.js";import"./chunk-chunk-J3QOW4OE.module.min.js";import{DARK_THEME as St,HIGH_CONTRAST_THEME as wt,LIGHT_THEME as kt,THEME_PRESETS as _t,applyThemeAccessibility as Mt,resolveThemeSemanticColors as Pt,useThemeSelector as Tt}from"./chunk-chunk-DSNGDNJY.module.min.js";import*as Lt from"react-dom/server";import*as Rt from"react";function Ct({data:e,safeData:t,areaBy:o,lineDataAccessor:i}){if(null==e)return[];const r=void 0!==t[0]?.[i];if(!r&&!o)return t;let s;if(r)s=t;else{const e=t.reduce((e,t)=>{const r="function"==typeof o?o(t):t[o],s=r+"";if(!e[s]){const t={[i]:[]};"string"==typeof o&&(t[o]=r),e[s]=t}return e[s][i].push(t),e},{});s=Object.values(e)}return s.flatMap(e=>{const t=Array.isArray(e[i])?e[i]:[];return"string"==typeof o?t.map(t=>({...t,[o]:t[o]??e[o]})):t})}function zt(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return e??((...e)=>({}));const o={};return void 0!==t.stroke&&(o.stroke=t.stroke),void 0!==t.strokeWidth&&(o.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(o.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...o}):(...e)=>({...o})}import{useMemo as Ft,forwardRef as Bt,useRef as Ot}from"react";import{useCallback as Et,useMemo as Dt,useState as jt}from"react";import{useMemo as Nt}from"react";import{useImperativeHandle as Wt,useRef as It}from"react";import{useMemo as $t}from"react";import{useEffect as Gt,useMemo as Yt,useRef as Ht,useState as Vt}from"react";var Xt=null;async function qt(){return Xt||(Xt=await import("./chunk-statisticalOverlays-QGDLRUHX.module.min.js")),Xt}var Qt="__semiotic_resolvedX",Kt="__semiotic_resolvedY";import{jsx as Zt}from"react/jsx-runtime";function Ut(e,t){if(null==t)return e;const o=e.trim(),i=o.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(i){const e=i[1],o=3===e.length?e.split("").map(e=>e+e).join(""):e;return`rgba(${parseInt(o.slice(0,2),16)}, ${parseInt(o.slice(2,4),16)}, ${parseInt(o.slice(4,6),16)}, ${t})`}if(o.startsWith("rgba(")){const e=o.lastIndexOf(","),i=o.lastIndexOf(")");if(-1!==e&&i>e)return`${o.slice(0,e+1)} ${t})`}return o.startsWith("rgb(")?o.replace(/^rgb\(/,"rgba(").replace(/\)$/,`, ${t})`):e}function Jt(e){return e.filter(e=>Number.isFinite(e.at)).map(e=>({offset:1-Math.max(0,Math.min(100,e.at))/100,color:Ut(e.color,e.opacity)})).sort((e,t)=>e.offset-t.offset)}function eo(e,t,o){return"function"==typeof e?e(o):o[e||t]}function to(e){return e instanceof Date?e.getTime():Number(e)}function oo(e,t){return mt(1===t?.5:e/(t-1))}function io(e){if(!e)return kt;if("string"==typeof e){if("light"===e)return kt;if("dark"===e)return St;if("high-contrast"===e)return wt;return _t[e]||kt}const t="dark"===e.mode?St:kt,o={...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}},tooltip:{...t.tooltip,...e.tooltip||{}}};return Mt(o)}function ro(e){return{background:e.colors.background,text:e.colors.text,textSecondary:e.colors.textSecondary,grid:e.colors.grid,border:e.colors.border,primary:e.colors.primary,fontFamily:e.typography.fontFamily,titleSize:e.typography.titleSize,labelSize:e.typography.labelSize,tickSize:e.typography.tickSize,categorical:e.colors.categorical,annotation:e.colors.annotation??e.colors.text,legendSize:e.typography.legendSize??e.typography.labelSize,titleFontSize:e.typography.titleFontSize??e.typography.titleSize,tickFontFamily:e.typography.tickFontFamily??e.typography.fontFamily}}Bt(function(e,t){const o=Ot(null);!function(e,t){const{variant:o,frameRef:i,overrides:r}=t,s=It(r);s.current=r,Wt(e,()=>{const e=function(e,t){if("xy"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.remove(t)??[],update:(t,o)=>e.current?.update(t,o)??[],replace:t=>e.current?.replace?.(t),clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getScales:()=>e.current?.getScales()??null,getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("network"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>{const o=Array.isArray(t)?t:[t],i=e.current?.getTopology()?.nodes??[],r=[];for(const t of o){const o=i.find(e=>e.id===t);o&&r.push({...o.data??{},id:t}),e.current?.removeNode(t)}return r},update:(t,o)=>(Array.isArray(t)?t:[t]).flatMap(t=>{const i=e.current?.updateNode(t,o);return i?[{...i,id:t}]:[]}),clear:()=>e.current?.clear(),getData:()=>e.current?.getTopology()?.nodes?.map(e=>e.data)??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}if("geo-points"===e){const e=t;return{push:t=>e.current?.push(t),pushMany:t=>e.current?.pushMany(t),remove:t=>e.current?.removePoint(t)??[],update:(t,o)=>{const i=e.current?.removePoint(t)??[];for(const t of i)e.current?.push(o(t));return i},clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}const o=t;return{push:e=>o.current?.pushLine(e),pushMany:e=>o.current?.pushManyLines(e),remove:e=>o.current?.removeLine(e)??[],update:(e,t)=>{const i=o.current?.removeLine(e)??[];for(const e of i)o.current?.pushLine(t(e));return i},clear:()=>o.current?.clear(),getData:()=>o.current?.getLines()??[],getCustomLayout:()=>o.current?.getCustomLayout?.()??null,getLayoutFailure:()=>o.current?.getLayoutFailure?.()??null}}(o,i);return new Proxy(e,{get(e,t,o){if("string"==typeof t){const e=s.current?.[t];if("function"==typeof e)return e}return Reflect.get(e,t,o)},has:(e,t)=>!("string"!=typeof t||!s.current||!(t in s.current))||Reflect.has(e,t)})},[])}(t,{variant:"xy",frameRef:o});const i=Ve(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules}),{data:r,margin:s,className:n,xFormat:a,yFormat:c,xAccessor:l="x",yAccessor:u="y",areaBy:h,y0Accessor:d,gradientFill:g=!1,semanticGradient:p,lineDataAccessor:f="coordinates",colorBy:y,colorScheme:x,styleRules:v,curve:S="monotoneX",areaOpacity:w=.7,lineGradient:k,showLine:_=!0,lineWidth:M=2,showPoints:P=!1,pointRadius:R=3,tooltip:B,annotations:E,forecast:D,anomaly:N,band:W,xExtent:I,yExtent:$,frameProps:G={},selection:Y,linkedHover:H,onObservation:V,onClick:X,hoverHighlight:q,chartId:Q,loading:K,loadingContent:Z,emptyContent:U,legendInteraction:J,legendPosition:ee,color:te,stroke:oe,strokeWidth:ie,opacity:ne}=e,{width:ae,height:ue,enableHover:he,showGrid:de,showLegend:ge,title:pe,description:fe,summary:ye,accessibleTable:xe,xLabel:Se,yLabel:we}=i,ke=Ft(()=>be(r),[r]),_e=y||h,Me=Ft(()=>p&&p.length>0?{colorStops:Jt(p)}:g,[p,g]);Ze("AreaChart",ke,"xAccessor",l),Ze("AreaChart",ke,"yAccessor",u);const Pe=function(e){const{data:t,rawData:o,colorBy:i,colorScheme:r,legendInteraction:s,legendPosition:n,selection:a,linkedHover:c,fallbackFields:l,unwrapData:u=!1,onObservation:h,chartType:d,chartId:g,showLegend:p,legend:f,userMargin:y,marginDefaults:m,onClick:b,hoverHighlight:x,mobileInteraction:v,mobileSemantics:A,loading:S,loadingContent:w,emptyContent:k,width:_,height:M}=e,P=void 0===o,T=Dt(()=>be(t),[t]),[L,R]=jt([]),C=Et(e=>{R(t=>t.length===e.length&&t.every((t,o)=>t===e[o])?t:e)},[]),z="string"==typeof e.colorBy?e.colorBy:void 0,F=Dt(()=>Ge(v,{width:_,mobileSemantics:A}),[v,_,A]),{activeSelectionHook:B,hoverSelectionHook:O,customHoverBehavior:E,customClickBehavior:D,crosshairSourceId:j}=Xe({selection:a,linkedHover:c,fallbackFields:l,unwrapData:u,onObservation:h,chartType:d,chartId:g,onClick:b,hoverHighlight:x,colorByField:z,mobileInteraction:F}),N=Ae(c,j),W=qe(T,i,r),I=Dt(()=>{if(!i)return[];const e=new Set;for(const t of T){const o="function"==typeof i?i(t):t[i];null!=o&&e.add(o+"")}return Array.from(e)},[T,i]),$=Dt(()=>P&&L.length>0?L:I,[P,L,I]),G=Qe(s,i,$),Y=Dt(()=>O||(G.legendSelectionHook?G.legendSelectionHook:B),[O,G.legendSelectionHook,B]),H=function(e){const t=Tt(e=>e.theme.colors.selectionOpacity);return Nt(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}(a),V=Ke(),X=Ye(),q=Dt(()=>{if(W)return W;if(!i||0===$.length)return;const e=Array.isArray(r)&&r.length>0||"string"==typeof r&&r.length>0?r:V&&V.length>0?V:ce,t="__streamCat",o=$.map(e=>({[t]:e})),s=me(o,t,e);return e=>X?.[e]||s(e)||"#999"},[W,i,$,r,V,X]),{legend:Q,margin:K,legendPosition:Z}=He({data:T,colorBy:i,colorScale:q,showLegend:p,legendPosition:n,userMargin:y,defaults:m,categories:$,additionalLegend:f}),U=Dt(()=>{const e={};return Q&&(e.legend=Q,e.legendPosition=Z),s&&"none"!==s&&(e.legendHoverBehavior=G.onLegendHover,e.legendClickBehavior=G.onLegendClick,e.legendHighlightedCategory=G.highlightedCategory,e.legendIsolatedCategories=G.isolatedCategories),P&&i&&(e.legendCategoryAccessor=i,e.onCategoriesChange=C),e},[Q,Z,s,G.onLegendHover,G.onLegendClick,G.highlightedCategory,G.isolatedCategories,P,i,C]),J=Array.isArray(o)?be(o):o,ee=Oe(S,_,M,w),te=ee?null:Be(J,_,M,k);return{data:T,colorScale:W,allCategories:$,legendState:G,effectiveSelectionHook:Y,activeSelectionHook:B,customHoverBehavior:E,customClickBehavior:D,mobileInteraction:F,legend:Q,margin:K,legendPosition:Z,earlyReturn:ee||te||null,legendBehaviorProps:U,crosshairProps:N,resolvedSelection:H}}({data:ke,rawData:r,colorBy:_e,colorScheme:x,legendInteraction:J,legendPosition:ee,selection:Y,linkedHover:H,fallbackFields:_e?["string"==typeof _e?_e:""]:[],unwrapData:!1,onObservation:V,onClick:X,hoverHighlight:q,mobileInteraction:i.mobileInteraction,mobileSemantics:i.mobileSemantics,chartType:"AreaChart",chartId:Q,showLegend:ge,userMargin:s,marginDefaults:i.marginDefaults,loading:K,loadingContent:Z,emptyContent:U,width:ae,height:ue}),{effectiveData:Te,statisticalAnnotations:Le}=function(e){const{data:t,xAccessor:o,yAccessor:i,forecast:r,anomaly:s,groupBy:n}=e,a="string"==typeof o?o:Qt,c="string"==typeof i?i:Kt,l=Yt(()=>{if(!r&&!s)return t;const e="function"==typeof o,n="function"==typeof i;return e||n?t.map(t=>{const r={...t};return e&&(r[Qt]=o(t)),n&&(r[Kt]=i(t)),r}):t},[t,r,s,o,i]),[u,h]=Vt(null),[d,g]=Vt([]),p=Ht(r),f=Ht(s);return Gt(()=>{if(!r&&!s)return void((p.current||f.current)&&(h(null),g([]),p.current=r,f.current=s));let e=!1;const t=r!==p.current||s!==f.current;if(p.current=r,f.current=s,t&&(h(null),g([])),r){const t=n&&"string"==typeof n&&"object"==typeof r?{...r,_groupBy:n}:r;(async function(...e){return(await qt()).buildForecast(...e)})(l,a,c,t,s).then(t=>{e||(h(t),g(t.annotations))}).catch(()=>{e||(h(null),g([]))})}else s&&async function(...e){return(await qt()).buildAnomalyAnnotations(...e)}(s).then(t=>{e||(h(null),g(t))}).catch(()=>{e||g([])});return()=>{e=!0}},[l,r,s,a,c,n]),{effectiveData:u?u.processedData:t,statisticalAnnotations:d,hasForecast:!!u,xAccessorKey:a,yAccessorKey:c}}({data:ke,xAccessor:l,yAccessor:u,forecast:D,anomaly:N,groupBy:h}),Re=Ft(()=>m(l,u),[l,u]),{flattenedData:Ce,lineStyle:ze,pointStyle:Fe,defaultTooltipContent:Ee}=function(e){const{safeData:t,data:o,areaBy:i,lineDataAccessor:r,colorBy:s,colorScale:n,color:a,stroke:c,strokeWidth:l,opacity:u,effectiveSelectionHook:h,resolvedSelection:d,areaOpacity:g,showLine:p,lineWidth:f,showPoints:y,pointRadius:m,xAccessor:x,yAccessor:v,xLabel:A,yLabel:S,xFormat:w,yFormat:k,groupField:_,styleRules:M,ruleContext:P}=e,T=$t(()=>Ct({data:o,safeData:t,areaBy:i,lineDataAccessor:r}),[o,t,i,r]),R=$t(()=>e=>{const t={};if(s){if(n){const o=ve(e,s,n);t.fill=o,p?(t.stroke=o,t.strokeWidth=f):t.stroke="none"}}else{const e=a||se;t.fill=e,p?(t.stroke=e,t.strokeWidth=f):t.stroke="none"}return t.fillOpacity=g,M&&M.length>0&&Object.assign(t,b(e,M,P?P(e):{value:void 0})),t},[s,n,a,g,p,f,M,P]),z=$t(()=>zt(R,{stroke:c,strokeWidth:l,opacity:u}),[R,c,l,u]);return{flattenedData:T,lineStyle:$t(()=>Ue(z,h??null,d),[z,h,d]),pointStyle:$t(()=>{if(y)return e=>{const t={r:m,fillOpacity:1};return s?n&&(t.fill=ve(e.parentLine||e,s,n)):t.fill=a||se,t}},[y,m,s,n,a]),defaultTooltipContent:$t(()=>O([{label:A||L(x),accessor:x,role:"x",format:w},{label:S||L(v),accessor:v,role:"y",format:k},..._?[{label:L(_),accessor:_,role:"group"}]:[],...C(e.band,k)]),[x,v,A,S,_,w,k,e.band])}}({safeData:Te,data:r,areaBy:h,lineDataAccessor:f,colorBy:_e,colorScale:Pe.colorScale,color:te,stroke:oe,strokeWidth:ie,opacity:ne,effectiveSelectionHook:Pe.effectiveSelectionHook,resolvedSelection:Pe.resolvedSelection,areaOpacity:w,showLine:_,lineWidth:M,showPoints:P,pointRadius:R,xAccessor:l,yAccessor:u,xLabel:Se,yLabel:we,xFormat:a,yFormat:c,groupField:h||y,band:W,styleRules:v,ruleContext:Re}),De=A({componentName:"AreaChart",data:r,accessors:{xAccessor:l,yAccessor:u}}),je={chartType:"area",...null!=r&&{data:Ce},xAccessor:l,yAccessor:u,groupAccessor:h||void 0,...d&&{y0Accessor:d},...W&&{band:W},...Me&&{gradientFill:Me},...k&&{lineGradient:k},curve:S,lineStyle:ze,...P&&Fe&&{pointStyle:Fe},size:[ae,ue],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:Pe.margin,showAxes:i.showAxes,xLabel:Se,yLabel:we,xFormat:a,yFormat:c,enableHover:he,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},showGrid:de,...Pe.legendBehaviorProps,...z({title:pe,description:fe,summary:ye,accessibleTable:xe,className:n,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),..."multi"===B?{tooltipContent:et(),tooltipMode:"multi"}:j({tooltip:B,defaultTooltipContent:Ee}),...F({linkedHover:H,selection:Y,onObservation:V,onClick:X,hoverHighlight:q,mobileInteraction:Pe.mobileInteraction,customHoverBehavior:Pe.customHoverBehavior,customClickBehavior:Pe.customClickBehavior}),...(E&&E.length>0||Le.length>0)&&{annotations:[...E||[],...Le]},...I&&{xExtent:I},...$&&{yExtent:$},...Pe.crosshairProps,...G};return Pe.earlyReturn?Pe.earlyReturn:De?Zt(re,{componentName:"AreaChart",message:De,width:ae,height:ue}):Zt(le,{componentName:"AreaChart",width:ae,height:ue,children:Zt(T,{ref:o,...je})})}).displayName="AreaChart";var so="__semiotic_resolvedX",no="__semiotic_resolvedY",ao="__compoundGroup";function co(e,t,o){const i=e[t],r=e[o];return null==i||null==r||Number.isNaN(i)||Number.isNaN(r)}function lo(e,t,o,i,r){const s=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=io(i.theme).colors.categorical,a=o??i.colorScheme??n,c="string"==typeof t?t:"__ssrAreaColorBy",l="function"==typeof t?s.map(e=>({...e,__ssrAreaColorBy:t(e)})):s,u=t?me(l,c,a):void 0,h=!1!==r.showLine,d="number"==typeof r.lineWidth?r.lineWidth:2,g="number"==typeof r.areaOpacity?r.areaOpacity:.7,p=y(r.yAccessor),f=r.styleRules;return(e,o)=>{const i=t&&u?ve(e,t,u):"string"==typeof r.color?r.color:se,s={fill:i,fillOpacity:g,stroke:h?i:"none",...h&&{strokeWidth:d}};return f?.length&&Object.assign(s,b(e,f,{value:p(e),category:o})),void 0!==r.stroke&&(s.stroke=r.stroke),void 0!==r.strokeWidth&&(s.strokeWidth=r.strokeWidth),void 0!==r.opacity&&(s.opacity=r.opacity),s}}function uo(e,t,o,i,r){const s=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=io(i.theme).colors.categorical,a=o??i.colorScheme??n,c="string"==typeof t?t:"__ssrBubbleColorBy",l="function"==typeof t?s.map(e=>({...e,__ssrBubbleColorBy:t(e)})):s,u=t?me(l,c,a):void 0,h=r.sizeBy,d=Array.isArray(r.sizeRange)?r.sizeRange:[5,40],g=h?s.map(e=>"function"==typeof h?h(e):Number(e[h])).filter(Number.isFinite):[],p=g.length?At(g):void 0;return e=>({fill:t&&u?ve(e,t,u):"string"==typeof r.color?r.color:se,fillOpacity:"number"==typeof r.bubbleOpacity?r.bubbleOpacity:.6,r:h?Se(e,h,d,p):d[0],stroke:r.stroke??r.bubbleStrokeColor??"white",strokeWidth:r.strokeWidth??r.bubbleStrokeWidth??1,...void 0!==r.opacity&&{opacity:r.opacity}})}function ho(e,t,o,i,r){const s=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=io(i.theme).colors.categorical,a=o??i.colorScheme??n,c="string"==typeof t?t:"__ssrScatterColorBy",l="function"==typeof t?s.map(e=>({...e,__ssrScatterColorBy:t(e)})):s,u=t?me(l,c,a):void 0,h=r.sizeBy,d=Array.isArray(r.sizeRange)?r.sizeRange:[3,15],g=h?s.map(e=>"function"==typeof h?h(e):Number(e[h])).filter(Number.isFinite):[],p=g.length?At(g):void 0,f=m(r.xAccessor,r.yAccessor),y=r.styleRules;return e=>{const o={fill:t&&u?ve(e,t,u):"string"==typeof r.color?r.color:se,fillOpacity:"number"==typeof r.pointOpacity?r.pointOpacity:.8,r:h?Se(e,h,d,p):"number"==typeof r.pointRadius?r.pointRadius:5};return y?.length&&Object.assign(o,b(e,y,f(e))),void 0!==r.stroke&&(o.stroke=r.stroke),void 0!==r.strokeWidth&&(o.strokeWidth=r.strokeWidth),void 0!==r.opacity&&(o.opacity=r.opacity),o}}function go(e,t,o,i,r){if(!r.showPoints)return;const s=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=io(i.theme).colors.categorical,a=o??i.colorScheme??n,c="string"==typeof t?t:"__ssrPointColorBy",l="function"==typeof t?s.map(e=>({...e,__ssrPointColorBy:t(e)})):s,u=t?me(l,c,a):void 0,h="number"==typeof r.pointRadius?r.pointRadius:3;return e=>{const o=t&&u?ve(e,t,u):"string"==typeof r.color?r.color:se;return{r:h,fill:o,stroke:"none"}}}function po(e){return Math.max(0,Math.min(1,e))}function fo(e){const t=e.trim();if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e.split("").map(e=>e+e).join("")),6===e.length&&/^[0-9a-f]{6}$/i.test(e))return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const o=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(o){const e=[Number(o[1]),Number(o[2]),Number(o[3])];if(e.every(Number.isFinite))return e}return null}function yo(e,t,o){const i=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${i(e)}${i(t)}${i(o)}`}function mo(e,t){const o=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:po(e.offset),color:e.color})).sort((e,t)=>e.offset-t.offset);if(0===o.length)return"#999999";if(1===o.length)return o[0].color;const i=po(t);if(o[0].offset>=i)return o[0].color;if(i>=o[o.length-1].offset)return o[o.length-1].color;for(let e=0;o.length-1>e;e++){const t=o[e],r=o[e+1];if(t.offset>i||i>r.offset)continue;const s=r.offset-t.offset,n=s>0?(i-t.offset)/s:0,a=fo(t.color),c=fo(r.color);if(!a||!c)return.5>n?t.color:r.color;const[l,u,h]=a,[d,g,p]=c;return yo(l+(d-l)*n,u+(g-u)*n,h+(p-h)*n)}return o[o.length-1].color}function bo(e,t,o){return null==o?`${e}-${t}`:`${e}-${t}-${o}`}import{Fragment as xo,jsx as vo,jsxs as Ao}from"react/jsx-runtime";import{useMemo as So,useCallback as wo,useRef as ko}from"react";var _o={RdBu:gt,PiYG:dt,PRGn:ht,BrBG:ut,RdYlBu:pt,RdYlGn:ft,Spectral:yt},Mo="__likert_neutral_neg",Po="__likert_neutral_pos";function To(e,t){if("function"==typeof e)return e;const o=e||t;return e=>e[o]}import*as Lo from"react";function Ro(e){return!0===e?{topOpacity:.8,bottomOpacity:.05}:!1===e?void 0:e}function Co(e,t,o,i,r){const s=io(i.theme).colors.categorical,n=o??i.colorScheme,a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],c="string"==typeof t?t:"__ssrColorBy",l="function"==typeof t?a.map(e=>({...e,__ssrColorBy:t(e)})):a,u=t?me(l,c,n??s):void 0,h=We("string"==typeof r.color?r.color:void 0,s,n,void 0,new Map),d=y(r.valueAccessor),g=r.styleRules,p=i.pieceStyle;return(e,o)=>{const i={fill:t&&u?ve(e,t,u):h};return g?.length&&Object.assign(i,b(e,g,{value:d(e),category:o})),"function"==typeof p?Object.assign(i,p(e,o)||{}):p&&"object"==typeof p&&Object.assign(i,p),void 0!==r.stroke&&(i.stroke=r.stroke),void 0!==r.strokeWidth&&(i.strokeWidth=r.strokeWidth),void 0!==r.opacity&&(i.opacity=r.opacity),i}}function zo(e,t,o,i,r){const s=Co(e,t,o,i,r);return(e,t)=>{const o=s(e,t);return void 0===o.fillOpacity&&(o.fillOpacity=.8),void 0===o.stroke&&(o.stroke=o.fill),o}}function Fo(e,t,o,i,r){const s=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n="string"==typeof t?t:"__ssrViolinColorBy",a="function"==typeof t?s.map(e=>({...e,__ssrViolinColorBy:t(e)})):s,c=io(i.theme).colors.categorical,l=o??i.colorScheme,u=t?me(a,n,l??c):void 0,h=We("string"==typeof r.color?r.color:void 0,c,l,void 0,new Map);return e=>{const o=t&&u?ve(e,t,u):h;return{fill:o,fillOpacity:.6,stroke:r.stroke??o,...void 0!==r.strokeWidth&&{strokeWidth:r.strokeWidth},...void 0!==r.opacity&&{opacity:r.opacity}}}}function Bo(e,t,o,i,r){const s=Co(e,t,o,i,r),n="number"==typeof r.dotRadius?r.dotRadius:5;return(e,t)=>({r:n,fillOpacity:.8,...s(e,t)})}function Oo(e,t,o,i,r){const s=Co(e,t,o,i,r),n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=r.sizeBy,c=Array.isArray(r.sizeRange)?r.sizeRange:[3,8],l=a?n.map(e=>"function"==typeof a?a(e):Number(e[a])).filter(Number.isFinite):[],u=l.length?At(l):void 0,h="number"==typeof r.pointRadius?r.pointRadius:4,d="number"==typeof r.pointOpacity?r.pointOpacity:.7;return(e,t)=>({r:a?Se(e,a,c,u):h,fillOpacity:d,...s(e,t)})}import{scaleTime as Eo}from"d3-scale";function Do(e){return"invalid-node-time"===e.kind?`node ${e.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===e.kind?`edge ${e.id} has an invalid startTime or endTime`:"invalid-domain"===e.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===e.kind?`edge ${e.id} must have a positive finite value`:"missing-node"===e.kind?`edge ${e.id} references missing ${e.endpoint} node "${e.nodeId}"`:"backward-edge"===e.kind?`edge ${e.id} (${e.source}->${e.target}) ends before it starts`:e.kind}function jo(e,t,o){const i=t.incoming[e.id],r=t.outgoing[e.id],s=[];for(const e of i)s.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:o.get(e.id).targetSide});for(const e of r)s.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:o.get(e.id).sourceSide});const n={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{s.sort((e,t)=>e.time-t.time||(n[e.kind]??99)-(n[t.kind]??99))},c=s.length?vt(s.map(e=>e.time)):null,l=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,u=null!=l?l-1:null!=c&&Number.isFinite(c)?c-1:null,h=[...new Set(s.map(e=>e.time))].sort((e,t)=>e-t),d=new Map;for(let e=1;h.length>e;e++)d.set(h[e],h[e-1]);const g=e=>{const t=d.get(e);return null!=t?(t+e)/2:null!=u?u:e};a();const p=[];let f=0,y=0;for(const e of s)if("out"===e.kind){const t=Math.abs(e.delta);let o=t-("top"===e.side?f:y);if(o>0){const t="top"===e.side?"bot":"top",i=Math.min(o,"top"===t?f:y);if(i>0){const r=g(e.time);p.push({time:r,delta:-i,kind:"transfer-out",side:t}),p.push({time:r,delta:+i,kind:"transfer-in",side:e.side}),"top"===t?f-=i:y-=i,"top"===e.side?f+=i:y+=i,o-=i}o>0&&null!==u&&(p.push({time:u,delta:+o,kind:"create",side:e.side}),"top"===e.side?f+=o:y+=o)}"top"===e.side?f-=t:y-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?f+=t:y+=t}s.push(...p),a();let m=0,b=0,x=0,v=0,A=0;const S=[],w=new Map;for(const e of s){if(S.push({t:e.time,topMass:m,botMass:b}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?m:b;w.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta)})}"top"===e.side?m+=e.delta:b+=e.delta,m+b>x&&(x=m+b),m>v&&(v=m),b>A&&(A=b),S.push({t:e.time,topMass:m,botMass:b})}const k=[];let _=0;for(;S.length>_;){let e=_;for(;S.length>e+1&&S[e+1].t===S[_].t;)e++;k.push(S[_]);for(let t=_+1;e>=t;t++){const e=k[k.length-1];S[t].topMass===e.topMass&&S[t].botMass===e.botMass||k.push(S[t])}_=e+1}const M=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let P=null;for(const e of r)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===P||P>e.systemInTime)&&(P=e.systemInTime);let T=null;for(const e of i)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===T||e.systemOutTime>T)&&(T=e.systemOutTime);if(k.length>0){const e=k[k.length-1],t=Math.max(null!=M?M:-1/0,null!=T?T:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&k.push({t:t,topMass:e.topMass,botMass:e.botMass});const o=k[0],i=Math.min(null!=l?l:1/0,null!=P?P:1/0);Number.isFinite(i)&&o.t>i&&o.topMass+o.botMass>0&&k.unshift({t:i,topMass:o.topMass,botMass:o.botMass})}return{samples:k,peak:x,topPeak:v,botPeak:A,localAttachments:w}}function No(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Wo(e,t){return e.map(e=>({t:No(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function Io(e,t,o){const i=e.value*o;if("out"===e.kind){const r=e.sideMassBefore*o;if("top"===e.side){const e=t-r;return[e,e+i]}const s=t+r;return[s-i,s]}const r=e.sideMassAfter*o;if("top"===e.side){const e=t-r;return[e,e+i]}const s=t+r;return[s-i,s]}function $o(e,t){let o=0;for(let i=0;t.length>i;i++)for(let r=i+1;t.length>r;r++){const s=t[i],n=t[r];s.source!==n.source&&s.target!==n.target&&s.source!==n.target&&s.target!==n.source&&(Math.min(s.endTime,n.endTime)>Math.max(s.startTime,n.startTime)&&e[n.source]>e[s.source]!=e[n.target]>e[s.target]&&o++)}return o}function Go(e,t){let o=0;for(const i of t)o+=Math.abs(e[i.source]-e[i.target])*(i.value||1);return o}function Yo(e,t){return 1e3*$o(e,t)+Go(e,t)}function Ho(e,t){return{slots:e.map(e=>({peak:{...e.peak},occupants:e.occupants.slice()})),map:{...t}}}function Vo(e,t,o){e.length>8||o.length>40?(function(e,t,o,i=6){const r=e.length;if(1>=r)return;let s=Ho(e,t),n=Yo(t,o);for(let a=0;i>a;a++){const i=Array(r).fill(0),a=Array(r).fill(0);for(const e of o){const o=t[e.source],r=t[e.target];i[o]+=r*(e.value||1),a[o]+=e.value||1,i[r]+=o*(e.value||1),a[r]+=e.value||1}const c=Array.from({length:r},(e,t)=>t).sort((e,t)=>(a[e]>0?i[e]/a[e]:e)-(a[t]>0?i[t]/a[t]:t)),l=c.map(t=>e[t]),u=new Map;c.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of l)e.push(t);const h=Yo(t,o);if(n>h)n=h,s=Ho(e,t);else if(h===n)break}!function(e,t,o){e.length=0;for(const t of o.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(o.map))t[e]=o.map[e]}(e,t,s)}(e,t,o,6),function(e,t,o,i=6){const r=e.length;if(1>=r)return;let s=Yo(t,o);for(let n=0;i>n;n++){let i=!1;for(let n=0;r-1>n;n++){const r=e[n];e[n]=e[n+1],e[n+1]=r;for(const e of Object.keys(t))t[e]===n?t[e]=n+1:t[e]===n+1&&(t[e]=n);const a=Yo(t,o);if(s>a)s=a,i=!0;else{const o=e[n];e[n]=e[n+1],e[n+1]=o;for(const e of Object.keys(t))t[e]===n?t[e]=n+1:t[e]===n+1&&(t[e]=n)}}if(!i)break}}(e,t,o,6)):function(e,t,o){const i=e.length;if(1>=i)return;const r={...t},s=Object.keys(r),n=Array.from({length:i},(e,t)=>t),a=n.slice(),c={...r};let l=n.slice(),u=1/0;const h=()=>{for(const e of s)c[e]=a[r[e]];const e=Yo(c,o);u>e&&(u=e,l=n.slice())},d=(e,t)=>{const o=n[e],i=n[t];n[e]=i,n[t]=o,a[o]=t,a[i]=e};h();const g=Array(i).fill(0);let p=0;for(;i>p;)p>g[p]?(d(p%2==0?0:g[p],p),h(),g[p]++,p=0):(g[p]=0,p++);const f=l.map(t=>e[t]),y=new Map;l.forEach((e,t)=>y.set(e,t));for(const e of Object.keys(t))t[e]=y.get(t[e]);e.length=0;for(const t of f)e.push(t)}(e,t,o)}function Xo(e,t,o,i,r){const{plotH:s,padding:n,valueScale:a,packing:c,laneOrder:l,lifetimeMode:u="full"}=r,h={},d={};for(const t of e)h[t.id]=o[t.id].topPeak||0,d[t.id]=o[t.id].botPeak||0;const g="half"===u,p={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,o=Array.isArray(t.xExtent)?t.xExtent[1]:null;let r=null!=e&&Number.isFinite(e)?e:1/0,s=null!=o&&Number.isFinite(o)?o:-1/0;for(const e of i.outgoing[t.id]){r>e.startTime&&(r=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&r>e.systemInTime&&(r=e.systemInTime);const t=g?(e.startTime+e.endTime)/2:e.endTime;t>s&&(s=t)}for(const e of i.incoming[t.id]){const t=g?(e.startTime+e.endTime)/2:e.startTime;r>t&&(r=t),e.endTime>s&&(s=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>s&&(s=e.systemOutTime)}p[t.id]={start:Number.isFinite(r)?r:null,end:Number.isFinite(s)?s:null}}const f={},y=[];if("reuse"===c){const o=new Map;for(const t of e)o.set(t.id,0);const r=new Map;for(const t of e)r.set(t.id,0);for(const e of t)r.set(e.target,(r.get(e.target)??0)+1);const s=[];for(const t of e)0===(r.get(t.id)??0)&&s.push(t.id);for(;s.length;){const e=s.shift();for(const t of i.outgoing[e]??[]){const i=(o.get(e)??0)+1;i>(o.get(t.target)??0)&&o.set(t.target,i),r.set(t.target,r.get(t.target)-1),0===r.get(t.target)&&s.push(t.target)}}const n=[...e].filter(e=>null!==p[e.id].start).sort((e,t)=>{const i=o.get(e.id)??0,r=o.get(t.id)??0;return i!==r?i-r:p[e.id].start-p[t.id].start}),a=e.filter(e=>null===p[e.id].start);for(const e of[...n,...a]){const t=p[e.id];let o=-1;for(let e=0;y.length>e;e++){const i=y[e].occupants[y[e].occupants.length-1];if(null===t.start||void 0===i||t.start>=i.end){o=e;break}}-1===o&&(y.push({occupants:[],peak:{topPeak:0,botPeak:0}}),o=y.length-1),y[o].occupants.push({id:e.id,end:t?.end??-1/0}),y[o].peak.topPeak=Math.max(y[o].peak.topPeak,h[e.id]),y[o].peak.botPeak=Math.max(y[o].peak.botPeak,d[e.id]),f[e.id]=o}}else e.forEach((e,t)=>{y.push({occupants:[{id:e.id,end:p[e.id]?.end??-1/0}],peak:{topPeak:h[e.id],botPeak:d[e.id]}}),f[e.id]=t});let m=null,b=null,x=null,v=null;const A=()=>{m=$o(f,t),x=Go(f,t)},S=()=>{b=$o(f,t),v=Go(f,t)};"crossing-min"===l?(A(),Vo(y,f,t),S()):"inside-out"===l?(A(),function(e,t){const o=e.length;if(1>=o)return;const i=e=>e.peak.topPeak+e.peak.botPeak,r=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>i(t.slot)-i(e.slot)),s=Array(o),n=Math.floor((o-1)/2);s[n]=r[0].idx;let a=n-1,c=n+1;for(let e=1;r.length>e;e++)e%2==1&&o>c||0>a?s[c++]=r[e].idx:s[a--]=r[e].idx;const l=s.map(t=>e[t]),u=new Map;s.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of l)e.push(t)}(y,f),S()):"crossing-min+inside-out"===l&&(A(),Vo(y,f,t),function(e,t,o){const i=e.length;if(1>=i)return;const r=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),s=Math.floor((i-1)/2);let n=Yo(t,o);for(const{slot:a}of r){const r=e.indexOf(a);if(0>r)continue;const c=s;if(r===c)continue;const l=e[r];e.splice(r,1),e.splice(c,0,l);const u=new Map;for(let e=0;i>e;e++)u.set(e,e);if(c>r){for(let e=r+1;c>=e;e++)u.set(e,e-1);u.set(r,c)}else{for(let e=c;r>e;e++)u.set(e,e+1);u.set(r,c)}for(const e of Object.keys(t))t[e]=u.get(t[e]);const h=Yo(t,o);if(h>n){const o=e[c];e.splice(c,1),e.splice(r,0,o);const s=new Map;for(let e=0;i>e;e++)s.set(e,e);if(r>c){for(let e=c+1;r>=e;e++)s.set(e,e-1);s.set(c,r)}else{for(let e=r;c>e;e++)s.set(e,e+1);s.set(c,r)}for(const e of Object.keys(t))t[e]=s.get(t[e])}else n=h}}(y,f,t),S());const w=y.map(e=>{const t=new Map;for(const i of e.occupants){const e=o[i.id];if(e)for(const o of e.samples){const e=t.get(o.t)||{top:0,bot:0};t.set(o.t,{top:Math.max(e.top,o.topMass),bot:Math.max(e.bot,o.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),k=(e,t)=>{let o={top:0,bot:0};for(const[i,r]of e){if(i>t)break;o=r}return o},_=[];for(let e=0;y.length-1>e;e++){const t=w[e],o=w[e+1],i=new Set([...t.map(e=>e[0]),...o.map(e=>e[0])]);let r=0;for(const e of i){const i=k(t,e),s=k(o,e);i.bot+s.top>r&&(r=i.bot+s.top)}_.push(r)}const M=[];let P=n+(y[0]?.peak.topPeak??0)*a;y.length>0&&M.push(P);for(let e=1;y.length>e;e++)P+=_[e-1]*a+n,M.push(P);if(y.length>0&&(P+=y[y.length-1].peak.botPeak*a+n),P>s){const e=s/P;for(let t=0;M.length>t;t++)M[t]*=e}const T=0===y.length?0:y[0].peak.topPeak+_.reduce((e,t)=>e+t,0)+y[y.length-1].peak.botPeak,L={};for(const t of e)L[t.id]=M[f[t.id]];return{effectiveSlotsHeight:T,centerlines:L,laneLifetime:p,slots:y,slotByNode:f,slotCenter:M,crossingsBefore:m,crossingsAfter:b,lengthBefore:x,lengthAfter:v}}function qo(e){const{nodes:t,edges:o,domain:i,plotW:r,plotH:s,ribbonLane:n,edgeOpacity:a,colorOf:c,layoutOpts:l}=e,u=function(e,t,o){const i=[],r=new Set(e.map(e=>e.id)),s=Array.isArray(o)&&2===o.length,n=s&&Number.isFinite(o[0])&&Number.isFinite(o[1]);s&&n&&n&&o[1]>=o[0]||i.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||i.push({kind:"invalid-node-time",id:t.id}));for(const e of t)r.has(e.source)||i.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),r.has(e.target)||i.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||i.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||i.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):i.push({kind:"invalid-edge-time",id:e.id});return i}(t,o,i),h=Eo().domain(i).range([0,r]);if(u.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:u,xScale:h};const d=function(e,t,o){const{plotH:i,pairing:r="temporal",packing:s="reuse",laneOrder:n="crossing-min",lifetimeMode:a="half"}=o,c=function(e,t){const o={},i={};for(const t of e)o[t.id]=[],i[t.id]=[];for(const e of t)i[e.source]&&i[e.source].push(e),o[e.target]&&o[e.target].push(e);return{incoming:o,outgoing:i}}(e,t),l=function(e,t,o,i="value"){const r="temporal"===i?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,s="temporal"===i?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,n=new Map;for(const e of t)n.set(e.id,{});const a=(e,t)=>{const o=new Map;for(const i of e){const e=i[t];o.has(e)||o.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const r=o.get(e);r.edges.push(i),r.total+=i.value,r.earliestStart=Math.min(r.earliestStart,i.startTime),r.latestEnd=Math.max(r.latestEnd,i.endTime)}const n=[...o.values()];n.sort("temporal"===i?(e,o)=>"target"===t?e.earliestStart-o.earliestStart:e.latestEnd-o.latestEnd:(e,t)=>t.total-e.total);for(const e of n)e.edges.sort("target"===t?s:r);return n};for(const t of e){const e=o.outgoing[t.id],i=o.incoming[t.id];if(0===i.length)a(e,"target").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)n.get(t.id).sourceSide=o});else if(0===e.length)a(i,"source").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)n.get(t.id).targetSide=o});else{const t=a(i,"source"),o=a(e,"target"),r=Math.max(t.length,o.length);for(let e=0;r>e;e++){const i=e%2==0?"top":"bot";if(t[e])for(const o of t[e].edges)n.get(o.id).targetSide=i;if(o[e])for(const t of o[e].edges)n.get(t.id).sourceSide=i}}}return n}(e,t,c,r);let u={};for(const t of e)u[t.id]=jo(t,c,l);const h=Xo(e,t,u,c,{plotH:i,padding:12,valueScale:1,packing:s,laneOrder:n,lifetimeMode:a}),d=new Set;for(const e of t){const t=h.slotByNode[e.source],o=h.slotByNode[e.target];if(void 0===t||void 0===o)continue;const i=l.get(e.id);t!==o?t>o?(i.sourceSide="top",i.targetSide="bot"):(i.sourceSide="bot",i.targetSide="top"):(d.add(e.id),i.sourceSide="bot",i.targetSide="bot")}for(const t of e){const e=c.outgoing[t.id],o=c.incoming[t.id],i=new Set(e.map(e=>l.get(e.id).sourceSide)),r=new Set(o.map(e=>l.get(e.id).targetSide));if(1===i.size&&o.length>0){const e=[...i][0];for(const t of o)h.slotByNode[t.source]===h.slotByNode[t.target]&&(l.get(t.id).targetSide=e)}if(1===r.size&&e.length>0){const t=[...r][0];for(const o of e)h.slotByNode[o.source]===h.slotByNode[o.target]&&(l.get(o.id).sourceSide=t)}}for(const t of e){const e=c.incoming[t.id],o=c.outgoing[t.id];if(0===e.length||0===o.length)continue;const i=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const o of e)"top"===l.get(o.id).targetSide?t.inTop+=o.value:t.inBot+=o.value;for(const e of o)"top"===l.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},r=(e,t)=>{const r=i(),s="top"===e?r.outTop-r.inTop:r.outBot-r.inBot,n="top"===t?r.inTop-r.outTop:r.inBot-r.outBot;if(0>=s||0>=n)return!1;const a=Math.min(s,n),c=o.filter(t=>!d.has(t.id)&&l.get(t.id).sourceSide===e&&a>=t.value).sort((e,t)=>t.value-e.value);return 0!==c.length&&(l.get(c[0].id).sourceSide=t,!0)};let s=o.length+1;for(;s-- >0&&(r("top","bot")||r("bot","top")););}u={};for(const t of e)u[t.id]=jo(t,c,l);const g=Xo(e,t,u,c,{plotH:i,padding:12,valueScale:1,packing:s,laneOrder:n,lifetimeMode:a}),p=g.effectiveSlotsHeight??g.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),f=Math.min(12,.35*i/Math.max(g.slots.length+1,1)),y=p>0?Math.max(0,(i-f*(g.slots.length+1))/p):1,m=Xo(e,t,u,c,{plotH:i,padding:f,valueScale:y,packing:s,laneOrder:n,lifetimeMode:a});return{nodeData:u,sides:l,valueScale:y,padding:f,compressedPadding:12>f,centerlines:m.centerlines,laneLifetime:m.laneLifetime,slots:m.slots,slotByNode:m.slotByNode,crossingsBefore:m.crossingsBefore,crossingsAfter:m.crossingsAfter,lengthBefore:m.lengthBefore,lengthAfter:m.lengthAfter}}(t,o,{plotH:s,...l}),{centerlines:g,nodeData:p,valueScale:f}=d,y=[],m=[];t.forEach((e,t)=>{const r=p[e.id];if(!r||0===r.samples.length)return;const s=function(e,t,o,i,r){if(0===e.length)return null;const s=Wo(e,r),n=e=>t-s[e].topMass*o,a=e=>t+s[e].botMass*o;let c=`M${i(s[0].t)},${n(0)}`;for(let e=1;s.length>e;e++)c+=` L${i(s[e].t)},${n(e)}`;c+=` L${i(s[s.length-1].t)},${a(s.length-1)}`;for(let e=s.length-2;e>=0;e--)c+=` L${i(s[e].t)},${a(e)}`;return c+" Z"}(r.samples,g[e.id],f,h,i);if(!s)return;const n=Wo(r.samples,i),a=n.find(e=>e.topMass+e.botMass>0)||n[0],l=g[e.id]+(a.botMass-a.topMass)*f/2,u=c(e.id,t),m=function(e,t,o,i,r){const s=o.nodeData[e];if(!s||0===s.samples.length)return[];const n=o.valueScale,a=o.centerlines[e],c=Wo(s.samples,r),l=c.find(e=>e.topMass+e.botMass>0)||c[0],u=[...c].reverse().find(e=>e.topMass+e.botMass>0)||c[c.length-1],h=i(l.t),d=i(u.t),g=e=>i(No(e,r)),p=[],f=(e,t,o,i)=>`M${e},${t} L${o},${t} L${o},${i} L${e},${i} Z`;for(const o of t){if(o.source===e&&null!=o.systemInTime&&Number.isFinite(o.systemInTime)){const e=s.localAttachments.get(o.id);if(e&&"out"===e.kind&&o.startTime>o.systemInTime){const t=g(o.systemInTime),i=g(o.startTime),r=t-20,s=Math.max(h,r);if(i>s){const[o,c]=Io(e,a,n);p.push({pathD:f(s,o,i,c),x0:r,x1:t,from:0,to:1})}}}if(o.target===e&&null!=o.systemOutTime&&Number.isFinite(o.systemOutTime)){const e=s.localAttachments.get(o.id);if(e&&"in"===e.kind&&o.systemOutTime>o.endTime){const t=g(o.systemOutTime),i=g(o.endTime),r=t+20,s=Math.min(d,r);if(s>i){const[o,c]=Io(e,a,n);p.push({pathD:f(i,o,s,c),x0:t,x1:r,from:1,to:0})}}}}return p}(e.id,o,d,h,i);y.push({id:e.id,pathD:s,fill:u,stroke:u,strokeWidth:.5,...m.length>0&&{gradientStubs:m},rawDatum:e.__raw??e,labelX:h(a.t)-4,labelY:l,labelText:e.id})});const b=new Map;return t.forEach((e,t)=>b.set(e.id,t)),o.forEach(e=>{const t=p[e.source]?.localAttachments.get(e.id),o=p[e.target]?.localAttachments.get(e.id);if(!t||!o)return;const r=b.get(e.source)??0,s=c(e.source,r),l=function(e,t,o,i,r,s,n,a){const c=r,l=e=>a?Math.max(a[0],Math.min(a[1],e)):e,u=s(l(e.time)),h=s(l(o.time)),d=e.value*c,g=o.value*c,p=e.sideMassBefore*c,f=o.sideMassAfter*c;let y,m,b,x;"top"===e.side?(y=t-p,m=y+d):(m=t+p,y=m-d),"top"===o.side?(b=i-f,x=b+g):(x=i+f,b=x-g);const v="source"===n?u+.85*(h-u):"target"===n?u+.15*(h-u):(u+h)/2;return{sx:u,sTop:y,sBot:m,tx:h,tTop:b,tBot:x,cp1X:v,cp2X:v}}(t,g[e.source],o,g[e.target],f,h,n,i),{pathD:u,bezier:d}=D(l);m.push({id:e.id,pathD:u,fill:s,opacity:a,rawDatum:e.__raw??e,bezier:d})}),{layout:d,layoutConfig:{bands:y,ribbons:m,showLabels:!0},issues:[],xScale:h}}var Qo=e=>{const{bands:t=[],ribbons:o=[],showLabels:i=!0}=e.config,r=[];for(const e of o)r.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}});for(const e of t)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const o=e.gradientStubs[t];r.push({type:"bezier",pathD:o.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:o.x0,x1:o.x1,from:o.from,to:o.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of t)r.push({type:"bezier",pathD:e.pathD,style:{...e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86},stroke:e.stroke??e.fill,strokeWidth:e.strokeWidth??.5},datum:{__kind:"band",data:e.rawDatum,id:e.id}});const s=i?t.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:t.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:r,labels:s}};function Ko(e,t){if(!e)return[];const o=[],i=e=>{o.push(e);const r="function"==typeof t?t(e):e[t];r&&Array.isArray(r)&&r.forEach(i)};return i(e),o}function Zo(e,t,o,i){if(e&&e.length>0)return e;const r=new Set;return t.forEach(e=>{const t="function"==typeof o?o(e):e[o],s="function"==typeof i?i(e):e[i];r.add(t),r.add(s)}),Array.from(r).map(e=>({id:e}))}import*as Uo from"react";var Jo={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5};import{scaleSequential as ei}from"d3-scale";function ti(e){return e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e}function oi(e){const t=ci(e);return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:t.top,x2:t.left,y2:e.floorY,thickness:t.thickness}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:t.top,x2:e.width-t.rightInset,y2:t.top,thickness:t.thickness}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:t.left,y1:e.floorY,x2:e.width-t.rightInset,y2:e.floorY,thickness:t.thickness}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:e.width-t.rightInset,y1:t.top,x2:e.width-t.rightInset,y2:e.floorY,thickness:t.thickness}}]}function ii(e,t,o,i){return o?"function"==typeof o?o(e,t):e[o]??i:i}function ri(e){return`gauntlet:${e}:core`}function si(e,t){return`gauntlet:${e}:positive:${t}`}function ni(e,t,o){return`gauntlet:${e}:negative:${t}:${o}`}var ai={left:28,top:76,rightInset:30,thickness:8};function ci(e){const t=e.height??e.floorY+36;if(e.width>=220&&t>=160)return ai;const o=Math.max(1,Math.min(e.width,t)),i=Math.max(2,.04*e.width);return{left:i,top:Math.max(2,.08*t),rightInset:i,thickness:Math.max(1,Math.min(4,.04*o))}}function li(e){return Math.max(.12,Math.min(1,e.width/500,(e.height??e.floorY+36)/260))}function ui(e,t,o,i){const r=ci(i),s=Math.max(2,o+2),n=r.top+r.thickness/2+s,a=i.floorY-s,c=(e,t,o)=>t>o?(t+o)/2:Math.max(t,Math.min(o,e));return{x:c(e,r.left+r.thickness/2+s,i.width-r.rightInset-r.thickness/2-s),y:c(t,n,a)}}function hi(e,t,o=1){const i=[...e].sort((e,t)=>e.localeCompare(t)),r=Math.max(0,i.indexOf(t));return{angle:.82*-Math.PI+(i.length>1?r/(i.length-1):.5)*Math.PI*.64,index:r,radius:(48+r%2*6)*o}}function di(e,t,o){const i=e.activePositiveIds.reduce((e,o)=>e+(t.get(o)?.value??1),0),r=e.missingPositiveIds.length+e.poppedPositiveIds.length,s=e.negativeIds.reduce((e,t)=>e+(o.get(t)?.load??1),0);return Math.max(0,Math.min(100,75+3*i-8*s-1.2*e.delay-5*r))}function gi(e){const t=function(e,t,o){const[i,r]=e,s=220>i||160>r,n=Math.round(.48*r),a=s?r-Math.max(3,Math.min(12,.1*r)):r-36,c=(t??[]).filter(e=>!1!==e.enabled),l=Math.max(1,c.length),u=.22*i,h=l>1?(.78*i-u)/(l-1):0,d=s?Math.max(Math.round(.12*i),.08*i+6):Math.max(Math.round(.14*i),110);return{crashY:a-(s?Math.min(o,Math.max(3,.22*r)):o),floorY:a,gates:c.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(u+t*h),width:e.width??Math.max(s?8:54,Math.round(.07*i))})),graveyardX:Math.round(i*(s?.72:.84)),graveyardY:a-4,height:r,routeY:n,socketX:Math.round(i*(s?.82:.92)),startX:d,width:i}}(e.size??[900,520],e.gates,e.crashOffset??30),o=e.positiveProperties??[],i=new Map(o.map(e=>[e.id,e])),r=new Map((e.negativeProperties??[]).map(e=>[e.id,e])),s={idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor},n=(e.data??[]).map((t,n)=>{const a=function(e,t,o,i,r){const s=ii(e,t,o.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",n=i.map(e=>e.id),a=[...ii(e,t,o.positiveAccessor,n)],c=[...ii(e,t,o.negativeAccessor,[])].filter(e=>r.has(e));return{id:s,activePositiveIds:a,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...ii(e,t,o.metricsAccessor,{})},missingPositiveIds:n.filter(e=>!a.includes(e)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(ii(e,t,o.startTimeAccessor,0))||0),stage:"project filed",viability:ii(e,t,o.initialViability,100)}}(t,n,s,o,r);return{...a,viability:e.viability?.(a,{negativeProperties:r,positiveProperties:i})??di(a,i,r)}}),a=n.flatMap((o,s)=>{const n=function(e,t,o,i){const r=function(e){return{graveyardX:e.graveyardX,graveyardY:e.graveyardY,routeY:e.routeY,socketX:e.socketX,socketY:e.routeY-4,startX:e.startX,startY:e.routeY}}(o),s=i?.(e,t,o)??{};return{...r,...s,startY:s.startY??s.routeY??r.startY,socketY:s.socketY??s.routeY??r.socketY,graveyardY:s.graveyardY??r.graveyardY}}(o,s,t,e.projectPlacement);return function(e,t,o,i,r,s,n){const a=li(o),c=Math.max(3,28*a),l=i.startX,u=i.startY+(i.startY===o.routeY?38*t*a:0),h=n?.(e,t,o,i)??{},d=h.x??l,g=h.y??u,p={__gauntlet:!0,kind:"gauntlet-core",projectId:e.id,sourceDatum:e.datum},f=[{...h,id:ri(e.id),x:d,y:g,vx:h.vx??42,vy:h.vy??0,mass:h.mass??7,bodyCollisions:h.bodyCollisions??!0,shape:h.shape??{type:"circle",radius:c},spawnAt:h.spawnAt??e.startedAt,datum:p}],y=ui(d,g,h.shape&&"radius"in h.shape&&Number(h.shape.radius)||c,o);f[0].x=y.x,f[0].y=y.y;for(const t of e.activePositiveIds){const i=r.get(t);if(!i)continue;const s=hi(e.activePositiveIds,t,a),n=i.radius??Math.max(2,10*a),c=ui(y.x+Math.cos(s.angle)*s.radius,y.y+Math.sin(s.angle)*s.radius,n,o);f.push({id:si(e.id,t),x:c.x,y:c.y,vx:18*Math.cos(s.angle),vy:18*Math.sin(s.angle),mass:i.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:n},spawnAt:h.spawnAt??e.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:e.id,property:i,sourceDatum:e.datum},springs:!1===i.spring?[]:[{target:{type:"body",bodyId:ri(e.id)},stiffness:.56,damping:.9,restLength:Math.max(6,(52+s.index%2*4)*a),...i.spring??{}}]})}return e.negativeIds.forEach((t,i)=>{const r=s.get(t);r&&f.push(function(e,t,o,i,r,s,n){const a=li(s),c=t.radius??Math.max(2,7.2*a),l=ui(i+(o%4*12-12)*a,r+(54+12*Math.floor(o/4))*a,c,s);return{id:ni(e.id,t.id,o),x:l.x,y:l.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:c},spawnAt:n,datum:{__gauntlet:!0,kind:"gauntlet-negative",projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:ri(e.id)},stiffness:.62,damping:.92,restLength:Math.max(6,(52+o%4*3)*a),...t.spring??{}}]}}(e,r,i,y.x,y.y,o,h.spawnAt??e.startedAt))}),f}(o,s,t,n,i,r,e.coreBody)});return{layout:t,initialSpawns:a,config:{fixedDt:1/60,maxSubsteps:8,kernel:{gravity:{x:0,y:0},restitution:.16,friction:.44,velocityDamping:.982,maxVelocity:520,sleepAfter:.8,sleepSpeed:7},colliders:oi(t)}}}function pi(e){return e.map(e=>({...e,spawnAt:void 0}))}var fi={Sparkline:{frameType:"xy",layout:{mode:"sparkline"},buildProps:(e,t,o,i,r)=>({chartType:"line",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||t,colorAccessor:t,...i,showAxes:!1,margin:i.margin,showLegend:!1,showGrid:!1,title:void 0})},LineChart:{frameType:"xy",buildProps:(e,t,o,i,r)=>{const s=t||r.lineBy,n=r.fillArea,a=Array.isArray(n)?"mixed":n?"area":"line",c=io(i.theme).colors.categorical,l=function(e,t,o,i,r){const s=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=io(i.theme).colors.categorical,a=o??i.colorScheme??n,c="string"==typeof t?t:"__ssrLineColorBy",l="function"==typeof t?s.map(e=>({...e,__ssrLineColorBy:t(e)})):s,u=t?me(l,c,a):void 0,h=m(r.xAccessor,r.yAccessor),d=function(e){const{lineWidth:t=2,colorBy:o,colorScale:i,color:r,resolveStroke:s,fillArea:n,areaOpacity:a=.3,styleRules:c,ruleContext:l}=e;return(e,u)=>{const h={strokeWidth:t},d=!0===n||Array.isArray(n)&&null!=u&&n.includes(u);let g;return s?g=s(e,u):o?i&&(g=ve(e,o,i)):g=r||se,void 0!==g&&(h.stroke=g,d&&(h.fill=g,h.fillOpacity=a)),c?.length&&Object.assign(h,b(e,c,l?l(e,u):{value:void 0,category:u})),h}}({lineWidth:"number"==typeof r.lineWidth?r.lineWidth:2,colorBy:t,colorScale:u,color:"string"==typeof r.color?r.color:void 0,fillArea:r.fillArea,areaOpacity:"number"==typeof r.areaOpacity?r.areaOpacity:.3,styleRules:r.styleRules,ruleContext:h});return zt(d,{stroke:"string"==typeof r.stroke?r.stroke:void 0,strokeWidth:"number"==typeof r.strokeWidth?r.strokeWidth:void 0,opacity:"number"==typeof r.opacity?r.opacity:void 0})}(e,s,o,i,r),u=function(e){const t=e.xAccessor||"x",o=e.yAccessor||"y",i=e.lineBy,r=e.colorBy||i;let s=Array.isArray(e.data)?be(e.data).filter(e=>!!e&&"object"==typeof e):[];const n=function(e,t,o){const i="function"==typeof t,r="function"==typeof o,s=i?so:t,n=r?no:o;return i||r?{xKey:s,yKey:n,rows:e.map(e=>{const s={...e};return i&&(s[so]=t(e)),r&&(s[no]=o(e)),s})}:{rows:e,xKey:s,yKey:n}}(s,t,o);s=n.rows;const a=n.xKey,c=n.yKey,l=Array.isArray(e.annotations)?[...e.annotations]:[];let u,h,d="string"==typeof i||"function"==typeof i?i:void 0,g=e.baseLineStyle;if(e.forecast){const t=i&&"string"==typeof i&&"object"==typeof e.forecast?{...e.forecast,_groupBy:i}:e.forecast,o=_(s,a,c,t,e.anomaly);if(s=o.processedData,l.push(...o.annotations),u=function(e,t,o){const i=o.upperBounds,r=o.lowerBounds;if(!i&&!r)return;const s="function"==typeof i?i:"string"==typeof i?e=>e[i]:null,n="function"==typeof r?r:"string"==typeof r?e=>e[r]:null;let a=1/0,c=-1/0;for(const o of e){const e=Number(o[t]);if(Number.isFinite(e)&&(a>e&&(a=e),e>c&&(c=e)),s){const e=s(o);null!=e&&Number.isFinite(e)&&(e>c&&(c=e),a>e&&(a=e))}if(n){const e=n(o);null!=e&&Number.isFinite(e)&&(a>e&&(a=e),e>c&&(c=e))}}return Number.isFinite(a)&&Number.isFinite(c)?[a,c]:void 0}(s,c,e.forecast),i&&"string"==typeof i?(s=s.map(e=>({...e,[ao]:`${e[i]}__${e[w]||"observed"}`})),d=ao):d=w,e.baseLineStyle){const t=M(t=>e.baseLineStyle(t),e.forecast);g=e=>t(e)}}else e.anomaly&&l.push(...k(e.anomaly));if(e.gapStrategy){if("function"==typeof d){const e=d;s=s.map(t=>({...t,__semiotic_gapGroup:e(t)})),d="__semiotic_gapGroup"}const t=function(e,t,o,i,r){const s=new Map;for(const t of e){const e=r?(t[r]??"")+"":"__single";s.has(e)||s.set(e,[]),s.get(e).push(t)}if("interpolate"===t){const e=[];for(const[,t]of s)for(const r of t)co(r,o,i)||e.push(r);return{rows:e,groupKey:r}}if("zero"===t){const e=[];for(const[,t]of s)for(const r of t)co(r,o,i)?e.push({...r,[i]:0}):e.push(r);return{rows:e,groupKey:r}}const n=[],a="_gapSegment";for(const[e,t]of s){let r=0,s=[];const c=()=>{if(0===s.length)return;const t="__single"===e?"__seg"+r:`${e}__seg${r}`;for(const e of s)n.push({...e,[a]:t});s=[],r++};for(const e of t)co(e,o,i)?c():s.push(e);c()}return{rows:n,groupKey:a}}(s,e.gapStrategy,a,c,"string"==typeof d?d:void 0);s=t.rows,t.groupKey&&(d=t.groupKey)}if(e.directLabel){const t=function(e,t,o,i,r,s,n,a){if(!t||!o)return{annotations:[]};const c="object"==typeof t?t:{},l=c.position||"end",u=c.fontSize||11,h="function"==typeof o?o:e=>e[o],d=new Map;for(const t of e){const e=h(t);if(null==e)continue;const o=e+"";""!==o&&(d.has(o)||d.set(o,[]),d.get(o).push(t))}const g=new Map;for(const[e,t]of d)t.sort((e,t)=>Number(e[i])-Number(t[i])),g.set(e,"end"===l?t[t.length-1]:t[0]);const p=me(Array.from(g.entries()).map(([e])=>({__lbl:e})),"__lbl",s??n),f=Array.from(g.entries()).map(([e,t])=>({type:"text",label:e,[i]:t[i],[r]:t[r],dx:"end"===l?6:-6,dy:0,color:p?ve({__lbl:e},"__lbl",p):a||se,fontSize:u}));f.sort((e,t)=>Number(e[r])-Number(t[r]));for(let e=1;f.length>e;e++){const t=f[e-1],o=f[e],i=Number(t[r])+t.dy;u+2>Math.abs(Number(o[r])+o.dy-i)&&(o.dy+=u+2)}const y=f.reduce((e,t)=>Math.max(e,(t.label+"").length*(.6*u)),0)+10;return{annotations:f,marginExtra:"end"===l?{right:y}:{left:y}}}(s,e.directLabel,"string"==typeof r||"function"==typeof r?r:void 0,a,c,e.colorScheme,e.themeCategorical,e.color);l.push(...t.annotations),h=t.marginExtra}return{data:s,xAccessor:"function"==typeof t?a:t,yAccessor:"function"==typeof o?c:o,groupAccessor:d,colorAccessor:r,annotations:l,lineStyle:g,yExtent:u,marginExtra:h}}({data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",lineBy:r.lineBy,colorBy:s,colorScheme:o,color:"string"==typeof r.color?r.color:void 0,forecast:r.forecast,anomaly:r.anomaly,gapStrategy:r.gapStrategy,directLabel:r.directLabel,annotations:i.annotations,themeCategorical:c,baseLineStyle:l}),h=i.pointStyle||go(u.data,u.colorAccessor,o,i,r);let d=i.margin;u.marginExtra&&d&&"object"==typeof d?d={...d,...null!=u.marginExtra.right&&{right:Math.max(Number(d.right)||0,u.marginExtra.right)},...null!=u.marginExtra.left&&{left:Math.max(Number(d.left)||0,u.marginExtra.left)}}:u.marginExtra&&null==d&&(d={top:20,right:u.marginExtra.right??20,bottom:30,left:u.marginExtra.left??40});const g=(!r.directLabel||void 0!==i.showLegend)&&(i.showLegend??!!u.colorAccessor);return{chartType:a,data:u.data,xAccessor:u.xAccessor,yAccessor:u.yAccessor,groupAccessor:u.groupAccessor,colorAccessor:u.colorAccessor,colorScheme:o,lineStyle:u.lineStyle||l,...Array.isArray(n)&&{areaGroups:n},...n&&null!=r.areaOpacity&&{areaOpacity:r.areaOpacity},...null!=r.band&&{band:r.band},...i,...void 0!==d&&{margin:d},annotations:u.annotations,...u.yExtent&&!i.yExtent&&{yExtent:u.yExtent},...h&&{pointStyle:h},showLegend:g}}},AreaChart:{frameType:"xy",buildProps:(e,t,o,i,r)=>{const s=t||r.areaBy,n=Ct({data:e,safeData:Array.isArray(e)?be(e):[],areaBy:r.areaBy,lineDataAccessor:r.lineDataAccessor||"coordinates"}),a=r.semanticGradient,c=a&&a.length>0?{colorStops:Jt(a)}:i.gradientFill,l=i.pointStyle||go(n,s,o,i,r);return{chartType:"area",data:n,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",y0Accessor:r.y0Accessor,groupAccessor:r.areaBy||void 0,colorAccessor:s,colorScheme:o,...i,...void 0!==c&&{gradientFill:c},lineStyle:i.lineStyle||lo(n,s,o,i,r),...l&&{pointStyle:l}}}},DifferenceChart:{frameType:"xy",buildProps:(e,t,o,i,r)=>{const s=r.xAccessor||"x",n=r.seriesAAccessor||"a",a=r.seriesBAccessor||"b",c=e=>to(eo(s,"x",e)),l=e=>to(eo(n,"a",e)),u=e=>to(eo(a,"b",e)),h=r.seriesAColor||"var(--semiotic-danger, #dc2626)",d=r.seriesBColor||"var(--semiotic-info, #2563eb)",g=r.areaOpacity??.6,p=r.lineWidth??1.5,f=!1!==r.showLines,y=!1!==i.showLegend,m=r.seriesALabel||"A",b=r.seriesBLabel||"B",x=i.legendPosition||"right",v=function(e,t,o,i){if(!e.length)return[];const r=e.filter(e=>Number.isFinite(t(e))).sort((e,o)=>t(e)-t(o)),s=[];let n=0,a=null,c=null,l=[];const u=(e,t)=>e>t?"A":t>e?"B":null,h=e=>`seg-${n}-${e}`,d=e=>s.push(e),g=(e,t)=>{d({__x:e.x,__y:e.y,__y0:e.y,__diffSegment:h(t),__diffWinner:t,__valA:e.y,__valB:e.y,__sourceDatum:e.datum})};for(let e=0;r.length>e;e++){const s=r[e],p=t(s),f=o(s),y=i(s);if(!Number.isFinite(p)||!Number.isFinite(f)||!Number.isFinite(y))continue;const m=u(f,y);if(null!==m)if(null!=a){if(c&&c.w!==m){let e,t;if(l.length>0)e=l[0].x,t=l[0].y;else{const o=f-c.a-(y-c.b);if(0!==o){const i=Math.max(0,Math.min(1,(c.b-c.a)/o));e=c.x+i*(p-c.x),t=c.a+i*(f-c.a)}else e=c.x,t=c.a}d({__x:e,__y:t,__y0:t,__diffSegment:h(a),__diffWinner:a,__valA:t,__valB:t}),n++,a=m,d({__x:e,__y:t,__y0:t,__diffSegment:h(a),__diffWinner:a,__valA:t,__valB:t});for(let e=1;l.length>e;e++)g(l[e],a)}else for(const e of l)g(e,a);l=[],d({__x:p,__y:y>f?y:f,__y0:y>f?f:y,__diffSegment:h(a),__diffWinner:a,__valA:f,__valB:y,__sourceDatum:s}),c={x:p,a:f,b:y,w:m}}else{a=m;for(const e of l)g(e,a);l=[],d({__x:p,__y:y>f?y:f,__y0:y>f?f:y,__diffSegment:h(a),__diffWinner:a,__valA:f,__valB:y,__sourceDatum:s}),c={x:p,a:f,b:y,w:m}}else l.push({x:p,y:f,datum:s})}for(const e of l)g(e,a??"A");return s}(Array.isArray(e)?e:[],c,l,u),A=[];if(f&&Array.isArray(e)){const t=e.filter(e=>Number.isFinite(c(e))).sort((e,t)=>c(e)-c(t));for(const e of t){const t=c(e),o=l(e),i=u(e);Number.isFinite(o)&&A.push({__x:t,__y:o,__diffSegment:"line-A"}),Number.isFinite(i)&&A.push({__x:t,__y:i,__diffSegment:"line-B"})}}return{chartType:"mixed",data:[...v,...A],xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:Array.from(new Set(v.map(e=>e.__diffSegment))),areaStyle:e=>{const t=e.__diffSegment;return{fill:"A"==(t?.endsWith("-A")?"A":"B")?h:d,stroke:"none",fillOpacity:g}},lineStyle:e=>({stroke:"A"==("line-A"===e.__diffSegment?"A":"B")?h:d,strokeWidth:p,fill:"none"}),curve:r.curve||"linear",...i,...y&&{legend:{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:m,color:h},{label:b,color:d}]}]},legendPosition:x}}}},StackedAreaChart:{frameType:"xy",buildProps:(e,t,o,i,r)=>{const s=t||r.areaBy,n="string"==typeof s&&Array.isArray(e)?me(e,s,o):void 0,a="number"==typeof r.areaOpacity?r.areaOpacity:.7,c=i.lineStyle||(e=>{const t=null==s?void 0:ve(e,s,n),o=r.showLine??!0,i={fill:r.color??t,stroke:o?r.stroke??t:"none",...o?{strokeWidth:r.strokeWidth??r.lineWidth??2}:{},fillOpacity:a,...null==r.opacity?{}:{opacity:r.opacity}},c=r.styleRules;if(c?.length){const t=y(r.yAccessor),o=s?"function"==typeof s?(s(e)??"")+"":(e[s]??"")+"":void 0;Object.assign(i,b(e,c,{value:t(e),category:o}))}return i}),l=r.normalize?"zero":r.baseline??"zero",u=i.pointStyle||go(e,s,o,i,r);return{chartType:"stackedarea",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.areaBy,colorAccessor:s,colorScheme:o,normalize:r.normalize,baseline:l,stackOrder:r.stackOrder,lineStyle:c,...i,...u&&{pointStyle:u},curve:i.curve??r.curve??"monotoneX",showLegend:i.showLegend??!!s}}},Scatterplot:{frameType:"xy",buildProps:(e,t,o,i,r)=>{const s=i.pointStyle||ho(e,t,o,i,r),n=v(r.styleRules,r.xAccessor||"x",r.yAccessor||"y"),a=n?e=>({..."function"==typeof s?s(e):s,...n(e)}):s;return{chartType:"scatter",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,sizeAccessor:r.sizeBy,...r.symbolBy&&{symbolAccessor:r.symbolBy},...r.symbolMap&&{symbolMap:r.symbolMap},colorScheme:o,...i,sizeRange:r.sizeRange||[3,15],pointStyle:a,showLegend:i.showLegend??!!t}}},CandlestickChart:{frameType:"xy",buildProps:(e,t,o,i,r)=>{const[s]=i.size??[600,400];return{chartType:"candlestick",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.highAccessor||"high",highAccessor:r.highAccessor||"high",lowAccessor:r.lowAccessor||"low",openAccessor:r.openAccessor,closeAccessor:r.closeAccessor,candlestickStyle:r.candlestickStyle,...i,scalePadding:i.scalePadding??Math.max(2,Math.min(12,Math.round(s/40))),extentPadding:i.extentPadding??(s>200?.1:.02)}}},BubbleChart:{frameType:"xy",buildProps:(e,t,o,i,r)=>({chartType:"scatter",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange||[5,40],colorScheme:o,...i,pointStyle:i.pointStyle||uo(e,t,o,i,r),showLegend:i.showLegend??!!t})},ConnectedScatterplot:{frameType:"xy",buildProps:(e,t,o,i,r)=>{const s=function(e,t){if(!Array.isArray(e))return{data:e,orderMap:new WeakMap};const o=t.xAccessor||"x",i=t.yAccessor||"y",r=t.orderAccessor?[...e].sort((e,o)=>null==e||"object"!=typeof e?1:null==o||"object"!=typeof o?-1:to(eo(t.orderAccessor,"order",e))-to(eo(t.orderAccessor,"order",o))):e,s=new WeakMap;let n=0;for(const e of r){if(null==e||"object"!=typeof e)continue;const t=to(eo(o,"x",e)),r=to(eo(i,"y",e));Number.isFinite(t)&&Number.isFinite(r)&&n++}let a=0;for(const e of r){if(null==e||"object"!=typeof e)continue;const t=to(eo(o,"x",e)),r=to(eo(i,"y",e));Number.isFinite(t)&&Number.isFinite(r)&&s.set(e,{idx:a++,total:n})}return{data:r,orderMap:s}}(e,r),n=r.pointRadius??4;return{chartType:"scatter",data:s.data,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,colorScheme:o,pointStyle:e=>{const t=s.orderMap.get(e),o=t?.idx??0,i=t?.total??1;return{fill:i>0?oo(o,i):"#6366f1",stroke:"white",strokeWidth:1,r:n,fillOpacity:1}},...i,svgPreRenderers:[e=>{const t=e.filter(e=>"point"===e.type&&"number"==typeof e.x&&"number"==typeof e.y);if(2>t.length)return null;const o=[];for(let e=0;t.length-1>e;e++){const i=t[e],r=t[e+1],s=oo(e,t.length);100>t.length&&o.push(Rt.createElement("line",{key:"halo-"+e,x1:i.x,y1:i.y,x2:r.x,y2:r.y,stroke:"white",strokeWidth:n+2,strokeLinecap:"round",opacity:.5})),o.push(Rt.createElement("line",{key:"segment-"+e,x1:i.x,y1:i.y,x2:r.x,y2:r.y,stroke:s,strokeWidth:n,strokeLinecap:"round"}))}return Rt.createElement(Rt.Fragment,null,...o)}]}}},QuadrantChart:{frameType:"xy",buildProps:(e,t,o,i,r)=>{const s=r.xCenter,n=r.yCenter,a=r.quadrants,c=r.centerlineStyle||{},l=!1!==r.showQuadrantLabels,u=r.quadrantLabelSize??12,h=c.stroke||"#999",d=c.strokeWidth??1,g=Array.isArray(c.strokeDasharray)?c.strokeDasharray.join(","):c.strokeDasharray,p=Rt.createElement,f=a?[(e,t,o)=>{if(!t?.x||!t?.y)return null;const i=o.width,r=o.height,c=null!=s?t.x(s):i/2,f=null!=n?t.y(n):r/2;if(null!=s&&!Number.isFinite(c))return null;if(null!=n&&!Number.isFinite(f))return null;const y=Math.max(0,Math.min(i,c)),m=Math.max(0,Math.min(r,f)),b=[{c:a.topLeft,x:0,y:0,w:y,h:m},{c:a.topRight,x:y,y:0,w:i-y,h:m},{c:a.bottomLeft,x:0,y:m,w:y,h:r-m},{c:a.bottomRight,x:y,y:m,w:i-y,h:r-m}],x=l?[p("text",{key:"ltl",x:8,y:8+u,fill:a.topLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.topLeft.label),p("text",{key:"ltr",x:i-8,y:8+u,fill:a.topRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.topRight.label),p("text",{key:"lbl",x:8,y:r-8,fill:a.bottomLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.bottomLeft.label),p("text",{key:"lbr",x:i-8,y:r-8,fill:a.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.bottomRight.label)]:[];return p(Rt.Fragment,null,...b.map((e,t)=>e.w>0&&e.h>0?p("rect",{key:"qf-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.c.color,opacity:e.c.opacity??.08}):null),p("line",{key:"vc",x1:y,y1:0,x2:y,y2:r,stroke:h,strokeWidth:d,strokeDasharray:g}),p("line",{key:"hc",x1:0,y1:m,x2:i,y2:m,stroke:h,strokeWidth:d,strokeDasharray:g}),...x)}]:void 0;return{chartType:"scatter",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange||[3,15],colorScheme:o,pointStyle:i.pointStyle||r.pointStyle||ho(e,t,o,i,r),...i,showLegend:i.showLegend??!!t,...f&&{svgPreRenderers:f}}}},Heatmap:{frameType:"xy",buildProps:(e,t,o,i,r)=>({chartType:"heatmap",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",valueAccessor:r.valueAccessor,colorScheme:o||r.colorScheme||"blues",showValues:r.showValues,heatmapValueFormat:r.valueFormat,cellBorderColor:r.cellBorderColor,...i})},TemporalHistogram:{frameType:"xy",buildProps:(e,t,o,i,r)=>{const s=Array.isArray(e)?be(e):[],n=r.timeAccessor||"time",a=r.valueAccessor||"value",c=r.categoryAccessor,l=r.valueExtent||i.yExtent,u="down"===r.direction?K({data:s,timeAccessor:n,valueAccessor:a,binSize:Number(r.binSize),valueExtent:l,extentPadding:r.extentPadding}):l,h={...void 0!==r.fill&&{fill:r.fill},...void 0!==r.stroke&&{stroke:r.stroke},...void 0!==r.strokeWidth&&{strokeWidth:r.strokeWidth},...void 0!==r.opacity&&{opacity:r.opacity},...void 0!==r.gap&&{gap:r.gap}};return{chartType:"bar",data:s,...i,runtimeMode:"streaming",windowMode:"growing",windowSize:Math.max(1,s.length),arrowOfTime:r.arrowOfTime||"right",timeAccessor:n,valueAccessor:a,xExtent:r.timeExtent||i.xExtent,yExtent:u,extentPadding:r.extentPadding??i.extentPadding,binSize:r.binSize,categoryAccessor:c,barColors:r.colors||i.barColors,colorScheme:r.colors||i.colorScheme,barStyle:i.barStyle||h,showLegend:i.showLegend??!!c}}},XYCustomChart:{frameType:"xy",buildProps:(e,t,o,i,r)=>({chartType:"custom",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,colorScheme:o,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...i,showAxes:r.frameProps?.showAxes??r.showAxes??!1,showLegend:i.showLegend??!!t})},BarChart:{frameType:"ordinal",buildProps:(e,t,o,i,r)=>({chartType:"bar",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:r.sort??!1,colorAccessor:t,colorScheme:o,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...i,gradientFill:Ro(i.gradientFill),pieceStyle:Co(e,t,o,i,r)})},StackedBarChart:{frameType:"ordinal",buildProps:(e,t,o,i,r)=>{const s=t||r.stackBy;return{chartType:"bar",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.stackBy,colorAccessor:s,colorScheme:o,projection:"horizontal"===r.orientation?"horizontal":"vertical",normalize:r.normalize,oSort:r.sort??!1,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...i,gradientFill:Ro(i.gradientFill),pieceStyle:Co(e,s,o,i,r),showLegend:i.showLegend??!!s}}},GroupedBarChart:{frameType:"ordinal",buildProps:(e,t,o,i,r)=>{const s=t||r.groupBy;return{chartType:"clusterbar",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",groupBy:r.groupBy,colorAccessor:s,colorScheme:o,projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:r.sort??!1,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...i,gradientFill:Ro(i.gradientFill),pieceStyle:Co(e,s,o,i,r),showLegend:i.showLegend??!!s}}},PieChart:{frameType:"ordinal",buildProps:(e,t,o,i,r)=>{const s=t||r.categoryAccessor;return{chartType:"pie",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",colorAccessor:s,colorScheme:o,...null!=r.cornerRadius&&{cornerRadius:r.cornerRadius},...null!=r.startAngle&&{startAngle:r.startAngle},...i,pieceStyle:Co(e,s,o,i,r),showLegend:i.showLegend??!!s}}},DonutChart:{frameType:"ordinal",layout:{primarySize:{width:400,height:400}},buildProps:(e,t,o,i,r)=>{const s=t||r.categoryAccessor;return{chartType:"donut",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",margin:i.margin??{top:50,right:40,bottom:60,left:70},innerRadius:r.innerRadius??60,colorAccessor:s,colorScheme:o,...null!=r.cornerRadius&&{cornerRadius:r.cornerRadius},...null!=r.startAngle&&{startAngle:r.startAngle},...i,pieceStyle:Co(e,s,o,i,r)}}},Histogram:{frameType:"ordinal",buildProps:(e,t,o,i,r)=>{const s=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],n=r.valueAccessor||"value",a=s.map(e=>Number("function"==typeof n?n(e):e[n])).filter(Number.isFinite),c=a.length?[Math.min(...a),Math.max(...a)]:void 0;return{chartType:"histogram",data:e,oAccessor:r.categoryAccessor||(e=>null==e.category?"All":e.category+""),rAccessor:n,projection:"horizontal",bins:r.bins??25,normalize:r.relative??!1,colorAccessor:t,colorScheme:o,barPadding:r.categoryPadding??20,...r.valueExtent?{rExtent:r.valueExtent}:c?{rExtent:c}:{},...i,summaryStyle:zo(e,t,o,i,r)}}},BoxPlot:{frameType:"ordinal",buildProps:(e,t,o,i,r)=>({chartType:"boxplot",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:t,colorScheme:o,...null!=r.showOutliers&&{showOutliers:r.showOutliers},...null!=r.outlierRadius&&{outlierRadius:r.outlierRadius},...i,summaryStyle:i.summaryStyle||zo(e,t,o,i,r)})},ViolinPlot:{frameType:"ordinal",buildProps:(e,t,o,i,r)=>({chartType:"violin",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:t,projection:"horizontal"===r.orientation?"horizontal":"vertical",bins:r.bins??25,showIQR:r.showIQR??!0,barPadding:r.categoryPadding??20,colorScheme:o,...i,summaryStyle:i.summaryStyle||Fo(e,t,o,i,r),showLegend:i.showLegend??!!t,...r.valueExtent&&{rExtent:r.valueExtent}})},SwarmPlot:{frameType:"ordinal",buildProps:(e,t,o,i,r)=>({chartType:"swarm",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:t,...r.symbolBy&&{symbolAccessor:r.symbolBy},...r.symbolMap&&{symbolMap:r.symbolMap},colorScheme:o,...i,sizeRange:r.sizeRange||[3,8],pieceStyle:i.pieceStyle||Oo(e,t,o,i,r),showLegend:i.showLegend??!!t})},DotPlot:{frameType:"ordinal",layout:{modeDefaults:{showGrid:!0}},buildProps:(e,t,o,i,r)=>({chartType:"point",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:t,colorScheme:o,projection:"vertical"===r.orientation?"vertical":"horizontal",oSort:r.sort??"auto",barPadding:r.categoryPadding??10,...i,pieceStyle:Bo(e,t,o,i,r),showGrid:i.showGrid??!0,showLegend:i.showLegend??!!t})},SwimlaneChart:{frameType:"ordinal",buildProps:(e,t,o,i,r)=>{const s=t||r.subcategoryAccessor;return{chartType:"swimlane",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.subcategoryAccessor,colorAccessor:s,categoryAccessor:r.categoryAccessor,subcategoryAccessor:r.subcategoryAccessor,colorScheme:o,projection:"vertical"===r.orientation?"vertical":"horizontal",...null!=r.trackFill&&{trackFill:r.trackFill},...r.valueExtent&&{rExtent:r.valueExtent},...null!=r.roundedTop&&{roundedTop:r.roundedTop},...i,gradientFill:Ro(i.gradientFill),pieceStyle:i.pieceStyle||Co(e,s,o,i,r),showLegend:i.showLegend??!!s,barPadding:r.barPadding??40}}},RidgelinePlot:{frameType:"ordinal",buildProps:(e,t,o,i,r)=>({chartType:"ridgeline",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:t,colorScheme:o,projection:"vertical"===r.orientation?"vertical":"horizontal",bins:r.bins??20,amplitude:r.amplitude??1.5,barPadding:r.categoryPadding??5,oSort:r.oSort??!1,...i,summaryStyle:i.summaryStyle||((s,n)=>({fillOpacity:.5,...Co(e,t,o,i,r)(s,n)})),showLegend:i.showLegend??!!t})},LikertChart:{frameType:"ordinal",layout:{margin:(e,t)=>({...t.marginDefaults,left:"vertical"===e.orientation?t.marginDefaults.left:Math.max(100,t.marginDefaults.left)})},buildProps:(e,t,o,i,r)=>{const s=Array.isArray(r.levels)&&r.levels.length>=2?r.levels:["Strongly disagree","Disagree","Neutral","Agree","Strongly agree"],n="vertical"!==r.orientation;let a=function(e,t,o,i,r,s){const n=new Map,a=new Set(t);for(const c of e){const e=o(c);n.has(e)||n.set(e,new Map);const l=n.get(e);if(i){const e=i(c);if(null==e||!Number.isFinite(e))continue;if(!Number.isInteger(e)){"production"!==process.env.NODE_ENV&&console.warn("[LikertChart] Ignoring non-integer Likert score:",e);continue}const o=e-1;if(0>o||o>=t.length)continue;const r=t[o];l.set(r,(l.get(r)||0)+1)}else if(r&&s){const e=r(c),t=s(c);if(!a.has(e))continue;l.set(e,(l.get(e)||0)+(Number.isFinite(t)?t:0))}}const c=[];for(const[e,o]of n){let i=0;for(const e of t)i+=o.get(e)||0;if(0!==i)for(let r=0;t.length>r;r++){const s=t[r],n=o.get(s)||0;c.push({__likertCategory:e,__likertLevel:s,__likertLevelLabel:s,__likertCount:n,__likertPct:n/i*100,__likertLevelIndex:r})}}return c}(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s,To(r.categoryAccessor,"question"),r.levelAccessor?null:To(r.valueAccessor,"score"),r.levelAccessor?To(r.levelAccessor,"level"):null,r.levelAccessor?To(r.countAccessor,"count"):null);n&&(a=function(e,t){const o=t.length,i=o%2!=0,r=Math.floor(o/2),s=new Map;for(const t of e){const e=s.get(t.__likertCategory)||[];e.push(t),s.set(t.__likertCategory,e)}const n=[];for(const[,e]of s){const t=new Map;let s,a;for(const o of e)o.__likertLevel===Mo?s=o:o.__likertLevel===Po?a=o:t.set(o.__likertLevelIndex,o);i&&s&&n.push(s);for(let e=r-1;e>=0;e--){const o=t.get(e);o&&n.push(o)}i&&a&&n.push(a);for(let e=i?r+1:r;o>e;e++){const o=t.get(e);o&&n.push(o)}}return n}(function(e,t){const o=t.length,i=o%2!=0,r=Math.floor(o/2),s=[];for(const t of e){const e=t.__likertLevelIndex;if(i&&e===r){const e=t.__likertPct/2;s.push({...t,__likertLevel:Mo,__likertPct:-e}),s.push({...t,__likertLevel:Po,__likertPct:e})}else s.push(r>e?{...t,__likertPct:-t.__likertPct}:t)}return s}(a,s),s));const c=io(i.theme).colors.diverging,l=Array.isArray(o)&&o.length>=s.length?o:function(e,t){if(0>=e)return[];if(t){const o=_o[t];if(o){if(1===e)return[o(.5)];const t=[];for(let i=0;e>i;i++)t.push(o(i/(e-1)));return t}}const o=["#da1e28","#ff8389","#ffb3b8"],i=["#a6c8ff","#4589ff","#0043ce"],r="#a8a8a8";if(1===e)return[r];const s=e%2!=0,n=Math.floor(e/2),a=[];for(let e=0;n>e;e++)a.push(o[Math.min(Math.floor(e*o.length/n),o.length-1)]);s&&a.push(r);for(let e=0;n>e;e++)a.push(i[Math.min(Math.floor(e*i.length/n),i.length-1)]);return a}(s.length,c),u=new Map(s.map((e,t)=>[e,l[t]||"#888"])),h=s.length%2&&u.get(s[Math.floor(s.length/2)])||"#888",d="function"==typeof r.valueFormat?r.valueFormat:e=>Math.abs(Number(e)).toFixed(0)+"%",g=!1===i.showLegend?void 0:{legendGroups:[{label:"",items:s.map(e=>({label:e})),styleFn:e=>({fill:u.get(e.label)||"#888"})}]},p=pe(g,i.legend);return{chartType:"bar",data:a,oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:n?"horizontal":"vertical",barPadding:r.barPadding,showGrid:i.showGrid,oLabel:r.categoryLabel,rLabel:r.valueLabel||(n?void 0:"Percentage"),rFormat:d,...r.categoryFormat&&{oFormat:r.categoryFormat},...r.valueExtent&&{rExtent:r.valueExtent},...i,pieceStyle:e=>{const t=e.__likertLevel||e.data?.__likertLevel;return{fill:t===Mo||t===Po?h:u.get((e.__likertLevelLabel||e.data?.__likertLevelLabel||t)+"")||"#888"}},showLegend:i.showLegend??!0,legendPosition:i.legendPosition||"right",...p&&{legend:p},__legendIncludesAutomatic:!0}}},FunnelChart:{frameType:"ordinal",layout:{margin:(e,t)=>"vertical"===e.orientation?{top:t.title?60:40,right:20,bottom:60,left:60}:{top:t.title?40:10,right:10,bottom:10,left:10}},buildProps:(e,t,o,i,r)=>{const s="vertical"===r.orientation,n=t||r.categoryAccessor;return{chartType:s?"bar-funnel":"funnel",data:e,oAccessor:r.stepAccessor||"step",rAccessor:r.valueAccessor||"value",colorAccessor:n,categoryAccessor:r.categoryAccessor,projection:s?"vertical":"horizontal",connectorAccessor:r.connectorAccessor,connectorStyle:r.connectorStyle,...!s&&null!=r.connectorOpacity&&{connectorOpacity:r.connectorOpacity},barPadding:s?40:0,colorScheme:o,...i,showAxes:s,showGrid:s,pieceStyle:Co(e,n,o,i,r),showLabels:r.showLabels??!0}}},GaugeChart:{frameType:"ordinal",layout:{primarySize:{width:300,height:250}},renderOverlay:function(e,{theme:t}){const o=e.__gauge;if(!o)return null;const i=(o.startAngleDeg+(o.gMax===o.gMin?0:(Math.max(o.gMin,Math.min(o.gMax,o.value??o.gMin))-o.gMin)/(o.gMax-o.gMin))*o.sweep-90)*Math.PI/180,r=o.needleColor||t.colors.text,s=o.showScaleLabels?(o.thresholds||[]).filter(e=>e.value>o.gMin&&o.gMax>e.value):[];return Ao(xo,{children:[o.showNeedle&&Ao(xo,{children:[vo("line",{x1:o.centerX,y1:o.centerY,x2:o.centerX+o.needleLength*Math.cos(i),y2:o.centerY+o.needleLength*Math.sin(i),stroke:r,strokeWidth:2.5,strokeLinecap:"round"}),vo("circle",{cx:o.centerX,cy:o.centerY,r:4,fill:r})]}),null!=o.contextValue&&vo("text",{x:o.centerX,y:o.contextValueY,textAnchor:"middle",dominantBaseline:"middle",fontSize:o.valueFontSize,fontWeight:700,fill:r,children:o.contextValue}),s.map((e,i)=>{const r=(o.startAngleDeg+(o.gMax===o.gMin?0:(e.value-o.gMin)/(o.gMax-o.gMin))*o.sweep-90)*Math.PI/180,s=o.innerRadius-1,n=o.radius+1,a=o.radius+10,c=((r+Math.PI/2)/(2*Math.PI)*12+12)%12,l=c>=11||1>c?"middle":5>c?"start":7>c?"middle":"end",u=c>=11||1>c?"auto":5>c?"middle":7>c?"hanging":"middle";return Ao("g",{children:[vo("line",{x1:o.centerX+Math.cos(r)*s,y1:o.centerY+Math.sin(r)*s,x2:o.centerX+Math.cos(r)*n,y2:o.centerY+Math.sin(r)*n,stroke:t.colors.border,strokeWidth:2,strokeLinecap:"round"}),vo("text",{x:o.centerX+Math.cos(r)*a,y:o.centerY+Math.sin(r)*a,textAnchor:l,dominantBaseline:u,fill:t.colors.textSecondary,fontSize:10,children:e.label||e.value+""})]},"gauge-label-"+i)})]})},buildProps:(o,i,r,s,n)=>{const a=n.min??0,c=n.max??100,l=n.sweep??240,u=n.arcWidth??.3,h=!1!==n.showNeedle,d=!1!==n.fillZones,{startAngleDeg:g}=t(l),p=n.thresholds||[{value:c,color:n.color||"#4e79a7"}],f=s.gradientFill,y=function(e){const{min:t,max:o,value:i,thresholds:r,fillColor:s,backgroundColor:n,fillZones:a,showScaleLabels:c,gradientFill:l,gradientSteps:u=240}=e,h=o-t||1,d=(Math.max(t,Math.min(o,i))-t)/h;let g=r&&r.length>0?[...r].sort((e,t)=>e.value-t.value):[{value:o,color:s||"#007bff"}];g=g.map(e=>({...e,value:Math.max(t,Math.min(o,e.value))})),o>g[g.length-1].value&&g.push({value:o,color:g[g.length-1].color});const p=!!l&&l.colorStops.length>=2,f=[],y=new Map,m=[];if(p){const e=a?d:1,t=bo("bg",0);if(f.push({category:t,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),y.set(t,{fill:n,opacity:.4}),e>0){const t=Math.max(1,Math.floor(u)),o=Math.max(1,Math.min(t,Math.round(e*t))),i=[];for(let t=0;o>t;t++)i.push(mo(l.colorStops,e*(t+.5)/o));const r=bo("fill",0);f.push({category:r,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:i}}),y.set(r,{fill:i[0]||n})}}else{let e=t;for(let o=0;g.length>o;o++){const i=g[o],r=(i.value-e)/h,s=(e-t)/h,c=(i.value-t)/h,l=Math.max(0,(a?Math.min(d,c):c)-s),u=a?Math.max(0,r-l):0;if(l>0){const e=bo("fill",o);f.push({category:e,value:l,_zone:i.label||"Zone "+(o+1),_isFill:!0}),y.set(e,{fill:i.color})}if(u>0){const e=bo("bg",o);f.push({category:e,value:u,_zone:i.label||"Zone "+(o+1),_isFill:!1}),y.set(e,{fill:n,opacity:.4})}e=i.value}}if(c&&r&&r.length>0)for(const e of r)e.value>t&&o>e.value&&m.push({type:"gauge-label",value:e.value,label:e.label||e.value+""});return{gaugeData:f,pieceStyle:(e,t)=>y.get(t||e.category)||{fill:n},gaugeAnnotations:m}}({min:a,max:c,value:n.value,thresholds:p,fillColor:n.color,backgroundColor:n.backgroundColor||"#e0e0e0",fillZones:d,showScaleLabels:!1!==n.showScaleLabels,gradientFill:f&&"object"==typeof f&&"colorStops"in f?f:void 0}),[m,b]=s.size||[300,250],x=e(l),v=Math.min(10,Math.max(1,Math.min(m,b)/12)),A=Math.max(4,Math.min((m-2*v)/x.width,(b-2*v)/x.height)-2),S=Math.max(0,Math.min(A-1.5,A*(1-u))),w=m/2-x.cx*A,k=b/2-x.cy*A,_=2*(A+4),M=Math.max(a,Math.min(c,n.value??a)),P="function"==typeof n.valueFormat?n.valueFormat(M):Math.round(M)+"",T=n.centerContent??s.centerContent,L=null!=T?"function"==typeof T?T(M,a,c):T:"sparkline"===n.mode||"context"===n.mode?void 0:Lo.createElement("div",{style:{textAlign:"center",lineHeight:1.2}},Lo.createElement("div",{style:{fontSize:Math.max(16,.3*A),fontWeight:700,color:"var(--semiotic-text, #333)"}},P),!1!==n.showScaleLabels&&Lo.createElement("div",{style:{fontSize:11,color:"var(--semiotic-text-secondary, #666)"}},`${a} – ${c}`));return{chartType:"donut",data:y.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:S,sweepAngle:l,startAngle:g,oSort:!1,pieceStyle:y.pieceStyle,...null!=n.cornerRadius&&{cornerRadius:n.cornerRadius},...s,size:[m,b],margin:{top:k-_/2,bottom:b-k-_/2,left:w-_/2,right:m-w-_/2},...null!=L&&{centerContent:L},showAxes:!1,annotations:[...Array.isArray(s.annotations)?s.annotations:[],...y.gaugeAnnotations],__gauge:{gMin:a,gMax:c,sweep:l,arcWidth:u,value:M,startAngleDeg:g,thresholds:p,centerX:w,centerY:k,radius:A,innerRadius:S,showScaleLabels:!1!==n.showScaleLabels,needleLength:S>20?S-8:A-1,showNeedle:h,needleColor:n.needleColor,..."context"===n.mode&&null==T&&{contextValue:P,contextValueY:k-.2*S,valueFontSize:Math.max(12,Math.min(22,.28*A))}}}}},OrdinalCustomChart:{frameType:"ordinal",buildProps:(e,t,o,i,r)=>({chartType:"custom",data:e,oAccessor:r.categoryAccessor||r.oAccessor||"category",rAccessor:r.valueAccessor||r.rAccessor||"value",projection:r.projection||"vertical",colorAccessor:t,colorScheme:o,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...i,showAxes:r.frameProps?.showAxes??r.showAxes??!1})},ForceDirectedGraph:{frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,o,i,r)=>{const{edgeWidth:s,edgeColor:n,edgeOpacity:a}=r,c=r.edgeStyle??(void 0!==s||void 0!==n||void 0!==a?e=>{const t=e?.data||e;let o=1;if("number"==typeof s)o=s;else if("function"==typeof s)o=s(t);else if("string"==typeof s){const e=t?.[s],i="number"==typeof e?e:Number(e);o=Number.isFinite(i)&&i>0?i:1}return{stroke:n??"#999",strokeWidth:o,opacity:a??.6}}:void 0),l=io(i.theme).colors.categorical,u=new Map,h=r.nodeStyle??(e=>({fill:t?ve(e?.data||e,t,void 0):We(void 0,l,o,void 0,u),..."number"==typeof r.nodeSize&&{r:r.nodeSize}})),d=x(r.styleRules,t,"number"==typeof r.nodeSize?void 0:r.nodeSize);return{chartType:"force",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,colorBy:t,colorScheme:o,iterations:r.iterations,forceStrength:r.forceStrength,showLabels:r.showLabels??!1,nodeLabel:r.nodeLabel,nodeSize:r.nodeSize??8,nodeSizeRange:r.nodeSizeRange,nodeStyle:d?(e,t)=>({...h(e),...d(e,t)}):h,edgeStyle:c,...i}}},NetworkCustomChart:{frameType:"network",layout:{margin:{top:40,right:40,bottom:40,left:40}},buildProps:(e,t,o,i,r)=>({chartType:"force",nodes:r.nodes||e||[],edges:r.edges||[],nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor||"id",sourceAccessor:r.sourceAccessor||"source",targetAccessor:r.targetAccessor||"target",valueAccessor:r.valueAccessor||"value",colorBy:t,colorScheme:o,customNetworkLayout:r.layout||r.customNetworkLayout,layoutConfig:r.layoutConfig,...i})},SankeyDiagram:{frameType:"network",layout:{primarySize:{width:800,height:600}},buildProps:(e,t,o,i,r)=>{const s=Array.isArray(r.nodes)?r.nodes:Zo([],Array.isArray(r.edges)?r.edges:[],r.sourceAccessor||"source",r.targetAccessor||"target"),n=io(i.theme).colors.categorical,a=new Map,c="string"==typeof t?t:"__ssrSankeyColorBy",l="function"==typeof t?s.map(e=>({...e,__ssrSankeyColorBy:t(e)})):s,u=t?me(l,c,o??i.colorScheme??n):void 0,h=e=>({fill:t?ve(e?.data||e,t,u):We(void 0,n,o,void 0,a),stroke:i.stroke??"black",strokeWidth:i.strokeWidth??1,...void 0!==i.opacity&&{opacity:i.opacity}}),d=x(r.styleRules,t,r.valueAccessor),g=d?(e,t)=>({...h(e),...d(e,t)}):h,p=function({edgeColorBy:e,colorBy:t,colorScale:o,nodeStyleFn:i,edgeOpacity:r,baseStyle:s={}}){return n=>{const a={fillOpacity:r,...s};if("function"==typeof e)a.fill=e(n);else if("source"===e){const e="object"==typeof n.source?n.source:null;t&&e?a.fill=ve(e.data||e,t,o):e&&(a.fill=i(e,e.index).fill)}else if("target"===e){const e="object"==typeof n.target?n.target:null;t&&e?a.fill=ve(e.data||e,t,o):e&&(a.fill=i(e,e.index).fill)}else"gradient"===e&&(a.fill="#999",a.fillOpacity=.7*r);return a}}({edgeColorBy:r.edgeColorBy??"source",colorBy:t,colorScale:u,nodeStyleFn:g,edgeOpacity:r.edgeOpacity??.5,baseStyle:{stroke:"none",strokeWidth:0}});return{chartType:"sankey",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,valueAccessor:r.valueAccessor,orientation:r.orientation,nodeAlign:r.nodeAlign,nodeWidth:r.nodeWidth,nodePaddingRatio:r.nodePaddingRatio,showLabels:r.showLabels,nodeLabel:r.nodeLabel,colorBy:t,edgeColorBy:r.edgeColorBy,edgeOpacity:r.edgeOpacity,nodeStyle:i.nodeStyle||r.nodeStyle||g,edgeStyle:i.edgeStyle||r.edgeStyle||p,colorScheme:o,...i}}},ProcessSankey:{frameType:"network",layout:{margin:{top:30,right:80,bottom:40,left:80}},buildProps:(e,t,o,i,r)=>{const s=e=>null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime(),n=r.sourceAccessor||"source",a=r.targetAccessor||"target",c=r.valueAccessor||"value",l=r.nodeIdAccessor||"id",u=r.startTimeAccessor||"startTime",h=r.endTimeAccessor||"endTime",d=r.systemInTimeAccessor,g=r.systemOutTimeAccessor,p=r.xExtentAccessor||"xExtent",f=r.edgeIdAccessor||"id",y=(e,t)=>"function"==typeof e?e(t):t[e],m=Array.isArray(r.edges)?r.edges:[],b=Array.isArray(r.nodes)?r.nodes:[],x=b.length>0?b:Zo([],m,n,a),v=[s(r.domain?.[0]),s(r.domain?.[1])],A=x.map(e=>{const t=y(l,e)+"",o=y(p,e),i={id:t,__raw:e};if(Array.isArray(o)&&2===o.length){const e=s(o[0]),t=s(o[1]);Number.isFinite(e)&&Number.isFinite(t)&&(i.xExtent=[e,t])}return i}),S=m.map((e,t)=>{const o=y(f,e),i={id:null!=o?o+"":`${y(n,e)}-${y(a,e)}-${t}`,source:y(n,e)+"",target:y(a,e)+"",value:Number(y(c,e)),startTime:s(y(u,e)),endTime:s(y(h,e)),__raw:e};if(d){const t=s(y(d,e));Number.isFinite(t)&&(i.systemInTime=t)}if(g){const t=s(y(g,e));Number.isFinite(t)&&(i.systemOutTime=t)}return i}),[w,k]=i.size??[600,400],_={top:20,right:20,bottom:20,left:20,...i.margin},M=(i.showLegend??!!t)&&!!t,P=i.legendPosition??"right",T=i.__explicitMargin,L=e=>"number"==typeof T||null!=T&&"object"==typeof T&&null!=T[e];M&&("right"!==P||L("right")?"bottom"!==P||L("bottom")||(_.bottom=Math.max(_.bottom,80)):_.right=Math.max(_.right,140));const R=_,C=w-R.left-R.right,z=k-R.top-R.bottom,F=io(i.theme),B=De(o,F.colors.categorical,bt),O="function"==typeof t?t:null,E=O?x.map(e=>({_cat:O(e)})):x,D=O?"_cat":"string"==typeof t?t:void 0,j=o??[...B],N=D?me(E,D,j):null,W=new Map;for(const e of A)W.set(e.id,e.__raw);const I=(e,o)=>{if(t&&W.has(e)){const o=W.get(e);return O?ve({_cat:O(o)},"_cat",N??void 0):ve(o,"string"==typeof t?t:"id",N??void 0)}return B[o%B.length]},$=M&&t?(()=>{const e=new Map;x.forEach((o,i)=>{const r=y(t,o),s=null==r?"":r+"";s&&!e.has(s)&&e.set(s,{label:s,color:I(y(l,o)+"",i)})});const o=Array.from(e.values());return o.length>0?{legendGroups:[{type:"fill",label:"",items:o,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0})():void 0,G=pe($,i.legend),{layout:Y,layoutConfig:H,issues:V,xScale:X}=qo({nodes:A,edges:S,domain:v,plotW:C,plotH:z,ribbonLane:r.ribbonLane||"both",edgeOpacity:"number"==typeof r.edgeOpacity?r.edgeOpacity:.35,colorOf:I,layoutOpts:{pairing:r.pairing||"temporal",packing:r.packing||"reuse",laneOrder:r.laneOrder||"crossing-min",lifetimeMode:r.lifetimeMode||"half"}});if(V.length>0){const e=V.map(Do).join("; ");throw Error("ProcessSankey: data invalid — "+e)}const q=Array.isArray(r.axisTicks)?r.axisTicks:[],Q=Y?(()=>{let e=null,t=null;for(const o of A){const i=Y.laneLifetime[o.id];if(!i||null==i.start||null==i.end)continue;const r=Number(X(i.start)),s=Number(X(i.end));e=null==e?r:Math.min(e,r),t=null==t?s:Math.max(t,s)}const o=e=>Math.max(0,Math.min(C,e)),i=o(e??0),n=Math.max(i,o(t??C)),a=q.map((e,t)=>({tick:e,index:t,x:Number(X(s(e.date)))})).filter(({x:e})=>e>=i-.5&&n+.5>=e);return Uo.createElement("g",null,...a.map(({index:e,x:t})=>Uo.createElement("line",{key:"grid-"+e,x1:t,y1:0,x2:t,y2:z,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"})),Uo.createElement("line",{key:"axis",x1:i,y1:z+4,x2:n,y2:z+4,stroke:"#94a3b8"}),...a.map(({tick:e,index:t,x:o})=>{const i=s(e.date),n=null!=e.label?e.label:"function"==typeof r.timeFormat?r.timeFormat(new Date(i)):"";return Uo.createElement("g",{key:"tick-"+t,transform:`translate(${o},${z+4})`},Uo.createElement("line",{y2:6,stroke:"#94a3b8"}),Uo.createElement("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569"},n))}))})():void 0;return{chartType:"force",nodes:x,edges:m,customNetworkLayout:Qo,layoutConfig:H,sourceAccessor:n,targetAccessor:a,valueAccessor:c,nodeIDAccessor:l,colorBy:t,colorScheme:o,...Q&&{backgroundGraphics:Q},...i,showLegend:M,...G&&{legend:G,legendPosition:P},__legendIncludesAutomatic:!0,margin:R}}},ChordDiagram:{frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,o,i,r)=>{if(!(t||Array.isArray(r.styleRules)&&r.styleRules.length>0||i.nodeStyle||r.nodeStyle))return{chartType:"chord",nodes:r.nodes,edges:r.edges,valueAccessor:r.valueAccessor,padAngle:r.padAngle,groupWidth:r.groupWidth,showLabels:r.showLabels,colorBy:t,edgeColorBy:r.edgeColorBy,colorScheme:o,...i};const s=Array.isArray(r.edges)?r.edges:[],n=Array.isArray(r.nodes)&&r.nodes.length>0?r.nodes:Zo([],s,r.sourceAccessor||"source",r.targetAccessor||"target"),a=io(i.theme).colors.categorical,c=De(o,a),l="string"==typeof t?t:"__ssrChordColorBy",u="function"==typeof t?n.map(e=>({...e,__ssrChordColorBy:t(e)})):n,h=t?me(u,l,o??i.colorScheme??a):void 0,d=new Map,g=r.nodeIdAccessor||r.nodeIDAccessor||"id",p=(e,o)=>{const r=e?.data||e;let s;if(t)s=ve(r,t,h);else{const t=(e.id??r?.[g]??"")+"";d.has(t)||d.set(t,d.size);const i=e.index??o??d.get(t);s=c[i%c.length]}return{fill:s,stroke:i.stroke??"black",strokeWidth:i.strokeWidth??1,...void 0!==i.opacity&&{opacity:i.opacity}}},f=x(r.styleRules,t,r.valueAccessor,p)??p;return{chartType:"chord",nodes:r.nodes,edges:r.edges,valueAccessor:r.valueAccessor,padAngle:r.padAngle,groupWidth:r.groupWidth,showLabels:r.showLabels,colorBy:t,edgeColorBy:r.edgeColorBy,colorScheme:o,nodeStyle:i.nodeStyle||r.nodeStyle||f,...i}}},TreeDiagram:{frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,o,i,r)=>{const s=io(i.theme).colors.categorical,n=new Map,a=Ko(e??null,r.childrenAccessor),c="function"==typeof t?t:null,l=c?a.map(e=>({__ssrTreeColorBy:c(e)})):a,u=c?"__ssrTreeColorBy":"string"==typeof t?t:void 0,h=t&&u?me(l,u,o??i.colorScheme??s):void 0;return{chartType:"cluster"===r.layout?"cluster":"tree",data:e,childrenAccessor:r.childrenAccessor,colorBy:t,colorByDepth:r.colorByDepth,orientation:r.orientation,showLabels:r.showLabels,nodeLabel:!1!==r.showLabels?r.nodeLabel||r.nodeIdAccessor:void 0,colorScheme:o,...i,nodeStyle:i.nodeStyle||r.nodeStyle||(e=>{const a=e?.data||e;return{fill:r.colorByDepth?ae[Number(e?.depth||0)%ae.length]:t?c?ve({__ssrTreeColorBy:c(a)},"__ssrTreeColorBy",h??void 0):ve(a,t,h??void 0):We(void 0,s,o,void 0,n),stroke:i.stroke??"black",strokeWidth:i.strokeWidth??1,...void 0!==i.opacity&&{opacity:i.opacity}}})}}},Treemap:{frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,o,i,r)=>{const s=io(i.theme).colors.categorical,n=new Map,a=Ko(e??null,r.childrenAccessor),c="function"==typeof t?t:null,l=c?a.map(e=>({__ssrTreemapColorBy:c(e)})):a,u=c?"__ssrTreemapColorBy":"string"==typeof t?t:void 0,h=t&&u?me(l,u,o??i.colorScheme??s):void 0,d=r.showLabels??i.showLabels,g=r.labelMode,p=void 0!==r.paddingTop?r.paddingTop:!d||"parent"!==g&&"all"!==g?void 0:18;return{chartType:"treemap",data:e,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:t,colorByDepth:r.colorByDepth,showLabels:r.showLabels,labelMode:g,nodeLabel:d?r.nodeLabel||r.nodeIdAccessor:void 0,...null!=r.padding&&{padding:r.padding},...null!=p&&{paddingTop:p},colorScheme:o,...i,nodeStyle:i.nodeStyle||r.nodeStyle||(e=>{const i=e?.data||e;return{fill:r.colorByDepth?ae[Number(e?.depth||0)%ae.length]:t?c?ve({__ssrTreemapColorBy:c(i)},"__ssrTreemapColorBy",h??void 0):ve(i,t,h??void 0):We(void 0,s,o,void 0,n),stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8}})}}},CirclePack:{frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,o,i,r)=>{const s=io(i.theme).colors.categorical,n=new Map,a=Ko(e??null,r.childrenAccessor),c="function"==typeof t?t:null,l=c?a.map(e=>({__ssrCirclePackColorBy:c(e)})):a,u=c?"__ssrCirclePackColorBy":"string"==typeof t?t:void 0,h=t&&u?me(l,u,o??i.colorScheme??s):void 0;return{chartType:"circlepack",data:e,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:t,colorByDepth:r.colorByDepth,showLabels:r.showLabels,nodeLabel:r.showLabels??i.showLabels?r.nodeLabel||r.nodeIdAccessor:void 0,...null!=r.padding&&{padding:r.padding},colorScheme:o,...i,nodeStyle:i.nodeStyle||r.nodeStyle||(e=>{const i=e?.data||e;return{fill:r.colorByDepth?ae[Number(e?.depth||0)%ae.length]:t?c?ve({__ssrCirclePackColorBy:c(i)},"__ssrCirclePackColorBy",h??void 0):ve(i,t,h??void 0):We(void 0,s,o,void 0,n),fillOpacity:r.circleOpacity??.7,stroke:"currentColor",strokeWidth:1,strokeOpacity:.3}})}}},ChoroplethMap:{frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,o,i,r)=>{const s="string"==typeof o?o:"blues",n=r.areaStyle??function(e,t,o,i){if(!Array.isArray(e))return;const r=e=>"function"==typeof t?t(e):null!=t?e?.properties?.[t]??e?.[t]:void 0;let s=1/0,n=-1/0;for(const t of e){const e=r(t);null!=e&&isFinite(e)&&(s>e&&(s=e),e>n&&(n=e))}const a=ei(lt(o)).domain([Number.isFinite(s)?s:0,Number.isFinite(n)?n:1]);return e=>{const t=r(e);return{fill:null!=t&&isFinite(t)?a(t):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:i}}}(r.areas,r.valueAccessor,s,r.areaOpacity??1),a=r.styleRules?p(n,r.styleRules,e=>{return{value:(t=e,"function"==typeof r.valueAccessor?r.valueAccessor(t):null!=r.valueAccessor?t?.properties?.[r.valueAccessor]??t?.[r.valueAccessor]:void 0)};var t},ti):n;return{areas:r.areas,projection:r.projection||"equalEarth",areaStyle:a,valueAccessor:r.valueAccessor,colorScheme:s,graticule:r.graticule,fitPadding:r.fitPadding,...i}}},ProportionalSymbolMap:{frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,o,i,r)=>{const s=e||r.points,n=r.pointStyle??function(e,t,o,i){const r=Array.isArray(e)?e:[];let s,n;if(t){const e="string"==typeof t?t:"__geoColorBy",i="string"==typeof t?r:r.map(e=>({...e,__geoColorBy:t(e)}));s=me(i,e,o)}if(i.sizeBy){const e=r.map("function"==typeof i.sizeBy?i.sizeBy:e=>e?.[i.sizeBy]).filter(e=>null!=e&&isFinite(e));e.length>0&&(n=At(e))}return e=>({fill:t&&s?ve(e,t,s):se,fillOpacity:i.fillOpacity,stroke:"#fff",strokeWidth:i.strokeWidth,r:i.sizeBy?Se(e,i.sizeBy,i.sizeRange,n):i.pointRadius??6})}(s,t,o,{sizeBy:r.sizeBy,sizeRange:r.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),a=r.styleRules?p(n,r.styleRules,f(t,r.sizeBy)):n;return{points:s,xAccessor:r.xAccessor||"lon",yAccessor:r.yAccessor||"lat",areas:r.areas,areaStyle:r.areaStyle||Jo,pointStyle:a,sizeBy:r.sizeBy,colorBy:t,colorScheme:o,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,...i}}},FlowMap:{frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,o,i,r)=>{const s=(Array.isArray(e)?e:null)||r.flows||[],n=r.nodeIdAccessor||"id",a=r.valueAccessor||"value",c=r.xAccessor||"lon",l=r.yAccessor||"lat",u="function"==typeof c?c:e=>e[c],h="function"==typeof l?l:e=>e[l],d=(r.nodes||[]).map(e=>({...e,x:u(e),y:h(e)})),g=new Map;for(const e of d)g.set(e[n]+"",e);const p=r.edgeColorBy??t,f="function"==typeof p,y=s.map(e=>{if(!e||null==e.source||null==e.target)return null;const t=g.get(e.source+""),o=g.get(e.target+"");return t&&o?{...e,coordinates:[{x:t.x,y:t.y},{x:o.x,y:o.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",b=(()=>{if(!p)return null;if(f){const e=y.map(e=>({[m]:p(e)}));return me(e,m,o||"category10")}return me(y,p,o||"category10")})(),x=e=>p&&b?ve(e,p,b):"#007bff";let v=1/0,A=-1/0;for(const e of y){const t=Number(e[a]??0);isFinite(t)&&(v>t&&(v=t),t>A&&(A=t))}const S=A>v?A-v:0,[w,k]=r.edgeWidthRange??[1,8],_=k-w,M=r.edgeOpacity??.6,P=r.edgeLinecap??"round";return{lines:y,points:d,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:r.lineType||"geo",flowStyle:r.flowStyle||"basic",areas:r.areas,areaStyle:r.areaStyle||Jo,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,colorScheme:o,lineStyle:e=>{const t=Number(e?.[a]),o=Number.isFinite(t)?t:v,i=w+Math.max(0,Math.min(1,S>0?(o-v)/S:0))*_;return{stroke:x(e),strokeWidth:i,strokeLinecap:P,opacity:M,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...i}}},GeoCustomChart:{frameType:"geo",buildProps:(e,t,o,i,r)=>({points:r.points||e||[],areas:r.areas||[],lines:r.lines||[],projection:r.projection||"equirectangular",xAccessor:r.xAccessor||"lon",yAccessor:r.yAccessor||"lat",lineDataAccessor:r.lineDataAccessor,colorBy:t,colorScheme:o,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...i})},GaltonBoardChart:{frameType:"physics",buildProps:(e,t,o,i,s)=>{const n=i.size??[600,400],a=s.bins??21,l=s.seed??1,u=Math.max(1,Math.round(s.pegRows??a-1)),h="mechanical"===s.mode,d=h?c({bins:a,branchProbability:s.branchProbability,count:s.mechanicalCount,pegRows:u,seed:l}):Array.isArray(e)?e:[],p=r({data:d,valueAccessor:s.valueAccessor||"value",bins:a,ballRadius:s.ballRadius??4,seed:l,size:n,valueExtent:h?[0,u]:void 0});return{...i,config:p.config,initialSpawns:pi(p.initialSpawns),projectionRows:p.projectionRows,bodyStyle:g(t||s.colorBy||(h?"side":void 0),"#4e79a7",{styleRules:s.styleRules,valueAccessor:s.valueAccessor||"value"})}}},EventDropChart:{frameType:"physics",buildProps:(e,t,o,r,s)=>{const n=r.size??[600,400],a=i({data:Array.isArray(e)?e:[],timeAccessor:s.timeAccessor||"time",arrivalAccessor:s.arrivalAccessor||"arrivalTime",windows:s.windows||{size:10},watermark:s.watermark,ballRadius:s.ballRadius??5,seed:s.seed??1,size:n,timeExtent:s.timeExtent,timeScale:s.timeScale??1});return{...r,config:a.config,initialSpawns:pi(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:g(t||s.colorBy,"#4e79a7",{styleRules:s.styleRules,valueAccessor:s.valueAccessor||s.timeAccessor||"time"})}}},PhysicsPileChart:{frameType:"physics",buildProps:(e,t,o,i,r)=>{const s=i.size??[600,400],a="mechanical"===r.mode,c=a?l({categories:r.mechanicalCategories,count:r.mechanicalCount,seed:r.seed??1,unitValue:r.unitValue??1}):Array.isArray(e)?e:[],u=n({data:c,categoryAccessor:r.categoryAccessor||"category",valueAccessor:r.valueAccessor||(a?"value":void 0),unitValue:r.unitValue??1,ballRadius:r.ballRadius??5,seed:r.seed??1,size:s});return{...i,config:u.config,initialSpawns:pi(u.initialSpawns),projectionRows:u.projectionRows,bodyStyle:g(t||r.colorBy||(a?"category":void 0),"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.valueAccessor||"value"})}}},CollisionSwarmChart:{frameType:"physics",buildProps:(e,t,i,r,s)=>{const n=r.size??[600,360],a=o({data:Array.isArray(e)?e:[],xAccessor:s.xAccessor||"x",groupAccessor:s.groupAccessor,radiusAccessor:s.radiusAccessor,pointRadius:s.pointRadius??5,seed:s.seed??1,size:n,xExtent:s.xExtent,collisionIterations:s.collisionIterations,settle:s.settle});return{...r,config:a.config,initialSpawns:pi(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:g(t||s.colorBy||s.groupAccessor,"#4e79a7",{styleRules:s.styleRules,valueAccessor:s.xAccessor||"x"})}}},ProcessFlowChart:{frameType:"physics",buildProps:(e,t,o,i,r)=>{const s=i.size??[900,420],n=Array.isArray(r.stages)?r.stages:[],c=a({data:Array.isArray(e)?e:[],stages:n,size:s,idAccessor:r.idAccessor,stageAccessor:r.stageAccessor||"stage",groupBy:r.groupBy,groupLabelAccessor:r.groupLabelAccessor,workAccessor:r.workAccessor,radiusAccessor:r.radiusAccessor,ballRadius:r.ballRadius??6,seed:r.seed??1,groupCompletion:r.groupCompletion,groupAnchorAlong:r.groupAnchorAlong,settle:r.settle??!0,gravityX:r.gravityX,gravityY:r.gravityY}),l=c.metadata;return{...i,config:c.config,initialSpawns:pi(c.initialSpawns),projectionRows:c.projectionRows,regionEffects:l?.regionEffects,bodyStyle:g(t||r.colorBy||r.groupBy,"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.workAccessor||r.stageAccessor||"stage"})}}},GauntletChart:{frameType:"physics",buildProps:(e,t,o,i,r)=>{const s=i.size??[900,520],n=gi({data:Array.isArray(e)?e:[],size:s,gates:r.gates,positiveProperties:r.positiveProperties,negativeProperties:r.negativeProperties,crashOffset:r.crashOffset,idAccessor:r.idAccessor,positiveAccessor:r.positiveAccessor,negativeAccessor:r.negativeAccessor,metricsAccessor:r.metricsAccessor,initialViability:r.initialViability,projectPlacement:r.projectPlacement,coreBody:r.coreBody,viability:r.viability});return{...i,config:n.config,initialSpawns:pi(n.initialSpawns),projectionRows:[],bodyStyle:g(t||r.colorBy)}}},PhysicalFlowChart:{frameType:"physics",buildProps:(e,t,o,i,r)=>{const n=i.size??[760,420],a=s({nodes:Array.isArray(r.nodes)?r.nodes:[],links:Array.isArray(r.links)?r.links:Array.isArray(r.edges)?r.edges:Array.isArray(e)?e:[],nodeIdAccessor:r.nodeIdAccessor||"id",nodeXAccessor:r.nodeXAccessor||"x",nodeYAccessor:r.nodeYAccessor||"y",sourceAccessor:r.sourceAccessor||"source",targetAccessor:r.targetAccessor||"target",throughputAccessor:r.throughputAccessor||"value",pathAccessor:r.pathAccessor||"path",coordinateMode:r.coordinateMode||"auto",particleRate:r.particleRate??.16,maxParticles:r.maxParticles??180,particleRadius:r.particleRadius??4,flowSpeed:r.flowSpeed??90,pathConstraint:r.pathConstraint||"path",reducedMotion:!0,seed:r.seed??1,size:n});return{...i,config:a.config,initialSpawns:pi(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:g(t||r.colorBy||"source")}}},PhysicsCustomChart:{frameType:"physics",buildProps:(e,t,o,i,r)=>{const s=i.size??[700,380],n=d({chartId:r.chartId,colorScheme:o,config:r.config,data:Array.isArray(e)?e:[],layout:r.layout,layoutConfig:r.layoutConfig,semantic:Pt(kt)??{},size:s,themeCategorical:kt.colors.categorical,xExtent:r.xExtent,yExtent:r.yExtent});return{...i,config:n.config,initialSpawns:pi(n.initialSpawns),projectionRows:[],bodyStyle:n.result.bodyStyle??g(t||r.colorBy)}}}};function yi(e){const t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function mi(e){if(!e||2>e.length)return;const t=yi(e[0]),o=yi(e[e.length-1]);return null!==t&&null!==o?[t,o]:void 0}function bi(e){const{count:t,byType:o}=function(e){const t={};for(const o of e){const e="string"==typeof o?.type&&o.type.length>0?o.type:"node";t[e]=(t[e]??0)+1}return{count:e.length,byType:t}}(e.marks),i=0===t,r=[...e.extraWarnings??[]];return i&&!r.includes("EMPTY_SCENE")&&r.push("EMPTY_SCENE"),{component:"",frameType:e.frameType,status:i?"empty":"ok",empty:i,markCount:t,markCountByType:o,width:e.width,height:e.height,...e.xDomain?{xDomain:e.xDomain}:{},...e.yDomain?{yDomain:e.yDomain}:{},...e.categories?{categories:e.categories}:{},...void 0!==e.nodeCount?{nodeCount:e.nodeCount}:{},...void 0!==e.edgeCount?{edgeCount:e.edgeCount}:{},...void 0!==e.legendItems?{legendItems:e.legendItems}:{},annotationCount:Array.isArray(e.annotations)?e.annotations.length:0,ariaLabel:"string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${t} marks`,warnings:r}}import*as xi from"react";import*as vi from"react-dom/server";import{scaleOrdinal as Ai}from"d3-scale";import{jsx as Si,jsxs as wi}from"react/jsx-runtime";var ki=ne;function _i(e,t,o){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;return t=>Ie(e,t)??"#999"}const i=Array.isArray(t)?t:o.colors.categorical.length>0?o.colors.categorical:bt;return Ai().domain(e).range(i)}function Mi(e){return"left"===e?"start":"right"===e?"end":e??"start"}function Pi(e){return Number(e.typography.legendSize??e.typography.labelSize??e.typography.tickSize)||11}function Ti(e,t,o,i){const r=Pi(i);return t+o+Math.ceil(e.length*r*.58)}function Li(e){const{categories:t,theme:o,position:i="right",totalWidth:r,margin:s,legendLayout:n}=e,{swatchSize:a,labelGap:c,itemGap:l,rowHeight:u}=$e(n),h=a+c,d="top"===i||"bottom"===i,g=Math.max(a,r-s.left-s.right),p=t.map(e=>Ti(e,a,c,o));if(d){const e=Math.max(a,n?.maxWidth??g),o=[];let i=0,r=0;p.forEach((t,s)=>{const n=0===r?t:r+l+t;r>0&&n>e?(o.push({start:i,end:s,width:r}),i=s,r=t):r=n}),t.length>0&&o.push({start:i,end:t.length,width:r});const s=Mi(n?.align),c=[];return o.forEach((o,i)=>{let r="center"===s?Math.max(0,(e-o.width)/2):"end"===s?Math.max(0,e-o.width):0;for(let e=o.start;o.end>e;e++)c.push({category:t[e],width:p[e],x:r,y:i*u}),r+=p[e]+l}),{items:c,width:Math.max(0,...o.map(e=>e.width)),height:o.length*u,swatchSize:a,labelOffset:h,swatchRadius:0}}const f=Math.max(0,...p);return{items:t.map((e,t)=>({category:e,width:p[t],x:0,y:t*u})),width:f,height:t.length*u,swatchSize:a,labelOffset:h,swatchRadius:0}}function Ri(e){const{legendGroups:t,theme:o,position:i="right",totalWidth:r,margin:s,legendLayout:n}=e,{swatchSize:a,labelGap:c,rowHeight:l}=$e(n),u=a+c,h=Math.max(12,Pi(o)),d="top"===i||"bottom"===i,g=Math.max(a,r-s.left-s.right);if(d){const i=Math.max(a,n?.maxWidth??g),r=Mi(n?.align);let s=0,c=0;const l=[];for(const r of t){const t=r.items.map(e=>e.label),u=Li({...e,categories:t,legendLayout:{...n,maxWidth:Math.max(a,i-h-8),align:"start"}}),d=r.label?h:0,g=r.label?Ti(r.label,0,0,o):0,p=d>0?d+8:0,f=p+u.width,y=Math.max(u.height,g);l.push({group:r,x:s,y:0,itemOffsetX:p,itemOffsetY:0,width:f,height:y,items:u.items}),s+=f+12,c=Math.max(c,y)}const d=l.length>0?s-12:0,p=d>i?0:"center"===r?Math.max(0,(i-d)/2):"end"===r?Math.max(0,i-d):0;return{groups:l.map(e=>({...e,x:e.x+p})),width:d,height:c,swatchSize:a,labelOffset:u,swatchRadius:0}}const p=Pe(t.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),l);let f=0;return{groups:t.map((e,t)=>{const i=e.items.map(e=>Ti(e.label,a,c,o)),r=Math.max(0,...i,e.label?Ti(e.label,0,0,o):0);return f=Math.max(f,r),{group:e,x:0,y:p[t].itemsY,itemOffsetX:0,itemOffsetY:0,width:r,height:e.items.length*l,items:e.items.map((e,t)=>({category:e.label,width:i[t],x:0,y:t*l}))}}),width:f,height:p.at(-1)?.endY??0,swatchSize:a,labelOffset:u,swatchRadius:0}}function Ci(e){const t="top"===e.position||"bottom"===e.position,o=Math.max(1,e.totalWidth-e.margin.left-e.margin.right);return t?{width:Math.min(e.legendLayout?.maxWidth??o,200),height:e.gradient.label?34:26,swatchSize:12}:{width:e.gradient.label?86:72,height:e.gradient.label?124:108,swatchSize:14}}function zi(e,t){if(!t||!e||0===e.length)return[];const o="function"==typeof t?t:e=>e[t],i=new Set;for(const t of e){const e=o(t);null!=e&&i.add(e+"")}return Array.from(i)}import{jsx as Fi,jsxs as Bi}from"react/jsx-runtime";var Oi=16;function Ei(e,t){return e.color||t.colors.annotation||t.colors.text}function Di(e,t,o){const i=e.labelBackground,r=t.colors.background,s=r&&"transparent"!==r?r:t.colors.surface||r;return void 0===i?"none"===o?"none":{type:"halo",fill:s}:!1===i||"none"===i?"none":!0===i||"halo"===i?{type:"halo",fill:s}:"box"===i?{type:"box",fill:s}:{fill:s,...i}}function ji(e,t,o){return null!=e.x&&t.x?t.x(e.x):o&&null!=e[o]&&t.x?t.x(e[o]):"number"==typeof e.x?e.x:null}function Ni(e,t,o){return null!=e.y&&t.y?t.y(e.y):o&&null!=e[o]&&t.y?t.y(e[o]):"number"==typeof e.y?e.y:null}function Wi(e){const{annotations:t}=e;if(!t||0===t.length)return null;const o=ot(t),i=e.autoPlaceAnnotations?ct({annotations:o,context:{scales:{x:e.scales.x,y:e.scales.y,time:e.scales.x,value:e.scales.y,o:e.scales.o,geoProjection:e.scales.geoProjection},width:e.layout.width,height:e.layout.height,xAccessor:e.xAccessor,yAccessor:e.yAccessor,frameType:e.projection?"ordinal":"xy",projection:"horizontal"===e.projection?"horizontal":"vertical"},..."object"==typeof e.autoPlaceAnnotations?e.autoPlaceAnnotations:{}}):o,r=[];for(let t=0;i.length>t;t++){const o=Ii(i[t],t,e);o&&r.push({node:o,annotation:i[t]})}const s=de(r);return s.length>0?Fi("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:s}):null}function Ii(e,t,o){const{scales:i,layout:r,theme:s,xAccessor:n,yAccessor:a}=o;switch(e.type){case"y-threshold":{const n=e.value;if(null==n)return null;const a=Ei(e,s),c=e.label,l=e.labelPosition||"right",u=e.strokeDasharray||"6,4",h=e.strokeWidth??1.5;if("horizontal"===o.projection&&i.r){const o=i.r(n);return null==o?null:Bi("g",{opacity:e.opacity,children:[Fi("line",{x1:o,y1:0,x2:o,y2:r.height,stroke:a,strokeWidth:h,strokeDasharray:u}),c&&Fi(ie,{x:o+4,y:Oi,textAnchor:"start",fontSize:s.typography.tickSize,fill:a,fontFamily:s.typography.fontFamily,text:c,background:Di(e,s,"halo")})]},"ann-ythresh-"+t)}const d=i.y?i.y(n):i.r?i.r(n):null;return null==d?null:Bi("g",{children:[Fi("line",{x1:0,y1:d,x2:r.width,y2:d,stroke:a,strokeWidth:h,strokeDasharray:u}),c&&Fi(ie,{x:"left"===l?4:"center"===l?r.width/2:r.width-4,y:20>d?Math.min(r.height-4,d+Oi):d-6,textAnchor:"left"===l?"start":"center"===l?"middle":"end",fontSize:s.typography.tickSize,fill:a,fontFamily:s.typography.fontFamily,text:c,background:Di(e,s,"halo")})]},"ann-ythresh-"+t)}case"x-threshold":{const o=e.value;if(null==o||!i.x)return null;const n=i.x(o);if(null==n)return null;const a=Ei(e,s),c=e.label,l=e.labelPosition||"top";return Bi("g",{opacity:e.opacity,children:[Fi("line",{x1:n,y1:0,x2:n,y2:r.height,stroke:a,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray||"6,4"}),c&&Fi(ie,{x:n>.6*r.width?n-4:n+4,y:"bottom"===l?r.height-4:"center"===l?r.height/2:Oi,textAnchor:n>.6*r.width?"end":"start",fontSize:s.typography.tickSize,fill:a,fontFamily:s.typography.fontFamily,text:c,background:Di(e,s,"halo")})]},"ann-xthresh-"+t)}case"band":{const o=i.y?.domain?.(),n=e.y0??o?.[0],a=e.y1??o?.[1],c=null!=n&&i.y?i.y(n):null,l=null!=a&&i.y?i.y(a):null;if(null==c||null==l)return null;const u=Math.min(c,l),h=Math.abs(l-c),d=st(e.fill||Ei(e,s),"ssr-band-"+t),g=e.fillOpacity??.1;return Bi("g",{opacity:e.opacity,children:[d.def&&Fi("defs",{children:d.def}),Fi("rect",{x:0,y:u,width:r.width,height:h,fill:d.fill,fillOpacity:g}),e.label&&Fi(ie,{x:r.width-4,y:Math.max(u,0)+Oi,textAnchor:"end",fontSize:s.typography.tickSize,fill:e.color||Ei(e,s),fontFamily:s.typography.fontFamily,fontWeight:"bold",text:e.label,background:Di(e,s,"halo")})]},"ann-band-"+t)}case"x-band":{const o=i.x?.domain?.(),n=e.x0??o?.[0],a=e.x1??o?.[1],c=null!=n&&i.x?i.x(n):null,l=null!=a&&i.x?i.x(a):null;if(null==c||null==l)return null;const u=Math.min(c,l),h=Math.abs(l-c),d=st(e.fill||Ei(e,s),"ssr-xband-"+t),g=e.fillOpacity??.1;return Bi("g",{opacity:e.opacity,children:[d.def&&Fi("defs",{children:d.def}),Fi("rect",{x:u,y:0,width:h,height:r.height,fill:d.fill,fillOpacity:g}),e.label&&Fi(ie,{x:u+4,y:Oi,textAnchor:"start",fontSize:s.typography.tickSize,fill:e.color||s.colors.primary||Ei(e,s),fontFamily:s.typography.fontFamily,fontWeight:"bold",text:e.label,background:Di(e,s,"halo")})]},"ann-xband-"+t)}case"category-highlight":{if(null==e.category||!i.o)return null;const n=i.o(e.category+"");if(null==n)return null;const a=i.o.bandwidth?i.o.bandwidth():40,c=Ei(e,s),l=e.opacity??.1,u=e.label;return Bi("g","horizontal"===o.projection?{children:[Fi("rect",{x:0,y:n,width:r.width,height:a,fill:c,opacity:l}),u&&Fi(ie,{x:12,y:n+a/2,dominantBaseline:"middle",fill:c,fontSize:s.typography.tickSize,fontWeight:"bold",fontFamily:s.typography.fontFamily,text:u,background:Di(e,s,"none")})]}:{children:[Fi("rect",{x:n,y:0,width:a,height:r.height,fill:c,opacity:l}),u&&Fi(ie,{x:n+a/2,y:Oi,textAnchor:"middle",fill:c,fontSize:s.typography.tickSize,fontWeight:"bold",fontFamily:s.typography.fontFamily,text:u,background:Di(e,s,"none")})]},"ann-cathighlight-"+t)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:o,y:r}=function(e,t,o,i){if(Array.isArray(e.coordinates)&&e.coordinates.length>=2&&t.geoProjection){const o=t.geoProjection([e.coordinates[0],e.coordinates[1]]);if(o)return{x:o[0],y:o[1]}}return{x:ji(e,t,o),y:Ni(e,t,i)}}(e,i,n,a);if(null==o||null==r)return null;const c="text"===e.type,l=e.dx??(c?0:30),u=e.dy??(c?0:-30),h=e.color||s.colors.text;if(!c){const i="callout"===e.type?"callout-circle":e.type,s="callout-circle"===i?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===i?{width:e.width,height:e.height}:void 0;return Fi(ue,{noteData:{x:o,y:r,dx:l,dy:u,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:i,...s?{subject:s}:{},connector:e.connector||{end:"arrow"},color:h,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-label-"+t)}return Fi("g",{children:Fi("text",{x:o+l,y:r+u,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||s.typography.labelSize,fill:h,fontFamily:s.typography.fontFamily,fontWeight:e.fontWeight,opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:e.label||e.title})},"ann-label-"+t)}default:return null}}import*as $i from"react";import{jsx as Gi,jsxs as Yi}from"react/jsx-runtime";function Hi(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){const t=e.id;return null==t?null:t+""}return null}function Vi(e){const t=e._idPrefix||e.chartId;if(t){const e=(t+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(e)?e:"c"+e}const o=`${e.chartType||""}:${e.title||""}:${Array.isArray(e.data)?e.data.length:0}`;let i=0;for(let e=0;o.length>e;e++)i=31*i+o.charCodeAt(e)|0;return"c"+(i>>>0).toString(36)}function Xi(e,t,o){const i=e.showLegend&&!e.__legendIncludesAutomatic?function(e,t,o){if(0===e.length)return;const i=_i(e,t,o);return{legendGroups:[{label:"",type:"fill",items:e.map(e=>({label:e})),styleFn:e=>({fill:i(e.label)})}]}}(t,e.colorScheme,o):void 0;return pe(i,e.legend)}var qi={right:110,left:110,top:50,bottom:80};function Qi(e,t){if(e.__autoLegendMargin&&!Ki(e,t))return qi[t]}function Ki(e,t){const o=e.__explicitMargin;return"number"==typeof o||!(!o||"object"!=typeof o||"number"!=typeof o[t])}function Zi(e,t){const{props:o,categories:i,theme:r,size:s,hasTitle:n}=t,a=o.legendPosition||"right",c={theme:r,position:a,size:s,hasTitle:n,legendLayout:o.legendLayout,minimumMargin:Qi(o,a),preserveExplicitMargin:Ki(o,a)};if(null!=o.legend){const t=Xi(o,i,r);(Me(t)||_e(t))&&function(e,t){if(t.preserveExplicitMargin)return;const o=t.position||"right",i={theme:t.theme,position:o,totalWidth:t.size[0],totalHeight:t.size[1],margin:e,hasTitle:t.hasTitle,legendLayout:t.legendLayout},r=Me(t.legend)?function(e){const{width:t,height:o,swatchSize:i}=Ri(e);return{width:t,height:o,swatchSize:i}}({...i,legendGroups:t.legend.legendGroups}):_e(t.legend)?Ci({...i,gradient:t.legend.gradient}):null;if(!r)return;const s=t.minimumMargin??r.width+14,n=t.minimumMargin??(t.hasTitle?32:8)+r.height+4,a=t.minimumMargin??38+r.height+4;"right"===o?e.right=Math.max(e.right,s):"left"===o?e.left=Math.max(e.left,s):"top"===o?e.top=Math.max(e.top,n):e.bottom=Math.max(e.bottom,a)}(e,{...c,legend:t})}else o.showLegend&&i.length>0&&function(e,t){if(0===t.categories.length)return;if(t.preserveExplicitMargin)return;const o=t.position||"right",i=function(e){const{width:t,height:o,swatchSize:i}=Li(e);return{width:t,height:o,swatchSize:i}}({categories:t.categories,colorScheme:t.colorScheme,theme:t.theme,position:o,totalWidth:t.size[0],totalHeight:t.size[1],margin:e,hasTitle:t.hasTitle,legendLayout:t.legendLayout}),r=t.minimumMargin??i.width+14,s=t.minimumMargin??(t.hasTitle?32:8)+i.height+4,n=t.minimumMargin??38+i.height+4;"right"===o?e.right=Math.max(e.right,r):"left"===o?e.left=Math.max(e.left,r):"top"===o?e.top=Math.max(e.top,s):e.bottom=Math.max(e.bottom,n)}(e,{...c,categories:i,colorScheme:o.colorScheme});return a}function Ui(e){const{props:t,categories:o,theme:i,size:r,margin:s,hasTitle:n}=e,a=t.legendPosition||"right",c={theme:i,position:a,size:r,margin:s,hasTitle:n,legendLayout:t.legendLayout,idPrefix:t._idPrefix,reservedWidth:t.__autoLegendMargin?100:void 0};if(null!=t.legend){const e=Xi(t,o,i);if($i.isValidElement(e))return e;const r=function(e,t){const o={theme:t.theme,position:t.position||"right",totalWidth:t.size[0],totalHeight:t.size[1],margin:t.margin,hasTitle:t.hasTitle,legendLayout:t.legendLayout,idPrefix:t.idPrefix,reservedWidth:t.reservedWidth};return Me(e)?function(e){if(0===(t=e.legendGroups,t.flatMap(e=>e.items.map((t,o)=>({group:e,item:t,itemIndex:o,label:t.label})))).length)return null;var t;const o=Ri(e),i="top"===e.position||"bottom"===e.position,r=e.theme.colors.grid||e.theme.colors.textSecondary;let s,n;if("left"===e.position?(s=Math.max(4,e.margin.left-(e.reservedWidth??100)-10),n=e.margin.top):"top"===e.position?(s=e.margin.left,n=e.hasTitle?32:8):"bottom"===e.position?(s=e.margin.left,n=e.totalHeight-e.margin.bottom+38):(s=e.totalWidth-e.margin.right+10,n=e.margin.top),!i){const t=Pe(e.legendGroups.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),Math.max(o.swatchSize,e.legendLayout?.rowHeight??ki)),i=e.legendGroups.flatMap((i,r)=>{const s=t[r],n=i.type??"fill",a=[Si("line",{x1:0,y1:s.lineY,x2:e.reservedWidth??100,y2:s.lineY,stroke:"gray"},"legend-group-neatline-"+r)];return i.label&&null!=s.labelY&&a.push(Si("text",{y:s.labelY,fontSize:Pi(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:i.label},"legend-group-label-"+r)),a.push(Si("g",{transform:`translate(0,${s.itemsY})`,children:i.items.map((t,s)=>{const a=i.styleFn(t,s),c="function"==typeof n?n(t):"line"===n?Si("line",{x1:0,y1:0,x2:o.swatchSize,y2:o.swatchSize,style:a}):Si("rect",{width:o.swatchSize,height:o.swatchSize,rx:o.swatchRadius,style:a});return wi("g",{transform:`translate(0,${s*Math.max(o.swatchSize,e.legendLayout?.rowHeight??ki)})`,children:[c,Si("text",{x:o.labelOffset,y:o.swatchSize/2,dominantBaseline:"central",fontSize:Pi(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:t.label})]},`legend-${r}-${s}`)})},"legend-group-"+r)),a});return Si("g",{className:"semiotic-legend",transform:`translate(${s},${n})`,"data-orientation":"vertical",children:i})}const a=o.groups.flatMap((t,s)=>{const{group:n}=t,a=n.type??"fill",c=[];if(n.label&&c.push(Si("text",i?{transform:`translate(${t.x},${t.y}) rotate(90)`,textAnchor:"start",fontSize:Pi(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:n.label}:{x:t.x,y:t.y+Pi(e.theme),fontSize:Pi(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:n.label},"legend-group-label-"+s)),c.push(...t.items.map((i,r)=>{const c=n.items[r],l=n.styleFn(c,r),u="function"==typeof a?a(c):"line"===a?Si("line",{x1:0,y1:0,x2:o.swatchSize,y2:o.swatchSize,style:l}):Si("rect",{width:o.swatchSize,height:o.swatchSize,rx:o.swatchRadius,style:l});return wi("g",{transform:`translate(${t.x+t.itemOffsetX+i.x},${t.y+t.itemOffsetY+i.y})`,children:[u,Si("text",{x:o.labelOffset,y:o.swatchSize/2,dominantBaseline:"central",fontSize:Pi(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:i.category})]},`legend-${s}-${r}`)})),i&&o.groups.length-1>s){const e=t.x+t.width+6;c.push(Si("line",{x1:e,y1:0,x2:e,y2:o.height,stroke:r},"legend-group-separator-"+s))}return c});return Si("g",{className:"semiotic-legend",transform:`translate(${s},${n})`,"data-orientation":i?"horizontal":"vertical",children:a})}({...o,legendGroups:e.legendGroups}):_e(e)?function(e){const t=Ci(e),o="top"===e.position||"bottom"===e.position,i=(e.idPrefix?e.idPrefix+"-":"")+"semiotic-static-gradient-legend",r=e.gradient.format||(e=>Math.round(100*e)/100+"");let s,n;"left"===e.position?(s=Math.max(4,e.margin.left-100-10),n=e.margin.top):"top"===e.position?(s=e.margin.left,n=e.hasTitle?32:8):"bottom"===e.position?(s=e.margin.left,n=e.totalHeight-e.margin.bottom+38):(s=e.totalWidth-e.margin.right+10,n=e.margin.top);const a=Array.from({length:17},(t,i)=>{const r=i/16;return Si("stop",{offset:100*r+"%",stopColor:e.gradient.colorFn(o?e.gradient.domain[0]+r*(e.gradient.domain[1]-e.gradient.domain[0]):e.gradient.domain[1]-r*(e.gradient.domain[1]-e.gradient.domain[0]))},i)});if(o){const o=12,c=e.gradient.label?0:void 0,l=e.gradient.label?8:0;return wi("g",{className:"semiotic-legend",transform:`translate(${s},${n})`,children:[Si("defs",{children:Si("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:a})}),e.gradient.label&&Si("text",{x:t.width/2,y:c,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),Si("rect",{x:0,y:l,width:t.width,height:o,fill:`url(#${i})`,rx:2}),Si("text",{x:0,y:l+o+12,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[0])}),Si("text",{x:t.width,y:l+o+12,textAnchor:"end",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[1])})]})}const c=e.gradient.label?-6:void 0;return wi("g",{className:"semiotic-legend",transform:`translate(${s},${n+(e.gradient.label?12:0)})`,children:[Si("defs",{children:Si("linearGradient",{id:i,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:a})}),e.gradient.label&&Si("text",{x:7,y:c,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),Si("rect",{x:0,y:0,width:14,height:100,fill:`url(#${i})`,rx:2}),Si("text",{x:19,y:10,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[1])}),Si("text",{x:19,y:100,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:r(e.gradient.domain[0])})]})}({...o,gradient:e.gradient}):null}(e,c);return r||(Me(e)||_e(e)?null:e??null)}return t.showLegend&&0!==o.length?function(e){const{categories:t,colorScheme:o,theme:i,position:r="right",totalWidth:s,totalHeight:n,margin:a,hasTitle:c=!1}=e;if(!t||0===t.length)return null;const l=_i(t,o,i),u="top"===r||"bottom"===r,h=Li(e);let d,g;if("left"===r?(d=Math.max(4,a.left-(e.reservedWidth??100)-10),g=a.top):"top"===r?(d=a.left,g=c?32:8):"bottom"===r?(d=a.left,g=n-a.bottom+38):(d=s-a.right+10,g=a.top),u){const e=h.items.map((e,t)=>wi("g",{transform:`translate(${e.x},${e.y})`,children:[Si("rect",{width:h.swatchSize,height:h.swatchSize,fill:l(e.category),rx:h.swatchRadius}),Si("text",{x:h.labelOffset,y:h.swatchSize/2,dominantBaseline:"central",fontSize:Pi(i),fill:i.colors.text,fontFamily:i.typography.fontFamily,children:e.category})]},"legend-"+t));return Si("g",{className:"semiotic-legend",transform:`translate(${d},${g})`,children:e})}const p=Pe([{hasLabel:!1,itemCount:t.length}],Math.max(h.swatchSize,e.legendLayout?.rowHeight??ki))[0],f=h.items.map((e,t)=>wi("g",{transform:`translate(${e.x},${e.y+p.itemsY})`,children:[Si("rect",{width:h.swatchSize,height:h.swatchSize,fill:l(e.category),rx:h.swatchRadius}),Si("text",{x:h.labelOffset,y:h.swatchSize/2,dominantBaseline:"central",fontSize:Pi(i),fill:i.colors.text,fontFamily:i.typography.fontFamily,children:e.category})]},"legend-"+t));return wi("g",{className:"semiotic-legend",transform:`translate(${d},${g})`,children:[Si("line",{x1:0,y1:p.lineY,x2:e.reservedWidth??100,y2:p.lineY,stroke:"gray"}),f]})}({categories:o,colorScheme:t.colorScheme,theme:i,position:a,totalWidth:r[0],totalHeight:r[1],margin:s,hasTitle:n,legendLayout:t.legendLayout,reservedWidth:t.__autoLegendMargin?100:void 0,idPrefix:t._idPrefix}):null}function Ji(e){return Math.round(100*e)/100+""}function er(e,t){const o=ro(t.theme),i=t.background??o.background,r=t.idPrefix?t.idPrefix+"-":"",s="string"==typeof t.title?t.title:void 0,n=s?r+"semiotic-title":void 0,a=t.description?r+"semiotic-desc":void 0,c=[n,a].filter(Boolean).join(" ")||void 0;return Yi("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className,width:t.width,height:t.height,role:"img","aria-labelledby":c,style:{fontFamily:o.fontFamily},children:[s&&Gi("title",{id:n,children:s}),t.description&&Gi("desc",{id:a,children:t.description}),t.defs&&Gi("defs",{children:t.defs}),i&&"transparent"!==i&&Gi("rect",{x:0,y:0,width:t.width,height:t.height,fill:i}),Gi("g",{id:r+"data-area",transform:t.innerTransform,children:e}),s&&Gi("text",{id:r+"chart-title",x:t.width/2,y:he,textAnchor:"middle",fontSize:o.titleSize,fontWeight:"bold",fill:o.text,fontFamily:o.fontFamily,children:s}),t.legend&&Gi("g",{id:r+"legend",children:t.legend}),t.outerElements]})}import{Fragment as tr,jsx as or,jsxs as ir}from"react/jsx-runtime";function rr(e,t){const o=io(e.theme),i=e.size||[500,300],r=Ee({top:20,right:20,bottom:30,left:40,...e.margin},e.title),s=we(e.title),n=be(e.data),a=e.showLegend?zi(n,e.colorAccessor||e.groupAccessor||e.categoryAccessor):[];Zi(r,{props:e,categories:a,theme:o,size:i,hasTitle:s});const c=i[0]-r.left-r.right,l=i[1]-r.top-r.bottom,u="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),h=e.colorScheme||o.colors.categorical,d={chartType:e.chartType,windowSize:e.windowSize??200,windowMode:e.windowMode??"sliding",arrowOfTime:u?e.arrowOfTime??"right":"right",extentPadding:e.extentPadding??.1,xAccessor:u?void 0:e.xAccessor,yAccessor:u?void 0:e.yAccessor,timeAccessor:u?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,axisExtent:e.axisExtent,sizeRange:e.sizeRange,xScaleType:e.xScaleType,yScaleType:e.yScaleType,scalePadding:e.scalePadding,binSize:e.binSize,normalize:e.normalize,baseline:e.baseline,stackOrder:e.stackOrder,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,band:e.band,y0Accessor:e.y0Accessor,areaGroups:e.areaGroups?e.areaGroups instanceof Set?e.areaGroups:new Set(e.areaGroups):void 0,curve:e.curve,gradientFill:!0===e.gradientFill?{topOpacity:.8,bottomOpacity:.05}:!1===e.gradientFill?void 0:e.gradientFill,lineGradient:e.lineGradient,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,barStyle:e.barStyle,waterfallStyle:e.waterfallStyle,swarmStyle:e.swarmStyle,colorScheme:h,themeCategorical:o.colors.categorical,themeSemantic:Pt(o),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:r,layoutSelection:e.layoutSelection,barColors:e.barColors,showValues:e.showValues,heatmapValueFormat:e.heatmapValueFormat},g=new P(d);if(e.data&&g.ingest({inserts:n,bounded:!0}),g.computeScene({width:c,height:l}),!g.scales||0===g.scene.length)return t&&(t.evidence=bi({frameType:"xy",width:i[0],height:i[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:g.scales?[]:["NO_SCALES"]})),vi.renderToStaticMarkup(er(null,{width:i[0],height:i[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${r.left},${r.top})`,innerWidth:c,innerHeight:l,idPrefix:e._idPrefix}));const p=e._idPrefix,f=q({nodes:g.scene,renderMode:e.renderMode,fallback:(e,t)=>Je(e,t,p)});t&&(t.evidence=bi({frameType:"xy",width:i[0],height:i[1],marks:f.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,xDomain:mi(g.scales.x?.domain?.()),yDomain:mi(g.scales.y?.domain?.()),legendItems:a.length>0?a.length:void 0}));const y=e.showGrid?function(e,t,o,i,r){const{grid:s}=ro(o),n=i?i+"-":"",a="exact"===r?5:Math.min(5,Math.max(2,Math.floor(t.width/70))),c="exact"===r?5:Math.min(5,Math.max(2,Math.floor(t.height/30))),l=U(e.x,a,r),u=U(e.y,c,r);return Yi("g",{id:n+"grid",className:"semiotic-grid",opacity:.8,children:[l.map((o,i)=>{const r=e.x(o);return Gi("line",{x1:r,y1:0,x2:r,y2:t.height,stroke:s,strokeWidth:.5},"gx-"+i)}),u.map((o,i)=>{const r=e.y(o);return Gi("line",{x1:0,y1:r,x2:t.width,y2:r,stroke:s,strokeWidth:.5},"gy-"+i)})]})}(g.scales,{width:c,height:l},o,p,e.axisExtent):null,m=f.map(e=>e.element),b=Vi(e)+"-plot-clip",x=!1!==e.showAxes?function(e,t,o,i,r){const s=ro(i),n="exact"===o.axisExtent?5:Math.min(5,Math.max(2,Math.floor(t.width/70))),a="exact"===o.axisExtent?5:Math.min(5,Math.max(2,Math.floor(t.height/30))),c=U(e.x,n,o.axisExtent).map(t=>({pixel:e.x(t),label:(o.xFormat||o.tickFormatTime||Ji)(t)})),l=U(e.y,a,o.axisExtent).map(t=>({pixel:e.y(t),label:(o.yFormat||o.tickFormatValue||Ji)(t)}));return Yi("g",{id:(r?r+"-":"")+"axes",className:"stream-axes",children:[Gi("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:s.border,strokeWidth:1}),c.map((e,o)=>Yi("g",{transform:`translate(${e.pixel},${t.height})`,children:[Gi("line",{y2:5,stroke:s.border,strokeWidth:1}),Gi("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"xtick-"+o)),o.xLabel&&Gi("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:o.xLabel}),Gi("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:s.border,strokeWidth:1}),l.map((e,t)=>Yi("g",{transform:`translate(0,${e.pixel})`,children:[Gi("line",{x2:-5,stroke:s.border,strokeWidth:1}),Gi("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"ytick-"+t)),o.yLabel&&Gi("text",{x:15-(o.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(o.margin?.left??40)}, ${t.height/2})`,children:o.yLabel})]})}(g.scales,{width:c,height:l},e,o,p):null,v=e.annotations?Wi({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{x:g.scales.x,y:g.scales.y},layout:{width:c,height:l},theme:o,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:p}):null,A=e.svgPreRenderers&&g.scales?e.svgPreRenderers.map((e,t)=>{try{return or(xi.Fragment,{children:e(g.scene,g.scales,{width:c,height:l})},"pre-"+t)}catch{return null}}).filter(Boolean):null,S=Ui({props:e,categories:a,theme:o,size:i,margin:r,hasTitle:s});return vi.renderToStaticMarkup(er(ir(tr,{children:[e.backgroundGraphics,A,y,or("defs",{children:or("clipPath",{id:b,children:or("rect",{x:0,y:0,width:c,height:l})})}),or("g",{clipPath:`url(#${b})`,children:m}),x,v,e.foregroundGraphics,g.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${r.left},${r.top})`,innerWidth:c,innerHeight:l,legend:S,idPrefix:e._idPrefix}))}import*as sr from"react-dom/server";import{scaleBand as nr,scaleLinear as ar}from"d3-scale";var cr=class{constructor(){this.colorSchemeMap=new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(e,t,o){if(t&&"function"==typeof e.pieceStyle){const i=e.pieceStyle(t,o);return i&&!i.fill&&o?{...i,fill:this.getColorFromScheme(e,o)}:i}return e.pieceStyle&&"object"==typeof e.pieceStyle?e.pieceStyle:e.barColors&&o?{fill:e.barColors[o]||"#007bff"}:{fill:o?this.getColorFromScheme(e,o):"#007bff"}}resolveSummaryStyle(e,t,o){return t&&"function"==typeof e.summaryStyle?e.summaryStyle(t,o):e.summaryStyle&&"object"==typeof e.summaryStyle?e.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(e,t){const o=this.colorSchemeMap.get(t);if(o)return o;const i=Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical||ce,r=i[this.colorSchemeIndex%i.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(t,r),r}};function lr(e){const t=e.getSymbol;if(!t)return null;const o=e.config.symbolMap,i=new Map;let r=0;return e=>{const s=t(e)+"",n=o?.[s];if(n)return n;let a=i.get(s);return a||(a=nt[r%nt.length],r++,i.set(s,a)),a}}function ur(e,t,o,i,r,s,n){e.push(t?{type:"symbol",x:i,y:r,size:Math.PI*s*s,symbolType:t(o),style:n,datum:o}:{type:"point",x:i,y:r,r:s,style:n,datum:o})}function hr(e,t){const{columns:o,config:i,resolvePieceStyle:r}=e,s=[],n=Math.min(t.width,t.height)/2-4,a="donut"===i.chartType?i.innerRadius||60:0,c=-Math.PI/2+(i.startAngle||0)*Math.PI/180,l=null!=i.sweepAngle?i.sweepAngle*Math.PI/180:2*Math.PI,u=null!=i.sweepAngle&&360>i.sweepAngle,h=Object.values(o),d=h.some(e=>{const t=e.pieceData[0];return t&&("number"==typeof t._pct||"number"==typeof t._pctStart||null!=t._roundedEnds)}),g=u&&!d&&h.length>1&&(i.cornerRadius??0)>0;for(let e=0;h.length>e;e++){const t=h[e],o=t.pieceData[0],u="number"==typeof o?._pctStart?o._pctStart:t.pctStart,d=c+u*l,p=c+(u+("number"==typeof o?._pct?o._pct:t.pct))*l,f=r(t.pieceData[0],t.name),y=0===e,m=e===h.length-1,b={type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:n,startAngle:d,endAngle:p,...i.cornerRadius&&{cornerRadius:i.cornerRadius},style:f,datum:o?._nonInteractive?null:t.pieceData,category:t.name};o?._roundedEnds?b.roundedEnds=o._roundedEnds:g&&(b.roundedEnds={start:y,end:m}),o?._gradientBand&&(b._gradientBand=o._gradientBand),s.push(b)}return s}import{quantile as dr}from"d3-array";function gr(e){const t=e.length,o=e[0],i=e[t-1];return{n:t,min:o,q1:dr(e,.25)??o,median:dr(e,.5)??(o+i)/2,q3:dr(e,.75)??i,max:i,mean:e.reduce((e,t)=>e+t,0)/t}}import{scaleLinear as pr}from"d3-scale";var fr={bar:function(e,t){const{scales:o,columns:i,config:r,getR:s,getStack:n,resolvePieceStyle:a}=e,{r:c,projection:l}=o,u=[],h="vertical"===l,d="horizontal"===l,g=r.normalize,p=[];if(n){const e=new Set;for(const t of Object.values(i))for(const o of t.pieceData){const t=n(o);e.has(t)||(e.add(t),p.push(t))}}else p.push("_default");for(const e of Object.values(i)){const t=new Map;for(const o of e.pieceData){const e=n?n(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const i=t.get(e);i.total+=s(o),i.pieces.push(o)}let o=0;if(g)for(const e of t.values())o+=Math.abs(e.total);let i=0,r=0;for(const s of p){const l=t.get(s);if(!l)continue;let p=l.total;g&&o>0&&(p/=o);const f=a(l.pieces[0],n?s:e.name),y={...l.pieces[0],__aggregateValue:l.total,__pieceCount:l.pieces.length,category:e.name};if(h){const t=c(0>p?r:i+p),o=0>p?c(r+p)-c(r):c(i)-c(i+p);u.push(E(e.x,t,e.width,Math.abs(o),f,y,s)),0>p?r+=p:i+=p}else if(d){const t=c(0>p?r+p:i),o=0>p?c(r)-c(r+p):c(i+p)-c(i);u.push(E(t,e.x,Math.abs(o),e.width,f,y,s)),0>p?r+=p:i+=p}}}const f="vertical"===l,y=r.roundedTop&&r.roundedTop>0?Math.max(0,r.roundedTop):0;for(const e of u){if("rect"!==e.type)continue;const t=e.datum?.__aggregateValue??0;e.roundedEdge=f?0>t?"bottom":"top":0>t?"left":"right",r.gradientFill&&(e.fillGradient=r.gradientFill)}if(y>0){const e=new Map;for(const t of u){if("rect"!==t.type)continue;const o=t.datum?.category||"";e.has(o)||e.set(o,[]),e.get(o).push(t)}for(const t of e.values()){if(0===t.length)continue;const e=t.filter(e=>(e.datum?.__aggregateValue??0)>=0),o=t.filter(e=>0>(e.datum?.__aggregateValue??0));e.length>0&&(e.reduce(f?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t).roundedTop=y),o.length>0&&(o.reduce(f?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t).roundedTop=y)}}return u},clusterbar:function(e,t){const{scales:o,columns:i,config:r,getR:s,getGroup:n,resolvePieceStyle:a}=e,{r:c,projection:l}=o,u=[],h="vertical"===l,d=[],g=new Set;for(const e of Object.values(i))for(const t of e.pieceData){const e=n?n(t):"_default";g.has(e)||(g.add(e),d.push(e))}const p=d.length||1;for(const e of Object.values(i)){const t=e.width/p,o=.2*t,i=t-o,r=new Map;for(const t of e.pieceData){const e=n?n(t):"_default";r.has(e)||r.set(e,[]),r.get(e).push(t)}for(let n=0;d.length>n;n++){const l=r.get(d[n])||[];for(const r of l){const l=s(r),g=a(r,d[n]);if(h){const s=e.x+n*t+o/2,a=c(0),h=c(l);u.push(E(s,Math.min(a,h),i,Math.abs(a-h),g,r,d[n]))}else{const s=e.x+n*t+o/2,a=c(0),h=c(l);u.push(E(Math.min(a,h),s,Math.abs(h-a),i,g,r,d[n]))}}}}const f=r.roundedTop&&r.roundedTop>0?Math.max(0,r.roundedTop):0;for(const e of u){if("rect"!==e.type)continue;if(null==e.datum)continue;const t=s(e.datum);f>0&&(e.roundedTop=f),e.roundedEdge=h?0>t?"bottom":"top":0>t?"left":"right",r.gradientFill&&(e.fillGradient=r.gradientFill)}return u},point:function(e,t){const{scales:o,columns:i,getR:r,multiScales:s,resolvePieceStyle:n}=e,{r:a,projection:c}=o,l=[],u="vertical"===c,h="radial"===c,d=s.length>0,g=lr(e),p=2*Math.PI,f=-Math.PI/2;for(const e of Object.values(i))for(const t of e.pieceData){const o=t.__rIndex??0,i=t.__rValue??r(t),c=d&&s[o]||a,y=n(t,e.name),m=y.r||5;let b,x;if(h){const t=f+(e.pctStart+e.pct/2)*p,o=c(i);b=Math.cos(t)*o,x=Math.sin(t)*o}else u?(b=e.middle,x=c(i)):(b=c(i),x=e.middle);ur(l,g,t,b,x,m,y)}return l},swarm:function(e,t){const{scales:o,columns:i,getR:r,resolvePieceStyle:s}=e,{r:n,projection:a}=o,c=[],l="vertical"===a,u=lr(e);for(const e of Object.values(i)){const t=e.width/2;for(let o=0;e.pieceData.length>o;o++){const i=e.pieceData[o],a=r(i),h=s(i,e.name),d=h.r||4,g=(7919*o%100/100-.5)*t*.8;ur(c,u,i,l?e.middle+g:n(a),l?n(a):e.middle+g,d,h)}}return c},pie:hr,donut:hr,boxplot:function(e,t){const{scales:o,columns:i,config:r,getR:s,resolveSummaryStyle:n}=e,{r:a,projection:c}=o,l=[],u="vertical"===c,h=!1!==r.showOutliers;for(const t of Object.values(i)){const o=t.pieceData.map(e=>s(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===o.length)continue;const i=o[0],r=o[o.length-1],c=dr(o,.25)??i,d=dr(o,.5)??(i+r)/2,g=dr(o,.75)??r,p=g-c,f=c-1.5*p,y=g+1.5*p,m=o.find(e=>e>=f)??i,b=[...o].reverse().find(e=>y>=e)??r,x=n(t.pieceData[0],t.name),v=[];if(h)for(const e of t.pieceData){const o=s(e);if(f>o||o>y){const i=u?t.middle:a(o),r=u?a(o):t.middle;v.push({px:i,py:r,value:o,datum:e})}}if(l.push({type:"boxplot",x:u?t.middle:0,y:u?0:t.middle,projection:u?"vertical":"horizontal",columnWidth:.6*t.width,minPos:a(m),q1Pos:a(c),medianPos:a(d),q3Pos:a(g),maxPos:a(b),stats:{n:o.length,min:m,q1:c,median:d,q3:g,max:b,mean:o.reduce((e,t)=>e+t,0)/o.length},style:x,datum:t.pieceData,category:t.name,outliers:v}),h)for(const t of v)l.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:x.fill||e.config.themeSemantic?.secondary||"#999",opacity:.6},datum:t.datum})}return l},violin:function(e,t){const{scales:o,columns:i,config:r,getR:s,resolveSummaryStyle:n}=e,{r:a,projection:c}=o,l=[],u="vertical"===c,h=r.bins||20,d=!1!==r.showIQR;for(const e of Object.values(i)){const t=e.pieceData.map(e=>s(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const o=t[0],i=t[t.length-1],r=(i-o)/h||1,c=Array(h).fill(0);for(const e of t)c[Math.min(Math.floor((e-o)/r),h-1)]++;const g=xt(c,1),p=e.width/2*.9;let f;if(u){f=`M ${e.middle} ${a(o)}`;for(let t=0;h>t;t++){const i=a(o+(t+.5)*r);f+=` L ${e.middle+c[t]/g*p} ${i}`}f+=` L ${e.middle} ${a(i)}`;for(let t=h-1;t>=0;t--){const i=a(o+(t+.5)*r);f+=` L ${e.middle-c[t]/g*p} ${i}`}f+=" Z"}else{f=`M ${a(o)} ${e.middle}`;for(let t=0;h>t;t++)f+=` L ${a(o+(t+.5)*r)} ${e.middle-c[t]/g*p}`;f+=` L ${a(i)} ${e.middle}`;for(let t=h-1;t>=0;t--)f+=` L ${a(o+(t+.5)*r)} ${e.middle+c[t]/g*p}`;f+=" Z"}const y=n(e.pieceData[0],e.name);let m;if(d&&t.length>=4){const r=dr(t,.25)??o,s=dr(t,.5)??(o+i)/2,n=dr(t,.75)??i;m={q1Pos:a(r),medianPos:a(s),q3Pos:a(n),centerPos:e.middle,isVertical:u}}const b=u?{x:e.x,y:Math.min(a(i),a(o)),width:e.width,height:Math.abs(a(i)-a(o))}:{x:Math.min(a(o),a(i)),y:e.x,width:Math.abs(a(i)-a(o)),height:e.width};l.push({type:"violin",pathString:f,translateX:0,translateY:0,bounds:b,iqrLine:m,stats:gr(t),style:y,datum:e.pieceData,category:e.name})}return l},histogram:function(e,t){const{scales:o,columns:i,config:r,getR:s,resolveSummaryStyle:n}=e,{r:a}=o,c=[],l=r.bins||25,u=r.normalize,h=a.domain?.(),d=h?+h[0]:void 0,g=h?+h[1]:void 0;for(const e of Object.values(i)){const t=e.pieceData.map(e=>s(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const[o,i]=At(t),r=null!=d&&isFinite(d)?d:o,h=null!=g&&isFinite(g)?g:i,p=(h-r)/l||1,f=Array(l).fill(0);for(const e of t)r>e||e>h||f[Math.min(Math.floor((e-r)/p),l-1)]++;const y=t.length,m=xt(f,1),b=n(e.pieceData[0],e.name);for(let t=0;l>t;t++){if(0===f[t])continue;const o=(u?f[t]/y:f[t]/m)*e.width*.9,i=a(r+t*p),s=a(r+(t+1)*p);c.push(E(Math.min(i,s),e.x+e.width-o,Math.abs(s-i),o,b,{bin:t,count:f[t],range:[r+t*p,r+(t+1)*p],category:e.name},e.name))}}return c},ridgeline:function(e,t){const{scales:o,columns:i,config:r,getR:s,resolveSummaryStyle:n}=e,{r:a,projection:c}=o,l=[],u=r.bins||20,h="horizontal"===c,d=r.amplitude||1.5;for(const e of Object.values(i)){const t=e.pieceData.map(e=>s(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const o=t[0],i=t[t.length-1],r=(i-o)/u||1,c=Array(u).fill(0);for(const e of t)o>e||e>i||c[Math.min(Math.floor((e-o)/r),u-1)]++;const g=xt(c,1),p=n(e.pieceData[0],e.name),f=e.width*d;let y;if(h){const t=e.x+e.width;y=`M ${a(o)} ${t}`;for(let e=0;u>e;e++)y+=` L ${a(o+(e+.5)*r)} ${t-c[e]/g*f}`;y+=` L ${a(i)} ${t} Z`}else{const t=e.x;y=`M ${t} ${a(o)}`;for(let e=0;u>e;e++){const i=a(o+(e+.5)*r);y+=` L ${t+c[e]/g*f} ${i}`}y+=` L ${t} ${a(i)} Z`}const m=h?{x:Math.min(a(o),a(i)),y:e.x,width:Math.abs(a(i)-a(o)),height:e.width}:{x:e.x,y:Math.min(a(i),a(o)),width:e.width,height:Math.abs(a(i)-a(o))};l.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:m,stats:gr(t),style:{...p,fillOpacity:p.fillOpacity??.5},datum:e.pieceData,category:e.name})}return l},timeline:function(e,t){const{scales:o,columns:i,getRawRange:r,resolvePieceStyle:s}=e,{r:n,projection:a}=o,c=[],l="horizontal"===a;for(const e of Object.values(i))for(const t of e.pieceData){const o=r(t);if(!o)continue;const[i,a]=o,u=s(t,e.name);if(l){const o=n(Math.min(i,a)),r=n(Math.max(i,a));c.push(E(o,e.x,r-o,e.width,u,t,e.name))}else{const o=n(Math.max(i,a)),r=n(Math.min(i,a));c.push(E(e.x,o,e.width,r-o,u,t,e.name))}}return c},funnel:function(e,t){const{columns:o,getR:i,getStack:r,resolvePieceStyle:s}=e,n=[],a=t.width/2,c=!1!==e.config.showLabels,l=e.scales.o.domain().map(e=>o[e]).filter(Boolean);if(0===l.length)return n;const u=[],h=new Set;for(const e of l)for(const t of e.pieceData){const e=r?r(t):"_default";h.has(e)||(h.add(e),u.push(e))}const d=u.length>1&&"_default"!==u[0],g=[];let p=0;for(const e of l){const t=new Map;let o=0;for(const s of e.pieceData){const e=r?r(s):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const n=t.get(e),a=i(s);n.total+=a,n.pieces.push(s),o+=a}g.push({col:e,groups:t,stepTotal:o}),d||o>p&&(p=o)}if(d)for(const e of g){let t=0,o=0;for(let i=0;u.length>i;i++){const r=e.groups.get(u[i]);r&&(i%2==0?t+=r.total:o+=r.total)}const i=Math.max(t,o);i>p&&(p=i)}if(0===p)return n;const f=new Map;for(const e of u){const t=g[0].groups.get(e);f.set(e,t?.total??0)}const y=g[0].stepTotal,m=d?.95*a:.9*t.width,b=pr().domain([0,p]).range([0,m]),x=e.config.connectorOpacity??.3;let v=new Map;for(let t=0;g.length>t;t++){const o=g[t],i=o.col,r=0===t,l=i.width,h=.55*l,p=i.x+(l-h)/2,m=new Map;if(d){let e=0;for(const t of u){const i=o.groups.get(t);i&&(e+=b(i.total))}let t=a,l=a;for(let d=0;u.length>d;d++){const g=u[d],y=o.groups.get(g);if(!y)continue;const x=b(y.total),v=d%2==0,A=v?t:l-x;v?t+=x:l-=x;const S=s(y.pieces[0],g),w=f.get(g)??y.total,k={...y.pieces[0],__funnelValue:y.total,__funnelPercent:w>0?y.total/w*100:0,__funnelStep:i.name,__funnelIsFirstStep:r,__aggregateValue:y.total,__pieceCount:y.pieces.length,category:g};c&&(0===d&&(k.__funnelStepLabel=i.name,k.__funnelStepLabelX=a,k.__funnelStepLabelY=p,k.__funnelRowWidth=e),k.__funnelValueLabelX=A+x/2,k.__funnelValueLabelY=p,k.__funnelBarW=x),n.push(E(A,p,x,h,S,k,g)),m.set(g,{x:A,y:p,w:x,h:h})}}else{const e=o.stepTotal,t=b(e),l=a-t/2,d=u[0],g="_default"!==d,f=o.groups.get(d)?.pieces[0]??i.pieceData[0],x=g?d:i.name,v=s(f,x),A=y>0?e/y*100:0,S={...f,__funnelValue:e,__funnelPercent:A,__funnelStep:i.name,__funnelIsFirstStep:r,category:g?d:i.name};c&&(S.__funnelStepLabel=i.name,S.__funnelStepLabelX=a,S.__funnelStepLabelY=p,S.__funnelRowWidth=t,S.__funnelValueLabelX=a,S.__funnelValueLabelY=p,S.__funnelBarW=t),n.push(E(l,p,t,h,v,S,x)),m.set(d,{x:l,y:p,w:t,h:h})}if(t>0&&v.size>0){const t=d?u:[u[0]];for(const r of t){const t=v.get(r),a=m.get(r);if(!t||!a)continue;const c=(()=>{const e=o.groups.get(r);return s(e?e.pieces[0]:i.pieceData[0],"_default"===r?i.name:r)})(),l={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[a.x+a.w,a.y],[a.x,a.y]],style:{fill:c.fill||e.config.themeSemantic?.secondary||"#999",opacity:x},datum:o.groups.get(r)?.pieces[0]??i.pieceData[0],category:"_default"===r?i.name:r};n.push(l)}}v=m}return n},"bar-funnel":function(e,t){const{columns:o,getR:i,getStack:r,resolvePieceStyle:s,scales:n}=e,a=[],c=n.o.domain().map(e=>o[e]).filter(Boolean);if(0===c.length)return a;const l=[],u=new Set;for(const e of c)for(const t of e.pieceData){const e=r?r(t):"_default";u.has(e)||(u.add(e),l.push(e))}const h=l.length>1&&"_default"!==l[0],d=[];for(const e of c){const t=new Map;let o=0;for(const s of e.pieceData){const e=r?r(s):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const n=t.get(e),a=i(s);n.total+=a,n.pieces.push(s),o+=a}d.push({col:e,groups:t,stepTotal:o})}const g=new Map;for(const e of l){const t=d[0]?.groups.get(e);g.set(e,t?.total??0)}const p=n.r,f=h?l.length:1,y=h?.15:0;for(let e=0;d.length>e;e++){const t=d[e],o=t.col,i=0===e,r=e>0?d[e-1]:null,n=o.width/f,c=n*y,u=n-c;for(let e=0;l.length>e;e++){const d=l[e],f=t.groups.get(d);if(!f)continue;const y=f.total,m=g.get(d)??y,b=m>0?y/m*100:0,x=r?.groups.get(d),v=i?0:Math.max(0,(x?.total??y)-y),A=o.x+e*n+c/2,S=p(y),w=p(0)-S,k=s(f.pieces[0],h?d:o.name),_={...f.pieces[0],__barFunnelValue:y,__barFunnelPercent:b,__barFunnelIsFirstStep:i,__barFunnelIsDropoff:!1,__barFunnelStep:o.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===d?void 0:d,category:h?d:o.name,__barFunnelLabelX:A+u/2,__barFunnelLabelY:p(y+v)};if(a.push(E(A,S,u,w,k,_,h?d:o.name)),v>0){const e=p(y+v),t=S-e,i={...k},r={...f.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:o.name,__barFunnelCategory:"_default"===d?void 0:d,category:h?d:o.name};a.push(E(A,e,u,t,i,r,h?d:o.name))}}}return a},swimlane:function(e,t){const{scales:o,columns:i,getR:r,getStack:s,resolvePieceStyle:n}=e,{r:a,projection:c}=o,l=[],u="horizontal"===c,h=e.config.gradientFill,d=u?"left":"bottom",g=e.config.trackFill;if(g){const e="string"==typeof g?g:g.color,t="string"==typeof g?1:g.opacity??1,[o,r]=a.range(),s=Math.min(o,r),n=Math.abs(r-o);for(const o of Object.values(i)){const i={fill:e,opacity:t},r=u?E(s,o.x,n,o.width,i,null,"__track__"):E(o.x,s,o.width,n,i,null,"__track__");l.push(r)}}const p=e.config.roundedTop&&e.config.roundedTop>0?Math.max(0,e.config.roundedTop):0;for(const e of Object.values(i)){let t=0;const o=l.length;for(const o of e.pieceData){const i=Math.abs(r(o));if(0===i)continue;const c=s?s(o):e.name,g=n(o,c);let p;if(u){const r=a(t),s=a(t+i);p=E(r,e.x,s-r,e.width,g,o,c)}else{const r=a(t+i),s=a(t);p=E(e.x,r,e.width,s-r,g,o,c)}h&&(p.fillGradient=h,p.roundedEdge=d),l.push(p),t+=i}if(p>0&&l.length>o){const e=l.slice(o),t=e[0],i=e[e.length-1];1===e.length?t.cornerRadii={tl:p,tr:p,br:p,bl:p}:u?(t.cornerRadii={tl:p,bl:p},i.cornerRadii={tr:p,br:p}):(t.cornerRadii={bl:p,br:p},i.cornerRadii={tl:p,tr:p})}}return l}},yr=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],mr=["scene-style","data-paint","accessibility","evidence"],br=(e,t)=>({retainedData:e,invalidations:t}),xr=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],vr=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ar=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Sr=["scene-geometry","data-paint","accessibility","evidence"],wr=["scene-style","data-paint","accessibility","evidence"],kr=[],_r={chartType:br("rebuild",xr),runtimeMode:br("rebuild",xr),categoryAccessor:br("rebuild",xr),valueAccessor:br("rebuild",xr),oAccessor:br("rebuild",xr),rAccessor:br("rebuild",xr),stackBy:br("rebuild",xr),groupBy:br("rebuild",xr),timeAccessor:br("rebuild",xr),accessorRevision:br("rebuild",xr),colorAccessor:br("rebuild",wr),symbolAccessor:br("rebuild",Sr),connectorAccessor:br("rebuild",Sr),dataIdAccessor:br("rebuild",Sr),projection:br("preserve",vr),extentPadding:br("preserve",vr),axisExtent:br("preserve",vr),rExtent:br("preserve",vr),oExtent:br("preserve",vr),multiAxis:br("preserve",vr),normalize:br("preserve",vr),bins:br("preserve",vr),oSort:br("preserve",Ar),barPadding:br("preserve",Ar),roundedTop:br("preserve",Ar),baselinePadding:br("preserve",Ar),innerRadius:br("preserve",Ar),cornerRadius:br("preserve",Ar),startAngle:br("preserve",Ar),sweepAngle:br("preserve",Ar),trackFill:br("preserve",Ar),showOutliers:br("preserve",Ar),showIQR:br("preserve",Ar),amplitude:br("preserve",Ar),connectorOpacity:br("preserve",Ar),showLabels:br("preserve",Ar),dynamicColumnWidth:br("rebuild",Ar),customLayout:br("preserve",Ar),layoutConfig:br("preserve",Ar),layoutMargin:br("preserve",Ar),symbolMap:br("preserve",Sr),pieceStyle:br("preserve",wr),summaryStyle:br("preserve",wr),connectorStyle:br("preserve",wr),gradientFill:br("preserve",wr),colorScheme:br("preserve",wr),themeCategorical:br("preserve",wr),themeSemantic:br("preserve",wr),themeSequential:br("preserve",wr),themeDiverging:br("preserve",wr),barColors:br("preserve",wr),decay:br("preserve",wr),pulse:br("preserve",wr),staleness:br("preserve",wr),layoutSelection:br("preserve",wr),windowSize:br("preserve",kr),windowMode:br("preserve",kr),clock:br("preserve",kr),transition:br("preserve",kr),introAnimation:br("preserve",kr),onLayoutError:br("preserve",kr)},Mr=br("preserve",Ar),Pr=class{constructor(){this.tracker=new at}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},yr)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},mr):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const o=new Set;for(const i of e){const e=_r[i]??Mr;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)o.add(t)}return{retainedData:t,invalidations:o}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}};import{quadtree as Tr}from"d3-quadtree";var Lr=class{constructor(e){this.rExtent=new te,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new Pr,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new cr,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},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.version=0,this._dataVersion=0,this._bufferArrayCache=null,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=e,this.buffer=new oe(e.windowSize),this.getO=rt(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>it(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new te)):(this.getR=it(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=rt(e.stackBy),this.getGroup=rt(e.groupBy),this.getColor=rt(e.colorAccessor),this.getSymbol=rt(e.symbolAccessor),this.getConnector=rt(e.connectorAccessor),this.getDataId=rt(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new oe(e.windowSize))}syncPulseTimestampBuffer(){var e,t,o,i;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,o=this.timestampBuffer,i=this.currentTime(),e?null!=o&&o.capacity===t.capacity&&o.size===t.size?o:G(t,i):null)}currentTime(){return this.config.clock?.()??ze()}ingest(e){const t=this.currentTime();if(this.lastIngestTime=t,this._dataVersion++,e.bounded){this.buffer.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();e.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),Y(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const o of e.inserts)X(this.buffer,o,this.timestampBuffer,t),this.categories.add(this.getO(o)),this.pushValueExtent(o)}else{this._hasStreamingData=!0;for(const o of e.inserts){const e=X(this.buffer,o,this.timestampBuffer,t);this.categories.add(this.getO(o)),this.pushValueExtent(o),null!=e&&this.evictValueExtent(e)}}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.valueAccessor||this.config.rAccessor;if(!t)return null;const o="function"==typeof t?t(e):e[t];return Array.isArray(o)&&o.length>=2?[+o[0],+o[1]]:null}computeScene(e){const{config:t,buffer:o}=this,i=this.scales,r=this.multiScales,s=this.columns;if(0===o.size)return this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(o,this.getR);const n=this.getBufferArray(),a=t.projection||"vertical",c=t.oExtent||this.resolveCategories(n),l=this.computeValueDomain(n,c),u="horizontal"===a,h="radial"===a,d=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===a?e.width:e.height):.1));let g,p;if(h){g=nr().domain(c).range([0,1]).padding(0);const o=Math.min(e.width,e.height)/2,i=t.innerRadius||0;p=ar().domain(l).range([i,o])}else u?(g=nr().domain(c).range([0,e.height]).padding(d),p=ar().domain(l).range([0,e.width])):(g=nr().domain(c).range([0,e.width]).padding(d),p=ar().domain(l).range([e.height,0]));this.scales={o:g,r:p,projection:a},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((i,r)=>{const s=this.rExtents[r];s.dirty&&s.recalculate(o,i);let[n,a]=s.extent;n===1/0&&(n=0,a=1);const c=a-n,l=c>0?c*(t.extentPadding??.05):1;return n-=l,a+=l,n>0&&(n=0),u?ar().domain([n,a]).range([0,e.width]):ar().domain([n,a]).range([e.height,0])}):[];let f=n;this.rAccessors.length>1&&(f=n.flatMap(e=>this.rAccessors.map((t,o)=>({...e,__rIndex:o,__rValue:t(e),__rName:this.resolveRAccessorName(o)})))),this.columns=this.buildColumns(f,c,g,a,e),this._customLayoutFailedThisBuild=!1;const y=this.buildSceneNodes(f,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=i,this.multiScales=r,this.columns=s):(this.scene=[],this.rebuildPointQuadtree()):(this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=y,this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,n),this.config.pulse&&this.applyPulse(this.scene,n),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.startTransition(),this.version++)}resolveRAccessorName(e){const t=this.config.valueAccessor||this.config.rAccessor,o=Array.isArray(t)?t[e]:t;return"string"==typeof o?o:"value"+e}resolveCategories(e){const t=this.config.oSort,o="streaming"===this.config.runtimeMode||this._hasStreamingData,i="auto"===t?void 0:t;let r=null;if(o){r=new Set;for(const t of e)r.add(this.getO(t))}const s=r?Array.from(this.categories).filter(e=>r.has(e)):Array.from(this.categories);if(o&&void 0===i){const e=Math.max(50,3*r.size);if(this.categories.size>e){let t=this.categories.size-e;for(const e of this.categories){if(0>=t)break;r.has(e)||(this.categories.delete(e),t--)}}return s}if(!1===i)return s;if("function"==typeof i)return s.sort(i);const n=new Map;for(const t of e){const e=this.getO(t);n.set(e,(n.get(e)||0)+Math.abs(this.getR(t)))}return s.sort("asc"===i?(e,t)=>(n.get(e)||0)-(n.get(t)||0):(e,t)=>(n.get(t)||0)-(n.get(e)||0))}computeValueDomain(e,t){return function(e){const{data:t,chartType:o,projection:i,normalize:r,rExtent:s,extentPadding:n=.05,baselinePadding:a,axisExtent:c,getO:l,getR:u,getStack:h,rawRExtent:d}=e,g=n;if("radial"===i&&("pie"===o||"donut"===o))return[0,1];let p=0,f=0;if("bar"===o&&h&&r)p=0,f=1;else if("bar"===o&&h){const e=new Map,o=new Map;for(const i of t){const t=l(i),r=u(i);0>r?o.set(t,(o.get(t)||0)+r):e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>f&&(f=t);for(const e of o.values())p>e&&(p=e)}else if("bar"===o){const e=new Map;for(const o of t){const t=l(o),i=u(o);e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>f&&(f=t),p>t&&(p=t)}else if("swimlane"===o){const e=new Map;for(const o of t){const t=l(o),i=Math.abs(u(o));e.set(t,(e.get(t)||0)+i)}for(const t of e.values())t>f&&(f=t)}else if("clusterbar"===o||"bar-funnel"===o)for(const e of t){const t=u(e);t>f&&(f=t),p>t&&(p=t)}else{const e=d[0],t=d[1];e!==1/0&&(p=e),t!==-1/0&&(f=t)}s&&(null!=s[0]&&(p=s[0]),null!=s[1]&&(f=s[1]));const y="bar"===o||"clusterbar"===o||"bar-funnel"===o||"swimlane"===o;if(y&&null==s?.[0]&&null==s?.[1]&&(p>0&&(p=0),0>f&&(f=0)),"bar-funnel"!==o&&"exact"!==c){const e=f-p,t=e>0?e*g:1,i=y&&!a&&0===p,r=y&&!a&&0===f||"swimlane"===o;null!=s?.[0]||i||(p-=t),null!=s?.[1]||r||(f+=t)}return[p,f]}({data:e,chartType:this.config.chartType,projection:this.config.projection,normalize:this.config.normalize,rExtent:this.config.rExtent,extentPadding:this.config.extentPadding,baselinePadding:this.config.baselinePadding,axisExtent:this.config.axisExtent,getO:this.getO,getR:this.getR,getStack:this.getStack,rawRExtent:this.rExtent.extent})}buildColumns(e,t,o,i,r){return function(e){const{data:t,oExtent:o,oScale:i,projection:r,layout:s,dynamicColumnWidth:n,getO:a,getR:c}=e,l={},u=new Map;for(const e of t){const t=a(e);u.has(t)||u.set(t,[]),u.get(t).push(e)}let h=0;if("radial"===r)for(const e of t)h+=Math.abs(c(e));let d=null;if(n&&"radial"!==r){d=new Map;let e=0;for(const t of o){const o=u.get(t)||[];let i;i="string"==typeof n?o.reduce((e,t)=>e+(Number(t[n])||0),0):n(o),d.set(t,i),e+=i}const t=("horizontal"===r?s.height:s.width)-i.padding()*i.step()*o.length;if(e>0)for(const[o,i]of d)d.set(o,i/e*t)}let g=0,p=0;for(const e of o){const t=u.get(e)||[],o=t.reduce((e,t)=>e+Math.abs(c(t)),0),r=h>0?o/h:0;let s,n;d?(s=p,n=d.get(e)||i.bandwidth(),p+=n+i.padding()*i.step()):(s=i(e)??0,n=i.bandwidth()),l[e]={name:e,x:s,y:0,width:n,middle:s+n/2,padding:i.padding()*i.step(),pieceData:t,pct:r,pctStart:g},g+=r}return l}({data:e,oExtent:t,oScale:o,projection:i,layout:r,dynamicColumnWidth:this.config.dynamicColumnWidth,getO:this.getO,getR:this.getR})}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getSymbol:this.getSymbol,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.styleResolver.resolvePieceStyle(this.config,e,t),resolveSummaryStyle:(e,t)=>this.styleResolver.resolveSummaryStyle(this.config,e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){if(!this.scales)return[];if(this.config.customLayout){const o=this.buildLayoutContext(e,t);let i;try{i=this.config.customLayout(o)}catch(e){const t=null!==this.lastCustomLayoutResult,o=$("ordinal",e,t,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",e);try{this.config.onLayoutError?.(o)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return t?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=i.overlays??null,this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null;const r=i.nodes??[];if(this._customRestyle=i.restyle,this.hasCustomRestyle=!!i.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const e of r)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(r,this.config.layoutSelection??null)}return ee({label:"ordinal customLayout",nodes:r,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),r}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const o=this.getSceneContext(),i=fr[this.config.chartType];let r=i?i(o,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:o,config:i,getConnector:r,getO:s}=e;if(!r||!o)return[];const n=[],{projection:a}=o,c=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const o=r(t);if(!o)continue;let i,n;"point"===e.type?(i=e.x,n=e.y):(i=e.x+e.w/2,n=e.y+("vertical"===a?0:e.h/2)),c.has(o)||c.set(o,[]),c.get(o).push({x:i,y:n,datum:t,category:s(t)})}const l=o.o.domain(),u=i.connectorStyle;for(const[t,o]of c)if(o.length>=2){o.sort((e,t)=>l.indexOf(e.category)-l.indexOf(t.category));for(let i=0;o.length-1>i;i++){const r=o[i],s=o[i+1],a="function"==typeof u?u(r.datum):u||{stroke:e.config.themeSemantic?.border||e.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5};n.push({type:"connector",x1:r.x,y1:r.y,x2:s.x,y2:s.y,style:a,datum:r.datum,group:t})}}return n}(o,r);r=[...e,...r]}return r}buildLayoutContext(e,t){const o=this.config,i=o.layoutMargin??{top:0,right:0,bottom:0,left:0},r=Ne(o.colorScheme,o.themeCategorical,ce),s=this.scales;return{data:e,scales:{o:s.o,r:s.r,projection:s.projection},dimensions:{width:t.width,height:t.height,margin:i,plot:"radial"===s.projection?{x:-t.width/2,y:-t.height/2,width:t.width,height:t.height}:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:o.themeSemantic??{},categorical:[...r]},resolveColor:ge(r,o.colorScheme),config:o.layoutConfig??{},selection:o.layoutSelection??null}}computeDecayOpacity(e,t){const o=this.config.decay;return o&&t>1?W(o,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=B(e);return this._datumIndexCache={version:this._dataVersion,map:t},t}getCategoryIndexMap(e){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const t=function(e,t){const o="function"==typeof t,i=o?null:t||"category",r=new Map;for(let s=0;e.length>s;s++){const n=e[s],a=o?t(n):n[i],c=r.get(a);c?c.push(s):r.set(a,[s])}return r}(e,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:t},t}rebuildPointQuadtree(){const e=function(e){let t=0,o=0;for(const i of e)"point"===i.type&&(t++,i.r>o&&(o=i.r));if(500>=t)return{quadtree:null,maxRadius:o};const i=Array(t);let r=0;for(const t of e)"point"===t.type&&(i[r++]=t);return{maxRadius:o,quadtree:Tr().x(e=>e.x).y(e=>e.y).addAll(i)}}(this.scene);this._pointQuadtree=e.quadtree,this._maxPointRadius=e.maxRadius}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(e,t){if(!this.config.decay)return;const o=t.length;if(1>=o)return;const i=this.getDatumIndexMap(t);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;if(!t.datum)continue;const e=i.get(t.datum);if(null==e)continue;const r=this.computeDecayOpacity(e,o);t.style={...t.style,opacity:(t.style?.opacity??1)*r}}}applyPulse(e,t,o=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,o,i,r,s){const n=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let c=!1;for(const l of t){if("connector"===l.type||"violin"===l.type||"boxplot"===l.type)continue;if("wedge"===l.type){const t=l.category;if(!t)continue;let i=0;for(const n of r(t)??[]){const t=o.get(n);null!=t&&(i=Math.max(i,I(e,t,s)))}c=Z(l,i,n)||c;continue}if(null==l.datum)continue;const t=i.get(l.datum);if(null==t)continue;const u=o.get(t),h=null==u?0:I(e,u,s);c=Z(l,h,n,a)||c}return c}(this.config.pulse,e,this.timestampBuffer,this.getDatumIndexMap(t),e=>this.getCategoryIndexMap(t).get(e),o)}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&V(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}synthesizeIntroPositions(){this.prevPositionMap.clear();const e=new Map,t=this.scales?.r(0)??0,o="horizontal"!==this.scales?.projection;let i;for(let r=0;this.scene.length>r;r++){const s=this.scene[r],n=this.getNodeKey(s,e);n&&("rect"===s.type?this.prevPositionMap.set(n,o?{x:s.x,y:t,w:s.w,h:0,opacity:s.style.opacity??1}:{x:t,y:s.y,w:0,h:s.h,opacity:s.style.opacity??1}):"point"===s.type?this.prevPositionMap.set(n,{x:s.x,y:s.y,r:0,opacity:0}):"wedge"===s.type&&(void 0===i&&(i=s.startAngle),this.prevPositionMap.set(n,{x:s.cx,y:s.cy,startAngle:i,endAngle:i,innerRadius:s.innerRadius,outerRadius:s.outerRadius,opacity:0})))}}getNodeKey(e,t){if("point"===e.type){const o=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,i=t.get(o)||0;return t.set(o,i+1),`${o}:${i}`}return"rect"===e.type?`r:${e.group||""}:${e.datum?.category??""}`:"wedge"===e.type?"w:"+(e.category??""):null}snapshotPositions(){this.prevPositionMap.clear();const e=new Map;for(let t=0;this.scene.length>t;t++){const o=this.scene[t],i=this.getNodeKey(o,e);i&&("point"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"rect"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"wedge"===o.type&&this.prevPositionMap.set(i,{x:o.cx,y:o.cy,startAngle:o.startAngle,endAngle:o.endAngle,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:o.style.opacity??1}))}}startTransition(){if(!this.config.transition||0===this.prevPositionMap.size)return;const e=this.config.transition.duration??300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let t=!1;const o=new Set,i=new Map;for(let e=0;this.scene.length>e;e++){const r=this.scene[e],s=this.getNodeKey(r,i);if(!s)continue;r._transitionKey=s;const n=this.prevPositionMap.get(s);if("point"===r.type)n?(o.add(s),r._targetOpacity=r.style.opacity??1,(n.x!==r.x||n.y!==r.y||void 0!==n.r&&n.r!==r.r)&&(r._targetX=r.x,r._targetY=r.y,r._targetR=r.r,r.x=n.x,r.y=n.y,void 0!==n.r&&(r.r=n.r),t=!0)):(r._targetOpacity=r.style.opacity??1,r._targetR=r.r,r.r=0,r.style={...r.style,opacity:0},t=!0);else if("rect"===r.type)n?(o.add(s),r._targetOpacity=r.style.opacity??1,n.x===r.x&&n.y===r.y&&n.w===r.w&&n.h===r.h||(r._targetX=r.x,r._targetY=r.y,r._targetW=r.w,r._targetH=r.h,r.x=n.x,r.y=n.y,r.w=n.w??r.w,r.h=n.h??r.h,t=!0)):(r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},t=!0);else if("wedge"===r.type)if(n)o.add(s),r._targetOpacity=r.style.opacity??1,n.startAngle===r.startAngle&&n.endAngle===r.endAngle||(r._targetStartAngle=r.startAngle,r._targetEndAngle=r.endAngle,r.startAngle=n.startAngle,r.endAngle=n.endAngle,t=!0);else{r._targetOpacity=r.style.opacity??1,r._targetStartAngle=r.startAngle,r._targetEndAngle=r.endAngle;const e=r.startAngle;r.startAngle=e,r.endAngle=e,r.style={...r.style,opacity:0},this.prevPositionMap.set(s,{x:r.cx,y:r.cy,startAngle:e,endAngle:e,innerRadius:r.innerRadius,outerRadius:r.outerRadius,opacity:0}),t=!0}}this.exitNodes=[];for(const[e,i]of this.prevPositionMap)if(!o.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:i.x,y:i.y,r:i.r??3,style:{opacity:i.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:i.x,y:i.y,w:i.w??0,h:i.h??0,style:{opacity:i.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){const t=((i.startAngle??0)+(i.endAngle??0))/2,o={type:"wedge",cx:i.x,cy:i.y,innerRadius:i.innerRadius??0,outerRadius:i.outerRadius??100,startAngle:i.startAngle??0,endAngle:i.endAngle??0,style:{opacity:i.opacity??1},datum:null,category:e.slice(2),_targetStartAngle:t,_targetEndAngle:t,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(o)}t=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),t&&(this.activeTransition={startTime:this.currentTime(),duration:e})}advanceTransition(e){if(!this.activeTransition)return!1;const t=ye(e,this.activeTransition),o=fe(t,"linear"===this.config.transition?.easing?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style.opacity=Te(i?i.opacity??1:0,e._targetOpacity,o)}const i=this.prevPositionMap.get(t);void 0!==e._targetX&&i&&(e.x=Te(i.x,e._targetX,o),e.y=Te(i.y,e._targetY,o)),void 0!==e._targetR&&void 0!==i?.r&&(e.r=Te(i.r,e._targetR,o))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style.opacity=Te(i?i.opacity??1:0,e._targetOpacity,o)}if(void 0===e._targetX)continue;const i=this.prevPositionMap.get(t);if(!i)continue;e.x=Te(i.x,e._targetX,o),e.y=Te(i.y,e._targetY,o),void 0!==i.w&&(e.w=Te(i.w,e._targetW,o),e.h=Te(i.h,e._targetH,o))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){const i=this.prevPositionMap.get(t);e.style={...e.style,opacity:Te(i?i.opacity??1:0,e._targetOpacity,o)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){const i=this.prevPositionMap.get(t);i&&void 0!==i.startAngle&&(e.startAngle=Te(i.startAngle,e._targetStartAngle,o),e.endAngle=Te(i.endAngle,e._targetEndAngle,o))}}}if(t>=1){for(const e of this.scene)if(void 0!==e._targetOpacity&&(e.style={...e.style||{},opacity:0===e._targetOpacity?0:e._targetOpacity},e._targetOpacity=void 0),"point"===e.type){if(void 0===e._targetX&&void 0===e._targetR)continue;void 0!==e._targetX&&(e.x=e._targetX,e.y=e._targetY),void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else"wedge"===e.type&&void 0!==e._targetStartAngle&&(e.startAngle=e._targetStartAngle,e.endAngle=e._targetEndAngle,e._targetStartAngle=void 0,e._targetEndAngle=void 0);if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null}getBufferArray(){return this._bufferArrayCache?.version!==this._dataVersion&&(this._bufferArrayCache={version:this._dataVersion,data:this.buffer.toArray()}),this._bufferArrayCache.data}getData(){return this.buffer.toArray()}remove(e){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=J(e),o=this.getDataId,i=e=>t.has(o(e));N(this.buffer,this.timestampBuffer,i);const r=this.buffer.remove(i);if(0===r.length)return this.updateResults.recordNoop("remove"),r;for(const e of r)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",r.length),r}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const o=J(e),i=this.getDataId,r=new Set;this.buffer.forEach((e,t)=>{o.has(i(e))&&r.add(t)});const s=this.buffer.update(e=>o.has(i(e)),t);if(0===s.length)return this.updateResults.recordNoop("update"),s;for(const e of s)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),r.has(t)&&this.pushValueExtent(e)}),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",s.length),s}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this.multiScales=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._pointQuadtree=null,this._maxPointRadius=0,this.styleResolver.resetColors(),this._dataVersion++,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}applyCustomRestyle(e,t){const o=this._customRestyle;if(o)for(const i of e){const e=this._baseStyles.get(i)??i.style??{},r=o(i,t);i.style=r?{...e,...r}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();this._categoryIndexCache=null,this.buffer.forEach(e=>{this.categories.add(this.getO(e)),this.pushValueExtent(e)})}updateConfig(e){const t={...this.config},o=Object.keys(e).filter(o=>e[o]!==t[o]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e&&e.colorScheme!==t.colorScheme||"themeCategorical"in e&&e.themeCategorical!==t.themeCategorical||"colorAccessor"in e&&!tt(e.colorAccessor,t.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!tt(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!tt(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let i=!1;("categoryAccessor"in e||"oAccessor"in e)&&(tt(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=rt(this.config.categoryAccessor||this.config.oAccessor,"category"),i=!0));let r=!1;if("valueAccessor"in e||"rAccessor"in e){const e=this.config.valueAccessor||this.config.rAccessor,o=t.valueAccessor||t.rAccessor,i=Array.isArray(e)?e:[e],s=Array.isArray(o)?o:[o];if(r=i.length!==s.length||i.some((e,t)=>!tt(e,s[t])),r){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>it(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new te)):(this.getR=it(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!tt(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?rt(this.config.stackBy):void 0),"groupBy"in e&&!tt(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?rt(this.config.groupBy):void 0),"colorAccessor"in e&&!tt(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?rt(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!tt(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?rt(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!tt(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?rt(this.config.connectorAccessor):void 0),(i||r||"accessorRevision"in e&&e.accessorRevision!==t.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(o)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};R(Lr);import{jsx as Rr,jsxs as Cr}from"react/jsx-runtime";import{Fragment as zr,jsx as Fr,jsxs as Br}from"react/jsx-runtime";function Or(e,t){const o=io(e.theme),i=e.size||[500,400],r=Ee({top:20,right:20,bottom:30,left:40,...e.margin},e.title),s=we(e.title),n=be(e.data),a=e.showLegend?zi(n,e.colorAccessor||e.stackBy||e.groupBy):[];Zi(r,{props:e,categories:a,theme:o,size:i,hasTitle:s});const c=i[0]-r.left-r.right,l=i[1]-r.top-r.bottom,u=e.projection||"vertical",h="radial"===u,d={chartType:e.chartType,windowSize:e.windowSize??1e4,windowMode:e.windowMode??"sliding",extentPadding:e.extentPadding??.05,projection:u,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,axisExtent:e.axisExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,gradientFill:e.gradientFill,symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,multiAxis:e.multiAxis,baselinePadding:e.baselinePadding,trackFill:e.trackFill,connectorOpacity:e.connectorOpacity,showLabels:e.showLabels,colorScheme:e.colorScheme||o.colors.categorical,themeCategorical:o.colors.categorical,themeSemantic:Pt(o),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:r,layoutSelection:e.layoutSelection,barColors:e.barColors},g=new Lr(d);if(e.data&&g.ingest({inserts:n,bounded:!0}),g.computeScene({width:c,height:l}),!g.scales||0===g.scene.length)return t&&(t.evidence=bi({frameType:"ordinal",width:i[0],height:i[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:g.scales?[]:["NO_SCALES"]})),sr.renderToStaticMarkup(er(null,{width:i[0],height:i[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${r.left},${r.top})`,innerWidth:c,innerHeight:l,idPrefix:e._idPrefix}));const p=e._idPrefix,f=e.showGrid?function(e,t,o,i,r){const s=e.scales;if(!s||"radial"===s.projection)return null;const{grid:n}=ro(o),a=i?i+"-":"",c="vertical"===s.projection,l=U(s.r,5,r);return Gi("g",c?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const i=s.r(e);return Gi("line",{x1:0,y1:i,x2:t.width,y2:i,stroke:n,strokeWidth:.5},"gr-"+o)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,o)=>{const i=s.r(e);return Gi("line",{x1:i,y1:0,x2:i,y2:t.height,stroke:n,strokeWidth:.5},"gr-"+o)})})}(g,{width:c,height:l},o,p,e.axisExtent):null;let y=null;if(g.scene.some(e=>"rect"===e.type&&e.datum?.__barFunnelIsDropoff)){const t=Vi(e),i=new Set;for(const e of g.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&i.add("string"==typeof e.style.fill?e.style.fill:"#666");y=Array.from(i).map((e,i)=>function(e){const{id:t,background:o="transparent",stroke:i="#000",lineWidth:r=1.5,spacing:s=6,angle:n=45}=e,a=Math.max(8,Math.ceil(2*s));return Cr("pattern",{id:t,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==n?`rotate(${n})`:void 0,children:[o&&"transparent"!==o&&Rr("rect",{width:a,height:a,fill:o}),Rr("line",{x1:0,y1:0,x2:0,y2:a,stroke:i,strokeWidth:r}),Rr("line",{x1:s,y1:0,x2:s,y2:a,stroke:i,strokeWidth:r})]},t)}({id:`funnel-hatch-${t}-${i}`,background:e,stroke:"transparent"===o.colors.background?"#fff":o.colors.background,lineWidth:1.5,spacing:5,angle:45}));const r=new Map;Array.from(i).forEach((e,o)=>r.set(e,`funnel-hatch-${t}-${o}`));for(const e of g.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&(e.style={...e.style,fill:`url(#${r.get("string"==typeof e.style.fill?e.style.fill:"#666")})`})}const m=q({nodes:g.scene,renderMode:e.renderMode,fallback:(e,t)=>Fe(e,t,p)}),b=m.map(e=>e.element);if(t){const o=g.scales.o?.domain?.();t.evidence=bi({frameType:"ordinal",width:i[0],height:i[1],marks:m.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,yDomain:mi(g.scales.r?.domain?.()),categories:Array.isArray(o)?o.map(String):void 0})}const x=!1!==e.showAxes?function(e,t,o,i,r){const s=e.scales;if(!s)return null;if("radial"===s.projection)return null;const n=ro(i),a="vertical"===s.projection,c=o.categoryFormat||o.oFormat,l=o.valueFormat||o.rFormat,u=o.categoryLabel||o.oLabel,h=o.valueLabel||o.rLabel,d=Object.values(e.columns).map(e=>({pixel:e.middle,label:(c||String)(e.name)})),g=U(s.r,5,o.axisExtent).map(e=>({pixel:s.r(e),label:(l||Ji)(e)}));return Br("g",a?{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[Fr("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:n.border,strokeWidth:1}),d.map((e,o)=>Br("g",{transform:`translate(${e.pixel},${t.height})`,children:[Fr("line",{y2:5,stroke:n.border,strokeWidth:1}),Fr("text",{y:18,textAnchor:"middle",fontSize:n.tickSize,fill:n.textSecondary,fontFamily:n.fontFamily,children:e.label})]},"oxtick-"+o)),u&&Fr("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:n.labelSize,fill:n.text,fontFamily:n.fontFamily,children:u}),Fr("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:n.border,strokeWidth:1}),g.map((e,t)=>Br("g",{transform:`translate(0,${e.pixel})`,children:[Fr("line",{x2:-5,stroke:n.border,strokeWidth:1}),Fr("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n.tickSize,fill:n.textSecondary,fontFamily:n.fontFamily,children:e.label})]},"oytick-"+t)),h&&Fr("text",{x:15-(o.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:n.labelSize,fill:n.text,fontFamily:n.fontFamily,transform:`rotate(-90, ${15-(o.margin?.left??40)}, ${t.height/2})`,children:h})]}:{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[Fr("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:n.border,strokeWidth:1}),g.map((e,o)=>Br("g",{transform:`translate(${e.pixel},${t.height})`,children:[Fr("line",{y2:5,stroke:n.border,strokeWidth:1}),Fr("text",{y:18,textAnchor:"middle",fontSize:n.tickSize,fill:n.textSecondary,fontFamily:n.fontFamily,children:e.label})]},"oxtick-"+o)),h&&Fr("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:n.labelSize,fill:n.text,fontFamily:n.fontFamily,children:h}),Fr("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:n.border,strokeWidth:1}),d.map((e,t)=>Br("g",{transform:`translate(0,${e.pixel})`,children:[Fr("line",{x2:-5,stroke:n.border,strokeWidth:1}),Fr("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n.tickSize,fill:n.textSecondary,fontFamily:n.fontFamily,children:e.label})]},"oytick-"+t)),u&&Fr("text",{x:15-(o.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:n.labelSize,fill:n.text,fontFamily:n.fontFamily,transform:`rotate(-90, ${15-(o.margin?.left??40)}, ${t.height/2})`,children:u})]})}(g,{width:c,height:l},e,o,p):null,v=e.annotations?Wi({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{o:g.scales.o,r:g.scales.r,y:"vertical"===g.scales.projection?g.scales.r:void 0},layout:{width:c,height:l},theme:o,projection:u,idPrefix:p}):null,A=Ui({props:e,categories:a,theme:o,size:i,margin:r,hasTitle:s}),S=h?r.left+c/2:r.left,w=h?r.top+l/2:r.top,k=h&&e.centerContent?Fr("foreignObject",{x:r.left,y:r.top,width:c,height:l,pointerEvents:"none",children:Fr("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:e.centerContent})}):null;return sr.renderToStaticMarkup(er(Br(zr,{children:[e.backgroundGraphics,f,b,x,v,e.foregroundGraphics,g.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${S},${w})`,innerWidth:c,innerHeight:l,legend:A,defs:y,outerElements:k,idPrefix:e._idPrefix}))}import*as Er from"react-dom/server";import{Fragment as Dr,jsxs as jr}from"react/jsx-runtime";function Nr(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}var Wr=new Set(["tree","cluster","treemap","circlepack","partition"]);function Ir(e,t){const o=io(e.theme),i=e.chartType||"force",r=()=>bi({frameType:"network",width:s[0],height:s[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,nodeCount:0,edgeCount:0}),s=e.size||[500,500],n=Ee({top:20,right:20,bottom:20,left:20,...e.margin},e.title),a=we(e.title),c=e.showLegend?(()=>{const t="string"==typeof(o=e.colorBy)||"function"==typeof o?e.colorBy:void 0;var o;if(!t)return[];const i=be(e.nodes||[]);if(i.length>0)return zi(i,t);const r=Array.isArray(e.edges)?be(e.edges):[];if(0===r.length)return[];const s=Nr(e.sourceAccessor,"source"),n=Nr(e.targetAccessor,"target");return zi(Array.from(new Set(r.flatMap(e=>[s(e),n(e)]).filter(e=>null!=e).map(String))).map(e=>({id:e})),t)})():[];Zi(n,{props:e,categories:c,theme:o,size:s,hasTitle:a});const l=s[0]-n.left-n.right,u=s[1]-n.top-n.bottom,h=H(i);if(!h&&!e.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${i}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const d={chartType:i,nodeIDAccessor:e.nodeIDAccessor,sourceAccessor:e.sourceAccessor,targetAccessor:e.targetAccessor,valueAccessor:e.valueAccessor,childrenAccessor:e.childrenAccessor,hierarchySum:e.hierarchySum,orientation:e.orientation,nodeAlign:e.nodeAlign,nodePaddingRatio:e.nodePaddingRatio,nodeWidth:e.nodeWidth,iterations:e.iterations,forceStrength:e.forceStrength,padAngle:e.padAngle,groupWidth:e.groupWidth,sortGroups:e.sortGroups,edgeSort:e.edgeSort,treeOrientation:e.treeOrientation,edgeType:e.edgeType,padding:e.padding,paddingTop:e.paddingTop,nodeStyle:e.nodeStyle,edgeStyle:e.edgeStyle,nodeLabel:e.nodeLabel,showLabels:e.showLabels,labelMode:e.labelMode,colorBy:e.colorBy,colorScheme:e.colorScheme||o.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig};let g,p;if(Wr.has(i)){const i=e.data||e.edges;if(!i||Array.isArray(i))return t&&(t.evidence=r()),Er.renderToStaticMarkup(er(null,{width:s[0],height:s[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${n.left},${n.top})`,innerWidth:l,innerHeight:u,idPrefix:e._idPrefix}));d.__hierarchyRoot=i,g=[],p=[]}else{const i=be(e.nodes||[]),a=Array.isArray(e.edges)?be(e.edges):[];if(0===i.length&&0===a.length)return t&&(t.evidence=r()),Er.renderToStaticMarkup(er(null,{width:s[0],height:s[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${n.left},${n.top})`,innerWidth:l,innerHeight:u,idPrefix:e._idPrefix}));if(p=function(e,t){const o=Nr(t.sourceAccessor,"source"),i=Nr(t.targetAccessor,"target"),r=Nr(t.valueAccessor,"value");return e.map(e=>({source:o(e)+"",target:i(e)+"",value:Number(r(e))||1,y0:0,y1:0,sankeyWidth:0,data:e}))}(a,d),0===i.length&&p.length>0){const e=new Set;for(const t of p){const o=Hi(t.source),i=Hi(t.target);o&&e.add(o),i&&e.add(i)}g=Array.from(e).map(e=>({id:e,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:e}}))}else g=function(e,t){const o=Nr(t.nodeIDAccessor,"id");return e.map(e=>({id:o(e)+"",x:e.x??0,y:e.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:e}))}(i,d)}let f=[],y=[],m=[],b=null;if(d.customNetworkLayout){const e=d.colorScheme,t=Ne(e,o.colors.categorical,bt),i=ge(t,e),r={nodes:g,edges:p,dimensions:{width:l,height:u,plot:{x:0,y:0,width:l,height:u}},theme:{semantic:o.colors,categorical:[...t]},resolveColor:i,config:d.layoutConfig??{}},s=d.customNetworkLayout(r);f=s.sceneNodes??[],y=s.sceneEdges??[],m=s.labels??[],b=s.overlays??null}else if(h){h.computeLayout(g,p,d,[l,u]);const e=h.buildScene(g,p,d,[l,u]);f=e.sceneNodes,y=e.sceneEdges,m=e.labels}const x=ro(o);for(const e of m)e.fill||(e.fill=x.text);const v=q({nodes:y,renderMode:e.renderMode,fallback:(e,t)=>Re(e,t)}),A=q({nodes:f,renderMode:e.renderMode,fallback:(e,t)=>Ce(e,t)});t&&(t.evidence=bi({frameType:"network",width:s[0],height:s[1],marks:[...A.map(({node:e})=>({type:"node:"+(e.type??"node")})),...v.map(({node:e})=>({type:"edge:"+(e.type??"edge")}))],title:e.title,description:e.description,annotations:e.annotations,nodeCount:A.length,edgeCount:v.length}));const S=v.map(e=>e.element),w=A.map(e=>e.element),k=m.map((e,t)=>Le(e,t)).filter(Boolean),_=e.annotations?Wi({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{},layout:{width:l,height:u},theme:o,idPrefix:e._idPrefix}):null,M=Ui({props:e,categories:c,theme:o,size:s,margin:n,hasTitle:a});return Er.renderToStaticMarkup(er(jr(Dr,{children:[e.backgroundGraphics,S,w,k,_,e.foregroundGraphics,b]}),{width:s[0],height:s[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${n.left},${n.top})`,innerWidth:l,innerHeight:u,legend:M,idPrefix:e._idPrefix}))}import*as $r from"react-dom/server";import{geoPath as Gr}from"d3-geo";import{quadtree as Yr}from"d3-quadtree";import{geoMercator as Hr,geoEqualEarth as Vr,geoAlbersUsa as Xr,geoOrthographic as qr,geoNaturalEarth1 as Qr,geoEquirectangular as Kr}from"d3-geo";var Zr={mercator:Hr,equalEarth:Vr,albersUsa:Xr,orthographic:qr,naturalEarth:Qr,equirectangular:Kr};function Ur(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function Jr(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function es(e,t,o){return e?"function"==typeof e?{...o,...e(t)}:{...o,...e}:{...o}}function ts(e,t){if(2>e.length)return[e];const o=.4*t,i=[];let r=[e[0]];for(let t=1;e.length>t;t++){const s=e[t];Math.abs(s[0]-e[t-1][0])>o?(2>r.length||i.push(r),r=[s]):r.push(s)}return 2>r.length||i.push(r),i}function os(e,t,o=24){const i=t[0]-e[0],r=t[1]-e[1],s=Math.sqrt(i*i+r*r);if(0===s)return[e,t];const n=-r/s,a=i/s,c=Math.min(.3*s,80),l=(e[0]+t[0])/2+n*c,u=(e[1]+t[1])/2+a*c,h=[];for(let i=0;o>=i;i++){const r=i/o,s=1-r;h.push([s*s*e[0]+2*s*r*l+r*r*t[0],s*s*e[1]+2*s*r*u+r*r*t[1]])}return h}function is(e,t){if(2>e.length)return e;const o=t/2+1,i=[];for(let t=0;e.length>t;t++){const r=e[t];let s,n;0===t?(s=e[1][0]-r[0],n=e[1][1]-r[1]):t===e.length-1?(s=r[0]-e[t-1][0],n=r[1]-e[t-1][1]):(s=e[t+1][0]-e[t-1][0],n=e[t+1][1]-e[t-1][1]);const a=Math.sqrt(s*s+n*n)||1;i.push([r[0]+n/a*o,r[1]+-s/a*o])}return i}function rs(e,t,o,i,r){const s=t[0]-e[0],n=t[1]-e[1],a=Math.sqrt(s*s+n*n);if(0===a)return[e,t];const c=n/a,l=-s/a,u=r/2+1;return[[e[0]+c*u,e[1]+l*u],[t[0]+c*u,t[1]+l*u]]}import{scaleLinear as ss}from"d3-scale";var ns=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],as=["scene-style","data-paint","accessibility","evidence"],cs=(e,t)=>({retainedData:e,invalidations:t}),ls=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],us=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],hs=["scene-geometry","data-paint","accessibility","evidence"],ds=["scene-style","data-paint","accessibility","evidence"],gs=["overlay","accessibility","evidence"],ps=[],fs={xAccessor:cs("rebuild",ls),yAccessor:cs("rebuild",ls),lineDataAccessor:cs("rebuild",ls),pointIdAccessor:cs("rebuild",hs),lineIdAccessor:cs("rebuild",hs),windowSize:cs("rebuild",ls),projection:cs("preserve",us),projectionExtent:cs("preserve",us),fitPadding:cs("preserve",us),lineType:cs("preserve",us),flowStyle:cs("preserve",us),graticule:cs("preserve",us),projectionTransform:cs("preserve",us),customLayout:cs("preserve",us),layoutConfig:cs("preserve",us),layoutMargin:cs("preserve",us),areaStyle:cs("preserve",ds),pointStyle:cs("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:cs("preserve",ds),colorScheme:cs("preserve",ds),themeCategorical:cs("preserve",ds),themeDiverging:cs("preserve",ds),themeSemantic:cs("preserve",ds),themeSequential:cs("preserve",ds),decay:cs("preserve",ds),pulse:cs("preserve",ds),layoutSelection:cs("preserve",ds),annotations:cs("preserve",gs),autoPlaceAnnotations:cs("preserve",gs),clock:cs("preserve",ps),transition:cs("preserve",ps),introAnimation:cs("preserve",ps),onLayoutError:cs("preserve",ps)},ys=cs("preserve",us),ms=class{constructor(){this.tracker=new at}get last(){return this.tracker.last}subscribe(e){return this.tracker.subscribe(e)}recordData(e,t){return this.tracker.record({kind:e,...void 0===t?{}:{count:t}},ns)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},as):this.recordNoop("restyle")}recordConfig(e,t={}){const o=function(e){let t="preserve";const o=new Set;for(const i of e){const e=fs[i]??ys;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)o.add(t)}return{retainedData:t,invalidations:o}}(e),i=new Set(o.invalidations);return t.retainedDataChanged&&i.add("data"),this.tracker.record({kind:"config",keys:e},i)}};import{geoDistance as bs,geoGraticule as xs,geoInterpolate as vs}from"d3-geo";function As(e){if(null==e)return 0;if("number"==typeof e&&Number.isFinite(e)&&e>=0&&.5>e)return e;throw new RangeError(`[semiotic] fitPadding must be a finite fraction in [0, 0.5); received ${e+""}.`)}var Ss=class e{constructor(e){this.updateResults=new ms,this.scene=[],this.scales=null,this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this._quadtree=null,this._maxPointRadius=0,this.projection=null,this.geoPath=null,this.baseScale=0,this.baseTranslate=[0,0],this.baseRotation=[0,0,0],this.currentZoom=1,this.cartogramLayout=null,this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.streaming=!1,this.lastIngestTime=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositions=null,this._hasRenderedOnce=!1,this.config=function(e){return{...e,fitPadding:As(e.fitPadding)}}(e)}currentTime(){return this.config.clock?.()??ze()}getConfiguredWindowSize(){const e=this.config.windowSize??500;if(!Number.isInteger(e)||1>e)throw Error("GeoPipelineStore windowSize must be a positive integer");return e}retainNewestLines(e=this.getConfiguredWindowSize()){this.lineData.length>e&&(this.lineData=this.lineData.slice(-e))}resizeStreamingWindow(e){if(this.pointBuffer){const t=this.pointBuffer.toArray(),o=this.timestampBuffer?.toArray()??[],i=t.slice(-e),r=o.slice(-i.length),s=this.currentTime();this.pointBuffer=new oe(e),this.timestampBuffer=new oe(e),i.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(r[t]??s)})}this.retainNewestLines(e)}updateConfig(e){const t=function(e){return"fitPadding"in e?{...e,fitPadding:As(e.fitPadding)}:e}(e),o=this.config,i=this.getConfiguredWindowSize(),r=Object.keys(t).filter(e=>t[e]!==o[e]);this.config={...this.config,...t};const s=this.getConfiguredWindowSize(),n=this.streaming&&s!==i;n&&(this.resizeStreamingWindow(s),this.version++),"customLayout"in t&&!t.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(r,{retainedDataChanged:n})}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setAreas(e){this.areas=e,this.updateResults.recordData("replace",e.length)}setAreasWithResult(e){return this.setAreas(e),this.updateResults.last}setPoints(e){this.pointData=e.slice(),this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.updateResults.recordData("replace",e.length)}setPointsWithResult(e){return this.setPoints(e),this.updateResults.last}setLines(e){this.lineData=e.slice(),this.streaming&&this.retainNewestLines(),this.updateResults.recordData("replace",e.length)}setLinesWithResult(e){return this.setLines(e),this.updateResults.last}initStreaming(e){void 0!==e&&e!==this.config.windowSize&&(this.config={...this.config,windowSize:e});const t=this.getConfiguredWindowSize(),o=this.pointBuffer?this.pointBuffer.toArray():this.pointData,i=this.timestampBuffer?.toArray()??[],r=o.slice(-t),s=i.slice(-r.length),n=this.currentTime();this.pointBuffer=new oe(t),this.timestampBuffer=new oe(t),r.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(s[t]??n)}),this.pointData=[],this.retainNewestLines(t),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();const t=this.currentTime();X(this.pointBuffer,e,this.timestampBuffer,t),this.lastIngestTime=t,this.updateResults.recordData("ingest",1)}pushPointWithResult(e){return this.pushPoint(e),this.updateResults.last}pushMany(e){this.pointBuffer||this.initStreaming();const t=this.currentTime();for(const o of e)X(this.pointBuffer,o,this.timestampBuffer,t);this.lastIngestTime=t,this.updateResults.recordData("ingest",e.length)}pushManyWithResult(e){return this.pushMany(e),this.updateResults.last}pushLine(e){null!=e&&"object"==typeof e?(this.streaming||this.initStreaming(),this.lineData.push(e),this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",1)):this.updateResults.recordNoop("ingest")}pushManyLines(e){if(!Array.isArray(e)||0===e.length)return void this.updateResults.recordNoop("ingest");const t=e.filter(e=>null!=e&&"object"==typeof e);if(0!==t.length){this.streaming||this.initStreaming();for(const e of t)this.lineData.push(e);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",t.length)}else this.updateResults.recordNoop("ingest")}removeLine(e){const{lineIdAccessor:t}=this.config;if(!t)throw Error("removeLine() requires lineIdAccessor to be configured");const o="function"==typeof t?t:e=>e[t],i=new Set(Array.isArray(e)?e:[e]),r=[];return this.lineData=this.lineData.filter(e=>!i.has(o(e)+"")||(r.push(e),!1)),r.length>0?(this.version++,this.updateResults.recordData("remove",r.length)):this.updateResults.recordNoop("remove"),r}getLines(){return this.lineData.slice()}removePoint(e){const{pointIdAccessor:t}=this.config;if(!t)throw Error("removePoint() requires pointIdAccessor to be configured");const o="function"==typeof t?t:e=>e[t],i=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){const e=e=>i.has(o(e)+"");N(this.pointBuffer,this.timestampBuffer,e);const t=this.pointBuffer.remove(e);return t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}{const e=[];return this.pointData=this.pointData.filter(t=>!i.has(o(t)+"")||(e.push(t),!1)),e.length>0?(this.version++,this.updateResults.recordData("remove",e.length)):this.updateResults.recordNoop("remove"),e}}clear(){this.areas=[],this.pointData=[],this.lineData=[],this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.scene=[],this.scales=null,this._hasRenderedOnce=!1,this.activeTransition=null,this.prevPositions=null,this._quadtree=null,this._maxPointRadius=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this._customLayoutFailedThisBuild=!1,this.version++,this.updateResults.recordData("clear")}restyleScene(e){const t=this._customRestyle;if(t){for(const o of this.scene){const i=this._baseStyles.get(o)??o.style,r=t(o,e);o.style=r?{...i,...r}:i}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(e){const{config:t}=this,o=this.projection,i=this.geoPath,r=this.scales,s=this.baseScale,n=[...this.baseTranslate],a=[...this.baseRotation],c=this.scene;this.projection=function(e){if(!e)return Vr();if("string"==typeof e){const t=Zr[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),Vr())}if("object"==typeof e&&"type"in e){const t=Zr[e.type],o=t?t():Vr();return e.rotate&&"rotate"in o&&o.rotate(e.rotate),e.center&&"center"in o&&o.center(e.center),o}return e}(t.projection),this.geoPath=Gr(this.projection),this.fitProjection(e),this.geoPath=Gr(this.projection);const l=this.projection;this.scales={projection:l,geoPath:this.geoPath,projectedPoint:(e,t)=>l([e,t]),invertedPoint:(e,t)=>l.invert?l.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const u=this.buildSceneNodes(e);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=o,this.geoPath=i,this.scales=r,this.baseScale=s,this.baseTranslate=n,this.baseRotation=a):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=u,this.rebuildQuadtree(),t.projectionTransform&&this.applyCartogramTransform(t.projectionTransform,e),t.decay&&this.streaming&&this.applyDecay(),t.pulse&&this.streaming&&this.applyPulse(),t.transition&&!this._hasRenderedOnce&&this.scene.length>0&&t.introAnimation){const t=e.width/2,o=e.height/2,i=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:o}));i.length>0&&this.startTransition(i)}this._hasRenderedOnce=!0,t.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(e){const t=this.projection,o=this.config,i=[...this.areas],r=Ur(o.xAccessor,"lon"),s=Ur(o.yAccessor,"lat"),n=this.getPoints();if(n.length>0){const e=n.map(e=>[r(e),s(e)]);i.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const a=Jr(o.lineDataAccessor);for(const e of this.lineData){const t=a(e);if(t&&t.length>0){const e=t.map(e=>[r(e),s(e)]);i.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==i.length){if(o.projectionExtent){const[[i,r],[s,n]]=o.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[i,r],[i,n],[s,n],[s,r],[i,r]]]}})}else if(t.clipAngle&&(t.clipAngle()??0)>0){const i=o.fitPadding??0,r=Math.min(e.width,e.height);t.scale(r/2-r*i),t.translate([e.width/2,e.height/2])}else{const r=o.fitPadding??0,s=e.width*r,n=e.height*r;t.fitExtent([[s,n],[e.width-s,e.height-n]],{type:"FeatureCollection",features:i})}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){const o=this.projection;if(!o)return;const i=this.geoPath,r=this.scales,s=o.scale(),n=[...o.translate()],a=this.currentZoom;o.scale(this.baseScale*e.k),o.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=Gr(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.scale(s),o.translate(n),this.currentZoom=a,this.geoPath=i,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){const o=this.projection;if(!o)return;const i=this.geoPath,r=this.scales,s=o.scale(),n=[...o.translate()],a=this.currentZoom;o.scale(this.baseScale*e),o.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=Gr(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.scale(s),o.translate(n),this.currentZoom=a,this.geoPath=i,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=c,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyRotation(e,t){const o=this.projection;if(!o||!o.rotate)return;const i=this.geoPath,r=this.scales,s=[...o.rotate()];o.rotate(e),this.geoPath=Gr(o),this.scales={projection:o,geoPath:this.geoPath,projectedPoint:(e,t)=>o([e,t]),invertedPoint:(e,t)=>o.invert?o.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const n=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(o.rotate(s),this.geoPath=i,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=n,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){const t=this.projection;t&&t.rotate&&t.rotate(e)}hasProjection(){return null!=this.projection}getRotation(){return this.projection?.rotate?.()??this.baseRotation}getBaseProjectionState(){return{scale:this.baseScale,translate:[...this.baseTranslate]}}getPoints(){return this.streaming&&this.pointBuffer?this.pointBuffer.toArray():this.pointData}rebuildQuadtree(){let t=0,o=0;for(const e of this.scene)"point"===e.type&&(o++,e.r>t&&(t=e.r));if(this._maxPointRadius=t,e.QUADTREE_THRESHOLD>=o)return void(this._quadtree=null);const i=Array(o);let r=0;for(const e of this.scene)"point"===e.type&&(i[r++]=e);this._quadtree=Yr().x(e=>e.x).y(e=>e.y).addAll(i)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){this._customLayoutFailedThisBuild=!1;const{config:t}=this,o=this.projection,i=this.geoPath;if(t.customLayout&&this.scales){const o=t.layoutMargin??{top:0,right:0,bottom:0,left:0},i=Ne(t.colorScheme,t.themeCategorical,ce),r={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:o,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...i]},resolveColor:ge(i,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null};let s;try{s=t.customLayout(r)}catch(e){const o=null!==this.lastCustomLayoutResult,i=$("geo",e,o,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",e);try{t.onLayoutError?.(i)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return o?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}const n=s.nodes??[];if(this.customLayoutOverlays=s.overlays??null,this.lastCustomLayoutResult=s,this.lastCustomLayoutFailure=null,this._customRestyle=s.restyle,this.hasCustomRestyle=!!s.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(const e of n)this._baseStyles.set(e,e.style);this.restyleScene(t.layoutSelection??null)}return ee({label:"geo customLayout",nodes:n,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),n}return this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,function({config:e,projection:t,path:o,areas:i,points:r,lines:s,layout:n}){const a=Ur(e.xAccessor,"lon"),c=Ur(e.yAccessor,"lat"),l=[],u=function(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(e),h=function(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(e),d=function(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(e);if(e.graticule){const t=!0===e.graticule?{}:e.graticule,i=xs();t.step&&i.step(t.step);const r=o(i())||"";r&&l.push({type:"geoarea",pathData:r,centroid:[n.width/2,n.height/2],bounds:[[0,0],[n.width,n.height]],screenArea:0,style:{fill:"none",stroke:t.stroke||"#e0e0e0",strokeWidth:t.strokeWidth||.5,strokeDasharray:t.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const t of i){const i=o(t);if(!i)continue;const r=o.centroid(t),s=o.bounds(t),n=o.area(t);l.push({type:"geoarea",pathData:i,centroid:r,bounds:s,screenArea:n,style:es(e.areaStyle,t,u),datum:t,interactive:!0})}const g=Jr(e.lineDataAccessor);for(const o of s){const i=g(o);if(!i||2>i.length)continue;let r=[];if("geo"===e.lineType){const e=Array(i.length);for(let t=0;i.length>t;t++)e[t]=[a(i[t]),c(i[t])];for(let o=0;e.length-1>o;o++){const i=e[o],s=e[o+1],n=bs(i,s)||0,a=Math.max(2,Math.ceil(n/(Math.PI/180))),c=vs(i,s);for(let e=0;a>=e;e++){if(o>0&&0===e)continue;const i=t(c(e/a));null!=i&&r.push(i)}}}else for(let e=0;i.length>e;e++){const o=i[e],s=t([a(o),c(o)]);null!=s&&r.push(s)}if(2>r.length)continue;const s=es(e.lineStyle,o,h),u="number"==typeof s.strokeWidth?s.strokeWidth:1;2!==i.length||2>r.length||"arc"!==e.flowStyle?2!==i.length||2>r.length||"offset"!==e.flowStyle||(r="geo"===e.lineType?is(r,u):rs(r[0],r[r.length-1],0,0,u)):r=os(r[0],r[r.length-1]);const d=ts(r,n.width);if(d.length>1)for(const e of d)2>e.length||l.push({type:"line",path:e,style:{...s,_edgeFade:!0},datum:o});else l.push({type:"line",path:2>r.length&&d[0]||r,style:s,datum:o})}const p=e.pointIdAccessor?"function"==typeof e.pointIdAccessor?e.pointIdAccessor:t=>t[e.pointIdAccessor]:null,f=t.clipAngle?t.clipAngle()??0:0,y=f>0?f*Math.PI/180:null,m=t.rotate?t.rotate():[0,0,0],b="function"==typeof t.center?t.center():[0,0],x=[(b[0]??0)-m[0],(b[1]??0)-m[1]];for(const o of r){const i=a(o),r=c(o);if(null!=y&&bs([i,r],x)>y)continue;const s=t([i,r]);if(!s)continue;const n=e.pointStyle?e.pointStyle(o):{...d},u={type:"point",x:s[0],y:s[1],r:n.r||4,style:n,datum:o,pointId:p?p(o)+"":void 0};l.push(u)}return l}({config:t,projection:o,path:i,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:e})}applyCartogramTransform(e,t){const o=function(e,t,o,i){const r=e.filter(e=>"point"===e.type);if(2>r.length)return null;const s=t.strength??1;if(0===s)return null;const n=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,a="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],c=r.find(e=>e.datum&&n(e.datum)+""==t.center+"");if(!c)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;const l=c.x,u=c.y,h=r.map(e=>e.datum?a(e.datum):NaN).filter(e=>isFinite(e)&&e>=0),d=xt(h,1),g=Math.min(o.width,o.height)/2,p=ss().domain([0,d]).range([0,g]);i>0&&"production"!==process.env.NODE_ENV&&console.warn("GeoFrame: Distance cartogram does not support area rendering. Areas will be ignored. Remove areas or set projectionTransform to null to render them.");for(let t=e.length-1;t>=0;t--){const o=e[t];"geoarea"===o.type&&o.interactive&&e.splice(t,1)}for(const e of r){if(e===c)continue;if(!e.datum)continue;const t=Math.atan2(e.y-u,e.x-l),o=Math.sqrt((e.x-l)**2+(e.y-u)**2),i=a(e.datum),r=o+((isFinite(i)?p(i):o)-o)*s;e.x=l+Math.cos(t)*r,e.y=u+Math.sin(t)*r}const f=o.width/2,y=o.height/2,m=f-c.x,b=y-c.y;if(Math.abs(m)>.5||Math.abs(b)>.5)for(const e of r)e.x+=m,e.y+=b;const x={cx:f,cy:y,maxCost:d,availableRadius:g},v=e.filter(e=>"line"===e.type);if(v.length>0&&"fractional"!==t.lineMode){const e=new Map;for(const t of r)t.pointId&&e.set(t.pointId,[t.x,t.y]);for(const t of v){const o=t.datum?.source,i=t.datum?.target;if(o&&i){const r=e.get(o+""),s=e.get(i+"");r&&s&&(t.path=[r,s])}}}return x}(this.scene,e,t,this.areas.length);o&&(this.cartogramLayout=o)}applyDecay(){const e=this.config.decay;if(!e||!this.pointBuffer)return;const t=this.pointBuffer.size;if(0===t)return;const o=this.scene.filter(e=>"point"===e.type);for(let i=0;o.length>i;i++){const r=W(e,i,t);o[i]._decayOpacity=r,o[i].style={...o[i].style,opacity:r}}}applyPulse(e=this.currentTime()){const t=this.config.pulse;if(!t||!this.timestampBuffer)return!1;const o=this.scene.filter(e=>"point"===e.type),i=this.timestampBuffer.toArray(),r=t.color||"rgba(255,255,255,0.6)",s=t.glowRadius??4;let n=!1;for(let a=0;o.length>a&&i.length>a;a++){const c=I(t,i[a],e);n=Z(o[a],c,r,s)||n}return n}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&V(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(e){const t=this.config.transition?.duration??300;if(0>=t)return;const o=new Map;for(const t of e)"point"===t.type&&t.pointId&&o.set(t.pointId,[t.x,t.y]);const i=this.scene.filter(e=>"point"===e.type);let r=!1;for(const e of i)if(e.pointId){const t=o.get(e.pointId);t&&(e._targetX=e.x,e._targetY=e.y,e.x=t[0],e.y=t[1],(Math.abs(t[0]-e._targetX)>.5||Math.abs(t[1]-e._targetY)>.5)&&(r=!0))}for(const e of i)e.pointId&&!o.has(e.pointId)&&(e._targetOpacity=e.style?.opacity??1,e.style={...e.style,opacity:0},r=!0);r&&(this.activeTransition={startTime:this.currentTime(),duration:t})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(e){if(!this.activeTransition)return!1;const t=ye(e,this.activeTransition),o=fe(t),i=this.scene.filter(e=>"point"===e.type);for(const e of i){if(null!=e._targetX&&null!=e._targetY){const t=e.y;e.x=Te(e.x,e._targetX,o),e.y=Te(t,e._targetY,o)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*o})}if(t>=1){for(const e of i)null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0),null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};Ss.QUADTREE_THRESHOLD=500;var ws=Ss;R(ws);import{Fragment as ks,jsxs as _s}from"react/jsx-runtime";function Ms(e,t){const o=io(e.theme),i=e.size||[e.width||600,e.height||400],r=Ee({top:10,right:10,bottom:10,left:10,...e.margin},e.title),s=we(e.title),n=Array.isArray(e.areas)?be(e.areas):e.areas,a=be(e.points),c=be(e.lines),l=e.showLegend?(()=>{const t="string"==typeof(o=e.colorBy)||"function"==typeof o?e.colorBy:void 0;var o;return zi(a.length>0?a:Array.isArray(n)&&n.length>0?"string"==typeof t?n.map(e=>({...e.properties||{},...e})):n:[],t)})():[];Zi(r,{props:e,categories:l,theme:o,size:i,hasTitle:s});const u=i[0]-(r.left??0)-(r.right??0),h=i[1]-(r.top??0)-(r.bottom??0),d={projection:e.projection||"equalEarth",xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineType:e.lineType,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform,customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:r,themeCategorical:o.colors.categorical,themeSemantic:Pt(o)},g=new ws(d);if(n){if("string"==typeof n)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${n}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${n}')\` before calling renderGeoToStaticSVG.`);g.setAreas(n)}e.points&&g.setPoints(a),e.lines&&g.setLines(c),g.computeScene({width:u,height:h});const p=q({nodes:g.scene,renderMode:e.renderMode,fallback:(e,t)=>xe(e,t)});if(t&&(t.evidence=bi({frameType:"geo",width:i[0],height:i[1],marks:p.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,legendItems:l.length>0?l.length:void 0})),0===p.length){const t=e.backgroundGraphics||e.foregroundGraphics||e.annotations||g.customLayoutOverlays?_s(ks,{children:[e.backgroundGraphics,e.annotations?Wi({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:g.scales?.projectedPoint?([e,t])=>g.scales.projectedPoint(e,t):void 0},layout:{width:u,height:h},theme:o,idPrefix:e._idPrefix}):null,e.foregroundGraphics,g.customLayoutOverlays]}):null;return $r.renderToStaticMarkup(er(t,{width:i[0],height:i[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${r.left??0},${r.top??0})`,innerWidth:u,innerHeight:h,idPrefix:e._idPrefix}))}const f=p.map(e=>e.element),y=e.annotations?Wi({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:g.scales?.projectedPoint?([e,t])=>g.scales.projectedPoint(e,t):void 0},layout:{width:u,height:h},theme:o,idPrefix:e._idPrefix}):null,m=Ui({props:e,categories:l,theme:o,size:i,margin:r,hasTitle:s});return $r.renderToStaticMarkup(er(_s(ks,{children:[e.backgroundGraphics,f,y,e.foregroundGraphics,g.customLayoutOverlays]}),{width:i[0],height:i[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:o,innerTransform:`translate(${r.left??0},${r.top??0})`,innerWidth:u,innerHeight:h,legend:m,idPrefix:e._idPrefix}))}function Ps(e,t){const o=e.size??[e.width??600,e.height??400],i=new S(e.config);Array.isArray(e.initialSpawns)&&e.initialSpawns.length>0&&i.enqueue(e.initialSpawns.map(e=>({...e,spawnAt:void 0})));const r=h(i,{...e,width:o[0],height:o[1],idPrefix:e.idPrefix??e._idPrefix??"physics"});return t&&(t.evidence=bi({frameType:"physics",width:o[0],height:o[1],marks:r.scene.sceneNodes,title:e.title,description:e.description,annotations:[],extraWarnings:0===r.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[]})),r.svg}import{Fragment as Ts,jsx as Ls,jsxs as Rs}from"react/jsx-runtime";function Cs(e,t){switch(e){case"xy":return rr(t);case"ordinal":return Or(t);case"network":return Ir(t);case"geo":return Ms(t);case"physics":return Ps(t);default:throw Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function zs(e){return rr(e)}function Fs(e){return Or(e)}function Bs(e){return Ir(e)}function Os(e){return Ms(e)}var Es=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","scalePadding","sizeRange","innerRadius","centerContent","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","barColors","legend","legendLayout","autoPlaceAnnotations"],Ds=["width","height","showAxes","showGrid","enableHover","showLegend","showLabels","showCategoryTicks","orientation","title","description","summary","accessibleTable","xLabel","yLabel","categoryLabel","valueLabel","linkedHover","mobileInteraction","mobileSemantics","responsiveRules"];function js(e,t){const o={};for(const i of t)void 0!==e[i]&&(o[i]=e[i]);return o}function Ns(e,t,o){return Is(e,t).svg}function Ws(e,t,o){const i={},{svg:r,frameType:s}=Is(e,t,0,i),n=i.evidence??bi({frameType:s,width:"number"==typeof t.width?t.width:600,height:"number"==typeof t.height?t.height:400,marks:[],title:"string"==typeof t.title?t.title:void 0,description:"string"==typeof t.description?t.description:void 0,annotations:t.annotations,extraWarnings:["NO_EVIDENCE"]});return n.component=e,{svg:r,evidence:n}}function Is(e,t,o,i){const r=fi[e];if(!r)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);const s=r.layout?.mode??(ke(t.mode)?t.mode:void 0),n=je(s,{...r.layout?.modeDefaults,...js(t,Ds)},r.layout?.primarySize),{data:a,theme:c,background:l,className:u,annotations:h,margin:d,colorScheme:g,colorBy:p,legendPosition:f,...y}=t,{width:m,height:b}=n,x=[m,b],v=y.frameProps||{},A=r.layout?.margin,S="function"==typeof A?A(t,n):A??n.marginDefaults,w=void 0!==d?d:v.margin,k=function(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}(w),_="number"==typeof w?{top:w,right:w,bottom:w,left:w}:{...S,...k},M=js(y,Es),P={...v,...M,theme:c,title:n.title,description:n.description,showAxes:n.showAxes,showLegend:n.showLegend,showLabels:n.showLabels,showGrid:n.showGrid,xLabel:n.xLabel,yLabel:n.yLabel,categoryLabel:n.categoryLabel,valueLabel:n.valueLabel,background:l,className:u,annotations:h,size:x,margin:_,__explicitMargin:w,__autoLegendMargin:!0,...void 0!==g&&{colorScheme:g},...void 0!==f&&{legendPosition:f},_idPrefix:y._idPrefix},T=r.buildProps(a,p,g,P,y);let L;switch(r.frameType){case"xy":L=rr(T,i);break;case"ordinal":L=Or(T,i);break;case"network":L=Ir(T,i);break;case"geo":L=Ms(T,i);break;case"physics":L=Ps(T,i)}const R=r.renderOverlay?.(T,{theme:io(c)});if(null!=R){const e=Lt.renderToStaticMarkup(Ls(Ts,{children:R}));L=L.replace("</svg>",e+"</svg>")}return{svg:L,frameType:r.frameType}}function $s(e,t={}){const{title:o,subtitle:i,theme:r,width:s=1200,height:n,layout:a={},background:c}=t,l=ro(io(r)),u=a.columns||2,h=a.gap??16;let d=0;o&&(d+=30),i&&(d+=20),d>0&&(d+=10);const g=Math.floor((s-h-h*(u-1))/u),p=[];let f=0,y=d+h,m=0;for(const t of e){const e=Math.min(t.colSpan||1,u),o=t.props.height||300;f+e>u&&(y+=m+h,f=0,m=0),p.push({chart:t,x:h/2+f*(g+h),y:y,w:g*e+h*(e-1),h:o}),m=Math.max(m,o),f+=e}const b=n||y+m+h,x=p.map((e,t)=>{const{chart:o,x:i,y:s,w:n,h:a}=e,c={...o.props,width:n,height:a,theme:r,_idPrefix:"chart-"+t};let l;return l=o.component?Ns(o.component,c):o.frameType?Cs(o.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${a}"></svg>`,Ls("g",{transform:`translate(${i},${s})`,children:Ls("foreignObject",{width:n,height:a,children:Ls("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:l}})})},"dashboard-chart-"+t)});return Lt.renderToStaticMarkup(Rs("svg",{xmlns:"http://www.w3.org/2000/svg",width:s,height:b,role:"img","aria-label":o||"Dashboard",style:{fontFamily:l.fontFamily},children:[o&&Ls("title",{children:o}),c&&Ls("rect",{x:0,y:0,width:s,height:b,fill:c}),o&&Ls("text",{x:s/2,y:24,textAnchor:"middle",fontSize:l.titleSize+4,fontWeight:"bold",fill:l.text,fontFamily:l.fontFamily,children:o}),i&&Ls("text",{x:s/2,y:o?46:20,textAnchor:"middle",fontSize:l.labelSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:i}),x]}))}import*as Gs from"react-dom/server";import{Fragment as Ys,jsx as Hs,jsxs as Vs}from"react/jsx-runtime";function Xs(e,t,o,i={}){const{stepSize:r,windowSize:s,frameCount:n,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:h="ease-out",decay:d}=i,g=o.width||600,p=o.height||400,f=io(o.theme),y={...o,...a&&{xExtent:a},...c&&{yExtent:c}};if(!t||0===t.length)return[];const m=r||Math.max(1,Math.ceil(t.length/(n||Math.min(60,Math.max(10,t.length))))),b=[];for(let e=m;t.length>=e;e+=m)b.push(e);b[b.length-1]!==t.length&&b.push(t.length);const x=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(e),v=Ee({top:20,right:20,bottom:30,left:40,...o.margin},o.title),A=g-v.left-v.right,S=p-v.top-v.bottom,w=[];if(x)for(let i=0;b.length>i;i++){const r=b[i],n=t.slice(s?Math.max(0,r-s):0,r),a={chartType:e,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:o.projection||"vertical",oAccessor:o.oAccessor||o.categoryAccessor||"category",rAccessor:o.rAccessor||o.valueAccessor||"value",colorAccessor:o.colorAccessor||o.colorBy,stackBy:o.stackBy,groupBy:o.groupBy,barPadding:o.barPadding,innerRadius:o.innerRadius,normalize:o.normalize,bins:o.bins,colorScheme:o.colorScheme||f.colors.categorical,...d&&{decay:d}},c=new Lr(a);c.ingest({inserts:n,bounded:!0}),c.computeScene({width:A,height:S}),c.scene.length>0&&w.push(Js(c.scene,g,p,f,y))}else for(let i=0;b.length>i;i++){const r=b[i],n=t.slice(s?Math.max(0,r-s):0,r),m={chartType:e,windowSize:n.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:o.colorAccessor||o.colorBy,groupAccessor:o.groupAccessor||o.lineBy,lineDataAccessor:o.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:o.colorScheme||f.colors.categorical,lineStyle:o.lineStyle,pointStyle:o.pointStyle,areaStyle:o.areaStyle,sizeAccessor:o.sizeAccessor||o.sizeBy,sizeRange:o.sizeRange,...d&&{decay:d},...l>0&&{transition:{duration:l*(1e3/u),easing:h}}},x=new P(m);if(x.ingest({inserts:n,bounded:!0}),x.computeScene({width:A,height:S}),0===x.scene.length)continue;const v=x.scales?{y:x.scales.y}:void 0;if(w.push(Us(x.scene,g,p,f,y,v)),l>0&&i>0&&x.activeTransition){const e=l*(1e3/u);for(let t=1;l>=t;t++)x.advanceTransition(x.activeTransition.startTime+t/l*e),w.push(Us(x.scene,g,p,f,y,v))}}return w}function qs(e,t,o={}){return t.map(t=>{try{return Ns(e,{...o,...t})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${o.width||t.width||600}" height="${o.height||t.height||400}"></svg>`}})}function Qs(e,t,o){const i=t.size??[t.width??600,t.height??400],r=io(t.theme),s=ro(r),n=t.background||r.colors.background,a=t.idPrefix??"physics-gif",c=t.title?`${a}-title-${o}`:void 0,l=t.description?`${a}-desc-${o}`:void 0,h=[c,l].filter(Boolean).join(" ")||void 0,d=u(e.readBodies(),{bodyStyle:t.bodyStyle,getBodyLabel:t.getBodyLabel}),g=Vs("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className??"stream-physics-frame",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,role:"img","aria-labelledby":h,style:{fontFamily:s.fontFamily},children:[t.title&&Hs("title",{id:c,children:t.title}),t.description&&Hs("desc",{id:l,children:t.description}),n&&"transparent"!==n?Hs("rect",{x:0,y:0,width:i[0],height:i[1],fill:n}):null,Hs("g",{id:`${a}-frame-${o}`,children:d.map((e,t)=>Je(e,t,`${a}-${o}`))})]});return Gs.renderToStaticMarkup(g)}function Ks(e,t={}){const{fps:o=12,frameCount:i,durationSeconds:r=2,includeInitialFrame:s=!0,stepDt:n,stepsPerFrame:a,background:c}=t,l=Math.max(.001,n??e.config?.fixedDt??1/120),u=a??Math.max(1,Math.round(1/Math.max(1,o)/l)),h=i??Math.max(1,Math.ceil(r*Math.max(1,o))),d=c?{...e,background:c}:e,g=new S(e.config);e.initialSpawns?.length&&g.enqueue(e.initialSpawns,e.initialSpawnPacing);const p=[];for(s&&(g.tick(0),p.push(Qs(g,d,0)));h>p.length;){for(let e=0;u>e;e+=1)g.tick(l);p.push(Qs(g,d,p.length))}return p}function Zs(e,t){const o=e.background||t.colors.background;return o&&"transparent"!==o?o:null}function Us(e,t,o,i,r,s){const n=ro(i),a=Ee({top:20,right:20,bottom:30,left:40,...r.margin},r.title),c=t-a.left-a.right,l=o-a.top-a.bottom,u=Zs(r,i),h=r.renderMode,d=e.map((e,t)=>Q({node:e,index:t,renderMode:h,fallback:()=>Je(e,t)})).filter(Boolean),g=function(e,t,o,i,r,s){if(!e||0===e.length)return null;const n=ro(i),a=[];for(let i=0;e.length>i;i++){const c=e[i];if("y-threshold"===c.type&&null!=c.value){let e=null;if(s)e=s(c.value);else if(r){const[t,i]=r,s=i-t;if(0===s)continue;e=o-(c.value-t)/s*o}if(null==e)continue;const l=c.color||n.primary,u=c.labelPosition||"right";a.push(Vs("g",{children:[Hs("line",{x1:0,y1:e,x2:t,y2:e,stroke:l,strokeWidth:c.strokeWidth??1.5,strokeDasharray:c.strokeDasharray||"6,4"}),c.label&&Hs("text",{x:"left"===u?4:"center"===u?t/2:t-4,y:20>e?Math.min(o-4,e+16):e-5,textAnchor:"left"===u?"start":"center"===u?"middle":"end",fontSize:n.tickSize,fill:l,fontFamily:n.fontFamily,children:c.label})]},"ann-"+i))}}return a.length>0?Hs(Ys,{children:a}):null}(r.annotations,c,l,i,r.yExtent,s?.y),p="string"==typeof r.title?r.title:void 0,f="string"==typeof r.description?r.description:void 0,y=p?"semiotic-title":void 0,m=f?"semiotic-desc":void 0,b=[y,m].filter(Boolean).join(" ")||void 0;return Gs.renderToStaticMarkup(Vs("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:o,role:"img","aria-labelledby":b,style:{fontFamily:n.fontFamily},children:[p&&Hs("title",{id:y,children:p}),f&&Hs("desc",{id:m,children:f}),u&&Hs("rect",{x:0,y:0,width:t,height:o,fill:u}),Vs("g",{transform:`translate(${a.left},${a.top})`,children:[g,d]}),p&&Hs("text",{x:t/2,y:he,textAnchor:"middle",fontSize:n.titleSize,fontWeight:"bold",fill:n.text,fontFamily:n.fontFamily,children:p})]}))}function Js(e,t,o,i,r){const s=ro(i),n=Ee({top:20,right:20,bottom:30,left:40,...r.margin},r.title),a="radial"===r.projection,c=a?n.left+(t-n.left-n.right)/2:n.left,l=a?n.top+(o-n.top-n.bottom)/2:n.top,u=Zs(r,i),h=r.renderMode,d=e.map((e,t)=>Q({node:e,index:t,renderMode:h,fallback:()=>Fe(e,t)})).filter(Boolean),g="string"==typeof r.title?r.title:void 0,p="string"==typeof r.description?r.description:void 0,f=g?"semiotic-title":void 0,y=p?"semiotic-desc":void 0,m=[f,y].filter(Boolean).join(" ")||void 0;return Gs.renderToStaticMarkup(Vs("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:o,role:"img","aria-labelledby":m,style:{fontFamily:s.fontFamily},children:[g&&Hs("title",{id:f,children:g}),p&&Hs("desc",{id:y,children:p}),u&&Hs("rect",{x:0,y:0,width:t,height:o,fill:u}),Hs("g",{transform:`translate(${c},${l})`,children:d}),g&&Hs("text",{x:t/2,y:he,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:g})]}))}export{Xs as generateFrameSVGs,qs as generateFrameSequence,Ks as generatePhysicsFrameSVGs,Ns as renderChart,Ws as renderChartWithEvidence,$s as renderDashboard,Os as renderGeoToStaticSVG,Bs as renderNetworkToStaticSVG,Fs as renderOrdinalToStaticSVG,Cs as renderToStaticSVG,zs as renderXYToStaticSVG,io as resolveTheme,ro as themeStyles};
|