semiotic 3.8.6 → 3.8.7
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 +33 -7
- package/README.md +82 -55
- package/ai/behaviorContracts.cjs +86 -1
- package/ai/componentMetadata.cjs +4 -9
- package/ai/dist/mcp-server.js +97 -10
- package/ai/examples.md +154 -7
- package/ai/schema.json +1611 -145
- package/ai/surface-manifest.json +12 -10
- package/ai/system-prompt.md +9 -3
- package/dist/{chunk-chartContainerDataAudit-FEOD5GTQ.module.min.js → chunk-chartContainerDataAudit-JDSVSKGM.module.min.js} +1 -1
- package/dist/chunk-chunk-2YAZHXL4.module.min.js +2 -0
- package/dist/{chunk-chunk-G7WFWHAD.module.min.js → chunk-chunk-4ITOQRXM.module.min.js} +1 -1
- package/dist/chunk-chunk-5SD6BHVW.module.min.js +2 -0
- package/dist/chunk-chunk-6V5VQVCT.module.min.js +2 -0
- package/dist/chunk-chunk-7TTBHSAG.module.min.js +2 -0
- package/dist/chunk-chunk-7ZDJSYKI.module.min.js +2 -0
- package/dist/chunk-chunk-BGHPD3RA.module.min.js +1 -0
- package/dist/chunk-chunk-BMRZ2SPU.module.min.js +2 -0
- package/dist/chunk-chunk-BNGBEY7N.module.min.js +2 -0
- package/dist/chunk-chunk-C7APLVQD.module.min.js +2 -0
- package/dist/chunk-chunk-DGWFBOGB.module.min.js +1 -0
- package/dist/{chunk-chunk-Q2BS46W2.module.min.js → chunk-chunk-DIVE2DRA.module.min.js} +1 -1
- package/dist/chunk-chunk-FBUNUIPV.module.min.js +2 -0
- package/dist/chunk-chunk-FQPKOAIH.module.min.js +2 -0
- package/dist/chunk-chunk-FRO4TRXK.module.min.js +2 -0
- package/dist/chunk-chunk-G7QVPZUD.module.min.js +2 -0
- package/dist/chunk-chunk-GBPYV4FP.module.min.js +2 -0
- package/dist/chunk-chunk-GU2EJIDJ.module.min.js +2 -0
- package/dist/chunk-chunk-J5QD4RAM.module.min.js +2 -0
- package/dist/{chunk-chunk-RA7JCG7D.module.min.js → chunk-chunk-JWXLNZSM.module.min.js} +1 -1
- package/dist/chunk-chunk-KXAFCCDB.module.min.js +2 -0
- package/dist/chunk-chunk-LG7YKJAK.module.min.js +2 -0
- package/dist/{chunk-chunk-XP3OHHFX.module.min.js → chunk-chunk-LVHDZAT3.module.min.js} +1 -1
- package/dist/chunk-chunk-LWITSR2O.module.min.js +2 -0
- package/dist/{chunk-chunk-SMVD3EQJ.module.min.js → chunk-chunk-MX35T6RX.module.min.js} +1 -1
- package/dist/chunk-chunk-NH4MEAKP.module.min.js +2 -0
- package/dist/chunk-chunk-NJETWX42.module.min.js +2 -0
- package/dist/chunk-chunk-NW25WGLS.module.min.js +2 -0
- package/dist/{chunk-chunk-GFTVACTO.module.min.js → chunk-chunk-OI7R7EJB.module.min.js} +1 -1
- package/dist/{chunk-chunk-OM6NWS4H.module.min.js → chunk-chunk-ONMLEXHR.module.min.js} +1 -1
- package/dist/chunk-chunk-OY66GCE6.module.min.js +1 -0
- package/dist/chunk-chunk-PZFT457G.module.min.js +1 -0
- package/dist/chunk-chunk-Q3WW6JGR.module.min.js +1 -0
- package/dist/chunk-chunk-Q6XKQTOQ.module.min.js +1 -0
- package/dist/chunk-chunk-RJRM2E6P.module.min.js +1 -0
- package/dist/chunk-chunk-RPL7WYXI.module.min.js +1 -0
- package/dist/chunk-chunk-SV4XAZ3Q.module.min.js +1 -0
- package/dist/chunk-chunk-TSCFL235.module.min.js +1 -0
- package/dist/chunk-chunk-UOQRPGPK.module.min.js +2 -0
- package/dist/chunk-chunk-V3OAKG32.module.min.js +1 -0
- package/dist/chunk-chunk-WLOIUMWG.module.min.js +2 -0
- package/dist/chunk-chunk-XEGXX4F7.module.min.js +1 -0
- package/dist/chunk-chunk-XFRBLXYM.module.min.js +1 -0
- package/dist/chunk-chunk-Z2AJERX5.module.min.js +2 -0
- package/dist/chunk-chunk-ZXYDYAB7.module.min.js +2 -0
- package/dist/components/ai/SemioticVACPBridge.d.ts +22 -0
- package/dist/components/ai/chartCapabilities.d.ts +4 -3
- package/dist/components/ai/conversationArc.d.ts +2 -176
- package/dist/components/ai/conversationArcTypes.d.ts +202 -0
- package/dist/components/ai/readerGrounding.d.ts +12 -0
- package/dist/components/ai/vacpAdapter.d.ts +13 -0
- package/dist/components/ai/vacpAdapterActions.d.ts +2 -0
- package/dist/components/ai/vacpAdapterModel.d.ts +7 -0
- package/dist/components/ai/vacpAdapterRuntime.d.ts +26 -0
- package/dist/components/ai/vacpAdapterState.d.ts +3 -0
- package/dist/components/ai/vacpAdapterTypes.d.ts +169 -0
- package/dist/components/ai/vacpTypes.d.ts +160 -0
- package/dist/components/charts/index.d.ts +4 -4
- package/dist/components/charts/physics/ChainReactionChart.capability.d.ts +9 -0
- package/dist/components/charts/physics/ChainReactionChart.d.ts +29 -0
- package/dist/components/charts/physics/CollisionSwarmChart.d.ts +1 -1
- package/dist/components/charts/physics/EventDropChart.d.ts +7 -2
- package/dist/components/charts/physics/GaltonBoardChart.d.ts +1 -1
- package/dist/components/charts/physics/{PhysicsPileChart.capability.d.ts → PacketFlowChart.capability.d.ts} +1 -1
- package/dist/components/charts/physics/{PhysicalFlowChart.d.ts → PacketFlowChart.d.ts} +22 -6
- package/dist/components/charts/physics/PhysicsCustomChart.d.ts +1 -1
- package/dist/components/charts/physics/ProcessFlowChart.d.ts +7 -4
- package/dist/components/charts/physics/{PhysicalFlowChart.capability.d.ts → UnitPileChart.capability.d.ts} +1 -1
- package/dist/components/charts/physics/{PhysicsPileChart.d.ts → UnitPileChart.d.ts} +19 -6
- package/dist/components/charts/physics/crucibleChartProps.d.ts +1 -1
- package/dist/components/charts/physics/crucibleChartUtils.d.ts +9 -0
- package/dist/components/charts/physics/gauntletChartProps.d.ts +6 -1
- package/dist/components/charts/physics/gauntletTerminal.d.ts +61 -0
- package/dist/components/charts/physics/packetFlowSemantics.d.ts +6 -0
- package/dist/components/charts/physics/physicsHocUtils.d.ts +45 -2
- package/dist/components/charts/shared/auditAccessibilityStyles.d.ts +9 -0
- package/dist/components/charts/shared/knownChartComponents.d.ts +1 -1
- package/dist/components/charts/shared/useChartLegend.d.ts +8 -1
- package/dist/components/charts/shared/useChartSetup.d.ts +7 -0
- package/dist/components/data/portability/capabilityBinding.d.ts +41 -0
- package/dist/components/data/portability/index.d.ts +2 -0
- package/dist/components/legendLayout.d.ts +56 -0
- package/dist/components/recipes/geographicDotGrid.d.ts +82 -0
- package/dist/components/recipes/geographicGrid.d.ts +100 -0
- package/dist/components/recipes/physics.d.ts +2 -0
- package/dist/components/recipes/physicsStageGeography.d.ts +137 -0
- package/dist/components/semiotic-ai.d.ts +4 -3
- package/dist/components/semiotic-experimental-vacp.d.ts +11 -0
- package/dist/components/semiotic-experimental.d.ts +6 -3
- package/dist/components/semiotic-geo.d.ts +4 -0
- package/dist/components/semiotic-physics.d.ts +9 -6
- package/dist/components/semiotic-recipes-core.d.ts +6 -1
- package/dist/components/server/renderEvidence.d.ts +1 -1
- package/dist/components/server/renderToStaticSVG.d.ts +2 -1
- package/dist/components/server/serverChartConfigHeatmap.d.ts +6 -0
- package/dist/components/server/serverChartConfigNetworkStyles.d.ts +12 -0
- package/dist/components/server/serverChartConfigShared.d.ts +16 -0
- package/dist/components/server/serverChartConfigs.d.ts +2 -2
- package/dist/components/server/serverChartConfigsPhysics.d.ts +2 -2
- package/dist/components/server/serverChartConfigsXY.d.ts +0 -1
- package/dist/components/server/staticLegend.d.ts +6 -0
- package/dist/components/server/staticSVGChrome.d.ts +10 -2
- package/dist/components/server/staticValue.d.ts +8 -0
- package/dist/components/stream/geoPipelineConfig.d.ts +10 -0
- package/dist/components/stream/legendRenderer.d.ts +8 -0
- package/dist/components/stream/physics/PhysicsEvidence.d.ts +37 -0
- package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +9 -0
- package/dist/components/stream/physics/PhysicsSettledScene.d.ts +5 -0
- package/dist/components/stream/physics/physicsFramePipelineConfig.d.ts +19 -0
- package/dist/components/stream/physics/physicsPipelineSettle.d.ts +52 -0
- package/dist/components/stream/physics/physicsRegionRuntime.d.ts +23 -0
- package/dist/components/stream/types.d.ts +2 -0
- package/dist/components/types/legendTypes.d.ts +17 -1
- package/dist/controls.min.js +1 -1
- package/dist/controls.module.min.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/semiotic-ai-core.min.js +1 -1
- package/dist/semiotic-ai-core.module.min.js +1 -1
- package/dist/semiotic-ai.d.ts +4 -3
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-data.module.min.js +1 -1
- package/dist/semiotic-experimental-vacp.d.ts +11 -0
- package/dist/semiotic-experimental-vacp.min.js +1 -0
- package/dist/semiotic-experimental-vacp.module.min.js +1 -0
- package/dist/semiotic-experimental.d.ts +6 -3
- package/dist/semiotic-experimental.min.js +2 -1
- package/dist/semiotic-experimental.module.min.js +2 -1
- package/dist/semiotic-geo.d.ts +4 -0
- package/dist/semiotic-physics.d.ts +9 -6
- 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 -1
- 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.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 +18 -2
- package/spec/README.md +94 -2
- package/spec/bindings/README.md +14 -3
- package/spec/v0.1/examples/annotation-provenance-reviewed-revision.json +27 -0
- package/spec/v0.1/examples/annotation-provenance-watcher-threshold.json +21 -0
- package/spec/v0.1/examples/audience-profile-executive-review.json +24 -0
- package/spec/v0.1/examples/audience-profile-incident-operators.json +42 -0
- package/spec/v0.1/examples/chart-capability-bar-comparison.json +48 -0
- package/spec/v0.1/examples/chart-capability-service-flow.json +54 -0
- package/dist/chunk-chunk-2CHN2TA3.module.min.js +0 -1
- package/dist/chunk-chunk-3SHB24AG.module.min.js +0 -1
- package/dist/chunk-chunk-4MMOOYTX.module.min.js +0 -2
- package/dist/chunk-chunk-5RKXZQ2P.module.min.js +0 -1
- package/dist/chunk-chunk-75OTQSXS.module.min.js +0 -1
- package/dist/chunk-chunk-7ALTGHK6.module.min.js +0 -1
- package/dist/chunk-chunk-A5GRQUOF.module.min.js +0 -1
- package/dist/chunk-chunk-AAF5LZAU.module.min.js +0 -2
- package/dist/chunk-chunk-ARZGA4LJ.module.min.js +0 -2
- package/dist/chunk-chunk-C4YA6TDR.module.min.js +0 -1
- package/dist/chunk-chunk-CAFLML4L.module.min.js +0 -2
- package/dist/chunk-chunk-CO5KQMGH.module.min.js +0 -1
- package/dist/chunk-chunk-FHBN7OEB.module.min.js +0 -2
- package/dist/chunk-chunk-GMQ5AYTD.module.min.js +0 -1
- package/dist/chunk-chunk-IP2UE74X.module.min.js +0 -1
- package/dist/chunk-chunk-ITDWLZXV.module.min.js +0 -2
- package/dist/chunk-chunk-JCG72SGW.module.min.js +0 -2
- package/dist/chunk-chunk-LPSPATPC.module.min.js +0 -1
- package/dist/chunk-chunk-PX5YQGDP.module.min.js +0 -2
- package/dist/chunk-chunk-QSQVBIJA.module.min.js +0 -1
- package/dist/chunk-chunk-RCF52Z42.module.min.js +0 -2
- package/dist/chunk-chunk-RNUHEXZA.module.min.js +0 -2
- package/dist/chunk-chunk-ROZWKEUG.module.min.js +0 -1
- package/dist/chunk-chunk-T2FKJD4O.module.min.js +0 -2
- package/dist/chunk-chunk-UDREYOLV.module.min.js +0 -1
- package/dist/chunk-chunk-VOWE3SAP.module.min.js +0 -2
- package/dist/chunk-chunk-VQPNBUSW.module.min.js +0 -2
- package/dist/chunk-chunk-WAWCIHFJ.module.min.js +0 -1
- package/dist/chunk-chunk-WYARAXHR.module.min.js +0 -2
- package/dist/chunk-chunk-XV3KGYTR.module.min.js +0 -2
- package/dist/chunk-chunk-YC2IVEPX.module.min.js +0 -1
- package/dist/chunk-chunk-ZOAQDIJO.module.min.js +0 -1
- package/dist/chunk-chunk-ZXIXAPRE.module.min.js +0 -2
package/dist/server.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e,t,n,o,r,i,s=Object.create,a=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,u=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty,h=(e,t,n)=>function(){if(n)throw n[0];try{return e&&(t=(0,e[l(e)[0]])(e=0)),t}catch(e){throw n=[e],e}},f=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},p=(e,t,n,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of l(t))d.call(e,r)||r===n||a(e,r,{get:()=>t[r],enumerable:!(o=c(t,r))||o.enumerable});return e},y=(e,t,n)=>(n=null!=e?s(u(e)):{},p(!t&&e&&e.__esModule?n:a(n,"default",{value:e,enumerable:!0}),e)),g=h({"src/components/stream/brushAccessibility.ts"(){e=y(require("react")),t="Use arrow keys to move the selected range, Shift plus an arrow key to resize it, and Escape to clear it."}}),m={};function x(e,t,n,o){const[r,i]=[Math.min(...t),Math.max(...t)],s=(i-r)/20;let[a,c]=e;if(o)0>n?a=Math.max(r,a-s):c=Math.min(i,c+s);else{const e=c-a;a=Math.max(r,Math.min(i-e,a+n*s)),c=a+e}return[a,c]}function b(e,t){let n=0,o=t.length-1;for(;o>n;){const r=n+o+1>>1;t[r]>e?o=r-1:n=r}return t[n]}function v(e,t){let n=0,o=t.length-1;for(;o>n;){const r=n+o>>1;e>t[r]?n=r+1:o=r}return t[n]}function w({width:s,height:a,totalWidth:c,totalHeight:l,margin:u,dimension:d,scales:h,onBrush:f,binSize:p,snap:y,binBoundaries:g,snapDuring:m,streaming:w}){const k=(0,n.useRef)(null),S=(0,n.useRef)(null),A=(0,n.useRef)(f);A.current=f;const M=(0,n.useRef)(h);M.current=h;const _=(0,n.useMemo)(()=>g?[...g].sort((e,t)=>e-t):void 0,[g]),P=(0,n.useRef)(_);P.current=_;const j=(0,n.useRef)(!1),R=(0,n.useRef)(null),C=function({label:n="Data range brush",description:o=t,onAction:r}={}){const i=e.useId().replace(/:/g,""),s=e.useRef(r);return s.current=r,{description:o,descriptionId:"semiotic-brush-description-"+i,svgProps:{role:"region",tabIndex:0,"aria-label":n,"aria-describedby":"semiotic-brush-description-"+i,onKeyDown:e.useCallback(e=>{const t=function(e){return"Escape"===e.key?{type:"clear"}:"ArrowLeft"===e.key?{type:"nudge",direction:"left",resize:e.shiftKey}:"ArrowRight"===e.key?{type:"nudge",direction:"right",resize:e.shiftKey}:"ArrowUp"===e.key?{type:"nudge",direction:"up",resize:e.shiftKey}:"ArrowDown"===e.key?{type:"nudge",direction:"down",resize:e.shiftKey}:null}(e);t&&(e.preventDefault(),s.current?.(t))},[])}}}({label:"xy"===d?"Two-dimensional data range brush":d.toUpperCase()+" data range brush",onAction:e=>{const t=M.current,n=S.current;if(!t||!n||!k.current)return;const r=(0,o.select)(k.current).select(".brush-g");if("clear"===e.type)return j.current=!0,r.call(n.move,null),j.current=!1,R.current=null,void A.current(null);const i=t.x.domain(),s=t.y.domain(),a=R.current;let c=a?.x??[i[0]+.4*(i[1]-i[0]),i[0]+.6*(i[1]-i[0])],l=a?.y??[s[0]+.4*(s[1]-s[0]),s[0]+.6*(s[1]-s[0])];const u="left"===e.direction||"right"===e.direction,h="left"===e.direction||"down"===e.direction?-1:1;if(u&&"y"!==d&&(c=x(c,i,h,e.resize)),u||"x"===d||(l=x(l,s,h,e.resize)),u&&"y"===d||!u&&"x"===d)return;const f={x:c,y:l};j.current=!0,r.call(n.move,"x"===d?[t.x(c[0]),t.x(c[1])]:"y"===d?[t.y(l[1]),t.y(l[0])]:[[t.x(c[0]),t.y(l[1])],[t.x(c[1]),t.y(l[0])]]),j.current=!1,R.current=f,A.current(f)}});return(0,n.useEffect)(()=>{if(!k.current)return;const e=(0,o.select)(k.current).select(".brush-g"),t="x"===d?(0,r.brushX)():"y"===d?(0,r.brushY)():(0,r.brush)();return t.extent([[0,0],[s,a]]),t.on("brush end",n=>{if(j.current)return;const o=M.current;if(!o)return;if(!n.selection)return R.current=null,void A.current(null);let r,i;if("x"===d){const[e,t]=n.selection;r=[o.x.invert(e),o.x.invert(t)],i=[o.y.invert(a),o.y.invert(0)]}else if("y"===d){const[e,t]=n.selection;r=[o.x.invert(0),o.x.invert(s)],i=[o.y.invert(t),o.y.invert(e)]}else{const[[e,t],[s,a]]=n.selection;r=[o.x.invert(e),o.x.invert(s)],i=[o.y.invert(a),o.y.invert(t)]}if("bin"===y&&"y"!==d&&("end"===n.type||"brush"===n.type&&m)){const i=P.current;i&&i.length>0?r=function(e,t){return 0===t.length?e:[b(e[0],t),v(e[1],t)]}(r,i):p&&p>0&&(r=[Math.floor(r[0]/p)*p,Math.ceil(r[1]/p)*p]);const s=o.x(r[0]),a=o.x(r[1]);if(j.current=!0,"x"===d)e.call(t.move,[s,a]);else if("xy"===d){const o=n.selection;e.call(t.move,[[s,o[0][1]],[a,o[1][1]]])}j.current=!1}const c={x:r,y:i};R.current=c,A.current(c)}),e.call(t),S.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null),S.current=null}},[s,a,d,y,p,m]),(0,n.useEffect)(()=>{if(!(w&&h&&S.current&&R.current))return;if(!k.current)return;if("y"===d)return;const e=R.current,t=h.x.domain()[0],n=(0,o.select)(k.current).select(".brush-g");if(t>=e.x[1])return j.current=!0,n.call(S.current.move,null),j.current=!1,R.current=null,void A.current(null);let r=e.x[0],i=!1;if(t>e.x[0]){if(r=t,"bin"===y){const e=P.current;e&&e.length>0?r=v(t,e):p&&p>0&&(r=Math.ceil(t/p)*p)}if(r>=e.x[1])return j.current=!0,n.call(S.current.move,null),j.current=!1,R.current=null,void A.current(null);i=!0}const s=h.x(r),a=h.x(e.x[1]);if(j.current=!0,"x"===d)n.call(S.current.move,[s,a]);else{const t=h.y(e.y[1]),o=h.y(e.y[0]);n.call(S.current.move,[[s,t],[a,o]])}if(j.current=!1,i){const t={x:[r,e.x[1]],y:e.y};R.current=t,A.current(t)}},[h,w,d,y,p]),(0,i.jsxs)("svg",{ref:k,width:c,height:l,...C.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:[(0,i.jsx)("title",{children:C.svgProps["aria-label"]}),(0,i.jsx)("desc",{id:C.descriptionId,children:C.description}),(0,i.jsx)("g",{className:"brush-g",transform:`translate(${u.left},${u.top})`})]})}f(m,{XYBrushOverlay:()=>w});var k,S=h({"src/components/stream/XYBrushOverlay.tsx"(){n=require("react"),o=require("d3-selection"),r=require("d3-brush"),g(),i=require("react/jsx-runtime")}}),A={};function M(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}f(A,{generateFrameSVGs:()=>yb,generateFrameSequence:()=>gb,generatePhysicsFrameSVGs:()=>xb,renderChart:()=>cb,renderChartWithEvidence:()=>lb,renderDashboard:()=>hb,renderGeoToStaticSVG:()=>rb,renderNetworkToStaticSVG:()=>ob,renderOrdinalToStaticSVG:()=>nb,renderPhysicsToAnimatedGif:()=>Sb,renderToAnimatedGif:()=>kb,renderToImage:()=>db,renderToStaticSVG:()=>eb,renderXYToStaticSVG:()=>tb,resolveTheme:()=>Ke,themeStyles:()=>Ze}),module.exports=(k=A,p(a({},"__esModule",{value:!0}),k));var _=44,P={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:_,snap:"nearestDatum",brushHandleSize:_,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function j(e,t={}){const n=t.mobileSemantics?.interaction,o="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,r="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,i=!!n||void 0!==o,s=e&&"object"==typeof e?e:void 0;if(!1===e||!1===s?.enabled||void 0===e&&!r&&!i)return P;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??o??_,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??_,standardControls:a.standardControls??!1}}var R={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}};function C(e,t,n){const o=R[e||"primary"],r=e&&"primary"!==e||!n?.width?o.width:n.width,i=e&&"primary"!==e||!n?.height?o.height:n.height,s=function(e,t,n=e.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:e,matches:[]};const o=n.map((e,t)=>({rule:e,index:t})).filter(e=>function(e,t){const{when:n}=e,o=t.width,r=t.height,i=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),s=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof n.minWidth&&n.minWidth>o||"number"==typeof n.maxWidth&&o>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof r||n.minHeight>r)||"number"==typeof n.maxHeight&&("number"!=typeof r||r>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof i||n.minAspectRatio>i)||"number"==typeof n.maxAspectRatio&&("number"!=typeof i||i>n.maxAspectRatio)||n.orientation&&s!==n.orientation)}(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:o.reduce((e,t)=>function(e,t){const n={...e,...t};for(const o of["margin","frameProps","mobileSemantics","style"])M(e[o])&&M(t[o])&&(n[o]={...e[o],...t[o]});return"string"==typeof e.className&&"string"==typeof t.className&&(n.className=`${e.className} ${t.className}`),n}(e,t.rule.transform),e),matches:o}}({...t,mode:e},{width:t.width??r,height:t.height??i}).props,a=s.mode||e||"primary",c=R[a],l="context"===a||"sparkline"===a,u="primary"===a&&n?.width?n.width:c.width;return{mode:a,width:s.width??u,height:s.height??("primary"===a&&n?.height?n.height:c.height),showAxes:s.showAxes??c.showAxes,showGrid:s.showGrid??c.showGrid,enableHover:s.enableHover??(!!s.linkedHover||c.enableHover),showLegend:s.showLegend??c.showLegend,showLabels:s.showLabels??c.showLabels,title:l?void 0:s.title,description:s.description,summary:s.summary,accessibleTable:s.accessibleTable,xLabel:l?void 0:s.xLabel,yLabel:l?void 0:s.yLabel,categoryLabel:l?void 0:s.categoryLabel,valueLabel:l?void 0:s.valueLabel,marginDefaults:L(c.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:l,mobileInteraction:j(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}function L(e,t,n){if(!1!==t)return e;const o={...e};return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}function I(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}var T=y(require("react-dom/server")),$=y(require("react")),z=Object.freeze([]);function E(e){if(!e)return z;let t=!1;for(let n=0;e.length>n;n++){const o=e[n];if(null==o||"object"!=typeof o){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}var O=require("d3-scale");function D(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function B(e,t,n){const o=e=>e.toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}`}function F(e){const t=e.map(D),n=t.length-1;return e=>{if(0>=e){const[e,n,o]=t[0];return B(e,n,o)}if(e>=1){const[e,o,r]=t[n];return B(e,o,r)}const o=e*n,r=Math.floor(o),i=o-r,[s,a,c]=t[r],[l,u,d]=t[r+1];return B(Math.round(s+(l-s)*i),Math.round(a+(u-a)*i),Math.round(c+(d-c)*i))}}var N=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],W=F(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),q=F(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),Y=F(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),G=F(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),H=F(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),V=F(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),X=F(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),U=F(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),K=F(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),Z=F(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),Q=F(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),J=F(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),ee={blues:W,reds:q,greens:Y,viridis:X,oranges:G,purples:H,greys:V,plasma:U,inferno:K,magma:Z,cividis:Q,turbo:J};function te(e){return e&&ee[e]||W}var ne=F(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),oe=F(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),re=F(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),ie=F(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),se=F(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),ae=F(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),ce=F(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),le={category10:N,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...ee},ue=N,de="#007bff";function he(e,t,n=ue){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=le[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}var fe=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],pe=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],ye=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function ge(e,t,n){if("function"==typeof t){const o=t(e);return n&&o&&"string"==typeof o&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||ye.has(t)}(o)?n(o):o}const o=e?.[t]+"";return n?n(o):ue[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o))%ue.length]}function me(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;const n=e[t];return"string"==typeof n&&n.length>0?n:void 0}function xe(e,t,n="category10"){if(n&&"object"==typeof n&&!Array.isArray(n)){const e=n;return t=>me(e,t)??"#999"}const o=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>e+""))),r=o.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return(0,O.scaleOrdinal)().domain(o).range(n).unknown("#999");const i=le[n]||le.category10;if(r&&"function"==typeof i){let e=-1/0;for(const t of o){const n=Number(t);n>e&&(e=n)}return t=>i(Number(t)/e)}{const e=Array.isArray(i)?i:ue;return(0,O.scaleOrdinal)().domain(o).range(e).unknown("#999")}}function be(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):e?.[t],!o)return r;const[i,s]=o,[a,c]=n;if(s===i)return(a+c)/2;let l=(r-i)/(s-i);return 0>l?l=0:l>1&&(l=1),a+l*(c-a)}function ve(e){let t=1/0,n=-1/0;for(const o of e)t>o&&(t=o),o>n&&(n=o);return[t,n]}function we(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}function ke(e){if(null==e)return()=>{};const t="function"==typeof e?e:t=>t[e];return e=>Me(t(e))}function Se(e,t){const n=ke(e),o=ke(t);return(e,t)=>{const r=o(e);return{value:r,x:n(e),y:r,category:t}}}function Ae(e,t){const n=ke(t??"value"),o=null==e?void 0:"function"==typeof e?e:t=>t[e];return e=>{const t=o?o(e):void 0;return{value:n(e),category:null==t?void 0:t+""}}}function Me(e){if("number"==typeof e)return Number.isFinite(e)?e:void 0;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}function _e(e,t,n){const o=e.when;return void 0===o||!0===o||!1!==o&&("function"==typeof o?o(t,n):function(e,t,n){const o=null!=e.axis?n[e.axis]:null!=e.field?t[e.field]:n.value;if(void 0!==e.eq&&o!==e.eq)return!1;if(void 0!==e.ne&&o===e.ne)return!1;if(void 0!==e.in&&!e.in.includes(o))return!1;if(void 0===e.gt&&void 0===e.gte&&void 0===e.lt&&void 0===e.lte&&void 0===e.within&&void 0===e.outside)return!0;const r=Me(o);if(void 0===r)return!1;if(void 0!==e.gt&&e.gt>=r)return!1;if(void 0!==e.gte&&e.gte>r)return!1;if(void 0!==e.lt&&r>=e.lt)return!1;if(void 0!==e.lte&&r>e.lte)return!1;if(void 0!==e.within){const[t,n]=e.within;if(t>r||r>n)return!1}if(void 0!==e.outside){const[t,n]=e.outside;if(r>=t&&n>=r)return!1}return!0}(o,t,n))}function Pe(e,t,n){if(!t||0===t.length)return{};let o={};for(const r of t){if(!_e(r,e,n))continue;const t="function"==typeof r.style?r.style(e,n):r.style;t&&(o={...o,...t})}return o}function je(e,t,n,o=e=>e){const r=e??(()=>({}));return t&&0!==t.length?(e,i)=>{const s=o(e),a={...r(e,i)};return Object.assign(a,Pe(s,t,n(s,i))),a}:r}function Re(e,t,n,o){if(!e||0===e.length)return o;const r=Ae(t,n);return(t,n)=>{const i=t&&t.data||t,s=Pe(i,e,r(i)),a=o?o(t,n):void 0;return a?{...s,...a}:s}}var Ce={stops:[{offset:0,opacity:.8},{offset:1,opacity:.05}]};function Le(e,t=Ce){if(e)return!0===e?t:"stops"in e?Array.isArray(e.stops)?e:void 0:"colorStops"in e?Array.isArray(e.colorStops)?{stops:e.colorStops.map(({offset:e,color:t})=>({offset:e,color:t}))}:void 0:{stops:[{offset:0,opacity:e.topOpacity??t.stops[0]?.opacity??.8},{offset:1,opacity:e.bottomOpacity??t.stops.at(-1)?.opacity??.05}]}}function Ie(e){return e?Le(e):void 0}function Te(e,t,n){return"function"==typeof e?e(n):n[e||t]}function $e(e){return e instanceof Date?e.getTime():Number(e)}function ze(e,t){return X(1===t?.5:e/(t-1))}var Ee=require("react"),Oe=require("react/jsx-runtime");function De(e){let t=null;const n=()=>(t||(t=(0,Ee.createContext)(null)),t),o=Be(e);return[function({children:t,initialState:o}){const r=(0,Ee.useRef)(o),i=(0,Ee.useMemo)(()=>Be(e,r.current),[]),s=n();return(0,Oe.jsx)(s.Provider,{value:i,children:t})},(e,t)=>{const r=n(),i=(0,Ee.useContext)(r)??o,s=(0,Ee.useRef)(e);s.current=e;const a=(0,Ee.useRef)({hasValue:!1,value:void 0}),c=(0,Ee.useCallback)(()=>{const e=s.current(i.getState()),n=a.current;return n.hasValue&&t&&t(n.value,e)?n.value:(a.current={hasValue:!0,value:e},e)},[i,t]),l=(0,Ee.useCallback)(()=>s.current(i.getState()),[i]);return(0,Ee.useSyncExternalStore)(i.subscribe,c,l)}]}function Be(e,t){const n=new Set;let o={...e(function(e){const t=e(o);if(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}(t)){o={...o,...t};for(const e of n)e()}}),...t??{}};return{getState:()=>o,subscribe:function(e){return n.add(e),()=>{n.delete(e)}}}}function Fe(e){if(!e?.colors)return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function Ne(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:We}}),e.accessibility.highContrast){const e="dark"===t.mode;t={...t,colors:{...t.colors,text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"}}}return t}var We=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],qe={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},Ye={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},Ge={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:We,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function He(e,t){if("light"===t)return qe;if("dark"===t)return Ye;if("high-contrast"===t)return Ge;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?Ye:qe;return Ne({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return Ne({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[Ve,Xe]=De(e=>({theme:qe,setTheme(t){e(e=>({theme:He(e.theme,t)}))}})),Ue={light:qe,dark:Ye,"high-contrast":Ge,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#7a644a",grid:"#e8d5c4",border:"#e8d5c4",focus:"#8a5fae",annotation:"#8a5fae",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#64717f",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#d06a6a",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#c63b3b",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#7a47e8",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function Ke(e){if(!e)return qe;if("string"==typeof e){if("light"===e)return qe;if("dark"===e)return Ye;if("high-contrast"===e)return Ge;return Ue[e]||qe}const t="dark"===e.mode?Ye:qe;return Ne({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}},tooltip:{...t.tooltip,...e.tooltip||{}}})}function Ze(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 Qe(e,t,n){const o="function"==typeof t?t(e):e[t??n];if(null==o)return null;if(o instanceof Date)return o.getTime();if("string"==typeof o&&""===o.trim())return null;const r=Number(o);return Number.isFinite(r)?r:null}var Je="__forecastSegment",et="__forecastOpacity";function tt(e,t,n,o){const r=t.uncertaintyOpacity,i=t.confidenceAccessor;if(!r&&!i)return;const s="object"==typeof r?r:{},a=s.min??.15,c=s.max??1;if(i){const t="function"==typeof i?i:e=>e[i];for(const n of e){const e=t(n);null!=e&&Number.isFinite(e)&&(n[et]=a+Math.max(0,Math.min(1,e))*(c-a))}return}const l=e.map(e=>{const t=n(e),r=o(e);return null!=t&&null!=r&&Number.isFinite(t)&&Number.isFinite(r)?Math.abs(t-r):NaN}),u=l.filter(e=>Number.isFinite(e));if(0===u.length)return;const[d,h]=ve(u),f=h-d;e.forEach((e,t)=>{const n=l[t];Number.isFinite(n)&&(e[et]=c-(f>0?(n-d)/f:0)*(c-a))})}function nt(e,t){return"function"==typeof t?t(e):!!e[t]}var ot="__semiotic_resolvedX",rt="__semiotic_resolvedY",it="__compoundGroup";function st(e,t,n){const o=e[t],r=e[n];return null==o||null==r||Number.isNaN(o)||Number.isNaN(r)}function at(e){const t=e.xAccessor||"x",n=e.yAccessor||"y",o=e.lineBy,r=e.colorBy||o;let i=Array.isArray(e.data)?E(e.data).filter(e=>!!e&&"object"==typeof e):[];const s=function(e,t,n){const o="function"==typeof t,r="function"==typeof n,i=o?ot:t,s=r?rt:n;return o||r?{xKey:i,yKey:s,rows:e.map(e=>{const i={...e};return o&&(i[ot]=t(e)),r&&(i[rt]=n(e)),i})}:{rows:e,xKey:i,yKey:s}}(i,t,n);i=s.rows;const a=s.xKey,c=s.yKey,l=Array.isArray(e.annotations)?[...e.annotations]:[];let u,d="string"==typeof o||"function"==typeof o?o:void 0,h=e.baseLineStyle;if(e.forecast){const t=function(e,t,n,o,r){return(i=o).isTraining||i.isForecast||i.isAnomaly||i.upperBounds||i.lowerBounds?function(e,t,n,o,r){const{isTraining:i,isForecast:s,isAnomaly:a,upperBounds:c,lowerBounds:l,color:u="#6366f1",bandOpacity:d=.15,anomalyColor:h="#ef4444",anomalyRadius:f=6,label:p}=o,y=e.map(e=>{let t="observed";return s&&nt(e,s)?t="forecast":i&&nt(e,i)&&(t="training"),{...e,[Je]:t}}),g=o._groupBy,m=[];if(g){const e=new Map;for(const t of y){const n=t[g]??"__default";e.has(n)||e.set(n,[]),e.get(n).push(t)}const t=[];for(const[,n]of e)for(let e=0;n.length-1>e;e++)n[e][Je]!==n[e+1][Je]&&(t.push({...n[e+1],[Je]:n[e][Je]}),t.push({...n[e],[Je]:n[e+1][Je]}));m.push(...y,...t)}else for(let e=0;y.length>e;e++)m.push(y[e]),y.length-1>e&&y[e][Je]!==y[e+1][Je]&&(m.push({...y[e+1],[Je]:y[e][Je]}),m.push({...y[e],[Je]:y[e+1][Je]}));if(o.trainUnderline){const e=[];for(const t of m)"training"===t[Je]&&e.push({...t,[Je]:"training-base"});m.unshift(...e)}const x=[];if(c&&l){const e="string"==typeof c?c:"__envUpper",t="string"==typeof l?l:"__envLower";if("function"==typeof c||"function"==typeof l)for(const n of m)"function"==typeof c&&(n[e]=c(n)),"function"==typeof l&&(n[t]=l(n));x.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:u,fillOpacity:d,label:p})}if(o.uncertaintyOpacity||o.confidenceAccessor){const e=c?"function"==typeof c?c:e=>e[c]:()=>{},t=l?"function"==typeof l?l:e=>e[l]:()=>{};tt(m.filter(e=>"forecast"===e[Je]),o,e,t)}if(a){const e=o.anomalyStyle,t={type:"highlight",filter:e=>nt(e,a)};e?(t.style=e,t.r=f):"function"==typeof h?(t.style=e=>{const t=h(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=f):(t.color=h,t.r=f,t.style={stroke:h,strokeWidth:1.5,fill:h,fillOpacity:.7}),x.push(t)}return r&&x.push({type:"anomaly-band",threshold:r.threshold??2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:r.bandOpacity??.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:r.anomalyRadius??6,label:r.label}),{processedData:m,annotations:x}}(e,0,0,o,r):function(e,t,n,o,r){const{trainEnd:i,steps:s=10,confidence:a=.95,color:c="#6366f1",bandOpacity:l=.15,label:u}=o;if(null==i)return{processedData:e,annotations:[]};const d=[],h=[];for(const n of e)n[t]>i?h.push({...n,[Je]:"observed"}):d.push({...n,[Je]:"training"});const f=d.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),p=[],y=[];if(f.length>=3){const r=f.length;let i=0,d=0,h=0,g=0;for(const[e,t]of f)i+=e,d+=t,h+=e*e,g+=e*t;const m=r*h-i*i;if(Math.abs(m)>1e-12){const h=(r*g-i*d)/m,x=(d-h*i)/r,b=e=>x+h*e,v=f.map(([e,t])=>t-b(e)).reduce((e,t)=>e+t*t,0),w=Math.sqrt(v/Math.max(r-2,1)),k=f.reduce((e,t)=>e+t[0],0)/r,S=f.reduce((e,t)=>e+(t[0]-k)**2,0),A=.99>a?.95>a?.9>a?1:1.645:1.96:2.576,M=we(e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e))),_=f.length>1?(f[r-1][0]-f[0][0])/(r-1):1;for(let e=1;s>=e;e++){const o=M+e*_,i=b(o),s=w*Math.sqrt(1+1/r+(S>0?(o-k)**2/S:0))*A;y.push({[t]:o,[n]:i,[Je]:"forecast",__forecastUpper:i+s,__forecastLower:i-s})}tt(y,o,e=>e.__forecastUpper,e=>e.__forecastLower),p.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:c,fillOpacity:l,label:u})}}p.push({type:"x-threshold",x:i,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),r&&p.push({type:"anomaly-band",threshold:r.threshold??2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:r.bandOpacity??.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:r.anomalyRadius??6,label:r.label});const g=[];if(g.push(...d),d.length>0&&h.length>0&&g.push({...d[d.length-1],[Je]:"observed"}),g.push(...h),y.length>0){const e=h.length>0?h[h.length-1]:d[d.length-1];e&&g.push({...e,[Je]:"forecast"}),g.push(...y)}return{processedData:g,annotations:p}}(e,t,n,o,r);var i}(i,a,c,o&&"string"==typeof o&&"object"==typeof e.forecast?{...e.forecast,_groupBy:o}:e.forecast,e.anomaly);if(i=t.processedData,l.push(...t.annotations),u=function(e,t,n){const o=n.upperBounds,r=n.lowerBounds;if(!o&&!r)return;const i="function"==typeof o?o:"string"==typeof o?e=>e[o]:null,s="function"==typeof r?r:"string"==typeof r?e=>e[r]:null;let a=1/0,c=-1/0;for(const n of e){const e=Number(n[t]);if(Number.isFinite(e)&&(a>e&&(a=e),e>c&&(c=e)),i){const e=i(n);null!=e&&Number.isFinite(e)&&(e>c&&(c=e),a>e&&(a=e))}if(s){const e=s(n);null!=e&&Number.isFinite(e)&&(a>e&&(a=e),e>c&&(c=e))}}return Number.isFinite(a)&&Number.isFinite(c)?[a,c]:void 0}(i,c,e.forecast),o&&"string"==typeof o?(i=i.map(e=>({...e,[it]:`${e[o]}__${e[Je]||"observed"}`})),d=it):d=Je,e.baseLineStyle){const t=function(e,t){const n=t.trainDasharray??"8,4",o=t.forecastDasharray??"4,4",r=t.color||"#6366f1",i=t.trainOpacity,s=t.forecastOpacity,a=t.trainStroke,c=t.trainLinecap,l=t.trainUnderline;return t=>{const u=e(t),d=t[Je];if("training"===d){let e=u.stroke;return"darken"===a?e=function(e,t=.5){const n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!n)return e;const o=Math.round(parseInt(n[1],16)*(1-t)),r=Math.round(parseInt(n[2],16)*(1-t)),i=Math.round(parseInt(n[3],16)*(1-t));return`#${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}(u.stroke||"#666",.5):a&&(e=a),{...u,stroke:e,strokeDasharray:n,...c&&{strokeLinecap:c},...null!=i&&{strokeOpacity:i}}}if("training-base"===d){let e=u.stroke||"#666";return"lighten"===l&&(e=function(e,t=.5){const n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!n)return e;const o=Math.round(parseInt(n[1],16)+(255-parseInt(n[1],16))*t),r=Math.round(parseInt(n[2],16)+(255-parseInt(n[2],16))*t),i=Math.round(parseInt(n[3],16)+(255-parseInt(n[3],16))*t);return`#${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}(e,.4)),{...u,stroke:e,strokeDasharray:void 0}}if("forecast"===d){const e=t[et],n=null!=e?e:s;return{...u,stroke:r,strokeDasharray:o,...null!=n&&{strokeOpacity:n}}}return u}}(t=>e.baseLineStyle(t),e.forecast);h=e=>t(e)}}else e.anomaly&&l.push(...(f=e.anomaly,[{type:"anomaly-band",threshold:f.threshold??2,showBand:!1!==f.showBand,fill:f.bandColor||"#6366f1",fillOpacity:f.bandOpacity??.1,anomalyColor:f.anomalyColor||"#ef4444",anomalyRadius:f.anomalyRadius??6,label:f.label}]));var f;if(e.gapStrategy){if("function"==typeof d){const e=d;i=i.map(t=>({...t,__semiotic_gapGroup:e(t)})),d="__semiotic_gapGroup"}const t=function(e,t,n,o,r){const i=new Map;for(const t of e){const e=r?(t[r]??"")+"":"__single";i.has(e)||i.set(e,[]),i.get(e).push(t)}if("interpolate"===t){const e=[];for(const[,t]of i)for(const r of t)st(r,n,o)||e.push(r);return{rows:e,groupKey:r}}if("zero"===t){const e=[];for(const[,t]of i)for(const r of t)st(r,n,o)?e.push({...r,[o]:0}):e.push(r);return{rows:e,groupKey:r}}const s=[],a="_gapSegment";for(const[e,t]of i){let r=0,i=[];const c=()=>{if(0===i.length)return;const t="__single"===e?"__seg"+r:`${e}__seg${r}`;for(const e of i)s.push({...e,[a]:t});i=[],r++};for(const e of t)st(e,n,o)?c():i.push(e);c()}return{rows:s,groupKey:a}}(i,e.gapStrategy,a,c,"string"==typeof d?d:void 0);i=t.rows,t.groupKey&&(d=t.groupKey)}let p;if(e.directLabel){const t=function(e,t,n,o,r,i,s,a){if(!t||!n)return{annotations:[]};const c="object"==typeof t?t:{},l=c.position||"end",u=c.fontSize||11,d="function"==typeof n?n:e=>e[n],h=new Map;for(const t of e){const e=d(t);if(null==e)continue;const n=e+"";""!==n&&(h.has(n)||h.set(n,[]),h.get(n).push(t))}const f=new Map;for(const[e,t]of h)t.sort((e,t)=>Number(e[o])-Number(t[o])),f.set(e,"end"===l?t[t.length-1]:t[0]);const p=xe(Array.from(f.entries()).map(([e])=>({__lbl:e})),"__lbl",i??s),y=Array.from(f.entries()).map(([e,t])=>({type:"text",label:e,[o]:t[o],[r]:t[r],dx:"end"===l?6:-6,dy:0,color:p?ge({__lbl:e},"__lbl",p):a||de,fontSize:u}));y.sort((e,t)=>Number(e[r])-Number(t[r]));for(let e=1;y.length>e;e++){const t=y[e-1],n=y[e],o=Number(t[r])+t.dy;u+2>Math.abs(Number(n[r])+n.dy-o)&&(n.dy+=u+2)}const g=y.reduce((e,t)=>Math.max(e,(t.label+"").length*(.6*u)),0)+10;return{annotations:y,marginExtra:"end"===l?{right:g}:{left:g}}}(i,e.directLabel,"string"==typeof r||"function"==typeof r?r:void 0,a,c,e.colorScheme,e.themeCategorical,e.color);l.push(...t.annotations),p=t.marginExtra}return{data:i,xAccessor:"function"==typeof t?a:t,yAccessor:"function"==typeof n?c:n,groupAccessor:d,colorAccessor:r,annotations:l,lineStyle:h,yExtent:u,marginExtra:p}}var ct=require("react"),lt=y(require("react")),ut=require("react/jsx-runtime"),dt={isActive:!1,predicate:()=>!0},ht=lt.createContext(null);function ft({value:e,children:t}){return(0,ut.jsx)(ht.Provider,{value:e,children:t})}function pt(e,t){return null!=e?(0,ut.jsx)(ft,{value:t,children:e}):e}var yt=require("react"),gt=y(require("react")),mt=require("react"),xt=y(require("react")),bt=require("react/jsx-runtime"),vt=null,wt=null;function kt(e){const[t,n]=xt.useState(()=>vt);return xt.useEffect(()=>{if(t)return;let e=!1;return(vt?Promise.resolve(vt):(wt||(wt=Promise.resolve().then(()=>(S(),m)).then(e=>vt=e.XYBrushOverlay).catch(e=>{throw wt=null,e})),wt)).then(t=>{e||n(()=>t)}),()=>{e=!0}},[t]),t?(0,bt.jsx)(t,{...e}):null}var St=class{constructor(e,t){this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=t?.chunkThreshold??5e3,this.chunkSize=t?.chunkSize??5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(e=E(e),this.lastBoundedData===e)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(e){if(e=E(e),this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){null!=e&&"object"==typeof e&&(this.pushBuffer.push(e),this.scheduleFlush())}pushMany(e){if(0===e.length)return;let t=0;for(let n=0;e.length>n;n++){const o=e[n];null!=o&&"object"==typeof o&&(this.pushBuffer.push(o),t++)}0!==t&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}},At=class{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;return{next:()=>this._size>e?{done:!1,value:this.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray();let n=0,o=[];t.length>e&&(n=t.length-e,o=t.slice(0,n)),this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(let e=n;t.length>e;e++)this.push(t[e]);return o}update(e,t){const n=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const i=(o+r)%this._capacity,s=this.buffer[i];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},n.push(e),this.buffer[i]=t(s)}}return n}remove(e){const t=[],n=[];if(this.forEach(o=>{e(o)?n.push(o):t.push(o)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}},Mt=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}};function _t(e,t){return e===t}function Pt(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function jt(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function Rt(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}var Ct=/^\d{4}-\d{1,2}$/;function Lt(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const n=Ct.test(t)?t+"-01":t;if(n===t&&10>t.length)return NaN;const o=Date.parse(n);return Number.isFinite(o)?o:NaN}function It(e){return e instanceof Date?e.getTime():"string"==typeof e?Lt(e):+e}function Tt(e){return new Set(Array.isArray(e)?e:[e])}function $t(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function zt(e,t){return Math.min((e-t.startTime)/t.duration,1)}function Et(e,t,n){return e+(t-e)*n}function Ot(){return"undefined"!=typeof performance?performance.now():Date.now()}function Dt(e,t,n){if(1>=n)return 1;const o=n-1;return function(e){const t=Math.max(0,Math.min(1,e.minOpacity??.1));if(Number.isNaN(e.age))return 1;if(e.age===1/0)return t;if(!Number.isFinite(e.extent)||0>=e.extent)return 1;const n=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>n?1:t;if("exponential"===e.type){const o=e.halfLife??e.extent/2;return t+Math.pow(.5,n/(o>0?o:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-n/e.extent))*(1-t)}({age:o-t,extent:o,type:e.type,halfLife:e.halfLife??n/2,threshold:e.stepThreshold??.5*n,minOpacity:e.minOpacity??.1})}function Bt(e){const t=new Map;for(let n=0;e.length>n;n++)t.set(e[n],n);return t}function Ft(e,t,n){const o=e.duration??500,r=n-t;return o>r?1-r/o:0}function Nt(e,t,n,o){let r=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,r=!0),e._pulseColor!==n&&(e._pulseColor=n,r=!0),e._pulseGlowRadius!==o&&(e._pulseGlowRadius=o,r=!0),r):(0!==e._pulseIntensity&&(e._pulseIntensity=0,r=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,r=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,r=!0),r)}function Wt(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;const o=e.duration??500,r=t.peek();return null!=r&&o>n-r}function qt(e,t,n){if(t._transitionKey)return t._transitionKey;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const n=e.getX(t.datum),o=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${o}`;if(null!=n&&null!=o)return`p:${n}:${o}`}return"p:"+n;case"glyph":return t.pointId?"g:"+t.pointId:"g:"+n;case"rect":return`r:${t.group||""}:${t.datum?.binStart??t.datum?.category??n}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+n:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function Yt(e,t,n,o,r,i){const s=[];for(const r of e){const e=n(r),i=o(r);Number.isFinite(e)&&Number.isFinite(i)&&s.push({px:t.x(e),py:t.y(i),rawY:i,d:r})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],c[e]=t.rawY,l[e]=t.d}return{type:"line",path:a,rawValues:c,style:r,datum:l,group:i}}function Gt(e,t,n,o,r,i,s,a){const c=[];for(const i of e){const e=n(i),s=o(i);if(!Number.isFinite(e)||!Number.isFinite(s))continue;const l=t.x(e),u=a?a(i):r;c.push({px:l,topY:t.y(s),botY:t.y(u),rawY:s})}c.sort((e,t)=>e.px-t.px);const l=Array(c.length),u=Array(c.length),d=Array(c.length);for(let e=0;c.length>e;e++){const t=c[e];l[e]=[t.px,t.topY],u[e]=[t.px,t.botY],d[e]=t.rawY}return{type:"area",topPath:l,bottomPath:u,rawValues:d,style:i,datum:e,group:s}}function Ht(e,t,n,o){const r=new Map;if("silhouette"===o)for(const o of e){let e=0;for(const r of t)e+=n(r,o)||0;r.set(o,-e/2)}else if("wiggle"===o){e.length>0&&r.set(e[0],0);for(let o=1;e.length>o;o++){const i=e[o-1],s=e[o];let a=0,c=0,l=0;for(const e of t){const t=n(e,s)||0;a+=(2*l+t)*(t-(n(e,i)||0)),c+=t,l+=t}const u=r.get(i)??0;r.set(s,u-(c>0?a/(2*c):0))}if(e.length>0){let o=0;for(const i of e){let e=0;for(const o of t)e+=n(o,i)||0;o+=(r.get(i)??0)+e/2}const i=o/e.length;for(const t of e)r.set(t,(r.get(t)??0)-i)}}else for(const t of e)r.set(t,0);return r}function Vt(e,t,n,o,r,i,s){const a=n(e),c=o(e);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:t.x(a),y:t.y(c),r:r,style:i,datum:e};return void 0!==s&&(l.pointId=s),l}function Xt(e,t,n,o,r,i,s,a){const c=n(e),l=o(e);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:t.x(c),y:t.y(l),size:r,symbolType:i,style:s,datum:e};return void 0!==a&&(u.pointId=a),u}function Ut(e,t,n,o,r,i,s){return{type:"rect",x:e,y:t,w:n,h:o,style:r,datum:i,group:s}}function Kt(e,t,n,o,r,i,s){const a={type:"heatcell",x:e,y:t,w:n,h:o,fill:r,datum:i};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function Zt(e,t,n,o){return"function"==typeof t.style?t.style(o||{},n):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(n,o)}function Qt(e,t,n,o){if(!e.scales)return null;const r=[],i=[];for(const n of t){const t=e.getX(n);if(!Number.isFinite(t))continue;const s=o.getTop(n),a=o.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const c=e.scales.x(t),l=e.scales.y(s),u=e.scales.y(a);Number.isFinite(c)&&Number.isFinite(l)&&Number.isFinite(u)&&(r.push([c,l]),i.push([c,u]))}return 2>r.length?null:{type:"area",topPath:r,bottomPath:i,...e.config.curve&&"linear"!==e.config.curve&&{curve:e.config.curve},style:Zt(e,o,n,t[0]),datum:t,group:n,interactive:o.interactive}}function Jt(e){const t=[],n=[];if(!e)return{perSeries:t,aggregate:n};for(const o of e)o.perSeries?t.push(o):n.push(o);return{perSeries:t,aggregate:n}}function en(e,t,n){const o=[];for(const r of n){const n=Qt(e,t,"__ribbon_aggregate",r);n&&o.push(n)}return o}function tn(e,t,n,o){const r=[];for(const i of o){const o=Qt(e,t,n,i);o&&r.push(o)}return r}function nn(e,t){if(!e)return{};if(!t||0===t.length)return e;const n=[];for(const o of t){if("band"!==o.kind)continue;const t=o.getTop(e),r=o.getBottom(e);Number.isFinite(r)&&Number.isFinite(t)&&n.push({y0:r,y1:t})}return 0===n.length?e:{...e,band:n[0],bands:n}}function on(e,t,n,o){if(!e.config.pointStyle)return;const r=o??e.getY;for(const o of t){const t=e.resolveGroupColor(o.key);for(const i of o.data){let o=e.config.pointStyle(i);!o.fill&&t&&(o={...o,fill:t});const s=o.r??3,a=e.getPointId?e.getPointId(i)+"":void 0,c=Vt(i,e.scales,e.getX,r,s,o,a);c&&n.push(c)}}}function rn(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}function sn(e){return Le(e)}var an=require("d3-shape"),cn={circle:an.symbolCircle,square:an.symbolSquare,triangle:an.symbolTriangle,diamond:an.symbolDiamond,star:an.symbolStar,cross:an.symbolCross,wye:an.symbolWye},ln=["circle","triangle","diamond","star","square","chevron","cross","wye"];function un(e,t,n){if(n)return n;const o=e??"circle";return"chevron"===o?function(e){const t=1.5*dn(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t):(0,an.symbol)(cn[o]??an.symbolCircle,Math.max(1,t))()??""}function dn(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var hn=new Map;function fn(e,t,n){const o=n.config.areaStyle?.(t);return o&&(e.style=o),e}function pn(e,t,n,o,r){const i=new Map;for(const s of e){const e=t(s),a=n(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const c=Math.floor(e/o)*o;let l=i.get(c);if(l||(l={start:c,end:c+o,total:0,categories:new Map},i.set(c,l)),l.total+=a,r){const e=r(s);l.categories.set(e,(l.categories.get(e)||0)+a)}}return i}function yn(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:o,warned:r}=e;gn(o)&&0===n.length&&mn(r,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),n.length>0&&n.every(e=>null==e.datum)&&mn(r,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function gn(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(gn))}function mn(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function xn(e,t,n,o){const r=function(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:e+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(t),i="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:i,message:`Semiotic ${e} ${i} failed: ${r.message}`,error:r,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:o}}function bn(e,t){const n="function"==typeof e?e:n=>n[e||t];return e=>{const t=n(e);return null==t?NaN:+t}}function vn(e){const t=[],n=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,o=bn(n&&e.valueAccessor||e.yAccessor,n?"value":"y");if(e.boundsAccessor){const n=Pt(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{const t=o(e);if(!Number.isFinite(t))return NaN;const r=n(e);return Number.isFinite(r)&&0!==r?t+r:t},getBottom:e=>{const t=o(e);if(!Number.isFinite(t))return NaN;const r=n(e);return Number.isFinite(r)&&0!==r?t-r:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){const n=Array.isArray(e.band)?e.band:[e.band];for(const e of n)t.push({kind:"band",getTop:bn(e.y1Accessor,"y1"),getBottom:bn(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}var wn=require("d3-scale");function kn(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function Sn(e,t,n){if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return(0,wn.scaleLog)().domain(e).range(n).clamp(!0)}return"symlog"===e?(0,wn.scaleSymlog)().domain(t).range(n):"time"===e?(0,wn.scaleTime)().domain([new Date(t[0]),new Date(t[1])]).range(n):(0,wn.scaleLinear)().domain(t).range(n)}function An(e,t,n){t>e.capacity&&(e.resize(t),n&&t>n.capacity&&n.resize(t))}function Mn(e,t){const n=new At(e.capacity);return e.forEach(()=>n.push(t)),n}function _n(e,t,n,o){const r=e.push(t);return n&&n.push(o),r}function Pn(e,t,n){if(!t||0===t.size)return;const o=new Set;if(e.forEach((e,t)=>{n(e)&&o.add(t)}),0===o.size)return;const r=t.toArray();t.clear();for(let e=0;r.length>e;e++)o.has(e)||t.push(r[e])}var jn=new WeakMap;function Rn(){return this.updateResults.last}function Cn(){return this.updateResults.last}function Ln(e){return this.updateResults.subscribe(e)}function In(e){this.config.layoutSelection=e}function Tn(){jn.set(this,!0)}function $n(){const e=!0===jn.get(this);return jn.delete(this),e}function zn(e){Object.assign(e.prototype,{getLastUpdateResult:Rn,getUpdateSnapshot:Cn,subscribeUpdateResult:Ln,setLayoutSelection:In,markStylePaintPending:Tn,consumeStylePaintPending:$n})}var En={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"};function On(e,t){const n={...e};for(const e of t)n[En[e]]++;return n}function Dn(e,t,n){const o=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:o,revisions:On(n,o)}}var Bn=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=Dn({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){const n=Dn(e,t,this.revisions);this.revisions=n.revisions,this.latest=n;for(const e of[...this.listeners])e();return n}},Fn=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Nn=["scene-style","data-paint","accessibility","evidence"],Wn=(e,t)=>({retainedData:e,invalidations:t}),qn=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Yn=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Gn=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Hn=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Vn=["scene-geometry","data-paint","accessibility","evidence"],Xn=["scene-style","data-paint","accessibility","evidence"],Un=[],Kn={chartType:Wn("rebuild",qn),runtimeMode:Wn("rebuild",qn),xAccessor:Wn("rebuild",qn),yAccessor:Wn("rebuild",qn),timeAccessor:Wn("rebuild",qn),valueAccessor:Wn("rebuild",qn),y0Accessor:Wn("rebuild",qn),boundsAccessor:Wn("rebuild",qn),band:Wn("rebuild",qn),openAccessor:Wn("rebuild",qn),highAccessor:Wn("rebuild",qn),lowAccessor:Wn("rebuild",qn),closeAccessor:Wn("rebuild",qn),candlestickRangeMode:Wn("rebuild",qn),accessorRevision:Wn("rebuild",qn),groupAccessor:Wn("rebuild",Yn),categoryAccessor:Wn("rebuild",Yn),lineDataAccessor:Wn("rebuild",Yn),colorAccessor:Wn("rebuild",Xn),sizeAccessor:Wn("rebuild",Vn),symbolAccessor:Wn("rebuild",Vn),pointIdAccessor:Wn("rebuild",Vn),xScaleType:Wn("preserve",Gn),yScaleType:Wn("preserve",Gn),xExtent:Wn("preserve",Gn),yExtent:Wn("preserve",Gn),extentPadding:Wn("preserve",Gn),scalePadding:Wn("preserve",Gn),axisExtent:Wn("preserve",Gn),binSize:Wn("preserve",Gn),normalize:Wn("preserve",Gn),heatmapAggregation:Wn("preserve",Gn),heatmapXBins:Wn("preserve",Gn),heatmapYBins:Wn("preserve",Gn),arrowOfTime:Wn("preserve",Hn),baseline:Wn("preserve",Hn),stackOrder:Wn("preserve",Hn),sizeRange:Wn("preserve",Hn),curve:Wn("preserve",Hn),areaGroups:Wn("preserve",Hn),customLayout:Wn("preserve",Hn),layoutConfig:Wn("preserve",Hn),layoutMargin:Wn("preserve",Hn),symbolMap:Wn("preserve",Vn),showValues:Wn("preserve",Vn),heatmapValueFormat:Wn("preserve",Vn),lineStyle:Wn("preserve",Xn),pointStyle:Wn("preserve",Xn),areaStyle:Wn("preserve",Xn),barStyle:Wn("preserve",Xn),swarmStyle:Wn("preserve",Xn),waterfallStyle:Wn("preserve",Xn),candlestickStyle:Wn("preserve",Xn),boundsStyle:Wn("preserve",Xn),gradientFill:Wn("preserve",Xn),lineGradient:Wn("preserve",Xn),semanticLineStops:Wn("preserve",Xn),colorScheme:Wn("preserve",Xn),themeCategorical:Wn("preserve",Xn),themeSemantic:Wn("preserve",Xn),themeSequential:Wn("preserve",Xn),themeDiverging:Wn("preserve",Xn),barColors:Wn("preserve",Xn),decay:Wn("preserve",Xn),pulse:Wn("preserve",Xn),staleness:Wn("preserve",Xn),layoutSelection:Wn("preserve",Xn),annotations:Wn("preserve",["overlay","accessibility","evidence"]),windowSize:Wn("preserve",Un),windowMode:Wn("preserve",Un),maxCapacity:Wn("preserve",Un),clock:Wn("preserve",Un),transition:Wn("preserve",Un),introAnimation:Wn("preserve",Un),onLayoutError:Wn("preserve",Un)},Zn=Wn("preserve",Hn),Qn=class{constructor(){this.tracker=new Bn}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}},Fn)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Nn):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const o of e){const e=Kn[o]??Zn;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},Jn=require("d3-quadtree"),eo=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(e,t){if("scatter"!==e&&"bubble"!==e&&"custom"!==e)return void this.clear();let n=0,o=0;for(const e of t)"point"===e.type&&(n++,e.r>o&&(o=e.r));if(this.maxRadius=o,500>=n)return void(this.tree=null);const r=Array(n);let i=0;for(const e of t)"point"===e.type&&(r[i++]=e);this.tree=(0,Jn.quadtree)().x(e=>e.x).y(e=>e.y).addAll(r)}},to=class e{constructor(e){if(this.xExtent=new Mt,this.yExtent=new Mt,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._datumIndexCache=null,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.updateResults=new Qn,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.xIsDate=!1,this.spatialIndex=new eo,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,n)=>!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,o,r,i=("undefined"!=typeof performance?performance.now():Date.now())){const s=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let c=!1;const l=r??(()=>{const e=new Map;for(let t=0;n.length>t;t++)e.set(n[t],t);return e})();for(const n of t){if("line"===n.type)continue;if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[n.datum];let r=0,a=!1;for(const n of t){const t=l.get(n);if(null==t)continue;a=!0;const s=o.get(t);if(null==s)continue;const c=Ft(e,s,i);c>r&&(r=c)}a&&(c=Nt(n,r,s)||c);continue}const t=l.get(n.datum);if(null==t)continue;const r=o.get(t);c=Nt(n,null==r?0:Ft(e,r,i),s,a)||c}return c}(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),n),this.config=e,this.buffer=new At(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=Pt(e.timeAccessor||e.xAccessor,"time"),this.getY=Pt(e.valueAccessor||e.yAccessor,"value")):(this.getX=Pt(e.xAccessor,"x"),this.getY=Pt(e.yAccessor,"y")),this.getGroup=Rt(e.groupAccessor),this.getCategory=Rt(e.categoryAccessor),this.getSize=e.sizeAccessor?Pt(e.sizeAccessor,"size"):void 0,this.getColor=Rt(e.colorAccessor),this.getSymbol=Rt(e.symbolAccessor),this.getY0=e.y0Accessor?Pt(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=vn(e),this.getPointId=Rt(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?Pt(e.openAccessor,"open"):void 0,this.getHigh=Pt(e.highAccessor,"high"),this.getLow=Pt(e.lowAccessor,"low"),this.getClose=n?Pt(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new At(e.windowSize))}currentTime(){return this.config.clock?.()??Ot()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=Mn(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(e)),void this.yExtent.push(this.getLow(e));this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e));for(const t of this.resolvedRibbons){const n=t.getTop(e),o=t.getBottom(e);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(o)&&this.yExtent.push(o)}}evictDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(e)),void this.yExtent.evict(this.getLow(e));this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e));for(const t of this.resolvedRibbons){const n=t.getTop(e),o=t.getBottom(e);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(o)&&this.yExtent.evict(o)}}rebuildYExtent(){this.yExtent.clear();for(const e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const e of this.buffer)this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e)}ingest(e){if(e.bounded&&this._lastBoundedInsertsRef===e.inserts)return this.updateResults.recordNoop("replace"),!1;const t=this.currentTime();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){this._lastBoundedInsertsRef=e.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=n?Pt(this.config.timeAccessor||this.config.xAccessor,"time"):Pt(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,o="function"==typeof n?n(t):t[n||"x"],r=o instanceof Date,i="string"==typeof o&&Number.isFinite(Lt(o));if(this.xIsDate=r||i,i){const e="string"==typeof n?n:void 0;this.getX=e?t=>It(t[e]):e=>It(n(e))}}An(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const n of e.inserts)_n(this.buffer,n,this.timestampBuffer,t),this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n)}else for(const n of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity??1e5;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"===process.env.NODE_ENV||this.growingCapacityWarned||5e4>this.growingCap||(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${e}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const e=_n(this.buffer,n,this.timestampBuffer,t);this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n),null!=e&&(this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e))}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}computeScene(e){const{config:t,buffer:n}=this,o=this.scales,r=this.lastLayout;if(!this.needsFullRebuild&&!t.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);this.xExtent.dirty&&this.xExtent.recalculate(n,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const i=this.getBufferArray(),s=this.yExtent.extent;let a=kn(this.xExtent.extent,t.xExtent),c=kn(s,t.yExtent);const l=!(!(u=t.yExtent)||null==u[0]||null==u[1]);var u;const d="exact"===t.axisExtent;if("stackedarea"===t.chartType&&!l&&n.size>0){const e=function(e){const{config:t,groups:n,getX:o,getY:r}=e,i="exact"===t.axisExtent;if(t.normalize){const n=[0,i?1:1+t.extentPadding];return{yDomain:n,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:n}}}const s=`${e.bufferSize}:${e.ingestVersion}:${t.baseline??"zero"}:${t.stackOrder??"key"}`;if(e.stackExtentCache&&e.stackExtentCache.key===s)return{yDomain:e.stackExtentCache.yDomain,stackExtentCache:e.stackExtentCache};const a=new Map,c=new Set;let l=0;const u=new Map,d=new Map;for(const e of n){const t=new Map;let n=0;for(const i of e.data){const e=o(i),s=r(i);if(!Number.isFinite(e)||!Number.isFinite(s))continue;t.set(e,(t.get(e)||0)+s),c.add(e),n+=s;const a=(u.get(e)||0)+s;u.set(e,a),a>l&&(l=a)}a.set(e.key,t),d.set(e.key,n)}const h=t.stackOrder??"key",f=(e,t)=>t>e?-1:e>t?1:0;let p,y;if("input"===h)p=n.map(e=>e.key);else if("insideOut"===h){const e=[...n].map(e=>e.key).sort((e,t)=>{const n=(d.get(t)??0)-(d.get(e)??0);return 0!==n?n:f(e,t)}),t=[],o=[];let r=0,i=0;for(const n of e)i>r?(t.push(n),r+=d.get(n)??0):(o.push(n),i+=d.get(n)??0);p=[...o.reverse(),...t]}else p="asc"===h?n.map(e=>e.key).sort((e,t)=>{const n=(d.get(e)??0)-(d.get(t)??0);return 0!==n?n:f(e,t)}):"desc"===h?n.map(e=>e.key).sort((e,t)=>{const n=(d.get(t)??0)-(d.get(e)??0);return 0!==n?n:f(e,t)}):n.map(e=>e.key).sort(f);if("wiggle"===t.baseline||"silhouette"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),n=Ht(e,p,(e,t)=>a.get(e)?.get(t)||0,t.baseline);let o=1/0,r=-1/0;for(const t of e){const e=n.get(t)??0,i=u.get(t)??0;o>e&&(o=e),e+i>r&&(r=e+i)}Number.isFinite(o)&&Number.isFinite(r)||(o=0,r=0);const s=r-o,l=i?0:s>0?s*t.extentPadding:1;y=[o-l,r+l]}else if("diverging"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),[n,o]=function(e,t,n){let o=0,r=0;for(const i of e){let e=0,s=0;for(const o of t){const t=n(o,i)||0;0>t?s+=t:e+=t}o>s&&(o=s),e>r&&(r=e)}return[o,r]}(e,p,(e,t)=>a.get(e)?.get(t)||0),r=o-n,s=i?0:r>0?r*t.extentPadding:1;y=[n-s,o+s]}else y=[0,l+(i?0:l>0?l*t.extentPadding:1)];return{yDomain:y,stackExtentCache:{key:s,yDomain:y}}}({config:t,groups:this.groupData(i),getX:this.getX,getY:this.getY,bufferSize:n.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!l&&n.size>0?c=function(e,t,n,o,r,i,s){const[,a]=function(e,t,n,o,r){const i=pn(e,t,n,o,r);if(0===i.size)return[0,0];let s=0;for(const e of i.values())e.total>s&&(s=e.total);return[0,s]}(e,t,n,o,r);return[0,s?a:a+a*i]}(n,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,d):"waterfall"===t.chartType&&!l&&n.size>0?c=function(e,t,n,o){const[r,i]=function(e,t){let n=0,o=0,r=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(r+=e,n>r&&(n=r),r>o&&(o=r))}return[n,o]}(e,t),s=i-r,a=o?0:s>0?s*n:1;return[Math.min(0,r-Math.abs(a)),Math.max(0,i+Math.abs(a))]}(n,this.getY,t.extentPadding,d):l||c[0]===1/0||(c=function(e,t,n){if(!n.length)return e;let[o,r]=e;for(const e of t)for(const t of n){const n=t.getTop(e),i=t.getBottom(e);Number.isFinite(n)&&(o>n&&(o=n),n>r&&(r=n)),Number.isFinite(i)&&(o>i&&(o=i),i>r&&(r=i))}return[o,r]}(c,i,this.resolvedRibbons),c=function(e,t){const n=e[1]-e[0],o=t.exactMode?0:n>0?n*t.extentPadding:1,r=[null!=t.userMin?e[0]:e[0]-o,null!=t.userMax?e[1]:e[1]+o];return"log"!==t.yScaleType||r[0]>0||0>=t.dataYDomain[0]||t.exactMode||null==t.userMin&&(r[0]=t.dataYDomain[0]/(1+t.extentPadding)),r}(c,{exactMode:d,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:s}));c=function(e,t,n){if(!t||n)return e;const o=t[0],r=t[1];return null==o&&null==r?e:[null!=o?o:e[0],null!=r?r:e[1]]}(c,t.yExtent,!!l),({xDomain:a,yDomain:c}=function(e,t,n){let o=e,r=t;if(o[0]===1/0||o[1]===-1/0)if("time"===n){const e=Date.now();o=[e-864e5,e]}else o=[0,1];return r[0]!==1/0&&r[1]!==-1/0||(r=[0,1]),{xDomain:o,yDomain:r}}(a,c,t.xScaleType)),this.scales=function(e){const{config:t,layout:n,xDomain:o,yDomain:r}=e,i="streaming"===t.runtimeMode,s=Math.max(0,Math.min(t.scalePadding||0,Math.min(n.width,n.height)/2-1));if(i){if("x"==("up"===(a=t.arrowOfTime)||"down"===a?"y":"x")){const e="right"===t.arrowOfTime?[s,n.width-s]:[n.width-s,s];return{x:(0,wn.scaleLinear)().domain(o).range(e),y:Sn(t.yScaleType,r,[n.height-s,s])}}const e="down"===t.arrowOfTime?[s,n.height-s]:[n.height-s,s];return{x:Sn(t.yScaleType,r,[s,n.width-s]),y:(0,wn.scaleLinear)().domain(o).range(e)}}var a;return{x:Sn(t.xScaleType,o,[s,n.width-s]),y:Sn(t.yScaleType,r,[n.height-s,s])}}({config:t,layout:e,xDomain:a,yDomain:c}),this._customLayoutFailedThisBuild=!1;const h=this.buildSceneNodes(e,i);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=o,this.lastLayout=r):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=h,this.config.decay&&this.applyDecay(this.scene,i),this.config.pulse&&this.applyPulse(this.scene,i,this.currentTime()),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const o of e.path)o[0]*=t,o[1]*=n;break;case"area":for(const o of e.topPath)o[0]*=t,o[1]*=n;for(const o of e.bottomPath)o[0]*=t,o[1]*=n;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*n,width:e.clipRect.width*t,height:e.clipRect.height*n}),e.strokeColorBands&&(e.strokeColorBands=e.strokeColorBands.map(e=>({...e,y:e.y*n,height:e.height*n})));break;case"point":case"glyph":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const o=this.scales.x.domain(),r=this.scales.y.domain(),i=this.scales.x.range(),s=this.scales.y.range(),a=Sn,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),l=s[1]>s[0];this.scales={x:a(this.config.xScaleType,o,i[0]>i[1]?[e.width-c,c]:[c,e.width-c]),y:a(this.config.yScaleType,r,l?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(e,t){const{config:n,scales:o}=this;if(!o)return[];if(n.customLayout){const r={data:t,scales:o,dimensions:{width:e.width,height:e.height,margin:n.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:n.themeSemantic??{},categorical:n.themeCategorical??fe},resolveColor:(e,t)=>{const o=this.resolveGroupColor(e);if(o)return o;const r=this.resolveLineStyle(e,t);return r.stroke?r.stroke:"string"==typeof r.fill?r.fill:n.themeSemantic?.primary??"#4e79a7"},config:n.layoutConfig??{},selection:n.layoutSelection??null};let i;try{i=n.customLayout(r)}catch(e){const t=null!==this.lastCustomLayoutResult,o=xn("xy",e,t,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",e);try{n.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,n.layoutSelection??null)}return yn({label:"customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===t.length)return[];const r={scales:o,config:n,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(n.chartType){case"line":return function(e,t){const n=e.groupData(t),o=[],r=e.config.annotations?.filter(rn).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:r,aggregate:i}=Jt(e.ribbons);if(i.length>0&&o.push(...en(e,t,i)),r.length>0)for(const t of n)o.push(...tn(e,t.data,t.key,r))}for(const t of n){const n=e.resolveLineStyle(t.key,t.data[0]),i=Yt(t.data,e.scales,e.getX,e.getY,n,t.key);r&&r.length>0&&(i.colorThresholds=r),e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),o.push(i)}return on(e,n,o),o}(r,t);case"area":return function(e,t){const n=e.groupData(t),o=[];if(e.ribbons&&e.ribbons.length>0){const{perSeries:r,aggregate:i}=Jt(e.ribbons);if(i.length>0&&o.push(...en(e,t,i)),r.length>0)for(const t of n)o.push(...tn(e,t.data,t.key,r))}const r=e.scales.y.domain(),i=r[0],s=e.config.semanticLineStops?.filter(e=>Number.isFinite(e.offset)).map(e=>({value:r[0]+Math.max(0,Math.min(1,e.offset))*(r[1]-r[0]),color:e.color,thresholdType:"greater"})).sort((e,t)=>e.value-t.value),a=s&&s.length>0?(()=>{const t=s.reduce((e,t)=>(e.at(-1)?.value===t.value?e[e.length-1]=t:e.push(t),e),[]),n=[{from:r[0],to:t[0].value}];for(let e=0;t.length>e;e++)n.push({from:t[e].value,to:t[e+1]?.value??r[1],color:t[e].color});return n.map(({from:t,to:n,color:o})=>{const r=e.scales.y(t),i=e.scales.y(n);return{y:Math.min(r,i),height:Math.abs(i-r),color:o}}).filter(e=>e.height>0)})():void 0,c=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),r=Gt(t.data,e.scales,e.getX,e.getY,i,n,t.key,c),l=sn(e.config.gradientFill);l&&(r.fillGradient=l),e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),s&&s.length>0&&(r.colorThresholds=s,r.strokeColorBands=a),o.push(r)}return on(e,n,o),o}(r,t);case"mixed":return function(e,t){const n=e.groupData(t),o=[],r=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){const{perSeries:r,aggregate:i}=Jt(e.ribbons);if(i.length>0&&o.push(...en(e,t,i)),r.length>0)for(const t of n)o.push(...tn(e,t.data,t.key,r))}const i=e.scales.y.domain()[0],s=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n)if(r.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),r=Gt(t.data,e.scales,e.getX,e.getY,i,n,t.key,s),a=sn(e.config.gradientFill);a&&(r.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),o.push(r)}else{const n=e.resolveLineStyle(t.key,t.data[0]),r=Yt(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),o.push(r)}return on(e,n,o),o}(r,t);case"stackedarea":return function(e,t){const n=e.groupData(t),o=e.config.stackOrder??"key",r=()=>n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"===o);else if("key"===o)r();else if("asc"===o||"desc"===o||"insideOut"===o){const t=new Map;for(const o of n){let n=0;for(const t of o.data){const o=e.getX(t),r=e.getY(t);Number.isFinite(o)&&Number.isFinite(r)&&(n+=r)}t.set(o.key,n)}const r=(e,t)=>t>e?-1:e>t?1:0;if("asc"===o)n.sort((e,n)=>{const o=(t.get(e.key)??0)-(t.get(n.key)??0);return 0!==o?o:r(e.key,n.key)});else if("desc"===o)n.sort((e,n)=>{const o=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==o?o:r(e.key,n.key)});else{const e=[...n].sort((e,n)=>{const o=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==o?o:r(e.key,n.key)}),o=[],i=[];let s=0,a=0;for(const n of e)a>s?(o.push(n),s+=t.get(n.key)??0):(i.push(n),a+=t.get(n.key)??0);n.length=0,n.push(...i.reverse(),...o)}}else r();const i=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,s=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:a,stackedTops:c}=function(e,t,n,o,r,i,s,a="zero"){const c=new Set;for(const t of e)for(const e of t.data){const t=n(e);Number.isFinite(t)&&c.add(t)}const l=Array.from(c).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const r of t.data){const t=n(r),i=o(r);Number.isFinite(t)&&Number.isFinite(i)&&e.set(t,(e.get(t)||0)+i)}u.set(t.key,e)}let d;if(i){d=new Map;for(const t of l){let n=0;for(const o of e)n+=u.get(o.key)?.get(t)||0;d.set(t,n||1)}}const h=Ht(l,e.map(e=>e.key),(e,t)=>u.get(e)?.get(t)||0,a),f="diverging"===a&&!i,p=[],y=new Map,g=new Map,m=new Map,x=new Map;for(const e of l)g.set(e,h.get(e)??0),m.set(e,0),x.set(e,0);for(const n of e){const e=u.get(n.key),o=new Map;let a=[],c=[];const h=()=>{if(a.length>=2){const e={type:"area",topPath:a,bottomPath:c,style:r(n.key,n.data[0]),datum:n.data,group:n.key};s&&(e.curve=s),p.push(e)}a=[],c=[]};for(const n of l){const r=e.has(n);let s,l,u=r?e.get(n):0;if(i&&r&&(u/=d.get(n)),!r||!Number.isFinite(u)||0===u){h();continue}f?u>0?(s=m.get(n),l=s+u,m.set(n,l)):(s=x.get(n),l=s+u,x.set(n,l)):(s=g.get(n),l=s+u,g.set(n,l));const p=t.x(n);c.push([p,t.y(s)]),a.push([p,t.y(l)]),o.set(n,l)}h(),y.set(n.key,o)}return{nodes:p,stackedTops:y}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,i,s),l=a;if(e.config.pointStyle){const t=new WeakMap;for(const o of n){const n=c.get(o.key);if(n)for(const r of o.data){const o=e.getX(r),i=e.getY(r);null==o||Number.isNaN(o)||null==i||Number.isNaN(i)||!n.has(o)||t.set(r,n.get(o))}}const o=n=>t.get(n)??e.getY(n);on(e,n,l,o)}return l}(r,t);case"scatter":case"bubble":return function(e,t){const n=[],o="bubble"===e.config.chartType?10:5,r=e.config.sizeRange||[3,15];let i=null;if(e.getSize&&!e.config.pointStyle){const n=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(n.length>0){let e=1/0,t=-1/0;for(const o of n)e>o&&(e=o),o>t&&(t=o);i=n=>e===t?(r[0]+r[1])/2:r[0]+(n-e)/(t-e)*(r[1]-r[0])}}const s=e.getColor?e.resolveColorMap(t):null,a=e.config.themeSemantic?.primary||"#4e79a7",c=e.getSymbol,l=e.config.symbolMap,u=new Map;let d=0;const h=e=>{const t=l?.[e];if(t)return t;let n=u.get(e);return n||(n=ln[d%ln.length],d++,u.set(e,n)),n};for(const r of t){let t=e.config.pointStyle?e.config.pointStyle(r):{fill:a,opacity:.8},l=t.r||o;if(i&&e.getSize){const t=e.getSize(r);null==t||Number.isNaN(t)||(l=i(t))}if(s&&e.getColor&&!t.fill){const n=e.getColor(r);n&&s.has(n)&&(t={...t,fill:s.get(n)})}const u=e.getPointId?e.getPointId(r)+"":void 0;if(c){const o=h(c(r)+""),i=Xt(r,e.scales,e.getX,e.getY,Math.PI*l*l,o,t,u);i&&n.push(i)}else{const o=Vt(r,e.scales,e.getX,e.getY,l,t,u);o&&n.push(o)}}return n}(r,t);case"heatmap":return function(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){const o=Math.max(1,Math.floor(e.config.heatmapXBins??20)),r=Math.max(1,Math.floor(e.config.heatmapYBins??20)),i=e.config.heatmapAggregation??"count",s=Pt(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[a,c]=e.scales.x.domain(),[l,u]=e.scales.y.domain(),d=(c-a||1)/o,h=(u-l||1)/r,f=o*r;if(f>1e6)return[];const p=new Int32Array(f),y=new Float64Array(f);for(let n=0;t.length>n;n++){const i=t[n],c=e.getX(i),u=e.getY(i);if(!isFinite(c)||!isFinite(u))continue;const f=Math.min(Math.floor((c-a)/d),o-1),g=Math.min(Math.floor((u-l)/h),r-1);if(0>f||0>g)continue;const m=g*o+f;p[m]++;const x=s(i);y[m]+=isFinite(x)?x:0}let g=1/0,m=-1/0;for(let e=0;f>e;e++){if(0===p[e])continue;let t;switch(i){case"sum":t=y[e];break;case"mean":t=y[e]/p[e];break;default:t=p[e]}g>t&&(g=t),t>m&&(m=t)}if(!isFinite(g))return[];const x=m-g||1,b=n.width/o,v=n.height/r,w=e.config.showValues,k=e.config.heatmapValueFormat,S=[];for(let t=0;r>t;t++){const n=t*o;for(let s=0;o>s;s++){const o=n+s;if(0===p[o])continue;let c;switch(i){case"sum":c=y[o];break;case"mean":c=y[o]/p[o];break;default:c=p[o]}const u=(c-g)/x,f={xi:s,yi:t,value:c,count:p[o],sum:y[o],xCenter:a+(s+.5)*d,yCenter:l+(t+.5)*h,agg:i};S.push(fn(Kt(s*b,(r-1-t)*v,b,v,`rgb(${220-(180*u+.5)|0},${220-(100*u+.5)|0},${255-(50*u+.5)|0})`,f,w?{value:c,showValues:!0,valueFormat:k}:void 0),f,e))}}return S}(e,t,n);if(0===t.length)return[];const o=Pt(e.config.valueAccessor,"value"),r=jt(e.config.xAccessor,"x"),i=jt(e.config.yAccessor,"y"),s=new Map,a=new Map,c=Array(t.length),l=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],o=r(n),u=i(n);c[e]=o,l[e]=u,s.has(o)||s.set(o,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,d=a.size;if(0===u||0===d)return[];const h=Array.from(s.keys()),f=Array.from(a.keys()),p=h.every(e=>"number"==typeof e&&!isNaN(e)),y=f.every(e=>"number"==typeof e&&!isNaN(e));if(p){h.sort((e,t)=>Number(e)-Number(t)),s.clear();for(let e=0;h.length>e;e++)s.set(h[e],e)}if(y){f.sort((e,t)=>Number(e)-Number(t)),a.clear();for(let e=0;f.length>e;e++)a.set(f[e],e)}const g=new Float64Array(t.length),m=new Float64Array(t.length),x=Array(t.length),b=new Map;let v=0;for(let e=0;t.length>e;e++){const n=t[e],r=s.get(c[e]),i=a.get(l[e]);if(void 0===r||void 0===i)continue;const d=o(n),h=i*u+r,f=b.get(h);let p;void 0!==f?p=f:(p=v++,b.set(h,p)),g[p]=h,m[p]=d,x[p]=n}let w=1/0,k=-1/0;for(let e=0;v>e;e++){const t=m[e];isFinite(t)&&(w>t&&(w=t),t>k&&(k=t))}if(!isFinite(w)||!isFinite(k))return[];const S=function(e){const t=e in ee?e:"blues";let n=hn.get(t);if(n)return n;n=Array(256);const o=te(t);for(let e=0;256>e;e++)n[e]=o(e/255);return hn.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),A=255/(k-w||1),M=n.width/u,_=n.height/d,P=e.config.showValues,j=e.config.heatmapValueFormat,R=[];for(let t=0;v>t;t++){const n=m[t];if(!isFinite(n))continue;const o=g[t],r=o%u,i=x[t];R.push(fn(Kt(r*M,(d-1-(o-r)/u)*_,M,_,S[Math.min((n-w)*A+.5|0,255)],i,P?{value:n,showValues:!0,valueFormat:j}:void 0),i,e))}return R}(r,t,e);case"bar":{const e=function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const n=pn(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===n.size)return{nodes:[],binBoundaries:[]};let o=null;if(e.getCategory){const t=new Set;for(const e of n.values())for(const n of e.categories.keys())t.add(n);const r=e.config.barColors?Object.keys(e.config.barColors):[],i=new Set(r),s=Array.from(t).filter(e=>!i.has(e)).sort(),a=r.filter(e=>t.has(e)),c=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===c?o=e.barCategoryCache.order:(o=[...a,...s],e.barCategoryCache={key:c,order:o})}const r=[],i=e.scales,[s,a]=i.x.domain(),c=e.config.barStyle,l=e.config.themeSemantic?.primary,u=c?.gap,d="number"!=typeof u||0>u?1:u,h={};c?.stroke&&(h.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(h.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(h.opacity=c.opacity);for(const t of n.values()){const n=Math.max(t.start,s),u=Math.min(t.end,a);if(n>=u)continue;const f=i.x(n),p=i.x(u),y=Math.abs(p-f),g=y>d+1?d:0,m=Math.min(f,p)+g/2,x=Math.max(y-g,1);if(x>0)if(o&&t.categories.size>0){let n=0;for(const s of o){const o=t.categories.get(s)||0;if(0===o)continue;const a=i.y(n),u=i.y(n+o);r.push(Ut(m,Math.min(a,u),x,Math.abs(a-u),{fill:e.config.barColors?.[s]||c?.fill||l||"#4e79a7",...h},{binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:o},s)),n+=o}}else{const e=i.y(0),n=i.y(t.total);r.push(Ut(m,Math.min(e,n),x,Math.abs(e-n),{fill:c?.fill||l||"#007bff",...h},{binStart:t.start,binEnd:t.end,total:t.total}))}}const f=new Set;for(const e of n.values())f.add(e.start),f.add(e.end);return{nodes:r,binBoundaries:Array.from(f).sort((e,t)=>e-t)}}(r,t);return this._barCategoryCache=r.barCategoryCache??null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){const n=[],o=e.config.swarmStyle||{},r=o.radius??3,i=o.fill??e.config.themeSemantic?.primary??"#007bff",s=o.opacity??.7,a=o.stroke,c=o.strokeWidth;for(const o of t){const t=e.getX(o),l=e.getY(o);if(null==l||Number.isNaN(l))continue;const u=e.scales.x(t),d=e.scales.y(l);let h=i;if(e.getCategory){const t=e.getCategory(o);h=e.config.barColors?.[t]||h}const{r:f,...p}=e.config.pointStyle?.(o)??{},y={type:"point",x:u,y:d,r:f??r,style:{fill:h,opacity:s,stroke:a,strokeWidth:c,...p},datum:o};e.getPointId&&(y.pointId=e.getPointId(o)+""),n.push(y)}return n}(r,t);case"waterfall":return function(e,t,n){const o=[],r=e.scales,i=e.config.waterfallStyle,s=t.filter(t=>{const n=e.getY(t),o=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=o&&isFinite(o)});if(0===s.length)return o;const a=i?.positiveColor??e.config.themeSemantic?.success??"#28a745",c=i?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",l=i?.gap??1,u=i?.stroke,d=i?.strokeWidth,h=i?.opacity;let f=0;for(let t=0;s.length>t;t++){const p=s[t],y=e.getX(p),g=e.getY(p),m=f+g;let x;x=s.length-1>t?e.getX(s[t+1])-y:t>0?y-e.getX(s[t-1]):0;const b=r.x(y),v=0!==x?r.x(y+x):b+n.width/10,w=Math.min(b,v)+l/2,k=Math.max(b,v)-l/2-w;if(0>=k){f=m;continue}const S=r.y(f),A=r.y(m),M=Math.min(S,A),_=Math.abs(S-A),P={fill:0>g?c:a,stroke:u,strokeWidth:d};null!=h&&(P.opacity=h),o.push(Ut(w,M,k,_,P,{...p,baseline:f,cumEnd:m,delta:g,_connectorStroke:i?.connectorStroke,_connectorWidth:i?.connectorWidth})),f=m}return o}(r,t,e);case"candlestick":return function(e,t,n){if(!e.getHigh||!e.getLow||!e.scales)return[];const o=e.config.candlestickRangeMode??!1;if(!(o||e.getOpen&&e.getClose))return[];const r=[],i=e.config.candlestickStyle||{},s=i.rangeColor||"#6366f1",a=o?s:i.upColor||"#28a745",c=o?s:i.downColor||"#dc3545",l=o?s:i.wickColor||"#333",u=i.wickWidth||(o?2:1),d=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let h=i.bodyWidth??0;if(null==i.bodyWidth)if(d.length>1){let t=1/0;for(let n=1;d.length>n;n++){const o=Math.abs(e.scales.x(d[n])-e.scales.x(d[n-1]));o>0&&t>o&&(t=o)}h=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else h=6;for(const i of t){const t=e.getX(i);if(null==t||Number.isNaN(t))continue;const s=e.getHigh(i),d=e.getLow(i);if(null==s||Number.isNaN(s)||null==d||Number.isNaN(d))continue;const f=o?s:e.getOpen(i),p=o?d:e.getClose(i);if(!o&&[f,p].some(e=>null==e||Number.isNaN(e)))continue;const y=p>=f,g={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(f),closeY:e.scales.y(p),highY:e.scales.y(s),lowY:e.scales.y(d),bodyWidth:h,upColor:a,downColor:c,wickColor:l,wickWidth:u,isUp:y,datum:i};o&&(g.isRange=!0,g.dotRadius=Math.max(2,Math.min(h/2,.12*n.height))),r.push(g)}return r}(r,t,e);default:return[]}}resolveBoundsStyle(e,t){return function(e,t,n,o){const r=e.boundsStyle;return"function"==typeof r?r(n||{},t):r&&"object"==typeof r?r:{fill:o(t,n).stroke||e.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?Dt(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const t=Bt(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&function(e,t,n,o=Bt(n)){const r=n.length;if(r>1)for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const i=Array(t.length);let s=!1;for(let n=0;t.length>n;n++){const a=o.get(t[n]);null!=a?(i[n]=Dt(e,a,r),1>i[n]&&(s=!0)):i[n]=1}s&&(n._decayOpacities=i);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],i=n.topPath?n.topPath.length:t.length;if(2>i)continue;if(t.length===i){const s=Array(i);let a=!1;for(let n=0;t.length>n;n++){const i=o.get(t[n]);null!=i?(s[n]=Dt(e,i,r),1>s[n]&&(a=!0)):s[n]=1}a&&(n._decayOpacities=s)}else{let s=1;for(const n of t){const t=o.get(n);if(null!=t){const n=Dt(e,t,r);s>n&&(s=n)}}if(1>s){const e=Array(i);e.fill(s),n._decayOpacities=e}}continue}const t=o.get(n.datum);if(null==t)continue;const i=Dt(e,t,r);"heatcell"===n.type?n.style={opacity:i}:"candlestick"===n.type?n._decayOpacity=i:n.style={...n.style,opacity:(n.style?.opacity??1)*i}}}(this.config.decay,e,t,this.getDatumIndexMap(t))}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&Wt(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,o){n.clear(),o.clear();for(let r=0;t.length>r;r++){const i=t[r],s=qt(e,i,r);s&&("point"===i.type?n.set(s,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"glyph"===i.type?n.set(s,{x:i.x,y:i.y,r:i.size,opacity:i.style.opacity,glyph:i.glyph}):"rect"===i.type?n.set(s,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}):"heatcell"===i.type?n.set(s,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style?.opacity}):"candlestick"===i.type?n.set(s,{x:i.x,y:i.openY,w:i.bodyWidth,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY,opacity:i.style?.opacity}):"line"===i.type?o.set(s,{path:i.path.map(e=>[e[0],e[1]]),opacity:i.style?.opacity}):"area"===i.type&&o.set(s,{topPath:i.topPath.map(e=>[e[0],e[1]]),bottomPath:i.bottomPath.map(e=>[e[0],e[1]]),opacity:i.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const e=this.scales?.y(0)??0;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],o=qt(this.transitionContext,n,t);o&&("point"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,r:0,opacity:0}):"rect"===n.type?this.prevPositionMap.set(o,{x:n.x,y:e,w:n.w,h:0,opacity:n.style.opacity??1}):"heatcell"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:0}):"line"===n.type?(n._introClipFraction=0,this.prevPathMap.set(o,{path:n.path.map(e=>[e[0],e[1]]),opacity:n.style.opacity})):"area"===n.type&&(n._introClipFraction=0,this.prevPathMap.set(o,{topPath:n.topPath.map(e=>[e[0],e[1]]),bottomPath:n.bottomPath.map(e=>[e[0],e[1]]),opacity:n.style.opacity})))}}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,o,r,i=Ot()){if(0===o.size&&0===r.size)return n;const s=t.duration??300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let a=!1;const c=new Set,l=new Set;for(let t=0;n.scene.length>t;t++){const i=n.scene[t],s=qt(e,i,t);if(!s)continue;if(i._transitionKey=s,"line"===i.type||"area"===i.type){const e=r.get(s);if(e){if(l.add(s),"line"===i.type&&e.path&&e.path.length===i.path.length){i._targetPath=i.path.map(e=>[e[0],e[1]]),i._prevPath=e.path;for(let t=0;i.path.length>t;t++)i.path[t]=[e.path[t][0],e.path[t][1]];a=!0}else if("area"===i.type&&e.topPath&&e.bottomPath&&e.topPath.length===i.topPath.length&&e.bottomPath.length===i.bottomPath.length){i._targetTopPath=i.topPath.map(e=>[e[0],e[1]]),i._targetBottomPath=i.bottomPath.map(e=>[e[0],e[1]]),i._prevTopPath=e.topPath,i._prevBottomPath=e.bottomPath;for(let t=0;i.topPath.length>t;t++)i.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;i.bottomPath.length>t;t++)i.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];a=!0}i._targetOpacity=i.style.opacity??1,i._startOpacity=e.opacity??i.style.opacity??1}else i._targetOpacity=i.style.opacity??1,i._startOpacity=0,i.style={...i.style,opacity:0},a=!0;continue}const u=o.get(s);if("point"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,r:i.r};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.r||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.r,i.x=u.x,i.y=u.y,i.r=u.r??i.r,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("glyph"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,size:i.size};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.size||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.size,i.x=u.x,i.y=u.y,i.size=u.r??i.size,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("rect"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("heatcell"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=i.style?.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,a=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},a=!0;else if("candlestick"===i.type)if(u&&null!=u.openY){c.add(s);const e={x:i.x,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY};i._targetOpacity=i.style?.opacity??1,(u.x!==e.x||u.openY!==e.openY||u.closeY!==e.closeY||u.highY!==e.highY||u.lowY!==e.lowY)&&(i._targetX=e.x,i._targetOpenY=e.openY,i._targetCloseY=e.closeY,i._targetHighY=e.highY,i._targetLowY=e.lowY,i.x=u.x,i.openY=u.openY,i.closeY=u.closeY??i.closeY,i.highY=u.highY??i.highY,i.lowY=u.lowY??i.lowY,a=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},a=!0}for(const[e,t]of r)if(!l.has(e))if(e.startsWith("l:")&&t.path){const o={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(o),a=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const o={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(o),a=!0}for(const[e,t]of o)if(!c.has(e)){if(e.startsWith("p:"))n.exitNodes.push({type:"point",x:t.x,y:t.y,r:t.r??3,style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("g:")&&t.glyph)n.exitNodes.push({type:"glyph",x:t.x,y:t.y,size:t.r??12,glyph:t.glyph,color:"#999",accent:"#999",style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))n.exitNodes.push({type:"rect",x:t.x,y:t.y,w:t.w??0,h:t.h??0,style:{opacity:t.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("h:"))n.exitNodes.push({type:"heatcell",x:t.x,y:t.y,w:t.w??0,h:t.h??0,fill:"#999",datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e});else if(e.startsWith("c:")){const o=t.openY??t.y;n.exitNodes.push({type:"candlestick",x:t.x,openY:o,closeY:t.closeY??o,highY:t.highY??o,lowY:t.lowY??o,bodyWidth:t.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e})}a=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),a&&(n.activeTransition={startTime:i,duration:s}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(e,t,n,o){if(!n.activeTransition)return!1;const r=zt(e,n.activeTransition),i=$t(r,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of n.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0;e.style.opacity=Et(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=Et(n.x,e._targetX,i),e.y=Et(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.r=Et(n.r,e._targetR,i))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0;e.style.opacity=Et(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=Et(n.x,e._targetX,i),e.y=Et(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.size=Et(n.r,e._targetR,i))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0;e.style.opacity=Et(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=Et(n.x,e._targetX,i),e.y=Et(n.y,e._targetY,i),void 0!==n.w&&(e.w=Et(n.w,e._targetW,i)),void 0!==n.h&&(e.h=Et(n.h,e._targetH,i))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0;e.style={...e.style||{},opacity:Et(n?n.opacity??1:0,e._targetOpacity,i)}}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=Et(n.x,e._targetX,i),e.y=Et(n.y,e._targetY,i),void 0!==n.w&&(e.w=Et(n.w,e._targetW,i)),void 0!==n.h&&(e.h=Et(n.h,e._targetH,i))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0;e.style={...e.style||{},opacity:Et(n?n.opacity??1:0,e._targetOpacity,i)}}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=Et(n.x,e._targetX,i),void 0!==n.openY&&(e.openY=Et(n.openY,e._targetOpenY,i)),void 0!==n.closeY&&(e.closeY=Et(n.closeY,e._targetCloseY,i)),void 0!==n.highY&&(e.highY=Et(n.highY,e._targetHighY,i)),void 0!==n.lowY&&(e.lowY=Et(n.lowY,e._targetLowY,i))}else if("line"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Et(e._startOpacity??0,e._targetOpacity,i)}),void 0!==e._introClipFraction&&(e._introClipFraction=i);const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let o=0;e.path.length>o;o++)e.path[o][0]=Et(t[o][0],n[o][0],i),e.path[o][1]=Et(t[o][1],n[o][1],i)}else if("area"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Et(e._startOpacity??0,e._targetOpacity,i)}),void 0!==e._introClipFraction&&(e._introClipFraction=i);const t=e._prevTopPath,n=e._prevBottomPath,o=e._targetTopPath,r=e._targetBottomPath;if(t&&o&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=Et(t[n][0],o[n][0],i),e.topPath[n][1]=Et(t[n][1],o[n][1],i);if(n&&r&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=Et(n[t][0],r[t][0],i),e.bottomPath[t][1]=Et(n[t][1],r[t][1],i)}}if(r>=1){for(const e of n.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style="line"===e.type||"area"===e.type?{...e.style,opacity:0===t?0:t}:{...e.style||{},opacity:0===t?0:t},e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("glyph"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.size=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("candlestick"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,void 0!==e._targetOpenY&&(e.openY=e._targetOpenY),void 0!==e._targetCloseY&&(e.closeY=e._targetCloseY),void 0!==e._targetHighY&&(e.highY=e._targetHighY),void 0!==e._targetLowY&&(e.lowY=e._targetLowY),e._targetX=void 0,e._targetOpenY=void 0,e._targetCloseY=void 0,e._targetHighY=void 0,e._targetLowY=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,n}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const e of this.scene)"line"!==e.type&&"area"!==e.type||(e._introClipFraction=void 0)}groupData(e){const{result:t,cache:n}=function(e,t,n,o){if(o&&o.version===n&&o.group===t&&o.data===e)return{result:o.result,cache:o};let r;if(t){const n=new Map;for(const o of e){const e=t(o);n.has(e)||n.set(e,[]),n.get(e).push(o)}r=Array.from(n.entries()).map(([e,t])=>({key:e,data:t}))}else r=[{key:"_default",data:e}];return{result:r,cache:{version:n,group:t,data:e,result:r}}}(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=n,t}resolveColorMap(e){const{map:t,cache:n}=function(e,t,n,o,r){if(r&&r.version===o)return{map:r.map,cache:r};const i=new Set;if(t)for(const n of e){const e=t(n);e&&i.add(e)}const s=Array.from(i).sort(),a=s.join("\0");if(r&&r.key===a){const e={...r,version:o};return{map:e.map,cache:e}}const c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical||fe,l=new Map;for(let e=0;s.length>e;e++)l.set(s[e],c[e%c.length]);return{map:l,cache:{key:a,map:l,version:o}}}(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=n,t}resolveLineStyle(e,t){return function(e,t,n,o){const r=e.lineStyle;if("function"==typeof r){const e=r(n||{},t);if(e&&!e.stroke&&t){const n=o(t);if(n)return{...e,stroke:n}}return e}const i=e.themeSemantic?.primary;return r&&"object"==typeof r?{stroke:r.stroke||i||"#007bff",strokeWidth:r.strokeWidth||2,strokeDasharray:r.strokeDasharray,fill:r.fill,fillOpacity:r.fillOpacity,opacity:r.opacity}:{stroke:o(t)||i||"#007bff",strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return function(e,t,n,o){if(e.areaStyle){const r=e.areaStyle(n||{});if(r&&!r.fill&&t){const e=o(t);if(e)return{...r,fill:e,stroke:r.stroke||e}}return r}const r=e.lineStyle;if("function"==typeof r){const e=r(n||{},t);if(e&&!e.fill&&t){const n=o(t);if(n)return{...e,fill:n,stroke:e.stroke||n}}return e}const i=e.themeSemantic?.primary;if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||i||"#4e79a7",fillOpacity:r.fillOpacity??.7,stroke:r.stroke||i||"#4e79a7",strokeWidth:r.strokeWidth||2};const s=o(t)||i||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(t){const{color:n,groupColorCounter:o}=function(e){const{group:t,colorMapCache:n,groupColorMap:o,groupColorMapCap:r,config:i}=e;let{groupColorCounter:s}=e;if(n){const e=n.map.get(t);if(e)return{color:e,groupColorCounter:s}}const a=o.get(t);if(a)return{color:a,groupColorCounter:s};const c=(Array.isArray(i.colorScheme)&&i.colorScheme.length>0?i.colorScheme:null)||(Array.isArray(i.themeCategorical)&&i.themeCategorical.length>0?i.themeCategorical:null)||fe;if(0===c.length)return{color:null,groupColorCounter:s};const l=c[s%c.length];if(s++,o.set(t,l),o.size>r){const e=o.keys().next().value;void 0!==e&&o.delete(e)}return{color:l,groupColorCounter:s}}({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:e.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=o,n}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=Tt(e),n=this.getPointId,o=e=>t.has(n(e));Pn(this.buffer,this.timestampBuffer,o);const r=this.buffer.remove(o);if(0===r.length)return this.updateResults.recordNoop("remove"),r;for(const e of r)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",r.length),r}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=Tt(e),o=this.getPointId,r=new Set;this.buffer.forEach((e,t)=>{n.has(o(e))&&r.add(t)});const i=this.buffer.update(e=>n.has(o(e)),t);if(0===i.length)return this.updateResults.recordNoop("update"),i;for(const e of i)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.buffer.forEach((e,t)=>{r.has(t)&&(this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",i.length),i}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(e,t){const n=this._customRestyle;if(n)for(const o of e){const e=this._baseStyles.get(o)??o.style??{},r=n(o,t);o.style=r?{...e,...r}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(e){const t={...this.config},n=Object.keys(e).filter(n=>e[n]!==t[n]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in e||"colorScheme"in e)&&(this._barCategoryCache=null),("normalize"in e||"extentPadding"in e||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e||"boundsAccessor"in e||"band"in e||"y0Accessor"in e||"openAccessor"in e||"highAccessor"in e||"lowAccessor"in e||"closeAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let o=!1,r=!1;Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();const i="chartType"in e&&e.chartType!==t.chartType||"runtimeMode"in e&&e.runtimeMode!==t.runtimeMode;if(i||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){const e=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,n=e&&this.config.valueAccessor||this.config.yAccessor,s=e&&t.valueAccessor||t.yAccessor,a=i||!_t(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),c=i||!_t(n,s);(a||c)&&(e?(this.getX=Pt(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Pt(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Pt(this.config.xAccessor,"x"),this.getY=Pt(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=vn(this.config)),o=!0,r=!0)}if("groupAccessor"in e&&!_t(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?Rt(this.config.groupAccessor):void 0,o=!0),"categoryAccessor"in e&&!_t(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?Rt(this.config.categoryAccessor):void 0,o=!0),"sizeAccessor"in e&&!_t(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Pt(this.config.sizeAccessor,"size"):void 0,o=!0),"symbolAccessor"in e&&!_t(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Rt(this.config.symbolAccessor):void 0,o=!0),"colorAccessor"in e&&!_t(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Rt(this.config.colorAccessor):void 0,o=!0),"y0Accessor"in e&&!_t(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?Pt(this.config.y0Accessor,"y0"):void 0,o=!0,r=!0),("boundsAccessor"in e&&!_t(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=vn(this.config),o=!0,r=!0),"pointIdAccessor"in e&&!_t(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?Rt(this.config.pointIdAccessor):void 0,o=!0),"candlestick"===this.config.chartType&&(i||"openAccessor"in e&&!_t(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!_t(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!_t(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!_t(e.lowAccessor,t.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?Pt(this.config.openAccessor,"open"):void 0,this.getHigh=Pt(this.config.highAccessor,"high"),this.getLow=Pt(this.config.lowAccessor,"low"),this.getClose=t?Pt(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,o=!0,r=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(o=!0,r=!0),!o){const n=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const r of n)if(e[r]!==t[r]){o=!0;break}}o&&(r&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(n)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};to.GROUP_COLOR_MAP_CAP=1e3;var no=to;zn(no);var oo=require("react"),ro={sceneGeometry:0,layout:0,domain:0};function io(e){const{domain:t,layout:n,sceneGeometry:o}=e.revisions;return{domain:t,layout:n,sceneGeometry:o}}function so(e,t){return{sceneGeometry:Math.max(e.sceneGeometry,t.sceneGeometry),layout:Math.max(e.layout,t.layout),domain:Math.max(e.domain,t.domain)}}var ao="production"!==process.env.NODE_ENV,co={revisions:ro,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},lo=class{constructor(e="scene host"){this.hostName=e,this.lastConsumed=ro,this.lastObserved=ro,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}observeUpdateResult(e){ao&&(this.lastObserved=so(this.lastObserved,io(e)))}beforeCompute(e,t){if(!ao)return co;const n=so(io(e),this.lastObserved),o=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),r=!((i=n).sceneGeometry===(s=this.lastConsumed).sceneGeometry&&i.layout===s.layout&&i.domain===s.domain);var i,s;return{revisions:n,signature:o,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:r,warnUnconsumed:!t&&r&&this.lastUnconsumedWarning!==o}}afterCompute(e,t,n){if(ao){if(t&&e.wasUnconsumed&&(this.lastConsumed=e.revisions),e.warnUnconsumed&&!t)return console.warn(`[semiotic] ${this.hostName} observed scene-affecting revisions without a scene rebuild: ${e.signature}.`),void(this.lastUnconsumedWarning=e.signature);t&&e.sawSignals&&!e.wasUnconsumed&&!n&&this.lastDuplicateWarning!==e.signature?(console.warn(`[semiotic] ${this.hostName} performed scene rebuild with unchanged scene revisions: ${e.signature}.`),this.lastDuplicateWarning=e.signature):t&&!e.sawSignals&&(this.lastDuplicateWarning="")}}},uo=(0,oo.memo)(function({store:e,diagnostics:t}){return(0,oo.useEffect)(()=>{const n=()=>t.observeUpdateResult(e.getUpdateSnapshot());return n(),e.subscribeUpdateResult(n)},[t,e]),null}),ho=y(require("react"));function fo(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:ho.createElement(ho.Fragment,null,...t)}var po=require("react");function yo(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function go(e,t=30){return Math.max((e??4)+5,12,t)}function mo(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function xo(e,t){const n=mo(e);if(!n)return!1;const o=mo(t);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}var bo=[40,40],vo=[.5,.5];function wo(e,t){const[n,o]=e.viewBox??bo,[r,i]=e.anchor??vo,s=o>0?o:1,a=Math.max(0,t)/s,c=(n>0?n:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-r*c,offsetY:-i*l}}function ko(e,t,n,o){if("none"!==e)return"color"===e||null==e?t??o:"accent"===e?n:e}var So=null;function Ao(e){if("undefined"==typeof Path2D)return null;So||(So=new Map);const t=So.get(e);if(t)return t;const n=new Path2D(e);return So.size>1024&&So.clear(),So.set(e,n),n}function Mo(e,t,n=0,o="horizontal"){const[r,i]=e.viewBox??bo,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a>s?s>0||1>a?"vertical"===o?{x:0,y:i*(1-a),width:r,height:i*(a-s)}:{x:r*s,y:0,width:r*(a-s),height:i}:null:{x:0,y:0,width:0,height:0}}function _o(e,t){const n=wo(e,t);return{centerDx:n.offsetX+n.width/2,centerDy:n.offsetY+n.height/2,halfWidth:n.width/2,halfHeight:n.height/2,radius:Math.hypot(n.width,n.height)/2}}function Po(e,t,n,o,r,i=e=>e){for(const s of t.parts){const t=Ao(s.d);if(!t)continue;const a=s.opacity??1,c=e.globalAlpha;1!==a&&(e.globalAlpha=c*a);const l=r?"none"===s.fill?void 0:r:ko(s.fill,n,o);l&&(e.fillStyle=i(l),e.fill(t));const u=r?s.stroke&&"none"!==s.stroke?r:void 0:ko(s.stroke??"none",n,o);u&&(e.strokeStyle=i(u),e.lineWidth=s.strokeWidth??1,e.lineCap=s.strokeLinecap??"butt",e.lineJoin=s.strokeLinejoin??"miter",e.stroke(t)),1!==a&&(e.globalAlpha=c)}}var jo=new WeakMap,Ro=0,Co=!1,Lo=null,Io=null;function To(e,t){if(!t)return t;const n=function(e){const t=e.trim();if(!t.startsWith("var(")||!t.endsWith(")"))return null;const n=t.slice(4,-1),o=n.indexOf(",");if(-1===o){const e=n.trim();return e.startsWith("--")?{name:e}:null}const r=n.slice(0,o).trim(),i=n.slice(o+1).trim();return r.startsWith("--")?{name:r,fallback:i||void 0}:null}(t);if(!n)return t;const o=()=>n.fallback?To(e,n.fallback):t,r=e.canvas;if(!r)return o();!function(){if(Co)return;if("undefined"==typeof window||"undefined"==typeof document)return;Co=!0;const e=()=>{Ro++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"],subtree:!0}),"function"==typeof window.matchMedia)try{Lo=window.matchMedia("(prefers-color-scheme: dark)"),Io=e,"function"==typeof Lo.addEventListener?Lo.addEventListener("change",Io):"function"==typeof Lo.addListener&&Lo.addListener(Io)}catch{}}();let i=jo.get(r);i&&i.version===Ro||(i={version:Ro,map:new Map},jo.set(r,i));const s=i.map.get(t);if(void 0!==s)return s;const a=getComputedStyle(r).getPropertyValue(n.name).trim()||o()||t;return i.map.set(t,a),a}function $o(e){return{type:"hatch",background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle}}var zo=null;var Eo=require("react/jsx-runtime");function Oo(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function Do(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}var Bo=new Map;function Fo(e,t){const{background:n="transparent",stroke:o="#000",lineWidth:r=1.5,spacing:i=6,angle:s=45,lineOpacity:a=1}=e,c=Math.max(8,Math.ceil(2*i));return(0,Eo.jsxs)("pattern",{id:t,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[n&&"transparent"!==n&&(0,Eo.jsx)("rect",{width:c,height:c,fill:n}),(0,Eo.jsx)("line",{x1:0,y1:0,x2:0,y2:c,stroke:o,strokeWidth:r,strokeOpacity:a}),(0,Eo.jsx)("line",{x1:i,y1:0,x2:i,y2:c,stroke:o,strokeWidth:r,strokeOpacity:a})]},t)}function No(e,t,n="#4e79a7"){if(Oo(e)){const n=function(e,t){let n=2166136261;const o=Do(t);for(let e=0;o.length>e;e++)n^=o.charCodeAt(e),n=Math.imul(n,16777619);return`${e}-hatch-${(n>>>0).toString(36)}`}(t,e);return{fill:`url(#${n})`,def:Fo(e,n)}}return e&&"string"==typeof e?{fill:e}:{fill:n}}var Wo=require("d3-shape");function qo(e){switch(e){case"monotoneX":return Wo.curveMonotoneX;case"monotoneY":return Wo.curveMonotoneY;case"cardinal":return Wo.curveCardinal;case"catmullRom":return Wo.curveCatmullRom;case"step":return Wo.curveStep;case"stepBefore":return Wo.curveStepBefore;case"stepAfter":return Wo.curveStepAfter;case"basis":return Wo.curveBasis;case"natural":return Wo.curveNatural;default:return null}}function Yo(e,t,n){if(null==t)return n;if(Oo(t)){const o=function(e,t){const n="undefined"!=typeof window&&window.devicePixelRatio||1,o=`${Do(e)}@${n}`,r=Bo.get(o);if(void 0!==r)return r;const i=function(e={},t){const{background:n="transparent",stroke:o="#000",lineWidth:r=1.5,spacing:i=6,angle:s=45}=e,a={background:n,stroke:o,lineWidth:r,spacing:i,angle:s},c=Math.max(8,Math.ceil(2*i));let l;try{l=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(zo||(zo=document.createElement("canvas")),zo.width=e,zo.height=e,zo)}(c)}catch{return $o(a)}const u=l.getContext("2d");if(!u)return $o(a);n&&"transparent"!==n?(u.fillStyle=n,u.fillRect(0,0,c,c)):u.clearRect(0,0,c,c),u.strokeStyle=o,u.lineWidth=r,u.lineCap="square";const d=s*Math.PI/180;if(45===s||-45===s){const e=s>0?1:-1;for(let t=-c;2*c>=t;t+=i)u.beginPath(),u.moveTo(t,0),u.lineTo(t+e*c,c),u.stroke()}else{u.save(),u.translate(c/2,c/2),u.rotate(d);const e=2*c;for(let t=-e;e>=t;t+=i)u.beginPath(),u.moveTo(-e,t),u.lineTo(e,t),u.stroke();u.restore()}return(t||u).createPattern(l,"repeat")}({background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle},t),s=Oo(i)?null:i;return Bo.set(o,s),s}(t,e);return o||t.background&&To(e,t.background)||n}return"string"!=typeof t?t:To(e,t)||n}function Go(e,t,n,o,r,i,s){const a=t.stops.filter(e=>Number.isFinite(e.offset)&&(null==e.opacity||Number.isFinite(e.opacity)));if(2>a.length)return null;const c=e.createLinearGradient(o,r,i,s);for(const t of a)c.addColorStop(Math.max(0,Math.min(1,t.offset)),Ho(e,t,n));return c}function Ho(e,t,n){const o=t.color??n,r=To(e,o)||o;if(null==t.opacity)return r;const i=Math.max(0,Math.min(1,t.opacity)),[s,a,c]=function(e,t){const n=e.fillStyle,o="#010203";try{e.fillStyle=o,e.fillStyle=t}catch{return e.fillStyle=n,[78,121,167]}const r=e.fillStyle;if(e.fillStyle=n,"string"!=typeof r)return[78,121,167];if(r.toLowerCase()===o&&t.trim().toLowerCase()!==o)return[78,121,167];if(r.startsWith("#"))return[parseInt(r.slice(1,3),16),parseInt(r.slice(3,5),16),parseInt(r.slice(5,7),16)];const i=r.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return i?[+i[1],+i[2],+i[3]]:[78,121,167]}(e,r);return`rgba(${s},${a},${c},${i})`}function Vo(e,t,n,o,r,i,s){const a=t.stops.filter(e=>Number.isFinite(e.offset)&&(null==e.opacity||Number.isFinite(e.opacity)));if(2>a.length)return null;const c=e.createLinearGradient(o,r,i,s);for(const t of a)c.addColorStop(Math.max(0,Math.min(1,t.offset)),Ho(e,t,n));return c}var Xo=require("d3-shape"),Uo=new WeakMap;function Ko(e,t){const n=qo(t);if(!n)return e;const o=Uo.get(e);if(o)return o;const r=function(e,t,n=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const o=[];let r=null;const i={moveTo(e,t){r=[e,t],o.push([e,t])},lineTo(e,t){r=[e,t],o.push([e,t])},bezierCurveTo(e,t,i,s,a,c){if(!r)return r=[a,c],void o.push([a,c]);const[l,u]=r;for(let r=1;n>=r;r++){const d=r/n,h=1-d;o.push([h*h*h*l+3*h*h*d*e+3*h*d*d*i+d*d*d*a,h*h*h*u+3*h*h*d*t+3*h*d*d*s+d*d*d*c])}r=[a,c]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,n,i){r=[n,i],o.push([n,i])}};return(0,Xo.line)().x(e=>e[0]).y(e=>e[1]).curve(t).context(i)(e),o}(e,n);return Uo.set(e,r),r}function Zo(e,t,n,o=30,r,i=0){let s=null;if(r){const e=function(e,t,n,o,r,i=e=>e.x,s=e=>e.y,a=e=>e.r){const c=Math.max(o,r+5,12),l=t-c,u=t+c,d=n-c,h=n+c;let f=null,p=1/0;return e.visit((e,r,c,y,g)=>{if(r>u||l>y||c>h||d>g)return!0;if(!e.length){let r=e;do{const e=r.data,c=i(e)-t,l=s(e)-n,u=Math.sqrt(c*c+l*l);go(a(e),o)>=u&&p>u&&(f=e,p=u),r=r.next}while(r)}return!1}),f?{node:f,distance:p}:null}(r,t,n,o,i);e&&(s={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const i of e){let e=null;switch(i.type){case"point":if(r)break;e=Jo(i,t,n,o);break;case"symbol":e=er(i,t,n,o);break;case"glyph":e=tr(i,t,n,o);break;case"line":e=nr(i,t,n,o);break;case"rect":if(null==i.datum)break;e=rr(i,t,n);break;case"heatcell":e=ir(i,t,n);break;case"area":if(!1===i.interactive)break;e=ar(i,t,n);break;case"candlestick":e=sr(i,t,n)}e&&o>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function Qo(e,t,n){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const o=cr(e,t);if(0>o)return null;if(Math.abs(e[o][0]-t)>n)return null;let r=o,i=o;o>0&&e[o][0]>=t?(r=o-1,i=o):e.length-1>o&&(r=o,i=o+1);const[s,a]=e[r],[c,l]=e[i];return c===s?a:a+Math.max(0,Math.min(1,(t-s)/(c-s)))*(l-a)}function Jo(e,t,n,o=30){const r=t-e.x,i=n-e.y,s=Math.sqrt(r*r+i*i);return s>go(e.r,o)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function er(e,t,n,o=30){const r=t-e.x,i=n-e.y,s=Math.sqrt(r*r+i*i);return s>go(dn(e.size),o)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function tr(e,t,n,o=30){if(null==e.datum)return null;const r=_o(e.glyph,e.size),i=e.x+r.centerDx,s=e.y+r.centerDy,a=t-i,c=n-s,l=Math.sqrt(a*a+c*c);return l>go(r.radius,o)?null:{node:e,datum:e.datum,x:i,y:s,distance:l}}function nr(e,t,n,o=30){if(0===e.path.length)return null;const r=cr(e.path,t);if(0>r)return null;const[i,s]=e.path[r];let a;if(e.path.length>1){let o=1/0;const i=Math.max(0,r-1),s=Math.min(e.path.length-2,r);for(let r=i;s>=r;r++){const[i,s]=e.path[r],[a,c]=e.path[r+1],l=or(t,n,i,s,a,c);o>l&&(o=l)}a=o}else{const e=t-i,o=n-s;a=Math.sqrt(e*e+o*o)}const c=e.style;return a>Math.max(5,(c.strokeWidth??c.lineWidth??1)/2+2,o)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:i,y:s,distance:a}}function or(e,t,n,o,r,i){const s=r-n,a=i-o,c=s*s+a*a;if(0===c)return Math.sqrt((e-n)**2+(t-o)**2);let l=((e-n)*s+(t-o)*a)/c;return l=Math.max(0,Math.min(1,l)),Math.sqrt((e-(n+l*s))**2+(t-(o+l*a))**2)}function rr(e,t,n){const o=yo(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function ir(e,t,n){const o=yo(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function sr(e,t,n){const o=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,i=t-e.x,s=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(i*i+s*s)}}return null}function ar(e,t,n){if(0===e.topPath.length)return null;const o=cr(e.topPath,t);if(0>o)return null;const[r,i]=e.topPath[o],s=t-r,a=n-i,c=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:i,distance:c}}function cr(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}var lr=require("react"),ur={fresh:1,aging:.7,stale:.45,expired:.25},dr={alpha:1,band:"fresh",isStale:!1};function hr(e,t){if(!e||0>=t)return dr;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,o=e.graded;if(o){const e="object"==typeof o?o:{},r=function(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??1)>e?"fresh":t*(n.aging??1.5)>e?"aging":t*(n.stale??3)>e?"stale":"expired":"fresh"}(t,n,e.thresholds);return{alpha:{...ur,...e.opacities??{}}[r],band:r,isStale:"fresh"!==r}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:dr}var fr=require("react/jsx-runtime");function pr({isStale:e,position:t}){return(0,fr.jsx)("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===t?{top:4,left:4}:"bottom-left"===t?{bottom:4,left:4}:"bottom-right"===t?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:e?"#dc3545":"#28a745",color:"white"},children:e?"STALE":"LIVE"})}var yr=require("react"),gr=y(require("react"));function mr(...e){let t;for(const n of e)n&&(t=xr(t)&&xr(n)?{legendGroups:[...t.legendGroups,...n.legendGroups],legendDistance:n.legendDistance??t.legendDistance}:n);return t}function xr(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}function br(e){return"object"==typeof e&&null!==e&&"gradient"in e}var vr=16,wr=6,kr=10,Sr=22,Ar=100,Mr=10;function _r(e){return Math.ceil(7*e.length)}function Pr(e,t){if(xr(e)){const n=Ir(t),o=e.legendGroups.flatMap(e=>[e.label?_r(e.label):0,...e.items.map(e=>n.swatchSize+n.labelGap+_r(e.label))]);return Math.max(Ar,...o)}if(br(e)){const{gradient:t}=e,n=t.format||(e=>Math.round(100*e)/100+""),o=Math.max(_r(n(t.domain[0])),_r(n(t.domain[1]))),r=t.label?_r(t.label):0;return Math.max(Ar,19+o,r)}return Ar}function jr(e){return(xr(e)||br(e))&&Number.isFinite(e.legendDistance)?Math.max(0,e.legendDistance):Mr}function Rr(e){return Math.max(0,e?.sideGutter??0)}function Cr(e,t,n){if(br(e))return e.gradient.label?34:26;if(!xr(e))return 20;const o=Ir(n),r=Math.max(1,n?.maxWidth??t);let i=o.rowHeight;for(const t of e.legendGroups){let e=0,n=0;for(const i of t.items){const t=o.swatchSize+o.labelGap+_r(i.label),s=0===n?t:n+o.itemGap+t;n>0&&s>r?(e+=1,n=t):n=s}t.items.length>0&&(e+=1),i=Math.max(i,e*o.rowHeight,t.label?_r(t.label):0)}return i+(e.legendGroups.length>1?16:0)}function Lr(e,t){return Pr(e,t)+jr(e)+Rr(t)}function Ir(e){const t=Math.max(1,e?.swatchSize??vr),n=Math.max(t,e?.rowHeight??Sr);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??wr),itemGap:Math.max(0,e?.itemGap??kr),rowHeight:n,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}function Tr(e,t){let n=24;return e.map(({hasLabel:e,itemCount:o})=>{n+=5;const r=n;let i;n+=8,e&&(n+=16,i=n,n+=8);const s=n;return n+=o*t+8,{lineY:r,labelY:i,itemsY:s,endY:n}})}var $r=require("react/jsx-runtime"),zr={fill:(e,t)=>(0,$r.jsx)("rect",{style:e,width:t,height:t}),line:(e,t)=>(0,$r.jsx)("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function Er(e,t,n,o,r){let i;return i="function"==typeof n?n(e):(0,zr[n])(o(e,t),r),i}function Or({swatchSize:e}){return(0,$r.jsx)("path",{d:`M${.25*e},${.55*e} L${.45*e},${.75*e} L${.8*e},${.3*e}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Dr(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var Br=(e,t,n,o,r,i,s,a,c,l,u)=>{const{type:d="fill",styleFn:h,items:f}=e,p=[];let y=0;const g=!(!t&&!n),m="isolate"===l||void 0===l&&null!=r,{swatchSize:x,labelGap:b,rowHeight:v}=u;return f.forEach((e,l)=>{const u=Er(e,l,d,h,x),w=Dr(e,o,r),k=r&&r.size>0&&r.has(e.label);p.push((0,$r.jsxs)("g",{transform:`translate(0,${y})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:g?a===i&&l===s?0:-1:void 0,role:g?"option":void 0,"aria-selected":g&&m?k||!1:void 0,"aria-current":g&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:g?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(l+("ArrowDown"===n.key?1:-1)+f.length)%f.length;c(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:g?t=>{c(a,l),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:g?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:g?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[g&&(0,$r.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:x+b+2+7*e.label.length,height:x+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,k&&(0,$r.jsx)(Or,{swatchSize:x}),(0,$r.jsx)("text",{y:x/2,x:x+b,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+l)),y+=v}),p};function Fr({config:e,orientation:t="vertical",width:n=100}){const{colorFn:o,domain:r,label:i,format:s}=e,a=s||(e=>Math.round(100*e)/100+""),c="grad-legend-"+gr.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),s=Math.max(0,(n-t)/2),l=[];for(let e=0;64>=e;e++){const t=e/64;l.push((0,$r.jsx)("stop",{offset:100*t+"%",stopColor:o(r[0]+t*(r[1]-r[0]))},e))}return(0,$r.jsxs)("g",{"aria-label":i||"Gradient legend",children:[(0,$r.jsx)("defs",{children:(0,$r.jsx)("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:l})}),i&&(0,$r.jsx)("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),(0,$r.jsx)("rect",{x:s,y:0,width:t,height:e,fill:`url(#${c})`,rx:2}),(0,$r.jsx)("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])}),(0,$r.jsx)("text",{x:s+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])})]})}const l=[];for(let e=0;64>=e;e++){const t=e/64;l.push((0,$r.jsx)("stop",{offset:100*t+"%",stopColor:o(r[1]-t*(r[1]-r[0]))},e))}return(0,$r.jsxs)("g",{"aria-label":i||"Gradient legend",children:[i&&(0,$r.jsx)("text",{x:0,y:-6,textAnchor:"start",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),(0,$r.jsx)("defs",{children:(0,$r.jsx)("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:l})}),(0,$r.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),(0,$r.jsx)("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])}),(0,$r.jsx)("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])})]})}function Nr(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,legendInteraction:s,title:a="Legend",width:c=100,height:l=20,orientation:u="vertical",legendLayout:d}=e,h=Ir(d),[f,p]=gr.useState(0),[y,g]=gr.useState(0),m=gr.useCallback((e,t)=>{p(e),g(t)},[]),x="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:l,metrics:u})=>{const d=[],h=Tr(e.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),u.rowHeight);return e.forEach((e,f)=>{const p=h[f];d.push((0,$r.jsx)("line",{stroke:"gray",x1:0,y1:p.lineY,x2:t,y2:p.lineY},"legend-top-line legend-symbol-"+f)),e.label&&null!=p.labelY&&d.push((0,$r.jsx)("text",{y:p.labelY,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),d.push((0,$r.jsx)("g",{className:"legend-item",transform:`translate(0,${p.itemsY})`,children:Br(e,n,o,r,i,s,a,f,c,l,u)},"legend-group-"+f))}),d})({legendGroups:t||[],width:c,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:s,metrics:h}):(({legendGroups:e,height:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:c,onFocusedIndexChange:l,legendInteraction:u,metrics:d})=>{let h=0;const f=[];e.forEach((e,t)=>{let p=0;e.label&&(p+=16);const y=((e,t,n,o,r,i,s,a,c,l,u,d)=>{const{type:h="fill",styleFn:f,items:p}=e,y=[],{swatchSize:g,labelGap:m,itemGap:x,rowHeight:b,align:v}=u,w=!(!t&&!n),k="isolate"===l||void 0===l&&null!=r,S=p.map(e=>g+m+7*e.label.length),A=[];let M=0,_=0;S.forEach((e,t)=>{const n=0===_?e:_+x+e;d&&d>0&&_>0&&n>d?(A.push({start:M,end:t,width:_}),M=t,_=e):_=n}),p.length>0&&A.push({start:M,end:p.length,width:_}),A.forEach((e,l)=>{let u="center"===v?Math.max(0,((d??e.width)-e.width)/2):"end"===v?Math.max(0,(d??e.width)-e.width):0;for(let d=e.start;e.end>d;d++){const e=p[d],v=Er(e,d,h,f,g),A=Dr(e,o,r),M=r&&r.size>0&&r.has(e.label);y.push((0,$r.jsxs)("g",{transform:`translate(${u},${l*b})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:w?a===i&&d===s?0:-1:void 0,role:w?"option":void 0,"aria-selected":w&&k?M||!1:void 0,"aria-current":w&&!k&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:w?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(d+("ArrowRight"===n.key?1:-1)+p.length)%p.length;c(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:w?t=>{c(a,d),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:w?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:w?"pointer":"default",opacity:A,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[w&&(0,$r.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:g+m+2+7*e.label.length,height:g+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,M&&(0,$r.jsx)(Or,{swatchSize:g}),(0,$r.jsx)("text",{y:g/2,x:g+m,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+d)),u+=S[d]+x}});const P=Math.max(0,...A.map(e=>e.width)),j=A.length;return{items:y,offset:P,totalRows:j,totalHeight:j*b}})(e,o,r,i,s,a,c,t,l,u,d,d.maxWidth??n);p+=y.offset+5,f.push({label:e.label,...y,offset:p,totalRows:y.totalRows,totalHeight:y.totalHeight}),h+=p+12});const p=d.maxWidth??n;let y=h>p?0:"center"===d.align?Math.max(0,(p-h)/2):"end"===d.align?Math.max(0,p-h):0;const g=[];return f.forEach((n,o)=>{const r=e[o];r.label&&(g.push((0,$r.jsx)("text",{transform:`translate(${y},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:r.label},"legend-text-"+o)),y+=16),g.push((0,$r.jsx)("g",{className:"legend-item",transform:`translate(${y},0)`,children:n.items},"legend-group-"+o)),y+=n.offset+5,e[o+1]&&g.push((0,$r.jsx)("line",{stroke:"gray",x1:y,y1:-8,x2:y,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+o)),y+=12}),(0,$r.jsx)("g",{children:g})})({legendGroups:t||[],title:a,height:l,width:c,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:s,metrics:h}),b=!(!n&&!o);return(0,$r.jsxs)("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"isolate"!==s&&(void 0!==s||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===u&&(0,$r.jsx)("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),x]})}var Wr=require("react/jsx-runtime");function qr(e){const{legend:t,totalWidth:n,totalHeight:o,margin:r,legendPosition:i="right",legendLayout:s,legendHoverBehavior:a,legendClickBehavior:c,legendHighlightedCategory:l,legendIsolatedCategories:u,legendInteraction:d}=e;if(!t)return null;const h="top"===i||"bottom"===i,f=Math.max(0,n-r.left-r.right),p=Math.max(1,h?s?.maxWidth??f:Pr(t,s)),y=jr(t),g=Rr(s),m=Cr(t,f,s);let x,b;return"left"===i?(x=r.left-g-p-y,b=r.top):"top"===i?(x=r.left,b=r.top-y-m):"bottom"===i?(x=r.left,b=o-r.bottom+y):(x=n-r.right+g+y,b=r.top),(0,Wr.jsx)("g",{transform:`translate(${x}, ${b})`,children:br(t)?(0,Wr.jsx)(Fr,{config:t.gradient,orientation:h?"horizontal":"vertical",width:p}):xr(t)?(0,Wr.jsx)(Nr,{legendGroups:t.legendGroups,title:"",width:p,orientation:h?"horizontal":"vertical",legendLayout:s,customHoverBehavior:a,customClickBehavior:c,highlightedCategory:l,isolatedCategories:u,legendInteraction:d}):t})}var Yr=require("react"),Gr=require("d3-array"),Hr=require("react/jsx-runtime");function Vr(e){return"string"==typeof e?{type:e}:e}function Xr({orient:e,config:t,values:n,scale:o,size:r,length:i}){const s=function(e){return{type:e.type,bins:e.bins??20,fill:e.fill??"#4e79a7",fillOpacity:e.fillOpacity??.5,stroke:e.stroke??"none",strokeWidth:e.strokeWidth??1}}(t),a="top"===e||"bottom"===e,c=(0,Yr.useMemo)(()=>{if(0===n.length)return null;const t=o.domain(),c=r-8;if("boxplot"===s.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],s=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(t[0],o-1.5*s),whiskerHigh:Math.min(t[n-1],i+1.5*s)}}(n);if(!t)return null;const{q1:r,median:i,q3:l,whiskerLow:u,whiskerHigh:d}=t,h=Math.min(.5*c,20),f=(c-h)/2+4;if(a){const t=o(r),n=o(l),a=o(i),c=o(u),p=o(d),y="top"===e?-1:1,g=0;return(0,Hr.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,Hr.jsx)("line",{x1:c,y1:g+y*(f+h/2),x2:p,y2:g+y*(f+h/2),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Hr.jsx)("line",{x1:c,y1:g+y*f,x2:c,y2:g+y*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Hr.jsx)("line",{x1:p,y1:g+y*f,x2:p,y2:g+y*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Hr.jsx)("rect",{x:Math.min(t,n),y:"top"===e?g-f-h:g+f,width:Math.abs(n-t),height:h,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),(0,Hr.jsx)("line",{x1:a,y1:"top"===e?g-f-h:g+f,x2:a,y2:"top"===e?g-f:g+f+h,stroke:s.fill,strokeWidth:2})]})}{const t=o(r),n=o(l),a=o(i),c=o(u),p=o(d),y="left"===e?-1:1,g=0;return(0,Hr.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,Hr.jsx)("line",{x1:g+y*(f+h/2),y1:c,x2:g+y*(f+h/2),y2:p,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Hr.jsx)("line",{x1:g+y*f,y1:c,x2:g+y*(f+h),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Hr.jsx)("line",{x1:g+y*f,y1:p,x2:g+y*(f+h),y2:p,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Hr.jsx)("rect",{x:"left"===e?g-f-h:g+f,y:Math.min(t,n),width:h,height:Math.abs(n-t),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),(0,Hr.jsx)("line",{x1:"left"===e?g-f-h:g+f,y1:a,x2:"left"===e?g-f:g+f+h,y2:a,stroke:s.fill,strokeWidth:2})]})}}const l=(0,Gr.bin)().domain(t).thresholds(s.bins)(n);if(0===l.length)return null;const u=we(l.map(e=>e.length));if(0===u)return null;if("histogram"===s.type)return(0,Hr.jsx)("g",{"data-testid":"marginal-histogram-"+e,children:l.map((t,n)=>{if(null==t.x0||null==t.x1)return null;const r=t.length/u*c;if(a){const i=o(t.x0),a=o(t.x1)-o(t.x0);return(0,Hr.jsx)("rect",{x:i,y:"top"===e?-4-r:4,width:Math.max(a,.5),height:r,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}{const i=o(t.x0),a=o(t.x1)-o(t.x0);return(0,Hr.jsx)("rect",{x:"left"===e?-4-r:4,y:Math.min(i,i+a),width:r,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}})});if("violin"===s.type){const t=c/2+4,n=[];for(const r of l){if(null==r.x0||null==r.x1)continue;const i=r.length/u*(c/2),s=o((r.x0+r.x1)/2);n.push(a?`${s},${"top"===e?-(t-i):t-i}`:`${"left"===e?-(t-i):t-i},${s}`)}for(let r=l.length-1;r>=0;r--){const i=l[r];if(null==i.x0||null==i.x1)continue;const s=i.length/u*(c/2),d=o((i.x0+i.x1)/2);n.push(a?`${d},${"top"===e?-(t+s):t+s}`:`${"left"===e?-(t+s):t+s},${d}`)}return(0,Hr.jsx)("g",{"data-testid":"marginal-violin-"+e,children:(0,Hr.jsx)("polygon",{points:n.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}if("ridgeline"===s.type){const t=[];if(a){const n=0,r=null!=l[0].x0?o(l[0].x0):0;t.push(`M${r},${n}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const r=n.length/u*c,i=o((n.x0+n.x1)/2);t.push(`L${i},${"top"===e?-r-4:r+4}`)}const s=null!=l[l.length-1].x1?o(l[l.length-1].x1):i;t.push(`L${s},${n}`),t.push("Z")}else{const n=0,r=null!=l[0].x0?o(l[0].x0):0;t.push(`M${n},${r}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const r=n.length/u*c,i=o((n.x0+n.x1)/2);t.push(`L${"left"===e?-r-4:r+4},${i}`)}const s=null!=l[l.length-1].x1?o(l[l.length-1].x1):i;t.push(`L${n},${s}`),t.push("Z")}return(0,Hr.jsx)("g",{"data-testid":"marginal-ridgeline-"+e,children:(0,Hr.jsx)("path",{d:t.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}return null},[n,o,s,r,i,e,a,4]);return c?(0,Hr.jsx)("g",{className:"marginal-"+e,"data-testid":"marginal-"+e,children:c}):null}var Ur=y(require("react")),Kr=require("react/jsx-runtime");function Zr(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),i=[];let s="";for(const e of r)s&&s.length+1+e.length>o?(i.push(s),s=e):s=s?`${s} ${e}`:e;return s&&i.push(s),i}function Qr(e,t,n,o){return"curly"===e?o?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:o?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function Jr(e,t,n,o){if(!e)return(0,Kr.jsx)("g",{className:"annotation-note"});const{label:r,title:i,orientation:s,align:a,wrap:c=120,noWrap:l}=e;if(!r&&!i)return(0,Kr.jsx)("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=a;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const f=16,p=i?l?[i]:Zr(i,c):[],y=r?l?[r]:Zr(r,c):[],g="leftRight"===u?"end"===h?-4:4:0;let m=0;const x=[],b=o||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?x.push((0,Kr.jsx)("foreignObject",{className:"annotation-note-html",x:"end"===h?g-c:"middle"===h?g-c/2:g,y:-16,width:c,height:Math.max(f,(p.length+y.length)*f+(i&&r?2:0))+f,style:{overflow:"visible"},children:(0,Kr.jsxs)("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:b,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===h?"right":"middle"===h?"center":"left",whiteSpace:l?"nowrap":"normal",wordBreak:"break-word"},children:[i&&(0,Kr.jsx)("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),r&&(0,Kr.jsx)("div",{className:"annotation-note-label",children:r})]})},"annotation-note-html")):(p.length>0&&(x.push((0,Kr.jsx)("text",{className:"annotation-note-title",fill:b,textAnchor:h,fontWeight:"bold",children:p.map((e,t)=>(0,Kr.jsx)("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-title")),m=p.length*f),y.length>0&&x.push((0,Kr.jsx)("text",{className:"annotation-note-label",fill:b,textAnchor:h,y:m,children:y.map((e,t)=>(0,Kr.jsx)("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-label")));let v=null;if((i||r)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(c,120);let t=0,n=e;"end"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),v=(0,Kr.jsx)("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(p.length+y.length)*f+(y.length>0?f:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),v=(0,Kr.jsx)("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,p.length+y.length-1)*f;let k=0;return"topBottom"===u?k=0>n?-(w+2):18:"leftRight"===u&&(k="middle"===d?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),(0,Kr.jsxs)("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[(0,Kr.jsx)("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0,children:x}),v]})}function ei(e,t,n,o,r){const i=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&i.push((0,Kr.jsx)("circle",{r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,o=t?.height||0;(e>0||o>0)&&i.push((0,Kr.jsx)("rect",{width:e,height:o,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":t?.custom&&i.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,s=r||0;if(void 0!==t?.x){const o=(t.x||0)-e;i.push((0,Kr.jsx)("line",{x1:o,y1:(t.y1||0)-s,x2:o,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const o=(t.y||0)-s;i.push((0,Kr.jsx)("line",{x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?i.push((0,Kr.jsx)("line",{x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===t?.y1&&void 0===t?.y2||i.push((0,Kr.jsx)("line",{x1:0,y1:(t.y1||0)-s,x2:0,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=t?.type||"curly",o=t?.width??t?.height;void 0!==o&&i.push((0,Kr.jsx)("path",{d:Qr(e,o,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return(0,Kr.jsx)("g",{className:"annotation-subject",children:i})}function ti(e,t,n,o,r,i){const s=[];let a=0,c=0;if("callout-circle"!==r&&"label"!==r||!i?.radius){if("callout-rect"===r&&i){const n=i.width||0,o=i.height||0;if(n>0||o>0){const r=n/2,i=o/2,s=e-r,l=t-i;if(0!==s||0!==l){const e=Math.abs(s),t=Math.abs(l),u=n/2,d=o/2,h=e*d>t*u?u/e:d/t;a=r+s*h,c=i+l*h}}}else if("bracket"===r&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(a=e/2,c=n):void 0!==t&&(a=n,c=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);a=Math.cos(o)*n,c=Math.sin(o)*n}}const l=Math.sqrt((e-a)**2+(t-c)**2);if(l>.5){const r=o||"var(--semiotic-text-secondary, currentColor)",i="curve"===n?.type;let u=Math.atan2(t-c,e-a);if(i){const o=(a+e)/2,i=(c+t)/2,d=-(t-c)/l,h=(e-a)/l,f=(n?.curve??.25)*l,p=o+d*f,y=i+h*f;s.push((0,Kr.jsx)("path",{className:"connector-curve",d:`M${a},${c}Q${p},${y} ${e},${t}`,fill:"none",stroke:r},"connector-line")),u=Math.atan2(y-c,p-a)}else s.push((0,Kr.jsx)("line",{x1:a,y1:c,x2:e,y2:t,stroke:r},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;s.push((0,Kr.jsx)("path",{d:`M${a},${c}L${a+e*Math.cos(u+t)},${c+e*Math.sin(u+t)}L${a+e*Math.cos(u-t)},${c+e*Math.sin(u-t)}Z`,fill:r,stroke:"none"},"connector-arrow"))}}return(0,Kr.jsx)("g",{className:"annotation-connector",children:s})}function ni(e){const{x:t=0,y:n=0,dx:o,dy:r,nx:i,ny:s,note:a,connector:c,subject:l,type:u,color:d,className:h,disable:f,opacity:p,strokeDasharray:y,events:g={},"data-testid":m}=e,x=Array.isArray(t)?t[0]??0:t,b=Array.isArray(n)?n[0]??0:n,v=new Set(Array.isArray(f)?f:[]);let w=o||0,k=r||0;null!=i&&(w=i-x),null!=s&&(k=s-b);const S="string"==typeof u?u:"label";if("bracket"===S&&l&&0===w&&0===k)if(void 0!==l.width){w=l.width/2;const e=l.depth||30;k=e+(0>e?-5:5)}else if(void 0!==l.height){const e=l.depth||30;w=e+(0>e?-5:5),k=l.height/2}return(0,Kr.jsxs)("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${x},${b})`,"data-testid":m,...null!=p&&{opacity:p},...y&&{strokeDasharray:y},...g,children:[!v.has("connector")&&ti(w,k,c,d,S,l),!v.has("subject")&&ei(S,l,d,x,b),!v.has("note")&&Jr(a,w,k,d)]})}function oi(e){const{noteData:t}=e,{screenCoordinates:n}=t,o="string"==typeof t.type?t.type:"label",r=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),r=t.ny||n[0][1]+(t.dy??0),i=n.map((n,i)=>{const s=Object.assign({},t,{note:0===i?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:r});return(0,Kr.jsx)(ni,{"data-testid":"semiotic-annotation",...s,type:o},"multi-annotation-"+i)});return(0,Kr.jsx)("g",{children:i})}const i=t.note||{title:"none",label:t.label},s=`${i.label}-${i.title}-${t.i}`;return(0,Kr.jsx)(ni,{"data-testid":"semiotic-annotation",events:r,...t,type:o},s)}var ri=require("d3-hierarchy"),ii=require("d3-shape");function si(e){return Math.round(100*e)/100}function ai(e,t=2){const n=[],o=[],r=t+1;for(let t=0;r>t;t++){let i=0;for(const[n,o]of e)null!==o&&(i+=n**t*o);n.push(i);const s=[];for(let n=0;r>n;n++){let o=0;for(const[r,i]of e)null!==i&&(o+=r**(t+n));s.push(o)}o.push(s)}o.push(n);const i=function(e,t){const n=e,o=e.length-1,r=[t];for(let e=0;o>e;e++){let t=e;for(let r=e+1;o>r;r++)Math.abs(n[e][r])>Math.abs(n[e][t])&&(t=r);for(let r=e;o+1>r;r++){const o=n[r][e];n[r][e]=n[r][t],n[r][t]=o}for(let t=e+1;o>t;t++)for(let r=o;r>=e;r--)n[r][t]-=n[r][e]*n[e][t]/n[e][e]}for(let e=o-1;e>=0;e--){let t=0;for(let i=e+1;o>i;i++)t+=n[i][e]*r[i];r[e]=(n[o][e]-t)/n[e][e]}return r}(o,r).map(si);return{points:e.map(([e])=>[si(e),si(i.reduce((t,n,o)=>t+n*e**o,0))]),equation:[...i].reverse()}}function ci(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function li(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function ui(e){return null==e?null:e+""}function di(e,t,n){return t.stickyPositionCache?.set(e,n),n}function hi(e,t,n){const o=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===e.pointId)return di(t,n,{x:r.x,y:r.y})}const o=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],o=e.scales?.x??e.scales?.time,r=e.scales?.y??e.scales?.value;if(!o||!r)return null;const i=n[e.xAccessor||"x"],s=n[e.yAccessor||"y"];return null==i||null==s?null:{x:o(i),y:r(s)}}(n);return o?di(t,n,o):null}if("semantic"===o){const o=function(e,t,n){const o=function(e){return ui(e.provenance?.stableId??e.stableId)}(e);if(!o)return null;const r=n.pointNodes?.find(e=>ui(e.pointId)===o);if(r)return di(t,n,{x:r.x,y:r.y});const i=n.data?.find(e=>function(e){return ui(e.stableId??e.id??e.provenance?.stableId)}(e)===o);if(!i)return null;const s=ci(i,n),a=li(i,n);return null==s||null==a?null:di(t,n,{x:s,y:a})}(e,t,n);if(o)return o}let r=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(r=t.x,i=t.y)}if(null!=r&&null!=i||(r=ci(e,n),i=li(e,n)),null!=r&&null!=i)return di(t,n,{x:r,y:i});if("sticky"===o){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function fi(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}var pi=require("react/jsx-runtime"),yi={secondary:0,primary:3},gi=1,mi=2,xi=.6,bi="0.88em",vi=.95,wi=.72,ki=.06,Si=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}",Ai=".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}";function Mi(e){return!0===e?._annotationDeferred}function _i(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function Pi(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function ji(e){return Math.max(wi,vi-e*ki)}var Ri=y(require("react")),[Ci,Li]=De(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function Ii(e,t={}){const n=function(e){const t=e.provenance,n=e.id??e.stableId??t?.stableId;return null==n||""===n?void 0:n+""}(e);return{"data-semiotic-annotation-widget":"",...n?{"data-semiotic-annotation-id":n}:{},onClickCapture(o){const r=function(e){const t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}(o);t.onAnnotationActivate?.({annotation:e,annotationId:n,chartId:t.chartId,inputType:r}),n&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:n,inputType:r,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}var Ti=require("react/jsx-runtime"),$i="var(--semiotic-bg, #ffffff)",zi=.85;function Ei(e){const{x:t,y:n,text:o,fill:r,fontSize:i=12,fontWeight:s,fontFamily:a,textAnchor:c="start",dominantBaseline:l,background:u,className:d}=e,h=function(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{type:e.type??"halo",...e}}(u),f=e=>(0,Ti.jsx)("text",{x:t,y:n,textAnchor:c,dominantBaseline:l,fill:r,fontSize:i,fontWeight:s,fontFamily:a,className:d,...e?{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}:{},children:o});if(!h)return f();if("halo"===h.type)return f({stroke:h.fill??$i,strokeWidth:h.haloWidth??3});const p=h.padding??{x:6,y:3},y="number"==typeof p?p:p.x,g="number"==typeof p?p:p.y,m=function(e,t){return(e+"").length*t*.6}(o,i),x=i+2*g;let b,v;return b="middle"===c?t-m/2-y:"end"===c?t-m-y:t-y,v="middle"===l||"central"===l?n-x/2:"hanging"===l||"text-before-edge"===l?n-g:n-.8*i-g,(0,Ti.jsxs)("g",{className:d,children:[(0,Ti.jsx)("rect",{x:b,y:v,width:m+2*y,height:x,rx:h.radius??3,ry:h.radius??3,fill:h.fill??$i,fillOpacity:h.opacity??zi,stroke:h.stroke,strokeWidth:h.strokeWidth}),f()]})}var Oi=require("react/jsx-runtime"),Di={linear:ii.curveLinear,monotoneX:ii.curveMonotoneX,monotoneY:ii.curveMonotoneY,step:ii.curveStep,stepAfter:ii.curveStepAfter,stepBefore:ii.curveStepBefore,basis:ii.curveBasis,cardinal:ii.curveCardinal,catmullRom:ii.curveCatmullRom};function Bi(e,t,n,o){const r=[];return e.forEach((e,i)=>{let s;if(n){const r=n(e,i,o);s=null!=r?r:t(e,i,o)}else s=t(e,i,o);s&&r.push({node:s,annotation:e})}),function(e){const t=e.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:Pi(e.annotation),readingOrder:null,rank:gi};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),o=e.some(e=>Mi(e.annotation)),r=e.some(e=>null!=_i(e.annotation)),i=e.some(e=>"layer"===_i(e.annotation));if(!n&&!o&&!r)return e.map(e=>e.node);const s=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);s.forEach((e,t)=>{e.readingOrder=t,e.rank=mi-t/Math.max(1,s.length)});for(const e of t)e.emphasis&&(e.rank=yi[e.emphasis]);const a=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:n,emphasis:o,readingOrder:r}=e,i=Mi(t.annotation);let s=t.node;if("primary"===o||"secondary"===o||null!=r){const e=null==o&&null!=r;s=(0,pi.jsx)("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+o,..."secondary"===o?{opacity:xi,fontSize:bi}:{},...e?{opacity:ji(r),"data-annotation-reading-order":r}:{},children:t.node},"annotation-emphasis-"+n)}const a=_i(t.annotation);return a&&(s=(0,pi.jsx)("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),i&&(s=(0,pi.jsx)("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return o&&a.unshift((0,pi.jsx)("style",{children:Si},"annotation-disclosure-style")),i&&a.unshift((0,pi.jsx)("style",{children:Ai},"annotation-cohesion-style")),a}(r)}var Fi=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function Ni(e){return!!e&&"object"==typeof e&&Fi.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}new Set(["label","callout","callout-circle","callout-rect"]);var Wi=2e4,qi=1;function Yi(e){return"primary"===e?.emphasis||!0===e?.defensive}function Gi(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:Wi))):1/0}function Hi(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const o=e?.provenance?.confidence;switch("number"==typeof o&&Number.isFinite(o)&&(t+=15*Math.max(0,Math.min(1,o))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}var Vi=32,Xi=6,Ui=4,Ki=8,Zi=72,Qi=30,Ji=-30,es=8,ts=480,ns=3;var os={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function rs(e){if(!is(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function is(e){return Ni(e)}function ss(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),o=e.split(/\s+/).filter(Boolean),r=[];let i="";for(const e of o)i&&i.length+e.length+1>n?(r.push(i),i=e):i=i?`${i} ${e}`:e;return i&&r.push(i),r}function as(e,t,n,o,r){const i=e+n,s=t+o;return Math.abs(n)>Math.abs(o)?{x:0>n?i-r.width-4:i+4,y:0>o?s-r.height:s,width:r.width,height:r.height}:{x:0>n?i-r.width:i,y:0>o?s-r.height-4:s+4,width:r.width,height:r.height}}function cs(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function ls(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function us(e,t,n,o,r,i,s,a){const c=cs(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,o){const r=Math.max(0,o-e.x),i=Math.max(0,o-e.y);return(r+Math.max(0,e.x+e.width-(t-o)))*e.height+(i+Math.max(0,e.y+e.height-(n-o)))*e.width}(c,r,i,a);for(const e of n)l+=12*ls(c,e);for(const e of o)l+=4*ls(c,e);return l}function ds(e){const{annotations:t,context:n,defaultOffset:o=Vi,notePadding:r=Xi,markPadding:i=Ui,edgePadding:s=Ki,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=Zi,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:p,cohesion:y,audience:g}=e,m=n.width||0,x=n.height||0,b="object"==typeof p?p:{},v=b.breakpoint??ts,w=!!p&&v>=m,k=w&&!1!==b.preferShortText?t.map(rs):t,S=w&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,A=d||w&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),M=w&&!f?b.responsive??{minWidth:v}:f,_=w&&!y?b.cohesion:y;if(0===k.length||0>=m||0>=x)return k.slice();const P=[],j=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(n,i);let R=!1;const C=k.map((e,t)=>{if(!is(e))return e;const i=function(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const o=e.pointId??e.nodeId;if(null!=o&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===o);if(e)return{x:e.x,y:e.y}}const r=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(r)&&r.length>=2&&i){const e=r[0],t=r[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?hi(e,t,n):{x:e.x,y:e.y}}(e,t,n);if(!i)return e;const u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,n=[...ss("string"==typeof e.title?e.title:void 0,t),...ss("string"==typeof e.label?e.label:void 0,t)],o=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*o)+10),height:Math.max(18,16*n.length+6)}}(e);if(a&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:Qi,dy:Ji}}(e);return P.push(cs(as(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),r)),e}var d;let h=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(o)){const t=us(as(i.x,i.y,e.dx,e.dy,u),e,P,j,m,x,r,s);f>t&&(h=e,f=t)}if(!h)return e;const p=cs(as(i.x,i.y,h.dx,h.dy,u),r);P.push(p);const y=Math.hypot(h.dx,h.dy),g=c&&y>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return R=!0,{...e,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),L=R?C:k.slice();let I=L;if(h){let e=!1;const t=L.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)<es?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});I=e?t:L}{let e=!1;const t=I.map(t=>{if(!0!==t?.defensive)return t;const n=function(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?os[t.source]??t.source:null,o="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!o)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const r=[n,o].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${r})`)?e:{...e,label:i?`${i} (${r})`:`(${r})`}}(t);return n!==t&&(e=!0),n});I=e?t:I}const T=new Set;if(S){const e="object"==typeof S?S:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return ns;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?ns:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(g),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??Gi(m,x,e))*t))},{deferred:o}=function(e){const{annotations:t,width:n,height:o}=e,r=Math.max(0,e.minVisible??qi),i=Gi(n,o,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,Ni(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||i>=a.length)return{visible:t.slice(),deferred:[],budget:i};const c=a.filter(e=>Yi(e.annotation)),l=a.filter(e=>!Yi(e.annotation)).sort((e,t)=>Hi(t.annotation)-Hi(e.annotation)||e.index-t.index),u=Math.min(l.length,Math.max(Math.max(0,i-c.length),Math.max(0,r-c.length))),d=new Set([...c.map(e=>e.index),...l.slice(0,u).map(e=>e.index)]),h=[],f=[];for(const{annotation:e,index:t,note:n}of s)!n||d.has(t)?h.push(e):f.push(e);return{visible:h,deferred:f,budget:i}}({annotations:I,width:m,height:x,...n});for(const e of o)T.add(e)}if(M&&("object"==typeof M&&"number"==typeof M.minWidth?M.minWidth:ts)>=m)for(const e of I)is(e)&&"secondary"===e.emphasis&&T.add(e);if(T.size>0)for(const e of I)!0===e?.defensive&&T.delete(e);let $;return $=0===T.size?I:A?I.map(e=>T.has(e)?{...e,_annotationDeferred:!0}:e):I.filter(e=>!T.has(e)),_?function(e,t){let n=!1;const o=e.map(e=>is(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?o:e}($,_):$}function hs(e,t={}){const n=!0===t.showRetractedAnnotations,o=!0===t.showSupersededAnnotations,r=new Set;for(const t of e){const e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&r.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!n)return!1;const t=e?.provenance?.stableId;return!(t&&r.has(t)&&!o)})}var fs=require("react"),ps={positions:new Map},ys=new Set;function gs(){for(const e of ys)e()}function ms(e,t){const n=ps.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const o=new Map(ps.positions);o.delete(e),ps={positions:o},gs()}function xs(e,t){const n=ps.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const o=new Map(ps.positions);o.delete(e),ps={positions:o},gs()}function bs(){return ps}function vs(e){return ys.add(e),()=>ys.delete(e)}var ws={positions:new Map};function ks(){return()=>{}}function Ss(){return ws}function As(e,t,n){return"exact"===n?function(e,t){const n=e.domain(),o=n[0],r=n[n.length-1],i=o instanceof Date,s=o instanceof Date?o.getTime():o,a=r instanceof Date?r.getTime():r;if(2>t||s===a)return i?[new Date(s),new Date(a)]:[s,a];const c=(a-s)/(t-1),l=Array(t);for(let e=0;t>e;e++){const n=e===t-1?a:s+e*c;l[e]=i?new Date(n):n}return l}(e,t):e.ticks(t)}function Ms(e,t,n){if("edges"===e){if(t)return"start";if(n)return"end"}return"middle"}function _s(e,t,n){if("edges"===e){if(t)return"hanging";if(n)return"auto"}return"middle"}function Ps(e){if(0===e.length)return{min:null,max:null};let t=1/0,n=-1/0;for(const o of e)t>o.pixel&&(t=o.pixel),o.pixel>n&&(n=o.pixel);return{min:t,max:n}}function js(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Rs(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,i=Math.ceil(t/8);let s="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${o+4*r}`,s+=`L${Math.min(n,t)},${o}`}return s}const o="bottom"===e?0:t,r="bottom"===e?1:-1,i=Math.ceil(n/8);let s=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);s+=`L${o+4*r},${Math.min(8*e+4,n)}`,s+=`L${o},${Math.min(t,n)}`}return s}var Cs=36,Ls=34,Is=58,Ts=22;function $s(e){return"string"==typeof e&&e.length>0}function zs(e,t,n=!1){const o=n?t?Is:Ls:t?Cs:0;return o>e.top?{...e,top:o}:e}function Es(e,t){return zs(e,$s(t))}var Os=require("react/jsx-runtime");function Ds(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,scales:s,showAxes:a,axes:c,showGrid:l,xFormat:u,yFormat:d,axisExtent:h}=e,f=(0,yr.useMemo)(()=>{if(!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||u||Bs,o=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,i="exact"===h?Math.max(2,r):Math.min(r,o),a=e?.tickValues??As(s.x,i,h),l=a.map(e=>e.valueOf()),d=a.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,l)})),f=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return Fs(d,Math.max(55,f+8))},[s,c,u,t,h]),p=(0,yr.useMemo)(()=>{if(!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||d||Bs,o=Math.max(2,Math.floor(n/30)),r=e?.ticks??5,i="exact"===h?Math.max(2,r):Math.min(r,o);return Fs((e?.tickValues??As(s.y,i,h)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[s,c,d,n,h]),y=l&&s,g=a&&s;if(!y&&!g)return null;const m=c?.find(e=>"bottom"===e.orient),x=c?.find(e=>"left"===e.orient),b=g&&(!m||!1!==m.baseline),v=g&&(!x||!1!==x.baseline),w=m?.jaggedBase||!1,k=x?.jaggedBase||!1,S="var(--semiotic-border, #ccc)";return(0,Os.jsx)("svg",{width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:(0,Os.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[y&&(()=>{const e=js(c?.find(e=>"bottom"===e.orient)?.gridStyle),o=js(c?.find(e=>"left"===e.orient)?.gridStyle);return(0,Os.jsxs)("g",{className:"stream-grid",children:[f.map((t,o)=>(0,Os.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+o)),p.map((e,n)=>(0,Os.jsx)("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"ygrid-"+n))]})})(),b&&!w&&(0,Os.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:S,strokeWidth:1}),w&&(0,Os.jsx)("path",{d:Rs("bottom",t,n),fill:"none",stroke:S,strokeWidth:1}),v&&!k&&(0,Os.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:S,strokeWidth:1}),k&&(0,Os.jsx)("path",{d:Rs("left",t,n),fill:"none",stroke:S,strokeWidth:1})]})})}function Bs(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function Fs(e,t){if(2>=e.length)return e;const n=[e[0]];for(let o=1;e.length-1>o;o++)t>Math.abs(e[o].pixel-n[n.length-1].pixel)||n.push(e[o]);const o=e[e.length-1];return t>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function Ns(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,scales:s,showAxes:a,axes:c,xLabel:l,yLabel:u,yLabelRight:d,xFormat:h,yFormat:f,axisExtent:p,showGrid:y,title:g,legend:m,legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:v,legendIsolatedCategories:w,legendPosition:k="right",legendLayout:S,foregroundGraphics:A,marginalGraphics:M,xValues:_,yValues:P,annotations:j,onAnnotationActivate:R,onObservation:C,chartId:L,chartType:I,autoPlaceAnnotations:T,svgAnnotationRules:$,xAccessor:z,yAccessor:E,annotationData:O,pointNodes:D,curve:B,underlayRendered:F,canvasObscuresUnderlay:N=!0,linkedCrosshairName:W,linkedCrosshairSourceId:q,children:Y}=e,G=function(e){const t=Li(e=>e.pushObservation),n=Ri.useCallback(n=>{e.onObservation?.(n),t?.(n)},[e,t]);return Ri.useMemo(()=>({...e,onObservation:n}),[n,e])}({onAnnotationActivate:R,onObservation:C,chartId:L,chartType:I}),H=Rr(S),V=m&&"left"===k&&H>0?H:i.left,X=m&&"right"===k&&H>0?H:i.right,U=(0,yr.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||h||Bs,o=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,i="exact"===p?Math.max(2,r):Math.min(r,o),l=e?.tickValues??As(s.x,i,p),u=l.map(e=>e.valueOf()),d=l.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,u)})),f=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),y=e?.autoRotate?Math.max(20,Math.min(f+8,55)):Math.max(55,f+8);let g=Fs(d,y);if(g.length>1&&(g=g.filter((e,t)=>0===t||e.label+""!=g[t-1].label+"")),e?.includeMax&&g.length>0&&"exact"!==p&&!e?.tickValues){const e=s.x.domain()[1],t=s.x(e),o=g[g.length-1].pixel;if(Math.abs(t-o)>1){const r=n(e,g.length,u);y>t-o&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:r})}}return g},[a,s,c,h,t,p]),K=(0,yr.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||f||Bs,o=Math.max(2,Math.floor(n/30)),r=e?.ticks??5,i="exact"===p?Math.max(2,r):Math.min(r,o);let l=Fs((e?.tickValues??As(s.y,i,p)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22);if(l.length>1&&(l=l.filter((e,t)=>0===t||e.label+""!=l[t-1].label+"")),e?.includeMax&&l.length>0&&"exact"!==p&&!e?.tickValues){const e=s.y.domain()[1],n=s.y(e),o=l[l.length-1].pixel;if(Math.abs(n-o)>1){const r=t(e);22>Math.abs(n-o)&&l.length>1&&(l=l.slice(0,-1)),l.push({value:e,pixel:n,label:r})}}return l},[a,s,c,f,n,p]),Z=(0,yr.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"right"===e.orient);if(!e)return[];const t=e.tickFormat||f||Bs,o=Math.max(2,Math.floor(n/30)),r=e.ticks??5;return Fs((e.tickValues??As(s.y,"exact"===p?Math.max(2,r):Math.min(r,o),p)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[a,s,c,f,n,p]),Q=(0,yr.useRef)(new Map),J=(0,yr.useRef)(j?.length??0),ee=j?.length??0;J.current!==ee&&(J.current=ee,Q.current=new Map);const te=(0,yr.useMemo)(()=>{if(!j||0===j.length)return null;const e=hs(j),o=function(e,t={}){return function(e,n,o){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const t=hi(e,n,o);if(!t)return null;const{x:r,y:i}=t;if(!fi(r,i,o))return null;const s="callout"===e.type?"callout-circle":e.type,a="callout-circle"===s?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===s?{width:e.width,height:e.height}:void 0;return(0,Oi.jsx)(oi,{noteData:{x:r,y:i,dx:e.dx??30,dy:e.dy??-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:s,...a?{subject:a}:{},connector:e.connector||{end:"arrow"},color:e.color,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-"+n)}case"x-threshold":{const t=ci(null!=e.value?{...e,x:e.value}:e,o);if(null==t)return null;const r=e.color||"#f97316",i=e.labelPosition||"top";let s;s="bottom"===i?(o.height||0)-4:"center"===i?(o.height||0)/2:16;const a=t>.6*(o.width||0),c=a?t-4:t+4,l=a?"end":"start";return(0,Oi.jsxs)("g",{opacity:e.opacity,children:[(0,Oi.jsx)("line",{x1:t,y1:0,x2:t,y2:o.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Oi.jsx)(Ei,{x:c,y:s,text:e.label,textAnchor:l,fill:r,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"y-threshold":{const t=li(null!=e.value?{...e,y:e.value}:e,o);if(null==t)return null;const r=e.color||"#f97316",i=e.labelPosition||"right";let a,c;"left"===i?(a=4,c="start"):"center"===i?(a=(o.width||0)/2,c="middle"):(a=(o.width||0)-4,c="end");const l=20>(s=t)?Math.min((o.height||0)-4,s+16):s-4;return(0,Oi.jsxs)("g",{opacity:e.opacity,children:[(0,Oi.jsx)("line",{x1:0,y1:t,x2:o.width||0,y2:t,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Oi.jsx)(Ei,{x:a,y:l,text:e.label,textAnchor:c,fill:r,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"enclose":{const t=(e.coordinates||[]).map(e=>({x:ci({...e,type:"point"},o),y:li({...e,type:"point"},o),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const r=(0,ri.packEnclose)(t),i=e.padding||10;return(0,Oi.jsxs)("g",{children:[(0,Oi.jsx)("circle",{cx:r.x,cy:r.y,r:r.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,Oi.jsx)(Ei,{x:r.x,y:r.y-r.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"rect-enclose":{const t=(e.coordinates||[]).map(e=>({x:ci({...e,type:"point"},o),y:li({...e,type:"point"},o)})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const r=e.padding||10,i=t.map(e=>e.x),s=t.map(e=>e.y),[a,c]=ve(i),[l,u]=ve(s),d=a-r,h=c+r,f=l-r;return(0,Oi.jsxs)("g",{children:[(0,Oi.jsx)("rect",{x:d,y:f,width:h-d,height:u+r-f,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,Oi.jsx)(Ei,{x:(d+h)/2,y:f-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"highlight":{const t=o.data||[],r="function"==typeof e.filter?t.filter(e.filter):e.field&&null!=e.value?t.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return(0,Oi.jsx)("g",{children:r.map((t,n)=>{const r=ci(t,o),s=li(t,o);if(null==r||null==s)return null;const a="function"==typeof e.r?e.r(t):e.r||6,c="function"==typeof e.style?e.style(t):e.style||i;return(0,Oi.jsx)("circle",{cx:r,cy:s,r:a,...c},"hl-"+n)})},"ann-"+n)}case"bracket":{const t=ci(e,o),r=li(e,o);return(0,Oi.jsx)(oi,{noteData:{x:t??0,y:r??0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+n)}case"trend":{const t=o.data||[];if(2>t.length)return null;const r=o.xAccessor||"x",i=o.yAccessor||"y",s="ordinal"===o.frameType,a="horizontal"===o.projection,c=s?r:null,l=s?i:null;let u;const d=[],h=new Map;if(s&&c&&l){for(const e of t){const t=e[c];if(null==t)continue;const n=t+"";h.has(n)||(h.set(n,d.length),d.push(n))}u=t.map(e=>{const t=e[c],n=e[l];if(null==t||null==n)return null;const o=h.get(t+"");return null!=o?[o,+n]:null}).filter(e=>null!==e)}else u=t.map(e=>[e[r],e[i]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const f=o.scales?.x??o.scales?.time,p=o.scales?.y??o.scales?.value;if(!f||!p)return null;const y=e=>t=>{const n=Math.max(0,Math.floor(t)),o=Math.min(d.length-1,n+1),r=t-n,i=e(d[n]);return i+(e(d[o])-i)*r},g=f,m=p;let x;if(s)if(a){const e=y(m);x=(t,n)=>[g(n),e(t)]}else{const e=y(g);x=(t,n)=>[e(t),m(n)]}else x=(e,t)=>[g(e),m(t)];const b=e.method||"linear";let v;if("loess"===b)v=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),r=o.map(e=>e[0]),i=o.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=r[e],o=r.map(e=>Math.abs(e-t)),c=o.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,l=[];for(let e=0;n>e;e++){const t=0===c?0:o[e]/c;l[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,f=0,p=0;for(let e=0;n>e;e++){const t=l[e];0!==t&&(u+=t,d+=t*r[e],h+=t*i[e],f+=t*r[e]*r[e],p+=t*r[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const y=u*f-d*d;if(1e-12>Math.abs(y))a.push([t,h/u]);else{const e=(u*p-d*h)/y;a.push([t,(h-e*d)/u+e*t])}}return a}(u,e.bandwidth??.3);else{const t="polynomial"===b?ai(u,e.order||2):function(e){const t=[0,0,0,0];let n=0;for(const[o,r]of e)null!==r&&(n++,t[0]+=o,t[1]+=r,t[2]+=o*o,t[3]+=o*r);const o=n*t[2]-t[0]*t[0],r=0===o?0:si((n*t[3]-t[0]*t[1])/o),i=si(t[1]/n-r*t[0]/n);return{points:e.map(([e])=>[si(e),si(r*e+i)]),equation:[r,i]}}(u);v=t.points}const w=v.map(([e,t])=>{const[n,o]=x(e,t);return`${n},${o}`}).join(" "),k=e.color||"#6366f1",S=v[v.length-1],[A,M]=x(S[0],S[1]);return(0,Oi.jsxs)("g",{children:[(0,Oi.jsx)("polyline",{points:w,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Oi.jsx)("text",{x:A+4,y:M-4,fill:k,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const t=o.scales?.y??o.scales?.value,s=t?.domain?.(),a=e.y0??s?.[0],c=e.y1??s?.[1],l=null!=a&&t?t(a):0,u=null!=c&&t?t(c):o.height||0,d=No(e.fill,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,Oi.jsxs)("g",{opacity:e.opacity,children:[d.def&&(0,Oi.jsx)("defs",{children:d.def}),(0,Oi.jsx)("rect",{x:0,y:Math.min(l,u),width:o.width||0,height:Math.abs(u-l),fill:d.fill,fillOpacity:e.fillOpacity||.1}),e.label&&(0,Oi.jsx)(Ei,{x:(o.width||0)-4,y:(r=l,i=u,Math.max(Math.min(r,i),0)+16),textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"x-band":{const t=o.scales?.x??o.scales?.time,r=t?.domain?.(),i=e.x0??r?.[0],s=e.x1??r?.[1],a=null!=i&&t?t(i):null,c=null!=s&&t?t(s):null;if(null==a||null==c)return null;const l=No(e.fill||e.color,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,Oi.jsxs)("g",{opacity:e.opacity,children:[l.def&&(0,Oi.jsx)("defs",{children:l.def}),(0,Oi.jsx)("rect",{x:Math.min(a,c),y:0,width:Math.abs(c-a),height:o.height||0,fill:l.fill,fillOpacity:e.fillOpacity??.1}),e.label&&(0,Oi.jsx)(Ei,{x:Math.min(a,c)+4,y:16,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"envelope":{const t=o.data||[];if(2>t.length)return null;const r=o.xAccessor||"x",i=o.scales?.x??o.scales?.time,s=o.scales?.y??o.scales?.value;if(!i||!s)return null;const a=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",l=e.filter,u=t.filter(e=>null!=e[a]&&null!=e[c]&&!(l&&!l(e))).sort((e,t)=>e[r]-t[r]);if(2>u.length)return null;const d=Di[o.curve||"linear"]||ii.curveLinear,h=(0,ii.area)().x(e=>i(e[r])).y0(e=>s(e[c])).y1(e=>s(e[a])).curve(d)(u);if(!h)return null;const f=e.fill||"#6366f1";return(0,Oi.jsxs)("g",{children:[(0,Oi.jsx)("path",{d:h,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&(0,Oi.jsx)("text",{x:i(u[u.length-1][r])+4,y:s(u[u.length-1][a])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const t=o.data||[];if(2>t.length)return null;const r=o.yAccessor||"y",i=o.scales?.x??o.scales?.time,s=o.scales?.y??o.scales?.value;if(!i||!s)return null;const a=t.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const c=a.reduce((e,t)=>e+t,0)/a.length,l=a.reduce((e,t)=>e+(t-c)**2,0)/a.length,u=Math.sqrt(l),d=e.threshold??2,h=c-d*u,f=!1!==e.showBand,p=e.fill||"#6366f1",y=e.fillOpacity??.1,g=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,x=s(c+d*u),b=s(h),v=t.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-c)>d*u});return(0,Oi.jsxs)("g",{children:[f&&(0,Oi.jsx)("rect",{x:0,y:Math.min(x,b),width:o.width||0,height:Math.abs(b-x),fill:p,fillOpacity:y}),v.map((e,t)=>{const n=ci(e,o),r=li(e,o);return null==n||null==r?null:(0,Oi.jsx)("circle",{cx:n,cy:r,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+t)}),e.label&&(0,Oi.jsx)("text",{x:(o.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:p,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const t=o.data||[];if(3>t.length)return null;const r=o.xAccessor||"x",i=o.yAccessor||"y",s=o.scales?.x??o.scales?.time,a=o.scales?.y??o.scales?.value;if(!s||!a)return null;const c=t.map(e=>[e[r],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let l;if("polynomial"===(e.method||"linear")){const t=ai(c,e.order||2).equation;l=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const e=c.length;let t=0,n=0,o=0,r=0;for(const[e,i]of c)t+=e,n+=i,o+=e*e,r+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const s=(e*r-t*n)/i,a=(n-s*t)/e;l=e=>a+s*e}const u=c.length,d=c.map(([e,t])=>t-l(e)),h=d.reduce((e,t)=>e+t*t,0),f=Math.sqrt(h/Math.max(u-2,1)),p=c.reduce((e,t)=>e+t[0],0)/u,y=c.reduce((e,t)=>e+(t[0]-p)**2,0),g=e.confidence??.95,m=.99>g?.95>g?.9>g?1:1.645:1.96:2.576,x=e.steps??5,b=c[u-1][0],v=(b-c[0][0])/Math.max(u-1,1),w=[];for(let e=1;x>=e;e++)w.push(b+e*v);const k=[];for(const e of w){const t=l(e),n=f*Math.sqrt(1+1/u+(y>0?(e-p)**2/y:0))*m;k.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const S=`M${k.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${k.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,A=k.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),M=`${s(b)},${a(l(b))}`,_=e.strokeColor||"#6366f1";return(0,Oi.jsxs)("g",{children:[(0,Oi.jsx)("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),(0,Oi.jsx)("polyline",{points:`${M} ${A}`,fill:"none",stroke:_,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&k.length>0&&(0,Oi.jsx)("text",{x:s(k[k.length-1].x)+4,y:a(k[k.length-1].yCenter)-4,fill:_,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let r,i;if(null!=e.px&&null!=e.py)r=e.px,i=e.py;else{const t=hi(e,n,o);if(!t)return null;r=t.x,i=t.y}if(!fi(r,i,o))return null;const s=e.dx??0,a=e.dy??0,c=e.width??32,l=e.height??32,u=e.content??(0,Oi.jsx)("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return(0,Oi.jsx)("foreignObject",{x:r+s-c/2,y:i+a-l/2,width:c,height:l,style:{overflow:"visible",pointerEvents:"auto"},children:(0,Oi.jsx)("div",{...Ii(e,t),style:{width:c,height:l,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const t=hi(e,n,o);if(!t)return null;const{x:r,y:i}=t,s=r+(e.dx||0),a=i+(e.dy||0),c=e.color||"var(--semiotic-text, #333)",l=(0,Oi.jsx)("text",{x:s,y:a,fill:c,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?Ur.cloneElement(l,{key:"ann-text-"+n}):(0,Oi.jsxs)("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[(0,Oi.jsx)("line",{x1:r,y1:i,x2:s,y2:a,stroke:c,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),Ur.cloneElement(l,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+n)}case"category-highlight":{const t=e.category;if(null==t)return null;const r=e=>"function"==typeof e&&"function"==typeof e.bandwidth,i=o.scales?.o,s=o.scales?.x,a=o.scales?.y,c=r(i)?i:r(s)?s:r(a)?a:null;if(!c)return null;const l=c(t+"");if(null==l)return null;const u=c.bandwidth(),d=e.color||"var(--semiotic-primary, #4589ff)",h=e.opacity??.15,f=e.label;return(0,Oi.jsxs)("g",(o.projection?"vertical"===o.projection:c===s)?{children:[(0,Oi.jsx)("rect",{x:l,y:0,width:u,height:o.height||0,fill:d,fillOpacity:h}),f&&(0,Oi.jsx)(Ei,{x:l+u/2,y:16,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]}:{children:[(0,Oi.jsx)("rect",{x:0,y:l,width:o.width||0,height:u,fill:d,fillOpacity:h}),f&&(0,Oi.jsx)(Ei,{x:12,y:l+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]},"ann-"+n)}default:return null}var r,i,s}}(0,G),r={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:z,yAccessor:E,width:t,height:n,data:O,frameType:"xy",pointNodes:D,curve:B,stickyPositionCache:Q.current};return Bi(T?ds({annotations:e,context:r,..."object"==typeof T?T:{}}):e,o,$,r)},[j,T,$,t,n,z,E,O,s,D,B,G]),ne=function(e){const t=(0,fs.useSyncExternalStore)(e?vs:ks,e?bs:Ss,e?bs:Ss);return e?t.positions.get(e)??null:null}(W);return(0,yr.useEffect)(()=>{if(!ne?.locked||!W)return;const e=e=>{"Escape"===e.key&&xs(W)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[ne?.locked,W]),a||g||m||A||M||te&&te.length>0||y||Y||ne?(0,Os.jsxs)("svg",{role:"img",width:o,height:r,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[(0,Os.jsx)("title",{children:"string"==typeof g?g:"XY Chart"}),(0,Os.jsx)("desc",{children:"string"==typeof g?g+" (XY data visualization)":"XY data visualization"}),(0,Os.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[y&&s&&(!F||N)&&(()=>{const e=js(c?.find(e=>"bottom"===e.orient)?.gridStyle),o=js(c?.find(e=>"left"===e.orient)?.gridStyle);return(0,Os.jsxs)("g",{className:"stream-grid",children:[U.map((t,o)=>(0,Os.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+o)),K.map((e,n)=>(0,Os.jsx)("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"ygrid-"+n))]})})(),a&&s&&(()=>{const e=c?.find(e=>"left"===e.orient),o=c?.find(e=>"bottom"===e.orient),r=!e||!1!==e.baseline,i=!o||!1!==o.baseline,s=e?.jaggedBase||!1,a=o?.jaggedBase||!1,h=o?.landmarkTicks,f=e?.landmarkTicks,p="var(--semiotic-border, #ccc)",y="var(--semiotic-text-secondary, var(--semiotic-text, #666))",g="var(--semiotic-text, #333)",m=!!o?.autoRotate&&U.length>1&&(()=>{const e=t/Math.max(U.length-1,1);return U.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})(),x=m?12:18,b=n+(m?58:40),v={fontSize:"var(--semiotic-tick-font-size, 12px)"},w={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},k={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},S=o?.tickAnchor,A=e?.tickAnchor,M=Ps(U),_=Ps(K);return(0,Os.jsxs)("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[(0,Os.jsxs)("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!F||N)&&i&&!a&&(0,Os.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:p,strokeWidth:1}),(!F||N)&&a&&(0,Os.jsx)("path",{d:Rs("bottom",t,n),fill:"none",stroke:p,strokeWidth:1}),U.map((e,t)=>{const o=!!h&&("function"==typeof h?h(e.value,t):xo(e.value,t>0?U[t-1].value:void 0));return(0,Os.jsxs)("g",{transform:`translate(${e.pixel},${n})`,children:[(0,Os.jsx)("line",{y2:5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Os.jsx)("text",{y:x,textAnchor:m?"end":Ms(S,e.pixel===M.min,e.pixel===M.max),fontWeight:o?600:400,fill:y,className:"semiotic-axis-tick",style:{userSelect:"none",...o?w:v},transform:m?"rotate(-45)":void 0,children:e.label}):(0,Os.jsx)("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:(0,Os.jsx)("div",{style:{textAlign:"center",userSelect:"none",...v},children:e.label})})]},"xtick-"+t)}),l&&(0,Os.jsx)("text",{x:t/2,y:b,textAnchor:"middle",fill:g,className:"semiotic-axis-label",style:{userSelect:"none",...k},children:l})]}),(0,Os.jsxs)("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!F||N)&&r&&!s&&(0,Os.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:p,strokeWidth:1}),(!F||N)&&s&&(0,Os.jsx)("path",{d:Rs("left",t,n),fill:"none",stroke:p,strokeWidth:1}),K.map((e,t)=>{const n=!!f&&("function"==typeof f?f(e.value,t):xo(e.value,t>0?K[t-1].value:void 0));return(0,Os.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,Os.jsx)("line",{x2:-5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Os.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:_s(A,e.pixel===_.min,e.pixel===_.max),fontWeight:n?600:400,fill:y,className:"semiotic-axis-tick",style:{userSelect:"none",...n?w:v},children:e.label}):(0,Os.jsx)("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,Os.jsx)("div",{style:{textAlign:"right",userSelect:"none",...v},children:e.label})})]},"ytick-"+t)}),(()=>{const t=e?.label||u;return t?(0,Os.jsx)("text",{x:15-V,y:n/2,textAnchor:"middle",fill:g,transform:`rotate(-90, ${15-V}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...k},children:t}):null})()]}),(()=>{const e=c?.find(e=>"right"===e.orient);if(!e||0===Z.length)return null;const o=!1!==e.baseline,r=e.landmarkTicks,i=e.label||d,s=e.tickAnchor,a=Ps(Z);return(0,Os.jsxs)("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[o&&(0,Os.jsx)("line",{x1:t,y1:0,x2:t,y2:n,stroke:p,strokeWidth:1}),Z.map((e,n)=>{const o=!!r&&("function"==typeof r?r(e.value,n):xo(e.value,n>0?Z[n-1].value:void 0));return(0,Os.jsxs)("g",{transform:`translate(${t},${e.pixel})`,children:[(0,Os.jsx)("line",{x2:5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Os.jsx)("text",{x:8,textAnchor:"start",dominantBaseline:_s(s,e.pixel===a.min,e.pixel===a.max),fontWeight:o?600:400,fill:y,className:"semiotic-axis-tick",style:{userSelect:"none",...o?w:v},children:e.label}):(0,Os.jsx)("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,Os.jsx)("div",{style:{textAlign:"left",userSelect:"none",...v},children:e.label})})]},"ytick-r-"+n)}),i&&(0,Os.jsx)("text",{x:t+X-15,y:n/2,textAnchor:"middle",fill:g,transform:`rotate(90, ${t+X-15}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...k},children:i})]})})()]})})(),te,M&&s&&_&&P&&(0,Os.jsxs)(Os.Fragment,{children:[M.top&&(0,Os.jsx)("g",{transform:"translate(0, 0)",children:(0,Os.jsx)(Xr,{orient:"top",config:Vr(M.top),values:_,scale:s.x,size:i.top,length:t})}),M.bottom&&(0,Os.jsx)("g",{transform:`translate(0, ${n})`,children:(0,Os.jsx)(Xr,{orient:"bottom",config:Vr(M.bottom),values:_,scale:s.x,size:i.bottom,length:t})}),M.left&&(0,Os.jsx)("g",{transform:"translate(0, 0)",children:(0,Os.jsx)(Xr,{orient:"left",config:Vr(M.left),values:P,scale:s.y,size:i.left,length:n})}),M.right&&(0,Os.jsx)("g",{transform:`translate(${t}, 0)`,children:(0,Os.jsx)(Xr,{orient:"right",config:Vr(M.right),values:P,scale:s.y,size:i.right,length:n})})]}),A,ne&&ne.sourceId!==q&&s?.x&&(()=>{const e=s.x(ne.xValue);if(null==e||0>e||e>t)return null;const o=ne.locked;return(0,Os.jsx)("line",{x1:e,y1:0,x2:e,y2:n,stroke:o?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:o?1.5:1,strokeDasharray:o?"6,3":"4,4",pointerEvents:"none"})})(),Y]}),g&&"string"==typeof g?(0,Os.jsx)("text",{x:o/2,y:Ts,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:g}):g?(0,Os.jsx)("foreignObject",{x:0,y:0,width:o,height:i.top,children:g}):null,qr({legend:m,totalWidth:o,totalHeight:r,margin:i,legendPosition:k,title:g,legendLayout:S,legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:v,legendIsolatedCategories:w})]}):null}var Ws=y(require("react")),qs=require("d3-shape");function Ys(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function Gs(e,t,n,o){if(2>e.length||t.length!==e.length||0===n.length)return[];const r=[],i=(e,t,n)=>{const o=r[r.length-1];o?.color===e?o.path.push(n):r.push({color:e,path:[t,n]})};for(let r=1;e.length>r;r++){const[s,a]=e[r-1],[c,l]=e[r],u=t[r-1],d=t[r]-u,h=[0,...0===d?[]:n.map(({value:e})=>(e-u)/d).filter(e=>e>0&&1>e&&Number.isFinite(e)).sort((e,t)=>e-t).filter((e,t,n)=>0===t||e!==n[t-1]),1];for(let e=1;h.length>e;e++){const t=h[e-1],r=h[e];i(Ys(u+d*((t+r)/2),n,o),[s+(c-s)*t,a+(l-a)*t],[s+(c-s)*r,a+(l-a)*r])}}return r}function Hs(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}function Vs(e){const t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(e.w,e.h)/2,o=e=>Math.max(0,Math.min(e??0,n));return{tl:o(t.tl),tr:o(t.tr),br:o(t.br),bl:o(t.bl)}}var Xs=require("react/jsx-runtime"),Us={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Ks(e,t="#4e79a7"){return Oo(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function Zs(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}function Qs(e,t,n,o){const r=e.glyph;if(!r?.parts?.length||0>=e.size)return null;const i=wo(r,e.size);if(0>=i.scale)return null;const s=`translate(${t},${n})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${i.offsetX},${i.offsetY}) scale(${i.scale})`,a=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),c=Mo(r,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),l=c?Zs(o+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>r.parts.map((n,o)=>{const r=t?"none"===n.fill?void 0:t:ko(n.fill,a,e.accent),i=t?n.stroke&&"none"!==n.stroke?t:void 0:ko(n.stroke??"none",a,e.accent);return r||i?(0,Xs.jsx)("path",{d:n.d,fill:r??"none",stroke:i,strokeWidth:i?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},o):null});return(0,Xs.jsxs)("g",{transform:s,opacity:1===u?void 0:u,children:[c&&l&&(0,Xs.jsx)("clipPath",{id:l,children:(0,Xs.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&e.ghostColor?(0,Xs.jsx)("g",{children:d(e.ghostColor)}):null,c&&l?(0,Xs.jsx)("g",{clipPath:`url(#${l})`,children:d()}):d()]},o)}function Js(e,t){const n=e.filter(e=>Number.isFinite(e.offset)&&(null==e.opacity||Number.isFinite(e.opacity))).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color??t,opacity:null==e.opacity?void 0:Math.max(0,Math.min(1,e.opacity))}));return 2>n.length?null:n.map((e,t)=>(0,Xs.jsx)("stop",{offset:e.offset,stopColor:e.color,stopOpacity:e.opacity},t))}function ea(e,t,n){const o=un(e.symbolType,e.size,e.path);return(0,Xs.jsx)("path",{d:o,transform:e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`,fill:e.style.fill?Ks(e.style.fill):"none",fillOpacity:e.style.fillOpacity,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${n??""}symbol-${t}`)}var ta=y(require("react")),na=require("d3-shape"),oa=require("react/jsx-runtime"),ra=y(require("react")),ia=require("react/jsx-runtime"),sa=y(require("react")),aa=require("d3-shape"),ca=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)});function la(e){const{innerRadius:t,outerRadius:n,startAngle:o,endAngle:r}=e,i=0>=t;if(0>=(e.cornerRadius??0)||!e.roundStart&&!e.roundEnd){if(i){const e=ca(n,o),t=ca(n,r);return`M0,0 L${e.x},${e.y} A${n},${n} 0 ${r-o>Math.PI?1:0} 1 ${t.x},${t.y} Z`}const e=ca(n,o),s=ca(n,r),a=ca(t,r),c=ca(t,o),l=r-o>Math.PI?1:0;return`M${e.x},${e.y} A${n},${n} 0 ${l} 1 ${s.x},${s.y} L${a.x},${a.y} A${t},${t} 0 ${l} 0 ${c.x},${c.y} Z`}const s=Math.max(0,Math.min(e.cornerRadius??0,(n-t)/2));if(0===s)return la({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const a=Math.asin(Math.min(1,s/Math.max(1e-9,n-s))),c=i?0:Math.asin(Math.min(1,s/Math.max(1e-9,t+s))),l=r-o,u=e.roundStart&&e.roundEnd?l/2:l,d=!!e.roundStart&&u>a,h=!!e.roundEnd&&u>a;if(!d&&!h)return la({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const f=o+(d?a:0),p=r-(h?a:0),y=o+(d?c:0),g=r-(h?c:0),m=ca(n,f),x=ca(n,p),b=(n-s)*Math.cos(a),v=ca(b,o),w=ca(b,r),k=i?null:ca(t,g),S=i?null:ca(t,y),A=i?0:(t+s)*Math.cos(c),M=i?null:ca(A,o),_=i?null:ca(A,r),P=p-f>Math.PI?1:0,j=i?0:g-y>Math.PI?1:0;let R="";if(d)R+=`M${v.x},${v.y}`,R+=` A${s},${s} 0 0 1 ${m.x},${m.y}`;else{const e=ca(n,o);R+=`M${e.x},${e.y}`}if(h)R+=` A${n},${n} 0 ${P} 1 ${x.x},${x.y}`,R+=` A${s},${s} 0 0 1 ${w.x},${w.y}`;else{const e=ca(n,r);R+=` A${n},${n} 0 ${P} 1 ${e.x},${e.y}`}if(i)R+=" L0,0";else{if(h)R+=` L${_.x},${_.y}`,R+=` A${s},${s} 0 0 1 ${k.x},${k.y}`;else{const e=ca(t,r);R+=` L${e.x},${e.y}`}if(d)R+=` A${t},${t} 0 ${j} 0 ${S.x},${S.y}`,R+=` A${s},${s} 0 0 1 ${M.x},${M.y}`;else{const e=ca(t,o);R+=` A${t},${t} 0 ${j} 0 ${e.x},${e.y}`}}return R+=" Z",R}var ua=require("react/jsx-runtime");function da(e){return 1e6>e?1e4>e?1e3>e?e+"":(e/1e3).toFixed(1)+"K":(e/1e3).toFixed(0)+"K":(e/1e6).toFixed(1)+"M"}function ha(e,t){const n=e.datum;if(!n)return null;const o=[],r=n.__funnelStepLabel,i=Number(n.__funnelStepLabelX),s=Number(n.__funnelStepLabelY),a=Number(n.__funnelRowWidth);"string"!=typeof r||!Number.isFinite(i)||!Number.isFinite(s)||Number.isFinite(a)&&8.4*r.length+16>a||o.push((0,ua.jsx)("text",{x:i,y:s+3,textAnchor:"middle",dominantBaseline:"hanging",fontSize:14,fontWeight:"bold",fill:"#fff",stroke:"rgba(0,0,0,0.6)",strokeWidth:3,paintOrder:"stroke",children:r},t+"-funnel-step"));const c=Number(n.__funnelValue),l=Number(n.__funnelValueLabelX),u=Number(n.__funnelValueLabelY),d=Number(n.__funnelBarW);if(Number.isFinite(c)&&0!==c&&Number.isFinite(l)&&Number.isFinite(u)&&d>=60){const e=Number(n.__funnelPercent);let r=!0!==n.__funnelIsFirstStep&&Number.isFinite(e)?`${da(c)} (${.05>Math.abs(e-Math.round(e))?Math.round(e):e.toFixed(1)}%)`:da(c);7.8*r.length+16>d&&(r=da(c)),7.8*r.length+16>d||o.push((0,ua.jsx)("text",{x:l,y:u+22,textAnchor:"middle",dominantBaseline:"hanging",fontSize:13,fontWeight:"bold",fill:"#fff",stroke:"rgba(0,0,0,0.5)",strokeWidth:3,paintOrder:"stroke",children:r},t+"-funnel-value"))}return o.length?(0,ua.jsx)("g",{children:o},t+"-funnel-labels"):null}function fa(e,t,n){const o=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",r=n=>`ord-${e.type}-${o}-${t}-${n}`,i=`ord-${e.type}-${o}-${t}`;switch(e.type){case"rect":{const t=e,n=Zs(i)+"-grad",o=function(e,t){const n=e.fillGradient;if(!n||"object"!=typeof n)return null;let o=e.x,r=e.y,i=e.x,s=e.y+e.h;"bottom"===e.roundedEdge?(r=e.y+e.h,s=e.y):"right"===e.roundedEdge?(o=e.x+e.w,r=e.y,i=e.x,s=e.y):"left"===e.roundedEdge&&(o=e.x,r=e.y,i=e.x+e.w,s=e.y);const a=Js(n.stops,Ks(e.style.fill));return a?(0,Xs.jsx)("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:o,y1:r,x2:i,y2:s,children:a}):null}(t,n);let r,s;if(o)s=`url(#${n})`;else if(Oo(t.style.fill)){const e=Zs(i)+"-hatch";r=Fo(t.style.fill,e),s=`url(#${e})`}else s=Ks(t.style.fill);const a=o||r?(0,ua.jsxs)("defs",{children:[o,r]}):null;if(t.cornerRadii&&Hs(t.cornerRadii)){const e=function(e){const{x:t,y:n,w:o,h:r}=e,{tl:i,tr:s,br:a,bl:c}=Vs(e);let l=`M${t+i},${n}`;return l+=` L${t+o-s},${n}`,s>0&&(l+=` A${s},${s} 0 0 1 ${t+o},${n+s}`),l+=` L${t+o},${n+r-a}`,a>0&&(l+=` A${a},${a} 0 0 1 ${t+o-a},${n+r}`),l+=` L${t+c},${n+r}`,c>0&&(l+=` A${c},${c} 0 0 1 ${t},${n+r-c}`),l+=` L${t},${n+i}`,i>0&&(l+=` A${i},${i} 0 0 1 ${t+i},${n}`),l+=" Z",l}(t);return(0,ua.jsxs)(sa.Fragment,{children:[a,(0,ua.jsx)("path",{d:e,fill:s,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},i)}if(t.roundedTop&&t.roundedTop>0){const e=Math.min(t.roundedTop,t.w/2,t.h/2),{x:n,y:o,w:r,h:c}=t;let l;switch(t.roundedEdge){case"right":l=`M${n},${o} L${n+r-e},${o} A${e},${e} 0 0 1 ${n+r},${o+e} L${n+r},${o+c-e} A${e},${e} 0 0 1 ${n+r-e},${o+c} L${n},${o+c} Z`;break;case"left":l=`M${n+r},${o} L${n+e},${o} A${e},${e} 0 0 0 ${n},${o+e} L${n},${o+c-e} A${e},${e} 0 0 0 ${n+e},${o+c} L${n+r},${o+c} Z`;break;case"bottom":l=`M${n},${o} L${n+r},${o} L${n+r},${o+c-e} A${e},${e} 0 0 1 ${n+r-e},${o+c} L${n+e},${o+c} A${e},${e} 0 0 1 ${n},${o+c-e} Z`;break;default:l=`M${n},${o+c} L${n},${o+e} A${e},${e} 0 0 1 ${n+e},${o} L${n+r-e},${o} A${e},${e} 0 0 1 ${n+r},${o+e} L${n+r},${o+c} Z`}return(0,ua.jsxs)(sa.Fragment,{children:[a,(0,ua.jsx)("path",{d:l,fill:s,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},i)}return(0,ua.jsxs)(sa.Fragment,{children:[a,(0,ua.jsx)("rect",{x:t.x,y:t.y,width:t.w,height:t.h,fill:s,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth}),ha(t,i)]},i)}case"point":{const t=e;return(0,ua.jsx)("circle",{cx:t.x,cy:t.y,r:t.r,fill:Ks(t.style.fill),opacity:t.style.opacity??t.style.fillOpacity??.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},i)}case"symbol":return ea(e,t,n);case"glyph":return Qs(e,e.x,e.y,`${n??""}ord-glyph-${e.pointId??t}`);case"wedge":{const o=e;if(o._gradientBand&&o._gradientBand.colors.length>0){const e=Zs(`${n?n+"-":""}gauge-grad-${o.category||i}-${t}`),{clipPath:r,slices:s}=function(e){const t=la({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,cornerRadius:e.cornerRadius,roundStart:e.roundStart,roundEnd:e.roundEnd}),n=[],o=e.colors;if(o.length>0){const t=(e.endAngle-e.startAngle)/o.length;for(let r=0;o.length>r;r++)n.push({d:la({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle+r*t,endAngle:e.endAngle}),color:o[r]})}return{clipPath:t,slices:n}}({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds?.start??!0,roundEnd:o.roundedEnds?.end??!0,colors:o._gradientBand.colors});return(0,ua.jsxs)("g",{transform:`translate(${o.cx},${o.cy})`,opacity:o.style.opacity,fillOpacity:o.style.fillOpacity,children:[(0,ua.jsx)("defs",{children:(0,ua.jsx)("clipPath",{id:e,children:(0,ua.jsx)("path",{d:r})})}),(0,ua.jsx)("g",{clipPath:`url(#${e})`,children:s.map((e,t)=>(0,ua.jsx)("path",{d:e.d,fill:Ks(e.color)},t))}),o.style.stroke&&"none"!==o.style.stroke&&(0,ua.jsx)("path",{d:r,fill:"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},i)}let r;if(o.roundedEnds)r=la({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds.start,roundEnd:o.roundedEnds.end});else{const e=(0,aa.arc)().innerRadius(o.innerRadius).outerRadius(o.outerRadius).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2);o.cornerRadius&&e.cornerRadius(o.cornerRadius),r=e(Us)||""}return(0,ua.jsx)("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:Ks(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},i)}case"boxplot":{const t=e,n=t.columnWidth/2;return(0,ua.jsxs)("g","vertical"===t.projection?{children:[(0,ua.jsx)("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,ua.jsx)("rect",{x:t.x-n,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:Ks(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,ua.jsx)("line",{x1:t.x-n,y1:t.medianPos,x2:t.x+n,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2}),(0,ua.jsx)("line",{x1:t.x-.5*n,y1:t.minPos,x2:t.x+.5*n,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,ua.jsx)("line",{x1:t.x-.5*n,y1:t.maxPos,x2:t.x+.5*n,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1})]}:{children:[(0,ua.jsx)("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,ua.jsx)("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-n,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:Ks(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,ua.jsx)("line",{x1:t.medianPos,y1:t.y-n,x2:t.medianPos,y2:t.y+n,stroke:t.style.stroke||"#333",strokeWidth:2}),(0,ua.jsx)("line",{x1:t.minPos,y1:t.y-.5*n,x2:t.minPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,ua.jsx)("line",{x1:t.maxPos,y1:t.y-.5*n,x2:t.maxPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1})]},i)}case"violin":{const t=e,n=[(0,ua.jsx)("path",{d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:Ks(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:t.style.strokeWidth||1},r("path"))];if(t.iqrLine&&t.bounds){const e=t.bounds,o=e.x+e.width/2,i=e.y+e.height/2;t.iqrLine.isVertical?n.push((0,ua.jsx)("line",{x1:o,y1:t.iqrLine.q1Pos,x2:o,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2},r("iqr")),(0,ua.jsx)("circle",{cx:o,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},r("med"))):n.push((0,ua.jsx)("line",{x1:t.iqrLine.q1Pos,y1:i,x2:t.iqrLine.q3Pos,y2:i,stroke:t.style.stroke||"#333",strokeWidth:2},r("iqr")),(0,ua.jsx)("circle",{cx:t.iqrLine.medianPos,cy:i,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},r("med")))}return(0,ua.jsx)("g",{children:n},i)}case"connector":return(0,ua.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity??.5},i);case"trapezoid":{const t=e,n=t.points.map(e=>`${e[0]},${e[1]}`).join(" ");return(0,ua.jsx)("polygon",{points:n,fill:Ks(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},i)}default:return null}}var pa=require("react/jsx-runtime");function ya(e,t,n,o){if(!e||2>t.length)return null;const r=Js(e.stops,o);return r?(0,pa.jsx)("linearGradient",{id:n,gradientUnits:"userSpaceOnUse",x1:t[0][0],y1:0,x2:t[t.length-1][0],y2:0,children:r}):null}function ga(e,t,n){switch(e.type){case"line":{const o=e;if(0===o.path.length)return null;const r=qo(o.curve),i=r?(0,qs.line)().x(([e])=>e).y(([,e])=>e).curve(r)(o.path)??"":"M"+o.path.map(([e,t])=>`${e},${t}`).join("L"),s=Zs(`${n?n+"-":""}line-${t}-stroke-gradient`),a=ya(o.strokeGradient,o.path,s,o.style.stroke||"#4e79a7");return(0,pa.jsxs)(Ws.Fragment,{children:[a&&(0,pa.jsx)("defs",{children:a}),(0,pa.jsx)("path",{d:i,fill:"none",stroke:a?`url(#${s})`:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||2,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity})]},"line-"+t)}case"area":{const o=e;if(0===o.topPath.length)return null;const r=qo(o.curve),i=!r||2>o.topPath.length||2>o.bottomPath.length?`M${o.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...o.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`:(0,qs.area)().x(([e])=>e).y0((e,t)=>o.bottomPath[t][1]).y1(([,e])=>e).curve(r)(o.topPath)??"",s=`${n?n+"-":""}area-${t}-hatch`,a=Oo(o.style.fill)?Fo(o.style.fill,s):void 0,c=Zs(`${n?n+"-":""}area-${t}-gradient`),l=function(e,t){const n=e.fillGradient;if(!n||"object"!=typeof n)return null;let o=1/0;for(const[,t]of e.topPath)o=Math.min(o,t);let r=-1/0;for(const[,t]of e.bottomPath)r=Math.max(r,t);if(!Number.isFinite(o)||!Number.isFinite(r))return null;const i=Js(n.stops,Ks(e.style.fill));return i?(0,pa.jsx)("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:0,y1:o,x2:0,y2:r,children:i}):null}(o,c),u=l?`url(#${c})`:a?`url(#${s})`:Ks(o.style.fill),d=l?void 0:o.style.fillOpacity??o.style.opacity??.7,h=r?(0,qs.line)().x(([e])=>e).y(([,e])=>e).curve(r)(o.topPath)??"":"M"+o.topPath.map(([e,t])=>`${e},${t}`).join("L"),f=Zs(`${n?n+"-":""}area-${t}-stroke-gradient`),p=!(!o.colorThresholds?.length||!o.rawValues||o.rawValues.length!==o.topPath.length),y=!!o.strokeColorBands?.length,g=p||y?null:ya(o.strokeGradient,o.topPath,f,o.style.stroke||"#4e79a7"),m=o.style.strokeWidth||2;let x=1/0,b=-1/0;for(const[e]of o.topPath)x>e&&(x=e),e>b&&(b=e);const v=y?o.strokeColorBands.map((e,o)=>Zs(`${n?n+"-":""}area-${t}-stroke-band-${o}`)):[],w=y?o.strokeColorBands.map((e,t)=>(0,pa.jsx)("clipPath",{id:v[t],children:(0,pa.jsx)("rect",{x:x-m,y:e.y,width:b-x+2*m,height:e.height})},v[t])):null,k=o.style.stroke&&"none"!==o.style.stroke?y?o.strokeColorBands.map((e,n)=>(0,pa.jsx)("path",{d:h,fill:"none",stroke:e.color??Ks(o.style.stroke),strokeWidth:m,opacity:o.style.opacity,clipPath:`url(#${v[n]})`},`area-${t}-stroke-band-${n}`)):p?Gs(o.topPath,o.rawValues,o.colorThresholds,Ks(o.style.stroke)).map((e,n)=>(0,pa.jsx)("path",{d:"M"+e.path.map(([e,t])=>`${e},${t}`).join("L"),fill:"none",stroke:e.color,strokeWidth:m,opacity:o.style.opacity},`area-${t}-threshold-${n}`)):(0,pa.jsx)("path",{d:h,fill:"none",stroke:g?`url(#${f})`:Ks(o.style.stroke),strokeWidth:m,opacity:o.style.opacity}):null;if(o.clipRect){const e=`${n?n+"-":""}area-clip-${t}`;return(0,pa.jsxs)("g",{children:[(0,pa.jsxs)("defs",{children:[l,!l&&a,g,w,(0,pa.jsx)("clipPath",{id:e,children:(0,pa.jsx)("rect",{x:o.clipRect.x,y:o.clipRect.y,width:o.clipRect.width,height:o.clipRect.height})})]}),(0,pa.jsxs)("g",{clipPath:`url(#${e})`,children:[(0,pa.jsx)("path",{d:i,fill:u,fillOpacity:d,opacity:l?o.style.opacity:void 0,stroke:"none"}),k]})]},"area-"+t)}return(0,pa.jsxs)(Ws.Fragment,{children:[(l||a||g||w)&&(0,pa.jsxs)("defs",{children:[l,!l&&a,g,w]}),(0,pa.jsx)("path",{d:i,fill:u,fillOpacity:d,opacity:l?o.style.opacity:void 0,stroke:"none"}),k]},"area-"+t)}case"point":{const o=e,r=`${n?n+"-":""}point-${t}-hatch`,i=Oo(o.style.fill)?Fo(o.style.fill,r):void 0;return(0,pa.jsxs)(Ws.Fragment,{children:[i&&(0,pa.jsx)("defs",{children:i}),(0,pa.jsx)("circle",{cx:o.x,cy:o.y,r:o.r,fill:i?`url(#${r})`:Ks(o.style.fill),opacity:o.style.opacity??o.style.fillOpacity??.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"point-"+t)}case"symbol":return ea(e,t);case"glyph":return Qs(e,e.x,e.y,`${n??""}glyph-${e.pointId??t}`);case"rect":{const o=e,r=`${n?n+"-":""}xyrect-${t}-hatch`,i=Oo(o.style.fill)?Fo(o.style.fill,r):void 0;return(0,pa.jsxs)(Ws.Fragment,{children:[i&&(0,pa.jsx)("defs",{children:i}),(0,pa.jsx)("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:i?`url(#${r})`:Ks(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"rect-"+t)}case"heatcell":{const n=e;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[o,r,i]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(n.fill),s=.299*o+.587*r+.114*i>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return(0,pa.jsxs)("g",{children:[(0,pa.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill,stroke:n.style?.stroke,strokeWidth:n.style?.strokeWidth}),(0,pa.jsx)("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px",children:e})]},"heatcell-"+t)}return(0,pa.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill,stroke:n.style?.stroke,strokeWidth:n.style?.strokeWidth},"heatcell-"+t)}case"candlestick":{const n=e;if(n.isRange){const e=n.dotRadius??Math.max(2,n.bodyWidth/2);return(0,pa.jsxs)("g",{children:[(0,pa.jsx)("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),(0,pa.jsx)("circle",{cx:n.x,cy:n.highY,r:e,fill:n.wickColor}),(0,pa.jsx)("circle",{cx:n.x,cy:n.lowY,r:e,fill:n.wickColor})]},"candle-"+t)}const o=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return(0,pa.jsxs)("g",{children:[(0,pa.jsx)("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),(0,pa.jsx)("rect",{x:n.x-n.bodyWidth/2,y:o,width:n.bodyWidth,height:r,fill:i,stroke:i,strokeWidth:1})]},"candle-"+t)}default:return null}}var ma="undefined"==typeof window||"undefined"==typeof document,xa=require("react"),ba="undefined"!=typeof window?xa.useLayoutEffect:xa.useEffect,va=()=>()=>{},wa=()=>!1,ka=()=>!0,Sa=require("react");function Aa(e,t){const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;if(!Object.is(e[o],t[o]))return!1}return!0}function Ma(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function _a(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function Pa(e){const{background:t,hasBackgroundGraphics:n=!1,themeBackground:o=""}=e;return"transparent"===t||n?null:t||(o&&"transparent"!==o?o:"")||null}var ja={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white",primary:"#007bff",background:""};function Ra(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],o=n[2],r=n[3];return`#${e}${e}${o}${o}${r}${r}${t}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${t}`;const o=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return o?`rgba(${o[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:n}var Ca=y(require("react")),La=y(require("react")),Ia=(require("react/jsx-runtime"),La.createContext(null)),Ta=require("react/jsx-runtime"),$a={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function za({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+n}return(0,Ta.jsx)("div",{"aria-live":"polite","aria-atomic":"true",style:$a,children:t})}function Ea(e){const t={};if(null==e||"object"!=typeof e)return t;for(const[n,o]of Object.entries(e))n.startsWith("_")||null!=o&&""!==o&&("number"==typeof o?Number.isFinite(o)&&(t[n]=o):"string"==typeof o?t[n]=o:"boolean"==typeof o?t[n]=o+"":o instanceof Date&&(t[n]=o.toISOString().slice(0,10)));return t}function Oa(e){return e&&"object"==typeof e?e:{}}function Da(e){return Oa(e.accessibility).tableFields??e.accessibleDatum??e.datum}var Ba=require("react/jsx-runtime");function Fa(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e){if(null===t?.datum)continue;const e=t.type+"";n[e]=(n[e]||0)+1}if(0===Object.keys(n).length)return t+", empty";const o=[],r={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((e,t)=>{const n=i.indexOf(e),o=i.indexOf(t);return(-1===n?999:n)-(-1===o?999:o)});for(const e of s)o.push(`${n[e]} ${r[e]||e}`);return`${t}, ${o.join(", ")}`}var Na=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Wa="semiotic-accessible-data-table",qa=Wa+" semiotic-accessible-data-table-hidden",Ya=Wa+" semiotic-accessible-data-table-visible",Ga={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Ha={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Va={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},Xa={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Ua={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},Ka={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Za={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Qa={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function Ja({scene:e,chartType:t,tableId:n,chartTitle:o}){const[r,i]=Ca.useState(!1),[s,a]=Ca.useState(5),c=La.useContext(Ia),l=c?.visible??!1,u=r||l,d=Ca.useRef(null),h=o?"Data summary for "+o:n?`Data summary for ${t} ${n}`:"Data summary for "+t;Ca.useEffect(()=>{u||a(5)},[u]);const f=Ca.useCallback(e=>{e.target===e.currentTarget&&(r||l||i(!0))},[r,l]),p=Ca.useCallback(e=>{l||d.current?.contains(e.relatedTarget)||i(!1)},[l]);if(!e||0===e.length)return n?(0,Ba.jsx)("span",{id:n,tabIndex:-1,style:$a}):null;if(!u)return(0,Ba.jsx)("div",{id:n,className:qa,tabIndex:-1,onFocus:f,style:$a,role:"region","aria-label":h,children:(0,Ba.jsxs)("button",{type:"button",onClick:()=>i(!0),children:["View data summary (",e.length," elements)"]})});const y=function(e){const t=[];if(!Array.isArray(e))return t;const n=e.some(e=>e&&("line"===e.type||"area"===e.type));for(const o of e)if(o&&"object"==typeof o&&null!==o.datum)try{switch(o.type){case"point":if(n)break;t.push({label:"Point",values:Ea(Da(o))});break;case"line":case"area":{const e=Da(o),n=Array.isArray(e)?e:[],r="line"===o.type?"Line point":"Area point";for(const e of n)t.push({label:r,values:Ea(e)});break}case"rect":{const e=Da(o),n=null!=e&&"object"==typeof e?e:{},r=n.category??o.group??"",i=n.value??n.__aggregateValue??n.total,s=Ea(n);null==s.category&&""!==r&&(s.category=r+""),null==s.value&&null!=i&&(s.value="number"==typeof i||"string"==typeof i?i:i+""),t.push({label:"Bar",values:s});break}case"heatcell":{const e=Ea(Da(o));null==e.value&&"number"==typeof o.value&&Number.isFinite(o.value)&&(e.value=o.value),t.push({label:"Cell",values:e});break}case"wedge":{const e=Da(o),n=Ea(e);if(null==n.category){const t=Oa(e),o=t.category??t.label;null!=o&&(n.category=o+"")}t.push({label:"Wedge",values:n});break}case"circle":t.push({label:"Node",values:Ea(Da(o))});break;case"arc":t.push({label:"Arc",values:Ea(Da(o))});break;case"candlestick":t.push({label:"Candlestick",values:Ea(Da(o))});break;case"geoarea":{const e=Oa(Da(o)),n=Ea(e);if(null==n.name){const t=Oa(e.properties).name??e.name;null!=t&&(n.name=t+"")}t.push({label:"Region",values:n});break}}}catch{}return t}(e),g=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const o of t){const t=[],r=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[o];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&r.add(e+""))}if(t.length>0){let e=t[0],r=t[0],i=0;for(const n of t)e>n&&(e=n),n>r&&(r=n),i+=n;n.push({name:o,count:t.length,numeric:!0,min:e,max:r,mean:i/t.length})}else if(r.size>0){const e=Array.from(r);n.push({name:o,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(y),m=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${Na(e.min)} to ${Na(e.max)}, mean ${Na(e.mean)}.`);else{const t=e.uniqueValues,o=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${o}.`)}return n.join(" ")}(y.length,g),x=Math.min(s,y.length),b=y.slice(0,x),v=y.length-x,w=new Set;for(const e of b)for(const t of Object.keys(e.values))w.add(t);const k=Array.from(w);return(0,Ba.jsxs)("div",{ref:d,id:n,className:Ya,tabIndex:-1,onBlur:p,style:Ga,role:"region","aria-label":h,children:[(0,Ba.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{l&&c&&c.setVisible(!1),i(!1)},"aria-label":"Close data summary",style:Va,children:"×"}),(0,Ba.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Ha,children:m}),(0,Ba.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+t,style:Xa,children:[(0,Ba.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:Za,children:v>0?`First ${x} of ${y.length} data points`:`All ${y.length} data points`}),(0,Ba.jsx)("thead",{children:(0,Ba.jsxs)("tr",{children:[(0,Ba.jsx)("th",{style:Ua,children:"type"}),k.map(e=>(0,Ba.jsx)("th",{style:Ua,children:e},e))]})}),(0,Ba.jsx)("tbody",{children:b.map((e,t)=>(0,Ba.jsxs)("tr",{children:[(0,Ba.jsx)("td",{style:Ka,children:e.label}),k.map(t=>{return(0,Ba.jsx)("td",{style:Ka,children:(n=e.values[t],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":Na(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},t);var n})]},t))})]}),v>0&&(0,Ba.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(e=>e+25),style:Qa,children:["Show ",Math.min(25,v)," more"," ",1===v?"row":"rows"," (",v," remaining)"]})]})}function ec({summary:e}){return e?(0,Ba.jsx)("div",{role:"note",style:$a,children:e}):null}function tc({tableId:e}){return(0,Ba.jsx)("a",{href:"#"+e,style:$a,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,$a)},children:"Skip to data table"})}var nc=require("react/jsx-runtime"),oc="var(--semiotic-focus, #005fcc)";function rc({active:e,hoverPoint:t,margin:n,size:o,shape:r="circle",width:i,height:s,pathData:a}){if(!e||!t)return null;const c=t.x+n.left,l=t.y+n.top;let u;if("geoarea"!==r&&"path"!==r||!a)if("rect"===r&&null!=i&&null!=s){const e=Math.max(i,4),t=Math.max(s,4);u=(0,nc.jsx)("rect",{x:c-e/2-3,y:l-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:oc,strokeWidth:2,strokeDasharray:"4,2"})}else u=(0,nc.jsx)("circle","wedge"===r?{cx:c,cy:l,r:12,fill:"none",stroke:oc,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:c,cy:l,r:8,fill:"none",stroke:oc,strokeWidth:2,strokeDasharray:"4,2"});else u=(0,nc.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:(0,nc.jsx)("path",{d:a,fill:"none",stroke:oc,strokeWidth:2.5,strokeDasharray:"6,3"})});return(0,nc.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}var ic=y(require("react"));function sc(e,t){return"touch"===t?Math.max(e,24):e}function ac(e){return Array.isArray(e)?e[0]:e}function cc(e,t,n,o){return{data:ac(e),x:t,y:n,__semioticHoverData:!0,...o}}var lc=["name","label","title"],uc=["type","kind","category","group","class","status","role","shape"],dc=["value","amount","total","count","weight","score"],hc=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function fc(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}function pc(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,o=!1!==t.skipPositional,r=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(o&&hc.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&r.push({key:t,lower:t.toLowerCase(),value:n})}if(0===r.length)return{entries:[]};let i=r.findIndex(e=>lc.includes(e.lower));const s=i>=0;0>i&&(i=r.findIndex(e=>"id"===e.lower)),0>i&&(i=r.findIndex(e=>"string"==typeof e.value));const a=0>i?void 0:r[i];let c=r.filter((e,t)=>t!==i);s&&(c=c.filter(e=>"id"!==e.lower));const l=fc(c,uc),u=fc(c,dc),d=new Set(uc),h=new Set(dc),f=[];l&&f.push({key:l.key,value:l.value}),u&&f.push({key:u.key,value:u.value});for(const e of c){if(f.length>=n)break;e!==l&&e!==u&&(d.has(e.lower)||h.has(e.lower)||f.push({key:e.key,value:e.value}))}return{titleKey:a?.key,title:a?.value,entries:f}}var yc=require("react/jsx-runtime"),gc={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function mc(e,t){return"function"==typeof t?t(e):e[t]}function xc(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function bc(e={}){const{fields:t,title:n,format:o,style:r={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let s;const a=[];if(n){const t=mc(e,n);s=xc(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const s=mc(e,r);a.push({label:n,value:xc(s,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){s=xc(e[n],o);break}if(!s){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(s=xc(e[t[0]],o))}}const c={...gc,...r};return(0,yc.jsxs)("div",{className:("semiotic-tooltip "+i).trim(),style:c,children:[s&&(0,yc.jsx)("div",{style:{fontWeight:a.length>0?"bold":"normal"},children:s}),a.map((e,t)=>(0,yc.jsxs)("div",{style:{marginTop:0===t&&s?"4px":0},children:[e.label&&(0,yc.jsxs)("span",{children:[e.label,": "]}),e.value]},t))]})}}var vc=require("react/jsx-runtime");function wc({x:e,y:t,containerWidth:n,containerHeight:o,margin:r,children:i,className:s="stream-frame-tooltip",zIndex:a=1}){const c=Number.isFinite(e)&&Number.isFinite(t),l=ic.useRef(null),[u,d]=ic.useState(null);ic.useLayoutEffect(()=>{const e=l.current;if(!e)return;const t=()=>{const t=e.getBoundingClientRect();Number.isFinite(t.width)&&Number.isFinite(t.height)&&d(e=>e&&.5>Math.abs(e.width-t.width)&&.5>Math.abs(e.height-t.height)?e:{width:t.width,height:t.height})};if(t(),"undefined"==typeof ResizeObserver)return;const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[s,n,o,c]);let h;h=u?`translate(${u.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>o-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*o>t?"4px":"calc(-100% - 4px)"})`;const f=function(e){if(!ic.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if(!0===n["data-semiotic-tooltip-chrome"])return!0;if("true"===n["data-semiotic-tooltip-chrome"])return!0;const o=n.style;if(o&&"object"==typeof o){if(null!=o.background&&""!==o.background&&"transparent"!==o.background)return!0;if(null!=o.backgroundColor&&""!==o.backgroundColor&&"transparent"!==o.backgroundColor)return!0}return!1}(i),p=f?null:gc;return c?(0,vc.jsx)("div",{ref:l,className:f?s:(s+" semiotic-tooltip").trim(),style:{...p||{},position:"absolute",left:r.left+e,top:r.top+t,transform:h,pointerEvents:"none",zIndex:a,width:"max-content"},children:i}):null}var kc=y(require("react")),Sc=require("react"),Ac=require("react");var Mc=require("react"),_c=()=>"undefined"!=typeof performance?performance.now():Date.now();function Pc(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function jc(e,t){const n=e();return Number.isFinite(n)?n:t}var Rc=class{constructor(e={}){this.randomSource=Math.random,this.subscribers=new Set,this.now=()=>this.advance(),this.random=()=>this.randomSource(),this.clock=e.clock??_c,this.lastWallTime=jc(this.clock,0),this.logicalTime=this.lastWallTime,this.pausedValue=!0===e.paused,this.visibleValue=!1!==e.visible,this.setRandomSource(e.random,e.seed)}get isActive(){return!this.pausedValue&&this.visibleValue}get paused(){return this.pausedValue}get seed(){return this.seedValue}get visible(){return this.visibleValue}configure(e){this.setClock(e.clock),this.setRandomSource(e.random,e.seed)}setPaused(e){this.pausedValue!==e&&(this.advance(),this.pausedValue=e,this.emit())}setVisible(e){this.visibleValue!==e&&(this.advance(),this.visibleValue=e,this.emit())}snapshot(){return{now:this.now(),paused:this.pausedValue,seed:this.seedValue,visible:this.visibleValue}}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}advance(){const e=jc(this.clock,this.lastWallTime),t=Math.max(0,e-this.lastWallTime);return this.lastWallTime=e,this.isActive&&(this.logicalTime+=t),this.logicalTime}emit(){for(const e of this.subscribers)e()}setClock(e){const t=e??_c;t!==this.clock&&(this.advance(),this.clock=t,this.lastWallTime=jc(t,this.lastWallTime))}setRandomSource(e,t){const n=function(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):void 0}(t);e===this.randomInput&&n===this.seedValue||(this.randomInput=e,this.seedValue=n,this.randomSource=e??(void 0===n?Math.random:Pc(n)))}},Cc="undefined"==typeof window?Sc.useEffect:Sc.useLayoutEffect,Lc={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function Ic(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function Tc(e){const t=function(){const[e,t]=(0,Ac.useState)(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return(0,Ac.useEffect)(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),function(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}(e,e=>t(e.matches))},[]),e}(),n=(0,Sc.useRef)(t);n.current=t;const[o,r]=function(e,t,n){const o=(0,Mc.useRef)(null),[r,i]=(0,Mc.useState)(null);return(0,Mc.useEffect)(()=>{if(!t&&!n)return;const e=o.current;if(!e)return;const r=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;i(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return r.observe(e),()=>r.disconnect()},[t,n]),[o,[t&&r?r.w:e[0],n&&r?r.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),i=!!e.title,s=!!e.legend&&"top"===e.legendPosition,a=(0,Sc.useMemo)(()=>zs({...e.marginDefault,...e.userMargin},i,s),[e.marginDefault,e.userMargin,i,s]),c=r[0]-a.left-a.right,l=r[1]-a.top-a.bottom,u=Ic(e.foregroundGraphics,r,a),d=Ic(e.backgroundGraphics,r,a),h=Xe(e=>e.theme),{transition:f,introEnabled:p}=function(e,t){if(!1===e)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:e?!0===e?{duration:300}:{duration:e.duration??300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(n||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),y="semiotic-table-"+kc.useId(),g=(0,Sc.useRef)(null);if(!g.current){const t=!e.suspendWhenHidden||"undefined"==typeof document||!document.hidden;g.current=new Rc({clock:e.clock,random:e.random,seed:e.seed,paused:e.paused,visible:t})}const m=g.current;m.configure({clock:e.clock,random:e.random,seed:e.seed});const x=(0,Sc.useRef)(null),b=(0,Sc.useRef)(e.frameScheduler??Lc);b.current=e.frameScheduler??Lc;const v=(0,Sc.useRef)(null),w=(0,Sc.useRef)(!1),k=(0,Sc.useRef)(()=>{}),S=(0,Sc.useCallback)(()=>{if(null!==x.current||w.current)return;const e=b.current;let t=!1,n=!1;const o=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&(w.current=!0),x.current=null,v.current=null;try{k.current()}finally{e&&(w.current=!1)}});n=!0,t||(x.current=o,v.current=e)},[]),A=(0,Sc.useCallback)(()=>{null!==x.current&&((v.current??b.current).cancelAnimationFrame(x.current),x.current=null,v.current=null)},[]);Cc(()=>{m.setPaused(!0===e.paused)},[m,e.paused]),(0,Sc.useEffect)(()=>{if(!e.suspendWhenHidden||"undefined"==typeof document)return void m.setVisible(!0);const t=()=>m.setVisible(!document.hidden);return t(),document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[m,e.suspendWhenHidden]),(0,Sc.useEffect)(()=>()=>{A()},[A]);const M=(0,Sc.useRef)(()=>{}),_=(0,Sc.useRef)(()=>{}),P=(0,Sc.useRef)(null),j=(0,Sc.useRef)(null),R=(0,Sc.useRef)(null),C=(0,Sc.useCallback)(()=>{const e=P.current;P.current=null,e&&M.current(e)},[]),L=(0,Sc.useCallback)(e=>{if(P.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===j.current){const e=b.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,j.current=null,R.current=null,C()});t||(j.current=n,R.current=e)}},[C]),I=(0,Sc.useCallback)(()=>{P.current=null,null!==j.current&&((R.current??b.current).cancelAnimationFrame(j.current),j.current=null,R.current=null),_.current()},[]);(0,Sc.useEffect)(()=>()=>{P.current=null,null!==j.current&&((R.current??b.current).cancelAnimationFrame(j.current),j.current=null,R.current=null)},[]);const T=e.themeDirtyRef;return Cc(()=>{T&&(Ro++,T.current=!0,S())},[h,S,T]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:o,size:r,margin:a,adjustedWidth:c,adjustedHeight:l,resolvedForeground:u,resolvedBackground:d,currentTheme:h,transition:f,introEnabled:p,tableId:y,frameRuntime:m,rafRef:x,renderFnRef:k,scheduleRender:S,cancelRender:A,hoverHandlerRef:M,hoverLeaveRef:_,onPointerMove:L,onPointerLeave:I}}var $c=require("react"),zc=require("react/jsx-runtime");function Ec({children:e,size:t,margin:n,overflowVisible:o=!1}){return e?(0,zc.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:t[0],height:t[1],pointerEvents:"none",overflow:o?"visible":void 0},children:(0,zc.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:e})}):null}function Oc(e,t,n,o){return"function"==typeof e?e({size:t,margin:n,scales:o}):e}function Dc(e,t,n,o){const r=e.getContext("2d");if(!r)return null;const i=Math.round(t[0]*o),s=Math.round(t[1]*o),a=i/t[0],c=s/t[1],l=t[0]+"px",u=t[1]+"px";return e.style.width!==l&&(e.style.width=l),e.style.height!==u&&(e.style.height=u),e.width===i&&e.height===s||(e.width=i,e.height=s),r.setTransform(a,0,0,c,0,0),r.translate(n.left,n.top),r}var Bc=require("react");function Fc(e,t,n,o){return"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:o,fn:t}:{key:void 0,fn:null}}var Nc=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Wc=3156e7;function qc(e){const t=e[1]-e[0];return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:Wc>t?e=>{const t=new Date(e);return`${Nc[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*Wc>t?e=>{const t=new Date(e);return`${Nc[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function Yc(e){if(!e)return;const t=[];for(const n of e)if("point"===n.type)t.push(n);else if("symbol"===n.type)t.push({pointId:n.pointId,x:n.x,y:n.y,r:dn(n.size)});else if("glyph"===n.type){const e=_o(n.glyph,n.size);t.push({pointId:n.pointId,x:n.x+e.centerDx,y:n.y+e.centerDy,r:e.radius})}return t}var Gc=require("d3-shape");function Hc(e,t,n,o,r,i){if(2>t.length)return;const s=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],o=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(n*n+o*o))}const a=s[s.length-1];if(0===a)return;const c=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=i;for(let n=0;t.length-1>n;n++){const o=(s[n]+s[n+1])/2;let i=r;c>o&&(i*=o/c),c>a-o&&(i*=(a-o)/c),e.globalAlpha=Math.max(0,i),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}var Vc=(e,t,n,o)=>{const r=t.filter(e=>"line"===e.type);for(const t of r){if(2>t.path.length)continue;const n=t._introClipFraction;void 0!==n&&1>n&&(e.save(),e.beginPath(),e.rect(0,0,o.width*n,o.height),e.clip());const r=t.style.stroke||"#007bff",i=To(e,r)||r,s=t.style.strokeWidth||2,a=t.colorThresholds,c=t.rawValues;if(e.setLineDash(t.style.strokeDasharray?t.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),e.lineWidth=s,e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade){Hc(e,t.path,i,s,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const l=qo(t.curve),u=a&&a.length>0&&c&&c.length===t.path.length,d=t._decayOpacities;if(d&&d.length===t.path.length&&!u){e.strokeStyle=i;const n=t.style.opacity??1;for(let o=0;t.path.length-1>o;o++)e.globalAlpha=.5*(d[o]+d[o+1])*n,e.beginPath(),e.moveTo(t.path[o][0],t.path[o][1]),e.lineTo(t.path[o+1][0],t.path[o+1][1]),e.stroke()}else if(u){const n=Gs(t.path,c,a,i);for(const t of n){e.beginPath(),e.strokeStyle=To(e,t.color)||t.color,e.moveTo(t.path[0][0],t.path[0][1]);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1]);e.stroke()}}else{e.beginPath();const n=t.strokeGradient&&t.path.length>=2?Vo(e,t.strokeGradient,i,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=n||i,l)(0,Gc.line)().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,o]=t.path[0];e.moveTo(n,o);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}e.stroke()}if(t.style.fill&&t.style.fillOpacity&&t.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=t.style.fillOpacity,e.fillStyle=Yo(e,t.style.fill,t.style.fill),l&&!u)(0,Gc.line)().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,o]=t.path[0];e.moveTo(n,o);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}const n=t.path[0][0];e.lineTo(t.path[t.path.length-1][0],o.height),e.lineTo(n,o.height),e.closePath(),e.fill()}void 0!==n&&1>n&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function Xc(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Uc(e,t,n=.3){Xc(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function Kc(e,t,n=.6){if(!Xc(t))return;const o=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,r=t.cx??t.x??0,i=t.cy??t.y??0;e.beginPath(),e.arc(r,i,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function Zc(e,t,n,o=.35){Xc(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}var Qc=require("d3-shape");function Jc(e,t){const n=qo(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const o=(0,Qc.area)().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),o(t.topPath)}}function el(e,t){const n=qo(t.curve);if(e.beginPath(),n)(0,Qc.line)().x(e=>e[0]).y(e=>e[1]).curve(n).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1])}}var tl=(e,t,n,o)=>{const r=t.filter(e=>"area"===e.type);for(const t of r){if(2>t.topPath.length)continue;let n=!1;t.clipRect&&(e.save(),e.beginPath(),e.rect(t.clipRect.x,t.clipRect.y,t.clipRect.width,t.clipRect.height),e.clip(),n=!0);const r=t._introClipFraction;void 0!==r&&1>r&&(e.save(),e.beginPath(),e.rect(0,0,o.width*r,o.height),e.clip());const i=Yo(e,t.style.fill,"#4e79a7"),s=t._decayOpacities,a=!(!t.colorThresholds?.length||!t.rawValues||t.rawValues.length!==t.topPath.length),c=!!t.strokeColorBands?.length;if(s&&s.length===t.topPath.length&&!a&&!c){const n=t.style.fillOpacity??.7;e.fillStyle=i;for(let o=0;t.topPath.length-1>o;o++)e.globalAlpha=.5*(s[o]+s[o+1])*n,e.beginPath(),e.moveTo(t.topPath[o][0],t.topPath[o][1]),e.lineTo(t.topPath[o+1][0],t.topPath[o+1][1]),e.lineTo(t.bottomPath[o+1][0],t.bottomPath[o+1][1]),e.lineTo(t.bottomPath[o][0],t.bottomPath[o][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=To(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(s[n]+s[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const l=t.style.opacity??1;if(Jc(e,t),t.fillGradient&&t.fillGradient.stops.length>=2&&t.fillGradient){let n=1/0;for(const e of t.topPath)n>e[1]&&(n=e[1]);let o=-1/0;for(const e of t.bottomPath)e[1]>o&&(o=e[1]);const r=Go(e,t.fillGradient,"string"==typeof i?i:"#4e79a7",0,n,0,o);e.fillStyle=r||i,e.globalAlpha=l}else e.globalAlpha=(t.style.fillOpacity??.7)*l,e.fillStyle=i;if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(Jc(e,t),Zc(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=l;const n=To(e,t.style.stroke)||t.style.stroke,o=a||c||!t.strokeGradient||2>t.topPath.length?null:Vo(e,t.strokeGradient,n,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0);if(e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]),c){let o=1/0,r=-1/0;for(const[e]of t.topPath)o=Math.min(o,e),r=Math.max(r,e);const i=e.lineWidth;for(const s of t.strokeColorBands){e.save(),e.beginPath(),e.rect(o-i,s.y,r-o+2*i,s.height),e.clip();const a=s.color??n;e.strokeStyle=To(e,a)||a,el(e,t),e.stroke(),e.restore()}}else if(a){const o=Gs(t.topPath,t.rawValues,t.colorThresholds,n);for(const t of o){e.beginPath(),e.strokeStyle=To(e,t.color)||t.color,e.moveTo(t.path[0][0],t.path[0][1]);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1]);e.stroke()}}else e.strokeStyle=o||n,el(e,t),e.stroke()}void 0!==r&&1>r&&e.restore(),n&&e.restore(),e.globalAlpha=1}},nl=(e,t,n,o)=>{const r=t.filter(e=>"point"===e.type);if(0!==r.length){e.save();try{const t=e.globalAlpha;for(const n of r)e.beginPath(),e.arc(n.x,n.y,n.r,0,2*Math.PI),e.globalAlpha=t*(n.style.opacity??n.style.fillOpacity??1),e.fillStyle=Yo(e,n.style.fill,"#4e79a7"),e.fill(),n.style.stroke&&"none"!==n.style.stroke&&(e.strokeStyle=Yo(e,n.style.stroke,n.style.stroke),e.lineWidth=n.style.strokeWidth||1,e.stroke()),Kc(e,n)}finally{e.restore()}}},ol=new Map;function rl(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=ol.get(t);return n||(n=new Path2D(un(e.symbolType,e.size)),ol.size>256&&ol.clear(),ol.set(t,n)),n}catch{return null}}var il=(e,t)=>{const n=e.globalAlpha;for(const o of t){if("symbol"!==o.type)continue;const t=o;if(0>=t.size)continue;const r=rl(t);if(!r)continue;e.save(),e.translate(t.x,t.y),t.rotation&&e.rotate(t.rotation);const i=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=n*i*(t.style.fillOpacity??1),e.fillStyle=Yo(e,t.style.fill,"#4e79a7"),e.fill(r)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*i,e.strokeStyle=Yo(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth??1,e.stroke(r)),e.restore()}e.globalAlpha=n};function sl(e,t,n,o,r){if(0>=t.size)return;const i=t.glyph;if(!i||!i.parts?.length)return;const s=wo(i,t.size);if(0>=s.scale)return;const a=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=a)return;const c=t=>{const n=Yo(e,t,t);return"string"==typeof n?n:t},l=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,o),t.rotation&&e.rotate(t.rotation),e.translate(s.offsetX,s.offsetY),e.scale(s.scale,s.scale),e.globalAlpha=r*a*(t.style.fillOpacity??1);const u=Mo(i,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&Po(e,i,l,t.accent,t.ghostColor,c),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),Po(e,i,l,t.accent,void 0,c),e.restore()}function al(e,t){const{x:n,y:o,w:r,h:i}=t,{tl:s,tr:a,br:c,bl:l}=Vs(t);e.beginPath(),e.moveTo(n+s,o),e.lineTo(n+r-a,o),a>0&&e.arcTo(n+r,o,n+r,o+a,a),e.lineTo(n+r,o+i-c),c>0&&e.arcTo(n+r,o+i,n+r-c,o+i,c),e.lineTo(n+l,o+i),l>0&&e.arcTo(n,o+i,n,o+i-l,l),e.lineTo(n,o+s),s>0&&e.arcTo(n,o,n+s,o,s),e.closePath()}function cl(e){switch(e.roundedEdge){case"bottom":return{x0:e.x,y0:e.y+e.h,x1:e.x,y1:e.y};case"right":return{x0:e.x+e.w,y0:e.y,x1:e.x,y1:e.y};case"left":return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y};default:return{x0:e.x,y0:e.y,x1:e.x,y1:e.y+e.h}}}var ll=(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)ul(e,t);else if(t.cornerRadii&&Hs(t.cornerRadii)){const n=Yo(e,t.style.fill,To(e,"var(--semiotic-primary, #007bff)")),o=cl(t),r=t.fillGradient&&"string"==typeof n?Go(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n,al(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=To(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else if(t.roundedTop&&t.roundedTop>0){const n=Yo(e,t.style.fill,To(e,"var(--semiotic-primary, #007bff)")),o=cl(t),r=t.fillGradient&&"string"==typeof n?Go(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n;const i=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:s,y:a,w:c,h:l}=t;switch(t.roundedEdge){case"right":e.moveTo(s,a),e.lineTo(s+c-i,a),e.arcTo(s+c,a,s+c,a+i,i),e.lineTo(s+c,a+l-i),e.arcTo(s+c,a+l,s+c-i,a+l,i),e.lineTo(s,a+l);break;case"left":e.moveTo(s+c,a),e.lineTo(s+i,a),e.arcTo(s,a,s,a+i,i),e.lineTo(s,a+l-i),e.arcTo(s,a+l,s+i,a+l,i),e.lineTo(s+c,a+l);break;case"bottom":e.moveTo(s,a),e.lineTo(s+c,a),e.lineTo(s+c,a+l-i),e.arcTo(s+c,a+l,s+c-i,a+l,i),e.lineTo(s+i,a+l),e.arcTo(s,a+l,s,a+l-i,i);break;default:e.moveTo(s,a+l),e.lineTo(s,a+i),e.arcTo(s,a,s+i,a,i),e.lineTo(s+c-i,a),e.arcTo(s+c,a,s+c,a+i,i),e.lineTo(s+c,a+l)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=To(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const n=Yo(e,t.style.fill,To(e,"var(--semiotic-primary, #007bff)")),o=cl(t),r=t.fillGradient&&"string"==typeof n?Go(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=To(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}Uc(e,t),e.globalAlpha=1}};function ul(e,t){const n=t.style.icon,o=t.style.iconPadding||2,r=Math.min(t.w,t.h)-o;if(0>=r)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=r+o,s=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=i)e.drawImage(n,s,o,r,r)}else{const i=r+o,s=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,s,r,r)}e.restore()}function dl(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>128?"#000":"#fff"}function hl(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var fl=(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of r){const n=t.style;null!=n?.opacity&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h);const o=Math.max(0,n?.strokeWidth??1);if(o>0&&(e.strokeStyle=To(e,n?.stroke??"var(--semiotic-surface, #fff)"),e.lineWidth=o,e.strokeRect(t.x,t.y,t.w,t.h)),Uc(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):hl(t.value),o=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),r=t.x+t.w/2,i=t.y+t.h/2;e.fillStyle=dl(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,i)}}}finally{e.restore()}},pl=(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const r=(t._decayOpacity??1)*(t.style?.opacity??1);1!==r&&(e.globalAlpha=r);const i=To(e,t.wickColor)||t.wickColor,s=60>o.height,a=s?Math.max(t.wickWidth,2):t.wickWidth,c=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=i,e.lineWidth=a,e.stroke()};if(s||c(),t.isRange){const n=t.dotRadius??Math.max(2,Math.min(t.bodyWidth/2,.12*o.height));e.fillStyle=i,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),o=Math.abs(t.openY-t.closeY),r=t.isUp?t.upColor:t.downColor,i=To(e,r)||r;e.fillStyle=i,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1)),e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1))}s&&c(),e.restore()}},yl={line:[tl,Vc,nl],area:[tl,nl],stackedarea:[tl,nl],scatter:[nl,il],bubble:[nl,il],heatmap:[fl],bar:[ll],swarm:[nl],waterfall:[(e,t,n,o)=>{ll(e,t);const r=t.filter(e=>"rect"===e.type);if(2>r.length)return;const i=r[0].datum,s=i?._connectorStroke;if(s){e.save(),e.strokeStyle=To(e,s)||s,e.lineWidth=i?._connectorWidth??1,e.setLineDash([]);for(let t=0;r.length-1>t;t++){const o=r[t],i=r[t+1],s=o.datum,a=i.datum;if(null==s?.cumEnd||null==a?.baseline)continue;const c=n.y(s.cumEnd),l=o.x+o.w,u=i.x;e.beginPath(),e.moveTo(l,c),e.lineTo(u,c),e.stroke()}e.restore()}}],candlestick:[pl],mixed:[tl,Vc,nl],custom:[tl,ll,fl,Vc,nl,il,(e,t)=>{const n=e.globalAlpha;for(const o of t)"glyph"===o.type&&sl(e,o,o.x,o.y,n);e.globalAlpha=n},pl]},gl=new Set;function ml(e,t){const n="function"==typeof e?e(t.datum??null,t):e;return(o=n)&&"object"==typeof o&&"string"==typeof o.id&&"function"==typeof o.cacheKey&&"function"==typeof o.drawCanvas&&"function"==typeof o.renderStaticSVG?n:void 0;var o}function xl(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const n=`${e}:${t}`;gl.has(n)||(gl.add(n),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function bl(e){const{node:t,index:n,renderMode:o,fallback:r}=e,i=ml(o,t);if(!i)return r();const s=i.renderStaticSVG({node:t,style:t.style??{},key:`${i.id}-${n}`});return null!=s?s:(xl(i.id,t.type??"unknown"),r())}function vl(e){const t=[];return e.nodes.forEach((n,o)=>{const r=bl({node:n,index:o,renderMode:e.renderMode,fallback:()=>e.fallback(n,o)});null!=r&&!1!==r&&t.push({node:n,element:r})}),t}require("react/jsx-runtime");var wl=require("react/jsx-runtime");function kl(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function Sl({hover:e}){const t=e.data??{},n=t.y??t.value,o=t.x??t.time;if(void 0===n&&void 0===o){const e=pc(t);if(null!=e.title||e.entries.length>0)return(0,wl.jsxs)("div",{className:"semiotic-tooltip",style:gc,children:[null!=e.title&&(0,wl.jsx)("div",{style:{fontWeight:600,marginBottom:e.entries.length?2:0},children:e.title+""}),e.entries.map(e=>(0,wl.jsxs)("div",{style:{opacity:.7,fontSize:11},children:[e.key,":"," ",(0,wl.jsx)("span",{style:{fontWeight:600},children:kl(e.value)})]},e.key))]})}return(0,wl.jsxs)("div",{className:"semiotic-tooltip",style:gc,children:[(0,wl.jsx)("div",{style:{fontWeight:600,marginBottom:2},children:kl(n)}),(0,wl.jsx)("div",{style:{opacity:.7,fontSize:11},children:kl(o)})]})}function Al(e){const{onObservation:t,datum:n,x:o=0,y:r=0,chartType:i,chartId:s,context:a,timestamp:c=Date.now()}=e;t&&(n?(t({type:"hover",datum:n,x:o,y:r,timestamp:c,chartType:i,chartId:s}),"focus"===a?.type&&t({type:"focus",datum:n,inputType:"touch"===a.inputType?"pointer":a.inputType,timestamp:c,chartType:i,chartId:s})):t({type:"hover-end",timestamp:c,chartType:i,chartId:s}))}function Ml(e){const{onObservation:t,datum:n,x:o=0,y:r=0,chartType:i,chartId:s,context:a,timestamp:c=Date.now()}=e;t&&(n?(t({type:"click",datum:n,x:o,y:r,timestamp:c,chartType:i,chartId:s}),"activate"===a?.type&&t({type:"activate",datum:n,inputType:a.inputType,timestamp:c,chartType:i,chartId:s})):t({type:"click-end",timestamp:c,chartType:i,chartId:s}))}Sl.ownsChrome=!0;var _l=require("react"),Pl=require("react");function jl(e,t,n){const o=e.byGroup.get(t);let r=0,i=Math.abs(o[0].x-n.x);for(let e=1;o.length>e;e++){const t=Math.abs(o[e].x-n.x);i>t&&(i=t,r=e)}return o[r]._flatIndex}function Rl(e){const t=[];for(const n of e)switch(n.type){case"point":t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=n.size)break;t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"glyph":{if(0>=n.size||null==n.datum)break;const e=_o(n.glyph,n.size);t.push({x:n.x+e.centerDx,y:n.y+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:"_default"});break}case"line":{const e=n,o=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.path.length>n&&o.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:o[n],shape:"circle",group:r});break}case"area":{const e=n,o=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.topPath.length>n&&o.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:o[n],shape:"circle",group:r});break}case"rect":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.group??"_default"});break;case"heatcell":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}var Cl=require("react/jsx-runtime"),Ll={top:20,right:20,bottom:30,left:40},Il=ja;function Tl(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var $l=(0,mt.memo)((0,mt.forwardRef)(function(e,t){const{chartType:n,runtimeMode:o,data:r,chunkThreshold:i,chunkSize:s,xAccessor:a,yAccessor:c,accessorRevision:l,colorAccessor:u,sizeAccessor:d,symbolAccessor:h,symbolMap:f,groupAccessor:p,lineDataAccessor:y,curve:g,normalize:m,baseline:x,stackOrder:b,binSize:v,valueAccessor:w,arrowOfTime:k="right",windowMode:S="sliding",windowSize:A=200,timeAccessor:M,xExtent:_,yExtent:P,extentPadding:j=.1,scalePadding:R,sizeRange:C,size:L=[500,300],responsiveWidth:I,responsiveHeight:T,margin:$,className:z,background:O,renderMode:D,lineStyle:B,pointStyle:F,areaStyle:N,barStyle:W,waterfallStyle:q,swarmStyle:Y,barColors:G,colorScheme:H,boundsAccessor:V,boundsStyle:X,y0Accessor:U,band:K,gradientFill:Z,lineGradient:Q,semanticLineStops:J,areaGroups:ee,openAccessor:te,highAccessor:ne,lowAccessor:oe,closeAccessor:re,candlestickStyle:ie,showAxes:se=!0,axes:ae,xLabel:ce,yLabel:le,yLabelRight:ue,xFormat:de,yFormat:he,axisExtent:fe,tickFormatTime:pe,tickFormatValue:ye,hoverAnnotation:ge,tooltipContent:me,customHoverBehavior:xe,customClickBehavior:be,onObservation:ve,annotationObservationCallback:we,chartId:ke,enableHover:Se,hoverRadius:Ae=30,tooltipMode:Me,annotations:_e,onAnnotationActivate:Pe,autoPlaceAnnotations:je,svgAnnotationRules:Re,showGrid:Ce,legend:Te,legendHoverBehavior:$e,legendClickBehavior:ze,legendHighlightedCategory:Ee,legendIsolatedCategories:Oe,legendPosition:De,legendLayout:Be,legendCategoryAccessor:Ne,onCategoriesChange:We,backgroundGraphics:qe,foregroundGraphics:Ye,canvasPreRenderers:Ge,svgPreRenderers:He,title:Ve,categoryAccessor:Xe,brush:Ue,onBrush:Ke,decay:Ze,pulse:Qe,transition:Je,animate:et,staleness:tt,frameScheduler:nt,clock:ot,random:rt,seed:it,paused:st=!1,suspendWhenHidden:at=!0,heatmapAggregation:ct,heatmapXBins:lt,heatmapYBins:ut,showValues:dt,heatmapValueFormat:ht,marginalGraphics:ft,pointIdAccessor:yt,xScaleType:xt,yScaleType:bt,accessibleTable:vt=!0,description:wt,summary:At,linkedCrosshairName:Mt,linkedCrosshairSourceId:_t,customLayout:Pt,onLayoutError:jt,layoutConfig:Rt,layoutSelection:Ct}=e,{customHoverBehavior:Lt,customClickBehavior:It,hasClickBehavior:Tt}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:o,chartType:r}){return{customHoverBehavior:(0,_l.useCallback)((t,i)=>{e?.(t,i),Al({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:r,chartId:o,context:i})},[o,r,e,n]),customClickBehavior:(0,_l.useCallback)((e,i)=>{t?.(e,i),Ml({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:r,chartId:o,context:i})},[o,r,t,n]),hasClickBehavior:!(!t&&!n)}}({customHoverBehavior:xe,customClickBehavior:be,onObservation:ve,chartId:ke,chartType:"StreamXYFrame"}),$t=(0,mt.useId)().replace(/:/g,""),zt=(0,mt.useRef)(!1),Et=(0,mt.useRef)({w:-1,h:-1}),Ot=(0,mt.useRef)(!1),Dt=Tc({sizeProp:L,responsiveWidth:I,responsiveHeight:T,userMargin:$,marginDefault:Ll,title:Ve,legend:Te,legendPosition:De,animate:et,transitionProp:Je,frameScheduler:nt,clock:ot,random:rt,seed:it,paused:st,suspendWhenHidden:at,themeDirtyRef:zt}),Bt=function(){const[e,t]=(0,xa.useState)(!1);return ba(()=>{t(!0)},[]),e}(),Ft=function(){const e=(0,xa.useSyncExternalStore)(va,wa,ka);return(0,xa.useRef)(e).current}(),{reducedMotionRef:Nt,responsiveRef:Wt,size:qt,currentTheme:Yt,transition:Gt,introEnabled:Ht,tableId:Vt,rafRef:Xt,renderFnRef:Ut,scheduleRender:Kt,frameRuntime:Zt}=Dt;let Qt=Dt.margin;if(ft){const e=60,t={...Dt.margin};ft.top&&e>t.top&&(t.top=e),ft.bottom&&e>t.bottom&&(t.bottom=e),ft.left&&e>t.left&&(t.left=e),ft.right&&e>t.right&&(t.right=e),Qt=t}const Jt=qt[0]-Qt.left-Qt.right,en=qt[1]-Qt.top-Qt.bottom,tn=(0,mt.useMemo)(()=>E(r),[r]),on=ge??Se,[rn,sn]=(0,mt.useState)(0),an=(0,mt.useRef)(0),[cn,ln]=(0,mt.useState)(null),un=Oc(Ye,qt,Qt,cn),dn=Oc(qe,qt,Qt,cn),hn=(0,mt.useRef)(null),fn=(0,mt.useRef)(null),pn=(0,mt.useRef)(void 0),[yn,gn]=(0,mt.useState)(null),mn=(0,mt.useRef)(Il.primary),xn=(0,mt.useRef)(function(){let e=-1,t=ja;return{resolve(n){if(!n)return ja;const o=Ro;return o===e||(t=function(e){if(!e)return ja;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),i=t.getPropertyValue("--semiotic-primary").trim(),s=o||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),c=n||t.getPropertyValue("--surface-3").trim(),l=r||t.getPropertyValue("--surface-0").trim();return s||a||n||i?{axisStroke:c||ja.axisStroke,tickText:s||ja.tickText,crosshair:s?Ra(s,"66"):ja.crosshair,hoverFill:l?Ra(l,"4D"):ja.hoverFill,hoverStroke:s?Ra(s,"99"):ja.hoverStroke,pointRing:l||ja.pointRing,primary:i||ja.primary,background:l||ja.background}:ja}(n),e=o),t},invalidate(){e=-1}}}()),bn=(0,mt.useRef)(!1),vn=(0,oo.useRef)(new lo("StreamXYFrame")),[wn,kn]=(0,mt.useState)(!1),[Sn,An]=(0,mt.useState)([]),[Mn,_n]=(0,mt.useState)([]),Pn="streaming"===o||["bar","swarm","waterfall"].includes(n),jn=function(e){const t=(0,Sa.useRef)(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return Ma(e,t);if(!_a(e)||!_a(t))return!1;const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;const n=e[o],r=t[o];if(!Object.is(n,r))if(Array.isArray(n)&&Array.isArray(r)){if(!Ma(n,r))return!1}else{if(!_a(n)||!_a(r))return!1;if(!Aa(n,r))return!1}}return!0}(t.current,e)||(t.current=e),t.current}((0,mt.useMemo)(()=>({chartType:n,runtimeMode:Pn?"streaming":"bounded",windowSize:A,windowMode:S,arrowOfTime:Pn?k:"right",extentPadding:j,scalePadding:R,axisExtent:fe,xAccessor:a,yAccessor:c,accessorRevision:l,timeAccessor:Pn?M:void 0,valueAccessor:w,colorAccessor:u,sizeAccessor:d,symbolAccessor:h,symbolMap:f,groupAccessor:p||(y?"_lineGroup":void 0),categoryAccessor:Xe,lineDataAccessor:y,xScaleType:xt,yScaleType:bt,xExtent:_,yExtent:P,sizeRange:C,binSize:v,normalize:m,baseline:x,stackOrder:b,boundsAccessor:V,boundsStyle:X,y0Accessor:U,band:K,gradientFill:Le(Z),areaGroups:ee?new Set(ee):void 0,lineGradient:Ie(Q),semanticLineStops:J,openAccessor:te,highAccessor:ne,lowAccessor:oe,closeAccessor:re,candlestickStyle:ie,lineStyle:B,pointStyle:F,areaStyle:N,swarmStyle:Y,waterfallStyle:q,colorScheme:H,barColors:G,barStyle:W,annotations:_e,decay:Ze,pulse:Qe,transition:Gt,introAnimation:Ht,staleness:tt,clock:Zt.now,heatmapAggregation:ct,heatmapXBins:lt,heatmapYBins:ut,showValues:dt,heatmapValueFormat:ht,pointIdAccessor:yt,curve:g,themeCategorical:Yt?.colors?.categorical,themeSemantic:Fe(Yt),themeSequential:Yt?.colors?.sequential,themeDiverging:Yt?.colors?.diverging,customLayout:Pt,onLayoutError:jt,layoutConfig:Rt,layoutMargin:Qt}),[n,Pn,A,S,k,j,R,fe,a,c,l,M,w,u,d,h,f,p,y,Xe,xt,bt,_,P,C,v,m,x,b,V,X,U,K,Z,ee,Q,J,te,ne,oe,re,ie,B,F,N,Y,q,H,G,W,_e,Ze,Qe,Gt,Ht,tt,Zt.now,ct,lt,ut,dt,ht,yt,g,Yt,Pt,jt,Rt,Qt])),Rn=(0,mt.useRef)(null);Rn.current||(Rn.current=new no(jn));const Cn=function(e,t,n,o){const r=(0,Bc.useRef)({accessor:t,onChange:n,readData:o}),i=(0,Bc.useRef)([]);return r.current={accessor:t,onChange:n,readData:o},(0,Bc.useCallback)(()=>{const{accessor:t,onChange:n,readData:o}=r.current;if(!n||!t)return;const s=function(e,t){if(!t)return[];const n=new Set,o=[];for(const r of e){if(!r||"object"!=typeof r)continue;const e="function"==typeof t?t(r):r[t];if(null==e)continue;const i=e+"";n.has(i)||(n.add(i),o.push(i))}return o}(e.current?o(e.current):[],t);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(s,i.current)||(i.current=s,n(s))},[e])}(Rn,Ne,We,e=>e.getData());!function(e,t,n,o){(0,po.useEffect)(()=>{e.current?.updateConfig(t),n.current=!0,o()},[t,o,e,n])}(Rn,jn,zt,Kt),function(e,t,n,o){const r=(0,po.useRef)(null);(0,po.useEffect)(()=>{const i=e.current;if(!i)return;const s=t??null;r.current!==s&&(r.current=s,i.setLayoutSelection(s),i.hasCustomRestyle?i.restyleScene(s):n.current=!0,o())},[t,o,e,n])}(Rn,Ct,zt,Kt);const Ln=(0,mt.useRef)(null);Ln.current||(Ln.current=new St(e=>{const t=Rn.current;t&&t.ingest(e)&&(zt.current=!0,Kt())},{chunkThreshold:i,chunkSize:s})),(0,mt.useEffect)(()=>{Ln.current?.updateChunkOptions({chunkThreshold:i,chunkSize:s})},[i,s]);const In=(0,mt.useCallback)(e=>{Ln.current?.push(e)},[]),Tn=(0,mt.useCallback)(e=>{Ln.current?.pushMany(e)},[]),$n=(0,mt.useCallback)(()=>{Ln.current?.clear(),Rn.current?.clear(),zt.current=!0,Kt()},[Kt]);(0,mt.useImperativeHandle)(t,()=>({push:In,pushMany:Tn,remove:e=>{Ln.current?.flush();const t=Rn.current?.remove(e)??[];return t.length>0&&(hn.current&&t.some(e=>e===hn.current?.data)&&(hn.current=null,gn(null)),zt.current=!0,Kt()),t},update:(e,t)=>{Ln.current?.flush();const n=Rn.current?.update(e,t)??[];return n.length>0&&(zt.current=!0,Kt()),n},clear:$n,getData:()=>(Ln.current?.flush(),Rn.current?.getData()??[]),getScales:()=>Rn.current?.scales??null,getExtents:()=>Rn.current?.getExtents()??null,getCustomLayout:()=>Rn.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Rn.current?.lastCustomLayoutFailure??null}),[In,Tn,$n,Kt]),(0,mt.useEffect)(()=>{if(r){if(y&&tn.length>0&&"object"==typeof tn[0]&&null!==tn[0]){const e="string"==typeof y?y:"coordinates";if(Array.isArray(tn[0][e])){const t=[];for(const n of tn){const o=n[e];if(Array.isArray(o)){const e=n.label||n.id||n.key;if(null!=e)for(const n of o)t.push({...n,_lineGroup:e});else for(const e of o)t.push(e)}}return void Ln.current?.setBoundedData(t)}}Ln.current?.setBoundedData(tn)}},[r,tn,y]);const{canvasRef:zn,interactionCanvasRef:En}=function(e,t){return function(e){const{cancelRender:t,dirtyRef:n,frameRuntime:o,manageFrameRuntime:r,scheduleRender:i}=e,s=(0,$c.useRef)(null),a=(0,$c.useRef)(null),c=(0,$c.useRef)(!1);return function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:o,dirtyRef:r,renderFnRef:i,cancelRender:s,cleanup:a}=e;ba(()=>{const e=o.current;t&&n&&e?.cancelIntroAnimation?.(),!n&&e?.sceneNodes&&e.sceneNodes.length>0&&e?.markStylePaintPending?e.markStylePaintPending():r.current=!0,s?.(),i.current()},[t,n]);const c=(0,xa.useRef)(a);c.current=a,(0,xa.useEffect)(()=>()=>c.current?.(),[])}({hydrated:e.hydrated,wasHydratingFromSSR:e.wasHydratingFromSSR,storeRef:e.storeRef,dirtyRef:e.dirtyRef,renderFnRef:e.renderFnRef,cancelRender:e.cancelRender,cleanup:e.cleanup}),(0,$c.useEffect)(()=>{if(!1!==r)return o.subscribe(()=>{o.isActive?(n.current=!0,i()):t()})},[t,n,o,r,i]),(0,$c.useEffect)(()=>{!c.current&&(c.current=!0,e.skipInitialCanvasPaintInvalidation)||(e.dirtyRef.current=!0,e.scheduleRender())},e.canvasPaintDependencies),{canvasRef:s,interactionCanvasRef:a}}({...t,renderFnRef:e.renderFnRef,scheduleRender:e.scheduleRender,cancelRender:e.cancelRender,frameRuntime:e.frameRuntime})}(Dt,{storeRef:Rn,dirtyRef:zt,hydrated:Bt,wasHydratingFromSSR:Ft,cleanup:()=>Ln.current?.clear(),canvasPaintDependencies:[n,Jt,en,se,O,qe,B,D,Ge,Kt]}),{hoverHandlerRef:On,hoverLeaveRef:Dn,onPointerMove:Bn,onPointerLeave:Fn}=Dt;On.current=e=>{if(!on)return;const t=zn.current;if(!t)return;const o=t.getBoundingClientRect(),r=e.clientX-o.left-Qt.left,i=e.clientY-o.top-Qt.top;if(0>r||r>Jt||0>i||i>en)return void(hn.current&&(hn.current=null,fn.current=null,gn(null),Lt&&(Lt(null),zt.current=!0),Kt()));const s=Rn.current;if(!s||0===s.scene.length)return;const c=sc(Ae,e.pointerType),l=Zo(s.scene,r,i,c,s.quadtree,s.maxPointRadius),u="multi"===Me,d=()=>{hn.current&&(hn.current=null,fn.current=null,gn(null),Lt&&Lt(null),Kt())};if(!l&&!u)return void d();const h=u||!l?r:l.x,f=u||!l?i:l.y,p=l?.datum?nn(l.datum,s.resolvedRibbons):{},y=s.scales?.x?.invert,g="function"==typeof y?y(h):void 0;let m=cc(p,h,f,null!=g?{xValue:g,xPx:h}:void 0);if(u&&s.scene.length>0&&s.scales){const e=function(e,t,n=30){const o=[];for(const r of e)if("line"===r.type){const e=r;if(2>e.path.length)continue;const i=Qo(Ko(e.path,e.curve),t,n);if(null===i)continue;const s=cr(e.path,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.path[s][0],y:i,group:e.group,color:e.style.stroke})}else if("area"===r.type){const e=r;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const i=Ko(e.topPath,e.curve),s=Ko(e.bottomPath,e.curve),a=Qo(i,t,n);if(null===a)continue;const c=Qo(s,t,n),l=cr(e.topPath,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:e.topPath[l][0],y:a,y0:c??void 0,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return o}(s.scene,h,Math.max(c,Jt));if(e.length>0){const t=s.scales.y.invert,o=mn.current,r=y?y(h):h;if(l)m.xValue=r,m.xPx=h;else{const e={xValue:r};"string"==typeof a&&(e[a]=r),m=cc(e,h,f,{xValue:r,xPx:h})}m.allSeries=e.map(e=>{const r=t?t(e.y):e.y,i=null!=e.y0?t?t(e.y0):e.y0:void 0;return{group:e.group||"",value:"stackedarea"===n&&null!=i?r-i:r,valuePx:e.y,color:e.color||o,datum:nn(e.datum,s.resolvedRibbons)}})}}l||m.allSeries?.length?(hn.current=m,fn.current=l?.node??null,gn(m),Lt&&(Lt(m),zt.current=!0),Kt()):d()},Dn.current=()=>{hn.current&&(hn.current=null,fn.current=null,gn(null),Lt&&(Lt(null),zt.current=!0),Kt())};const Nn=(0,mt.useRef)(()=>{});Nn.current=e=>{if((t=e.target)instanceof Element&&null!=t.closest("[data-semiotic-annotation-widget]"))return;var t;if(!It)return;const n=zn.current;if(!n)return;const o=n.getBoundingClientRect(),r=e.clientX-o.left-Qt.left,i=e.clientY-o.top-Qt.top;if(0>r||r>Jt||0>i||i>en)return void It(null);const s=Rn.current;if(!s||0===s.scene.length)return void It(null);const a=sc(Ae,pn.current),c=Zo(s.scene,r,i,a,s.quadtree,s.maxPointRadius);if(!c)return void It(null);const l=c.datum||{},u=s.scales?.x?.invert,d="function"==typeof u?u(c.x):void 0;var h;It(cc(l,c.x,c.y,null!=d?{xValue:d,xPx:c.x}:void 0),{type:"activate",inputType:(h=pn.current,"touch"===h?"touch":"pointer")})};const Wn=(0,mt.useCallback)(e=>Nn.current(e),[]),{kbFocusIndexRef:qn,focusedNavPointRef:Yn,onKeyDown:Gn}=(Hn={storeRef:Rn,hoverRef:hn,hoveredNodeRef:fn,setHoverPoint:gn,customHoverBehavior:Lt,customClickBehavior:It,scheduleRender:Kt},function({storeRef:e,hoverRef:t,hoveredNodeRef:n,setHoverPoint:o,customHoverBehavior:r,customClickBehavior:i,scheduleRender:s,extractPoints:a,toHover:c}){const l=(0,Pl.useRef)(-1),u=(0,Pl.useRef)(null),d=(0,Pl.useRef)(null),h=(0,Pl.useCallback)(h=>{if(function(e){const t=e.target;return t instanceof Element&&t!==e.currentTarget&&null!=t.closest("button, a[href], input, select, textarea, summary, [contenteditable='true'], [role='button'], [role='link'], [role='checkbox'], [role='radio'], [role='switch']")}(h))return;const f=e.current;if(!f)return;const p=()=>{l.current=-1,u.current=null,t.current=null,n&&(n.current=null),o(null),r(null),s()};if(0===f.scene.length)return void(0>l.current||p());let y;if(d.current?.version===f.version)y=d.current.graph;else{const e=a(f.scene);if(0===e.length)return void(0>l.current||p());y=function(e){const t=new Map;for(const n of e){const e=n.group??"_default";let o=t.get(e);o||(o=[],t.set(e,o)),o.push(n)}for(const e of t.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const n=Array.from(t.keys()).sort((e,n)=>{const o=t.get(e),r=t.get(n);return(o.length>0?o[0].y:0)-(r.length>0?r[0].y:0)}),o=Array.from(t.values()).flat();o.sort((e,t)=>e.x-t.x||e.y-t.y);const r=new Map;for(let e=0;o.length>e;e++){o[e]._flatIndex=e;const t=o[e].datum?.id;null!=t&&r.set(t+"",e)}return{flat:o,groups:n,byGroup:t,idToIdx:r}}(e),d.current={version:f.version,graph:y}}let g=l.current;if(y.flat.length>g||(p(),g=-1),("Enter"===h.key||" "===h.key)&&g>=0)return h.preventDefault(),void i(c(y.flat[g],f),{type:"activate",inputType:"keyboard"});if(0>g){if("Escape"===h.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(h.key))return;h.preventDefault(),l.current=0;const e=y.flat[0];u.current=e;const n=c(e,f);return t.current=n,o(n),r(n,{type:"focus",inputType:"keyboard"}),void s()}const m=function(e,t,n){const{group:o,indexInGroup:r}=t,i=n.byGroup.get(o);switch(e){case"ArrowRight":return i.length-1>r?i[r+1]._flatIndex:t.flatIndex;case"ArrowLeft":return r>0?i[r-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(o);return n.groups.length-1>e?jl(n,n.groups[e+1],i[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(o);return e>0?jl(n,n.groups[e-1],i[r]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}(h.key,function(e,t){if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const n=Math.max(0,Math.min(t,e.flat.length-1)),o=e.flat[n];return{flatIndex:n,group:o.group??"_default",indexInGroup:o._groupIndex??0}}(y,g),y);if(null===m)return;if(h.preventDefault(),0>m)return void p();l.current=m;const x=y.flat[m];u.current=x;const b=c(x,f);t.current=b,o(b),r(b,{type:"focus",inputType:"keyboard"}),s()},[i,r,a,t,n,s,o,e,c]);return{kbFocusIndexRef:l,focusedNavPointRef:u,onKeyDown:h}}({...Hn,extractPoints:Rl,toHover:(e,t)=>function(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}({...e,datum:nn(e.datum,t.resolvedRibbons)})}));var Hn;const Vn=(0,mt.useCallback)(e=>{pn.current=e.pointerType,qn.current=-1,Yn.current=null,Bn(e)},[Yn,qn,Bn]),Xn=(0,mt.useCallback)(e=>{pn.current="mouse",qn.current=-1,Yn.current=null,Bn({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[Yn,qn,Bn]),Un=(0,mt.useCallback)(e=>{pn.current=e.pointerType},[]);Ut.current=()=>{if(Xt.current=null,!Zt.isActive)return;const e=zn.current,t=En.current;if(!e||!t)return;const o=Rn.current;if(!o)return;const r=Zt.now(),i=o.advanceTransition(Nt.current?r+1e6:r),s=!Nt.current&&i,l=Et.current.w!==Jt||Et.current.h!==en,u=zt.current||i||l,d=o.consumeStylePaintPending();let h=!1;const f=o.getLastUpdateResult(),p=vn.current.beforeCompute(f,s);!u||s&&!l||(o.computeScene({width:Jt,height:en}),Et.current={w:Jt,h:en},h=!0,Cn()),vn.current.afterCompute(p,h,l);const y=function(e,t,n,o){const r=o.current,i=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,s=!i&&e.hasActivePulsesAt(t),a=!(n||i||!s&&!r)&&e.refreshPulse(t);return o.current=s,{changed:a,pending:s}}(o,r,h,Ot),g=function(){if("undefined"==typeof window)return 1;const e=window.devicePixelRatio||1,t=function(){if("undefined"==typeof window)return!1;const e="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,t=768>Math.min(window.innerWidth||1/0,window.innerHeight||1/0);return e||t}()?2:3;return Math.max(1,Math.min(e,t))}(),m=xn.current.resolve(e);mn.current=m.primary;const x=hr(tt,o.lastIngestTime>0?r-o.lastIngestTime:0),b=tt&&x.isStale;if(u||d||y.changed){const t=Dc(e,qt,Qt,g);if(t){if(t.clearRect(-Qt.left,-Qt.top,qt[0],qt[1]),tt&&1>x.alpha&&(t.globalAlpha=x.alpha),function(e,t){const{background:n,hasBackgroundGraphics:o=!1,themeBackground:r="",x:i=0,y:s=0,width:a,height:c}=t,l=Pa({background:n,hasBackgroundGraphics:o,themeBackground:r});if(!l)return!1;const u=To(e,l);u&&(e.fillStyle=u,e.fillRect(i,s,a,c))}(t,{background:O,hasBackgroundGraphics:!!qe,themeBackground:m.background,x:-Qt.left,y:-Qt.top,width:qt[0],height:qt[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Jt,en),t.clip()),Ge&&o.scales)for(const e of Ge)t.save(),e(t,o.scene,o.scales,{width:Jt,height:en}),t.restore();const e=Pt?yl.custom:yl[n];!function(e){const{context:t,nodes:n,renderMode:o,pixelRatio:r,paintBuiltIn:i}=e;if(!o||"sketchy"===o)return void i(n);let s=[];const a=()=>{s.length&&(i(s),s=[])};for(const e of n){const n=ml(o,e);if(!n){s.push(e);continue}let c;a(),t.save();try{c=n.drawCanvas({context:t,node:e,style:e.style??{},pixelRatio:r})}finally{t.restore()}c||(xl(n.id,e.type??"unknown"),i([e]))}a()}({context:t,nodes:o.scene,renderMode:D,pixelRatio:g,paintBuiltIn:n=>{if(e&&o.scales)for(const r of e)r(t,n,o.scales,{width:Jt,height:en})}}),t.restore(),tt&&1>x.alpha&&(t.globalAlpha=1)}}const v=!!(on&&hn.current&&o.scales),w=!!(fn.current&&Array.isArray(ge)&&ge.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),k=v||w;if(k||bn.current){const e=Dc(t,qt,Qt,g);if(e&&(e.clearRect(-Qt.left,-Qt.top,qt[0],qt[1]),v&&hn.current&&function(e,t,n,o,r,i,s){if(!1===r.crosshair)return;const a=t.allSeries,c=a&&a.length>0,l=t.xPx??t.x;e.save();const u="object"==typeof r.crosshair?r.crosshair:{};if(e.strokeStyle=u.stroke||s.crosshair,e.lineWidth=u.strokeWidth||1,e.setLineDash(u.strokeDasharray?u.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(c?l:t.x,0),e.lineTo(c?l:t.x,o),e.stroke(),c||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),c){e.lineWidth=2,e.strokeStyle=s.pointRing;for(const t of a)null!=t.valuePx&&(e.beginPath(),e.arc(l,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||s.primary,e.fill(),e.stroke())}else{const n=r.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(i)||s.primary;e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=n,e.fill(),e.strokeStyle=s.pointRing,e.lineWidth=2,e.stroke()}}(e,hn.current,Jt,en,"object"==typeof on?on:{},fn.current,m),w&&fn.current&&Array.isArray(ge))){const t=ge.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o,r){if(!n)return;const i="group"in n?n.group:void 0;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?n.datum?o.style(n.datum):{}:o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||r.primary,e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=t.opacity??1,e.stroke(),e.restore()}}(e,o.scene,fn.current,t,m)}bn.current=k}u&&e&&e.setAttribute("aria-label",Fa(o.scene,n+" chart"));const S=zt.current;if(zt.current=S&&s&&!h,S&&o.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!cn||e(cn.x.domain()[0])!==e(o.scales.x.domain()[0])||e(cn.x.domain()[1])!==e(o.scales.x.domain()[1])||e(cn.y.domain()[0])!==e(o.scales.y.domain()[0])||e(cn.y.domain()[1])!==e(o.scales.y.domain()[1])||cn.x.range()[0]!==o.scales.x.range()[0]||cn.x.range()[1]!==o.scales.x.range()[1]||cn.y.range()[0]!==o.scales.y.range()[0]||cn.y.range()[1]!==o.scales.y.range()[1])&&ln(o.scales),ft){const e=o.getData(),t="function"==typeof a?a:e=>e[a||"x"],n="function"==typeof c?c:e=>e[c||"y"];An(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),_n(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((_e&&_e.length>0||Pt)&&(h||s))||!h&&33>r-an.current||(sn(e=>e+1),an.current=r),tt?.showBadge&&kn(!!b),(s||null!=o.activeTransition||y.pending)&&Kt()},function(e,t,n,o,r,i){const s=(0,lr.useRef)("fresh");(0,lr.useEffect)(()=>{if(!e)return;const a=setInterval(()=>{const a=t.current;if(!a||0===a.lastIngestTime)return;const c="undefined"!=typeof performance?performance.now():Date.now(),l=hr(e,c-a.lastIngestTime);l.band===s.current&&l.isStale===r||(s.current=l.band,l.isStale!==r&&i(l.isStale),n.current=!0,o())},1e3);return()=>clearInterval(a)},[e,r,o,t,i,n])}(tt,Rn,zt,Kt,wn,kn);const Kn=(0,mt.useMemo)(()=>{if(de||pe)return;const e=Rn.current;return e?.xIsDate&&cn?qc(cn.x.domain()):void 0},[de,pe,cn]),Zn=de||pe||Kn,Qn=on&&yn?me?me(yn):(0,Cl.jsx)(Sl,{hover:yn}):null,Jn=Qn?(0,Cl.jsx)(wc,{x:yn.x,y:yn.y,containerWidth:Jt,containerHeight:en,margin:Qt,className:"stream-frame-tooltip",children:Qn}):null,eo=Yn.current,to=(0,Cl.jsx)(rc,{active:qn.current>=0,hoverPoint:yn,margin:Qt,size:qt,shape:eo?.shape,width:eo?.w,height:eo?.h}),ro=Fc(a,M,"__semiotic_resolvedX","__semiotic_resolvedTime"),io=Fc(c,w,"__semiotic_resolvedY","__semiotic_resolvedValue"),so=ro.key,ao=io.key,co=function(e,t,n){return o=>{if(!o||!n||!e.fn&&!t.fn)return o;let r=!1;const i=o.map(n=>{const o=e.fn&&e.key&&!(e.key in n),i=t.fn&&t.key&&!(t.key in n);if(!o&&!i)return n;r=!0;const s={...n};return o&&(s[e.key]=e.fn(n)),i&&(s[t.key]=t.fn(n)),s});return r?i:o}}(ro,io,_e&&_e.length>0||!1);if(ma||!Bt&&Ft){const e=Rn.current;e&&r&&(e.ingest({inserts:tn,bounded:!0}),e.computeScene({width:Jt,height:en}));const t=e?.scene??[],n=e?.scales??null,o=Oc(Ye,qt,Qt,n),i=Oc(qe,qt,Qt,n),s=Zn||(()=>{if(e?.xIsDate&&n)return qc(n.x.domain())})();return(0,Cl.jsxs)("div",{ref:Wt,className:"stream-xy-frame"+(z?" "+z:""),role:"img","aria-label":wt||("string"==typeof Ve?Ve:"XY chart"),style:{position:"relative",width:I?"100%":qt[0],height:T?"100%":qt[1]},children:[(0,Cl.jsx)(ec,{summary:At}),(0,Cl.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:qt[0],height:qt[1],style:{position:"absolute",left:0,top:0},children:[(0,Cl.jsx)("g",{transform:`translate(${Qt.left},${Qt.top})`,children:i}),(0,Cl.jsxs)("g",{transform:`translate(${Qt.left},${Qt.top})`,children:[O&&(0,Cl.jsx)("rect",{x:0,y:0,width:Jt,height:en,fill:O}),He&&n&&He.map((e,o)=>(0,Cl.jsx)(gt.Fragment,{children:e(t,n,{width:Jt,height:en})},"svgpre-"+o)),t.map((e,t)=>bl({node:e,index:t,renderMode:D,fallback:()=>ga(e,t,$t)})).filter(Boolean)]})]}),(0,Cl.jsx)(Ns,{width:Jt,height:en,totalWidth:qt[0],totalHeight:qt[1],margin:Qt,scales:n,showAxes:se,axes:ae,xLabel:ce,yLabel:le,yLabelRight:ue,xFormat:s,yFormat:he||ye,axisExtent:fe,showGrid:Ce,title:Ve,legend:Te,legendHoverBehavior:$e,legendClickBehavior:ze,legendHighlightedCategory:Ee,legendIsolatedCategories:Oe,legendPosition:De,legendLayout:Be,foregroundGraphics:fo(o,pt(Rn.current?.customLayoutOverlays,Ct??null)),marginalGraphics:ft,xValues:[],yValues:[],annotations:_e,onAnnotationActivate:Pe,onObservation:we??ve,chartId:ke,chartType:"StreamXYFrame",autoPlaceAnnotations:je,svgAnnotationRules:Re,annotationFrame:0,xAccessor:so,yAccessor:ao,annotationData:co(Rn.current?.getData()),pointNodes:Yc(Rn.current?.scene),curve:"string"==typeof g?g:void 0,linkedCrosshairName:Mt,linkedCrosshairSourceId:_t})]})}return(0,Cl.jsxs)("div",{ref:Wt,className:"stream-xy-frame"+(z?" "+z:""),role:"group","aria-label":wt||("string"==typeof Ve?Ve:"XY chart"),tabIndex:0,style:{position:"relative",width:I?"100%":qt[0],height:T?"100%":qt[1],overflow:"visible",touchAction:Tl(Ue)},onKeyDown:Gn,children:["production"!==process.env.NODE_ENV&&Rn.current&&(0,Cl.jsx)(uo,{store:Rn.current,diagnostics:vn.current}),vt&&(0,Cl.jsx)(tc,{tableId:Vt}),vt&&(0,Cl.jsx)(Ja,{scene:Rn.current?.scene??[],chartType:n+" chart",tableId:Vt,chartTitle:"string"==typeof Ve?Ve:void 0}),(0,Cl.jsx)(ec,{summary:At}),(0,Cl.jsx)(za,{hoverPoint:yn}),(0,Cl.jsxs)("div",{role:"img","aria-label":wt||("string"==typeof Ve?Ve:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:on?Vn:void 0,onMouseMove:on?Xn:void 0,onPointerLeave:on?Fn:void 0,onMouseLeave:on?Fn:void 0,onPointerDown:on||Tt?Un:void 0,onClick:Tt?Wn:void 0,children:[(0,Cl.jsx)(Ec,{size:qt,margin:Qt,children:dn}),(0,Cl.jsx)(Ds,{width:Jt,height:en,totalWidth:qt[0],totalHeight:qt[1],margin:Qt,scales:cn,showAxes:se,axes:ae,showGrid:Ce,xFormat:Zn,yFormat:he||ye,axisExtent:fe}),(0,Cl.jsx)("canvas",{ref:zn,"aria-label":Fa(Rn.current?.scene??[],n+" chart"),style:{position:"absolute",left:0,top:0}}),(0,Cl.jsx)("canvas",{ref:En,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),(0,Cl.jsx)(Ns,{width:Jt,height:en,totalWidth:qt[0],totalHeight:qt[1],margin:Qt,scales:cn,showAxes:se,axes:ae,xLabel:ce,yLabel:le,yLabelRight:ue,xFormat:Zn,yFormat:he||ye,axisExtent:fe,showGrid:Ce,title:Ve,legend:Te,legendHoverBehavior:$e,legendClickBehavior:ze,legendHighlightedCategory:Ee,legendIsolatedCategories:Oe,legendPosition:De,legendLayout:Be,foregroundGraphics:fo(un,pt(Rn.current?.customLayoutOverlays,Ct??null)),marginalGraphics:ft,xValues:Sn,yValues:Mn,annotations:_e,onAnnotationActivate:Pe,onObservation:we??ve,chartId:ke,chartType:"StreamXYFrame",autoPlaceAnnotations:je,svgAnnotationRules:Re,annotationFrame:rn,xAccessor:so,yAccessor:ao,annotationData:co(Rn.current?.getData()),pointNodes:Yc(Rn.current?.scene),curve:"string"==typeof g?g:void 0,underlayRendered:!0,canvasObscuresUnderlay:!!Pa({background:O,hasBackgroundGraphics:!!qe,themeBackground:Yt?.colors.background}),linkedCrosshairName:Mt,linkedCrosshairSourceId:_t}),(Ue||Ke)&&(0,Cl.jsx)(kt,{width:Jt,height:en,totalWidth:qt[0],totalHeight:qt[1],margin:Qt,dimension:Ue?.dimension??"xy",scales:cn,onBrush:Ke??(()=>{}),binSize:v,snap:Ue?.snap,binBoundaries:Ue?.binBoundaries??("bar"===n?Rn.current?.getBinBoundaries():void 0),snapDuring:Ue?.snapDuring,streaming:"streaming"===o}),tt?.showBadge&&(0,Cl.jsx)(pr,{isStale:wn,position:tt.badgePosition}),to,Jn]})]})}));$l.displayName="StreamXYFrame";var zl=$l,El=y(require("react")),Ol=require("react/jsx-runtime");function Dl({componentName:e,message:t,diagnosticHint:n,width:o,height:r}){return(0,Ol.jsx)("div",{role:"alert",style:{width:o,height:Math.max(r,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"},children:(0,Ol.jsxs)("div",{style:{textAlign:"center",maxWidth:400},children:[(0,Ol.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),(0,Ol.jsx)("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:t}),n&&(0,Ol.jsx)("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:n})]})})}var Bl=require("react/jsx-runtime"),Fl=class extends El.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.onError?.(e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:(0,Bl.jsx)(Dl,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}},Nl=require("react/jsx-runtime");function Wl({componentName:e,width:t,height:n,children:o}){return(0,Nl.jsx)(Fl,{fallback:o=>(0,Nl.jsx)(Dl,{componentName:e,message:o.message,width:t,height:n}),children:o})}"undefined"!=typeof process&&process;var ql={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Yl={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2},Gl=require("react"),Hl=require("react"),Vl=require("react"),Xl=(require("react/jsx-runtime"),(0,Vl.createContext)(null));function Ul(){return(0,Vl.useContext)(Xl)}var Kl=require("react");function Zl(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function Ql(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function Jl(e,t){if(e.type!==t.type)return!1;if("interval"===e.type&&"interval"===t.type)return e.range[0]===t.range[0]&&e.range[1]===t.range[1];if("point"===e.type&&"point"===t.type){if(e.values.size!==t.values.size)return!1;for(const n of e.values)if(!t.values.has(n))return!1;return!0}return!1}var[eu,tu]=De(e=>({selections:new Map,setClause(t,n){e(e=>{const o=e.selections.get(t),r=o?.clauses.get(n.clientId);if(r&&function(e,t){if(e.clientId!==t.clientId||e.type!==t.type)return!1;const n=Object.entries(e.fields);if(n.length!==function(e){let t=0;for(const n in e)t++;return t}(t.fields))return!1;for(const[e,o]of n){const n=t.fields[e];if(!n||!Jl(o,n))return!1}return!0}(r,n))return{};const i=new Map(e.selections),s=Ql(i,t),a=new Map(s.clauses);return a.set(n.clientId,n),i.set(t,{...s,clauses:a}),{selections:i}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o||!o.clauses.has(n))return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,{...o,clauses:i}),{selections:r}})},setResolution(t,n){e(e=>{const o=e.selections.get(t);if(o?.resolution===n)return{};const r=new Map(e.selections),i=Ql(r,t);return r.set(t,{...i,resolution:n}),{selections:r}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const o=new Map(e.selections);return o.set(t,{...n,clauses:new Map}),{selections:o}})}}));function nu(e){const t=(0,Kl.useId)(),n=e.clientId||t,{name:o}=e,r=tu(e=>e.selections.get(o)),i=tu(e=>e.setClause),s=tu(e=>e.clearClause),a=(0,Kl.useMemo)(()=>!!r&&r.clauses.size>0,[r]);return{predicate:(0,Kl.useMemo)(()=>r&&0!==r.clauses.size?function(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(Zl(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(r,n):()=>!0,[r,n]),isActive:a,selectPoints:(0,Kl.useCallback)(e=>{const t={};let r=!1;for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)},r=!0;r&&i(o,{clientId:n,type:"point",fields:t})},[n,o,i]),selectInterval:(0,Kl.useCallback)(e=>{const t={};let r=!1;for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o},r=!0;r&&i(o,{clientId:n,type:"interval",fields:t})},[n,o,i]),clear:(0,Kl.useCallback)(()=>{s(o,n)},[s,o,n]),clientId:n}}var ou=y(require("react"));function ru(){return Xe(e=>e.theme)}function iu(e,t,n){const o=e.xValue??t?.[n];if(null==o)return null;const r=Number(o);return Number.isFinite(r)?r:null}function su(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?{...t,xValue:e.xValue}:t||{}}function au(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}require("react/jsx-runtime"),ou.createContext(void 0);var cu=require("react"),lu=require("react"),uu=(require("react/jsx-runtime"),(0,lu.createContext)(!1));(0,lu.createContext)(!1);var du=(0,lu.createContext)(null),hu="undefined"==typeof window?lu.useEffect:lu.useLayoutEffect;function fu({data:e,colorBy:t,colorScale:n,showLegend:o,legendPosition:r="right",userMargin:i,defaults:s={top:50,bottom:60,left:70,right:40},categories:a,additionalLegend:c,chartWidth:l,legendLayout:u,hasTitle:d=!1}){const h=(0,lu.useContext)(uu),f=null!==(0,lu.useContext)(du),p=void 0!==o?o:!h&&!!t,y=!!t&&(p||f),g=(0,cu.useMemo)(()=>{if(!y)return[];if(void 0!==a)return a;const n=new Set;for(const o of e){const e="function"==typeof t?t(o):o[t];null!=e&&n.add(e+"")}return Array.from(n)},[a,t,e,y]);!function(e){const t=(0,lu.useContext)(du),n=(0,lu.useId)(),o=function(e){const t=new Set,n=[];for(const o of e)t.has(o)||(t.add(o),n.push(o));return n}(e),r=(0,lu.useRef)([]);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(r.current,o)||(r.current=o);const i=r.current;hu(()=>{if(t)return()=>t.unregisterCategories(n)},[t,n]),hu(()=>{t&&t.registerCategories(n,i)},[t,n,i])}(f&&t?g:[]);const m=(0,cu.useMemo)(()=>{if(!p||!t)return;const o=function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i,categories:s}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==r&&(n.stroke=r),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:(s&&s.length>0?s:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((r,i)=>{const s=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),a=s?o(s,t,n):n?n(r):fe[i%fe.length];return{label:r+"",color:a}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:ge,categories:g});return 0!==o.legendGroups.reduce((e,t)=>e+t.items.length,0)?o:void 0},[p,t,e,n,g]),x=(0,cu.useMemo)(()=>mr(m,c),[m,c]),b=(0,cu.useMemo)(()=>{const e="number"==typeof i?{top:i,bottom:i,left:i,right:i}:i??{},t=t=>{const n=e[t];return"number"==typeof n?n:s[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},o=t=>"number"==typeof e[t];if(x){const e=Lr(x,u),t=Cr(x,Math.max(1,(l??600)-n.left-n.right),u)+jr(x)+("top"===r&&d?24:0);"right"===r&&!o("right")&&e>n.right?n.right=e:"left"===r&&!o("left")&&e>n.left?n.left=e:"top"!==r||o("top")?"bottom"!==r||o("bottom")||(n.bottom=Math.max(n.bottom,80,t)):n.top=Math.max(n.top,50,t)}return n},[s,i,x,r,l,u,d]);return{legend:x,margin:b,legendPosition:r}}var pu=[];function yu(){const e=ru(),t=e?.colors?.categorical;return t&&t.length>0?t:void 0}function gu(e,t,n,o,r){if(e)return e;if(n&&"object"==typeof n&&!Array.isArray(n)){const e=me(n,o);if(e)return e}let i;if(Array.isArray(n))i=n;else if(t&&t.length>0)i=t;else if("string"==typeof n){const e=le[n];Array.isArray(e)&&(i=e)}return i&&0!==i.length?null!=o?(r.has(o)||r.set(o,r.size),i[r.get(o)%i.length]):i[0]:de}function mu({selection:e,linkedHover:t,fallbackFields:n=pu,unwrapData:o=!1,onObservation:r,chartType:i,chartId:s,onClick:a,hoverHighlight:c,colorByField:l,mobileInteraction:u}){const d=(0,Hl.useId)(),h=(0,Hl.useMemo)(()=>function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField,seriesField:e.seriesField}:null}(t,n),[t,n]),f=(0,Hl.useMemo)(()=>"series"===h?.mode?[h.seriesField||l||n[0]].filter(e=>!!e):h?.fields||n,[h,l,n]),p=nu({name:e?.name||"__unused__",fields:f}),y=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:o,isActive:r,selectPoints:i,clear:s}=nu({name:t,fields:n});return{onHover:(0,Kl.useCallback)(e=>{if(!e)return void s();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1})(t)&&i(t)},[n,i,s]),predicate:o,isActive:r}}({name:h?.name||"hover",fields:f}),g=Li(e=>e.pushObservation),m=(0,Hl.useCallback)(e=>{r?.(e),g?.(e)},[r,g]),x=e?{isActive:p.isActive,predicate:p.predicate}:null,[b,v]=(0,Hl.useState)(null),w=(0,Hl.useRef)(!1),k=l||n[0],S=(0,Hl.useMemo)(()=>{if(!c||null==b||!k)return null;const e=b,t=k;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[c,b,k]),A=(0,Hl.useCallback)((e,n)=>{const o=!e&&w.current&&!!u?.enabled&&u.tapToLockTooltip;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===h?.mode&&h.xField){const n=iu(e,t,h.xField);null!=n&&function(e,t,n){const o=ps.positions.get(e);o?.locked||o&&o.xValue===t&&o.sourceId===n||(ps={positions:new Map(ps.positions).set(e,{xValue:t,sourceId:n})},gs())}(h.name||"hover",n,d)}"x-position"!==h?.mode&&y.onHover(t)}else"x-position"!==h?.mode||o||ms(h.name||"hover",d),"x-position"===h?.mode||o||y.onHover(null);if(c&&k)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=t?.[k];v(null!=n?n+"":null)}else o||v(null);(r||g)&&Al({onObservation:m,datum:e?su(e):null,x:e?.x,y:e?.y,chartType:i||"unknown",chartId:s,context:n})},[t,y,h,d,r,i,s,g,m,c,k,u]),M=(0,Hl.useCallback)((n=!0)=>{w.current=!1,t&&"x-position"!==h?.mode&&y.onHover(null),e&&u?.tapToSelect&&p.clear(),n&&c&&v(null),"x-position"===h?.mode&&(xs(h.name||"hover",d),ms(h.name||"hover",d))},[t,h,y,e,u,p,c,d]),_=(0,Hl.useCallback)((n,o)=>{const l=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),x=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===h?.mode&&h.xField&&n){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]);const t=iu(n,e,h.xField);null!=t&&function(e,t,n){const o=ps.positions.get(e);if(o?.locked){const t=new Map(ps.positions);return t.delete(e),ps={positions:t},gs(),!1}ps={positions:new Map(ps.positions).set(e,{xValue:t,sourceId:n,locked:!0})},gs()}(h.name||"hover",t,d)}if(l)if(n){w.current=!0;const o=su(n);if(t&&"x-position"!==h?.mode&&y.onHover(o),e&&u?.tapToSelect&&f.length>0){const e={};for(const t of f){const n=o[t];void 0!==n&&(e[t]=[n])}au(e)&&p.selectPoints(e)}if(c&&k){const e=o?.[k];v(null!=e?e+"":null)}}else x&&M();if(n||x){if(n&&a){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]),a(e,{x:n.x??0,y:n.y??0})}(r||g)&&Ml({onObservation:m,datum:n?su(n):null,x:n?.x,y:n?.y,chartType:i||"unknown",chartId:s,context:o})}},[a,r,g,m,i,s,h,d,u,t,y,e,p,f,c,k,M]);return(0,Hl.useEffect)(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&w.current&&M()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,M]),(0,Hl.useEffect)(()=>()=>{w.current&&M(!1)},[M]),(0,Hl.useEffect)(()=>{if("x-position"!==h?.mode)return;const e=h.name||"hover";return()=>{xs(e,d),ms(e,d)}},[h?.mode,h?.name,d]),{activeSelectionHook:x,hoverSelectionHook:S,customHoverBehavior:A,customClickBehavior:_,crosshairSourceId:d}}var xu=require("react"),bu=require("react");var vu=require("react");function wu(e){const t=(0,Gl.useRef)(null);return function(e,t){const{variant:n,frameRef:o,overrides:r}=t,i=(0,vu.useRef)(r);i.current=r,(0,vu.useImperativeHandle)(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,n)=>e.current?.update(t,n)??[],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 n=Array.isArray(t)?t:[t],o=e.current?.getTopology()?.nodes??[],r=[];for(const t of n){const n=o.find(e=>e.id===t);n&&r.push({...n.data??{},id:t}),e.current?.removeNode(t)}return r},update:(t,n)=>(Array.isArray(t)?t:[t]).flatMap(t=>{const o=e.current?.updateNode(t,n);return o?[{...o,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,n)=>{const o=e.current?.removePoint(t)??[];for(const t of o)e.current?.push(n(t));return o},clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}const n=t;return{push:e=>n.current?.pushLine(e),pushMany:e=>n.current?.pushManyLines(e),remove:e=>n.current?.removeLine(e)??[],update:(e,t)=>{const o=n.current?.removeLine(e)??[];for(const e of o)n.current?.pushLine(t(e));return o},clear:()=>n.current?.clear(),getData:()=>n.current?.getLines()??[],getCustomLayout:()=>n.current?.getCustomLayout?.()??null,getLayoutFailure:()=>n.current?.getLayoutFailure?.()??null}}(n,o);return new Proxy(e,{get(e,t,n){if("string"==typeof t){const e=i.current?.[t];if("function"==typeof e)return e}return Reflect.get(e,t,n)},has:(e,t)=>!("string"!=typeof t||!i.current||!(t in i.current))||Reflect.has(e,t)})},[])}(e.imperativeRef,{variant:e.imperativeVariant,frameRef:t}),{frameRef:t,resolved:C(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},void 0),normalizedMargin:(0,Gl.useMemo)(()=>I(e.margin),[e.margin])}}function ku(e){const{title:t,description:n,summary:o,accessibleTable:r,className:i,animate:s,axisExtent:a,autoPlaceAnnotations:c}=e,l={};return t&&(l.title=t),n&&(l.description=n),o&&(l.summary=o),void 0!==r&&(l.accessibleTable=r),i&&(l.className=i),null!=s&&(l.animate=s),void 0!==a&&(l.axisExtent=a),void 0!==c&&(l.autoPlaceAnnotations=c),l}function Su(e){const{linkedHover:t,selection:n,onObservation:o,onClick:r,hoverRadius:i,hoverHighlight:s,forceHoverBehavior:a,forceClickBehavior:c,mobileInteraction:l,customHoverBehavior:u,customClickBehavior:d,linkedHoverInClickPredicate:h=!0}=e,f={};o&&(f.annotationObservationCallback=o);const p=l?.enabled?Math.max(i??30,Math.ceil((l.targetSize||44)/2),24):i;return(a||t||o||r||s)&&(f.customHoverBehavior=u),d&&(c||(h?o||r||t:o||r)||l?.enabled&&(l.tapToSelect||l.tapToLockTooltip)&&(t||s||n))&&(f.customClickBehavior=d),null!=p&&(f.hoverRadius=p),f}var Au=require("react/jsx-runtime"),Mu=(0,yt.forwardRef)(function(e,t){const{data:n,layout:o,layoutConfig:r,onLayoutError:i,xExtent:s,yExtent:a,showAxes:c=!1,margin:l,className:u,annotations:d,onObservation:h,onClick:f,selection:p,linkedHover:y,hoverHighlight:g,chartId:m,loading:x,loadingContent:b,emptyContent:v,colorBy:w,colorScheme:k,legend:S,legendInteraction:A,legendPosition:M,frameProps:_={}}=e,{legend:P,...R}=_,C=(0,yt.useMemo)(()=>mr(P,S),[P,S]),{frameRef:L,resolved:I,safeData:T,setup:$,earlyReturn:z}=function(e){const t=wu(e),{resolved:n,normalizedMargin:o}=t,r=function(e){const{data:t,rawData:n,colorBy:o,colorScheme:r,legendInteraction:i,legendPosition:s,selection:a,linkedHover:c,fallbackFields:l,unwrapData:u=!1,onObservation:d,chartType:h,chartId:f,showLegend:p,legend:y,legendLayout:g,userMargin:m,marginDefaults:x,onClick:b,hoverHighlight:v,mobileInteraction:w,mobileSemantics:k,loading:S,loadingContent:A,emptyContent:M,width:_,height:P,hasTitle:R}=e,C=void 0===n,L=(0,xu.useMemo)(()=>E(t),[t]),[I,T]=(0,xu.useState)([]),$=(0,xu.useCallback)(e=>{T(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),z="string"==typeof e.colorBy?e.colorBy:void 0,O=(0,xu.useMemo)(()=>j(w,{width:_,mobileSemantics:k}),[w,_,k]),{activeSelectionHook:D,hoverSelectionHook:B,customHoverBehavior:F,customClickBehavior:N,crosshairSourceId:W}=mu({selection:a,linkedHover:c,fallbackFields:l,unwrapData:u,onObservation:d,chartType:h,chartId:f,onClick:b,hoverHighlight:v,colorByField:z,mobileInteraction:O}),q=function(e,t){const n="object"==typeof e&&null!==e?e:void 0;if("x-position"===n?.mode)return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:t}}(c,W),Y=function(e,t,n){const o=Ul(),r=yu();return(0,Hl.useMemo)(()=>{if(!t)return;const i=o??void 0,s=n??(r&&r.length>0?r:void 0)??"category10";if(0!==e.length){if("function"==typeof t){const n=Array.from(new Set(e.map(e=>t(e)+"")));if(i&&au(i)){const e=xe(n.map(e=>({_cat:e})),"_cat",s);return t=>i[t]||e(t)}return xe(n.map(e=>({_cat:e})),"_cat",s)}if(i&&au(i)){const n=xe(e,t,s);return e=>i[e]||n(e)}return xe(e,t,s)}if(i&&au(i)){const e=xe([{_:"a"}],"_",s);return t=>i[t]||e(t)}},[e,t,n,o,r])}(L,o,r),G=(0,xu.useMemo)(()=>{if(!o)return[];const e=new Set;for(const t of L){const n="function"==typeof o?o(t):t[o];null!=n&&e.add(n+"")}return Array.from(e)},[L,o]),H=(0,xu.useMemo)(()=>C&&I.length>0?I:G,[C,I,G]),V=function(e,t,n){const[o,r]=(0,cu.useState)(null),[i,s]=(0,cu.useState)(new Set),a=(0,cu.useMemo)(()=>new Set,[]),c=(0,cu.useCallback)(t=>{"highlight"===e&&r(t?t.label:null)},[e]),l=(0,cu.useCallback)(t=>{"isolate"===e&&s(e=>{const o=new Set(e);return o.has(t.label)?o.delete(t.label):o.add(t.label),o.size===n.length?new Set:o})},[e,n.length]),u=(0,cu.useMemo)(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=o?{isActive:!0,predicate:e=>(n?e[n]:"function"==typeof t?t(e):null)===o}:"isolate"===e&&i.size>0?{isActive:!0,predicate:e=>{const o=n?e[n]:"function"==typeof t?t(e):null;return i.has(o)}}:null},[e,t,o,i]);return{highlightedCategory:"highlight"===e?o:null,isolatedCategories:"isolate"===e?i:a,onLegendHover:c,onLegendClick:l,legendSelectionHook:u}}(i,o,H),X=(0,xu.useMemo)(()=>B||(V.legendSelectionHook?V.legendSelectionHook:D),[B,V.legendSelectionHook,D]),U=function(e){const t=Xe(e=>e.theme.colors.selectionOpacity);return(0,bu.useMemo)(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}(a),K=yu(),Z=Ul(),Q=(0,xu.useMemo)(()=>{if(Y)return Y;if(!o||0===H.length)return;const e=Array.isArray(r)&&r.length>0||"string"==typeof r&&r.length>0?r:K&&K.length>0?K:fe,t="__streamCat",n=xe(H.map(e=>({[t]:e})),t,e);return e=>Z?.[e]||n(e)||"#999"},[Y,o,H,r,K,Z]),{legend:J,margin:ee,legendPosition:te}=fu({data:L,colorBy:o,colorScale:Q,showLegend:p,legendPosition:s,userMargin:m,defaults:x,categories:H,additionalLegend:y,chartWidth:_,legendLayout:g,hasTitle:R}),ne=(0,xu.useMemo)(()=>{const e={};return J&&(e.legend=J,e.legendPosition=te,g&&(e.legendLayout=g)),i&&"none"!==i&&(e.legendHoverBehavior=V.onLegendHover,e.legendClickBehavior=V.onLegendClick,e.legendHighlightedCategory=V.highlightedCategory,e.legendIsolatedCategories=V.isolatedCategories),C&&o&&(e.legendCategoryAccessor=o,e.onCategoriesChange=$),e},[J,te,g,i,V.onLegendHover,V.onLegendClick,V.highlightedCategory,V.isolatedCategories,C,o,$]),oe=Array.isArray(n)?E(n):n,re=function(e,t,n,o){if(!e)return null;if(!1===o)return null;if(null!=o)return(0,Nl.jsx)("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:o});const r=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*r))),s=Math.max(6,Math.floor(n/(2.5*r))),a=Math.floor((n-(r*(i+s)-s))/2);return(0,Nl.jsx)("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:r},(e,n)=>(0,Nl.jsx)("div",{className:"semiotic-loading-bar",style:{...Yl,position:"absolute",top:a+n*(i+s),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2}},n))})}(S,_,P,A),ie=re?null:function(e,t,n,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?(0,Nl.jsx)("div",{style:{...ql,width:t,height:n},children:o||"No data available"}):null}(oe,_,P,M);return{data:L,colorScale:Y,allCategories:H,legendState:V,effectiveSelectionHook:X,activeSelectionHook:D,customHoverBehavior:F,customClickBehavior:N,mobileInteraction:O,legend:J,margin:ee,legendPosition:te,earlyReturn:re||ie||null,legendBehaviorProps:ne,crosshairProps:q,resolvedSelection:U}}({data:e.data??[],rawData:e.data,colorBy:e.colorBy,colorScheme:e.colorScheme,legendInteraction:e.legendInteraction,legendPosition:e.legendPosition,selection:e.selection,linkedHover:e.linkedHover,hoverHighlight:e.hoverHighlight,fallbackFields:"string"==typeof e.colorBy?[e.colorBy]:[],unwrapData:e.unwrapData,onObservation:e.onObservation,onClick:e.onClick,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:e.chartTypeLabel,chartId:e.chartId,showLegend:n.showLegend,legend:e.legend,userMargin:o,marginDefaults:n.marginDefaults,loading:e.loading,loadingContent:e.loadingContent,emptyContent:e.emptyContent,width:n.width,height:n.height});return{...t,safeData:r.data,setup:r,earlyReturn:r.earlyReturn}}({imperativeRef:t,imperativeVariant:"xy",chartTypeLabel:"XYCustomChart",unwrapData:!1,data:n,colorBy:w,colorScheme:k,legend:C,legendInteraction:A,legendPosition:M,selection:p,linkedHover:y,hoverHighlight:g,onObservation:h,onClick:f,chartId:m,loading:x,loadingContent:b,emptyContent:v,margin:l,width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules,xLabel:e.xLabel,yLabel:e.yLabel}),O=$.effectiveSelectionHook,D=(0,yt.useMemo)(()=>O?.isActive?{isActive:!0,predicate:O.predicate}:null,[O?.isActive,O?.predicate]);if(z)return z;const{width:B,height:F,enableHover:N,showGrid:W,title:q,description:Y,summary:G,accessibleTable:H,xLabel:V,yLabel:X}=I,U={chartType:"custom",...null!=n&&{data:T},customLayout:o,layoutConfig:r,onLayoutError:i,...D&&{layoutSelection:D},xExtent:s,yExtent:a,colorAccessor:w,colorScheme:k,size:[B,F],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:$.margin,showAxes:c,xLabel:V,yLabel:X,enableHover:N,showGrid:W,...$.legendBehaviorProps,...ku({title:q,description:Y,summary:G,accessibleTable:H,className:u,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...null!=e.tooltip&&{tooltipContent:e.tooltip},...Su({linkedHover:y,selection:p,onObservation:h,onClick:f,hoverRadius:e.hoverRadius,hoverHighlight:g,mobileInteraction:$.mobileInteraction,customHoverBehavior:$.customHoverBehavior,customClickBehavior:$.customClickBehavior}),...d&&d.length>0&&{annotations:d},...$.crosshairProps,...R};return(0,Au.jsx)(Wl,{componentName:"XYCustomChart",width:B,height:F,children:(0,Au.jsx)(zl,{ref:L,...U})})});function _u(e,t,n,o,r){const i=1-r;return i*i*i*e+3*i*i*r*t+3*i*r*r*n+r*r*r*o}function Pu(e,t,n,o,r){const i=1-r;return 3*i*i*(t-e)+6*i*r*(n-t)+3*r*r*(o-n)}function ju(e,t,n,o,r){const i=[],s=(e.x+t.x)/2;for(let a=0;r>=a;a++){const c=a/r;let l,u,d,h;"linear"===o?(l=e.x+(t.x-e.x)*c,u=e.y+(t.y-e.y)*c,d=t.x-e.x,h=t.y-e.y):(l=_u(e.x,s,s,t.x,c),u=_u(e.y,e.y,t.y,t.y,c),d=Pu(e.x,s,s,t.x,c),h=Pu(e.y,e.y,t.y,t.y,c)),i.push({x:l,y:u,dx:d,dy:h,radius:e.radius+(t.radius-e.radius)*c,datumIndex:.5>c?n:n+1})}return i}function Ru(e,t={}){const n=[],o=[],r=[];if(2>e.length)return{topPath:n,bottomPath:o,datumIndices:r};const i=t.curve??"smooth",s=Math.max(2,Math.floor(t.samplesPerSegment??12));for(let t=0;e.length-1>t;t++){const a=ju(e[t],e[t+1],t,i,s);for(let e=0===t?0:1;a.length>e;e++){const t=a[e],i=Math.hypot(t.dx,t.dy)||1,s=-t.dy/i,c=t.dx/i,l=Math.max(0,t.radius);n.push([t.x+s*l,t.y+c*l]),o.push([t.x-s*l,t.y-c*l]),r.push(t.datumIndex)}}return{topPath:n,bottomPath:o,datumIndices:r}}Mu.displayName="XYCustomChart";var Cu=require("react/jsx-runtime");function Lu(e,t,n){return"function"==typeof e?e(t,n):t[e]}function Iu(e){return e instanceof Date?"date:"+e.getTime():`${typeof e}:${e+""}`}function Tu(e,t){if(!e?.length)return;const n=new Map(t.map((e,t)=>[Iu(e),t]));return e.map(e=>{const t={...e},o=o=>{if(!(o in e))return;const r=n.get(Iu(e[o]));void 0!==r&&(t[o]=r)};return o("x"),o("x0"),o("x1"),"string"!=typeof e.type||"x-threshold"!==e.type&&"x"!==e.type||o("value"),t})}function $u(e){const{seriesOrder:t,overallOrder:n,highlightTop:o,color:r,colorScheme:i,neutralColor:s,themeCategorical:a,themeNeutral:c}=e;if(null==o&&null==r)return i;const l=new Set(n.slice(0,null==o?n.length:Math.max(0,Math.floor(o)))),u=new Map,d={};for(const e of t)d[e]=r??(l.has(e)?gu(void 0,a,i,e,u):s??c??"#b8bec8");return d}function zu(e,t={}){const n=t.xAccessor??"x",o=t.yAccessor??"y",r=t.lineBy??"series",i=t.rankDirection??"descending",s=[],a=new Map,c=new Map,l=[],u=new Map;let d=1/0,h=-1/0;e.forEach((e,t)=>{const i=Lu(n,e,t),f=Iu(i);let p=a.get(f);null==p&&(p=s.length,a.set(f,p),s.push(i),c.set(p,[]));const y=Lu(r,e,t)+"";u.has(y)||(u.set(y,l.length),l.push(y));const g=Number(Lu(o,e,t));Number.isFinite(g)&&(d=Math.min(d,g),h=Math.max(h,g),c.get(p)?.push({datum:e,inputIndex:t,series:y,value:g}))});const f=[],p=new Map,y=new Map;for(let e=0;s.length>e;e++){const t=c.get(e)??[];t.sort((e,t)=>("descending"===i?t.value-e.value:e.value-t.value)||(u.get(e.series)??0)-(u.get(t.series)??0)),t.forEach((t,n)=>{const o=n+1;f.push({datum:t.datum,xIndex:e,xValue:s[e],series:t.series,value:t.value,rank:o}),p.set(t.series,(p.get(t.series)??0)+o),y.set(t.series,(y.get(t.series)??0)+1)})}const g=l.length+1,m=[...l].sort((e,t)=>{const n=y.get(e)??0,o=y.get(t)??0;return((p.get(e)??0)+(s.length-n)*g)/Math.max(1,s.length)-((p.get(t)??0)+(s.length-o)*g)/Math.max(1,s.length)||(u.get(e)??0)-(u.get(t)??0)}),x=new Set(m.slice(0,null==t.highlightTop?m.length:Math.max(0,Math.floor(t.highlightTop))));return{data:f.map(e=>{const t=x.has(e.series);return{...e.datum,x:e.xIndex,y:e.rank,__bumpRaw:e.datum,__bumpSeries:e.series,__bumpColorGroup:t?e.series:"Other",__bumpValue:e.value,__bumpRank:e.rank,__bumpXValue:e.xValue,__bumpHighlighted:t}}),xValues:s,seriesOrder:l,overallOrder:m,valueExtent:d===1/0?[0,0]:[d,h]}}function Eu({datum:e,x:t,y:n,side:o,color:r,highlighted:i,labelStyle:s}){const a=lt.useContext(ht)??dt,c=a.isActive&&!a.predicate(e),l="function"==typeof s?s(e.__bumpRaw):s;return(0,Cu.jsx)("text",{className:"semiotic-bump-label",x:t+("end"===o?8:-8),y:n,dy:"0.35em",textAnchor:"end"===o?"start":"end",fill:r,fillOpacity:c?.16:1,fontWeight:i?650:450,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-axis-label-font-size, 11px)",...l},children:e.__bumpSeries})}function Ou(e,t,n){const[o,r]=t,[i,s]=n;return r===o?(i+s)/2:i+(s-i)*Math.max(0,Math.min(1,(e-o)/(r-o)))}function Du(e){const t=e instanceof Date?e.getTime():Number(e);return Number.isFinite(t)?t:void 0}function Bu(e){return{value:e.__bumpValue,x:Du(e.__bumpXValue),y:e.__bumpValue,category:e.__bumpSeries}}function Fu(e){const t=e.config,n=new Map;for(const t of e.data){const e=n.get(t.__bumpSeries)??[];e.push(t),n.set(t.__bumpSeries,e)}const o=t.seriesOrder.filter(e=>n.has(e)).sort((e,o)=>(n.get(e)?.[0]?.__bumpHighlighted?1:0)-(n.get(o)?.[0]?.__bumpHighlighted?1:0)||t.seriesOrder.indexOf(e)-t.seriesOrder.indexOf(o)),r=[],i=[];for(const s of o){const o=(n.get(s)??[]).sort((e,t)=>e.x-t.x);if(2>o.length)continue;const a=o[0].__bumpHighlighted,c=e.resolveColor(o[0].__bumpSeries,o[0]),l=t.color??(a?c:t.neutralColor??e.theme.semantic.textSecondary??e.theme.semantic.border??c),u=o.map(n=>({x:e.scales.x(n.x),y:e.scales.y(n.y),radius:t.ribbon?Ou(n.__bumpValue,t.valueExtent,t.ribbonSizeRange)/2:Math.max(.5,t.lineWidth/2)})),d=Ru(u,{curve:t.curve,samplesPerSegment:t.samplesPerSegment}),h=d.datumIndices.map(e=>o[e]),f={fill:l,fillOpacity:1,opacity:a?t.ribbon?t.ribbonOpacity:t.lineOpacity:Math.min(t.ribbon?t.ribbonOpacity:t.lineOpacity,.58)};t.styleRules?.length&&Object.assign(f,Pe(o[0].__bumpRaw,t.styleRules,Bu(o[0]))),t.areaStyle&&Object.assign(f,t.areaStyle(o[0].__bumpRaw)??{}),void 0!==t.stroke&&(f.stroke=t.stroke),void 0!==t.strokeWidth&&(f.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(f.opacity=t.opacity),r.push({type:"area",topPath:d.topPath,bottomPath:d.bottomPath,style:f,datum:h,accessibleDatum:o.map(e=>e.__bumpRaw),accessibility:{label:s+" ranking trajectory",tableFields:o.map(e=>e.__bumpRaw)},group:s,interactive:!0}),t.showPoints&&o.forEach((e,n)=>{const o={fill:l,stroke:"none",opacity:a?1:.75};t.styleRules?.length&&Object.assign(o,Pe(e.__bumpRaw,t.styleRules,Bu(e))),t.pointStyle&&Object.assign(o,t.pointStyle(e.__bumpRaw)??{}),void 0!==t.stroke&&(o.stroke=t.stroke),void 0!==t.strokeWidth&&(o.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(o.opacity=t.opacity),r.push({type:"point",x:u[n].x,y:u[n].y,r:o.r??t.pointRadius,style:o,datum:e,accessibleDatum:e.__bumpRaw,accessibility:{label:`${s}, rank ${e.__bumpRank}, value ${e.__bumpValue}`},pointId:`${s}:${e.x}`})});const p=!0===t.showLabels?"end":t.showLabels,y=(e,n,o)=>{i.push((0,Cu.jsx)(Eu,{datum:e,x:u[n].x,y:u[n].y,side:o,color:"string"==typeof f.fill?f.fill:l,highlighted:a,labelStyle:t.labelStyle},`${s}-${o}`))};"start"!==p&&"both"!==p||y(o[0],0,"start"),"end"!==p&&"both"!==p||y(o.at(-1),o.length-1,"end")}return{nodes:r,overlays:i.length?(0,Cu.jsx)("g",{className:"semiotic-bump-labels",children:i}):void 0,restyle:(e,t)=>{const n=function(e){const t=Array.isArray(e.datum)?e.datum[0]:e.datum;return t&&"object"==typeof t&&"__bumpSeries"in t?t:void 0}(e);if(t?.isActive&&n&&!t.predicate(n))return{opacity:.14}}}}function Nu(e,t,n,o,r){const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Ke(o.theme).colors.categorical,a=n??o.colorScheme??s,c="string"==typeof t?t:"__ssrAreaColorBy",l="function"==typeof t?i.map(e=>({...e,__ssrAreaColorBy:t(e)})):i,u=t?xe(l,c,a):void 0,d=!1!==r.showLine,h="number"==typeof r.lineWidth?r.lineWidth:2,f="number"==typeof r.areaOpacity?r.areaOpacity:.7,p=ke(r.yAccessor),y=r.styleRules;return(e,n)=>{const o=t&&u?ge(e,t,u):"string"==typeof r.color?r.color:de,i={fill:o,fillOpacity:f,stroke:d?o:"none",...d&&{strokeWidth:h}};return y?.length&&Object.assign(i,Pe(e,y,{value:p(e),category:n})),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 Wu(e,t,n,o,r){const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Ke(o.theme).colors.categorical,a=n??o.colorScheme??s,c="string"==typeof t?t:"__ssrBubbleColorBy",l="function"==typeof t?i.map(e=>({...e,__ssrBubbleColorBy:t(e)})):i,u=t?xe(l,c,a):void 0,d=r.sizeBy,h=Array.isArray(r.sizeRange)?r.sizeRange:[5,40],f=d?i.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],p=f.length?ve(f):void 0;return e=>({fill:t&&u?ge(e,t,u):"string"==typeof r.color?r.color:de,fillOpacity:"number"==typeof r.bubbleOpacity?r.bubbleOpacity:.6,r:d?be(e,d,h,p):h[0],stroke:r.stroke??r.bubbleStrokeColor??"white",strokeWidth:r.strokeWidth??r.bubbleStrokeWidth??1,...void 0!==r.opacity&&{opacity:r.opacity}})}function qu(e,t,n,o,r){const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Ke(o.theme).colors.categorical,a=n??o.colorScheme??s,c="string"==typeof t?t:"__ssrScatterColorBy",l="function"==typeof t?i.map(e=>({...e,__ssrScatterColorBy:t(e)})):i,u=t?xe(l,c,a):void 0,d=r.sizeBy,h=Array.isArray(r.sizeRange)?r.sizeRange:[3,15],f=d?i.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],p=f.length?ve(f):void 0,y=Se(r.xAccessor,r.yAccessor),g=r.styleRules;return e=>{const n={fill:t&&u?ge(e,t,u):"string"==typeof r.color?r.color:de,fillOpacity:"number"==typeof r.pointOpacity?r.pointOpacity:.8,r:d?be(e,d,h,p):"number"==typeof r.pointRadius?r.pointRadius:5};return g?.length&&Object.assign(n,Pe(e,g,y(e))),void 0!==r.stroke&&(n.stroke=r.stroke),void 0!==r.strokeWidth&&(n.strokeWidth=r.strokeWidth),void 0!==r.opacity&&(n.opacity=r.opacity),n}}(0,ct.forwardRef)(function(e,t){const n=yu(),o=ru(),{data:r,xAccessor:i,yAccessor:s,lineBy:a,rankDirection:c="descending",ribbon:l=!1,curve:u="smooth",ribbonSizeRange:d=[4,28],samplesPerSegment:h=12,lineWidth:f=3,highlightTop:p,neutralColor:y,styleRules:g,labelStyle:m,colorScheme:x,ribbonOpacity:b=.82,lineOpacity:v=.9,showPoints:w=!1,pointRadius:k=3,showLabels:S=!0,showAxes:A=!0,showGrid:M=!0,showLegend:_=!1,enableHover:P=!0,hoverHighlight:j=!0,tooltip:R,frameProps:C={},xFormat:L,yFormat:I,onClick:T}=e,$=(0,ct.useMemo)(()=>zu(r,{xAccessor:i,yAccessor:s,lineBy:a,rankDirection:c,highlightTop:p}),[r,i,s,a,c,p]),{axes:z,areaStyle:E,pointStyle:O,...D}=C,B=(0,ct.useMemo)(()=>$u({seriesOrder:$.seriesOrder,overallOrder:$.overallOrder,highlightTop:p,color:e.color,colorScheme:x,neutralColor:y,themeCategorical:n,themeNeutral:o.colors.textSecondary}),[$.seriesOrder,$.overallOrder,p,e.color,x,y,n,o.colors.textSecondary]),F=(0,ct.useMemo)(()=>({ribbon:l,curve:u,samplesPerSegment:h,ribbonSizeRange:d,valueExtent:$.valueExtent,seriesOrder:$.seriesOrder,lineWidth:f,ribbonOpacity:b,lineOpacity:v,neutralColor:y,color:e.color,stroke:e.stroke,strokeWidth:e.strokeWidth,opacity:e.opacity,styleRules:g,areaStyle:E,pointStyle:O,labelStyle:m,showPoints:w,pointRadius:k,showLabels:S}),[l,u,h,d,$.valueExtent,$.seriesOrder,f,b,v,y,e.color,e.stroke,e.strokeWidth,e.opacity,g,E,O,m,w,k,S]),N=(0,ct.useCallback)((e,t)=>{if(0===$.xValues.length)return"";const n=$.xValues[Math.max(0,Math.min($.xValues.length-1,Math.round(Number(e))))];return L?L(n,t):(n instanceof Date?n.toLocaleDateString():n)+""},[$.xValues,L]),W=(0,ct.useCallback)(e=>I?I(e):e.toLocaleString(),[I]),q=(0,ct.useMemo)(()=>"multi"===R?void 0:function(e){if(!0!==e){if("function"==typeof e){const t=e;return e=>{let n=ac(!0===e?.__semioticHoverData||e&&void 0!==e.data&&"number"==typeof e.x&&"number"==typeof e.y&&e&&("node"===e.type||"edge"===e.type||void 0!==e.nodeOrEdge||void 0!==e.allSeries||void 0!==e.stats||void 0!==e.__chartType)?e.data??{}:e);if(!n)return null;if(("node"===e?.nodeOrEdge&&"number"==typeof n?.x0&&"number"==typeof n?.x1||"edge"===e?.nodeOrEdge&&"number"==typeof n?.sankeyWidth)&&n.data&&"object"==typeof n.data&&(n=n.data),!n)return null;const o=t(n);return null==o?null:(0,yc.jsx)("div",{className:"semiotic-tooltip",style:gc,children:o})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?bc(e):"multi"===e?("undefined"!=typeof process&&"production"!==process.env?.NODE_ENV&&console.warn('[semiotic] tooltip="multi" reached normalizeTooltip — prefer charts that set tooltipMode (LineChart, AreaChart, StackedAreaChart, DifferenceChart). Rendering MultiLineTooltip content as a fallback.'),function(e={}){const{fields:t=[],title:n,format:o,style:r={},className:i="",showLabels:s=!0,separator:a=": "}=e;return e=>{if(!e||"object"!=typeof e)return null;const c=[];if(n){const t=mc(e,n);c.push({value:xc(t,o)})}if(t&&Array.isArray(t)&&t.length>0)t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const a=xc(mc(e,r),i);c.push({label:s?n:void 0,value:a})});else{const t=pc(e,{skipPositional:!1});null!=t.title&&c.push({label:void 0,value:xc(t.title,o),bold:!0}),t.entries.forEach(e=>{c.push({label:s?e.key:void 0,value:xc(e.value,o)})})}const l={...gc,...r};return Array.isArray(c)&&0!==c.length?(0,yc.jsx)("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+i).trim(),style:l,children:c.map((e,t)=>(0,yc.jsxs)("div",{style:{marginBottom:c.length-1>t?"4px":0,fontWeight:e.bold?"bold":void 0},children:[e.label&&(0,yc.jsxs)("strong",{children:[e.label,a]}),e.value]},t))}):null}}()):bc())}}(R),[R]),Y=(0,ct.useCallback)(e=>{const t=e?.data??e;return t?!1===R?null:q?q({...e,data:t.__bumpRaw,__semioticHoverData:!0}):(0,Cu.jsxs)("div",{className:"semiotic-tooltip",style:gc,children:[(0,Cu.jsx)("div",{style:{fontWeight:700},children:t.__bumpSeries}),(0,Cu.jsxs)("div",{children:[N(t.x)," · Rank ",t.__bumpRank]}),(0,Cu.jsxs)("div",{children:["Value: ",W(t.__bumpValue)]})]}):null},[W,N,q,R]),G=(0,ct.useMemo)(()=>{if(T)return(e,t)=>{T(e.__bumpRaw??e,t)}},[T]),H=Math.max(1,$.seriesOrder.length),V=$.xValues.map((e,t)=>t),X=Array.from({length:H},(e,t)=>t+1),U=z??[{orient:"left",tickValues:X,tickFormat:e=>e+"",label:e.yLabel??"Rank",baseline:!1},{orient:"bottom",tickValues:V,tickFormat:N,label:e.xLabel,tickAnchor:"edges"}],K=(0,ct.useMemo)(()=>Tu(e.annotations,$.xValues),[e.annotations,$.xValues]);return(0,Cu.jsx)(Mu,{ref:t,data:$.data,layout:Fu,layoutConfig:F,xExtent:[0,Math.max(1,$.xValues.length-1)],yExtent:[H+.5,.5],showAxes:A,showGrid:M,showLegend:_,enableHover:P,hoverHighlight:j,colorBy:"__bumpSeries",colorScheme:B,tooltip:Y,onClick:G,hoverRadius:e.hoverRadius,width:e.width,height:e.height,responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,responsiveRules:e.responsiveRules,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,mode:e.mode,margin:e.margin??{top:20,right:S?110:24,bottom:48,left:48},className:e.className,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,selection:e.selection,linkedHover:e.linkedHover,legend:e.legend,legendInteraction:e.legendInteraction,legendPosition:e.legendPosition,onObservation:e.onObservation,chartId:e.chartId,loading:e.loading,loadingContent:e.loadingContent,emptyContent:e.emptyContent,animate:e.animate,autoPlaceAnnotations:e.autoPlaceAnnotations,annotations:K,xLabel:e.xLabel,yLabel:e.yLabel??"Rank",frameProps:{axes:U,axisExtent:"exact",...D}})}).displayName="BumpChart";var Yu={frameType:"xy",buildProps:(e,t,n,o,r)=>({chartType:"scatter",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange||[5,40],colorScheme:n,...o,pointStyle:o.pointStyle||Wu(e,t,n,o,r),showLegend:o.showLegend??!!t})},Gu={frameType:"xy",layout:{margin:e=>({top:20,right:!1===e.showLabels?24:110,bottom:48,left:48})},buildProps:(e,t,n,o,r)=>{const i=zu(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],{xAccessor:r.xAccessor,yAccessor:r.yAccessor,lineBy:r.lineBy,rankDirection:r.rankDirection,highlightTop:"number"==typeof r.highlightTop?r.highlightTop:void 0}),s=Math.max(1,i.seriesOrder.length),a=Ke(o.theme),c=$u({seriesOrder:i.seriesOrder,overallOrder:i.overallOrder,highlightTop:"number"==typeof r.highlightTop?r.highlightTop:void 0,color:"string"==typeof r.color?r.color:void 0,colorScheme:n,neutralColor:"string"==typeof r.neutralColor?r.neutralColor:void 0,themeCategorical:a.colors.categorical,themeNeutral:a.colors.textSecondary}),l={ribbon:!0===r.ribbon,curve:"linear"===r.curve?"linear":"smooth",samplesPerSegment:"number"==typeof r.samplesPerSegment?r.samplesPerSegment:12,ribbonSizeRange:Array.isArray(r.ribbonSizeRange)?r.ribbonSizeRange:[4,28],valueExtent:i.valueExtent,seriesOrder:i.seriesOrder,lineWidth:"number"==typeof r.lineWidth?r.lineWidth:3,ribbonOpacity:"number"==typeof r.ribbonOpacity?r.ribbonOpacity:.82,lineOpacity:"number"==typeof r.lineOpacity?r.lineOpacity:.9,neutralColor:"string"==typeof r.neutralColor?r.neutralColor:void 0,color:"string"==typeof r.color?r.color:void 0,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,styleRules:r.styleRules,areaStyle:o.areaStyle,pointStyle:o.pointStyle,labelStyle:r.labelStyle,showPoints:!0===r.showPoints,pointRadius:"number"==typeof r.pointRadius?r.pointRadius:3,showLabels:r.showLabels??!0},u=o.xFormat,d=(e,t)=>{if(0===i.xValues.length)return"";const n=i.xValues[Math.max(0,Math.min(i.xValues.length-1,Math.round(Number(e))))];return u?u(n,t):(n instanceof Date?n.toLocaleDateString():n)+""},h=i.xValues.map((e,t)=>t),f=Array.from({length:s},(e,t)=>t+1),p=o.axes??[{orient:"left",tickValues:f,tickFormat:e=>e+"",label:o.yLabel??"Rank",baseline:!1},{orient:"bottom",tickValues:h,tickFormat:d,label:o.xLabel,tickAnchor:"edges"}];return{...o,chartType:"custom",data:i.data,xAccessor:"x",yAccessor:"y",xExtent:[0,Math.max(1,i.xValues.length-1)],yExtent:[s+.5,.5],customLayout:Fu,layoutConfig:l,colorAccessor:"__bumpSeries",colorScheme:c,xFormat:d,axes:p,axisExtent:"exact",showAxes:o.showAxes??!0,showLegend:o.showLegend??!1,annotations:Tu(o.annotations,i.xValues)}}};function Hu(e,t,n,o,r){if(!r.showPoints)return;const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Ke(o.theme).colors.categorical,a=n??o.colorScheme??s,c="string"==typeof t?t:"__ssrPointColorBy",l="function"==typeof t?i.map(e=>({...e,__ssrPointColorBy:t(e)})):i,u=t?xe(l,c,a):void 0,d="number"==typeof r.pointRadius?r.pointRadius:3;return e=>{const n=t&&u?ge(e,t,u):"string"==typeof r.color?r.color:de;return{r:d,fill:n,stroke:"none"}}}var Vu={frameType:"xy",buildProps:(e,t,n,o,r)=>{const i=t||r.lineBy,s=r.fillArea,a=Array.isArray(s)?"mixed":s?"area":"line",c=Ke(o.theme).colors.categorical,l=function(e,t,n,o,r){const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Ke(o.theme).colors.categorical,a=n??o.colorScheme??s,c="string"==typeof t?t:"__ssrLineColorBy",l="function"==typeof t?i.map(e=>({...e,__ssrLineColorBy:t(e)})):i,u=t?xe(l,c,a):void 0,d=Se(r.xAccessor,r.yAccessor),h=function(e){const{lineWidth:t=2,colorBy:n,colorScale:o,color:r,resolveStroke:i,fillArea:s,areaOpacity:a=.3,styleRules:c,ruleContext:l}=e;return(e,u)=>{const d={strokeWidth:t},h=!0===s||Array.isArray(s)&&null!=u&&s.includes(u);let f;return i?f=i(e,u):n?o&&(f=ge(e,n,o)):f=r||de,void 0!==f&&(d.stroke=f,h&&(d.fill=f,d.fillOpacity=a)),c?.length&&Object.assign(d,Pe(e,c,l?l(e,u):{value:void 0,category:u})),d}}({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:d});return function(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return e??((...e)=>({}));const n={};return void 0!==t.stroke&&(n.stroke=t.stroke),void 0!==t.strokeWidth&&(n.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(n.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...n}):(...e)=>({...n})}(h,{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,i,n,o,r),u=at({data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",lineBy:r.lineBy,colorBy:i,colorScheme:n,color:"string"==typeof r.color?r.color:void 0,forecast:r.forecast,anomaly:r.anomaly,gapStrategy:r.gapStrategy,directLabel:r.directLabel,annotations:o.annotations,themeCategorical:c,baseLineStyle:l}),d=o.pointStyle||Hu(u.data,u.colorAccessor,n,o,r);let h=o.margin;u.marginExtra&&h&&"object"==typeof h?h={...h,...null!=u.marginExtra.right&&{right:Math.max(Number(h.right)||0,u.marginExtra.right)},...null!=u.marginExtra.left&&{left:Math.max(Number(h.left)||0,u.marginExtra.left)}}:u.marginExtra&&null==h&&(h={top:20,right:u.marginExtra.right??20,bottom:30,left:u.marginExtra.left??40});const f=(!r.directLabel||void 0!==o.showLegend)&&(o.showLegend??!!u.colorAccessor);return{chartType:a,data:u.data,xAccessor:u.xAccessor,yAccessor:u.yAccessor,groupAccessor:u.groupAccessor,colorAccessor:u.colorAccessor,colorScheme:n,lineStyle:u.lineStyle||l,...Array.isArray(s)&&{areaGroups:s},...s&&null!=r.areaOpacity&&{areaOpacity:r.areaOpacity},...null!=r.band&&{band:r.band},...o,...void 0!==h&&{margin:h},annotations:u.annotations,...u.yExtent&&!o.yExtent&&{yExtent:u.yExtent},...d&&{pointStyle:d},showLegend:f}}},Xu={frameType:"xy",buildProps:(e,t,n,o,r)=>{const i=Array.isArray(e)?E(e):[],s=r.timeAccessor||"time",a=r.valueAccessor||"value",c=r.categoryAccessor,l=r.valueExtent||o.yExtent,u="down"===r.direction?function({data:e,valueAccessor:t,timeAccessor:n,binSize:o,valueExtent:r,extentPadding:i}){if(r)return[r[1],r[0]];if(!e||0===e.length)return;const s=new Map;for(const r of e){const e=Qe(r,n,"time"),i=Qe(r,t,"value");if(null==e||null==i)continue;const a=Math.floor(e/o)*o;s.set(a,(s.get(a)??0)+i)}let a=0;for(const e of s.values())a=Math.max(a,e);return[a>0?a+a*(i??.1):1,0]}({data:i,timeAccessor:s,valueAccessor:a,binSize:Number(r.binSize),valueExtent:l,extentPadding:r.extentPadding}):l,d={...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:i,...o,runtimeMode:"streaming",windowMode:"growing",windowSize:Math.max(1,i.length),arrowOfTime:r.arrowOfTime||"right",timeAccessor:s,valueAccessor:a,xExtent:r.timeExtent||o.xExtent,yExtent:u,extentPadding:r.extentPadding??o.extentPadding,binSize:r.binSize,categoryAccessor:c,barColors:r.colors||o.barColors,colorScheme:r.colors||o.colorScheme,barStyle:o.barStyle||d,showLegend:o.showLegend??!!c}}},Uu={frameType:"xy",buildProps:(e,t,n,o,r)=>{const i=t||r.areaBy,s=function({data:e,safeData:t,areaBy:n,lineDataAccessor:o}){if(null==e)return[];const r=void 0!==t[0]?.[o];if(!r&&!n)return t;let i;if(r)i=t;else{const e=t.reduce((e,t)=>{const r="function"==typeof n?n(t):t[n],i=r+"";if(!e[i]){const t={[o]:[]};"string"==typeof n&&(t[n]=r),e[i]=t}return e[i][o].push(t),e},{});i=Object.values(e)}return i.flatMap(e=>{const t=Array.isArray(e[o])?e[o]:[];return"string"==typeof n?t.map(t=>({...t,[n]:t[n]??e[n]})):t})}({data:e,safeData:Array.isArray(e)?E(e):[],areaBy:r.areaBy,lineDataAccessor:r.lineDataAccessor||"coordinates"}),a=function(e){if(e)return Array.isArray(e)?{stops:e.map(({at:e,color:t,opacity:n})=>({offset:e/100,color:t,...null!=n&&{opacity:n}}))}:Array.isArray(e.stops)?e:void 0}(r.semanticGradient),c=a?.stops.length?{stops:a.stops.map(e=>({...e,offset:1-e.offset})).sort((e,t)=>e.offset-t.offset)}:Le(o.gradientFill),l=!1!==r.semanticLine&&a?.stops.length?a.stops.flatMap(({offset:e,color:t})=>t?[{offset:e,color:t}]:[]):void 0,u=o.pointStyle||Hu(s,i,n,o,r);return{chartType:"area",data:s,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",y0Accessor:r.y0Accessor,groupAccessor:r.areaBy||void 0,colorAccessor:i,colorScheme:n,...o,...void 0!==c&&{gradientFill:c},...l&&{semanticLineStops:l},lineStyle:o.lineStyle||Nu(s,i,n,o,r),...u&&{pointStyle:u}}}},Ku={frameType:"xy",buildProps:(e,t,n,o,r)=>{const i=r.xAccessor||"x",s=r.seriesAAccessor||"a",a=r.seriesBAccessor||"b",c=e=>$e(Te(i,"x",e)),l=e=>$e(Te(s,"a",e)),u=e=>$e(Te(a,"b",e)),d=r.seriesAColor||"var(--semiotic-danger, #dc2626)",h=r.seriesBColor||"var(--semiotic-info, #2563eb)",f=r.areaOpacity??.6,p=r.lineWidth??1.5,y=!1!==r.showLines,g=!1!==o.showLegend,m=r.seriesALabel||"A",x=r.seriesBLabel||"B",b=o.legendPosition||"right",v=function(e,t,n,o){if(!e.length)return[];const r=e.filter(e=>Number.isFinite(t(e))).sort((e,n)=>t(e)-t(n)),i=[];let s=0,a=null,c=null,l=[];const u=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${s}-${e}`,h=e=>i.push(e),f=(e,t)=>{h({__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;r.length>e;e++){const i=r[e],p=t(i),y=n(i),g=o(i);if(!Number.isFinite(p)||!Number.isFinite(y)||!Number.isFinite(g))continue;const m=u(y,g);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 n=y-c.a-(g-c.b);if(0!==n){const o=Math.max(0,Math.min(1,(c.b-c.a)/n));e=c.x+o*(p-c.x),t=c.a+o*(y-c.a)}else e=c.x,t=c.a}h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t}),s++,a=m,h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t});for(let e=1;l.length>e;e++)f(l[e],a)}else for(const e of l)f(e,a);l=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:i}),c={x:p,a:y,b:g,w:m}}else{a=m;for(const e of l)f(e,a);l=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:i}),c={x:p,a:y,b:g,w:m}}else l.push({x:p,y:y,datum:i})}for(const e of l)f(e,a??"A");return i}(Array.isArray(e)?e:[],c,l,u),w=[];if(y&&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),n=l(e),o=u(e);Number.isFinite(n)&&w.push({__x:t,__y:n,__diffSegment:"line-A"}),Number.isFinite(o)&&w.push({__x:t,__y:o,__diffSegment:"line-B"})}}return{chartType:"mixed",data:[...v,...w],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")?d:h,stroke:"none",fillOpacity:f}},lineStyle:e=>({stroke:"A"==("line-A"===e.__diffSegment?"A":"B")?d:h,strokeWidth:p,fill:"none"}),curve:r.curve||"linear",...o,...g&&{legend:{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:m,color:d},{label:x,color:h}]}]},legendPosition:b}}}},Zu={frameType:"xy",buildProps:(e,t,n,o,r)=>{const i=t||r.areaBy,s="string"==typeof i&&Array.isArray(e)?xe(e,i,n):void 0,a="number"==typeof r.areaOpacity?r.areaOpacity:.7,c=o.lineStyle||(e=>{const t=null==i?void 0:ge(e,i,s),n=r.showLine??!0,o={fill:r.color??t,stroke:n?r.stroke??t:"none",...n?{strokeWidth:r.strokeWidth??r.lineWidth??2}:{},fillOpacity:a,...null==r.opacity?{}:{opacity:r.opacity}},c=r.styleRules;if(c?.length){const t=ke(r.yAccessor),n=i?"function"==typeof i?(i(e)??"")+"":(e[i]??"")+"":void 0;Object.assign(o,Pe(e,c,{value:t(e),category:n}))}return o}),l=r.normalize?"zero":r.baseline??"zero",u=o.pointStyle||Hu(e,i,n,o,r);return{chartType:"stackedarea",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.areaBy,colorAccessor:i,colorScheme:n,normalize:r.normalize,baseline:l,stackOrder:r.stackOrder,lineStyle:c,...o,...u&&{pointStyle:u},curve:o.curve??r.curve??"monotoneX",showLegend:o.showLegend??!!i}}},Qu={frameType:"xy",buildProps:(e,t,n,o,r)=>{const[i]=o.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,...o,scalePadding:o.scalePadding??Math.max(2,Math.min(12,Math.round(i/40))),extentPadding:o.extentPadding??(i>200?.1:.02)}}},Ju={frameType:"xy",buildProps:(e,t,n,o,r)=>{const i=o.pointStyle||qu(e,t,n,o,r),s=function(e,t,n){return e&&0!==e.length?(o,r)=>{const i=Pe(o,e,t(o,r)),s=n?n(o,r):void 0;return s?{...i,...s}:i}:n}(r.styleRules,Se(r.xAccessor||"x",r.yAccessor||"y"),c),a=s?e=>({..."function"==typeof i?i(e):i,...s(e)}):i;var c;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:n,...o,sizeRange:r.sizeRange||[3,15],pointStyle:a,showLegend:o.showLegend??!!t}}},ed={frameType:"xy",buildProps:(e,t,n,o,r)=>{const i=r.xCenter,s=r.yCenter,a=r.quadrants,c=r.centerlineStyle||{},l=!1!==r.showQuadrantLabels,u=r.quadrantLabelSize??12,d=c.stroke||"#999",h=c.strokeWidth??1,f=Array.isArray(c.strokeDasharray)?c.strokeDasharray.join(","):c.strokeDasharray,p=$.createElement,y=a?[(e,t,n)=>{if(!t?.x||!t?.y)return null;const o=n.width,r=n.height,c=null!=i?t.x(i):o/2,y=null!=s?t.y(s):r/2;if(null!=i&&!Number.isFinite(c))return null;if(null!=s&&!Number.isFinite(y))return null;const g=Math.max(0,Math.min(o,c)),m=Math.max(0,Math.min(r,y)),x=[{c:a.topLeft,x:0,y:0,w:g,h:m},{c:a.topRight,x:g,y:0,w:o-g,h:m},{c:a.bottomLeft,x:0,y:m,w:g,h:r-m},{c:a.bottomRight,x:g,y:m,w:o-g,h:r-m}],b=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:o-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:o-8,y:r-8,fill:a.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.bottomRight.label)]:[];return p($.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:g,y1:0,x2:g,y2:r,stroke:d,strokeWidth:h,strokeDasharray:f}),p("line",{key:"hc",x1:0,y1:m,x2:o,y2:m,stroke:d,strokeWidth:h,strokeDasharray:f}),...b)}]: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:n,pointStyle:o.pointStyle||r.pointStyle||qu(e,t,n,o,r),...o,showLegend:o.showLegend??!!t,...y&&{svgPreRenderers:y}}}},td={frameType:"xy",buildProps:(e,t,n,o,r)=>{const i=function(e,t){if(!Array.isArray(e))return{data:e,orderMap:new WeakMap};const n=t.xAccessor||"x",o=t.yAccessor||"y",r=t.orderAccessor?[...e].sort((e,n)=>null==e||"object"!=typeof e?1:null==n||"object"!=typeof n?-1:$e(Te(t.orderAccessor,"order",e))-$e(Te(t.orderAccessor,"order",n))):e,i=new WeakMap;let s=0;for(const e of r){if(null==e||"object"!=typeof e)continue;const t=$e(Te(n,"x",e)),r=$e(Te(o,"y",e));Number.isFinite(t)&&Number.isFinite(r)&&s++}let a=0;for(const e of r){if(null==e||"object"!=typeof e)continue;const t=$e(Te(n,"x",e)),r=$e(Te(o,"y",e));Number.isFinite(t)&&Number.isFinite(r)&&i.set(e,{idx:a++,total:s})}return{data:r,orderMap:i}}(e,r),s=r.pointRadius??4;return{chartType:"scatter",data:i.data,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,colorScheme:n,pointStyle:e=>{const t=i.orderMap.get(e),n=t?.idx??0,o=t?.total??1;return{fill:o>0?ze(n,o):"#6366f1",stroke:"white",strokeWidth:1,r:s,fillOpacity:1}},...o,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 n=[];for(let e=0;t.length-1>e;e++){const o=t[e],r=t[e+1],i=ze(e,t.length);100>t.length&&n.push($.createElement("line",{key:"halo-"+e,x1:o.x,y1:o.y,x2:r.x,y2:r.y,stroke:"white",strokeWidth:s+2,strokeLinecap:"round",opacity:.5})),n.push($.createElement("line",{key:"segment-"+e,x1:o.x,y1:o.y,x2:r.x,y2:r.y,stroke:i,strokeWidth:s,strokeLinecap:"round"}))}return $.createElement($.Fragment,null,...n)}]}}};function nd(e){return Math.max(0,Math.min(1,e))}function od(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 n=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(n){const e=[Number(n[1]),Number(n[2]),Number(n[3])];if(e.every(Number.isFinite))return e}return null}function rd(e,t,n){const o=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}`}function id(e,t,n){const o=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:nd(e.offset),color:e.color??n,opacity:null==e.opacity?1:nd(e.opacity)})).sort((e,t)=>e.offset-t.offset);if(0===o.length)return"#999999";const r=e=>{if(1===e.opacity)return e.color;const t=od(e.color);return t?`rgba(${t[0]},${t[1]},${t[2]},${e.opacity})`:e.color};if(1===o.length)return r(o[0]);const i=nd(t);if(o[0].offset>=i)return r(o[0]);if(i>=o[o.length-1].offset)return r(o[o.length-1]);for(let e=0;o.length-1>e;e++){const t=o[e],n=o[e+1];if(t.offset>i||i>n.offset)continue;const s=n.offset-t.offset,a=s>0?(i-t.offset)/s:0,c=od(t.color),l=od(n.color);if(!c||!l)return r(.5>a?t:n);const[u,d,h]=c,[f,p,y]=l,g=u+(f-u)*a,m=d+(p-d)*a,x=h+(y-h)*a,b=t.opacity+(n.opacity-t.opacity)*a;return 1===b?rd(g,m,x):`rgba(${Math.round(g)},${Math.round(m)},${Math.round(x)},${b})`}return r(o[o.length-1])}function sd(e,t,n){return null==n?`${e}-${t}`:`${e}-${t}-${n}`}var ad=require("react/jsx-runtime");function cd(e=240){const t=360-e,n=180+t/2,o=n*Math.PI/180;return{sweepRad:e*Math.PI/180,gapDeg:t,startAngleDeg:n,startAngleRad:o,offsetRad:-Math.PI/2+o}}require("react");var ld={RdBu:ne,PiYG:oe,PRGn:re,BrBG:ie,RdYlBu:se,RdYlGn:ae,Spectral:ce},ud="__likert_neutral_neg",dd="__likert_neutral_pos";function hd(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}var fd=y(require("react"));function pd(e){return Le(e)}function yd(e,t,n,o,r){const i=Ke(o.theme).colors.categorical,s=n??o.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?xe(l,c,s??i):void 0,d=gu("string"==typeof r.color?r.color:void 0,i,s,void 0,new Map),h=ke(r.valueAccessor),f=r.styleRules,p=o.pieceStyle;return(e,n)=>{const o={fill:t&&u?ge(e,t,u):d};return f?.length&&Object.assign(o,Pe(e,f,{value:h(e),category:n})),"function"==typeof p?Object.assign(o,p(e,n)||{}):p&&"object"==typeof p&&Object.assign(o,p),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 gd(e,t,n,o,r){const i=yd(e,t,n,o,r);return(e,t)=>{const n=i(e,t);return void 0===n.fillOpacity&&(n.fillOpacity=.8),void 0===n.stroke&&(n.stroke=n.fill),n}}function md(e,t,n,o,r){const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s="string"==typeof t?t:"__ssrViolinColorBy",a="function"==typeof t?i.map(e=>({...e,__ssrViolinColorBy:t(e)})):i,c=Ke(o.theme).colors.categorical,l=n??o.colorScheme,u=t?xe(a,s,l??c):void 0,d=gu("string"==typeof r.color?r.color:void 0,c,l,void 0,new Map);return e=>{const n=t&&u?ge(e,t,u):d;return{fill:n,fillOpacity:.6,stroke:r.stroke??n,...void 0!==r.strokeWidth&&{strokeWidth:r.strokeWidth},...void 0!==r.opacity&&{opacity:r.opacity}}}}function xd(e,t,n,o,r){const i=yd(e,t,n,o,r),s="number"==typeof r.dotRadius?r.dotRadius:5;return(e,t)=>({r:s,fillOpacity:.8,...i(e,t)})}function bd(e,t,n,o,r){const i=yd(e,t,n,o,r),s=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=r.sizeBy,c=Array.isArray(r.sizeRange)?r.sizeRange:[3,8],l=a?s.map(e=>"function"==typeof a?a(e):Number(e[a])).filter(Number.isFinite):[],u=l.length?ve(l):void 0,d="number"==typeof r.pointRadius?r.pointRadius:4,h="number"==typeof r.pointOpacity?r.pointOpacity:.7;return(e,t)=>({r:a?be(e,a,c,u):d,fillOpacity:h,...i(e,t)})}var vd={frameType:"ordinal",buildProps:(e,t,n,o,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:n,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...o,gradientFill:pd(o.gradientFill),pieceStyle:yd(e,t,n,o,r)})},wd={frameType:"ordinal",buildProps:(e,t,n,o,r)=>{const i=t||r.stackBy;return{chartType:"bar",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.stackBy,colorAccessor:i,colorScheme:n,projection:"horizontal"===r.orientation?"horizontal":"vertical",normalize:r.normalize,oSort:r.sort??!1,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...o,gradientFill:pd(o.gradientFill),pieceStyle:yd(e,i,n,o,r),showLegend:o.showLegend??!!i}}},kd={frameType:"ordinal",buildProps:(e,t,n,o,r)=>{const i=t||r.groupBy;return{chartType:"clusterbar",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",groupBy:r.groupBy,colorAccessor:i,colorScheme:n,projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:r.sort??!1,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...o,gradientFill:pd(o.gradientFill),pieceStyle:yd(e,i,n,o,r),showLegend:o.showLegend??!!i}}},Sd={frameType:"ordinal",buildProps:(e,t,n,o,r)=>{const i=t||r.categoryAccessor;return{chartType:"pie",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",colorAccessor:i,colorScheme:n,...null!=r.cornerRadius&&{cornerRadius:r.cornerRadius},...null!=r.startAngle&&{startAngle:r.startAngle},...o,pieceStyle:yd(e,i,n,o,r),showLegend:o.showLegend??!!i}}},Ad={frameType:"ordinal",layout:{primarySize:{width:400,height:400}},buildProps:(e,t,n,o,r)=>{const i=t||r.categoryAccessor;return{chartType:"donut",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",margin:o.margin??{top:50,right:40,bottom:60,left:70},innerRadius:r.innerRadius??60,colorAccessor:i,colorScheme:n,...null!=r.cornerRadius&&{cornerRadius:r.cornerRadius},...null!=r.startAngle&&{startAngle:r.startAngle},...o,pieceStyle:yd(e,i,n,o,r)}}},Md={frameType:"ordinal",buildProps:(e,t,n,o,r)=>{const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=r.valueAccessor||"value",a=i.map(e=>Number("function"==typeof s?s(e):e[s])).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:s,projection:"horizontal",bins:r.bins??25,normalize:r.relative??!1,colorAccessor:t,colorScheme:n,barPadding:r.categoryPadding??20,...r.valueExtent?{rExtent:r.valueExtent}:c?{rExtent:c}:{},...o,summaryStyle:gd(e,t,n,o,r)}}},_d={frameType:"ordinal",buildProps:(e,t,n,o,r)=>({chartType:"boxplot",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:t,colorScheme:n,...null!=r.showOutliers&&{showOutliers:r.showOutliers},...null!=r.outlierRadius&&{outlierRadius:r.outlierRadius},...o,summaryStyle:o.summaryStyle||gd(e,t,n,o,r)})},Pd={frameType:"ordinal",buildProps:(e,t,n,o,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:n,...o,summaryStyle:o.summaryStyle||md(e,t,n,o,r),showLegend:o.showLegend??!!t,...r.valueExtent&&{rExtent:r.valueExtent}})},jd={frameType:"ordinal",buildProps:(e,t,n,o,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:n,...o,sizeRange:r.sizeRange||[3,8],pieceStyle:o.pieceStyle||bd(e,t,n,o,r),showLegend:o.showLegend??!!t})},Rd={frameType:"ordinal",layout:{modeDefaults:{showGrid:!0}},buildProps:(e,t,n,o,r)=>({chartType:"point",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:t,colorScheme:n,projection:"vertical"===r.orientation?"vertical":"horizontal",oSort:r.sort??"auto",barPadding:r.categoryPadding??10,...o,pieceStyle:xd(e,t,n,o,r),showGrid:o.showGrid??!0,showLegend:o.showLegend??!!t})},Cd={frameType:"ordinal",buildProps:(e,t,n,o,r)=>{const i=t||r.subcategoryAccessor;return{chartType:"swimlane",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.subcategoryAccessor,colorAccessor:i,categoryAccessor:r.categoryAccessor,subcategoryAccessor:r.subcategoryAccessor,colorScheme:n,projection:"vertical"===r.orientation?"vertical":"horizontal",...null!=r.trackFill&&{trackFill:r.trackFill},...r.valueExtent&&{rExtent:r.valueExtent},...null!=r.roundedTop&&{roundedTop:r.roundedTop},...o,gradientFill:pd(o.gradientFill),pieceStyle:o.pieceStyle||yd(e,i,n,o,r),showLegend:o.showLegend??!!i,barPadding:r.barPadding??40}}},Ld={frameType:"ordinal",buildProps:(e,t,n,o,r)=>({chartType:"ridgeline",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:t,colorScheme:n,projection:"vertical"===r.orientation?"vertical":"horizontal",bins:r.bins??20,amplitude:r.amplitude??1.5,barPadding:r.categoryPadding??5,oSort:r.oSort??!1,...o,summaryStyle:o.summaryStyle||((i,s)=>({fillOpacity:.5,...yd(e,t,n,o,r)(i,s)})),showLegend:o.showLegend??!!t})},Id={frameType:"ordinal",layout:{margin:(e,t)=>({...t.marginDefaults,left:"vertical"===e.orientation?t.marginDefaults.left:Math.max(100,t.marginDefaults.left)})},buildProps:(e,t,n,o,r)=>{const i=Array.isArray(r.levels)&&r.levels.length>=2?r.levels:["Strongly disagree","Disagree","Neutral","Agree","Strongly agree"],s="vertical"!==r.orientation;let a=function(e,t,n,o,r,i){const s=new Map,a=new Set(t);for(const c of e){const e=n(c);s.has(e)||s.set(e,new Map);const l=s.get(e);if(o){const e=o(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 n=e-1;if(0>n||n>=t.length)continue;const r=t[n];l.set(r,(l.get(r)||0)+1)}else if(r&&i){const e=r(c),t=i(c);if(!a.has(e))continue;l.set(e,(l.get(e)||0)+(Number.isFinite(t)?t:0))}}const c=[];for(const[e,n]of s){let o=0;for(const e of t)o+=n.get(e)||0;if(0!==o)for(let r=0;t.length>r;r++){const i=t[r],s=n.get(i)||0;c.push({__likertCategory:e,__likertLevel:i,__likertLevelLabel:i,__likertCount:s,__likertPct:s/o*100,__likertLevelIndex:r})}}return c}(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],i,hd(r.categoryAccessor,"question"),r.levelAccessor?null:hd(r.valueAccessor,"score"),r.levelAccessor?hd(r.levelAccessor,"level"):null,r.levelAccessor?hd(r.countAccessor,"count"):null);s&&(a=function(e,t){const n=t.length,o=n%2!=0,r=Math.floor(n/2),i=new Map;for(const t of e){const e=i.get(t.__likertCategory)||[];e.push(t),i.set(t.__likertCategory,e)}const s=[];for(const[,e]of i){const t=new Map;let i,a;for(const n of e)n.__likertLevel===ud?i=n:n.__likertLevel===dd?a=n:t.set(n.__likertLevelIndex,n);o&&i&&s.push(i);for(let e=r-1;e>=0;e--){const n=t.get(e);n&&s.push(n)}o&&a&&s.push(a);for(let e=o?r+1:r;n>e;e++){const n=t.get(e);n&&s.push(n)}}return s}(function(e,t){const n=t.length,o=n%2!=0,r=Math.floor(n/2),i=[];for(const t of e){const e=t.__likertLevelIndex;if(o&&e===r){const e=t.__likertPct/2;i.push({...t,__likertLevel:ud,__likertPct:-e}),i.push({...t,__likertLevel:dd,__likertPct:e})}else i.push(r>e?{...t,__likertPct:-t.__likertPct}:t)}return i}(a,i),i));const c=Ke(o.theme).colors.diverging,l=Array.isArray(n)&&n.length>=i.length?n:function(e,t){if(0>=e)return[];if(t){const n=ld[t];if(n){if(1===e)return[n(.5)];const t=[];for(let o=0;e>o;o++)t.push(n(o/(e-1)));return t}}const n=["#da1e28","#ff8389","#ffb3b8"],o=["#a6c8ff","#4589ff","#0043ce"],r="#a8a8a8";if(1===e)return[r];const i=e%2!=0,s=Math.floor(e/2),a=[];for(let e=0;s>e;e++)a.push(n[Math.min(Math.floor(e*n.length/s),n.length-1)]);i&&a.push(r);for(let e=0;s>e;e++)a.push(o[Math.min(Math.floor(e*o.length/s),o.length-1)]);return a}(i.length,c),u=new Map(i.map((e,t)=>[e,l[t]||"#888"])),d=i.length%2&&u.get(i[Math.floor(i.length/2)])||"#888",h="function"==typeof r.valueFormat?r.valueFormat:e=>Math.abs(Number(e)).toFixed(0)+"%",f=mr(!1===o.showLegend?void 0:{legendGroups:[{label:"",items:i.map(e=>({label:e})),styleFn:e=>({fill:u.get(e.label)||"#888"})}]},o.legend);return{chartType:"bar",data:a,oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:s?"horizontal":"vertical",barPadding:r.barPadding,showGrid:o.showGrid,oLabel:r.categoryLabel,rLabel:r.valueLabel||(s?void 0:"Percentage"),rFormat:h,...r.categoryFormat&&{oFormat:r.categoryFormat},...r.valueExtent&&{rExtent:r.valueExtent},...o,pieceStyle:e=>{const t=e.__likertLevel||e.data?.__likertLevel;return{fill:t===ud||t===dd?d:u.get((e.__likertLevelLabel||e.data?.__likertLevelLabel||t)+"")||"#888"}},showLegend:o.showLegend??!0,legendPosition:o.legendPosition||"right",...f&&{legend:f},__legendIncludesAutomatic:!0}}},Td={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,n,o,r)=>{const i="vertical"===r.orientation,s=t||r.categoryAccessor;return{chartType:i?"bar-funnel":"funnel",data:e,oAccessor:r.stepAccessor||"step",rAccessor:r.valueAccessor||"value",colorAccessor:s,categoryAccessor:r.categoryAccessor,projection:i?"vertical":"horizontal",connectorAccessor:r.connectorAccessor,connectorStyle:r.connectorStyle,...!i&&null!=r.connectorOpacity&&{connectorOpacity:r.connectorOpacity},barPadding:i?40:0,colorScheme:n,...o,showAxes:i,showGrid:i,pieceStyle:yd(e,s,n,o,r),showLabels:r.showLabels??!0}}},$d={frameType:"ordinal",layout:{primarySize:{width:300,height:250}},renderOverlay:function(e,{theme:t}){const n=e.__gauge;if(!n)return null;const o=(n.startAngleDeg+(n.gMax===n.gMin?0:(Math.max(n.gMin,Math.min(n.gMax,n.value??n.gMin))-n.gMin)/(n.gMax-n.gMin))*n.sweep-90)*Math.PI/180,r=n.needleColor||t.colors.text,i=n.showScaleLabels?(n.thresholds||[]).filter(e=>e.value>n.gMin&&n.gMax>e.value):[];return(0,ad.jsxs)(ad.Fragment,{children:[n.showNeedle&&(0,ad.jsxs)(ad.Fragment,{children:[(0,ad.jsx)("line",{x1:n.centerX,y1:n.centerY,x2:n.centerX+n.needleLength*Math.cos(o),y2:n.centerY+n.needleLength*Math.sin(o),stroke:r,strokeWidth:2.5,strokeLinecap:"round"}),(0,ad.jsx)("circle",{cx:n.centerX,cy:n.centerY,r:4,fill:r})]}),null!=n.contextValue&&(0,ad.jsx)("text",{x:n.centerX,y:n.contextValueY,textAnchor:"middle",dominantBaseline:"middle",fontSize:n.valueFontSize,fontWeight:700,fill:r,children:n.contextValue}),i.map((e,o)=>{const r=(n.startAngleDeg+(n.gMax===n.gMin?0:(e.value-n.gMin)/(n.gMax-n.gMin))*n.sweep-90)*Math.PI/180,i=n.innerRadius-1,s=n.radius+1,a=n.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(0,ad.jsxs)("g",{children:[(0,ad.jsx)("line",{x1:n.centerX+Math.cos(r)*i,y1:n.centerY+Math.sin(r)*i,x2:n.centerX+Math.cos(r)*s,y2:n.centerY+Math.sin(r)*s,stroke:t.colors.border,strokeWidth:2,strokeLinecap:"round"}),(0,ad.jsx)("text",{x:n.centerX+Math.cos(r)*a,y:n.centerY+Math.sin(r)*a,textAnchor:l,dominantBaseline:u,fill:t.colors.textSecondary,fontSize:10,children:e.label||e.value+""})]},"gauge-label-"+o)})]})},buildProps:(e,t,n,o,r)=>{const i=r.min??0,s=r.max??100,a=r.sweep??240,c=r.arcWidth??.3,l=!1!==r.showNeedle,u=!1!==r.fillZones,{startAngleDeg:d}=cd(a),h=r.thresholds||[{value:s,color:r.color||"#4e79a7"}],f=Ie(o.gradientFill),p=function(e){const{min:t,max:n,value:o,thresholds:r,fillColor:i,backgroundColor:s,fillZones:a,showScaleLabels:c,gradientFill:l,gradientSteps:u=240}=e,d=n-t||1,h=(Math.max(t,Math.min(n,o))-t)/d;let f=r&&r.length>0?[...r].sort((e,t)=>e.value-t.value):[{value:n,color:i||"#007bff"}];f=f.map(e=>({...e,value:Math.max(t,Math.min(n,e.value))})),n>f[f.length-1].value&&f.push({value:n,color:f[f.length-1].color});const p=!!l&&l.stops.length>=2,y=[],g=new Map,m=[];if(p){const e=a?h:1,t=sd("bg",0);if(y.push({category:t,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),g.set(t,{fill:s,opacity:.4}),e>0){const t=Math.max(1,Math.floor(u)),n=Math.max(1,Math.min(t,Math.round(e*t))),o=[];for(let t=0;n>t;t++)o.push(id(l.stops,e*(t+.5)/n,i||f[0]?.color||"#007bff"));const r=sd("fill",0);y.push({category:r,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:o}}),g.set(r,{fill:o[0]||s})}}else{let e=t;for(let n=0;f.length>n;n++){const o=f[n],r=(o.value-e)/d,i=(e-t)/d,c=(o.value-t)/d,l=Math.max(0,(a?Math.min(h,c):c)-i),u=a?Math.max(0,r-l):0;if(l>0){const e=sd("fill",n);y.push({category:e,value:l,_zone:o.label||"Zone "+(n+1),_isFill:!0}),g.set(e,{fill:o.color})}if(u>0){const e=sd("bg",n);y.push({category:e,value:u,_zone:o.label||"Zone "+(n+1),_isFill:!1}),g.set(e,{fill:s,opacity:.4})}e=o.value}}if(c&&r&&r.length>0)for(const e of r)e.value>t&&n>e.value&&m.push({type:"gauge-label",value:e.value,label:e.label||e.value+""});return{gaugeData:y,pieceStyle:(e,t)=>g.get(t||e.category)||{fill:s},gaugeAnnotations:m}}({min:i,max:s,value:r.value,thresholds:h,fillColor:r.color,backgroundColor:r.backgroundColor||"#e0e0e0",fillZones:u,showScaleLabels:!1!==r.showScaleLabels,gradientFill:f}),[y,g]=o.size||[300,250],m=function(e=240){const{sweepRad:t,offsetRad:n}=cd(e),o=[[Math.cos(n),Math.sin(n)],[Math.cos(n+t),Math.sin(n+t)],[0,0]];for(let e=0;2*Math.PI>e;e+=Math.PI/2)((e-n)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)>t+.001||o.push([Math.cos(e),Math.sin(e)]);const r=o.map(e=>e[0]),i=o.map(e=>e[1]),[s,a]=ve(r),[c,l]=ve(i);return{minX:s,maxX:a,minY:c,maxY:l,width:a-s,height:l-c,cx:(s+a)/2,cy:(c+l)/2}}(a),x=Math.min(10,Math.max(1,Math.min(y,g)/12)),b=Math.max(4,Math.min((y-2*x)/m.width,(g-2*x)/m.height)-2),v=Math.max(0,Math.min(b-1.5,b*(1-c))),w=y/2-m.cx*b,k=g/2-m.cy*b,S=2*(b+4),A=Math.max(i,Math.min(s,r.value??i)),M="function"==typeof r.valueFormat?r.valueFormat(A):Math.round(A)+"",_=r.centerContent??o.centerContent,P=null!=_?"function"==typeof _?_(A,i,s):_:"sparkline"===r.mode||"context"===r.mode?void 0:fd.createElement("div",{style:{textAlign:"center",lineHeight:1.2}},fd.createElement("div",{style:{fontSize:Math.max(16,.3*b),fontWeight:700,color:"var(--semiotic-text, #333)"}},M),!1!==r.showScaleLabels&&fd.createElement("div",{style:{fontSize:11,color:"var(--semiotic-text-secondary, #666)"}},`${i} – ${s}`));return{chartType:"donut",data:p.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:v,sweepAngle:a,startAngle:d,oSort:!1,pieceStyle:p.pieceStyle,...null!=r.cornerRadius&&{cornerRadius:r.cornerRadius},...o,size:[y,g],margin:{top:k-S/2,bottom:g-k-S/2,left:w-S/2,right:y-w-S/2},...null!=P&&{centerContent:P},showAxes:!1,annotations:[...Array.isArray(o.annotations)?o.annotations:[],...p.gaugeAnnotations],__gauge:{gMin:i,gMax:s,sweep:a,arcWidth:c,value:A,startAngleDeg:d,thresholds:h,centerX:w,centerY:k,radius:b,innerRadius:v,showScaleLabels:!1!==r.showScaleLabels,needleLength:v>20?v-8:b-1,showNeedle:l,needleColor:r.needleColor,..."context"===r.mode&&null==_&&{contextValue:M,contextValueY:k-.2*v,valueFontSize:Math.max(12,Math.min(22,.28*b))}}}}},zd=require("d3-scale");function Ed(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 Od(e,t,n){const o=t.incoming[e.id],r=t.outgoing[e.id],i=[];for(const e of o)i.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:n.get(e.id).targetSide});for(const e of r)i.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:n.get(e.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{i.sort((e,t)=>e.time-t.time||(s[e.kind]??99)-(s[t.kind]??99))},c=i.length?function(e,t=1/0){let n=t;for(const t of e)n>t&&(n=t);return n}(i.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,d=[...new Set(i.map(e=>e.time))].sort((e,t)=>e-t),h=new Map;for(let e=1;d.length>e;e++)h.set(d[e],d[e-1]);const f=e=>{const t=h.get(e);return null!=t?(t+e)/2:null!=u?u:e};a();const p=[];let y=0,g=0;for(const e of i)if("out"===e.kind){const t=Math.abs(e.delta);let n=t-("top"===e.side?y:g);if(n>0){const t="top"===e.side?"bot":"top",o=Math.min(n,"top"===t?y:g);if(o>0){const r=f(e.time);p.push({time:r,delta:-o,kind:"transfer-out",side:t}),p.push({time:r,delta:+o,kind:"transfer-in",side:e.side}),"top"===t?y-=o:g-=o,"top"===e.side?y+=o:g+=o,n-=o}n>0&&null!==u&&(p.push({time:u,delta:+n,kind:"create",side:e.side}),"top"===e.side?y+=n:g+=n)}"top"===e.side?y-=t:g-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?y+=t:g+=t}i.push(...p),a();let m=0,x=0,b=0,v=0,w=0;const k=[],S=new Map;for(const e of i){if(k.push({t:e.time,topMass:m,botMass:x}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?m:x;S.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>v&&(v=m),x>w&&(w=x),k.push({t:e.time,topMass:m,botMass:x})}const A=[];let M=0;for(;k.length>M;){let e=M;for(;k.length>e+1&&k[e+1].t===k[M].t;)e++;A.push(k[M]);for(let t=M+1;e>=t;t++){const e=A[A.length-1];k[t].topMass===e.topMass&&k[t].botMass===e.botMass||A.push(k[t])}M=e+1}const _=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 j=null;for(const e of o)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===j||e.systemOutTime>j)&&(j=e.systemOutTime);if(A.length>0){const e=A[A.length-1],t=Math.max(null!=_?_:-1/0,null!=j?j:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&A.push({t:t,topMass:e.topMass,botMass:e.botMass});const n=A[0],o=Math.min(null!=l?l:1/0,null!=P?P:1/0);Number.isFinite(o)&&n.t>o&&n.topMass+n.botMass>0&&A.unshift({t:o,topMass:n.topMass,botMass:n.botMass})}return{samples:A,peak:b,topPeak:v,botPeak:w,localAttachments:S}}function Dd(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Bd(e,t){return e.map(e=>({t:Dd(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function Fd(e,t,n){const o=e.value*n;if("out"===e.kind){const r=e.sideMassBefore*n;if("top"===e.side){const e=t-r;return[e,e+o]}const i=t+r;return[i-o,i]}const r=e.sideMassAfter*n;if("top"===e.side){const e=t-r;return[e,e+o]}const i=t+r;return[i-o,i]}function Nd(e,t){let n=0;for(let o=0;t.length>o;o++)for(let r=o+1;t.length>r;r++){const i=t[o],s=t[r];i.source!==s.source&&i.target!==s.target&&i.source!==s.target&&i.target!==s.source&&(Math.min(i.endTime,s.endTime)>Math.max(i.startTime,s.startTime)&&e[s.source]>e[i.source]!=e[s.target]>e[i.target]&&n++)}return n}function Wd(e,t){let n=0;for(const o of t)n+=Math.abs(e[o.source]-e[o.target])*(o.value||1);return n}function qd(e,t){return 1e3*Nd(e,t)+Wd(e,t)}function Yd(e,t){return{slots:e.map(e=>({peak:{...e.peak},occupants:e.occupants.slice()})),map:{...t}}}function Gd(e,t,n){e.length>8||n.length>40?(function(e,t,n,o=6){const r=e.length;if(1>=r)return;let i=Yd(e,t),s=qd(t,n);for(let a=0;o>a;a++){const o=Array(r).fill(0),a=Array(r).fill(0);for(const e of n){const n=t[e.source],r=t[e.target];o[n]+=r*(e.value||1),a[n]+=e.value||1,o[r]+=n*(e.value||1),a[r]+=e.value||1}const c=Array.from({length:r},(e,t)=>t).sort((e,t)=>(a[e]>0?o[e]/a[e]:e)-(a[t]>0?o[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 d=qd(t,n);if(s>d)s=d,i=Yd(e,t);else if(d===s)break}!function(e,t,n){e.length=0;for(const t of n.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(n.map))t[e]=n.map[e]}(e,t,i)}(e,t,n,6),function(e,t,n,o=6){const r=e.length;if(1>=r)return;let i=qd(t,n);for(let s=0;o>s;s++){let o=!1;for(let s=0;r-1>s;s++){const r=e[s];e[s]=e[s+1],e[s+1]=r;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s);const a=qd(t,n);if(i>a)i=a,o=!0;else{const n=e[s];e[s]=e[s+1],e[s+1]=n;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s)}}if(!o)break}}(e,t,n,6)):function(e,t,n){const o=e.length;if(1>=o)return;const r={...t},i=Object.keys(r),s=Array.from({length:o},(e,t)=>t),a=s.slice(),c={...r};let l=s.slice(),u=1/0;const d=()=>{for(const e of i)c[e]=a[r[e]];const e=qd(c,n);u>e&&(u=e,l=s.slice())},h=(e,t)=>{const n=s[e],o=s[t];s[e]=o,s[t]=n,a[n]=t,a[o]=e};d();const f=Array(o).fill(0);let p=0;for(;o>p;)p>f[p]?(h(p%2==0?0:f[p],p),d(),f[p]++,p=0):(f[p]=0,p++);const y=l.map(t=>e[t]),g=new Map;l.forEach((e,t)=>g.set(e,t));for(const e of Object.keys(t))t[e]=g.get(t[e]);e.length=0;for(const t of y)e.push(t)}(e,t,n)}function Hd(e,t,n,o,r){const{plotH:i,padding:s,valueScale:a,packing:c,laneOrder:l,lifetimeMode:u="full"}=r,d={},h={};for(const t of e)d[t.id]=n[t.id].topPeak||0,h[t.id]=n[t.id].botPeak||0;const f="half"===u,p={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,n=Array.isArray(t.xExtent)?t.xExtent[1]:null;let r=null!=e&&Number.isFinite(e)?e:1/0,i=null!=n&&Number.isFinite(n)?n:-1/0;for(const e of o.outgoing[t.id]){r>e.startTime&&(r=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&r>e.systemInTime&&(r=e.systemInTime);const t=f?(e.startTime+e.endTime)/2:e.endTime;t>i&&(i=t)}for(const e of o.incoming[t.id]){const t=f?(e.startTime+e.endTime)/2:e.startTime;r>t&&(r=t),e.endTime>i&&(i=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>i&&(i=e.systemOutTime)}p[t.id]={start:Number.isFinite(r)?r:null,end:Number.isFinite(i)?i:null}}const y={},g=[];if("reuse"===c){const n=new Map;for(const t of e)n.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 i=[];for(const t of e)0===(r.get(t.id)??0)&&i.push(t.id);for(;i.length;){const e=i.shift();for(const t of o.outgoing[e]??[]){const o=(n.get(e)??0)+1;o>(n.get(t.target)??0)&&n.set(t.target,o),r.set(t.target,r.get(t.target)-1),0===r.get(t.target)&&i.push(t.target)}}const s=[...e].filter(e=>null!==p[e.id].start).sort((e,t)=>{const o=n.get(e.id)??0,r=n.get(t.id)??0;return o!==r?o-r:p[e.id].start-p[t.id].start}),a=e.filter(e=>null===p[e.id].start);for(const e of[...s,...a]){const t=p[e.id];let n=-1;for(let e=0;g.length>e;e++){const o=g[e].occupants[g[e].occupants.length-1];if(null===t.start||void 0===o||t.start>=o.end){n=e;break}}-1===n&&(g.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=g.length-1),g[n].occupants.push({id:e.id,end:t?.end??-1/0}),g[n].peak.topPeak=Math.max(g[n].peak.topPeak,d[e.id]),g[n].peak.botPeak=Math.max(g[n].peak.botPeak,h[e.id]),y[e.id]=n}}else e.forEach((e,t)=>{g.push({occupants:[{id:e.id,end:p[e.id]?.end??-1/0}],peak:{topPeak:d[e.id],botPeak:h[e.id]}}),y[e.id]=t});let m=null,x=null,b=null,v=null;const w=()=>{m=Nd(y,t),b=Wd(y,t)},k=()=>{x=Nd(y,t),v=Wd(y,t)};"crossing-min"===l?(w(),Gd(g,y,t),k()):"inside-out"===l?(w(),function(e,t){const n=e.length;if(1>=n)return;const o=e=>e.peak.topPeak+e.peak.botPeak,r=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>o(t.slot)-o(e.slot)),i=Array(n),s=Math.floor((n-1)/2);i[s]=r[0].idx;let a=s-1,c=s+1;for(let e=1;r.length>e;e++)e%2==1&&n>c||0>a?i[c++]=r[e].idx:i[a--]=r[e].idx;const l=i.map(t=>e[t]),u=new Map;i.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)}(g,y),k()):"crossing-min+inside-out"===l&&(w(),Gd(g,y,t),function(e,t,n){const o=e.length;if(1>=o)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),i=Math.floor((o-1)/2);let s=qd(t,n);for(const{slot:a}of r){const r=e.indexOf(a);if(0>r)continue;const c=i;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;o>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 d=qd(t,n);if(d>s){const n=e[c];e.splice(c,1),e.splice(r,0,n);const i=new Map;for(let e=0;o>e;e++)i.set(e,e);if(r>c){for(let e=c+1;r>=e;e++)i.set(e,e-1);i.set(c,r)}else{for(let e=r;c>e;e++)i.set(e,e+1);i.set(c,r)}for(const e of Object.keys(t))t[e]=i.get(t[e])}else s=d}}(g,y,t),k());const S=g.map(e=>{const t=new Map;for(const o of e.occupants){const e=n[o.id];if(e)for(const n of e.samples){const e=t.get(n.t)||{top:0,bot:0};t.set(n.t,{top:Math.max(e.top,n.topMass),bot:Math.max(e.bot,n.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),A=(e,t)=>{let n={top:0,bot:0};for(const[o,r]of e){if(o>t)break;n=r}return n},M=[];for(let e=0;g.length-1>e;e++){const t=S[e],n=S[e+1],o=new Set([...t.map(e=>e[0]),...n.map(e=>e[0])]);let r=0;for(const e of o){const o=A(t,e),i=A(n,e);o.bot+i.top>r&&(r=o.bot+i.top)}M.push(r)}const _=[];let P=s+(g[0]?.peak.topPeak??0)*a;g.length>0&&_.push(P);for(let e=1;g.length>e;e++)P+=M[e-1]*a+s,_.push(P);if(g.length>0&&(P+=g[g.length-1].peak.botPeak*a+s),P>i){const e=i/P;for(let t=0;_.length>t;t++)_[t]*=e}const j=0===g.length?0:g[0].peak.topPeak+M.reduce((e,t)=>e+t,0)+g[g.length-1].peak.botPeak,R={};for(const t of e)R[t.id]=_[y[t.id]];return{effectiveSlotsHeight:j,centerlines:R,laneLifetime:p,slots:g,slotByNode:y,slotCenter:_,crossingsBefore:m,crossingsAfter:x,lengthBefore:b,lengthAfter:v}}function Vd(e){const{sx:t,sTop:n,sBot:o,tx:r,tTop:i,tBot:s,cp1X:a,cp2X:c}=e,l=(n+o)/2,u=(i+s)/2;return{pathD:[`M${t},${n}`,`C${a},${n} ${c},${i} ${r},${i}`,`L${r},${s}`,`C${c},${s} ${a},${o} ${t},${o}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:l},{x:a,y:l},{x:c,y:u},{x:r,y:u}],halfWidth:(o-n)/2}}}function Xd(e){const{nodes:t,edges:n,domain:o,plotW:r,plotH:i,ribbonLane:s,edgeOpacity:a,colorOf:c,layoutOpts:l}=e,u=function(e,t,n){const o=[],r=new Set(e.map(e=>e.id)),i=Array.isArray(n)&&2===n.length,s=i&&Number.isFinite(n[0])&&Number.isFinite(n[1]);i&&s&&s&&n[1]>=n[0]||o.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]||o.push({kind:"invalid-node-time",id:t.id}));for(const e of t)r.has(e.source)||o.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),r.has(e.target)||o.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||o.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||o.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):o.push({kind:"invalid-edge-time",id:e.id});return o}(t,n,o),d=(0,zd.scaleTime)().domain(o).range([0,r]);if(u.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:u,xScale:d};const h=function(e,t,n){const{plotH:o,pairing:r="temporal",packing:i="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half"}=n,c=function(e,t){const n={},o={};for(const t of e)n[t.id]=[],o[t.id]=[];for(const e of t)o[e.source]&&o[e.source].push(e),n[e.target]&&n[e.target].push(e);return{incoming:n,outgoing:o}}(e,t),l=function(e,t,n,o="value"){const r="temporal"===o?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,i="temporal"===o?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,s=new Map;for(const e of t)s.set(e.id,{});const a=(e,t)=>{const n=new Map;for(const o of e){const e=o[t];n.has(e)||n.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const r=n.get(e);r.edges.push(o),r.total+=o.value,r.earliestStart=Math.min(r.earliestStart,o.startTime),r.latestEnd=Math.max(r.latestEnd,o.endTime)}const s=[...n.values()];s.sort("temporal"===o?(e,n)=>"target"===t?e.earliestStart-n.earliestStart:e.latestEnd-n.latestEnd:(e,t)=>t.total-e.total);for(const e of s)e.edges.sort("target"===t?i:r);return s};for(const t of e){const e=n.outgoing[t.id],o=n.incoming[t.id];if(0===o.length)a(e,"target").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).sourceSide=n});else if(0===e.length)a(o,"source").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).targetSide=n});else{const t=a(o,"source"),n=a(e,"target"),r=Math.max(t.length,n.length);for(let e=0;r>e;e++){const o=e%2==0?"top":"bot";if(t[e])for(const n of t[e].edges)s.get(n.id).targetSide=o;if(n[e])for(const t of n[e].edges)s.get(t.id).sourceSide=o}}}return s}(e,t,c,r);let u={};for(const t of e)u[t.id]=Od(t,c,l);const d=Hd(e,t,u,c,{plotH:o,padding:12,valueScale:1,packing:i,laneOrder:s,lifetimeMode:a}),h=new Set;for(const e of t){const t=d.slotByNode[e.source],n=d.slotByNode[e.target];if(void 0===t||void 0===n)continue;const o=l.get(e.id);t!==n?t>n?(o.sourceSide="top",o.targetSide="bot"):(o.sourceSide="bot",o.targetSide="top"):(h.add(e.id),o.sourceSide="bot",o.targetSide="bot")}for(const t of e){const e=c.outgoing[t.id],n=c.incoming[t.id],o=new Set(e.map(e=>l.get(e.id).sourceSide)),r=new Set(n.map(e=>l.get(e.id).targetSide));if(1===o.size&&n.length>0){const e=[...o][0];for(const t of n)d.slotByNode[t.source]===d.slotByNode[t.target]&&(l.get(t.id).targetSide=e)}if(1===r.size&&e.length>0){const t=[...r][0];for(const n of e)d.slotByNode[n.source]===d.slotByNode[n.target]&&(l.get(n.id).sourceSide=t)}}for(const t of e){const e=c.incoming[t.id],n=c.outgoing[t.id];if(0===e.length||0===n.length)continue;const o=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of e)"top"===l.get(n.id).targetSide?t.inTop+=n.value:t.inBot+=n.value;for(const e of n)"top"===l.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},r=(e,t)=>{const r=o(),i="top"===e?r.outTop-r.inTop:r.outBot-r.inBot,s="top"===t?r.inTop-r.outTop:r.inBot-r.outBot;if(0>=i||0>=s)return!1;const a=Math.min(i,s),c=n.filter(t=>!h.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 i=n.length+1;for(;i-- >0&&(r("top","bot")||r("bot","top")););}u={};for(const t of e)u[t.id]=Od(t,c,l);const f=Hd(e,t,u,c,{plotH:o,padding:12,valueScale:1,packing:i,laneOrder:s,lifetimeMode:a}),p=f.effectiveSlotsHeight??f.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),y=Math.min(12,.35*o/Math.max(f.slots.length+1,1)),g=p>0?Math.max(0,(o-y*(f.slots.length+1))/p):1,m=Hd(e,t,u,c,{plotH:o,padding:y,valueScale:g,packing:i,laneOrder:s,lifetimeMode:a});return{nodeData:u,sides:l,valueScale:g,padding:y,compressedPadding:12>y,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,n,{plotH:i,...l}),{centerlines:f,nodeData:p,valueScale:y}=h,g=[],m=[];t.forEach((e,t)=>{const r=p[e.id];if(!r||0===r.samples.length)return;const i=function(e,t,n,o,r){if(0===e.length)return null;const i=Bd(e,r),s=e=>t-i[e].topMass*n,a=e=>t+i[e].botMass*n;let c=`M${o(i[0].t)},${s(0)}`;for(let e=1;i.length>e;e++)c+=` L${o(i[e].t)},${s(e)}`;c+=` L${o(i[i.length-1].t)},${a(i.length-1)}`;for(let e=i.length-2;e>=0;e--)c+=` L${o(i[e].t)},${a(e)}`;return c+" Z"}(r.samples,f[e.id],y,d,o);if(!i)return;const s=Bd(r.samples,o),a=s.find(e=>e.topMass+e.botMass>0)||s[0],l=f[e.id]+(a.botMass-a.topMass)*y/2,u=c(e.id,t),m=function(e,t,n,o,r){const i=n.nodeData[e];if(!i||0===i.samples.length)return[];const s=n.valueScale,a=n.centerlines[e],c=Bd(i.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],d=o(l.t),h=o(u.t),f=e=>o(Dd(e,r)),p=[],y=(e,t,n,o)=>`M${e},${t} L${n},${t} L${n},${o} L${e},${o} Z`;for(const n of t){if(n.source===e&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const e=i.localAttachments.get(n.id);if(e&&"out"===e.kind&&n.startTime>n.systemInTime){const t=f(n.systemInTime),o=f(n.startTime),r=t-20,i=Math.max(d,r);if(o>i){const[n,c]=Fd(e,a,s);p.push({pathD:y(i,n,o,c),x0:r,x1:t,from:0,to:1})}}}if(n.target===e&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const e=i.localAttachments.get(n.id);if(e&&"in"===e.kind&&n.systemOutTime>n.endTime){const t=f(n.systemOutTime),o=f(n.endTime),r=t+20,i=Math.min(h,r);if(i>o){const[n,c]=Fd(e,a,s);p.push({pathD:y(o,n,i,c),x0:t,x1:r,from:1,to:0})}}}}return p}(e.id,n,h,d,o);g.push({id:e.id,pathD:i,fill:u,stroke:u,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)),n.forEach(e=>{const t=p[e.source]?.localAttachments.get(e.id),n=p[e.target]?.localAttachments.get(e.id);if(!t||!n)return;const r=x.get(e.source)??0,i=c(e.source,r),l=function(e,t,n,o,r,i,s,a){const c=r,l=e=>a?Math.max(a[0],Math.min(a[1],e)):e,u=i(l(e.time)),d=i(l(n.time)),h=e.value*c,f=n.value*c,p=e.sideMassBefore*c,y=n.sideMassAfter*c;let g,m,x,b;"top"===e.side?(g=t-p,m=g+h):(m=t+p,g=m-h),"top"===n.side?(x=o-y,b=x+f):(b=o+y,x=b-f);const v="source"===s?u+.85*(d-u):"target"===s?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:g,sBot:m,tx:d,tTop:x,tBot:b,cp1X:v,cp2X:v}}(t,f[e.source],n,f[e.target],y,d,s,o),{pathD:u,bezier:h}=Vd(l);m.push({id:e.id,pathD:u,fill:i,opacity:a,rawDatum:e.__raw??e,bezier:h})}),{layout:h,layoutConfig:{bands:g,ribbons:m,showLabels:!0},issues:[],xScale:d}}var Ud=e=>{const{bands:t=[],ribbons:n=[],showLabels:o=!0}=e.config,r=[];for(const e of n)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 n=e.gradientStubs[t];r.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.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 i=o?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:i}};function Kd(e,t){if(!e)return[];const n=[],o=e=>{n.push(e);const r="function"==typeof t?t(e):e[t];r&&Array.isArray(r)&&r.forEach(o)};return o(e),n}function Zd(e,t,n,o){if(e&&e.length>0)return e;const r=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof o?o(e):e[o];r.add(t),r.add(i)}),Array.from(r).map(e=>({id:e}))}var Qd=y(require("react"));function Jd(e,t){return t?"function"==typeof t?n=>({...e(n),...t(n)??{}}):n=>({...e(n),...t}):e}var eh={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,n,o,r)=>{const{edgeWidth:i,edgeColor:s,edgeOpacity:a}=r,c=r.edgeStyle??(void 0!==i||void 0!==s||void 0!==a?e=>{const t=e?.data||e;let n=1;if("number"==typeof i)n=i;else if("function"==typeof i)n=i(t);else if("string"==typeof i){const e=t?.[i],o="number"==typeof e?e:Number(e);n=Number.isFinite(o)&&o>0?o:1}return{stroke:s??"#999",strokeWidth:n,opacity:a??.6}}:void 0),l=Ke(o.theme).colors.categorical,u=new Map,d=r.nodeStyle??(e=>({fill:t?ge(e?.data||e,t,void 0):gu(void 0,l,n,void 0,u),..."number"==typeof r.nodeSize&&{r:r.nodeSize}})),h=Re(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:n,iterations:r.iterations,forceStrength:r.forceStrength,showLabels:r.showLabels??!1,nodeLabel:r.nodeLabel,nodeSize:r.nodeSize??8,nodeSizeRange:r.nodeSizeRange,nodeStyle:h?(e,t)=>({...d(e),...h(e,t)}):d,edgeStyle:c,...o}}},th={frameType:"network",layout:{margin:{top:30,right:80,bottom:40,left:80}},buildProps:(e,t,n,o,r)=>{const i=e=>null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime(),s=r.sourceAccessor||"source",a=r.targetAccessor||"target",c=r.valueAccessor||"value",l=r.nodeIdAccessor||"id",u=r.startTimeAccessor||"startTime",d=r.endTimeAccessor||"endTime",h=r.systemInTimeAccessor,f=r.systemOutTimeAccessor,p=r.xExtentAccessor||"xExtent",y=r.edgeIdAccessor||"id",g=(e,t)=>"function"==typeof e?e(t):t[e],m=Array.isArray(r.edges)?r.edges:[],x=Array.isArray(r.nodes)?r.nodes:[],b=x.length>0?x:Zd([],m,s,a),v=[i(r.domain?.[0]),i(r.domain?.[1])],w=b.map(e=>{const t=g(l,e)+"",n=g(p,e),o={id:t,__raw:e};if(Array.isArray(n)&&2===n.length){const e=i(n[0]),t=i(n[1]);Number.isFinite(e)&&Number.isFinite(t)&&(o.xExtent=[e,t])}return o}),k=m.map((e,t)=>{const n=g(y,e),o={id:null!=n?n+"":`${g(s,e)}-${g(a,e)}-${t}`,source:g(s,e)+"",target:g(a,e)+"",value:Number(g(c,e)),startTime:i(g(u,e)),endTime:i(g(d,e)),__raw:e};if(h){const t=i(g(h,e));Number.isFinite(t)&&(o.systemInTime=t)}if(f){const t=i(g(f,e));Number.isFinite(t)&&(o.systemOutTime=t)}return o}),[S,A]=o.size??[600,400],M={top:20,right:20,bottom:20,left:20,...o.margin},_=(o.showLegend??!!t)&&!!t,P=o.legendPosition??"right",j=o.__explicitMargin,R=e=>"number"==typeof j||null!=j&&"object"==typeof j&&null!=j[e];_&&("right"!==P||R("right")?"bottom"!==P||R("bottom")||(M.bottom=Math.max(M.bottom,80)):M.right=Math.max(M.right,140));const C=M,L=S-C.left-C.right,I=A-C.top-C.bottom,T=he(n,Ke(o.theme).colors.categorical,N),$="function"==typeof t?t:null,z=$?b.map(e=>({_cat:$(e)})):b,E=$?"_cat":"string"==typeof t?t:void 0,O=n??[...T],D=E?xe(z,E,O):null,B=new Map;for(const e of w)B.set(e.id,e.__raw);const F=(e,n)=>{if(t&&B.has(e)){const n=B.get(e);return $?ge({_cat:$(n)},"_cat",D??void 0):ge(n,"string"==typeof t?t:"id",D??void 0)}return T[n%T.length]},W=mr(_&&t?(()=>{const e=new Map;b.forEach((n,o)=>{const r=g(t,n),i=null==r?"":r+"";i&&!e.has(i)&&e.set(i,{label:i,color:F(g(l,n)+"",o)})});const n=Array.from(e.values());return n.length>0?{legendGroups:[{type:"fill",label:"",items:n,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0})():void 0,o.legend),{layout:q,layoutConfig:Y,issues:G,xScale:H}=Xd({nodes:w,edges:k,domain:v,plotW:L,plotH:I,ribbonLane:r.ribbonLane||"both",edgeOpacity:"number"==typeof r.edgeOpacity?r.edgeOpacity:.35,colorOf:F,layoutOpts:{pairing:r.pairing||"temporal",packing:r.packing||"reuse",laneOrder:r.laneOrder||"crossing-min",lifetimeMode:r.lifetimeMode||"half"}});if(G.length>0){const e=G.map(Ed).join("; ");throw Error("ProcessSankey: data invalid — "+e)}const V=Array.isArray(r.axisTicks)?r.axisTicks:[],X=q?(()=>{let e=null,t=null;for(const n of w){const o=q.laneLifetime[n.id];if(!o||null==o.start||null==o.end)continue;const r=Number(H(o.start)),i=Number(H(o.end));e=null==e?r:Math.min(e,r),t=null==t?i:Math.max(t,i)}const n=e=>Math.max(0,Math.min(L,e)),o=n(e??0),s=Math.max(o,n(t??L)),a=V.map((e,t)=>({tick:e,index:t,x:Number(H(i(e.date)))})).filter(({x:e})=>e>=o-.5&&s+.5>=e);return Qd.createElement("g",null,...a.map(({index:e,x:t})=>Qd.createElement("line",{key:"grid-"+e,x1:t,y1:0,x2:t,y2:I,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"})),Qd.createElement("line",{key:"axis",x1:o,y1:I+4,x2:s,y2:I+4,stroke:"#94a3b8"}),...a.map(({tick:e,index:t,x:n})=>{const o=i(e.date),s=null!=e.label?e.label:"function"==typeof r.timeFormat?r.timeFormat(new Date(o)):"";return Qd.createElement("g",{key:"tick-"+t,transform:`translate(${n},${I+4})`},Qd.createElement("line",{y2:6,stroke:"#94a3b8"}),Qd.createElement("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569"},s))}))})():void 0;return{chartType:"force",nodes:b,edges:m,customNetworkLayout:Ud,layoutConfig:Y,sourceAccessor:s,targetAccessor:a,valueAccessor:c,nodeIDAccessor:l,colorBy:t,colorScheme:n,...X&&{backgroundGraphics:X},...o,showLegend:_,...W&&{legend:W,legendPosition:P},__legendIncludesAutomatic:!0,margin:C}}},nh={frameType:"network",layout:{primarySize:{width:800,height:600}},buildProps:(e,t,n,o,r)=>{const i=Array.isArray(r.nodes)?r.nodes:Zd([],Array.isArray(r.edges)?r.edges:[],r.sourceAccessor||"source",r.targetAccessor||"target"),s=Ke(o.theme).colors.categorical,a=new Map,c="string"==typeof t?t:"__ssrSankeyColorBy",l="function"==typeof t?i.map(e=>({...e,__ssrSankeyColorBy:t(e)})):i,u=t?xe(l,c,n??o.colorScheme??s):void 0,d=e=>({fill:t?ge(e?.data||e,t,u):gu(void 0,s,n,void 0,a),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}),h=Re(r.styleRules,t,r.valueAccessor),f=h?(e,t)=>({...d(e),...h(e,t)}):d,p=function({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:o,edgeOpacity:r,baseStyle:i={}}){return s=>{const a={fillOpacity:r,...i};if("function"==typeof e)a.fill=e(s);else if("source"===e){const e="object"==typeof s.source?s.source:null;t&&e?a.fill=ge(e.data||e,t,n):e&&(a.fill=o(e,e.index).fill)}else if("target"===e){const e="object"==typeof s.target?s.target:null;t&&e?a.fill=ge(e.data||e,t,n):e&&(a.fill=o(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:f,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:o.nodeStyle||r.nodeStyle||f,edgeStyle:o.edgeStyle||r.edgeStyle||p,colorScheme:n,...o}}},oh={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,n,o,r)=>{if(!(t||Array.isArray(r.styleRules)&&r.styleRules.length>0||o.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:n,...o};const i=Array.isArray(r.edges)?r.edges:[],s=Array.isArray(r.nodes)&&r.nodes.length>0?r.nodes:Zd([],i,r.sourceAccessor||"source",r.targetAccessor||"target"),a=Ke(o.theme).colors.categorical,c=he(n,a),l="string"==typeof t?t:"__ssrChordColorBy",u="function"==typeof t?s.map(e=>({...e,__ssrChordColorBy:t(e)})):s,d=t?xe(u,l,n??o.colorScheme??a):void 0,h=new Map,f=r.nodeIdAccessor||r.nodeIDAccessor||"id",p=(e,n)=>{const r=e?.data||e;let i;if(t)i=ge(r,t,d);else{const t=(e.id??r?.[f]??"")+"";h.has(t)||h.set(t,h.size);const o=e.index??n??h.get(t);i=c[o%c.length]}return{fill:i,stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}},y=Re(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:n,nodeStyle:o.nodeStyle||r.nodeStyle||y,...o}}},rh={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,n,o,r)=>{const i=Ke(o.theme).colors.categorical,s=new Map,a=Kd(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,d=t&&u?xe(l,u,n??o.colorScheme??i):void 0,h=o.nodeStyle||r.nodeStyle;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:n,...o,nodeStyle:Jd(e=>{const a=e?.data||e;return{fill:r.colorByDepth?pe[Number(e?.depth||0)%pe.length]:t?c?ge({__ssrTreeColorBy:c(a)},"__ssrTreeColorBy",d??void 0):ge(a,t,d??void 0):gu(void 0,i,n,void 0,s),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}},h)}}},ih={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,n,o,r)=>{const i=Ke(o.theme).colors.categorical,s=new Map,a=Kd(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,d=t&&u?xe(l,u,n??o.colorScheme??i):void 0,h=r.showLabels??o.showLabels,f=r.labelMode,p=void 0!==r.paddingTop?r.paddingTop:o.paddingTop,y=void 0!==p?p:!h||"parent"!==f&&"all"!==f?void 0:18,g=o.nodeStyle||r.nodeStyle;return{chartType:"treemap",data:e,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:t,colorByDepth:r.colorByDepth,showLabels:r.showLabels,labelMode:f,nodeLabel:h?r.nodeLabel||r.nodeIdAccessor:void 0,...null!=r.padding&&{padding:r.padding},...null!=y&&{paddingTop:y},colorScheme:n,...o,nodeStyle:Jd(e=>{const o=e?.data||e;return{fill:r.colorByDepth?pe[Number(e?.depth||0)%pe.length]:t?c?ge({__ssrTreemapColorBy:c(o)},"__ssrTreemapColorBy",d??void 0):ge(o,t,d??void 0):gu(void 0,i,n,void 0,s),stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8}},g)}}},sh={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,n,o,r)=>{const i=Ke(o.theme).colors.categorical,s=new Map,a=Kd(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,d=t&&u?xe(l,u,n??o.colorScheme??i):void 0,h=o.nodeStyle||r.nodeStyle;return{chartType:"circlepack",data:e,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:t,colorByDepth:r.colorByDepth,showLabels:r.showLabels,nodeLabel:r.showLabels??o.showLabels?r.nodeLabel||r.nodeIdAccessor:void 0,...null!=r.padding&&{padding:r.padding},colorScheme:n,...o,nodeStyle:Jd(e=>{const o=e?.data||e;return{fill:r.colorByDepth?pe[Number(e?.depth||0)%pe.length]:t?c?ge({__ssrCirclePackColorBy:c(o)},"__ssrCirclePackColorBy",d??void 0):ge(o,t,d??void 0):gu(void 0,i,n,void 0,s),fillOpacity:r.circleOpacity??.7,stroke:"currentColor",strokeWidth:1,strokeOpacity:.3}},h)}}},ah={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},ch=require("d3-scale");function lh(e){return e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e}var uh={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,n,o,r)=>{const i="string"==typeof n?n:"blues",s=r.areaStyle??function(e,t,n,o){if(!Array.isArray(e))return;const r=e=>"function"==typeof t?t(e):null!=t?e?.properties?.[t]??e?.[t]:void 0;let i=1/0,s=-1/0;for(const t of e){const e=r(t);null!=e&&isFinite(e)&&(i>e&&(i=e),e>s&&(s=e))}const a=(0,ch.scaleSequential)(te(n)).domain([Number.isFinite(i)?i:0,Number.isFinite(s)?s:1]);return e=>{const t=r(e);return{fill:null!=t&&isFinite(t)?a(t):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:o}}}(r.areas,r.valueAccessor,i,r.areaOpacity??1),a=r.styleRules?je(s,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},lh):s;return{areas:r.areas,projection:r.projection||"equalEarth",areaStyle:a,valueAccessor:r.valueAccessor,colorScheme:i,graticule:r.graticule,fitPadding:r.fitPadding,...o}}},dh={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,n,o,r)=>{const i=e||r.points,s=r.pointStyle??function(e,t,n,o){const r=Array.isArray(e)?e:[];let i,s;if(t){const e="string"==typeof t?t:"__geoColorBy",o="string"==typeof t?r:r.map(e=>({...e,__geoColorBy:t(e)}));i=xe(o,e,n)}if(o.sizeBy){const e=r.map("function"==typeof o.sizeBy?o.sizeBy:e=>e?.[o.sizeBy]).filter(e=>null!=e&&isFinite(e));e.length>0&&(s=ve(e))}return e=>({fill:t&&i?ge(e,t,i):de,fillOpacity:o.fillOpacity,stroke:"#fff",strokeWidth:o.strokeWidth,r:o.sizeBy?be(e,o.sizeBy,o.sizeRange,s):o.pointRadius??6})}(i,t,n,{sizeBy:r.sizeBy,sizeRange:r.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),a=r.styleRules?je(s,r.styleRules,Ae(t,r.sizeBy)):s;return{points:i,xAccessor:r.xAccessor||"lon",yAccessor:r.yAccessor||"lat",areas:r.areas,areaStyle:r.areaStyle||ah,pointStyle:a,sizeBy:r.sizeBy,colorBy:t,colorScheme:n,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,...o}}},hh={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,n,o,r)=>{const i=(Array.isArray(e)?e:null)||r.flows||[],s=r.nodeIdAccessor||"id",a=r.valueAccessor||"value",c=r.xAccessor||"lon",l=r.yAccessor||"lat",u="function"==typeof c?c:e=>e[c],d="function"==typeof l?l:e=>e[l],h=(r.nodes||[]).map(e=>({...e,x:u(e),y:d(e)})),f=new Map;for(const e of h)f.set(e[s]+"",e);const p=r.edgeColorBy??t,y="function"==typeof p,g=i.map(e=>{if(!e||null==e.source||null==e.target)return null;const t=f.get(e.source+""),n=f.get(e.target+"");return t&&n?{...e,coordinates:[{x:t.x,y:t.y},{x:n.x,y:n.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=p?y?xe(g.map(e=>({[m]:p(e)})),m,n||"category10"):xe(g,p,n||"category10"):null,b=e=>p&&x?ge(e,p,x):"#007bff";let v=1/0,w=-1/0;for(const e of g){const t=Number(e[a]??0);isFinite(t)&&(v>t&&(v=t),t>w&&(w=t))}const k=w>v?w-v:0,[S,A]=r.edgeWidthRange??[1,8],M=A-S,_=r.edgeOpacity??.6,P=r.edgeLinecap??"round";return{lines:g,points:h,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:r.lineType||"geo",flowStyle:r.flowStyle||"basic",areas:r.areas,areaStyle:r.areaStyle||ah,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,colorScheme:n,lineStyle:e=>{const t=Number(e?.[a]),n=Number.isFinite(t)?t:v,o=S+Math.max(0,Math.min(1,k>0?(n-v)/k:0))*M;return{stroke:b(e),strokeWidth:o,strokeLinecap:P,opacity:_,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...o}}},fh=y(require("react"));function ph(e){const[t,n]=e,o=160>t||116>n,r=o?Math.min(12,Math.max(2,.08*t)):32,i=o?Math.min(8,Math.max(2,.12*n)):24,s=o?i:34;return{width:t,height:n,plot:{x:r,y:i,width:Math.max(1,t-2*r),height:Math.max(1,n-i-s)}}}function yh(e){const t=(e??"")+"";if(!t)return"#4e79a7";const n=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let o=0;for(let e=0;t.length>e;e+=1)o=31*o+t.charCodeAt(e)>>>0;return n[o%n.length]}function gh(e,t="#4e79a7",n){const o=n?.styleRules,r=!!o&&o.length>0,i=r?ke(n?.valueAccessor):void 0;return n=>{const s=n.datum,a=s&&e?"function"==typeof e?e(s,0):s[e]:void 0,c={fill:null==a?t:yh(a),stroke:"#111827",strokeWidth:1,opacity:.9};return r&&s&&Object.assign(c,Pe(s,o,{value:i?i(s):void 0,category:null==a?void 0:a+""})),c}}function mh(e,t,n,o){return{fixedDt:1/120,maxSubsteps:8,colliders:t,observation:{chartType:n},kernel:{seed:e,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...o}}}function xh(e,t,n){return"function"==typeof n?n(e,t):e[n]}function bh(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:null}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function vh(e,t,n){return Math.max(t,Math.min(n,e))}function wh(e,t){const n=bh(e);return null!=n&&n>0?n:t}function kh(e){return((e??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function Sh(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}var Ah=require("d3-scale");function Mh(e){let t=e>>>0;return function(){t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}var _h={seed:1,gravity:{x:0,y:980},fixedDt:1/120,cellSize:64,collisionIterations:6,velocityDamping:.995,sleepSpeed:8,sleepAfter:.35,restitution:.1,friction:.35,maxVelocity:1600,contactWakeSpeed:200},Ph=1e-9,jh=.005;function Rh(e){return"circle"===e.type?{type:"circle",radius:e.radius}:{type:"aabb",width:e.width,height:e.height}}function Ch(e){return"aabb"===e.type?{type:"aabb",x:e.x,y:e.y,width:e.width,height:e.height}:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:e.thickness}}function Lh(e,t,n){return Math.max(t,Math.min(n,e))}function Ih(e){return 0>e?-1:1}function Th(e){if("circle"===e.shape.type){const t=e.shape.radius;return{minX:e.x-t,minY:e.y-t,maxX:e.x+t,maxY:e.y+t}}const t=e.shape.width/2,n=e.shape.height/2;return{minX:e.x-t,minY:e.y-n,maxX:e.x+t,maxY:e.y+n}}function $h(e){const t=e.shape;if("aabb"===t.type){const e=t.width/2,n=t.height/2;return{minX:t.x-e,minY:t.y-n,maxX:t.x+e,maxY:t.y+n}}const n=(t.thickness??0)/2;return{minX:Math.min(t.x1,t.x2)-n,minY:Math.min(t.y1,t.y2)-n,maxX:Math.max(t.x1,t.x2)+n,maxY:Math.max(t.y1,t.y2)+n}}function zh(e,t){return!(e.minX>t.maxX||t.minX>e.maxX||e.minY>t.maxY||t.minY>e.maxY)}function Eh(e,t,n,o,r,i,s,a){const c=r-e,l=(n+s)/2-Math.abs(c);if(0>=l)return null;const u=i-t,d=(o+a)/2-Math.abs(u);return d>0?d>l?{nx:Ih(c),ny:0,penetration:l}:{nx:0,ny:Ih(u),penetration:d}:null}function Oh(e,t,n,o,r,i,s){const a=i/2,c=s/2;let l=e-Lh(e,o-a,o+a),u=t-Lh(t,r-c,r+c);const d=l*l+u*u;if(d>n*n)return null;if(Ph>=d){const i=Math.abs(e-(o-a)),s=Math.abs(e-(o+a)),d=Math.abs(t-(r-c)),h=Math.abs(t-(r+c)),f=Math.min(i,s,d,h);return f===i?(l=-1,u=0,{nx:l,ny:u,penetration:n+i}):f===s?(l=1,u=0,{nx:l,ny:u,penetration:n+s}):f===d?(l=0,u=-1,{nx:l,ny:u,penetration:n+d}):(l=0,u=1,{nx:l,ny:u,penetration:n+h})}const h=Math.sqrt(d);return{nx:l/h,ny:u/h,penetration:n-h}}function Dh(e,t){if("circle"===e.shape.type&&"circle"===t.shape.type)return function(e,t,n,o,r,i){const s=o-e,a=r-t,c=n+i,l=s*s+a*a;if(l>=c*c)return null;if(Ph>=l)return{nx:1,ny:0,penetration:c};const u=Math.sqrt(l);return{nx:s/u,ny:a/u,penetration:c-u}}(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.radius);if("aabb"===e.shape.type&&"aabb"===t.shape.type)return Eh(e.x,e.y,e.shape.width,e.shape.height,t.x,t.y,t.shape.width,t.shape.height);if("circle"===e.shape.type&&"aabb"===t.shape.type){const n=Oh(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height);return n?{nx:-n.nx,ny:-n.ny,penetration:n.penetration}:null}return"aabb"===e.shape.type&&"circle"===t.shape.type?Oh(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height):null}function Bh(e,t){const n=t.shape;return"aabb"===n.type?"circle"===e.shape.type?Oh(e.x,e.y,e.shape.radius,n.x,n.y,n.width,n.height):Eh(n.x,n.y,n.width,n.height,e.x,e.y,e.shape.width,e.shape.height):function(e,t,n,o,r,i,s,a=0){const c=i-o,l=s-r,u=c*c+l*l,d=u>Ph?Lh(((e-o)*c+(t-r)*l)/u,0,1):0,h=n+a/2,f=e-(o+c*d),p=t-(r+l*d),y=f*f+p*p;if(y>=h*h)return null;if(Ph>=y){const e=Math.sqrt(u);return e>Ph?{nx:-l/e,ny:c/e,penetration:h}:{nx:1,ny:0,penetration:h}}const g=Math.sqrt(y);return{nx:f/g,ny:p/g,penetration:h-g}}(e.x,e.y,"circle"===e.shape.type?e.shape.radius:Math.sqrt(e.shape.width*e.shape.width+e.shape.height*e.shape.height)/2,n.x1,n.y1,n.x2,n.y2,n.thickness??0)}function Fh(e,t){return`${e}\0${t}`}function Nh(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function Wh(e){return{id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,bodyCollisions:e.bodyCollisions,shape:Rh(e.shape),sleeping:e.sleeping,datum:e.datum,index:e.index,sleepTime:e.sleepTime,restitution:e.restitution,friction:e.friction}}function qh(e){return e&&"function"!=typeof e?{property:e.property,equals:e.equals,notEquals:e.notEquals,oneOf:e.oneOf?.slice(),notOneOf:e.notOneOf?.slice()}:e}function Yh(e){return{id:e.id,shape:Ch(e.shape),sensor:e.sensor,restitution:e.restitution,friction:e.friction,bodyFilter:qh(e.bodyFilter),index:e.index}}function Gh(e,t){return!!t?.some(t=>Object.is(e,t))}function Hh(e,t){const n=e.bodyFilter;if(!n)return!0;if("function"==typeof n)return n(t);const o=function(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;n=n[e]}return n}(t,n.property);return!("equals"in n&&!Object.is(o,n.equals)||"notEquals"in n&&Object.is(o,n.notEquals)||n.oneOf&&!Gh(o,n.oneOf)||n.notOneOf&&Gh(o,n.notOneOf))}var Vh=class{constructor(e={}){this.capabilities={determinism:"strict",sensors:!0,joints:!1,ccd:!1,maxBodiesHint:5e3,worker:!1},this.bodies=new Map,this.colliders=new Map,this.springs=new Map,this.activeSensors=new Set,this.supportedThisStep=new Set,this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0,this.options={..._h,...e},this.random=Mh(this.options.seed)}init(e={}){this.options={..._h,...e},this.random=Mh(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0}spawn(e){const t={id:e.id,x:e.x,y:e.y,prevX:e.x,prevY:e.y,vx:e.vx??0,vy:e.vy??0,angle:e.angle??0,mass:Math.max(Ph,e.mass??1),bodyCollisions:e.bodyCollisions??!0,shape:Rh(e.shape),sleeping:!1,datum:e.datum,restitution:e.restitution,friction:e.friction,index:this.nextBodyIndex,sleepTime:0};this.nextBodyIndex+=1,this.bodies.set(e.id,t)}remove(e){for(const t of e){this.bodies.delete(t);for(const e of Array.from(this.activeSensors))Nh(e).bodyId===t&&this.activeSensors.delete(e)}}setColliders(e){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(const t of e)this.colliders.set(t.id,{...t,shape:Ch(t.shape),bodyFilter:qh(t.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(e){const t=e.id??"spring-"+this.nextSpringIndex;return this.springs.set(t,{id:t,bodyId:e.bodyId,target:e.target,restLength:e.restLength??0,stiffness:e.stiffness??40,damping:e.damping??3}),this.nextSpringIndex+=1,t}removeConstraint(e){this.springs.delete(e)}applyImpulse(e,t,n){const o=this.bodies.get(e);o&&(o.vx+=t/o.mass,o.vy+=n/o.mass,this.wake(o))}step(e=this.options.fixedDt){const t=Math.max(0,e);if(this.lastEvents=[],0===t)return;const n=this.sortedBodies();for(const e of n)e.prevX=e.x,e.prevY=e.y;this.applySprings(t);const o=this.options.maxVelocity;for(const e of n)if(!e.sleeping){if(e.vx+=this.options.gravity.x*t,e.vy+=this.options.gravity.y*t,e.vx*=this.options.velocityDamping,e.vy*=this.options.velocityDamping,o>0){const t=Math.sqrt(e.vx*e.vx+e.vy*e.vy);if(t>o){const n=o/t;e.vx*=n,e.vy*=n}}e.x+=e.vx*t,e.y+=e.vy*t}this.supportedThisStep.clear();const r=this.bodyPairKeys(n),i=this.sortedColliders().filter(e=>!e.sensor);for(let e=0;this.options.collisionIterations>e;e+=1)this.resolveBodyPairs(n,r,0===e),this.resolveColliders(n,i,0===e);this.updateSensors(n),this.updateSleeping(n,t)}settle(e=1200,t=this.options.fixedDt){let n=0;for(;e>n&&!this.allSleeping();)this.step(t),n+=1;return n}readState(e=[]){e.length=0;for(const t of this.sortedBodies())e.push({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,shape:Rh(t.shape),sleeping:t.sleeping,datum:t.datum});return e}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(Nh)}allSleeping(){for(const e of this.bodies.values())if(!e.sleeping)return!1;return!0}snapshot(){return{options:{...this.options,gravity:{...this.options.gravity}},bodies:this.sortedBodies().map(Wh),colliders:this.sortedColliders().map(Yh),springs:Array.from(this.springs.values()).map(e=>({...e,target:{...e.target}})),activeSensors:Array.from(this.activeSensors).sort()}}restore(e){this.options={...e.options,gravity:{...e.options.gravity}},this.random=Mh(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(e.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(const t of e.bodies){const e=Wh(t);this.bodies.set(e.id,e),this.nextBodyIndex=Math.max(this.nextBodyIndex,e.index+1)}this.nextColliderIndex=0;for(const t of e.colliders){const e=Yh(t);this.colliders.set(e.id,e),this.nextColliderIndex=Math.max(this.nextColliderIndex,e.index+1)}this.nextSpringIndex=0;for(const t of e.springs){this.springs.set(t.id,{...t,target:{...t.target}});const e=/^spring-(\d+)$/.exec(t.id);e&&(this.nextSpringIndex=Math.max(this.nextSpringIndex,Number(e[1])+1))}}dispose(){this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[]}sortedBodies(){return Array.from(this.bodies.values()).sort((e,t)=>e.index-t.index)}sortedColliders(){return Array.from(this.colliders.values()).sort((e,t)=>e.index-t.index)}applySprings(e){for(const t of Array.from(this.springs.values()).sort((e,t)=>e.id.localeCompare(t.id))){const n=this.bodies.get(t.bodyId);if(!n||n.sleeping)continue;const o="point"===t.target.type?t.target:this.bodies.get(t.target.bodyId);if(!o)continue;const r=o.x-n.x,i=o.y-n.y,s=Math.sqrt(r*r+i*i);if(Ph>=s)continue;const a=r/s,c=i/s,l=(s-t.restLength)*t.stiffness+((("vx"in o?o.vx:0)-n.vx)*a+(("vy"in o?o.vy:0)-n.vy)*c)*t.damping;n.vx+=l*a*e/n.mass,n.vy+=l*c*e/n.mass}}resolveBodyPairs(e,t,n){for(const o of t){const[t,r]=o.split(":").map(Number),i=e[t],s=e[r];if(!i||!s)continue;const a=Dh(i,s);a&&(this.resolveDynamicCollision(i,s,a),n&&this.lastEvents.push({type:"contact",bodyId:i.id,otherId:s.id,sensor:!1}))}}bodyPairKeys(e){const t=Math.max(1,this.options.cellSize),n=new Map;for(let o=0;e.length>o;o+=1){if(!1===e[o].bodyCollisions)continue;const r=Th(e[o]),i=Math.floor(r.minX/t),s=Math.floor(r.maxX/t),a=Math.floor(r.minY/t),c=Math.floor(r.maxY/t);for(let e=i;s>=e;e+=1)for(let t=a;c>=t;t+=1){const r=`${e}:${t}`,i=n.get(r);i?i.push(o):n.set(r,[o])}}const o=new Set;for(const t of Array.from(n.keys()).sort()){const r=n.get(t)??[];r.sort((e,t)=>e-t);for(let t=0;r.length>t;t+=1)for(let n=t+1;r.length>n;n+=1){const i=r[t],s=r[n];!1!==e[i].bodyCollisions&&!1!==e[s].bodyCollisions&&zh(Th(e[i]),Th(e[s]))&&o.add(`${i}:${s}`)}}return Array.from(o).sort((e,t)=>{const[n,o]=e.split(":").map(Number),[r,i]=t.split(":").map(Number);return n===r?o-i:n-r})}resolveDynamicCollision(e,t,n){e.sleeping&&this.contactOpposesGravity(n.nx,n.ny)&&this.supportedThisStep.add(t.id),t.sleeping&&this.contactOpposesGravity(-n.nx,-n.ny)&&this.supportedThisStep.add(e.id);const o=e.sleeping?0:1/e.mass,r=t.sleeping?0:1/t.mass,i=o+r;if(Ph>=i)return;const s=Math.max(0,n.penetration-jh)/i;e.x-=n.nx*s*o,e.y-=n.ny*s*o,t.x+=n.nx*s*r,t.y+=n.ny*s*r;const a=(t.vx-e.vx)*n.nx+(t.vy-e.vy)*n.ny;if(a>0)return;const c=Math.abs(a),l=-(1+Math.min(e.restitution??this.options.restitution,t.restitution??this.options.restitution))*a/i,u=l*n.nx,d=l*n.ny;e.vx-=u*o,e.vy-=d*o,t.vx+=u*r,t.vy+=d*r,this.applyFriction(e,t,n,l,o,r),c>this.options.contactWakeSpeed&&(this.wake(e),this.wake(t))}applyFriction(e,t,n,o,r,i){const s=-n.ny,a=n.nx,c=(t.vx-e.vx)*s+(t.vy-e.vy)*a,l=r+i;if(Ph>=Math.abs(c)||Ph>=l)return;const u=Math.max(0,Math.min(1,Math.max(e.friction??this.options.friction,t.friction??this.options.friction))),d=Lh(-c/l,-o*u,o*u),h=d*s,f=d*a;e.vx-=h*r,e.vy-=f*r,t.vx+=h*i,t.vy+=f*i}resolveColliders(e,t,n){for(const o of e)for(const e of t){if(!Hh(e,o))continue;if(!zh(Th(o),$h(e)))continue;const t=Bh(o,e);t&&(this.resolveStaticCollision(o,e,t),this.contactOpposesGravity(t.nx,t.ny)&&this.supportedThisStep.add(o.id),n&&this.lastEvents.push({type:"contact",bodyId:o.id,otherId:e.id,sensor:!1}))}}resolveStaticCollision(e,t,n){e.x+=n.nx*Math.max(0,n.penetration-jh),e.y+=n.ny*Math.max(0,n.penetration-jh);const o=e.vx*n.nx+e.vy*n.ny;if(0>o){const r=Math.min(e.restitution??this.options.restitution,t.restitution??this.options.restitution);e.vx-=(1+r)*o*n.nx,e.vy-=(1+r)*o*n.ny;const i=-n.ny,s=n.nx,a=e.vx*i+e.vy*s,c=Math.max(0,Math.min(1,Math.max(e.friction??this.options.friction,t.friction??this.options.friction)));e.vx-=a*i*c,e.vy-=a*s*c}}updateSensors(e){const t=new Set,n=this.sortedColliders().filter(e=>e.sensor);for(const o of e){const e=Th(o);for(const r of n){if(!Hh(r,o))continue;if(!zh(e,$h(r)))continue;if(!Bh(o,r))continue;const n=Fh(r.id,o.id);t.add(n),this.activeSensors.has(n)||this.lastEvents.push({type:"sensor-enter",bodyId:o.id,sensorId:r.id})}}for(const e of Array.from(this.activeSensors).sort()){if(t.has(e))continue;const{sensorId:n,bodyId:o}=Nh(e);this.lastEvents.push({type:"sensor-exit",bodyId:o,sensorId:n})}this.activeSensors=t}updateSleeping(e,t){const n=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const o of e)Math.sqrt(o.vx*o.vx+o.vy*o.vy)>=this.options.sleepSpeed||Math.sqrt((o.x-o.prevX)*(o.x-o.prevX)+(o.y-o.prevY)*(o.y-o.prevY))>=this.options.sleepSpeed*t||n&&!this.supportedThisStep.has(o.id)?o.sleeping?this.wake(o):o.sleepTime=0:(o.sleepTime+=t,o.sleeping||this.options.sleepAfter>o.sleepTime||(o.sleeping=!0,o.vx=0,o.vy=0,this.lastEvents.push({type:"sleep",bodyId:o.id})))}contactOpposesGravity(e,t){const{x:n,y:o}=this.options.gravity,r=Math.hypot(n,o);return 1e-9>=r||-.2>(e*n+t*o)/r}wake(e){e.sleeping&&this.lastEvents.push({type:"wake",bodyId:e.id}),e.sleeping=!1,e.sleepTime=0}nextRandom(){return this.random()}},Xh=class{constructor(e={}){this.id="builtin",this.capabilities={...(new Vh).capabilities,engine:"builtin"},this.world=new Vh(e)}init(e={}){this.world.init(e)}spawn(e){this.world.spawn(e)}remove(e){this.world.remove(e)}setColliders(e){this.world.setColliders(e)}setConstraint(e){return this.world.setConstraint(e)}removeConstraint(e){this.world.removeConstraint(e)}applyImpulse(e,t,n){this.world.applyImpulse(e,t,n)}step(e){this.world.step(e)}settle(e,t){return this.world.settle(e,t)}readState(e){return this.world.readState(e)}events(){return this.world.events()}activeSensorPairs(){return this.world.activeSensorPairs()}allSleeping(){return this.world.allSleeping()}snapshot(){return this.world.snapshot()}restore(e){this.world.restore(e)}nextRandom(){return this.world.nextRandom()}dispose(){this.world.dispose()}};function Uh(e,t={}){return e?"function"==typeof e?e(t):(e.init(t),e):function(e={}){return new Xh(e)}(t)}var Kh=["binId","targetBin","category","windowIndex","lane","group"];function Zh(e,t){if(!Number.isFinite(t))return;e.count+=1,e.total+=t,e.min=Math.min(e.min,t),e.max=Math.max(e.max,t);const n=t-e.mean;e.mean+=n/e.count,e.m2+=n*(t-e.mean)}function Qh(e){return{count:e.count,total:e.total,mean:e.count>0?e.mean:0,min:e.count>0?e.min:0,max:e.count>0?e.max:0,variance:e.count>1?e.m2/(e.count-1):0}}function Jh(e){return{count:e.count,total:e.total,mean:e.mean,m2:e.variance*Math.max(0,e.count-1),min:e.count>0?e.min:1/0,max:e.count>0?e.max:-1/0}}function ef(e,t){if(null!=e[t])return e[t];const n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function tf(e,t,n){return"function"==typeof e?e(t,n):"string"==typeof e?ef(t,e):void 0}function nf(e){if(null==e)return;const t=e+"";return t.trim()?t:void 0}function of(e){const t=Qh(e.value);return{id:e.id,label:e.label,count:t.count,total:t.total,bodyIds:e.bodyIds.slice(),lastBodyId:e.lastBodyId,lastDatum:e.lastDatum,x:Qh(e.x),y:Qh(e.y),value:t}}var rf=class{constructor(e=!1){this.bins=new Map,this.nextIndex=0,this.config=e}updateConfig(e){void 0!==e&&(this.config=e,!1===e&&this.clear())}isEnabled(){return!1!==this.config}add(e){if(!1===this.config)return null;const t=this.nextIndex;this.nextIndex+=1;const n=nf(tf(this.config.binAccessor,e,t))??function(e){for(const t of Kh){const n=nf(ef(e,t));if(n)return n}return"sediment"}(e),o=nf(tf(this.config.labelAccessor,e,t))??n,r=function(e,t,n){if("number"==typeof e)return e;const o="function"==typeof e?e(t,n):"string"==typeof e?ef(t,e):1,r="number"==typeof o?o:Number(o);return Number.isFinite(r)?r:1}(this.config.valueAccessor,e,t),i=Math.max(0,Math.floor(this.config.retainBodyIds??12));let s=this.bins.get(n);return s||(s={id:n,label:o,bodyIds:[],x:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},y:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},value:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0}},this.bins.set(n,s)),s.label=o,s.lastBodyId=e.id,s.lastDatum=e.datum,Zh(s.x,e.x),Zh(s.y,e.y),Zh(s.value,r),i>0&&(s.bodyIds.push(e.id),s.bodyIds.length>i&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-i))),of(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(of)}restore(e=[]){this.bins.clear();for(const t of e)this.bins.set(t.id,{id:t.id,label:t.label,bodyIds:t.bodyIds.slice(),lastBodyId:t.lastBodyId,lastDatum:t.lastDatum,x:Jh(t.x),y:Jh(t.y),value:Jh(t.value)});this.nextIndex=e.reduce((e,t)=>e+t.count,0)}totals(){const e=this.snapshot();return{bins:e.length,count:e.reduce((e,t)=>e+t.count,0),total:e.reduce((e,t)=>e+t.total,0)}}};function sf(e){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}var af={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},cf={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function lf(e={},t=cf){return{chartId:e.chartId??t.chartId,chartType:e.chartType??t.chartType,sensors:e.sensors??t.sensors,onObservation:e.onObservation??t.onObservation,onSimulationStateChange:e.onSimulationStateChange??t.onSimulationStateChange}}function uf(e){return{...e,shape:{...e.shape},datum:e.datum,springs:e.springs?.map(e=>({...e,target:{...e.target}}))}}function df(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:void 0}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function hf(e,t){if(null!=e[t])return e[t];const n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function ff(e){return{...uf(e),sequence:e.sequence,spawnAt:e.spawnAt}}function pf(e){return e.map(e=>({...e,shape:{...e.shape},bodyFilter:e.bodyFilter&&"function"!=typeof e.bodyFilter?{...e.bodyFilter,oneOf:e.bodyFilter.oneOf?.slice(),notOneOf:e.bodyFilter.notOneOf?.slice()}:e.bodyFilter}))}function yf(e){return!1!==e&&{...e}}function gf(e,t){return e.spawnAt===t.spawnAt?e.sequence-t.sequence:e.spawnAt-t.spawnAt}function mf(e){return{...e,gravity:{...e.gravity}}}function xf(e,t,n,o){if("circle"===e.shape.type){const r=e.x-t,i=e.y-n,s=e.shape.radius+o,a=r*r+i*i;return a>s*s?null:a}const r=Math.max(Math.abs(t-e.x)-e.shape.width/2,0),i=Math.max(Math.abs(n-e.y)-e.shape.height/2,0),s=r*r+i*i;return s>o*o?null:s}function bf(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function vf(e,t={}){const{idPrefix:n="plot",includeFloor:o=!0,includeCeiling:r=!1,includeLeftWall:i=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=t,l=[],u=e.x+e.width/2,d=e.y+e.height/2;return o&&l.push({id:n+"-floor",shape:{type:"aabb",x:u,y:e.y+e.height+c/2,width:e.width+2*a,height:c}}),r&&l.push({id:n+"-ceiling",shape:{type:"aabb",x:u,y:e.y-c/2,width:e.width+2*a,height:c}}),i&&l.push({id:n+"-left-wall",shape:{type:"aabb",x:e.x-a/2,y:d,width:a,height:e.height+2*c}}),s&&l.push({id:n+"-right-wall",shape:{type:"aabb",x:e.x+e.width+a/2,y:d,width:a,height:e.height+2*c}}),l}function wf(e){const{idPrefix:t="bin",count:n,domainStart:o,domainStep:r,xScale:i,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=s,lidThickness:f=Math.max(2,c)}=e,p=[],y=s+(a-s)/2,g=Math.abs(a-s),m=l?n:n-1;if(u||l)for(let e=l?0:1;m>=e;e+=1){if(!u&&e>0&&n>e)continue;const s=i(o+e*r);p.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:s,y:y,width:c,height:g}})}if(null!=d)for(let e=0;n>e;e+=1){const n=o+e*r,s=n+r;if(s>=d)continue;const a=i(n),l=i(s);p.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:h,x2:Math.max(a,l)-c/2,y2:h,thickness:f}})}return p}var kf=require("d3-quadtree"),Sf=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(e,t,n,o,r,i=0){const s=this.ensure(e,t);if(!s)return null;let a=null,c=1/0;const l=Math.max(0,i)+this.maxSearchRadius,u=o-l,d=o+l,h=r-l,f=r+l;return s.visit((e,t,s,l,p)=>{if(u>l||t>d||h>p||s>f)return!0;if(e.length)return!1;let y=e;for(;y;){const e=y.data;if(e){const t=xf(e,o,r,Math.max(0,i));null!=t&&(c>t||t===c&&n.indexOf(e.id)>n.indexOf(a?.id??""))&&(a=e,c=t)}y=y.next}return!1}),a}ensure(e,t){if(this.tree&&this.revision===t)return this.tree;const n=e.readState();return 0===n.length?(this.tree=null,this.maxSearchRadius=0,this.revision=t,null):(this.maxSearchRadius=n.reduce((e,t)=>Math.max(e,function(e){return"circle"===e.shape.type?e.shape.radius:Math.hypot(e.shape.width,e.shape.height)/2}(t)),0),this.tree=(0,kf.quadtree)().x(e=>e.x).y(e=>e.y).addAll(n),this.revision=t,this.tree)}},Af=["data","scene-geometry","data-paint","accessibility","evidence"],Mf=["scene-geometry","data-paint","accessibility","evidence"],_f=["overlay","accessibility","evidence"],Pf=(e,t)=>({retainedData:e,invalidations:t}),jf=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Rf=["scene-geometry","data-paint","accessibility","evidence"],Cf=[],Lf={engine:Pf("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:Pf("preserve",Rf),colliders:Pf("preserve",Rf),sediment:Pf("preserve",Rf),bodyBudget:Pf("preserve",jf),bodyLimit:Pf("preserve",jf),eviction:Pf("preserve",jf),fixedDt:Pf("preserve",Cf),maxDeltaSeconds:Pf("preserve",Cf),maxSubsteps:Pf("preserve",Cf),settleStepLimit:Pf("preserve",Cf),timeScale:Pf("preserve",Cf),observation:Pf("preserve",Cf)},If=Pf("preserve",jf);function Tf(e){let t="preserve";const n=new Set;for(const o of e){const e=Lf[o]??If;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}var $f=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function zf(e,t){return e===t||!(!e||!t)&&e.gravity?.x===t.gravity?.x&&e.gravity?.y===t.gravity?.y&&$f.every(n=>e[n]===t[n])}function Ef(e,t,n,o){return e||!t?"paused":n||!o?"running":"settled"}var Of=class{constructor(){this.seconds=0,this.speed=8,this.scratch=[]}setKernelOptions(e){this.speed=function(e){const t=e?.sleepSpeed;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:8}(e)}reset(){this.seconds=0}isAtRest(){return this.seconds>=.6}refresh(e,t,n){if(n>0)return void(this.seconds=0);const o=e.readState(this.scratch),r=this.speed*this.speed;let i=!0;for(const e of o)if(!e.sleeping&&e.vx*e.vx+e.vy*e.vy>=r){i=!1;break}this.seconds=i?this.seconds+Math.max(0,t):0}},Df=class{constructor(e={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new Sf,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new Bn,this.simulationState="settled",this.visible=!0,this.quiescence=new Of;const{bodyBudget:t,colliders:n,engine:o,kernel:r,observation:i,sediment:s,...a}=e;this.config={...af,...a},this.configInput={...e},this.bodyBudget=t??{},this.engineInput=o,this.observation=lf(i),this.sediment=new rf(s??!1),this.world=Uh(o,{fixedDt:this.config.fixedDt,...r}),this.quiescence.setKernelOptions(r),n&&this.world.setColliders(pf(n))}updateConfig(e){const t=function(e,t){return Object.keys(e).filter(n=>"kernel"===n?!zf(e.kernel,t.kernel):e[n]!==t[n])}(e,this.configInput),{colliders:n,bodyBudget:o,engine:r,kernel:i,observation:s,sediment:a,...c}=e;if(this.config={...this.config,...c},void 0!==o&&(this.bodyBudget=o,!1===o&&(this.bodyBudgetObservationKey="ok")),r&&r!==this.engineInput){const e=this.world.snapshot();this.world.dispose(),this.engineInput=r,this.world=Uh(r,e.options),this.world.restore(e),this.revision+=1}if(i&&!zf(i,this.configInput.kernel)){const e=this.world.snapshot(),t={...e.options,...i,gravity:{...e.options.gravity,...i.gravity}};this.world.restore({...e,options:t}),this.quiescence.setKernelOptions(t),this.revision+=1}s&&(this.observation=lf(s,this.observation)),this.sediment.updateConfig(a),n&&(this.world.setColliders(pf(n)),this.revision+=1),this.configInput={...this.configInput,...e};const l=Tf(t);this.updateResults.record({kind:"config",keys:t},l.invalidations)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setColliders(e){this.world.setColliders(pf(e)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},Tf(["colliders"]).invalidations)}enqueue(e,t){const n=Array.isArray(e)?e:[e],o=t?function(e,t={}){const n=df(t.startAt)??0,o=t.pacing??"immediate";if("arrival"===o){const o=e.map((e,n)=>function(e,t,n){return"function"==typeof n?df(n(e,t)):"string"==typeof n?df(hf(e,n)):df(e.spawnAt)??df(hf(e,"arrivalTime"))??df(hf(e,"timestamp"))??df(hf(e,"time"))??df(hf(e,"eventTime"))}(e,n,t.timeAccessor)),r=o.filter(e=>null!=e),i=r.length>0?Math.min(...r):0,s=df(t.timeScale)??1,a=s>0?s:1;return e.map((e,t)=>{const r=o[t],s=null==r?0:Math.max(0,r-i);return{...uf(e),spawnAt:n+s/a}})}if("object"==typeof o){const t=df(o.ratePerSec);if(t&&t>0)return e.map((e,o)=>({...uf(e),spawnAt:n+o/t}))}return e.map(e=>({...uf(e),spawnAt:n}))}(n,{...t,startAt:t.startAt??this.elapsedSeconds}):n;for(const e of o)this.queue.push({...uf(e),sequence:this.nextSequence,spawnAt:e.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(gf),o.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:o.length},o.length?Af:[])}enqueueWithResult(e,t){return this.enqueue(e,t),this.updateResults.last}spawnNow(e){this.spawnOne(uf(e)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},Af)}materializeDueSpawns(){const e=this.revision,t=[],n=[];return this.spawnDue(t,n),0===t.length||(this.observeBodyBudget(n),this.evictOverflow(n),this.syncSimulationState(n),this.revision+=1,this.updateResults.record({kind:"enqueue",count:t.length},this.revision!==e?Af:[])),t}clear(){const e=this.world.snapshot().options;this.world.init({...e,fixedDt:this.config.fixedDt}),this.activeSensorPairs.clear(),this.liveBodyOrder=[],this.queue=[],this.accumulator=0,this.elapsedSeconds=0,this.nextSequence=0,this.quiescence.reset(),this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},Af)}tick(e){const t=this.revision,n=[],o=[],r=[],i=[],s=[];if(this.paused||!this.visible){const e=this.result(0,n,o,r,i,s,!1);return this.updateResults.record({kind:"tick",count:0},[]),e}const a=Math.max(0,Math.min(e,this.config.maxDeltaSeconds))*this.config.timeScale;this.elapsedSeconds+=a,this.spawnDue(n,s);const c=this.observeBodyBudget(s),l=this.evictOverflow(s);o.push(...l.evicted),r.push(...l.sedimented),this.syncSimulationState(s),this.accumulator+=a;let u=0;for(;this.accumulator>=this.config.fixedDt&&this.config.maxSubsteps>u;){this.world.step(this.config.fixedDt);const e=this.world.events();i.push(...e),this.observeKernelEvents(e,s),this.observeSensorTransitions(s),this.accumulator-=this.config.fixedDt,u+=1}u===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),this.quiescence.refresh(this.world,a,n.length),(u>0||n.length>0||o.length>0||r.length>0||i.length>0)&&(this.revision+=1);const d=this.result(u,n,o,r,i,s,void 0,c);return this.updateResults.record({kind:"tick",count:u},this.revision!==t?n.length||o.length||r.length?Af:Mf:[]),d}settle(e=this.config.settleStepLimit){const t=this.revision;this.spawnDue([],[]);const n=this.world.settle(e,this.config.fixedDt);return n>0&&(this.revision+=1),this.syncSimulationState(),this.updateResults.record({kind:"settle",count:n},this.revision!==t?Mf:[]),n}settleWithObservations(e=this.config.settleStepLimit){const t=this.revision,n=[],o=[],r=[],i=[],s=[];if(this.paused||!this.visible){const e=this.result(0,n,o,r,i,s,!1);return this.updateResults.record({kind:"settle",count:0},[]),e}this.spawnDue(n,s);const a=this.observeBodyBudget(s),c=this.evictOverflow(s);o.push(...c.evicted),r.push(...c.sedimented),this.syncSimulationState(s);let l=0;for(n.length>0&&this.quiescence.reset();e>l&&!this.atRest();){this.world.step(this.config.fixedDt);const e=this.world.events();i.push(...e),this.observeKernelEvents(e,s),this.observeSensorTransitions(s),l+=1,this.quiescence.refresh(this.world,this.config.fixedDt,0)}(l>0||n.length>0||o.length>0||r.length>0||i.length>0)&&(this.revision+=1);const u=this.result(l,n,o,r,i,s,void 0,a);return this.updateResults.record({kind:"settle",count:l},this.revision!==t?n.length||o.length||r.length?Af:Mf:[]),u}readBodies(e=[]){return this.world.readState(e)}readSediment(){return this.sediment.snapshot()}bodyBudgetStatus(){return this.evaluateBodyBudget()}sedimentTotals(){return this.sediment.totals()}sedimentHeightfield(e={}){return function(e,t={}){const{baselineY:n=0,binWidth:o=24,gap:r=2,maxHeight:i=80,value:s="count",x:a}=t,c=Math.max(1,...e.map(e=>e[s]));return e.map((e,t)=>{const l=Math.max(0,e[s]/c*i),u=a?.(e,t)??t*(o+r);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:n-l,width:o,height:l,meanX:e.x.mean,meanY:e.y.mean}})}(this.readSediment(),e)}hitTest(e,t,n=0){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,e,t,n)}events(){return this.world.events()}allSleeping(){return this.world.allSleeping()}atRest(){return this.world.allSleeping()||this.quiescence.isAtRest()}hasPendingWork(){return this.queue.length>0||!this.atRest()}queueSize(){return this.queue.length}liveBodyCount(){return this.liveBodyOrder.length}elapsed(){return this.elapsedSeconds}recordObservation(e){const{timestamp:t,chartType:n,chartId:o,...r}=e,i={...r,timestamp:t??this.elapsedSeconds,chartType:n??this.observation.chartType,chartId:o??this.observation.chartId};return this.emitObservation(i),this.updateResults.record({kind:"update",count:1},["evidence"]),i}getLastUpdateResult(){return this.updateResults.last}getUpdateSnapshot(){return this.updateResults.last}subscribeUpdateResult(e){return this.updateResults.subscribe(e)}version(){return this.revision}setPaused(e){const t=this.paused!==e;this.paused=e,this.syncSimulationState(),this.updateResults.record({kind:"pause"},t?_f:[])}setVisible(e){const t=this.visible!==e;this.visible=e,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},t?_f:[])}remove(e){const t=new Set(e),n=new Set(this.liveBodyOrder),o=new Set(this.queue.map(e=>e.id));this.queue=this.queue.filter(e=>!t.has(e.id)),this.liveBodyOrder=this.liveBodyOrder.filter(e=>!t.has(e)),this.world.remove(e),this.removeActiveSensorPairsForBodies(t);const r=e.filter(e=>n.has(e)||o.has(e));return r.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:r,count:r.length},r.length?Af:[]),r}setConstraint(e){const t=this.world.setConstraint(e);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},Mf),t}removeConstraint(e){this.world.removeConstraint(e),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},Mf)}applyImpulse(e,t,n){this.world.applyImpulse(e,t,n),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[e]},Mf)}nextRandom(){return this.world.nextRandom()}controls(){return e=this,{applyImpulse:(t,n,o)=>e.applyImpulse(t,n,o),clear:()=>e.clear(),hitTest:(t,n,o)=>e.hitTest(t,n,o),pause:()=>e.setPaused(!0),push:(t,n)=>e.enqueue(t,n),pushMany:(t,n)=>e.enqueue(t,n),bodyBudgetStatus:()=>e.bodyBudgetStatus(),readBodies:t=>e.readBodies(t),readSediment:()=>e.readSediment(),recordObservation:t=>e.recordObservation(t),remove:t=>e.remove(t),restore:t=>e.restore(t),resume:()=>e.setPaused(!1),settle:t=>e.settle(t),settleWithObservations:t=>e.settleWithObservations(t),snapshot:()=>e.snapshot(),sedimentHeightfield:t=>e.sedimentHeightfield(t),sedimentTotals:()=>e.sedimentTotals(),step:t=>e.tick(t)};var e}snapshot(){const e=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:yf(this.bodyBudget),config:{...this.config,kernel:mf(e.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(ff),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:e}}restore(e){this.config={bodyLimit:e.config.bodyLimit,eviction:e.config.eviction,fixedDt:e.config.fixedDt,maxDeltaSeconds:e.config.maxDeltaSeconds,maxSubsteps:e.config.maxSubsteps,settleStepLimit:e.config.settleStepLimit,timeScale:e.config.timeScale},this.configInput={...e.config,bodyBudget:yf(e.bodyBudget??{}),kernel:mf(e.world.options)},this.bodyBudget=yf(e.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.quiescence.setKernelOptions(e.world.options),this.quiescence.reset(),this.activeSensorPairs=new Set(e.activeSensorPairs),this.accumulator=e.accumulator,this.elapsedSeconds=e.elapsedSeconds,this.paused=e.paused,this.queue=e.queue.map(ff).sort(gf),this.revision=e.revision,this.sediment.restore(e.sediment??[]),this.simulationState=e.simulationState??Ef(e.paused,e.visible,e.queue.length>0,e.world.bodies.every(e=>e.sleeping)),this.liveBodyOrder=e.liveBodyOrder.slice(),this.visible=e.visible,this.nextSequence=this.queue.reduce((e,t)=>Math.max(e,t.sequence),-1)+1,this.world.restore(e.world),this.updateResults.record({kind:"restore"},Af)}spawnDue(e,t){for(;this.queue.length>0&&this.elapsedSeconds>=this.queue[0].spawnAt;){const n=this.queue.shift();if(!n)return;this.spawnOne(n,t),e.push(n.id)}}spawnOne(e,t){this.liveBodyOrder=this.liveBodyOrder.filter(t=>t!==e.id),this.removeActiveSensorPairsForBodies(new Set([e.id])),this.world.spawn(e),this.liveBodyOrder.push(e.id);for(const t of e.springs??[])this.world.setConstraint({...t,bodyId:e.id});const n=this.world.readState().find(t=>t.id===e.id);this.emitObservation({type:"physics-spawn",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:e.id,datum:n?.datum??e.datum,x:n?.x??e.x,y:n?.y??e.y},t)}result(e,t,n,o,r,i,s,a=this.evaluateBodyBudget()){this.syncSimulationState(i);const c=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:n,events:r,observations:i,queueSize:this.queue.length,revision:this.revision,shouldContinue:s??(this.queue.length>0||!this.atRest()),sleeping:c,sedimented:o,spawned:t,steps:e}}observeKernelEvents(e,t){!function(e,t,n){if(0===t.length)return;const o=new Map(e.readState().map(e=>[e.id,e]));for(const e of t){if("sleep"!==e.type)continue;const t=o.get(e.bodyId);n.emit({type:"physics-settle",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,bodyId:e.bodyId,datum:t?.datum,x:t?.x,y:t?.y})}}(this.world,e,this.observationContext(t))}observeSensorTransitions(e){this.activeSensorPairs=function(e,t,n){const o=new Set(e.activeSensorPairs().map(e=>`${e.sensorId}\0${e.bodyId}`));if(0===o.size&&0===t.size)return o;const r=new Map(e.readState().map(e=>[e.id,e])),i=(e,t)=>{const{sensorId:o,bodyId:i}=bf(t),s=n.observation.sensors[o],a=r.get(i);n.emit({type:"enter"===e?s?.enterType??"physics-bin-enter":s?.exitType??"physics-bin-exit",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,bodyId:i,datum:a?.datum,x:a?.x,y:a?.y,sensorId:o,binId:s?.binId??o})};for(const e of Array.from(o).sort())t.has(e)||i("enter",e);for(const e of Array.from(t).sort())o.has(e)||i("exit",e);return o}(this.world,this.activeSensorPairs,this.observationContext(e))}removeActiveSensorPairsForBodies(e){!function(e,t){for(const n of e)t.has(bf(n).bodyId)&&e.delete(n)}(this.activeSensorPairs,e)}observationContext(e){return{elapsedSeconds:this.elapsedSeconds,observation:this.observation,emit:t=>this.emitObservation(t,e)}}emitObservation(e,t){t?.push(e),this.observation.onObservation?.(e)}evaluateBodyBudget(){return function(e){const t=Math.max(0,Math.floor(e.liveBodies)),n=Math.max(0,Math.floor(e.queuedBodies??0)),o=t+n,r=sf(e.bodyLimit),i=sf(e.engineMaxBodiesHint),s=function(e,t,n){if(!1===n)return;const o=sf(n?.warnAt);return null!=o?o:null!=e?Math.max(1,Math.floor(.8*e)):null!=t?Math.max(1,Math.floor(.8*t)):void 0}(r,i,e.options),a=null==r?0:Math.max(0,t-r),c=a>0?"overflow":null==s||s>o?"ok":"warning";return{action:"overflow"!==c?"continue":e.sedimentEnabled?"sediment":e.evictionEnabled?"evict":"retain",bodyLimit:r,engineMaxBodiesHint:i,liveBodies:t,overflow:a,projectedBodies:o,queuedBodies:n,state:c,warnAt:s}}({bodyLimit:this.config.bodyLimit,engineMaxBodiesHint:this.world.capabilities.maxBodiesHint,evictionEnabled:!1!==this.config.eviction,liveBodies:this.liveBodyOrder.length,queuedBodies:this.queue.length,sedimentEnabled:this.sediment.isEnabled(),options:this.bodyBudget})}observeBodyBudget(e){const t=this.evaluateBodyBudget();if("ok"===t.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",t;const n=`${t.state}:${t.action}`;return n===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=n,this.emitObservation({type:"overflow"===t.state?"physics-budget-overflow":"physics-budget-warning",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,budgetAction:t.action,bodyLimit:t.bodyLimit,engineMaxBodiesHint:t.engineMaxBodiesHint,liveBodies:t.liveBodies,overflow:t.overflow,projectedBodies:t.projectedBodies,queuedBodies:t.queuedBodies,warnAt:t.warnAt},e)),t}syncSimulationState(e){const t=Ef(this.paused,this.visible,this.queue.length>0,this.atRest());if(t===this.simulationState)return;const n=this.simulationState;this.simulationState=t,function(e,t,n){n.observation.onSimulationStateChange?.(t,e),"running"!==t&&"settled"!==t||n.emit({type:"running"===t?"sim-active":"sim-idle",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,simulationState:t,previousSimulationState:e})}(n,t,this.observationContext(e))}evictOverflow(e){const{evicted:t,sedimented:n,liveBodyOrder:o}=function(e,t,n,o,r,i){const s={evicted:[],sedimented:[],liveBodyOrder:r};if(!1===n)return s;const a=Math.max(0,Math.floor(o));if(!Number.isFinite(a))return s;const c=r.length-a;if(0>=c)return s;const l=function(e,t,n){if("sleeping-first"!==t)return n.slice();const o=new Map(e.readState().map(e=>[e.id,e.sleeping])),r=[],i=[];for(const e of n)o.get(e)?r.push(e):i.push(e);return[...r,...i]}(e,n,r),u=l.slice(0,c);if(0===u.length)return s;const d=function(e,t,n,o){const r=new Map(e.readState().map(e=>[e.id,e])),i=[];for(const e of n){const n=r.get(e);if(!n)continue;const s=t.add(n);s&&(i.push(e),o.emit({type:"physics-sediment",timestamp:o.elapsedSeconds,chartType:o.observation.chartType,chartId:o.observation.chartId,bodyId:e,datum:n.datum,x:n.x,y:n.y,binId:s.id,count:s.count,total:s.total}))}return i}(e,t,u,i);e.remove(u);const h=new Set(u);return{evicted:u,sedimented:d,liveBodyOrder:r.filter(e=>!h.has(e))}}(this.world,this.sediment,this.config.eviction,this.config.bodyLimit,this.liveBodyOrder,this.observationContext(e));return t.length>0&&(this.liveBodyOrder=o,this.removeActiveSensorPairsForBodies(new Set(t))),{evicted:t,sedimented:n}}};var Bf=require("d3-scale");function Ff(e){const{count:t,idPrefix:n,wallThickness:o,xScale:r,yBottom:i,yTop:s,yTopForIndex:a}=e;return Array.from({length:t+1},(e,t)=>{const c=Math.min(i-1,a?.(t)??s),l=Math.max(1,i-c);return{id:`${n}-wall-${t}`,shape:{type:"aabb",x:r(t),y:c+l/2,width:o,height:l}}})}var Nf=require("d3-scale");function Wf(e){if(Array.isArray(e)&&e.length>=2){const t=bh(e[0]),n=bh(e[1]);return null!=t&&null!=n?{x:t,y:n}:null}if(e&&"object"==typeof e){const t=e,n=bh(t.x),o=bh(t.y);return null!=n&&null!=o?{x:n,y:o}:null}return null}function qf(e){return Array.isArray(e)?e.map(Wf).filter(e=>null!=e):[]}function Yf(e,t,n){return"normalized"===n?{x:t.plot.x+e.x*t.plot.width,y:t.plot.y+e.y*t.plot.height}:{x:vh(e.x,t.plot.x,t.plot.x+t.plot.width),y:vh(e.y,t.plot.y,t.plot.y+t.plot.height)}}function Gf(e){let t=0;for(let n=1;e.length>n;n+=1)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t}function Hf(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};const n=vh(t,0,1)*Gf(e);let o=0;for(let t=1;e.length>t;t+=1){const r=e[t-1],i=e[t],s=Math.hypot(i.x-r.x,i.y-r.y);if(s>0){if(o+s>=n){const e=(n-o)/s;return{x:r.x+(i.x-r.x)*e,y:r.y+(i.y-r.y)*e}}o+=s}}return{...e[e.length-1]}}function Vf(e,t){const n=Hf(e,Math.max(0,t-.02)),o=Hf(e,Math.min(1,t+.02)),r=o.x-n.x,i=o.y-n.y,s=Math.hypot(r,i)||1;return{x:r/s,y:i/s}}function Xf(e,t,n){return Math.max(t,Math.min(n,e))}function Uf(e,t,n,o,r,i={}){return{id:e,friction:i.friction,restitution:i.restitution,bodyFilter:i.bodyFilter,shape:{type:"segment",x1:t,y1:n,x2:o,y2:r,thickness:i.thickness??8}}}function Kf(e){return{id:e.id,label:e.label,description:e.description,kind:e.kind,shape:(t=e.x,n=e.y,o=e.width,r=e.height,{type:"aabb",x:t,y:n,width:o,height:r}),bodyFilter:e.bodyFilter,collider:e.collider,colliderThickness:e.colliderThickness,friction:e.friction,restitution:e.restitution,semanticItem:e.semanticItem,metadata:e.metadata,bodyStyle:e.bodyStyle,attributes:e.attributes,onEnter:e.onEnter,onExit:e.onExit};var t,n,o,r}function Zf(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...Kf({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function Qf(e,t=12){return"number"==typeof e?{x:e,y:0}:e&&"object"==typeof e?{x:Number.isFinite(e.x)?Number(e.x):t,y:Number.isFinite(e.y)?Number(e.y):0}:{x:t,y:0}}function Jf(e){const t=e.stages;if(!t.length)throw Error("buildProcessFlowPhysics requires at least one stage");const n=e.size,o=ph(n),r=vh(e.ballRadius??6,2,18),i=e.seed??1,s=Sh(i),a=e.idAccessor,c=e.stageAccessor??"stage",l=e.groupBy,u=e.groupLabelAccessor,d=e.workAccessor,h=e.radiusAccessor,f=e.groupCompletion??(l?"allAbsorbed":"none"),p=e.springStiffness??.28,y=e.springDamping??.72,g=!0===e.settle,m=t.map(e=>({id:e.id,label:e.label??e.id,description:e.description,share:e.share})),x=function(e){const t=e.shape??"lane",n=Math.max(1,Math.round(e.width)),o=Math.max(1,Math.round(e.height)),r=e.padX??46,i=e.padY??72,s=r,a=n-r,c=i,l=o-Math.max(24,Math.round(.45*i)),u=(c+l)/2,d=Math.max(1,l-c),h=Xf(e.pinchRatio??.18,.06,.5),f=Number(e.pinchHeightOffset??0),p=Number.isFinite(f)?f:0,y=Xf(d*h+p,.06*d,.5*d),g=y/2,m=u-g,x=u+g,b=e.idPrefix??"process",v=e.friction??.58,w=e.restitution??.18,k=e.wallThickness??8,S=e.stages;if(!S.length)throw Error("processStageLayout requires at least one stage");const A=Xf(e.centerStageIndex??Math.floor(S.length/2),0,S.length-1),M=function(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}(S),_=a-s;let P=s;const j=S.map((e,t)=>{const n=P,o=t===S.length-1?a:P+(e.share??1)/M*_;return P=o,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:n,x1:o,x:(n+o)/2,width:o-n,y:u,height:d}}),R=j[A],C=R.x0,L=R.x1,I=(e,n)=>{if("lane"===t)return"top"===n?c:l;if("funnel"===t){const t=Xf((e-s)/Math.max(1,a-s),0,1);return"top"===n?c+(m-c)*t:l+(x-l)*t}if(C>=e){const t=Xf((e-s)/Math.max(1,C-s),0,1);return"top"===n?c+(m-c)*t:l+(x-l)*t}if(L>=e)return"top"===n?m:x;const o=Xf((e-L)/Math.max(1,a-L),0,1);return"top"===n?m+(c-m)*o:x+(l-x)*o},T=j.map(e=>{const t=Math.min(I(e.x0,"top"),I(e.x1,"top")),n=Math.max(I(e.x0,"bottom"),I(e.x1,"bottom"));return{...e,y:(t+n)/2,height:Math.max(1,n-t)}}),$={thickness:k,friction:v,restitution:w},z=[];"lane"===t?z.push(Uf(b+"-top",s,c,a,c,$),Uf(b+"-bottom",s,l,a,l,$),Uf(b+"-left",s,c,s,l,{...$,thickness:Math.max(6,k-2)}),Uf(b+"-right",a,c,a,l,{...$,thickness:Math.max(6,k)})):"funnel"===t?z.push(Uf(b+"-top",s,c,a,m,$),Uf(b+"-bottom",s,l,a,x,$),Uf(b+"-left",s,c,s,l,{...$,thickness:Math.max(6,k-2)}),Uf(b+"-right",a,m,a,x,{...$,thickness:Math.max(6,k)})):z.push(Uf(b+"-left-top",s,c,C,m,$),Uf(b+"-left-bottom",s,l,C,x,$),Uf(b+"-center-top",C,m,L,m,$),Uf(b+"-center-bottom",C,x,L,x,$),Uf(b+"-right-top",L,m,a,c,$),Uf(b+"-right-bottom",L,x,a,l,$),Uf(b+"-left",s,c,s,l,{...$,thickness:Math.max(6,k-2)}),Uf(b+"-right",a,c,a,l,{...$,thickness:Math.max(6,k)}));const E=e.membraneDampingScale??.5,O=s,D=Math.max(1,("bowtie"===t?C:a)-O),B=(e.membranes??[]).map(e=>{const t=O+Xf(e.offset,0,1)*D,n=e.width??18+18*e.cost,o=d-16,r=u+.25*(e.wobble??0);return{...e,x:t,y:r,width:n,height:o}}),F=!1===e.includeMembraneRegions?[]:B.map(e=>function(e){const t=e.dampingScale??.5,n=e.energyScale??1,o=Xf(e.cost,0,2);return{...Kf({...e,kind:e.kind??"membrane",attributes:{primitive:"membrane",membraneCost:o,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:o*t,energyDelta:-o*n}}({id:e.id,label:e.label??e.id,description:e.description??(e.label??e.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??E,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:n,height:o,padX:r,padY:i,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:C,centerRight:L,pinchHeight:y,pinchTop:m,pinchBottom:x,stages:T,membranes:B,colliders:z,regionEffects:F,boundaryY:I}}({width:n[0],height:n[1],shape:"lane",padX:Math.max(28,o.plot.x),padY:Math.max(36,o.plot.y+8),stages:m,idPrefix:"process-flow",includeMembraneRegions:!1,friction:.48,restitution:.14}),b=new Map(x.stages.map((e,t)=>[e.id,t])),v=new Map(x.stages.map(e=>[e.id,e])),w=x.stages[0].id,k=x.stages[0],S=new Set(t.filter(e=>e.absorb).map(e=>e.id)),A=t.map(e=>{const t=v.get(e.id)??k;return function(e,t){const n={id:"process-stage-"+e.id,label:e.label??e.id,description:e.description,x:t.x,y:t.y,width:Math.max(12,.92*t.width),height:Math.max(40,.88*t.height),semanticItem:!1,attributes:{stageId:e.id}};if(e.absorb)return function(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...Kf({...e,kind:e.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.02,charge:e.charge??"absorbed"}}({...n,kind:e.kind??"sink",force:Qf(e.force,28),damping:e.damping??.04,charge:"absorbed",attributes:{...n.attributes,primitive:"absorb"}});if(e.portal){const t=e.portal.force??e.force??{x:-40,y:0};return o={...n,kind:e.kind??"force-field",force:Qf(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...n.attributes,primitive:"portal",targetStage:e.portal.targetStageId}},{...Kf({...o,kind:o.kind??"force-field",attributes:{primitive:"portal",targetStage:o.targetStage,..."object"==typeof o.attributes&&o.attributes?o.attributes:{}}}),force:o.force,impulseOnEnter:o.impulseOnEnter,damping:o.damping??.08}}var o;if(e.capacity){const t=Math.max(.1,e.capacity.unitsPerSecond);return function(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...Kf({...e,kind:e.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:e.capacity,unitsPerSecond:e.unitsPerSecond??e.capacity,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping,charge:e.charge??e.capacity}}({...n,kind:e.kind??"force-field",capacity:t,unitsPerSecond:t,force:Qf(e.force,10+.8*t),damping:e.damping??Math.max(.04,.32-.01*t),attributes:{...n.attributes,unitAccessor:e.capacity.unitAccessor,reviewerCapacity:t}})}if(e.pressure){const t="object"==typeof e.pressure&&e.pressure?e.pressure:{};return function(e){const t=e.pressure??e.occupancy??0,n=e.baseDamping??.08,o=e.dampingPerUnit??.12,r=e.energyPerUnit??0;return{...Kf({...e,kind:e.kind??"membrane",attributes:{primitive:"pressureField",pressure:t,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:n+t*o,energyDelta:r?-t*r:void 0,force:e.force}}({...n,kind:e.kind??"membrane",pressure:t.pressure,occupancy:t.occupancy,baseDamping:t.baseDamping??e.damping??.1,dampingPerUnit:t.dampingPerUnit??.1,energyPerUnit:t.energyPerUnit??0,force:Qf(e.force,8),attributes:{...n.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?Zf({...n,kind:e.kind??"force-field",force:Qf(e.force,14),damping:e.damping??.02,attributes:{...n.attributes,primitive:"routeSurface"}}):function(e){return{...Kf({...e,kind:e.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:e.force,damping:e.damping,energyDelta:e.energyDelta}}({...n,kind:e.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...n.attributes,primitive:"forceField"}})}(e,{x:t.x,y:x.midY,width:t.width,height:x.bottomY-x.topY})});A.unshift(Zf({id:"process-flow-route",label:"process route",description:"Baseline conveyor along the process lane.",x:(x.left+x.right)/2,y:x.midY,width:x.right-x.left,height:x.bottomY-x.topY-12,force:8,damping:.012,semanticItem:!1}));const M=new Map;for(const e of x.stages)M.set(e.id,0);const _=[];e.data.forEach((e,t)=>{const n=(a?xh(e,t,a)??e.id??"process-flow-"+t:e.id??"process-flow-"+t)+"",o=(xh(e,t,c)??w)+"",i=b.has(o)?o:w;M.set(i,(M.get(i)??0)+1);const s=l?(xh(e,t,l)??"")+"":void 0,f=s&&u?(xh(e,t,u)??s)+"":s,p=d?bh(xh(e,t,d))??1:1,y=h?bh(xh(e,t,h)):null,g=vh(null!=y&&y>0?y:r,2,18);_.push({datum:e,id:n,stageId:i,groupId:s||void 0,groupLabel:f||void 0,work:p,radius:g,index:t})});const P=new Map,j=new Map;for(const e of _){if(!e.groupId)continue;const t=P.get(e.groupId)??[];t.push(e.id),P.set(e.groupId,t),e.groupLabel&&j.set(e.groupId,e.groupLabel)}const R=vh(e.groupAnchorAlong??.55,.15,.9),C=x.left+(x.right-x.left)*R,L=Array.from(P.keys()),I=L.map((e,n)=>{const o=P.get(e)??[],r=L.length>1?x.topY+28+n/Math.max(1,L.length-1)*(x.bottomY-x.topY-56):x.midY;return function(e){const t=e.x??e.anchor?.x??0,n=e.y??e.anchor?.y??0;return{id:e.id,label:e.label,description:e.description,group:e.group,bodyIds:e.bodyIds,datum:e.datum,state:e.state,x:t,y:n,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:n},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}({id:e,label:j.get(e)??e,bodyIds:o,anchor:{x:C,y:r},x:C,y:r,completion:"allAbsorbed"===f?{mode:"allMembersAbsorbed",targetZone:t.find(e=>e.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),T=function(e,t){const n=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],o=t.filter(e=>!n.has(e)),r=t.length-o.length,i=e.completion?.mode??"allMembersAbsorbed",s=e.completion?.valueByBodyId,a=e=>{const t=s?.[e];return Number.isFinite(t)&&Number(t)>=0?Number(t):1},c=t.reduce((e,t)=>e+a(t),0),l=t.reduce((e,t)=>e+(n.has(t)?a(t):0),0),u=e.completion?.threshold,d="threshold"===i?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:e.id,label:e.label??e.id,mode:i,complete:t.length>0&&("anyAbsorbed"===i?r>0:"threshold"===i?l>=(d??c):0===o.length),absorbed:r,total:t.length,absorbedValue:l,totalValue:c,threshold:d,missing:o}})}(I,_.filter(e=>S.has(e.stageId)).map(e=>e.id)),$=new Map(I.map(e=>[e.id,e])),z=_.map((e,t)=>{const n=v.get(e.stageId)??k,o=n.x+(s()-.5)*Math.min(24,.2*n.width),r=x.boundaryY(o,"top")+e.radius+10,i=x.boundaryY(o,"bottom")-e.radius-10,a=i>r?r+s()*Math.max(1,i-r):x.midY,c=g?o:x.left+18+t%7*4,l=g?a:x.midY+(s()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:o,y:a},restLength:.45*e.radius,stiffness:p,damping:y}];if(e.groupId){const t=$.get(e.groupId);t?.anchor&&!S.has(e.stageId)&&u.push({target:{type:"point",x:t.anchor.x,y:t.anchor.y},restLength:t.tether?.restLength??22,stiffness:t.tether?.stiffness??.05,damping:.8})}return{id:e.id,x:c,y:l,vx:g?0:40+40*s(),vy:g?0:20*(s()-.5),mass:1,shape:{type:"circle",radius:e.radius},spawnAt:g?0:.03*t,springs:u,datum:{...e.datum,id:e.id,stage:e.stageId,groupId:e.groupId,groupLabel:e.groupLabel,work:e.work,__processFlow:!0}}}),E={kernel:{seed:i,gravity:{x:e.gravityX??22,y:e.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:x.colliders,fixedDt:1/60,maxSubsteps:8},O=x.stages.map(e=>({label:e.label??e.id,value:M.get(e.id)??0})),D=t.map(e=>{const t=v.get(e.id)??k;return{id:e.id,label:e.label??e.id,x:t.x,width:t.width,count:M.get(e.id)??0,capacity:e.capacity?.unitsPerSecond,absorb:!0===e.absorb,portalTarget:e.portal?.targetStageId}});return{config:E,initialSpawns:z,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:O,metadata:{kind:"process-flow",plot:o.plot,volume:x,stages:D,groups:I,groupCompletion:T,regionEffects:A}}}var ep=require("d3-scale");function tp(e,t,n){return he(e,t,n)}function np(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&me(n,e)||"#4e79a7":t=>{if(n){const e=me(n,t);if(e)return e}let o=0;for(let e=0;t.length>e;e++)o=31*o+t.charCodeAt(e)|0;return e[Math.abs(o)%e.length]??"#4e79a7"}}function op(e,t){const n=t.config??{},o=(t.sensors??[]).map(e=>({...e,sensor:!0})),r=[...t.colliders??[],...o],i=[...e.colliders??[],...n.colliders??[],...r];return{...e,...n,observation:{...e.observation,...n.observation},...i.length>0&&{colliders:i}}}function rp(e){const t=up(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 ip(e,t,n,o){return n?"function"==typeof n?n(e,t):e[n]??o:o}function sp(e){return`gauntlet:${e}:core`}function ap(e,t){return`gauntlet:${e}:positive:${t}`}function cp(e,t,n){return`gauntlet:${e}:negative:${t}:${n}`}var lp={left:28,top:76,rightInset:30,thickness:8};function up(e){const t=e.height??e.floorY+36;if(e.width>=220&&t>=160)return lp;const n=Math.max(1,Math.min(e.width,t)),o=Math.max(2,.04*e.width);return{left:o,top:Math.max(2,.08*t),rightInset:o,thickness:Math.max(1,Math.min(4,.04*n))}}function dp(e){return Math.max(.12,Math.min(1,e.width/500,(e.height??e.floorY+36)/260))}function hp(e,t,n,o){const r=up(o),i=Math.max(2,n+2),s=r.top+r.thickness/2+i,a=o.floorY-i,c=(e,t,n)=>t>n?(t+n)/2:Math.max(t,Math.min(n,e));return{x:c(e,r.left+r.thickness/2+i,o.width-r.rightInset-r.thickness/2-i),y:c(t,s,a)}}function fp(e,t,n=1){const o=[...e].sort((e,t)=>e.localeCompare(t)),r=Math.max(0,o.indexOf(t));return{angle:.82*-Math.PI+(o.length>1?r/(o.length-1):.5)*Math.PI*.64,index:r,radius:(48+r%2*6)*n}}function pp(e,t,n){const o=e.activePositiveIds.reduce((e,n)=>e+(t.get(n)?.value??1),0),r=e.missingPositiveIds.length+e.poppedPositiveIds.length,i=e.negativeIds.reduce((e,t)=>e+(n.get(t)?.load??1),0);return Math.max(0,Math.min(100,75+3*o-8*i-1.2*e.delay-5*r))}function yp(e){const t=function(e,t,n){const[o,r]=e,i=220>o||160>r,s=Math.round(.48*r),a=i?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*o,d=l>1?(.78*o-u)/(l-1):0,h=i?Math.max(Math.round(.12*o),.08*o+6):Math.max(Math.round(.14*o),110);return{crashY:a-(i?Math.min(n,Math.max(3,.22*r)):n),floorY:a,gates:c.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(u+t*d),width:e.width??Math.max(i?8:54,Math.round(.07*o))})),graveyardX:Math.round(o*(i?.72:.84)),graveyardY:a-4,height:r,routeY:s,socketX:Math.round(o*(i?.82:.92)),startX:h,width:o}}(e.size??[900,520],e.gates,e.crashOffset??30),n=e.positiveProperties??[],o=new Map(n.map(e=>[e.id,e])),r=new Map((e.negativeProperties??[]).map(e=>[e.id,e])),i={idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor},s=(e.data??[]).map((t,s)=>{const a=function(e,t,n,o,r){const i=ip(e,t,n.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",s=o.map(e=>e.id),a=[...ip(e,t,n.positiveAccessor,s)],c=[...ip(e,t,n.negativeAccessor,[])].filter(e=>r.has(e));return{id:i,activePositiveIds:a,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...ip(e,t,n.metricsAccessor,{})},missingPositiveIds:s.filter(e=>!a.includes(e)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(ip(e,t,n.startTimeAccessor,0))||0),stage:"project filed",viability:ip(e,t,n.initialViability,100)}}(t,s,i,n,r);return{...a,viability:e.viability?.(a,{negativeProperties:r,positiveProperties:o})??pp(a,o,r)}}),a=s.flatMap((n,i)=>{const s=function(e,t,n,o){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}}(n),i=o?.(e,t,n)??{};return{...r,...i,startY:i.startY??i.routeY??r.startY,socketY:i.socketY??i.routeY??r.socketY,graveyardY:i.graveyardY??r.graveyardY}}(n,i,t,e.projectPlacement);return function(e,t,n,o,r,i,s){const a=dp(n),c=Math.max(3,28*a),l=o.startX,u=o.startY+(o.startY===n.routeY?38*t*a:0),d=s?.(e,t,n,o)??{},h=d.x??l,f=d.y??u,p={__gauntlet:!0,kind:"gauntlet-core",projectId:e.id,sourceDatum:e.datum},y=[{...d,id:sp(e.id),x:h,y:f,vx:d.vx??42,vy:d.vy??0,mass:d.mass??7,bodyCollisions:d.bodyCollisions??!0,shape:d.shape??{type:"circle",radius:c},spawnAt:d.spawnAt??e.startedAt,datum:p}],g=hp(h,f,d.shape&&"radius"in d.shape&&Number(d.shape.radius)||c,n);y[0].x=g.x,y[0].y=g.y;for(const t of e.activePositiveIds){const o=r.get(t);if(!o)continue;const i=fp(e.activePositiveIds,t,a),s=o.radius??Math.max(2,10*a),c=hp(g.x+Math.cos(i.angle)*i.radius,g.y+Math.sin(i.angle)*i.radius,s,n);y.push({id:ap(e.id,t),x:c.x,y:c.y,vx:18*Math.cos(i.angle),vy:18*Math.sin(i.angle),mass:o.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:d.spawnAt??e.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:e.id,property:o,sourceDatum:e.datum},springs:!1===o.spring?[]:[{target:{type:"body",bodyId:sp(e.id)},stiffness:.56,damping:.9,restLength:Math.max(6,(52+i.index%2*4)*a),...o.spring??{}}]})}return e.negativeIds.forEach((t,o)=>{const r=i.get(t);r&&y.push(function(e,t,n,o,r,i,s){const a=dp(i),c=t.radius??Math.max(2,7.2*a),l=hp(o+(n%4*12-12)*a,r+(54+12*Math.floor(n/4))*a,c,i);return{id:cp(e.id,t.id,n),x:l.x,y:l.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:c},spawnAt:s,datum:{__gauntlet:!0,kind:"gauntlet-negative",projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:sp(e.id)},stiffness:.62,damping:.92,restLength:Math.max(6,(52+n%4*3)*a),...t.spring??{}}]}}(e,r,o,g.x,g.y,n,d.spawnAt??e.startedAt))}),y}(n,i,t,s,o,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:rp(t)}}}var gp=1e-9;function mp(e,t){return t>e?-1:e>t?1:0}function xp(e){return{...e}}function bp(e){return e.map(e=>({...e,sourceIds:e.sourceIds?[...e.sourceIds]:void 0,productIds:e.productIds?[...e.productIds]:void 0,relationIds:e.relationIds?[...e.relationIds]:void 0,outletIds:e.outletIds?[...e.outletIds]:void 0}))}function vp(e){const t=Object.fromEntries(Object.entries(e.components).map(([e,t])=>[e,{...t,initialMetrics:xp(t.initialMetrics),metrics:xp(t.metrics),productIds:[...t.productIds],history:bp(t.history)}])),n=Object.fromEntries(Object.entries(e.products).map(([e,t])=>[e,{...t,metrics:xp(t.metrics),sourceIds:[...t.sourceIds],history:bp(t.history)}])),o=Object.fromEntries(Object.entries(e.relations).map(([e,t])=>[e,{...t,sourceIds:[...t.sourceIds],metrics:t.metrics?xp(t.metrics):void 0}]));return{...e,eventsApplied:[...e.eventsApplied],components:t,products:n,relations:o,input:{amount:e.input.amount,metrics:xp(e.input.metrics)},metrics:xp(e.metrics),loss:{amount:e.loss.amount,metrics:xp(e.loss.metrics)},history:bp(e.history)}}function wp(e,t,n,o,r){return{severity:e,code:t,message:n,path:o,ids:r?[...r]:void 0}}function kp(e){const t=new Set,n=new Set;for(const o of e)t.has(o)&&n.add(o),t.add(o);return[...n].sort(mp)}function Sp(e,t){return e?Object.entries(e).flatMap(([e,n])=>Number.isFinite(n)?[]:[wp("error","invalid-metric",`Metric "${e}" must be a finite number.`,`${t}.${e}`)]):[]}function Ap(e,t){for(const[n,o]of Object.entries(t))e[n]=Number(e[n]??0)+o}function Mp(e,t,n="selector"){const o=[],r=Object.values(e.components),i=new Set(r.map(e=>e.id)),s=(t.ids??[]).filter(e=>!i.has(e));if(s.length&&o.push(wp("error","unknown-component",`Selector references unknown component id${1===s.length?"":"s"}: ${s.join(", ")}.`,n+".ids",s)),void 0===t.count||Number.isInteger(t.count)&&t.count>=0||o.push(wp("error","invalid-selector-count","Selector count must be a non-negative integer.",n+".count")),o.some(e=>"error"===e.severity))return{ids:[],diagnostics:o};const a=t.ids?new Set(t.ids):null,c=t.categories?new Set(t.categories):null,l=t.statuses?new Set(t.statuses):null,u=t.outletIds?new Set(t.outletIds):null;let d=r.filter(e=>!a||a.has(e.id)).filter(e=>!c||c.has(e.category)).filter(e=>!l||l.has(e.status)).filter(e=>!u||void 0!==e.outletId&&u.has(e.outletId)).map(e=>e.id).sort(mp);return void 0!==t.count&&(d=d.slice(0,t.count)),d.length||o.push(wp("warning","empty-selector","Selector matched no source components.",n)),{ids:d,diagnostics:o}}function _p(e,t,n={}){return{eventId:e.event.id,effectType:t.type,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,label:e.event.label,summary:e.event.summary,...n}}function Pp(e,t){const n={...t,eventId:e.event.id};e.materializations.push(n),e.observations.push({...n,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt})}function jp(e,t,n){return!(void 0!==t&&!e.outletIds.has(t)&&(e.diagnostics.push(wp("error","unknown-outlet",`Unknown outlet "${t}".`,n,[t])),1))}function Rp(e,t,n){const o=kp(t);t.length||e.diagnostics.push(wp("error","empty-source-list","A product requires at least one source component.",n)),o.length&&e.diagnostics.push(wp("error","duplicate-source",`Source ids may appear only once: ${o.join(", ")}.`,n,o));const r=t.filter(t=>!e.state.components[t]);r.length&&e.diagnostics.push(wp("error","unknown-component",`Unknown source component id${1===r.length?"":"s"}: ${r.join(", ")}.`,n,r));const i=t.filter(t=>(e.state.components[t]?.productIds.length??0)>0);i.length&&e.diagnostics.push(wp("error","source-already-assigned",`Source component${1===i.length?" is":"s are"} already assigned: ${i.join(", ")}.`,n,i));const s=t.filter(t=>"consumed"===e.state.components[t]?.status&&!i.includes(t));return s.length&&e.diagnostics.push(wp("error","source-unavailable",`Consumed source component${1===s.length?" is":"s are"} unavailable: ${s.join(", ")}.`,n,s)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}function Cp(e,t,n,o,r){const i=o?.amount??0;(!Number.isFinite(i)||0>i||i>t+gp)&&e.diagnostics.push(wp("error","invalid-loss","Loss amount must be finite, non-negative, and no greater than its sources.",r+".amount")),e.diagnostics.push(...Sp(o?.metrics,r+".metrics"));for(const[t,i]of Object.entries(o?.metrics??{}))(0>i||i>Number(n[t]??0)+gp)&&e.diagnostics.push(wp("error","invalid-metric-loss",`Metric loss "${t}" must be non-negative and no greater than its sources.`,`${r}.metrics.${t}`));return!e.diagnostics.some(e=>"error"===e.severity)}function Lp(e,t,n,o,r,i,s){return{id:e.id,label:e.label??e.id,description:e.description,category:e.category??"product",color:e.color,order:e.order,declaredAmount:e.amount,amount:i&&void 0!==e.amount?e.amount:n,metrics:i&&e.metrics?{...o,...e.metrics}:o,status:i?"complete":"forming",sourceIds:[...t],outletId:i?e.outletId??(r.outletIds.has("product")?"product":void 0):void 0,createdByEventId:r.event.id,createdAt:r.context.appliedAt,completedByEventId:i?r.event.id:void 0,completedAt:i?r.context.appliedAt:void 0,history:[s]}}function Ip(e,t,n,o){void 0!==t.amount&&Math.abs(t.amount-n)>gp&&e.diagnostics.push(wp("warning","declared-product-amount-mismatch",`Product "${t.id}" declares ${t.amount}, while its sources yield ${n}.`,o,[t.id]))}function Tp(e,t,n){const o=`events.${e.event.id}.effects.${n}`,r=e.state;if("set-state"===t.type){["queued","active","transformed","retained","ejected","failed","recovered"].includes(t.state)||e.diagnostics.push(wp("error","invalid-component-state",`set-state cannot assign "${t.state+""}".`,o+".state")),e.diagnostics.push(...Sp(t.metricsDelta,o+".metricsDelta")),jp(e,t.outletId,o+".outletId");const n=Mp(r,t.select,o+".select");e.diagnostics.push(...n.diagnostics);const i=n.ids.filter(e=>r.components[e].productIds.length);if(i.length&&e.diagnostics.push(wp("error","source-already-assigned",`Assigned source components cannot be retargeted: ${i.join(", ")}.`,o+".select",i)),e.diagnostics.some(e=>"error"===e.severity))return;const s=_p(e,t,{sourceIds:n.ids,outletIds:t.outletId?[t.outletId]:void 0});for(const e of n.ids){const n=r.components[e];n.status=t.state,n.outletId=t.outletId,n.reason=t.reason,t.metricsDelta&&Ap(n.metrics,t.metricsDelta),n.history.push(s)}return r.history.push(s),void(n.ids.length&&Pp(e,{type:"retarget-component",sourceIds:n.ids,outletIds:t.outletId?[t.outletId]:void 0}))}if("set-relation"===t.type){const{relation:n}=t;n.id&&!r.relations[n.id]||e.diagnostics.push(wp("error","duplicate-relation",`Relation id "${n.id}" is missing or already active.`,o+".relation.id",[n.id]));const i=function(e,t,n){const o=kp(t),r=t.filter(t=>!e.state.components[t]);return 2>t.length&&e.diagnostics.push(wp("error","insufficient-relation-sources","A relation requires at least two source components.",n)),o.length&&e.diagnostics.push(wp("error","duplicate-source",`Relation source ids must be unique: ${o.join(", ")}.`,n,o)),r.length&&e.diagnostics.push(wp("error","unknown-component",`Relation references unknown source component${1===r.length?"":"s"}: ${r.join(", ")}.`,n,r)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}(e,n.sourceIds,o+".relation.sourceIds");if(e.diagnostics.push(...Sp(n.metrics,o+".relation.metrics")),!i||e.diagnostics.some(e=>"error"===e.severity))return;r.relations[n.id]={...n,sourceIds:[...n.sourceIds],metrics:n.metrics?{...n.metrics}:void 0,status:"active",createdByEventId:e.event.id,createdAt:e.context.appliedAt};const s=_p(e,t,{sourceIds:[...n.sourceIds],relationIds:[n.id]});return r.history.push(s),void Pp(e,{type:"activate-relation",sourceIds:[...n.sourceIds],relationIds:[n.id]})}if("resolve-relation"===t.type){const n=kp(t.relationIds),i=t.relationIds.filter(e=>!r.relations[e]),s=t.relationIds.filter(e=>"resolved"===r.relations[e]?.status);if(n.length&&e.diagnostics.push(wp("error","duplicate-relation","Relation ids must be unique.",o+".relationIds",n)),i.length&&e.diagnostics.push(wp("error","unknown-relation",`Unknown relation: ${i.join(", ")}.`,o+".relationIds",i)),s.length&&e.diagnostics.push(wp("error","resolved-relation",`Relation is already resolved: ${s.join(", ")}.`,o+".relationIds",s)),e.diagnostics.some(e=>"error"===e.severity))return;for(const n of t.relationIds){const o=r.relations[n];o.status="resolved",o.resolution=t.resolution,o.resolvedByEventId=e.event.id,o.resolvedAt=e.context.appliedAt,o.reason=t.reason}const a=_p(e,t,{relationIds:[...t.relationIds]});return r.history.push(a),void Pp(e,{type:"resolve-relation",relationIds:[...t.relationIds]})}if("combine"===t.type||"contribute"===t.type){const n=e.productDefinitions.get(t.productId);n||e.diagnostics.push(wp("error","unknown-product",`Product "${t.productId}" has no declared mold.`,o+".productId",[t.productId]));const i=r.products[t.productId];"combine"===t.type&&i&&e.diagnostics.push(wp("error","duplicate-product",`Product "${t.productId}" has already been formed.`,o+".productId",[t.productId])),"contribute"!==t.type||i&&"forming"===i.status||e.diagnostics.push(wp("error","product-not-forming",`Contributions require an existing forming product "${t.productId}".`,o+".productId",[t.productId]));const s=Rp(e,t.sourceIds,o+".sourceIds"),a="contribute"===t.type&&i?[...i.sourceIds,...t.sourceIds]:t.sourceIds,c=function(e,t,n,o){if(!t?.length)return[];const r=kp(t),i=t.filter(t=>!e.state.relations[t]),s=t.filter(t=>"resolved"===e.state.relations[t]?.status),a=new Set(n),c=t.filter(t=>(e.state.relations[t]?.sourceIds??[]).some(e=>!a.has(e)));return r.length&&e.diagnostics.push(wp("error","duplicate-relation","Basis relations must be unique.",o,r)),i.length&&e.diagnostics.push(wp("error","unknown-relation",`Unknown basis relation: ${i.join(", ")}.`,o,i)),s.length&&e.diagnostics.push(wp("error","resolved-relation",`Basis relation is already resolved: ${s.join(", ")}.`,o,s)),c.length&&e.diagnostics.push(wp("error","relation-source-mismatch",`Basis relation includes a source outside this product: ${c.join(", ")}.`,o,c)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.relations[t])}(e,t.basisRelationIds,a,o+".basisRelationIds");if(!s||!c||!n||e.diagnostics.some(e=>"error"===e.severity))return;const l=s.reduce((e,t)=>e+t.amount,0),u=function(e){const t={};for(const n of e)Ap(t,n.metrics);return t}(s);if(!Cp(e,l,u,t.loss,o+".loss"))return;const d=l-(t.loss?.amount??0);!function(e,t,n){e.state.loss.amount+=n?.amount??0;for(const[o,r]of Object.entries(n?.metrics??{}))t[o]=Number(t[o]??0)-r,e.state.loss.metrics[o]=Number(e.state.loss.metrics[o]??0)+r}(e,u,t.loss);const h="combine"===t.type&&!1!==t.complete,f=_p(e,t,{sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0});let p;if("combine"===t.type){if(h&&Ip(e,n,d,o+".productId"),p=Lp(n,t.sourceIds,d,u,e,h,f),h&&!jp(e,p.outletId,o+".productId"))return;r.products[t.productId]=p}else p=i,p.sourceIds.push(...t.sourceIds),p.amount+=d,Ap(p.metrics,u),p.history.push(f);for(const e of s)e.productIds=[t.productId],e.status="consumed",e.outletId=void 0,e.history.push(f);return r.history.push(f),function(e,t){if(t.length){for(const n of t)n.status="resolved",n.resolution="combined",n.resolvedByEventId=e.event.id,n.resolvedAt=e.context.appliedAt;Pp(e,{type:"resolve-relation",relationIds:t.map(e=>e.id)})}}(e,c),Pp(e,{type:"combine"===t.type?"form-product":"update-product",sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0,outletIds:p.outletId?[p.outletId]:void 0}),void(h&&Pp(e,{type:"complete-product",sourceIds:[...p.sourceIds],productIds:[p.id],outletIds:p.outletId?[p.outletId]:void 0}))}if("complete-product"===t.type){const n=r.products[t.productId];return n?void function(e,t,n,o,r,i){const s=e.productDefinitions.get(t.id),a=n??s?.outletId??(e.outletIds.has("product")?"product":void 0);if(!jp(e,a,i+".outletId"))return;if("complete"===t.status)return void e.diagnostics.push(wp("error","product-already-complete",`Product "${t.id}" is already complete.`,i,[t.id]));s&&(Ip(e,s,t.amount,i+".productId"),void 0!==s.amount&&(t.amount=s.amount),s.metrics&&(t.metrics={...t.metrics,...s.metrics})),t.status="complete",t.outletId=a,t.reason=o,t.completedByEventId=e.event.id,t.completedAt=e.context.appliedAt;const c=_p(e,r,{sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:a?[a]:void 0});t.history.push(c),e.state.history.push(c),Pp(e,{type:"complete-product",sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:a?[a]:void 0})}(e,n,t.outletId,t.reason,t,o):void e.diagnostics.push(wp("error","unknown-product-state",`Product "${t.productId}" has not been formed.`,o+".productId",[t.productId]))}if("split"===t.type){const n=Rp(e,[t.sourceId],o+".sourceId");t.products.length||e.diagnostics.push(wp("error","empty-split","A split requires at least one product allocation.",o+".products"));const i=t.products.map(e=>e.productId),s=kp(i);s.length&&e.diagnostics.push(wp("error","duplicate-product","Split product ids must be unique.",o+".products",s));const a=i.map(t=>e.productDefinitions.get(t)),c=i.filter((e,t)=>!a[t]),l=i.filter(e=>r.products[e]);c.length&&e.diagnostics.push(wp("error","unknown-product",`Split references undeclared product molds: ${c.join(", ")}.`,o+".products",c)),l.length&&e.diagnostics.push(wp("error","duplicate-product",`Split products already exist: ${l.join(", ")}.`,o+".products",l));for(const[n,r]of t.products.entries())void 0===r.amount||Number.isFinite(r.amount)&&r.amount>=0||e.diagnostics.push(wp("error","invalid-product-amount","Split allocation amounts must be finite and non-negative.",`${o}.products.${n}.amount`)),e.diagnostics.push(...Sp(r.metrics,`${o}.products.${n}.metrics`));if(!n?.length||e.diagnostics.some(e=>"error"===e.severity))return;const u=n[0];if(!Cp(e,u.amount,u.metrics,t.loss,o+".loss"))return;const d=u.amount-(t.loss?.amount??0),h=t.products.map((e,t)=>e.amount??a[t]?.amount),f=h.filter(e=>void 0!==e).length;if(0!==f&&f!==h.length)return void e.diagnostics.push(wp("error","partial-split-allocation","Either every split product must declare an amount or none may do so.",o+".products"));const p=f?h:t.products.map(()=>d/t.products.length),y=p.reduce((e,t)=>e+t,0);if(Math.abs(y-d)>gp)return void e.diagnostics.push(wp("error","split-amount-mismatch",`Split allocations total ${y}, but ${d} remains after loss.`,o+".products"));const g={...u.metrics};for(const[e,n]of Object.entries(t.loss?.metrics??{}))g[e]=Number(g[e]??0)-n;const m=_p(e,t,{sourceIds:[u.id],productIds:i});if(t.products.forEach((n,i)=>{const s=a[i],c=d>gp?p[i]/d:1/t.products.length,l=Object.fromEntries(Object.entries(g).map(([e,t])=>[e,t*c])),h=n.metrics??s.metrics??l,f=Lp({...s,amount:p[i],metrics:h},[u.id],p[i],{...h},e,!0,m);jp(e,f.outletId,`${o}.products.${i}.productId`)&&(r.products[f.id]=f)}),e.diagnostics.some(e=>"error"===e.severity))return;u.productIds=i,u.status="consumed",u.outletId=void 0,u.history.push(m),r.loss.amount+=t.loss?.amount??0;for(const[e,n]of Object.entries(t.loss?.metrics??{}))r.loss.metrics[e]=Number(r.loss.metrics[e]??0)+n;r.history.push(m),Pp(e,{type:"split-source",sourceIds:[u.id],productIds:i});for(const t of i)Pp(e,{type:"complete-product",sourceIds:[u.id],productIds:[t],outletIds:r.products[t].outletId?[r.products[t].outletId]:void 0});return}if("eject"===t.type){jp(e,t.outletId,o+".outletId");const n=Mp(r,t.select,o+".select");e.diagnostics.push(...n.diagnostics);const i=n.ids.filter(e=>r.components[e].productIds.length);if(i.length&&e.diagnostics.push(wp("error","source-already-assigned",`Assigned source components cannot be ejected: ${i.join(", ")}.`,o+".select",i)),e.diagnostics.some(e=>"error"===e.severity))return;const s=_p(e,t,{sourceIds:n.ids,outletIds:[t.outletId]});for(const e of n.ids){const n=r.components[e];n.status=t.state??"ejected",n.outletId=t.outletId,n.reason=t.reason,n.history.push(s)}return r.history.push(s),void(n.ids.length&&Pp(e,{type:"retarget-component",sourceIds:n.ids,outletIds:[t.outletId]}))}if("set-metric"===t.type){if(e.diagnostics.push(...Sp(t.metricsDelta,o+".metricsDelta")),e.diagnostics.some(e=>"error"===e.severity))return;let n,i;if("run"===t.target)Ap(r.metrics,t.metricsDelta);else if("components"in t.target){const i=Mp(r,t.target.components,o+".target.components");if(e.diagnostics.push(...i.diagnostics),e.diagnostics.some(e=>"error"===e.severity))return;n=i.ids;for(const e of i.ids)Ap(r.components[e].metrics,t.metricsDelta)}else{i=[...t.target.productIds];const n=kp(i),s=i.filter(e=>!r.products[e]);if(n.length&&e.diagnostics.push(wp("error","duplicate-product","Metric target product ids must be unique.",o+".target.productIds",n)),s.length&&e.diagnostics.push(wp("error","unknown-product-state",`Metric target product has not formed: ${s.join(", ")}.`,o+".target.productIds",s)),e.diagnostics.some(e=>"error"===e.severity))return;for(const e of i)Ap(r.products[e].metrics,t.metricsDelta)}return void r.history.push(_p(e,t,{sourceIds:n,productIds:i}))}t.outcome.trim()?(r.outcome=t.outcome,r.summary=t.summary,r.history.push(_p(e,t)),e.observations.push({type:"crucible-outcome",eventId:e.event.id,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,outcome:t.outcome})):e.diagnostics.push(wp("error","invalid-outcome","Outcome must be a non-empty string.",o+".outcome"))}function $p(e,t,n){if(e.eventsApplied.includes(t.id))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:[wp("warning","duplicate-event-application",`Event "${t.id}" has already been applied.`,"events."+t.id,[t.id])]};const o=vp(e),r={state:o,event:t,context:n,productDefinitions:new Map(n.products.map(e=>[e.id,e])),outletIds:new Set(n.outlets.map(e=>e.id)),diagnostics:[],materializations:[],observations:[]};for(const[n,o]of t.effects.entries())if(Tp(r,o,n),r.diagnostics.some(e=>"error"===e.severity))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:r.diagnostics};return o.elapsed=Math.max(o.elapsed,n.appliedAt),o.phaseId=n.phaseId,o.eventsApplied.push(t.id),r.observations.unshift({type:"crucible-event",eventId:t.id,phaseId:n.phaseId,authoredAt:n.authoredAt,appliedAt:n.appliedAt}),{applied:!0,state:o,materializations:r.materializations,observations:r.observations,diagnostics:r.diagnostics}}var zp=[900,520],Ep=[{id:"product",label:"Products",side:"bottom",order:0},{id:"retained",label:"Retained",side:"bottom",order:1},{id:"residue",label:"Residue",side:"left",order:2},{id:"failed",label:"Failed",side:"right",order:3},{id:"recovered",label:"Recovered",side:"right",order:4}],Op=new Set(["queued","active","transformed","consumed","retained","ejected","failed","recovered"]),Dp=1e-9;function Bp(e,t){return t>e?-1:e>t?1:0}function Fp(e,t,n,o,r){return{severity:e,code:t,message:n,path:o,ids:r?[...r]:void 0}}function Np(e){const t=new Set,n=new Set;for(const o of e)t.has(o)&&n.add(o),t.add(o);return[...n].sort(Bp)}function Wp(e){const t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function qp(e,t,n,o,r,i){if(!n)return o;try{return("function"==typeof n?n(e,t):e[n])??o}catch(e){return r.push(Fp("error","accessor-error",`Accessor threw: ${e instanceof Error?e.message:e+""}.`,i)),o}}function Yp(e,t,n){if(!e||"object"!=typeof e||Array.isArray(e))return null!=e&&t.push(Fp("error","invalid-metrics","Metrics must be a numeric object.",n)),{};const o={};for(const[r,i]of Object.entries(e)){const e=Wp(i);null!=e?o[r]=e:t.push(Fp("error","invalid-metric",`Metric "${r}" must be finite.`,`${n}.${r}`))}return o}function Gp(e){return e.map((e,t)=>({outlet:e,index:t})).sort((e,t)=>(e.outlet.order??e.index)-(t.outlet.order??t.index)||e.index-t.index).map(({outlet:e})=>({...e}))}function Hp(e){const{id:t,orientation:n,fixed:o,start:r,end:i,openings:s,thickness:a,friction:c,restitution:l}=e,u=function(e,t,n){const o=n.map(([n,o])=>[Math.max(e,Math.min(n,o)),Math.min(t,Math.max(n,o))]).filter(([e,t])=>t>e+Dp).sort((e,t)=>e[0]-t[0]||e[1]-t[1]),r=[];let i=e;for(const[e,t]of o)e>i+Dp&&r.push([i,e]),i=Math.max(i,t);return t>i+Dp&&r.push([i,t]),r}(r,i,s);return u.map(([e,r],i)=>({id:1===u.length?t:`${t}:${i}`,friction:c,restitution:l,shape:"horizontal"===n?{type:"segment",x1:e,y1:o,x2:r,y2:o,thickness:a}:{type:"segment",x1:o,y1:e,x2:o,y2:r,thickness:a}}))}function Vp(e){let t=2166136261;for(let n=0;e.length>n;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function Xp(e){return"number"==typeof e&&Number.isFinite(e)?e>>>0:"string"==typeof e?Vp(e):1}function Up(e,t){return{fixedDt:1/120,maxSubsteps:8,settleStepLimit:7200,colliders:t.map(e=>({...e,shape:{...e.shape}})),observation:{chartType:"crucible"},kernel:{seed:Xp(e),gravity:{x:0,y:0},cellSize:42,collisionIterations:6,velocityDamping:.992,restitution:.12,friction:.42,sleepSpeed:4,sleepAfter:.5,maxVelocity:620}}}function Kp(e){return"crucible:component:"+encodeURIComponent(e)}function Zp(e,t,n,o){if(void 0!==n&&Number.isFinite(n)&&n>0)return n;const r=Math.min(...t,e),i=Math.max(...t,e);return i-r>Dp?o[0]+(o[1]-o[0])*Math.sqrt(Math.max(0,e-r)/(i-r)):(o[0]+o[1])/2}function Qp(e,t){const n=Math.max(.25,Math.min(1,t.width/900,t.height/520)),o=e?.[0]??7*n,r=e?.[1]??18*n,i=Math.max(1,Math.min(o,r));return[i,Math.max(i,Math.max(o,r))]}function Jp(e,t){if(!e)return[];const n=Math.min(e,Math.max(1,Math.ceil(Math.sqrt(e*Math.max(.5,t.width/Math.max(1,t.height)))))),o=Math.max(1,Math.ceil(e/n));return Array.from({length:e},(e,r)=>({x:t.x+t.width/n*(r%n+.5),y:t.y+(Math.floor(r/n)+.5)*(t.height/o)}))}function ey(e){return e.outletId?e.outletId:"failed"===e.status?"failed":"recovered"===e.status?"recovered":"retained"===e.status?"retained":"ejected"===e.status?"residue":void 0}function ty(e,t){return e.outlets.find(e=>e.id===t)||{x:e.chamber.x+.18*e.chamber.width,y:e.chamber.y+.2*e.chamber.height,width:.64*e.chamber.width,height:.6*e.chamber.height}}function ny(e,t,n={}){const o=Object.values(e.products).sort((e,t)=>Bp(e.id,t.id)),r=Object.values(e.components).sort((e,t)=>Bp(e.id,t.id)),i=[...r.map(e=>e.amount),...o.map(e=>e.amount)],s=Qp(n.radiusRange,t),a=function(e,t){const n=new Map;for(const t of e){const e=t.outletId??"__chamber__",o=n.get(e)??[];o.push(t),n.set(e,o)}const o=new Map;for(const[e,r]of n){r.sort((e,t)=>(e.order??Number.MAX_SAFE_INTEGER)-(t.order??Number.MAX_SAFE_INTEGER)||Bp(e.id,t.id));const n=Jp(r.length,ty(t,"__chamber__"===e?void 0:e));r.forEach((e,t)=>o.set(e.id,n[t]))}return o}(o,t),c=o.map(e=>{const o=a.get(e.id)??{x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2},r=1.28*Zp(e.amount,i,n.bodyRadius,s),c={__crucible:!0,kind:"product",semanticId:e.id,product:e};return{id:(l=e.id,"crucible:product:"+encodeURIComponent(l)),x:o.x,y:o.y,mass:Math.max(.25,r*r*.018),bodyCollisions:!1,shape:{type:"circle",radius:r},datum:c};var l}),l=new Map;for(const e of r.filter(e=>!e.productIds.length)){const t=ey(e)??"__chamber__",n=l.get(t)??[];n.push(e),l.set(t,n)}const u=new Map;for(const[e,n]of l){const o=Jp(n.length,ty(t,"__chamber__"===e?void 0:e));n.forEach((e,t)=>u.set(e.id,o[t]))}return[...r.map(e=>{let o=u.get(e.id);if(e.productIds.length){const n=e.productIds.map(e=>a.get(e)).filter(e=>!!e);if(n.length){o={x:n.reduce((e,t)=>e+t.x,0)/n.length,y:n.reduce((e,t)=>e+t.y,0)/n.length};const r=Vp(e.id)/4294967295*Math.PI*2,i=Math.min(20,Math.max(4,.012*t.width));o={x:o.x+Math.cos(r)*i,y:o.y+Math.sin(r)*i}}}o??(o={x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2});const r=Zp(e.amount,i,n.bodyRadius,s),c={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:Kp(e.id),x:o.x,y:o.y,mass:Math.max(.25,r*r*.015),shape:{type:"circle",radius:r},datum:c}}),...c]}var oy=ny;function ry(e){return Array.isArray(e)?e.map(ry):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e&&"function"!=typeof e).sort(([e],[t])=>Bp(e,t)).map(([e,t])=>[e,ry(t)])):e}function iy(e,t=e.duration){const n=function(e,t){const n=Wp(t)??0,o=Math.max(0,Math.min(e.duration,n));if(!e.phases.length)return{elapsed:o,phaseId:"",phaseIndex:-1,phaseElapsed:0,complete:!0};const r=o>=e.duration-Dp,i=r?e.phases[e.phases.length-1]:e.phases.find(e=>o>=e.start&&e.end>o)??e.phases[0];return{elapsed:o,phaseId:i.id,phaseIndex:i.index,phaseElapsed:r?i.duration:Math.max(0,o-i.start),complete:r}}(e,t);let o=vp(e.initialState);const r=[],i=[],s=[];for(const t of e.events){if(t.authoredAt>n.elapsed+Dp)break;const a=$p(o,t,{phaseId:t.phaseId,authoredAt:t.authoredAt,appliedAt:t.authoredAt,products:e.products,outlets:e.outlets});r.push(...a.diagnostics),i.push(...a.materializations),s.push(...a.observations),a.applied&&(o=a.state)}return o.elapsed=n.elapsed,o.phaseId=n.phaseId,o.phaseIndex=n.phaseIndex,o.phaseElapsed=n.phaseElapsed,o.complete=n.complete,n.complete&&"in_process"===o.outcome&&(o.outcome="complete"),o.playing=!1,{state:o,diagnostics:r,materializations:i,observations:s}}function sy(e){const t=function(e){const t=[];e.length||t.push(Fp("error","empty-phase-program","CrucibleChart requires at least one phase.","phases"));const n=Np(e.map(e=>e.id));n.length&&t.push(Fp("error","duplicate-phase-id",`Phase ids must be unique: ${n.join(", ")}.`,"phases",n));let o=0;return{phases:e.map((e,n)=>{const r=Wp(e.duration),i=null!=r&&r>0?r:0;e.id.trim()||t.push(Fp("error","invalid-phase-id","Phase ids may not be empty.",`phases.${n}.id`)),null!=r&&r>0||t.push(Fp("error","invalid-phase-duration","Phase duration must be finite and greater than zero.",`phases.${n}.duration`,[e.id])),void 0===e.intensity||Number.isFinite(e.intensity)||t.push(Fp("error","invalid-phase-intensity","Phase intensity must be finite.",`phases.${n}.intensity`,[e.id]));const s={...e,duration:i,intensity:void 0===e.intensity?.5:Number.isFinite(e.intensity)?Math.max(0,Math.min(1,e.intensity)):.5,motion:e.motion??"hold",index:n,start:o,end:o+i};return o=s.end,s}),diagnostics:t}}(e.phases),n=t.phases.at(-1)?.end??0,o=Gp(e.outlets??Ep),r=(e.products??[]).map(e=>({...e,metrics:e.metrics?{...e.metrics}:void 0})),i=function(e,t,n){const o=[],r=Np(e.map(e=>e.id));r.length&&o.push(Fp("error","duplicate-event-id",`Event ids must be unique: ${r.join(", ")}.`,"events",r));const i=[];return e.forEach((e,r)=>{let s,a,c;if(e.id.trim()||o.push(Fp("error","invalid-event-id","Event ids may not be empty.",`events.${r}.id`)),"time"in e.at&&void 0!==e.at.time){const i=Wp(e.at.time);if(null==i||0>i||i>n+Dp)return void o.push(Fp("error","event-time-out-of-range",`Event time must fall between 0 and ${n}.`,`events.${r}.at.time`,[e.id]));s=Math.max(0,Math.min(n,i));const l=function(e,t,n){const o=e.find(e=>Dp>=Math.abs(e.start-n));if(o)return{phase:o,boundaryRank:1};const r=e.find(e=>n>=e.start&&e.end>n);return r?{phase:r,boundaryRank:0}:Dp>=Math.abs(n-t)&&e.length?{phase:e[e.length-1],boundaryRank:0}:{phase:void 0,boundaryRank:1}}(t,n,s);a=l.phase,c=l.boundaryRank}else{if(a=t.find(t=>t.id===e.at.phaseId),!a)return void o.push(Fp("error","unknown-event-phase",`Event references unknown phase "${e.at.phaseId}".`,`events.${r}.at.phaseId`,[e.id,e.at.phaseId]));const n=e.at.progress??0;if(!Number.isFinite(n)||0>n||n>1)return void o.push(Fp("error","event-progress-out-of-range","Event phase progress must be between 0 and 1.",`events.${r}.at.progress`,[e.id]));s=a.start+a.duration*n,c=0===n?1:0}a?i.push({...e,index:r,authoredAt:s,phaseId:a.id,phaseIndex:a.index,boundaryRank:c}):o.push(Fp("error","event-without-phase","Event could not be assigned to a phase.",`events.${r}.at`,[e.id]))}),i.sort((e,t)=>e.authoredAt-t.authoredAt||e.boundaryRank-t.boundaryRank||e.index-t.index),{events:i,diagnostics:o}}(e.events??[],t.phases,n),s=function(e){const t=[],n={},o=[];let r=0;const i={};e.data.forEach((s,a)=>{const c=(s.id??"component-"+a)+"",l=((qp(s,a,e.idAccessor,c,t,`data.${a}.id`)??c)+"").trim();if(!l)return void t.push(Fp("error","invalid-component-id","Component ids may not be empty.",`data.${a}.id`));o.push(l);const u=Wp(qp(s,a,e.amountAccessor,1,t,`data.${a}.amount`)),d=null==u||0>u?0:u;(null==u||0>u)&&t.push(Fp("error","invalid-component-amount","Component amount must be finite and non-negative.",`data.${a}.amount`,[l]));const h=Yp(qp(s,a,e.metricsAccessor,{},t,`data.${a}.metrics`),t,`data.${a}.metrics`),f=qp(s,a,e.initialStateAccessor,"active",t,`data.${a}.status`),p=Op.has(f)?f:"active";Op.has(f)||t.push(Fp("error","invalid-component-status",`Unknown component status "${f+""}".`,`data.${a}.status`,[l]));const y=qp(s,a,e.labelAccessor,(s.label??s.name??l)+"",t,`data.${a}.label`)+"",g=qp(s,a,e.categoryAccessor,"component",t,`data.${a}.category`)+"";n[l]||(n[l]={id:l,label:y,category:g,datum:s,status:p,initialAmount:d,amount:d,initialMetrics:{...h},metrics:{...h},productIds:[],history:[]},r+=d,function(e,t){for(const[n,o]of Object.entries(t))e[n]=Number(e[n]??0)+o}(i,h))});const s=Np(o);s.length&&t.push(Fp("error","duplicate-component-id",`Component ids must be unique: ${s.join(", ")}.`,"data",s));const a=Yp(e.metrics??{},t,"metrics");return{state:{elapsed:0,phaseElapsed:0,phaseId:e.phases[0]?.id??"",phaseIndex:e.phases.length?0:-1,playing:!1,complete:0===e.phases.length,outcome:"in_process",eventsApplied:[],components:n,products:{},relations:{},input:{amount:r,metrics:i},metrics:a,loss:{amount:0,metrics:{}},history:[]},diagnostics:t}}(e),a=function(e=zp,t=Ep){const n=Math.max(1,Wp(e[0])??900),o=Math.max(1,Wp(e[1])??520),r=360>n||260>o,i=r?Math.max(4,.035*Math.min(n,o)):20,s=r?Math.max(10,.075*o):34,a={x:i,y:i,width:Math.max(1,n-2*i),height:s},c=r?Math.max(16,.14*o):Math.min(78,.16*o),l={x:i,y:o-i-c,width:Math.max(1,n-2*i),height:c},u=r?Math.max(12,.08*n):Math.min(150,.17*n),d=a.y+a.height+(r?12:38),h=l.y-(r?10:34),f={x:u,y:d,width:Math.max(24,n-2*u),height:Math.max(24,h-d)},p=Math.max(18,Math.min(.32*f.width,r?84:180)),y={x:f.x+(f.width-p)/2,y:f.y-(r?10:24),width:p,height:r?12:28},g=Gp(t),m={left:g.filter(e=>"left"===(e.side??"bottom")),right:g.filter(e=>"right"===e.side),bottom:g.filter(e=>"bottom"===(e.side??"bottom"))},x=[],b=(e,t)=>{const o=Math.max(8,u-1.5*i),s=f.height/Math.max(1,t.length);t.forEach((t,a)=>{x.push({...t,side:e,x:"left"===e?i:n-i-o,y:f.y+a*s,width:o,height:Math.max(8,s-(r?2:8))})})};b("left",m.left),b("right",m.right);const v=f.width/Math.max(1,m.bottom.length);return m.bottom.forEach((e,t)=>{x.push({...e,side:"bottom",x:f.x+t*v,y:f.y+f.height+(r?2:7),width:Math.max(8,v-(r?2:8)),height:Math.max(8,l.y-f.y-f.height-(r?4:12))})}),x.sort((e,t)=>g.findIndex(t=>t.id===e.id)-g.findIndex(e=>e.id===t.id)),{width:n,height:o,phaseRail:a,chamber:f,mouth:y,projection:l,outlets:x}}(e.size??zp,o),c=function(e){const{chamber:t,mouth:n}=e,o=Math.max(2,Math.min(10,.018*Math.min(e.width,e.height))),r=Math.max(t.x,n.x),i=Math.min(t.x+t.width,n.x+n.width),s={left:e.outlets.filter(e=>"left"===e.side),right:e.outlets.filter(e=>"right"===e.side),bottom:e.outlets.filter(e=>"bottom"===e.side)},a=[{id:"crucible:wall:top-left",friction:.42,restitution:.1,shape:{type:"segment",x1:t.x,y1:t.y,x2:r,y2:t.y,thickness:o}},{id:"crucible:wall:top-right",friction:.42,restitution:.1,shape:{type:"segment",x1:i,y1:t.y,x2:t.x+t.width,y2:t.y,thickness:o}}];a.push(...Hp({id:"crucible:wall:left",orientation:"vertical",fixed:t.x,start:t.y,end:t.y+t.height,openings:s.left.map(e=>[e.y,e.y+e.height]),thickness:o,friction:.46,restitution:.12}),...Hp({id:"crucible:wall:right",orientation:"vertical",fixed:t.x+t.width,start:t.y,end:t.y+t.height,openings:s.right.map(e=>[e.y,e.y+e.height]),thickness:o,friction:.46,restitution:.12}),...Hp({id:"crucible:wall:bottom",orientation:"horizontal",fixed:t.y+t.height,start:t.x,end:t.x+t.width,openings:s.bottom.map(e=>[e.x,e.x+e.width]),thickness:o,friction:.5,restitution:.08}));for(const t of e.outlets)a.push({id:"crucible:outlet:"+encodeURIComponent(t.id),sensor:!0,shape:{type:"aabb",x:t.x+t.width/2,y:t.y+t.height/2,width:t.width,height:t.height}});return a}(a),l=function(e,t){const n=[],o=new Set(t.map(e=>e.id)),r=Np(t.map(e=>e.id)),i=Np(e.map(e=>e.id));return r.length&&n.push(Fp("error","duplicate-outlet-id",`Outlet ids must be unique: ${r.join(", ")}.`,"outlets",r)),i.length&&n.push(Fp("error","duplicate-product-id",`Product ids must be unique: ${i.join(", ")}.`,"products",i)),t.forEach((e,t)=>{e.id.trim()||n.push(Fp("error","invalid-outlet-id","Outlet ids may not be empty.",`outlets.${t}.id`)),void 0===e.order||Number.isFinite(e.order)||n.push(Fp("error","invalid-outlet-order","Outlet order must be finite.",`outlets.${t}.order`,[e.id]))}),e.forEach((e,t)=>{e.id.trim()||n.push(Fp("error","invalid-product-id","Product ids may not be empty.",`products.${t}.id`)),void 0===e.amount||Number.isFinite(e.amount)&&e.amount>=0||n.push(Fp("error","invalid-product-amount","Declared product amount must be finite and non-negative.",`products.${t}.amount`,[e.id])),void 0===e.outletId||o.has(e.outletId)||n.push(Fp("error","unknown-outlet",`Product "${e.id}" references unknown outlet "${e.outletId}".`,`products.${t}.outletId`,[e.outletId])),Yp(e.metrics??{},n,`products.${t}.metrics`)}),n}(r,o),u=(d={seed:e.seed??1,components:Object.values(s.state.components).sort((e,t)=>Bp(e.id,t.id)).map(e=>({id:e.id,label:e.label,category:e.category,amount:e.amount,metrics:e.metrics,status:e.status})),phases:t.phases.map(({id:e,duration:t,label:n,description:o,intensity:r,motion:i,color:s,metrics:a})=>({id:e,duration:t,label:n,description:o,intensity:r,motion:i,color:s,metrics:a})),products:r,outlets:o,events:i.events.map(({id:e,label:t,description:n,summary:o,authoredAt:r,phaseId:i,boundaryRank:s,effects:a})=>({id:e,label:t,description:n,summary:o,authoredAt:r,phaseId:i,boundaryRank:s,effects:a}))},JSON.stringify(ry(d)));var d;const h=function(e,t,n={}){const o=Object.values(e.components).sort((e,t)=>Bp(e.id,t.id)),r=o.map(e=>e.amount),i=Qp(n.radiusRange,t),s=function(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}(Xp(n.seed)),a=t.mouth.x+t.mouth.width/2,c=t.chamber.y+Math.max(18,.18*t.chamber.height),l=Math.max(4,.28*t.chamber.width),u=Math.max(4,.12*t.chamber.height);return o.map((e,t)=>{const d=t/Math.max(1,o.length)*Math.PI*2+.18*(s()-.5),h=Zp(e.amount,r,n.bodyRadius,i),f={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:Kp(e.id),x:a+Math.cos(d)*l*(.45+.45*s()),y:c+Math.sin(d)*u*(.45+.45*s()),vx:24*(s()-.5),vy:18*(s()-.5),mass:Math.max(.25,h*h*.015),restitution:.12,friction:.4,shape:{type:"circle",radius:h},datum:f}})}(s.state,a,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),f=[...t.diagnostics,...i.diagnostics,...s.diagnostics,...l],p={phases:t.phases,events:i.events,products:r,outlets:o,duration:n,initialState:s.state,terminalState:s.state,layout:a,colliders:c,config:Up(e.seed,c),initialSpawns:h,terminalSpawns:[],semanticKey:u,diagnostics:f},y=iy(p),g=Object.values(y.state.products).filter(e=>"forming"===e.status).map(e=>e.id),m=g.length?[Fp("warning","forming-product-at-end",`Products remain forming at the end of the tape: ${g.join(", ")}.`,"events",g)]:[];return p.terminalState=y.state,p.terminalSpawns=oy(y.state,a,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),p.diagnostics=[...f,...y.diagnostics,...m],p}var ay=y(require("react")),cy=require("react/jsx-runtime");function ly(e){return Number.isFinite(e)?1e3>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2).replace(/\.00$/,"").replace(/(\.\d)0$/,"$1"):e.toLocaleString():"0"}function uy(e,t,n,o){const r=e.datum;if(!r?.__crucible)return;const i="circle"===e.shape.type?e.shape.radius:8,s="string"==typeof t.fill?t.fill:"product"===r.kind?"#b8792d":"#356b63",a="string"==typeof t.stroke?t.stroke:"#26323a",c="number"==typeof t.strokeWidth?t.strokeWidth:1.25,l="number"==typeof t.opacity?t.opacity:.96,u=o?`${o}-crucible-body-${n}`:"crucible-body-"+n;if("product"===r.kind){const t=Array.from({length:6},(t,n)=>{const o=-Math.PI/2+n/6*Math.PI*2;return`${e.x+Math.cos(o)*i},${e.y+Math.sin(o)*i}`}).join(" "),n=u+"-glow";return(0,cy.jsxs)(ay.Fragment,{children:[(0,cy.jsx)("defs",{children:(0,cy.jsx)("filter",{id:n,x:"-60%",y:"-60%",width:"220%",height:"220%",children:(0,cy.jsx)("feDropShadow",{dx:"0",dy:"0",stdDeviation:"4",floodColor:s,floodOpacity:"0.8"})})}),(0,cy.jsx)("polygon",{points:t,fill:s,stroke:a,strokeWidth:c,opacity:l,filter:`url(#${n})`}),(0,cy.jsx)("circle",{cx:e.x,cy:e.y,r:Math.max(2,.36*i),fill:"none",stroke:"var(--semiotic-background, #fffaf0)",strokeWidth:c,opacity:.72*l})]},u)}return(0,cy.jsxs)(ay.Fragment,{children:[(0,cy.jsx)("circle",{cx:e.x,cy:e.y,r:i,fill:s,stroke:a,strokeWidth:c,opacity:l}),(0,cy.jsx)("circle",{cx:e.x-.25*i,cy:e.y-.28*i,r:Math.max(1,.18*i),fill:"rgba(255,255,255,0.34)"})]},u)}var dy=require("react/jsx-runtime"),hy="var(--semiotic-text, #26323a)",fy="var(--semiotic-text-secondary, #6c7377)",py="var(--semiotic-accent, #b8792d)",yy="var(--semiotic-negative, #9f3d35)",gy="var(--semiotic-positive, #356b63)";function my(e){const{x:t,y:n,width:o,height:r}=e.chamber,i=Math.min(.14*o,48),s=n+r;return[`M ${t} ${n}`,`L ${t+i} ${s-.16*r}`,`Q ${t+o/2} ${s+.1*r} ${t+o-i} ${s-.16*r}`,`L ${t+o} ${n}`].join(" ")}function xy({layout:e,phases:t,state:n,compact:o=!1}){const r=Math.max(1,t.reduce((e,t)=>e+Math.max(0,t.duration),0));return(0,dy.jsxs)("svg",{"aria-hidden":"true","data-testid":"crucible-chrome",viewBox:`0 0 ${e.width} ${e.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:[(0,dy.jsxs)("defs",{children:[(0,dy.jsxs)("linearGradient",{id:"semiotic-crucible-heat",x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,dy.jsx)("stop",{offset:"0",stopColor:py,stopOpacity:"0.03"}),(0,dy.jsx)("stop",{offset:"0.66",stopColor:py,stopOpacity:"0.1"}),(0,dy.jsx)("stop",{offset:"1",stopColor:yy,stopOpacity:"0.18"})]}),(0,dy.jsx)("pattern",{id:"semiotic-crucible-hatch",width:"7",height:"7",patternUnits:"userSpaceOnUse",patternTransform:"rotate(20)",children:(0,dy.jsx)("line",{x1:"0",x2:"0",y1:"0",y2:"7",stroke:hy,strokeOpacity:"0.08",strokeWidth:"1"})})]}),(0,dy.jsx)("rect",{x:e.chamber.x,y:e.chamber.y,width:e.chamber.width,height:e.chamber.height,rx:2,fill:"url(#semiotic-crucible-heat)",stroke:hy,strokeOpacity:"0.52",strokeWidth:o?1:2.2}),(0,dy.jsx)("path",{d:my(e),fill:"url(#semiotic-crucible-hatch)",stroke:"none"}),(0,dy.jsx)("line",{x1:e.mouth.x,x2:e.mouth.x+e.mouth.width,y1:e.mouth.y,y2:e.mouth.y,stroke:hy,strokeLinecap:"round",strokeOpacity:"0.72",strokeWidth:o?2:5}),o?null:(0,dy.jsx)("g",{"data-testid":"crucible-phase-rail",children:t.map((o,i)=>{const s=t.slice(0,i).reduce((e,t)=>e+Math.max(0,t.duration),0),a=e.phaseRail.x+s/r*e.phaseRail.width,c=Math.max(0,o.duration)/r*e.phaseRail.width,l=o.id===n.phaseId,u=n.phaseIndex>i||n.complete;return(0,dy.jsxs)("g",{children:[(0,dy.jsx)("rect",{x:a,y:e.phaseRail.y,width:Math.max(1,c-2),height:e.phaseRail.height,rx:2,fill:l?o.color??py:u?gy:hy,fillOpacity:l?.68:u?.28:.09}),46>c?null:(0,dy.jsx)("text",{x:a+c/2,y:e.phaseRail.y+e.phaseRail.height+13,fill:l?hy:fy,fontFamily:"system-ui, sans-serif",fontSize:8.5,fontWeight:l?800:650,letterSpacing:"0.04em",textAnchor:"middle",children:(o.label??o.id).toUpperCase()})]},o.id)})}),e.outlets.map(e=>(0,dy.jsxs)("g",{children:[(0,dy.jsx)("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:3,fill:e.color??("left"===e.side?yy:gy),fillOpacity:"0.1",stroke:e.color??("left"===e.side?yy:gy),strokeDasharray:"3 3",strokeOpacity:"0.62"}),o?null:(0,dy.jsx)("text",{x:e.x+e.width/2,y:e.y+Math.min(13,e.height/2+3),fill:fy,fontFamily:"system-ui, sans-serif",fontSize:8,fontWeight:750,letterSpacing:"0.05em",textAnchor:"middle",children:(e.label??e.id).toUpperCase()})]},e.id))]})}function by({rows:e,layout:t,projection:n,amountLabel:o}){if(!e.length)return null;const r=n.measure??"count",i=e.map(e=>Math.max(0,function(e,t){return"count"===t?e.count:"amount"===t?e.amount:Number(e.metrics[t]??0)}(e,r))),s=Math.max(1,...i),a=t.projection.width/Math.max(1,e.length),c=t.projection.height>48?21:4,l=Math.max(5,t.projection.height-c-5);return(0,dy.jsx)("svg",{"aria-hidden":"true","data-testid":"crucible-projection-overlay",viewBox:`0 0 ${t.width} ${t.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:e.map((e,n)=>{const u=i[n],d=Math.max(u>0?2:0,u/s*l),h=t.projection.x+n*a+.18*a;return(0,dy.jsxs)("g",{children:[(0,dy.jsx)("rect",{x:h,y:t.projection.y+l-d,width:Math.max(3,.64*a),height:d,rx:2,fill:"failed"===e.status||"ejected"===e.status?yy:"complete"===e.status?py:gy,fillOpacity:"0.68"}),c>4&&a>=34?(0,dy.jsxs)(dy.Fragment,{children:[(0,dy.jsx)("text",{x:h+.32*a,y:t.projection.y+l+10,fill:fy,fontFamily:"system-ui, sans-serif",fontSize:7.5,fontWeight:700,textAnchor:"middle",children:e.label.length>13?e.label.slice(0,12)+"…":e.label}),(0,dy.jsxs)("text",{x:h+.32*a,y:t.projection.y+l+19,fill:hy,fontFamily:"system-ui, sans-serif",fontSize:8,fontWeight:850,textAnchor:"middle",children:[ly(u),"amount"===r&&o?" "+o:""]})]}):null]},e.key)})})}function vy(e){const t=e.datum;if(t&&"object"==typeof t){const e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e.id}function wy(e){return e.map(e=>({...e,spawnAt:void 0}))}function ky(e,t){return e?t?n=>fh.createElement(fh.Fragment,null,e,"function"==typeof t?t(n):t):e:t}var Sy=["#356b63","#a34b43","#c08b38","#3e5f83","#785b7c","#6e7740","#8f5c3a","#41717b"];function Ay(e){let t=2166136261;for(let n=0;e.length>n;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return Sy[(t>>>0)%Sy.length]}var My={Sparkline:{frameType:"xy",layout:{mode:"sparkline"},buildProps:(e,t,n,o,r)=>({chartType:"line",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||t,colorAccessor:t,...o,showAxes:!1,margin:o.margin,showLegend:!1,showGrid:!1,title:void 0})},BumpChart:Gu,LineChart:Vu,AreaChart:Uu,DifferenceChart:Ku,StackedAreaChart:Zu,Scatterplot:Ju,CandlestickChart:Qu,BubbleChart:Yu,ConnectedScatterplot:td,QuadrantChart:ed,Heatmap:{frameType:"xy",buildProps:(e,t,n,o,r)=>({chartType:"heatmap",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",valueAccessor:r.valueAccessor,colorScheme:n||r.colorScheme||"blues",showValues:r.showValues,heatmapValueFormat:r.valueFormat,cellBorderColor:r.cellBorderColor,...o})},TemporalHistogram:Xu,XYCustomChart:{frameType:"xy",buildProps:(e,t,n,o,r)=>({chartType:"custom",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,colorScheme:n,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...o,showAxes:r.frameProps?.showAxes??r.showAxes??!1,showLegend:o.showLegend??!!t})},BarChart:vd,StackedBarChart:wd,GroupedBarChart:kd,PieChart:Sd,DonutChart:Ad,Histogram:Md,BoxPlot:_d,ViolinPlot:Pd,SwarmPlot:jd,DotPlot:Rd,SwimlaneChart:Cd,RidgelinePlot:Ld,LikertChart:Id,FunnelChart:Td,GaugeChart:$d,OrdinalCustomChart:{frameType:"ordinal",buildProps:(e,t,n,o,r)=>({chartType:"custom",data:e,oAccessor:r.categoryAccessor||r.oAccessor||"category",rAccessor:r.valueAccessor||r.rAccessor||"value",projection:r.projection||"vertical",colorAccessor:t,colorScheme:n,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...o,showAxes:r.frameProps?.showAxes??r.showAxes??!1})},ForceDirectedGraph:eh,NetworkCustomChart:{frameType:"network",layout:{margin:{top:40,right:40,bottom:40,left:40}},buildProps:(e,t,n,o,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:n,customNetworkLayout:r.layout||r.customNetworkLayout,layoutConfig:r.layoutConfig,...o})},SankeyDiagram:nh,ProcessSankey:th,ChordDiagram:oh,TreeDiagram:rh,Treemap:ih,CirclePack:sh,ChoroplethMap:uh,ProportionalSymbolMap:dh,FlowMap:hh,GeoCustomChart:{frameType:"geo",buildProps:(e,t,n,o,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:n,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...o})},GaltonBoardChart:{frameType:"physics",buildProps:(e,t,n,o,r)=>{const i=o.size??[600,400],s=r.bins??21,a=r.seed??1,c=Math.max(1,Math.round(r.pegRows??s-1)),l="mechanical"===r.mode,u=l?function(e){const t=Math.max(2,Math.round(e.bins)),n=Math.max(1,Math.round(e.pegRows??t-1)),o=Math.max(1,Math.round(e.count??Math.max(64,4*t))),r=vh(Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,0,1),i=Sh(e.seed??1),s=e.idPrefix??"mechanical";return Array.from({length:o},(e,t)=>{let o=0;for(let e=0;n>e;e+=1)i()<r&&(o+=1);const a=n/2;return{id:`${s}-${t}`,value:o,mechanical:!0,pegRows:n,branchProbability:r,pathRights:o,side:a>o?"left":o>a?"right":"center"}})}({bins:s,branchProbability:r.branchProbability,count:r.mechanicalCount,pegRows:c,seed:a}):Array.isArray(e)?e:[],d=function(e){const{data:t,valueAccessor:n,bins:o,ballRadius:r,seed:i,size:s,valueExtent:a}=e,c=ph(s),l=t.map((e,t)=>bh(xh(e,t,n))).filter(e=>null!=e),u=function(e){if(!e)return;const t=bh(e[0]),n=bh(e[1]);return null!=t&&null!=n?t>n?[n,t]:[t,n]:void 0}(a),d=u?.[0]??(l.length?Math.min(...l):0),h=u?.[1]??(l.length?Math.max(...l):1),f=h===d?1:h-d,p=(0,Ah.scaleLinear)().domain([0,o]).range([c.plot.x,c.plot.x+c.plot.width]),y=Array.from({length:o},()=>0),g=[];t.forEach((e,t)=>{const i=bh(xh(e,t,n));if(null==i)return;const s=Math.max(0,Math.min(o-1,Math.floor((i-d)/f*o)));y[s]+=1,g.push({id:(e.id??"galton-"+t)+"",x:p(s+.5),y:c.plot.y+r+2,vx:8*(t%5-2),vy:0,mass:1,shape:{type:"circle",radius:r},datum:{...e,value:i,bin:s}})});const m=c.plot.y+c.plot.height;return{config:mh(i,[...vf({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...wf({idPrefix:"galton-bin",count:o,domainStart:0,domainStep:1,xScale:p,yTop:c.plot.y-400,yBottom:m,wallThickness:6})],"GaltonBoardChart"),initialSpawns:g,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:y.map((e,t)=>({label:t+1+"",value:e})),metadata:{kind:"galton-board",bins:o,plot:c.plot,valueExtent:[d,h]}}}({data:u,valueAccessor:r.valueAccessor||"value",bins:s,ballRadius:r.ballRadius??4,seed:a,size:i,valueExtent:l?[0,c]:void 0});return{...o,config:d.config,initialSpawns:wy(d.initialSpawns),projectionRows:d.projectionRows,bodyStyle:gh(t||r.colorBy||(l?"side":void 0),"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.valueAccessor||"value"})}}},EventDropChart:{frameType:"physics",buildProps:(e,t,n,o,r)=>{const i=o.size??[600,400],s=function(e){const{data:t,timeAccessor:n,arrivalAccessor:o,windows:r,watermark:i,ballRadius:s,seed:a,size:c,timeExtent:l,timeScale:u=1}=e,d=ph(c),h=t.map((e,t)=>bh(xh(e,t,n))).filter(e=>null!=e),f=bh(l?.[0]),p=bh(l?.[1]),y=h.length?Math.min(...h):0,g=h.length?Math.max(...h):y+r.size,m=Math.min(f??y,y),x=Math.max(p??g,g),b=Math.floor(m/r.size)*r.size,v=Math.max(1,Math.ceil((x-b+r.size)/r.size)),w=h.length?Math.max(...h):0,k="function"==typeof i?i(w):bh(i?.value)??w-(i?.delay??r.size),S=Math.max(0,Math.min(v,Array.from({length:v},(e,t)=>t).reduce((e,t)=>b+(t+1)*r.size>k?e:e+1,0))),A=function(e,t){const n=Math.max(5*t,Math.min(92,.13*e.plot.width));return{gutter:{x:e.plot.x,y:e.plot.y,width:n,height:e.plot.height},windowPlot:{x:e.plot.x+n,y:e.plot.y,width:Math.max(40,e.plot.width-n),height:e.plot.height},wallTop:e.plot.y+.48*e.plot.height}}(d,s),M=b+v*r.size,_=(0,Bf.scaleLinear)().domain([b,M]).range([A.windowPlot.x,A.windowPlot.x+A.windowPlot.width]),P=Array.from({length:v},()=>({value:0,secondary:0})),j=[];t.forEach((e,t)=>{const i=bh(xh(e,t,n));if(null==i)return;const a=bh(xh(e,t,o))??i,c=Math.max(0,Math.min(v-1,Math.floor((i-b)/r.size))),l=k>=b+(c+1)*r.size;P[c].value+=l?0:1,P[c].secondary+=l?1:0,j.push({id:(e.id??"event-"+t)+"",x:Math.max(A.windowPlot.x+s,Math.min(A.windowPlot.x+A.windowPlot.width-s,_(i))),y:d.plot.y+s+2,vx:8*(t%3-1),vy:0,mass:1,friction:.02,spawnAt:a,shape:{type:"circle",radius:s},datum:{...e,eventTime:i,arrivalTime:a,windowIndex:c,late:l}})});const R=d.plot.y+d.plot.height,C=function(e,t){const n=Math.max(0,Math.min(e.windowCount,e.closedWindowCount));if(!n)return[];const o=e.windowStart,r=e.windowStart+e.windowCount*e.windowSize,i=(0,Bf.scaleLinear)().domain([o,r]).range([e.windowPlot.x,e.windowPlot.x+e.windowPlot.width]),s=i(e.windowStart+n*e.windowSize),a=e.windowPlot.x,c=t+Math.max(18,Math.min(.3*e.windowPlot.height,s-a)),l=e=>s===a?t:c+(e-a)/(s-a)*(t-c),u=[];for(let t=0;n>t;t+=1){const n=e.windowStart+t*e.windowSize,o=n+e.windowSize,r=i(n),s=i(o);u.push({id:"eventdrop-lid-"+t,windowIndex:t,x1:r,y1:l(r),x2:s,y2:l(s)})}return u}({closedWindowCount:S,gutter:A.gutter,plot:d.plot,windowCount:v,windowPlot:A.windowPlot,windowSize:r.size,windowStart:b},d.plot.y+.28*d.plot.height);return{config:mh(a,[...vf({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...Ff({idPrefix:"eventdrop-window",count:v,xScale:e=>_(b+e*r.size),yTop:A.wallTop,yTopForIndex:e=>{const t=(e=>{if(0>e||e>S)return null;const t=0===e?C[0]?.y1:C[e-1]?.y2??C[e]?.y1;return"number"==typeof t&&Number.isFinite(t)?t:null})(e);return null==t?A.wallTop:t+1.25*s},yBottom:R,wallThickness:6}),...C.map(e=>({id:e.id,shape:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:Math.max(4,.42*s)},friction:.02,restitution:.01}))],"EventDropChart",{friction:.08}),initialSpawns:j,initialSpawnPacing:{pacing:"arrival",timeAccessor:e=>e.datum?.arrivalTime,timeScale:u},projectionRows:P.map((e,t)=>({label:`${b+t*r.size}-${b+(t+1)*r.size}`,value:e.value,secondary:e.secondary})),metadata:{kind:"event-drop",closedWindowCount:S,gutter:A.gutter,lidSegments:C,lateCount:P.reduce((e,t)=>e+t.secondary,0),plot:d.plot,windowPlot:A.windowPlot,watermarkValue:k,windowCount:v,windowSize:r.size,windowStart:b}}}({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:i,timeExtent:r.timeExtent,timeScale:r.timeScale??1});return{...o,config:s.config,initialSpawns:wy(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:gh(t||r.colorBy,"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.valueAccessor||r.timeAccessor||"time"})}}},PhysicsPileChart:{frameType:"physics",buildProps:(e,t,n,o,r)=>{const i=o.size??[600,400],s="mechanical"===r.mode,a=function(e){const{data:t,categoryAccessor:n,valueAccessor:o,unitValue:r,ballRadius:i,seed:s,size:a}=e,c=wh(r,1),l=ph(a),u=[],d=new Map,h=new Map,f=[];function p(e){let t=d.get(e);return null==t&&(t=u.length,u.push(e),d.set(e,t)),t}t.forEach((e,t)=>{p((xh(e,t,n)??"unknown")+"")});const y=Math.max(1,u.length),g=function(e,t,n){const o=e.width/Math.max(1,t),r=Math.max(2,2*n),i=Math.min(.7*o,Math.max(3.2*r,r+8)),s=Math.max(1,Math.floor(i/r));return{laneWidth:o,tubeWidth:i,ballDiameter:r,perRow:s,centerX:t=>e.x+(t+.5)*o,pileHeight:e=>Math.ceil(Math.max(0,e)/s)*r}}(l.plot,y,i),m=Math.max(0,g.tubeWidth/2-i-1),x=u.map(()=>[]);t.forEach((e,t)=>{const r=(xh(e,t,n)??"unknown")+"",s=p(r),a=o?bh(xh(e,t,o)):1,u=Math.max(0,Math.round((a??0)/c)),d=g.centerX(s);for(let n=0;u>n;n+=1){const o=h.get(r)??0,a=g.perRow>1?((g.perRow>1?o%g.perRow:0)/(g.perRow-1)*2-1)*m:0;h.set(r,o+1),x[s].push({id:`${(e.id??"pile-"+t)+""}-${n}`,x:d+a,y:l.plot.y+i+2,vx:(n%3-1)*i/2,vy:0,mass:1,shape:{type:"circle",radius:i},datum:{...e,category:r,unitIndex:n}})}});const b=x.reduce((e,t)=>Math.max(e,t.length),0);for(let e=0;b>e;e+=1)for(const t of x)t.length>e&&f.push(t[e]);const v=l.plot.y+l.plot.height,w=[...vf({x:l.plot.x,y:l.plot.y,width:l.plot.width,height:l.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],k=l.plot.y-400;for(let e=0;y>e;e+=1){const t=g.centerX(e);for(const n of[-1,1])w.push({id:`pile-tube-${e}-${0>n?"l":"r"}`,shape:{type:"aabb",x:t+n*g.tubeWidth/2,y:(k+v)/2,width:6,height:v-k}})}return{config:mh(s,w,"PhysicsPileChart"),initialSpawns:f,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:u.map(e=>({label:e,value:h.get(e)??0}))}}({data:s?function(e={}){const t=(e.categories?.length?e.categories:["Intake","Review","Build","Ship"]).map(e=>(e+"").trim()).filter(Boolean),n=t.length?t:["Intake"],o=Math.max(n.length,Math.round(e.count??Math.max(48,12*n.length))),r=wh(e.unitValue,1),i=Sh(e.seed??1),s=e.idPrefix??"mechanical-pile",a=n.map(()=>.65+.9*i()),c=a.reduce((e,t)=>e+t,0)||1,l=o-n.length,u=a.map(e=>e/c*l),d=u.map(e=>1+Math.floor(e));let h=o-d.reduce((e,t)=>e+t,0);const f=u.map((e,t)=>({index:t,fraction:e-Math.floor(e)})).sort((e,t)=>t.fraction-e.fraction);for(let e=0;h>0;e=(e+1)%f.length)d[f[e].index]+=1,h-=1;return n.map((e,t)=>({id:`${s}-${t}`,category:e,value:d[t]*r,mechanical:!0,unitCount:d[t],unitValue:r,share:d[t]/o}))}({categories:r.mechanicalCategories,count:r.mechanicalCount,seed:r.seed??1,unitValue:r.unitValue??1}):Array.isArray(e)?e:[],categoryAccessor:r.categoryAccessor||"category",valueAccessor:r.valueAccessor||(s?"value":void 0),unitValue:r.unitValue??1,ballRadius:r.ballRadius??5,seed:r.seed??1,size:i});return{...o,config:a.config,initialSpawns:wy(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:gh(t||r.colorBy||(s?"category":void 0),"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.valueAccessor||"value"})}}},CollisionSwarmChart:{frameType:"physics",buildProps:(e,t,n,o,r)=>{const i=o.size??[600,360],s=function(e){const{data:t,xAccessor:n,groupAccessor:o,radiusAccessor:r,pointRadius:i,seed:s,size:a,xExtent:c,collisionIterations:l,settle:u}=e,d=ph(a),h=Sh(s),f=[],p=[],y=new Map;t.forEach((e,t)=>{const s=bh(xh(e,t,n));if(null==s)return;const a=o?(xh(e,t,o)??"All")+"":"All",c=r?bh(xh(e,t,r)):null,l=vh(null!=c&&c>0?c:i,2,18);!function(e){let t=y.get(e);null==t&&(t=p.length,p.push(e),y.set(e,t))}(a),f.push({datum:e,index:t,value:s,group:a,radius:l})});const g=f.map(e=>e.value),m=c?bh(c[0]):null,x=c?bh(c[1]):null,b=g.length?Math.min(...g):0,v=g.length?Math.max(...g):1;let w=m??b,k=x??v;if(w===k&&(w-=.5,k+=.5),w>k){const e=k;k=w,w=e}const S=Math.max(i,...f.map(e=>e.radius)),A=d.plot.x+S+8,M=d.plot.x+d.plot.width-S-8,_=(0,Nf.scaleLinear)().domain([w,k]).range([A,M]),P=Math.max(1,p.length),j=Math.min(Math.max(28,3*S),d.plot.height/4),R=d.plot.y+j,C=Math.max(0,d.plot.y+d.plot.height-j-R),L=e=>{const t=y.get(e)??0;return 1===P?d.plot.y+.54*d.plot.height:R+t/(P-1)*C},I=new Map,T=f.map((e,t)=>{I.set(e.group,(I.get(e.group)??0)+1);const n=_(e.value),o=L(e.group),r=(h()-.5)*e.radius*1.6,i=(h()-.5)*e.radius*1.6;return{id:(e.datum.id??"collision-swarm-"+t)+"",x:u?n+r:vh(n+(t%9-4)*e.radius*2.5,A,M),y:u?o+i:d.plot.y-18-t%12*e.radius,vx:u?0:22*(h()-.5),vy:u?0:24+18*h(),mass:1,shape:{type:"circle",radius:e.radius},datum:{...e.datum,xValue:e.value,group:e.group,radius:e.radius,targetX:n,targetY:o},springs:[{target:{type:"point",x:n,y:o},restLength:0,stiffness:34,damping:5.5}]}});return{config:mh(s,vf({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"collision-swarm",includeCeiling:!1,wallThickness:20,floorThickness:20}),"CollisionSwarmChart",{gravity:{x:0,y:0},cellSize:Math.max(24,4*S),collisionIterations:Math.max(1,Math.round(l??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:T,projectionRows:p.map(e=>({label:e,value:I.get(e)??0})),metadata:{kind:"collision-swarm",xExtent:[w,k],xRange:[A,M],groups:p.map(e=>({label:e,y:L(e),count:I.get(e)??0})),plot:d.plot}}}({data:Array.isArray(e)?e:[],xAccessor:r.xAccessor||"x",groupAccessor:r.groupAccessor,radiusAccessor:r.radiusAccessor,pointRadius:r.pointRadius??5,seed:r.seed??1,size:i,xExtent:r.xExtent,collisionIterations:r.collisionIterations,settle:r.settle});return{...o,config:s.config,initialSpawns:wy(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:gh(t||r.colorBy||r.groupAccessor,"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.xAccessor||"x"})}}},ProcessFlowChart:{frameType:"physics",buildProps:(e,t,n,o,r)=>{const i=o.size??[900,420],s=Array.isArray(r.stages)?r.stages:[],a=Jf({data:Array.isArray(e)?e:[],stages:s,size:i,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}),c=a.metadata;return{...o,config:a.config,initialSpawns:wy(a.initialSpawns),projectionRows:a.projectionRows,regionEffects:c?.regionEffects,bodyStyle:gh(t||r.colorBy||r.groupBy,"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.workAccessor||r.stageAccessor||"stage"})}}},GauntletChart:{frameType:"physics",buildProps:(e,t,n,o,r)=>{const i=o.size??[900,520],s=yp({data:Array.isArray(e)?e:[],size:i,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{...o,config:s.config,initialSpawns:wy(s.initialSpawns),projectionRows:[],bodyStyle:gh(t||r.colorBy)}}},CrucibleChart:{frameType:"physics",buildProps:(e,t,n,o,r)=>{const i=o.size??[900,520],s=sy({data:Array.isArray(e)?e:[],phases:Array.isArray(r.phases)?r.phases:[],products:Array.isArray(r.products)?r.products:void 0,outlets:Array.isArray(r.outlets)?r.outlets:void 0,events:Array.isArray(r.events)?r.events:void 0,idAccessor:r.idAccessor,labelAccessor:r.labelAccessor,categoryAccessor:r.categoryAccessor,amountAccessor:r.amountAccessor,metricsAccessor:r.metricsAccessor,initialStateAccessor:r.initialStateAccessor,metrics:r.metrics,size:i,seed:r.seed,bodyRadius:"number"==typeof r.bodyRadius?r.bodyRadius:void 0,radiusRange:r.radiusRange}),a="snapshot"===r.playback?function(e,t){if(void 0===t)return e.duration;if("number"==typeof t)return Math.max(0,Math.min(e.duration,Wp(t)??0));const n=e.phases.find(e=>e.id===t.phaseId);if(!n)return e.duration;const o=Math.max(0,Math.min(1,Wp(t.progress??0)??0));return n.start+n.duration*o}(s,r.snapshotAt):s.duration,c=iy(s,a).state,l=r.projection&&"object"==typeof r.projection?r.projection:{groupBy:"outlet",measure:"count"},u=function(e,t={}){const n=t.groupBy??"outlet",o=new Map,r=e=>{const t=function(e,t){return"product"===t?"product"===e.kind?e.id:"unassigned":"outlet"===t?e.outletId??"unassigned":"category"===t?e.category:e.status}({...e,status:e.status??"active"},n),r=o.get(t);if(r)return r.count+=1,r.amount+=e.amount,void Ap(r.metrics,e.metrics);o.set(t,{key:t,label:"product"===n&&"product"===e.kind?e.label:t,count:1,amount:e.amount,metrics:{...e.metrics},status:"status"===n?e.status:void 0,outletId:"outlet"===n?e.outletId:void 0,category:"category"===n?e.category:void 0,productId:"product"===n&&"product"===e.kind?e.id:void 0})};for(const t of Object.values(e.components))t.productIds.length||"consumed"===t.status||r({kind:"component",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});for(const t of Object.values(e.products))r({kind:"product",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});const i=new Map((t.order??[]).map((e,t)=>[e,t]));return[...o.values()].sort((e,t)=>(i.get(e.key)??Number.MAX_SAFE_INTEGER)-(i.get(t.key)??Number.MAX_SAFE_INTEGER)||mp(e.key,t.key))}(c,l),d=l.measure??"count",h=function(e,t={}){const n=t.bodies??[],o=Math.max(0,t.recentBodyLimit??6),r=new Map;for(const e of n){const n=t.getContainerId?.(e);if(!n)continue;const o=r.get(n);o?o.push(e):r.set(n,[e])}const i=e.map(e=>{const n=r.get(e.id)??[],i=Math.max(0,Math.floor(e.count??n.length)),s=n.slice(Math.max(0,n.length-o)).map(e=>({id:e.id,label:t.getBodyLabel?.(e)??vy(e),datum:e.datum}));return{id:e.id,label:e.label,count:i,share:0,secondary:e.secondary,secondaryLabel:e.secondaryLabel,observed:e.observed,bodyIds:n.map(e=>e.id),recentBodies:s,metadata:e.metadata}}),s=i.reduce((e,t)=>e+t.count,0);return i.map(e=>({...e,share:s>0?e.count/s:0}))}(u.map(e=>({id:e.key,label:e.label,count:e.count,secondary:"count"===d||"amount"===d?e.amount:Number(e.metrics[d]??0),secondaryLabel:"count"===d||"amount"===d?r.amountLabel??"amount":d,metadata:{amount:e.amount,metrics:e.metrics,status:e.status,outletId:e.outletId,category:e.category,productId:e.productId}}))),f={seed:r.seed,bodyRadius:"number"==typeof r.bodyRadius?r.bodyRadius:void 0,radiusRange:r.radiusRange},p=t??r.colorBy??"category",y=!1===r.showChrome?null:fh.createElement(xy,{layout:s.layout,phases:s.phases,state:c,compact:520>i[0]||360>i[1]}),g=!1===r.showProjection?null:fh.createElement(by,{rows:u,layout:s.layout,projection:l,amountLabel:r.amountLabel});return{...o,config:s.config,initialSpawns:wy(ny(c,s.layout,f)),projectionRows:h,bodyStyle:e=>function(e,t,n,o){const r=e.datum,i={stroke:o.stroke??("product"===r?.kind?"#fffaf0":"#26323a"),strokeWidth:o.strokeWidth??("product"===r?.kind?1.8:1.1),opacity:o.opacity??.96};if(!r?.__crucible)return{...i,fill:o.color??"#b8792d"};if("product"===r.kind){const e=t.products[r.semanticId];return{...i,fill:o.color??e?.color??Ay(e?.id??r.semanticId)}}const s=t.components[r.semanticId];if(!s)return{...i,fill:o.color??"#356b63"};let a;return a="status"===n?s.status:"outlet"===n?s.outletId??"in chamber":"product"===n?s.productIds[0]??"unalloyed":"category"===n||null==n?s.category:"function"==typeof n?(n(s.datum)??"unassigned")+"":(s.datum[n+""]??"unassigned")+"",{...i,fill:o.color??Ay(a)}}(e,c,p,r),getBodyLabel:e=>function(e,t){const n=e.datum;if(n?.__crucible)return"product"===n.kind?t.products[n.semanticId]?.label:t.components[n.semanticId]?.label}(e,c),renderBodySVG:uy,backgroundGraphics:ky(y,o.backgroundGraphics),foregroundGraphics:ky(g,o.foregroundGraphics)}}},PhysicalFlowChart:{frameType:"physics",buildProps:(e,t,n,o,r)=>{const i=o.size??[760,420],s=function(e){const{coordinateMode:t,flowSpeed:n,links:o,maxParticles:r,nodeIdAccessor:i,nodeXAccessor:s,nodeYAccessor:a,nodes:c,particleRadius:l,particleRate:u,pathAccessor:d,pathConstraint:h="path",reducedMotion:f,seed:p,size:y,sourceAccessor:g,targetAccessor:m,throughputAccessor:x}=e,b=ph(y),v=Sh(p),w=new Map,k=new Map,S=[];function A(e){if(e&&"object"==typeof e){const t=e;if("function"==typeof i){const e=i(t,0);if(null!=e)return e+""}if("string"==typeof i&&null!=t[i])return t[i]+"";if(null!=t.id)return t.id+""}return(e??"unknown")+""}c.forEach((e,t)=>{const n=(xh(e,t,i)??e.id??t)+"",o=bh(xh(e,t,s)),r=bh(xh(e,t,a));if(null!=o&&null!=r){const e={x:o,y:r};w.set(n,e),S.push(e)}k.set(n,(e.label??e.name??n)+"")});const M=[];o.forEach((e,t)=>{const n=A(xh(e,t,g)),o=A(xh(e,t,m)),r=Math.max(0,bh(xh(e,t,x))??0),i=qf(d?xh(e,t,d):void 0),s=i.length?i:qf(e.path??e.points??e.route);s.forEach(e=>S.push(e)),M.push({id:(e.id??`physical-flow-${n}-${o}-${t}`)+"",link:e,index:t,source:n,target:o,throughput:r,rawPath:s})});const _=(j=S,"normalized"===(P=t)||"pixels"===P?P:j.length>0&&j.every(e=>!(0>e.x||e.x>1||0>e.y||e.y>1))?"normalized":"pixels");var P,j;const R=new Map;for(const[e,t]of w)R.set(e,Yf(t,b,_));const C=[];for(const e of M){let t=e.rawPath.map(e=>Yf(e,b,_));if(2>t.length){const n=R.get(e.source),o=R.get(e.target);n&&o&&(t=[n,o])}else R.has(e.source)||R.set(e.source,t[0]),R.has(e.target)||R.set(e.target,t[t.length-1]);t.length>=2&&e.throughput>0&&(k.has(e.source)||k.set(e.source,e.source),k.has(e.target)||k.set(e.target,e.target),C.push({...e,path:t,packetCount:0}))}const L=wh(u,.12),I=Math.max(1,Math.round(r)),T=C.map(e=>Math.max(1,Math.round(e.throughput*L))),$=T.reduce((e,t)=>e+t,0),z=$>I?I/$:1;C.forEach((e,t)=>{e.packetCount=Math.max(1,Math.floor(T[t]*z))});let E=C.reduce((e,t)=>e+t.packetCount,0);for(;E>I;){const e=C.reduce((e,t,n)=>t.packetCount>1&&(-1===e||t.packetCount>C[e].packetCount)?n:e,-1);if(-1===e)break;C[e].packetCount-=1,E-=1}const O=new Map,D=new Map,B=[],F=wh(n,90),N=wh(l,4);C.forEach((e,t)=>{O.set(e.target,(O.get(e.target)??0)+e.throughput),D.set(e.source,(D.get(e.source)??0)+e.throughput);const n=Gf(e.path);for(let o=0;e.packetCount>o;o+=1){const r=(o+.5)/e.packetCount,i=f?r:vh(.12+.84*r+.04*(v()-.5),.04,.98),s=f?i:Math.max(0,i-(.18+.12*v())),a=Hf(e.path,s),c=Hf(e.path,i),l=Vf(e.path,s),u={x:-l.y,y:l.x},d=(v()-.5)*N*1.5;B.push({id:`${e.id}-packet-${o}`,x:a.x+u.x*d,y:a.y+u.y*d,vx:f?0:l.x*F+10*(v()-.5),vy:f?0:l.y*F+10*(v()-.5),mass:.8,spawnAt:f?0:.04*t+o/32,shape:{type:"circle",radius:N},datum:{...e.link,source:e.source,target:e.target,throughput:e.throughput,packetIndex:o,packetCount:e.packetCount,routeProgress:i,flowPath:e.path,flowPathLength:n,flowRouteId:e.id,flowSpeed:F,sourceLabel:k.get(e.source)??e.source,targetLabel:k.get(e.target)??e.target},springs:"none"!==h&&f?[{target:{type:"point",x:c.x,y:c.y},restLength:.7*N,stiffness:26,damping:4.25}]:void 0})}});const W=Math.max(18,5*N),q=Array.from(R,([e,t])=>({nodeId:e,label:k.get(e)??e,sensorId:"physical-flow-node-"+kh(e),point:t})),Y=q.map(e=>({id:e.sensorId,sensor:!0,shape:{type:"aabb",x:e.point.x,y:e.point.y,width:W,height:W}})),G=Object.fromEntries(q.map(e=>[e.sensorId,{binId:e.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),H=mh(p,[...vf({x:b.plot.x,y:b.plot.y,width:b.plot.width,height:b.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...Y],"PhysicalFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*N),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});H.bodyLimit=I,H.eviction="oldest",H.observation={...H.observation,sensors:G};const V=Array.from(R,([e,t])=>({id:e,label:k.get(e)??e,x:t.x,y:t.y,sensorId:"physical-flow-node-"+kh(e),incoming:O.get(e)??0,outgoing:D.get(e)??0})),X=C.map(e=>({id:e.id,source:e.source,target:e.target,sourceLabel:k.get(e.source)??e.source,targetLabel:k.get(e.target)??e.target,throughput:e.throughput,packetCount:e.packetCount,path:e.path}));return{config:H,initialSpawns:B,projectionRows:V.filter(e=>e.incoming>0||e.outgoing>0).map(e=>({label:e.label,value:e.incoming,secondary:e.outgoing})),metadata:{kind:"physical-flow",coordinateMode:_,particleCount:B.length,totalThroughput:C.reduce((e,t)=>e+t.throughput,0),plot:b.plot,nodes:V,links:X}}}({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:i});return{...o,config:s.config,initialSpawns:wy(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:gh(t||r.colorBy||"source")}}},PhysicsCustomChart:{frameType:"physics",buildProps:(e,t,n,o,r)=>{const i=o.size??[700,380],s=function(e){const t=function(e,t,n){const o=e?.observation;return{...e,observation:{...o,chartId:t??o?.chartId??"physics-custom",chartType:o?.chartType??"PhysicsCustomChart",onObservation:n??o?.onObservation}}}(e.config,e.chartId,e.onObservation),n=tp(e.colorScheme,e.themeCategorical,N),o=ph(e.size),r={data:e.data,scales:{x:(0,ep.scaleLinear)().domain(e.xExtent??[0,1]).range([o.plot.x,o.plot.x+o.plot.width]),y:(0,ep.scaleLinear)().domain(e.yExtent??[0,1]).range([o.plot.y+o.plot.height,o.plot.y])},dimensions:o,theme:{semantic:e.semantic,categorical:[...n]},resolveColor:np(n,e.colorScheme),config:e.layoutConfig??{},world:new Df(t)},i=e.skipLayout?{}:e.layout(r)??{},s=function(e,t){if(!t?.length)return e;const n=new Map;for(const e of t){const{bodyId:t,...o}=e,r=n.get(t)??[];r.push(o),n.set(t,r)}return e.map(e=>{const t=n.get(e.id);return t?.length?{...e,springs:[...e.springs??[],...t]}:e})}([...i.initialSpawns??i.bodies??[]],i.constraints);return{config:op(t,i),context:r,initialSpawnPacing:i.initialSpawnPacing,initialSpawns:s,result:i}}({chartId:r.chartId,colorScheme:n,config:r.config,data:Array.isArray(e)?e:[],layout:r.layout,layoutConfig:r.layoutConfig,semantic:Fe(qe)??{},size:i,themeCategorical:qe.colors.categorical,xExtent:r.xExtent,yExtent:r.yExtent});return{...o,config:s.config,initialSpawns:wy(s.initialSpawns),projectionRows:[],bodyStyle:s.result.bodyStyle??gh(t||r.colorBy)}}}};function _y(e){const t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function Py(e){if(!e||2>e.length)return;const t=_y(e[0]),n=_y(e[e.length-1]);return null!==t&&null!==n?[t,n]:void 0}function jy(e){const{count:t,byType:n}=function(e){const t={};for(const n of e){const e="string"==typeof n?.type&&n.type.length>0?n.type:"node";t[e]=(t[e]??0)+1}return{count:e.length,byType:t}}(e.marks),o=0===t,r=[...e.extraWarnings??[]];o&&!r.includes("EMPTY_SCENE")&&r.push("EMPTY_SCENE");const i=e.margin,s=i?{x:i.left,y:i.top,width:e.width-i.left-i.right,height:e.height-i.top-i.bottom}:void 0;return{component:"",frameType:e.frameType,status:o?"empty":"ok",empty:o,markCount:t,markCountByType:n,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,...i?{margin:i}:{},...s?{plot:s}:{}}}var Ry=y(require("react")),Cy=y(require("react-dom/server")),Ly=require("d3-scale"),Iy=require("react/jsx-runtime"),Ty=Sr;function $y(e,t,n){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;return t=>me(e,t)??"#999"}const o=Array.isArray(t)?t:n.colors.categorical.length>0?n.colors.categorical:N;return(0,Ly.scaleOrdinal)().domain(e).range(o)}function zy(e,t,n){if(0===e.length)return;const o=$y(e,t,n);return{legendGroups:[{label:"",type:"fill",items:e.map(e=>({label:e})),styleFn:e=>({fill:o(e.label)})}]}}function Ey(e){return"left"===e?"start":"right"===e?"end":e??"start"}function Oy(e){return Number(e.typography.legendSize??e.typography.labelSize??e.typography.tickSize)||11}function Dy(e,t,n,o){const r=Oy(o);return t+n+Math.ceil(e.length*r*.58)}function By(e){const{categories:t,theme:n,position:o="right",totalWidth:r,margin:i,legendLayout:s}=e,{swatchSize:a,labelGap:c,itemGap:l,rowHeight:u}=Ir(s),d=a+c,h="top"===o||"bottom"===o,f=Math.max(a,r-i.left-i.right),p=t.map(e=>Dy(e,a,c,n));if(h){const e=Math.max(a,s?.maxWidth??f),n=[];let o=0,r=0;p.forEach((t,i)=>{const s=0===r?t:r+l+t;r>0&&s>e?(n.push({start:o,end:i,width:r}),o=i,r=t):r=s}),t.length>0&&n.push({start:o,end:t.length,width:r});const i=Ey(s?.align),c=[];return n.forEach((n,o)=>{let r="center"===i?Math.max(0,(e-n.width)/2):"end"===i?Math.max(0,e-n.width):0;for(let e=n.start;n.end>e;e++)c.push({category:t[e],width:p[e],x:r,y:o*u}),r+=p[e]+l}),{items:c,width:Math.max(0,...n.map(e=>e.width)),height:n.length*u,swatchSize:a,labelOffset:d,swatchRadius:0}}const y=Math.max(0,...p);return{items:t.map((e,t)=>({category:e,width:p[t],x:0,y:t*u})),width:y,height:t.length*u,swatchSize:a,labelOffset:d,swatchRadius:0}}function Fy(e){const{legendGroups:t,theme:n,position:o="right",totalWidth:r,margin:i,legendLayout:s}=e,{swatchSize:a,labelGap:c,rowHeight:l}=Ir(s),u=a+c,d=Math.max(12,Oy(n)),h="top"===o||"bottom"===o,f=Math.max(a,r-i.left-i.right);if(h){const o=Math.max(a,s?.maxWidth??f),r=Ey(s?.align);let i=0,c=0;const l=[];for(const r of t){const t=r.items.map(e=>e.label),u=By({...e,categories:t,legendLayout:{...s,maxWidth:Math.max(a,o-d-8),align:"start"}}),h=r.label?d:0,f=r.label?Dy(r.label,0,0,n):0,p=h>0?h+8:0,y=p+u.width,g=Math.max(u.height,f);l.push({group:r,x:i,y:0,itemOffsetX:p,itemOffsetY:0,width:y,height:g,items:u.items}),i+=y+12,c=Math.max(c,g)}const h=l.length>0?i-12:0,p=h>o?0:"center"===r?Math.max(0,(o-h)/2):"end"===r?Math.max(0,o-h):0;return{groups:l.map(e=>({...e,x:e.x+p})),width:h,height:c,swatchSize:a,labelOffset:u,swatchRadius:0}}const p=Tr(t.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),l);let y=0;return{groups:t.map((e,t)=>{const o=e.items.map(e=>Dy(e.label,a,c,n)),r=Math.max(0,...o,e.label?Dy(e.label,0,0,n):0);return y=Math.max(y,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:o[t],x:0,y:t*l}))}}),width:y,height:p.at(-1)?.endY??0,swatchSize:a,labelOffset:u,swatchRadius:0}}function Ny(e){const t="top"===e.position||"bottom"===e.position,n=Math.max(1,e.totalWidth-e.margin.left-e.margin.right);return t?{width:Math.min(e.legendLayout?.maxWidth??n,200),height:e.gradient.label?34:26,swatchSize:12}:{width:e.gradient.label?86:72,height:e.gradient.label?124:108,swatchSize:14}}function Wy(e,t){if(!t||!e||0===e.length)return[];const n="function"==typeof t?t:e=>e[t],o=new Set;for(const t of e){const e=n(t);null!=e&&o.add(e+"")}return Array.from(o)}var qy=require("react/jsx-runtime"),Yy=16,Gy=20;function Hy(e,t){return e.color||t.colors.annotation||t.colors.text}function Vy(e,t,n){const o=e.labelBackground,r=t.colors.background,i=r&&"transparent"!==r?r:t.colors.surface||r;return void 0===o?"none"===n?"none":{type:"halo",fill:i}:!1===o||"none"===o?"none":!0===o||"halo"===o?{type:"halo",fill:i}:"box"===o?{type:"box",fill:i}:{fill:i,...o}}function Xy(e,t,n){return null!=e.x&&t.x?t.x(e.x):n&&null!=e[n]&&t.x?t.x(e[n]):"number"==typeof e.x?e.x:null}function Uy(e,t,n){return null!=e.y&&t.y?t.y(e.y):n&&null!=e[n]&&t.y?t.y(e[n]):"number"==typeof e.y?e.y:null}function Ky(e){const{annotations:t}=e;if(!t||0===t.length)return null;const n=hs(t),o=e.scales.geoProjection,r=o?n.map(e=>{if(!Array.isArray(e.coordinates)||2>e.coordinates.length)return e;const t=o([Number(e.coordinates[0]),Number(e.coordinates[1])]);return t?{...e,x:t[0],y:t[1]}:e}):n,i=!!o&&!e.scales.x&&!e.scales.y,s=e=>Number(e),a=e.scales.x??(i?s:void 0),c=e.scales.y??(i?s:void 0),l=e.projection?"horizontal"===e.projection?"horizontal":"vertical":void 0,u={scales:{x:a,y:c,time:a,value:c,o:e.scales.o,...o?{geoProjection:o}:{}},width:e.layout.width,height:e.layout.height,xAccessor:e.xAccessor,yAccessor:e.yAccessor,data:e.annotationData,frameType:e.projection?"ordinal":o||e.scales.x||e.scales.y?"xy":"network",...l?{projection:l}:{}},d=Bi(e.autoPlaceAnnotations?ds({annotations:r,context:u,..."object"==typeof e.autoPlaceAnnotations?e.autoPlaceAnnotations:{}}):r,(t,n)=>function(e,t,n){const{scales:o,layout:r,theme:i,xAccessor:s,yAccessor:a}=n;switch(e.type){case"y-threshold":{const s=e.value;if(null==s)return null;const a=Hy(e,i),c=e.label,l=e.labelPosition||"right",u=e.strokeDasharray||"6,4",d=e.strokeWidth??1.5;if("horizontal"===n.projection&&o.r){const n=o.r(s);return null==n?null:(0,qy.jsxs)("g",{opacity:e.opacity,children:[(0,qy.jsx)("line",{x1:n,y1:0,x2:n,y2:r.height,stroke:a,strokeWidth:d,strokeDasharray:u}),c&&(0,qy.jsx)(Ei,{x:n+4,y:Yy,textAnchor:"start",fontSize:i.typography.tickSize,fill:a,fontFamily:i.typography.fontFamily,text:c,background:Vy(e,i,"halo")})]},"ann-ythresh-"+t)}const h=o.y?o.y(s):o.r?o.r(s):null;return null==h?null:(0,qy.jsxs)("g",{children:[(0,qy.jsx)("line",{x1:0,y1:h,x2:r.width,y2:h,stroke:a,strokeWidth:d,strokeDasharray:u}),c&&(0,qy.jsx)(Ei,{x:"left"===l?4:"center"===l?r.width/2:r.width-4,y:Gy>h?Math.min(r.height-4,h+Yy):h-6,textAnchor:"left"===l?"start":"center"===l?"middle":"end",fontSize:i.typography.tickSize,fill:a,fontFamily:i.typography.fontFamily,text:c,background:Vy(e,i,"halo")})]},"ann-ythresh-"+t)}case"x-threshold":{const s=e.value;if(null==s)return null;const a="horizontal"===n.projection&&o.r?o.r(s):o.x?o.x(s):null;if(null==a)return null;const c=Hy(e,i),l=e.label,u=e.labelPosition||"top";return(0,qy.jsxs)("g",{opacity:e.opacity,children:[(0,qy.jsx)("line",{x1:a,y1:0,x2:a,y2:r.height,stroke:c,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray||"6,4"}),l&&(0,qy.jsx)(Ei,{x:a>.6*r.width?a-4:a+4,y:"bottom"===u?r.height-4:"center"===u?r.height/2:Yy,textAnchor:a>.6*r.width?"end":"start",fontSize:i.typography.tickSize,fill:c,fontFamily:i.typography.fontFamily,text:l,background:Vy(e,i,"halo")})]},"ann-xthresh-"+t)}case"band":{const n=o.y?.domain?.(),s=e.y0??n?.[0],a=e.y1??n?.[1],c=null!=s&&o.y?o.y(s):null,l=null!=a&&o.y?o.y(a):null;if(null==c||null==l)return null;const u=Math.min(c,l),d=Math.abs(l-c),h=No(e.fill||Hy(e,i),"ssr-band-"+t),f=e.fillOpacity??.1;return(0,qy.jsxs)("g",{opacity:e.opacity,children:[h.def&&(0,qy.jsx)("defs",{children:h.def}),(0,qy.jsx)("rect",{x:0,y:u,width:r.width,height:d,fill:h.fill,fillOpacity:f}),e.label&&(0,qy.jsx)(Ei,{x:r.width-4,y:Math.max(u,0)+Yy,textAnchor:"end",fontSize:i.typography.tickSize,fill:e.color||Hy(e,i),fontFamily:i.typography.fontFamily,fontWeight:"bold",text:e.label,background:Vy(e,i,"halo")})]},"ann-band-"+t)}case"x-band":{const n=o.x?.domain?.(),s=e.x0??n?.[0],a=e.x1??n?.[1],c=null!=s&&o.x?o.x(s):null,l=null!=a&&o.x?o.x(a):null;if(null==c||null==l)return null;const u=Math.min(c,l),d=Math.abs(l-c),h=No(e.fill||Hy(e,i),"ssr-xband-"+t),f=e.fillOpacity??.1;return(0,qy.jsxs)("g",{opacity:e.opacity,children:[h.def&&(0,qy.jsx)("defs",{children:h.def}),(0,qy.jsx)("rect",{x:u,y:0,width:d,height:r.height,fill:h.fill,fillOpacity:f}),e.label&&(0,qy.jsx)(Ei,{x:u+4,y:Yy,textAnchor:"start",fontSize:i.typography.tickSize,fill:e.color||i.colors.primary||Hy(e,i),fontFamily:i.typography.fontFamily,fontWeight:"bold",text:e.label,background:Vy(e,i,"halo")})]},"ann-xband-"+t)}case"category-highlight":{if(null==e.category||!o.o)return null;const s=o.o(e.category+"");if(null==s)return null;const a=o.o.bandwidth?o.o.bandwidth():40,c=Hy(e,i),l=e.opacity??.1,u=e.label;return(0,qy.jsxs)("g","horizontal"===n.projection?{children:[(0,qy.jsx)("rect",{x:0,y:s,width:r.width,height:a,fill:c,opacity:l}),u&&(0,qy.jsx)(Ei,{x:12,y:s+a/2,dominantBaseline:"middle",fill:c,fontSize:i.typography.tickSize,fontWeight:"bold",fontFamily:i.typography.fontFamily,text:u,background:Vy(e,i,"none")})]}:{children:[(0,qy.jsx)("rect",{x:s,y:0,width:a,height:r.height,fill:c,opacity:l}),u&&(0,qy.jsx)(Ei,{x:s+a/2,y:Yy,textAnchor:"middle",fill:c,fontSize:i.typography.tickSize,fontWeight:"bold",fontFamily:i.typography.fontFamily,text:u,background:Vy(e,i,"none")})]},"ann-cathighlight-"+t)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:n,y:r}=function(e,t,n,o){if(Array.isArray(e.coordinates)&&e.coordinates.length>=2&&t.geoProjection){const n=t.geoProjection([e.coordinates[0],e.coordinates[1]]);if(n)return{x:n[0],y:n[1]}}return{x:Xy(e,t,n),y:Uy(e,t,o)}}(e,o,s,a);if(null==n||null==r)return null;const c="text"===e.type,l=e.dx??(c?0:30),u=e.dy??(c?0:-30),d=e.color||i.colors.text;if(!c){const o="callout"===e.type?"callout-circle":e.type,i="callout-circle"===o?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===o?{width:e.width,height:e.height}:void 0;return(0,qy.jsx)(oi,{noteData:{x:n,y:r,dx:l,dy:u,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:o,...i?{subject:i}:{},connector:e.connector||{end:"arrow"},color:d,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-label-"+t)}return(0,qy.jsx)("g",{children:(0,qy.jsx)("text",{x:n+l,y:r+u,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||i.typography.labelSize,fill:d,fontFamily:i.typography.fontFamily,fontWeight:e.fontWeight,opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:e.label||e.title})},"ann-label-"+t)}default:return null}}(t,n,e),e.svgAnnotationRules,u);return d.length>0?(0,qy.jsx)("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:d}):null}var Zy=y(require("react")),Qy=require("react/jsx-runtime");function Jy(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){const t=e.id;return null==t?null:t+""}return null}function eg(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 n=`${e.chartType||""}:${e.title||""}:${Array.isArray(e.data)?e.data.length:0}`;let o=0;for(let e=0;n.length>e;e++)o=31*o+n.charCodeAt(e)|0;return"c"+(o>>>0).toString(36)}function tg(e,t,n){return mr(e.showLegend&&!e.__legendIncludesAutomatic?zy(t,e.colorScheme,n):void 0,e.legend)}var ng={right:110,left:110,top:50,bottom:80};function og(e,t){if(e.__autoLegendMargin&&!rg(e,t))return ng[t]}function rg(e,t){const n=e.__explicitMargin;return"number"==typeof n||!(!n||"object"!=typeof n||"number"!=typeof n[t])}function ig(e,t){const{props:n,categories:o,theme:r,size:i,hasTitle:s}=t,a=n.legendPosition||"right",c={theme:r,position:a,size:i,hasTitle:s,legendLayout:n.legendLayout,minimumMargin:og(n,a),preserveExplicitMargin:rg(n,a)};if(null!=n.legend){const t=tg(n,o,r);(xr(t)||br(t))&&function(e,t){if(t.preserveExplicitMargin)return;const n=t.position||"right",o={theme:t.theme,position:n,totalWidth:t.size[0],totalHeight:t.size[1],margin:e,hasTitle:t.hasTitle,legendLayout:t.legendLayout},r=xr(t.legend)?function(e){const{width:t,height:n,swatchSize:o}=Fy(e);return{width:t,height:n,swatchSize:o}}({...o,legendGroups:t.legend.legendGroups}):br(t.legend)?Ny({...o,gradient:t.legend.gradient}):null;if(!r)return;const i=jr(t.legend),s=Math.max(t.minimumMargin??0,Lr(t.legend,t.legendLayout)),a=Math.max(t.minimumMargin??0,i+r.height+(t.hasTitle?24:0)),c=Math.max(t.minimumMargin??0,i+r.height);"right"===n?e.right=Math.max(e.right,s):"left"===n?e.left=Math.max(e.left,s):"top"===n?e.top=Math.max(e.top,a):e.bottom=Math.max(e.bottom,c)}(e,{...c,legend:t})}else n.showLegend&&o.length>0&&function(e,t){if(0===t.categories.length)return;if(t.preserveExplicitMargin)return;const n=t.position||"right",o=function(e){const{width:t,height:n,swatchSize:o}=By(e);return{width:t,height:n,swatchSize:o}}({categories:t.categories,colorScheme:t.colorScheme,theme:t.theme,position:n,totalWidth:t.size[0],totalHeight:t.size[1],margin:e,hasTitle:t.hasTitle,legendLayout:t.legendLayout}),r=zy(t.categories,t.colorScheme,t.theme),i=jr(r),s=Math.max(t.minimumMargin??0,Lr(r,t.legendLayout)),a=Math.max(t.minimumMargin??0,i+o.height+(t.hasTitle?24:0)),c=Math.max(t.minimumMargin??0,i+o.height);"right"===n?e.right=Math.max(e.right,s):"left"===n?e.left=Math.max(e.left,s):"top"===n?e.top=Math.max(e.top,a):e.bottom=Math.max(e.bottom,c)}(e,{...c,categories:o,colorScheme:n.colorScheme});return a}function sg(e){const{props:t,categories:n,theme:o,size:r,margin:i,hasTitle:s}=e,a=t.legendPosition||"right",c={theme:o,position:a,size:r,margin:i,hasTitle:s,legendLayout:t.legendLayout,idPrefix:t._idPrefix};if(null!=t.legend){const e=tg(t,n,o);if(Zy.isValidElement(e))return e;const r=function(e,t){const n={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,legendDistance:xr(e)||br(e)?e.legendDistance:void 0};return xr(e)?function(e){if(0===(t=e.legendGroups,t.flatMap(e=>e.items.map((t,n)=>({group:e,item:t,itemIndex:n,label:t.label})))).length)return null;var t;const n=Fy(e),o="top"===e.position||"bottom"===e.position,r={legendGroups:e.legendGroups,legendDistance:e.legendDistance},i=e.reservedWidth??Pr(r,e.legendLayout),s=jr(r),a=Rr(e.legendLayout),c=e.theme.colors.grid||e.theme.colors.textSecondary;let l,u;if("left"===e.position?(l=e.margin.left-a-i-s,u=e.margin.top):"top"===e.position?(l=e.margin.left,u=e.margin.top-s-n.height):"bottom"===e.position?(l=e.margin.left,u=e.totalHeight-e.margin.bottom+s):(l=e.totalWidth-e.margin.right+a+s,u=e.margin.top),!o){const t=Tr(e.legendGroups.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),Math.max(n.swatchSize,e.legendLayout?.rowHeight??Ty)),o=e.legendGroups.flatMap((o,r)=>{const s=t[r],a=o.type??"fill",c=[(0,Iy.jsx)("line",{x1:0,y1:s.lineY,x2:i,y2:s.lineY,stroke:"gray"},"legend-group-neatline-"+r)];return o.label&&null!=s.labelY&&c.push((0,Iy.jsx)("text",{y:s.labelY,fontSize:Oy(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:o.label},"legend-group-label-"+r)),c.push((0,Iy.jsx)("g",{transform:`translate(0,${s.itemsY})`,children:o.items.map((t,i)=>{const s=o.styleFn(t,i),c="function"==typeof a?a(t):"line"===a?(0,Iy.jsx)("line",{x1:0,y1:0,x2:n.swatchSize,y2:n.swatchSize,style:s}):(0,Iy.jsx)("rect",{width:n.swatchSize,height:n.swatchSize,rx:n.swatchRadius,style:s});return(0,Iy.jsxs)("g",{transform:`translate(0,${i*Math.max(n.swatchSize,e.legendLayout?.rowHeight??Ty)})`,children:[c,(0,Iy.jsx)("text",{x:n.labelOffset,y:n.swatchSize/2,dominantBaseline:"central",fontSize:Oy(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:t.label})]},`legend-${r}-${i}`)})},"legend-group-"+r)),c});return(0,Iy.jsx)("g",{className:"semiotic-legend",transform:`translate(${l},${u})`,"data-orientation":"vertical",children:o})}const d=n.groups.flatMap((t,r)=>{const{group:i}=t,s=i.type??"fill",a=[];if(i.label&&a.push((0,Iy.jsx)("text",o?{transform:`translate(${t.x},${t.y}) rotate(90)`,textAnchor:"start",fontSize:Oy(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:i.label}:{x:t.x,y:t.y+Oy(e.theme),fontSize:Oy(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:i.label},"legend-group-label-"+r)),a.push(...t.items.map((o,a)=>{const c=i.items[a],l=i.styleFn(c,a),u="function"==typeof s?s(c):"line"===s?(0,Iy.jsx)("line",{x1:0,y1:0,x2:n.swatchSize,y2:n.swatchSize,style:l}):(0,Iy.jsx)("rect",{width:n.swatchSize,height:n.swatchSize,rx:n.swatchRadius,style:l});return(0,Iy.jsxs)("g",{transform:`translate(${t.x+t.itemOffsetX+o.x},${t.y+t.itemOffsetY+o.y})`,children:[u,(0,Iy.jsx)("text",{x:n.labelOffset,y:n.swatchSize/2,dominantBaseline:"central",fontSize:Oy(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:o.category})]},`legend-${r}-${a}`)})),o&&n.groups.length-1>r){const e=t.x+t.width+6;a.push((0,Iy.jsx)("line",{x1:e,y1:0,x2:e,y2:n.height,stroke:c},"legend-group-separator-"+r))}return a});return(0,Iy.jsx)("g",{className:"semiotic-legend",transform:`translate(${l},${u})`,"data-orientation":o?"horizontal":"vertical",children:d})}({...n,legendGroups:e.legendGroups}):br(e)?function(e){const t=Ny(e),n="top"===e.position||"bottom"===e.position,o={gradient:e.gradient,legendDistance:e.legendDistance},r=Pr(o),i=jr(o),s=Rr(e.legendLayout),a=(e.idPrefix?e.idPrefix+"-":"")+"semiotic-static-gradient-legend",c=e.gradient.format||(e=>Math.round(100*e)/100+"");let l,u;"left"===e.position?(l=e.margin.left-s-r-i,u=e.margin.top):"top"===e.position?(l=e.margin.left,u=e.margin.top-i-t.height):"bottom"===e.position?(l=e.margin.left,u=e.totalHeight-e.margin.bottom+i):(l=e.totalWidth-e.margin.right+s+i,u=e.margin.top);const d=Array.from({length:17},(t,o)=>{const r=o/16;return(0,Iy.jsx)("stop",{offset:100*r+"%",stopColor:e.gradient.colorFn(n?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]))},o)});if(n){const n=12,o=e.gradient.label?0:void 0,r=e.gradient.label?8:0;return(0,Iy.jsxs)("g",{className:"semiotic-legend",transform:`translate(${l},${u})`,children:[(0,Iy.jsx)("defs",{children:(0,Iy.jsx)("linearGradient",{id:a,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:d})}),e.gradient.label&&(0,Iy.jsx)("text",{x:t.width/2,y:o,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),(0,Iy.jsx)("rect",{x:0,y:r,width:t.width,height:n,fill:`url(#${a})`,rx:2}),(0,Iy.jsx)("text",{x:0,y:r+n+12,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:c(e.gradient.domain[0])}),(0,Iy.jsx)("text",{x:t.width,y:r+n+12,textAnchor:"end",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:c(e.gradient.domain[1])})]})}const h=e.gradient.label?-6:void 0;return(0,Iy.jsxs)("g",{className:"semiotic-legend",transform:`translate(${l},${u+(e.gradient.label?12:0)})`,children:[(0,Iy.jsx)("defs",{children:(0,Iy.jsx)("linearGradient",{id:a,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:d})}),e.gradient.label&&(0,Iy.jsx)("text",{x:0,y:h,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),(0,Iy.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${a})`,rx:2}),(0,Iy.jsx)("text",{x:19,y:10,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:c(e.gradient.domain[1])}),(0,Iy.jsx)("text",{x:19,y:100,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:c(e.gradient.domain[0])})]})}({...n,gradient:e.gradient}):null}(e,c);return r||(xr(e)||br(e)?null:e??null)}return t.showLegend&&0!==n.length?function(e){const{categories:t,colorScheme:n,theme:o,position:r="right",totalWidth:i,totalHeight:s,margin:a}=e;if(!t||0===t.length)return null;const c=$y(t,n,o),l="top"===r||"bottom"===r,u=By(e),d=zy(t,n,o),h=e.reservedWidth??Pr(d,e.legendLayout),f="number"==typeof e.legendDistance?Math.max(0,e.legendDistance):jr(d),p=Rr(e.legendLayout);let y,g;if("left"===r?(y=a.left-p-h-f,g=a.top):"top"===r?(y=a.left,g=a.top-f-u.height):"bottom"===r?(y=a.left,g=s-a.bottom+f):(y=i-a.right+p+f,g=a.top),l){const e=u.items.map((e,t)=>(0,Iy.jsxs)("g",{transform:`translate(${e.x},${e.y})`,children:[(0,Iy.jsx)("rect",{width:u.swatchSize,height:u.swatchSize,fill:c(e.category),rx:u.swatchRadius}),(0,Iy.jsx)("text",{x:u.labelOffset,y:u.swatchSize/2,dominantBaseline:"central",fontSize:Oy(o),fill:o.colors.text,fontFamily:o.typography.fontFamily,children:e.category})]},"legend-"+t));return(0,Iy.jsx)("g",{className:"semiotic-legend",transform:`translate(${y},${g})`,children:e})}const m=Tr([{hasLabel:!1,itemCount:t.length}],Math.max(u.swatchSize,e.legendLayout?.rowHeight??Ty))[0],x=u.items.map((e,t)=>(0,Iy.jsxs)("g",{transform:`translate(${e.x},${e.y+m.itemsY})`,children:[(0,Iy.jsx)("rect",{width:u.swatchSize,height:u.swatchSize,fill:c(e.category),rx:u.swatchRadius}),(0,Iy.jsx)("text",{x:u.labelOffset,y:u.swatchSize/2,dominantBaseline:"central",fontSize:Oy(o),fill:o.colors.text,fontFamily:o.typography.fontFamily,children:e.category})]},"legend-"+t));return(0,Iy.jsxs)("g",{className:"semiotic-legend",transform:`translate(${y},${g})`,children:[(0,Iy.jsx)("line",{x1:0,y1:m.lineY,x2:h,y2:m.lineY,stroke:"gray"}),x]})}({categories:n,colorScheme:t.colorScheme,theme:o,position:a,totalWidth:r[0],totalHeight:r[1],margin:i,hasTitle:s,legendLayout:t.legendLayout,idPrefix:t._idPrefix}):null}function ag(e){return Math.round(100*e)/100+""}function cg(e,t){const n=Ze(t.theme),o=t.background??n.background,r=t.idPrefix?t.idPrefix+"-":"",i="string"==typeof t.title?t.title:void 0,s=i?r+"semiotic-title":void 0,a=t.description?r+"semiotic-desc":void 0,c=[s,a].filter(Boolean).join(" ")||void 0;return(0,Qy.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className,width:t.width,height:t.height,role:"img","aria-labelledby":c,style:{fontFamily:n.fontFamily},children:[i&&(0,Qy.jsx)("title",{id:s,children:i}),t.description&&(0,Qy.jsx)("desc",{id:a,children:t.description}),t.defs&&(0,Qy.jsx)("defs",{children:t.defs}),o&&"transparent"!==o&&(0,Qy.jsx)("rect",{x:0,y:0,width:t.width,height:t.height,fill:o}),(0,Qy.jsx)("g",{id:r+"data-area",transform:t.innerTransform,children:e}),i&&(0,Qy.jsx)("text",{id:r+"chart-title",x:t.width/2,y:Ts,textAnchor:"middle",fontSize:n.titleSize,fontWeight:"bold",fill:n.text,fontFamily:n.fontFamily,children:i}),t.legend&&(0,Qy.jsx)("g",{id:r+"legend",children:t.legend}),t.outerElements]})}var lg=require("react/jsx-runtime");function ug(e,t){const n=Ke(e.theme),o=e.size||[500,300],r=Es({top:20,right:20,bottom:30,left:40,...e.margin},e.title),i=$s(e.title),s=E(e.data),a=e.showLegend?Wy(s,e.colorAccessor||e.groupAccessor||e.categoryAccessor):[];ig(r,{props:e,categories:a,theme:n,size:o,hasTitle:i});const c=o[0]-r.left-r.right,l=o[1]-r.top-r.bottom,u="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),d=e.colorScheme||n.colors.categorical,h={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:Le(e.gradientFill),lineGradient:Ie(e.lineGradient),semanticLineStops:e.semanticLineStops,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:d,themeCategorical:n.colors.categorical,themeSemantic:Fe(n),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:r,layoutSelection:e.layoutSelection,barColors:e.barColors,showValues:e.showValues,heatmapValueFormat:e.heatmapValueFormat},f=new no(h);if(e.data&&f.ingest({inserts:s,bounded:!0}),f.computeScene({width:c,height:l}),!f.scales||0===f.scene.length)return t&&(t.evidence=jy({frameType:"xy",width:o[0],height:o[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:f.scales?[]:["NO_SCALES"],margin:r})),Cy.renderToStaticMarkup(cg(null,{width:o[0],height:o[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left},${r.top})`,innerWidth:c,innerHeight:l,idPrefix:e._idPrefix}));const p=e._idPrefix,y=vl({nodes:f.scene,renderMode:e.renderMode,fallback:(e,t)=>ga(e,t,p)});t&&(t.evidence=jy({frameType:"xy",width:o[0],height:o[1],marks:y.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,xDomain:Py(f.scales.x?.domain?.()),yDomain:Py(f.scales.y?.domain?.()),legendItems:a.length>0?a.length:void 0,margin:r}));const g=e.showGrid?function(e,t,n,o,r){const{grid:i}=Ze(n),s=o?o+"-":"",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=As(e.x,a,r),u=As(e.y,c,r);return(0,Qy.jsxs)("g",{id:s+"grid",className:"semiotic-grid",opacity:.8,children:[l.map((n,o)=>{const r=e.x(n);return(0,Qy.jsx)("line",{x1:r,y1:0,x2:r,y2:t.height,stroke:i,strokeWidth:.5},"gx-"+o)}),u.map((n,o)=>{const r=e.y(n);return(0,Qy.jsx)("line",{x1:0,y1:r,x2:t.width,y2:r,stroke:i,strokeWidth:.5},"gy-"+o)})]})}(f.scales,{width:c,height:l},n,p,e.axisExtent):null,m=y.map(e=>e.element),x=eg(e)+"-plot-clip",b=!1!==e.showAxes?function(e,t,n,o,r){const i=Ze(o),s=Rr(n.legendLayout),a=n.legend&&"left"===n.legendPosition&&s>0?s:n.margin?.left??40,c="exact"===n.axisExtent?5:Math.min(5,Math.max(2,Math.floor(t.width/70))),l="exact"===n.axisExtent?5:Math.min(5,Math.max(2,Math.floor(t.height/30))),u=n.axes?.find(e=>"bottom"===e.orient),d=n.axes?.find(e=>"left"===e.orient),h=u?.tickValues??As(e.x,u?.ticks??c,n.axisExtent),f=h.map(e=>e.valueOf()),p=u?.tickFormat||n.xFormat||n.tickFormatTime||ag,y=h.map((t,n)=>({pixel:e.x(t),label:p(t,n,f)})),g=d?.tickValues??As(e.y,d?.ticks??l,n.axisExtent),m=d?.tickFormat||n.yFormat||n.tickFormatValue||ag,x=g.map(t=>({pixel:e.y(t),label:m(t)})),b=u?.label??n.xLabel,v=d?.label??n.yLabel;return(0,Qy.jsxs)("g",{id:(r?r+"-":"")+"axes",className:"stream-axes",children:[!1!==u?.baseline&&(0,Qy.jsx)("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:i.border,strokeWidth:1}),y.map((e,n)=>(0,Qy.jsxs)("g",{transform:`translate(${e.pixel},${t.height})`,children:[(0,Qy.jsx)("line",{y2:5,stroke:i.border,strokeWidth:1}),(0,Qy.jsx)("text",{y:18,textAnchor:"middle",fontSize:i.tickSize,fill:i.textSecondary,fontFamily:i.fontFamily,children:e.label})]},"xtick-"+n)),b&&(0,Qy.jsx)("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:i.labelSize,fill:i.text,fontFamily:i.fontFamily,children:b}),!1!==d?.baseline&&(0,Qy.jsx)("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:i.border,strokeWidth:1}),x.map((e,t)=>(0,Qy.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,Qy.jsx)("line",{x2:-5,stroke:i.border,strokeWidth:1}),(0,Qy.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:i.tickSize,fill:i.textSecondary,fontFamily:i.fontFamily,children:e.label})]},"ytick-"+t)),v&&(0,Qy.jsx)("text",{x:15-a,y:t.height/2,textAnchor:"middle",fontSize:i.labelSize,fill:i.text,fontFamily:i.fontFamily,transform:`rotate(-90, ${15-a}, ${t.height/2})`,children:v})]})}(f.scales,{width:c,height:l},e,n,p):null,v=e.annotations?Ky({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:s,scales:{x:f.scales.x,y:f.scales.y},layout:{width:c,height:l},theme:n,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:p}):null,w=e.svgPreRenderers&&f.scales?e.svgPreRenderers.map((e,t)=>{try{return(0,lg.jsx)(Ry.Fragment,{children:e(f.scene,f.scales,{width:c,height:l})},"pre-"+t)}catch{return null}}).filter(Boolean):null,k=sg({props:e,categories:a,theme:n,size:o,margin:r,hasTitle:i});return Cy.renderToStaticMarkup(cg((0,lg.jsxs)(lg.Fragment,{children:[e.backgroundGraphics,w,g,(0,lg.jsx)("defs",{children:(0,lg.jsx)("clipPath",{id:x,children:(0,lg.jsx)("rect",{x:0,y:0,width:c,height:l})})}),(0,lg.jsx)("g",{clipPath:`url(#${x})`,children:m}),b,v,e.foregroundGraphics,f.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left},${r.top})`,innerWidth:c,innerHeight:l,legend:k,idPrefix:e._idPrefix}))}var dg=y(require("react-dom/server")),hg=require("d3-scale"),fg=class{constructor(){this.colorSchemeMap=new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(e,t,n){if(t&&"function"==typeof e.pieceStyle){const o=e.pieceStyle(t,n);return o&&!o.fill&&n?{...o,fill:this.getColorFromScheme(e,n)}:o}return e.pieceStyle&&"object"==typeof e.pieceStyle?e.pieceStyle:e.barColors&&n?{fill:e.barColors[n]||"#007bff"}:{fill:n?this.getColorFromScheme(e,n):"#007bff"}}resolveSummaryStyle(e,t,n){return t&&"function"==typeof e.summaryStyle?e.summaryStyle(t,n):e.summaryStyle&&"object"==typeof e.summaryStyle?e.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(e,t){const n=this.colorSchemeMap.get(t);if(n)return n;const o=Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical||fe,r=o[this.colorSchemeIndex%o.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(t,r),r}};function pg(e){const t=e.getSymbol;if(!t)return null;const n=e.config.symbolMap,o=new Map;let r=0;return e=>{const i=t(e)+"",s=n?.[i];if(s)return s;let a=o.get(i);return a||(a=ln[r%ln.length],r++,o.set(i,a)),a}}function yg(e,t,n,o,r,i,s){e.push(t?{type:"symbol",x:o,y:r,size:Math.PI*i*i,symbolType:t(n),style:s,datum:n}:{type:"point",x:o,y:r,r:i,style:s,datum:n})}function gg(e,t){const{columns:n,config:o,resolvePieceStyle:r}=e,i=[],s=Math.min(t.width,t.height)/2-4,a="donut"===o.chartType?o.innerRadius||60:0,c=-Math.PI/2+(o.startAngle||0)*Math.PI/180,l=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI,u=null!=o.sweepAngle&&360>o.sweepAngle,d=Object.values(n),h=d.some(e=>{const t=e.pieceData[0];return t&&("number"==typeof t._pct||"number"==typeof t._pctStart||null!=t._roundedEnds)}),f=u&&!h&&d.length>1&&(o.cornerRadius??0)>0;for(let e=0;d.length>e;e++){const t=d[e],n=t.pieceData[0],u="number"==typeof n?._pctStart?n._pctStart:t.pctStart,h=c+u*l,p=c+(u+("number"==typeof n?._pct?n._pct:t.pct))*l,y=r(t.pieceData[0],t.name),g=0===e,m=e===d.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:h,endAngle:p,...o.cornerRadius&&{cornerRadius:o.cornerRadius},style:y,datum:n?._nonInteractive?null:t.pieceData,category:t.name};n?._roundedEnds?x.roundedEnds=n._roundedEnds:f&&(x.roundedEnds={start:g,end:m}),n?._gradientBand&&(x._gradientBand=n._gradientBand),i.push(x)}return i}var mg=require("d3-array");function xg(e){const t=e.length,n=e[0],o=e[t-1];return{n:t,min:n,q1:(0,mg.quantile)(e,.25)??n,median:(0,mg.quantile)(e,.5)??(n+o)/2,q3:(0,mg.quantile)(e,.75)??o,max:o,mean:e.reduce((e,t)=>e+t,0)/t}}var bg=require("d3-scale"),vg={bar:function(e,t){const{scales:n,columns:o,config:r,getR:i,getStack:s,resolvePieceStyle:a}=e,{r:c,projection:l}=n,u=[],d="vertical"===l,h="horizontal"===l,f=r.normalize,p=[];if(s){const e=new Set;for(const t of Object.values(o))for(const n of t.pieceData){const t=s(n);e.has(t)||(e.add(t),p.push(t))}}else p.push("_default");for(const e of Object.values(o)){const t=new Map;for(const n of e.pieceData){const e=s?s(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const o=t.get(e);o.total+=i(n),o.pieces.push(n)}let n=0;if(f)for(const e of t.values())n+=Math.abs(e.total);let o=0,r=0;for(const i of p){const l=t.get(i);if(!l)continue;let p=l.total;f&&n>0&&(p/=n);const y=a(l.pieces[0],s?i:e.name),g={...l.pieces[0],__aggregateValue:l.total,__pieceCount:l.pieces.length,category:e.name};if(d){const t=c(0>p?r:o+p),n=0>p?c(r+p)-c(r):c(o)-c(o+p);u.push(Ut(e.x,t,e.width,Math.abs(n),y,g,i)),0>p?r+=p:o+=p}else if(h){const t=c(0>p?r+p:o),n=0>p?c(r)-c(r+p):c(o+p)-c(o);u.push(Ut(t,e.x,Math.abs(n),e.width,y,g,i)),0>p?r+=p:o+=p}}}const y="vertical"===l,g=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=y?0>t?"bottom":"top":0>t?"left":"right",r.gradientFill&&(e.fillGradient=r.gradientFill)}if(g>0){const e=new Map;for(const t of u){if("rect"!==t.type)continue;const n=t.datum?.category||"";e.has(n)||e.set(n,[]),e.get(n).push(t)}for(const t of e.values()){if(0===t.length)continue;const e=t.filter(e=>(e.datum?.__aggregateValue??0)>=0),n=t.filter(e=>0>(e.datum?.__aggregateValue??0));e.length>0&&(e.reduce(y?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t).roundedTop=g),n.length>0&&(n.reduce(y?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t).roundedTop=g)}}return u},clusterbar:function(e,t){const{scales:n,columns:o,config:r,getR:i,getGroup:s,resolvePieceStyle:a}=e,{r:c,projection:l}=n,u=[],d="vertical"===l,h=[],f=new Set;for(const e of Object.values(o))for(const t of e.pieceData){const e=s?s(t):"_default";f.has(e)||(f.add(e),h.push(e))}const p=h.length||1;for(const e of Object.values(o)){const t=e.width/p,n=.2*t,o=t-n,r=new Map;for(const t of e.pieceData){const e=s?s(t):"_default";r.has(e)||r.set(e,[]),r.get(e).push(t)}for(let s=0;h.length>s;s++){const l=r.get(h[s])||[];for(const r of l){const l=i(r),f=a(r,h[s]);if(d){const i=e.x+s*t+n/2,a=c(0),d=c(l);u.push(Ut(i,Math.min(a,d),o,Math.abs(a-d),f,r,h[s]))}else{const i=e.x+s*t+n/2,a=c(0),d=c(l);u.push(Ut(Math.min(a,d),i,Math.abs(d-a),o,f,r,h[s]))}}}}const y=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=i(e.datum);y>0&&(e.roundedTop=y),e.roundedEdge=d?0>t?"bottom":"top":0>t?"left":"right",r.gradientFill&&(e.fillGradient=r.gradientFill)}return u},point:function(e,t){const{scales:n,columns:o,getR:r,multiScales:i,resolvePieceStyle:s}=e,{r:a,projection:c}=n,l=[],u="vertical"===c,d="radial"===c,h=i.length>0,f=pg(e),p=2*Math.PI,y=-Math.PI/2;for(const e of Object.values(o))for(const t of e.pieceData){const n=t.__rIndex??0,o=t.__rValue??r(t),c=h&&i[n]||a,g=s(t,e.name),m=g.r||5;let x,b;if(d){const t=y+(e.pctStart+e.pct/2)*p,n=c(o);x=Math.cos(t)*n,b=Math.sin(t)*n}else u?(x=e.middle,b=c(o)):(x=c(o),b=e.middle);yg(l,f,t,x,b,m,g)}return l},swarm:function(e,t){const{scales:n,columns:o,getR:r,resolvePieceStyle:i}=e,{r:s,projection:a}=n,c=[],l="vertical"===a,u=pg(e);for(const e of Object.values(o)){const t=e.width/2;for(let n=0;e.pieceData.length>n;n++){const o=e.pieceData[n],a=r(o),d=i(o,e.name),h=d.r||4,f=(7919*n%100/100-.5)*t*.8;yg(c,u,o,l?e.middle+f:s(a),l?s(a):e.middle+f,h,d)}}return c},pie:gg,donut:gg,boxplot:function(e,t){const{scales:n,columns:o,config:r,getR:i,resolveSummaryStyle:s}=e,{r:a,projection:c}=n,l=[],u="vertical"===c,d=!1!==r.showOutliers;for(const t of Object.values(o)){const n=t.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===n.length)continue;const o=n[0],r=n[n.length-1],c=(0,mg.quantile)(n,.25)??o,h=(0,mg.quantile)(n,.5)??(o+r)/2,f=(0,mg.quantile)(n,.75)??r,p=f-c,y=c-1.5*p,g=f+1.5*p,m=n.find(e=>e>=y)??o,x=[...n].reverse().find(e=>g>=e)??r,b=s(t.pieceData[0],t.name),v=[];if(d)for(const e of t.pieceData){const n=i(e);if(y>n||n>g){const o=u?t.middle:a(n),r=u?a(n):t.middle;v.push({px:o,py:r,value:n,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(h),q3Pos:a(f),maxPos:a(x),stats:{n:n.length,min:m,q1:c,median:h,q3:f,max:x,mean:n.reduce((e,t)=>e+t,0)/n.length},style:b,datum:t.pieceData,category:t.name,outliers:v}),d)for(const t of v)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:n,columns:o,config:r,getR:i,resolveSummaryStyle:s}=e,{r:a,projection:c}=n,l=[],u="vertical"===c,d=r.bins||20,h=!1!==r.showIQR;for(const e of Object.values(o)){const t=e.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const n=t[0],o=t[t.length-1],r=(o-n)/d||1,c=Array(d).fill(0);for(const e of t)c[Math.min(Math.floor((e-n)/r),d-1)]++;const f=we(c,1),p=e.width/2*.9;let y;if(u){y=`M ${e.middle} ${a(n)}`;for(let t=0;d>t;t++){const o=a(n+(t+.5)*r);y+=` L ${e.middle+c[t]/f*p} ${o}`}y+=` L ${e.middle} ${a(o)}`;for(let t=d-1;t>=0;t--){const o=a(n+(t+.5)*r);y+=` L ${e.middle-c[t]/f*p} ${o}`}y+=" Z"}else{y=`M ${a(n)} ${e.middle}`;for(let t=0;d>t;t++)y+=` L ${a(n+(t+.5)*r)} ${e.middle-c[t]/f*p}`;y+=` L ${a(o)} ${e.middle}`;for(let t=d-1;t>=0;t--)y+=` L ${a(n+(t+.5)*r)} ${e.middle+c[t]/f*p}`;y+=" Z"}const g=s(e.pieceData[0],e.name);let m;if(h&&t.length>=4){const r=(0,mg.quantile)(t,.25)??n,i=(0,mg.quantile)(t,.5)??(n+o)/2,s=(0,mg.quantile)(t,.75)??o;m={q1Pos:a(r),medianPos:a(i),q3Pos:a(s),centerPos:e.middle,isVertical:u}}const x=u?{x:e.x,y:Math.min(a(o),a(n)),width:e.width,height:Math.abs(a(o)-a(n))}:{x:Math.min(a(n),a(o)),y:e.x,width:Math.abs(a(o)-a(n)),height:e.width};l.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:x,iqrLine:m,stats:xg(t),style:g,datum:e.pieceData,category:e.name})}return l},histogram:function(e,t){const{scales:n,columns:o,config:r,getR:i,resolveSummaryStyle:s}=e,{r:a}=n,c=[],l=r.bins||25,u=r.normalize,d=a.domain?.(),h=d?+d[0]:void 0,f=d?+d[1]:void 0;for(const e of Object.values(o)){const t=e.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const[n,o]=ve(t),r=null!=h&&isFinite(h)?h:n,d=null!=f&&isFinite(f)?f:o,p=(d-r)/l||1,y=Array(l).fill(0);for(const e of t)r>e||e>d||y[Math.min(Math.floor((e-r)/p),l-1)]++;const g=t.length,m=we(y,1),x=s(e.pieceData[0],e.name);for(let t=0;l>t;t++){if(0===y[t])continue;const n=(u?y[t]/g:y[t]/m)*e.width*.9,o=a(r+t*p),i=a(r+(t+1)*p);c.push(Ut(Math.min(o,i),e.x+e.width-n,Math.abs(i-o),n,x,{bin:t,count:y[t],range:[r+t*p,r+(t+1)*p],category:e.name},e.name))}}return c},ridgeline:function(e,t){const{scales:n,columns:o,config:r,getR:i,resolveSummaryStyle:s}=e,{r:a,projection:c}=n,l=[],u=r.bins||20,d="horizontal"===c,h=r.amplitude||1.5;for(const e of Object.values(o)){const t=e.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const n=t[0],o=t[t.length-1],r=(o-n)/u||1,c=Array(u).fill(0);for(const e of t)n>e||e>o||c[Math.min(Math.floor((e-n)/r),u-1)]++;const f=we(c,1),p=s(e.pieceData[0],e.name),y=e.width*h;let g;if(d){const t=e.x+e.width;g=`M ${a(n)} ${t}`;for(let e=0;u>e;e++)g+=` L ${a(n+(e+.5)*r)} ${t-c[e]/f*y}`;g+=` L ${a(o)} ${t} Z`}else{const t=e.x;g=`M ${t} ${a(n)}`;for(let e=0;u>e;e++){const o=a(n+(e+.5)*r);g+=` L ${t+c[e]/f*y} ${o}`}g+=` L ${t} ${a(o)} Z`}const m=d?{x:Math.min(a(n),a(o)),y:e.x,width:Math.abs(a(o)-a(n)),height:e.width}:{x:e.x,y:Math.min(a(o),a(n)),width:e.width,height:Math.abs(a(o)-a(n))};l.push({type:"violin",pathString:g,translateX:0,translateY:0,bounds:m,stats:xg(t),style:{...p,fillOpacity:p.fillOpacity??.5},datum:e.pieceData,category:e.name})}return l},timeline:function(e,t){const{scales:n,columns:o,getRawRange:r,resolvePieceStyle:i}=e,{r:s,projection:a}=n,c=[],l="horizontal"===a;for(const e of Object.values(o))for(const t of e.pieceData){const n=r(t);if(!n)continue;const[o,a]=n,u=i(t,e.name);if(l){const n=s(Math.min(o,a)),r=s(Math.max(o,a));c.push(Ut(n,e.x,r-n,e.width,u,t,e.name))}else{const n=s(Math.max(o,a)),r=s(Math.min(o,a));c.push(Ut(e.x,n,e.width,r-n,u,t,e.name))}}return c},funnel:function(e,t){const{columns:n,getR:o,getStack:r,resolvePieceStyle:i}=e,s=[],a=t.width/2,c=!1!==e.config.showLabels,l=e.scales.o.domain().map(e=>n[e]).filter(Boolean);if(0===l.length)return s;const u=[],d=new Set;for(const e of l)for(const t of e.pieceData){const e=r?r(t):"_default";d.has(e)||(d.add(e),u.push(e))}const h=u.length>1&&"_default"!==u[0],f=[];let p=0;for(const e of l){const t=new Map;let n=0;for(const i of e.pieceData){const e=r?r(i):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const s=t.get(e),a=o(i);s.total+=a,s.pieces.push(i),n+=a}f.push({col:e,groups:t,stepTotal:n}),h||n>p&&(p=n)}if(h)for(const e of f){let t=0,n=0;for(let o=0;u.length>o;o++){const r=e.groups.get(u[o]);r&&(o%2==0?t+=r.total:n+=r.total)}const o=Math.max(t,n);o>p&&(p=o)}if(0===p)return s;const y=new Map;for(const e of u){const t=f[0].groups.get(e);y.set(e,t?.total??0)}const g=f[0].stepTotal,m=h?.95*a:.9*t.width,x=(0,bg.scaleLinear)().domain([0,p]).range([0,m]),b=e.config.connectorOpacity??.3;let v=new Map;for(let t=0;f.length>t;t++){const n=f[t],o=n.col,r=0===t,l=o.width,d=.55*l,p=o.x+(l-d)/2,m=new Map;if(h){let e=0;for(const t of u){const o=n.groups.get(t);o&&(e+=x(o.total))}let t=a,l=a;for(let h=0;u.length>h;h++){const f=u[h],g=n.groups.get(f);if(!g)continue;const b=x(g.total),v=h%2==0,w=v?t:l-b;v?t+=b:l-=b;const k=i(g.pieces[0],f),S=y.get(f)??g.total,A={...g.pieces[0],__funnelValue:g.total,__funnelPercent:S>0?g.total/S*100:0,__funnelStep:o.name,__funnelIsFirstStep:r,__aggregateValue:g.total,__pieceCount:g.pieces.length,category:f};c&&(0===h&&(A.__funnelStepLabel=o.name,A.__funnelStepLabelX=a,A.__funnelStepLabelY=p,A.__funnelRowWidth=e),A.__funnelValueLabelX=w+b/2,A.__funnelValueLabelY=p,A.__funnelBarW=b),s.push(Ut(w,p,b,d,k,A,f)),m.set(f,{x:w,y:p,w:b,h:d})}}else{const e=n.stepTotal,t=x(e),l=a-t/2,h=u[0],f="_default"!==h,y=n.groups.get(h)?.pieces[0]??o.pieceData[0],b=f?h:o.name,v=i(y,b),w=g>0?e/g*100:0,k={...y,__funnelValue:e,__funnelPercent:w,__funnelStep:o.name,__funnelIsFirstStep:r,category:f?h:o.name};c&&(k.__funnelStepLabel=o.name,k.__funnelStepLabelX=a,k.__funnelStepLabelY=p,k.__funnelRowWidth=t,k.__funnelValueLabelX=a,k.__funnelValueLabelY=p,k.__funnelBarW=t),s.push(Ut(l,p,t,d,v,k,b)),m.set(h,{x:l,y:p,w:t,h:d})}if(t>0&&v.size>0){const t=h?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=n.groups.get(r);return i(e?e.pieces[0]:o.pieceData[0],"_default"===r?o.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:b},datum:n.groups.get(r)?.pieces[0]??o.pieceData[0],category:"_default"===r?o.name:r};s.push(l)}}v=m}return s},"bar-funnel":function(e,t){const{columns:n,getR:o,getStack:r,resolvePieceStyle:i,scales:s}=e,a=[],c=s.o.domain().map(e=>n[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 d=l.length>1&&"_default"!==l[0],h=[];for(const e of c){const t=new Map;let n=0;for(const i of e.pieceData){const e=r?r(i):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const s=t.get(e),a=o(i);s.total+=a,s.pieces.push(i),n+=a}h.push({col:e,groups:t,stepTotal:n})}const f=new Map;for(const e of l){const t=h[0]?.groups.get(e);f.set(e,t?.total??0)}const p=s.r,y=d?l.length:1,g=d?.15:0;for(let e=0;h.length>e;e++){const t=h[e],n=t.col,o=0===e,r=e>0?h[e-1]:null,s=n.width/y,c=s*g,u=s-c;for(let e=0;l.length>e;e++){const h=l[e],y=t.groups.get(h);if(!y)continue;const g=y.total,m=f.get(h)??g,x=m>0?g/m*100:0,b=r?.groups.get(h),v=o?0:Math.max(0,(b?.total??g)-g),w=n.x+e*s+c/2,k=p(g),S=p(0)-k,A=i(y.pieces[0],d?h:n.name),M={...y.pieces[0],__barFunnelValue:g,__barFunnelPercent:x,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:n.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:n.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:p(g+v)};if(a.push(Ut(w,k,u,S,A,M,d?h:n.name)),v>0){const e=p(g+v),t=k-e,o={...A},r={...y.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:n.name,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:n.name};a.push(Ut(w,e,u,t,o,r,d?h:n.name))}}}return a},swimlane:function(e,t){const{scales:n,columns:o,getR:r,getStack:i,resolvePieceStyle:s}=e,{r:a,projection:c}=n,l=[],u="horizontal"===c,d=e.config.gradientFill,h=u?"left":"bottom",f=e.config.trackFill;if(f){const e="string"==typeof f?f:f.color,t="string"==typeof f?1:f.opacity??1,[n,r]=a.range(),i=Math.min(n,r),s=Math.abs(r-n);for(const n of Object.values(o)){const o={fill:e,opacity:t},r=u?Ut(i,n.x,s,n.width,o,null,"__track__"):Ut(n.x,i,n.width,s,o,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(o)){let t=0;const n=l.length;for(const n of e.pieceData){const o=Math.abs(r(n));if(0===o)continue;const c=i?i(n):e.name,f=s(n,c);let p;if(u){const r=a(t),i=a(t+o);p=Ut(r,e.x,i-r,e.width,f,n,c)}else{const r=a(t+o),i=a(t);p=Ut(e.x,r,e.width,i-r,f,n,c)}d&&(p.fillGradient=d,p.roundedEdge=h),l.push(p),t+=o}if(p>0&&l.length>n){const e=l.slice(n),t=e[0],o=e[e.length-1];1===e.length?t.cornerRadii={tl:p,tr:p,br:p,bl:p}:u?(t.cornerRadii={tl:p,bl:p},o.cornerRadii={tr:p,br:p}):(t.cornerRadii={bl:p,br:p},o.cornerRadii={tl:p,tr:p})}}return l}},wg=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],kg=["scene-style","data-paint","accessibility","evidence"],Sg=(e,t)=>({retainedData:e,invalidations:t}),Ag=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Mg=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],_g=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Pg=["scene-geometry","data-paint","accessibility","evidence"],jg=["scene-style","data-paint","accessibility","evidence"],Rg=[],Cg={chartType:Sg("rebuild",Ag),runtimeMode:Sg("rebuild",Ag),categoryAccessor:Sg("rebuild",Ag),valueAccessor:Sg("rebuild",Ag),oAccessor:Sg("rebuild",Ag),rAccessor:Sg("rebuild",Ag),stackBy:Sg("rebuild",Ag),groupBy:Sg("rebuild",Ag),timeAccessor:Sg("rebuild",Ag),accessorRevision:Sg("rebuild",Ag),colorAccessor:Sg("rebuild",jg),symbolAccessor:Sg("rebuild",Pg),connectorAccessor:Sg("rebuild",Pg),dataIdAccessor:Sg("rebuild",Pg),projection:Sg("preserve",Mg),extentPadding:Sg("preserve",Mg),axisExtent:Sg("preserve",Mg),rExtent:Sg("preserve",Mg),oExtent:Sg("preserve",Mg),multiAxis:Sg("preserve",Mg),normalize:Sg("preserve",Mg),bins:Sg("preserve",Mg),oSort:Sg("preserve",_g),barPadding:Sg("preserve",_g),roundedTop:Sg("preserve",_g),baselinePadding:Sg("preserve",_g),innerRadius:Sg("preserve",_g),cornerRadius:Sg("preserve",_g),startAngle:Sg("preserve",_g),sweepAngle:Sg("preserve",_g),trackFill:Sg("preserve",_g),showOutliers:Sg("preserve",_g),showIQR:Sg("preserve",_g),amplitude:Sg("preserve",_g),connectorOpacity:Sg("preserve",_g),showLabels:Sg("preserve",_g),dynamicColumnWidth:Sg("rebuild",_g),customLayout:Sg("preserve",_g),layoutConfig:Sg("preserve",_g),layoutMargin:Sg("preserve",_g),symbolMap:Sg("preserve",Pg),pieceStyle:Sg("preserve",jg),summaryStyle:Sg("preserve",jg),connectorStyle:Sg("preserve",jg),gradientFill:Sg("preserve",jg),colorScheme:Sg("preserve",jg),themeCategorical:Sg("preserve",jg),themeSemantic:Sg("preserve",jg),themeSequential:Sg("preserve",jg),themeDiverging:Sg("preserve",jg),barColors:Sg("preserve",jg),decay:Sg("preserve",jg),pulse:Sg("preserve",jg),staleness:Sg("preserve",jg),layoutSelection:Sg("preserve",jg),windowSize:Sg("preserve",Rg),windowMode:Sg("preserve",Rg),clock:Sg("preserve",Rg),transition:Sg("preserve",Rg),introAnimation:Sg("preserve",Rg),onLayoutError:Sg("preserve",Rg)},Lg=Sg("preserve",_g),Ig=class{constructor(){this.tracker=new Bn}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}},wg)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},kg):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const o of e){const e=Cg[o]??Lg;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},Tg=require("d3-quadtree"),$g=class{constructor(e){this.rExtent=new Mt,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new Ig,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new fg,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 At(e.windowSize),this.getO=Rt(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>Pt(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new Mt)):(this.getR=Pt(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 At(e.windowSize))}syncPulseTimestampBuffer(){var e,t,n,o;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,n=this.timestampBuffer,o=this.currentTime(),e?null!=n&&n.capacity===t.capacity&&n.size===t.size?n:Mn(t,o):null)}currentTime(){return this.config.clock?.()??Ot()}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(),An(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const n of e.inserts)_n(this.buffer,n,this.timestampBuffer,t),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else{this._hasStreamingData=!0;for(const n of e.inserts){const e=_n(this.buffer,n,this.timestampBuffer,t);this.categories.add(this.getO(n)),this.pushValueExtent(n),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 n="function"==typeof t?t(e):e[t];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(e){const{config:t,buffer:n}=this,o=this.scales,r=this.multiScales,i=this.columns;if(0===n.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(n,this.getR);const s=this.getBufferArray(),a=t.projection||"vertical",c=t.oExtent||this.resolveCategories(s),l=this.computeValueDomain(s,c),u="horizontal"===a,d="radial"===a,h=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===a?e.width:e.height):.1));let f,p;if(d){f=(0,hg.scaleBand)().domain(c).range([0,1]).padding(0);const n=Math.min(e.width,e.height)/2,o=t.innerRadius||0;p=(0,hg.scaleLinear)().domain(l).range([o,n])}else u?(f=(0,hg.scaleBand)().domain(c).range([0,e.height]).padding(h),p=(0,hg.scaleLinear)().domain(l).range([0,e.width])):(f=(0,hg.scaleBand)().domain(c).range([0,e.width]).padding(h),p=(0,hg.scaleLinear)().domain(l).range([e.height,0]));this.scales={o:f,r:p,projection:a},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((o,r)=>{const i=this.rExtents[r];i.dirty&&i.recalculate(n,o);let[s,a]=i.extent;s===1/0&&(s=0,a=1);const c=a-s,l=c>0?c*(t.extentPadding??.05):1;return s-=l,a+=l,s>0&&(s=0),u?(0,hg.scaleLinear)().domain([s,a]).range([0,e.width]):(0,hg.scaleLinear)().domain([s,a]).range([e.height,0])}):[];let y=s;this.rAccessors.length>1&&(y=s.flatMap(e=>this.rAccessors.map((t,n)=>({...e,__rIndex:n,__rValue:t(e),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(y,c,f,a,e),this._customLayoutFailedThisBuild=!1;const g=this.buildSceneNodes(y,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=o,this.multiScales=r,this.columns=i):(this.scene=[],this.rebuildPointQuadtree()):(this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=g,this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,s),this.config.pulse&&this.applyPulse(this.scene,s),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,n=Array.isArray(t)?t[e]:t;return"string"==typeof n?n:"value"+e}resolveCategories(e){const t=this.config.oSort,n="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===t?void 0:t;let r=null;if(n){r=new Set;for(const t of e)r.add(this.getO(t))}const i=r?Array.from(this.categories).filter(e=>r.has(e)):Array.from(this.categories);if(n&&void 0===o){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 i}if(!1===o)return i;if("function"==typeof o)return i.sort(o);const s=new Map;for(const t of e){const e=this.getO(t);s.set(e,(s.get(e)||0)+Math.abs(this.getR(t)))}return i.sort("asc"===o?(e,t)=>(s.get(e)||0)-(s.get(t)||0):(e,t)=>(s.get(t)||0)-(s.get(e)||0))}computeValueDomain(e,t){return function(e){const{data:t,chartType:n,projection:o,normalize:r,rExtent:i,extentPadding:s=.05,baselinePadding:a,axisExtent:c,getO:l,getR:u,getStack:d,rawRExtent:h}=e,f=s;if("radial"===o&&("pie"===n||"donut"===n))return[0,1];let p=0,y=0;if("bar"===n&&d&&r)p=0,y=1;else if("bar"===n&&d){const e=new Map,n=new Map;for(const o of t){const t=l(o),r=u(o);0>r?n.set(t,(n.get(t)||0)+r):e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>y&&(y=t);for(const e of n.values())p>e&&(p=e)}else if("bar"===n){const e=new Map;for(const n of t){const t=l(n),o=u(n);e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>y&&(y=t),p>t&&(p=t)}else if("swimlane"===n){const e=new Map;for(const n of t){const t=l(n),o=Math.abs(u(n));e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>y&&(y=t)}else if("clusterbar"===n||"bar-funnel"===n)for(const e of t){const t=u(e);t>y&&(y=t),p>t&&(p=t)}else{const e=h[0],t=h[1];e!==1/0&&(p=e),t!==-1/0&&(y=t)}i&&(null!=i[0]&&(p=i[0]),null!=i[1]&&(y=i[1]));const g="bar"===n||"clusterbar"===n||"bar-funnel"===n||"swimlane"===n;if(g&&null==i?.[0]&&null==i?.[1]&&(p>0&&(p=0),0>y&&(y=0)),"bar-funnel"!==n&&"exact"!==c){const e=y-p,t=e>0?e*f:1,o=g&&!a&&0===p,r=g&&!a&&0===y||"swimlane"===n;null!=i?.[0]||o||(p-=t),null!=i?.[1]||r||(y+=t)}return[p,y]}({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,n,o,r){return function(e){const{data:t,oExtent:n,oScale:o,projection:r,layout:i,dynamicColumnWidth:s,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 d=0;if("radial"===r)for(const e of t)d+=Math.abs(c(e));let h=null;if(s&&"radial"!==r){h=new Map;let e=0;for(const t of n){const n=u.get(t)||[];let o;o="string"==typeof s?n.reduce((e,t)=>e+(Number(t[s])||0),0):s(n),h.set(t,o),e+=o}const t=("horizontal"===r?i.height:i.width)-o.padding()*o.step()*n.length;if(e>0)for(const[n,o]of h)h.set(n,o/e*t)}let f=0,p=0;for(const e of n){const t=u.get(e)||[],n=t.reduce((e,t)=>e+Math.abs(c(t)),0),r=d>0?n/d:0;let i,s;h?(i=p,s=h.get(e)||o.bandwidth(),p+=s+o.padding()*o.step()):(i=o(e)??0,s=o.bandwidth()),l[e]={name:e,x:i,y:0,width:s,middle:i+s/2,padding:o.padding()*o.step(),pieceData:t,pct:r,pctStart:f},f+=r}return l}({data:e,oExtent:t,oScale:n,projection:o,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 n=this.buildLayoutContext(e,t);let o;try{o=this.config.customLayout(n)}catch(e){const t=null!==this.lastCustomLayoutResult,n=xn("ordinal",e,t,this.version);this.lastCustomLayoutFailure=n,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",e);try{this.config.onLayoutError?.(n)}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=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null;const r=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.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 yn({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 n=this.getSceneContext(),o=vg[this.config.chartType];let r=o?o(n,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:n,config:o,getConnector:r,getO:i}=e;if(!r||!n)return[];const s=[],{projection:a}=n,c=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const n=r(t);if(!n)continue;let o,s;"point"===e.type?(o=e.x,s=e.y):(o=e.x+e.w/2,s=e.y+("vertical"===a?0:e.h/2)),c.has(n)||c.set(n,[]),c.get(n).push({x:o,y:s,datum:t,category:i(t)})}const l=n.o.domain(),u=o.connectorStyle;for(const[t,n]of c)if(n.length>=2){n.sort((e,t)=>l.indexOf(e.category)-l.indexOf(t.category));for(let o=0;n.length-1>o;o++){const r=n[o],i=n[o+1],a="function"==typeof u?u(r.datum):u||{stroke:e.config.themeSemantic?.border||e.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:r.x,y1:r.y,x2:i.x,y2:i.y,style:a,datum:r.datum,group:t})}}return s}(n,r);r=[...e,...r]}return r}buildLayoutContext(e,t){const n=this.config,o=n.layoutMargin??{top:0,right:0,bottom:0,left:0},r=tp(n.colorScheme,n.themeCategorical,fe),i=this.scales;return{data:e,scales:{o:i.o,r:i.r,projection:i.projection},dimensions:{width:t.width,height:t.height,margin:o,plot:"radial"===i.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:n.themeSemantic??{},categorical:[...r]},resolveColor:np(r,n.colorScheme),config:n.layoutConfig??{},selection:n.layoutSelection??null}}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?Dt(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=Bt(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 n="function"==typeof t,o=n?null:t||"category",r=new Map;for(let i=0;e.length>i;i++){const s=e[i],a=n?t(s):s[o],c=r.get(a);c?c.push(i):r.set(a,[i])}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,n=0;for(const o of e)"point"===o.type&&(t++,o.r>n&&(n=o.r));if(500>=t)return{quadtree:null,maxRadius:n};const o=Array(t);let r=0;for(const t of e)"point"===t.type&&(o[r++]=t);return{maxRadius:n,quadtree:(0,Tg.quadtree)().x(e=>e.x).y(e=>e.y).addAll(o)}}(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 n=t.length;if(1>=n)return;const o=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=o.get(t.datum);if(null==e)continue;const r=this.computeDecayOpacity(e,n);t.style={...t.style,opacity:(t.style?.opacity??1)*r}}}applyPulse(e,t,n=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,o,r,i){const s=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 o=0;for(const s of r(t)??[]){const t=n.get(s);null!=t&&(o=Math.max(o,Ft(e,t,i)))}c=Nt(l,o,s)||c;continue}if(null==l.datum)continue;const t=o.get(l.datum);if(null==t)continue;const u=n.get(t);c=Nt(l,null==u?0:Ft(e,u,i),s,a)||c}return c}(this.config.pulse,e,this.timestampBuffer,this.getDatumIndexMap(t),e=>this.getCategoryIndexMap(t).get(e),n)}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&Wt(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,n="horizontal"!==this.scales?.projection;let o;for(let r=0;this.scene.length>r;r++){const i=this.scene[r],s=this.getNodeKey(i,e);s&&("rect"===i.type?this.prevPositionMap.set(s,n?{x:i.x,y:t,w:i.w,h:0,opacity:i.style.opacity??1}:{x:t,y:i.y,w:0,h:i.h,opacity:i.style.opacity??1}):"point"===i.type?this.prevPositionMap.set(s,{x:i.x,y:i.y,r:0,opacity:0}):"wedge"===i.type&&(void 0===o&&(o=i.startAngle),this.prevPositionMap.set(s,{x:i.cx,y:i.cy,startAngle:o,endAngle:o,innerRadius:i.innerRadius,outerRadius:i.outerRadius,opacity:0})))}}getNodeKey(e,t){if("point"===e.type){const n=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,o=t.get(n)||0;return t.set(n,o+1),`${n}:${o}`}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 n=this.scene[t],o=this.getNodeKey(n,e);o&&("point"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,r:n.r,opacity:n.style.opacity}):"rect"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style.opacity}):"wedge"===n.type&&this.prevPositionMap.set(o,{x:n.cx,y:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:n.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 n=new Set,o=new Map;for(let e=0;this.scene.length>e;e++){const r=this.scene[e],i=this.getNodeKey(r,o);if(!i)continue;r._transitionKey=i;const s=this.prevPositionMap.get(i);if("point"===r.type)s?(n.add(i),r._targetOpacity=r.style.opacity??1,(s.x!==r.x||s.y!==r.y||void 0!==s.r&&s.r!==r.r)&&(r._targetX=r.x,r._targetY=r.y,r._targetR=r.r,r.x=s.x,r.y=s.y,void 0!==s.r&&(r.r=s.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)s?(n.add(i),r._targetOpacity=r.style.opacity??1,s.x===r.x&&s.y===r.y&&s.w===r.w&&s.h===r.h||(r._targetX=r.x,r._targetY=r.y,r._targetW=r.w,r._targetH=r.h,r.x=s.x,r.y=s.y,r.w=s.w??r.w,r.h=s.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(s)n.add(i),r._targetOpacity=r.style.opacity??1,s.startAngle===r.startAngle&&s.endAngle===r.endAngle||(r._targetStartAngle=r.startAngle,r._targetEndAngle=r.endAngle,r.startAngle=s.startAngle,r.endAngle=s.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(i,{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,o]of this.prevPositionMap)if(!n.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:o.x,y:o.y,r:o.r??3,style:{opacity:o.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:o.x,y:o.y,w:o.w??0,h:o.h??0,style:{opacity:o.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){const t=((o.startAngle??0)+(o.endAngle??0))/2,n={type:"wedge",cx:o.x,cy:o.y,innerRadius:o.innerRadius??0,outerRadius:o.outerRadius??100,startAngle:o.startAngle??0,endAngle:o.endAngle??0,style:{opacity:o.opacity??1},datum:null,category:e.slice(2),_targetStartAngle:t,_targetEndAngle:t,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}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=zt(e,this.activeTransition),n=$t(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 o=this.prevPositionMap.get(t);e.style.opacity=Et(o?o.opacity??1:0,e._targetOpacity,n)}const o=this.prevPositionMap.get(t);void 0!==e._targetX&&o&&(e.x=Et(o.x,e._targetX,n),e.y=Et(o.y,e._targetY,n)),void 0!==e._targetR&&void 0!==o?.r&&(e.r=Et(o.r,e._targetR,n))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const o=this.prevPositionMap.get(t);e.style.opacity=Et(o?o.opacity??1:0,e._targetOpacity,n)}if(void 0===e._targetX)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=Et(o.x,e._targetX,n),e.y=Et(o.y,e._targetY,n),void 0!==o.w&&(e.w=Et(o.w,e._targetW,n),e.h=Et(o.h,e._targetH,n))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){const o=this.prevPositionMap.get(t);e.style={...e.style,opacity:Et(o?o.opacity??1:0,e._targetOpacity,n)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){const o=this.prevPositionMap.get(t);o&&void 0!==o.startAngle&&(e.startAngle=Et(o.startAngle,e._targetStartAngle,n),e.endAngle=Et(o.endAngle,e._targetEndAngle,n))}}}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=Tt(e),n=this.getDataId,o=e=>t.has(n(e));Pn(this.buffer,this.timestampBuffer,o);const r=this.buffer.remove(o);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 n=Tt(e),o=this.getDataId,r=new Set;this.buffer.forEach((e,t)=>{n.has(o(e))&&r.add(t)});const i=this.buffer.update(e=>n.has(o(e)),t);if(0===i.length)return this.updateResults.recordNoop("update"),i;for(const e of i)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",i.length),i}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 n=this._customRestyle;if(n)for(const o of e){const e=this._baseStyles.get(o)??o.style??{},r=n(o,t);o.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},n=Object.keys(e).filter(n=>e[n]!==t[n]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e&&e.colorScheme!==t.colorScheme||"themeCategorical"in e&&e.themeCategorical!==t.themeCategorical||"colorAccessor"in e&&!_t(e.colorAccessor,t.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!_t(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!_t(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let o=!1;("categoryAccessor"in e||"oAccessor"in e)&&(_t(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=Rt(this.config.categoryAccessor||this.config.oAccessor,"category"),o=!0));let r=!1;if("valueAccessor"in e||"rAccessor"in e){const e=this.config.valueAccessor||this.config.rAccessor,n=t.valueAccessor||t.rAccessor,o=Array.isArray(e)?e:[e],i=Array.isArray(n)?n:[n];if(r=o.length!==i.length||o.some((e,t)=>!_t(e,i[t])),r){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>Pt(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new Mt)):(this.getR=Pt(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!_t(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?Rt(this.config.stackBy):void 0),"groupBy"in e&&!_t(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?Rt(this.config.groupBy):void 0),"colorAccessor"in e&&!_t(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Rt(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!_t(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Rt(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!_t(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?Rt(this.config.connectorAccessor):void 0),(o||r||"accessorRevision"in e&&e.accessorRevision!==t.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(n)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};zn($g);var zg=require("react/jsx-runtime"),Eg=require("react/jsx-runtime");function Og(e,t){const n=Ke(e.theme),o=e.size||[500,400],r=Es({top:20,right:20,bottom:30,left:40,...e.margin},e.title),i=$s(e.title),s=E(e.data),a=e.showLegend?Wy(s,e.colorAccessor||e.stackBy||e.groupBy):[];ig(r,{props:e,categories:a,theme:n,size:o,hasTitle:i});const c=o[0]-r.left-r.right,l=o[1]-r.top-r.bottom,u=e.projection||"vertical",d="radial"===u,h=e.colorScheme||n.colors.categorical,f={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:Le(e.gradientFill),symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,multiAxis:e.multiAxis,baselinePadding:e.baselinePadding,trackFill:e.trackFill,connectorOpacity:e.connectorOpacity,showLabels:e.showLabels,colorScheme:h,themeCategorical:n.colors.categorical,themeSemantic:Fe(n),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:r,layoutSelection:e.layoutSelection,barColors:e.barColors},p=new $g(f);if(e.data&&p.ingest({inserts:s,bounded:!0}),p.computeScene({width:c,height:l}),!p.scales||0===p.scene.length)return t&&(t.evidence=jy({frameType:"ordinal",width:o[0],height:o[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:p.scales?[]:["NO_SCALES"],margin:r})),dg.renderToStaticMarkup(cg(null,{width:o[0],height:o[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left},${r.top})`,innerWidth:c,innerHeight:l,idPrefix:e._idPrefix}));const y=e._idPrefix,g=e.showGrid?function(e,t,n,o,r){const i=e.scales;if(!i||"radial"===i.projection)return null;const{grid:s}=Ze(n),a=o?o+"-":"",c="vertical"===i.projection,l=As(i.r,5,r);return(0,Qy.jsx)("g",c?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,n)=>{const o=i.r(e);return(0,Qy.jsx)("line",{x1:0,y1:o,x2:t.width,y2:o,stroke:s,strokeWidth:.5},"gr-"+n)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,n)=>{const o=i.r(e);return(0,Qy.jsx)("line",{x1:o,y1:0,x2:o,y2:t.height,stroke:s,strokeWidth:.5},"gr-"+n)})})}(p,{width:c,height:l},n,y,e.axisExtent):null;let m=null;if(p.scene.some(e=>"rect"===e.type&&e.datum?.__barFunnelIsDropoff)){const t=eg(e),o=new Set;for(const e of p.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&o.add("string"==typeof e.style.fill?e.style.fill:"#666");m=Array.from(o).map((e,o)=>function(e){const{id:t,background:n="transparent",stroke:o="#000",lineWidth:r=1.5,spacing:i=6,angle:s=45}=e,a=Math.max(8,Math.ceil(2*i));return(0,zg.jsxs)("pattern",{id:t,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[n&&"transparent"!==n&&(0,zg.jsx)("rect",{width:a,height:a,fill:n}),(0,zg.jsx)("line",{x1:0,y1:0,x2:0,y2:a,stroke:o,strokeWidth:r}),(0,zg.jsx)("line",{x1:i,y1:0,x2:i,y2:a,stroke:o,strokeWidth:r})]},t)}({id:`funnel-hatch-${t}-${o}`,background:e,stroke:"transparent"===n.colors.background?"#fff":n.colors.background,lineWidth:1.5,spacing:5,angle:45}));const r=new Map;Array.from(o).forEach((e,n)=>r.set(e,`funnel-hatch-${t}-${n}`));for(const e of p.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 x=vl({nodes:p.scene,renderMode:e.renderMode,fallback:(e,t)=>fa(e,t,y)}),b=x.map(e=>e.element);if(t){const n=p.scales.o?.domain?.();t.evidence=jy({frameType:"ordinal",width:o[0],height:o[1],marks:x.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,yDomain:Py(p.scales.r?.domain?.()),categories:Array.isArray(n)?n.map(String):void 0,margin:r})}const v=!1!==e.showAxes?function(e,t,n,o,r){const i=e.scales;if(!i)return null;if("radial"===i.projection)return null;const s=Ze(o),a="vertical"===i.projection,c=n.categoryFormat||n.oFormat,l=n.valueFormat||n.rFormat,u=n.categoryLabel||n.oLabel,d=n.valueLabel||n.rLabel,h=Object.values(e.columns).map(e=>({pixel:e.middle,label:(c||String)(e.name)})),f=As(i.r,5,n.axisExtent).map(e=>({pixel:i.r(e),label:(l||ag)(e)}));return(0,Eg.jsxs)("g",a?{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[(0,Eg.jsx)("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:s.border,strokeWidth:1}),h.map((e,n)=>(0,Eg.jsxs)("g",{transform:`translate(${e.pixel},${t.height})`,children:[(0,Eg.jsx)("line",{y2:5,stroke:s.border,strokeWidth:1}),(0,Eg.jsx)("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oxtick-"+n)),u&&(0,Eg.jsx)("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:u}),(0,Eg.jsx)("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:s.border,strokeWidth:1}),f.map((e,t)=>(0,Eg.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,Eg.jsx)("line",{x2:-5,stroke:s.border,strokeWidth:1}),(0,Eg.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oytick-"+t)),d&&(0,Eg.jsx)("text",{x:15-(n.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${t.height/2})`,children:d})]}:{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[(0,Eg.jsx)("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:s.border,strokeWidth:1}),f.map((e,n)=>(0,Eg.jsxs)("g",{transform:`translate(${e.pixel},${t.height})`,children:[(0,Eg.jsx)("line",{y2:5,stroke:s.border,strokeWidth:1}),(0,Eg.jsx)("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oxtick-"+n)),d&&(0,Eg.jsx)("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:d}),(0,Eg.jsx)("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:s.border,strokeWidth:1}),h.map((e,t)=>(0,Eg.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,Eg.jsx)("line",{x2:-5,stroke:s.border,strokeWidth:1}),(0,Eg.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oytick-"+t)),u&&(0,Eg.jsx)("text",{x:15-(n.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${t.height/2})`,children:u})]})}(p,{width:c,height:l},e,n,y):null,w=e.annotations?Ky({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:s,scales:{o:p.scales.o,r:p.scales.r,y:"vertical"===p.scales.projection?p.scales.r:void 0},layout:{width:c,height:l},theme:n,projection:u,idPrefix:y}):null,k=sg({props:e,categories:a,theme:n,size:o,margin:r,hasTitle:i}),S=d?r.left+c/2:r.left,A=d?r.top+l/2:r.top,M=d&&e.centerContent?(0,Eg.jsx)("foreignObject",{x:r.left,y:r.top,width:c,height:l,pointerEvents:"none",children:(0,Eg.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:e.centerContent})}):null;return dg.renderToStaticMarkup(cg((0,Eg.jsxs)(Eg.Fragment,{children:[e.backgroundGraphics,g,b,v,w,e.foregroundGraphics,p.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${S},${A})`,innerWidth:c,innerHeight:l,legend:k,defs:m,outerElements:M,idPrefix:e._idPrefix}))}var Dg=y(require("react-dom/server"));function Bg(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function Fg(e,t){var n,o=[],r=[],i=[],s={},a=[];function c(e){i[e]=!1,s.hasOwnProperty(e)&&Object.keys(s[e]).forEach(function(t){delete s[e][t],i[t]&&c(t)})}function l(e){var t,o,d=!1;for(r.push(e),i[e]=!0,t=0;a[e].length>t;t++)(o=a[e][t])===n?(u(n,r),d=!0):i[o]||(d=l(o));if(d)c(e);else for(t=0;a[e].length>t;t++){var h=s[o=a[e][t]];h||(s[o]=h={}),h[o]=!0}return r.pop(),d}function u(e,n){var r=[].concat(n).concat(e);t?t(r):o.push(r)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,o=function(e){for(var t=e.length,n=Array(t),o=Array(t),r=Array(t),i=Array(t),s=Array(t),a=Array(t),c=0;t>c;++c)n[c]=-1,o[c]=0,r[c]=!1,i[c]=0,s[c]=-1,a[c]=[];var l,u=0,d=[],h=[];function f(t){var c=[t],l=[t];for(n[t]=o[t]=u,r[t]=!0,u+=1;l.length>0;){var f=e[t=l[l.length-1]];if(f.length>i[t]){for(var p=i[t];f.length>p;++p){var y=f[p];if(0>n[y]){n[y]=o[y]=u,r[y]=!0,u+=1,c.push(y),l.push(y);break}r[y]&&(o[t]=0|Math.min(o[t],o[y])),0>s[y]||a[t].push(s[y])}i[t]=p}else{if(o[t]===n[t]){var g=[],m=[],x=0;for(p=c.length-1;p>=0;--p){var b=c[p];if(r[b]=!1,g.push(b),m.push(a[b]),x+=a[b].length,s[b]=d.length,b===t){c.length=p;break}}d.push(g);var v=Array(x);for(p=0;m.length>p;p++)for(var w=0;m[p].length>w;w++)v[--x]=m[p][w];h.push(v)}l.pop()}}}for(c=0;t>c;++c)0>n[c]&&f(c);for(c=0;h.length>c;c++){var p=h[c];if(0!==p.length){p.sort(function(e,t){return e-t}),l=[p[0]];for(var y=1;p.length>y;y++)p[y]!==p[y-1]&&l.push(p[y]);h[c]=l}}return{components:d,adjacencyList:h}}(e),r=o.components.filter(function(e){return e.length>1}),i=1/0,s=0;r.length>s;s++)for(var a=0;r[s].length>a;a++)i>r[s][a]&&(i=r[s][a],n=s);var c=r[n];return!!c&&{leastVertex:i,adjList:e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})})}}n=0;for(var h=e.length;h>n;){var f=d(n);if(n=f.leastVertex,a=f.adjList){for(var p=0;a.length>p;p++)for(var y=0;a[p].length>y;y++){var g=a[p][y];i[+g]=!1,s[g]={}}l(n),n+=1}else n=h}return t?void 0:o}function Ng(e){return e.y0-e.y1>0?"up":"down"}function Wg(e,t){return t(e.source)==t(e.target)}function qg(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function Yg(e){return e.target.x0-e.source.x1}function Gg(e,t){var n=Vg(e),o=Yg(t)/Math.tan(n);return"up"==Ng(e)?e.y1-o:e.y1+o}function Hg(e,t){var n=Vg(e),o=Yg(t)/Math.tan(n);return"up"==Ng(e)?e.y1+o:e.y1-o}function Vg(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Xg(e,t){return t(e)}function Ug(e){return Zg(e.source)}function Kg(e){return Zg(e.target)}function Zg(e){return(e.y0+e.y1)/2}function Qg(e){return e.virtual?0:e.value}function Jg(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!Wg(e,t)?n+1:n});var o=0;return e.targetLinks.forEach(function(e){o=e.circular&&!Wg(e,t)?o+1:o}),n+o}function em(e){return e.target.depth}function tm(e,t){return e.sourceLinks.length?e.depth:t-1}function nm(e,t){return e.y0-t.y0}function om(e,t){return t.y0-e.y0}function rm(e,t){return e.y1-t.y1}function im(e,t){return t.y1-e.y1}function sm(e,t){return cm(e.source,t.source)||e.index-t.index}function am(e,t){return cm(e.target,t.target)||e.index-t.index}function cm(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function lm(e,t){return um(e)==um(t)?"bottom"==e.circularLinkType?om(e,t):nm(e,t):um(t)-um(e)}function um(e){return e.target.column-e.source.column}function dm(e,t){return hm(e)==hm(t)}function hm(e){return e.y0-e.y1>0?"up":"down"}var fm=require("d3-array");function pm(e,t,n,o,r){let i=e;var s=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var a=(0,fm.min)(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=i.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),ym(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),ym(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,Wg(e,t)&&qg(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+r+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var s=e.source.column,c=e.circularLinkType,l=i.links.filter(function(e){return e.source.column==s&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?om:nm);var u=0;l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),s=e.target.column,(l=i.links.filter(function(e){return e.target.column==s&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?im:rm),u=0,l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+r+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=a-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,o=e.target.x0,r=e.y1,i=(t+o)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+r+" "+o+","+r}(e)}),i}function ym(e,t,n){e.sort(lm);var o=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,r){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(Wg(e,t)&&qg(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&gm(e,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;i=c>i?c:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function gm(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}var mm=require("d3-array");function xm(e){return function(){return e}}function bm(e){return e.index}function vm(e){return e.nodes}function wm(e){return e.links}function km(e,t,n){var o=(0,mm.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r,i){var s=r.length;if(t)r.sort(t);else if(i>0){var a=new Map;r.forEach(function(e,t){var n,o,r,i=(o=0,r=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=Zg(e.source)*t,o+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=Zg(e.target)*t,o+=t}}),o>0?r/o:NaN);a.set(e,{bc:i,idx:t})}),r.sort(function(e,t){var n=a.get(e),o=a.get(t),r=n.bc,i=o.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(r)||isNaN(i)?isNaN(r)?isNaN(i)?n.idx-o.idx:1:-1:r-i})}else r.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Jg(t,n)-Jg(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});r.forEach(function(t,r){t.depth==o.length-1&&1==s||0==t.depth&&1==s?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==Jg(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+r,t.y1=t.y0+t.value*e.ky)})})}function Sm(e,t,n,o,r,i){var s=(0,mm.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var a=1,c=i;c>0;--c)l(a*=.99,n),u();function l(t,n){var o=s.length;s.forEach(function(r){var i=r.length,s=r[0].depth;r.forEach(function(r){var a;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&Jg(r,n)>0){var c=(0,mm.mean)(r.sourceLinks,Kg),l=(0,mm.mean)(r.targetLinks,Ug),u=c&&l?(c+l)/2:c||l;if(u){var d=(u-Zg(r))*t*.3;r.y0+=d,r.y1+=d}}else if(0==s&&1==i)r.y0=e.y1/2-(a=r.y1-r.y0)/2,r.y1=e.y1/2+a/2;else if(s==o-1&&1==i)r.y0=e.y1/2-(a=r.y1-r.y0)/2,r.y1=e.y1/2+a/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)a=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+a;else{var h=(0,mm.mean)(r.sourceLinks,Kg),f=(0,mm.mean)(r.targetLinks,Ug),p=((h&&f?(h+f)/2:h||f)-Zg(r))*t;r.y0+=p,r.y1+=p}})})}function u(){s.forEach(function(n){var i,s,a,c=e.y0,l=n.length;for(n.sort(t||cm),a=0;l>a;++a)(s=c-(i=n[a]).y0)>0&&(i.y0+=s,i.y1+=s),c=i.y1+o;if((s=c-o-e.y1)>0)for(c=i.y0-=s,i.y1-=s,a=l-2;a>=0;--a)(s=(i=n[a]).y1+r-c)>0&&(i.y0-=s,i.y1-=s),c=i.y0})}}function Am(e){e.nodes.forEach(function(e){e.sourceLinks.sort(am),e.targetLinks.sort(sm)}),e.nodes.forEach(function(e){var t=e.y0,n=t,o=e.y1,r=o;e.sourceLinks.forEach(function(e){e.circular?(e.y0=o-e.width/2,o-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=r-e.width/2,r-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function Mm(){var e=0,t=0,n=1,o=1,r=24,i=8,s=null,a=bm,c=tm,l=void 0,u=32,d=2,h=vm,f=wm;function p(){var p={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=n,h.y1=o,h.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return(0,mm.group)(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var o=e.source,r=e.target;"object"!=typeof o&&(o=e.source=Bg(n,o)),"object"!=typeof r&&(r=e.target=Bg(n,r)),o.sourceLinks.push(e),r.targetLinks.push(e)})}(h,a),function(e,t){var n=0;if(null==t){for(var o=[],r=0;e.links.length>r;r++){var i=e.links[r],s=i.source.index,a=i.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var c=Fg(o);c.sort(function(e,t){return e.length-t.length});var l={};for(r=0;c.length>r;r++){var u=c[r].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,o=e.source.index;t===o||l[o]&&l[o][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(h,l),function(e,t){var n=0,o=0;e.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>n?"top":"bottom","top"==r.circularLinkType?n++:o++,e.nodes.forEach(function(e){Xg(e,t)!=Xg(r.source,t)&&Xg(e,t)!=Xg(r.target,t)||(e.circularLinkType=r.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),Wg(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,a),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max((0,mm.sum)(e.sourceLinks,Qg),(0,mm.sum)(e.targetLinks,Qg)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(h),function(e,t,n){var o,r,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var s=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){s=t(e)==a?s:s+1,a=t(e)==a?a:t(e),e.column=s})}for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>r.indexOf(e.target)&&!e.circular&&r.push(e.target)})});for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>r.indexOf(e.source)&&!e.circular&&r.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(h,l,c);var f=i;if(null!==s){var p=(0,mm.groups)(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=(0,mm.max)(p,function(e){return e.length});y>1&&(f=Math.max(1,(o-t)*s/(y-1)))}(function(e,t,n){var o=(0,mm.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var r=(0,mm.min)(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/(0,mm.sum)(t,function(e){return e.value})});e.ky=r,e.links.forEach(function(t){t.width=t.value*e.ky});var i=(0,mm.max)(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(h,f,r),km(h,l,a),Sm(h,l,a,f,f,u),Am(h),pm(h,a,d,10,8),km(h,l,a),Sm(h,l,a,f,f,u),Am(h),pm(h,a,d,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var o=n.links.filter(function(n){return Xg(n.source,t)==Xg(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!dm(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=Gg(t,e);return e.y1-n}if(t.target.column>e.target.column)return Gg(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,s=0;r>i;i++)s+=o[i].width;t.y0=e.y1-s-t.width/2}})})}(h,a),function(e,t){let n=e;n.nodes.forEach(function(e){var o=n.links.filter(function(n){return Xg(n.target,t)==Xg(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!dm(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=Hg(t,e);return e.y0-n}if(t.source.column>e.source.column)return Hg(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,s=0;r>i;i++)s+=o[i].width;t.y1=e.y1-s-t.width/2}})})}(h,a),function(e){var t=e.nodes,n=e.links,o=!1,r=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(r=!0)}),0==o||0==r){let o=function(t){return(t-i)/(s-i)*(e.y1-e.y0)+e.y0};var i=(0,mm.min)(t,function(e){return e.y0}),s=(0,mm.max)(t,function(e){return e.y1}),a=(e.y1-e.y0)/(s-i);1>a?(t.forEach(function(e){e.y0=o(e.y0),e.y1=o(e.y1)}),n.forEach(function(e){e.y0=o(e.y0),e.y1=o(e.y1),e.width=e.width*a})):t.forEach(function(e){var t=e.y1-e.y0,n=o(e.y0)-e.y0;e.y0=o(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(h),pm(h,a,d,10,8)}(p),p}return p.update=function(e){return Am(e),pm(e,a,d,10,8),e},p.nodeWidth=function(e){return arguments.length?(r=+e,p):r},p.nodePadding=function(e){return arguments.length?(i=+e,p):i},p.nodePaddingRatio=function(e){return arguments.length?(s=+e,p):s},p.nodes=function(e){return arguments.length?(h="function"==typeof e?e:xm(e),p):h},p.links=function(e){return arguments.length?(f="function"==typeof e?e:xm(e),p):f},p.nodeId=function(e){return arguments.length?(a="function"==typeof e?e:xm(e),p):a},p.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:xm(e),p):c},p.nodeSort=function(e){return arguments.length?(l=e,p):l},p.iterations=function(e){return arguments.length?(u=+e,p):u},p.circularLinkGap=function(e){return arguments.length?(d=+e,p):d},p.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],p):[[e,t],[n,o]]},p.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],p):[n-e,o-t]},p}var _m=require("d3-interpolate"),Pm=(require("d3-shape"),.5),jm=e=>{let t,n,o,r,i,s,a,c,l;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,r=e.y0+e.sankeyWidth/2,i=e.source.x1,s=e.target.x0,a=(0,_m.interpolateNumber)(i,s),c=a(Pm),l=a(.5),`M${t},${i}C${t},${c} ${n},${l} ${n},${s}L${o},${s}C${o},${l} ${r},${c} ${r},${i}Z`;const u=e.sankeyWidth/2,d=(0,_m.interpolateNumber)(e.source.x1,e.target.x0),{pathD:h}=Vd({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:d(Pm),cp2X:d(.5)});return h};function Rm(e){const t=e.sankeyWidth/2,n=(e._circularWidth??e.sankeyWidth)/2,o=e.circularPathData;if(!o)return null;if("down"===e.direction)return null;if(e._circularStub){const n=o.sourceX,r=o.sourceY,i=o.targetX,s=o.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const a=Math.max(15,Math.min(40,.33*(o.rightFullExtent-n))),c=Math.max(15,Math.min(40,.33*(i-o.leftFullExtent)));return`M${n},${r-t}L${n+a},${r-t}L${n+a},${r+t}L${n},${r+t}ZM${i},${s-t}L${i-c},${s-t}L${i-c},${s+t}L${i},${s+t}Z`}const r=o.sourceX,i=o.sourceY,s=o.targetX,a=o.targetY,c=o.rightFullExtent,l=o.leftFullExtent,u=o.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(n,15));return`M${r},${i-d*t}L${c},${i-d*t}L${c+n},${i-d*t+d*h}L${c+n},${u+d*n-d*h}L${c+n-h},${u+d*n}L${l-n+h},${u+d*n}L${l-n},${u+d*n-d*h}L${l-n},${a-d*t+d*h}L${l-n+h},${a-d*t}L${s},${a-d*t}L${s},${a+d*t}L${l+n},${a+d*t}L${l+n},${u-d*n}L${c-n},${u-d*n}L${c-n},${i+d*t}L${r},${i+d*t}Z`}var Cm=new Set,Lm=new WeakMap;function Im(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=Lm.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,Lm.set(e,n);const o=new Proxy(e,{get(e,n,o){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;Cm.has(e)||(Cm.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,o)}});return n.set(t,o),o}var Tm={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(em))-1:0},justify:tm};function $m(e){return"string"==typeof e?e:e.id}var zm={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const r="vertical"===n.orientation?"down":"right",i=n.nodeAlign||"justify",s=n.nodeWidth??15,a=n.nodePaddingRatio??.05,c=n.iterations??100,l=e.map(e=>({...e})),u=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let d;d="down"===r?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const h=Mm().extent(d).links(u).nodes(l).nodeAlign(Tm[i]||tm).nodeId(e=>e.id).nodeWidth(s).iterations(c);h.nodePaddingRatio&&h.nodePaddingRatio(a),h();{let e=1/0,t=-1/0,n=1/0,r=-1/0;for(const o of l)e>o.x0&&(e=o.x0),o.x1>t&&(t=o.x1),n>o.y0&&(n=o.y0),o.y1>r&&(r=o.y1);for(const o of u){if(!o.circular||!o.circularPathData)continue;const i=o.circularPathData,s=(o._circularWidth??o.width??0)/2;e>i.leftFullExtent-s&&(e=i.leftFullExtent-s),i.rightFullExtent+s>t&&(t=i.rightFullExtent+s),n>i.verticalFullExtent-s&&(n=i.verticalFullExtent-s),i.verticalFullExtent+s>r&&(r=i.verticalFullExtent+s)}const i=t-e,s=r-n,a=o[0],c=o[1];if(i>0&&s>0&&(0>e||0>n||t>a||r>c)){const t=Math.min(a/i,c/s),o=-e*t+(a-i*t)/2,r=-n*t+(c-s*t)/2;for(const e of l)e.x0=e.x0*t+o,e.x1=e.x1*t+o,e.y0=e.y0*t+r,e.y1=e.y1*t+r;for(const e of u)if(e.y0=e.y0*t+r,e.y1=e.y1*t+r,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+o,n.targetX=n.targetX*t+o,n.sourceY=n.sourceY*t+r,n.targetY=n.targetY*t+r,n.rightFullExtent=n.rightFullExtent*t+o,n.leftFullExtent=n.leftFullExtent*t+o,n.verticalFullExtent=n.verticalFullExtent*t+r,n.rightInnerExtent=n.rightInnerExtent*t+o,n.leftInnerExtent=n.leftInnerExtent*t+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+r,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of l){const t=f.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const p=new Map;for(const e of t)p.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of u){const t=$m(e.source),n=$m(e.target),o=p.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(o){o.y0=e.y0,o.y1=e.y1,o.sankeyWidth=e.width??0,o.circular=!!e.circular,o.circularPathData=e.circularPathData,o._circularWidth=e._circularWidth,o._circularStub=e._circularStub,o.path=e.path,o.circularLinkType=e.circularLinkType,o.direction=r;const i=f.get(t),s=f.get(n);i&&(o.source=i),s&&(o.target=s)}}},buildScene(e,t,n,o){const r="vertical"===n.orientation?"down":"right",i=n.nodeStyle,s=n.edgeStyle,a=n.edgeOpacity??.5,c=n.edgeColorBy||"source",l=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:N,u=new Map;e.forEach((e,t)=>{u.set(e.id,l[t%l.length])});const d=[],h=[],f=[],p=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const o=i?i(Im(t,"nodeStyle")):{},s={fill:o.fill||u.get(t.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};p.set(t.id,("string"==typeof s.fill?s.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===r?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:s,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:s,datum:t,id:t.id,label:t.id})}const y=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of y){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;if(!t||!o)continue;let r=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";r="function"==typeof c?c(e)||r:"target"===c?p.get(o.id)||u.get(o.id)||r:p.get(t.id)||u.get(t.id)||r;const i=s?s(Im(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=i.fill||r;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+o},${t.sourceY-n}L${t.sourceX+o},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+o}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-s},${t.targetY-n}L${t.targetX-s},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let l;(l=e.circular&&e.circularPathData?Rm(e):jm(e),l)&&h.push({type:"bezier",pathD:l,bezierCache:e.bezier,style:{fill:i.fill||r,fillOpacity:i.fillOpacity??a,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity},datum:e})}if(!1!==n.showLabels){const t=(g=n.nodeLabel)?"function"==typeof g?g:e=>e[g]||e.id:null;for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=t?t(n):n.id;if(!s)continue;let a,c,l;"down"===r?(a=n.y0+(n.y1-n.y0)/2,c=n.x1+14,l="start"):(o[0]/2>n.x0+e/2?(a=n.x0-6,l="end"):(a=n.x1+6,l="start"),c=n.y0+i/2),f.push({x:a,y:c,text:s+"",anchor:"down"===r?"middle":l,baseline:"middle",fontSize:11})}}var g;return{sceneNodes:d,sceneEdges:h,labels:f}}},Em=require("d3-force"),Om=require("d3-scale"),Dm={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const r=n.forceStrength??.1,i=o[0]/2,s=o[1]/2,a=Math.max(.1,Math.min(1,Math.min(o[0],o[1])/200)),c=Math.min(.5,.06+1.8*(1-a)),l=n.__previousPositions;let u=0;const d=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=l?.get(t.id);e?u++:n?(t.x=n.x,t.y=n.y,u++):d.push(t)}const h=u>0&&.3>=(e.length>0?d.length/e.length:1);if(h){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of d){const o=Bm(e.id,t,n);if(o.length>0){let t=0,n=0;for(const e of o)t+=e.x,n+=e.y;const r=Fm(e.id),i=r%360*(Math.PI/180),s=(10+r%20)*a;e.x=t/o.length+s*Math.cos(i),e.y=n/o.length+s*Math.sin(i)}else{const t=Fm(e.id),n=t%360*(Math.PI/180),o=(15+t%30)*a;e.x=i+o*Math.cos(n),e.y=s+o*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const o=e[n];if(null==o.x||null==o.y||0===o.x&&0===o.y){const e=10*Math.sqrt(n+.5)*a,r=n*t;o.x=i+e*Math.cos(r),o.y=s+e*Math.sin(r)}}}const f=n.__skipForceSimulation||0===n.iterations?0:h?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),p=Nm(n.nodeSize,n.nodeSizeRange,e),y=e=>p(e);if(f>0){const l=new Map,u=new Map;for(const t of e)l.set(t.id,0),u.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id;l.set(t,(l.get(t)??0)+1),l.set(n,(l.get(n)??0)+1)}const d=(0,Em.forceLink)().strength(e=>{const t=e.weight,n="string"==typeof e.target?e.target:e.target.id,o=Math.max(1,Math.min(l.get("string"==typeof e.source?e.source:e.source.id)??1,l.get(n)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*r/(.1*o))}).distance(e=>{const t="string"==typeof e.source?u.get(e.source):e.source,n="string"==typeof e.target?u.get(e.target):e.target,o=(t?y(t):0)+(n?y(n):0)+Math.max(6,12*a);return Math.max(16,40*a,o)}).id(e=>e.id),p=(0,Em.forceSimulation)();if(void 0===n.random&&void 0===n.seed||p.randomSource(n.random??Pc(n.seed)),p.force("charge",(0,Em.forceManyBody)().strength(e=>{const t=l.get(e.id)??0;return-15*a*y(e)*Math.sqrt(t+1)})).force("collide",(0,Em.forceCollide)(e=>y(e)+3*a).strength(.9).iterations(2)).force("center",(0,Em.forceCenter)(i,s).strength(.8)).force("x",(0,Em.forceX)(i).strength(c)).force("y",(0,Em.forceY)(s).strength(c)).force("bounds",function(e,t,n=2,o=.6){let r=[];const i=i=>{const s=o*Math.max(i,.2);for(const o of r){const r=o.x??e[0]/2,i=o.y??e[1]/2,a=o.vx??0,c=o.vy??0,l=t(o)+n,u=Math.min(e[0]/2,l),d=Math.max(e[0]/2,e[0]-l),h=Math.min(e[1]/2,l),f=Math.max(e[1]/2,e[1]-l),p=r+a,y=i+c;u>p?o.vx=a+(u-p)*s:p>d&&(o.vx=a+(d-p)*s),h>y?o.vy=c+(h-y)*s:y>f&&(o.vy=c+(f-y)*s)}};return i.initialize=e=>{r=e},i}(o,y)),p.nodes(e),t.length>0){const e=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));d.links(e),p.force("link",d)}h?p.alpha(.3):.1>p.alpha()&&p.alpha(1),p.stop();for(let e=0;f>e;++e)p.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=y(t),n=f>0?2:0,r=Math.min(o[0]/2,e+n),i=Math.min(o[1]/2,e+n);t.x=Math.max(r,Math.min(o[0]-r,t.x)),t.y=Math.max(i,Math.min(o[1]-i,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const g=new Map;for(const t of e)g.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=g.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=g.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,o){const r=n.nodeStyle,i=n.edgeStyle,s=Nm(n.nodeSize,n.nodeSizeRange,e),a=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:N,c=new Map;e.forEach((e,t)=>{c.set(e.id,a[t%a.length])});const l=[],u=[],d=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=s(Im(t,"nodeSize")),o=r?r(Im(t,"nodeStyle")):{},i={fill:o.fill||c.get(t.id)||n.themeSemantic?.primary||"#007bff",stroke:o.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??2,opacity:o.opacity};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:i,datum:t,id:t.id,label:t.id})}const h=new Map;for(const t of e)h.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:h.get(e.source),o="object"==typeof e.target?e.target:h.get(e.target);if(!t||!o)continue;if(null==t.x||null==t.y)continue;if(null==o.x||null==o.y)continue;const r=i?i(Im(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:o.x,y2:o.y,style:{stroke:r.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:r.strokeWidth??1,opacity:r.opacity??.6},datum:e})}if(!1!==n.showLabels){const t=(f=n.nodeLabel)?"function"==typeof f?f:e=>e[f]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const o=s(Im(n,"nodeSize"));d.push({x:n.x,y:n.y-o-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:l,sceneEdges:u,labels:d}}};function Bm(e,t,n){const o=[];for(const r of t){const t="string"==typeof r.source?r.source:r.source.id,i="string"==typeof r.target?r.target:r.target.id;let s=null;if(t===e?s=i:i===e&&(s=t),s){const e=n.get(s);!e||0===e.x&&0===e.y||o.push({x:e.x,y:e.y})}}return o}function Fm(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function Nm(e,t,n){if(n.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const o=t||[5,20],r=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&r.push(n)}if(0===r.length)return()=>o[0];const[i,s]=ve(r);if(i===s)return()=>(o[0]+o[1])/2;const a=(0,Om.scaleLinear)().domain([i,s]).range(o).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?o[0]:a(n)}}var Wm=require("d3-chord"),qm=require("d3-shape"),Ym=N,Gm={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const{padAngle:r=.01,groupWidth:i=20,sortGroups:s}=n,a=Math.min(o[0],o[1])/2,c=a-i,l=o[0]/2,u=o[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:e=>e[h]??1:e=>e.value??1;var h;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const p=e.length,y=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=f.get("string"==typeof e.source?e.source:e.source.id),o=f.get(t);if(void 0===n||void 0===o)continue;const r=d(e);y[n][o]=r}const g=(0,Wm.chord)().padAngle(r);s&&g.sortGroups(s);const m=g(y),x=m.groups,b=(0,qm.arc)().innerRadius(c).outerRadius(a);for(const t of x){const n=e[t.index],o=b.centroid({innerRadius:c,outerRadius:a,startAngle:t.startAngle,endAngle:t.endAngle});n.x=o[0]+l,n.y=o[1]+u,n.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=v.get("string"==typeof e.source?e.source:e.source.id),o=v.get(t);n&&(e.source=n),o&&(e.target=o)}const w=new Map;for(const e of t)w.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of m){const n=e[t.source.index].id,o=e[t.target.index].id,r=w.get(`${n}\0${o}`)||w.get(`${o}\0${n}`);r&&(r.__chordData=t)}},buildScene(e,t,n,o){const{groupWidth:r=20,edgeOpacity:i=.5}=n,s=Math.min(o[0],o[1])/2,a=s-r,c=o[0]/2,l=o[1]/2,u=n.nodeStyle,d=n.edgeStyle,h=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Ym,p=new Map;e.forEach((e,t)=>{p.set(e.id,f[t%f.length])});const y=(0,Wm.ribbon)().radius(a),g=[],m=[],x=[];for(let t=0;e.length>t;t++){const n=e[t],o=n.__arcData;if(!o)continue;let r;r=u?u(Im(n,"nodeStyle")).fill||p.get(n.id)||f[t%f.length]:p.get(n.id)||f[t%f.length];const i=u?u(Im(n,"nodeStyle")):{};g.push({type:"arc",cx:c,cy:l,innerR:a,outerR:s,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:{fill:r,stroke:i.stroke||"black",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const o=y(t);if(!o)continue;const r=Hm(o,c,l);let s=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(d)s=d(Im(e,"edgeStyle")).fill||s;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===h&&n?s=p.get(n.id)||s:t&&(s=p.get(t.id)||s)}const a=d?d(Im(e,"edgeStyle")):{};m.push({type:"ribbon",pathD:r,style:{fill:s,fillOpacity:a.fillOpacity??i,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:e})}if(!1!==n.showLabels){const t=(b=n.nodeLabel)?"function"==typeof b?b:e=>e[b]||e.id:null,o=s+12;for(const n of e){const e=n.__arcData;if(!e)continue;const r=t?t(n):n.id;if(!r)continue;const i=(e.startAngle+e.endAngle)/2,s=i-Math.PI/2;x.push({x:c+Math.cos(s)*o,y:l+Math.sin(s)*o,text:r+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var b;return{sceneNodes:g,sceneEdges:m,labels:x}}};function Hm(e,t,n){const o=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return e;const r=[];let i=0;for(;o.length>i;){const e=o[i];if("M"===e||"L"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("C"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;3>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("Q"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;2>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("A"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&(r.push(Number(o[i])+t+""),i++),o.length>i&&(r.push(Number(o[i])+n+""),i++);else"Z"===e||"z"===e?(r.push(e),i++):(r.push(o[i]),i++)}return r.join(" ")}var Vm=require("d3-hierarchy"),Xm=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Um(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>150?"#222":"#fff"}function Km(e,t,n){const o=t.nodeIDAccessor;return"function"==typeof o?o(e.data)+"":"string"==typeof o&&void 0!==e.data[o]?e.data[o]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function Zm(e){if(!e)return null;if("function"==typeof e){const t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function Qm(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:Xm}function Jm(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:e.themeSemantic?.primary?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function ex(e,t,n,o,r){if("horizontal"===r){const r=(e+n)/2;return`M ${e},${t} C ${r},${t} ${r},${o} ${n},${o}`}if("radial"===r){const r=(e+n)/2;return`M ${e},${t} Q ${r},${t} ${r},${(t+o)/2} T ${n},${o}`}{const r=(t+o)/2;return`M ${e},${t} C ${e},${r} ${n},${r} ${n},${o}`}}var tx={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,o){const r=n.__hierarchyRoot;if(!r)return;const i=n.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),a=n.hierarchySum,c="function"==typeof a?a:"string"==typeof a?e=>Number(e[a])||0:e=>Number(e.value)||0,l=(0,Vm.hierarchy)(r,s);l.sum(c),l.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=o;switch(i){case"tree":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=(0,Vm.tree)();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(l,n,u,d);break;case"cluster":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=(0,Vm.cluster)();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(l,n,u,d);break;case"treemap":!function(e,t,n,o){const r=t.padding??4,i=t.paddingTop??0,s=(0,Vm.treemap)().size([n,o]).tile(Vm.treemapBinary).padding(r);i>0&&s.paddingTop(i),s(e)}(l,n,u,d);break;case"circlepack":!function(e,t,n,o){const r=t.padding??4;(0,Vm.pack)().size([n,o]).padding(r)(e)}(l,n,u,d);break;case"partition":!function(e,t,n,o){(0,Vm.partition)().size([n,o]).padding(t.padding??1)(e)}(l,n,u,d)}const h=l.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;h.length>t;t++){const o=h[t],r={id:Km(o,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:o.value??0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===i||"cluster"===i?nx(r,o,n):"treemap"===i||"partition"===i?ox(r,o):"circlepack"===i&&rx(r,o),r.__hierarchyNode=o,e.push(r),f.set(o,r)}if("tree"===i||"cluster"===i)for(const e of h)if(e.parent){const n=f.get(e.parent),o=f.get(e);n&&o&&t.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,o){const r=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,o,r,i){const s=[],a=[],c=[],l=n.treeOrientation||"vertical",u="radial"===l,d=o[0]/2,h=o[1]/2,f="number"==typeof(p=n.nodeSize)?p:5;var p;for(const t of e){let e=t.x,o=t.y;u&&(e+=d,o+=h);const i=r(Im(t,"nodeStyle"));let a=i.fill||Jm(n);if(n.colorByDepth&&void 0!==t.depth){const e=Qm(n);a=e[t.depth%e.length]}s.push({type:"circle",cx:e,cy:o,r:f,style:{fill:a,stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:t,id:t.id,label:t.id,depth:t.depth})}const y=n.edgeOpacity??.5;for(const e of t){const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;if(!t||!o)continue;let r=t.x,s=t.y,c=o.x,f=o.y;u&&(r+=d,s+=h,c+=d,f+=h);const p=ex(r,s,c,f,l),g=i(Im(e,"edgeStyle"));a.push({type:"curved",pathD:p,style:{fill:"none",stroke:g.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??y},datum:e})}if(!1!==n.showLabels){const t=Zm(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let o,r,i,s=n.x,a=n.y;if(u&&(s+=d,a+=h),u){const e=s-d,t=a-h,n=Math.sqrt(e*e+t*t);n>0?(o=s+e/n*10,r=a+t/n*10,i=0>e?"end":"start"):(o=s,r=a-12,i="middle")}else"horizontal"===l?(n.data?.children&&0!==n.data.children.length?(o=s-f-6,i="end"):(o=s+f+6,i="start"),r=a):(o=s,r=a+f+14,i="middle");c.push({x:o,y:r,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:c}}(e,t,n,o,r,i);case"treemap":case"partition":return function(e,t,n,o){const r=[],i=[];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=o(Im(n,"nodeStyle"));let a=s.fill||Jm(t);if(t.colorByDepth&&void 0!==n.depth){const e=Qm(t);a=e[n.depth%e.length]}r.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:{fill:a,stroke:s.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Zm(t.nodeLabel),r=t.labelMode||"leaf",s="partition"===t.chartType;for(const a of e){const e=a.x1-a.x0,c=a.y1-a.y0;if(0>=e||0>=c)continue;const l=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===r&&!l)continue;if("parent"===r&&l)continue}const u=n?n(a):a.id;if(!u)continue;if((l?30:40)>e||(l?16:14)>c)continue;let d=o(Im(a,"nodeStyle")).fill||Jm(t);if(t.colorByDepth&&void 0!==a.depth){const e=Qm(t);d=e[a.depth%e.length]}const h="string"==typeof d?Um(d):t.themeSemantic?.text??"#000";i.push(l?{x:a.x0+e/2,y:a.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/6)),fill:h}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:r,sceneEdges:[],labels:i}}(e,n,0,r);case"circlepack":return function(e,t,n,o){const r=[],i=[];for(const n of e){const e=n.__radius??5;if(0>=e)continue;const i=o(Im(n,"nodeStyle"));let s=i.fill||Jm(t);if(t.colorByDepth&&void 0!==n.depth){const e=Qm(t);s=e[n.depth%e.length]}r.push({type:"circle",cx:n.x,cy:n.y,r:e,style:{fill:s,stroke:i.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Zm(t.nodeLabel);for(const r of e){const e=r.__radius??5,s=n?n(r):r.id;if(!s)continue;if(15>e)continue;const a=!(r.data?.children&&r.data.children.length>0);let c=o(Im(r,"nodeStyle")).fill||Jm(t);if(t.colorByDepth&&void 0!==r.depth){const e=Qm(t);c=e[r.depth%e.length]}if(a){const n="string"==typeof c?Um(c):t.themeSemantic?.text??"#000";i.push({x:r.x,y:r.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else i.push({x:r.x,y:r.y-e+14,text:s+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:r,sceneEdges:[],labels:i}}(e,n,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function nx(e,t,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=t.x,o=t.y;e.x=o*Math.cos(n-Math.PI/2),e.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function ox(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function rx(e,t){const n=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}var ix=require("d3-shape");function sx(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var ax={sankey:zm,force:Dm,chord:Gm,tree:tx,cluster:tx,treemap:tx,circlepack:tx,partition:tx,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,o){const r=n.__hierarchyRoot;r&&function(e,t,n,o,r){const i=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),s=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(n.nodeIDAccessor),a=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),c=n.orbitSize??2.95,l=n.orbitEccentricity??1,u="number"==typeof c?()=>c:c,d="number"==typeof l?()=>l:l,h=sx(n);h.metaMap.clear(),o.length=0,r.length=0;const f=new Map;function p(e){const t=f.get(e)??0;return f.set(e,t+1),0===t?e:`${e}__${t}`}const y=t[0]/2,g=t[1]/2,m=Math.min(t[0],t[1])/2*.85,x=p(s(e));o.push({id:x,x:y,y:g,x0:y,x1:y,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:e}),h.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,c,l,f,y,g){const m=i(t);if(!m?.length)return;const x=m.length;let b=0,v=0,w=0;for(;x>v;)v+=a[Math.min(w,a.length-1)],w++,b++;let k=0;for(let x=0;b>x;x++){const v=a[Math.min(x,a.length-1)],w=m.slice(k,k+v);if(!w.length)break;const S=(x+1)/b,A={id:n,depth:y,data:t,parentId:n},M=g?f/u(A)*S:f*S,_=(0,ix.pie)().value(e=>{const t=i(e)?.length;return t?4:1}).sort(null)(w),P=d(A);for(let t=0;w.length>t;t++){const i=(_[t].startAngle+_[t].endAngle)/2,a=w[t],u=p(s(a)),d=c+M*Math.sin(i),f=l+M*Math.cos(i)*P;o.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:y,data:a}),h.metaMap.set(u,{ring:M,angle:i,depth:y,parentId:n,eccentricity:P}),r.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(a,u,d,f,M,y+1,!0)}k+=v}}(e,x,y,g,m,1,!1)}(r,o,n,e,t)},buildScene(e,t,n,o){const r=n.nodeStyle,i=n.nodeSize,s="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,a=[],c=[],l=[];if(!1!==n.orbitShowRings){const t=sx(n),o=new Map;for(const t of e)o.set(t.id,t);const r=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=o.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;r.has(n)||r.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:o}]of r)for(let r=0;i>r;r++){const a=r/i*Math.PI*2,l=(r+1)/i*Math.PI*2;c.push({type:"line",x1:e+n*Math.sin(a),y1:t+n*Math.cos(a)*o,x2:e+n*Math.sin(l),y2:t+n*Math.cos(l)*o,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=s(Im(t,"nodeSize")),o=r?r(Im(t,"nodeStyle")):{};a.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:o.fill||n.themeSemantic?.primary||"#6366f1",stroke:o.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.opacity??(0===(t.depth??0)?1:.85)},datum:t,id:t.id,label:t.id,depth:t.depth})}const u=new Map;for(const t of e)u.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:u.get(e.source),n="object"==typeof e.target?e.target:u.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&c.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=s(Im(n,"nodeSize"));if(4>=e)continue;const o="function"==typeof t?t(n):t?n.data?.[t]??n.id:n.id;l.push({x:n.x,y:n.y+e+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:c,labels:l}},tick:(e,t,n,o,r)=>!1!==n.orbitAnimated&&(function(e,t){const n=sx(t),o=t.orbitSpeed??.25,r=t.orbitRevolution??function(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),i=(("undefined"!=typeof performance?performance.now():Date.now())-n.startTime)/1e3,s=o*(Math.PI/6),a=new Map;for(const t of e)a.set(t.id,t);for(const t of e){const e=n.metaMap.get(t.id);if(!e||!e.parentId)continue;const o=a.get(e.parentId);if(!o)continue;const c=e.angle+i*s*r({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=o.x+e.ring*Math.sin(c),t.y=o.y+e.ring*Math.cos(c)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)}},cx=require("react/jsx-runtime");function lx(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}var ux=new Set(["tree","cluster","treemap","circlepack","partition"]);function dx(e,t){const n=Ke(e.theme),o=e.chartType||"force",r=()=>jy({frameType:"network",width:i[0],height:i[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,nodeCount:0,edgeCount:0,margin:s}),i=e.size||[500,500],s=Es({top:20,right:20,bottom:20,left:20,...e.margin},e.title),a=$s(e.title),c=e.showLegend?(()=>{const t="string"==typeof(n=e.colorBy)||"function"==typeof n?e.colorBy:void 0;var n;if(!t)return[];const o=E(e.nodes||[]);if(o.length>0)return Wy(o,t);const r=Array.isArray(e.edges)?E(e.edges):[];if(0===r.length)return[];const i=lx(e.sourceAccessor,"source"),s=lx(e.targetAccessor,"target");return Wy(Array.from(new Set(r.flatMap(e=>[i(e),s(e)]).filter(e=>null!=e).map(String))).map(e=>({id:e})),t)})():[];ig(s,{props:e,categories:c,theme:n,size:i,hasTitle:a});const l=i[0]-s.left-s.right,u=i[1]-s.top-s.bottom,d=function(e){return ax[e]}(o);if(!d&&!e.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${o}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const h={chartType:o,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||n.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig};let f,p;if(ux.has(o)){const o=e.data||e.edges;if(!o||Array.isArray(o))return t&&(t.evidence=r()),Dg.renderToStaticMarkup(cg(null,{width:i[0],height:i[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:u,idPrefix:e._idPrefix}));h.__hierarchyRoot=o,f=[],p=[]}else{const o=E(e.nodes||[]),a=Array.isArray(e.edges)?E(e.edges):[];if(0===o.length&&0===a.length)return t&&(t.evidence=r()),Dg.renderToStaticMarkup(cg(null,{width:i[0],height:i[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:u,idPrefix:e._idPrefix}));if(p=function(e,t){const n=lx(t.sourceAccessor,"source"),o=lx(t.targetAccessor,"target"),r=lx(t.valueAccessor,"value");return e.map(e=>({source:n(e)+"",target:o(e)+"",value:Number(r(e))||1,y0:0,y1:0,sankeyWidth:0,data:e}))}(a,h),0===o.length&&p.length>0){const e=new Set;for(const t of p){const n=Jy(t.source),o=Jy(t.target);n&&e.add(n),o&&e.add(o)}f=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 f=function(e,t){const n=lx(t.nodeIDAccessor,"id");return e.map(e=>({id:n(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}))}(o,h)}let y=[],g=[],m=[],x=null;if(h.customNetworkLayout){const e=h.colorScheme,t=tp(e,n.colors.categorical,N),o=np(t,e),r={nodes:f,edges:p,dimensions:{width:l,height:u,plot:{x:0,y:0,width:l,height:u}},theme:{semantic:n.colors,categorical:[...t]},resolveColor:o,config:h.layoutConfig??{}},i=h.customNetworkLayout(r);y=i.sceneNodes??[],g=i.sceneEdges??[],m=i.labels??[],x=i.overlays??null}else if(d){d.computeLayout(f,p,h,[l,u]);const e=d.buildScene(f,p,h,[l,u]);y=e.sceneNodes,g=e.sceneEdges,m=e.labels}const b=Ze(n);for(const e of m)e.fill||(e.fill=b.text);const v=vl({nodes:g,renderMode:e.renderMode,fallback:(e,t)=>function(e,t){switch(e.type){case"line":return(0,oa.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+t);case"bezier":{const n=e;return(0,oa.jsx)("path",{d:n.pathD,fill:Ks(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"ribbon":{const n=e;return(0,oa.jsx)("path",{d:n.pathD,fill:Ks(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"curved":{const n=e;return(0,oa.jsx)("path",{d:n.pathD,fill:Ks(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+t)}default:return null}}(e,t)}),w=vl({nodes:y,renderMode:e.renderMode,fallback:(e,t)=>function(e,t){switch(e.type){case"circle":{const n=e,o=Oo(n.style.fill)?Fo(n.style.fill,`net-circle-${t}-hatch`):void 0;return(0,oa.jsxs)(ta.Fragment,{children:[o&&(0,oa.jsx)("defs",{children:o}),(0,oa.jsx)("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:o?`url(#net-circle-${t}-hatch)`:Ks(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-circle-"+t)}case"rect":{const n=e,o=Oo(n.style.fill)?Fo(n.style.fill,`net-rect-${t}-hatch`):void 0;return(0,oa.jsxs)(ta.Fragment,{children:[o&&(0,oa.jsx)("defs",{children:o}),(0,oa.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:o?`url(#net-rect-${t}-hatch)`:Ks(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-rect-"+t)}case"arc":{const n=e,o=(0,na.arc)().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(Us)||"",r=Oo(n.style.fill)?Fo(n.style.fill,`net-arc-${t}-hatch`):void 0;return(0,oa.jsxs)(ta.Fragment,{children:[r&&(0,oa.jsx)("defs",{children:r}),(0,oa.jsx)("path",{d:o,transform:`translate(${n.cx},${n.cy})`,fill:r?`url(#net-arc-${t}-hatch)`:Ks(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-arc-"+t)}case"symbol":{const n=e,o=un(n.symbolType,n.size,n.path);return(0,oa.jsx)("path",{d:o,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?Ks(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return Qs(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)});t&&(t.evidence=jy({frameType:"network",width:i[0],height:i[1],marks:[...w.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:w.length,edgeCount:v.length,margin:s}));const k=v.map(e=>e.element),S=w.map(e=>e.element),A=m.map((e,t)=>function(e,t){return(0,oa.jsx)("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+t)}(e,t)).filter(Boolean),M=e.annotations?Ky({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{},layout:{width:l,height:u},theme:n,idPrefix:e._idPrefix}):null,_=sg({props:e,categories:c,theme:n,size:i,margin:s,hasTitle:a});return Dg.renderToStaticMarkup(cg((0,cx.jsxs)(cx.Fragment,{children:[e.backgroundGraphics,k,S,A,M,e.foregroundGraphics,x]}),{width:i[0],height:i[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:u,legend:_,idPrefix:e._idPrefix}))}var hx=y(require("react-dom/server")),fx=require("d3-geo"),px=require("d3-quadtree"),yx=require("d3-geo"),gx={mercator:yx.geoMercator,equalEarth:yx.geoEqualEarth,albersUsa:yx.geoAlbersUsa,orthographic:yx.geoOrthographic,naturalEarth:yx.geoNaturalEarth1,equirectangular:yx.geoEquirectangular};function mx(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function xx(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function bx(e,t,n){return e?"function"==typeof e?{...n,...e(t)}:{...n,...e}:{...n}}function vx(e,t){if(2>e.length)return[e];const n=.4*t,o=[];let r=[e[0]];for(let t=1;e.length>t;t++){const i=e[t];Math.abs(i[0]-e[t-1][0])>n?(2>r.length||o.push(r),r=[i]):r.push(i)}return 2>r.length||o.push(r),o}function wx(e,t,n=24){const o=t[0]-e[0],r=t[1]-e[1],i=Math.sqrt(o*o+r*r);if(0===i)return[e,t];const s=-r/i,a=o/i,c=Math.min(.3*i,80),l=(e[0]+t[0])/2+s*c,u=(e[1]+t[1])/2+a*c,d=[];for(let o=0;n>=o;o++){const r=o/n,i=1-r;d.push([i*i*e[0]+2*i*r*l+r*r*t[0],i*i*e[1]+2*i*r*u+r*r*t[1]])}return d}function kx(e,t){if(2>e.length)return e;const n=t/2+1,o=[];for(let t=0;e.length>t;t++){const r=e[t];let i,s;0===t?(i=e[1][0]-r[0],s=e[1][1]-r[1]):t===e.length-1?(i=r[0]-e[t-1][0],s=r[1]-e[t-1][1]):(i=e[t+1][0]-e[t-1][0],s=e[t+1][1]-e[t-1][1]);const a=Math.sqrt(i*i+s*s)||1;o.push([r[0]+s/a*n,r[1]+-i/a*n])}return o}function Sx(e,t,n,o,r){const i=t[0]-e[0],s=t[1]-e[1],a=Math.sqrt(i*i+s*s);if(0===a)return[e,t];const c=s/a,l=-i/a,u=r/2+1;return[[e[0]+c*u,e[1]+l*u],[t[0]+c*u,t[1]+l*u]]}var Ax=require("d3-scale");var Mx=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],_x=["scene-style","data-paint","accessibility","evidence"],Px=(e,t)=>({retainedData:e,invalidations:t}),jx=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Rx=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Cx=["scene-geometry","data-paint","accessibility","evidence"],Lx=["scene-style","data-paint","accessibility","evidence"],Ix=["overlay","accessibility","evidence"],Tx=[],$x={xAccessor:Px("rebuild",jx),yAccessor:Px("rebuild",jx),lineDataAccessor:Px("rebuild",jx),pointIdAccessor:Px("rebuild",Cx),lineIdAccessor:Px("rebuild",Cx),windowSize:Px("rebuild",jx),projection:Px("preserve",Rx),projectionExtent:Px("preserve",Rx),fitPadding:Px("preserve",Rx),lineType:Px("preserve",Rx),flowStyle:Px("preserve",Rx),graticule:Px("preserve",Rx),projectionTransform:Px("preserve",Rx),customLayout:Px("preserve",Rx),layoutConfig:Px("preserve",Rx),layoutMargin:Px("preserve",Rx),areaStyle:Px("preserve",Lx),pointStyle:Px("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:Px("preserve",Lx),colorScheme:Px("preserve",Lx),themeCategorical:Px("preserve",Lx),themeDiverging:Px("preserve",Lx),themeSemantic:Px("preserve",Lx),themeSequential:Px("preserve",Lx),decay:Px("preserve",Lx),pulse:Px("preserve",Lx),layoutSelection:Px("preserve",Lx),annotations:Px("preserve",Ix),autoPlaceAnnotations:Px("preserve",Ix),clock:Px("preserve",Tx),transition:Px("preserve",Tx),introAnimation:Px("preserve",Tx),onLayoutError:Px("preserve",Tx)},zx=Px("preserve",Rx),Ex=class{constructor(){this.tracker=new Bn}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}},Mx)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},_x):this.recordNoop("restyle")}recordConfig(e,t={}){const n=function(e){let t="preserve";const n=new Set;for(const o of e){const e=$x[o]??zx;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e),o=new Set(n.invalidations);return t.retainedDataChanged&&o.add("data"),this.tracker.record({kind:"config",keys:e},o)}},Ox=require("d3-geo");function Dx(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 Bx=class e{constructor(e){this.updateResults=new Ex,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:Dx(e.fitPadding)}}(e)}currentTime(){return this.config.clock?.()??Ot()}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(),n=this.timestampBuffer?.toArray()??[],o=t.slice(-e),r=n.slice(-o.length),i=this.currentTime();this.pointBuffer=new At(e),this.timestampBuffer=new At(e),o.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(r[t]??i)})}this.retainNewestLines(e)}updateConfig(e){const t=function(e){return"fitPadding"in e?{...e,fitPadding:Dx(e.fitPadding)}:e}(e),n=this.config,o=this.getConfiguredWindowSize(),r=Object.keys(t).filter(e=>t[e]!==n[e]);this.config={...this.config,...t};const i=this.getConfiguredWindowSize(),s=this.streaming&&i!==o;s&&(this.resizeStreamingWindow(i),this.version++),"customLayout"in t&&!t.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(r,{retainedDataChanged:s})}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(),n=this.pointBuffer?this.pointBuffer.toArray():this.pointData,o=this.timestampBuffer?.toArray()??[],r=n.slice(-t),i=o.slice(-r.length),s=this.currentTime();this.pointBuffer=new At(t),this.timestampBuffer=new At(t),r.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(i[t]??s)}),this.pointData=[],this.retainNewestLines(t),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();const t=this.currentTime();_n(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 n of e)_n(this.pointBuffer,n,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 n="function"==typeof t?t:e=>e[t],o=new Set(Array.isArray(e)?e:[e]),r=[];return this.lineData=this.lineData.filter(e=>!o.has(n(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 n="function"==typeof t?t:e=>e[t],o=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){const e=e=>o.has(n(e)+"");Pn(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=>!o.has(n(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 n of this.scene){const o=this._baseStyles.get(n)??n.style,r=t(n,e);n.style=r?{...o,...r}:o}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(e){const{config:t}=this,n=this.projection,o=this.geoPath,r=this.scales,i=this.baseScale,s=[...this.baseTranslate],a=[...this.baseRotation],c=this.scene;this.projection=function(e){if(!e)return(0,yx.geoEqualEarth)();if("string"==typeof e){const t=gx[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),(0,yx.geoEqualEarth)())}if("object"==typeof e&&"type"in e){const t=gx[e.type],n=t?t():(0,yx.geoEqualEarth)();return e.rotate&&"rotate"in n&&n.rotate(e.rotate),e.center&&"center"in n&&n.center(e.center),n}return e}(t.projection),this.geoPath=(0,fx.geoPath)(this.projection),this.fitProjection(e),this.geoPath=(0,fx.geoPath)(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=n,this.geoPath=o,this.scales=r,this.baseScale=i,this.baseTranslate=s,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,n=e.height/2,o=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:n}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,t.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(e){const t=this.projection,n=this.config,o=[...this.areas],r=mx(n.xAccessor,"lon"),i=mx(n.yAccessor,"lat"),s=this.getPoints();if(s.length>0){const e=s.map(e=>[r(e),i(e)]);o.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const a=xx(n.lineDataAccessor);for(const e of this.lineData){const t=a(e);if(t&&t.length>0){const e=t.map(e=>[r(e),i(e)]);o.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==o.length){if(n.projectionExtent){const[[o,r],[i,s]]=n.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[o,r],[o,s],[i,s],[i,r],[o,r]]]}})}else if(t.clipAngle&&(t.clipAngle()??0)>0){const o=n.fitPadding??0,r=Math.min(e.width,e.height);t.scale(r/2-r*o),t.translate([e.width/2,e.height/2])}else{const r=n.fitPadding??0,i=e.width*r,s=e.height*r;t.fitExtent([[i,s],[e.width-i,e.height-s]],{type:"FeatureCollection",features:o})}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){const n=this.projection;if(!n)return;const o=this.geoPath,r=this.scales,i=n.scale(),s=[...n.translate()],a=this.currentZoom;n.scale(this.baseScale*e.k),n.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=(0,fx.geoPath)(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(i),n.translate(s),this.currentZoom=a,this.geoPath=o,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 n=this.projection;if(!n)return;const o=this.geoPath,r=this.scales,i=n.scale(),s=[...n.translate()],a=this.currentZoom;n.scale(this.baseScale*e),n.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=(0,fx.geoPath)(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(i),n.translate(s),this.currentZoom=a,this.geoPath=o,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 n=this.projection;if(!n||!n.rotate)return;const o=this.geoPath,r=this.scales,i=[...n.rotate()];n.rotate(e),this.geoPath=(0,fx.geoPath)(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const s=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.rotate(i),this.geoPath=o,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=s,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,n=0;for(const e of this.scene)"point"===e.type&&(n++,e.r>t&&(t=e.r));if(this._maxPointRadius=t,e.QUADTREE_THRESHOLD>=n)return void(this._quadtree=null);const o=Array(n);let r=0;for(const e of this.scene)"point"===e.type&&(o[r++]=e);this._quadtree=(0,px.quadtree)().x(e=>e.x).y(e=>e.y).addAll(o)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){this._customLayoutFailedThisBuild=!1;const{config:t}=this,n=this.projection,o=this.geoPath;if(t.customLayout&&this.scales){const n=t.layoutMargin??{top:0,right:0,bottom:0,left:0},o=tp(t.colorScheme,t.themeCategorical,fe),r={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:n,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...o]},resolveColor:np(o,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null};let i;try{i=t.customLayout(r)}catch(e){const n=null!==this.lastCustomLayoutResult,o=xn("geo",e,n,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",e);try{t.onLayoutError?.(o)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return n?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}const s=i.nodes??[];if(this.customLayoutOverlays=i.overlays??null,this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null,this._customRestyle=i.restyle,this.hasCustomRestyle=!!i.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(const e of s)this._baseStyles.set(e,e.style);this.restyleScene(t.layoutSelection??null)}return yn({label:"geo customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}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:n,areas:o,points:r,lines:i,layout:s}){const a=mx(e.xAccessor,"lon"),c=mx(e.yAccessor,"lat"),l=[],u=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),h=function(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(e);if(e.graticule){const t=!0===e.graticule?{}:e.graticule,o=(0,Ox.geoGraticule)();t.step&&o.step(t.step);const r=n(o())||"";r&&l.push({type:"geoarea",pathData:r,centroid:[s.width/2,s.height/2],bounds:[[0,0],[s.width,s.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 o){const o=n(t);if(!o)continue;const r=n.centroid(t),i=n.bounds(t),s=n.area(t);l.push({type:"geoarea",pathData:o,centroid:r,bounds:i,screenArea:s,style:bx(e.areaStyle,t,u),datum:t,interactive:!0})}const f=xx(e.lineDataAccessor);for(const n of i){const o=f(n);if(!o||2>o.length)continue;let r=[];if("geo"===e.lineType){const e=Array(o.length);for(let t=0;o.length>t;t++)e[t]=[a(o[t]),c(o[t])];for(let n=0;e.length-1>n;n++){const o=e[n],i=e[n+1],s=(0,Ox.geoDistance)(o,i)||0,a=Math.max(2,Math.ceil(s/(Math.PI/180))),c=(0,Ox.geoInterpolate)(o,i);for(let e=0;a>=e;e++){if(n>0&&0===e)continue;const o=t(c(e/a));null!=o&&r.push(o)}}}else for(let e=0;o.length>e;e++){const n=o[e],i=t([a(n),c(n)]);null!=i&&r.push(i)}if(2>r.length)continue;const i=bx(e.lineStyle,n,d),u="number"==typeof i.strokeWidth?i.strokeWidth:1;2!==o.length||2>r.length||"arc"!==e.flowStyle?2!==o.length||2>r.length||"offset"!==e.flowStyle||(r="geo"===e.lineType?kx(r,u):Sx(r[0],r[r.length-1],0,0,u)):r=wx(r[0],r[r.length-1]);const h=vx(r,s.width);if(h.length>1)for(const e of h)2>e.length||l.push({type:"line",path:e,style:{...i,_edgeFade:!0},datum:n});else l.push({type:"line",path:2>r.length&&h[0]||r,style:i,datum:n})}const p=e.pointIdAccessor?"function"==typeof e.pointIdAccessor?e.pointIdAccessor:t=>t[e.pointIdAccessor]:null,y=t.clipAngle?t.clipAngle()??0:0,g=y>0?y*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 n of r){const o=a(n),r=c(n);if(null!=g&&(0,Ox.geoDistance)([o,r],b)>g)continue;const i=t([o,r]);if(!i)continue;const s=e.pointStyle?e.pointStyle(n):{...h},u={type:"point",x:i[0],y:i[1],r:s.r||4,style:s,datum:n,pointId:p?p(n)+"":void 0};l.push(u)}return l}({config:t,projection:n,path:o,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:e})}applyCartogramTransform(e,t){const n=function(e,t,n,o){const r=e.filter(e=>"point"===e.type);if(2>r.length)return null;const i=t.strength??1,s=Number.isFinite(i)?Math.max(0,Math.min(1,i)):1,a="strip"===t.layout?"strip":"radial";if("radial"===a&&0===s)return null;const c=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,l="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=r.find(e=>e.datum&&c(e.datum)+""==t.center+"");if(!u)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;const d=we(r.map(e=>e.datum?Number(l(e.datum)):NaN).filter(e=>isFinite(e)&&e>=0),1);o>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 n=e[t];"geoarea"===n.type&&n.interactive&&e.splice(t,1)}const h="strip"===a?function(e,t,n,o,r){const i=Math.max(3,Math.min(8,.35*r.height)),s=Math.max(1,r.width-2*i),a=r.height/2,c=(0,Ax.scaleLinear)().domain([0,o]).range([0,s]);t.x=i,t.y=a;const l=[];for(const r of e){if(r===t)continue;if(!r.datum){r.x=i,r.y=a;continue}const e=Number(n(r.datum)),s=i+(isFinite(e)&&e>=0&&o>0?c(e):0);r.x=s,r.y=a,l.push({node:r,x:s})}l.sort((e,t)=>e.x-t.x);const u=Math.max(0,Math.min(r.height/2-1,6));let d=0;for(;l.length>d;){let e=d+1;for(;l.length>e&&3>Math.abs(l[e].x-l[d].x);)e++;const t=e-d;if(t>1&&u>0)for(let e=0;t>e;e++)l[d+e].node.y=a+(e-(t-1)/2)*Math.min(2.5,2*u/Math.max(1,t-1));d=e}return{cx:i,cy:a,maxCost:o,availableRadius:s,layout:"strip"}}(r,u,l,d,n):function(e,t,n,o,r,i){const s=t.x,a=t.y,c=i.width/2,l=i.height/2,u=Math.min(i.width,i.height)/2,d=(0,Ax.scaleLinear)().domain([0,o]).range([0,u]);for(const i of e){if(i===t)continue;if(!i.datum)continue;const e=i.x,u=i.y,h=Math.atan2(u-a,e-s),f=Math.hypot(e-s,u-a),p=Number(n(i.datum)),y=isFinite(p)&&p>=0?o>0?d(p):0:f,g=c+Math.cos(h)*y,m=l+Math.sin(h)*y;i.x=e+(g-e)*r,i.y=u+(m-u)*r}return t.x=s+(c-s)*r,t.y=a+(l-a)*r,{cx:t.x,cy:t.y,maxCost:o,availableRadius:u,layout:"radial"}}(r,u,l,d,s,n),f=e.filter(e=>"line"===e.type);if(f.length>0){const e=new Map;for(const t of r)null!=t.pointId&&e.set(t.pointId+"",[t.x,t.y]);for(const n of f){const o=n.datum?.source,r=n.datum?.target;if(null!=o&&null!=r){const i=e.get(o+""),s=e.get(r+"");if(i&&s)if("fractional"===t.lineMode&&n.path.length>2){const e=n.path[0],t=n.path[n.path.length-1],o=[i[0]-e[0],i[1]-e[1]],r=[s[0]-t[0],s[1]-t[1]],a=[0];for(let e=1;n.path.length>e;e++)a.push(a[e-1]+Math.hypot(n.path[e][0]-n.path[e-1][0],n.path[e][1]-n.path[e-1][1]));const c=a[a.length-1];n.path=n.path.map((e,t)=>{const i=c>0?a[t]/c:t/(n.path.length-1);return[e[0]+o[0]*(1-i)+r[0]*i,e[1]+o[1]*(1-i)+r[1]*i]})}else n.path=[i,s]}}}return h}(this.scene,e,t,this.areas.length);n&&(this.cartogramLayout=n)}applyDecay(){const e=this.config.decay;if(!e||!this.pointBuffer)return;const t=this.pointBuffer.size;if(0===t)return;const n=this.scene.filter(e=>"point"===e.type);for(let o=0;n.length>o;o++){const r=Dt(e,o,t);n[o]._decayOpacity=r,n[o].style={...n[o].style,opacity:r}}}applyPulse(e=this.currentTime()){const t=this.config.pulse;if(!t||!this.timestampBuffer)return!1;const n=this.scene.filter(e=>"point"===e.type),o=this.timestampBuffer.toArray(),r=t.color||"rgba(255,255,255,0.6)",i=t.glowRadius??4;let s=!1;for(let a=0;n.length>a&&o.length>a;a++){const c=Ft(t,o[a],e);s=Nt(n[a],c,r,i)||s}return s}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&Wt(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 n=new Map;for(const t of e)"point"===t.type&&t.pointId&&n.set(t.pointId,[t.x,t.y]);const o=this.scene.filter(e=>"point"===e.type);let r=!1;for(const e of o)if(e.pointId){const t=n.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 o)e.pointId&&!n.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=zt(e,this.activeTransition),n=$t(t),o=this.scene.filter(e=>"point"===e.type);for(const e of o){if(null!=e._targetX&&null!=e._targetY){const t=e.y;e.x=Et(e.x,e._targetX,n),e.y=Et(t,e._targetY,n)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*n})}if(t>=1){for(const e of o)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}};Bx.QUADTREE_THRESHOLD=500;var Fx=Bx;zn(Fx);var Nx=require("react/jsx-runtime");function Wx(e,t){const n=Ke(e.theme),o=e.size||[e.width||600,e.height||400],r=Es({top:10,right:10,bottom:10,left:10,...e.margin},e.title),i=$s(e.title),s=Array.isArray(e.areas)?E(e.areas):e.areas,a=E(e.points),c=E(e.lines),l=e.showLegend?(()=>{const t="string"==typeof(n=e.colorBy)||"function"==typeof n?e.colorBy:void 0;var n;return Wy(a.length>0?a:Array.isArray(s)&&s.length>0?"string"==typeof t?s.map(e=>({...e.properties||{},...e})):s:[],t)})():[];ig(r,{props:e,categories:l,theme:n,size:o,hasTitle:i});const u=o[0]-(r.left??0)-(r.right??0),d=o[1]-(r.top??0)-(r.bottom??0),h={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:n.colors.categorical,themeSemantic:Fe(n)},f=new Fx(h);if(s){if("string"==typeof s)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${s}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${s}')\` before calling renderGeoToStaticSVG.`);f.setAreas(s)}e.points&&f.setPoints(a),e.lines&&f.setLines(c),f.computeScene({width:u,height:d});const p=vl({nodes:f.scene,renderMode:e.renderMode,fallback:(e,t)=>function(e,t){switch(e.type){case"geoarea":{const n=e;if(!n.pathData)return null;const o=Oo(n.style.fill)?Fo(n.style.fill,`geoarea-${t}-hatch`):void 0;return(0,ia.jsxs)(ra.Fragment,{children:[o&&(0,ia.jsx)("defs",{children:o}),(0,ia.jsx)("path",{d:n.pathData,fill:o?`url(#geoarea-${t}-hatch)`:Ks(n.style.fill,"#e0e0e0"),fillOpacity:n.style.fillOpacity??1,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth||.5,strokeDasharray:n.style.strokeDasharray,opacity:n._decayOpacity??1})]},"geoarea-"+t)}case"point":{const n=e,o=Oo(n.style.fill)?Fo(n.style.fill,`geopoint-${t}-hatch`):void 0;return(0,ia.jsxs)(ra.Fragment,{children:[o&&(0,ia.jsx)("defs",{children:o}),(0,ia.jsx)("circle",{cx:n.x,cy:n.y,r:n.r,fill:o?`url(#geopoint-${t}-hatch)`:Ks(n.style.fill),fillOpacity:n.style.fillOpacity??.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n._decayOpacity??n.style.opacity??1})]},"point-"+t)}case"line":{const n=e;if(2>n.path.length)return null;const o="M"+n.path.map(e=>`${e[0]},${e[1]}`).join("L");return(0,ia.jsx)("path",{d:o,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||1.5,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity??1},"line-"+t)}case"glyph":return Qs(e,e.x,e.y,"geo-glyph-"+(e.pointId??t));default:return null}}(e,t)});if(t&&(t.evidence=jy({frameType:"geo",width:o[0],height:o[1],marks:p.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,legendItems:l.length>0?l.length:void 0,margin:r})),0===p.length){const t=e.backgroundGraphics||e.foregroundGraphics||e.annotations||f.customLayoutOverlays?(0,Nx.jsxs)(Nx.Fragment,{children:[e.backgroundGraphics,e.annotations?Ky({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{geoProjection:f.scales?.projectedPoint?([e,t])=>f.scales.projectedPoint(e,t):void 0},layout:{width:u,height:d},theme:n,idPrefix:e._idPrefix}):null,e.foregroundGraphics,f.customLayoutOverlays]}):null;return hx.renderToStaticMarkup(cg(t,{width:o[0],height:o[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left??0},${r.top??0})`,innerWidth:u,innerHeight:d,idPrefix:e._idPrefix}))}const y=p.map(e=>e.element),g=e.annotations?Ky({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{geoProjection:f.scales?.projectedPoint?([e,t])=>f.scales.projectedPoint(e,t):void 0},layout:{width:u,height:d},theme:n,idPrefix:e._idPrefix}):null,m=sg({props:e,categories:l,theme:n,size:o,margin:r,hasTitle:i});return hx.renderToStaticMarkup(cg((0,Nx.jsxs)(Nx.Fragment,{children:[e.backgroundGraphics,y,g,e.foregroundGraphics,f.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left??0},${r.top??0})`,innerWidth:u,innerHeight:d,legend:m,idPrefix:e._idPrefix}))}var qx=y(require("react-dom/server"));function Yx(e=[]){return e.map(e=>({id:e.id,label:e.label,count:e.count,...null!=e.secondary?{secondary:e.secondary}:{},...e.secondaryLabel?{secondaryLabel:e.secondaryLabel}:{},...null!=e.observed?{observed:e.observed}:{}}))}var Gx={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function Hx(e){const t=e.datum;if(t&&"object"==typeof t){const e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e.id}function Vx(e,t){const n="function"==typeof t?t(e):t;return{...Gx,...n??{}}}function Xx(e,t={}){return e.map(e=>function(e,t={}){const n=function(e){return e.datum&&"object"==typeof e.datum?e.datum:null}(e),o={label:t.getBodyLabel?.(e)??Hx(e)},r={style:Vx(e,t.bodyStyle),datum:n,accessibleDatum:n,accessibility:o,_transitionKey:e.id};return"aabb"===e.shape.type?{type:"rect",x:e.x-e.shape.width/2,y:e.y-e.shape.height/2,w:e.shape.width,h:e.shape.height,...r}:{type:"point",x:e.x,y:e.y,r:e.shape.radius,pointId:e.id,...r}}(e,t))}var Ux=require("react/jsx-runtime"),Kx={top:0,right:0,bottom:0,left:0};function Zx(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function Qx(e,t){const n=e.size??[e.width??600,e.height??400],o=new Df(e.config);Array.isArray(e.initialSpawns)&&e.initialSpawns.length>0&&o.enqueue(e.initialSpawns.map(e=>({...e,spawnAt:void 0})));const r=function(e,t={}){const{width:n=640,height:o=360,title:r,description:i,background:s,backgroundGraphics:a,className:c,foregroundGraphics:l,idPrefix:u="physics",margin:d,renderBodySVG:h,...f}=t,p=function(e,t={}){const n=e.settle(t.maxSteps),o=e.readBodies(),r=e.snapshot(),i=Xx(o,t),s=function(e,t={}){const n=t.bodies??function(e){return e.world.bodies.map(e=>({id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,shape:{...e.shape},sleeping:e.sleeping,datum:e.datum}))}(e),o=n.filter(e=>e.sleeping).length;return{bodyCount:n.length,sleepingCount:o,settled:"settled"===e.simulationState&&0===e.queue.length&&o===n.length,stepsRun:Math.max(0,Math.floor(t.stepsRun??0)),seed:e.world.options.seed,binCounts:Yx(t.projectionRows)}}(r,{bodies:o,projectionRows:t.projectionRows,stepsRun:n});return{snapshot:r,bodies:o,sceneNodes:i,evidence:s,stepsRun:n}}(e,f),y={...Kx,...d},g=[n,o],m=Zx(a,g,y),x=Zx(l,g,y),b=function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"physics-"+t:t}(u),v=r?b+"-title":void 0,w=i?b+"-desc":void 0,k=[v,w].filter(Boolean).join(" ")||void 0;return{svg:qx.renderToStaticMarkup((0,Ux.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:c??"stream-physics-frame",width:n,height:o,viewBox:`0 0 ${n} ${o}`,role:"img","aria-labelledby":k,children:[r&&(0,Ux.jsx)("title",{id:v,children:r}),i&&(0,Ux.jsx)("desc",{id:w,children:i}),!a&&s&&"transparent"!==s?(0,Ux.jsx)("rect",{x:0,y:0,width:n,height:o,fill:s}):null,m,(0,Ux.jsx)("g",{id:b+"-data-area",children:p.sceneNodes.map((e,t)=>{const n=p.bodies[t];return(n&&h?h(n,e.style??{},t,b):void 0)??ga(e,t,b)})}),x]})),scene:p,evidence:p.evidence}}(o,{...e,width:n[0],height:n[1],idPrefix:e.idPrefix??e._idPrefix??"physics"});return t&&(t.evidence=jy({frameType:"physics",width:n[0],height:n[1],marks:r.scene.sceneNodes,title:e.title,description:e.description,annotations:[],extraWarnings:0===r.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[]})),r.svg}var Jx=require("react/jsx-runtime");function eb(e,t){switch(e){case"xy":return ug(t);case"ordinal":return Og(t);case"network":return dx(t);case"geo":return Wx(t);case"physics":return Qx(t);default:throw Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function tb(e){return ug(e)}function nb(e){return Og(e)}function ob(e){return dx(e)}function rb(e){return Wx(e)}var ib=["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","svgAnnotationRules","barColors","legend","legendLayout","autoPlaceAnnotations"],sb=["width","height","showAxes","showGrid","enableHover","showLegend","showLabels","showCategoryTicks","orientation","title","description","summary","accessibleTable","xLabel","yLabel","categoryLabel","valueLabel","linkedHover","mobileInteraction","mobileSemantics","responsiveRules"];function ab(e,t){const n={};for(const o of t)void 0!==e[o]&&(n[o]=e[o]);return n}function cb(e,t,n){return ub(e,t).svg}function lb(e,t,n){const o={},{svg:r,frameType:i}=ub(e,t,0,o),s=o.evidence??jy({frameType:i,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 s.component=e,{svg:r,evidence:s}}function ub(e,t,n,o){const r=My[e];if(!r)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);var i;const s=C(r.layout?.mode??("string"==typeof(i=t.mode)&&Object.prototype.hasOwnProperty.call(R,i)?t.mode:void 0),{...r.layout?.modeDefaults,...ab(t,sb)},r.layout?.primarySize),{data:a,theme:c,background:l,className:u,annotations:d,margin:h,colorScheme:f,colorBy:p,legendPosition:y,...g}=t,{width:m,height:x}=s,b=[m,x],v=g.frameProps||{},w=r.layout?.margin,k="function"==typeof w?w(t,s):w??s.marginDefaults,S=void 0!==h?h:v.margin,A=I(S),M="number"==typeof S?{top:S,right:S,bottom:S,left:S}:{...k,...A},_=ab(g,ib),P=e=>v[e]??s[e],j={...v,..._,theme:c,title:s.title,description:s.description,showAxes:P("showAxes"),showLegend:P("showLegend"),showLabels:P("showLabels"),showGrid:P("showGrid"),xLabel:P("xLabel"),yLabel:P("yLabel"),categoryLabel:P("categoryLabel"),valueLabel:P("valueLabel"),background:l,className:u,annotations:d,size:b,margin:M,__explicitMargin:S,__autoLegendMargin:!0,...void 0!==f&&{colorScheme:f},...void 0!==y&&{legendPosition:y},_idPrefix:g._idPrefix},L=r.buildProps(a,p,f,j,g);let $;switch(r.frameType){case"xy":$=ug(L,o);break;case"ordinal":$=Og(L,o);break;case"network":$=dx(L,o);break;case"geo":$=Wx(L,o);break;case"physics":$=Qx(L,o)}const z=r.renderOverlay?.(L,{theme:Ke(c)});if(null!=z){const e=T.renderToStaticMarkup((0,Jx.jsx)(Jx.Fragment,{children:z}));$=$.replace("</svg>",e+"</svg>")}return{svg:$,frameType:r.frameType}}async function db(e,t,n={}){const{format:o="png",scale:r=1,background:i}=n;let s,a;s=["xy","ordinal","network","geo","physics"].includes(e)?eb(e,t):cb(e,t),i&&(s=s.replace(/<svg /,`<svg style="background:${i}" `));try{const e="sharp",t=await import(e);a=t.default??t}catch{throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const c=t.width||t.size?.[0]||600,l=t.height||t.size?.[1]||400,u=a(void 0!==globalThis.Buffer?globalThis.Buffer.from(s):(new TextEncoder).encode(s),{density:72*r}).resize(Math.round(c*r),Math.round(l*r));return"jpeg"===o?u.jpeg({quality:90}).toBuffer():u.png().toBuffer()}function hb(e,t={}){const{title:n,subtitle:o,theme:r,width:i=1200,height:s,layout:a={},background:c}=t,l=Ze(Ke(r)),u=a.columns||2,d=a.gap??16;let h=0;n&&(h+=30),o&&(h+=20),h>0&&(h+=10);const f=Math.floor((i-d-d*(u-1))/u),p=[];let y=0,g=h+d,m=0;for(const t of e){const e=Math.min(t.colSpan||1,u),n=t.props.height||300;y+e>u&&(g+=m+d,y=0,m=0),p.push({chart:t,x:d/2+y*(f+d),y:g,w:f*e+d*(e-1),h:n}),m=Math.max(m,n),y+=e}const x=s||g+m+d,b=p.map((e,t)=>{const{chart:n,x:o,y:i,w:s,h:a}=e,c={...n.props,width:s,height:a,theme:r,_idPrefix:"chart-"+t};let l;return l=n.component?cb(n.component,c):n.frameType?eb(n.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"></svg>`,(0,Jx.jsx)("g",{transform:`translate(${o},${i})`,children:(0,Jx.jsx)("foreignObject",{width:s,height:a,children:(0,Jx.jsx)("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:l}})})},"dashboard-chart-"+t)});return T.renderToStaticMarkup((0,Jx.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:x,role:"img","aria-label":n||"Dashboard",style:{fontFamily:l.fontFamily},children:[n&&(0,Jx.jsx)("title",{children:n}),c&&(0,Jx.jsx)("rect",{x:0,y:0,width:i,height:x,fill:c}),n&&(0,Jx.jsx)("text",{x:i/2,y:24,textAnchor:"middle",fontSize:l.titleSize+4,fontWeight:"bold",fill:l.text,fontFamily:l.fontFamily,children:n}),o&&(0,Jx.jsx)("text",{x:i/2,y:n?46:20,textAnchor:"middle",fontSize:l.labelSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:o}),b]}))}var fb=y(require("react-dom/server")),pb=require("react/jsx-runtime");function yb(e,t,n,o={}){const{stepSize:r,windowSize:i,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:d="ease-out",decay:h}=o,f=n.width||600,p=n.height||400,y=Ke(n.theme),g={...n,...a&&{xExtent:a},...c&&{yExtent:c}};if(!t||0===t.length)return[];const m=r||Math.max(1,Math.ceil(t.length/(s||Math.min(60,Math.max(10,t.length))))),x=[];for(let e=m;t.length>=e;e+=m)x.push(e);x[x.length-1]!==t.length&&x.push(t.length);const b=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(e),v=Es({top:20,right:20,bottom:30,left:40,...n.margin},n.title),w=f-v.left-v.right,k=p-v.top-v.bottom,S=[];if(b)for(let o=0;x.length>o;o++){const r=x[o],s=t.slice(i?Math.max(0,r-i):0,r),a={chartType:e,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:n.projection||"vertical",oAccessor:n.oAccessor||n.categoryAccessor||"category",rAccessor:n.rAccessor||n.valueAccessor||"value",colorAccessor:n.colorAccessor||n.colorBy,stackBy:n.stackBy,groupBy:n.groupBy,barPadding:n.barPadding,innerRadius:n.innerRadius,normalize:n.normalize,bins:n.bins,colorScheme:n.colorScheme||y.colors.categorical,...h&&{decay:h}},c=new $g(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:w,height:k}),c.scene.length>0&&S.push(wb(c.scene,f,p,y,g))}else for(let o=0;x.length>o;o++){const r=x[o],s=t.slice(i?Math.max(0,r-i):0,r),m={chartType:e,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:n.colorAccessor||n.colorBy,groupAccessor:n.groupAccessor||n.lineBy,lineDataAccessor:n.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:n.colorScheme||y.colors.categorical,lineStyle:n.lineStyle,pointStyle:n.pointStyle,areaStyle:n.areaStyle,sizeAccessor:n.sizeAccessor||n.sizeBy,sizeRange:n.sizeRange,...h&&{decay:h},...l>0&&{transition:{duration:l*(1e3/u),easing:d}}},b=new no(m);if(b.ingest({inserts:s,bounded:!0}),b.computeScene({width:w,height:k}),0===b.scene.length)continue;const v=b.scales?{y:b.scales.y}:void 0;if(S.push(vb(b.scene,f,p,y,g,v)),l>0&&o>0&&b.activeTransition){const e=l*(1e3/u);for(let t=1;l>=t;t++)b.advanceTransition(b.activeTransition.startTime+t/l*e),S.push(vb(b.scene,f,p,y,g,v))}}return S}function gb(e,t,n={}){return t.map(t=>{try{return cb(e,{...n,...t})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${n.width||t.width||600}" height="${n.height||t.height||400}"></svg>`}})}function mb(e,t,n){const o=t.size??[t.width??600,t.height??400],r=Ke(t.theme),i=Ze(r),s=t.background||r.colors.background,a=t.idPrefix??"physics-gif",c=t.title?`${a}-title-${n}`:void 0,l=t.description?`${a}-desc-${n}`:void 0,u=[c,l].filter(Boolean).join(" ")||void 0,d=Xx(e.readBodies(),{bodyStyle:t.bodyStyle,getBodyLabel:t.getBodyLabel}),h=(0,pb.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className??"stream-physics-frame",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,role:"img","aria-labelledby":u,style:{fontFamily:i.fontFamily},children:[t.title&&(0,pb.jsx)("title",{id:c,children:t.title}),t.description&&(0,pb.jsx)("desc",{id:l,children:t.description}),s&&"transparent"!==s?(0,pb.jsx)("rect",{x:0,y:0,width:o[0],height:o[1],fill:s}):null,(0,pb.jsx)("g",{id:`${a}-frame-${n}`,children:d.map((e,t)=>ga(e,t,`${a}-${n}`))})]});return fb.renderToStaticMarkup(h)}function xb(e,t={}){const{fps:n=12,frameCount:o,durationSeconds:r=2,includeInitialFrame:i=!0,stepDt:s,stepsPerFrame:a,background:c}=t,l=Math.max(.001,s??e.config?.fixedDt??1/120),u=a??Math.max(1,Math.round(1/Math.max(1,n)/l)),d=o??Math.max(1,Math.ceil(r*Math.max(1,n))),h=c?{...e,background:c}:e,f=new Df(e.config);e.initialSpawns?.length&&f.enqueue(e.initialSpawns,e.initialSpawnPacing);const p=[];for(i&&(f.tick(0),p.push(mb(f,h,0)));d>p.length;){for(let e=0;u>e;e+=1)f.tick(l);p.push(mb(f,h,p.length))}return p}function bb(e,t){const n=e.background||t.colors.background;return n&&"transparent"!==n?n:null}function vb(e,t,n,o,r,i){const s=Ze(o),a=Es({top:20,right:20,bottom:30,left:40,...r.margin},r.title),c=t-a.left-a.right,l=n-a.top-a.bottom,u=bb(r,o),d=r.renderMode,h=e.map((e,t)=>bl({node:e,index:t,renderMode:d,fallback:()=>ga(e,t)})).filter(Boolean),f=function(e,t,n,o,r,i){if(!e||0===e.length)return null;const s=Ze(o),a=[];for(let o=0;e.length>o;o++){const c=e[o];if("y-threshold"===c.type&&null!=c.value){let e=null;if(i)e=i(c.value);else if(r){const[t,o]=r,i=o-t;if(0===i)continue;e=n-(c.value-t)/i*n}if(null==e)continue;const l=c.color||s.primary,u=c.labelPosition||"right";a.push((0,pb.jsxs)("g",{children:[(0,pb.jsx)("line",{x1:0,y1:e,x2:t,y2:e,stroke:l,strokeWidth:c.strokeWidth??1.5,strokeDasharray:c.strokeDasharray||"6,4"}),c.label&&(0,pb.jsx)("text",{x:"left"===u?4:"center"===u?t/2:t-4,y:20>e?Math.min(n-4,e+16):e-5,textAnchor:"left"===u?"start":"center"===u?"middle":"end",fontSize:s.tickSize,fill:l,fontFamily:s.fontFamily,children:c.label})]},"ann-"+o))}}return a.length>0?(0,pb.jsx)(pb.Fragment,{children:a}):null}(r.annotations,c,l,o,r.yExtent,i?.y),p="string"==typeof r.title?r.title:void 0,y="string"==typeof r.description?r.description:void 0,g=p?"semiotic-title":void 0,m=y?"semiotic-desc":void 0,x=[g,m].filter(Boolean).join(" ")||void 0;return fb.renderToStaticMarkup((0,pb.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,role:"img","aria-labelledby":x,style:{fontFamily:s.fontFamily},children:[p&&(0,pb.jsx)("title",{id:g,children:p}),y&&(0,pb.jsx)("desc",{id:m,children:y}),u&&(0,pb.jsx)("rect",{x:0,y:0,width:t,height:n,fill:u}),(0,pb.jsxs)("g",{transform:`translate(${a.left},${a.top})`,children:[f,h]}),p&&(0,pb.jsx)("text",{x:t/2,y:Ts,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:p})]}))}function wb(e,t,n,o,r){const i=Ze(o),s=Es({top:20,right:20,bottom:30,left:40,...r.margin},r.title),a="radial"===r.projection,c=a?s.left+(t-s.left-s.right)/2:s.left,l=a?s.top+(n-s.top-s.bottom)/2:s.top,u=bb(r,o),d=r.renderMode,h=e.map((e,t)=>bl({node:e,index:t,renderMode:d,fallback:()=>fa(e,t)})).filter(Boolean),f="string"==typeof r.title?r.title:void 0,p="string"==typeof r.description?r.description:void 0,y=f?"semiotic-title":void 0,g=p?"semiotic-desc":void 0,m=[y,g].filter(Boolean).join(" ")||void 0;return fb.renderToStaticMarkup((0,pb.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,role:"img","aria-labelledby":m,style:{fontFamily:i.fontFamily},children:[f&&(0,pb.jsx)("title",{id:y,children:f}),p&&(0,pb.jsx)("desc",{id:g,children:p}),u&&(0,pb.jsx)("rect",{x:0,y:0,width:t,height:n,fill:u}),(0,pb.jsx)("g",{transform:`translate(${c},${l})`,children:h}),f&&(0,pb.jsx)("text",{x:t/2,y:Ts,textAnchor:"middle",fontSize:i.titleSize,fontWeight:"bold",fill:i.text,fontFamily:i.fontFamily,children:f})]}))}async function kb(e,t,n,o={}){const{fps:r=12,loop:i=!0,scale:s=1,background:a}=o,c=n.width||600,l=n.height||400,u=yb(e,t,a?{...n,background:a}:n,o);if(0===u.length)throw Error("No frames generated — check that data is not empty");return Ab(u,c,l,{fps:r,loop:i,scale:s})}async function Sb(e,t={}){const{fps:n=12,loop:o=!0,scale:r=1}=t,i=e.size??[e.width??600,e.height??400],s=xb(e,t);if(0===s.length)throw Error("No physics frames generated");return Ab(s,i[0],i[1],{fps:n,loop:o,scale:r})}async function Ab(e,t,n,o={}){const{fps:r=12,loop:i=!0,scale:s=1}=o,a=Math.round(t*s),c=Math.round(n*s);let l,u,d,h;try{const e="sharp",t=await import(e);l=t.default??t}catch{throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const e="gifenc",t=await import(e),n=[t,t.default].find(e=>"function"==typeof e?.GIFEncoder&&"function"==typeof e.quantize&&"function"==typeof e.applyPalette);if(!n)throw Error("gifenc did not expose its encoder functions");u=n.GIFEncoder,d=n.quantize,h=n.applyPalette}catch(e){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc',{cause:e})}const f=Math.round(1e3/r),p=u();for(let t=0;e.length>t;t++){const n=e[t],o=await l(Buffer.from(n),{density:72*s}).resize(a,c).ensureAlpha().raw().toBuffer(),r=new Uint8Array(o),u=d(r,256),y=h(r,u);p.writeFrame(y,a,c,{palette:u,delay:f,repeat:i?0:-1})}return p.finish(),Buffer.from(p.bytes())}
|
|
1
|
+
var e,t,n,o,r,i,s=Object.create,a=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,u=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty,h=(e,t,n)=>function(){if(n)throw n[0];try{return e&&(t=(0,e[l(e)[0]])(e=0)),t}catch(e){throw n=[e],e}},f=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},p=(e,t,n,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of l(t))d.call(e,r)||r===n||a(e,r,{get:()=>t[r],enumerable:!(o=c(t,r))||o.enumerable});return e},y=(e,t,n)=>(n=null!=e?s(u(e)):{},p(!t&&e&&e.__esModule?n:a(n,"default",{value:e,enumerable:!0}),e)),g=h({"src/components/stream/brushAccessibility.ts"(){e=y(require("react")),t="Use arrow keys to move the selected range, Shift plus an arrow key to resize it, and Escape to clear it."}}),m={};function x(e,t,n,o){const[r,i]=[Math.min(...t),Math.max(...t)],s=(i-r)/20;let[a,c]=e;if(o)0>n?a=Math.max(r,a-s):c=Math.min(i,c+s);else{const e=c-a;a=Math.max(r,Math.min(i-e,a+n*s)),c=a+e}return[a,c]}function b(e,t){let n=0,o=t.length-1;for(;o>n;){const r=n+o+1>>1;t[r]>e?o=r-1:n=r}return t[n]}function v(e,t){let n=0,o=t.length-1;for(;o>n;){const r=n+o>>1;e>t[r]?n=r+1:o=r}return t[n]}function w({width:s,height:a,totalWidth:c,totalHeight:l,margin:u,dimension:d,scales:h,onBrush:f,binSize:p,snap:y,binBoundaries:g,snapDuring:m,streaming:w}){const k=(0,n.useRef)(null),S=(0,n.useRef)(null),A=(0,n.useRef)(f);A.current=f;const M=(0,n.useRef)(h);M.current=h;const _=(0,n.useMemo)(()=>g?[...g].sort((e,t)=>e-t):void 0,[g]),P=(0,n.useRef)(_);P.current=_;const j=(0,n.useRef)(!1),C=(0,n.useRef)(null),R=function({label:n="Data range brush",description:o=t,onAction:r}={}){const i=e.useId().replace(/:/g,""),s=e.useRef(r);return s.current=r,{description:o,descriptionId:"semiotic-brush-description-"+i,svgProps:{role:"region",tabIndex:0,"aria-label":n,"aria-describedby":"semiotic-brush-description-"+i,onKeyDown:e.useCallback(e=>{const t=function(e){return"Escape"===e.key?{type:"clear"}:"ArrowLeft"===e.key?{type:"nudge",direction:"left",resize:e.shiftKey}:"ArrowRight"===e.key?{type:"nudge",direction:"right",resize:e.shiftKey}:"ArrowUp"===e.key?{type:"nudge",direction:"up",resize:e.shiftKey}:"ArrowDown"===e.key?{type:"nudge",direction:"down",resize:e.shiftKey}:null}(e);t&&(e.preventDefault(),s.current?.(t))},[])}}}({label:"xy"===d?"Two-dimensional data range brush":d.toUpperCase()+" data range brush",onAction:e=>{const t=M.current,n=S.current;if(!t||!n||!k.current)return;const r=(0,o.select)(k.current).select(".brush-g");if("clear"===e.type)return j.current=!0,r.call(n.move,null),j.current=!1,C.current=null,void A.current(null);const i=t.x.domain(),s=t.y.domain(),a=C.current;let c=a?.x??[i[0]+.4*(i[1]-i[0]),i[0]+.6*(i[1]-i[0])],l=a?.y??[s[0]+.4*(s[1]-s[0]),s[0]+.6*(s[1]-s[0])];const u="left"===e.direction||"right"===e.direction,h="left"===e.direction||"down"===e.direction?-1:1;if(u&&"y"!==d&&(c=x(c,i,h,e.resize)),u||"x"===d||(l=x(l,s,h,e.resize)),u&&"y"===d||!u&&"x"===d)return;const f={x:c,y:l};j.current=!0,r.call(n.move,"x"===d?[t.x(c[0]),t.x(c[1])]:"y"===d?[t.y(l[1]),t.y(l[0])]:[[t.x(c[0]),t.y(l[1])],[t.x(c[1]),t.y(l[0])]]),j.current=!1,C.current=f,A.current(f)}});return(0,n.useEffect)(()=>{if(!k.current)return;const e=(0,o.select)(k.current).select(".brush-g"),t="x"===d?(0,r.brushX)():"y"===d?(0,r.brushY)():(0,r.brush)();return t.extent([[0,0],[s,a]]),t.on("brush end",n=>{if(j.current)return;const o=M.current;if(!o)return;if(!n.selection)return C.current=null,void A.current(null);let r,i;if("x"===d){const[e,t]=n.selection;r=[o.x.invert(e),o.x.invert(t)],i=[o.y.invert(a),o.y.invert(0)]}else if("y"===d){const[e,t]=n.selection;r=[o.x.invert(0),o.x.invert(s)],i=[o.y.invert(t),o.y.invert(e)]}else{const[[e,t],[s,a]]=n.selection;r=[o.x.invert(e),o.x.invert(s)],i=[o.y.invert(a),o.y.invert(t)]}if("bin"===y&&"y"!==d&&("end"===n.type||"brush"===n.type&&m)){const i=P.current;i&&i.length>0?r=function(e,t){return 0===t.length?e:[b(e[0],t),v(e[1],t)]}(r,i):p&&p>0&&(r=[Math.floor(r[0]/p)*p,Math.ceil(r[1]/p)*p]);const s=o.x(r[0]),a=o.x(r[1]);if(j.current=!0,"x"===d)e.call(t.move,[s,a]);else if("xy"===d){const o=n.selection;e.call(t.move,[[s,o[0][1]],[a,o[1][1]]])}j.current=!1}const c={x:r,y:i};C.current=c,A.current(c)}),e.call(t),S.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null),S.current=null}},[s,a,d,y,p,m]),(0,n.useEffect)(()=>{if(!(w&&h&&S.current&&C.current))return;if(!k.current)return;if("y"===d)return;const e=C.current,t=h.x.domain()[0],n=(0,o.select)(k.current).select(".brush-g");if(t>=e.x[1])return j.current=!0,n.call(S.current.move,null),j.current=!1,C.current=null,void A.current(null);let r=e.x[0],i=!1;if(t>e.x[0]){if(r=t,"bin"===y){const e=P.current;e&&e.length>0?r=v(t,e):p&&p>0&&(r=Math.ceil(t/p)*p)}if(r>=e.x[1])return j.current=!0,n.call(S.current.move,null),j.current=!1,C.current=null,void A.current(null);i=!0}const s=h.x(r),a=h.x(e.x[1]);if(j.current=!0,"x"===d)n.call(S.current.move,[s,a]);else{const t=h.y(e.y[1]),o=h.y(e.y[0]);n.call(S.current.move,[[s,t],[a,o]])}if(j.current=!1,i){const t={x:[r,e.x[1]],y:e.y};C.current=t,A.current(t)}},[h,w,d,y,p]),(0,i.jsxs)("svg",{ref:k,width:c,height:l,...R.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:[(0,i.jsx)("title",{children:R.svgProps["aria-label"]}),(0,i.jsx)("desc",{id:R.descriptionId,children:R.description}),(0,i.jsx)("g",{className:"brush-g",transform:`translate(${u.left},${u.top})`})]})}f(m,{XYBrushOverlay:()=>w});var k,S=h({"src/components/stream/XYBrushOverlay.tsx"(){n=require("react"),o=require("d3-selection"),r=require("d3-brush"),g(),i=require("react/jsx-runtime")}}),A={};function M(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}f(A,{generateFrameSVGs:()=>Cb,generateFrameSequence:()=>Rb,generatePhysicsFrameSVGs:()=>Ib,renderChart:()=>kb,renderChartWithEvidence:()=>Sb,renderDashboard:()=>_b,renderGeoToStaticSVG:()=>xb,renderNetworkToStaticSVG:()=>mb,renderOrdinalToStaticSVG:()=>gb,renderPhysicsToAnimatedGif:()=>Eb,renderToAnimatedGif:()=>Db,renderToImage:()=>Mb,renderToStaticSVG:()=>pb,renderXYToStaticSVG:()=>yb,resolveTheme:()=>Je,themeStyles:()=>et}),module.exports=(k=A,p(a({},"__esModule",{value:!0}),k));var _=44,P={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:_,snap:"nearestDatum",brushHandleSize:_,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function j(e,t={}){const n=t.mobileSemantics?.interaction,o="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,r="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,i=!!n||void 0!==o,s=e&&"object"==typeof e?e:void 0;if(!1===e||!1===s?.enabled||void 0===e&&!r&&!i)return P;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??o??_,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??_,standardControls:a.standardControls??!1}}var C={primary:{width:600,height:400,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:void 0,showLabels:void 0,marginDefaults:{top:50,bottom:60,left:70,right:40}},context:{width:400,height:250,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:10,bottom:10,left:10,right:10}},sparkline:{width:120,height:24,showAxes:!1,showGrid:!1,enableHover:!1,showLegend:!1,showLabels:!1,marginDefaults:{top:2,bottom:2,left:0,right:0}},mobile:{width:390,height:300,showAxes:!0,showGrid:!1,enableHover:!0,showLegend:!1,showLabels:!0,marginDefaults:{top:28,bottom:42,left:44,right:16}}};function R(e,t,n){const o=C[e||"primary"],r=e&&"primary"!==e||!n?.width?o.width:n.width,i=e&&"primary"!==e||!n?.height?o.height:n.height,s=function(e,t,n=e.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:e,matches:[]};const o=n.map((e,t)=>({rule:e,index:t})).filter(e=>function(e,t){const{when:n}=e,o=t.width,r=t.height,i=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),s=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof n.minWidth&&n.minWidth>o||"number"==typeof n.maxWidth&&o>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof r||n.minHeight>r)||"number"==typeof n.maxHeight&&("number"!=typeof r||r>n.maxHeight)||"number"==typeof n.minAspectRatio&&("number"!=typeof i||n.minAspectRatio>i)||"number"==typeof n.maxAspectRatio&&("number"!=typeof i||i>n.maxAspectRatio)||n.orientation&&s!==n.orientation)}(e.rule,t)).sort((e,t)=>("number"==typeof e.rule.priority?e.rule.priority:e.index)-("number"==typeof t.rule.priority?t.rule.priority:t.index));return{props:o.reduce((e,t)=>function(e,t){const n={...e,...t};for(const o of["margin","frameProps","mobileSemantics","style"])M(e[o])&&M(t[o])&&(n[o]={...e[o],...t[o]});return"string"==typeof e.className&&"string"==typeof t.className&&(n.className=`${e.className} ${t.className}`),n}(e,t.rule.transform),e),matches:o}}({...t,mode:e},{width:t.width??r,height:t.height??i}).props,a=s.mode||e||"primary",c=C[a],l="context"===a||"sparkline"===a,u="primary"===a&&n?.width?n.width:c.width;return{mode:a,width:s.width??u,height:s.height??("primary"===a&&n?.height?n.height:c.height),showAxes:s.showAxes??c.showAxes,showGrid:s.showGrid??c.showGrid,enableHover:s.enableHover??(!!s.linkedHover||c.enableHover),showLegend:s.showLegend??c.showLegend,showLabels:s.showLabels??c.showLabels,title:l?void 0:s.title,description:s.description,summary:s.summary,accessibleTable:s.accessibleTable,xLabel:l?void 0:s.xLabel,yLabel:l?void 0:s.yLabel,categoryLabel:l?void 0:s.categoryLabel,valueLabel:l?void 0:s.valueLabel,marginDefaults:L(c.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:l,mobileInteraction:j(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}function L(e,t,n){if(!1!==t)return e;const o={...e};return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}function I(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}var T=y(require("react-dom/server")),$=y(require("react")),z=Object.freeze([]);function D(e){if(!e)return z;let t=!1;for(let n=0;e.length>n;n++){const o=e[n];if(null==o||"object"!=typeof o){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}var E=require("d3-scale");function O(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function F(e,t,n){const o=e=>e.toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}`}function B(e){const t=e.map(O),n=t.length-1;return e=>{if(0>=e){const[e,n,o]=t[0];return F(e,n,o)}if(e>=1){const[e,o,r]=t[n];return F(e,o,r)}const o=e*n,r=Math.floor(o),i=o-r,[s,a,c]=t[r],[l,u,d]=t[r+1];return F(Math.round(s+(l-s)*i),Math.round(a+(u-a)*i),Math.round(c+(d-c)*i))}}var N=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],W=B(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),q=B(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),Y=B(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),G=B(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),H=B(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),V=B(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),X=B(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),U=B(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),K=B(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),Z=B(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),Q=B(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),J=B(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),ee={blues:W,reds:q,greens:Y,viridis:X,oranges:G,purples:H,greys:V,plasma:U,inferno:K,magma:Z,cividis:Q,turbo:J};function te(e){return e&&ee[e]||W}var ne=B(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),oe=B(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),re=B(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),ie=B(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),se=B(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),ae=B(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),ce=B(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),le={category10:N,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...ee},ue=N,de="#007bff";function he(e,t,n=ue){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=Object.values(e).filter(e=>"string"==typeof e&&e.length>0);if(t.length>0)return t}if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=le[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}var fe=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],pe=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],ye=new Set(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","transparent","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]);function ge(e,t,n){if("function"==typeof t){const o=t(e);return n&&o&&"string"==typeof o&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||ye.has(t)}(o)?n(o):o}const o=e?.[t]+"";return n?n(o):ue[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o))%ue.length]}function me(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;const n=e[t];return"string"==typeof n&&n.length>0?n:void 0}function xe(e,t,n="category10"){if(n&&"object"==typeof n&&!Array.isArray(n)){const e=n;return t=>me(e,t)??"#999"}const o=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>e+""))),r=o.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return(0,E.scaleOrdinal)().domain(o).range(n).unknown("#999");const i=le[n]||le.category10;if(r&&"function"==typeof i){let e=-1/0;for(const t of o){const n=Number(t);n>e&&(e=n)}return t=>i(Number(t)/e)}{const e=Array.isArray(i)?i:ue;return(0,E.scaleOrdinal)().domain(o).range(e).unknown("#999")}}function be(e,t,n=[3,20],o){let r;if(r="function"==typeof t?t(e):e?.[t],!o)return r;const[i,s]=o,[a,c]=n;if(s===i)return(a+c)/2;let l=(r-i)/(s-i);return 0>l?l=0:l>1&&(l=1),a+l*(c-a)}function ve(e){let t=1/0,n=-1/0;for(const o of e)t>o&&(t=o),o>n&&(n=o);return[t,n]}function we(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}function ke(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}function Se(e,t){if(!ke(t))return e??((...e)=>({}));const n={};return void 0!==t.stroke&&(n.stroke=t.stroke),void 0!==t.strokeWidth&&(n.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(n.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...n}):(...e)=>({...n})}function Ae(e){if(null==e)return()=>{};const t="function"==typeof e?e:t=>t[e];return e=>Pe(t(e))}function Me(e,t){const n=Ae(e),o=Ae(t);return(e,t)=>{const r=o(e);return{value:r,x:n(e),y:r,category:t}}}function _e(e,t){const n=Ae(t??"value"),o=null==e?void 0:"function"==typeof e?e:t=>t[e];return e=>{const t=o?o(e):void 0;return{value:n(e),category:null==t?void 0:t+""}}}function Pe(e){if("number"==typeof e)return Number.isFinite(e)?e:void 0;if("string"==typeof e&&""!==e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}function je(e,t,n){const o=e.when;return void 0===o||!0===o||!1!==o&&("function"==typeof o?o(t,n):function(e,t,n){const o=null!=e.axis?n[e.axis]:null!=e.field?t[e.field]:n.value;if(void 0!==e.eq&&o!==e.eq)return!1;if(void 0!==e.ne&&o===e.ne)return!1;if(void 0!==e.in&&!e.in.includes(o))return!1;if(void 0===e.gt&&void 0===e.gte&&void 0===e.lt&&void 0===e.lte&&void 0===e.within&&void 0===e.outside)return!0;const r=Pe(o);if(void 0===r)return!1;if(void 0!==e.gt&&e.gt>=r)return!1;if(void 0!==e.gte&&e.gte>r)return!1;if(void 0!==e.lt&&r>=e.lt)return!1;if(void 0!==e.lte&&r>e.lte)return!1;if(void 0!==e.within){const[t,n]=e.within;if(t>r||r>n)return!1}if(void 0!==e.outside){const[t,n]=e.outside;if(r>=t&&n>=r)return!1}return!0}(o,t,n))}function Ce(e,t,n){if(!t||0===t.length)return{};let o={};for(const r of t){if(!je(r,e,n))continue;const t="function"==typeof r.style?r.style(e,n):r.style;t&&(o={...o,...t})}return o}function Re(e,t,n,o=e=>e){const r=e??(()=>({}));return t&&0!==t.length?(e,i)=>{const s=o(e),a={...r(e,i)};return Object.assign(a,Ce(s,t,n(s,i))),a}:r}function Le(e,t,n,o){if(!e||0===e.length)return o;const r=_e(t,n);return(t,n)=>{const i=t&&t.data||t,s=Ce(i,e,r(i)),a=o?o(t,n):void 0;return a?{...s,...a}:s}}var Ie={stops:[{offset:0,opacity:.8},{offset:1,opacity:.05}]};function Te(e,t=Ie){if(e)return!0===e?t:"stops"in e?Array.isArray(e.stops)?e:void 0:"colorStops"in e?Array.isArray(e.colorStops)?{stops:e.colorStops.map(({offset:e,color:t})=>({offset:e,color:t}))}:void 0:{stops:[{offset:0,opacity:e.topOpacity??t.stops[0]?.opacity??.8},{offset:1,opacity:e.bottomOpacity??t.stops.at(-1)?.opacity??.05}]}}function $e(e){return e?Te(e):void 0}function ze(e,t,n){return"function"==typeof e?e(n):n[e||t]}function De(e){return e instanceof Date?e.getTime():Number(e)}function Ee(e,t){return X(1===t?.5:e/(t-1))}function Oe(e){const t={};return void 0!==e.stroke&&(t.stroke=e.stroke),void 0!==e.strokeWidth&&(t.strokeWidth=e.strokeWidth),void 0!==e.opacity&&(t.opacity=e.opacity),t}var Fe=require("react"),Be=require("react/jsx-runtime");function Ne(e){let t=null;const n=()=>(t||(t=(0,Fe.createContext)(null)),t),o=We(e);return[function({children:t,initialState:o}){const r=(0,Fe.useRef)(o),i=(0,Fe.useMemo)(()=>We(e,r.current),[]),s=n();return(0,Be.jsx)(s.Provider,{value:i,children:t})},(e,t)=>{const r=n(),i=(0,Fe.useContext)(r)??o,s=(0,Fe.useRef)(e);s.current=e;const a=(0,Fe.useRef)({hasValue:!1,value:void 0}),c=(0,Fe.useCallback)(()=>{const e=s.current(i.getState()),n=a.current;return n.hasValue&&t&&t(n.value,e)?n.value:(a.current={hasValue:!0,value:e},e)},[i,t]),l=(0,Fe.useCallback)(()=>s.current(i.getState()),[i]);return(0,Fe.useSyncExternalStore)(i.subscribe,c,l)}]}function We(e,t){const n=new Set;let o={...e(function(e){const t=e(o);if(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}(t)){o={...o,...t};for(const e of n)e()}}),...t??{}};return{getState:()=>o,subscribe:function(e){return n.add(e),()=>{n.delete(e)}}}}function qe(e){if(!e?.colors)return;const t=e.colors;return{primary:t.primary,secondary:t.secondary||t.primary,surface:t.surface||t.background,success:t.success,danger:t.danger,warning:t.warning,error:t.error,info:t.info,text:t.text,textSecondary:t.textSecondary,border:t.border,grid:t.grid}}function Ye(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:Ge}}),e.accessibility.highContrast){const e="dark"===t.mode;t={...t,colors:{...t.colors,text:e?"#ffffff":"#000000",textSecondary:e?"#cccccc":"#333333",grid:e?"#666666":"#999999",border:e?"#888888":"#000000"}}}return t}var Ge=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],He={mode:"light",colors:{primary:"#00a2ce",secondary:"#6c757d",categorical:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],sequential:"blues",diverging:"RdBu",background:"transparent",surface:"#ffffff",text:"#333",textSecondary:"#666",grid:"#e0e0e0",border:"#ccc",selection:"#00a2ce",selectionOpacity:.15,success:"#2ca02c",danger:"#d62728",warning:"#f0ad4e",error:"#b4181b",info:"#00a2ce"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},Ve={mode:"dark",colors:{primary:"#4fc3f7",secondary:"#90a4ae",categorical:["#4fc3f7","#ffb74d","#81c784","#ef5350","#ba68c8","#a1887f","#f06292","#90a4ae","#dce775","#4dd0e1"],sequential:"blues",diverging:"RdBu",background:"#1a1a2e",surface:"#252540",text:"#e0e0e0",textSecondary:"#aaa",grid:"#333",border:"#555",selection:"#4fc3f7",selectionOpacity:.15,success:"#81c784",danger:"#ef5350",warning:"#ffb74d",error:"#d84848",info:"#4fc3f7"},typography:{fontFamily:"sans-serif",titleSize:16,labelSize:12,tickSize:12}},Xe={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:Ge,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function Ue(e,t){if("light"===t)return He;if("dark"===t)return Ve;if("high-contrast"===t)return Xe;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?Ve:He;return Ye({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return Ye({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[Ke,Ze]=Ne(e=>({theme:He,setTheme(t){e(e=>({theme:Ue(e.theme,t)}))}})),Qe={light:He,dark:Ve,"high-contrast":Xe,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#7a644a",grid:"#e8d5c4",border:"#e8d5c4",focus:"#8a5fae",annotation:"#8a5fae",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#64717f",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#d06a6a",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#c63b3b",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#7a47e8",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function Je(e){if(!e)return He;if("string"==typeof e){if("light"===e)return He;if("dark"===e)return Ve;if("high-contrast"===e)return Xe;return Qe[e]||He}const t="dark"===e.mode?Ve:He;return Ye({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}},tooltip:{...t.tooltip,...e.tooltip||{}}})}function et(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 tt(e,t,n){const o="function"==typeof t?t(e):e[t??n];if(null==o)return null;if(o instanceof Date)return o.getTime();if("string"==typeof o&&""===o.trim())return null;const r=Number(o);return Number.isFinite(r)?r:null}var nt="__forecastSegment",ot="__forecastOpacity";function rt(e,t,n,o){const r=t.uncertaintyOpacity,i=t.confidenceAccessor;if(!r&&!i)return;const s="object"==typeof r?r:{},a=s.min??.15,c=s.max??1;if(i){const t="function"==typeof i?i:e=>e[i];for(const n of e){const e=t(n);null!=e&&Number.isFinite(e)&&(n[ot]=a+Math.max(0,Math.min(1,e))*(c-a))}return}const l=e.map(e=>{const t=n(e),r=o(e);return null!=t&&null!=r&&Number.isFinite(t)&&Number.isFinite(r)?Math.abs(t-r):NaN}),u=l.filter(e=>Number.isFinite(e));if(0===u.length)return;const[d,h]=ve(u),f=h-d;e.forEach((e,t)=>{const n=l[t];Number.isFinite(n)&&(e[ot]=c-(f>0?(n-d)/f:0)*(c-a))})}function it(e,t){return"function"==typeof t?t(e):!!e[t]}var st="__semiotic_resolvedX",at="__semiotic_resolvedY",ct="__compoundGroup";function lt(e,t,n){const o=e[t],r=e[n];return null==o||null==r||Number.isNaN(o)||Number.isNaN(r)}function ut(e){const t=e.xAccessor||"x",n=e.yAccessor||"y",o=e.lineBy,r=e.colorBy||o;let i=Array.isArray(e.data)?D(e.data).filter(e=>!!e&&"object"==typeof e):[];const s=function(e,t,n){const o="function"==typeof t,r="function"==typeof n,i=o?st:t,s=r?at:n;return o||r?{xKey:i,yKey:s,rows:e.map(e=>{const i={...e};return o&&(i[st]=t(e)),r&&(i[at]=n(e)),i})}:{rows:e,xKey:i,yKey:s}}(i,t,n);i=s.rows;const a=s.xKey,c=s.yKey,l=Array.isArray(e.annotations)?[...e.annotations]:[];let u,d="string"==typeof o||"function"==typeof o?o:void 0,h=e.baseLineStyle;if(e.forecast){const t=function(e,t,n,o,r){return(i=o).isTraining||i.isForecast||i.isAnomaly||i.upperBounds||i.lowerBounds?function(e,t,n,o,r){const{isTraining:i,isForecast:s,isAnomaly:a,upperBounds:c,lowerBounds:l,color:u="#6366f1",bandOpacity:d=.15,anomalyColor:h="#ef4444",anomalyRadius:f=6,label:p}=o,y=e.map(e=>{let t="observed";return s&&it(e,s)?t="forecast":i&&it(e,i)&&(t="training"),{...e,[nt]:t}}),g=o._groupBy,m=[];if(g){const e=new Map;for(const t of y){const n=t[g]??"__default";e.has(n)||e.set(n,[]),e.get(n).push(t)}const t=[];for(const[,n]of e)for(let e=0;n.length-1>e;e++)n[e][nt]!==n[e+1][nt]&&(t.push({...n[e+1],[nt]:n[e][nt]}),t.push({...n[e],[nt]:n[e+1][nt]}));m.push(...y,...t)}else for(let e=0;y.length>e;e++)m.push(y[e]),y.length-1>e&&y[e][nt]!==y[e+1][nt]&&(m.push({...y[e+1],[nt]:y[e][nt]}),m.push({...y[e],[nt]:y[e+1][nt]}));if(o.trainUnderline){const e=[];for(const t of m)"training"===t[nt]&&e.push({...t,[nt]:"training-base"});m.unshift(...e)}const x=[];if(c&&l){const e="string"==typeof c?c:"__envUpper",t="string"==typeof l?l:"__envLower";if("function"==typeof c||"function"==typeof l)for(const n of m)"function"==typeof c&&(n[e]=c(n)),"function"==typeof l&&(n[t]=l(n));x.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:u,fillOpacity:d,label:p})}if(o.uncertaintyOpacity||o.confidenceAccessor){const e=c?"function"==typeof c?c:e=>e[c]:()=>{},t=l?"function"==typeof l?l:e=>e[l]:()=>{};rt(m.filter(e=>"forecast"===e[nt]),o,e,t)}if(a){const e=o.anomalyStyle,t={type:"highlight",filter:e=>it(e,a)};e?(t.style=e,t.r=f):"function"==typeof h?(t.style=e=>{const t=h(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=f):(t.color=h,t.r=f,t.style={stroke:h,strokeWidth:1.5,fill:h,fillOpacity:.7}),x.push(t)}return r&&x.push({type:"anomaly-band",threshold:r.threshold??2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:r.bandOpacity??.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:r.anomalyRadius??6,label:r.label}),{processedData:m,annotations:x}}(e,0,0,o,r):function(e,t,n,o,r){const{trainEnd:i,steps:s=10,confidence:a=.95,color:c="#6366f1",bandOpacity:l=.15,label:u}=o;if(null==i)return{processedData:e,annotations:[]};const d=[],h=[];for(const n of e)n[t]>i?h.push({...n,[nt]:"observed"}):d.push({...n,[nt]:"training"});const f=d.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),p=[],y=[];if(f.length>=3){const r=f.length;let i=0,d=0,h=0,g=0;for(const[e,t]of f)i+=e,d+=t,h+=e*e,g+=e*t;const m=r*h-i*i;if(Math.abs(m)>1e-12){const h=(r*g-i*d)/m,x=(d-h*i)/r,b=e=>x+h*e,v=f.map(([e,t])=>t-b(e)).reduce((e,t)=>e+t*t,0),w=Math.sqrt(v/Math.max(r-2,1)),k=f.reduce((e,t)=>e+t[0],0)/r,S=f.reduce((e,t)=>e+(t[0]-k)**2,0),A=.99>a?.95>a?.9>a?1:1.645:1.96:2.576,M=we(e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e))),_=f.length>1?(f[r-1][0]-f[0][0])/(r-1):1;for(let e=1;s>=e;e++){const o=M+e*_,i=b(o),s=w*Math.sqrt(1+1/r+(S>0?(o-k)**2/S:0))*A;y.push({[t]:o,[n]:i,[nt]:"forecast",__forecastUpper:i+s,__forecastLower:i-s})}rt(y,o,e=>e.__forecastUpper,e=>e.__forecastLower),p.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:c,fillOpacity:l,label:u})}}p.push({type:"x-threshold",x:i,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),r&&p.push({type:"anomaly-band",threshold:r.threshold??2,showBand:!1!==r.showBand,fill:r.bandColor||"#6366f1",fillOpacity:r.bandOpacity??.1,anomalyColor:r.anomalyColor||"#ef4444",anomalyRadius:r.anomalyRadius??6,label:r.label});const g=[];if(g.push(...d),d.length>0&&h.length>0&&g.push({...d[d.length-1],[nt]:"observed"}),g.push(...h),y.length>0){const e=h.length>0?h[h.length-1]:d[d.length-1];e&&g.push({...e,[nt]:"forecast"}),g.push(...y)}return{processedData:g,annotations:p}}(e,t,n,o,r);var i}(i,a,c,o&&"string"==typeof o&&"object"==typeof e.forecast?{...e.forecast,_groupBy:o}:e.forecast,e.anomaly);if(i=t.processedData,l.push(...t.annotations),u=function(e,t,n){const o=n.upperBounds,r=n.lowerBounds;if(!o&&!r)return;const i="function"==typeof o?o:"string"==typeof o?e=>e[o]:null,s="function"==typeof r?r:"string"==typeof r?e=>e[r]:null;let a=1/0,c=-1/0;for(const n of e){const e=Number(n[t]);if(Number.isFinite(e)&&(a>e&&(a=e),e>c&&(c=e)),i){const e=i(n);null!=e&&Number.isFinite(e)&&(e>c&&(c=e),a>e&&(a=e))}if(s){const e=s(n);null!=e&&Number.isFinite(e)&&(a>e&&(a=e),e>c&&(c=e))}}return Number.isFinite(a)&&Number.isFinite(c)?[a,c]:void 0}(i,c,e.forecast),o&&"string"==typeof o?(i=i.map(e=>({...e,[ct]:`${e[o]}__${e[nt]||"observed"}`})),d=ct):d=nt,e.baseLineStyle){const t=function(e,t){const n=t.trainDasharray??"8,4",o=t.forecastDasharray??"4,4",r=t.color||"#6366f1",i=t.trainOpacity,s=t.forecastOpacity,a=t.trainStroke,c=t.trainLinecap,l=t.trainUnderline;return t=>{const u=e(t),d=t[nt];if("training"===d){let e=u.stroke;return"darken"===a?e=function(e,t=.5){const n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!n)return e;const o=Math.round(parseInt(n[1],16)*(1-t)),r=Math.round(parseInt(n[2],16)*(1-t)),i=Math.round(parseInt(n[3],16)*(1-t));return`#${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}(u.stroke||"#666",.5):a&&(e=a),{...u,stroke:e,strokeDasharray:n,...c&&{strokeLinecap:c},...null!=i&&{strokeOpacity:i}}}if("training-base"===d){let e=u.stroke||"#666";return"lighten"===l&&(e=function(e,t=.5){const n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!n)return e;const o=Math.round(parseInt(n[1],16)+(255-parseInt(n[1],16))*t),r=Math.round(parseInt(n[2],16)+(255-parseInt(n[2],16))*t),i=Math.round(parseInt(n[3],16)+(255-parseInt(n[3],16))*t);return`#${o.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}(e,.4)),{...u,stroke:e,strokeDasharray:void 0}}if("forecast"===d){const e=t[ot],n=null!=e?e:s;return{...u,stroke:r,strokeDasharray:o,...null!=n&&{strokeOpacity:n}}}return u}}(t=>e.baseLineStyle(t),e.forecast);h=e=>t(e)}}else e.anomaly&&l.push(...(f=e.anomaly,[{type:"anomaly-band",threshold:f.threshold??2,showBand:!1!==f.showBand,fill:f.bandColor||"#6366f1",fillOpacity:f.bandOpacity??.1,anomalyColor:f.anomalyColor||"#ef4444",anomalyRadius:f.anomalyRadius??6,label:f.label}]));var f;if(e.gapStrategy){if("function"==typeof d){const e=d;i=i.map(t=>({...t,__semiotic_gapGroup:e(t)})),d="__semiotic_gapGroup"}const t=function(e,t,n,o,r){const i=new Map;for(const t of e){const e=r?(t[r]??"")+"":"__single";i.has(e)||i.set(e,[]),i.get(e).push(t)}if("interpolate"===t){const e=[];for(const[,t]of i)for(const r of t)lt(r,n,o)||e.push(r);return{rows:e,groupKey:r}}if("zero"===t){const e=[];for(const[,t]of i)for(const r of t)lt(r,n,o)?e.push({...r,[o]:0}):e.push(r);return{rows:e,groupKey:r}}const s=[],a="_gapSegment";for(const[e,t]of i){let r=0,i=[];const c=()=>{if(0===i.length)return;const t="__single"===e?"__seg"+r:`${e}__seg${r}`;for(const e of i)s.push({...e,[a]:t});i=[],r++};for(const e of t)lt(e,n,o)?c():i.push(e);c()}return{rows:s,groupKey:a}}(i,e.gapStrategy,a,c,"string"==typeof d?d:void 0);i=t.rows,t.groupKey&&(d=t.groupKey)}let p;if(e.directLabel){const t=function(e,t,n,o,r,i,s,a){if(!t||!n)return{annotations:[]};const c="object"==typeof t?t:{},l=c.position||"end",u=c.fontSize||11,d="function"==typeof n?n:e=>e[n],h=new Map;for(const t of e){const e=d(t);if(null==e)continue;const n=e+"";""!==n&&(h.has(n)||h.set(n,[]),h.get(n).push(t))}const f=new Map;for(const[e,t]of h)t.sort((e,t)=>Number(e[o])-Number(t[o])),f.set(e,"end"===l?t[t.length-1]:t[0]);const p=xe(Array.from(f.entries()).map(([e])=>({__lbl:e})),"__lbl",i??s),y=Array.from(f.entries()).map(([e,t])=>({type:"text",label:e,[o]:t[o],[r]:t[r],dx:"end"===l?6:-6,dy:0,color:p?ge({__lbl:e},"__lbl",p):a||de,fontSize:u}));y.sort((e,t)=>Number(e[r])-Number(t[r]));for(let e=1;y.length>e;e++){const t=y[e-1],n=y[e],o=Number(t[r])+t.dy;u+2>Math.abs(Number(n[r])+n.dy-o)&&(n.dy+=u+2)}const g=y.reduce((e,t)=>Math.max(e,(t.label+"").length*(.6*u)),0)+10;return{annotations:y,marginExtra:"end"===l?{right:g}:{left:g}}}(i,e.directLabel,"string"==typeof r||"function"==typeof r?r:void 0,a,c,e.colorScheme,e.themeCategorical,e.color);l.push(...t.annotations),p=t.marginExtra}return{data:i,xAccessor:"function"==typeof t?a:t,yAccessor:"function"==typeof n?c:n,groupAccessor:d,colorAccessor:r,annotations:l,lineStyle:h,yExtent:u,marginExtra:p}}var dt=require("react"),ht=y(require("react")),ft=require("react/jsx-runtime"),pt={isActive:!1,predicate:()=>!0},yt=ht.createContext(null);function gt({value:e,children:t}){return(0,ft.jsx)(yt.Provider,{value:e,children:t})}function mt(e,t){return null!=e?(0,ft.jsx)(gt,{value:t,children:e}):e}var xt=require("react"),bt=y(require("react")),vt=require("react"),wt=y(require("react")),kt=require("react/jsx-runtime"),St=null,At=null;function Mt(e){const[t,n]=wt.useState(()=>St);return wt.useEffect(()=>{if(t)return;let e=!1;return(St?Promise.resolve(St):(At||(At=Promise.resolve().then(()=>(S(),m)).then(e=>St=e.XYBrushOverlay).catch(e=>{throw At=null,e})),At)).then(t=>{e||n(()=>t)}),()=>{e=!0}},[t]),t?(0,kt.jsx)(t,{...e}):null}var _t=class{constructor(e,t){this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=t?.chunkThreshold??5e3,this.chunkSize=t?.chunkSize??5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(e=D(e),this.lastBoundedData===e)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(e){if(e=D(e),this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:e.length});let t=this.chunkSize;const n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){null!=e&&"object"==typeof e&&(this.pushBuffer.push(e),this.scheduleFlush())}pushMany(e){if(0===e.length)return;let t=0;for(let n=0;e.length>n;n++){const o=e[n];null!=o&&"object"==typeof o&&(this.pushBuffer.push(o),t++)}0!==t&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}},Pt=class{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;return{next:()=>this._size>e?{done:!1,value:this.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray();let n=0,o=[];t.length>e&&(n=t.length-e,o=t.slice(0,n)),this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(let e=n;t.length>e;e++)this.push(t[e]);return o}update(e,t){const n=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const i=(o+r)%this._capacity,s=this.buffer[i];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},n.push(e),this.buffer[i]=t(s)}}return n}remove(e){const t=[],n=[];if(this.forEach(o=>{e(o)?n.push(o):t.push(o)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}},jt=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}};function Ct(e,t){return e===t}function Rt(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function Lt(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function It(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}var Tt=/^\d{4}-\d{1,2}$/;function $t(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const n=Tt.test(t)?t+"-01":t;if(n===t&&10>t.length)return NaN;const o=Date.parse(n);return Number.isFinite(o)?o:NaN}function zt(e){return e instanceof Date?e.getTime():"string"==typeof e?$t(e):+e}function Dt(e){return new Set(Array.isArray(e)?e:[e])}function Et(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function Ot(e,t){return Math.min((e-t.startTime)/t.duration,1)}function Ft(e,t,n){return e+(t-e)*n}function Bt(){return"undefined"!=typeof performance?performance.now():Date.now()}function Nt(e,t,n){if(1>=n)return 1;const o=n-1;return function(e){const t=Math.max(0,Math.min(1,e.minOpacity??.1));if(Number.isNaN(e.age))return 1;if(e.age===1/0)return t;if(!Number.isFinite(e.extent)||0>=e.extent)return 1;const n=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>n?1:t;if("exponential"===e.type){const o=e.halfLife??e.extent/2;return t+Math.pow(.5,n/(o>0?o:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-n/e.extent))*(1-t)}({age:o-t,extent:o,type:e.type,halfLife:e.halfLife??n/2,threshold:e.stepThreshold??.5*n,minOpacity:e.minOpacity??.1})}function Wt(e){const t=new Map;for(let n=0;e.length>n;n++)t.set(e[n],n);return t}function qt(e,t,n){const o=e.duration??500,r=n-t;return o>r?1-r/o:0}function Yt(e,t,n,o){let r=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,r=!0),e._pulseColor!==n&&(e._pulseColor=n,r=!0),e._pulseGlowRadius!==o&&(e._pulseGlowRadius=o,r=!0),r):(0!==e._pulseIntensity&&(e._pulseIntensity=0,r=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,r=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,r=!0),r)}function Gt(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;const o=e.duration??500,r=t.peek();return null!=r&&o>n-r}function Ht(e,t,n){if(t._transitionKey)return t._transitionKey;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const n=e.getX(t.datum),o=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${o}`;if(null!=n&&null!=o)return`p:${n}:${o}`}return"p:"+n;case"glyph":return t.pointId?"g:"+t.pointId:"g:"+n;case"rect":return`r:${t.group||""}:${t.datum?.binStart??t.datum?.category??n}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+n:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function Vt(e,t,n,o,r,i){const s=[];for(const r of e){const e=n(r),i=o(r);Number.isFinite(e)&&Number.isFinite(i)&&s.push({px:t.x(e),py:t.y(i),rawY:i,d:r})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],c[e]=t.rawY,l[e]=t.d}return{type:"line",path:a,rawValues:c,style:r,datum:l,group:i}}function Xt(e,t,n,o,r,i,s,a){const c=[];for(const i of e){const e=n(i),s=o(i);if(!Number.isFinite(e)||!Number.isFinite(s))continue;const l=t.x(e),u=a?a(i):r;c.push({px:l,topY:t.y(s),botY:t.y(u),rawY:s})}c.sort((e,t)=>e.px-t.px);const l=Array(c.length),u=Array(c.length),d=Array(c.length);for(let e=0;c.length>e;e++){const t=c[e];l[e]=[t.px,t.topY],u[e]=[t.px,t.botY],d[e]=t.rawY}return{type:"area",topPath:l,bottomPath:u,rawValues:d,style:i,datum:e,group:s}}function Ut(e,t,n,o){const r=new Map;if("silhouette"===o)for(const o of e){let e=0;for(const r of t)e+=n(r,o)||0;r.set(o,-e/2)}else if("wiggle"===o){e.length>0&&r.set(e[0],0);for(let o=1;e.length>o;o++){const i=e[o-1],s=e[o];let a=0,c=0,l=0;for(const e of t){const t=n(e,s)||0;a+=(2*l+t)*(t-(n(e,i)||0)),c+=t,l+=t}const u=r.get(i)??0;r.set(s,u-(c>0?a/(2*c):0))}if(e.length>0){let o=0;for(const i of e){let e=0;for(const o of t)e+=n(o,i)||0;o+=(r.get(i)??0)+e/2}const i=o/e.length;for(const t of e)r.set(t,(r.get(t)??0)-i)}}else for(const t of e)r.set(t,0);return r}function Kt(e,t,n,o,r,i,s){const a=n(e),c=o(e);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:t.x(a),y:t.y(c),r:r,style:i,datum:e};return void 0!==s&&(l.pointId=s),l}function Zt(e,t,n,o,r,i,s,a){const c=n(e),l=o(e);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:t.x(c),y:t.y(l),size:r,symbolType:i,style:s,datum:e};return void 0!==a&&(u.pointId=a),u}function Qt(e,t,n,o,r,i,s){return{type:"rect",x:e,y:t,w:n,h:o,style:r,datum:i,group:s}}function Jt(e,t,n,o,r,i,s){const a={type:"heatcell",x:e,y:t,w:n,h:o,fill:r,datum:i};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function en(e,t,n,o){return"function"==typeof t.style?t.style(o||{},n):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(n,o)}function tn(e,t,n,o){if(!e.scales)return null;const r=[],i=[];for(const n of t){const t=e.getX(n);if(!Number.isFinite(t))continue;const s=o.getTop(n),a=o.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const c=e.scales.x(t),l=e.scales.y(s),u=e.scales.y(a);Number.isFinite(c)&&Number.isFinite(l)&&Number.isFinite(u)&&(r.push([c,l]),i.push([c,u]))}return 2>r.length?null:{type:"area",topPath:r,bottomPath:i,...e.config.curve&&"linear"!==e.config.curve&&{curve:e.config.curve},style:en(e,o,n,t[0]),datum:t,group:n,interactive:o.interactive}}function nn(e){const t=[],n=[];if(!e)return{perSeries:t,aggregate:n};for(const o of e)o.perSeries?t.push(o):n.push(o);return{perSeries:t,aggregate:n}}function on(e,t,n){const o=[];for(const r of n){const n=tn(e,t,"__ribbon_aggregate",r);n&&o.push(n)}return o}function rn(e,t,n,o){const r=[];for(const i of o){const o=tn(e,t,n,i);o&&r.push(o)}return r}function sn(e,t){if(!e)return{};if(!t||0===t.length)return e;const n=[];for(const o of t){if("band"!==o.kind)continue;const t=o.getTop(e),r=o.getBottom(e);Number.isFinite(r)&&Number.isFinite(t)&&n.push({y0:r,y1:t})}return 0===n.length?e:{...e,band:n[0],bands:n}}function an(e,t,n,o){if(!e.config.pointStyle)return;const r=o??e.getY;for(const o of t){const t=e.resolveGroupColor(o.key);for(const i of o.data){let o=e.config.pointStyle(i);!o.fill&&t&&(o={...o,fill:t});const s=o.r??3,a=e.getPointId?e.getPointId(i)+"":void 0,c=Kt(i,e.scales,e.getX,r,s,o,a);c&&n.push(c)}}}function cn(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}function ln(e){return Te(e)}var un=require("d3-shape"),dn={circle:un.symbolCircle,square:un.symbolSquare,triangle:un.symbolTriangle,diamond:un.symbolDiamond,star:un.symbolStar,cross:un.symbolCross,wye:un.symbolWye},hn=["circle","triangle","diamond","star","square","chevron","cross","wye"];function fn(e,t,n){if(n)return n;const o=e??"circle";return"chevron"===o?function(e){const t=1.5*pn(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}(t):(0,un.symbol)(dn[o]??un.symbolCircle,Math.max(1,t))()??""}function pn(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var yn=new Map;function gn(e,t,n){const o=n.config.areaStyle?.(t);return o&&(e.style=o),e}function mn(e,t,n,o,r){const i=new Map;for(const s of e){const e=t(s),a=n(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const c=Math.floor(e/o)*o;let l=i.get(c);if(l||(l={start:c,end:c+o,total:0,categories:new Map},i.set(c,l)),l.total+=a,r){const e=r(s);l.categories.set(e,(l.categories.get(e)||0)+a)}}return i}function xn(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:o,warned:r}=e;bn(o)&&0===n.length&&vn(r,"overlay-only",`[semiotic] ${t} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),n.length>0&&n.every(e=>null==e.datum)&&vn(r,"null-datums",`[semiotic] ${t} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function bn(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(bn))}function vn(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function wn(e,t,n,o){const r=function(e){if(e instanceof Error)return{name:e.name||"Error",message:e.message||"Custom layout threw."};if("string"==typeof e)return{name:"Error",message:e};if(null==e)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:e+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(t),i="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:i,message:`Semiotic ${e} ${i} failed: ${r.message}`,error:r,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:o}}function kn(e,t){const n="function"==typeof e?e:n=>n[e||t];return e=>{const t=n(e);return null==t?NaN:+t}}function Sn(e){const t=[],n=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,o=kn(n&&e.valueAccessor||e.yAccessor,n?"value":"y");if(e.boundsAccessor){const n=Rt(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{const t=o(e);if(!Number.isFinite(t))return NaN;const r=n(e);return Number.isFinite(r)&&0!==r?t+r:t},getBottom:e=>{const t=o(e);if(!Number.isFinite(t))return NaN;const r=n(e);return Number.isFinite(r)&&0!==r?t-r:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){const n=Array.isArray(e.band)?e.band:[e.band];for(const e of n)t.push({kind:"band",getTop:kn(e.y1Accessor,"y1"),getBottom:kn(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}var An=require("d3-scale");function Mn(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function _n(e,t,n){if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return(0,An.scaleLog)().domain(e).range(n).clamp(!0)}return"symlog"===e?(0,An.scaleSymlog)().domain(t).range(n):"time"===e?(0,An.scaleTime)().domain([new Date(t[0]),new Date(t[1])]).range(n):(0,An.scaleLinear)().domain(t).range(n)}function Pn(e,t,n){t>e.capacity&&(e.resize(t),n&&t>n.capacity&&n.resize(t))}function jn(e,t){const n=new Pt(e.capacity);return e.forEach(()=>n.push(t)),n}function Cn(e,t,n,o){const r=e.push(t);return n&&n.push(o),r}function Rn(e,t,n){if(!t||0===t.size)return;const o=new Set;if(e.forEach((e,t)=>{n(e)&&o.add(t)}),0===o.size)return;const r=t.toArray();t.clear();for(let e=0;r.length>e;e++)o.has(e)||t.push(r[e])}var Ln=new WeakMap;function In(){return this.updateResults.last}function Tn(){return this.updateResults.last}function $n(e){return this.updateResults.subscribe(e)}function zn(e){this.config.layoutSelection=e}function Dn(){Ln.set(this,!0)}function En(){const e=!0===Ln.get(this);return Ln.delete(this),e}function On(e){Object.assign(e.prototype,{getLastUpdateResult:In,getUpdateSnapshot:Tn,subscribeUpdateResult:$n,setLayoutSelection:zn,markStylePaintPending:Dn,consumeStylePaintPending:En})}var Fn={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"};function Bn(e,t){const n={...e};for(const e of t)n[Fn[e]]++;return n}function Nn(e,t,n){const o=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:o,revisions:Bn(n,o)}}var Wn=class{constructor(){this.revisions={data:0,domain:0,layout:0,sceneGeometry:0,sceneStyle:0,dataPaint:0,interactionPaint:0,overlay:0,accessibility:0,evidence:0},this.latest=Nn({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){const n=Nn(e,t,this.revisions);this.revisions=n.revisions,this.latest=n;for(const e of[...this.listeners])e();return n}},qn=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Yn=["scene-style","data-paint","accessibility","evidence"],Gn=(e,t)=>({retainedData:e,invalidations:t}),Hn=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Vn=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Xn=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Un=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Kn=["scene-geometry","data-paint","accessibility","evidence"],Zn=["scene-style","data-paint","accessibility","evidence"],Qn=[],Jn={chartType:Gn("rebuild",Hn),runtimeMode:Gn("rebuild",Hn),xAccessor:Gn("rebuild",Hn),yAccessor:Gn("rebuild",Hn),timeAccessor:Gn("rebuild",Hn),valueAccessor:Gn("rebuild",Hn),y0Accessor:Gn("rebuild",Hn),boundsAccessor:Gn("rebuild",Hn),band:Gn("rebuild",Hn),openAccessor:Gn("rebuild",Hn),highAccessor:Gn("rebuild",Hn),lowAccessor:Gn("rebuild",Hn),closeAccessor:Gn("rebuild",Hn),candlestickRangeMode:Gn("rebuild",Hn),accessorRevision:Gn("rebuild",Hn),groupAccessor:Gn("rebuild",Vn),categoryAccessor:Gn("rebuild",Vn),lineDataAccessor:Gn("rebuild",Vn),colorAccessor:Gn("rebuild",Zn),sizeAccessor:Gn("rebuild",Kn),symbolAccessor:Gn("rebuild",Kn),pointIdAccessor:Gn("rebuild",Kn),xScaleType:Gn("preserve",Xn),yScaleType:Gn("preserve",Xn),xExtent:Gn("preserve",Xn),yExtent:Gn("preserve",Xn),extentPadding:Gn("preserve",Xn),scalePadding:Gn("preserve",Xn),axisExtent:Gn("preserve",Xn),binSize:Gn("preserve",Xn),normalize:Gn("preserve",Xn),heatmapAggregation:Gn("preserve",Xn),heatmapXBins:Gn("preserve",Xn),heatmapYBins:Gn("preserve",Xn),arrowOfTime:Gn("preserve",Un),baseline:Gn("preserve",Un),stackOrder:Gn("preserve",Un),sizeRange:Gn("preserve",Un),curve:Gn("preserve",Un),areaGroups:Gn("preserve",Un),customLayout:Gn("preserve",Un),layoutConfig:Gn("preserve",Un),layoutMargin:Gn("preserve",Un),symbolMap:Gn("preserve",Kn),showValues:Gn("preserve",Kn),heatmapValueFormat:Gn("preserve",Kn),lineStyle:Gn("preserve",Zn),pointStyle:Gn("preserve",Zn),areaStyle:Gn("preserve",Zn),barStyle:Gn("preserve",Zn),swarmStyle:Gn("preserve",Zn),waterfallStyle:Gn("preserve",Zn),candlestickStyle:Gn("preserve",Zn),boundsStyle:Gn("preserve",Zn),gradientFill:Gn("preserve",Zn),lineGradient:Gn("preserve",Zn),semanticLineStops:Gn("preserve",Zn),colorScheme:Gn("preserve",Zn),themeCategorical:Gn("preserve",Zn),themeSemantic:Gn("preserve",Zn),themeSequential:Gn("preserve",Zn),themeDiverging:Gn("preserve",Zn),barColors:Gn("preserve",Zn),decay:Gn("preserve",Zn),pulse:Gn("preserve",Zn),staleness:Gn("preserve",Zn),layoutSelection:Gn("preserve",Zn),annotations:Gn("preserve",["overlay","accessibility","evidence"]),windowSize:Gn("preserve",Qn),windowMode:Gn("preserve",Qn),maxCapacity:Gn("preserve",Qn),clock:Gn("preserve",Qn),transition:Gn("preserve",Qn),introAnimation:Gn("preserve",Qn),onLayoutError:Gn("preserve",Qn)},eo=Gn("preserve",Un),to=class{constructor(){this.tracker=new Wn}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}},qn)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Yn):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const o of e){const e=Jn[o]??eo;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},no=require("d3-quadtree"),oo=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(e,t){if("scatter"!==e&&"bubble"!==e&&"custom"!==e)return void this.clear();let n=0,o=0;for(const e of t)"point"===e.type&&(n++,e.r>o&&(o=e.r));if(this.maxRadius=o,500>=n)return void(this.tree=null);const r=Array(n);let i=0;for(const e of t)"point"===e.type&&(r[i++]=e);this.tree=(0,no.quadtree)().x(e=>e.x).y(e=>e.y).addAll(r)}},ro=class e{constructor(e){if(this.xExtent=new jt,this.yExtent=new jt,this.growingCapacityWarned=!1,this.windowSizeWarned=!1,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this._ingestVersion=0,this._datumIndexCache=null,this._bufferArrayCache=null,this._bufferDirty=!0,this.needsFullRebuild=!0,this.lastLayout=null,this.updateResults=new to,this.scales=null,this.scene=[],this.version=0,this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customLayoutFailedThisBuild=!1,this._customLayoutDiagnosticsWarned=new Set,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.xIsDate=!1,this.spatialIndex=new oo,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,n)=>!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,o,r,i=("undefined"!=typeof performance?performance.now():Date.now())){const s=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let c=!1;const l=r??(()=>{const e=new Map;for(let t=0;n.length>t;t++)e.set(n[t],t);return e})();for(const n of t){if("line"===n.type)continue;if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[n.datum];let r=0,a=!1;for(const n of t){const t=l.get(n);if(null==t)continue;a=!0;const s=o.get(t);if(null==s)continue;const c=qt(e,s,i);c>r&&(r=c)}a&&(c=Yt(n,r,s)||c);continue}const t=l.get(n.datum);if(null==t)continue;const r=o.get(t);c=Yt(n,null==r?0:qt(e,r,i),s,a)||c}return c}(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),n),this.config=e,this.buffer=new Pt(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=Rt(e.timeAccessor||e.xAccessor,"time"),this.getY=Rt(e.valueAccessor||e.yAccessor,"value")):(this.getX=Rt(e.xAccessor,"x"),this.getY=Rt(e.yAccessor,"y")),this.getGroup=It(e.groupAccessor),this.getCategory=It(e.categoryAccessor),this.getSize=e.sizeAccessor?Rt(e.sizeAccessor,"size"):void 0,this.getColor=It(e.colorAccessor),this.getSymbol=It(e.symbolAccessor),this.getY0=e.y0Accessor?Rt(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=Sn(e),this.getPointId=It(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?Rt(e.openAccessor,"open"):void 0,this.getHigh=Rt(e.highAccessor,"high"),this.getLow=Rt(e.lowAccessor,"low"),this.getClose=n?Rt(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new Pt(e.windowSize))}currentTime(){return this.config.clock?.()??Bt()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=jn(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(e)),void this.yExtent.push(this.getLow(e));this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e));for(const t of this.resolvedRibbons){const n=t.getTop(e),o=t.getBottom(e);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(o)&&this.yExtent.push(o)}}evictDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(e)),void this.yExtent.evict(this.getLow(e));this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e));for(const t of this.resolvedRibbons){const n=t.getTop(e),o=t.getBottom(e);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(o)&&this.yExtent.evict(o)}}rebuildYExtent(){this.yExtent.clear();for(const e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const e of this.buffer)this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e)}ingest(e){if(e.bounded&&this._lastBoundedInsertsRef===e.inserts)return this.updateResults.recordNoop("replace"),!1;const t=this.currentTime();if(this.lastIngestTime=t,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,e.bounded){this._lastBoundedInsertsRef=e.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const n=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=n?Rt(this.config.timeAccessor||this.config.xAccessor,"time"):Rt(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,o="function"==typeof n?n(t):t[n||"x"],r=o instanceof Date,i="string"==typeof o&&Number.isFinite($t(o));if(this.xIsDate=r||i,i){const e="string"==typeof n?n:void 0;this.getX=e?t=>zt(t[e]):e=>zt(n(e))}}Pn(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const n of e.inserts)Cn(this.buffer,n,this.timestampBuffer,t),this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n)}else for(const n of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity??1e5;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"===process.env.NODE_ENV||this.growingCapacityWarned||5e4>this.growingCap||(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${e}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const e=Cn(this.buffer,n,this.timestampBuffer,t);this.xExtent.push(this.getX(n)),this.pushDatumYExtent(n),null!=e&&(this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e))}return this.updateResults.recordData(e.bounded?"replace":"ingest",e.inserts.length),!0}ingestWithResult(e){return this.ingest(e),this.updateResults.last}computeScene(e){const{config:t,buffer:n}=this,o=this.scales,r=this.lastLayout;if(!this.needsFullRebuild&&!t.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==e.width||this.lastLayout.height!==e.height))return void this.remapScene(e);this.xExtent.dirty&&this.xExtent.recalculate(n,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const i=this.getBufferArray(),s=this.yExtent.extent;let a=Mn(this.xExtent.extent,t.xExtent),c=Mn(s,t.yExtent);const l=!(!(u=t.yExtent)||null==u[0]||null==u[1]);var u;const d="exact"===t.axisExtent;if("stackedarea"===t.chartType&&!l&&n.size>0){const e=function(e){const{config:t,groups:n,getX:o,getY:r}=e,i="exact"===t.axisExtent;if(t.normalize){const n=[0,i?1:1+t.extentPadding];return{yDomain:n,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:n}}}const s=`${e.bufferSize}:${e.ingestVersion}:${t.baseline??"zero"}:${t.stackOrder??"key"}`;if(e.stackExtentCache&&e.stackExtentCache.key===s)return{yDomain:e.stackExtentCache.yDomain,stackExtentCache:e.stackExtentCache};const a=new Map,c=new Set;let l=0;const u=new Map,d=new Map;for(const e of n){const t=new Map;let n=0;for(const i of e.data){const e=o(i),s=r(i);if(!Number.isFinite(e)||!Number.isFinite(s))continue;t.set(e,(t.get(e)||0)+s),c.add(e),n+=s;const a=(u.get(e)||0)+s;u.set(e,a),a>l&&(l=a)}a.set(e.key,t),d.set(e.key,n)}const h=t.stackOrder??"key",f=(e,t)=>t>e?-1:e>t?1:0;let p,y;if("input"===h)p=n.map(e=>e.key);else if("insideOut"===h){const e=[...n].map(e=>e.key).sort((e,t)=>{const n=(d.get(t)??0)-(d.get(e)??0);return 0!==n?n:f(e,t)}),t=[],o=[];let r=0,i=0;for(const n of e)i>r?(t.push(n),r+=d.get(n)??0):(o.push(n),i+=d.get(n)??0);p=[...o.reverse(),...t]}else p="asc"===h?n.map(e=>e.key).sort((e,t)=>{const n=(d.get(e)??0)-(d.get(t)??0);return 0!==n?n:f(e,t)}):"desc"===h?n.map(e=>e.key).sort((e,t)=>{const n=(d.get(t)??0)-(d.get(e)??0);return 0!==n?n:f(e,t)}):n.map(e=>e.key).sort(f);if("wiggle"===t.baseline||"silhouette"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),n=Ut(e,p,(e,t)=>a.get(e)?.get(t)||0,t.baseline);let o=1/0,r=-1/0;for(const t of e){const e=n.get(t)??0,i=u.get(t)??0;o>e&&(o=e),e+i>r&&(r=e+i)}Number.isFinite(o)&&Number.isFinite(r)||(o=0,r=0);const s=r-o,l=i?0:s>0?s*t.extentPadding:1;y=[o-l,r+l]}else if("diverging"===t.baseline){const e=Array.from(c).sort((e,t)=>e-t),[n,o]=function(e,t,n){let o=0,r=0;for(const i of e){let e=0,s=0;for(const o of t){const t=n(o,i)||0;0>t?s+=t:e+=t}o>s&&(o=s),e>r&&(r=e)}return[o,r]}(e,p,(e,t)=>a.get(e)?.get(t)||0),r=o-n,s=i?0:r>0?r*t.extentPadding:1;y=[n-s,o+s]}else y=[0,l+(i?0:l>0?l*t.extentPadding:1)];return{yDomain:y,stackExtentCache:{key:s,yDomain:y}}}({config:t,groups:this.groupData(i),getX:this.getX,getY:this.getY,bufferSize:n.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!l&&n.size>0?c=function(e,t,n,o,r,i,s){const[,a]=function(e,t,n,o,r){const i=mn(e,t,n,o,r);if(0===i.size)return[0,0];let s=0;for(const e of i.values())e.total>s&&(s=e.total);return[0,s]}(e,t,n,o,r);return[0,s?a:a+a*i]}(n,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,d):"waterfall"===t.chartType&&!l&&n.size>0?c=function(e,t,n,o){const[r,i]=function(e,t){let n=0,o=0,r=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(r+=e,n>r&&(n=r),r>o&&(o=r))}return[n,o]}(e,t),s=i-r,a=o?0:s>0?s*n:1;return[Math.min(0,r-Math.abs(a)),Math.max(0,i+Math.abs(a))]}(n,this.getY,t.extentPadding,d):l||c[0]===1/0||(c=function(e,t,n){if(!n.length)return e;let[o,r]=e;for(const e of t)for(const t of n){const n=t.getTop(e),i=t.getBottom(e);Number.isFinite(n)&&(o>n&&(o=n),n>r&&(r=n)),Number.isFinite(i)&&(o>i&&(o=i),i>r&&(r=i))}return[o,r]}(c,i,this.resolvedRibbons),c=function(e,t){const n=e[1]-e[0],o=t.exactMode?0:n>0?n*t.extentPadding:1,r=[null!=t.userMin?e[0]:e[0]-o,null!=t.userMax?e[1]:e[1]+o];return"log"!==t.yScaleType||r[0]>0||0>=t.dataYDomain[0]||t.exactMode||null==t.userMin&&(r[0]=t.dataYDomain[0]/(1+t.extentPadding)),r}(c,{exactMode:d,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:s}));c=function(e,t,n){if(!t||n)return e;const o=t[0],r=t[1];return null==o&&null==r?e:[null!=o?o:e[0],null!=r?r:e[1]]}(c,t.yExtent,!!l),({xDomain:a,yDomain:c}=function(e,t,n){let o=e,r=t;if(o[0]===1/0||o[1]===-1/0)if("time"===n){const e=Date.now();o=[e-864e5,e]}else o=[0,1];return r[0]!==1/0&&r[1]!==-1/0||(r=[0,1]),{xDomain:o,yDomain:r}}(a,c,t.xScaleType)),this.scales=function(e){const{config:t,layout:n,xDomain:o,yDomain:r}=e,i="streaming"===t.runtimeMode,s=Math.max(0,Math.min(t.scalePadding||0,Math.min(n.width,n.height)/2-1));if(i){if("x"==("up"===(a=t.arrowOfTime)||"down"===a?"y":"x")){const e="right"===t.arrowOfTime?[s,n.width-s]:[n.width-s,s];return{x:(0,An.scaleLinear)().domain(o).range(e),y:_n(t.yScaleType,r,[n.height-s,s])}}const e="down"===t.arrowOfTime?[s,n.height-s]:[n.height-s,s];return{x:_n(t.yScaleType,r,[s,n.width-s]),y:(0,An.scaleLinear)().domain(o).range(e)}}var a;return{x:_n(t.xScaleType,o,[s,n.width-s]),y:_n(t.yScaleType,r,[n.height-s,s])}}({config:t,layout:e,xDomain:a,yDomain:c}),this._customLayoutFailedThisBuild=!1;const h=this.buildSceneNodes(e,i);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=o,this.lastLayout=r):(this.scene=[],this.spatialIndex.rebuild(this.config.chartType,this.scene)),void(this.needsFullRebuild=!0);this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=h,this.config.decay&&this.applyDecay(this.scene,i),this.config.pulse&&this.applyPulse(this.scene,i,this.currentTime()),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:e.width,height:e.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const o of e.path)o[0]*=t,o[1]*=n;break;case"area":for(const o of e.topPath)o[0]*=t,o[1]*=n;for(const o of e.bottomPath)o[0]*=t,o[1]*=n;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*n,width:e.clipRect.width*t,height:e.clipRect.height*n}),e.strokeColorBands&&(e.strokeColorBands=e.strokeColorBands.map(e=>({...e,y:e.y*n,height:e.height*n})));break;case"point":case"glyph":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const o=this.scales.x.domain(),r=this.scales.y.domain(),i=this.scales.x.range(),s=this.scales.y.range(),a=_n,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),l=s[1]>s[0];this.scales={x:a(this.config.xScaleType,o,i[0]>i[1]?[e.width-c,c]:[c,e.width-c]),y:a(this.config.yScaleType,r,l?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(e,t){const{config:n,scales:o}=this;if(!o)return[];if(n.customLayout){const r={data:t,scales:o,dimensions:{width:e.width,height:e.height,margin:n.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:n.themeSemantic??{},categorical:n.themeCategorical??fe},resolveColor:(e,t)=>{const o=this.resolveGroupColor(e);if(o)return o;const r=this.resolveLineStyle(e,t);return r.stroke?r.stroke:"string"==typeof r.fill?r.fill:n.themeSemantic?.primary??"#4e79a7"},config:n.layoutConfig??{},selection:n.layoutSelection??null};let i;try{i=n.customLayout(r)}catch(e){const t=null!==this.lastCustomLayoutResult,o=wn("xy",e,t,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",e);try{n.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,n.layoutSelection??null)}return xn({label:"customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}if(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,0===t.length)return[];const r={scales:o,config:n,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(n.chartType){case"line":return function(e,t){const n=e.groupData(t),o=[],r=e.config.annotations?.filter(cn).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:r,aggregate:i}=nn(e.ribbons);if(i.length>0&&o.push(...on(e,t,i)),r.length>0)for(const t of n)o.push(...rn(e,t.data,t.key,r))}for(const t of n){const n=e.resolveLineStyle(t.key,t.data[0]),i=Vt(t.data,e.scales,e.getX,e.getY,n,t.key);r&&r.length>0&&(i.colorThresholds=r),e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),o.push(i)}return an(e,n,o),o}(r,t);case"area":return function(e,t){const n=e.groupData(t),o=[];if(e.ribbons&&e.ribbons.length>0){const{perSeries:r,aggregate:i}=nn(e.ribbons);if(i.length>0&&o.push(...on(e,t,i)),r.length>0)for(const t of n)o.push(...rn(e,t.data,t.key,r))}const r=e.scales.y.domain(),i=r[0],s=e.config.semanticLineStops?.filter(e=>Number.isFinite(e.offset)).map(e=>({value:r[0]+Math.max(0,Math.min(1,e.offset))*(r[1]-r[0]),color:e.color,thresholdType:"greater"})).sort((e,t)=>e.value-t.value),a=s&&s.length>0?(()=>{const t=s.reduce((e,t)=>(e.at(-1)?.value===t.value?e[e.length-1]=t:e.push(t),e),[]),n=[{from:r[0],to:t[0].value}];for(let e=0;t.length>e;e++)n.push({from:t[e].value,to:t[e+1]?.value??r[1],color:t[e].color});return n.map(({from:t,to:n,color:o})=>{const r=e.scales.y(t),i=e.scales.y(n);return{y:Math.min(r,i),height:Math.abs(i-r),color:o}}).filter(e=>e.height>0)})():void 0,c=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),r=Xt(t.data,e.scales,e.getX,e.getY,i,n,t.key,c),l=ln(e.config.gradientFill);l&&(r.fillGradient=l),e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),s&&s.length>0&&(r.colorThresholds=s,r.strokeColorBands=a),o.push(r)}return an(e,n,o),o}(r,t);case"mixed":return function(e,t){const n=e.groupData(t),o=[],r=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){const{perSeries:r,aggregate:i}=nn(e.ribbons);if(i.length>0&&o.push(...on(e,t,i)),r.length>0)for(const t of n)o.push(...rn(e,t.data,t.key,r))}const i=e.scales.y.domain()[0],s=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n)if(r.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),r=Xt(t.data,e.scales,e.getX,e.getY,i,n,t.key,s),a=ln(e.config.gradientFill);a&&(r.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),o.push(r)}else{const n=e.resolveLineStyle(t.key,t.data[0]),r=Vt(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(r.curve=e.config.curve),e.config.lineGradient&&(r.strokeGradient=e.config.lineGradient),o.push(r)}return an(e,n,o),o}(r,t);case"stackedarea":return function(e,t){const n=e.groupData(t),o=e.config.stackOrder??"key",r=()=>n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"===o);else if("key"===o)r();else if("asc"===o||"desc"===o||"insideOut"===o){const t=new Map;for(const o of n){let n=0;for(const t of o.data){const o=e.getX(t),r=e.getY(t);Number.isFinite(o)&&Number.isFinite(r)&&(n+=r)}t.set(o.key,n)}const r=(e,t)=>t>e?-1:e>t?1:0;if("asc"===o)n.sort((e,n)=>{const o=(t.get(e.key)??0)-(t.get(n.key)??0);return 0!==o?o:r(e.key,n.key)});else if("desc"===o)n.sort((e,n)=>{const o=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==o?o:r(e.key,n.key)});else{const e=[...n].sort((e,n)=>{const o=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==o?o:r(e.key,n.key)}),o=[],i=[];let s=0,a=0;for(const n of e)a>s?(o.push(n),s+=t.get(n.key)??0):(i.push(n),a+=t.get(n.key)??0);n.length=0,n.push(...i.reverse(),...o)}}else r();const i=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,s=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:a,stackedTops:c}=function(e,t,n,o,r,i,s,a="zero"){const c=new Set;for(const t of e)for(const e of t.data){const t=n(e);Number.isFinite(t)&&c.add(t)}const l=Array.from(c).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const r of t.data){const t=n(r),i=o(r);Number.isFinite(t)&&Number.isFinite(i)&&e.set(t,(e.get(t)||0)+i)}u.set(t.key,e)}let d;if(i){d=new Map;for(const t of l){let n=0;for(const o of e)n+=u.get(o.key)?.get(t)||0;d.set(t,n||1)}}const h=Ut(l,e.map(e=>e.key),(e,t)=>u.get(e)?.get(t)||0,a),f="diverging"===a&&!i,p=[],y=new Map,g=new Map,m=new Map,x=new Map;for(const e of l)g.set(e,h.get(e)??0),m.set(e,0),x.set(e,0);for(const n of e){const e=u.get(n.key),o=new Map;let a=[],c=[];const h=()=>{if(a.length>=2){const e={type:"area",topPath:a,bottomPath:c,style:r(n.key,n.data[0]),datum:n.data,group:n.key};s&&(e.curve=s),p.push(e)}a=[],c=[]};for(const n of l){const r=e.has(n);let s,l,u=r?e.get(n):0;if(i&&r&&(u/=d.get(n)),!r||!Number.isFinite(u)||0===u){h();continue}f?u>0?(s=m.get(n),l=s+u,m.set(n,l)):(s=x.get(n),l=s+u,x.set(n,l)):(s=g.get(n),l=s+u,g.set(n,l));const p=t.x(n);c.push([p,t.y(s)]),a.push([p,t.y(l)]),o.set(n,l)}h(),y.set(n.key,o)}return{nodes:p,stackedTops:y}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,i,s),l=a;if(e.config.pointStyle){const t=new WeakMap;for(const o of n){const n=c.get(o.key);if(n)for(const r of o.data){const o=e.getX(r),i=e.getY(r);null==o||Number.isNaN(o)||null==i||Number.isNaN(i)||!n.has(o)||t.set(r,n.get(o))}}const o=n=>t.get(n)??e.getY(n);an(e,n,l,o)}return l}(r,t);case"scatter":case"bubble":return function(e,t){const n=[],o="bubble"===e.config.chartType?10:5,r=e.config.sizeRange||[3,15];let i=null;if(e.getSize&&!e.config.pointStyle){const n=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(n.length>0){let e=1/0,t=-1/0;for(const o of n)e>o&&(e=o),o>t&&(t=o);i=n=>e===t?(r[0]+r[1])/2:r[0]+(n-e)/(t-e)*(r[1]-r[0])}}const s=e.getColor?e.resolveColorMap(t):null,a=e.config.themeSemantic?.primary||"#4e79a7",c=e.getSymbol,l=e.config.symbolMap,u=new Map;let d=0;const h=e=>{const t=l?.[e];if(t)return t;let n=u.get(e);return n||(n=hn[d%hn.length],d++,u.set(e,n)),n};for(const r of t){let t=e.config.pointStyle?e.config.pointStyle(r):{fill:a,opacity:.8},l=t.r||o;if(i&&e.getSize){const t=e.getSize(r);null==t||Number.isNaN(t)||(l=i(t))}if(s&&e.getColor&&!t.fill){const n=e.getColor(r);n&&s.has(n)&&(t={...t,fill:s.get(n)})}const u=e.getPointId?e.getPointId(r)+"":void 0;if(c){const o=h(c(r)+""),i=Zt(r,e.scales,e.getX,e.getY,Math.PI*l*l,o,t,u);i&&n.push(i)}else{const o=Kt(r,e.scales,e.getX,e.getY,l,t,u);o&&n.push(o)}}return n}(r,t);case"heatmap":return function(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){const o=Math.max(1,Math.floor(e.config.heatmapXBins??20)),r=Math.max(1,Math.floor(e.config.heatmapYBins??20)),i=e.config.heatmapAggregation??"count",s=Rt(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[a,c]=e.scales.x.domain(),[l,u]=e.scales.y.domain(),d=(c-a||1)/o,h=(u-l||1)/r,f=o*r;if(f>1e6)return[];const p=new Int32Array(f),y=new Float64Array(f);for(let n=0;t.length>n;n++){const i=t[n],c=e.getX(i),u=e.getY(i);if(!isFinite(c)||!isFinite(u))continue;const f=Math.min(Math.floor((c-a)/d),o-1),g=Math.min(Math.floor((u-l)/h),r-1);if(0>f||0>g)continue;const m=g*o+f;p[m]++;const x=s(i);y[m]+=isFinite(x)?x:0}let g=1/0,m=-1/0;for(let e=0;f>e;e++){if(0===p[e])continue;let t;switch(i){case"sum":t=y[e];break;case"mean":t=y[e]/p[e];break;default:t=p[e]}g>t&&(g=t),t>m&&(m=t)}if(!isFinite(g))return[];const x=m-g||1,b=n.width/o,v=n.height/r,w=e.config.showValues,k=e.config.heatmapValueFormat,S=[];for(let t=0;r>t;t++){const n=t*o;for(let s=0;o>s;s++){const o=n+s;if(0===p[o])continue;let c;switch(i){case"sum":c=y[o];break;case"mean":c=y[o]/p[o];break;default:c=p[o]}const u=(c-g)/x,f={xi:s,yi:t,value:c,count:p[o],sum:y[o],xCenter:a+(s+.5)*d,yCenter:l+(t+.5)*h,agg:i};S.push(gn(Jt(s*b,(r-1-t)*v,b,v,`rgb(${220-(180*u+.5)|0},${220-(100*u+.5)|0},${255-(50*u+.5)|0})`,f,w?{value:c,showValues:!0,valueFormat:k}:void 0),f,e))}}return S}(e,t,n);if(0===t.length)return[];const o=Rt(e.config.valueAccessor,"value"),r=Lt(e.config.xAccessor,"x"),i=Lt(e.config.yAccessor,"y"),s=new Map,a=new Map,c=Array(t.length),l=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],o=r(n),u=i(n);c[e]=o,l[e]=u,s.has(o)||s.set(o,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,d=a.size;if(0===u||0===d)return[];const h=Array.from(s.keys()),f=Array.from(a.keys()),p=h.every(e=>"number"==typeof e&&!isNaN(e)),y=f.every(e=>"number"==typeof e&&!isNaN(e));if(p){h.sort((e,t)=>Number(e)-Number(t)),s.clear();for(let e=0;h.length>e;e++)s.set(h[e],e)}if(y){f.sort((e,t)=>Number(e)-Number(t)),a.clear();for(let e=0;f.length>e;e++)a.set(f[e],e)}const g=new Float64Array(t.length),m=new Float64Array(t.length),x=Array(t.length),b=new Map;let v=0;for(let e=0;t.length>e;e++){const n=t[e],r=s.get(c[e]),i=a.get(l[e]);if(void 0===r||void 0===i)continue;const d=o(n),h=i*u+r,f=b.get(h);let p;void 0!==f?p=f:(p=v++,b.set(h,p)),g[p]=h,m[p]=d,x[p]=n}let w=1/0,k=-1/0;for(let e=0;v>e;e++){const t=m[e];isFinite(t)&&(w>t&&(w=t),t>k&&(k=t))}if(!isFinite(w)||!isFinite(k))return[];const S=function(e){const t=e in ee?e:"blues";let n=yn.get(t);if(n)return n;n=Array(256);const o=te(t);for(let e=0;256>e;e++)n[e]=o(e/255);return yn.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),A=255/(k-w||1),M=n.width/u,_=n.height/d,P=e.config.showValues,j=e.config.heatmapValueFormat,C=[];for(let t=0;v>t;t++){const n=m[t];if(!isFinite(n))continue;const o=g[t],r=o%u,i=x[t];C.push(gn(Jt(r*M,(d-1-(o-r)/u)*_,M,_,S[Math.min((n-w)*A+.5|0,255)],i,P?{value:n,showValues:!0,valueFormat:j}:void 0),i,e))}return C}(r,t,e);case"bar":{const e=function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const n=mn(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===n.size)return{nodes:[],binBoundaries:[]};let o=null;if(e.getCategory){const t=new Set;for(const e of n.values())for(const n of e.categories.keys())t.add(n);const r=e.config.barColors?Object.keys(e.config.barColors):[],i=new Set(r),s=Array.from(t).filter(e=>!i.has(e)).sort(),a=r.filter(e=>t.has(e)),c=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===c?o=e.barCategoryCache.order:(o=[...a,...s],e.barCategoryCache={key:c,order:o})}const r=[],i=e.scales,[s,a]=i.x.domain(),c=e.config.barStyle,l=e.config.themeSemantic?.primary,u=c?.gap,d="number"!=typeof u||0>u?1:u,h={};c?.stroke&&(h.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(h.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(h.opacity=c.opacity);for(const t of n.values()){const n=Math.max(t.start,s),u=Math.min(t.end,a);if(n>=u)continue;const f=i.x(n),p=i.x(u),y=Math.abs(p-f),g=y>d+1?d:0,m=Math.min(f,p)+g/2,x=Math.max(y-g,1);if(x>0)if(o&&t.categories.size>0){let n=0;for(const s of o){const o=t.categories.get(s)||0;if(0===o)continue;const a=i.y(n),u=i.y(n+o);r.push(Qt(m,Math.min(a,u),x,Math.abs(a-u),{fill:e.config.barColors?.[s]||c?.fill||l||"#4e79a7",...h},{binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:o},s)),n+=o}}else{const e=i.y(0),n=i.y(t.total);r.push(Qt(m,Math.min(e,n),x,Math.abs(e-n),{fill:c?.fill||l||"#007bff",...h},{binStart:t.start,binEnd:t.end,total:t.total}))}}const f=new Set;for(const e of n.values())f.add(e.start),f.add(e.end);return{nodes:r,binBoundaries:Array.from(f).sort((e,t)=>e-t)}}(r,t);return this._barCategoryCache=r.barCategoryCache??null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){const n=[],o=e.config.swarmStyle||{},r=o.radius??3,i=o.fill??e.config.themeSemantic?.primary??"#007bff",s=o.opacity??.7,a=o.stroke,c=o.strokeWidth;for(const o of t){const t=e.getX(o),l=e.getY(o);if(null==l||Number.isNaN(l))continue;const u=e.scales.x(t),d=e.scales.y(l);let h=i;if(e.getCategory){const t=e.getCategory(o);h=e.config.barColors?.[t]||h}const{r:f,...p}=e.config.pointStyle?.(o)??{},y={type:"point",x:u,y:d,r:f??r,style:{fill:h,opacity:s,stroke:a,strokeWidth:c,...p},datum:o};e.getPointId&&(y.pointId=e.getPointId(o)+""),n.push(y)}return n}(r,t);case"waterfall":return function(e,t,n){const o=[],r=e.scales,i=e.config.waterfallStyle,s=t.filter(t=>{const n=e.getY(t),o=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=o&&isFinite(o)});if(0===s.length)return o;const a=i?.positiveColor??e.config.themeSemantic?.success??"#28a745",c=i?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",l=i?.gap??1,u=i?.stroke,d=i?.strokeWidth,h=i?.opacity;let f=0;for(let t=0;s.length>t;t++){const p=s[t],y=e.getX(p),g=e.getY(p),m=f+g;let x;x=s.length-1>t?e.getX(s[t+1])-y:t>0?y-e.getX(s[t-1]):0;const b=r.x(y),v=0!==x?r.x(y+x):b+n.width/10,w=Math.min(b,v)+l/2,k=Math.max(b,v)-l/2-w;if(0>=k){f=m;continue}const S=r.y(f),A=r.y(m),M=Math.min(S,A),_=Math.abs(S-A),P={fill:0>g?c:a,stroke:u,strokeWidth:d};null!=h&&(P.opacity=h),o.push(Qt(w,M,k,_,P,{...p,baseline:f,cumEnd:m,delta:g,_connectorStroke:i?.connectorStroke,_connectorWidth:i?.connectorWidth})),f=m}return o}(r,t,e);case"candlestick":return function(e,t,n){if(!e.getHigh||!e.getLow||!e.scales)return[];const o=e.config.candlestickRangeMode??!1;if(!(o||e.getOpen&&e.getClose))return[];const r=[],i=e.config.candlestickStyle||{},s=i.rangeColor||"#6366f1",a=o?s:i.upColor||"#28a745",c=o?s:i.downColor||"#dc3545",l=o?s:i.wickColor||"#333",u=i.wickWidth||(o?2:1),d=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let h=i.bodyWidth??0;if(null==i.bodyWidth)if(d.length>1){let t=1/0;for(let n=1;d.length>n;n++){const o=Math.abs(e.scales.x(d[n])-e.scales.x(d[n-1]));o>0&&t>o&&(t=o)}h=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else h=6;for(const i of t){const t=e.getX(i);if(null==t||Number.isNaN(t))continue;const s=e.getHigh(i),d=e.getLow(i);if(null==s||Number.isNaN(s)||null==d||Number.isNaN(d))continue;const f=o?s:e.getOpen(i),p=o?d:e.getClose(i);if(!o&&[f,p].some(e=>null==e||Number.isNaN(e)))continue;const y=p>=f,g={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(f),closeY:e.scales.y(p),highY:e.scales.y(s),lowY:e.scales.y(d),bodyWidth:h,upColor:a,downColor:c,wickColor:l,wickWidth:u,isUp:y,datum:i};o&&(g.isRange=!0,g.dotRadius=Math.max(2,Math.min(h/2,.12*n.height))),r.push(g)}return r}(r,t,e);default:return[]}}resolveBoundsStyle(e,t){return function(e,t,n,o){const r=e.boundsStyle;return"function"==typeof r?r(n||{},t):r&&"object"==typeof r?r:{fill:o(t,n).stroke||e.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?Nt(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const t=Wt(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&function(e,t,n,o=Wt(n)){const r=n.length;if(r>1)for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const i=Array(t.length);let s=!1;for(let n=0;t.length>n;n++){const a=o.get(t[n]);null!=a?(i[n]=Nt(e,a,r),1>i[n]&&(s=!0)):i[n]=1}s&&(n._decayOpacities=i);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],i=n.topPath?n.topPath.length:t.length;if(2>i)continue;if(t.length===i){const s=Array(i);let a=!1;for(let n=0;t.length>n;n++){const i=o.get(t[n]);null!=i?(s[n]=Nt(e,i,r),1>s[n]&&(a=!0)):s[n]=1}a&&(n._decayOpacities=s)}else{let s=1;for(const n of t){const t=o.get(n);if(null!=t){const n=Nt(e,t,r);s>n&&(s=n)}}if(1>s){const e=Array(i);e.fill(s),n._decayOpacities=e}}continue}const t=o.get(n.datum);if(null==t)continue;const i=Nt(e,t,r);"heatcell"===n.type?n.style={opacity:i}:"candlestick"===n.type?n._decayOpacity=i:n.style={...n.style,opacity:(n.style?.opacity??1)*i}}}(this.config.decay,e,t,this.getDatumIndexMap(t))}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&Gt(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,o){n.clear(),o.clear();for(let r=0;t.length>r;r++){const i=t[r],s=Ht(e,i,r);s&&("point"===i.type?n.set(s,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"glyph"===i.type?n.set(s,{x:i.x,y:i.y,r:i.size,opacity:i.style.opacity,glyph:i.glyph}):"rect"===i.type?n.set(s,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}):"heatcell"===i.type?n.set(s,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style?.opacity}):"candlestick"===i.type?n.set(s,{x:i.x,y:i.openY,w:i.bodyWidth,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY,opacity:i.style?.opacity}):"line"===i.type?o.set(s,{path:i.path.map(e=>[e[0],e[1]]),opacity:i.style?.opacity}):"area"===i.type&&o.set(s,{topPath:i.topPath.map(e=>[e[0],e[1]]),bottomPath:i.bottomPath.map(e=>[e[0],e[1]]),opacity:i.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const e=this.scales?.y(0)??0;for(let t=0;this.scene.length>t;t++){const n=this.scene[t],o=Ht(this.transitionContext,n,t);o&&("point"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,r:0,opacity:0}):"rect"===n.type?this.prevPositionMap.set(o,{x:n.x,y:e,w:n.w,h:0,opacity:n.style.opacity??1}):"heatcell"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:0}):"line"===n.type?(n._introClipFraction=0,this.prevPathMap.set(o,{path:n.path.map(e=>[e[0],e[1]]),opacity:n.style.opacity})):"area"===n.type&&(n._introClipFraction=0,this.prevPathMap.set(o,{topPath:n.topPath.map(e=>[e[0],e[1]]),bottomPath:n.bottomPath.map(e=>[e[0],e[1]]),opacity:n.style.opacity})))}}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,o,r,i=Bt()){if(0===o.size&&0===r.size)return n;const s=t.duration??300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let a=!1;const c=new Set,l=new Set;for(let t=0;n.scene.length>t;t++){const i=n.scene[t],s=Ht(e,i,t);if(!s)continue;if(i._transitionKey=s,"line"===i.type||"area"===i.type){const e=r.get(s);if(e){if(l.add(s),"line"===i.type&&e.path&&e.path.length===i.path.length){i._targetPath=i.path.map(e=>[e[0],e[1]]),i._prevPath=e.path;for(let t=0;i.path.length>t;t++)i.path[t]=[e.path[t][0],e.path[t][1]];a=!0}else if("area"===i.type&&e.topPath&&e.bottomPath&&e.topPath.length===i.topPath.length&&e.bottomPath.length===i.bottomPath.length){i._targetTopPath=i.topPath.map(e=>[e[0],e[1]]),i._targetBottomPath=i.bottomPath.map(e=>[e[0],e[1]]),i._prevTopPath=e.topPath,i._prevBottomPath=e.bottomPath;for(let t=0;i.topPath.length>t;t++)i.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;i.bottomPath.length>t;t++)i.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];a=!0}i._targetOpacity=i.style.opacity??1,i._startOpacity=e.opacity??i.style.opacity??1}else i._targetOpacity=i.style.opacity??1,i._startOpacity=0,i.style={...i.style,opacity:0},a=!0;continue}const u=o.get(s);if("point"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,r:i.r};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.r||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.r,i.x=u.x,i.y=u.y,i.r=u.r??i.r,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("glyph"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,size:i.size};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.r===e.size||(i._targetX=e.x,i._targetY=e.y,i._targetR=e.size,i.x=u.x,i.y=u.y,i.size=u.r??i.size,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("rect"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=i.style.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,a=!0)}else i._targetOpacity=i.style.opacity??1,i.style={...i.style,opacity:0},a=!0;else if("heatcell"===i.type)if(u){c.add(s);const e={x:i.x,y:i.y,w:i.w,h:i.h};i._targetOpacity=i.style?.opacity??1,u.x===e.x&&u.y===e.y&&u.w===e.w&&u.h===e.h||(i._targetX=e.x,i._targetY=e.y,i._targetW=e.w,i._targetH=e.h,i.x=u.x,i.y=u.y,i.w=u.w??i.w,i.h=u.h??i.h,a=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},a=!0;else if("candlestick"===i.type)if(u&&null!=u.openY){c.add(s);const e={x:i.x,openY:i.openY,closeY:i.closeY,highY:i.highY,lowY:i.lowY};i._targetOpacity=i.style?.opacity??1,(u.x!==e.x||u.openY!==e.openY||u.closeY!==e.closeY||u.highY!==e.highY||u.lowY!==e.lowY)&&(i._targetX=e.x,i._targetOpenY=e.openY,i._targetCloseY=e.closeY,i._targetHighY=e.highY,i._targetLowY=e.lowY,i.x=u.x,i.openY=u.openY,i.closeY=u.closeY??i.closeY,i.highY=u.highY??i.highY,i.lowY=u.lowY??i.lowY,a=!0)}else i._targetOpacity=i.style?.opacity??1,i.style={...i.style||{},opacity:0},a=!0}for(const[e,t]of r)if(!l.has(e))if(e.startsWith("l:")&&t.path){const o={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(o),a=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const o={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(o),a=!0}for(const[e,t]of o)if(!c.has(e)){if(e.startsWith("p:"))n.exitNodes.push({type:"point",x:t.x,y:t.y,r:t.r??3,style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("g:")&&t.glyph)n.exitNodes.push({type:"glyph",x:t.x,y:t.y,size:t.r??12,glyph:t.glyph,color:"#999",accent:"#999",style:{opacity:t.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))n.exitNodes.push({type:"rect",x:t.x,y:t.y,w:t.w??0,h:t.h??0,style:{opacity:t.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("h:"))n.exitNodes.push({type:"heatcell",x:t.x,y:t.y,w:t.w??0,h:t.h??0,fill:"#999",datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e});else if(e.startsWith("c:")){const o=t.openY??t.y;n.exitNodes.push({type:"candlestick",x:t.x,openY:o,closeY:t.closeY??o,highY:t.highY??o,lowY:t.lowY??o,bodyWidth:t.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:t.opacity??1},_targetOpacity:0,_transitionKey:e})}a=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),a&&(n.activeTransition={startTime:i,duration:s}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(e,t,n,o){if(!n.activeTransition)return!1;const r=Ot(e,n.activeTransition),i=Et(r,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of n.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0;e.style.opacity=Ft(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=Ft(n.x,e._targetX,i),e.y=Ft(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.r=Ft(n.r,e._targetR,i))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0;e.style.opacity=Ft(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=Ft(n.x,e._targetX,i),e.y=Ft(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.size=Ft(n.r,e._targetR,i))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0;e.style.opacity=Ft(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=Ft(n.x,e._targetX,i),e.y=Ft(n.y,e._targetY,i),void 0!==n.w&&(e.w=Ft(n.w,e._targetW,i)),void 0!==n.h&&(e.h=Ft(n.h,e._targetH,i))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0;e.style={...e.style||{},opacity:Ft(n?n.opacity??1:0,e._targetOpacity,i)}}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=Ft(n.x,e._targetX,i),e.y=Ft(n.y,e._targetY,i),void 0!==n.w&&(e.w=Ft(n.w,e._targetW,i)),void 0!==n.h&&(e.h=Ft(n.h,e._targetH,i))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0;e.style={...e.style||{},opacity:Ft(n?n.opacity??1:0,e._targetOpacity,i)}}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=Ft(n.x,e._targetX,i),void 0!==n.openY&&(e.openY=Ft(n.openY,e._targetOpenY,i)),void 0!==n.closeY&&(e.closeY=Ft(n.closeY,e._targetCloseY,i)),void 0!==n.highY&&(e.highY=Ft(n.highY,e._targetHighY,i)),void 0!==n.lowY&&(e.lowY=Ft(n.lowY,e._targetLowY,i))}else if("line"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Ft(e._startOpacity??0,e._targetOpacity,i)}),void 0!==e._introClipFraction&&(e._introClipFraction=i);const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let o=0;e.path.length>o;o++)e.path[o][0]=Ft(t[o][0],n[o][0],i),e.path[o][1]=Ft(t[o][1],n[o][1],i)}else if("area"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Ft(e._startOpacity??0,e._targetOpacity,i)}),void 0!==e._introClipFraction&&(e._introClipFraction=i);const t=e._prevTopPath,n=e._prevBottomPath,o=e._targetTopPath,r=e._targetBottomPath;if(t&&o&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=Ft(t[n][0],o[n][0],i),e.topPath[n][1]=Ft(t[n][1],o[n][1],i);if(n&&r&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=Ft(n[t][0],r[t][0],i),e.bottomPath[t][1]=Ft(n[t][1],r[t][1],i)}}if(r>=1){for(const e of n.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style="line"===e.type||"area"===e.type?{...e.style,opacity:0===t?0:t}:{...e.style||{},opacity:0===t?0:t},e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("glyph"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.size=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("candlestick"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,void 0!==e._targetOpenY&&(e.openY=e._targetOpenY),void 0!==e._targetCloseY&&(e.closeY=e._targetCloseY),void 0!==e._targetHighY&&(e.highY=e._targetHighY),void 0!==e._targetLowY&&(e.lowY=e._targetLowY),e._targetX=void 0,e._targetOpenY=void 0,e._targetCloseY=void 0,e._targetHighY=void 0,e._targetLowY=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,n}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const e of this.scene)"line"!==e.type&&"area"!==e.type||(e._introClipFraction=void 0)}groupData(e){const{result:t,cache:n}=function(e,t,n,o){if(o&&o.version===n&&o.group===t&&o.data===e)return{result:o.result,cache:o};let r;if(t){const n=new Map;for(const o of e){const e=t(o);n.has(e)||n.set(e,[]),n.get(e).push(o)}r=Array.from(n.entries()).map(([e,t])=>({key:e,data:t}))}else r=[{key:"_default",data:e}];return{result:r,cache:{version:n,group:t,data:e,result:r}}}(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=n,t}resolveColorMap(e){const{map:t,cache:n}=function(e,t,n,o,r){if(r&&r.version===o)return{map:r.map,cache:r};const i=new Set;if(t)for(const n of e){const e=t(n);e&&i.add(e)}const s=Array.from(i).sort(),a=s.join("\0");if(r&&r.key===a){const e={...r,version:o};return{map:e.map,cache:e}}const c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical||fe,l=new Map;for(let e=0;s.length>e;e++)l.set(s[e],c[e%c.length]);return{map:l,cache:{key:a,map:l,version:o}}}(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=n,t}resolveLineStyle(e,t){return function(e,t,n,o){const r=e.lineStyle;if("function"==typeof r){const e=r(n||{},t);if(e&&!e.stroke&&t){const n=o(t);if(n)return{...e,stroke:n}}return e}const i=e.themeSemantic?.primary;return r&&"object"==typeof r?{stroke:r.stroke||i||"#007bff",strokeWidth:r.strokeWidth||2,strokeDasharray:r.strokeDasharray,fill:r.fill,fillOpacity:r.fillOpacity,opacity:r.opacity}:{stroke:o(t)||i||"#007bff",strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return function(e,t,n,o){if(e.areaStyle){const r=e.areaStyle(n||{});if(r&&!r.fill&&t){const e=o(t);if(e)return{...r,fill:e,stroke:r.stroke||e}}return r}const r=e.lineStyle;if("function"==typeof r){const e=r(n||{},t);if(e&&!e.fill&&t){const n=o(t);if(n)return{...e,fill:n,stroke:e.stroke||n}}return e}const i=e.themeSemantic?.primary;if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||i||"#4e79a7",fillOpacity:r.fillOpacity??.7,stroke:r.stroke||i||"#4e79a7",strokeWidth:r.strokeWidth||2};const s=o(t)||i||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(t){const{color:n,groupColorCounter:o}=function(e){const{group:t,colorMapCache:n,groupColorMap:o,groupColorMapCap:r,config:i}=e;let{groupColorCounter:s}=e;if(n){const e=n.map.get(t);if(e)return{color:e,groupColorCounter:s}}const a=o.get(t);if(a)return{color:a,groupColorCounter:s};const c=(Array.isArray(i.colorScheme)&&i.colorScheme.length>0?i.colorScheme:null)||(Array.isArray(i.themeCategorical)&&i.themeCategorical.length>0?i.themeCategorical:null)||fe;if(0===c.length)return{color:null,groupColorCounter:s};const l=c[s%c.length];if(s++,o.set(t,l),o.size>r){const e=o.keys().next().value;void 0!==e&&o.delete(e)}return{color:l,groupColorCounter:s}}({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:e.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=o,n}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=Dt(e),n=this.getPointId,o=e=>t.has(n(e));Rn(this.buffer,this.timestampBuffer,o);const r=this.buffer.remove(o);if(0===r.length)return this.updateResults.recordNoop("remove"),r;for(const e of r)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",r.length),r}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=Dt(e),o=this.getPointId,r=new Set;this.buffer.forEach((e,t)=>{n.has(o(e))&&r.add(t)});const i=this.buffer.update(e=>n.has(o(e)),t);if(0===i.length)return this.updateResults.recordNoop("update"),i;for(const e of i)this.xExtent.evict(this.getX(e)),this.evictDatumYExtent(e);return this.buffer.forEach((e,t)=>{r.has(t)&&(this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",i.length),i}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(e,t){const n=this._customRestyle;if(n)for(const o of e){const e=this._baseStyles.get(o)??o.style??{},r=n(o,t);o.style=r?{...e,...r}:e}}restyleScene(e){this._customRestyle?(this.applyCustomRestyle(this.scene,e),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(e){const t={...this.config},n=Object.keys(e).filter(n=>e[n]!==t[n]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in e||"colorScheme"in e)&&(this._barCategoryCache=null),("normalize"in e||"extentPadding"in e||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e||"boundsAccessor"in e||"band"in e||"y0Accessor"in e||"openAccessor"in e||"highAccessor"in e||"lowAccessor"in e||"closeAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let o=!1,r=!1;Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();const i="chartType"in e&&e.chartType!==t.chartType||"runtimeMode"in e&&e.runtimeMode!==t.runtimeMode;if(i||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){const e=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,n=e&&this.config.valueAccessor||this.config.yAccessor,s=e&&t.valueAccessor||t.yAccessor,a=i||!Ct(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),c=i||!Ct(n,s);(a||c)&&(e?(this.getX=Rt(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Rt(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Rt(this.config.xAccessor,"x"),this.getY=Rt(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=Sn(this.config)),o=!0,r=!0)}if("groupAccessor"in e&&!Ct(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?It(this.config.groupAccessor):void 0,o=!0),"categoryAccessor"in e&&!Ct(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?It(this.config.categoryAccessor):void 0,o=!0),"sizeAccessor"in e&&!Ct(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Rt(this.config.sizeAccessor,"size"):void 0,o=!0),"symbolAccessor"in e&&!Ct(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?It(this.config.symbolAccessor):void 0,o=!0),"colorAccessor"in e&&!Ct(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?It(this.config.colorAccessor):void 0,o=!0),"y0Accessor"in e&&!Ct(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?Rt(this.config.y0Accessor,"y0"):void 0,o=!0,r=!0),("boundsAccessor"in e&&!Ct(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=Sn(this.config),o=!0,r=!0),"pointIdAccessor"in e&&!Ct(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?It(this.config.pointIdAccessor):void 0,o=!0),"candlestick"===this.config.chartType&&(i||"openAccessor"in e&&!Ct(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!Ct(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!Ct(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!Ct(e.lowAccessor,t.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?Rt(this.config.openAccessor,"open"):void 0,this.getHigh=Rt(this.config.highAccessor,"high"),this.getLow=Rt(this.config.lowAccessor,"low"),this.getClose=t?Rt(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,o=!0,r=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(o=!0,r=!0),!o){const n=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const r of n)if(e[r]!==t[r]){o=!0;break}}o&&(r&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(n)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};ro.GROUP_COLOR_MAP_CAP=1e3;var io=ro;On(io);var so=require("react"),ao={sceneGeometry:0,layout:0,domain:0};function co(e){const{domain:t,layout:n,sceneGeometry:o}=e.revisions;return{domain:t,layout:n,sceneGeometry:o}}function lo(e,t){return{sceneGeometry:Math.max(e.sceneGeometry,t.sceneGeometry),layout:Math.max(e.layout,t.layout),domain:Math.max(e.domain,t.domain)}}var uo="production"!==process.env.NODE_ENV,ho={revisions:ao,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},fo=class{constructor(e="scene host"){this.hostName=e,this.lastConsumed=ao,this.lastObserved=ao,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}observeUpdateResult(e){uo&&(this.lastObserved=lo(this.lastObserved,co(e)))}beforeCompute(e,t){if(!uo)return ho;const n=lo(co(e),this.lastObserved),o=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),r=!((i=n).sceneGeometry===(s=this.lastConsumed).sceneGeometry&&i.layout===s.layout&&i.domain===s.domain);var i,s;return{revisions:n,signature:o,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:r,warnUnconsumed:!t&&r&&this.lastUnconsumedWarning!==o}}afterCompute(e,t,n){if(uo){if(t&&e.wasUnconsumed&&(this.lastConsumed=e.revisions),e.warnUnconsumed&&!t)return console.warn(`[semiotic] ${this.hostName} observed scene-affecting revisions without a scene rebuild: ${e.signature}.`),void(this.lastUnconsumedWarning=e.signature);t&&e.sawSignals&&!e.wasUnconsumed&&!n&&this.lastDuplicateWarning!==e.signature?(console.warn(`[semiotic] ${this.hostName} performed scene rebuild with unchanged scene revisions: ${e.signature}.`),this.lastDuplicateWarning=e.signature):t&&!e.sawSignals&&(this.lastDuplicateWarning="")}}},po=(0,so.memo)(function({store:e,diagnostics:t}){return(0,so.useEffect)(()=>{const n=()=>t.observeUpdateResult(e.getUpdateSnapshot());return n(),e.subscribeUpdateResult(n)},[t,e]),null}),yo=y(require("react"));function go(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:yo.createElement(yo.Fragment,null,...t)}var mo=require("react");function xo(e,t,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function bo(e,t=30){return Math.max((e??4)+5,12,t)}function vo(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function wo(e,t){const n=vo(e);if(!n)return!1;const o=vo(t);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}var ko=[40,40],So=[.5,.5];function Ao(e,t){const[n,o]=e.viewBox??ko,[r,i]=e.anchor??So,s=o>0?o:1,a=Math.max(0,t)/s,c=(n>0?n:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-r*c,offsetY:-i*l}}function Mo(e,t,n,o){if("none"!==e)return"color"===e||null==e?t??o:"accent"===e?n:e}var _o=null;function Po(e){if("undefined"==typeof Path2D)return null;_o||(_o=new Map);const t=_o.get(e);if(t)return t;const n=new Path2D(e);return _o.size>1024&&_o.clear(),_o.set(e,n),n}function jo(e,t,n=0,o="horizontal"){const[r,i]=e.viewBox??ko,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a>s?s>0||1>a?"vertical"===o?{x:0,y:i*(1-a),width:r,height:i*(a-s)}:{x:r*s,y:0,width:r*(a-s),height:i}:null:{x:0,y:0,width:0,height:0}}function Co(e,t){const n=Ao(e,t);return{centerDx:n.offsetX+n.width/2,centerDy:n.offsetY+n.height/2,halfWidth:n.width/2,halfHeight:n.height/2,radius:Math.hypot(n.width,n.height)/2}}function Ro(e,t,n,o,r,i=e=>e){for(const s of t.parts){const t=Po(s.d);if(!t)continue;const a=s.opacity??1,c=e.globalAlpha;1!==a&&(e.globalAlpha=c*a);const l=r?"none"===s.fill?void 0:r:Mo(s.fill,n,o);l&&(e.fillStyle=i(l),e.fill(t));const u=r?s.stroke&&"none"!==s.stroke?r:void 0:Mo(s.stroke??"none",n,o);u&&(e.strokeStyle=i(u),e.lineWidth=s.strokeWidth??1,e.lineCap=s.strokeLinecap??"butt",e.lineJoin=s.strokeLinejoin??"miter",e.stroke(t)),1!==a&&(e.globalAlpha=c)}}var Lo=new WeakMap,Io=0,To=!1,$o=null,zo=null;function Do(e,t){if(!t)return t;const n=function(e){const t=e.trim();if(!t.startsWith("var(")||!t.endsWith(")"))return null;const n=t.slice(4,-1),o=n.indexOf(",");if(-1===o){const e=n.trim();return e.startsWith("--")?{name:e}:null}const r=n.slice(0,o).trim(),i=n.slice(o+1).trim();return r.startsWith("--")?{name:r,fallback:i||void 0}:null}(t);if(!n)return t;const o=()=>n.fallback?Do(e,n.fallback):t,r=e.canvas;if(!r)return o();!function(){if(To)return;if("undefined"==typeof window||"undefined"==typeof document)return;To=!0;const e=()=>{Io++};if("undefined"!=typeof MutationObserver&&document.documentElement&&new MutationObserver(e).observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"],subtree:!0}),"function"==typeof window.matchMedia)try{$o=window.matchMedia("(prefers-color-scheme: dark)"),zo=e,"function"==typeof $o.addEventListener?$o.addEventListener("change",zo):"function"==typeof $o.addListener&&$o.addListener(zo)}catch{}}();let i=Lo.get(r);i&&i.version===Io||(i={version:Io,map:new Map},Lo.set(r,i));const s=i.map.get(t);if(void 0!==s)return s;const a=getComputedStyle(r).getPropertyValue(n.name).trim()||o()||t;return i.map.set(t,a),a}function Eo(e){return{type:"hatch",background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle}}var Oo=null;var Fo=require("react/jsx-runtime");function Bo(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function No(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}var Wo=new Map;function qo(e,t){const{background:n="transparent",stroke:o="#000",lineWidth:r=1.5,spacing:i=6,angle:s=45,lineOpacity:a=1}=e,c=Math.max(8,Math.ceil(2*i));return(0,Fo.jsxs)("pattern",{id:t,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[n&&"transparent"!==n&&(0,Fo.jsx)("rect",{width:c,height:c,fill:n}),(0,Fo.jsx)("line",{x1:0,y1:0,x2:0,y2:c,stroke:o,strokeWidth:r,strokeOpacity:a}),(0,Fo.jsx)("line",{x1:i,y1:0,x2:i,y2:c,stroke:o,strokeWidth:r,strokeOpacity:a})]},t)}function Yo(e,t,n="#4e79a7"){if(Bo(e)){const n=function(e,t){let n=2166136261;const o=No(t);for(let e=0;o.length>e;e++)n^=o.charCodeAt(e),n=Math.imul(n,16777619);return`${e}-hatch-${(n>>>0).toString(36)}`}(t,e);return{fill:`url(#${n})`,def:qo(e,n)}}return e&&"string"==typeof e?{fill:e}:{fill:n}}var Go=require("d3-shape");function Ho(e){switch(e){case"monotoneX":return Go.curveMonotoneX;case"monotoneY":return Go.curveMonotoneY;case"cardinal":return Go.curveCardinal;case"catmullRom":return Go.curveCatmullRom;case"step":return Go.curveStep;case"stepBefore":return Go.curveStepBefore;case"stepAfter":return Go.curveStepAfter;case"basis":return Go.curveBasis;case"natural":return Go.curveNatural;default:return null}}function Vo(e,t,n){if(null==t)return n;if(Bo(t)){const o=function(e,t){const n="undefined"!=typeof window&&window.devicePixelRatio||1,o=`${No(e)}@${n}`,r=Wo.get(o);if(void 0!==r)return r;const i=function(e={},t){const{background:n="transparent",stroke:o="#000",lineWidth:r=1.5,spacing:i=6,angle:s=45}=e,a={background:n,stroke:o,lineWidth:r,spacing:i,angle:s},c=Math.max(8,Math.ceil(2*i));let l;try{l=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Oo||(Oo=document.createElement("canvas")),Oo.width=e,Oo.height=e,Oo)}(c)}catch{return Eo(a)}const u=l.getContext("2d");if(!u)return Eo(a);n&&"transparent"!==n?(u.fillStyle=n,u.fillRect(0,0,c,c)):u.clearRect(0,0,c,c),u.strokeStyle=o,u.lineWidth=r,u.lineCap="square";const d=s*Math.PI/180;if(45===s||-45===s){const e=s>0?1:-1;for(let t=-c;2*c>=t;t+=i)u.beginPath(),u.moveTo(t,0),u.lineTo(t+e*c,c),u.stroke()}else{u.save(),u.translate(c/2,c/2),u.rotate(d);const e=2*c;for(let t=-e;e>=t;t+=i)u.beginPath(),u.moveTo(-e,t),u.lineTo(e,t),u.stroke();u.restore()}return(t||u).createPattern(l,"repeat")}({background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle},t),s=Bo(i)?null:i;return Wo.set(o,s),s}(t,e);return o||t.background&&Do(e,t.background)||n}return"string"!=typeof t?t:Do(e,t)||n}function Xo(e,t,n,o,r,i,s){const a=t.stops.filter(e=>Number.isFinite(e.offset)&&(null==e.opacity||Number.isFinite(e.opacity)));if(2>a.length)return null;const c=e.createLinearGradient(o,r,i,s);for(const t of a)c.addColorStop(Math.max(0,Math.min(1,t.offset)),Uo(e,t,n));return c}function Uo(e,t,n){const o=t.color??n,r=Do(e,o)||o;if(null==t.opacity)return r;const i=Math.max(0,Math.min(1,t.opacity)),[s,a,c]=function(e,t){const n=e.fillStyle,o="#010203";try{e.fillStyle=o,e.fillStyle=t}catch{return e.fillStyle=n,[78,121,167]}const r=e.fillStyle;if(e.fillStyle=n,"string"!=typeof r)return[78,121,167];if(r.toLowerCase()===o&&t.trim().toLowerCase()!==o)return[78,121,167];if(r.startsWith("#"))return[parseInt(r.slice(1,3),16),parseInt(r.slice(3,5),16),parseInt(r.slice(5,7),16)];const i=r.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return i?[+i[1],+i[2],+i[3]]:[78,121,167]}(e,r);return`rgba(${s},${a},${c},${i})`}function Ko(e,t,n,o,r,i,s){const a=t.stops.filter(e=>Number.isFinite(e.offset)&&(null==e.opacity||Number.isFinite(e.opacity)));if(2>a.length)return null;const c=e.createLinearGradient(o,r,i,s);for(const t of a)c.addColorStop(Math.max(0,Math.min(1,t.offset)),Uo(e,t,n));return c}var Zo=require("d3-shape"),Qo=new WeakMap;function Jo(e,t){const n=Ho(t);if(!n)return e;const o=Qo.get(e);if(o)return o;const r=function(e,t,n=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const o=[];let r=null;const i={moveTo(e,t){r=[e,t],o.push([e,t])},lineTo(e,t){r=[e,t],o.push([e,t])},bezierCurveTo(e,t,i,s,a,c){if(!r)return r=[a,c],void o.push([a,c]);const[l,u]=r;for(let r=1;n>=r;r++){const d=r/n,h=1-d;o.push([h*h*h*l+3*h*h*d*e+3*h*d*d*i+d*d*d*a,h*h*h*u+3*h*h*d*t+3*h*d*d*s+d*d*d*c])}r=[a,c]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,n,i){r=[n,i],o.push([n,i])}};return(0,Zo.line)().x(e=>e[0]).y(e=>e[1]).curve(t).context(i)(e),o}(e,n);return Qo.set(e,r),r}function er(e,t,n,o=30,r,i=0){let s=null;if(r){const e=function(e,t,n,o,r,i=e=>e.x,s=e=>e.y,a=e=>e.r){const c=Math.max(o,r+5,12),l=t-c,u=t+c,d=n-c,h=n+c;let f=null,p=1/0;return e.visit((e,r,c,y,g)=>{if(r>u||l>y||c>h||d>g)return!0;if(!e.length){let r=e;do{const e=r.data,c=i(e)-t,l=s(e)-n,u=Math.sqrt(c*c+l*l);bo(a(e),o)>=u&&p>u&&(f=e,p=u),r=r.next}while(r)}return!1}),f?{node:f,distance:p}:null}(r,t,n,o,i);e&&(s={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const i of e){let e=null;switch(i.type){case"point":if(r)break;e=nr(i,t,n,o);break;case"symbol":e=or(i,t,n,o);break;case"glyph":e=rr(i,t,n,o);break;case"line":e=ir(i,t,n,o);break;case"rect":if(null==i.datum)break;e=ar(i,t,n);break;case"heatcell":e=cr(i,t,n);break;case"area":if(!1===i.interactive)break;e=ur(i,t,n);break;case"candlestick":e=lr(i,t,n)}e&&o>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function tr(e,t,n){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const o=dr(e,t);if(0>o)return null;if(Math.abs(e[o][0]-t)>n)return null;let r=o,i=o;o>0&&e[o][0]>=t?(r=o-1,i=o):e.length-1>o&&(r=o,i=o+1);const[s,a]=e[r],[c,l]=e[i];return c===s?a:a+Math.max(0,Math.min(1,(t-s)/(c-s)))*(l-a)}function nr(e,t,n,o=30){const r=t-e.x,i=n-e.y,s=Math.sqrt(r*r+i*i);return s>bo(e.r,o)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function or(e,t,n,o=30){const r=t-e.x,i=n-e.y,s=Math.sqrt(r*r+i*i);return s>bo(pn(e.size),o)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function rr(e,t,n,o=30){if(null==e.datum)return null;const r=Co(e.glyph,e.size),i=e.x+r.centerDx,s=e.y+r.centerDy,a=t-i,c=n-s,l=Math.sqrt(a*a+c*c);return l>bo(r.radius,o)?null:{node:e,datum:e.datum,x:i,y:s,distance:l}}function ir(e,t,n,o=30){if(0===e.path.length)return null;const r=dr(e.path,t);if(0>r)return null;const[i,s]=e.path[r];let a;if(e.path.length>1){let o=1/0;const i=Math.max(0,r-1),s=Math.min(e.path.length-2,r);for(let r=i;s>=r;r++){const[i,s]=e.path[r],[a,c]=e.path[r+1],l=sr(t,n,i,s,a,c);o>l&&(o=l)}a=o}else{const e=t-i,o=n-s;a=Math.sqrt(e*e+o*o)}const c=e.style;return a>Math.max(5,(c.strokeWidth??c.lineWidth??1)/2+2,o)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:i,y:s,distance:a}}function sr(e,t,n,o,r,i){const s=r-n,a=i-o,c=s*s+a*a;if(0===c)return Math.sqrt((e-n)**2+(t-o)**2);let l=((e-n)*s+(t-o)*a)/c;return l=Math.max(0,Math.min(1,l)),Math.sqrt((e-(n+l*s))**2+(t-(o+l*a))**2)}function ar(e,t,n){const o=xo(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function cr(e,t,n){const o=xo(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function lr(e,t,n){const o=e.bodyWidth/2,r=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=r+Math.max(Math.max(e.openY,e.closeY)-r,1)/2,i=t-e.x,s=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(i*i+s*s)}}return null}function ur(e,t,n){if(0===e.topPath.length)return null;const o=dr(e.topPath,t);if(0>o)return null;const[r,i]=e.topPath[o],s=t-r,a=n-i,c=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:r,y:i,distance:c}}function dr(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const r=n+o>>1;t>e[r][0]?n=r+1:o=r}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}var hr=require("react"),fr={fresh:1,aging:.7,stale:.45,expired:.25},pr={alpha:1,band:"fresh",isStale:!1};function yr(e,t){if(!e||0>=t)return pr;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,o=e.graded;if(o){const e="object"==typeof o?o:{},r=function(e,t,n={}){return Number.isFinite(t)&&t>0?Number.isNaN(e)?"fresh":e===1/0?"expired":0>e||t*(n.fresh??1)>e?"fresh":t*(n.aging??1.5)>e?"aging":t*(n.stale??3)>e?"stale":"expired":"fresh"}(t,n,e.thresholds);return{alpha:{...fr,...e.opacities??{}}[r],band:r,isStale:"fresh"!==r}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:pr}var gr=require("react/jsx-runtime");function mr({isStale:e,position:t}){return(0,gr.jsx)("div",{className:"stream-staleness-badge",style:{position:"absolute",..."top-left"===t?{top:4,left:4}:"bottom-left"===t?{bottom:4,left:4}:"bottom-right"===t?{bottom:4,right:4}:{top:4,right:4},padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",zIndex:3,background:e?"#dc3545":"#28a745",color:"white"},children:e?"STALE":"LIVE"})}var xr=require("react"),br=y(require("react"));function vr(...e){let t;for(const n of e)n&&(t=wr(t)&&wr(n)?{legendGroups:[...t.legendGroups,...n.legendGroups],legendDistance:n.legendDistance??t.legendDistance}:n);return t}function wr(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}function kr(e){return"object"==typeof e&&null!==e&&"gradient"in e}var Sr=16,Ar=6,Mr=10,_r=22,Pr=100,jr=10;function Cr(e){return Math.ceil(7*e.length)}function Rr(e,t){if(wr(e)){const n=Fr(t),o=e.legendGroups.flatMap(e=>[e.label?Cr(e.label):0,...e.items.map(e=>n.swatchSize+n.labelGap+Cr(e.label))]);return Math.max(Pr,...o)}if(kr(e)){const{gradient:t}=e,n=t.format||(e=>Math.round(100*e)/100+""),o=Math.max(Cr(n(t.domain[0])),Cr(n(t.domain[1]))),r=t.label?Cr(t.label):0;return Math.max(Pr,19+o,r)}return Pr}function Lr(e){return(wr(e)||kr(e))&&Number.isFinite(e.legendDistance)?Math.max(0,e.legendDistance):jr}function Ir(e){return Math.max(0,e?.sideGutter??0)}var Tr=22,$r=46,zr=64;function Dr(e,t){return null!=t?.axisGutter?Math.max(0,t.axisGutter):e?.hasAxis?e.hasAxisLabel?e.rotatedTicks?zr:$r:Tr:0}function Er(e,t,n){if(kr(e))return e.gradient.label?34:26;if(!wr(e))return 20;const o=Fr(n),r=Math.max(1,n?.maxWidth??t);let i=o.rowHeight;for(const t of e.legendGroups){let e=0,n=0;for(const i of t.items){const t=o.swatchSize+o.labelGap+Cr(i.label),s=0===n?t:n+o.itemGap+t;n>0&&s>r?(e+=1,n=t):n=s}t.items.length>0&&(e+=1),i=Math.max(i,e*o.rowHeight,t.label?Cr(t.label):0)}return i+(e.legendGroups.length>1?16:0)}function Or(e,t){return Rr(e,t)+Lr(e)+Ir(t)}function Fr(e){const t=Math.max(1,e?.swatchSize??Sr),n=Math.max(t,e?.rowHeight??_r);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??Ar),itemGap:Math.max(0,e?.itemGap??Mr),rowHeight:n,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}function Br(e,t){let n=24;return e.map(({hasLabel:e,itemCount:o})=>{n+=5;const r=n;let i;n+=8,e&&(n+=16,i=n,n+=8);const s=n;return n+=o*t+8,{lineY:r,labelY:i,itemsY:s,endY:n}})}var Nr=require("react/jsx-runtime"),Wr={fill:(e,t)=>(0,Nr.jsx)("rect",{style:e,width:t,height:t}),line:(e,t)=>(0,Nr.jsx)("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function qr(e,t,n,o,r){let i;return i="function"==typeof n?n(e):(0,Wr[n])(o(e,t),r),i}function Yr({swatchSize:e}){return(0,Nr.jsx)("path",{d:`M${.25*e},${.55*e} L${.45*e},${.75*e} L${.8*e},${.3*e}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Gr(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var Hr=(e,t,n,o,r,i,s,a,c,l,u)=>{const{type:d="fill",styleFn:h,items:f}=e,p=[];let y=0;const g=!(!t&&!n),m="isolate"===l||void 0===l&&null!=r,{swatchSize:x,labelGap:b,rowHeight:v}=u;return f.forEach((e,l)=>{const u=qr(e,l,d,h,x),w=Gr(e,o,r),k=r&&r.size>0&&r.has(e.label);p.push((0,Nr.jsxs)("g",{transform:`translate(0,${y})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:g?a===i&&l===s?0:-1:void 0,role:g?"option":void 0,"aria-selected":g&&m?k||!1:void 0,"aria-current":g&&!m&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:g?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowDown"===n.key||"ArrowUp"===n.key){n.preventDefault();const e=(l+("ArrowDown"===n.key?1:-1)+f.length)%f.length;c(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:g?t=>{c(a,l),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:g?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:g?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[g&&(0,Nr.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:x+b+2+7*e.label.length,height:x+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),u,k&&(0,Nr.jsx)(Yr,{swatchSize:x}),(0,Nr.jsx)("text",{y:x/2,x:x+b,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+l)),y+=v}),p};function Vr({config:e,orientation:t="vertical",width:n=100}){const{colorFn:o,domain:r,label:i,format:s}=e,a=s||(e=>Math.round(100*e)/100+""),c="grad-legend-"+br.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),s=Math.max(0,(n-t)/2),l=[];for(let e=0;64>=e;e++){const t=e/64;l.push((0,Nr.jsx)("stop",{offset:100*t+"%",stopColor:o(r[0]+t*(r[1]-r[0]))},e))}return(0,Nr.jsxs)("g",{"aria-label":i||"Gradient legend",children:[(0,Nr.jsx)("defs",{children:(0,Nr.jsx)("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:l})}),i&&(0,Nr.jsx)("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),(0,Nr.jsx)("rect",{x:s,y:0,width:t,height:e,fill:`url(#${c})`,rx:2}),(0,Nr.jsx)("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])}),(0,Nr.jsx)("text",{x:s+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])})]})}const l=[];for(let e=0;64>=e;e++){const t=e/64;l.push((0,Nr.jsx)("stop",{offset:100*t+"%",stopColor:o(r[1]-t*(r[1]-r[0]))},e))}return(0,Nr.jsxs)("g",{"aria-label":i||"Gradient legend",children:[i&&(0,Nr.jsx)("text",{x:0,y:-6,textAnchor:"start",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),(0,Nr.jsx)("defs",{children:(0,Nr.jsx)("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:l})}),(0,Nr.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),(0,Nr.jsx)("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[1])}),(0,Nr.jsx)("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(r[0])})]})}function Xr(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,legendInteraction:s,title:a="Legend",width:c=100,height:l=20,orientation:u="vertical",legendLayout:d}=e,h=Fr(d),[f,p]=br.useState(0),[y,g]=br.useState(0),m=br.useCallback((e,t)=>{p(e),g(t)},[]),x="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:c,legendInteraction:l,metrics:u})=>{const d=[],h=Br(e.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),u.rowHeight);return e.forEach((e,f)=>{const p=h[f];d.push((0,Nr.jsx)("line",{stroke:"gray",x1:0,y1:p.lineY,x2:t,y2:p.lineY},"legend-top-line legend-symbol-"+f)),e.label&&null!=p.labelY&&d.push((0,Nr.jsx)("text",{y:p.labelY,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label},"legend-text-"+f)),d.push((0,Nr.jsx)("g",{className:"legend-item",transform:`translate(0,${p.itemsY})`,children:Hr(e,n,o,r,i,s,a,f,c,l,u)},"legend-group-"+f))}),d})({legendGroups:t||[],width:c,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:s,metrics:h}):(({legendGroups:e,height:t,width:n,customClickBehavior:o,customHoverBehavior:r,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:c,onFocusedIndexChange:l,legendInteraction:u,metrics:d})=>{let h=0;const f=[];e.forEach((e,t)=>{let p=0;e.label&&(p+=16);const y=((e,t,n,o,r,i,s,a,c,l,u,d)=>{const{type:h="fill",styleFn:f,items:p}=e,y=[],{swatchSize:g,labelGap:m,itemGap:x,rowHeight:b,align:v}=u,w=!(!t&&!n),k="isolate"===l||void 0===l&&null!=r,S=p.map(e=>g+m+7*e.label.length),A=[];let M=0,_=0;S.forEach((e,t)=>{const n=0===_?e:_+x+e;d&&d>0&&_>0&&n>d?(A.push({start:M,end:t,width:_}),M=t,_=e):_=n}),p.length>0&&A.push({start:M,end:p.length,width:_}),A.forEach((e,l)=>{let u="center"===v?Math.max(0,((d??e.width)-e.width)/2):"end"===v?Math.max(0,(d??e.width)-e.width):0;for(let d=e.start;e.end>d;d++){const e=p[d],v=qr(e,d,h,f,g),A=Gr(e,o,r),M=r&&r.size>0&&r.has(e.label);y.push((0,Nr.jsxs)("g",{transform:`translate(${u},${l*b})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:w?a===i&&d===s?0:-1:void 0,role:w?"option":void 0,"aria-selected":w&&k?M||!1:void 0,"aria-current":w&&!k&&null!=o&&e.label===o||void 0,"aria-label":e.label,onKeyDown:w?n=>{if("Enter"!==n.key&&" "!==n.key||(n.preventDefault(),t&&t(e)),"ArrowRight"===n.key||"ArrowLeft"===n.key){n.preventDefault();const e=(d+("ArrowRight"===n.key?1:-1)+p.length)%p.length;c(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:w?t=>{c(a,d),n&&n(e);const o=t.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:w?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:w?"pointer":"default",opacity:A,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[w&&(0,Nr.jsx)("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:g+m+2+7*e.label.length,height:g+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),v,M&&(0,Nr.jsx)(Yr,{swatchSize:g}),(0,Nr.jsx)("text",{y:g/2,x:g+m,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:e.label})]},"legend-item-"+d)),u+=S[d]+x}});const P=Math.max(0,...A.map(e=>e.width)),j=A.length;return{items:y,offset:P,totalRows:j,totalHeight:j*b}})(e,o,r,i,s,a,c,t,l,u,d,d.maxWidth??n);p+=y.offset+5,f.push({label:e.label,...y,offset:p,totalRows:y.totalRows,totalHeight:y.totalHeight}),h+=p+12});const p=d.maxWidth??n;let y=h>p?0:"center"===d.align?Math.max(0,(p-h)/2):"end"===d.align?Math.max(0,p-h):0;const g=[];return f.forEach((n,o)=>{const r=e[o];r.label&&(g.push((0,Nr.jsx)("text",{transform:`translate(${y},0) rotate(90)`,textAnchor:"start",className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:r.label},"legend-text-"+o)),y+=16),g.push((0,Nr.jsx)("g",{className:"legend-item",transform:`translate(${y},0)`,children:n.items},"legend-group-"+o)),y+=n.offset+5,e[o+1]&&g.push((0,Nr.jsx)("line",{stroke:"gray",x1:y,y1:-8,x2:y,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+o)),y+=12}),(0,Nr.jsx)("g",{children:g})})({legendGroups:t||[],title:a,height:l,width:c,customClickBehavior:n,customHoverBehavior:o,highlightedCategory:r,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:s,metrics:h}),b=!(!n&&!o);return(0,Nr.jsxs)("g",{role:b?"listbox":void 0,"aria-multiselectable":!(!b||"isolate"!==s&&(void 0!==s||null==i))||void 0,"aria-label":"Chart legend",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[void 0!==a&&""!==a&&"vertical"===u&&(0,Nr.jsx)("text",{className:"legend-title",y:16,x:c/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),x]})}var Ur=require("react/jsx-runtime");function Kr(e){const{legend:t,totalWidth:n,totalHeight:o,margin:r,legendPosition:i="right",legendLayout:s,legendHoverBehavior:a,legendClickBehavior:c,legendHighlightedCategory:l,legendIsolatedCategories:u,legendInteraction:d}=e;if(!t)return null;const h="top"===i||"bottom"===i,f=Math.max(0,n-r.left-r.right),p=Math.max(1,h?s?.maxWidth??f:Rr(t,s)),y=Lr(t),g=Ir(s),m=Dr(e.axisChrome,s),x=Dr(void 0,s),b=Er(t,f,s);let v,w;if("left"===i)v=r.left-g-p-y,w=r.top;else if("top"===i)v=r.left,w=r.top-x-y-b;else if("bottom"===i){v=r.left;const e=o-r.bottom;w=Math.max(e+y,Math.min(e+m+y,o-b))}else v=n-r.right+g+y,w=r.top;return(0,Ur.jsx)("g",{transform:`translate(${v}, ${w})`,children:kr(t)?(0,Ur.jsx)(Vr,{config:t.gradient,orientation:h?"horizontal":"vertical",width:p}):wr(t)?(0,Ur.jsx)(Xr,{legendGroups:t.legendGroups,title:"",width:p,orientation:h?"horizontal":"vertical",legendLayout:s,customHoverBehavior:a,customClickBehavior:c,highlightedCategory:l,isolatedCategories:u,legendInteraction:d}):t})}var Zr=require("react"),Qr=require("d3-array"),Jr=require("react/jsx-runtime");function ei(e){return"string"==typeof e?{type:e}:e}function ti({orient:e,config:t,values:n,scale:o,size:r,length:i}){const s=function(e){return{type:e.type,bins:e.bins??20,fill:e.fill??"#4e79a7",fillOpacity:e.fillOpacity??.5,stroke:e.stroke??"none",strokeWidth:e.strokeWidth??1}}(t),a="top"===e||"bottom"===e,c=(0,Zr.useMemo)(()=>{if(0===n.length)return null;const t=o.domain(),c=r-8;if("boxplot"===s.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],r=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],s=i-o;return{q1:o,median:r,q3:i,whiskerLow:Math.max(t[0],o-1.5*s),whiskerHigh:Math.min(t[n-1],i+1.5*s)}}(n);if(!t)return null;const{q1:r,median:i,q3:l,whiskerLow:u,whiskerHigh:d}=t,h=Math.min(.5*c,20),f=(c-h)/2+4;if(a){const t=o(r),n=o(l),a=o(i),c=o(u),p=o(d),y="top"===e?-1:1,g=0;return(0,Jr.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,Jr.jsx)("line",{x1:c,y1:g+y*(f+h/2),x2:p,y2:g+y*(f+h/2),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Jr.jsx)("line",{x1:c,y1:g+y*f,x2:c,y2:g+y*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Jr.jsx)("line",{x1:p,y1:g+y*f,x2:p,y2:g+y*(f+h),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Jr.jsx)("rect",{x:Math.min(t,n),y:"top"===e?g-f-h:g+f,width:Math.abs(n-t),height:h,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),(0,Jr.jsx)("line",{x1:a,y1:"top"===e?g-f-h:g+f,x2:a,y2:"top"===e?g-f:g+f+h,stroke:s.fill,strokeWidth:2})]})}{const t=o(r),n=o(l),a=o(i),c=o(u),p=o(d),y="left"===e?-1:1,g=0;return(0,Jr.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,Jr.jsx)("line",{x1:g+y*(f+h/2),y1:c,x2:g+y*(f+h/2),y2:p,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Jr.jsx)("line",{x1:g+y*f,y1:c,x2:g+y*(f+h),y2:c,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Jr.jsx)("line",{x1:g+y*f,y1:p,x2:g+y*(f+h),y2:p,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Jr.jsx)("rect",{x:"left"===e?g-f-h:g+f,y:Math.min(t,n),width:h,height:Math.abs(n-t),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),(0,Jr.jsx)("line",{x1:"left"===e?g-f-h:g+f,y1:a,x2:"left"===e?g-f:g+f+h,y2:a,stroke:s.fill,strokeWidth:2})]})}}const l=(0,Qr.bin)().domain(t).thresholds(s.bins)(n);if(0===l.length)return null;const u=we(l.map(e=>e.length));if(0===u)return null;if("histogram"===s.type)return(0,Jr.jsx)("g",{"data-testid":"marginal-histogram-"+e,children:l.map((t,n)=>{if(null==t.x0||null==t.x1)return null;const r=t.length/u*c;if(a){const i=o(t.x0),a=o(t.x1)-o(t.x0);return(0,Jr.jsx)("rect",{x:i,y:"top"===e?-4-r:4,width:Math.max(a,.5),height:r,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}{const i=o(t.x0),a=o(t.x1)-o(t.x0);return(0,Jr.jsx)("rect",{x:"left"===e?-4-r:4,y:Math.min(i,i+a),width:r,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}})});if("violin"===s.type){const t=c/2+4,n=[];for(const r of l){if(null==r.x0||null==r.x1)continue;const i=r.length/u*(c/2),s=o((r.x0+r.x1)/2);n.push(a?`${s},${"top"===e?-(t-i):t-i}`:`${"left"===e?-(t-i):t-i},${s}`)}for(let r=l.length-1;r>=0;r--){const i=l[r];if(null==i.x0||null==i.x1)continue;const s=i.length/u*(c/2),d=o((i.x0+i.x1)/2);n.push(a?`${d},${"top"===e?-(t+s):t+s}`:`${"left"===e?-(t+s):t+s},${d}`)}return(0,Jr.jsx)("g",{"data-testid":"marginal-violin-"+e,children:(0,Jr.jsx)("polygon",{points:n.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}if("ridgeline"===s.type){const t=[];if(a){const n=0,r=null!=l[0].x0?o(l[0].x0):0;t.push(`M${r},${n}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const r=n.length/u*c,i=o((n.x0+n.x1)/2);t.push(`L${i},${"top"===e?-r-4:r+4}`)}const s=null!=l[l.length-1].x1?o(l[l.length-1].x1):i;t.push(`L${s},${n}`),t.push("Z")}else{const n=0,r=null!=l[0].x0?o(l[0].x0):0;t.push(`M${n},${r}`);for(const n of l){if(null==n.x0||null==n.x1)continue;const r=n.length/u*c,i=o((n.x0+n.x1)/2);t.push(`L${"left"===e?-r-4:r+4},${i}`)}const s=null!=l[l.length-1].x1?o(l[l.length-1].x1):i;t.push(`L${n},${s}`),t.push("Z")}return(0,Jr.jsx)("g",{"data-testid":"marginal-ridgeline-"+e,children:(0,Jr.jsx)("path",{d:t.join(" "),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth})})}return null},[n,o,s,r,i,e,a,4]);return c?(0,Jr.jsx)("g",{className:"marginal-"+e,"data-testid":"marginal-"+e,children:c}):null}var ni=y(require("react")),oi=require("react/jsx-runtime");function ri(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=e.split(/\s+/),i=[];let s="";for(const e of r)s&&s.length+1+e.length>o?(i.push(s),s=e):s=s?`${s} ${e}`:e;return s&&i.push(s),i}function ii(e,t,n,o){return"curly"===e?o?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:o?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function si(e,t,n,o){if(!e)return(0,oi.jsx)("g",{className:"annotation-note"});const{label:r,title:i,orientation:s,align:a,wrap:c=120,noWrap:l}=e;if(!r&&!i)return(0,oi.jsx)("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let d=a;d&&"dynamic"!==d||(d="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let h="start";"topBottom"===u?"right"===d?h="end":"middle"===d&&(h="middle"):h=0>t?"end":"start";const f=16,p=i?l?[i]:ri(i,c):[],y=r?l?[r]:ri(r,c):[],g="leftRight"===u?"end"===h?-4:4:0;let m=0;const x=[],b=o||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?x.push((0,oi.jsx)("foreignObject",{className:"annotation-note-html",x:"end"===h?g-c:"middle"===h?g-c/2:g,y:-16,width:c,height:Math.max(f,(p.length+y.length)*f+(i&&r?2:0))+f,style:{overflow:"visible"},children:(0,oi.jsxs)("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:b,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===h?"right":"middle"===h?"center":"left",whiteSpace:l?"nowrap":"normal",wordBreak:"break-word"},children:[i&&(0,oi.jsx)("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),r&&(0,oi.jsx)("div",{className:"annotation-note-label",children:r})]})},"annotation-note-html")):(p.length>0&&(x.push((0,oi.jsx)("text",{className:"annotation-note-title",fill:b,textAnchor:h,fontWeight:"bold",children:p.map((e,t)=>(0,oi.jsx)("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-title")),m=p.length*f),y.length>0&&x.push((0,oi.jsx)("text",{className:"annotation-note-label",fill:b,textAnchor:h,y:m,children:y.map((e,t)=>(0,oi.jsx)("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-label")));let v=null;if((i||r)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(c,120);let t=0,n=e;"end"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),v=(0,oi.jsx)("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(p.length+y.length)*f+(y.length>0?f:0);let t=0,n=e;"bottom"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),v=(0,oi.jsx)("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,p.length+y.length-1)*f;let k=0;return"topBottom"===u?k=0>n?-(w+2):18:"leftRight"===u&&(k="middle"===d?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===d||0>n?-(w+2):18),(0,oi.jsxs)("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[(0,oi.jsx)("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0,children:x}),v]})}function ai(e,t,n,o,r){const i=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&i.push((0,oi.jsx)("circle",{r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,o=t?.height||0;(e>0||o>0)&&i.push((0,oi.jsx)("rect",{width:e,height:o,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":t?.custom&&i.push(...Array.isArray(t.custom)?t.custom:[t.custom]);break;case"xy-threshold":{const e=o||0,s=r||0;if(void 0!==t?.x){const o=(t.x||0)-e;i.push((0,oi.jsx)("line",{x1:o,y1:(t.y1||0)-s,x2:o,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const o=(t.y||0)-s;i.push((0,oi.jsx)("line",{x1:(t.x1||0)-e,y1:o,x2:(t.x2||0)-e,y2:o,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?i.push((0,oi.jsx)("line",{x1:(t.x1||0)-e,y1:0,x2:(t.x2||0)-e,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===t?.y1&&void 0===t?.y2||i.push((0,oi.jsx)("line",{x1:0,y1:(t.y1||0)-s,x2:0,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const e=t?.type||"curly",o=t?.width??t?.height;void 0!==o&&i.push((0,oi.jsx)("path",{d:ii(e,o,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return(0,oi.jsx)("g",{className:"annotation-subject",children:i})}function ci(e,t,n,o,r,i){const s=[];let a=0,c=0;if("callout-circle"!==r&&"label"!==r||!i?.radius){if("callout-rect"===r&&i){const n=i.width||0,o=i.height||0;if(n>0||o>0){const r=n/2,i=o/2,s=e-r,l=t-i;if(0!==s||0!==l){const e=Math.abs(s),t=Math.abs(l),u=n/2,d=o/2,h=e*d>t*u?u/e:d/t;a=r+s*h,c=i+l*h}}}else if("bracket"===r&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(a=e/2,c=n):void 0!==t&&(a=n,c=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const o=Math.atan2(t,e);a=Math.cos(o)*n,c=Math.sin(o)*n}}const l=Math.sqrt((e-a)**2+(t-c)**2);if(l>.5){const r=o||"var(--semiotic-text-secondary, currentColor)",i="curve"===n?.type;let u=Math.atan2(t-c,e-a);if(i){const o=(a+e)/2,i=(c+t)/2,d=-(t-c)/l,h=(e-a)/l,f=(n?.curve??.25)*l,p=o+d*f,y=i+h*f;s.push((0,oi.jsx)("path",{className:"connector-curve",d:`M${a},${c}Q${p},${y} ${e},${t}`,fill:"none",stroke:r},"connector-line")),u=Math.atan2(y-c,p-a)}else s.push((0,oi.jsx)("line",{x1:a,y1:c,x2:e,y2:t,stroke:r},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;s.push((0,oi.jsx)("path",{d:`M${a},${c}L${a+e*Math.cos(u+t)},${c+e*Math.sin(u+t)}L${a+e*Math.cos(u-t)},${c+e*Math.sin(u-t)}Z`,fill:r,stroke:"none"},"connector-arrow"))}}return(0,oi.jsx)("g",{className:"annotation-connector",children:s})}function li(e){const{x:t=0,y:n=0,dx:o,dy:r,nx:i,ny:s,note:a,connector:c,subject:l,type:u,color:d,className:h,disable:f,opacity:p,strokeDasharray:y,events:g={},"data-testid":m}=e,x=Array.isArray(t)?t[0]??0:t,b=Array.isArray(n)?n[0]??0:n,v=new Set(Array.isArray(f)?f:[]);let w=o||0,k=r||0;null!=i&&(w=i-x),null!=s&&(k=s-b);const S="string"==typeof u?u:"label";if("bracket"===S&&l&&0===w&&0===k)if(void 0!==l.width){w=l.width/2;const e=l.depth||30;k=e+(0>e?-5:5)}else if(void 0!==l.height){const e=l.depth||30;w=e+(0>e?-5:5),k=l.height/2}return(0,oi.jsxs)("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${x},${b})`,"data-testid":m,...null!=p&&{opacity:p},...y&&{strokeDasharray:y},...g,children:[!v.has("connector")&&ci(w,k,c,d,S,l),!v.has("subject")&&ai(S,l,d,x,b),!v.has("note")&&si(a,w,k,d)]})}function ui(e){const{noteData:t}=e,{screenCoordinates:n}=t,o="string"==typeof t.type?t.type:"label",r=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),r=t.ny||n[0][1]+(t.dy??0),i=n.map((n,i)=>{const s=Object.assign({},t,{note:0===i?t.note:{label:""},x:n[0],y:n[1],nx:e,ny:r});return(0,oi.jsx)(li,{"data-testid":"semiotic-annotation",...s,type:o},"multi-annotation-"+i)});return(0,oi.jsx)("g",{children:i})}const i=t.note||{title:"none",label:t.label},s=`${i.label}-${i.title}-${t.i}`;return(0,oi.jsx)(li,{"data-testid":"semiotic-annotation",events:r,...t,type:o},s)}var di=require("d3-hierarchy"),hi=require("d3-shape");function fi(e){return Math.round(100*e)/100}function pi(e,t=2){const n=[],o=[],r=t+1;for(let t=0;r>t;t++){let i=0;for(const[n,o]of e)null!==o&&(i+=n**t*o);n.push(i);const s=[];for(let n=0;r>n;n++){let o=0;for(const[r,i]of e)null!==i&&(o+=r**(t+n));s.push(o)}o.push(s)}o.push(n);const i=function(e,t){const n=e,o=e.length-1,r=[t];for(let e=0;o>e;e++){let t=e;for(let r=e+1;o>r;r++)Math.abs(n[e][r])>Math.abs(n[e][t])&&(t=r);for(let r=e;o+1>r;r++){const o=n[r][e];n[r][e]=n[r][t],n[r][t]=o}for(let t=e+1;o>t;t++)for(let r=o;r>=e;r--)n[r][t]-=n[r][e]*n[e][t]/n[e][e]}for(let e=o-1;e>=0;e--){let t=0;for(let i=e+1;o>i;i++)t+=n[i][e]*r[i];r[e]=(n[o][e]-t)/n[e][e]}return r}(o,r).map(fi);return{points:e.map(([e])=>[fi(e),fi(i.reduce((t,n,o)=>t+n*e**o,0))]),equation:[...i].reverse()}}function yi(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function gi(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function mi(e){return null==e?null:e+""}function xi(e,t,n){return t.stickyPositionCache?.set(e,n),n}function bi(e,t,n){const o=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===e.pointId)return xi(t,n,{x:r.x,y:r.y})}const o=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],o=e.scales?.x??e.scales?.time,r=e.scales?.y??e.scales?.value;if(!o||!r)return null;const i=n[e.xAccessor||"x"],s=n[e.yAccessor||"y"];return null==i||null==s?null:{x:o(i),y:r(s)}}(n);return o?xi(t,n,o):null}if("semantic"===o){const o=function(e,t,n){const o=function(e){return mi(e.provenance?.stableId??e.stableId)}(e);if(!o)return null;const r=n.pointNodes?.find(e=>mi(e.pointId)===o);if(r)return xi(t,n,{x:r.x,y:r.y});const i=n.data?.find(e=>function(e){return mi(e.stableId??e.id??e.provenance?.stableId)}(e)===o);if(!i)return null;const s=yi(i,n),a=gi(i,n);return null==s||null==a?null:xi(t,n,{x:s,y:a})}(e,t,n);if(o)return o}let r=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(r=t.x,i=t.y)}if(null!=r&&null!=i||(r=yi(e,n),i=gi(e,n)),null!=r&&null!=i)return xi(t,n,{x:r,y:i});if("sticky"===o){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function vi(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}var wi=require("react/jsx-runtime"),ki={secondary:0,primary:3},Si=1,Ai=2,Mi=.6,_i="0.88em",Pi=.95,ji=.72,Ci=.06,Ri=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}",Li=".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}";function Ii(e){return!0===e?._annotationDeferred}function Ti(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function $i(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function zi(e){return Math.max(ji,Pi-e*Ci)}var Di=y(require("react")),[Ei,Oi]=Ne(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function Fi(e,t={}){const n=function(e){const t=e.provenance,n=e.id??e.stableId??t?.stableId;return null==n||""===n?void 0:n+""}(e);return{"data-semiotic-annotation-widget":"",...n?{"data-semiotic-annotation-id":n}:{},onClickCapture(o){const r=function(e){const t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}(o);t.onAnnotationActivate?.({annotation:e,annotationId:n,chartId:t.chartId,inputType:r}),n&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:n,inputType:r,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}var Bi=require("react/jsx-runtime"),Ni="var(--semiotic-bg, #ffffff)",Wi=.85;function qi(e){const{x:t,y:n,text:o,fill:r,fontSize:i=12,fontWeight:s,fontFamily:a,textAnchor:c="start",dominantBaseline:l,background:u,className:d}=e,h=function(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{type:e.type??"halo",...e}}(u),f=e=>(0,Bi.jsx)("text",{x:t,y:n,textAnchor:c,dominantBaseline:l,fill:r,fontSize:i,fontWeight:s,fontFamily:a,className:d,...e?{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}:{},children:o});if(!h)return f();if("halo"===h.type)return f({stroke:h.fill??Ni,strokeWidth:h.haloWidth??3});const p=h.padding??{x:6,y:3},y="number"==typeof p?p:p.x,g="number"==typeof p?p:p.y,m=function(e,t){return(e+"").length*t*.6}(o,i),x=i+2*g;let b,v;return b="middle"===c?t-m/2-y:"end"===c?t-m-y:t-y,v="middle"===l||"central"===l?n-x/2:"hanging"===l||"text-before-edge"===l?n-g:n-.8*i-g,(0,Bi.jsxs)("g",{className:d,children:[(0,Bi.jsx)("rect",{x:b,y:v,width:m+2*y,height:x,rx:h.radius??3,ry:h.radius??3,fill:h.fill??Ni,fillOpacity:h.opacity??Wi,stroke:h.stroke,strokeWidth:h.strokeWidth}),f()]})}var Yi=require("react/jsx-runtime"),Gi={linear:hi.curveLinear,monotoneX:hi.curveMonotoneX,monotoneY:hi.curveMonotoneY,step:hi.curveStep,stepAfter:hi.curveStepAfter,stepBefore:hi.curveStepBefore,basis:hi.curveBasis,cardinal:hi.curveCardinal,catmullRom:hi.curveCatmullRom};function Hi(e,t,n,o){const r=[];return e.forEach((e,i)=>{let s;if(n){const r=n(e,i,o);s=null!=r?r:t(e,i,o)}else s=t(e,i,o);s&&r.push({node:s,annotation:e})}),function(e){const t=e.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===n?.emphasis||"secondary"===n?.emphasis?n.emphasis:null),confidence:$i(e.annotation),readingOrder:null,rank:Si};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),o=e.some(e=>Ii(e.annotation)),r=e.some(e=>null!=Ti(e.annotation)),i=e.some(e=>"layer"===Ti(e.annotation));if(!n&&!o&&!r)return e.map(e=>e.node);const s=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);s.forEach((e,t)=>{e.readingOrder=t,e.rank=Ai-t/Math.max(1,s.length)});for(const e of t)e.emphasis&&(e.rank=ki[e.emphasis]);const a=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:n,emphasis:o,readingOrder:r}=e,i=Ii(t.annotation);let s=t.node;if("primary"===o||"secondary"===o||null!=r){const e=null==o&&null!=r;s=(0,wi.jsx)("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+o,..."secondary"===o?{opacity:Mi,fontSize:_i}:{},...e?{opacity:zi(r),"data-annotation-reading-order":r}:{},children:t.node},"annotation-emphasis-"+n)}const a=Ti(t.annotation);return a&&(s=(0,wi.jsx)("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),i&&(s=(0,wi.jsx)("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return o&&a.unshift((0,wi.jsx)("style",{children:Ri},"annotation-disclosure-style")),i&&a.unshift((0,wi.jsx)("style",{children:Li},"annotation-cohesion-style")),a}(r)}var Vi=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function Xi(e){return!!e&&"object"==typeof e&&Vi.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}new Set(["label","callout","callout-circle","callout-rect"]);var Ui=2e4,Ki=1;function Zi(e){return"primary"===e?.emphasis||!0===e?.defensive}function Qi(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:Ui))):1/0}function Ji(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const o=e?.provenance?.confidence;switch("number"==typeof o&&Number.isFinite(o)&&(t+=15*Math.max(0,Math.min(1,o))),e?.lifecycle?.freshness){case"fresh":t+=8;break;case"aging":t+=4;break;case"stale":t+=1;break;case"expired":t-=200}return t}var es=32,ts=6,ns=4,os=8,rs=72,is=30,ss=-30,as=8,cs=480,ls=3;var us={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function ds(e){if(!hs(e))return e;const t=("string"==typeof e.mobileText?e.mobileText:void 0)??("string"==typeof e.shortText?e.shortText:void 0);return!t||"string"!=typeof e.label&&null!=e.label?e:{...e,label:t}}function hs(e){return Xi(e)}function fs(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),o=e.split(/\s+/).filter(Boolean),r=[];let i="";for(const e of o)i&&i.length+e.length+1>n?(r.push(i),i=e):i=i?`${i} ${e}`:e;return i&&r.push(i),r}function ps(e,t,n,o,r){const i=e+n,s=t+o;return Math.abs(n)>Math.abs(o)?{x:0>n?i-r.width-4:i+4,y:0>o?s-r.height:s,width:r.width,height:r.height}:{x:0>n?i-r.width:i,y:0>o?s-r.height-4:s+4,width:r.width,height:r.height}}function ys(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function gs(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function ms(e,t,n,o,r,i,s,a){const c=ys(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,o){const r=Math.max(0,o-e.x),i=Math.max(0,o-e.y);return(r+Math.max(0,e.x+e.width-(t-o)))*e.height+(i+Math.max(0,e.y+e.height-(n-o)))*e.width}(c,r,i,a);for(const e of n)l+=12*gs(c,e);for(const e of o)l+=4*gs(c,e);return l}function xs(e){const{annotations:t,context:n,defaultOffset:o=es,notePadding:r=ts,markPadding:i=ns,edgePadding:s=os,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=rs,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:p,cohesion:y,audience:g}=e,m=n.width||0,x=n.height||0,b="object"==typeof p?p:{},v=b.breakpoint??cs,w=!!p&&v>=m,k=w&&!1!==b.preferShortText?t.map(ds):t,S=w&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,A=d||w&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),M=w&&!f?b.responsive??{minWidth:v}:f,_=w&&!y?b.cohesion:y;if(0===k.length||0>=m||0>=x)return k.slice();const P=[],j=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(n,i);let C=!1;const R=k.map((e,t)=>{if(!hs(e))return e;const i=function(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const o=e.pointId??e.nodeId;if(null!=o&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===o);if(e)return{x:e.x,y:e.y}}const r=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(r)&&r.length>=2&&i){const e=r[0],t=r[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?bi(e,t,n):{x:e.x,y:e.y}}(e,t,n);if(!i)return e;const u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,n=[...fs("string"==typeof e.title?e.title:void 0,t),...fs("string"==typeof e.label?e.label:void 0,t)],o=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*o)+10),height:Math.max(18,16*n.length+6)}}(e);if(a&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:is,dy:ss}}(e);return P.push(ys(ps(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),r)),e}var d;let h=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(o)){const t=ms(ps(i.x,i.y,e.dx,e.dy,u),e,P,j,m,x,r,s);f>t&&(h=e,f=t)}if(!h)return e;const p=ys(ps(i.x,i.y,h.dx,h.dy,u),r);P.push(p);const y=Math.hypot(h.dx,h.dy),g=c&&y>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return C=!0,{...e,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),L=C?R:k.slice();let I=L;if(h){let e=!1;const t=L.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)<as?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});I=e?t:L}{let e=!1;const t=I.map(t=>{if(!0!==t?.defensive)return t;const n=function(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?us[t.source]??t.source:null,o="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!o)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const r=[n,o].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${r})`)?e:{...e,label:i?`${i} (${r})`:`(${r})`}}(t);return n!==t&&(e=!0),n});I=e?t:I}const T=new Set;if(S){const e="object"==typeof S?S:{},t=function(e){if(!e)return 1;const t=function(e){const t=e?.familiarity;if(!t)return ls;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?ls:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(g),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??Qi(m,x,e))*t))},{deferred:o}=function(e){const{annotations:t,width:n,height:o}=e,r=Math.max(0,e.minVisible??Ki),i=Qi(n,o,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,Xi(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||i>=a.length)return{visible:t.slice(),deferred:[],budget:i};const c=a.filter(e=>Zi(e.annotation)),l=a.filter(e=>!Zi(e.annotation)).sort((e,t)=>Ji(t.annotation)-Ji(e.annotation)||e.index-t.index),u=Math.min(l.length,Math.max(Math.max(0,i-c.length),Math.max(0,r-c.length))),d=new Set([...c.map(e=>e.index),...l.slice(0,u).map(e=>e.index)]),h=[],f=[];for(const{annotation:e,index:t,note:n}of s)!n||d.has(t)?h.push(e):f.push(e);return{visible:h,deferred:f,budget:i}}({annotations:I,width:m,height:x,...n});for(const e of o)T.add(e)}if(M&&("object"==typeof M&&"number"==typeof M.minWidth?M.minWidth:cs)>=m)for(const e of I)hs(e)&&"secondary"===e.emphasis&&T.add(e);if(T.size>0)for(const e of I)!0===e?.defensive&&T.delete(e);let $;return $=0===T.size?I:A?I.map(e=>T.has(e)?{...e,_annotationDeferred:!0}:e):I.filter(e=>!T.has(e)),_?function(e,t){let n=!1;const o=e.map(e=>hs(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?o:e}($,_):$}function bs(e,t={}){const n=!0===t.showRetractedAnnotations,o=!0===t.showSupersededAnnotations,r=new Set;for(const t of e){const e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&r.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!n)return!1;const t=e?.provenance?.stableId;return!(t&&r.has(t)&&!o)})}var vs=require("react"),ws={positions:new Map},ks=new Set;function Ss(){for(const e of ks)e()}function As(e,t){const n=ws.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const o=new Map(ws.positions);o.delete(e),ws={positions:o},Ss()}function Ms(e,t){const n=ws.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const o=new Map(ws.positions);o.delete(e),ws={positions:o},Ss()}function _s(){return ws}function Ps(e){return ks.add(e),()=>ks.delete(e)}var js={positions:new Map};function Cs(){return()=>{}}function Rs(){return js}function Ls(e,t,n){return"exact"===n?function(e,t){const n=e.domain(),o=n[0],r=n[n.length-1],i=o instanceof Date,s=o instanceof Date?o.getTime():o,a=r instanceof Date?r.getTime():r;if(2>t||s===a)return i?[new Date(s),new Date(a)]:[s,a];const c=(a-s)/(t-1),l=Array(t);for(let e=0;t>e;e++){const n=e===t-1?a:s+e*c;l[e]=i?new Date(n):n}return l}(e,t):e.ticks(t)}function Is(e,t,n){if("edges"===e){if(t)return"start";if(n)return"end"}return"middle"}function Ts(e,t,n){if("edges"===e){if(t)return"hanging";if(n)return"auto"}return"middle"}function $s(e){if(0===e.length)return{min:null,max:null};let t=1/0,n=-1/0;for(const o of e)t>o.pixel&&(t=o.pixel),o.pixel>n&&(n=o.pixel);return{min:t,max:n}}function zs(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Ds(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,r="left"===e?-1:1,i=Math.ceil(t/8);let s="M0,"+o;for(let e=0;i>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${o+4*r}`,s+=`L${Math.min(n,t)},${o}`}return s}const o="bottom"===e?0:t,r="bottom"===e?1:-1,i=Math.ceil(n/8);let s=`M${o},0`;for(let e=0;i>e;e++){const t=8*(e+1);s+=`L${o+4*r},${Math.min(8*e+4,n)}`,s+=`L${o},${Math.min(t,n)}`}return s}var Es=36,Os=34,Fs=58,Bs=22;function Ns(e){return"string"==typeof e&&e.length>0}function Ws(e,t,n=!1){const o=n?t?Fs:Os:t?Es:0;return o>e.top?{...e,top:o}:e}function qs(e,t){return Ws(e,Ns(t))}var Ys=require("react/jsx-runtime");function Gs(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,scales:s,showAxes:a,axes:c,showGrid:l,xFormat:u,yFormat:d,axisExtent:h}=e,f=(0,xr.useMemo)(()=>{if(!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||u||Hs,o=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,i="exact"===h?Math.max(2,r):Math.min(r,o),a=e?.tickValues??Ls(s.x,i,h),l=a.map(e=>e.valueOf()),d=a.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,l)})),f=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return Vs(d,Math.max(55,f+8))},[s,c,u,t,h]),p=(0,xr.useMemo)(()=>{if(!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||d||Hs,o=Math.max(2,Math.floor(n/30)),r=e?.ticks??5,i="exact"===h?Math.max(2,r):Math.min(r,o);return Vs((e?.tickValues??Ls(s.y,i,h)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[s,c,d,n,h]),y=l&&s,g=a&&s;if(!y&&!g)return null;const m=c?.find(e=>"bottom"===e.orient),x=c?.find(e=>"left"===e.orient),b=g&&(!m||!1!==m.baseline),v=g&&(!x||!1!==x.baseline),w=m?.jaggedBase||!1,k=x?.jaggedBase||!1,S="var(--semiotic-border, #ccc)";return(0,Ys.jsx)("svg",{width:o,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:(0,Ys.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[y&&(()=>{const e=zs(c?.find(e=>"bottom"===e.orient)?.gridStyle),o=zs(c?.find(e=>"left"===e.orient)?.gridStyle);return(0,Ys.jsxs)("g",{className:"stream-grid",children:[f.map((t,o)=>(0,Ys.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+o)),p.map((e,n)=>(0,Ys.jsx)("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"ygrid-"+n))]})})(),b&&!w&&(0,Ys.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:S,strokeWidth:1}),w&&(0,Ys.jsx)("path",{d:Ds("bottom",t,n),fill:"none",stroke:S,strokeWidth:1}),v&&!k&&(0,Ys.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:S,strokeWidth:1}),k&&(0,Ys.jsx)("path",{d:Ds("left",t,n),fill:"none",stroke:S,strokeWidth:1})]})})}function Hs(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function Vs(e,t){if(2>=e.length)return e;const n=[e[0]];for(let o=1;e.length-1>o;o++)t>Math.abs(e[o].pixel-n[n.length-1].pixel)||n.push(e[o]);const o=e[e.length-1];return t>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function Xs(e){const{width:t,height:n,totalWidth:o,totalHeight:r,margin:i,scales:s,showAxes:a,axes:c,xLabel:l,yLabel:u,yLabelRight:d,xFormat:h,yFormat:f,axisExtent:p,showGrid:y,title:g,legend:m,legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:v,legendIsolatedCategories:w,legendPosition:k="right",legendLayout:S,foregroundGraphics:A,marginalGraphics:M,xValues:_,yValues:P,annotations:j,onAnnotationActivate:C,onObservation:R,chartId:L,chartType:I,autoPlaceAnnotations:T,svgAnnotationRules:$,xAccessor:z,yAccessor:D,annotationData:E,pointNodes:O,curve:F,underlayRendered:B,canvasObscuresUnderlay:N=!0,linkedCrosshairName:W,linkedCrosshairSourceId:q,children:Y}=e,G=function(e){const t=Oi(e=>e.pushObservation),n=Di.useCallback(n=>{e.onObservation?.(n),t?.(n)},[e,t]);return Di.useMemo(()=>({...e,onObservation:n}),[n,e])}({onAnnotationActivate:C,onObservation:R,chartId:L,chartType:I}),H=Ir(S),V=m&&"left"===k&&H>0?H:i.left,X=m&&"right"===k&&H>0?H:i.right,U=(0,xr.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"bottom"===e.orient),n=e?.tickFormat||h||Hs,o=Math.max(2,Math.floor(t/70)),r=e?.ticks??5,i="exact"===p?Math.max(2,r):Math.min(r,o),l=e?.tickValues??Ls(s.x,i,p),u=l.map(e=>e.valueOf()),d=l.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,u)})),f=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0),y=e?.autoRotate?Math.max(20,Math.min(f+8,55)):Math.max(55,f+8);let g=Vs(d,y);if(g.length>1&&(g=g.filter((e,t)=>0===t||e.label+""!=g[t-1].label+"")),e?.includeMax&&g.length>0&&"exact"!==p&&!e?.tickValues){const e=s.x.domain()[1],t=s.x(e),o=g[g.length-1].pixel;if(Math.abs(t-o)>1){const r=n(e,g.length,u);y>t-o&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:r})}}return g},[a,s,c,h,t,p]),K=(0,xr.useMemo)(()=>{const e=c?.find(e=>"bottom"===e.orient);if(!e?.autoRotate||1>=U.length)return!1;const n=t/Math.max(U.length-1,1);return U.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>n},[c,U,t]),Z=(0,xr.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"left"===e.orient),t=e?.tickFormat||f||Hs,o=Math.max(2,Math.floor(n/30)),r=e?.ticks??5,i="exact"===p?Math.max(2,r):Math.min(r,o);let l=Vs((e?.tickValues??Ls(s.y,i,p)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22);if(l.length>1&&(l=l.filter((e,t)=>0===t||e.label+""!=l[t-1].label+"")),e?.includeMax&&l.length>0&&"exact"!==p&&!e?.tickValues){const e=s.y.domain()[1],n=s.y(e),o=l[l.length-1].pixel;if(Math.abs(n-o)>1){const r=t(e);22>Math.abs(n-o)&&l.length>1&&(l=l.slice(0,-1)),l.push({value:e,pixel:n,label:r})}}return l},[a,s,c,f,n,p]),Q=(0,xr.useMemo)(()=>{if(!a||!s)return[];const e=c?.find(e=>"right"===e.orient);if(!e)return[];const t=e.tickFormat||f||Hs,o=Math.max(2,Math.floor(n/30)),r=e.ticks??5;return Vs((e.tickValues??Ls(s.y,"exact"===p?Math.max(2,r):Math.min(r,o),p)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[a,s,c,f,n,p]),J=(0,xr.useRef)(new Map),ee=(0,xr.useRef)(j?.length??0),te=j?.length??0;ee.current!==te&&(ee.current=te,J.current=new Map);const ne=(0,xr.useMemo)(()=>{if(!j||0===j.length)return null;const e=bs(j),o=function(e,t={}){return function(e,n,o){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const t=bi(e,n,o);if(!t)return null;const{x:r,y:i}=t;if(!vi(r,i,o))return null;const s="callout"===e.type?"callout-circle":e.type,a="callout-circle"===s?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===s?{width:e.width,height:e.height}:void 0;return(0,Yi.jsx)(ui,{noteData:{x:r,y:i,dx:e.dx??30,dy:e.dy??-30,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:s,...a?{subject:a}:{},connector:e.connector||{end:"arrow"},color:e.color,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-"+n)}case"x-threshold":{const t=yi(null!=e.value?{...e,x:e.value}:e,o);if(null==t)return null;const r=e.color||"#f97316",i=e.labelPosition||"top";let s;s="bottom"===i?(o.height||0)-4:"center"===i?(o.height||0)/2:16;const a=t>.6*(o.width||0),c=a?t-4:t+4,l=a?"end":"start";return(0,Yi.jsxs)("g",{opacity:e.opacity,children:[(0,Yi.jsx)("line",{x1:t,y1:0,x2:t,y2:o.height||0,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Yi.jsx)(qi,{x:c,y:s,text:e.label,textAnchor:l,fill:r,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"y-threshold":{const t=gi(null!=e.value?{...e,y:e.value}:e,o);if(null==t)return null;const r=e.color||"#f97316",i=e.labelPosition||"right";let a,c;"left"===i?(a=4,c="start"):"center"===i?(a=(o.width||0)/2,c="middle"):(a=(o.width||0)-4,c="end");const l=20>(s=t)?Math.min((o.height||0)-4,s+16):s-4;return(0,Yi.jsxs)("g",{opacity:e.opacity,children:[(0,Yi.jsx)("line",{x1:0,y1:t,x2:o.width||0,y2:t,stroke:r,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Yi.jsx)(qi,{x:a,y:l,text:e.label,textAnchor:c,fill:r,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"enclose":{const t=(e.coordinates||[]).map(e=>({x:yi({...e,type:"point"},o),y:gi({...e,type:"point"},o),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const r=(0,di.packEnclose)(t),i=e.padding||10;return(0,Yi.jsxs)("g",{children:[(0,Yi.jsx)("circle",{cx:r.x,cy:r.y,r:r.r+i,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,Yi.jsx)(qi,{x:r.x,y:r.y-r.r-i-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"rect-enclose":{const t=(e.coordinates||[]).map(e=>({x:yi({...e,type:"point"},o),y:gi({...e,type:"point"},o)})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const r=e.padding||10,i=t.map(e=>e.x),s=t.map(e=>e.y),[a,c]=ve(i),[l,u]=ve(s),d=a-r,h=c+r,f=l-r;return(0,Yi.jsxs)("g",{children:[(0,Yi.jsx)("rect",{x:d,y:f,width:h-d,height:u+r-f,fill:e.fill||"none",fillOpacity:e.fillOpacity||.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&(0,Yi.jsx)(qi,{x:(d+h)/2,y:f-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+n)}case"highlight":{const t=o.data||[],r="function"==typeof e.filter?t.filter(e.filter):e.field&&null!=e.value?t.filter(t=>t[e.field]===e.value):[],i={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return(0,Yi.jsx)("g",{children:r.map((t,n)=>{const r=yi(t,o),s=gi(t,o);if(null==r||null==s)return null;const a="function"==typeof e.r?e.r(t):e.r||6,c="function"==typeof e.style?e.style(t):e.style||i;return(0,Yi.jsx)("circle",{cx:r,cy:s,r:a,...c},"hl-"+n)})},"ann-"+n)}case"bracket":{const t=yi(e,o),r=gi(e,o);return(0,Yi.jsx)(ui,{noteData:{x:t??0,y:r??0,dx:e.dx||0,dy:e.dy||0,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+n)}case"trend":{const t=o.data||[];if(2>t.length)return null;const r=o.xAccessor||"x",i=o.yAccessor||"y",s="ordinal"===o.frameType,a="horizontal"===o.projection,c=s?r:null,l=s?i:null;let u;const d=[],h=new Map;if(s&&c&&l){for(const e of t){const t=e[c];if(null==t)continue;const n=t+"";h.has(n)||(h.set(n,d.length),d.push(n))}u=t.map(e=>{const t=e[c],n=e[l];if(null==t||null==n)return null;const o=h.get(t+"");return null!=o?[o,+n]:null}).filter(e=>null!==e)}else u=t.map(e=>[e[r],e[i]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const f=o.scales?.x??o.scales?.time,p=o.scales?.y??o.scales?.value;if(!f||!p)return null;const y=e=>t=>{const n=Math.max(0,Math.floor(t)),o=Math.min(d.length-1,n+1),r=t-n,i=e(d[n]);return i+(e(d[o])-i)*r},g=f,m=p;let x;if(s)if(a){const e=y(m);x=(t,n)=>[g(n),e(t)]}else{const e=y(g);x=(t,n)=>[e(t),m(n)]}else x=(e,t)=>[g(e),m(t)];const b=e.method||"linear";let v;if("loess"===b)v=function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),r=o.map(e=>e[0]),i=o.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=r[e],o=r.map(e=>Math.abs(e-t)),c=o.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,l=[];for(let e=0;n>e;e++){const t=0===c?0:o[e]/c;l[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,f=0,p=0;for(let e=0;n>e;e++){const t=l[e];0!==t&&(u+=t,d+=t*r[e],h+=t*i[e],f+=t*r[e]*r[e],p+=t*r[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const y=u*f-d*d;if(1e-12>Math.abs(y))a.push([t,h/u]);else{const e=(u*p-d*h)/y;a.push([t,(h-e*d)/u+e*t])}}return a}(u,e.bandwidth??.3);else{const t="polynomial"===b?pi(u,e.order||2):function(e){const t=[0,0,0,0];let n=0;for(const[o,r]of e)null!==r&&(n++,t[0]+=o,t[1]+=r,t[2]+=o*o,t[3]+=o*r);const o=n*t[2]-t[0]*t[0],r=0===o?0:fi((n*t[3]-t[0]*t[1])/o),i=fi(t[1]/n-r*t[0]/n);return{points:e.map(([e])=>[fi(e),fi(r*e+i)]),equation:[r,i]}}(u);v=t.points}const w=v.map(([e,t])=>{const[n,o]=x(e,t);return`${n},${o}`}).join(" "),k=e.color||"#6366f1",S=v[v.length-1],[A,M]=x(S[0],S[1]);return(0,Yi.jsxs)("g",{children:[(0,Yi.jsx)("polyline",{points:w,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Yi.jsx)("text",{x:A+4,y:M-4,fill:k,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const t=o.scales?.y??o.scales?.value,s=t?.domain?.(),a=e.y0??s?.[0],c=e.y1??s?.[1],l=null!=a&&t?t(a):0,u=null!=c&&t?t(c):o.height||0,d=Yo(e.fill,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,Yi.jsxs)("g",{opacity:e.opacity,children:[d.def&&(0,Yi.jsx)("defs",{children:d.def}),(0,Yi.jsx)("rect",{x:0,y:Math.min(l,u),width:o.width||0,height:Math.abs(u-l),fill:d.fill,fillOpacity:e.fillOpacity||.1}),e.label&&(0,Yi.jsx)(qi,{x:(o.width||0)-4,y:(r=l,i=u,Math.max(Math.min(r,i),0)+16),textAnchor:"end",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"x-band":{const t=o.scales?.x??o.scales?.time,r=t?.domain?.(),i=e.x0??r?.[0],s=e.x1??r?.[1],a=null!=i&&t?t(i):null,c=null!=s&&t?t(s):null;if(null==a||null==c)return null;const l=Yo(e.fill||e.color,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,Yi.jsxs)("g",{opacity:e.opacity,children:[l.def&&(0,Yi.jsx)("defs",{children:l.def}),(0,Yi.jsx)("rect",{x:Math.min(a,c),y:0,width:Math.abs(c-a),height:o.height||0,fill:l.fill,fillOpacity:e.fillOpacity??.1}),e.label&&(0,Yi.jsx)(qi,{x:Math.min(a,c)+4,y:16,textAnchor:"start",fill:e.color||"var(--semiotic-primary, #6366f1)",fontSize:11,fontWeight:"bold",text:e.label,background:e.labelBackground??"halo"})]},"ann-"+n)}case"envelope":{const t=o.data||[];if(2>t.length)return null;const r=o.xAccessor||"x",i=o.scales?.x??o.scales?.time,s=o.scales?.y??o.scales?.value;if(!i||!s)return null;const a=e.upperAccessor||"upperBounds",c=e.lowerAccessor||"lowerBounds",l=e.filter,u=t.filter(e=>null!=e[a]&&null!=e[c]&&!(l&&!l(e))).sort((e,t)=>e[r]-t[r]);if(2>u.length)return null;const d=Gi[o.curve||"linear"]||hi.curveLinear,h=(0,hi.area)().x(e=>i(e[r])).y0(e=>s(e[c])).y1(e=>s(e[a])).curve(d)(u);if(!h)return null;const f=e.fill||"#6366f1";return(0,Yi.jsxs)("g",{children:[(0,Yi.jsx)("path",{d:h,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&(0,Yi.jsx)("text",{x:i(u[u.length-1][r])+4,y:s(u[u.length-1][a])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const t=o.data||[];if(2>t.length)return null;const r=o.yAccessor||"y",i=o.scales?.x??o.scales?.time,s=o.scales?.y??o.scales?.value;if(!i||!s)return null;const a=t.map(e=>e[r]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const c=a.reduce((e,t)=>e+t,0)/a.length,l=a.reduce((e,t)=>e+(t-c)**2,0)/a.length,u=Math.sqrt(l),d=e.threshold??2,h=c-d*u,f=!1!==e.showBand,p=e.fill||"#6366f1",y=e.fillOpacity??.1,g=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,x=s(c+d*u),b=s(h),v=t.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-c)>d*u});return(0,Yi.jsxs)("g",{children:[f&&(0,Yi.jsx)("rect",{x:0,y:Math.min(x,b),width:o.width||0,height:Math.abs(b-x),fill:p,fillOpacity:y}),v.map((e,t)=>{const n=yi(e,o),r=gi(e,o);return null==n||null==r?null:(0,Yi.jsx)("circle",{cx:n,cy:r,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+t)}),e.label&&(0,Yi.jsx)("text",{x:(o.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:p,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const t=o.data||[];if(3>t.length)return null;const r=o.xAccessor||"x",i=o.yAccessor||"y",s=o.scales?.x??o.scales?.time,a=o.scales?.y??o.scales?.value;if(!s||!a)return null;const c=t.map(e=>[e[r],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;let l;if("polynomial"===(e.method||"linear")){const t=pi(c,e.order||2).equation;l=e=>t.reduce((t,n,o)=>t+n*Math.pow(e,o),0)}else{const e=c.length;let t=0,n=0,o=0,r=0;for(const[e,i]of c)t+=e,n+=i,o+=e*e,r+=e*i;const i=e*o-t*t;if(1e-12>Math.abs(i))return null;const s=(e*r-t*n)/i,a=(n-s*t)/e;l=e=>a+s*e}const u=c.length,d=c.map(([e,t])=>t-l(e)),h=d.reduce((e,t)=>e+t*t,0),f=Math.sqrt(h/Math.max(u-2,1)),p=c.reduce((e,t)=>e+t[0],0)/u,y=c.reduce((e,t)=>e+(t[0]-p)**2,0),g=e.confidence??.95,m=.99>g?.95>g?.9>g?1:1.645:1.96:2.576,x=e.steps??5,b=c[u-1][0],v=(b-c[0][0])/Math.max(u-1,1),w=[];for(let e=1;x>=e;e++)w.push(b+e*v);const k=[];for(const e of w){const t=l(e),n=f*Math.sqrt(1+1/u+(y>0?(e-p)**2/y:0))*m;k.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}const S=`M${k.map(e=>`${s(e.x)},${a(e.yUpper)}`).join(" L")} L${k.slice().reverse().map(e=>`${s(e.x)},${a(e.yLower)}`).join(" L")} Z`,A=k.map(e=>`${s(e.x)},${a(e.yCenter)}`).join(" "),M=`${s(b)},${a(l(b))}`,_=e.strokeColor||"#6366f1";return(0,Yi.jsxs)("g",{children:[(0,Yi.jsx)("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),(0,Yi.jsx)("polyline",{points:`${M} ${A}`,fill:"none",stroke:_,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&k.length>0&&(0,Yi.jsx)("text",{x:s(k[k.length-1].x)+4,y:a(k[k.length-1].yCenter)-4,fill:_,fontSize:11,children:e.label})]},"ann-"+n)}case"widget":{let r,i;if(null!=e.px&&null!=e.py)r=e.px,i=e.py;else{const t=bi(e,n,o);if(!t)return null;r=t.x,i=t.y}if(!vi(r,i,o))return null;const s=e.dx??0,a=e.dy??0,c=e.width??32,l=e.height??32,u=e.content??(0,Yi.jsx)("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return(0,Yi.jsx)("foreignObject",{x:r+s-c/2,y:i+a-l/2,width:c,height:l,style:{overflow:"visible",pointerEvents:"auto"},children:(0,Yi.jsx)("div",{...Fi(e,t),style:{width:c,height:l,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const t=bi(e,n,o);if(!t)return null;const{x:r,y:i}=t,s=r+(e.dx||0),a=i+(e.dy||0),c=e.color||"var(--semiotic-text, #333)",l=(0,Yi.jsx)("text",{x:s,y:a,fill:c,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?ni.cloneElement(l,{key:"ann-text-"+n}):(0,Yi.jsxs)("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[(0,Yi.jsx)("line",{x1:r,y1:i,x2:s,y2:a,stroke:c,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),ni.cloneElement(l,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+n)}case"category-highlight":{const t=e.category;if(null==t)return null;const r=e=>"function"==typeof e&&"function"==typeof e.bandwidth,i=o.scales?.o,s=o.scales?.x,a=o.scales?.y,c=r(i)?i:r(s)?s:r(a)?a:null;if(!c)return null;const l=c(t+"");if(null==l)return null;const u=c.bandwidth(),d=e.color||"var(--semiotic-primary, #4589ff)",h=e.opacity??.15,f=e.label;return(0,Yi.jsxs)("g",(o.projection?"vertical"===o.projection:c===s)?{children:[(0,Yi.jsx)("rect",{x:l,y:0,width:u,height:o.height||0,fill:d,fillOpacity:h}),f&&(0,Yi.jsx)(qi,{x:l+u/2,y:16,textAnchor:"middle",fill:d,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]}:{children:[(0,Yi.jsx)("rect",{x:0,y:l,width:o.width||0,height:u,fill:d,fillOpacity:h}),f&&(0,Yi.jsx)(qi,{x:12,y:l+u/2,dominantBaseline:"middle",fill:d,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]},"ann-"+n)}default:return null}var r,i,s}}(0,G),r={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:z,yAccessor:D,width:t,height:n,data:E,frameType:"xy",pointNodes:O,curve:F,stickyPositionCache:J.current};return Hi(T?xs({annotations:e,context:r,..."object"==typeof T?T:{}}):e,o,$,r)},[j,T,$,t,n,z,D,E,s,O,F,G]),oe=function(e){const t=(0,vs.useSyncExternalStore)(e?Ps:Cs,e?_s:Rs,e?_s:Rs);return e?t.positions.get(e)??null:null}(W);return(0,xr.useEffect)(()=>{if(!oe?.locked||!W)return;const e=e=>{"Escape"===e.key&&Ms(W)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[oe?.locked,W]),a||g||m||A||M||ne&&ne.length>0||y||Y||oe?(0,Ys.jsxs)("svg",{role:"img",width:o,height:r,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[(0,Ys.jsx)("title",{children:"string"==typeof g?g:"XY Chart"}),(0,Ys.jsx)("desc",{children:"string"==typeof g?g+" (XY data visualization)":"XY data visualization"}),(0,Ys.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[y&&s&&(!B||N)&&(()=>{const e=zs(c?.find(e=>"bottom"===e.orient)?.gridStyle),o=zs(c?.find(e=>"left"===e.orient)?.gridStyle);return(0,Ys.jsxs)("g",{className:"stream-grid",children:[U.map((t,o)=>(0,Ys.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+o)),Z.map((e,n)=>(0,Ys.jsx)("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"ygrid-"+n))]})})(),a&&s&&(()=>{const e=c?.find(e=>"left"===e.orient),o=c?.find(e=>"bottom"===e.orient),r=!e||!1!==e.baseline,i=!o||!1!==o.baseline,s=e?.jaggedBase||!1,a=o?.jaggedBase||!1,h=o?.landmarkTicks,f=e?.landmarkTicks,p="var(--semiotic-border, #ccc)",y="var(--semiotic-text-secondary, var(--semiotic-text, #666))",g="var(--semiotic-text, #333)",m=K,x=m?12:18,b=n+(m?58:40),v={fontSize:"var(--semiotic-tick-font-size, 12px)"},w={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},k={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},S=o?.tickAnchor,A=e?.tickAnchor,M=$s(U),_=$s(Z);return(0,Ys.jsxs)("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[(0,Ys.jsxs)("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!B||N)&&i&&!a&&(0,Ys.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:p,strokeWidth:1}),(!B||N)&&a&&(0,Ys.jsx)("path",{d:Ds("bottom",t,n),fill:"none",stroke:p,strokeWidth:1}),U.map((e,t)=>{const o=!!h&&("function"==typeof h?h(e.value,t):wo(e.value,t>0?U[t-1].value:void 0));return(0,Ys.jsxs)("g",{transform:`translate(${e.pixel},${n})`,children:[(0,Ys.jsx)("line",{y2:5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Ys.jsx)("text",{y:x,textAnchor:m?"end":Is(S,e.pixel===M.min,e.pixel===M.max),fontWeight:o?600:400,fill:y,className:"semiotic-axis-tick",style:{userSelect:"none",...o?w:v},transform:m?"rotate(-45)":void 0,children:e.label}):(0,Ys.jsx)("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:(0,Ys.jsx)("div",{style:{textAlign:"center",userSelect:"none",...v},children:e.label})})]},"xtick-"+t)}),l&&(0,Ys.jsx)("text",{x:t/2,y:b,textAnchor:"middle",fill:g,className:"semiotic-axis-label",style:{userSelect:"none",...k},children:l})]}),(0,Ys.jsxs)("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!B||N)&&r&&!s&&(0,Ys.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:p,strokeWidth:1}),(!B||N)&&s&&(0,Ys.jsx)("path",{d:Ds("left",t,n),fill:"none",stroke:p,strokeWidth:1}),Z.map((e,t)=>{const n=!!f&&("function"==typeof f?f(e.value,t):wo(e.value,t>0?Z[t-1].value:void 0));return(0,Ys.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,Ys.jsx)("line",{x2:-5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Ys.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:Ts(A,e.pixel===_.min,e.pixel===_.max),fontWeight:n?600:400,fill:y,className:"semiotic-axis-tick",style:{userSelect:"none",...n?w:v},children:e.label}):(0,Ys.jsx)("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,Ys.jsx)("div",{style:{textAlign:"right",userSelect:"none",...v},children:e.label})})]},"ytick-"+t)}),(()=>{const t=e?.label||u;return t?(0,Ys.jsx)("text",{x:15-V,y:n/2,textAnchor:"middle",fill:g,transform:`rotate(-90, ${15-V}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...k},children:t}):null})()]}),(()=>{const e=c?.find(e=>"right"===e.orient);if(!e||0===Q.length)return null;const o=!1!==e.baseline,r=e.landmarkTicks,i=e.label||d,s=e.tickAnchor,a=$s(Q);return(0,Ys.jsxs)("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[o&&(0,Ys.jsx)("line",{x1:t,y1:0,x2:t,y2:n,stroke:p,strokeWidth:1}),Q.map((e,n)=>{const o=!!r&&("function"==typeof r?r(e.value,n):wo(e.value,n>0?Q[n-1].value:void 0));return(0,Ys.jsxs)("g",{transform:`translate(${t},${e.pixel})`,children:[(0,Ys.jsx)("line",{x2:5,stroke:p,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Ys.jsx)("text",{x:8,textAnchor:"start",dominantBaseline:Ts(s,e.pixel===a.min,e.pixel===a.max),fontWeight:o?600:400,fill:y,className:"semiotic-axis-tick",style:{userSelect:"none",...o?w:v},children:e.label}):(0,Ys.jsx)("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,Ys.jsx)("div",{style:{textAlign:"left",userSelect:"none",...v},children:e.label})})]},"ytick-r-"+n)}),i&&(0,Ys.jsx)("text",{x:t+X-15,y:n/2,textAnchor:"middle",fill:g,transform:`rotate(90, ${t+X-15}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...k},children:i})]})})()]})})(),ne,M&&s&&_&&P&&(0,Ys.jsxs)(Ys.Fragment,{children:[M.top&&(0,Ys.jsx)("g",{transform:"translate(0, 0)",children:(0,Ys.jsx)(ti,{orient:"top",config:ei(M.top),values:_,scale:s.x,size:i.top,length:t})}),M.bottom&&(0,Ys.jsx)("g",{transform:`translate(0, ${n})`,children:(0,Ys.jsx)(ti,{orient:"bottom",config:ei(M.bottom),values:_,scale:s.x,size:i.bottom,length:t})}),M.left&&(0,Ys.jsx)("g",{transform:"translate(0, 0)",children:(0,Ys.jsx)(ti,{orient:"left",config:ei(M.left),values:P,scale:s.y,size:i.left,length:n})}),M.right&&(0,Ys.jsx)("g",{transform:`translate(${t}, 0)`,children:(0,Ys.jsx)(ti,{orient:"right",config:ei(M.right),values:P,scale:s.y,size:i.right,length:n})})]}),A,oe&&oe.sourceId!==q&&s?.x&&(()=>{const e=s.x(oe.xValue);if(null==e||0>e||e>t)return null;const o=oe.locked;return(0,Ys.jsx)("line",{x1:e,y1:0,x2:e,y2:n,stroke:o?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:o?1.5:1,strokeDasharray:o?"6,3":"4,4",pointerEvents:"none"})})(),Y]}),g&&"string"==typeof g?(0,Ys.jsx)("text",{x:o/2,y:Bs,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:g}):g?(0,Ys.jsx)("foreignObject",{x:0,y:0,width:o,height:i.top,children:g}):null,Kr({legend:m,totalWidth:o,totalHeight:r,margin:i,legendPosition:k,title:g,legendLayout:S,axisChrome:{hasAxis:!!a,hasAxisLabel:!!l,rotatedTicks:K},legendHoverBehavior:x,legendClickBehavior:b,legendHighlightedCategory:v,legendIsolatedCategories:w})]}):null}var Us=y(require("react")),Ks=require("d3-shape");function Zs(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function Qs(e,t,n,o){if(2>e.length||t.length!==e.length||0===n.length)return[];const r=[],i=(e,t,n)=>{const o=r[r.length-1];o?.color===e?o.path.push(n):r.push({color:e,path:[t,n]})};for(let r=1;e.length>r;r++){const[s,a]=e[r-1],[c,l]=e[r],u=t[r-1],d=t[r]-u,h=[0,...0===d?[]:n.map(({value:e})=>(e-u)/d).filter(e=>e>0&&1>e&&Number.isFinite(e)).sort((e,t)=>e-t).filter((e,t,n)=>0===t||e!==n[t-1]),1];for(let e=1;h.length>e;e++){const t=h[e-1],r=h[e];i(Zs(u+d*((t+r)/2),n,o),[s+(c-s)*t,a+(l-a)*t],[s+(c-s)*r,a+(l-a)*r])}}return r}function Js(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}function ea(e){const t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(e.w,e.h)/2,o=e=>Math.max(0,Math.min(e??0,n));return{tl:o(t.tl),tr:o(t.tr),br:o(t.br),bl:o(t.bl)}}var ta=require("react/jsx-runtime"),na={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function oa(e,t="#4e79a7"){return Bo(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function ra(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}function ia(e,t,n,o){const r=e.glyph;if(!r?.parts?.length||0>=e.size)return null;const i=Ao(r,e.size);if(0>=i.scale)return null;const s=`translate(${t},${n})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${i.offsetX},${i.offsetY}) scale(${i.scale})`,a=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),c=jo(r,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),l=c?ra(o+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>r.parts.map((n,o)=>{const r=t?"none"===n.fill?void 0:t:Mo(n.fill,a,e.accent),i=t?n.stroke&&"none"!==n.stroke?t:void 0:Mo(n.stroke??"none",a,e.accent);return r||i?(0,ta.jsx)("path",{d:n.d,fill:r??"none",stroke:i,strokeWidth:i?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},o):null});return(0,ta.jsxs)("g",{transform:s,opacity:1===u?void 0:u,children:[c&&l&&(0,ta.jsx)("clipPath",{id:l,children:(0,ta.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&e.ghostColor?(0,ta.jsx)("g",{children:d(e.ghostColor)}):null,c&&l?(0,ta.jsx)("g",{clipPath:`url(#${l})`,children:d()}):d()]},o)}function sa(e,t){const n=e.filter(e=>Number.isFinite(e.offset)&&(null==e.opacity||Number.isFinite(e.opacity))).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color??t,opacity:null==e.opacity?void 0:Math.max(0,Math.min(1,e.opacity))}));return 2>n.length?null:n.map((e,t)=>(0,ta.jsx)("stop",{offset:e.offset,stopColor:e.color,stopOpacity:e.opacity},t))}function aa(e,t,n){const o=fn(e.symbolType,e.size,e.path);return(0,ta.jsx)("path",{d:o,transform:e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`,fill:e.style.fill?oa(e.style.fill):"none",fillOpacity:e.style.fillOpacity,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${n??""}symbol-${t}`)}var ca=y(require("react")),la=require("d3-shape"),ua=require("react/jsx-runtime"),da=y(require("react")),ha=require("react/jsx-runtime"),fa=y(require("react")),pa=require("d3-shape"),ya=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)});function ga(e){const{innerRadius:t,outerRadius:n,startAngle:o,endAngle:r}=e,i=0>=t;if(0>=(e.cornerRadius??0)||!e.roundStart&&!e.roundEnd){if(i){const e=ya(n,o),t=ya(n,r);return`M0,0 L${e.x},${e.y} A${n},${n} 0 ${r-o>Math.PI?1:0} 1 ${t.x},${t.y} Z`}const e=ya(n,o),s=ya(n,r),a=ya(t,r),c=ya(t,o),l=r-o>Math.PI?1:0;return`M${e.x},${e.y} A${n},${n} 0 ${l} 1 ${s.x},${s.y} L${a.x},${a.y} A${t},${t} 0 ${l} 0 ${c.x},${c.y} Z`}const s=Math.max(0,Math.min(e.cornerRadius??0,(n-t)/2));if(0===s)return ga({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const a=Math.asin(Math.min(1,s/Math.max(1e-9,n-s))),c=i?0:Math.asin(Math.min(1,s/Math.max(1e-9,t+s))),l=r-o,u=e.roundStart&&e.roundEnd?l/2:l,d=!!e.roundStart&&u>a,h=!!e.roundEnd&&u>a;if(!d&&!h)return ga({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const f=o+(d?a:0),p=r-(h?a:0),y=o+(d?c:0),g=r-(h?c:0),m=ya(n,f),x=ya(n,p),b=(n-s)*Math.cos(a),v=ya(b,o),w=ya(b,r),k=i?null:ya(t,g),S=i?null:ya(t,y),A=i?0:(t+s)*Math.cos(c),M=i?null:ya(A,o),_=i?null:ya(A,r),P=p-f>Math.PI?1:0,j=i?0:g-y>Math.PI?1:0;let C="";if(d)C+=`M${v.x},${v.y}`,C+=` A${s},${s} 0 0 1 ${m.x},${m.y}`;else{const e=ya(n,o);C+=`M${e.x},${e.y}`}if(h)C+=` A${n},${n} 0 ${P} 1 ${x.x},${x.y}`,C+=` A${s},${s} 0 0 1 ${w.x},${w.y}`;else{const e=ya(n,r);C+=` A${n},${n} 0 ${P} 1 ${e.x},${e.y}`}if(i)C+=" L0,0";else{if(h)C+=` L${_.x},${_.y}`,C+=` A${s},${s} 0 0 1 ${k.x},${k.y}`;else{const e=ya(t,r);C+=` L${e.x},${e.y}`}if(d)C+=` A${t},${t} 0 ${j} 0 ${S.x},${S.y}`,C+=` A${s},${s} 0 0 1 ${M.x},${M.y}`;else{const e=ya(t,o);C+=` A${t},${t} 0 ${j} 0 ${e.x},${e.y}`}}return C+=" Z",C}var ma=require("react/jsx-runtime");function xa(e){return 1e6>e?1e4>e?1e3>e?e+"":(e/1e3).toFixed(1)+"K":(e/1e3).toFixed(0)+"K":(e/1e6).toFixed(1)+"M"}function ba(e,t){const n=e.datum;if(!n)return null;const o=[],r=n.__funnelStepLabel,i=Number(n.__funnelStepLabelX),s=Number(n.__funnelStepLabelY),a=Number(n.__funnelRowWidth);"string"!=typeof r||!Number.isFinite(i)||!Number.isFinite(s)||Number.isFinite(a)&&8.4*r.length+16>a||o.push((0,ma.jsx)("text",{x:i,y:s+3,textAnchor:"middle",dominantBaseline:"hanging",fontSize:14,fontWeight:"bold",fill:"#fff",stroke:"rgba(0,0,0,0.6)",strokeWidth:3,paintOrder:"stroke",children:r},t+"-funnel-step"));const c=Number(n.__funnelValue),l=Number(n.__funnelValueLabelX),u=Number(n.__funnelValueLabelY),d=Number(n.__funnelBarW);if(Number.isFinite(c)&&0!==c&&Number.isFinite(l)&&Number.isFinite(u)&&d>=60){const e=Number(n.__funnelPercent);let r=!0!==n.__funnelIsFirstStep&&Number.isFinite(e)?`${xa(c)} (${.05>Math.abs(e-Math.round(e))?Math.round(e):e.toFixed(1)}%)`:xa(c);7.8*r.length+16>d&&(r=xa(c)),7.8*r.length+16>d||o.push((0,ma.jsx)("text",{x:l,y:u+22,textAnchor:"middle",dominantBaseline:"hanging",fontSize:13,fontWeight:"bold",fill:"#fff",stroke:"rgba(0,0,0,0.5)",strokeWidth:3,paintOrder:"stroke",children:r},t+"-funnel-value"))}return o.length?(0,ma.jsx)("g",{children:o},t+"-funnel-labels"):null}function va(e,t,n){const o=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",r=n=>`ord-${e.type}-${o}-${t}-${n}`,i=`ord-${e.type}-${o}-${t}`;switch(e.type){case"rect":{const t=e,n=ra(i)+"-grad",o=function(e,t){const n=e.fillGradient;if(!n||"object"!=typeof n)return null;let o=e.x,r=e.y,i=e.x,s=e.y+e.h;"bottom"===e.roundedEdge?(r=e.y+e.h,s=e.y):"right"===e.roundedEdge?(o=e.x+e.w,r=e.y,i=e.x,s=e.y):"left"===e.roundedEdge&&(o=e.x,r=e.y,i=e.x+e.w,s=e.y);const a=sa(n.stops,oa(e.style.fill));return a?(0,ta.jsx)("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:o,y1:r,x2:i,y2:s,children:a}):null}(t,n);let r,s;if(o)s=`url(#${n})`;else if(Bo(t.style.fill)){const e=ra(i)+"-hatch";r=qo(t.style.fill,e),s=`url(#${e})`}else s=oa(t.style.fill);const a=o||r?(0,ma.jsxs)("defs",{children:[o,r]}):null;if(t.cornerRadii&&Js(t.cornerRadii)){const e=function(e){const{x:t,y:n,w:o,h:r}=e,{tl:i,tr:s,br:a,bl:c}=ea(e);let l=`M${t+i},${n}`;return l+=` L${t+o-s},${n}`,s>0&&(l+=` A${s},${s} 0 0 1 ${t+o},${n+s}`),l+=` L${t+o},${n+r-a}`,a>0&&(l+=` A${a},${a} 0 0 1 ${t+o-a},${n+r}`),l+=` L${t+c},${n+r}`,c>0&&(l+=` A${c},${c} 0 0 1 ${t},${n+r-c}`),l+=` L${t},${n+i}`,i>0&&(l+=` A${i},${i} 0 0 1 ${t+i},${n}`),l+=" Z",l}(t);return(0,ma.jsxs)(fa.Fragment,{children:[a,(0,ma.jsx)("path",{d:e,fill:s,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},i)}if(t.roundedTop&&t.roundedTop>0){const e=Math.min(t.roundedTop,t.w/2,t.h/2),{x:n,y:o,w:r,h:c}=t;let l;switch(t.roundedEdge){case"right":l=`M${n},${o} L${n+r-e},${o} A${e},${e} 0 0 1 ${n+r},${o+e} L${n+r},${o+c-e} A${e},${e} 0 0 1 ${n+r-e},${o+c} L${n},${o+c} Z`;break;case"left":l=`M${n+r},${o} L${n+e},${o} A${e},${e} 0 0 0 ${n},${o+e} L${n},${o+c-e} A${e},${e} 0 0 0 ${n+e},${o+c} L${n+r},${o+c} Z`;break;case"bottom":l=`M${n},${o} L${n+r},${o} L${n+r},${o+c-e} A${e},${e} 0 0 1 ${n+r-e},${o+c} L${n+e},${o+c} A${e},${e} 0 0 1 ${n},${o+c-e} Z`;break;default:l=`M${n},${o+c} L${n},${o+e} A${e},${e} 0 0 1 ${n+e},${o} L${n+r-e},${o} A${e},${e} 0 0 1 ${n+r},${o+e} L${n+r},${o+c} Z`}return(0,ma.jsxs)(fa.Fragment,{children:[a,(0,ma.jsx)("path",{d:l,fill:s,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},i)}return(0,ma.jsxs)(fa.Fragment,{children:[a,(0,ma.jsx)("rect",{x:t.x,y:t.y,width:t.w,height:t.h,fill:s,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth}),ba(t,i)]},i)}case"point":{const t=e;return(0,ma.jsx)("circle",{cx:t.x,cy:t.y,r:t.r,fill:oa(t.style.fill),opacity:t.style.opacity??t.style.fillOpacity??.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},i)}case"symbol":return aa(e,t,n);case"glyph":return ia(e,e.x,e.y,`${n??""}ord-glyph-${e.pointId??t}`);case"wedge":{const o=e;if(o._gradientBand&&o._gradientBand.colors.length>0){const e=ra(`${n?n+"-":""}gauge-grad-${o.category||i}-${t}`),{clipPath:r,slices:s}=function(e){const t=ga({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,cornerRadius:e.cornerRadius,roundStart:e.roundStart,roundEnd:e.roundEnd}),n=[],o=e.colors;if(o.length>0){const t=(e.endAngle-e.startAngle)/o.length;for(let r=0;o.length>r;r++)n.push({d:ga({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle+r*t,endAngle:e.endAngle}),color:o[r]})}return{clipPath:t,slices:n}}({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds?.start??!0,roundEnd:o.roundedEnds?.end??!0,colors:o._gradientBand.colors});return(0,ma.jsxs)("g",{transform:`translate(${o.cx},${o.cy})`,opacity:o.style.opacity,fillOpacity:o.style.fillOpacity,children:[(0,ma.jsx)("defs",{children:(0,ma.jsx)("clipPath",{id:e,children:(0,ma.jsx)("path",{d:r})})}),(0,ma.jsx)("g",{clipPath:`url(#${e})`,children:s.map((e,t)=>(0,ma.jsx)("path",{d:e.d,fill:oa(e.color)},t))}),o.style.stroke&&"none"!==o.style.stroke&&(0,ma.jsx)("path",{d:r,fill:"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},i)}let r;if(o.roundedEnds)r=ga({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds.start,roundEnd:o.roundedEnds.end});else{const e=(0,pa.arc)().innerRadius(o.innerRadius).outerRadius(o.outerRadius).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2);o.cornerRadius&&e.cornerRadius(o.cornerRadius),r=e(na)||""}return(0,ma.jsx)("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:oa(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},i)}case"boxplot":{const t=e,n=t.columnWidth/2;return(0,ma.jsxs)("g","vertical"===t.projection?{children:[(0,ma.jsx)("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,ma.jsx)("rect",{x:t.x-n,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:oa(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,ma.jsx)("line",{x1:t.x-n,y1:t.medianPos,x2:t.x+n,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2}),(0,ma.jsx)("line",{x1:t.x-.5*n,y1:t.minPos,x2:t.x+.5*n,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,ma.jsx)("line",{x1:t.x-.5*n,y1:t.maxPos,x2:t.x+.5*n,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1})]}:{children:[(0,ma.jsx)("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,ma.jsx)("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-n,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:oa(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,ma.jsx)("line",{x1:t.medianPos,y1:t.y-n,x2:t.medianPos,y2:t.y+n,stroke:t.style.stroke||"#333",strokeWidth:2}),(0,ma.jsx)("line",{x1:t.minPos,y1:t.y-.5*n,x2:t.minPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,ma.jsx)("line",{x1:t.maxPos,y1:t.y-.5*n,x2:t.maxPos,y2:t.y+.5*n,stroke:t.style.stroke||"#333",strokeWidth:1})]},i)}case"violin":{const t=e,n=[(0,ma.jsx)("path",{d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:oa(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:t.style.strokeWidth||1},r("path"))];if(t.iqrLine&&t.bounds){const e=t.bounds,o=e.x+e.width/2,i=e.y+e.height/2;t.iqrLine.isVertical?n.push((0,ma.jsx)("line",{x1:o,y1:t.iqrLine.q1Pos,x2:o,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2},r("iqr")),(0,ma.jsx)("circle",{cx:o,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},r("med"))):n.push((0,ma.jsx)("line",{x1:t.iqrLine.q1Pos,y1:i,x2:t.iqrLine.q3Pos,y2:i,stroke:t.style.stroke||"#333",strokeWidth:2},r("iqr")),(0,ma.jsx)("circle",{cx:t.iqrLine.medianPos,cy:i,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},r("med")))}return(0,ma.jsx)("g",{children:n},i)}case"connector":return(0,ma.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity??.5},i);case"trapezoid":{const t=e,n=t.points.map(e=>`${e[0]},${e[1]}`).join(" ");return(0,ma.jsx)("polygon",{points:n,fill:oa(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},i)}default:return null}}var wa=require("react/jsx-runtime");function ka(e,t,n,o){if(!e||2>t.length)return null;const r=sa(e.stops,o);return r?(0,wa.jsx)("linearGradient",{id:n,gradientUnits:"userSpaceOnUse",x1:t[0][0],y1:0,x2:t[t.length-1][0],y2:0,children:r}):null}function Sa(e,t,n){switch(e.type){case"line":{const o=e;if(0===o.path.length)return null;const r=Ho(o.curve),i=r?(0,Ks.line)().x(([e])=>e).y(([,e])=>e).curve(r)(o.path)??"":"M"+o.path.map(([e,t])=>`${e},${t}`).join("L"),s=ra(`${n?n+"-":""}line-${t}-stroke-gradient`),a=ka(o.strokeGradient,o.path,s,o.style.stroke||"#4e79a7");return(0,wa.jsxs)(Us.Fragment,{children:[a&&(0,wa.jsx)("defs",{children:a}),(0,wa.jsx)("path",{d:i,fill:"none",stroke:a?`url(#${s})`:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||2,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity})]},"line-"+t)}case"area":{const o=e;if(0===o.topPath.length)return null;const r=Ho(o.curve),i=!r||2>o.topPath.length||2>o.bottomPath.length?`M${o.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...o.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`:(0,Ks.area)().x(([e])=>e).y0((e,t)=>o.bottomPath[t][1]).y1(([,e])=>e).curve(r)(o.topPath)??"",s=`${n?n+"-":""}area-${t}-hatch`,a=Bo(o.style.fill)?qo(o.style.fill,s):void 0,c=ra(`${n?n+"-":""}area-${t}-gradient`),l=function(e,t){const n=e.fillGradient;if(!n||"object"!=typeof n)return null;let o=1/0;for(const[,t]of e.topPath)o=Math.min(o,t);let r=-1/0;for(const[,t]of e.bottomPath)r=Math.max(r,t);if(!Number.isFinite(o)||!Number.isFinite(r))return null;const i=sa(n.stops,oa(e.style.fill));return i?(0,wa.jsx)("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:0,y1:o,x2:0,y2:r,children:i}):null}(o,c),u=l?`url(#${c})`:a?`url(#${s})`:oa(o.style.fill),d=l?void 0:o.style.fillOpacity??o.style.opacity??.7,h=r?(0,Ks.line)().x(([e])=>e).y(([,e])=>e).curve(r)(o.topPath)??"":"M"+o.topPath.map(([e,t])=>`${e},${t}`).join("L"),f=ra(`${n?n+"-":""}area-${t}-stroke-gradient`),p=!(!o.colorThresholds?.length||!o.rawValues||o.rawValues.length!==o.topPath.length),y=!!o.strokeColorBands?.length,g=p||y?null:ka(o.strokeGradient,o.topPath,f,o.style.stroke||"#4e79a7"),m=o.style.strokeWidth||2;let x=1/0,b=-1/0;for(const[e]of o.topPath)x>e&&(x=e),e>b&&(b=e);const v=y?o.strokeColorBands.map((e,o)=>ra(`${n?n+"-":""}area-${t}-stroke-band-${o}`)):[],w=y?o.strokeColorBands.map((e,t)=>(0,wa.jsx)("clipPath",{id:v[t],children:(0,wa.jsx)("rect",{x:x-m,y:e.y,width:b-x+2*m,height:e.height})},v[t])):null,k=o.style.stroke&&"none"!==o.style.stroke?y?o.strokeColorBands.map((e,n)=>(0,wa.jsx)("path",{d:h,fill:"none",stroke:e.color??oa(o.style.stroke),strokeWidth:m,opacity:o.style.opacity,clipPath:`url(#${v[n]})`},`area-${t}-stroke-band-${n}`)):p?Qs(o.topPath,o.rawValues,o.colorThresholds,oa(o.style.stroke)).map((e,n)=>(0,wa.jsx)("path",{d:"M"+e.path.map(([e,t])=>`${e},${t}`).join("L"),fill:"none",stroke:e.color,strokeWidth:m,opacity:o.style.opacity},`area-${t}-threshold-${n}`)):(0,wa.jsx)("path",{d:h,fill:"none",stroke:g?`url(#${f})`:oa(o.style.stroke),strokeWidth:m,opacity:o.style.opacity}):null;if(o.clipRect){const e=`${n?n+"-":""}area-clip-${t}`;return(0,wa.jsxs)("g",{children:[(0,wa.jsxs)("defs",{children:[l,!l&&a,g,w,(0,wa.jsx)("clipPath",{id:e,children:(0,wa.jsx)("rect",{x:o.clipRect.x,y:o.clipRect.y,width:o.clipRect.width,height:o.clipRect.height})})]}),(0,wa.jsxs)("g",{clipPath:`url(#${e})`,children:[(0,wa.jsx)("path",{d:i,fill:u,fillOpacity:d,opacity:l?o.style.opacity:void 0,stroke:"none"}),k]})]},"area-"+t)}return(0,wa.jsxs)(Us.Fragment,{children:[(l||a||g||w)&&(0,wa.jsxs)("defs",{children:[l,!l&&a,g,w]}),(0,wa.jsx)("path",{d:i,fill:u,fillOpacity:d,opacity:l?o.style.opacity:void 0,stroke:"none"}),k]},"area-"+t)}case"point":{const o=e,r=`${n?n+"-":""}point-${t}-hatch`,i=Bo(o.style.fill)?qo(o.style.fill,r):void 0;return(0,wa.jsxs)(Us.Fragment,{children:[i&&(0,wa.jsx)("defs",{children:i}),(0,wa.jsx)("circle",{cx:o.x,cy:o.y,r:o.r,fill:i?`url(#${r})`:oa(o.style.fill),opacity:o.style.opacity??o.style.fillOpacity??.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"point-"+t)}case"symbol":return aa(e,t);case"glyph":return ia(e,e.x,e.y,`${n??""}glyph-${e.pointId??t}`);case"rect":{const o=e,r=`${n?n+"-":""}xyrect-${t}-hatch`,i=Bo(o.style.fill)?qo(o.style.fill,r):void 0;return(0,wa.jsxs)(Us.Fragment,{children:[i&&(0,wa.jsx)("defs",{children:i}),(0,wa.jsx)("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:i?`url(#${r})`:oa(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"rect-"+t)}case"heatcell":{const n=e,o={x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill,stroke:n.style?.stroke,strokeWidth:n.style?.strokeWidth,...null!=n.style?.opacity&&{opacity:n.style.opacity}};if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const e=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[r,i,s]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(n.fill),a=.299*r+.587*i+.114*s>128?"#000":"#fff",c=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return(0,wa.jsxs)("g",{children:[(0,wa.jsx)("rect",{...o}),(0,wa.jsx)("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:c+"px",children:e})]},"heatcell-"+t)}return(0,wa.jsx)("rect",{...o},"heatcell-"+t)}case"candlestick":{const n=e;if(n.isRange){const e=n.dotRadius??Math.max(2,n.bodyWidth/2);return(0,wa.jsxs)("g",{children:[(0,wa.jsx)("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),(0,wa.jsx)("circle",{cx:n.x,cy:n.highY,r:e,fill:n.wickColor}),(0,wa.jsx)("circle",{cx:n.x,cy:n.lowY,r:e,fill:n.wickColor})]},"candle-"+t)}const o=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return(0,wa.jsxs)("g",{children:[(0,wa.jsx)("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),(0,wa.jsx)("rect",{x:n.x-n.bodyWidth/2,y:o,width:n.bodyWidth,height:r,fill:i,stroke:i,strokeWidth:1})]},"candle-"+t)}default:return null}}var Aa="undefined"==typeof window||"undefined"==typeof document,Ma=require("react"),_a="undefined"!=typeof window?Ma.useLayoutEffect:Ma.useEffect,Pa=()=>()=>{},ja=()=>!1,Ca=()=>!0,Ra=require("react");function La(e,t){const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;if(!Object.is(e[o],t[o]))return!1}return!0}function Ia(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function Ta(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}function $a(e){const{background:t,hasBackgroundGraphics:n=!1,themeBackground:o=""}=e;return"transparent"===t||n?null:t||(o&&"transparent"!==o?o:"")||null}var za={axisStroke:"#ccc",tickText:"#666",crosshair:"rgba(0, 0, 0, 0.25)",hoverFill:"rgba(255, 255, 255, 0.3)",hoverStroke:"rgba(0, 0, 0, 0.4)",pointRing:"white",primary:"#007bff",background:""};function Da(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],o=n[2],r=n[3];return`#${e}${e}${o}${o}${r}${r}${t}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${t}`;const o=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return o?`rgba(${o[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:n}var Ea=y(require("react")),Oa=y(require("react")),Fa=(require("react/jsx-runtime"),Oa.createContext(null)),Ba=require("react/jsx-runtime"),Na={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Wa({hoverPoint:e}){let t="";if(e){const n=e.data||e;t="object"==typeof n?"Data point: "+Object.entries(n).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+n}return(0,Ba.jsx)("div",{"aria-live":"polite","aria-atomic":"true",style:Na,children:t})}function qa(e){const t={};if(null==e||"object"!=typeof e)return t;for(const[n,o]of Object.entries(e))n.startsWith("_")||null!=o&&""!==o&&("number"==typeof o?Number.isFinite(o)&&(t[n]=o):"string"==typeof o?t[n]=o:"boolean"==typeof o?t[n]=o+"":o instanceof Date&&(t[n]=o.toISOString().slice(0,10)));return t}function Ya(e){return e&&"object"==typeof e?e:{}}function Ga(e){return Ya(e.accessibility).tableFields??e.accessibleDatum??e.datum}var Ha=require("react/jsx-runtime");function Va(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e){if(null===t?.datum)continue;const e=t.type+"";n[e]=(n[e]||0)+1}if(0===Object.keys(n).length)return t+", empty";const o=[],r={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},i=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((e,t)=>{const n=i.indexOf(e),o=i.indexOf(t);return(-1===n?999:n)-(-1===o?999:o)});for(const e of s)o.push(`${n[e]} ${r[e]||e}`);return`${t}, ${o.join(", ")}`}var Xa=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Ua="semiotic-accessible-data-table",Ka=Ua+" semiotic-accessible-data-table-hidden",Za=Ua+" semiotic-accessible-data-table-visible",Qa={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},Ja={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},ec={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},tc={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},nc={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},oc={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},rc={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},ic={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function sc({scene:e,chartType:t,tableId:n,chartTitle:o}){const[r,i]=Ea.useState(!1),[s,a]=Ea.useState(5),c=Oa.useContext(Fa),l=c?.visible??!1,u=r||l,d=Ea.useRef(null),h=o?"Data summary for "+o:n?`Data summary for ${t} ${n}`:"Data summary for "+t;Ea.useEffect(()=>{u||a(5)},[u]);const f=Ea.useCallback(e=>{e.target===e.currentTarget&&(r||l||i(!0))},[r,l]),p=Ea.useCallback(e=>{l||d.current?.contains(e.relatedTarget)||i(!1)},[l]);if(!e||0===e.length)return n?(0,Ha.jsx)("span",{id:n,tabIndex:-1,style:Na}):null;if(!u)return(0,Ha.jsx)("div",{id:n,className:Ka,tabIndex:-1,onFocus:f,style:Na,role:"region","aria-label":h,children:(0,Ha.jsxs)("button",{type:"button",onClick:()=>i(!0),children:["View data summary (",e.length," elements)"]})});const y=function(e){const t=[];if(!Array.isArray(e))return t;const n=e.some(e=>e&&("line"===e.type||"area"===e.type));for(const o of e)if(o&&"object"==typeof o&&null!==o.datum)try{switch(o.type){case"point":if(n)break;t.push({label:"Point",values:qa(Ga(o))});break;case"line":case"area":{const e=Ga(o),n=Array.isArray(e)?e:[],r="line"===o.type?"Line point":"Area point";for(const e of n)t.push({label:r,values:qa(e)});break}case"rect":{const e=Ga(o),n=null!=e&&"object"==typeof e?e:{},r=n.category??o.group??"",i=n.value??n.__aggregateValue??n.total,s=qa(n);null==s.category&&""!==r&&(s.category=r+""),null==s.value&&null!=i&&(s.value="number"==typeof i||"string"==typeof i?i:i+""),t.push({label:"Bar",values:s});break}case"heatcell":{const e=qa(Ga(o));null==e.value&&"number"==typeof o.value&&Number.isFinite(o.value)&&(e.value=o.value),t.push({label:"Cell",values:e});break}case"wedge":{const e=Ga(o),n=qa(e);if(null==n.category){const t=Ya(e),o=t.category??t.label;null!=o&&(n.category=o+"")}t.push({label:"Wedge",values:n});break}case"circle":t.push({label:"Node",values:qa(Ga(o))});break;case"arc":t.push({label:"Arc",values:qa(Ga(o))});break;case"candlestick":t.push({label:"Candlestick",values:qa(Ga(o))});break;case"geoarea":{const e=Ya(Ga(o)),n=qa(e);if(null==n.name){const t=Ya(e.properties).name??e.name;null!=t&&(n.name=t+"")}t.push({label:"Region",values:n});break}}}catch{}return t}(e),g=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const o of t){const t=[],r=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[o];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&r.add(e+""))}if(t.length>0){let e=t[0],r=t[0],i=0;for(const n of t)e>n&&(e=n),n>r&&(r=n),i+=n;n.push({name:o,count:t.length,numeric:!0,min:e,max:r,mean:i/t.length})}else if(r.size>0){const e=Array.from(r);n.push({name:o,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(y),m=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${Xa(e.min)} to ${Xa(e.max)}, mean ${Xa(e.mean)}.`);else{const t=e.uniqueValues,o=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${o}.`)}return n.join(" ")}(y.length,g),x=Math.min(s,y.length),b=y.slice(0,x),v=y.length-x,w=new Set;for(const e of b)for(const t of Object.keys(e.values))w.add(t);const k=Array.from(w);return(0,Ha.jsxs)("div",{ref:d,id:n,className:Za,tabIndex:-1,onBlur:p,style:Qa,role:"region","aria-label":h,children:[(0,Ha.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{l&&c&&c.setVisible(!1),i(!1)},"aria-label":"Close data summary",style:ec,children:"×"}),(0,Ha.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Ja,children:m}),(0,Ha.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+t,style:tc,children:[(0,Ha.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:rc,children:v>0?`First ${x} of ${y.length} data points`:`All ${y.length} data points`}),(0,Ha.jsx)("thead",{children:(0,Ha.jsxs)("tr",{children:[(0,Ha.jsx)("th",{style:nc,children:"type"}),k.map(e=>(0,Ha.jsx)("th",{style:nc,children:e},e))]})}),(0,Ha.jsx)("tbody",{children:b.map((e,t)=>(0,Ha.jsxs)("tr",{children:[(0,Ha.jsx)("td",{style:oc,children:e.label}),k.map(t=>{return(0,Ha.jsx)("td",{style:oc,children:(n=e.values[t],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":Xa(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},t);var n})]},t))})]}),v>0&&(0,Ha.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(e=>e+25),style:ic,children:["Show ",Math.min(25,v)," more"," ",1===v?"row":"rows"," (",v," remaining)"]})]})}function ac({summary:e}){return e?(0,Ha.jsx)("div",{role:"note",style:Na,children:e}):null}function cc({tableId:e}){return(0,Ha.jsx)("a",{href:"#"+e,style:Na,onClick:t=>{t.preventDefault();const n=document.getElementById(e);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Na)},children:"Skip to data table"})}var lc=require("react/jsx-runtime"),uc="var(--semiotic-focus, #005fcc)";function dc({active:e,hoverPoint:t,margin:n,size:o,shape:r="circle",width:i,height:s,pathData:a}){if(!e||!t)return null;const c=t.x+n.left,l=t.y+n.top;let u;if("geoarea"!==r&&"path"!==r||!a)if("rect"===r&&null!=i&&null!=s){const e=Math.max(i,4),t=Math.max(s,4);u=(0,lc.jsx)("rect",{x:c-e/2-3,y:l-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:uc,strokeWidth:2,strokeDasharray:"4,2"})}else u=(0,lc.jsx)("circle","wedge"===r?{cx:c,cy:l,r:12,fill:"none",stroke:uc,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:c,cy:l,r:8,fill:"none",stroke:uc,strokeWidth:2,strokeDasharray:"4,2"});else u=(0,lc.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:(0,lc.jsx)("path",{d:a,fill:"none",stroke:uc,strokeWidth:2.5,strokeDasharray:"6,3"})});return(0,lc.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:o[0],height:o[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}var hc=y(require("react"));function fc(e,t){return"touch"===t?Math.max(e,24):e}function pc(e){return Array.isArray(e)?e[0]:e}function yc(e,t,n,o){return{data:pc(e),x:t,y:n,__semioticHoverData:!0,...o}}var gc=["name","label","title"],mc=["type","kind","category","group","class","status","role","shape"],xc=["value","amount","total","count","weight","score"],bc=new Set(["x","y","z","x0","x1","y0","y1","r","cx","cy","radius","layer","row","rowindex","col","column","depth","index","order","sankeywidth","coincidentpoints","sourcelinks","targetlinks","parent","children","fx","fy","vx","vy"]);function vc(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}function wc(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,o=!1!==t.skipPositional,r=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(o&&bc.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&r.push({key:t,lower:t.toLowerCase(),value:n})}if(0===r.length)return{entries:[]};let i=r.findIndex(e=>gc.includes(e.lower));const s=i>=0;0>i&&(i=r.findIndex(e=>"id"===e.lower)),0>i&&(i=r.findIndex(e=>"string"==typeof e.value));const a=0>i?void 0:r[i];let c=r.filter((e,t)=>t!==i);s&&(c=c.filter(e=>"id"!==e.lower));const l=vc(c,mc),u=vc(c,xc),d=new Set(mc),h=new Set(xc),f=[];l&&f.push({key:l.key,value:l.value}),u&&f.push({key:u.key,value:u.value});for(const e of c){if(f.length>=n)break;e!==l&&e!==u&&(d.has(e.lower)||h.has(e.lower)||f.push({key:e.key,value:e.value}))}return{titleKey:a?.key,title:a?.value,entries:f}}var kc=require("react/jsx-runtime"),Sc={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, white)",padding:"8px 12px",borderRadius:"var(--semiotic-tooltip-radius, 6px)",fontSize:"var(--semiotic-tooltip-font-size, 14px)",fontFamily:"var(--semiotic-font-family, inherit)",lineHeight:"1.5",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.15))",pointerEvents:"none",maxWidth:"300px",wordWrap:"break-word"};function Ac(e,t){return"function"==typeof t?t(e):e[t]}function Mc(e,t){if(t)return t(e);if(null==e)return"";if("number"==typeof e){if(!Number.isFinite(e))return e+"";const t=Number.isInteger(e)?e:parseFloat(e.toPrecision(6));return Math.abs(t)>9999?t.toLocaleString():t+""}return e instanceof Date?e.toLocaleDateString():"object"==typeof e&&null!==e?void 0!==e.id?e.id+"":void 0!==e.name?e.name+"":JSON.stringify(e):e+""}function _c(e={}){const{fields:t,title:n,format:o,style:r={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let s;const a=[];if(n){const t=Ac(e,n);s=Mc(t,o)}if(t&&t.length>0)t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const s=Ac(e,r);a.push({label:n,value:Mc(s,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){s=Mc(e[n],o);break}if(!s){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(s=Mc(e[t[0]],o))}}const c={...Sc,...r};return(0,kc.jsxs)("div",{className:("semiotic-tooltip "+i).trim(),style:c,children:[s&&(0,kc.jsx)("div",{style:{fontWeight:a.length>0?"bold":"normal"},children:s}),a.map((e,t)=>(0,kc.jsxs)("div",{style:{marginTop:0===t&&s?"4px":0},children:[e.label&&(0,kc.jsxs)("span",{children:[e.label,": "]}),e.value]},t))]})}}var Pc=require("react/jsx-runtime");function jc({x:e,y:t,containerWidth:n,containerHeight:o,margin:r,children:i,className:s="stream-frame-tooltip",zIndex:a=1}){const c=Number.isFinite(e)&&Number.isFinite(t),l=hc.useRef(null),[u,d]=hc.useState(null);hc.useLayoutEffect(()=>{const e=l.current;if(!e)return;const t=()=>{const t=e.getBoundingClientRect();Number.isFinite(t.width)&&Number.isFinite(t.height)&&d(e=>e&&.5>Math.abs(e.width-t.width)&&.5>Math.abs(e.height-t.height)?e:{width:t.width,height:t.height})};if(t(),"undefined"==typeof ResizeObserver)return;const n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[s,n,o,c]);let h;h=u?`translate(${u.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>o-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*o>t?"4px":"calc(-100% - 4px)"})`;const f=function(e){if(!hc.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if(!0===n["data-semiotic-tooltip-chrome"])return!0;if("true"===n["data-semiotic-tooltip-chrome"])return!0;const o=n.style;if(o&&"object"==typeof o){if(null!=o.background&&""!==o.background&&"transparent"!==o.background)return!0;if(null!=o.backgroundColor&&""!==o.backgroundColor&&"transparent"!==o.backgroundColor)return!0}return!1}(i),p=f?null:Sc;return c?(0,Pc.jsx)("div",{ref:l,className:f?s:(s+" semiotic-tooltip").trim(),style:{...p||{},position:"absolute",left:r.left+e,top:r.top+t,transform:h,pointerEvents:"none",zIndex:a,width:"max-content"},children:i}):null}var Cc=y(require("react")),Rc=require("react"),Lc=require("react");var Ic=require("react"),Tc=()=>"undefined"!=typeof performance?performance.now():Date.now();function $c(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function zc(e,t){const n=e();return Number.isFinite(n)?n:t}var Dc=class{constructor(e={}){this.randomSource=Math.random,this.subscribers=new Set,this.now=()=>this.advance(),this.random=()=>this.randomSource(),this.clock=e.clock??Tc,this.lastWallTime=zc(this.clock,0),this.logicalTime=this.lastWallTime,this.pausedValue=!0===e.paused,this.visibleValue=!1!==e.visible,this.setRandomSource(e.random,e.seed)}get isActive(){return!this.pausedValue&&this.visibleValue}get paused(){return this.pausedValue}get seed(){return this.seedValue}get visible(){return this.visibleValue}configure(e){this.setClock(e.clock),this.setRandomSource(e.random,e.seed)}setPaused(e){this.pausedValue!==e&&(this.advance(),this.pausedValue=e,this.emit())}setVisible(e){this.visibleValue!==e&&(this.advance(),this.visibleValue=e,this.emit())}snapshot(){return{now:this.now(),paused:this.pausedValue,seed:this.seedValue,visible:this.visibleValue}}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}advance(){const e=zc(this.clock,this.lastWallTime),t=Math.max(0,e-this.lastWallTime);return this.lastWallTime=e,this.isActive&&(this.logicalTime+=t),this.logicalTime}emit(){for(const e of this.subscribers)e()}setClock(e){const t=e??Tc;t!==this.clock&&(this.advance(),this.clock=t,this.lastWallTime=zc(t,this.lastWallTime))}setRandomSource(e,t){const n=function(e){return"number"==typeof e&&Number.isFinite(e)?Math.trunc(e):void 0}(t);e===this.randomInput&&n===this.seedValue||(this.randomInput=e,this.seedValue=n,this.randomSource=e??(void 0===n?Math.random:$c(n)))}},Ec="undefined"==typeof window?Rc.useEffect:Rc.useLayoutEffect,Oc={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function Fc(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function Bc(e){const t=function(){const[e,t]=(0,Lc.useState)(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return(0,Lc.useEffect)(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return t(e.matches),function(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}(e,e=>t(e.matches))},[]),e}(),n=(0,Rc.useRef)(t);n.current=t;const[o,r]=function(e,t,n){const o=(0,Ic.useRef)(null),[r,i]=(0,Ic.useState)(null);return(0,Ic.useEffect)(()=>{if(!t&&!n)return;const e=o.current;if(!e)return;const r=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;i(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return r.observe(e),()=>r.disconnect()},[t,n]),[o,[t&&r?r.w:e[0],n&&r?r.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),i=!!e.title,s=!!e.legend&&"top"===e.legendPosition,a=(0,Rc.useMemo)(()=>Ws({...e.marginDefault,...e.userMargin},i,s),[e.marginDefault,e.userMargin,i,s]),c=r[0]-a.left-a.right,l=r[1]-a.top-a.bottom,u=Fc(e.foregroundGraphics,r,a),d=Fc(e.backgroundGraphics,r,a),h=Ze(e=>e.theme),{transition:f,introEnabled:p}=function(e,t){if(!1===e)return{transition:void 0,introEnabled:!1};const n="undefined"!=typeof window&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;return{transition:e?!0===e?{duration:300}:{duration:e.duration??300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(n||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),y="semiotic-table-"+Cc.useId(),g=(0,Rc.useRef)(null);if(!g.current){const t=!e.suspendWhenHidden||"undefined"==typeof document||!document.hidden;g.current=new Dc({clock:e.clock,random:e.random,seed:e.seed,paused:e.paused,visible:t})}const m=g.current;m.configure({clock:e.clock,random:e.random,seed:e.seed});const x=(0,Rc.useRef)(null),b=(0,Rc.useRef)(e.frameScheduler??Oc);b.current=e.frameScheduler??Oc;const v=(0,Rc.useRef)(null),w=(0,Rc.useRef)(!1),k=(0,Rc.useRef)(()=>{}),S=(0,Rc.useCallback)(()=>{if(null!==x.current||w.current)return;const e=b.current;let t=!1,n=!1;const o=e.requestAnimationFrame(()=>{t=!0;const e=!n;e&&(w.current=!0),x.current=null,v.current=null;try{k.current()}finally{e&&(w.current=!1)}});n=!0,t||(x.current=o,v.current=e)},[]),A=(0,Rc.useCallback)(()=>{null!==x.current&&((v.current??b.current).cancelAnimationFrame(x.current),x.current=null,v.current=null)},[]);Ec(()=>{m.setPaused(!0===e.paused)},[m,e.paused]),(0,Rc.useEffect)(()=>{if(!e.suspendWhenHidden||"undefined"==typeof document)return void m.setVisible(!0);const t=()=>m.setVisible(!document.hidden);return t(),document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[m,e.suspendWhenHidden]),(0,Rc.useEffect)(()=>()=>{A()},[A]);const M=(0,Rc.useRef)(()=>{}),_=(0,Rc.useRef)(()=>{}),P=(0,Rc.useRef)(null),j=(0,Rc.useRef)(null),C=(0,Rc.useRef)(null),R=(0,Rc.useCallback)(()=>{const e=P.current;P.current=null,e&&M.current(e)},[]),L=(0,Rc.useCallback)(e=>{if(P.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===j.current){const e=b.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,j.current=null,C.current=null,R()});t||(j.current=n,C.current=e)}},[R]),I=(0,Rc.useCallback)(()=>{P.current=null,null!==j.current&&((C.current??b.current).cancelAnimationFrame(j.current),j.current=null,C.current=null),_.current()},[]);(0,Rc.useEffect)(()=>()=>{P.current=null,null!==j.current&&((C.current??b.current).cancelAnimationFrame(j.current),j.current=null,C.current=null)},[]);const T=e.themeDirtyRef;return Ec(()=>{T&&(Io++,T.current=!0,S())},[h,S,T]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:o,size:r,margin:a,adjustedWidth:c,adjustedHeight:l,resolvedForeground:u,resolvedBackground:d,currentTheme:h,transition:f,introEnabled:p,tableId:y,frameRuntime:m,rafRef:x,renderFnRef:k,scheduleRender:S,cancelRender:A,hoverHandlerRef:M,hoverLeaveRef:_,onPointerMove:L,onPointerLeave:I}}var Nc=require("react"),Wc=require("react/jsx-runtime");function qc({children:e,size:t,margin:n,overflowVisible:o=!1}){return e?(0,Wc.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:t[0],height:t[1],pointerEvents:"none",overflow:o?"visible":void 0},children:(0,Wc.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:e})}):null}function Yc(e,t,n,o){return"function"==typeof e?e({size:t,margin:n,scales:o}):e}function Gc(e,t,n,o){const r=e.getContext("2d");if(!r)return null;const i=Math.round(t[0]*o),s=Math.round(t[1]*o),a=i/t[0],c=s/t[1],l=t[0]+"px",u=t[1]+"px";return e.style.width!==l&&(e.style.width=l),e.style.height!==u&&(e.style.height=u),e.width===i&&e.height===s||(e.width=i,e.height=s),r.setTransform(a,0,0,c,0,0),r.translate(n.left,n.top),r}var Hc=require("react");function Vc(e,t,n,o){return"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:o,fn:t}:{key:void 0,fn:null}}var Xc=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Uc=3156e7;function Kc(e){const t=e[1]-e[0];return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:Uc>t?e=>{const t=new Date(e);return`${Xc[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*Uc>t?e=>{const t=new Date(e);return`${Xc[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function Zc(e){if(!e)return;const t=[];for(const n of e)if("point"===n.type)t.push(n);else if("symbol"===n.type)t.push({pointId:n.pointId,x:n.x,y:n.y,r:pn(n.size)});else if("glyph"===n.type){const e=Co(n.glyph,n.size);t.push({pointId:n.pointId,x:n.x+e.centerDx,y:n.y+e.centerDy,r:e.radius})}return t}var Qc=require("d3-shape");function Jc(e,t,n,o,r,i){if(2>t.length)return;const s=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],o=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(n*n+o*o))}const a=s[s.length-1];if(0===a)return;const c=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=i;for(let n=0;t.length-1>n;n++){const o=(s[n]+s[n+1])/2;let i=r;c>o&&(i*=o/c),c>a-o&&(i*=(a-o)/c),e.globalAlpha=Math.max(0,i),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}var el=(e,t,n,o)=>{const r=t.filter(e=>"line"===e.type);for(const t of r){if(2>t.path.length)continue;const n=t._introClipFraction;void 0!==n&&1>n&&(e.save(),e.beginPath(),e.rect(0,0,o.width*n,o.height),e.clip());const r=t.style.stroke||"#007bff",i=Do(e,r)||r,s=t.style.strokeWidth||2,a=t.colorThresholds,c=t.rawValues;if(e.setLineDash(t.style.strokeDasharray?t.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),e.lineWidth=s,e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade){Jc(e,t.path,i,s,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const l=Ho(t.curve),u=a&&a.length>0&&c&&c.length===t.path.length,d=t._decayOpacities;if(d&&d.length===t.path.length&&!u){e.strokeStyle=i;const n=t.style.opacity??1;for(let o=0;t.path.length-1>o;o++)e.globalAlpha=.5*(d[o]+d[o+1])*n,e.beginPath(),e.moveTo(t.path[o][0],t.path[o][1]),e.lineTo(t.path[o+1][0],t.path[o+1][1]),e.stroke()}else if(u){const n=Qs(t.path,c,a,i);for(const t of n){e.beginPath(),e.strokeStyle=Do(e,t.color)||t.color,e.moveTo(t.path[0][0],t.path[0][1]);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1]);e.stroke()}}else{e.beginPath();const n=t.strokeGradient&&t.path.length>=2?Ko(e,t.strokeGradient,i,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=n||i,l)(0,Qc.line)().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,o]=t.path[0];e.moveTo(n,o);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}e.stroke()}if(t.style.fill&&t.style.fillOpacity&&t.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=t.style.fillOpacity,e.fillStyle=Vo(e,t.style.fill,t.style.fill),l&&!u)(0,Qc.line)().x(e=>e[0]).y(e=>e[1]).curve(l).context(e)(t.path);else{const[n,o]=t.path[0];e.moveTo(n,o);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1])}const n=t.path[0][0];e.lineTo(t.path[t.path.length-1][0],o.height),e.lineTo(n,o.height),e.closePath(),e.fill()}void 0!==n&&1>n&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function tl(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function nl(e,t,n=.3){tl(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function ol(e,t,n=.6){if(!tl(t))return;const o=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,r=t.cx??t.x??0,i=t.cy??t.y??0;e.beginPath(),e.arc(r,i,o,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function rl(e,t,n,o=.35){tl(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}var il=require("d3-shape");function sl(e,t){const n=Ho(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const o=(0,il.area)().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),o(t.topPath)}}function al(e,t){const n=Ho(t.curve);if(e.beginPath(),n)(0,il.line)().x(e=>e[0]).y(e=>e[1]).curve(n).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1])}}var cl=(e,t,n,o)=>{const r=t.filter(e=>"area"===e.type);for(const t of r){if(2>t.topPath.length)continue;let n=!1;t.clipRect&&(e.save(),e.beginPath(),e.rect(t.clipRect.x,t.clipRect.y,t.clipRect.width,t.clipRect.height),e.clip(),n=!0);const r=t._introClipFraction;void 0!==r&&1>r&&(e.save(),e.beginPath(),e.rect(0,0,o.width*r,o.height),e.clip());const i=Vo(e,t.style.fill,"#4e79a7"),s=t._decayOpacities,a=!(!t.colorThresholds?.length||!t.rawValues||t.rawValues.length!==t.topPath.length),c=!!t.strokeColorBands?.length;if(s&&s.length===t.topPath.length&&!a&&!c){const n=t.style.fillOpacity??.7;e.fillStyle=i;for(let o=0;t.topPath.length-1>o;o++)e.globalAlpha=.5*(s[o]+s[o+1])*n,e.beginPath(),e.moveTo(t.topPath[o][0],t.topPath[o][1]),e.lineTo(t.topPath[o+1][0],t.topPath[o+1][1]),e.lineTo(t.bottomPath[o+1][0],t.bottomPath[o+1][1]),e.lineTo(t.bottomPath[o][0],t.bottomPath[o][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=Do(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(s[n]+s[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const l=t.style.opacity??1;if(sl(e,t),t.fillGradient&&t.fillGradient.stops.length>=2&&t.fillGradient){let n=1/0;for(const e of t.topPath)n>e[1]&&(n=e[1]);let o=-1/0;for(const e of t.bottomPath)e[1]>o&&(o=e[1]);const r=Xo(e,t.fillGradient,"string"==typeof i?i:"#4e79a7",0,n,0,o);e.fillStyle=r||i,e.globalAlpha=l}else e.globalAlpha=(t.style.fillOpacity??.7)*l,e.fillStyle=i;if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(sl(e,t),rl(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=l;const n=Do(e,t.style.stroke)||t.style.stroke,o=a||c||!t.strokeGradient||2>t.topPath.length?null:Ko(e,t.strokeGradient,n,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0);if(e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]),c){let o=1/0,r=-1/0;for(const[e]of t.topPath)o=Math.min(o,e),r=Math.max(r,e);const i=e.lineWidth;for(const s of t.strokeColorBands){e.save(),e.beginPath(),e.rect(o-i,s.y,r-o+2*i,s.height),e.clip();const a=s.color??n;e.strokeStyle=Do(e,a)||a,al(e,t),e.stroke(),e.restore()}}else if(a){const o=Qs(t.topPath,t.rawValues,t.colorThresholds,n);for(const t of o){e.beginPath(),e.strokeStyle=Do(e,t.color)||t.color,e.moveTo(t.path[0][0],t.path[0][1]);for(let n=1;t.path.length>n;n++)e.lineTo(t.path[n][0],t.path[n][1]);e.stroke()}}else e.strokeStyle=o||n,al(e,t),e.stroke()}void 0!==r&&1>r&&e.restore(),n&&e.restore(),e.globalAlpha=1}},ll=(e,t,n,o)=>{const r=t.filter(e=>"point"===e.type);if(0!==r.length){e.save();try{const t=e.globalAlpha;for(const n of r)e.beginPath(),e.arc(n.x,n.y,n.r,0,2*Math.PI),e.globalAlpha=t*(n.style.opacity??n.style.fillOpacity??1),e.fillStyle=Vo(e,n.style.fill,"#4e79a7"),e.fill(),n.style.stroke&&"none"!==n.style.stroke&&(e.strokeStyle=Vo(e,n.style.stroke,n.style.stroke),e.lineWidth=n.style.strokeWidth||1,e.stroke()),ol(e,n)}finally{e.restore()}}},ul=new Map;function dl(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=ul.get(t);return n||(n=new Path2D(fn(e.symbolType,e.size)),ul.size>256&&ul.clear(),ul.set(t,n)),n}catch{return null}}var hl=(e,t)=>{const n=e.globalAlpha;for(const o of t){if("symbol"!==o.type)continue;const t=o;if(0>=t.size)continue;const r=dl(t);if(!r)continue;e.save(),e.translate(t.x,t.y),t.rotation&&e.rotate(t.rotation);const i=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=n*i*(t.style.fillOpacity??1),e.fillStyle=Vo(e,t.style.fill,"#4e79a7"),e.fill(r)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*i,e.strokeStyle=Vo(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth??1,e.stroke(r)),e.restore()}e.globalAlpha=n};function fl(e,t,n,o,r){if(0>=t.size)return;const i=t.glyph;if(!i||!i.parts?.length)return;const s=Ao(i,t.size);if(0>=s.scale)return;const a=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=a)return;const c=t=>{const n=Vo(e,t,t);return"string"==typeof n?n:t},l=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,o),t.rotation&&e.rotate(t.rotation),e.translate(s.offsetX,s.offsetY),e.scale(s.scale,s.scale),e.globalAlpha=r*a*(t.style.fillOpacity??1);const u=jo(i,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&Ro(e,i,l,t.accent,t.ghostColor,c),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),Ro(e,i,l,t.accent,void 0,c),e.restore()}function pl(e,t){const{x:n,y:o,w:r,h:i}=t,{tl:s,tr:a,br:c,bl:l}=ea(t);e.beginPath(),e.moveTo(n+s,o),e.lineTo(n+r-a,o),a>0&&e.arcTo(n+r,o,n+r,o+a,a),e.lineTo(n+r,o+i-c),c>0&&e.arcTo(n+r,o+i,n+r-c,o+i,c),e.lineTo(n+l,o+i),l>0&&e.arcTo(n,o+i,n,o+i-l,l),e.lineTo(n,o+s),s>0&&e.arcTo(n,o,n+s,o,s),e.closePath()}function yl(e){switch(e.roundedEdge){case"bottom":return{x0:e.x,y0:e.y+e.h,x1:e.x,y1:e.y};case"right":return{x0:e.x+e.w,y0:e.y,x1:e.x,y1:e.y};case"left":return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y};default:return{x0:e.x,y0:e.y,x1:e.x,y1:e.y+e.h}}}var gl=(e,t,n,o)=>{const r=t.filter(e=>"rect"===e.type);for(const t of r){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)ml(e,t);else if(t.cornerRadii&&Js(t.cornerRadii)){const n=Vo(e,t.style.fill,Do(e,"var(--semiotic-primary, #007bff)")),o=yl(t),r=t.fillGradient&&"string"==typeof n?Xo(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n,pl(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Do(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else if(t.roundedTop&&t.roundedTop>0){const n=Vo(e,t.style.fill,Do(e,"var(--semiotic-primary, #007bff)")),o=yl(t),r=t.fillGradient&&"string"==typeof n?Xo(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n;const i=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:s,y:a,w:c,h:l}=t;switch(t.roundedEdge){case"right":e.moveTo(s,a),e.lineTo(s+c-i,a),e.arcTo(s+c,a,s+c,a+i,i),e.lineTo(s+c,a+l-i),e.arcTo(s+c,a+l,s+c-i,a+l,i),e.lineTo(s,a+l);break;case"left":e.moveTo(s+c,a),e.lineTo(s+i,a),e.arcTo(s,a,s,a+i,i),e.lineTo(s,a+l-i),e.arcTo(s,a+l,s+i,a+l,i),e.lineTo(s+c,a+l);break;case"bottom":e.moveTo(s,a),e.lineTo(s+c,a),e.lineTo(s+c,a+l-i),e.arcTo(s+c,a+l,s+c-i,a+l,i),e.lineTo(s+i,a+l),e.arcTo(s,a+l,s,a+l-i,i);break;default:e.moveTo(s,a+l),e.lineTo(s,a+i),e.arcTo(s,a,s+i,a,i),e.lineTo(s+c-i,a),e.arcTo(s+c,a,s+c,a+i,i),e.lineTo(s+c,a+l)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Do(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const n=Vo(e,t.style.fill,Do(e,"var(--semiotic-primary, #007bff)")),o=yl(t),r=t.fillGradient&&"string"==typeof n?Xo(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=r||n,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=Do(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}nl(e,t),e.globalAlpha=1}};function ml(e,t){const n=t.style.icon,o=t.style.iconPadding||2,r=Math.min(t.w,t.h)-o;if(0>=r)return;const i=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),i){const i=r+o,s=t.x+(t.w-r)/2;for(let o=t.y+t.h-r;o>=t.y-r;o-=i)e.drawImage(n,s,o,r,r)}else{const i=r+o,s=t.y+(t.h-r)/2;for(let o=t.x;t.x+t.w>o;o+=i)e.drawImage(n,o,s,r,r)}e.restore()}function xl(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>128?"#000":"#fff"}function bl(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var vl=(e,t,n,o)=>{const r=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of r){const n=t.style;null!=n?.opacity&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h);const o=Math.max(0,n?.strokeWidth??1);if(o>0&&(e.strokeStyle=Do(e,n?.stroke??"var(--semiotic-surface, #fff)"),e.lineWidth=o,e.strokeRect(t.x,t.y,t.w,t.h)),nl(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):bl(t.value),o=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),r=t.x+t.w/2,i=t.y+t.h/2;e.fillStyle=xl(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,r,i)}}}finally{e.restore()}},wl=(e,t,n,o)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const r=(t._decayOpacity??1)*(t.style?.opacity??1);1!==r&&(e.globalAlpha=r);const i=Do(e,t.wickColor)||t.wickColor,s=60>o.height,a=s?Math.max(t.wickWidth,2):t.wickWidth,c=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=i,e.lineWidth=a,e.stroke()};if(s||c(),t.isRange){const n=t.dotRadius??Math.max(2,Math.min(t.bodyWidth/2,.12*o.height));e.fillStyle=i,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),o=Math.abs(t.openY-t.closeY),r=t.isUp?t.upColor:t.downColor,i=Do(e,r)||r;e.fillStyle=i,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1)),e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1))}s&&c(),e.restore()}},kl={line:[cl,el,ll],area:[cl,ll],stackedarea:[cl,ll],scatter:[ll,hl],bubble:[ll,hl],heatmap:[vl],bar:[gl],swarm:[ll],waterfall:[(e,t,n,o)=>{gl(e,t);const r=t.filter(e=>"rect"===e.type);if(2>r.length)return;const i=r[0].datum,s=i?._connectorStroke;if(s){e.save(),e.strokeStyle=Do(e,s)||s,e.lineWidth=i?._connectorWidth??1,e.setLineDash([]);for(let t=0;r.length-1>t;t++){const o=r[t],i=r[t+1],s=o.datum,a=i.datum;if(null==s?.cumEnd||null==a?.baseline)continue;const c=n.y(s.cumEnd),l=o.x+o.w,u=i.x;e.beginPath(),e.moveTo(l,c),e.lineTo(u,c),e.stroke()}e.restore()}}],candlestick:[wl],mixed:[cl,el,ll],custom:[cl,gl,vl,el,ll,hl,(e,t)=>{const n=e.globalAlpha;for(const o of t)"glyph"===o.type&&fl(e,o,o.x,o.y,n);e.globalAlpha=n},wl]},Sl=new Set;function Al(e,t){const n="function"==typeof e?e(t.datum??null,t):e;return(o=n)&&"object"==typeof o&&"string"==typeof o.id&&"function"==typeof o.cacheKey&&"function"==typeof o.drawCanvas&&"function"==typeof o.renderStaticSVG?n:void 0;var o}function Ml(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const n=`${e}:${t}`;Sl.has(n)||(Sl.add(n),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function _l(e){const{node:t,index:n,renderMode:o,fallback:r}=e,i=Al(o,t);if(!i)return r();const s=i.renderStaticSVG({node:t,style:t.style??{},key:`${i.id}-${n}`});return null!=s?s:(Ml(i.id,t.type??"unknown"),r())}function Pl(e){const t=[];return e.nodes.forEach((n,o)=>{const r=_l({node:n,index:o,renderMode:e.renderMode,fallback:()=>e.fallback(n,o)});null!=r&&!1!==r&&t.push({node:n,element:r})}),t}require("react/jsx-runtime");var jl=require("react/jsx-runtime");function Cl(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function Rl({hover:e}){const t=e.data??{},n=t.y??t.value,o=t.x??t.time;if(void 0===n&&void 0===o){const e=wc(t);if(null!=e.title||e.entries.length>0)return(0,jl.jsxs)("div",{className:"semiotic-tooltip",style:Sc,children:[null!=e.title&&(0,jl.jsx)("div",{style:{fontWeight:600,marginBottom:e.entries.length?2:0},children:e.title+""}),e.entries.map(e=>(0,jl.jsxs)("div",{style:{opacity:.7,fontSize:11},children:[e.key,":"," ",(0,jl.jsx)("span",{style:{fontWeight:600},children:Cl(e.value)})]},e.key))]})}return(0,jl.jsxs)("div",{className:"semiotic-tooltip",style:Sc,children:[(0,jl.jsx)("div",{style:{fontWeight:600,marginBottom:2},children:Cl(n)}),(0,jl.jsx)("div",{style:{opacity:.7,fontSize:11},children:Cl(o)})]})}function Ll(e){const{onObservation:t,datum:n,x:o=0,y:r=0,chartType:i,chartId:s,context:a,timestamp:c=Date.now()}=e;t&&(n?(t({type:"hover",datum:n,x:o,y:r,timestamp:c,chartType:i,chartId:s}),"focus"===a?.type&&t({type:"focus",datum:n,inputType:"touch"===a.inputType?"pointer":a.inputType,timestamp:c,chartType:i,chartId:s})):t({type:"hover-end",timestamp:c,chartType:i,chartId:s}))}function Il(e){const{onObservation:t,datum:n,x:o=0,y:r=0,chartType:i,chartId:s,context:a,timestamp:c=Date.now()}=e;t&&(n?(t({type:"click",datum:n,x:o,y:r,timestamp:c,chartType:i,chartId:s}),"activate"===a?.type&&t({type:"activate",datum:n,inputType:a.inputType,timestamp:c,chartType:i,chartId:s})):t({type:"click-end",timestamp:c,chartType:i,chartId:s}))}Rl.ownsChrome=!0;var Tl=require("react"),$l=require("react");function zl(e,t,n){const o=e.byGroup.get(t);let r=0,i=Math.abs(o[0].x-n.x);for(let e=1;o.length>e;e++){const t=Math.abs(o[e].x-n.x);i>t&&(i=t,r=e)}return o[r]._flatIndex}function Dl(e){const t=[];for(const n of e)switch(n.type){case"point":t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"symbol":if(0>=n.size)break;t.push({x:n.x,y:n.y,datum:n.datum,shape:"circle",group:"_default"});break;case"glyph":{if(0>=n.size||null==n.datum)break;const e=Co(n.glyph,n.size);t.push({x:n.x+e.centerDx,y:n.y+e.centerDy,datum:n.datum,shape:"rect",w:2*e.halfWidth,h:2*e.halfHeight,group:"_default"});break}case"line":{const e=n,o=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.path.length>n&&o.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:o[n],shape:"circle",group:r});break}case"area":{const e=n,o=Array.isArray(e.datum)?e.datum:[],r=e.group??"_default";for(let n=0;e.topPath.length>n&&o.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:o[n],shape:"circle",group:r});break}case"rect":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:n.group??"_default"});break;case"heatcell":t.push({x:n.x+n.w/2,y:n.y+n.h/2,datum:n.datum,shape:"rect",w:n.w,h:n.h,group:"_default"})}return t.sort((e,t)=>e.x-t.x||e.y-t.y),t}var El=require("react/jsx-runtime"),Ol={top:20,right:20,bottom:30,left:40},Fl=za;function Bl(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var Nl=(0,vt.memo)((0,vt.forwardRef)(function(e,t){const{chartType:n,runtimeMode:o,data:r,chunkThreshold:i,chunkSize:s,xAccessor:a,yAccessor:c,accessorRevision:l,colorAccessor:u,sizeAccessor:d,symbolAccessor:h,symbolMap:f,groupAccessor:p,lineDataAccessor:y,curve:g,normalize:m,baseline:x,stackOrder:b,binSize:v,valueAccessor:w,arrowOfTime:k="right",windowMode:S="sliding",windowSize:A=200,timeAccessor:M,xExtent:_,yExtent:P,extentPadding:j=.1,scalePadding:C,sizeRange:R,size:L=[500,300],responsiveWidth:I,responsiveHeight:T,margin:$,className:z,background:E,renderMode:O,lineStyle:F,pointStyle:B,areaStyle:N,barStyle:W,waterfallStyle:q,swarmStyle:Y,barColors:G,colorScheme:H,boundsAccessor:V,boundsStyle:X,y0Accessor:U,band:K,gradientFill:Z,lineGradient:Q,semanticLineStops:J,areaGroups:ee,openAccessor:te,highAccessor:ne,lowAccessor:oe,closeAccessor:re,candlestickStyle:ie,showAxes:se=!0,axes:ae,xLabel:ce,yLabel:le,yLabelRight:ue,xFormat:de,yFormat:he,axisExtent:fe,tickFormatTime:pe,tickFormatValue:ye,hoverAnnotation:ge,tooltipContent:me,customHoverBehavior:xe,customClickBehavior:be,onObservation:ve,annotationObservationCallback:we,chartId:ke,enableHover:Se,hoverRadius:Ae=30,tooltipMode:Me,annotations:_e,onAnnotationActivate:Pe,autoPlaceAnnotations:je,svgAnnotationRules:Ce,showGrid:Re,legend:Le,legendHoverBehavior:Ie,legendClickBehavior:ze,legendHighlightedCategory:De,legendIsolatedCategories:Ee,legendPosition:Oe,legendLayout:Fe,legendCategoryAccessor:Be,onCategoriesChange:Ne,backgroundGraphics:We,foregroundGraphics:Ye,canvasPreRenderers:Ge,svgPreRenderers:He,title:Ve,categoryAccessor:Xe,brush:Ue,onBrush:Ke,decay:Ze,pulse:Qe,transition:Je,animate:et,staleness:tt,frameScheduler:nt,clock:ot,random:rt,seed:it,paused:st=!1,suspendWhenHidden:at=!0,heatmapAggregation:ct,heatmapXBins:lt,heatmapYBins:ut,showValues:dt,heatmapValueFormat:ht,marginalGraphics:ft,pointIdAccessor:pt,xScaleType:yt,yScaleType:gt,accessibleTable:xt=!0,description:wt,summary:kt,linkedCrosshairName:St,linkedCrosshairSourceId:At,customLayout:Pt,onLayoutError:jt,layoutConfig:Ct,layoutSelection:Rt}=e,{customHoverBehavior:Lt,customClickBehavior:It,hasClickBehavior:Tt}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:o,chartType:r}){return{customHoverBehavior:(0,Tl.useCallback)((t,i)=>{e?.(t,i),Ll({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:r,chartId:o,context:i})},[o,r,e,n]),customClickBehavior:(0,Tl.useCallback)((e,i)=>{t?.(e,i),Il({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:r,chartId:o,context:i})},[o,r,t,n]),hasClickBehavior:!(!t&&!n)}}({customHoverBehavior:xe,customClickBehavior:be,onObservation:ve,chartId:ke,chartType:"StreamXYFrame"}),$t=(0,vt.useId)().replace(/:/g,""),zt=(0,vt.useRef)(!1),Dt=(0,vt.useRef)({w:-1,h:-1}),Et=(0,vt.useRef)(!1),Ot=Bc({sizeProp:L,responsiveWidth:I,responsiveHeight:T,userMargin:$,marginDefault:Ol,title:Ve,legend:Le,legendPosition:Oe,animate:et,transitionProp:Je,frameScheduler:nt,clock:ot,random:rt,seed:it,paused:st,suspendWhenHidden:at,themeDirtyRef:zt}),Ft=function(){const[e,t]=(0,Ma.useState)(!1);return _a(()=>{t(!0)},[]),e}(),Bt=function(){const e=(0,Ma.useSyncExternalStore)(Pa,ja,Ca);return(0,Ma.useRef)(e).current}(),{reducedMotionRef:Nt,responsiveRef:Wt,size:qt,currentTheme:Yt,transition:Gt,introEnabled:Ht,tableId:Vt,rafRef:Xt,renderFnRef:Ut,scheduleRender:Kt,frameRuntime:Zt}=Ot;let Qt=Ot.margin;if(ft){const e=60,t={...Ot.margin};ft.top&&e>t.top&&(t.top=e),ft.bottom&&e>t.bottom&&(t.bottom=e),ft.left&&e>t.left&&(t.left=e),ft.right&&e>t.right&&(t.right=e),Qt=t}const Jt=qt[0]-Qt.left-Qt.right,en=qt[1]-Qt.top-Qt.bottom,tn=(0,vt.useMemo)(()=>D(r),[r]),nn=ge??Se,[on,rn]=(0,vt.useState)(0),an=(0,vt.useRef)(0),[cn,ln]=(0,vt.useState)(null),un=Yc(Ye,qt,Qt,cn),dn=Yc(We,qt,Qt,cn),hn=(0,vt.useRef)(null),fn=(0,vt.useRef)(null),pn=(0,vt.useRef)(void 0),[yn,gn]=(0,vt.useState)(null),mn=(0,vt.useRef)(Fl.primary),xn=(0,vt.useRef)(function(){let e=-1,t=za;return{resolve(n){if(!n)return za;const o=Io;return o===e||(t=function(e){if(!e)return za;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),r=t.getPropertyValue("--semiotic-bg").trim(),i=t.getPropertyValue("--semiotic-primary").trim(),s=o||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),c=n||t.getPropertyValue("--surface-3").trim(),l=r||t.getPropertyValue("--surface-0").trim();return s||a||n||i?{axisStroke:c||za.axisStroke,tickText:s||za.tickText,crosshair:s?Da(s,"66"):za.crosshair,hoverFill:l?Da(l,"4D"):za.hoverFill,hoverStroke:s?Da(s,"99"):za.hoverStroke,pointRing:l||za.pointRing,primary:i||za.primary,background:l||za.background}:za}(n),e=o),t},invalidate(){e=-1}}}()),bn=(0,vt.useRef)(!1),vn=(0,so.useRef)(new fo("StreamXYFrame")),[wn,kn]=(0,vt.useState)(!1),[Sn,An]=(0,vt.useState)([]),[Mn,_n]=(0,vt.useState)([]),Pn="streaming"===o||["bar","swarm","waterfall"].includes(n),jn=function(e){const t=(0,Ra.useRef)(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return Ia(e,t);if(!Ta(e)||!Ta(t))return!1;const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;const n=e[o],r=t[o];if(!Object.is(n,r))if(Array.isArray(n)&&Array.isArray(r)){if(!Ia(n,r))return!1}else{if(!Ta(n)||!Ta(r))return!1;if(!La(n,r))return!1}}return!0}(t.current,e)||(t.current=e),t.current}((0,vt.useMemo)(()=>({chartType:n,runtimeMode:Pn?"streaming":"bounded",windowSize:A,windowMode:S,arrowOfTime:Pn?k:"right",extentPadding:j,scalePadding:C,axisExtent:fe,xAccessor:a,yAccessor:c,accessorRevision:l,timeAccessor:Pn?M:void 0,valueAccessor:w,colorAccessor:u,sizeAccessor:d,symbolAccessor:h,symbolMap:f,groupAccessor:p||(y?"_lineGroup":void 0),categoryAccessor:Xe,lineDataAccessor:y,xScaleType:yt,yScaleType:gt,xExtent:_,yExtent:P,sizeRange:R,binSize:v,normalize:m,baseline:x,stackOrder:b,boundsAccessor:V,boundsStyle:X,y0Accessor:U,band:K,gradientFill:Te(Z),areaGroups:ee?new Set(ee):void 0,lineGradient:$e(Q),semanticLineStops:J,openAccessor:te,highAccessor:ne,lowAccessor:oe,closeAccessor:re,candlestickStyle:ie,lineStyle:F,pointStyle:B,areaStyle:N,swarmStyle:Y,waterfallStyle:q,colorScheme:H,barColors:G,barStyle:W,annotations:_e,decay:Ze,pulse:Qe,transition:Gt,introAnimation:Ht,staleness:tt,clock:Zt.now,heatmapAggregation:ct,heatmapXBins:lt,heatmapYBins:ut,showValues:dt,heatmapValueFormat:ht,pointIdAccessor:pt,curve:g,themeCategorical:Yt?.colors?.categorical,themeSemantic:qe(Yt),themeSequential:Yt?.colors?.sequential,themeDiverging:Yt?.colors?.diverging,customLayout:Pt,onLayoutError:jt,layoutConfig:Ct,layoutMargin:Qt}),[n,Pn,A,S,k,j,C,fe,a,c,l,M,w,u,d,h,f,p,y,Xe,yt,gt,_,P,R,v,m,x,b,V,X,U,K,Z,ee,Q,J,te,ne,oe,re,ie,F,B,N,Y,q,H,G,W,_e,Ze,Qe,Gt,Ht,tt,Zt.now,ct,lt,ut,dt,ht,pt,g,Yt,Pt,jt,Ct,Qt])),Cn=(0,vt.useRef)(null);Cn.current||(Cn.current=new io(jn));const Rn=function(e,t,n,o){const r=(0,Hc.useRef)({accessor:t,onChange:n,readData:o}),i=(0,Hc.useRef)([]);return r.current={accessor:t,onChange:n,readData:o},(0,Hc.useCallback)(()=>{const{accessor:t,onChange:n,readData:o}=r.current;if(!n||!t)return;const s=function(e,t){if(!t)return[];const n=new Set,o=[];for(const r of e){if(!r||"object"!=typeof r)continue;const e="function"==typeof t?t(r):r[t];if(null==e)continue;const i=e+"";n.has(i)||(n.add(i),o.push(i))}return o}(e.current?o(e.current):[],t);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(s,i.current)||(i.current=s,n(s))},[e])}(Cn,Be,Ne,e=>e.getData());!function(e,t,n,o){(0,mo.useEffect)(()=>{e.current?.updateConfig(t),n.current=!0,o()},[t,o,e,n])}(Cn,jn,zt,Kt),function(e,t,n,o){const r=(0,mo.useRef)(null);(0,mo.useEffect)(()=>{const i=e.current;if(!i)return;const s=t??null;r.current!==s&&(r.current=s,i.setLayoutSelection(s),i.hasCustomRestyle?i.restyleScene(s):n.current=!0,o())},[t,o,e,n])}(Cn,Rt,zt,Kt);const Ln=(0,vt.useRef)(null);Ln.current||(Ln.current=new _t(e=>{const t=Cn.current;t&&t.ingest(e)&&(zt.current=!0,Kt())},{chunkThreshold:i,chunkSize:s})),(0,vt.useEffect)(()=>{Ln.current?.updateChunkOptions({chunkThreshold:i,chunkSize:s})},[i,s]);const In=(0,vt.useCallback)(e=>{Ln.current?.push(e)},[]),Tn=(0,vt.useCallback)(e=>{Ln.current?.pushMany(e)},[]),$n=(0,vt.useCallback)(()=>{Ln.current?.clear(),Cn.current?.clear(),zt.current=!0,Kt()},[Kt]);(0,vt.useImperativeHandle)(t,()=>({push:In,pushMany:Tn,remove:e=>{Ln.current?.flush();const t=Cn.current?.remove(e)??[];return t.length>0&&(hn.current&&t.some(e=>e===hn.current?.data)&&(hn.current=null,gn(null)),zt.current=!0,Kt()),t},update:(e,t)=>{Ln.current?.flush();const n=Cn.current?.update(e,t)??[];return n.length>0&&(zt.current=!0,Kt()),n},clear:$n,getData:()=>(Ln.current?.flush(),Cn.current?.getData()??[]),getScales:()=>Cn.current?.scales??null,getExtents:()=>Cn.current?.getExtents()??null,getCustomLayout:()=>Cn.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Cn.current?.lastCustomLayoutFailure??null}),[In,Tn,$n,Kt]),(0,vt.useEffect)(()=>{if(r){if(y&&tn.length>0&&"object"==typeof tn[0]&&null!==tn[0]){const e="string"==typeof y?y:"coordinates";if(Array.isArray(tn[0][e])){const t=[];for(const n of tn){const o=n[e];if(Array.isArray(o)){const e=n.label||n.id||n.key;if(null!=e)for(const n of o)t.push({...n,_lineGroup:e});else for(const e of o)t.push(e)}}return void Ln.current?.setBoundedData(t)}}Ln.current?.setBoundedData(tn)}},[r,tn,y]);const{canvasRef:zn,interactionCanvasRef:Dn}=function(e,t){return function(e){const{cancelRender:t,dirtyRef:n,frameRuntime:o,manageFrameRuntime:r,scheduleRender:i}=e,s=(0,Nc.useRef)(null),a=(0,Nc.useRef)(null),c=(0,Nc.useRef)(!1);return function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:o,dirtyRef:r,renderFnRef:i,cancelRender:s,cleanup:a}=e;_a(()=>{const e=o.current;t&&n&&e?.cancelIntroAnimation?.(),!n&&e?.sceneNodes&&e.sceneNodes.length>0&&e?.markStylePaintPending?e.markStylePaintPending():r.current=!0,s?.(),i.current()},[t,n]);const c=(0,Ma.useRef)(a);c.current=a,(0,Ma.useEffect)(()=>()=>c.current?.(),[])}({hydrated:e.hydrated,wasHydratingFromSSR:e.wasHydratingFromSSR,storeRef:e.storeRef,dirtyRef:e.dirtyRef,renderFnRef:e.renderFnRef,cancelRender:e.cancelRender,cleanup:e.cleanup}),(0,Nc.useEffect)(()=>{if(!1!==r)return o.subscribe(()=>{o.isActive?(n.current=!0,i()):t()})},[t,n,o,r,i]),(0,Nc.useEffect)(()=>{!c.current&&(c.current=!0,e.skipInitialCanvasPaintInvalidation)||(e.dirtyRef.current=!0,e.scheduleRender())},e.canvasPaintDependencies),{canvasRef:s,interactionCanvasRef:a}}({...t,renderFnRef:e.renderFnRef,scheduleRender:e.scheduleRender,cancelRender:e.cancelRender,frameRuntime:e.frameRuntime})}(Ot,{storeRef:Cn,dirtyRef:zt,hydrated:Ft,wasHydratingFromSSR:Bt,cleanup:()=>Ln.current?.clear(),canvasPaintDependencies:[n,Jt,en,se,E,We,F,O,Ge,Kt]}),{hoverHandlerRef:En,hoverLeaveRef:On,onPointerMove:Fn,onPointerLeave:Bn}=Ot;En.current=e=>{if(!nn)return;const t=zn.current;if(!t)return;const o=t.getBoundingClientRect(),r=e.clientX-o.left-Qt.left,i=e.clientY-o.top-Qt.top;if(0>r||r>Jt||0>i||i>en)return void(hn.current&&(hn.current=null,fn.current=null,gn(null),Lt&&(Lt(null),zt.current=!0),Kt()));const s=Cn.current;if(!s||0===s.scene.length)return;const c=fc(Ae,e.pointerType),l=er(s.scene,r,i,c,s.quadtree,s.maxPointRadius),u="multi"===Me,d=()=>{hn.current&&(hn.current=null,fn.current=null,gn(null),Lt&&Lt(null),Kt())};if(!l&&!u)return void d();const h=u||!l?r:l.x,f=u||!l?i:l.y,p=l?.datum?sn(l.datum,s.resolvedRibbons):{},y=s.scales?.x?.invert,g="function"==typeof y?y(h):void 0;let m=yc(p,h,f,null!=g?{xValue:g,xPx:h}:void 0);if(u&&s.scene.length>0&&s.scales){const e=function(e,t,n=30){const o=[];for(const r of e)if("line"===r.type){const e=r;if(2>e.path.length)continue;const i=tr(Jo(e.path,e.curve),t,n);if(null===i)continue;const s=dr(e.path,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.path[s][0],y:i,group:e.group,color:e.style.stroke})}else if("area"===r.type){const e=r;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const i=Jo(e.topPath,e.curve),s=Jo(e.bottomPath,e.curve),a=tr(i,t,n);if(null===a)continue;const c=tr(s,t,n),l=dr(e.topPath,t);o.push({node:r,datum:Array.isArray(e.datum)&&e.datum[l]?e.datum[l]:e.datum,x:e.topPath[l][0],y:a,y0:c??void 0,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return o}(s.scene,h,Math.max(c,Jt));if(e.length>0){const t=s.scales.y.invert,o=mn.current,r=y?y(h):h;if(l)m.xValue=r,m.xPx=h;else{const e={xValue:r};"string"==typeof a&&(e[a]=r),m=yc(e,h,f,{xValue:r,xPx:h})}m.allSeries=e.map(e=>{const r=t?t(e.y):e.y,i=null!=e.y0?t?t(e.y0):e.y0:void 0;return{group:e.group||"",value:"stackedarea"===n&&null!=i?r-i:r,valuePx:e.y,color:e.color||o,datum:sn(e.datum,s.resolvedRibbons)}})}}l||m.allSeries?.length?(hn.current=m,fn.current=l?.node??null,gn(m),Lt&&(Lt(m),zt.current=!0),Kt()):d()},On.current=()=>{hn.current&&(hn.current=null,fn.current=null,gn(null),Lt&&(Lt(null),zt.current=!0),Kt())};const Nn=(0,vt.useRef)(()=>{});Nn.current=e=>{if((t=e.target)instanceof Element&&null!=t.closest("[data-semiotic-annotation-widget]"))return;var t;if(!It)return;const n=zn.current;if(!n)return;const o=n.getBoundingClientRect(),r=e.clientX-o.left-Qt.left,i=e.clientY-o.top-Qt.top;if(0>r||r>Jt||0>i||i>en)return void It(null);const s=Cn.current;if(!s||0===s.scene.length)return void It(null);const a=fc(Ae,pn.current),c=er(s.scene,r,i,a,s.quadtree,s.maxPointRadius);if(!c)return void It(null);const l=c.datum||{},u=s.scales?.x?.invert,d="function"==typeof u?u(c.x):void 0;var h;It(yc(l,c.x,c.y,null!=d?{xValue:d,xPx:c.x}:void 0),{type:"activate",inputType:(h=pn.current,"touch"===h?"touch":"pointer")})};const Wn=(0,vt.useCallback)(e=>Nn.current(e),[]),{kbFocusIndexRef:qn,focusedNavPointRef:Yn,onKeyDown:Gn}=(Hn={storeRef:Cn,hoverRef:hn,hoveredNodeRef:fn,setHoverPoint:gn,customHoverBehavior:Lt,customClickBehavior:It,scheduleRender:Kt},function({storeRef:e,hoverRef:t,hoveredNodeRef:n,setHoverPoint:o,customHoverBehavior:r,customClickBehavior:i,scheduleRender:s,extractPoints:a,toHover:c}){const l=(0,$l.useRef)(-1),u=(0,$l.useRef)(null),d=(0,$l.useRef)(null),h=(0,$l.useCallback)(h=>{if(function(e){const t=e.target;return t instanceof Element&&t!==e.currentTarget&&null!=t.closest("button, a[href], input, select, textarea, summary, [contenteditable='true'], [role='button'], [role='link'], [role='checkbox'], [role='radio'], [role='switch']")}(h))return;const f=e.current;if(!f)return;const p=()=>{l.current=-1,u.current=null,t.current=null,n&&(n.current=null),o(null),r(null),s()};if(0===f.scene.length)return void(0>l.current||p());let y;if(d.current?.version===f.version)y=d.current.graph;else{const e=a(f.scene);if(0===e.length)return void(0>l.current||p());y=function(e){const t=new Map;for(const n of e){const e=n.group??"_default";let o=t.get(e);o||(o=[],t.set(e,o)),o.push(n)}for(const e of t.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const n=Array.from(t.keys()).sort((e,n)=>{const o=t.get(e),r=t.get(n);return(o.length>0?o[0].y:0)-(r.length>0?r[0].y:0)}),o=Array.from(t.values()).flat();o.sort((e,t)=>e.x-t.x||e.y-t.y);const r=new Map;for(let e=0;o.length>e;e++){o[e]._flatIndex=e;const t=o[e].datum?.id;null!=t&&r.set(t+"",e)}return{flat:o,groups:n,byGroup:t,idToIdx:r}}(e),d.current={version:f.version,graph:y}}let g=l.current;if(y.flat.length>g||(p(),g=-1),("Enter"===h.key||" "===h.key)&&g>=0)return h.preventDefault(),void i(c(y.flat[g],f),{type:"activate",inputType:"keyboard"});if(0>g){if("Escape"===h.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(h.key))return;h.preventDefault(),l.current=0;const e=y.flat[0];u.current=e;const n=c(e,f);return t.current=n,o(n),r(n,{type:"focus",inputType:"keyboard"}),void s()}const m=function(e,t,n){const{group:o,indexInGroup:r}=t,i=n.byGroup.get(o);switch(e){case"ArrowRight":return i.length-1>r?i[r+1]._flatIndex:t.flatIndex;case"ArrowLeft":return r>0?i[r-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(o);return n.groups.length-1>e?zl(n,n.groups[e+1],i[r]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(o);return e>0?zl(n,n.groups[e-1],i[r]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}(h.key,function(e,t){if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const n=Math.max(0,Math.min(t,e.flat.length-1)),o=e.flat[n];return{flatIndex:n,group:o.group??"_default",indexInGroup:o._groupIndex??0}}(y,g),y);if(null===m)return;if(h.preventDefault(),0>m)return void p();l.current=m;const x=y.flat[m];u.current=x;const b=c(x,f);t.current=b,o(b),r(b,{type:"focus",inputType:"keyboard"}),s()},[i,r,a,t,n,s,o,e,c]);return{kbFocusIndexRef:l,focusedNavPointRef:u,onKeyDown:h}}({...Hn,extractPoints:Dl,toHover:(e,t)=>function(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}({...e,datum:sn(e.datum,t.resolvedRibbons)})}));var Hn;const Vn=(0,vt.useCallback)(e=>{pn.current=e.pointerType,qn.current=-1,Yn.current=null,Fn(e)},[Yn,qn,Fn]),Xn=(0,vt.useCallback)(e=>{pn.current="mouse",qn.current=-1,Yn.current=null,Fn({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[Yn,qn,Fn]),Un=(0,vt.useCallback)(e=>{pn.current=e.pointerType},[]);Ut.current=()=>{if(Xt.current=null,!Zt.isActive)return;const e=zn.current,t=Dn.current;if(!e||!t)return;const o=Cn.current;if(!o)return;const r=Zt.now(),i=o.advanceTransition(Nt.current?r+1e6:r),s=!Nt.current&&i,l=Dt.current.w!==Jt||Dt.current.h!==en,u=zt.current||i||l,d=o.consumeStylePaintPending();let h=!1;const f=o.getLastUpdateResult(),p=vn.current.beforeCompute(f,s);!u||s&&!l||(o.computeScene({width:Jt,height:en}),Dt.current={w:Jt,h:en},h=!0,Rn()),vn.current.afterCompute(p,h,l);const y=function(e,t,n,o){const r=o.current,i=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,s=!i&&e.hasActivePulsesAt(t),a=!(n||i||!s&&!r)&&e.refreshPulse(t);return o.current=s,{changed:a,pending:s}}(o,r,h,Et),g=function(){if("undefined"==typeof window)return 1;const e=window.devicePixelRatio||1,t=function(){if("undefined"==typeof window)return!1;const e="function"==typeof window.matchMedia&&window.matchMedia("(pointer: coarse)").matches,t=768>Math.min(window.innerWidth||1/0,window.innerHeight||1/0);return e||t}()?2:3;return Math.max(1,Math.min(e,t))}(),m=xn.current.resolve(e);mn.current=m.primary;const x=yr(tt,o.lastIngestTime>0?r-o.lastIngestTime:0),b=tt&&x.isStale;if(u||d||y.changed){const t=Gc(e,qt,Qt,g);if(t){if(t.clearRect(-Qt.left,-Qt.top,qt[0],qt[1]),tt&&1>x.alpha&&(t.globalAlpha=x.alpha),function(e,t){const{background:n,hasBackgroundGraphics:o=!1,themeBackground:r="",x:i=0,y:s=0,width:a,height:c}=t,l=$a({background:n,hasBackgroundGraphics:o,themeBackground:r});if(!l)return!1;const u=Do(e,l);u&&(e.fillStyle=u,e.fillRect(i,s,a,c))}(t,{background:E,hasBackgroundGraphics:!!We,themeBackground:m.background,x:-Qt.left,y:-Qt.top,width:qt[0],height:qt[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Jt,en),t.clip()),Ge&&o.scales)for(const e of Ge)t.save(),e(t,o.scene,o.scales,{width:Jt,height:en}),t.restore();const e=Pt?kl.custom:kl[n];!function(e){const{context:t,nodes:n,renderMode:o,pixelRatio:r,paintBuiltIn:i}=e;if(!o||"sketchy"===o)return void i(n);let s=[];const a=()=>{s.length&&(i(s),s=[])};for(const e of n){const n=Al(o,e);if(!n){s.push(e);continue}let c;a(),t.save();try{c=n.drawCanvas({context:t,node:e,style:e.style??{},pixelRatio:r})}finally{t.restore()}c||(Ml(n.id,e.type??"unknown"),i([e]))}a()}({context:t,nodes:o.scene,renderMode:O,pixelRatio:g,paintBuiltIn:n=>{if(e&&o.scales)for(const r of e)r(t,n,o.scales,{width:Jt,height:en})}}),t.restore(),tt&&1>x.alpha&&(t.globalAlpha=1)}}const v=!!(nn&&hn.current&&o.scales),w=!!(fn.current&&Array.isArray(ge)&&ge.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),k=v||w;if(k||bn.current){const e=Gc(t,qt,Qt,g);if(e&&(e.clearRect(-Qt.left,-Qt.top,qt[0],qt[1]),v&&hn.current&&function(e,t,n,o,r,i,s){if(!1===r.crosshair)return;const a=t.allSeries,c=a&&a.length>0,l=t.xPx??t.x;e.save();const u="object"==typeof r.crosshair?r.crosshair:{};if(e.strokeStyle=u.stroke||s.crosshair,e.lineWidth=u.strokeWidth||1,e.setLineDash(u.strokeDasharray?u.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(c?l:t.x,0),e.lineTo(c?l:t.x,o),e.stroke(),c||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),c){e.lineWidth=2,e.strokeStyle=s.pointRing;for(const t of a)null!=t.valuePx&&(e.beginPath(),e.arc(l,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||s.primary,e.fill(),e.stroke())}else{const n=r.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(i)||s.primary;e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=n,e.fill(),e.strokeStyle=s.pointRing,e.lineWidth=2,e.stroke()}}(e,hn.current,Jt,en,"object"==typeof nn?nn:{},fn.current,m),w&&fn.current&&Array.isArray(ge))){const t=ge.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o,r){if(!n)return;const i="group"in n?n.group:void 0;if(void 0!==i)for(const n of t){if("line"!==n.type)continue;if(n.group!==i)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?n.datum?o.style(n.datum):{}:o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||r.primary,e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=t.opacity??1,e.stroke(),e.restore()}}(e,o.scene,fn.current,t,m)}bn.current=k}u&&e&&e.setAttribute("aria-label",Va(o.scene,n+" chart"));const S=zt.current;if(zt.current=S&&s&&!h,S&&o.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!cn||e(cn.x.domain()[0])!==e(o.scales.x.domain()[0])||e(cn.x.domain()[1])!==e(o.scales.x.domain()[1])||e(cn.y.domain()[0])!==e(o.scales.y.domain()[0])||e(cn.y.domain()[1])!==e(o.scales.y.domain()[1])||cn.x.range()[0]!==o.scales.x.range()[0]||cn.x.range()[1]!==o.scales.x.range()[1]||cn.y.range()[0]!==o.scales.y.range()[0]||cn.y.range()[1]!==o.scales.y.range()[1])&&ln(o.scales),ft){const e=o.getData(),t="function"==typeof a?a:e=>e[a||"x"],n="function"==typeof c?c:e=>e[c||"y"];An(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),_n(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((_e&&_e.length>0||Pt)&&(h||s))||!h&&33>r-an.current||(rn(e=>e+1),an.current=r),tt?.showBadge&&kn(!!b),(s||null!=o.activeTransition||y.pending)&&Kt()},function(e,t,n,o,r,i){const s=(0,hr.useRef)("fresh");(0,hr.useEffect)(()=>{if(!e)return;const a=setInterval(()=>{const a=t.current;if(!a||0===a.lastIngestTime)return;const c="undefined"!=typeof performance?performance.now():Date.now(),l=yr(e,c-a.lastIngestTime);l.band===s.current&&l.isStale===r||(s.current=l.band,l.isStale!==r&&i(l.isStale),n.current=!0,o())},1e3);return()=>clearInterval(a)},[e,r,o,t,i,n])}(tt,Cn,zt,Kt,wn,kn);const Kn=(0,vt.useMemo)(()=>{if(de||pe)return;const e=Cn.current;return e?.xIsDate&&cn?Kc(cn.x.domain()):void 0},[de,pe,cn]),Zn=de||pe||Kn,Qn=nn&&yn?me?me(yn):(0,El.jsx)(Rl,{hover:yn}):null,Jn=Qn?(0,El.jsx)(jc,{x:yn.x,y:yn.y,containerWidth:Jt,containerHeight:en,margin:Qt,className:"stream-frame-tooltip",children:Qn}):null,eo=Yn.current,to=(0,El.jsx)(dc,{active:qn.current>=0,hoverPoint:yn,margin:Qt,size:qt,shape:eo?.shape,width:eo?.w,height:eo?.h}),no=Vc(a,M,"__semiotic_resolvedX","__semiotic_resolvedTime"),oo=Vc(c,w,"__semiotic_resolvedY","__semiotic_resolvedValue"),ro=no.key,ao=oo.key,co=function(e,t,n){return o=>{if(!o||!n||!e.fn&&!t.fn)return o;let r=!1;const i=o.map(n=>{const o=e.fn&&e.key&&!(e.key in n),i=t.fn&&t.key&&!(t.key in n);if(!o&&!i)return n;r=!0;const s={...n};return o&&(s[e.key]=e.fn(n)),i&&(s[t.key]=t.fn(n)),s});return r?i:o}}(no,oo,_e&&_e.length>0||!1);if(Aa||!Ft&&Bt){const e=Cn.current;e&&r&&(e.ingest({inserts:tn,bounded:!0}),e.computeScene({width:Jt,height:en}));const t=e?.scene??[],n=e?.scales??null,o=Yc(Ye,qt,Qt,n),i=Yc(We,qt,Qt,n),s=Zn||(()=>{if(e?.xIsDate&&n)return Kc(n.x.domain())})();return(0,El.jsxs)("div",{ref:Wt,className:"stream-xy-frame"+(z?" "+z:""),role:"img","aria-label":wt||("string"==typeof Ve?Ve:"XY chart"),style:{position:"relative",width:I?"100%":qt[0],height:T?"100%":qt[1]},children:[(0,El.jsx)(ac,{summary:kt}),(0,El.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:qt[0],height:qt[1],style:{position:"absolute",left:0,top:0},children:[(0,El.jsx)("g",{transform:`translate(${Qt.left},${Qt.top})`,children:i}),(0,El.jsxs)("g",{transform:`translate(${Qt.left},${Qt.top})`,children:[E&&(0,El.jsx)("rect",{x:0,y:0,width:Jt,height:en,fill:E}),He&&n&&He.map((e,o)=>(0,El.jsx)(bt.Fragment,{children:e(t,n,{width:Jt,height:en})},"svgpre-"+o)),t.map((e,t)=>_l({node:e,index:t,renderMode:O,fallback:()=>Sa(e,t,$t)})).filter(Boolean)]})]}),(0,El.jsx)(Xs,{width:Jt,height:en,totalWidth:qt[0],totalHeight:qt[1],margin:Qt,scales:n,showAxes:se,axes:ae,xLabel:ce,yLabel:le,yLabelRight:ue,xFormat:s,yFormat:he||ye,axisExtent:fe,showGrid:Re,title:Ve,legend:Le,legendHoverBehavior:Ie,legendClickBehavior:ze,legendHighlightedCategory:De,legendIsolatedCategories:Ee,legendPosition:Oe,legendLayout:Fe,foregroundGraphics:go(o,mt(Cn.current?.customLayoutOverlays,Rt??null)),marginalGraphics:ft,xValues:[],yValues:[],annotations:_e,onAnnotationActivate:Pe,onObservation:we??ve,chartId:ke,chartType:"StreamXYFrame",autoPlaceAnnotations:je,svgAnnotationRules:Ce,annotationFrame:0,xAccessor:ro,yAccessor:ao,annotationData:co(Cn.current?.getData()),pointNodes:Zc(Cn.current?.scene),curve:"string"==typeof g?g:void 0,linkedCrosshairName:St,linkedCrosshairSourceId:At})]})}return(0,El.jsxs)("div",{ref:Wt,className:"stream-xy-frame"+(z?" "+z:""),role:"group","aria-label":wt||("string"==typeof Ve?Ve:"XY chart"),tabIndex:0,style:{position:"relative",width:I?"100%":qt[0],height:T?"100%":qt[1],overflow:"visible",touchAction:Bl(Ue)},onKeyDown:Gn,children:["production"!==process.env.NODE_ENV&&Cn.current&&(0,El.jsx)(po,{store:Cn.current,diagnostics:vn.current}),xt&&(0,El.jsx)(cc,{tableId:Vt}),xt&&(0,El.jsx)(sc,{scene:Cn.current?.scene??[],chartType:n+" chart",tableId:Vt,chartTitle:"string"==typeof Ve?Ve:void 0}),(0,El.jsx)(ac,{summary:kt}),(0,El.jsx)(Wa,{hoverPoint:yn}),(0,El.jsxs)("div",{role:"img","aria-label":wt||("string"==typeof Ve?Ve:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:nn?Vn:void 0,onMouseMove:nn?Xn:void 0,onPointerLeave:nn?Bn:void 0,onMouseLeave:nn?Bn:void 0,onPointerDown:nn||Tt?Un:void 0,onClick:Tt?Wn:void 0,children:[(0,El.jsx)(qc,{size:qt,margin:Qt,children:dn}),(0,El.jsx)(Gs,{width:Jt,height:en,totalWidth:qt[0],totalHeight:qt[1],margin:Qt,scales:cn,showAxes:se,axes:ae,showGrid:Re,xFormat:Zn,yFormat:he||ye,axisExtent:fe}),(0,El.jsx)("canvas",{ref:zn,"aria-label":Va(Cn.current?.scene??[],n+" chart"),style:{position:"absolute",left:0,top:0}}),(0,El.jsx)("canvas",{ref:Dn,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),(0,El.jsx)(Xs,{width:Jt,height:en,totalWidth:qt[0],totalHeight:qt[1],margin:Qt,scales:cn,showAxes:se,axes:ae,xLabel:ce,yLabel:le,yLabelRight:ue,xFormat:Zn,yFormat:he||ye,axisExtent:fe,showGrid:Re,title:Ve,legend:Le,legendHoverBehavior:Ie,legendClickBehavior:ze,legendHighlightedCategory:De,legendIsolatedCategories:Ee,legendPosition:Oe,legendLayout:Fe,foregroundGraphics:go(un,mt(Cn.current?.customLayoutOverlays,Rt??null)),marginalGraphics:ft,xValues:Sn,yValues:Mn,annotations:_e,onAnnotationActivate:Pe,onObservation:we??ve,chartId:ke,chartType:"StreamXYFrame",autoPlaceAnnotations:je,svgAnnotationRules:Ce,annotationFrame:on,xAccessor:ro,yAccessor:ao,annotationData:co(Cn.current?.getData()),pointNodes:Zc(Cn.current?.scene),curve:"string"==typeof g?g:void 0,underlayRendered:!0,canvasObscuresUnderlay:!!$a({background:E,hasBackgroundGraphics:!!We,themeBackground:Yt?.colors.background}),linkedCrosshairName:St,linkedCrosshairSourceId:At}),(Ue||Ke)&&(0,El.jsx)(Mt,{width:Jt,height:en,totalWidth:qt[0],totalHeight:qt[1],margin:Qt,dimension:Ue?.dimension??"xy",scales:cn,onBrush:Ke??(()=>{}),binSize:v,snap:Ue?.snap,binBoundaries:Ue?.binBoundaries??("bar"===n?Cn.current?.getBinBoundaries():void 0),snapDuring:Ue?.snapDuring,streaming:"streaming"===o}),tt?.showBadge&&(0,El.jsx)(mr,{isStale:wn,position:tt.badgePosition}),to,Jn]})]})}));Nl.displayName="StreamXYFrame";var Wl=Nl,ql=y(require("react")),Yl=require("react/jsx-runtime");function Gl({componentName:e,message:t,diagnosticHint:n,width:o,height:r}){return(0,Yl.jsx)("div",{role:"alert",style:{width:o,height:Math.max(r,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"},children:(0,Yl.jsxs)("div",{style:{textAlign:"center",maxWidth:400},children:[(0,Yl.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),(0,Yl.jsx)("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:t}),n&&(0,Yl.jsx)("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:n})]})})}var Hl=require("react/jsx-runtime"),Vl=class extends ql.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){this.props.onError?.(e,t)}render(){if(this.state.error){const{fallback:e}=this.props,t=this.state.error;return"function"==typeof e?e(t):void 0!==e?e:(0,Hl.jsx)(Gl,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}},Xl=require("react/jsx-runtime");function Ul({componentName:e,width:t,height:n,children:o}){return(0,Xl.jsx)(Vl,{fallback:o=>(0,Xl.jsx)(Gl,{componentName:e,message:o.message,width:t,height:n}),children:o})}"undefined"!=typeof process&&process;var Kl={display:"flex",alignItems:"center",justifyContent:"center",color:"var(--semiotic-text-secondary, #666)",fontSize:13,fontFamily:"inherit",border:"1px dashed var(--semiotic-border, #ddd)",borderRadius:4,boxSizing:"border-box"},Zl={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2},Ql=require("react"),Jl=require("react"),eu=require("react"),tu=(require("react/jsx-runtime"),(0,eu.createContext)(null));function nu(){return(0,eu.useContext)(tu)}var ou=require("react");function ru(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,r]=o.range;t.push(t=>{const o=t[n];return o>=e&&r>=o})}return e=>t.every(t=>t(e))}function iu(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function su(e,t){if(e.type!==t.type)return!1;if("interval"===e.type&&"interval"===t.type)return e.range[0]===t.range[0]&&e.range[1]===t.range[1];if("point"===e.type&&"point"===t.type){if(e.values.size!==t.values.size)return!1;for(const n of e.values)if(!t.values.has(n))return!1;return!0}return!1}var[au,cu]=Ne(e=>({selections:new Map,setClause(t,n){e(e=>{const o=e.selections.get(t),r=o?.clauses.get(n.clientId);if(r&&function(e,t){if(e.clientId!==t.clientId||e.type!==t.type)return!1;const n=Object.entries(e.fields);if(n.length!==function(e){let t=0;for(const n in e)t++;return t}(t.fields))return!1;for(const[e,o]of n){const n=t.fields[e];if(!n||!su(o,n))return!1}return!0}(r,n))return{};const i=new Map(e.selections),s=iu(i,t),a=new Map(s.clauses);return a.set(n.clientId,n),i.set(t,{...s,clauses:a}),{selections:i}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o||!o.clauses.has(n))return{};const r=new Map(e.selections),i=new Map(o.clauses);return i.delete(n),r.set(t,{...o,clauses:i}),{selections:r}})},setResolution(t,n){e(e=>{const o=e.selections.get(t);if(o?.resolution===n)return{};const r=new Map(e.selections),i=iu(r,t);return r.set(t,{...i,resolution:n}),{selections:r}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const o=new Map(e.selections);return o.set(t,{...n,clauses:new Map}),{selections:o}})}}));function lu(e){const t=(0,ou.useId)(),n=e.clientId||t,{name:o}=e,r=cu(e=>e.selections.get(o)),i=cu(e=>e.setClause),s=cu(e=>e.clearClause),a=(0,ou.useMemo)(()=>!!r&&r.clauses.size>0,[r]);return{predicate:(0,ou.useMemo)(()=>r&&0!==r.clauses.size?function(e,t){const n=[];for(const[o,r]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(ru(r));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(r,n):()=>!0,[r,n]),isActive:a,selectPoints:(0,ou.useCallback)(e=>{const t={};let r=!1;for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)},r=!0;r&&i(o,{clientId:n,type:"point",fields:t})},[n,o,i]),selectInterval:(0,ou.useCallback)(e=>{const t={};let r=!1;for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o},r=!0;r&&i(o,{clientId:n,type:"interval",fields:t})},[n,o,i]),clear:(0,ou.useCallback)(()=>{s(o,n)},[s,o,n]),clientId:n}}var uu=y(require("react"));function du(){return Ze(e=>e.theme)}function hu(e,t,n){const o=e.xValue??t?.[n];if(null==o)return null;const r=Number(o);return Number.isFinite(r)?r:null}function fu(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?{...t,xValue:e.xValue}:t||{}}function pu(e){if(!e)return!1;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}require("react/jsx-runtime"),uu.createContext(void 0);var yu=require("react"),gu=require("react"),mu=(require("react/jsx-runtime"),(0,gu.createContext)(!1));(0,gu.createContext)(!1);var xu=(0,gu.createContext)(null),bu="undefined"==typeof window?gu.useEffect:gu.useLayoutEffect;function vu({data:e,colorBy:t,colorScale:n,showLegend:o,legendPosition:r="right",userMargin:i,defaults:s={top:50,bottom:60,left:70,right:40},categories:a,additionalLegend:c,chartWidth:l,legendLayout:u,hasTitle:d=!1,axisChrome:h}){const f=(0,gu.useContext)(mu),p=null!==(0,gu.useContext)(xu),y=void 0!==o?o:!f&&!!t,g=!!t&&(y||p),m=(0,yu.useMemo)(()=>{if(!g)return[];if(void 0!==a)return a;const n=new Set;for(const o of e){const e="function"==typeof t?t(o):o[t];null!=e&&n.add(e+"")}return Array.from(n)},[a,t,e,g]);!function(e){const t=(0,gu.useContext)(xu),n=(0,gu.useId)(),o=function(e){const t=new Set,n=[];for(const o of e)t.has(o)||(t.add(o),n.push(o));return n}(e),r=(0,gu.useRef)([]);(function(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0})(r.current,o)||(r.current=o);const i=r.current;bu(()=>{if(t)return()=>t.unregisterCategories(n)},[t,n]),bu(()=>{t&&t.registerCategories(n,i)},[t,n,i])}(p&&t?m:[]);const x=(0,yu.useMemo)(()=>{if(!y||!t)return;const o=function({data:e,colorBy:t,colorScale:n,getColor:o,strokeColor:r,strokeWidth:i,categories:s}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==r&&(n.stroke=r),void 0!==i&&(n.strokeWidth=i),n},type:"fill",items:(s&&s.length>0?s:Array.from(new Set(e.map(e=>"function"==typeof t?t(e):e[t])))).map((r,i)=>{const s=e.find("function"==typeof t?e=>t(e)===r:e=>e[t]===r),a=s?o(s,t,n):n?n(r):fe[i%fe.length];return{label:r+"",color:a}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:ge,categories:m});return 0!==o.legendGroups.reduce((e,t)=>e+t.items.length,0)?o:void 0},[y,t,e,n,m]),b=(0,yu.useMemo)(()=>vr(x,c),[x,c]),{hasAxis:v,hasAxisLabel:w,rotatedTicks:k}=h??{},S=(0,yu.useMemo)(()=>{const e="number"==typeof i?{top:i,bottom:i,left:i,right:i}:i??{},t=t=>{const n=e[t];return"number"==typeof n?n:s[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},o=t=>"number"==typeof e[t];if(b){const e=Or(b,u),t=void 0===v?{hasAxis:!0,hasAxisLabel:!0}:{hasAxis:v,hasAxisLabel:w,rotatedTicks:k},i=Er(b,Math.max(1,(l??600)-n.left-n.right),u)+Lr(b)+Dr("bottom"===r?t:void 0,u)+("top"===r&&d?24:0);"right"===r&&!o("right")&&e>n.right?n.right=e:"left"===r&&!o("left")&&e>n.left?n.left=e:"top"!==r||o("top")?"bottom"!==r||o("bottom")||(n.bottom=Math.max(n.bottom,80,i)):n.top=Math.max(n.top,50,i)}return n},[s,i,b,r,l,u,d,v,w,k]);return{legend:b,margin:S,legendPosition:r}}var wu=[];function ku(){const e=du(),t=e?.colors?.categorical;return t&&t.length>0?t:void 0}function Su(e,t,n,o,r){if(e)return e;if(n&&"object"==typeof n&&!Array.isArray(n)){const e=me(n,o);if(e)return e}let i;if(Array.isArray(n))i=n;else if(t&&t.length>0)i=t;else if("string"==typeof n){const e=le[n];Array.isArray(e)&&(i=e)}return i&&0!==i.length?null!=o?(r.has(o)||r.set(o,r.size),i[r.get(o)%i.length]):i[0]:de}function Au({selection:e,linkedHover:t,fallbackFields:n=wu,unwrapData:o=!1,onObservation:r,chartType:i,chartId:s,onClick:a,hoverHighlight:c,colorByField:l,mobileInteraction:u}){const d=(0,Jl.useId)(),h=(0,Jl.useMemo)(()=>function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField,seriesField:e.seriesField}:null}(t,n),[t,n]),f=(0,Jl.useMemo)(()=>"series"===h?.mode?[h.seriesField||l||n[0]].filter(e=>!!e):h?.fields||n,[h,l,n]),p=lu({name:e?.name||"__unused__",fields:f}),y=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:o,isActive:r,selectPoints:i,clear:s}=lu({name:t,fields:n});return{onHover:(0,ou.useCallback)(e=>{if(!e)return void s();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1})(t)&&i(t)},[n,i,s]),predicate:o,isActive:r}}({name:h?.name||"hover",fields:f}),g=Oi(e=>e.pushObservation),m=(0,Jl.useCallback)(e=>{r?.(e),g?.(e)},[r,g]),x=e?{isActive:p.isActive,predicate:p.predicate}:null,[b,v]=(0,Jl.useState)(null),w=(0,Jl.useRef)(!1),k=l||n[0],S=(0,Jl.useMemo)(()=>{if(!c||null==b||!k)return null;const e=b,t=k;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[c,b,k]),A=(0,Jl.useCallback)((e,n)=>{const o=!e&&w.current&&!!u?.enabled&&u.tapToLockTooltip;if(t)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===h?.mode&&h.xField){const n=hu(e,t,h.xField);null!=n&&function(e,t,n){const o=ws.positions.get(e);o?.locked||o&&o.xValue===t&&o.sourceId===n||(ws={positions:new Map(ws.positions).set(e,{xValue:t,sourceId:n})},Ss())}(h.name||"hover",n,d)}"x-position"!==h?.mode&&y.onHover(t)}else"x-position"!==h?.mode||o||As(h.name||"hover",d),"x-position"===h?.mode||o||y.onHover(null);if(c&&k)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=t?.[k];v(null!=n?n+"":null)}else o||v(null);(r||g)&&Ll({onObservation:m,datum:e?fu(e):null,x:e?.x,y:e?.y,chartType:i||"unknown",chartId:s,context:n})},[t,y,h,d,r,i,s,g,m,c,k,u]),M=(0,Jl.useCallback)((n=!0)=>{w.current=!1,t&&"x-position"!==h?.mode&&y.onHover(null),e&&u?.tapToSelect&&p.clear(),n&&c&&v(null),"x-position"===h?.mode&&(Ms(h.name||"hover",d),As(h.name||"hover",d))},[t,h,y,e,u,p,c,d]),_=(0,Jl.useCallback)((n,o)=>{const l=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),x=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===h?.mode&&h.xField&&n){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]);const t=hu(n,e,h.xField);null!=t&&function(e,t,n){const o=ws.positions.get(e);if(o?.locked){const t=new Map(ws.positions);return t.delete(e),ws={positions:t},Ss(),!1}ws={positions:new Map(ws.positions).set(e,{xValue:t,sourceId:n,locked:!0})},Ss()}(h.name||"hover",t,d)}if(l)if(n){w.current=!0;const o=fu(n);if(t&&"x-position"!==h?.mode&&y.onHover(o),e&&u?.tapToSelect&&f.length>0){const e={};for(const t of f){const n=o[t];void 0!==n&&(e[t]=[n])}pu(e)&&p.selectPoints(e)}if(c&&k){const e=o?.[k];v(null!=e?e+"":null)}}else x&&M();if(n||x){if(n&&a){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]),a(e,{x:n.x??0,y:n.y??0})}(r||g)&&Il({onObservation:m,datum:n?fu(n):null,x:n?.x,y:n?.y,chartType:i||"unknown",chartId:s,context:o})}},[a,r,g,m,i,s,h,d,u,t,y,e,p,f,c,k,M]);return(0,Jl.useEffect)(()=>{if(!u?.enabled||"undefined"==typeof document)return;const e=e=>{"Escape"===e.key&&w.current&&M()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u?.enabled,M]),(0,Jl.useEffect)(()=>()=>{w.current&&M(!1)},[M]),(0,Jl.useEffect)(()=>{if("x-position"!==h?.mode)return;const e=h.name||"hover";return()=>{Ms(e,d),As(e,d)}},[h?.mode,h?.name,d]),{activeSelectionHook:x,hoverSelectionHook:S,customHoverBehavior:A,customClickBehavior:_,crosshairSourceId:d}}var Mu=require("react"),_u=require("react");var Pu=require("react");function ju(e){const t=(0,Ql.useRef)(null);return function(e,t){const{variant:n,frameRef:o,overrides:r}=t,i=(0,Pu.useRef)(r);i.current=r,(0,Pu.useImperativeHandle)(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,n)=>e.current?.update(t,n)??[],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 n=Array.isArray(t)?t:[t],o=e.current?.getTopology()?.nodes??[],r=[];for(const t of n){const n=o.find(e=>e.id===t);n&&r.push({...n.data??{},id:t}),e.current?.removeNode(t)}return r},update:(t,n)=>(Array.isArray(t)?t:[t]).flatMap(t=>{const o=e.current?.updateNode(t,n);return o?[{...o,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,n)=>{const o=e.current?.removePoint(t)??[];for(const t of o)e.current?.push(n(t));return o},clear:()=>e.current?.clear(),getData:()=>e.current?.getData()??[],getCustomLayout:()=>e.current?.getCustomLayout?.()??null,getLayoutFailure:()=>e.current?.getLayoutFailure?.()??null}}const n=t;return{push:e=>n.current?.pushLine(e),pushMany:e=>n.current?.pushManyLines(e),remove:e=>n.current?.removeLine(e)??[],update:(e,t)=>{const o=n.current?.removeLine(e)??[];for(const e of o)n.current?.pushLine(t(e));return o},clear:()=>n.current?.clear(),getData:()=>n.current?.getLines()??[],getCustomLayout:()=>n.current?.getCustomLayout?.()??null,getLayoutFailure:()=>n.current?.getLayoutFailure?.()??null}}(n,o);return new Proxy(e,{get(e,t,n){if("string"==typeof t){const e=i.current?.[t];if("function"==typeof e)return e}return Reflect.get(e,t,n)},has:(e,t)=>!("string"!=typeof t||!i.current||!(t in i.current))||Reflect.has(e,t)})},[])}(e.imperativeRef,{variant:e.imperativeVariant,frameRef:t}),{frameRef:t,resolved:R(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},void 0),normalizedMargin:(0,Ql.useMemo)(()=>I(e.margin),[e.margin])}}function Cu(e){const{title:t,description:n,summary:o,accessibleTable:r,className:i,animate:s,axisExtent:a,autoPlaceAnnotations:c}=e,l={};return t&&(l.title=t),n&&(l.description=n),o&&(l.summary=o),void 0!==r&&(l.accessibleTable=r),i&&(l.className=i),null!=s&&(l.animate=s),void 0!==a&&(l.axisExtent=a),void 0!==c&&(l.autoPlaceAnnotations=c),l}function Ru(e){const{linkedHover:t,selection:n,onObservation:o,onClick:r,hoverRadius:i,hoverHighlight:s,forceHoverBehavior:a,forceClickBehavior:c,mobileInteraction:l,customHoverBehavior:u,customClickBehavior:d,linkedHoverInClickPredicate:h=!0}=e,f={};o&&(f.annotationObservationCallback=o);const p=l?.enabled?Math.max(i??30,Math.ceil((l.targetSize||44)/2),24):i;return(a||t||o||r||s)&&(f.customHoverBehavior=u),d&&(c||(h?o||r||t:o||r)||l?.enabled&&(l.tapToSelect||l.tapToLockTooltip)&&(t||s||n))&&(f.customClickBehavior=d),null!=p&&(f.hoverRadius=p),f}var Lu=require("react/jsx-runtime"),Iu=(0,xt.forwardRef)(function(e,t){const{data:n,layout:o,layoutConfig:r,onLayoutError:i,xExtent:s,yExtent:a,showAxes:c=!1,margin:l,className:u,annotations:d,onObservation:h,onClick:f,selection:p,linkedHover:y,hoverHighlight:g,chartId:m,loading:x,loadingContent:b,emptyContent:v,colorBy:w,colorScheme:k,legend:S,legendInteraction:A,legendPosition:M,frameProps:_={}}=e,{legend:P,...C}=_,R=(0,xt.useMemo)(()=>vr(P,S),[P,S]),{frameRef:L,resolved:I,safeData:T,setup:$,earlyReturn:z}=function(e){const t=ju(e),{resolved:n,normalizedMargin:o}=t,r=function(e){const{data:t,rawData:n,colorBy:o,colorScheme:r,legendInteraction:i,legendPosition:s,selection:a,linkedHover:c,fallbackFields:l,unwrapData:u=!1,onObservation:d,chartType:h,chartId:f,showLegend:p,legend:y,legendLayout:g,userMargin:m,marginDefaults:x,onClick:b,hoverHighlight:v,mobileInteraction:w,mobileSemantics:k,loading:S,loadingContent:A,emptyContent:M,width:_,height:P,hasTitle:C,axisChrome:R}=e,L=void 0===n,I=(0,Mu.useMemo)(()=>D(t),[t]),[T,$]=(0,Mu.useState)([]),z=(0,Mu.useCallback)(e=>{$(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),E="string"==typeof e.colorBy?e.colorBy:void 0,O=(0,Mu.useMemo)(()=>j(w,{width:_,mobileSemantics:k}),[w,_,k]),{activeSelectionHook:F,hoverSelectionHook:B,customHoverBehavior:N,customClickBehavior:W,crosshairSourceId:q}=Au({selection:a,linkedHover:c,fallbackFields:l,unwrapData:u,onObservation:d,chartType:h,chartId:f,onClick:b,hoverHighlight:v,colorByField:E,mobileInteraction:O}),Y=function(e,t){const n="object"==typeof e&&null!==e?e:void 0;if("x-position"===n?.mode)return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:t}}(c,q),G=function(e,t,n){const o=nu(),r=ku();return(0,Jl.useMemo)(()=>{if(!t)return;const i=o??void 0,s=n??(r&&r.length>0?r:void 0)??"category10";if(0!==e.length){if("function"==typeof t){const n=Array.from(new Set(e.map(e=>t(e)+"")));if(i&&pu(i)){const e=xe(n.map(e=>({_cat:e})),"_cat",s);return t=>i[t]||e(t)}return xe(n.map(e=>({_cat:e})),"_cat",s)}if(i&&pu(i)){const n=xe(e,t,s);return e=>i[e]||n(e)}return xe(e,t,s)}if(i&&pu(i)){const e=xe([{_:"a"}],"_",s);return t=>i[t]||e(t)}},[e,t,n,o,r])}(I,o,r),H=(0,Mu.useMemo)(()=>{if(!o)return[];const e=new Set;for(const t of I){const n="function"==typeof o?o(t):t[o];null!=n&&e.add(n+"")}return Array.from(e)},[I,o]),V=(0,Mu.useMemo)(()=>L&&T.length>0?T:H,[L,T,H]),X=function(e,t,n){const[o,r]=(0,yu.useState)(null),[i,s]=(0,yu.useState)(new Set),a=(0,yu.useMemo)(()=>new Set,[]),c=(0,yu.useCallback)(t=>{"highlight"===e&&r(t?t.label:null)},[e]),l=(0,yu.useCallback)(t=>{"isolate"===e&&s(e=>{const o=new Set(e);return o.has(t.label)?o.delete(t.label):o.add(t.label),o.size===n.length?new Set:o})},[e,n.length]),u=(0,yu.useMemo)(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=o?{isActive:!0,predicate:e=>(n?e[n]:"function"==typeof t?t(e):null)===o}:"isolate"===e&&i.size>0?{isActive:!0,predicate:e=>{const o=n?e[n]:"function"==typeof t?t(e):null;return i.has(o)}}:null},[e,t,o,i]);return{highlightedCategory:"highlight"===e?o:null,isolatedCategories:"isolate"===e?i:a,onLegendHover:c,onLegendClick:l,legendSelectionHook:u}}(i,o,V),U=(0,Mu.useMemo)(()=>B||(X.legendSelectionHook?X.legendSelectionHook:F),[B,X.legendSelectionHook,F]),K=function(e){const t=Ze(e=>e.theme.colors.selectionOpacity);return(0,_u.useMemo)(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}(a),Z=ku(),Q=nu(),J=(0,Mu.useMemo)(()=>{if(G)return G;if(!o||0===V.length)return;const e=Array.isArray(r)&&r.length>0||"string"==typeof r&&r.length>0?r:Z&&Z.length>0?Z:fe,t="__streamCat",n=xe(V.map(e=>({[t]:e})),t,e);return e=>Q?.[e]||n(e)||"#999"},[G,o,V,r,Z,Q]),{legend:ee,margin:te,legendPosition:ne}=vu({data:I,colorBy:o,colorScale:J,showLegend:p,legendPosition:s,userMargin:m,defaults:x,categories:V,additionalLegend:y,chartWidth:_,legendLayout:g,hasTitle:C,axisChrome:R}),oe=(0,Mu.useMemo)(()=>{const e={};return ee&&(e.legend=ee,e.legendPosition=ne,g&&(e.legendLayout=g)),i&&"none"!==i&&(e.legendHoverBehavior=X.onLegendHover,e.legendClickBehavior=X.onLegendClick,e.legendHighlightedCategory=X.highlightedCategory,e.legendIsolatedCategories=X.isolatedCategories),L&&o&&(e.legendCategoryAccessor=o,e.onCategoriesChange=z),e},[ee,ne,g,i,X.onLegendHover,X.onLegendClick,X.highlightedCategory,X.isolatedCategories,L,o,z]),re=Array.isArray(n)?D(n):n,ie=function(e,t,n,o){if(!e)return null;if(!1===o)return null;if(null!=o)return(0,Xl.jsx)("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:o});const r=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*r))),s=Math.max(6,Math.floor(n/(2.5*r))),a=Math.floor((n-(r*(i+s)-s))/2);return(0,Xl.jsx)("div",{style:{width:t,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:r},(e,n)=>(0,Xl.jsx)("div",{className:"semiotic-loading-bar",style:{...Zl,position:"absolute",top:a+n*(i+s),left:Math.floor(.1*t),width:30+(37*n+13)%50+"%",height:i,opacity:.5+n%2*.2}},n))})}(S,_,P,A),se=ie?null:function(e,t,n,o){return!1===o||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?(0,Xl.jsx)("div",{style:{...Kl,width:t,height:n},children:o||"No data available"}):null}(re,_,P,M);return{data:I,colorScale:G,allCategories:V,legendState:X,effectiveSelectionHook:U,activeSelectionHook:F,customHoverBehavior:N,customClickBehavior:W,mobileInteraction:O,legend:ee,margin:te,legendPosition:ne,earlyReturn:ie||se||null,legendBehaviorProps:oe,crosshairProps:Y,resolvedSelection:K}}({data:e.data??[],rawData:e.data,colorBy:e.colorBy,colorScheme:e.colorScheme,legendInteraction:e.legendInteraction,legendPosition:e.legendPosition,selection:e.selection,linkedHover:e.linkedHover,hoverHighlight:e.hoverHighlight,fallbackFields:"string"==typeof e.colorBy?[e.colorBy]:[],unwrapData:e.unwrapData,onObservation:e.onObservation,onClick:e.onClick,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,chartType:e.chartTypeLabel,chartId:e.chartId,showLegend:n.showLegend,legend:e.legend,userMargin:o,marginDefaults:n.marginDefaults,loading:e.loading,loadingContent:e.loadingContent,emptyContent:e.emptyContent,width:n.width,height:n.height});return{...t,safeData:r.data,setup:r,earlyReturn:r.earlyReturn}}({imperativeRef:t,imperativeVariant:"xy",chartTypeLabel:"XYCustomChart",unwrapData:!1,data:n,colorBy:w,colorScheme:k,legend:R,legendInteraction:A,legendPosition:M,selection:p,linkedHover:y,hoverHighlight:g,onObservation:h,onClick:f,chartId:m,loading:x,loadingContent:b,emptyContent:v,margin:l,width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,mode:e.mode,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules,xLabel:e.xLabel,yLabel:e.yLabel}),E=$.effectiveSelectionHook,O=(0,xt.useMemo)(()=>E?.isActive?{isActive:!0,predicate:E.predicate}:null,[E?.isActive,E?.predicate]);if(z)return z;const{width:F,height:B,enableHover:N,showGrid:W,title:q,description:Y,summary:G,accessibleTable:H,xLabel:V,yLabel:X}=I,U={chartType:"custom",...null!=n&&{data:T},customLayout:o,layoutConfig:r,onLayoutError:i,...O&&{layoutSelection:O},xExtent:s,yExtent:a,colorAccessor:w,colorScheme:k,size:[F,B],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:$.margin,showAxes:c,xLabel:V,yLabel:X,enableHover:N,showGrid:W,...$.legendBehaviorProps,...Cu({title:q,description:Y,summary:G,accessibleTable:H,className:u,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),...null!=e.tooltip&&{tooltipContent:e.tooltip},...Ru({linkedHover:y,selection:p,onObservation:h,onClick:f,hoverRadius:e.hoverRadius,hoverHighlight:g,mobileInteraction:$.mobileInteraction,customHoverBehavior:$.customHoverBehavior,customClickBehavior:$.customClickBehavior}),...d&&d.length>0&&{annotations:d},...$.crosshairProps,...C};return(0,Lu.jsx)(Ul,{componentName:"XYCustomChart",width:F,height:B,children:(0,Lu.jsx)(Wl,{ref:L,...U})})});function Tu(e,t,n,o,r){const i=1-r;return i*i*i*e+3*i*i*r*t+3*i*r*r*n+r*r*r*o}function $u(e,t,n,o,r){const i=1-r;return 3*i*i*(t-e)+6*i*r*(n-t)+3*r*r*(o-n)}function zu(e,t,n,o,r){const i=[],s=(e.x+t.x)/2;for(let a=0;r>=a;a++){const c=a/r;let l,u,d,h;"linear"===o?(l=e.x+(t.x-e.x)*c,u=e.y+(t.y-e.y)*c,d=t.x-e.x,h=t.y-e.y):(l=Tu(e.x,s,s,t.x,c),u=Tu(e.y,e.y,t.y,t.y,c),d=$u(e.x,s,s,t.x,c),h=$u(e.y,e.y,t.y,t.y,c)),i.push({x:l,y:u,dx:d,dy:h,radius:e.radius+(t.radius-e.radius)*c,datumIndex:.5>c?n:n+1})}return i}function Du(e,t={}){const n=[],o=[],r=[];if(2>e.length)return{topPath:n,bottomPath:o,datumIndices:r};const i=t.curve??"smooth",s=Math.max(2,Math.floor(t.samplesPerSegment??12));for(let t=0;e.length-1>t;t++){const a=zu(e[t],e[t+1],t,i,s);for(let e=0===t?0:1;a.length>e;e++){const t=a[e],i=Math.hypot(t.dx,t.dy)||1,s=-t.dy/i,c=t.dx/i,l=Math.max(0,t.radius);n.push([t.x+s*l,t.y+c*l]),o.push([t.x-s*l,t.y-c*l]),r.push(t.datumIndex)}}return{topPath:n,bottomPath:o,datumIndices:r}}Iu.displayName="XYCustomChart";var Eu=require("react/jsx-runtime");function Ou(e,t,n){return"function"==typeof e?e(t,n):t[e]}function Fu(e){return e instanceof Date?"date:"+e.getTime():`${typeof e}:${e+""}`}function Bu(e,t){if(!e?.length)return;const n=new Map(t.map((e,t)=>[Fu(e),t]));return e.map(e=>{const t={...e},o=o=>{if(!(o in e))return;const r=n.get(Fu(e[o]));void 0!==r&&(t[o]=r)};return o("x"),o("x0"),o("x1"),"string"!=typeof e.type||"x-threshold"!==e.type&&"x"!==e.type||o("value"),t})}function Nu(e){const{seriesOrder:t,overallOrder:n,highlightTop:o,color:r,colorScheme:i,neutralColor:s,themeCategorical:a,themeNeutral:c}=e;if(null==o&&null==r)return i;const l=new Set(n.slice(0,null==o?n.length:Math.max(0,Math.floor(o)))),u=new Map,d={};for(const e of t)d[e]=r??(l.has(e)?Su(void 0,a,i,e,u):s??c??"#b8bec8");return d}function Wu(e,t={}){const n=t.xAccessor??"x",o=t.yAccessor??"y",r=t.lineBy??"series",i=t.rankDirection??"descending",s=[],a=new Map,c=new Map,l=[],u=new Map;let d=1/0,h=-1/0;e.forEach((e,t)=>{const i=Ou(n,e,t),f=Fu(i);let p=a.get(f);null==p&&(p=s.length,a.set(f,p),s.push(i),c.set(p,[]));const y=Ou(r,e,t)+"";u.has(y)||(u.set(y,l.length),l.push(y));const g=Number(Ou(o,e,t));Number.isFinite(g)&&(d=Math.min(d,g),h=Math.max(h,g),c.get(p)?.push({datum:e,inputIndex:t,series:y,value:g}))});const f=[],p=new Map,y=new Map;for(let e=0;s.length>e;e++){const t=c.get(e)??[];t.sort((e,t)=>("descending"===i?t.value-e.value:e.value-t.value)||(u.get(e.series)??0)-(u.get(t.series)??0)),t.forEach((t,n)=>{const o=n+1;f.push({datum:t.datum,xIndex:e,xValue:s[e],series:t.series,value:t.value,rank:o}),p.set(t.series,(p.get(t.series)??0)+o),y.set(t.series,(y.get(t.series)??0)+1)})}const g=l.length+1,m=[...l].sort((e,t)=>{const n=y.get(e)??0,o=y.get(t)??0;return((p.get(e)??0)+(s.length-n)*g)/Math.max(1,s.length)-((p.get(t)??0)+(s.length-o)*g)/Math.max(1,s.length)||(u.get(e)??0)-(u.get(t)??0)}),x=new Set(m.slice(0,null==t.highlightTop?m.length:Math.max(0,Math.floor(t.highlightTop))));return{data:f.map(e=>{const t=x.has(e.series);return{...e.datum,x:e.xIndex,y:e.rank,__bumpRaw:e.datum,__bumpSeries:e.series,__bumpColorGroup:t?e.series:"Other",__bumpValue:e.value,__bumpRank:e.rank,__bumpXValue:e.xValue,__bumpHighlighted:t}}),xValues:s,seriesOrder:l,overallOrder:m,valueExtent:d===1/0?[0,0]:[d,h]}}function qu({datum:e,x:t,y:n,side:o,color:r,highlighted:i,labelStyle:s}){const a=ht.useContext(yt)??pt,c=a.isActive&&!a.predicate(e),l="function"==typeof s?s(e.__bumpRaw):s;return(0,Eu.jsx)("text",{className:"semiotic-bump-label",x:t+("end"===o?8:-8),y:n,dy:"0.35em",textAnchor:"end"===o?"start":"end",fill:r,fillOpacity:c?.16:1,fontWeight:i?650:450,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-axis-label-font-size, 11px)",...l},children:e.__bumpSeries})}function Yu(e,t,n){const[o,r]=t,[i,s]=n;return r===o?(i+s)/2:i+(s-i)*Math.max(0,Math.min(1,(e-o)/(r-o)))}function Gu(e){const t=e instanceof Date?e.getTime():Number(e);return Number.isFinite(t)?t:void 0}function Hu(e){return{value:e.__bumpValue,x:Gu(e.__bumpXValue),y:e.__bumpValue,category:e.__bumpSeries}}function Vu(e){const t=e.config,n=new Map;for(const t of e.data){const e=n.get(t.__bumpSeries)??[];e.push(t),n.set(t.__bumpSeries,e)}const o=t.seriesOrder.filter(e=>n.has(e)).sort((e,o)=>(n.get(e)?.[0]?.__bumpHighlighted?1:0)-(n.get(o)?.[0]?.__bumpHighlighted?1:0)||t.seriesOrder.indexOf(e)-t.seriesOrder.indexOf(o)),r=[],i=[];for(const s of o){const o=(n.get(s)??[]).sort((e,t)=>e.x-t.x);if(2>o.length)continue;const a=o[0].__bumpHighlighted,c=e.resolveColor(o[0].__bumpSeries,o[0]),l=t.color??(a?c:t.neutralColor??e.theme.semantic.textSecondary??e.theme.semantic.border??c),u=o.map(n=>({x:e.scales.x(n.x),y:e.scales.y(n.y),radius:t.ribbon?Yu(n.__bumpValue,t.valueExtent,t.ribbonSizeRange)/2:Math.max(.5,t.lineWidth/2)})),d=Du(u,{curve:t.curve,samplesPerSegment:t.samplesPerSegment}),h=d.datumIndices.map(e=>o[e]),f={fill:l,fillOpacity:1,opacity:a?t.ribbon?t.ribbonOpacity:t.lineOpacity:Math.min(t.ribbon?t.ribbonOpacity:t.lineOpacity,.58)};t.styleRules?.length&&Object.assign(f,Ce(o[0].__bumpRaw,t.styleRules,Hu(o[0]))),t.areaStyle&&Object.assign(f,t.areaStyle(o[0].__bumpRaw)??{}),void 0!==t.stroke&&(f.stroke=t.stroke),void 0!==t.strokeWidth&&(f.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(f.opacity=t.opacity),r.push({type:"area",topPath:d.topPath,bottomPath:d.bottomPath,style:f,datum:h,accessibleDatum:o.map(e=>e.__bumpRaw),accessibility:{label:s+" ranking trajectory",tableFields:o.map(e=>e.__bumpRaw)},group:s,interactive:!0}),t.showPoints&&o.forEach((e,n)=>{const o={fill:l,stroke:"none",opacity:a?1:.75};t.styleRules?.length&&Object.assign(o,Ce(e.__bumpRaw,t.styleRules,Hu(e))),t.pointStyle&&Object.assign(o,t.pointStyle(e.__bumpRaw)??{}),void 0!==t.stroke&&(o.stroke=t.stroke),void 0!==t.strokeWidth&&(o.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(o.opacity=t.opacity),r.push({type:"point",x:u[n].x,y:u[n].y,r:o.r??t.pointRadius,style:o,datum:e,accessibleDatum:e.__bumpRaw,accessibility:{label:`${s}, rank ${e.__bumpRank}, value ${e.__bumpValue}`},pointId:`${s}:${e.x}`})});const p=!0===t.showLabels?"end":t.showLabels,y=(e,n,o)=>{i.push((0,Eu.jsx)(qu,{datum:e,x:u[n].x,y:u[n].y,side:o,color:"string"==typeof f.fill?f.fill:l,highlighted:a,labelStyle:t.labelStyle},`${s}-${o}`))};"start"!==p&&"both"!==p||y(o[0],0,"start"),"end"!==p&&"both"!==p||y(o.at(-1),o.length-1,"end")}return{nodes:r,overlays:i.length?(0,Eu.jsx)("g",{className:"semiotic-bump-labels",children:i}):void 0,restyle:(e,t)=>{const n=function(e){const t=Array.isArray(e.datum)?e.datum[0]:e.datum;return t&&"object"==typeof t&&"__bumpSeries"in t?t:void 0}(e);if(t?.isActive&&n&&!t.predicate(n))return{opacity:.14}}}}function Xu(e,t,n,o,r){const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Je(o.theme).colors.categorical,a=n??o.colorScheme??s,c="string"==typeof t?t:"__ssrAreaColorBy",l="function"==typeof t?i.map(e=>({...e,__ssrAreaColorBy:t(e)})):i,u=t?xe(l,c,a):void 0,d=!1!==r.showLine,h="number"==typeof r.lineWidth?r.lineWidth:2,f="number"==typeof r.areaOpacity?r.areaOpacity:.7,p=Ae(r.yAccessor),y=r.styleRules;return(e,n)=>{const o=t&&u?ge(e,t,u):"string"==typeof r.color?r.color:de,i={fill:o,fillOpacity:f,stroke:d?o:"none",...d&&{strokeWidth:h}};return y?.length&&Object.assign(i,Ce(e,y,{value:p(e),category:n})),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 Uu(e,t,n,o,r){const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Je(o.theme).colors.categorical,a=n??o.colorScheme??s,c="string"==typeof t?t:"__ssrBubbleColorBy",l="function"==typeof t?i.map(e=>({...e,__ssrBubbleColorBy:t(e)})):i,u=t?xe(l,c,a):void 0,d=r.sizeBy,h=Array.isArray(r.sizeRange)?r.sizeRange:[5,40],f=d?i.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],p=f.length?ve(f):void 0;return e=>({fill:t&&u?ge(e,t,u):"string"==typeof r.color?r.color:de,fillOpacity:"number"==typeof r.bubbleOpacity?r.bubbleOpacity:.6,r:d?be(e,d,h,p):h[0],stroke:r.stroke??r.bubbleStrokeColor??"white",strokeWidth:r.strokeWidth??r.bubbleStrokeWidth??1,...void 0!==r.opacity&&{opacity:r.opacity}})}function Ku(e,t,n,o,r){const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Je(o.theme).colors.categorical,a=n??o.colorScheme??s,c="string"==typeof t?t:"__ssrScatterColorBy",l="function"==typeof t?i.map(e=>({...e,__ssrScatterColorBy:t(e)})):i,u=t?xe(l,c,a):void 0,d=r.sizeBy,h=Array.isArray(r.sizeRange)?r.sizeRange:[3,15],f=d?i.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],p=f.length?ve(f):void 0,y=Me(r.xAccessor,r.yAccessor),g=r.styleRules;return e=>{const n={fill:t&&u?ge(e,t,u):"string"==typeof r.color?r.color:de,fillOpacity:"number"==typeof r.pointOpacity?r.pointOpacity:.8,r:d?be(e,d,h,p):"number"==typeof r.pointRadius?r.pointRadius:5};return g?.length&&Object.assign(n,Ce(e,g,y(e))),void 0!==r.stroke&&(n.stroke=r.stroke),void 0!==r.strokeWidth&&(n.strokeWidth=r.strokeWidth),void 0!==r.opacity&&(n.opacity=r.opacity),n}}(0,dt.forwardRef)(function(e,t){const n=ku(),o=du(),{data:r,xAccessor:i,yAccessor:s,lineBy:a,rankDirection:c="descending",ribbon:l=!1,curve:u="smooth",ribbonSizeRange:d=[4,28],samplesPerSegment:h=12,lineWidth:f=3,highlightTop:p,neutralColor:y,styleRules:g,labelStyle:m,colorScheme:x,ribbonOpacity:b=.82,lineOpacity:v=.9,showPoints:w=!1,pointRadius:k=3,showLabels:S=!0,showAxes:A=!0,showGrid:M=!0,showLegend:_=!1,enableHover:P=!0,hoverHighlight:j=!0,tooltip:C,frameProps:R={},xFormat:L,yFormat:I,onClick:T}=e,$=(0,dt.useMemo)(()=>Wu(r,{xAccessor:i,yAccessor:s,lineBy:a,rankDirection:c,highlightTop:p}),[r,i,s,a,c,p]),{axes:z,areaStyle:D,pointStyle:E,...O}=R,F=(0,dt.useMemo)(()=>Nu({seriesOrder:$.seriesOrder,overallOrder:$.overallOrder,highlightTop:p,color:e.color,colorScheme:x,neutralColor:y,themeCategorical:n,themeNeutral:o.colors.textSecondary}),[$.seriesOrder,$.overallOrder,p,e.color,x,y,n,o.colors.textSecondary]),B=(0,dt.useMemo)(()=>({ribbon:l,curve:u,samplesPerSegment:h,ribbonSizeRange:d,valueExtent:$.valueExtent,seriesOrder:$.seriesOrder,lineWidth:f,ribbonOpacity:b,lineOpacity:v,neutralColor:y,color:e.color,stroke:e.stroke,strokeWidth:e.strokeWidth,opacity:e.opacity,styleRules:g,areaStyle:D,pointStyle:E,labelStyle:m,showPoints:w,pointRadius:k,showLabels:S}),[l,u,h,d,$.valueExtent,$.seriesOrder,f,b,v,y,e.color,e.stroke,e.strokeWidth,e.opacity,g,D,E,m,w,k,S]),N=(0,dt.useCallback)((e,t)=>{if(0===$.xValues.length)return"";const n=$.xValues[Math.max(0,Math.min($.xValues.length-1,Math.round(Number(e))))];return L?L(n,t):(n instanceof Date?n.toLocaleDateString():n)+""},[$.xValues,L]),W=(0,dt.useCallback)(e=>I?I(e):e.toLocaleString(),[I]),q=(0,dt.useMemo)(()=>"multi"===C?void 0:function(e){if(!0!==e){if("function"==typeof e){const t=e;return e=>{let n=pc(!0===e?.__semioticHoverData||e&&void 0!==e.data&&"number"==typeof e.x&&"number"==typeof e.y&&e&&("node"===e.type||"edge"===e.type||void 0!==e.nodeOrEdge||void 0!==e.allSeries||void 0!==e.stats||void 0!==e.__chartType)?e.data??{}:e);if(!n)return null;if(("node"===e?.nodeOrEdge&&"number"==typeof n?.x0&&"number"==typeof n?.x1||"edge"===e?.nodeOrEdge&&"number"==typeof n?.sankeyWidth)&&n.data&&"object"==typeof n.data&&(n=n.data),!n)return null;const o=t(n);return null==o?null:(0,kc.jsx)("div",{className:"semiotic-tooltip",style:Sc,children:o})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?_c(e):"multi"===e?("undefined"!=typeof process&&"production"!==process.env?.NODE_ENV&&console.warn('[semiotic] tooltip="multi" reached normalizeTooltip — prefer charts that set tooltipMode (LineChart, AreaChart, StackedAreaChart, DifferenceChart). Rendering MultiLineTooltip content as a fallback.'),function(e={}){const{fields:t=[],title:n,format:o,style:r={},className:i="",showLabels:s=!0,separator:a=": "}=e;return e=>{if(!e||"object"!=typeof e)return null;const c=[];if(n){const t=Ac(e,n);c.push({value:Mc(t,o)})}if(t&&Array.isArray(t)&&t.length>0)t.forEach(t=>{let n,r,i;"string"==typeof t?(n=t,r=t,i=o):(n=t.label,r=t.accessor||t.key||"",i=t.format||o);const a=Mc(Ac(e,r),i);c.push({label:s?n:void 0,value:a})});else{const t=wc(e,{skipPositional:!1});null!=t.title&&c.push({label:void 0,value:Mc(t.title,o),bold:!0}),t.entries.forEach(e=>{c.push({label:s?e.key:void 0,value:Mc(e.value,o)})})}const l={...Sc,...r};return Array.isArray(c)&&0!==c.length?(0,kc.jsx)("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+i).trim(),style:l,children:c.map((e,t)=>(0,kc.jsxs)("div",{style:{marginBottom:c.length-1>t?"4px":0,fontWeight:e.bold?"bold":void 0},children:[e.label&&(0,kc.jsxs)("strong",{children:[e.label,a]}),e.value]},t))}):null}}()):_c())}}(C),[C]),Y=(0,dt.useCallback)(e=>{const t=e?.data??e;return t?!1===C?null:q?q({...e,data:t.__bumpRaw,__semioticHoverData:!0}):(0,Eu.jsxs)("div",{className:"semiotic-tooltip",style:Sc,children:[(0,Eu.jsx)("div",{style:{fontWeight:700},children:t.__bumpSeries}),(0,Eu.jsxs)("div",{children:[N(t.x)," · Rank ",t.__bumpRank]}),(0,Eu.jsxs)("div",{children:["Value: ",W(t.__bumpValue)]})]}):null},[W,N,q,C]),G=(0,dt.useMemo)(()=>{if(T)return(e,t)=>{T(e.__bumpRaw??e,t)}},[T]),H=Math.max(1,$.seriesOrder.length),V=$.xValues.map((e,t)=>t),X=Array.from({length:H},(e,t)=>t+1),U=z??[{orient:"left",tickValues:X,tickFormat:e=>e+"",label:e.yLabel??"Rank",baseline:!1},{orient:"bottom",tickValues:V,tickFormat:N,label:e.xLabel,tickAnchor:"edges"}],K=(0,dt.useMemo)(()=>Bu(e.annotations,$.xValues),[e.annotations,$.xValues]);return(0,Eu.jsx)(Iu,{ref:t,data:$.data,layout:Vu,layoutConfig:B,xExtent:[0,Math.max(1,$.xValues.length-1)],yExtent:[H+.5,.5],showAxes:A,showGrid:M,showLegend:_,enableHover:P,hoverHighlight:j,colorBy:"__bumpSeries",colorScheme:F,tooltip:Y,onClick:G,hoverRadius:e.hoverRadius,width:e.width,height:e.height,responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,responsiveRules:e.responsiveRules,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,mode:e.mode,margin:e.margin??{top:20,right:S?110:24,bottom:48,left:48},className:e.className,title:e.title,description:e.description,summary:e.summary,accessibleTable:e.accessibleTable,selection:e.selection,linkedHover:e.linkedHover,legend:e.legend,legendInteraction:e.legendInteraction,legendPosition:e.legendPosition,onObservation:e.onObservation,chartId:e.chartId,loading:e.loading,loadingContent:e.loadingContent,emptyContent:e.emptyContent,animate:e.animate,autoPlaceAnnotations:e.autoPlaceAnnotations,annotations:K,xLabel:e.xLabel,yLabel:e.yLabel??"Rank",frameProps:{axes:U,axisExtent:"exact",...O}})}).displayName="BumpChart";var Zu={frameType:"xy",buildProps:(e,t,n,o,r)=>({chartType:"scatter",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange||[5,40],colorScheme:n,...o,pointStyle:o.pointStyle||Uu(e,t,n,o,r),showLegend:o.showLegend??!!t})},Qu={frameType:"xy",layout:{margin:e=>({top:20,right:!1===e.showLabels?24:110,bottom:48,left:48})},buildProps:(e,t,n,o,r)=>{const i=Wu(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],{xAccessor:r.xAccessor,yAccessor:r.yAccessor,lineBy:r.lineBy,rankDirection:r.rankDirection,highlightTop:"number"==typeof r.highlightTop?r.highlightTop:void 0}),s=Math.max(1,i.seriesOrder.length),a=Je(o.theme),c=Nu({seriesOrder:i.seriesOrder,overallOrder:i.overallOrder,highlightTop:"number"==typeof r.highlightTop?r.highlightTop:void 0,color:"string"==typeof r.color?r.color:void 0,colorScheme:n,neutralColor:"string"==typeof r.neutralColor?r.neutralColor:void 0,themeCategorical:a.colors.categorical,themeNeutral:a.colors.textSecondary}),l={ribbon:!0===r.ribbon,curve:"linear"===r.curve?"linear":"smooth",samplesPerSegment:"number"==typeof r.samplesPerSegment?r.samplesPerSegment:12,ribbonSizeRange:Array.isArray(r.ribbonSizeRange)?r.ribbonSizeRange:[4,28],valueExtent:i.valueExtent,seriesOrder:i.seriesOrder,lineWidth:"number"==typeof r.lineWidth?r.lineWidth:3,ribbonOpacity:"number"==typeof r.ribbonOpacity?r.ribbonOpacity:.82,lineOpacity:"number"==typeof r.lineOpacity?r.lineOpacity:.9,neutralColor:"string"==typeof r.neutralColor?r.neutralColor:void 0,color:"string"==typeof r.color?r.color:void 0,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,styleRules:r.styleRules,areaStyle:o.areaStyle,pointStyle:o.pointStyle,labelStyle:r.labelStyle,showPoints:!0===r.showPoints,pointRadius:"number"==typeof r.pointRadius?r.pointRadius:3,showLabels:r.showLabels??!0},u=o.xFormat,d=(e,t)=>{if(0===i.xValues.length)return"";const n=i.xValues[Math.max(0,Math.min(i.xValues.length-1,Math.round(Number(e))))];return u?u(n,t):(n instanceof Date?n.toLocaleDateString():n)+""},h=i.xValues.map((e,t)=>t),f=Array.from({length:s},(e,t)=>t+1),p=o.axes??[{orient:"left",tickValues:f,tickFormat:e=>e+"",label:o.yLabel??"Rank",baseline:!1},{orient:"bottom",tickValues:h,tickFormat:d,label:o.xLabel,tickAnchor:"edges"}];return{...o,chartType:"custom",data:i.data,xAccessor:"x",yAccessor:"y",xExtent:[0,Math.max(1,i.xValues.length-1)],yExtent:[s+.5,.5],customLayout:Vu,layoutConfig:l,colorAccessor:"__bumpSeries",colorScheme:c,xFormat:d,axes:p,axisExtent:"exact",showAxes:o.showAxes??!0,showLegend:o.showLegend??!1,annotations:Bu(o.annotations,i.xValues)}}};function Ju(e,t,n,o,r){if(!r.showPoints)return;const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Je(o.theme).colors.categorical,a=n??o.colorScheme??s,c="string"==typeof t?t:"__ssrPointColorBy",l="function"==typeof t?i.map(e=>({...e,__ssrPointColorBy:t(e)})):i,u=t?xe(l,c,a):void 0,d="number"==typeof r.pointRadius?r.pointRadius:3;return e=>{const n=t&&u?ge(e,t,u):"string"==typeof r.color?r.color:de;return{r:d,fill:n,stroke:"none"}}}var ed={frameType:"xy",buildProps:(e,t,n,o,r)=>{const i=t||r.lineBy,s=r.fillArea,a=Array.isArray(s)?"mixed":s?"area":"line",c=Je(o.theme).colors.categorical,l=function(e,t,n,o,r){const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Je(o.theme).colors.categorical,a=n??o.colorScheme??s,c="string"==typeof t?t:"__ssrLineColorBy",l="function"==typeof t?i.map(e=>({...e,__ssrLineColorBy:t(e)})):i,u=t?xe(l,c,a):void 0,d=Me(r.xAccessor,r.yAccessor),h=function(e){const{lineWidth:t=2,colorBy:n,colorScale:o,color:r,resolveStroke:i,fillArea:s,areaOpacity:a=.3,styleRules:c,ruleContext:l}=e;return(e,u)=>{const d={strokeWidth:t},h=!0===s||Array.isArray(s)&&null!=u&&s.includes(u);let f;return i?f=i(e,u):n?o&&(f=ge(e,n,o)):f=r||de,void 0!==f&&(d.stroke=f,h&&(d.fill=f,d.fillOpacity=a)),c?.length&&Object.assign(d,Ce(e,c,l?l(e,u):{value:void 0,category:u})),d}}({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:d});return Se(h,{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,i,n,o,r),u=ut({data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",lineBy:r.lineBy,colorBy:i,colorScheme:n,color:"string"==typeof r.color?r.color:void 0,forecast:r.forecast,anomaly:r.anomaly,gapStrategy:r.gapStrategy,directLabel:r.directLabel,annotations:o.annotations,themeCategorical:c,baseLineStyle:l}),d=o.pointStyle||Ju(u.data,u.colorAccessor,n,o,r);let h=o.margin;u.marginExtra&&h&&"object"==typeof h?h={...h,...null!=u.marginExtra.right&&{right:Math.max(Number(h.right)||0,u.marginExtra.right)},...null!=u.marginExtra.left&&{left:Math.max(Number(h.left)||0,u.marginExtra.left)}}:u.marginExtra&&null==h&&(h={top:20,right:u.marginExtra.right??20,bottom:30,left:u.marginExtra.left??40});const f=(!r.directLabel||void 0!==o.showLegend)&&(o.showLegend??!!u.colorAccessor);return{chartType:a,data:u.data,xAccessor:u.xAccessor,yAccessor:u.yAccessor,groupAccessor:u.groupAccessor,colorAccessor:u.colorAccessor,colorScheme:n,lineStyle:u.lineStyle||l,...Array.isArray(s)&&{areaGroups:s},...s&&null!=r.areaOpacity&&{areaOpacity:r.areaOpacity},...null!=r.band&&{band:r.band},...o,...void 0!==h&&{margin:h},annotations:u.annotations,...u.yExtent&&!o.yExtent&&{yExtent:u.yExtent},...d&&{pointStyle:d},showLegend:f}}},td={frameType:"xy",buildProps:(e,t,n,o,r)=>{const i=Array.isArray(e)?D(e):[],s=r.timeAccessor||"time",a=r.valueAccessor||"value",c=r.categoryAccessor,l=r.valueExtent||o.yExtent,u="down"===r.direction?function({data:e,valueAccessor:t,timeAccessor:n,binSize:o,valueExtent:r,extentPadding:i}){if(r)return[r[1],r[0]];if(!e||0===e.length)return;const s=new Map;for(const r of e){const e=tt(r,n,"time"),i=tt(r,t,"value");if(null==e||null==i)continue;const a=Math.floor(e/o)*o;s.set(a,(s.get(a)??0)+i)}let a=0;for(const e of s.values())a=Math.max(a,e);return[a>0?a+a*(i??.1):1,0]}({data:i,timeAccessor:s,valueAccessor:a,binSize:Number(r.binSize),valueExtent:l,extentPadding:r.extentPadding}):l,d={...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:i,...o,runtimeMode:"streaming",windowMode:"growing",windowSize:Math.max(1,i.length),arrowOfTime:r.arrowOfTime||"right",timeAccessor:s,valueAccessor:a,xExtent:r.timeExtent||o.xExtent,yExtent:u,extentPadding:r.extentPadding??o.extentPadding,binSize:r.binSize,categoryAccessor:c,barColors:r.colors||o.barColors,colorScheme:r.colors||o.colorScheme,barStyle:o.barStyle||d,showLegend:o.showLegend??!!c}}},nd={frameType:"xy",buildProps:(e,t,n,o,r)=>{const i=t||r.areaBy,s=function({data:e,safeData:t,areaBy:n,lineDataAccessor:o}){if(null==e)return[];const r=void 0!==t[0]?.[o];if(!r&&!n)return t;let i;if(r)i=t;else{const e=t.reduce((e,t)=>{const r="function"==typeof n?n(t):t[n],i=r+"";if(!e[i]){const t={[o]:[]};"string"==typeof n&&(t[n]=r),e[i]=t}return e[i][o].push(t),e},{});i=Object.values(e)}return i.flatMap(e=>{const t=Array.isArray(e[o])?e[o]:[];return"string"==typeof n?t.map(t=>({...t,[n]:t[n]??e[n]})):t})}({data:e,safeData:Array.isArray(e)?D(e):[],areaBy:r.areaBy,lineDataAccessor:r.lineDataAccessor||"coordinates"}),a=function(e){if(e)return Array.isArray(e)?{stops:e.map(({at:e,color:t,opacity:n})=>({offset:e/100,color:t,...null!=n&&{opacity:n}}))}:Array.isArray(e.stops)?e:void 0}(r.semanticGradient),c=a?.stops.length?{stops:a.stops.map(e=>({...e,offset:1-e.offset})).sort((e,t)=>e.offset-t.offset)}:Te(o.gradientFill),l=!1!==r.semanticLine&&a?.stops.length?a.stops.flatMap(({offset:e,color:t})=>t?[{offset:e,color:t}]:[]):void 0,u=o.pointStyle||Ju(s,i,n,o,r);return{chartType:"area",data:s,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",y0Accessor:r.y0Accessor,groupAccessor:r.areaBy||void 0,colorAccessor:i,colorScheme:n,...o,...void 0!==c&&{gradientFill:c},...l&&{semanticLineStops:l},lineStyle:o.lineStyle||Xu(s,i,n,o,r),...u&&{pointStyle:u}}}},od={frameType:"xy",buildProps:(e,t,n,o,r)=>{const i=r.xAccessor||"x",s=r.seriesAAccessor||"a",a=r.seriesBAccessor||"b",c=e=>De(ze(i,"x",e)),l=e=>De(ze(s,"a",e)),u=e=>De(ze(a,"b",e)),d=r.seriesAColor||"var(--semiotic-danger, #dc2626)",h=r.seriesBColor||"var(--semiotic-info, #2563eb)",f=r.areaOpacity??.6,p=r.lineWidth??1.5,y=!1!==r.showLines,g=!1!==o.showLegend,m=r.seriesALabel||"A",x=r.seriesBLabel||"B",b=o.legendPosition||"right",v=function(e,t,n,o){if(!e.length)return[];const r=e.filter(e=>Number.isFinite(t(e))).sort((e,n)=>t(e)-t(n)),i=[];let s=0,a=null,c=null,l=[];const u=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${s}-${e}`,h=e=>i.push(e),f=(e,t)=>{h({__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;r.length>e;e++){const i=r[e],p=t(i),y=n(i),g=o(i);if(!Number.isFinite(p)||!Number.isFinite(y)||!Number.isFinite(g))continue;const m=u(y,g);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 n=y-c.a-(g-c.b);if(0!==n){const o=Math.max(0,Math.min(1,(c.b-c.a)/n));e=c.x+o*(p-c.x),t=c.a+o*(y-c.a)}else e=c.x,t=c.a}h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t}),s++,a=m,h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t});for(let e=1;l.length>e;e++)f(l[e],a)}else for(const e of l)f(e,a);l=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:i}),c={x:p,a:y,b:g,w:m}}else{a=m;for(const e of l)f(e,a);l=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:i}),c={x:p,a:y,b:g,w:m}}else l.push({x:p,y:y,datum:i})}for(const e of l)f(e,a??"A");return i}(Array.isArray(e)?e:[],c,l,u),w=[];if(y&&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),n=l(e),o=u(e);Number.isFinite(n)&&w.push({__x:t,__y:n,__diffSegment:"line-A"}),Number.isFinite(o)&&w.push({__x:t,__y:o,__diffSegment:"line-B"})}}return{chartType:"mixed",data:[...v,...w],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")?d:h,stroke:"none",fillOpacity:f}},lineStyle:e=>({stroke:"A"==("line-A"===e.__diffSegment?"A":"B")?d:h,strokeWidth:p,fill:"none"}),curve:r.curve||"linear",...o,...g&&{legend:{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:m,color:d},{label:x,color:h}]}]},legendPosition:b}}}},rd={frameType:"xy",buildProps:(e,t,n,o,r)=>{const i=t||r.areaBy,s="string"==typeof i&&Array.isArray(e)?xe(e,i,n):void 0,a="number"==typeof r.areaOpacity?r.areaOpacity:.7,c=o.lineStyle||(e=>{const t=null==i?void 0:ge(e,i,s),n=r.showLine??!0,o={fill:r.color??t,stroke:n?r.stroke??t:"none",...n?{strokeWidth:r.strokeWidth??r.lineWidth??2}:{},fillOpacity:a,...null==r.opacity?{}:{opacity:r.opacity}},c=r.styleRules;if(c?.length){const t=Ae(r.yAccessor),n=i?"function"==typeof i?(i(e)??"")+"":(e[i]??"")+"":void 0;Object.assign(o,Ce(e,c,{value:t(e),category:n}))}return o}),l=r.normalize?"zero":r.baseline??"zero",u=o.pointStyle||Ju(e,i,n,o,r);return{chartType:"stackedarea",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.areaBy,colorAccessor:i,colorScheme:n,normalize:r.normalize,baseline:l,stackOrder:r.stackOrder,lineStyle:c,...o,...u&&{pointStyle:u},curve:o.curve??r.curve??"monotoneX",showLegend:o.showLegend??!!i}}},id={frameType:"xy",buildProps:(e,t,n,o,r)=>{const[i]=o.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,...o,scalePadding:o.scalePadding??Math.max(2,Math.min(12,Math.round(i/40))),extentPadding:o.extentPadding??(i>200?.1:.02)}}},sd={frameType:"xy",buildProps:(e,t,n,o,r)=>{const i=o.pointStyle||Ku(e,t,n,o,r),s=function(e,t,n){return e&&0!==e.length?(o,r)=>{const i=Ce(o,e,t(o,r)),s=n?n(o,r):void 0;return s?{...i,...s}:i}:n}(r.styleRules,Me(r.xAccessor||"x",r.yAccessor||"y"),c),a=s?e=>({..."function"==typeof i?i(e):i,...s(e)}):i;var c;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:n,...o,sizeRange:r.sizeRange||[3,15],pointStyle:a,showLegend:o.showLegend??!!t}}},ad={frameType:"xy",buildProps:(e,t,n,o,r)=>{const i=r.xCenter,s=r.yCenter,a=r.quadrants,c=r.centerlineStyle||{},l=!1!==r.showQuadrantLabels,u=r.quadrantLabelSize??12,d=c.stroke||"#999",h=c.strokeWidth??1,f=Array.isArray(c.strokeDasharray)?c.strokeDasharray.join(","):c.strokeDasharray,p=$.createElement,y=a?[(e,t,n)=>{if(!t?.x||!t?.y)return null;const o=n.width,r=n.height,c=null!=i?t.x(i):o/2,y=null!=s?t.y(s):r/2;if(null!=i&&!Number.isFinite(c))return null;if(null!=s&&!Number.isFinite(y))return null;const g=Math.max(0,Math.min(o,c)),m=Math.max(0,Math.min(r,y)),x=[{c:a.topLeft,x:0,y:0,w:g,h:m},{c:a.topRight,x:g,y:0,w:o-g,h:m},{c:a.bottomLeft,x:0,y:m,w:g,h:r-m},{c:a.bottomRight,x:g,y:m,w:o-g,h:r-m}],b=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:o-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:o-8,y:r-8,fill:a.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.bottomRight.label)]:[];return p($.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:g,y1:0,x2:g,y2:r,stroke:d,strokeWidth:h,strokeDasharray:f}),p("line",{key:"hc",x1:0,y1:m,x2:o,y2:m,stroke:d,strokeWidth:h,strokeDasharray:f}),...b)}]: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:n,pointStyle:o.pointStyle||r.pointStyle||Ku(e,t,n,o,r),...o,showLegend:o.showLegend??!!t,...y&&{svgPreRenderers:y}}}},cd={frameType:"xy",buildProps:(e,t,n,o,r)=>{const i=function(e,t){if(!Array.isArray(e))return{data:e,orderMap:new WeakMap};const n=t.xAccessor||"x",o=t.yAccessor||"y",r=t.orderAccessor?[...e].sort((e,n)=>null==e||"object"!=typeof e?1:null==n||"object"!=typeof n?-1:De(ze(t.orderAccessor,"order",e))-De(ze(t.orderAccessor,"order",n))):e,i=new WeakMap;let s=0;for(const e of r){if(null==e||"object"!=typeof e)continue;const t=De(ze(n,"x",e)),r=De(ze(o,"y",e));Number.isFinite(t)&&Number.isFinite(r)&&s++}let a=0;for(const e of r){if(null==e||"object"!=typeof e)continue;const t=De(ze(n,"x",e)),r=De(ze(o,"y",e));Number.isFinite(t)&&Number.isFinite(r)&&i.set(e,{idx:a++,total:s})}return{data:r,orderMap:i}}(e,r),s=r.pointRadius??4,a=[e=>{const t=e.filter(e=>"point"===e.type&&"number"==typeof e.x&&"number"==typeof e.y);if(2>t.length)return null;const n=[];for(let e=0;t.length-1>e;e++){const o=t[e],r=t[e+1],i=Ee(e,t.length);100>t.length&&n.push($.createElement("line",{key:"halo-"+e,x1:o.x,y1:o.y,x2:r.x,y2:r.y,stroke:"white",strokeWidth:s+2,strokeLinecap:"round",opacity:.5})),n.push($.createElement("line",{key:"segment-"+e,x1:o.x,y1:o.y,x2:r.x,y2:r.y,stroke:i,strokeWidth:s,strokeLinecap:"round"}))}return $.createElement($.Fragment,null,...n)}];return{chartType:"scatter",data:i.data,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,colorScheme:n,pointStyle:Se(e=>{const t=i.orderMap.get(e),n=t?.idx??0,o=t?.total??1;return{fill:o>0?Ee(n,o):"#6366f1",stroke:"white",strokeWidth:1,r:s,fillOpacity:1}},Oe(r)),...o,svgPreRenderers:a}}},ld={frameType:"xy",buildProps:(e,t,n,o,r)=>{const i=Number.isFinite(r.cellBorderWidth)?Math.max(0,r.cellBorderWidth):1;return{chartType:"heatmap",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",valueAccessor:r.valueAccessor,colorScheme:n||r.colorScheme||"blues",showValues:r.showValues,heatmapValueFormat:r.valueFormat,areaStyle:()=>({stroke:r.cellBorderColor??"#fff",strokeWidth:i}),...o}}};function ud(e){return Math.max(0,Math.min(1,e))}function dd(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 n=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(n){const e=[Number(n[1]),Number(n[2]),Number(n[3])];if(e.every(Number.isFinite))return e}return null}function hd(e,t,n){const o=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}`}function fd(e,t,n){const o=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:ud(e.offset),color:e.color??n,opacity:null==e.opacity?1:ud(e.opacity)})).sort((e,t)=>e.offset-t.offset);if(0===o.length)return"#999999";const r=e=>{if(1===e.opacity)return e.color;const t=dd(e.color);return t?`rgba(${t[0]},${t[1]},${t[2]},${e.opacity})`:e.color};if(1===o.length)return r(o[0]);const i=ud(t);if(o[0].offset>=i)return r(o[0]);if(i>=o[o.length-1].offset)return r(o[o.length-1]);for(let e=0;o.length-1>e;e++){const t=o[e],n=o[e+1];if(t.offset>i||i>n.offset)continue;const s=n.offset-t.offset,a=s>0?(i-t.offset)/s:0,c=dd(t.color),l=dd(n.color);if(!c||!l)return r(.5>a?t:n);const[u,d,h]=c,[f,p,y]=l,g=u+(f-u)*a,m=d+(p-d)*a,x=h+(y-h)*a,b=t.opacity+(n.opacity-t.opacity)*a;return 1===b?hd(g,m,x):`rgba(${Math.round(g)},${Math.round(m)},${Math.round(x)},${b})`}return r(o[o.length-1])}function pd(e,t,n){return null==n?`${e}-${t}`:`${e}-${t}-${n}`}var yd=require("react/jsx-runtime");function gd(e=240){const t=360-e,n=180+t/2,o=n*Math.PI/180;return{sweepRad:e*Math.PI/180,gapDeg:t,startAngleDeg:n,startAngleRad:o,offsetRad:-Math.PI/2+o}}require("react");var md={RdBu:ne,PiYG:oe,PRGn:re,BrBG:ie,RdYlBu:se,RdYlGn:ae,Spectral:ce},xd="__likert_neutral_neg",bd="__likert_neutral_pos";function vd(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}var wd=y(require("react"));function kd(e){return Te(e)}function Sd(e,t,n,o,r){const i=Je(o.theme).colors.categorical,s=n??o.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?xe(l,c,s??i):void 0,d=Su("string"==typeof r.color?r.color:void 0,i,s,void 0,new Map),h=Ae(r.valueAccessor),f=r.styleRules,p=o.pieceStyle;return(e,n)=>{const o={fill:t&&u?ge(e,t,u):d};return f?.length&&Object.assign(o,Ce(e,f,{value:h(e),category:n})),"function"==typeof p?Object.assign(o,p(e,n)||{}):p&&"object"==typeof p&&Object.assign(o,p),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 Ad(e,t,n,o,r){const i=Sd(e,t,n,o,r);return(e,t)=>{const n=i(e,t);return void 0===n.fillOpacity&&(n.fillOpacity=.8),void 0===n.stroke&&(n.stroke=n.fill),n}}function Md(e,t,n,o,r){const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s="string"==typeof t?t:"__ssrViolinColorBy",a="function"==typeof t?i.map(e=>({...e,__ssrViolinColorBy:t(e)})):i,c=Je(o.theme).colors.categorical,l=n??o.colorScheme,u=t?xe(a,s,l??c):void 0,d=Su("string"==typeof r.color?r.color:void 0,c,l,void 0,new Map);return e=>{const n=t&&u?ge(e,t,u):d;return{fill:n,fillOpacity:.6,stroke:r.stroke??n,...void 0!==r.strokeWidth&&{strokeWidth:r.strokeWidth},...void 0!==r.opacity&&{opacity:r.opacity}}}}function _d(e,t,n,o,r){const i=Sd(e,t,n,o,r),s="number"==typeof r.dotRadius?r.dotRadius:5;return(e,t)=>({r:s,fillOpacity:.8,...i(e,t)})}function Pd(e,t,n,o,r){const i=Sd(e,t,n,o,r),s=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=r.sizeBy,c=Array.isArray(r.sizeRange)?r.sizeRange:[3,8],l=a?s.map(e=>"function"==typeof a?a(e):Number(e[a])).filter(Number.isFinite):[],u=l.length?ve(l):void 0,d="number"==typeof r.pointRadius?r.pointRadius:4,h="number"==typeof r.pointOpacity?r.pointOpacity:.7;return(e,t)=>({r:a?be(e,a,c,u):d,fillOpacity:h,...i(e,t)})}var jd={frameType:"ordinal",buildProps:(e,t,n,o,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:n,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...o,gradientFill:kd(o.gradientFill),pieceStyle:Sd(e,t,n,o,r)})},Cd={frameType:"ordinal",buildProps:(e,t,n,o,r)=>{const i=t||r.stackBy;return{chartType:"bar",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.stackBy,colorAccessor:i,colorScheme:n,projection:"horizontal"===r.orientation?"horizontal":"vertical",normalize:r.normalize,oSort:r.sort??!1,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...o,gradientFill:kd(o.gradientFill),pieceStyle:Sd(e,i,n,o,r),showLegend:o.showLegend??!!i}}},Rd={frameType:"ordinal",buildProps:(e,t,n,o,r)=>{const i=t||r.groupBy;return{chartType:"clusterbar",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",groupBy:r.groupBy,colorAccessor:i,colorScheme:n,projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:r.sort??!1,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...o,gradientFill:kd(o.gradientFill),pieceStyle:Sd(e,i,n,o,r),showLegend:o.showLegend??!!i}}},Ld={frameType:"ordinal",buildProps:(e,t,n,o,r)=>{const i=t||r.categoryAccessor;return{chartType:"pie",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",colorAccessor:i,colorScheme:n,...null!=r.cornerRadius&&{cornerRadius:r.cornerRadius},...null!=r.startAngle&&{startAngle:r.startAngle},...o,pieceStyle:Sd(e,i,n,o,r),showLegend:o.showLegend??!!i}}},Id={frameType:"ordinal",layout:{primarySize:{width:400,height:400}},buildProps:(e,t,n,o,r)=>{const i=t||r.categoryAccessor;return{chartType:"donut",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",margin:o.margin??{top:50,right:40,bottom:60,left:70},innerRadius:r.innerRadius??60,colorAccessor:i,colorScheme:n,...null!=r.cornerRadius&&{cornerRadius:r.cornerRadius},...null!=r.startAngle&&{startAngle:r.startAngle},...o,pieceStyle:Sd(e,i,n,o,r)}}},Td={frameType:"ordinal",buildProps:(e,t,n,o,r)=>{const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=r.valueAccessor||"value",a=i.map(e=>Number("function"==typeof s?s(e):e[s])).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:s,projection:"horizontal",bins:r.bins??25,normalize:r.relative??!1,colorAccessor:t,colorScheme:n,barPadding:r.categoryPadding??20,...r.valueExtent?{rExtent:r.valueExtent}:c?{rExtent:c}:{},...o,summaryStyle:Ad(e,t,n,o,r)}}},$d={frameType:"ordinal",buildProps:(e,t,n,o,r)=>({chartType:"boxplot",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:t,colorScheme:n,...null!=r.showOutliers&&{showOutliers:r.showOutliers},...null!=r.outlierRadius&&{outlierRadius:r.outlierRadius},...o,summaryStyle:o.summaryStyle||Ad(e,t,n,o,r)})},zd={frameType:"ordinal",buildProps:(e,t,n,o,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:n,...o,summaryStyle:o.summaryStyle||Md(e,t,n,o,r),showLegend:o.showLegend??!!t,...r.valueExtent&&{rExtent:r.valueExtent}})},Dd={frameType:"ordinal",buildProps:(e,t,n,o,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:n,...o,sizeRange:r.sizeRange||[3,8],pieceStyle:o.pieceStyle||Pd(e,t,n,o,r),showLegend:o.showLegend??!!t})},Ed={frameType:"ordinal",layout:{modeDefaults:{showGrid:!0}},buildProps:(e,t,n,o,r)=>({chartType:"point",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:t,colorScheme:n,projection:"vertical"===r.orientation?"vertical":"horizontal",oSort:r.sort??"auto",barPadding:r.categoryPadding??10,...o,pieceStyle:_d(e,t,n,o,r),showGrid:o.showGrid??!0,showLegend:o.showLegend??!!t})},Od={frameType:"ordinal",buildProps:(e,t,n,o,r)=>{const i=t||r.subcategoryAccessor;return{chartType:"swimlane",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.subcategoryAccessor,colorAccessor:i,categoryAccessor:r.categoryAccessor,subcategoryAccessor:r.subcategoryAccessor,colorScheme:n,projection:"vertical"===r.orientation?"vertical":"horizontal",...null!=r.trackFill&&{trackFill:r.trackFill},...r.valueExtent&&{rExtent:r.valueExtent},...null!=r.roundedTop&&{roundedTop:r.roundedTop},...o,gradientFill:kd(o.gradientFill),pieceStyle:o.pieceStyle||Sd(e,i,n,o,r),showLegend:o.showLegend??!!i,barPadding:r.barPadding??40}}},Fd={frameType:"ordinal",buildProps:(e,t,n,o,r)=>({chartType:"ridgeline",data:e,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:t,colorScheme:n,projection:"vertical"===r.orientation?"vertical":"horizontal",bins:r.bins??20,amplitude:r.amplitude??1.5,barPadding:r.categoryPadding??5,oSort:r.oSort??!1,...o,summaryStyle:o.summaryStyle||((i,s)=>({fillOpacity:.5,...Sd(e,t,n,o,r)(i,s)})),showLegend:o.showLegend??!!t})},Bd={frameType:"ordinal",layout:{margin:(e,t)=>({...t.marginDefaults,left:"vertical"===e.orientation?t.marginDefaults.left:Math.max(100,t.marginDefaults.left)})},buildProps:(e,t,n,o,r)=>{const i=Array.isArray(r.levels)&&r.levels.length>=2?r.levels:["Strongly disagree","Disagree","Neutral","Agree","Strongly agree"],s="vertical"!==r.orientation;let a=function(e,t,n,o,r,i){const s=new Map,a=new Set(t);for(const c of e){const e=n(c);s.has(e)||s.set(e,new Map);const l=s.get(e);if(o){const e=o(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 n=e-1;if(0>n||n>=t.length)continue;const r=t[n];l.set(r,(l.get(r)||0)+1)}else if(r&&i){const e=r(c),t=i(c);if(!a.has(e))continue;l.set(e,(l.get(e)||0)+(Number.isFinite(t)?t:0))}}const c=[];for(const[e,n]of s){let o=0;for(const e of t)o+=n.get(e)||0;if(0!==o)for(let r=0;t.length>r;r++){const i=t[r],s=n.get(i)||0;c.push({__likertCategory:e,__likertLevel:i,__likertLevelLabel:i,__likertCount:s,__likertPct:s/o*100,__likertLevelIndex:r})}}return c}(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],i,vd(r.categoryAccessor,"question"),r.levelAccessor?null:vd(r.valueAccessor,"score"),r.levelAccessor?vd(r.levelAccessor,"level"):null,r.levelAccessor?vd(r.countAccessor,"count"):null);s&&(a=function(e,t){const n=t.length,o=n%2!=0,r=Math.floor(n/2),i=new Map;for(const t of e){const e=i.get(t.__likertCategory)||[];e.push(t),i.set(t.__likertCategory,e)}const s=[];for(const[,e]of i){const t=new Map;let i,a;for(const n of e)n.__likertLevel===xd?i=n:n.__likertLevel===bd?a=n:t.set(n.__likertLevelIndex,n);o&&i&&s.push(i);for(let e=r-1;e>=0;e--){const n=t.get(e);n&&s.push(n)}o&&a&&s.push(a);for(let e=o?r+1:r;n>e;e++){const n=t.get(e);n&&s.push(n)}}return s}(function(e,t){const n=t.length,o=n%2!=0,r=Math.floor(n/2),i=[];for(const t of e){const e=t.__likertLevelIndex;if(o&&e===r){const e=t.__likertPct/2;i.push({...t,__likertLevel:xd,__likertPct:-e}),i.push({...t,__likertLevel:bd,__likertPct:e})}else i.push(r>e?{...t,__likertPct:-t.__likertPct}:t)}return i}(a,i),i));const c=Je(o.theme).colors.diverging,l=Array.isArray(n)&&n.length>=i.length?n:function(e,t){if(0>=e)return[];if(t){const n=md[t];if(n){if(1===e)return[n(.5)];const t=[];for(let o=0;e>o;o++)t.push(n(o/(e-1)));return t}}const n=["#da1e28","#ff8389","#ffb3b8"],o=["#a6c8ff","#4589ff","#0043ce"],r="#a8a8a8";if(1===e)return[r];const i=e%2!=0,s=Math.floor(e/2),a=[];for(let e=0;s>e;e++)a.push(n[Math.min(Math.floor(e*n.length/s),n.length-1)]);i&&a.push(r);for(let e=0;s>e;e++)a.push(o[Math.min(Math.floor(e*o.length/s),o.length-1)]);return a}(i.length,c),u=new Map(i.map((e,t)=>[e,l[t]||"#888"])),d=i.length%2&&u.get(i[Math.floor(i.length/2)])||"#888",h="function"==typeof r.valueFormat?r.valueFormat:e=>Math.abs(Number(e)).toFixed(0)+"%",f=vr(!1===o.showLegend?void 0:{legendGroups:[{label:"",items:i.map(e=>({label:e})),styleFn:e=>({fill:u.get(e.label)||"#888"})}]},o.legend);return{chartType:"bar",data:a,oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:s?"horizontal":"vertical",barPadding:r.barPadding,showGrid:o.showGrid,oLabel:r.categoryLabel,rLabel:r.valueLabel||(s?void 0:"Percentage"),rFormat:h,...r.categoryFormat&&{oFormat:r.categoryFormat},...r.valueExtent&&{rExtent:r.valueExtent},...o,pieceStyle:Se(e=>{const t=e.__likertLevel||e.data?.__likertLevel;return{fill:t===xd||t===bd?d:u.get((e.__likertLevelLabel||e.data?.__likertLevelLabel||t)+"")||"#888"}},Oe(r)),showLegend:o.showLegend??!0,legendPosition:o.legendPosition||"right",...f&&{legend:f},__legendIncludesAutomatic:!0}}},Nd={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,n,o,r)=>{const i="vertical"===r.orientation,s=t||r.categoryAccessor;return{chartType:i?"bar-funnel":"funnel",data:e,oAccessor:r.stepAccessor||"step",rAccessor:r.valueAccessor||"value",colorAccessor:s,categoryAccessor:r.categoryAccessor,projection:i?"vertical":"horizontal",connectorAccessor:r.connectorAccessor,connectorStyle:r.connectorStyle,...!i&&null!=r.connectorOpacity&&{connectorOpacity:r.connectorOpacity},barPadding:i?40:0,colorScheme:n,...o,showAxes:i,showGrid:i,pieceStyle:Sd(e,s,n,o,r),showLabels:r.showLabels??!0}}},Wd={frameType:"ordinal",layout:{primarySize:{width:300,height:250}},renderOverlay:function(e,{theme:t}){const n=e.__gauge;if(!n)return null;const o=(n.startAngleDeg+(n.gMax===n.gMin?0:(Math.max(n.gMin,Math.min(n.gMax,n.value??n.gMin))-n.gMin)/(n.gMax-n.gMin))*n.sweep-90)*Math.PI/180,r=n.needleColor||t.colors.text,i=n.showScaleLabels?(n.thresholds||[]).filter(e=>e.value>n.gMin&&n.gMax>e.value):[];return(0,yd.jsxs)(yd.Fragment,{children:[n.showNeedle&&(0,yd.jsxs)(yd.Fragment,{children:[(0,yd.jsx)("line",{x1:n.centerX,y1:n.centerY,x2:n.centerX+n.needleLength*Math.cos(o),y2:n.centerY+n.needleLength*Math.sin(o),stroke:r,strokeWidth:2.5,strokeLinecap:"round"}),(0,yd.jsx)("circle",{cx:n.centerX,cy:n.centerY,r:4,fill:r})]}),null!=n.contextValue&&(0,yd.jsx)("text",{x:n.centerX,y:n.contextValueY,textAnchor:"middle",dominantBaseline:"middle",fontSize:n.valueFontSize,fontWeight:700,fill:r,children:n.contextValue}),i.map((e,o)=>{const r=(n.startAngleDeg+(n.gMax===n.gMin?0:(e.value-n.gMin)/(n.gMax-n.gMin))*n.sweep-90)*Math.PI/180,i=n.innerRadius-1,s=n.radius+1,a=n.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(0,yd.jsxs)("g",{children:[(0,yd.jsx)("line",{x1:n.centerX+Math.cos(r)*i,y1:n.centerY+Math.sin(r)*i,x2:n.centerX+Math.cos(r)*s,y2:n.centerY+Math.sin(r)*s,stroke:t.colors.border,strokeWidth:2,strokeLinecap:"round"}),(0,yd.jsx)("text",{x:n.centerX+Math.cos(r)*a,y:n.centerY+Math.sin(r)*a,textAnchor:l,dominantBaseline:u,fill:t.colors.textSecondary,fontSize:10,children:e.label||e.value+""})]},"gauge-label-"+o)})]})},buildProps:(e,t,n,o,r)=>{const i=r.min??0,s=r.max??100,a=r.sweep??240,c=r.arcWidth??.3,l=!1!==r.showNeedle,u=!1!==r.fillZones,{startAngleDeg:d}=gd(a),h=r.thresholds||[{value:s,color:r.color||"#4e79a7"}],f=$e(o.gradientFill),p=function(e){const{min:t,max:n,value:o,thresholds:r,fillColor:i,backgroundColor:s,fillZones:a,showScaleLabels:c,gradientFill:l,gradientSteps:u=240}=e,d=n-t||1,h=(Math.max(t,Math.min(n,o))-t)/d;let f=r&&r.length>0?[...r].sort((e,t)=>e.value-t.value):[{value:n,color:i||"#007bff"}];f=f.map(e=>({...e,value:Math.max(t,Math.min(n,e.value))})),n>f[f.length-1].value&&f.push({value:n,color:f[f.length-1].color});const p=!!l&&l.stops.length>=2,y=[],g=new Map,m=[];if(p){const e=a?h:1,t=pd("bg",0);if(y.push({category:t,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),g.set(t,{fill:s,opacity:.4}),e>0){const t=Math.max(1,Math.floor(u)),n=Math.max(1,Math.min(t,Math.round(e*t))),o=[];for(let t=0;n>t;t++)o.push(fd(l.stops,e*(t+.5)/n,i||f[0]?.color||"#007bff"));const r=pd("fill",0);y.push({category:r,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:o}}),g.set(r,{fill:o[0]||s})}}else{let e=t;for(let n=0;f.length>n;n++){const o=f[n],r=(o.value-e)/d,i=(e-t)/d,c=(o.value-t)/d,l=Math.max(0,(a?Math.min(h,c):c)-i),u=a?Math.max(0,r-l):0;if(l>0){const e=pd("fill",n);y.push({category:e,value:l,_zone:o.label||"Zone "+(n+1),_isFill:!0}),g.set(e,{fill:o.color})}if(u>0){const e=pd("bg",n);y.push({category:e,value:u,_zone:o.label||"Zone "+(n+1),_isFill:!1}),g.set(e,{fill:s,opacity:.4})}e=o.value}}if(c&&r&&r.length>0)for(const e of r)e.value>t&&n>e.value&&m.push({type:"gauge-label",value:e.value,label:e.label||e.value+""});return{gaugeData:y,pieceStyle:(e,t)=>g.get(t||e.category)||{fill:s},gaugeAnnotations:m}}({min:i,max:s,value:r.value,thresholds:h,fillColor:r.color,backgroundColor:r.backgroundColor||"#e0e0e0",fillZones:u,showScaleLabels:!1!==r.showScaleLabels,gradientFill:f}),[y,g]=o.size||[300,250],m=function(e=240){const{sweepRad:t,offsetRad:n}=gd(e),o=[[Math.cos(n),Math.sin(n)],[Math.cos(n+t),Math.sin(n+t)],[0,0]];for(let e=0;2*Math.PI>e;e+=Math.PI/2)((e-n)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)>t+.001||o.push([Math.cos(e),Math.sin(e)]);const r=o.map(e=>e[0]),i=o.map(e=>e[1]),[s,a]=ve(r),[c,l]=ve(i);return{minX:s,maxX:a,minY:c,maxY:l,width:a-s,height:l-c,cx:(s+a)/2,cy:(c+l)/2}}(a),x=Math.min(10,Math.max(1,Math.min(y,g)/12)),b=Math.max(4,Math.min((y-2*x)/m.width,(g-2*x)/m.height)-2),v=Math.max(0,Math.min(b-1.5,b*(1-c))),w=y/2-m.cx*b,k=g/2-m.cy*b,S=2*(b+4),A=Math.max(i,Math.min(s,r.value??i)),M="function"==typeof r.valueFormat?r.valueFormat(A):Math.round(A)+"",_=r.centerContent??o.centerContent,P=null!=_?"function"==typeof _?_(A,i,s):_:"sparkline"===r.mode||"context"===r.mode?void 0:wd.createElement("div",{style:{textAlign:"center",lineHeight:1.2}},wd.createElement("div",{style:{fontSize:Math.max(16,.3*b),fontWeight:700,color:"var(--semiotic-text, #333)"}},M),!1!==r.showScaleLabels&&wd.createElement("div",{style:{fontSize:11,color:"var(--semiotic-text-secondary, #666)"}},`${i} – ${s}`));return{chartType:"donut",data:p.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:v,sweepAngle:a,startAngle:d,oSort:!1,pieceStyle:Se(p.pieceStyle,Oe(r)),...null!=r.cornerRadius&&{cornerRadius:r.cornerRadius},...o,size:[y,g],margin:{top:k-S/2,bottom:g-k-S/2,left:w-S/2,right:y-w-S/2},...null!=P&&{centerContent:P},showAxes:!1,annotations:[...Array.isArray(o.annotations)?o.annotations:[],...p.gaugeAnnotations],__gauge:{gMin:i,gMax:s,sweep:a,arcWidth:c,value:A,startAngleDeg:d,thresholds:h,centerX:w,centerY:k,radius:b,innerRadius:v,showScaleLabels:!1!==r.showScaleLabels,needleLength:v>20?v-8:b-1,showNeedle:l,needleColor:r.needleColor,..."context"===r.mode&&null==_&&{contextValue:M,contextValueY:k-.2*v,valueFontSize:Math.max(12,Math.min(22,.28*b))}}}}},qd=require("d3-scale");function Yd(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 Gd(e,t,n){const o=t.incoming[e.id],r=t.outgoing[e.id],i=[];for(const e of o)i.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:n.get(e.id).targetSide});for(const e of r)i.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:n.get(e.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{i.sort((e,t)=>e.time-t.time||(s[e.kind]??99)-(s[t.kind]??99))},c=i.length?function(e,t=1/0){let n=t;for(const t of e)n>t&&(n=t);return n}(i.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,d=[...new Set(i.map(e=>e.time))].sort((e,t)=>e-t),h=new Map;for(let e=1;d.length>e;e++)h.set(d[e],d[e-1]);const f=e=>{const t=h.get(e);return null!=t?(t+e)/2:null!=u?u:e};a();const p=[];let y=0,g=0;for(const e of i)if("out"===e.kind){const t=Math.abs(e.delta);let n=t-("top"===e.side?y:g);if(n>0){const t="top"===e.side?"bot":"top",o=Math.min(n,"top"===t?y:g);if(o>0){const r=f(e.time);p.push({time:r,delta:-o,kind:"transfer-out",side:t}),p.push({time:r,delta:+o,kind:"transfer-in",side:e.side}),"top"===t?y-=o:g-=o,"top"===e.side?y+=o:g+=o,n-=o}n>0&&null!==u&&(p.push({time:u,delta:+n,kind:"create",side:e.side}),"top"===e.side?y+=n:g+=n)}"top"===e.side?y-=t:g-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?y+=t:g+=t}i.push(...p),a();let m=0,x=0,b=0,v=0,w=0;const k=[],S=new Map;for(const e of i){if(k.push({t:e.time,topMass:m,botMass:x}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?m:x;S.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>v&&(v=m),x>w&&(w=x),k.push({t:e.time,topMass:m,botMass:x})}const A=[];let M=0;for(;k.length>M;){let e=M;for(;k.length>e+1&&k[e+1].t===k[M].t;)e++;A.push(k[M]);for(let t=M+1;e>=t;t++){const e=A[A.length-1];k[t].topMass===e.topMass&&k[t].botMass===e.botMass||A.push(k[t])}M=e+1}const _=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 j=null;for(const e of o)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===j||e.systemOutTime>j)&&(j=e.systemOutTime);if(A.length>0){const e=A[A.length-1],t=Math.max(null!=_?_:-1/0,null!=j?j:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&A.push({t:t,topMass:e.topMass,botMass:e.botMass});const n=A[0],o=Math.min(null!=l?l:1/0,null!=P?P:1/0);Number.isFinite(o)&&n.t>o&&n.topMass+n.botMass>0&&A.unshift({t:o,topMass:n.topMass,botMass:n.botMass})}return{samples:A,peak:b,topPeak:v,botPeak:w,localAttachments:S}}function Hd(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Vd(e,t){return e.map(e=>({t:Hd(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function Xd(e,t,n){const o=e.value*n;if("out"===e.kind){const r=e.sideMassBefore*n;if("top"===e.side){const e=t-r;return[e,e+o]}const i=t+r;return[i-o,i]}const r=e.sideMassAfter*n;if("top"===e.side){const e=t-r;return[e,e+o]}const i=t+r;return[i-o,i]}function Ud(e,t){let n=0;for(let o=0;t.length>o;o++)for(let r=o+1;t.length>r;r++){const i=t[o],s=t[r];i.source!==s.source&&i.target!==s.target&&i.source!==s.target&&i.target!==s.source&&(Math.min(i.endTime,s.endTime)>Math.max(i.startTime,s.startTime)&&e[s.source]>e[i.source]!=e[s.target]>e[i.target]&&n++)}return n}function Kd(e,t){let n=0;for(const o of t)n+=Math.abs(e[o.source]-e[o.target])*(o.value||1);return n}function Zd(e,t){return 1e3*Ud(e,t)+Kd(e,t)}function Qd(e,t){return{slots:e.map(e=>({peak:{...e.peak},occupants:e.occupants.slice()})),map:{...t}}}function Jd(e,t,n){e.length>8||n.length>40?(function(e,t,n,o=6){const r=e.length;if(1>=r)return;let i=Qd(e,t),s=Zd(t,n);for(let a=0;o>a;a++){const o=Array(r).fill(0),a=Array(r).fill(0);for(const e of n){const n=t[e.source],r=t[e.target];o[n]+=r*(e.value||1),a[n]+=e.value||1,o[r]+=n*(e.value||1),a[r]+=e.value||1}const c=Array.from({length:r},(e,t)=>t).sort((e,t)=>(a[e]>0?o[e]/a[e]:e)-(a[t]>0?o[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 d=Zd(t,n);if(s>d)s=d,i=Qd(e,t);else if(d===s)break}!function(e,t,n){e.length=0;for(const t of n.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(n.map))t[e]=n.map[e]}(e,t,i)}(e,t,n,6),function(e,t,n,o=6){const r=e.length;if(1>=r)return;let i=Zd(t,n);for(let s=0;o>s;s++){let o=!1;for(let s=0;r-1>s;s++){const r=e[s];e[s]=e[s+1],e[s+1]=r;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s);const a=Zd(t,n);if(i>a)i=a,o=!0;else{const n=e[s];e[s]=e[s+1],e[s+1]=n;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s)}}if(!o)break}}(e,t,n,6)):function(e,t,n){const o=e.length;if(1>=o)return;const r={...t},i=Object.keys(r),s=Array.from({length:o},(e,t)=>t),a=s.slice(),c={...r};let l=s.slice(),u=1/0;const d=()=>{for(const e of i)c[e]=a[r[e]];const e=Zd(c,n);u>e&&(u=e,l=s.slice())},h=(e,t)=>{const n=s[e],o=s[t];s[e]=o,s[t]=n,a[n]=t,a[o]=e};d();const f=Array(o).fill(0);let p=0;for(;o>p;)p>f[p]?(h(p%2==0?0:f[p],p),d(),f[p]++,p=0):(f[p]=0,p++);const y=l.map(t=>e[t]),g=new Map;l.forEach((e,t)=>g.set(e,t));for(const e of Object.keys(t))t[e]=g.get(t[e]);e.length=0;for(const t of y)e.push(t)}(e,t,n)}function eh(e,t,n,o,r){const{plotH:i,padding:s,valueScale:a,packing:c,laneOrder:l,lifetimeMode:u="full"}=r,d={},h={};for(const t of e)d[t.id]=n[t.id].topPeak||0,h[t.id]=n[t.id].botPeak||0;const f="half"===u,p={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,n=Array.isArray(t.xExtent)?t.xExtent[1]:null;let r=null!=e&&Number.isFinite(e)?e:1/0,i=null!=n&&Number.isFinite(n)?n:-1/0;for(const e of o.outgoing[t.id]){r>e.startTime&&(r=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&r>e.systemInTime&&(r=e.systemInTime);const t=f?(e.startTime+e.endTime)/2:e.endTime;t>i&&(i=t)}for(const e of o.incoming[t.id]){const t=f?(e.startTime+e.endTime)/2:e.startTime;r>t&&(r=t),e.endTime>i&&(i=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>i&&(i=e.systemOutTime)}p[t.id]={start:Number.isFinite(r)?r:null,end:Number.isFinite(i)?i:null}}const y={},g=[];if("reuse"===c){const n=new Map;for(const t of e)n.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 i=[];for(const t of e)0===(r.get(t.id)??0)&&i.push(t.id);for(;i.length;){const e=i.shift();for(const t of o.outgoing[e]??[]){const o=(n.get(e)??0)+1;o>(n.get(t.target)??0)&&n.set(t.target,o),r.set(t.target,r.get(t.target)-1),0===r.get(t.target)&&i.push(t.target)}}const s=[...e].filter(e=>null!==p[e.id].start).sort((e,t)=>{const o=n.get(e.id)??0,r=n.get(t.id)??0;return o!==r?o-r:p[e.id].start-p[t.id].start}),a=e.filter(e=>null===p[e.id].start);for(const e of[...s,...a]){const t=p[e.id];let n=-1;for(let e=0;g.length>e;e++){const o=g[e].occupants[g[e].occupants.length-1];if(null===t.start||void 0===o||t.start>=o.end){n=e;break}}-1===n&&(g.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=g.length-1),g[n].occupants.push({id:e.id,end:t?.end??-1/0}),g[n].peak.topPeak=Math.max(g[n].peak.topPeak,d[e.id]),g[n].peak.botPeak=Math.max(g[n].peak.botPeak,h[e.id]),y[e.id]=n}}else e.forEach((e,t)=>{g.push({occupants:[{id:e.id,end:p[e.id]?.end??-1/0}],peak:{topPeak:d[e.id],botPeak:h[e.id]}}),y[e.id]=t});let m=null,x=null,b=null,v=null;const w=()=>{m=Ud(y,t),b=Kd(y,t)},k=()=>{x=Ud(y,t),v=Kd(y,t)};"crossing-min"===l?(w(),Jd(g,y,t),k()):"inside-out"===l?(w(),function(e,t){const n=e.length;if(1>=n)return;const o=e=>e.peak.topPeak+e.peak.botPeak,r=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>o(t.slot)-o(e.slot)),i=Array(n),s=Math.floor((n-1)/2);i[s]=r[0].idx;let a=s-1,c=s+1;for(let e=1;r.length>e;e++)e%2==1&&n>c||0>a?i[c++]=r[e].idx:i[a--]=r[e].idx;const l=i.map(t=>e[t]),u=new Map;i.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)}(g,y),k()):"crossing-min+inside-out"===l&&(w(),Jd(g,y,t),function(e,t,n){const o=e.length;if(1>=o)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),i=Math.floor((o-1)/2);let s=Zd(t,n);for(const{slot:a}of r){const r=e.indexOf(a);if(0>r)continue;const c=i;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;o>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 d=Zd(t,n);if(d>s){const n=e[c];e.splice(c,1),e.splice(r,0,n);const i=new Map;for(let e=0;o>e;e++)i.set(e,e);if(r>c){for(let e=c+1;r>=e;e++)i.set(e,e-1);i.set(c,r)}else{for(let e=r;c>e;e++)i.set(e,e+1);i.set(c,r)}for(const e of Object.keys(t))t[e]=i.get(t[e])}else s=d}}(g,y,t),k());const S=g.map(e=>{const t=new Map;for(const o of e.occupants){const e=n[o.id];if(e)for(const n of e.samples){const e=t.get(n.t)||{top:0,bot:0};t.set(n.t,{top:Math.max(e.top,n.topMass),bot:Math.max(e.bot,n.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),A=(e,t)=>{let n={top:0,bot:0};for(const[o,r]of e){if(o>t)break;n=r}return n},M=[];for(let e=0;g.length-1>e;e++){const t=S[e],n=S[e+1],o=new Set([...t.map(e=>e[0]),...n.map(e=>e[0])]);let r=0;for(const e of o){const o=A(t,e),i=A(n,e);o.bot+i.top>r&&(r=o.bot+i.top)}M.push(r)}const _=[];let P=s+(g[0]?.peak.topPeak??0)*a;g.length>0&&_.push(P);for(let e=1;g.length>e;e++)P+=M[e-1]*a+s,_.push(P);if(g.length>0&&(P+=g[g.length-1].peak.botPeak*a+s),P>i){const e=i/P;for(let t=0;_.length>t;t++)_[t]*=e}const j=0===g.length?0:g[0].peak.topPeak+M.reduce((e,t)=>e+t,0)+g[g.length-1].peak.botPeak,C={};for(const t of e)C[t.id]=_[y[t.id]];return{effectiveSlotsHeight:j,centerlines:C,laneLifetime:p,slots:g,slotByNode:y,slotCenter:_,crossingsBefore:m,crossingsAfter:x,lengthBefore:b,lengthAfter:v}}function th(e){const{sx:t,sTop:n,sBot:o,tx:r,tTop:i,tBot:s,cp1X:a,cp2X:c}=e,l=(n+o)/2,u=(i+s)/2;return{pathD:[`M${t},${n}`,`C${a},${n} ${c},${i} ${r},${i}`,`L${r},${s}`,`C${c},${s} ${a},${o} ${t},${o}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:l},{x:a,y:l},{x:c,y:u},{x:r,y:u}],halfWidth:(o-n)/2}}}function nh(e){const{nodes:t,edges:n,domain:o,plotW:r,plotH:i,ribbonLane:s,edgeOpacity:a,colorOf:c,layoutOpts:l}=e,u=function(e,t,n){const o=[],r=new Set(e.map(e=>e.id)),i=Array.isArray(n)&&2===n.length,s=i&&Number.isFinite(n[0])&&Number.isFinite(n[1]);i&&s&&s&&n[1]>=n[0]||o.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]||o.push({kind:"invalid-node-time",id:t.id}));for(const e of t)r.has(e.source)||o.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),r.has(e.target)||o.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||o.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||o.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):o.push({kind:"invalid-edge-time",id:e.id});return o}(t,n,o),d=(0,qd.scaleTime)().domain(o).range([0,r]);if(u.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:u,xScale:d};const h=function(e,t,n){const{plotH:o,pairing:r="temporal",packing:i="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half"}=n,c=function(e,t){const n={},o={};for(const t of e)n[t.id]=[],o[t.id]=[];for(const e of t)o[e.source]&&o[e.source].push(e),n[e.target]&&n[e.target].push(e);return{incoming:n,outgoing:o}}(e,t),l=function(e,t,n,o="value"){const r="temporal"===o?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,i="temporal"===o?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,s=new Map;for(const e of t)s.set(e.id,{});const a=(e,t)=>{const n=new Map;for(const o of e){const e=o[t];n.has(e)||n.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const r=n.get(e);r.edges.push(o),r.total+=o.value,r.earliestStart=Math.min(r.earliestStart,o.startTime),r.latestEnd=Math.max(r.latestEnd,o.endTime)}const s=[...n.values()];s.sort("temporal"===o?(e,n)=>"target"===t?e.earliestStart-n.earliestStart:e.latestEnd-n.latestEnd:(e,t)=>t.total-e.total);for(const e of s)e.edges.sort("target"===t?i:r);return s};for(const t of e){const e=n.outgoing[t.id],o=n.incoming[t.id];if(0===o.length)a(e,"target").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).sourceSide=n});else if(0===e.length)a(o,"source").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).targetSide=n});else{const t=a(o,"source"),n=a(e,"target"),r=Math.max(t.length,n.length);for(let e=0;r>e;e++){const o=e%2==0?"top":"bot";if(t[e])for(const n of t[e].edges)s.get(n.id).targetSide=o;if(n[e])for(const t of n[e].edges)s.get(t.id).sourceSide=o}}}return s}(e,t,c,r);let u={};for(const t of e)u[t.id]=Gd(t,c,l);const d=eh(e,t,u,c,{plotH:o,padding:12,valueScale:1,packing:i,laneOrder:s,lifetimeMode:a}),h=new Set;for(const e of t){const t=d.slotByNode[e.source],n=d.slotByNode[e.target];if(void 0===t||void 0===n)continue;const o=l.get(e.id);t!==n?t>n?(o.sourceSide="top",o.targetSide="bot"):(o.sourceSide="bot",o.targetSide="top"):(h.add(e.id),o.sourceSide="bot",o.targetSide="bot")}for(const t of e){const e=c.outgoing[t.id],n=c.incoming[t.id],o=new Set(e.map(e=>l.get(e.id).sourceSide)),r=new Set(n.map(e=>l.get(e.id).targetSide));if(1===o.size&&n.length>0){const e=[...o][0];for(const t of n)d.slotByNode[t.source]===d.slotByNode[t.target]&&(l.get(t.id).targetSide=e)}if(1===r.size&&e.length>0){const t=[...r][0];for(const n of e)d.slotByNode[n.source]===d.slotByNode[n.target]&&(l.get(n.id).sourceSide=t)}}for(const t of e){const e=c.incoming[t.id],n=c.outgoing[t.id];if(0===e.length||0===n.length)continue;const o=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of e)"top"===l.get(n.id).targetSide?t.inTop+=n.value:t.inBot+=n.value;for(const e of n)"top"===l.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},r=(e,t)=>{const r=o(),i="top"===e?r.outTop-r.inTop:r.outBot-r.inBot,s="top"===t?r.inTop-r.outTop:r.inBot-r.outBot;if(0>=i||0>=s)return!1;const a=Math.min(i,s),c=n.filter(t=>!h.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 i=n.length+1;for(;i-- >0&&(r("top","bot")||r("bot","top")););}u={};for(const t of e)u[t.id]=Gd(t,c,l);const f=eh(e,t,u,c,{plotH:o,padding:12,valueScale:1,packing:i,laneOrder:s,lifetimeMode:a}),p=f.effectiveSlotsHeight??f.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),y=Math.min(12,.35*o/Math.max(f.slots.length+1,1)),g=p>0?Math.max(0,(o-y*(f.slots.length+1))/p):1,m=eh(e,t,u,c,{plotH:o,padding:y,valueScale:g,packing:i,laneOrder:s,lifetimeMode:a});return{nodeData:u,sides:l,valueScale:g,padding:y,compressedPadding:12>y,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,n,{plotH:i,...l}),{centerlines:f,nodeData:p,valueScale:y}=h,g=[],m=[];t.forEach((e,t)=>{const r=p[e.id];if(!r||0===r.samples.length)return;const i=function(e,t,n,o,r){if(0===e.length)return null;const i=Vd(e,r),s=e=>t-i[e].topMass*n,a=e=>t+i[e].botMass*n;let c=`M${o(i[0].t)},${s(0)}`;for(let e=1;i.length>e;e++)c+=` L${o(i[e].t)},${s(e)}`;c+=` L${o(i[i.length-1].t)},${a(i.length-1)}`;for(let e=i.length-2;e>=0;e--)c+=` L${o(i[e].t)},${a(e)}`;return c+" Z"}(r.samples,f[e.id],y,d,o);if(!i)return;const s=Vd(r.samples,o),a=s.find(e=>e.topMass+e.botMass>0)||s[0],l=f[e.id]+(a.botMass-a.topMass)*y/2,u=c(e.id,t),m=function(e,t,n,o,r){const i=n.nodeData[e];if(!i||0===i.samples.length)return[];const s=n.valueScale,a=n.centerlines[e],c=Vd(i.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],d=o(l.t),h=o(u.t),f=e=>o(Hd(e,r)),p=[],y=(e,t,n,o)=>`M${e},${t} L${n},${t} L${n},${o} L${e},${o} Z`;for(const n of t){if(n.source===e&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const e=i.localAttachments.get(n.id);if(e&&"out"===e.kind&&n.startTime>n.systemInTime){const t=f(n.systemInTime),o=f(n.startTime),r=t-20,i=Math.max(d,r);if(o>i){const[n,c]=Xd(e,a,s);p.push({pathD:y(i,n,o,c),x0:r,x1:t,from:0,to:1})}}}if(n.target===e&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const e=i.localAttachments.get(n.id);if(e&&"in"===e.kind&&n.systemOutTime>n.endTime){const t=f(n.systemOutTime),o=f(n.endTime),r=t+20,i=Math.min(h,r);if(i>o){const[n,c]=Xd(e,a,s);p.push({pathD:y(o,n,i,c),x0:t,x1:r,from:1,to:0})}}}}return p}(e.id,n,h,d,o);g.push({id:e.id,pathD:i,fill:u,stroke:u,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)),n.forEach(e=>{const t=p[e.source]?.localAttachments.get(e.id),n=p[e.target]?.localAttachments.get(e.id);if(!t||!n)return;const r=x.get(e.source)??0,i=c(e.source,r),l=function(e,t,n,o,r,i,s,a){const c=r,l=e=>a?Math.max(a[0],Math.min(a[1],e)):e,u=i(l(e.time)),d=i(l(n.time)),h=e.value*c,f=n.value*c,p=e.sideMassBefore*c,y=n.sideMassAfter*c;let g,m,x,b;"top"===e.side?(g=t-p,m=g+h):(m=t+p,g=m-h),"top"===n.side?(x=o-y,b=x+f):(b=o+y,x=b-f);const v="source"===s?u+.85*(d-u):"target"===s?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:g,sBot:m,tx:d,tTop:x,tBot:b,cp1X:v,cp2X:v}}(t,f[e.source],n,f[e.target],y,d,s,o),{pathD:u,bezier:h}=th(l);m.push({id:e.id,pathD:u,fill:i,opacity:a,rawDatum:e.__raw??e,bezier:h})}),{layout:h,layoutConfig:{bands:g,ribbons:m,showLabels:!0},issues:[],xScale:d}}var oh=e=>{const{bands:t=[],ribbons:n=[],showLabels:o=!0}=e.config,r=[];for(const e of n)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 n=e.gradientStubs[t];r.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.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 i=o?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:i}};function rh(e,t){if(!e)return[];const n=[],o=e=>{n.push(e);const r="function"==typeof t?t(e):e[t];r&&Array.isArray(r)&&r.forEach(o)};return o(e),n}function ih(e,t,n,o){if(e&&e.length>0)return e;const r=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof o?o(e):e[o];r.add(t),r.add(i)}),Array.from(r).map(e=>({id:e}))}function sh(e,t,n={}){return Se(t?"function"==typeof t?n=>({...e(n),...t(n)??{}}):n=>({...e(n),...t}):e,n)}var ah=y(require("react")),ch={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,n,o,r)=>{const i=function(e){if(void 0!==e.edgeStyle)return e.edgeStyle;const{edgeWidth:t,edgeColor:n,edgeOpacity:o}=e,r=e.strokeWidth??1;return void 0!==t||void 0!==n||void 0!==o||void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity?i=>{const s=i?.data||i;let a=r;if("number"==typeof t)a=t;else if("function"==typeof t)a=t(s);else if("string"==typeof t){const e=s?.[t],n="number"==typeof e?e:Number(e);a=Number.isFinite(n)&&n>0?n:r}return{stroke:n??e.stroke??"#999",strokeWidth:a,opacity:o??e.opacity??.6}}:void 0}(r),s=Je(o.theme).colors.categorical,a=new Map,c=r.nodeStyle??(e=>({fill:t?ge(e?.data||e,t,void 0):Su(void 0,s,n,void 0,a),..."number"==typeof r.nodeSize&&{r:r.nodeSize}})),l=Le(r.styleRules,t,"number"==typeof r.nodeSize?void 0:r.nodeSize),u=Se(l?(e,t)=>({...c(e),...l(e,t)}):c,{stroke:r.nodeStroke??r.stroke,strokeWidth:r.nodeStrokeWidth??r.strokeWidth,opacity:r.opacity});return{chartType:"force",nodes:r.nodes,edges:r.edges,nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor,sourceAccessor:r.sourceAccessor,targetAccessor:r.targetAccessor,colorBy:t,colorScheme:n,iterations:r.iterations,forceStrength:r.forceStrength,showLabels:r.showLabels??!1,nodeLabel:r.nodeLabel,nodeSize:r.nodeSize??8,nodeSizeRange:r.nodeSizeRange,nodeStyle:u,edgeStyle:i,...o}}},lh={frameType:"network",layout:{margin:{top:30,right:80,bottom:40,left:80}},buildProps:(e,t,n,o,r)=>{const i=e=>null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime(),s=r.sourceAccessor||"source",a=r.targetAccessor||"target",c=r.valueAccessor||"value",l=r.nodeIdAccessor||"id",u=r.startTimeAccessor||"startTime",d=r.endTimeAccessor||"endTime",h=r.systemInTimeAccessor,f=r.systemOutTimeAccessor,p=r.xExtentAccessor||"xExtent",y=r.edgeIdAccessor||"id",g=(e,t)=>"function"==typeof e?e(t):t[e],m=Array.isArray(r.edges)?r.edges:[],x=Array.isArray(r.nodes)?r.nodes:[],b=x.length>0?x:ih([],m,s,a),v=[i(r.domain?.[0]),i(r.domain?.[1])],w=b.map(e=>{const t=g(l,e)+"",n=g(p,e),o={id:t,__raw:e};if(Array.isArray(n)&&2===n.length){const e=i(n[0]),t=i(n[1]);Number.isFinite(e)&&Number.isFinite(t)&&(o.xExtent=[e,t])}return o}),k=m.map((e,t)=>{const n=g(y,e),o={id:null!=n?n+"":`${g(s,e)}-${g(a,e)}-${t}`,source:g(s,e)+"",target:g(a,e)+"",value:Number(g(c,e)),startTime:i(g(u,e)),endTime:i(g(d,e)),__raw:e};if(h){const t=i(g(h,e));Number.isFinite(t)&&(o.systemInTime=t)}if(f){const t=i(g(f,e));Number.isFinite(t)&&(o.systemOutTime=t)}return o}),[S,A]=o.size??[600,400],M={top:20,right:20,bottom:20,left:20,...o.margin},_=(o.showLegend??!!t)&&!!t,P=o.legendPosition??"right",j=o.__explicitMargin,C=e=>"number"==typeof j||null!=j&&"object"==typeof j&&null!=j[e];_&&("right"!==P||C("right")?"bottom"!==P||C("bottom")||(M.bottom=Math.max(M.bottom,80)):M.right=Math.max(M.right,140));const R=M,L=S-R.left-R.right,I=A-R.top-R.bottom,T=he(n,Je(o.theme).colors.categorical,N),$="function"==typeof t?t:null,z=$?b.map(e=>({_cat:$(e)})):b,D=$?"_cat":"string"==typeof t?t:void 0,E=n??[...T],O=D?xe(z,D,E):null,F=new Map;for(const e of w)F.set(e.id,e.__raw);const B=(e,n)=>{if(t&&F.has(e)){const n=F.get(e);return $?ge({_cat:$(n)},"_cat",O??void 0):ge(n,"string"==typeof t?t:"id",O??void 0)}return T[n%T.length]},W=vr(_&&t?(()=>{const e=new Map;b.forEach((n,o)=>{const r=g(t,n),i=null==r?"":r+"";i&&!e.has(i)&&e.set(i,{label:i,color:B(g(l,n)+"",o)})});const n=Array.from(e.values());return n.length>0?{legendGroups:[{type:"fill",label:"",items:n,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0})():void 0,o.legend),{layout:q,layoutConfig:Y,issues:G,xScale:H}=nh({nodes:w,edges:k,domain:v,plotW:L,plotH:I,ribbonLane:r.ribbonLane||"both",edgeOpacity:"number"==typeof r.edgeOpacity?r.edgeOpacity:.35,colorOf:B,layoutOpts:{pairing:r.pairing||"temporal",packing:r.packing||"reuse",laneOrder:r.laneOrder||"crossing-min",lifetimeMode:r.lifetimeMode||"half"}});if(G.length>0){const e=G.map(Yd).join("; ");throw Error("ProcessSankey: data invalid — "+e)}const V=Array.isArray(r.axisTicks)?r.axisTicks:[],X=q?(()=>{let e=null,t=null;for(const n of w){const o=q.laneLifetime[n.id];if(!o||null==o.start||null==o.end)continue;const r=Number(H(o.start)),i=Number(H(o.end));e=null==e?r:Math.min(e,r),t=null==t?i:Math.max(t,i)}const n=e=>Math.max(0,Math.min(L,e)),o=n(e??0),s=Math.max(o,n(t??L)),a=V.map((e,t)=>({tick:e,index:t,x:Number(H(i(e.date)))})).filter(({x:e})=>e>=o-.5&&s+.5>=e);return ah.createElement("g",null,...a.map(({index:e,x:t})=>ah.createElement("line",{key:"grid-"+e,x1:t,y1:0,x2:t,y2:I,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"})),ah.createElement("line",{key:"axis",x1:o,y1:I+4,x2:s,y2:I+4,stroke:"#94a3b8"}),...a.map(({tick:e,index:t,x:n})=>{const o=i(e.date),s=null!=e.label?e.label:"function"==typeof r.timeFormat?r.timeFormat(new Date(o)):"";return ah.createElement("g",{key:"tick-"+t,transform:`translate(${n},${I+4})`},ah.createElement("line",{y2:6,stroke:"#94a3b8"}),ah.createElement("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569"},s))}))})():void 0;return{chartType:"force",nodes:b,edges:m,customNetworkLayout:oh,layoutConfig:Y,sourceAccessor:s,targetAccessor:a,valueAccessor:c,nodeIDAccessor:l,colorBy:t,colorScheme:n,...X&&{backgroundGraphics:X},...o,showLegend:_,...W&&{legend:W,legendPosition:P},__legendIncludesAutomatic:!0,margin:R}}},uh={frameType:"network",layout:{primarySize:{width:800,height:600}},buildProps:(e,t,n,o,r)=>{const i=Array.isArray(r.nodes)?r.nodes:ih([],Array.isArray(r.edges)?r.edges:[],r.sourceAccessor||"source",r.targetAccessor||"target"),s=Je(o.theme).colors.categorical,a=new Map,c="string"==typeof t?t:"__ssrSankeyColorBy",l="function"==typeof t?i.map(e=>({...e,__ssrSankeyColorBy:t(e)})):i,u=t?xe(l,c,n??o.colorScheme??s):void 0,d=e=>({fill:t?ge(e?.data||e,t,u):Su(void 0,s,n,void 0,a),stroke:r.stroke??"black",strokeWidth:r.strokeWidth??1,...void 0!==r.opacity&&{opacity:r.opacity}}),h=Le(r.styleRules,t,r.valueAccessor),f=h?(e,t)=>({...d(e),...h(e,t)}):d,p=function({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:o,edgeOpacity:r,baseStyle:i={}}){return s=>{const a={fillOpacity:r,...i};if("function"==typeof e)a.fill=e(s);else if("source"===e){const e="object"==typeof s.source?s.source:null;t&&e?a.fill=ge(e.data||e,t,n):e&&(a.fill=o(e,e.index).fill)}else if("target"===e){const e="object"==typeof s.target?s.target:null;t&&e?a.fill=ge(e.data||e,t,n):e&&(a.fill=o(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:f,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:Se(r.nodeStyle||f,Oe(r)),edgeStyle:Se(r.edgeStyle||p,Oe(r)),colorScheme:n,...o}}},dh={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,n,o,r)=>{if(!(t||Array.isArray(r.styleRules)&&r.styleRules.length>0||o.nodeStyle||r.nodeStyle||ke(Oe(r))))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:n,...o};const i=Array.isArray(r.edges)?r.edges:[],s=Array.isArray(r.nodes)&&r.nodes.length>0?r.nodes:ih([],i,r.sourceAccessor||"source",r.targetAccessor||"target"),a=Je(o.theme).colors.categorical,c=he(n,a),l="string"==typeof t?t:"__ssrChordColorBy",u="function"==typeof t?s.map(e=>({...e,__ssrChordColorBy:t(e)})):s,d=t?xe(u,l,n??o.colorScheme??a):void 0,h=new Map,f=r.nodeIdAccessor||r.nodeIDAccessor||"id",p=(e,n)=>{const o=e?.data||e;let i;if(t)i=ge(o,t,d);else{const t=(e.id??o?.[f]??"")+"";h.has(t)||h.set(t,h.size);const r=e.index??n??h.get(t);i=c[r%c.length]}return{fill:i,stroke:r.stroke??"black",strokeWidth:r.strokeWidth??1,...void 0!==r.opacity&&{opacity:r.opacity}}},y=Le(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:n,nodeStyle:Se(r.nodeStyle||y,Oe(r)),...o}}},hh={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,n,o,r)=>{const i=Je(o.theme).colors.categorical,s=new Map,a=rh(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,d=t&&u?xe(l,u,n??o.colorScheme??i):void 0,h=o.nodeStyle||r.nodeStyle;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:n,...o,nodeStyle:sh(e=>{const o=e?.data||e;return{fill:r.colorByDepth?pe[Number(e?.depth||0)%pe.length]:t?c?ge({__ssrTreeColorBy:c(o)},"__ssrTreeColorBy",d??void 0):ge(o,t,d??void 0):Su(void 0,i,n,void 0,s),stroke:r.stroke??"black",strokeWidth:r.strokeWidth??1,...void 0!==r.opacity&&{opacity:r.opacity}}},h,Oe(r))}}},fh={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,n,o,r)=>{const i=Je(o.theme).colors.categorical,s=new Map,a=rh(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,d=t&&u?xe(l,u,n??o.colorScheme??i):void 0,h=r.showLabels??o.showLabels,f=r.labelMode,p=void 0!==r.paddingTop?r.paddingTop:o.paddingTop,y=void 0!==p?p:!h||"parent"!==f&&"all"!==f?void 0:18,g=o.nodeStyle||r.nodeStyle;return{chartType:"treemap",data:e,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:t,colorByDepth:r.colorByDepth,showLabels:r.showLabels,labelMode:f,nodeLabel:h?r.nodeLabel||r.nodeIdAccessor:void 0,...null!=r.padding&&{padding:r.padding},...null!=y&&{paddingTop:y},colorScheme:n,...o,nodeStyle:sh(e=>{const o=e?.data||e;return{fill:r.colorByDepth?pe[Number(e?.depth||0)%pe.length]:t?c?ge({__ssrTreemapColorBy:c(o)},"__ssrTreemapColorBy",d??void 0):ge(o,t,d??void 0):Su(void 0,i,n,void 0,s),stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8}},g,Oe(r))}}},ph={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,n,o,r)=>{const i=Je(o.theme).colors.categorical,s=new Map,a=rh(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,d=t&&u?xe(l,u,n??o.colorScheme??i):void 0,h=o.nodeStyle||r.nodeStyle;return{chartType:"circlepack",data:e,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:t,colorByDepth:r.colorByDepth,showLabels:r.showLabels,nodeLabel:r.showLabels??o.showLabels?r.nodeLabel||r.nodeIdAccessor:void 0,...null!=r.padding&&{padding:r.padding},colorScheme:n,...o,nodeStyle:sh(e=>{const o=e?.data||e;return{fill:r.colorByDepth?pe[Number(e?.depth||0)%pe.length]:t?c?ge({__ssrCirclePackColorBy:c(o)},"__ssrCirclePackColorBy",d??void 0):ge(o,t,d??void 0):Su(void 0,i,n,void 0,s),fillOpacity:r.circleOpacity??.7,stroke:"currentColor",strokeWidth:1,strokeOpacity:.3}},h,Oe(r))}}},yh={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},gh=require("d3-scale");function mh(e){return e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e}var xh={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,n,o,r)=>{const i="string"==typeof n?n:"blues",s=r.areaStyle??function(e,t,n,o){if(!Array.isArray(e))return;const r=e=>"function"==typeof t?t(e):null!=t?e?.properties?.[t]??e?.[t]:void 0;let i=1/0,s=-1/0;for(const t of e){const e=r(t);null!=e&&isFinite(e)&&(i>e&&(i=e),e>s&&(s=e))}const a=(0,gh.scaleSequential)(te(n)).domain([Number.isFinite(i)?i:0,Number.isFinite(s)?s:1]);return e=>{const t=r(e);return{fill:null!=t&&isFinite(t)?a(t):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:o}}}(r.areas,r.valueAccessor,i,r.areaOpacity??1),a=r.styleRules?Re(s,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},mh):s;return{areas:r.areas,projection:r.projection||"equalEarth",areaStyle:a,valueAccessor:r.valueAccessor,colorScheme:i,graticule:r.graticule,fitPadding:r.fitPadding,...o}}},bh={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,n,o,r)=>{const i=e||r.points,s=r.pointStyle??function(e,t,n,o){const r=Array.isArray(e)?e:[];let i,s;if(t){const e="string"==typeof t?t:"__geoColorBy",o="string"==typeof t?r:r.map(e=>({...e,__geoColorBy:t(e)}));i=xe(o,e,n)}if(o.sizeBy){const e=r.map("function"==typeof o.sizeBy?o.sizeBy:e=>e?.[o.sizeBy]).filter(e=>null!=e&&isFinite(e));e.length>0&&(s=ve(e))}return e=>({fill:t&&i?ge(e,t,i):de,fillOpacity:o.fillOpacity,stroke:"#fff",strokeWidth:o.strokeWidth,r:o.sizeBy?be(e,o.sizeBy,o.sizeRange,s):o.pointRadius??6})}(i,t,n,{sizeBy:r.sizeBy,sizeRange:r.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),a=r.styleRules?Re(s,r.styleRules,_e(t,r.sizeBy)):s;return{points:i,xAccessor:r.xAccessor||"lon",yAccessor:r.yAccessor||"lat",areas:r.areas,areaStyle:r.areaStyle||yh,pointStyle:a,sizeBy:r.sizeBy,colorBy:t,colorScheme:n,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,...o}}},vh={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,n,o,r)=>{const i=(Array.isArray(e)?e:null)||r.flows||[],s=r.nodeIdAccessor||"id",a=r.valueAccessor||"value",c=r.xAccessor||"lon",l=r.yAccessor||"lat",u="function"==typeof c?c:e=>e[c],d="function"==typeof l?l:e=>e[l],h=(r.nodes||[]).map(e=>({...e,x:u(e),y:d(e)})),f=new Map;for(const e of h)f.set(e[s]+"",e);const p=r.edgeColorBy??t,y="function"==typeof p,g=i.map(e=>{if(!e||null==e.source||null==e.target)return null;const t=f.get(e.source+""),n=f.get(e.target+"");return t&&n?{...e,coordinates:[{x:t.x,y:t.y},{x:n.x,y:n.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=p?y?xe(g.map(e=>({[m]:p(e)})),m,n||"category10"):xe(g,p,n||"category10"):null,b=e=>p&&x?ge(e,p,x):"#007bff";let v=1/0,w=-1/0;for(const e of g){const t=Number(e[a]??0);isFinite(t)&&(v>t&&(v=t),t>w&&(w=t))}const k=w>v?w-v:0,[S,A]=r.edgeWidthRange??[1,8],M=A-S,_=r.edgeOpacity??.6,P=r.edgeLinecap??"round";return{lines:g,points:h,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:r.lineType||"geo",flowStyle:r.flowStyle||"basic",areas:r.areas,areaStyle:r.areaStyle||yh,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,colorScheme:n,lineStyle:e=>{const t=Number(e?.[a]),n=Number.isFinite(t)?t:v,o=S+Math.max(0,Math.min(1,k>0?(n-v)/k:0))*M;return{stroke:b(e),strokeWidth:o,strokeLinecap:P,opacity:_,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...o}}},wh=y(require("react"));function kh(e){const[t,n]=e,o=160>t||116>n,r=o?Math.min(12,Math.max(2,.08*t)):32,i=o?Math.min(8,Math.max(2,.12*n)):24,s=o?i:34;return{width:t,height:n,plot:{x:r,y:i,width:Math.max(1,t-2*r),height:Math.max(1,n-i-s)}}}function Sh(e){const t=(e??"")+"";if(!t)return"#4e79a7";const n=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let o=0;for(let e=0;t.length>e;e+=1)o=31*o+t.charCodeAt(e)>>>0;return n[o%n.length]}function Ah(e,t="#4e79a7",n){const o=n?.styleRules,r=!!o&&o.length>0,i=r?Ae(n?.valueAccessor):void 0;return n=>{const s=n.datum,a=s&&e?"function"==typeof e?e(s,0):s[e]:void 0,c={fill:null==a?t:Sh(a),stroke:"#111827",strokeWidth:1,opacity:.9};return r&&s&&Object.assign(c,Ce(s,o,{value:i?i(s):void 0,category:null==a?void 0:a+""})),c}}function Mh(e,t,n,o){return{fixedDt:1/120,maxSubsteps:8,colliders:t,observation:{chartType:n},kernel:{seed:e,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...o}}}function _h(e,t,n){return"function"==typeof n?n(e,t):e[n]}function Ph(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:null}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function jh(e,t,n){return Math.max(t,Math.min(n,e))}function Ch(e,t){const n=Ph(e);return null!=n&&n>0?n:t}function Rh(e){return((e??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function Lh(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}var Ih=require("d3-scale");function Th(e){let t=e>>>0;return function(){t=t+1831565813|0;let e=Math.imul(t^t>>>15,1|t);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}}var $h={seed:1,gravity:{x:0,y:980},fixedDt:1/120,cellSize:64,collisionIterations:6,velocityDamping:.995,sleepSpeed:8,sleepAfter:.35,restitution:.1,friction:.35,maxVelocity:1600,contactWakeSpeed:200},zh=1e-9,Dh=.005;function Eh(e){return"circle"===e.type?{type:"circle",radius:e.radius}:{type:"aabb",width:e.width,height:e.height}}function Oh(e){return"aabb"===e.type?{type:"aabb",x:e.x,y:e.y,width:e.width,height:e.height}:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:e.thickness}}function Fh(e,t,n){return Math.max(t,Math.min(n,e))}function Bh(e){return 0>e?-1:1}function Nh(e){if("circle"===e.shape.type){const t=e.shape.radius;return{minX:e.x-t,minY:e.y-t,maxX:e.x+t,maxY:e.y+t}}const t=e.shape.width/2,n=e.shape.height/2;return{minX:e.x-t,minY:e.y-n,maxX:e.x+t,maxY:e.y+n}}function Wh(e){const t=e.shape;if("aabb"===t.type){const e=t.width/2,n=t.height/2;return{minX:t.x-e,minY:t.y-n,maxX:t.x+e,maxY:t.y+n}}const n=(t.thickness??0)/2;return{minX:Math.min(t.x1,t.x2)-n,minY:Math.min(t.y1,t.y2)-n,maxX:Math.max(t.x1,t.x2)+n,maxY:Math.max(t.y1,t.y2)+n}}function qh(e,t){return!(e.minX>t.maxX||t.minX>e.maxX||e.minY>t.maxY||t.minY>e.maxY)}function Yh(e,t,n,o,r,i,s,a){const c=r-e,l=(n+s)/2-Math.abs(c);if(0>=l)return null;const u=i-t,d=(o+a)/2-Math.abs(u);return d>0?d>l?{nx:Bh(c),ny:0,penetration:l}:{nx:0,ny:Bh(u),penetration:d}:null}function Gh(e,t,n,o,r,i,s){const a=i/2,c=s/2;let l=e-Fh(e,o-a,o+a),u=t-Fh(t,r-c,r+c);const d=l*l+u*u;if(d>n*n)return null;if(zh>=d){const i=Math.abs(e-(o-a)),s=Math.abs(e-(o+a)),d=Math.abs(t-(r-c)),h=Math.abs(t-(r+c)),f=Math.min(i,s,d,h);return f===i?(l=-1,u=0,{nx:l,ny:u,penetration:n+i}):f===s?(l=1,u=0,{nx:l,ny:u,penetration:n+s}):f===d?(l=0,u=-1,{nx:l,ny:u,penetration:n+d}):(l=0,u=1,{nx:l,ny:u,penetration:n+h})}const h=Math.sqrt(d);return{nx:l/h,ny:u/h,penetration:n-h}}function Hh(e,t){if("circle"===e.shape.type&&"circle"===t.shape.type)return function(e,t,n,o,r,i){const s=o-e,a=r-t,c=n+i,l=s*s+a*a;if(l>=c*c)return null;if(zh>=l)return{nx:1,ny:0,penetration:c};const u=Math.sqrt(l);return{nx:s/u,ny:a/u,penetration:c-u}}(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.radius);if("aabb"===e.shape.type&&"aabb"===t.shape.type)return Yh(e.x,e.y,e.shape.width,e.shape.height,t.x,t.y,t.shape.width,t.shape.height);if("circle"===e.shape.type&&"aabb"===t.shape.type){const n=Gh(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height);return n?{nx:-n.nx,ny:-n.ny,penetration:n.penetration}:null}return"aabb"===e.shape.type&&"circle"===t.shape.type?Gh(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height):null}function Vh(e,t){const n=t.shape;return"aabb"===n.type?"circle"===e.shape.type?Gh(e.x,e.y,e.shape.radius,n.x,n.y,n.width,n.height):Yh(n.x,n.y,n.width,n.height,e.x,e.y,e.shape.width,e.shape.height):function(e,t,n,o,r,i,s,a=0){const c=i-o,l=s-r,u=c*c+l*l,d=u>zh?Fh(((e-o)*c+(t-r)*l)/u,0,1):0,h=n+a/2,f=e-(o+c*d),p=t-(r+l*d),y=f*f+p*p;if(y>=h*h)return null;if(zh>=y){const e=Math.sqrt(u);return e>zh?{nx:-l/e,ny:c/e,penetration:h}:{nx:1,ny:0,penetration:h}}const g=Math.sqrt(y);return{nx:f/g,ny:p/g,penetration:h-g}}(e.x,e.y,"circle"===e.shape.type?e.shape.radius:Math.sqrt(e.shape.width*e.shape.width+e.shape.height*e.shape.height)/2,n.x1,n.y1,n.x2,n.y2,n.thickness??0)}function Xh(e,t){return`${e}\0${t}`}function Uh(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function Kh(e){return{id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,bodyCollisions:e.bodyCollisions,shape:Eh(e.shape),sleeping:e.sleeping,datum:e.datum,index:e.index,sleepTime:e.sleepTime,restitution:e.restitution,friction:e.friction}}function Zh(e){return e&&"function"!=typeof e?{property:e.property,equals:e.equals,notEquals:e.notEquals,oneOf:e.oneOf?.slice(),notOneOf:e.notOneOf?.slice()}:e}function Qh(e){return{id:e.id,shape:Oh(e.shape),sensor:e.sensor,restitution:e.restitution,friction:e.friction,bodyFilter:Zh(e.bodyFilter),index:e.index}}function Jh(e,t){return!!t?.some(t=>Object.is(e,t))}function ef(e,t){const n=e.bodyFilter;if(!n)return!0;if("function"==typeof n)return n(t);const o=function(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;n=n[e]}return n}(t,n.property);return!("equals"in n&&!Object.is(o,n.equals)||"notEquals"in n&&Object.is(o,n.notEquals)||n.oneOf&&!Jh(o,n.oneOf)||n.notOneOf&&Jh(o,n.notOneOf))}var tf=class{constructor(e={}){this.capabilities={determinism:"strict",sensors:!0,joints:!1,ccd:!1,maxBodiesHint:5e3,worker:!1},this.bodies=new Map,this.colliders=new Map,this.springs=new Map,this.activeSensors=new Set,this.supportedThisStep=new Set,this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0,this.options={...$h,...e},this.random=Th(this.options.seed)}init(e={}){this.options={...$h,...e},this.random=Th(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0}spawn(e){const t={id:e.id,x:e.x,y:e.y,prevX:e.x,prevY:e.y,vx:e.vx??0,vy:e.vy??0,angle:e.angle??0,mass:Math.max(zh,e.mass??1),bodyCollisions:e.bodyCollisions??!0,shape:Eh(e.shape),sleeping:!1,datum:e.datum,restitution:e.restitution,friction:e.friction,index:this.nextBodyIndex,sleepTime:0};this.nextBodyIndex+=1,this.bodies.set(e.id,t)}remove(e){for(const t of e){this.bodies.delete(t);for(const e of Array.from(this.activeSensors))Uh(e).bodyId===t&&this.activeSensors.delete(e)}}setColliders(e){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(const t of e)this.colliders.set(t.id,{...t,shape:Oh(t.shape),bodyFilter:Zh(t.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(e){const t=e.id??"spring-"+this.nextSpringIndex;return this.springs.set(t,{id:t,bodyId:e.bodyId,target:e.target,restLength:e.restLength??0,stiffness:e.stiffness??40,damping:e.damping??3}),this.nextSpringIndex+=1,t}removeConstraint(e){this.springs.delete(e)}applyImpulse(e,t,n){const o=this.bodies.get(e);o&&(o.vx+=t/o.mass,o.vy+=n/o.mass,this.wake(o))}step(e=this.options.fixedDt){const t=Math.max(0,e);if(this.lastEvents=[],0===t)return;const n=this.sortedBodies();for(const e of n)e.prevX=e.x,e.prevY=e.y;this.applySprings(t);const o=this.options.maxVelocity;for(const e of n)if(!e.sleeping){if(e.vx+=this.options.gravity.x*t,e.vy+=this.options.gravity.y*t,e.vx*=this.options.velocityDamping,e.vy*=this.options.velocityDamping,o>0){const t=Math.sqrt(e.vx*e.vx+e.vy*e.vy);if(t>o){const n=o/t;e.vx*=n,e.vy*=n}}e.x+=e.vx*t,e.y+=e.vy*t}this.supportedThisStep.clear();const r=this.bodyPairKeys(n),i=this.sortedColliders().filter(e=>!e.sensor);for(let e=0;this.options.collisionIterations>e;e+=1)this.resolveBodyPairs(n,r,0===e),this.resolveColliders(n,i,0===e);this.updateSensors(n),this.updateSleeping(n,t)}settle(e=1200,t=this.options.fixedDt){let n=0;for(;e>n&&!this.allSleeping();)this.step(t),n+=1;return n}readState(e=[]){e.length=0;for(const t of this.sortedBodies())e.push({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,shape:Eh(t.shape),sleeping:t.sleeping,datum:t.datum});return e}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(Uh)}allSleeping(){for(const e of this.bodies.values())if(!e.sleeping)return!1;return!0}snapshot(){return{options:{...this.options,gravity:{...this.options.gravity}},bodies:this.sortedBodies().map(Kh),colliders:this.sortedColliders().map(Qh),springs:Array.from(this.springs.values()).map(e=>({...e,target:{...e.target}})),activeSensors:Array.from(this.activeSensors).sort()}}restore(e){this.options={...e.options,gravity:{...e.options.gravity}},this.random=Th(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(e.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(const t of e.bodies){const e=Kh(t);this.bodies.set(e.id,e),this.nextBodyIndex=Math.max(this.nextBodyIndex,e.index+1)}this.nextColliderIndex=0;for(const t of e.colliders){const e=Qh(t);this.colliders.set(e.id,e),this.nextColliderIndex=Math.max(this.nextColliderIndex,e.index+1)}this.nextSpringIndex=0;for(const t of e.springs){this.springs.set(t.id,{...t,target:{...t.target}});const e=/^spring-(\d+)$/.exec(t.id);e&&(this.nextSpringIndex=Math.max(this.nextSpringIndex,Number(e[1])+1))}}dispose(){this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[]}sortedBodies(){return Array.from(this.bodies.values()).sort((e,t)=>e.index-t.index)}sortedColliders(){return Array.from(this.colliders.values()).sort((e,t)=>e.index-t.index)}applySprings(e){for(const t of Array.from(this.springs.values()).sort((e,t)=>e.id.localeCompare(t.id))){const n=this.bodies.get(t.bodyId);if(!n||n.sleeping)continue;const o="point"===t.target.type?t.target:this.bodies.get(t.target.bodyId);if(!o)continue;const r=o.x-n.x,i=o.y-n.y,s=Math.sqrt(r*r+i*i);if(zh>=s)continue;const a=r/s,c=i/s,l=(s-t.restLength)*t.stiffness+((("vx"in o?o.vx:0)-n.vx)*a+(("vy"in o?o.vy:0)-n.vy)*c)*t.damping;n.vx+=l*a*e/n.mass,n.vy+=l*c*e/n.mass}}resolveBodyPairs(e,t,n){for(const o of t){const[t,r]=o.split(":").map(Number),i=e[t],s=e[r];if(!i||!s)continue;const a=Hh(i,s);a&&(this.resolveDynamicCollision(i,s,a),n&&this.lastEvents.push({type:"contact",bodyId:i.id,otherId:s.id,sensor:!1}))}}bodyPairKeys(e){const t=Math.max(1,this.options.cellSize),n=new Map;for(let o=0;e.length>o;o+=1){if(!1===e[o].bodyCollisions)continue;const r=Nh(e[o]),i=Math.floor(r.minX/t),s=Math.floor(r.maxX/t),a=Math.floor(r.minY/t),c=Math.floor(r.maxY/t);for(let e=i;s>=e;e+=1)for(let t=a;c>=t;t+=1){const r=`${e}:${t}`,i=n.get(r);i?i.push(o):n.set(r,[o])}}const o=new Set;for(const t of Array.from(n.keys()).sort()){const r=n.get(t)??[];r.sort((e,t)=>e-t);for(let t=0;r.length>t;t+=1)for(let n=t+1;r.length>n;n+=1){const i=r[t],s=r[n];!1!==e[i].bodyCollisions&&!1!==e[s].bodyCollisions&&qh(Nh(e[i]),Nh(e[s]))&&o.add(`${i}:${s}`)}}return Array.from(o).sort((e,t)=>{const[n,o]=e.split(":").map(Number),[r,i]=t.split(":").map(Number);return n===r?o-i:n-r})}resolveDynamicCollision(e,t,n){e.sleeping&&this.contactOpposesGravity(n.nx,n.ny)&&this.supportedThisStep.add(t.id),t.sleeping&&this.contactOpposesGravity(-n.nx,-n.ny)&&this.supportedThisStep.add(e.id);const o=e.sleeping?0:1/e.mass,r=t.sleeping?0:1/t.mass,i=o+r;if(zh>=i)return;const s=Math.max(0,n.penetration-Dh)/i;e.x-=n.nx*s*o,e.y-=n.ny*s*o,t.x+=n.nx*s*r,t.y+=n.ny*s*r;const a=(t.vx-e.vx)*n.nx+(t.vy-e.vy)*n.ny;if(a>0)return;const c=Math.abs(a),l=-(1+Math.min(e.restitution??this.options.restitution,t.restitution??this.options.restitution))*a/i,u=l*n.nx,d=l*n.ny;e.vx-=u*o,e.vy-=d*o,t.vx+=u*r,t.vy+=d*r,this.applyFriction(e,t,n,l,o,r),c>this.options.contactWakeSpeed&&(this.wake(e),this.wake(t))}applyFriction(e,t,n,o,r,i){const s=-n.ny,a=n.nx,c=(t.vx-e.vx)*s+(t.vy-e.vy)*a,l=r+i;if(zh>=Math.abs(c)||zh>=l)return;const u=Math.max(0,Math.min(1,Math.max(e.friction??this.options.friction,t.friction??this.options.friction))),d=Fh(-c/l,-o*u,o*u),h=d*s,f=d*a;e.vx-=h*r,e.vy-=f*r,t.vx+=h*i,t.vy+=f*i}resolveColliders(e,t,n){for(const o of e)for(const e of t){if(!ef(e,o))continue;if(!qh(Nh(o),Wh(e)))continue;const t=Vh(o,e);t&&(this.resolveStaticCollision(o,e,t),this.contactOpposesGravity(t.nx,t.ny)&&this.supportedThisStep.add(o.id),n&&this.lastEvents.push({type:"contact",bodyId:o.id,otherId:e.id,sensor:!1}))}}resolveStaticCollision(e,t,n){e.x+=n.nx*Math.max(0,n.penetration-Dh),e.y+=n.ny*Math.max(0,n.penetration-Dh);const o=e.vx*n.nx+e.vy*n.ny;if(0>o){const r=Math.min(e.restitution??this.options.restitution,t.restitution??this.options.restitution);e.vx-=(1+r)*o*n.nx,e.vy-=(1+r)*o*n.ny;const i=-n.ny,s=n.nx,a=e.vx*i+e.vy*s,c=Math.max(0,Math.min(1,Math.max(e.friction??this.options.friction,t.friction??this.options.friction)));e.vx-=a*i*c,e.vy-=a*s*c}}updateSensors(e){const t=new Set,n=this.sortedColliders().filter(e=>e.sensor);for(const o of e){const e=Nh(o);for(const r of n){if(!ef(r,o))continue;if(!qh(e,Wh(r)))continue;if(!Vh(o,r))continue;const n=Xh(r.id,o.id);t.add(n),this.activeSensors.has(n)||this.lastEvents.push({type:"sensor-enter",bodyId:o.id,sensorId:r.id})}}for(const e of Array.from(this.activeSensors).sort()){if(t.has(e))continue;const{sensorId:n,bodyId:o}=Uh(e);this.lastEvents.push({type:"sensor-exit",bodyId:o,sensorId:n})}this.activeSensors=t}updateSleeping(e,t){const n=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const o of e)Math.sqrt(o.vx*o.vx+o.vy*o.vy)>=this.options.sleepSpeed||Math.sqrt((o.x-o.prevX)*(o.x-o.prevX)+(o.y-o.prevY)*(o.y-o.prevY))>=this.options.sleepSpeed*t||n&&!this.supportedThisStep.has(o.id)?o.sleeping?this.wake(o):o.sleepTime=0:(o.sleepTime+=t,o.sleeping||this.options.sleepAfter>o.sleepTime||(o.sleeping=!0,o.vx=0,o.vy=0,this.lastEvents.push({type:"sleep",bodyId:o.id})))}contactOpposesGravity(e,t){const{x:n,y:o}=this.options.gravity,r=Math.hypot(n,o);return 1e-9>=r||-.2>(e*n+t*o)/r}wake(e){e.sleeping&&this.lastEvents.push({type:"wake",bodyId:e.id}),e.sleeping=!1,e.sleepTime=0}nextRandom(){return this.random()}},nf=class{constructor(e={}){this.id="builtin",this.capabilities={...(new tf).capabilities,engine:"builtin"},this.world=new tf(e)}init(e={}){this.world.init(e)}spawn(e){this.world.spawn(e)}remove(e){this.world.remove(e)}setColliders(e){this.world.setColliders(e)}setConstraint(e){return this.world.setConstraint(e)}removeConstraint(e){this.world.removeConstraint(e)}applyImpulse(e,t,n){this.world.applyImpulse(e,t,n)}step(e){this.world.step(e)}settle(e,t){return this.world.settle(e,t)}readState(e){return this.world.readState(e)}events(){return this.world.events()}activeSensorPairs(){return this.world.activeSensorPairs()}allSleeping(){return this.world.allSleeping()}snapshot(){return this.world.snapshot()}restore(e){this.world.restore(e)}nextRandom(){return this.world.nextRandom()}dispose(){this.world.dispose()}};function of(e,t={}){return e?"function"==typeof e?e(t):(e.init(t),e):function(e={}){return new nf(e)}(t)}var rf=["binId","targetBin","category","windowIndex","lane","group"];function sf(e,t){if(!Number.isFinite(t))return;e.count+=1,e.total+=t,e.min=Math.min(e.min,t),e.max=Math.max(e.max,t);const n=t-e.mean;e.mean+=n/e.count,e.m2+=n*(t-e.mean)}function af(e){return{count:e.count,total:e.total,mean:e.count>0?e.mean:0,min:e.count>0?e.min:0,max:e.count>0?e.max:0,variance:e.count>1?e.m2/(e.count-1):0}}function cf(e){return{count:e.count,total:e.total,mean:e.mean,m2:e.variance*Math.max(0,e.count-1),min:e.count>0?e.min:1/0,max:e.count>0?e.max:-1/0}}function lf(e,t){if(null!=e[t])return e[t];const n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function uf(e,t,n){return"function"==typeof e?e(t,n):"string"==typeof e?lf(t,e):void 0}function df(e){if(null==e)return;const t=e+"";return t.trim()?t:void 0}function hf(e){const t=af(e.value);return{id:e.id,label:e.label,count:t.count,total:t.total,bodyIds:e.bodyIds.slice(),lastBodyId:e.lastBodyId,lastDatum:e.lastDatum,x:af(e.x),y:af(e.y),value:t}}var ff=class{constructor(e=!1){this.bins=new Map,this.nextIndex=0,this.config=e}updateConfig(e){void 0!==e&&(this.config=e,!1===e&&this.clear())}isEnabled(){return!1!==this.config}add(e){if(!1===this.config)return null;const t=this.nextIndex;this.nextIndex+=1;const n=df(uf(this.config.binAccessor,e,t))??function(e){for(const t of rf){const n=df(lf(e,t));if(n)return n}return"sediment"}(e),o=df(uf(this.config.labelAccessor,e,t))??n,r=function(e,t,n){if("number"==typeof e)return e;const o="function"==typeof e?e(t,n):"string"==typeof e?lf(t,e):1,r="number"==typeof o?o:Number(o);return Number.isFinite(r)?r:1}(this.config.valueAccessor,e,t),i=Math.max(0,Math.floor(this.config.retainBodyIds??12));let s=this.bins.get(n);return s||(s={id:n,label:o,bodyIds:[],x:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},y:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0},value:{count:0,total:0,mean:0,m2:0,min:1/0,max:-1/0}},this.bins.set(n,s)),s.label=o,s.lastBodyId=e.id,s.lastDatum=e.datum,sf(s.x,e.x),sf(s.y,e.y),sf(s.value,r),i>0&&(s.bodyIds.push(e.id),s.bodyIds.length>i&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-i))),hf(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(hf)}restore(e=[]){this.bins.clear();for(const t of e)this.bins.set(t.id,{id:t.id,label:t.label,bodyIds:t.bodyIds.slice(),lastBodyId:t.lastBodyId,lastDatum:t.lastDatum,x:cf(t.x),y:cf(t.y),value:cf(t.value)});this.nextIndex=e.reduce((e,t)=>e+t.count,0)}totals(){const e=this.snapshot();return{bins:e.length,count:e.reduce((e,t)=>e+t.count,0),total:e.reduce((e,t)=>e+t.total,0)}}};function pf(e){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}var yf={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},gf={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function mf(e={},t=gf){return{chartId:e.chartId??t.chartId,chartType:e.chartType??t.chartType,sensors:e.sensors??t.sensors,onObservation:e.onObservation??t.onObservation,onSimulationStateChange:e.onSimulationStateChange??t.onSimulationStateChange}}function xf(e){return{...e,shape:{...e.shape},datum:e.datum,springs:e.springs?.map(e=>({...e,target:{...e.target}}))}}function bf(e){if(e instanceof Date){const t=e.getTime();return Number.isFinite(t)?t:void 0}const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function vf(e,t){if(null!=e[t])return e[t];const n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function wf(e){return{...xf(e),sequence:e.sequence,spawnAt:e.spawnAt}}function kf(e){return e.map(e=>({...e,shape:{...e.shape},bodyFilter:e.bodyFilter&&"function"!=typeof e.bodyFilter?{...e.bodyFilter,oneOf:e.bodyFilter.oneOf?.slice(),notOneOf:e.bodyFilter.notOneOf?.slice()}:e.bodyFilter}))}function Sf(e){return!1!==e&&{...e}}function Af(e,t){return e.spawnAt===t.spawnAt?e.sequence-t.sequence:e.spawnAt-t.spawnAt}function Mf(e){return{...e,gravity:{...e.gravity}}}function _f(e,t,n,o){if("circle"===e.shape.type){const r=e.x-t,i=e.y-n,s=e.shape.radius+o,a=r*r+i*i;return a>s*s?null:a}const r=Math.max(Math.abs(t-e.x)-e.shape.width/2,0),i=Math.max(Math.abs(n-e.y)-e.shape.height/2,0),s=r*r+i*i;return s>o*o?null:s}function Pf(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function jf(e,t={}){const{idPrefix:n="plot",includeFloor:o=!0,includeCeiling:r=!1,includeLeftWall:i=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=t,l=[],u=e.x+e.width/2,d=e.y+e.height/2;return o&&l.push({id:n+"-floor",shape:{type:"aabb",x:u,y:e.y+e.height+c/2,width:e.width+2*a,height:c}}),r&&l.push({id:n+"-ceiling",shape:{type:"aabb",x:u,y:e.y-c/2,width:e.width+2*a,height:c}}),i&&l.push({id:n+"-left-wall",shape:{type:"aabb",x:e.x-a/2,y:d,width:a,height:e.height+2*c}}),s&&l.push({id:n+"-right-wall",shape:{type:"aabb",x:e.x+e.width+a/2,y:d,width:a,height:e.height+2*c}}),l}function Cf(e){const{idPrefix:t="bin",count:n,domainStart:o,domainStep:r,xScale:i,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=s,lidThickness:f=Math.max(2,c)}=e,p=[],y=s+(a-s)/2,g=Math.abs(a-s),m=l?n:n-1;if(u||l)for(let e=l?0:1;m>=e;e+=1){if(!u&&e>0&&n>e)continue;const s=i(o+e*r);p.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:s,y:y,width:c,height:g}})}if(null!=d)for(let e=0;n>e;e+=1){const n=o+e*r,s=n+r;if(s>=d)continue;const a=i(n),l=i(s);p.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:h,x2:Math.max(a,l)-c/2,y2:h,thickness:f}})}return p}var Rf=require("d3-quadtree"),Lf=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(e,t,n,o,r,i=0){const s=this.ensure(e,t);if(!s)return null;let a=null,c=1/0;const l=Math.max(0,i)+this.maxSearchRadius,u=o-l,d=o+l,h=r-l,f=r+l;return s.visit((e,t,s,l,p)=>{if(u>l||t>d||h>p||s>f)return!0;if(e.length)return!1;let y=e;for(;y;){const e=y.data;if(e){const t=_f(e,o,r,Math.max(0,i));null!=t&&(c>t||t===c&&n.indexOf(e.id)>n.indexOf(a?.id??""))&&(a=e,c=t)}y=y.next}return!1}),a}ensure(e,t){if(this.tree&&this.revision===t)return this.tree;const n=e.readState();return 0===n.length?(this.tree=null,this.maxSearchRadius=0,this.revision=t,null):(this.maxSearchRadius=n.reduce((e,t)=>Math.max(e,function(e){return"circle"===e.shape.type?e.shape.radius:Math.hypot(e.shape.width,e.shape.height)/2}(t)),0),this.tree=(0,Rf.quadtree)().x(e=>e.x).y(e=>e.y).addAll(n),this.revision=t,this.tree)}},If=["data","scene-geometry","data-paint","accessibility","evidence"],Tf=["scene-geometry","data-paint","accessibility","evidence"],$f=["overlay","accessibility","evidence"],zf=(e,t)=>({retainedData:e,invalidations:t}),Df=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ef=["scene-geometry","data-paint","accessibility","evidence"],Of=[],Ff={engine:zf("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:zf("preserve",Ef),colliders:zf("preserve",Ef),sediment:zf("preserve",Ef),bodyBudget:zf("preserve",Df),bodyLimit:zf("preserve",Df),eviction:zf("preserve",Df),fixedDt:zf("preserve",Of),maxDeltaSeconds:zf("preserve",Of),maxSubsteps:zf("preserve",Of),settleStepLimit:zf("preserve",Of),timeScale:zf("preserve",Of),observation:zf("preserve",Of)},Bf=zf("preserve",Df);function Nf(e){let t="preserve";const n=new Set;for(const o of e){const e=Ff[o]??Bf;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}var Wf=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function qf(e,t){return e===t||!(!e||!t)&&e.gravity?.x===t.gravity?.x&&e.gravity?.y===t.gravity?.y&&Wf.every(n=>e[n]===t[n])}function Yf(e,t,n,o){return e||!t?"paused":n||!o?"running":"settled"}var Gf=class{constructor(){this.seconds=0,this.speed=8,this.scratch=[]}setKernelOptions(e){this.speed=function(e){const t=e?.sleepSpeed;return"number"==typeof t&&Number.isFinite(t)&&t>0?t:8}(e)}reset(){this.seconds=0}isAtRest(){return this.seconds>=.6}refresh(e,t,n){if(n>0)return void(this.seconds=0);const o=e.readState(this.scratch),r=this.speed*this.speed;let i=!0;for(const e of o)if(!e.sleeping&&e.vx*e.vx+e.vy*e.vy>=r){i=!1;break}this.seconds=i?this.seconds+Math.max(0,t):0}},Hf=class{constructor(e={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new Lf,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new Wn,this.simulationState="settled",this.visible=!0,this.quiescence=new Gf;const{bodyBudget:t,colliders:n,engine:o,kernel:r,observation:i,sediment:s,...a}=e;this.config={...yf,...a},this.configInput={...e},this.bodyBudget=t??{},this.engineInput=o,this.observation=mf(i),this.sediment=new ff(s??!1),this.world=of(o,{fixedDt:this.config.fixedDt,...r}),this.quiescence.setKernelOptions(r),n&&this.world.setColliders(kf(n))}updateConfig(e){const t=function(e,t){return Object.keys(e).filter(n=>"kernel"===n?!qf(e.kernel,t.kernel):e[n]!==t[n])}(e,this.configInput),{colliders:n,bodyBudget:o,engine:r,kernel:i,observation:s,sediment:a,...c}=e;if(this.config={...this.config,...c},void 0!==o&&(this.bodyBudget=o,!1===o&&(this.bodyBudgetObservationKey="ok")),r&&r!==this.engineInput){const e=this.world.snapshot();this.world.dispose(),this.engineInput=r,this.world=of(r,e.options),this.world.restore(e),this.revision+=1}if(i&&!qf(i,this.configInput.kernel)){const e=this.world.snapshot(),t={...e.options,...i,gravity:{...e.options.gravity,...i.gravity}};this.world.restore({...e,options:t}),this.quiescence.setKernelOptions(t),this.revision+=1}s&&(this.observation=mf(s,this.observation)),this.sediment.updateConfig(a),n&&(this.world.setColliders(kf(n)),this.revision+=1),this.configInput={...this.configInput,...e};const l=Nf(t);this.updateResults.record({kind:"config",keys:t},l.invalidations)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setColliders(e){this.world.setColliders(kf(e)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},Nf(["colliders"]).invalidations)}enqueue(e,t){const n=Array.isArray(e)?e:[e],o=t?function(e,t={}){const n=bf(t.startAt)??0,o=t.pacing??"immediate";if("arrival"===o){const o=e.map((e,n)=>function(e,t,n){return"function"==typeof n?bf(n(e,t)):"string"==typeof n?bf(vf(e,n)):bf(e.spawnAt)??bf(vf(e,"arrivalTime"))??bf(vf(e,"timestamp"))??bf(vf(e,"time"))??bf(vf(e,"eventTime"))}(e,n,t.timeAccessor)),r=o.filter(e=>null!=e),i=r.length>0?Math.min(...r):0,s=bf(t.timeScale)??1,a=s>0?s:1;return e.map((e,t)=>{const r=o[t],s=null==r?0:Math.max(0,r-i);return{...xf(e),spawnAt:n+s/a}})}if("object"==typeof o){const t=bf(o.ratePerSec);if(t&&t>0)return e.map((e,o)=>({...xf(e),spawnAt:n+o/t}))}return e.map(e=>({...xf(e),spawnAt:n}))}(n,{...t,startAt:t.startAt??this.elapsedSeconds}):n;for(const e of o)this.queue.push({...xf(e),sequence:this.nextSequence,spawnAt:e.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(Af),o.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:o.length},o.length?If:[])}enqueueWithResult(e,t){return this.enqueue(e,t),this.updateResults.last}spawnNow(e){this.spawnOne(xf(e)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},If)}materializeDueSpawns(){const e=this.revision,t=[],n=[];return this.spawnDue(t,n),0===t.length||(this.observeBodyBudget(n),this.evictOverflow(n),this.syncSimulationState(n),this.revision+=1,this.updateResults.record({kind:"enqueue",count:t.length},this.revision!==e?If:[])),t}clear(){const e=this.world.snapshot().options;this.world.init({...e,fixedDt:this.config.fixedDt}),this.activeSensorPairs.clear(),this.liveBodyOrder=[],this.queue=[],this.accumulator=0,this.elapsedSeconds=0,this.nextSequence=0,this.quiescence.reset(),this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},If)}tick(e){const t=this.revision,n=[],o=[],r=[],i=[],s=[];if(this.paused||!this.visible){const e=this.result(0,n,o,r,i,s,!1);return this.updateResults.record({kind:"tick",count:0},[]),e}const a=Math.max(0,Math.min(e,this.config.maxDeltaSeconds))*this.config.timeScale;this.elapsedSeconds+=a,this.spawnDue(n,s);const c=this.observeBodyBudget(s),l=this.evictOverflow(s);o.push(...l.evicted),r.push(...l.sedimented),this.syncSimulationState(s),this.accumulator+=a;let u=0;for(;this.accumulator>=this.config.fixedDt&&this.config.maxSubsteps>u;){this.world.step(this.config.fixedDt);const e=this.world.events();i.push(...e),this.observeKernelEvents(e,s),this.observeSensorTransitions(s),this.accumulator-=this.config.fixedDt,u+=1}u===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),this.quiescence.refresh(this.world,a,n.length),(u>0||n.length>0||o.length>0||r.length>0||i.length>0)&&(this.revision+=1);const d=this.result(u,n,o,r,i,s,void 0,c);return this.updateResults.record({kind:"tick",count:u},this.revision!==t?n.length||o.length||r.length?If:Tf:[]),d}settle(e=this.config.settleStepLimit){return this.runSettle(e,!1).steps}settleWithObservations(e=this.config.settleStepLimit){return this.runSettle(e,!0)}settleHost(){return{fixedDt:this.config.fixedDt,queueSize:()=>this.queue.length,atRest:()=>this.atRest(),advanceTime:e=>{this.elapsedSeconds+=e},spawnDue:(e,t)=>this.spawnDue(e,t),observeBodyBudget:e=>this.observeBodyBudget(e),evictOverflow:e=>this.evictOverflow(e),step:e=>this.world.step(e),drainEvents:()=>this.world.events(),observeKernelEvents:(e,t)=>this.observeKernelEvents(e,t),observeSensorTransitions:e=>this.observeSensorTransitions(e),refreshQuiescence:(e,t)=>this.quiescence.refresh(this.world,e,t)}}runSettle(e,t){const n=this.revision,o=[],r=[],i=[],s=[],a=t?[]:void 0;if(t&&(this.paused||!this.visible)){const e=this.result(0,o,r,i,s,a??[],!1);return this.updateResults.record({kind:"settle",count:0},[]),e}this.spawnDue(o,a);const c=this.observeBodyBudget(a),l=this.evictOverflow(a);r.push(...l.evicted),i.push(...l.sedimented),this.syncSimulationState(a),o.length>0&&this.quiescence.reset();const u=t?{spawned:o,evicted:r,sedimented:i,events:s,observations:a}:{spawned:o},{steps:d,budget:h}=function(e,t,n){let o,r=0;for(;t>r&&(e.queueSize()>0||!e.atRest());){e.advanceTime(e.fixedDt);const t=[];if(e.spawnDue(t,n.observations),t.length>0){n.spawned.push(...t),o=e.observeBodyBudget(n.observations);const r=e.evictOverflow(n.observations);n.evicted?.push(...r.evicted),n.sedimented?.push(...r.sedimented)}e.step(e.fixedDt);const i=e.drainEvents();n.events&&(n.events.push(...i),e.observeKernelEvents(i,n.observations),e.observeSensorTransitions(n.observations)),r+=1,e.refreshQuiescence(e.fixedDt,t.length)}return{steps:r,budget:o}}(this.settleHost(),e,u),f=o.length+r.length+i.length>0;(d>0||f||s.length>0)&&(this.revision+=1);const p=this.result(d,o,r,i,s,a??[],void 0,h??c);return this.updateResults.record({kind:"settle",count:d},this.revision===n?[]:f?If:Tf),p}readBodies(e=[]){return this.world.readState(e)}readSediment(){return this.sediment.snapshot()}bodyBudgetStatus(){return this.evaluateBodyBudget()}sedimentTotals(){return this.sediment.totals()}sedimentHeightfield(e={}){return function(e,t={}){const{baselineY:n=0,binWidth:o=24,gap:r=2,maxHeight:i=80,value:s="count",x:a}=t,c=Math.max(1,...e.map(e=>e[s]));return e.map((e,t)=>{const l=Math.max(0,e[s]/c*i),u=a?.(e,t)??t*(o+r);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:n-l,width:o,height:l,meanX:e.x.mean,meanY:e.y.mean}})}(this.readSediment(),e)}hitTest(e,t,n=0){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,e,t,n)}events(){return this.world.events()}allSleeping(){return this.world.allSleeping()}atRest(){return this.world.allSleeping()||this.quiescence.isAtRest()}hasPendingWork(){return this.queue.length>0||!this.atRest()}queueSize(){return this.queue.length}liveBodyCount(){return this.liveBodyOrder.length}elapsed(){return this.elapsedSeconds}recordObservation(e){const{timestamp:t,chartType:n,chartId:o,...r}=e,i={...r,timestamp:t??this.elapsedSeconds,chartType:n??this.observation.chartType,chartId:o??this.observation.chartId};return this.emitObservation(i),this.updateResults.record({kind:"update",count:1},["evidence"]),i}getLastUpdateResult(){return this.updateResults.last}getUpdateSnapshot(){return this.updateResults.last}subscribeUpdateResult(e){return this.updateResults.subscribe(e)}version(){return this.revision}setPaused(e){const t=this.paused!==e;this.paused=e,this.syncSimulationState(),this.updateResults.record({kind:"pause"},t?$f:[])}setVisible(e){const t=this.visible!==e;this.visible=e,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},t?$f:[])}remove(e){const t=new Set(e),n=new Set(this.liveBodyOrder),o=new Set(this.queue.map(e=>e.id));this.queue=this.queue.filter(e=>!t.has(e.id)),this.liveBodyOrder=this.liveBodyOrder.filter(e=>!t.has(e)),this.world.remove(e),this.removeActiveSensorPairsForBodies(t);const r=e.filter(e=>n.has(e)||o.has(e));return r.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:r,count:r.length},r.length?If:[]),r}setConstraint(e){const t=this.world.setConstraint(e);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},Tf),t}removeConstraint(e){this.world.removeConstraint(e),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},Tf)}applyImpulse(e,t,n){this.world.applyImpulse(e,t,n),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[e]},Tf)}nextRandom(){return this.world.nextRandom()}controls(){return e=this,{applyImpulse:(t,n,o)=>e.applyImpulse(t,n,o),clear:()=>e.clear(),hitTest:(t,n,o)=>e.hitTest(t,n,o),pause:()=>e.setPaused(!0),push:(t,n)=>e.enqueue(t,n),pushMany:(t,n)=>e.enqueue(t,n),bodyBudgetStatus:()=>e.bodyBudgetStatus(),readBodies:t=>e.readBodies(t),readSediment:()=>e.readSediment(),recordObservation:t=>e.recordObservation(t),remove:t=>e.remove(t),restore:t=>e.restore(t),resume:()=>e.setPaused(!1),settle:t=>e.settle(t),settleWithObservations:t=>e.settleWithObservations(t),snapshot:()=>e.snapshot(),sedimentHeightfield:t=>e.sedimentHeightfield(t),sedimentTotals:()=>e.sedimentTotals(),step:t=>e.tick(t)};var e}snapshot(){const e=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:Sf(this.bodyBudget),config:{...this.config,kernel:Mf(e.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(wf),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:e}}restore(e){this.config={bodyLimit:e.config.bodyLimit,eviction:e.config.eviction,fixedDt:e.config.fixedDt,maxDeltaSeconds:e.config.maxDeltaSeconds,maxSubsteps:e.config.maxSubsteps,settleStepLimit:e.config.settleStepLimit,timeScale:e.config.timeScale},this.configInput={...e.config,bodyBudget:Sf(e.bodyBudget??{}),kernel:Mf(e.world.options)},this.bodyBudget=Sf(e.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.quiescence.setKernelOptions(e.world.options),this.quiescence.reset(),this.activeSensorPairs=new Set(e.activeSensorPairs),this.accumulator=e.accumulator,this.elapsedSeconds=e.elapsedSeconds,this.paused=e.paused,this.queue=e.queue.map(wf).sort(Af),this.revision=e.revision,this.sediment.restore(e.sediment??[]),this.simulationState=e.simulationState??Yf(e.paused,e.visible,e.queue.length>0,e.world.bodies.every(e=>e.sleeping)),this.liveBodyOrder=e.liveBodyOrder.slice(),this.visible=e.visible,this.nextSequence=this.queue.reduce((e,t)=>Math.max(e,t.sequence),-1)+1,this.world.restore(e.world),this.updateResults.record({kind:"restore"},If)}spawnDue(e,t){for(;this.queue.length>0&&this.elapsedSeconds>=this.queue[0].spawnAt;){const n=this.queue.shift();if(!n)return;this.spawnOne(n,t),e.push(n.id)}}spawnOne(e,t){this.liveBodyOrder=this.liveBodyOrder.filter(t=>t!==e.id),this.removeActiveSensorPairsForBodies(new Set([e.id])),this.world.spawn(e),this.liveBodyOrder.push(e.id);for(const t of e.springs??[])this.world.setConstraint({...t,bodyId:e.id});const n=this.world.readState().find(t=>t.id===e.id);this.emitObservation({type:"physics-spawn",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:e.id,datum:n?.datum??e.datum,x:n?.x??e.x,y:n?.y??e.y},t)}result(e,t,n,o,r,i,s,a=this.evaluateBodyBudget()){this.syncSimulationState(i);const c=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:n,events:r,observations:i,queueSize:this.queue.length,revision:this.revision,shouldContinue:s??(this.queue.length>0||!this.atRest()),sleeping:c,sedimented:o,spawned:t,steps:e}}observeKernelEvents(e,t){!function(e,t,n){if(0===t.length)return;const o=new Map(e.readState().map(e=>[e.id,e]));for(const e of t){if("sleep"!==e.type)continue;const t=o.get(e.bodyId);n.emit({type:"physics-settle",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,bodyId:e.bodyId,datum:t?.datum,x:t?.x,y:t?.y})}}(this.world,e,this.observationContext(t))}observeSensorTransitions(e){this.activeSensorPairs=function(e,t,n){const o=new Set(e.activeSensorPairs().map(e=>`${e.sensorId}\0${e.bodyId}`));if(0===o.size&&0===t.size)return o;const r=new Map(e.readState().map(e=>[e.id,e])),i=(e,t)=>{const{sensorId:o,bodyId:i}=Pf(t),s=n.observation.sensors[o],a=r.get(i);n.emit({type:"enter"===e?s?.enterType??"physics-bin-enter":s?.exitType??"physics-bin-exit",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,bodyId:i,datum:a?.datum,x:a?.x,y:a?.y,sensorId:o,binId:s?.binId??o})};for(const e of Array.from(o).sort())t.has(e)||i("enter",e);for(const e of Array.from(t).sort())o.has(e)||i("exit",e);return o}(this.world,this.activeSensorPairs,this.observationContext(e))}removeActiveSensorPairsForBodies(e){!function(e,t){for(const n of e)t.has(Pf(n).bodyId)&&e.delete(n)}(this.activeSensorPairs,e)}observationContext(e){return{elapsedSeconds:this.elapsedSeconds,observation:this.observation,emit:t=>this.emitObservation(t,e)}}emitObservation(e,t){t?.push(e),this.observation.onObservation?.(e)}evaluateBodyBudget(){return function(e){const t=Math.max(0,Math.floor(e.liveBodies)),n=Math.max(0,Math.floor(e.queuedBodies??0)),o=t+n,r=pf(e.bodyLimit),i=pf(e.engineMaxBodiesHint),s=function(e,t,n){if(!1===n)return;const o=pf(n?.warnAt);return null!=o?o:null!=e?Math.max(1,Math.floor(.8*e)):null!=t?Math.max(1,Math.floor(.8*t)):void 0}(r,i,e.options),a=null==r?0:Math.max(0,t-r),c=a>0?"overflow":null==s||s>o?"ok":"warning";return{action:"overflow"!==c?"continue":e.sedimentEnabled?"sediment":e.evictionEnabled?"evict":"retain",bodyLimit:r,engineMaxBodiesHint:i,liveBodies:t,overflow:a,projectedBodies:o,queuedBodies:n,state:c,warnAt:s}}({bodyLimit:this.config.bodyLimit,engineMaxBodiesHint:this.world.capabilities.maxBodiesHint,evictionEnabled:!1!==this.config.eviction,liveBodies:this.liveBodyOrder.length,queuedBodies:this.queue.length,sedimentEnabled:this.sediment.isEnabled(),options:this.bodyBudget})}observeBodyBudget(e){const t=this.evaluateBodyBudget();if("ok"===t.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",t;const n=`${t.state}:${t.action}`;return n===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=n,this.emitObservation({type:"overflow"===t.state?"physics-budget-overflow":"physics-budget-warning",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,budgetAction:t.action,bodyLimit:t.bodyLimit,engineMaxBodiesHint:t.engineMaxBodiesHint,liveBodies:t.liveBodies,overflow:t.overflow,projectedBodies:t.projectedBodies,queuedBodies:t.queuedBodies,warnAt:t.warnAt},e)),t}syncSimulationState(e){const t=Yf(this.paused,this.visible,this.queue.length>0,this.atRest());if(t===this.simulationState)return;const n=this.simulationState;this.simulationState=t,function(e,t,n){n.observation.onSimulationStateChange?.(t,e),"running"!==t&&"settled"!==t||n.emit({type:"running"===t?"sim-active":"sim-idle",timestamp:n.elapsedSeconds,chartType:n.observation.chartType,chartId:n.observation.chartId,simulationState:t,previousSimulationState:e})}(n,t,this.observationContext(e))}evictOverflow(e){const{evicted:t,sedimented:n,liveBodyOrder:o}=function(e,t,n,o,r,i){const s={evicted:[],sedimented:[],liveBodyOrder:r};if(!1===n)return s;const a=Math.max(0,Math.floor(o));if(!Number.isFinite(a))return s;const c=r.length-a;if(0>=c)return s;const l=function(e,t,n){if("sleeping-first"!==t)return n.slice();const o=new Map(e.readState().map(e=>[e.id,e.sleeping])),r=[],i=[];for(const e of n)o.get(e)?r.push(e):i.push(e);return[...r,...i]}(e,n,r),u=l.slice(0,c);if(0===u.length)return s;const d=function(e,t,n,o){const r=new Map(e.readState().map(e=>[e.id,e])),i=[];for(const e of n){const n=r.get(e);if(!n)continue;const s=t.add(n);s&&(i.push(e),o.emit({type:"physics-sediment",timestamp:o.elapsedSeconds,chartType:o.observation.chartType,chartId:o.observation.chartId,bodyId:e,datum:n.datum,x:n.x,y:n.y,binId:s.id,count:s.count,total:s.total}))}return i}(e,t,u,i);e.remove(u);const h=new Set(u);return{evicted:u,sedimented:d,liveBodyOrder:r.filter(e=>!h.has(e))}}(this.world,this.sediment,this.config.eviction,this.config.bodyLimit,this.liveBodyOrder,this.observationContext(e));return t.length>0&&(this.liveBodyOrder=o,this.removeActiveSensorPairsForBodies(new Set(t))),{evicted:t,sedimented:n}}};var Vf=require("d3-scale");function Xf(e){const{count:t,idPrefix:n,wallThickness:o,xScale:r,yBottom:i,yTop:s,yTopForIndex:a}=e;return Array.from({length:t+1},(e,t)=>{const c=Math.min(i-1,a?.(t)??s),l=Math.max(1,i-c);return{id:`${n}-wall-${t}`,shape:{type:"aabb",x:r(t),y:c+l/2,width:o,height:l}}})}var Uf=require("d3-scale");function Kf(e){if(Array.isArray(e)&&e.length>=2){const t=Ph(e[0]),n=Ph(e[1]);return null!=t&&null!=n?{x:t,y:n}:null}if(e&&"object"==typeof e){const t=e,n=Ph(t.x),o=Ph(t.y);return null!=n&&null!=o?{x:n,y:o}:null}return null}function Zf(e){return Array.isArray(e)?e.map(Kf).filter(e=>null!=e):[]}function Qf(e,t,n){return"normalized"===n?{x:t.plot.x+e.x*t.plot.width,y:t.plot.y+e.y*t.plot.height}:{x:jh(e.x,t.plot.x,t.plot.x+t.plot.width),y:jh(e.y,t.plot.y,t.plot.y+t.plot.height)}}function Jf(e){let t=0;for(let n=1;e.length>n;n+=1)t+=Math.hypot(e[n].x-e[n-1].x,e[n].y-e[n-1].y);return t}function ep(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};const n=jh(t,0,1)*Jf(e);let o=0;for(let t=1;e.length>t;t+=1){const r=e[t-1],i=e[t],s=Math.hypot(i.x-r.x,i.y-r.y);if(s>0){if(o+s>=n){const e=(n-o)/s;return{x:r.x+(i.x-r.x)*e,y:r.y+(i.y-r.y)*e}}o+=s}}return{...e[e.length-1]}}function tp(e,t){const n=ep(e,Math.max(0,t-.02)),o=ep(e,Math.min(1,t+.02)),r=o.x-n.x,i=o.y-n.y,s=Math.hypot(r,i)||1;return{x:r/s,y:i/s}}function np(e,t,n){return Math.max(t,Math.min(n,e))}function op(e,t,n,o,r,i={}){return{id:e,friction:i.friction,restitution:i.restitution,bodyFilter:i.bodyFilter,shape:{type:"segment",x1:t,y1:n,x2:o,y2:r,thickness:i.thickness??8}}}function rp(e){return{id:e.id,label:e.label,description:e.description,kind:e.kind,shape:(t=e.x,n=e.y,o=e.width,r=e.height,{type:"aabb",x:t,y:n,width:o,height:r}),bodyFilter:e.bodyFilter,collider:e.collider,colliderThickness:e.colliderThickness,friction:e.friction,restitution:e.restitution,semanticItem:e.semanticItem,metadata:e.metadata,bodyStyle:e.bodyStyle,attributes:e.attributes,onEnter:e.onEnter,onExit:e.onExit};var t,n,o,r}function ip(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...rp({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function sp(e,t=12){return"number"==typeof e?{x:e,y:0}:e&&"object"==typeof e?{x:Number.isFinite(e.x)?Number(e.x):t,y:Number.isFinite(e.y)?Number(e.y):0}:{x:t,y:0}}function ap(e){const t=e.stages;if(!t.length)throw Error("buildProcessFlowPhysics requires at least one stage");const n=e.size,o=kh(n),r=jh(e.ballRadius??6,2,18),i=e.seed??1,s=Lh(i),a=e.idAccessor,c=e.stageAccessor??"stage",l=e.groupBy,u=e.groupLabelAccessor,d=e.workAccessor,h=e.radiusAccessor,f=e.groupCompletion??(l?"allAbsorbed":"none"),p=e.springStiffness??.28,y=e.springDamping??.72,g=!0===e.settle,m=t.map(e=>({id:e.id,label:e.label??e.id,description:e.description,share:e.share})),x=function(e){const t=e.shape??"lane",n=Math.max(1,Math.round(e.width)),o=Math.max(1,Math.round(e.height)),r=e.padX??46,i=e.padY??72,s=r,a=n-r,c=i,l=o-Math.max(24,Math.round(.45*i)),u=(c+l)/2,d=Math.max(1,l-c),h=np(e.pinchRatio??.18,.06,.5),f=Number(e.pinchHeightOffset??0),p=Number.isFinite(f)?f:0,y=np(d*h+p,.06*d,.5*d),g=y/2,m=u-g,x=u+g,b=e.idPrefix??"process",v=e.friction??.58,w=e.restitution??.18,k=e.wallThickness??8,S=e.stages;if(!S.length)throw Error("processStageLayout requires at least one stage");const A=np(e.centerStageIndex??Math.floor(S.length/2),0,S.length-1),M=function(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}(S),_=a-s;let P=s;const j=S.map((e,t)=>{const n=P,o=t===S.length-1?a:P+(e.share??1)/M*_;return P=o,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:n,x1:o,x:(n+o)/2,width:o-n,y:u,height:d}}),C=j[A],R=C.x0,L=C.x1,I=(e,n)=>{if("lane"===t)return"top"===n?c:l;if("funnel"===t){const t=np((e-s)/Math.max(1,a-s),0,1);return"top"===n?c+(m-c)*t:l+(x-l)*t}if(R>=e){const t=np((e-s)/Math.max(1,R-s),0,1);return"top"===n?c+(m-c)*t:l+(x-l)*t}if(L>=e)return"top"===n?m:x;const o=np((e-L)/Math.max(1,a-L),0,1);return"top"===n?m+(c-m)*o:x+(l-x)*o},T=j.map(e=>{const t=Math.min(I(e.x0,"top"),I(e.x1,"top")),n=Math.max(I(e.x0,"bottom"),I(e.x1,"bottom"));return{...e,y:(t+n)/2,height:Math.max(1,n-t)}}),$={thickness:k,friction:v,restitution:w},z=[];"lane"===t?z.push(op(b+"-top",s,c,a,c,$),op(b+"-bottom",s,l,a,l,$),op(b+"-left",s,c,s,l,{...$,thickness:Math.max(6,k-2)}),op(b+"-right",a,c,a,l,{...$,thickness:Math.max(6,k)})):"funnel"===t?z.push(op(b+"-top",s,c,a,m,$),op(b+"-bottom",s,l,a,x,$),op(b+"-left",s,c,s,l,{...$,thickness:Math.max(6,k-2)}),op(b+"-right",a,m,a,x,{...$,thickness:Math.max(6,k)})):z.push(op(b+"-left-top",s,c,R,m,$),op(b+"-left-bottom",s,l,R,x,$),op(b+"-center-top",R,m,L,m,$),op(b+"-center-bottom",R,x,L,x,$),op(b+"-right-top",L,m,a,c,$),op(b+"-right-bottom",L,x,a,l,$),op(b+"-left",s,c,s,l,{...$,thickness:Math.max(6,k-2)}),op(b+"-right",a,c,a,l,{...$,thickness:Math.max(6,k)}));const D=e.membraneDampingScale??.5,E=s,O=Math.max(1,("bowtie"===t?R:a)-E),F=(e.membranes??[]).map(e=>{const t=E+np(e.offset,0,1)*O,n=e.width??18+18*e.cost,o=d-16,r=u+.25*(e.wobble??0);return{...e,x:t,y:r,width:n,height:o}}),B=!1===e.includeMembraneRegions?[]:F.map(e=>function(e){const t=e.dampingScale??.5,n=e.energyScale??1,o=np(e.cost,0,2);return{...rp({...e,kind:e.kind??"membrane",attributes:{primitive:"membrane",membraneCost:o,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:o*t,energyDelta:-o*n}}({id:e.id,label:e.label??e.id,description:e.description??(e.label??e.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??D,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:n,height:o,padX:r,padY:i,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:R,centerRight:L,pinchHeight:y,pinchTop:m,pinchBottom:x,stages:T,membranes:F,colliders:z,regionEffects:B,boundaryY:I}}({width:n[0],height:n[1],shape:"lane",padX:Math.max(28,o.plot.x),padY:Math.max(36,o.plot.y+8),stages:m,idPrefix:"process-flow",includeMembraneRegions:!1,friction:.48,restitution:.14}),b=new Map(x.stages.map((e,t)=>[e.id,t])),v=new Map(x.stages.map(e=>[e.id,e])),w=x.stages[0].id,k=x.stages[0],S=new Set(t.filter(e=>e.absorb).map(e=>e.id)),A=t.map(e=>{const t=v.get(e.id)??k;return function(e,t){const n={id:"process-stage-"+e.id,label:e.label??e.id,description:e.description,x:t.x,y:t.y,width:Math.max(12,.92*t.width),height:Math.max(40,.88*t.height),semanticItem:!1,attributes:{stageId:e.id}};if(e.absorb)return function(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...rp({...e,kind:e.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.02,charge:e.charge??"absorbed"}}({...n,kind:e.kind??"sink",force:sp(e.force,28),damping:e.damping??.04,charge:"absorbed",attributes:{...n.attributes,primitive:"absorb"}});if(e.portal){const t=e.portal.force??e.force??{x:-40,y:0};return o={...n,kind:e.kind??"force-field",force:sp(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...n.attributes,primitive:"portal",targetStage:e.portal.targetStageId}},{...rp({...o,kind:o.kind??"force-field",attributes:{primitive:"portal",targetStage:o.targetStage,..."object"==typeof o.attributes&&o.attributes?o.attributes:{}}}),force:o.force,impulseOnEnter:o.impulseOnEnter,damping:o.damping??.08}}var o;if(e.capacity){const t=Math.max(.1,e.capacity.unitsPerSecond);return function(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...rp({...e,kind:e.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:e.capacity,unitsPerSecond:e.unitsPerSecond??e.capacity,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping,charge:e.charge??e.capacity}}({...n,kind:e.kind??"force-field",capacity:t,unitsPerSecond:t,force:sp(e.force,10+.8*t),damping:e.damping??Math.max(.04,.32-.01*t),attributes:{...n.attributes,unitAccessor:e.capacity.unitAccessor,reviewerCapacity:t}})}if(e.pressure){const t="object"==typeof e.pressure&&e.pressure?e.pressure:{};return function(e){const t=e.pressure??e.occupancy??0,n=e.baseDamping??.08,o=e.dampingPerUnit??.12,r=e.energyPerUnit??0;return{...rp({...e,kind:e.kind??"membrane",attributes:{primitive:"pressureField",pressure:t,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:n+t*o,energyDelta:r?-t*r:void 0,force:e.force}}({...n,kind:e.kind??"membrane",pressure:t.pressure,occupancy:t.occupancy,baseDamping:t.baseDamping??e.damping??.1,dampingPerUnit:t.dampingPerUnit??.1,energyPerUnit:t.energyPerUnit??0,force:sp(e.force,8),attributes:{...n.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?ip({...n,kind:e.kind??"force-field",force:sp(e.force,14),damping:e.damping??.02,attributes:{...n.attributes,primitive:"routeSurface"}}):function(e){return{...rp({...e,kind:e.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:e.force,damping:e.damping,energyDelta:e.energyDelta}}({...n,kind:e.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...n.attributes,primitive:"forceField"}})}(e,{x:t.x,y:x.midY,width:t.width,height:x.bottomY-x.topY})});A.unshift(ip({id:"process-flow-route",label:"process route",description:"Baseline conveyor along the process lane.",x:(x.left+x.right)/2,y:x.midY,width:x.right-x.left,height:x.bottomY-x.topY-12,force:8,damping:.012,semanticItem:!1}));const M=new Map;for(const e of x.stages)M.set(e.id,0);const _=[];e.data.forEach((e,t)=>{const n=(a?_h(e,t,a)??e.id??"process-flow-"+t:e.id??"process-flow-"+t)+"",o=(_h(e,t,c)??w)+"",i=b.has(o)?o:w;M.set(i,(M.get(i)??0)+1);const s=l?(_h(e,t,l)??"")+"":void 0,f=s&&u?(_h(e,t,u)??s)+"":s,p=d?Ph(_h(e,t,d))??1:1,y=h?Ph(_h(e,t,h)):null,g=jh(null!=y&&y>0?y:r,2,18);_.push({datum:e,id:n,stageId:i,groupId:s||void 0,groupLabel:f||void 0,work:p,radius:g,index:t})});const P=new Map,j=new Map;for(const e of _){if(!e.groupId)continue;const t=P.get(e.groupId)??[];t.push(e.id),P.set(e.groupId,t),e.groupLabel&&j.set(e.groupId,e.groupLabel)}const C=jh(e.groupAnchorAlong??.55,.15,.9),R=x.left+(x.right-x.left)*C,L=Array.from(P.keys()),I=L.map((e,n)=>{const o=P.get(e)??[],r=L.length>1?x.topY+28+n/Math.max(1,L.length-1)*(x.bottomY-x.topY-56):x.midY;return function(e){const t=e.x??e.anchor?.x??0,n=e.y??e.anchor?.y??0;return{id:e.id,label:e.label,description:e.description,group:e.group,bodyIds:e.bodyIds,datum:e.datum,state:e.state,x:t,y:n,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:n},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}({id:e,label:j.get(e)??e,bodyIds:o,anchor:{x:R,y:r},x:R,y:r,completion:"allAbsorbed"===f?{mode:"allMembersAbsorbed",targetZone:t.find(e=>e.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),T=function(e,t){const n=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],o=t.filter(e=>!n.has(e)),r=t.length-o.length,i=e.completion?.mode??"allMembersAbsorbed",s=e.completion?.valueByBodyId,a=e=>{const t=s?.[e];return Number.isFinite(t)&&Number(t)>=0?Number(t):1},c=t.reduce((e,t)=>e+a(t),0),l=t.reduce((e,t)=>e+(n.has(t)?a(t):0),0),u=e.completion?.threshold,d="threshold"===i?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:e.id,label:e.label??e.id,mode:i,complete:t.length>0&&("anyAbsorbed"===i?r>0:"threshold"===i?l>=(d??c):0===o.length),absorbed:r,total:t.length,absorbedValue:l,totalValue:c,threshold:d,missing:o}})}(I,_.filter(e=>S.has(e.stageId)).map(e=>e.id)),$=new Map(I.map(e=>[e.id,e])),z=_.map((e,t)=>{const n=v.get(e.stageId)??k,o=n.x+(s()-.5)*Math.min(24,.2*n.width),r=x.boundaryY(o,"top")+e.radius+10,i=x.boundaryY(o,"bottom")-e.radius-10,a=i>r?r+s()*Math.max(1,i-r):x.midY,c=g?o:x.left+18+t%7*4,l=g?a:x.midY+(s()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:o,y:a},restLength:.45*e.radius,stiffness:p,damping:y}];if(e.groupId){const t=$.get(e.groupId);t?.anchor&&!S.has(e.stageId)&&u.push({target:{type:"point",x:t.anchor.x,y:t.anchor.y},restLength:t.tether?.restLength??22,stiffness:t.tether?.stiffness??.05,damping:.8})}return{id:e.id,x:c,y:l,vx:g?0:40+40*s(),vy:g?0:20*(s()-.5),mass:1,shape:{type:"circle",radius:e.radius},spawnAt:g?0:.03*t,springs:u,datum:{...e.datum,id:e.id,stage:e.stageId,groupId:e.groupId,groupLabel:e.groupLabel,work:e.work,__processFlow:!0}}}),D={kernel:{seed:i,gravity:{x:e.gravityX??22,y:e.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:x.colliders,fixedDt:1/60,maxSubsteps:8},E=x.stages.map(e=>({label:e.label??e.id,value:M.get(e.id)??0})),O=t.map(e=>{const t=v.get(e.id)??k;return{id:e.id,label:e.label??e.id,x:t.x,width:t.width,count:M.get(e.id)??0,capacity:e.capacity?.unitsPerSecond,absorb:!0===e.absorb,portalTarget:e.portal?.targetStageId}});return{config:D,initialSpawns:z,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:E,metadata:{kind:"process-flow",plot:o.plot,volume:x,stages:O,groups:I,groupCompletion:T,regionEffects:A}}}var cp=require("d3-scale");function lp(e,t,n){return he(e,t,n)}function up(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&me(n,e)||"#4e79a7":t=>{if(n){const e=me(n,t);if(e)return e}let o=0;for(let e=0;t.length>e;e++)o=31*o+t.charCodeAt(e)|0;return e[Math.abs(o)%e.length]??"#4e79a7"}}function dp(e,t){const n=t.config??{},o=(t.sensors??[]).map(e=>({...e,sensor:!0})),r=[...t.colliders??[],...o],i=[...e.colliders??[],...n.colliders??[],...r];return{...e,...n,observation:{...e.observation,...n.observation},...i.length>0&&{colliders:i}}}function hp(e){const t=xp(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 fp(e,t,n,o){return n?"function"==typeof n?n(e,t):e[n]??o:o}function pp(e){return`gauntlet:${e}:core`}function yp(e,t){return`gauntlet:${e}:positive:${t}`}function gp(e,t,n){return`gauntlet:${e}:negative:${t}:${n}`}var mp={left:28,top:76,rightInset:30,thickness:8};function xp(e){const t=e.height??e.floorY+36;if(e.width>=220&&t>=160)return mp;const n=Math.max(1,Math.min(e.width,t)),o=Math.max(2,.04*e.width);return{left:o,top:Math.max(2,.08*t),rightInset:o,thickness:Math.max(1,Math.min(4,.04*n))}}function bp(e){return Math.max(.12,Math.min(1,e.width/500,(e.height??e.floorY+36)/260))}function vp(e,t,n,o){const r=xp(o),i=Math.max(2,n+2),s=r.top+r.thickness/2+i,a=o.floorY-i,c=(e,t,n)=>t>n?(t+n)/2:Math.max(t,Math.min(n,e));return{x:c(e,r.left+r.thickness/2+i,o.width-r.rightInset-r.thickness/2-i),y:c(t,s,a)}}function wp(e,t,n=1){const o=[...e].sort((e,t)=>e.localeCompare(t)),r=Math.max(0,o.indexOf(t));return{angle:.82*-Math.PI+(o.length>1?r/(o.length-1):.5)*Math.PI*.64,index:r,radius:(48+r%2*6)*n}}function kp(e,t,n){const o=e.activePositiveIds.reduce((e,n)=>e+(t.get(n)?.value??1),0),r=e.missingPositiveIds.length+e.poppedPositiveIds.length,i=e.negativeIds.reduce((e,t)=>e+(n.get(t)?.load??1),0);return Math.max(0,Math.min(100,75+3*o-8*i-1.2*e.delay-5*r))}function Sp(e){const t=function(e,t,n){const[o,r]=e,i=220>o||160>r,s=Math.round(.48*r),a=i?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*o,d=l>1?(.78*o-u)/(l-1):0,h=i?Math.max(Math.round(.12*o),.08*o+6):Math.max(Math.round(.14*o),110);return{crashY:a-(i?Math.min(n,Math.max(3,.22*r)):n),floorY:a,gates:c.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(u+t*d),width:e.width??Math.max(i?8:54,Math.round(.07*o))})),graveyardX:Math.round(o*(i?.72:.84)),graveyardY:a-4,height:r,routeY:s,socketX:Math.round(o*(i?.82:.92)),startX:h,width:o}}(e.size??[900,520],e.gates,e.crashOffset??30),n=e.positiveProperties??[],o=new Map(n.map(e=>[e.id,e])),r=new Map((e.negativeProperties??[]).map(e=>[e.id,e])),i={idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor},s=(e.data??[]).map((t,s)=>{const a=function(e,t,n,o,r){const i=fp(e,t,n.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",s=o.map(e=>e.id),a=[...fp(e,t,n.positiveAccessor,s)],c=[...fp(e,t,n.negativeAccessor,[])].filter(e=>r.has(e));return{id:i,activePositiveIds:a,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...fp(e,t,n.metricsAccessor,{})},missingPositiveIds:s.filter(e=>!a.includes(e)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(fp(e,t,n.startTimeAccessor,0))||0),stage:"project filed",viability:fp(e,t,n.initialViability,100)}}(t,s,i,n,r);return{...a,viability:e.viability?.(a,{negativeProperties:r,positiveProperties:o})??kp(a,o,r)}}),a=s.flatMap((n,i)=>{const s=function(e,t,n,o){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}}(n),i=o?.(e,t,n)??{};return{...r,...i,startY:i.startY??i.routeY??r.startY,socketY:i.socketY??i.routeY??r.socketY,graveyardY:i.graveyardY??r.graveyardY}}(n,i,t,e.projectPlacement);return function(e,t,n,o,r,i,s){const a=bp(n),c=Math.max(3,28*a),l=o.startX,u=o.startY+(o.startY===n.routeY?38*t*a:0),d=s?.(e,t,n,o)??{},h=d.x??l,f=d.y??u,p={__gauntlet:!0,kind:"gauntlet-core",projectId:e.id,sourceDatum:e.datum},y=[{...d,id:pp(e.id),x:h,y:f,vx:d.vx??42,vy:d.vy??0,mass:d.mass??7,bodyCollisions:d.bodyCollisions??!0,shape:d.shape??{type:"circle",radius:c},spawnAt:d.spawnAt??e.startedAt,datum:p}],g=vp(h,f,d.shape&&"radius"in d.shape&&Number(d.shape.radius)||c,n);y[0].x=g.x,y[0].y=g.y;for(const t of e.activePositiveIds){const o=r.get(t);if(!o)continue;const i=wp(e.activePositiveIds,t,a),s=o.radius??Math.max(2,10*a),c=vp(g.x+Math.cos(i.angle)*i.radius,g.y+Math.sin(i.angle)*i.radius,s,n);y.push({id:yp(e.id,t),x:c.x,y:c.y,vx:18*Math.cos(i.angle),vy:18*Math.sin(i.angle),mass:o.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:d.spawnAt??e.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:e.id,property:o,sourceDatum:e.datum},springs:!1===o.spring?[]:[{target:{type:"body",bodyId:pp(e.id)},stiffness:.56,damping:.9,restLength:Math.max(6,(52+i.index%2*4)*a),...o.spring??{}}]})}return e.negativeIds.forEach((t,o)=>{const r=i.get(t);r&&y.push(function(e,t,n,o,r,i,s){const a=bp(i),c=t.radius??Math.max(2,7.2*a),l=vp(o+(n%4*12-12)*a,r+(54+12*Math.floor(n/4))*a,c,i);return{id:gp(e.id,t.id,n),x:l.x,y:l.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:c},spawnAt:s,datum:{__gauntlet:!0,kind:"gauntlet-negative",projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:pp(e.id)},stiffness:.62,damping:.92,restLength:Math.max(6,(52+n%4*3)*a),...t.spring??{}}]}}(e,r,o,g.x,g.y,n,d.spawnAt??e.startedAt))}),y}(n,i,t,s,o,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:hp(t)}}}var Ap=1e-9;function Mp(e,t){return t>e?-1:e>t?1:0}function _p(e){return{...e}}function Pp(e){return e.map(e=>({...e,sourceIds:e.sourceIds?[...e.sourceIds]:void 0,productIds:e.productIds?[...e.productIds]:void 0,relationIds:e.relationIds?[...e.relationIds]:void 0,outletIds:e.outletIds?[...e.outletIds]:void 0}))}function jp(e){const t=Object.fromEntries(Object.entries(e.components).map(([e,t])=>[e,{...t,initialMetrics:_p(t.initialMetrics),metrics:_p(t.metrics),productIds:[...t.productIds],history:Pp(t.history)}])),n=Object.fromEntries(Object.entries(e.products).map(([e,t])=>[e,{...t,metrics:_p(t.metrics),sourceIds:[...t.sourceIds],history:Pp(t.history)}])),o=Object.fromEntries(Object.entries(e.relations).map(([e,t])=>[e,{...t,sourceIds:[...t.sourceIds],metrics:t.metrics?_p(t.metrics):void 0}]));return{...e,eventsApplied:[...e.eventsApplied],components:t,products:n,relations:o,input:{amount:e.input.amount,metrics:_p(e.input.metrics)},metrics:_p(e.metrics),loss:{amount:e.loss.amount,metrics:_p(e.loss.metrics)},history:Pp(e.history)}}function Cp(e,t,n,o,r){return{severity:e,code:t,message:n,path:o,ids:r?[...r]:void 0}}function Rp(e){const t=new Set,n=new Set;for(const o of e)t.has(o)&&n.add(o),t.add(o);return[...n].sort(Mp)}function Lp(e,t){return e?Object.entries(e).flatMap(([e,n])=>Number.isFinite(n)?[]:[Cp("error","invalid-metric",`Metric "${e}" must be a finite number.`,`${t}.${e}`)]):[]}function Ip(e,t){for(const[n,o]of Object.entries(t))e[n]=Number(e[n]??0)+o}function Tp(e,t,n="selector"){const o=[],r=Object.values(e.components),i=new Set(r.map(e=>e.id)),s=(t.ids??[]).filter(e=>!i.has(e));if(s.length&&o.push(Cp("error","unknown-component",`Selector references unknown component id${1===s.length?"":"s"}: ${s.join(", ")}.`,n+".ids",s)),void 0===t.count||Number.isInteger(t.count)&&t.count>=0||o.push(Cp("error","invalid-selector-count","Selector count must be a non-negative integer.",n+".count")),o.some(e=>"error"===e.severity))return{ids:[],diagnostics:o};const a=t.ids?new Set(t.ids):null,c=t.categories?new Set(t.categories):null,l=t.statuses?new Set(t.statuses):null,u=t.outletIds?new Set(t.outletIds):null;let d=r.filter(e=>!a||a.has(e.id)).filter(e=>!c||c.has(e.category)).filter(e=>!l||l.has(e.status)).filter(e=>!u||void 0!==e.outletId&&u.has(e.outletId)).map(e=>e.id).sort(Mp);return void 0!==t.count&&(d=d.slice(0,t.count)),d.length||o.push(Cp("warning","empty-selector","Selector matched no source components.",n)),{ids:d,diagnostics:o}}function $p(e,t,n={}){return{eventId:e.event.id,effectType:t.type,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,label:e.event.label,summary:e.event.summary,...n}}function zp(e,t){const n={...t,eventId:e.event.id};e.materializations.push(n),e.observations.push({...n,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt})}function Dp(e,t,n){return!(void 0!==t&&!e.outletIds.has(t)&&(e.diagnostics.push(Cp("error","unknown-outlet",`Unknown outlet "${t}".`,n,[t])),1))}function Ep(e,t,n){const o=Rp(t);t.length||e.diagnostics.push(Cp("error","empty-source-list","A product requires at least one source component.",n)),o.length&&e.diagnostics.push(Cp("error","duplicate-source",`Source ids may appear only once: ${o.join(", ")}.`,n,o));const r=t.filter(t=>!e.state.components[t]);r.length&&e.diagnostics.push(Cp("error","unknown-component",`Unknown source component id${1===r.length?"":"s"}: ${r.join(", ")}.`,n,r));const i=t.filter(t=>(e.state.components[t]?.productIds.length??0)>0);i.length&&e.diagnostics.push(Cp("error","source-already-assigned",`Source component${1===i.length?" is":"s are"} already assigned: ${i.join(", ")}.`,n,i));const s=t.filter(t=>"consumed"===e.state.components[t]?.status&&!i.includes(t));return s.length&&e.diagnostics.push(Cp("error","source-unavailable",`Consumed source component${1===s.length?" is":"s are"} unavailable: ${s.join(", ")}.`,n,s)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}function Op(e,t,n,o,r){const i=o?.amount??0;(!Number.isFinite(i)||0>i||i>t+Ap)&&e.diagnostics.push(Cp("error","invalid-loss","Loss amount must be finite, non-negative, and no greater than its sources.",r+".amount")),e.diagnostics.push(...Lp(o?.metrics,r+".metrics"));for(const[t,i]of Object.entries(o?.metrics??{}))(0>i||i>Number(n[t]??0)+Ap)&&e.diagnostics.push(Cp("error","invalid-metric-loss",`Metric loss "${t}" must be non-negative and no greater than its sources.`,`${r}.metrics.${t}`));return!e.diagnostics.some(e=>"error"===e.severity)}function Fp(e,t,n,o,r,i,s){return{id:e.id,label:e.label??e.id,description:e.description,category:e.category??"product",color:e.color,order:e.order,declaredAmount:e.amount,amount:i&&void 0!==e.amount?e.amount:n,metrics:i&&e.metrics?{...o,...e.metrics}:o,status:i?"complete":"forming",sourceIds:[...t],outletId:i?e.outletId??(r.outletIds.has("product")?"product":void 0):void 0,createdByEventId:r.event.id,createdAt:r.context.appliedAt,completedByEventId:i?r.event.id:void 0,completedAt:i?r.context.appliedAt:void 0,history:[s]}}function Bp(e,t,n,o){void 0!==t.amount&&Math.abs(t.amount-n)>Ap&&e.diagnostics.push(Cp("warning","declared-product-amount-mismatch",`Product "${t.id}" declares ${t.amount}, while its sources yield ${n}.`,o,[t.id]))}function Np(e,t,n){const o=`events.${e.event.id}.effects.${n}`,r=e.state;if("set-state"===t.type){["queued","active","transformed","retained","ejected","failed","recovered"].includes(t.state)||e.diagnostics.push(Cp("error","invalid-component-state",`set-state cannot assign "${t.state+""}".`,o+".state")),e.diagnostics.push(...Lp(t.metricsDelta,o+".metricsDelta")),Dp(e,t.outletId,o+".outletId");const n=Tp(r,t.select,o+".select");e.diagnostics.push(...n.diagnostics);const i=n.ids.filter(e=>r.components[e].productIds.length);if(i.length&&e.diagnostics.push(Cp("error","source-already-assigned",`Assigned source components cannot be retargeted: ${i.join(", ")}.`,o+".select",i)),e.diagnostics.some(e=>"error"===e.severity))return;const s=$p(e,t,{sourceIds:n.ids,outletIds:t.outletId?[t.outletId]:void 0});for(const e of n.ids){const n=r.components[e];n.status=t.state,n.outletId=t.outletId,n.reason=t.reason,t.metricsDelta&&Ip(n.metrics,t.metricsDelta),n.history.push(s)}return r.history.push(s),void(n.ids.length&&zp(e,{type:"retarget-component",sourceIds:n.ids,outletIds:t.outletId?[t.outletId]:void 0}))}if("set-relation"===t.type){const{relation:n}=t;n.id&&!r.relations[n.id]||e.diagnostics.push(Cp("error","duplicate-relation",`Relation id "${n.id}" is missing or already active.`,o+".relation.id",[n.id]));const i=function(e,t,n){const o=Rp(t),r=t.filter(t=>!e.state.components[t]);return 2>t.length&&e.diagnostics.push(Cp("error","insufficient-relation-sources","A relation requires at least two source components.",n)),o.length&&e.diagnostics.push(Cp("error","duplicate-source",`Relation source ids must be unique: ${o.join(", ")}.`,n,o)),r.length&&e.diagnostics.push(Cp("error","unknown-component",`Relation references unknown source component${1===r.length?"":"s"}: ${r.join(", ")}.`,n,r)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}(e,n.sourceIds,o+".relation.sourceIds");if(e.diagnostics.push(...Lp(n.metrics,o+".relation.metrics")),!i||e.diagnostics.some(e=>"error"===e.severity))return;r.relations[n.id]={...n,sourceIds:[...n.sourceIds],metrics:n.metrics?{...n.metrics}:void 0,status:"active",createdByEventId:e.event.id,createdAt:e.context.appliedAt};const s=$p(e,t,{sourceIds:[...n.sourceIds],relationIds:[n.id]});return r.history.push(s),void zp(e,{type:"activate-relation",sourceIds:[...n.sourceIds],relationIds:[n.id]})}if("resolve-relation"===t.type){const n=Rp(t.relationIds),i=t.relationIds.filter(e=>!r.relations[e]),s=t.relationIds.filter(e=>"resolved"===r.relations[e]?.status);if(n.length&&e.diagnostics.push(Cp("error","duplicate-relation","Relation ids must be unique.",o+".relationIds",n)),i.length&&e.diagnostics.push(Cp("error","unknown-relation",`Unknown relation: ${i.join(", ")}.`,o+".relationIds",i)),s.length&&e.diagnostics.push(Cp("error","resolved-relation",`Relation is already resolved: ${s.join(", ")}.`,o+".relationIds",s)),e.diagnostics.some(e=>"error"===e.severity))return;for(const n of t.relationIds){const o=r.relations[n];o.status="resolved",o.resolution=t.resolution,o.resolvedByEventId=e.event.id,o.resolvedAt=e.context.appliedAt,o.reason=t.reason}const a=$p(e,t,{relationIds:[...t.relationIds]});return r.history.push(a),void zp(e,{type:"resolve-relation",relationIds:[...t.relationIds]})}if("combine"===t.type||"contribute"===t.type){const n=e.productDefinitions.get(t.productId);n||e.diagnostics.push(Cp("error","unknown-product",`Product "${t.productId}" has no declared mold.`,o+".productId",[t.productId]));const i=r.products[t.productId];"combine"===t.type&&i&&e.diagnostics.push(Cp("error","duplicate-product",`Product "${t.productId}" has already been formed.`,o+".productId",[t.productId])),"contribute"!==t.type||i&&"forming"===i.status||e.diagnostics.push(Cp("error","product-not-forming",`Contributions require an existing forming product "${t.productId}".`,o+".productId",[t.productId]));const s=Ep(e,t.sourceIds,o+".sourceIds"),a="contribute"===t.type&&i?[...i.sourceIds,...t.sourceIds]:t.sourceIds,c=function(e,t,n,o){if(!t?.length)return[];const r=Rp(t),i=t.filter(t=>!e.state.relations[t]),s=t.filter(t=>"resolved"===e.state.relations[t]?.status),a=new Set(n),c=t.filter(t=>(e.state.relations[t]?.sourceIds??[]).some(e=>!a.has(e)));return r.length&&e.diagnostics.push(Cp("error","duplicate-relation","Basis relations must be unique.",o,r)),i.length&&e.diagnostics.push(Cp("error","unknown-relation",`Unknown basis relation: ${i.join(", ")}.`,o,i)),s.length&&e.diagnostics.push(Cp("error","resolved-relation",`Basis relation is already resolved: ${s.join(", ")}.`,o,s)),c.length&&e.diagnostics.push(Cp("error","relation-source-mismatch",`Basis relation includes a source outside this product: ${c.join(", ")}.`,o,c)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.relations[t])}(e,t.basisRelationIds,a,o+".basisRelationIds");if(!s||!c||!n||e.diagnostics.some(e=>"error"===e.severity))return;const l=s.reduce((e,t)=>e+t.amount,0),u=function(e){const t={};for(const n of e)Ip(t,n.metrics);return t}(s);if(!Op(e,l,u,t.loss,o+".loss"))return;const d=l-(t.loss?.amount??0);!function(e,t,n){e.state.loss.amount+=n?.amount??0;for(const[o,r]of Object.entries(n?.metrics??{}))t[o]=Number(t[o]??0)-r,e.state.loss.metrics[o]=Number(e.state.loss.metrics[o]??0)+r}(e,u,t.loss);const h="combine"===t.type&&!1!==t.complete,f=$p(e,t,{sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0});let p;if("combine"===t.type){if(h&&Bp(e,n,d,o+".productId"),p=Fp(n,t.sourceIds,d,u,e,h,f),h&&!Dp(e,p.outletId,o+".productId"))return;r.products[t.productId]=p}else p=i,p.sourceIds.push(...t.sourceIds),p.amount+=d,Ip(p.metrics,u),p.history.push(f);for(const e of s)e.productIds=[t.productId],e.status="consumed",e.outletId=void 0,e.history.push(f);return r.history.push(f),function(e,t){if(t.length){for(const n of t)n.status="resolved",n.resolution="combined",n.resolvedByEventId=e.event.id,n.resolvedAt=e.context.appliedAt;zp(e,{type:"resolve-relation",relationIds:t.map(e=>e.id)})}}(e,c),zp(e,{type:"combine"===t.type?"form-product":"update-product",sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0,outletIds:p.outletId?[p.outletId]:void 0}),void(h&&zp(e,{type:"complete-product",sourceIds:[...p.sourceIds],productIds:[p.id],outletIds:p.outletId?[p.outletId]:void 0}))}if("complete-product"===t.type){const n=r.products[t.productId];return n?void function(e,t,n,o,r,i){const s=e.productDefinitions.get(t.id),a=n??s?.outletId??(e.outletIds.has("product")?"product":void 0);if(!Dp(e,a,i+".outletId"))return;if("complete"===t.status)return void e.diagnostics.push(Cp("error","product-already-complete",`Product "${t.id}" is already complete.`,i,[t.id]));s&&(Bp(e,s,t.amount,i+".productId"),void 0!==s.amount&&(t.amount=s.amount),s.metrics&&(t.metrics={...t.metrics,...s.metrics})),t.status="complete",t.outletId=a,t.reason=o,t.completedByEventId=e.event.id,t.completedAt=e.context.appliedAt;const c=$p(e,r,{sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:a?[a]:void 0});t.history.push(c),e.state.history.push(c),zp(e,{type:"complete-product",sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:a?[a]:void 0})}(e,n,t.outletId,t.reason,t,o):void e.diagnostics.push(Cp("error","unknown-product-state",`Product "${t.productId}" has not been formed.`,o+".productId",[t.productId]))}if("split"===t.type){const n=Ep(e,[t.sourceId],o+".sourceId");t.products.length||e.diagnostics.push(Cp("error","empty-split","A split requires at least one product allocation.",o+".products"));const i=t.products.map(e=>e.productId),s=Rp(i);s.length&&e.diagnostics.push(Cp("error","duplicate-product","Split product ids must be unique.",o+".products",s));const a=i.map(t=>e.productDefinitions.get(t)),c=i.filter((e,t)=>!a[t]),l=i.filter(e=>r.products[e]);c.length&&e.diagnostics.push(Cp("error","unknown-product",`Split references undeclared product molds: ${c.join(", ")}.`,o+".products",c)),l.length&&e.diagnostics.push(Cp("error","duplicate-product",`Split products already exist: ${l.join(", ")}.`,o+".products",l));for(const[n,r]of t.products.entries())void 0===r.amount||Number.isFinite(r.amount)&&r.amount>=0||e.diagnostics.push(Cp("error","invalid-product-amount","Split allocation amounts must be finite and non-negative.",`${o}.products.${n}.amount`)),e.diagnostics.push(...Lp(r.metrics,`${o}.products.${n}.metrics`));if(!n?.length||e.diagnostics.some(e=>"error"===e.severity))return;const u=n[0];if(!Op(e,u.amount,u.metrics,t.loss,o+".loss"))return;const d=u.amount-(t.loss?.amount??0),h=t.products.map((e,t)=>e.amount??a[t]?.amount),f=h.filter(e=>void 0!==e).length;if(0!==f&&f!==h.length)return void e.diagnostics.push(Cp("error","partial-split-allocation","Either every split product must declare an amount or none may do so.",o+".products"));const p=f?h:t.products.map(()=>d/t.products.length),y=p.reduce((e,t)=>e+t,0);if(Math.abs(y-d)>Ap)return void e.diagnostics.push(Cp("error","split-amount-mismatch",`Split allocations total ${y}, but ${d} remains after loss.`,o+".products"));const g={...u.metrics};for(const[e,n]of Object.entries(t.loss?.metrics??{}))g[e]=Number(g[e]??0)-n;const m=$p(e,t,{sourceIds:[u.id],productIds:i});if(t.products.forEach((n,i)=>{const s=a[i],c=d>Ap?p[i]/d:1/t.products.length,l=Object.fromEntries(Object.entries(g).map(([e,t])=>[e,t*c])),h=n.metrics??s.metrics??l,f=Fp({...s,amount:p[i],metrics:h},[u.id],p[i],{...h},e,!0,m);Dp(e,f.outletId,`${o}.products.${i}.productId`)&&(r.products[f.id]=f)}),e.diagnostics.some(e=>"error"===e.severity))return;u.productIds=i,u.status="consumed",u.outletId=void 0,u.history.push(m),r.loss.amount+=t.loss?.amount??0;for(const[e,n]of Object.entries(t.loss?.metrics??{}))r.loss.metrics[e]=Number(r.loss.metrics[e]??0)+n;r.history.push(m),zp(e,{type:"split-source",sourceIds:[u.id],productIds:i});for(const t of i)zp(e,{type:"complete-product",sourceIds:[u.id],productIds:[t],outletIds:r.products[t].outletId?[r.products[t].outletId]:void 0});return}if("eject"===t.type){Dp(e,t.outletId,o+".outletId");const n=Tp(r,t.select,o+".select");e.diagnostics.push(...n.diagnostics);const i=n.ids.filter(e=>r.components[e].productIds.length);if(i.length&&e.diagnostics.push(Cp("error","source-already-assigned",`Assigned source components cannot be ejected: ${i.join(", ")}.`,o+".select",i)),e.diagnostics.some(e=>"error"===e.severity))return;const s=$p(e,t,{sourceIds:n.ids,outletIds:[t.outletId]});for(const e of n.ids){const n=r.components[e];n.status=t.state??"ejected",n.outletId=t.outletId,n.reason=t.reason,n.history.push(s)}return r.history.push(s),void(n.ids.length&&zp(e,{type:"retarget-component",sourceIds:n.ids,outletIds:[t.outletId]}))}if("set-metric"===t.type){if(e.diagnostics.push(...Lp(t.metricsDelta,o+".metricsDelta")),e.diagnostics.some(e=>"error"===e.severity))return;let n,i;if("run"===t.target)Ip(r.metrics,t.metricsDelta);else if("components"in t.target){const i=Tp(r,t.target.components,o+".target.components");if(e.diagnostics.push(...i.diagnostics),e.diagnostics.some(e=>"error"===e.severity))return;n=i.ids;for(const e of i.ids)Ip(r.components[e].metrics,t.metricsDelta)}else{i=[...t.target.productIds];const n=Rp(i),s=i.filter(e=>!r.products[e]);if(n.length&&e.diagnostics.push(Cp("error","duplicate-product","Metric target product ids must be unique.",o+".target.productIds",n)),s.length&&e.diagnostics.push(Cp("error","unknown-product-state",`Metric target product has not formed: ${s.join(", ")}.`,o+".target.productIds",s)),e.diagnostics.some(e=>"error"===e.severity))return;for(const e of i)Ip(r.products[e].metrics,t.metricsDelta)}return void r.history.push($p(e,t,{sourceIds:n,productIds:i}))}t.outcome.trim()?(r.outcome=t.outcome,r.summary=t.summary,r.history.push($p(e,t)),e.observations.push({type:"crucible-outcome",eventId:e.event.id,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,outcome:t.outcome})):e.diagnostics.push(Cp("error","invalid-outcome","Outcome must be a non-empty string.",o+".outcome"))}function Wp(e,t,n){if(e.eventsApplied.includes(t.id))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:[Cp("warning","duplicate-event-application",`Event "${t.id}" has already been applied.`,"events."+t.id,[t.id])]};const o=jp(e),r={state:o,event:t,context:n,productDefinitions:new Map(n.products.map(e=>[e.id,e])),outletIds:new Set(n.outlets.map(e=>e.id)),diagnostics:[],materializations:[],observations:[]};for(const[n,o]of t.effects.entries())if(Np(r,o,n),r.diagnostics.some(e=>"error"===e.severity))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:r.diagnostics};return o.elapsed=Math.max(o.elapsed,n.appliedAt),o.phaseId=n.phaseId,o.eventsApplied.push(t.id),r.observations.unshift({type:"crucible-event",eventId:t.id,phaseId:n.phaseId,authoredAt:n.authoredAt,appliedAt:n.appliedAt}),{applied:!0,state:o,materializations:r.materializations,observations:r.observations,diagnostics:r.diagnostics}}var qp=[900,520],Yp=[{id:"product",label:"Products",side:"bottom",order:0},{id:"retained",label:"Retained",side:"bottom",order:1},{id:"residue",label:"Residue",side:"left",order:2},{id:"failed",label:"Failed",side:"right",order:3},{id:"recovered",label:"Recovered",side:"right",order:4}],Gp=new Set(["queued","active","transformed","consumed","retained","ejected","failed","recovered"]),Hp=1e-9;function Vp(e,t){return t>e?-1:e>t?1:0}function Xp(e,t,n,o,r){return{severity:e,code:t,message:n,path:o,ids:r?[...r]:void 0}}function Up(e){const t=new Set,n=new Set;for(const o of e)t.has(o)&&n.add(o),t.add(o);return[...n].sort(Vp)}function Kp(e){const t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function Zp(e,t,n,o,r,i){if(!n)return o;try{return("function"==typeof n?n(e,t):e[n])??o}catch(e){return r.push(Xp("error","accessor-error",`Accessor threw: ${e instanceof Error?e.message:e+""}.`,i)),o}}function Qp(e,t,n){if(!e||"object"!=typeof e||Array.isArray(e))return null!=e&&t.push(Xp("error","invalid-metrics","Metrics must be a numeric object.",n)),{};const o={};for(const[r,i]of Object.entries(e)){const e=Kp(i);null!=e?o[r]=e:t.push(Xp("error","invalid-metric",`Metric "${r}" must be finite.`,`${n}.${r}`))}return o}function Jp(e){return e.map((e,t)=>({outlet:e,index:t})).sort((e,t)=>(e.outlet.order??e.index)-(t.outlet.order??t.index)||e.index-t.index).map(({outlet:e})=>({...e}))}function ey(e){const{id:t,orientation:n,fixed:o,start:r,end:i,openings:s,thickness:a,friction:c,restitution:l}=e,u=function(e,t,n){const o=n.map(([n,o])=>[Math.max(e,Math.min(n,o)),Math.min(t,Math.max(n,o))]).filter(([e,t])=>t>e+Hp).sort((e,t)=>e[0]-t[0]||e[1]-t[1]),r=[];let i=e;for(const[e,t]of o)e>i+Hp&&r.push([i,e]),i=Math.max(i,t);return t>i+Hp&&r.push([i,t]),r}(r,i,s);return u.map(([e,r],i)=>({id:1===u.length?t:`${t}:${i}`,friction:c,restitution:l,shape:"horizontal"===n?{type:"segment",x1:e,y1:o,x2:r,y2:o,thickness:a}:{type:"segment",x1:o,y1:e,x2:o,y2:r,thickness:a}}))}function ty(e){let t=2166136261;for(let n=0;e.length>n;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function ny(e){return"number"==typeof e&&Number.isFinite(e)?e>>>0:"string"==typeof e?ty(e):1}function oy(e,t){return{fixedDt:1/120,maxSubsteps:8,settleStepLimit:7200,colliders:t.map(e=>({...e,shape:{...e.shape}})),observation:{chartType:"crucible"},kernel:{seed:ny(e),gravity:{x:0,y:0},cellSize:42,collisionIterations:6,velocityDamping:.992,restitution:.12,friction:.42,sleepSpeed:4,sleepAfter:.5,maxVelocity:620}}}function ry(e){return"crucible:component:"+encodeURIComponent(e)}function iy(e,t,n,o){if(void 0!==n&&Number.isFinite(n)&&n>0)return n;const r=Math.min(...t,e),i=Math.max(...t,e);return i-r>Hp?o[0]+(o[1]-o[0])*Math.sqrt(Math.max(0,e-r)/(i-r)):(o[0]+o[1])/2}function sy(e,t){const n=Math.max(.25,Math.min(1,t.width/900,t.height/520)),o=e?.[0]??7*n,r=e?.[1]??18*n,i=Math.max(1,Math.min(o,r));return[i,Math.max(i,Math.max(o,r))]}function ay(e,t){if(!e)return[];const n=Math.min(e,Math.max(1,Math.ceil(Math.sqrt(e*Math.max(.5,t.width/Math.max(1,t.height)))))),o=Math.max(1,Math.ceil(e/n));return Array.from({length:e},(e,r)=>({x:t.x+t.width/n*(r%n+.5),y:t.y+(Math.floor(r/n)+.5)*(t.height/o)}))}function cy(e){return e.outletId?e.outletId:"failed"===e.status?"failed":"recovered"===e.status?"recovered":"retained"===e.status?"retained":"ejected"===e.status?"residue":void 0}function ly(e,t){return e.outlets.find(e=>e.id===t)||{x:e.chamber.x+.18*e.chamber.width,y:e.chamber.y+.2*e.chamber.height,width:.64*e.chamber.width,height:.6*e.chamber.height}}function uy(e,t,n={}){const o=Object.values(e.products).sort((e,t)=>Vp(e.id,t.id)),r=Object.values(e.components).sort((e,t)=>Vp(e.id,t.id)),i=[...r.map(e=>e.amount),...o.map(e=>e.amount)],s=sy(n.radiusRange,t),a=function(e,t){const n=new Map;for(const t of e){const e=t.outletId??"__chamber__",o=n.get(e)??[];o.push(t),n.set(e,o)}const o=new Map;for(const[e,r]of n){r.sort((e,t)=>(e.order??Number.MAX_SAFE_INTEGER)-(t.order??Number.MAX_SAFE_INTEGER)||Vp(e.id,t.id));const n=ay(r.length,ly(t,"__chamber__"===e?void 0:e));r.forEach((e,t)=>o.set(e.id,n[t]))}return o}(o,t),c=o.map(e=>{const o=a.get(e.id)??{x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2},r=1.28*iy(e.amount,i,n.bodyRadius,s),c={__crucible:!0,kind:"product",semanticId:e.id,product:e};return{id:(l=e.id,"crucible:product:"+encodeURIComponent(l)),x:o.x,y:o.y,mass:Math.max(.25,r*r*.018),bodyCollisions:!1,shape:{type:"circle",radius:r},datum:c};var l}),l=new Map;for(const e of r.filter(e=>!e.productIds.length)){const t=cy(e)??"__chamber__",n=l.get(t)??[];n.push(e),l.set(t,n)}const u=new Map;for(const[e,n]of l){const o=ay(n.length,ly(t,"__chamber__"===e?void 0:e));n.forEach((e,t)=>u.set(e.id,o[t]))}return[...r.map(e=>{let o=u.get(e.id);if(e.productIds.length){const n=e.productIds.map(e=>a.get(e)).filter(e=>!!e);if(n.length){o={x:n.reduce((e,t)=>e+t.x,0)/n.length,y:n.reduce((e,t)=>e+t.y,0)/n.length};const r=ty(e.id)/4294967295*Math.PI*2,i=Math.min(20,Math.max(4,.012*t.width));o={x:o.x+Math.cos(r)*i,y:o.y+Math.sin(r)*i}}}o??(o={x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2});const r=iy(e.amount,i,n.bodyRadius,s),c={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:ry(e.id),x:o.x,y:o.y,mass:Math.max(.25,r*r*.015),shape:{type:"circle",radius:r},datum:c}}),...c]}var dy=uy;function hy(e){return Array.isArray(e)?e.map(hy):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e&&"function"!=typeof e).sort(([e],[t])=>Vp(e,t)).map(([e,t])=>[e,hy(t)])):e}function fy(e,t=e.duration){const n=function(e,t){const n=Kp(t)??0,o=Math.max(0,Math.min(e.duration,n));if(!e.phases.length)return{elapsed:o,phaseId:"",phaseIndex:-1,phaseElapsed:0,complete:!0};const r=o>=e.duration-Hp,i=r?e.phases[e.phases.length-1]:e.phases.find(e=>o>=e.start&&e.end>o)??e.phases[0];return{elapsed:o,phaseId:i.id,phaseIndex:i.index,phaseElapsed:r?i.duration:Math.max(0,o-i.start),complete:r}}(e,t);let o=jp(e.initialState);const r=[],i=[],s=[];for(const t of e.events){if(t.authoredAt>n.elapsed+Hp)break;const a=Wp(o,t,{phaseId:t.phaseId,authoredAt:t.authoredAt,appliedAt:t.authoredAt,products:e.products,outlets:e.outlets});r.push(...a.diagnostics),i.push(...a.materializations),s.push(...a.observations),a.applied&&(o=a.state)}return o.elapsed=n.elapsed,o.phaseId=n.phaseId,o.phaseIndex=n.phaseIndex,o.phaseElapsed=n.phaseElapsed,o.complete=n.complete,n.complete&&"in_process"===o.outcome&&(o.outcome="complete"),o.playing=!1,{state:o,diagnostics:r,materializations:i,observations:s}}function py(e){const t=function(e){const t=[];e.length||t.push(Xp("error","empty-phase-program","CrucibleChart requires at least one phase.","phases"));const n=Up(e.map(e=>e.id));n.length&&t.push(Xp("error","duplicate-phase-id",`Phase ids must be unique: ${n.join(", ")}.`,"phases",n));let o=0;return{phases:e.map((e,n)=>{const r=Kp(e.duration),i=null!=r&&r>0?r:0;e.id.trim()||t.push(Xp("error","invalid-phase-id","Phase ids may not be empty.",`phases.${n}.id`)),null!=r&&r>0||t.push(Xp("error","invalid-phase-duration","Phase duration must be finite and greater than zero.",`phases.${n}.duration`,[e.id])),void 0===e.intensity||Number.isFinite(e.intensity)||t.push(Xp("error","invalid-phase-intensity","Phase intensity must be finite.",`phases.${n}.intensity`,[e.id]));const s={...e,duration:i,intensity:void 0===e.intensity?.5:Number.isFinite(e.intensity)?Math.max(0,Math.min(1,e.intensity)):.5,motion:e.motion??"hold",index:n,start:o,end:o+i};return o=s.end,s}),diagnostics:t}}(e.phases),n=t.phases.at(-1)?.end??0,o=Jp(e.outlets??Yp),r=(e.products??[]).map(e=>({...e,metrics:e.metrics?{...e.metrics}:void 0})),i=function(e,t,n){const o=[],r=Up(e.map(e=>e.id));r.length&&o.push(Xp("error","duplicate-event-id",`Event ids must be unique: ${r.join(", ")}.`,"events",r));const i=[];return e.forEach((e,r)=>{let s,a,c;if(e.id.trim()||o.push(Xp("error","invalid-event-id","Event ids may not be empty.",`events.${r}.id`)),"time"in e.at&&void 0!==e.at.time){const i=Kp(e.at.time);if(null==i||0>i||i>n+Hp)return void o.push(Xp("error","event-time-out-of-range",`Event time must fall between 0 and ${n}.`,`events.${r}.at.time`,[e.id]));s=Math.max(0,Math.min(n,i));const l=function(e,t,n){const o=e.find(e=>Hp>=Math.abs(e.start-n));if(o)return{phase:o,boundaryRank:1};const r=e.find(e=>n>=e.start&&e.end>n);return r?{phase:r,boundaryRank:0}:Hp>=Math.abs(n-t)&&e.length?{phase:e[e.length-1],boundaryRank:0}:{phase:void 0,boundaryRank:1}}(t,n,s);a=l.phase,c=l.boundaryRank}else{if(a=t.find(t=>t.id===e.at.phaseId),!a)return void o.push(Xp("error","unknown-event-phase",`Event references unknown phase "${e.at.phaseId}".`,`events.${r}.at.phaseId`,[e.id,e.at.phaseId]));const n=e.at.progress??0;if(!Number.isFinite(n)||0>n||n>1)return void o.push(Xp("error","event-progress-out-of-range","Event phase progress must be between 0 and 1.",`events.${r}.at.progress`,[e.id]));s=a.start+a.duration*n,c=0===n?1:0}a?i.push({...e,index:r,authoredAt:s,phaseId:a.id,phaseIndex:a.index,boundaryRank:c}):o.push(Xp("error","event-without-phase","Event could not be assigned to a phase.",`events.${r}.at`,[e.id]))}),i.sort((e,t)=>e.authoredAt-t.authoredAt||e.boundaryRank-t.boundaryRank||e.index-t.index),{events:i,diagnostics:o}}(e.events??[],t.phases,n),s=function(e){const t=[],n={},o=[];let r=0;const i={};e.data.forEach((s,a)=>{const c=(s.id??"component-"+a)+"",l=((Zp(s,a,e.idAccessor,c,t,`data.${a}.id`)??c)+"").trim();if(!l)return void t.push(Xp("error","invalid-component-id","Component ids may not be empty.",`data.${a}.id`));o.push(l);const u=Kp(Zp(s,a,e.amountAccessor,1,t,`data.${a}.amount`)),d=null==u||0>u?0:u;(null==u||0>u)&&t.push(Xp("error","invalid-component-amount","Component amount must be finite and non-negative.",`data.${a}.amount`,[l]));const h=Qp(Zp(s,a,e.metricsAccessor,{},t,`data.${a}.metrics`),t,`data.${a}.metrics`),f=Zp(s,a,e.initialStateAccessor,"active",t,`data.${a}.status`),p=Gp.has(f)?f:"active";Gp.has(f)||t.push(Xp("error","invalid-component-status",`Unknown component status "${f+""}".`,`data.${a}.status`,[l]));const y=Zp(s,a,e.labelAccessor,(s.label??s.name??l)+"",t,`data.${a}.label`)+"",g=Zp(s,a,e.categoryAccessor,"component",t,`data.${a}.category`)+"";n[l]||(n[l]={id:l,label:y,category:g,datum:s,status:p,initialAmount:d,amount:d,initialMetrics:{...h},metrics:{...h},productIds:[],history:[]},r+=d,function(e,t){for(const[n,o]of Object.entries(t))e[n]=Number(e[n]??0)+o}(i,h))});const s=Up(o);s.length&&t.push(Xp("error","duplicate-component-id",`Component ids must be unique: ${s.join(", ")}.`,"data",s));const a=Qp(e.metrics??{},t,"metrics");return{state:{elapsed:0,phaseElapsed:0,phaseId:e.phases[0]?.id??"",phaseIndex:e.phases.length?0:-1,playing:!1,complete:0===e.phases.length,outcome:"in_process",eventsApplied:[],components:n,products:{},relations:{},input:{amount:r,metrics:i},metrics:a,loss:{amount:0,metrics:{}},history:[]},diagnostics:t}}(e),a=function(e=qp,t=Yp){const n=Math.max(1,Kp(e[0])??900),o=Math.max(1,Kp(e[1])??520),r=360>n||260>o,i=r?Math.max(4,.035*Math.min(n,o)):20,s=r?Math.max(10,.075*o):34,a={x:i,y:i,width:Math.max(1,n-2*i),height:s},c=r?Math.max(16,.14*o):Math.min(78,.16*o),l={x:i,y:o-i-c,width:Math.max(1,n-2*i),height:c},u=r?Math.max(12,.08*n):Math.min(150,.17*n),d=a.y+a.height+(r?12:38),h=l.y-(r?10:34),f={x:u,y:d,width:Math.max(24,n-2*u),height:Math.max(24,h-d)},p=Math.max(18,Math.min(.32*f.width,r?84:180)),y={x:f.x+(f.width-p)/2,y:f.y-(r?10:24),width:p,height:r?12:28},g=Jp(t),m={left:g.filter(e=>"left"===(e.side??"bottom")),right:g.filter(e=>"right"===e.side),bottom:g.filter(e=>"bottom"===(e.side??"bottom"))},x=[],b=(e,t)=>{const o=Math.max(8,u-1.5*i),s=f.height/Math.max(1,t.length);t.forEach((t,a)=>{x.push({...t,side:e,x:"left"===e?i:n-i-o,y:f.y+a*s,width:o,height:Math.max(8,s-(r?2:8))})})};b("left",m.left),b("right",m.right);const v=f.width/Math.max(1,m.bottom.length);return m.bottom.forEach((e,t)=>{x.push({...e,side:"bottom",x:f.x+t*v,y:f.y+f.height+(r?2:7),width:Math.max(8,v-(r?2:8)),height:Math.max(8,l.y-f.y-f.height-(r?4:12))})}),x.sort((e,t)=>g.findIndex(t=>t.id===e.id)-g.findIndex(e=>e.id===t.id)),{width:n,height:o,phaseRail:a,chamber:f,mouth:y,projection:l,outlets:x}}(e.size??qp,o),c=function(e){const{chamber:t,mouth:n}=e,o=Math.max(2,Math.min(10,.018*Math.min(e.width,e.height))),r=Math.max(t.x,n.x),i=Math.min(t.x+t.width,n.x+n.width),s={left:e.outlets.filter(e=>"left"===e.side),right:e.outlets.filter(e=>"right"===e.side),bottom:e.outlets.filter(e=>"bottom"===e.side)},a=[{id:"crucible:wall:top-left",friction:.42,restitution:.1,shape:{type:"segment",x1:t.x,y1:t.y,x2:r,y2:t.y,thickness:o}},{id:"crucible:wall:top-right",friction:.42,restitution:.1,shape:{type:"segment",x1:i,y1:t.y,x2:t.x+t.width,y2:t.y,thickness:o}}];a.push(...ey({id:"crucible:wall:left",orientation:"vertical",fixed:t.x,start:t.y,end:t.y+t.height,openings:s.left.map(e=>[e.y,e.y+e.height]),thickness:o,friction:.46,restitution:.12}),...ey({id:"crucible:wall:right",orientation:"vertical",fixed:t.x+t.width,start:t.y,end:t.y+t.height,openings:s.right.map(e=>[e.y,e.y+e.height]),thickness:o,friction:.46,restitution:.12}),...ey({id:"crucible:wall:bottom",orientation:"horizontal",fixed:t.y+t.height,start:t.x,end:t.x+t.width,openings:s.bottom.map(e=>[e.x,e.x+e.width]),thickness:o,friction:.5,restitution:.08}));for(const t of e.outlets)a.push({id:"crucible:outlet:"+encodeURIComponent(t.id),sensor:!0,shape:{type:"aabb",x:t.x+t.width/2,y:t.y+t.height/2,width:t.width,height:t.height}});return a}(a),l=function(e,t){const n=[],o=new Set(t.map(e=>e.id)),r=Up(t.map(e=>e.id)),i=Up(e.map(e=>e.id));return r.length&&n.push(Xp("error","duplicate-outlet-id",`Outlet ids must be unique: ${r.join(", ")}.`,"outlets",r)),i.length&&n.push(Xp("error","duplicate-product-id",`Product ids must be unique: ${i.join(", ")}.`,"products",i)),t.forEach((e,t)=>{e.id.trim()||n.push(Xp("error","invalid-outlet-id","Outlet ids may not be empty.",`outlets.${t}.id`)),void 0===e.order||Number.isFinite(e.order)||n.push(Xp("error","invalid-outlet-order","Outlet order must be finite.",`outlets.${t}.order`,[e.id]))}),e.forEach((e,t)=>{e.id.trim()||n.push(Xp("error","invalid-product-id","Product ids may not be empty.",`products.${t}.id`)),void 0===e.amount||Number.isFinite(e.amount)&&e.amount>=0||n.push(Xp("error","invalid-product-amount","Declared product amount must be finite and non-negative.",`products.${t}.amount`,[e.id])),void 0===e.outletId||o.has(e.outletId)||n.push(Xp("error","unknown-outlet",`Product "${e.id}" references unknown outlet "${e.outletId}".`,`products.${t}.outletId`,[e.outletId])),Qp(e.metrics??{},n,`products.${t}.metrics`)}),n}(r,o),u=(d={seed:e.seed??1,components:Object.values(s.state.components).sort((e,t)=>Vp(e.id,t.id)).map(e=>({id:e.id,label:e.label,category:e.category,amount:e.amount,metrics:e.metrics,status:e.status})),phases:t.phases.map(({id:e,duration:t,label:n,description:o,intensity:r,motion:i,color:s,metrics:a})=>({id:e,duration:t,label:n,description:o,intensity:r,motion:i,color:s,metrics:a})),products:r,outlets:o,events:i.events.map(({id:e,label:t,description:n,summary:o,authoredAt:r,phaseId:i,boundaryRank:s,effects:a})=>({id:e,label:t,description:n,summary:o,authoredAt:r,phaseId:i,boundaryRank:s,effects:a}))},JSON.stringify(hy(d)));var d;const h=function(e,t,n={}){const o=Object.values(e.components).sort((e,t)=>Vp(e.id,t.id)),r=o.map(e=>e.amount),i=sy(n.radiusRange,t),s=function(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}(ny(n.seed)),a=t.mouth.x+t.mouth.width/2,c=t.chamber.y+Math.max(18,.18*t.chamber.height),l=Math.max(4,.28*t.chamber.width),u=Math.max(4,.12*t.chamber.height);return o.map((e,t)=>{const d=t/Math.max(1,o.length)*Math.PI*2+.18*(s()-.5),h=iy(e.amount,r,n.bodyRadius,i),f={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:ry(e.id),x:a+Math.cos(d)*l*(.45+.45*s()),y:c+Math.sin(d)*u*(.45+.45*s()),vx:24*(s()-.5),vy:18*(s()-.5),mass:Math.max(.25,h*h*.015),restitution:.12,friction:.4,shape:{type:"circle",radius:h},datum:f}})}(s.state,a,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),f=[...t.diagnostics,...i.diagnostics,...s.diagnostics,...l],p={phases:t.phases,events:i.events,products:r,outlets:o,duration:n,initialState:s.state,terminalState:s.state,layout:a,colliders:c,config:oy(e.seed,c),initialSpawns:h,terminalSpawns:[],semanticKey:u,diagnostics:f},y=fy(p),g=Object.values(y.state.products).filter(e=>"forming"===e.status).map(e=>e.id),m=g.length?[Xp("warning","forming-product-at-end",`Products remain forming at the end of the tape: ${g.join(", ")}.`,"events",g)]:[];return p.terminalState=y.state,p.terminalSpawns=dy(y.state,a,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),p.diagnostics=[...f,...y.diagnostics,...m],p}var yy=y(require("react")),gy=require("react/jsx-runtime");function my(e){return Number.isFinite(e)?1e3>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2).replace(/\.00$/,"").replace(/(\.\d)0$/,"$1"):e.toLocaleString():"0"}function xy(e,t,n,o){const r=e.datum;if(!r?.__crucible)return;const i="circle"===e.shape.type?e.shape.radius:8,s="string"==typeof t.fill?t.fill:"product"===r.kind?"#b8792d":"#356b63",a="string"==typeof t.stroke?t.stroke:"#26323a",c="number"==typeof t.strokeWidth?t.strokeWidth:1.25,l="number"==typeof t.opacity?t.opacity:.96,u=o?`${o}-crucible-body-${n}`:"crucible-body-"+n;if("product"===r.kind){const t=Array.from({length:6},(t,n)=>{const o=-Math.PI/2+n/6*Math.PI*2;return`${e.x+Math.cos(o)*i},${e.y+Math.sin(o)*i}`}).join(" "),n=u+"-glow";return(0,gy.jsxs)(yy.Fragment,{children:[(0,gy.jsx)("defs",{children:(0,gy.jsx)("filter",{id:n,x:"-60%",y:"-60%",width:"220%",height:"220%",children:(0,gy.jsx)("feDropShadow",{dx:"0",dy:"0",stdDeviation:"4",floodColor:s,floodOpacity:"0.8"})})}),(0,gy.jsx)("polygon",{points:t,fill:s,stroke:a,strokeWidth:c,opacity:l,filter:`url(#${n})`}),(0,gy.jsx)("circle",{cx:e.x,cy:e.y,r:Math.max(2,.36*i),fill:"none",stroke:"var(--semiotic-bg, #fffaf0)",strokeWidth:c,opacity:.72*l})]},u)}return(0,gy.jsxs)(yy.Fragment,{children:[(0,gy.jsx)("circle",{cx:e.x,cy:e.y,r:i,fill:s,stroke:a,strokeWidth:c,opacity:l}),(0,gy.jsx)("circle",{cx:e.x-.25*i,cy:e.y-.28*i,r:Math.max(1,.18*i),fill:"rgba(255,255,255,0.34)"})]},u)}var by=require("react/jsx-runtime"),vy="var(--semiotic-text, #26323a)",wy="var(--semiotic-text-secondary, #6c7377)",ky="var(--semiotic-primary, #b8792d)",Sy="var(--semiotic-danger, #9f3d35)",Ay="var(--semiotic-success, #356b63)";function My(e){const{x:t,y:n,width:o,height:r}=e.chamber,i=Math.min(.14*o,48),s=n+r;return[`M ${t} ${n}`,`L ${t+i} ${s-.16*r}`,`Q ${t+o/2} ${s+.1*r} ${t+o-i} ${s-.16*r}`,`L ${t+o} ${n}`].join(" ")}function _y({layout:e,phases:t,state:n,compact:o=!1}){const r=Math.max(1,t.reduce((e,t)=>e+Math.max(0,t.duration),0));return(0,by.jsxs)("svg",{"aria-hidden":"true","data-testid":"crucible-chrome",viewBox:`0 0 ${e.width} ${e.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:[(0,by.jsxs)("defs",{children:[(0,by.jsxs)("linearGradient",{id:"semiotic-crucible-heat",x1:"0",x2:"0",y1:"0",y2:"1",children:[(0,by.jsx)("stop",{offset:"0",stopColor:ky,stopOpacity:"0.03"}),(0,by.jsx)("stop",{offset:"0.66",stopColor:ky,stopOpacity:"0.1"}),(0,by.jsx)("stop",{offset:"1",stopColor:Sy,stopOpacity:"0.18"})]}),(0,by.jsx)("pattern",{id:"semiotic-crucible-hatch",width:"7",height:"7",patternUnits:"userSpaceOnUse",patternTransform:"rotate(20)",children:(0,by.jsx)("line",{x1:"0",x2:"0",y1:"0",y2:"7",stroke:vy,strokeOpacity:"0.08",strokeWidth:"1"})})]}),(0,by.jsx)("rect",{x:e.chamber.x,y:e.chamber.y,width:e.chamber.width,height:e.chamber.height,rx:2,fill:"url(#semiotic-crucible-heat)",stroke:vy,strokeOpacity:"0.52",strokeWidth:o?1:2.2}),(0,by.jsx)("path",{d:My(e),fill:"url(#semiotic-crucible-hatch)",stroke:"none"}),(0,by.jsx)("line",{x1:e.mouth.x,x2:e.mouth.x+e.mouth.width,y1:e.mouth.y,y2:e.mouth.y,stroke:vy,strokeLinecap:"round",strokeOpacity:"0.72",strokeWidth:o?2:5}),o?null:(0,by.jsx)("g",{"data-testid":"crucible-phase-rail",children:t.map((o,i)=>{const s=t.slice(0,i).reduce((e,t)=>e+Math.max(0,t.duration),0),a=e.phaseRail.x+s/r*e.phaseRail.width,c=Math.max(0,o.duration)/r*e.phaseRail.width,l=o.id===n.phaseId,u=n.phaseIndex>i||n.complete;return(0,by.jsxs)("g",{children:[(0,by.jsx)("rect",{x:a,y:e.phaseRail.y,width:Math.max(1,c-2),height:e.phaseRail.height,rx:2,fill:l?o.color??ky:u?Ay:vy,fillOpacity:l?.68:u?.28:.09}),46>c?null:(0,by.jsx)("text",{x:a+c/2,y:e.phaseRail.y+e.phaseRail.height+13,fill:l?vy:wy,fontFamily:"system-ui, sans-serif",fontSize:8.5,fontWeight:l?800:650,letterSpacing:"0.04em",textAnchor:"middle",children:(o.label??o.id).toUpperCase()})]},o.id)})}),e.outlets.map(e=>(0,by.jsxs)("g",{children:[(0,by.jsx)("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:3,fill:e.color??("left"===e.side?Sy:Ay),fillOpacity:"0.1",stroke:e.color??("left"===e.side?Sy:Ay),strokeDasharray:"3 3",strokeOpacity:"0.62"}),o?null:(0,by.jsx)("text",{x:e.x+e.width/2,y:e.y+Math.min(13,e.height/2+3),fill:wy,fontFamily:"system-ui, sans-serif",fontSize:8,fontWeight:750,letterSpacing:"0.05em",textAnchor:"middle",children:(e.label??e.id).toUpperCase()})]},e.id))]})}function Py({rows:e,layout:t,projection:n,amountLabel:o}){if(!e.length)return null;const r=n.measure??"count",i=e.map(e=>Math.max(0,function(e,t){return"count"===t?e.count:"amount"===t?e.amount:Number(e.metrics[t]??0)}(e,r))),s=Math.max(1,...i),a=t.projection.width/Math.max(1,e.length),c=t.projection.height>48?21:4,l=Math.max(5,t.projection.height-c-5);return(0,by.jsx)("svg",{"aria-hidden":"true","data-testid":"crucible-projection-overlay",viewBox:`0 0 ${t.width} ${t.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:e.map((e,n)=>{const u=i[n],d=Math.max(u>0?2:0,u/s*l),h=t.projection.x+n*a+.18*a;return(0,by.jsxs)("g",{children:[(0,by.jsx)("rect",{x:h,y:t.projection.y+l-d,width:Math.max(3,.64*a),height:d,rx:2,fill:"failed"===e.status||"ejected"===e.status?Sy:"complete"===e.status?ky:Ay,fillOpacity:"0.68"}),c>4&&a>=34?(0,by.jsxs)(by.Fragment,{children:[(0,by.jsx)("text",{x:h+.32*a,y:t.projection.y+l+10,fill:wy,fontFamily:"system-ui, sans-serif",fontSize:7.5,fontWeight:700,textAnchor:"middle",children:e.label.length>13?e.label.slice(0,12)+"…":e.label}),(0,by.jsxs)("text",{x:h+.32*a,y:t.projection.y+l+19,fill:vy,fontFamily:"system-ui, sans-serif",fontSize:8,fontWeight:850,textAnchor:"middle",children:[my(u),"amount"===r&&o?" "+o:""]})]}):null]},e.key)})})}function jy(e){const t=e.datum;if(t&&"object"==typeof t){const e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e.id}function Cy(e){return e.map(e=>({...e,spawnAt:void 0}))}function Ry(e,t){return e?t?n=>wh.createElement(wh.Fragment,null,e,"function"==typeof t?t(n):t):e:t}var Ly=["#356b63","#a34b43","#c08b38","#3e5f83","#785b7c","#6e7740","#8f5c3a","#41717b"];function Iy(e){let t=2166136261;for(let n=0;e.length>n;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return Ly[(t>>>0)%Ly.length]}var Ty={Sparkline:{frameType:"xy",layout:{mode:"sparkline"},buildProps:(e,t,n,o,r)=>({chartType:"line",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||t,colorAccessor:t,...o,showAxes:!1,margin:o.margin,showLegend:!1,showGrid:!1,title:void 0})},BumpChart:Qu,LineChart:ed,AreaChart:nd,DifferenceChart:od,StackedAreaChart:rd,Scatterplot:sd,CandlestickChart:id,BubbleChart:Zu,ConnectedScatterplot:cd,QuadrantChart:ad,Heatmap:ld,TemporalHistogram:td,XYCustomChart:{frameType:"xy",buildProps:(e,t,n,o,r)=>({chartType:"custom",data:e,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:t,colorScheme:n,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...o,showAxes:r.frameProps?.showAxes??r.showAxes??!1,showLegend:o.showLegend??!!t})},BarChart:jd,StackedBarChart:Cd,GroupedBarChart:Rd,PieChart:Ld,DonutChart:Id,Histogram:Td,BoxPlot:$d,ViolinPlot:zd,SwarmPlot:Dd,DotPlot:Ed,SwimlaneChart:Od,RidgelinePlot:Fd,LikertChart:Bd,FunnelChart:Nd,GaugeChart:Wd,OrdinalCustomChart:{frameType:"ordinal",buildProps:(e,t,n,o,r)=>({chartType:"custom",data:e,oAccessor:r.categoryAccessor||r.oAccessor||"category",rAccessor:r.valueAccessor||r.rAccessor||"value",projection:r.projection||"vertical",colorAccessor:t,colorScheme:n,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...o,showAxes:r.frameProps?.showAxes??r.showAxes??!1})},ForceDirectedGraph:ch,NetworkCustomChart:{frameType:"network",layout:{margin:{top:40,right:40,bottom:40,left:40}},buildProps:(e,t,n,o,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:n,customNetworkLayout:r.layout||r.customNetworkLayout,layoutConfig:r.layoutConfig,...o})},SankeyDiagram:uh,ProcessSankey:lh,ChordDiagram:dh,TreeDiagram:hh,Treemap:fh,CirclePack:ph,ChoroplethMap:xh,ProportionalSymbolMap:bh,FlowMap:vh,GeoCustomChart:{frameType:"geo",buildProps:(e,t,n,o,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:n,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...o})},GaltonBoardChart:{frameType:"physics",buildProps:(e,t,n,o,r)=>{const i=o.size??[600,400],s=r.bins??21,a=r.seed??1,c=Math.max(1,Math.round(r.pegRows??s-1)),l="mechanical"===r.mode,u=l?function(e){const t=Math.max(2,Math.round(e.bins)),n=Math.max(1,Math.round(e.pegRows??t-1)),o=Math.max(1,Math.round(e.count??Math.max(64,4*t))),r=jh(Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,0,1),i=Lh(e.seed??1),s=e.idPrefix??"mechanical";return Array.from({length:o},(e,t)=>{let o=0;for(let e=0;n>e;e+=1)i()<r&&(o+=1);const a=n/2;return{id:`${s}-${t}`,value:o,mechanical:!0,pegRows:n,branchProbability:r,pathRights:o,side:a>o?"left":o>a?"right":"center"}})}({bins:s,branchProbability:r.branchProbability,count:r.mechanicalCount,pegRows:c,seed:a}):Array.isArray(e)?e:[],d=function(e){const{data:t,valueAccessor:n,bins:o,ballRadius:r,seed:i,size:s,valueExtent:a}=e,c=kh(s),l=t.map((e,t)=>Ph(_h(e,t,n))).filter(e=>null!=e),u=function(e){if(!e)return;const t=Ph(e[0]),n=Ph(e[1]);return null!=t&&null!=n?t>n?[n,t]:[t,n]:void 0}(a),d=u?.[0]??(l.length?Math.min(...l):0),h=u?.[1]??(l.length?Math.max(...l):1),f=h===d?1:h-d,p=(0,Ih.scaleLinear)().domain([0,o]).range([c.plot.x,c.plot.x+c.plot.width]),y=Array.from({length:o},()=>0),g=[];t.forEach((e,t)=>{const i=Ph(_h(e,t,n));if(null==i)return;const s=Math.max(0,Math.min(o-1,Math.floor((i-d)/f*o)));y[s]+=1,g.push({id:(e.id??"galton-"+t)+"",x:p(s+.5),y:c.plot.y+r+2,vx:8*(t%5-2),vy:0,mass:1,shape:{type:"circle",radius:r},datum:{...e,value:i,bin:s}})});const m=c.plot.y+c.plot.height;return{config:Mh(i,[...jf({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...Cf({idPrefix:"galton-bin",count:o,domainStart:0,domainStep:1,xScale:p,yTop:c.plot.y-400,yBottom:m,wallThickness:6})],"GaltonBoardChart"),initialSpawns:g,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:y.map((e,t)=>({label:t+1+"",value:e})),metadata:{kind:"galton-board",bins:o,plot:c.plot,valueExtent:[d,h]}}}({data:u,valueAccessor:r.valueAccessor||"value",bins:s,ballRadius:r.ballRadius??4,seed:a,size:i,valueExtent:l?[0,c]:void 0});return{...o,config:d.config,initialSpawns:Cy(d.initialSpawns),projectionRows:d.projectionRows,bodyStyle:Ah(t||r.colorBy||(l?"side":void 0),"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.valueAccessor||"value"})}}},EventDropChart:{frameType:"physics",buildProps:(e,t,n,o,r)=>{const i=o.size??[600,400],s=function(e){const{data:t,timeAccessor:n,arrivalAccessor:o,windows:r,watermark:i,ballRadius:s,seed:a,size:c,timeExtent:l,timeScale:u=1}=e,d=kh(c),h=t.map((e,t)=>Ph(_h(e,t,n))).filter(e=>null!=e),f=Ph(l?.[0]),p=Ph(l?.[1]),y=h.length?Math.min(...h):0,g=h.length?Math.max(...h):y+r.size,m=Math.min(f??y,y),x=Math.max(p??g,g),b=Math.floor(m/r.size)*r.size,v=Math.max(1,Math.ceil((x-b+r.size)/r.size)),w=h.length?Math.max(...h):0,k="function"==typeof i?i(w):Ph(i?.value)??w-(i?.delay??r.size),S=Math.max(0,Math.min(v,Array.from({length:v},(e,t)=>t).reduce((e,t)=>b+(t+1)*r.size>k?e:e+1,0))),A=function(e,t){const n=Math.max(5*t,Math.min(92,.13*e.plot.width));return{gutter:{x:e.plot.x,y:e.plot.y,width:n,height:e.plot.height},windowPlot:{x:e.plot.x+n,y:e.plot.y,width:Math.max(40,e.plot.width-n),height:e.plot.height},wallTop:e.plot.y+.48*e.plot.height}}(d,s),M=b+v*r.size,_=(0,Vf.scaleLinear)().domain([b,M]).range([A.windowPlot.x,A.windowPlot.x+A.windowPlot.width]),P=Array.from({length:v},()=>({value:0,secondary:0})),j=[];t.forEach((e,t)=>{const i=Ph(_h(e,t,n));if(null==i)return;const a=Ph(_h(e,t,o))??i,c=Math.max(0,Math.min(v-1,Math.floor((i-b)/r.size))),l=k>=b+(c+1)*r.size;P[c].value+=l?0:1,P[c].secondary+=l?1:0,j.push({id:(e.id??"event-"+t)+"",x:Math.max(A.windowPlot.x+s,Math.min(A.windowPlot.x+A.windowPlot.width-s,_(i))),y:d.plot.y+s+2,vx:8*(t%3-1),vy:0,mass:1,friction:.02,spawnAt:a,shape:{type:"circle",radius:s},datum:{...e,eventTime:i,arrivalTime:a,windowIndex:c,late:l}})});const C=d.plot.y+d.plot.height,R=function(e,t){const n=Math.max(0,Math.min(e.windowCount,e.closedWindowCount));if(!n)return[];const o=e.windowStart,r=e.windowStart+e.windowCount*e.windowSize,i=(0,Vf.scaleLinear)().domain([o,r]).range([e.windowPlot.x,e.windowPlot.x+e.windowPlot.width]),s=i(e.windowStart+n*e.windowSize),a=e.windowPlot.x,c=t+Math.max(18,Math.min(.3*e.windowPlot.height,s-a)),l=e=>s===a?t:c+(e-a)/(s-a)*(t-c),u=[];for(let t=0;n>t;t+=1){const n=e.windowStart+t*e.windowSize,o=n+e.windowSize,r=i(n),s=i(o);u.push({id:"eventdrop-lid-"+t,windowIndex:t,x1:r,y1:l(r),x2:s,y2:l(s)})}return u}({closedWindowCount:S,gutter:A.gutter,plot:d.plot,windowCount:v,windowPlot:A.windowPlot,windowSize:r.size,windowStart:b},d.plot.y+.28*d.plot.height);return{config:Mh(a,[...jf({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...Xf({idPrefix:"eventdrop-window",count:v,xScale:e=>_(b+e*r.size),yTop:A.wallTop,yTopForIndex:e=>{const t=(e=>{if(0>e||e>S)return null;const t=0===e?R[0]?.y1:R[e-1]?.y2??R[e]?.y1;return"number"==typeof t&&Number.isFinite(t)?t:null})(e);return null==t?A.wallTop:t+1.25*s},yBottom:C,wallThickness:6}),...R.map(e=>({id:e.id,shape:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:Math.max(4,.42*s)},friction:.02,restitution:.01}))],"EventDropChart",{friction:.08}),initialSpawns:j,initialSpawnPacing:{pacing:"arrival",timeAccessor:e=>e.datum?.arrivalTime,timeScale:u},projectionRows:P.map((e,t)=>({label:`${b+t*r.size}-${b+(t+1)*r.size}`,value:e.value,secondary:e.secondary})),metadata:{kind:"event-drop",closedWindowCount:S,gutter:A.gutter,lidSegments:R,lateCount:P.reduce((e,t)=>e+t.secondary,0),plot:d.plot,windowPlot:A.windowPlot,watermarkValue:k,windowCount:v,windowSize:r.size,windowStart:b}}}({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:i,timeExtent:r.timeExtent,timeScale:r.timeScale??1});return{...o,config:s.config,initialSpawns:Cy(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:Ah(t||r.colorBy,"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.valueAccessor||r.timeAccessor||"time"})}}},UnitPileChart:{frameType:"physics",buildProps:(e,t,n,o,r)=>{const i=o.size??[600,400],s="mechanical"===r.mode,a=function(e){const{data:t,categoryAccessor:n,valueAccessor:o,unitValue:r,ballRadius:i,seed:s,size:a}=e,c=Ch(r,1),l=kh(a),u=[],d=new Map,h=new Map,f=[];function p(e){let t=d.get(e);return null==t&&(t=u.length,u.push(e),d.set(e,t)),t}t.forEach((e,t)=>{p((_h(e,t,n)??"unknown")+"")});const y=Math.max(1,u.length),g=function(e,t,n){const o=e.width/Math.max(1,t),r=Math.max(2,2*n),i=Math.min(.7*o,Math.max(3.2*r,r+8)),s=Math.max(1,Math.floor(i/r));return{laneWidth:o,tubeWidth:i,ballDiameter:r,perRow:s,centerX:t=>e.x+(t+.5)*o,pileHeight:e=>Math.ceil(Math.max(0,e)/s)*r}}(l.plot,y,i),m=Math.max(0,g.tubeWidth/2-i-1),x=u.map(()=>[]);t.forEach((e,t)=>{const r=(_h(e,t,n)??"unknown")+"",s=p(r),a=o?Ph(_h(e,t,o)):1,u=Math.max(0,Math.round((a??0)/c)),d=g.centerX(s);for(let n=0;u>n;n+=1){const o=h.get(r)??0,a=g.perRow>1?((g.perRow>1?o%g.perRow:0)/(g.perRow-1)*2-1)*m:0;h.set(r,o+1),x[s].push({id:`${(e.id??"pile-"+t)+""}-${n}`,x:d+a,y:l.plot.y+i+2,vx:(n%3-1)*i/2,vy:0,mass:1,shape:{type:"circle",radius:i},datum:{...e,category:r,unitIndex:n}})}});const b=x.reduce((e,t)=>Math.max(e,t.length),0);for(let e=0;b>e;e+=1)for(const t of x)t.length>e&&f.push(t[e]);const v=l.plot.y+l.plot.height,w=[...jf({x:l.plot.x,y:l.plot.y,width:l.plot.width,height:l.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],k=l.plot.y-400;for(let e=0;y>e;e+=1){const t=g.centerX(e);for(const n of[-1,1])w.push({id:`pile-tube-${e}-${0>n?"l":"r"}`,shape:{type:"aabb",x:t+n*g.tubeWidth/2,y:(k+v)/2,width:6,height:v-k}})}return{config:Mh(s,w,"UnitPileChart"),initialSpawns:f,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:u.map(e=>({label:e,value:h.get(e)??0}))}}({data:s?function(e={}){const t=(e.categories?.length?e.categories:["Intake","Review","Build","Ship"]).map(e=>(e+"").trim()).filter(Boolean),n=t.length?t:["Intake"],o=Math.max(n.length,Math.round(e.count??Math.max(48,12*n.length))),r=Ch(e.unitValue,1),i=Lh(e.seed??1),s=e.idPrefix??"mechanical-pile",a=n.map(()=>.65+.9*i()),c=a.reduce((e,t)=>e+t,0)||1,l=o-n.length,u=a.map(e=>e/c*l),d=u.map(e=>1+Math.floor(e));let h=o-d.reduce((e,t)=>e+t,0);const f=u.map((e,t)=>({index:t,fraction:e-Math.floor(e)})).sort((e,t)=>t.fraction-e.fraction);for(let e=0;h>0;e=(e+1)%f.length)d[f[e].index]+=1,h-=1;return n.map((e,t)=>({id:`${s}-${t}`,category:e,value:d[t]*r,mechanical:!0,unitCount:d[t],unitValue:r,share:d[t]/o}))}({categories:r.mechanicalCategories,count:r.mechanicalCount,seed:r.seed??1,unitValue:r.unitValue??1}):Array.isArray(e)?e:[],categoryAccessor:r.categoryAccessor||"category",valueAccessor:r.valueAccessor||(s?"value":void 0),unitValue:r.unitValue??1,ballRadius:r.ballRadius??5,seed:r.seed??1,size:i});return{...o,config:a.config,initialSpawns:Cy(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:Ah(t||r.colorBy||(s?"category":void 0),"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.valueAccessor||"value"})}}},CollisionSwarmChart:{frameType:"physics",buildProps:(e,t,n,o,r)=>{const i=o.size??[600,360],s=function(e){const{data:t,xAccessor:n,groupAccessor:o,radiusAccessor:r,pointRadius:i,seed:s,size:a,xExtent:c,collisionIterations:l,settle:u}=e,d=kh(a),h=Lh(s),f=[],p=[],y=new Map;t.forEach((e,t)=>{const s=Ph(_h(e,t,n));if(null==s)return;const a=o?(_h(e,t,o)??"All")+"":"All",c=r?Ph(_h(e,t,r)):null,l=jh(null!=c&&c>0?c:i,2,18);!function(e){let t=y.get(e);null==t&&(t=p.length,p.push(e),y.set(e,t))}(a),f.push({datum:e,index:t,value:s,group:a,radius:l})});const g=f.map(e=>e.value),m=c?Ph(c[0]):null,x=c?Ph(c[1]):null,b=g.length?Math.min(...g):0,v=g.length?Math.max(...g):1;let w=m??b,k=x??v;if(w===k&&(w-=.5,k+=.5),w>k){const e=k;k=w,w=e}const S=Math.max(i,...f.map(e=>e.radius)),A=d.plot.x+S+8,M=d.plot.x+d.plot.width-S-8,_=(0,Uf.scaleLinear)().domain([w,k]).range([A,M]),P=Math.max(1,p.length),j=Math.min(Math.max(28,3*S),d.plot.height/4),C=d.plot.y+j,R=Math.max(0,d.plot.y+d.plot.height-j-C),L=e=>{const t=y.get(e)??0;return 1===P?d.plot.y+.54*d.plot.height:C+t/(P-1)*R},I=new Map,T=f.map((e,t)=>{I.set(e.group,(I.get(e.group)??0)+1);const n=_(e.value),o=L(e.group),r=(h()-.5)*e.radius*1.6,i=(h()-.5)*e.radius*1.6;return{id:(e.datum.id??"collision-swarm-"+t)+"",x:u?n+r:jh(n+(t%9-4)*e.radius*2.5,A,M),y:u?o+i:d.plot.y-18-t%12*e.radius,vx:u?0:22*(h()-.5),vy:u?0:24+18*h(),mass:1,shape:{type:"circle",radius:e.radius},datum:{...e.datum,xValue:e.value,group:e.group,radius:e.radius,targetX:n,targetY:o},springs:[{target:{type:"point",x:n,y:o},restLength:0,stiffness:34,damping:5.5}]}});return{config:Mh(s,jf({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"collision-swarm",includeCeiling:!1,wallThickness:20,floorThickness:20}),"CollisionSwarmChart",{gravity:{x:0,y:0},cellSize:Math.max(24,4*S),collisionIterations:Math.max(1,Math.round(l??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:T,projectionRows:p.map(e=>({label:e,value:I.get(e)??0})),metadata:{kind:"collision-swarm",xExtent:[w,k],xRange:[A,M],groups:p.map(e=>({label:e,y:L(e),count:I.get(e)??0})),plot:d.plot}}}({data:Array.isArray(e)?e:[],xAccessor:r.xAccessor||"x",groupAccessor:r.groupAccessor,radiusAccessor:r.radiusAccessor,pointRadius:r.pointRadius??5,seed:r.seed??1,size:i,xExtent:r.xExtent,collisionIterations:r.collisionIterations,settle:r.settle});return{...o,config:s.config,initialSpawns:Cy(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:Ah(t||r.colorBy||r.groupAccessor,"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.xAccessor||"x"})}}},ProcessFlowChart:{frameType:"physics",buildProps:(e,t,n,o,r)=>{const i=o.size??[900,420],s=Array.isArray(r.stages)?r.stages:[],a=ap({data:Array.isArray(e)?e:[],stages:s,size:i,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}),c=a.metadata;return{...o,config:a.config,initialSpawns:Cy(a.initialSpawns),projectionRows:a.projectionRows,regionEffects:c?.regionEffects,bodyStyle:Ah(t||r.colorBy||r.groupBy,"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.workAccessor||r.stageAccessor||"stage"})}}},GauntletChart:{frameType:"physics",buildProps:(e,t,n,o,r)=>{const i=o.size??[900,520],s=Sp({data:Array.isArray(e)?e:[],size:i,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{...o,config:s.config,initialSpawns:Cy(s.initialSpawns),projectionRows:[],bodyStyle:Ah(t||r.colorBy)}}},CrucibleChart:{frameType:"physics",buildProps:(e,t,n,o,r)=>{const i=o.size??[900,520],s=py({data:Array.isArray(e)?e:[],phases:Array.isArray(r.phases)?r.phases:[],products:Array.isArray(r.products)?r.products:void 0,outlets:Array.isArray(r.outlets)?r.outlets:void 0,events:Array.isArray(r.events)?r.events:void 0,idAccessor:r.idAccessor,labelAccessor:r.labelAccessor,categoryAccessor:r.categoryAccessor,amountAccessor:r.amountAccessor,metricsAccessor:r.metricsAccessor,initialStateAccessor:r.initialStateAccessor,metrics:r.metrics,size:i,seed:r.seed,bodyRadius:"number"==typeof r.bodyRadius?r.bodyRadius:void 0,radiusRange:r.radiusRange}),a="snapshot"===r.playback?function(e,t){if(void 0===t)return e.duration;if("number"==typeof t)return Math.max(0,Math.min(e.duration,Kp(t)??0));const n=e.phases.find(e=>e.id===t.phaseId);if(!n)return e.duration;const o=Math.max(0,Math.min(1,Kp(t.progress??0)??0));return n.start+n.duration*o}(s,r.snapshotAt):s.duration,c=fy(s,a).state,l=r.projection&&"object"==typeof r.projection?r.projection:{groupBy:"outlet",measure:"count"},u=function(e,t={}){const n=t.groupBy??"outlet",o=new Map,r=e=>{const t=function(e,t){return"product"===t?"product"===e.kind?e.id:"unassigned":"outlet"===t?e.outletId??"unassigned":"category"===t?e.category:e.status}({...e,status:e.status??"active"},n),r=o.get(t);if(r)return r.count+=1,r.amount+=e.amount,void Ip(r.metrics,e.metrics);o.set(t,{key:t,label:"product"===n&&"product"===e.kind?e.label:t,count:1,amount:e.amount,metrics:{...e.metrics},status:"status"===n?e.status:void 0,outletId:"outlet"===n?e.outletId:void 0,category:"category"===n?e.category:void 0,productId:"product"===n&&"product"===e.kind?e.id:void 0})};for(const t of Object.values(e.components))t.productIds.length||"consumed"===t.status||r({kind:"component",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});for(const t of Object.values(e.products))r({kind:"product",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});const i=new Map((t.order??[]).map((e,t)=>[e,t]));return[...o.values()].sort((e,t)=>(i.get(e.key)??Number.MAX_SAFE_INTEGER)-(i.get(t.key)??Number.MAX_SAFE_INTEGER)||Mp(e.key,t.key))}(c,l),d=l.measure??"count",h=function(e,t={}){const n=t.bodies??[],o=Math.max(0,t.recentBodyLimit??6),r=new Map;for(const e of n){const n=t.getContainerId?.(e);if(!n)continue;const o=r.get(n);o?o.push(e):r.set(n,[e])}const i=e.map(e=>{const n=r.get(e.id)??[],i=Math.max(0,Math.floor(e.count??n.length)),s=n.slice(Math.max(0,n.length-o)).map(e=>({id:e.id,label:t.getBodyLabel?.(e)??jy(e),datum:e.datum}));return{id:e.id,label:e.label,count:i,share:0,secondary:e.secondary,secondaryLabel:e.secondaryLabel,observed:e.observed,bodyIds:n.map(e=>e.id),recentBodies:s,metadata:e.metadata}}),s=i.reduce((e,t)=>e+t.count,0);return i.map(e=>({...e,share:s>0?e.count/s:0}))}(u.map(e=>({id:e.key,label:e.label,count:e.count,secondary:"count"===d||"amount"===d?e.amount:Number(e.metrics[d]??0),secondaryLabel:"count"===d||"amount"===d?r.amountLabel??"amount":d,metadata:{amount:e.amount,metrics:e.metrics,status:e.status,outletId:e.outletId,category:e.category,productId:e.productId}}))),f={seed:r.seed,bodyRadius:"number"==typeof r.bodyRadius?r.bodyRadius:void 0,radiusRange:r.radiusRange},p=t??r.colorBy??"category",y=!1===r.showChrome?null:wh.createElement(_y,{layout:s.layout,phases:s.phases,state:c,compact:520>i[0]||360>i[1]}),g=!1===r.showProjection?null:wh.createElement(Py,{rows:u,layout:s.layout,projection:l,amountLabel:r.amountLabel});return{...o,config:s.config,initialSpawns:Cy(uy(c,s.layout,f)),projectionRows:h,bodyStyle:e=>function(e,t,n,o){const r=e.datum,i={stroke:o.stroke??("product"===r?.kind?"#fffaf0":"#26323a"),strokeWidth:o.strokeWidth??("product"===r?.kind?1.8:1.1),opacity:o.opacity??.96};if(!r?.__crucible)return{...i,fill:o.color??"#b8792d"};if("product"===r.kind){const e=t.products[r.semanticId];return{...i,fill:o.color??e?.color??Iy(e?.id??r.semanticId)}}const s=t.components[r.semanticId];if(!s)return{...i,fill:o.color??"#356b63"};let a;return a="status"===n?s.status:"outlet"===n?s.outletId??"in chamber":"product"===n?s.productIds[0]??"unalloyed":"category"===n||null==n?s.category:"function"==typeof n?(n(s.datum)??"unassigned")+"":(s.datum[n+""]??"unassigned")+"",{...i,fill:o.color??Iy(a)}}(e,c,p,r),getBodyLabel:e=>function(e,t){const n=e.datum;if(n?.__crucible)return"product"===n.kind?t.products[n.semanticId]?.label:t.components[n.semanticId]?.label}(e,c),renderBodySVG:xy,backgroundGraphics:Ry(y,o.backgroundGraphics),foregroundGraphics:Ry(g,o.foregroundGraphics)}}},PacketFlowChart:{frameType:"physics",buildProps:(e,t,n,o,r)=>{const i=o.size??[760,420],s=function(e){const{coordinateMode:t,flowSpeed:n,links:o,maxParticles:r,nodeIdAccessor:i,nodeXAccessor:s,nodeYAccessor:a,nodes:c,particleRadius:l,particleRate:u,pathAccessor:d,pathConstraint:h="path",reducedMotion:f,seed:p,size:y,sourceAccessor:g,targetAccessor:m,throughputAccessor:x}=e,b=kh(y),v=Lh(p),w=new Map,k=new Map,S=[];function A(e){if(e&&"object"==typeof e){const t=e;if("function"==typeof i){const e=i(t,0);if(null!=e)return e+""}if("string"==typeof i&&null!=t[i])return t[i]+"";if(null!=t.id)return t.id+""}return(e??"unknown")+""}c.forEach((e,t)=>{const n=(_h(e,t,i)??e.id??t)+"",o=Ph(_h(e,t,s)),r=Ph(_h(e,t,a));if(null!=o&&null!=r){const e={x:o,y:r};w.set(n,e),S.push(e)}k.set(n,(e.label??e.name??n)+"")});const M=[];o.forEach((e,t)=>{const n=A(_h(e,t,g)),o=A(_h(e,t,m)),r=Math.max(0,Ph(_h(e,t,x))??0),i=Zf(d?_h(e,t,d):void 0),s=i.length?i:Zf(e.path??e.points??e.route);s.forEach(e=>S.push(e)),M.push({id:(e.id??`physical-flow-${n}-${o}-${t}`)+"",link:e,index:t,source:n,target:o,throughput:r,rawPath:s})});const _=(j=S,"normalized"===(P=t)||"pixels"===P?P:j.length>0&&j.every(e=>!(0>e.x||e.x>1||0>e.y||e.y>1))?"normalized":"pixels");var P,j;const C=new Map;for(const[e,t]of w)C.set(e,Qf(t,b,_));const R=[];for(const e of M){let t=e.rawPath.map(e=>Qf(e,b,_));if(2>t.length){const n=C.get(e.source),o=C.get(e.target);n&&o&&(t=[n,o])}else C.has(e.source)||C.set(e.source,t[0]),C.has(e.target)||C.set(e.target,t[t.length-1]);t.length>=2&&e.throughput>0&&(k.has(e.source)||k.set(e.source,e.source),k.has(e.target)||k.set(e.target,e.target),R.push({...e,path:t,packetCount:0}))}const L=Ch(u,.12),I=Math.max(1,Math.round(r)),T=R.map(e=>Math.max(1,Math.round(e.throughput*L))),$=T.reduce((e,t)=>e+t,0),z=$>I?I/$:1;R.forEach((e,t)=>{e.packetCount=Math.max(1,Math.floor(T[t]*z))});let D=R.reduce((e,t)=>e+t.packetCount,0);for(;D>I;){const e=R.reduce((e,t,n)=>t.packetCount>1&&(-1===e||t.packetCount>R[e].packetCount)?n:e,-1);if(-1===e)break;R[e].packetCount-=1,D-=1}const E=new Map,O=new Map,F=[],B=Ch(n,90),N=Ch(l,4);R.forEach((e,t)=>{E.set(e.target,(E.get(e.target)??0)+e.throughput),O.set(e.source,(O.get(e.source)??0)+e.throughput);const n=Jf(e.path);for(let o=0;e.packetCount>o;o+=1){const r=(o+.5)/e.packetCount,i=f?r:jh(.12+.84*r+.04*(v()-.5),.04,.98),s=f?i:Math.max(0,i-(.18+.12*v())),a=ep(e.path,s),c=ep(e.path,i),l=tp(e.path,s),u={x:-l.y,y:l.x},d=(v()-.5)*N*1.5;F.push({id:`${e.id}-packet-${o}`,x:a.x+u.x*d,y:a.y+u.y*d,vx:f?0:l.x*B+10*(v()-.5),vy:f?0:l.y*B+10*(v()-.5),mass:.8,spawnAt:f?0:.04*t+o/32,shape:{type:"circle",radius:N},datum:{...e.link,source:e.source,target:e.target,throughput:e.throughput,packetIndex:o,packetCount:e.packetCount,routeProgress:i,flowPath:e.path,flowPathLength:n,flowRouteId:e.id,flowSpeed:B,sourceLabel:k.get(e.source)??e.source,targetLabel:k.get(e.target)??e.target},springs:"none"!==h&&f?[{target:{type:"point",x:c.x,y:c.y},restLength:.7*N,stiffness:26,damping:4.25}]:void 0})}});const W=Math.max(18,5*N),q=Array.from(C,([e,t])=>({nodeId:e,label:k.get(e)??e,sensorId:"physical-flow-node-"+Rh(e),point:t})),Y=q.map(e=>({id:e.sensorId,sensor:!0,shape:{type:"aabb",x:e.point.x,y:e.point.y,width:W,height:W}})),G=Object.fromEntries(q.map(e=>[e.sensorId,{binId:e.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),H=Mh(p,[...jf({x:b.plot.x,y:b.plot.y,width:b.plot.width,height:b.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...Y],"PacketFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*N),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});H.bodyLimit=I,H.eviction="oldest",H.observation={...H.observation,sensors:G};const V=Array.from(C,([e,t])=>({id:e,label:k.get(e)??e,x:t.x,y:t.y,sensorId:"physical-flow-node-"+Rh(e),incoming:E.get(e)??0,outgoing:O.get(e)??0})),X=R.map(e=>({id:e.id,source:e.source,target:e.target,sourceLabel:k.get(e.source)??e.source,targetLabel:k.get(e.target)??e.target,throughput:e.throughput,packetCount:e.packetCount,path:e.path}));return{config:H,initialSpawns:F,projectionRows:V.filter(e=>e.incoming>0||e.outgoing>0).map(e=>({label:e.label,value:e.incoming,secondary:e.outgoing})),metadata:{kind:"physical-flow",coordinateMode:_,particleCount:F.length,totalThroughput:R.reduce((e,t)=>e+t.throughput,0),plot:b.plot,nodes:V,links:X}}}({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:i});return{...o,config:s.config,initialSpawns:Cy(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:Ah(t||r.colorBy||"source")}}},PhysicsCustomChart:{frameType:"physics",buildProps:(e,t,n,o,r)=>{const i=o.size??[700,380],s=function(e){const t=function(e,t,n){const o=e?.observation;return{...e,observation:{...o,chartId:t??o?.chartId??"physics-custom",chartType:o?.chartType??"PhysicsCustomChart",onObservation:n??o?.onObservation}}}(e.config,e.chartId,e.onObservation),n=lp(e.colorScheme,e.themeCategorical,N),o=kh(e.size),r={data:e.data,scales:{x:(0,cp.scaleLinear)().domain(e.xExtent??[0,1]).range([o.plot.x,o.plot.x+o.plot.width]),y:(0,cp.scaleLinear)().domain(e.yExtent??[0,1]).range([o.plot.y+o.plot.height,o.plot.y])},dimensions:o,theme:{semantic:e.semantic,categorical:[...n]},resolveColor:up(n,e.colorScheme),config:e.layoutConfig??{},world:new Hf(t)},i=e.skipLayout?{}:e.layout(r)??{},s=function(e,t){if(!t?.length)return e;const n=new Map;for(const e of t){const{bodyId:t,...o}=e,r=n.get(t)??[];r.push(o),n.set(t,r)}return e.map(e=>{const t=n.get(e.id);return t?.length?{...e,springs:[...e.springs??[],...t]}:e})}([...i.initialSpawns??i.bodies??[]],i.constraints);return{config:dp(t,i),context:r,initialSpawnPacing:i.initialSpawnPacing,initialSpawns:s,result:i}}({chartId:r.chartId,colorScheme:n,config:r.config,data:Array.isArray(e)?e:[],layout:r.layout,layoutConfig:r.layoutConfig,semantic:qe(He)??{},size:i,themeCategorical:He.colors.categorical,xExtent:r.xExtent,yExtent:r.yExtent});return{...o,config:s.config,initialSpawns:Cy(s.initialSpawns),projectionRows:[],bodyStyle:s.result.bodyStyle??Ah(t||r.colorBy)}}}};function $y(e){const t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function zy(e){if(!e||2>e.length)return;const t=$y(e[0]),n=$y(e[e.length-1]);return null!==t&&null!==n?[t,n]:void 0}function Dy(e){const{count:t,byType:n}=function(e){const t={};for(const n of e){const e="string"==typeof n?.type&&n.type.length>0?n.type:"node";t[e]=(t[e]??0)+1}return{count:e.length,byType:t}}(e.marks),o=0===t,r=[...e.extraWarnings??[]];o&&!r.includes("EMPTY_SCENE")&&r.push("EMPTY_SCENE");const i=e.margin,s=i?{x:i.left,y:i.top,width:e.width-i.left-i.right,height:e.height-i.top-i.bottom}:void 0;return{component:"",frameType:e.frameType,status:o?"empty":"ok",empty:o,markCount:t,markCountByType:n,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,...i?{margin:i}:{},...s?{plot:s}:{}}}var Ey=y(require("react")),Oy=y(require("react-dom/server")),Fy=require("d3-scale"),By=require("react/jsx-runtime"),Ny=_r;function Wy(e,t,n){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;return t=>me(e,t)??"#999"}const o=Array.isArray(t)?t:n.colors.categorical.length>0?n.colors.categorical:N;return(0,Fy.scaleOrdinal)().domain(e).range(o)}function qy(e,t,n){if(0===e.length)return;const o=Wy(e,t,n);return{legendGroups:[{label:"",type:"fill",items:e.map(e=>({label:e})),styleFn:e=>({fill:o(e.label)})}]}}function Yy(e){return"left"===e?"start":"right"===e?"end":e??"start"}function Gy(e){return Number(e.typography.legendSize??e.typography.labelSize??e.typography.tickSize)||11}function Hy(e,t,n,o){const r=Gy(o);return t+n+Math.ceil(e.length*r*.58)}function Vy(e){const{categories:t,theme:n,position:o="right",totalWidth:r,margin:i,legendLayout:s}=e,{swatchSize:a,labelGap:c,itemGap:l,rowHeight:u}=Fr(s),d=a+c,h="top"===o||"bottom"===o,f=Math.max(a,r-i.left-i.right),p=t.map(e=>Hy(e,a,c,n));if(h){const e=Math.max(a,s?.maxWidth??f),n=[];let o=0,r=0;p.forEach((t,i)=>{const s=0===r?t:r+l+t;r>0&&s>e?(n.push({start:o,end:i,width:r}),o=i,r=t):r=s}),t.length>0&&n.push({start:o,end:t.length,width:r});const i=Yy(s?.align),c=[];return n.forEach((n,o)=>{let r="center"===i?Math.max(0,(e-n.width)/2):"end"===i?Math.max(0,e-n.width):0;for(let e=n.start;n.end>e;e++)c.push({category:t[e],width:p[e],x:r,y:o*u}),r+=p[e]+l}),{items:c,width:Math.max(0,...n.map(e=>e.width)),height:n.length*u,swatchSize:a,labelOffset:d,swatchRadius:0}}const y=Math.max(0,...p);return{items:t.map((e,t)=>({category:e,width:p[t],x:0,y:t*u})),width:y,height:t.length*u,swatchSize:a,labelOffset:d,swatchRadius:0}}function Xy(e){const{legendGroups:t,theme:n,position:o="right",totalWidth:r,margin:i,legendLayout:s}=e,{swatchSize:a,labelGap:c,rowHeight:l}=Fr(s),u=a+c,d=Math.max(12,Gy(n)),h="top"===o||"bottom"===o,f=Math.max(a,r-i.left-i.right);if(h){const o=Math.max(a,s?.maxWidth??f),r=Yy(s?.align);let i=0,c=0;const l=[];for(const r of t){const t=r.items.map(e=>e.label),u=Vy({...e,categories:t,legendLayout:{...s,maxWidth:Math.max(a,o-d-8),align:"start"}}),h=r.label?d:0,f=r.label?Hy(r.label,0,0,n):0,p=h>0?h+8:0,y=p+u.width,g=Math.max(u.height,f);l.push({group:r,x:i,y:0,itemOffsetX:p,itemOffsetY:0,width:y,height:g,items:u.items}),i+=y+12,c=Math.max(c,g)}const h=l.length>0?i-12:0,p=h>o?0:"center"===r?Math.max(0,(o-h)/2):"end"===r?Math.max(0,o-h):0;return{groups:l.map(e=>({...e,x:e.x+p})),width:h,height:c,swatchSize:a,labelOffset:u,swatchRadius:0}}const p=Br(t.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),l);let y=0;return{groups:t.map((e,t)=>{const o=e.items.map(e=>Hy(e.label,a,c,n)),r=Math.max(0,...o,e.label?Hy(e.label,0,0,n):0);return y=Math.max(y,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:o[t],x:0,y:t*l}))}}),width:y,height:p.at(-1)?.endY??0,swatchSize:a,labelOffset:u,swatchRadius:0}}function Uy(e){const t="top"===e.position||"bottom"===e.position,n=Math.max(1,e.totalWidth-e.margin.left-e.margin.right);return t?{width:Math.min(e.legendLayout?.maxWidth??n,200),height:e.gradient.label?34:26,swatchSize:12}:{width:e.gradient.label?86:72,height:e.gradient.label?124:108,swatchSize:14}}function Ky(e,t){if(!t||!e||0===e.length)return[];const n="function"==typeof t?t:e=>e[t],o=new Set;for(const t of e){const e=n(t);null!=e&&o.add(e+"")}return Array.from(o)}var Zy=require("react/jsx-runtime"),Qy=16,Jy=20;function eg(e,t){return e.color||t.colors.annotation||t.colors.text}function tg(e,t,n){const o=e.labelBackground,r=t.colors.background,i=r&&"transparent"!==r?r:t.colors.surface||r;return void 0===o?"none"===n?"none":{type:"halo",fill:i}:!1===o||"none"===o?"none":!0===o||"halo"===o?{type:"halo",fill:i}:"box"===o?{type:"box",fill:i}:{fill:i,...o}}function ng(e,t,n){return null!=e.x&&t.x?t.x(e.x):n&&null!=e[n]&&t.x?t.x(e[n]):"number"==typeof e.x?e.x:null}function og(e,t,n){return null!=e.y&&t.y?t.y(e.y):n&&null!=e[n]&&t.y?t.y(e[n]):"number"==typeof e.y?e.y:null}function rg(e){const{annotations:t}=e;if(!t||0===t.length)return null;const n=bs(t),o=e.scales.geoProjection,r=o?n.map(e=>{if(!Array.isArray(e.coordinates)||2>e.coordinates.length)return e;const t=o([Number(e.coordinates[0]),Number(e.coordinates[1])]);return t?{...e,x:t[0],y:t[1]}:e}):n,i=!!o&&!e.scales.x&&!e.scales.y,s=e=>Number(e),a=e.scales.x??(i?s:void 0),c=e.scales.y??(i?s:void 0),l=e.projection?"horizontal"===e.projection?"horizontal":"vertical":void 0,u={scales:{x:a,y:c,time:a,value:c,o:e.scales.o,...o?{geoProjection:o}:{}},width:e.layout.width,height:e.layout.height,xAccessor:e.xAccessor,yAccessor:e.yAccessor,data:e.annotationData,frameType:e.projection?"ordinal":o||e.scales.x||e.scales.y?"xy":"network",...l?{projection:l}:{}},d=Hi(e.autoPlaceAnnotations?xs({annotations:r,context:u,..."object"==typeof e.autoPlaceAnnotations?e.autoPlaceAnnotations:{}}):r,(t,n)=>function(e,t,n){const{scales:o,layout:r,theme:i,xAccessor:s,yAccessor:a}=n;switch(e.type){case"y-threshold":{const s=e.value;if(null==s)return null;const a=eg(e,i),c=e.label,l=e.labelPosition||"right",u=e.strokeDasharray||"6,4",d=e.strokeWidth??1.5;if("horizontal"===n.projection&&o.r){const n=o.r(s);return null==n?null:(0,Zy.jsxs)("g",{opacity:e.opacity,children:[(0,Zy.jsx)("line",{x1:n,y1:0,x2:n,y2:r.height,stroke:a,strokeWidth:d,strokeDasharray:u}),c&&(0,Zy.jsx)(qi,{x:n+4,y:Qy,textAnchor:"start",fontSize:i.typography.tickSize,fill:a,fontFamily:i.typography.fontFamily,text:c,background:tg(e,i,"halo")})]},"ann-ythresh-"+t)}const h=o.y?o.y(s):o.r?o.r(s):null;return null==h?null:(0,Zy.jsxs)("g",{children:[(0,Zy.jsx)("line",{x1:0,y1:h,x2:r.width,y2:h,stroke:a,strokeWidth:d,strokeDasharray:u}),c&&(0,Zy.jsx)(qi,{x:"left"===l?4:"center"===l?r.width/2:r.width-4,y:Jy>h?Math.min(r.height-4,h+Qy):h-6,textAnchor:"left"===l?"start":"center"===l?"middle":"end",fontSize:i.typography.tickSize,fill:a,fontFamily:i.typography.fontFamily,text:c,background:tg(e,i,"halo")})]},"ann-ythresh-"+t)}case"x-threshold":{const s=e.value;if(null==s)return null;const a="horizontal"===n.projection&&o.r?o.r(s):o.x?o.x(s):null;if(null==a)return null;const c=eg(e,i),l=e.label,u=e.labelPosition||"top";return(0,Zy.jsxs)("g",{opacity:e.opacity,children:[(0,Zy.jsx)("line",{x1:a,y1:0,x2:a,y2:r.height,stroke:c,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray||"6,4"}),l&&(0,Zy.jsx)(qi,{x:a>.6*r.width?a-4:a+4,y:"bottom"===u?r.height-4:"center"===u?r.height/2:Qy,textAnchor:a>.6*r.width?"end":"start",fontSize:i.typography.tickSize,fill:c,fontFamily:i.typography.fontFamily,text:l,background:tg(e,i,"halo")})]},"ann-xthresh-"+t)}case"band":{const n=o.y?.domain?.(),s=e.y0??n?.[0],a=e.y1??n?.[1],c=null!=s&&o.y?o.y(s):null,l=null!=a&&o.y?o.y(a):null;if(null==c||null==l)return null;const u=Math.min(c,l),d=Math.abs(l-c),h=Yo(e.fill||eg(e,i),"ssr-band-"+t),f=e.fillOpacity??.1;return(0,Zy.jsxs)("g",{opacity:e.opacity,children:[h.def&&(0,Zy.jsx)("defs",{children:h.def}),(0,Zy.jsx)("rect",{x:0,y:u,width:r.width,height:d,fill:h.fill,fillOpacity:f}),e.label&&(0,Zy.jsx)(qi,{x:r.width-4,y:Math.max(u,0)+Qy,textAnchor:"end",fontSize:i.typography.tickSize,fill:e.color||eg(e,i),fontFamily:i.typography.fontFamily,fontWeight:"bold",text:e.label,background:tg(e,i,"halo")})]},"ann-band-"+t)}case"x-band":{const n=o.x?.domain?.(),s=e.x0??n?.[0],a=e.x1??n?.[1],c=null!=s&&o.x?o.x(s):null,l=null!=a&&o.x?o.x(a):null;if(null==c||null==l)return null;const u=Math.min(c,l),d=Math.abs(l-c),h=Yo(e.fill||eg(e,i),"ssr-xband-"+t),f=e.fillOpacity??.1;return(0,Zy.jsxs)("g",{opacity:e.opacity,children:[h.def&&(0,Zy.jsx)("defs",{children:h.def}),(0,Zy.jsx)("rect",{x:u,y:0,width:d,height:r.height,fill:h.fill,fillOpacity:f}),e.label&&(0,Zy.jsx)(qi,{x:u+4,y:Qy,textAnchor:"start",fontSize:i.typography.tickSize,fill:e.color||i.colors.primary||eg(e,i),fontFamily:i.typography.fontFamily,fontWeight:"bold",text:e.label,background:tg(e,i,"halo")})]},"ann-xband-"+t)}case"category-highlight":{if(null==e.category||!o.o)return null;const s=o.o(e.category+"");if(null==s)return null;const a=o.o.bandwidth?o.o.bandwidth():40,c=eg(e,i),l=e.opacity??.1,u=e.label;return(0,Zy.jsxs)("g","horizontal"===n.projection?{children:[(0,Zy.jsx)("rect",{x:0,y:s,width:r.width,height:a,fill:c,opacity:l}),u&&(0,Zy.jsx)(qi,{x:12,y:s+a/2,dominantBaseline:"middle",fill:c,fontSize:i.typography.tickSize,fontWeight:"bold",fontFamily:i.typography.fontFamily,text:u,background:tg(e,i,"none")})]}:{children:[(0,Zy.jsx)("rect",{x:s,y:0,width:a,height:r.height,fill:c,opacity:l}),u&&(0,Zy.jsx)(qi,{x:s+a/2,y:Qy,textAnchor:"middle",fill:c,fontSize:i.typography.tickSize,fontWeight:"bold",fontFamily:i.typography.fontFamily,text:u,background:tg(e,i,"none")})]},"ann-cathighlight-"+t)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:n,y:r}=function(e,t,n,o){if(Array.isArray(e.coordinates)&&e.coordinates.length>=2&&t.geoProjection){const n=t.geoProjection([e.coordinates[0],e.coordinates[1]]);if(n)return{x:n[0],y:n[1]}}return{x:ng(e,t,n),y:og(e,t,o)}}(e,o,s,a);if(null==n||null==r)return null;const c="text"===e.type,l=e.dx??(c?0:30),u=e.dy??(c?0:-30),d=e.color||i.colors.text;if(!c){const o="callout"===e.type?"callout-circle":e.type,i="callout-circle"===o?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===o?{width:e.width,height:e.height}:void 0;return(0,Zy.jsx)(ui,{noteData:{x:n,y:r,dx:l,dy:u,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:o,...i?{subject:i}:{},connector:e.connector||{end:"arrow"},color:d,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-label-"+t)}return(0,Zy.jsx)("g",{children:(0,Zy.jsx)("text",{x:n+l,y:r+u,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||i.typography.labelSize,fill:d,fontFamily:i.typography.fontFamily,fontWeight:e.fontWeight,opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:e.label||e.title})},"ann-label-"+t)}default:return null}}(t,n,e),e.svgAnnotationRules,u);return d.length>0?(0,Zy.jsx)("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:d}):null}var ig=y(require("react")),sg=require("react/jsx-runtime");function ag(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){const t=e.id;return null==t?null:t+""}return null}function cg(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 n=`${e.chartType||""}:${e.title||""}:${Array.isArray(e.data)?e.data.length:0}`;let o=0;for(let e=0;n.length>e;e++)o=31*o+n.charCodeAt(e)|0;return"c"+(o>>>0).toString(36)}function lg(e,t,n){return vr(e.showLegend&&!e.__legendIncludesAutomatic?qy(t,e.colorScheme,n):void 0,e.legend)}var ug={right:110,left:110,top:50,bottom:80};function dg(e,t){if(e.__autoLegendMargin&&!hg(e,t))return ug[t]}function hg(e,t){const n=e.__explicitMargin;return"number"==typeof n||!(!n||"object"!=typeof n||"number"!=typeof n[t])}function fg(e,t){const{props:n,categories:o,theme:r,size:i,hasTitle:s}=t,a=n.legendPosition||"right",c={theme:r,position:a,size:i,hasTitle:s,legendLayout:n.legendLayout,axisChrome:n.axisChrome,minimumMargin:dg(n,a),preserveExplicitMargin:hg(n,a)};if(null!=n.legend){const t=lg(n,o,r);(wr(t)||kr(t))&&function(e,t){if(t.preserveExplicitMargin)return;const n=t.position||"right",o={theme:t.theme,position:n,totalWidth:t.size[0],totalHeight:t.size[1],margin:e,hasTitle:t.hasTitle,legendLayout:t.legendLayout},r=wr(t.legend)?function(e){const{width:t,height:n,swatchSize:o}=Xy(e);return{width:t,height:n,swatchSize:o}}({...o,legendGroups:t.legend.legendGroups}):kr(t.legend)?Uy({...o,gradient:t.legend.gradient}):null;if(!r)return;const i=Lr(t.legend),s=Math.max(t.minimumMargin??0,Or(t.legend,t.legendLayout)),a=Dr(t.axisChrome,t.legendLayout),c=Math.max(t.minimumMargin??0,i+r.height+(t.hasTitle?24:0)),l=Math.max(t.minimumMargin??0,a+i+r.height);"right"===n?e.right=Math.max(e.right,s):"left"===n?e.left=Math.max(e.left,s):"top"===n?e.top=Math.max(e.top,c):e.bottom=Math.max(e.bottom,l)}(e,{...c,legend:t})}else n.showLegend&&o.length>0&&function(e,t){if(0===t.categories.length)return;if(t.preserveExplicitMargin)return;const n=t.position||"right",o=function(e){const{width:t,height:n,swatchSize:o}=Vy(e);return{width:t,height:n,swatchSize:o}}({categories:t.categories,colorScheme:t.colorScheme,theme:t.theme,position:n,totalWidth:t.size[0],totalHeight:t.size[1],margin:e,hasTitle:t.hasTitle,legendLayout:t.legendLayout}),r=qy(t.categories,t.colorScheme,t.theme),i=Lr(r),s=Math.max(t.minimumMargin??0,Or(r,t.legendLayout)),a=Dr(t.axisChrome,t.legendLayout),c=Math.max(t.minimumMargin??0,i+o.height+(t.hasTitle?24:0)),l=Math.max(t.minimumMargin??0,a+i+o.height);"right"===n?e.right=Math.max(e.right,s):"left"===n?e.left=Math.max(e.left,s):"top"===n?e.top=Math.max(e.top,c):e.bottom=Math.max(e.bottom,l)}(e,{...c,categories:o,colorScheme:n.colorScheme});return a}function pg(e){const{props:t,categories:n,theme:o,size:r,margin:i,hasTitle:s}=e,a=t.legendPosition||"right",c={theme:o,position:a,size:r,margin:i,hasTitle:s,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix};if(null!=t.legend){const e=lg(t,n,o);if(ig.isValidElement(e))return e;const r=function(e,t){const n={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,axisChrome:t.axisChrome,legendDistance:wr(e)||kr(e)?e.legendDistance:void 0};return wr(e)?function(e){if(0===(t=e.legendGroups,t.flatMap(e=>e.items.map((t,n)=>({group:e,item:t,itemIndex:n,label:t.label})))).length)return null;var t;const n=Xy(e),o="top"===e.position||"bottom"===e.position,r={legendGroups:e.legendGroups,legendDistance:e.legendDistance},i=e.reservedWidth??Rr(r,e.legendLayout),s=Lr(r),a=Ir(e.legendLayout),c=Dr(e.axisChrome,e.legendLayout),l=Dr(void 0,e.legendLayout),u=e.theme.colors.grid||e.theme.colors.textSecondary;let d,h;if("left"===e.position?(d=e.margin.left-a-i-s,h=e.margin.top):"top"===e.position?(d=e.margin.left,h=e.margin.top-l-s-n.height):"bottom"===e.position?(d=e.margin.left,h=Math.max(e.totalHeight-e.margin.bottom+s,Math.min(e.totalHeight-e.margin.bottom+c+s,e.totalHeight-n.height))):(d=e.totalWidth-e.margin.right+a+s,h=e.margin.top),!o){const t=Br(e.legendGroups.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),Math.max(n.swatchSize,e.legendLayout?.rowHeight??Ny)),o=e.legendGroups.flatMap((o,r)=>{const s=t[r],a=o.type??"fill",c=[(0,By.jsx)("line",{x1:0,y1:s.lineY,x2:i,y2:s.lineY,stroke:"gray"},"legend-group-neatline-"+r)];return o.label&&null!=s.labelY&&c.push((0,By.jsx)("text",{y:s.labelY,fontSize:Gy(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:o.label},"legend-group-label-"+r)),c.push((0,By.jsx)("g",{transform:`translate(0,${s.itemsY})`,children:o.items.map((t,i)=>{const s=o.styleFn(t,i),c="function"==typeof a?a(t):"line"===a?(0,By.jsx)("line",{x1:0,y1:0,x2:n.swatchSize,y2:n.swatchSize,style:s}):(0,By.jsx)("rect",{width:n.swatchSize,height:n.swatchSize,rx:n.swatchRadius,style:s});return(0,By.jsxs)("g",{transform:`translate(0,${i*Math.max(n.swatchSize,e.legendLayout?.rowHeight??Ny)})`,children:[c,(0,By.jsx)("text",{x:n.labelOffset,y:n.swatchSize/2,dominantBaseline:"central",fontSize:Gy(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:t.label})]},`legend-${r}-${i}`)})},"legend-group-"+r)),c});return(0,By.jsx)("g",{className:"semiotic-legend",transform:`translate(${d},${h})`,"data-orientation":"vertical",children:o})}const f=n.groups.flatMap((t,r)=>{const{group:i}=t,s=i.type??"fill",a=[];if(i.label&&a.push((0,By.jsx)("text",o?{transform:`translate(${t.x},${t.y}) rotate(90)`,textAnchor:"start",fontSize:Gy(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:i.label}:{x:t.x,y:t.y+Gy(e.theme),fontSize:Gy(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:i.label},"legend-group-label-"+r)),a.push(...t.items.map((o,a)=>{const c=i.items[a],l=i.styleFn(c,a),u="function"==typeof s?s(c):"line"===s?(0,By.jsx)("line",{x1:0,y1:0,x2:n.swatchSize,y2:n.swatchSize,style:l}):(0,By.jsx)("rect",{width:n.swatchSize,height:n.swatchSize,rx:n.swatchRadius,style:l});return(0,By.jsxs)("g",{transform:`translate(${t.x+t.itemOffsetX+o.x},${t.y+t.itemOffsetY+o.y})`,children:[u,(0,By.jsx)("text",{x:n.labelOffset,y:n.swatchSize/2,dominantBaseline:"central",fontSize:Gy(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:o.category})]},`legend-${r}-${a}`)})),o&&n.groups.length-1>r){const e=t.x+t.width+6;a.push((0,By.jsx)("line",{x1:e,y1:0,x2:e,y2:n.height,stroke:u},"legend-group-separator-"+r))}return a});return(0,By.jsx)("g",{className:"semiotic-legend",transform:`translate(${d},${h})`,"data-orientation":o?"horizontal":"vertical",children:f})}({...n,legendGroups:e.legendGroups}):kr(e)?function(e){const t=Uy(e),n="top"===e.position||"bottom"===e.position,o={gradient:e.gradient,legendDistance:e.legendDistance},r=Rr(o),i=Lr(o),s=Ir(e.legendLayout),a=Dr(e.axisChrome,e.legendLayout),c=Dr(void 0,e.legendLayout),l=(e.idPrefix?e.idPrefix+"-":"")+"semiotic-static-gradient-legend",u=e.gradient.format||(e=>Math.round(100*e)/100+"");let d,h;"left"===e.position?(d=e.margin.left-s-r-i,h=e.margin.top):"top"===e.position?(d=e.margin.left,h=e.margin.top-c-i-t.height):"bottom"===e.position?(d=e.margin.left,h=Math.max(e.totalHeight-e.margin.bottom+i,Math.min(e.totalHeight-e.margin.bottom+a+i,e.totalHeight-t.height))):(d=e.totalWidth-e.margin.right+s+i,h=e.margin.top);const f=Array.from({length:17},(t,o)=>{const r=o/16;return(0,By.jsx)("stop",{offset:100*r+"%",stopColor:e.gradient.colorFn(n?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]))},o)});if(n){const n=12,o=e.gradient.label?0:void 0,r=e.gradient.label?8:0;return(0,By.jsxs)("g",{className:"semiotic-legend",transform:`translate(${d},${h})`,children:[(0,By.jsx)("defs",{children:(0,By.jsx)("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:f})}),e.gradient.label&&(0,By.jsx)("text",{x:t.width/2,y:o,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),(0,By.jsx)("rect",{x:0,y:r,width:t.width,height:n,fill:`url(#${l})`,rx:2}),(0,By.jsx)("text",{x:0,y:r+n+12,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:u(e.gradient.domain[0])}),(0,By.jsx)("text",{x:t.width,y:r+n+12,textAnchor:"end",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:u(e.gradient.domain[1])})]})}const p=e.gradient.label?-6:void 0;return(0,By.jsxs)("g",{className:"semiotic-legend",transform:`translate(${d},${h+(e.gradient.label?12:0)})`,children:[(0,By.jsx)("defs",{children:(0,By.jsx)("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:f})}),e.gradient.label&&(0,By.jsx)("text",{x:0,y:p,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),(0,By.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),(0,By.jsx)("text",{x:19,y:10,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:u(e.gradient.domain[1])}),(0,By.jsx)("text",{x:19,y:100,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:u(e.gradient.domain[0])})]})}({...n,gradient:e.gradient}):null}(e,c);return r||(wr(e)||kr(e)?null:e??null)}return t.showLegend&&0!==n.length?function(e){const{categories:t,colorScheme:n,theme:o,position:r="right",totalWidth:i,totalHeight:s,margin:a}=e;if(!t||0===t.length)return null;const c=Wy(t,n,o),l="top"===r||"bottom"===r,u=Vy(e),d=qy(t,n,o),h=e.reservedWidth??Rr(d,e.legendLayout),f="number"==typeof e.legendDistance?Math.max(0,e.legendDistance):Lr(d),p=Ir(e.legendLayout),y=Dr(e.axisChrome,e.legendLayout),g=Dr(void 0,e.legendLayout);let m,x;if("left"===r?(m=a.left-p-h-f,x=a.top):"top"===r?(m=a.left,x=a.top-g-f-u.height):"bottom"===r?(m=a.left,x=Math.max(s-a.bottom+f,Math.min(s-a.bottom+y+f,s-u.height))):(m=i-a.right+p+f,x=a.top),l){const e=u.items.map((e,t)=>(0,By.jsxs)("g",{transform:`translate(${e.x},${e.y})`,children:[(0,By.jsx)("rect",{width:u.swatchSize,height:u.swatchSize,fill:c(e.category),rx:u.swatchRadius}),(0,By.jsx)("text",{x:u.labelOffset,y:u.swatchSize/2,dominantBaseline:"central",fontSize:Gy(o),fill:o.colors.text,fontFamily:o.typography.fontFamily,children:e.category})]},"legend-"+t));return(0,By.jsx)("g",{className:"semiotic-legend",transform:`translate(${m},${x})`,children:e})}const b=Br([{hasLabel:!1,itemCount:t.length}],Math.max(u.swatchSize,e.legendLayout?.rowHeight??Ny))[0],v=u.items.map((e,t)=>(0,By.jsxs)("g",{transform:`translate(${e.x},${e.y+b.itemsY})`,children:[(0,By.jsx)("rect",{width:u.swatchSize,height:u.swatchSize,fill:c(e.category),rx:u.swatchRadius}),(0,By.jsx)("text",{x:u.labelOffset,y:u.swatchSize/2,dominantBaseline:"central",fontSize:Gy(o),fill:o.colors.text,fontFamily:o.typography.fontFamily,children:e.category})]},"legend-"+t));return(0,By.jsxs)("g",{className:"semiotic-legend",transform:`translate(${m},${x})`,children:[(0,By.jsx)("line",{x1:0,y1:b.lineY,x2:h,y2:b.lineY,stroke:"gray"}),v]})}({categories:n,colorScheme:t.colorScheme,theme:o,position:a,totalWidth:r[0],totalHeight:r[1],margin:i,hasTitle:s,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix}):null}function yg(e){return Math.round(100*e)/100+""}function gg(e,t){const n=et(t.theme),o=t.background??n.background,r=t.idPrefix?t.idPrefix+"-":"",i="string"==typeof t.title?t.title:void 0,s=i?r+"semiotic-title":void 0,a=t.description?r+"semiotic-desc":void 0,c=[s,a].filter(Boolean).join(" ")||void 0;return(0,sg.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className,width:t.width,height:t.height,role:"img","aria-labelledby":c,style:{fontFamily:n.fontFamily},children:[i&&(0,sg.jsx)("title",{id:s,children:i}),t.description&&(0,sg.jsx)("desc",{id:a,children:t.description}),t.defs&&(0,sg.jsx)("defs",{children:t.defs}),o&&"transparent"!==o&&(0,sg.jsx)("rect",{x:0,y:0,width:t.width,height:t.height,fill:o}),(0,sg.jsx)("g",{id:r+"data-area",transform:t.innerTransform,children:e}),i&&(0,sg.jsx)("text",{id:r+"chart-title",x:t.width/2,y:Bs,textAnchor:"middle",fontSize:n.titleSize,fontWeight:"bold",fill:n.text,fontFamily:n.fontFamily,children:i}),t.legend&&(0,sg.jsx)("g",{id:r+"legend",children:t.legend}),t.outerElements]})}var mg=require("react/jsx-runtime");function xg(e,t){const n=Je(e.theme),o=e.size||[500,300],r=qs({top:20,right:20,bottom:30,left:40,...e.margin},e.title),i=Ns(e.title),s=D(e.data),a=e.showLegend?Ky(s,e.colorAccessor||e.groupAccessor||e.categoryAccessor):[],c={hasAxis:!1!==e.showAxes,hasAxisLabel:!!e.xLabel};fg(r,{props:{...e,axisChrome:c},categories:a,theme:n,size:o,hasTitle:i});const l=o[0]-r.left-r.right,u=o[1]-r.top-r.bottom,d="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),h=e.colorScheme||n.colors.categorical,f={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,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:Te(e.gradientFill),lineGradient:$e(e.lineGradient),semanticLineStops:e.semanticLineStops,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:n.colors.categorical,themeSemantic:qe(n),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:r,layoutSelection:e.layoutSelection,barColors:e.barColors,showValues:e.showValues,heatmapValueFormat:e.heatmapValueFormat},p=new io(f);if(e.data&&p.ingest({inserts:s,bounded:!0}),p.computeScene({width:l,height:u}),!p.scales||0===p.scene.length)return t&&(t.evidence=Dy({frameType:"xy",width:o[0],height:o[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:p.scales?[]:["NO_SCALES"],margin:r})),Oy.renderToStaticMarkup(gg(null,{width:o[0],height:o[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left},${r.top})`,innerWidth:l,innerHeight:u,idPrefix:e._idPrefix}));const y=e._idPrefix,g=Pl({nodes:p.scene,renderMode:e.renderMode,fallback:(e,t)=>Sa(e,t,y)});t&&(t.evidence=Dy({frameType:"xy",width:o[0],height:o[1],marks:g.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,xDomain:zy(p.scales.x?.domain?.()),yDomain:zy(p.scales.y?.domain?.()),legendItems:a.length>0?a.length:void 0,margin:r}));const m=e.showGrid?function(e,t,n,o,r){const{grid:i}=et(n),s=o?o+"-":"",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=Ls(e.x,a,r),u=Ls(e.y,c,r);return(0,sg.jsxs)("g",{id:s+"grid",className:"semiotic-grid",opacity:.8,children:[l.map((n,o)=>{const r=e.x(n);return(0,sg.jsx)("line",{x1:r,y1:0,x2:r,y2:t.height,stroke:i,strokeWidth:.5},"gx-"+o)}),u.map((n,o)=>{const r=e.y(n);return(0,sg.jsx)("line",{x1:0,y1:r,x2:t.width,y2:r,stroke:i,strokeWidth:.5},"gy-"+o)})]})}(p.scales,{width:l,height:u},n,y,e.axisExtent):null,x=g.map(e=>e.element),b=cg(e)+"-plot-clip",v=!1!==e.showAxes?function(e,t,n,o,r){const i=et(o),s=Ir(n.legendLayout),a=n.legend&&"left"===n.legendPosition&&s>0?s:n.margin?.left??40,c="exact"===n.axisExtent?5:Math.min(5,Math.max(2,Math.floor(t.width/70))),l="exact"===n.axisExtent?5:Math.min(5,Math.max(2,Math.floor(t.height/30))),u=n.axes?.find(e=>"bottom"===e.orient),d=n.axes?.find(e=>"left"===e.orient),h=u?.tickValues??Ls(e.x,u?.ticks??c,n.axisExtent),f=h.map(e=>e.valueOf()),p=u?.tickFormat||n.xFormat||n.tickFormatTime||yg,y=h.map((t,n)=>({pixel:e.x(t),label:p(t,n,f)})),g=d?.tickValues??Ls(e.y,d?.ticks??l,n.axisExtent),m=d?.tickFormat||n.yFormat||n.tickFormatValue||yg,x=g.map(t=>({pixel:e.y(t),label:m(t)})),b=u?.label??n.xLabel,v=d?.label??n.yLabel;return(0,sg.jsxs)("g",{id:(r?r+"-":"")+"axes",className:"stream-axes",children:[!1!==u?.baseline&&(0,sg.jsx)("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:i.border,strokeWidth:1}),y.map((e,n)=>(0,sg.jsxs)("g",{transform:`translate(${e.pixel},${t.height})`,children:[(0,sg.jsx)("line",{y2:5,stroke:i.border,strokeWidth:1}),(0,sg.jsx)("text",{y:18,textAnchor:"middle",fontSize:i.tickSize,fill:i.textSecondary,fontFamily:i.fontFamily,children:e.label})]},"xtick-"+n)),b&&(0,sg.jsx)("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:i.labelSize,fill:i.text,fontFamily:i.fontFamily,children:b}),!1!==d?.baseline&&(0,sg.jsx)("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:i.border,strokeWidth:1}),x.map((e,t)=>(0,sg.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,sg.jsx)("line",{x2:-5,stroke:i.border,strokeWidth:1}),(0,sg.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:i.tickSize,fill:i.textSecondary,fontFamily:i.fontFamily,children:e.label})]},"ytick-"+t)),v&&(0,sg.jsx)("text",{x:15-a,y:t.height/2,textAnchor:"middle",fontSize:i.labelSize,fill:i.text,fontFamily:i.fontFamily,transform:`rotate(-90, ${15-a}, ${t.height/2})`,children:v})]})}(p.scales,{width:l,height:u},e,n,y):null,w=e.annotations?rg({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:s,scales:{x:p.scales.x,y:p.scales.y},layout:{width:l,height:u},theme:n,xAccessor:"string"==typeof e.xAccessor?e.xAccessor:void 0,yAccessor:"string"==typeof e.yAccessor?e.yAccessor:void 0,idPrefix:y}):null,k=e.svgPreRenderers&&p.scales?e.svgPreRenderers.map((e,t)=>{try{return(0,mg.jsx)(Ey.Fragment,{children:e(p.scene,p.scales,{width:l,height:u})},"pre-"+t)}catch{return null}}).filter(Boolean):null,S=pg({props:{...e,axisChrome:c},categories:a,theme:n,size:o,margin:r,hasTitle:i});return Oy.renderToStaticMarkup(gg((0,mg.jsxs)(mg.Fragment,{children:[e.backgroundGraphics,k,m,(0,mg.jsx)("defs",{children:(0,mg.jsx)("clipPath",{id:b,children:(0,mg.jsx)("rect",{x:0,y:0,width:l,height:u})})}),(0,mg.jsx)("g",{clipPath:`url(#${b})`,children:x}),v,w,e.foregroundGraphics,p.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left},${r.top})`,innerWidth:l,innerHeight:u,legend:S,idPrefix:e._idPrefix}))}var bg=y(require("react-dom/server")),vg=require("d3-scale"),wg=class{constructor(){this.colorSchemeMap=new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(e,t,n){if(t&&"function"==typeof e.pieceStyle){const o=e.pieceStyle(t,n);return o&&!o.fill&&n?{...o,fill:this.getColorFromScheme(e,n)}:o}return e.pieceStyle&&"object"==typeof e.pieceStyle?e.pieceStyle:e.barColors&&n?{fill:e.barColors[n]||"#007bff"}:{fill:n?this.getColorFromScheme(e,n):"#007bff"}}resolveSummaryStyle(e,t,n){return t&&"function"==typeof e.summaryStyle?e.summaryStyle(t,n):e.summaryStyle&&"object"==typeof e.summaryStyle?e.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(e,t){const n=this.colorSchemeMap.get(t);if(n)return n;const o=Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical||fe,r=o[this.colorSchemeIndex%o.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(t,r),r}};function kg(e){const t=e.getSymbol;if(!t)return null;const n=e.config.symbolMap,o=new Map;let r=0;return e=>{const i=t(e)+"",s=n?.[i];if(s)return s;let a=o.get(i);return a||(a=hn[r%hn.length],r++,o.set(i,a)),a}}function Sg(e,t,n,o,r,i,s){e.push(t?{type:"symbol",x:o,y:r,size:Math.PI*i*i,symbolType:t(n),style:s,datum:n}:{type:"point",x:o,y:r,r:i,style:s,datum:n})}function Ag(e,t){const{columns:n,config:o,resolvePieceStyle:r}=e,i=[],s=Math.min(t.width,t.height)/2-4,a="donut"===o.chartType?o.innerRadius||60:0,c=-Math.PI/2+(o.startAngle||0)*Math.PI/180,l=null!=o.sweepAngle?o.sweepAngle*Math.PI/180:2*Math.PI,u=null!=o.sweepAngle&&360>o.sweepAngle,d=Object.values(n),h=d.some(e=>{const t=e.pieceData[0];return t&&("number"==typeof t._pct||"number"==typeof t._pctStart||null!=t._roundedEnds)}),f=u&&!h&&d.length>1&&(o.cornerRadius??0)>0;for(let e=0;d.length>e;e++){const t=d[e],n=t.pieceData[0],u="number"==typeof n?._pctStart?n._pctStart:t.pctStart,h=c+u*l,p=c+(u+("number"==typeof n?._pct?n._pct:t.pct))*l,y=r(t.pieceData[0],t.name),g=0===e,m=e===d.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:h,endAngle:p,...o.cornerRadius&&{cornerRadius:o.cornerRadius},style:y,datum:n?._nonInteractive?null:t.pieceData,category:t.name};n?._roundedEnds?x.roundedEnds=n._roundedEnds:f&&(x.roundedEnds={start:g,end:m}),n?._gradientBand&&(x._gradientBand=n._gradientBand),i.push(x)}return i}var Mg=require("d3-array");function _g(e){const t=e.length,n=e[0],o=e[t-1];return{n:t,min:n,q1:(0,Mg.quantile)(e,.25)??n,median:(0,Mg.quantile)(e,.5)??(n+o)/2,q3:(0,Mg.quantile)(e,.75)??o,max:o,mean:e.reduce((e,t)=>e+t,0)/t}}var Pg=require("d3-scale"),jg={bar:function(e,t){const{scales:n,columns:o,config:r,getR:i,getStack:s,resolvePieceStyle:a}=e,{r:c,projection:l}=n,u=[],d="vertical"===l,h="horizontal"===l,f=r.normalize,p=[];if(s){const e=new Set;for(const t of Object.values(o))for(const n of t.pieceData){const t=s(n);e.has(t)||(e.add(t),p.push(t))}}else p.push("_default");for(const e of Object.values(o)){const t=new Map;for(const n of e.pieceData){const e=s?s(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const o=t.get(e);o.total+=i(n),o.pieces.push(n)}let n=0;if(f)for(const e of t.values())n+=Math.abs(e.total);let o=0,r=0;for(const i of p){const l=t.get(i);if(!l)continue;let p=l.total;f&&n>0&&(p/=n);const y=a(l.pieces[0],s?i:e.name),g={...l.pieces[0],__aggregateValue:l.total,__pieceCount:l.pieces.length,category:e.name};if(d){const t=c(0>p?r:o+p),n=0>p?c(r+p)-c(r):c(o)-c(o+p);u.push(Qt(e.x,t,e.width,Math.abs(n),y,g,i)),0>p?r+=p:o+=p}else if(h){const t=c(0>p?r+p:o),n=0>p?c(r)-c(r+p):c(o+p)-c(o);u.push(Qt(t,e.x,Math.abs(n),e.width,y,g,i)),0>p?r+=p:o+=p}}}const y="vertical"===l,g=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=y?0>t?"bottom":"top":0>t?"left":"right",r.gradientFill&&(e.fillGradient=r.gradientFill)}if(g>0){const e=new Map;for(const t of u){if("rect"!==t.type)continue;const n=t.datum?.category||"";e.has(n)||e.set(n,[]),e.get(n).push(t)}for(const t of e.values()){if(0===t.length)continue;const e=t.filter(e=>(e.datum?.__aggregateValue??0)>=0),n=t.filter(e=>0>(e.datum?.__aggregateValue??0));e.length>0&&(e.reduce(y?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t).roundedTop=g),n.length>0&&(n.reduce(y?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t).roundedTop=g)}}return u},clusterbar:function(e,t){const{scales:n,columns:o,config:r,getR:i,getGroup:s,resolvePieceStyle:a}=e,{r:c,projection:l}=n,u=[],d="vertical"===l,h=[],f=new Set;for(const e of Object.values(o))for(const t of e.pieceData){const e=s?s(t):"_default";f.has(e)||(f.add(e),h.push(e))}const p=h.length||1;for(const e of Object.values(o)){const t=e.width/p,n=.2*t,o=t-n,r=new Map;for(const t of e.pieceData){const e=s?s(t):"_default";r.has(e)||r.set(e,[]),r.get(e).push(t)}for(let s=0;h.length>s;s++){const l=r.get(h[s])||[];for(const r of l){const l=i(r),f=a(r,h[s]);if(d){const i=e.x+s*t+n/2,a=c(0),d=c(l);u.push(Qt(i,Math.min(a,d),o,Math.abs(a-d),f,r,h[s]))}else{const i=e.x+s*t+n/2,a=c(0),d=c(l);u.push(Qt(Math.min(a,d),i,Math.abs(d-a),o,f,r,h[s]))}}}}const y=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=i(e.datum);y>0&&(e.roundedTop=y),e.roundedEdge=d?0>t?"bottom":"top":0>t?"left":"right",r.gradientFill&&(e.fillGradient=r.gradientFill)}return u},point:function(e,t){const{scales:n,columns:o,getR:r,multiScales:i,resolvePieceStyle:s}=e,{r:a,projection:c}=n,l=[],u="vertical"===c,d="radial"===c,h=i.length>0,f=kg(e),p=2*Math.PI,y=-Math.PI/2;for(const e of Object.values(o))for(const t of e.pieceData){const n=t.__rIndex??0,o=t.__rValue??r(t),c=h&&i[n]||a,g=s(t,e.name),m=g.r||5;let x,b;if(d){const t=y+(e.pctStart+e.pct/2)*p,n=c(o);x=Math.cos(t)*n,b=Math.sin(t)*n}else u?(x=e.middle,b=c(o)):(x=c(o),b=e.middle);Sg(l,f,t,x,b,m,g)}return l},swarm:function(e,t){const{scales:n,columns:o,getR:r,resolvePieceStyle:i}=e,{r:s,projection:a}=n,c=[],l="vertical"===a,u=kg(e);for(const e of Object.values(o)){const t=e.width/2;for(let n=0;e.pieceData.length>n;n++){const o=e.pieceData[n],a=r(o),d=i(o,e.name),h=d.r||4,f=(7919*n%100/100-.5)*t*.8;Sg(c,u,o,l?e.middle+f:s(a),l?s(a):e.middle+f,h,d)}}return c},pie:Ag,donut:Ag,boxplot:function(e,t){const{scales:n,columns:o,config:r,getR:i,resolveSummaryStyle:s}=e,{r:a,projection:c}=n,l=[],u="vertical"===c,d=!1!==r.showOutliers;for(const t of Object.values(o)){const n=t.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===n.length)continue;const o=n[0],r=n[n.length-1],c=(0,Mg.quantile)(n,.25)??o,h=(0,Mg.quantile)(n,.5)??(o+r)/2,f=(0,Mg.quantile)(n,.75)??r,p=f-c,y=c-1.5*p,g=f+1.5*p,m=n.find(e=>e>=y)??o,x=[...n].reverse().find(e=>g>=e)??r,b=s(t.pieceData[0],t.name),v=[];if(d)for(const e of t.pieceData){const n=i(e);if(y>n||n>g){const o=u?t.middle:a(n),r=u?a(n):t.middle;v.push({px:o,py:r,value:n,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(h),q3Pos:a(f),maxPos:a(x),stats:{n:n.length,min:m,q1:c,median:h,q3:f,max:x,mean:n.reduce((e,t)=>e+t,0)/n.length},style:b,datum:t.pieceData,category:t.name,outliers:v}),d)for(const t of v)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:n,columns:o,config:r,getR:i,resolveSummaryStyle:s}=e,{r:a,projection:c}=n,l=[],u="vertical"===c,d=r.bins||20,h=!1!==r.showIQR;for(const e of Object.values(o)){const t=e.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const n=t[0],o=t[t.length-1],r=(o-n)/d||1,c=Array(d).fill(0);for(const e of t)c[Math.min(Math.floor((e-n)/r),d-1)]++;const f=we(c,1),p=e.width/2*.9;let y;if(u){y=`M ${e.middle} ${a(n)}`;for(let t=0;d>t;t++){const o=a(n+(t+.5)*r);y+=` L ${e.middle+c[t]/f*p} ${o}`}y+=` L ${e.middle} ${a(o)}`;for(let t=d-1;t>=0;t--){const o=a(n+(t+.5)*r);y+=` L ${e.middle-c[t]/f*p} ${o}`}y+=" Z"}else{y=`M ${a(n)} ${e.middle}`;for(let t=0;d>t;t++)y+=` L ${a(n+(t+.5)*r)} ${e.middle-c[t]/f*p}`;y+=` L ${a(o)} ${e.middle}`;for(let t=d-1;t>=0;t--)y+=` L ${a(n+(t+.5)*r)} ${e.middle+c[t]/f*p}`;y+=" Z"}const g=s(e.pieceData[0],e.name);let m;if(h&&t.length>=4){const r=(0,Mg.quantile)(t,.25)??n,i=(0,Mg.quantile)(t,.5)??(n+o)/2,s=(0,Mg.quantile)(t,.75)??o;m={q1Pos:a(r),medianPos:a(i),q3Pos:a(s),centerPos:e.middle,isVertical:u}}const x=u?{x:e.x,y:Math.min(a(o),a(n)),width:e.width,height:Math.abs(a(o)-a(n))}:{x:Math.min(a(n),a(o)),y:e.x,width:Math.abs(a(o)-a(n)),height:e.width};l.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:x,iqrLine:m,stats:_g(t),style:g,datum:e.pieceData,category:e.name})}return l},histogram:function(e,t){const{scales:n,columns:o,config:r,getR:i,resolveSummaryStyle:s}=e,{r:a}=n,c=[],l=r.bins||25,u=r.normalize,d=a.domain?.(),h=d?+d[0]:void 0,f=d?+d[1]:void 0;for(const e of Object.values(o)){const t=e.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const[n,o]=ve(t),r=null!=h&&isFinite(h)?h:n,d=null!=f&&isFinite(f)?f:o,p=(d-r)/l||1,y=Array(l).fill(0);for(const e of t)r>e||e>d||y[Math.min(Math.floor((e-r)/p),l-1)]++;const g=t.length,m=we(y,1),x=s(e.pieceData[0],e.name);for(let t=0;l>t;t++){if(0===y[t])continue;const n=(u?y[t]/g:y[t]/m)*e.width*.9,o=a(r+t*p),i=a(r+(t+1)*p);c.push(Qt(Math.min(o,i),e.x+e.width-n,Math.abs(i-o),n,x,{bin:t,count:y[t],range:[r+t*p,r+(t+1)*p],category:e.name},e.name))}}return c},ridgeline:function(e,t){const{scales:n,columns:o,config:r,getR:i,resolveSummaryStyle:s}=e,{r:a,projection:c}=n,l=[],u=r.bins||20,d="horizontal"===c,h=r.amplitude||1.5;for(const e of Object.values(o)){const t=e.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const n=t[0],o=t[t.length-1],r=(o-n)/u||1,c=Array(u).fill(0);for(const e of t)n>e||e>o||c[Math.min(Math.floor((e-n)/r),u-1)]++;const f=we(c,1),p=s(e.pieceData[0],e.name),y=e.width*h;let g;if(d){const t=e.x+e.width;g=`M ${a(n)} ${t}`;for(let e=0;u>e;e++)g+=` L ${a(n+(e+.5)*r)} ${t-c[e]/f*y}`;g+=` L ${a(o)} ${t} Z`}else{const t=e.x;g=`M ${t} ${a(n)}`;for(let e=0;u>e;e++){const o=a(n+(e+.5)*r);g+=` L ${t+c[e]/f*y} ${o}`}g+=` L ${t} ${a(o)} Z`}const m=d?{x:Math.min(a(n),a(o)),y:e.x,width:Math.abs(a(o)-a(n)),height:e.width}:{x:e.x,y:Math.min(a(o),a(n)),width:e.width,height:Math.abs(a(o)-a(n))};l.push({type:"violin",pathString:g,translateX:0,translateY:0,bounds:m,stats:_g(t),style:{...p,fillOpacity:p.fillOpacity??.5},datum:e.pieceData,category:e.name})}return l},timeline:function(e,t){const{scales:n,columns:o,getRawRange:r,resolvePieceStyle:i}=e,{r:s,projection:a}=n,c=[],l="horizontal"===a;for(const e of Object.values(o))for(const t of e.pieceData){const n=r(t);if(!n)continue;const[o,a]=n,u=i(t,e.name);if(l){const n=s(Math.min(o,a)),r=s(Math.max(o,a));c.push(Qt(n,e.x,r-n,e.width,u,t,e.name))}else{const n=s(Math.max(o,a)),r=s(Math.min(o,a));c.push(Qt(e.x,n,e.width,r-n,u,t,e.name))}}return c},funnel:function(e,t){const{columns:n,getR:o,getStack:r,resolvePieceStyle:i}=e,s=[],a=t.width/2,c=!1!==e.config.showLabels,l=e.scales.o.domain().map(e=>n[e]).filter(Boolean);if(0===l.length)return s;const u=[],d=new Set;for(const e of l)for(const t of e.pieceData){const e=r?r(t):"_default";d.has(e)||(d.add(e),u.push(e))}const h=u.length>1&&"_default"!==u[0],f=[];let p=0;for(const e of l){const t=new Map;let n=0;for(const i of e.pieceData){const e=r?r(i):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const s=t.get(e),a=o(i);s.total+=a,s.pieces.push(i),n+=a}f.push({col:e,groups:t,stepTotal:n}),h||n>p&&(p=n)}if(h)for(const e of f){let t=0,n=0;for(let o=0;u.length>o;o++){const r=e.groups.get(u[o]);r&&(o%2==0?t+=r.total:n+=r.total)}const o=Math.max(t,n);o>p&&(p=o)}if(0===p)return s;const y=new Map;for(const e of u){const t=f[0].groups.get(e);y.set(e,t?.total??0)}const g=f[0].stepTotal,m=h?.95*a:.9*t.width,x=(0,Pg.scaleLinear)().domain([0,p]).range([0,m]),b=e.config.connectorOpacity??.3;let v=new Map;for(let t=0;f.length>t;t++){const n=f[t],o=n.col,r=0===t,l=o.width,d=.55*l,p=o.x+(l-d)/2,m=new Map;if(h){let e=0;for(const t of u){const o=n.groups.get(t);o&&(e+=x(o.total))}let t=a,l=a;for(let h=0;u.length>h;h++){const f=u[h],g=n.groups.get(f);if(!g)continue;const b=x(g.total),v=h%2==0,w=v?t:l-b;v?t+=b:l-=b;const k=i(g.pieces[0],f),S=y.get(f)??g.total,A={...g.pieces[0],__funnelValue:g.total,__funnelPercent:S>0?g.total/S*100:0,__funnelStep:o.name,__funnelIsFirstStep:r,__aggregateValue:g.total,__pieceCount:g.pieces.length,category:f};c&&(0===h&&(A.__funnelStepLabel=o.name,A.__funnelStepLabelX=a,A.__funnelStepLabelY=p,A.__funnelRowWidth=e),A.__funnelValueLabelX=w+b/2,A.__funnelValueLabelY=p,A.__funnelBarW=b),s.push(Qt(w,p,b,d,k,A,f)),m.set(f,{x:w,y:p,w:b,h:d})}}else{const e=n.stepTotal,t=x(e),l=a-t/2,h=u[0],f="_default"!==h,y=n.groups.get(h)?.pieces[0]??o.pieceData[0],b=f?h:o.name,v=i(y,b),w=g>0?e/g*100:0,k={...y,__funnelValue:e,__funnelPercent:w,__funnelStep:o.name,__funnelIsFirstStep:r,category:f?h:o.name};c&&(k.__funnelStepLabel=o.name,k.__funnelStepLabelX=a,k.__funnelStepLabelY=p,k.__funnelRowWidth=t,k.__funnelValueLabelX=a,k.__funnelValueLabelY=p,k.__funnelBarW=t),s.push(Qt(l,p,t,d,v,k,b)),m.set(h,{x:l,y:p,w:t,h:d})}if(t>0&&v.size>0){const t=h?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=n.groups.get(r);return i(e?e.pieces[0]:o.pieceData[0],"_default"===r?o.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:b},datum:n.groups.get(r)?.pieces[0]??o.pieceData[0],category:"_default"===r?o.name:r};s.push(l)}}v=m}return s},"bar-funnel":function(e,t){const{columns:n,getR:o,getStack:r,resolvePieceStyle:i,scales:s}=e,a=[],c=s.o.domain().map(e=>n[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 d=l.length>1&&"_default"!==l[0],h=[];for(const e of c){const t=new Map;let n=0;for(const i of e.pieceData){const e=r?r(i):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const s=t.get(e),a=o(i);s.total+=a,s.pieces.push(i),n+=a}h.push({col:e,groups:t,stepTotal:n})}const f=new Map;for(const e of l){const t=h[0]?.groups.get(e);f.set(e,t?.total??0)}const p=s.r,y=d?l.length:1,g=d?.15:0;for(let e=0;h.length>e;e++){const t=h[e],n=t.col,o=0===e,r=e>0?h[e-1]:null,s=n.width/y,c=s*g,u=s-c;for(let e=0;l.length>e;e++){const h=l[e],y=t.groups.get(h);if(!y)continue;const g=y.total,m=f.get(h)??g,x=m>0?g/m*100:0,b=r?.groups.get(h),v=o?0:Math.max(0,(b?.total??g)-g),w=n.x+e*s+c/2,k=p(g),S=p(0)-k,A=i(y.pieces[0],d?h:n.name),M={...y.pieces[0],__barFunnelValue:g,__barFunnelPercent:x,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:n.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:n.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:p(g+v)};if(a.push(Qt(w,k,u,S,A,M,d?h:n.name)),v>0){const e=p(g+v),t=k-e,o={...A},r={...y.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:n.name,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:n.name};a.push(Qt(w,e,u,t,o,r,d?h:n.name))}}}return a},swimlane:function(e,t){const{scales:n,columns:o,getR:r,getStack:i,resolvePieceStyle:s}=e,{r:a,projection:c}=n,l=[],u="horizontal"===c,d=e.config.gradientFill,h=u?"left":"bottom",f=e.config.trackFill;if(f){const e="string"==typeof f?f:f.color,t="string"==typeof f?1:f.opacity??1,[n,r]=a.range(),i=Math.min(n,r),s=Math.abs(r-n);for(const n of Object.values(o)){const o={fill:e,opacity:t},r=u?Qt(i,n.x,s,n.width,o,null,"__track__"):Qt(n.x,i,n.width,s,o,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(o)){let t=0;const n=l.length;for(const n of e.pieceData){const o=Math.abs(r(n));if(0===o)continue;const c=i?i(n):e.name,f=s(n,c);let p;if(u){const r=a(t),i=a(t+o);p=Qt(r,e.x,i-r,e.width,f,n,c)}else{const r=a(t+o),i=a(t);p=Qt(e.x,r,e.width,i-r,f,n,c)}d&&(p.fillGradient=d,p.roundedEdge=h),l.push(p),t+=o}if(p>0&&l.length>n){const e=l.slice(n),t=e[0],o=e[e.length-1];1===e.length?t.cornerRadii={tl:p,tr:p,br:p,bl:p}:u?(t.cornerRadii={tl:p,bl:p},o.cornerRadii={tr:p,br:p}):(t.cornerRadii={bl:p,br:p},o.cornerRadii={tl:p,tr:p})}}return l}},Cg=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Rg=["scene-style","data-paint","accessibility","evidence"],Lg=(e,t)=>({retainedData:e,invalidations:t}),Ig=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Tg=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],$g=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],zg=["scene-geometry","data-paint","accessibility","evidence"],Dg=["scene-style","data-paint","accessibility","evidence"],Eg=[],Og={chartType:Lg("rebuild",Ig),runtimeMode:Lg("rebuild",Ig),categoryAccessor:Lg("rebuild",Ig),valueAccessor:Lg("rebuild",Ig),oAccessor:Lg("rebuild",Ig),rAccessor:Lg("rebuild",Ig),stackBy:Lg("rebuild",Ig),groupBy:Lg("rebuild",Ig),timeAccessor:Lg("rebuild",Ig),accessorRevision:Lg("rebuild",Ig),colorAccessor:Lg("rebuild",Dg),symbolAccessor:Lg("rebuild",zg),connectorAccessor:Lg("rebuild",zg),dataIdAccessor:Lg("rebuild",zg),projection:Lg("preserve",Tg),extentPadding:Lg("preserve",Tg),axisExtent:Lg("preserve",Tg),rExtent:Lg("preserve",Tg),oExtent:Lg("preserve",Tg),multiAxis:Lg("preserve",Tg),normalize:Lg("preserve",Tg),bins:Lg("preserve",Tg),oSort:Lg("preserve",$g),barPadding:Lg("preserve",$g),roundedTop:Lg("preserve",$g),baselinePadding:Lg("preserve",$g),innerRadius:Lg("preserve",$g),cornerRadius:Lg("preserve",$g),startAngle:Lg("preserve",$g),sweepAngle:Lg("preserve",$g),trackFill:Lg("preserve",$g),showOutliers:Lg("preserve",$g),showIQR:Lg("preserve",$g),amplitude:Lg("preserve",$g),connectorOpacity:Lg("preserve",$g),showLabels:Lg("preserve",$g),dynamicColumnWidth:Lg("rebuild",$g),customLayout:Lg("preserve",$g),layoutConfig:Lg("preserve",$g),layoutMargin:Lg("preserve",$g),symbolMap:Lg("preserve",zg),pieceStyle:Lg("preserve",Dg),summaryStyle:Lg("preserve",Dg),connectorStyle:Lg("preserve",Dg),gradientFill:Lg("preserve",Dg),colorScheme:Lg("preserve",Dg),themeCategorical:Lg("preserve",Dg),themeSemantic:Lg("preserve",Dg),themeSequential:Lg("preserve",Dg),themeDiverging:Lg("preserve",Dg),barColors:Lg("preserve",Dg),decay:Lg("preserve",Dg),pulse:Lg("preserve",Dg),staleness:Lg("preserve",Dg),layoutSelection:Lg("preserve",Dg),windowSize:Lg("preserve",Eg),windowMode:Lg("preserve",Eg),clock:Lg("preserve",Eg),transition:Lg("preserve",Eg),introAnimation:Lg("preserve",Eg),onLayoutError:Lg("preserve",Eg)},Fg=Lg("preserve",$g),Bg=class{constructor(){this.tracker=new Wn}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}},Cg)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Rg):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const o of e){const e=Og[o]??Fg;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}},Ng=require("d3-quadtree"),Wg=class{constructor(e){this.rExtent=new jt,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new Bg,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new wg,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 Pt(e.windowSize),this.getO=It(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>Rt(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new jt)):(this.getR=Rt(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=It(e.stackBy),this.getGroup=It(e.groupBy),this.getColor=It(e.colorAccessor),this.getSymbol=It(e.symbolAccessor),this.getConnector=It(e.connectorAccessor),this.getDataId=It(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new Pt(e.windowSize))}syncPulseTimestampBuffer(){var e,t,n,o;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,n=this.timestampBuffer,o=this.currentTime(),e?null!=n&&n.capacity===t.capacity&&n.size===t.size?n:jn(t,o):null)}currentTime(){return this.config.clock?.()??Bt()}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(),Pn(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(const n of e.inserts)Cn(this.buffer,n,this.timestampBuffer,t),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else{this._hasStreamingData=!0;for(const n of e.inserts){const e=Cn(this.buffer,n,this.timestampBuffer,t);this.categories.add(this.getO(n)),this.pushValueExtent(n),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 n="function"==typeof t?t(e):e[t];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(e){const{config:t,buffer:n}=this,o=this.scales,r=this.multiScales,i=this.columns;if(0===n.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(n,this.getR);const s=this.getBufferArray(),a=t.projection||"vertical",c=t.oExtent||this.resolveCategories(s),l=this.computeValueDomain(s,c),u="horizontal"===a,d="radial"===a,h=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===a?e.width:e.height):.1));let f,p;if(d){f=(0,vg.scaleBand)().domain(c).range([0,1]).padding(0);const n=Math.min(e.width,e.height)/2,o=t.innerRadius||0;p=(0,vg.scaleLinear)().domain(l).range([o,n])}else u?(f=(0,vg.scaleBand)().domain(c).range([0,e.height]).padding(h),p=(0,vg.scaleLinear)().domain(l).range([0,e.width])):(f=(0,vg.scaleBand)().domain(c).range([0,e.width]).padding(h),p=(0,vg.scaleLinear)().domain(l).range([e.height,0]));this.scales={o:f,r:p,projection:a},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((o,r)=>{const i=this.rExtents[r];i.dirty&&i.recalculate(n,o);let[s,a]=i.extent;s===1/0&&(s=0,a=1);const c=a-s,l=c>0?c*(t.extentPadding??.05):1;return s-=l,a+=l,s>0&&(s=0),u?(0,vg.scaleLinear)().domain([s,a]).range([0,e.width]):(0,vg.scaleLinear)().domain([s,a]).range([e.height,0])}):[];let y=s;this.rAccessors.length>1&&(y=s.flatMap(e=>this.rAccessors.map((t,n)=>({...e,__rIndex:n,__rValue:t(e),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(y,c,f,a,e),this._customLayoutFailedThisBuild=!1;const g=this.buildSceneNodes(y,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=o,this.multiScales=r,this.columns=i):(this.scene=[],this.rebuildPointQuadtree()):(this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=g,this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,s),this.config.pulse&&this.applyPulse(this.scene,s),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,n=Array.isArray(t)?t[e]:t;return"string"==typeof n?n:"value"+e}resolveCategories(e){const t=this.config.oSort,n="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===t?void 0:t;let r=null;if(n){r=new Set;for(const t of e)r.add(this.getO(t))}const i=r?Array.from(this.categories).filter(e=>r.has(e)):Array.from(this.categories);if(n&&void 0===o){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 i}if(!1===o)return i;if("function"==typeof o)return i.sort(o);const s=new Map;for(const t of e){const e=this.getO(t);s.set(e,(s.get(e)||0)+Math.abs(this.getR(t)))}return i.sort("asc"===o?(e,t)=>(s.get(e)||0)-(s.get(t)||0):(e,t)=>(s.get(t)||0)-(s.get(e)||0))}computeValueDomain(e,t){return function(e){const{data:t,chartType:n,projection:o,normalize:r,rExtent:i,extentPadding:s=.05,baselinePadding:a,axisExtent:c,getO:l,getR:u,getStack:d,rawRExtent:h}=e,f=s;if("radial"===o&&("pie"===n||"donut"===n))return[0,1];let p=0,y=0;if("bar"===n&&d&&r)p=0,y=1;else if("bar"===n&&d){const e=new Map,n=new Map;for(const o of t){const t=l(o),r=u(o);0>r?n.set(t,(n.get(t)||0)+r):e.set(t,(e.get(t)||0)+r)}for(const t of e.values())t>y&&(y=t);for(const e of n.values())p>e&&(p=e)}else if("bar"===n){const e=new Map;for(const n of t){const t=l(n),o=u(n);e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>y&&(y=t),p>t&&(p=t)}else if("swimlane"===n){const e=new Map;for(const n of t){const t=l(n),o=Math.abs(u(n));e.set(t,(e.get(t)||0)+o)}for(const t of e.values())t>y&&(y=t)}else if("clusterbar"===n||"bar-funnel"===n)for(const e of t){const t=u(e);t>y&&(y=t),p>t&&(p=t)}else{const e=h[0],t=h[1];e!==1/0&&(p=e),t!==-1/0&&(y=t)}i&&(null!=i[0]&&(p=i[0]),null!=i[1]&&(y=i[1]));const g="bar"===n||"clusterbar"===n||"bar-funnel"===n||"swimlane"===n;if(g&&null==i?.[0]&&null==i?.[1]&&(p>0&&(p=0),0>y&&(y=0)),"bar-funnel"!==n&&"exact"!==c){const e=y-p,t=e>0?e*f:1,o=g&&!a&&0===p,r=g&&!a&&0===y||"swimlane"===n;null!=i?.[0]||o||(p-=t),null!=i?.[1]||r||(y+=t)}return[p,y]}({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,n,o,r){return function(e){const{data:t,oExtent:n,oScale:o,projection:r,layout:i,dynamicColumnWidth:s,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 d=0;if("radial"===r)for(const e of t)d+=Math.abs(c(e));let h=null;if(s&&"radial"!==r){h=new Map;let e=0;for(const t of n){const n=u.get(t)||[];let o;o="string"==typeof s?n.reduce((e,t)=>e+(Number(t[s])||0),0):s(n),h.set(t,o),e+=o}const t=("horizontal"===r?i.height:i.width)-o.padding()*o.step()*n.length;if(e>0)for(const[n,o]of h)h.set(n,o/e*t)}let f=0,p=0;for(const e of n){const t=u.get(e)||[],n=t.reduce((e,t)=>e+Math.abs(c(t)),0),r=d>0?n/d:0;let i,s;h?(i=p,s=h.get(e)||o.bandwidth(),p+=s+o.padding()*o.step()):(i=o(e)??0,s=o.bandwidth()),l[e]={name:e,x:i,y:0,width:s,middle:i+s/2,padding:o.padding()*o.step(),pieceData:t,pct:r,pctStart:f},f+=r}return l}({data:e,oExtent:t,oScale:n,projection:o,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 n=this.buildLayoutContext(e,t);let o;try{o=this.config.customLayout(n)}catch(e){const t=null!==this.lastCustomLayoutResult,n=wn("ordinal",e,t,this.version);this.lastCustomLayoutFailure=n,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",e);try{this.config.onLayoutError?.(n)}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=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null;const r=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.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 xn({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 n=this.getSceneContext(),o=jg[this.config.chartType];let r=o?o(n,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:n,config:o,getConnector:r,getO:i}=e;if(!r||!n)return[];const s=[],{projection:a}=n,c=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const n=r(t);if(!n)continue;let o,s;"point"===e.type?(o=e.x,s=e.y):(o=e.x+e.w/2,s=e.y+("vertical"===a?0:e.h/2)),c.has(n)||c.set(n,[]),c.get(n).push({x:o,y:s,datum:t,category:i(t)})}const l=n.o.domain(),u=o.connectorStyle;for(const[t,n]of c)if(n.length>=2){n.sort((e,t)=>l.indexOf(e.category)-l.indexOf(t.category));for(let o=0;n.length-1>o;o++){const r=n[o],i=n[o+1],a="function"==typeof u?u(r.datum):u||{stroke:e.config.themeSemantic?.border||e.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:r.x,y1:r.y,x2:i.x,y2:i.y,style:a,datum:r.datum,group:t})}}return s}(n,r);r=[...e,...r]}return r}buildLayoutContext(e,t){const n=this.config,o=n.layoutMargin??{top:0,right:0,bottom:0,left:0},r=lp(n.colorScheme,n.themeCategorical,fe),i=this.scales;return{data:e,scales:{o:i.o,r:i.r,projection:i.projection},dimensions:{width:t.width,height:t.height,margin:o,plot:"radial"===i.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:n.themeSemantic??{},categorical:[...r]},resolveColor:up(r,n.colorScheme),config:n.layoutConfig??{},selection:n.layoutSelection??null}}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?Nt(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=Wt(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 n="function"==typeof t,o=n?null:t||"category",r=new Map;for(let i=0;e.length>i;i++){const s=e[i],a=n?t(s):s[o],c=r.get(a);c?c.push(i):r.set(a,[i])}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,n=0;for(const o of e)"point"===o.type&&(t++,o.r>n&&(n=o.r));if(500>=t)return{quadtree:null,maxRadius:n};const o=Array(t);let r=0;for(const t of e)"point"===t.type&&(o[r++]=t);return{maxRadius:n,quadtree:(0,Ng.quadtree)().x(e=>e.x).y(e=>e.y).addAll(o)}}(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 n=t.length;if(1>=n)return;const o=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=o.get(t.datum);if(null==e)continue;const r=this.computeDecayOpacity(e,n);t.style={...t.style,opacity:(t.style?.opacity??1)*r}}}applyPulse(e,t,n=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,o,r,i){const s=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 o=0;for(const s of r(t)??[]){const t=n.get(s);null!=t&&(o=Math.max(o,qt(e,t,i)))}c=Yt(l,o,s)||c;continue}if(null==l.datum)continue;const t=o.get(l.datum);if(null==t)continue;const u=n.get(t);c=Yt(l,null==u?0:qt(e,u,i),s,a)||c}return c}(this.config.pulse,e,this.timestampBuffer,this.getDatumIndexMap(t),e=>this.getCategoryIndexMap(t).get(e),n)}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&Gt(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,n="horizontal"!==this.scales?.projection;let o;for(let r=0;this.scene.length>r;r++){const i=this.scene[r],s=this.getNodeKey(i,e);s&&("rect"===i.type?this.prevPositionMap.set(s,n?{x:i.x,y:t,w:i.w,h:0,opacity:i.style.opacity??1}:{x:t,y:i.y,w:0,h:i.h,opacity:i.style.opacity??1}):"point"===i.type?this.prevPositionMap.set(s,{x:i.x,y:i.y,r:0,opacity:0}):"wedge"===i.type&&(void 0===o&&(o=i.startAngle),this.prevPositionMap.set(s,{x:i.cx,y:i.cy,startAngle:o,endAngle:o,innerRadius:i.innerRadius,outerRadius:i.outerRadius,opacity:0})))}}getNodeKey(e,t){if("point"===e.type){const n=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,o=t.get(n)||0;return t.set(n,o+1),`${n}:${o}`}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 n=this.scene[t],o=this.getNodeKey(n,e);o&&("point"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,r:n.r,opacity:n.style.opacity}):"rect"===n.type?this.prevPositionMap.set(o,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style.opacity}):"wedge"===n.type&&this.prevPositionMap.set(o,{x:n.cx,y:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:n.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 n=new Set,o=new Map;for(let e=0;this.scene.length>e;e++){const r=this.scene[e],i=this.getNodeKey(r,o);if(!i)continue;r._transitionKey=i;const s=this.prevPositionMap.get(i);if("point"===r.type)s?(n.add(i),r._targetOpacity=r.style.opacity??1,(s.x!==r.x||s.y!==r.y||void 0!==s.r&&s.r!==r.r)&&(r._targetX=r.x,r._targetY=r.y,r._targetR=r.r,r.x=s.x,r.y=s.y,void 0!==s.r&&(r.r=s.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)s?(n.add(i),r._targetOpacity=r.style.opacity??1,s.x===r.x&&s.y===r.y&&s.w===r.w&&s.h===r.h||(r._targetX=r.x,r._targetY=r.y,r._targetW=r.w,r._targetH=r.h,r.x=s.x,r.y=s.y,r.w=s.w??r.w,r.h=s.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(s)n.add(i),r._targetOpacity=r.style.opacity??1,s.startAngle===r.startAngle&&s.endAngle===r.endAngle||(r._targetStartAngle=r.startAngle,r._targetEndAngle=r.endAngle,r.startAngle=s.startAngle,r.endAngle=s.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(i,{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,o]of this.prevPositionMap)if(!n.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:o.x,y:o.y,r:o.r??3,style:{opacity:o.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:o.x,y:o.y,w:o.w??0,h:o.h??0,style:{opacity:o.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){const t=((o.startAngle??0)+(o.endAngle??0))/2,n={type:"wedge",cx:o.x,cy:o.y,innerRadius:o.innerRadius??0,outerRadius:o.outerRadius??100,startAngle:o.startAngle??0,endAngle:o.endAngle??0,style:{opacity:o.opacity??1},datum:null,category:e.slice(2),_targetStartAngle:t,_targetEndAngle:t,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}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=Ot(e,this.activeTransition),n=Et(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 o=this.prevPositionMap.get(t);e.style.opacity=Ft(o?o.opacity??1:0,e._targetOpacity,n)}const o=this.prevPositionMap.get(t);void 0!==e._targetX&&o&&(e.x=Ft(o.x,e._targetX,n),e.y=Ft(o.y,e._targetY,n)),void 0!==e._targetR&&void 0!==o?.r&&(e.r=Ft(o.r,e._targetR,n))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const o=this.prevPositionMap.get(t);e.style.opacity=Ft(o?o.opacity??1:0,e._targetOpacity,n)}if(void 0===e._targetX)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=Ft(o.x,e._targetX,n),e.y=Ft(o.y,e._targetY,n),void 0!==o.w&&(e.w=Ft(o.w,e._targetW,n),e.h=Ft(o.h,e._targetH,n))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){const o=this.prevPositionMap.get(t);e.style={...e.style,opacity:Ft(o?o.opacity??1:0,e._targetOpacity,n)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){const o=this.prevPositionMap.get(t);o&&void 0!==o.startAngle&&(e.startAngle=Ft(o.startAngle,e._targetStartAngle,n),e.endAngle=Ft(o.endAngle,e._targetEndAngle,n))}}}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=Dt(e),n=this.getDataId,o=e=>t.has(n(e));Rn(this.buffer,this.timestampBuffer,o);const r=this.buffer.remove(o);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 n=Dt(e),o=this.getDataId,r=new Set;this.buffer.forEach((e,t)=>{n.has(o(e))&&r.add(t)});const i=this.buffer.update(e=>n.has(o(e)),t);if(0===i.length)return this.updateResults.recordNoop("update"),i;for(const e of i)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",i.length),i}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 n=this._customRestyle;if(n)for(const o of e){const e=this._baseStyles.get(o)??o.style??{},r=n(o,t);o.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},n=Object.keys(e).filter(n=>e[n]!==t[n]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in e&&e.windowSize!==t.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${t.windowSize} → ${e.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in e&&e.colorScheme!==t.colorScheme||"themeCategorical"in e&&e.themeCategorical!==t.themeCategorical||"colorAccessor"in e&&!Ct(e.colorAccessor,t.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!Ct(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!Ct(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let o=!1;("categoryAccessor"in e||"oAccessor"in e)&&(Ct(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=It(this.config.categoryAccessor||this.config.oAccessor,"category"),o=!0));let r=!1;if("valueAccessor"in e||"rAccessor"in e){const e=this.config.valueAccessor||this.config.rAccessor,n=t.valueAccessor||t.rAccessor,o=Array.isArray(e)?e:[e],i=Array.isArray(n)?n:[n];if(r=o.length!==i.length||o.some((e,t)=>!Ct(e,i[t])),r){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>Rt(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new jt)):(this.getR=Rt(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!Ct(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?It(this.config.stackBy):void 0),"groupBy"in e&&!Ct(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?It(this.config.groupBy):void 0),"colorAccessor"in e&&!Ct(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?It(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!Ct(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?It(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!Ct(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?It(this.config.connectorAccessor):void 0),(o||r||"accessorRevision"in e&&e.accessorRevision!==t.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(n)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};On(Wg);var qg=require("react/jsx-runtime"),Yg=require("react/jsx-runtime");function Gg(e,t){const n=Je(e.theme),o=e.size||[500,400],r=qs({top:20,right:20,bottom:30,left:40,...e.margin},e.title),i=Ns(e.title),s=D(e.data),a=e.showLegend?Ky(s,e.colorAccessor||e.stackBy||e.groupBy):[],c=e.projection||"vertical",l={hasAxis:!1!==e.showAxes&&"radial"!==c,hasAxisLabel:"horizontal"===c?!(!e.valueLabel&&!e.rLabel):!(!e.categoryLabel&&!e.oLabel)};fg(r,{props:{...e,axisChrome:l},categories:a,theme:n,size:o,hasTitle:i});const u=o[0]-r.left-r.right,d=o[1]-r.top-r.bottom,h=e.projection||"vertical",f="radial"===h,p=e.colorScheme||n.colors.categorical,y={chartType:e.chartType,windowSize:e.windowSize??1e4,windowMode:e.windowMode??"sliding",extentPadding:e.extentPadding??.05,projection:h,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:Te(e.gradientFill),symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,multiAxis:e.multiAxis,baselinePadding:e.baselinePadding,trackFill:e.trackFill,connectorOpacity:e.connectorOpacity,showLabels:e.showLabels,colorScheme:p,themeCategorical:n.colors.categorical,themeSemantic:qe(n),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:r,layoutSelection:e.layoutSelection,barColors:e.barColors},g=new Wg(y);if(e.data&&g.ingest({inserts:s,bounded:!0}),g.computeScene({width:u,height:d}),!g.scales||0===g.scene.length)return t&&(t.evidence=Dy({frameType:"ordinal",width:o[0],height:o[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:g.scales?[]:["NO_SCALES"],margin:r})),bg.renderToStaticMarkup(gg(null,{width:o[0],height:o[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left},${r.top})`,innerWidth:u,innerHeight:d,idPrefix:e._idPrefix}));const m=e._idPrefix,x=e.showGrid?function(e,t,n,o,r){const i=e.scales;if(!i||"radial"===i.projection)return null;const{grid:s}=et(n),a=o?o+"-":"",c="vertical"===i.projection,l=Ls(i.r,5,r);return(0,sg.jsx)("g",c?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,n)=>{const o=i.r(e);return(0,sg.jsx)("line",{x1:0,y1:o,x2:t.width,y2:o,stroke:s,strokeWidth:.5},"gr-"+n)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((e,n)=>{const o=i.r(e);return(0,sg.jsx)("line",{x1:o,y1:0,x2:o,y2:t.height,stroke:s,strokeWidth:.5},"gr-"+n)})})}(g,{width:u,height:d},n,m,e.axisExtent):null;let b=null;if(g.scene.some(e=>"rect"===e.type&&e.datum?.__barFunnelIsDropoff)){const t=cg(e),o=new Set;for(const e of g.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&o.add("string"==typeof e.style.fill?e.style.fill:"#666");b=Array.from(o).map((e,o)=>function(e){const{id:t,background:n="transparent",stroke:o="#000",lineWidth:r=1.5,spacing:i=6,angle:s=45}=e,a=Math.max(8,Math.ceil(2*i));return(0,qg.jsxs)("pattern",{id:t,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[n&&"transparent"!==n&&(0,qg.jsx)("rect",{width:a,height:a,fill:n}),(0,qg.jsx)("line",{x1:0,y1:0,x2:0,y2:a,stroke:o,strokeWidth:r}),(0,qg.jsx)("line",{x1:i,y1:0,x2:i,y2:a,stroke:o,strokeWidth:r})]},t)}({id:`funnel-hatch-${t}-${o}`,background:e,stroke:"transparent"===n.colors.background?"#fff":n.colors.background,lineWidth:1.5,spacing:5,angle:45}));const r=new Map;Array.from(o).forEach((e,n)=>r.set(e,`funnel-hatch-${t}-${n}`));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 v=Pl({nodes:g.scene,renderMode:e.renderMode,fallback:(e,t)=>va(e,t,m)}),w=v.map(e=>e.element);if(t){const n=g.scales.o?.domain?.();t.evidence=Dy({frameType:"ordinal",width:o[0],height:o[1],marks:v.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,yDomain:zy(g.scales.r?.domain?.()),categories:Array.isArray(n)?n.map(String):void 0,margin:r})}const k=!1!==e.showAxes?function(e,t,n,o,r){const i=e.scales;if(!i)return null;if("radial"===i.projection)return null;const s=et(o),a="vertical"===i.projection,c=n.categoryFormat||n.oFormat,l=n.valueFormat||n.rFormat,u=n.categoryLabel||n.oLabel,d=n.valueLabel||n.rLabel,h=Object.values(e.columns).map(e=>({pixel:e.middle,label:(c||String)(e.name)})),f=Ls(i.r,5,n.axisExtent).map(e=>({pixel:i.r(e),label:(l||yg)(e)}));return(0,Yg.jsxs)("g",a?{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[(0,Yg.jsx)("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:s.border,strokeWidth:1}),h.map((e,n)=>(0,Yg.jsxs)("g",{transform:`translate(${e.pixel},${t.height})`,children:[(0,Yg.jsx)("line",{y2:5,stroke:s.border,strokeWidth:1}),(0,Yg.jsx)("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oxtick-"+n)),u&&(0,Yg.jsx)("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:u}),(0,Yg.jsx)("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:s.border,strokeWidth:1}),f.map((e,t)=>(0,Yg.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,Yg.jsx)("line",{x2:-5,stroke:s.border,strokeWidth:1}),(0,Yg.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oytick-"+t)),d&&(0,Yg.jsx)("text",{x:15-(n.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${t.height/2})`,children:d})]}:{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[(0,Yg.jsx)("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:s.border,strokeWidth:1}),f.map((e,n)=>(0,Yg.jsxs)("g",{transform:`translate(${e.pixel},${t.height})`,children:[(0,Yg.jsx)("line",{y2:5,stroke:s.border,strokeWidth:1}),(0,Yg.jsx)("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oxtick-"+n)),d&&(0,Yg.jsx)("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:d}),(0,Yg.jsx)("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:s.border,strokeWidth:1}),h.map((e,t)=>(0,Yg.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,Yg.jsx)("line",{x2:-5,stroke:s.border,strokeWidth:1}),(0,Yg.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oytick-"+t)),u&&(0,Yg.jsx)("text",{x:15-(n.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${t.height/2})`,children:u})]})}(g,{width:u,height:d},e,n,m):null,S=e.annotations?rg({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:s,scales:{o:g.scales.o,r:g.scales.r,y:"vertical"===g.scales.projection?g.scales.r:void 0},layout:{width:u,height:d},theme:n,projection:h,idPrefix:m}):null,A=pg({props:{...e,axisChrome:l},categories:a,theme:n,size:o,margin:r,hasTitle:i}),M=f?r.left+u/2:r.left,_=f?r.top+d/2:r.top,P=f&&e.centerContent?(0,Yg.jsx)("foreignObject",{x:r.left,y:r.top,width:u,height:d,pointerEvents:"none",children:(0,Yg.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:e.centerContent})}):null;return bg.renderToStaticMarkup(gg((0,Yg.jsxs)(Yg.Fragment,{children:[e.backgroundGraphics,x,w,k,S,e.foregroundGraphics,g.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${M},${_})`,innerWidth:u,innerHeight:d,legend:A,defs:b,outerElements:P,idPrefix:e._idPrefix}))}var Hg=y(require("react-dom/server"));function Vg(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function Xg(e,t){var n,o=[],r=[],i=[],s={},a=[];function c(e){i[e]=!1,s.hasOwnProperty(e)&&Object.keys(s[e]).forEach(function(t){delete s[e][t],i[t]&&c(t)})}function l(e){var t,o,d=!1;for(r.push(e),i[e]=!0,t=0;a[e].length>t;t++)(o=a[e][t])===n?(u(n,r),d=!0):i[o]||(d=l(o));if(d)c(e);else for(t=0;a[e].length>t;t++){var h=s[o=a[e][t]];h||(s[o]=h={}),h[o]=!0}return r.pop(),d}function u(e,n){var r=[].concat(n).concat(e);t?t(r):o.push(r)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,o=function(e){for(var t=e.length,n=Array(t),o=Array(t),r=Array(t),i=Array(t),s=Array(t),a=Array(t),c=0;t>c;++c)n[c]=-1,o[c]=0,r[c]=!1,i[c]=0,s[c]=-1,a[c]=[];var l,u=0,d=[],h=[];function f(t){var c=[t],l=[t];for(n[t]=o[t]=u,r[t]=!0,u+=1;l.length>0;){var f=e[t=l[l.length-1]];if(f.length>i[t]){for(var p=i[t];f.length>p;++p){var y=f[p];if(0>n[y]){n[y]=o[y]=u,r[y]=!0,u+=1,c.push(y),l.push(y);break}r[y]&&(o[t]=0|Math.min(o[t],o[y])),0>s[y]||a[t].push(s[y])}i[t]=p}else{if(o[t]===n[t]){var g=[],m=[],x=0;for(p=c.length-1;p>=0;--p){var b=c[p];if(r[b]=!1,g.push(b),m.push(a[b]),x+=a[b].length,s[b]=d.length,b===t){c.length=p;break}}d.push(g);var v=Array(x);for(p=0;m.length>p;p++)for(var w=0;m[p].length>w;w++)v[--x]=m[p][w];h.push(v)}l.pop()}}}for(c=0;t>c;++c)0>n[c]&&f(c);for(c=0;h.length>c;c++){var p=h[c];if(0!==p.length){p.sort(function(e,t){return e-t}),l=[p[0]];for(var y=1;p.length>y;y++)p[y]!==p[y-1]&&l.push(p[y]);h[c]=l}}return{components:d,adjacencyList:h}}(e),r=o.components.filter(function(e){return e.length>1}),i=1/0,s=0;r.length>s;s++)for(var a=0;r[s].length>a;a++)i>r[s][a]&&(i=r[s][a],n=s);var c=r[n];return!!c&&{leastVertex:i,adjList:e.map(function(e,t){return-1===c.indexOf(t)?[]:e.filter(function(e){return-1!==c.indexOf(e)})})}}n=0;for(var h=e.length;h>n;){var f=d(n);if(n=f.leastVertex,a=f.adjList){for(var p=0;a.length>p;p++)for(var y=0;a[p].length>y;y++){var g=a[p][y];i[+g]=!1,s[g]={}}l(n),n+=1}else n=h}return t?void 0:o}function Ug(e){return e.y0-e.y1>0?"up":"down"}function Kg(e,t){return t(e.source)==t(e.target)}function Zg(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function Qg(e){return e.target.x0-e.source.x1}function Jg(e,t){var n=tm(e),o=Qg(t)/Math.tan(n);return"up"==Ug(e)?e.y1-o:e.y1+o}function em(e,t){var n=tm(e),o=Qg(t)/Math.tan(n);return"up"==Ug(e)?e.y1+o:e.y1-o}function tm(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function nm(e,t){return t(e)}function om(e){return im(e.source)}function rm(e){return im(e.target)}function im(e){return(e.y0+e.y1)/2}function sm(e){return e.virtual?0:e.value}function am(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!Kg(e,t)?n+1:n});var o=0;return e.targetLinks.forEach(function(e){o=e.circular&&!Kg(e,t)?o+1:o}),n+o}function cm(e){return e.target.depth}function lm(e,t){return e.sourceLinks.length?e.depth:t-1}function um(e,t){return e.y0-t.y0}function dm(e,t){return t.y0-e.y0}function hm(e,t){return e.y1-t.y1}function fm(e,t){return t.y1-e.y1}function pm(e,t){return gm(e.source,t.source)||e.index-t.index}function ym(e,t){return gm(e.target,t.target)||e.index-t.index}function gm(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function mm(e,t){return xm(e)==xm(t)?"bottom"==e.circularLinkType?dm(e,t):um(e,t):xm(t)-xm(e)}function xm(e){return e.target.column-e.source.column}function bm(e,t){return vm(e)==vm(t)}function vm(e){return e.y0-e.y1>0?"up":"down"}var wm=require("d3-array");function km(e,t,n,o,r){let i=e;var s=Math.max(8,.15*(i.y1-i.y0));i.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var a=(0,wm.min)(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=i.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),Sm(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),Sm(i.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),i.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,Kg(e,t)&&Zg(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+r+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var s=e.source.column,c=e.circularLinkType,l=i.links.filter(function(e){return e.source.column==s&&e.circularLinkType==c});l.sort("bottom"==e.circularLinkType?dm:um);var u=0;l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),s=e.target.column,(l=i.links.filter(function(e){return e.target.column==s&&e.circularLinkType==c})).sort("bottom"==e.circularLinkType?fm:hm),u=0,l.forEach(function(t,r){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+r*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+r+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=a-r-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,o=e.target.x0,r=e.y1,i=(t+o)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+r+" "+o+","+r}(e)}),i}function Sm(e,t,n){e.sort(mm);var o=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,r){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(Kg(e,t)&&Zg(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Am(e,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;i=c>i?c:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function Am(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}var Mm=require("d3-array");function _m(e){return function(){return e}}function Pm(e){return e.index}function jm(e){return e.nodes}function Cm(e){return e.links}function Rm(e,t,n){var o=(0,Mm.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.forEach(function(r,i){var s=r.length;if(t)r.sort(t);else if(i>0){var a=new Map;r.forEach(function(e,t){var n,o,r,i=(o=0,r=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=im(e.source)*t,o+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;r+=im(e.target)*t,o+=t}}),o>0?r/o:NaN);a.set(e,{bc:i,idx:t})}),r.sort(function(e,t){var n=a.get(e),o=a.get(t),r=n.bc,i=o.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(r)||isNaN(i)?isNaN(r)?isNaN(i)?n.idx-o.idx:1:-1:r-i})}else r.sort(function(e,t){return e.circularLinkType==t.circularLinkType?am(t,n)-am(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});r.forEach(function(t,r){t.depth==o.length-1&&1==s||0==t.depth&&1==s?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==am(t,n)?(t.y0=e.y1/2+r,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+r,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-r,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*r,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+r,t.y1=t.y0+t.value*e.ky)})})}function Lm(e,t,n,o,r,i){var s=(0,Mm.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});u();for(var a=1,c=i;c>0;--c)l(a*=.99,n),u();function l(t,n){var o=s.length;s.forEach(function(r){var i=r.length,s=r[0].depth;r.forEach(function(r){var a;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&am(r,n)>0){var c=(0,Mm.mean)(r.sourceLinks,rm),l=(0,Mm.mean)(r.targetLinks,om),u=c&&l?(c+l)/2:c||l;if(u){var d=(u-im(r))*t*.3;r.y0+=d,r.y1+=d}}else if(0==s&&1==i)r.y0=e.y1/2-(a=r.y1-r.y0)/2,r.y1=e.y1/2+a/2;else if(s==o-1&&1==i)r.y0=e.y1/2-(a=r.y1-r.y0)/2,r.y1=e.y1/2+a/2;else if(1==r.targetLinks.length&&1==r.targetLinks[0].source.sourceLinks.length)a=r.y1-r.y0,r.y0=r.targetLinks[0].source.y0,r.y1=r.y0+a;else{var h=(0,Mm.mean)(r.sourceLinks,rm),f=(0,Mm.mean)(r.targetLinks,om),p=((h&&f?(h+f)/2:h||f)-im(r))*t;r.y0+=p,r.y1+=p}})})}function u(){s.forEach(function(n){var i,s,a,c=e.y0,l=n.length;for(n.sort(t||gm),a=0;l>a;++a)(s=c-(i=n[a]).y0)>0&&(i.y0+=s,i.y1+=s),c=i.y1+o;if((s=c-o-e.y1)>0)for(c=i.y0-=s,i.y1-=s,a=l-2;a>=0;--a)(s=(i=n[a]).y1+r-c)>0&&(i.y0-=s,i.y1-=s),c=i.y0})}}function Im(e){e.nodes.forEach(function(e){e.sourceLinks.sort(ym),e.targetLinks.sort(pm)}),e.nodes.forEach(function(e){var t=e.y0,n=t,o=e.y1,r=o;e.sourceLinks.forEach(function(e){e.circular?(e.y0=o-e.width/2,o-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=r-e.width/2,r-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function Tm(){var e=0,t=0,n=1,o=1,r=24,i=8,s=null,a=Pm,c=lm,l=void 0,u=32,d=2,h=jm,f=Cm;function p(){var p={nodes:h.apply(null,arguments),links:f.apply(null,arguments)};return function(h){h.x0=e,h.y0=t,h.x1=n,h.y1=o,h.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return(0,Mm.group)(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var o=e.source,r=e.target;"object"!=typeof o&&(o=e.source=Vg(n,o)),"object"!=typeof r&&(r=e.target=Vg(n,r)),o.sourceLinks.push(e),r.targetLinks.push(e)})}(h,a),function(e,t){var n=0;if(null==t){for(var o=[],r=0;e.links.length>r;r++){var i=e.links[r],s=i.source.index,a=i.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var c=Xg(o);c.sort(function(e,t){return e.length-t.length});var l={};for(r=0;c.length>r;r++){var u=c[r].slice(-2);l[u[0]]||(l[u[0]]={}),l[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,o=e.source.index;t===o||l[o]&&l[o][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(h,l),function(e,t){var n=0,o=0;e.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>n?"top":"bottom","top"==r.circularLinkType?n++:o++,e.nodes.forEach(function(e){nm(e,t)!=nm(r.source,t)&&nm(e,t)!=nm(r.target,t)||(e.circularLinkType=r.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),Kg(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(h,a),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max((0,Mm.sum)(e.sourceLinks,sm),(0,Mm.sum)(e.targetLinks,sm)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(h),function(e,t,n){var o,r,i;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var s=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){s=t(e)==a?s:s+1,a=t(e)==a?a:t(e),e.column=s})}for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>r.indexOf(e.target)&&!e.circular&&r.push(e.target)})});for(o=e.nodes,r=[],i=0;o.length;++i,o=r,r=[])o.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>r.indexOf(e.source)&&!e.circular&&r.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(h,l,c);var f=i;if(null!==s){var p=(0,Mm.groups)(h.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=(0,Mm.max)(p,function(e){return e.length});y>1&&(f=Math.max(1,(o-t)*s/(y-1)))}(function(e,t,n){var o=(0,Mm.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var r=(0,Mm.min)(o,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/(0,Mm.sum)(t,function(e){return e.value})});e.ky=r,e.links.forEach(function(t){t.width=t.value*e.ky});var i=(0,Mm.max)(e.nodes,function(e){return e.column});e.nodes.forEach(i>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-n)/i),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(h,f,r),Rm(h,l,a),Lm(h,l,a,f,f,u),Im(h),km(h,a,d,10,8),Rm(h,l,a),Lm(h,l,a,f,f,u),Im(h),km(h,a,d,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var o=n.links.filter(function(n){return nm(n.source,t)==nm(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!bm(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=Jg(t,e);return e.y1-n}if(t.target.column>e.target.column)return Jg(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,s=0;r>i;i++)s+=o[i].width;t.y0=e.y1-s-t.width/2}})})}(h,a),function(e,t){let n=e;n.nodes.forEach(function(e){var o=n.links.filter(function(n){return nm(n.target,t)==nm(e,t)}),r=o.length;r>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!bm(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=em(t,e);return e.y0-n}if(t.source.column>e.source.column)return em(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var i=e.y0;o.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,s=0;r>i;i++)s+=o[i].width;t.y1=e.y1-s-t.width/2}})})}(h,a),function(e){var t=e.nodes,n=e.links,o=!1,r=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(r=!0)}),0==o||0==r){let o=function(t){return(t-i)/(s-i)*(e.y1-e.y0)+e.y0};var i=(0,Mm.min)(t,function(e){return e.y0}),s=(0,Mm.max)(t,function(e){return e.y1}),a=(e.y1-e.y0)/(s-i);1>a?(t.forEach(function(e){e.y0=o(e.y0),e.y1=o(e.y1)}),n.forEach(function(e){e.y0=o(e.y0),e.y1=o(e.y1),e.width=e.width*a})):t.forEach(function(e){var t=e.y1-e.y0,n=o(e.y0)-e.y0;e.y0=o(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(h),km(h,a,d,10,8)}(p),p}return p.update=function(e){return Im(e),km(e,a,d,10,8),e},p.nodeWidth=function(e){return arguments.length?(r=+e,p):r},p.nodePadding=function(e){return arguments.length?(i=+e,p):i},p.nodePaddingRatio=function(e){return arguments.length?(s=+e,p):s},p.nodes=function(e){return arguments.length?(h="function"==typeof e?e:_m(e),p):h},p.links=function(e){return arguments.length?(f="function"==typeof e?e:_m(e),p):f},p.nodeId=function(e){return arguments.length?(a="function"==typeof e?e:_m(e),p):a},p.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:_m(e),p):c},p.nodeSort=function(e){return arguments.length?(l=e,p):l},p.iterations=function(e){return arguments.length?(u=+e,p):u},p.circularLinkGap=function(e){return arguments.length?(d=+e,p):d},p.extent=function(r){return arguments.length?(e=+r[0][0],t=+r[0][1],n=+r[1][0],o=+r[1][1],p):[[e,t],[n,o]]},p.size=function(r){return arguments.length?(e=t=0,n=+r[0],o=+r[1],p):[n-e,o-t]},p}var $m=require("d3-interpolate"),zm=(require("d3-shape"),.5),Dm=e=>{let t,n,o,r,i,s,a,c,l;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=e.y1+e.sankeyWidth/2,r=e.y0+e.sankeyWidth/2,i=e.source.x1,s=e.target.x0,a=(0,$m.interpolateNumber)(i,s),c=a(zm),l=a(.5),`M${t},${i}C${t},${c} ${n},${l} ${n},${s}L${o},${s}C${o},${l} ${r},${c} ${r},${i}Z`;const u=e.sankeyWidth/2,d=(0,$m.interpolateNumber)(e.source.x1,e.target.x0),{pathD:h}=th({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:d(zm),cp2X:d(.5)});return h};function Em(e){const t=e.sankeyWidth/2,n=(e._circularWidth??e.sankeyWidth)/2,o=e.circularPathData;if(!o)return null;if("down"===e.direction)return null;if(e._circularStub){const n=o.sourceX,r=o.sourceY,i=o.targetX,s=o.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const a=Math.max(15,Math.min(40,.33*(o.rightFullExtent-n))),c=Math.max(15,Math.min(40,.33*(i-o.leftFullExtent)));return`M${n},${r-t}L${n+a},${r-t}L${n+a},${r+t}L${n},${r+t}ZM${i},${s-t}L${i-c},${s-t}L${i-c},${s+t}L${i},${s+t}Z`}const r=o.sourceX,i=o.sourceY,s=o.targetX,a=o.targetY,c=o.rightFullExtent,l=o.leftFullExtent,u=o.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(n,15));return`M${r},${i-d*t}L${c},${i-d*t}L${c+n},${i-d*t+d*h}L${c+n},${u+d*n-d*h}L${c+n-h},${u+d*n}L${l-n+h},${u+d*n}L${l-n},${u+d*n-d*h}L${l-n},${a-d*t+d*h}L${l-n+h},${a-d*t}L${s},${a-d*t}L${s},${a+d*t}L${l+n},${a+d*t}L${l+n},${u-d*n}L${c-n},${u-d*n}L${c-n},${i+d*t}L${r},${i+d*t}Z`}var Om=new Set,Fm=new WeakMap;function Bm(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=Fm.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,Fm.set(e,n);const o=new Proxy(e,{get(e,n,o){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;Om.has(e)||(Om.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,o)}});return n.set(t,o),o}var Nm={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(cm))-1:0},justify:lm};function Wm(e){return"string"==typeof e?e:e.id}var qm={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const r="vertical"===n.orientation?"down":"right",i=n.nodeAlign||"justify",s=n.nodeWidth??15,a=n.nodePaddingRatio??.05,c=n.iterations??100,l=e.map(e=>({...e})),u=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let d;d="down"===r?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const h=Tm().extent(d).links(u).nodes(l).nodeAlign(Nm[i]||lm).nodeId(e=>e.id).nodeWidth(s).iterations(c);h.nodePaddingRatio&&h.nodePaddingRatio(a),h();{let e=1/0,t=-1/0,n=1/0,r=-1/0;for(const o of l)e>o.x0&&(e=o.x0),o.x1>t&&(t=o.x1),n>o.y0&&(n=o.y0),o.y1>r&&(r=o.y1);for(const o of u){if(!o.circular||!o.circularPathData)continue;const i=o.circularPathData,s=(o._circularWidth??o.width??0)/2;e>i.leftFullExtent-s&&(e=i.leftFullExtent-s),i.rightFullExtent+s>t&&(t=i.rightFullExtent+s),n>i.verticalFullExtent-s&&(n=i.verticalFullExtent-s),i.verticalFullExtent+s>r&&(r=i.verticalFullExtent+s)}const i=t-e,s=r-n,a=o[0],c=o[1];if(i>0&&s>0&&(0>e||0>n||t>a||r>c)){const t=Math.min(a/i,c/s),o=-e*t+(a-i*t)/2,r=-n*t+(c-s*t)/2;for(const e of l)e.x0=e.x0*t+o,e.x1=e.x1*t+o,e.y0=e.y0*t+r,e.y1=e.y1*t+r;for(const e of u)if(e.y0=e.y0*t+r,e.y1=e.y1*t+r,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+o,n.targetX=n.targetX*t+o,n.sourceY=n.sourceY*t+r,n.targetY=n.targetY*t+r,n.rightFullExtent=n.rightFullExtent*t+o,n.leftFullExtent=n.leftFullExtent*t+o,n.verticalFullExtent=n.verticalFullExtent*t+r,n.rightInnerExtent=n.rightInnerExtent*t+o,n.leftInnerExtent=n.leftInnerExtent*t+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+r,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+r,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const f=new Map;for(const t of e)f.set(t.id,t);for(const e of l){const t=f.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const p=new Map;for(const e of t)p.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of u){const t=Wm(e.source),n=Wm(e.target),o=p.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(o){o.y0=e.y0,o.y1=e.y1,o.sankeyWidth=e.width??0,o.circular=!!e.circular,o.circularPathData=e.circularPathData,o._circularWidth=e._circularWidth,o._circularStub=e._circularStub,o.path=e.path,o.circularLinkType=e.circularLinkType,o.direction=r;const i=f.get(t),s=f.get(n);i&&(o.source=i),s&&(o.target=s)}}},buildScene(e,t,n,o){const r="vertical"===n.orientation?"down":"right",i=n.nodeStyle,s=n.edgeStyle,a=n.edgeOpacity??.5,c=n.edgeColorBy||"source",l=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:N,u=new Map;e.forEach((e,t)=>{u.set(e.id,l[t%l.length])});const d=[],h=[],f=[],p=new Map;for(const t of e){const e=t.x1-t.x0,n=t.y1-t.y0;if(0>=e||0>=n)continue;const o=i?i(Bm(t,"nodeStyle")):{},s={fill:o.fill||u.get(t.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};p.set(t.id,("string"==typeof s.fill?s.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===r?{type:"rect",x:t.y0,y:t.x0,w:n,h:e,style:s,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:s,datum:t,id:t.id,label:t.id})}const y=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of y){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;if(!t||!o)continue;let r=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";r="function"==typeof c?c(e)||r:"target"===c?p.get(o.id)||u.get(o.id)||r:p.get(t.id)||u.get(t.id)||r;const i=s?s(Bm(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),c=i.fill||r;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+o},${t.sourceY-n}L${t.sourceX+o},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:c,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+o}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-s},${t.targetY-n}L${t.targetX-s},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:c,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-s,x1:t.targetX}});continue}let l;(l=e.circular&&e.circularPathData?Em(e):Dm(e),l)&&h.push({type:"bezier",pathD:l,bezierCache:e.bezier,style:{fill:i.fill||r,fillOpacity:i.fillOpacity??a,stroke:i.stroke||"none",strokeWidth:i.strokeWidth,opacity:i.opacity},datum:e})}if(!1!==n.showLabels){const t=(g=n.nodeLabel)?"function"==typeof g?g:e=>e[g]||e.id:null;for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=t?t(n):n.id;if(!s)continue;let a,c,l;"down"===r?(a=n.y0+(n.y1-n.y0)/2,c=n.x1+14,l="start"):(o[0]/2>n.x0+e/2?(a=n.x0-6,l="end"):(a=n.x1+6,l="start"),c=n.y0+i/2),f.push({x:a,y:c,text:s+"",anchor:"down"===r?"middle":l,baseline:"middle",fontSize:11})}}var g;return{sceneNodes:d,sceneEdges:h,labels:f}}},Ym=require("d3-force"),Gm=require("d3-scale"),Hm={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const r=n.forceStrength??.1,i=o[0]/2,s=o[1]/2,a=Math.max(.1,Math.min(1,Math.min(o[0],o[1])/200)),c=Math.min(.5,.06+1.8*(1-a)),l=n.__previousPositions;let u=0;const d=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=l?.get(t.id);e?u++:n?(t.x=n.x,t.y=n.y,u++):d.push(t)}const h=u>0&&.3>=(e.length>0?d.length/e.length:1);if(h){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of d){const o=Vm(e.id,t,n);if(o.length>0){let t=0,n=0;for(const e of o)t+=e.x,n+=e.y;const r=Xm(e.id),i=r%360*(Math.PI/180),s=(10+r%20)*a;e.x=t/o.length+s*Math.cos(i),e.y=n/o.length+s*Math.sin(i)}else{const t=Xm(e.id),n=t%360*(Math.PI/180),o=(15+t%30)*a;e.x=i+o*Math.cos(n),e.y=s+o*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const o=e[n];if(null==o.x||null==o.y||0===o.x&&0===o.y){const e=10*Math.sqrt(n+.5)*a,r=n*t;o.x=i+e*Math.cos(r),o.y=s+e*Math.sin(r)}}}const f=n.__skipForceSimulation||0===n.iterations?0:h?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),p=Um(n.nodeSize,n.nodeSizeRange,e),y=e=>p(e);if(f>0){const l=new Map,u=new Map;for(const t of e)l.set(t.id,0),u.set(t.id,t);for(const e of t){const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id;l.set(t,(l.get(t)??0)+1),l.set(n,(l.get(n)??0)+1)}const d=(0,Ym.forceLink)().strength(e=>{const t=e.weight,n="string"==typeof e.target?e.target:e.target.id,o=Math.max(1,Math.min(l.get("string"==typeof e.source?e.source:e.source.id)??1,l.get(n)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*r/(.1*o))}).distance(e=>{const t="string"==typeof e.source?u.get(e.source):e.source,n="string"==typeof e.target?u.get(e.target):e.target,o=(t?y(t):0)+(n?y(n):0)+Math.max(6,12*a);return Math.max(16,40*a,o)}).id(e=>e.id),p=(0,Ym.forceSimulation)();if(void 0===n.random&&void 0===n.seed||p.randomSource(n.random??$c(n.seed)),p.force("charge",(0,Ym.forceManyBody)().strength(e=>{const t=l.get(e.id)??0;return-15*a*y(e)*Math.sqrt(t+1)})).force("collide",(0,Ym.forceCollide)(e=>y(e)+3*a).strength(.9).iterations(2)).force("center",(0,Ym.forceCenter)(i,s).strength(.8)).force("x",(0,Ym.forceX)(i).strength(c)).force("y",(0,Ym.forceY)(s).strength(c)).force("bounds",function(e,t,n=2,o=.6){let r=[];const i=i=>{const s=o*Math.max(i,.2);for(const o of r){const r=o.x??e[0]/2,i=o.y??e[1]/2,a=o.vx??0,c=o.vy??0,l=t(o)+n,u=Math.min(e[0]/2,l),d=Math.max(e[0]/2,e[0]-l),h=Math.min(e[1]/2,l),f=Math.max(e[1]/2,e[1]-l),p=r+a,y=i+c;u>p?o.vx=a+(u-p)*s:p>d&&(o.vx=a+(d-p)*s),h>y?o.vy=c+(h-y)*s:y>f&&(o.vy=c+(f-y)*s)}};return i.initialize=e=>{r=e},i}(o,y)),p.nodes(e),t.length>0){const e=t.map(e=>({...e,source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));d.links(e),p.force("link",d)}h?p.alpha(.3):.1>p.alpha()&&p.alpha(1),p.stop();for(let e=0;f>e;++e)p.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=y(t),n=f>0?2:0,r=Math.min(o[0]/2,e+n),i=Math.min(o[1]/2,e+n);t.x=Math.max(r,Math.min(o[0]-r,t.x)),t.y=Math.max(i,Math.min(o[1]-i,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const g=new Map;for(const t of e)g.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=g.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=g.get(e.target);t&&(e.target=t)}}},buildScene(e,t,n,o){const r=n.nodeStyle,i=n.edgeStyle,s=Um(n.nodeSize,n.nodeSizeRange,e),a=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:N,c=new Map;e.forEach((e,t)=>{c.set(e.id,a[t%a.length])});const l=[],u=[],d=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=s(Bm(t,"nodeSize")),o=r?r(Bm(t,"nodeStyle")):{},i={fill:o.fill||c.get(t.id)||n.themeSemantic?.primary||"#007bff",stroke:o.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??2,opacity:o.opacity};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:i,datum:t,id:t.id,label:t.id})}const h=new Map;for(const t of e)h.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:h.get(e.source),o="object"==typeof e.target?e.target:h.get(e.target);if(!t||!o)continue;if(null==t.x||null==t.y)continue;if(null==o.x||null==o.y)continue;const r=i?i(Bm(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:o.x,y2:o.y,style:{stroke:r.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:r.strokeWidth??1,opacity:r.opacity??.6},datum:e})}if(!1!==n.showLabels){const t=(f=n.nodeLabel)?"function"==typeof f?f:e=>e[f]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const o=s(Bm(n,"nodeSize"));d.push({x:n.x,y:n.y-o-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:l,sceneEdges:u,labels:d}}};function Vm(e,t,n){const o=[];for(const r of t){const t="string"==typeof r.source?r.source:r.source.id,i="string"==typeof r.target?r.target:r.target.id;let s=null;if(t===e?s=i:i===e&&(s=t),s){const e=n.get(s);!e||0===e.x&&0===e.y||o.push({x:e.x,y:e.y})}}return o}function Xm(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function Um(e,t,n){if(n.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const o=t||[5,20],r=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&r.push(n)}if(0===r.length)return()=>o[0];const[i,s]=ve(r);if(i===s)return()=>(o[0]+o[1])/2;const a=(0,Gm.scaleLinear)().domain([i,s]).range(o).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?o[0]:a(n)}}var Km=require("d3-chord"),Zm=require("d3-shape"),Qm=N,Jm={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const{padAngle:r=.01,groupWidth:i=20,sortGroups:s}=n,a=Math.min(o[0],o[1])/2,c=a-i,l=o[0]/2,u=o[1]/2,d=(h=n.valueAccessor)?"function"==typeof h?h:e=>e[h]??1:e=>e.value??1;var h;const f=new Map;for(let t=0;e.length>t;t++)f.set(e[t].id,t);const p=e.length,y=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=f.get("string"==typeof e.source?e.source:e.source.id),o=f.get(t);if(void 0===n||void 0===o)continue;const r=d(e);y[n][o]=r}const g=(0,Km.chord)().padAngle(r);s&&g.sortGroups(s);const m=g(y),x=m.groups,b=(0,Zm.arc)().innerRadius(c).outerRadius(a);for(const t of x){const n=e[t.index],o=b.centroid({innerRadius:c,outerRadius:a,startAngle:t.startAngle,endAngle:t.endAngle});n.x=o[0]+l,n.y=o[1]+u,n.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=v.get("string"==typeof e.source?e.source:e.source.id),o=v.get(t);n&&(e.source=n),o&&(e.target=o)}const w=new Map;for(const e of t)w.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of m){const n=e[t.source.index].id,o=e[t.target.index].id,r=w.get(`${n}\0${o}`)||w.get(`${o}\0${n}`);r&&(r.__chordData=t)}},buildScene(e,t,n,o){const{groupWidth:r=20,edgeOpacity:i=.5}=n,s=Math.min(o[0],o[1])/2,a=s-r,c=o[0]/2,l=o[1]/2,u=n.nodeStyle,d=n.edgeStyle,h=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Qm,p=new Map;e.forEach((e,t)=>{p.set(e.id,f[t%f.length])});const y=(0,Km.ribbon)().radius(a),g=[],m=[],x=[];for(let t=0;e.length>t;t++){const n=e[t],o=n.__arcData;if(!o)continue;let r;r=u?u(Bm(n,"nodeStyle")).fill||p.get(n.id)||f[t%f.length]:p.get(n.id)||f[t%f.length];const i=u?u(Bm(n,"nodeStyle")):{};g.push({type:"arc",cx:c,cy:l,innerR:a,outerR:s,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:{fill:r,stroke:i.stroke||"black",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const o=y(t);if(!o)continue;const r=ex(o,c,l);let s=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(d)s=d(Bm(e,"edgeStyle")).fill||s;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===h&&n?s=p.get(n.id)||s:t&&(s=p.get(t.id)||s)}const a=d?d(Bm(e,"edgeStyle")):{};m.push({type:"ribbon",pathD:r,style:{fill:s,fillOpacity:a.fillOpacity??i,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:e})}if(!1!==n.showLabels){const t=(b=n.nodeLabel)?"function"==typeof b?b:e=>e[b]||e.id:null,o=s+12;for(const n of e){const e=n.__arcData;if(!e)continue;const r=t?t(n):n.id;if(!r)continue;const i=(e.startAngle+e.endAngle)/2,s=i-Math.PI/2;x.push({x:c+Math.cos(s)*o,y:l+Math.sin(s)*o,text:r+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var b;return{sceneNodes:g,sceneEdges:m,labels:x}}};function ex(e,t,n){const o=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return e;const r=[];let i=0;for(;o.length>i;){const e=o[i];if("M"===e||"L"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("C"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;3>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("Q"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)for(let e=0;2>e&&o.length>i&&!isNaN(Number(o[i]));e++)r.push(Number(o[i])+t+""),i++,o.length>i&&!isNaN(Number(o[i]))&&(r.push(Number(o[i])+n+""),i++);else if("A"===e)for(r.push(e),i++;o.length>i&&!isNaN(Number(o[i]));)r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&r.push(o[i++]),o.length>i&&(r.push(Number(o[i])+t+""),i++),o.length>i&&(r.push(Number(o[i])+n+""),i++);else"Z"===e||"z"===e?(r.push(e),i++):(r.push(o[i]),i++)}return r.join(" ")}var tx=require("d3-hierarchy"),nx=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function ox(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>150?"#222":"#fff"}function rx(e,t,n){const o=t.nodeIDAccessor;return"function"==typeof o?o(e.data)+"":"string"==typeof o&&void 0!==e.data[o]?e.data[o]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function ix(e){if(!e)return null;if("function"==typeof e){const t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function sx(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:nx}function ax(e){return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:e.themeSemantic?.primary?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function cx(e,t,n,o,r){if("horizontal"===r){const r=(e+n)/2;return`M ${e},${t} C ${r},${t} ${r},${o} ${n},${o}`}if("radial"===r){const r=(e+n)/2;return`M ${e},${t} Q ${r},${t} ${r},${(t+o)/2} T ${n},${o}`}{const r=(t+o)/2;return`M ${e},${t} C ${e},${r} ${n},${r} ${n},${o}`}}var lx={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,o){const r=n.__hierarchyRoot;if(!r)return;const i=n.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),a=n.hierarchySum,c="function"==typeof a?a:"string"==typeof a?e=>Number(e[a])||0:e=>Number(e.value)||0,l=(0,tx.hierarchy)(r,s);l.sum(c),l.sort((e,t)=>(t.value??0)-(e.value??0));const[u,d]=o;switch(i){case"tree":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=(0,tx.tree)();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(l,n,u,d);break;case"cluster":!function(e,t,n,o){const r=t.treeOrientation||"vertical",i=(0,tx.cluster)();i.size("horizontal"===r?[o,n]:"radial"===r?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),i(e)}(l,n,u,d);break;case"treemap":!function(e,t,n,o){const r=t.padding??4,i=t.paddingTop??0,s=(0,tx.treemap)().size([n,o]).tile(tx.treemapBinary).padding(r);i>0&&s.paddingTop(i),s(e)}(l,n,u,d);break;case"circlepack":!function(e,t,n,o){const r=t.padding??4;(0,tx.pack)().size([n,o]).padding(r)(e)}(l,n,u,d);break;case"partition":!function(e,t,n,o){(0,tx.partition)().size([n,o]).padding(t.padding??1)(e)}(l,n,u,d)}const h=l.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;h.length>t;t++){const o=h[t],r={id:rx(o,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:o.value??0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===i||"cluster"===i?ux(r,o,n):"treemap"===i||"partition"===i?dx(r,o):"circlepack"===i&&hx(r,o),r.__hierarchyNode=o,e.push(r),f.set(o,r)}if("tree"===i||"cluster"===i)for(const e of h)if(e.parent){const n=f.get(e.parent),o=f.get(e);n&&o&&t.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,o){const r=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,o,r,i){const s=[],a=[],c=[],l=n.treeOrientation||"vertical",u="radial"===l,d=o[0]/2,h=o[1]/2,f="number"==typeof(p=n.nodeSize)?p:5;var p;for(const t of e){let e=t.x,o=t.y;u&&(e+=d,o+=h);const i=r(Bm(t,"nodeStyle"));let a=i.fill||ax(n);if(n.colorByDepth&&void 0!==t.depth){const e=sx(n);a=e[t.depth%e.length]}s.push({type:"circle",cx:e,cy:o,r:f,style:{fill:a,stroke:i.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity},datum:t,id:t.id,label:t.id,depth:t.depth})}const y=n.edgeOpacity??.5;for(const e of t){const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;if(!t||!o)continue;let r=t.x,s=t.y,c=o.x,f=o.y;u&&(r+=d,s+=h,c+=d,f+=h);const p=cx(r,s,c,f,l),g=i(Bm(e,"edgeStyle"));a.push({type:"curved",pathD:p,style:{fill:"none",stroke:g.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??y},datum:e})}if(!1!==n.showLabels){const t=ix(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let o,r,i,s=n.x,a=n.y;if(u&&(s+=d,a+=h),u){const e=s-d,t=a-h,n=Math.sqrt(e*e+t*t);n>0?(o=s+e/n*10,r=a+t/n*10,i=0>e?"end":"start"):(o=s,r=a-12,i="middle")}else"horizontal"===l?(n.data?.children&&0!==n.data.children.length?(o=s-f-6,i="end"):(o=s+f+6,i="start"),r=a):(o=s,r=a+f+14,i="middle");c.push({x:o,y:r,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:c}}(e,t,n,o,r,i);case"treemap":case"partition":return function(e,t,n,o){const r=[],i=[];for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const s=o(Bm(n,"nodeStyle"));let a=s.fill||ax(t);if(t.colorByDepth&&void 0!==n.depth){const e=sx(t);a=e[n.depth%e.length]}r.push({type:"rect",x:n.x0,y:n.y0,w:e,h:i,style:{fill:a,stroke:s.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=ix(t.nodeLabel),r=t.labelMode||"leaf",s="partition"===t.chartType;for(const a of e){const e=a.x1-a.x0,c=a.y1-a.y0;if(0>=e||0>=c)continue;const l=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===r&&!l)continue;if("parent"===r&&l)continue}const u=n?n(a):a.id;if(!u)continue;if((l?30:40)>e||(l?16:14)>c)continue;let d=o(Bm(a,"nodeStyle")).fill||ax(t);if(t.colorByDepth&&void 0!==a.depth){const e=sx(t);d=e[a.depth%e.length]}const h="string"==typeof d?ox(d):t.themeSemantic?.text??"#000";i.push(l?{x:a.x0+e/2,y:a.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,c)/6)),fill:h}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:r,sceneEdges:[],labels:i}}(e,n,0,r);case"circlepack":return function(e,t,n,o){const r=[],i=[];for(const n of e){const e=n.__radius??5;if(0>=e)continue;const i=o(Bm(n,"nodeStyle"));let s=i.fill||ax(t);if(t.colorByDepth&&void 0!==n.depth){const e=sx(t);s=e[n.depth%e.length]}r.push({type:"circle",cx:n.x,cy:n.y,r:e,style:{fill:s,stroke:i.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:i.strokeWidth??1,opacity:i.opacity??.7},datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=ix(t.nodeLabel);for(const r of e){const e=r.__radius??5,s=n?n(r):r.id;if(!s)continue;if(15>e)continue;const a=!(r.data?.children&&r.data.children.length>0);let c=o(Bm(r,"nodeStyle")).fill||ax(t);if(t.colorByDepth&&void 0!==r.depth){const e=sx(t);c=e[r.depth%e.length]}if(a){const n="string"==typeof c?ox(c):t.themeSemantic?.text??"#000";i.push({x:r.x,y:r.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else i.push({x:r.x,y:r.y-e+14,text:s+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:t.themeSemantic?.text||"#000",stroke:t.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:r,sceneEdges:[],labels:i}}(e,n,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function ux(e,t,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=t.x,o=t.y;e.x=o*Math.cos(n-Math.PI/2),e.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function dx(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function hx(e,t){const n=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}var fx=require("d3-shape");function px(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var yx={sankey:qm,force:Hm,chord:Jm,tree:lx,cluster:lx,treemap:lx,circlepack:lx,partition:lx,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,o){const r=n.__hierarchyRoot;r&&function(e,t,n,o,r){const i=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),s=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>(e[t]??"")+""}(n.nodeIDAccessor),a=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),c=n.orbitSize??2.95,l=n.orbitEccentricity??1,u="number"==typeof c?()=>c:c,d="number"==typeof l?()=>l:l,h=px(n);h.metaMap.clear(),o.length=0,r.length=0;const f=new Map;function p(e){const t=f.get(e)??0;return f.set(e,t+1),0===t?e:`${e}__${t}`}const y=t[0]/2,g=t[1]/2,m=Math.min(t[0],t[1])/2*.85,x=p(s(e));o.push({id:x,x:y,y:g,x0:y,x1:y,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:e}),h.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,c,l,f,y,g){const m=i(t);if(!m?.length)return;const x=m.length;let b=0,v=0,w=0;for(;x>v;)v+=a[Math.min(w,a.length-1)],w++,b++;let k=0;for(let x=0;b>x;x++){const v=a[Math.min(x,a.length-1)],w=m.slice(k,k+v);if(!w.length)break;const S=(x+1)/b,A={id:n,depth:y,data:t,parentId:n},M=g?f/u(A)*S:f*S,_=(0,fx.pie)().value(e=>{const t=i(e)?.length;return t?4:1}).sort(null)(w),P=d(A);for(let t=0;w.length>t;t++){const i=(_[t].startAngle+_[t].endAngle)/2,a=w[t],u=p(s(a)),d=c+M*Math.sin(i),f=l+M*Math.cos(i)*P;o.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:y,data:a}),h.metaMap.set(u,{ring:M,angle:i,depth:y,parentId:n,eccentricity:P}),r.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(a,u,d,f,M,y+1,!0)}k+=v}}(e,x,y,g,m,1,!1)}(r,o,n,e,t)},buildScene(e,t,n,o){const r=n.nodeStyle,i=n.nodeSize,s="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,a=[],c=[],l=[];if(!1!==n.orbitShowRings){const t=px(n),o=new Map;for(const t of e)o.set(t.id,t);const r=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=o.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;r.has(n)||r.set(n,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const i=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:n,ecc:o}]of r)for(let r=0;i>r;r++){const a=r/i*Math.PI*2,l=(r+1)/i*Math.PI*2;c.push({type:"line",x1:e+n*Math.sin(a),y1:t+n*Math.cos(a)*o,x2:e+n*Math.sin(l),y2:t+n*Math.cos(l)*o,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=s(Bm(t,"nodeSize")),o=r?r(Bm(t,"nodeStyle")):{};a.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:o.fill||n.themeSemantic?.primary||"#6366f1",stroke:o.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.opacity??(0===(t.depth??0)?1:.85)},datum:t,id:t.id,label:t.id,depth:t.depth})}const u=new Map;for(const t of e)u.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:u.get(e.source),n="object"==typeof e.target?e.target:u.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&c.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=s(Bm(n,"nodeSize"));if(4>=e)continue;const o="function"==typeof t?t(n):t?n.data?.[t]??n.id:n.id;l.push({x:n.x,y:n.y+e+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:c,labels:l}},tick:(e,t,n,o,r)=>!1!==n.orbitAnimated&&(function(e,t){const n=px(t),o=t.orbitSpeed??.25,r=t.orbitRevolution??function(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),i=(("undefined"!=typeof performance?performance.now():Date.now())-n.startTime)/1e3,s=o*(Math.PI/6),a=new Map;for(const t of e)a.set(t.id,t);for(const t of e){const e=n.metaMap.get(t.id);if(!e||!e.parentId)continue;const o=a.get(e.parentId);if(!o)continue;const c=e.angle+i*s*r({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=o.x+e.ring*Math.sin(c),t.y=o.y+e.ring*Math.cos(c)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)}},gx=require("react/jsx-runtime");function mx(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}var xx=new Set(["tree","cluster","treemap","circlepack","partition"]);function bx(e,t){const n=Je(e.theme),o=e.chartType||"force",r=()=>Dy({frameType:"network",width:i[0],height:i[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,nodeCount:0,edgeCount:0,margin:s}),i=e.size||[500,500],s=qs({top:20,right:20,bottom:20,left:20,...e.margin},e.title),a=Ns(e.title),c=e.showLegend?(()=>{const t="string"==typeof(n=e.colorBy)||"function"==typeof n?e.colorBy:void 0;var n;if(!t)return[];const o=D(e.nodes||[]);if(o.length>0)return Ky(o,t);const r=Array.isArray(e.edges)?D(e.edges):[];if(0===r.length)return[];const i=mx(e.sourceAccessor,"source"),s=mx(e.targetAccessor,"target");return Ky(Array.from(new Set(r.flatMap(e=>[i(e),s(e)]).filter(e=>null!=e).map(String))).map(e=>({id:e})),t)})():[];fg(s,{props:e,categories:c,theme:n,size:i,hasTitle:a});const l=i[0]-s.left-s.right,u=i[1]-s.top-s.bottom,d=function(e){return yx[e]}(o);if(!d&&!e.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${o}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const h={chartType:o,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||n.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig};let f,p;if(xx.has(o)){const o=e.data||e.edges;if(!o||Array.isArray(o))return t&&(t.evidence=r()),Hg.renderToStaticMarkup(gg(null,{width:i[0],height:i[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:u,idPrefix:e._idPrefix}));h.__hierarchyRoot=o,f=[],p=[]}else{const o=D(e.nodes||[]),a=Array.isArray(e.edges)?D(e.edges):[];if(0===o.length&&0===a.length)return t&&(t.evidence=r()),Hg.renderToStaticMarkup(gg(null,{width:i[0],height:i[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:u,idPrefix:e._idPrefix}));if(p=function(e,t){const n=mx(t.sourceAccessor,"source"),o=mx(t.targetAccessor,"target"),r=mx(t.valueAccessor,"value");return e.map(e=>({source:n(e)+"",target:o(e)+"",value:Number(r(e))||1,y0:0,y1:0,sankeyWidth:0,data:e}))}(a,h),0===o.length&&p.length>0){const e=new Set;for(const t of p){const n=ag(t.source),o=ag(t.target);n&&e.add(n),o&&e.add(o)}f=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 f=function(e,t){const n=mx(t.nodeIDAccessor,"id");return e.map(e=>({id:n(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}))}(o,h)}let y=[],g=[],m=[],x=null;if(h.customNetworkLayout){const e=h.colorScheme,t=lp(e,n.colors.categorical,N),o=up(t,e),r={nodes:f,edges:p,dimensions:{width:l,height:u,plot:{x:0,y:0,width:l,height:u}},theme:{semantic:n.colors,categorical:[...t]},resolveColor:o,config:h.layoutConfig??{}},i=h.customNetworkLayout(r);y=i.sceneNodes??[],g=i.sceneEdges??[],m=i.labels??[],x=i.overlays??null}else if(d){d.computeLayout(f,p,h,[l,u]);const e=d.buildScene(f,p,h,[l,u]);y=e.sceneNodes,g=e.sceneEdges,m=e.labels}const b=et(n);for(const e of m)e.fill||(e.fill=b.text);const v=Pl({nodes:g,renderMode:e.renderMode,fallback:(e,t)=>function(e,t){switch(e.type){case"line":return(0,ua.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:e.style.stroke||"#999",strokeWidth:e.style.strokeWidth||1,opacity:e.style.opacity},"net-edge-"+t);case"bezier":{const n=e;return(0,ua.jsx)("path",{d:n.pathD,fill:oa(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"ribbon":{const n=e;return(0,ua.jsx)("path",{d:n.pathD,fill:oa(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+t)}case"curved":{const n=e;return(0,ua.jsx)("path",{d:n.pathD,fill:oa(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+t)}default:return null}}(e,t)}),w=Pl({nodes:y,renderMode:e.renderMode,fallback:(e,t)=>function(e,t){switch(e.type){case"circle":{const n=e,o=Bo(n.style.fill)?qo(n.style.fill,`net-circle-${t}-hatch`):void 0;return(0,ua.jsxs)(ca.Fragment,{children:[o&&(0,ua.jsx)("defs",{children:o}),(0,ua.jsx)("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:o?`url(#net-circle-${t}-hatch)`:oa(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-circle-"+t)}case"rect":{const n=e,o=Bo(n.style.fill)?qo(n.style.fill,`net-rect-${t}-hatch`):void 0;return(0,ua.jsxs)(ca.Fragment,{children:[o&&(0,ua.jsx)("defs",{children:o}),(0,ua.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:o?`url(#net-rect-${t}-hatch)`:oa(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-rect-"+t)}case"arc":{const n=e,o=(0,la.arc)().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(na)||"",r=Bo(n.style.fill)?qo(n.style.fill,`net-arc-${t}-hatch`):void 0;return(0,ua.jsxs)(ca.Fragment,{children:[r&&(0,ua.jsx)("defs",{children:r}),(0,ua.jsx)("path",{d:o,transform:`translate(${n.cx},${n.cy})`,fill:r?`url(#net-arc-${t}-hatch)`:oa(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-arc-"+t)}case"symbol":{const n=e,o=fn(n.symbolType,n.size,n.path);return(0,ua.jsx)("path",{d:o,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?oa(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return ia(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)});t&&(t.evidence=Dy({frameType:"network",width:i[0],height:i[1],marks:[...w.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:w.length,edgeCount:v.length,margin:s}));const k=v.map(e=>e.element),S=w.map(e=>e.element),A=m.map((e,t)=>function(e,t){return(0,ua.jsx)("text",{x:e.x,y:e.y,textAnchor:e.anchor||"middle",dominantBaseline:e.baseline||"auto",fontSize:e.fontSize||11,fontWeight:e.fontWeight,fill:e.fill||"var(--semiotic-text, #333)",stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:e.paintOrder,children:e.text},"net-label-"+t)}(e,t)).filter(Boolean),M=e.annotations?rg({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{},layout:{width:l,height:u},theme:n,idPrefix:e._idPrefix}):null,_=pg({props:e,categories:c,theme:n,size:i,margin:s,hasTitle:a});return Hg.renderToStaticMarkup(gg((0,gx.jsxs)(gx.Fragment,{children:[e.backgroundGraphics,k,S,A,M,e.foregroundGraphics,x]}),{width:i[0],height:i[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:u,legend:_,idPrefix:e._idPrefix}))}var vx=y(require("react-dom/server")),wx=require("d3-geo"),kx=require("d3-quadtree"),Sx=require("d3-geo"),Ax={mercator:Sx.geoMercator,equalEarth:Sx.geoEqualEarth,albersUsa:Sx.geoAlbersUsa,orthographic:Sx.geoOrthographic,naturalEarth:Sx.geoNaturalEarth1,equirectangular:Sx.geoEquirectangular};function Mx(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function _x(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function Px(e,t,n){return e?"function"==typeof e?{...n,...e(t)}:{...n,...e}:{...n}}function jx(e,t){if(2>e.length)return[e];const n=.4*t,o=[];let r=[e[0]];for(let t=1;e.length>t;t++){const i=e[t];Math.abs(i[0]-e[t-1][0])>n?(2>r.length||o.push(r),r=[i]):r.push(i)}return 2>r.length||o.push(r),o}function Cx(e,t,n=24){const o=t[0]-e[0],r=t[1]-e[1],i=Math.sqrt(o*o+r*r);if(0===i)return[e,t];const s=-r/i,a=o/i,c=Math.min(.3*i,80),l=(e[0]+t[0])/2+s*c,u=(e[1]+t[1])/2+a*c,d=[];for(let o=0;n>=o;o++){const r=o/n,i=1-r;d.push([i*i*e[0]+2*i*r*l+r*r*t[0],i*i*e[1]+2*i*r*u+r*r*t[1]])}return d}function Rx(e,t){if(2>e.length)return e;const n=t/2+1,o=[];for(let t=0;e.length>t;t++){const r=e[t];let i,s;0===t?(i=e[1][0]-r[0],s=e[1][1]-r[1]):t===e.length-1?(i=r[0]-e[t-1][0],s=r[1]-e[t-1][1]):(i=e[t+1][0]-e[t-1][0],s=e[t+1][1]-e[t-1][1]);const a=Math.sqrt(i*i+s*s)||1;o.push([r[0]+s/a*n,r[1]+-i/a*n])}return o}function Lx(e,t,n,o,r){const i=t[0]-e[0],s=t[1]-e[1],a=Math.sqrt(i*i+s*s);if(0===a)return[e,t];const c=s/a,l=-i/a,u=r/2+1;return[[e[0]+c*u,e[1]+l*u],[t[0]+c*u,t[1]+l*u]]}var Ix=require("d3-scale");var Tx=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],$x=["scene-style","data-paint","accessibility","evidence"],zx=(e,t)=>({retainedData:e,invalidations:t}),Dx=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ex=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ox=["scene-geometry","data-paint","accessibility","evidence"],Fx=["scene-style","data-paint","accessibility","evidence"],Bx=["overlay","accessibility","evidence"],Nx=[],Wx={xAccessor:zx("rebuild",Dx),yAccessor:zx("rebuild",Dx),lineDataAccessor:zx("rebuild",Dx),pointIdAccessor:zx("rebuild",Ox),lineIdAccessor:zx("rebuild",Ox),windowSize:zx("rebuild",Dx),projection:zx("preserve",Ex),projectionExtent:zx("preserve",Ex),fitPadding:zx("preserve",Ex),lineType:zx("preserve",Ex),flowStyle:zx("preserve",Ex),graticule:zx("preserve",Ex),projectionTransform:zx("preserve",Ex),customLayout:zx("preserve",Ex),layoutConfig:zx("preserve",Ex),layoutMargin:zx("preserve",Ex),areaStyle:zx("preserve",Fx),pointStyle:zx("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:zx("preserve",Fx),colorScheme:zx("preserve",Fx),themeCategorical:zx("preserve",Fx),themeDiverging:zx("preserve",Fx),themeSemantic:zx("preserve",Fx),themeSequential:zx("preserve",Fx),decay:zx("preserve",Fx),pulse:zx("preserve",Fx),layoutSelection:zx("preserve",Fx),annotations:zx("preserve",Bx),autoPlaceAnnotations:zx("preserve",Bx),clock:zx("preserve",Nx),transition:zx("preserve",Nx),introAnimation:zx("preserve",Nx),onLayoutError:zx("preserve",Nx)},qx=zx("preserve",Ex),Yx=class{constructor(){this.tracker=new Wn}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}},Tx)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},$x):this.recordNoop("restyle")}recordConfig(e,t={}){const n=function(e){let t="preserve";const n=new Set;for(const o of e){const e=Wx[o]??qx;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e),o=new Set(n.invalidations);return t.retainedDataChanged&&o.add("data"),this.tracker.record({kind:"config",keys:e},o)}},Gx=require("d3-geo");function Hx(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 Vx=class e{constructor(e){this.updateResults=new Yx,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:Hx(e.fitPadding)}}(e)}currentTime(){return this.config.clock?.()??Bt()}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(),n=this.timestampBuffer?.toArray()??[],o=t.slice(-e),r=n.slice(-o.length),i=this.currentTime();this.pointBuffer=new Pt(e),this.timestampBuffer=new Pt(e),o.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(r[t]??i)})}this.retainNewestLines(e)}updateConfig(e){const t=function(e){return"fitPadding"in e?{...e,fitPadding:Hx(e.fitPadding)}:e}(e),n=this.config,o=this.getConfiguredWindowSize(),r=Object.keys(t).filter(e=>t[e]!==n[e]);this.config={...this.config,...t};const i=this.getConfiguredWindowSize(),s=this.streaming&&i!==o;s&&(this.resizeStreamingWindow(i),this.version++),"customLayout"in t&&!t.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(r,{retainedDataChanged:s})}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(),n=this.pointBuffer?this.pointBuffer.toArray():this.pointData,o=this.timestampBuffer?.toArray()??[],r=n.slice(-t),i=o.slice(-r.length),s=this.currentTime();this.pointBuffer=new Pt(t),this.timestampBuffer=new Pt(t),r.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(i[t]??s)}),this.pointData=[],this.retainNewestLines(t),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();const t=this.currentTime();Cn(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 n of e)Cn(this.pointBuffer,n,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 n="function"==typeof t?t:e=>e[t],o=new Set(Array.isArray(e)?e:[e]),r=[];return this.lineData=this.lineData.filter(e=>!o.has(n(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 n="function"==typeof t?t:e=>e[t],o=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){const e=e=>o.has(n(e)+"");Rn(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=>!o.has(n(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 n of this.scene){const o=this._baseStyles.get(n)??n.style,r=t(n,e);n.style=r?{...o,...r}:o}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(e){const{config:t}=this,n=this.projection,o=this.geoPath,r=this.scales,i=this.baseScale,s=[...this.baseTranslate],a=[...this.baseRotation],c=this.scene;this.projection=function(e){if(!e)return(0,Sx.geoEqualEarth)();if("string"==typeof e){const t=Ax[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),(0,Sx.geoEqualEarth)())}if("object"==typeof e&&"type"in e){const t=Ax[e.type],n=t?t():(0,Sx.geoEqualEarth)();return e.rotate&&"rotate"in n&&n.rotate(e.rotate),e.center&&"center"in n&&n.center(e.center),n}return e}(t.projection),this.geoPath=(0,wx.geoPath)(this.projection),this.fitProjection(e),this.geoPath=(0,wx.geoPath)(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=n,this.geoPath=o,this.scales=r,this.baseScale=i,this.baseTranslate=s,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,n=e.height/2,o=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:n}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,t.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(e){const t=this.projection,n=this.config,o=[...this.areas],r=Mx(n.xAccessor,"lon"),i=Mx(n.yAccessor,"lat"),s=this.getPoints();if(s.length>0){const e=s.map(e=>[r(e),i(e)]);o.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const a=_x(n.lineDataAccessor);for(const e of this.lineData){const t=a(e);if(t&&t.length>0){const e=t.map(e=>[r(e),i(e)]);o.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==o.length){if(n.projectionExtent){const[[o,r],[i,s]]=n.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[o,r],[o,s],[i,s],[i,r],[o,r]]]}})}else if(t.clipAngle&&(t.clipAngle()??0)>0){const o=n.fitPadding??0,r=Math.min(e.width,e.height);t.scale(r/2-r*o),t.translate([e.width/2,e.height/2])}else{const r=n.fitPadding??0,i=e.width*r,s=e.height*r;t.fitExtent([[i,s],[e.width-i,e.height-s]],{type:"FeatureCollection",features:o})}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){const n=this.projection;if(!n)return;const o=this.geoPath,r=this.scales,i=n.scale(),s=[...n.translate()],a=this.currentZoom;n.scale(this.baseScale*e.k),n.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=(0,wx.geoPath)(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(i),n.translate(s),this.currentZoom=a,this.geoPath=o,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 n=this.projection;if(!n)return;const o=this.geoPath,r=this.scales,i=n.scale(),s=[...n.translate()],a=this.currentZoom;n.scale(this.baseScale*e),n.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=(0,wx.geoPath)(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(i),n.translate(s),this.currentZoom=a,this.geoPath=o,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 n=this.projection;if(!n||!n.rotate)return;const o=this.geoPath,r=this.scales,i=[...n.rotate()];n.rotate(e),this.geoPath=(0,wx.geoPath)(n),this.scales={projection:n,geoPath:this.geoPath,projectedPoint:(e,t)=>n([e,t]),invertedPoint:(e,t)=>n.invert?n.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const s=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.rotate(i),this.geoPath=o,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=s,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,n=0;for(const e of this.scene)"point"===e.type&&!1!==e.interactive&&(n++,e.r>t&&(t=e.r));if(this._maxPointRadius=t,e.QUADTREE_THRESHOLD>=n)return void(this._quadtree=null);const o=Array(n);let r=0;for(const e of this.scene)"point"===e.type&&!1!==e.interactive&&(o[r++]=e);this._quadtree=(0,kx.quadtree)().x(e=>e.x).y(e=>e.y).addAll(o)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){this._customLayoutFailedThisBuild=!1;const{config:t}=this,n=this.projection,o=this.geoPath;if(t.customLayout&&this.scales){const n=t.layoutMargin??{top:0,right:0,bottom:0,left:0},o=lp(t.colorScheme,t.themeCategorical,fe),r={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:n,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...o]},resolveColor:up(o,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null};let i;try{i=t.customLayout(r)}catch(e){const n=null!==this.lastCustomLayoutResult,o=wn("geo",e,n,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",e);try{t.onLayoutError?.(o)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return n?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}const s=i.nodes??[];if(this.customLayoutOverlays=i.overlays??null,this.lastCustomLayoutResult=i,this.lastCustomLayoutFailure=null,this._customRestyle=i.restyle,this.hasCustomRestyle=!!i.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(const e of s)this._baseStyles.set(e,e.style);this.restyleScene(t.layoutSelection??null)}return xn({label:"geo customLayout",nodes:s,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),s}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:n,areas:o,points:r,lines:i,layout:s}){const a=Mx(e.xAccessor,"lon"),c=Mx(e.yAccessor,"lat"),l=[],u=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),h=function(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(e);if(e.graticule){const t=!0===e.graticule?{}:e.graticule,o=(0,Gx.geoGraticule)();t.step&&o.step(t.step);const r=n(o())||"";r&&l.push({type:"geoarea",pathData:r,centroid:[s.width/2,s.height/2],bounds:[[0,0],[s.width,s.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 o){const o=n(t);if(!o)continue;const r=n.centroid(t),i=n.bounds(t),s=n.area(t);l.push({type:"geoarea",pathData:o,centroid:r,bounds:i,screenArea:s,style:Px(e.areaStyle,t,u),datum:t,interactive:!0})}const f=_x(e.lineDataAccessor);for(const n of i){const o=f(n);if(!o||2>o.length)continue;let r=[];if("geo"===e.lineType){const e=Array(o.length);for(let t=0;o.length>t;t++)e[t]=[a(o[t]),c(o[t])];for(let n=0;e.length-1>n;n++){const o=e[n],i=e[n+1],s=(0,Gx.geoDistance)(o,i)||0,a=Math.max(2,Math.ceil(s/(Math.PI/180))),c=(0,Gx.geoInterpolate)(o,i);for(let e=0;a>=e;e++){if(n>0&&0===e)continue;const o=t(c(e/a));null!=o&&r.push(o)}}}else for(let e=0;o.length>e;e++){const n=o[e],i=t([a(n),c(n)]);null!=i&&r.push(i)}if(2>r.length)continue;const i=Px(e.lineStyle,n,d),u="number"==typeof i.strokeWidth?i.strokeWidth:1;2!==o.length||2>r.length||"arc"!==e.flowStyle?2!==o.length||2>r.length||"offset"!==e.flowStyle||(r="geo"===e.lineType?Rx(r,u):Lx(r[0],r[r.length-1],0,0,u)):r=Cx(r[0],r[r.length-1]);const h=jx(r,s.width);if(h.length>1)for(const e of h)2>e.length||l.push({type:"line",path:e,style:{...i,_edgeFade:!0},datum:n});else l.push({type:"line",path:2>r.length&&h[0]||r,style:i,datum:n})}const p=e.pointIdAccessor?"function"==typeof e.pointIdAccessor?e.pointIdAccessor:t=>t[e.pointIdAccessor]:null,y=t.clipAngle?t.clipAngle()??0:0,g=y>0?y*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 n of r){const o=a(n),r=c(n);if(null!=g&&(0,Gx.geoDistance)([o,r],b)>g)continue;const i=t([o,r]);if(!i)continue;const s=e.pointStyle?e.pointStyle(n):{...h},u={type:"point",x:i[0],y:i[1],r:s.r||4,style:s,datum:n,pointId:p?p(n)+"":void 0};l.push(u)}return l}({config:t,projection:n,path:o,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:e})}applyCartogramTransform(e,t){const n=function(e,t,n,o){const r=e.filter(e=>"point"===e.type);if(2>r.length)return null;const i=t.strength??1,s=Number.isFinite(i)?Math.max(0,Math.min(1,i)):1,a="strip"===t.layout?"strip":"radial";if("radial"===a&&0===s)return null;const c=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,l="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=r.find(e=>e.datum&&c(e.datum)+""==t.center+"");if(!u)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;const d=we(r.map(e=>e.datum?Number(l(e.datum)):NaN).filter(e=>isFinite(e)&&e>=0),1);o>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 n=e[t];"geoarea"===n.type&&n.interactive&&e.splice(t,1)}const h="strip"===a?function(e,t,n,o,r){const i=Math.max(3,Math.min(8,.35*r.height)),s=Math.max(1,r.width-2*i),a=r.height/2,c=(0,Ix.scaleLinear)().domain([0,o]).range([0,s]);t.x=i,t.y=a;const l=[];for(const r of e){if(r===t)continue;if(!r.datum){r.x=i,r.y=a;continue}const e=Number(n(r.datum)),s=i+(isFinite(e)&&e>=0&&o>0?c(e):0);r.x=s,r.y=a,l.push({node:r,x:s})}l.sort((e,t)=>e.x-t.x);const u=Math.max(0,Math.min(r.height/2-1,6));let d=0;for(;l.length>d;){let e=d+1;for(;l.length>e&&3>Math.abs(l[e].x-l[d].x);)e++;const t=e-d;if(t>1&&u>0)for(let e=0;t>e;e++)l[d+e].node.y=a+(e-(t-1)/2)*Math.min(2.5,2*u/Math.max(1,t-1));d=e}return{cx:i,cy:a,maxCost:o,availableRadius:s,layout:"strip"}}(r,u,l,d,n):function(e,t,n,o,r,i){const s=t.x,a=t.y,c=i.width/2,l=i.height/2,u=Math.min(i.width,i.height)/2,d=(0,Ix.scaleLinear)().domain([0,o]).range([0,u]);for(const i of e){if(i===t)continue;if(!i.datum)continue;const e=i.x,u=i.y,h=Math.atan2(u-a,e-s),f=Math.hypot(e-s,u-a),p=Number(n(i.datum)),y=isFinite(p)&&p>=0?o>0?d(p):0:f,g=c+Math.cos(h)*y,m=l+Math.sin(h)*y;i.x=e+(g-e)*r,i.y=u+(m-u)*r}return t.x=s+(c-s)*r,t.y=a+(l-a)*r,{cx:t.x,cy:t.y,maxCost:o,availableRadius:u,layout:"radial"}}(r,u,l,d,s,n),f=e.filter(e=>"line"===e.type);if(f.length>0){const e=new Map;for(const t of r)null!=t.pointId&&e.set(t.pointId+"",[t.x,t.y]);for(const n of f){const o=n.datum?.source,r=n.datum?.target;if(null!=o&&null!=r){const i=e.get(o+""),s=e.get(r+"");if(i&&s)if("fractional"===t.lineMode&&n.path.length>2){const e=n.path[0],t=n.path[n.path.length-1],o=[i[0]-e[0],i[1]-e[1]],r=[s[0]-t[0],s[1]-t[1]],a=[0];for(let e=1;n.path.length>e;e++)a.push(a[e-1]+Math.hypot(n.path[e][0]-n.path[e-1][0],n.path[e][1]-n.path[e-1][1]));const c=a[a.length-1];n.path=n.path.map((e,t)=>{const i=c>0?a[t]/c:t/(n.path.length-1);return[e[0]+o[0]*(1-i)+r[0]*i,e[1]+o[1]*(1-i)+r[1]*i]})}else n.path=[i,s]}}}return h}(this.scene,e,t,this.areas.length);n&&(this.cartogramLayout=n)}applyDecay(){const e=this.config.decay;if(!e||!this.pointBuffer)return;const t=this.pointBuffer.size;if(0===t)return;const n=this.scene.filter(e=>"point"===e.type);for(let o=0;n.length>o;o++){const r=Nt(e,o,t);n[o]._decayOpacity=r,n[o].style={...n[o].style,opacity:r}}}applyPulse(e=this.currentTime()){const t=this.config.pulse;if(!t||!this.timestampBuffer)return!1;const n=this.scene.filter(e=>"point"===e.type),o=this.timestampBuffer.toArray(),r=t.color||"rgba(255,255,255,0.6)",i=t.glowRadius??4;let s=!1;for(let a=0;n.length>a&&o.length>a;a++){const c=qt(t,o[a],e);s=Yt(n[a],c,r,i)||s}return s}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&Gt(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 n=new Map;for(const t of e)"point"===t.type&&t.pointId&&n.set(t.pointId,[t.x,t.y]);const o=this.scene.filter(e=>"point"===e.type);let r=!1;for(const e of o)if(e.pointId){const t=n.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 o)e.pointId&&!n.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=Ot(e,this.activeTransition),n=Et(t),o=this.scene.filter(e=>"point"===e.type);for(const e of o){if(null!=e._targetX&&null!=e._targetY){const t=e.y;e.x=Ft(e.x,e._targetX,n),e.y=Ft(t,e._targetY,n)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*n})}if(t>=1){for(const e of o)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}};Vx.QUADTREE_THRESHOLD=500;var Xx=Vx;On(Xx);var Ux=require("react/jsx-runtime");function Kx(e,t){const n=Je(e.theme),o=e.size||[e.width||600,e.height||400],r=qs({top:10,right:10,bottom:10,left:10,...e.margin},e.title),i=Ns(e.title),s=Array.isArray(e.areas)?D(e.areas):e.areas,a=D(e.points),c=D(e.lines),l=e.showLegend?(()=>{const t="string"==typeof(n=e.colorBy)||"function"==typeof n?e.colorBy:void 0;var n;return Ky(a.length>0?a:Array.isArray(s)&&s.length>0?"string"==typeof t?s.map(e=>({...e.properties||{},...e})):s:[],t)})():[];fg(r,{props:e,categories:l,theme:n,size:o,hasTitle:i});const u=o[0]-(r.left??0)-(r.right??0),d=o[1]-(r.top??0)-(r.bottom??0),h={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:n.colors.categorical,themeSemantic:qe(n)},f=new Xx(h);if(s){if("string"==typeof s)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${s}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${s}')\` before calling renderGeoToStaticSVG.`);f.setAreas(s)}e.points&&f.setPoints(a),e.lines&&f.setLines(c),f.computeScene({width:u,height:d});const p=Pl({nodes:f.scene,renderMode:e.renderMode,fallback:(e,t)=>function(e,t){switch(e.type){case"geoarea":{const n=e;if(!n.pathData)return null;const o=Bo(n.style.fill)?qo(n.style.fill,`geoarea-${t}-hatch`):void 0;return(0,ha.jsxs)(da.Fragment,{children:[o&&(0,ha.jsx)("defs",{children:o}),(0,ha.jsx)("path",{d:n.pathData,fill:o?`url(#geoarea-${t}-hatch)`:oa(n.style.fill,"#e0e0e0"),fillOpacity:n.style.fillOpacity??1,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth||.5,strokeDasharray:n.style.strokeDasharray,opacity:n._decayOpacity??1})]},"geoarea-"+t)}case"point":{const n=e,o=Bo(n.style.fill)?qo(n.style.fill,`geopoint-${t}-hatch`):void 0;return(0,ha.jsxs)(da.Fragment,{children:[o&&(0,ha.jsx)("defs",{children:o}),(0,ha.jsx)("circle",{cx:n.x,cy:n.y,r:n.r,fill:o?`url(#geopoint-${t}-hatch)`:oa(n.style.fill),fillOpacity:n.style.fillOpacity??.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n._decayOpacity??n.style.opacity??1})]},"point-"+t)}case"line":{const n=e;if(2>n.path.length)return null;const o="M"+n.path.map(e=>`${e[0]},${e[1]}`).join("L");return(0,ha.jsx)("path",{d:o,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||1.5,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity??1},"line-"+t)}case"glyph":return ia(e,e.x,e.y,"geo-glyph-"+(e.pointId??t));default:return null}}(e,t)});if(t&&(t.evidence=Dy({frameType:"geo",width:o[0],height:o[1],marks:p.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,legendItems:l.length>0?l.length:void 0,margin:r})),0===p.length){const t=e.backgroundGraphics||e.foregroundGraphics||e.annotations||f.customLayoutOverlays?(0,Ux.jsxs)(Ux.Fragment,{children:[e.backgroundGraphics,e.annotations?rg({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{geoProjection:f.scales?.projectedPoint?([e,t])=>f.scales.projectedPoint(e,t):void 0},layout:{width:u,height:d},theme:n,idPrefix:e._idPrefix}):null,e.foregroundGraphics,f.customLayoutOverlays]}):null;return vx.renderToStaticMarkup(gg(t,{width:o[0],height:o[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left??0},${r.top??0})`,innerWidth:u,innerHeight:d,idPrefix:e._idPrefix}))}const y=p.map(e=>e.element),g=e.annotations?rg({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{geoProjection:f.scales?.projectedPoint?([e,t])=>f.scales.projectedPoint(e,t):void 0},layout:{width:u,height:d},theme:n,idPrefix:e._idPrefix}):null,m=pg({props:e,categories:l,theme:n,size:o,margin:r,hasTitle:i});return vx.renderToStaticMarkup(gg((0,Ux.jsxs)(Ux.Fragment,{children:[e.backgroundGraphics,y,g,e.foregroundGraphics,f.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${r.left??0},${r.top??0})`,innerWidth:u,innerHeight:d,legend:m,idPrefix:e._idPrefix}))}var Zx=y(require("react-dom/server"));function Qx(e=[]){return e.map(e=>({id:e.id,label:e.label,count:e.count,...null!=e.secondary?{secondary:e.secondary}:{},...e.secondaryLabel?{secondaryLabel:e.secondaryLabel}:{},...null!=e.observed?{observed:e.observed}:{}}))}var Jx={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function eb(e){const t=e.datum;if(t&&"object"==typeof t){const e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e.id}function tb(e,t){const n="function"==typeof t?t(e):t;return{...Jx,...n??{}}}function nb(e,t={}){return e.map(e=>function(e,t={}){const n=function(e){return e.datum&&"object"==typeof e.datum?e.datum:null}(e),o={label:t.getBodyLabel?.(e)??eb(e)},r={style:tb(e,t.bodyStyle),datum:n,accessibleDatum:n,accessibility:o,_transitionKey:e.id};return"aabb"===e.shape.type?{type:"rect",x:e.x-e.shape.width/2,y:e.y-e.shape.height/2,w:e.shape.width,h:e.shape.height,...r}:{type:"point",x:e.x,y:e.y,r:e.shape.radius,pointId:e.id,...r}}(e,t))}var ob=require("react/jsx-runtime"),rb={top:0,right:0,bottom:0,left:0};function ib(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function sb(e,t){const n=e.size??[e.width??600,e.height??400],o=new Hf(e.config);Array.isArray(e.initialSpawns)&&e.initialSpawns.length>0&&o.enqueue(e.initialSpawns.map(e=>({...e,spawnAt:void 0})));const r=function(e,t={}){const{width:n=640,height:o=360,title:r,description:i,background:s,backgroundGraphics:a,className:c,foregroundGraphics:l,idPrefix:u="physics",margin:d,renderBodySVG:h,...f}=t,p=function(e,t={}){const n=e.settle(t.maxSteps),o=e.readBodies(),r=e.snapshot(),i=nb(o,t),s=function(e,t={}){const n=t.bodies??function(e){return e.world.bodies.map(e=>({id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,shape:{...e.shape},sleeping:e.sleeping,datum:e.datum}))}(e),o=n.filter(e=>e.sleeping).length,r=e.queue.length,i=e.sediment.reduce((e,t)=>e+t.count,0),s="settled"===e.simulationState&&0===r&&o===n.length,a=[];r>0&&a.push("PHYSICS_QUEUE_UNDRAINED");const c=null!=t.charge&&Number.isFinite(t.charge)?function(e,t,n,o){const r=e-(t+n+o);return{charge:e,live:t,queued:n,sedimented:o,unaccounted:r,balanced:0===r}}(t.charge,n.length,r,i):void 0;return c&&!c.balanced&&a.push("PHYSICS_LEDGER_MISMATCH"),{bodyCount:n.length,sleepingCount:o,settled:s,stepsRun:Math.max(0,Math.floor(t.stepsRun??0)),seed:e.world.options.seed,binCounts:Qx(t.projectionRows),queuedCount:r,sedimentedCount:i,...c?{ledger:c}:{},warnings:a}}(r,{bodies:o,projectionRows:t.projectionRows,stepsRun:n,charge:t.charge});return{snapshot:r,bodies:o,sceneNodes:i,evidence:s,stepsRun:n}}(e,f),y={...rb,...d},g=[n,o],m=ib(a,g,y),x=ib(l,g,y),b=function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"physics-"+t:t}(u),v=r?b+"-title":void 0,w=i?b+"-desc":void 0,k=[v,w].filter(Boolean).join(" ")||void 0;return{svg:Zx.renderToStaticMarkup((0,ob.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:c??"stream-physics-frame",width:n,height:o,viewBox:`0 0 ${n} ${o}`,role:"img","aria-labelledby":k,children:[r&&(0,ob.jsx)("title",{id:v,children:r}),i&&(0,ob.jsx)("desc",{id:w,children:i}),!a&&s&&"transparent"!==s?(0,ob.jsx)("rect",{x:0,y:0,width:n,height:o,fill:s}):null,m,(0,ob.jsx)("g",{id:b+"-data-area",children:p.sceneNodes.map((e,t)=>{const n=p.bodies[t];return(n&&h?h(n,e.style??{},t,b):void 0)??Sa(e,t,b)})}),x]})),scene:p,evidence:p.evidence}}(o,{...e,width:n[0],height:n[1],charge:e.charge,idPrefix:e.idPrefix??e._idPrefix??"physics"});return t&&(t.evidence=Dy({frameType:"physics",width:n[0],height:n[1],marks:r.scene.sceneNodes,title:e.title,description:e.description,annotations:[],extraWarnings:[...0===r.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[],...r.scene.evidence.warnings]})),r.svg}var ab=y(require("react-dom/server"));var cb=require("react/jsx-runtime"),lb={tile:{width:280,height:184,padding:16,labelSize:13,captionSize:11,valueSize:40,detailSize:13,align:"start",border:!0,showHeader:!0,showDetail:!0},presentation:{width:540,height:320,padding:32,labelSize:18,captionSize:14,valueSize:96,detailSize:18,align:"center",border:!0,showHeader:!0,showDetail:!0},inline:{width:240,height:64,padding:8,labelSize:0,captionSize:0,valueSize:28,detailSize:13,align:"start",border:!1,showHeader:!1,showDetail:!0},thumbnail:{width:96,height:56,padding:6,labelSize:0,captionSize:0,valueSize:22,detailSize:0,align:"center",border:!1,showHeader:!1,showDetail:!1}};function ub(e,t){return"number"==typeof e&&Number.isFinite(e)&&e>0?e:t}var db={BigNumber:function(e,t){const n="presentation"===e.mode||"inline"===e.mode||"thumbnail"===e.mode?e.mode:"tile",o=lb[n],r=ub(e.width,o.width),i=ub(e.height,o.height),s="number"==typeof e.padding&&Number.isFinite(e.padding)?Math.max(0,e.padding):o.padding,a="center"===e.align||"end"===e.align||"start"===e.align?e.align:o.align,c="center"===a?"middle":"end"===a?"end":"start",l="center"===a?r/2:"end"===a?r-s:s,u=Je(e.theme),d="number"==typeof e.value&&Number.isFinite(e.value)?e.value:void 0,h=function(e,t={}){if("function"==typeof e)return e;const n=t.locale??"en-US";if("currency"===e){const e=t.precision??2,o=new Intl.NumberFormat(n,{style:"currency",currency:t.currency??"USD",maximumFractionDigits:e,minimumFractionDigits:e});return e=>o.format(e)}if("percent"===e){const e=new Intl.NumberFormat(n,{style:"percent",maximumFractionDigits:t.precision??1,minimumFractionDigits:0});return t=>e.format(t)}if("compact"===e){const e=new Intl.NumberFormat(n,{notation:"compact",maximumFractionDigits:t.precision??1,minimumFractionDigits:0});return t=>e.format(t)}if("duration"===e)return e=>function(e){if(!Number.isFinite(e))return e+"";const t=0>e?"-":"",n=Math.abs(e);if(1e3>n)return`${t}${Math.round(n)}ms`;const o=n/1e3;if(60>o)return`${t}${r=o,Math.round(100*r)/100+""}s`;var r;const i=o/60;if(60>i){const e=Math.floor(i),n=Math.round(o-60*e);return 0===n?`${t}${e}m`:`${t}${e}m ${n}s`}const s=i/60;if(24>s){const e=Math.floor(s),n=Math.round(i-60*e);return 0===n?`${t}${e}h`:`${t}${e}h ${n}m`}const a=Math.floor(s/24),c=Math.round(s-24*a);return 0===c?`${t}${a}d`:`${t}${a}d ${c}h`}(e);const o=new Intl.NumberFormat(n,{notation:t.notation??"standard",maximumFractionDigits:t.precision??0,minimumFractionDigits:0});return e=>o.format(e)}("string"==typeof e.format||"function"==typeof e.format?e.format:"number",{locale:"string"==typeof e.locale?e.locale:void 0,currency:"string"==typeof e.currency?e.currency:void 0,precision:"number"==typeof e.precision?e.precision:void 0}),f=void 0===d?"No value":(p=h(d),`${("string"==typeof e.prefix?e.prefix:void 0)??""}${p}${("string"==typeof e.suffix?e.suffix:void 0)??""}`);var p;const y=void 0===d?void 0:function(e,t){if(!t||0===t.length)return null;if(!Number.isFinite(e))return null;const n=t.filter(e=>Number.isFinite(e.at)||e.at===-1/0).slice().sort((e,t)=>e.at-t.at);let o=null;for(const t of n){if(t.at>e)break;o=t}return o}(d,e.thresholds),g="string"==typeof e.color?e.color:function(e,t,n){return t||("success"===e?n.colors.success??"#2ca02c":"warning"===e?n.colors.warning??"#b26a00":"danger"===e?n.colors.danger??"#d62728":"info"===e?n.colors.info??n.colors.primary:n.colors.text)}(y?.level??"neutral",y?.color,u),m="string"==typeof e.label?e.label:void 0,x="string"==typeof e.caption?e.caption:void 0,b="string"==typeof e.unit?e.unit:void 0,v=void 0===d?void 0:function(e,t,n){const o=e.comparison&&"object"==typeof e.comparison?e.comparison:void 0,r=o&&"number"==typeof o.value&&Number.isFinite(o.value)?o.value:void 0,i=("number"==typeof e.delta&&Number.isFinite(e.delta)?e.delta:void 0)??(void 0===r?void 0:t-r);if(void 0===i)return;const s=function(e,t){return Number.isFinite(e)?0===e?t(0):`${e>0?"+":"−"}${t(Math.abs(e))}`:""}(i,n);return`${s}${o&&"string"==typeof o.label?" "+o.label:""}`}(e,d,h),w=void 0===d?void 0:function(e,t,n){const o=e.target&&"object"==typeof e.target?e.target:void 0;if(!o||"number"!=typeof o.value||!Number.isFinite(o.value))return;const r="string"==typeof o.label?" "+o.label:"";return 0===o.value?`target ${n(o.value)}${r}`:`${new Intl.NumberFormat("string"==typeof e.locale?e.locale:"en-US",{style:"percent",maximumFractionDigits:0}).format(t/o.value)} of ${n(o.value)}${r}`}(e,d,h),k=[v,w,y?.label].filter(Boolean).join(" · "),S="string"==typeof e.description&&e.description||[m,f,b,k].filter(Boolean).join(", "),A="string"==typeof e.background?e.background:u.colors.surface??u.colors.background,M="string"==typeof e.borderColor?e.borderColor:u.colors.border,_=s+o.labelSize,P=_+o.captionSize+4,j="presentation"===n?i/2+.32*o.valueSize:"thumbnail"===n?i/2+.34*o.valueSize:Math.min(i-s-(k?26:4),(o.showHeader&&(m||x)?x?P+10:_+14:s)+o.valueSize),C=l+("start"===c?Math.max(o.valueSize,f.length*o.valueSize*.55):0),R=ab.renderToStaticMarkup((0,cb.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:r,height:i,viewBox:`0 0 ${r} ${i}`,role:"img","aria-label":S,"data-semiotic-component":"BigNumber",children:[(0,cb.jsx)("title",{children:m??f}),"string"==typeof e.description&&(0,cb.jsx)("desc",{children:e.description}),(0,cb.jsx)("rect",{x:o.border?.5:0,y:o.border?.5:0,width:o.border?r-1:r,height:o.border?i-1:i,rx:o.border?8:0,fill:A,stroke:o.border?M:"none"}),o.showHeader&&m&&(0,cb.jsx)("text",{x:l,y:_,textAnchor:c,fontFamily:u.typography.fontFamily,fontSize:o.labelSize,fontWeight:600,fill:u.colors.text,children:m}),o.showHeader&&x&&(0,cb.jsx)("text",{x:l,y:P,textAnchor:c,fontFamily:u.typography.fontFamily,fontSize:o.captionSize,fill:u.colors.textSecondary,children:x}),(0,cb.jsx)("text",{x:l,y:j,textAnchor:c,fontFamily:u.typography.fontFamily,fontSize:o.valueSize,fontWeight:600,fontVariant:"tabular-nums",fill:void 0===d?u.colors.textSecondary:g,"data-mark-type":"value",children:f}),b&&void 0!==d&&"start"===c&&(0,cb.jsx)("text",{x:C+6,y:j,textAnchor:"start",fontFamily:u.typography.fontFamily,fontSize:Math.max(11,Math.round(.32*o.valueSize)),fontWeight:500,fill:u.colors.textSecondary,children:b}),o.showDetail&&k&&(0,cb.jsx)("text",{x:l,y:Math.min(i-s,j+o.detailSize+10),textAnchor:c,fontFamily:u.typography.fontFamily,fontSize:o.detailSize,fill:u.colors.textSecondary,children:k})]}));return t&&(t.evidence=Dy({frameType:"value",width:r,height:i,marks:void 0===d?[]:[{type:"value"}],title:m,description:S})),R}};function hb(e,t,n){return db[e](t,n)}var fb=require("react/jsx-runtime");function pb(e,t){switch(e){case"xy":return xg(t);case"ordinal":return Gg(t);case"network":return bx(t);case"geo":return Kx(t);case"physics":return sb(t);default:throw Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function yb(e){return xg(e)}function gb(e){return Gg(e)}function mb(e){return bx(e)}function xb(e){return Kx(e)}var bb=["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","svgAnnotationRules","barColors","legend","legendLayout","autoPlaceAnnotations"],vb=["width","height","showAxes","showGrid","enableHover","showLegend","showLabels","showCategoryTicks","orientation","title","description","summary","accessibleTable","xLabel","yLabel","categoryLabel","valueLabel","linkedHover","mobileInteraction","mobileSemantics","responsiveRules"];function wb(e,t){const n={};for(const o of t)void 0!==e[o]&&(n[o]=e[o]);return n}function kb(e,t,n){return Ab(e,t).svg}function Sb(e,t,n){const o={},{svg:r,frameType:i}=Ab(e,t,0,o),s=o.evidence??Dy({frameType:i,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 s.component=e,{svg:r,evidence:s}}function Ab(e,t,n,o){if(e in db)return{svg:hb(e,t,o),frameType:"value"};const r=Ty[e];if(!r)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);var i;const s=R(r.layout?.mode??("string"==typeof(i=t.mode)&&Object.prototype.hasOwnProperty.call(C,i)?t.mode:void 0),{...r.layout?.modeDefaults,...wb(t,vb)},r.layout?.primarySize),{data:a,theme:c,background:l,className:u,annotations:d,margin:h,colorScheme:f,colorBy:p,legendPosition:y,...g}=t,{width:m,height:x}=s,b=[m,x],v=g.frameProps||{},w=r.layout?.margin,k="function"==typeof w?w(t,s):w??s.marginDefaults,S=void 0!==h?h:v.margin,A=I(S),M="number"==typeof S?{top:S,right:S,bottom:S,left:S}:{...k,...A},_=wb(g,bb),P=e=>v[e]??s[e],j={...v,..._,theme:c,title:s.title,description:s.description,showAxes:P("showAxes"),showLegend:P("showLegend"),showLabels:P("showLabels"),showGrid:P("showGrid"),xLabel:P("xLabel"),yLabel:P("yLabel"),categoryLabel:P("categoryLabel"),valueLabel:P("valueLabel"),background:l,className:u,annotations:d,size:b,margin:M,__explicitMargin:S,__autoLegendMargin:!0,...void 0!==f&&{colorScheme:f},...void 0!==y&&{legendPosition:y},_idPrefix:g._idPrefix},L=r.buildProps(a,p,f,j,g);let $;switch(r.frameType){case"xy":$=xg(L,o);break;case"ordinal":$=Gg(L,o);break;case"network":$=bx(L,o);break;case"geo":$=Kx(L,o);break;case"physics":$=sb(L,o)}const z=r.renderOverlay?.(L,{theme:Je(c)});if(null!=z){const e=T.renderToStaticMarkup((0,fb.jsx)(fb.Fragment,{children:z}));$=$.replace("</svg>",e+"</svg>")}return{svg:$,frameType:r.frameType}}async function Mb(e,t,n={}){const{format:o="png",scale:r=1,background:i}=n;let s,a;s=["xy","ordinal","network","geo","physics"].includes(e)?pb(e,t):kb(e,t),i&&(s=s.replace(/<svg /,`<svg style="background:${i}" `));try{const e="sharp",t=await import(e);a=t.default??t}catch{throw Error('Image export requires the "sharp" package and a Node.js runtime. Install it:\n npm install sharp\nsharp is listed as an optional dependency of semiotic.')}const c=t.width||t.size?.[0]||600,l=t.height||t.size?.[1]||400,u=a(void 0!==globalThis.Buffer?globalThis.Buffer.from(s):(new TextEncoder).encode(s),{density:72*r}).resize(Math.round(c*r),Math.round(l*r));return"jpeg"===o?u.jpeg({quality:90}).toBuffer():u.png().toBuffer()}function _b(e,t={}){const{title:n,subtitle:o,theme:r,width:i=1200,height:s,layout:a={},background:c}=t,l=et(Je(r)),u=a.columns||2,d=a.gap??16;let h=0;n&&(h+=30),o&&(h+=20),h>0&&(h+=10);const f=Math.floor((i-d-d*(u-1))/u),p=[];let y=0,g=h+d,m=0;for(const t of e){const e=Math.min(t.colSpan||1,u),n=t.props.height||300;y+e>u&&(g+=m+d,y=0,m=0),p.push({chart:t,x:d/2+y*(f+d),y:g,w:f*e+d*(e-1),h:n}),m=Math.max(m,n),y+=e}const x=s||g+m+d,b=p.map((e,t)=>{const{chart:n,x:o,y:i,w:s,h:a}=e,c={...n.props,width:s,height:a,theme:r,_idPrefix:"chart-"+t};let l;return l=n.component?kb(n.component,c):n.frameType?pb(n.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"></svg>`,(0,fb.jsx)("g",{transform:`translate(${o},${i})`,children:(0,fb.jsx)("foreignObject",{width:s,height:a,children:(0,fb.jsx)("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:l}})})},"dashboard-chart-"+t)});return T.renderToStaticMarkup((0,fb.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:x,role:"img","aria-label":n||"Dashboard",style:{fontFamily:l.fontFamily},children:[n&&(0,fb.jsx)("title",{children:n}),c&&(0,fb.jsx)("rect",{x:0,y:0,width:i,height:x,fill:c}),n&&(0,fb.jsx)("text",{x:i/2,y:24,textAnchor:"middle",fontSize:l.titleSize+4,fontWeight:"bold",fill:l.text,fontFamily:l.fontFamily,children:n}),o&&(0,fb.jsx)("text",{x:i/2,y:n?46:20,textAnchor:"middle",fontSize:l.labelSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:o}),b]}))}var Pb=y(require("react-dom/server")),jb=require("react/jsx-runtime");function Cb(e,t,n,o={}){const{stepSize:r,windowSize:i,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:d="ease-out",decay:h}=o,f=n.width||600,p=n.height||400,y=Je(n.theme),g={...n,...a&&{xExtent:a},...c&&{yExtent:c}};if(!t||0===t.length)return[];const m=r||Math.max(1,Math.ceil(t.length/(s||Math.min(60,Math.max(10,t.length))))),x=[];for(let e=m;t.length>=e;e+=m)x.push(e);x[x.length-1]!==t.length&&x.push(t.length);const b=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(e),v=qs({top:20,right:20,bottom:30,left:40,...n.margin},n.title),w=f-v.left-v.right,k=p-v.top-v.bottom,S=[];if(b)for(let o=0;x.length>o;o++){const r=x[o],s=t.slice(i?Math.max(0,r-i):0,r),a={chartType:e,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:n.projection||"vertical",oAccessor:n.oAccessor||n.categoryAccessor||"category",rAccessor:n.rAccessor||n.valueAccessor||"value",colorAccessor:n.colorAccessor||n.colorBy,stackBy:n.stackBy,groupBy:n.groupBy,barPadding:n.barPadding,innerRadius:n.innerRadius,normalize:n.normalize,bins:n.bins,colorScheme:n.colorScheme||y.colors.categorical,...h&&{decay:h}},c=new Wg(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:w,height:k}),c.scene.length>0&&S.push(zb(c.scene,f,p,y,g))}else for(let o=0;x.length>o;o++){const r=x[o],s=t.slice(i?Math.max(0,r-i):0,r),m={chartType:e,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:n.xAccessor||"x",yAccessor:n.yAccessor||"y",colorAccessor:n.colorAccessor||n.colorBy,groupAccessor:n.groupAccessor||n.lineBy,lineDataAccessor:n.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:n.colorScheme||y.colors.categorical,lineStyle:n.lineStyle,pointStyle:n.pointStyle,areaStyle:n.areaStyle,sizeAccessor:n.sizeAccessor||n.sizeBy,sizeRange:n.sizeRange,...h&&{decay:h},...l>0&&{transition:{duration:l*(1e3/u),easing:d}}},b=new io(m);if(b.ingest({inserts:s,bounded:!0}),b.computeScene({width:w,height:k}),0===b.scene.length)continue;const v=b.scales?{y:b.scales.y}:void 0;if(S.push($b(b.scene,f,p,y,g,v)),l>0&&o>0&&b.activeTransition){const e=l*(1e3/u);for(let t=1;l>=t;t++)b.advanceTransition(b.activeTransition.startTime+t/l*e),S.push($b(b.scene,f,p,y,g,v))}}return S}function Rb(e,t,n={}){return t.map(t=>{try{return kb(e,{...n,...t})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${n.width||t.width||600}" height="${n.height||t.height||400}"></svg>`}})}function Lb(e,t,n){const o=t.size??[t.width??600,t.height??400],r=Je(t.theme),i=et(r),s=t.background||r.colors.background,a=t.idPrefix??"physics-gif",c=t.title?`${a}-title-${n}`:void 0,l=t.description?`${a}-desc-${n}`:void 0,u=[c,l].filter(Boolean).join(" ")||void 0,d=nb(e.readBodies(),{bodyStyle:t.bodyStyle,getBodyLabel:t.getBodyLabel}),h=(0,jb.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className??"stream-physics-frame",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,role:"img","aria-labelledby":u,style:{fontFamily:i.fontFamily},children:[t.title&&(0,jb.jsx)("title",{id:c,children:t.title}),t.description&&(0,jb.jsx)("desc",{id:l,children:t.description}),s&&"transparent"!==s?(0,jb.jsx)("rect",{x:0,y:0,width:o[0],height:o[1],fill:s}):null,(0,jb.jsx)("g",{id:`${a}-frame-${n}`,children:d.map((e,t)=>Sa(e,t,`${a}-${n}`))})]});return Pb.renderToStaticMarkup(h)}function Ib(e,t={}){const{fps:n=12,frameCount:o,durationSeconds:r=2,includeInitialFrame:i=!0,stepDt:s,stepsPerFrame:a,background:c}=t,l=Math.max(.001,s??e.config?.fixedDt??1/120),u=a??Math.max(1,Math.round(1/Math.max(1,n)/l)),d=o??Math.max(1,Math.ceil(r*Math.max(1,n))),h=c?{...e,background:c}:e,f=new Hf(e.config);e.initialSpawns?.length&&f.enqueue(e.initialSpawns,e.initialSpawnPacing);const p=[];for(i&&(f.tick(0),p.push(Lb(f,h,0)));d>p.length;){for(let e=0;u>e;e+=1)f.tick(l);p.push(Lb(f,h,p.length))}return p}function Tb(e,t){const n=e.background||t.colors.background;return n&&"transparent"!==n?n:null}function $b(e,t,n,o,r,i){const s=et(o),a=qs({top:20,right:20,bottom:30,left:40,...r.margin},r.title),c=t-a.left-a.right,l=n-a.top-a.bottom,u=Tb(r,o),d=r.renderMode,h=e.map((e,t)=>_l({node:e,index:t,renderMode:d,fallback:()=>Sa(e,t)})).filter(Boolean),f=function(e,t,n,o,r,i){if(!e||0===e.length)return null;const s=et(o),a=[];for(let o=0;e.length>o;o++){const c=e[o];if("y-threshold"===c.type&&null!=c.value){let e=null;if(i)e=i(c.value);else if(r){const[t,o]=r,i=o-t;if(0===i)continue;e=n-(c.value-t)/i*n}if(null==e)continue;const l=c.color||s.primary,u=c.labelPosition||"right";a.push((0,jb.jsxs)("g",{children:[(0,jb.jsx)("line",{x1:0,y1:e,x2:t,y2:e,stroke:l,strokeWidth:c.strokeWidth??1.5,strokeDasharray:c.strokeDasharray||"6,4"}),c.label&&(0,jb.jsx)("text",{x:"left"===u?4:"center"===u?t/2:t-4,y:20>e?Math.min(n-4,e+16):e-5,textAnchor:"left"===u?"start":"center"===u?"middle":"end",fontSize:s.tickSize,fill:l,fontFamily:s.fontFamily,children:c.label})]},"ann-"+o))}}return a.length>0?(0,jb.jsx)(jb.Fragment,{children:a}):null}(r.annotations,c,l,o,r.yExtent,i?.y),p="string"==typeof r.title?r.title:void 0,y="string"==typeof r.description?r.description:void 0,g=p?"semiotic-title":void 0,m=y?"semiotic-desc":void 0,x=[g,m].filter(Boolean).join(" ")||void 0;return Pb.renderToStaticMarkup((0,jb.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,role:"img","aria-labelledby":x,style:{fontFamily:s.fontFamily},children:[p&&(0,jb.jsx)("title",{id:g,children:p}),y&&(0,jb.jsx)("desc",{id:m,children:y}),u&&(0,jb.jsx)("rect",{x:0,y:0,width:t,height:n,fill:u}),(0,jb.jsxs)("g",{transform:`translate(${a.left},${a.top})`,children:[f,h]}),p&&(0,jb.jsx)("text",{x:t/2,y:Bs,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:p})]}))}function zb(e,t,n,o,r){const i=et(o),s=qs({top:20,right:20,bottom:30,left:40,...r.margin},r.title),a="radial"===r.projection,c=a?s.left+(t-s.left-s.right)/2:s.left,l=a?s.top+(n-s.top-s.bottom)/2:s.top,u=Tb(r,o),d=r.renderMode,h=e.map((e,t)=>_l({node:e,index:t,renderMode:d,fallback:()=>va(e,t)})).filter(Boolean),f="string"==typeof r.title?r.title:void 0,p="string"==typeof r.description?r.description:void 0,y=f?"semiotic-title":void 0,g=p?"semiotic-desc":void 0,m=[y,g].filter(Boolean).join(" ")||void 0;return Pb.renderToStaticMarkup((0,jb.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:n,role:"img","aria-labelledby":m,style:{fontFamily:i.fontFamily},children:[f&&(0,jb.jsx)("title",{id:y,children:f}),p&&(0,jb.jsx)("desc",{id:g,children:p}),u&&(0,jb.jsx)("rect",{x:0,y:0,width:t,height:n,fill:u}),(0,jb.jsx)("g",{transform:`translate(${c},${l})`,children:h}),f&&(0,jb.jsx)("text",{x:t/2,y:Bs,textAnchor:"middle",fontSize:i.titleSize,fontWeight:"bold",fill:i.text,fontFamily:i.fontFamily,children:f})]}))}async function Db(e,t,n,o={}){const{fps:r=12,loop:i=!0,scale:s=1,background:a}=o,c=n.width||600,l=n.height||400,u=Cb(e,t,a?{...n,background:a}:n,o);if(0===u.length)throw Error("No frames generated — check that data is not empty");return Ob(u,c,l,{fps:r,loop:i,scale:s})}async function Eb(e,t={}){const{fps:n=12,loop:o=!0,scale:r=1}=t,i=e.size??[e.width??600,e.height??400],s=Ib(e,t);if(0===s.length)throw Error("No physics frames generated");return Ob(s,i[0],i[1],{fps:n,loop:o,scale:r})}async function Ob(e,t,n,o={}){const{fps:r=12,loop:i=!0,scale:s=1}=o,a=Math.round(t*s),c=Math.round(n*s);let l,u,d,h;try{const e="sharp",t=await import(e);l=t.default??t}catch{throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const e="gifenc",t=await import(e),n=[t,t.default].find(e=>"function"==typeof e?.GIFEncoder&&"function"==typeof e.quantize&&"function"==typeof e.applyPalette);if(!n)throw Error("gifenc did not expose its encoder functions");u=n.GIFEncoder,d=n.quantize,h=n.applyPalette}catch(e){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc',{cause:e})}const f=Math.round(1e3/r),p=u();for(let t=0;e.length>t;t++){const n=e[t],o=await l(Buffer.from(n),{density:72*s}).resize(a,c).ensureAlpha().raw().toBuffer(),r=new Uint8Array(o),u=d(r,256),y=h(r,u);p.writeFrame(y,a,c,{palette:u,delay:f,repeat:i?0:-1})}return p.finish(),Buffer.from(p.bytes())}
|