semiotic 3.8.3 → 3.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +9 -9
- package/README.md +40 -39
- package/ai/examples.md +1 -1
- package/ai/schema.json +2726 -300
- package/ai/surface-manifest.json +1 -1
- package/ai/system-prompt.md +1 -1
- package/dist/chunk-chunk-2JGJ5GUG.module.min.js +0 -1
- package/dist/chunk-chunk-3ILKBVVQ.module.min.js +1 -0
- package/dist/{chunk-chunk-XQYVEKEJ.module.min.js → chunk-chunk-6TPGFL7M.module.min.js} +1 -1
- package/dist/{chunk-chunk-VVCA3DB7.module.min.js → chunk-chunk-7ALTGHK6.module.min.js} +1 -1
- package/dist/chunk-chunk-7KZJUTKP.module.min.js +2 -0
- package/dist/chunk-chunk-7RYBCTK5.module.min.js +1 -0
- package/dist/chunk-chunk-ACLDBMRH.module.min.js +2 -0
- package/dist/{chunk-chunk-AZJUDQRM.module.min.js → chunk-chunk-AQPQN2HH.module.min.js} +1 -1
- package/dist/chunk-chunk-ASKSE5F5.module.min.js +1 -0
- package/dist/chunk-chunk-AVBI6GDT.module.min.js +1 -0
- package/dist/chunk-chunk-B3DRZPBK.module.min.js +2 -0
- package/dist/chunk-chunk-BFHUYEOS.module.min.js +2 -0
- package/dist/chunk-chunk-C4YA6TDR.module.min.js +1 -0
- package/dist/chunk-chunk-C57LR3YG.module.min.js +1 -0
- package/dist/chunk-chunk-F5V4UIE6.module.min.js +2 -0
- package/dist/chunk-chunk-F7WFPD4O.module.min.js +2 -0
- package/dist/{chunk-chunk-SANERMIZ.module.min.js → chunk-chunk-FBGHXL72.module.min.js} +1 -1
- package/dist/chunk-chunk-FP44FHFO.module.min.js +2 -0
- package/dist/chunk-chunk-HKXUAEPJ.module.min.js +2 -0
- package/dist/chunk-chunk-ICEXPNDC.module.min.js +2 -0
- package/dist/chunk-chunk-IY7RYD4S.module.min.js +1 -0
- package/dist/{chunk-chunk-7FW6EGLP.module.min.js → chunk-chunk-JDXT6ORT.module.min.js} +1 -1
- package/dist/chunk-chunk-JMVEIZXP.module.min.js +1 -0
- package/dist/chunk-chunk-KHCOJMGK.module.min.js +1 -0
- package/dist/{chunk-chunk-OQTLSTGI.module.min.js → chunk-chunk-KQ546MKE.module.min.js} +1 -1
- package/dist/chunk-chunk-LQBSXO7K.module.min.js +2 -0
- package/dist/chunk-chunk-LRIFN2HK.module.min.js +1 -0
- package/dist/chunk-chunk-MFHF4J2Z.module.min.js +1 -0
- package/dist/{chunk-chunk-JNCHKRIR.module.min.js → chunk-chunk-N6VKKF3A.module.min.js} +1 -1
- package/dist/chunk-chunk-NEVE562N.module.min.js +1 -0
- package/dist/chunk-chunk-NKZ75IM5.module.min.js +2 -0
- package/dist/chunk-chunk-PLIDPQNG.module.min.js +2 -0
- package/dist/{chunk-chunk-FYY2ACNJ.module.min.js → chunk-chunk-PRDGLMJT.module.min.js} +1 -1
- package/dist/chunk-chunk-QGZGZI4X.module.min.js +1 -0
- package/dist/chunk-chunk-RP7WTID5.module.min.js +1 -0
- package/dist/chunk-chunk-S7KLNUO6.module.min.js +1 -0
- package/dist/chunk-chunk-SR4ZXOWR.module.min.js +2 -0
- package/dist/chunk-chunk-ZOAQDIJO.module.min.js +1 -0
- package/dist/chunk-minimapBrushOverlay-JU57U7NM.module.min.js +2 -0
- package/dist/chunk-scatterplotMatrixBrushOverlay-SDIZSN66.module.min.js +2 -0
- package/dist/chunk-statisticalOverlays-QGDLRUHX.module.min.js +1 -0
- package/dist/chunk-statisticalOverlays-T77OKLDY.module.min.js +1 -0
- package/dist/components/ChartContainer.d.ts +2 -2
- package/dist/components/ai/chartCapabilityTypes.d.ts +5 -0
- package/dist/components/charts/geo/ChoroplethMap.d.ts +2 -0
- package/dist/components/charts/geo/DistanceCartogram.d.ts +7 -3
- package/dist/components/charts/geo/FlowMap.d.ts +4 -0
- package/dist/components/charts/geo/ProportionalSymbolMap.d.ts +3 -1
- package/dist/components/charts/physics/CollisionSwarmChart.d.ts +6 -1
- package/dist/components/charts/physics/GaltonBoardChart.d.ts +6 -1
- package/dist/components/charts/physics/gauntletChartProps.d.ts +7 -1
- package/dist/components/charts/physics/gauntletChrome.d.ts +2 -1
- package/dist/components/charts/physics/gauntletPhysics.d.ts +19 -4
- package/dist/components/charts/physics/gauntletRuntime.d.ts +3 -0
- package/dist/components/charts/physics/physicsHocUtils.d.ts +12 -0
- package/dist/components/charts/shared/chartMode.d.ts +8 -0
- package/dist/components/charts/shared/chartSpecCore.d.ts +2 -2
- package/dist/components/charts/shared/hatchPattern.d.ts +8 -3
- package/dist/components/charts/shared/lineSeriesSsr.d.ts +55 -0
- package/dist/components/charts/shared/types.d.ts +2 -2
- package/dist/components/charts/shared/validateProps.d.ts +1 -1
- package/dist/components/charts/xy/AreaChart.d.ts +10 -0
- package/dist/components/charts/xy/minimapBrushOverlay.d.ts +17 -0
- package/dist/components/charts/xy/minimapBrushOverlayLazy.d.ts +4 -0
- package/dist/components/charts/xy/scatterplotMatrixBrushOverlay.d.ts +8 -0
- package/dist/components/charts/xy/scatterplotMatrixBrushOverlayLazy.d.ts +3 -0
- package/dist/components/realtime/types.d.ts +5 -0
- package/dist/components/recipes/gridObservatory.d.ts +176 -0
- package/dist/components/recipes/recipeChrome.d.ts +24 -0
- package/dist/components/recipes/sequenceLayout.d.ts +139 -0
- package/dist/components/semiotic-recipes-core.d.ts +6 -2
- package/dist/components/server/staticAnnotations.d.ts +3 -1
- package/dist/components/stream/SceneToSVG.d.ts +6 -6
- package/dist/components/stream/SceneToSVGOrdinal.d.ts +12 -0
- package/dist/components/stream/networkFramePaint.d.ts +2 -0
- package/dist/components/stream/physics/PhysicsPipelineStore.d.ts +18 -2
- package/dist/components/stream/physics/physicsBodyCanvas.d.ts +7 -0
- package/dist/components/stream/physics/physicsPipelineEviction.d.ts +15 -0
- package/dist/components/stream/physics/physicsPipelineObservations.d.ts +1 -1
- package/dist/components/stream/physics/physicsPipelineQuiescence.d.ts +20 -0
- package/dist/components/stream/sceneToSVGShared.d.ts +30 -1
- package/dist/components/stream/types.d.ts +4 -0
- package/dist/components/stream/useHydration.d.ts +7 -1
- package/dist/components/stream/xySceneBuilders/candlestickScene.d.ts +1 -1
- package/dist/forceLayoutWorker.js +1 -1
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/physics.min.js +1 -1
- package/dist/physics.module.min.js +1 -1
- package/dist/physicsWorker.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/rough.min.js +1 -1
- package/dist/rough.module.min.js +1 -1
- package/dist/semiotic-ai-core.min.js +1 -1
- package/dist/semiotic-ai-core.module.min.js +1 -1
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-experimental.min.js +1 -1
- package/dist/semiotic-experimental.module.min.js +1 -1
- package/dist/semiotic-realtime-core.min.js +1 -1
- package/dist/semiotic-realtime-core.module.min.js +1 -1
- package/dist/semiotic-recipes-core.d.ts +6 -2
- package/dist/semiotic-recipes-core.min.js +1 -1
- package/dist/semiotic-recipes-core.module.min.js +1 -1
- package/dist/semiotic-recipes.min.js +1 -1
- package/dist/semiotic-recipes.module.min.js +1 -1
- package/dist/semiotic-server-edge.min.js +1 -1
- package/dist/semiotic-server-edge.module.min.js +1 -1
- package/dist/semiotic-server-node.min.js +1 -1
- package/dist/semiotic-server-node.module.min.js +1 -1
- package/dist/semiotic-utils-core.min.js +1 -1
- package/dist/semiotic-utils-core.module.min.js +1 -1
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-value.module.min.js +1 -1
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +3 -2
- package/dist/chunk-chunk-255KDHW5.module.min.js +0 -1
- package/dist/chunk-chunk-2CCFBTQC.module.min.js +0 -2
- package/dist/chunk-chunk-2RXP3FS3.module.min.js +0 -1
- package/dist/chunk-chunk-2WVCH4PL.module.min.js +0 -1
- package/dist/chunk-chunk-4TMZXLCR.module.min.js +0 -1
- package/dist/chunk-chunk-5APBQXZA.module.min.js +0 -1
- package/dist/chunk-chunk-6HSGDMTA.module.min.js +0 -2
- package/dist/chunk-chunk-7OEOSCBP.module.min.js +0 -1
- package/dist/chunk-chunk-A63CTACR.module.min.js +0 -2
- package/dist/chunk-chunk-B6V35LMY.module.min.js +0 -2
- package/dist/chunk-chunk-BOSVL645.module.min.js +0 -2
- package/dist/chunk-chunk-CP3EN6KZ.module.min.js +0 -1
- package/dist/chunk-chunk-F25UA5HT.module.min.js +0 -1
- package/dist/chunk-chunk-FRIO6MCV.module.min.js +0 -1
- package/dist/chunk-chunk-GWSWSPXN.module.min.js +0 -1
- package/dist/chunk-chunk-I6C3KR5H.module.min.js +0 -2
- package/dist/chunk-chunk-IP2UE74X.module.min.js +0 -1
- package/dist/chunk-chunk-J3ELI22J.module.min.js +0 -1
- package/dist/chunk-chunk-J5RL6GXU.module.min.js +0 -2
- package/dist/chunk-chunk-L3H6DQCR.module.min.js +0 -2
- package/dist/chunk-chunk-M337NY6L.module.min.js +0 -1
- package/dist/chunk-chunk-M7VYYHCE.module.min.js +0 -2
- package/dist/chunk-chunk-MC35ILYP.module.min.js +0 -2
- package/dist/chunk-chunk-N72SWNBV.module.min.js +0 -1
- package/dist/chunk-chunk-OBQRFTIL.module.min.js +0 -2
- package/dist/chunk-chunk-QRIBHZYW.module.min.js +0 -1
- package/dist/chunk-chunk-SA3D43RA.module.min.js +0 -2
- package/dist/chunk-chunk-UHSZEB74.module.min.js +0 -1
- package/dist/chunk-chunk-Y6AXCRVO.module.min.js +0 -1
- package/dist/chunk-chunk-ZCNBUZPL.module.min.js +0 -2
package/dist/server.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var t,e=Object.create,i=Object.defineProperty,o=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,n=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,a=(t,e,n,a)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let c of r(e))s.call(t,c)||c===n||i(t,c,{get:()=>e[c],enumerable:!(a=o(e,c))||a.enumerable});return t},c=(t,o,r)=>(r=null!=t?e(n(t)):{},a(!o&&t&&t.__esModule?r:i(r,"default",{value:t,enumerable:!0}),t)),l={};function u(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}((t,e)=>{for(var o in e)i(t,o,{get:e[o],enumerable:!0})})(l,{generateFrameSVGs:()=>gh,generateFrameSequence:()=>mh,generatePhysicsFrameSVGs:()=>bh,renderChart:()=>lh,renderChartWithEvidence:()=>uh,renderDashboard:()=>fh,renderGeoToStaticSVG:()=>nh,renderNetworkToStaticSVG:()=>rh,renderOrdinalToStaticSVG:()=>oh,renderPhysicsToAnimatedGif:()=>Ah,renderToAnimatedGif:()=>Sh,renderToImage:()=>dh,renderToStaticSVG:()=>eh,renderXYToStaticSVG:()=>ih,resolveTheme:()=>Pt,themeStyles:()=>Lt}),module.exports=(t=l,a(i({},"__esModule",{value:!0}),t));var h=44,d={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:h,snap:"nearestDatum",brushHandleSize:h,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function f(t,e={}){const i=e.mobileSemantics?.interaction,o="number"==typeof i?.targetSize?i.targetSize:"number"==typeof e.mobileSemantics?.minimumHitTarget?e.mobileSemantics.minimumHitTarget:void 0,r="mobile"===e.mode||"number"==typeof e.width&&480>=e.width,n=!!i||void 0!==o,s=t&&"object"==typeof t?t:void 0;if(!1===t||!1===s?.enabled||void 0===t&&!r&&!n)return d;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??o??h,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??h,standardControls:a.standardControls??!1}}var p={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 y(t,e,i){if(!1!==e)return t;const o={...t};return"horizontal"===i?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}var g=c(require("react-dom/server")),m=c(require("react")),x=Object.freeze([]);function b(t){if(!t)return x;let e=!1;for(let i=0;t.length>i;i++){const o=t[i];if(null==o||"object"!=typeof o){e=!0;break}}if(!e)return t;const i=[];for(const e of t)null!=e&&"object"==typeof e&&i.push(e);return i}var v=require("d3-scale");function w(t){return[parseInt(t.slice(1,3),16),parseInt(t.slice(3,5),16),parseInt(t.slice(5,7),16)]}function k(t,e,i){const o=t=>t.toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(i)}`}function S(t){const e=t.map(w),i=e.length-1;return t=>{if(0>=t){const[t,i,o]=e[0];return k(t,i,o)}if(t>=1){const[t,o,r]=e[i];return k(t,o,r)}const o=t*i,r=Math.floor(o),n=o-r,[s,a,c]=e[r],[l,u,h]=e[r+1];return k(Math.round(s+(l-s)*n),Math.round(a+(u-a)*n),Math.round(c+(h-c)*n))}}var A=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],M=S(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),_=S(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),P=S(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),L=S(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),R=S(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),T=S(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),C=S(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),$=S(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),j=S(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),z=S(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),E=S(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),D=S(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),F={blues:M,reds:_,greens:P,viridis:C,oranges:L,purples:R,greys:T,plasma:$,inferno:j,magma:z,cividis:E,turbo:D};function O(t){return t&&F[t]||M}var N=S(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),B=S(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),I=S(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),W=S(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),Y=S(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),q=S(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),X=S(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),G={category10:A,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...F},V=A,H="#007bff";function Z(t,e,i=V){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=Object.values(t).filter(t=>"string"==typeof t&&t.length>0);if(e.length>0)return e}if(Array.isArray(t)&&t.length>0)return t;if("string"==typeof t){const e=G[t];if(Array.isArray(e)&&e.length>0)return e}return e&&e.length>0?e:i}var U=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],K=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 Q(t,e,i){if("function"==typeof e){const o=e(t);return i&&o&&"string"==typeof o&&!function(t){const e=t.toLowerCase();return e.startsWith("#")||e.startsWith("rgb")||e.startsWith("hsl")||K.has(e)}(o)?i(o):o}const o=t?.[e]+"";return i?i(o):V[Math.abs(function(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i),e&=e;return Math.abs(e)}(o))%V.length]}function J(t,e){if(null==e||!Object.prototype.hasOwnProperty.call(t,e))return;const i=t[e];return"string"==typeof i&&i.length>0?i:void 0}function tt(t,e,i="category10"){if(i&&"object"==typeof i&&!Array.isArray(i)){const t=i;return e=>J(t,e)??"#999"}const o=Array.from(new Set(t.map(t=>t?.[e]).filter(t=>null!=t).map(t=>t+""))),r=o.every(t=>!isNaN(Number(t)));if(Array.isArray(i))return(0,v.scaleOrdinal)().domain(o).range(i).unknown("#999");const n=G[i]||G.category10;if(r&&"function"==typeof n){let t=-1/0;for(const e of o){const i=Number(e);i>t&&(t=i)}return e=>n(Number(e)/t)}{const t=Array.isArray(n)?n:V;return(0,v.scaleOrdinal)().domain(o).range(t).unknown("#999")}}function et(t,e,i=[3,20],o){let r;if(r="function"==typeof e?e(t):t?.[e],!o)return r;const[n,s]=o,[a,c]=i;if(s===n)return(a+c)/2;let l=(r-n)/(s-n);return 0>l?l=0:l>1&&(l=1),a+l*(c-a)}function it(t){let e=1/0,i=-1/0;for(const o of t)e>o&&(e=o),o>i&&(i=o);return[e,i]}function ot(t,e=-1/0){let i=e;for(const e of t)e>i&&(i=e);return i}function rt(t){if(null==t)return()=>{};const e="function"==typeof t?t:e=>e[t];return t=>at(e(t))}function nt(t,e){const i=rt(t),o=rt(e);return(t,e)=>{const r=o(t);return{value:r,x:i(t),y:r,category:e}}}function st(t,e){const i=rt(e??"value"),o=null==t?void 0:"function"==typeof t?t:e=>e[t];return t=>{const e=o?o(t):void 0;return{value:i(t),category:null==e?void 0:e+""}}}function at(t){if("number"==typeof t)return Number.isFinite(t)?t:void 0;if("string"==typeof t&&""!==t.trim()){const e=Number(t);return Number.isFinite(e)?e:void 0}}function ct(t,e,i){const o=t.when;return void 0===o||!0===o||!1!==o&&("function"==typeof o?o(e,i):function(t,e,i){const o=null!=t.axis?i[t.axis]:null!=t.field?e[t.field]:i.value;if(void 0!==t.eq&&o!==t.eq)return!1;if(void 0!==t.ne&&o===t.ne)return!1;if(void 0!==t.in&&!t.in.includes(o))return!1;if(void 0===t.gt&&void 0===t.gte&&void 0===t.lt&&void 0===t.lte&&void 0===t.within&&void 0===t.outside)return!0;const r=at(o);if(void 0===r)return!1;if(void 0!==t.gt&&t.gt>=r)return!1;if(void 0!==t.gte&&t.gte>r)return!1;if(void 0!==t.lt&&r>=t.lt)return!1;if(void 0!==t.lte&&r>t.lte)return!1;if(void 0!==t.within){const[e,i]=t.within;if(e>r||r>i)return!1}if(void 0!==t.outside){const[e,i]=t.outside;if(r>=e&&i>=r)return!1}return!0}(o,e,i))}function lt(t,e,i){if(!e||0===e.length)return{};let o={};for(const r of e){if(!ct(r,t,i))continue;const e="function"==typeof r.style?r.style(t,i):r.style;e&&(o={...o,...e})}return o}function ut(t,e,i,o=t=>t){const r=t??(()=>({}));return e&&0!==e.length?(t,n)=>{const s=o(t),a={...r(t,n)};return Object.assign(a,lt(s,e,i(s,n))),a}:r}function ht(t,e,i){return"function"==typeof t?t(i):i[t||e]}function dt(t){return t instanceof Date?t.getTime():Number(t)}function ft(t,e){return C(1===e?.5:t/(e-1))}var pt=require("react"),yt=require("react/jsx-runtime");function gt(t,e){const i=new Set;let o={...t(function(t){const e=t(o);if(function(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!0;return!1}(e)){o={...o,...e};for(const t of i)t()}}),...e??{}};return{getState:()=>o,subscribe:function(t){return i.add(t),()=>{i.delete(t)}}}}function mt(t){if(!t?.colors)return;const e=t.colors;return{primary:e.primary,secondary:e.secondary||e.primary,surface:e.surface||e.background,success:e.success,danger:e.danger,warning:e.warning,error:e.error,info:e.info,text:e.text,textSecondary:e.textSecondary,border:e.border,grid:e.grid}}function xt(t){if(!t.accessibility)return t;let e=t;if(t.accessibility.colorBlindSafe&&(e={...e,colors:{...e.colors,categorical:bt}}),t.accessibility.highContrast){const t="dark"===e.mode;e={...e,colors:{...e.colors,text:t?"#ffffff":"#000000",textSecondary:t?"#cccccc":"#333333",grid:t?"#666666":"#999999",border:t?"#888888":"#000000"}}}return e}var bt=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],vt={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}},wt={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}},kt={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:bt,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 St(t,e){if("light"===e)return vt;if("dark"===e)return wt;if("high-contrast"===e)return kt;if("string"==typeof e)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${e}". Keeping current theme.`),t;if(e.mode&&"auto"!==e.mode){const t="dark"===e.mode?wt:vt;return xt({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}}})}return xt({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}}})}var[At,Mt]=function(t){let e=null;const i=()=>(e||(e=(0,pt.createContext)(null)),e),o=gt(t);return[function({children:e,initialState:o}){const r=(0,pt.useRef)(o),n=(0,pt.useMemo)(()=>gt(t,r.current),[]),s=i();return(0,yt.jsx)(s.Provider,{value:n,children:e})},(t,e)=>{const r=i(),n=(0,pt.useContext)(r)??o,s=(0,pt.useRef)(t);s.current=t;const a=(0,pt.useRef)({hasValue:!1,value:void 0}),c=(0,pt.useCallback)(()=>{const t=s.current(n.getState()),i=a.current;return i.hasValue&&e&&e(i.value,t)?i.value:(a.current={hasValue:!0,value:t},t)},[n,e]),l=(0,pt.useCallback)(()=>s.current(n.getState()),[n]);return(0,pt.useSyncExternalStore)(n.subscribe,c,l)}]}(t=>({theme:vt,setTheme(e){t(t=>({theme:St(t.theme,e)}))}})),_t={light:vt,dark:wt,"high-contrast":kt,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 Pt(t){if(!t)return vt;if("string"==typeof t){if("light"===t)return vt;if("dark"===t)return wt;if("high-contrast"===t)return kt;return _t[t]||vt}const e="dark"===t.mode?wt:vt;return xt({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}},tooltip:{...e.tooltip,...t.tooltip||{}}})}function Lt(t){return{background:t.colors.background,text:t.colors.text,textSecondary:t.colors.textSecondary,grid:t.colors.grid,border:t.colors.border,primary:t.colors.primary,fontFamily:t.typography.fontFamily,titleSize:t.typography.titleSize,labelSize:t.typography.labelSize,tickSize:t.typography.tickSize,categorical:t.colors.categorical,annotation:t.colors.annotation??t.colors.text,legendSize:t.typography.legendSize??t.typography.labelSize,titleFontSize:t.typography.titleFontSize??t.typography.titleSize,tickFontFamily:t.typography.tickFontFamily??t.typography.fontFamily}}function Rt(t,e,i){const o="function"==typeof e?e(t):t[e??i];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}function Tt(t,e,i,o,r){const n=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=Pt(o.theme).colors.categorical,a=i??o.colorScheme??s,c="string"==typeof e?e:"__ssrLineColorBy",l="function"==typeof e?n.map(t=>({...t,__ssrLineColorBy:e(t)})):n,u=e?tt(l,c,a):void 0,h=nt(r.xAccessor,r.yAccessor),d=function(t){const{lineWidth:e=2,colorBy:i,colorScale:o,color:r,resolveStroke:n,fillArea:s,areaOpacity:a=.3,styleRules:c,ruleContext:l}=t;return(t,u)=>{const h={strokeWidth:e},d=!0===s||Array.isArray(s)&&null!=u&&s.includes(u);let f;return n?f=n(t,u):i?o&&(f=Q(t,i,o)):f=r||H,void 0!==f&&(h.stroke=f,d&&(h.fill=f,h.fillOpacity=a)),c?.length&&Object.assign(h,lt(t,c,l?l(t,u):{value:void 0,category:u})),h}}({lineWidth:"number"==typeof r.lineWidth?r.lineWidth:2,colorBy:e,colorScale:u,color:"string"==typeof r.color?r.color:void 0,fillArea:r.fillArea,areaOpacity:"number"==typeof r.areaOpacity?r.areaOpacity:.3,styleRules:r.styleRules,ruleContext:h});return function(t,e){if(!function(t){return void 0!==t.stroke||void 0!==t.strokeWidth||void 0!==t.opacity}(e))return t??((...t)=>({}));const i={};return void 0!==e.stroke&&(i.stroke=e.stroke),void 0!==e.strokeWidth&&(i.strokeWidth=e.strokeWidth),void 0!==e.opacity&&(i.opacity=e.opacity),t?(...e)=>({...t(...e)||{},...i}):(...t)=>({...i})}(d,{stroke:"string"==typeof r.stroke?r.stroke:void 0,strokeWidth:"number"==typeof r.strokeWidth?r.strokeWidth:void 0,opacity:"number"==typeof r.opacity?r.opacity:void 0})}function Ct(t,e,i,o,r){const n=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=Pt(o.theme).colors.categorical,a=i??o.colorScheme??s,c="string"==typeof e?e:"__ssrAreaColorBy",l="function"==typeof e?n.map(t=>({...t,__ssrAreaColorBy:e(t)})):n,u=e?tt(l,c,a):void 0,h=!1!==r.showLine,d="number"==typeof r.lineWidth?r.lineWidth:2,f="number"==typeof r.areaOpacity?r.areaOpacity:.7,p=rt(r.yAccessor),y=r.styleRules;return(t,i)=>{const o=e&&u?Q(t,e,u):"string"==typeof r.color?r.color:H,n={fill:o,fillOpacity:f,stroke:h?o:"none",...h&&{strokeWidth:d}};return y?.length&&Object.assign(n,lt(t,y,{value:p(t),category:i})),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}}function $t(t,e,i,o,r){const n=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=Pt(o.theme).colors.categorical,a=i??o.colorScheme??s,c="string"==typeof e?e:"__ssrBubbleColorBy",l="function"==typeof e?n.map(t=>({...t,__ssrBubbleColorBy:e(t)})):n,u=e?tt(l,c,a):void 0,h=r.sizeBy,d=Array.isArray(r.sizeRange)?r.sizeRange:[5,40],f=h?n.map(t=>"function"==typeof h?h(t):Number(t[h])).filter(Number.isFinite):[],p=f.length?it(f):void 0;return t=>({fill:e&&u?Q(t,e,u):"string"==typeof r.color?r.color:H,fillOpacity:"number"==typeof r.bubbleOpacity?r.bubbleOpacity:.6,r:h?et(t,h,d,p):d[0],stroke:r.stroke??r.bubbleStrokeColor??"white",strokeWidth:r.strokeWidth??r.bubbleStrokeWidth??1,...void 0!==r.opacity&&{opacity:r.opacity}})}function jt(t,e,i,o,r){const n=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=Pt(o.theme).colors.categorical,a=i??o.colorScheme??s,c="string"==typeof e?e:"__ssrScatterColorBy",l="function"==typeof e?n.map(t=>({...t,__ssrScatterColorBy:e(t)})):n,u=e?tt(l,c,a):void 0,h=r.sizeBy,d=Array.isArray(r.sizeRange)?r.sizeRange:[3,15],f=h?n.map(t=>"function"==typeof h?h(t):Number(t[h])).filter(Number.isFinite):[],p=f.length?it(f):void 0,y=nt(r.xAccessor,r.yAccessor),g=r.styleRules;return t=>{const i={fill:e&&u?Q(t,e,u):"string"==typeof r.color?r.color:H,fillOpacity:"number"==typeof r.pointOpacity?r.pointOpacity:.8,r:h?et(t,h,d,p):"number"==typeof r.pointRadius?r.pointRadius:5};return g?.length&&Object.assign(i,lt(t,g,y(t))),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}}var zt={frameType:"xy",buildProps:(t,e,i,o,r)=>({chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange||[5,40],colorScheme:i,...o,pointStyle:o.pointStyle||$t(t,e,i,o,r),showLegend:o.showLegend??!!e})},Et={frameType:"xy",buildProps:(t,e,i,o,r)=>{const n=e||r.lineBy;return{chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||e,colorAccessor:n,colorScheme:i,lineStyle:Tt(t,n,i,o,r),...o,showLegend:o.showLegend??!!n}}},Dt={frameType:"xy",buildProps:(t,e,i,o,r)=>{const n=Array.isArray(t)?b(t):[],s=r.timeAccessor||"time",a=r.valueAccessor||"value",c=r.categoryAccessor,l=r.valueExtent||o.yExtent,u="down"===r.direction?function({data:t,valueAccessor:e,timeAccessor:i,binSize:o,valueExtent:r,extentPadding:n}){if(r)return[r[1],r[0]];if(!t||0===t.length)return;const s=new Map;for(const r of t){const t=Rt(r,i,"time"),n=Rt(r,e,"value");if(null==t||null==n)continue;const a=Math.floor(t/o)*o;s.set(a,(s.get(a)??0)+n)}let a=0;for(const t of s.values())a=Math.max(a,t);return[a>0?a+a*(n??.1):1,0]}({data:n,timeAccessor:s,valueAccessor:a,binSize:Number(r.binSize),valueExtent:l,extentPadding:r.extentPadding}):l,h={...void 0!==r.fill&&{fill:r.fill},...void 0!==r.stroke&&{stroke:r.stroke},...void 0!==r.strokeWidth&&{strokeWidth:r.strokeWidth},...void 0!==r.opacity&&{opacity:r.opacity},...void 0!==r.gap&&{gap:r.gap}};return{chartType:"bar",data:n,...o,runtimeMode:"streaming",windowMode:"growing",windowSize:Math.max(1,n.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||h,showLegend:o.showLegend??!!c}}},Ft={frameType:"xy",buildProps:(t,e,i,o,r)=>{const n=e||r.areaBy,s=function({data:t,safeData:e,areaBy:i,lineDataAccessor:o}){if(null==t)return[];const r=void 0!==e[0]?.[o];if(!r&&!i)return e;let n;if(r)n=e;else{const t=e.reduce((t,e)=>{const r="function"==typeof i?i(e):e[i],n=r+"";if(!t[n]){const e={[o]:[]};"string"==typeof i&&(e[i]=r),t[n]=e}return t[n][o].push(e),t},{});n=Object.values(t)}return n.flatMap(t=>{const e=Array.isArray(t[o])?t[o]:[];return"string"==typeof i?e.map(e=>({...e,[i]:e[i]??t[i]})):e})}({data:t,safeData:Array.isArray(t)?b(t):[],areaBy:r.areaBy,lineDataAccessor:r.lineDataAccessor||"coordinates"});return{chartType:"area",data:s,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",y0Accessor:r.y0Accessor,groupAccessor:r.areaBy||void 0,colorAccessor:n,colorScheme:i,...o,lineStyle:o.lineStyle||Ct(s,n,i,o,r)}}},Ot={frameType:"xy",buildProps:(t,e,i,o,r)=>{const n=r.xAccessor||"x",s=r.seriesAAccessor||"a",a=r.seriesBAccessor||"b",c=t=>dt(ht(n,"x",t)),l=t=>dt(ht(s,"a",t)),u=t=>dt(ht(a,"b",t)),h=r.seriesAColor||"var(--semiotic-danger, #dc2626)",d=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(t,e,i,o){if(!t.length)return[];const r=t.filter(t=>Number.isFinite(e(t))).sort((t,i)=>e(t)-e(i)),n=[];let s=0,a=null,c=null,l=[];const u=(t,e)=>t>e?"A":e>t?"B":null,h=t=>`seg-${s}-${t}`,d=t=>n.push(t),f=(t,e)=>{d({__x:t.x,__y:t.y,__y0:t.y,__diffSegment:h(e),__diffWinner:e,__valA:t.y,__valB:t.y,__sourceDatum:t.datum})};for(let t=0;r.length>t;t++){const n=r[t],p=e(n),y=i(n),g=o(n);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 t,e;if(l.length>0)t=l[0].x,e=l[0].y;else{const i=y-c.a-(g-c.b);if(0!==i){const o=Math.max(0,Math.min(1,(c.b-c.a)/i));t=c.x+o*(p-c.x),e=c.a+o*(y-c.a)}else t=c.x,e=c.a}d({__x:t,__y:e,__y0:e,__diffSegment:h(a),__diffWinner:a,__valA:e,__valB:e}),s++,a=m,d({__x:t,__y:e,__y0:e,__diffSegment:h(a),__diffWinner:a,__valA:e,__valB:e});for(let t=1;l.length>t;t++)f(l[t],a)}else for(const t of l)f(t,a);l=[],d({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:h(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:n}),c={x:p,a:y,b:g,w:m}}else{a=m;for(const t of l)f(t,a);l=[],d({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:h(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:n}),c={x:p,a:y,b:g,w:m}}else l.push({x:p,y:y,datum:n})}for(const t of l)f(t,a??"A");return n}(Array.isArray(t)?t:[],c,l,u),w=[];if(y&&Array.isArray(t)){const e=t.filter(t=>Number.isFinite(c(t))).sort((t,e)=>c(t)-c(e));for(const t of e){const e=c(t),i=l(t),o=u(t);Number.isFinite(i)&&w.push({__x:e,__y:i,__diffSegment:"line-A"}),Number.isFinite(o)&&w.push({__x:e,__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(t=>t.__diffSegment))),areaStyle:t=>{const e=t.__diffSegment;return{fill:"A"==(e?.endsWith("-A")?"A":"B")?h:d,stroke:"none",fillOpacity:f}},lineStyle:t=>({stroke:"A"==("line-A"===t.__diffSegment?"A":"B")?h:d,strokeWidth:p,fill:"none"}),curve:r.curve||"linear",...o,...g&&{legend:{legendGroups:[{label:"",type:"fill",styleFn:t=>({fill:t.color||"currentColor"}),items:[{label:m,color:h},{label:x,color:d}]}]},legendPosition:b}}}},Nt={frameType:"xy",buildProps:(t,e,i,o,r)=>{const n=e||r.areaBy,s="string"==typeof n&&Array.isArray(t)?tt(t,n,i):void 0;return{chartType:"stackedarea",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.areaBy,colorAccessor:n,colorScheme:i,normalize:r.normalize,stackOrder:r.stackOrder,lineStyle:null==r.areaOpacity?void 0:t=>{const e=null==n?void 0:Q(t,n,s),i=r.showLine??!0;return{fill:r.color??e,stroke:i?r.stroke??e:"none",...i?{strokeWidth:r.strokeWidth??r.lineWidth??2}:{},fillOpacity:r.areaOpacity,...null==r.opacity?{}:{opacity:r.opacity}}},...o,curve:o.curve??r.curve??"monotoneX",showLegend:o.showLegend??!!n}}},Bt={frameType:"xy",buildProps:(t,e,i,o,r)=>{const[n]=o.size??[600,400];return{chartType:"candlestick",data:t,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(n/40))),extentPadding:o.extentPadding??(n>200?.1:.02)}}},It={frameType:"xy",buildProps:(t,e,i,o,r)=>{const n=o.pointStyle||jt(t,e,i,o,r),s=function(t,e,i){return t&&0!==t.length?(o,r)=>{const n=lt(o,t,e(o,r)),s=i?i(o,r):void 0;return s?{...n,...s}:n}:i}(r.styleRules,nt(r.xAccessor||"x",r.yAccessor||"y"),c),a=s?t=>({..."function"==typeof n?n(t):n,...s(t)}):n;var c;return{chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,...r.symbolBy&&{symbolAccessor:r.symbolBy},...r.symbolMap&&{symbolMap:r.symbolMap},colorScheme:i,...o,sizeRange:r.sizeRange||[3,15],pointStyle:a,showLegend:o.showLegend??!!e}}},Wt={frameType:"xy",buildProps:(t,e,i,o,r)=>{const n=r.xCenter,s=r.yCenter,a=r.quadrants,c=r.centerlineStyle||{},l=!1!==r.showQuadrantLabels,u=r.quadrantLabelSize??12,h=c.stroke||"#999",d=c.strokeWidth??1,f=Array.isArray(c.strokeDasharray)?c.strokeDasharray.join(","):c.strokeDasharray,p=m.createElement,y=a?[(t,e,i)=>{if(!e?.x||!e?.y)return null;const o=i.width,r=i.height,c=null!=n?e.x(n):o/2,y=null!=s?e.y(s):r/2;if(null!=n&&!Number.isFinite(c))return null;if(null!=s&&!Number.isFinite(y))return null;const g=Math.max(0,Math.min(o,c)),x=Math.max(0,Math.min(r,y)),b=[{c:a.topLeft,x:0,y:0,w:g,h:x},{c:a.topRight,x:g,y:0,w:o-g,h:x},{c:a.bottomLeft,x:0,y:x,w:g,h:r-x},{c:a.bottomRight,x:g,y:x,w:o-g,h:r-x}],v=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(m.Fragment,null,...b.map((t,e)=>t.w>0&&t.h>0?p("rect",{key:"qf-"+e,x:t.x,y:t.y,width:t.w,height:t.h,fill:t.c.color,opacity:t.c.opacity??.08}):null),p("line",{key:"vc",x1:g,y1:0,x2:g,y2:r,stroke:h,strokeWidth:d,strokeDasharray:f}),p("line",{key:"hc",x1:0,y1:x,x2:o,y2:x,stroke:h,strokeWidth:d,strokeDasharray:f}),...v)}]:void 0;return{chartType:"scatter",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,sizeAccessor:r.sizeBy,sizeRange:r.sizeRange||[3,15],colorScheme:i,pointStyle:o.pointStyle||r.pointStyle||jt(t,e,i,o,r),...o,showLegend:o.showLegend??!!e,...y&&{svgPreRenderers:y}}}},Yt={frameType:"xy",buildProps:(t,e,i,o,r)=>{const n=function(t,e){if(!Array.isArray(t))return{data:t,orderMap:new WeakMap};const i=e.xAccessor||"x",o=e.yAccessor||"y",r=e.orderAccessor?[...t].sort((t,i)=>null==t||"object"!=typeof t?1:null==i||"object"!=typeof i?-1:dt(ht(e.orderAccessor,"order",t))-dt(ht(e.orderAccessor,"order",i))):t,n=new WeakMap;let s=0;for(const t of r){if(null==t||"object"!=typeof t)continue;const e=dt(ht(i,"x",t)),r=dt(ht(o,"y",t));Number.isFinite(e)&&Number.isFinite(r)&&s++}let a=0;for(const t of r){if(null==t||"object"!=typeof t)continue;const e=dt(ht(i,"x",t)),r=dt(ht(o,"y",t));Number.isFinite(e)&&Number.isFinite(r)&&n.set(t,{idx:a++,total:s})}return{data:r,orderMap:n}}(t,r),s=r.pointRadius??4;return{chartType:"scatter",data:n.data,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,colorScheme:i,pointStyle:t=>{const e=n.orderMap.get(t),i=e?.idx??0,o=e?.total??1;return{fill:o>0?ft(i,o):"#6366f1",stroke:"white",strokeWidth:1,r:s,fillOpacity:1}},...o,svgPreRenderers:[t=>{const e=t.filter(t=>"point"===t.type&&"number"==typeof t.x&&"number"==typeof t.y);if(2>e.length)return null;const i=[];for(let t=0;e.length-1>t;t++){const o=e[t],r=e[t+1],n=ft(t,e.length);100>e.length&&i.push(m.createElement("line",{key:"halo-"+t,x1:o.x,y1:o.y,x2:r.x,y2:r.y,stroke:"white",strokeWidth:s+2,strokeLinecap:"round",opacity:.5})),i.push(m.createElement("line",{key:"segment-"+t,x1:o.x,y1:o.y,x2:r.x,y2:r.y,stroke:n,strokeWidth:s,strokeLinecap:"round"}))}return m.createElement(m.Fragment,null,...i)}]}}};function qt(t){return Math.max(0,Math.min(1,t))}function Xt(t){const e=t.trim();if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t.split("").map(t=>t+t).join("")),6===t.length&&/^[0-9a-f]{6}$/i.test(t))return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const i=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(i){const t=[Number(i[1]),Number(i[2]),Number(i[3])];if(t.every(Number.isFinite))return t}return null}function Gt(t,e,i){const o=t=>Math.max(0,Math.min(255,Math.round(t))).toString(16).padStart(2,"0");return`#${o(t)}${o(e)}${o(i)}`}function Vt(t,e){const i=t.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:qt(t.offset),color:t.color})).sort((t,e)=>t.offset-e.offset);if(0===i.length)return"#999999";if(1===i.length)return i[0].color;const o=qt(e);if(i[0].offset>=o)return i[0].color;if(o>=i[i.length-1].offset)return i[i.length-1].color;for(let t=0;i.length-1>t;t++){const e=i[t],r=i[t+1];if(e.offset>o||o>r.offset)continue;const n=r.offset-e.offset,s=n>0?(o-e.offset)/n:0,a=Xt(e.color),c=Xt(r.color);if(!a||!c)return.5>s?e.color:r.color;const[l,u,h]=a,[d,f,p]=c;return Gt(l+(d-l)*s,u+(f-u)*s,h+(p-h)*s)}return i[i.length-1].color}function Ht(t,e,i){return null==i?`${t}-${e}`:`${t}-${e}-${i}`}var Zt=require("react/jsx-runtime");function Ut(t=240){const e=360-t,i=180+e/2,o=i*Math.PI/180;return{sweepRad:t*Math.PI/180,gapDeg:e,startAngleDeg:i,startAngleRad:o,offsetRad:-Math.PI/2+o}}require("react");var Kt={RdBu:N,PiYG:B,PRGn:I,BrBG:W,RdYlBu:Y,RdYlGn:q,Spectral:X},Qt="__likert_neutral_neg",Jt="__likert_neutral_pos";function te(t,e){if("function"==typeof t)return t;const i=t||e;return t=>t[i]}require("react");var ee=16,ie=6,oe=10,re=22;function ne(t){const e=Math.max(1,t?.swatchSize??ee),i=Math.max(e,t?.rowHeight??re);return{swatchSize:e,labelGap:Math.max(0,t?.labelGap??ie),itemGap:Math.max(0,t?.itemGap??oe),rowHeight:i,align:"left"===t?.align?"start":"right"===t?.align?"end":t?.align??"start",maxWidth:t?.maxWidth}}function se(t,e){let i=24;return t.map(({hasLabel:t,itemCount:o})=>{i+=5;const r=i;let n;i+=8,t&&(i+=16,n=i,i+=8);const s=i;return i+=o*e+8,{lineY:r,labelY:n,itemsY:s,endY:i}})}function ae(...t){let e;for(const i of t)i&&(e=ce(e)&&ce(i)?{legendGroups:[...e.legendGroups,...i.legendGroups]}:i);return e}function ce(t){return"object"==typeof t&&null!==t&&"legendGroups"in t&&Array.isArray(t.legendGroups)}function le(t){return"object"==typeof t&&null!==t&&"gradient"in t}function ue(t,e,i,o,r){if(t)return t;if(i&&"object"==typeof i&&!Array.isArray(i)){const t=J(i,o);if(t)return t}let n;if(Array.isArray(i))n=i;else if(e&&e.length>0)n=e;else if("string"==typeof i){const t=G[i];Array.isArray(t)&&(n=t)}return n&&0!==n.length?null!=o?(r.has(o)||r.set(o,r.size),n[r.get(o)%n.length]):n[0]:H}var he=c(require("react"));function de(t){return!0===t?{topOpacity:.8,bottomOpacity:.05}:!1===t?void 0:t}function fe(t,e,i,o,r){const n=Pt(o.theme).colors.categorical,s=i??o.colorScheme,a=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],c="string"==typeof e?e:"__ssrColorBy",l="function"==typeof e?a.map(t=>({...t,__ssrColorBy:e(t)})):a,u=e?tt(l,c,s??n):void 0,h=ue("string"==typeof r.color?r.color:void 0,n,s,void 0,new Map),d=rt(r.valueAccessor),f=r.styleRules,p=o.pieceStyle;return(t,i)=>{const o={fill:e&&u?Q(t,e,u):h};return f?.length&&Object.assign(o,lt(t,f,{value:d(t),category:i})),"function"==typeof p?Object.assign(o,p(t,i)||{}):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 pe(t,e,i,o,r){const n=fe(t,e,i,o,r);return(t,e)=>{const i=n(t,e);return void 0===i.fillOpacity&&(i.fillOpacity=.8),void 0===i.stroke&&(i.stroke=i.fill),i}}function ye(t,e,i,o,r){const n=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s="string"==typeof e?e:"__ssrViolinColorBy",a="function"==typeof e?n.map(t=>({...t,__ssrViolinColorBy:e(t)})):n,c=Pt(o.theme).colors.categorical,l=i??o.colorScheme,u=e?tt(a,s,l??c):void 0,h=ue("string"==typeof r.color?r.color:void 0,c,l,void 0,new Map);return t=>{const i=e&&u?Q(t,e,u):h;return{fill:i,fillOpacity:.6,stroke:r.stroke??i,...void 0!==r.strokeWidth&&{strokeWidth:r.strokeWidth},...void 0!==r.opacity&&{opacity:r.opacity}}}}function ge(t,e,i,o,r){const n=fe(t,e,i,o,r),s="number"==typeof r.dotRadius?r.dotRadius:5;return(t,e)=>({r:s,fillOpacity:.8,...n(t,e)})}function me(t,e,i,o,r){const n=fe(t,e,i,o,r),s=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],a=r.sizeBy,c=Array.isArray(r.sizeRange)?r.sizeRange:[3,8],l=a?s.map(t=>"function"==typeof a?a(t):Number(t[a])).filter(Number.isFinite):[],u=l.length?it(l):void 0,h="number"==typeof r.pointRadius?r.pointRadius:4,d="number"==typeof r.pointOpacity?r.pointOpacity:.7;return(t,e)=>({r:a?et(t,a,c,u):h,fillOpacity:d,...n(t,e)})}var xe={frameType:"ordinal",buildProps:(t,e,i,o,r)=>({chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:r.sort??!1,colorAccessor:e,colorScheme:i,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...o,gradientFill:de(o.gradientFill),pieceStyle:fe(t,e,i,o,r)})},be={frameType:"ordinal",buildProps:(t,e,i,o,r)=>{const n=e||r.stackBy;return{chartType:"bar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.stackBy,colorAccessor:n,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical",normalize:r.normalize,oSort:r.sort??!1,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...o,gradientFill:de(o.gradientFill),pieceStyle:fe(t,n,i,o,r),showLegend:o.showLegend??!!n}}},ve={frameType:"ordinal",buildProps:(t,e,i,o,r)=>{const n=e||r.groupBy;return{chartType:"clusterbar",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",groupBy:r.groupBy,colorAccessor:n,colorScheme:i,projection:"horizontal"===r.orientation?"horizontal":"vertical",oSort:r.sort??!1,barPadding:r.barPadding,...null!=r.roundedTop&&{roundedTop:r.roundedTop},...o,gradientFill:de(o.gradientFill),pieceStyle:fe(t,n,i,o,r),showLegend:o.showLegend??!!n}}},we={frameType:"ordinal",buildProps:(t,e,i,o,r)=>{const n=e||r.categoryAccessor;return{chartType:"pie",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",projection:"radial",colorAccessor:n,colorScheme:i,...null!=r.cornerRadius&&{cornerRadius:r.cornerRadius},...o,pieceStyle:fe(t,n,i,o,r),showLegend:o.showLegend??!!n}}},ke={frameType:"ordinal",layout:{primarySize:{width:400,height:400}},buildProps:(t,e,i,o,r)=>{const n=e||r.categoryAccessor;return{chartType:"donut",data:t,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:n,colorScheme:i,...null!=r.cornerRadius&&{cornerRadius:r.cornerRadius},...o,pieceStyle:fe(t,n,i,o,r)}}},Se={frameType:"ordinal",buildProps:(t,e,i,o,r)=>{const n=Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],s=r.valueAccessor||"value",a=n.map(t=>Number("function"==typeof s?s(t):t[s])).filter(Number.isFinite),c=a.length?[Math.min(...a),Math.max(...a)]:void 0;return{chartType:"histogram",data:t,oAccessor:r.categoryAccessor||(t=>null==t.category?"All":t.category+""),rAccessor:s,projection:"horizontal",bins:r.bins??25,normalize:r.relative??!1,colorAccessor:e,colorScheme:i,barPadding:r.categoryPadding??20,...r.valueExtent?{rExtent:r.valueExtent}:c?{rExtent:c}:{},...o,summaryStyle:pe(t,e,i,o,r)}}},Ae={frameType:"ordinal",buildProps:(t,e,i,o,r)=>({chartType:"boxplot",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:e,colorScheme:i,...o,summaryStyle:o.summaryStyle||pe(t,e,i,o,r)})},Me={frameType:"ordinal",buildProps:(t,e,i,o,r)=>({chartType:"violin",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:e,projection:"horizontal"===r.orientation?"horizontal":"vertical",bins:r.bins??25,showIQR:r.showIQR??!0,barPadding:r.categoryPadding??20,colorScheme:i,...o,summaryStyle:o.summaryStyle||ye(t,e,i,o,r),showLegend:o.showLegend??!!e,...r.valueExtent&&{rExtent:r.valueExtent}})},_e={frameType:"ordinal",buildProps:(t,e,i,o,r)=>({chartType:"swarm",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:e,...r.symbolBy&&{symbolAccessor:r.symbolBy},...r.symbolMap&&{symbolMap:r.symbolMap},colorScheme:i,...o,sizeRange:r.sizeRange||[3,8],pieceStyle:o.pieceStyle||me(t,e,i,o,r),showLegend:o.showLegend??!!e})},Pe={frameType:"ordinal",layout:{modeDefaults:{showGrid:!0}},buildProps:(t,e,i,o,r)=>({chartType:"point",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:e,colorScheme:i,projection:"vertical"===r.orientation?"vertical":"horizontal",oSort:r.sort??"auto",barPadding:r.categoryPadding??10,...o,pieceStyle:ge(t,e,i,o,r),showGrid:o.showGrid??!0,showLegend:o.showLegend??!!e})},Le={frameType:"ordinal",buildProps:(t,e,i,o,r)=>{const n=e||r.subcategoryAccessor;return{chartType:"swimlane",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",stackBy:r.subcategoryAccessor,colorAccessor:n,categoryAccessor:r.categoryAccessor,subcategoryAccessor:r.subcategoryAccessor,colorScheme:i,projection:"vertical"===r.orientation?"vertical":"horizontal",...null!=r.trackFill&&{trackFill:r.trackFill},...o,gradientFill:de(o.gradientFill),pieceStyle:o.pieceStyle||fe(t,n,i,o,r),showLegend:o.showLegend??!!n,barPadding:r.barPadding??40}}},Re={frameType:"ordinal",buildProps:(t,e,i,o,r)=>({chartType:"ridgeline",data:t,oAccessor:r.categoryAccessor||"category",rAccessor:r.valueAccessor||"value",colorAccessor:e,colorScheme:i,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||((n,s)=>({fillOpacity:.5,...fe(t,e,i,o,r)(n,s)})),showLegend:o.showLegend??!!e})},Te={frameType:"ordinal",layout:{margin:(t,e)=>({...e.marginDefaults,left:"vertical"===t.orientation?e.marginDefaults.left:Math.max(100,e.marginDefaults.left)})},buildProps:(t,e,i,o,r)=>{const n=Array.isArray(r.levels)&&r.levels.length>=2?r.levels:["Strongly disagree","Disagree","Neutral","Agree","Strongly agree"],s="vertical"!==r.orientation;let a=function(t,e,i,o,r,n){const s=new Map,a=new Set(e);for(const c of t){const t=i(c);s.has(t)||s.set(t,new Map);const l=s.get(t);if(o){const t=o(c);if(null==t||!Number.isFinite(t))continue;if(!Number.isInteger(t)){"production"!==process.env.NODE_ENV&&console.warn("[LikertChart] Ignoring non-integer Likert score:",t);continue}const i=t-1;if(0>i||i>=e.length)continue;const r=e[i];l.set(r,(l.get(r)||0)+1)}else if(r&&n){const t=r(c),e=n(c);if(!a.has(t))continue;l.set(t,(l.get(t)||0)+(Number.isFinite(e)?e:0))}}const c=[];for(const[t,i]of s){let o=0;for(const t of e)o+=i.get(t)||0;if(0!==o)for(let r=0;e.length>r;r++){const n=e[r],s=i.get(n)||0;c.push({__likertCategory:t,__likertLevel:n,__likertLevelLabel:n,__likertCount:s,__likertPct:s/o*100,__likertLevelIndex:r})}}return c}(Array.isArray(t)?t.filter(t=>!!t&&"object"==typeof t):[],n,te(r.categoryAccessor,"question"),r.levelAccessor?null:te(r.valueAccessor,"score"),r.levelAccessor?te(r.levelAccessor,"level"):null,r.levelAccessor?te(r.countAccessor,"count"):null);s&&(a=function(t,e){const i=e.length,o=i%2!=0,r=Math.floor(i/2),n=new Map;for(const e of t){const t=n.get(e.__likertCategory)||[];t.push(e),n.set(e.__likertCategory,t)}const s=[];for(const[,t]of n){const e=new Map;let n,a;for(const i of t)i.__likertLevel===Qt?n=i:i.__likertLevel===Jt?a=i:e.set(i.__likertLevelIndex,i);o&&n&&s.push(n);for(let t=r-1;t>=0;t--){const i=e.get(t);i&&s.push(i)}o&&a&&s.push(a);for(let t=o?r+1:r;i>t;t++){const i=e.get(t);i&&s.push(i)}}return s}(function(t,e){const i=e.length,o=i%2!=0,r=Math.floor(i/2),n=[];for(const e of t){const t=e.__likertLevelIndex;if(o&&t===r){const t=e.__likertPct/2;n.push({...e,__likertLevel:Qt,__likertPct:-t}),n.push({...e,__likertLevel:Jt,__likertPct:t})}else n.push(r>t?{...e,__likertPct:-e.__likertPct}:e)}return n}(a,n),n));const c=Pt(o.theme).colors.diverging,l=Array.isArray(i)&&i.length>=n.length?i:function(t,e){if(0>=t)return[];if(e){const i=Kt[e];if(i){if(1===t)return[i(.5)];const e=[];for(let o=0;t>o;o++)e.push(i(o/(t-1)));return e}}const i=["#da1e28","#ff8389","#ffb3b8"],o=["#a6c8ff","#4589ff","#0043ce"],r="#a8a8a8";if(1===t)return[r];const n=t%2!=0,s=Math.floor(t/2),a=[];for(let t=0;s>t;t++)a.push(i[Math.min(Math.floor(t*i.length/s),i.length-1)]);n&&a.push(r);for(let t=0;s>t;t++)a.push(o[Math.min(Math.floor(t*o.length/s),o.length-1)]);return a}(n.length,c),u=new Map(n.map((t,e)=>[t,l[e]||"#888"])),h=n.length%2&&u.get(n[Math.floor(n.length/2)])||"#888",d="function"==typeof r.valueFormat?r.valueFormat:t=>Math.abs(Number(t)).toFixed(0)+"%",f=ae(!1===o.showLegend?void 0:{legendGroups:[{label:"",items:n.map(t=>({label:t})),styleFn:t=>({fill:u.get(t.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:d,...r.categoryFormat&&{oFormat:r.categoryFormat},...r.valueExtent&&{rExtent:r.valueExtent},...o,pieceStyle:t=>{const e=t.__likertLevel||t.data?.__likertLevel;return{fill:e===Qt||e===Jt?h:u.get((t.__likertLevelLabel||t.data?.__likertLevelLabel||e)+"")||"#888"}},showLegend:o.showLegend??!0,legendPosition:o.legendPosition||"right",...f&&{legend:f},__legendIncludesAutomatic:!0}}},Ce={frameType:"ordinal",layout:{margin:(t,e)=>"vertical"===t.orientation?{top:e.title?60:40,right:20,bottom:60,left:60}:{top:e.title?40:10,right:10,bottom:10,left:10}},buildProps:(t,e,i,o,r)=>{const n="vertical"===r.orientation,s=e||r.categoryAccessor;return{chartType:n?"bar-funnel":"funnel",data:t,oAccessor:r.stepAccessor||"step",rAccessor:r.valueAccessor||"value",colorAccessor:s,categoryAccessor:r.categoryAccessor,projection:n?"vertical":"horizontal",connectorAccessor:r.connectorAccessor,connectorStyle:r.connectorStyle,...!n&&null!=r.connectorOpacity&&{connectorOpacity:r.connectorOpacity},barPadding:n?40:0,colorScheme:i,...o,showAxes:n,showGrid:n,pieceStyle:fe(t,s,i,o,r),showLabels:r.showLabels??!0}}},$e={frameType:"ordinal",layout:{primarySize:{width:300,height:250}},renderOverlay:function(t,{theme:e}){const i=t.__gauge;if(!i)return null;const o=(i.startAngleDeg+(i.gMax===i.gMin?0:(Math.max(i.gMin,Math.min(i.gMax,i.value??i.gMin))-i.gMin)/(i.gMax-i.gMin))*i.sweep-90)*Math.PI/180,r=i.needleColor||e.colors.text,n=i.showScaleLabels?(i.thresholds||[]).filter(t=>t.value>i.gMin&&i.gMax>t.value):[];return(0,Zt.jsxs)(Zt.Fragment,{children:[i.showNeedle&&(0,Zt.jsxs)(Zt.Fragment,{children:[(0,Zt.jsx)("line",{x1:i.centerX,y1:i.centerY,x2:i.centerX+i.needleLength*Math.cos(o),y2:i.centerY+i.needleLength*Math.sin(o),stroke:r,strokeWidth:2.5,strokeLinecap:"round"}),(0,Zt.jsx)("circle",{cx:i.centerX,cy:i.centerY,r:4,fill:r})]}),null!=i.contextValue&&(0,Zt.jsx)("text",{x:i.centerX,y:i.contextValueY,textAnchor:"middle",dominantBaseline:"middle",fontSize:i.valueFontSize,fontWeight:700,fill:r,children:i.contextValue}),n.map((t,o)=>{const r=(i.startAngleDeg+(i.gMax===i.gMin?0:(t.value-i.gMin)/(i.gMax-i.gMin))*i.sweep-90)*Math.PI/180,n=i.innerRadius-1,s=i.radius+1,a=i.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,Zt.jsxs)("g",{children:[(0,Zt.jsx)("line",{x1:i.centerX+Math.cos(r)*n,y1:i.centerY+Math.sin(r)*n,x2:i.centerX+Math.cos(r)*s,y2:i.centerY+Math.sin(r)*s,stroke:e.colors.border,strokeWidth:2,strokeLinecap:"round"}),(0,Zt.jsx)("text",{x:i.centerX+Math.cos(r)*a,y:i.centerY+Math.sin(r)*a,textAnchor:l,dominantBaseline:u,fill:e.colors.textSecondary,fontSize:10,children:t.label||t.value+""})]},"gauge-label-"+o)})]})},buildProps:(t,e,i,o,r)=>{const n=r.min??0,s=r.max??100,a=r.sweep??240,c=r.arcWidth??.3,l=!1!==r.showNeedle,u=!1!==r.fillZones,{startAngleDeg:h}=Ut(a),d=r.thresholds||[{value:s,color:r.color||"#4e79a7"}],f=o.gradientFill,p=function(t){const{min:e,max:i,value:o,thresholds:r,fillColor:n,backgroundColor:s,fillZones:a,showScaleLabels:c,gradientFill:l,gradientSteps:u=240}=t,h=i-e||1,d=(Math.max(e,Math.min(i,o))-e)/h;let f=r&&r.length>0?[...r].sort((t,e)=>t.value-e.value):[{value:i,color:n||"#007bff"}];f=f.map(t=>({...t,value:Math.max(e,Math.min(i,t.value))})),i>f[f.length-1].value&&f.push({value:i,color:f[f.length-1].color});const p=!!l&&l.colorStops.length>=2,y=[],g=new Map,m=[];if(p){const t=a?d:1,e=Ht("bg",0);if(y.push({category:e,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),g.set(e,{fill:s,opacity:.4}),t>0){const e=Math.max(1,Math.floor(u)),i=Math.max(1,Math.min(e,Math.round(t*e))),o=[];for(let e=0;i>e;e++)o.push(Vt(l.colorStops,t*(e+.5)/i));const r=Ht("fill",0);y.push({category:r,value:t,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:t,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:o}}),g.set(r,{fill:o[0]||s})}}else{let t=e;for(let i=0;f.length>i;i++){const o=f[i],r=(o.value-t)/h,n=(t-e)/h,c=(o.value-e)/h,l=Math.max(0,(a?Math.min(d,c):c)-n),u=a?Math.max(0,r-l):0;if(l>0){const t=Ht("fill",i);y.push({category:t,value:l,_zone:o.label||"Zone "+(i+1),_isFill:!0}),g.set(t,{fill:o.color})}if(u>0){const t=Ht("bg",i);y.push({category:t,value:u,_zone:o.label||"Zone "+(i+1),_isFill:!1}),g.set(t,{fill:s,opacity:.4})}t=o.value}}if(c&&r&&r.length>0)for(const t of r)t.value>e&&i>t.value&&m.push({type:"gauge-label",value:t.value,label:t.label||t.value+""});return{gaugeData:y,pieceStyle:(t,e)=>g.get(e||t.category)||{fill:s},gaugeAnnotations:m}}({min:n,max:s,value:r.value,thresholds:d,fillColor:r.color,backgroundColor:r.backgroundColor||"#e0e0e0",fillZones:u,showScaleLabels:!1!==r.showScaleLabels,gradientFill:f&&"object"==typeof f&&"colorStops"in f?f:void 0}),[y,g]=o.size||[300,250],m=function(t=240){const{sweepRad:e,offsetRad:i}=Ut(t),o=[[Math.cos(i),Math.sin(i)],[Math.cos(i+e),Math.sin(i+e)],[0,0]];for(let t=0;2*Math.PI>t;t+=Math.PI/2)((t-i)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)>e+.001||o.push([Math.cos(t),Math.sin(t)]);const r=o.map(t=>t[0]),n=o.map(t=>t[1]),[s,a]=it(r),[c,l]=it(n);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(n,Math.min(s,r.value??n)),M="function"==typeof r.valueFormat?r.valueFormat(A):Math.round(A)+"",_=r.centerContent??o.centerContent,P=null!=_?"function"==typeof _?_(A,n,s):_:"sparkline"===r.mode||"context"===r.mode?void 0:he.createElement("div",{style:{textAlign:"center",lineHeight:1.2}},he.createElement("div",{style:{fontSize:Math.max(16,.3*b),fontWeight:700,color:"var(--semiotic-text, #333)"}},M),!1!==r.showScaleLabels&&he.createElement("div",{style:{fontSize:11,color:"var(--semiotic-text-secondary, #666)"}},`${n} – ${s}`));return{chartType:"donut",data:p.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:v,sweepAngle:a,startAngle:h,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:n,gMax:s,sweep:a,arcWidth:c,value:A,startAngleDeg:h,thresholds:d,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))}}}}},je=require("d3-scale");function ze(t){return"invalid-node-time"===t.kind?`node ${t.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===t.kind?`edge ${t.id} has an invalid startTime or endTime`:"invalid-domain"===t.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===t.kind?`edge ${t.id} must have a positive finite value`:"missing-node"===t.kind?`edge ${t.id} references missing ${t.endpoint} node "${t.nodeId}"`:"backward-edge"===t.kind?`edge ${t.id} (${t.source}->${t.target}) ends before it starts`:t.kind}function Ee(t,e,i){const o=e.incoming[t.id],r=e.outgoing[t.id],n=[];for(const t of o)n.push({time:t.endTime,delta:+t.value,edge:t,kind:"in",side:i.get(t.id).targetSide});for(const t of r)n.push({time:t.startTime,delta:-t.value,edge:t,kind:"out",side:i.get(t.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{n.sort((t,e)=>t.time-e.time||(s[t.kind]??99)-(s[e.kind]??99))},c=n.length?function(t,e=1/0){let i=e;for(const e of t)i>e&&(i=e);return i}(n.map(t=>t.time)):null,l=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[0])?t.xExtent[0]:null,u=null!=l?l-1:null!=c&&Number.isFinite(c)?c-1:null,h=[...new Set(n.map(t=>t.time))].sort((t,e)=>t-e),d=new Map;for(let t=1;h.length>t;t++)d.set(h[t],h[t-1]);const f=t=>{const e=d.get(t);return null!=e?(e+t)/2:null!=u?u:t};a();const p=[];let y=0,g=0;for(const t of n)if("out"===t.kind){const e=Math.abs(t.delta);let i=e-("top"===t.side?y:g);if(i>0){const e="top"===t.side?"bot":"top",o=Math.min(i,"top"===e?y:g);if(o>0){const r=f(t.time);p.push({time:r,delta:-o,kind:"transfer-out",side:e}),p.push({time:r,delta:+o,kind:"transfer-in",side:t.side}),"top"===e?y-=o:g-=o,"top"===t.side?y+=o:g+=o,i-=o}i>0&&null!==u&&(p.push({time:u,delta:+i,kind:"create",side:t.side}),"top"===t.side?y+=i:g+=i)}"top"===t.side?y-=e:g-=e}else if("in"===t.kind){const e=Math.abs(t.delta);"top"===t.side?y+=e:g+=e}n.push(...p),a();let m=0,x=0,b=0,v=0,w=0;const k=[],S=new Map;for(const t of n){if(k.push({t:t.time,topMass:m,botMass:x}),("in"===t.kind||"out"===t.kind)&&t.edge){const e="top"===t.side?m:x;S.set(t.edge.id,{side:t.side,time:t.time,sideMassBefore:e,sideMassAfter:e+t.delta,kind:t.kind,value:Math.abs(t.delta)})}"top"===t.side?m+=t.delta:x+=t.delta,m+x>b&&(b=m+x),m>v&&(v=m),x>w&&(w=x),k.push({t:t.time,topMass:m,botMass:x})}const A=[];let M=0;for(;k.length>M;){let t=M;for(;k.length>t+1&&k[t+1].t===k[M].t;)t++;A.push(k[M]);for(let e=M+1;t>=e;e++){const t=A[A.length-1];k[e].topMass===t.topMass&&k[e].botMass===t.botMass||A.push(k[e])}M=t+1}const _=Array.isArray(t.xExtent)&&Number.isFinite(t.xExtent[1])?t.xExtent[1]:null;let P=null;for(const t of r)null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&t.startTime>t.systemInTime&&(null===P||P>t.systemInTime)&&(P=t.systemInTime);let L=null;for(const t of o)null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>t.endTime&&(null===L||t.systemOutTime>L)&&(L=t.systemOutTime);if(A.length>0){const t=A[A.length-1],e=Math.max(null!=_?_:-1/0,null!=L?L:-1/0);Number.isFinite(e)&&e>t.t&&t.topMass+t.botMass>0&&A.push({t:e,topMass:t.topMass,botMass:t.botMass});const i=A[0],o=Math.min(null!=l?l:1/0,null!=P?P:1/0);Number.isFinite(o)&&i.t>o&&i.topMass+i.botMass>0&&A.unshift({t:o,topMass:i.topMass,botMass:i.botMass})}return{samples:A,peak:b,topPeak:v,botPeak:w,localAttachments:S}}function De(t,e){return e?Math.max(e[0],Math.min(e[1],t)):t}function Fe(t,e){return t.map(t=>({t:De(t.t,e),topMass:t.topMass,botMass:t.botMass}))}function Oe(t,e,i){const o=t.value*i;if("out"===t.kind){const r=t.sideMassBefore*i;if("top"===t.side){const t=e-r;return[t,t+o]}const n=e+r;return[n-o,n]}const r=t.sideMassAfter*i;if("top"===t.side){const t=e-r;return[t,t+o]}const n=e+r;return[n-o,n]}function Ne(t,e){let i=0;for(let o=0;e.length>o;o++)for(let r=o+1;e.length>r;r++){const n=e[o],s=e[r];n.source!==s.source&&n.target!==s.target&&n.source!==s.target&&n.target!==s.source&&(Math.min(n.endTime,s.endTime)>Math.max(n.startTime,s.startTime)&&t[s.source]>t[n.source]!=t[s.target]>t[n.target]&&i++)}return i}function Be(t,e){let i=0;for(const o of e)i+=Math.abs(t[o.source]-t[o.target])*(o.value||1);return i}function Ie(t,e){return 1e3*Ne(t,e)+Be(t,e)}function We(t,e){return{slots:t.map(t=>({peak:{...t.peak},occupants:t.occupants.slice()})),map:{...e}}}function Ye(t,e,i){t.length>8||i.length>40?(function(t,e,i,o=6){const r=t.length;if(1>=r)return;let n=We(t,e),s=Ie(e,i);for(let a=0;o>a;a++){const o=Array(r).fill(0),a=Array(r).fill(0);for(const t of i){const i=e[t.source],r=e[t.target];o[i]+=r*(t.value||1),a[i]+=t.value||1,o[r]+=i*(t.value||1),a[r]+=t.value||1}const c=Array.from({length:r},(t,e)=>e).sort((t,e)=>(a[t]>0?o[t]/a[t]:t)-(a[e]>0?o[e]/a[e]:e)),l=c.map(e=>t[e]),u=new Map;c.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of l)t.push(e);const h=Ie(e,i);if(s>h)s=h,n=We(t,e);else if(h===s)break}!function(t,e,i){t.length=0;for(const e of i.slots)t.push(e);for(const t of Object.keys(e))delete e[t];for(const t of Object.keys(i.map))e[t]=i.map[t]}(t,e,n)}(t,e,i,6),function(t,e,i,o=6){const r=t.length;if(1>=r)return;let n=Ie(e,i);for(let s=0;o>s;s++){let o=!1;for(let s=0;r-1>s;s++){const r=t[s];t[s]=t[s+1],t[s+1]=r;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s);const a=Ie(e,i);if(n>a)n=a,o=!0;else{const i=t[s];t[s]=t[s+1],t[s+1]=i;for(const t of Object.keys(e))e[t]===s?e[t]=s+1:e[t]===s+1&&(e[t]=s)}}if(!o)break}}(t,e,i,6)):function(t,e,i){const o=t.length;if(1>=o)return;const r={...e},n=Object.keys(r),s=Array.from({length:o},(t,e)=>e),a=s.slice(),c={...r};let l=s.slice(),u=1/0;const h=()=>{for(const t of n)c[t]=a[r[t]];const t=Ie(c,i);u>t&&(u=t,l=s.slice())},d=(t,e)=>{const i=s[t],o=s[e];s[t]=o,s[e]=i,a[i]=e,a[o]=t};h();const f=Array(o).fill(0);let p=0;for(;o>p;)p>f[p]?(d(p%2==0?0:f[p],p),h(),f[p]++,p=0):(f[p]=0,p++);const y=l.map(e=>t[e]),g=new Map;l.forEach((t,e)=>g.set(t,e));for(const t of Object.keys(e))e[t]=g.get(e[t]);t.length=0;for(const e of y)t.push(e)}(t,e,i)}function qe(t,e,i,o,r){const{plotH:n,padding:s,valueScale:a,packing:c,laneOrder:l,lifetimeMode:u="full"}=r,h={},d={};for(const e of t)h[e.id]=i[e.id].topPeak||0,d[e.id]=i[e.id].botPeak||0;const f="half"===u,p={};for(const e of t){const t=Array.isArray(e.xExtent)?e.xExtent[0]:null,i=Array.isArray(e.xExtent)?e.xExtent[1]:null;let r=null!=t&&Number.isFinite(t)?t:1/0,n=null!=i&&Number.isFinite(i)?i:-1/0;for(const t of o.outgoing[e.id]){r>t.startTime&&(r=t.startTime),null!=t.systemInTime&&Number.isFinite(t.systemInTime)&&r>t.systemInTime&&(r=t.systemInTime);const e=f?(t.startTime+t.endTime)/2:t.endTime;e>n&&(n=e)}for(const t of o.incoming[e.id]){const e=f?(t.startTime+t.endTime)/2:t.startTime;r>e&&(r=e),t.endTime>n&&(n=t.endTime),null!=t.systemOutTime&&Number.isFinite(t.systemOutTime)&&t.systemOutTime>n&&(n=t.systemOutTime)}p[e.id]={start:Number.isFinite(r)?r:null,end:Number.isFinite(n)?n:null}}const y={},g=[];if("reuse"===c){const i=new Map;for(const e of t)i.set(e.id,0);const r=new Map;for(const e of t)r.set(e.id,0);for(const t of e)r.set(t.target,(r.get(t.target)??0)+1);const n=[];for(const e of t)0===(r.get(e.id)??0)&&n.push(e.id);for(;n.length;){const t=n.shift();for(const e of o.outgoing[t]??[]){const o=(i.get(t)??0)+1;o>(i.get(e.target)??0)&&i.set(e.target,o),r.set(e.target,r.get(e.target)-1),0===r.get(e.target)&&n.push(e.target)}}const s=[...t].filter(t=>null!==p[t.id].start).sort((t,e)=>{const o=i.get(t.id)??0,r=i.get(e.id)??0;return o!==r?o-r:p[t.id].start-p[e.id].start}),a=t.filter(t=>null===p[t.id].start);for(const t of[...s,...a]){const e=p[t.id];let i=-1;for(let t=0;g.length>t;t++){const o=g[t].occupants[g[t].occupants.length-1];if(null===e.start||void 0===o||e.start>=o.end){i=t;break}}-1===i&&(g.push({occupants:[],peak:{topPeak:0,botPeak:0}}),i=g.length-1),g[i].occupants.push({id:t.id,end:e?.end??-1/0}),g[i].peak.topPeak=Math.max(g[i].peak.topPeak,h[t.id]),g[i].peak.botPeak=Math.max(g[i].peak.botPeak,d[t.id]),y[t.id]=i}}else t.forEach((t,e)=>{g.push({occupants:[{id:t.id,end:p[t.id]?.end??-1/0}],peak:{topPeak:h[t.id],botPeak:d[t.id]}}),y[t.id]=e});let m=null,x=null,b=null,v=null;const w=()=>{m=Ne(y,e),b=Be(y,e)},k=()=>{x=Ne(y,e),v=Be(y,e)};"crossing-min"===l?(w(),Ye(g,y,e),k()):"inside-out"===l?(w(),function(t,e){const i=t.length;if(1>=i)return;const o=t=>t.peak.topPeak+t.peak.botPeak,r=t.map((t,e)=>({slot:t,idx:e})).sort((t,e)=>o(e.slot)-o(t.slot)),n=Array(i),s=Math.floor((i-1)/2);n[s]=r[0].idx;let a=s-1,c=s+1;for(let t=1;r.length>t;t++)t%2==1&&i>c||0>a?n[c++]=r[t].idx:n[a--]=r[t].idx;const l=n.map(e=>t[e]),u=new Map;n.forEach((t,e)=>u.set(t,e));for(const t of Object.keys(e))e[t]=u.get(e[t]);t.length=0;for(const e of l)t.push(e)}(g,y),k()):"crossing-min+inside-out"===l&&(w(),Ye(g,y,e),function(t,e,i){const o=t.length;if(1>=o)return;const r=t.map(t=>{return{slot:t,size:(e=t,e.peak.topPeak+e.peak.botPeak)};var e}).sort((t,e)=>e.size-t.size),n=Math.floor((o-1)/2);let s=Ie(e,i);for(const{slot:a}of r){const r=t.indexOf(a);if(0>r)continue;const c=n;if(r===c)continue;const l=t[r];t.splice(r,1),t.splice(c,0,l);const u=new Map;for(let t=0;o>t;t++)u.set(t,t);if(c>r){for(let t=r+1;c>=t;t++)u.set(t,t-1);u.set(r,c)}else{for(let t=c;r>t;t++)u.set(t,t+1);u.set(r,c)}for(const t of Object.keys(e))e[t]=u.get(e[t]);const h=Ie(e,i);if(h>s){const i=t[c];t.splice(c,1),t.splice(r,0,i);const n=new Map;for(let t=0;o>t;t++)n.set(t,t);if(r>c){for(let t=c+1;r>=t;t++)n.set(t,t-1);n.set(c,r)}else{for(let t=r;c>t;t++)n.set(t,t+1);n.set(c,r)}for(const t of Object.keys(e))e[t]=n.get(e[t])}else s=h}}(g,y,e),k());const S=g.map(t=>{const e=new Map;for(const o of t.occupants){const t=i[o.id];if(t)for(const i of t.samples){const t=e.get(i.t)||{top:0,bot:0};e.set(i.t,{top:Math.max(t.top,i.topMass),bot:Math.max(t.bot,i.botMass)})}}return[...e.entries()].sort((t,e)=>t[0]-e[0])}),A=(t,e)=>{let i={top:0,bot:0};for(const[o,r]of t){if(o>e)break;i=r}return i},M=[];for(let t=0;g.length-1>t;t++){const e=S[t],i=S[t+1],o=new Set([...e.map(t=>t[0]),...i.map(t=>t[0])]);let r=0;for(const t of o){const o=A(e,t),n=A(i,t);o.bot+n.top>r&&(r=o.bot+n.top)}M.push(r)}const _=[];let P=s+(g[0]?.peak.topPeak??0)*a;g.length>0&&_.push(P);for(let t=1;g.length>t;t++)P+=M[t-1]*a+s,_.push(P);if(g.length>0&&(P+=g[g.length-1].peak.botPeak*a+s),P>n){const t=n/P;for(let e=0;_.length>e;e++)_[e]*=t}const L=0===g.length?0:g[0].peak.topPeak+M.reduce((t,e)=>t+e,0)+g[g.length-1].peak.botPeak,R={};for(const e of t)R[e.id]=_[y[e.id]];return{effectiveSlotsHeight:L,centerlines:R,laneLifetime:p,slots:g,slotByNode:y,slotCenter:_,crossingsBefore:m,crossingsAfter:x,lengthBefore:b,lengthAfter:v}}function Xe(t){const{sx:e,sTop:i,sBot:o,tx:r,tTop:n,tBot:s,cp1X:a,cp2X:c}=t,l=(i+o)/2,u=(n+s)/2;return{pathD:[`M${e},${i}`,`C${a},${i} ${c},${n} ${r},${n}`,`L${r},${s}`,`C${c},${s} ${a},${o} ${e},${o}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:e,y:l},{x:a,y:l},{x:c,y:u},{x:r,y:u}],halfWidth:(o-i)/2}}}function Ge(t){const{nodes:e,edges:i,domain:o,plotW:r,plotH:n,ribbonLane:s,edgeOpacity:a,colorOf:c,layoutOpts:l}=t,u=function(t,e,i){const o=[],r=new Set(t.map(t=>t.id)),n=Array.isArray(i)&&2===i.length,s=n&&Number.isFinite(i[0])&&Number.isFinite(i[1]);n&&s&&s&&i[1]>=i[0]||o.push({kind:"invalid-domain"});for(const e of t)null!=e.xExtent&&(Array.isArray(e.xExtent)&&2===e.xExtent.length&&Number.isFinite(e.xExtent[0])&&Number.isFinite(e.xExtent[1])&&e.xExtent[1]>=e.xExtent[0]||o.push({kind:"invalid-node-time",id:e.id}));for(const t of e)r.has(t.source)||o.push({kind:"missing-node",id:t.id,endpoint:"source",nodeId:t.source}),r.has(t.target)||o.push({kind:"missing-node",id:t.id,endpoint:"target",nodeId:t.target}),Number.isFinite(t.startTime)&&Number.isFinite(t.endTime)?(Number.isFinite(t.value)&&t.value>0||o.push({kind:"invalid-value",id:t.id}),t.endTime>t.startTime||o.push({kind:"backward-edge",id:t.id,source:t.source,target:t.target})):o.push({kind:"invalid-edge-time",id:t.id});return o}(e,i,o),h=(0,je.scaleTime)().domain(o).range([0,r]);if(u.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:u,xScale:h};const d=function(t,e,i){const{plotH:o,pairing:r="temporal",packing:n="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half"}=i,c=function(t,e){const i={},o={};for(const e of t)i[e.id]=[],o[e.id]=[];for(const t of e)o[t.source]&&o[t.source].push(t),i[t.target]&&i[t.target].push(t);return{incoming:i,outgoing:o}}(t,e),l=function(t,e,i,o="value"){const r="temporal"===o?(t,e)=>t.endTime-e.endTime:(t,e)=>e.value-t.value,n="temporal"===o?(t,e)=>t.startTime-e.startTime:(t,e)=>e.value-t.value,s=new Map;for(const t of e)s.set(t.id,{});const a=(t,e)=>{const i=new Map;for(const o of t){const t=o[e];i.has(t)||i.set(t,{partner:t,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const r=i.get(t);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=[...i.values()];s.sort("temporal"===o?(t,i)=>"target"===e?t.earliestStart-i.earliestStart:t.latestEnd-i.latestEnd:(t,e)=>e.total-t.total);for(const t of s)t.edges.sort("target"===e?n:r);return s};for(const e of t){const t=i.outgoing[e.id],o=i.incoming[e.id];if(0===o.length)a(t,"target").forEach((t,e)=>{const i=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).sourceSide=i});else if(0===t.length)a(o,"source").forEach((t,e)=>{const i=e%2==0?"top":"bot";for(const e of t.edges)s.get(e.id).targetSide=i});else{const e=a(o,"source"),i=a(t,"target"),r=Math.max(e.length,i.length);for(let t=0;r>t;t++){const o=t%2==0?"top":"bot";if(e[t])for(const i of e[t].edges)s.get(i.id).targetSide=o;if(i[t])for(const e of i[t].edges)s.get(e.id).sourceSide=o}}}return s}(t,e,c,r);let u={};for(const e of t)u[e.id]=Ee(e,c,l);const h=qe(t,e,u,c,{plotH:o,padding:12,valueScale:1,packing:n,laneOrder:s,lifetimeMode:a}),d=new Set;for(const t of e){const e=h.slotByNode[t.source],i=h.slotByNode[t.target];if(void 0===e||void 0===i)continue;const o=l.get(t.id);e!==i?e>i?(o.sourceSide="top",o.targetSide="bot"):(o.sourceSide="bot",o.targetSide="top"):(d.add(t.id),o.sourceSide="bot",o.targetSide="bot")}for(const e of t){const t=c.outgoing[e.id],i=c.incoming[e.id],o=new Set(t.map(t=>l.get(t.id).sourceSide)),r=new Set(i.map(t=>l.get(t.id).targetSide));if(1===o.size&&i.length>0){const t=[...o][0];for(const e of i)h.slotByNode[e.source]===h.slotByNode[e.target]&&(l.get(e.id).targetSide=t)}if(1===r.size&&t.length>0){const e=[...r][0];for(const i of t)h.slotByNode[i.source]===h.slotByNode[i.target]&&(l.get(i.id).sourceSide=e)}}for(const e of t){const t=c.incoming[e.id],i=c.outgoing[e.id];if(0===t.length||0===i.length)continue;const o=()=>{const e={inTop:0,inBot:0,outTop:0,outBot:0};for(const i of t)"top"===l.get(i.id).targetSide?e.inTop+=i.value:e.inBot+=i.value;for(const t of i)"top"===l.get(t.id).sourceSide?e.outTop+=t.value:e.outBot+=t.value;return e},r=(t,e)=>{const r=o(),n="top"===t?r.outTop-r.inTop:r.outBot-r.inBot,s="top"===e?r.inTop-r.outTop:r.inBot-r.outBot;if(0>=n||0>=s)return!1;const a=Math.min(n,s),c=i.filter(e=>!d.has(e.id)&&l.get(e.id).sourceSide===t&&a>=e.value).sort((t,e)=>e.value-t.value);return 0!==c.length&&(l.get(c[0].id).sourceSide=e,!0)};let n=i.length+1;for(;n-- >0&&(r("top","bot")||r("bot","top")););}u={};for(const e of t)u[e.id]=Ee(e,c,l);const f=qe(t,e,u,c,{plotH:o,padding:12,valueScale:1,packing:n,laneOrder:s,lifetimeMode:a}),p=f.effectiveSlotsHeight??f.slots.reduce((t,e)=>t+e.peak.topPeak+e.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=qe(t,e,u,c,{plotH:o,padding:y,valueScale:g,packing:n,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}}(e,i,{plotH:n,...l}),{centerlines:f,nodeData:p,valueScale:y}=d,g=[],m=[];e.forEach((t,e)=>{const r=p[t.id];if(!r||0===r.samples.length)return;const n=function(t,e,i,o,r){if(0===t.length)return null;const n=Fe(t,r),s=t=>e-n[t].topMass*i,a=t=>e+n[t].botMass*i;let c=`M${o(n[0].t)},${s(0)}`;for(let t=1;n.length>t;t++)c+=` L${o(n[t].t)},${s(t)}`;c+=` L${o(n[n.length-1].t)},${a(n.length-1)}`;for(let t=n.length-2;t>=0;t--)c+=` L${o(n[t].t)},${a(t)}`;return c+" Z"}(r.samples,f[t.id],y,h,o);if(!n)return;const s=Fe(r.samples,o),a=s.find(t=>t.topMass+t.botMass>0)||s[0],l=f[t.id]+(a.botMass-a.topMass)*y/2,u=c(t.id,e),m=function(t,e,i,o,r){const n=i.nodeData[t];if(!n||0===n.samples.length)return[];const s=i.valueScale,a=i.centerlines[t],c=Fe(n.samples,r),l=c.find(t=>t.topMass+t.botMass>0)||c[0],u=[...c].reverse().find(t=>t.topMass+t.botMass>0)||c[c.length-1],h=o(l.t),d=o(u.t),f=t=>o(De(t,r)),p=[],y=(t,e,i,o)=>`M${t},${e} L${i},${e} L${i},${o} L${t},${o} Z`;for(const i of e){if(i.source===t&&null!=i.systemInTime&&Number.isFinite(i.systemInTime)){const t=n.localAttachments.get(i.id);if(t&&"out"===t.kind&&i.startTime>i.systemInTime){const e=f(i.systemInTime),o=f(i.startTime),r=e-20,n=Math.max(h,r);if(o>n){const[i,c]=Oe(t,a,s);p.push({pathD:y(n,i,o,c),x0:r,x1:e,from:0,to:1})}}}if(i.target===t&&null!=i.systemOutTime&&Number.isFinite(i.systemOutTime)){const t=n.localAttachments.get(i.id);if(t&&"in"===t.kind&&i.systemOutTime>i.endTime){const e=f(i.systemOutTime),o=f(i.endTime),r=e+20,n=Math.min(d,r);if(n>o){const[i,c]=Oe(t,a,s);p.push({pathD:y(o,i,n,c),x0:e,x1:r,from:1,to:0})}}}}return p}(t.id,i,d,h,o);g.push({id:t.id,pathD:n,fill:u,stroke:u,strokeWidth:.5,...m.length>0&&{gradientStubs:m},rawDatum:t.__raw??t,labelX:h(a.t)-4,labelY:l,labelText:t.id})});const x=new Map;return e.forEach((t,e)=>x.set(t.id,e)),i.forEach(t=>{const e=p[t.source]?.localAttachments.get(t.id),i=p[t.target]?.localAttachments.get(t.id);if(!e||!i)return;const r=x.get(t.source)??0,n=c(t.source,r),l=function(t,e,i,o,r,n,s,a){const c=r,l=t=>a?Math.max(a[0],Math.min(a[1],t)):t,u=n(l(t.time)),h=n(l(i.time)),d=t.value*c,f=i.value*c,p=t.sideMassBefore*c,y=i.sideMassAfter*c;let g,m,x,b;"top"===t.side?(g=e-p,m=g+d):(m=e+p,g=m-d),"top"===i.side?(x=o-y,b=x+f):(b=o+y,x=b-f);const v="source"===s?u+.85*(h-u):"target"===s?u+.15*(h-u):(u+h)/2;return{sx:u,sTop:g,sBot:m,tx:h,tTop:x,tBot:b,cp1X:v,cp2X:v}}(e,f[t.source],i,f[t.target],y,h,s,o),{pathD:u,bezier:d}=Xe(l);m.push({id:t.id,pathD:u,fill:n,opacity:a,rawDatum:t.__raw??t,bezier:d})}),{layout:d,layoutConfig:{bands:g,ribbons:m,showLabels:!0},issues:[],xScale:h}}var Ve=t=>{const{bands:e=[],ribbons:i=[],showLabels:o=!0}=t.config,r=[];for(const t of i)r.push({type:"bezier",pathD:t.pathD,...t.bezier&&{bezierCache:t.bezier},style:{fill:t.fill,opacity:t.opacity,stroke:"none"},datum:{__kind:"ribbon",data:t.rawDatum,id:t.id}});for(const t of e)if(t.gradientStubs)for(let e=0;t.gradientStubs.length>e;e++){const i=t.gradientStubs[e];r.push({type:"bezier",pathD:i.pathD,interactive:!1,style:{fill:t.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:i.x0,x1:i.x1,from:i.from,to:i.to},datum:{__kind:"band",data:t.rawDatum,id:`${t.id}__stub${e}`}})}for(const t of e)r.push({type:"bezier",pathD:t.pathD,style:{...t.gradientStubs&&t.gradientStubs.length>0?{fill:"none"}:{fill:t.fill,fillOpacity:.86},stroke:t.stroke??t.fill,strokeWidth:t.strokeWidth??.5},datum:{__kind:"band",data:t.rawDatum,id:t.id}});const n=o?e.map(t=>({x:t.labelX,y:t.labelY,text:t.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:e.map(t=>({type:"circle",id:t.id,cx:-1e4,cy:-1e4,r:0,style:{fill:t.fill},datum:{__kind:"band",data:t.rawDatum,id:t.id}})),sceneEdges:r,labels:n}};function He(t,e,i,o){if(t&&t.length>0)return t;const r=new Set;return e.forEach(t=>{const e="function"==typeof i?i(t):t[i],n="function"==typeof o?o(t):t[o];r.add(e),r.add(n)}),Array.from(r).map(t=>({id:t}))}var Ze=c(require("react")),Ue={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,i,o,r)=>{const{edgeWidth:n,edgeColor:s,edgeOpacity:a}=r,c=r.edgeStyle??(void 0!==n||void 0!==s||void 0!==a?t=>{const e=t?.data||t;let i=1;if("number"==typeof n)i=n;else if("function"==typeof n)i=n(e);else if("string"==typeof n){const t=e?.[n],o="number"==typeof t?t:Number(t);i=Number.isFinite(o)&&o>0?o:1}return{stroke:s??"#999",strokeWidth:i,opacity:a??.6}}:void 0),l=Pt(o.theme).colors.categorical,u=new Map,h=r.nodeStyle??(t=>({fill:e?Q(t?.data||t,e,void 0):ue(void 0,l,i,void 0,u),..."number"==typeof r.nodeSize&&{r:r.nodeSize}})),d=function(t,e,i,o){if(!t||0===t.length)return o;const r=st(e,i);return(e,i)=>{const o=e&&e.data||e,n=lt(o,t,r(o));return n}}(r.styleRules,e,"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:e,colorScheme:i,iterations:r.iterations,forceStrength:r.forceStrength,showLabels:r.showLabels??!1,nodeLabel:r.nodeLabel,nodeSize:r.nodeSize??8,nodeSizeRange:r.nodeSizeRange,nodeStyle:d?(t,e)=>({...h(t),...d(t,e)}):h,edgeStyle:c,...o}}},Ke={frameType:"network",layout:{margin:{top:30,right:80,bottom:40,left:80}},buildProps:(t,e,i,o,r)=>{const n=t=>null==t?NaN:t instanceof Date?t.getTime():"number"==typeof t?t:new Date(t).getTime(),s=r.sourceAccessor||"source",a=r.targetAccessor||"target",c=r.valueAccessor||"value",l=r.nodeIdAccessor||"id",u=r.startTimeAccessor||"startTime",h=r.endTimeAccessor||"endTime",d=r.systemInTimeAccessor,f=r.systemOutTimeAccessor,p=r.xExtentAccessor||"xExtent",y=r.edgeIdAccessor||"id",g=(t,e)=>"function"==typeof t?t(e):e[t],m=Array.isArray(r.edges)?r.edges:[],x=Array.isArray(r.nodes)?r.nodes:[],b=x.length>0?x:He([],m,s,a),v=[n(r.domain?.[0]),n(r.domain?.[1])],w=b.map(t=>{const e=g(l,t)+"",i=g(p,t),o={id:e,__raw:t};if(Array.isArray(i)&&2===i.length){const t=n(i[0]),e=n(i[1]);Number.isFinite(t)&&Number.isFinite(e)&&(o.xExtent=[t,e])}return o}),k=m.map((t,e)=>{const i=g(y,t),o={id:null!=i?i+"":`${g(s,t)}-${g(a,t)}-${e}`,source:g(s,t)+"",target:g(a,t)+"",value:Number(g(c,t)),startTime:n(g(u,t)),endTime:n(g(h,t)),__raw:t};if(d){const e=n(g(d,t));Number.isFinite(e)&&(o.systemInTime=e)}if(f){const e=n(g(f,t));Number.isFinite(e)&&(o.systemOutTime=e)}return o}),[S,M]=o.size??[600,400],_={top:20,right:20,bottom:20,left:20,...o.margin},P=(o.showLegend??!!e)&&!!e,L=o.legendPosition??"right",R=o.__explicitMargin,T=t=>"number"==typeof R||null!=R&&"object"==typeof R&&null!=R[t];P&&("right"!==L||T("right")?"bottom"!==L||T("bottom")||(_.bottom=Math.max(_.bottom,80)):_.right=Math.max(_.right,140));const C=_,$=S-C.left-C.right,j=M-C.top-C.bottom,z=Z(i,Pt(o.theme).colors.categorical,A),E="function"==typeof e?e:null,D=E?b.map(t=>({_cat:E(t)})):b,F=E?"_cat":"string"==typeof e?e:void 0,O=i??[...z],N=F?tt(D,F,O):null,B=new Map;for(const t of w)B.set(t.id,t.__raw);const I=(t,i)=>{if(e&&B.has(t)){const i=B.get(t);return E?Q({_cat:E(i)},"_cat",N??void 0):Q(i,"string"==typeof e?e:"id",N??void 0)}return z[i%z.length]},W=ae(P&&e?(()=>{const t=new Map;b.forEach((i,o)=>{const r=g(e,i),n=null==r?"":r+"";n&&!t.has(n)&&t.set(n,{label:n,color:I(g(l,i)+"",o)})});const i=Array.from(t.values());return i.length>0?{legendGroups:[{type:"fill",label:"",items:i,styleFn:t=>{const e=t.color||"#333";return{fill:e,stroke:e}}}]}:void 0})():void 0,o.legend),{layout:Y,layoutConfig:q,issues:X,xScale:G}=Ge({nodes:w,edges:k,domain:v,plotW:$,plotH:j,ribbonLane:r.ribbonLane||"both",edgeOpacity:"number"==typeof r.edgeOpacity?r.edgeOpacity:.35,colorOf:I,layoutOpts:{pairing:r.pairing||"temporal",packing:r.packing||"reuse",laneOrder:r.laneOrder||"crossing-min",lifetimeMode:r.lifetimeMode||"half"}});if(X.length>0){const t=X.map(ze).join("; ");throw Error("ProcessSankey: data invalid — "+t)}const V=Array.isArray(r.axisTicks)?r.axisTicks:[],H=Y?(()=>{let t=null,e=null;for(const i of w){const o=Y.laneLifetime[i.id];if(!o||null==o.start||null==o.end)continue;const r=Number(G(o.start)),n=Number(G(o.end));t=null==t?r:Math.min(t,r),e=null==e?n:Math.max(e,n)}const i=t=>Math.max(0,Math.min($,t)),o=i(t??0),s=Math.max(o,i(e??$)),a=V.map((t,e)=>({tick:t,index:e,x:Number(G(n(t.date)))})).filter(({x:t})=>t>=o-.5&&s+.5>=t);return Ze.createElement("g",null,...a.map(({index:t,x:e})=>Ze.createElement("line",{key:"grid-"+t,x1:e,y1:0,x2:e,y2:j,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"})),Ze.createElement("line",{key:"axis",x1:o,y1:j+4,x2:s,y2:j+4,stroke:"#94a3b8"}),...a.map(({tick:t,index:e,x:i})=>{const o=n(t.date),s=null!=t.label?t.label:"function"==typeof r.timeFormat?r.timeFormat(new Date(o)):"";return Ze.createElement("g",{key:"tick-"+e,transform:`translate(${i},${j+4})`},Ze.createElement("line",{y2:6,stroke:"#94a3b8"}),Ze.createElement("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569"},s))}))})():void 0;return{chartType:"force",nodes:b,edges:m,customNetworkLayout:Ve,layoutConfig:q,sourceAccessor:s,targetAccessor:a,valueAccessor:c,nodeIDAccessor:l,colorBy:e,colorScheme:i,...H&&{backgroundGraphics:H},...o,showLegend:P,...W&&{legend:W,legendPosition:L},__legendIncludesAutomatic:!0,margin:C}}},Qe={frameType:"network",layout:{primarySize:{width:800,height:600}},buildProps:(t,e,i,o,r)=>{const n=Array.isArray(r.nodes)?r.nodes:He([],Array.isArray(r.edges)?r.edges:[],r.sourceAccessor||"source",r.targetAccessor||"target"),s=Pt(o.theme).colors.categorical,a=new Map,c="string"==typeof e?e:"__ssrSankeyColorBy",l="function"==typeof e?n.map(t=>({...t,__ssrSankeyColorBy:e(t)})):n,u=e?tt(l,c,i??o.colorScheme??s):void 0,h=t=>({fill:e?Q(t?.data||t,e,u):ue(void 0,s,i,void 0,a),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}),d=function({edgeColorBy:t,colorBy:e,colorScale:i,nodeStyleFn:o,edgeOpacity:r,baseStyle:n={}}){return s=>{const a={fillOpacity:r,...n};if("function"==typeof t)a.fill=t(s);else if("source"===t){const t="object"==typeof s.source?s.source:null;e&&t?a.fill=Q(t.data||t,e,i):t&&(a.fill=o(t,t.index).fill)}else if("target"===t){const t="object"==typeof s.target?s.target:null;e&&t?a.fill=Q(t.data||t,e,i):t&&(a.fill=o(t,t.index).fill)}else"gradient"===t&&(a.fill="#999",a.fillOpacity=.7*r);return a}}({edgeColorBy:r.edgeColorBy??"source",colorBy:e,colorScale:u,nodeStyleFn:h,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:e,edgeColorBy:r.edgeColorBy,edgeOpacity:r.edgeOpacity,nodeStyle:o.nodeStyle||r.nodeStyle||h,edgeStyle:o.edgeStyle||r.edgeStyle||d,colorScheme:i,...o}}},Je={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,i,o,r)=>{const n=Pt(o.theme).colors.categorical,s=new Map,a=e&&"string"==typeof e?tt(t&&"object"==typeof t?[t]:[],e,i??o.colorScheme??n):void 0,c=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7"];return{chartType:"cluster"===r.layout?"cluster":"tree",data:t,childrenAccessor:r.childrenAccessor,colorBy:e,colorByDepth:r.colorByDepth,orientation:r.orientation,showLabels:r.showLabels,colorScheme:i,...o,nodeStyle:o.nodeStyle||r.nodeStyle||(t=>{const l=t?.data||t;return{fill:r.colorByDepth?c[Number(t?.depth||0)%c.length]:e?Q(l,e,a):ue(void 0,n,i,void 0,s),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}})}}},ti={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,i,o,r)=>{const n=Pt(o.theme).colors.categorical,s=new Map;return{chartType:"circlepack",data:t,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:e,colorByDepth:r.colorByDepth,colorScheme:i,...o,nodeStyle:o.nodeStyle||(()=>({fill:ue(void 0,n,i,void 0,s),fillOpacity:r.circleOpacity??.7,stroke:"currentColor",strokeWidth:1,strokeOpacity:.3}))}}},ei={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},ii=require("d3-scale");function oi(t){return t&&"object"==typeof t&&t.properties?{...t.properties,...t}:t}var ri={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(t,e,i,o,r)=>{const n="string"==typeof i?i:"blues",s=r.areaStyle??function(t,e,i,o){if(!Array.isArray(t))return;const r=t=>"function"==typeof e?e(t):null!=e?t?.properties?.[e]??t?.[e]:void 0;let n=1/0,s=-1/0;for(const e of t){const t=r(e);null!=t&&isFinite(t)&&(n>t&&(n=t),t>s&&(s=t))}const a=(0,ii.scaleSequential)(O(i)).domain([Number.isFinite(n)?n:0,Number.isFinite(s)?s:1]);return t=>{const e=r(t);return{fill:null!=e&&isFinite(e)?a(e):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:o}}}(r.areas,r.valueAccessor,n,r.areaOpacity??1),a=r.styleRules?ut(s,r.styleRules,t=>{return{value:(e=t,"function"==typeof r.valueAccessor?r.valueAccessor(e):null!=r.valueAccessor?e?.properties?.[r.valueAccessor]??e?.[r.valueAccessor]:void 0)};var e},oi):s;return{areas:r.areas,projection:r.projection||"equalEarth",areaStyle:a,valueAccessor:r.valueAccessor,colorScheme:n,graticule:r.graticule,fitPadding:r.fitPadding,...o}}},ni={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(t,e,i,o,r)=>{const n=t||r.points,s=r.pointStyle??function(t,e,i,o){const r=Array.isArray(t)?t:[];let n,s;if(e){const t="string"==typeof e?e:"__geoColorBy",o="string"==typeof e?r:r.map(t=>({...t,__geoColorBy:e(t)}));n=tt(o,t,i)}if(o.sizeBy){const t=r.map("function"==typeof o.sizeBy?o.sizeBy:t=>t?.[o.sizeBy]).filter(t=>null!=t&&isFinite(t));t.length>0&&(s=it(t))}return t=>({fill:e&&n?Q(t,e,n):H,fillOpacity:o.fillOpacity,stroke:"#fff",strokeWidth:o.strokeWidth,r:o.sizeBy?et(t,o.sizeBy,o.sizeRange,s):o.pointRadius??6})}(n,e,i,{sizeBy:r.sizeBy,sizeRange:r.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),a=r.styleRules?ut(s,r.styleRules,st(e,r.sizeBy)):s;return{points:n,xAccessor:r.xAccessor||"lon",yAccessor:r.yAccessor||"lat",areas:r.areas,areaStyle:r.areaStyle||ei,pointStyle:a,sizeBy:r.sizeBy,colorBy:e,colorScheme:i,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,...o}}},si={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(t,e,i,o,r)=>{const n=(Array.isArray(t)?t:null)||r.flows||[],s=r.nodeIdAccessor||"id",a=r.valueAccessor||"value",c=r.xAccessor||"lon",l=r.yAccessor||"lat",u="function"==typeof c?c:t=>t[c],h="function"==typeof l?l:t=>t[l],d=(r.nodes||[]).map(t=>({...t,x:u(t),y:h(t)})),f=new Map;for(const t of d)f.set(t[s]+"",t);const p=r.edgeColorBy??e,y="function"==typeof p,g=n.map(t=>{if(!t||null==t.source||null==t.target)return null;const e=f.get(t.source+""),i=f.get(t.target+"");return e&&i?{...t,coordinates:[{x:e.x,y:e.y},{x:i.x,y:i.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=p?y?tt(g.map(t=>({[m]:p(t)})),m,i||"category10"):tt(g,p,i||"category10"):null,b=t=>p&&x?Q(t,p,x):"#007bff";let v=1/0,w=-1/0;for(const t of g){const e=Number(t[a]??0);isFinite(e)&&(v>e&&(v=e),e>w&&(w=e))}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:d,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:r.lineType||"geo",flowStyle:r.flowStyle||"basic",areas:r.areas,areaStyle:r.areaStyle||ei,projection:r.projection||"equalEarth",graticule:r.graticule,fitPadding:r.fitPadding,colorScheme:i,lineStyle:t=>{const e=Number(t?.[a]),i=Number.isFinite(e)?e:v,o=S+Math.max(0,Math.min(1,k>0?(i-v)/k:0))*M;return{stroke:b(t),strokeWidth:o,strokeLinecap:P,opacity:_,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...o}}};function ai(t){const[e,i]=t;return{width:e,height:i,plot:{x:32,y:24,width:Math.max(80,e-64),height:Math.max(80,i-58)}}}function ci(t){const e=(t??"")+"";if(!e)return"#4e79a7";const i=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let o=0;for(let t=0;e.length>t;t+=1)o=31*o+e.charCodeAt(t)>>>0;return i[o%i.length]}function li(t,e="#4e79a7",i){const o=i?.styleRules,r=!!o&&o.length>0,n=r?rt(i?.valueAccessor):void 0;return i=>{const s=i.datum,a=s&&t?"function"==typeof t?t(s,0):s[t]:void 0,c={fill:null==a?e:ci(a),stroke:"#111827",strokeWidth:1,opacity:.9};return r&&s&&Object.assign(c,lt(s,o,{value:n?n(s):void 0,category:null==a?void 0:a+""})),c}}function ui(t,e,i,o){return{fixedDt:1/120,maxSubsteps:8,colliders:e,observation:{chartType:i},kernel:{seed:t,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...o}}}function hi(t,e,i){return"function"==typeof i?i(t,e):t[i]}function di(t){if(t instanceof Date){const e=t.getTime();return Number.isFinite(e)?e:null}const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:null}function fi(t,e,i){return Math.max(e,Math.min(i,t))}function pi(t,e){const i=di(t);return null!=i&&i>0?i:e}function yi(t){return((t??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function gi(t){let e=t>>>0;return()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}var mi=require("d3-scale");function xi(t){let e=t>>>0;return function(){e=e+1831565813|0;let t=Math.imul(e^e>>>15,1|e);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}var bi={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},vi=1e-9,wi=.005;function ki(t){return"circle"===t.type?{type:"circle",radius:t.radius}:{type:"aabb",width:t.width,height:t.height}}function Si(t){return"aabb"===t.type?{type:"aabb",x:t.x,y:t.y,width:t.width,height:t.height}:{type:"segment",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,thickness:t.thickness}}function Ai(t,e,i){return Math.max(e,Math.min(i,t))}function Mi(t){return 0>t?-1:1}function _i(t){if("circle"===t.shape.type){const e=t.shape.radius;return{minX:t.x-e,minY:t.y-e,maxX:t.x+e,maxY:t.y+e}}const e=t.shape.width/2,i=t.shape.height/2;return{minX:t.x-e,minY:t.y-i,maxX:t.x+e,maxY:t.y+i}}function Pi(t){const e=t.shape;if("aabb"===e.type){const t=e.width/2,i=e.height/2;return{minX:e.x-t,minY:e.y-i,maxX:e.x+t,maxY:e.y+i}}const i=(e.thickness??0)/2;return{minX:Math.min(e.x1,e.x2)-i,minY:Math.min(e.y1,e.y2)-i,maxX:Math.max(e.x1,e.x2)+i,maxY:Math.max(e.y1,e.y2)+i}}function Li(t,e){return!(t.minX>e.maxX||e.minX>t.maxX||t.minY>e.maxY||e.minY>t.maxY)}function Ri(t,e,i,o,r,n,s,a){const c=r-t,l=(i+s)/2-Math.abs(c);if(0>=l)return null;const u=n-e,h=(o+a)/2-Math.abs(u);return h>0?h>l?{nx:Mi(c),ny:0,penetration:l}:{nx:0,ny:Mi(u),penetration:h}:null}function Ti(t,e,i,o,r,n,s){const a=n/2,c=s/2;let l=t-Ai(t,o-a,o+a),u=e-Ai(e,r-c,r+c);const h=l*l+u*u;if(h>i*i)return null;if(vi>=h){const n=Math.abs(t-(o-a)),s=Math.abs(t-(o+a)),h=Math.abs(e-(r-c)),d=Math.abs(e-(r+c)),f=Math.min(n,s,h,d);return f===n?(l=-1,u=0,{nx:l,ny:u,penetration:i+n}):f===s?(l=1,u=0,{nx:l,ny:u,penetration:i+s}):f===h?(l=0,u=-1,{nx:l,ny:u,penetration:i+h}):(l=0,u=1,{nx:l,ny:u,penetration:i+d})}const d=Math.sqrt(h);return{nx:l/d,ny:u/d,penetration:i-d}}function Ci(t,e){if("circle"===t.shape.type&&"circle"===e.shape.type)return function(t,e,i,o,r,n){const s=o-t,a=r-e,c=i+n,l=s*s+a*a;if(l>=c*c)return null;if(vi>=l)return{nx:1,ny:0,penetration:c};const u=Math.sqrt(l);return{nx:s/u,ny:a/u,penetration:c-u}}(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.radius);if("aabb"===t.shape.type&&"aabb"===e.shape.type)return Ri(t.x,t.y,t.shape.width,t.shape.height,e.x,e.y,e.shape.width,e.shape.height);if("circle"===t.shape.type&&"aabb"===e.shape.type){const i=Ti(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height);return i?{nx:-i.nx,ny:-i.ny,penetration:i.penetration}:null}return"aabb"===t.shape.type&&"circle"===e.shape.type?Ti(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height):null}function $i(t,e){const i=e.shape;return"aabb"===i.type?"circle"===t.shape.type?Ti(t.x,t.y,t.shape.radius,i.x,i.y,i.width,i.height):Ri(i.x,i.y,i.width,i.height,t.x,t.y,t.shape.width,t.shape.height):function(t,e,i,o,r,n,s,a=0){const c=n-o,l=s-r,u=c*c+l*l,h=u>vi?Ai(((t-o)*c+(e-r)*l)/u,0,1):0,d=i+a/2,f=t-(o+c*h),p=e-(r+l*h),y=f*f+p*p;if(y>=d*d)return null;if(vi>=y){const t=Math.sqrt(u);return t>vi?{nx:-l/t,ny:c/t,penetration:d}:{nx:1,ny:0,penetration:d}}const g=Math.sqrt(y);return{nx:f/g,ny:p/g,penetration:d-g}}(t.x,t.y,"circle"===t.shape.type?t.shape.radius:Math.sqrt(t.shape.width*t.shape.width+t.shape.height*t.shape.height)/2,i.x1,i.y1,i.x2,i.y2,i.thickness??0)}function ji(t,e){return`${t}\0${e}`}function zi(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function Ei(t){return{id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,bodyCollisions:t.bodyCollisions,shape:ki(t.shape),sleeping:t.sleeping,datum:t.datum,index:t.index,sleepTime:t.sleepTime,restitution:t.restitution,friction:t.friction}}function Di(t){return t&&"function"!=typeof t?{property:t.property,equals:t.equals,notEquals:t.notEquals,oneOf:t.oneOf?.slice(),notOneOf:t.notOneOf?.slice()}:t}function Fi(t){return{id:t.id,shape:Si(t.shape),sensor:t.sensor,restitution:t.restitution,friction:t.friction,bodyFilter:Di(t.bodyFilter),index:t.index}}function Oi(t,e){return!!e?.some(e=>Object.is(t,e))}function Ni(t,e){const i=t.bodyFilter;if(!i)return!0;if("function"==typeof i)return i(e);const o=function(t,e){if(!e)return;let i=t;for(const t of e.split(".")){if(null==i||"object"!=typeof i)return;i=i[t]}return i}(e,i.property);return!("equals"in i&&!Object.is(o,i.equals)||"notEquals"in i&&Object.is(o,i.notEquals)||i.oneOf&&!Oi(o,i.oneOf)||i.notOneOf&&Oi(o,i.notOneOf))}var Bi=class{constructor(t={}){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={...bi,...t},this.random=xi(this.options.seed)}init(t={}){this.options={...bi,...t},this.random=xi(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[],this.nextBodyIndex=0,this.nextColliderIndex=0,this.nextSpringIndex=0}spawn(t){const e={id:t.id,x:t.x,y:t.y,prevX:t.x,prevY:t.y,vx:t.vx??0,vy:t.vy??0,angle:t.angle??0,mass:Math.max(vi,t.mass??1),bodyCollisions:t.bodyCollisions??!0,shape:ki(t.shape),sleeping:!1,datum:t.datum,restitution:t.restitution,friction:t.friction,index:this.nextBodyIndex,sleepTime:0};this.nextBodyIndex+=1,this.bodies.set(t.id,e)}remove(t){for(const e of t){this.bodies.delete(e);for(const t of Array.from(this.activeSensors))zi(t).bodyId===e&&this.activeSensors.delete(t)}}setColliders(t){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(const e of t)this.colliders.set(e.id,{...e,shape:Si(e.shape),bodyFilter:Di(e.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(t){const e=t.id??"spring-"+this.nextSpringIndex;return this.springs.set(e,{id:e,bodyId:t.bodyId,target:t.target,restLength:t.restLength??0,stiffness:t.stiffness??40,damping:t.damping??3}),this.nextSpringIndex+=1,e}removeConstraint(t){this.springs.delete(t)}applyImpulse(t,e,i){const o=this.bodies.get(t);o&&(o.vx+=e/o.mass,o.vy+=i/o.mass,this.wake(o))}step(t=this.options.fixedDt){const e=Math.max(0,t);if(this.lastEvents=[],0===e)return;const i=this.sortedBodies();for(const t of i)t.prevX=t.x,t.prevY=t.y;this.applySprings(e);const o=this.options.maxVelocity;for(const t of i)if(!t.sleeping){if(t.vx+=this.options.gravity.x*e,t.vy+=this.options.gravity.y*e,t.vx*=this.options.velocityDamping,t.vy*=this.options.velocityDamping,o>0){const e=Math.sqrt(t.vx*t.vx+t.vy*t.vy);if(e>o){const i=o/e;t.vx*=i,t.vy*=i}}t.x+=t.vx*e,t.y+=t.vy*e}this.supportedThisStep.clear();const r=this.bodyPairKeys(i),n=this.sortedColliders().filter(t=>!t.sensor);for(let t=0;this.options.collisionIterations>t;t+=1)this.resolveBodyPairs(i,r,0===t),this.resolveColliders(i,n,0===t);this.updateSensors(i),this.updateSleeping(i,e)}settle(t=1200,e=this.options.fixedDt){let i=0;for(;t>i&&!this.allSleeping();)this.step(e),i+=1;return i}readState(t=[]){t.length=0;for(const e of this.sortedBodies())t.push({id:e.id,x:e.x,y:e.y,prevX:e.prevX,prevY:e.prevY,vx:e.vx,vy:e.vy,angle:e.angle,mass:e.mass,shape:ki(e.shape),sleeping:e.sleeping,datum:e.datum});return t}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(zi)}allSleeping(){for(const t of this.bodies.values())if(!t.sleeping)return!1;return!0}snapshot(){return{options:{...this.options,gravity:{...this.options.gravity}},bodies:this.sortedBodies().map(Ei),colliders:this.sortedColliders().map(Fi),springs:Array.from(this.springs.values()).map(t=>({...t,target:{...t.target}})),activeSensors:Array.from(this.activeSensors).sort()}}restore(t){this.options={...t.options,gravity:{...t.options.gravity}},this.random=xi(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(t.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(const e of t.bodies){const t=Ei(e);this.bodies.set(t.id,t),this.nextBodyIndex=Math.max(this.nextBodyIndex,t.index+1)}this.nextColliderIndex=0;for(const e of t.colliders){const t=Fi(e);this.colliders.set(t.id,t),this.nextColliderIndex=Math.max(this.nextColliderIndex,t.index+1)}this.nextSpringIndex=0;for(const e of t.springs){this.springs.set(e.id,{...e,target:{...e.target}});const t=/^spring-(\d+)$/.exec(e.id);t&&(this.nextSpringIndex=Math.max(this.nextSpringIndex,Number(t[1])+1))}}dispose(){this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors.clear(),this.lastEvents=[]}sortedBodies(){return Array.from(this.bodies.values()).sort((t,e)=>t.index-e.index)}sortedColliders(){return Array.from(this.colliders.values()).sort((t,e)=>t.index-e.index)}applySprings(t){for(const e of Array.from(this.springs.values()).sort((t,e)=>t.id.localeCompare(e.id))){const i=this.bodies.get(e.bodyId);if(!i||i.sleeping)continue;const o="point"===e.target.type?e.target:this.bodies.get(e.target.bodyId);if(!o)continue;const r=o.x-i.x,n=o.y-i.y,s=Math.sqrt(r*r+n*n);if(vi>=s)continue;const a=r/s,c=n/s,l=(s-e.restLength)*e.stiffness+((("vx"in o?o.vx:0)-i.vx)*a+(("vy"in o?o.vy:0)-i.vy)*c)*e.damping;i.vx+=l*a*t/i.mass,i.vy+=l*c*t/i.mass}}resolveBodyPairs(t,e,i){for(const o of e){const[e,r]=o.split(":").map(Number),n=t[e],s=t[r];if(!n||!s)continue;const a=Ci(n,s);a&&(this.resolveDynamicCollision(n,s,a),i&&this.lastEvents.push({type:"contact",bodyId:n.id,otherId:s.id,sensor:!1}))}}bodyPairKeys(t){const e=Math.max(1,this.options.cellSize),i=new Map;for(let o=0;t.length>o;o+=1){if(!1===t[o].bodyCollisions)continue;const r=_i(t[o]),n=Math.floor(r.minX/e),s=Math.floor(r.maxX/e),a=Math.floor(r.minY/e),c=Math.floor(r.maxY/e);for(let t=n;s>=t;t+=1)for(let e=a;c>=e;e+=1){const r=`${t}:${e}`,n=i.get(r);n?n.push(o):i.set(r,[o])}}const o=new Set;for(const e of Array.from(i.keys()).sort()){const r=i.get(e)??[];r.sort((t,e)=>t-e);for(let e=0;r.length>e;e+=1)for(let i=e+1;r.length>i;i+=1){const n=r[e],s=r[i];!1!==t[n].bodyCollisions&&!1!==t[s].bodyCollisions&&Li(_i(t[n]),_i(t[s]))&&o.add(`${n}:${s}`)}}return Array.from(o).sort((t,e)=>{const[i,o]=t.split(":").map(Number),[r,n]=e.split(":").map(Number);return i===r?o-n:i-r})}resolveDynamicCollision(t,e,i){t.sleeping&&this.supportedThisStep.add(e.id),e.sleeping&&this.supportedThisStep.add(t.id);const o=t.sleeping?0:1/t.mass,r=e.sleeping?0:1/e.mass,n=o+r;if(vi>=n)return;const s=Math.max(0,i.penetration-wi)/n;t.x-=i.nx*s*o,t.y-=i.ny*s*o,e.x+=i.nx*s*r,e.y+=i.ny*s*r;const a=(e.vx-t.vx)*i.nx+(e.vy-t.vy)*i.ny;if(a>0)return;const c=Math.abs(a),l=-(1+Math.min(t.restitution??this.options.restitution,e.restitution??this.options.restitution))*a/n,u=l*i.nx,h=l*i.ny;t.vx-=u*o,t.vy-=h*o,e.vx+=u*r,e.vy+=h*r,this.applyFriction(t,e,i,l,o,r),c>this.options.contactWakeSpeed&&(this.wake(t),this.wake(e))}applyFriction(t,e,i,o,r,n){const s=-i.ny,a=i.nx,c=(e.vx-t.vx)*s+(e.vy-t.vy)*a,l=r+n;if(vi>=Math.abs(c)||vi>=l)return;const u=Math.max(0,Math.min(1,Math.max(t.friction??this.options.friction,e.friction??this.options.friction))),h=Ai(-c/l,-o*u,o*u),d=h*s,f=h*a;t.vx-=d*r,t.vy-=f*r,e.vx+=d*n,e.vy+=f*n}resolveColliders(t,e,i){for(const o of t)for(const t of e){if(!Ni(t,o))continue;if(!Li(_i(o),Pi(t)))continue;const e=$i(o,t);e&&(this.resolveStaticCollision(o,t,e),this.supportedThisStep.add(o.id),i&&this.lastEvents.push({type:"contact",bodyId:o.id,otherId:t.id,sensor:!1}))}}resolveStaticCollision(t,e,i){t.x+=i.nx*Math.max(0,i.penetration-wi),t.y+=i.ny*Math.max(0,i.penetration-wi);const o=t.vx*i.nx+t.vy*i.ny;if(0>o){const r=Math.min(t.restitution??this.options.restitution,e.restitution??this.options.restitution);t.vx-=(1+r)*o*i.nx,t.vy-=(1+r)*o*i.ny;const n=-i.ny,s=i.nx,a=t.vx*n+t.vy*s,c=Math.max(0,Math.min(1,Math.max(t.friction??this.options.friction,e.friction??this.options.friction)));t.vx-=a*n*c,t.vy-=a*s*c}}updateSensors(t){const e=new Set,i=this.sortedColliders().filter(t=>t.sensor);for(const o of t){const t=_i(o);for(const r of i){if(!Ni(r,o))continue;if(!Li(t,Pi(r)))continue;if(!$i(o,r))continue;const i=ji(r.id,o.id);e.add(i),this.activeSensors.has(i)||this.lastEvents.push({type:"sensor-enter",bodyId:o.id,sensorId:r.id})}}for(const t of Array.from(this.activeSensors).sort()){if(e.has(t))continue;const{sensorId:i,bodyId:o}=zi(t);this.lastEvents.push({type:"sensor-exit",bodyId:o,sensorId:i})}this.activeSensors=e}updateSleeping(t,e){const i=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const o of t)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*e||i&&!this.supportedThisStep.has(o.id)?o.sleeping?this.wake(o):o.sleepTime=0:(o.sleepTime+=e,o.sleeping||this.options.sleepAfter>o.sleepTime||(o.sleeping=!0,o.vx=0,o.vy=0,this.lastEvents.push({type:"sleep",bodyId:o.id})))}wake(t){t.sleeping&&this.lastEvents.push({type:"wake",bodyId:t.id}),t.sleeping=!1,t.sleepTime=0}nextRandom(){return this.random()}},Ii=class{constructor(t={}){this.id="builtin",this.capabilities={...(new Bi).capabilities,engine:"builtin"},this.world=new Bi(t)}init(t={}){this.world.init(t)}spawn(t){this.world.spawn(t)}remove(t){this.world.remove(t)}setColliders(t){this.world.setColliders(t)}setConstraint(t){return this.world.setConstraint(t)}removeConstraint(t){this.world.removeConstraint(t)}applyImpulse(t,e,i){this.world.applyImpulse(t,e,i)}step(t){this.world.step(t)}settle(t,e){return this.world.settle(t,e)}readState(t){return this.world.readState(t)}events(){return this.world.events()}activeSensorPairs(){return this.world.activeSensorPairs()}allSleeping(){return this.world.allSleeping()}snapshot(){return this.world.snapshot()}restore(t){this.world.restore(t)}nextRandom(){return this.world.nextRandom()}dispose(){this.world.dispose()}};function Wi(t,e={}){return t?"function"==typeof t?t(e):(t.init(e),t):function(t={}){return new Ii(t)}(e)}var Yi=["binId","targetBin","category","windowIndex","lane","group"];function qi(t,e){if(!Number.isFinite(e))return;t.count+=1,t.total+=e,t.min=Math.min(t.min,e),t.max=Math.max(t.max,e);const i=e-t.mean;t.mean+=i/t.count,t.m2+=i*(e-t.mean)}function Xi(t){return{count:t.count,total:t.total,mean:t.count>0?t.mean:0,min:t.count>0?t.min:0,max:t.count>0?t.max:0,variance:t.count>1?t.m2/(t.count-1):0}}function Gi(t){return{count:t.count,total:t.total,mean:t.mean,m2:t.variance*Math.max(0,t.count-1),min:t.count>0?t.min:1/0,max:t.count>0?t.max:-1/0}}function Vi(t,e){if(null!=t[e])return t[e];const i=t.datum;return i&&"object"==typeof i?i[e]:void 0}function Hi(t,e,i){return"function"==typeof t?t(e,i):"string"==typeof t?Vi(e,t):void 0}function Zi(t){if(null==t)return;const e=t+"";return e.trim()?e:void 0}function Ui(t){const e=Xi(t.value);return{id:t.id,label:t.label,count:e.count,total:e.total,bodyIds:t.bodyIds.slice(),lastBodyId:t.lastBodyId,lastDatum:t.lastDatum,x:Xi(t.x),y:Xi(t.y),value:e}}var Ki=class{constructor(t=!1){this.bins=new Map,this.nextIndex=0,this.config=t}updateConfig(t){void 0!==t&&(this.config=t,!1===t&&this.clear())}isEnabled(){return!1!==this.config}add(t){if(!1===this.config)return null;const e=this.nextIndex;this.nextIndex+=1;const i=Zi(Hi(this.config.binAccessor,t,e))??function(t){for(const e of Yi){const i=Zi(Vi(t,e));if(i)return i}return"sediment"}(t),o=Zi(Hi(this.config.labelAccessor,t,e))??i,r=function(t,e,i){if("number"==typeof t)return t;const o="function"==typeof t?t(e,i):"string"==typeof t?Vi(e,t):1,r="number"==typeof o?o:Number(o);return Number.isFinite(r)?r:1}(this.config.valueAccessor,t,e),n=Math.max(0,Math.floor(this.config.retainBodyIds??12));let s=this.bins.get(i);return s||(s={id:i,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(i,s)),s.label=o,s.lastBodyId=t.id,s.lastDatum=t.datum,qi(s.x,t.x),qi(s.y,t.y),qi(s.value,r),n>0&&(s.bodyIds.push(t.id),s.bodyIds.length>n&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-n))),Ui(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(Ui)}restore(t=[]){this.bins.clear();for(const e of t)this.bins.set(e.id,{id:e.id,label:e.label,bodyIds:e.bodyIds.slice(),lastBodyId:e.lastBodyId,lastDatum:e.lastDatum,x:Gi(e.x),y:Gi(e.y),value:Gi(e.value)});this.nextIndex=t.reduce((t,e)=>t+e.count,0)}totals(){const t=this.snapshot();return{bins:t.length,count:t.reduce((t,e)=>t+e.count,0),total:t.reduce((t,e)=>t+e.total,0)}}};function Qi(t){const e=Number(t);if(Number.isFinite(e)&&e>0)return Math.floor(e)}var Ji={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},to={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function eo(t={},e=to){return{chartId:t.chartId??e.chartId,chartType:t.chartType??e.chartType,sensors:t.sensors??e.sensors,onObservation:t.onObservation??e.onObservation,onSimulationStateChange:t.onSimulationStateChange??e.onSimulationStateChange}}function io(t){return{...t,shape:{...t.shape},datum:t.datum,springs:t.springs?.map(t=>({...t,target:{...t.target}}))}}function oo(t){if(t instanceof Date){const e=t.getTime();return Number.isFinite(e)?e:void 0}const e="number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;return Number.isFinite(e)?e:void 0}function ro(t,e){if(null!=t[e])return t[e];const i=t.datum;return i&&"object"==typeof i?i[e]:void 0}function no(t){return{...io(t),sequence:t.sequence,spawnAt:t.spawnAt}}function so(t){return t.map(t=>({...t,shape:{...t.shape},bodyFilter:t.bodyFilter&&"function"!=typeof t.bodyFilter?{...t.bodyFilter,oneOf:t.bodyFilter.oneOf?.slice(),notOneOf:t.bodyFilter.notOneOf?.slice()}:t.bodyFilter}))}function ao(t){return!1!==t&&{...t}}function co(t,e){return t.spawnAt===e.spawnAt?t.sequence-e.sequence:t.spawnAt-e.spawnAt}function lo(t){return{...t,gravity:{...t.gravity}}}function uo(t,e,i,o){if("circle"===t.shape.type){const r=t.x-e,n=t.y-i,s=t.shape.radius+o,a=r*r+n*n;return a>s*s?null:a}const r=Math.max(Math.abs(e-t.x)-t.shape.width/2,0),n=Math.max(Math.abs(i-t.y)-t.shape.height/2,0),s=r*r+n*n;return s>o*o?null:s}function ho(t){const e=t.indexOf("\0");return{sensorId:t.slice(0,e),bodyId:t.slice(e+1)}}function fo(t,e={}){const{idPrefix:i="plot",includeFloor:o=!0,includeCeiling:r=!1,includeLeftWall:n=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=e,l=[],u=t.x+t.width/2,h=t.y+t.height/2;return o&&l.push({id:i+"-floor",shape:{type:"aabb",x:u,y:t.y+t.height+c/2,width:t.width+2*a,height:c}}),r&&l.push({id:i+"-ceiling",shape:{type:"aabb",x:u,y:t.y-c/2,width:t.width+2*a,height:c}}),n&&l.push({id:i+"-left-wall",shape:{type:"aabb",x:t.x-a/2,y:h,width:a,height:t.height+2*c}}),s&&l.push({id:i+"-right-wall",shape:{type:"aabb",x:t.x+t.width+a/2,y:h,width:a,height:t.height+2*c}}),l}function po(t){const{idPrefix:e="bin",count:i,domainStart:o,domainStep:r,xScale:n,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:h,lidY:d=s,lidThickness:f=Math.max(2,c)}=t,p=[],y=s+(a-s)/2,g=Math.abs(a-s),m=l?i:i-1;if(u||l)for(let t=l?0:1;m>=t;t+=1){if(!u&&t>0&&i>t)continue;const s=n(o+t*r);p.push({id:`${e}-wall-${t}`,shape:{type:"aabb",x:s,y:y,width:c,height:g}})}if(null!=h)for(let t=0;i>t;t+=1){const i=o+t*r,s=i+r;if(s>=h)continue;const a=n(i),l=n(s);p.push({id:`${e}-lid-${t}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:d,x2:Math.max(a,l)-c/2,y2:d,thickness:f}})}return p}var yo={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 go(t,e){const i={...t};for(const t of e)i[yo[t]]++;return i}function mo(t,e,i){const o=new Set(e);return{changeSet:{...t,...t.keys?{keys:[...t.keys]}:{}},changed:o,revisions:go(i,o)}}var xo=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=mo({kind:"initialize"},[],this.revisions),this.listeners=new Set}get last(){return this.latest}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}record(t,e){const i=mo(t,e,this.revisions);this.revisions=i.revisions,this.latest=i;for(const t of[...this.listeners])t();return i}},bo=require("d3-quadtree"),vo=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(t,e,i,o,r,n=0){const s=this.ensure(t,e);if(!s)return null;let a=null,c=1/0;const l=Math.max(0,n)+this.maxSearchRadius,u=o-l,h=o+l,d=r-l,f=r+l;return s.visit((t,e,s,l,p)=>{if(u>l||e>h||d>p||s>f)return!0;if(t.length)return!1;let y=t;for(;y;){const t=y.data;if(t){const e=uo(t,o,r,Math.max(0,n));null!=e&&(c>e||e===c&&i.indexOf(t.id)>i.indexOf(a?.id??""))&&(a=t,c=e)}y=y.next}return!1}),a}ensure(t,e){if(this.tree&&this.revision===e)return this.tree;const i=t.readState();return 0===i.length?(this.tree=null,this.maxSearchRadius=0,this.revision=e,null):(this.maxSearchRadius=i.reduce((t,e)=>Math.max(t,function(t){return"circle"===t.shape.type?t.shape.radius:Math.hypot(t.shape.width,t.shape.height)/2}(e)),0),this.tree=(0,bo.quadtree)().x(t=>t.x).y(t=>t.y).addAll(i),this.revision=e,this.tree)}},wo=["data","scene-geometry","data-paint","accessibility","evidence"],ko=["scene-geometry","data-paint","accessibility","evidence"],So=["overlay","accessibility","evidence"],Ao=(t,e)=>({retainedData:t,invalidations:e}),Mo=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],_o=["scene-geometry","data-paint","accessibility","evidence"],Po=[],Lo={engine:Ao("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:Ao("preserve",_o),colliders:Ao("preserve",_o),sediment:Ao("preserve",_o),bodyBudget:Ao("preserve",Mo),bodyLimit:Ao("preserve",Mo),eviction:Ao("preserve",Mo),fixedDt:Ao("preserve",Po),maxDeltaSeconds:Ao("preserve",Po),maxSubsteps:Ao("preserve",Po),settleStepLimit:Ao("preserve",Po),timeScale:Ao("preserve",Po),observation:Ao("preserve",Po)},Ro=Ao("preserve",Mo);function To(t){let e="preserve";const i=new Set;for(const o of t){const t=Lo[o]??Ro;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}var Co=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function $o(t,e){return t===e||!(!t||!e)&&t.gravity?.x===e.gravity?.x&&t.gravity?.y===e.gravity?.y&&Co.every(i=>t[i]===e[i])}function jo(t,e,i,o){return t||!e?"paused":i||!o?"running":"settled"}var zo=class{constructor(t={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new vo,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new xo,this.simulationState="settled",this.visible=!0;const{bodyBudget:e,colliders:i,engine:o,kernel:r,observation:n,sediment:s,...a}=t;this.config={...Ji,...a},this.configInput={...t},this.bodyBudget=e??{},this.engineInput=o,this.observation=eo(n),this.sediment=new Ki(s??!1),this.world=Wi(o,{fixedDt:this.config.fixedDt,...r}),i&&this.world.setColliders(so(i))}updateConfig(t){const e=function(t,e){return Object.keys(t).filter(i=>"kernel"===i?!$o(t.kernel,e.kernel):t[i]!==e[i])}(t,this.configInput),{colliders:i,bodyBudget:o,engine:r,kernel:n,observation:s,sediment:a,...c}=t;if(this.config={...this.config,...c},void 0!==o&&(this.bodyBudget=o,!1===o&&(this.bodyBudgetObservationKey="ok")),r&&r!==this.engineInput){const t=this.world.snapshot();this.world.dispose(),this.engineInput=r,this.world=Wi(r,t.options),this.world.restore(t),this.revision+=1}if(n&&!$o(n,this.configInput.kernel)){const t=this.world.snapshot(),e={...t.options,...n,gravity:{...t.options.gravity,...n.gravity}};this.world.restore({...t,options:e}),this.revision+=1}s&&(this.observation=eo(s,this.observation)),this.sediment.updateConfig(a),i&&(this.world.setColliders(so(i)),this.revision+=1),this.configInput={...this.configInput,...t};const l=To(e);this.updateResults.record({kind:"config",keys:e},l.invalidations)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}setColliders(t){this.world.setColliders(so(t)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},To(["colliders"]).invalidations)}enqueue(t,e){const i=Array.isArray(t)?t:[t],o=e?function(t,e={}){const i=oo(e.startAt)??0,o=e.pacing??"immediate";if("arrival"===o){const o=t.map((t,i)=>function(t,e,i){return"function"==typeof i?oo(i(t,e)):"string"==typeof i?oo(ro(t,i)):oo(t.spawnAt)??oo(ro(t,"arrivalTime"))??oo(ro(t,"timestamp"))??oo(ro(t,"time"))??oo(ro(t,"eventTime"))}(t,i,e.timeAccessor)),r=o.filter(t=>null!=t),n=r.length>0?Math.min(...r):0,s=oo(e.timeScale)??1,a=s>0?s:1;return t.map((t,e)=>{const r=o[e],s=null==r?0:Math.max(0,r-n);return{...io(t),spawnAt:i+s/a}})}if("object"==typeof o){const e=oo(o.ratePerSec);if(e&&e>0)return t.map((t,o)=>({...io(t),spawnAt:i+o/e}))}return t.map(t=>({...io(t),spawnAt:i}))}(i,{...e,startAt:e.startAt??this.elapsedSeconds}):i;for(const t of o)this.queue.push({...io(t),sequence:this.nextSequence,spawnAt:t.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(co),o.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:o.length},o.length?wo:[])}enqueueWithResult(t,e){return this.enqueue(t,e),this.updateResults.last}spawnNow(t){this.spawnOne(io(t)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},wo)}clear(){const t=this.world.snapshot().options;this.world.init({...t,fixedDt:this.config.fixedDt}),this.activeSensorPairs.clear(),this.liveBodyOrder=[],this.queue=[],this.accumulator=0,this.elapsedSeconds=0,this.nextSequence=0,this.sediment.clear(),this.bodyBudgetObservationKey="ok",this.revision+=1,this.syncSimulationState(),this.updateResults.record({kind:"clear"},wo)}tick(t){const e=this.revision,i=[],o=[],r=[],n=[],s=[];if(this.paused||!this.visible){const t=this.result(0,i,o,r,n,s,!1);return this.updateResults.record({kind:"tick",count:0},[]),t}const a=Math.max(0,Math.min(t,this.config.maxDeltaSeconds))*this.config.timeScale;this.elapsedSeconds+=a,this.spawnDue(i,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 t=this.world.events();n.push(...t),this.observeKernelEvents(t,s),this.observeSensorTransitions(s),this.accumulator-=this.config.fixedDt,u+=1}u===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),(u>0||i.length>0||o.length>0||r.length>0||n.length>0)&&(this.revision+=1);const h=this.result(u,i,o,r,n,s,void 0,c);return this.updateResults.record({kind:"tick",count:u},this.revision!==e?i.length||o.length||r.length?wo:ko:[]),h}settle(t=this.config.settleStepLimit){const e=this.revision;this.spawnDue([],[]);const i=this.world.settle(t,this.config.fixedDt);return i>0&&(this.revision+=1),this.syncSimulationState(),this.updateResults.record({kind:"settle",count:i},this.revision!==e?ko:[]),i}settleWithObservations(t=this.config.settleStepLimit){const e=this.revision,i=[],o=[],r=[],n=[],s=[];if(this.paused||!this.visible){const t=this.result(0,i,o,r,n,s,!1);return this.updateResults.record({kind:"settle",count:0},[]),t}this.spawnDue(i,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(;t>l&&!this.world.allSleeping();){this.world.step(this.config.fixedDt);const t=this.world.events();n.push(...t),this.observeKernelEvents(t,s),this.observeSensorTransitions(s),l+=1}(l>0||i.length>0||o.length>0||r.length>0||n.length>0)&&(this.revision+=1);const u=this.result(l,i,o,r,n,s,void 0,a);return this.updateResults.record({kind:"settle",count:l},this.revision!==e?i.length||o.length||r.length?wo:ko:[]),u}readBodies(t=[]){return this.world.readState(t)}readSediment(){return this.sediment.snapshot()}bodyBudgetStatus(){return this.evaluateBodyBudget()}sedimentTotals(){return this.sediment.totals()}sedimentHeightfield(t={}){return function(t,e={}){const{baselineY:i=0,binWidth:o=24,gap:r=2,maxHeight:n=80,value:s="count",x:a}=e,c=Math.max(1,...t.map(t=>t[s]));return t.map((t,e)=>{const l=Math.max(0,t[s]/c*n),u=a?.(t,e)??e*(o+r);return{binId:t.id,label:t.label,index:e,count:t.count,total:t.total,x:u,y:i-l,width:o,height:l,meanX:t.x.mean,meanY:t.y.mean}})}(this.readSediment(),t)}hitTest(t,e,i=0){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,t,e,i)}events(){return this.world.events()}allSleeping(){return this.world.allSleeping()}hasPendingWork(){return this.queue.length>0||!this.world.allSleeping()}queueSize(){return this.queue.length}liveBodyCount(){return this.liveBodyOrder.length}elapsed(){return this.elapsedSeconds}recordObservation(t){const{timestamp:e,chartType:i,chartId:o,...r}=t,n={...r,timestamp:e??this.elapsedSeconds,chartType:i??this.observation.chartType,chartId:o??this.observation.chartId};return this.emitObservation(n),this.updateResults.record({kind:"update",count:1},["evidence"]),n}getLastUpdateResult(){return this.updateResults.last}getUpdateSnapshot(){return this.updateResults.last}subscribeUpdateResult(t){return this.updateResults.subscribe(t)}version(){return this.revision}setPaused(t){const e=this.paused!==t;this.paused=t,this.syncSimulationState(),this.updateResults.record({kind:"pause"},e?So:[])}setVisible(t){const e=this.visible!==t;this.visible=t,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},e?So:[])}remove(t){const e=new Set(t),i=new Set(this.liveBodyOrder),o=new Set(this.queue.map(t=>t.id));this.queue=this.queue.filter(t=>!e.has(t.id)),this.liveBodyOrder=this.liveBodyOrder.filter(t=>!e.has(t)),this.world.remove(t),this.removeActiveSensorPairsForBodies(e);const r=t.filter(t=>i.has(t)||o.has(t));return r.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:r,count:r.length},r.length?wo:[]),r}setConstraint(t){const e=this.world.setConstraint(t);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},ko),e}removeConstraint(t){this.world.removeConstraint(t),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},ko)}applyImpulse(t,e,i){this.world.applyImpulse(t,e,i),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[t]},ko)}nextRandom(){return this.world.nextRandom()}controls(){return t=this,{applyImpulse:(e,i,o)=>t.applyImpulse(e,i,o),clear:()=>t.clear(),hitTest:(e,i,o)=>t.hitTest(e,i,o),pause:()=>t.setPaused(!0),push:(e,i)=>t.enqueue(e,i),pushMany:(e,i)=>t.enqueue(e,i),bodyBudgetStatus:()=>t.bodyBudgetStatus(),readBodies:e=>t.readBodies(e),readSediment:()=>t.readSediment(),recordObservation:e=>t.recordObservation(e),remove:e=>t.remove(e),restore:e=>t.restore(e),resume:()=>t.setPaused(!1),settle:e=>t.settle(e),settleWithObservations:e=>t.settleWithObservations(e),snapshot:()=>t.snapshot(),sedimentHeightfield:e=>t.sedimentHeightfield(e),sedimentTotals:()=>t.sedimentTotals(),step:e=>t.tick(e)};var t}snapshot(){const t=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:ao(this.bodyBudget),config:{...this.config,kernel:lo(t.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(no),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:t}}restore(t){this.config={bodyLimit:t.config.bodyLimit,eviction:t.config.eviction,fixedDt:t.config.fixedDt,maxDeltaSeconds:t.config.maxDeltaSeconds,maxSubsteps:t.config.maxSubsteps,settleStepLimit:t.config.settleStepLimit,timeScale:t.config.timeScale},this.configInput={...t.config,bodyBudget:ao(t.bodyBudget??{}),kernel:lo(t.world.options)},this.bodyBudget=ao(t.bodyBudget??{}),this.bodyBudgetObservationKey="ok",this.activeSensorPairs=new Set(t.activeSensorPairs),this.accumulator=t.accumulator,this.elapsedSeconds=t.elapsedSeconds,this.paused=t.paused,this.queue=t.queue.map(no).sort(co),this.revision=t.revision,this.sediment.restore(t.sediment??[]),this.simulationState=t.simulationState??jo(t.paused,t.visible,t.queue.length>0,t.world.bodies.every(t=>t.sleeping)),this.liveBodyOrder=t.liveBodyOrder.slice(),this.visible=t.visible,this.nextSequence=this.queue.reduce((t,e)=>Math.max(t,e.sequence),-1)+1,this.world.restore(t.world),this.updateResults.record({kind:"restore"},wo)}spawnDue(t,e){for(;this.queue.length>0&&this.elapsedSeconds>=this.queue[0].spawnAt;){const i=this.queue.shift();if(!i)return;this.spawnOne(i,e),t.push(i.id)}}spawnOne(t,e){this.liveBodyOrder=this.liveBodyOrder.filter(e=>e!==t.id),this.removeActiveSensorPairsForBodies(new Set([t.id])),this.world.spawn(t),this.liveBodyOrder.push(t.id);for(const e of t.springs??[])this.world.setConstraint({...e,bodyId:t.id});const i=this.world.readState().find(e=>e.id===t.id);this.emitObservation({type:"physics-spawn",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:t.id,datum:i?.datum??t.datum,x:i?.x??t.x,y:i?.y??t.y},e)}result(t,e,i,o,r,n,s,a=this.evaluateBodyBudget()){this.syncSimulationState(n);const c=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:i,events:r,observations:n,queueSize:this.queue.length,revision:this.revision,shouldContinue:s??(this.queue.length>0||!c),sleeping:c,sedimented:o,spawned:e,steps:t}}observeKernelEvents(t,e){!function(t,e,i){if(0===e.length)return;const o=new Map(t.readState().map(t=>[t.id,t]));for(const t of e){if("sleep"!==t.type)continue;const e=o.get(t.bodyId);i.emit({type:"physics-settle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:t.bodyId,datum:e?.datum,x:e?.x,y:e?.y})}}(this.world,t,this.observationContext(e))}observeSensorTransitions(t){this.activeSensorPairs=function(t,e,i){const o=new Set(t.activeSensorPairs().map(t=>`${t.sensorId}\0${t.bodyId}`));if(0===o.size&&0===e.size)return o;const r=new Map(t.readState().map(t=>[t.id,t])),n=(t,e)=>{const{sensorId:o,bodyId:n}=ho(e),s=i.observation.sensors[o],a=r.get(n);i.emit({type:"enter"===t?s?.enterType??"physics-bin-enter":s?.exitType??"physics-bin-exit",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:n,datum:a?.datum,x:a?.x,y:a?.y,sensorId:o,binId:s?.binId??o})};for(const t of Array.from(o).sort())e.has(t)||n("enter",t);for(const t of Array.from(e).sort())o.has(t)||n("exit",t);return o}(this.world,this.activeSensorPairs,this.observationContext(t))}removeActiveSensorPairsForBodies(t){!function(t,e){for(const i of t)e.has(ho(i).bodyId)&&t.delete(i)}(this.activeSensorPairs,t)}observationContext(t){return{elapsedSeconds:this.elapsedSeconds,observation:this.observation,emit:e=>this.emitObservation(e,t)}}emitObservation(t,e){e?.push(t),this.observation.onObservation?.(t)}evaluateBodyBudget(){return function(t){const e=Math.max(0,Math.floor(t.liveBodies)),i=Math.max(0,Math.floor(t.queuedBodies??0)),o=e+i,r=Qi(t.bodyLimit),n=Qi(t.engineMaxBodiesHint),s=function(t,e,i){if(!1===i)return;const o=Qi(i?.warnAt);return null!=o?o:null!=t?Math.max(1,Math.floor(.8*t)):null!=e?Math.max(1,Math.floor(.8*e)):void 0}(r,n,t.options),a=null==r?0:Math.max(0,e-r),c=a>0?"overflow":null==s||s>o?"ok":"warning";return{action:"overflow"!==c?"continue":t.sedimentEnabled?"sediment":t.evictionEnabled?"evict":"retain",bodyLimit:r,engineMaxBodiesHint:n,liveBodies:e,overflow:a,projectedBodies:o,queuedBodies:i,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(t){const e=this.evaluateBodyBudget();if("ok"===e.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",e;const i=`${e.state}:${e.action}`;return i===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=i,this.emitObservation({type:"overflow"===e.state?"physics-budget-overflow":"physics-budget-warning",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,budgetAction:e.action,bodyLimit:e.bodyLimit,engineMaxBodiesHint:e.engineMaxBodiesHint,liveBodies:e.liveBodies,overflow:e.overflow,projectedBodies:e.projectedBodies,queuedBodies:e.queuedBodies,warnAt:e.warnAt},t)),e}syncSimulationState(t){const e=jo(this.paused,this.visible,this.queue.length>0,this.world.allSleeping());if(e===this.simulationState)return;const i=this.simulationState;this.simulationState=e,function(t,e,i){i.observation.onSimulationStateChange?.(e,t),"running"!==e&&"settled"!==e||i.emit({type:"running"===e?"sim-active":"sim-idle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,simulationState:e,previousSimulationState:t})}(i,e,this.observationContext(t))}evictOverflow(t){if(!1===this.config.eviction)return{evicted:[],sedimented:[]};const e=Math.max(0,Math.floor(this.config.bodyLimit));if(!Number.isFinite(e))return{evicted:[],sedimented:[]};const i=this.liveBodyOrder.length-e;if(0>=i)return{evicted:[],sedimented:[]};const o=("sleeping-first"===this.config.eviction?this.sleepingFirstEvictionOrder():this.liveBodyOrder.slice()).slice(0,i);if(0===o.length)return{evicted:[],sedimented:[]};const r=this.absorbSediment(o,t);this.world.remove(o);const n=new Set(o);return this.liveBodyOrder=this.liveBodyOrder.filter(t=>!n.has(t)),this.removeActiveSensorPairsForBodies(n),{evicted:o,sedimented:r}}absorbSediment(t,e){const i=new Map(this.world.readState().map(t=>[t.id,t])),o=[];for(const r of t){const t=i.get(r);if(!t)continue;const n=this.sediment.add(t);n&&(o.push(r),this.emitObservation({type:"physics-sediment",timestamp:this.elapsedSeconds,chartType:this.observation.chartType,chartId:this.observation.chartId,bodyId:r,datum:t.datum,x:t.x,y:t.y,binId:n.id,count:n.count,total:n.total},e))}return o}sleepingFirstEvictionOrder(){const t=new Map(this.world.readState().map(t=>[t.id,t.sleeping])),e=[],i=[];for(const o of this.liveBodyOrder)t.get(o)?e.push(o):i.push(o);return[...e,...i]}};var Eo=require("d3-scale");function Do(t){const{count:e,idPrefix:i,wallThickness:o,xScale:r,yBottom:n,yTop:s,yTopForIndex:a}=t;return Array.from({length:e+1},(t,e)=>{const c=Math.min(n-1,a?.(e)??s),l=Math.max(1,n-c);return{id:`${i}-wall-${e}`,shape:{type:"aabb",x:r(e),y:c+l/2,width:o,height:l}}})}var Fo=require("d3-scale");function Oo(t){if(Array.isArray(t)&&t.length>=2){const e=di(t[0]),i=di(t[1]);return null!=e&&null!=i?{x:e,y:i}:null}if(t&&"object"==typeof t){const e=t,i=di(e.x),o=di(e.y);return null!=i&&null!=o?{x:i,y:o}:null}return null}function No(t){return Array.isArray(t)?t.map(Oo).filter(t=>null!=t):[]}function Bo(t,e,i){return"normalized"===i?{x:e.plot.x+t.x*e.plot.width,y:e.plot.y+t.y*e.plot.height}:{x:fi(t.x,e.plot.x,e.plot.x+e.plot.width),y:fi(t.y,e.plot.y,e.plot.y+e.plot.height)}}function Io(t){let e=0;for(let i=1;t.length>i;i+=1)e+=Math.hypot(t[i].x-t[i-1].x,t[i].y-t[i-1].y);return e}function Wo(t,e){if(0===t.length)return{x:0,y:0};if(1===t.length)return{...t[0]};const i=fi(e,0,1)*Io(t);let o=0;for(let e=1;t.length>e;e+=1){const r=t[e-1],n=t[e],s=Math.hypot(n.x-r.x,n.y-r.y);if(s>0){if(o+s>=i){const t=(i-o)/s;return{x:r.x+(n.x-r.x)*t,y:r.y+(n.y-r.y)*t}}o+=s}}return{...t[t.length-1]}}function Yo(t,e){const i=Wo(t,Math.max(0,e-.02)),o=Wo(t,Math.min(1,e+.02)),r=o.x-i.x,n=o.y-i.y,s=Math.hypot(r,n)||1;return{x:r/s,y:n/s}}function qo(t,e,i){return Math.max(e,Math.min(i,t))}function Xo(t,e,i,o,r,n={}){return{id:t,friction:n.friction,restitution:n.restitution,bodyFilter:n.bodyFilter,shape:{type:"segment",x1:e,y1:i,x2:o,y2:r,thickness:n.thickness??8}}}function Go(t){return{id:t.id,label:t.label,description:t.description,kind:t.kind,shape:(e=t.x,i=t.y,o=t.width,r=t.height,{type:"aabb",x:e,y:i,width:o,height:r}),bodyFilter:t.bodyFilter,collider:t.collider,colliderThickness:t.colliderThickness,friction:t.friction,restitution:t.restitution,semanticItem:t.semanticItem,metadata:t.metadata,bodyStyle:t.bodyStyle,attributes:t.attributes,onEnter:t.onEnter,onExit:t.onExit};var e,i,o,r}function Vo(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:12,y:0};return{...Go({...t,kind:t.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.015}}function Ho(t,e=12){return"number"==typeof t?{x:t,y:0}:t&&"object"==typeof t?{x:Number.isFinite(t.x)?Number(t.x):e,y:Number.isFinite(t.y)?Number(t.y):0}:{x:e,y:0}}function Zo(t){const e=t.stages;if(!e.length)throw Error("buildProcessFlowPhysics requires at least one stage");const i=t.size,o=ai(i),r=fi(t.ballRadius??6,2,18),n=t.seed??1,s=gi(n),a=t.idAccessor,c=t.stageAccessor??"stage",l=t.groupBy,u=t.groupLabelAccessor,h=t.workAccessor,d=t.radiusAccessor,f=t.groupCompletion??(l?"allAbsorbed":"none"),p=t.springStiffness??.28,y=t.springDamping??.72,g=!0===t.settle,m=e.map(t=>({id:t.id,label:t.label??t.id,description:t.description,share:t.share})),x=function(t){const e=t.shape??"lane",i=Math.max(1,Math.round(t.width)),o=Math.max(1,Math.round(t.height)),r=t.padX??46,n=t.padY??72,s=r,a=i-r,c=n,l=o-Math.max(24,Math.round(.45*n)),u=(c+l)/2,h=Math.max(1,l-c),d=qo(t.pinchRatio??.18,.06,.5),f=Number(t.pinchHeightOffset??0),p=Number.isFinite(f)?f:0,y=qo(h*d+p,.06*h,.5*h),g=y/2,m=u-g,x=u+g,b=t.idPrefix??"process",v=t.friction??.58,w=t.restitution??.18,k=t.wallThickness??8,S=t.stages;if(!S.length)throw Error("processStageLayout requires at least one stage");const A=qo(t.centerStageIndex??Math.floor(S.length/2),0,S.length-1),M=function(t){const e=t.reduce((t,e)=>t+(e.share??1),0);return e>0?e:t.length}(S),_=a-s;let P=s;const L=S.map((t,e)=>{const i=P,o=e===S.length-1?a:P+(t.share??1)/M*_;return P=o,{id:t.id,label:t.label,description:t.description,kind:t.kind??"stage",index:e,x0:i,x1:o,x:(i+o)/2,width:o-i,y:u,height:h}}),R=L[A],T=R.x0,C=R.x1,$=(t,i)=>{if("lane"===e)return"top"===i?c:l;if("funnel"===e){const e=qo((t-s)/Math.max(1,a-s),0,1);return"top"===i?c+(m-c)*e:l+(x-l)*e}if(T>=t){const e=qo((t-s)/Math.max(1,T-s),0,1);return"top"===i?c+(m-c)*e:l+(x-l)*e}if(C>=t)return"top"===i?m:x;const o=qo((t-C)/Math.max(1,a-C),0,1);return"top"===i?m+(c-m)*o:x+(l-x)*o},j=L.map(t=>{const e=Math.min($(t.x0,"top"),$(t.x1,"top")),i=Math.max($(t.x0,"bottom"),$(t.x1,"bottom"));return{...t,y:(e+i)/2,height:Math.max(1,i-e)}}),z={thickness:k,friction:v,restitution:w},E=[];"lane"===e?E.push(Xo(b+"-top",s,c,a,c,z),Xo(b+"-bottom",s,l,a,l,z),Xo(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,k-2)}),Xo(b+"-right",a,c,a,l,{...z,thickness:Math.max(6,k)})):"funnel"===e?E.push(Xo(b+"-top",s,c,a,m,z),Xo(b+"-bottom",s,l,a,x,z),Xo(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,k-2)}),Xo(b+"-right",a,m,a,x,{...z,thickness:Math.max(6,k)})):E.push(Xo(b+"-left-top",s,c,T,m,z),Xo(b+"-left-bottom",s,l,T,x,z),Xo(b+"-center-top",T,m,C,m,z),Xo(b+"-center-bottom",T,x,C,x,z),Xo(b+"-right-top",C,m,a,c,z),Xo(b+"-right-bottom",C,x,a,l,z),Xo(b+"-left",s,c,s,l,{...z,thickness:Math.max(6,k-2)}),Xo(b+"-right",a,c,a,l,{...z,thickness:Math.max(6,k)}));const D=t.membraneDampingScale??.5,F=s,O=Math.max(1,("bowtie"===e?T:a)-F),N=(t.membranes??[]).map(t=>{const e=F+qo(t.offset,0,1)*O,i=t.width??18+18*t.cost,o=h-16,r=u+.25*(t.wobble??0);return{...t,x:e,y:r,width:i,height:o}}),B=!1===t.includeMembraneRegions?[]:N.map(t=>function(t){const e=t.dampingScale??.5,i=t.energyScale??1,o=qo(t.cost,0,2);return{...Go({...t,kind:t.kind??"membrane",attributes:{primitive:"membrane",membraneCost:o,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:o*e,energyDelta:-o*i}}({id:t.id,label:t.label??t.id,description:t.description??(t.label??t.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:t.x,y:t.y,width:t.width,height:t.height,cost:t.cost,dampingScale:t.dampingScale??D,bodyStyle:t.bodyStyle,metadata:t.metadata,semanticItem:t.semanticItem,color:t.color}));return{shape:e,width:i,height:o,padX:r,padY:n,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:T,centerRight:C,pinchHeight:y,pinchTop:m,pinchBottom:x,stages:j,membranes:N,colliders:E,regionEffects:B,boundaryY:$}}({width:i[0],height:i[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((t,e)=>[t.id,e])),v=new Map(x.stages.map(t=>[t.id,t])),w=x.stages[0].id,k=x.stages[0],S=new Set(e.filter(t=>t.absorb).map(t=>t.id)),A=e.map(t=>{const e=v.get(t.id)??k;return function(t,e){const i={id:"process-stage-"+t.id,label:t.label??t.id,description:t.description,x:e.x,y:e.y,width:Math.max(12,.92*e.width),height:Math.max(40,.88*e.height),semanticItem:!1,attributes:{stageId:t.id}};if(t.absorb)return function(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force??{x:24,y:0};return{...Go({...t,kind:t.kind??"sink",attributes:{primitive:"absorb",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping??.02,charge:t.charge??"absorbed"}}({...i,kind:t.kind??"sink",force:Ho(t.force,28),damping:t.damping??.04,charge:"absorbed",attributes:{...i.attributes,primitive:"absorb"}});if(t.portal){const e=t.portal.force??t.force??{x:-40,y:0};return o={...i,kind:t.kind??"force-field",force:Ho(e,-40),damping:t.damping??.1,targetStage:t.portal.targetStageId,attributes:{...i.attributes,primitive:"portal",targetStage:t.portal.targetStageId}},{...Go({...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(t.capacity){const e=Math.max(.1,t.capacity.unitsPerSecond);return function(t){const e="number"==typeof t.force?{x:t.force,y:0}:t.force;return{...Go({...t,kind:t.kind??"force-field",attributes:{primitive:"capacitatedSensor",capacity:t.capacity,unitsPerSecond:t.unitsPerSecond??t.capacity,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:e,damping:t.damping,charge:t.charge??t.capacity}}({...i,kind:t.kind??"force-field",capacity:e,unitsPerSecond:e,force:Ho(t.force,10+.8*e),damping:t.damping??Math.max(.04,.32-.01*e),attributes:{...i.attributes,unitAccessor:t.capacity.unitAccessor,reviewerCapacity:e}})}if(t.pressure){const e="object"==typeof t.pressure&&t.pressure?t.pressure:{};return function(t){const e=t.pressure??t.occupancy??0,i=t.baseDamping??.08,o=t.dampingPerUnit??.12,r=t.energyPerUnit??0;return{...Go({...t,kind:t.kind??"membrane",attributes:{primitive:"pressureField",pressure:e,..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),damping:i+e*o,energyDelta:r?-e*r:void 0,force:t.force}}({...i,kind:t.kind??"membrane",pressure:e.pressure,occupancy:e.occupancy,baseDamping:e.baseDamping??t.damping??.1,dampingPerUnit:e.dampingPerUnit??.1,energyPerUnit:e.energyPerUnit??0,force:Ho(t.force,8),attributes:{...i.attributes,primitive:"pressureField"}})}return null!=t.force||null!=t.damping?Vo({...i,kind:t.kind??"force-field",force:Ho(t.force,14),damping:t.damping??.02,attributes:{...i.attributes,primitive:"routeSurface"}}):function(t){return{...Go({...t,kind:t.kind??"force-field",attributes:{primitive:"forceField",..."object"==typeof t.attributes&&t.attributes?t.attributes:{}}}),force:t.force,damping:t.damping,energyDelta:t.energyDelta}}({...i,kind:t.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...i.attributes,primitive:"forceField"}})}(t,{x:e.x,y:x.midY,width:e.width,height:x.bottomY-x.topY})});A.unshift(Vo({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 t of x.stages)M.set(t.id,0);const _=[];t.data.forEach((t,e)=>{const i=(a?hi(t,e,a)??t.id??"process-flow-"+e:t.id??"process-flow-"+e)+"",o=(hi(t,e,c)??w)+"",n=b.has(o)?o:w;M.set(n,(M.get(n)??0)+1);const s=l?(hi(t,e,l)??"")+"":void 0,f=s&&u?(hi(t,e,u)??s)+"":s,p=h?di(hi(t,e,h))??1:1,y=d?di(hi(t,e,d)):null,g=fi(null!=y&&y>0?y:r,2,18);_.push({datum:t,id:i,stageId:n,groupId:s||void 0,groupLabel:f||void 0,work:p,radius:g,index:e})});const P=new Map,L=new Map;for(const t of _){if(!t.groupId)continue;const e=P.get(t.groupId)??[];e.push(t.id),P.set(t.groupId,e),t.groupLabel&&L.set(t.groupId,t.groupLabel)}const R=fi(t.groupAnchorAlong??.55,.15,.9),T=x.left+(x.right-x.left)*R,C=Array.from(P.keys()),$=C.map((t,i)=>{const o=P.get(t)??[],r=C.length>1?x.topY+28+i/Math.max(1,C.length-1)*(x.bottomY-x.topY-56):x.midY;return function(t){const e=t.x??t.anchor?.x??0,i=t.y??t.anchor?.y??0;return{id:t.id,label:t.label,description:t.description,group:t.group,bodyIds:t.bodyIds,datum:t.datum,state:t.state,x:e,y:i,width:t.width,height:t.height,anchor:t.anchor??{x:e,y:i},completion:t.completion,tether:t.tether,semanticItem:t.semanticItem}}({id:t,label:L.get(t)??t,bodyIds:o,anchor:{x:T,y:r},x:T,y:r,completion:"allAbsorbed"===f?{mode:"allMembersAbsorbed",targetZone:e.find(t=>t.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),j=function(t,e){const i=e instanceof Set?e:new Set(e);return t.map(t=>{const e=t.bodyIds??[],o=e.filter(t=>!i.has(t)),r=e.length-o.length,n=t.completion?.mode??"allMembersAbsorbed",s=t.completion?.valueByBodyId,a=t=>{const e=s?.[t];return Number.isFinite(e)&&Number(e)>=0?Number(e):1},c=e.reduce((t,e)=>t+a(e),0),l=e.reduce((t,e)=>t+(i.has(e)?a(e):0),0),u=t.completion?.threshold,h="threshold"===n?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0;return{id:t.id,label:t.label??t.id,mode:n,complete:e.length>0&&("anyAbsorbed"===n?r>0:"threshold"===n?l>=(h??c):0===o.length),absorbed:r,total:e.length,absorbedValue:l,totalValue:c,threshold:h,missing:o}})}($,_.filter(t=>S.has(t.stageId)).map(t=>t.id)),z=new Map($.map(t=>[t.id,t])),E=_.map((t,e)=>{const i=v.get(t.stageId)??k,o=i.x+(s()-.5)*Math.min(24,.2*i.width),r=x.boundaryY(o,"top")+t.radius+10,n=x.boundaryY(o,"bottom")-t.radius-10,a=n>r?r+s()*Math.max(1,n-r):x.midY,c=g?o:x.left+18+e%7*4,l=g?a:x.midY+(s()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:o,y:a},restLength:.45*t.radius,stiffness:p,damping:y}];if(t.groupId){const e=z.get(t.groupId);e?.anchor&&!S.has(t.stageId)&&u.push({target:{type:"point",x:e.anchor.x,y:e.anchor.y},restLength:e.tether?.restLength??22,stiffness:e.tether?.stiffness??.05,damping:.8})}return{id:t.id,x:c,y:l,vx:g?0:40+40*s(),vy:g?0:20*(s()-.5),mass:1,shape:{type:"circle",radius:t.radius},spawnAt:g?0:.03*e,springs:u,datum:{...t.datum,id:t.id,stage:t.stageId,groupId:t.groupId,groupLabel:t.groupLabel,work:t.work,__processFlow:!0}}}),D={kernel:{seed:n,gravity:{x:t.gravityX??22,y:t.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:x.colliders,fixedDt:1/60,maxSubsteps:8},F=x.stages.map(t=>({label:t.label??t.id,value:M.get(t.id)??0})),O=e.map(t=>{const e=v.get(t.id)??k;return{id:t.id,label:t.label??t.id,x:e.x,width:e.width,count:M.get(t.id)??0,capacity:t.capacity?.unitsPerSecond,absorb:!0===t.absorb,portalTarget:t.portal?.targetStageId}});return{config:D,initialSpawns:E,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:F,metadata:{kind:"process-flow",plot:o.plot,volume:x,stages:O,groups:$,groupCompletion:j,regionEffects:A}}}var Uo=require("d3-scale");function Ko(t,e,i){return Z(t,e,i)}function Qo(t,e){const i=e&&"object"==typeof e&&!Array.isArray(e)?e:void 0;return 0===t.length?t=>i&&J(i,t)||"#4e79a7":e=>{if(i){const t=J(i,e);if(t)return t}let o=0;for(let t=0;e.length>t;t++)o=31*o+e.charCodeAt(t)|0;return t[Math.abs(o)%t.length]??"#4e79a7"}}function Jo(t,e){const i=e.config??{},o=(e.sensors??[]).map(t=>({...t,sensor:!0})),r=[...e.colliders??[],...o],n=[...t.colliders??[],...i.colliders??[],...r];return{...t,...i,observation:{...t.observation,...i.observation},...n.length>0&&{colliders:n}}}function tr(t){return[{id:"gauntlet-left",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:28,y2:t.floorY,thickness:8}},{id:"gauntlet-ceiling",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:76,x2:t.width-30,y2:76,thickness:8}},{id:"gauntlet-floor",restitution:.12,friction:.42,shape:{type:"segment",x1:28,y1:t.floorY,x2:t.width-30,y2:t.floorY,thickness:8}},{id:"gauntlet-right",restitution:.12,friction:.42,shape:{type:"segment",x1:t.width-30,y1:76,x2:t.width-30,y2:t.floorY,thickness:8}}]}function er(t,e,i,o){return i?"function"==typeof i?i(t,e):t[i]??o:o}function ir(t){return`gauntlet:${t}:core`}function or(t,e){return`gauntlet:${t}:positive:${e}`}function rr(t,e,i){return`gauntlet:${t}:negative:${e}:${i}`}function nr(t,e,i,o){const r=Math.max(2,i+2),n=80+r,s=o.floorY-r;return{x:Math.max(32+r,Math.min(o.width-30-4-r,t)),y:Math.max(n,Math.min(s,e))}}function sr(t,e){const i=[...t].sort((t,e)=>t.localeCompare(e)),o=Math.max(0,i.indexOf(e));return{angle:.82*-Math.PI+(i.length>1?o/(i.length-1):.5)*Math.PI*.64,index:o,radius:48+o%2*6}}function ar(t,e,i){const o=t.activePositiveIds.reduce((t,i)=>t+(e.get(i)?.value??1),0),r=t.missingPositiveIds.length+t.poppedPositiveIds.length,n=t.negativeIds.reduce((t,e)=>t+(i.get(e)?.load??1),0);return Math.max(0,Math.min(100,75+3*o-8*n-1.2*t.delay-5*r))}function cr(t){const e=function(t,e,i){const[o,r]=t,n=Math.round(.48*r),s=r-36,a=(e??[]).filter(t=>!1!==t.enabled),c=Math.max(1,a.length),l=.22*o,u=c>1?(.78*o-l)/(c-1):0,h=Math.max(Math.round(.14*o),110);return{crashY:s-i,floorY:s,gates:a.map((t,e)=>({...t,id:t.id,x:t.x??Math.round(l+e*u),width:t.width??Math.max(54,Math.round(.07*o))})),graveyardX:Math.round(.84*o),graveyardY:s-4,height:r,routeY:n,socketX:Math.round(.92*o),startX:h,width:o}}(t.size??[900,520],t.gates,t.crashOffset??30),i=t.positiveProperties??[],o=new Map(i.map(t=>[t.id,t])),r=new Map((t.negativeProperties??[]).map(t=>[t.id,t])),n={idAccessor:t.idAccessor,initialViability:t.initialViability,metricsAccessor:t.metricsAccessor,negativeAccessor:t.negativeAccessor,positiveAccessor:t.positiveAccessor,startTimeAccessor:t.startTimeAccessor},s=(t.data??[]).map((e,s)=>{const a=function(t,e,i,o,r){const n=er(t,e,i.idAccessor,null!=t.id?t.id+"":"project-"+e)+"",s=o.map(t=>t.id),a=[...er(t,e,i.positiveAccessor,s)],c=[...er(t,e,i.negativeAccessor,[])].filter(t=>r.has(t));return{id:n,activePositiveIds:a,datum:t,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...er(t,e,i.metricsAccessor,{})},missingPositiveIds:s.filter(t=>!a.includes(t)),negativeIds:c,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(er(t,e,i.startTimeAccessor,0))||0),stage:"project filed",viability:er(t,e,i.initialViability,100)}}(e,s,n,i,r);return{...a,viability:t.viability?.(a,{negativeProperties:r,positiveProperties:o})??ar(a,o,r)}}),a=s.flatMap((i,n)=>{const s=function(t,e,i,o){const r=function(t){return{graveyardX:t.graveyardX,graveyardY:t.graveyardY,routeY:t.routeY,socketX:t.socketX,socketY:t.routeY-4,startX:t.startX,startY:t.routeY}}(i),n=o?.(t,e,i)??{};return{...r,...n,startY:n.startY??n.routeY??r.startY,socketY:n.socketY??n.routeY??r.socketY,graveyardY:n.graveyardY??r.graveyardY}}(i,n,e,t.projectPlacement);return function(t,e,i,o,r,n,s){const a=o.startX,c=o.startY+(o.startY===i.routeY?38*e:0),l=s?.(t,e,i,o)??{},u={__gauntlet:!0,kind:"gauntlet-core",projectId:t.id,sourceDatum:t.datum},h=[{...l,id:ir(t.id),x:l.x??a,y:l.y??c,vx:l.vx??42,vy:l.vy??0,mass:l.mass??7,bodyCollisions:l.bodyCollisions??!0,shape:l.shape??{type:"circle",radius:28},spawnAt:l.spawnAt??t.startedAt,datum:u}],d=nr(a,c,l.shape&&"radius"in l.shape&&Number(l.shape.radius)||28,i);h[0].x=d.x,h[0].y=d.y;for(const e of t.activePositiveIds){const o=r.get(e);if(!o)continue;const n=sr(t.activePositiveIds,e),s=o.radius??10,a=nr(d.x+Math.cos(n.angle)*n.radius,d.y+Math.sin(n.angle)*n.radius,s,i);h.push({id:or(t.id,e),x:a.x,y:a.y,vx:18*Math.cos(n.angle),vy:18*Math.sin(n.angle),mass:o.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:l.spawnAt??t.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:t.id,property:o,sourceDatum:t.datum},springs:!1===o.spring?[]:[{target:{type:"body",bodyId:ir(t.id)},stiffness:.56,damping:.9,restLength:52+n.index%2*4,...o.spring??{}}]})}return t.negativeIds.forEach((e,o)=>{const r=n.get(e);r&&h.push(function(t,e,i,o,r,n,s){const a=e.radius??7.2,c=nr(o-12+i%4*12,r+54+12*Math.floor(i/4),a,n);return{id:rr(t.id,e.id,i),x:c.x,y:c.y,vx:10,vy:6,mass:e.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:a},spawnAt:s,datum:{__gauntlet:!0,kind:"gauntlet-negative",projectId:t.id,property:e,sourceDatum:t.datum},springs:!1===e.spring?[]:[{target:{type:"body",bodyId:ir(t.id)},stiffness:.62,damping:.92,restLength:52+i%4*3,...e.spring??{}}]}}(t,r,o,d.x,d.y,i,l.spawnAt??t.startedAt))}),h}(i,n,e,s,o,r,t.coreBody)});return{layout:e,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:tr(e)}}}function lr(t){return t.map(t=>({...t,spawnAt:void 0}))}var ur={Sparkline:{frameType:"xy",layout:{mode:"sparkline"},buildProps:(t,e,i,o,r)=>({chartType:"line",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",groupAccessor:r.lineBy||e,colorAccessor:e,...o,showAxes:!1,margin:o.margin,showLegend:!1,showGrid:!1,title:void 0})},LineChart:Et,AreaChart:Ft,DifferenceChart:Ot,StackedAreaChart:Nt,Scatterplot:It,CandlestickChart:Bt,BubbleChart:zt,ConnectedScatterplot:Yt,QuadrantChart:Wt,Heatmap:{frameType:"xy",buildProps:(t,e,i,o,r)=>({chartType:"heatmap",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",valueAccessor:r.valueAccessor,colorScheme:i||r.colorScheme||"blues",showValues:r.showValues,heatmapValueFormat:r.valueFormat,cellBorderColor:r.cellBorderColor,...o})},TemporalHistogram:Dt,XYCustomChart:{frameType:"xy",buildProps:(t,e,i,o,r)=>({chartType:"custom",data:t,xAccessor:r.xAccessor||"x",yAccessor:r.yAccessor||"y",colorAccessor:e,colorScheme:i,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...o,showAxes:r.frameProps?.showAxes??r.showAxes??!1,showLegend:o.showLegend??!!e})},BarChart:xe,StackedBarChart:be,GroupedBarChart:ve,PieChart:we,DonutChart:ke,Histogram:Se,BoxPlot:Ae,ViolinPlot:Me,SwarmPlot:_e,DotPlot:Pe,SwimlaneChart:Le,RidgelinePlot:Re,LikertChart:Te,FunnelChart:Ce,GaugeChart:$e,OrdinalCustomChart:{frameType:"ordinal",buildProps:(t,e,i,o,r)=>({chartType:"custom",data:t,oAccessor:r.categoryAccessor||r.oAccessor||"category",rAccessor:r.valueAccessor||r.rAccessor||"value",projection:r.projection||"vertical",colorAccessor:e,colorScheme:i,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...o,showAxes:r.frameProps?.showAxes??r.showAxes??!1})},ForceDirectedGraph:Ue,NetworkCustomChart:{frameType:"network",layout:{margin:{top:40,right:40,bottom:40,left:40}},buildProps:(t,e,i,o,r)=>({chartType:"force",nodes:r.nodes||t||[],edges:r.edges||[],nodeIDAccessor:r.nodeIdAccessor||r.nodeIDAccessor||"id",sourceAccessor:r.sourceAccessor||"source",targetAccessor:r.targetAccessor||"target",valueAccessor:r.valueAccessor||"value",colorBy:e,colorScheme:i,customNetworkLayout:r.layout||r.customNetworkLayout,layoutConfig:r.layoutConfig,...o})},SankeyDiagram:Qe,ProcessSankey:Ke,ChordDiagram:{frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,i,o,r)=>({chartType:"chord",nodes:r.nodes,edges:r.edges,valueAccessor:r.valueAccessor,padAngle:r.padAngle,groupWidth:r.groupWidth,showLabels:r.showLabels,colorBy:e,edgeColorBy:r.edgeColorBy,colorScheme:i,...o})},TreeDiagram:Je,Treemap:{frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(t,e,i,o,r)=>({chartType:"treemap",data:t,childrenAccessor:r.childrenAccessor,hierarchySum:r.valueAccessor,colorBy:e,colorByDepth:r.colorByDepth,showLabels:r.showLabels,colorScheme:i,...o,nodeStyle:o.nodeStyle||r.nodeStyle||(()=>({stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8}))})},CirclePack:ti,ChoroplethMap:ri,ProportionalSymbolMap:ni,FlowMap:si,GeoCustomChart:{frameType:"geo",buildProps:(t,e,i,o,r)=>({points:r.points||t||[],areas:r.areas||[],lines:r.lines||[],projection:r.projection||"equirectangular",xAccessor:r.xAccessor||"lon",yAccessor:r.yAccessor||"lat",lineDataAccessor:r.lineDataAccessor,colorBy:e,colorScheme:i,customLayout:r.layout||r.customLayout,layoutConfig:r.layoutConfig,...o})},GaltonBoardChart:{frameType:"physics",buildProps:(t,e,i,o,r)=>{const n=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(t){const e=Math.max(2,Math.round(t.bins)),i=Math.max(1,Math.round(t.pegRows??e-1)),o=Math.max(1,Math.round(t.count??Math.max(64,4*e))),r=fi(Number.isFinite(t.branchProbability)?t.branchProbability??.5:.5,0,1),n=gi(t.seed??1),s=t.idPrefix??"mechanical";return Array.from({length:o},(t,e)=>{let o=0;for(let t=0;i>t;t+=1)n()<r&&(o+=1);const a=i/2;return{id:`${s}-${e}`,value:o,mechanical:!0,pegRows:i,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(t)?t:[],h=function(t){const{data:e,valueAccessor:i,bins:o,ballRadius:r,seed:n,size:s,valueExtent:a}=t,c=ai(s),l=e.map((t,e)=>di(hi(t,e,i))).filter(t=>null!=t),u=function(t){if(!t)return;const e=di(t[0]),i=di(t[1]);return null!=e&&null!=i?e>i?[i,e]:[e,i]:void 0}(a),h=u?.[0]??(l.length?Math.min(...l):0),d=u?.[1]??(l.length?Math.max(...l):1),f=d===h?1:d-h,p=(0,mi.scaleLinear)().domain([0,o]).range([c.plot.x,c.plot.x+c.plot.width]),y=Array.from({length:o},()=>0),g=[];e.forEach((t,e)=>{const n=di(hi(t,e,i));if(null==n)return;const s=Math.max(0,Math.min(o-1,Math.floor((n-h)/f*o)));y[s]+=1,g.push({id:(t.id??"galton-"+e)+"",x:p(s+.5),y:c.plot.y+r+2,vx:8*(e%5-2),vy:0,mass:1,shape:{type:"circle",radius:r},datum:{...t,value:n,bin:s}})});const m=c.plot.y+c.plot.height;return{config:ui(n,[...fo({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...po({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((t,e)=>({label:e+1+"",value:t})),metadata:{kind:"galton-board",bins:o,plot:c.plot,valueExtent:[h,d]}}}({data:u,valueAccessor:r.valueAccessor||"value",bins:s,ballRadius:r.ballRadius??4,seed:a,size:n,valueExtent:l?[0,c]:void 0});return{...o,config:h.config,initialSpawns:lr(h.initialSpawns),projectionRows:h.projectionRows,bodyStyle:li(e||r.colorBy||(l?"side":void 0),"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.valueAccessor||"value"})}}},EventDropChart:{frameType:"physics",buildProps:(t,e,i,o,r)=>{const n=o.size??[600,400],s=function(t){const{data:e,timeAccessor:i,arrivalAccessor:o,windows:r,watermark:n,ballRadius:s,seed:a,size:c,timeExtent:l,timeScale:u=1}=t,h=ai(c),d=e.map((t,e)=>di(hi(t,e,i))).filter(t=>null!=t),f=di(l?.[0]),p=di(l?.[1]),y=d.length?Math.min(...d):0,g=d.length?Math.max(...d):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=d.length?Math.max(...d):0,k="function"==typeof n?n(w):di(n?.value)??w-(n?.delay??r.size),S=Math.max(0,Math.min(v,Array.from({length:v},(t,e)=>e).reduce((t,e)=>b+(e+1)*r.size>k?t:t+1,0))),A=function(t,e){const i=Math.max(5*e,Math.min(92,.13*t.plot.width));return{gutter:{x:t.plot.x,y:t.plot.y,width:i,height:t.plot.height},windowPlot:{x:t.plot.x+i,y:t.plot.y,width:Math.max(40,t.plot.width-i),height:t.plot.height},wallTop:t.plot.y+.48*t.plot.height}}(h,s),M=b+v*r.size,_=(0,Eo.scaleLinear)().domain([b,M]).range([A.windowPlot.x,A.windowPlot.x+A.windowPlot.width]),P=Array.from({length:v},()=>({value:0,secondary:0})),L=[];e.forEach((t,e)=>{const n=di(hi(t,e,i));if(null==n)return;const a=di(hi(t,e,o))??n,c=Math.max(0,Math.min(v-1,Math.floor((n-b)/r.size))),l=k>=b+(c+1)*r.size;P[c].value+=l?0:1,P[c].secondary+=l?1:0,L.push({id:(t.id??"event-"+e)+"",x:Math.max(A.windowPlot.x+s,Math.min(A.windowPlot.x+A.windowPlot.width-s,_(n))),y:h.plot.y+s+2,vx:8*(e%3-1),vy:0,mass:1,friction:.02,spawnAt:a,shape:{type:"circle",radius:s},datum:{...t,eventTime:n,arrivalTime:a,windowIndex:c,late:l}})});const R=h.plot.y+h.plot.height,T=function(t,e){const i=Math.max(0,Math.min(t.windowCount,t.closedWindowCount));if(!i)return[];const o=t.windowStart,r=t.windowStart+t.windowCount*t.windowSize,n=(0,Eo.scaleLinear)().domain([o,r]).range([t.windowPlot.x,t.windowPlot.x+t.windowPlot.width]),s=n(t.windowStart+i*t.windowSize),a=t.windowPlot.x,c=e+Math.max(18,Math.min(.3*t.windowPlot.height,s-a)),l=t=>s===a?e:c+(t-a)/(s-a)*(e-c),u=[];for(let e=0;i>e;e+=1){const i=t.windowStart+e*t.windowSize,o=i+t.windowSize,r=n(i),s=n(o);u.push({id:"eventdrop-lid-"+e,windowIndex:e,x1:r,y1:l(r),x2:s,y2:l(s)})}return u}({closedWindowCount:S,gutter:A.gutter,plot:h.plot,windowCount:v,windowPlot:A.windowPlot,windowSize:r.size,windowStart:b},h.plot.y+.28*h.plot.height);return{config:ui(a,[...fo({x:h.plot.x,y:h.plot.y,width:h.plot.width,height:h.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...Do({idPrefix:"eventdrop-window",count:v,xScale:t=>_(b+t*r.size),yTop:A.wallTop,yTopForIndex:t=>{const e=(t=>{if(0>t||t>S)return null;const e=0===t?T[0]?.y1:T[t-1]?.y2??T[t]?.y1;return"number"==typeof e&&Number.isFinite(e)?e:null})(t);return null==e?A.wallTop:e+1.25*s},yBottom:R,wallThickness:6}),...T.map(t=>({id:t.id,shape:{type:"segment",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,thickness:Math.max(4,.42*s)},friction:.02,restitution:.01}))],"EventDropChart",{friction:.08}),initialSpawns:L,initialSpawnPacing:{pacing:"arrival",timeAccessor:t=>t.datum?.arrivalTime,timeScale:u},projectionRows:P.map((t,e)=>({label:`${b+e*r.size}-${b+(e+1)*r.size}`,value:t.value,secondary:t.secondary})),metadata:{kind:"event-drop",closedWindowCount:S,gutter:A.gutter,lidSegments:T,lateCount:P.reduce((t,e)=>t+e.secondary,0),plot:h.plot,windowPlot:A.windowPlot,watermarkValue:k,windowCount:v,windowSize:r.size,windowStart:b}}}({data:Array.isArray(t)?t:[],timeAccessor:r.timeAccessor||"time",arrivalAccessor:r.arrivalAccessor||"arrivalTime",windows:r.windows||{size:10},watermark:r.watermark,ballRadius:r.ballRadius??5,seed:r.seed??1,size:n,timeExtent:r.timeExtent,timeScale:r.timeScale??1});return{...o,config:s.config,initialSpawns:lr(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:li(e||r.colorBy,"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.valueAccessor||r.timeAccessor||"time"})}}},PhysicsPileChart:{frameType:"physics",buildProps:(t,e,i,o,r)=>{const n=o.size??[600,400],s="mechanical"===r.mode,a=function(t){const{data:e,categoryAccessor:i,valueAccessor:o,unitValue:r,ballRadius:n,seed:s,size:a}=t,c=pi(r,1),l=ai(a),u=[],h=new Map,d=new Map,f=[];function p(t){let e=h.get(t);return null==e&&(e=u.length,u.push(t),h.set(t,e)),e}e.forEach((t,e)=>{p((hi(t,e,i)??"unknown")+"")});const y=Math.max(1,u.length),g=function(t,e,i){const o=t.width/Math.max(1,e),r=Math.max(2,2*i),n=Math.min(.7*o,Math.max(3.2*r,r+8)),s=Math.max(1,Math.floor(n/r));return{laneWidth:o,tubeWidth:n,ballDiameter:r,perRow:s,centerX:e=>t.x+(e+.5)*o,pileHeight:t=>Math.ceil(Math.max(0,t)/s)*r}}(l.plot,y,n),m=Math.max(0,g.tubeWidth/2-n-1),x=u.map(()=>[]);e.forEach((t,e)=>{const r=(hi(t,e,i)??"unknown")+"",s=p(r),a=o?di(hi(t,e,o)):1,u=Math.max(0,Math.round((a??0)/c)),h=g.centerX(s);for(let i=0;u>i;i+=1){const o=d.get(r)??0,a=g.perRow>1?((g.perRow>1?o%g.perRow:0)/(g.perRow-1)*2-1)*m:0;d.set(r,o+1),x[s].push({id:`${(t.id??"pile-"+e)+""}-${i}`,x:h+a,y:l.plot.y+n+2,vx:(i%3-1)*n/2,vy:0,mass:1,shape:{type:"circle",radius:n},datum:{...t,category:r,unitIndex:i}})}});const b=x.reduce((t,e)=>Math.max(t,e.length),0);for(let t=0;b>t;t+=1)for(const e of x)e.length>t&&f.push(e[t]);const v=l.plot.y+l.plot.height,w=[...fo({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 t=0;y>t;t+=1){const e=g.centerX(t);for(const i of[-1,1])w.push({id:`pile-tube-${t}-${0>i?"l":"r"}`,shape:{type:"aabb",x:e+i*g.tubeWidth/2,y:(k+v)/2,width:6,height:v-k}})}return{config:ui(s,w,"PhysicsPileChart"),initialSpawns:f,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:u.map(t=>({label:t,value:d.get(t)??0}))}}({data:s?function(t={}){const e=(t.categories?.length?t.categories:["Intake","Review","Build","Ship"]).map(t=>(t+"").trim()).filter(Boolean),i=e.length?e:["Intake"],o=Math.max(i.length,Math.round(t.count??Math.max(48,12*i.length))),r=pi(t.unitValue,1),n=gi(t.seed??1),s=t.idPrefix??"mechanical-pile",a=i.map(()=>.65+.9*n()),c=a.reduce((t,e)=>t+e,0)||1,l=o-i.length,u=a.map(t=>t/c*l),h=u.map(t=>1+Math.floor(t));let d=o-h.reduce((t,e)=>t+e,0);const f=u.map((t,e)=>({index:e,fraction:t-Math.floor(t)})).sort((t,e)=>e.fraction-t.fraction);for(let t=0;d>0;t=(t+1)%f.length)h[f[t].index]+=1,d-=1;return i.map((t,e)=>({id:`${s}-${e}`,category:t,value:h[e]*r,mechanical:!0,unitCount:h[e],unitValue:r,share:h[e]/o}))}({categories:r.mechanicalCategories,count:r.mechanicalCount,seed:r.seed??1,unitValue:r.unitValue??1}):Array.isArray(t)?t:[],categoryAccessor:r.categoryAccessor||"category",valueAccessor:r.valueAccessor||(s?"value":void 0),unitValue:r.unitValue??1,ballRadius:r.ballRadius??5,seed:r.seed??1,size:n});return{...o,config:a.config,initialSpawns:lr(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:li(e||r.colorBy||(s?"category":void 0),"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.valueAccessor||"value"})}}},CollisionSwarmChart:{frameType:"physics",buildProps:(t,e,i,o,r)=>{const n=o.size??[600,360],s=function(t){const{data:e,xAccessor:i,groupAccessor:o,radiusAccessor:r,pointRadius:n,seed:s,size:a,xExtent:c,collisionIterations:l,settle:u}=t,h=ai(a),d=gi(s),f=[],p=[],y=new Map;e.forEach((t,e)=>{const s=di(hi(t,e,i));if(null==s)return;const a=o?(hi(t,e,o)??"All")+"":"All",c=r?di(hi(t,e,r)):null,l=fi(null!=c&&c>0?c:n,2,18);!function(t){let e=y.get(t);null==e&&(e=p.length,p.push(t),y.set(t,e))}(a),f.push({datum:t,index:e,value:s,group:a,radius:l})});const g=f.map(t=>t.value),m=c?di(c[0]):null,x=c?di(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 t=k;k=w,w=t}const S=Math.max(n,...f.map(t=>t.radius)),A=h.plot.x+S+8,M=h.plot.x+h.plot.width-S-8,_=(0,Fo.scaleLinear)().domain([w,k]).range([A,M]),P=Math.max(1,p.length),L=h.plot.y+Math.max(28,3*S),R=Math.max(0,h.plot.y+h.plot.height-Math.max(28,3*S)-L),T=t=>{const e=y.get(t)??0;return 1===P?h.plot.y+.54*h.plot.height:L+e/(P-1)*R},C=new Map,$=f.map((t,e)=>{C.set(t.group,(C.get(t.group)??0)+1);const i=_(t.value),o=T(t.group),r=(d()-.5)*t.radius*1.6,n=(d()-.5)*t.radius*1.6;return{id:(t.datum.id??"collision-swarm-"+e)+"",x:u?i+r:fi(i+(e%9-4)*t.radius*2.5,A,M),y:u?o+n:h.plot.y-18-e%12*t.radius,vx:u?0:22*(d()-.5),vy:u?0:24+18*d(),mass:1,shape:{type:"circle",radius:t.radius},datum:{...t.datum,xValue:t.value,group:t.group,radius:t.radius,targetX:i,targetY:o},springs:[{target:{type:"point",x:i,y:o},restLength:0,stiffness:34,damping:5.5}]}});return{config:ui(s,fo({x:h.plot.x,y:h.plot.y,width:h.plot.width,height:h.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:$,projectionRows:p.map(t=>({label:t,value:C.get(t)??0})),metadata:{kind:"collision-swarm",xExtent:[w,k],xRange:[A,M],groups:p.map(t=>({label:t,y:T(t),count:C.get(t)??0})),plot:h.plot}}}({data:Array.isArray(t)?t:[],xAccessor:r.xAccessor||"x",groupAccessor:r.groupAccessor,radiusAccessor:r.radiusAccessor,pointRadius:r.pointRadius??5,seed:r.seed??1,size:n,xExtent:r.xExtent,collisionIterations:r.collisionIterations,settle:r.settle});return{...o,config:s.config,initialSpawns:lr(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:li(e||r.colorBy||r.groupAccessor,"#4e79a7",{styleRules:r.styleRules,valueAccessor:r.xAccessor||"x"})}}},ProcessFlowChart:{frameType:"physics",buildProps:(t,e,i,o,r)=>{const n=o.size??[900,420],s=Array.isArray(r.stages)?r.stages:[],a=Zo({data:Array.isArray(t)?t:[],stages:s,size:n,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:lr(a.initialSpawns),projectionRows:a.projectionRows,regionEffects:c?.regionEffects,bodyStyle:li(e||r.colorBy||r.groupBy)}}},GauntletChart:{frameType:"physics",buildProps:(t,e,i,o,r)=>{const n=o.size??[900,520],s=cr({data:Array.isArray(t)?t:[],size:n,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:lr(s.initialSpawns),projectionRows:[],bodyStyle:li(e||r.colorBy)}}},PhysicalFlowChart:{frameType:"physics",buildProps:(t,e,i,o,r)=>{const n=o.size??[760,420],s=function(t){const{coordinateMode:e,flowSpeed:i,links:o,maxParticles:r,nodeIdAccessor:n,nodeXAccessor:s,nodeYAccessor:a,nodes:c,particleRadius:l,particleRate:u,pathAccessor:h,pathConstraint:d="path",reducedMotion:f,seed:p,size:y,sourceAccessor:g,targetAccessor:m,throughputAccessor:x}=t,b=ai(y),v=gi(p),w=new Map,k=new Map,S=[];function A(t){if(t&&"object"==typeof t){const e=t;if("function"==typeof n){const t=n(e,0);if(null!=t)return t+""}if("string"==typeof n&&null!=e[n])return e[n]+"";if(null!=e.id)return e.id+""}return(t??"unknown")+""}c.forEach((t,e)=>{const i=(hi(t,e,n)??t.id??e)+"",o=di(hi(t,e,s)),r=di(hi(t,e,a));if(null!=o&&null!=r){const t={x:o,y:r};w.set(i,t),S.push(t)}k.set(i,(t.label??t.name??i)+"")});const M=[];o.forEach((t,e)=>{const i=A(hi(t,e,g)),o=A(hi(t,e,m)),r=Math.max(0,di(hi(t,e,x))??0),n=No(h?hi(t,e,h):void 0),s=n.length?n:No(t.path??t.points??t.route);s.forEach(t=>S.push(t)),M.push({id:(t.id??`physical-flow-${i}-${o}-${e}`)+"",link:t,index:e,source:i,target:o,throughput:r,rawPath:s})});const _=(L=S,"normalized"===(P=e)||"pixels"===P?P:L.length>0&&L.every(t=>!(0>t.x||t.x>1||0>t.y||t.y>1))?"normalized":"pixels");var P,L;const R=new Map;for(const[t,e]of w)R.set(t,Bo(e,b,_));const T=[];for(const t of M){let e=t.rawPath.map(t=>Bo(t,b,_));if(2>e.length){const i=R.get(t.source),o=R.get(t.target);i&&o&&(e=[i,o])}else R.has(t.source)||R.set(t.source,e[0]),R.has(t.target)||R.set(t.target,e[e.length-1]);e.length>=2&&t.throughput>0&&(k.has(t.source)||k.set(t.source,t.source),k.has(t.target)||k.set(t.target,t.target),T.push({...t,path:e,packetCount:0}))}const C=pi(u,.12),$=Math.max(1,Math.round(r)),j=T.map(t=>Math.max(1,Math.round(t.throughput*C))),z=j.reduce((t,e)=>t+e,0),E=z>$?$/z:1;T.forEach((t,e)=>{t.packetCount=Math.max(1,Math.floor(j[e]*E))});let D=T.reduce((t,e)=>t+e.packetCount,0);for(;D>$;){const t=T.reduce((t,e,i)=>e.packetCount>1&&(-1===t||e.packetCount>T[t].packetCount)?i:t,-1);if(-1===t)break;T[t].packetCount-=1,D-=1}const F=new Map,O=new Map,N=[],B=pi(i,90),I=pi(l,4);T.forEach((t,e)=>{F.set(t.target,(F.get(t.target)??0)+t.throughput),O.set(t.source,(O.get(t.source)??0)+t.throughput);const i=Io(t.path);for(let o=0;t.packetCount>o;o+=1){const r=(o+.5)/t.packetCount,n=f?r:fi(.12+.84*r+.04*(v()-.5),.04,.98),s=f?n:Math.max(0,n-(.18+.12*v())),a=Wo(t.path,s),c=Wo(t.path,n),l=Yo(t.path,s),u={x:-l.y,y:l.x},h=(v()-.5)*I*1.5;N.push({id:`${t.id}-packet-${o}`,x:a.x+u.x*h,y:a.y+u.y*h,vx:f?0:l.x*B+10*(v()-.5),vy:f?0:l.y*B+10*(v()-.5),mass:.8,spawnAt:f?0:.04*e+o/32,shape:{type:"circle",radius:I},datum:{...t.link,source:t.source,target:t.target,throughput:t.throughput,packetIndex:o,packetCount:t.packetCount,routeProgress:n,flowPath:t.path,flowPathLength:i,flowRouteId:t.id,flowSpeed:B,sourceLabel:k.get(t.source)??t.source,targetLabel:k.get(t.target)??t.target},springs:"none"!==d&&f?[{target:{type:"point",x:c.x,y:c.y},restLength:.7*I,stiffness:26,damping:4.25}]:void 0})}});const W=Math.max(18,5*I),Y=Array.from(R,([t,e])=>({nodeId:t,label:k.get(t)??t,sensorId:"physical-flow-node-"+yi(t),point:e})),q=Y.map(t=>({id:t.sensorId,sensor:!0,shape:{type:"aabb",x:t.point.x,y:t.point.y,width:W,height:W}})),X=Object.fromEntries(Y.map(t=>[t.sensorId,{binId:t.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),G=ui(p,[...fo({x:b.plot.x,y:b.plot.y,width:b.plot.width,height:b.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...q],"PhysicalFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*I),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});G.bodyLimit=$,G.eviction="oldest",G.observation={...G.observation,sensors:X};const V=Array.from(R,([t,e])=>({id:t,label:k.get(t)??t,x:e.x,y:e.y,sensorId:"physical-flow-node-"+yi(t),incoming:F.get(t)??0,outgoing:O.get(t)??0})),H=T.map(t=>({id:t.id,source:t.source,target:t.target,sourceLabel:k.get(t.source)??t.source,targetLabel:k.get(t.target)??t.target,throughput:t.throughput,packetCount:t.packetCount,path:t.path}));return{config:G,initialSpawns:N,projectionRows:V.filter(t=>t.incoming>0||t.outgoing>0).map(t=>({label:t.label,value:t.incoming,secondary:t.outgoing})),metadata:{kind:"physical-flow",coordinateMode:_,particleCount:N.length,totalThroughput:T.reduce((t,e)=>t+e.throughput,0),plot:b.plot,nodes:V,links:H}}}({nodes:Array.isArray(r.nodes)?r.nodes:[],links:Array.isArray(r.links)?r.links:Array.isArray(r.edges)?r.edges:Array.isArray(t)?t:[],nodeIdAccessor:r.nodeIdAccessor||"id",nodeXAccessor:r.nodeXAccessor||"x",nodeYAccessor:r.nodeYAccessor||"y",sourceAccessor:r.sourceAccessor||"source",targetAccessor:r.targetAccessor||"target",throughputAccessor:r.throughputAccessor||"value",pathAccessor:r.pathAccessor||"path",coordinateMode:r.coordinateMode||"auto",particleRate:r.particleRate??.16,maxParticles:r.maxParticles??180,particleRadius:r.particleRadius??4,flowSpeed:r.flowSpeed??90,pathConstraint:r.pathConstraint||"path",reducedMotion:!0,seed:r.seed??1,size:n});return{...o,config:s.config,initialSpawns:lr(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:li(e||r.colorBy||"source")}}},PhysicsCustomChart:{frameType:"physics",buildProps:(t,e,i,o,r)=>{const n=o.size??[700,380],s=function(t){const e=function(t,e,i){const o=t?.observation;return{...t,observation:{...o,chartId:e??o?.chartId??"physics-custom",chartType:o?.chartType??"PhysicsCustomChart",onObservation:i??o?.onObservation}}}(t.config,t.chartId,t.onObservation),i=Ko(t.colorScheme,t.themeCategorical,A),o=ai(t.size),r={data:t.data,scales:{x:(0,Uo.scaleLinear)().domain(t.xExtent??[0,1]).range([o.plot.x,o.plot.x+o.plot.width]),y:(0,Uo.scaleLinear)().domain(t.yExtent??[0,1]).range([o.plot.y+o.plot.height,o.plot.y])},dimensions:o,theme:{semantic:t.semantic,categorical:[...i]},resolveColor:Qo(i,t.colorScheme),config:t.layoutConfig??{},world:new zo(e)},n=t.skipLayout?{}:t.layout(r)??{},s=function(t,e){if(!e?.length)return t;const i=new Map;for(const t of e){const{bodyId:e,...o}=t,r=i.get(e)??[];r.push(o),i.set(e,r)}return t.map(t=>{const e=i.get(t.id);return e?.length?{...t,springs:[...t.springs??[],...e]}:t})}([...n.initialSpawns??n.bodies??[]],n.constraints);return{config:Jo(e,n),context:r,initialSpawnPacing:n.initialSpawnPacing,initialSpawns:s,result:n}}({chartId:r.chartId,colorScheme:i,config:r.config,data:Array.isArray(t)?t:[],layout:r.layout,layoutConfig:r.layoutConfig,semantic:mt(vt)??{},size:n,themeCategorical:vt.colors.categorical,xExtent:r.xExtent,yExtent:r.yExtent});return{...o,config:s.config,initialSpawns:lr(s.initialSpawns),projectionRows:[],bodyStyle:s.result.bodyStyle??li(e||r.colorBy)}}}};function hr(t){const e=t instanceof Date?t.getTime():"number"==typeof t?t:Number(t);return Number.isFinite(e)?e:null}function dr(t){if(!t||2>t.length)return;const e=hr(t[0]),i=hr(t[t.length-1]);return null!==e&&null!==i?[e,i]:void 0}function fr(t){const{count:e,byType:i}=function(t){const e={};for(const i of t){const t="string"==typeof i?.type&&i.type.length>0?i.type:"node";e[t]=(e[t]??0)+1}return{count:t.length,byType:e}}(t.marks),o=0===e,r=[...t.extraWarnings??[]];return o&&!r.includes("EMPTY_SCENE")&&r.push("EMPTY_SCENE"),{component:"",frameType:t.frameType,status:o?"empty":"ok",empty:o,markCount:e,markCountByType:i,width:t.width,height:t.height,...t.xDomain?{xDomain:t.xDomain}:{},...t.yDomain?{yDomain:t.yDomain}:{},...t.categories?{categories:t.categories}:{},...void 0!==t.nodeCount?{nodeCount:t.nodeCount}:{},...void 0!==t.edgeCount?{edgeCount:t.edgeCount}:{},...void 0!==t.legendItems?{legendItems:t.legendItems}:{},annotationCount:Array.isArray(t.annotations)?t.annotations.length:0,ariaLabel:"string"==typeof t.description&&t.description||"string"==typeof t.title&&t.title||`${t.frameType} chart, ${e} marks`,warnings:r}}var pr=c(require("react")),yr=c(require("react-dom/server")),gr=class{constructor(t){if(this._capacity=t,this.head=0,this._size=0,1>t)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(t)}push(t){let e;return this._size===this._capacity?e=this.buffer[this.head]:this._size++,this.buffer[this.head]=t,this.head=(this.head+1)%this._capacity,e}pushMany(t){const e=[];for(const i of t){const t=this.push(i);void 0!==t&&e.push(t)}return e}get(t){if(t>=0&&this._size>t)return this.buffer[(this.head-this._size+t+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let t=0;return{next:()=>this._size>t?{done:!1,value:this.get(t++)}:{done:!0,value:void 0}}}forEach(t){const e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t(this.buffer[(e+i)%this._capacity],i)}toArray(){const t=Array(this._size),e=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)t[i]=this.buffer[(e+i)%this._capacity];return t}resize(t){if(1>t)throw Error("RingBuffer capacity must be at least 1");const e=this.toArray();let i=0,o=[];e.length>t&&(i=e.length-t,o=e.slice(0,i)),this._capacity=t,this.buffer=Array(t),this.head=0,this._size=0;for(let t=i;e.length>t;t++)this.push(e[t]);return o}update(t,e){const i=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let r=0;this._size>r;r++){const n=(o+r)%this._capacity,s=this.buffer[n];if(t(s)){let t;t="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:{...s},i.push(t),this.buffer[n]=e(s)}}return i}remove(t){const e=[],i=[];if(this.forEach(o=>{t(o)?i.push(o):e.push(o)}),0===i.length)return i;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const t of e)this.push(t);return i}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}},mr=class{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(t){Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}evict(t){t!==this._min&&t!==this._max||(this._dirty=!0)}recalculate(t,e){this._min=1/0,this._max=-1/0;for(const i of t){const t=e?e(i):i;Number.isFinite(t)&&(this._min>t&&(this._min=t),t>this._max&&(this._max=t))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}};function xr(t,e){return t===e}function br(t,e){if("function"==typeof t)return e=>+t(e);const i=t||e;return t=>+t[i]}function vr(t,e){if("function"==typeof t)return t;const i=t||e;return t=>t[i]}function wr(t,e){return"function"==typeof t?t:t?e=>e[t]+"":e?t=>t[e]+"":void 0}var kr=/^\d{4}-\d{1,2}$/;function Sr(t){const e=t.trim();if(!e||!Number.isNaN(Number(e)))return NaN;const i=kr.test(e)?e+"-01":e;if(i===e&&10>e.length)return NaN;const o=Date.parse(i);return Number.isFinite(o)?o:NaN}function Ar(t){return t instanceof Date?t.getTime():"string"==typeof t?Sr(t):+t}function Mr(t){return new Set(Array.isArray(t)?t:[t])}function _r(t,e="ease-out-cubic"){return"linear"===e?t:1-Math.pow(1-t,3)}function Pr(t,e){return Math.min((t-e.startTime)/e.duration,1)}function Lr(t,e,i){return t+(e-t)*i}function Rr(){return"undefined"!=typeof performance?performance.now():Date.now()}function Tr(t,e,i){if(1>=i)return 1;const o=i-1;return function(t){const e=Math.max(0,Math.min(1,t.minOpacity??.1));if(Number.isNaN(t.age))return 1;if(t.age===1/0)return e;if(!Number.isFinite(t.extent)||0>=t.extent)return 1;const i=Math.max(0,t.age);if("step"===t.type)return(t.threshold??.5*t.extent)>i?1:e;if("exponential"===t.type){const o=t.halfLife??t.extent/2;return e+Math.pow(.5,i/(o>0?o:t.extent/2))*(1-e)}return e+Math.max(0,Math.min(1,1-i/t.extent))*(1-e)}({age:o-e,extent:o,type:t.type,halfLife:t.halfLife??i/2,threshold:t.stepThreshold??.5*i,minOpacity:t.minOpacity??.1})}function Cr(t){const e=new Map;for(let i=0;t.length>i;i++)e.set(t[i],i);return e}function $r(t,e,i){const o=t.duration??500,r=i-e;return o>r?1-r/o:0}function jr(t,e,i,o){let r=!1;return e>0?(t._pulseIntensity!==e&&(t._pulseIntensity=e,r=!0),t._pulseColor!==i&&(t._pulseColor=i,r=!0),t._pulseGlowRadius!==o&&(t._pulseGlowRadius=o,r=!0),r):(0!==t._pulseIntensity&&(t._pulseIntensity=0,r=!0),void 0!==t._pulseColor&&(t._pulseColor=void 0,r=!0),void 0!==t._pulseGlowRadius&&(t._pulseGlowRadius=void 0,r=!0),r)}function zr(t,e,i=("undefined"!=typeof performance?performance.now():Date.now())){if(!e||0===e.size)return!1;const o=t.duration??500,r=e.peek();return null!=r&&o>i-r}function Er(t,e,i){if(e._transitionKey)return e._transitionKey;switch(e.type){case"point":if(e.pointId)return"p:"+e.pointId;if("streaming"===t.runtimeMode&&e.datum){const i=t.getX(e.datum),o=t.getY(e.datum);if(t.getCategory)return`p:${t.getCategory(e.datum)}:${i}:${o}`;if(null!=i&&null!=o)return`p:${i}:${o}`}return"p:"+i;case"glyph":return e.pointId?"g:"+e.pointId:"g:"+i;case"rect":return`r:${e.group||""}:${e.datum?.binStart??e.datum?.category??i}`;case"heatcell":return`h:${e.x}_${e.y}`;case"candlestick":return null==e.datum?"c:"+i:"c:"+t.getX(e.datum);case"line":return"l:"+(e.group||"_default");case"area":return"a:"+(e.group||"_default");default:return null}}function Dr(t,e,i,o,r,n){const s=[];for(const r of t){const t=i(r),n=o(r);Number.isFinite(t)&&Number.isFinite(n)&&s.push({px:e.x(t),py:e.y(n),rawY:n,d:r})}s.sort((t,e)=>t.px-e.px);const a=Array(s.length),c=Array(s.length),l=Array(s.length);for(let t=0;s.length>t;t++){const e=s[t];a[t]=[e.px,e.py],c[t]=e.rawY,l[t]=e.d}return{type:"line",path:a,rawValues:c,style:r,datum:l,group:n}}function Fr(t,e,i,o,r,n,s,a){const c=[];for(const n of t){const t=i(n),s=o(n);if(!Number.isFinite(t)||!Number.isFinite(s))continue;const l=e.x(t),u=a?a(n):r;c.push({px:l,topY:e.y(s),botY:e.y(u)})}c.sort((t,e)=>t.px-e.px);const l=Array(c.length),u=Array(c.length);for(let t=0;c.length>t;t++){const e=c[t];l[t]=[e.px,e.topY],u[t]=[e.px,e.botY]}return{type:"area",topPath:l,bottomPath:u,style:n,datum:t,group:s}}function Or(t,e,i,o){const r=new Map;if("silhouette"===o)for(const o of t){let t=0;for(const r of e)t+=i(r,o)||0;r.set(o,-t/2)}else if("wiggle"===o){t.length>0&&r.set(t[0],0);for(let o=1;t.length>o;o++){const n=t[o-1],s=t[o];let a=0,c=0,l=0;for(const t of e){const e=i(t,s)||0;a+=(2*l+e)*(e-(i(t,n)||0)),c+=e,l+=e}const u=r.get(n)??0;r.set(s,u-(c>0?a/(2*c):0))}if(t.length>0){let o=0;for(const n of t){let t=0;for(const o of e)t+=i(o,n)||0;o+=(r.get(n)??0)+t/2}const n=o/t.length;for(const e of t)r.set(e,(r.get(e)??0)-n)}}else for(const e of t)r.set(e,0);return r}function Nr(t,e,i,o,r,n,s){const a=i(t),c=o(t);if(!Number.isFinite(a)||!Number.isFinite(c))return null;const l={type:"point",x:e.x(a),y:e.y(c),r:r,style:n,datum:t};return void 0!==s&&(l.pointId=s),l}function Br(t,e,i,o,r,n,s,a){const c=i(t),l=o(t);if(!Number.isFinite(c)||!Number.isFinite(l))return null;const u={type:"symbol",x:e.x(c),y:e.y(l),size:r,symbolType:n,style:s,datum:t};return void 0!==a&&(u.pointId=a),u}function Ir(t,e,i,o,r,n,s){return{type:"rect",x:t,y:e,w:i,h:o,style:r,datum:n,group:s}}function Wr(t,e,i,o,r,n,s){const a={type:"heatcell",x:t,y:e,w:i,h:o,fill:r,datum:n};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function Yr(t,e,i,o){return"function"==typeof e.style?e.style(o||{},i):e.style&&"object"==typeof e.style?e.style:t.resolveBoundsStyle(i,o)}function qr(t,e,i,o){if(!t.scales)return null;const r=[],n=[];for(const i of e){const e=t.getX(i);if(!Number.isFinite(e))continue;const s=o.getTop(i),a=o.getBottom(i);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const c=t.scales.x(e),l=t.scales.y(s),u=t.scales.y(a);Number.isFinite(c)&&Number.isFinite(l)&&Number.isFinite(u)&&(r.push([c,l]),n.push([c,u]))}return 2>r.length?null:{type:"area",topPath:r,bottomPath:n,style:Yr(t,o,i,e[0]),datum:e,group:i,interactive:o.interactive}}function Xr(t){const e=[],i=[];if(!t)return{perSeries:e,aggregate:i};for(const o of t)o.perSeries?e.push(o):i.push(o);return{perSeries:e,aggregate:i}}function Gr(t,e,i){const o=[];for(const r of i){const i=qr(t,e,"__ribbon_aggregate",r);i&&o.push(i)}return o}function Vr(t,e,i,o){const r=[];for(const n of o){const o=qr(t,e,i,n);o&&r.push(o)}return r}function Hr(t,e,i,o){if(!t.config.pointStyle)return;const r=o??t.getY;for(const o of e){const e=t.resolveGroupColor(o.key);for(const n of o.data){let o=t.config.pointStyle(n);!o.fill&&e&&(o={...o,fill:e});const s=o.r??3,a=t.getPointId?t.getPointId(n)+"":void 0,c=Nr(n,t.scales,t.getX,r,s,o,a);c&&i.push(c)}}}function Zr(t){return"threshold"===t.type&&"string"==typeof t.color&&"number"==typeof t.value}var Ur={topOpacity:.8,bottomOpacity:.05};function Kr(t){if(t)return!0===t?Ur:"colorStops"in t?t:{topOpacity:t.topOpacity??Ur.topOpacity,bottomOpacity:t.bottomOpacity??Ur.bottomOpacity}}var Qr=require("d3-shape"),Jr={circle:Qr.symbolCircle,square:Qr.symbolSquare,triangle:Qr.symbolTriangle,diamond:Qr.symbolDiamond,star:Qr.symbolStar,cross:Qr.symbolCross,wye:Qr.symbolWye},tn=["circle","triangle","diamond","star","square","chevron","cross","wye"];function en(t,e,i){if(i)return i;const o=t??"circle";return"chevron"===o?function(t){const e=1.5*function(t){return Math.sqrt(Math.max(1,t)/Math.PI)}(t),i=.92*e;return`M0,${-e}L${i},${(.78*e).toFixed(3)}L0,${(.28*e).toFixed(3)}L${-i},${(.78*e).toFixed(3)}Z`}(e):(0,Qr.symbol)(Jr[o]??Qr.symbolCircle,Math.max(1,e))()??""}var on=new Map;function rn(t,e,i,o,r){const n=new Map;for(const s of t){const t=e(s),a=i(s);if(null==t||null==a||Number.isNaN(t)||Number.isNaN(a))continue;const c=Math.floor(t/o)*o;let l=n.get(c);if(l||(l={start:c,end:c+o,total:0,categories:new Map},n.set(c,l)),l.total+=a,r){const t=r(s);l.categories.set(t,(l.categories.get(t)||0)+a)}}return n}function nn(t){if("production"===process.env.NODE_ENV)return;const{label:e,nodes:i,overlays:o,warned:r}=t;sn(o)&&0===i.length&&an(r,"overlay-only",`[semiotic] ${e} returned overlays but no data-bearing scene nodes. Overlays do not participate in hover, selection, transitions, SSR evidence, or accessibility tables. Emit at least one scene node with a datum, or mark the overlay-only chart as intentionally decorative.`),i.length>0&&i.every(t=>null==t.datum)&&an(r,"null-datums",`[semiotic] ${e} returned scene nodes, but every scene-node datum is null. Hover, callbacks, selection, and tooltip helpers need data-bearing nodes. Attach a user-facing datum to each interactive node, or set interactive overlays outside the chart.`)}function sn(t){return null!=t&&!1!==t&&""!==t&&(!Array.isArray(t)||t.some(sn))}function an(t,e,i){t.has(e)||(t.add(e),console.warn(i))}function cn(t,e,i,o){const r=function(t){if(t instanceof Error)return{name:t.name||"Error",message:t.message||"Custom layout threw."};if("string"==typeof t)return{name:"Error",message:t};if(null==t)return{name:"Error",message:"Custom layout threw a nullish value."};try{return{name:"Error",message:t+""}}catch{return{name:"Error",message:"Custom layout threw a non-stringifiable value."}}}(e),n="network"===t?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:t,source:n,message:`Semiotic ${t} ${n} failed: ${r.message}`,error:r,recovery:i?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:i,affectedRevision:o}}function ln(t,e){const i="function"==typeof t?t:i=>i[t||e];return t=>{const e=i(t);return null==e?NaN:+e}}function un(t){const e=[],i=["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode,o=ln(i&&t.valueAccessor||t.yAccessor,i?"value":"y");if(t.boundsAccessor){const i=br(t.boundsAccessor,"bounds");e.push({kind:"bounds",getTop:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const r=i(t);return Number.isFinite(r)&&0!==r?e+r:e},getBottom:t=>{const e=o(t);if(!Number.isFinite(e))return NaN;const r=i(t);return Number.isFinite(r)&&0!==r?e-r:e},style:t.boundsStyle,perSeries:!0,interactive:!1})}if(t.band){const i=Array.isArray(t.band)?t.band:[t.band];for(const t of i)e.push({kind:"band",getTop:ln(t.y1Accessor,"y1"),getBottom:ln(t.y0Accessor,"y0"),style:t.style,perSeries:!1!==t.perSeries,interactive:!0===t.interactive})}return e}var hn=require("d3-scale");function dn(t,e){return e?[e[0]??t[0],e[1]??t[1]]:t}function fn(t,e,i){if("log"===t){const t=[Math.max(e[0],1e-6),Math.max(e[1],1e-6)];return(0,hn.scaleLog)().domain(t).range(i).clamp(!0)}return"symlog"===t?(0,hn.scaleSymlog)().domain(e).range(i):"time"===t?(0,hn.scaleTime)().domain([new Date(e[0]),new Date(e[1])]).range(i):(0,hn.scaleLinear)().domain(e).range(i)}function pn(t,e,i){e>t.capacity&&(t.resize(e),i&&e>i.capacity&&i.resize(e))}function yn(t,e){const i=new gr(t.capacity);return t.forEach(()=>i.push(e)),i}function gn(t,e,i,o){const r=t.push(e);return i&&i.push(o),r}function mn(t,e,i){if(!e||0===e.size)return;const o=new Set;if(t.forEach((t,e)=>{i(t)&&o.add(e)}),0===o.size)return;const r=e.toArray();e.clear();for(let t=0;r.length>t;t++)o.has(t)||e.push(r[t])}var xn=new WeakMap;function bn(){return this.updateResults.last}function vn(){return this.updateResults.last}function wn(t){return this.updateResults.subscribe(t)}function kn(t){this.config.layoutSelection=t}function Sn(){xn.set(this,!0)}function An(){const t=!0===xn.get(this);return xn.delete(this),t}function Mn(t){Object.assign(t.prototype,{getLastUpdateResult:bn,getUpdateSnapshot:vn,subscribeUpdateResult:wn,setLayoutSelection:kn,markStylePaintPending:Sn,consumeStylePaintPending:An})}var _n=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Pn=["scene-style","data-paint","accessibility","evidence"],Ln=(t,e)=>({retainedData:t,invalidations:e}),Rn=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Tn=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Cn=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],$n=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],jn=["scene-geometry","data-paint","accessibility","evidence"],zn=["scene-style","data-paint","accessibility","evidence"],En=[],Dn={chartType:Ln("rebuild",Rn),runtimeMode:Ln("rebuild",Rn),xAccessor:Ln("rebuild",Rn),yAccessor:Ln("rebuild",Rn),timeAccessor:Ln("rebuild",Rn),valueAccessor:Ln("rebuild",Rn),y0Accessor:Ln("rebuild",Rn),boundsAccessor:Ln("rebuild",Rn),band:Ln("rebuild",Rn),openAccessor:Ln("rebuild",Rn),highAccessor:Ln("rebuild",Rn),lowAccessor:Ln("rebuild",Rn),closeAccessor:Ln("rebuild",Rn),candlestickRangeMode:Ln("rebuild",Rn),accessorRevision:Ln("rebuild",Rn),groupAccessor:Ln("rebuild",Tn),categoryAccessor:Ln("rebuild",Tn),lineDataAccessor:Ln("rebuild",Tn),colorAccessor:Ln("rebuild",zn),sizeAccessor:Ln("rebuild",jn),symbolAccessor:Ln("rebuild",jn),pointIdAccessor:Ln("rebuild",jn),xScaleType:Ln("preserve",Cn),yScaleType:Ln("preserve",Cn),xExtent:Ln("preserve",Cn),yExtent:Ln("preserve",Cn),extentPadding:Ln("preserve",Cn),scalePadding:Ln("preserve",Cn),axisExtent:Ln("preserve",Cn),binSize:Ln("preserve",Cn),normalize:Ln("preserve",Cn),heatmapAggregation:Ln("preserve",Cn),heatmapXBins:Ln("preserve",Cn),heatmapYBins:Ln("preserve",Cn),arrowOfTime:Ln("preserve",$n),baseline:Ln("preserve",$n),stackOrder:Ln("preserve",$n),sizeRange:Ln("preserve",$n),curve:Ln("preserve",$n),areaGroups:Ln("preserve",$n),customLayout:Ln("preserve",$n),layoutConfig:Ln("preserve",$n),layoutMargin:Ln("preserve",$n),symbolMap:Ln("preserve",jn),showValues:Ln("preserve",jn),heatmapValueFormat:Ln("preserve",jn),lineStyle:Ln("preserve",zn),pointStyle:Ln("preserve",zn),areaStyle:Ln("preserve",zn),barStyle:Ln("preserve",zn),swarmStyle:Ln("preserve",zn),waterfallStyle:Ln("preserve",zn),candlestickStyle:Ln("preserve",zn),boundsStyle:Ln("preserve",zn),gradientFill:Ln("preserve",zn),lineGradient:Ln("preserve",zn),colorScheme:Ln("preserve",zn),themeCategorical:Ln("preserve",zn),themeSemantic:Ln("preserve",zn),themeSequential:Ln("preserve",zn),themeDiverging:Ln("preserve",zn),barColors:Ln("preserve",zn),decay:Ln("preserve",zn),pulse:Ln("preserve",zn),staleness:Ln("preserve",zn),layoutSelection:Ln("preserve",zn),annotations:Ln("preserve",["overlay","accessibility","evidence"]),windowSize:Ln("preserve",En),windowMode:Ln("preserve",En),maxCapacity:Ln("preserve",En),clock:Ln("preserve",En),transition:Ln("preserve",En),introAnimation:Ln("preserve",En),onLayoutError:Ln("preserve",En)},Fn=Ln("preserve",$n),On=class{constructor(){this.tracker=new xo}get last(){return this.tracker.last}subscribe(t){return this.tracker.subscribe(t)}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},_n)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},Pn):this.recordNoop("restyle")}recordConfig(t){const e=function(t){let e="preserve";const i=new Set;for(const o of t){const t=Dn[o]??Fn;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}(t);return this.tracker.record({kind:"config",keys:t},e.invalidations)}},Nn=require("d3-quadtree"),Bn=class{constructor(){this.maxRadius=0,this.tree=null}get quadtree(){return this.tree}get maxPointRadius(){return this.maxRadius}clear(){this.tree=null,this.maxRadius=0}rebuild(t,e){if("scatter"!==t&&"bubble"!==t&&"custom"!==t)return void this.clear();let i=0,o=0;for(const t of e)"point"===t.type&&(i++,t.r>o&&(o=t.r));if(this.maxRadius=o,500>=i)return void(this.tree=null);const r=Array(i);let n=0;for(const t of e)"point"===t.type&&(r[n++]=t);this.tree=(0,Nn.quadtree)().x(t=>t.x).y(t=>t.y).addAll(r)}},In=class t{constructor(t){if(this.xExtent=new mr,this.yExtent=new mr,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 On,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 Bn,this._lastBoundedInsertsRef=null,this.applyPulse=(t,e,i)=>!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,i,o,r,n=("undefined"!=typeof performance?performance.now():Date.now())){const s=t.color??"rgba(255,255,255,0.6)",a=t.glowRadius??4;let c=!1;const l=r??(()=>{const t=new Map;for(let e=0;i.length>e;e++)t.set(i[e],e);return t})();for(const i of e){if("line"===i.type)continue;if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[i.datum];let r=0,a=!1;for(const i of e){const e=l.get(i);if(null==e)continue;a=!0;const s=o.get(e);if(null==s)continue;const c=$r(t,s,n);c>r&&(r=c)}a&&(c=jr(i,r,s)||c);continue}const e=l.get(i.datum);if(null==e)continue;const r=o.get(e);c=jr(i,null==r?0:$r(t,r,n),s,a)||c}return c}(this.config.pulse,t,e,this.timestampBuffer,this.getDatumIndexMap(e),i),this.config=t,this.buffer=new gr(t.windowSize),this.growingCap=t.windowSize,["bar","swarm","waterfall"].includes(t.chartType)||"streaming"===t.runtimeMode?(this.getX=br(t.timeAccessor||t.xAccessor,"time"),this.getY=br(t.valueAccessor||t.yAccessor,"value")):(this.getX=br(t.xAccessor,"x"),this.getY=br(t.yAccessor,"y")),this.getGroup=wr(t.groupAccessor),this.getCategory=wr(t.categoryAccessor),this.getSize=t.sizeAccessor?br(t.sizeAccessor,"size"):void 0,this.getColor=wr(t.colorAccessor),this.getSymbol=wr(t.symbolAccessor),this.getY0=t.y0Accessor?br(t.y0Accessor,"y0"):void 0,this.resolvedRibbons=un(t),this.getPointId=wr(t.pointIdAccessor),"candlestick"===t.chartType){const e=null!=t.openAccessor,i=null!=t.closeAccessor;this.getOpen=e?br(t.openAccessor,"open"):void 0,this.getHigh=br(t.highAccessor,"high"),this.getLow=br(t.lowAccessor,"low"),this.getClose=i?br(t.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!i}t.pulse&&(this.timestampBuffer=new gr(t.windowSize))}currentTime(){return this.config.clock?.()??Rr()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=yn(this.buffer,this.currentTime())):this.timestampBuffer=null}pushDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(t)),void this.yExtent.push(this.getLow(t));this.yExtent.push(this.getY(t)),this.getY0&&this.yExtent.push(this.getY0(t));for(const e of this.resolvedRibbons){const i=e.getTop(t),o=e.getBottom(t);Number.isFinite(i)&&this.yExtent.push(i),Number.isFinite(o)&&this.yExtent.push(o)}}evictDatumYExtent(t){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.evict(this.getHigh(t)),void this.yExtent.evict(this.getLow(t));this.yExtent.evict(this.getY(t)),this.getY0&&this.yExtent.evict(this.getY0(t));for(const e of this.resolvedRibbons){const i=e.getTop(t),o=e.getBottom(t);Number.isFinite(i)&&this.yExtent.evict(i),Number.isFinite(o)&&this.yExtent.evict(o)}}rebuildYExtent(){this.yExtent.clear();for(const t of this.buffer)this.pushDatumYExtent(t)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const t of this.buffer)this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t)}ingest(t){if(t.bounded&&this._lastBoundedInsertsRef===t.inserts)return this.updateResults.recordNoop("replace"),!1;const e=this.currentTime();if(this.lastIngestTime=e,this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,t.bounded){this._lastBoundedInsertsRef=t.inserts,this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const i=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=i?br(this.config.timeAccessor||this.config.xAccessor,"time"):br(this.config.xAccessor,"x"),this.xIsDate=!1,t.inserts.length>0){const e=t.inserts[0],i=this.config.xAccessor,o="function"==typeof i?i(e):e[i||"x"],r=o instanceof Date,n="string"==typeof o&&Number.isFinite(Sr(o));if(this.xIsDate=r||n,n){const t="string"==typeof i?i:void 0;this.getX=t?e=>Ar(e[t]):t=>Ar(i(t))}}pn(this.buffer,t.totalSize||t.inserts.length,this.timestampBuffer);for(const i of t.inserts)gn(this.buffer,i,this.timestampBuffer,e),this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i)}else for(const i of t.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const t=this.config.maxCapacity??1e5;t>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,t),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap),"production"===process.env.NODE_ENV||this.growingCapacityWarned||5e4>this.growingCap||(this.growingCapacityWarned=!0,console.warn(`[Semiotic] Growing window buffer reached ${this.growingCap} points (cap ${t}). Large canvas scenes are expensive — prefer a sliding window, aggregation, or an explicit maxCapacity if this is intentional.`)))}const t=gn(this.buffer,i,this.timestampBuffer,e);this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i),null!=t&&(this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t))}return this.updateResults.recordData(t.bounded?"replace":"ingest",t.inserts.length),!0}ingestWithResult(t){return this.ingest(t),this.updateResults.last}computeScene(t){const{config:e,buffer:i}=this,o=this.scales,r=this.lastLayout;if(!this.needsFullRebuild&&!e.customLayout&&this.lastLayout&&this.scene.length>0&&this.scales&&0>=(this.config.scalePadding??0)&&(this.lastLayout.width!==t.width||this.lastLayout.height!==t.height))return void this.remapScene(t);this.xExtent.dirty&&this.xExtent.recalculate(i,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const n=this.getBufferArray(),s=this.yExtent.extent;let a=dn(this.xExtent.extent,e.xExtent),c=dn(s,e.yExtent);const l=!(!(u=e.yExtent)||null==u[0]||null==u[1]);var u;const h="exact"===e.axisExtent;if("stackedarea"===e.chartType&&!l&&i.size>0){const t=function(t){const{config:e,groups:i,getX:o,getY:r}=t,n="exact"===e.axisExtent;if(e.normalize){const i=[0,n?1:1+e.extentPadding];return{yDomain:i,stackExtentCache:{key:`${t.bufferSize}:${t.ingestVersion}:norm`,yDomain:i}}}const s=`${t.bufferSize}:${t.ingestVersion}:${e.baseline??"zero"}:${e.stackOrder??"key"}`;if(t.stackExtentCache&&t.stackExtentCache.key===s)return{yDomain:t.stackExtentCache.yDomain,stackExtentCache:t.stackExtentCache};const a=new Map,c=new Set;let l=0;const u=new Map,h=new Map;for(const t of i){const e=new Map;let i=0;for(const n of t.data){const t=o(n),s=r(n);if(!Number.isFinite(t)||!Number.isFinite(s))continue;e.set(t,(e.get(t)||0)+s),c.add(t),i+=s;const a=(u.get(t)||0)+s;u.set(t,a),a>l&&(l=a)}a.set(t.key,e),h.set(t.key,i)}const d=e.stackOrder??"key",f=(t,e)=>e>t?-1:t>e?1:0;let p,y;if("input"===d)p=i.map(t=>t.key);else if("insideOut"===d){const t=[...i].map(t=>t.key).sort((t,e)=>{const i=(h.get(e)??0)-(h.get(t)??0);return 0!==i?i:f(t,e)}),e=[],o=[];let r=0,n=0;for(const i of t)n>r?(e.push(i),r+=h.get(i)??0):(o.push(i),n+=h.get(i)??0);p=[...o.reverse(),...e]}else p="asc"===d?i.map(t=>t.key).sort((t,e)=>{const i=(h.get(t)??0)-(h.get(e)??0);return 0!==i?i:f(t,e)}):"desc"===d?i.map(t=>t.key).sort((t,e)=>{const i=(h.get(e)??0)-(h.get(t)??0);return 0!==i?i:f(t,e)}):i.map(t=>t.key).sort(f);if("wiggle"===e.baseline||"silhouette"===e.baseline){const t=Array.from(c).sort((t,e)=>t-e),i=Or(t,p,(t,e)=>a.get(t)?.get(e)||0,e.baseline);let o=1/0,r=-1/0;for(const e of t){const t=i.get(e)??0,n=u.get(e)??0;o>t&&(o=t),t+n>r&&(r=t+n)}Number.isFinite(o)&&Number.isFinite(r)||(o=0,r=0);const s=r-o,l=n?0:s>0?s*e.extentPadding:1;y=[o-l,r+l]}else if("diverging"===e.baseline){const t=Array.from(c).sort((t,e)=>t-e),[i,o]=function(t,e,i){let o=0,r=0;for(const n of t){let t=0,s=0;for(const o of e){const e=i(o,n)||0;0>e?s+=e:t+=e}o>s&&(o=s),t>r&&(r=t)}return[o,r]}(t,p,(t,e)=>a.get(t)?.get(e)||0),r=o-i,s=n?0:r>0?r*e.extentPadding:1;y=[i-s,o+s]}else y=[0,l+(n?0:l>0?l*e.extentPadding:1)];return{yDomain:y,stackExtentCache:{key:s,yDomain:y}}}({config:e,groups:this.groupData(n),getX:this.getX,getY:this.getY,bufferSize:i.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=t.yDomain,this._stackExtentCache=t.stackExtentCache}else"bar"===e.chartType&&e.binSize&&!l&&i.size>0?c=function(t,e,i,o,r,n,s){const[,a]=function(t,e,i,o,r){const n=rn(t,e,i,o,r);if(0===n.size)return[0,0];let s=0;for(const t of n.values())t.total>s&&(s=t.total);return[0,s]}(t,e,i,o,r);return[0,s?a:a+a*n]}(i,this.getX,this.getY,e.binSize,this.getCategory,e.extentPadding,h):"waterfall"===e.chartType&&!l&&i.size>0?c=function(t,e,i,o){const[r,n]=function(t,e){let i=0,o=0,r=0;for(const n of t){const t=e(n);null==t||Number.isNaN(t)||(r+=t,i>r&&(i=r),r>o&&(o=r))}return[i,o]}(t,e),s=n-r,a=o?0:s>0?s*i:1;return[Math.min(0,r-Math.abs(a)),Math.max(0,n+Math.abs(a))]}(i,this.getY,e.extentPadding,h):l||c[0]===1/0||(c=function(t,e,i){if(!i.length)return t;let[o,r]=t;for(const t of e)for(const e of i){const i=e.getTop(t),n=e.getBottom(t);Number.isFinite(i)&&(o>i&&(o=i),i>r&&(r=i)),Number.isFinite(n)&&(o>n&&(o=n),n>r&&(r=n))}return[o,r]}(c,n,this.resolvedRibbons),c=function(t,e){const i=t[1]-t[0],o=e.exactMode?0:i>0?i*e.extentPadding:1,r=[null!=e.userMin?t[0]:t[0]-o,null!=e.userMax?t[1]:t[1]+o];return"log"!==e.yScaleType||r[0]>0||0>=e.dataYDomain[0]||e.exactMode||null==e.userMin&&(r[0]=e.dataYDomain[0]/(1+e.extentPadding)),r}(c,{exactMode:h,extentPadding:e.extentPadding,userMin:e.yExtent?.[0],userMax:e.yExtent?.[1],yScaleType:e.yScaleType,dataYDomain:s}));c=function(t,e,i){if(!e||i)return t;const o=e[0],r=e[1];return null==o&&null==r?t:[null!=o?o:t[0],null!=r?r:t[1]]}(c,e.yExtent,!!l),({xDomain:a,yDomain:c}=function(t,e,i){let o=t,r=e;if(o[0]===1/0||o[1]===-1/0)if("time"===i){const t=Date.now();o=[t-864e5,t]}else o=[0,1];return r[0]!==1/0&&r[1]!==-1/0||(r=[0,1]),{xDomain:o,yDomain:r}}(a,c,e.xScaleType)),this.scales=function(t){const{config:e,layout:i,xDomain:o,yDomain:r}=t,n="streaming"===e.runtimeMode,s=Math.max(0,Math.min(e.scalePadding||0,Math.min(i.width,i.height)/2-1));if(n){if("x"==("up"===(a=e.arrowOfTime)||"down"===a?"y":"x")){const t="right"===e.arrowOfTime?[s,i.width-s]:[i.width-s,s];return{x:(0,hn.scaleLinear)().domain(o).range(t),y:fn(e.yScaleType,r,[i.height-s,s])}}const t="down"===e.arrowOfTime?[s,i.height-s]:[i.height-s,s];return{x:fn(e.yScaleType,r,[s,i.width-s]),y:(0,hn.scaleLinear)().domain(o).range(t)}}var a;return{x:fn(e.xScaleType,o,[s,i.width-s]),y:fn(e.yScaleType,r,[i.height-s,s])}}({config:e,layout:t,xDomain:a,yDomain:c}),this._customLayoutFailedThisBuild=!1;const d=this.buildSceneNodes(t,n);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=d,this.config.decay&&this.applyDecay(this.scene,n),this.config.pulse&&this.applyPulse(this.scene,n,this.currentTime()),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&(this.prevPositionMap.size>0||this.prevPathMap.size>0)&&this.startTransition(),this.spatialIndex.rebuild(this.config.chartType,this.scene),this.needsFullRebuild=!1,this.lastLayout={width:t.width,height:t.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(t){const e=t.width/this.lastLayout.width,i=t.height/this.lastLayout.height;for(const t of this.scene)switch(t.type){case"line":for(const o of t.path)o[0]*=e,o[1]*=i;break;case"area":for(const o of t.topPath)o[0]*=e,o[1]*=i;for(const o of t.bottomPath)o[0]*=e,o[1]*=i;t.clipRect&&(t.clipRect={x:t.clipRect.x*e,y:t.clipRect.y*i,width:t.clipRect.width*e,height:t.clipRect.height*i});break;case"point":case"glyph":t.x*=e,t.y*=i;break;case"rect":case"heatcell":t.x*=e,t.y*=i,t.w*=e,t.h*=i;break;case"candlestick":t.x*=e,t.openY*=i,t.closeY*=i,t.highY*=i,t.lowY*=i}const o=this.scales.x.domain(),r=this.scales.y.domain(),n=this.scales.x.range(),s=this.scales.y.range(),a=fn,c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(t.width,t.height)/2-1)),l=s[1]>s[0];this.scales={x:a(this.config.xScaleType,o,n[0]>n[1]?[t.width-c,c]:[c,t.width-c]),y:a(this.config.yScaleType,r,l?[c,t.height-c]:[t.height-c,c])},this.lastLayout={width:t.width,height:t.height},this.spatialIndex.rebuild(this.config.chartType,this.scene),this.version++}buildSceneNodes(t,e){const{config:i,scales:o}=this;if(!o)return[];if(i.customLayout){const r={data:e,scales:o,dimensions:{width:t.width,height:t.height,margin:i.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:i.themeSemantic??{},categorical:i.themeCategorical??U},resolveColor:(t,e)=>{const o=this.resolveGroupColor(t);if(o)return o;const r=this.resolveLineStyle(t,e);return r.stroke?r.stroke:"string"==typeof r.fill?r.fill:i.themeSemantic?.primary??"#4e79a7"},config:i.layoutConfig??{},selection:i.layoutSelection??null};let n;try{n=i.customLayout(r)}catch(t){const e=null!==this.lastCustomLayoutResult,o=cn("xy",t,e,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",t);try{i.onLayoutError?.(o)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return e?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=n.overlays??null,this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null;const s=n.nodes??[];if(this._customRestyle=n.restyle,this.hasCustomRestyle=!!n.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const t of s)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(s,i.layoutSelection??null)}return nn({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===e.length)return[];const r={scales:o,config:i,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getSymbol:this.getSymbol,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(t,e)=>this.resolveLineStyle(t,e),resolveAreaStyle:(t,e)=>this.resolveAreaStyle(t,e),resolveBoundsStyle:(t,e)=>this.resolveBoundsStyle(t,e),resolveColorMap:t=>this.resolveColorMap(t),resolveGroupColor:t=>this.resolveGroupColor(t),groupData:t=>this.groupData(t),barCategoryCache:this._barCategoryCache};switch(i.chartType){case"line":return function(t,e){const i=t.groupData(e),o=[],r=t.config.annotations?.filter(Zr).map(t=>({value:t.value,color:t.color,thresholdType:t.thresholdType||"greater"}));if(t.ribbons&&t.ribbons.length>0){const{perSeries:r,aggregate:n}=Xr(t.ribbons);if(n.length>0&&o.push(...Gr(t,e,n)),r.length>0)for(const e of i)o.push(...Vr(t,e.data,e.key,r))}for(const e of i){const i=t.resolveLineStyle(e.key,e.data[0]),n=Dr(e.data,t.scales,t.getX,t.getY,i,e.key);r&&r.length>0&&(n.colorThresholds=r),t.config.curve&&"linear"!==t.config.curve&&(n.curve=t.config.curve),t.config.lineGradient&&(n.strokeGradient=t.config.lineGradient),o.push(n)}return Hr(t,i,o),o}(r,e);case"area":return function(t,e){const i=t.groupData(e),o=[];if(t.ribbons&&t.ribbons.length>0){const{perSeries:r,aggregate:n}=Xr(t.ribbons);if(n.length>0&&o.push(...Gr(t,e,n)),r.length>0)for(const e of i)o.push(...Vr(t,e.data,e.key,r))}const r=t.scales.y.domain()[0],n=t.getY0?e=>{const i=t.getY0(e);return null==i?r:i}:void 0;for(const e of i){const i=t.resolveAreaStyle(e.key,e.data[0]),s=Fr(e.data,t.scales,t.getX,t.getY,r,i,e.key,n),a=Kr(t.config.gradientFill);a&&(s.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(s.curve=t.config.curve),t.config.lineGradient&&(s.strokeGradient=t.config.lineGradient),o.push(s)}return Hr(t,i,o),o}(r,e);case"mixed":return function(t,e){const i=t.groupData(e),o=[],r=t.config.areaGroups||new Set;if(t.ribbons&&t.ribbons.length>0){const{perSeries:r,aggregate:n}=Xr(t.ribbons);if(n.length>0&&o.push(...Gr(t,e,n)),r.length>0)for(const e of i)o.push(...Vr(t,e.data,e.key,r))}const n=t.scales.y.domain()[0],s=t.getY0?e=>{const i=t.getY0(e);return null==i?n:i}:void 0;for(const e of i)if(r.has(e.key)){const i=t.resolveAreaStyle(e.key,e.data[0]),r=Fr(e.data,t.scales,t.getX,t.getY,n,i,e.key,s),a=Kr(t.config.gradientFill);a&&(r.fillGradient=a),t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}else{const i=t.resolveLineStyle(e.key,e.data[0]),r=Dr(e.data,t.scales,t.getX,t.getY,i,e.key);t.config.curve&&"linear"!==t.config.curve&&(r.curve=t.config.curve),t.config.lineGradient&&(r.strokeGradient=t.config.lineGradient),o.push(r)}return Hr(t,i,o),o}(r,e);case"stackedarea":return function(t,e){const i=t.groupData(e),o=t.config.stackOrder??"key",r=()=>i.sort((t,e)=>e.key>t.key?-1:t.key>e.key?1:0);if("input"===o);else if("key"===o)r();else if("asc"===o||"desc"===o||"insideOut"===o){const e=new Map;for(const o of i){let i=0;for(const e of o.data){const o=t.getX(e),r=t.getY(e);Number.isFinite(o)&&Number.isFinite(r)&&(i+=r)}e.set(o.key,i)}const r=(t,e)=>e>t?-1:t>e?1:0;if("asc"===o)i.sort((t,i)=>{const o=(e.get(t.key)??0)-(e.get(i.key)??0);return 0!==o?o:r(t.key,i.key)});else if("desc"===o)i.sort((t,i)=>{const o=(e.get(i.key)??0)-(e.get(t.key)??0);return 0!==o?o:r(t.key,i.key)});else{const t=[...i].sort((t,i)=>{const o=(e.get(i.key)??0)-(e.get(t.key)??0);return 0!==o?o:r(t.key,i.key)}),o=[],n=[];let s=0,a=0;for(const i of t)a>s?(o.push(i),s+=e.get(i.key)??0):(n.push(i),a+=e.get(i.key)??0);i.length=0,i.push(...n.reverse(),...o)}}else r();const n=t.config.curve&&"linear"!==t.config.curve?t.config.curve:void 0,s=t.config.normalize?"zero":t.config.baseline??"zero",{nodes:a,stackedTops:c}=function(t,e,i,o,r,n,s,a="zero"){const c=new Set;for(const e of t)for(const t of e.data){const e=i(t);Number.isFinite(e)&&c.add(e)}const l=Array.from(c).sort((t,e)=>t-e),u=new Map;for(const e of t){const t=new Map;for(const r of e.data){const e=i(r),n=o(r);Number.isFinite(e)&&Number.isFinite(n)&&t.set(e,(t.get(e)||0)+n)}u.set(e.key,t)}let h;if(n){h=new Map;for(const e of l){let i=0;for(const o of t)i+=u.get(o.key)?.get(e)||0;h.set(e,i||1)}}const d=Or(l,t.map(t=>t.key),(t,e)=>u.get(t)?.get(e)||0,a),f="diverging"===a&&!n,p=[],y=new Map,g=new Map,m=new Map,x=new Map;for(const t of l)g.set(t,d.get(t)??0),m.set(t,0),x.set(t,0);for(const i of t){const t=u.get(i.key),o=new Map;let a=[],c=[];const d=()=>{if(a.length>=2){const t={type:"area",topPath:a,bottomPath:c,style:r(i.key,i.data[0]),datum:i.data,group:i.key};s&&(t.curve=s),p.push(t)}a=[],c=[]};for(const i of l){const r=t.has(i);let s,l,u=r?t.get(i):0;if(n&&r&&(u/=h.get(i)),!r||!Number.isFinite(u)||0===u){d();continue}f?u>0?(s=m.get(i),l=s+u,m.set(i,l)):(s=x.get(i),l=s+u,x.set(i,l)):(s=g.get(i),l=s+u,g.set(i,l));const p=e.x(i);c.push([p,e.y(s)]),a.push([p,e.y(l)]),o.set(i,l)}d(),y.set(i.key,o)}return{nodes:p,stackedTops:y}}(i,t.scales,t.getX,t.getY,(e,i)=>t.resolveAreaStyle(e,i),t.config.normalize,n,s),l=a;if(t.config.pointStyle){const e=new WeakMap;for(const o of i){const i=c.get(o.key);if(i)for(const r of o.data){const o=t.getX(r),n=t.getY(r);null==o||Number.isNaN(o)||null==n||Number.isNaN(n)||!i.has(o)||e.set(r,i.get(o))}}const o=i=>e.get(i)??t.getY(i);Hr(t,i,l,o)}return l}(r,e);case"scatter":case"bubble":return function(t,e){const i=[],o="bubble"===t.config.chartType?10:5,r=t.config.sizeRange||[3,15];let n=null;if(t.getSize&&!t.config.pointStyle){const i=e.map(e=>t.getSize(e)).filter(t=>null!=t&&!Number.isNaN(t));if(i.length>0){let t=1/0,e=-1/0;for(const o of i)t>o&&(t=o),o>e&&(e=o);n=i=>t===e?(r[0]+r[1])/2:r[0]+(i-t)/(e-t)*(r[1]-r[0])}}const s=t.getColor?t.resolveColorMap(e):null,a=t.config.themeSemantic?.primary||"#4e79a7",c=t.getSymbol,l=t.config.symbolMap,u=new Map;let h=0;const d=t=>{const e=l?.[t];if(e)return e;let i=u.get(t);return i||(i=tn[h%tn.length],h++,u.set(t,i)),i};for(const r of e){let e=t.config.pointStyle?t.config.pointStyle(r):{fill:a,opacity:.8},l=e.r||o;if(n&&t.getSize){const e=t.getSize(r);null==e||Number.isNaN(e)||(l=n(e))}if(s&&t.getColor&&!e.fill){const i=t.getColor(r);i&&s.has(i)&&(e={...e,fill:s.get(i)})}const u=t.getPointId?t.getPointId(r)+"":void 0;if(c){const o=d(c(r)+""),n=Br(r,t.scales,t.getX,t.getY,Math.PI*l*l,o,e,u);n&&i.push(n)}else{const o=Nr(r,t.scales,t.getX,t.getY,l,e,u);o&&i.push(o)}}return i}(r,e);case"heatmap":return function(t,e,i){if(t.config.heatmapAggregation)return function(t,e,i){const o=Math.max(1,Math.floor(t.config.heatmapXBins??20)),r=Math.max(1,Math.floor(t.config.heatmapYBins??20)),n=t.config.heatmapAggregation??"count",s=br(t.config.valueAccessor,"value");if(!t.scales||0===e.length)return[];const[a,c]=t.scales.x.domain(),[l,u]=t.scales.y.domain(),h=(c-a||1)/o,d=(u-l||1)/r,f=o*r;if(f>1e6)return[];const p=new Int32Array(f),y=new Float64Array(f);for(let i=0;e.length>i;i++){const n=e[i],c=t.getX(n),u=t.getY(n);if(!isFinite(c)||!isFinite(u))continue;const f=Math.min(Math.floor((c-a)/h),o-1),g=Math.min(Math.floor((u-l)/d),r-1);if(0>f||0>g)continue;const m=g*o+f;p[m]++;const x=s(n);y[m]+=isFinite(x)?x:0}let g=1/0,m=-1/0;for(let t=0;f>t;t++){if(0===p[t])continue;let e;switch(n){case"sum":e=y[t];break;case"mean":e=y[t]/p[t];break;default:e=p[t]}g>e&&(g=e),e>m&&(m=e)}if(!isFinite(g))return[];const x=m-g||1,b=i.width/o,v=i.height/r,w=t.config.showValues,k=t.config.heatmapValueFormat,S=[];for(let t=0;r>t;t++){const e=t*o;for(let i=0;o>i;i++){const o=e+i;if(0===p[o])continue;let s;switch(n){case"sum":s=y[o];break;case"mean":s=y[o]/p[o];break;default:s=p[o]}const c=(s-g)/x;S.push(Wr(i*b,(r-1-t)*v,b,v,`rgb(${220-(180*c+.5)|0},${220-(100*c+.5)|0},${255-(50*c+.5)|0})`,{xi:i,yi:t,value:s,count:p[o],sum:y[o],xCenter:a+(i+.5)*h,yCenter:l+(t+.5)*d,agg:n},w?{value:s,showValues:!0,valueFormat:k}:void 0))}}return S}(t,e,i);if(0===e.length)return[];const o=br(t.config.valueAccessor,"value"),r=vr(t.config.xAccessor,"x"),n=vr(t.config.yAccessor,"y"),s=new Map,a=new Map,c=Array(e.length),l=Array(e.length);for(let t=0;e.length>t;t++){const i=e[t],o=r(i),u=n(i);c[t]=o,l[t]=u,s.has(o)||s.set(o,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,h=a.size;if(0===u||0===h)return[];const d=Array.from(s.keys()),f=Array.from(a.keys()),p=d.every(t=>"number"==typeof t&&!isNaN(t)),y=f.every(t=>"number"==typeof t&&!isNaN(t));if(p){d.sort((t,e)=>Number(t)-Number(e)),s.clear();for(let t=0;d.length>t;t++)s.set(d[t],t)}if(y){f.sort((t,e)=>Number(t)-Number(e)),a.clear();for(let t=0;f.length>t;t++)a.set(f[t],t)}const g=new Float64Array(e.length),m=new Float64Array(e.length),x=Array(e.length),b=new Map;let v=0;for(let t=0;e.length>t;t++){const i=e[t],r=s.get(c[t]),n=a.get(l[t]);if(void 0===r||void 0===n)continue;const h=o(i),d=n*u+r,f=b.get(d);let p;void 0!==f?p=f:(p=v++,b.set(d,p)),g[p]=d,m[p]=h,x[p]=i}let w=1/0,k=-1/0;for(let t=0;v>t;t++){const e=m[t];isFinite(e)&&(w>e&&(w=e),e>k&&(k=e))}if(!isFinite(w)||!isFinite(k))return[];const S=function(t){const e=t in F?t:"blues";let i=on.get(e);if(i)return i;i=Array(256);const o=O(e);for(let t=0;256>t;t++)i[t]=o(t/255);return on.set(e,i),i}("string"==typeof t.config.colorScheme?t.config.colorScheme:t.config.themeSequential||"blues"),A=255/(k-w||1),M=i.width/u,_=i.height/h,P=t.config.showValues,L=t.config.heatmapValueFormat,R=[];for(let t=0;v>t;t++){const e=m[t];if(!isFinite(e))continue;const i=g[t],o=i%u;R.push(Wr(o*M,(h-1-(i-o)/u)*_,M,_,S[Math.min((e-w)*A+.5|0,255)],x[t],P?{value:e,showValues:!0,valueFormat:L}:void 0))}return R}(r,e,t);case"bar":{const t=function(t,e){if(!t.config.binSize)return{nodes:[],binBoundaries:[]};const i=rn(e,t.getX,t.getY,t.config.binSize,t.getCategory);if(0===i.size)return{nodes:[],binBoundaries:[]};let o=null;if(t.getCategory){const e=new Set;for(const t of i.values())for(const i of t.categories.keys())e.add(i);const r=t.config.barColors?Object.keys(t.config.barColors):[],n=new Set(r),s=Array.from(e).filter(t=>!n.has(t)).sort(),a=r.filter(t=>e.has(t)),c=a.join("\0")+""+s.join("\0");t.barCategoryCache&&t.barCategoryCache.key===c?o=t.barCategoryCache.order:(o=[...a,...s],t.barCategoryCache={key:c,order:o})}const r=[],n=t.scales,[s,a]=n.x.domain(),c=t.config.barStyle,l=t.config.themeSemantic?.primary,u=c?.gap,h="number"!=typeof u||0>u?1:u,d={};c?.stroke&&(d.stroke=c.stroke),"number"==typeof c?.strokeWidth&&(d.strokeWidth=c.strokeWidth),"number"==typeof c?.opacity&&(d.opacity=c.opacity);for(const e of i.values()){const i=Math.max(e.start,s),u=Math.min(e.end,a);if(i>=u)continue;const f=n.x(i),p=n.x(u),y=Math.abs(p-f),g=y>h+1?h:0,m=Math.min(f,p)+g/2,x=Math.max(y-g,1);if(x>0)if(o&&e.categories.size>0){let i=0;for(const s of o){const o=e.categories.get(s)||0;if(0===o)continue;const a=n.y(i),u=n.y(i+o);r.push(Ir(m,Math.min(a,u),x,Math.abs(a-u),{fill:t.config.barColors?.[s]||c?.fill||l||"#4e79a7",...d},{binStart:e.start,binEnd:e.end,total:e.total,category:s,categoryValue:o},s)),i+=o}}else{const t=n.y(0),i=n.y(e.total);r.push(Ir(m,Math.min(t,i),x,Math.abs(t-i),{fill:c?.fill||l||"#007bff",...d},{binStart:e.start,binEnd:e.end,total:e.total}))}}const f=new Set;for(const t of i.values())f.add(t.start),f.add(t.end);return{nodes:r,binBoundaries:Array.from(f).sort((t,e)=>t-e)}}(r,e);return this._barCategoryCache=r.barCategoryCache??null,this._binBoundaries=t.binBoundaries,t.nodes}case"swarm":return function(t,e){const i=[],o=t.config.swarmStyle||{},r=o.radius??3,n=o.fill??t.config.themeSemantic?.primary??"#007bff",s=o.opacity??.7,a=o.stroke,c=o.strokeWidth;for(const o of e){const e=t.getX(o),l=t.getY(o);if(null==l||Number.isNaN(l))continue;const u=t.scales.x(e),h=t.scales.y(l);let d=n;if(t.getCategory){const e=t.getCategory(o);d=t.config.barColors?.[e]||d}const{r:f,...p}=t.config.pointStyle?.(o)??{},y={type:"point",x:u,y:h,r:f??r,style:{fill:d,opacity:s,stroke:a,strokeWidth:c,...p},datum:o};t.getPointId&&(y.pointId=t.getPointId(o)+""),i.push(y)}return i}(r,e);case"waterfall":return function(t,e,i){const o=[],r=t.scales,n=t.config.waterfallStyle,s=e.filter(e=>{const i=t.getY(e),o=t.getX(e);return null!=i&&!Number.isNaN(i)&&null!=o&&isFinite(o)});if(0===s.length)return o;const a=n?.positiveColor??t.config.themeSemantic?.success??"#28a745",c=n?.negativeColor??t.config.themeSemantic?.danger??"#dc3545",l=n?.gap??1,u=n?.stroke,h=n?.strokeWidth,d=n?.opacity;let f=0;for(let e=0;s.length>e;e++){const p=s[e],y=t.getX(p),g=t.getY(p),m=f+g;let x;x=s.length-1>e?t.getX(s[e+1])-y:e>0?y-t.getX(s[e-1]):0;const b=r.x(y),v=0!==x?r.x(y+x):b+i.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:h};null!=d&&(P.opacity=d),o.push(Ir(w,M,k,_,P,{...p,baseline:f,cumEnd:m,delta:g,_connectorStroke:n?.connectorStroke,_connectorWidth:n?.connectorWidth})),f=m}return o}(r,e,t);case"candlestick":return function(t,e){if(!t.getHigh||!t.getLow||!t.scales)return[];const i=t.config.candlestickRangeMode??!1;if(!(i||t.getOpen&&t.getClose))return[];const o=[],r=t.config.candlestickStyle||{},n=r.rangeColor||"#6366f1",s=i?n:r.upColor||"#28a745",a=i?n:r.downColor||"#dc3545",c=i?n:r.wickColor||"#333",l=r.wickWidth||(i?2:1),u=e.map(e=>t.getX(e)).filter(t=>null!=t&&!Number.isNaN(t)).sort((t,e)=>t-e);let h=r.bodyWidth??0;if(null==r.bodyWidth)if(u.length>1){let e=1/0;for(let i=1;u.length>i;i++){const o=Math.abs(t.scales.x(u[i])-t.scales.x(u[i-1]));o>0&&e>o&&(e=o)}h=e!==1/0?Math.max(2,Math.min(.6*e,20)):6}else h=6;for(const r of e){const e=t.getX(r);if(null==e||Number.isNaN(e))continue;const n=t.getHigh(r),u=t.getLow(r);if(null==n||Number.isNaN(n)||null==u||Number.isNaN(u))continue;const d=i?n:t.getOpen(r),f=i?u:t.getClose(r);if(!i&&[d,f].some(t=>null==t||Number.isNaN(t)))continue;const p=f>=d,y={type:"candlestick",x:t.scales.x(e),openY:t.scales.y(d),closeY:t.scales.y(f),highY:t.scales.y(n),lowY:t.scales.y(u),bodyWidth:h,upColor:s,downColor:a,wickColor:c,wickWidth:l,isUp:p,datum:r};i&&(y.isRange=!0),o.push(y)}return o}(r,e);default:return[]}}resolveBoundsStyle(t,e){return function(t,e,i,o){const r=t.boundsStyle;return"function"==typeof r?r(i||{},e):r&&"object"==typeof r?r:{fill:o(e,i).stroke||t.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,stroke:"none"}}(this.config,t,e,(t,e)=>this.resolveLineStyle(t,e))}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?Tr(i,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const e=Cr(t);return this._datumIndexCache={version:this._ingestVersion,map:e},e}applyDecay(t,e){this.config.decay&&function(t,e,i,o=Cr(i)){const r=i.length;if(r>1)for(const i of e){if("line"===i.type){const e=Array.isArray(i.datum)?i.datum:[];if(2>e.length)continue;const n=Array(e.length);let s=!1;for(let i=0;e.length>i;i++){const a=o.get(e[i]);null!=a?(n[i]=Tr(t,a,r),1>n[i]&&(s=!0)):n[i]=1}s&&(i._decayOpacities=n);continue}if("area"===i.type){const e=Array.isArray(i.datum)?i.datum:[],n=i.topPath?i.topPath.length:e.length;if(2>n)continue;if(e.length===n){const s=Array(n);let a=!1;for(let i=0;e.length>i;i++){const n=o.get(e[i]);null!=n?(s[i]=Tr(t,n,r),1>s[i]&&(a=!0)):s[i]=1}a&&(i._decayOpacities=s)}else{let s=1;for(const i of e){const e=o.get(i);if(null!=e){const i=Tr(t,e,r);s>i&&(s=i)}}if(1>s){const t=Array(n);t.fill(s),i._decayOpacities=t}}continue}const e=o.get(i.datum);if(null==e)continue;const n=Tr(t,e,r);"heatcell"===i.type?i.style={opacity:n}:"candlestick"===i.type?i._decayOpacity=n:i.style={...i.style,opacity:(i.style?.opacity??1)*n}}}(this.config.decay,t,e,this.getDatumIndexMap(e))}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),t)}hasActivePulsesAt(t){return!!this.config.pulse&&zr(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(t,e,i,o){i.clear(),o.clear();for(let r=0;e.length>r;r++){const n=e[r],s=Er(t,n,r);s&&("point"===n.type?i.set(s,{x:n.x,y:n.y,r:n.r,opacity:n.style.opacity}):"glyph"===n.type?i.set(s,{x:n.x,y:n.y,r:n.size,opacity:n.style.opacity,glyph:n.glyph}):"rect"===n.type?i.set(s,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style.opacity}):"heatcell"===n.type?i.set(s,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style?.opacity}):"candlestick"===n.type?i.set(s,{x:n.x,y:n.openY,w:n.bodyWidth,openY:n.openY,closeY:n.closeY,highY:n.highY,lowY:n.lowY,opacity:n.style?.opacity}):"line"===n.type?o.set(s,{path:n.path.map(t=>[t[0],t[1]]),opacity:n.style?.opacity}):"area"===n.type&&o.set(s,{topPath:n.topPath.map(t=>[t[0],t[1]]),bottomPath:n.bottomPath.map(t=>[t[0],t[1]]),opacity:n.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();const t=this.scales?.y(0)??0;for(let e=0;this.scene.length>e;e++){const i=this.scene[e],o=Er(this.transitionContext,i,e);o&&("point"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,r:0,opacity:0}):"rect"===i.type?this.prevPositionMap.set(o,{x:i.x,y:t,w:i.w,h:0,opacity:i.style.opacity??1}):"heatcell"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:0}):"line"===i.type?(i._introClipFraction=0,this.prevPathMap.set(o,{path:i.path.map(t=>[t[0],t[1]]),opacity:i.style.opacity})):"area"===i.type&&(i._introClipFraction=0,this.prevPathMap.set(o,{topPath:i.topPath.map(t=>[t[0],t[1]]),bottomPath:i.bottomPath.map(t=>[t[0],t[1]]),opacity:i.style.opacity})))}}startTransition(){if(!this.config.transition)return;const t=function(t,e,i,o,r,n=Rr()){if(0===o.size&&0===r.size)return i;const s=e.duration??300;if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}let a=!1;const c=new Set,l=new Set;for(let e=0;i.scene.length>e;e++){const n=i.scene[e],s=Er(t,n,e);if(!s)continue;if(n._transitionKey=s,"line"===n.type||"area"===n.type){const t=r.get(s);if(t){if(l.add(s),"line"===n.type&&t.path&&t.path.length===n.path.length){n._targetPath=n.path.map(t=>[t[0],t[1]]),n._prevPath=t.path;for(let e=0;n.path.length>e;e++)n.path[e]=[t.path[e][0],t.path[e][1]];a=!0}else if("area"===n.type&&t.topPath&&t.bottomPath&&t.topPath.length===n.topPath.length&&t.bottomPath.length===n.bottomPath.length){n._targetTopPath=n.topPath.map(t=>[t[0],t[1]]),n._targetBottomPath=n.bottomPath.map(t=>[t[0],t[1]]),n._prevTopPath=t.topPath,n._prevBottomPath=t.bottomPath;for(let e=0;n.topPath.length>e;e++)n.topPath[e]=[t.topPath[e][0],t.topPath[e][1]];for(let e=0;n.bottomPath.length>e;e++)n.bottomPath[e]=[t.bottomPath[e][0],t.bottomPath[e][1]];a=!0}n._targetOpacity=n.style.opacity??1,n._startOpacity=t.opacity??n.style.opacity??1}else n._targetOpacity=n.style.opacity??1,n._startOpacity=0,n.style={...n.style,opacity:0},a=!0;continue}const u=o.get(s);if("point"===n.type)if(u){c.add(s);const t={x:n.x,y:n.y,r:n.r};n._targetOpacity=n.style.opacity??1,u.x===t.x&&u.y===t.y&&u.r===t.r||(n._targetX=t.x,n._targetY=t.y,n._targetR=t.r,n.x=u.x,n.y=u.y,n.r=u.r??n.r,a=!0)}else n._targetOpacity=n.style.opacity??1,n.style={...n.style,opacity:0},a=!0;else if("glyph"===n.type)if(u){c.add(s);const t={x:n.x,y:n.y,size:n.size};n._targetOpacity=n.style.opacity??1,u.x===t.x&&u.y===t.y&&u.r===t.size||(n._targetX=t.x,n._targetY=t.y,n._targetR=t.size,n.x=u.x,n.y=u.y,n.size=u.r??n.size,a=!0)}else n._targetOpacity=n.style.opacity??1,n.style={...n.style,opacity:0},a=!0;else if("rect"===n.type)if(u){c.add(s);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=n.style.opacity??1,u.x===t.x&&u.y===t.y&&u.w===t.w&&u.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=u.x,n.y=u.y,n.w=u.w??n.w,n.h=u.h??n.h,a=!0)}else n._targetOpacity=n.style.opacity??1,n.style={...n.style,opacity:0},a=!0;else if("heatcell"===n.type)if(u){c.add(s);const t={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=n.style?.opacity??1,u.x===t.x&&u.y===t.y&&u.w===t.w&&u.h===t.h||(n._targetX=t.x,n._targetY=t.y,n._targetW=t.w,n._targetH=t.h,n.x=u.x,n.y=u.y,n.w=u.w??n.w,n.h=u.h??n.h,a=!0)}else n._targetOpacity=n.style?.opacity??1,n.style={...n.style||{},opacity:0},a=!0;else if("candlestick"===n.type)if(u&&null!=u.openY){c.add(s);const t={x:n.x,openY:n.openY,closeY:n.closeY,highY:n.highY,lowY:n.lowY};n._targetOpacity=n.style?.opacity??1,(u.x!==t.x||u.openY!==t.openY||u.closeY!==t.closeY||u.highY!==t.highY||u.lowY!==t.lowY)&&(n._targetX=t.x,n._targetOpenY=t.openY,n._targetCloseY=t.closeY,n._targetHighY=t.highY,n._targetLowY=t.lowY,n.x=u.x,n.openY=u.openY,n.closeY=u.closeY??n.closeY,n.highY=u.highY??n.highY,n.lowY=u.lowY??n.lowY,a=!0)}else n._targetOpacity=n.style?.opacity??1,n.style={...n.style||{},opacity:0},a=!0}for(const[t,e]of r)if(!l.has(t))if(t.startsWith("l:")&&e.path){const o={type:"line",path:e.path.map(t=>[t[0],t[1]]),group:t.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),a=!0}else if(t.startsWith("a:")&&e.topPath&&e.bottomPath){const o={type:"area",topPath:e.topPath.map(t=>[t[0],t[1]]),bottomPath:e.bottomPath.map(t=>[t[0],t[1]]),group:t.slice(2),style:{fill:"#999",opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t,datum:null};i.exitNodes.push(o),a=!0}for(const[t,e]of o)if(!c.has(t)){if(t.startsWith("p:"))i.exitNodes.push({type:"point",x:e.x,y:e.y,r:e.r??3,style:{opacity:e.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("g:")&&e.glyph)i.exitNodes.push({type:"glyph",x:e.x,y:e.y,size:e.r??12,glyph:e.glyph,color:"#999",accent:"#999",style:{opacity:e.opacity??1},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("r:"))i.exitNodes.push({type:"rect",x:e.x,y:e.y,w:e.w??0,h:e.h??0,style:{opacity:e.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:t});else if(t.startsWith("h:"))i.exitNodes.push({type:"heatcell",x:e.x,y:e.y,w:e.w??0,h:e.h??0,fill:"#999",datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t});else if(t.startsWith("c:")){const o=e.openY??e.y;i.exitNodes.push({type:"candlestick",x:e.x,openY:o,closeY:e.closeY??o,highY:e.highY??o,lowY:e.lowY??o,bodyWidth:e.w??6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:e.opacity??1},_targetOpacity:0,_transitionKey:t})}a=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),a&&(i.activeTransition={startTime:n,duration:s}),i}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap,this.currentTime());this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition}advanceTransition(t){if(!this.activeTransition||!this.config.transition)return!1;const e={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},i=function(t,e,i,o){if(!i.activeTransition)return!1;const r=Pr(t,i.activeTransition),n=_r(r,"linear"===e.easing?"linear":"ease-out-cubic");for(const t of i.scene){const e=t._transitionKey;if("point"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style.opacity=Lr(i?i.opacity??1:0,t._targetOpacity,n)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Lr(i.x,t._targetX,n),t.y=Lr(i.y,t._targetY,n),void 0!==t._targetR&&void 0!==i.r&&(t.r=Lr(i.r,t._targetR,n))}else if("glyph"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style.opacity=Lr(i?i.opacity??1:0,t._targetOpacity,n)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Lr(i.x,t._targetX,n),t.y=Lr(i.y,t._targetY,n),void 0!==t._targetR&&void 0!==i.r&&(t.size=Lr(i.r,t._targetR,n))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style.opacity=Lr(i?i.opacity??1:0,t._targetOpacity,n)}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Lr(i.x,t._targetX,n),t.y=Lr(i.y,t._targetY,n),void 0!==i.w&&(t.w=Lr(i.w,t._targetW,n)),void 0!==i.h&&(t.h=Lr(i.h,t._targetH,n))}else if("heatcell"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style={...t.style||{},opacity:Lr(i?i.opacity??1:0,t._targetOpacity,n)}}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Lr(i.x,t._targetX,n),t.y=Lr(i.y,t._targetY,n),void 0!==i.w&&(t.w=Lr(i.w,t._targetW,n)),void 0!==i.h&&(t.h=Lr(i.h,t._targetH,n))}else if("candlestick"===t.type){if(void 0!==t._targetOpacity){const i=e?o.get(e):void 0;t.style={...t.style||{},opacity:Lr(i?i.opacity??1:0,t._targetOpacity,n)}}if(void 0===t._targetX)continue;if(!e)continue;const i=o.get(e);if(!i)continue;t.x=Lr(i.x,t._targetX,n),void 0!==i.openY&&(t.openY=Lr(i.openY,t._targetOpenY,n)),void 0!==i.closeY&&(t.closeY=Lr(i.closeY,t._targetCloseY,n)),void 0!==i.highY&&(t.highY=Lr(i.highY,t._targetHighY,n)),void 0!==i.lowY&&(t.lowY=Lr(i.lowY,t._targetLowY,n))}else if("line"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:Lr(t._startOpacity??0,t._targetOpacity,n)}),void 0!==t._introClipFraction&&(t._introClipFraction=n);const e=t._prevPath,i=t._targetPath;if(e&&i&&e.length===t.path.length)for(let o=0;t.path.length>o;o++)t.path[o][0]=Lr(e[o][0],i[o][0],n),t.path[o][1]=Lr(e[o][1],i[o][1],n)}else if("area"===t.type){void 0!==t._targetOpacity&&(t.style={...t.style,opacity:Lr(t._startOpacity??0,t._targetOpacity,n)}),void 0!==t._introClipFraction&&(t._introClipFraction=n);const e=t._prevTopPath,i=t._prevBottomPath,o=t._targetTopPath,r=t._targetBottomPath;if(e&&o&&e.length===t.topPath.length)for(let i=0;t.topPath.length>i;i++)t.topPath[i][0]=Lr(e[i][0],o[i][0],n),t.topPath[i][1]=Lr(e[i][1],o[i][1],n);if(i&&r&&i.length===t.bottomPath.length)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e][0]=Lr(i[e][0],r[e][0],n),t.bottomPath[e][1]=Lr(i[e][1],r[e][1],n)}}if(r>=1){for(const t of i.scene){if(void 0!==t._targetOpacity){const e=t._targetOpacity;t.style="line"===t.type||"area"===t.type?{...t.style,opacity:0===e?0:e}:{...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}if("point"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("glyph"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,void 0!==t._targetR&&(t.size=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("heatcell"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else if("candlestick"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,void 0!==t._targetOpenY&&(t.openY=t._targetOpenY),void 0!==t._targetCloseY&&(t.closeY=t._targetCloseY),void 0!==t._targetHighY&&(t.highY=t._targetHighY),void 0!==t._targetLowY&&(t.lowY=t._targetLowY),t._targetX=void 0,t._targetOpenY=void 0,t._targetCloseY=void 0,t._targetHighY=void 0,t._targetLowY=void 0}else if("line"===t.type){const e=t._targetPath;if(e)for(let i=0;t.path.length>i;i++)t.path[i]=e[i];t._prevPath=void 0,t._targetPath=void 0,t._introClipFraction=void 0}else if("area"===t.type){const e=t._targetTopPath,i=t._targetBottomPath;if(e)for(let i=0;t.topPath.length>i;i++)t.topPath[i]=e[i];if(i)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=i[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0,t._introClipFraction=void 0}}if(i.exitNodes.length>0){const t=new Set(i.exitNodes);i.scene=i.scene.filter(e=>!t.has(e)),i.exitNodes=[]}return i.activeTransition=null,!1}return!0}(t,this.config.transition,e,this.prevPositionMap);return this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition,i}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const t of this.scene)"line"!==t.type&&"area"!==t.type||(t._introClipFraction=void 0)}groupData(t){const{result:e,cache:i}=function(t,e,i,o){if(o&&o.version===i&&o.group===e&&o.data===t)return{result:o.result,cache:o};let r;if(e){const i=new Map;for(const o of t){const t=e(o);i.has(t)||i.set(t,[]),i.get(t).push(o)}r=Array.from(i.entries()).map(([t,e])=>({key:t,data:e}))}else r=[{key:"_default",data:t}];return{result:r,cache:{version:i,group:e,data:t,result:r}}}(t,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=i,e}resolveColorMap(t){const{map:e,cache:i}=function(t,e,i,o,r){if(r&&r.version===o)return{map:r.map,cache:r};const n=new Set;if(e)for(const i of t){const t=e(i);t&&n.add(t)}const s=Array.from(n).sort(),a=s.join("\0");if(r&&r.key===a){const t={...r,version:o};return{map:t.map,cache:t}}const c=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical||U,l=new Map;for(let t=0;s.length>t;t++)l.set(s[t],c[t%c.length]);return{map:l,cache:{key:a,map:l,version:o}}}(t,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=i,e}resolveLineStyle(t,e){return function(t,e,i,o){const r=t.lineStyle;if("function"==typeof r){const t=r(i||{},e);if(t&&!t.stroke&&e){const i=o(e);if(i)return{...t,stroke:i}}return t}const n=t.themeSemantic?.primary;return r&&"object"==typeof r?{stroke:r.stroke||n||"#007bff",strokeWidth:r.strokeWidth||2,strokeDasharray:r.strokeDasharray,fill:r.fill,fillOpacity:r.fillOpacity,opacity:r.opacity}:{stroke:o(e)||n||"#007bff",strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveAreaStyle(t,e){return function(t,e,i,o){if(t.areaStyle){const r=t.areaStyle(i||{});if(r&&!r.fill&&e){const t=o(e);if(t)return{...r,fill:t,stroke:r.stroke||t}}return r}const r=t.lineStyle;if("function"==typeof r){const t=r(i||{},e);if(t&&!t.fill&&e){const i=o(e);if(i)return{...t,fill:i,stroke:t.stroke||i}}return t}const n=t.themeSemantic?.primary;if(r&&"object"==typeof r)return{fill:r.fill||r.stroke||n||"#4e79a7",fillOpacity:r.fillOpacity??.7,stroke:r.stroke||n||"#4e79a7",strokeWidth:r.strokeWidth||2};const s=o(e)||n||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}(this.config,t,e,t=>this.resolveGroupColor(t))}resolveGroupColor(e){const{color:i,groupColorCounter:o}=function(t){const{group:e,colorMapCache:i,groupColorMap:o,groupColorMapCap:r,config:n}=t;let{groupColorCounter:s}=t;if(i){const t=i.map.get(e);if(t)return{color:t,groupColorCounter:s}}const a=o.get(e);if(a)return{color:a,groupColorCounter:s};const c=(Array.isArray(n.colorScheme)&&n.colorScheme.length>0?n.colorScheme:null)||(Array.isArray(n.themeCategorical)&&n.themeCategorical.length>0?n.themeCategorical:null)||U;if(0===c.length)return{color:null,groupColorCounter:s};const l=c[s%c.length];if(s++,o.set(e,l),o.size>r){const t=o.keys().next().value;void 0!==t&&o.delete(t)}return{color:l,groupColorCounter:s}}({group:e,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:t.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=o,i}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(t){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=Mr(t),i=this.getPointId,o=t=>e.has(i(t));mn(this.buffer,this.timestampBuffer,o);const r=this.buffer.remove(o);if(0===r.length)return this.updateResults.recordNoop("remove"),r;for(const t of r)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",r.length),r}update(t,e){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const i=Mr(t),o=this.getPointId,r=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&r.add(e)});const n=this.buffer.update(t=>i.has(o(t)),e);if(0===n.length)return this.updateResults.recordNoop("update"),n;for(const t of n)this.xExtent.evict(this.getX(t)),this.evictDatumYExtent(t);return this.buffer.forEach((t,e)=>{r.has(e)&&(this.xExtent.push(this.getX(t)),this.pushDatumYExtent(t))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",n.length),n}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._lastBoundedInsertsRef=null,this.needsFullRebuild=!0,this._bufferDirty=!0,this._bufferArrayCache=null,this._datumIndexCache=null,this.lastLayout=null,this.scales=null,this.scene=[],this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,this.spatialIndex.clear(),this._colorMapCache=null,this._groupDataCache=null,this._groupColorMap=new Map,this._groupColorCounter=0,this._barCategoryCache=null,this._binBoundaries=[],this._stackExtentCache=null,this.version++,this.updateResults.recordData("clear")}get size(){return this.buffer.size}getBuffer(){return this.buffer}getXAccessor(){return this.getX}getYAccessor(){return this.getY}getCategoryAccessor(){return this.getCategory}applyCustomRestyle(t,e){const i=this._customRestyle;if(i)for(const o of t){const t=this._baseStyles.get(o)??o.style??{},r=i(o,e);o.style=r?{...t,...r}:t}}restyleScene(t){this._customRestyle?(this.applyCustomRestyle(this.scene,t),this.markStylePaintPending(),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}updateConfig(t){const e={...this.config},i=Object.keys(t).filter(i=>t[i]!==e[i]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in t&&t.windowSize!==e.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${e.windowSize} → ${t.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in t||"themeCategorical"in t||"colorAccessor"in t)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in t||"colorScheme"in t)&&(this._barCategoryCache=null),("normalize"in t||"extentPadding"in t||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t||"boundsAccessor"in t||"band"in t||"y0Accessor"in t||"openAccessor"in t||"highAccessor"in t||"lowAccessor"in t||"closeAccessor"in t||"groupAccessor"in t||"categoryAccessor"in t||"chartType"in t||"runtimeMode"in t)&&(this._stackExtentCache=null);let o=!1,r=!1;Object.assign(this.config,t),"pulse"in t&&this.syncPulseTimestampBuffer();const n="chartType"in t&&t.chartType!==e.chartType||"runtimeMode"in t&&t.runtimeMode!==e.runtimeMode;if(n||"xAccessor"in t||"yAccessor"in t||"timeAccessor"in t||"valueAccessor"in t){const t=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,i=t&&this.config.valueAccessor||this.config.yAccessor,s=t&&e.valueAccessor||e.yAccessor,a=n||!xr(t&&this.config.timeAccessor||this.config.xAccessor,t&&e.timeAccessor||e.xAccessor),c=n||!xr(i,s);(a||c)&&(t?(this.getX=br(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=br(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=br(this.config.xAccessor,"x"),this.getY=br(this.config.yAccessor,"y")),c&&this.resolvedRibbons.some(t=>"bounds"===t.kind)&&(this.resolvedRibbons=un(this.config)),o=!0,r=!0)}if("groupAccessor"in t&&!xr(t.groupAccessor,e.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?wr(this.config.groupAccessor):void 0,o=!0),"categoryAccessor"in t&&!xr(t.categoryAccessor,e.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?wr(this.config.categoryAccessor):void 0,o=!0),"sizeAccessor"in t&&!xr(t.sizeAccessor,e.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?br(this.config.sizeAccessor,"size"):void 0,o=!0),"symbolAccessor"in t&&!xr(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?wr(this.config.symbolAccessor):void 0,o=!0),"colorAccessor"in t&&!xr(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?wr(this.config.colorAccessor):void 0,o=!0),"y0Accessor"in t&&!xr(t.y0Accessor,e.y0Accessor)&&(this.getY0=this.config.y0Accessor?br(this.config.y0Accessor,"y0"):void 0,o=!0,r=!0),("boundsAccessor"in t&&!xr(t.boundsAccessor,e.boundsAccessor)||"band"in t&&t.band!==e.band||"boundsStyle"in t&&t.boundsStyle!==e.boundsStyle)&&(this.resolvedRibbons=un(this.config),o=!0,r=!0),"pointIdAccessor"in t&&!xr(t.pointIdAccessor,e.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?wr(this.config.pointIdAccessor):void 0,o=!0),"candlestick"===this.config.chartType&&(n||"openAccessor"in t&&!xr(t.openAccessor,e.openAccessor)||"closeAccessor"in t&&!xr(t.closeAccessor,e.closeAccessor)||"highAccessor"in t&&!xr(t.highAccessor,e.highAccessor)||"lowAccessor"in t&&!xr(t.lowAccessor,e.lowAccessor))){const t=null!=this.config.openAccessor,e=null!=this.config.closeAccessor;this.getOpen=t?br(this.config.openAccessor,"open"):void 0,this.getHigh=br(this.config.highAccessor,"high"),this.getLow=br(this.config.lowAccessor,"low"),this.getClose=e?br(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!e,o=!0,r=!0}if("accessorRevision"in t&&t.accessorRevision!==e.accessorRevision&&(o=!0,r=!0),!o){const i=Object.keys(t).filter(t=>!t.endsWith("Accessor")&&"timeAccessor"!==t&&"valueAccessor"!==t);for(const r of i)if(t[r]!==e[r]){o=!0;break}}o&&(r&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(i)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};In.GROUP_COLOR_MAP_CAP=1e3;var Wn=In;Mn(Wn);var Yn=c(require("react")),qn=require("d3-shape"),Xn=require("react/jsx-runtime");function Gn(t){return"object"==typeof t&&null!==t&&"hatch"===t.type}function Vn(t,e){const{background:i="transparent",stroke:o="#000",lineWidth:r=1.5,spacing:n=6,angle:s=45,lineOpacity:a=1}=t,c=Math.max(8,Math.ceil(2*n));return(0,Xn.jsxs)("pattern",{id:e,width:c,height:c,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[i&&"transparent"!==i&&(0,Xn.jsx)("rect",{width:c,height:c,fill:i}),(0,Xn.jsx)("line",{x1:0,y1:0,x2:0,y2:c,stroke:o,strokeWidth:r,strokeOpacity:a}),(0,Xn.jsx)("line",{x1:n,y1:0,x2:n,y2:c,stroke:o,strokeWidth:r,strokeOpacity:a})]},e)}function Hn(t,e,i="#4e79a7"){if(Gn(t)){const i=function(t,e){let i=2166136261;const o=function(t){return["hatch",t.background??"transparent",t.stroke??"#000",t.lineWidth??1.5,t.spacing??6,t.angle??45,t.lineOpacity??1].join("|")}(e);for(let t=0;o.length>t;t++)i^=o.charCodeAt(t),i=Math.imul(i,16777619);return`${t}-hatch-${(i>>>0).toString(36)}`}(e,t);return{fill:`url(#${i})`,def:Vn(t,i)}}return t&&"string"==typeof t?{fill:t}:{fill:i}}var Zn=require("d3-shape");function Un(t){switch(t){case"monotoneX":return Zn.curveMonotoneX;case"monotoneY":return Zn.curveMonotoneY;case"cardinal":return Zn.curveCardinal;case"catmullRom":return Zn.curveCatmullRom;case"step":return Zn.curveStep;case"stepBefore":return Zn.curveStepBefore;case"stepAfter":return Zn.curveStepAfter;case"basis":return Zn.curveBasis;case"natural":return Zn.curveNatural;default:return null}}var Kn=(t,e)=>({x:t*Math.cos(e),y:t*Math.sin(e)});function Qn(t){const{innerRadius:e,outerRadius:i,startAngle:o,endAngle:r}=t,n=0>=e;if(0>=(t.cornerRadius??0)||!t.roundStart&&!t.roundEnd){if(n){const t=Kn(i,o),e=Kn(i,r);return`M0,0 L${t.x},${t.y} A${i},${i} 0 ${r-o>Math.PI?1:0} 1 ${e.x},${e.y} Z`}const t=Kn(i,o),s=Kn(i,r),a=Kn(e,r),c=Kn(e,o),l=r-o>Math.PI?1:0;return`M${t.x},${t.y} A${i},${i} 0 ${l} 1 ${s.x},${s.y} L${a.x},${a.y} A${e},${e} 0 ${l} 0 ${c.x},${c.y} Z`}const s=Math.max(0,Math.min(t.cornerRadius??0,(i-e)/2));if(0===s)return Qn({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const a=Math.asin(Math.min(1,s/Math.max(1e-9,i-s))),c=n?0:Math.asin(Math.min(1,s/Math.max(1e-9,e+s))),l=r-o,u=t.roundStart&&t.roundEnd?l/2:l,h=!!t.roundStart&&u>a,d=!!t.roundEnd&&u>a;if(!h&&!d)return Qn({...t,cornerRadius:0,roundStart:!1,roundEnd:!1});const f=o+(h?a:0),p=r-(d?a:0),y=o+(h?c:0),g=r-(d?c:0),m=Kn(i,f),x=Kn(i,p),b=(i-s)*Math.cos(a),v=Kn(b,o),w=Kn(b,r),k=n?null:Kn(e,g),S=n?null:Kn(e,y),A=n?0:(e+s)*Math.cos(c),M=n?null:Kn(A,o),_=n?null:Kn(A,r),P=p-f>Math.PI?1:0,L=n?0:g-y>Math.PI?1:0;let R="";if(h)R+=`M${v.x},${v.y}`,R+=` A${s},${s} 0 0 1 ${m.x},${m.y}`;else{const t=Kn(i,o);R+=`M${t.x},${t.y}`}if(d)R+=` A${i},${i} 0 ${P} 1 ${x.x},${x.y}`,R+=` A${s},${s} 0 0 1 ${w.x},${w.y}`;else{const t=Kn(i,r);R+=` A${i},${i} 0 ${P} 1 ${t.x},${t.y}`}if(n)R+=" L0,0";else{if(d)R+=` L${_.x},${_.y}`,R+=` A${s},${s} 0 0 1 ${k.x},${k.y}`;else{const t=Kn(e,r);R+=` L${t.x},${t.y}`}if(h)R+=` A${e},${e} 0 ${L} 0 ${S.x},${S.y}`,R+=` A${s},${s} 0 0 1 ${M.x},${M.y}`;else{const t=Kn(e,o);R+=` A${e},${e} 0 ${L} 0 ${t.x},${t.y}`}}return R+=" Z",R}var Jn=[40,40],ts=[.5,.5];function es(t,e,i,o){if("none"!==t)return"color"===t||null==t?e??o:"accent"===t?i:t}var is=require("react/jsx-runtime"),os={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function rs(t,e="#4e79a7"){return Gn(t)?t.background&&"transparent"!==t.background?t.background:e:t&&"string"==typeof t?t:e}function ns(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"s_"+e:e}function ss(t,e,i,o){const r=t.glyph;if(!r?.parts?.length||0>=t.size)return null;const n=function(t,e){const[i,o]=t.viewBox??Jn,[r,n]=t.anchor??ts,s=o>0?o:1,a=Math.max(0,e)/s,c=(i>0?i:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-r*c,offsetY:-n*l}}(r,t.size);if(0>=n.scale)return null;const s=`translate(${e},${i})${t.rotation?` rotate(${180*t.rotation/Math.PI})`:""} translate(${n.offsetX},${n.offsetY}) scale(${n.scale})`,a=t.color??("string"==typeof t.style.fill?t.style.fill:void 0),c=function(t,e,i=0,o="horizontal"){const[r,n]=t.viewBox??Jn,s=Math.min(1,Math.max(0,i)),a=Math.min(1,Math.max(0,e));return a>s?s>0||1>a?"vertical"===o?{x:0,y:n*(1-a),width:r,height:n*(a-s)}:{x:r*s,y:0,width:r*(a-s),height:n}:null:{x:0,y:0,width:0,height:0}}(r,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal"),l=c?ns(o+"-clip"):void 0,u=(t.style.opacity??1)*(t._decayOpacity??1)*(t.style.fillOpacity??1),h=e=>r.parts.map((i,o)=>{const r=e?"none"===i.fill?void 0:e:es(i.fill,a,t.accent),n=e?i.stroke&&"none"!==i.stroke?e:void 0:es(i.stroke??"none",a,t.accent);return r||n?(0,is.jsx)("path",{d:i.d,fill:r??"none",stroke:n,strokeWidth:n?i.strokeWidth??1:void 0,strokeLinecap:i.strokeLinecap,strokeLinejoin:i.strokeLinejoin,opacity:i.opacity},o):null});return(0,is.jsxs)("g",{transform:s,opacity:1===u?void 0:u,children:[c&&l&&(0,is.jsx)("clipPath",{id:l,children:(0,is.jsx)("rect",{x:c.x,y:c.y,width:c.width,height:c.height})}),c&&t.ghostColor?(0,is.jsx)("g",{children:h(t.ghostColor)}):null,c&&l?(0,is.jsx)("g",{clipPath:`url(#${l})`,children:h()}):h()]},o)}var as=c(require("react")),cs=require("d3-shape"),ls=require("react/jsx-runtime"),us=c(require("react")),hs=require("react/jsx-runtime"),ds=require("react/jsx-runtime");function fs(t,e,i){const o=en(t.symbolType,t.size,t.path);return(0,ds.jsx)("path",{d:o,transform:t.rotation?`translate(${t.x},${t.y}) rotate(${180*t.rotation/Math.PI})`:`translate(${t.x},${t.y})`,fill:t.style.fill?rs(t.style.fill):"none",fillOpacity:t.style.fillOpacity,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},`${i??""}symbol-${e}`)}function ps(t){const e=t.filter(t=>Number.isFinite(t.offset)).map(t=>({offset:Math.max(0,Math.min(1,t.offset)),color:t.color}));return 2>e.length?null:e.map((t,e)=>(0,ds.jsx)("stop",{offset:t.offset,stopColor:t.color},e))}function ys(t,e,i){if(!t||2>e.length)return null;const o=ps(t.colorStops);return o?(0,ds.jsx)("linearGradient",{id:i,gradientUnits:"userSpaceOnUse",x1:e[0][0],y1:0,x2:e[e.length-1][0],y2:0,children:o}):null}function gs(t,e,i){switch(t.type){case"line":{const o=t;if(0===o.path.length)return null;const r=Un(o.curve),n=r?(0,qn.line)().x(([t])=>t).y(([,t])=>t).curve(r)(o.path)??"":"M"+o.path.map(([t,e])=>`${t},${e}`).join("L"),s=ns(`${i?i+"-":""}line-${e}-stroke-gradient`),a=ys(o.strokeGradient,o.path,s);return(0,ds.jsxs)(Yn.Fragment,{children:[a&&(0,ds.jsx)("defs",{children:a}),(0,ds.jsx)("path",{d:n,fill:"none",stroke:a?`url(#${s})`:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||2,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity})]},"line-"+e)}case"area":{const o=t;if(0===o.topPath.length)return null;const r=Un(o.curve),n=!r||2>o.topPath.length||2>o.bottomPath.length?`M${o.topPath.map(([t,e])=>`${t},${e}`).join("L")}L${[...o.bottomPath].reverse().map(([t,e])=>`${t},${e}`).join("L")}Z`:(0,qn.area)().x(([t])=>t).y0((t,e)=>o.bottomPath[e][1]).y1(([,t])=>t).curve(r)(o.topPath)??"",s=`${i?i+"-":""}area-${e}-hatch`,a=Gn(o.style.fill)?Vn(o.style.fill,s):void 0,c=ns(`${i?i+"-":""}area-${e}-gradient`),l=function(t,e){const i=t.fillGradient;if(!i||"object"!=typeof i)return null;let o=1/0;for(const[,e]of t.topPath)o=Math.min(o,e);let r=-1/0;for(const[,e]of t.bottomPath)r=Math.max(r,e);if(!Number.isFinite(o)||!Number.isFinite(r))return null;const n=[];if("colorStops"in i){const t=ps(i.colorStops);if(!t)return null;n.push(...t)}else{if(!Number.isFinite(i.topOpacity)||!Number.isFinite(i.bottomOpacity))return null;n.push((0,ds.jsx)("stop",{offset:0,stopColor:rs(t.style.fill),stopOpacity:Math.max(0,Math.min(1,i.topOpacity))},"0")),n.push((0,ds.jsx)("stop",{offset:1,stopColor:rs(t.style.fill),stopOpacity:Math.max(0,Math.min(1,i.bottomOpacity))},"1"))}return(0,ds.jsx)("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:0,y1:o,x2:0,y2:r,children:n})}(o,c),u=l?`url(#${c})`:a?`url(#${s})`:rs(o.style.fill),h=l?void 0:o.style.fillOpacity??o.style.opacity??.7,d=r?(0,qn.line)().x(([t])=>t).y(([,t])=>t).curve(r)(o.topPath)??"":"M"+o.topPath.map(([t,e])=>`${t},${e}`).join("L"),f=ns(`${i?i+"-":""}area-${e}-stroke-gradient`),p=ys(o.strokeGradient,o.topPath,f),y=o.style.stroke&&"none"!==o.style.stroke?(0,ds.jsx)("path",{d:d,fill:"none",stroke:p?`url(#${f})`:rs(o.style.stroke),strokeWidth:o.style.strokeWidth||2,opacity:o.style.opacity}):null;if(o.clipRect){const t=`${i?i+"-":""}area-clip-${e}`;return(0,ds.jsxs)("g",{children:[(0,ds.jsxs)("defs",{children:[l,!l&&a,p,(0,ds.jsx)("clipPath",{id:t,children:(0,ds.jsx)("rect",{x:o.clipRect.x,y:o.clipRect.y,width:o.clipRect.width,height:o.clipRect.height})})]}),(0,ds.jsxs)("g",{clipPath:`url(#${t})`,children:[(0,ds.jsx)("path",{d:n,fill:u,fillOpacity:h,opacity:l?o.style.opacity:void 0,stroke:"none"}),y]})]},"area-"+e)}return(0,ds.jsxs)(Yn.Fragment,{children:[(l||a||p)&&(0,ds.jsxs)("defs",{children:[l,!l&&a,p]}),(0,ds.jsx)("path",{d:n,fill:u,fillOpacity:h,opacity:l?o.style.opacity:void 0,stroke:"none"}),y]},"area-"+e)}case"point":{const o=t,r=`${i?i+"-":""}point-${e}-hatch`,n=Gn(o.style.fill)?Vn(o.style.fill,r):void 0;return(0,ds.jsxs)(Yn.Fragment,{children:[n&&(0,ds.jsx)("defs",{children:n}),(0,ds.jsx)("circle",{cx:o.x,cy:o.y,r:o.r,fill:n?`url(#${r})`:rs(o.style.fill),opacity:o.style.opacity??o.style.fillOpacity??.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"point-"+e)}case"symbol":return fs(t,e);case"glyph":return ss(t,t.x,t.y,`${i??""}glyph-${t.pointId??e}`);case"rect":{const o=t,r=`${i?i+"-":""}xyrect-${e}-hatch`,n=Gn(o.style.fill)?Vn(o.style.fill,r):void 0;return(0,ds.jsxs)(Yn.Fragment,{children:[n&&(0,ds.jsx)("defs",{children:n}),(0,ds.jsx)("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:n?`url(#${r})`:rs(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},"rect-"+e)}case"heatcell":{const i=t;if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){const t=i.valueFormat?i.valueFormat(i.value):Number.isInteger(i.value)?i.value+"":100>Math.abs(i.value)?1>Math.abs(i.value)?i.value.toPrecision(3):i.value.toFixed(1):i.value.toFixed(0),[o,r,n]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(i.fill),s=.299*o+.587*r+.114*n>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));return(0,ds.jsxs)("g",{children:[(0,ds.jsx)("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill}),(0,ds.jsx)("text",{x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:a+"px",children:t})]},"heatcell-"+e)}return(0,ds.jsx)("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill},"heatcell-"+e)}case"candlestick":{const i=t,o=Math.min(i.openY,i.closeY),r=Math.max(Math.abs(i.openY-i.closeY),1),n=i.isUp?i.upColor:i.downColor;return(0,ds.jsxs)("g",{children:[(0,ds.jsx)("line",{x1:i.x,y1:i.highY,x2:i.x,y2:i.lowY,stroke:i.wickColor,strokeWidth:i.wickWidth}),(0,ds.jsx)("rect",{x:i.x-i.bodyWidth/2,y:o,width:i.bodyWidth,height:r,fill:n,stroke:n,strokeWidth:1})]},"candle-"+e)}default:return null}}function ms(t){return 1e6>t?1e4>t?1e3>t?t+"":(t/1e3).toFixed(1)+"K":(t/1e3).toFixed(0)+"K":(t/1e6).toFixed(1)+"M"}function xs(t,e){const i=t.datum;if(!i)return null;const o=[],r=i.__funnelStepLabel,n=Number(i.__funnelStepLabelX),s=Number(i.__funnelStepLabelY),a=Number(i.__funnelRowWidth);"string"!=typeof r||!Number.isFinite(n)||!Number.isFinite(s)||Number.isFinite(a)&&8.4*r.length+16>a||o.push((0,ds.jsx)("text",{x:n,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},e+"-funnel-step"));const c=Number(i.__funnelValue),l=Number(i.__funnelValueLabelX),u=Number(i.__funnelValueLabelY),h=Number(i.__funnelBarW);if(Number.isFinite(c)&&0!==c&&Number.isFinite(l)&&Number.isFinite(u)&&h>=60){const t=Number(i.__funnelPercent);let r=!0!==i.__funnelIsFirstStep&&Number.isFinite(t)?`${ms(c)} (${.05>Math.abs(t-Math.round(t))?Math.round(t):t.toFixed(1)}%)`:ms(c);7.8*r.length+16>h&&(r=ms(c)),7.8*r.length+16>h||o.push((0,ds.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},e+"-funnel-value"))}return o.length?(0,ds.jsx)("g",{children:o},e+"-funnel-labels"):null}function bs(t,e,i){const o=("category"in t?t.category:void 0)||("group"in t?t.group:void 0)||"",r=i=>`ord-${t.type}-${o}-${e}-${i}`,n=`ord-${t.type}-${o}-${e}`;switch(t.type){case"rect":{const e=t,i=ns(n)+"-grad",o=function(t,e){const i=t.fillGradient;if(!i||"object"!=typeof i)return null;let o=t.x,r=t.y,n=t.x,s=t.y+t.h;"bottom"===t.roundedEdge?(r=t.y+t.h,s=t.y):"right"===t.roundedEdge?(o=t.x+t.w,r=t.y,n=t.x,s=t.y):"left"===t.roundedEdge&&(o=t.x,r=t.y,n=t.x+t.w,s=t.y);const a=[];if("colorStops"in i){const t=ps(i.colorStops);if(!t)return null;a.push(...t)}else{const e=rs(t.style.fill);a.push((0,ds.jsx)("stop",{offset:0,stopColor:e,stopOpacity:i.topOpacity},"0")),a.push((0,ds.jsx)("stop",{offset:1,stopColor:e,stopOpacity:i.bottomOpacity},"1"))}return(0,ds.jsx)("linearGradient",{id:e,gradientUnits:"userSpaceOnUse",x1:o,y1:r,x2:n,y2:s,children:a})}(e,i);let r,a;if(o)a=`url(#${i})`;else if(Gn(e.style.fill)){const t=ns(n)+"-hatch";r=Vn(e.style.fill,t),a=`url(#${t})`}else a=rs(e.style.fill);const c=o||r?(0,ds.jsxs)("defs",{children:[o,r]}):null;if(e.cornerRadii&&(((s=e.cornerRadii).tl??0)>0||(s.tr??0)>0||(s.br??0)>0||(s.bl??0)>0)){const t=function(t){const{x:e,y:i,w:o,h:r}=t,{tl:n,tr:s,br:a,bl:c}=function(t){const e=t.cornerRadii;if(!e)return{tl:0,tr:0,br:0,bl:0};const i=Math.min(t.w,t.h)/2,o=t=>Math.max(0,Math.min(t??0,i));return{tl:o(e.tl),tr:o(e.tr),br:o(e.br),bl:o(e.bl)}}(t);let l=`M${e+n},${i}`;return l+=` L${e+o-s},${i}`,s>0&&(l+=` A${s},${s} 0 0 1 ${e+o},${i+s}`),l+=` L${e+o},${i+r-a}`,a>0&&(l+=` A${a},${a} 0 0 1 ${e+o-a},${i+r}`),l+=` L${e+c},${i+r}`,c>0&&(l+=` A${c},${c} 0 0 1 ${e},${i+r-c}`),l+=` L${e},${i+n}`,n>0&&(l+=` A${n},${n} 0 0 1 ${e+n},${i}`),l+=" Z",l}(e);return(0,ds.jsxs)(Yn.Fragment,{children:[c,(0,ds.jsx)("path",{d:t,fill:a,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},n)}if(e.roundedTop&&e.roundedTop>0){const t=Math.min(e.roundedTop,e.w/2,e.h/2),{x:i,y:o,w:r,h:s}=e;let l;switch(e.roundedEdge){case"right":l=`M${i},${o} L${i+r-t},${o} A${t},${t} 0 0 1 ${i+r},${o+t} L${i+r},${o+s-t} A${t},${t} 0 0 1 ${i+r-t},${o+s} L${i},${o+s} Z`;break;case"left":l=`M${i+r},${o} L${i+t},${o} A${t},${t} 0 0 0 ${i},${o+t} L${i},${o+s-t} A${t},${t} 0 0 0 ${i+t},${o+s} L${i+r},${o+s} Z`;break;case"bottom":l=`M${i},${o} L${i+r},${o} L${i+r},${o+s-t} A${t},${t} 0 0 1 ${i+r-t},${o+s} L${i+t},${o+s} A${t},${t} 0 0 1 ${i},${o+s-t} Z`;break;default:l=`M${i},${o+s} L${i},${o+t} A${t},${t} 0 0 1 ${i+t},${o} L${i+r-t},${o} A${t},${t} 0 0 1 ${i+r},${o+t} L${i+r},${o+s} Z`}return(0,ds.jsxs)(Yn.Fragment,{children:[c,(0,ds.jsx)("path",{d:l,fill:a,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},n)}return(0,ds.jsxs)(Yn.Fragment,{children:[c,(0,ds.jsx)("rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:a,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth}),xs(e,n)]},n)}case"point":{const e=t;return(0,ds.jsx)("circle",{cx:e.x,cy:e.y,r:e.r,fill:rs(e.style.fill),opacity:e.style.opacity??e.style.fillOpacity??.8,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},n)}case"symbol":return fs(t,e,i);case"glyph":return ss(t,t.x,t.y,`${i??""}ord-glyph-${t.pointId??e}`);case"wedge":{const o=t;if(o._gradientBand&&o._gradientBand.colors.length>0){const t=ns(`${i?i+"-":""}gauge-grad-${o.category||n}-${e}`),{clipPath:r,slices:s}=function(t){const e=Qn({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundStart,roundEnd:t.roundEnd}),i=[],o=t.colors;if(o.length>0){const e=(t.endAngle-t.startAngle)/o.length;for(let r=0;o.length>r;r++)i.push({d:Qn({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+r*e,endAngle:t.endAngle}),color:o[r]})}return{clipPath:e,slices:i}}({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,ds.jsxs)("g",{transform:`translate(${o.cx},${o.cy})`,opacity:o.style.opacity,fillOpacity:o.style.fillOpacity,children:[(0,ds.jsx)("defs",{children:(0,ds.jsx)("clipPath",{id:t,children:(0,ds.jsx)("path",{d:r})})}),(0,ds.jsx)("g",{clipPath:`url(#${t})`,children:s.map((t,e)=>(0,ds.jsx)("path",{d:t.d,fill:rs(t.color)},e))}),o.style.stroke&&"none"!==o.style.stroke&&(0,ds.jsx)("path",{d:r,fill:"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},n)}let r;if(o.roundedEnds)r=Qn({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 t=(0,qn.arc)().innerRadius(o.innerRadius).outerRadius(o.outerRadius).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2);o.cornerRadius&&t.cornerRadius(o.cornerRadius),r=t(os)||""}return(0,ds.jsx)("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:rs(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},n)}case"boxplot":{const e=t,i=e.columnWidth/2;return(0,ds.jsxs)("g","vertical"===e.projection?{children:[(0,ds.jsx)("line",{x1:e.x,y1:e.minPos,x2:e.x,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1}),(0,ds.jsx)("rect",{x:e.x-i,y:Math.min(e.q1Pos,e.q3Pos),width:e.columnWidth,height:Math.abs(e.q3Pos-e.q1Pos),fill:rs(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:1}),(0,ds.jsx)("line",{x1:e.x-i,y1:e.medianPos,x2:e.x+i,y2:e.medianPos,stroke:e.style.stroke||"#333",strokeWidth:2}),(0,ds.jsx)("line",{x1:e.x-.5*i,y1:e.minPos,x2:e.x+.5*i,y2:e.minPos,stroke:e.style.stroke||"#333",strokeWidth:1}),(0,ds.jsx)("line",{x1:e.x-.5*i,y1:e.maxPos,x2:e.x+.5*i,y2:e.maxPos,stroke:e.style.stroke||"#333",strokeWidth:1})]}:{children:[(0,ds.jsx)("line",{x1:e.minPos,y1:e.y,x2:e.maxPos,y2:e.y,stroke:e.style.stroke||"#333",strokeWidth:1}),(0,ds.jsx)("rect",{x:Math.min(e.q1Pos,e.q3Pos),y:e.y-i,width:Math.abs(e.q3Pos-e.q1Pos),height:e.columnWidth,fill:rs(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:1}),(0,ds.jsx)("line",{x1:e.medianPos,y1:e.y-i,x2:e.medianPos,y2:e.y+i,stroke:e.style.stroke||"#333",strokeWidth:2}),(0,ds.jsx)("line",{x1:e.minPos,y1:e.y-.5*i,x2:e.minPos,y2:e.y+.5*i,stroke:e.style.stroke||"#333",strokeWidth:1}),(0,ds.jsx)("line",{x1:e.maxPos,y1:e.y-.5*i,x2:e.maxPos,y2:e.y+.5*i,stroke:e.style.stroke||"#333",strokeWidth:1})]},n)}case"violin":{const e=t,i=[(0,ds.jsx)("path",{d:e.pathString,transform:e.translateX||e.translateY?`translate(${e.translateX},${e.translateY})`:void 0,fill:rs(e.style.fill),fillOpacity:e.style.fillOpacity??.6,stroke:e.style.stroke||"#333",strokeWidth:e.style.strokeWidth||1},r("path"))];if(e.iqrLine&&e.bounds){const t=e.bounds,o=t.x+t.width/2,n=t.y+t.height/2;e.iqrLine.isVertical?i.push((0,ds.jsx)("line",{x1:o,y1:e.iqrLine.q1Pos,x2:o,y2:e.iqrLine.q3Pos,stroke:e.style.stroke||"#333",strokeWidth:2},r("iqr")),(0,ds.jsx)("circle",{cx:o,cy:e.iqrLine.medianPos,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},r("med"))):i.push((0,ds.jsx)("line",{x1:e.iqrLine.q1Pos,y1:n,x2:e.iqrLine.q3Pos,y2:n,stroke:e.style.stroke||"#333",strokeWidth:2},r("iqr")),(0,ds.jsx)("circle",{cx:e.iqrLine.medianPos,cy:n,r:3,fill:"white",stroke:e.style.stroke||"#333",strokeWidth:1},r("med")))}return(0,ds.jsx)("g",{children:i},n)}case"connector":return(0,ds.jsx)("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity??.5},n);case"trapezoid":{const e=t,i=e.points.map(t=>`${t[0]},${t[1]}`).join(" ");return(0,ds.jsx)("polygon",{points:i,fill:rs(e.style.fill,"#999"),opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},n)}default:return null}var s}var vs=new Set;function ws(t){const{node:e,index:i,renderMode:o,fallback:r}=t,n=function(t,e){const i="function"==typeof t?t(e.datum??null,e):t;return(o=i)&&"object"==typeof o&&"string"==typeof o.id&&"function"==typeof o.cacheKey&&"function"==typeof o.drawCanvas&&"function"==typeof o.renderStaticSVG?i:void 0;var o}(o,e);if(!n)return r();const s=n.renderStaticSVG({node:e,style:e.style??{},key:`${n.id}-${i}`});return null!=s?s:(function(t,e){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const i=`${t}:${e}`;vs.has(i)||(vs.add(i),console.warn(`[Semiotic] Render backend "${t}" does not support scene node "${e}"; using the built-in renderer.`))}(n.id,e.type??"unknown"),r())}function ks(t){const e=[];return t.nodes.forEach((i,o)=>{const r=ws({node:i,index:o,renderMode:t.renderMode,fallback:()=>t.fallback(i,o)});null!=r&&!1!==r&&e.push({node:i,element:r})}),e}var Ss=require("d3-scale"),As=require("react/jsx-runtime"),Ms=re;function _s(t,e,i){if(e&&"object"==typeof e&&!Array.isArray(e)){const t=e;return e=>J(t,e)??"#999"}const o=Array.isArray(e)?e:i.colors.categorical.length>0?i.colors.categorical:A;return(0,Ss.scaleOrdinal)().domain(t).range(o)}function Ps(t){return"left"===t?"start":"right"===t?"end":t??"start"}function Ls(t){return Number(t.typography.legendSize??t.typography.labelSize??t.typography.tickSize)||11}function Rs(t,e,i,o){const r=Ls(o);return e+i+Math.ceil(t.length*r*.58)}function Ts(t){const{categories:e,theme:i,position:o="right",totalWidth:r,margin:n,legendLayout:s}=t,{swatchSize:a,labelGap:c,itemGap:l,rowHeight:u}=ne(s),h=a+c,d="top"===o||"bottom"===o,f=Math.max(a,r-n.left-n.right),p=e.map(t=>Rs(t,a,c,i));if(d){const t=Math.max(a,s?.maxWidth??f),i=[];let o=0,r=0;p.forEach((e,n)=>{const s=0===r?e:r+l+e;r>0&&s>t?(i.push({start:o,end:n,width:r}),o=n,r=e):r=s}),e.length>0&&i.push({start:o,end:e.length,width:r});const n=Ps(s?.align),c=[];return i.forEach((i,o)=>{let r="center"===n?Math.max(0,(t-i.width)/2):"end"===n?Math.max(0,t-i.width):0;for(let t=i.start;i.end>t;t++)c.push({category:e[t],width:p[t],x:r,y:o*u}),r+=p[t]+l}),{items:c,width:Math.max(0,...i.map(t=>t.width)),height:i.length*u,swatchSize:a,labelOffset:h,swatchRadius:0}}const y=Math.max(0,...p);return{items:e.map((t,e)=>({category:t,width:p[e],x:0,y:e*u})),width:y,height:e.length*u,swatchSize:a,labelOffset:h,swatchRadius:0}}function Cs(t){const{legendGroups:e,theme:i,position:o="right",totalWidth:r,margin:n,legendLayout:s}=t,{swatchSize:a,labelGap:c,rowHeight:l}=ne(s),u=a+c,h=Math.max(12,Ls(i)),d="top"===o||"bottom"===o,f=Math.max(a,r-n.left-n.right);if(d){const o=Math.max(a,s?.maxWidth??f),r=Ps(s?.align);let n=0,c=0;const l=[];for(const r of e){const e=r.items.map(t=>t.label),u=Ts({...t,categories:e,legendLayout:{...s,maxWidth:Math.max(a,o-h-8),align:"start"}}),d=r.label?h:0,f=r.label?Rs(r.label,0,0,i):0,p=d>0?d+8:0,y=p+u.width,g=Math.max(u.height,f);l.push({group:r,x:n,y:0,itemOffsetX:p,itemOffsetY:0,width:y,height:g,items:u.items}),n+=y+12,c=Math.max(c,g)}const d=l.length>0?n-12:0,p=d>o?0:"center"===r?Math.max(0,(o-d)/2):"end"===r?Math.max(0,o-d):0;return{groups:l.map(t=>({...t,x:t.x+p})),width:d,height:c,swatchSize:a,labelOffset:u,swatchRadius:0}}const p=se(e.map(t=>({hasLabel:!!t.label,itemCount:t.items.length})),l);let y=0;return{groups:e.map((t,e)=>{const o=t.items.map(t=>Rs(t.label,a,c,i)),r=Math.max(0,...o,t.label?Rs(t.label,0,0,i):0);return y=Math.max(y,r),{group:t,x:0,y:p[e].itemsY,itemOffsetX:0,itemOffsetY:0,width:r,height:t.items.length*l,items:t.items.map((t,e)=>({category:t.label,width:o[e],x:0,y:e*l}))}}),width:y,height:p.at(-1)?.endY??0,swatchSize:a,labelOffset:u,swatchRadius:0}}function $s(t){const e="top"===t.position||"bottom"===t.position,i=Math.max(1,t.totalWidth-t.margin.left-t.margin.right);return e?{width:Math.min(t.legendLayout?.maxWidth??i,200),height:t.gradient.label?34:26,swatchSize:12}:{width:t.gradient.label?86:72,height:t.gradient.label?124:108,swatchSize:14}}function js(t,e){if(!e||!t||0===t.length)return[];const i="function"==typeof e?e:t=>t[e],o=new Set;for(const e of t){const t=i(e);null!=t&&o.add(t+"")}return Array.from(o)}var zs=require("react/jsx-runtime");function Es(t,e=120,i=8){if(!t)return[];const o=Math.max(1,Math.floor(e/i)),r=t.split(/\s+/),n=[];let s="";for(const t of r)s&&s.length+1+t.length>o?(n.push(s),s=t):s=s?`${s} ${t}`:t;return s&&n.push(s),n}function Ds(t,e,i,o){return"curly"===t?o?`M0,0 C${.6*i},0 ${.4*i},${e/2} ${i},${e/2} C${.4*i},${e/2} ${.6*i},${e} 0,${e}`:`M0,0 C0,${.6*i} ${e/2},${.4*i} ${e/2},${i} C${e/2},${.4*i} ${e},${.6*i} ${e},0`:o?`M0,0 L${i},0 L${i},${e} L0,${e}`:`M0,0 L0,${i} L${e},${i} L${e},0`}function Fs(t,e,i,o){if(!t)return(0,zs.jsx)("g",{className:"annotation-note"});const{label:r,title:n,orientation:s,align:a,wrap:c=120,noWrap:l}=t;if(!r&&!n)return(0,zs.jsx)("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(e)>Math.abs(i)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===u?0>e?"right":"left":0>i?"bottom":"top");let d="start";"topBottom"===u?"right"===h?d="end":"middle"===h&&(d="middle"):d=0>e?"end":"start";const f=16,p=n?l?[n]:Es(n,c):[],y=r?l?[r]:Es(r,c):[],g="leftRight"===u?"end"===d?-4:4:0;let m=0;const x=[],b=o||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";t.useHTML||t.html?x.push((0,zs.jsx)("foreignObject",{className:"annotation-note-html",x:"end"===d?g-c:"middle"===d?g-c/2:g,y:-16,width:c,height:Math.max(f,(p.length+y.length)*f+(n&&r?2:0))+f,style:{overflow:"visible"},children:(0,zs.jsxs)("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:b,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===d?"right":"middle"===d?"center":"left",whiteSpace:l?"nowrap":"normal",wordBreak:"break-word"},children:[n&&(0,zs.jsx)("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:n}),r&&(0,zs.jsx)("div",{className:"annotation-note-label",children:r})]})},"annotation-note-html")):(p.length>0&&(x.push((0,zs.jsx)("text",{className:"annotation-note-title",fill:b,textAnchor:d,fontWeight:"bold",children:p.map((t,e)=>(0,zs.jsx)("tspan",{x:g,dy:0===e?0:f,children:t},e))},"annotation-note-title")),m=p.length*f),y.length>0&&x.push((0,zs.jsx)("text",{className:"annotation-note-label",fill:b,textAnchor:d,y:m,children:y.map((t,e)=>(0,zs.jsx)("tspan",{x:g,dy:0===e?0:f,children:t},e))},"annotation-note-label")));let v=null;if((n||r)&&(0!==e||0!==i))if("topBottom"===u){const t=Math.min(c,120);let e=0,i=t;"end"===d?(e=-t,i=0):"middle"===d&&(e=-t/2,i=t/2),v=(0,zs.jsx)("line",{className:"note-line",x1:e,x2:i,y1:0,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(p.length+y.length)*f+(y.length>0?f:0);let e=0,i=t;"bottom"===h?(e=-t,i=0):"middle"===h&&(e=-t/2,i=t/2),v=(0,zs.jsx)("line",{className:"note-line",x1:0,x2:0,y1:e,y2:i,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>i?-(w+2):18:"leftRight"===u&&(k="middle"===h?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===h||0>i?-(w+2):18),(0,zs.jsxs)("g",{className:"annotation-note",transform:`translate(${e},${i})`,children:[(0,zs.jsx)("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0,children:x}),v]})}function Os(t,e,i,o,r){const n=[];switch(t){case"callout-circle":{const t=(e?.radius||0)+(e?.radiusPadding||0);t>0&&n.push((0,zs.jsx)("circle",{r:t,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const t=e?.width||0,o=e?.height||0;(t>0||o>0)&&n.push((0,zs.jsx)("rect",{width:t,height:o,fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":e?.custom&&n.push(...Array.isArray(e.custom)?e.custom:[e.custom]);break;case"xy-threshold":{const t=o||0,s=r||0;if(void 0!==e?.x){const o=(e.x||0)-t;n.push((0,zs.jsx)("line",{x1:o,y1:(e.y1||0)-s,x2:o,y2:(e.y2||0)-s,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==e?.y){const o=(e.y||0)-s;n.push((0,zs.jsx)("line",{x1:(e.x1||0)-t,y1:o,x2:(e.x2||0)-t,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==e?.x1||void 0!==e?.x2?n.push((0,zs.jsx)("line",{x1:(e.x1||0)-t,y1:0,x2:(e.x2||0)-t,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===e?.y1&&void 0===e?.y2||n.push((0,zs.jsx)("line",{x1:0,y1:(e.y1||0)-s,x2:0,y2:(e.y2||0)-s,stroke:i||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const t=e?.type||"curly",o=e?.width??e?.height;void 0!==o&&n.push((0,zs.jsx)("path",{d:Ds(t,o,e?.depth||30,void 0===e?.width),fill:"none",stroke:i||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return(0,zs.jsx)("g",{className:"annotation-subject",children:n})}function Ns(t,e,i,o,r,n){const s=[];let a=0,c=0;if("callout-circle"!==r&&"label"!==r||!n?.radius){if("callout-rect"===r&&n){const i=n.width||0,o=n.height||0;if(i>0||o>0){const r=i/2,n=o/2,s=t-r,l=e-n;if(0!==s||0!==l){const t=Math.abs(s),e=Math.abs(l),u=i/2,h=o/2,d=t*h>e*u?u/t:h/e;a=r+s*d,c=n+l*d}}}else if("bracket"===r&&n){const t=n.width,e=n.height,i=n.depth||30;void 0!==t?(a=t/2,c=i):void 0!==e&&(a=i,c=e/2)}}else{const i=(n.radius||0)+(n.radiusPadding||0);if(i>0&&(0!==t||0!==e)){const o=Math.atan2(e,t);a=Math.cos(o)*i,c=Math.sin(o)*i}}const l=Math.sqrt((t-a)**2+(e-c)**2);if(l>.5){const r=o||"var(--semiotic-text-secondary, currentColor)",n="curve"===i?.type;let u=Math.atan2(e-c,t-a);if(n){const o=(a+t)/2,n=(c+e)/2,h=-(e-c)/l,d=(t-a)/l,f=(i?.curve??.25)*l,p=o+h*f,y=n+d*f;s.push((0,zs.jsx)("path",{className:"connector-curve",d:`M${a},${c}Q${p},${y} ${t},${e}`,fill:"none",stroke:r},"connector-line")),u=Math.atan2(y-c,p-a)}else s.push((0,zs.jsx)("line",{x1:a,y1:c,x2:t,y2:e,stroke:r},"connector-line"));if("arrow"===i?.end){const t=10,e=16/180*Math.PI;s.push((0,zs.jsx)("path",{d:`M${a},${c}L${a+t*Math.cos(u+e)},${c+t*Math.sin(u+e)}L${a+t*Math.cos(u-e)},${c+t*Math.sin(u-e)}Z`,fill:r,stroke:"none"},"connector-arrow"))}}return(0,zs.jsx)("g",{className:"annotation-connector",children:s})}function Bs(t){const{x:e=0,y:i=0,dx:o,dy:r,nx:n,ny:s,note:a,connector:c,subject:l,type:u,color:h,className:d,disable:f,opacity:p,strokeDasharray:y,events:g={},"data-testid":m}=t,x=Array.isArray(e)?e[0]??0:e,b=Array.isArray(i)?i[0]??0:i,v=new Set(Array.isArray(f)?f:[]);let w=o||0,k=r||0;null!=n&&(w=n-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 t=l.depth||30;k=t+(0>t?-5:5)}else if(void 0!==l.height){const t=l.depth||30;w=t+(0>t?-5:5),k=l.height/2}return(0,zs.jsxs)("g",{className:("annotation "+(d||"")).trim(),transform:`translate(${x},${b})`,"data-testid":m,...null!=p&&{opacity:p},...y&&{strokeDasharray:y},...g,children:[!v.has("connector")&&Ns(w,k,c,h,S,l),!v.has("subject")&&Os(S,l,h,x,b),!v.has("note")&&Fs(a,w,k,h)]})}function Is(t){const{noteData:e}=t,{screenCoordinates:i}=e,o="string"==typeof e.type?e.type:"label",r=e.eventListeners||e.events||{};if(e.coordinates&&i){const t=e.nx||i[0][0]+(e.dx??0),r=e.ny||i[0][1]+(e.dy??0),n=i.map((i,n)=>{const s=Object.assign({},e,{note:0===n?e.note:{label:""},x:i[0],y:i[1],nx:t,ny:r});return(0,zs.jsx)(Bs,{"data-testid":"semiotic-annotation",...s,type:o},"multi-annotation-"+n)});return(0,zs.jsx)("g",{children:n})}const n=e.note||{title:"none",label:e.label},s=`${n.label}-${n.title}-${e.i}`;return(0,zs.jsx)(Bs,{"data-testid":"semiotic-annotation",events:r,...e,type:o},s)}var Ws=require("react/jsx-runtime"),Ys={secondary:0,primary:3},qs=1,Xs=2,Gs=.6,Vs="0.88em",Hs=.95,Zs=.72,Us=.06,Ks=".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}}",Qs=".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}";function Js(t){return!0===t?._annotationDeferred}function ta(t){return"blended"===t?.cohesion||"layer"===t?.cohesion?t.cohesion:null}function ea(t){const e=t?.provenance?.confidence;return"number"==typeof e&&Number.isFinite(e)?Math.max(0,Math.min(1,e)):null}function ia(t){return Math.max(Zs,Hs-t*Us)}function oa(t,e){const i=e.scales?.x??e.scales?.time;return i?null!=t.x?i(t.x):e.xAccessor&&null!=t[e.xAccessor]?i(t[e.xAccessor]):null:null}function ra(t,e){const i=e.scales?.y??e.scales?.value;return i?null!=t.y?i(t.y):e.yAccessor&&null!=t[e.yAccessor]?i(t[e.yAccessor]):null:null}function na(t){return null==t?null:t+""}function sa(t,e,i){return e.stickyPositionCache?.set(t,i),i}var aa=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function ca(t){return!!t&&"object"==typeof t&&aa.has(function(t){return"string"==typeof t?.type?t.type:""}(t))}new Set(["label","callout","callout-circle","callout-rect"]);var la=2e4,ua=1;function ha(t){return"primary"===t?.emphasis||!0===t?.defensive}function da(t,e,i={}){return"number"==typeof i.maxAnnotations&&Number.isFinite(i.maxAnnotations)?Math.max(0,Math.floor(i.maxAnnotations)):t>0&&e>0?Math.max(1,Math.round(t*e/(i.areaPerAnnotation&&i.areaPerAnnotation>0?i.areaPerAnnotation:la))):1/0}function fa(t){let e;const i=t?.emphasis;e="primary"===i?100:"secondary"===i?10:50;const o=t?.provenance?.confidence;switch("number"==typeof o&&Number.isFinite(o)&&(e+=15*Math.max(0,Math.min(1,o))),t?.lifecycle?.freshness){case"fresh":e+=8;break;case"aging":e+=4;break;case"stale":e+=1;break;case"expired":e-=200}return e}var pa=32,ya=6,ga=4,ma=8,xa=72,ba=30,va=-30,wa=8,ka=480,Sa=3;var Aa={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function Ma(t){if(!_a(t))return t;const e=("string"==typeof t.mobileText?t.mobileText:void 0)??("string"==typeof t.shortText?t.shortText:void 0);return!e||"string"!=typeof t.label&&null!=t.label?t:{...t,label:e}}function _a(t){return ca(t)}function Pa(t,e){if(!t)return[];const i=Math.max(1,Math.floor(e/7)),o=t.split(/\s+/).filter(Boolean),r=[];let n="";for(const t of o)n&&n.length+t.length+1>i?(r.push(n),n=t):n=n?`${n} ${t}`:t;return n&&r.push(n),r}function La(t,e,i,o,r){const n=t+i,s=e+o;return Math.abs(i)>Math.abs(o)?{x:0>i?n-r.width-4:n+4,y:0>o?s-r.height:s,width:r.width,height:r.height}:{x:0>i?n-r.width:n,y:0>o?s-r.height-4:s+4,width:r.width,height:r.height}}function Ra(t,e){return{x:t.x-e,y:t.y-e,width:t.width+2*e,height:t.height+2*e}}function Ta(t,e){return Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x))*Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y))}function Ca(t,e,i,o,r,n,s,a){const c=Ra(t,s);let l=.4*Math.hypot(e.dx,e.dy)+80*function(t,e,i,o){const r=Math.max(0,o-t.x),n=Math.max(0,o-t.y);return(r+Math.max(0,t.x+t.width-(e-o)))*t.height+(n+Math.max(0,t.y+t.height-(i-o)))*t.width}(c,r,n,a);for(const t of i)l+=12*Ta(c,t);for(const t of o)l+=4*Ta(c,t);return l}function $a(t,e,i){if("widget"===t.type&&"number"==typeof t.px&&"number"==typeof t.py)return{x:t.px,y:t.py};const o=t.pointId??t.nodeId;if(null!=o&&i.pointNodes){const t=i.pointNodes.find(t=>t.pointId===o);if(t)return{x:t.x,y:t.y}}const r=t.coordinates,n=i.scales?.geoProjection;if(Array.isArray(r)&&r.length>=2&&n){const t=r[0],e=r[1];if("number"==typeof t&&"number"==typeof e){const i=n([t,e]);if(i&&"number"==typeof i[0]&&"number"==typeof i[1])return{x:i[0],y:i[1]}}}return i.scales||"number"!=typeof t.x||"number"!=typeof t.y?function(t,e,i){const o=t.anchor||t.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=t.pointId&&i.pointNodes&&i.pointNodes.length>0)for(let o=i.pointNodes.length-1;o>=0;o--){const r=i.pointNodes[o];if(r.pointId===t.pointId)return sa(e,i,{x:r.x,y:r.y})}const o=function(t){const e=t.data;if(!e||0===e.length)return null;const i=e[e.length-1],o=t.scales?.x??t.scales?.time,r=t.scales?.y??t.scales?.value;if(!o||!r)return null;const n=i[t.xAccessor||"x"],s=i[t.yAccessor||"y"];return null==n||null==s?null:{x:o(n),y:r(s)}}(i);return o?sa(e,i,o):null}if("semantic"===o){const o=function(t,e,i){const o=function(t){return na(t.provenance?.stableId??t.stableId)}(t);if(!o)return null;const r=i.pointNodes?.find(t=>na(t.pointId)===o);if(r)return sa(e,i,{x:r.x,y:r.y});const n=i.data?.find(t=>function(t){return na(t.stableId??t.id??t.provenance?.stableId)}(t)===o);if(!n)return null;const s=oa(n,i),a=ra(n,i);return null==s||null==a?null:sa(e,i,{x:s,y:a})}(t,e,i);if(o)return o}let r=null,n=null;if(null!=t.pointId&&i.pointNodes){const e=i.pointNodes.find(e=>e.pointId===t.pointId);e&&(r=e.x,n=e.y)}if(null!=r&&null!=n||(r=oa(t,i),n=ra(t,i)),null!=r&&null!=n)return sa(e,i,{x:r,y:n});if("sticky"===o){const t=i.stickyPositionCache?.get(e);if(t)return t}return null}(t,e,i):{x:t.x,y:t.y}}function ja(t){const{annotations:e,context:i,defaultOffset:o=pa,notePadding:r=ya,markPadding:n=ga,edgePadding:s=ma,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=xa,density:u,progressiveDisclosure:h=!1,redundantCues:d=!1,responsive:f,mobile:p,cohesion:y,audience:g}=t,m=i.width||0,x=i.height||0,b="object"==typeof p?p:{},v=b.breakpoint??ka,w=!!p&&v>=m,k=w&&!1!==b.preferShortText?e.map(Ma):e,S=w&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,A=h||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=[],L=function(t,e){return(t.pointNodes||[]).map(t=>{const i=Math.max(1,t.r||1)+e;return{x:t.x-i,y:t.y-i,width:2*i,height:2*i}})}(i,n);let R=!1;const T=k.map((t,e)=>{if(!_a(t))return t;const n=$a(t,e,i);if(!n)return t;const u=function(t){if("widget"===t.type)return{width:"number"==typeof t.width?t.width:32,height:"number"==typeof t.height?t.height:32};const e="number"==typeof t.wrap?t.wrap:120,i=[...Pa("string"==typeof t.title?t.title:void 0,e),...Pa("string"==typeof t.label?t.label:void 0,e)],o=i.reduce((t,e)=>Math.max(t,e.length),0);return{width:Math.max(24,Math.min(e,7*o)+10),height:Math.max(18,16*i.length+6)}}(t);if(a&&("number"==typeof(h=t).dx||"number"==typeof h.dy)){const e=function(t){return"text"===t.type||"widget"===t.type?{dx:0,dy:0}:{dx:ba,dy:va}}(t);return P.push(Ra(La(n.x,n.y,"number"==typeof t.dx?t.dx:e.dx,"number"==typeof t.dy?t.dy:e.dy,u),r)),t}var h;let d=null,f=1/0;for(const t of function(t){const e=1.6*t;return[{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t},{dx:t,dy:0},{dx:-t,dy:0},{dx:0,dy:-t},{dx:0,dy:t},{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e}]}(o)){const e=Ca(La(n.x,n.y,t.dx,t.dy,u),t,P,L,m,x,r,s);f>e&&(d=t,f=e)}if(!d)return t;const p=Ra(La(n.x,n.y,d.dx,d.dy,u),r);P.push(p);const y=Math.hypot(d.dx,d.dy),g=c&&y>=l&&"text"!==t.type&&"widget"!==t.type?{...t.connector||{end:"arrow"},type:"curve"}:t.connector;return R=!0,{...t,dx:d.dx,dy:d.dy,...g?{connector:g}:{}}}),C=R?T:k.slice();let $=C;if(d){let t=!1;const e=C.map(e=>{const i=function(t){return"text"!==t.type||"string"!=typeof t.color||Math.hypot("number"==typeof t.dx?t.dx:0,"number"==typeof t.dy?t.dy:0)<wa?t:{...t,_redundantConnector:!0}}(e);return i!==e&&(t=!0),i});$=t?e:C}{let t=!1;const e=$.map(e=>{if(!0!==e?.defensive)return e;const i=function(t){const e=t?.provenance;if(!e||"object"!=typeof e)return t;const i="string"==typeof e.source?Aa[e.source]??e.source:null,o="number"==typeof e.confidence&&Number.isFinite(e.confidence)?Math.round(100*Math.max(0,Math.min(1,e.confidence)))+"%":null;if(!i&&!o)return t;if(null!=t.label&&"string"!=typeof t.label)return t;const r=[i,o].filter(Boolean).join(" · "),n="string"==typeof t.label?t.label:"";return n.includes(`(${r})`)?t:{...t,label:n?`${n} (${r})`:`(${r})`}}(e);return i!==e&&(t=!0),i});$=t?e:$}const j=new Set;if(S){const t="object"==typeof S?S:{},e=function(t){if(!t)return 1;const e=function(t){const e=t?.familiarity;if(!e)return Sa;const i=Object.values(e).filter(t=>"number"==typeof t&&Number.isFinite(t));return 0===i.length?Sa:i.reduce((t,e)=>t+e,0)/i.length}(t);return e>2?4>e?1:.6:1.5}(g),i=1===e?t:{...t,maxAnnotations:Math.max(0,Math.round((t.maxAnnotations??da(m,x,t))*e))},{deferred:o}=function(t){const{annotations:e,width:i,height:o}=t,r=Math.max(0,t.minVisible??ua),n=da(i,o,t),s=e.map((t,e)=>{return{annotation:t,index:e,note:(i=t,ca(i))};var i}),a=s.filter(t=>t.note);if(0===a.length||n>=a.length)return{visible:e.slice(),deferred:[],budget:n};const c=a.filter(t=>ha(t.annotation)),l=a.filter(t=>!ha(t.annotation)).sort((t,e)=>fa(e.annotation)-fa(t.annotation)||t.index-e.index),u=Math.min(l.length,Math.max(Math.max(0,n-c.length),Math.max(0,r-c.length))),h=new Set([...c.map(t=>t.index),...l.slice(0,u).map(t=>t.index)]),d=[],f=[];for(const{annotation:t,index:e,note:i}of s)!i||h.has(e)?d.push(t):f.push(t);return{visible:d,deferred:f,budget:n}}({annotations:$,width:m,height:x,...i});for(const t of o)j.add(t)}if(M&&("object"==typeof M&&"number"==typeof M.minWidth?M.minWidth:ka)>=m)for(const t of $)_a(t)&&"secondary"===t.emphasis&&j.add(t);if(j.size>0)for(const t of $)!0===t?.defensive&&j.delete(t);let z;return z=0===j.size?$:A?$.map(t=>j.has(t)?{...t,_annotationDeferred:!0}:t):$.filter(t=>!j.has(t)),_?function(t,e){let i=!1;const o=t.map(t=>_a(t)?"blended"===t.cohesion||"layer"===t.cohesion?t:(i=!0,{...t,cohesion:e}):t);return i?o:t}(z,_):z}var za=require("react/jsx-runtime"),Ea="var(--semiotic-bg, #ffffff)",Da=.85;function Fa(t){const{x:e,y:i,text:o,fill:r,fontSize:n=12,fontWeight:s,fontFamily:a,textAnchor:c="start",dominantBaseline:l,background:u,className:h}=t,d=function(t){return void 0===t||!0===t||"halo"===t?{type:"halo"}:!1===t||"none"===t?null:"box"===t?{type:"box"}:{type:t.type??"halo",...t}}(u),f=t=>(0,za.jsx)("text",{x:e,y:i,textAnchor:c,dominantBaseline:l,fill:r,fontSize:n,fontWeight:s,fontFamily:a,className:h,...t?{stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:"stroke"}:{},children:o});if(!d)return f();if("halo"===d.type)return f({stroke:d.fill??Ea,strokeWidth:d.haloWidth??3});const p=d.padding??{x:6,y:3},y="number"==typeof p?p:p.x,g="number"==typeof p?p:p.y,m=function(t,e){return(t+"").length*e*.6}(o,n),x=n+2*g;let b,v;return b="middle"===c?e-m/2-y:"end"===c?e-m-y:e-y,v="middle"===l||"central"===l?i-x/2:"hanging"===l||"text-before-edge"===l?i-g:i-.8*n-g,(0,za.jsxs)("g",{className:h,children:[(0,za.jsx)("rect",{x:b,y:v,width:m+2*y,height:x,rx:d.radius??3,ry:d.radius??3,fill:d.fill??Ea,fillOpacity:d.opacity??Da,stroke:d.stroke,strokeWidth:d.strokeWidth}),f()]})}var Oa=require("react/jsx-runtime"),Na=16,Ba=20;function Ia(t,e){return t.color||e.colors.annotation||e.colors.text}function Wa(t,e,i){const o=t.labelBackground,r=e.colors.background;return void 0===o?"none"===i?"none":{type:"halo",fill:r}:!1===o||"none"===o?"none":!0===o||"halo"===o?{type:"halo",fill:r}:"box"===o?{type:"box",fill:r}:{fill:r,...o}}function Ya(t,e,i){return null!=t.x&&e.x?e.x(t.x):i&&null!=t[i]&&e.x?e.x(t[i]):"number"==typeof t.x?t.x:null}function qa(t,e,i){return null!=t.y&&e.y?e.y(t.y):i&&null!=t[i]&&e.y?e.y(t[i]):"number"==typeof t.y?t.y:null}function Xa(t){const{annotations:e}=t;if(!e||0===e.length)return null;const i=t.autoPlaceAnnotations?ja({annotations:e,context:{scales:{x:t.scales.x,y:t.scales.y,time:t.scales.x,value:t.scales.y,o:t.scales.o,geoProjection:t.scales.geoProjection},width:t.layout.width,height:t.layout.height,xAccessor:t.xAccessor,yAccessor:t.yAccessor,frameType:t.projection?"ordinal":"xy",projection:"horizontal"===t.projection?"horizontal":"vertical"},..."object"==typeof t.autoPlaceAnnotations?t.autoPlaceAnnotations:{}}):e,o=[];for(let e=0;i.length>e;e++){const r=Ga(i[e],e,t);r&&o.push({node:r,annotation:i[e]})}const r=function(t){const e=t.map((t,e)=>{return{p:t,i:e,emphasis:(i=t.annotation,"primary"===i?.emphasis||"secondary"===i?.emphasis?i.emphasis:null),confidence:ea(t.annotation),readingOrder:null,rank:qs};var i}),i=e.some(t=>null!=t.emphasis||null!=t.confidence),o=t.some(t=>Js(t.annotation)),r=t.some(t=>null!=ta(t.annotation)),n=t.some(t=>"layer"===ta(t.annotation));if(!i&&!o&&!r)return t.map(t=>t.node);const s=e.filter(t=>null==t.emphasis&&null!=t.confidence).slice().sort((t,e)=>(e.confidence??0)-(t.confidence??0)||t.i-e.i);s.forEach((t,e)=>{t.readingOrder=e,t.rank=Xs-e/Math.max(1,s.length)});for(const t of e)t.emphasis&&(t.rank=Ys[t.emphasis]);const a=e.sort((t,e)=>t.rank-e.rank||t.i-e.i).map(t=>{const{p:e,i:i,emphasis:o,readingOrder:r}=t,n=Js(e.annotation);let s=e.node;if("primary"===o||"secondary"===o||null!=r){const t=null==o&&null!=r;s=(0,Ws.jsx)("g",{className:t?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+o,..."secondary"===o?{opacity:Gs,fontSize:Vs}:{},...t?{opacity:ia(r),"data-annotation-reading-order":r}:{},children:e.node},"annotation-emphasis-"+i)}const a=ta(e.annotation);return a&&(s=(0,Ws.jsx)("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+i)),n&&(s=(0,Ws.jsx)("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+i)),s});return o&&a.unshift((0,Ws.jsx)("style",{children:Ks},"annotation-disclosure-style")),n&&a.unshift((0,Ws.jsx)("style",{children:Qs},"annotation-cohesion-style")),a}(o);return r.length>0?(0,Oa.jsx)("g",{id:(t.idPrefix?t.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:r}):null}function Ga(t,e,i){const{scales:o,layout:r,theme:n,xAccessor:s,yAccessor:a}=i;switch(t.type){case"y-threshold":{const s=t.value;if(null==s)return null;const a=Ia(t,n),c=t.label,l=t.labelPosition||"right",u=t.strokeDasharray||"6,4",h=t.strokeWidth??1.5;if("horizontal"===i.projection&&o.r){const i=o.r(s);return null==i?null:(0,Oa.jsxs)("g",{opacity:t.opacity,children:[(0,Oa.jsx)("line",{x1:i,y1:0,x2:i,y2:r.height,stroke:a,strokeWidth:h,strokeDasharray:u}),c&&(0,Oa.jsx)(Fa,{x:i+4,y:Na,textAnchor:"start",fontSize:n.typography.tickSize,fill:a,fontFamily:n.typography.fontFamily,text:c,background:Wa(t,n,"halo")})]},"ann-ythresh-"+e)}const d=o.y?o.y(s):o.r?o.r(s):null;return null==d?null:(0,Oa.jsxs)("g",{children:[(0,Oa.jsx)("line",{x1:0,y1:d,x2:r.width,y2:d,stroke:a,strokeWidth:h,strokeDasharray:u}),c&&(0,Oa.jsx)(Fa,{x:"left"===l?4:"center"===l?r.width/2:r.width-4,y:Ba>d?Math.min(r.height-4,d+Na):d-6,textAnchor:"left"===l?"start":"center"===l?"middle":"end",fontSize:n.typography.tickSize,fill:a,fontFamily:n.typography.fontFamily,text:c,background:Wa(t,n,"halo")})]},"ann-ythresh-"+e)}case"x-threshold":{const i=t.value;if(null==i||!o.x)return null;const s=o.x(i);if(null==s)return null;const a=Ia(t,n),c=t.label,l=t.labelPosition||"top";return(0,Oa.jsxs)("g",{opacity:t.opacity,children:[(0,Oa.jsx)("line",{x1:s,y1:0,x2:s,y2:r.height,stroke:a,strokeWidth:t.strokeWidth??1.5,strokeDasharray:t.strokeDasharray||"6,4"}),c&&(0,Oa.jsx)(Fa,{x:s>.6*r.width?s-4:s+4,y:"bottom"===l?r.height-4:"center"===l?r.height/2:Na,textAnchor:s>.6*r.width?"end":"start",fontSize:n.typography.tickSize,fill:a,fontFamily:n.typography.fontFamily,text:c,background:Wa(t,n,"halo")})]},"ann-xthresh-"+e)}case"band":{const i=null!=t.y0&&o.y?o.y(t.y0):null,s=null!=t.y1&&o.y?o.y(t.y1):null;if(null==i||null==s)return null;const a=Math.min(i,s),c=Math.abs(s-i),l=Hn(t.fill||Ia(t,n),"ssr-band-"+e),u=t.fillOpacity??.1;return(0,Oa.jsxs)("g",{opacity:t.opacity,children:[l.def&&(0,Oa.jsx)("defs",{children:l.def}),(0,Oa.jsx)("rect",{x:0,y:a,width:r.width,height:c,fill:l.fill,fillOpacity:u}),t.label&&(0,Oa.jsx)(Fa,{x:r.width-4,y:Math.max(a,0)+Na,textAnchor:"end",fontSize:n.typography.tickSize,fill:t.color||Ia(t,n),fontFamily:n.typography.fontFamily,fontWeight:"bold",text:t.label,background:Wa(t,n,"halo")})]},"ann-band-"+e)}case"x-band":{const i=null!=t.x0&&o.x?o.x(t.x0):null,s=null!=t.x1&&o.x?o.x(t.x1):null;if(null==i||null==s)return null;const a=Math.min(i,s),c=Math.abs(s-i),l=Hn(t.fill||Ia(t,n),"ssr-xband-"+e),u=t.fillOpacity??.1;return(0,Oa.jsxs)("g",{opacity:t.opacity,children:[l.def&&(0,Oa.jsx)("defs",{children:l.def}),(0,Oa.jsx)("rect",{x:a,y:0,width:c,height:r.height,fill:l.fill,fillOpacity:u}),t.label&&(0,Oa.jsx)(Fa,{x:a+4,y:Na,textAnchor:"start",fontSize:n.typography.tickSize,fill:t.color||Ia(t,n),fontFamily:n.typography.fontFamily,fontWeight:"bold",text:t.label,background:Wa(t,n,"halo")})]},"ann-xband-"+e)}case"category-highlight":{if(null==t.category||!o.o)return null;const s=o.o(t.category+"");if(null==s)return null;const a=o.o.bandwidth?o.o.bandwidth():40,c=Ia(t,n),l=t.opacity??.1,u=t.label;return(0,Oa.jsxs)("g","horizontal"===i.projection?{children:[(0,Oa.jsx)("rect",{x:0,y:s,width:r.width,height:a,fill:c,opacity:l}),u&&(0,Oa.jsx)(Fa,{x:12,y:s+a/2,dominantBaseline:"middle",fill:c,fontSize:n.typography.tickSize,fontWeight:"bold",fontFamily:n.typography.fontFamily,text:u,background:Wa(t,n,"none")})]}:{children:[(0,Oa.jsx)("rect",{x:s,y:0,width:a,height:r.height,fill:c,opacity:l}),u&&(0,Oa.jsx)(Fa,{x:s+a/2,y:Na,textAnchor:"middle",fill:c,fontSize:n.typography.tickSize,fontWeight:"bold",fontFamily:n.typography.fontFamily,text:u,background:Wa(t,n,"none")})]},"ann-cathighlight-"+e)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:i,y:r}=function(t,e,i,o){if(Array.isArray(t.coordinates)&&t.coordinates.length>=2&&e.geoProjection){const i=e.geoProjection([t.coordinates[0],t.coordinates[1]]);if(i)return{x:i[0],y:i[1]}}return{x:Ya(t,e,i),y:qa(t,e,o)}}(t,o,s,a);if(null==i||null==r)return null;const c="text"===t.type,l=t.dx??(c?0:30),u=t.dy??(c?0:-30),h=t.color||n.colors.text;if(!c){const o="callout"===t.type?"callout-circle":t.type,n="callout-circle"===o?{radius:t.radius??12,radiusPadding:t.radiusPadding}:"callout-rect"===o?{width:t.width,height:t.height}:void 0;return(0,Oa.jsx)(Is,{noteData:{x:i,y:r,dx:l,dy:u,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:o,...n?{subject:n}:{},connector:t.connector||{end:"arrow"},color:h,disable:t.disable,opacity:t.opacity,strokeDasharray:t.strokeDasharray,className:t.className}},"ann-label-"+e)}return(0,Oa.jsx)("g",{children:(0,Oa.jsx)("text",{x:i+l,y:r+u,textAnchor:t.textAnchor||"start",fontSize:t.fontSize||n.typography.labelSize,fill:h,fontFamily:n.typography.fontFamily,fontWeight:t.fontWeight,opacity:t.opacity,strokeDasharray:t.strokeDasharray,children:t.label||t.title})},"ann-label-"+e)}default:return null}}var Va=36,Ha=34,Za=58,Ua=22;function Ka(t){return"string"==typeof t&&t.length>0}function Qa(t,e){return function(t,e,i=!1){const o=i?e?Za:Ha:e?Va:0;return o>t.top?{...t,top:o}:t}(t,Ka(e))}var Ja=c(require("react"));function tc(t,e,i){return"exact"===i?function(t,e){const i=t.domain(),o=i[0],r=i[i.length-1],n=o instanceof Date,s=o instanceof Date?o.getTime():o,a=r instanceof Date?r.getTime():r;if(2>e||s===a)return n?[new Date(s),new Date(a)]:[s,a];const c=(a-s)/(e-1),l=Array(e);for(let t=0;e>t;t++){const i=t===e-1?a:s+t*c;l[t]=n?new Date(i):i}return l}(t,e):t.ticks(e)}var ec=require("react/jsx-runtime");function ic(t){if("string"==typeof t)return t;if(t&&"object"==typeof t){const e=t.id;return null==e?null:e+""}return null}function oc(t){const e=t._idPrefix||t.chartId;if(e){const t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(t)?t:"c"+t}const i=`${t.chartType||""}:${t.title||""}:${Array.isArray(t.data)?t.data.length:0}`;let o=0;for(let t=0;i.length>t;t++)o=31*o+i.charCodeAt(t)|0;return"c"+(o>>>0).toString(36)}function rc(t,e,i){const o=t.showLegend&&!t.__legendIncludesAutomatic?function(t,e,i){if(0===t.length)return;const o=_s(t,e,i);return{legendGroups:[{label:"",type:"fill",items:t.map(t=>({label:t})),styleFn:t=>({fill:o(t.label)})}]}}(e,t.colorScheme,i):void 0;return ae(o,t.legend)}var nc={right:110,left:110,top:50,bottom:80};function sc(t,e){if(t.__autoLegendMargin&&!ac(t,e))return nc[e]}function ac(t,e){const i=t.__explicitMargin;return"number"==typeof i||!(!i||"object"!=typeof i||"number"!=typeof i[e])}function cc(t,e){const{props:i,categories:o,theme:r,size:n,hasTitle:s}=e,a=i.legendPosition||"right",c={theme:r,position:a,size:n,hasTitle:s,legendLayout:i.legendLayout,minimumMargin:sc(i,a),preserveExplicitMargin:ac(i,a)};if(null!=i.legend){const e=rc(i,o,r);(ce(e)||le(e))&&function(t,e){if(e.preserveExplicitMargin)return;const i=e.position||"right",o={theme:e.theme,position:i,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,hasTitle:e.hasTitle,legendLayout:e.legendLayout},r=ce(e.legend)?function(t){const{width:e,height:i,swatchSize:o}=Cs(t);return{width:e,height:i,swatchSize:o}}({...o,legendGroups:e.legend.legendGroups}):le(e.legend)?$s({...o,gradient:e.legend.gradient}):null;if(!r)return;const n=e.minimumMargin??r.width+14,s=e.minimumMargin??(e.hasTitle?32:8)+r.height+4,a=e.minimumMargin??38+r.height+4;"right"===i?t.right=Math.max(t.right,n):"left"===i?t.left=Math.max(t.left,n):"top"===i?t.top=Math.max(t.top,s):t.bottom=Math.max(t.bottom,a)}(t,{...c,legend:e})}else i.showLegend&&o.length>0&&function(t,e){if(0===e.categories.length)return;if(e.preserveExplicitMargin)return;const i=e.position||"right",o=function(t){const{width:e,height:i,swatchSize:o}=Ts(t);return{width:e,height:i,swatchSize:o}}({categories:e.categories,colorScheme:e.colorScheme,theme:e.theme,position:i,totalWidth:e.size[0],totalHeight:e.size[1],margin:t,hasTitle:e.hasTitle,legendLayout:e.legendLayout}),r=e.minimumMargin??o.width+14,n=e.minimumMargin??(e.hasTitle?32:8)+o.height+4,s=e.minimumMargin??38+o.height+4;"right"===i?t.right=Math.max(t.right,r):"left"===i?t.left=Math.max(t.left,r):"top"===i?t.top=Math.max(t.top,n):t.bottom=Math.max(t.bottom,s)}(t,{...c,categories:o,colorScheme:i.colorScheme});return a}function lc(t){const{props:e,categories:i,theme:o,size:r,margin:n,hasTitle:s}=t,a=e.legendPosition||"right",c={theme:o,position:a,size:r,margin:n,hasTitle:s,legendLayout:e.legendLayout,idPrefix:e._idPrefix,reservedWidth:e.__autoLegendMargin?100:void 0};if(null!=e.legend){const t=rc(e,i,o);if(Ja.isValidElement(t))return t;const r=function(t,e){const i={theme:e.theme,position:e.position||"right",totalWidth:e.size[0],totalHeight:e.size[1],margin:e.margin,hasTitle:e.hasTitle,legendLayout:e.legendLayout,idPrefix:e.idPrefix,reservedWidth:e.reservedWidth};return ce(t)?function(t){if(0===(e=t.legendGroups,e.flatMap(t=>t.items.map((e,i)=>({group:t,item:e,itemIndex:i,label:e.label})))).length)return null;var e;const i=Cs(t),o="top"===t.position||"bottom"===t.position,r=t.theme.colors.grid||t.theme.colors.textSecondary;let n,s;if("left"===t.position?(n=Math.max(4,t.margin.left-(t.reservedWidth??100)-10),s=t.margin.top):"top"===t.position?(n=t.margin.left,s=t.hasTitle?32:8):"bottom"===t.position?(n=t.margin.left,s=t.totalHeight-t.margin.bottom+38):(n=t.totalWidth-t.margin.right+10,s=t.margin.top),!o){const e=se(t.legendGroups.map(t=>({hasLabel:!!t.label,itemCount:t.items.length})),Math.max(i.swatchSize,t.legendLayout?.rowHeight??Ms)),o=t.legendGroups.flatMap((o,r)=>{const n=e[r],s=o.type??"fill",a=[(0,As.jsx)("line",{x1:0,y1:n.lineY,x2:t.reservedWidth??100,y2:n.lineY,stroke:"gray"},"legend-group-neatline-"+r)];return o.label&&null!=n.labelY&&a.push((0,As.jsx)("text",{y:n.labelY,fontSize:Ls(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:o.label},"legend-group-label-"+r)),a.push((0,As.jsx)("g",{transform:`translate(0,${n.itemsY})`,children:o.items.map((e,n)=>{const a=o.styleFn(e,n),c="function"==typeof s?s(e):"line"===s?(0,As.jsx)("line",{x1:0,y1:0,x2:i.swatchSize,y2:i.swatchSize,style:a}):(0,As.jsx)("rect",{width:i.swatchSize,height:i.swatchSize,rx:i.swatchRadius,style:a});return(0,As.jsxs)("g",{transform:`translate(0,${n*Math.max(i.swatchSize,t.legendLayout?.rowHeight??Ms)})`,children:[c,(0,As.jsx)("text",{x:i.labelOffset,y:i.swatchSize/2,dominantBaseline:"central",fontSize:Ls(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:e.label})]},`legend-${r}-${n}`)})},"legend-group-"+r)),a});return(0,As.jsx)("g",{className:"semiotic-legend",transform:`translate(${n},${s})`,"data-orientation":"vertical",children:o})}const a=i.groups.flatMap((e,n)=>{const{group:s}=e,a=s.type??"fill",c=[];if(s.label&&c.push((0,As.jsx)("text",o?{transform:`translate(${e.x},${e.y}) rotate(90)`,textAnchor:"start",fontSize:Ls(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:s.label}:{x:e.x,y:e.y+Ls(t.theme),fontSize:Ls(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:s.label},"legend-group-label-"+n)),c.push(...e.items.map((o,r)=>{const c=s.items[r],l=s.styleFn(c,r),u="function"==typeof a?a(c):"line"===a?(0,As.jsx)("line",{x1:0,y1:0,x2:i.swatchSize,y2:i.swatchSize,style:l}):(0,As.jsx)("rect",{width:i.swatchSize,height:i.swatchSize,rx:i.swatchRadius,style:l});return(0,As.jsxs)("g",{transform:`translate(${e.x+e.itemOffsetX+o.x},${e.y+e.itemOffsetY+o.y})`,children:[u,(0,As.jsx)("text",{x:i.labelOffset,y:i.swatchSize/2,dominantBaseline:"central",fontSize:Ls(t.theme),fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:o.category})]},`legend-${n}-${r}`)})),o&&i.groups.length-1>n){const t=e.x+e.width+6;c.push((0,As.jsx)("line",{x1:t,y1:0,x2:t,y2:i.height,stroke:r},"legend-group-separator-"+n))}return c});return(0,As.jsx)("g",{className:"semiotic-legend",transform:`translate(${n},${s})`,"data-orientation":o?"horizontal":"vertical",children:a})}({...i,legendGroups:t.legendGroups}):le(t)?function(t){const e=$s(t),i="top"===t.position||"bottom"===t.position,o=(t.idPrefix?t.idPrefix+"-":"")+"semiotic-static-gradient-legend",r=t.gradient.format||(t=>Math.round(100*t)/100+"");let n,s;"left"===t.position?(n=Math.max(4,t.margin.left-100-10),s=t.margin.top):"top"===t.position?(n=t.margin.left,s=t.hasTitle?32:8):"bottom"===t.position?(n=t.margin.left,s=t.totalHeight-t.margin.bottom+38):(n=t.totalWidth-t.margin.right+10,s=t.margin.top);const a=Array.from({length:17},(e,o)=>{const r=o/16;return(0,As.jsx)("stop",{offset:100*r+"%",stopColor:t.gradient.colorFn(i?t.gradient.domain[0]+r*(t.gradient.domain[1]-t.gradient.domain[0]):t.gradient.domain[1]-r*(t.gradient.domain[1]-t.gradient.domain[0]))},o)});if(i){const i=12,c=t.gradient.label?0:void 0,l=t.gradient.label?8:0;return(0,As.jsxs)("g",{className:"semiotic-legend",transform:`translate(${n},${s})`,children:[(0,As.jsx)("defs",{children:(0,As.jsx)("linearGradient",{id:o,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:a})}),t.gradient.label&&(0,As.jsx)("text",{x:e.width/2,y:c,textAnchor:"middle",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:t.gradient.label}),(0,As.jsx)("rect",{x:0,y:l,width:e.width,height:i,fill:`url(#${o})`,rx:2}),(0,As.jsx)("text",{x:0,y:l+i+12,textAnchor:"start",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:r(t.gradient.domain[0])}),(0,As.jsx)("text",{x:e.width,y:l+i+12,textAnchor:"end",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:r(t.gradient.domain[1])})]})}const c=t.gradient.label?-6:void 0;return(0,As.jsxs)("g",{className:"semiotic-legend",transform:`translate(${n},${s+(t.gradient.label?12:0)})`,children:[(0,As.jsx)("defs",{children:(0,As.jsx)("linearGradient",{id:o,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:a})}),t.gradient.label&&(0,As.jsx)("text",{x:7,y:c,textAnchor:"middle",fontSize:t.theme.typography.tickSize,fill:t.theme.colors.text,fontFamily:t.theme.typography.fontFamily,children:t.gradient.label}),(0,As.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${o})`,rx:2}),(0,As.jsx)("text",{x:19,y:10,fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:r(t.gradient.domain[1])}),(0,As.jsx)("text",{x:19,y:100,fontSize:t.theme.typography.tickSize,fill:t.theme.colors.textSecondary,fontFamily:t.theme.typography.fontFamily,children:r(t.gradient.domain[0])})]})}({...i,gradient:t.gradient}):null}(t,c);return r||(ce(t)||le(t)?null:t??null)}return e.showLegend&&0!==i.length?function(t){const{categories:e,colorScheme:i,theme:o,position:r="right",totalWidth:n,totalHeight:s,margin:a,hasTitle:c=!1}=t;if(!e||0===e.length)return null;const l=_s(e,i,o),u="top"===r||"bottom"===r,h=Ts(t);let d,f;if("left"===r?(d=Math.max(4,a.left-(t.reservedWidth??100)-10),f=a.top):"top"===r?(d=a.left,f=c?32:8):"bottom"===r?(d=a.left,f=s-a.bottom+38):(d=n-a.right+10,f=a.top),u){const t=h.items.map((t,e)=>(0,As.jsxs)("g",{transform:`translate(${t.x},${t.y})`,children:[(0,As.jsx)("rect",{width:h.swatchSize,height:h.swatchSize,fill:l(t.category),rx:h.swatchRadius}),(0,As.jsx)("text",{x:h.labelOffset,y:h.swatchSize/2,dominantBaseline:"central",fontSize:Ls(o),fill:o.colors.text,fontFamily:o.typography.fontFamily,children:t.category})]},"legend-"+e));return(0,As.jsx)("g",{className:"semiotic-legend",transform:`translate(${d},${f})`,children:t})}const p=se([{hasLabel:!1,itemCount:e.length}],Math.max(h.swatchSize,t.legendLayout?.rowHeight??Ms))[0],y=h.items.map((t,e)=>(0,As.jsxs)("g",{transform:`translate(${t.x},${t.y+p.itemsY})`,children:[(0,As.jsx)("rect",{width:h.swatchSize,height:h.swatchSize,fill:l(t.category),rx:h.swatchRadius}),(0,As.jsx)("text",{x:h.labelOffset,y:h.swatchSize/2,dominantBaseline:"central",fontSize:Ls(o),fill:o.colors.text,fontFamily:o.typography.fontFamily,children:t.category})]},"legend-"+e));return(0,As.jsxs)("g",{className:"semiotic-legend",transform:`translate(${d},${f})`,children:[(0,As.jsx)("line",{x1:0,y1:p.lineY,x2:t.reservedWidth??100,y2:p.lineY,stroke:"gray"}),y]})}({categories:i,colorScheme:e.colorScheme,theme:o,position:a,totalWidth:r[0],totalHeight:r[1],margin:n,hasTitle:s,legendLayout:e.legendLayout,reservedWidth:e.__autoLegendMargin?100:void 0,idPrefix:e._idPrefix}):null}function uc(t){return Math.round(100*t)/100+""}function hc(t,e){const i=Lt(e.theme),o=e.background??i.background,r=e.idPrefix?e.idPrefix+"-":"",n="string"==typeof e.title?e.title:void 0,s=n?r+"semiotic-title":void 0,a=e.description?r+"semiotic-desc":void 0,c=[s,a].filter(Boolean).join(" ")||void 0;return(0,ec.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className,width:e.width,height:e.height,role:"img","aria-labelledby":c,style:{fontFamily:i.fontFamily},children:[n&&(0,ec.jsx)("title",{id:s,children:n}),e.description&&(0,ec.jsx)("desc",{id:a,children:e.description}),e.defs&&(0,ec.jsx)("defs",{children:e.defs}),o&&"transparent"!==o&&(0,ec.jsx)("rect",{x:0,y:0,width:e.width,height:e.height,fill:o}),(0,ec.jsx)("g",{id:r+"data-area",transform:e.innerTransform,children:t}),n&&(0,ec.jsx)("text",{id:r+"chart-title",x:e.width/2,y:Ua,textAnchor:"middle",fontSize:i.titleSize,fontWeight:"bold",fill:i.text,fontFamily:i.fontFamily,children:n}),e.legend&&(0,ec.jsx)("g",{id:r+"legend",children:e.legend}),e.outerElements]})}var dc=require("react/jsx-runtime");function fc(t,e){const i=Pt(t.theme),o=t.size||[500,300],r=Qa({top:20,right:20,bottom:30,left:40,...t.margin},t.title),n=Ka(t.title),s=b(t.data),a=t.showLegend?js(s,t.colorAccessor||t.groupAccessor||t.categoryAccessor):[];cc(r,{props:t,categories:a,theme:i,size:o,hasTitle:n});const c=o[0]-r.left-r.right,l=o[1]-r.top-r.bottom,u="streaming"===t.runtimeMode||["bar","swarm","waterfall"].includes(t.chartType),h=t.colorScheme||i.colors.categorical,d={chartType:t.chartType,windowSize:t.windowSize??200,windowMode:t.windowMode??"sliding",arrowOfTime:u?t.arrowOfTime??"right":"right",extentPadding:t.extentPadding??.1,xAccessor:u?void 0:t.xAccessor,yAccessor:u?void 0:t.yAccessor,timeAccessor:u?t.timeAccessor:void 0,valueAccessor:t.valueAccessor,colorAccessor:t.colorAccessor,sizeAccessor:t.sizeAccessor,symbolAccessor:t.symbolAccessor,symbolMap:t.symbolMap,groupAccessor:t.groupAccessor,categoryAccessor:t.categoryAccessor,lineDataAccessor:t.lineDataAccessor,xExtent:t.xExtent,yExtent:t.yExtent,axisExtent:t.axisExtent,sizeRange:t.sizeRange,xScaleType:t.xScaleType,yScaleType:t.yScaleType,scalePadding:t.scalePadding,binSize:t.binSize,normalize:t.normalize,stackOrder:t.stackOrder,boundsAccessor:t.boundsAccessor,boundsStyle:t.boundsStyle,y0Accessor:t.y0Accessor,areaGroups:t.areaGroups?t.areaGroups instanceof Set?t.areaGroups:new Set(t.areaGroups):void 0,curve:t.curve,gradientFill:!0===t.gradientFill?{topOpacity:.8,bottomOpacity:.05}:!1===t.gradientFill?void 0:t.gradientFill,lineGradient:t.lineGradient,openAccessor:t.openAccessor,highAccessor:t.highAccessor,lowAccessor:t.lowAccessor,closeAccessor:t.closeAccessor,candlestickStyle:t.candlestickStyle,lineStyle:t.lineStyle,pointStyle:t.pointStyle,areaStyle:t.areaStyle,barStyle:t.barStyle,waterfallStyle:t.waterfallStyle,swarmStyle:t.swarmStyle,colorScheme:h,themeCategorical:i.colors.categorical,themeSemantic:mt(i),customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:r,layoutSelection:t.layoutSelection,barColors:t.barColors,showValues:t.showValues,heatmapValueFormat:t.heatmapValueFormat},f=new Wn(d);if(t.data&&f.ingest({inserts:s,bounded:!0}),f.computeScene({width:c,height:l}),!f.scales||0===f.scene.length)return e&&(e.evidence=fr({frameType:"xy",width:o[0],height:o[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,extraWarnings:f.scales?[]:["NO_SCALES"]})),yr.renderToStaticMarkup(hc(null,{width:o[0],height:o[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${r.left},${r.top})`,innerWidth:c,innerHeight:l,idPrefix:t._idPrefix}));const p=t._idPrefix,y=ks({nodes:f.scene,renderMode:t.renderMode,fallback:(t,e)=>gs(t,e,p)});e&&(e.evidence=fr({frameType:"xy",width:o[0],height:o[1],marks:y.map(t=>t.node),title:t.title,description:t.description,annotations:t.annotations,xDomain:dr(f.scales.x?.domain?.()),yDomain:dr(f.scales.y?.domain?.()),legendItems:a.length>0?a.length:void 0}));const g=t.showGrid?function(t,e,i,o,r){const{grid:n}=Lt(i),s=o?o+"-":"",a="exact"===r?5:Math.min(5,Math.max(2,Math.floor(e.width/70))),c="exact"===r?5:Math.min(5,Math.max(2,Math.floor(e.height/30))),l=tc(t.x,a,r),u=tc(t.y,c,r);return(0,ec.jsxs)("g",{id:s+"grid",className:"semiotic-grid",opacity:.8,children:[l.map((i,o)=>{const r=t.x(i);return(0,ec.jsx)("line",{x1:r,y1:0,x2:r,y2:e.height,stroke:n,strokeWidth:.5},"gx-"+o)}),u.map((i,o)=>{const r=t.y(i);return(0,ec.jsx)("line",{x1:0,y1:r,x2:e.width,y2:r,stroke:n,strokeWidth:.5},"gy-"+o)})]})}(f.scales,{width:c,height:l},i,p,t.axisExtent):null,m=y.map(t=>t.element),x=oc(t)+"-plot-clip",v=!1!==t.showAxes?function(t,e,i,o,r){const n=Lt(o),s="exact"===i.axisExtent?5:Math.min(5,Math.max(2,Math.floor(e.width/70))),a="exact"===i.axisExtent?5:Math.min(5,Math.max(2,Math.floor(e.height/30))),c=tc(t.x,s,i.axisExtent).map(e=>({pixel:t.x(e),label:(i.xFormat||i.tickFormatTime||uc)(e)})),l=tc(t.y,a,i.axisExtent).map(e=>({pixel:t.y(e),label:(i.yFormat||i.tickFormatValue||uc)(e)}));return(0,ec.jsxs)("g",{id:(r?r+"-":"")+"axes",className:"stream-axes",children:[(0,ec.jsx)("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:n.border,strokeWidth:1}),c.map((t,i)=>(0,ec.jsxs)("g",{transform:`translate(${t.pixel},${e.height})`,children:[(0,ec.jsx)("line",{y2:5,stroke:n.border,strokeWidth:1}),(0,ec.jsx)("text",{y:18,textAnchor:"middle",fontSize:n.tickSize,fill:n.textSecondary,fontFamily:n.fontFamily,children:t.label})]},"xtick-"+i)),i.xLabel&&(0,ec.jsx)("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:n.labelSize,fill:n.text,fontFamily:n.fontFamily,children:i.xLabel}),(0,ec.jsx)("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:n.border,strokeWidth:1}),l.map((t,e)=>(0,ec.jsxs)("g",{transform:`translate(0,${t.pixel})`,children:[(0,ec.jsx)("line",{x2:-5,stroke:n.border,strokeWidth:1}),(0,ec.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:n.tickSize,fill:n.textSecondary,fontFamily:n.fontFamily,children:t.label})]},"ytick-"+e)),i.yLabel&&(0,ec.jsx)("text",{x:15-(i.margin?.left??40),y:e.height/2,textAnchor:"middle",fontSize:n.labelSize,fill:n.text,fontFamily:n.fontFamily,transform:`rotate(-90, ${15-(i.margin?.left??40)}, ${e.height/2})`,children:i.yLabel})]})}(f.scales,{width:c,height:l},t,i,p):null,w=t.annotations?Xa({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{x:f.scales.x,y:f.scales.y},layout:{width:c,height:l},theme:i,xAccessor:"string"==typeof t.xAccessor?t.xAccessor:void 0,yAccessor:"string"==typeof t.yAccessor?t.yAccessor:void 0,idPrefix:p}):null,k=t.svgPreRenderers&&f.scales?t.svgPreRenderers.map((t,e)=>{try{return(0,dc.jsx)(pr.Fragment,{children:t(f.scene,f.scales,{width:c,height:l})},"pre-"+e)}catch{return null}}).filter(Boolean):null,S=lc({props:t,categories:a,theme:i,size:o,margin:r,hasTitle:n});return yr.renderToStaticMarkup(hc((0,dc.jsxs)(dc.Fragment,{children:[t.backgroundGraphics,k,g,(0,dc.jsx)("defs",{children:(0,dc.jsx)("clipPath",{id:x,children:(0,dc.jsx)("rect",{x:0,y:0,width:c,height:l})})}),(0,dc.jsx)("g",{clipPath:`url(#${x})`,children:m}),v,w,t.foregroundGraphics,f.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-xy-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${r.left},${r.top})`,innerWidth:c,innerHeight:l,legend:S,idPrefix:t._idPrefix}))}var pc=c(require("react-dom/server")),yc=require("d3-scale"),gc=class{constructor(){this.colorSchemeMap=new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(t,e,i){if(e&&"function"==typeof t.pieceStyle){const o=t.pieceStyle(e,i);return o&&!o.fill&&i?{...o,fill:this.getColorFromScheme(t,i)}:o}return t.pieceStyle&&"object"==typeof t.pieceStyle?t.pieceStyle:t.barColors&&i?{fill:t.barColors[i]||"#007bff"}:{fill:i?this.getColorFromScheme(t,i):"#007bff"}}resolveSummaryStyle(t,e,i){return e&&"function"==typeof t.summaryStyle?t.summaryStyle(e,i):t.summaryStyle&&"object"==typeof t.summaryStyle?t.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(t,e){const i=this.colorSchemeMap.get(e);if(i)return i;const o=Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical||U,r=o[this.colorSchemeIndex%o.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(e,r),r}};function mc(t){const e=t.getSymbol;if(!e)return null;const i=t.config.symbolMap,o=new Map;let r=0;return t=>{const n=e(t)+"",s=i?.[n];if(s)return s;let a=o.get(n);return a||(a=tn[r%tn.length],r++,o.set(n,a)),a}}function xc(t,e,i,o,r,n,s){t.push(e?{type:"symbol",x:o,y:r,size:Math.PI*n*n,symbolType:e(i),style:s,datum:i}:{type:"point",x:o,y:r,r:n,style:s,datum:i})}function bc(t,e){const{columns:i,config:o,resolvePieceStyle:r}=t,n=[],s=Math.min(e.width,e.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,h=Object.values(i),d=h.some(t=>{const e=t.pieceData[0];return e&&("number"==typeof e._pct||"number"==typeof e._pctStart||null!=e._roundedEnds)}),f=u&&!d&&h.length>1&&(o.cornerRadius??0)>0;for(let t=0;h.length>t;t++){const e=h[t],i=e.pieceData[0],u="number"==typeof i?._pctStart?i._pctStart:e.pctStart,d=c+u*l,p=c+(u+("number"==typeof i?._pct?i._pct:e.pct))*l,y=r(e.pieceData[0],e.name),g=0===t,m=t===h.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:d,endAngle:p,...o.cornerRadius&&{cornerRadius:o.cornerRadius},style:y,datum:i?._nonInteractive?null:e.pieceData,category:e.name};i?._roundedEnds?x.roundedEnds=i._roundedEnds:f&&(x.roundedEnds={start:g,end:m}),i?._gradientBand&&(x._gradientBand=i._gradientBand),n.push(x)}return n}var vc=require("d3-array");function wc(t){const e=t.length,i=t[0],o=t[e-1];return{n:e,min:i,q1:(0,vc.quantile)(t,.25)??i,median:(0,vc.quantile)(t,.5)??(i+o)/2,q3:(0,vc.quantile)(t,.75)??o,max:o,mean:t.reduce((t,e)=>t+e,0)/e}}var kc=require("d3-scale"),Sc={bar:function(t,e){const{scales:i,columns:o,config:r,getR:n,getStack:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,d="horizontal"===l,f=r.normalize,p=[];if(s){const t=new Set;for(const e of Object.values(o))for(const i of e.pieceData){const e=s(i);t.has(e)||(t.add(e),p.push(e))}}else p.push("_default");for(const t of Object.values(o)){const e=new Map;for(const i of t.pieceData){const t=s?s(i):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const o=e.get(t);o.total+=n(i),o.pieces.push(i)}let i=0;if(f)for(const t of e.values())i+=Math.abs(t.total);let o=0,r=0;for(const n of p){const l=e.get(n);if(!l)continue;let p=l.total;f&&i>0&&(p/=i);const y=a(l.pieces[0],s?n:t.name),g={...l.pieces[0],__aggregateValue:l.total,__pieceCount:l.pieces.length,category:t.name};if(h){const e=c(0>p?r:o+p),i=0>p?c(r+p)-c(r):c(o)-c(o+p);u.push(Ir(t.x,e,t.width,Math.abs(i),y,g,n)),0>p?r+=p:o+=p}else if(d){const e=c(0>p?r+p:o),i=0>p?c(r)-c(r+p):c(o+p)-c(o);u.push(Ir(e,t.x,Math.abs(i),t.width,y,g,n)),0>p?r+=p:o+=p}}}const y="vertical"===l,g=r.roundedTop&&r.roundedTop>0?Math.max(0,r.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;const e=t.datum?.__aggregateValue??0;t.roundedEdge=y?0>e?"bottom":"top":0>e?"left":"right",r.gradientFill&&(t.fillGradient=r.gradientFill)}if(g>0){const t=new Map;for(const e of u){if("rect"!==e.type)continue;const i=e.datum?.category||"";t.has(i)||t.set(i,[]),t.get(i).push(e)}for(const e of t.values()){if(0===e.length)continue;const t=e.filter(t=>(t.datum?.__aggregateValue??0)>=0),i=e.filter(t=>0>(t.datum?.__aggregateValue??0));t.length>0&&(t.reduce(y?(t,e)=>e.y>t.y?t:e:(t,e)=>t.x+t.w>e.x+e.w?t:e).roundedTop=g),i.length>0&&(i.reduce(y?(t,e)=>t.y+t.h>e.y+e.h?t:e:(t,e)=>e.x>t.x?t:e).roundedTop=g)}}return u},clusterbar:function(t,e){const{scales:i,columns:o,config:r,getR:n,getGroup:s,resolvePieceStyle:a}=t,{r:c,projection:l}=i,u=[],h="vertical"===l,d=[],f=new Set;for(const t of Object.values(o))for(const e of t.pieceData){const t=s?s(e):"_default";f.has(t)||(f.add(t),d.push(t))}const p=d.length||1;for(const t of Object.values(o)){const e=t.width/p,i=.2*e,o=e-i,r=new Map;for(const e of t.pieceData){const t=s?s(e):"_default";r.has(t)||r.set(t,[]),r.get(t).push(e)}for(let s=0;d.length>s;s++){const l=r.get(d[s])||[];for(const r of l){const l=n(r),f=a(r,d[s]);if(h){const n=t.x+s*e+i/2,a=c(0),h=c(l);u.push(Ir(n,Math.min(a,h),o,Math.abs(a-h),f,r,d[s]))}else{const n=t.x+s*e+i/2,a=c(0),h=c(l);u.push(Ir(Math.min(a,h),n,Math.abs(h-a),o,f,r,d[s]))}}}}const y=r.roundedTop&&r.roundedTop>0?Math.max(0,r.roundedTop):0;for(const t of u){if("rect"!==t.type)continue;if(null==t.datum)continue;const e=n(t.datum);y>0&&(t.roundedTop=y),t.roundedEdge=h?0>e?"bottom":"top":0>e?"left":"right",r.gradientFill&&(t.fillGradient=r.gradientFill)}return u},point:function(t,e){const{scales:i,columns:o,getR:r,multiScales:n,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],u="vertical"===c,h="radial"===c,d=n.length>0,f=mc(t),p=2*Math.PI,y=-Math.PI/2;for(const t of Object.values(o))for(const e of t.pieceData){const i=e.__rIndex??0,o=e.__rValue??r(e),c=d&&n[i]||a,g=s(e,t.name),m=g.r||5;let x,b;if(h){const e=y+(t.pctStart+t.pct/2)*p,i=c(o);x=Math.cos(e)*i,b=Math.sin(e)*i}else u?(x=t.middle,b=c(o)):(x=c(o),b=t.middle);xc(l,f,e,x,b,m,g)}return l},swarm:function(t,e){const{scales:i,columns:o,getR:r,resolvePieceStyle:n}=t,{r:s,projection:a}=i,c=[],l="vertical"===a,u=mc(t);for(const t of Object.values(o)){const e=t.width/2;for(let i=0;t.pieceData.length>i;i++){const o=t.pieceData[i],a=r(o),h=n(o,t.name),d=h.r||4,f=(7919*i%100/100-.5)*e*.8;xc(c,u,o,l?t.middle+f:s(a),l?s(a):t.middle+f,d,h)}}return c},pie:bc,donut:bc,boxplot:function(t,e){const{scales:i,columns:o,config:r,getR:n,resolveSummaryStyle:s}=t,{r:a,projection:c}=i,l=[],u="vertical"===c,h=!1!==r.showOutliers;for(const e of Object.values(o)){const i=e.pieceData.map(t=>n(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(0===i.length)continue;const o=i[0],r=i[i.length-1],c=(0,vc.quantile)(i,.25)??o,d=(0,vc.quantile)(i,.5)??(o+r)/2,f=(0,vc.quantile)(i,.75)??r,p=f-c,y=c-1.5*p,g=f+1.5*p,m=i.find(t=>t>=y)??o,x=[...i].reverse().find(t=>g>=t)??r,b=s(e.pieceData[0],e.name),v=[];if(h)for(const t of e.pieceData){const i=n(t);if(y>i||i>g){const o=u?e.middle:a(i),r=u?a(i):e.middle;v.push({px:o,py:r,value:i,datum:t})}}if(l.push({type:"boxplot",x:u?e.middle:0,y:u?0:e.middle,projection:u?"vertical":"horizontal",columnWidth:.6*e.width,minPos:a(m),q1Pos:a(c),medianPos:a(d),q3Pos:a(f),maxPos:a(x),stats:{n:i.length,min:m,q1:c,median:d,q3:f,max:x,mean:i.reduce((t,e)=>t+e,0)/i.length},style:b,datum:e.pieceData,category:e.name,outliers:v}),h)for(const e of v)l.push({type:"point",x:e.px,y:e.py,r:3,style:{fill:b.fill||t.config.themeSemantic?.secondary||"#999",opacity:.6},datum:e.datum})}return l},violin:function(t,e){const{scales:i,columns:o,config:r,getR:n,resolveSummaryStyle:s}=t,{r:a,projection:c}=i,l=[],u="vertical"===c,h=r.bins||20,d=!1!==r.showIQR;for(const t of Object.values(o)){const e=t.pieceData.map(t=>n(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const i=e[0],o=e[e.length-1],r=(o-i)/h||1,c=Array(h).fill(0);for(const t of e)c[Math.min(Math.floor((t-i)/r),h-1)]++;const f=ot(c,1),p=t.width/2*.9;let y;if(u){y=`M ${t.middle} ${a(i)}`;for(let e=0;h>e;e++){const o=a(i+(e+.5)*r);y+=` L ${t.middle+c[e]/f*p} ${o}`}y+=` L ${t.middle} ${a(o)}`;for(let e=h-1;e>=0;e--){const o=a(i+(e+.5)*r);y+=` L ${t.middle-c[e]/f*p} ${o}`}y+=" Z"}else{y=`M ${a(i)} ${t.middle}`;for(let e=0;h>e;e++)y+=` L ${a(i+(e+.5)*r)} ${t.middle-c[e]/f*p}`;y+=` L ${a(o)} ${t.middle}`;for(let e=h-1;e>=0;e--)y+=` L ${a(i+(e+.5)*r)} ${t.middle+c[e]/f*p}`;y+=" Z"}const g=s(t.pieceData[0],t.name);let m;if(d&&e.length>=4){const r=(0,vc.quantile)(e,.25)??i,n=(0,vc.quantile)(e,.5)??(i+o)/2,s=(0,vc.quantile)(e,.75)??o;m={q1Pos:a(r),medianPos:a(n),q3Pos:a(s),centerPos:t.middle,isVertical:u}}const x=u?{x:t.x,y:Math.min(a(o),a(i)),width:t.width,height:Math.abs(a(o)-a(i))}:{x:Math.min(a(i),a(o)),y:t.x,width:Math.abs(a(o)-a(i)),height:t.width};l.push({type:"violin",pathString:y,translateX:0,translateY:0,bounds:x,iqrLine:m,stats:wc(e),style:g,datum:t.pieceData,category:t.name})}return l},histogram:function(t,e){const{scales:i,columns:o,config:r,getR:n,resolveSummaryStyle:s}=t,{r:a}=i,c=[],l=r.bins||25,u=r.normalize,h=a.domain?.(),d=h?+h[0]:void 0,f=h?+h[1]:void 0;for(const t of Object.values(o)){const e=t.pieceData.map(t=>n(t)).filter(t=>null!=t&&!isNaN(t));if(0===e.length)continue;const[i,o]=it(e),r=null!=d&&isFinite(d)?d:i,h=null!=f&&isFinite(f)?f:o,p=(h-r)/l||1,y=Array(l).fill(0);for(const t of e)r>t||t>h||y[Math.min(Math.floor((t-r)/p),l-1)]++;const g=e.length,m=ot(y,1),x=s(t.pieceData[0],t.name);for(let e=0;l>e;e++){if(0===y[e])continue;const i=(u?y[e]/g:y[e]/m)*t.width*.9,o=a(r+e*p),n=a(r+(e+1)*p);c.push(Ir(Math.min(o,n),t.x+t.width-i,Math.abs(n-o),i,x,{bin:e,count:y[e],range:[r+e*p,r+(e+1)*p],category:t.name},t.name))}}return c},ridgeline:function(t,e){const{scales:i,columns:o,config:r,getR:n,resolveSummaryStyle:s}=t,{r:a,projection:c}=i,l=[],u=r.bins||20,h="horizontal"===c,d=r.amplitude||1.5;for(const t of Object.values(o)){const e=t.pieceData.map(t=>n(t)).filter(t=>null!=t&&!isNaN(t)).sort((t,e)=>t-e);if(2>e.length)continue;const i=e[0],o=e[e.length-1],r=(o-i)/u||1,c=Array(u).fill(0);for(const t of e)i>t||t>o||c[Math.min(Math.floor((t-i)/r),u-1)]++;const f=ot(c,1),p=s(t.pieceData[0],t.name),y=t.width*d;let g;if(h){const e=t.x+t.width;g=`M ${a(i)} ${e}`;for(let t=0;u>t;t++)g+=` L ${a(i+(t+.5)*r)} ${e-c[t]/f*y}`;g+=` L ${a(o)} ${e} Z`}else{const e=t.x;g=`M ${e} ${a(i)}`;for(let t=0;u>t;t++){const o=a(i+(t+.5)*r);g+=` L ${e+c[t]/f*y} ${o}`}g+=` L ${e} ${a(o)} Z`}const m=h?{x:Math.min(a(i),a(o)),y:t.x,width:Math.abs(a(o)-a(i)),height:t.width}:{x:t.x,y:Math.min(a(o),a(i)),width:t.width,height:Math.abs(a(o)-a(i))};l.push({type:"violin",pathString:g,translateX:0,translateY:0,bounds:m,stats:wc(e),style:{...p,fillOpacity:p.fillOpacity??.5},datum:t.pieceData,category:t.name})}return l},timeline:function(t,e){const{scales:i,columns:o,getRawRange:r,resolvePieceStyle:n}=t,{r:s,projection:a}=i,c=[],l="horizontal"===a;for(const t of Object.values(o))for(const e of t.pieceData){const i=r(e);if(!i)continue;const[o,a]=i,u=n(e,t.name);if(l){const i=s(Math.min(o,a)),r=s(Math.max(o,a));c.push(Ir(i,t.x,r-i,t.width,u,e,t.name))}else{const i=s(Math.max(o,a)),r=s(Math.min(o,a));c.push(Ir(t.x,i,t.width,r-i,u,e,t.name))}}return c},funnel:function(t,e){const{columns:i,getR:o,getStack:r,resolvePieceStyle:n}=t,s=[],a=e.width/2,c=!1!==t.config.showLabels,l=t.scales.o.domain().map(t=>i[t]).filter(Boolean);if(0===l.length)return s;const u=[],h=new Set;for(const t of l)for(const e of t.pieceData){const t=r?r(e):"_default";h.has(t)||(h.add(t),u.push(t))}const d=u.length>1&&"_default"!==u[0],f=[];let p=0;for(const t of l){const e=new Map;let i=0;for(const n of t.pieceData){const t=r?r(n):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const s=e.get(t),a=o(n);s.total+=a,s.pieces.push(n),i+=a}f.push({col:t,groups:e,stepTotal:i}),d||i>p&&(p=i)}if(d)for(const t of f){let e=0,i=0;for(let o=0;u.length>o;o++){const r=t.groups.get(u[o]);r&&(o%2==0?e+=r.total:i+=r.total)}const o=Math.max(e,i);o>p&&(p=o)}if(0===p)return s;const y=new Map;for(const t of u){const e=f[0].groups.get(t);y.set(t,e?.total??0)}const g=f[0].stepTotal,m=d?.95*a:.9*e.width,x=(0,kc.scaleLinear)().domain([0,p]).range([0,m]),b=t.config.connectorOpacity??.3;let v=new Map;for(let e=0;f.length>e;e++){const i=f[e],o=i.col,r=0===e,l=o.width,h=.55*l,p=o.x+(l-h)/2,m=new Map;if(d){let t=0;for(const e of u){const o=i.groups.get(e);o&&(t+=x(o.total))}let e=a,l=a;for(let d=0;u.length>d;d++){const f=u[d],g=i.groups.get(f);if(!g)continue;const b=x(g.total),v=d%2==0,w=v?e:l-b;v?e+=b:l-=b;const k=n(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===d&&(A.__funnelStepLabel=o.name,A.__funnelStepLabelX=a,A.__funnelStepLabelY=p,A.__funnelRowWidth=t),A.__funnelValueLabelX=w+b/2,A.__funnelValueLabelY=p,A.__funnelBarW=b),s.push(Ir(w,p,b,h,k,A,f)),m.set(f,{x:w,y:p,w:b,h:h})}}else{const t=i.stepTotal,e=x(t),l=a-e/2,d=u[0],f="_default"!==d,y=i.groups.get(d)?.pieces[0]??o.pieceData[0],b=f?d:o.name,v=n(y,b),w=g>0?t/g*100:0,k={...y,__funnelValue:t,__funnelPercent:w,__funnelStep:o.name,__funnelIsFirstStep:r,category:f?d:o.name};c&&(k.__funnelStepLabel=o.name,k.__funnelStepLabelX=a,k.__funnelStepLabelY=p,k.__funnelRowWidth=e,k.__funnelValueLabelX=a,k.__funnelValueLabelY=p,k.__funnelBarW=e),s.push(Ir(l,p,e,h,v,k,b)),m.set(d,{x:l,y:p,w:e,h:h})}if(e>0&&v.size>0){const e=d?u:[u[0]];for(const r of e){const e=v.get(r),a=m.get(r);if(!e||!a)continue;const c=(()=>{const t=i.groups.get(r);return n(t?t.pieces[0]:o.pieceData[0],"_default"===r?o.name:r)})(),l={type:"trapezoid",points:[[e.x,e.y+e.h],[e.x+e.w,e.y+e.h],[a.x+a.w,a.y],[a.x,a.y]],style:{fill:c.fill||t.config.themeSemantic?.secondary||"#999",opacity:b},datum:i.groups.get(r)?.pieces[0]??o.pieceData[0],category:"_default"===r?o.name:r};s.push(l)}}v=m}return s},"bar-funnel":function(t,e){const{columns:i,getR:o,getStack:r,resolvePieceStyle:n,scales:s}=t,a=[],c=s.o.domain().map(t=>i[t]).filter(Boolean);if(0===c.length)return a;const l=[],u=new Set;for(const t of c)for(const e of t.pieceData){const t=r?r(e):"_default";u.has(t)||(u.add(t),l.push(t))}const h=l.length>1&&"_default"!==l[0],d=[];for(const t of c){const e=new Map;let i=0;for(const n of t.pieceData){const t=r?r(n):"_default";e.has(t)||e.set(t,{total:0,pieces:[]});const s=e.get(t),a=o(n);s.total+=a,s.pieces.push(n),i+=a}d.push({col:t,groups:e,stepTotal:i})}const f=new Map;for(const t of l){const e=d[0]?.groups.get(t);f.set(t,e?.total??0)}const p=s.r,y=h?l.length:1,g=h?.15:0;for(let t=0;d.length>t;t++){const e=d[t],i=e.col,o=0===t,r=t>0?d[t-1]:null,s=i.width/y,c=s*g,u=s-c;for(let t=0;l.length>t;t++){const d=l[t],y=e.groups.get(d);if(!y)continue;const g=y.total,m=f.get(d)??g,x=m>0?g/m*100:0,b=r?.groups.get(d),v=o?0:Math.max(0,(b?.total??g)-g),w=i.x+t*s+c/2,k=p(g),S=p(0)-k,A=n(y.pieces[0],h?d:i.name),M={...y.pieces[0],__barFunnelValue:g,__barFunnelPercent:x,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===d?void 0:d,category:h?d:i.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:p(g+v)};if(a.push(Ir(w,k,u,S,A,M,h?d:i.name)),v>0){const t=p(g+v),e=k-t,o={...A},r={...y.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===d?void 0:d,category:h?d:i.name};a.push(Ir(w,t,u,e,o,r,h?d:i.name))}}}return a},swimlane:function(t,e){const{scales:i,columns:o,getR:r,getStack:n,resolvePieceStyle:s}=t,{r:a,projection:c}=i,l=[],u="horizontal"===c,h=t.config.gradientFill,d=u?"left":"bottom",f=t.config.trackFill;if(f){const t="string"==typeof f?f:f.color,e="string"==typeof f?1:f.opacity??1,[i,r]=a.range(),n=Math.min(i,r),s=Math.abs(r-i);for(const i of Object.values(o)){const o={fill:t,opacity:e},r=u?Ir(n,i.x,s,i.width,o,null,"__track__"):Ir(i.x,n,i.width,s,o,null,"__track__");l.push(r)}}const p=t.config.roundedTop&&t.config.roundedTop>0?Math.max(0,t.config.roundedTop):0;for(const t of Object.values(o)){let e=0;const i=l.length;for(const i of t.pieceData){const o=Math.abs(r(i));if(0===o)continue;const c=n?n(i):t.name,f=s(i,c);let p;if(u){const r=a(e),n=a(e+o);p=Ir(r,t.x,n-r,t.width,f,i,c)}else{const r=a(e+o),n=a(e);p=Ir(t.x,r,t.width,n-r,f,i,c)}h&&(p.fillGradient=h,p.roundedEdge=d),l.push(p),e+=o}if(p>0&&l.length>i){const t=l.slice(i),e=t[0],o=t[t.length-1];1===t.length?e.cornerRadii={tl:p,tr:p,br:p,bl:p}:u?(e.cornerRadii={tl:p,bl:p},o.cornerRadii={tr:p,br:p}):(e.cornerRadii={bl:p,br:p},o.cornerRadii={tl:p,tr:p})}}return l}},Ac=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Mc=["scene-style","data-paint","accessibility","evidence"],_c=(t,e)=>({retainedData:t,invalidations:e}),Pc=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Lc=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Rc=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Tc=["scene-geometry","data-paint","accessibility","evidence"],Cc=["scene-style","data-paint","accessibility","evidence"],$c=[],jc={chartType:_c("rebuild",Pc),runtimeMode:_c("rebuild",Pc),categoryAccessor:_c("rebuild",Pc),valueAccessor:_c("rebuild",Pc),oAccessor:_c("rebuild",Pc),rAccessor:_c("rebuild",Pc),stackBy:_c("rebuild",Pc),groupBy:_c("rebuild",Pc),timeAccessor:_c("rebuild",Pc),accessorRevision:_c("rebuild",Pc),colorAccessor:_c("rebuild",Cc),symbolAccessor:_c("rebuild",Tc),connectorAccessor:_c("rebuild",Tc),dataIdAccessor:_c("rebuild",Tc),projection:_c("preserve",Lc),extentPadding:_c("preserve",Lc),axisExtent:_c("preserve",Lc),rExtent:_c("preserve",Lc),oExtent:_c("preserve",Lc),multiAxis:_c("preserve",Lc),normalize:_c("preserve",Lc),bins:_c("preserve",Lc),oSort:_c("preserve",Rc),barPadding:_c("preserve",Rc),roundedTop:_c("preserve",Rc),baselinePadding:_c("preserve",Rc),innerRadius:_c("preserve",Rc),cornerRadius:_c("preserve",Rc),startAngle:_c("preserve",Rc),sweepAngle:_c("preserve",Rc),trackFill:_c("preserve",Rc),showOutliers:_c("preserve",Rc),showIQR:_c("preserve",Rc),amplitude:_c("preserve",Rc),connectorOpacity:_c("preserve",Rc),showLabels:_c("preserve",Rc),dynamicColumnWidth:_c("rebuild",Rc),customLayout:_c("preserve",Rc),layoutConfig:_c("preserve",Rc),layoutMargin:_c("preserve",Rc),symbolMap:_c("preserve",Tc),pieceStyle:_c("preserve",Cc),summaryStyle:_c("preserve",Cc),connectorStyle:_c("preserve",Cc),gradientFill:_c("preserve",Cc),colorScheme:_c("preserve",Cc),themeCategorical:_c("preserve",Cc),themeSemantic:_c("preserve",Cc),themeSequential:_c("preserve",Cc),themeDiverging:_c("preserve",Cc),barColors:_c("preserve",Cc),decay:_c("preserve",Cc),pulse:_c("preserve",Cc),staleness:_c("preserve",Cc),layoutSelection:_c("preserve",Cc),windowSize:_c("preserve",$c),windowMode:_c("preserve",$c),clock:_c("preserve",$c),transition:_c("preserve",$c),introAnimation:_c("preserve",$c),onLayoutError:_c("preserve",$c)},zc=_c("preserve",Rc),Ec=class{constructor(){this.tracker=new xo}get last(){return this.tracker.last}subscribe(t){return this.tracker.subscribe(t)}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},Ac)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},Mc):this.recordNoop("restyle")}recordConfig(t){const e=function(t){let e="preserve";const i=new Set;for(const o of t){const t=jc[o]??zc;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}(t);return this.tracker.record({kind:"config",keys:t},e.invalidations)}},Dc=require("d3-quadtree"),Fc=class{constructor(t){this.rExtent=new mr,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new Ec,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new gc,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=t,this.buffer=new gr(t.windowSize),this.getO=wr(t.categoryAccessor||t.oAccessor,"category");const e=t.valueAccessor||t.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(t=>br(t,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new mr)):(this.getR=br(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=wr(t.stackBy),this.getGroup=wr(t.groupBy),this.getColor=wr(t.colorAccessor),this.getSymbol=wr(t.symbolAccessor),this.getConnector=wr(t.connectorAccessor),this.getDataId=wr(t.dataIdAccessor),t.pulse&&(this.timestampBuffer=new gr(t.windowSize))}syncPulseTimestampBuffer(){var t,e,i,o;this.timestampBuffer=(t=!!this.config.pulse,e=this.buffer,i=this.timestampBuffer,o=this.currentTime(),t?null!=i&&i.capacity===e.capacity&&i.size===e.size?i:yn(e,o):null)}currentTime(){return this.config.clock?.()??Rr()}ingest(t){const e=this.currentTime();if(this.lastIngestTime=e,this._dataVersion++,t.bounded){this.buffer.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();t.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),pn(this.buffer,t.totalSize||t.inserts.length,this.timestampBuffer);for(const i of t.inserts)gn(this.buffer,i,this.timestampBuffer,e),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(const i of t.inserts){const t=gn(this.buffer,i,this.timestampBuffer,e);this.categories.add(this.getO(i)),this.pushValueExtent(i),null!=t&&this.evictValueExtent(t)}}return this.updateResults.recordData(t.bounded?"replace":"ingest",t.inserts.length),!0}ingestWithResult(t){return this.ingest(t),this.updateResults.last}pushValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.push(e[0]),this.rExtent.push(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].push(this.rAccessors[e](t));this.rExtent.push(this.getR(t))}else this.rExtent.push(this.getR(t))}evictValueExtent(t){if("timeline"===this.config.chartType){const e=this.getRawRange(t);e&&(this.rExtent.evict(e[0]),this.rExtent.evict(e[1]))}else if(this.rAccessors.length>1){for(let e=0;this.rAccessors.length>e;e++)this.rExtents[e].evict(this.rAccessors[e](t));this.rExtent.evict(this.getR(t))}else this.rExtent.evict(this.getR(t))}getRawRange(t){const e=this.config.valueAccessor||this.config.rAccessor;if(!e)return null;const i="function"==typeof e?e(t):t[e];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(t){const{config:e,buffer:i}=this,o=this.scales,r=this.multiScales,n=this.columns;if(0===i.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(i,this.getR);const s=this.getBufferArray(),a=e.projection||"vertical",c=e.oExtent||this.resolveCategories(s),l=this.computeValueDomain(s,c),u="horizontal"===a,h="radial"===a,d=Math.min(.9,Math.max(0,null!=e.barPadding?e.barPadding/("vertical"===a?t.width:t.height):.1));let f,p;if(h){f=(0,yc.scaleBand)().domain(c).range([0,1]).padding(0);const i=Math.min(t.width,t.height)/2,o=e.innerRadius||0;p=(0,yc.scaleLinear)().domain(l).range([o,i])}else u?(f=(0,yc.scaleBand)().domain(c).range([0,t.height]).padding(d),p=(0,yc.scaleLinear)().domain(l).range([0,t.width])):(f=(0,yc.scaleBand)().domain(c).range([0,t.width]).padding(d),p=(0,yc.scaleLinear)().domain(l).range([t.height,0]));this.scales={o:f,r:p,projection:a},this.multiScales=this.rAccessors.length>1&&e.multiAxis?this.rAccessors.map((o,r)=>{const n=this.rExtents[r];n.dirty&&n.recalculate(i,o);let[s,a]=n.extent;s===1/0&&(s=0,a=1);const c=a-s,l=c>0?c*(e.extentPadding??.05):1;return s-=l,a+=l,s>0&&(s=0),u?(0,yc.scaleLinear)().domain([s,a]).range([0,t.width]):(0,yc.scaleLinear)().domain([s,a]).range([t.height,0])}):[];let y=s;this.rAccessors.length>1&&(y=s.flatMap(t=>this.rAccessors.map((e,i)=>({...t,__rIndex:i,__rValue:e(t),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(y,c,f,a,t),this._customLayoutFailedThisBuild=!1;const g=this.buildSceneNodes(y,t);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=o,this.multiScales=r,this.columns=n):(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(t){const e=this.config.valueAccessor||this.config.rAccessor,i=Array.isArray(e)?e[t]:e;return"string"==typeof i?i:"value"+t}resolveCategories(t){const e=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===e?void 0:e;let r=null;if(i){r=new Set;for(const e of t)r.add(this.getO(e))}const n=r?Array.from(this.categories).filter(t=>r.has(t)):Array.from(this.categories);if(i&&void 0===o){const t=Math.max(50,3*r.size);if(this.categories.size>t){let e=this.categories.size-t;for(const t of this.categories){if(0>=e)break;r.has(t)||(this.categories.delete(t),e--)}}return n}if(!1===o)return n;if("function"==typeof o)return n.sort(o);const s=new Map;for(const e of t){const t=this.getO(e);s.set(t,(s.get(t)||0)+Math.abs(this.getR(e)))}return n.sort("asc"===o?(t,e)=>(s.get(t)||0)-(s.get(e)||0):(t,e)=>(s.get(e)||0)-(s.get(t)||0))}computeValueDomain(t,e){return function(t){const{data:e,chartType:i,projection:o,normalize:r,rExtent:n,extentPadding:s=.05,baselinePadding:a,axisExtent:c,getO:l,getR:u,getStack:h,rawRExtent:d}=t,f=s;if("radial"===o&&("pie"===i||"donut"===i))return[0,1];let p=0,y=0;if("bar"===i&&h&&r)p=0,y=1;else if("bar"===i&&h){const t=new Map,i=new Map;for(const o of e){const e=l(o),r=u(o);0>r?i.set(e,(i.get(e)||0)+r):t.set(e,(t.get(e)||0)+r)}for(const e of t.values())e>y&&(y=e);for(const t of i.values())p>t&&(p=t)}else if("bar"===i){const t=new Map;for(const i of e){const e=l(i),o=u(i);t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>y&&(y=e),p>e&&(p=e)}else if("swimlane"===i){const t=new Map;for(const i of e){const e=l(i),o=Math.abs(u(i));t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>y&&(y=e)}else if("clusterbar"===i||"bar-funnel"===i)for(const t of e){const e=u(t);e>y&&(y=e),p>e&&(p=e)}else{const t=d[0],e=d[1];t!==1/0&&(p=t),e!==-1/0&&(y=e)}n&&(null!=n[0]&&(p=n[0]),null!=n[1]&&(y=n[1]));const g="bar"===i||"clusterbar"===i||"bar-funnel"===i||"swimlane"===i;if(g&&null==n?.[0]&&null==n?.[1]&&(p>0&&(p=0),0>y&&(y=0)),"bar-funnel"!==i&&"exact"!==c){const t=y-p,e=t>0?t*f:1,o=g&&!a&&0===p,r=g&&!a&&0===y||"swimlane"===i;null!=n?.[0]||o||(p-=e),null!=n?.[1]||r||(y+=e)}return[p,y]}({data:t,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(t,e,i,o,r){return function(t){const{data:e,oExtent:i,oScale:o,projection:r,layout:n,dynamicColumnWidth:s,getO:a,getR:c}=t,l={},u=new Map;for(const t of e){const e=a(t);u.has(e)||u.set(e,[]),u.get(e).push(t)}let h=0;if("radial"===r)for(const t of e)h+=Math.abs(c(t));let d=null;if(s&&"radial"!==r){d=new Map;let t=0;for(const e of i){const i=u.get(e)||[];let o;o="string"==typeof s?i.reduce((t,e)=>t+(Number(e[s])||0),0):s(i),d.set(e,o),t+=o}const e=("horizontal"===r?n.height:n.width)-o.padding()*o.step()*i.length;if(t>0)for(const[i,o]of d)d.set(i,o/t*e)}let f=0,p=0;for(const t of i){const e=u.get(t)||[],i=e.reduce((t,e)=>t+Math.abs(c(e)),0),r=h>0?i/h:0;let n,s;d?(n=p,s=d.get(t)||o.bandwidth(),p+=s+o.padding()*o.step()):(n=o(t)??0,s=o.bandwidth()),l[t]={name:t,x:n,y:0,width:s,middle:n+s/2,padding:o.padding()*o.step(),pieceData:e,pct:r,pctStart:f},f+=r}return l}({data:t,oExtent:e,oScale:i,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:(t,e)=>this.styleResolver.resolvePieceStyle(this.config,t,e),resolveSummaryStyle:(t,e)=>this.styleResolver.resolveSummaryStyle(this.config,t,e),getRawRange:t=>this.getRawRange(t)}}buildSceneNodes(t,e){if(!this.scales)return[];if(this.config.customLayout){const i=this.buildLayoutContext(t,e);let o;try{o=this.config.customLayout(i)}catch(t){const e=null!==this.lastCustomLayoutResult,i=cn("ordinal",t,e,this.version);this.lastCustomLayoutFailure=i,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",t);try{this.config.onLayoutError?.(i)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return e?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}this.customLayoutOverlays=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 t of r)t.style&&this._baseStyles.set(t,t.style);this.applyCustomRestyle(r,this.config.layoutSelection??null)}return nn({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 i=this.getSceneContext(),o=Sc[this.config.chartType];let r=o?o(i,e):[];if(this.getConnector&&this.scales){const t=function(t,e){const{scales:i,config:o,getConnector:r,getO:n}=t;if(!r||!i)return[];const s=[],{projection:a}=i,c=new Map;for(const t of e){if("point"!==t.type&&"rect"!==t.type)continue;const e=t.datum;if(!e)continue;const i=r(e);if(!i)continue;let o,s;"point"===t.type?(o=t.x,s=t.y):(o=t.x+t.w/2,s=t.y+("vertical"===a?0:t.h/2)),c.has(i)||c.set(i,[]),c.get(i).push({x:o,y:s,datum:e,category:n(e)})}const l=i.o.domain(),u=o.connectorStyle;for(const[e,i]of c)if(i.length>=2){i.sort((t,e)=>l.indexOf(t.category)-l.indexOf(e.category));for(let o=0;i.length-1>o;o++){const r=i[o],n=i[o+1],a="function"==typeof u?u(r.datum):u||{stroke:t.config.themeSemantic?.border||t.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:r.x,y1:r.y,x2:n.x,y2:n.y,style:a,datum:r.datum,group:e})}}return s}(i,r);r=[...t,...r]}return r}buildLayoutContext(t,e){const i=this.config,o=i.layoutMargin??{top:0,right:0,bottom:0,left:0},r=Ko(i.colorScheme,i.themeCategorical,U),n=this.scales;return{data:t,scales:{o:n.o,r:n.r,projection:n.projection},dimensions:{width:e.width,height:e.height,margin:o,plot:"radial"===n.projection?{x:-e.width/2,y:-e.height/2,width:e.width,height:e.height}:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:i.themeSemantic??{},categorical:[...r]},resolveColor:Qo(r,i.colorScheme),config:i.layoutConfig??{},selection:i.layoutSelection??null}}computeDecayOpacity(t,e){const i=this.config.decay;return i&&e>1?Tr(i,t,e):1}getDatumIndexMap(t){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const e=Cr(t);return this._datumIndexCache={version:this._dataVersion,map:e},e}getCategoryIndexMap(t){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const e=function(t,e){const i="function"==typeof e,o=i?null:e||"category",r=new Map;for(let n=0;t.length>n;n++){const s=t[n],a=i?e(s):s[o],c=r.get(a);c?c.push(n):r.set(a,[n])}return r}(t,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:e},e}rebuildPointQuadtree(){const t=function(t){let e=0,i=0;for(const o of t)"point"===o.type&&(e++,o.r>i&&(i=o.r));if(500>=e)return{quadtree:null,maxRadius:i};const o=Array(e);let r=0;for(const e of t)"point"===e.type&&(o[r++]=e);return{maxRadius:i,quadtree:(0,Dc.quadtree)().x(t=>t.x).y(t=>t.y).addAll(o)}}(this.scene);this._pointQuadtree=t.quadtree,this._maxPointRadius=t.maxRadius}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(t,e){if(!this.config.decay)return;const i=e.length;if(1>=i)return;const o=this.getDatumIndexMap(e);for(const e of t){if("connector"===e.type||"violin"===e.type||"boxplot"===e.type||"wedge"===e.type)continue;if(!e.datum)continue;const t=o.get(e.datum);if(null==t)continue;const r=this.computeDecayOpacity(t,i);e.style={...e.style,opacity:(e.style?.opacity??1)*r}}}applyPulse(t,e,i=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&function(t,e,i,o,r,n){const s=t.color??"rgba(255,255,255,0.6)",a=t.glowRadius??4;let c=!1;for(const l of e){if("connector"===l.type||"violin"===l.type||"boxplot"===l.type)continue;if("wedge"===l.type){const e=l.category;if(!e)continue;let o=0;for(const s of r(e)??[]){const e=i.get(s);null!=e&&(o=Math.max(o,$r(t,e,n)))}c=jr(l,o,s)||c;continue}if(null==l.datum)continue;const e=o.get(l.datum);if(null==e)continue;const u=i.get(e);c=jr(l,null==u?0:$r(t,u,n),s,a)||c}return c}(this.config.pulse,t,this.timestampBuffer,this.getDatumIndexMap(e),t=>this.getCategoryIndexMap(e).get(t),i)}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),t)}hasActivePulsesAt(t){return!!this.config.pulse&&zr(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}synthesizeIntroPositions(){this.prevPositionMap.clear();const t=new Map,e=this.scales?.r(0)??0,i="horizontal"!==this.scales?.projection;let o;for(let r=0;this.scene.length>r;r++){const n=this.scene[r],s=this.getNodeKey(n,t);s&&("rect"===n.type?this.prevPositionMap.set(s,i?{x:n.x,y:e,w:n.w,h:0,opacity:n.style.opacity??1}:{x:e,y:n.y,w:0,h:n.h,opacity:n.style.opacity??1}):"point"===n.type?this.prevPositionMap.set(s,{x:n.x,y:n.y,r:0,opacity:0}):"wedge"===n.type&&(void 0===o&&(o=n.startAngle),this.prevPositionMap.set(s,{x:n.cx,y:n.cy,startAngle:o,endAngle:o,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:0})))}}getNodeKey(t,e){if("point"===t.type){const i=`p:${t.datum?this.getO(t.datum):""}:${t.datum?this.getR(t.datum):0}`,o=e.get(i)||0;return e.set(i,o+1),`${i}:${o}`}return"rect"===t.type?`r:${t.group||""}:${t.datum?.category??""}`:"wedge"===t.type?"w:"+(t.category??""):null}snapshotPositions(){this.prevPositionMap.clear();const t=new Map;for(let e=0;this.scene.length>e;e++){const i=this.scene[e],o=this.getNodeKey(i,t);o&&("point"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity}):"rect"===i.type?this.prevPositionMap.set(o,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity}):"wedge"===i.type&&this.prevPositionMap.set(o,{x:i.cx,y:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius,opacity:i.style.opacity??1}))}}startTransition(){if(!this.config.transition||0===this.prevPositionMap.size)return;const t=this.config.transition.duration??300;if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),this.exitNodes=[]}let e=!1;const i=new Set,o=new Map;for(let t=0;this.scene.length>t;t++){const r=this.scene[t],n=this.getNodeKey(r,o);if(!n)continue;r._transitionKey=n;const s=this.prevPositionMap.get(n);if("point"===r.type)s?(i.add(n),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),e=!0)):(r._targetOpacity=r.style.opacity??1,r._targetR=r.r,r.r=0,r.style={...r.style,opacity:0},e=!0);else if("rect"===r.type)s?(i.add(n),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,e=!0)):(r._targetOpacity=r.style.opacity??1,r.style={...r.style,opacity:0},e=!0);else if("wedge"===r.type)if(s)i.add(n),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,e=!0);else{r._targetOpacity=r.style.opacity??1,r._targetStartAngle=r.startAngle,r._targetEndAngle=r.endAngle;const t=r.startAngle;r.startAngle=t,r.endAngle=t,r.style={...r.style,opacity:0},this.prevPositionMap.set(n,{x:r.cx,y:r.cy,startAngle:t,endAngle:t,innerRadius:r.innerRadius,outerRadius:r.outerRadius,opacity:0}),e=!0}}this.exitNodes=[];for(const[t,o]of this.prevPositionMap)if(!i.has(t)){if(t.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:t});else if(t.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:t});else if(t.startsWith("w:")){const e=((o.startAngle??0)+(o.endAngle??0))/2,i={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:t.slice(2),_targetStartAngle:e,_targetEndAngle:e,_targetOpacity:0,_transitionKey:t};this.exitNodes.push(i)}e=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),e&&(this.activeTransition={startTime:this.currentTime(),duration:t})}advanceTransition(t){if(!this.activeTransition)return!1;const e=Pr(t,this.activeTransition),i=_r(e,"linear"===this.config.transition?.easing?"linear":"ease-out-cubic");for(const t of this.scene){const e=t._transitionKey;if(e)if("point"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e);t.style.opacity=Lr(o?o.opacity??1:0,t._targetOpacity,i)}const o=this.prevPositionMap.get(e);void 0!==t._targetX&&o&&(t.x=Lr(o.x,t._targetX,i),t.y=Lr(o.y,t._targetY,i)),void 0!==t._targetR&&void 0!==o?.r&&(t.r=Lr(o.r,t._targetR,i))}else if("rect"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e);t.style.opacity=Lr(o?o.opacity??1:0,t._targetOpacity,i)}if(void 0===t._targetX)continue;const o=this.prevPositionMap.get(e);if(!o)continue;t.x=Lr(o.x,t._targetX,i),t.y=Lr(o.y,t._targetY,i),void 0!==o.w&&(t.w=Lr(o.w,t._targetW,i),t.h=Lr(o.h,t._targetH,i))}else if("wedge"===t.type){if(void 0!==t._targetOpacity){const o=this.prevPositionMap.get(e);t.style={...t.style,opacity:Lr(o?o.opacity??1:0,t._targetOpacity,i)}}if(void 0!==t._targetStartAngle&&void 0!==t._targetEndAngle){const o=this.prevPositionMap.get(e);o&&void 0!==o.startAngle&&(t.startAngle=Lr(o.startAngle,t._targetStartAngle,i),t.endAngle=Lr(o.endAngle,t._targetEndAngle,i))}}}if(e>=1){for(const t of this.scene)if(void 0!==t._targetOpacity&&(t.style={...t.style||{},opacity:0===t._targetOpacity?0:t._targetOpacity},t._targetOpacity=void 0),"point"===t.type){if(void 0===t._targetX&&void 0===t._targetR)continue;void 0!==t._targetX&&(t.x=t._targetX,t.y=t._targetY),void 0!==t._targetR&&(t.r=t._targetR),t._targetX=void 0,t._targetY=void 0,t._targetR=void 0}else if("rect"===t.type){if(void 0===t._targetX)continue;t.x=t._targetX,t.y=t._targetY,t.w=t._targetW,t.h=t._targetH,t._targetX=void 0,t._targetY=void 0,t._targetW=void 0,t._targetH=void 0}else"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0);if(this.exitNodes.length>0){const t=new Set(this.exitNodes);this.scene=this.scene.filter(e=>!t.has(e)),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(t){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const e=Mr(t),i=this.getDataId,o=t=>e.has(i(t));mn(this.buffer,this.timestampBuffer,o);const r=this.buffer.remove(o);if(0===r.length)return this.updateResults.recordNoop("remove"),r;for(const t of r)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach(t=>this.categories.add(this.getO(t))),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("remove",r.length),r}update(t,e){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const i=Mr(t),o=this.getDataId,r=new Set;this.buffer.forEach((t,e)=>{i.has(o(t))&&r.add(e)});const n=this.buffer.update(t=>i.has(o(t)),e);if(0===n.length)return this.updateResults.recordNoop("update"),n;for(const t of n)this.evictValueExtent(t);return this.categories.clear(),this.buffer.forEach((t,e)=>{this.categories.add(this.getO(t)),r.has(e)&&this.pushValueExtent(t)}),this._dataVersion++,this.version++,this.lastIngestTime=this.currentTime(),this.updateResults.recordData("update",n.length),n}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(t,e){const i=this._customRestyle;if(i)for(const o of t){const t=this._baseStyles.get(o)??o.style??{},r=i(o,e);o.style=r?{...t,...r}:t}}restyleScene(t){this._customRestyle?(this.applyCustomRestyle(this.scene,t),this.updateResults.recordRestyle(!0)):this.updateResults.recordRestyle(!1)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(const t of this.rExtents)t.clear();this._categoryIndexCache=null,this.buffer.forEach(t=>{this.categories.add(this.getO(t)),this.pushValueExtent(t)})}updateConfig(t){const e={...this.config},i=Object.keys(t).filter(i=>t[i]!==e[i]);"production"!==process.env.NODE_ENV&&!this.windowSizeWarned&&"windowSize"in t&&t.windowSize!==e.windowSize&&(this.windowSizeWarned=!0,console.warn(`[Semiotic] windowSize changed after mount (${e.windowSize} → ${t.windowSize}) but it is a mount-only setting — the ring buffer keeps its original capacity. Remount the chart (e.g. via a React key) to apply a new windowSize.`)),("colorScheme"in t&&t.colorScheme!==e.colorScheme||"themeCategorical"in t&&t.themeCategorical!==e.themeCategorical||"colorAccessor"in t&&!xr(t.colorAccessor,e.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in t&&!xr(t.categoryAccessor,e.categoryAccessor)||"oAccessor"in t&&!xr(t.oAccessor,e.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,t),"pulse"in t&&this.syncPulseTimestampBuffer();let o=!1;("categoryAccessor"in t||"oAccessor"in t)&&(xr(this.config.categoryAccessor||this.config.oAccessor,e.categoryAccessor||e.oAccessor)||(this.getO=wr(this.config.categoryAccessor||this.config.oAccessor,"category"),o=!0));let r=!1;if("valueAccessor"in t||"rAccessor"in t){const t=this.config.valueAccessor||this.config.rAccessor,i=e.valueAccessor||e.rAccessor,o=Array.isArray(t)?t:[t],n=Array.isArray(i)?i:[i];if(r=o.length!==n.length||o.some((t,e)=>!xr(t,n[e])),r){const t=this.config.valueAccessor||this.config.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(t=>br(t,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new mr)):(this.getR=br(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in t&&!xr(t.stackBy,e.stackBy)&&(this.getStack=null!=this.config.stackBy?wr(this.config.stackBy):void 0),"groupBy"in t&&!xr(t.groupBy,e.groupBy)&&(this.getGroup=null!=this.config.groupBy?wr(this.config.groupBy):void 0),"colorAccessor"in t&&!xr(t.colorAccessor,e.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?wr(this.config.colorAccessor):void 0),"symbolAccessor"in t&&!xr(t.symbolAccessor,e.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?wr(this.config.symbolAccessor):void 0),"connectorAccessor"in t&&!xr(t.connectorAccessor,e.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?wr(this.config.connectorAccessor):void 0),(o||r||"accessorRevision"in t&&t.accessorRevision!==e.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(i)}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}};Mn(Fc);var Oc=require("react/jsx-runtime"),Nc=require("react/jsx-runtime");function Bc(t,e){const i=Pt(t.theme),o=t.size||[500,400],r=Qa({top:20,right:20,bottom:30,left:40,...t.margin},t.title),n=Ka(t.title),s=b(t.data),a=t.showLegend?js(s,t.colorAccessor||t.stackBy||t.groupBy):[];cc(r,{props:t,categories:a,theme:i,size:o,hasTitle:n});const c=o[0]-r.left-r.right,l=o[1]-r.top-r.bottom,u=t.projection||"vertical",h="radial"===u,d={chartType:t.chartType,windowSize:t.windowSize??1e4,windowMode:t.windowMode??"sliding",extentPadding:t.extentPadding??.05,projection:u,oAccessor:t.oAccessor,rAccessor:t.rAccessor,colorAccessor:t.colorAccessor,stackBy:t.stackBy,groupBy:t.groupBy,categoryAccessor:t.categoryAccessor,valueAccessor:t.valueAccessor,timeAccessor:t.timeAccessor,rExtent:t.rExtent,oExtent:t.oExtent,axisExtent:t.axisExtent,barPadding:t.barPadding,roundedTop:t.roundedTop,innerRadius:t.innerRadius,cornerRadius:t.cornerRadius,normalize:t.normalize,startAngle:t.startAngle,sweepAngle:t.sweepAngle,bins:t.bins,showOutliers:t.showOutliers,showIQR:t.showIQR,amplitude:t.amplitude,oSort:t.oSort,connectorAccessor:t.connectorAccessor,connectorStyle:t.connectorStyle,dynamicColumnWidth:t.dynamicColumnWidth,pieceStyle:t.pieceStyle,summaryStyle:t.summaryStyle,gradientFill:t.gradientFill,symbolAccessor:t.symbolAccessor,symbolMap:t.symbolMap,multiAxis:t.multiAxis,baselinePadding:t.baselinePadding,trackFill:t.trackFill,connectorOpacity:t.connectorOpacity,showLabels:t.showLabels,colorScheme:t.colorScheme||i.colors.categorical,themeCategorical:i.colors.categorical,themeSemantic:mt(i),customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:r,layoutSelection:t.layoutSelection,barColors:t.barColors},f=new Fc(d);if(t.data&&f.ingest({inserts:s,bounded:!0}),f.computeScene({width:c,height:l}),!f.scales||0===f.scene.length)return e&&(e.evidence=fr({frameType:"ordinal",width:o[0],height:o[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,extraWarnings:f.scales?[]:["NO_SCALES"]})),pc.renderToStaticMarkup(hc(null,{width:o[0],height:o[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${r.left},${r.top})`,innerWidth:c,innerHeight:l,idPrefix:t._idPrefix}));const p=t._idPrefix,y=t.showGrid?function(t,e,i,o,r){const n=t.scales;if(!n||"radial"===n.projection)return null;const{grid:s}=Lt(i),a=o?o+"-":"",c="vertical"===n.projection,l=tc(n.r,5,r);return(0,ec.jsx)("g",c?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((t,i)=>{const o=n.r(t);return(0,ec.jsx)("line",{x1:0,y1:o,x2:e.width,y2:o,stroke:s,strokeWidth:.5},"gr-"+i)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:l.map((t,i)=>{const o=n.r(t);return(0,ec.jsx)("line",{x1:o,y1:0,x2:o,y2:e.height,stroke:s,strokeWidth:.5},"gr-"+i)})})}(f,{width:c,height:l},i,p,t.axisExtent):null;let g=null;if(f.scene.some(t=>"rect"===t.type&&t.datum?.__barFunnelIsDropoff)){const e=oc(t),o=new Set;for(const t of f.scene)"rect"===t.type&&t.datum?.__barFunnelIsDropoff&&o.add("string"==typeof t.style.fill?t.style.fill:"#666");g=Array.from(o).map((t,o)=>function(t){const{id:e,background:i="transparent",stroke:o="#000",lineWidth:r=1.5,spacing:n=6,angle:s=45}=t,a=Math.max(8,Math.ceil(2*n));return(0,Oc.jsxs)("pattern",{id:e,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[i&&"transparent"!==i&&(0,Oc.jsx)("rect",{width:a,height:a,fill:i}),(0,Oc.jsx)("line",{x1:0,y1:0,x2:0,y2:a,stroke:o,strokeWidth:r}),(0,Oc.jsx)("line",{x1:n,y1:0,x2:n,y2:a,stroke:o,strokeWidth:r})]},e)}({id:`funnel-hatch-${e}-${o}`,background:t,stroke:"transparent"===i.colors.background?"#fff":i.colors.background,lineWidth:1.5,spacing:5,angle:45}));const r=new Map;Array.from(o).forEach((t,i)=>r.set(t,`funnel-hatch-${e}-${i}`));for(const t of f.scene)"rect"===t.type&&t.datum?.__barFunnelIsDropoff&&(t.style={...t.style,fill:`url(#${r.get("string"==typeof t.style.fill?t.style.fill:"#666")})`})}const m=ks({nodes:f.scene,renderMode:t.renderMode,fallback:(t,e)=>bs(t,e,p)}),x=m.map(t=>t.element);if(e){const i=f.scales.o?.domain?.();e.evidence=fr({frameType:"ordinal",width:o[0],height:o[1],marks:m.map(t=>t.node),title:t.title,description:t.description,annotations:t.annotations,yDomain:dr(f.scales.r?.domain?.()),categories:Array.isArray(i)?i.map(String):void 0})}const v=!1!==t.showAxes?function(t,e,i,o,r){const n=t.scales;if(!n)return null;if("radial"===n.projection)return null;const s=Lt(o),a="vertical"===n.projection,c=i.categoryFormat||i.oFormat,l=i.valueFormat||i.rFormat,u=i.categoryLabel||i.oLabel,h=i.valueLabel||i.rLabel,d=Object.values(t.columns).map(t=>({pixel:t.middle,label:(c||String)(t.name)})),f=tc(n.r,5,i.axisExtent).map(t=>({pixel:n.r(t),label:(l||uc)(t)}));return(0,Nc.jsxs)("g",a?{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[(0,Nc.jsx)("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:s.border,strokeWidth:1}),d.map((t,i)=>(0,Nc.jsxs)("g",{transform:`translate(${t.pixel},${e.height})`,children:[(0,Nc.jsx)("line",{y2:5,stroke:s.border,strokeWidth:1}),(0,Nc.jsx)("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oxtick-"+i)),u&&(0,Nc.jsx)("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:u}),(0,Nc.jsx)("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:s.border,strokeWidth:1}),f.map((t,e)=>(0,Nc.jsxs)("g",{transform:`translate(0,${t.pixel})`,children:[(0,Nc.jsx)("line",{x2:-5,stroke:s.border,strokeWidth:1}),(0,Nc.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oytick-"+e)),h&&(0,Nc.jsx)("text",{x:15-(i.margin?.left??40),y:e.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(i.margin?.left??40)}, ${e.height/2})`,children:h})]}:{id:(r?r+"-":"")+"axes",className:"ordinal-axes",children:[(0,Nc.jsx)("line",{x1:0,y1:e.height,x2:e.width,y2:e.height,stroke:s.border,strokeWidth:1}),f.map((t,i)=>(0,Nc.jsxs)("g",{transform:`translate(${t.pixel},${e.height})`,children:[(0,Nc.jsx)("line",{y2:5,stroke:s.border,strokeWidth:1}),(0,Nc.jsx)("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oxtick-"+i)),h&&(0,Nc.jsx)("text",{x:e.width/2,y:e.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:h}),(0,Nc.jsx)("line",{x1:0,y1:0,x2:0,y2:e.height,stroke:s.border,strokeWidth:1}),d.map((t,e)=>(0,Nc.jsxs)("g",{transform:`translate(0,${t.pixel})`,children:[(0,Nc.jsx)("line",{x2:-5,stroke:s.border,strokeWidth:1}),(0,Nc.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:t.label})]},"oytick-"+e)),u&&(0,Nc.jsx)("text",{x:15-(i.margin?.left??40),y:e.height/2,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,transform:`rotate(-90, ${15-(i.margin?.left??40)}, ${e.height/2})`,children:u})]})}(f,{width:c,height:l},t,i,p):null,w=t.annotations?Xa({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{o:f.scales.o,r:f.scales.r,y:"vertical"===f.scales.projection?f.scales.r:void 0},layout:{width:c,height:l},theme:i,projection:u,idPrefix:p}):null,k=lc({props:t,categories:a,theme:i,size:o,margin:r,hasTitle:n}),S=h?r.left+c/2:r.left,A=h?r.top+l/2:r.top,M=h&&t.centerContent?(0,Nc.jsx)("foreignObject",{x:r.left,y:r.top,width:c,height:l,pointerEvents:"none",children:(0,Nc.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:t.centerContent})}):null;return pc.renderToStaticMarkup(hc((0,Nc.jsxs)(Nc.Fragment,{children:[t.backgroundGraphics,y,x,v,w,t.foregroundGraphics,f.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-ordinal-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${S},${A})`,innerWidth:c,innerHeight:l,legend:k,defs:g,outerElements:M,idPrefix:t._idPrefix}))}var Ic=c(require("react-dom/server"));function Wc(t,e){var i=t.get(e);if(!i)throw Error("missing: "+e);return i}function Yc(t,e){var i,o=[],r=[],n=[],s={},a=[];function c(t){n[t]=!1,s.hasOwnProperty(t)&&Object.keys(s[t]).forEach(function(e){delete s[t][e],n[e]&&c(e)})}function l(t){var e,o,h=!1;for(r.push(t),n[t]=!0,e=0;a[t].length>e;e++)(o=a[t][e])===i?(u(i,r),h=!0):n[o]||(h=l(o));if(h)c(t);else for(e=0;a[t].length>e;e++){var d=s[o=a[t][e]];d||(s[o]=d={}),d[o]=!0}return r.pop(),h}function u(t,i){var r=[].concat(i).concat(t);e?e(r):o.push(r)}function h(e){!function(e){for(var i=0;t.length>i;i++)i>=e&&t[i]||(t[i]=[]),t[i]=t[i].filter(function(t){return t>=e})}(e);for(var i,o=function(t){for(var e=t.length,i=Array(e),o=Array(e),r=Array(e),n=Array(e),s=Array(e),a=Array(e),c=0;e>c;++c)i[c]=-1,o[c]=0,r[c]=!1,n[c]=0,s[c]=-1,a[c]=[];var l,u=0,h=[],d=[];function f(e){var c=[e],l=[e];for(i[e]=o[e]=u,r[e]=!0,u+=1;l.length>0;){var f=t[e=l[l.length-1]];if(f.length>n[e]){for(var p=n[e];f.length>p;++p){var y=f[p];if(0>i[y]){i[y]=o[y]=u,r[y]=!0,u+=1,c.push(y),l.push(y);break}r[y]&&(o[e]=0|Math.min(o[e],o[y])),0>s[y]||a[e].push(s[y])}n[e]=p}else{if(o[e]===i[e]){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]=h.length,b===e){c.length=p;break}}h.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];d.push(v)}l.pop()}}}for(c=0;e>c;++c)0>i[c]&&f(c);for(c=0;d.length>c;c++){var p=d[c];if(0!==p.length){p.sort(function(t,e){return t-e}),l=[p[0]];for(var y=1;p.length>y;y++)p[y]!==p[y-1]&&l.push(p[y]);d[c]=l}}return{components:h,adjacencyList:d}}(t),r=o.components.filter(function(t){return t.length>1}),n=1/0,s=0;r.length>s;s++)for(var a=0;r[s].length>a;a++)n>r[s][a]&&(n=r[s][a],i=s);var c=r[i];return!!c&&{leastVertex:n,adjList:t.map(function(t,e){return-1===c.indexOf(e)?[]:t.filter(function(t){return-1!==c.indexOf(t)})})}}i=0;for(var d=t.length;d>i;){var f=h(i);if(i=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];n[+g]=!1,s[g]={}}l(i),i+=1}else i=d}return e?void 0:o}function qc(t){return t.y0-t.y1>0?"up":"down"}function Xc(t,e){return e(t.source)==e(t.target)}function Gc(t){var e=0;t.source.sourceLinks.forEach(function(t){e=t.circular?e+1:e});var i=0;return t.target.targetLinks.forEach(function(t){i=t.circular?i+1:i}),1>=e&&1>=i}function Vc(t){return t.target.x0-t.source.x1}function Hc(t,e){var i=Uc(t),o=Vc(e)/Math.tan(i);return"up"==qc(t)?t.y1-o:t.y1+o}function Zc(t,e){var i=Uc(t),o=Vc(e)/Math.tan(i);return"up"==qc(t)?t.y1+o:t.y1-o}function Uc(t){var e=Math.abs(t.y1-t.y0);return Math.atan(Math.abs(t.target.x0-t.source.x1)/e)}function Kc(t,e){return e(t)}function Qc(t){return tl(t.source)}function Jc(t){return tl(t.target)}function tl(t){return(t.y0+t.y1)/2}function el(t){return t.virtual?0:t.value}function il(t,e){var i=0;t.sourceLinks.forEach(function(t){i=t.circular&&!Xc(t,e)?i+1:i});var o=0;return t.targetLinks.forEach(function(t){o=t.circular&&!Xc(t,e)?o+1:o}),i+o}function ol(t){return t.target.depth}function rl(t,e){return t.sourceLinks.length?t.depth:e-1}function nl(t,e){return t.y0-e.y0}function sl(t,e){return e.y0-t.y0}function al(t,e){return t.y1-e.y1}function cl(t,e){return e.y1-t.y1}function ll(t,e){return hl(t.source,e.source)||t.index-e.index}function ul(t,e){return hl(t.target,e.target)||t.index-e.index}function hl(t,e){return t.partOfCycle===e.partOfCycle?t.y0-e.y0:"top"===t.circularLinkType||"bottom"===e.circularLinkType?-1:1}function dl(t,e){return fl(t)==fl(e)?"bottom"==t.circularLinkType?sl(t,e):nl(t,e):fl(e)-fl(t)}function fl(t){return t.target.column-t.source.column}function pl(t,e){return yl(t)==yl(e)}function yl(t){return t.y0-t.y1>0?"up":"down"}var gl=require("d3-array");function ml(t,e,i,o,r){let n=t;var s=Math.max(8,.15*(n.y1-n.y0));n.links.forEach(function(t){t.circular&&(t._circularWidth=Math.min(t.width,s))});var a=(0,gl.min)(n.links,function(t){return t.source.y0});n.links.forEach(function(t){t.circular&&(t.circularPathData={})});var c=n.links.filter(function(t){return t.circular});return c.sort(function(t,e){return e.value-t.value}),c.forEach(function(t,e){t._circularStub=e>=4}),xl(n.links.filter(function(t){return"top"==t.circularLinkType}),e,i),xl(n.links.filter(function(t){return"bottom"==t.circularLinkType}),e,i),n.links.forEach(function(t){if(t.circular){if(t.circularPathData.arcRadius=t._circularWidth+o,t.circularPathData.rightNodeBuffer=5,t.circularPathData.leftNodeBuffer=5,t.circularPathData.sourceWidth=t.source.x1-t.source.x0,t.circularPathData.sourceX=t.source.x0+t.circularPathData.sourceWidth,t.circularPathData.targetX=t.target.x0,t.circularPathData.sourceY=t.y0,t.circularPathData.targetY=t.y1,Xc(t,e)&&Gc(t))t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2,t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2,"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=t.source.y1+r+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=t.source.y0-r-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius);else{var s=t.source.column,c=t.circularLinkType,l=n.links.filter(function(t){return t.source.column==s&&t.circularLinkType==c});l.sort("bottom"==t.circularLinkType?sl:nl);var u=0;l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.rightSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.rightLargeArcRadius=o+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),s=t.target.column,(l=n.links.filter(function(t){return t.target.column==s&&t.circularLinkType==c})).sort("bottom"==t.circularLinkType?cl:al),u=0,l.forEach(function(e,r){e.circularLinkID==t.circularLinkID&&(t.circularPathData.leftSmallArcRadius=o+t._circularWidth/2+u,t.circularPathData.leftLargeArcRadius=o+t._circularWidth/2+r*i+u),u+=e._circularWidth||e.width}),"bottom"==t.circularLinkType?(t.circularPathData.verticalFullExtent=Math.max(n.y1,t.source.y1,t.target.y1)+r+t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent-t.circularPathData.leftLargeArcRadius):(t.circularPathData.verticalFullExtent=a-r-t.circularPathData.verticalBuffer,t.circularPathData.verticalRightInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.rightLargeArcRadius,t.circularPathData.verticalLeftInnerExtent=t.circularPathData.verticalFullExtent+t.circularPathData.leftLargeArcRadius)}t.circularPathData.rightInnerExtent=t.circularPathData.sourceX+t.circularPathData.rightNodeBuffer,t.circularPathData.leftInnerExtent=t.circularPathData.targetX-t.circularPathData.leftNodeBuffer,t.circularPathData.rightFullExtent=t.circularPathData.sourceX+t.circularPathData.rightLargeArcRadius+t.circularPathData.rightNodeBuffer,t.circularPathData.leftFullExtent=t.circularPathData.targetX-t.circularPathData.leftLargeArcRadius-t.circularPathData.leftNodeBuffer}t.path=t.circular?function(t){return"top"==t.circularLinkType?"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 0 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY-t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 0 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 0 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY-t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 0 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY:"M"+t.circularPathData.sourceX+" "+t.circularPathData.sourceY+" L"+t.circularPathData.rightInnerExtent+" "+t.circularPathData.sourceY+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightSmallArcRadius+" 0 0 1 "+t.circularPathData.rightFullExtent+" "+(t.circularPathData.sourceY+t.circularPathData.rightSmallArcRadius)+" L"+t.circularPathData.rightFullExtent+" "+t.circularPathData.verticalRightInnerExtent+" A"+t.circularPathData.rightLargeArcRadius+" "+t.circularPathData.rightLargeArcRadius+" 0 0 1 "+t.circularPathData.rightInnerExtent+" "+t.circularPathData.verticalFullExtent+" L"+t.circularPathData.leftInnerExtent+" "+t.circularPathData.verticalFullExtent+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftLargeArcRadius+" 0 0 1 "+t.circularPathData.leftFullExtent+" "+t.circularPathData.verticalLeftInnerExtent+" L"+t.circularPathData.leftFullExtent+" "+(t.circularPathData.targetY+t.circularPathData.leftSmallArcRadius)+" A"+t.circularPathData.leftLargeArcRadius+" "+t.circularPathData.leftSmallArcRadius+" 0 0 1 "+t.circularPathData.leftInnerExtent+" "+t.circularPathData.targetY+" L"+t.circularPathData.targetX+" "+t.circularPathData.targetY}(t):function(t){var e=t.source.x1,i=t.y0,o=t.target.x0,r=t.y1,n=(e+o)/2;return"M"+e+","+i+"C"+n+","+i+" "+n+","+r+" "+o+","+r}(t)}),n}function xl(t,e,i){t.sort(dl);var o=t.filter(function(t){return!t._circularStub});return t.forEach(function(t,r){var n=0;if(t._circularStub)t.circularPathData.verticalBuffer=0;else if(Xc(t,e)&&Gc(t))t.circularPathData.verticalBuffer=n+t._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==t&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&bl(t,a)){var c=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+i;n=c>n?c:n}}t.circularPathData.verticalBuffer=n+t._circularWidth/2}}),t}function bl(t,e){return t.source.column>=e.target.column&&e.source.column>=t.target.column}var vl=require("d3-array");function wl(t){return function(){return t}}function kl(t){return t.index}function Sl(t){return t.nodes}function Al(t){return t.links}function Ml(t,e,i){var o=(0,vl.groups)(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});o.forEach(function(r,n){var s=r.length;if(e)r.sort(e);else if(n>0){var a=new Map;r.forEach(function(t,e){var i,o,r,n=(o=0,r=0,(i=t).targetLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=tl(t.source)*e,o+=e}}),i.sourceLinks.forEach(function(t){if(!t.circular){var e=t.value||1;r+=tl(t.target)*e,o+=e}}),o>0?r/o:NaN);a.set(t,{bc:n,idx:e})}),r.sort(function(t,e){var i=a.get(t),o=a.get(e),r=i.bc,n=o.bc;if(t.circularLinkType!==e.circularLinkType){if("top"==t.circularLinkType&&"bottom"==e.circularLinkType)return-1;if("bottom"==t.circularLinkType&&"top"==e.circularLinkType)return 1;if("top"==t.circularLinkType)return-1;if("top"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return-1}return isNaN(r)||isNaN(n)?isNaN(r)?isNaN(n)?i.idx-o.idx:1:-1:r-n})}else r.sort(function(t,e){return t.circularLinkType==e.circularLinkType?il(e,i)-il(t,i):"top"==t.circularLinkType&&"bottom"==e.circularLinkType||"top"==t.circularLinkType&&0==e.partOfCycle||0==t.partOfCycle&&"bottom"==e.circularLinkType?-1:0});r.forEach(function(e,r){e.depth==o.length-1&&1==s||0==e.depth&&1==s?(e.y0=t.y1/2-e.value*t.ky,e.y1=e.y0+e.value*t.ky):e.partOfCycle?0==il(e,i)?(e.y0=t.y1/2+r,e.y1=e.y0+e.value*t.ky):"top"==e.circularLinkType?(e.y0=t.y0+r,e.y1=e.y0+e.value*t.ky):(e.y0=t.y1-e.value*t.ky-r,e.y1=e.y0+e.value*t.ky):0==t.y0||0==t.y1?(e.y0=(t.y1-t.y0)/s*r,e.y1=e.y0+e.value*t.ky):(e.y0=(t.y1-t.y0)/2-s/2+r,e.y1=e.y0+e.value*t.ky)})})}function _l(t,e,i,o,r,n){var s=(0,vl.groups)(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});u();for(var a=1,c=n;c>0;--c)l(a*=.99,i),u();function l(e,i){var o=s.length;s.forEach(function(r){var n=r.length,s=r[0].depth;r.forEach(function(r){var a;if(r.sourceLinks.length||r.targetLinks.length)if(r.partOfCycle&&il(r,i)>0){var c=(0,vl.mean)(r.sourceLinks,Jc),l=(0,vl.mean)(r.targetLinks,Qc),u=c&&l?(c+l)/2:c||l;if(u){var h=(u-tl(r))*e*.3;r.y0+=h,r.y1+=h}}else if(0==s&&1==n)r.y0=t.y1/2-(a=r.y1-r.y0)/2,r.y1=t.y1/2+a/2;else if(s==o-1&&1==n)r.y0=t.y1/2-(a=r.y1-r.y0)/2,r.y1=t.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 d=(0,vl.mean)(r.sourceLinks,Jc),f=(0,vl.mean)(r.targetLinks,Qc),p=((d&&f?(d+f)/2:d||f)-tl(r))*e;r.y0+=p,r.y1+=p}})})}function u(){s.forEach(function(i){var n,s,a,c=t.y0,l=i.length;for(i.sort(e||hl),a=0;l>a;++a)(s=c-(n=i[a]).y0)>0&&(n.y0+=s,n.y1+=s),c=n.y1+o;if((s=c-o-t.y1)>0)for(c=n.y0-=s,n.y1-=s,a=l-2;a>=0;--a)(s=(n=i[a]).y1+r-c)>0&&(n.y0-=s,n.y1-=s),c=n.y0})}}function Pl(t){t.nodes.forEach(function(t){t.sourceLinks.sort(ul),t.targetLinks.sort(ll)}),t.nodes.forEach(function(t){var e=t.y0,i=e,o=t.y1,r=o;t.sourceLinks.forEach(function(t){t.circular?(t.y0=o-t.width/2,o-=t.width):(t.y0=e+t.width/2,e+=t.width)}),t.targetLinks.forEach(function(t){t.circular?(t.y1=r-t.width/2,r-=t.width):(t.y1=i+t.width/2,i+=t.width)})})}function Ll(){var t=0,e=0,i=1,o=1,r=24,n=8,s=null,a=kl,c=rl,l=void 0,u=32,h=2,d=Sl,f=Al;function p(){var p={nodes:d.apply(null,arguments),links:f.apply(null,arguments)};return function(d){d.x0=t,d.y0=e,d.x1=i,d.y1=o,d.py=0,function(t,e){t.nodes.forEach(function(t,e){t.index=e,t.sourceLinks=[],t.targetLinks=[]});var i=function(t,e){var i=new Map;return(0,vl.group)(t,e).forEach(function(t,e){i.set(e,t[0])}),i}(t.nodes,e);t.links.forEach(function(t,e){t.index=e;var o=t.source,r=t.target;"object"!=typeof o&&(o=t.source=Wc(i,o)),"object"!=typeof r&&(r=t.target=Wc(i,r)),o.sourceLinks.push(t),r.targetLinks.push(t)})}(d,a),function(t,e){var i=0;if(null==e){for(var o=[],r=0;t.links.length>r;r++){var n=t.links[r],s=n.source.index,a=n.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var c=Yc(o);c.sort(function(t,e){return t.length-e.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}t.links.forEach(function(t){var e=t.target.index,o=t.source.index;e===o||l[o]&&l[o][e]?(t.circular=!0,t.circularLinkID=i++):t.circular=!1})}else t.links.forEach(function(t){e(t.source)<e(t.target)?t.circular=!1:(t.circular=!0,t.circularLinkID=i++)})}(d,l),function(t,e){var i=0,o=0;t.links.forEach(function(r){r.circular&&(r.circularLinkType=r.source.circularLinkType||r.target.circularLinkType?r.source.circularLinkType?r.source.circularLinkType:r.target.circularLinkType:o>i?"top":"bottom","top"==r.circularLinkType?i++:o++,t.nodes.forEach(function(t){Kc(t,e)!=Kc(r.source,e)&&Kc(t,e)!=Kc(r.target,e)||(t.circularLinkType=r.circularLinkType)}))}),t.links.forEach(function(t){t.circular&&(t.source.circularLinkType==t.target.circularLinkType&&(t.circularLinkType=t.source.circularLinkType),Xc(t,e)&&(t.circularLinkType=t.source.circularLinkType))})}(d,a),function(t){t.nodes.forEach(function(t){t.partOfCycle=!1,t.value=Math.max((0,vl.sum)(t.sourceLinks,el),(0,vl.sum)(t.targetLinks,el)),t.sourceLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)}),t.targetLinks.forEach(function(e){e.circular&&(t.partOfCycle=!0,t.circularLinkType=e.circularLinkType)})})}(d),function(t,e,i){var o,r,n;if(null!=e){t.nodes.sort(function(t,i){return e(t)<e(i)?-1:1});var s=0,a=e(t.nodes[0]);t.nodes.forEach(function(t){s=e(t)==a?s:s+1,a=e(t)==a?a:e(t),t.column=s})}for(o=t.nodes,r=[],n=0;o.length;++n,o=r,r=[])o.forEach(function(t){t.depth=n,t.sourceLinks.forEach(function(t){0>r.indexOf(t.target)&&!t.circular&&r.push(t.target)})});for(o=t.nodes,r=[],n=0;o.length;++n,o=r,r=[])o.forEach(function(t){t.height=n,t.targetLinks.forEach(function(t){0>r.indexOf(t.source)&&!t.circular&&r.push(t.source)})});t.nodes.forEach(function(t){t.column=null==e?i(t,n):t.column})}(d,l,c);var f=n;if(null!==s){var p=(0,vl.groups)(d.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]}),y=(0,vl.max)(p,function(t){return t.length});y>1&&(f=Math.max(1,(o-e)*s/(y-1)))}(function(t,e,i){var o=(0,vl.groups)(t.nodes,function(t){return t.column}).sort(function(t,e){return t[0]-e[0]}).map(function(t){return t[1]});t.py=e;var r=(0,vl.min)(o,function(e){return(t.y1-t.y0-(e.length-1)*t.py)/(0,vl.sum)(e,function(t){return t.value})});t.ky=r,t.links.forEach(function(e){e.width=e.value*t.ky});var n=(0,vl.max)(t.nodes,function(t){return t.column});t.nodes.forEach(n>0?function(e){e.x0=t.x0+e.column*((t.x1-t.x0-i)/n),e.x1=e.x0+i}:function(e){e.x0=t.x0,e.x1=e.x0+i})})(d,f,r),Ml(d,l,a),_l(d,l,a,f,f,u),Pl(d),ml(d,a,h,10,8),Ml(d,l,a),_l(d,l,a,f,f,u),Pl(d),ml(d,a,h,10,8),function(t,e){let i=t;i.nodes.forEach(function(t){t.y+(t.y1-t.y0)>i.y1&&(t.y=t.y-(t.y+(t.y1-t.y0)-i.y1));var o=i.links.filter(function(i){return Kc(i.source,e)==Kc(t,e)}),r=o.length;r>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.target.column==e.target.column)return t.y1-e.y1;if(!pl(t,e))return t.y1-e.y1;if(t.target.column>e.target.column){var i=Hc(e,t);return t.y1-i}if(e.target.column>t.target.column)return Hc(t,e)-e.y1}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.target.column===e.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.target.column===e.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:"top"==t.circularLinkType?-1:1:void 0});var n=t.y0;o.forEach(function(t){t.y0=n+t.width/2,n+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,s=0;r>n;n++)s+=o[n].width;e.y0=t.y1-s-e.width/2}})})}(d,a),function(t,e){let i=t;i.nodes.forEach(function(t){var o=i.links.filter(function(i){return Kc(i.target,e)==Kc(t,e)}),r=o.length;r>1&&o.sort(function(t,e){if(!t.circular&&!e.circular){if(t.source.column==e.source.column)return t.y0-e.y0;if(!pl(t,e))return t.y0-e.y0;if(t.source.column>e.source.column){var i=Zc(e,t);return t.y0-i}if(e.source.column>t.source.column)return Zc(t,e)-e.y0}return t.circular&&!e.circular?"top"==t.circularLinkType?-1:1:e.circular&&!t.circular?"top"==e.circularLinkType?1:-1:t.circular&&e.circular?t.circularLinkType===e.circularLinkType&&"top"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:t.source.column-e.source.column:t.circularLinkType===e.circularLinkType&&"bottom"==t.circularLinkType?t.source.column===e.source.column?t.source.y1-e.source.y1:e.source.column-t.source.column:"top"==t.circularLinkType?-1:1:void 0});var n=t.y0;o.forEach(function(t){t.y1=n+t.width/2,n+=t.width}),o.forEach(function(e,i){if("bottom"==e.circularLinkType){for(var n=i+1,s=0;r>n;n++)s+=o[n].width;e.y1=t.y1-s-e.width/2}})})}(d,a),function(t){var e=t.nodes,i=t.links,o=!1,r=!1;if(i.forEach(function(t){"top"==t.circularLinkType?o=!0:"bottom"==t.circularLinkType&&(r=!0)}),0==o||0==r){let o=function(e){return(e-n)/(s-n)*(t.y1-t.y0)+t.y0};var n=(0,vl.min)(e,function(t){return t.y0}),s=(0,vl.max)(e,function(t){return t.y1}),a=(t.y1-t.y0)/(s-n);1>a?(e.forEach(function(t){t.y0=o(t.y0),t.y1=o(t.y1)}),i.forEach(function(t){t.y0=o(t.y0),t.y1=o(t.y1),t.width=t.width*a})):e.forEach(function(t){var e=t.y1-t.y0,i=o(t.y0)-t.y0;t.y0=o(t.y0),t.y1=t.y0+e,t.sourceLinks.forEach(function(t){t.y0=t.y0+i}),t.targetLinks.forEach(function(t){t.y1=t.y1+i})})}}(d),ml(d,a,h,10,8)}(p),p}return p.update=function(t){return Pl(t),ml(t,a,h,10,8),t},p.nodeWidth=function(t){return arguments.length?(r=+t,p):r},p.nodePadding=function(t){return arguments.length?(n=+t,p):n},p.nodePaddingRatio=function(t){return arguments.length?(s=+t,p):s},p.nodes=function(t){return arguments.length?(d="function"==typeof t?t:wl(t),p):d},p.links=function(t){return arguments.length?(f="function"==typeof t?t:wl(t),p):f},p.nodeId=function(t){return arguments.length?(a="function"==typeof t?t:wl(t),p):a},p.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:wl(t),p):c},p.nodeSort=function(t){return arguments.length?(l=t,p):l},p.iterations=function(t){return arguments.length?(u=+t,p):u},p.circularLinkGap=function(t){return arguments.length?(h=+t,p):h},p.extent=function(r){return arguments.length?(t=+r[0][0],e=+r[0][1],i=+r[1][0],o=+r[1][1],p):[[t,e],[i,o]]},p.size=function(r){return arguments.length?(t=e=0,i=+r[0],o=+r[1],p):[i-t,o-e]},p}var Rl=require("d3-interpolate"),Tl=(require("d3-shape"),.5),Cl=t=>{let e,i,o,r,n,s,a,c,l;if("down"===t.direction)return e=t.y0-t.sankeyWidth/2,i=t.y1-t.sankeyWidth/2,o=t.y1+t.sankeyWidth/2,r=t.y0+t.sankeyWidth/2,n=t.source.x1,s=t.target.x0,a=(0,Rl.interpolateNumber)(n,s),c=a(Tl),l=a(.5),`M${e},${n}C${e},${c} ${i},${l} ${i},${s}L${o},${s}C${o},${l} ${r},${c} ${r},${n}Z`;const u=t.sankeyWidth/2,h=(0,Rl.interpolateNumber)(t.source.x1,t.target.x0),{pathD:d}=Xe({sx:t.source.x1,sTop:t.y0-u,sBot:t.y0+u,tx:t.target.x0,tTop:t.y1-u,tBot:t.y1+u,cp1X:h(Tl),cp2X:h(.5)});return d};function $l(t){const e=t.sankeyWidth/2,i=(t._circularWidth??t.sankeyWidth)/2,o=t.circularPathData;if(!o)return null;if("down"===t.direction)return null;if(t._circularStub){const i=o.sourceX,r=o.sourceY,n=o.targetX,s=o.targetY;if("object"!=typeof t.source||!t.source||"object"!=typeof t.target||!t.target)return null;const a=Math.max(15,Math.min(40,.33*(o.rightFullExtent-i))),c=Math.max(15,Math.min(40,.33*(n-o.leftFullExtent)));return`M${i},${r-e}L${i+a},${r-e}L${i+a},${r+e}L${i},${r+e}ZM${n},${s-e}L${n-c},${s-e}L${n-c},${s+e}L${n},${s+e}Z`}const r=o.sourceX,n=o.sourceY,s=o.targetX,a=o.targetY,c=o.rightFullExtent,l=o.leftFullExtent,u=o.verticalFullExtent,h="bottom"===t.circularLinkType?1:-1,d=Math.max(4,Math.min(i,15));return`M${r},${n-h*e}L${c},${n-h*e}L${c+i},${n-h*e+h*d}L${c+i},${u+h*i-h*d}L${c+i-d},${u+h*i}L${l-i+d},${u+h*i}L${l-i},${u+h*i-h*d}L${l-i},${a-h*e+h*d}L${l-i+d},${a-h*e}L${s},${a-h*e}L${s},${a+h*e}L${l+i},${a+h*e}L${l+i},${u-h*i}L${c-i},${u-h*i}L${c-i},${n+h*e}L${r},${n+h*e}Z`}var jl=new Set,zl=new WeakMap;function El(t,e){if("production"===process.env.NODE_ENV)return t;if(!t||!t.data||"object"!=typeof t.data)return t;let i=zl.get(t);if(i){const t=i.get(e);if(t)return t}else i=new Map,zl.set(t,i);const o=new Proxy(t,{get(t,i,o){if("string"==typeof i&&!(i in t)&&t.data&&i in t.data){const t=`${e}:${i}`;jl.has(t)||(jl.add(t),console.warn(`[Semiotic] "${e}" callback accessed "${i}" on the wrapper object, but it only exists on ".data". Use d.data.${i} (or d.data?.${i}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(t,i,o)}});return i.set(e,o),o}var Dl={left:function(t){return t.depth},right:function(t,e){return e-1-t.height},center:function(t){return t.targetLinks.length?t.depth:t.sourceLinks.length?Math.min.apply(Math,t.sourceLinks.map(ol))-1:0},justify:rl};function Fl(t){return"string"==typeof t?t:t.id}var Ol={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){if(0===t.length)return;const r="vertical"===i.orientation?"down":"right",n=i.nodeAlign||"justify",s=i.nodeWidth??15,a=i.nodePaddingRatio??.05,c=i.iterations??100,l=t.map(t=>({...t})),u=e.map(t=>({...t,source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id,value:Math.sqrt(Math.max(1,t.value||1))}));let h;h="down"===r?[[0,0],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const d=Ll().extent(h).links(u).nodes(l).nodeAlign(Dl[n]||rl).nodeId(t=>t.id).nodeWidth(s).iterations(c);d.nodePaddingRatio&&d.nodePaddingRatio(a),d();{let t=1/0,e=-1/0,i=1/0,r=-1/0;for(const o of l)t>o.x0&&(t=o.x0),o.x1>e&&(e=o.x1),i>o.y0&&(i=o.y0),o.y1>r&&(r=o.y1);for(const o of u){if(!o.circular||!o.circularPathData)continue;const n=o.circularPathData,s=(o._circularWidth??o.width??0)/2;t>n.leftFullExtent-s&&(t=n.leftFullExtent-s),n.rightFullExtent+s>e&&(e=n.rightFullExtent+s),i>n.verticalFullExtent-s&&(i=n.verticalFullExtent-s),n.verticalFullExtent+s>r&&(r=n.verticalFullExtent+s)}const n=e-t,s=r-i,a=o[0],c=o[1];if(n>0&&s>0&&(0>t||0>i||e>a||r>c)){const e=Math.min(a/n,c/s),o=-t*e+(a-n*e)/2,r=-i*e+(c-s*e)/2;for(const t of l)t.x0=t.x0*e+o,t.x1=t.x1*e+o,t.y0=t.y0*e+r,t.y1=t.y1*e+r;for(const t of u)if(t.y0=t.y0*e+r,t.y1=t.y1*e+r,t.width=(t.width??0)*e,t._circularWidth&&(t._circularWidth*=e),t.circular&&t.circularPathData){const i=t.circularPathData;i.sourceX=i.sourceX*e+o,i.targetX=i.targetX*e+o,i.sourceY=i.sourceY*e+r,i.targetY=i.targetY*e+r,i.rightFullExtent=i.rightFullExtent*e+o,i.leftFullExtent=i.leftFullExtent*e+o,i.verticalFullExtent=i.verticalFullExtent*e+r,i.rightInnerExtent=i.rightInnerExtent*e+o,i.leftInnerExtent=i.leftInnerExtent*e+o,i.verticalRightInnerExtent=i.verticalRightInnerExtent*e+r,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*e+r,i.rightSmallArcRadius*=e,i.rightLargeArcRadius*=e,i.leftSmallArcRadius*=e,i.leftLargeArcRadius*=e,i.sourceWidth*=e,i.rightNodeBuffer*=e,i.leftNodeBuffer*=e,i.arcRadius*=e}}}const f=new Map;for(const e of t)f.set(e.id,e);for(const t of l){const e=f.get(t.id);e&&(e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.value=t.value,e.depth=t.depth,e.sourceLinks=t.sourceLinks,e.targetLinks=t.targetLinks,e.width=t.x1-t.x0,e.height=t.y1-t.y0,e.x=t.x0+(t.x1-t.x0)/2,e.y=t.y0+(t.y1-t.y0)/2)}const p=new Map;for(const t of e)p.set(t._edgeKey?t._edgeKey:`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const t of u){const e=Fl(t.source),i=Fl(t.target),o=p.get(t._edgeKey?t._edgeKey:`${e}\0${i}`);if(o){o.y0=t.y0,o.y1=t.y1,o.sankeyWidth=t.width??0,o.circular=!!t.circular,o.circularPathData=t.circularPathData,o._circularWidth=t._circularWidth,o._circularStub=t._circularStub,o.path=t.path,o.circularLinkType=t.circularLinkType,o.direction=r;const n=f.get(e),s=f.get(i);n&&(o.source=n),s&&(o.target=s)}}},buildScene(t,e,i,o){const r="vertical"===i.orientation?"down":"right",n=i.nodeStyle,s=i.edgeStyle,a=i.edgeOpacity??.5,c=i.edgeColorBy||"source",l=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:A,u=new Map;t.forEach((t,e)=>{u.set(t.id,l[e%l.length])});const h=[],d=[],f=[],p=new Map;for(const e of t){const t=e.x1-e.x0,i=e.y1-e.y0;if(0>=t||0>=i)continue;const o=n?n(El(e,"nodeStyle")):{},s={fill:o.fill||u.get(e.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity};p.set(e.id,("string"==typeof s.fill?s.fill:null)||u.get(e.id)||"#4d430c"),h.push("down"===r?{type:"rect",x:e.y0,y:e.x0,w:i,h:t,style:s,datum:e,id:e.id,label:e.id}:{type:"rect",x:e.x0,y:e.y0,w:t,h:i,style:s,datum:e,id:e.id,label:e.id})}const y=[...e].sort((t,e)=>(e.sankeyWidth||0)-(t.sankeyWidth||0));for(const t of y){if(!t.sankeyWidth||0>=t.sankeyWidth)continue;const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let r=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999";r="function"==typeof c?c(t)||r:"target"===c?p.get(o.id)||u.get(o.id)||r:p.get(e.id)||u.get(e.id)||r;const n=s?s(El(t,"edgeStyle")):{};if(t._circularStub&&t.circular&&t.circularPathData){const e=t.circularPathData,i=t.sankeyWidth/2,o=Math.max(15,Math.min(40,.33*(e.rightFullExtent-e.sourceX))),s=Math.max(15,Math.min(40,.33*(e.targetX-e.leftFullExtent))),c=n.fill||r;d.push({type:"bezier",pathD:`M${e.sourceX},${e.sourceY-i}L${e.sourceX+o},${e.sourceY-i}L${e.sourceX+o},${e.sourceY+i}L${e.sourceX},${e.sourceY+i}Z`,style:{fill:c,fillOpacity:n.fillOpacity??a,stroke:"none",opacity:n.opacity},datum:t,_gradient:{direction:"right",from:1,to:0,x0:e.sourceX,x1:e.sourceX+o}}),d.push({type:"bezier",pathD:`M${e.targetX},${e.targetY-i}L${e.targetX-s},${e.targetY-i}L${e.targetX-s},${e.targetY+i}L${e.targetX},${e.targetY+i}Z`,style:{fill:c,fillOpacity:n.fillOpacity??a,stroke:"none",opacity:n.opacity},datum:t,_gradient:{direction:"left",from:0,to:1,x0:e.targetX-s,x1:e.targetX}});continue}let l;(l=t.circular&&t.circularPathData?$l(t):Cl(t),l)&&d.push({type:"bezier",pathD:l,bezierCache:t.bezier,style:{fill:n.fill||r,fillOpacity:n.fillOpacity??a,stroke:n.stroke||"none",strokeWidth:n.strokeWidth,opacity:n.opacity},datum:t})}if(!1!==i.showLabels){const e=(g=i.nodeLabel)?"function"==typeof g?g:t=>t[g]||t.id:null;for(const i of t){const t=i.x1-i.x0,n=i.y1-i.y0;if(0>=t||0>=n)continue;const s=e?e(i):i.id;if(!s)continue;let a,c,l;"down"===r?(a=i.y0+(i.y1-i.y0)/2,c=i.x1+14,l="start"):(o[0]/2>i.x0+t/2?(a=i.x0-6,l="end"):(a=i.x1+6,l="start"),c=i.y0+n/2),f.push({x:a,y:c,text:s+"",anchor:"down"===r?"middle":l,baseline:"middle",fontSize:11})}}var g;return{sceneNodes:h,sceneEdges:d,labels:f}}},Nl=require("d3-force"),Bl=require("d3-scale"),Il={supportsStreaming:!0,hierarchical:!1,computeLayout(t,e,i,o){if(0===t.length)return;const r=i.forceStrength??.1,n=o[0]/2,s=o[1]/2,a=i.__previousPositions;let c=0;const l=[];for(const e of t){const t=null!=e.x&&null!=e.y&&(0!==e.x||0!==e.y),i=a?.get(e.id);t?c++:i?(e.x=i.x,e.y=i.y,c++):l.push(e)}const u=c>0&&.3>=(t.length>0?l.length/t.length:1);if(u){const i=new Map;for(const e of t)i.set(e.id,e);for(const t of l){const o=Wl(t.id,e,i);if(o.length>0){let e=0,i=0;for(const t of o)e+=t.x,i+=t.y;const r=Yl(t.id),n=r%360*(Math.PI/180),s=10+r%20;t.x=e/o.length+s*Math.cos(n),t.y=i/o.length+s*Math.sin(n)}else{const e=Yl(t.id),i=e%360*(Math.PI/180),o=15+e%30;t.x=n+o*Math.cos(i),t.y=s+o*Math.sin(i)}}}else{const e=2.399963229728653;for(let i=0;t.length>i;i++){const o=t[i];if(null==o.x||null==o.y||0===o.x&&0===o.y){const t=10*Math.sqrt(i+.5),r=i*e;o.x=n+t*Math.cos(r),o.y=s+t*Math.sin(r)}}}const h=i.__skipForceSimulation||0===i.iterations?0:u?40:i.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(t.length-30)))),d=ql(i.nodeSize,i.nodeSizeRange,t),f=t=>d(t);if(h>0){const o=new Map,a=new Map;for(const e of t)o.set(e.id,0),a.set(e.id,e);for(const t of e){const e="string"==typeof t.source?t.source:t.source.id,i="string"==typeof t.target?t.target:t.target.id;o.set(e,(o.get(e)??0)+1),o.set(i,(o.get(i)??0)+1)}const c=(0,Nl.forceLink)().strength(t=>{const e=t.weight,i="string"==typeof t.target?t.target:t.target.id,n=Math.max(1,Math.min(o.get("string"==typeof t.source?t.source:t.source.id)??1,o.get(i)??1));return Math.min(2.5,(e&&e>0?Math.sqrt(e):1)*r/(.1*n))}).distance(t=>{const e="string"==typeof t.source?a.get(t.source):t.source,i="string"==typeof t.target?a.get(t.target):t.target,o=(e?f(e):0)+(i?f(i):0)+12;return Math.max(40,o)}).id(t=>t.id),l=(0,Nl.forceSimulation)();if(void 0===i.random&&void 0===i.seed||l.randomSource(i.random??function(t){let e=t>>>0;return()=>{e+=1831565813;let t=e;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296}}(i.seed)),l.force("charge",(0,Nl.forceManyBody)().strength(t=>{const e=o.get(t.id)??0;return-15*f(t)*Math.sqrt(e+1)})).force("collide",(0,Nl.forceCollide)(t=>f(t)+3).strength(.9).iterations(2)).force("center",(0,Nl.forceCenter)(n,s).strength(.8)).force("x",(0,Nl.forceX)(n).strength(.06)).force("y",(0,Nl.forceY)(s).strength(.06)),l.nodes(t),e.length>0){const t=e.map(t=>({...t,source:"string"==typeof t.source?t.source:t.source.id,target:"string"==typeof t.target?t.target:t.target.id}));c.links(t),l.force("link",c)}u?l.alpha(.3):.1>l.alpha()&&l.alpha(1),l.stop();for(let t=0;h>t;++t)l.tick()}for(const e of t){if(null==e.x||null==e.y)continue;const t=f(e);e.x=Math.max(t,Math.min(o[0]-t,e.x)),e.y=Math.max(t,Math.min(o[1]-t,e.y)),e.x0=0,e.x1=0,e.y0=0,e.y1=0}const p=new Map;for(const e of t)p.set(e.id,e);for(const t of e){if("string"==typeof t.source){const e=p.get(t.source);e&&(t.source=e)}if("string"==typeof t.target){const e=p.get(t.target);e&&(t.target=e)}}},buildScene(t,e,i,o){const r=i.nodeStyle,n=i.edgeStyle,s=ql(i.nodeSize,i.nodeSizeRange,t),a=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:A,c=new Map;t.forEach((t,e)=>{c.set(t.id,a[e%a.length])});const l=[],u=[],h=[];for(const e of t){if(null==e.x||null==e.y)continue;const t=s(El(e,"nodeSize")),o=r?r(El(e,"nodeStyle")):{},n={fill:o.fill||c.get(e.id)||i.themeSemantic?.primary||"#007bff",stroke:o.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??2,opacity:o.opacity};l.push({type:"circle",cx:e.x,cy:e.y,r:t,style:n,datum:e,id:e.id,label:e.id})}const d=new Map;for(const e of t)d.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:d.get(t.source),o="object"==typeof t.target?t.target:d.get(t.target);if(!e||!o)continue;if(null==e.x||null==e.y)continue;if(null==o.x||null==o.y)continue;const r=n?n(El(t,"edgeStyle")):{};u.push({type:"line",x1:e.x,y1:e.y,x2:o.x,y2:o.y,style:{stroke:r.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:r.strokeWidth??1,opacity:r.opacity??.6},datum:t})}if(!1!==i.showLabels){const e=(f=i.nodeLabel)?"function"==typeof f?f:t=>t[f]||t.id:null;for(const i of t){if(null==i.x||null==i.y)continue;const t=e?e(i):i.id;if(!t)continue;const o=s(El(i,"nodeSize"));h.push({x:i.x,y:i.y-o-4,text:t+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:l,sceneEdges:u,labels:h}}};function Wl(t,e,i){const o=[];for(const r of e){const e="string"==typeof r.source?r.source:r.source.id,n="string"==typeof r.target?r.target:r.target.id;let s=null;if(e===t?s=n:n===t&&(s=e),s){const t=i.get(s);!t||0===t.x&&0===t.y||o.push({x:t.x,y:t.y})}}return o}function Yl(t){let e=0;for(let i=0;t.length>i;i++)e=(e<<5)-e+t.charCodeAt(i)|0;return Math.abs(e)}function ql(t,e,i){if(i.some(t=>null!=t.__forceRadius))return t=>t.__forceRadius??8;if(null==t)return()=>8;if("number"==typeof t)return()=>t;if("function"==typeof t)return e=>t(e)||8;const o=e||[5,20],r=[];for(const e of i){const i=e.data?.[t];"number"==typeof i&&r.push(i)}if(0===r.length)return()=>o[0];const[n,s]=it(r);if(n===s)return()=>(o[0]+o[1])/2;const a=(0,Bl.scaleLinear)().domain([n,s]).range(o).clamp(!0);return e=>{const i=e.data?.[t];return null==i||"number"!=typeof i?o[0]:a(i)}}var Xl=require("d3-chord"),Gl=require("d3-shape"),Vl=A,Hl={supportsStreaming:!1,hierarchical:!1,computeLayout(t,e,i,o){if(0===t.length)return;const{padAngle:r=.01,groupWidth:n=20,sortGroups:s}=i,a=Math.min(o[0],o[1])/2,c=a-n,l=o[0]/2,u=o[1]/2,h=(d=i.valueAccessor)?"function"==typeof d?d:t=>t[d]??1:t=>t.value??1;var d;const f=new Map;for(let e=0;t.length>e;e++)f.set(t[e].id,e);const p=t.length,y=Array.from({length:p},()=>Array.from({length:p},()=>0));for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=f.get("string"==typeof t.source?t.source:t.source.id),o=f.get(e);if(void 0===i||void 0===o)continue;const r=h(t);y[i][o]=r}const g=(0,Xl.chord)().padAngle(r);s&&g.sortGroups(s);const m=g(y),x=m.groups,b=(0,Gl.arc)().innerRadius(c).outerRadius(a);for(const e of x){const i=t[e.index],o=b.centroid({innerRadius:c,outerRadius:a,startAngle:e.startAngle,endAngle:e.endAngle});i.x=o[0]+l,i.y=o[1]+u,i.__arcData={startAngle:e.startAngle,endAngle:e.endAngle}}const v=new Map;for(const e of t)v.set(e.id,e);for(const t of e){const e="string"==typeof t.target?t.target:t.target.id,i=v.get("string"==typeof t.source?t.source:t.source.id),o=v.get(e);i&&(t.source=i),o&&(t.target=o)}const w=new Map;for(const t of e)w.set(`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}`,t);for(const e of m){const i=t[e.source.index].id,o=t[e.target.index].id,r=w.get(`${i}\0${o}`)||w.get(`${o}\0${i}`);r&&(r.__chordData=e)}},buildScene(t,e,i,o){const{groupWidth:r=20,edgeOpacity:n=.5}=i,s=Math.min(o[0],o[1])/2,a=s-r,c=o[0]/2,l=o[1]/2,u=i.nodeStyle,h=i.edgeStyle,d=i.edgeColorBy||"source",f=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:Vl,p=new Map;t.forEach((t,e)=>{p.set(t.id,f[e%f.length])});const y=(0,Xl.ribbon)().radius(a),g=[],m=[],x=[];for(let e=0;t.length>e;e++){const i=t[e],o=i.__arcData;if(!o)continue;let r;r=u?u(El(i,"nodeStyle")).fill||p.get(i.id)||f[e%f.length]:p.get(i.id)||f[e%f.length];const n=u?u(El(i,"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:n.stroke||"black",strokeWidth:n.strokeWidth??1,opacity:n.opacity},datum:i,id:i.id,label:i.id})}for(const t of e){const e=t.__chordData;if(!e)continue;const o=y(e);if(!o)continue;const r=Zl(o,c,l);let s=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999";if(h)s=h(El(t,"edgeStyle")).fill||s;else{const e="object"==typeof t.source?t.source:null,i="object"==typeof t.target?t.target:null;"target"===d&&i?s=p.get(i.id)||s:e&&(s=p.get(e.id)||s)}const a=h?h(El(t,"edgeStyle")):{};m.push({type:"ribbon",pathD:r,style:{fill:s,fillOpacity:a.fillOpacity??n,stroke:a.stroke||"none",strokeWidth:a.strokeWidth,opacity:a.opacity},datum:t})}if(!1!==i.showLabels){const e=(b=i.nodeLabel)?"function"==typeof b?b:t=>t[b]||t.id:null,o=s+12;for(const i of t){const t=i.__arcData;if(!t)continue;const r=e?e(i):i.id;if(!r)continue;const n=(t.startAngle+t.endAngle)/2,s=n-Math.PI/2;x.push({x:c+Math.cos(s)*o,y:l+Math.sin(s)*o,text:r+"",anchor:n>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var b;return{sceneNodes:g,sceneEdges:m,labels:x}}};function Zl(t,e,i){const o=t.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return t;const r=[];let n=0;for(;o.length>n;){const t=o[n];if("M"===t||"L"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("C"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)for(let t=0;3>t&&o.length>n&&!isNaN(Number(o[n]));t++)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("Q"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)for(let t=0;2>t&&o.length>n&&!isNaN(Number(o[n]));t++)r.push(Number(o[n])+e+""),n++,o.length>n&&!isNaN(Number(o[n]))&&(r.push(Number(o[n])+i+""),n++);else if("A"===t)for(r.push(t),n++;o.length>n&&!isNaN(Number(o[n]));)r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&r.push(o[n++]),o.length>n&&(r.push(Number(o[n])+e+""),n++),o.length>n&&(r.push(Number(o[n])+i+""),n++);else"Z"===t||"z"===t?(r.push(t),n++):(r.push(o[n]),n++)}return r.join(" ")}var Ul=require("d3-hierarchy"),Kl=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Ql(t){const[e,i,o]=function(t){if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6===e.length)return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const e=t.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return e?[+e[1],+e[2],+e[3]]:[128,128,128]}(t);return.299*e+.587*i+.114*o>150?"#222":"#fff"}function Jl(t,e,i){const o=e.nodeIDAccessor;return"function"==typeof o?o(t.data)+"":"string"==typeof o&&void 0!==t.data[o]?t.data[o]+"":void 0!==t.data.name?t.data.name+"":void 0!==t.data.id?t.data.id+"":"node-"+i}function tu(t){if(!t)return null;if("function"==typeof t){const e=t;return t=>e(t.data??t)}return e=>e.data?.[t]||e[t]||e.id}function eu(t){return Array.isArray(t.colorScheme)?t.colorScheme:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical:Kl}function iu(t){return Array.isArray(t.colorScheme)&&t.colorScheme.length>0?t.colorScheme[0]:t.themeSemantic?.primary?t.themeSemantic.primary:t.themeCategorical&&t.themeCategorical.length>0?t.themeCategorical[0]:"#4d430c"}function ou(t,e,i,o,r){if("horizontal"===r){const r=(t+i)/2;return`M ${t},${e} C ${r},${e} ${r},${o} ${i},${o}`}if("radial"===r){const r=(t+i)/2;return`M ${t},${e} Q ${r},${e} ${r},${(e+o)/2} T ${i},${o}`}{const r=(e+o)/2;return`M ${t},${e} C ${t},${r} ${i},${r} ${i},${o}`}}var ru={supportsStreaming:!1,hierarchical:!0,computeLayout(t,e,i,o){const r=i.__hierarchyRoot;if(!r)return;const n=i.chartType,s=function(t){if(t)return"function"==typeof t?t:e=>e[t]}(i.childrenAccessor),a=i.hierarchySum,c="function"==typeof a?a:"string"==typeof a?t=>Number(t[a])||0:t=>Number(t.value)||0,l=(0,Ul.hierarchy)(r,s);l.sum(c),l.sort((t,e)=>(e.value??0)-(t.value??0));const[u,h]=o;switch(n){case"tree":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=(0,Ul.tree)();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(l,i,u,h);break;case"cluster":!function(t,e,i,o){const r=e.treeOrientation||"vertical",n=(0,Ul.cluster)();n.size("horizontal"===r?[o,i]:"radial"===r?[2*Math.PI,Math.min(i,o)/2*.8]:[i,o]),n(t)}(l,i,u,h);break;case"treemap":!function(t,e,i,o){const r=e.padding??4,n=e.paddingTop??0,s=(0,Ul.treemap)().size([i,o]).tile(Ul.treemapBinary).padding(r);n>0&&s.paddingTop(n),s(t)}(l,i,u,h);break;case"circlepack":!function(t,e,i,o){const r=e.padding??4;(0,Ul.pack)().size([i,o]).padding(r)(t)}(l,i,u,h);break;case"partition":!function(t,e,i,o){(0,Ul.partition)().size([i,o]).padding(e.padding??1)(t)}(l,i,u,h)}const d=l.descendants();t.length=0,e.length=0;const f=new Map;for(let e=0;d.length>e;e++){const o=d[e],r={id:Jl(o,i,e),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"===n||"cluster"===n?nu(r,o,i):"treemap"===n||"partition"===n?su(r,o):"circlepack"===n&&au(r,o),r.__hierarchyNode=o,t.push(r),f.set(o,r)}if("tree"===n||"cluster"===n)for(const t of d)if(t.parent){const i=f.get(t.parent),o=f.get(t);i&&o&&e.push({source:i,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:t.depth}})}},buildScene(t,e,i,o){const r=i.nodeStyle||(()=>({})),n=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(t,e,i,o,r,n){const s=[],a=[],c=[],l=i.treeOrientation||"vertical",u="radial"===l,h=o[0]/2,d=o[1]/2,f="number"==typeof(p=i.nodeSize)?p:5;var p;for(const e of t){let t=e.x,o=e.y;u&&(t+=h,o+=d);const n=r(El(e,"nodeStyle"));let a=n.fill||iu(i);if(i.colorByDepth&&void 0!==e.depth){const t=eu(i);a=t[e.depth%t.length]}s.push({type:"circle",cx:t,cy:o,r:f,style:{fill:a,stroke:n.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??1,opacity:n.opacity},datum:e,id:e.id,label:e.id,depth:e.depth})}const y=i.edgeOpacity??.5;for(const t of e){const e="object"==typeof t.source?t.source:null,o="object"==typeof t.target?t.target:null;if(!e||!o)continue;let r=e.x,s=e.y,c=o.x,f=o.y;u&&(r+=h,s+=d,c+=h,f+=d);const p=ou(r,s,c,f,l),g=n(El(t,"edgeStyle"));a.push({type:"curved",pathD:p,style:{fill:"none",stroke:g.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??y},datum:t})}if(!1!==i.showLabels){const e=tu(i.nodeLabel);for(const i of t){const t=e?e(i):i.id;if(!t)continue;let o,r,n,s=i.x,a=i.y;if(u&&(s+=h,a+=d),u){const t=s-h,e=a-d,i=Math.sqrt(t*t+e*e);i>0?(o=s+t/i*10,r=a+e/i*10,n=0>t?"end":"start"):(o=s,r=a-12,n="middle")}else"horizontal"===l?(i.data?.children&&0!==i.data.children.length?(o=s-f-6,n="end"):(o=s+f+6,n="start"),r=a):(o=s,r=a+f+14,n="middle");c.push({x:o,y:r,text:t+"",anchor:n,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:c}}(t,e,i,o,r,n);case"treemap":case"partition":return function(t,e,i,o){const r=[],n=[];for(const i of t){const t=i.x1-i.x0,n=i.y1-i.y0;if(0>=t||0>=n)continue;const s=o(El(i,"nodeStyle"));let a=s.fill||iu(e);if(e.colorByDepth&&void 0!==i.depth){const t=eu(e);a=t[i.depth%t.length]}r.push({type:"rect",x:i.x0,y:i.y0,w:t,h:n,style:{fill:a,stroke:s.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:s.strokeWidth??1,opacity:s.opacity},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=tu(e.nodeLabel),r=e.labelMode||"leaf",s="partition"===e.chartType;for(const a of t){const t=a.x1-a.x0,c=a.y1-a.y0;if(0>=t||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=i?i(a):a.id;if(!u)continue;if((l?30:40)>t||(l?16:14)>c)continue;let h=o(El(a,"nodeStyle")).fill||iu(e);if(e.colorByDepth&&void 0!==a.depth){const t=eu(e);h=t[a.depth%t.length]}const d="string"==typeof h?Ql(h):e.themeSemantic?.text??"#000";n.push(l?{x:a.x0+t/2,y:a.y0+c/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(t,c)/6)),fill:d}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:r,sceneEdges:[],labels:n}}(t,i,0,r);case"circlepack":return function(t,e,i,o){const r=[],n=[];for(const i of t){const t=i.__radius??5;if(0>=t)continue;const n=o(El(i,"nodeStyle"));let s=n.fill||iu(e);if(e.colorByDepth&&void 0!==i.depth){const t=eu(e);s=t[i.depth%t.length]}r.push({type:"circle",cx:i.x,cy:i.y,r:t,style:{fill:s,stroke:n.stroke||e.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??1,opacity:n.opacity??.7},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==e.showLabels){const i=tu(e.nodeLabel);for(const r of t){const t=r.__radius??5,s=i?i(r):r.id;if(!s)continue;if(15>t)continue;const a=!(r.data?.children&&r.data.children.length>0);let c=o(El(r,"nodeStyle")).fill||iu(e);if(e.colorByDepth&&void 0!==r.depth){const t=eu(e);c=t[r.depth%t.length]}if(a){const i="string"==typeof c?Ql(c):e.themeSemantic?.text??"#000";n.push({x:r.x,y:r.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,t/3)),fill:i})}else n.push({x:r.x,y:r.y-t+14,text:s+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,t/3)),fill:e.themeSemantic?.text||"#000",stroke:e.themeSemantic?.surface||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:r,sceneEdges:[],labels:n}}(t,i,0,r);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function nu(t,e,i){const o=i.treeOrientation||"vertical";if("radial"===o){const i=e.x,o=e.y;t.x=o*Math.cos(i-Math.PI/2),t.y=o*Math.sin(i-Math.PI/2)}else"horizontal"===o?(t.x=e.y,t.y=e.x):(t.x=e.x,t.y=e.y);t.x0=t.x-5,t.x1=t.x+5,t.y0=t.y-5,t.y1=t.y+5,t.width=10,t.height=10}function su(t,e){t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.x=(e.x0+e.x1)/2,t.y=(e.y0+e.y1)/2,t.width=e.x1-e.x0,t.height=e.y1-e.y0}function au(t,e){const i=e.r??0;t.x=e.x,t.y=e.y,t.x0=e.x-i,t.x1=e.x+i,t.y0=e.y-i,t.y1=e.y+i,t.width=2*i,t.height=2*i,t.__radius=i}var cu=require("d3-shape");function lu(t){let e=t.__orbitState;return e||(e={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},t.__orbitState=e),e}var uu={sankey:Ol,force:Il,chord:Hl,tree:ru,cluster:ru,treemap:ru,circlepack:ru,partition:ru,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(t,e,i,o){const r=i.__hierarchyRoot;r&&function(t,e,i,o,r){const n=function(t){if("function"==typeof t)return t;const e=t||"children";return t=>t[e]||null}(i.childrenAccessor),s=function(t){if("function"==typeof t)return t;const e=t||"name";return t=>(t[e]??"")+""}(i.nodeIDAccessor),a=function(t){if(Array.isArray(t))return t;switch(t){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(i.orbitMode),c=i.orbitSize??2.95,l=i.orbitEccentricity??1,u="number"==typeof c?()=>c:c,h="number"==typeof l?()=>l:l,d=lu(i);d.metaMap.clear(),o.length=0,r.length=0;const f=new Map;function p(t){const e=f.get(t)??0;return f.set(t,e+1),0===e?t:`${t}__${e}`}const y=e[0]/2,g=e[1]/2,m=Math.min(e[0],e[1])/2*.85,x=p(s(t));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:t}),d.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function t(e,i,c,l,f,y,g){const m=n(e);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:i,depth:y,data:e,parentId:i},M=g?f/u(A)*S:f*S,_=(0,cu.pie)().value(t=>{const e=n(t)?.length;return e?4:1}).sort(null)(w),P=h(A);for(let e=0;w.length>e;e++){const n=(_[e].startAngle+_[e].endAngle)/2,a=w[e],u=p(s(a)),h=c+M*Math.sin(n),f=l+M*Math.cos(n)*P;o.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:y,data:a}),d.metaMap.set(u,{ring:M,angle:n,depth:y,parentId:i,eccentricity:P}),r.push({source:i,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:u}}),t(a,u,h,f,M,y+1,!0)}k+=v}}(t,x,y,g,m,1,!1)}(r,o,i,t,e)},buildScene(t,e,i,o){const r=i.nodeStyle,n=i.nodeSize,s="number"==typeof n?()=>n:"function"==typeof n?n:()=>6,a=[],c=[],l=[];if(!1!==i.orbitShowRings){const e=lu(i),o=new Map;for(const e of t)o.set(e.id,e);const r=new Map;for(const[,t]of e.metaMap){if(!t.parentId)continue;const e=o.get(t.parentId);if(!e)continue;const i=`${t.parentId}:${t.ring}`;r.has(i)||r.set(i,{parentX:e.x,parentY:e.y,ring:t.ring,ecc:t.eccentricity})}const n=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:t,parentY:e,ring:i,ecc:o}]of r)for(let r=0;n>r;r++){const a=r/n*Math.PI*2,l=(r+1)/n*Math.PI*2;c.push({type:"line",x1:t+i*Math.sin(a),y1:e+i*Math.cos(a)*o,x2:t+i*Math.sin(l),y2:e+i*Math.cos(l)*o,style:s,datum:null})}}for(const e of t){if(null==e.x||null==e.y)continue;const t=s(El(e,"nodeSize")),o=r?r(El(e,"nodeStyle")):{};a.push({type:"circle",cx:e.x,cy:e.y,r:t,style:{fill:o.fill||i.themeSemantic?.primary||"#6366f1",stroke:o.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:o.strokeWidth??1,opacity:o.opacity??(0===(e.depth??0)?1:.85)},datum:e,id:e.id,label:e.id,depth:e.depth})}const u=new Map;for(const e of t)u.set(e.id,e);for(const t of e){const e="object"==typeof t.source?t.source:u.get(t.source),i="object"==typeof t.target?t.target:u.get(t.target);e&&i&&(null!=e.x&&null!=i.x&&c.push({type:"line",x1:e.x,y1:e.y,x2:i.x,y2:i.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:t}))}if(i.showLabels){const e=i.nodeLabel;for(const i of t){const t=s(El(i,"nodeSize"));if(4>=t)continue;const o="function"==typeof e?e(i):e?i.data?.[e]??i.id:i.id;l.push({x:i.x,y:i.y+t+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:c,labels:l}},tick:(t,e,i,o,r)=>!1!==i.orbitAnimated&&(function(t,e){const i=lu(e),o=e.orbitSpeed??.25,r=e.orbitRevolution??function(t){switch(t){case"decay":return t=>Math.pow(.6,t.depth??0);case"alternate":return t=>{const e=t.depth??0;return(e%2==0?1:-1)/(e+1)};default:return t=>1/((t.depth??0)+1)}}(e.orbitRevolutionStyle),n=(("undefined"!=typeof performance?performance.now():Date.now())-i.startTime)/1e3,s=o*(Math.PI/6),a=new Map;for(const e of t)a.set(e.id,e);for(const e of t){const t=i.metaMap.get(e.id);if(!t||!t.parentId)continue;const o=a.get(t.parentId);if(!o)continue;const c=t.angle+n*s*r({id:e.id,depth:t.depth,data:e.data,parentId:t.parentId});e.x=o.x+t.ring*Math.sin(c),e.y=o.y+t.ring*Math.cos(c)*t.eccentricity,e.x0=e.x,e.x1=e.x,e.y0=e.y,e.y1=e.y}}(t,i),!0)}},hu=require("react/jsx-runtime");function du(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}var fu=new Set(["tree","cluster","treemap","circlepack","partition"]);function pu(t,e){const i=Pt(t.theme),o=t.chartType||"force",r=()=>fr({frameType:"network",width:n[0],height:n[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,nodeCount:0,edgeCount:0}),n=t.size||[500,500],s=Qa({top:20,right:20,bottom:20,left:20,...t.margin},t.title),a=Ka(t.title),c=t.showLegend?(()=>{const e="string"==typeof(i=t.colorBy)||"function"==typeof i?t.colorBy:void 0;var i;if(!e)return[];const o=b(t.nodes||[]);if(o.length>0)return js(o,e);const r=Array.isArray(t.edges)?b(t.edges):[];if(0===r.length)return[];const n=du(t.sourceAccessor,"source"),s=du(t.targetAccessor,"target");return js(Array.from(new Set(r.flatMap(t=>[n(t),s(t)]).filter(t=>null!=t).map(String))).map(t=>({id:t})),e)})():[];cc(s,{props:t,categories:c,theme:i,size:n,hasTitle:a});const l=n[0]-s.left-s.right,u=n[1]-s.top-s.bottom,h=function(t){return uu[t]}(o);if(!h&&!t.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${o}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const d={chartType:o,nodeIDAccessor:t.nodeIDAccessor,sourceAccessor:t.sourceAccessor,targetAccessor:t.targetAccessor,valueAccessor:t.valueAccessor,childrenAccessor:t.childrenAccessor,hierarchySum:t.hierarchySum,orientation:t.orientation,nodeAlign:t.nodeAlign,nodePaddingRatio:t.nodePaddingRatio,nodeWidth:t.nodeWidth,iterations:t.iterations,forceStrength:t.forceStrength,padAngle:t.padAngle,groupWidth:t.groupWidth,sortGroups:t.sortGroups,edgeSort:t.edgeSort,treeOrientation:t.treeOrientation,edgeType:t.edgeType,padding:t.padding,paddingTop:t.paddingTop,nodeStyle:t.nodeStyle,edgeStyle:t.edgeStyle,nodeLabel:t.nodeLabel,showLabels:t.showLabels,colorBy:t.colorBy,colorScheme:t.colorScheme||i.colors.categorical,edgeColorBy:t.edgeColorBy,edgeOpacity:t.edgeOpacity,colorByDepth:t.colorByDepth,nodeSize:t.nodeSize,nodeSizeRange:t.nodeSizeRange,customNetworkLayout:t.customNetworkLayout,layoutConfig:t.layoutConfig};let f,p;if(fu.has(o)){const o=t.data||t.edges;if(!o||Array.isArray(o))return e&&(e.evidence=r()),Ic.renderToStaticMarkup(hc(null,{width:n[0],height:n[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:u,idPrefix:t._idPrefix}));d.__hierarchyRoot=o,f=[],p=[]}else{const o=b(t.nodes||[]),a=Array.isArray(t.edges)?b(t.edges):[];if(0===o.length&&0===a.length)return e&&(e.evidence=r()),Ic.renderToStaticMarkup(hc(null,{width:n[0],height:n[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:u,idPrefix:t._idPrefix}));if(p=function(t,e){const i=du(e.sourceAccessor,"source"),o=du(e.targetAccessor,"target"),r=du(e.valueAccessor,"value");return t.map(t=>({source:i(t)+"",target:o(t)+"",value:Number(r(t))||1,y0:0,y1:0,sankeyWidth:0,data:t}))}(a,d),0===o.length&&p.length>0){const t=new Set;for(const e of p){const i=ic(e.source),o=ic(e.target);i&&t.add(i),o&&t.add(o)}f=Array.from(t).map(t=>({id:t,x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:{id:t}}))}else f=function(t,e){const i=du(e.nodeIDAccessor,"id");return t.map(t=>({id:i(t)+"",x:t.x??0,y:t.y??0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:0,data:t}))}(o,d)}let y=[],g=[],m=[],x=null;if(d.customNetworkLayout){const t=d.colorScheme,e=Ko(t,i.colors.categorical,A),o=Qo(e,t),r={nodes:f,edges:p,dimensions:{width:l,height:u,plot:{x:0,y:0,width:l,height:u}},theme:{semantic:i.colors,categorical:[...e]},resolveColor:o,config:d.layoutConfig??{}},n=d.customNetworkLayout(r);y=n.sceneNodes??[],g=n.sceneEdges??[],m=n.labels??[],x=n.overlays??null}else if(h){h.computeLayout(f,p,d,[l,u]);const t=h.buildScene(f,p,d,[l,u]);y=t.sceneNodes,g=t.sceneEdges,m=t.labels}const v=Lt(i);for(const t of m)t.fill||(t.fill=v.text);const w=ks({nodes:g,renderMode:t.renderMode,fallback:(t,e)=>function(t,e){switch(t.type){case"line":return(0,ls.jsx)("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity},"net-edge-"+e);case"bezier":{const i=t;return(0,ls.jsx)("path",{d:i.pathD,fill:rs(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+e)}case"ribbon":{const i=t;return(0,ls.jsx)("path",{d:i.pathD,fill:rs(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-edge-"+e)}case"curved":{const i=t;return(0,ls.jsx)("path",{d:i.pathD,fill:rs(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth||1,opacity:i.style.opacity},"net-edge-"+e)}default:return null}}(t,e)}),k=ks({nodes:y,renderMode:t.renderMode,fallback:(t,e)=>function(t,e){switch(t.type){case"circle":{const i=t,o=Gn(i.style.fill)?Vn(i.style.fill,`net-circle-${e}-hatch`):void 0;return(0,ls.jsxs)(as.Fragment,{children:[o&&(0,ls.jsx)("defs",{children:o}),(0,ls.jsx)("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:o?`url(#net-circle-${e}-hatch)`:rs(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-circle-"+e)}case"rect":{const i=t,o=Gn(i.style.fill)?Vn(i.style.fill,`net-rect-${e}-hatch`):void 0;return(0,ls.jsxs)(as.Fragment,{children:[o&&(0,ls.jsx)("defs",{children:o}),(0,ls.jsx)("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:o?`url(#net-rect-${e}-hatch)`:rs(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-rect-"+e)}case"arc":{const i=t,o=(0,cs.arc)().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(os)||"",r=Gn(i.style.fill)?Vn(i.style.fill,`net-arc-${e}-hatch`):void 0;return(0,ls.jsxs)(as.Fragment,{children:[r&&(0,ls.jsx)("defs",{children:r}),(0,ls.jsx)("path",{d:o,transform:`translate(${i.cx},${i.cy})`,fill:r?`url(#net-arc-${e}-hatch)`:rs(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-arc-"+e)}case"symbol":{const i=t,o=en(i.symbolType,i.size,i.path);return(0,ls.jsx)("path",{d:o,transform:i.rotation?`translate(${i.cx},${i.cy}) rotate(${180*i.rotation/Math.PI})`:`translate(${i.cx},${i.cy})`,fill:i.style.fill?rs(i.style.fill):"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},"net-symbol-"+e)}case"glyph":return ss(t,t.cx,t.cy,"net-glyph-"+(t.id??e));default:return null}}(t,e)});e&&(e.evidence=fr({frameType:"network",width:n[0],height:n[1],marks:[...k.map(({node:t})=>({type:"node:"+(t.type??"node")})),...w.map(({node:t})=>({type:"edge:"+(t.type??"edge")}))],title:t.title,description:t.description,annotations:t.annotations,nodeCount:k.length,edgeCount:w.length}));const S=w.map(t=>t.element),M=k.map(t=>t.element),_=m.map((t,e)=>function(t,e){return(0,ls.jsx)("text",{x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"var(--semiotic-text, #333)",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,children:t.text},"net-label-"+e)}(t,e)).filter(Boolean),P=t.annotations?Xa({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{},layout:{width:l,height:u},theme:i,idPrefix:t._idPrefix}):null,L=lc({props:t,categories:c,theme:i,size:n,margin:s,hasTitle:a});return Ic.renderToStaticMarkup(hc((0,hu.jsxs)(hu.Fragment,{children:[t.backgroundGraphics,S,M,_,P,t.foregroundGraphics,x]}),{width:n[0],height:n[1],className:"stream-network-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${s.left},${s.top})`,innerWidth:l,innerHeight:u,legend:L,idPrefix:t._idPrefix}))}var yu=c(require("react-dom/server")),gu=require("d3-geo"),mu=require("d3-quadtree"),xu=require("d3-geo"),bu={mercator:xu.geoMercator,equalEarth:xu.geoEqualEarth,albersUsa:xu.geoAlbersUsa,orthographic:xu.geoOrthographic,naturalEarth:xu.geoNaturalEarth1,equirectangular:xu.geoEquirectangular};function vu(t,e){return t?"function"==typeof t?t:e=>e[t]:t=>t[e]}function wu(t){return t?"function"==typeof t?t:e=>e[t]:t=>t.coordinates||t.data||[]}function ku(t,e,i){return t?"function"==typeof t?{...i,...t(e)}:{...i,...t}:{...i}}function Su(t,e){if(2>t.length)return[t];const i=.4*e,o=[];let r=[t[0]];for(let e=1;t.length>e;e++){const n=t[e];Math.abs(n[0]-t[e-1][0])>i?(2>r.length||o.push(r),r=[n]):r.push(n)}return 2>r.length||o.push(r),o}function Au(t,e,i=24){const o=e[0]-t[0],r=e[1]-t[1],n=Math.sqrt(o*o+r*r);if(0===n)return[t,e];const s=-r/n,a=o/n,c=Math.min(.3*n,80),l=(t[0]+e[0])/2+s*c,u=(t[1]+e[1])/2+a*c,h=[];for(let o=0;i>=o;o++){const r=o/i,n=1-r;h.push([n*n*t[0]+2*n*r*l+r*r*e[0],n*n*t[1]+2*n*r*u+r*r*e[1]])}return h}function Mu(t,e){if(2>t.length)return t;const i=e/2+1,o=[];for(let e=0;t.length>e;e++){const r=t[e];let n,s;0===e?(n=t[1][0]-r[0],s=t[1][1]-r[1]):e===t.length-1?(n=r[0]-t[e-1][0],s=r[1]-t[e-1][1]):(n=t[e+1][0]-t[e-1][0],s=t[e+1][1]-t[e-1][1]);const a=Math.sqrt(n*n+s*s)||1;o.push([r[0]+s/a*i,r[1]+-n/a*i])}return o}function _u(t,e,i,o,r){const n=e[0]-t[0],s=e[1]-t[1],a=Math.sqrt(n*n+s*s);if(0===a)return[t,e];const c=s/a,l=-n/a,u=r/2+1;return[[t[0]+c*u,t[1]+l*u],[e[0]+c*u,e[1]+l*u]]}var Pu=require("d3-scale"),Lu=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Ru=["scene-style","data-paint","accessibility","evidence"],Tu=(t,e)=>({retainedData:t,invalidations:e}),Cu=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],$u=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ju=["scene-geometry","data-paint","accessibility","evidence"],zu=["scene-style","data-paint","accessibility","evidence"],Eu=["overlay","accessibility","evidence"],Du=[],Fu={xAccessor:Tu("rebuild",Cu),yAccessor:Tu("rebuild",Cu),lineDataAccessor:Tu("rebuild",Cu),pointIdAccessor:Tu("rebuild",ju),lineIdAccessor:Tu("rebuild",ju),windowSize:Tu("rebuild",Cu),projection:Tu("preserve",$u),projectionExtent:Tu("preserve",$u),fitPadding:Tu("preserve",$u),lineType:Tu("preserve",$u),flowStyle:Tu("preserve",$u),graticule:Tu("preserve",$u),projectionTransform:Tu("preserve",$u),customLayout:Tu("preserve",$u),layoutConfig:Tu("preserve",$u),layoutMargin:Tu("preserve",$u),areaStyle:Tu("preserve",zu),pointStyle:Tu("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:Tu("preserve",zu),colorScheme:Tu("preserve",zu),themeCategorical:Tu("preserve",zu),themeDiverging:Tu("preserve",zu),themeSemantic:Tu("preserve",zu),themeSequential:Tu("preserve",zu),decay:Tu("preserve",zu),pulse:Tu("preserve",zu),layoutSelection:Tu("preserve",zu),annotations:Tu("preserve",Eu),autoPlaceAnnotations:Tu("preserve",Eu),clock:Tu("preserve",Du),transition:Tu("preserve",Du),introAnimation:Tu("preserve",Du),onLayoutError:Tu("preserve",Du)},Ou=Tu("preserve",$u),Nu=class{constructor(){this.tracker=new xo}get last(){return this.tracker.last}subscribe(t){return this.tracker.subscribe(t)}recordData(t,e){return this.tracker.record({kind:t,...void 0===e?{}:{count:e}},Lu)}recordNoop(t){return this.tracker.record({kind:t,..."restyle"===t?{}:{count:0}},[])}recordRestyle(t){return t?this.tracker.record({kind:"restyle"},Ru):this.recordNoop("restyle")}recordConfig(t,e={}){const i=function(t){let e="preserve";const i=new Set;for(const o of t){const t=Fu[o]??Ou;"rebuild"===t.retainedData&&(e="rebuild");for(const e of t.invalidations)i.add(e)}return{retainedData:e,invalidations:i}}(t),o=new Set(i.invalidations);return e.retainedDataChanged&&o.add("data"),this.tracker.record({kind:"config",keys:t},o)}},Bu=require("d3-geo");function Iu(t){if(null==t)return 0;if("number"==typeof t&&Number.isFinite(t)&&t>=0&&.5>t)return t;throw new RangeError(`[semiotic] fitPadding must be a finite fraction in [0, 0.5); received ${t+""}.`)}var Wu=class t{constructor(t){this.updateResults=new Nu,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(t){return{...t,fitPadding:Iu(t.fitPadding)}}(t)}currentTime(){return this.config.clock?.()??Rr()}getConfiguredWindowSize(){const t=this.config.windowSize??500;if(!Number.isInteger(t)||1>t)throw Error("GeoPipelineStore windowSize must be a positive integer");return t}retainNewestLines(t=this.getConfiguredWindowSize()){this.lineData.length>t&&(this.lineData=this.lineData.slice(-t))}resizeStreamingWindow(t){if(this.pointBuffer){const e=this.pointBuffer.toArray(),i=this.timestampBuffer?.toArray()??[],o=e.slice(-t),r=i.slice(-o.length),n=this.currentTime();this.pointBuffer=new gr(t),this.timestampBuffer=new gr(t),o.forEach((t,e)=>{this.pointBuffer.push(t),this.timestampBuffer.push(r[e]??n)})}this.retainNewestLines(t)}updateConfig(t){const e=function(t){return"fitPadding"in t?{...t,fitPadding:Iu(t.fitPadding)}:t}(t),i=this.config,o=this.getConfiguredWindowSize(),r=Object.keys(e).filter(t=>e[t]!==i[t]);this.config={...this.config,...e};const n=this.getConfiguredWindowSize(),s=this.streaming&&n!==o;s&&(this.resizeStreamingWindow(n),this.version++),"customLayout"in e&&!e.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(r,{retainedDataChanged:s})}updateConfigWithResult(t){return this.updateConfig(t),this.updateResults.last}setAreas(t){this.areas=t,this.updateResults.recordData("replace",t.length)}setAreasWithResult(t){return this.setAreas(t),this.updateResults.last}setPoints(t){this.pointData=t.slice(),this.pointBuffer=null,this.timestampBuffer=null,this.streaming=!1,this.updateResults.recordData("replace",t.length)}setPointsWithResult(t){return this.setPoints(t),this.updateResults.last}setLines(t){this.lineData=t.slice(),this.streaming&&this.retainNewestLines(),this.updateResults.recordData("replace",t.length)}setLinesWithResult(t){return this.setLines(t),this.updateResults.last}initStreaming(t){void 0!==t&&t!==this.config.windowSize&&(this.config={...this.config,windowSize:t});const e=this.getConfiguredWindowSize(),i=this.pointBuffer?this.pointBuffer.toArray():this.pointData,o=this.timestampBuffer?.toArray()??[],r=i.slice(-e),n=o.slice(-r.length),s=this.currentTime();this.pointBuffer=new gr(e),this.timestampBuffer=new gr(e),r.forEach((t,e)=>{this.pointBuffer.push(t),this.timestampBuffer.push(n[e]??s)}),this.pointData=[],this.retainNewestLines(e),this.streaming=!0}pushPoint(t){this.pointBuffer||this.initStreaming();const e=this.currentTime();gn(this.pointBuffer,t,this.timestampBuffer,e),this.lastIngestTime=e,this.updateResults.recordData("ingest",1)}pushPointWithResult(t){return this.pushPoint(t),this.updateResults.last}pushMany(t){this.pointBuffer||this.initStreaming();const e=this.currentTime();for(const i of t)gn(this.pointBuffer,i,this.timestampBuffer,e);this.lastIngestTime=e,this.updateResults.recordData("ingest",t.length)}pushManyWithResult(t){return this.pushMany(t),this.updateResults.last}pushLine(t){null!=t&&"object"==typeof t?(this.streaming||this.initStreaming(),this.lineData.push(t),this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",1)):this.updateResults.recordNoop("ingest")}pushManyLines(t){if(!Array.isArray(t)||0===t.length)return void this.updateResults.recordNoop("ingest");const e=t.filter(t=>null!=t&&"object"==typeof t);if(0!==e.length){this.streaming||this.initStreaming();for(const t of e)this.lineData.push(t);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",e.length)}else this.updateResults.recordNoop("ingest")}removeLine(t){const{lineIdAccessor:e}=this.config;if(!e)throw Error("removeLine() requires lineIdAccessor to be configured");const i="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]),r=[];return this.lineData=this.lineData.filter(t=>!o.has(i(t)+"")||(r.push(t),!1)),r.length>0?(this.version++,this.updateResults.recordData("remove",r.length)):this.updateResults.recordNoop("remove"),r}getLines(){return this.lineData.slice()}removePoint(t){const{pointIdAccessor:e}=this.config;if(!e)throw Error("removePoint() requires pointIdAccessor to be configured");const i="function"==typeof e?e:t=>t[e],o=new Set(Array.isArray(t)?t:[t]);if(this.streaming&&this.pointBuffer){const t=t=>o.has(i(t)+"");mn(this.pointBuffer,this.timestampBuffer,t);const e=this.pointBuffer.remove(t);return e.length>0?(this.version++,this.updateResults.recordData("remove",e.length)):this.updateResults.recordNoop("remove"),e}{const t=[];return this.pointData=this.pointData.filter(e=>!o.has(i(e)+"")||(t.push(e),!1)),t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}}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(t){const e=this._customRestyle;if(e){for(const i of this.scene){const o=this._baseStyles.get(i)??i.style,r=e(i,t);i.style=r?{...o,...r}:o}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(t){const{config:e}=this,i=this.projection,o=this.geoPath,r=this.scales,n=this.baseScale,s=[...this.baseTranslate],a=[...this.baseRotation],c=this.scene;this.projection=function(t){if(!t)return(0,xu.geoEqualEarth)();if("string"==typeof t){const e=bu[t];return e?e():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${t}", falling back to equalEarth`),(0,xu.geoEqualEarth)())}if("object"==typeof t&&"type"in t){const e=bu[t.type],i=e?e():(0,xu.geoEqualEarth)();return t.rotate&&"rotate"in i&&i.rotate(t.rotate),t.center&&"center"in i&&i.center(t.center),i}return t}(e.projection),this.geoPath=(0,gu.geoPath)(this.projection),this.fitProjection(t),this.geoPath=(0,gu.geoPath)(this.projection);const l=this.projection;this.scales={projection:l,geoPath:this.geoPath,projectedPoint:(t,e)=>l([t,e]),invertedPoint:(t,e)=>l.invert?l.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const u=this.buildSceneNodes(t);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=i,this.geoPath=o,this.scales=r,this.baseScale=n,this.baseTranslate=s,this.baseRotation=a):(this.scene=[],this.rebuildQuadtree());else{if(this.scene=u,this.rebuildQuadtree(),e.projectionTransform&&this.applyCartogramTransform(e.projectionTransform,t),e.decay&&this.streaming&&this.applyDecay(),e.pulse&&this.streaming&&this.applyPulse(),e.transition&&!this._hasRenderedOnce&&this.scene.length>0&&e.introAnimation){const e=t.width/2,i=t.height/2,o=this.scene.filter(t=>"point"===t.type).map(t=>({...t,x:e,y:i}));o.length>0&&this.startTransition(o)}this._hasRenderedOnce=!0,e.transition&&c.length>0&&this.startTransition(c),this.version++}}fitProjection(t){const e=this.projection,i=this.config,o=[...this.areas],r=vu(i.xAccessor,"lon"),n=vu(i.yAccessor,"lat"),s=this.getPoints();if(s.length>0){const t=s.map(t=>[r(t),n(t)]);o.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:t}})}const a=wu(i.lineDataAccessor);for(const t of this.lineData){const e=a(t);if(e&&e.length>0){const t=e.map(t=>[r(t),n(t)]);o.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:t}})}}if(0!==o.length){if(i.projectionExtent){const[[o,r],[n,s]]=i.projectionExtent;e.fitExtent([[0,0],[t.width,t.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[o,r],[o,s],[n,s],[n,r],[o,r]]]}})}else if(e.clipAngle&&(e.clipAngle()??0)>0){const o=i.fitPadding??0,r=Math.min(t.width,t.height);e.scale(r/2-r*o),e.translate([t.width/2,t.height/2])}else{const r=i.fitPadding??0,n=t.width*r,s=t.height*r;e.fitExtent([[n,s],[t.width-n,t.height-s]],{type:"FeatureCollection",features:o})}this.baseScale=e.scale(),this.baseTranslate=e.translate(),this.baseRotation=e.rotate?.()??[0,0,0]}}applyZoomTransform(t,e){const i=this.projection;if(!i)return;const o=this.geoPath,r=this.scales,n=i.scale(),s=[...i.translate()],a=this.currentZoom;i.scale(this.baseScale*t.k),i.translate([this.baseTranslate[0]*t.k+t.x,this.baseTranslate[1]*t.k+t.y]),this.currentZoom=t.k,this.geoPath=(0,gu.geoPath)(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(n),i.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,e),this.version++)}applyZoomScale(t,e){const i=this.projection;if(!i)return;const o=this.geoPath,r=this.scales,n=i.scale(),s=[...i.translate()],a=this.currentZoom;i.scale(this.baseScale*t),i.translate(this.baseTranslate),this.currentZoom=t,this.geoPath=(0,gu.geoPath)(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const c=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(n),i.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,e),this.version++)}applyRotation(t,e){const i=this.projection;if(!i||!i.rotate)return;const o=this.geoPath,r=this.scales,n=[...i.rotate()];i.rotate(t),this.geoPath=(0,gu.geoPath)(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(t,e)=>i([t,e]),invertedPoint:(t,e)=>i.invert?i.invert([t,e]):null},this._customLayoutFailedThisBuild=!1;const s=this.buildSceneNodes(e);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.rotate(n),this.geoPath=o,this.scales=r):(this.scene=[],this.rebuildQuadtree()):(this.scene=s,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,e),this.version++)}setRotation(t){const e=this.projection;e&&e.rotate&&e.rotate(t)}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 e=0,i=0;for(const t of this.scene)"point"===t.type&&(i++,t.r>e&&(e=t.r));if(this._maxPointRadius=e,t.QUADTREE_THRESHOLD>=i)return void(this._quadtree=null);const o=Array(i);let r=0;for(const t of this.scene)"point"===t.type&&(o[r++]=t);this._quadtree=(0,mu.quadtree)().x(t=>t.x).y(t=>t.y).addAll(o)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(t){this._customLayoutFailedThisBuild=!1;const{config:e}=this,i=this.projection,o=this.geoPath;if(e.customLayout&&this.scales){const i=e.layoutMargin??{top:0,right:0,bottom:0,left:0},o=Ko(e.colorScheme,e.themeCategorical,U),r={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:t.width,height:t.height,margin:i,plot:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:e.themeSemantic??{},categorical:[...o]},resolveColor:Qo(o,e.colorScheme),config:e.layoutConfig??{},selection:e.layoutSelection??null};let n;try{n=e.customLayout(r)}catch(t){const i=null!==this.lastCustomLayoutResult,o=cn("geo",t,i,this.version);this.lastCustomLayoutFailure=o,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",t);try{e.onLayoutError?.(o)}catch(t){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",t)}return i?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[])}const s=n.nodes??[];if(this.customLayoutOverlays=n.overlays??null,this.lastCustomLayoutResult=n,this.lastCustomLayoutFailure=null,this._customRestyle=n.restyle,this.hasCustomRestyle=!!n.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(const t of s)this._baseStyles.set(t,t.style);this.restyleScene(e.layoutSelection??null)}return nn({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:t,projection:e,path:i,areas:o,points:r,lines:n,layout:s}){const a=vu(t.xAccessor,"lon"),c=vu(t.yAccessor,"lat"),l=[],u=function(t){return{fill:t.themeSemantic?.surface||"#e0e0e0",stroke:t.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(t),h=function(t){return{stroke:t.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(t),d=function(t){return{fill:t.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(t);if(t.graticule){const e=!0===t.graticule?{}:t.graticule,o=(0,Bu.geoGraticule)();e.step&&o.step(e.step);const r=i(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:e.stroke||"#e0e0e0",strokeWidth:e.strokeWidth||.5,strokeDasharray:e.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(const e of o){const o=i(e);if(!o)continue;const r=i.centroid(e),n=i.bounds(e),s=i.area(e);l.push({type:"geoarea",pathData:o,centroid:r,bounds:n,screenArea:s,style:ku(t.areaStyle,e,u),datum:e,interactive:!0})}const f=wu(t.lineDataAccessor);for(const i of n){const o=f(i);if(!o||2>o.length)continue;let r=[];if("geo"===t.lineType){const t=Array(o.length);for(let e=0;o.length>e;e++)t[e]=[a(o[e]),c(o[e])];for(let i=0;t.length-1>i;i++){const o=t[i],n=t[i+1],s=(0,Bu.geoDistance)(o,n)||0,a=Math.max(2,Math.ceil(s/(Math.PI/180))),c=(0,Bu.geoInterpolate)(o,n);for(let t=0;a>=t;t++){if(i>0&&0===t)continue;const o=e(c(t/a));null!=o&&r.push(o)}}}else for(let t=0;o.length>t;t++){const i=o[t],n=e([a(i),c(i)]);null!=n&&r.push(n)}if(2>r.length)continue;const n=ku(t.lineStyle,i,h),u="number"==typeof n.strokeWidth?n.strokeWidth:1;2!==o.length||2>r.length||"arc"!==t.flowStyle?2!==o.length||2>r.length||"offset"!==t.flowStyle||(r="geo"===t.lineType?Mu(r,u):_u(r[0],r[r.length-1],0,0,u)):r=Au(r[0],r[r.length-1]);const d=Su(r,s.width);if(d.length>1)for(const t of d)2>t.length||l.push({type:"line",path:t,style:{...n,_edgeFade:!0},datum:i});else l.push({type:"line",path:2>r.length&&d[0]||r,style:n,datum:i})}const p=t.pointIdAccessor?"function"==typeof t.pointIdAccessor?t.pointIdAccessor:e=>e[t.pointIdAccessor]:null,y=e.clipAngle?e.clipAngle()??0:0,g=y>0?y*Math.PI/180:null,m=e.rotate?e.rotate():[0,0,0],x="function"==typeof e.center?e.center():[0,0],b=[(x[0]??0)-m[0],(x[1]??0)-m[1]];for(const i of r){const o=a(i),r=c(i);if(null!=g&&(0,Bu.geoDistance)([o,r],b)>g)continue;const n=e([o,r]);if(!n)continue;const s=t.pointStyle?t.pointStyle(i):{...d},u={type:"point",x:n[0],y:n[1],r:s.r||4,style:s,datum:i,pointId:p?p(i)+"":void 0};l.push(u)}return l}({config:e,projection:i,path:o,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:t})}applyCartogramTransform(t,e){const i=function(t,e,i,o){const r=t.filter(t=>"point"===t.type);if(2>r.length)return null;const n=e.strength??1;if(0===n)return null;const s=e.centerAccessor?"function"==typeof e.centerAccessor?e.centerAccessor:t=>t[e.centerAccessor]:t=>t.id,a="function"==typeof e.costAccessor?e.costAccessor:t=>t[e.costAccessor],c=r.find(t=>t.datum&&s(t.datum)+""==e.center+"");if(!c)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${e.center}" not found in point data`),null;const l=c.x,u=c.y,h=ot(r.map(t=>t.datum?a(t.datum):NaN).filter(t=>isFinite(t)&&t>=0),1),d=Math.min(i.width,i.height)/2,f=(0,Pu.scaleLinear)().domain([0,h]).range([0,d]);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 e=t.length-1;e>=0;e--){const i=t[e];"geoarea"===i.type&&i.interactive&&t.splice(e,1)}for(const t of r){if(t===c)continue;if(!t.datum)continue;const e=Math.atan2(t.y-u,t.x-l),i=Math.sqrt((t.x-l)**2+(t.y-u)**2),o=a(t.datum),r=i+((isFinite(o)?f(o):i)-i)*n;t.x=l+Math.cos(e)*r,t.y=u+Math.sin(e)*r}const p=i.width/2,y=i.height/2,g=p-c.x,m=y-c.y;if(Math.abs(g)>.5||Math.abs(m)>.5)for(const t of r)t.x+=g,t.y+=m;const x={cx:p,cy:y,maxCost:h,availableRadius:d},b=t.filter(t=>"line"===t.type);if(b.length>0&&"fractional"!==e.lineMode){const t=new Map;for(const e of r)e.pointId&&t.set(e.pointId,[e.x,e.y]);for(const e of b){const i=e.datum?.source,o=e.datum?.target;if(i&&o){const r=t.get(i+""),n=t.get(o+"");r&&n&&(e.path=[r,n])}}}return x}(this.scene,t,e,this.areas.length);i&&(this.cartogramLayout=i)}applyDecay(){const t=this.config.decay;if(!t||!this.pointBuffer)return;const e=this.pointBuffer.size;if(0===e)return;const i=this.scene.filter(t=>"point"===t.type);for(let o=0;i.length>o;o++){const r=Tr(t,o,e);i[o]._decayOpacity=r,i[o].style={...i[o].style,opacity:r}}}applyPulse(t=this.currentTime()){const e=this.config.pulse;if(!e||!this.timestampBuffer)return!1;const i=this.scene.filter(t=>"point"===t.type),o=this.timestampBuffer.toArray(),r=e.color||"rgba(255,255,255,0.6)",n=e.glowRadius??4;let s=!1;for(let a=0;i.length>a&&o.length>a;a++){const c=$r(e,o[a],t);s=jr(i[a],c,r,n)||s}return s}refreshPulse(t){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(t)}hasActivePulsesAt(t){return!!this.config.pulse&&zr(this.config.pulse,this.timestampBuffer,t)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(t){const e=this.config.transition?.duration??300;if(0>=e)return;const i=new Map;for(const e of t)"point"===e.type&&e.pointId&&i.set(e.pointId,[e.x,e.y]);const o=this.scene.filter(t=>"point"===t.type);let r=!1;for(const t of o)if(t.pointId){const e=i.get(t.pointId);e&&(t._targetX=t.x,t._targetY=t.y,t.x=e[0],t.y=e[1],(Math.abs(e[0]-t._targetX)>.5||Math.abs(e[1]-t._targetY)>.5)&&(r=!0))}for(const t of o)t.pointId&&!i.has(t.pointId)&&(t._targetOpacity=t.style?.opacity??1,t.style={...t.style,opacity:0},r=!0);r&&(this.activeTransition={startTime:this.currentTime(),duration:e})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(t){if(!this.activeTransition)return!1;const e=Pr(t,this.activeTransition),i=_r(e),o=this.scene.filter(t=>"point"===t.type);for(const t of o){if(null!=t._targetX&&null!=t._targetY){const e=t.y;t.x=Lr(t.x,t._targetX,i),t.y=Lr(e,t._targetY,i)}null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity*i})}if(e>=1){for(const t of o)null!=t._targetX&&(t.x=t._targetX,t.y=t._targetY,t._targetX=void 0,t._targetY=void 0),null!=t._targetOpacity&&(t.style={...t.style,opacity:t._targetOpacity},t._targetOpacity=void 0);return this.activeTransition=null,!1}return!0}};Wu.QUADTREE_THRESHOLD=500;var Yu=Wu;Mn(Yu);var qu=require("react/jsx-runtime");function Xu(t,e){const i=Pt(t.theme),o=t.size||[t.width||600,t.height||400],r=Qa({top:10,right:10,bottom:10,left:10,...t.margin},t.title),n=Ka(t.title),s=Array.isArray(t.areas)?b(t.areas):t.areas,a=b(t.points),c=b(t.lines),l=t.showLegend?(()=>{const e="string"==typeof(i=t.colorBy)||"function"==typeof i?t.colorBy:void 0;var i;return js(a.length>0?a:Array.isArray(s)&&s.length>0?"string"==typeof e?s.map(t=>({...t.properties||{},...t})):s:[],e)})():[];cc(r,{props:t,categories:l,theme:i,size:o,hasTitle:n});const u=o[0]-(r.left??0)-(r.right??0),h=o[1]-(r.top??0)-(r.bottom??0),d={projection:t.projection||"equalEarth",xAccessor:t.xAccessor,yAccessor:t.yAccessor,lineDataAccessor:t.lineDataAccessor,pointIdAccessor:t.pointIdAccessor,lineType:t.lineType,areaStyle:t.areaStyle,pointStyle:t.pointStyle,lineStyle:t.lineStyle,graticule:t.graticule,fitPadding:t.fitPadding,projectionTransform:t.projectionTransform,customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:r,themeCategorical:i.colors.categorical,themeSemantic:mt(i)},f=new Yu(d);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)}t.points&&f.setPoints(a),t.lines&&f.setLines(c),f.computeScene({width:u,height:h});const p=ks({nodes:f.scene,renderMode:t.renderMode,fallback:(t,e)=>function(t,e){switch(t.type){case"geoarea":{const i=t;if(!i.pathData)return null;const o=Gn(i.style.fill)?Vn(i.style.fill,`geoarea-${e}-hatch`):void 0;return(0,hs.jsxs)(us.Fragment,{children:[o&&(0,hs.jsx)("defs",{children:o}),(0,hs.jsx)("path",{d:i.pathData,fill:o?`url(#geoarea-${e}-hatch)`:rs(i.style.fill,"#e0e0e0"),fillOpacity:i.style.fillOpacity??1,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth||.5,strokeDasharray:i.style.strokeDasharray,opacity:i._decayOpacity??1})]},"geoarea-"+e)}case"point":{const i=t,o=Gn(i.style.fill)?Vn(i.style.fill,`geopoint-${e}-hatch`):void 0;return(0,hs.jsxs)(us.Fragment,{children:[o&&(0,hs.jsx)("defs",{children:o}),(0,hs.jsx)("circle",{cx:i.x,cy:i.y,r:i.r,fill:o?`url(#geopoint-${e}-hatch)`:rs(i.style.fill),fillOpacity:i.style.fillOpacity??.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i._decayOpacity??i.style.opacity??1})]},"point-"+e)}case"line":{const i=t;if(2>i.path.length)return null;const o="M"+i.path.map(t=>`${t[0]},${t[1]}`).join("L");return(0,hs.jsx)("path",{d:o,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth||1.5,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity??1},"line-"+e)}case"glyph":return ss(t,t.x,t.y,"geo-glyph-"+(t.pointId??e));default:return null}}(t,e)});if(e&&(e.evidence=fr({frameType:"geo",width:o[0],height:o[1],marks:p.map(t=>t.node),title:t.title,description:t.description,annotations:t.annotations,legendItems:l.length>0?l.length:void 0})),0===p.length){const e=t.backgroundGraphics||t.foregroundGraphics||t.annotations||f.customLayoutOverlays?(0,qu.jsxs)(qu.Fragment,{children:[t.backgroundGraphics,t.annotations?Xa({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{geoProjection:f.scales?.projectedPoint?([t,e])=>f.scales.projectedPoint(t,e):void 0},layout:{width:u,height:h},theme:i,idPrefix:t._idPrefix}):null,t.foregroundGraphics,f.customLayoutOverlays]}):null;return yu.renderToStaticMarkup(hc(e,{width:o[0],height:o[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${r.left??0},${r.top??0})`,innerWidth:u,innerHeight:h,idPrefix:t._idPrefix}))}const y=p.map(t=>t.element),g=t.annotations?Xa({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{geoProjection:f.scales?.projectedPoint?([t,e])=>f.scales.projectedPoint(t,e):void 0},layout:{width:u,height:h},theme:i,idPrefix:t._idPrefix}):null,m=lc({props:t,categories:l,theme:i,size:o,margin:r,hasTitle:n});return yu.renderToStaticMarkup(hc((0,qu.jsxs)(qu.Fragment,{children:[t.backgroundGraphics,y,g,t.foregroundGraphics,f.customLayoutOverlays]}),{width:o[0],height:o[1],className:"stream-geo-frame"+(t.className?" "+t.className:""),title:t.title,description:t.description,background:t.background,theme:i,innerTransform:`translate(${r.left??0},${r.top??0})`,innerWidth:u,innerHeight:h,legend:m,idPrefix:t._idPrefix}))}var Gu=c(require("react-dom/server"));function Vu(t=[]){return t.map(t=>({id:t.id,label:t.label,count:t.count,...null!=t.secondary?{secondary:t.secondary}:{},...t.secondaryLabel?{secondaryLabel:t.secondaryLabel}:{},...null!=t.observed?{observed:t.observed}:{}}))}var Hu={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function Zu(t){const e=t.datum;if(e&&"object"==typeof e){const t=e.label??e.name??e.id;if(null!=t&&""!==t)return t+""}return t.id}function Uu(t,e){const i="function"==typeof e?e(t):e;return{...Hu,...i??{}}}function Ku(t,e={}){return t.map(t=>function(t,e={}){const i=function(t){return t.datum&&"object"==typeof t.datum?t.datum:null}(t),o={label:e.getBodyLabel?.(t)??Zu(t)},r={style:Uu(t,e.bodyStyle),datum:i,accessibleDatum:i,accessibility:o,_transitionKey:t.id};return"aabb"===t.shape.type?{type:"rect",x:t.x-t.shape.width/2,y:t.y-t.shape.height/2,w:t.shape.width,h:t.shape.height,...r}:{type:"point",x:t.x,y:t.y,r:t.shape.radius,pointId:t.id,...r}}(t,e))}var Qu=require("react/jsx-runtime");function Ju(t,e){const i=t.size??[t.width??600,t.height??400],o=new zo(t.config);Array.isArray(t.initialSpawns)&&t.initialSpawns.length>0&&o.enqueue(t.initialSpawns.map(t=>({...t,spawnAt:void 0})));const r=function(t,e={}){const{width:i=640,height:o=360,title:r,description:n,background:s,className:a,idPrefix:c="physics",...l}=e,u=function(t,e={}){const i=t.settle(e.maxSteps),o=t.readBodies(),r=t.snapshot(),n=Ku(o,e),s=function(t,e={}){const i=e.bodies??function(t){return t.world.bodies.map(t=>({id:t.id,x:t.x,y:t.y,prevX:t.prevX,prevY:t.prevY,vx:t.vx,vy:t.vy,angle:t.angle,mass:t.mass,shape:{...t.shape},sleeping:t.sleeping,datum:t.datum}))}(t),o=i.filter(t=>t.sleeping).length;return{bodyCount:i.length,sleepingCount:o,settled:"settled"===t.simulationState&&0===t.queue.length&&o===i.length,stepsRun:Math.max(0,Math.floor(e.stepsRun??0)),seed:t.world.options.seed,binCounts:Vu(e.projectionRows)}}(r,{bodies:o,projectionRows:e.projectionRows,stepsRun:i});return{snapshot:r,bodies:o,sceneNodes:n,evidence:s,stepsRun:i}}(t,l),h=function(t){const e=t.replace(/[^A-Za-z0-9_-]/g,"_");return!e||/^\d/.test(e)?"physics-"+e:e}(c),d=r?h+"-title":void 0,f=n?h+"-desc":void 0,p=[d,f].filter(Boolean).join(" ")||void 0;return{svg:Gu.renderToStaticMarkup((0,Qu.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:a??"stream-physics-frame",width:i,height:o,viewBox:`0 0 ${i} ${o}`,role:"img","aria-labelledby":p,children:[r&&(0,Qu.jsx)("title",{id:d,children:r}),n&&(0,Qu.jsx)("desc",{id:f,children:n}),s&&"transparent"!==s?(0,Qu.jsx)("rect",{x:0,y:0,width:i,height:o,fill:s}):null,(0,Qu.jsx)("g",{id:h+"-data-area",children:u.sceneNodes.map((t,e)=>gs(t,e,h))})]})),scene:u,evidence:u.evidence}}(o,{...t,width:i[0],height:i[1],idPrefix:t.idPrefix??t._idPrefix??"physics"});return e&&(e.evidence=fr({frameType:"physics",width:i[0],height:i[1],marks:r.scene.sceneNodes,title:t.title,description:t.description,annotations:[],extraWarnings:0===r.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[]})),r.svg}var th=require("react/jsx-runtime");function eh(t,e){switch(t){case"xy":return fc(e);case"ordinal":return Bc(e);case"network":return pu(e);case"geo":return Xu(e);case"physics":return Ju(e);default:throw Error(`Unknown frame type: ${t}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function ih(t){return fc(t)}function oh(t){return Bc(t)}function rh(t){return pu(t)}function nh(t){return Xu(t)}var sh=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","scalePadding","sizeRange","innerRadius","centerContent","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","barColors","legend","legendLayout"],ah=["width","height","showAxes","showGrid","enableHover","showLegend","showLabels","showCategoryTicks","orientation","title","description","summary","accessibleTable","xLabel","yLabel","categoryLabel","valueLabel","linkedHover","mobileInteraction","mobileSemantics","responsiveRules"];function ch(t,e){const i={};for(const o of e)void 0!==t[o]&&(i[o]=t[o]);return i}function lh(t,e,i){return hh(t,e).svg}function uh(t,e,i){const o={},{svg:r,frameType:n}=hh(t,e,0,o),s=o.evidence??fr({frameType:n,width:"number"==typeof e.width?e.width:600,height:"number"==typeof e.height?e.height:400,marks:[],title:"string"==typeof e.title?e.title:void 0,description:"string"==typeof e.description?e.description:void 0,annotations:e.annotations,extraWarnings:["NO_EVIDENCE"]});return s.component=t,{svg:r,evidence:s}}function hh(t,e,i,o){const r=ur[t];if(!r)throw Error(`Unknown chart component: "${t}". See CLAUDE.md for supported chart types.`);var n;const s=function(t,e,i){const o=p[t||"primary"],r=t&&"primary"!==t||!i?.width?o.width:i.width,n=t&&"primary"!==t||!i?.height?o.height:i.height,s=function(t,e,i=t.responsiveRules){if(!Array.isArray(i)||0===i.length)return{props:t,matches:[]};const o=i.map((t,e)=>({rule:t,index:e})).filter(t=>function(t,e){const{when:i}=t,o=e.width,r=e.height,n=function(t){if("number"==typeof t.height&&t.height>0)return t.width/t.height}(e),s=function(t){if("number"==typeof t.height&&t.height>0)return t.height>t.width?"portrait":"landscape"}(e);return!("number"==typeof i.minWidth&&i.minWidth>o||"number"==typeof i.maxWidth&&o>i.maxWidth||"number"==typeof i.minHeight&&("number"!=typeof r||i.minHeight>r)||"number"==typeof i.maxHeight&&("number"!=typeof r||r>i.maxHeight)||"number"==typeof i.minAspectRatio&&("number"!=typeof n||i.minAspectRatio>n)||"number"==typeof i.maxAspectRatio&&("number"!=typeof n||n>i.maxAspectRatio)||i.orientation&&s!==i.orientation)}(t.rule,e)).sort((t,e)=>("number"==typeof t.rule.priority?t.rule.priority:t.index)-("number"==typeof e.rule.priority?e.rule.priority:e.index));return{props:o.reduce((t,e)=>function(t,e){const i={...t,...e};for(const o of["margin","frameProps","mobileSemantics","style"])u(t[o])&&u(e[o])&&(i[o]={...t[o],...e[o]});return"string"==typeof t.className&&"string"==typeof e.className&&(i.className=`${t.className} ${e.className}`),i}(t,e.rule.transform),t),matches:o}}({...e,mode:t},{width:e.width??r,height:e.height??n}).props,a=s.mode||t,c=p[a||"primary"],l="context"===a||"sparkline"===a,h=a&&"primary"!==a||!i?.width?c.width:i.width;return{width:s.width??h,height:s.height??(a&&"primary"!==a||!i?.height?c.height:i.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:y(c.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:l,mobileInteraction:f(s.mobileInteraction,{mode:a,width:s.width??h,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}(r.layout?.mode??("string"==typeof(n=e.mode)&&Object.prototype.hasOwnProperty.call(p,n)?e.mode:void 0),{...r.layout?.modeDefaults,...ch(e,ah)},r.layout?.primarySize),{data:a,theme:c,background:l,className:h,annotations:d,margin:m,colorScheme:x,colorBy:b,legendPosition:v,...w}=e,{width:k,height:S}=s,A=[k,S],M=w.frameProps||{},_=r.layout?.margin,P="function"==typeof _?_(e,s):_??s.marginDefaults,L=void 0!==m?m:M.margin,R=function(t){if(null==t)return;if("number"==typeof t)return{top:t,right:t,bottom:t,left:t};const e={};return"number"==typeof t.top&&(e.top=t.top),"number"==typeof t.right&&(e.right=t.right),"number"==typeof t.bottom&&(e.bottom=t.bottom),"number"==typeof t.left&&(e.left=t.left),e}(L),T="number"==typeof L?{top:L,right:L,bottom:L,left:L}:{...P,...R},C=ch(w,sh),$={...M,...C,theme:c,title:s.title,description:s.description,showAxes:s.showAxes,showLegend:s.showLegend,showLabels:s.showLabels,showGrid:s.showGrid,xLabel:s.xLabel,yLabel:s.yLabel,categoryLabel:s.categoryLabel,valueLabel:s.valueLabel,background:l,className:h,annotations:d,size:A,margin:T,__explicitMargin:L,__autoLegendMargin:!0,...void 0!==x&&{colorScheme:x},...void 0!==v&&{legendPosition:v},_idPrefix:w._idPrefix},j=r.buildProps(a,b,x,$,w);let z;switch(r.frameType){case"xy":z=fc(j,o);break;case"ordinal":z=Bc(j,o);break;case"network":z=pu(j,o);break;case"geo":z=Xu(j,o);break;case"physics":z=Ju(j,o)}const E=r.renderOverlay?.(j,{theme:Pt(c)});if(null!=E){const t=g.renderToStaticMarkup((0,th.jsx)(th.Fragment,{children:E}));z=z.replace("</svg>",t+"</svg>")}return{svg:z,frameType:r.frameType}}async function dh(t,e,i={}){const{format:o="png",scale:r=1,background:n}=i;let s,a;s=["xy","ordinal","network","geo","physics"].includes(t)?eh(t,e):lh(t,e),n&&(s=s.replace(/<svg /,`<svg style="background:${n}" `));try{const t="sharp",e=await import(t);a=e.default??e}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=e.width||e.size?.[0]||600,l=e.height||e.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 fh(t,e={}){const{title:i,subtitle:o,theme:r,width:n=1200,height:s,layout:a={},background:c}=e,l=Lt(Pt(r)),u=a.columns||2,h=a.gap??16;let d=0;i&&(d+=30),o&&(d+=20),d>0&&(d+=10);const f=Math.floor((n-h-h*(u-1))/u),p=[];let y=0,m=d+h,x=0;for(const e of t){const t=Math.min(e.colSpan||1,u),i=e.props.height||300;y+t>u&&(m+=x+h,y=0,x=0),p.push({chart:e,x:h/2+y*(f+h),y:m,w:f*t+h*(t-1),h:i}),x=Math.max(x,i),y+=t}const b=s||m+x+h,v=p.map((t,e)=>{const{chart:i,x:o,y:n,w:s,h:a}=t,c={...i.props,width:s,height:a,theme:r,_idPrefix:"chart-"+e};let l;return l=i.component?lh(i.component,c):i.frameType?eh(i.frameType,c):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"></svg>`,(0,th.jsx)("g",{transform:`translate(${o},${n})`,children:(0,th.jsx)("foreignObject",{width:s,height:a,children:(0,th.jsx)("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:l}})})},"dashboard-chart-"+e)});return g.renderToStaticMarkup((0,th.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:n,height:b,role:"img","aria-label":i||"Dashboard",style:{fontFamily:l.fontFamily},children:[i&&(0,th.jsx)("title",{children:i}),c&&(0,th.jsx)("rect",{x:0,y:0,width:n,height:b,fill:c}),i&&(0,th.jsx)("text",{x:n/2,y:24,textAnchor:"middle",fontSize:l.titleSize+4,fontWeight:"bold",fill:l.text,fontFamily:l.fontFamily,children:i}),o&&(0,th.jsx)("text",{x:n/2,y:i?46:20,textAnchor:"middle",fontSize:l.labelSize,fill:l.textSecondary,fontFamily:l.fontFamily,children:o}),v]}))}var ph=c(require("react-dom/server")),yh=require("react/jsx-runtime");function gh(t,e,i,o={}){const{stepSize:r,windowSize:n,frameCount:s,xExtent:a,yExtent:c,transitionFrames:l=4,fps:u=12,easing:h="ease-out",decay:d}=o,f=i.width||600,p=i.height||400,y=Pt(i.theme),g={...i,...a&&{xExtent:a},...c&&{yExtent:c}};if(!e||0===e.length)return[];const m=r||Math.max(1,Math.ceil(e.length/(s||Math.min(60,Math.max(10,e.length))))),x=[];for(let t=m;e.length>=t;t+=m)x.push(t);x[x.length-1]!==e.length&&x.push(e.length);const b=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(t),v=Qa({top:20,right:20,bottom:30,left:40,...i.margin},i.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=e.slice(n?Math.max(0,r-n):0,r),a={chartType:t,windowSize:1e4,windowMode:"sliding",extentPadding:.05,projection:i.projection||"vertical",oAccessor:i.oAccessor||i.categoryAccessor||"category",rAccessor:i.rAccessor||i.valueAccessor||"value",colorAccessor:i.colorAccessor||i.colorBy,stackBy:i.stackBy,groupBy:i.groupBy,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||y.colors.categorical,...d&&{decay:d}},c=new Fc(a);c.ingest({inserts:s,bounded:!0}),c.computeScene({width:w,height:k}),c.scene.length>0&&S.push(kh(c.scene,f,p,y,g))}else for(let o=0;x.length>o;o++){const r=x[o],s=e.slice(n?Math.max(0,r-n):0,r),m={chartType:t,windowSize:s.length+10,windowMode:"sliding",arrowOfTime:"right",extentPadding:.1,xAccessor:i.xAccessor||"x",yAccessor:i.yAccessor||"y",colorAccessor:i.colorAccessor||i.colorBy,groupAccessor:i.groupAccessor||i.lineBy,lineDataAccessor:i.lineDataAccessor,xExtent:a,yExtent:c,colorScheme:i.colorScheme||y.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange,...d&&{decay:d},...l>0&&{transition:{duration:l*(1e3/u),easing:h}}},b=new Wn(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(wh(b.scene,f,p,y,g,v)),l>0&&o>0&&b.activeTransition){const t=l*(1e3/u);for(let e=1;l>=e;e++)b.advanceTransition(b.activeTransition.startTime+e/l*t),S.push(wh(b.scene,f,p,y,g,v))}}return S}function mh(t,e,i={}){return e.map(e=>{try{return lh(t,{...i,...e})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${i.width||e.width||600}" height="${i.height||e.height||400}"></svg>`}})}function xh(t,e,i){const o=e.size??[e.width??600,e.height??400],r=Pt(e.theme),n=Lt(r),s=e.background||r.colors.background,a=e.idPrefix??"physics-gif",c=e.title?`${a}-title-${i}`:void 0,l=e.description?`${a}-desc-${i}`:void 0,u=[c,l].filter(Boolean).join(" ")||void 0,h=Ku(t.readBodies(),{bodyStyle:e.bodyStyle,getBodyLabel:e.getBodyLabel}),d=(0,yh.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:e.className??"stream-physics-frame",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,role:"img","aria-labelledby":u,style:{fontFamily:n.fontFamily},children:[e.title&&(0,yh.jsx)("title",{id:c,children:e.title}),e.description&&(0,yh.jsx)("desc",{id:l,children:e.description}),s&&"transparent"!==s?(0,yh.jsx)("rect",{x:0,y:0,width:o[0],height:o[1],fill:s}):null,(0,yh.jsx)("g",{id:`${a}-frame-${i}`,children:h.map((t,e)=>gs(t,e,`${a}-${i}`))})]});return ph.renderToStaticMarkup(d)}function bh(t,e={}){const{fps:i=12,frameCount:o,durationSeconds:r=2,includeInitialFrame:n=!0,stepDt:s,stepsPerFrame:a,background:c}=e,l=Math.max(.001,s??t.config?.fixedDt??1/120),u=a??Math.max(1,Math.round(1/Math.max(1,i)/l)),h=o??Math.max(1,Math.ceil(r*Math.max(1,i))),d=c?{...t,background:c}:t,f=new zo(t.config);t.initialSpawns?.length&&f.enqueue(t.initialSpawns,t.initialSpawnPacing);const p=[];for(n&&(f.tick(0),p.push(xh(f,d,0)));h>p.length;){for(let t=0;u>t;t+=1)f.tick(l);p.push(xh(f,d,p.length))}return p}function vh(t,e){const i=t.background||e.colors.background;return i&&"transparent"!==i?i:null}function wh(t,e,i,o,r,n){const s=Lt(o),a=Qa({top:20,right:20,bottom:30,left:40,...r.margin},r.title),c=e-a.left-a.right,l=i-a.top-a.bottom,u=vh(r,o),h=r.renderMode,d=t.map((t,e)=>ws({node:t,index:e,renderMode:h,fallback:()=>gs(t,e)})).filter(Boolean),f=function(t,e,i,o,r,n){if(!t||0===t.length)return null;const s=Lt(o),a=[];for(let o=0;t.length>o;o++){const c=t[o];if("y-threshold"===c.type&&null!=c.value){let t=null;if(n)t=n(c.value);else if(r){const[e,o]=r,n=o-e;if(0===n)continue;t=i-(c.value-e)/n*i}if(null==t)continue;const l=c.color||s.primary,u=c.labelPosition||"right";a.push((0,yh.jsxs)("g",{children:[(0,yh.jsx)("line",{x1:0,y1:t,x2:e,y2:t,stroke:l,strokeWidth:c.strokeWidth??1.5,strokeDasharray:c.strokeDasharray||"6,4"}),c.label&&(0,yh.jsx)("text",{x:"left"===u?4:"center"===u?e/2:e-4,y:20>t?Math.min(i-4,t+16):t-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,yh.jsx)(yh.Fragment,{children:a}):null}(r.annotations,c,l,o,r.yExtent,n?.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 ph.renderToStaticMarkup((0,yh.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:i,role:"img","aria-labelledby":x,style:{fontFamily:s.fontFamily},children:[p&&(0,yh.jsx)("title",{id:g,children:p}),y&&(0,yh.jsx)("desc",{id:m,children:y}),u&&(0,yh.jsx)("rect",{x:0,y:0,width:e,height:i,fill:u}),(0,yh.jsxs)("g",{transform:`translate(${a.left},${a.top})`,children:[f,d]}),p&&(0,yh.jsx)("text",{x:e/2,y:Ua,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:p})]}))}function kh(t,e,i,o,r){const n=Lt(o),s=Qa({top:20,right:20,bottom:30,left:40,...r.margin},r.title),a="radial"===r.projection,c=a?s.left+(e-s.left-s.right)/2:s.left,l=a?s.top+(i-s.top-s.bottom)/2:s.top,u=vh(r,o),h=r.renderMode,d=t.map((t,e)=>ws({node:t,index:e,renderMode:h,fallback:()=>bs(t,e)})).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 ph.renderToStaticMarkup((0,yh.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:i,role:"img","aria-labelledby":m,style:{fontFamily:n.fontFamily},children:[f&&(0,yh.jsx)("title",{id:y,children:f}),p&&(0,yh.jsx)("desc",{id:g,children:p}),u&&(0,yh.jsx)("rect",{x:0,y:0,width:e,height:i,fill:u}),(0,yh.jsx)("g",{transform:`translate(${c},${l})`,children:d}),f&&(0,yh.jsx)("text",{x:e/2,y:Ua,textAnchor:"middle",fontSize:n.titleSize,fontWeight:"bold",fill:n.text,fontFamily:n.fontFamily,children:f})]}))}async function Sh(t,e,i,o={}){const{fps:r=12,loop:n=!0,scale:s=1,background:a}=o,c=i.width||600,l=i.height||400,u=gh(t,e,a?{...i,background:a}:i,o);if(0===u.length)throw Error("No frames generated — check that data is not empty");return Mh(u,c,l,{fps:r,loop:n,scale:s})}async function Ah(t,e={}){const{fps:i=12,loop:o=!0,scale:r=1}=e,n=t.size??[t.width??600,t.height??400],s=bh(t,e);if(0===s.length)throw Error("No physics frames generated");return Mh(s,n[0],n[1],{fps:i,loop:o,scale:r})}async function Mh(t,e,i,o={}){const{fps:r=12,loop:n=!0,scale:s=1}=o,a=Math.round(e*s),c=Math.round(i*s);let l,u,h,d;try{const t="sharp",e=await import(t);l=e.default??e}catch{throw Error('Animated GIF export requires "sharp". Install it:\n npm install sharp')}try{const t="gifenc",e=await import(t),i=[e,e.default].find(t=>"function"==typeof t?.GIFEncoder&&"function"==typeof t.quantize&&"function"==typeof t.applyPalette);if(!i)throw Error("gifenc did not expose its encoder functions");u=i.GIFEncoder,h=i.quantize,d=i.applyPalette}catch(t){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc',{cause:t})}const f=Math.round(1e3/r),p=u();for(let e=0;t.length>e;e++){const i=t[e],o=await l(Buffer.from(i),{density:72*s}).resize(a,c).ensureAlpha().raw().toBuffer(),r=new Uint8Array(o),u=h(r,256),y=d(r,u);p.writeFrame(y,a,c,{palette:u,delay:f,repeat:n?0:-1})}return p.finish(),Buffer.from(p.bytes())}
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty,s=(e,t,n)=>function(){if(n)throw n[0];try{return e&&(t=(0,e[r(e)[0]])(e=0)),t}catch(e){throw n=[e],e}},a=(e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})},l=(e,o,s,a)=>{if(o&&"object"==typeof o||"function"==typeof o)for(let l of r(o))i.call(e,l)||l===s||t(e,l,{get:()=>o[l],enumerable:!(a=n(o,l))||a.enumerable});return e},c=(n,r,i)=>(i=null!=n?e(o(n)):{},l(!r&&n&&n.__esModule?i:t(i,"default",{value:n,enumerable:!0}),n));function u(e){let t=1/0,n=-1/0;for(const r of e)t>r&&(t=r),r>n&&(n=r);return[t,n]}function h(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}var d,f,p,y,g,m,x=s({"src/components/charts/shared/minMax.ts"(){}}),b=s({"src/components/stream/brushAccessibility.ts"(){d=c(require("react")),f="Use arrow keys to move the selected range, Shift plus an arrow key to resize it, and Escape to clear it."}}),v={};function w(e,t,n,r){const[o,i]=[Math.min(...t),Math.max(...t)],s=(i-o)/20;let[a,l]=e;if(r)0>n?a=Math.max(o,a-s):l=Math.min(i,l+s);else{const e=l-a;a=Math.max(o,Math.min(i-e,a+n*s)),l=a+e}return[a,l]}function k(e,t){let n=0,r=t.length-1;for(;r>n;){const o=n+r+1>>1;t[o]>e?r=o-1:n=o}return t[n]}function S(e,t){let n=0,r=t.length-1;for(;r>n;){const o=n+r>>1;e>t[o]?n=o+1:r=o}return t[n]}function A({width:e,height:t,totalWidth:n,totalHeight:r,margin:o,dimension:i,scales:s,onBrush:a,binSize:l,snap:c,binBoundaries:u,snapDuring:h,streaming:x}){const b=(0,p.useRef)(null),v=(0,p.useRef)(null),A=(0,p.useRef)(a);A.current=a;const M=(0,p.useRef)(s);M.current=s;const _=(0,p.useMemo)(()=>u?[...u].sort((e,t)=>e-t):void 0,[u]),P=(0,p.useRef)(_);P.current=_;const C=(0,p.useRef)(!1),j=(0,p.useRef)(null),T=function({label:e="Data range brush",description:t=f,onAction:n}={}){const r=d.useId().replace(/:/g,""),o=d.useRef(n);return o.current=n,{description:t,descriptionId:"semiotic-brush-description-"+r,svgProps:{role:"region",tabIndex:0,"aria-label":e,"aria-describedby":"semiotic-brush-description-"+r,onKeyDown:d.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(),o.current?.(t))},[])}}}({label:"xy"===i?"Two-dimensional data range brush":i.toUpperCase()+" data range brush",onAction:e=>{const t=M.current,n=v.current;if(!t||!n||!b.current)return;const r=(0,y.select)(b.current).select(".brush-g");if("clear"===e.type)return C.current=!0,r.call(n.move,null),C.current=!1,j.current=null,void A.current(null);const o=t.x.domain(),s=t.y.domain(),a=j.current;let l=a?.x??[o[0]+.4*(o[1]-o[0]),o[0]+.6*(o[1]-o[0])],c=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"!==i&&(l=w(l,o,h,e.resize)),u||"x"===i||(c=w(c,s,h,e.resize)),u&&"y"===i||!u&&"x"===i)return;const d={x:l,y:c};C.current=!0,r.call(n.move,"x"===i?[t.x(l[0]),t.x(l[1])]:"y"===i?[t.y(c[1]),t.y(c[0])]:[[t.x(l[0]),t.y(c[1])],[t.x(l[1]),t.y(c[0])]]),C.current=!1,j.current=d,A.current(d)}});return(0,p.useEffect)(()=>{if(!b.current)return;const n=(0,y.select)(b.current).select(".brush-g"),r="x"===i?(0,g.brushX)():"y"===i?(0,g.brushY)():(0,g.brush)();return r.extent([[0,0],[e,t]]),r.on("brush end",o=>{if(C.current)return;const s=M.current;if(!s)return;if(!o.selection)return j.current=null,void A.current(null);let a,u;if("x"===i){const[e,n]=o.selection;a=[s.x.invert(e),s.x.invert(n)],u=[s.y.invert(t),s.y.invert(0)]}else if("y"===i){const[t,n]=o.selection;a=[s.x.invert(0),s.x.invert(e)],u=[s.y.invert(n),s.y.invert(t)]}else{const[[e,t],[n,r]]=o.selection;a=[s.x.invert(e),s.x.invert(n)],u=[s.y.invert(r),s.y.invert(t)]}if("bin"===c&&"y"!==i&&("end"===o.type||"brush"===o.type&&h)){const e=P.current;e&&e.length>0?a=function(e,t){return 0===t.length?e:[k(e[0],t),S(e[1],t)]}(a,e):l&&l>0&&(a=[Math.floor(a[0]/l)*l,Math.ceil(a[1]/l)*l]);const t=s.x(a[0]),c=s.x(a[1]);if(C.current=!0,"x"===i)n.call(r.move,[t,c]);else if("xy"===i){const e=o.selection;n.call(r.move,[[t,e[0][1]],[c,e[1][1]]])}C.current=!1}const d={x:a,y:u};j.current=d,A.current(d)}),n.call(r),v.current=r,n.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{r.on("brush end",null),v.current=null}},[e,t,i,c,l,h]),(0,p.useEffect)(()=>{if(!(x&&s&&v.current&&j.current))return;if(!b.current)return;if("y"===i)return;const e=j.current,t=s.x.domain()[0],n=(0,y.select)(b.current).select(".brush-g");if(t>=e.x[1])return C.current=!0,n.call(v.current.move,null),C.current=!1,j.current=null,void A.current(null);let r=e.x[0],o=!1;if(t>e.x[0]){if(r=t,"bin"===c){const e=P.current;e&&e.length>0?r=S(t,e):l&&l>0&&(r=Math.ceil(t/l)*l)}if(r>=e.x[1])return C.current=!0,n.call(v.current.move,null),C.current=!1,j.current=null,void A.current(null);o=!0}const a=s.x(r),u=s.x(e.x[1]);if(C.current=!0,"x"===i)n.call(v.current.move,[a,u]);else{const t=s.y(e.y[1]),r=s.y(e.y[0]);n.call(v.current.move,[[a,t],[u,r]])}if(C.current=!1,o){const t={x:[r,e.x[1]],y:e.y};j.current=t,A.current(t)}},[s,x,i,c,l]),(0,m.jsxs)("svg",{ref:b,width:n,height:r,...T.svgProps,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:[(0,m.jsx)("title",{children:T.svgProps["aria-label"]}),(0,m.jsx)("desc",{id:T.descriptionId,children:T.description}),(0,m.jsx)("g",{className:"brush-g",transform:`translate(${o.left},${o.top})`})]})}a(v,{XYBrushOverlay:()=>A});var M=s({"src/components/stream/XYBrushOverlay.tsx"(){p=require("react"),y=require("d3-selection"),g=require("d3-brush"),b(),m=require("react/jsx-runtime")}});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 r=Math.round(parseInt(n[1],16)*(1-t)),o=Math.round(parseInt(n[2],16)*(1-t)),i=Math.round(parseInt(n[3],16)*(1-t));return`#${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}function P(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 r=Math.round(parseInt(n[1],16)+(255-parseInt(n[1],16))*t),o=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`#${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`}var C,j,T=s({"src/components/charts/shared/colorManipulation.ts"(){}}),R={};function L(e,t,n,r){const o=t.uncertaintyOpacity,i=t.confidenceAccessor;if(!o&&!i)return;const s="object"==typeof o?o:{},a=s.min??.15,l=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[j]=a+Math.max(0,Math.min(1,e))*(l-a))}return}const c=e.map(e=>{const t=n(e),o=r(e);return null!=t&&null!=o&&Number.isFinite(t)&&Number.isFinite(o)?Math.abs(t-o):NaN}),h=c.filter(e=>Number.isFinite(e));if(0===h.length)return;const[d,f]=u(h),p=f-d;e.forEach((e,t)=>{const n=c[t];Number.isFinite(n)&&(e[j]=l-(p>0?(n-d)/p:0)*(l-a))})}function $(e,t){return"function"==typeof t?t(e):!!e[t]}function z(e){return[{type:"anomaly-band",threshold:e.threshold??2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:e.bandOpacity??.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:e.anomalyRadius??6,label:e.label}]}function D(e,t,n,r,o){return(i=r).isTraining||i.isForecast||i.isAnomaly||i.upperBounds||i.lowerBounds?function(e,t,n,r,o){const{isTraining:i,isForecast:s,isAnomaly:a,upperBounds:l,lowerBounds:c,color:u="#6366f1",bandOpacity:h=.15,anomalyColor:d="#ef4444",anomalyRadius:f=6,label:p}=r,y=e.map(e=>{let t="observed";return s&&$(e,s)?t="forecast":i&&$(e,i)&&(t="training"),{...e,[C]:t}}),g=r._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][C]!==n[e+1][C]&&(t.push({...n[e+1],[C]:n[e][C]}),t.push({...n[e],[C]:n[e+1][C]}));m.push(...y,...t)}else for(let e=0;y.length>e;e++)m.push(y[e]),y.length-1>e&&y[e][C]!==y[e+1][C]&&(m.push({...y[e+1],[C]:y[e][C]}),m.push({...y[e],[C]:y[e+1][C]}));if(r.trainUnderline){const e=[];for(const t of m)"training"===t[C]&&e.push({...t,[C]:"training-base"});m.unshift(...e)}const x=[];if(l&&c){const e="string"==typeof l?l:"__envUpper",t="string"==typeof c?c:"__envLower";if("function"==typeof l||"function"==typeof c)for(const n of m)"function"==typeof l&&(n[e]=l(n)),"function"==typeof c&&(n[t]=c(n));x.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:u,fillOpacity:h,label:p})}if(r.uncertaintyOpacity||r.confidenceAccessor){const e=l?"function"==typeof l?l:e=>e[l]:()=>{},t=c?"function"==typeof c?c:e=>e[c]:()=>{};L(m.filter(e=>"forecast"===e[C]),r,e,t)}if(a){const e=r.anomalyStyle,t={type:"highlight",filter:e=>$(e,a)};e?(t.style=e,t.r=f):"function"==typeof d?(t.style=e=>{const t=d(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=f):(t.color=d,t.r=f,t.style={stroke:d,strokeWidth:1.5,fill:d,fillOpacity:.7}),x.push(t)}return o&&x.push({type:"anomaly-band",threshold:o.threshold??2,showBand:!1!==o.showBand,fill:o.bandColor||"#6366f1",fillOpacity:o.bandOpacity??.1,anomalyColor:o.anomalyColor||"#ef4444",anomalyRadius:o.anomalyRadius??6,label:o.label}),{processedData:m,annotations:x}}(e,0,0,r,o):function(e,t,n,r,o){const{trainEnd:i,steps:s=10,confidence:a=.95,color:l="#6366f1",bandOpacity:c=.15,label:u}=r;if(null==i)return{processedData:e,annotations:[]};const d=[],f=[];for(const n of e)n[t]>i?f.push({...n,[C]:"observed"}):d.push({...n,[C]:"training"});const p=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]),y=[],g=[];if(p.length>=3){const o=p.length;let i=0,d=0,f=0,m=0;for(const[e,t]of p)i+=e,d+=t,f+=e*e,m+=e*t;const x=o*f-i*i;if(Math.abs(x)>1e-12){const f=(o*m-i*d)/x,b=(d-f*i)/o,v=e=>b+f*e,w=p.map(([e,t])=>t-v(e)).reduce((e,t)=>e+t*t,0),k=Math.sqrt(w/Math.max(o-2,1)),S=p.reduce((e,t)=>e+t[0],0)/o,A=p.reduce((e,t)=>e+(t[0]-S)**2,0),M=.99>a?.95>a?.9>a?1:1.645:1.96:2.576,_=h(e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e))),P=p.length>1?(p[o-1][0]-p[0][0])/(o-1):1;for(let e=1;s>=e;e++){const r=_+e*P,i=v(r),s=k*Math.sqrt(1+1/o+(A>0?(r-S)**2/A:0))*M;g.push({[t]:r,[n]:i,[C]:"forecast",__forecastUpper:i+s,__forecastLower:i-s})}L(g,r,e=>e.__forecastUpper,e=>e.__forecastLower),y.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:l,fillOpacity:c,label:u})}}y.push({type:"x-threshold",x:i,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),o&&y.push({type:"anomaly-band",threshold:o.threshold??2,showBand:!1!==o.showBand,fill:o.bandColor||"#6366f1",fillOpacity:o.bandOpacity??.1,anomalyColor:o.anomalyColor||"#ef4444",anomalyRadius:o.anomalyRadius??6,label:o.label});const m=[];if(m.push(...d),d.length>0&&f.length>0&&m.push({...d[d.length-1],[C]:"observed"}),m.push(...f),g.length>0){const e=f.length>0?f[f.length-1]:d[d.length-1];e&&m.push({...e,[C]:"forecast"}),m.push(...g)}return{processedData:m,annotations:y}}(e,t,n,r,o);var i}function O(e,t){const n=t.trainDasharray??"8,4",r=t.forecastDasharray??"4,4",o=t.color||"#6366f1",i=t.trainOpacity,s=t.forecastOpacity,a=t.trainStroke,l=t.trainLinecap,c=t.trainUnderline;return t=>{const u=e(t),h=t[C];if("training"===h){let e=u.stroke;return"darken"===a?e=_(u.stroke||"#666",.5):a&&(e=a),{...u,stroke:e,strokeDasharray:n,...l&&{strokeLinecap:l},...null!=i&&{strokeOpacity:i}}}if("training-base"===h){let e=u.stroke||"#666";return"lighten"===c&&(e=P(e,.4)),{...u,stroke:e,strokeDasharray:void 0}}if("forecast"===h){const e=t[j],n=null!=e?e:s;return{...u,stroke:o,strokeDasharray:r,...null!=n&&{strokeOpacity:n}}}return u}}a(R,{FORECAST_OPACITY_FIELD:()=>j,SEGMENT_FIELD:()=>C,buildAnomalyAnnotations:()=>z,buildForecast:()=>D,createSegmentLineStyle:()=>O,darkenColor:()=>_,lightenColor:()=>P,stampForecastOpacity:()=>L});var I,E=s({"src/components/charts/shared/statisticalOverlays.ts"(){x(),T(),T(),C="__forecastSegment",j="__forecastOpacity"}}),B={};function F(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}a(B,{generateFrameSVGs:()=>Km,generateFrameSequence:()=>Zm,generatePhysicsFrameSVGs:()=>Jm,renderChart:()=>Ym,renderChartWithEvidence:()=>qm,renderDashboard:()=>Hm,renderGeoToStaticSVG:()=>Bm,renderNetworkToStaticSVG:()=>Em,renderOrdinalToStaticSVG:()=>Im,renderPhysicsToAnimatedGif:()=>ox,renderToAnimatedGif:()=>rx,renderToImage:()=>Xm,renderToStaticSVG:()=>Dm,renderXYToStaticSVG:()=>Om,resolveTheme:()=>Cu,themeStyles:()=>ju}),module.exports=(I=B,l(t({},"__esModule",{value:!0}),I));var N=44,W={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:N,snap:"nearestDatum",brushHandleSize:N,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1};function Y(e,t={}){const n=t.mobileSemantics?.interaction,r="number"==typeof n?.targetSize?n.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,o="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,i=!!n||void 0!==r,s=e&&"object"==typeof e?e:void 0;if(!1===e||!1===s?.enabled||void 0===e&&!o&&!i)return W;const a=s??{};return{enabled:!0,tapToSelect:a.tapToSelect??!0,tapToLockTooltip:a.tapToLockTooltip??!0,clearSelection:a.clearSelection??"backgroundTap",targetSize:a.targetSize??r??N,snap:a.snap??"nearestDatum",brushHandleSize:a.brushHandleSize??N,standardControls:a.standardControls??!1}}var q={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 G(e,t,n){const r=q[e||"primary"],o=e&&"primary"!==e||!n?.width?r.width:n.width,i=e&&"primary"!==e||!n?.height?r.height:n.height,s=function(e,t,n=e.responsiveRules){if(!Array.isArray(n)||0===n.length)return{props:e,matches:[]};const r=n.map((e,t)=>({rule:e,index:t})).filter(e=>function(e,t){const{when:n}=e,r=t.width,o=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>r||"number"==typeof n.maxWidth&&r>n.maxWidth||"number"==typeof n.minHeight&&("number"!=typeof o||n.minHeight>o)||"number"==typeof n.maxHeight&&("number"!=typeof o||o>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:r.reduce((e,t)=>function(e,t){const n={...e,...t};for(const r of["margin","frameProps","mobileSemantics","style"])F(e[r])&&F(t[r])&&(n[r]={...e[r],...t[r]});return"string"==typeof e.className&&"string"==typeof t.className&&(n.className=`${e.className} ${t.className}`),n}(e,t.rule.transform),e),matches:r}}({...t,mode:e},{width:t.width??o,height:t.height??i}).props,a=s.mode||e||"primary",l=q[a],c="context"===a||"sparkline"===a,u="primary"===a&&n?.width?n.width:l.width;return{mode:a,width:s.width??u,height:s.height??("primary"===a&&n?.height?n.height:l.height),showAxes:s.showAxes??l.showAxes,showGrid:s.showGrid??l.showGrid,enableHover:s.enableHover??(!!s.linkedHover||l.enableHover),showLegend:s.showLegend??l.showLegend,showLabels:s.showLabels??l.showLabels,title:c?void 0:s.title,description:s.description,summary:s.summary,accessibleTable:s.accessibleTable,xLabel:c?void 0:s.xLabel,yLabel:c?void 0:s.yLabel,categoryLabel:c?void 0:s.categoryLabel,valueLabel:c?void 0:s.valueLabel,marginDefaults:X(l.marginDefaults,s.showCategoryTicks,s.orientation),compactMode:c,mobileInteraction:Y(s.mobileInteraction,{mode:a,width:s.width??u,mobileSemantics:s.mobileSemantics}),mobileSemantics:s.mobileSemantics}}function X(e,t,n){if(!1!==t)return e;const r={...e};return"horizontal"===n?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}var H=c(require("react-dom/server")),V=c(require("react"));function U({data:e,safeData:t,areaBy:n,lineDataAccessor:r}){if(null==e)return[];const o=void 0!==t[0]?.[r];if(!o&&!n)return t;let i;if(o)i=t;else{const e=t.reduce((e,t)=>{const o="function"==typeof n?n(t):t[n],i=o+"";if(!e[i]){const t={[r]:[]};"string"==typeof n&&(t[n]=o),e[i]=t}return e[i][r].push(t),e},{});i=Object.values(e)}return i.flatMap(e=>{const t=Array.isArray(e[r])?e[r]:[];return"string"==typeof n?t.map(t=>({...t,[n]:t[n]??e[n]})):t})}var K=Object.freeze([]);function Z(e){if(!e)return K;let t=!1;for(let n=0;e.length>n;n++){const r=e[n];if(null==r||"object"!=typeof r){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 Q=require("d3-scale");function J(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function ee(e,t,n){const r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function te(e){const t=e.map(J),n=t.length-1;return e=>{if(0>=e){const[e,n,r]=t[0];return ee(e,n,r)}if(e>=1){const[e,r,o]=t[n];return ee(e,r,o)}const r=e*n,o=Math.floor(r),i=r-o,[s,a,l]=t[o],[c,u,h]=t[o+1];return ee(Math.round(s+(c-s)*i),Math.round(a+(u-a)*i),Math.round(l+(h-l)*i))}}var ne=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],re=te(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),oe=te(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),ie=te(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),se=te(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),ae=te(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),le=te(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),ce=te(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),ue=te(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),he=te(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),de=te(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),fe=te(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),pe=te(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),ye={blues:re,reds:oe,greens:ie,viridis:ce,oranges:se,purples:ae,greys:le,plasma:ue,inferno:he,magma:de,cividis:fe,turbo:pe};function ge(e){return e&&ye[e]||re}var me=te(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),xe=te(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),be=te(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),ve=te(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),we=te(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),ke=te(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),Se=te(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),Ae={category10:ne,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...ye},Me=ne,_e="#007bff";function Pe(e,t,n=Me){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=Ae[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:n}var Ce=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],je=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],Te=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 Re(e,t,n){if("function"==typeof t){const r=t(e);return n&&r&&"string"==typeof r&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||Te.has(t)}(r)?n(r):r}const r=e?.[t]+"";return n?n(r):Me[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)}(r))%Me.length]}function Le(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 $e(e,t,n="category10"){if(n&&"object"==typeof n&&!Array.isArray(n)){const e=n;return t=>Le(e,t)??"#999"}const r=Array.from(new Set(e.map(e=>e?.[t]).filter(e=>null!=e).map(e=>e+""))),o=r.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return(0,Q.scaleOrdinal)().domain(r).range(n).unknown("#999");const i=Ae[n]||Ae.category10;if(o&&"function"==typeof i){let e=-1/0;for(const t of r){const n=Number(t);n>e&&(e=n)}return t=>i(Number(t)/e)}{const e=Array.isArray(i)?i:Me;return(0,Q.scaleOrdinal)().domain(r).range(e).unknown("#999")}}function ze(e,t,n=[3,20],r){let o;if(o="function"==typeof t?t(e):e?.[t],!r)return o;const[i,s]=r,[a,l]=n;if(s===i)return(a+l)/2;let c=(o-i)/(s-i);return 0>c?c=0:c>1&&(c=1),a+c*(l-a)}function De(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})}function Oe(e){if(null==e)return()=>{};const t="function"==typeof e?e:t=>t[e];return e=>Be(t(e))}function Ie(e,t){const n=Oe(e),r=Oe(t);return(e,t)=>{const o=r(e);return{value:o,x:n(e),y:o,category:t}}}function Ee(e,t){const n=Oe(t??"value"),r=null==e?void 0:"function"==typeof e?e:t=>t[e];return e=>{const t=r?r(e):void 0;return{value:n(e),category:null==t?void 0:t+""}}}function Be(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 Fe(e,t,n){const r=e.when;return void 0===r||!0===r||!1!==r&&("function"==typeof r?r(t,n):function(e,t,n){const r=null!=e.axis?n[e.axis]:null!=e.field?t[e.field]:n.value;if(void 0!==e.eq&&r!==e.eq)return!1;if(void 0!==e.ne&&r===e.ne)return!1;if(void 0!==e.in&&!e.in.includes(r))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 o=Be(r);if(void 0===o)return!1;if(void 0!==e.gt&&e.gt>=o)return!1;if(void 0!==e.gte&&e.gte>o)return!1;if(void 0!==e.lt&&o>=e.lt)return!1;if(void 0!==e.lte&&o>e.lte)return!1;if(void 0!==e.within){const[t,n]=e.within;if(t>o||o>n)return!1}if(void 0!==e.outside){const[t,n]=e.outside;if(o>=t&&n>=o)return!1}return!0}(r,t,n))}function Ne(e,t,n){if(!t||0===t.length)return{};let r={};for(const o of t){if(!Fe(o,e,n))continue;const t="function"==typeof o.style?o.style(e,n):o.style;t&&(r={...r,...t})}return r}function We(e,t,n,r=e=>e){const o=e??(()=>({}));return t&&0!==t.length?(e,i)=>{const s=r(e),a={...o(e,i)};return Object.assign(a,Ne(s,t,n(s,i))),a}:o}function Ye(e,t,n,r){if(!e||0===e.length)return r;const o=Ee(t,n);return(t,n)=>{const i=t&&t.data||t,s=Ne(i,e,o(i)),a=r?r(t,n):void 0;return a?{...s,...a}:s}}function qe(e,t){return"touch"===t?Math.max(e,24):e}function Ge(e){return Array.isArray(e)?e[0]:e}function Xe(e,t,n,r){return{data:Ge(e),x:t,y:n,__semioticHoverData:!0,...r}}x();var He=["name","label","title"],Ve=["type","kind","category","group","class","status","role","shape"],Ue=["value","amount","total","count","weight","score"],Ke=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 Ze(e,t){for(const n of t){const t=e.find(e=>e.lower===n);if(t)return t}}function Qe(e,t={}){if(!e||"object"!=typeof e)return{entries:[]};const n=t.maxEntries??6,r=!1!==t.skipPositional,o=[];for(const[t,n]of Object.entries(e)){if(t.startsWith("_"))continue;if("data"===t)continue;if(r&&Ke.has(t.toLowerCase()))continue;if(null==n)continue;const e=typeof n;("string"===e||"number"===e||"boolean"===e||n instanceof Date)&&o.push({key:t,lower:t.toLowerCase(),value:n})}if(0===o.length)return{entries:[]};let i=o.findIndex(e=>He.includes(e.lower));const s=i>=0;0>i&&(i=o.findIndex(e=>"id"===e.lower)),0>i&&(i=o.findIndex(e=>"string"==typeof e.value));const a=0>i?void 0:o[i];let l=o.filter((e,t)=>t!==i);s&&(l=l.filter(e=>"id"!==e.lower));const c=Ze(l,Ve),u=Ze(l,Ue),h=new Set(Ve),d=new Set(Ue),f=[];c&&f.push({key:c.key,value:c.value}),u&&f.push({key:u.key,value:u.value});for(const e of l){if(f.length>=n)break;e!==c&&e!==u&&(h.has(e.lower)||d.has(e.lower)||f.push({key:e.key,value:e.value}))}return{titleKey:a?.key,title:a?.value,entries:f}}var Je=require("react/jsx-runtime"),et={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 tt(e,t){return"function"==typeof t?t(e):e[t]}function nt(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 rt(e={}){const{fields:t,title:n,format:r,style:o={},className:i=""}=e;return e=>{if(!e||"object"!=typeof e)return null;let s;const a=[];if(n){const t=tt(e,n);s=nt(t,r)}if(t&&t.length>0)t.forEach(t=>{let n,o,i;"string"==typeof t?(n=t,o=t,i=r):(n=t.label,o=t.accessor||t.key||"",i=t.format||r);const s=tt(e,o);a.push({label:n,value:nt(s,i)})});else if(!n){const t=["value","y","name","id","label"];for(const n of t)if(void 0!==e[n]){s=nt(e[n],r);break}if(!s){const t=Object.keys(e).filter(e=>!e.startsWith("_"));t.length>0&&(s=nt(e[t[0]],r))}}const l={...et,...o};return(0,Je.jsxs)("div",{className:("semiotic-tooltip "+i).trim(),style:l,children:[s&&(0,Je.jsx)("div",{style:{fontWeight:a.length>0?"bold":"normal"},children:s}),a.map((e,t)=>(0,Je.jsxs)("div",{style:{marginTop:0===t&&s?"4px":0},children:[e.label&&(0,Je.jsxs)("span",{children:[e.label,": "]}),e.value]},t))]})}}function ot(e){if(!0!==e){if("function"==typeof e){const t=e;return e=>{let n=Ge(!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 r=t(n);return null==r?null:(0,Je.jsx)("div",{className:"semiotic-tooltip",style:et,children:r})}}return!1!==e&&void 0!==e&&("object"==typeof e&&null!==e&&("fields"in e||"title"in e)?rt(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:r,style:o={},className:i="",showLabels:s=!0,separator:a=": "}=e;return e=>{if(!e||"object"!=typeof e)return null;const l=[];if(n){const t=tt(e,n);l.push({value:nt(t,r)})}if(t&&Array.isArray(t)&&t.length>0)t.forEach(t=>{let n,o,i;"string"==typeof t?(n=t,o=t,i=r):(n=t.label,o=t.accessor||t.key||"",i=t.format||r);const a=nt(tt(e,o),i);l.push({label:s?n:void 0,value:a})});else{const t=Qe(e,{skipPositional:!1});null!=t.title&&l.push({label:void 0,value:nt(t.title,r),bold:!0}),t.entries.forEach(e=>{l.push({label:s?e.key:void 0,value:nt(e.value,r)})})}const c={...et,...o};return Array.isArray(l)&&0!==l.length?(0,Je.jsx)("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+i).trim(),style:c,children:l.map((e,t)=>(0,Je.jsxs)("div",{style:{marginBottom:l.length-1>t?"4px":0,fontWeight:e.bold?"bold":void 0},children:[e.label&&(0,Je.jsxs)("strong",{children:[e.label,a]}),e.value]},t))}):null}}()):rt())}}function it(e){const{title:t,description:n,summary:r,accessibleTable:o,className:i,animate:s,axisExtent:a,autoPlaceAnnotations:l}=e,c={};return t&&(c.title=t),n&&(c.description=n),r&&(c.summary=r),void 0!==o&&(c.accessibleTable=o),i&&(c.className=i),null!=s&&(c.animate=s),void 0!==a&&(c.axisExtent=a),void 0!==l&&(c.autoPlaceAnnotations=l),c}function st(e){const{linkedHover:t,selection:n,onObservation:r,onClick:o,hoverRadius:i,hoverHighlight:s,forceHoverBehavior:a,forceClickBehavior:l,mobileInteraction:c,customHoverBehavior:u,customClickBehavior:h,linkedHoverInClickPredicate:d=!0}=e,f={};r&&(f.annotationObservationCallback=r);const p=c?.enabled?Math.max(i??30,Math.ceil((c.targetSize||44)/2),24):i;return(a||t||r||o||s)&&(f.customHoverBehavior=u),h&&(l||(d?r||o||t:r||o)||c?.enabled&&(c.tapToSelect||c.tapToLockTooltip)&&(t||s||n))&&(f.customClickBehavior=h),null!=p&&(f.hoverRadius=p),f}function at(e){const{tooltip:t,defaultTooltipContent:n}=e;return{tooltipContent:!1===t?()=>null:ot(t)||n}}var lt=require("react"),ct=c(require("react")),ut=require("react"),ht=c(require("react")),dt=require("react/jsx-runtime"),ft=null,pt=null;function yt(e){const[t,n]=ht.useState(()=>ft);return ht.useEffect(()=>{if(t)return;let e=!1;return(ft?Promise.resolve(ft):(pt||(pt=Promise.resolve().then(()=>(M(),v)).then(e=>ft=e.XYBrushOverlay).catch(e=>{throw pt=null,e})),pt)).then(t=>{e||n(()=>t)}),()=>{e=!0}},[t]),t?(0,dt.jsx)(t,{...e}):null}var gt=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=Z(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 r=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,r),bounded:!1}),t=r,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(e){if(e=Z(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 r=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,r),bounded:!1}),t=r,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 r=e[n];null!=r&&"object"==typeof r&&(this.pushBuffer.push(r),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}},mt=require("react"),xt=require("react/jsx-runtime");function bt(e){let t=null;const n=()=>(t||(t=(0,mt.createContext)(null)),t),r=vt(e);return[function({children:t,initialState:r}){const o=(0,mt.useRef)(r),i=(0,mt.useMemo)(()=>vt(e,o.current),[]),s=n();return(0,xt.jsx)(s.Provider,{value:i,children:t})},(e,t)=>{const o=n(),i=(0,mt.useContext)(o)??r,s=(0,mt.useRef)(e);s.current=e;const a=(0,mt.useRef)({hasValue:!1,value:void 0}),l=(0,mt.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]),c=(0,mt.useCallback)(()=>s.current(i.getState()),[i]);return(0,mt.useSyncExternalStore)(i.subscribe,l,c)}]}function vt(e,t){const n=new Set;let r={...e(function(e){const t=e(r);if(function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!0;return!1}(t)){r={...r,...t};for(const e of n)e()}}),...t??{}};return{getState:()=>r,subscribe:function(e){return n.add(e),()=>{n.delete(e)}}}}function wt(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 kt(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:St}}),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 St=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],At={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}},Mt={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}},_t={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:St,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 Pt(e,t){if("light"===t)return At;if("dark"===t)return Mt;if("high-contrast"===t)return _t;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?Mt:At;return kt({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}return kt({...e,...t,colors:{...e.colors,...t.colors||{}},typography:{...e.typography,...t.typography||{}}})}var[Ct,jt]=bt(e=>({theme:At,setTheme(t){e(e=>({theme:Pt(e.theme,t)}))}})),Tt=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,r=[];t.length>e&&(n=t.length-e,r=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 r}update(e,t){const n=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){const i=(r+o)%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(r=>{e(r)?n.push(r):t.push(r)}),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}},Rt=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 Lt(e,t){return e===t}function $t(e,t){if("function"==typeof e)return t=>+e(t);const n=e||t;return e=>+e[n]}function zt(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function Dt(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}var Ot=/^\d{4}-\d{1,2}$/;function It(e){const t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;const n=Ot.test(t)?t+"-01":t;if(n===t&&10>t.length)return NaN;const r=Date.parse(n);return Number.isFinite(r)?r:NaN}function Et(e){return e instanceof Date?e.getTime():"string"==typeof e?It(e):+e}function Bt(e){return new Set(Array.isArray(e)?e:[e])}function Ft(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function Nt(e,t){return Math.min((e-t.startTime)/t.duration,1)}function Wt(e,t,n){return e+(t-e)*n}function Yt(){return"undefined"!=typeof performance?performance.now():Date.now()}function qt(e,t,n){if(1>=n)return 1;const r=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 r=e.halfLife??e.extent/2;return t+Math.pow(.5,n/(r>0?r:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-n/e.extent))*(1-t)}({age:r-t,extent:r,type:e.type,halfLife:e.halfLife??n/2,threshold:e.stepThreshold??.5*n,minOpacity:e.minOpacity??.1})}function Gt(e){const t=new Map;for(let n=0;e.length>n;n++)t.set(e[n],n);return t}function Xt(e,t,n){const r=e.duration??500,o=n-t;return r>o?1-o/r:0}function Ht(e,t,n,r){let o=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,o=!0),e._pulseColor!==n&&(e._pulseColor=n,o=!0),e._pulseGlowRadius!==r&&(e._pulseGlowRadius=r,o=!0),o):(0!==e._pulseIntensity&&(e._pulseIntensity=0,o=!0),void 0!==e._pulseColor&&(e._pulseColor=void 0,o=!0),void 0!==e._pulseGlowRadius&&(e._pulseGlowRadius=void 0,o=!0),o)}function Vt(e,t,n=("undefined"!=typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;const r=e.duration??500,o=t.peek();return null!=o&&r>n-o}function Ut(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),r=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${r}`;if(null!=n&&null!=r)return`p:${n}:${r}`}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 Kt(e,t,n,r,o,i){const s=[];for(const o of e){const e=n(o),i=r(o);Number.isFinite(e)&&Number.isFinite(i)&&s.push({px:t.x(e),py:t.y(i),rawY:i,d:o})}s.sort((e,t)=>e.px-t.px);const a=Array(s.length),l=Array(s.length),c=Array(s.length);for(let e=0;s.length>e;e++){const t=s[e];a[e]=[t.px,t.py],l[e]=t.rawY,c[e]=t.d}return{type:"line",path:a,rawValues:l,style:o,datum:c,group:i}}function Zt(e,t,n,r,o,i,s,a){const l=[];for(const i of e){const e=n(i),s=r(i);if(!Number.isFinite(e)||!Number.isFinite(s))continue;const c=t.x(e),u=a?a(i):o;l.push({px:c,topY:t.y(s),botY:t.y(u)})}l.sort((e,t)=>e.px-t.px);const c=Array(l.length),u=Array(l.length);for(let e=0;l.length>e;e++){const t=l[e];c[e]=[t.px,t.topY],u[e]=[t.px,t.botY]}return{type:"area",topPath:c,bottomPath:u,style:i,datum:e,group:s}}function Qt(e,t,n,r){const o=new Map;if("silhouette"===r)for(const r of e){let e=0;for(const o of t)e+=n(o,r)||0;o.set(r,-e/2)}else if("wiggle"===r){e.length>0&&o.set(e[0],0);for(let r=1;e.length>r;r++){const i=e[r-1],s=e[r];let a=0,l=0,c=0;for(const e of t){const t=n(e,s)||0;a+=(2*c+t)*(t-(n(e,i)||0)),l+=t,c+=t}const u=o.get(i)??0;o.set(s,u-(l>0?a/(2*l):0))}if(e.length>0){let r=0;for(const i of e){let e=0;for(const r of t)e+=n(r,i)||0;r+=(o.get(i)??0)+e/2}const i=r/e.length;for(const t of e)o.set(t,(o.get(t)??0)-i)}}else for(const t of e)o.set(t,0);return o}function Jt(e,t,n,r,o,i,s){const a=n(e),l=r(e);if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c={type:"point",x:t.x(a),y:t.y(l),r:o,style:i,datum:e};return void 0!==s&&(c.pointId=s),c}function en(e,t,n,r,o,i,s,a){const l=n(e),c=r(e);if(!Number.isFinite(l)||!Number.isFinite(c))return null;const u={type:"symbol",x:t.x(l),y:t.y(c),size:o,symbolType:i,style:s,datum:e};return void 0!==a&&(u.pointId=a),u}function tn(e,t,n,r,o,i,s){return{type:"rect",x:e,y:t,w:n,h:r,style:o,datum:i,group:s}}function nn(e,t,n,r,o,i,s){const a={type:"heatcell",x:e,y:t,w:n,h:r,fill:o,datum:i};return s?.showValues&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function rn(e,t,n,r){return"function"==typeof t.style?t.style(r||{},n):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(n,r)}function on(e,t,n,r){if(!e.scales)return null;const o=[],i=[];for(const n of t){const t=e.getX(n);if(!Number.isFinite(t))continue;const s=r.getTop(n),a=r.getBottom(n);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const l=e.scales.x(t),c=e.scales.y(s),u=e.scales.y(a);Number.isFinite(l)&&Number.isFinite(c)&&Number.isFinite(u)&&(o.push([l,c]),i.push([l,u]))}return 2>o.length?null:{type:"area",topPath:o,bottomPath:i,...e.config.curve&&"linear"!==e.config.curve&&{curve:e.config.curve},style:rn(e,r,n,t[0]),datum:t,group:n,interactive:r.interactive}}function sn(e){const t=[],n=[];if(!e)return{perSeries:t,aggregate:n};for(const r of e)r.perSeries?t.push(r):n.push(r);return{perSeries:t,aggregate:n}}function an(e,t,n){const r=[];for(const o of n){const n=on(e,t,"__ribbon_aggregate",o);n&&r.push(n)}return r}function ln(e,t,n,r){const o=[];for(const i of r){const r=on(e,t,n,i);r&&o.push(r)}return o}function cn(e,t){if(!e)return{};if(!t||0===t.length)return e;const n=[];for(const r of t){if("band"!==r.kind)continue;const t=r.getTop(e),o=r.getBottom(e);Number.isFinite(o)&&Number.isFinite(t)&&n.push({y0:o,y1:t})}return 0===n.length?e:{...e,band:n[0],bands:n}}function un(e,t,n,r){if(!e.config.pointStyle)return;const o=r??e.getY;for(const r of t){const t=e.resolveGroupColor(r.key);for(const i of r.data){let r=e.config.pointStyle(i);!r.fill&&t&&(r={...r,fill:t});const s=r.r??3,a=e.getPointId?e.getPointId(i)+"":void 0,l=Jt(i,e.scales,e.getX,o,s,r,a);l&&n.push(l)}}}function hn(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}var dn={topOpacity:.8,bottomOpacity:.05};function fn(e){if(e)return!0===e?dn:"colorStops"in e?e:{topOpacity:e.topOpacity??dn.topOpacity,bottomOpacity:e.bottomOpacity??dn.bottomOpacity}}var pn=require("d3-shape"),yn={circle:pn.symbolCircle,square:pn.symbolSquare,triangle:pn.symbolTriangle,diamond:pn.symbolDiamond,star:pn.symbolStar,cross:pn.symbolCross,wye:pn.symbolWye},gn=["circle","triangle","diamond","star","square","chevron","cross","wye"];function mn(e,t,n){if(n)return n;const r=e??"circle";return"chevron"===r?function(e){const t=1.5*xn(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,pn.symbol)(yn[r]??pn.symbolCircle,Math.max(1,t))()??""}function xn(e){return Math.sqrt(Math.max(1,e)/Math.PI)}var bn=new Map;function vn(e,t,n){const r=n.config.areaStyle?.(t);return r&&(e.style=r),e}function wn(e,t,n,r,o){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 l=Math.floor(e/r)*r;let c=i.get(l);if(c||(c={start:l,end:l+r,total:0,categories:new Map},i.set(l,c)),c.total+=a,o){const e=o(s);c.categories.set(e,(c.categories.get(e)||0)+a)}}return i}function kn(e){if("production"===process.env.NODE_ENV)return;const{label:t,nodes:n,overlays:r,warned:o}=e;Sn(r)&&0===n.length&&An(o,"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)&&An(o,"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 Sn(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(Sn))}function An(e,t,n){e.has(t)||(e.add(t),console.warn(n))}function Mn(e,t,n,r){const o=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: ${o.message}`,error:o,recovery:n?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:n,affectedRevision:r}}function _n(e,t){const n="function"==typeof e?e:n=>n[e||t];return e=>{const t=n(e);return null==t?NaN:+t}}function Pn(e){const t=[],n=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,r=_n(n&&e.valueAccessor||e.yAccessor,n?"value":"y");if(e.boundsAccessor){const n=$t(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{const t=r(e);if(!Number.isFinite(t))return NaN;const o=n(e);return Number.isFinite(o)&&0!==o?t+o:t},getBottom:e=>{const t=r(e);if(!Number.isFinite(t))return NaN;const o=n(e);return Number.isFinite(o)&&0!==o?t-o: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:_n(e.y1Accessor,"y1"),getBottom:_n(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}var Cn=require("d3-scale");function jn(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function Tn(e,t,n){if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return(0,Cn.scaleLog)().domain(e).range(n).clamp(!0)}return"symlog"===e?(0,Cn.scaleSymlog)().domain(t).range(n):"time"===e?(0,Cn.scaleTime)().domain([new Date(t[0]),new Date(t[1])]).range(n):(0,Cn.scaleLinear)().domain(t).range(n)}function Rn(e,t,n){t>e.capacity&&(e.resize(t),n&&t>n.capacity&&n.resize(t))}function Ln(e,t){const n=new Tt(e.capacity);return e.forEach(()=>n.push(t)),n}function $n(e,t,n,r){const o=e.push(t);return n&&n.push(r),o}function zn(e,t,n){if(!t||0===t.size)return;const r=new Set;if(e.forEach((e,t)=>{n(e)&&r.add(t)}),0===r.size)return;const o=t.toArray();t.clear();for(let e=0;o.length>e;e++)r.has(e)||t.push(o[e])}var Dn=new WeakMap;function On(){return this.updateResults.last}function In(){return this.updateResults.last}function En(e){return this.updateResults.subscribe(e)}function Bn(e){this.config.layoutSelection=e}function Fn(){Dn.set(this,!0)}function Nn(){const e=!0===Dn.get(this);return Dn.delete(this),e}function Wn(e){Object.assign(e.prototype,{getLastUpdateResult:On,getUpdateSnapshot:In,subscribeUpdateResult:En,setLayoutSelection:Bn,markStylePaintPending:Fn,consumeStylePaintPending:Nn})}var Yn={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 qn(e,t){const n={...e};for(const e of t)n[Yn[e]]++;return n}function Gn(e,t,n){const r=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:r,revisions:qn(n,r)}}var Xn=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=Gn({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=Gn(e,t,this.revisions);this.revisions=n.revisions,this.latest=n;for(const e of[...this.listeners])e();return n}},Hn=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Vn=["scene-style","data-paint","accessibility","evidence"],Un=(e,t)=>({retainedData:e,invalidations:t}),Kn=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Zn=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Qn=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Jn=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],er=["scene-geometry","data-paint","accessibility","evidence"],tr=["scene-style","data-paint","accessibility","evidence"],nr=[],rr={chartType:Un("rebuild",Kn),runtimeMode:Un("rebuild",Kn),xAccessor:Un("rebuild",Kn),yAccessor:Un("rebuild",Kn),timeAccessor:Un("rebuild",Kn),valueAccessor:Un("rebuild",Kn),y0Accessor:Un("rebuild",Kn),boundsAccessor:Un("rebuild",Kn),band:Un("rebuild",Kn),openAccessor:Un("rebuild",Kn),highAccessor:Un("rebuild",Kn),lowAccessor:Un("rebuild",Kn),closeAccessor:Un("rebuild",Kn),candlestickRangeMode:Un("rebuild",Kn),accessorRevision:Un("rebuild",Kn),groupAccessor:Un("rebuild",Zn),categoryAccessor:Un("rebuild",Zn),lineDataAccessor:Un("rebuild",Zn),colorAccessor:Un("rebuild",tr),sizeAccessor:Un("rebuild",er),symbolAccessor:Un("rebuild",er),pointIdAccessor:Un("rebuild",er),xScaleType:Un("preserve",Qn),yScaleType:Un("preserve",Qn),xExtent:Un("preserve",Qn),yExtent:Un("preserve",Qn),extentPadding:Un("preserve",Qn),scalePadding:Un("preserve",Qn),axisExtent:Un("preserve",Qn),binSize:Un("preserve",Qn),normalize:Un("preserve",Qn),heatmapAggregation:Un("preserve",Qn),heatmapXBins:Un("preserve",Qn),heatmapYBins:Un("preserve",Qn),arrowOfTime:Un("preserve",Jn),baseline:Un("preserve",Jn),stackOrder:Un("preserve",Jn),sizeRange:Un("preserve",Jn),curve:Un("preserve",Jn),areaGroups:Un("preserve",Jn),customLayout:Un("preserve",Jn),layoutConfig:Un("preserve",Jn),layoutMargin:Un("preserve",Jn),symbolMap:Un("preserve",er),showValues:Un("preserve",er),heatmapValueFormat:Un("preserve",er),lineStyle:Un("preserve",tr),pointStyle:Un("preserve",tr),areaStyle:Un("preserve",tr),barStyle:Un("preserve",tr),swarmStyle:Un("preserve",tr),waterfallStyle:Un("preserve",tr),candlestickStyle:Un("preserve",tr),boundsStyle:Un("preserve",tr),gradientFill:Un("preserve",tr),lineGradient:Un("preserve",tr),colorScheme:Un("preserve",tr),themeCategorical:Un("preserve",tr),themeSemantic:Un("preserve",tr),themeSequential:Un("preserve",tr),themeDiverging:Un("preserve",tr),barColors:Un("preserve",tr),decay:Un("preserve",tr),pulse:Un("preserve",tr),staleness:Un("preserve",tr),layoutSelection:Un("preserve",tr),annotations:Un("preserve",["overlay","accessibility","evidence"]),windowSize:Un("preserve",nr),windowMode:Un("preserve",nr),maxCapacity:Un("preserve",nr),clock:Un("preserve",nr),transition:Un("preserve",nr),introAnimation:Un("preserve",nr),onLayoutError:Un("preserve",nr)},or=Un("preserve",Jn),ir=class{constructor(){this.tracker=new Xn}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}},Hn)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Vn):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const r of e){const e=rr[r]??or;"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)}},sr=require("d3-quadtree"),ar=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,r=0;for(const e of t)"point"===e.type&&(n++,e.r>r&&(r=e.r));if(this.maxRadius=r,500>=n)return void(this.tree=null);const o=Array(n);let i=0;for(const e of t)"point"===e.type&&(o[i++]=e);this.tree=(0,sr.quadtree)().x(e=>e.x).y(e=>e.y).addAll(o)}},lr=class e{constructor(e){if(this.xExtent=new Rt,this.yExtent=new Rt,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 ir,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 ar,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,n)=>!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,r,o,i=("undefined"!=typeof performance?performance.now():Date.now())){const s=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let l=!1;const c=o??(()=>{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 o=0,a=!1;for(const n of t){const t=c.get(n);if(null==t)continue;a=!0;const s=r.get(t);if(null==s)continue;const l=Xt(e,s,i);l>o&&(o=l)}a&&(l=Ht(n,o,s)||l);continue}const t=c.get(n.datum);if(null==t)continue;const o=r.get(t);l=Ht(n,null==o?0:Xt(e,o,i),s,a)||l}return l}(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),n),this.config=e,this.buffer=new Tt(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=$t(e.timeAccessor||e.xAccessor,"time"),this.getY=$t(e.valueAccessor||e.yAccessor,"value")):(this.getX=$t(e.xAccessor,"x"),this.getY=$t(e.yAccessor,"y")),this.getGroup=Dt(e.groupAccessor),this.getCategory=Dt(e.categoryAccessor),this.getSize=e.sizeAccessor?$t(e.sizeAccessor,"size"):void 0,this.getColor=Dt(e.colorAccessor),this.getSymbol=Dt(e.symbolAccessor),this.getY0=e.y0Accessor?$t(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=Pn(e),this.getPointId=Dt(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=null!=e.closeAccessor;this.getOpen=t?$t(e.openAccessor,"open"):void 0,this.getHigh=$t(e.highAccessor,"high"),this.getLow=$t(e.lowAccessor,"low"),this.getClose=n?$t(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new Tt(e.windowSize))}currentTime(){return this.config.clock?.()??Yt()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=Ln(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),r=t.getBottom(e);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(r)&&this.yExtent.push(r)}}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),r=t.getBottom(e);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(r)&&this.yExtent.evict(r)}}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?$t(this.config.timeAccessor||this.config.xAccessor,"time"):$t(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],n=this.config.xAccessor,r="function"==typeof n?n(t):t[n||"x"],o=r instanceof Date,i="string"==typeof r&&Number.isFinite(It(r));if(this.xIsDate=o||i,i){const e="string"==typeof n?n:void 0;this.getX=e?t=>Et(t[e]):e=>Et(n(e))}}Rn(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,r=this.scales,o=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=jn(this.xExtent.extent,t.xExtent),l=jn(s,t.yExtent);const c=!(!(u=t.yExtent)||null==u[0]||null==u[1]);var u;const h="exact"===t.axisExtent;if("stackedarea"===t.chartType&&!c&&n.size>0){const e=function(e){const{config:t,groups:n,getX:r,getY:o}=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,l=new Set;let c=0;const u=new Map,h=new Map;for(const e of n){const t=new Map;let n=0;for(const i of e.data){const e=r(i),s=o(i);if(!Number.isFinite(e)||!Number.isFinite(s))continue;t.set(e,(t.get(e)||0)+s),l.add(e),n+=s;const a=(u.get(e)||0)+s;u.set(e,a),a>c&&(c=a)}a.set(e.key,t),h.set(e.key,n)}const d=t.stackOrder??"key",f=(e,t)=>t>e?-1:e>t?1:0;let p,y;if("input"===d)p=n.map(e=>e.key);else if("insideOut"===d){const e=[...n].map(e=>e.key).sort((e,t)=>{const n=(h.get(t)??0)-(h.get(e)??0);return 0!==n?n:f(e,t)}),t=[],r=[];let o=0,i=0;for(const n of e)i>o?(t.push(n),o+=h.get(n)??0):(r.push(n),i+=h.get(n)??0);p=[...r.reverse(),...t]}else p="asc"===d?n.map(e=>e.key).sort((e,t)=>{const n=(h.get(e)??0)-(h.get(t)??0);return 0!==n?n:f(e,t)}):"desc"===d?n.map(e=>e.key).sort((e,t)=>{const n=(h.get(t)??0)-(h.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(l).sort((e,t)=>e-t),n=Qt(e,p,(e,t)=>a.get(e)?.get(t)||0,t.baseline);let r=1/0,o=-1/0;for(const t of e){const e=n.get(t)??0,i=u.get(t)??0;r>e&&(r=e),e+i>o&&(o=e+i)}Number.isFinite(r)&&Number.isFinite(o)||(r=0,o=0);const s=o-r,c=i?0:s>0?s*t.extentPadding:1;y=[r-c,o+c]}else if("diverging"===t.baseline){const e=Array.from(l).sort((e,t)=>e-t),[n,r]=function(e,t,n){let r=0,o=0;for(const i of e){let e=0,s=0;for(const r of t){const t=n(r,i)||0;0>t?s+=t:e+=t}r>s&&(r=s),e>o&&(o=e)}return[r,o]}(e,p,(e,t)=>a.get(e)?.get(t)||0),o=r-n,s=i?0:o>0?o*t.extentPadding:1;y=[n-s,r+s]}else y=[0,c+(i?0:c>0?c*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});l=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!c&&n.size>0?l=function(e,t,n,r,o,i,s){const[,a]=function(e,t,n,r,o){const i=wn(e,t,n,r,o);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,r,o);return[0,s?a:a+a*i]}(n,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,h):"waterfall"===t.chartType&&!c&&n.size>0?l=function(e,t,n,r){const[o,i]=function(e,t){let n=0,r=0,o=0;for(const i of e){const e=t(i);null==e||Number.isNaN(e)||(o+=e,n>o&&(n=o),o>r&&(r=o))}return[n,r]}(e,t),s=i-o,a=r?0:s>0?s*n:1;return[Math.min(0,o-Math.abs(a)),Math.max(0,i+Math.abs(a))]}(n,this.getY,t.extentPadding,h):c||l[0]===1/0||(l=function(e,t,n){if(!n.length)return e;let[r,o]=e;for(const e of t)for(const t of n){const n=t.getTop(e),i=t.getBottom(e);Number.isFinite(n)&&(r>n&&(r=n),n>o&&(o=n)),Number.isFinite(i)&&(r>i&&(r=i),i>o&&(o=i))}return[r,o]}(l,i,this.resolvedRibbons),l=function(e,t){const n=e[1]-e[0],r=t.exactMode?0:n>0?n*t.extentPadding:1,o=[null!=t.userMin?e[0]:e[0]-r,null!=t.userMax?e[1]:e[1]+r];return"log"!==t.yScaleType||o[0]>0||0>=t.dataYDomain[0]||t.exactMode||null==t.userMin&&(o[0]=t.dataYDomain[0]/(1+t.extentPadding)),o}(l,{exactMode:h,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:s}));l=function(e,t,n){if(!t||n)return e;const r=t[0],o=t[1];return null==r&&null==o?e:[null!=r?r:e[0],null!=o?o:e[1]]}(l,t.yExtent,!!c),({xDomain:a,yDomain:l}=function(e,t,n){let r=e,o=t;if(r[0]===1/0||r[1]===-1/0)if("time"===n){const e=Date.now();r=[e-864e5,e]}else r=[0,1];return o[0]!==1/0&&o[1]!==-1/0||(o=[0,1]),{xDomain:r,yDomain:o}}(a,l,t.xScaleType)),this.scales=function(e){const{config:t,layout:n,xDomain:r,yDomain:o}=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,Cn.scaleLinear)().domain(r).range(e),y:Tn(t.yScaleType,o,[n.height-s,s])}}const e="down"===t.arrowOfTime?[s,n.height-s]:[n.height-s,s];return{x:Tn(t.yScaleType,o,[s,n.width-s]),y:(0,Cn.scaleLinear)().domain(r).range(e)}}var a;return{x:Tn(t.xScaleType,r,[s,n.width-s]),y:Tn(t.yScaleType,o,[n.height-s,s])}}({config:t,layout:e,xDomain:a,yDomain:l}),this._customLayoutFailedThisBuild=!1;const d=this.buildSceneNodes(e,i);if(this._customLayoutFailedThisBuild)return!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.lastLayout=o):(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=d,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 r of e.path)r[0]*=t,r[1]*=n;break;case"area":for(const r of e.topPath)r[0]*=t,r[1]*=n;for(const r of e.bottomPath)r[0]*=t,r[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});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 r=this.scales.x.domain(),o=this.scales.y.domain(),i=this.scales.x.range(),s=this.scales.y.range(),a=Tn,l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),c=s[1]>s[0];this.scales={x:a(this.config.xScaleType,r,i[0]>i[1]?[e.width-l,l]:[l,e.width-l]),y:a(this.config.yScaleType,o,c?[l,e.height-l]:[e.height-l,l])},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:r}=this;if(!r)return[];if(n.customLayout){const o={data:t,scales:r,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??Ce},resolveColor:(e,t)=>{const r=this.resolveGroupColor(e);if(r)return r;const o=this.resolveLineStyle(e,t);return o.stroke?o.stroke:"string"==typeof o.fill?o.fill:n.themeSemantic?.primary??"#4e79a7"},config:n.layoutConfig??{},selection:n.layoutSelection??null};let i;try{i=n.customLayout(o)}catch(e){const t=null!==this.lastCustomLayoutResult,r=Mn("xy",e,t,this.version);this.lastCustomLayoutFailure=r,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",e);try{n.onLayoutError?.(r)}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 kn({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 o={scales:r,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),r=[],o=e.config.annotations?.filter(hn).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:i}=sn(e.ribbons);if(i.length>0&&r.push(...an(e,t,i)),o.length>0)for(const t of n)r.push(...ln(e,t.data,t.key,o))}for(const t of n){const n=e.resolveLineStyle(t.key,t.data[0]),i=Kt(t.data,e.scales,e.getX,e.getY,n,t.key);o&&o.length>0&&(i.colorThresholds=o),e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),r.push(i)}return un(e,n,r),r}(o,t);case"area":return function(e,t){const n=e.groupData(t),r=[];if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:i}=sn(e.ribbons);if(i.length>0&&r.push(...an(e,t,i)),o.length>0)for(const t of n)r.push(...ln(e,t.data,t.key,o))}const o=e.scales.y.domain()[0],i=e.getY0?t=>{const n=e.getY0(t);return null==n?o:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),s=Zt(t.data,e.scales,e.getX,e.getY,o,n,t.key,i),a=fn(e.config.gradientFill);a&&(s.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(s.curve=e.config.curve),e.config.lineGradient&&(s.strokeGradient=e.config.lineGradient),r.push(s)}return un(e,n,r),r}(o,t);case"mixed":return function(e,t){const n=e.groupData(t),r=[],o=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:i}=sn(e.ribbons);if(i.length>0&&r.push(...an(e,t,i)),o.length>0)for(const t of n)r.push(...ln(e,t.data,t.key,o))}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(o.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),o=Zt(t.data,e.scales,e.getX,e.getY,i,n,t.key,s),a=fn(e.config.gradientFill);a&&(o.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}else{const n=e.resolveLineStyle(t.key,t.data[0]),o=Kt(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}return un(e,n,r),r}(o,t);case"stackedarea":return function(e,t){const n=e.groupData(t),r=e.config.stackOrder??"key",o=()=>n.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"===r);else if("key"===r)o();else if("asc"===r||"desc"===r||"insideOut"===r){const t=new Map;for(const r of n){let n=0;for(const t of r.data){const r=e.getX(t),o=e.getY(t);Number.isFinite(r)&&Number.isFinite(o)&&(n+=o)}t.set(r.key,n)}const o=(e,t)=>t>e?-1:e>t?1:0;if("asc"===r)n.sort((e,n)=>{const r=(t.get(e.key)??0)-(t.get(n.key)??0);return 0!==r?r:o(e.key,n.key)});else if("desc"===r)n.sort((e,n)=>{const r=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,n.key)});else{const e=[...n].sort((e,n)=>{const r=(t.get(n.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,n.key)}),r=[],i=[];let s=0,a=0;for(const n of e)a>s?(r.push(n),s+=t.get(n.key)??0):(i.push(n),a+=t.get(n.key)??0);n.length=0,n.push(...i.reverse(),...r)}}else o();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:l}=function(e,t,n,r,o,i,s,a="zero"){const l=new Set;for(const t of e)for(const e of t.data){const t=n(e);Number.isFinite(t)&&l.add(t)}const c=Array.from(l).sort((e,t)=>e-t),u=new Map;for(const t of e){const e=new Map;for(const o of t.data){const t=n(o),i=r(o);Number.isFinite(t)&&Number.isFinite(i)&&e.set(t,(e.get(t)||0)+i)}u.set(t.key,e)}let h;if(i){h=new Map;for(const t of c){let n=0;for(const r of e)n+=u.get(r.key)?.get(t)||0;h.set(t,n||1)}}const d=Qt(c,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 c)g.set(e,d.get(e)??0),m.set(e,0),x.set(e,0);for(const n of e){const e=u.get(n.key),r=new Map;let a=[],l=[];const d=()=>{if(a.length>=2){const e={type:"area",topPath:a,bottomPath:l,style:o(n.key,n.data[0]),datum:n.data,group:n.key};s&&(e.curve=s),p.push(e)}a=[],l=[]};for(const n of c){const o=e.has(n);let s,c,u=o?e.get(n):0;if(i&&o&&(u/=h.get(n)),!o||!Number.isFinite(u)||0===u){d();continue}f?u>0?(s=m.get(n),c=s+u,m.set(n,c)):(s=x.get(n),c=s+u,x.set(n,c)):(s=g.get(n),c=s+u,g.set(n,c));const p=t.x(n);l.push([p,t.y(s)]),a.push([p,t.y(c)]),r.set(n,c)}d(),y.set(n.key,r)}return{nodes:p,stackedTops:y}}(n,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,i,s),c=a;if(e.config.pointStyle){const t=new WeakMap;for(const r of n){const n=l.get(r.key);if(n)for(const o of r.data){const r=e.getX(o),i=e.getY(o);null==r||Number.isNaN(r)||null==i||Number.isNaN(i)||!n.has(r)||t.set(o,n.get(r))}}const r=n=>t.get(n)??e.getY(n);un(e,n,c,r)}return c}(o,t);case"scatter":case"bubble":return function(e,t){const n=[],r="bubble"===e.config.chartType?10:5,o=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 r of n)e>r&&(e=r),r>t&&(t=r);i=n=>e===t?(o[0]+o[1])/2:o[0]+(n-e)/(t-e)*(o[1]-o[0])}}const s=e.getColor?e.resolveColorMap(t):null,a=e.config.themeSemantic?.primary||"#4e79a7",l=e.getSymbol,c=e.config.symbolMap,u=new Map;let h=0;const d=e=>{const t=c?.[e];if(t)return t;let n=u.get(e);return n||(n=gn[h%gn.length],h++,u.set(e,n)),n};for(const o of t){let t=e.config.pointStyle?e.config.pointStyle(o):{fill:a,opacity:.8},c=t.r||r;if(i&&e.getSize){const t=e.getSize(o);null==t||Number.isNaN(t)||(c=i(t))}if(s&&e.getColor&&!t.fill){const n=e.getColor(o);n&&s.has(n)&&(t={...t,fill:s.get(n)})}const u=e.getPointId?e.getPointId(o)+"":void 0;if(l){const r=d(l(o)+""),i=en(o,e.scales,e.getX,e.getY,Math.PI*c*c,r,t,u);i&&n.push(i)}else{const r=Jt(o,e.scales,e.getX,e.getY,c,t,u);r&&n.push(r)}}return n}(o,t);case"heatmap":return function(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){const r=Math.max(1,Math.floor(e.config.heatmapXBins??20)),o=Math.max(1,Math.floor(e.config.heatmapYBins??20)),i=e.config.heatmapAggregation??"count",s=$t(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[a,l]=e.scales.x.domain(),[c,u]=e.scales.y.domain(),h=(l-a||1)/r,d=(u-c||1)/o,f=r*o;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],l=e.getX(i),u=e.getY(i);if(!isFinite(l)||!isFinite(u))continue;const f=Math.min(Math.floor((l-a)/h),r-1),g=Math.min(Math.floor((u-c)/d),o-1);if(0>f||0>g)continue;const m=g*r+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/r,v=n.height/o,w=e.config.showValues,k=e.config.heatmapValueFormat,S=[];for(let t=0;o>t;t++){const n=t*r;for(let s=0;r>s;s++){const r=n+s;if(0===p[r])continue;let l;switch(i){case"sum":l=y[r];break;case"mean":l=y[r]/p[r];break;default:l=p[r]}const u=(l-g)/x,f={xi:s,yi:t,value:l,count:p[r],sum:y[r],xCenter:a+(s+.5)*h,yCenter:c+(t+.5)*d,agg:i};S.push(vn(nn(s*b,(o-1-t)*v,b,v,`rgb(${220-(180*u+.5)|0},${220-(100*u+.5)|0},${255-(50*u+.5)|0})`,f,w?{value:l,showValues:!0,valueFormat:k}:void 0),f,e))}}return S}(e,t,n);if(0===t.length)return[];const r=$t(e.config.valueAccessor,"value"),o=zt(e.config.xAccessor,"x"),i=zt(e.config.yAccessor,"y"),s=new Map,a=new Map,l=Array(t.length),c=Array(t.length);for(let e=0;t.length>e;e++){const n=t[e],r=o(n),u=i(n);l[e]=r,c[e]=u,s.has(r)||s.set(r,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,h=a.size;if(0===u||0===h)return[];const d=Array.from(s.keys()),f=Array.from(a.keys()),p=d.every(e=>"number"==typeof e&&!isNaN(e)),y=f.every(e=>"number"==typeof e&&!isNaN(e));if(p){d.sort((e,t)=>Number(e)-Number(t)),s.clear();for(let e=0;d.length>e;e++)s.set(d[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],o=s.get(l[e]),i=a.get(c[e]);if(void 0===o||void 0===i)continue;const h=r(n),d=i*u+o,f=b.get(d);let p;void 0!==f?p=f:(p=v++,b.set(d,p)),g[p]=d,m[p]=h,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 ye?e:"blues";let n=bn.get(t);if(n)return n;n=Array(256);const r=ge(t);for(let e=0;256>e;e++)n[e]=r(e/255);return bn.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/h,P=e.config.showValues,C=e.config.heatmapValueFormat,j=[];for(let t=0;v>t;t++){const n=m[t];if(!isFinite(n))continue;const r=g[t],o=r%u,i=x[t];j.push(vn(nn(o*M,(h-1-(r-o)/u)*_,M,_,S[Math.min((n-w)*A+.5|0,255)],i,P?{value:n,showValues:!0,valueFormat:C}:void 0),i,e))}return j}(o,t,e);case"bar":{const e=function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const n=wn(t,e.getX,e.getY,e.config.binSize,e.getCategory);if(0===n.size)return{nodes:[],binBoundaries:[]};let r=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 o=e.config.barColors?Object.keys(e.config.barColors):[],i=new Set(o),s=Array.from(t).filter(e=>!i.has(e)).sort(),a=o.filter(e=>t.has(e)),l=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===l?r=e.barCategoryCache.order:(r=[...a,...s],e.barCategoryCache={key:l,order:r})}const o=[],i=e.scales,[s,a]=i.x.domain(),l=e.config.barStyle,c=e.config.themeSemantic?.primary,u=l?.gap,h="number"!=typeof u||0>u?1:u,d={};l?.stroke&&(d.stroke=l.stroke),"number"==typeof l?.strokeWidth&&(d.strokeWidth=l.strokeWidth),"number"==typeof l?.opacity&&(d.opacity=l.opacity);for(const 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>h+1?h:0,m=Math.min(f,p)+g/2,x=Math.max(y-g,1);if(x>0)if(r&&t.categories.size>0){let n=0;for(const s of r){const r=t.categories.get(s)||0;if(0===r)continue;const a=i.y(n),u=i.y(n+r);o.push(tn(m,Math.min(a,u),x,Math.abs(a-u),{fill:e.config.barColors?.[s]||l?.fill||c||"#4e79a7",...d},{binStart:t.start,binEnd:t.end,total:t.total,category:s,categoryValue:r},s)),n+=r}}else{const e=i.y(0),n=i.y(t.total);o.push(tn(m,Math.min(e,n),x,Math.abs(e-n),{fill:l?.fill||c||"#007bff",...d},{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:o,binBoundaries:Array.from(f).sort((e,t)=>e-t)}}(o,t);return this._barCategoryCache=o.barCategoryCache??null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){const n=[],r=e.config.swarmStyle||{},o=r.radius??3,i=r.fill??e.config.themeSemantic?.primary??"#007bff",s=r.opacity??.7,a=r.stroke,l=r.strokeWidth;for(const r of t){const t=e.getX(r),c=e.getY(r);if(null==c||Number.isNaN(c))continue;const u=e.scales.x(t),h=e.scales.y(c);let d=i;if(e.getCategory){const t=e.getCategory(r);d=e.config.barColors?.[t]||d}const{r:f,...p}=e.config.pointStyle?.(r)??{},y={type:"point",x:u,y:h,r:f??o,style:{fill:d,opacity:s,stroke:a,strokeWidth:l,...p},datum:r};e.getPointId&&(y.pointId=e.getPointId(r)+""),n.push(y)}return n}(o,t);case"waterfall":return function(e,t,n){const r=[],o=e.scales,i=e.config.waterfallStyle,s=t.filter(t=>{const n=e.getY(t),r=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=r&&isFinite(r)});if(0===s.length)return r;const a=i?.positiveColor??e.config.themeSemantic?.success??"#28a745",l=i?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",c=i?.gap??1,u=i?.stroke,h=i?.strokeWidth,d=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=o.x(y),v=0!==x?o.x(y+x):b+n.width/10,w=Math.min(b,v)+c/2,k=Math.max(b,v)-c/2-w;if(0>=k){f=m;continue}const S=o.y(f),A=o.y(m),M=Math.min(S,A),_=Math.abs(S-A),P={fill:0>g?l:a,stroke:u,strokeWidth:h};null!=d&&(P.opacity=d),r.push(tn(w,M,k,_,P,{...p,baseline:f,cumEnd:m,delta:g,_connectorStroke:i?.connectorStroke,_connectorWidth:i?.connectorWidth})),f=m}return r}(o,t,e);case"candlestick":return function(e,t,n){if(!e.getHigh||!e.getLow||!e.scales)return[];const r=e.config.candlestickRangeMode??!1;if(!(r||e.getOpen&&e.getClose))return[];const o=[],i=e.config.candlestickStyle||{},s=i.rangeColor||"#6366f1",a=r?s:i.upColor||"#28a745",l=r?s:i.downColor||"#dc3545",c=r?s:i.wickColor||"#333",u=i.wickWidth||(r?2:1),h=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let d=i.bodyWidth??0;if(null==i.bodyWidth)if(h.length>1){let t=1/0;for(let n=1;h.length>n;n++){const r=Math.abs(e.scales.x(h[n])-e.scales.x(h[n-1]));r>0&&t>r&&(t=r)}d=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else d=6;for(const i of t){const t=e.getX(i);if(null==t||Number.isNaN(t))continue;const s=e.getHigh(i),h=e.getLow(i);if(null==s||Number.isNaN(s)||null==h||Number.isNaN(h))continue;const f=r?s:e.getOpen(i),p=r?h:e.getClose(i);if(!r&&[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(h),bodyWidth:d,upColor:a,downColor:l,wickColor:c,wickWidth:u,isUp:y,datum:i};r&&(g.isRange=!0,g.dotRadius=Math.max(2,Math.min(d/2,.12*n.height))),o.push(g)}return o}(o,t,e);default:return[]}}resolveBoundsStyle(e,t){return function(e,t,n,r){const o=e.boundsStyle;return"function"==typeof o?o(n||{},t):o&&"object"==typeof o?o:{fill:r(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?qt(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;const t=Gt(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&function(e,t,n,r=Gt(n)){const o=n.length;if(o>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=r.get(t[n]);null!=a?(i[n]=qt(e,a,o),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=r.get(t[n]);null!=i?(s[n]=qt(e,i,o),1>s[n]&&(a=!0)):s[n]=1}a&&(n._decayOpacities=s)}else{let s=1;for(const n of t){const t=r.get(n);if(null!=t){const n=qt(e,t,o);s>n&&(s=n)}}if(1>s){const e=Array(i);e.fill(s),n._decayOpacities=e}}continue}const t=r.get(n.datum);if(null==t)continue;const i=qt(e,t,o);"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&&Vt(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,r){n.clear(),r.clear();for(let o=0;t.length>o;o++){const i=t[o],s=Ut(e,i,o);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?r.set(s,{path:i.path.map(e=>[e[0],e[1]]),opacity:i.style?.opacity}):"area"===i.type&&r.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],r=Ut(this.transitionContext,n,t);r&&("point"===n.type?this.prevPositionMap.set(r,{x:n.x,y:n.y,r:0,opacity:0}):"rect"===n.type?this.prevPositionMap.set(r,{x:n.x,y:e,w:n.w,h:0,opacity:n.style.opacity??1}):"heatcell"===n.type?this.prevPositionMap.set(r,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:0}):"line"===n.type?(n._introClipFraction=0,this.prevPathMap.set(r,{path:n.path.map(e=>[e[0],e[1]]),opacity:n.style.opacity})):"area"===n.type&&(n._introClipFraction=0,this.prevPathMap.set(r,{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,r,o,i=Yt()){if(0===r.size&&0===o.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 l=new Set,c=new Set;for(let t=0;n.scene.length>t;t++){const i=n.scene[t],s=Ut(e,i,t);if(!s)continue;if(i._transitionKey=s,"line"===i.type||"area"===i.type){const e=o.get(s);if(e){if(c.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=r.get(s);if("point"===i.type)if(u){l.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){l.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){l.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){l.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){l.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 o)if(!c.has(e))if(e.startsWith("l:")&&t.path){const r={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(r),a=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const r={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(r),a=!0}for(const[e,t]of r)if(!l.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 r=t.openY??t.y;n.exitNodes.push({type:"candlestick",x:t.x,openY:r,closeY:t.closeY??r,highY:t.highY??r,lowY:t.lowY??r,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,r){if(!n.activeTransition)return!1;const o=Nt(e,n.activeTransition),i=Ft(o,"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?r.get(t):void 0;e.style.opacity=Wt(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=Wt(n.x,e._targetX,i),e.y=Wt(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.r=Wt(n.r,e._targetR,i))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style.opacity=Wt(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=Wt(n.x,e._targetX,i),e.y=Wt(n.y,e._targetY,i),void 0!==e._targetR&&void 0!==n.r&&(e.size=Wt(n.r,e._targetR,i))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style.opacity=Wt(n?n.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=Wt(n.x,e._targetX,i),e.y=Wt(n.y,e._targetY,i),void 0!==n.w&&(e.w=Wt(n.w,e._targetW,i)),void 0!==n.h&&(e.h=Wt(n.h,e._targetH,i))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style={...e.style||{},opacity:Wt(n?n.opacity??1:0,e._targetOpacity,i)}}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=Wt(n.x,e._targetX,i),e.y=Wt(n.y,e._targetY,i),void 0!==n.w&&(e.w=Wt(n.w,e._targetW,i)),void 0!==n.h&&(e.h=Wt(n.h,e._targetH,i))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const n=t?r.get(t):void 0;e.style={...e.style||{},opacity:Wt(n?n.opacity??1:0,e._targetOpacity,i)}}if(void 0===e._targetX)continue;if(!t)continue;const n=r.get(t);if(!n)continue;e.x=Wt(n.x,e._targetX,i),void 0!==n.openY&&(e.openY=Wt(n.openY,e._targetOpenY,i)),void 0!==n.closeY&&(e.closeY=Wt(n.closeY,e._targetCloseY,i)),void 0!==n.highY&&(e.highY=Wt(n.highY,e._targetHighY,i)),void 0!==n.lowY&&(e.lowY=Wt(n.lowY,e._targetLowY,i))}else if("line"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Wt(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 r=0;e.path.length>r;r++)e.path[r][0]=Wt(t[r][0],n[r][0],i),e.path[r][1]=Wt(t[r][1],n[r][1],i)}else if("area"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Wt(e._startOpacity??0,e._targetOpacity,i)}),void 0!==e._introClipFraction&&(e._introClipFraction=i);const t=e._prevTopPath,n=e._prevBottomPath,r=e._targetTopPath,o=e._targetBottomPath;if(t&&r&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=Wt(t[n][0],r[n][0],i),e.topPath[n][1]=Wt(t[n][1],r[n][1],i);if(n&&o&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=Wt(n[t][0],o[t][0],i),e.bottomPath[t][1]=Wt(n[t][1],o[t][1],i)}}if(o>=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,r){if(r&&r.version===n&&r.group===t&&r.data===e)return{result:r.result,cache:r};let o;if(t){const n=new Map;for(const r of e){const e=t(r);n.has(e)||n.set(e,[]),n.get(e).push(r)}o=Array.from(n.entries()).map(([e,t])=>({key:e,data:t}))}else o=[{key:"_default",data:e}];return{result:o,cache:{version:n,group:t,data:e,result:o}}}(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=n,t}resolveColorMap(e){const{map:t,cache:n}=function(e,t,n,r,o){if(o&&o.version===r)return{map:o.map,cache:o};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(o&&o.key===a){const e={...o,version:r};return{map:e.map,cache:e}}const l=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical||Ce,c=new Map;for(let e=0;s.length>e;e++)c.set(s[e],l[e%l.length]);return{map:c,cache:{key:a,map:c,version:r}}}(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=n,t}resolveLineStyle(e,t){return function(e,t,n,r){const o=e.lineStyle;if("function"==typeof o){const e=o(n||{},t);if(e&&!e.stroke&&t){const n=r(t);if(n)return{...e,stroke:n}}return e}const i=e.themeSemantic?.primary;return o&&"object"==typeof o?{stroke:o.stroke||i||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:r(t)||i||"#007bff",strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return function(e,t,n,r){if(e.areaStyle){const o=e.areaStyle(n||{});if(o&&!o.fill&&t){const e=r(t);if(e)return{...o,fill:e,stroke:o.stroke||e}}return o}const o=e.lineStyle;if("function"==typeof o){const e=o(n||{},t);if(e&&!e.fill&&t){const n=r(t);if(n)return{...e,fill:n,stroke:e.stroke||n}}return e}const i=e.themeSemantic?.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||i||"#4e79a7",fillOpacity:o.fillOpacity??.7,stroke:o.stroke||i||"#4e79a7",strokeWidth:o.strokeWidth||2};const s=r(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:r}=function(e){const{group:t,colorMapCache:n,groupColorMap:r,groupColorMapCap:o,config:i}=e;let{groupColorCounter:s}=e;if(n){const e=n.map.get(t);if(e)return{color:e,groupColorCounter:s}}const a=r.get(t);if(a)return{color:a,groupColorCounter:s};const l=(Array.isArray(i.colorScheme)&&i.colorScheme.length>0?i.colorScheme:null)||(Array.isArray(i.themeCategorical)&&i.themeCategorical.length>0?i.themeCategorical:null)||Ce;if(0===l.length)return{color:null,groupColorCounter:s};const c=l[s%l.length];if(s++,r.set(t,c),r.size>o){const e=r.keys().next().value;void 0!==e&&r.delete(e)}return{color:c,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=r,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=Bt(e),n=this.getPointId,r=e=>t.has(n(e));zn(this.buffer,this.timestampBuffer,r);const o=this.buffer.remove(r);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(const e of o)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",o.length),o}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=Bt(e),r=this.getPointId,o=new Set;this.buffer.forEach((e,t)=>{n.has(r(e))&&o.add(t)});const i=this.buffer.update(e=>n.has(r(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)=>{o.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 r of e){const e=this._baseStyles.get(r)??r.style??{},o=n(r,t);r.style=o?{...e,...o}: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 r=!1,o=!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||!Lt(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),l=i||!Lt(n,s);(a||l)&&(e?(this.getX=$t(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=$t(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=$t(this.config.xAccessor,"x"),this.getY=$t(this.config.yAccessor,"y")),l&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=Pn(this.config)),r=!0,o=!0)}if("groupAccessor"in e&&!Lt(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?Dt(this.config.groupAccessor):void 0,r=!0),"categoryAccessor"in e&&!Lt(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?Dt(this.config.categoryAccessor):void 0,r=!0),"sizeAccessor"in e&&!Lt(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?$t(this.config.sizeAccessor,"size"):void 0,r=!0),"symbolAccessor"in e&&!Lt(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Dt(this.config.symbolAccessor):void 0,r=!0),"colorAccessor"in e&&!Lt(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Dt(this.config.colorAccessor):void 0,r=!0),"y0Accessor"in e&&!Lt(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?$t(this.config.y0Accessor,"y0"):void 0,r=!0,o=!0),("boundsAccessor"in e&&!Lt(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=Pn(this.config),r=!0,o=!0),"pointIdAccessor"in e&&!Lt(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?Dt(this.config.pointIdAccessor):void 0,r=!0),"candlestick"===this.config.chartType&&(i||"openAccessor"in e&&!Lt(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!Lt(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!Lt(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!Lt(e.lowAccessor,t.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?$t(this.config.openAccessor,"open"):void 0,this.getHigh=$t(this.config.highAccessor,"high"),this.getLow=$t(this.config.lowAccessor,"low"),this.getClose=t?$t(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,r=!0,o=!0}if("accessorRevision"in e&&e.accessorRevision!==t.accessorRevision&&(r=!0,o=!0),!r){const n=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const o of n)if(e[o]!==t[o]){r=!0;break}}r&&(o&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(n)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};lr.GROUP_COLOR_MAP_CAP=1e3;var cr=lr;Wn(cr);var ur=require("react"),hr={sceneGeometry:0,layout:0,domain:0};function dr(e){const{domain:t,layout:n,sceneGeometry:r}=e.revisions;return{domain:t,layout:n,sceneGeometry:r}}function fr(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 pr="production"!==process.env.NODE_ENV,yr={revisions:hr,signature:"",sawSignals:!1,wasUnconsumed:!1,warnUnconsumed:!1},gr=class{constructor(e="scene host"){this.hostName=e,this.lastConsumed=hr,this.lastObserved=hr,this.lastDuplicateWarning="",this.lastUnconsumedWarning=""}observeUpdateResult(e){pr&&(this.lastObserved=fr(this.lastObserved,dr(e)))}beforeCompute(e,t){if(!pr)return yr;const n=fr(dr(e),this.lastObserved),r=function(e){return`${e.sceneGeometry}|${e.layout}|${e.domain}`}(n),o=!((i=n).sceneGeometry===(s=this.lastConsumed).sceneGeometry&&i.layout===s.layout&&i.domain===s.domain);var i,s;return{revisions:n,signature:r,sawSignals:e.changed.has("scene-geometry")||e.changed.has("layout")||e.changed.has("domain"),wasUnconsumed:o,warnUnconsumed:!t&&o&&this.lastUnconsumedWarning!==r}}afterCompute(e,t,n){if(pr){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="")}}},mr=(0,ur.memo)(function({store:e,diagnostics:t}){return(0,ur.useEffect)(()=>{const n=()=>t.observeUpdateResult(e.getUpdateSnapshot());return n(),e.subscribeUpdateResult(n)},[t,e]),null}),xr=c(require("react"));function br(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:xr.createElement(xr.Fragment,null,...t)}var vr=c(require("react")),wr=require("react/jsx-runtime"),kr=vr.createContext(null);function Sr({value:e,children:t}){return(0,wr.jsx)(kr.Provider,{value:e,children:t})}function Ar(e,t){return null!=e?(0,wr.jsx)(Sr,{value:t,children:e}):e}var Mr=require("react");function _r(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 Pr(e,t=30){return Math.max((e??4)+5,12,t)}function Cr(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function jr(e,t){const n=Cr(e);if(!n)return!1;const r=Cr(t);return!r||n.getFullYear()!==r.getFullYear()||n.getMonth()!==r.getMonth()}var Tr=[40,40],Rr=[.5,.5];function Lr(e,t){const[n,r]=e.viewBox??Tr,[o,i]=e.anchor??Rr,s=r>0?r:1,a=Math.max(0,t)/s,l=(n>0?n:s)*a,c=s*a;return{width:l,height:c,scale:a,offsetX:-o*l,offsetY:-i*c}}function $r(e,t,n,r){if("none"!==e)return"color"===e||null==e?t??r:"accent"===e?n:e}var zr=null;function Dr(e){if("undefined"==typeof Path2D)return null;zr||(zr=new Map);const t=zr.get(e);if(t)return t;const n=new Path2D(e);return zr.size>1024&&zr.clear(),zr.set(e,n),n}function Or(e,t,n=0,r="horizontal"){const[o,i]=e.viewBox??Tr,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a>s?s>0||1>a?"vertical"===r?{x:0,y:i*(1-a),width:o,height:i*(a-s)}:{x:o*s,y:0,width:o*(a-s),height:i}:null:{x:0,y:0,width:0,height:0}}function Ir(e,t){const n=Lr(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 Er(e,t,n,r,o,i=e=>e){for(const s of t.parts){const t=Dr(s.d);if(!t)continue;const a=s.opacity??1,l=e.globalAlpha;1!==a&&(e.globalAlpha=l*a);const c=o?"none"===s.fill?void 0:o:$r(s.fill,n,r);c&&(e.fillStyle=i(c),e.fill(t));const u=o?s.stroke&&"none"!==s.stroke?o:void 0:$r(s.stroke??"none",n,r);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=l)}}var Br=new WeakMap,Fr=0,Nr=!1,Wr=null,Yr=null;function qr(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),r=n.indexOf(",");if(-1===r){const e=n.trim();return e.startsWith("--")?{name:e}:null}const o=n.slice(0,r).trim(),i=n.slice(r+1).trim();return o.startsWith("--")?{name:o,fallback:i||void 0}:null}(t);if(!n)return t;const r=()=>n.fallback?qr(e,n.fallback):t,o=e.canvas;if(!o)return r();!function(){if(Nr)return;if("undefined"==typeof window||"undefined"==typeof document)return;Nr=!0;const e=()=>{Fr++};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{Wr=window.matchMedia("(prefers-color-scheme: dark)"),Yr=e,"function"==typeof Wr.addEventListener?Wr.addEventListener("change",Yr):"function"==typeof Wr.addListener&&Wr.addListener(Yr)}catch{}}();let i=Br.get(o);i&&i.version===Fr||(i={version:Fr,map:new Map},Br.set(o,i));const s=i.map.get(t);if(void 0!==s)return s;const a=getComputedStyle(o).getPropertyValue(n.name).trim()||r()||t;return i.map.set(t,a),a}function Gr(e){return{type:"hatch",background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle}}var Xr=null;var Hr=require("react/jsx-runtime");function Vr(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function Ur(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}var Kr=new Map;function Zr(e,t){const{background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:s=45,lineOpacity:a=1}=e,l=Math.max(8,Math.ceil(2*i));return(0,Hr.jsxs)("pattern",{id:t,width:l,height:l,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[n&&"transparent"!==n&&(0,Hr.jsx)("rect",{width:l,height:l,fill:n}),(0,Hr.jsx)("line",{x1:0,y1:0,x2:0,y2:l,stroke:r,strokeWidth:o,strokeOpacity:a}),(0,Hr.jsx)("line",{x1:i,y1:0,x2:i,y2:l,stroke:r,strokeWidth:o,strokeOpacity:a})]},t)}function Qr(e,t,n="#4e79a7"){if(Vr(e)){const n=function(e,t){let n=2166136261;const r=Ur(t);for(let e=0;r.length>e;e++)n^=r.charCodeAt(e),n=Math.imul(n,16777619);return`${e}-hatch-${(n>>>0).toString(36)}`}(t,e);return{fill:`url(#${n})`,def:Zr(e,n)}}return e&&"string"==typeof e?{fill:e}:{fill:n}}var Jr=require("d3-shape");function eo(e){switch(e){case"monotoneX":return Jr.curveMonotoneX;case"monotoneY":return Jr.curveMonotoneY;case"cardinal":return Jr.curveCardinal;case"catmullRom":return Jr.curveCatmullRom;case"step":return Jr.curveStep;case"stepBefore":return Jr.curveStepBefore;case"stepAfter":return Jr.curveStepAfter;case"basis":return Jr.curveBasis;case"natural":return Jr.curveNatural;default:return null}}function to(e,t,n){if(null==t)return n;if(Vr(t)){const r=function(e,t){const n="undefined"!=typeof window&&window.devicePixelRatio||1,r=`${Ur(e)}@${n}`,o=Kr.get(r);if(void 0!==o)return o;const i=function(e={},t){const{background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:s=45}=e,a={background:n,stroke:r,lineWidth:o,spacing:i,angle:s},l=Math.max(8,Math.ceil(2*i));let c;try{c=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Xr||(Xr=document.createElement("canvas")),Xr.width=e,Xr.height=e,Xr)}(l)}catch{return Gr(a)}const u=c.getContext("2d");if(!u)return Gr(a);n&&"transparent"!==n?(u.fillStyle=n,u.fillRect(0,0,l,l)):u.clearRect(0,0,l,l),u.strokeStyle=r,u.lineWidth=o,u.lineCap="square";const h=s*Math.PI/180;if(45===s||-45===s){const e=s>0?1:-1;for(let t=-l;2*l>=t;t+=i)u.beginPath(),u.moveTo(t,0),u.lineTo(t+e*l,l),u.stroke()}else{u.save(),u.translate(l/2,l/2),u.rotate(h);const e=2*l;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(c,"repeat")}({background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle},t),s=Vr(i)?null:i;return Kr.set(r,s),s}(t,e);return r||t.background&&qr(e,t.background)||n}return"string"!=typeof t?t:qr(e,t)||n}function no(e,t,n,r,o,i,s){if("colorStops"in t){const n=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>n.length)return null;const a=e.createLinearGradient(r,o,i,s);for(const e of n)a.addColorStop(e.offset,e.color);return a}const{topOpacity:a,bottomOpacity:l}=t;if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c=Math.max(0,Math.min(1,a)),u=Math.max(0,Math.min(1,l)),h=e.createLinearGradient(r,o,i,s),[d,f,p]=function(e,t){const n=e.fillStyle,r="#010203";try{e.fillStyle=r,e.fillStyle=t}catch{return e.fillStyle=n,[78,121,167]}const o=e.fillStyle;if(e.fillStyle=n,"string"!=typeof o)return[78,121,167];if(o.toLowerCase()===r&&t.trim().toLowerCase()!==r)return[78,121,167];if(o.startsWith("#"))return[parseInt(o.slice(1,3),16),parseInt(o.slice(3,5),16),parseInt(o.slice(5,7),16)];const i=o.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return i?[+i[1],+i[2],+i[3]]:[78,121,167]}(e,n);return h.addColorStop(0,`rgba(${d},${f},${p},${c})`),h.addColorStop(1,`rgba(${d},${f},${p},${u})`),h}function ro(e,t,n,r,o,i){const s=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>s.length)return null;const a=e.createLinearGradient(n,r,o,i);for(const e of s)a.addColorStop(e.offset,e.color);return a}var oo=require("d3-shape"),io=new WeakMap;function so(e,t){const n=eo(t);if(!n)return e;const r=io.get(e);if(r)return r;const o=function(e,t,n=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const r=[];let o=null;const i={moveTo(e,t){o=[e,t],r.push([e,t])},lineTo(e,t){o=[e,t],r.push([e,t])},bezierCurveTo(e,t,i,s,a,l){if(!o)return o=[a,l],void r.push([a,l]);const[c,u]=o;for(let o=1;n>=o;o++){const h=o/n,d=1-h;r.push([d*d*d*c+3*d*d*h*e+3*d*h*h*i+h*h*h*a,d*d*d*u+3*d*d*h*t+3*d*h*h*s+h*h*h*l])}o=[a,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,n,i){o=[n,i],r.push([n,i])}};return(0,oo.line)().x(e=>e[0]).y(e=>e[1]).curve(t).context(i)(e),r}(e,n);return io.set(e,o),o}function ao(e,t,n,r=30,o,i=0){let s=null;if(o){const e=function(e,t,n,r,o,i=e=>e.x,s=e=>e.y,a=e=>e.r){const l=Math.max(r,o+5,12),c=t-l,u=t+l,h=n-l,d=n+l;let f=null,p=1/0;return e.visit((e,o,l,y,g)=>{if(o>u||c>y||l>d||h>g)return!0;if(!e.length){let o=e;do{const e=o.data,l=i(e)-t,c=s(e)-n,u=Math.sqrt(l*l+c*c);Pr(a(e),r)>=u&&p>u&&(f=e,p=u),o=o.next}while(o)}return!1}),f?{node:f,distance:p}:null}(o,t,n,r,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(o)break;e=co(i,t,n,r);break;case"symbol":e=uo(i,t,n,r);break;case"glyph":e=ho(i,t,n,r);break;case"line":e=fo(i,t,n,r);break;case"rect":if(null==i.datum)break;e=yo(i,t,n);break;case"heatcell":e=go(i,t,n);break;case"area":if(!1===i.interactive)break;e=xo(i,t,n);break;case"candlestick":e=mo(i,t,n)}e&&r>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function lo(e,t,n){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const r=bo(e,t);if(0>r)return null;if(Math.abs(e[r][0]-t)>n)return null;let o=r,i=r;r>0&&e[r][0]>=t?(o=r-1,i=r):e.length-1>r&&(o=r,i=r+1);const[s,a]=e[o],[l,c]=e[i];return l===s?a:a+Math.max(0,Math.min(1,(t-s)/(l-s)))*(c-a)}function co(e,t,n,r=30){const o=t-e.x,i=n-e.y,s=Math.sqrt(o*o+i*i);return s>Pr(e.r,r)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function uo(e,t,n,r=30){const o=t-e.x,i=n-e.y,s=Math.sqrt(o*o+i*i);return s>Pr(xn(e.size),r)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function ho(e,t,n,r=30){if(null==e.datum)return null;const o=Ir(e.glyph,e.size),i=e.x+o.centerDx,s=e.y+o.centerDy,a=t-i,l=n-s,c=Math.sqrt(a*a+l*l);return c>Pr(o.radius,r)?null:{node:e,datum:e.datum,x:i,y:s,distance:c}}function fo(e,t,n,r=30){if(0===e.path.length)return null;const o=bo(e.path,t);if(0>o)return null;const[i,s]=e.path[o];let a;if(e.path.length>1){let r=1/0;const i=Math.max(0,o-1),s=Math.min(e.path.length-2,o);for(let o=i;s>=o;o++){const[i,s]=e.path[o],[a,l]=e.path[o+1],c=po(t,n,i,s,a,l);r>c&&(r=c)}a=r}else{const e=t-i,r=n-s;a=Math.sqrt(e*e+r*r)}const l=e.style;return a>Math.max(5,(l.strokeWidth??l.lineWidth??1)/2+2,r)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:i,y:s,distance:a}}function po(e,t,n,r,o,i){const s=o-n,a=i-r,l=s*s+a*a;if(0===l)return Math.sqrt((e-n)**2+(t-r)**2);let c=((e-n)*s+(t-r)*a)/l;return c=Math.max(0,Math.min(1,c)),Math.sqrt((e-(n+c*s))**2+(t-(r+c*a))**2)}function yo(e,t,n){const r=_r(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function go(e,t,n){const r=_r(t,n,e);return r.hit?{node:e,datum:e.datum,x:r.cx,y:r.cy,distance:0}:null}function mo(e,t,n){const r=e.bodyWidth/2,o=Math.min(e.openY,e.closeY);if(!(e.x-r-3>t||t>e.x+r+3||e.highY-3>n||n>e.lowY+3)){const r=o+Math.max(Math.max(e.openY,e.closeY)-o,1)/2,i=t-e.x,s=n-r;return{node:e,datum:e.datum,x:e.x,y:r,distance:Math.sqrt(i*i+s*s)}}return null}function xo(e,t,n){if(0===e.topPath.length)return null;const r=bo(e.topPath,t);if(0>r)return null;const[o,i]=e.topPath[r],s=t-o,a=n-i,l=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[r]?e.datum[r]:e.datum,x:o,y:i,distance:l}}function bo(e,t){if(0===e.length)return-1;let n=0,r=e.length-1;for(;r>n;){const o=n+r>>1;t>e[o][0]?n=o+1:r=o}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}var vo=require("react"),wo={fresh:1,aging:.7,stale:.45,expired:.25},ko={alpha:1,band:"fresh",isStale:!1};function So(e,t){if(!e||0>=t)return ko;const n=null!=e.threshold&&e.threshold>0?e.threshold:5e3,r=e.graded;if(r){const e="object"==typeof r?r:{},o=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:{...wo,...e.opacities??{}}[o],band:o,isStale:"fresh"!==o}}return t>n?{alpha:e.dimOpacity??.5,band:"stale",isStale:!0}:ko}var Ao=require("react/jsx-runtime");function Mo({isStale:e,position:t}){return(0,Ao.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 _o=require("react"),Po=c(require("react")),Co=16,jo=6,To=10,Ro=22;function Lo(e){const t=Math.max(1,e?.swatchSize??Co),n=Math.max(t,e?.rowHeight??Ro);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??jo),itemGap:Math.max(0,e?.itemGap??To),rowHeight:n,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}function $o(e,t){let n=24;return e.map(({hasLabel:e,itemCount:r})=>{n+=5;const o=n;let i;n+=8,e&&(n+=16,i=n,n+=8);const s=n;return n+=r*t+8,{lineY:o,labelY:i,itemsY:s,endY:n}})}var zo=require("react/jsx-runtime"),Do={fill:(e,t)=>(0,zo.jsx)("rect",{style:e,width:t,height:t}),line:(e,t)=>(0,zo.jsx)("line",{style:e,x1:0,y1:0,x2:t,y2:t})};function Oo(e,t,n,r,o){let i;return i="function"==typeof n?n(e):(0,Do[n])(r(e,t),o),i}function Io({swatchSize:e}){return(0,zo.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 Eo(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}var Bo=(e,t,n,r,o,i,s,a,l,c,u)=>{const{type:h="fill",styleFn:d,items:f}=e,p=[];let y=0;const g=!(!t&&!n),m="isolate"===c||void 0===c&&null!=o,{swatchSize:x,labelGap:b,rowHeight:v}=u;return f.forEach((e,c)=>{const u=Oo(e,c,h,d,x),w=Eo(e,r,o),k=o&&o.size>0&&o.has(e.label);p.push((0,zo.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&&c===s?0:-1:void 0,role:g?"option":void 0,"aria-selected":g&&m?k||!1:void 0,"aria-current":g&&!m&&null!=r&&e.label===r||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=(c+("ArrowDown"===n.key?1:-1)+f.length)%f.length;l(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:g?t=>{l(a,c),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.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,zo.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,zo.jsx)(Io,{swatchSize:x}),(0,zo.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-"+c)),y+=v}),p};function Fo({config:e,orientation:t="vertical",width:n=100}){const{colorFn:r,domain:o,label:i,format:s}=e,a=s||(e=>Math.round(100*e)/100+""),l="grad-legend-"+Po.useId();if("horizontal"===t){const e=12,t=Math.min(n,200),s=Math.max(0,(n-t)/2),c=[];for(let e=0;64>=e;e++){const t=e/64;c.push((0,zo.jsx)("stop",{offset:100*t+"%",stopColor:r(o[0]+t*(o[1]-o[0]))},e))}return(0,zo.jsxs)("g",{"aria-label":i||"Gradient legend",children:[(0,zo.jsx)("defs",{children:(0,zo.jsx)("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:c})}),i&&(0,zo.jsx)("text",{x:s+t/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),(0,zo.jsx)("rect",{x:s,y:0,width:t,height:e,fill:`url(#${l})`,rx:2}),(0,zo.jsx)("text",{x:s,y:e+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[0])}),(0,zo.jsx)("text",{x:s+t,y:e+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[1])})]})}const c=[];for(let e=0;64>=e;e++){const t=e/64;c.push((0,zo.jsx)("stop",{offset:100*t+"%",stopColor:r(o[1]-t*(o[1]-o[0]))},e))}return(0,zo.jsxs)("g",{"aria-label":i||"Gradient legend",children:[i&&(0,zo.jsx)("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:i}),(0,zo.jsx)("defs",{children:(0,zo.jsx)("linearGradient",{id:l,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:c})}),(0,zo.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${l})`,rx:2}),(0,zo.jsx)("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[1])}),(0,zo.jsx)("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:a(o[0])})]})}function No(e){const{legendGroups:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,legendInteraction:s,title:a="Legend",width:l=100,height:c=20,orientation:u="vertical",legendLayout:h}=e,d=Lo(h),[f,p]=Po.useState(0),[y,g]=Po.useState(0),m=Po.useCallback((e,t)=>{p(e),g(t)},[]),x="vertical"===u?(({legendGroups:e,width:t,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:s,focusedItemIndex:a,onFocusedIndexChange:l,legendInteraction:c,metrics:u})=>{const h=[],d=$o(e.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),u.rowHeight);return e.forEach((e,f)=>{const p=d[f];h.push((0,zo.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&&h.push((0,zo.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)),h.push((0,zo.jsx)("g",{className:"legend-item",transform:`translate(0,${p.itemsY})`,children:Bo(e,n,r,o,i,s,a,f,l,c,u)},"legend-group-"+f))}),h})({legendGroups:t||[],width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:s,metrics:d}):(({legendGroups:e,height:t,width:n,customClickBehavior:r,customHoverBehavior:o,highlightedCategory:i,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u,metrics:h})=>{let d=0;const f=[];e.forEach((e,t)=>{let p=0;e.label&&(p+=16);const y=((e,t,n,r,o,i,s,a,l,c,u,h)=>{const{type:d="fill",styleFn:f,items:p}=e,y=[],{swatchSize:g,labelGap:m,itemGap:x,rowHeight:b,align:v}=u,w=!(!t&&!n),k="isolate"===c||void 0===c&&null!=o,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;h&&h>0&&_>0&&n>h?(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,c)=>{let u="center"===v?Math.max(0,((h??e.width)-e.width)/2):"end"===v?Math.max(0,(h??e.width)-e.width):0;for(let h=e.start;e.end>h;h++){const e=p[h],v=Oo(e,h,d,f,g),A=Eo(e,r,o),M=o&&o.size>0&&o.has(e.label);y.push((0,zo.jsxs)("g",{transform:`translate(${u},${c*b})`,onClick:t?()=>t(e):void 0,onMouseEnter:n?()=>n(e):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:w?a===i&&h===s?0:-1:void 0,role:w?"option":void 0,"aria-selected":w&&k?M||!1:void 0,"aria-current":w&&!k&&null!=r&&e.label===r||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=(h+("ArrowRight"===n.key?1:-1)+p.length)%p.length;l(a,e);const t=n.currentTarget.parentElement?.children[e];t instanceof SVGElement&&t.focus()}}:void 0,onFocus:w?t=>{l(a,h),n&&n(e);const r=t.currentTarget.querySelector(".semiotic-legend-focus-ring");r&&r.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,zo.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,zo.jsx)(Io,{swatchSize:g}),(0,zo.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-"+h)),u+=S[h]+x}});const P=Math.max(0,...A.map(e=>e.width)),C=A.length;return{items:y,offset:P,totalRows:C,totalHeight:C*b}})(e,r,o,i,s,a,l,t,c,u,h,h.maxWidth??n);p+=y.offset+5,f.push({label:e.label,...y,offset:p,totalRows:y.totalRows,totalHeight:y.totalHeight}),d+=p+12});const p=h.maxWidth??n;let y=d>p?0:"center"===h.align?Math.max(0,(p-d)/2):"end"===h.align?Math.max(0,p-d):0;const g=[];return f.forEach((n,r)=>{const o=e[r];o.label&&(g.push((0,zo.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:o.label},"legend-text-"+r)),y+=16),g.push((0,zo.jsx)("g",{className:"legend-item",transform:`translate(${y},0)`,children:n.items},"legend-group-"+r)),y+=n.offset+5,e[r+1]&&g.push((0,zo.jsx)("line",{stroke:"gray",x1:y,y1:-8,x2:y,y2:(n.totalHeight||t)+0+8},"legend-top-line legend-symbol-"+r)),y+=12}),(0,zo.jsx)("g",{children:g})})({legendGroups:t||[],title:a,height:c,width:l,customClickBehavior:n,customHoverBehavior:r,highlightedCategory:o,isolatedCategories:i,focusedGroupIndex:f,focusedItemIndex:y,onFocusedIndexChange:m,legendInteraction:s,metrics:d}),b=!(!n&&!r);return(0,zo.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,zo.jsx)("text",{className:"legend-title",y:16,x:l/2,textAnchor:"middle",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:a}),x]})}function Wo(...e){let t;for(const n of e)n&&(t=Yo(t)&&Yo(n)?{legendGroups:[...t.legendGroups,...n.legendGroups]}:n);return t}function Yo(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}function qo(e){return"object"==typeof e&&null!==e&&"gradient"in e}var Go=require("react/jsx-runtime");function Xo(e){const{legend:t,totalWidth:n,totalHeight:r,margin:o,legendPosition:i="right",legendLayout:s,title:a,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:h,legendInteraction:d}=e;if(!t)return null;const f="top"===i||"bottom"===i,p=!!a,y=Math.max(0,n-o.left-o.right),g=Math.max(1,f?s?.maxWidth??y:100);let m,x;return"left"===i?(m=Math.max(4,o.left-g-10),x=o.top):"top"===i?(m=o.left,x=p?32:8):"bottom"===i?(m=o.left,x=r-o.bottom+38):(m=n-o.right+10,x=o.top),(0,Go.jsx)("g",{transform:`translate(${m}, ${x})`,children:qo(t)?(0,Go.jsx)(Fo,{config:t.gradient,orientation:f?"horizontal":"vertical",width:g}):Yo(t)?(0,Go.jsx)(No,{legendGroups:t.legendGroups,title:"",width:g,orientation:f?"horizontal":"vertical",legendLayout:s,customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:h,legendInteraction:d}):t})}var Ho=require("react"),Vo=require("d3-array");x();var Uo=require("react/jsx-runtime");function Ko(e){return"string"==typeof e?{type:e}:e}function Zo({orient:e,config:t,values:n,scale:r,size:o,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,l=(0,Ho.useMemo)(()=>{if(0===n.length)return null;const t=r.domain(),l=o-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 r=t[Math.floor(.25*n)],o=t[Math.floor(.5*n)],i=t[Math.floor(.75*n)],s=i-r;return{q1:r,median:o,q3:i,whiskerLow:Math.max(t[0],r-1.5*s),whiskerHigh:Math.min(t[n-1],i+1.5*s)}}(n);if(!t)return null;const{q1:o,median:i,q3:c,whiskerLow:u,whiskerHigh:h}=t,d=Math.min(.5*l,20),f=(l-d)/2+4;if(a){const t=r(o),n=r(c),a=r(i),l=r(u),p=r(h),y="top"===e?-1:1,g=0;return(0,Uo.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,Uo.jsx)("line",{x1:l,y1:g+y*(f+d/2),x2:p,y2:g+y*(f+d/2),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Uo.jsx)("line",{x1:l,y1:g+y*f,x2:l,y2:g+y*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Uo.jsx)("line",{x1:p,y1:g+y*f,x2:p,y2:g+y*(f+d),stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Uo.jsx)("rect",{x:Math.min(t,n),y:"top"===e?g-f-d:g+f,width:Math.abs(n-t),height:d,fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),(0,Uo.jsx)("line",{x1:a,y1:"top"===e?g-f-d:g+f,x2:a,y2:"top"===e?g-f:g+f+d,stroke:s.fill,strokeWidth:2})]})}{const t=r(o),n=r(c),a=r(i),l=r(u),p=r(h),y="left"===e?-1:1,g=0;return(0,Uo.jsxs)("g",{"data-testid":"marginal-boxplot-"+e,children:[(0,Uo.jsx)("line",{x1:g+y*(f+d/2),y1:l,x2:g+y*(f+d/2),y2:p,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Uo.jsx)("line",{x1:g+y*f,y1:l,x2:g+y*(f+d),y2:l,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Uo.jsx)("line",{x1:g+y*f,y1:p,x2:g+y*(f+d),y2:p,stroke:s.fill,strokeWidth:s.strokeWidth}),(0,Uo.jsx)("rect",{x:"left"===e?g-f-d:g+f,y:Math.min(t,n),width:d,height:Math.abs(n-t),fill:s.fill,fillOpacity:s.fillOpacity,stroke:"none"===s.stroke?s.fill:s.stroke,strokeWidth:s.strokeWidth}),(0,Uo.jsx)("line",{x1:"left"===e?g-f-d:g+f,y1:a,x2:"left"===e?g-f:g+f+d,y2:a,stroke:s.fill,strokeWidth:2})]})}}const c=(0,Vo.bin)().domain(t).thresholds(s.bins)(n);if(0===c.length)return null;const u=h(c.map(e=>e.length));if(0===u)return null;if("histogram"===s.type)return(0,Uo.jsx)("g",{"data-testid":"marginal-histogram-"+e,children:c.map((t,n)=>{if(null==t.x0||null==t.x1)return null;const o=t.length/u*l;if(a){const i=r(t.x0),a=r(t.x1)-r(t.x0);return(0,Uo.jsx)("rect",{x:i,y:"top"===e?-4-o:4,width:Math.max(a,.5),height:o,fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}{const i=r(t.x0),a=r(t.x1)-r(t.x0);return(0,Uo.jsx)("rect",{x:"left"===e?-4-o:4,y:Math.min(i,i+a),width:o,height:Math.abs(a),fill:s.fill,fillOpacity:s.fillOpacity,stroke:s.stroke,strokeWidth:s.strokeWidth},n)}})});if("violin"===s.type){const t=l/2+4,n=[];for(const o of c){if(null==o.x0||null==o.x1)continue;const i=o.length/u*(l/2),s=r((o.x0+o.x1)/2);n.push(a?`${s},${"top"===e?-(t-i):t-i}`:`${"left"===e?-(t-i):t-i},${s}`)}for(let o=c.length-1;o>=0;o--){const i=c[o];if(null==i.x0||null==i.x1)continue;const s=i.length/u*(l/2),h=r((i.x0+i.x1)/2);n.push(a?`${h},${"top"===e?-(t+s):t+s}`:`${"left"===e?-(t+s):t+s},${h}`)}return(0,Uo.jsx)("g",{"data-testid":"marginal-violin-"+e,children:(0,Uo.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,o=null!=c[0].x0?r(c[0].x0):0;t.push(`M${o},${n}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const o=n.length/u*l,i=r((n.x0+n.x1)/2);t.push(`L${i},${"top"===e?-o-4:o+4}`)}const s=null!=c[c.length-1].x1?r(c[c.length-1].x1):i;t.push(`L${s},${n}`),t.push("Z")}else{const n=0,o=null!=c[0].x0?r(c[0].x0):0;t.push(`M${n},${o}`);for(const n of c){if(null==n.x0||null==n.x1)continue;const o=n.length/u*l,i=r((n.x0+n.x1)/2);t.push(`L${"left"===e?-o-4:o+4},${i}`)}const s=null!=c[c.length-1].x1?r(c[c.length-1].x1):i;t.push(`L${n},${s}`),t.push("Z")}return(0,Uo.jsx)("g",{"data-testid":"marginal-ridgeline-"+e,children:(0,Uo.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,r,s,o,i,e,a,4]);return l?(0,Uo.jsx)("g",{className:"marginal-"+e,"data-testid":"marginal-"+e,children:l}):null}var Qo=c(require("react")),Jo=require("react/jsx-runtime");function ei(e,t=120,n=8){if(!e)return[];const r=Math.max(1,Math.floor(t/n)),o=e.split(/\s+/),i=[];let s="";for(const e of o)s&&s.length+1+e.length>r?(i.push(s),s=e):s=s?`${s} ${e}`:e;return s&&i.push(s),i}function ti(e,t,n,r){return"curly"===e?r?`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`:r?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function ni(e,t,n,r){if(!e)return(0,Jo.jsx)("g",{className:"annotation-note"});const{label:o,title:i,orientation:s,align:a,wrap:l=120,noWrap:c}=e;if(!o&&!i)return(0,Jo.jsx)("g",{className:"annotation-note"});let u=s;u||(u=Math.abs(t)>Math.abs(n)?"leftRight":"topBottom");let h=a;h&&"dynamic"!==h||(h="topBottom"===u?0>t?"right":"left":0>n?"bottom":"top");let d="start";"topBottom"===u?"right"===h?d="end":"middle"===h&&(d="middle"):d=0>t?"end":"start";const f=16,p=i?c?[i]:ei(i,l):[],y=o?c?[o]:ei(o,l):[],g="leftRight"===u?"end"===d?-4:4:0;let m=0;const x=[],b=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";e.useHTML||e.html?x.push((0,Jo.jsx)("foreignObject",{className:"annotation-note-html",x:"end"===d?g-l:"middle"===d?g-l/2:g,y:-16,width:l,height:Math.max(f,(p.length+y.length)*f+(i&&o?2:0))+f,style:{overflow:"visible"},children:(0,Jo.jsxs)("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:b,fontSize:"12px",lineHeight:"16px",overflow:"visible",textAlign:"end"===d?"right":"middle"===d?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[i&&(0,Jo.jsx)("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:i}),o&&(0,Jo.jsx)("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html")):(p.length>0&&(x.push((0,Jo.jsx)("text",{className:"annotation-note-title",fill:b,textAnchor:d,fontWeight:"bold",children:p.map((e,t)=>(0,Jo.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,Jo.jsx)("text",{className:"annotation-note-label",fill:b,textAnchor:d,y:m,children:y.map((e,t)=>(0,Jo.jsx)("tspan",{x:g,dy:0===t?0:f,children:e},t))},"annotation-note-label")));let v=null;if((i||o)&&(0!==t||0!==n))if("topBottom"===u){const e=Math.min(l,120);let t=0,n=e;"end"===d?(t=-e,n=0):"middle"===d&&(t=-e/2,n=e/2),v=(0,Jo.jsx)("line",{className:"note-line",x1:t,x2:n,y1:0,y2:0,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}else{const e=(p.length+y.length)*f+(y.length>0?f:0);let t=0,n=e;"bottom"===h?(t=-e,n=0):"middle"===h&&(t=-e/2,n=e/2),v=(0,Jo.jsx)("line",{className:"note-line",x1:0,x2:0,y1:t,y2:n,stroke:r||"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"===h?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===h||0>n?-(w+2):18),(0,Jo.jsxs)("g",{className:"annotation-note",transform:`translate(${t},${n})`,children:[(0,Jo.jsx)("g",{className:"annotation-note-content",transform:0!==k?`translate(0,${k})`:void 0,children:x}),v]})}function ri(e,t,n,r,o){const i=[];switch(e){case"callout-circle":{const e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&i.push((0,Jo.jsx)("circle",{r:e,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const e=t?.width||0,r=t?.height||0;(e>0||r>0)&&i.push((0,Jo.jsx)("rect",{width:e,height:r,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=r||0,s=o||0;if(void 0!==t?.x){const r=(t.x||0)-e;i.push((0,Jo.jsx)("line",{x1:r,y1:(t.y1||0)-s,x2:r,y2:(t.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==t?.y){const r=(t.y||0)-s;i.push((0,Jo.jsx)("line",{x1:(t.x1||0)-e,y1:r,x2:(t.x2||0)-e,y2:r,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==t?.x1||void 0!==t?.x2?i.push((0,Jo.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,Jo.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",r=t?.width??t?.height;void 0!==r&&i.push((0,Jo.jsx)("path",{d:ti(e,r,t?.depth||30,void 0===t?.width),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return(0,Jo.jsx)("g",{className:"annotation-subject",children:i})}function oi(e,t,n,r,o,i){const s=[];let a=0,l=0;if("callout-circle"!==o&&"label"!==o||!i?.radius){if("callout-rect"===o&&i){const n=i.width||0,r=i.height||0;if(n>0||r>0){const o=n/2,i=r/2,s=e-o,c=t-i;if(0!==s||0!==c){const e=Math.abs(s),t=Math.abs(c),u=n/2,h=r/2,d=e*h>t*u?u/e:h/t;a=o+s*d,l=i+c*d}}}else if("bracket"===o&&i){const e=i.width,t=i.height,n=i.depth||30;void 0!==e?(a=e/2,l=n):void 0!==t&&(a=n,l=t/2)}}else{const n=(i.radius||0)+(i.radiusPadding||0);if(n>0&&(0!==e||0!==t)){const r=Math.atan2(t,e);a=Math.cos(r)*n,l=Math.sin(r)*n}}const c=Math.sqrt((e-a)**2+(t-l)**2);if(c>.5){const o=r||"var(--semiotic-text-secondary, currentColor)",i="curve"===n?.type;let u=Math.atan2(t-l,e-a);if(i){const r=(a+e)/2,i=(l+t)/2,h=-(t-l)/c,d=(e-a)/c,f=(n?.curve??.25)*c,p=r+h*f,y=i+d*f;s.push((0,Jo.jsx)("path",{className:"connector-curve",d:`M${a},${l}Q${p},${y} ${e},${t}`,fill:"none",stroke:o},"connector-line")),u=Math.atan2(y-l,p-a)}else s.push((0,Jo.jsx)("line",{x1:a,y1:l,x2:e,y2:t,stroke:o},"connector-line"));if("arrow"===n?.end){const e=10,t=16/180*Math.PI;s.push((0,Jo.jsx)("path",{d:`M${a},${l}L${a+e*Math.cos(u+t)},${l+e*Math.sin(u+t)}L${a+e*Math.cos(u-t)},${l+e*Math.sin(u-t)}Z`,fill:o,stroke:"none"},"connector-arrow"))}}return(0,Jo.jsx)("g",{className:"annotation-connector",children:s})}function ii(e){const{x:t=0,y:n=0,dx:r,dy:o,nx:i,ny:s,note:a,connector:l,subject:c,type:u,color:h,className:d,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=r||0,k=o||0;null!=i&&(w=i-x),null!=s&&(k=s-b);const S="string"==typeof u?u:"label";if("bracket"===S&&c&&0===w&&0===k)if(void 0!==c.width){w=c.width/2;const e=c.depth||30;k=e+(0>e?-5:5)}else if(void 0!==c.height){const e=c.depth||30;w=e+(0>e?-5:5),k=c.height/2}return(0,Jo.jsxs)("g",{className:("annotation "+(d||"")).trim(),transform:`translate(${x},${b})`,"data-testid":m,...null!=p&&{opacity:p},...y&&{strokeDasharray:y},...g,children:[!v.has("connector")&&oi(w,k,l,h,S,c),!v.has("subject")&&ri(S,c,h,x,b),!v.has("note")&&ni(a,w,k,h)]})}function si(e){const{noteData:t}=e,{screenCoordinates:n}=t,r="string"==typeof t.type?t.type:"label",o=t.eventListeners||t.events||{};if(t.coordinates&&n){const e=t.nx||n[0][0]+(t.dx??0),o=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:o});return(0,Jo.jsx)(ii,{"data-testid":"semiotic-annotation",...s,type:r},"multi-annotation-"+i)});return(0,Jo.jsx)("g",{children:i})}const i=t.note||{title:"none",label:t.label},s=`${i.label}-${i.title}-${t.i}`;return(0,Jo.jsx)(ii,{"data-testid":"semiotic-annotation",events:o,...t,type:r},s)}var ai=require("d3-hierarchy"),li=require("d3-shape");function ci(e){return Math.round(100*e)/100}function ui(e,t=2){const n=[],r=[],o=t+1;for(let t=0;o>t;t++){let i=0;for(const[n,r]of e)null!==r&&(i+=n**t*r);n.push(i);const s=[];for(let n=0;o>n;n++){let r=0;for(const[o,i]of e)null!==i&&(r+=o**(t+n));s.push(r)}r.push(s)}r.push(n);const i=function(e,t){const n=e,r=e.length-1,o=[t];for(let e=0;r>e;e++){let t=e;for(let o=e+1;r>o;o++)Math.abs(n[e][o])>Math.abs(n[e][t])&&(t=o);for(let o=e;r+1>o;o++){const r=n[o][e];n[o][e]=n[o][t],n[o][t]=r}for(let t=e+1;r>t;t++)for(let o=r;o>=e;o--)n[o][t]-=n[o][e]*n[e][t]/n[e][e]}for(let e=r-1;e>=0;e--){let t=0;for(let i=e+1;r>i;i++)t+=n[i][e]*o[i];o[e]=(n[r][e]-t)/n[e][e]}return o}(r,o).map(ci);return{points:e.map(([e])=>[ci(e),ci(i.reduce((t,n,r)=>t+n*e**r,0))]),equation:[...i].reverse()}}function hi(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 di(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 fi(e){return null==e?null:e+""}function pi(e,t,n){return t.stickyPositionCache?.set(e,n),n}function yi(e,t,n){const r=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===r){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let r=n.pointNodes.length-1;r>=0;r--){const o=n.pointNodes[r];if(o.pointId===e.pointId)return pi(t,n,{x:o.x,y:o.y})}const r=function(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],r=e.scales?.x??e.scales?.time,o=e.scales?.y??e.scales?.value;if(!r||!o)return null;const i=n[e.xAccessor||"x"],s=n[e.yAccessor||"y"];return null==i||null==s?null:{x:r(i),y:o(s)}}(n);return r?pi(t,n,r):null}if("semantic"===r){const r=function(e,t,n){const r=function(e){return fi(e.provenance?.stableId??e.stableId)}(e);if(!r)return null;const o=n.pointNodes?.find(e=>fi(e.pointId)===r);if(o)return pi(t,n,{x:o.x,y:o.y});const i=n.data?.find(e=>function(e){return fi(e.stableId??e.id??e.provenance?.stableId)}(e)===r);if(!i)return null;const s=hi(i,n),a=di(i,n);return null==s||null==a?null:pi(t,n,{x:s,y:a})}(e,t,n);if(r)return r}let o=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(o=t.x,i=t.y)}if(null!=o&&null!=i||(o=hi(e,n),i=di(e,n)),null!=o&&null!=i)return pi(t,n,{x:o,y:i});if("sticky"===r){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function gi(e,t,n,r=50){return!(-r>e||e>(n.width||0)+r||-r>t||t>(n.height||0)+r)}var mi=require("react/jsx-runtime"),xi={secondary:0,primary:3},bi=1,vi=2,wi=.6,ki="0.88em",Si=.95,Ai=.72,Mi=.06,_i=".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}}",Pi=".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}";function Ci(e){return!0===e?._annotationDeferred}function ji(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function Ti(e){const t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function Ri(e){return Math.max(Ai,Si-e*Mi)}function Li(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:Ti(e.annotation),readingOrder:null,rank:bi};var n}),n=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>Ci(e.annotation)),o=e.some(e=>null!=ji(e.annotation)),i=e.some(e=>"layer"===ji(e.annotation));if(!n&&!r&&!o)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=vi-t/Math.max(1,s.length)});for(const e of t)e.emphasis&&(e.rank=xi[e.emphasis]);const a=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{const{p:t,i:n,emphasis:r,readingOrder:o}=e,i=Ci(t.annotation);let s=t.node;if("primary"===r||"secondary"===r||null!=o){const e=null==r&&null!=o;s=(0,mi.jsx)("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:wi,fontSize:ki}:{},...e?{opacity:Ri(o),"data-annotation-reading-order":o}:{},children:t.node},"annotation-emphasis-"+n)}const a=ji(t.annotation);return a&&(s=(0,mi.jsx)("g",{className:"annotation-cohesion--"+a,children:s},"annotation-cohesion-"+n)),i&&(s=(0,mi.jsx)("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:s},"annotation-deferred-"+n)),s});return r&&a.unshift((0,mi.jsx)("style",{children:_i},"annotation-disclosure-style")),i&&a.unshift((0,mi.jsx)("style",{children:Pi},"annotation-cohesion-style")),a}x();var $i=c(require("react")),[zi,Di]=bt(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 Oi(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(r){const o=function(e){const t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}(r);t.onAnnotationActivate?.({annotation:e,annotationId:n,chartId:t.chartId,inputType:o}),n&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:n,inputType:o,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}var Ii=require("react/jsx-runtime"),Ei="var(--semiotic-bg, #ffffff)",Bi=.85;function Fi(e){const{x:t,y:n,text:r,fill:o,fontSize:i=12,fontWeight:s,fontFamily:a,textAnchor:l="start",dominantBaseline:c,background:u,className:h}=e,d=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,Ii.jsx)("text",{x:t,y:n,textAnchor:l,dominantBaseline:c,fill:o,fontSize:i,fontWeight:s,fontFamily:a,className:h,...e?{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}:{},children:r});if(!d)return f();if("halo"===d.type)return f({stroke:d.fill??Ei,strokeWidth:d.haloWidth??3});const p=d.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}(r,i),x=i+2*g;let b,v;return b="middle"===l?t-m/2-y:"end"===l?t-m-y:t-y,v="middle"===c||"central"===c?n-x/2:"hanging"===c||"text-before-edge"===c?n-g:n-.8*i-g,(0,Ii.jsxs)("g",{className:h,children:[(0,Ii.jsx)("rect",{x:b,y:v,width:m+2*y,height:x,rx:d.radius??3,ry:d.radius??3,fill:d.fill??Ei,fillOpacity:d.opacity??Bi,stroke:d.stroke,strokeWidth:d.strokeWidth}),f()]})}var Ni=require("react/jsx-runtime"),Wi={linear:li.curveLinear,monotoneX:li.curveMonotoneX,monotoneY:li.curveMonotoneY,step:li.curveStep,stepAfter:li.curveStepAfter,stepBefore:li.curveStepBefore,basis:li.curveBasis,cardinal:li.curveCardinal,catmullRom:li.curveCatmullRom};var Yi=new Set(["label","callout","callout-circle","callout-rect","text","widget"]);function qi(e){return!!e&&"object"==typeof e&&Yi.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}new Set(["label","callout","callout-circle","callout-rect"]);var Gi=2e4,Xi=1;function Hi(e){return"primary"===e?.emphasis||!0===e?.defensive}function Vi(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:Gi))):1/0}function Ui(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const r=e?.provenance?.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(t+=15*Math.max(0,Math.min(1,r))),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 Ki=32,Zi=6,Qi=4,Ji=8,es=72,ts=30,ns=-30,rs=8,os=480,is=3;var ss={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function as(e){if(!ls(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 ls(e){return qi(e)}function cs(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),r=e.split(/\s+/).filter(Boolean),o=[];let i="";for(const e of r)i&&i.length+e.length+1>n?(o.push(i),i=e):i=i?`${i} ${e}`:e;return i&&o.push(i),o}function us(e,t,n,r,o){const i=e+n,s=t+r;return Math.abs(n)>Math.abs(r)?{x:0>n?i-o.width-4:i+4,y:0>r?s-o.height:s,width:o.width,height:o.height}:{x:0>n?i-o.width:i,y:0>r?s-o.height-4:s+4,width:o.width,height:o.height}}function hs(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function ds(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 fs(e,t,n,r,o,i,s,a){const l=hs(e,s);let c=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,r){const o=Math.max(0,r-e.x),i=Math.max(0,r-e.y);return(o+Math.max(0,e.x+e.width-(t-r)))*e.height+(i+Math.max(0,e.y+e.height-(n-r)))*e.width}(l,o,i,a);for(const e of n)c+=12*ds(l,e);for(const e of r)c+=4*ds(l,e);return c}function ps(e){const{annotations:t,context:n,defaultOffset:r=Ki,notePadding:o=Zi,markPadding:i=Qi,edgePadding:s=Ji,preserveManualOffsets:a=!0,routeLongConnectors:l=!0,connectorThreshold:c=es,density:u,progressiveDisclosure:h=!1,redundantCues:d=!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??os,w=!!p&&v>=m,k=w&&!1!==b.preferShortText?t.map(as):t,S=w&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,A=h||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=[],C=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 j=!1;const T=k.map((e,t)=>{if(!ls(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 r=e.pointId??e.nodeId;if(null!=r&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===r);if(e)return{x:e.x,y:e.y}}const o=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(o)&&o.length>=2&&i){const e=o[0],t=o[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?yi(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=[...cs("string"==typeof e.title?e.title:void 0,t),...cs("string"==typeof e.label?e.label:void 0,t)],r=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*r)+10),height:Math.max(18,16*n.length+6)}}(e);if(a&&("number"==typeof(h=e).dx||"number"==typeof h.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:ts,dy:ns}}(e);return P.push(hs(us(i.x,i.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),o)),e}var h;let d=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}]}(r)){const t=fs(us(i.x,i.y,e.dx,e.dy,u),e,P,C,m,x,o,s);f>t&&(d=e,f=t)}if(!d)return e;const p=hs(us(i.x,i.y,d.dx,d.dy,u),o);P.push(p);const y=Math.hypot(d.dx,d.dy),g=l&&y>=c&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return j=!0,{...e,dx:d.dx,dy:d.dy,...g?{connector:g}:{}}}),R=j?T:k.slice();let L=R;if(d){let e=!1;const t=R.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)<rs?e:{...e,_redundantConnector:!0}}(t);return n!==t&&(e=!0),n});L=e?t:R}{let e=!1;const t=L.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?ss[t.source]??t.source:null,r="number"==typeof t.confidence&&Number.isFinite(t.confidence)?Math.round(100*Math.max(0,Math.min(1,t.confidence)))+"%":null;if(!n&&!r)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const o=[n,r].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${o})`)?e:{...e,label:i?`${i} (${o})`:`(${o})`}}(t);return n!==t&&(e=!0),n});L=e?t:L}const $=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 is;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?is: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??Vi(m,x,e))*t))},{deferred:r}=function(e){const{annotations:t,width:n,height:r}=e,o=Math.max(0,e.minVisible??Xi),i=Vi(n,r,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,qi(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||i>=a.length)return{visible:t.slice(),deferred:[],budget:i};const l=a.filter(e=>Hi(e.annotation)),c=a.filter(e=>!Hi(e.annotation)).sort((e,t)=>Ui(t.annotation)-Ui(e.annotation)||e.index-t.index),u=Math.min(c.length,Math.max(Math.max(0,i-l.length),Math.max(0,o-l.length))),h=new Set([...l.map(e=>e.index),...c.slice(0,u).map(e=>e.index)]),d=[],f=[];for(const{annotation:e,index:t,note:n}of s)!n||h.has(t)?d.push(e):f.push(e);return{visible:d,deferred:f,budget:i}}({annotations:L,width:m,height:x,...n});for(const e of r)$.add(e)}if(M&&("object"==typeof M&&"number"==typeof M.minWidth?M.minWidth:os)>=m)for(const e of L)ls(e)&&"secondary"===e.emphasis&&$.add(e);if($.size>0)for(const e of L)!0===e?.defensive&&$.delete(e);let z;return z=0===$.size?L:A?L.map(e=>$.has(e)?{...e,_annotationDeferred:!0}:e):L.filter(e=>!$.has(e)),_?function(e,t){let n=!1;const r=e.map(e=>ls(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?r:e}(z,_):z}function ys(e,t={}){const n=!0===t.showRetractedAnnotations,r=!0===t.showSupersededAnnotations,o=new Set;for(const t of e){const e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&o.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!n)return!1;const t=e?.provenance?.stableId;return!(t&&o.has(t)&&!r)})}var gs=require("react"),ms={positions:new Map},xs=new Set;function bs(){for(const e of xs)e()}function vs(e,t){const n=ms.positions.get(e);if(n?.locked)return;if(!n||n.sourceId!==t)return;const r=new Map(ms.positions);r.delete(e),ms={positions:r},bs()}function ws(e,t){const n=ms.positions.get(e);if(!n?.locked)return;if(t&&n.sourceId!==t)return;const r=new Map(ms.positions);r.delete(e),ms={positions:r},bs()}function ks(){return ms}function Ss(e){return xs.add(e),()=>xs.delete(e)}var As={positions:new Map};function Ms(){return()=>{}}function _s(){return As}function Ps(e,t,n){return"exact"===n?function(e,t){const n=e.domain(),r=n[0],o=n[n.length-1],i=r instanceof Date,s=r instanceof Date?r.getTime():r,a=o instanceof Date?o.getTime():o;if(2>t||s===a)return i?[new Date(s),new Date(a)]:[s,a];const l=(a-s)/(t-1),c=Array(t);for(let e=0;t>e;e++){const n=e===t-1?a:s+e*l;c[e]=i?new Date(n):n}return c}(e,t):e.ticks(t)}function Cs(e,t,n){if("edges"===e){if(t)return"start";if(n)return"end"}return"middle"}function js(e,t,n){if("edges"===e){if(t)return"hanging";if(n)return"auto"}return"middle"}function Ts(e){if(0===e.length)return{min:null,max:null};let t=1/0,n=-1/0;for(const r of e)t>r.pixel&&(t=r.pixel),r.pixel>n&&(n=r.pixel);return{min:t,max:n}}function Rs(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Ls(e,t,n){if("left"===e||"right"===e){const r="left"===e?n:0,o="left"===e?-1:1,i=Math.ceil(t/8);let s="M0,"+r;for(let e=0;i>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${r+4*o}`,s+=`L${Math.min(n,t)},${r}`}return s}const r="bottom"===e?0:t,o="bottom"===e?1:-1,i=Math.ceil(n/8);let s=`M${r},0`;for(let e=0;i>e;e++){const t=8*(e+1);s+=`L${r+4*o},${Math.min(8*e+4,n)}`,s+=`L${r},${Math.min(t,n)}`}return s}var $s=36,zs=34,Ds=58,Os=22;function Is(e){return"string"==typeof e&&e.length>0}function Es(e,t,n=!1){const r=n?t?Ds:zs:t?$s:0;return r>e.top?{...e,top:r}:e}function Bs(e,t){return Es(e,Is(t))}var Fs=require("react/jsx-runtime");function Ns(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,scales:s,showAxes:a,axes:l,showGrid:c,xFormat:u,yFormat:h,axisExtent:d}=e,f=(0,_o.useMemo)(()=>{if(!s)return[];const e=l?.find(e=>"bottom"===e.orient),n=e?.tickFormat||u||Ws,r=Math.max(2,Math.floor(t/70)),o=e?.ticks??5,i="exact"===d?Math.max(2,o):Math.min(o,r),a=e?.tickValues??Ps(s.x,i,d),c=a.map(e=>e.valueOf()),h=a.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,c)})),f=h.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 Ys(h,Math.max(55,f+8))},[s,l,u,t,d]),p=(0,_o.useMemo)(()=>{if(!s)return[];const e=l?.find(e=>"left"===e.orient),t=e?.tickFormat||h||Ws,r=Math.max(2,Math.floor(n/30)),o=e?.ticks??5,i="exact"===d?Math.max(2,o):Math.min(o,r);return Ys((e?.tickValues??Ps(s.y,i,d)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[s,l,h,n,d]),y=c&&s,g=a&&s;if(!y&&!g)return null;const m=l?.find(e=>"bottom"===e.orient),x=l?.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,Fs.jsx)("svg",{width:r,height:o,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:(0,Fs.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[y&&(()=>{const e=Rs(l?.find(e=>"bottom"===e.orient)?.gridStyle),r=Rs(l?.find(e=>"left"===e.orient)?.gridStyle);return(0,Fs.jsxs)("g",{className:"stream-grid",children:[f.map((t,r)=>(0,Fs.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+r)),p.map((e,n)=>(0,Fs.jsx)("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),b&&!w&&(0,Fs.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:S,strokeWidth:1}),w&&(0,Fs.jsx)("path",{d:Ls("bottom",t,n),fill:"none",stroke:S,strokeWidth:1}),v&&!k&&(0,Fs.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:S,strokeWidth:1}),k&&(0,Fs.jsx)("path",{d:Ls("left",t,n),fill:"none",stroke:S,strokeWidth:1})]})})}function Ws(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function Ys(e,t){if(2>=e.length)return e;const n=[e[0]];for(let r=1;e.length-1>r;r++)t>Math.abs(e[r].pixel-n[n.length-1].pixel)||n.push(e[r]);const r=e[e.length-1];return t>Math.abs(r.pixel-n[n.length-1].pixel)?n[n.length-1]=r:n.push(r),n}function qs(e){const{width:t,height:n,totalWidth:r,totalHeight:o,margin:i,scales:s,showAxes:a,axes:l,xLabel:c,yLabel:h,yLabelRight:d,xFormat:f,yFormat:p,axisExtent:y,showGrid:g,title:m,legend:x,legendHoverBehavior:b,legendClickBehavior:v,legendHighlightedCategory:w,legendIsolatedCategories:k,legendPosition:S="right",legendLayout:A,foregroundGraphics:M,marginalGraphics:_,xValues:P,yValues:C,annotations:j,onAnnotationActivate:T,onObservation:R,chartId:L,chartType:$,autoPlaceAnnotations:z,svgAnnotationRules:D,xAccessor:O,yAccessor:I,annotationData:E,pointNodes:B,curve:F,underlayRendered:N,canvasObscuresUnderlay:W=!0,linkedCrosshairName:Y,linkedCrosshairSourceId:q,children:G}=e,X=function(e){const t=Di(e=>e.pushObservation),n=$i.useCallback(n=>{e.onObservation?.(n),t?.(n)},[e,t]);return $i.useMemo(()=>({...e,onObservation:n}),[n,e])}({onAnnotationActivate:T,onObservation:R,chartId:L,chartType:$}),H=(0,_o.useMemo)(()=>{if(!a||!s)return[];const e=l?.find(e=>"bottom"===e.orient),n=e?.tickFormat||f||Ws,r=Math.max(2,Math.floor(t/70)),o=e?.ticks??5,i="exact"===y?Math.max(2,o):Math.min(o,r),c=e?.tickValues??Ps(s.x,i,y),u=c.map(e=>e.valueOf()),h=c.map((e,t)=>({value:e,pixel:s.x(e),label:n(e,t,u)})),d=h.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),p=e?.autoRotate?Math.max(20,Math.min(d+8,55)):Math.max(55,d+8);let g=Ys(h,p);if(g.length>1&&(g=g.filter((e,t)=>0===t||e.label+""!=g[t-1].label+"")),e?.includeMax&&g.length>0&&"exact"!==y&&!e?.tickValues){const e=s.x.domain()[1],t=s.x(e),r=g[g.length-1].pixel;if(Math.abs(t-r)>1){const o=n(e,g.length,u);p>t-r&&g.length>1&&(g=g.slice(0,-1)),g.push({value:e,pixel:t,label:o})}}return g},[a,s,l,f,t,y]),V=(0,_o.useMemo)(()=>{if(!a||!s)return[];const e=l?.find(e=>"left"===e.orient),t=e?.tickFormat||p||Ws,r=Math.max(2,Math.floor(n/30)),o=e?.ticks??5,i="exact"===y?Math.max(2,o):Math.min(o,r);let c=Ys((e?.tickValues??Ps(s.y,i,y)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22);if(c.length>1&&(c=c.filter((e,t)=>0===t||e.label+""!=c[t-1].label+"")),e?.includeMax&&c.length>0&&"exact"!==y&&!e?.tickValues){const e=s.y.domain()[1],n=s.y(e),r=c[c.length-1].pixel;if(Math.abs(n-r)>1){const o=t(e);22>Math.abs(n-r)&&c.length>1&&(c=c.slice(0,-1)),c.push({value:e,pixel:n,label:o})}}return c},[a,s,l,p,n,y]),U=(0,_o.useMemo)(()=>{if(!a||!s)return[];const e=l?.find(e=>"right"===e.orient);if(!e)return[];const t=e.tickFormat||p||Ws,r=Math.max(2,Math.floor(n/30)),o=e.ticks??5;return Ys((e.tickValues??Ps(s.y,"exact"===y?Math.max(2,o):Math.min(o,r),y)).map(e=>({value:e,pixel:s.y(e),label:t(e)})),22)},[a,s,l,p,n,y]),K=(0,_o.useRef)(new Map),Z=(0,_o.useRef)(j?.length??0),Q=j?.length??0;Z.current!==Q&&(Z.current=Q,K.current=new Map);const J=(0,_o.useMemo)(()=>{if(!j||0===j.length)return null;const e=ys(j),r=function(e,t={}){return function(e,n,r){switch(e.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const t=yi(e,n,r);if(!t)return null;const{x:o,y:i}=t;if(!gi(o,i,r))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,Ni.jsx)(si,{noteData:{x:o,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=hi(null!=e.value?{...e,x:e.value}:e,r);if(null==t)return null;const o=e.color||"#f97316",i=e.labelPosition||"top";let s;s="bottom"===i?(r.height||0)-4:"center"===i?(r.height||0)/2:16;const a=t>.6*(r.width||0),l=a?t-4:t+4,c=a?"end":"start";return(0,Ni.jsxs)("g",{opacity:e.opacity,children:[(0,Ni.jsx)("line",{x1:t,y1:0,x2:t,y2:r.height||0,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Ni.jsx)(Fi,{x:l,y:s,text:e.label,textAnchor:c,fill:o,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"y-threshold":{const t=di(null!=e.value?{...e,y:e.value}:e,r);if(null==t)return null;const o=e.color||"#f97316",i=e.labelPosition||"right";let a,l;"left"===i?(a=4,l="start"):"center"===i?(a=(r.width||0)/2,l="middle"):(a=(r.width||0)-4,l="end");const c=20>(s=t)?Math.min((r.height||0)-4,s+16):s-4;return(0,Ni.jsxs)("g",{opacity:e.opacity,children:[(0,Ni.jsx)("line",{x1:0,y1:t,x2:r.width||0,y2:t,stroke:o,strokeWidth:e.strokeWidth||1.5,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Ni.jsx)(Fi,{x:a,y:c,text:e.label,textAnchor:l,fill:o,fontSize:12,fontWeight:"bold",background:e.labelBackground??"halo"})]},"ann-"+n)}case"enclose":{const t=(e.coordinates||[]).map(e=>({x:hi({...e,type:"point"},r),y:di({...e,type:"point"},r),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const o=(0,ai.packEnclose)(t),i=e.padding||10;return(0,Ni.jsxs)("g",{children:[(0,Ni.jsx)("circle",{cx:o.x,cy:o.y,r:o.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,Ni.jsx)(Fi,{x:o.x,y:o.y-o.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:hi({...e,type:"point"},r),y:di({...e,type:"point"},r)})).filter(e=>null!=e.x&&null!=e.y);if(2>t.length)return null;const o=e.padding||10,i=t.map(e=>e.x),s=t.map(e=>e.y),[a,l]=u(i),[c,h]=u(s),d=a-o,f=l+o,p=c-o;return(0,Ni.jsxs)("g",{children:[(0,Ni.jsx)("rect",{x:d,y:p,width:f-d,height:h+o-p,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,Ni.jsx)(Fi,{x:(d+f)/2,y:p-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=r.data||[],o="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,Ni.jsx)("g",{children:o.map((t,n)=>{const o=hi(t,r),s=di(t,r);if(null==o||null==s)return null;const a="function"==typeof e.r?e.r(t):e.r||6,l="function"==typeof e.style?e.style(t):e.style||i;return(0,Ni.jsx)("circle",{cx:o,cy:s,r:a,...l},"hl-"+n)})},"ann-"+n)}case"bracket":{const t=hi(e,r),o=di(e,r);return(0,Ni.jsx)(si,{noteData:{x:t??0,y:o??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=r.data||[];if(2>t.length)return null;const o=r.xAccessor||"x",i=r.yAccessor||"y",s="ordinal"===r.frameType,a="horizontal"===r.projection,l=s?o:null,c=s?i:null;let u;const h=[],d=new Map;if(s&&l&&c){for(const e of t){const t=e[l];if(null==t)continue;const n=t+"";d.has(n)||(d.set(n,h.length),h.push(n))}u=t.map(e=>{const t=e[l],n=e[c];if(null==t||null==n)return null;const r=d.get(t+"");return null!=r?[r,+n]:null}).filter(e=>null!==e)}else u=t.map(e=>[e[o],e[i]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>u.length)return null;const f=r.scales?.x??r.scales?.time,p=r.scales?.y??r.scales?.value;if(!f||!p)return null;const y=e=>t=>{const n=Math.max(0,Math.floor(t)),r=Math.min(h.length-1,n+1),o=t-n,i=e(h[n]);return i+(e(h[r])-i)*o},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 r=e.slice().sort((e,t)=>e[0]-t[0]),o=r.map(e=>e[0]),i=r.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=o[e],r=o.map(e=>Math.abs(e-t)),l=r.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:r[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,h=0,d=0,f=0,p=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,h+=t*o[e],d+=t*i[e],f+=t*o[e]*o[e],p+=t*o[e]*i[e])}if(0===u){a.push([t,i[e]]);continue}const y=u*f-h*h;if(1e-12>Math.abs(y))a.push([t,d/u]);else{const e=(u*p-h*d)/y;a.push([t,(d-e*h)/u+e*t])}}return a}(u,e.bandwidth??.3);else{const t="polynomial"===b?ui(u,e.order||2):function(e){const t=[0,0,0,0];let n=0;for(const[r,o]of e)null!==o&&(n++,t[0]+=r,t[1]+=o,t[2]+=r*r,t[3]+=r*o);const r=n*t[2]-t[0]*t[0],o=0===r?0:ci((n*t[3]-t[0]*t[1])/r),i=ci(t[1]/n-o*t[0]/n);return{points:e.map(([e])=>[ci(e),ci(o*e+i)]),equation:[o,i]}}(u);v=t.points}const w=v.map(([e,t])=>{const[n,r]=x(e,t);return`${n},${r}`}).join(" "),k=e.color||"#6366f1",S=v[v.length-1],[A,M]=x(S[0],S[1]);return(0,Ni.jsxs)("g",{children:[(0,Ni.jsx)("polyline",{points:w,fill:"none",stroke:k,strokeWidth:e.strokeWidth||2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&(0,Ni.jsx)("text",{x:A+4,y:M-4,fill:k,fontSize:11,children:e.label})]},"ann-"+n)}case"band":{const t=r.scales?.y??r.scales?.value,s=t?.domain?.(),a=e.y0??s?.[0],l=e.y1??s?.[1],c=null!=a&&t?t(a):0,u=null!=l&&t?t(l):r.height||0,h=Qr(e.fill,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,Ni.jsxs)("g",{opacity:e.opacity,children:[h.def&&(0,Ni.jsx)("defs",{children:h.def}),(0,Ni.jsx)("rect",{x:0,y:Math.min(c,u),width:r.width||0,height:Math.abs(u-c),fill:h.fill,fillOpacity:e.fillOpacity||.1}),e.label&&(0,Ni.jsx)(Fi,{x:(r.width||0)-4,y:(o=c,i=u,Math.max(Math.min(o,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=r.scales?.x??r.scales?.time,o=t?.domain?.(),i=e.x0??o?.[0],s=e.x1??o?.[1],a=null!=i&&t?t(i):null,l=null!=s&&t?t(s):null;if(null==a||null==l)return null;const c=Qr(e.fill||e.color,"ann-"+n,"var(--semiotic-primary, #6366f1)");return(0,Ni.jsxs)("g",{opacity:e.opacity,children:[c.def&&(0,Ni.jsx)("defs",{children:c.def}),(0,Ni.jsx)("rect",{x:Math.min(a,l),y:0,width:Math.abs(l-a),height:r.height||0,fill:c.fill,fillOpacity:e.fillOpacity??.1}),e.label&&(0,Ni.jsx)(Fi,{x:Math.min(a,l)+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=r.data||[];if(2>t.length)return null;const o=r.xAccessor||"x",i=r.scales?.x??r.scales?.time,s=r.scales?.y??r.scales?.value;if(!i||!s)return null;const a=e.upperAccessor||"upperBounds",l=e.lowerAccessor||"lowerBounds",c=e.filter,u=t.filter(e=>null!=e[a]&&null!=e[l]&&!(c&&!c(e))).sort((e,t)=>e[o]-t[o]);if(2>u.length)return null;const h=Wi[r.curve||"linear"]||li.curveLinear,d=(0,li.area)().x(e=>i(e[o])).y0(e=>s(e[l])).y1(e=>s(e[a])).curve(h)(u);if(!d)return null;const f=e.fill||"#6366f1";return(0,Ni.jsxs)("g",{children:[(0,Ni.jsx)("path",{d:d,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&u.length>0&&(0,Ni.jsx)("text",{x:i(u[u.length-1][o])+4,y:s(u[u.length-1][a])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+n)}case"anomaly-band":{const t=r.data||[];if(2>t.length)return null;const o=r.yAccessor||"y",i=r.scales?.x??r.scales?.time,s=r.scales?.y??r.scales?.value;if(!i||!s)return null;const a=t.map(e=>e[o]).filter(e=>null!=e&&isFinite(e));if(2>a.length)return null;const l=a.reduce((e,t)=>e+t,0)/a.length,c=a.reduce((e,t)=>e+(t-l)**2,0)/a.length,u=Math.sqrt(c),h=e.threshold??2,d=l-h*u,f=!1!==e.showBand,p=e.fill||"#6366f1",y=e.fillOpacity??.1,g=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,x=s(l+h*u),b=s(d),v=t.filter(e=>{const t=e[o];return null!=t&&Math.abs(t-l)>h*u});return(0,Ni.jsxs)("g",{children:[f&&(0,Ni.jsx)("rect",{x:0,y:Math.min(x,b),width:r.width||0,height:Math.abs(b-x),fill:p,fillOpacity:y}),v.map((e,t)=>{const n=hi(e,r),o=di(e,r);return null==n||null==o?null:(0,Ni.jsx)("circle",{cx:n,cy:o,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+t)}),e.label&&(0,Ni.jsx)("text",{x:(r.width||0)-4,y:Math.min(x,b)-4,textAnchor:"end",fill:p,fontSize:11,children:e.label})]},"ann-"+n)}case"forecast":{const t=r.data||[];if(3>t.length)return null;const o=r.xAccessor||"x",i=r.yAccessor||"y",s=r.scales?.x??r.scales?.time,a=r.scales?.y??r.scales?.value;if(!s||!a)return null;const l=t.map(e=>[e[o],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>l.length)return null;let c;if("polynomial"===(e.method||"linear")){const t=ui(l,e.order||2).equation;c=e=>t.reduce((t,n,r)=>t+n*Math.pow(e,r),0)}else{const e=l.length;let t=0,n=0,r=0,o=0;for(const[e,i]of l)t+=e,n+=i,r+=e*e,o+=e*i;const i=e*r-t*t;if(1e-12>Math.abs(i))return null;const s=(e*o-t*n)/i,a=(n-s*t)/e;c=e=>a+s*e}const u=l.length,h=l.map(([e,t])=>t-c(e)),d=h.reduce((e,t)=>e+t*t,0),f=Math.sqrt(d/Math.max(u-2,1)),p=l.reduce((e,t)=>e+t[0],0)/u,y=l.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=l[u-1][0],v=(b-l[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=c(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(c(b))}`,_=e.strokeColor||"#6366f1";return(0,Ni.jsxs)("g",{children:[(0,Ni.jsx)("path",{d:S,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),(0,Ni.jsx)("polyline",{points:`${M} ${A}`,fill:"none",stroke:_,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&k.length>0&&(0,Ni.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 o,i;if(null!=e.px&&null!=e.py)o=e.px,i=e.py;else{const t=yi(e,n,r);if(!t)return null;o=t.x,i=t.y}if(!gi(o,i,r))return null;const s=e.dx??0,a=e.dy??0,l=e.width??32,c=e.height??32,u=e.content??(0,Ni.jsx)("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return(0,Ni.jsx)("foreignObject",{x:o+s-l/2,y:i+a-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:(0,Ni.jsx)("div",{...Oi(e,t),style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const t=yi(e,n,r);if(!t)return null;const{x:o,y:i}=t,s=o+(e.dx||0),a=i+(e.dy||0),l=e.color||"var(--semiotic-text, #333)",c=(0,Ni.jsx)("text",{x:s,y:a,fill:l,fontSize:e.fontSize||11,opacity:e.opacity,strokeDasharray:e.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:e.label});return!0!==e._redundantConnector?Qo.cloneElement(c,{key:"ann-text-"+n}):(0,Ni.jsxs)("g",{opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:[(0,Ni.jsx)("line",{x1:o,y1:i,x2:s,y2:a,stroke:l,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),Qo.cloneElement(c,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+n)}case"category-highlight":{const t=e.category;if(null==t)return null;const o=e=>"function"==typeof e&&"function"==typeof e.bandwidth,i=r.scales?.o,s=r.scales?.x,a=r.scales?.y,l=o(i)?i:o(s)?s:o(a)?a:null;if(!l)return null;const c=l(t+"");if(null==c)return null;const u=l.bandwidth(),h=e.color||"var(--semiotic-primary, #4589ff)",d=e.opacity??.15,f=e.label;return(0,Ni.jsxs)("g",(r.projection?"vertical"===r.projection:l===s)?{children:[(0,Ni.jsx)("rect",{x:c,y:0,width:u,height:r.height||0,fill:h,fillOpacity:d}),f&&(0,Ni.jsx)(Fi,{x:c+u/2,y:16,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]}:{children:[(0,Ni.jsx)("rect",{x:0,y:c,width:r.width||0,height:u,fill:h,fillOpacity:d}),f&&(0,Ni.jsx)(Fi,{x:12,y:c+u/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",text:f,background:e.labelBackground??"none"})]},"ann-"+n)}default:return null}var o,i,s}}(0,X),o={scales:s?{x:s.x,y:s.y,time:s.x,value:s.y}:null,timeAxis:"x",xAccessor:O,yAccessor:I,width:t,height:n,data:E,frameType:"xy",pointNodes:B,curve:F,stickyPositionCache:K.current};return function(e,t,n,r){const o=[];return e.forEach((e,i)=>{let s;if(n){const o=n(e,i,r);s=null!=o?o:t(e,i,r)}else s=t(e,i,r);s&&o.push({node:s,annotation:e})}),Li(o)}(z?ps({annotations:e,context:o,..."object"==typeof z?z:{}}):e,r,D,o)},[j,z,D,t,n,O,I,E,s,B,F,X]),ee=function(e){const t=(0,gs.useSyncExternalStore)(e?Ss:Ms,e?ks:_s,e?ks:_s);return e?t.positions.get(e)??null:null}(Y);return(0,_o.useEffect)(()=>{if(!ee?.locked||!Y)return;const e=e=>{"Escape"===e.key&&ws(Y)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[ee?.locked,Y]),a||m||x||M||_||J&&J.length>0||g||G||ee?(0,Fs.jsxs)("svg",{role:"img",width:r,height:o,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[(0,Fs.jsx)("title",{children:"string"==typeof m?m:"XY Chart"}),(0,Fs.jsx)("desc",{children:"string"==typeof m?m+" (XY data visualization)":"XY data visualization"}),(0,Fs.jsxs)("g",{transform:`translate(${i.left},${i.top})`,children:[g&&s&&(!N||W)&&(()=>{const e=Rs(l?.find(e=>"bottom"===e.orient)?.gridStyle),r=Rs(l?.find(e=>"left"===e.orient)?.gridStyle);return(0,Fs.jsxs)("g",{className:"stream-grid",children:[H.map((t,r)=>(0,Fs.jsx)("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:n,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:e},"xgrid-"+r)),V.map((e,n)=>(0,Fs.jsx)("line",{x1:0,y1:e.pixel,x2:t,y2:e.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"ygrid-"+n))]})})(),a&&s&&(()=>{const e=l?.find(e=>"left"===e.orient),r=l?.find(e=>"bottom"===e.orient),o=!e||!1!==e.baseline,s=!r||!1!==r.baseline,a=e?.jaggedBase||!1,u=r?.jaggedBase||!1,f=r?.landmarkTicks,p=e?.landmarkTicks,y="var(--semiotic-border, #ccc)",g="var(--semiotic-text-secondary, var(--semiotic-text, #666))",m="var(--semiotic-text, #333)",x=!!r?.autoRotate&&H.length>1&&(()=>{const e=t/Math.max(H.length-1,1);return H.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})(),b=x?12:18,v=n+(x?58:40),w={fontSize:"var(--semiotic-tick-font-size, 12px)"},k={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},S={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},A=r?.tickAnchor,M=e?.tickAnchor,_=Ts(H),P=Ts(V);return(0,Fs.jsxs)("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[(0,Fs.jsxs)("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!N||W)&&s&&!u&&(0,Fs.jsx)("line",{x1:0,y1:n,x2:t,y2:n,stroke:y,strokeWidth:1}),(!N||W)&&u&&(0,Fs.jsx)("path",{d:Ls("bottom",t,n),fill:"none",stroke:y,strokeWidth:1}),H.map((e,t)=>{const r=!!f&&("function"==typeof f?f(e.value,t):jr(e.value,t>0?H[t-1].value:void 0));return(0,Fs.jsxs)("g",{transform:`translate(${e.pixel},${n})`,children:[(0,Fs.jsx)("line",{y2:5,stroke:y,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Fs.jsx)("text",{y:b,textAnchor:x?"end":Cs(A,e.pixel===_.min,e.pixel===_.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?k:w},transform:x?"rotate(-45)":void 0,children:e.label}):(0,Fs.jsx)("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:(0,Fs.jsx)("div",{style:{textAlign:"center",userSelect:"none",...w},children:e.label})})]},"xtick-"+t)}),c&&(0,Fs.jsx)("text",{x:t/2,y:v,textAnchor:"middle",fill:m,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:c})]}),(0,Fs.jsxs)("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!N||W)&&o&&!a&&(0,Fs.jsx)("line",{x1:0,y1:0,x2:0,y2:n,stroke:y,strokeWidth:1}),(!N||W)&&a&&(0,Fs.jsx)("path",{d:Ls("left",t,n),fill:"none",stroke:y,strokeWidth:1}),V.map((e,t)=>{const n=!!p&&("function"==typeof p?p(e.value,t):jr(e.value,t>0?V[t-1].value:void 0));return(0,Fs.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,Fs.jsx)("line",{x2:-5,stroke:y,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Fs.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:js(M,e.pixel===P.min,e.pixel===P.max),fontWeight:n?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...n?k:w},children:e.label}):(0,Fs.jsx)("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,Fs.jsx)("div",{style:{textAlign:"right",userSelect:"none",...w},children:e.label})})]},"ytick-"+t)}),(()=>{const t=e?.label||h;return t?(0,Fs.jsx)("text",{x:15-i.left,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(-90, ${15-i.left}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:t}):null})()]}),(()=>{const e=l?.find(e=>"right"===e.orient);if(!e||0===U.length)return null;const r=!1!==e.baseline,o=e.landmarkTicks,s=e.label||d,a=e.tickAnchor,c=Ts(U);return(0,Fs.jsxs)("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[r&&(0,Fs.jsx)("line",{x1:t,y1:0,x2:t,y2:n,stroke:y,strokeWidth:1}),U.map((e,n)=>{const r=!!o&&("function"==typeof o?o(e.value,n):jr(e.value,n>0?U[n-1].value:void 0));return(0,Fs.jsxs)("g",{transform:`translate(${t},${e.pixel})`,children:[(0,Fs.jsx)("line",{x2:5,stroke:y,strokeWidth:1}),"string"==typeof e.label||"number"==typeof e.label?(0,Fs.jsx)("text",{x:8,textAnchor:"start",dominantBaseline:js(a,e.pixel===c.min,e.pixel===c.max),fontWeight:r?600:400,fill:g,className:"semiotic-axis-tick",style:{userSelect:"none",...r?k:w},children:e.label}):(0,Fs.jsx)("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:(0,Fs.jsx)("div",{style:{textAlign:"left",userSelect:"none",...w},children:e.label})})]},"ytick-r-"+n)}),s&&(0,Fs.jsx)("text",{x:t+i.right-15,y:n/2,textAnchor:"middle",fill:m,transform:`rotate(90, ${t+i.right-15}, ${n/2})`,className:"semiotic-axis-label",style:{userSelect:"none",...S},children:s})]})})()]})})(),J,_&&s&&P&&C&&(0,Fs.jsxs)(Fs.Fragment,{children:[_.top&&(0,Fs.jsx)("g",{transform:"translate(0, 0)",children:(0,Fs.jsx)(Zo,{orient:"top",config:Ko(_.top),values:P,scale:s.x,size:i.top,length:t})}),_.bottom&&(0,Fs.jsx)("g",{transform:`translate(0, ${n})`,children:(0,Fs.jsx)(Zo,{orient:"bottom",config:Ko(_.bottom),values:P,scale:s.x,size:i.bottom,length:t})}),_.left&&(0,Fs.jsx)("g",{transform:"translate(0, 0)",children:(0,Fs.jsx)(Zo,{orient:"left",config:Ko(_.left),values:C,scale:s.y,size:i.left,length:n})}),_.right&&(0,Fs.jsx)("g",{transform:`translate(${t}, 0)`,children:(0,Fs.jsx)(Zo,{orient:"right",config:Ko(_.right),values:C,scale:s.y,size:i.right,length:n})})]}),M,ee&&ee.sourceId!==q&&s?.x&&(()=>{const e=s.x(ee.xValue);if(null==e||0>e||e>t)return null;const r=ee.locked;return(0,Fs.jsx)("line",{x1:e,y1:0,x2:e,y2:n,stroke:r?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:r?1.5:1,strokeDasharray:r?"6,3":"4,4",pointerEvents:"none"})})(),G]}),m&&"string"==typeof m?(0,Fs.jsx)("text",{x:r/2,y:Os,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:m}):m?(0,Fs.jsx)("foreignObject",{x:0,y:0,width:r,height:i.top,children:m}):null,Xo({legend:x,totalWidth:r,totalHeight:o,margin:i,legendPosition:S,title:m,legendLayout:A,legendHoverBehavior:b,legendClickBehavior:v,legendHighlightedCategory:w,legendIsolatedCategories:k})]}):null}var Gs=c(require("react")),Xs=require("d3-shape");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,r=e=>Math.max(0,Math.min(e??0,n));return{tl:r(t.tl),tr:r(t.tr),br:r(t.br),bl:r(t.bl)}}var Us=require("react/jsx-runtime"),Ks={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Zs(e,t="#4e79a7"){return Vr(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function Qs(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}function Js(e,t,n,r){const o=e.glyph;if(!o?.parts?.length||0>=e.size)return null;const i=Lr(o,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),l=Or(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),c=l?Qs(r+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),h=t=>o.parts.map((n,r)=>{const o=t?"none"===n.fill?void 0:t:$r(n.fill,a,e.accent),i=t?n.stroke&&"none"!==n.stroke?t:void 0:$r(n.stroke??"none",a,e.accent);return o||i?(0,Us.jsx)("path",{d:n.d,fill:o??"none",stroke:i,strokeWidth:i?n.strokeWidth??1:void 0,strokeLinecap:n.strokeLinecap,strokeLinejoin:n.strokeLinejoin,opacity:n.opacity},r):null});return(0,Us.jsxs)("g",{transform:s,opacity:1===u?void 0:u,children:[l&&c&&(0,Us.jsx)("clipPath",{id:c,children:(0,Us.jsx)("rect",{x:l.x,y:l.y,width:l.width,height:l.height})}),l&&e.ghostColor?(0,Us.jsx)("g",{children:h(e.ghostColor)}):null,l&&c?(0,Us.jsx)("g",{clipPath:`url(#${c})`,children:h()}):h()]},r)}function ea(e){const t=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));return 2>t.length?null:t.map((e,t)=>(0,Us.jsx)("stop",{offset:e.offset,stopColor:e.color},t))}function ta(e,t,n){const r=mn(e.symbolType,e.size,e.path);return(0,Us.jsx)("path",{d:r,transform:e.rotation?`translate(${e.x},${e.y}) rotate(${180*e.rotation/Math.PI})`:`translate(${e.x},${e.y})`,fill:e.style.fill?Zs(e.style.fill):"none",fillOpacity:e.style.fillOpacity,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${n??""}symbol-${t}`)}var na=c(require("react")),ra=require("d3-shape"),oa=require("react/jsx-runtime"),ia=c(require("react")),sa=require("react/jsx-runtime"),aa=c(require("react")),la=require("d3-shape"),ca=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)});function ua(e){const{innerRadius:t,outerRadius:n,startAngle:r,endAngle:o}=e,i=0>=t;if(0>=(e.cornerRadius??0)||!e.roundStart&&!e.roundEnd){if(i){const e=ca(n,r),t=ca(n,o);return`M0,0 L${e.x},${e.y} A${n},${n} 0 ${o-r>Math.PI?1:0} 1 ${t.x},${t.y} Z`}const e=ca(n,r),s=ca(n,o),a=ca(t,o),l=ca(t,r),c=o-r>Math.PI?1:0;return`M${e.x},${e.y} A${n},${n} 0 ${c} 1 ${s.x},${s.y} L${a.x},${a.y} A${t},${t} 0 ${c} 0 ${l.x},${l.y} Z`}const s=Math.max(0,Math.min(e.cornerRadius??0,(n-t)/2));if(0===s)return ua({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const a=Math.asin(Math.min(1,s/Math.max(1e-9,n-s))),l=i?0:Math.asin(Math.min(1,s/Math.max(1e-9,t+s))),c=o-r,u=e.roundStart&&e.roundEnd?c/2:c,h=!!e.roundStart&&u>a,d=!!e.roundEnd&&u>a;if(!h&&!d)return ua({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});const f=r+(h?a:0),p=o-(d?a:0),y=r+(h?l:0),g=o-(d?l:0),m=ca(n,f),x=ca(n,p),b=(n-s)*Math.cos(a),v=ca(b,r),w=ca(b,o),k=i?null:ca(t,g),S=i?null:ca(t,y),A=i?0:(t+s)*Math.cos(l),M=i?null:ca(A,r),_=i?null:ca(A,o),P=p-f>Math.PI?1:0,C=i?0:g-y>Math.PI?1:0;let j="";if(h)j+=`M${v.x},${v.y}`,j+=` A${s},${s} 0 0 1 ${m.x},${m.y}`;else{const e=ca(n,r);j+=`M${e.x},${e.y}`}if(d)j+=` A${n},${n} 0 ${P} 1 ${x.x},${x.y}`,j+=` A${s},${s} 0 0 1 ${w.x},${w.y}`;else{const e=ca(n,o);j+=` A${n},${n} 0 ${P} 1 ${e.x},${e.y}`}if(i)j+=" L0,0";else{if(d)j+=` L${_.x},${_.y}`,j+=` A${s},${s} 0 0 1 ${k.x},${k.y}`;else{const e=ca(t,o);j+=` L${e.x},${e.y}`}if(h)j+=` A${t},${t} 0 ${C} 0 ${S.x},${S.y}`,j+=` A${s},${s} 0 0 1 ${M.x},${M.y}`;else{const e=ca(t,r);j+=` A${t},${t} 0 ${C} 0 ${e.x},${e.y}`}}return j+=" Z",j}var ha=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 fa(e,t){const n=e.datum;if(!n)return null;const r=[],o=n.__funnelStepLabel,i=Number(n.__funnelStepLabelX),s=Number(n.__funnelStepLabelY),a=Number(n.__funnelRowWidth);"string"!=typeof o||!Number.isFinite(i)||!Number.isFinite(s)||Number.isFinite(a)&&8.4*o.length+16>a||r.push((0,ha.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:o},t+"-funnel-step"));const l=Number(n.__funnelValue),c=Number(n.__funnelValueLabelX),u=Number(n.__funnelValueLabelY),h=Number(n.__funnelBarW);if(Number.isFinite(l)&&0!==l&&Number.isFinite(c)&&Number.isFinite(u)&&h>=60){const e=Number(n.__funnelPercent);let o=!0!==n.__funnelIsFirstStep&&Number.isFinite(e)?`${da(l)} (${.05>Math.abs(e-Math.round(e))?Math.round(e):e.toFixed(1)}%)`:da(l);7.8*o.length+16>h&&(o=da(l)),7.8*o.length+16>h||r.push((0,ha.jsx)("text",{x:c,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:o},t+"-funnel-value"))}return r.length?(0,ha.jsx)("g",{children:r},t+"-funnel-labels"):null}function pa(e,t,n){const r=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",o=n=>`ord-${e.type}-${r}-${t}-${n}`,i=`ord-${e.type}-${r}-${t}`;switch(e.type){case"rect":{const t=e,n=Qs(i)+"-grad",r=function(e,t){const n=e.fillGradient;if(!n||"object"!=typeof n)return null;let r=e.x,o=e.y,i=e.x,s=e.y+e.h;"bottom"===e.roundedEdge?(o=e.y+e.h,s=e.y):"right"===e.roundedEdge?(r=e.x+e.w,o=e.y,i=e.x,s=e.y):"left"===e.roundedEdge&&(r=e.x,o=e.y,i=e.x+e.w,s=e.y);const a=[];if("colorStops"in n){const e=ea(n.colorStops);if(!e)return null;a.push(...e)}else{const t=Zs(e.style.fill);a.push((0,Us.jsx)("stop",{offset:0,stopColor:t,stopOpacity:n.topOpacity},"0")),a.push((0,Us.jsx)("stop",{offset:1,stopColor:t,stopOpacity:n.bottomOpacity},"1"))}return(0,Us.jsx)("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:r,y1:o,x2:i,y2:s,children:a})}(t,n);let o,s;if(r)s=`url(#${n})`;else if(Vr(t.style.fill)){const e=Qs(i)+"-hatch";o=Zr(t.style.fill,e),s=`url(#${e})`}else s=Zs(t.style.fill);const a=r||o?(0,ha.jsxs)("defs",{children:[r,o]}):null;if(t.cornerRadii&&Hs(t.cornerRadii)){const e=function(e){const{x:t,y:n,w:r,h:o}=e,{tl:i,tr:s,br:a,bl:l}=Vs(e);let c=`M${t+i},${n}`;return c+=` L${t+r-s},${n}`,s>0&&(c+=` A${s},${s} 0 0 1 ${t+r},${n+s}`),c+=` L${t+r},${n+o-a}`,a>0&&(c+=` A${a},${a} 0 0 1 ${t+r-a},${n+o}`),c+=` L${t+l},${n+o}`,l>0&&(c+=` A${l},${l} 0 0 1 ${t},${n+o-l}`),c+=` L${t},${n+i}`,i>0&&(c+=` A${i},${i} 0 0 1 ${t+i},${n}`),c+=" Z",c}(t);return(0,ha.jsxs)(aa.Fragment,{children:[a,(0,ha.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:r,w:o,h:l}=t;let c;switch(t.roundedEdge){case"right":c=`M${n},${r} L${n+o-e},${r} A${e},${e} 0 0 1 ${n+o},${r+e} L${n+o},${r+l-e} A${e},${e} 0 0 1 ${n+o-e},${r+l} L${n},${r+l} Z`;break;case"left":c=`M${n+o},${r} L${n+e},${r} A${e},${e} 0 0 0 ${n},${r+e} L${n},${r+l-e} A${e},${e} 0 0 0 ${n+e},${r+l} L${n+o},${r+l} Z`;break;case"bottom":c=`M${n},${r} L${n+o},${r} L${n+o},${r+l-e} A${e},${e} 0 0 1 ${n+o-e},${r+l} L${n+e},${r+l} A${e},${e} 0 0 1 ${n},${r+l-e} Z`;break;default:c=`M${n},${r+l} L${n},${r+e} A${e},${e} 0 0 1 ${n+e},${r} L${n+o-e},${r} A${e},${e} 0 0 1 ${n+o},${r+e} L${n+o},${r+l} Z`}return(0,ha.jsxs)(aa.Fragment,{children:[a,(0,ha.jsx)("path",{d:c,fill:s,opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth})]},i)}return(0,ha.jsxs)(aa.Fragment,{children:[a,(0,ha.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}),fa(t,i)]},i)}case"point":{const t=e;return(0,ha.jsx)("circle",{cx:t.x,cy:t.y,r:t.r,fill:Zs(t.style.fill),opacity:t.style.opacity??t.style.fillOpacity??.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},i)}case"symbol":return ta(e,t,n);case"glyph":return Js(e,e.x,e.y,`${n??""}ord-glyph-${e.pointId??t}`);case"wedge":{const r=e;if(r._gradientBand&&r._gradientBand.colors.length>0){const e=Qs(`${n?n+"-":""}gauge-grad-${r.category||i}-${t}`),{clipPath:o,slices:s}=function(e){const t=ua({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,cornerRadius:e.cornerRadius,roundStart:e.roundStart,roundEnd:e.roundEnd}),n=[],r=e.colors;if(r.length>0){const t=(e.endAngle-e.startAngle)/r.length;for(let o=0;r.length>o;o++)n.push({d:ua({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle+o*t,endAngle:e.endAngle}),color:r[o]})}return{clipPath:t,slices:n}}({innerRadius:r.innerRadius,outerRadius:r.outerRadius,startAngle:r.startAngle,endAngle:r.endAngle,cornerRadius:r.cornerRadius,roundStart:r.roundedEnds?.start??!0,roundEnd:r.roundedEnds?.end??!0,colors:r._gradientBand.colors});return(0,ha.jsxs)("g",{transform:`translate(${r.cx},${r.cy})`,opacity:r.style.opacity,fillOpacity:r.style.fillOpacity,children:[(0,ha.jsx)("defs",{children:(0,ha.jsx)("clipPath",{id:e,children:(0,ha.jsx)("path",{d:o})})}),(0,ha.jsx)("g",{clipPath:`url(#${e})`,children:s.map((e,t)=>(0,ha.jsx)("path",{d:e.d,fill:Zs(e.color)},t))}),r.style.stroke&&"none"!==r.style.stroke&&(0,ha.jsx)("path",{d:o,fill:"none",stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},i)}let o;if(r.roundedEnds)o=ua({innerRadius:r.innerRadius,outerRadius:r.outerRadius,startAngle:r.startAngle,endAngle:r.endAngle,cornerRadius:r.cornerRadius,roundStart:r.roundedEnds.start,roundEnd:r.roundedEnds.end});else{const e=(0,la.arc)().innerRadius(r.innerRadius).outerRadius(r.outerRadius).startAngle(r.startAngle+Math.PI/2).endAngle(r.endAngle+Math.PI/2);r.cornerRadius&&e.cornerRadius(r.cornerRadius),o=e(Ks)||""}return(0,ha.jsx)("path",{d:o,transform:`translate(${r.cx},${r.cy})`,fill:Zs(r.style.fill),stroke:r.style.stroke,strokeWidth:r.style.strokeWidth,opacity:r.style.opacity},i)}case"boxplot":{const t=e,n=t.columnWidth/2;return(0,ha.jsxs)("g","vertical"===t.projection?{children:[(0,ha.jsx)("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,ha.jsx)("rect",{x:t.x-n,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:Zs(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,ha.jsx)("line",{x1:t.x-n,y1:t.medianPos,x2:t.x+n,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2}),(0,ha.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,ha.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,ha.jsx)("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,ha.jsx)("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-n,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:Zs(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:1}),(0,ha.jsx)("line",{x1:t.medianPos,y1:t.y-n,x2:t.medianPos,y2:t.y+n,stroke:t.style.stroke||"#333",strokeWidth:2}),(0,ha.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,ha.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,ha.jsx)("path",{d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:Zs(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:t.style.strokeWidth||1},o("path"))];if(t.iqrLine&&t.bounds){const e=t.bounds,r=e.x+e.width/2,i=e.y+e.height/2;t.iqrLine.isVertical?n.push((0,ha.jsx)("line",{x1:r,y1:t.iqrLine.q1Pos,x2:r,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2},o("iqr")),(0,ha.jsx)("circle",{cx:r,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},o("med"))):n.push((0,ha.jsx)("line",{x1:t.iqrLine.q1Pos,y1:i,x2:t.iqrLine.q3Pos,y2:i,stroke:t.style.stroke||"#333",strokeWidth:2},o("iqr")),(0,ha.jsx)("circle",{cx:t.iqrLine.medianPos,cy:i,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},o("med")))}return(0,ha.jsx)("g",{children:n},i)}case"connector":return(0,ha.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,ha.jsx)("polygon",{points:n,fill:Zs(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},i)}default:return null}}var ya=require("react/jsx-runtime");function ga(e,t,n){if(!e||2>t.length)return null;const r=ea(e.colorStops);return r?(0,ya.jsx)("linearGradient",{id:n,gradientUnits:"userSpaceOnUse",x1:t[0][0],y1:0,x2:t[t.length-1][0],y2:0,children:r}):null}function ma(e,t,n){switch(e.type){case"line":{const r=e;if(0===r.path.length)return null;const o=eo(r.curve),i=o?(0,Xs.line)().x(([e])=>e).y(([,e])=>e).curve(o)(r.path)??"":"M"+r.path.map(([e,t])=>`${e},${t}`).join("L"),s=Qs(`${n?n+"-":""}line-${t}-stroke-gradient`),a=ga(r.strokeGradient,r.path,s);return(0,ya.jsxs)(Gs.Fragment,{children:[a&&(0,ya.jsx)("defs",{children:a}),(0,ya.jsx)("path",{d:i,fill:"none",stroke:a?`url(#${s})`:r.style.stroke||"#4e79a7",strokeWidth:r.style.strokeWidth||2,strokeDasharray:r.style.strokeDasharray,opacity:r.style.opacity})]},"line-"+t)}case"area":{const r=e;if(0===r.topPath.length)return null;const o=eo(r.curve),i=!o||2>r.topPath.length||2>r.bottomPath.length?`M${r.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...r.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`:(0,Xs.area)().x(([e])=>e).y0((e,t)=>r.bottomPath[t][1]).y1(([,e])=>e).curve(o)(r.topPath)??"",s=`${n?n+"-":""}area-${t}-hatch`,a=Vr(r.style.fill)?Zr(r.style.fill,s):void 0,l=Qs(`${n?n+"-":""}area-${t}-gradient`),c=function(e,t){const n=e.fillGradient;if(!n||"object"!=typeof n)return null;let r=1/0;for(const[,t]of e.topPath)r=Math.min(r,t);let o=-1/0;for(const[,t]of e.bottomPath)o=Math.max(o,t);if(!Number.isFinite(r)||!Number.isFinite(o))return null;const i=[];if("colorStops"in n){const e=ea(n.colorStops);if(!e)return null;i.push(...e)}else{if(!Number.isFinite(n.topOpacity)||!Number.isFinite(n.bottomOpacity))return null;i.push((0,ya.jsx)("stop",{offset:0,stopColor:Zs(e.style.fill),stopOpacity:Math.max(0,Math.min(1,n.topOpacity))},"0")),i.push((0,ya.jsx)("stop",{offset:1,stopColor:Zs(e.style.fill),stopOpacity:Math.max(0,Math.min(1,n.bottomOpacity))},"1"))}return(0,ya.jsx)("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:0,y1:r,x2:0,y2:o,children:i})}(r,l),u=c?`url(#${l})`:a?`url(#${s})`:Zs(r.style.fill),h=c?void 0:r.style.fillOpacity??r.style.opacity??.7,d=o?(0,Xs.line)().x(([e])=>e).y(([,e])=>e).curve(o)(r.topPath)??"":"M"+r.topPath.map(([e,t])=>`${e},${t}`).join("L"),f=Qs(`${n?n+"-":""}area-${t}-stroke-gradient`),p=ga(r.strokeGradient,r.topPath,f),y=r.style.stroke&&"none"!==r.style.stroke?(0,ya.jsx)("path",{d:d,fill:"none",stroke:p?`url(#${f})`:Zs(r.style.stroke),strokeWidth:r.style.strokeWidth||2,opacity:r.style.opacity}):null;if(r.clipRect){const e=`${n?n+"-":""}area-clip-${t}`;return(0,ya.jsxs)("g",{children:[(0,ya.jsxs)("defs",{children:[c,!c&&a,p,(0,ya.jsx)("clipPath",{id:e,children:(0,ya.jsx)("rect",{x:r.clipRect.x,y:r.clipRect.y,width:r.clipRect.width,height:r.clipRect.height})})]}),(0,ya.jsxs)("g",{clipPath:`url(#${e})`,children:[(0,ya.jsx)("path",{d:i,fill:u,fillOpacity:h,opacity:c?r.style.opacity:void 0,stroke:"none"}),y]})]},"area-"+t)}return(0,ya.jsxs)(Gs.Fragment,{children:[(c||a||p)&&(0,ya.jsxs)("defs",{children:[c,!c&&a,p]}),(0,ya.jsx)("path",{d:i,fill:u,fillOpacity:h,opacity:c?r.style.opacity:void 0,stroke:"none"}),y]},"area-"+t)}case"point":{const r=e,o=`${n?n+"-":""}point-${t}-hatch`,i=Vr(r.style.fill)?Zr(r.style.fill,o):void 0;return(0,ya.jsxs)(Gs.Fragment,{children:[i&&(0,ya.jsx)("defs",{children:i}),(0,ya.jsx)("circle",{cx:r.x,cy:r.y,r:r.r,fill:i?`url(#${o})`:Zs(r.style.fill),opacity:r.style.opacity??r.style.fillOpacity??.8,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},"point-"+t)}case"symbol":return ta(e,t);case"glyph":return Js(e,e.x,e.y,`${n??""}glyph-${e.pointId??t}`);case"rect":{const r=e,o=`${n?n+"-":""}xyrect-${t}-hatch`,i=Vr(r.style.fill)?Zr(r.style.fill,o):void 0;return(0,ya.jsxs)(Gs.Fragment,{children:[i&&(0,ya.jsx)("defs",{children:i}),(0,ya.jsx)("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:i?`url(#${o})`:Zs(r.style.fill),opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.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),[r,o,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*r+.587*o+.114*i>128?"#000":"#fff",a=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return(0,ya.jsxs)("g",{children:[(0,ya.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,ya.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,ya.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,ya.jsxs)("g",{children:[(0,ya.jsx)("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),(0,ya.jsx)("circle",{cx:n.x,cy:n.highY,r:e,fill:n.wickColor}),(0,ya.jsx)("circle",{cx:n.x,cy:n.lowY,r:e,fill:n.wickColor})]},"candle-"+t)}const r=Math.min(n.openY,n.closeY),o=Math.max(Math.abs(n.openY-n.closeY),1),i=n.isUp?n.upColor:n.downColor;return(0,ya.jsxs)("g",{children:[(0,ya.jsx)("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),(0,ya.jsx)("rect",{x:n.x-n.bodyWidth/2,y:r,width:n.bodyWidth,height:o,fill:i,stroke:i,strokeWidth:1})]},"candle-"+t)}default:return null}}var xa="undefined"==typeof window||"undefined"==typeof document,ba=require("react"),va="undefined"!=typeof window?ba.useLayoutEffect:ba.useEffect,wa=()=>()=>{},ka=()=>!1,Sa=()=>!0,Aa=require("react");function Ma(e,t){const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;if(!Object.is(e[r],t[r]))return!1}return!0}function _a(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 Pa(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 Ca(e){const{background:t,hasBackgroundGraphics:n=!1,themeBackground:r=""}=e;return"transparent"===t||n?null:t||(r&&"transparent"!==r?r:"")||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 Ta(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],r=n[2],o=n[3];return`#${e}${e}${r}${r}${o}${o}${t}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${t}`;const r=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return r?`rgba(${r[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:n}var Ra=c(require("react")),La=c(require("react")),$a=(require("react/jsx-runtime"),La.createContext(null)),za=require("react/jsx-runtime"),Da={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Oa({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,za.jsx)("div",{"aria-live":"polite","aria-atomic":"true",style:Da,children:t})}function Ia(e){const t={};if(null==e||"object"!=typeof e)return t;for(const[n,r]of Object.entries(e))n.startsWith("_")||null!=r&&""!==r&&("number"==typeof r?Number.isFinite(r)&&(t[n]=r):"string"==typeof r?t[n]=r:"boolean"==typeof r?t[n]=r+"":r instanceof Date&&(t[n]=r.toISOString().slice(0,10)));return t}function Ea(e){return e&&"object"==typeof e?e:{}}function Ba(e){return Ea(e.accessibility).tableFields??e.accessibleDatum??e.datum}var Fa=require("react/jsx-runtime");function Na(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 r=[],o={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),r=i.indexOf(t);return(-1===n?999:n)-(-1===r?999:r)});for(const e of s)r.push(`${n[e]} ${o[e]||e}`);return`${t}, ${r.join(", ")}`}var Wa=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Ya="semiotic-accessible-data-table",qa=Ya+" semiotic-accessible-data-table-hidden",Ga=Ya+" semiotic-accessible-data-table-visible",Xa={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)"},Ua={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Ka={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))"},Za={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Qa={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",marginBottom:4,fontStyle:"italic"},Ja={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 el({scene:e,chartType:t,tableId:n,chartTitle:r}){const[o,i]=Ra.useState(!1),[s,a]=Ra.useState(5),l=La.useContext($a),c=l?.visible??!1,u=o||c,h=Ra.useRef(null),d=r?"Data summary for "+r:n?`Data summary for ${t} ${n}`:"Data summary for "+t;Ra.useEffect(()=>{u||a(5)},[u]);const f=Ra.useCallback(e=>{e.target===e.currentTarget&&(o||c||i(!0))},[o,c]),p=Ra.useCallback(e=>{c||h.current?.contains(e.relatedTarget)||i(!1)},[c]);if(!e||0===e.length)return n?(0,Fa.jsx)("span",{id:n,tabIndex:-1,style:Da}):null;if(!u)return(0,Fa.jsx)("div",{id:n,className:qa,tabIndex:-1,onFocus:f,style:Da,role:"region","aria-label":d,children:(0,Fa.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 r of e)if(r&&"object"==typeof r&&null!==r.datum)try{switch(r.type){case"point":if(n)break;t.push({label:"Point",values:Ia(Ba(r))});break;case"line":case"area":{const e=Ba(r),n=Array.isArray(e)?e:[],o="line"===r.type?"Line point":"Area point";for(const e of n)t.push({label:o,values:Ia(e)});break}case"rect":{const e=Ba(r),n=null!=e&&"object"==typeof e?e:{},o=n.category??r.group??"",i=n.value??n.__aggregateValue??n.total,s=Ia(n);null==s.category&&""!==o&&(s.category=o+""),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=Ia(Ba(r));null==e.value&&"number"==typeof r.value&&Number.isFinite(r.value)&&(e.value=r.value),t.push({label:"Cell",values:e});break}case"wedge":{const e=Ba(r),n=Ia(e);if(null==n.category){const t=Ea(e),r=t.category??t.label;null!=r&&(n.category=r+"")}t.push({label:"Wedge",values:n});break}case"circle":t.push({label:"Node",values:Ia(Ba(r))});break;case"arc":t.push({label:"Arc",values:Ia(Ba(r))});break;case"candlestick":t.push({label:"Candlestick",values:Ia(Ba(r))});break;case"geoarea":{const e=Ea(Ba(r)),n=Ia(e);if(null==n.name){const t=Ea(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 r of t){const t=[],o=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[r];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&o.add(e+""))}if(t.length>0){let e=t[0],o=t[0],i=0;for(const n of t)e>n&&(e=n),n>o&&(o=n),i+=n;n.push({name:r,count:t.length,numeric:!0,min:e,max:o,mean:i/t.length})}else if(o.size>0){const e=Array.from(o);n.push({name:r,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}: ${Wa(e.min)} to ${Wa(e.max)}, mean ${Wa(e.mean)}.`);else{const t=e.uniqueValues,r=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${r}.`)}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,Fa.jsxs)("div",{ref:h,id:n,className:Ga,tabIndex:-1,onBlur:p,style:Xa,role:"region","aria-label":d,children:[(0,Fa.jsx)("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{c&&l&&l.setVisible(!1),i(!1)},"aria-label":"Close data summary",style:Va,children:"×"}),(0,Fa.jsx)("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:Ha,children:m}),(0,Fa.jsxs)("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+t,style:Ua,children:[(0,Fa.jsx)("caption",{className:"semiotic-accessible-data-table-caption",style:Qa,children:v>0?`First ${x} of ${y.length} data points`:`All ${y.length} data points`}),(0,Fa.jsx)("thead",{children:(0,Fa.jsxs)("tr",{children:[(0,Fa.jsx)("th",{style:Ka,children:"type"}),k.map(e=>(0,Fa.jsx)("th",{style:Ka,children:e},e))]})}),(0,Fa.jsx)("tbody",{children:b.map((e,t)=>(0,Fa.jsxs)("tr",{children:[(0,Fa.jsx)("td",{style:Za,children:e.label}),k.map(t=>{return(0,Fa.jsx)("td",{style:Za,children:(n=e.values[t],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":Wa(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},t);var n})]},t))})]}),v>0&&(0,Fa.jsxs)("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>a(e=>e+25),style:Ja,children:["Show ",Math.min(25,v)," more"," ",1===v?"row":"rows"," (",v," remaining)"]})]})}function tl({summary:e}){return e?(0,Fa.jsx)("div",{role:"note",style:Da,children:e}):null}function nl({tableId:e}){return(0,Fa.jsx)("a",{href:"#"+e,style:Da,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,Da)},children:"Skip to data table"})}var rl=require("react/jsx-runtime"),ol="var(--semiotic-focus, #005fcc)";function il({active:e,hoverPoint:t,margin:n,size:r,shape:o="circle",width:i,height:s,pathData:a}){if(!e||!t)return null;const l=t.x+n.left,c=t.y+n.top;let u;if("geoarea"!==o&&"path"!==o||!a)if("rect"===o&&null!=i&&null!=s){const e=Math.max(i,4),t=Math.max(s,4);u=(0,rl.jsx)("rect",{x:l-e/2-3,y:c-t/2-3,width:e+6,height:t+6,rx:3,fill:"none",stroke:ol,strokeWidth:2,strokeDasharray:"4,2"})}else u=(0,rl.jsx)("circle","wedge"===o?{cx:l,cy:c,r:12,fill:"none",stroke:ol,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:ol,strokeWidth:2,strokeDasharray:"4,2"});else u=(0,rl.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:(0,rl.jsx)("path",{d:a,fill:"none",stroke:ol,strokeWidth:2.5,strokeDasharray:"6,3"})});return(0,rl.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:r[0],height:r[1],pointerEvents:"none",zIndex:2},"aria-hidden":"true",children:u})}var sl=c(require("react")),al=require("react/jsx-runtime");function ll({x:e,y:t,containerWidth:n,containerHeight:r,margin:o,children:i,className:s="stream-frame-tooltip",zIndex:a=1}){const l=Number.isFinite(e)&&Number.isFinite(t),c=sl.useRef(null),[u,h]=sl.useState(null);sl.useLayoutEffect(()=>{const e=c.current;if(!e)return;const t=()=>{const t=e.getBoundingClientRect();Number.isFinite(t.width)&&Number.isFinite(t.height)&&h(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,r,l]);let d;d=u?`translate(${u.width+12>n-e?"calc(-100% - 12px)":"12px"}, ${u.height+12>r-t?"calc(-100% - 4px)":"4px"})`:`translate(${e>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*r>t?"4px":"calc(-100% - 4px)"})`;const f=function(e){if(!sl.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 r=n.style;if(r&&"object"==typeof r){if(null!=r.background&&""!==r.background&&"transparent"!==r.background)return!0;if(null!=r.backgroundColor&&""!==r.backgroundColor&&"transparent"!==r.backgroundColor)return!0}return!1}(i),p=f?null:et;return l?(0,al.jsx)("div",{ref:c,className:f?s:(s+" semiotic-tooltip").trim(),style:{...p||{},position:"absolute",left:o.left+e,top:o.top+t,transform:d,pointerEvents:"none",zIndex:a,width:"max-content"},children:i}):null}var cl=c(require("react")),ul=require("react"),hl=require("react");var dl=require("react"),fl=()=>"undefined"!=typeof performance?performance.now():Date.now();function pl(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 yl(e,t){const n=e();return Number.isFinite(n)?n:t}var gl=class{constructor(e={}){this.randomSource=Math.random,this.subscribers=new Set,this.now=()=>this.advance(),this.random=()=>this.randomSource(),this.clock=e.clock??fl,this.lastWallTime=yl(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=yl(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??fl;t!==this.clock&&(this.advance(),this.clock=t,this.lastWallTime=yl(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:pl(n)))}},ml="undefined"==typeof window?ul.useEffect:ul.useLayoutEffect,xl={requestAnimationFrame:e=>("undefined"==typeof window?globalThis:window).requestAnimationFrame(e),cancelAnimationFrame:e=>("undefined"==typeof window?globalThis:window).cancelAnimationFrame(e)};function bl(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function vl(e){const t=function(){const[e,t]=(0,hl.useState)(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return(0,hl.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,ul.useRef)(t);n.current=t;const[r,o]=function(e,t,n){const r=(0,dl.useRef)(null),[o,i]=(0,dl.useState)(null);return(0,dl.useEffect)(()=>{if(!t&&!n)return;const e=r.current;if(!e)return;const o=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 o.observe(e),()=>o.disconnect()},[t,n]),[r,[t&&o?o.w:e[0],n&&o?o.h:e[1]]]}(e.sizeProp,e.responsiveWidth,e.responsiveHeight),i=!!e.title,s=!!e.legend&&"top"===e.legendPosition,a=(0,ul.useMemo)(()=>Es({...e.marginDefault,...e.userMargin},i,s),[e.marginDefault,e.userMargin,i,s]),l=o[0]-a.left-a.right,c=o[1]-a.top-a.bottom,u=bl(e.foregroundGraphics,o,a),h=bl(e.backgroundGraphics,o,a),d=jt(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-"+cl.useId(),g=(0,ul.useRef)(null);if(!g.current){const t=!e.suspendWhenHidden||"undefined"==typeof document||!document.hidden;g.current=new gl({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,ul.useRef)(null),b=(0,ul.useRef)(e.frameScheduler??xl);b.current=e.frameScheduler??xl;const v=(0,ul.useRef)(null),w=(0,ul.useRef)(!1),k=(0,ul.useRef)(()=>{}),S=(0,ul.useCallback)(()=>{if(null!==x.current||w.current)return;const e=b.current;let t=!1,n=!1;const r=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=r,v.current=e)},[]),A=(0,ul.useCallback)(()=>{null!==x.current&&((v.current??b.current).cancelAnimationFrame(x.current),x.current=null,v.current=null)},[]);ml(()=>{m.setPaused(!0===e.paused)},[m,e.paused]),(0,ul.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,ul.useEffect)(()=>()=>{A()},[A]);const M=(0,ul.useRef)(()=>{}),_=(0,ul.useRef)(()=>{}),P=(0,ul.useRef)(null),C=(0,ul.useRef)(null),j=(0,ul.useRef)(null),T=(0,ul.useCallback)(()=>{const e=P.current;P.current=null,e&&M.current(e)},[]),R=(0,ul.useCallback)(e=>{if(P.current={clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType},null===C.current){const e=b.current;let t=!1;const n=e.requestAnimationFrame(()=>{t=!0,C.current=null,j.current=null,T()});t||(C.current=n,j.current=e)}},[T]),L=(0,ul.useCallback)(()=>{P.current=null,null!==C.current&&((j.current??b.current).cancelAnimationFrame(C.current),C.current=null,j.current=null),_.current()},[]);(0,ul.useEffect)(()=>()=>{P.current=null,null!==C.current&&((j.current??b.current).cancelAnimationFrame(C.current),C.current=null,j.current=null)},[]);const $=e.themeDirtyRef;return ml(()=>{$&&(Fr++,$.current=!0,S())},[d,S,$]),{reducedMotion:t,reducedMotionRef:n,responsiveRef:r,size:o,margin:a,adjustedWidth:l,adjustedHeight:c,resolvedForeground:u,resolvedBackground:h,currentTheme:d,transition:f,introEnabled:p,tableId:y,frameRuntime:m,rafRef:x,renderFnRef:k,scheduleRender:S,cancelRender:A,hoverHandlerRef:M,hoverLeaveRef:_,onPointerMove:R,onPointerLeave:L}}var wl=require("react"),kl=require("react/jsx-runtime");function Sl({children:e,size:t,margin:n,overflowVisible:r=!1}){return e?(0,kl.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:t[0],height:t[1],pointerEvents:"none",overflow:r?"visible":void 0},children:(0,kl.jsx)("g",{transform:`translate(${n.left},${n.top})`,children:e})}):null}function Al(e,t,n,r){return"function"==typeof e?e({size:t,margin:n,scales:r}):e}function Ml(e,t,n,r){const o=e.getContext("2d");if(!o)return null;const i=Math.round(t[0]*r),s=Math.round(t[1]*r),a=i/t[0],l=s/t[1],c=t[0]+"px",u=t[1]+"px";return e.style.width!==c&&(e.style.width=c),e.style.height!==u&&(e.style.height=u),e.width===i&&e.height===s||(e.width=i,e.height=s),o.setTransform(a,0,0,l,0,0),o.translate(n.left,n.top),o}var _l=require("react");function Pl(e,t,n,r){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:r,fn:t}:{key:void 0,fn:null}}var Cl=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],jl=3156e7;function Tl(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")}`}:jl>t?e=>{const t=new Date(e);return`${Cl[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*jl>t?e=>{const t=new Date(e);return`${Cl[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}function Rl(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:xn(n.size)});else if("glyph"===n.type){const e=Ir(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 Ll=require("d3-shape");function $l(e,t,n){let r=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(r=n.color):e>n.value&&(r=n.color);return r}function zl(e,t,n,r,o,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],r=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(n*n+r*r))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=r,e.lineCap=i;for(let n=0;t.length-1>n;n++){const r=(s[n]+s[n+1])/2;let i=o;l>r&&(i*=r/l),l>a-r&&(i*=(a-r)/l),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 Dl=(e,t,n,r)=>{const o=t.filter(e=>"line"===e.type);for(const t of o){if(2>t.path.length)continue;const n=t._introClipFraction;void 0!==n&&1>n&&(e.save(),e.beginPath(),e.rect(0,0,r.width*n,r.height),e.clip());const o=t.style.stroke||"#007bff",i=qr(e,o)||o,s=t.style.strokeWidth||2,a=t.colorThresholds,l=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){zl(e,t.path,i,s,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const c=eo(t.curve),u=a&&a.length>0&&l&&l.length===t.path.length,h=t._decayOpacities;if(h&&h.length===t.path.length&&!u){e.strokeStyle=i;const n=t.style.opacity??1;for(let r=0;t.path.length-1>r;r++)e.globalAlpha=.5*(h[r]+h[r+1])*n,e.beginPath(),e.moveTo(t.path[r][0],t.path[r][1]),e.lineTo(t.path[r+1][0],t.path[r+1][1]),e.stroke()}else if(u){let n=function(t,n,r){e.beginPath(),e.strokeStyle=t,e.moveTo(n,r),h=!0},r=function(){h&&(e.stroke(),h=!1)},o=null,s=null,c=null,u=null,h=!1;for(let h=0;t.path.length>h;h++){const[d,f]=t.path[h],p=l[h],y=$l(p,a,i);if(null!==o&&null!==u&&null!==c){if(y===u)e.lineTo(d,f);else{const t=[];for(const e of a){const n=e.value;(c>n||n>p)&&(n>c||p>n)||c===n||p===n||t.push({t:(n-c)/(p-c)})}t.sort((e,t)=>e.t-t.t);for(const l of t){const t=o+(d-o)*l.t,u=s+(f-s)*l.t,h=$l(c+(p-c)*Math.min(l.t+1e-4,1),a,i);e.lineTo(t,u),r(),n(h,t,u)}e.lineTo(d,f)}o=d,s=f,c=p,u=y}else n(y,d,f),o=d,s=f,c=p,u=y}r()}else{e.beginPath();const n=t.strokeGradient&&t.path.length>=2?ro(e,t.strokeGradient,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=n||i,c)(0,Ll.line)().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{const[n,r]=t.path[0];e.moveTo(n,r);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=to(e,t.style.fill,t.style.fill),c&&!u)(0,Ll.line)().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{const[n,r]=t.path[0];e.moveTo(n,r);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],r.height),e.lineTo(n,r.height),e.closePath(),e.fill()}void 0!==n&&1>n&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function Ol(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Il(e,t,n=.3){Ol(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 El(e,t,n=.6){if(!Ol(t))return;const r=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,o=t.cx??t.x??0,i=t.cy??t.y??0;e.beginPath(),e.arc(o,i,r,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 Bl(e,t,n,r=.35){Ol(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",n?e.fill(n):e.fill())}var Fl=require("d3-shape");function Nl(e,t){const n=eo(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 r=(0,Fl.area)().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),r(t.topPath)}}var Wl=(e,t,n,r)=>{const o=t.filter(e=>"area"===e.type);for(const t of o){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 o=t._introClipFraction;void 0!==o&&1>o&&(e.save(),e.beginPath(),e.rect(0,0,r.width*o,r.height),e.clip());const i=to(e,t.style.fill,"#4e79a7"),s=t._decayOpacities;if(s&&s.length===t.topPath.length){const n=t.style.fillOpacity??.7;e.fillStyle=i;for(let r=0;t.topPath.length-1>r;r++)e.globalAlpha=.5*(s[r]+s[r+1])*n,e.beginPath(),e.moveTo(t.topPath[r][0],t.topPath[r][1]),e.lineTo(t.topPath[r+1][0],t.topPath[r+1][1]),e.lineTo(t.bottomPath[r+1][0],t.bottomPath[r+1][1]),e.lineTo(t.bottomPath[r][0],t.bottomPath[r][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=qr(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 a=t.style.opacity??1;if(Nl(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let n=1/0;for(const e of t.topPath)n>e[1]&&(n=e[1]);let r=-1/0;for(const e of t.bottomPath)e[1]>r&&(r=e[1]);const o=no(e,t.fillGradient,"string"==typeof i?i:"#4e79a7",0,n,0,r);e.fillStyle=o||i,e.globalAlpha=a}else e.globalAlpha=(t.style.fillOpacity??.7)*a,e.fillStyle=i;if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(Nl(e,t),Bl(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=a;const n=t.strokeGradient&&t.topPath.length>=2?ro(e,t.strokeGradient,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0):null;e.strokeStyle=n||qr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const r=eo(t.curve);if(e.beginPath(),r)(0,Fl.line)().x(e=>e[0]).y(e=>e[1]).curve(r).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])}e.stroke()}void 0!==o&&1>o&&e.restore(),n&&e.restore(),e.globalAlpha=1}},Yl=(e,t,n,r)=>{const o=t.filter(e=>"point"===e.type);if(0!==o.length){e.save();try{const t=e.globalAlpha;for(const n of o)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=to(e,n.style.fill,"#4e79a7"),e.fill(),n.style.stroke&&(e.strokeStyle=to(e,n.style.stroke,n.style.stroke),e.lineWidth=n.style.strokeWidth||1,e.stroke()),El(e,n)}finally{e.restore()}}},ql=new Map;function Gl(e){try{if(e.path)return new Path2D(e.path);const t=`${e.symbolType??"circle"}:${Math.round(e.size)}`;let n=ql.get(t);return n||(n=new Path2D(mn(e.symbolType,e.size)),ql.size>256&&ql.clear(),ql.set(t,n)),n}catch{return null}}var Xl=(e,t)=>{const n=e.globalAlpha;for(const r of t){if("symbol"!==r.type)continue;const t=r;if(0>=t.size)continue;const o=Gl(t);if(!o)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=to(e,t.style.fill,"#4e79a7"),e.fill(o)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=n*i,e.strokeStyle=to(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth??1,e.stroke(o)),e.restore()}e.globalAlpha=n};function Hl(e,t,n,r,o){if(0>=t.size)return;const i=t.glyph;if(!i||!i.parts?.length)return;const s=Lr(i,t.size);if(0>=s.scale)return;const a=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=a)return;const l=t=>{const n=to(e,t,t);return"string"==typeof n?n:t},c=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(n,r),t.rotation&&e.rotate(t.rotation),e.translate(s.offsetX,s.offsetY),e.scale(s.scale,s.scale),e.globalAlpha=o*a*(t.style.fillOpacity??1);const u=Or(i,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&Er(e,i,c,t.accent,t.ghostColor,l),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),Er(e,i,c,t.accent,void 0,l),e.restore()}function Vl(e,t){const{x:n,y:r,w:o,h:i}=t,{tl:s,tr:a,br:l,bl:c}=Vs(t);e.beginPath(),e.moveTo(n+s,r),e.lineTo(n+o-a,r),a>0&&e.arcTo(n+o,r,n+o,r+a,a),e.lineTo(n+o,r+i-l),l>0&&e.arcTo(n+o,r+i,n+o-l,r+i,l),e.lineTo(n+c,r+i),c>0&&e.arcTo(n,r+i,n,r+i-c,c),e.lineTo(n,r+s),s>0&&e.arcTo(n,r,n+s,r,s),e.closePath()}function Ul(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 Kl=(e,t,n,r)=>{const o=t.filter(e=>"rect"===e.type);for(const t of o){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)Zl(e,t);else if(t.cornerRadii&&Hs(t.cornerRadii)){const n=to(e,t.style.fill,qr(e,"var(--semiotic-primary, #007bff)")),r=Ul(t),o=t.fillGradient&&"string"==typeof n?no(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=o||n,Vl(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=qr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else if(t.roundedTop&&t.roundedTop>0){const n=to(e,t.style.fill,qr(e,"var(--semiotic-primary, #007bff)")),r=Ul(t),o=t.fillGradient&&"string"==typeof n?no(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=o||n;const i=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:s,y:a,w:l,h:c}=t;switch(t.roundedEdge){case"right":e.moveTo(s,a),e.lineTo(s+l-i,a),e.arcTo(s+l,a,s+l,a+i,i),e.lineTo(s+l,a+c-i),e.arcTo(s+l,a+c,s+l-i,a+c,i),e.lineTo(s,a+c);break;case"left":e.moveTo(s+l,a),e.lineTo(s+i,a),e.arcTo(s,a,s,a+i,i),e.lineTo(s,a+c-i),e.arcTo(s,a+c,s+i,a+c,i),e.lineTo(s+l,a+c);break;case"bottom":e.moveTo(s,a),e.lineTo(s+l,a),e.lineTo(s+l,a+c-i),e.arcTo(s+l,a+c,s+l-i,a+c,i),e.lineTo(s+i,a+c),e.arcTo(s,a+c,s,a+c-i,i);break;default:e.moveTo(s,a+c),e.lineTo(s,a+i),e.arcTo(s,a,s+i,a,i),e.lineTo(s+l-i,a),e.arcTo(s+l,a,s+l,a+i,i),e.lineTo(s+l,a+c)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=qr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const n=to(e,t.style.fill,qr(e,"var(--semiotic-primary, #007bff)")),r=Ul(t),o=t.fillGradient&&"string"==typeof n?no(e,t.fillGradient,n,r.x0,r.y0,r.x1,r.y1):null;e.fillStyle=o||n,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=qr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}Il(e,t),e.globalAlpha=1}};function Zl(e,t){const n=t.style.icon,r=t.style.iconPadding||2,o=Math.min(t.w,t.h)-r;if(0>=o)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=o+r,s=t.x+(t.w-o)/2;for(let r=t.y+t.h-o;r>=t.y-o;r-=i)e.drawImage(n,s,r,o,o)}else{const i=o+r,s=t.y+(t.h-o)/2;for(let r=t.x;t.x+t.w>r;r+=i)e.drawImage(n,r,s,o,o)}e.restore()}function Ql(e){const[t,n,r]=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*r>128?"#000":"#fff"}function Jl(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}var ec=(e,t,n,r)=>{const o=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of o){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 r=Math.max(0,n?.strokeWidth??1);if(r>0&&(e.strokeStyle=qr(e,n?.stroke??"var(--semiotic-surface, #fff)"),e.lineWidth=r,e.strokeRect(t.x,t.y,t.w,t.h)),Il(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):Jl(t.value),r=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),o=t.x+t.w/2,i=t.y+t.h/2;e.fillStyle=Ql(t.fill),e.font=r+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,o,i)}}}finally{e.restore()}},tc=(e,t,n,r)=>{for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const o=(t._decayOpacity??1)*(t.style?.opacity??1);1!==o&&(e.globalAlpha=o);const i=qr(e,t.wickColor)||t.wickColor,s=60>r.height,a=s?Math.max(t.wickWidth,2):t.wickWidth,l=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=i,e.lineWidth=a,e.stroke()};if(s||l(),t.isRange){const n=t.dotRadius??Math.max(2,Math.min(t.bodyWidth/2,.12*r.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),r=Math.abs(t.openY-t.closeY),o=t.isUp?t.upColor:t.downColor,i=qr(e,o)||o;e.fillStyle=i,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1)),e.strokeStyle=i,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(r,1))}s&&l(),e.restore()}},nc={line:[Wl,Dl,Yl],area:[Wl,Yl],stackedarea:[Wl,Yl],scatter:[Yl,Xl],bubble:[Yl,Xl],heatmap:[ec],bar:[Kl],swarm:[Yl],waterfall:[(e,t,n,r)=>{Kl(e,t);const o=t.filter(e=>"rect"===e.type);if(2>o.length)return;const i=o[0].datum,s=i?._connectorStroke;if(s){e.save(),e.strokeStyle=qr(e,s)||s,e.lineWidth=i?._connectorWidth??1,e.setLineDash([]);for(let t=0;o.length-1>t;t++){const r=o[t],i=o[t+1],s=r.datum,a=i.datum;if(null==s?.cumEnd||null==a?.baseline)continue;const l=n.y(s.cumEnd),c=r.x+r.w,u=i.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[tc],mixed:[Wl,Dl,Yl],custom:[Wl,Kl,ec,Dl,Yl,Xl,(e,t)=>{const n=e.globalAlpha;for(const r of t)"glyph"===r.type&&Hl(e,r,r.x,r.y,n);e.globalAlpha=n},tc]},rc=new Set;function oc(e,t){const n="function"==typeof e?e(t.datum??null,t):e;return(r=n)&&"object"==typeof r&&"string"==typeof r.id&&"function"==typeof r.cacheKey&&"function"==typeof r.drawCanvas&&"function"==typeof r.renderStaticSVG?n:void 0;var r}function ic(e,t){if("undefined"!=typeof process&&"production"===process.env?.NODE_ENV)return;const n=`${e}:${t}`;rc.has(n)||(rc.add(n),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}function sc(e){const{node:t,index:n,renderMode:r,fallback:o}=e,i=oc(r,t);if(!i)return o();const s=i.renderStaticSVG({node:t,style:t.style??{},key:`${i.id}-${n}`});return null!=s?s:(ic(i.id,t.type??"unknown"),o())}function ac(e){const t=[];return e.nodes.forEach((n,r)=>{const o=sc({node:n,index:r,renderMode:e.renderMode,fallback:()=>e.fallback(n,r)});null!=o&&!1!==o&&t.push({node:n,element:o})}),t}var lc=require("react/jsx-runtime");function cc(e){return"string"==typeof e?e:"value"}function uc(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function hc(e,t){if(!t)return uc(e);try{const n=t(e);return null==n?uc(e):n}catch{return uc(e)}}function dc(e,t){return"function"==typeof t?t(e):e[t]}function fc(e,t){if(!e)return[];const n=[];return(Array.isArray(e)?e:[e]).forEach((e,r)=>{const o="string"==typeof e?.y0Accessor?e.y0Accessor:"low",i="string"==typeof e?.y1Accessor?e.y1Accessor:"high";n.push({label:o,accessor:e=>e.bands?.[r]?.y0??(0===r?e.band?.y0:void 0),format:t}),n.push({label:i,accessor:e=>e.bands?.[r]?.y1??(0===r?e.band?.y1:void 0),format:t})}),n}var pc=require("react/jsx-runtime");function yc(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function gc({hover:e}){const t=e.data??{},n=t.y??t.value,r=t.x??t.time;if(void 0===n&&void 0===r){const e=Qe(t);if(null!=e.title||e.entries.length>0)return(0,pc.jsxs)("div",{className:"semiotic-tooltip",style:et,children:[null!=e.title&&(0,pc.jsx)("div",{style:{fontWeight:600,marginBottom:e.entries.length?2:0},children:e.title+""}),e.entries.map(e=>(0,pc.jsxs)("div",{style:{opacity:.7,fontSize:11},children:[e.key,":"," ",(0,pc.jsx)("span",{style:{fontWeight:600},children:yc(e.value)})]},e.key))]})}return(0,pc.jsxs)("div",{className:"semiotic-tooltip",style:et,children:[(0,pc.jsx)("div",{style:{fontWeight:600,marginBottom:2},children:yc(n)}),(0,pc.jsx)("div",{style:{opacity:.7,fontSize:11},children:yc(r)})]})}function mc(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:s,context:a,timestamp:l=Date.now()}=e;t&&(n?(t({type:"hover",datum:n,x:r,y:o,timestamp:l,chartType:i,chartId:s}),"focus"===a?.type&&t({type:"focus",datum:n,inputType:"touch"===a.inputType?"pointer":a.inputType,timestamp:l,chartType:i,chartId:s})):t({type:"hover-end",timestamp:l,chartType:i,chartId:s}))}function xc(e){const{onObservation:t,datum:n,x:r=0,y:o=0,chartType:i,chartId:s,context:a,timestamp:l=Date.now()}=e;t&&(n?(t({type:"click",datum:n,x:r,y:o,timestamp:l,chartType:i,chartId:s}),"activate"===a?.type&&t({type:"activate",datum:n,inputType:a.inputType,timestamp:l,chartType:i,chartId:s})):t({type:"click-end",timestamp:l,chartType:i,chartId:s}))}gc.ownsChrome=!0;var bc=require("react"),vc=require("react");function wc(e,t,n){const r=e.byGroup.get(t);let o=0,i=Math.abs(r[0].x-n.x);for(let e=1;r.length>e;e++){const t=Math.abs(r[e].x-n.x);i>t&&(i=t,o=e)}return r[o]._flatIndex}function kc(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=Ir(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,r=Array.isArray(e.datum)?e.datum:[],o=e.group??"_default";for(let n=0;e.path.length>n&&r.length>n;n++)t.push({x:e.path[n][0],y:e.path[n][1],datum:r[n],shape:"circle",group:o});break}case"area":{const e=n,r=Array.isArray(e.datum)?e.datum:[],o=e.group??"_default";for(let n=0;e.topPath.length>n&&r.length>n;n++)t.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:r[n],shape:"circle",group:o});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 Sc=require("react/jsx-runtime"),Ac={top:20,right:20,bottom:30,left:40},Mc=ja;function _c(e){if(e)return"x"===e.dimension?"pan-y":"y"===e.dimension?"pan-x":"none"}var Pc=(0,ut.memo)((0,ut.forwardRef)(function(e,t){const{chartType:n,runtimeMode:r,data:o,chunkThreshold:i,chunkSize:s,xAccessor:a,yAccessor:l,accessorRevision:c,colorAccessor:u,sizeAccessor:h,symbolAccessor:d,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:C=.1,scalePadding:j,sizeRange:T,size:R=[500,300],responsiveWidth:L,responsiveHeight:$,margin:z,className:D,background:O,renderMode:I,lineStyle:E,pointStyle:B,areaStyle:F,barStyle:N,waterfallStyle:W,swarmStyle:Y,barColors:q,colorScheme:G,boundsAccessor:X,boundsStyle:H,y0Accessor:V,band:U,gradientFill:K,lineGradient:Q,areaGroups:J,openAccessor:ee,highAccessor:te,lowAccessor:ne,closeAccessor:re,candlestickStyle:oe,showAxes:ie=!0,axes:se,xLabel:ae,yLabel:le,yLabelRight:ce,xFormat:ue,yFormat:he,axisExtent:de,tickFormatTime:fe,tickFormatValue:pe,hoverAnnotation:ye,tooltipContent:ge,customHoverBehavior:me,customClickBehavior:xe,onObservation:be,annotationObservationCallback:ve,chartId:we,enableHover:ke,hoverRadius:Se=30,tooltipMode:Ae,annotations:Me,onAnnotationActivate:_e,autoPlaceAnnotations:Pe,svgAnnotationRules:Ce,showGrid:je,legend:Te,legendHoverBehavior:Re,legendClickBehavior:Le,legendHighlightedCategory:$e,legendIsolatedCategories:ze,legendPosition:De,legendLayout:Oe,legendCategoryAccessor:Ie,onCategoriesChange:Ee,backgroundGraphics:Be,foregroundGraphics:Fe,canvasPreRenderers:Ne,svgPreRenderers:We,title:Ye,categoryAccessor:Ge,brush:He,onBrush:Ve,decay:Ue,pulse:Ke,transition:Ze,animate:Qe,staleness:Je,frameScheduler:et,clock:tt,random:nt,seed:rt,paused:ot=!1,suspendWhenHidden:it=!0,heatmapAggregation:st,heatmapXBins:at,heatmapYBins:lt,showValues:ht,heatmapValueFormat:dt,marginalGraphics:ft,pointIdAccessor:pt,xScaleType:mt,yScaleType:xt,accessibleTable:bt=!0,description:vt,summary:kt,linkedCrosshairName:St,linkedCrosshairSourceId:At,customLayout:Mt,onLayoutError:_t,layoutConfig:Pt,layoutSelection:Ct}=e,{customHoverBehavior:jt,customClickBehavior:Tt,hasClickBehavior:Rt}=function({customHoverBehavior:e,customClickBehavior:t,onObservation:n,chartId:r,chartType:o}){return{customHoverBehavior:(0,bc.useCallback)((t,i)=>{e?.(t,i),mc({onObservation:n,datum:t?t.data||t:null,x:t?.x,y:t?.y,chartType:o,chartId:r,context:i})},[r,o,e,n]),customClickBehavior:(0,bc.useCallback)((e,i)=>{t?.(e,i),xc({onObservation:n,datum:e?e.data||e:null,x:e?.x,y:e?.y,chartType:o,chartId:r,context:i})},[r,o,t,n]),hasClickBehavior:!(!t&&!n)}}({customHoverBehavior:me,customClickBehavior:xe,onObservation:be,chartId:we,chartType:"StreamXYFrame"}),Lt=(0,ut.useId)().replace(/:/g,""),$t=(0,ut.useRef)(!1),zt=(0,ut.useRef)({w:-1,h:-1}),Dt=(0,ut.useRef)(!1),Ot=vl({sizeProp:R,responsiveWidth:L,responsiveHeight:$,userMargin:z,marginDefault:Ac,title:Ye,legend:Te,legendPosition:De,animate:Qe,transitionProp:Ze,frameScheduler:et,clock:tt,random:nt,seed:rt,paused:ot,suspendWhenHidden:it,themeDirtyRef:$t}),It=function(){const[e,t]=(0,ba.useState)(!1);return va(()=>{t(!0)},[]),e}(),Et=function(){const e=(0,ba.useSyncExternalStore)(wa,ka,Sa);return(0,ba.useRef)(e).current}(),{reducedMotionRef:Bt,responsiveRef:Ft,size:Nt,currentTheme:Wt,transition:Yt,introEnabled:qt,tableId:Gt,rafRef:Xt,renderFnRef:Ht,scheduleRender:Vt,frameRuntime:Ut}=Ot;let Kt=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),Kt=t}const Zt=Nt[0]-Kt.left-Kt.right,Qt=Nt[1]-Kt.top-Kt.bottom,Jt=(0,ut.useMemo)(()=>Z(o),[o]),en=ye??ke,[tn,nn]=(0,ut.useState)(0),rn=(0,ut.useRef)(0),[on,sn]=(0,ut.useState)(null),an=Al(Fe,Nt,Kt,on),ln=Al(Be,Nt,Kt,on),un=(0,ut.useRef)(null),hn=(0,ut.useRef)(null),dn=(0,ut.useRef)(void 0),[fn,pn]=(0,ut.useState)(null),yn=(0,ut.useRef)(Mc.primary),gn=(0,ut.useRef)(function(){let e=-1,t=ja;return{resolve(n){if(!n)return ja;const r=Fr;return r===e||(t=function(e){if(!e)return ja;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),r=t.getPropertyValue("--semiotic-text-secondary").trim(),o=t.getPropertyValue("--semiotic-bg").trim(),i=t.getPropertyValue("--semiotic-primary").trim(),s=r||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),l=n||t.getPropertyValue("--surface-3").trim(),c=o||t.getPropertyValue("--surface-0").trim();return s||a||n||i?{axisStroke:l||ja.axisStroke,tickText:s||ja.tickText,crosshair:s?Ta(s,"66"):ja.crosshair,hoverFill:c?Ta(c,"4D"):ja.hoverFill,hoverStroke:s?Ta(s,"99"):ja.hoverStroke,pointRing:c||ja.pointRing,primary:i||ja.primary,background:c||ja.background}:ja}(n),e=r),t},invalidate(){e=-1}}}()),mn=(0,ut.useRef)(!1),xn=(0,ur.useRef)(new gr("StreamXYFrame")),[bn,vn]=(0,ut.useState)(!1),[wn,kn]=(0,ut.useState)([]),[Sn,An]=(0,ut.useState)([]),Mn="streaming"===r||["bar","swarm","waterfall"].includes(n),_n=function(e){const t=(0,Aa.useRef)(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return _a(e,t);if(!Pa(e)||!Pa(t))return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const r of n){if(!Object.prototype.hasOwnProperty.call(t,r))return!1;const n=e[r],o=t[r];if(!Object.is(n,o))if(Array.isArray(n)&&Array.isArray(o)){if(!_a(n,o))return!1}else{if(!Pa(n)||!Pa(o))return!1;if(!Ma(n,o))return!1}}return!0}(t.current,e)||(t.current=e),t.current}((0,ut.useMemo)(()=>({chartType:n,runtimeMode:Mn?"streaming":"bounded",windowSize:A,windowMode:S,arrowOfTime:Mn?k:"right",extentPadding:C,scalePadding:j,axisExtent:de,xAccessor:a,yAccessor:l,accessorRevision:c,timeAccessor:Mn?M:void 0,valueAccessor:w,colorAccessor:u,sizeAccessor:h,symbolAccessor:d,symbolMap:f,groupAccessor:p||(y?"_lineGroup":void 0),categoryAccessor:Ge,lineDataAccessor:y,xScaleType:mt,yScaleType:xt,xExtent:_,yExtent:P,sizeRange:T,binSize:v,normalize:m,baseline:x,stackOrder:b,boundsAccessor:X,boundsStyle:H,y0Accessor:V,band:U,gradientFill:!0===K?{topOpacity:.8,bottomOpacity:.05}:!1===K?void 0:K,areaGroups:J?new Set(J):void 0,lineGradient:Q,openAccessor:ee,highAccessor:te,lowAccessor:ne,closeAccessor:re,candlestickStyle:oe,lineStyle:E,pointStyle:B,areaStyle:F,swarmStyle:Y,waterfallStyle:W,colorScheme:G,barColors:q,barStyle:N,annotations:Me,decay:Ue,pulse:Ke,transition:Yt,introAnimation:qt,staleness:Je,clock:Ut.now,heatmapAggregation:st,heatmapXBins:at,heatmapYBins:lt,showValues:ht,heatmapValueFormat:dt,pointIdAccessor:pt,curve:g,themeCategorical:Wt?.colors?.categorical,themeSemantic:wt(Wt),themeSequential:Wt?.colors?.sequential,themeDiverging:Wt?.colors?.diverging,customLayout:Mt,onLayoutError:_t,layoutConfig:Pt,layoutMargin:Kt}),[n,Mn,A,S,k,C,j,de,a,l,c,M,w,u,h,d,f,p,y,Ge,mt,xt,_,P,T,v,m,x,b,X,H,V,U,K,J,Q,ee,te,ne,re,oe,E,B,F,Y,W,G,q,N,Me,Ue,Ke,Yt,qt,Je,Ut.now,st,at,lt,ht,dt,pt,g,Wt,Mt,_t,Pt,Kt])),Pn=(0,ut.useRef)(null);Pn.current||(Pn.current=new cr(_n));const Cn=function(e,t,n,r){const o=(0,_l.useRef)({accessor:t,onChange:n,readData:r}),i=(0,_l.useRef)([]);return o.current={accessor:t,onChange:n,readData:r},(0,_l.useCallback)(()=>{const{accessor:t,onChange:n,readData:r}=o.current;if(!n||!t)return;const s=function(e,t){if(!t)return[];const n=new Set,r=[];for(const o of e){if(!o||"object"!=typeof o)continue;const e="function"==typeof t?t(o):o[t];if(null==e)continue;const i=e+"";n.has(i)||(n.add(i),r.push(i))}return r}(e.current?r(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])}(Pn,Ie,Ee,e=>e.getData());!function(e,t,n,r){(0,Mr.useEffect)(()=>{e.current?.updateConfig(t),n.current=!0,r()},[t,r,e,n])}(Pn,_n,$t,Vt),function(e,t,n,r){const o=(0,Mr.useRef)(null);(0,Mr.useEffect)(()=>{const i=e.current;if(!i)return;const s=t??null;o.current!==s&&(o.current=s,i.setLayoutSelection(s),i.hasCustomRestyle?i.restyleScene(s):n.current=!0,r())},[t,r,e,n])}(Pn,Ct,$t,Vt);const jn=(0,ut.useRef)(null);jn.current||(jn.current=new gt(e=>{const t=Pn.current;t&&t.ingest(e)&&($t.current=!0,Vt())},{chunkThreshold:i,chunkSize:s})),(0,ut.useEffect)(()=>{jn.current?.updateChunkOptions({chunkThreshold:i,chunkSize:s})},[i,s]);const Tn=(0,ut.useCallback)(e=>{jn.current?.push(e)},[]),Rn=(0,ut.useCallback)(e=>{jn.current?.pushMany(e)},[]),Ln=(0,ut.useCallback)(()=>{jn.current?.clear(),Pn.current?.clear(),$t.current=!0,Vt()},[Vt]);(0,ut.useImperativeHandle)(t,()=>({push:Tn,pushMany:Rn,remove:e=>{jn.current?.flush();const t=Pn.current?.remove(e)??[];return t.length>0&&(un.current&&t.some(e=>e===un.current?.data)&&(un.current=null,pn(null)),$t.current=!0,Vt()),t},update:(e,t)=>{jn.current?.flush();const n=Pn.current?.update(e,t)??[];return n.length>0&&($t.current=!0,Vt()),n},clear:Ln,getData:()=>(jn.current?.flush(),Pn.current?.getData()??[]),getScales:()=>Pn.current?.scales??null,getExtents:()=>Pn.current?.getExtents()??null,getCustomLayout:()=>Pn.current?.lastCustomLayoutResult??null,getLayoutFailure:()=>Pn.current?.lastCustomLayoutFailure??null}),[Tn,Rn,Ln,Vt]),(0,ut.useEffect)(()=>{if(o){if(y&&Jt.length>0&&"object"==typeof Jt[0]&&null!==Jt[0]){const e="string"==typeof y?y:"coordinates";if(Array.isArray(Jt[0][e])){const t=[];for(const n of Jt){const r=n[e];if(Array.isArray(r)){const e=n.label||n.id||n.key;if(null!=e)for(const n of r)t.push({...n,_lineGroup:e});else for(const e of r)t.push(e)}}return void jn.current?.setBoundedData(t)}}jn.current?.setBoundedData(Jt)}},[o,Jt,y]);const{canvasRef:$n,interactionCanvasRef:zn}=function(e,t){return function(e){const{cancelRender:t,dirtyRef:n,frameRuntime:r,manageFrameRuntime:o,scheduleRender:i}=e,s=(0,wl.useRef)(null),a=(0,wl.useRef)(null),l=(0,wl.useRef)(!1);return function(e){const{hydrated:t,wasHydratingFromSSR:n,storeRef:r,dirtyRef:o,renderFnRef:i,cancelRender:s,cleanup:a}=e;va(()=>{const e=r.current;t&&n&&e?.cancelIntroAnimation?.(),!n&&e?.sceneNodes&&e.sceneNodes.length>0&&e?.markStylePaintPending?e.markStylePaintPending():o.current=!0,s?.(),i.current()},[t,n]);const l=(0,ba.useRef)(a);l.current=a,(0,ba.useEffect)(()=>()=>l.current?.(),[])}({hydrated:e.hydrated,wasHydratingFromSSR:e.wasHydratingFromSSR,storeRef:e.storeRef,dirtyRef:e.dirtyRef,renderFnRef:e.renderFnRef,cancelRender:e.cancelRender,cleanup:e.cleanup}),(0,wl.useEffect)(()=>{if(!1!==o)return r.subscribe(()=>{r.isActive?(n.current=!0,i()):t()})},[t,n,r,o,i]),(0,wl.useEffect)(()=>{!l.current&&(l.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:Pn,dirtyRef:$t,hydrated:It,wasHydratingFromSSR:Et,cleanup:()=>jn.current?.clear(),canvasPaintDependencies:[n,Zt,Qt,ie,O,Be,E,I,Ne,Vt]}),{hoverHandlerRef:Dn,hoverLeaveRef:On,onPointerMove:In,onPointerLeave:En}=Ot;Dn.current=e=>{if(!en)return;const t=$n.current;if(!t)return;const r=t.getBoundingClientRect(),o=e.clientX-r.left-Kt.left,i=e.clientY-r.top-Kt.top;if(0>o||o>Zt||0>i||i>Qt)return void(un.current&&(un.current=null,hn.current=null,pn(null),jt&&(jt(null),$t.current=!0),Vt()));const s=Pn.current;if(!s||0===s.scene.length)return;const l=qe(Se,e.pointerType),c=ao(s.scene,o,i,l,s.quadtree,s.maxPointRadius),u="multi"===Ae,h=()=>{un.current&&(un.current=null,hn.current=null,pn(null),jt&&jt(null),Vt())};if(!c&&!u)return void h();const d=u||!c?o:c.x,f=u||!c?i:c.y,p=c?.datum?cn(c.datum,s.resolvedRibbons):{},y=s.scales?.x?.invert,g="function"==typeof y?y(d):void 0;let m=Xe(p,d,f,null!=g?{xValue:g,xPx:d}:void 0);if(u&&s.scene.length>0&&s.scales){const e=function(e,t,n=30){const r=[];for(const o of e)if("line"===o.type){const e=o;if(2>e.path.length)continue;const i=lo(so(e.path,e.curve),t,n);if(null===i)continue;const s=bo(e.path,t);r.push({node:o,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"===o.type){const e=o;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const i=so(e.topPath,e.curve),s=so(e.bottomPath,e.curve),a=lo(i,t,n);if(null===a)continue;const l=lo(s,t,n),c=bo(e.topPath,t);r.push({node:o,datum:Array.isArray(e.datum)&&e.datum[c]?e.datum[c]:e.datum,x:e.topPath[c][0],y:a,y0:l??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 r}(s.scene,d,Math.max(l,Zt));if(e.length>0){const t=s.scales.y.invert,r=yn.current,o=y?y(d):d;if(c)m.xValue=o,m.xPx=d;else{const e={xValue:o};"string"==typeof a&&(e[a]=o),m=Xe(e,d,f,{xValue:o,xPx:d})}m.allSeries=e.map(e=>{const o=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?o-i:o,valuePx:e.y,color:e.color||r,datum:cn(e.datum,s.resolvedRibbons)}})}}c||m.allSeries?.length?(un.current=m,hn.current=c?.node??null,pn(m),jt&&(jt(m),$t.current=!0),Vt()):h()},On.current=()=>{un.current&&(un.current=null,hn.current=null,pn(null),jt&&(jt(null),$t.current=!0),Vt())};const Bn=(0,ut.useRef)(()=>{});Bn.current=e=>{if((t=e.target)instanceof Element&&null!=t.closest("[data-semiotic-annotation-widget]"))return;var t;if(!Tt)return;const n=$n.current;if(!n)return;const r=n.getBoundingClientRect(),o=e.clientX-r.left-Kt.left,i=e.clientY-r.top-Kt.top;if(0>o||o>Zt||0>i||i>Qt)return void Tt(null);const s=Pn.current;if(!s||0===s.scene.length)return void Tt(null);const a=qe(Se,dn.current),l=ao(s.scene,o,i,a,s.quadtree,s.maxPointRadius);if(!l)return void Tt(null);const c=l.datum||{},u=s.scales?.x?.invert,h="function"==typeof u?u(l.x):void 0;var d;Tt(Xe(c,l.x,l.y,null!=h?{xValue:h,xPx:l.x}:void 0),{type:"activate",inputType:(d=dn.current,"touch"===d?"touch":"pointer")})};const Fn=(0,ut.useCallback)(e=>Bn.current(e),[]),{kbFocusIndexRef:Nn,focusedNavPointRef:Wn,onKeyDown:Yn}=(qn={storeRef:Pn,hoverRef:un,hoveredNodeRef:hn,setHoverPoint:pn,customHoverBehavior:jt,customClickBehavior:Tt,scheduleRender:Vt},function({storeRef:e,hoverRef:t,hoveredNodeRef:n,setHoverPoint:r,customHoverBehavior:o,customClickBehavior:i,scheduleRender:s,extractPoints:a,toHover:l}){const c=(0,vc.useRef)(-1),u=(0,vc.useRef)(null),h=(0,vc.useRef)(null),d=(0,vc.useCallback)(d=>{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']")}(d))return;const f=e.current;if(!f)return;const p=()=>{c.current=-1,u.current=null,t.current=null,n&&(n.current=null),r(null),o(null),s()};if(0===f.scene.length)return void(0>c.current||p());let y;if(h.current?.version===f.version)y=h.current.graph;else{const e=a(f.scene);if(0===e.length)return void(0>c.current||p());y=function(e){const t=new Map;for(const n of e){const e=n.group??"_default";let r=t.get(e);r||(r=[],t.set(e,r)),r.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 r=t.get(e),o=t.get(n);return(r.length>0?r[0].y:0)-(o.length>0?o[0].y:0)}),r=Array.from(t.values()).flat();r.sort((e,t)=>e.x-t.x||e.y-t.y);const o=new Map;for(let e=0;r.length>e;e++){r[e]._flatIndex=e;const t=r[e].datum?.id;null!=t&&o.set(t+"",e)}return{flat:r,groups:n,byGroup:t,idToIdx:o}}(e),h.current={version:f.version,graph:y}}let g=c.current;if(y.flat.length>g||(p(),g=-1),("Enter"===d.key||" "===d.key)&&g>=0)return d.preventDefault(),void i(l(y.flat[g],f),{type:"activate",inputType:"keyboard"});if(0>g){if("Escape"===d.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(d.key))return;d.preventDefault(),c.current=0;const e=y.flat[0];u.current=e;const n=l(e,f);return t.current=n,r(n),o(n,{type:"focus",inputType:"keyboard"}),void s()}const m=function(e,t,n){const{group:r,indexInGroup:o}=t,i=n.byGroup.get(r);switch(e){case"ArrowRight":return i.length-1>o?i[o+1]._flatIndex:t.flatIndex;case"ArrowLeft":return o>0?i[o-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(r);return n.groups.length-1>e?wc(n,n.groups[e+1],i[o]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(r);return e>0?wc(n,n.groups[e-1],i[o]):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}}(d.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)),r=e.flat[n];return{flatIndex:n,group:r.group??"_default",indexInGroup:r._groupIndex??0}}(y,g),y);if(null===m)return;if(d.preventDefault(),0>m)return void p();c.current=m;const x=y.flat[m];u.current=x;const b=l(x,f);t.current=b,r(b),o(b,{type:"focus",inputType:"keyboard"}),s()},[i,o,a,t,n,s,r,e,l]);return{kbFocusIndexRef:c,focusedNavPointRef:u,onKeyDown:d}}({...qn,extractPoints:kc,toHover:(e,t)=>function(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}({...e,datum:cn(e.datum,t.resolvedRibbons)})}));var qn;const Gn=(0,ut.useCallback)(e=>{dn.current=e.pointerType,Nn.current=-1,Wn.current=null,In(e)},[Wn,Nn,In]),Xn=(0,ut.useCallback)(e=>{dn.current="mouse",Nn.current=-1,Wn.current=null,In({clientX:e.clientX,clientY:e.clientY,pointerType:"mouse"})},[Wn,Nn,In]),Hn=(0,ut.useCallback)(e=>{dn.current=e.pointerType},[]);Ht.current=()=>{if(Xt.current=null,!Ut.isActive)return;const e=$n.current,t=zn.current;if(!e||!t)return;const r=Pn.current;if(!r)return;const o=Ut.now(),i=r.advanceTransition(Bt.current?o+1e6:o),s=!Bt.current&&i,c=zt.current.w!==Zt||zt.current.h!==Qt,u=$t.current||i||c,h=r.consumeStylePaintPending();let d=!1;const f=r.getLastUpdateResult(),p=xn.current.beforeCompute(f,s);!u||s&&!c||(r.computeScene({width:Zt,height:Qt}),zt.current={w:Zt,h:Qt},d=!0,Cn()),xn.current.afterCompute(p,d,c);const y=function(e,t,n,r){const o=r.current,i=!0===e.lastCustomLayoutFailure?.preservedLastGoodScene,s=!i&&e.hasActivePulsesAt(t),a=!(n||i||!s&&!o)&&e.refreshPulse(t);return r.current=s,{changed:a,pending:s}}(r,o,d,Dt),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=gn.current.resolve(e);yn.current=m.primary;const x=So(Je,r.lastIngestTime>0?o-r.lastIngestTime:0),b=Je&&x.isStale;if(u||h||y.changed){const t=Ml(e,Nt,Kt,g);if(t){if(t.clearRect(-Kt.left,-Kt.top,Nt[0],Nt[1]),Je&&1>x.alpha&&(t.globalAlpha=x.alpha),function(e,t){const{background:n,hasBackgroundGraphics:r=!1,themeBackground:o="",x:i=0,y:s=0,width:a,height:l}=t,c=Ca({background:n,hasBackgroundGraphics:r,themeBackground:o});if(!c)return!1;const u=qr(e,c);u&&(e.fillStyle=u,e.fillRect(i,s,a,l))}(t,{background:O,hasBackgroundGraphics:!!Be,themeBackground:m.background,x:-Kt.left,y:-Kt.top,width:Nt[0],height:Nt[1]}),t.save(),"function"==typeof t.rect&&(t.beginPath(),t.rect(0,0,Zt,Qt),t.clip()),Ne&&r.scales)for(const e of Ne)t.save(),e(t,r.scene,r.scales,{width:Zt,height:Qt}),t.restore();const e=Mt?nc.custom:nc[n];!function(e){const{context:t,nodes:n,renderMode:r,pixelRatio:o,paintBuiltIn:i}=e;if(!r||"sketchy"===r)return void i(n);let s=[];const a=()=>{s.length&&(i(s),s=[])};for(const e of n){const n=oc(r,e);if(!n){s.push(e);continue}let l;a(),t.save();try{l=n.drawCanvas({context:t,node:e,style:e.style??{},pixelRatio:o})}finally{t.restore()}l||(ic(n.id,e.type??"unknown"),i([e]))}a()}({context:t,nodes:r.scene,renderMode:I,pixelRatio:g,paintBuiltIn:n=>{if(e&&r.scales)for(const o of e)o(t,n,r.scales,{width:Zt,height:Qt})}}),t.restore(),Je&&1>x.alpha&&(t.globalAlpha=1)}}const v=!!(en&&un.current&&r.scales),w=!!(hn.current&&Array.isArray(ye)&&ye.some(e=>e&&"object"==typeof e&&"highlight"===e.type)),k=v||w;if(k||mn.current){const e=Ml(t,Nt,Kt,g);if(e&&(e.clearRect(-Kt.left,-Kt.top,Nt[0],Nt[1]),v&&un.current&&function(e,t,n,r,o,i,s){if(!1===o.crosshair)return;const a=t.allSeries,l=a&&a.length>0,c=t.xPx??t.x;e.save();const u="object"==typeof o.crosshair?o.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(l?c:t.x,0),e.lineTo(l?c:t.x,r),e.stroke(),l||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),l){e.lineWidth=2,e.strokeStyle=s.pointRing;for(const t of a)null!=t.valuePx&&(e.beginPath(),e.arc(c,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||s.primary,e.fill(),e.stroke())}else{const n=o.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,un.current,Zt,Qt,"object"==typeof en?en:{},hn.current,m),w&&hn.current&&Array.isArray(ye))){const t=ye.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,r,o){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 r.style?n.datum?r.style(n.datum):{}:r.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||o.primary,e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=t.opacity??1,e.stroke(),e.restore()}}(e,r.scene,hn.current,t,m)}mn.current=k}u&&e&&e.setAttribute("aria-label",Na(r.scene,n+" chart"));const S=$t.current;if($t.current=S&&s&&!d,S&&r.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!on||e(on.x.domain()[0])!==e(r.scales.x.domain()[0])||e(on.x.domain()[1])!==e(r.scales.x.domain()[1])||e(on.y.domain()[0])!==e(r.scales.y.domain()[0])||e(on.y.domain()[1])!==e(r.scales.y.domain()[1])||on.x.range()[0]!==r.scales.x.range()[0]||on.x.range()[1]!==r.scales.x.range()[1]||on.y.range()[0]!==r.scales.y.range()[0]||on.y.range()[1]!==r.scales.y.range()[1])&&sn(r.scales),ft){const e=r.getData(),t="function"==typeof a?a:e=>e[a||"x"],n="function"==typeof l?l:e=>e[l||"y"];kn(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),An(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}!((Me&&Me.length>0||Mt)&&(d||s))||!d&&33>o-rn.current||(nn(e=>e+1),rn.current=o),Je?.showBadge&&vn(!!b),(s||null!=r.activeTransition||y.pending)&&Vt()},function(e,t,n,r,o,i){const s=(0,vo.useRef)("fresh");(0,vo.useEffect)(()=>{if(!e)return;const a=setInterval(()=>{const a=t.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=So(e,l-a.lastIngestTime);c.band===s.current&&c.isStale===o||(s.current=c.band,c.isStale!==o&&i(c.isStale),n.current=!0,r())},1e3);return()=>clearInterval(a)},[e,o,r,t,i,n])}(Je,Pn,$t,Vt,bn,vn);const Vn=(0,ut.useMemo)(()=>{if(ue||fe)return;const e=Pn.current;return e?.xIsDate&&on?Tl(on.x.domain()):void 0},[ue,fe,on]),Un=ue||fe||Vn,Kn=en&&fn?ge?ge(fn):(0,Sc.jsx)(gc,{hover:fn}):null,Zn=Kn?(0,Sc.jsx)(ll,{x:fn.x,y:fn.y,containerWidth:Zt,containerHeight:Qt,margin:Kt,className:"stream-frame-tooltip",children:Kn}):null,Qn=Wn.current,Jn=(0,Sc.jsx)(il,{active:Nn.current>=0,hoverPoint:fn,margin:Kt,size:Nt,shape:Qn?.shape,width:Qn?.w,height:Qn?.h}),er=Pl(a,M,"__semiotic_resolvedX","__semiotic_resolvedTime"),tr=Pl(l,w,"__semiotic_resolvedY","__semiotic_resolvedValue"),nr=er.key,rr=tr.key,or=function(e,t,n){return r=>{if(!r||!n||!e.fn&&!t.fn)return r;let o=!1;const i=r.map(n=>{const r=e.fn&&e.key&&!(e.key in n),i=t.fn&&t.key&&!(t.key in n);if(!r&&!i)return n;o=!0;const s={...n};return r&&(s[e.key]=e.fn(n)),i&&(s[t.key]=t.fn(n)),s});return o?i:r}}(er,tr,Me&&Me.length>0||!1);if(xa||!It&&Et){const e=Pn.current;e&&o&&(e.ingest({inserts:Jt,bounded:!0}),e.computeScene({width:Zt,height:Qt}));const t=e?.scene??[],n=e?.scales??null,r=Al(Fe,Nt,Kt,n),i=Al(Be,Nt,Kt,n),s=Un||(()=>{if(e?.xIsDate&&n)return Tl(n.x.domain())})();return(0,Sc.jsxs)("div",{ref:Ft,className:"stream-xy-frame"+(D?" "+D:""),role:"img","aria-label":vt||("string"==typeof Ye?Ye:"XY chart"),style:{position:"relative",width:L?"100%":Nt[0],height:$?"100%":Nt[1]},children:[(0,Sc.jsx)(tl,{summary:kt}),(0,Sc.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:Nt[0],height:Nt[1],style:{position:"absolute",left:0,top:0},children:[(0,Sc.jsx)("g",{transform:`translate(${Kt.left},${Kt.top})`,children:i}),(0,Sc.jsxs)("g",{transform:`translate(${Kt.left},${Kt.top})`,children:[O&&(0,Sc.jsx)("rect",{x:0,y:0,width:Zt,height:Qt,fill:O}),We&&n&&We.map((e,r)=>(0,Sc.jsx)(ct.Fragment,{children:e(t,n,{width:Zt,height:Qt})},"svgpre-"+r)),t.map((e,t)=>sc({node:e,index:t,renderMode:I,fallback:()=>ma(e,t,Lt)})).filter(Boolean)]})]}),(0,Sc.jsx)(qs,{width:Zt,height:Qt,totalWidth:Nt[0],totalHeight:Nt[1],margin:Kt,scales:n,showAxes:ie,axes:se,xLabel:ae,yLabel:le,yLabelRight:ce,xFormat:s,yFormat:he||pe,axisExtent:de,showGrid:je,title:Ye,legend:Te,legendHoverBehavior:Re,legendClickBehavior:Le,legendHighlightedCategory:$e,legendIsolatedCategories:ze,legendPosition:De,legendLayout:Oe,foregroundGraphics:br(r,Ar(Pn.current?.customLayoutOverlays,Ct??null)),marginalGraphics:ft,xValues:[],yValues:[],annotations:Me,onAnnotationActivate:_e,onObservation:ve??be,chartId:we,chartType:"StreamXYFrame",autoPlaceAnnotations:Pe,svgAnnotationRules:Ce,annotationFrame:0,xAccessor:nr,yAccessor:rr,annotationData:or(Pn.current?.getData()),pointNodes:Rl(Pn.current?.scene),curve:"string"==typeof g?g:void 0,linkedCrosshairName:St,linkedCrosshairSourceId:At})]})}return(0,Sc.jsxs)("div",{ref:Ft,className:"stream-xy-frame"+(D?" "+D:""),role:"group","aria-label":vt||("string"==typeof Ye?Ye:"XY chart"),tabIndex:0,style:{position:"relative",width:L?"100%":Nt[0],height:$?"100%":Nt[1],overflow:"visible",touchAction:_c(He)},onKeyDown:Yn,children:["production"!==process.env.NODE_ENV&&Pn.current&&(0,Sc.jsx)(mr,{store:Pn.current,diagnostics:xn.current}),bt&&(0,Sc.jsx)(nl,{tableId:Gt}),bt&&(0,Sc.jsx)(el,{scene:Pn.current?.scene??[],chartType:n+" chart",tableId:Gt,chartTitle:"string"==typeof Ye?Ye:void 0}),(0,Sc.jsx)(tl,{summary:kt}),(0,Sc.jsx)(Oa,{hoverPoint:fn}),(0,Sc.jsxs)("div",{role:"img","aria-label":vt||("string"==typeof Ye?Ye:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onPointerMove:en?Gn:void 0,onMouseMove:en?Xn:void 0,onPointerLeave:en?En:void 0,onMouseLeave:en?En:void 0,onPointerDown:en||Rt?Hn:void 0,onClick:Rt?Fn:void 0,children:[(0,Sc.jsx)(Sl,{size:Nt,margin:Kt,children:ln}),(0,Sc.jsx)(Ns,{width:Zt,height:Qt,totalWidth:Nt[0],totalHeight:Nt[1],margin:Kt,scales:on,showAxes:ie,axes:se,showGrid:je,xFormat:Un,yFormat:he||pe,axisExtent:de}),(0,Sc.jsx)("canvas",{ref:$n,"aria-label":Na(Pn.current?.scene??[],n+" chart"),style:{position:"absolute",left:0,top:0}}),(0,Sc.jsx)("canvas",{ref:zn,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),(0,Sc.jsx)(qs,{width:Zt,height:Qt,totalWidth:Nt[0],totalHeight:Nt[1],margin:Kt,scales:on,showAxes:ie,axes:se,xLabel:ae,yLabel:le,yLabelRight:ce,xFormat:Un,yFormat:he||pe,axisExtent:de,showGrid:je,title:Ye,legend:Te,legendHoverBehavior:Re,legendClickBehavior:Le,legendHighlightedCategory:$e,legendIsolatedCategories:ze,legendPosition:De,legendLayout:Oe,foregroundGraphics:br(an,Ar(Pn.current?.customLayoutOverlays,Ct??null)),marginalGraphics:ft,xValues:wn,yValues:Sn,annotations:Me,onAnnotationActivate:_e,onObservation:ve??be,chartId:we,chartType:"StreamXYFrame",autoPlaceAnnotations:Pe,svgAnnotationRules:Ce,annotationFrame:tn,xAccessor:nr,yAccessor:rr,annotationData:or(Pn.current?.getData()),pointNodes:Rl(Pn.current?.scene),curve:"string"==typeof g?g:void 0,underlayRendered:!0,canvasObscuresUnderlay:!!Ca({background:O,hasBackgroundGraphics:!!Be,themeBackground:Wt?.colors.background}),linkedCrosshairName:St,linkedCrosshairSourceId:At}),(He||Ve)&&(0,Sc.jsx)(yt,{width:Zt,height:Qt,totalWidth:Nt[0],totalHeight:Nt[1],margin:Kt,dimension:He?.dimension??"xy",scales:on,onBrush:Ve??(()=>{}),binSize:v,snap:He?.snap,binBoundaries:He?.binBoundaries??("bar"===n?Pn.current?.getBinBoundaries():void 0),snapDuring:He?.snapDuring,streaming:"streaming"===r}),Je?.showBadge&&(0,Sc.jsx)(Mo,{isStale:bn,position:Je.badgePosition}),Jn,Zn]})]})}));Pc.displayName="StreamXYFrame";var Cc=Pc,jc=require("react"),Tc=require("react"),Rc=(require("react/jsx-runtime"),(0,Tc.createContext)(null));function Lc(){return(0,Tc.useContext)(Rc)}var $c=require("react");function zc(e){const t=[];for(const[n,r]of Object.entries(e.fields))if("point"===r.type)t.push(e=>r.values.has(e[n]));else{const[e,o]=r.range;t.push(t=>{const r=t[n];return r>=e&&o>=r})}return e=>t.every(t=>t(e))}function Dc(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}function Oc(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[Ic,Ec]=bt(e=>({selections:new Map,setClause(t,n){e(e=>{const r=e.selections.get(t),o=r?.clauses.get(n.clientId);if(o&&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,r]of n){const n=t.fields[e];if(!n||!Oc(r,n))return!1}return!0}(o,n))return{};const i=new Map(e.selections),s=Dc(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 r=e.selections.get(t);if(!r||!r.clauses.has(n))return{};const o=new Map(e.selections),i=new Map(r.clauses);return i.delete(n),o.set(t,{...r,clauses:i}),{selections:o}})},setResolution(t,n){e(e=>{const r=e.selections.get(t);if(r?.resolution===n)return{};const o=new Map(e.selections),i=Dc(o,t);return o.set(t,{...i,resolution:n}),{selections:o}})},clearSelection(t){e(e=>{const n=e.selections.get(t);if(!n||0===n.clauses.size)return{};const r=new Map(e.selections);return r.set(t,{...n,clauses:new Map}),{selections:r}})}})),Bc=require("react");function Fc(e){const t=(0,Bc.useId)(),n=e.clientId||t,{name:r}=e,o=Ec(e=>e.selections.get(r)),i=Ec(e=>e.setClause),s=Ec(e=>e.clearClause),a=(0,Bc.useMemo)(()=>!!o&&o.clauses.size>0,[o]);return{predicate:(0,Bc.useMemo)(()=>o&&0!==o.clauses.size?function(e,t){const n=[];for(const[r,o]of e.clauses)"crossfilter"===e.resolution&&r===t||n.push(zc(o));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}(o,n):()=>!0,[o,n]),isActive:a,selectPoints:(0,Bc.useCallback)(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"point",values:new Set(r)},o=!0;o&&i(r,{clientId:n,type:"point",fields:t})},[n,r,i]),selectInterval:(0,Bc.useCallback)(e=>{const t={};let o=!1;for(const[n,r]of Object.entries(e))t[n]={type:"interval",range:r},o=!0;o&&i(r,{clientId:n,type:"interval",fields:t})},[n,r,i]),clear:(0,Bc.useCallback)(()=>{s(r,n)},[s,r,n]),clientId:n}}require("react/jsx-runtime");var Nc=(0,$c.createContext)(!1);(0,$c.createContext)(!1);var Wc=(0,$c.createContext)(null),Yc="undefined"==typeof window?$c.useEffect:$c.useLayoutEffect;var qc=c(require("react")),Gc={light:At,dark:Mt,"high-contrast":_t,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 Xc(e,t,n){const r=e.xValue??t?.[n];if(null==r)return null;const o=Number(r);return Number.isFinite(o)?o:null}function Hc(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 Vc(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"),qc.createContext(void 0);var Uc=[];function Kc(){const e=jt(e=>e.theme),t=e?.colors?.categorical;return t&&t.length>0?t:void 0}function Zc(e,t,n,r,o){if(e)return e;if(n&&"object"==typeof n&&!Array.isArray(n)){const e=Le(n,r);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=Ae[n];Array.isArray(e)&&(i=e)}return i&&0!==i.length?null!=r?(o.has(r)||o.set(r,o.size),i[o.get(r)%i.length]):i[0]:_e}function Qc({selection:e,linkedHover:t,fallbackFields:n=Uc,unwrapData:r=!1,onObservation:o,chartType:i,chartId:s,onClick:a,hoverHighlight:l,colorByField:c,mobileInteraction:u}){const h=(0,jc.useId)(),d=(0,jc.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,jc.useMemo)(()=>"series"===d?.mode?[d.seriesField||c||n[0]].filter(e=>!!e):d?.fields||n,[d,c,n]),p=Fc({name:e?.name||"__unused__",fields:f}),y=function(e){const t=e.name||"hover",{fields:n}=e,{predicate:r,isActive:o,selectPoints:i,clear:s}=Fc({name:t,fields:n});return{onHover:(0,Bc.useCallback)(e=>{if(!e)return void s();const t={};for(const r of n){const n=e[r];void 0!==n&&(t[r]=[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:r,isActive:o}}({name:d?.name||"hover",fields:f}),g=Di(e=>e.pushObservation),m=(0,jc.useCallback)(e=>{o?.(e),g?.(e)},[o,g]),x=e?{isActive:p.isActive,predicate:p.predicate}:null,[b,v]=(0,jc.useState)(null),w=(0,jc.useRef)(!1),k=c||n[0],S=(0,jc.useMemo)(()=>{if(!l||null==b||!k)return null;const e=b,t=k;return{isActive:!0,predicate:n=>("string"==typeof n[t]?n[t]:(n[t]??"")+"")===e}},[l,b,k]),A=(0,jc.useCallback)((e,n)=>{const r=!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"===d?.mode&&d.xField){const n=Xc(e,t,d.xField);null!=n&&function(e,t,n){const r=ms.positions.get(e);r?.locked||r&&r.xValue===t&&r.sourceId===n||(ms={positions:new Map(ms.positions).set(e,{xValue:t,sourceId:n})},bs())}(d.name||"hover",n,h)}"x-position"!==d?.mode&&y.onHover(t)}else"x-position"!==d?.mode||r||vs(d.name||"hover",h),"x-position"===d?.mode||r||y.onHover(null);if(l&&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 r||v(null);(o||g)&&mc({onObservation:m,datum:e?Hc(e):null,x:e?.x,y:e?.y,chartType:i||"unknown",chartId:s,context:n})},[t,y,d,h,o,i,s,g,m,l,k,u]),M=(0,jc.useCallback)((n=!0)=>{w.current=!1,t&&"x-position"!==d?.mode&&y.onHover(null),e&&u?.tapToSelect&&p.clear(),n&&l&&v(null),"x-position"===d?.mode&&(ws(d.name||"hover",h),vs(d.name||"hover",h))},[t,d,y,e,u,p,l,h]),_=(0,jc.useCallback)((n,r)=>{const c=!!u?.enabled&&(u.tapToLockTooltip||u.tapToSelect),x=!!u?.enabled&&"backgroundTap"===u.clearSelection;if("x-position"===d?.mode&&d.xField&&n){let e=n.data||n.datum||n;Array.isArray(e)&&(e=e[0]);const t=Xc(n,e,d.xField);null!=t&&function(e,t,n){const r=ms.positions.get(e);if(r?.locked){const t=new Map(ms.positions);return t.delete(e),ms={positions:t},bs(),!1}ms={positions:new Map(ms.positions).set(e,{xValue:t,sourceId:n,locked:!0})},bs()}(d.name||"hover",t,h)}if(c)if(n){w.current=!0;const r=Hc(n);if(t&&"x-position"!==d?.mode&&y.onHover(r),e&&u?.tapToSelect&&f.length>0){const e={};for(const t of f){const n=r[t];void 0!==n&&(e[t]=[n])}Vc(e)&&p.selectPoints(e)}if(l&&k){const e=r?.[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})}(o||g)&&xc({onObservation:m,datum:n?Hc(n):null,x:n?.x,y:n?.y,chartType:i||"unknown",chartId:s,context:r})}},[a,o,g,m,i,s,d,h,u,t,y,e,p,f,l,k,M]);return(0,jc.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,jc.useEffect)(()=>()=>{w.current&&M(!1)},[M]),(0,jc.useEffect)(()=>{if("x-position"!==d?.mode)return;const e=d.name||"hover";return()=>{ws(e,h),vs(e,h)}},[d?.mode,d?.name,h]),{activeSelectionHook:x,hoverSelectionHook:S,customHoverBehavior:A,customClickBehavior:_,crosshairSourceId:h}}function Jc({data:e,colorBy:t,colorScale:n,showLegend:r,legendPosition:o="right",userMargin:i,defaults:s={top:50,bottom:60,left:70,right:40},categories:a,additionalLegend:l}){const c=(0,$c.useContext)(Nc),u=null!==(0,$c.useContext)(Wc),h=void 0!==r?r:!c&&!!t,d=!!t&&(h||u),f=(0,jc.useMemo)(()=>{if(!d)return[];if(void 0!==a)return a;const n=new Set;for(const r of e){const e="function"==typeof t?t(r):r[t];null!=e&&n.add(e+"")}return Array.from(n)},[a,t,e,d]);!function(e){const t=(0,$c.useContext)(Wc),n=(0,$c.useId)(),r=function(e){const t=new Set,n=[];for(const r of e)t.has(r)||(t.add(r),n.push(r));return n}(e),o=(0,$c.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})(o.current,r)||(o.current=r);const i=o.current;Yc(()=>{if(t)return()=>t.unregisterCategories(n)},[t,n]),Yc(()=>{t&&t.registerCategories(n,i)},[t,n,i])}(u&&t?f:[]);const p=(0,jc.useMemo)(()=>{if(!h||!t)return;const r=function({data:e,colorBy:t,colorScale:n,getColor:r,strokeColor:o,strokeWidth:i,categories:s}){return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==o&&(n.stroke=o),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((o,i)=>{const s=e.find("function"==typeof t?e=>t(e)===o:e=>e[t]===o),a=s?r(s,t,n):n?n(o):Ce[i%Ce.length];return{label:o+"",color:a}}),label:""}]}}({data:e,colorBy:t,colorScale:n,getColor:Re,categories:f});return 0!==r.legendGroups.reduce((e,t)=>e+t.items.length,0)?r:void 0},[h,t,e,n,f]),y=(0,jc.useMemo)(()=>Wo(p,l),[p,l]),g=(0,jc.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")},r=t=>"number"==typeof e[t];return y&&("right"===o&&!r("right")&&110>n.right?n.right=110:"left"===o&&!r("left")&&110>n.left?n.left=110:"top"===o&&!r("top")&&50>n.top?n.top=50:"bottom"===o&&!r("bottom")&&80>n.bottom&&(n.bottom=80)),n},[s,i,y,o]);return{legend:y,margin:g,legendPosition:o}}var eu=require("react/jsx-runtime");function tu({componentName:e,message:t,diagnosticHint:n,width:r,height:o}){return(0,eu.jsx)("div",{role:"alert",style:{width:r,height:Math.max(o,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,eu.jsxs)("div",{style:{textAlign:"center",maxWidth:400},children:[(0,eu.jsx)("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:e}),(0,eu.jsx)("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:t}),n&&(0,eu.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 nu=c(require("react")),ru=require("react/jsx-runtime"),ou=class extends nu.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,ru.jsx)(tu,{componentName:"ChartErrorBoundary",message:t.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}},iu=require("react/jsx-runtime"),su="undefined"!=typeof process&&"production"!==process.env?.NODE_ENV;function au({componentName:e,width:t,height:n,children:r}){return(0,iu.jsx)(ou,{fallback:r=>(0,iu.jsx)(tu,{componentName:e,message:r.message,width:t,height:n}),children:r})}var lu={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"},cu={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function uu(e,t,n,r){if(!su)return;if(!t||0===t.length)return;if("string"!=typeof r)return;const o=t[0];if(!o||"object"!=typeof o)return;if(r in o)return;const i=Object.keys(o).join(", ");console.warn(`[semiotic] ${e}: ${n} "${r}" not found in data. Available keys: ${i}`)}function hu(e,t){const n=e.length,r=t.length,o=Array(r+1);for(let e=0;r>=e;e++)o[e]=e;for(let i=1;n>=i;i++){let n=o[0];o[0]=i;for(let s=1;r>=s;s++){const r=o[s];o[s]=e[i-1]===t[s-1]?n:1+Math.min(n,o[s],o[s-1]),n=r}}return o[r]}function du(e,t){if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(function(e,t,n=3){let r,o=n+1;for(const n of t){const t=hu(e.toLowerCase(),n.toLowerCase());o>t&&(o=t,r=n)}return o>n?void 0:r}(e,t,3)??null)}var fu=require("react"),pu=require("react");var yu=require("react");var gu=require("react");var mu=require("react"),xu=null;async function bu(){return xu||(xu=await Promise.resolve().then(()=>(E(),R))),xu}var vu="__semiotic_resolvedX",wu="__semiotic_resolvedY";var ku=require("react/jsx-runtime");function Su(e,t){if(null==t)return e;const n=e.trim(),r=n.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(r){const e=r[1],n=3===e.length?e.split("").map(e=>e+e).join(""):e;return`rgba(${parseInt(n.slice(0,2),16)}, ${parseInt(n.slice(2,4),16)}, ${parseInt(n.slice(4,6),16)}, ${t})`}if(n.startsWith("rgba(")){const e=n.lastIndexOf(","),r=n.lastIndexOf(")");if(-1!==e&&r>e)return`${n.slice(0,e+1)} ${t})`}return n.startsWith("rgb(")?n.replace(/^rgb\(/,"rgba(").replace(/\)$/,`, ${t})`):e}function Au(e){return e.filter(e=>Number.isFinite(e.at)).map(e=>({offset:1-Math.max(0,Math.min(100,e.at))/100,color:Su(e.color,e.opacity)})).sort((e,t)=>e.offset-t.offset)}function Mu(e,t,n){return"function"==typeof e?e(n):n[e||t]}function _u(e){return e instanceof Date?e.getTime():Number(e)}function Pu(e,t){return ce(1===t?.5:e/(t-1))}function Cu(e){if(!e)return At;if("string"==typeof e){if("light"===e)return At;if("dark"===e)return Mt;if("high-contrast"===e)return _t;return Gc[e]||At}const t="dark"===e.mode?Mt:At;return kt({...t,...e,colors:{...t.colors,...e.colors||{}},typography:{...t.typography,...e.typography||{}},tooltip:{...t.tooltip,...e.tooltip||{}}})}function ju(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 Tu(e,t,n){const r="function"==typeof t?t(e):e[t??n];if(null==r)return null;if(r instanceof Date)return r.getTime();if("string"==typeof r&&""===r.trim())return null;const o=Number(r);return Number.isFinite(o)?o:null}(0,lt.forwardRef)(function(e,t){const n=(0,lt.useRef)(null);!function(e,t){const{variant:n,frameRef:r,overrides:o}=t,i=(0,yu.useRef)(o);i.current=o,(0,yu.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],r=e.current?.getTopology()?.nodes??[],o=[];for(const t of n){const n=r.find(e=>e.id===t);n&&o.push({...n.data??{},id:t}),e.current?.removeNode(t)}return o},update:(t,n)=>(Array.isArray(t)?t:[t]).flatMap(t=>{const r=e.current?.updateNode(t,n);return r?[{...r,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 r=e.current?.removePoint(t)??[];for(const t of r)e.current?.push(n(t));return r},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 r=n.current?.removeLine(e)??[];for(const e of r)n.current?.pushLine(t(e));return r},clear:()=>n.current?.clear(),getData:()=>n.current?.getLines()??[],getCustomLayout:()=>n.current?.getCustomLayout?.()??null,getLayoutFailure:()=>n.current?.getLayoutFailure?.()??null}}(n,r);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)})},[])}(t,{variant:"xy",frameRef:n});const r=G(e.mode,{width:e.width,height:e.height,showGrid:e.showGrid,enableHover:e.enableHover,showLegend:e.showLegend,title:e.title,xLabel:e.xLabel,yLabel:e.yLabel,mobileInteraction:e.mobileInteraction,mobileSemantics:e.mobileSemantics,responsiveRules:e.responsiveRules},void 0);const{data:o,margin:i,className:s,xFormat:a,yFormat:l,xAccessor:c="x",yAccessor:u="y",areaBy:h,y0Accessor:d,gradientFill:f=!1,semanticGradient:p,lineDataAccessor:y="coordinates",colorBy:g,colorScheme:m,styleRules:x,curve:b="monotoneX",areaOpacity:v=.7,lineGradient:w,showLine:k=!0,lineWidth:S=2,showPoints:A=!1,pointRadius:M=3,tooltip:_,annotations:P,forecast:C,anomaly:j,band:T,xExtent:R,yExtent:L,frameProps:$={},selection:z,linkedHover:D,onObservation:O,onClick:I,hoverHighlight:E,chartId:B,loading:F,loadingContent:N,emptyContent:W,legendInteraction:q,legendPosition:X,color:H,stroke:V,strokeWidth:K,opacity:Q}=e,{width:J,height:ee,enableHover:te,showGrid:ne,showLegend:re,title:oe,description:ie,summary:se,accessibleTable:ae,xLabel:le,yLabel:ce}=r,ue=(0,lt.useMemo)(()=>Z(o),[o]),he=g||h,de=(0,lt.useMemo)(()=>p&&p.length>0?{colorStops:Au(p)}:f,[p,f]);uu("AreaChart",ue,"xAccessor",c),uu("AreaChart",ue,"yAccessor",u);const fe=function(e){const{data:t,rawData:n,colorBy:r,colorScheme:o,legendInteraction:i,legendPosition:s,selection:a,linkedHover:l,fallbackFields:c,unwrapData:u=!1,onObservation:h,chartType:d,chartId:f,showLegend:p,legend:y,userMargin:g,marginDefaults:m,onClick:x,hoverHighlight:b,mobileInteraction:v,mobileSemantics:w,loading:k,loadingContent:S,emptyContent:A,width:M,height:_}=e,P=void 0===n,C=(0,fu.useMemo)(()=>Z(t),[t]),[j,T]=(0,fu.useState)([]),R=(0,fu.useCallback)(e=>{T(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),L="string"==typeof e.colorBy?e.colorBy:void 0,$=(0,fu.useMemo)(()=>Y(v,{width:M,mobileSemantics:w}),[v,M,w]),{activeSelectionHook:z,hoverSelectionHook:D,customHoverBehavior:O,customClickBehavior:I,crosshairSourceId:E}=Qc({selection:a,linkedHover:l,fallbackFields:c,unwrapData:u,onObservation:h,chartType:d,chartId:f,onClick:x,hoverHighlight:b,colorByField:L,mobileInteraction:$}),B=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}}(l,E),F=function(e,t,n){const r=Lc(),o=Kc();return(0,jc.useMemo)(()=>{if(!t)return;const i=r??void 0,s=n??(o&&o.length>0?o:void 0)??"category10";if(0!==e.length){if("function"==typeof t){const n=Array.from(new Set(e.map(e=>t(e)+"")));if(i&&Vc(i)){const e=$e(n.map(e=>({_cat:e})),"_cat",s);return t=>i[t]||e(t)}return $e(n.map(e=>({_cat:e})),"_cat",s)}if(i&&Vc(i)){const n=$e(e,t,s);return e=>i[e]||n(e)}return $e(e,t,s)}if(i&&Vc(i)){const e=$e([{_:"a"}],"_",s);return t=>i[t]||e(t)}},[e,t,n,r,o])}(C,r,o),N=(0,fu.useMemo)(()=>{if(!r)return[];const e=new Set;for(const t of C){const n="function"==typeof r?r(t):t[r];null!=n&&e.add(n+"")}return Array.from(e)},[C,r]),W=(0,fu.useMemo)(()=>P&&j.length>0?j:N,[P,j,N]),q=function(e,t,n){const[r,o]=(0,jc.useState)(null),[i,s]=(0,jc.useState)(new Set),a=(0,jc.useMemo)(()=>new Set,[]),l=(0,jc.useCallback)(t=>{"highlight"===e&&o(t?t.label:null)},[e]),c=(0,jc.useCallback)(t=>{"isolate"===e&&s(e=>{const r=new Set(e);return r.has(t.label)?r.delete(t.label):r.add(t.label),r.size===n.length?new Set:r})},[e,n.length]),u=(0,jc.useMemo)(()=>{if(!e||"none"===e||!t)return null;const n="string"==typeof t?t:null;return"highlight"===e&&null!=r?{isActive:!0,predicate:e=>(n?e[n]:"function"==typeof t?t(e):null)===r}:"isolate"===e&&i.size>0?{isActive:!0,predicate:e=>{const r=n?e[n]:"function"==typeof t?t(e):null;return i.has(r)}}:null},[e,t,r,i]);return{highlightedCategory:"highlight"===e?r:null,isolatedCategories:"isolate"===e?i:a,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}(i,r,W),G=(0,fu.useMemo)(()=>D||(q.legendSelectionHook?q.legendSelectionHook:z),[D,q.legendSelectionHook,z]),X=function(e){const t=jt(e=>e.theme.colors.selectionOpacity);return(0,pu.useMemo)(()=>{if(void 0!==e||void 0!==t)return{name:e?.name??"",...e,unselectedOpacity:e?.unselectedOpacity??t}},[e,t])}(a),H=Kc(),V=Lc(),U=(0,fu.useMemo)(()=>{if(F)return F;if(!r||0===W.length)return;const e=Array.isArray(o)&&o.length>0||"string"==typeof o&&o.length>0?o:H&&H.length>0?H:Ce,t="__streamCat",n=$e(W.map(e=>({[t]:e})),t,e);return e=>V?.[e]||n(e)||"#999"},[F,r,W,o,H,V]),{legend:K,margin:Q,legendPosition:J}=Jc({data:C,colorBy:r,colorScale:U,showLegend:p,legendPosition:s,userMargin:g,defaults:m,categories:W,additionalLegend:y}),ee=(0,fu.useMemo)(()=>{const e={};return K&&(e.legend=K,e.legendPosition=J),i&&"none"!==i&&(e.legendHoverBehavior=q.onLegendHover,e.legendClickBehavior=q.onLegendClick,e.legendHighlightedCategory=q.highlightedCategory,e.legendIsolatedCategories=q.isolatedCategories),P&&r&&(e.legendCategoryAccessor=r,e.onCategoriesChange=R),e},[K,J,i,q.onLegendHover,q.onLegendClick,q.highlightedCategory,q.isolatedCategories,P,r,R]),te=Array.isArray(n)?Z(n):n,ne=function(e,t,n,r){if(!e)return null;if(!1===r)return null;if(null!=r)return(0,iu.jsx)("div",{style:{width:t,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:r});const o=Math.min(5,Math.floor(n/40)),i=Math.max(8,Math.floor(n/(3*o))),s=Math.max(6,Math.floor(n/(2.5*o))),a=Math.floor((n-(o*(i+s)-s))/2);return(0,iu.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:o},(e,n)=>(0,iu.jsx)("div",{className:"semiotic-loading-bar",style:{...cu,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))})}(k,M,_,S),re=ne?null:function(e,t,n,r){return!1===r||null==e||Array.isArray(e)&&e.length>0?null:Array.isArray(e)?(0,iu.jsx)("div",{style:{...lu,width:t,height:n},children:r||"No data available"}):null}(te,M,_,A);return{data:C,colorScale:F,allCategories:W,legendState:q,effectiveSelectionHook:G,activeSelectionHook:z,customHoverBehavior:O,customClickBehavior:I,mobileInteraction:$,legend:K,margin:Q,legendPosition:J,earlyReturn:ne||re||null,legendBehaviorProps:ee,crosshairProps:B,resolvedSelection:X}}({data:ue,rawData:o,colorBy:he,colorScheme:m,legendInteraction:q,legendPosition:X,selection:z,linkedHover:D,fallbackFields:he?["string"==typeof he?he:""]:[],unwrapData:!1,onObservation:O,onClick:I,hoverHighlight:E,mobileInteraction:r.mobileInteraction,mobileSemantics:r.mobileSemantics,chartType:"AreaChart",chartId:B,showLegend:re,userMargin:i,marginDefaults:r.marginDefaults,loading:F,loadingContent:N,emptyContent:W,width:J,height:ee}),{effectiveData:pe,statisticalAnnotations:ye}=function(e){const{data:t,xAccessor:n,yAccessor:r,forecast:o,anomaly:i,groupBy:s}=e,a="string"==typeof n?n:vu,l="string"==typeof r?r:wu,c=(0,mu.useMemo)(()=>{if(!o&&!i)return t;const e="function"==typeof n,s="function"==typeof r;return e||s?t.map(t=>{const o={...t};return e&&(o[vu]=n(t)),s&&(o[wu]=r(t)),o}):t},[t,o,i,n,r]),[u,h]=(0,mu.useState)(null),[d,f]=(0,mu.useState)([]),p=(0,mu.useRef)(o),y=(0,mu.useRef)(i);return(0,mu.useEffect)(()=>{if(!o&&!i)return void((p.current||y.current)&&(h(null),f([]),p.current=o,y.current=i));let e=!1;const t=o!==p.current||i!==y.current;if(p.current=o,y.current=i,t&&(h(null),f([])),o){const t=s&&"string"==typeof s&&"object"==typeof o?{...o,_groupBy:s}:o;(async function(...e){return(await bu()).buildForecast(...e)})(c,a,l,t,i).then(t=>{e||(h(t),f(t.annotations))}).catch(()=>{e||(h(null),f([]))})}else i&&async function(...e){return(await bu()).buildAnomalyAnnotations(...e)}(i).then(t=>{e||(h(null),f(t))}).catch(()=>{e||f([])});return()=>{e=!0}},[c,o,i,a,l,s]),{effectiveData:u?u.processedData:t,statisticalAnnotations:d,hasForecast:!!u,xAccessorKey:a,yAccessorKey:l}}({data:ue,xAccessor:c,yAccessor:u,forecast:C,anomaly:j,groupBy:h}),ge=(0,lt.useMemo)(()=>Ie(c,u),[c,u]),{flattenedData:me,lineStyle:xe,pointStyle:be,defaultTooltipContent:ve}=function(e){const{safeData:t,data:n,areaBy:r,lineDataAccessor:o,colorBy:i,colorScale:s,color:a,stroke:l,strokeWidth:c,opacity:u,effectiveSelectionHook:h,resolvedSelection:d,areaOpacity:f,showLine:p,lineWidth:y,showPoints:g,pointRadius:m,xAccessor:x,yAccessor:b,xLabel:v,yLabel:w,xFormat:k,yFormat:S,groupField:A,styleRules:M,ruleContext:_}=e,P=(0,gu.useMemo)(()=>U({data:n,safeData:t,areaBy:r,lineDataAccessor:o}),[n,t,r,o]),C=(0,gu.useMemo)(()=>e=>{const t={};if(i){if(s){const n=Re(e,i,s);t.fill=n,p?(t.stroke=n,t.strokeWidth=y):t.stroke="none"}}else{const e=a||_e;t.fill=e,p?(t.stroke=e,t.strokeWidth=y):t.stroke="none"}return t.fillOpacity=f,M&&M.length>0&&Object.assign(t,Ne(e,M,_?_(e):{value:void 0})),t},[i,s,a,f,p,y,M,_]),j=(0,gu.useMemo)(()=>De(C,{stroke:l,strokeWidth:c,opacity:u}),[C,l,c,u]);return{flattenedData:P,lineStyle:(0,gu.useMemo)(()=>{return e=j,n=d,(t=h??null)?(r,...o)=>{const i={...e(r,...o)};if(t.isActive)if(t.predicate(r))n?.selectedStyle&&Object.assign(i,n.selectedStyle);else{const e=n?.unselectedOpacity??.5;i.opacity=e,i.fillOpacity=e,i.strokeOpacity=e,n?.unselectedStyle&&Object.assign(i,n.unselectedStyle)}return i}:e;var e,t,n},[j,h,d]),pointStyle:(0,gu.useMemo)(()=>{if(g)return e=>{const t={r:m,fillOpacity:1};return i?s&&(t.fill=Re(e.parentLine||e,i,s)):t.fill=a||_e,t}},[g,m,i,s,a]),defaultTooltipContent:(0,gu.useMemo)(()=>function(e){const t=e.find(e=>"title"===e.role),n=e.filter(e=>"title"!==e.role);return e=>{const r=e.data;if(!r)return null;const o=t?hc(dc(r,t.accessor),t.format):null;return(0,lc.jsxs)("div",{className:"semiotic-tooltip",style:et,children:[null!=o&&(0,lc.jsx)("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0},children:o}),n.map((e,t)=>{const n=hc(dc(r,e.accessor),e.format);return(0,lc.jsxs)("div",{style:t>0?{marginTop:2}:void 0,children:[(0,lc.jsxs)("span",{style:{opacity:.7},children:[e.label,": "]}),(0,lc.jsx)("span",{children:n})]},t)})]})}}([{label:v||cc(x),accessor:x,role:"x",format:k},{label:w||cc(b),accessor:b,role:"y",format:S},...A?[{label:cc(A),accessor:A,role:"group"}]:[],...fc(e.band,S)]),[x,b,v,w,A,k,S,e.band])}}({safeData:pe,data:o,areaBy:h,lineDataAccessor:y,colorBy:he,colorScale:fe.colorScale,color:H,stroke:V,strokeWidth:K,opacity:Q,effectiveSelectionHook:fe.effectiveSelectionHook,resolvedSelection:fe.resolvedSelection,areaOpacity:v,showLine:k,lineWidth:S,showPoints:A,pointRadius:M,xAccessor:c,yAccessor:u,xLabel:le,yLabel:ce,xFormat:a,yFormat:l,groupField:h||g,band:T,styleRules:x,ruleContext:ge}),we=function({componentName:e,data:t,accessors:n,requiredProps:r}){if(r)for(const[t,n]of Object.entries(r))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(n){const r=function(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:[...e]}(t).find(e=>e&&"object"==typeof e);if(r){const t=Object.keys(r);for(const[o,i]of Object.entries(n))if(i&&"string"==typeof i&&!(i in r)){const n=du(i,t),r=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${i}" not found in data. Available fields: ${t.join(", ")}.${r}`}}}return null}({componentName:"AreaChart",data:o,accessors:{xAccessor:c,yAccessor:u}}),ke={chartType:"area",...null!=o&&{data:me},xAccessor:c,yAccessor:u,groupAccessor:h||void 0,...d&&{y0Accessor:d},...T&&{band:T},...de&&{gradientFill:de},...w&&{lineGradient:w},curve:b,lineStyle:xe,...A&&be&&{pointStyle:be},size:[J,ee],responsiveWidth:e.responsiveWidth,responsiveHeight:e.responsiveHeight,margin:fe.margin,showAxes:r.showAxes,xLabel:le,yLabel:ce,xFormat:a,yFormat:l,enableHover:te,...e.pointIdAccessor&&{pointIdAccessor:e.pointIdAccessor},showGrid:ne,...fe.legendBehaviorProps,...it({title:oe,description:ie,summary:se,accessibleTable:ae,className:s,animate:e.animate,axisExtent:e.axisExtent,autoPlaceAnnotations:e.autoPlaceAnnotations}),..."multi"===_?{tooltipContent:e=>{const t=e.allSeries;if(!t||0===t.length)return(0,Je.jsx)("div",{className:"semiotic-tooltip",style:et,children:(0,Je.jsx)("div",{children:nt(e.data?.value??e.data?.y)})});const n=e.xValue??e.data?.time??e.data?.x;return(0,Je.jsxs)("div",{className:"semiotic-tooltip",style:et,children:[null!=n&&(0,Je.jsx)("div",{style:{fontWeight:600,marginBottom:4,fontSize:"0.9em",borderBottom:"1px solid var(--semiotic-border, #eee)",paddingBottom:4},children:nt(n)}),t.map((e,t)=>(0,Je.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"1px 0"},children:[(0,Je.jsx)("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:e.color,flexShrink:0}}),(0,Je.jsx)("span",{style:{flex:1,fontSize:"0.85em"},children:e.group}),(0,Je.jsx)("span",{style:{fontWeight:500,fontSize:"0.85em"},children:nt(e.value)})]},t))]})},tooltipMode:"multi"}:at({tooltip:_,defaultTooltipContent:ve}),...st({linkedHover:D,selection:z,onObservation:O,onClick:I,hoverHighlight:E,mobileInteraction:fe.mobileInteraction,customHoverBehavior:fe.customHoverBehavior,customClickBehavior:fe.customClickBehavior}),...(P&&P.length>0||ye.length>0)&&{annotations:[...P||[],...ye]},...R&&{xExtent:R},...L&&{yExtent:L},...fe.crosshairProps,...$};return fe.earlyReturn?fe.earlyReturn:we?(0,ku.jsx)(tu,{componentName:"AreaChart",message:we,width:J,height:ee}):(0,ku.jsx)(au,{componentName:"AreaChart",width:J,height:ee,children:(0,ku.jsx)(Cc,{ref:n,...ke})})}).displayName="AreaChart",E();var Ru="__semiotic_resolvedX",Lu="__semiotic_resolvedY",$u="__compoundGroup";function zu(e,t,n){const r=e[t],o=e[n];return null==r||null==o||Number.isNaN(r)||Number.isNaN(o)}function Du(e,t,n,r,o){const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Cu(r.theme).colors.categorical,a=n??r.colorScheme??s,l="string"==typeof t?t:"__ssrAreaColorBy",c="function"==typeof t?i.map(e=>({...e,__ssrAreaColorBy:t(e)})):i,u=t?$e(c,l,a):void 0,h=!1!==o.showLine,d="number"==typeof o.lineWidth?o.lineWidth:2,f="number"==typeof o.areaOpacity?o.areaOpacity:.7,p=Oe(o.yAccessor),y=o.styleRules;return(e,n)=>{const r=t&&u?Re(e,t,u):"string"==typeof o.color?o.color:_e,i={fill:r,fillOpacity:f,stroke:h?r:"none",...h&&{strokeWidth:d}};return y?.length&&Object.assign(i,Ne(e,y,{value:p(e),category:n})),void 0!==o.stroke&&(i.stroke=o.stroke),void 0!==o.strokeWidth&&(i.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(i.opacity=o.opacity),i}}function Ou(e,t,n,r,o){const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Cu(r.theme).colors.categorical,a=n??r.colorScheme??s,l="string"==typeof t?t:"__ssrBubbleColorBy",c="function"==typeof t?i.map(e=>({...e,__ssrBubbleColorBy:t(e)})):i,h=t?$e(c,l,a):void 0,d=o.sizeBy,f=Array.isArray(o.sizeRange)?o.sizeRange:[5,40],p=d?i.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],y=p.length?u(p):void 0;return e=>({fill:t&&h?Re(e,t,h):"string"==typeof o.color?o.color:_e,fillOpacity:"number"==typeof o.bubbleOpacity?o.bubbleOpacity:.6,r:d?ze(e,d,f,y):f[0],stroke:o.stroke??o.bubbleStrokeColor??"white",strokeWidth:o.strokeWidth??o.bubbleStrokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}})}function Iu(e,t,n,r,o){const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Cu(r.theme).colors.categorical,a=n??r.colorScheme??s,l="string"==typeof t?t:"__ssrScatterColorBy",c="function"==typeof t?i.map(e=>({...e,__ssrScatterColorBy:t(e)})):i,h=t?$e(c,l,a):void 0,d=o.sizeBy,f=Array.isArray(o.sizeRange)?o.sizeRange:[3,15],p=d?i.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],y=p.length?u(p):void 0,g=Ie(o.xAccessor,o.yAccessor),m=o.styleRules;return e=>{const n={fill:t&&h?Re(e,t,h):"string"==typeof o.color?o.color:_e,fillOpacity:"number"==typeof o.pointOpacity?o.pointOpacity:.8,r:d?ze(e,d,f,y):"number"==typeof o.pointRadius?o.pointRadius:5};return m?.length&&Object.assign(n,Ne(e,m,g(e))),void 0!==o.stroke&&(n.stroke=o.stroke),void 0!==o.strokeWidth&&(n.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(n.opacity=o.opacity),n}}var Eu={frameType:"xy",buildProps:(e,t,n,r,o)=>({chartType:"scatter",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[5,40],colorScheme:n,...r,pointStyle:r.pointStyle||Ou(e,t,n,r,o),showLegend:r.showLegend??!!t})};function Bu(e,t,n,r,o){if(!o.showPoints)return;const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Cu(r.theme).colors.categorical,a=n??r.colorScheme??s,l="string"==typeof t?t:"__ssrPointColorBy",c="function"==typeof t?i.map(e=>({...e,__ssrPointColorBy:t(e)})):i,u=t?$e(c,l,a):void 0,h="number"==typeof o.pointRadius?o.pointRadius:3;return e=>{const n=t&&u?Re(e,t,u):"string"==typeof o.color?o.color:_e;return{r:h,fill:n,stroke:"none"}}}var Fu={frameType:"xy",buildProps:(e,t,n,r,o)=>{const i=t||o.lineBy,s=o.fillArea,a=Array.isArray(s)?"mixed":s?"area":"line",l=Cu(r.theme).colors.categorical,c=function(e,t,n,r,o){const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=Cu(r.theme).colors.categorical,a=n??r.colorScheme??s,l="string"==typeof t?t:"__ssrLineColorBy",c="function"==typeof t?i.map(e=>({...e,__ssrLineColorBy:t(e)})):i,u=t?$e(c,l,a):void 0,h=Ie(o.xAccessor,o.yAccessor),d=function(e){const{lineWidth:t=2,colorBy:n,colorScale:r,color:o,resolveStroke:i,fillArea:s,areaOpacity:a=.3,styleRules:l,ruleContext:c}=e;return(e,u)=>{const h={strokeWidth:t},d=!0===s||Array.isArray(s)&&null!=u&&s.includes(u);let f;return i?f=i(e,u):n?r&&(f=Re(e,n,r)):f=o||_e,void 0!==f&&(h.stroke=f,d&&(h.fill=f,h.fillOpacity=a)),l?.length&&Object.assign(h,Ne(e,l,c?c(e,u):{value:void 0,category:u})),h}}({lineWidth:"number"==typeof o.lineWidth?o.lineWidth:2,colorBy:t,colorScale:u,color:"string"==typeof o.color?o.color:void 0,fillArea:o.fillArea,areaOpacity:"number"==typeof o.areaOpacity?o.areaOpacity:.3,styleRules:o.styleRules,ruleContext:h});return De(d,{stroke:"string"==typeof o.stroke?o.stroke:void 0,strokeWidth:"number"==typeof o.strokeWidth?o.strokeWidth:void 0,opacity:"number"==typeof o.opacity?o.opacity:void 0})}(e,i,n,r,o),u=function(e){const t=e.xAccessor||"x",n=e.yAccessor||"y",r=e.lineBy,o=e.colorBy||r;let i=Array.isArray(e.data)?Z(e.data).filter(e=>!!e&&"object"==typeof e):[];const s=function(e,t,n){const r="function"==typeof t,o="function"==typeof n,i=r?Ru:t,s=o?Lu:n;return r||o?{xKey:i,yKey:s,rows:e.map(e=>{const i={...e};return r&&(i[Ru]=t(e)),o&&(i[Lu]=n(e)),i})}:{rows:e,xKey:i,yKey:s}}(i,t,n);i=s.rows;const a=s.xKey,l=s.yKey,c=Array.isArray(e.annotations)?[...e.annotations]:[];let u,h,d="string"==typeof r||"function"==typeof r?r:void 0,f=e.baseLineStyle;if(e.forecast){const t=D(i,a,l,r&&"string"==typeof r&&"object"==typeof e.forecast?{...e.forecast,_groupBy:r}:e.forecast,e.anomaly);if(i=t.processedData,c.push(...t.annotations),u=function(e,t,n){const r=n.upperBounds,o=n.lowerBounds;if(!r&&!o)return;const i="function"==typeof r?r:"string"==typeof r?e=>e[r]:null,s="function"==typeof o?o:"string"==typeof o?e=>e[o]:null;let a=1/0,l=-1/0;for(const n of e){const e=Number(n[t]);if(Number.isFinite(e)&&(a>e&&(a=e),e>l&&(l=e)),i){const e=i(n);null!=e&&Number.isFinite(e)&&(e>l&&(l=e),a>e&&(a=e))}if(s){const e=s(n);null!=e&&Number.isFinite(e)&&(a>e&&(a=e),e>l&&(l=e))}}return Number.isFinite(a)&&Number.isFinite(l)?[a,l]:void 0}(i,l,e.forecast),r&&"string"==typeof r?(i=i.map(e=>({...e,[$u]:`${e[r]}__${e[C]||"observed"}`})),d=$u):d=C,e.baseLineStyle){const t=O(t=>e.baseLineStyle(t),e.forecast);f=e=>t(e)}}else e.anomaly&&c.push(...z(e.anomaly));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,r,o){const i=new Map;for(const t of e){const e=o?(t[o]??"")+"":"__single";i.has(e)||i.set(e,[]),i.get(e).push(t)}if("interpolate"===t){const e=[];for(const[,t]of i)for(const o of t)zu(o,n,r)||e.push(o);return{rows:e,groupKey:o}}if("zero"===t){const e=[];for(const[,t]of i)for(const o of t)zu(o,n,r)?e.push({...o,[r]:0}):e.push(o);return{rows:e,groupKey:o}}const s=[],a="_gapSegment";for(const[e,t]of i){let o=0,i=[];const l=()=>{if(0===i.length)return;const t="__single"===e?"__seg"+o:`${e}__seg${o}`;for(const e of i)s.push({...e,[a]:t});i=[],o++};for(const e of t)zu(e,n,r)?l():i.push(e);l()}return{rows:s,groupKey:a}}(i,e.gapStrategy,a,l,"string"==typeof d?d:void 0);i=t.rows,t.groupKey&&(d=t.groupKey)}if(e.directLabel){const t=function(e,t,n,r,o,i,s,a){if(!t||!n)return{annotations:[]};const l="object"==typeof t?t:{},c=l.position||"end",u=l.fontSize||11,h="function"==typeof n?n:e=>e[n],d=new Map;for(const t of e){const e=h(t);if(null==e)continue;const n=e+"";""!==n&&(d.has(n)||d.set(n,[]),d.get(n).push(t))}const f=new Map;for(const[e,t]of d)t.sort((e,t)=>Number(e[r])-Number(t[r])),f.set(e,"end"===c?t[t.length-1]:t[0]);const p=$e(Array.from(f.entries()).map(([e])=>({__lbl:e})),"__lbl",i??s),y=Array.from(f.entries()).map(([e,t])=>({type:"text",label:e,[r]:t[r],[o]:t[o],dx:"end"===c?6:-6,dy:0,color:p?Re({__lbl:e},"__lbl",p):a||_e,fontSize:u}));y.sort((e,t)=>Number(e[o])-Number(t[o]));for(let e=1;y.length>e;e++){const t=y[e-1],n=y[e],r=Number(t[o])+t.dy;u+2>Math.abs(Number(n[o])+n.dy-r)&&(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"===c?{right:g}:{left:g}}}(i,e.directLabel,"string"==typeof o||"function"==typeof o?o:void 0,a,l,e.colorScheme,e.themeCategorical,e.color);c.push(...t.annotations),h=t.marginExtra}return{data:i,xAccessor:"function"==typeof t?a:t,yAccessor:"function"==typeof n?l:n,groupAccessor:d,colorAccessor:o,annotations:c,lineStyle:f,yExtent:u,marginExtra:h}}({data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",lineBy:o.lineBy,colorBy:i,colorScheme:n,color:"string"==typeof o.color?o.color:void 0,forecast:o.forecast,anomaly:o.anomaly,gapStrategy:o.gapStrategy,directLabel:o.directLabel,annotations:r.annotations,themeCategorical:l,baseLineStyle:c}),h=r.pointStyle||Bu(u.data,u.colorAccessor,n,r,o);let d=r.margin;u.marginExtra&&d&&"object"==typeof d?d={...d,...null!=u.marginExtra.right&&{right:Math.max(Number(d.right)||0,u.marginExtra.right)},...null!=u.marginExtra.left&&{left:Math.max(Number(d.left)||0,u.marginExtra.left)}}:u.marginExtra&&null==d&&(d={top:20,right:u.marginExtra.right??20,bottom:30,left:u.marginExtra.left??40});const f=(!o.directLabel||void 0!==r.showLegend)&&(r.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||c,...Array.isArray(s)&&{areaGroups:s},...s&&null!=o.areaOpacity&&{areaOpacity:o.areaOpacity},...null!=o.band&&{band:o.band},...r,...void 0!==d&&{margin:d},annotations:u.annotations,...u.yExtent&&!r.yExtent&&{yExtent:u.yExtent},...h&&{pointStyle:h},showLegend:f}}},Nu={frameType:"xy",buildProps:(e,t,n,r,o)=>{const i=Array.isArray(e)?Z(e):[],s=o.timeAccessor||"time",a=o.valueAccessor||"value",l=o.categoryAccessor,c=o.valueExtent||r.yExtent,u="down"===o.direction?function({data:e,valueAccessor:t,timeAccessor:n,binSize:r,valueExtent:o,extentPadding:i}){if(o)return[o[1],o[0]];if(!e||0===e.length)return;const s=new Map;for(const o of e){const e=Tu(o,n,"time"),i=Tu(o,t,"value");if(null==e||null==i)continue;const a=Math.floor(e/r)*r;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(o.binSize),valueExtent:c,extentPadding:o.extentPadding}):c,h={...void 0!==o.fill&&{fill:o.fill},...void 0!==o.stroke&&{stroke:o.stroke},...void 0!==o.strokeWidth&&{strokeWidth:o.strokeWidth},...void 0!==o.opacity&&{opacity:o.opacity},...void 0!==o.gap&&{gap:o.gap}};return{chartType:"bar",data:i,...r,runtimeMode:"streaming",windowMode:"growing",windowSize:Math.max(1,i.length),arrowOfTime:o.arrowOfTime||"right",timeAccessor:s,valueAccessor:a,xExtent:o.timeExtent||r.xExtent,yExtent:u,extentPadding:o.extentPadding??r.extentPadding,binSize:o.binSize,categoryAccessor:l,barColors:o.colors||r.barColors,colorScheme:o.colors||r.colorScheme,barStyle:r.barStyle||h,showLegend:r.showLegend??!!l}}},Wu={frameType:"xy",buildProps:(e,t,n,r,o)=>{const i=t||o.areaBy,s=U({data:e,safeData:Array.isArray(e)?Z(e):[],areaBy:o.areaBy,lineDataAccessor:o.lineDataAccessor||"coordinates"}),a=o.semanticGradient,l=a&&a.length>0?{colorStops:Au(a)}:r.gradientFill,c=r.pointStyle||Bu(s,i,n,r,o);return{chartType:"area",data:s,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",y0Accessor:o.y0Accessor,groupAccessor:o.areaBy||void 0,colorAccessor:i,colorScheme:n,...r,...void 0!==l&&{gradientFill:l},lineStyle:r.lineStyle||Du(s,i,n,r,o),...c&&{pointStyle:c}}}},Yu={frameType:"xy",buildProps:(e,t,n,r,o)=>{const i=o.xAccessor||"x",s=o.seriesAAccessor||"a",a=o.seriesBAccessor||"b",l=e=>_u(Mu(i,"x",e)),c=e=>_u(Mu(s,"a",e)),u=e=>_u(Mu(a,"b",e)),h=o.seriesAColor||"var(--semiotic-danger, #dc2626)",d=o.seriesBColor||"var(--semiotic-info, #2563eb)",f=o.areaOpacity??.6,p=o.lineWidth??1.5,y=!1!==o.showLines,g=!1!==r.showLegend,m=o.seriesALabel||"A",x=o.seriesBLabel||"B",b=r.legendPosition||"right",v=function(e,t,n,r){if(!e.length)return[];const o=e.filter(e=>Number.isFinite(t(e))).sort((e,n)=>t(e)-t(n)),i=[];let s=0,a=null,l=null,c=[];const u=(e,t)=>e>t?"A":t>e?"B":null,h=e=>`seg-${s}-${e}`,d=e=>i.push(e),f=(e,t)=>{d({__x:e.x,__y:e.y,__y0:e.y,__diffSegment:h(t),__diffWinner:t,__valA:e.y,__valB:e.y,__sourceDatum:e.datum})};for(let e=0;o.length>e;e++){const i=o[e],p=t(i),y=n(i),g=r(i);if(!Number.isFinite(p)||!Number.isFinite(y)||!Number.isFinite(g))continue;const m=u(y,g);if(null!==m)if(null!=a){if(l&&l.w!==m){let e,t;if(c.length>0)e=c[0].x,t=c[0].y;else{const n=y-l.a-(g-l.b);if(0!==n){const r=Math.max(0,Math.min(1,(l.b-l.a)/n));e=l.x+r*(p-l.x),t=l.a+r*(y-l.a)}else e=l.x,t=l.a}d({__x:e,__y:t,__y0:t,__diffSegment:h(a),__diffWinner:a,__valA:t,__valB:t}),s++,a=m,d({__x:e,__y:t,__y0:t,__diffSegment:h(a),__diffWinner:a,__valA:t,__valB:t});for(let e=1;c.length>e;e++)f(c[e],a)}else for(const e of c)f(e,a);c=[],d({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:h(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:i}),l={x:p,a:y,b:g,w:m}}else{a=m;for(const e of c)f(e,a);c=[],d({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:h(a),__diffWinner:a,__valA:y,__valB:g,__sourceDatum:i}),l={x:p,a:y,b:g,w:m}}else c.push({x:p,y:y,datum:i})}for(const e of c)f(e,a??"A");return i}(Array.isArray(e)?e:[],l,c,u),w=[];if(y&&Array.isArray(e)){const t=e.filter(e=>Number.isFinite(l(e))).sort((e,t)=>l(e)-l(t));for(const e of t){const t=l(e),n=c(e),r=u(e);Number.isFinite(n)&&w.push({__x:t,__y:n,__diffSegment:"line-A"}),Number.isFinite(r)&&w.push({__x:t,__y:r,__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")?h:d,stroke:"none",fillOpacity:f}},lineStyle:e=>({stroke:"A"==("line-A"===e.__diffSegment?"A":"B")?h:d,strokeWidth:p,fill:"none"}),curve:o.curve||"linear",...r,...g&&{legend:{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:m,color:h},{label:x,color:d}]}]},legendPosition:b}}}},qu={frameType:"xy",buildProps:(e,t,n,r,o)=>{const i=t||o.areaBy,s="string"==typeof i&&Array.isArray(e)?$e(e,i,n):void 0,a="number"==typeof o.areaOpacity?o.areaOpacity:.7,l=r.lineStyle||(e=>{const t=null==i?void 0:Re(e,i,s),n=o.showLine??!0,r={fill:o.color??t,stroke:n?o.stroke??t:"none",...n?{strokeWidth:o.strokeWidth??o.lineWidth??2}:{},fillOpacity:a,...null==o.opacity?{}:{opacity:o.opacity}},l=o.styleRules;if(l?.length){const t=Oe(o.yAccessor),n=i?"function"==typeof i?(i(e)??"")+"":(e[i]??"")+"":void 0;Object.assign(r,Ne(e,l,{value:t(e),category:n}))}return r}),c=o.normalize?"zero":o.baseline??"zero",u=r.pointStyle||Bu(e,i,n,r,o);return{chartType:"stackedarea",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.areaBy,colorAccessor:i,colorScheme:n,normalize:o.normalize,baseline:c,stackOrder:o.stackOrder,lineStyle:l,...r,...u&&{pointStyle:u},curve:r.curve??o.curve??"monotoneX",showLegend:r.showLegend??!!i}}},Gu={frameType:"xy",buildProps:(e,t,n,r,o)=>{const[i]=r.size??[600,400];return{chartType:"candlestick",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.highAccessor||"high",highAccessor:o.highAccessor||"high",lowAccessor:o.lowAccessor||"low",openAccessor:o.openAccessor,closeAccessor:o.closeAccessor,candlestickStyle:o.candlestickStyle,...r,scalePadding:r.scalePadding??Math.max(2,Math.min(12,Math.round(i/40))),extentPadding:r.extentPadding??(i>200?.1:.02)}}},Xu={frameType:"xy",buildProps:(e,t,n,r,o)=>{const i=r.pointStyle||Iu(e,t,n,r,o),s=function(e,t,n){return e&&0!==e.length?(r,o)=>{const i=Ne(r,e,t(r,o)),s=n?n(r,o):void 0;return s?{...i,...s}:i}:n}(o.styleRules,Ie(o.xAccessor||"x",o.yAccessor||"y"),l),a=s?e=>({..."function"==typeof i?i(e):i,...s(e)}):i;var l;return{chartType:"scatter",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,sizeAccessor:o.sizeBy,...o.symbolBy&&{symbolAccessor:o.symbolBy},...o.symbolMap&&{symbolMap:o.symbolMap},colorScheme:n,...r,sizeRange:o.sizeRange||[3,15],pointStyle:a,showLegend:r.showLegend??!!t}}},Hu={frameType:"xy",buildProps:(e,t,n,r,o)=>{const i=o.xCenter,s=o.yCenter,a=o.quadrants,l=o.centerlineStyle||{},c=!1!==o.showQuadrantLabels,u=o.quadrantLabelSize??12,h=l.stroke||"#999",d=l.strokeWidth??1,f=Array.isArray(l.strokeDasharray)?l.strokeDasharray.join(","):l.strokeDasharray,p=V.createElement,y=a?[(e,t,n)=>{if(!t?.x||!t?.y)return null;const r=n.width,o=n.height,l=null!=i?t.x(i):r/2,y=null!=s?t.y(s):o/2;if(null!=i&&!Number.isFinite(l))return null;if(null!=s&&!Number.isFinite(y))return null;const g=Math.max(0,Math.min(r,l)),m=Math.max(0,Math.min(o,y)),x=[{c:a.topLeft,x:0,y:0,w:g,h:m},{c:a.topRight,x:g,y:0,w:r-g,h:m},{c:a.bottomLeft,x:0,y:m,w:g,h:o-m},{c:a.bottomRight,x:g,y:m,w:r-g,h:o-m}],b=c?[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:r-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:o-8,fill:a.bottomLeft.color,fontWeight:600,fontSize:u,opacity:.5},a.bottomLeft.label),p("text",{key:"lbr",x:r-8,y:o-8,fill:a.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},a.bottomRight.label)]:[];return p(V.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:o,stroke:h,strokeWidth:d,strokeDasharray:f}),p("line",{key:"hc",x1:0,y1:m,x2:r,y2:m,stroke:h,strokeWidth:d,strokeDasharray:f}),...b)}]:void 0;return{chartType:"scatter",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[3,15],colorScheme:n,pointStyle:r.pointStyle||o.pointStyle||Iu(e,t,n,r,o),...r,showLegend:r.showLegend??!!t,...y&&{svgPreRenderers:y}}}},Vu={frameType:"xy",buildProps:(e,t,n,r,o)=>{const i=function(e,t){if(!Array.isArray(e))return{data:e,orderMap:new WeakMap};const n=t.xAccessor||"x",r=t.yAccessor||"y",o=t.orderAccessor?[...e].sort((e,n)=>null==e||"object"!=typeof e?1:null==n||"object"!=typeof n?-1:_u(Mu(t.orderAccessor,"order",e))-_u(Mu(t.orderAccessor,"order",n))):e,i=new WeakMap;let s=0;for(const e of o){if(null==e||"object"!=typeof e)continue;const t=_u(Mu(n,"x",e)),o=_u(Mu(r,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&s++}let a=0;for(const e of o){if(null==e||"object"!=typeof e)continue;const t=_u(Mu(n,"x",e)),o=_u(Mu(r,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&i.set(e,{idx:a++,total:s})}return{data:o,orderMap:i}}(e,o),s=o.pointRadius??4;return{chartType:"scatter",data:i.data,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,colorScheme:n,pointStyle:e=>{const t=i.orderMap.get(e),n=t?.idx??0,r=t?.total??1;return{fill:r>0?Pu(n,r):"#6366f1",stroke:"white",strokeWidth:1,r:s,fillOpacity:1}},...r,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 r=t[e],o=t[e+1],i=Pu(e,t.length);100>t.length&&n.push(V.createElement("line",{key:"halo-"+e,x1:r.x,y1:r.y,x2:o.x,y2:o.y,stroke:"white",strokeWidth:s+2,strokeLinecap:"round",opacity:.5})),n.push(V.createElement("line",{key:"segment-"+e,x1:r.x,y1:r.y,x2:o.x,y2:o.y,stroke:i,strokeWidth:s,strokeLinecap:"round"}))}return V.createElement(V.Fragment,null,...n)}]}}};function Uu(e){return Math.max(0,Math.min(1,e))}function Ku(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 Zu(e,t,n){const r=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(n)}`}function Qu(e,t){const n=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Uu(e.offset),color:e.color})).sort((e,t)=>e.offset-t.offset);if(0===n.length)return"#999999";if(1===n.length)return n[0].color;const r=Uu(t);if(n[0].offset>=r)return n[0].color;if(r>=n[n.length-1].offset)return n[n.length-1].color;for(let e=0;n.length-1>e;e++){const t=n[e],o=n[e+1];if(t.offset>r||r>o.offset)continue;const i=o.offset-t.offset,s=i>0?(r-t.offset)/i:0,a=Ku(t.color),l=Ku(o.color);if(!a||!l)return.5>s?t.color:o.color;const[c,u,h]=a,[d,f,p]=l;return Zu(c+(d-c)*s,u+(f-u)*s,h+(p-h)*s)}return n[n.length-1].color}function Ju(e,t,n){return null==n?`${e}-${t}`:`${e}-${t}-${n}`}var eh=require("react/jsx-runtime");function th(e=240){const t=360-e,n=180+t/2,r=n*Math.PI/180;return{sweepRad:e*Math.PI/180,gapDeg:t,startAngleDeg:n,startAngleRad:r,offsetRad:-Math.PI/2+r}}x(),require("react");var nh={RdBu:me,PiYG:xe,PRGn:be,BrBG:ve,RdYlBu:we,RdYlGn:ke,Spectral:Se},rh="__likert_neutral_neg",oh="__likert_neutral_pos";function ih(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}x();var sh=c(require("react"));function ah(e){return!0===e?{topOpacity:.8,bottomOpacity:.05}:!1===e?void 0:e}function lh(e,t,n,r,o){const i=Cu(r.theme).colors.categorical,s=n??r.colorScheme,a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],l="string"==typeof t?t:"__ssrColorBy",c="function"==typeof t?a.map(e=>({...e,__ssrColorBy:t(e)})):a,u=t?$e(c,l,s??i):void 0,h=Zc("string"==typeof o.color?o.color:void 0,i,s,void 0,new Map),d=Oe(o.valueAccessor),f=o.styleRules,p=r.pieceStyle;return(e,n)=>{const r={fill:t&&u?Re(e,t,u):h};return f?.length&&Object.assign(r,Ne(e,f,{value:d(e),category:n})),"function"==typeof p?Object.assign(r,p(e,n)||{}):p&&"object"==typeof p&&Object.assign(r,p),void 0!==o.stroke&&(r.stroke=o.stroke),void 0!==o.strokeWidth&&(r.strokeWidth=o.strokeWidth),void 0!==o.opacity&&(r.opacity=o.opacity),r}}function ch(e,t,n,r,o){const i=lh(e,t,n,r,o);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 uh(e,t,n,r,o){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,l=Cu(r.theme).colors.categorical,c=n??r.colorScheme,u=t?$e(a,s,c??l):void 0,h=Zc("string"==typeof o.color?o.color:void 0,l,c,void 0,new Map);return e=>{const n=t&&u?Re(e,t,u):h;return{fill:n,fillOpacity:.6,stroke:o.stroke??n,...void 0!==o.strokeWidth&&{strokeWidth:o.strokeWidth},...void 0!==o.opacity&&{opacity:o.opacity}}}}function hh(e,t,n,r,o){const i=lh(e,t,n,r,o),s="number"==typeof o.dotRadius?o.dotRadius:5;return(e,t)=>({r:s,fillOpacity:.8,...i(e,t)})}function dh(e,t,n,r,o){const i=lh(e,t,n,r,o),s=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=o.sizeBy,l=Array.isArray(o.sizeRange)?o.sizeRange:[3,8],c=a?s.map(e=>"function"==typeof a?a(e):Number(e[a])).filter(Number.isFinite):[],h=c.length?u(c):void 0,d="number"==typeof o.pointRadius?o.pointRadius:4,f="number"==typeof o.pointOpacity?o.pointOpacity:.7;return(e,t)=>({r:a?ze(e,a,l,h):d,fillOpacity:f,...i(e,t)})}var fh={frameType:"ordinal",buildProps:(e,t,n,r,o)=>({chartType:"bar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",oSort:o.sort??!1,colorAccessor:t,colorScheme:n,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:ah(r.gradientFill),pieceStyle:lh(e,t,n,r,o)})},ph={frameType:"ordinal",buildProps:(e,t,n,r,o)=>{const i=t||o.stackBy;return{chartType:"bar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.stackBy,colorAccessor:i,colorScheme:n,projection:"horizontal"===o.orientation?"horizontal":"vertical",normalize:o.normalize,oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:ah(r.gradientFill),pieceStyle:lh(e,i,n,r,o),showLegend:r.showLegend??!!i}}},yh={frameType:"ordinal",buildProps:(e,t,n,r,o)=>{const i=t||o.groupBy;return{chartType:"clusterbar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",groupBy:o.groupBy,colorAccessor:i,colorScheme:n,projection:"horizontal"===o.orientation?"horizontal":"vertical",oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:ah(r.gradientFill),pieceStyle:lh(e,i,n,r,o),showLegend:r.showLegend??!!i}}},gh={frameType:"ordinal",buildProps:(e,t,n,r,o)=>{const i=t||o.categoryAccessor;return{chartType:"pie",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",colorAccessor:i,colorScheme:n,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...null!=o.startAngle&&{startAngle:o.startAngle},...r,pieceStyle:lh(e,i,n,r,o),showLegend:r.showLegend??!!i}}},mh={frameType:"ordinal",layout:{primarySize:{width:400,height:400}},buildProps:(e,t,n,r,o)=>{const i=t||o.categoryAccessor;return{chartType:"donut",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",margin:r.margin??{top:50,right:40,bottom:60,left:70},innerRadius:o.innerRadius??60,colorAccessor:i,colorScheme:n,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...null!=o.startAngle&&{startAngle:o.startAngle},...r,pieceStyle:lh(e,i,n,r,o)}}},xh={frameType:"ordinal",buildProps:(e,t,n,r,o)=>{const i=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=o.valueAccessor||"value",a=i.map(e=>Number("function"==typeof s?s(e):e[s])).filter(Number.isFinite),l=a.length?[Math.min(...a),Math.max(...a)]:void 0;return{chartType:"histogram",data:e,oAccessor:o.categoryAccessor||(e=>null==e.category?"All":e.category+""),rAccessor:s,projection:"horizontal",bins:o.bins??25,normalize:o.relative??!1,colorAccessor:t,colorScheme:n,barPadding:o.categoryPadding??20,...o.valueExtent?{rExtent:o.valueExtent}:l?{rExtent:l}:{},...r,summaryStyle:ch(e,t,n,r,o)}}},bh={frameType:"ordinal",buildProps:(e,t,n,r,o)=>({chartType:"boxplot",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,colorScheme:n,...null!=o.showOutliers&&{showOutliers:o.showOutliers},...null!=o.outlierRadius&&{outlierRadius:o.outlierRadius},...r,summaryStyle:r.summaryStyle||ch(e,t,n,r,o)})},vh={frameType:"ordinal",buildProps:(e,t,n,r,o)=>({chartType:"violin",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,projection:"horizontal"===o.orientation?"horizontal":"vertical",bins:o.bins??25,showIQR:o.showIQR??!0,barPadding:o.categoryPadding??20,colorScheme:n,...r,summaryStyle:r.summaryStyle||uh(e,t,n,r,o),showLegend:r.showLegend??!!t,...o.valueExtent&&{rExtent:o.valueExtent}})},wh={frameType:"ordinal",buildProps:(e,t,n,r,o)=>({chartType:"swarm",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,...o.symbolBy&&{symbolAccessor:o.symbolBy},...o.symbolMap&&{symbolMap:o.symbolMap},colorScheme:n,...r,sizeRange:o.sizeRange||[3,8],pieceStyle:r.pieceStyle||dh(e,t,n,r,o),showLegend:r.showLegend??!!t})},kh={frameType:"ordinal",layout:{modeDefaults:{showGrid:!0}},buildProps:(e,t,n,r,o)=>({chartType:"point",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,colorScheme:n,projection:"vertical"===o.orientation?"vertical":"horizontal",oSort:o.sort??"auto",barPadding:o.categoryPadding??10,...r,pieceStyle:hh(e,t,n,r,o),showGrid:r.showGrid??!0,showLegend:r.showLegend??!!t})},Sh={frameType:"ordinal",buildProps:(e,t,n,r,o)=>{const i=t||o.subcategoryAccessor;return{chartType:"swimlane",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.subcategoryAccessor,colorAccessor:i,categoryAccessor:o.categoryAccessor,subcategoryAccessor:o.subcategoryAccessor,colorScheme:n,projection:"vertical"===o.orientation?"vertical":"horizontal",...null!=o.trackFill&&{trackFill:o.trackFill},...o.valueExtent&&{rExtent:o.valueExtent},...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:ah(r.gradientFill),pieceStyle:r.pieceStyle||lh(e,i,n,r,o),showLegend:r.showLegend??!!i,barPadding:o.barPadding??40}}},Ah={frameType:"ordinal",buildProps:(e,t,n,r,o)=>({chartType:"ridgeline",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,colorScheme:n,projection:"vertical"===o.orientation?"vertical":"horizontal",bins:o.bins??20,amplitude:o.amplitude??1.5,barPadding:o.categoryPadding??5,oSort:o.oSort??!1,...r,summaryStyle:r.summaryStyle||((i,s)=>({fillOpacity:.5,...lh(e,t,n,r,o)(i,s)})),showLegend:r.showLegend??!!t})},Mh={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,r,o)=>{const i=Array.isArray(o.levels)&&o.levels.length>=2?o.levels:["Strongly disagree","Disagree","Neutral","Agree","Strongly agree"],s="vertical"!==o.orientation;let a=function(e,t,n,r,o,i){const s=new Map,a=new Set(t);for(const l of e){const e=n(l);s.has(e)||s.set(e,new Map);const c=s.get(e);if(r){const e=r(l);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 o=t[n];c.set(o,(c.get(o)||0)+1)}else if(o&&i){const e=o(l),t=i(l);if(!a.has(e))continue;c.set(e,(c.get(e)||0)+(Number.isFinite(t)?t:0))}}const l=[];for(const[e,n]of s){let r=0;for(const e of t)r+=n.get(e)||0;if(0!==r)for(let o=0;t.length>o;o++){const i=t[o],s=n.get(i)||0;l.push({__likertCategory:e,__likertLevel:i,__likertLevelLabel:i,__likertCount:s,__likertPct:s/r*100,__likertLevelIndex:o})}}return l}(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],i,ih(o.categoryAccessor,"question"),o.levelAccessor?null:ih(o.valueAccessor,"score"),o.levelAccessor?ih(o.levelAccessor,"level"):null,o.levelAccessor?ih(o.countAccessor,"count"):null);s&&(a=function(e,t){const n=t.length,r=n%2!=0,o=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===rh?i=n:n.__likertLevel===oh?a=n:t.set(n.__likertLevelIndex,n);r&&i&&s.push(i);for(let e=o-1;e>=0;e--){const n=t.get(e);n&&s.push(n)}r&&a&&s.push(a);for(let e=r?o+1:o;n>e;e++){const n=t.get(e);n&&s.push(n)}}return s}(function(e,t){const n=t.length,r=n%2!=0,o=Math.floor(n/2),i=[];for(const t of e){const e=t.__likertLevelIndex;if(r&&e===o){const e=t.__likertPct/2;i.push({...t,__likertLevel:rh,__likertPct:-e}),i.push({...t,__likertLevel:oh,__likertPct:e})}else i.push(o>e?{...t,__likertPct:-t.__likertPct}:t)}return i}(a,i),i));const l=Cu(r.theme).colors.diverging,c=Array.isArray(n)&&n.length>=i.length?n:function(e,t){if(0>=e)return[];if(t){const n=nh[t];if(n){if(1===e)return[n(.5)];const t=[];for(let r=0;e>r;r++)t.push(n(r/(e-1)));return t}}const n=["#da1e28","#ff8389","#ffb3b8"],r=["#a6c8ff","#4589ff","#0043ce"],o="#a8a8a8";if(1===e)return[o];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(o);for(let e=0;s>e;e++)a.push(r[Math.min(Math.floor(e*r.length/s),r.length-1)]);return a}(i.length,l),u=new Map(i.map((e,t)=>[e,c[t]||"#888"])),h=i.length%2&&u.get(i[Math.floor(i.length/2)])||"#888",d="function"==typeof o.valueFormat?o.valueFormat:e=>Math.abs(Number(e)).toFixed(0)+"%",f=Wo(!1===r.showLegend?void 0:{legendGroups:[{label:"",items:i.map(e=>({label:e})),styleFn:e=>({fill:u.get(e.label)||"#888"})}]},r.legend);return{chartType:"bar",data:a,oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:s?"horizontal":"vertical",barPadding:o.barPadding,showGrid:r.showGrid,oLabel:o.categoryLabel,rLabel:o.valueLabel||(s?void 0:"Percentage"),rFormat:d,...o.categoryFormat&&{oFormat:o.categoryFormat},...o.valueExtent&&{rExtent:o.valueExtent},...r,pieceStyle:e=>{const t=e.__likertLevel||e.data?.__likertLevel;return{fill:t===rh||t===oh?h:u.get((e.__likertLevelLabel||e.data?.__likertLevelLabel||t)+"")||"#888"}},showLegend:r.showLegend??!0,legendPosition:r.legendPosition||"right",...f&&{legend:f},__legendIncludesAutomatic:!0}}},_h={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,r,o)=>{const i="vertical"===o.orientation,s=t||o.categoryAccessor;return{chartType:i?"bar-funnel":"funnel",data:e,oAccessor:o.stepAccessor||"step",rAccessor:o.valueAccessor||"value",colorAccessor:s,categoryAccessor:o.categoryAccessor,projection:i?"vertical":"horizontal",connectorAccessor:o.connectorAccessor,connectorStyle:o.connectorStyle,...!i&&null!=o.connectorOpacity&&{connectorOpacity:o.connectorOpacity},barPadding:i?40:0,colorScheme:n,...r,showAxes:i,showGrid:i,pieceStyle:lh(e,s,n,r,o),showLabels:o.showLabels??!0}}},Ph={frameType:"ordinal",layout:{primarySize:{width:300,height:250}},renderOverlay:function(e,{theme:t}){const n=e.__gauge;if(!n)return null;const r=(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,o=n.needleColor||t.colors.text,i=n.showScaleLabels?(n.thresholds||[]).filter(e=>e.value>n.gMin&&n.gMax>e.value):[];return(0,eh.jsxs)(eh.Fragment,{children:[n.showNeedle&&(0,eh.jsxs)(eh.Fragment,{children:[(0,eh.jsx)("line",{x1:n.centerX,y1:n.centerY,x2:n.centerX+n.needleLength*Math.cos(r),y2:n.centerY+n.needleLength*Math.sin(r),stroke:o,strokeWidth:2.5,strokeLinecap:"round"}),(0,eh.jsx)("circle",{cx:n.centerX,cy:n.centerY,r:4,fill:o})]}),null!=n.contextValue&&(0,eh.jsx)("text",{x:n.centerX,y:n.contextValueY,textAnchor:"middle",dominantBaseline:"middle",fontSize:n.valueFontSize,fontWeight:700,fill:o,children:n.contextValue}),i.map((e,r)=>{const o=(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,l=((o+Math.PI/2)/(2*Math.PI)*12+12)%12,c=l>=11||1>l?"middle":5>l?"start":7>l?"middle":"end",u=l>=11||1>l?"auto":5>l?"middle":7>l?"hanging":"middle";return(0,eh.jsxs)("g",{children:[(0,eh.jsx)("line",{x1:n.centerX+Math.cos(o)*i,y1:n.centerY+Math.sin(o)*i,x2:n.centerX+Math.cos(o)*s,y2:n.centerY+Math.sin(o)*s,stroke:t.colors.border,strokeWidth:2,strokeLinecap:"round"}),(0,eh.jsx)("text",{x:n.centerX+Math.cos(o)*a,y:n.centerY+Math.sin(o)*a,textAnchor:c,dominantBaseline:u,fill:t.colors.textSecondary,fontSize:10,children:e.label||e.value+""})]},"gauge-label-"+r)})]})},buildProps:(e,t,n,r,o)=>{const i=o.min??0,s=o.max??100,a=o.sweep??240,l=o.arcWidth??.3,c=!1!==o.showNeedle,h=!1!==o.fillZones,{startAngleDeg:d}=th(a),f=o.thresholds||[{value:s,color:o.color||"#4e79a7"}],p=r.gradientFill,y=function(e){const{min:t,max:n,value:r,thresholds:o,fillColor:i,backgroundColor:s,fillZones:a,showScaleLabels:l,gradientFill:c,gradientSteps:u=240}=e,h=n-t||1,d=(Math.max(t,Math.min(n,r))-t)/h;let f=o&&o.length>0?[...o].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=!!c&&c.colorStops.length>=2,y=[],g=new Map,m=[];if(p){const e=a?d:1,t=Ju("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))),r=[];for(let t=0;n>t;t++)r.push(Qu(c.colorStops,e*(t+.5)/n));const o=Ju("fill",0);y.push({category:o,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:r}}),g.set(o,{fill:r[0]||s})}}else{let e=t;for(let n=0;f.length>n;n++){const r=f[n],o=(r.value-e)/h,i=(e-t)/h,l=(r.value-t)/h,c=Math.max(0,(a?Math.min(d,l):l)-i),u=a?Math.max(0,o-c):0;if(c>0){const e=Ju("fill",n);y.push({category:e,value:c,_zone:r.label||"Zone "+(n+1),_isFill:!0}),g.set(e,{fill:r.color})}if(u>0){const e=Ju("bg",n);y.push({category:e,value:u,_zone:r.label||"Zone "+(n+1),_isFill:!1}),g.set(e,{fill:s,opacity:.4})}e=r.value}}if(l&&o&&o.length>0)for(const e of o)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:o.value,thresholds:f,fillColor:o.color,backgroundColor:o.backgroundColor||"#e0e0e0",fillZones:h,showScaleLabels:!1!==o.showScaleLabels,gradientFill:p&&"object"==typeof p&&"colorStops"in p?p:void 0}),[g,m]=r.size||[300,250],x=function(e=240){const{sweepRad:t,offsetRad:n}=th(e),r=[[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||r.push([Math.cos(e),Math.sin(e)]);const o=r.map(e=>e[0]),i=r.map(e=>e[1]),[s,a]=u(o),[l,c]=u(i);return{minX:s,maxX:a,minY:l,maxY:c,width:a-s,height:c-l,cx:(s+a)/2,cy:(l+c)/2}}(a),b=Math.min(10,Math.max(1,Math.min(g,m)/12)),v=Math.max(4,Math.min((g-2*b)/x.width,(m-2*b)/x.height)-2),w=Math.max(0,Math.min(v-1.5,v*(1-l))),k=g/2-x.cx*v,S=m/2-x.cy*v,A=2*(v+4),M=Math.max(i,Math.min(s,o.value??i)),_="function"==typeof o.valueFormat?o.valueFormat(M):Math.round(M)+"",P=o.centerContent??r.centerContent,C=null!=P?"function"==typeof P?P(M,i,s):P:"sparkline"===o.mode||"context"===o.mode?void 0:sh.createElement("div",{style:{textAlign:"center",lineHeight:1.2}},sh.createElement("div",{style:{fontSize:Math.max(16,.3*v),fontWeight:700,color:"var(--semiotic-text, #333)"}},_),!1!==o.showScaleLabels&&sh.createElement("div",{style:{fontSize:11,color:"var(--semiotic-text-secondary, #666)"}},`${i} – ${s}`));return{chartType:"donut",data:y.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:w,sweepAngle:a,startAngle:d,oSort:!1,pieceStyle:y.pieceStyle,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...r,size:[g,m],margin:{top:S-A/2,bottom:m-S-A/2,left:k-A/2,right:g-k-A/2},...null!=C&&{centerContent:C},showAxes:!1,annotations:[...Array.isArray(r.annotations)?r.annotations:[],...y.gaugeAnnotations],__gauge:{gMin:i,gMax:s,sweep:a,arcWidth:l,value:M,startAngleDeg:d,thresholds:f,centerX:k,centerY:S,radius:v,innerRadius:w,showScaleLabels:!1!==o.showScaleLabels,needleLength:w>20?w-8:v-1,showNeedle:c,needleColor:o.needleColor,..."context"===o.mode&&null==P&&{contextValue:_,contextValueY:S-.2*w,valueFontSize:Math.max(12,Math.min(22,.28*v))}}}}},Ch=require("d3-scale");function jh(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 Th(e,t,n){const r=t.incoming[e.id],o=t.outgoing[e.id],i=[];for(const e of r)i.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:n.get(e.id).targetSide});for(const e of o)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))},l=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,c=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,u=null!=c?c-1:null!=l&&Number.isFinite(l)?l-1:null,h=[...new Set(i.map(e=>e.time))].sort((e,t)=>e-t),d=new Map;for(let e=1;h.length>e;e++)d.set(h[e],h[e-1]);const f=e=>{const t=d.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",r=Math.min(n,"top"===t?y:g);if(r>0){const o=f(e.time);p.push({time:o,delta:-r,kind:"transfer-out",side:t}),p.push({time:o,delta:+r,kind:"transfer-in",side:e.side}),"top"===t?y-=r:g-=r,"top"===e.side?y+=r:g+=r,n-=r}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 o)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===P||P>e.systemInTime)&&(P=e.systemInTime);let C=null;for(const e of r)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===C||e.systemOutTime>C)&&(C=e.systemOutTime);if(A.length>0){const e=A[A.length-1],t=Math.max(null!=_?_:-1/0,null!=C?C:-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],r=Math.min(null!=c?c:1/0,null!=P?P:1/0);Number.isFinite(r)&&n.t>r&&n.topMass+n.botMass>0&&A.unshift({t:r,topMass:n.topMass,botMass:n.botMass})}return{samples:A,peak:b,topPeak:v,botPeak:w,localAttachments:S}}function Rh(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Lh(e,t){return e.map(e=>({t:Rh(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function $h(e,t,n){const r=e.value*n;if("out"===e.kind){const o=e.sideMassBefore*n;if("top"===e.side){const e=t-o;return[e,e+r]}const i=t+o;return[i-r,i]}const o=e.sideMassAfter*n;if("top"===e.side){const e=t-o;return[e,e+r]}const i=t+o;return[i-r,i]}function zh(e,t){let n=0;for(let r=0;t.length>r;r++)for(let o=r+1;t.length>o;o++){const i=t[r],s=t[o];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 Dh(e,t){let n=0;for(const r of t)n+=Math.abs(e[r.source]-e[r.target])*(r.value||1);return n}function Oh(e,t){return 1e3*zh(e,t)+Dh(e,t)}function Ih(e,t){return{slots:e.map(e=>({peak:{...e.peak},occupants:e.occupants.slice()})),map:{...t}}}function Eh(e,t,n){e.length>8||n.length>40?(function(e,t,n,r=6){const o=e.length;if(1>=o)return;let i=Ih(e,t),s=Oh(t,n);for(let a=0;r>a;a++){const r=Array(o).fill(0),a=Array(o).fill(0);for(const e of n){const n=t[e.source],o=t[e.target];r[n]+=o*(e.value||1),a[n]+=e.value||1,r[o]+=n*(e.value||1),a[o]+=e.value||1}const l=Array.from({length:o},(e,t)=>t).sort((e,t)=>(a[e]>0?r[e]/a[e]:e)-(a[t]>0?r[t]/a[t]:t)),c=l.map(t=>e[t]),u=new Map;l.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 c)e.push(t);const h=Oh(t,n);if(s>h)s=h,i=Ih(e,t);else if(h===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,r=6){const o=e.length;if(1>=o)return;let i=Oh(t,n);for(let s=0;r>s;s++){let r=!1;for(let s=0;o-1>s;s++){const o=e[s];e[s]=e[s+1],e[s+1]=o;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s);const a=Oh(t,n);if(i>a)i=a,r=!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(!r)break}}(e,t,n,6)):function(e,t,n){const r=e.length;if(1>=r)return;const o={...t},i=Object.keys(o),s=Array.from({length:r},(e,t)=>t),a=s.slice(),l={...o};let c=s.slice(),u=1/0;const h=()=>{for(const e of i)l[e]=a[o[e]];const e=Oh(l,n);u>e&&(u=e,c=s.slice())},d=(e,t)=>{const n=s[e],r=s[t];s[e]=r,s[t]=n,a[n]=t,a[r]=e};h();const f=Array(r).fill(0);let p=0;for(;r>p;)p>f[p]?(d(p%2==0?0:f[p],p),h(),f[p]++,p=0):(f[p]=0,p++);const y=c.map(t=>e[t]),g=new Map;c.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 Bh(e,t,n,r,o){const{plotH:i,padding:s,valueScale:a,packing:l,laneOrder:c,lifetimeMode:u="full"}=o,h={},d={};for(const t of e)h[t.id]=n[t.id].topPeak||0,d[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 o=null!=e&&Number.isFinite(e)?e:1/0,i=null!=n&&Number.isFinite(n)?n:-1/0;for(const e of r.outgoing[t.id]){o>e.startTime&&(o=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&o>e.systemInTime&&(o=e.systemInTime);const t=f?(e.startTime+e.endTime)/2:e.endTime;t>i&&(i=t)}for(const e of r.incoming[t.id]){const t=f?(e.startTime+e.endTime)/2:e.startTime;o>t&&(o=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(o)?o:null,end:Number.isFinite(i)?i:null}}const y={},g=[];if("reuse"===l){const n=new Map;for(const t of e)n.set(t.id,0);const o=new Map;for(const t of e)o.set(t.id,0);for(const e of t)o.set(e.target,(o.get(e.target)??0)+1);const i=[];for(const t of e)0===(o.get(t.id)??0)&&i.push(t.id);for(;i.length;){const e=i.shift();for(const t of r.outgoing[e]??[]){const r=(n.get(e)??0)+1;r>(n.get(t.target)??0)&&n.set(t.target,r),o.set(t.target,o.get(t.target)-1),0===o.get(t.target)&&i.push(t.target)}}const s=[...e].filter(e=>null!==p[e.id].start).sort((e,t)=>{const r=n.get(e.id)??0,o=n.get(t.id)??0;return r!==o?r-o: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 r=g[e].occupants[g[e].occupants.length-1];if(null===t.start||void 0===r||t.start>=r.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,h[e.id]),g[n].peak.botPeak=Math.max(g[n].peak.botPeak,d[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:h[e.id],botPeak:d[e.id]}}),y[e.id]=t});let m=null,x=null,b=null,v=null;const w=()=>{m=zh(y,t),b=Dh(y,t)},k=()=>{x=zh(y,t),v=Dh(y,t)};"crossing-min"===c?(w(),Eh(g,y,t),k()):"inside-out"===c?(w(),function(e,t){const n=e.length;if(1>=n)return;const r=e=>e.peak.topPeak+e.peak.botPeak,o=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>r(t.slot)-r(e.slot)),i=Array(n),s=Math.floor((n-1)/2);i[s]=o[0].idx;let a=s-1,l=s+1;for(let e=1;o.length>e;e++)e%2==1&&n>l||0>a?i[l++]=o[e].idx:i[a--]=o[e].idx;const c=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 c)e.push(t)}(g,y),k()):"crossing-min+inside-out"===c&&(w(),Eh(g,y,t),function(e,t,n){const r=e.length;if(1>=r)return;const o=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((r-1)/2);let s=Oh(t,n);for(const{slot:a}of o){const o=e.indexOf(a);if(0>o)continue;const l=i;if(o===l)continue;const c=e[o];e.splice(o,1),e.splice(l,0,c);const u=new Map;for(let e=0;r>e;e++)u.set(e,e);if(l>o){for(let e=o+1;l>=e;e++)u.set(e,e-1);u.set(o,l)}else{for(let e=l;o>e;e++)u.set(e,e+1);u.set(o,l)}for(const e of Object.keys(t))t[e]=u.get(t[e]);const h=Oh(t,n);if(h>s){const n=e[l];e.splice(l,1),e.splice(o,0,n);const i=new Map;for(let e=0;r>e;e++)i.set(e,e);if(o>l){for(let e=l+1;o>=e;e++)i.set(e,e-1);i.set(l,o)}else{for(let e=o;l>e;e++)i.set(e,e+1);i.set(l,o)}for(const e of Object.keys(t))t[e]=i.get(t[e])}else s=h}}(g,y,t),k());const S=g.map(e=>{const t=new Map;for(const r of e.occupants){const e=n[r.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[r,o]of e){if(r>t)break;n=o}return n},M=[];for(let e=0;g.length-1>e;e++){const t=S[e],n=S[e+1],r=new Set([...t.map(e=>e[0]),...n.map(e=>e[0])]);let o=0;for(const e of r){const r=A(t,e),i=A(n,e);r.bot+i.top>o&&(o=r.bot+i.top)}M.push(o)}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 C=0===g.length?0:g[0].peak.topPeak+M.reduce((e,t)=>e+t,0)+g[g.length-1].peak.botPeak,j={};for(const t of e)j[t.id]=_[y[t.id]];return{effectiveSlotsHeight:C,centerlines:j,laneLifetime:p,slots:g,slotByNode:y,slotCenter:_,crossingsBefore:m,crossingsAfter:x,lengthBefore:b,lengthAfter:v}}function Fh(e){const{sx:t,sTop:n,sBot:r,tx:o,tTop:i,tBot:s,cp1X:a,cp2X:l}=e,c=(n+r)/2,u=(i+s)/2;return{pathD:[`M${t},${n}`,`C${a},${n} ${l},${i} ${o},${i}`,`L${o},${s}`,`C${l},${s} ${a},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:a,y:c},{x:l,y:u},{x:o,y:u}],halfWidth:(r-n)/2}}}function Nh(e){const{nodes:t,edges:n,domain:r,plotW:o,plotH:i,ribbonLane:s,edgeOpacity:a,colorOf:l,layoutOpts:c}=e,u=function(e,t,n){const r=[],o=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]||r.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]||r.push({kind:"invalid-node-time",id:t.id}));for(const e of t)o.has(e.source)||r.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),o.has(e.target)||r.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||r.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||r.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):r.push({kind:"invalid-edge-time",id:e.id});return r}(t,n,r),h=(0,Ch.scaleTime)().domain(r).range([0,o]);if(u.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!0},issues:u,xScale:h};const d=function(e,t,n){const{plotH:r,pairing:o="temporal",packing:i="reuse",laneOrder:s="crossing-min",lifetimeMode:a="half"}=n,l=function(e,t){const n={},r={};for(const t of e)n[t.id]=[],r[t.id]=[];for(const e of t)r[e.source]&&r[e.source].push(e),n[e.target]&&n[e.target].push(e);return{incoming:n,outgoing:r}}(e,t),c=function(e,t,n,r="value"){const o="temporal"===r?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,i="temporal"===r?(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 r of e){const e=r[t];n.has(e)||n.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const o=n.get(e);o.edges.push(r),o.total+=r.value,o.earliestStart=Math.min(o.earliestStart,r.startTime),o.latestEnd=Math.max(o.latestEnd,r.endTime)}const s=[...n.values()];s.sort("temporal"===r?(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:o);return s};for(const t of e){const e=n.outgoing[t.id],r=n.incoming[t.id];if(0===r.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(r,"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(r,"source"),n=a(e,"target"),o=Math.max(t.length,n.length);for(let e=0;o>e;e++){const r=e%2==0?"top":"bot";if(t[e])for(const n of t[e].edges)s.get(n.id).targetSide=r;if(n[e])for(const t of n[e].edges)s.get(t.id).sourceSide=r}}}return s}(e,t,l,o);let u={};for(const t of e)u[t.id]=Th(t,l,c);const h=Bh(e,t,u,l,{plotH:r,padding:12,valueScale:1,packing:i,laneOrder:s,lifetimeMode:a}),d=new Set;for(const e of t){const t=h.slotByNode[e.source],n=h.slotByNode[e.target];if(void 0===t||void 0===n)continue;const r=c.get(e.id);t!==n?t>n?(r.sourceSide="top",r.targetSide="bot"):(r.sourceSide="bot",r.targetSide="top"):(d.add(e.id),r.sourceSide="bot",r.targetSide="bot")}for(const t of e){const e=l.outgoing[t.id],n=l.incoming[t.id],r=new Set(e.map(e=>c.get(e.id).sourceSide)),o=new Set(n.map(e=>c.get(e.id).targetSide));if(1===r.size&&n.length>0){const e=[...r][0];for(const t of n)h.slotByNode[t.source]===h.slotByNode[t.target]&&(c.get(t.id).targetSide=e)}if(1===o.size&&e.length>0){const t=[...o][0];for(const n of e)h.slotByNode[n.source]===h.slotByNode[n.target]&&(c.get(n.id).sourceSide=t)}}for(const t of e){const e=l.incoming[t.id],n=l.outgoing[t.id];if(0===e.length||0===n.length)continue;const r=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of e)"top"===c.get(n.id).targetSide?t.inTop+=n.value:t.inBot+=n.value;for(const e of n)"top"===c.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},o=(e,t)=>{const o=r(),i="top"===e?o.outTop-o.inTop:o.outBot-o.inBot,s="top"===t?o.inTop-o.outTop:o.inBot-o.outBot;if(0>=i||0>=s)return!1;const a=Math.min(i,s),l=n.filter(t=>!d.has(t.id)&&c.get(t.id).sourceSide===e&&a>=t.value).sort((e,t)=>t.value-e.value);return 0!==l.length&&(c.get(l[0].id).sourceSide=t,!0)};let i=n.length+1;for(;i-- >0&&(o("top","bot")||o("bot","top")););}u={};for(const t of e)u[t.id]=Th(t,l,c);const f=Bh(e,t,u,l,{plotH:r,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*r/Math.max(f.slots.length+1,1)),g=p>0?Math.max(0,(r-y*(f.slots.length+1))/p):1,m=Bh(e,t,u,l,{plotH:r,padding:y,valueScale:g,packing:i,laneOrder:s,lifetimeMode:a});return{nodeData:u,sides:c,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,...c}),{centerlines:f,nodeData:p,valueScale:y}=d,g=[],m=[];t.forEach((e,t)=>{const o=p[e.id];if(!o||0===o.samples.length)return;const i=function(e,t,n,r,o){if(0===e.length)return null;const i=Lh(e,o),s=e=>t-i[e].topMass*n,a=e=>t+i[e].botMass*n;let l=`M${r(i[0].t)},${s(0)}`;for(let e=1;i.length>e;e++)l+=` L${r(i[e].t)},${s(e)}`;l+=` L${r(i[i.length-1].t)},${a(i.length-1)}`;for(let e=i.length-2;e>=0;e--)l+=` L${r(i[e].t)},${a(e)}`;return l+" Z"}(o.samples,f[e.id],y,h,r);if(!i)return;const s=Lh(o.samples,r),a=s.find(e=>e.topMass+e.botMass>0)||s[0],c=f[e.id]+(a.botMass-a.topMass)*y/2,u=l(e.id,t),m=function(e,t,n,r,o){const i=n.nodeData[e];if(!i||0===i.samples.length)return[];const s=n.valueScale,a=n.centerlines[e],l=Lh(i.samples,o),c=l.find(e=>e.topMass+e.botMass>0)||l[0],u=[...l].reverse().find(e=>e.topMass+e.botMass>0)||l[l.length-1],h=r(c.t),d=r(u.t),f=e=>r(Rh(e,o)),p=[],y=(e,t,n,r)=>`M${e},${t} L${n},${t} L${n},${r} L${e},${r} 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),r=f(n.startTime),o=t-20,i=Math.max(h,o);if(r>i){const[n,l]=$h(e,a,s);p.push({pathD:y(i,n,r,l),x0:o,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),r=f(n.endTime),o=t+20,i=Math.min(d,o);if(i>r){const[n,l]=$h(e,a,s);p.push({pathD:y(r,n,i,l),x0:t,x1:o,from:1,to:0})}}}}return p}(e.id,n,d,h,r);g.push({id:e.id,pathD:i,fill:u,stroke:u,strokeWidth:.5,...m.length>0&&{gradientStubs:m},rawDatum:e.__raw??e,labelX:h(a.t)-4,labelY:c,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 o=x.get(e.source)??0,i=l(e.source,o),c=function(e,t,n,r,o,i,s,a){const l=o,c=e=>a?Math.max(a[0],Math.min(a[1],e)):e,u=i(c(e.time)),h=i(c(n.time)),d=e.value*l,f=n.value*l,p=e.sideMassBefore*l,y=n.sideMassAfter*l;let g,m,x,b;"top"===e.side?(g=t-p,m=g+d):(m=t+p,g=m-d),"top"===n.side?(x=r-y,b=x+f):(b=r+y,x=b-f);const v="source"===s?u+.85*(h-u):"target"===s?u+.15*(h-u):(u+h)/2;return{sx:u,sTop:g,sBot:m,tx:h,tTop:x,tBot:b,cp1X:v,cp2X:v}}(t,f[e.source],n,f[e.target],y,h,s,r),{pathD:u,bezier:d}=Fh(c);m.push({id:e.id,pathD:u,fill:i,opacity:a,rawDatum:e.__raw??e,bezier:d})}),{layout:d,layoutConfig:{bands:g,ribbons:m,showLabels:!0},issues:[],xScale:h}}x();var Wh=e=>{const{bands:t=[],ribbons:n=[],showLabels:r=!0}=e.config,o=[];for(const e of n)o.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];o.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)o.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=r?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:o,labels:i}};function Yh(e,t){if(!e)return[];const n=[],r=e=>{n.push(e);const o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(r)};return r(e),n}function qh(e,t,n,r){if(e&&e.length>0)return e;const o=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],i="function"==typeof r?r(e):e[r];o.add(t),o.add(i)}),Array.from(o).map(e=>({id:e}))}var Gh=c(require("react")),Xh={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,n,r,o)=>{const{edgeWidth:i,edgeColor:s,edgeOpacity:a}=o,l=o.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],r="number"==typeof e?e:Number(e);n=Number.isFinite(r)&&r>0?r:1}return{stroke:s??"#999",strokeWidth:n,opacity:a??.6}}:void 0),c=Cu(r.theme).colors.categorical,u=new Map,h=o.nodeStyle??(e=>({fill:t?Re(e?.data||e,t,void 0):Zc(void 0,c,n,void 0,u),..."number"==typeof o.nodeSize&&{r:o.nodeSize}})),d=Ye(o.styleRules,t,"number"==typeof o.nodeSize?void 0:o.nodeSize);return{chartType:"force",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,colorBy:t,colorScheme:n,iterations:o.iterations,forceStrength:o.forceStrength,showLabels:o.showLabels??!1,nodeLabel:o.nodeLabel,nodeSize:o.nodeSize??8,nodeSizeRange:o.nodeSizeRange,nodeStyle:d?(e,t)=>({...h(e),...d(e,t)}):h,edgeStyle:l,...r}}},Hh={frameType:"network",layout:{margin:{top:30,right:80,bottom:40,left:80}},buildProps:(e,t,n,r,o)=>{const i=e=>null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime(),s=o.sourceAccessor||"source",a=o.targetAccessor||"target",l=o.valueAccessor||"value",c=o.nodeIdAccessor||"id",u=o.startTimeAccessor||"startTime",h=o.endTimeAccessor||"endTime",d=o.systemInTimeAccessor,f=o.systemOutTimeAccessor,p=o.xExtentAccessor||"xExtent",y=o.edgeIdAccessor||"id",g=(e,t)=>"function"==typeof e?e(t):t[e],m=Array.isArray(o.edges)?o.edges:[],x=Array.isArray(o.nodes)?o.nodes:[],b=x.length>0?x:qh([],m,s,a),v=[i(o.domain?.[0]),i(o.domain?.[1])],w=b.map(e=>{const t=g(c,e)+"",n=g(p,e),r={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)&&(r.xExtent=[e,t])}return r}),k=m.map((e,t)=>{const n=g(y,e),r={id:null!=n?n+"":`${g(s,e)}-${g(a,e)}-${t}`,source:g(s,e)+"",target:g(a,e)+"",value:Number(g(l,e)),startTime:i(g(u,e)),endTime:i(g(h,e)),__raw:e};if(d){const t=i(g(d,e));Number.isFinite(t)&&(r.systemInTime=t)}if(f){const t=i(g(f,e));Number.isFinite(t)&&(r.systemOutTime=t)}return r}),[S,A]=r.size??[600,400],M={top:20,right:20,bottom:20,left:20,...r.margin},_=(r.showLegend??!!t)&&!!t,P=r.legendPosition??"right",C=r.__explicitMargin,j=e=>"number"==typeof C||null!=C&&"object"==typeof C&&null!=C[e];_&&("right"!==P||j("right")?"bottom"!==P||j("bottom")||(M.bottom=Math.max(M.bottom,80)):M.right=Math.max(M.right,140));const T=M,R=S-T.left-T.right,L=A-T.top-T.bottom,$=Pe(n,Cu(r.theme).colors.categorical,ne),z="function"==typeof t?t:null,D=z?b.map(e=>({_cat:z(e)})):b,O=z?"_cat":"string"==typeof t?t:void 0,I=n??[...$],E=O?$e(D,O,I):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 z?Re({_cat:z(n)},"_cat",E??void 0):Re(n,"string"==typeof t?t:"id",E??void 0)}return $[n%$.length]},N=Wo(_&&t?(()=>{const e=new Map;b.forEach((n,r)=>{const o=g(t,n),i=null==o?"":o+"";i&&!e.has(i)&&e.set(i,{label:i,color:F(g(c,n)+"",r)})});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,r.legend),{layout:W,layoutConfig:Y,issues:q,xScale:G}=Nh({nodes:w,edges:k,domain:v,plotW:R,plotH:L,ribbonLane:o.ribbonLane||"both",edgeOpacity:"number"==typeof o.edgeOpacity?o.edgeOpacity:.35,colorOf:F,layoutOpts:{pairing:o.pairing||"temporal",packing:o.packing||"reuse",laneOrder:o.laneOrder||"crossing-min",lifetimeMode:o.lifetimeMode||"half"}});if(q.length>0){const e=q.map(jh).join("; ");throw Error("ProcessSankey: data invalid — "+e)}const X=Array.isArray(o.axisTicks)?o.axisTicks:[],H=W?(()=>{let e=null,t=null;for(const n of w){const r=W.laneLifetime[n.id];if(!r||null==r.start||null==r.end)continue;const o=Number(G(r.start)),i=Number(G(r.end));e=null==e?o:Math.min(e,o),t=null==t?i:Math.max(t,i)}const n=e=>Math.max(0,Math.min(R,e)),r=n(e??0),s=Math.max(r,n(t??R)),a=X.map((e,t)=>({tick:e,index:t,x:Number(G(i(e.date)))})).filter(({x:e})=>e>=r-.5&&s+.5>=e);return Gh.createElement("g",null,...a.map(({index:e,x:t})=>Gh.createElement("line",{key:"grid-"+e,x1:t,y1:0,x2:t,y2:L,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"})),Gh.createElement("line",{key:"axis",x1:r,y1:L+4,x2:s,y2:L+4,stroke:"#94a3b8"}),...a.map(({tick:e,index:t,x:n})=>{const r=i(e.date),s=null!=e.label?e.label:"function"==typeof o.timeFormat?o.timeFormat(new Date(r)):"";return Gh.createElement("g",{key:"tick-"+t,transform:`translate(${n},${L+4})`},Gh.createElement("line",{y2:6,stroke:"#94a3b8"}),Gh.createElement("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569"},s))}))})():void 0;return{chartType:"force",nodes:b,edges:m,customNetworkLayout:Wh,layoutConfig:Y,sourceAccessor:s,targetAccessor:a,valueAccessor:l,nodeIDAccessor:c,colorBy:t,colorScheme:n,...H&&{backgroundGraphics:H},...r,showLegend:_,...N&&{legend:N,legendPosition:P},__legendIncludesAutomatic:!0,margin:T}}},Vh={frameType:"network",layout:{primarySize:{width:800,height:600}},buildProps:(e,t,n,r,o)=>{const i=Array.isArray(o.nodes)?o.nodes:qh([],Array.isArray(o.edges)?o.edges:[],o.sourceAccessor||"source",o.targetAccessor||"target"),s=Cu(r.theme).colors.categorical,a=new Map,l="string"==typeof t?t:"__ssrSankeyColorBy",c="function"==typeof t?i.map(e=>({...e,__ssrSankeyColorBy:t(e)})):i,u=t?$e(c,l,n??r.colorScheme??s):void 0,h=e=>({fill:t?Re(e?.data||e,t,u):Zc(void 0,s,n,void 0,a),stroke:r.stroke??"black",strokeWidth:r.strokeWidth??1,...void 0!==r.opacity&&{opacity:r.opacity}}),d=Ye(o.styleRules,t,o.valueAccessor),f=d?(e,t)=>({...h(e),...d(e,t)}):h,p=function({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:r,edgeOpacity:o,baseStyle:i={}}){return s=>{const a={fillOpacity:o,...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=Re(e.data||e,t,n):e&&(a.fill=r(e,e.index).fill)}else if("target"===e){const e="object"==typeof s.target?s.target:null;t&&e?a.fill=Re(e.data||e,t,n):e&&(a.fill=r(e,e.index).fill)}else"gradient"===e&&(a.fill="#999",a.fillOpacity=.7*o);return a}}({edgeColorBy:o.edgeColorBy??"source",colorBy:t,colorScale:u,nodeStyleFn:f,edgeOpacity:o.edgeOpacity??.5,baseStyle:{stroke:"none",strokeWidth:0}});return{chartType:"sankey",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,valueAccessor:o.valueAccessor,orientation:o.orientation,nodeAlign:o.nodeAlign,nodeWidth:o.nodeWidth,nodePaddingRatio:o.nodePaddingRatio,showLabels:o.showLabels,nodeLabel:o.nodeLabel,colorBy:t,edgeColorBy:o.edgeColorBy,edgeOpacity:o.edgeOpacity,nodeStyle:r.nodeStyle||o.nodeStyle||f,edgeStyle:r.edgeStyle||o.edgeStyle||p,colorScheme:n,...r}}},Uh={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,n,r,o)=>{if(!(t||Array.isArray(o.styleRules)&&o.styleRules.length>0||r.nodeStyle||o.nodeStyle))return{chartType:"chord",nodes:o.nodes,edges:o.edges,valueAccessor:o.valueAccessor,padAngle:o.padAngle,groupWidth:o.groupWidth,showLabels:o.showLabels,colorBy:t,edgeColorBy:o.edgeColorBy,colorScheme:n,...r};const i=Array.isArray(o.edges)?o.edges:[],s=Array.isArray(o.nodes)&&o.nodes.length>0?o.nodes:qh([],i,o.sourceAccessor||"source",o.targetAccessor||"target"),a=Cu(r.theme).colors.categorical,l=Pe(n,a),c="string"==typeof t?t:"__ssrChordColorBy",u="function"==typeof t?s.map(e=>({...e,__ssrChordColorBy:t(e)})):s,h=t?$e(u,c,n??r.colorScheme??a):void 0,d=new Map,f=o.nodeIdAccessor||o.nodeIDAccessor||"id",p=(e,n)=>{const o=e?.data||e;let i;if(t)i=Re(o,t,h);else{const t=(e.id??o?.[f]??"")+"";d.has(t)||d.set(t,d.size);const r=e.index??n??d.get(t);i=l[r%l.length]}return{fill:i,stroke:r.stroke??"black",strokeWidth:r.strokeWidth??1,...void 0!==r.opacity&&{opacity:r.opacity}}},y=Ye(o.styleRules,t,o.valueAccessor,p)??p;return{chartType:"chord",nodes:o.nodes,edges:o.edges,valueAccessor:o.valueAccessor,padAngle:o.padAngle,groupWidth:o.groupWidth,showLabels:o.showLabels,colorBy:t,edgeColorBy:o.edgeColorBy,colorScheme:n,nodeStyle:r.nodeStyle||o.nodeStyle||y,...r}}},Kh={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,n,r,o)=>{const i=Cu(r.theme).colors.categorical,s=new Map,a=Yh(e??null,o.childrenAccessor),l="function"==typeof t?t:null,c=l?a.map(e=>({__ssrTreeColorBy:l(e)})):a,u=l?"__ssrTreeColorBy":"string"==typeof t?t:void 0,h=t&&u?$e(c,u,n??r.colorScheme??i):void 0;return{chartType:"cluster"===o.layout?"cluster":"tree",data:e,childrenAccessor:o.childrenAccessor,colorBy:t,colorByDepth:o.colorByDepth,orientation:o.orientation,showLabels:o.showLabels,nodeLabel:!1!==o.showLabels?o.nodeLabel||o.nodeIdAccessor:void 0,colorScheme:n,...r,nodeStyle:r.nodeStyle||o.nodeStyle||(e=>{const a=e?.data||e;return{fill:o.colorByDepth?je[Number(e?.depth||0)%je.length]:t?l?Re({__ssrTreeColorBy:l(a)},"__ssrTreeColorBy",h??void 0):Re(a,t,h??void 0):Zc(void 0,i,n,void 0,s),stroke:r.stroke??"black",strokeWidth:r.strokeWidth??1,...void 0!==r.opacity&&{opacity:r.opacity}}})}}},Zh={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,n,r,o)=>{const i=Cu(r.theme).colors.categorical,s=new Map,a=Yh(e??null,o.childrenAccessor),l="function"==typeof t?t:null,c=l?a.map(e=>({__ssrTreemapColorBy:l(e)})):a,u=l?"__ssrTreemapColorBy":"string"==typeof t?t:void 0,h=t&&u?$e(c,u,n??r.colorScheme??i):void 0,d=o.showLabels??r.showLabels,f=o.labelMode,p=void 0!==o.paddingTop?o.paddingTop:!d||"parent"!==f&&"all"!==f?void 0:18;return{chartType:"treemap",data:e,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:t,colorByDepth:o.colorByDepth,showLabels:o.showLabels,labelMode:f,nodeLabel:d?o.nodeLabel||o.nodeIdAccessor:void 0,...null!=o.padding&&{padding:o.padding},...null!=p&&{paddingTop:p},colorScheme:n,...r,nodeStyle:r.nodeStyle||o.nodeStyle||(e=>{const r=e?.data||e;return{fill:o.colorByDepth?je[Number(e?.depth||0)%je.length]:t?l?Re({__ssrTreemapColorBy:l(r)},"__ssrTreemapColorBy",h??void 0):Re(r,t,h??void 0):Zc(void 0,i,n,void 0,s),stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8}})}}},Qh={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,n,r,o)=>{const i=Cu(r.theme).colors.categorical,s=new Map,a=Yh(e??null,o.childrenAccessor),l="function"==typeof t?t:null,c=l?a.map(e=>({__ssrCirclePackColorBy:l(e)})):a,u=l?"__ssrCirclePackColorBy":"string"==typeof t?t:void 0,h=t&&u?$e(c,u,n??r.colorScheme??i):void 0;return{chartType:"circlepack",data:e,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:t,colorByDepth:o.colorByDepth,showLabels:o.showLabels,nodeLabel:o.showLabels??r.showLabels?o.nodeLabel||o.nodeIdAccessor:void 0,...null!=o.padding&&{padding:o.padding},colorScheme:n,...r,nodeStyle:r.nodeStyle||o.nodeStyle||(e=>{const r=e?.data||e;return{fill:o.colorByDepth?je[Number(e?.depth||0)%je.length]:t?l?Re({__ssrCirclePackColorBy:l(r)},"__ssrCirclePackColorBy",h??void 0):Re(r,t,h??void 0):Zc(void 0,i,n,void 0,s),fillOpacity:o.circleOpacity??.7,stroke:"currentColor",strokeWidth:1,strokeOpacity:.3}})}}};x();var Jh={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5},ed=require("d3-scale");function td(e){return e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e}var nd={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,n,r,o)=>{const i="string"==typeof n?n:"blues",s=o.areaStyle??function(e,t,n,r){if(!Array.isArray(e))return;const o=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=o(t);null!=e&&isFinite(e)&&(i>e&&(i=e),e>s&&(s=e))}const a=(0,ed.scaleSequential)(ge(n)).domain([Number.isFinite(i)?i:0,Number.isFinite(s)?s:1]);return e=>{const t=o(e);return{fill:null!=t&&isFinite(t)?a(t):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:r}}}(o.areas,o.valueAccessor,i,o.areaOpacity??1),a=o.styleRules?We(s,o.styleRules,e=>{return{value:(t=e,"function"==typeof o.valueAccessor?o.valueAccessor(t):null!=o.valueAccessor?t?.properties?.[o.valueAccessor]??t?.[o.valueAccessor]:void 0)};var t},td):s;return{areas:o.areas,projection:o.projection||"equalEarth",areaStyle:a,valueAccessor:o.valueAccessor,colorScheme:i,graticule:o.graticule,fitPadding:o.fitPadding,...r}}},rd={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,n,r,o)=>{const i=e||o.points,s=o.pointStyle??function(e,t,n,r){const o=Array.isArray(e)?e:[];let i,s;if(t){const e="string"==typeof t?t:"__geoColorBy",r="string"==typeof t?o:o.map(e=>({...e,__geoColorBy:t(e)}));i=$e(r,e,n)}if(r.sizeBy){const e=o.map("function"==typeof r.sizeBy?r.sizeBy:e=>e?.[r.sizeBy]).filter(e=>null!=e&&isFinite(e));e.length>0&&(s=u(e))}return e=>({fill:t&&i?Re(e,t,i):_e,fillOpacity:r.fillOpacity,stroke:"#fff",strokeWidth:r.strokeWidth,r:r.sizeBy?ze(e,r.sizeBy,r.sizeRange,s):r.pointRadius??6})}(i,t,n,{sizeBy:o.sizeBy,sizeRange:o.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),a=o.styleRules?We(s,o.styleRules,Ee(t,o.sizeBy)):s;return{points:i,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",areas:o.areas,areaStyle:o.areaStyle||Jh,pointStyle:a,sizeBy:o.sizeBy,colorBy:t,colorScheme:n,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,...r}}},od={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,n,r,o)=>{const i=(Array.isArray(e)?e:null)||o.flows||[],s=o.nodeIdAccessor||"id",a=o.valueAccessor||"value",l=o.xAccessor||"lon",c=o.yAccessor||"lat",u="function"==typeof l?l:e=>e[l],h="function"==typeof c?c:e=>e[c],d=(o.nodes||[]).map(e=>({...e,x:u(e),y:h(e)})),f=new Map;for(const e of d)f.set(e[s]+"",e);const p=o.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?$e(g.map(e=>({[m]:p(e)})),m,n||"category10"):$e(g,p,n||"category10"):null,b=e=>p&&x?Re(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]=o.edgeWidthRange??[1,8],M=A-S,_=o.edgeOpacity??.6,P=o.edgeLinecap??"round";return{lines:g,points:d,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:o.lineType||"geo",flowStyle:o.flowStyle||"basic",areas:o.areas,areaStyle:o.areaStyle||Jh,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,colorScheme:n,lineStyle:e=>{const t=Number(e?.[a]),n=Number.isFinite(t)?t:v,r=S+Math.max(0,Math.min(1,k>0?(n-v)/k:0))*M;return{stroke:b(e),strokeWidth:r,strokeLinecap:P,opacity:_,fillOpacity:0}},pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...r}}};function id(e){const[t,n]=e,r=160>t||116>n,o=r?Math.min(12,Math.max(2,.08*t)):32,i=r?Math.min(8,Math.max(2,.12*n)):24,s=r?i:34;return{width:t,height:n,plot:{x:o,y:i,width:Math.max(1,t-2*o),height:Math.max(1,n-i-s)}}}function sd(e){const t=(e??"")+"";if(!t)return"#4e79a7";const n=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"];let r=0;for(let e=0;t.length>e;e+=1)r=31*r+t.charCodeAt(e)>>>0;return n[r%n.length]}function ad(e,t="#4e79a7",n){const r=n?.styleRules,o=!!r&&r.length>0,i=o?Oe(n?.valueAccessor):void 0;return n=>{const s=n.datum,a=s&&e?"function"==typeof e?e(s,0):s[e]:void 0,l={fill:null==a?t:sd(a),stroke:"#111827",strokeWidth:1,opacity:.9};return o&&s&&Object.assign(l,Ne(s,r,{value:i?i(s):void 0,category:null==a?void 0:a+""})),l}}function ld(e,t,n,r){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,...r}}}function cd(e,t,n){return"function"==typeof n?n(e,t):e[n]}function ud(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 hd(e,t,n){return Math.max(t,Math.min(n,e))}function dd(e,t){const n=ud(e);return null!=n&&n>0?n:t}function fd(e){return((e??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function pd(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 yd=require("d3-scale");function gd(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 md={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},xd=1e-9,bd=.005;function vd(e){return"circle"===e.type?{type:"circle",radius:e.radius}:{type:"aabb",width:e.width,height:e.height}}function wd(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 kd(e,t,n){return Math.max(t,Math.min(n,e))}function Sd(e){return 0>e?-1:1}function Ad(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 Md(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 _d(e,t){return!(e.minX>t.maxX||t.minX>e.maxX||e.minY>t.maxY||t.minY>e.maxY)}function Pd(e,t,n,r,o,i,s,a){const l=o-e,c=(n+s)/2-Math.abs(l);if(0>=c)return null;const u=i-t,h=(r+a)/2-Math.abs(u);return h>0?h>c?{nx:Sd(l),ny:0,penetration:c}:{nx:0,ny:Sd(u),penetration:h}:null}function Cd(e,t,n,r,o,i,s){const a=i/2,l=s/2;let c=e-kd(e,r-a,r+a),u=t-kd(t,o-l,o+l);const h=c*c+u*u;if(h>n*n)return null;if(xd>=h){const i=Math.abs(e-(r-a)),s=Math.abs(e-(r+a)),h=Math.abs(t-(o-l)),d=Math.abs(t-(o+l)),f=Math.min(i,s,h,d);return f===i?(c=-1,u=0,{nx:c,ny:u,penetration:n+i}):f===s?(c=1,u=0,{nx:c,ny:u,penetration:n+s}):f===h?(c=0,u=-1,{nx:c,ny:u,penetration:n+h}):(c=0,u=1,{nx:c,ny:u,penetration:n+d})}const d=Math.sqrt(h);return{nx:c/d,ny:u/d,penetration:n-d}}function jd(e,t){if("circle"===e.shape.type&&"circle"===t.shape.type)return function(e,t,n,r,o,i){const s=r-e,a=o-t,l=n+i,c=s*s+a*a;if(c>=l*l)return null;if(xd>=c)return{nx:1,ny:0,penetration:l};const u=Math.sqrt(c);return{nx:s/u,ny:a/u,penetration:l-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 Pd(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=Cd(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?Cd(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height):null}function Td(e,t){const n=t.shape;return"aabb"===n.type?"circle"===e.shape.type?Cd(e.x,e.y,e.shape.radius,n.x,n.y,n.width,n.height):Pd(n.x,n.y,n.width,n.height,e.x,e.y,e.shape.width,e.shape.height):function(e,t,n,r,o,i,s,a=0){const l=i-r,c=s-o,u=l*l+c*c,h=u>xd?kd(((e-r)*l+(t-o)*c)/u,0,1):0,d=n+a/2,f=e-(r+l*h),p=t-(o+c*h),y=f*f+p*p;if(y>=d*d)return null;if(xd>=y){const e=Math.sqrt(u);return e>xd?{nx:-c/e,ny:l/e,penetration:d}:{nx:1,ny:0,penetration:d}}const g=Math.sqrt(y);return{nx:f/g,ny:p/g,penetration:d-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 Rd(e,t){return`${e}\0${t}`}function Ld(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function $d(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:vd(e.shape),sleeping:e.sleeping,datum:e.datum,index:e.index,sleepTime:e.sleepTime,restitution:e.restitution,friction:e.friction}}function zd(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 Dd(e){return{id:e.id,shape:wd(e.shape),sensor:e.sensor,restitution:e.restitution,friction:e.friction,bodyFilter:zd(e.bodyFilter),index:e.index}}function Od(e,t){return!!t?.some(t=>Object.is(e,t))}function Id(e,t){const n=e.bodyFilter;if(!n)return!0;if("function"==typeof n)return n(t);const r=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(r,n.equals)||"notEquals"in n&&Object.is(r,n.notEquals)||n.oneOf&&!Od(r,n.oneOf)||n.notOneOf&&Od(r,n.notOneOf))}var Ed=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={...md,...e},this.random=gd(this.options.seed)}init(e={}){this.options={...md,...e},this.random=gd(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(xd,e.mass??1),bodyCollisions:e.bodyCollisions??!0,shape:vd(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))Ld(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:wd(t.shape),bodyFilter:zd(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 r=this.bodies.get(e);r&&(r.vx+=t/r.mass,r.vy+=n/r.mass,this.wake(r))}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 r=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,r>0){const t=Math.sqrt(e.vx*e.vx+e.vy*e.vy);if(t>r){const n=r/t;e.vx*=n,e.vy*=n}}e.x+=e.vx*t,e.y+=e.vy*t}this.supportedThisStep.clear();const o=this.bodyPairKeys(n),i=this.sortedColliders().filter(e=>!e.sensor);for(let e=0;this.options.collisionIterations>e;e+=1)this.resolveBodyPairs(n,o,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:vd(t.shape),sleeping:t.sleeping,datum:t.datum});return e}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(Ld)}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($d),colliders:this.sortedColliders().map(Dd),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=gd(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=$d(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=Dd(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 r="point"===t.target.type?t.target:this.bodies.get(t.target.bodyId);if(!r)continue;const o=r.x-n.x,i=r.y-n.y,s=Math.sqrt(o*o+i*i);if(xd>=s)continue;const a=o/s,l=i/s,c=(s-t.restLength)*t.stiffness+((("vx"in r?r.vx:0)-n.vx)*a+(("vy"in r?r.vy:0)-n.vy)*l)*t.damping;n.vx+=c*a*e/n.mass,n.vy+=c*l*e/n.mass}}resolveBodyPairs(e,t,n){for(const r of t){const[t,o]=r.split(":").map(Number),i=e[t],s=e[o];if(!i||!s)continue;const a=jd(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 r=0;e.length>r;r+=1){if(!1===e[r].bodyCollisions)continue;const o=Ad(e[r]),i=Math.floor(o.minX/t),s=Math.floor(o.maxX/t),a=Math.floor(o.minY/t),l=Math.floor(o.maxY/t);for(let e=i;s>=e;e+=1)for(let t=a;l>=t;t+=1){const o=`${e}:${t}`,i=n.get(o);i?i.push(r):n.set(o,[r])}}const r=new Set;for(const t of Array.from(n.keys()).sort()){const o=n.get(t)??[];o.sort((e,t)=>e-t);for(let t=0;o.length>t;t+=1)for(let n=t+1;o.length>n;n+=1){const i=o[t],s=o[n];!1!==e[i].bodyCollisions&&!1!==e[s].bodyCollisions&&_d(Ad(e[i]),Ad(e[s]))&&r.add(`${i}:${s}`)}}return Array.from(r).sort((e,t)=>{const[n,r]=e.split(":").map(Number),[o,i]=t.split(":").map(Number);return n===o?r-i:n-o})}resolveDynamicCollision(e,t,n){e.sleeping&&this.supportedThisStep.add(t.id),t.sleeping&&this.supportedThisStep.add(e.id);const r=e.sleeping?0:1/e.mass,o=t.sleeping?0:1/t.mass,i=r+o;if(xd>=i)return;const s=Math.max(0,n.penetration-bd)/i;e.x-=n.nx*s*r,e.y-=n.ny*s*r,t.x+=n.nx*s*o,t.y+=n.ny*s*o;const a=(t.vx-e.vx)*n.nx+(t.vy-e.vy)*n.ny;if(a>0)return;const l=Math.abs(a),c=-(1+Math.min(e.restitution??this.options.restitution,t.restitution??this.options.restitution))*a/i,u=c*n.nx,h=c*n.ny;e.vx-=u*r,e.vy-=h*r,t.vx+=u*o,t.vy+=h*o,this.applyFriction(e,t,n,c,r,o),l>this.options.contactWakeSpeed&&(this.wake(e),this.wake(t))}applyFriction(e,t,n,r,o,i){const s=-n.ny,a=n.nx,l=(t.vx-e.vx)*s+(t.vy-e.vy)*a,c=o+i;if(xd>=Math.abs(l)||xd>=c)return;const u=Math.max(0,Math.min(1,Math.max(e.friction??this.options.friction,t.friction??this.options.friction))),h=kd(-l/c,-r*u,r*u),d=h*s,f=h*a;e.vx-=d*o,e.vy-=f*o,t.vx+=d*i,t.vy+=f*i}resolveColliders(e,t,n){for(const r of e)for(const e of t){if(!Id(e,r))continue;if(!_d(Ad(r),Md(e)))continue;const t=Td(r,e);t&&(this.resolveStaticCollision(r,e,t),this.supportedThisStep.add(r.id),n&&this.lastEvents.push({type:"contact",bodyId:r.id,otherId:e.id,sensor:!1}))}}resolveStaticCollision(e,t,n){e.x+=n.nx*Math.max(0,n.penetration-bd),e.y+=n.ny*Math.max(0,n.penetration-bd);const r=e.vx*n.nx+e.vy*n.ny;if(0>r){const o=Math.min(e.restitution??this.options.restitution,t.restitution??this.options.restitution);e.vx-=(1+o)*r*n.nx,e.vy-=(1+o)*r*n.ny;const i=-n.ny,s=n.nx,a=e.vx*i+e.vy*s,l=Math.max(0,Math.min(1,Math.max(e.friction??this.options.friction,t.friction??this.options.friction)));e.vx-=a*i*l,e.vy-=a*s*l}}updateSensors(e){const t=new Set,n=this.sortedColliders().filter(e=>e.sensor);for(const r of e){const e=Ad(r);for(const o of n){if(!Id(o,r))continue;if(!_d(e,Md(o)))continue;if(!Td(r,o))continue;const n=Rd(o.id,r.id);t.add(n),this.activeSensors.has(n)||this.lastEvents.push({type:"sensor-enter",bodyId:r.id,sensorId:o.id})}}for(const e of Array.from(this.activeSensors).sort()){if(t.has(e))continue;const{sensorId:n,bodyId:r}=Ld(e);this.lastEvents.push({type:"sensor-exit",bodyId:r,sensorId:n})}this.activeSensors=t}updateSleeping(e,t){const n=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(const r of e)Math.sqrt(r.vx*r.vx+r.vy*r.vy)>=this.options.sleepSpeed||Math.sqrt((r.x-r.prevX)*(r.x-r.prevX)+(r.y-r.prevY)*(r.y-r.prevY))>=this.options.sleepSpeed*t||n&&!this.supportedThisStep.has(r.id)?r.sleeping?this.wake(r):r.sleepTime=0:(r.sleepTime+=t,r.sleeping||this.options.sleepAfter>r.sleepTime||(r.sleeping=!0,r.vx=0,r.vy=0,this.lastEvents.push({type:"sleep",bodyId:r.id})))}wake(e){e.sleeping&&this.lastEvents.push({type:"wake",bodyId:e.id}),e.sleeping=!1,e.sleepTime=0}nextRandom(){return this.random()}},Bd=class{constructor(e={}){this.id="builtin",this.capabilities={...(new Ed).capabilities,engine:"builtin"},this.world=new Ed(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 Fd(e,t={}){return e?"function"==typeof e?e(t):(e.init(t),e):function(e={}){return new Bd(e)}(t)}var Nd=["binId","targetBin","category","windowIndex","lane","group"];function Wd(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 Yd(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 qd(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 Gd(e,t){if(null!=e[t])return e[t];const n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function Xd(e,t,n){return"function"==typeof e?e(t,n):"string"==typeof e?Gd(t,e):void 0}function Hd(e){if(null==e)return;const t=e+"";return t.trim()?t:void 0}function Vd(e){const t=Yd(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:Yd(e.x),y:Yd(e.y),value:t}}var Ud=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=Hd(Xd(this.config.binAccessor,e,t))??function(e){for(const t of Nd){const n=Hd(Gd(e,t));if(n)return n}return"sediment"}(e),r=Hd(Xd(this.config.labelAccessor,e,t))??n,o=function(e,t,n){if("number"==typeof e)return e;const r="function"==typeof e?e(t,n):"string"==typeof e?Gd(t,e):1,o="number"==typeof r?r:Number(r);return Number.isFinite(o)?o: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:r,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=r,s.lastBodyId=e.id,s.lastDatum=e.datum,Wd(s.x,e.x),Wd(s.y,e.y),Wd(s.value,o),i>0&&(s.bodyIds.push(e.id),s.bodyIds.length>i&&(s.bodyIds=s.bodyIds.slice(s.bodyIds.length-i))),Vd(s)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(Vd)}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:qd(t.x),y:qd(t.y),value:qd(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 Kd(e){const t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}var Zd={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},Qd={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0};function Jd(e={},t=Qd){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 ef(e){return{...e,shape:{...e.shape},datum:e.datum,springs:e.springs?.map(e=>({...e,target:{...e.target}}))}}function tf(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 nf(e,t){if(null!=e[t])return e[t];const n=e.datum;return n&&"object"==typeof n?n[t]:void 0}function rf(e){return{...ef(e),sequence:e.sequence,spawnAt:e.spawnAt}}function of(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 lf(e){return{...e,gravity:{...e.gravity}}}function cf(e,t,n,r){if("circle"===e.shape.type){const o=e.x-t,i=e.y-n,s=e.shape.radius+r,a=o*o+i*i;return a>s*s?null:a}const o=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=o*o+i*i;return s>r*r?null:s}function uf(e){const t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function hf(e,t={}){const{idPrefix:n="plot",includeFloor:r=!0,includeCeiling:o=!1,includeLeftWall:i=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:l=a}=t,c=[],u=e.x+e.width/2,h=e.y+e.height/2;return r&&c.push({id:n+"-floor",shape:{type:"aabb",x:u,y:e.y+e.height+l/2,width:e.width+2*a,height:l}}),o&&c.push({id:n+"-ceiling",shape:{type:"aabb",x:u,y:e.y-l/2,width:e.width+2*a,height:l}}),i&&c.push({id:n+"-left-wall",shape:{type:"aabb",x:e.x-a/2,y:h,width:a,height:e.height+2*l}}),s&&c.push({id:n+"-right-wall",shape:{type:"aabb",x:e.x+e.width+a/2,y:h,width:a,height:e.height+2*l}}),c}function df(e){const{idPrefix:t="bin",count:n,domainStart:r,domainStep:o,xScale:i,yTop:s,yBottom:a,wallThickness:l=4,includeBoundaryWalls:c=!0,includeInteriorWalls:u=!0,closedBefore:h,lidY:d=s,lidThickness:f=Math.max(2,l)}=e,p=[],y=s+(a-s)/2,g=Math.abs(a-s),m=c?n:n-1;if(u||c)for(let e=c?0:1;m>=e;e+=1){if(!u&&e>0&&n>e)continue;const s=i(r+e*o);p.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:s,y:y,width:l,height:g}})}if(null!=h)for(let e=0;n>e;e+=1){const n=r+e*o,s=n+o;if(s>=h)continue;const a=i(n),c=i(s);p.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(a,c)+l/2,y1:d,x2:Math.max(a,c)-l/2,y2:d,thickness:f}})}return p}var ff=require("d3-quadtree"),pf=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(e,t,n,r,o,i=0){const s=this.ensure(e,t);if(!s)return null;let a=null,l=1/0;const c=Math.max(0,i)+this.maxSearchRadius,u=r-c,h=r+c,d=o-c,f=o+c;return s.visit((e,t,s,c,p)=>{if(u>c||t>h||d>p||s>f)return!0;if(e.length)return!1;let y=e;for(;y;){const e=y.data;if(e){const t=cf(e,r,o,Math.max(0,i));null!=t&&(l>t||t===l&&n.indexOf(e.id)>n.indexOf(a?.id??""))&&(a=e,l=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,ff.quadtree)().x(e=>e.x).y(e=>e.y).addAll(n),this.revision=t,this.tree)}},yf=["data","scene-geometry","data-paint","accessibility","evidence"],gf=["scene-geometry","data-paint","accessibility","evidence"],mf=["overlay","accessibility","evidence"],xf=(e,t)=>({retainedData:e,invalidations:t}),bf=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],vf=["scene-geometry","data-paint","accessibility","evidence"],wf=[],kf={engine:xf("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:xf("preserve",vf),colliders:xf("preserve",vf),sediment:xf("preserve",vf),bodyBudget:xf("preserve",bf),bodyLimit:xf("preserve",bf),eviction:xf("preserve",bf),fixedDt:xf("preserve",wf),maxDeltaSeconds:xf("preserve",wf),maxSubsteps:xf("preserve",wf),settleStepLimit:xf("preserve",wf),timeScale:xf("preserve",wf),observation:xf("preserve",wf)},Sf=xf("preserve",bf);function Af(e){let t="preserve";const n=new Set;for(const r of e){const e=kf[r]??Sf;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}var Mf=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"];function _f(e,t){return e===t||!(!e||!t)&&e.gravity?.x===t.gravity?.x&&e.gravity?.y===t.gravity?.y&&Mf.every(n=>e[n]===t[n])}function Pf(e,t,n,r){return e||!t?"paused":n||!r?"running":"settled"}var Cf=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 r=e.readState(this.scratch),o=this.speed*this.speed;let i=!0;for(const e of r)if(!e.sleeping&&e.vx*e.vx+e.vy*e.vy>=o){i=!1;break}this.seconds=i?this.seconds+Math.max(0,t):0}},jf=class{constructor(e={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new pf,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new Xn,this.simulationState="settled",this.visible=!0,this.quiescence=new Cf;const{bodyBudget:t,colliders:n,engine:r,kernel:o,observation:i,sediment:s,...a}=e;this.config={...Zd,...a},this.configInput={...e},this.bodyBudget=t??{},this.engineInput=r,this.observation=Jd(i),this.sediment=new Ud(s??!1),this.world=Fd(r,{fixedDt:this.config.fixedDt,...o}),this.quiescence.setKernelOptions(o),n&&this.world.setColliders(of(n))}updateConfig(e){const t=function(e,t){return Object.keys(e).filter(n=>"kernel"===n?!_f(e.kernel,t.kernel):e[n]!==t[n])}(e,this.configInput),{colliders:n,bodyBudget:r,engine:o,kernel:i,observation:s,sediment:a,...l}=e;if(this.config={...this.config,...l},void 0!==r&&(this.bodyBudget=r,!1===r&&(this.bodyBudgetObservationKey="ok")),o&&o!==this.engineInput){const e=this.world.snapshot();this.world.dispose(),this.engineInput=o,this.world=Fd(o,e.options),this.world.restore(e),this.revision+=1}if(i&&!_f(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=Jd(s,this.observation)),this.sediment.updateConfig(a),n&&(this.world.setColliders(of(n)),this.revision+=1),this.configInput={...this.configInput,...e};const c=Af(t);this.updateResults.record({kind:"config",keys:t},c.invalidations)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setColliders(e){this.world.setColliders(of(e)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},Af(["colliders"]).invalidations)}enqueue(e,t){const n=Array.isArray(e)?e:[e],r=t?function(e,t={}){const n=tf(t.startAt)??0,r=t.pacing??"immediate";if("arrival"===r){const r=e.map((e,n)=>function(e,t,n){return"function"==typeof n?tf(n(e,t)):"string"==typeof n?tf(nf(e,n)):tf(e.spawnAt)??tf(nf(e,"arrivalTime"))??tf(nf(e,"timestamp"))??tf(nf(e,"time"))??tf(nf(e,"eventTime"))}(e,n,t.timeAccessor)),o=r.filter(e=>null!=e),i=o.length>0?Math.min(...o):0,s=tf(t.timeScale)??1,a=s>0?s:1;return e.map((e,t)=>{const o=r[t],s=null==o?0:Math.max(0,o-i);return{...ef(e),spawnAt:n+s/a}})}if("object"==typeof r){const t=tf(r.ratePerSec);if(t&&t>0)return e.map((e,r)=>({...ef(e),spawnAt:n+r/t}))}return e.map(e=>({...ef(e),spawnAt:n}))}(n,{...t,startAt:t.startAt??this.elapsedSeconds}):n;for(const e of r)this.queue.push({...ef(e),sequence:this.nextSequence,spawnAt:e.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(af),r.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:r.length},r.length?yf:[])}enqueueWithResult(e,t){return this.enqueue(e,t),this.updateResults.last}spawnNow(e){this.spawnOne(ef(e)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},yf)}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?yf:[])),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"},yf)}tick(e){const t=this.revision,n=[],r=[],o=[],i=[],s=[];if(this.paused||!this.visible){const e=this.result(0,n,r,o,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 l=this.observeBodyBudget(s),c=this.evictOverflow(s);r.push(...c.evicted),o.push(...c.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||r.length>0||o.length>0||i.length>0)&&(this.revision+=1);const h=this.result(u,n,r,o,i,s,void 0,l);return this.updateResults.record({kind:"tick",count:u},this.revision!==t?n.length||r.length||o.length?yf:gf:[]),h}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?gf:[]),n}settleWithObservations(e=this.config.settleStepLimit){const t=this.revision,n=[],r=[],o=[],i=[],s=[];if(this.paused||!this.visible){const e=this.result(0,n,r,o,i,s,!1);return this.updateResults.record({kind:"settle",count:0},[]),e}this.spawnDue(n,s);const a=this.observeBodyBudget(s),l=this.evictOverflow(s);r.push(...l.evicted),o.push(...l.sedimented),this.syncSimulationState(s);let c=0;for(n.length>0&&this.quiescence.reset();e>c&&!this.atRest();){this.world.step(this.config.fixedDt);const e=this.world.events();i.push(...e),this.observeKernelEvents(e,s),this.observeSensorTransitions(s),c+=1,this.quiescence.refresh(this.world,this.config.fixedDt,0)}(c>0||n.length>0||r.length>0||o.length>0||i.length>0)&&(this.revision+=1);const u=this.result(c,n,r,o,i,s,void 0,a);return this.updateResults.record({kind:"settle",count:c},this.revision!==t?n.length||r.length||o.length?yf:gf:[]),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:r=24,gap:o=2,maxHeight:i=80,value:s="count",x:a}=t,l=Math.max(1,...e.map(e=>e[s]));return e.map((e,t)=>{const c=Math.max(0,e[s]/l*i),u=a?.(e,t)??t*(r+o);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:n-c,width:r,height:c,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:r,...o}=e,i={...o,timestamp:t??this.elapsedSeconds,chartType:n??this.observation.chartType,chartId:r??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?mf:[])}setVisible(e){const t=this.visible!==e;this.visible=e,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},t?mf:[])}remove(e){const t=new Set(e),n=new Set(this.liveBodyOrder),r=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 o=e.filter(e=>n.has(e)||r.has(e));return o.length>0&&(this.revision+=1,this.syncSimulationState()),this.updateResults.record({kind:"remove",keys:o,count:o.length},o.length?yf:[]),o}setConstraint(e){const t=this.world.setConstraint(e);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},gf),t}removeConstraint(e){this.world.removeConstraint(e),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},gf)}applyImpulse(e,t,n){this.world.applyImpulse(e,t,n),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[e]},gf)}nextRandom(){return this.world.nextRandom()}controls(){return e=this,{applyImpulse:(t,n,r)=>e.applyImpulse(t,n,r),clear:()=>e.clear(),hitTest:(t,n,r)=>e.hitTest(t,n,r),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:lf(e.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(rf),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:lf(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(rf).sort(af),this.revision=e.revision,this.sediment.restore(e.sediment??[]),this.simulationState=e.simulationState??Pf(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"},yf)}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,r,o,i,s,a=this.evaluateBodyBudget()){this.syncSimulationState(i);const l=this.world.allSleeping();return{budget:a,elapsedSeconds:this.elapsedSeconds,evicted:n,events:o,observations:i,queueSize:this.queue.length,revision:this.revision,shouldContinue:s??(this.queue.length>0||!this.atRest()),sleeping:l,sedimented:r,spawned:t,steps:e}}observeKernelEvents(e,t){!function(e,t,n){if(0===t.length)return;const r=new Map(e.readState().map(e=>[e.id,e]));for(const e of t){if("sleep"!==e.type)continue;const t=r.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 r=new Set(e.activeSensorPairs().map(e=>`${e.sensorId}\0${e.bodyId}`));if(0===r.size&&0===t.size)return r;const o=new Map(e.readState().map(e=>[e.id,e])),i=(e,t)=>{const{sensorId:r,bodyId:i}=uf(t),s=n.observation.sensors[r],a=o.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:r,binId:s?.binId??r})};for(const e of Array.from(r).sort())t.has(e)||i("enter",e);for(const e of Array.from(t).sort())r.has(e)||i("exit",e);return r}(this.world,this.activeSensorPairs,this.observationContext(e))}removeActiveSensorPairsForBodies(e){!function(e,t){for(const n of e)t.has(uf(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)),r=t+n,o=Kd(e.bodyLimit),i=Kd(e.engineMaxBodiesHint),s=function(e,t,n){if(!1===n)return;const r=Kd(n?.warnAt);return null!=r?r:null!=e?Math.max(1,Math.floor(.8*e)):null!=t?Math.max(1,Math.floor(.8*t)):void 0}(o,i,e.options),a=null==o?0:Math.max(0,t-o),l=a>0?"overflow":null==s||s>r?"ok":"warning";return{action:"overflow"!==l?"continue":e.sedimentEnabled?"sediment":e.evictionEnabled?"evict":"retain",bodyLimit:o,engineMaxBodiesHint:i,liveBodies:t,overflow:a,projectedBodies:r,queuedBodies:n,state:l,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=Pf(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:r}=function(e,t,n,r,o,i){const s={evicted:[],sedimented:[],liveBodyOrder:o};if(!1===n)return s;const a=Math.max(0,Math.floor(r));if(!Number.isFinite(a))return s;const l=o.length-a;if(0>=l)return s;const c=function(e,t,n){if("sleeping-first"!==t)return n.slice();const r=new Map(e.readState().map(e=>[e.id,e.sleeping])),o=[],i=[];for(const e of n)r.get(e)?o.push(e):i.push(e);return[...o,...i]}(e,n,o),u=c.slice(0,l);if(0===u.length)return s;const h=function(e,t,n,r){const o=new Map(e.readState().map(e=>[e.id,e])),i=[];for(const e of n){const n=o.get(e);if(!n)continue;const s=t.add(n);s&&(i.push(e),r.emit({type:"physics-sediment",timestamp:r.elapsedSeconds,chartType:r.observation.chartType,chartId:r.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 d=new Set(u);return{evicted:u,sedimented:h,liveBodyOrder:o.filter(e=>!d.has(e))}}(this.world,this.sediment,this.config.eviction,this.config.bodyLimit,this.liveBodyOrder,this.observationContext(e));return t.length>0&&(this.liveBodyOrder=r,this.removeActiveSensorPairsForBodies(new Set(t))),{evicted:t,sedimented:n}}};var Tf=require("d3-scale");function Rf(e){const{count:t,idPrefix:n,wallThickness:r,xScale:o,yBottom:i,yTop:s,yTopForIndex:a}=e;return Array.from({length:t+1},(e,t)=>{const l=Math.min(i-1,a?.(t)??s),c=Math.max(1,i-l);return{id:`${n}-wall-${t}`,shape:{type:"aabb",x:o(t),y:l+c/2,width:r,height:c}}})}var Lf=require("d3-scale");function $f(e){if(Array.isArray(e)&&e.length>=2){const t=ud(e[0]),n=ud(e[1]);return null!=t&&null!=n?{x:t,y:n}:null}if(e&&"object"==typeof e){const t=e,n=ud(t.x),r=ud(t.y);return null!=n&&null!=r?{x:n,y:r}:null}return null}function zf(e){return Array.isArray(e)?e.map($f).filter(e=>null!=e):[]}function Df(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:hd(e.x,t.plot.x,t.plot.x+t.plot.width),y:hd(e.y,t.plot.y,t.plot.y+t.plot.height)}}function Of(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 If(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};const n=hd(t,0,1)*Of(e);let r=0;for(let t=1;e.length>t;t+=1){const o=e[t-1],i=e[t],s=Math.hypot(i.x-o.x,i.y-o.y);if(s>0){if(r+s>=n){const e=(n-r)/s;return{x:o.x+(i.x-o.x)*e,y:o.y+(i.y-o.y)*e}}r+=s}}return{...e[e.length-1]}}function Ef(e,t){const n=If(e,Math.max(0,t-.02)),r=If(e,Math.min(1,t+.02)),o=r.x-n.x,i=r.y-n.y,s=Math.hypot(o,i)||1;return{x:o/s,y:i/s}}function Bf(e,t,n){return Math.max(t,Math.min(n,e))}function Ff(e,t,n,r,o,i={}){return{id:e,friction:i.friction,restitution:i.restitution,bodyFilter:i.bodyFilter,shape:{type:"segment",x1:t,y1:n,x2:r,y2:o,thickness:i.thickness??8}}}function Nf(e){return{id:e.id,label:e.label,description:e.description,kind:e.kind,shape:(t=e.x,n=e.y,r=e.width,o=e.height,{type:"aabb",x:t,y:n,width:r,height:o}),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,r,o}function Wf(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...Nf({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function Yf(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 qf(e){const t=e.stages;if(!t.length)throw Error("buildProcessFlowPhysics requires at least one stage");const n=e.size,r=id(n),o=hd(e.ballRadius??6,2,18),i=e.seed??1,s=pd(i),a=e.idAccessor,l=e.stageAccessor??"stage",c=e.groupBy,u=e.groupLabelAccessor,h=e.workAccessor,d=e.radiusAccessor,f=e.groupCompletion??(c?"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)),r=Math.max(1,Math.round(e.height)),o=e.padX??46,i=e.padY??72,s=o,a=n-o,l=i,c=r-Math.max(24,Math.round(.45*i)),u=(l+c)/2,h=Math.max(1,c-l),d=Bf(e.pinchRatio??.18,.06,.5),f=Number(e.pinchHeightOffset??0),p=Number.isFinite(f)?f:0,y=Bf(h*d+p,.06*h,.5*h),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=Bf(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 C=S.map((e,t)=>{const n=P,r=t===S.length-1?a:P+(e.share??1)/M*_;return P=r,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:n,x1:r,x:(n+r)/2,width:r-n,y:u,height:h}}),j=C[A],T=j.x0,R=j.x1,L=(e,n)=>{if("lane"===t)return"top"===n?l:c;if("funnel"===t){const t=Bf((e-s)/Math.max(1,a-s),0,1);return"top"===n?l+(m-l)*t:c+(x-c)*t}if(T>=e){const t=Bf((e-s)/Math.max(1,T-s),0,1);return"top"===n?l+(m-l)*t:c+(x-c)*t}if(R>=e)return"top"===n?m:x;const r=Bf((e-R)/Math.max(1,a-R),0,1);return"top"===n?m+(l-m)*r:x+(c-x)*r},$=C.map(e=>{const t=Math.min(L(e.x0,"top"),L(e.x1,"top")),n=Math.max(L(e.x0,"bottom"),L(e.x1,"bottom"));return{...e,y:(t+n)/2,height:Math.max(1,n-t)}}),z={thickness:k,friction:v,restitution:w},D=[];"lane"===t?D.push(Ff(b+"-top",s,l,a,l,z),Ff(b+"-bottom",s,c,a,c,z),Ff(b+"-left",s,l,s,c,{...z,thickness:Math.max(6,k-2)}),Ff(b+"-right",a,l,a,c,{...z,thickness:Math.max(6,k)})):"funnel"===t?D.push(Ff(b+"-top",s,l,a,m,z),Ff(b+"-bottom",s,c,a,x,z),Ff(b+"-left",s,l,s,c,{...z,thickness:Math.max(6,k-2)}),Ff(b+"-right",a,m,a,x,{...z,thickness:Math.max(6,k)})):D.push(Ff(b+"-left-top",s,l,T,m,z),Ff(b+"-left-bottom",s,c,T,x,z),Ff(b+"-center-top",T,m,R,m,z),Ff(b+"-center-bottom",T,x,R,x,z),Ff(b+"-right-top",R,m,a,l,z),Ff(b+"-right-bottom",R,x,a,c,z),Ff(b+"-left",s,l,s,c,{...z,thickness:Math.max(6,k-2)}),Ff(b+"-right",a,l,a,c,{...z,thickness:Math.max(6,k)}));const O=e.membraneDampingScale??.5,I=s,E=Math.max(1,("bowtie"===t?T:a)-I),B=(e.membranes??[]).map(e=>{const t=I+Bf(e.offset,0,1)*E,n=e.width??18+18*e.cost,r=h-16,o=u+.25*(e.wobble??0);return{...e,x:t,y:o,width:n,height:r}}),F=!1===e.includeMembraneRegions?[]:B.map(e=>function(e){const t=e.dampingScale??.5,n=e.energyScale??1,r=Bf(e.cost,0,2);return{...Nf({...e,kind:e.kind??"membrane",attributes:{primitive:"membrane",membraneCost:r,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:r*t,energyDelta:-r*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??O,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:n,height:r,padX:o,padY:i,left:s,right:a,topY:l,bottomY:c,midY:u,centerLeft:T,centerRight:R,pinchHeight:y,pinchTop:m,pinchBottom:x,stages:$,membranes:B,colliders:D,regionEffects:F,boundaryY:L}}({width:n[0],height:n[1],shape:"lane",padX:Math.max(28,r.plot.x),padY:Math.max(36,r.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{...Nf({...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:Yf(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 r={...n,kind:e.kind??"force-field",force:Yf(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...n.attributes,primitive:"portal",targetStage:e.portal.targetStageId}},{...Nf({...r,kind:r.kind??"force-field",attributes:{primitive:"portal",targetStage:r.targetStage,..."object"==typeof r.attributes&&r.attributes?r.attributes:{}}}),force:r.force,impulseOnEnter:r.impulseOnEnter,damping:r.damping??.08}}var r;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{...Nf({...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:Yf(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,r=e.dampingPerUnit??.12,o=e.energyPerUnit??0;return{...Nf({...e,kind:e.kind??"membrane",attributes:{primitive:"pressureField",pressure:t,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:n+t*r,energyDelta:o?-t*o: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:Yf(e.force,8),attributes:{...n.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?Wf({...n,kind:e.kind??"force-field",force:Yf(e.force,14),damping:e.damping??.02,attributes:{...n.attributes,primitive:"routeSurface"}}):function(e){return{...Nf({...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(Wf({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?cd(e,t,a)??e.id??"process-flow-"+t:e.id??"process-flow-"+t)+"",r=(cd(e,t,l)??w)+"",i=b.has(r)?r:w;M.set(i,(M.get(i)??0)+1);const s=c?(cd(e,t,c)??"")+"":void 0,f=s&&u?(cd(e,t,u)??s)+"":s,p=h?ud(cd(e,t,h))??1:1,y=d?ud(cd(e,t,d)):null,g=hd(null!=y&&y>0?y:o,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,C=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&&C.set(e.groupId,e.groupLabel)}const j=hd(e.groupAnchorAlong??.55,.15,.9),T=x.left+(x.right-x.left)*j,R=Array.from(P.keys()),L=R.map((e,n)=>{const r=P.get(e)??[],o=R.length>1?x.topY+28+n/Math.max(1,R.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:C.get(e)??e,bodyIds:r,anchor:{x:T,y:o},x:T,y:o,completion:"allAbsorbed"===f?{mode:"allMembersAbsorbed",targetZone:t.find(e=>e.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),$=function(e,t){const n=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],r=t.filter(e=>!n.has(e)),o=t.length-r.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},l=t.reduce((e,t)=>e+a(t),0),c=t.reduce((e,t)=>e+(n.has(t)?a(t):0),0),u=e.completion?.threshold,h="threshold"===i?Number.isFinite(u)&&Number(u)>=0?Number(u):l:void 0;return{id:e.id,label:e.label??e.id,mode:i,complete:t.length>0&&("anyAbsorbed"===i?o>0:"threshold"===i?c>=(h??l):0===r.length),absorbed:o,total:t.length,absorbedValue:c,totalValue:l,threshold:h,missing:r}})}(L,_.filter(e=>S.has(e.stageId)).map(e=>e.id)),z=new Map(L.map(e=>[e.id,e])),D=_.map((e,t)=>{const n=v.get(e.stageId)??k,r=n.x+(s()-.5)*Math.min(24,.2*n.width),o=x.boundaryY(r,"top")+e.radius+10,i=x.boundaryY(r,"bottom")-e.radius-10,a=i>o?o+s()*Math.max(1,i-o):x.midY,l=g?r:x.left+18+t%7*4,c=g?a:x.midY+(s()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:r,y:a},restLength:.45*e.radius,stiffness:p,damping:y}];if(e.groupId){const t=z.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:l,y:c,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}}}),O={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},I=x.stages.map(e=>({label:e.label??e.id,value:M.get(e.id)??0})),E=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:O,initialSpawns:D,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:I,metadata:{kind:"process-flow",plot:r.plot,volume:x,stages:E,groups:L,groupCompletion:$,regionEffects:A}}}var Gf=require("d3-scale");function Xf(e,t,n){return Pe(e,t,n)}function Hf(e,t){const n=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>n&&Le(n,e)||"#4e79a7":t=>{if(n){const e=Le(n,t);if(e)return e}let r=0;for(let e=0;t.length>e;e++)r=31*r+t.charCodeAt(e)|0;return e[Math.abs(r)%e.length]??"#4e79a7"}}function Vf(e,t){const n=t.config??{},r=(t.sensors??[]).map(e=>({...e,sensor:!0})),o=[...t.colliders??[],...r],i=[...e.colliders??[],...n.colliders??[],...o];return{...e,...n,observation:{...e.observation,...n.observation},...i.length>0&&{colliders:i}}}function Uf(e){const t=tp(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 Kf(e,t,n,r){return n?"function"==typeof n?n(e,t):e[n]??r:r}function Zf(e){return`gauntlet:${e}:core`}function Qf(e,t){return`gauntlet:${e}:positive:${t}`}function Jf(e,t,n){return`gauntlet:${e}:negative:${t}:${n}`}var ep={left:28,top:76,rightInset:30,thickness:8};function tp(e){const t=e.height??e.floorY+36;if(e.width>=220&&t>=160)return ep;const n=Math.max(1,Math.min(e.width,t)),r=Math.max(2,.04*e.width);return{left:r,top:Math.max(2,.08*t),rightInset:r,thickness:Math.max(1,Math.min(4,.04*n))}}function np(e){return Math.max(.12,Math.min(1,e.width/500,(e.height??e.floorY+36)/260))}function rp(e,t,n,r){const o=tp(r),i=Math.max(2,n+2),s=o.top+o.thickness/2+i,a=r.floorY-i,l=(e,t,n)=>t>n?(t+n)/2:Math.max(t,Math.min(n,e));return{x:l(e,o.left+o.thickness/2+i,r.width-o.rightInset-o.thickness/2-i),y:l(t,s,a)}}function op(e,t,n=1){const r=[...e].sort((e,t)=>e.localeCompare(t)),o=Math.max(0,r.indexOf(t));return{angle:.82*-Math.PI+(r.length>1?o/(r.length-1):.5)*Math.PI*.64,index:o,radius:(48+o%2*6)*n}}function ip(e,t,n){const r=e.activePositiveIds.reduce((e,n)=>e+(t.get(n)?.value??1),0),o=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*r-8*i-1.2*e.delay-5*o))}function sp(e){const t=function(e,t,n){const[r,o]=e,i=220>r||160>o,s=Math.round(.48*o),a=i?o-Math.max(3,Math.min(12,.1*o)):o-36,l=(t??[]).filter(e=>!1!==e.enabled),c=Math.max(1,l.length),u=.22*r,h=c>1?(.78*r-u)/(c-1):0,d=i?Math.max(Math.round(.12*r),.08*r+6):Math.max(Math.round(.14*r),110);return{crashY:a-(i?Math.min(n,Math.max(3,.22*o)):n),floorY:a,gates:l.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(u+t*h),width:e.width??Math.max(i?8:54,Math.round(.07*r))})),graveyardX:Math.round(r*(i?.72:.84)),graveyardY:a-4,height:o,routeY:s,socketX:Math.round(r*(i?.82:.92)),startX:d,width:r}}(e.size??[900,520],e.gates,e.crashOffset??30),n=e.positiveProperties??[],r=new Map(n.map(e=>[e.id,e])),o=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,r,o){const i=Kf(e,t,n.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",s=r.map(e=>e.id),a=[...Kf(e,t,n.positiveAccessor,s)],l=[...Kf(e,t,n.negativeAccessor,[])].filter(e=>o.has(e));return{id:i,activePositiveIds:a,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...Kf(e,t,n.metricsAccessor,{})},missingPositiveIds:s.filter(e=>!a.includes(e)),negativeIds:l,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(Kf(e,t,n.startTimeAccessor,0))||0),stage:"project filed",viability:Kf(e,t,n.initialViability,100)}}(t,s,i,n,o);return{...a,viability:e.viability?.(a,{negativeProperties:o,positiveProperties:r})??ip(a,r,o)}}),a=s.flatMap((n,i)=>{const s=function(e,t,n,r){const o=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=r?.(e,t,n)??{};return{...o,...i,startY:i.startY??i.routeY??o.startY,socketY:i.socketY??i.routeY??o.socketY,graveyardY:i.graveyardY??o.graveyardY}}(n,i,t,e.projectPlacement);return function(e,t,n,r,o,i,s){const a=np(n),l=Math.max(3,28*a),c=r.startX,u=r.startY+(r.startY===n.routeY?38*t*a:0),h=s?.(e,t,n,r)??{},d=h.x??c,f=h.y??u,p={__gauntlet:!0,kind:"gauntlet-core",projectId:e.id,sourceDatum:e.datum},y=[{...h,id:Zf(e.id),x:d,y:f,vx:h.vx??42,vy:h.vy??0,mass:h.mass??7,bodyCollisions:h.bodyCollisions??!0,shape:h.shape??{type:"circle",radius:l},spawnAt:h.spawnAt??e.startedAt,datum:p}],g=rp(d,f,h.shape&&"radius"in h.shape&&Number(h.shape.radius)||l,n);y[0].x=g.x,y[0].y=g.y;for(const t of e.activePositiveIds){const r=o.get(t);if(!r)continue;const i=op(e.activePositiveIds,t,a),s=r.radius??Math.max(2,10*a),l=rp(g.x+Math.cos(i.angle)*i.radius,g.y+Math.sin(i.angle)*i.radius,s,n);y.push({id:Qf(e.id,t),x:l.x,y:l.y,vx:18*Math.cos(i.angle),vy:18*Math.sin(i.angle),mass:r.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:s},spawnAt:h.spawnAt??e.startedAt,datum:{__gauntlet:!0,kind:"gauntlet-positive",projectId:e.id,property:r,sourceDatum:e.datum},springs:!1===r.spring?[]:[{target:{type:"body",bodyId:Zf(e.id)},stiffness:.56,damping:.9,restLength:Math.max(6,(52+i.index%2*4)*a),...r.spring??{}}]})}return e.negativeIds.forEach((t,r)=>{const o=i.get(t);o&&y.push(function(e,t,n,r,o,i,s){const a=np(i),l=t.radius??Math.max(2,7.2*a),c=rp(r+(n%4*12-12)*a,o+(54+12*Math.floor(n/4))*a,l,i);return{id:Jf(e.id,t.id,n),x:c.x,y:c.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:l},spawnAt:s,datum:{__gauntlet:!0,kind:"gauntlet-negative",projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:Zf(e.id)},stiffness:.62,damping:.92,restLength:Math.max(6,(52+n%4*3)*a),...t.spring??{}}]}}(e,o,r,g.x,g.y,n,h.spawnAt??e.startedAt))}),y}(n,i,t,s,r,o,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:Uf(t)}}}function ap(e){return e.map(e=>({...e,spawnAt:void 0}))}var lp={Sparkline:{frameType:"xy",layout:{mode:"sparkline"},buildProps:(e,t,n,r,o)=>({chartType:"line",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.lineBy||t,colorAccessor:t,...r,showAxes:!1,margin:r.margin,showLegend:!1,showGrid:!1,title:void 0})},LineChart:Fu,AreaChart:Wu,DifferenceChart:Yu,StackedAreaChart:qu,Scatterplot:Xu,CandlestickChart:Gu,BubbleChart:Eu,ConnectedScatterplot:Vu,QuadrantChart:Hu,Heatmap:{frameType:"xy",buildProps:(e,t,n,r,o)=>({chartType:"heatmap",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",valueAccessor:o.valueAccessor,colorScheme:n||o.colorScheme||"blues",showValues:o.showValues,heatmapValueFormat:o.valueFormat,cellBorderColor:o.cellBorderColor,...r})},TemporalHistogram:Nu,XYCustomChart:{frameType:"xy",buildProps:(e,t,n,r,o)=>({chartType:"custom",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,colorScheme:n,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r,showAxes:o.frameProps?.showAxes??o.showAxes??!1,showLegend:r.showLegend??!!t})},BarChart:fh,StackedBarChart:ph,GroupedBarChart:yh,PieChart:gh,DonutChart:mh,Histogram:xh,BoxPlot:bh,ViolinPlot:vh,SwarmPlot:wh,DotPlot:kh,SwimlaneChart:Sh,RidgelinePlot:Ah,LikertChart:Mh,FunnelChart:_h,GaugeChart:Ph,OrdinalCustomChart:{frameType:"ordinal",buildProps:(e,t,n,r,o)=>({chartType:"custom",data:e,oAccessor:o.categoryAccessor||o.oAccessor||"category",rAccessor:o.valueAccessor||o.rAccessor||"value",projection:o.projection||"vertical",colorAccessor:t,colorScheme:n,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r,showAxes:o.frameProps?.showAxes??o.showAxes??!1})},ForceDirectedGraph:Xh,NetworkCustomChart:{frameType:"network",layout:{margin:{top:40,right:40,bottom:40,left:40}},buildProps:(e,t,n,r,o)=>({chartType:"force",nodes:o.nodes||e||[],edges:o.edges||[],nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor||"id",sourceAccessor:o.sourceAccessor||"source",targetAccessor:o.targetAccessor||"target",valueAccessor:o.valueAccessor||"value",colorBy:t,colorScheme:n,customNetworkLayout:o.layout||o.customNetworkLayout,layoutConfig:o.layoutConfig,...r})},SankeyDiagram:Vh,ProcessSankey:Hh,ChordDiagram:Uh,TreeDiagram:Kh,Treemap:Zh,CirclePack:Qh,ChoroplethMap:nd,ProportionalSymbolMap:rd,FlowMap:od,GeoCustomChart:{frameType:"geo",buildProps:(e,t,n,r,o)=>({points:o.points||e||[],areas:o.areas||[],lines:o.lines||[],projection:o.projection||"equirectangular",xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",lineDataAccessor:o.lineDataAccessor,colorBy:t,colorScheme:n,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r})},GaltonBoardChart:{frameType:"physics",buildProps:(e,t,n,r,o)=>{const i=r.size??[600,400],s=o.bins??21,a=o.seed??1,l=Math.max(1,Math.round(o.pegRows??s-1)),c="mechanical"===o.mode,u=c?function(e){const t=Math.max(2,Math.round(e.bins)),n=Math.max(1,Math.round(e.pegRows??t-1)),r=Math.max(1,Math.round(e.count??Math.max(64,4*t))),o=hd(Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,0,1),i=pd(e.seed??1),s=e.idPrefix??"mechanical";return Array.from({length:r},(e,t)=>{let r=0;for(let e=0;n>e;e+=1)i()<o&&(r+=1);const a=n/2;return{id:`${s}-${t}`,value:r,mechanical:!0,pegRows:n,branchProbability:o,pathRights:r,side:a>r?"left":r>a?"right":"center"}})}({bins:s,branchProbability:o.branchProbability,count:o.mechanicalCount,pegRows:l,seed:a}):Array.isArray(e)?e:[],h=function(e){const{data:t,valueAccessor:n,bins:r,ballRadius:o,seed:i,size:s,valueExtent:a}=e,l=id(s),c=t.map((e,t)=>ud(cd(e,t,n))).filter(e=>null!=e),u=function(e){if(!e)return;const t=ud(e[0]),n=ud(e[1]);return null!=t&&null!=n?t>n?[n,t]:[t,n]:void 0}(a),h=u?.[0]??(c.length?Math.min(...c):0),d=u?.[1]??(c.length?Math.max(...c):1),f=d===h?1:d-h,p=(0,yd.scaleLinear)().domain([0,r]).range([l.plot.x,l.plot.x+l.plot.width]),y=Array.from({length:r},()=>0),g=[];t.forEach((e,t)=>{const i=ud(cd(e,t,n));if(null==i)return;const s=Math.max(0,Math.min(r-1,Math.floor((i-h)/f*r)));y[s]+=1,g.push({id:(e.id??"galton-"+t)+"",x:p(s+.5),y:l.plot.y+o+2,vx:8*(t%5-2),vy:0,mass:1,shape:{type:"circle",radius:o},datum:{...e,value:i,bin:s}})});const m=l.plot.y+l.plot.height;return{config:ld(i,[...hf({x:l.plot.x,y:l.plot.y,width:l.plot.width,height:l.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...df({idPrefix:"galton-bin",count:r,domainStart:0,domainStep:1,xScale:p,yTop:l.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:r,plot:l.plot,valueExtent:[h,d]}}}({data:u,valueAccessor:o.valueAccessor||"value",bins:s,ballRadius:o.ballRadius??4,seed:a,size:i,valueExtent:c?[0,l]:void 0});return{...r,config:h.config,initialSpawns:ap(h.initialSpawns),projectionRows:h.projectionRows,bodyStyle:ad(t||o.colorBy||(c?"side":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},EventDropChart:{frameType:"physics",buildProps:(e,t,n,r,o)=>{const i=r.size??[600,400],s=function(e){const{data:t,timeAccessor:n,arrivalAccessor:r,windows:o,watermark:i,ballRadius:s,seed:a,size:l,timeExtent:c,timeScale:u=1}=e,h=id(l),d=t.map((e,t)=>ud(cd(e,t,n))).filter(e=>null!=e),f=ud(c?.[0]),p=ud(c?.[1]),y=d.length?Math.min(...d):0,g=d.length?Math.max(...d):y+o.size,m=Math.min(f??y,y),x=Math.max(p??g,g),b=Math.floor(m/o.size)*o.size,v=Math.max(1,Math.ceil((x-b+o.size)/o.size)),w=d.length?Math.max(...d):0,k="function"==typeof i?i(w):ud(i?.value)??w-(i?.delay??o.size),S=Math.max(0,Math.min(v,Array.from({length:v},(e,t)=>t).reduce((e,t)=>b+(t+1)*o.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}}(h,s),M=b+v*o.size,_=(0,Tf.scaleLinear)().domain([b,M]).range([A.windowPlot.x,A.windowPlot.x+A.windowPlot.width]),P=Array.from({length:v},()=>({value:0,secondary:0})),C=[];t.forEach((e,t)=>{const i=ud(cd(e,t,n));if(null==i)return;const a=ud(cd(e,t,r))??i,l=Math.max(0,Math.min(v-1,Math.floor((i-b)/o.size))),c=k>=b+(l+1)*o.size;P[l].value+=c?0:1,P[l].secondary+=c?1:0,C.push({id:(e.id??"event-"+t)+"",x:Math.max(A.windowPlot.x+s,Math.min(A.windowPlot.x+A.windowPlot.width-s,_(i))),y:h.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:l,late:c}})});const j=h.plot.y+h.plot.height,T=function(e,t){const n=Math.max(0,Math.min(e.windowCount,e.closedWindowCount));if(!n)return[];const r=e.windowStart,o=e.windowStart+e.windowCount*e.windowSize,i=(0,Tf.scaleLinear)().domain([r,o]).range([e.windowPlot.x,e.windowPlot.x+e.windowPlot.width]),s=i(e.windowStart+n*e.windowSize),a=e.windowPlot.x,l=t+Math.max(18,Math.min(.3*e.windowPlot.height,s-a)),c=e=>s===a?t:l+(e-a)/(s-a)*(t-l),u=[];for(let t=0;n>t;t+=1){const n=e.windowStart+t*e.windowSize,r=n+e.windowSize,o=i(n),s=i(r);u.push({id:"eventdrop-lid-"+t,windowIndex:t,x1:o,y1:c(o),x2:s,y2:c(s)})}return u}({closedWindowCount:S,gutter:A.gutter,plot:h.plot,windowCount:v,windowPlot:A.windowPlot,windowSize:o.size,windowStart:b},h.plot.y+.28*h.plot.height);return{config:ld(a,[...hf({x:h.plot.x,y:h.plot.y,width:h.plot.width,height:h.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...Rf({idPrefix:"eventdrop-window",count:v,xScale:e=>_(b+e*o.size),yTop:A.wallTop,yTopForIndex:e=>{const t=(e=>{if(0>e||e>S)return null;const t=0===e?T[0]?.y1:T[e-1]?.y2??T[e]?.y1;return"number"==typeof t&&Number.isFinite(t)?t:null})(e);return null==t?A.wallTop:t+1.25*s},yBottom:j,wallThickness:6}),...T.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:C,initialSpawnPacing:{pacing:"arrival",timeAccessor:e=>e.datum?.arrivalTime,timeScale:u},projectionRows:P.map((e,t)=>({label:`${b+t*o.size}-${b+(t+1)*o.size}`,value:e.value,secondary:e.secondary})),metadata:{kind:"event-drop",closedWindowCount:S,gutter:A.gutter,lidSegments:T,lateCount:P.reduce((e,t)=>e+t.secondary,0),plot:h.plot,windowPlot:A.windowPlot,watermarkValue:k,windowCount:v,windowSize:o.size,windowStart:b}}}({data:Array.isArray(e)?e:[],timeAccessor:o.timeAccessor||"time",arrivalAccessor:o.arrivalAccessor||"arrivalTime",windows:o.windows||{size:10},watermark:o.watermark,ballRadius:o.ballRadius??5,seed:o.seed??1,size:i,timeExtent:o.timeExtent,timeScale:o.timeScale??1});return{...r,config:s.config,initialSpawns:ap(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:ad(t||o.colorBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||o.timeAccessor||"time"})}}},PhysicsPileChart:{frameType:"physics",buildProps:(e,t,n,r,o)=>{const i=r.size??[600,400],s="mechanical"===o.mode,a=function(e){const{data:t,categoryAccessor:n,valueAccessor:r,unitValue:o,ballRadius:i,seed:s,size:a}=e,l=dd(o,1),c=id(a),u=[],h=new Map,d=new Map,f=[];function p(e){let t=h.get(e);return null==t&&(t=u.length,u.push(e),h.set(e,t)),t}t.forEach((e,t)=>{p((cd(e,t,n)??"unknown")+"")});const y=Math.max(1,u.length),g=function(e,t,n){const r=e.width/Math.max(1,t),o=Math.max(2,2*n),i=Math.min(.7*r,Math.max(3.2*o,o+8)),s=Math.max(1,Math.floor(i/o));return{laneWidth:r,tubeWidth:i,ballDiameter:o,perRow:s,centerX:t=>e.x+(t+.5)*r,pileHeight:e=>Math.ceil(Math.max(0,e)/s)*o}}(c.plot,y,i),m=Math.max(0,g.tubeWidth/2-i-1),x=u.map(()=>[]);t.forEach((e,t)=>{const o=(cd(e,t,n)??"unknown")+"",s=p(o),a=r?ud(cd(e,t,r)):1,u=Math.max(0,Math.round((a??0)/l)),h=g.centerX(s);for(let n=0;u>n;n+=1){const r=d.get(o)??0,a=g.perRow>1?((g.perRow>1?r%g.perRow:0)/(g.perRow-1)*2-1)*m:0;d.set(o,r+1),x[s].push({id:`${(e.id??"pile-"+t)+""}-${n}`,x:h+a,y:c.plot.y+i+2,vx:(n%3-1)*i/2,vy:0,mass:1,shape:{type:"circle",radius:i},datum:{...e,category:o,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=c.plot.y+c.plot.height,w=[...hf({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],k=c.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:ld(s,w,"PhysicsPileChart"),initialSpawns:f,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:u.map(e=>({label:e,value:d.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"],r=Math.max(n.length,Math.round(e.count??Math.max(48,12*n.length))),o=dd(e.unitValue,1),i=pd(e.seed??1),s=e.idPrefix??"mechanical-pile",a=n.map(()=>.65+.9*i()),l=a.reduce((e,t)=>e+t,0)||1,c=r-n.length,u=a.map(e=>e/l*c),h=u.map(e=>1+Math.floor(e));let d=r-h.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;d>0;e=(e+1)%f.length)h[f[e].index]+=1,d-=1;return n.map((e,t)=>({id:`${s}-${t}`,category:e,value:h[t]*o,mechanical:!0,unitCount:h[t],unitValue:o,share:h[t]/r}))}({categories:o.mechanicalCategories,count:o.mechanicalCount,seed:o.seed??1,unitValue:o.unitValue??1}):Array.isArray(e)?e:[],categoryAccessor:o.categoryAccessor||"category",valueAccessor:o.valueAccessor||(s?"value":void 0),unitValue:o.unitValue??1,ballRadius:o.ballRadius??5,seed:o.seed??1,size:i});return{...r,config:a.config,initialSpawns:ap(a.initialSpawns),projectionRows:a.projectionRows,bodyStyle:ad(t||o.colorBy||(s?"category":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},CollisionSwarmChart:{frameType:"physics",buildProps:(e,t,n,r,o)=>{const i=r.size??[600,360],s=function(e){const{data:t,xAccessor:n,groupAccessor:r,radiusAccessor:o,pointRadius:i,seed:s,size:a,xExtent:l,collisionIterations:c,settle:u}=e,h=id(a),d=pd(s),f=[],p=[],y=new Map;t.forEach((e,t)=>{const s=ud(cd(e,t,n));if(null==s)return;const a=r?(cd(e,t,r)??"All")+"":"All",l=o?ud(cd(e,t,o)):null,c=hd(null!=l&&l>0?l: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:c})});const g=f.map(e=>e.value),m=l?ud(l[0]):null,x=l?ud(l[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=h.plot.x+S+8,M=h.plot.x+h.plot.width-S-8,_=(0,Lf.scaleLinear)().domain([w,k]).range([A,M]),P=Math.max(1,p.length),C=Math.min(Math.max(28,3*S),h.plot.height/4),j=h.plot.y+C,T=Math.max(0,h.plot.y+h.plot.height-C-j),R=e=>{const t=y.get(e)??0;return 1===P?h.plot.y+.54*h.plot.height:j+t/(P-1)*T},L=new Map,$=f.map((e,t)=>{L.set(e.group,(L.get(e.group)??0)+1);const n=_(e.value),r=R(e.group),o=(d()-.5)*e.radius*1.6,i=(d()-.5)*e.radius*1.6;return{id:(e.datum.id??"collision-swarm-"+t)+"",x:u?n+o:hd(n+(t%9-4)*e.radius*2.5,A,M),y:u?r+i:h.plot.y-18-t%12*e.radius,vx:u?0:22*(d()-.5),vy:u?0:24+18*d(),mass:1,shape:{type:"circle",radius:e.radius},datum:{...e.datum,xValue:e.value,group:e.group,radius:e.radius,targetX:n,targetY:r},springs:[{target:{type:"point",x:n,y:r},restLength:0,stiffness:34,damping:5.5}]}});return{config:ld(s,hf({x:h.plot.x,y:h.plot.y,width:h.plot.width,height:h.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(c??6)),velocityDamping:.992,restitution:.02,friction:.18,sleepSpeed:3,sleepAfter:.5}),initialSpawns:$,projectionRows:p.map(e=>({label:e,value:L.get(e)??0})),metadata:{kind:"collision-swarm",xExtent:[w,k],xRange:[A,M],groups:p.map(e=>({label:e,y:R(e),count:L.get(e)??0})),plot:h.plot}}}({data:Array.isArray(e)?e:[],xAccessor:o.xAccessor||"x",groupAccessor:o.groupAccessor,radiusAccessor:o.radiusAccessor,pointRadius:o.pointRadius??5,seed:o.seed??1,size:i,xExtent:o.xExtent,collisionIterations:o.collisionIterations,settle:o.settle});return{...r,config:s.config,initialSpawns:ap(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:ad(t||o.colorBy||o.groupAccessor,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.xAccessor||"x"})}}},ProcessFlowChart:{frameType:"physics",buildProps:(e,t,n,r,o)=>{const i=r.size??[900,420],s=Array.isArray(o.stages)?o.stages:[],a=qf({data:Array.isArray(e)?e:[],stages:s,size:i,idAccessor:o.idAccessor,stageAccessor:o.stageAccessor||"stage",groupBy:o.groupBy,groupLabelAccessor:o.groupLabelAccessor,workAccessor:o.workAccessor,radiusAccessor:o.radiusAccessor,ballRadius:o.ballRadius??6,seed:o.seed??1,groupCompletion:o.groupCompletion,groupAnchorAlong:o.groupAnchorAlong,settle:o.settle??!0,gravityX:o.gravityX,gravityY:o.gravityY}),l=a.metadata;return{...r,config:a.config,initialSpawns:ap(a.initialSpawns),projectionRows:a.projectionRows,regionEffects:l?.regionEffects,bodyStyle:ad(t||o.colorBy||o.groupBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.workAccessor||o.stageAccessor||"stage"})}}},GauntletChart:{frameType:"physics",buildProps:(e,t,n,r,o)=>{const i=r.size??[900,520],s=sp({data:Array.isArray(e)?e:[],size:i,gates:o.gates,positiveProperties:o.positiveProperties,negativeProperties:o.negativeProperties,crashOffset:o.crashOffset,idAccessor:o.idAccessor,positiveAccessor:o.positiveAccessor,negativeAccessor:o.negativeAccessor,metricsAccessor:o.metricsAccessor,initialViability:o.initialViability,projectPlacement:o.projectPlacement,coreBody:o.coreBody,viability:o.viability});return{...r,config:s.config,initialSpawns:ap(s.initialSpawns),projectionRows:[],bodyStyle:ad(t||o.colorBy)}}},PhysicalFlowChart:{frameType:"physics",buildProps:(e,t,n,r,o)=>{const i=r.size??[760,420],s=function(e){const{coordinateMode:t,flowSpeed:n,links:r,maxParticles:o,nodeIdAccessor:i,nodeXAccessor:s,nodeYAccessor:a,nodes:l,particleRadius:c,particleRate:u,pathAccessor:h,pathConstraint:d="path",reducedMotion:f,seed:p,size:y,sourceAccessor:g,targetAccessor:m,throughputAccessor:x}=e,b=id(y),v=pd(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")+""}l.forEach((e,t)=>{const n=(cd(e,t,i)??e.id??t)+"",r=ud(cd(e,t,s)),o=ud(cd(e,t,a));if(null!=r&&null!=o){const e={x:r,y:o};w.set(n,e),S.push(e)}k.set(n,(e.label??e.name??n)+"")});const M=[];r.forEach((e,t)=>{const n=A(cd(e,t,g)),r=A(cd(e,t,m)),o=Math.max(0,ud(cd(e,t,x))??0),i=zf(h?cd(e,t,h):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}-${r}-${t}`)+"",link:e,index:t,source:n,target:r,throughput:o,rawPath:s})});const _=(C=S,"normalized"===(P=t)||"pixels"===P?P:C.length>0&&C.every(e=>!(0>e.x||e.x>1||0>e.y||e.y>1))?"normalized":"pixels");var P,C;const j=new Map;for(const[e,t]of w)j.set(e,Df(t,b,_));const T=[];for(const e of M){let t=e.rawPath.map(e=>Df(e,b,_));if(2>t.length){const n=j.get(e.source),r=j.get(e.target);n&&r&&(t=[n,r])}else j.has(e.source)||j.set(e.source,t[0]),j.has(e.target)||j.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),T.push({...e,path:t,packetCount:0}))}const R=dd(u,.12),L=Math.max(1,Math.round(o)),$=T.map(e=>Math.max(1,Math.round(e.throughput*R))),z=$.reduce((e,t)=>e+t,0),D=z>L?L/z:1;T.forEach((e,t)=>{e.packetCount=Math.max(1,Math.floor($[t]*D))});let O=T.reduce((e,t)=>e+t.packetCount,0);for(;O>L;){const e=T.reduce((e,t,n)=>t.packetCount>1&&(-1===e||t.packetCount>T[e].packetCount)?n:e,-1);if(-1===e)break;T[e].packetCount-=1,O-=1}const I=new Map,E=new Map,B=[],F=dd(n,90),N=dd(c,4);T.forEach((e,t)=>{I.set(e.target,(I.get(e.target)??0)+e.throughput),E.set(e.source,(E.get(e.source)??0)+e.throughput);const n=Of(e.path);for(let r=0;e.packetCount>r;r+=1){const o=(r+.5)/e.packetCount,i=f?o:hd(.12+.84*o+.04*(v()-.5),.04,.98),s=f?i:Math.max(0,i-(.18+.12*v())),a=If(e.path,s),l=If(e.path,i),c=Ef(e.path,s),u={x:-c.y,y:c.x},h=(v()-.5)*N*1.5;B.push({id:`${e.id}-packet-${r}`,x:a.x+u.x*h,y:a.y+u.y*h,vx:f?0:c.x*F+10*(v()-.5),vy:f?0:c.y*F+10*(v()-.5),mass:.8,spawnAt:f?0:.04*t+r/32,shape:{type:"circle",radius:N},datum:{...e.link,source:e.source,target:e.target,throughput:e.throughput,packetIndex:r,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"!==d&&f?[{target:{type:"point",x:l.x,y:l.y},restLength:.7*N,stiffness:26,damping:4.25}]:void 0})}});const W=Math.max(18,5*N),Y=Array.from(j,([e,t])=>({nodeId:e,label:k.get(e)??e,sensorId:"physical-flow-node-"+fd(e),point:t})),q=Y.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(Y.map(e=>[e.sensorId,{binId:e.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),X=ld(p,[...hf({x:b.plot.x,y:b.plot.y,width:b.plot.width,height:b.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...q],"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});X.bodyLimit=L,X.eviction="oldest",X.observation={...X.observation,sensors:G};const H=Array.from(j,([e,t])=>({id:e,label:k.get(e)??e,x:t.x,y:t.y,sensorId:"physical-flow-node-"+fd(e),incoming:I.get(e)??0,outgoing:E.get(e)??0})),V=T.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:X,initialSpawns:B,projectionRows:H.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:T.reduce((e,t)=>e+t.throughput,0),plot:b.plot,nodes:H,links:V}}}({nodes:Array.isArray(o.nodes)?o.nodes:[],links:Array.isArray(o.links)?o.links:Array.isArray(o.edges)?o.edges:Array.isArray(e)?e:[],nodeIdAccessor:o.nodeIdAccessor||"id",nodeXAccessor:o.nodeXAccessor||"x",nodeYAccessor:o.nodeYAccessor||"y",sourceAccessor:o.sourceAccessor||"source",targetAccessor:o.targetAccessor||"target",throughputAccessor:o.throughputAccessor||"value",pathAccessor:o.pathAccessor||"path",coordinateMode:o.coordinateMode||"auto",particleRate:o.particleRate??.16,maxParticles:o.maxParticles??180,particleRadius:o.particleRadius??4,flowSpeed:o.flowSpeed??90,pathConstraint:o.pathConstraint||"path",reducedMotion:!0,seed:o.seed??1,size:i});return{...r,config:s.config,initialSpawns:ap(s.initialSpawns),projectionRows:s.projectionRows,bodyStyle:ad(t||o.colorBy||"source")}}},PhysicsCustomChart:{frameType:"physics",buildProps:(e,t,n,r,o)=>{const i=r.size??[700,380],s=function(e){const t=function(e,t,n){const r=e?.observation;return{...e,observation:{...r,chartId:t??r?.chartId??"physics-custom",chartType:r?.chartType??"PhysicsCustomChart",onObservation:n??r?.onObservation}}}(e.config,e.chartId,e.onObservation),n=Xf(e.colorScheme,e.themeCategorical,ne),r=id(e.size),o={data:e.data,scales:{x:(0,Gf.scaleLinear)().domain(e.xExtent??[0,1]).range([r.plot.x,r.plot.x+r.plot.width]),y:(0,Gf.scaleLinear)().domain(e.yExtent??[0,1]).range([r.plot.y+r.plot.height,r.plot.y])},dimensions:r,theme:{semantic:e.semantic,categorical:[...n]},resolveColor:Hf(n,e.colorScheme),config:e.layoutConfig??{},world:new jf(t)},i=e.skipLayout?{}:e.layout(o)??{},s=function(e,t){if(!t?.length)return e;const n=new Map;for(const e of t){const{bodyId:t,...r}=e,o=n.get(t)??[];o.push(r),n.set(t,o)}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:Vf(t,i),context:o,initialSpawnPacing:i.initialSpawnPacing,initialSpawns:s,result:i}}({chartId:o.chartId,colorScheme:n,config:o.config,data:Array.isArray(e)?e:[],layout:o.layout,layoutConfig:o.layoutConfig,semantic:wt(At)??{},size:i,themeCategorical:At.colors.categorical,xExtent:o.xExtent,yExtent:o.yExtent});return{...r,config:s.config,initialSpawns:ap(s.initialSpawns),projectionRows:[],bodyStyle:s.result.bodyStyle??ad(t||o.colorBy)}}}};function cp(e){const t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function up(e){if(!e||2>e.length)return;const t=cp(e[0]),n=cp(e[e.length-1]);return null!==t&&null!==n?[t,n]:void 0}function hp(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),r=0===t,o=[...e.extraWarnings??[]];return r&&!o.includes("EMPTY_SCENE")&&o.push("EMPTY_SCENE"),{component:"",frameType:e.frameType,status:r?"empty":"ok",empty:r,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:o}}var dp=c(require("react")),fp=c(require("react-dom/server")),pp=require("d3-scale"),yp=require("react/jsx-runtime"),gp=Ro;function mp(e,t,n){if(t&&"object"==typeof t&&!Array.isArray(t)){const e=t;return t=>Le(e,t)??"#999"}const r=Array.isArray(t)?t:n.colors.categorical.length>0?n.colors.categorical:ne;return(0,pp.scaleOrdinal)().domain(e).range(r)}function xp(e){return"left"===e?"start":"right"===e?"end":e??"start"}function bp(e){return Number(e.typography.legendSize??e.typography.labelSize??e.typography.tickSize)||11}function vp(e,t,n,r){const o=bp(r);return t+n+Math.ceil(e.length*o*.58)}function wp(e){const{categories:t,theme:n,position:r="right",totalWidth:o,margin:i,legendLayout:s}=e,{swatchSize:a,labelGap:l,itemGap:c,rowHeight:u}=Lo(s),h=a+l,d="top"===r||"bottom"===r,f=Math.max(a,o-i.left-i.right),p=t.map(e=>vp(e,a,l,n));if(d){const e=Math.max(a,s?.maxWidth??f),n=[];let r=0,o=0;p.forEach((t,i)=>{const s=0===o?t:o+c+t;o>0&&s>e?(n.push({start:r,end:i,width:o}),r=i,o=t):o=s}),t.length>0&&n.push({start:r,end:t.length,width:o});const i=xp(s?.align),l=[];return n.forEach((n,r)=>{let o="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++)l.push({category:t[e],width:p[e],x:o,y:r*u}),o+=p[e]+c}),{items:l,width:Math.max(0,...n.map(e=>e.width)),height:n.length*u,swatchSize:a,labelOffset:h,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:h,swatchRadius:0}}function kp(e){const{legendGroups:t,theme:n,position:r="right",totalWidth:o,margin:i,legendLayout:s}=e,{swatchSize:a,labelGap:l,rowHeight:c}=Lo(s),u=a+l,h=Math.max(12,bp(n)),d="top"===r||"bottom"===r,f=Math.max(a,o-i.left-i.right);if(d){const r=Math.max(a,s?.maxWidth??f),o=xp(s?.align);let i=0,l=0;const c=[];for(const o of t){const t=o.items.map(e=>e.label),u=wp({...e,categories:t,legendLayout:{...s,maxWidth:Math.max(a,r-h-8),align:"start"}}),d=o.label?h:0,f=o.label?vp(o.label,0,0,n):0,p=d>0?d+8:0,y=p+u.width,g=Math.max(u.height,f);c.push({group:o,x:i,y:0,itemOffsetX:p,itemOffsetY:0,width:y,height:g,items:u.items}),i+=y+12,l=Math.max(l,g)}const d=c.length>0?i-12:0,p=d>r?0:"center"===o?Math.max(0,(r-d)/2):"end"===o?Math.max(0,r-d):0;return{groups:c.map(e=>({...e,x:e.x+p})),width:d,height:l,swatchSize:a,labelOffset:u,swatchRadius:0}}const p=$o(t.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),c);let y=0;return{groups:t.map((e,t)=>{const r=e.items.map(e=>vp(e.label,a,l,n)),o=Math.max(0,...r,e.label?vp(e.label,0,0,n):0);return y=Math.max(y,o),{group:e,x:0,y:p[t].itemsY,itemOffsetX:0,itemOffsetY:0,width:o,height:e.items.length*c,items:e.items.map((e,t)=>({category:e.label,width:r[t],x:0,y:t*c}))}}),width:y,height:p.at(-1)?.endY??0,swatchSize:a,labelOffset:u,swatchRadius:0}}function Sp(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 Ap(e,t){if(!t||!e||0===e.length)return[];const n="function"==typeof t?t:e=>e[t],r=new Set;for(const t of e){const e=n(t);null!=e&&r.add(e+"")}return Array.from(r)}var Mp=require("react/jsx-runtime"),_p=16,Pp=20;function Cp(e,t){return e.color||t.colors.annotation||t.colors.text}function jp(e,t,n){const r=e.labelBackground,o=t.colors.background,i=o&&"transparent"!==o?o:t.colors.surface||o;return void 0===r?"none"===n?"none":{type:"halo",fill:i}:!1===r||"none"===r?"none":!0===r||"halo"===r?{type:"halo",fill:i}:"box"===r?{type:"box",fill:i}:{fill:i,...r}}function Tp(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 Rp(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 Lp(e){const{annotations:t}=e;if(!t||0===t.length)return null;const n=ys(t),r=e.autoPlaceAnnotations?ps({annotations:n,context:{scales:{x:e.scales.x,y:e.scales.y,time:e.scales.x,value:e.scales.y,o:e.scales.o,geoProjection:e.scales.geoProjection},width:e.layout.width,height:e.layout.height,xAccessor:e.xAccessor,yAccessor:e.yAccessor,frameType:e.projection?"ordinal":"xy",projection:"horizontal"===e.projection?"horizontal":"vertical"},..."object"==typeof e.autoPlaceAnnotations?e.autoPlaceAnnotations:{}}):n,o=[];for(let t=0;r.length>t;t++){const n=$p(r[t],t,e);n&&o.push({node:n,annotation:r[t]})}const i=Li(o);return i.length>0?(0,Mp.jsx)("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:i}):null}function $p(e,t,n){const{scales:r,layout:o,theme:i,xAccessor:s,yAccessor:a}=n;switch(e.type){case"y-threshold":{const s=e.value;if(null==s)return null;const a=Cp(e,i),l=e.label,c=e.labelPosition||"right",u=e.strokeDasharray||"6,4",h=e.strokeWidth??1.5;if("horizontal"===n.projection&&r.r){const n=r.r(s);return null==n?null:(0,Mp.jsxs)("g",{opacity:e.opacity,children:[(0,Mp.jsx)("line",{x1:n,y1:0,x2:n,y2:o.height,stroke:a,strokeWidth:h,strokeDasharray:u}),l&&(0,Mp.jsx)(Fi,{x:n+4,y:_p,textAnchor:"start",fontSize:i.typography.tickSize,fill:a,fontFamily:i.typography.fontFamily,text:l,background:jp(e,i,"halo")})]},"ann-ythresh-"+t)}const d=r.y?r.y(s):r.r?r.r(s):null;return null==d?null:(0,Mp.jsxs)("g",{children:[(0,Mp.jsx)("line",{x1:0,y1:d,x2:o.width,y2:d,stroke:a,strokeWidth:h,strokeDasharray:u}),l&&(0,Mp.jsx)(Fi,{x:"left"===c?4:"center"===c?o.width/2:o.width-4,y:Pp>d?Math.min(o.height-4,d+_p):d-6,textAnchor:"left"===c?"start":"center"===c?"middle":"end",fontSize:i.typography.tickSize,fill:a,fontFamily:i.typography.fontFamily,text:l,background:jp(e,i,"halo")})]},"ann-ythresh-"+t)}case"x-threshold":{const n=e.value;if(null==n||!r.x)return null;const s=r.x(n);if(null==s)return null;const a=Cp(e,i),l=e.label,c=e.labelPosition||"top";return(0,Mp.jsxs)("g",{opacity:e.opacity,children:[(0,Mp.jsx)("line",{x1:s,y1:0,x2:s,y2:o.height,stroke:a,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray||"6,4"}),l&&(0,Mp.jsx)(Fi,{x:s>.6*o.width?s-4:s+4,y:"bottom"===c?o.height-4:"center"===c?o.height/2:_p,textAnchor:s>.6*o.width?"end":"start",fontSize:i.typography.tickSize,fill:a,fontFamily:i.typography.fontFamily,text:l,background:jp(e,i,"halo")})]},"ann-xthresh-"+t)}case"band":{const n=r.y?.domain?.(),s=e.y0??n?.[0],a=e.y1??n?.[1],l=null!=s&&r.y?r.y(s):null,c=null!=a&&r.y?r.y(a):null;if(null==l||null==c)return null;const u=Math.min(l,c),h=Math.abs(c-l),d=Qr(e.fill||Cp(e,i),"ssr-band-"+t),f=e.fillOpacity??.1;return(0,Mp.jsxs)("g",{opacity:e.opacity,children:[d.def&&(0,Mp.jsx)("defs",{children:d.def}),(0,Mp.jsx)("rect",{x:0,y:u,width:o.width,height:h,fill:d.fill,fillOpacity:f}),e.label&&(0,Mp.jsx)(Fi,{x:o.width-4,y:Math.max(u,0)+_p,textAnchor:"end",fontSize:i.typography.tickSize,fill:e.color||Cp(e,i),fontFamily:i.typography.fontFamily,fontWeight:"bold",text:e.label,background:jp(e,i,"halo")})]},"ann-band-"+t)}case"x-band":{const n=r.x?.domain?.(),s=e.x0??n?.[0],a=e.x1??n?.[1],l=null!=s&&r.x?r.x(s):null,c=null!=a&&r.x?r.x(a):null;if(null==l||null==c)return null;const u=Math.min(l,c),h=Math.abs(c-l),d=Qr(e.fill||Cp(e,i),"ssr-xband-"+t),f=e.fillOpacity??.1;return(0,Mp.jsxs)("g",{opacity:e.opacity,children:[d.def&&(0,Mp.jsx)("defs",{children:d.def}),(0,Mp.jsx)("rect",{x:u,y:0,width:h,height:o.height,fill:d.fill,fillOpacity:f}),e.label&&(0,Mp.jsx)(Fi,{x:u+4,y:_p,textAnchor:"start",fontSize:i.typography.tickSize,fill:e.color||i.colors.primary||Cp(e,i),fontFamily:i.typography.fontFamily,fontWeight:"bold",text:e.label,background:jp(e,i,"halo")})]},"ann-xband-"+t)}case"category-highlight":{if(null==e.category||!r.o)return null;const s=r.o(e.category+"");if(null==s)return null;const a=r.o.bandwidth?r.o.bandwidth():40,l=Cp(e,i),c=e.opacity??.1,u=e.label;return(0,Mp.jsxs)("g","horizontal"===n.projection?{children:[(0,Mp.jsx)("rect",{x:0,y:s,width:o.width,height:a,fill:l,opacity:c}),u&&(0,Mp.jsx)(Fi,{x:12,y:s+a/2,dominantBaseline:"middle",fill:l,fontSize:i.typography.tickSize,fontWeight:"bold",fontFamily:i.typography.fontFamily,text:u,background:jp(e,i,"none")})]}:{children:[(0,Mp.jsx)("rect",{x:s,y:0,width:a,height:o.height,fill:l,opacity:c}),u&&(0,Mp.jsx)(Fi,{x:s+a/2,y:_p,textAnchor:"middle",fill:l,fontSize:i.typography.tickSize,fontWeight:"bold",fontFamily:i.typography.fontFamily,text:u,background:jp(e,i,"none")})]},"ann-cathighlight-"+t)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{const{x:n,y:o}=function(e,t,n,r){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:Tp(e,t,n),y:Rp(e,t,r)}}(e,r,s,a);if(null==n||null==o)return null;const l="text"===e.type,c=e.dx??(l?0:30),u=e.dy??(l?0:-30),h=e.color||i.colors.text;if(!l){const r="callout"===e.type?"callout-circle":e.type,i="callout-circle"===r?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===r?{width:e.width,height:e.height}:void 0;return(0,Mp.jsx)(si,{noteData:{x:n,y:o,dx:c,dy:u,note:{label:e.label,title:e.title,wrap:e.wrap||120},type:r,...i?{subject:i}:{},connector:e.connector||{end:"arrow"},color:h,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-label-"+t)}return(0,Mp.jsx)("g",{children:(0,Mp.jsx)("text",{x:n+c,y:o+u,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||i.typography.labelSize,fill:h,fontFamily:i.typography.fontFamily,fontWeight:e.fontWeight,opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:e.label||e.title})},"ann-label-"+t)}default:return null}}var zp=c(require("react")),Dp=require("react/jsx-runtime");function Op(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){const t=e.id;return null==t?null:t+""}return null}function Ip(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 r=0;for(let e=0;n.length>e;e++)r=31*r+n.charCodeAt(e)|0;return"c"+(r>>>0).toString(36)}function Ep(e,t,n){const r=e.showLegend&&!e.__legendIncludesAutomatic?function(e,t,n){if(0===e.length)return;const r=mp(e,t,n);return{legendGroups:[{label:"",type:"fill",items:e.map(e=>({label:e})),styleFn:e=>({fill:r(e.label)})}]}}(t,e.colorScheme,n):void 0;return Wo(r,e.legend)}var Bp={right:110,left:110,top:50,bottom:80};function Fp(e,t){if(e.__autoLegendMargin&&!Np(e,t))return Bp[t]}function Np(e,t){const n=e.__explicitMargin;return"number"==typeof n||!(!n||"object"!=typeof n||"number"!=typeof n[t])}function Wp(e,t){const{props:n,categories:r,theme:o,size:i,hasTitle:s}=t,a=n.legendPosition||"right",l={theme:o,position:a,size:i,hasTitle:s,legendLayout:n.legendLayout,minimumMargin:Fp(n,a),preserveExplicitMargin:Np(n,a)};if(null!=n.legend){const t=Ep(n,r,o);(Yo(t)||qo(t))&&function(e,t){if(t.preserveExplicitMargin)return;const n=t.position||"right",r={theme:t.theme,position:n,totalWidth:t.size[0],totalHeight:t.size[1],margin:e,hasTitle:t.hasTitle,legendLayout:t.legendLayout},o=Yo(t.legend)?function(e){const{width:t,height:n,swatchSize:r}=kp(e);return{width:t,height:n,swatchSize:r}}({...r,legendGroups:t.legend.legendGroups}):qo(t.legend)?Sp({...r,gradient:t.legend.gradient}):null;if(!o)return;const i=t.minimumMargin??o.width+14,s=t.minimumMargin??(t.hasTitle?32:8)+o.height+4,a=t.minimumMargin??38+o.height+4;"right"===n?e.right=Math.max(e.right,i):"left"===n?e.left=Math.max(e.left,i):"top"===n?e.top=Math.max(e.top,s):e.bottom=Math.max(e.bottom,a)}(e,{...l,legend:t})}else n.showLegend&&r.length>0&&function(e,t){if(0===t.categories.length)return;if(t.preserveExplicitMargin)return;const n=t.position||"right",r=function(e){const{width:t,height:n,swatchSize:r}=wp(e);return{width:t,height:n,swatchSize:r}}({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}),o=t.minimumMargin??r.width+14,i=t.minimumMargin??(t.hasTitle?32:8)+r.height+4,s=t.minimumMargin??38+r.height+4;"right"===n?e.right=Math.max(e.right,o):"left"===n?e.left=Math.max(e.left,o):"top"===n?e.top=Math.max(e.top,i):e.bottom=Math.max(e.bottom,s)}(e,{...l,categories:r,colorScheme:n.colorScheme});return a}function Yp(e){const{props:t,categories:n,theme:r,size:o,margin:i,hasTitle:s}=e,a=t.legendPosition||"right",l={theme:r,position:a,size:o,margin:i,hasTitle:s,legendLayout:t.legendLayout,idPrefix:t._idPrefix,reservedWidth:t.__autoLegendMargin?100:void 0};if(null!=t.legend){const e=Ep(t,n,r);if(zp.isValidElement(e))return e;const o=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};return Yo(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=kp(e),r="top"===e.position||"bottom"===e.position,o=e.theme.colors.grid||e.theme.colors.textSecondary;let i,s;if("left"===e.position?(i=Math.max(4,e.margin.left-(e.reservedWidth??100)-10),s=e.margin.top):"top"===e.position?(i=e.margin.left,s=e.hasTitle?32:8):"bottom"===e.position?(i=e.margin.left,s=e.totalHeight-e.margin.bottom+38):(i=e.totalWidth-e.margin.right+10,s=e.margin.top),!r){const t=$o(e.legendGroups.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),Math.max(n.swatchSize,e.legendLayout?.rowHeight??gp)),r=e.legendGroups.flatMap((r,o)=>{const i=t[o],s=r.type??"fill",a=[(0,yp.jsx)("line",{x1:0,y1:i.lineY,x2:e.reservedWidth??100,y2:i.lineY,stroke:"gray"},"legend-group-neatline-"+o)];return r.label&&null!=i.labelY&&a.push((0,yp.jsx)("text",{y:i.labelY,fontSize:bp(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:r.label},"legend-group-label-"+o)),a.push((0,yp.jsx)("g",{transform:`translate(0,${i.itemsY})`,children:r.items.map((t,i)=>{const a=r.styleFn(t,i),l="function"==typeof s?s(t):"line"===s?(0,yp.jsx)("line",{x1:0,y1:0,x2:n.swatchSize,y2:n.swatchSize,style:a}):(0,yp.jsx)("rect",{width:n.swatchSize,height:n.swatchSize,rx:n.swatchRadius,style:a});return(0,yp.jsxs)("g",{transform:`translate(0,${i*Math.max(n.swatchSize,e.legendLayout?.rowHeight??gp)})`,children:[l,(0,yp.jsx)("text",{x:n.labelOffset,y:n.swatchSize/2,dominantBaseline:"central",fontSize:bp(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:t.label})]},`legend-${o}-${i}`)})},"legend-group-"+o)),a});return(0,yp.jsx)("g",{className:"semiotic-legend",transform:`translate(${i},${s})`,"data-orientation":"vertical",children:r})}const a=n.groups.flatMap((t,i)=>{const{group:s}=t,a=s.type??"fill",l=[];if(s.label&&l.push((0,yp.jsx)("text",r?{transform:`translate(${t.x},${t.y}) rotate(90)`,textAnchor:"start",fontSize:bp(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:s.label}:{x:t.x,y:t.y+bp(e.theme),fontSize:bp(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:s.label},"legend-group-label-"+i)),l.push(...t.items.map((r,o)=>{const l=s.items[o],c=s.styleFn(l,o),u="function"==typeof a?a(l):"line"===a?(0,yp.jsx)("line",{x1:0,y1:0,x2:n.swatchSize,y2:n.swatchSize,style:c}):(0,yp.jsx)("rect",{width:n.swatchSize,height:n.swatchSize,rx:n.swatchRadius,style:c});return(0,yp.jsxs)("g",{transform:`translate(${t.x+t.itemOffsetX+r.x},${t.y+t.itemOffsetY+r.y})`,children:[u,(0,yp.jsx)("text",{x:n.labelOffset,y:n.swatchSize/2,dominantBaseline:"central",fontSize:bp(e.theme),fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:r.category})]},`legend-${i}-${o}`)})),r&&n.groups.length-1>i){const e=t.x+t.width+6;l.push((0,yp.jsx)("line",{x1:e,y1:0,x2:e,y2:n.height,stroke:o},"legend-group-separator-"+i))}return l});return(0,yp.jsx)("g",{className:"semiotic-legend",transform:`translate(${i},${s})`,"data-orientation":r?"horizontal":"vertical",children:a})}({...n,legendGroups:e.legendGroups}):qo(e)?function(e){const t=Sp(e),n="top"===e.position||"bottom"===e.position,r=(e.idPrefix?e.idPrefix+"-":"")+"semiotic-static-gradient-legend",o=e.gradient.format||(e=>Math.round(100*e)/100+"");let i,s;"left"===e.position?(i=Math.max(4,e.margin.left-100-10),s=e.margin.top):"top"===e.position?(i=e.margin.left,s=e.hasTitle?32:8):"bottom"===e.position?(i=e.margin.left,s=e.totalHeight-e.margin.bottom+38):(i=e.totalWidth-e.margin.right+10,s=e.margin.top);const a=Array.from({length:17},(t,r)=>{const o=r/16;return(0,yp.jsx)("stop",{offset:100*o+"%",stopColor:e.gradient.colorFn(n?e.gradient.domain[0]+o*(e.gradient.domain[1]-e.gradient.domain[0]):e.gradient.domain[1]-o*(e.gradient.domain[1]-e.gradient.domain[0]))},r)});if(n){const n=12,l=e.gradient.label?0:void 0,c=e.gradient.label?8:0;return(0,yp.jsxs)("g",{className:"semiotic-legend",transform:`translate(${i},${s})`,children:[(0,yp.jsx)("defs",{children:(0,yp.jsx)("linearGradient",{id:r,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:a})}),e.gradient.label&&(0,yp.jsx)("text",{x:t.width/2,y:l,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),(0,yp.jsx)("rect",{x:0,y:c,width:t.width,height:n,fill:`url(#${r})`,rx:2}),(0,yp.jsx)("text",{x:0,y:c+n+12,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:o(e.gradient.domain[0])}),(0,yp.jsx)("text",{x:t.width,y:c+n+12,textAnchor:"end",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:o(e.gradient.domain[1])})]})}const l=e.gradient.label?-6:void 0;return(0,yp.jsxs)("g",{className:"semiotic-legend",transform:`translate(${i},${s+(e.gradient.label?12:0)})`,children:[(0,yp.jsx)("defs",{children:(0,yp.jsx)("linearGradient",{id:r,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:a})}),e.gradient.label&&(0,yp.jsx)("text",{x:7,y:l,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:e.theme.typography.fontFamily,children:e.gradient.label}),(0,yp.jsx)("rect",{x:0,y:0,width:14,height:100,fill:`url(#${r})`,rx:2}),(0,yp.jsx)("text",{x:19,y:10,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:o(e.gradient.domain[1])}),(0,yp.jsx)("text",{x:19,y:100,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:e.theme.typography.fontFamily,children:o(e.gradient.domain[0])})]})}({...n,gradient:e.gradient}):null}(e,l);return o||(Yo(e)||qo(e)?null:e??null)}return t.showLegend&&0!==n.length?function(e){const{categories:t,colorScheme:n,theme:r,position:o="right",totalWidth:i,totalHeight:s,margin:a,hasTitle:l=!1}=e;if(!t||0===t.length)return null;const c=mp(t,n,r),u="top"===o||"bottom"===o,h=wp(e);let d,f;if("left"===o?(d=Math.max(4,a.left-(e.reservedWidth??100)-10),f=a.top):"top"===o?(d=a.left,f=l?32:8):"bottom"===o?(d=a.left,f=s-a.bottom+38):(d=i-a.right+10,f=a.top),u){const e=h.items.map((e,t)=>(0,yp.jsxs)("g",{transform:`translate(${e.x},${e.y})`,children:[(0,yp.jsx)("rect",{width:h.swatchSize,height:h.swatchSize,fill:c(e.category),rx:h.swatchRadius}),(0,yp.jsx)("text",{x:h.labelOffset,y:h.swatchSize/2,dominantBaseline:"central",fontSize:bp(r),fill:r.colors.text,fontFamily:r.typography.fontFamily,children:e.category})]},"legend-"+t));return(0,yp.jsx)("g",{className:"semiotic-legend",transform:`translate(${d},${f})`,children:e})}const p=$o([{hasLabel:!1,itemCount:t.length}],Math.max(h.swatchSize,e.legendLayout?.rowHeight??gp))[0],y=h.items.map((e,t)=>(0,yp.jsxs)("g",{transform:`translate(${e.x},${e.y+p.itemsY})`,children:[(0,yp.jsx)("rect",{width:h.swatchSize,height:h.swatchSize,fill:c(e.category),rx:h.swatchRadius}),(0,yp.jsx)("text",{x:h.labelOffset,y:h.swatchSize/2,dominantBaseline:"central",fontSize:bp(r),fill:r.colors.text,fontFamily:r.typography.fontFamily,children:e.category})]},"legend-"+t));return(0,yp.jsxs)("g",{className:"semiotic-legend",transform:`translate(${d},${f})`,children:[(0,yp.jsx)("line",{x1:0,y1:p.lineY,x2:e.reservedWidth??100,y2:p.lineY,stroke:"gray"}),y]})}({categories:n,colorScheme:t.colorScheme,theme:r,position:a,totalWidth:o[0],totalHeight:o[1],margin:i,hasTitle:s,legendLayout:t.legendLayout,reservedWidth:t.__autoLegendMargin?100:void 0,idPrefix:t._idPrefix}):null}function qp(e){return Math.round(100*e)/100+""}function Gp(e,t){const n=ju(t.theme),r=t.background??n.background,o=t.idPrefix?t.idPrefix+"-":"",i="string"==typeof t.title?t.title:void 0,s=i?o+"semiotic-title":void 0,a=t.description?o+"semiotic-desc":void 0,l=[s,a].filter(Boolean).join(" ")||void 0;return(0,Dp.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className,width:t.width,height:t.height,role:"img","aria-labelledby":l,style:{fontFamily:n.fontFamily},children:[i&&(0,Dp.jsx)("title",{id:s,children:i}),t.description&&(0,Dp.jsx)("desc",{id:a,children:t.description}),t.defs&&(0,Dp.jsx)("defs",{children:t.defs}),r&&"transparent"!==r&&(0,Dp.jsx)("rect",{x:0,y:0,width:t.width,height:t.height,fill:r}),(0,Dp.jsx)("g",{id:o+"data-area",transform:t.innerTransform,children:e}),i&&(0,Dp.jsx)("text",{id:o+"chart-title",x:t.width/2,y:Os,textAnchor:"middle",fontSize:n.titleSize,fontWeight:"bold",fill:n.text,fontFamily:n.fontFamily,children:i}),t.legend&&(0,Dp.jsx)("g",{id:o+"legend",children:t.legend}),t.outerElements]})}var Xp=require("react/jsx-runtime");function Hp(e,t){const n=Cu(e.theme),r=e.size||[500,300],o=Bs({top:20,right:20,bottom:30,left:40,...e.margin},e.title),i=Is(e.title),s=Z(e.data),a=e.showLegend?Ap(s,e.colorAccessor||e.groupAccessor||e.categoryAccessor):[];Wp(o,{props:e,categories:a,theme:n,size:r,hasTitle:i});const l=r[0]-o.left-o.right,c=r[1]-o.top-o.bottom,u="streaming"===e.runtimeMode||["bar","swarm","waterfall"].includes(e.chartType),h=e.colorScheme||n.colors.categorical,d={chartType:e.chartType,windowSize:e.windowSize??200,windowMode:e.windowMode??"sliding",arrowOfTime:u?e.arrowOfTime??"right":"right",extentPadding:e.extentPadding??.1,xAccessor:u?void 0:e.xAccessor,yAccessor:u?void 0:e.yAccessor,timeAccessor:u?e.timeAccessor:void 0,valueAccessor:e.valueAccessor,colorAccessor:e.colorAccessor,sizeAccessor:e.sizeAccessor,symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,groupAccessor:e.groupAccessor,categoryAccessor:e.categoryAccessor,lineDataAccessor:e.lineDataAccessor,xExtent:e.xExtent,yExtent:e.yExtent,axisExtent:e.axisExtent,sizeRange:e.sizeRange,xScaleType:e.xScaleType,yScaleType:e.yScaleType,scalePadding:e.scalePadding,binSize:e.binSize,normalize:e.normalize,baseline:e.baseline,stackOrder:e.stackOrder,boundsAccessor:e.boundsAccessor,boundsStyle:e.boundsStyle,band:e.band,y0Accessor:e.y0Accessor,areaGroups:e.areaGroups?e.areaGroups instanceof Set?e.areaGroups:new Set(e.areaGroups):void 0,curve:e.curve,gradientFill:!0===e.gradientFill?{topOpacity:.8,bottomOpacity:.05}:!1===e.gradientFill?void 0:e.gradientFill,lineGradient:e.lineGradient,openAccessor:e.openAccessor,highAccessor:e.highAccessor,lowAccessor:e.lowAccessor,closeAccessor:e.closeAccessor,candlestickStyle:e.candlestickStyle,lineStyle:e.lineStyle,pointStyle:e.pointStyle,areaStyle:e.areaStyle,barStyle:e.barStyle,waterfallStyle:e.waterfallStyle,swarmStyle:e.swarmStyle,colorScheme:h,themeCategorical:n.colors.categorical,themeSemantic:wt(n),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:o,layoutSelection:e.layoutSelection,barColors:e.barColors,showValues:e.showValues,heatmapValueFormat:e.heatmapValueFormat},f=new cr(d);if(e.data&&f.ingest({inserts:s,bounded:!0}),f.computeScene({width:l,height:c}),!f.scales||0===f.scene.length)return t&&(t.evidence=hp({frameType:"xy",width:r[0],height:r[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:f.scales?[]:["NO_SCALES"]})),fp.renderToStaticMarkup(Gp(null,{width:r[0],height:r[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${o.left},${o.top})`,innerWidth:l,innerHeight:c,idPrefix:e._idPrefix}));const p=e._idPrefix,y=ac({nodes:f.scene,renderMode:e.renderMode,fallback:(e,t)=>ma(e,t,p)});t&&(t.evidence=hp({frameType:"xy",width:r[0],height:r[1],marks:y.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,xDomain:up(f.scales.x?.domain?.()),yDomain:up(f.scales.y?.domain?.()),legendItems:a.length>0?a.length:void 0}));const g=e.showGrid?function(e,t,n,r,o){const{grid:i}=ju(n),s=r?r+"-":"",a="exact"===o?5:Math.min(5,Math.max(2,Math.floor(t.width/70))),l="exact"===o?5:Math.min(5,Math.max(2,Math.floor(t.height/30))),c=Ps(e.x,a,o),u=Ps(e.y,l,o);return(0,Dp.jsxs)("g",{id:s+"grid",className:"semiotic-grid",opacity:.8,children:[c.map((n,r)=>{const o=e.x(n);return(0,Dp.jsx)("line",{x1:o,y1:0,x2:o,y2:t.height,stroke:i,strokeWidth:.5},"gx-"+r)}),u.map((n,r)=>{const o=e.y(n);return(0,Dp.jsx)("line",{x1:0,y1:o,x2:t.width,y2:o,stroke:i,strokeWidth:.5},"gy-"+r)})]})}(f.scales,{width:l,height:c},n,p,e.axisExtent):null,m=y.map(e=>e.element),x=Ip(e)+"-plot-clip",b=!1!==e.showAxes?function(e,t,n,r,o){const i=ju(r),s="exact"===n.axisExtent?5:Math.min(5,Math.max(2,Math.floor(t.width/70))),a="exact"===n.axisExtent?5:Math.min(5,Math.max(2,Math.floor(t.height/30))),l=Ps(e.x,s,n.axisExtent).map(t=>({pixel:e.x(t),label:(n.xFormat||n.tickFormatTime||qp)(t)})),c=Ps(e.y,a,n.axisExtent).map(t=>({pixel:e.y(t),label:(n.yFormat||n.tickFormatValue||qp)(t)}));return(0,Dp.jsxs)("g",{id:(o?o+"-":"")+"axes",className:"stream-axes",children:[(0,Dp.jsx)("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:i.border,strokeWidth:1}),l.map((e,n)=>(0,Dp.jsxs)("g",{transform:`translate(${e.pixel},${t.height})`,children:[(0,Dp.jsx)("line",{y2:5,stroke:i.border,strokeWidth:1}),(0,Dp.jsx)("text",{y:18,textAnchor:"middle",fontSize:i.tickSize,fill:i.textSecondary,fontFamily:i.fontFamily,children:e.label})]},"xtick-"+n)),n.xLabel&&(0,Dp.jsx)("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:i.labelSize,fill:i.text,fontFamily:i.fontFamily,children:n.xLabel}),(0,Dp.jsx)("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:i.border,strokeWidth:1}),c.map((e,t)=>(0,Dp.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,Dp.jsx)("line",{x2:-5,stroke:i.border,strokeWidth:1}),(0,Dp.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:i.tickSize,fill:i.textSecondary,fontFamily:i.fontFamily,children:e.label})]},"ytick-"+t)),n.yLabel&&(0,Dp.jsx)("text",{x:15-(n.margin?.left??40),y:t.height/2,textAnchor:"middle",fontSize:i.labelSize,fill:i.text,fontFamily:i.fontFamily,transform:`rotate(-90, ${15-(n.margin?.left??40)}, ${t.height/2})`,children:n.yLabel})]})}(f.scales,{width:l,height:c},e,n,p):null,v=e.annotations?Lp({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{x:f.scales.x,y:f.scales.y},layout:{width:l,height:c},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,Xp.jsx)(dp.Fragment,{children:e(f.scene,f.scales,{width:l,height:c})},"pre-"+t)}catch{return null}}).filter(Boolean):null,k=Yp({props:e,categories:a,theme:n,size:r,margin:o,hasTitle:i});return fp.renderToStaticMarkup(Gp((0,Xp.jsxs)(Xp.Fragment,{children:[e.backgroundGraphics,w,g,(0,Xp.jsx)("defs",{children:(0,Xp.jsx)("clipPath",{id:x,children:(0,Xp.jsx)("rect",{x:0,y:0,width:l,height:c})})}),(0,Xp.jsx)("g",{clipPath:`url(#${x})`,children:m}),b,v,e.foregroundGraphics,f.customLayoutOverlays]}),{width:r[0],height:r[1],className:"stream-xy-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${o.left},${o.top})`,innerWidth:l,innerHeight:c,legend:k,idPrefix:e._idPrefix}))}var Vp=c(require("react-dom/server")),Up=require("d3-scale"),Kp=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 r=e.pieceStyle(t,n);return r&&!r.fill&&n?{...r,fill:this.getColorFromScheme(e,n)}:r}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 r=Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical||Ce,o=r[this.colorSchemeIndex%r.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(t,o),o}};function Zp(e){const t=e.getSymbol;if(!t)return null;const n=e.config.symbolMap,r=new Map;let o=0;return e=>{const i=t(e)+"",s=n?.[i];if(s)return s;let a=r.get(i);return a||(a=gn[o%gn.length],o++,r.set(i,a)),a}}function Qp(e,t,n,r,o,i,s){e.push(t?{type:"symbol",x:r,y:o,size:Math.PI*i*i,symbolType:t(n),style:s,datum:n}:{type:"point",x:r,y:o,r:i,style:s,datum:n})}function Jp(e,t){const{columns:n,config:r,resolvePieceStyle:o}=e,i=[],s=Math.min(t.width,t.height)/2-4,a="donut"===r.chartType?r.innerRadius||60:0,l=-Math.PI/2+(r.startAngle||0)*Math.PI/180,c=null!=r.sweepAngle?r.sweepAngle*Math.PI/180:2*Math.PI,u=null!=r.sweepAngle&&360>r.sweepAngle,h=Object.values(n),d=h.some(e=>{const t=e.pieceData[0];return t&&("number"==typeof t._pct||"number"==typeof t._pctStart||null!=t._roundedEnds)}),f=u&&!d&&h.length>1&&(r.cornerRadius??0)>0;for(let e=0;h.length>e;e++){const t=h[e],n=t.pieceData[0],u="number"==typeof n?._pctStart?n._pctStart:t.pctStart,d=l+u*c,p=l+(u+("number"==typeof n?._pct?n._pct:t.pct))*c,y=o(t.pieceData[0],t.name),g=0===e,m=e===h.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:a,outerRadius:s,startAngle:d,endAngle:p,...r.cornerRadius&&{cornerRadius:r.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 ey=require("d3-array");function ty(e){const t=e.length,n=e[0],r=e[t-1];return{n:t,min:n,q1:(0,ey.quantile)(e,.25)??n,median:(0,ey.quantile)(e,.5)??(n+r)/2,q3:(0,ey.quantile)(e,.75)??r,max:r,mean:e.reduce((e,t)=>e+t,0)/t}}x();var ny=require("d3-scale"),ry={bar:function(e,t){const{scales:n,columns:r,config:o,getR:i,getStack:s,resolvePieceStyle:a}=e,{r:l,projection:c}=n,u=[],h="vertical"===c,d="horizontal"===c,f=o.normalize,p=[];if(s){const e=new Set;for(const t of Object.values(r))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(r)){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 r=t.get(e);r.total+=i(n),r.pieces.push(n)}let n=0;if(f)for(const e of t.values())n+=Math.abs(e.total);let r=0,o=0;for(const i of p){const c=t.get(i);if(!c)continue;let p=c.total;f&&n>0&&(p/=n);const y=a(c.pieces[0],s?i:e.name),g={...c.pieces[0],__aggregateValue:c.total,__pieceCount:c.pieces.length,category:e.name};if(h){const t=l(0>p?o:r+p),n=0>p?l(o+p)-l(o):l(r)-l(r+p);u.push(tn(e.x,t,e.width,Math.abs(n),y,g,i)),0>p?o+=p:r+=p}else if(d){const t=l(0>p?o+p:r),n=0>p?l(o)-l(o+p):l(r+p)-l(r);u.push(tn(t,e.x,Math.abs(n),e.width,y,g,i)),0>p?o+=p:r+=p}}}const y="vertical"===c,g=o.roundedTop&&o.roundedTop>0?Math.max(0,o.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",o.gradientFill&&(e.fillGradient=o.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:r,config:o,getR:i,getGroup:s,resolvePieceStyle:a}=e,{r:l,projection:c}=n,u=[],h="vertical"===c,d=[],f=new Set;for(const e of Object.values(r))for(const t of e.pieceData){const e=s?s(t):"_default";f.has(e)||(f.add(e),d.push(e))}const p=d.length||1;for(const e of Object.values(r)){const t=e.width/p,n=.2*t,r=t-n,o=new Map;for(const t of e.pieceData){const e=s?s(t):"_default";o.has(e)||o.set(e,[]),o.get(e).push(t)}for(let s=0;d.length>s;s++){const c=o.get(d[s])||[];for(const o of c){const c=i(o),f=a(o,d[s]);if(h){const i=e.x+s*t+n/2,a=l(0),h=l(c);u.push(tn(i,Math.min(a,h),r,Math.abs(a-h),f,o,d[s]))}else{const i=e.x+s*t+n/2,a=l(0),h=l(c);u.push(tn(Math.min(a,h),i,Math.abs(h-a),r,f,o,d[s]))}}}}const y=o.roundedTop&&o.roundedTop>0?Math.max(0,o.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=h?0>t?"bottom":"top":0>t?"left":"right",o.gradientFill&&(e.fillGradient=o.gradientFill)}return u},point:function(e,t){const{scales:n,columns:r,getR:o,multiScales:i,resolvePieceStyle:s}=e,{r:a,projection:l}=n,c=[],u="vertical"===l,h="radial"===l,d=i.length>0,f=Zp(e),p=2*Math.PI,y=-Math.PI/2;for(const e of Object.values(r))for(const t of e.pieceData){const n=t.__rIndex??0,r=t.__rValue??o(t),l=d&&i[n]||a,g=s(t,e.name),m=g.r||5;let x,b;if(h){const t=y+(e.pctStart+e.pct/2)*p,n=l(r);x=Math.cos(t)*n,b=Math.sin(t)*n}else u?(x=e.middle,b=l(r)):(x=l(r),b=e.middle);Qp(c,f,t,x,b,m,g)}return c},swarm:function(e,t){const{scales:n,columns:r,getR:o,resolvePieceStyle:i}=e,{r:s,projection:a}=n,l=[],c="vertical"===a,u=Zp(e);for(const e of Object.values(r)){const t=e.width/2;for(let n=0;e.pieceData.length>n;n++){const r=e.pieceData[n],a=o(r),h=i(r,e.name),d=h.r||4,f=(7919*n%100/100-.5)*t*.8;Qp(l,u,r,c?e.middle+f:s(a),c?s(a):e.middle+f,d,h)}}return l},pie:Jp,donut:Jp,boxplot:function(e,t){const{scales:n,columns:r,config:o,getR:i,resolveSummaryStyle:s}=e,{r:a,projection:l}=n,c=[],u="vertical"===l,h=!1!==o.showOutliers;for(const t of Object.values(r)){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 r=n[0],o=n[n.length-1],l=(0,ey.quantile)(n,.25)??r,d=(0,ey.quantile)(n,.5)??(r+o)/2,f=(0,ey.quantile)(n,.75)??o,p=f-l,y=l-1.5*p,g=f+1.5*p,m=n.find(e=>e>=y)??r,x=[...n].reverse().find(e=>g>=e)??o,b=s(t.pieceData[0],t.name),v=[];if(h)for(const e of t.pieceData){const n=i(e);if(y>n||n>g){const r=u?t.middle:a(n),o=u?a(n):t.middle;v.push({px:r,py:o,value:n,datum:e})}}if(c.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(l),medianPos:a(d),q3Pos:a(f),maxPos:a(x),stats:{n:n.length,min:m,q1:l,median:d,q3:f,max:x,mean:n.reduce((e,t)=>e+t,0)/n.length},style:b,datum:t.pieceData,category:t.name,outliers:v}),h)for(const t of v)c.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 c},violin:function(e,t){const{scales:n,columns:r,config:o,getR:i,resolveSummaryStyle:s}=e,{r:a,projection:l}=n,c=[],u="vertical"===l,d=o.bins||20,f=!1!==o.showIQR;for(const e of Object.values(r)){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],r=t[t.length-1],o=(r-n)/d||1,l=Array(d).fill(0);for(const e of t)l[Math.min(Math.floor((e-n)/o),d-1)]++;const p=h(l,1),y=e.width/2*.9;let g;if(u){g=`M ${e.middle} ${a(n)}`;for(let t=0;d>t;t++){const r=a(n+(t+.5)*o);g+=` L ${e.middle+l[t]/p*y} ${r}`}g+=` L ${e.middle} ${a(r)}`;for(let t=d-1;t>=0;t--){const r=a(n+(t+.5)*o);g+=` L ${e.middle-l[t]/p*y} ${r}`}g+=" Z"}else{g=`M ${a(n)} ${e.middle}`;for(let t=0;d>t;t++)g+=` L ${a(n+(t+.5)*o)} ${e.middle-l[t]/p*y}`;g+=` L ${a(r)} ${e.middle}`;for(let t=d-1;t>=0;t--)g+=` L ${a(n+(t+.5)*o)} ${e.middle+l[t]/p*y}`;g+=" Z"}const m=s(e.pieceData[0],e.name);let x;if(f&&t.length>=4){const o=(0,ey.quantile)(t,.25)??n,i=(0,ey.quantile)(t,.5)??(n+r)/2,s=(0,ey.quantile)(t,.75)??r;x={q1Pos:a(o),medianPos:a(i),q3Pos:a(s),centerPos:e.middle,isVertical:u}}const b=u?{x:e.x,y:Math.min(a(r),a(n)),width:e.width,height:Math.abs(a(r)-a(n))}:{x:Math.min(a(n),a(r)),y:e.x,width:Math.abs(a(r)-a(n)),height:e.width};c.push({type:"violin",pathString:g,translateX:0,translateY:0,bounds:b,iqrLine:x,stats:ty(t),style:m,datum:e.pieceData,category:e.name})}return c},histogram:function(e,t){const{scales:n,columns:r,config:o,getR:i,resolveSummaryStyle:s}=e,{r:a}=n,l=[],c=o.bins||25,d=o.normalize,f=a.domain?.(),p=f?+f[0]:void 0,y=f?+f[1]:void 0;for(const e of Object.values(r)){const t=e.pieceData.map(e=>i(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const[n,r]=u(t),o=null!=p&&isFinite(p)?p:n,f=null!=y&&isFinite(y)?y:r,g=(f-o)/c||1,m=Array(c).fill(0);for(const e of t)o>e||e>f||m[Math.min(Math.floor((e-o)/g),c-1)]++;const x=t.length,b=h(m,1),v=s(e.pieceData[0],e.name);for(let t=0;c>t;t++){if(0===m[t])continue;const n=(d?m[t]/x:m[t]/b)*e.width*.9,r=a(o+t*g),i=a(o+(t+1)*g);l.push(tn(Math.min(r,i),e.x+e.width-n,Math.abs(i-r),n,v,{bin:t,count:m[t],range:[o+t*g,o+(t+1)*g],category:e.name},e.name))}}return l},ridgeline:function(e,t){const{scales:n,columns:r,config:o,getR:i,resolveSummaryStyle:s}=e,{r:a,projection:l}=n,c=[],u=o.bins||20,d="horizontal"===l,f=o.amplitude||1.5;for(const e of Object.values(r)){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],r=t[t.length-1],o=(r-n)/u||1,l=Array(u).fill(0);for(const e of t)n>e||e>r||l[Math.min(Math.floor((e-n)/o),u-1)]++;const p=h(l,1),y=s(e.pieceData[0],e.name),g=e.width*f;let m;if(d){const t=e.x+e.width;m=`M ${a(n)} ${t}`;for(let e=0;u>e;e++)m+=` L ${a(n+(e+.5)*o)} ${t-l[e]/p*g}`;m+=` L ${a(r)} ${t} Z`}else{const t=e.x;m=`M ${t} ${a(n)}`;for(let e=0;u>e;e++){const r=a(n+(e+.5)*o);m+=` L ${t+l[e]/p*g} ${r}`}m+=` L ${t} ${a(r)} Z`}const x=d?{x:Math.min(a(n),a(r)),y:e.x,width:Math.abs(a(r)-a(n)),height:e.width}:{x:e.x,y:Math.min(a(r),a(n)),width:e.width,height:Math.abs(a(r)-a(n))};c.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:x,stats:ty(t),style:{...y,fillOpacity:y.fillOpacity??.5},datum:e.pieceData,category:e.name})}return c},timeline:function(e,t){const{scales:n,columns:r,getRawRange:o,resolvePieceStyle:i}=e,{r:s,projection:a}=n,l=[],c="horizontal"===a;for(const e of Object.values(r))for(const t of e.pieceData){const n=o(t);if(!n)continue;const[r,a]=n,u=i(t,e.name);if(c){const n=s(Math.min(r,a)),o=s(Math.max(r,a));l.push(tn(n,e.x,o-n,e.width,u,t,e.name))}else{const n=s(Math.max(r,a)),o=s(Math.min(r,a));l.push(tn(e.x,n,e.width,o-n,u,t,e.name))}}return l},funnel:function(e,t){const{columns:n,getR:r,getStack:o,resolvePieceStyle:i}=e,s=[],a=t.width/2,l=!1!==e.config.showLabels,c=e.scales.o.domain().map(e=>n[e]).filter(Boolean);if(0===c.length)return s;const u=[],h=new Set;for(const e of c)for(const t of e.pieceData){const e=o?o(t):"_default";h.has(e)||(h.add(e),u.push(e))}const d=u.length>1&&"_default"!==u[0],f=[];let p=0;for(const e of c){const t=new Map;let n=0;for(const i of e.pieceData){const e=o?o(i):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const s=t.get(e),a=r(i);s.total+=a,s.pieces.push(i),n+=a}f.push({col:e,groups:t,stepTotal:n}),d||n>p&&(p=n)}if(d)for(const e of f){let t=0,n=0;for(let r=0;u.length>r;r++){const o=e.groups.get(u[r]);o&&(r%2==0?t+=o.total:n+=o.total)}const r=Math.max(t,n);r>p&&(p=r)}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=d?.95*a:.9*t.width,x=(0,ny.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],r=n.col,o=0===t,c=r.width,h=.55*c,p=r.x+(c-h)/2,m=new Map;if(d){let e=0;for(const t of u){const r=n.groups.get(t);r&&(e+=x(r.total))}let t=a,c=a;for(let d=0;u.length>d;d++){const f=u[d],g=n.groups.get(f);if(!g)continue;const b=x(g.total),v=d%2==0,w=v?t:c-b;v?t+=b:c-=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:r.name,__funnelIsFirstStep:o,__aggregateValue:g.total,__pieceCount:g.pieces.length,category:f};l&&(0===d&&(A.__funnelStepLabel=r.name,A.__funnelStepLabelX=a,A.__funnelStepLabelY=p,A.__funnelRowWidth=e),A.__funnelValueLabelX=w+b/2,A.__funnelValueLabelY=p,A.__funnelBarW=b),s.push(tn(w,p,b,h,k,A,f)),m.set(f,{x:w,y:p,w:b,h:h})}}else{const e=n.stepTotal,t=x(e),c=a-t/2,d=u[0],f="_default"!==d,y=n.groups.get(d)?.pieces[0]??r.pieceData[0],b=f?d:r.name,v=i(y,b),w=g>0?e/g*100:0,k={...y,__funnelValue:e,__funnelPercent:w,__funnelStep:r.name,__funnelIsFirstStep:o,category:f?d:r.name};l&&(k.__funnelStepLabel=r.name,k.__funnelStepLabelX=a,k.__funnelStepLabelY=p,k.__funnelRowWidth=t,k.__funnelValueLabelX=a,k.__funnelValueLabelY=p,k.__funnelBarW=t),s.push(tn(c,p,t,h,v,k,b)),m.set(d,{x:c,y:p,w:t,h:h})}if(t>0&&v.size>0){const t=d?u:[u[0]];for(const o of t){const t=v.get(o),a=m.get(o);if(!t||!a)continue;const l=(()=>{const e=n.groups.get(o);return i(e?e.pieces[0]:r.pieceData[0],"_default"===o?r.name:o)})(),c={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:l.fill||e.config.themeSemantic?.secondary||"#999",opacity:b},datum:n.groups.get(o)?.pieces[0]??r.pieceData[0],category:"_default"===o?r.name:o};s.push(c)}}v=m}return s},"bar-funnel":function(e,t){const{columns:n,getR:r,getStack:o,resolvePieceStyle:i,scales:s}=e,a=[],l=s.o.domain().map(e=>n[e]).filter(Boolean);if(0===l.length)return a;const c=[],u=new Set;for(const e of l)for(const t of e.pieceData){const e=o?o(t):"_default";u.has(e)||(u.add(e),c.push(e))}const h=c.length>1&&"_default"!==c[0],d=[];for(const e of l){const t=new Map;let n=0;for(const i of e.pieceData){const e=o?o(i):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const s=t.get(e),a=r(i);s.total+=a,s.pieces.push(i),n+=a}d.push({col:e,groups:t,stepTotal:n})}const f=new Map;for(const e of c){const t=d[0]?.groups.get(e);f.set(e,t?.total??0)}const p=s.r,y=h?c.length:1,g=h?.15:0;for(let e=0;d.length>e;e++){const t=d[e],n=t.col,r=0===e,o=e>0?d[e-1]:null,s=n.width/y,l=s*g,u=s-l;for(let e=0;c.length>e;e++){const d=c[e],y=t.groups.get(d);if(!y)continue;const g=y.total,m=f.get(d)??g,x=m>0?g/m*100:0,b=o?.groups.get(d),v=r?0:Math.max(0,(b?.total??g)-g),w=n.x+e*s+l/2,k=p(g),S=p(0)-k,A=i(y.pieces[0],h?d:n.name),M={...y.pieces[0],__barFunnelValue:g,__barFunnelPercent:x,__barFunnelIsFirstStep:r,__barFunnelIsDropoff:!1,__barFunnelStep:n.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===d?void 0:d,category:h?d:n.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:p(g+v)};if(a.push(tn(w,k,u,S,A,M,h?d:n.name)),v>0){const e=p(g+v),t=k-e,r={...A},o={...y.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:n.name,__barFunnelCategory:"_default"===d?void 0:d,category:h?d:n.name};a.push(tn(w,e,u,t,r,o,h?d:n.name))}}}return a},swimlane:function(e,t){const{scales:n,columns:r,getR:o,getStack:i,resolvePieceStyle:s}=e,{r:a,projection:l}=n,c=[],u="horizontal"===l,h=e.config.gradientFill,d=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,o]=a.range(),i=Math.min(n,o),s=Math.abs(o-n);for(const n of Object.values(r)){const r={fill:e,opacity:t},o=u?tn(i,n.x,s,n.width,r,null,"__track__"):tn(n.x,i,n.width,s,r,null,"__track__");c.push(o)}}const p=e.config.roundedTop&&e.config.roundedTop>0?Math.max(0,e.config.roundedTop):0;for(const e of Object.values(r)){let t=0;const n=c.length;for(const n of e.pieceData){const r=Math.abs(o(n));if(0===r)continue;const l=i?i(n):e.name,f=s(n,l);let p;if(u){const o=a(t),i=a(t+r);p=tn(o,e.x,i-o,e.width,f,n,l)}else{const o=a(t+r),i=a(t);p=tn(e.x,o,e.width,i-o,f,n,l)}h&&(p.fillGradient=h,p.roundedEdge=d),c.push(p),t+=r}if(p>0&&c.length>n){const e=c.slice(n),t=e[0],r=e[e.length-1];1===e.length?t.cornerRadii={tl:p,tr:p,br:p,bl:p}:u?(t.cornerRadii={tl:p,bl:p},r.cornerRadii={tr:p,br:p}):(t.cornerRadii={bl:p,br:p},r.cornerRadii={tl:p,tr:p})}}return c}},oy=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],iy=["scene-style","data-paint","accessibility","evidence"],sy=(e,t)=>({retainedData:e,invalidations:t}),ay=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ly=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],cy=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],uy=["scene-geometry","data-paint","accessibility","evidence"],hy=["scene-style","data-paint","accessibility","evidence"],dy=[],fy={chartType:sy("rebuild",ay),runtimeMode:sy("rebuild",ay),categoryAccessor:sy("rebuild",ay),valueAccessor:sy("rebuild",ay),oAccessor:sy("rebuild",ay),rAccessor:sy("rebuild",ay),stackBy:sy("rebuild",ay),groupBy:sy("rebuild",ay),timeAccessor:sy("rebuild",ay),accessorRevision:sy("rebuild",ay),colorAccessor:sy("rebuild",hy),symbolAccessor:sy("rebuild",uy),connectorAccessor:sy("rebuild",uy),dataIdAccessor:sy("rebuild",uy),projection:sy("preserve",ly),extentPadding:sy("preserve",ly),axisExtent:sy("preserve",ly),rExtent:sy("preserve",ly),oExtent:sy("preserve",ly),multiAxis:sy("preserve",ly),normalize:sy("preserve",ly),bins:sy("preserve",ly),oSort:sy("preserve",cy),barPadding:sy("preserve",cy),roundedTop:sy("preserve",cy),baselinePadding:sy("preserve",cy),innerRadius:sy("preserve",cy),cornerRadius:sy("preserve",cy),startAngle:sy("preserve",cy),sweepAngle:sy("preserve",cy),trackFill:sy("preserve",cy),showOutliers:sy("preserve",cy),showIQR:sy("preserve",cy),amplitude:sy("preserve",cy),connectorOpacity:sy("preserve",cy),showLabels:sy("preserve",cy),dynamicColumnWidth:sy("rebuild",cy),customLayout:sy("preserve",cy),layoutConfig:sy("preserve",cy),layoutMargin:sy("preserve",cy),symbolMap:sy("preserve",uy),pieceStyle:sy("preserve",hy),summaryStyle:sy("preserve",hy),connectorStyle:sy("preserve",hy),gradientFill:sy("preserve",hy),colorScheme:sy("preserve",hy),themeCategorical:sy("preserve",hy),themeSemantic:sy("preserve",hy),themeSequential:sy("preserve",hy),themeDiverging:sy("preserve",hy),barColors:sy("preserve",hy),decay:sy("preserve",hy),pulse:sy("preserve",hy),staleness:sy("preserve",hy),layoutSelection:sy("preserve",hy),windowSize:sy("preserve",dy),windowMode:sy("preserve",dy),clock:sy("preserve",dy),transition:sy("preserve",dy),introAnimation:sy("preserve",dy),onLayoutError:sy("preserve",dy)},py=sy("preserve",cy),yy=class{constructor(){this.tracker=new Xn}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}},oy)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},iy):this.recordNoop("restyle")}recordConfig(e){const t=function(e){let t="preserve";const n=new Set;for(const r of e){const e=fy[r]??py;"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)}},gy=require("d3-quadtree"),my=class{constructor(e){this.rExtent=new Rt,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new yy,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new Kp,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 Tt(e.windowSize),this.getO=Dt(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>$t(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new Rt)):(this.getR=$t(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=Dt(e.stackBy),this.getGroup=Dt(e.groupBy),this.getColor=Dt(e.colorAccessor),this.getSymbol=Dt(e.symbolAccessor),this.getConnector=Dt(e.connectorAccessor),this.getDataId=Dt(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new Tt(e.windowSize))}syncPulseTimestampBuffer(){var e,t,n,r;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,n=this.timestampBuffer,r=this.currentTime(),e?null!=n&&n.capacity===t.capacity&&n.size===t.size?n:Ln(t,r):null)}currentTime(){return this.config.clock?.()??Yt()}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(),Rn(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,r=this.scales,o=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",l=t.oExtent||this.resolveCategories(s),c=this.computeValueDomain(s,l),u="horizontal"===a,h="radial"===a,d=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===a?e.width:e.height):.1));let f,p;if(h){f=(0,Up.scaleBand)().domain(l).range([0,1]).padding(0);const n=Math.min(e.width,e.height)/2,r=t.innerRadius||0;p=(0,Up.scaleLinear)().domain(c).range([r,n])}else u?(f=(0,Up.scaleBand)().domain(l).range([0,e.height]).padding(d),p=(0,Up.scaleLinear)().domain(c).range([0,e.width])):(f=(0,Up.scaleBand)().domain(l).range([0,e.width]).padding(d),p=(0,Up.scaleLinear)().domain(c).range([e.height,0]));this.scales={o:f,r:p,projection:a},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((r,o)=>{const i=this.rExtents[o];i.dirty&&i.recalculate(n,r);let[s,a]=i.extent;s===1/0&&(s=0,a=1);const l=a-s,c=l>0?l*(t.extentPadding??.05):1;return s-=c,a+=c,s>0&&(s=0),u?(0,Up.scaleLinear)().domain([s,a]).range([0,e.width]):(0,Up.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,l,f,a,e),this._customLayoutFailedThisBuild=!1;const g=this.buildSceneNodes(y,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.multiScales=o,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,r="auto"===t?void 0:t;let o=null;if(n){o=new Set;for(const t of e)o.add(this.getO(t))}const i=o?Array.from(this.categories).filter(e=>o.has(e)):Array.from(this.categories);if(n&&void 0===r){const e=Math.max(50,3*o.size);if(this.categories.size>e){let t=this.categories.size-e;for(const e of this.categories){if(0>=t)break;o.has(e)||(this.categories.delete(e),t--)}}return i}if(!1===r)return i;if("function"==typeof r)return i.sort(r);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"===r?(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:r,normalize:o,rExtent:i,extentPadding:s=.05,baselinePadding:a,axisExtent:l,getO:c,getR:u,getStack:h,rawRExtent:d}=e,f=s;if("radial"===r&&("pie"===n||"donut"===n))return[0,1];let p=0,y=0;if("bar"===n&&h&&o)p=0,y=1;else if("bar"===n&&h){const e=new Map,n=new Map;for(const r of t){const t=c(r),o=u(r);0>o?n.set(t,(n.get(t)||0)+o):e.set(t,(e.get(t)||0)+o)}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=c(n),r=u(n);e.set(t,(e.get(t)||0)+r)}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=c(n),r=Math.abs(u(n));e.set(t,(e.get(t)||0)+r)}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=d[0],t=d[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"!==l){const e=y-p,t=e>0?e*f:1,r=g&&!a&&0===p,o=g&&!a&&0===y||"swimlane"===n;null!=i?.[0]||r||(p-=t),null!=i?.[1]||o||(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,r,o){return function(e){const{data:t,oExtent:n,oScale:r,projection:o,layout:i,dynamicColumnWidth:s,getO:a,getR:l}=e,c={},u=new Map;for(const e of t){const t=a(e);u.has(t)||u.set(t,[]),u.get(t).push(e)}let h=0;if("radial"===o)for(const e of t)h+=Math.abs(l(e));let d=null;if(s&&"radial"!==o){d=new Map;let e=0;for(const t of n){const n=u.get(t)||[];let r;r="string"==typeof s?n.reduce((e,t)=>e+(Number(t[s])||0),0):s(n),d.set(t,r),e+=r}const t=("horizontal"===o?i.height:i.width)-r.padding()*r.step()*n.length;if(e>0)for(const[n,r]of d)d.set(n,r/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(l(t)),0),o=h>0?n/h:0;let i,s;d?(i=p,s=d.get(e)||r.bandwidth(),p+=s+r.padding()*r.step()):(i=r(e)??0,s=r.bandwidth()),c[e]={name:e,x:i,y:0,width:s,middle:i+s/2,padding:r.padding()*r.step(),pieceData:t,pct:o,pctStart:f},f+=o}return c}({data:e,oExtent:t,oScale:n,projection:r,layout:o,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 r;try{r=this.config.customLayout(n)}catch(e){const t=null!==this.lastCustomLayoutResult,n=Mn("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=r.overlays??null,this.lastCustomLayoutResult=r,this.lastCustomLayoutFailure=null;const o=r.nodes??[];if(this._customRestyle=r.restyle,this.hasCustomRestyle=!!r.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(const e of o)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(o,this.config.layoutSelection??null)}return kn({label:"ordinal customLayout",nodes:o,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),o}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;const n=this.getSceneContext(),r=ry[this.config.chartType];let o=r?r(n,t):[];if(this.getConnector&&this.scales){const e=function(e,t){const{scales:n,config:r,getConnector:o,getO:i}=e;if(!o||!n)return[];const s=[],{projection:a}=n,l=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const n=o(t);if(!n)continue;let r,s;"point"===e.type?(r=e.x,s=e.y):(r=e.x+e.w/2,s=e.y+("vertical"===a?0:e.h/2)),l.has(n)||l.set(n,[]),l.get(n).push({x:r,y:s,datum:t,category:i(t)})}const c=n.o.domain(),u=r.connectorStyle;for(const[t,n]of l)if(n.length>=2){n.sort((e,t)=>c.indexOf(e.category)-c.indexOf(t.category));for(let r=0;n.length-1>r;r++){const o=n[r],i=n[r+1],a="function"==typeof u?u(o.datum):u||{stroke:e.config.themeSemantic?.border||e.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5};s.push({type:"connector",x1:o.x,y1:o.y,x2:i.x,y2:i.y,style:a,datum:o.datum,group:t})}}return s}(n,o);o=[...e,...o]}return o}buildLayoutContext(e,t){const n=this.config,r=n.layoutMargin??{top:0,right:0,bottom:0,left:0},o=Xf(n.colorScheme,n.themeCategorical,Ce),i=this.scales;return{data:e,scales:{o:i.o,r:i.r,projection:i.projection},dimensions:{width:t.width,height:t.height,margin:r,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:[...o]},resolveColor:Hf(o,n.colorScheme),config:n.layoutConfig??{},selection:n.layoutSelection??null}}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?qt(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=Gt(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,r=n?null:t||"category",o=new Map;for(let i=0;e.length>i;i++){const s=e[i],a=n?t(s):s[r],l=o.get(a);l?l.push(i):o.set(a,[i])}return o}(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 r of e)"point"===r.type&&(t++,r.r>n&&(n=r.r));if(500>=t)return{quadtree:null,maxRadius:n};const r=Array(t);let o=0;for(const t of e)"point"===t.type&&(r[o++]=t);return{maxRadius:n,quadtree:(0,gy.quadtree)().x(e=>e.x).y(e=>e.y).addAll(r)}}(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 r=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=r.get(t.datum);if(null==e)continue;const o=this.computeDecayOpacity(e,n);t.style={...t.style,opacity:(t.style?.opacity??1)*o}}}applyPulse(e,t,n=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,n,r,o,i){const s=e.color??"rgba(255,255,255,0.6)",a=e.glowRadius??4;let l=!1;for(const c of t){if("connector"===c.type||"violin"===c.type||"boxplot"===c.type)continue;if("wedge"===c.type){const t=c.category;if(!t)continue;let r=0;for(const s of o(t)??[]){const t=n.get(s);null!=t&&(r=Math.max(r,Xt(e,t,i)))}l=Ht(c,r,s)||l;continue}if(null==c.datum)continue;const t=r.get(c.datum);if(null==t)continue;const u=n.get(t);l=Ht(c,null==u?0:Xt(e,u,i),s,a)||l}return l}(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&&Vt(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 r;for(let o=0;this.scene.length>o;o++){const i=this.scene[o],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===r&&(r=i.startAngle),this.prevPositionMap.set(s,{x:i.cx,y:i.cy,startAngle:r,endAngle:r,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}`,r=t.get(n)||0;return t.set(n,r+1),`${n}:${r}`}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],r=this.getNodeKey(n,e);r&&("point"===n.type?this.prevPositionMap.set(r,{x:n.x,y:n.y,r:n.r,opacity:n.style.opacity}):"rect"===n.type?this.prevPositionMap.set(r,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style.opacity}):"wedge"===n.type&&this.prevPositionMap.set(r,{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,r=new Map;for(let e=0;this.scene.length>e;e++){const o=this.scene[e],i=this.getNodeKey(o,r);if(!i)continue;o._transitionKey=i;const s=this.prevPositionMap.get(i);if("point"===o.type)s?(n.add(i),o._targetOpacity=o.style.opacity??1,(s.x!==o.x||s.y!==o.y||void 0!==s.r&&s.r!==o.r)&&(o._targetX=o.x,o._targetY=o.y,o._targetR=o.r,o.x=s.x,o.y=s.y,void 0!==s.r&&(o.r=s.r),t=!0)):(o._targetOpacity=o.style.opacity??1,o._targetR=o.r,o.r=0,o.style={...o.style,opacity:0},t=!0);else if("rect"===o.type)s?(n.add(i),o._targetOpacity=o.style.opacity??1,s.x===o.x&&s.y===o.y&&s.w===o.w&&s.h===o.h||(o._targetX=o.x,o._targetY=o.y,o._targetW=o.w,o._targetH=o.h,o.x=s.x,o.y=s.y,o.w=s.w??o.w,o.h=s.h??o.h,t=!0)):(o._targetOpacity=o.style.opacity??1,o.style={...o.style,opacity:0},t=!0);else if("wedge"===o.type)if(s)n.add(i),o._targetOpacity=o.style.opacity??1,s.startAngle===o.startAngle&&s.endAngle===o.endAngle||(o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle,o.startAngle=s.startAngle,o.endAngle=s.endAngle,t=!0);else{o._targetOpacity=o.style.opacity??1,o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle;const e=o.startAngle;o.startAngle=e,o.endAngle=e,o.style={...o.style,opacity:0},this.prevPositionMap.set(i,{x:o.cx,y:o.cy,startAngle:e,endAngle:e,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:0}),t=!0}}this.exitNodes=[];for(const[e,r]of this.prevPositionMap)if(!n.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:r.x,y:r.y,r:r.r??3,style:{opacity:r.opacity??1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:r.x,y:r.y,w:r.w??0,h:r.h??0,style:{opacity:r.opacity??1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){const t=((r.startAngle??0)+(r.endAngle??0))/2,n={type:"wedge",cx:r.x,cy:r.y,innerRadius:r.innerRadius??0,outerRadius:r.outerRadius??100,startAngle:r.startAngle??0,endAngle:r.endAngle??0,style:{opacity:r.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=Nt(e,this.activeTransition),n=Ft(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 r=this.prevPositionMap.get(t);e.style.opacity=Wt(r?r.opacity??1:0,e._targetOpacity,n)}const r=this.prevPositionMap.get(t);void 0!==e._targetX&&r&&(e.x=Wt(r.x,e._targetX,n),e.y=Wt(r.y,e._targetY,n)),void 0!==e._targetR&&void 0!==r?.r&&(e.r=Wt(r.r,e._targetR,n))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const r=this.prevPositionMap.get(t);e.style.opacity=Wt(r?r.opacity??1:0,e._targetOpacity,n)}if(void 0===e._targetX)continue;const r=this.prevPositionMap.get(t);if(!r)continue;e.x=Wt(r.x,e._targetX,n),e.y=Wt(r.y,e._targetY,n),void 0!==r.w&&(e.w=Wt(r.w,e._targetW,n),e.h=Wt(r.h,e._targetH,n))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){const r=this.prevPositionMap.get(t);e.style={...e.style,opacity:Wt(r?r.opacity??1:0,e._targetOpacity,n)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){const r=this.prevPositionMap.get(t);r&&void 0!==r.startAngle&&(e.startAngle=Wt(r.startAngle,e._targetStartAngle,n),e.endAngle=Wt(r.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=Bt(e),n=this.getDataId,r=e=>t.has(n(e));zn(this.buffer,this.timestampBuffer,r);const o=this.buffer.remove(r);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(const e of o)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",o.length),o}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const n=Bt(e),r=this.getDataId,o=new Set;this.buffer.forEach((e,t)=>{n.has(r(e))&&o.add(t)});const i=this.buffer.update(e=>n.has(r(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)),o.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 r of e){const e=this._baseStyles.get(r)??r.style??{},o=n(r,t);r.style=o?{...e,...o}: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&&!Lt(e.colorAccessor,t.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!Lt(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!Lt(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),"pulse"in e&&this.syncPulseTimestampBuffer();let r=!1;("categoryAccessor"in e||"oAccessor"in e)&&(Lt(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=Dt(this.config.categoryAccessor||this.config.oAccessor,"category"),r=!0));let o=!1;if("valueAccessor"in e||"rAccessor"in e){const e=this.config.valueAccessor||this.config.rAccessor,n=t.valueAccessor||t.rAccessor,r=Array.isArray(e)?e:[e],i=Array.isArray(n)?n:[n];if(o=r.length!==i.length||r.some((e,t)=>!Lt(e,i[t])),o){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>$t(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new Rt)):(this.getR=$t(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!Lt(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?Dt(this.config.stackBy):void 0),"groupBy"in e&&!Lt(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?Dt(this.config.groupBy):void 0),"colorAccessor"in e&&!Lt(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Dt(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!Lt(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Dt(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!Lt(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?Dt(this.config.connectorAccessor):void 0),(r||o||"accessorRevision"in e&&e.accessorRevision!==t.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(n)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};Wn(my);var xy=require("react/jsx-runtime"),by=require("react/jsx-runtime");function vy(e,t){const n=Cu(e.theme),r=e.size||[500,400],o=Bs({top:20,right:20,bottom:30,left:40,...e.margin},e.title),i=Is(e.title),s=Z(e.data),a=e.showLegend?Ap(s,e.colorAccessor||e.stackBy||e.groupBy):[];Wp(o,{props:e,categories:a,theme:n,size:r,hasTitle:i});const l=r[0]-o.left-o.right,c=r[1]-o.top-o.bottom,u=e.projection||"vertical",h="radial"===u,d={chartType:e.chartType,windowSize:e.windowSize??1e4,windowMode:e.windowMode??"sliding",extentPadding:e.extentPadding??.05,projection:u,oAccessor:e.oAccessor,rAccessor:e.rAccessor,colorAccessor:e.colorAccessor,stackBy:e.stackBy,groupBy:e.groupBy,categoryAccessor:e.categoryAccessor,valueAccessor:e.valueAccessor,timeAccessor:e.timeAccessor,rExtent:e.rExtent,oExtent:e.oExtent,axisExtent:e.axisExtent,barPadding:e.barPadding,roundedTop:e.roundedTop,innerRadius:e.innerRadius,cornerRadius:e.cornerRadius,normalize:e.normalize,startAngle:e.startAngle,sweepAngle:e.sweepAngle,bins:e.bins,showOutliers:e.showOutliers,showIQR:e.showIQR,amplitude:e.amplitude,oSort:e.oSort,connectorAccessor:e.connectorAccessor,connectorStyle:e.connectorStyle,dynamicColumnWidth:e.dynamicColumnWidth,pieceStyle:e.pieceStyle,summaryStyle:e.summaryStyle,gradientFill:e.gradientFill,symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,multiAxis:e.multiAxis,baselinePadding:e.baselinePadding,trackFill:e.trackFill,connectorOpacity:e.connectorOpacity,showLabels:e.showLabels,colorScheme:e.colorScheme||n.colors.categorical,themeCategorical:n.colors.categorical,themeSemantic:wt(n),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:o,layoutSelection:e.layoutSelection,barColors:e.barColors},f=new my(d);if(e.data&&f.ingest({inserts:s,bounded:!0}),f.computeScene({width:l,height:c}),!f.scales||0===f.scene.length)return t&&(t.evidence=hp({frameType:"ordinal",width:r[0],height:r[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,extraWarnings:f.scales?[]:["NO_SCALES"]})),Vp.renderToStaticMarkup(Gp(null,{width:r[0],height:r[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${o.left},${o.top})`,innerWidth:l,innerHeight:c,idPrefix:e._idPrefix}));const p=e._idPrefix,y=e.showGrid?function(e,t,n,r,o){const i=e.scales;if(!i||"radial"===i.projection)return null;const{grid:s}=ju(n),a=r?r+"-":"",l="vertical"===i.projection,c=Ps(i.r,5,o);return(0,Dp.jsx)("g",l?{id:a+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,n)=>{const r=i.r(e);return(0,Dp.jsx)("line",{x1:0,y1:r,x2:t.width,y2:r,stroke:s,strokeWidth:.5},"gr-"+n)})}:{id:a+"grid",className:"semiotic-grid",opacity:.8,children:c.map((e,n)=>{const r=i.r(e);return(0,Dp.jsx)("line",{x1:r,y1:0,x2:r,y2:t.height,stroke:s,strokeWidth:.5},"gr-"+n)})})}(f,{width:l,height:c},n,p,e.axisExtent):null;let g=null;if(f.scene.some(e=>"rect"===e.type&&e.datum?.__barFunnelIsDropoff)){const t=Ip(e),r=new Set;for(const e of f.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&r.add("string"==typeof e.style.fill?e.style.fill:"#666");g=Array.from(r).map((e,r)=>function(e){const{id:t,background:n="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:i=6,angle:s=45}=e,a=Math.max(8,Math.ceil(2*i));return(0,xy.jsxs)("pattern",{id:t,width:a,height:a,patternUnits:"userSpaceOnUse",patternTransform:0!==s?`rotate(${s})`:void 0,children:[n&&"transparent"!==n&&(0,xy.jsx)("rect",{width:a,height:a,fill:n}),(0,xy.jsx)("line",{x1:0,y1:0,x2:0,y2:a,stroke:r,strokeWidth:o}),(0,xy.jsx)("line",{x1:i,y1:0,x2:i,y2:a,stroke:r,strokeWidth:o})]},t)}({id:`funnel-hatch-${t}-${r}`,background:e,stroke:"transparent"===n.colors.background?"#fff":n.colors.background,lineWidth:1.5,spacing:5,angle:45}));const o=new Map;Array.from(r).forEach((e,n)=>o.set(e,`funnel-hatch-${t}-${n}`));for(const e of f.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&(e.style={...e.style,fill:`url(#${o.get("string"==typeof e.style.fill?e.style.fill:"#666")})`})}const m=ac({nodes:f.scene,renderMode:e.renderMode,fallback:(e,t)=>pa(e,t,p)}),x=m.map(e=>e.element);if(t){const n=f.scales.o?.domain?.();t.evidence=hp({frameType:"ordinal",width:r[0],height:r[1],marks:m.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,yDomain:up(f.scales.r?.domain?.()),categories:Array.isArray(n)?n.map(String):void 0})}const b=!1!==e.showAxes?function(e,t,n,r,o){const i=e.scales;if(!i)return null;if("radial"===i.projection)return null;const s=ju(r),a="vertical"===i.projection,l=n.categoryFormat||n.oFormat,c=n.valueFormat||n.rFormat,u=n.categoryLabel||n.oLabel,h=n.valueLabel||n.rLabel,d=Object.values(e.columns).map(e=>({pixel:e.middle,label:(l||String)(e.name)})),f=Ps(i.r,5,n.axisExtent).map(e=>({pixel:i.r(e),label:(c||qp)(e)}));return(0,by.jsxs)("g",a?{id:(o?o+"-":"")+"axes",className:"ordinal-axes",children:[(0,by.jsx)("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:s.border,strokeWidth:1}),d.map((e,n)=>(0,by.jsxs)("g",{transform:`translate(${e.pixel},${t.height})`,children:[(0,by.jsx)("line",{y2:5,stroke:s.border,strokeWidth:1}),(0,by.jsx)("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oxtick-"+n)),u&&(0,by.jsx)("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:u}),(0,by.jsx)("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:s.border,strokeWidth:1}),f.map((e,t)=>(0,by.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,by.jsx)("line",{x2:-5,stroke:s.border,strokeWidth:1}),(0,by.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oytick-"+t)),h&&(0,by.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:h})]}:{id:(o?o+"-":"")+"axes",className:"ordinal-axes",children:[(0,by.jsx)("line",{x1:0,y1:t.height,x2:t.width,y2:t.height,stroke:s.border,strokeWidth:1}),f.map((e,n)=>(0,by.jsxs)("g",{transform:`translate(${e.pixel},${t.height})`,children:[(0,by.jsx)("line",{y2:5,stroke:s.border,strokeWidth:1}),(0,by.jsx)("text",{y:18,textAnchor:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oxtick-"+n)),h&&(0,by.jsx)("text",{x:t.width/2,y:t.height+40,textAnchor:"middle",fontSize:s.labelSize,fill:s.text,fontFamily:s.fontFamily,children:h}),(0,by.jsx)("line",{x1:0,y1:0,x2:0,y2:t.height,stroke:s.border,strokeWidth:1}),d.map((e,t)=>(0,by.jsxs)("g",{transform:`translate(0,${e.pixel})`,children:[(0,by.jsx)("line",{x2:-5,stroke:s.border,strokeWidth:1}),(0,by.jsx)("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:s.tickSize,fill:s.textSecondary,fontFamily:s.fontFamily,children:e.label})]},"oytick-"+t)),u&&(0,by.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})]})}(f,{width:l,height:c},e,n,p):null,v=e.annotations?Lp({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{o:f.scales.o,r:f.scales.r,y:"vertical"===f.scales.projection?f.scales.r:void 0},layout:{width:l,height:c},theme:n,projection:u,idPrefix:p}):null,w=Yp({props:e,categories:a,theme:n,size:r,margin:o,hasTitle:i}),k=h?o.left+l/2:o.left,S=h?o.top+c/2:o.top,A=h&&e.centerContent?(0,by.jsx)("foreignObject",{x:o.left,y:o.top,width:l,height:c,pointerEvents:"none",children:(0,by.jsx)("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:e.centerContent})}):null;return Vp.renderToStaticMarkup(Gp((0,by.jsxs)(by.Fragment,{children:[e.backgroundGraphics,y,x,b,v,e.foregroundGraphics,f.customLayoutOverlays]}),{width:r[0],height:r[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${k},${S})`,innerWidth:l,innerHeight:c,legend:w,defs:g,outerElements:A,idPrefix:e._idPrefix}))}var wy=c(require("react-dom/server"));function ky(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function Sy(e,t){var n,r=[],o=[],i=[],s={},a=[];function l(e){i[e]=!1,s.hasOwnProperty(e)&&Object.keys(s[e]).forEach(function(t){delete s[e][t],i[t]&&l(t)})}function c(e){var t,r,h=!1;for(o.push(e),i[e]=!0,t=0;a[e].length>t;t++)(r=a[e][t])===n?(u(n,o),h=!0):i[r]||(h=c(r));if(h)l(e);else for(t=0;a[e].length>t;t++){var d=s[r=a[e][t]];d||(s[r]=d={}),d[r]=!0}return o.pop(),h}function u(e,n){var o=[].concat(n).concat(e);t?t(o):r.push(o)}function h(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,r=function(e){for(var t=e.length,n=Array(t),r=Array(t),o=Array(t),i=Array(t),s=Array(t),a=Array(t),l=0;t>l;++l)n[l]=-1,r[l]=0,o[l]=!1,i[l]=0,s[l]=-1,a[l]=[];var c,u=0,h=[],d=[];function f(t){var l=[t],c=[t];for(n[t]=r[t]=u,o[t]=!0,u+=1;c.length>0;){var f=e[t=c[c.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]=r[y]=u,o[y]=!0,u+=1,l.push(y),c.push(y);break}o[y]&&(r[t]=0|Math.min(r[t],r[y])),0>s[y]||a[t].push(s[y])}i[t]=p}else{if(r[t]===n[t]){var g=[],m=[],x=0;for(p=l.length-1;p>=0;--p){var b=l[p];if(o[b]=!1,g.push(b),m.push(a[b]),x+=a[b].length,s[b]=h.length,b===t){l.length=p;break}}h.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];d.push(v)}c.pop()}}}for(l=0;t>l;++l)0>n[l]&&f(l);for(l=0;d.length>l;l++){var p=d[l];if(0!==p.length){p.sort(function(e,t){return e-t}),c=[p[0]];for(var y=1;p.length>y;y++)p[y]!==p[y-1]&&c.push(p[y]);d[l]=c}}return{components:h,adjacencyList:d}}(e),o=r.components.filter(function(e){return e.length>1}),i=1/0,s=0;o.length>s;s++)for(var a=0;o[s].length>a;a++)i>o[s][a]&&(i=o[s][a],n=s);var l=o[n];return!!l&&{leastVertex:i,adjList:e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})})}}n=0;for(var d=e.length;d>n;){var f=h(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]={}}c(n),n+=1}else n=d}return t?void 0:r}function Ay(e){return e.y0-e.y1>0?"up":"down"}function My(e,t){return t(e.source)==t(e.target)}function _y(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 Py(e){return e.target.x0-e.source.x1}function Cy(e,t){var n=Ty(e),r=Py(t)/Math.tan(n);return"up"==Ay(e)?e.y1-r:e.y1+r}function jy(e,t){var n=Ty(e),r=Py(t)/Math.tan(n);return"up"==Ay(e)?e.y1+r:e.y1-r}function Ty(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Ry(e,t){return t(e)}function Ly(e){return zy(e.source)}function $y(e){return zy(e.target)}function zy(e){return(e.y0+e.y1)/2}function Dy(e){return e.virtual?0:e.value}function Oy(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!My(e,t)?n+1:n});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!My(e,t)?r+1:r}),n+r}function Iy(e){return e.target.depth}function Ey(e,t){return e.sourceLinks.length?e.depth:t-1}function By(e,t){return e.y0-t.y0}function Fy(e,t){return t.y0-e.y0}function Ny(e,t){return e.y1-t.y1}function Wy(e,t){return t.y1-e.y1}function Yy(e,t){return Gy(e.source,t.source)||e.index-t.index}function qy(e,t){return Gy(e.target,t.target)||e.index-t.index}function Gy(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Xy(e,t){return Hy(e)==Hy(t)?"bottom"==e.circularLinkType?Fy(e,t):By(e,t):Hy(t)-Hy(e)}function Hy(e){return e.target.column-e.source.column}function Vy(e,t){return Uy(e)==Uy(t)}function Uy(e){return e.y0-e.y1>0?"up":"down"}var Ky=require("d3-array");function Zy(e,t,n,r,o){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,Ky.min)(i.links,function(e){return e.source.y0});i.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=i.links.filter(function(e){return e.circular});return l.sort(function(e,t){return t.value-e.value}),l.forEach(function(e,t){e._circularStub=t>=4}),Qy(i.links.filter(function(e){return"top"==e.circularLinkType}),t,n),Qy(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+r,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,My(e,t)&&_y(e))e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var s=e.source.column,l=e.circularLinkType,c=i.links.filter(function(e){return e.source.column==s&&e.circularLinkType==l});c.sort("bottom"==e.circularLinkType?Fy:By);var u=0;c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),s=e.target.column,(c=i.links.filter(function(e){return e.target.column==s&&e.circularLinkType==l})).sort("bottom"==e.circularLinkType?Wy:Ny),u=0,c.forEach(function(t,o){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=r+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=r+e._circularWidth/2+o*n+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(i.y1,e.source.y1,e.target.y1)+o+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=a-o-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,n=e.y0,r=e.target.x0,o=e.y1,i=(t+r)/2;return"M"+t+","+n+"C"+i+","+n+" "+i+","+o+" "+r+","+o}(e)}),i}function Qy(e,t,n){e.sort(Xy);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var i=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(My(e,t)&&_y(e))e.circularPathData.verticalBuffer=i+e._circularWidth/2;else{for(var s=0;r.length>s;s++){var a=r[s];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&Jy(e,a)){var l=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;i=l>i?l:i}}e.circularPathData.verticalBuffer=i+e._circularWidth/2}}),e}function Jy(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}var eg=require("d3-array");function tg(e){return function(){return e}}function ng(e){return e.index}function rg(e){return e.nodes}function og(e){return e.links}function ig(e,t,n){var r=(0,eg.groups)(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});r.forEach(function(o,i){var s=o.length;if(t)o.sort(t);else if(i>0){var a=new Map;o.forEach(function(e,t){var n,r,o,i=(r=0,o=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=zy(e.source)*t,r+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=zy(e.target)*t,r+=t}}),r>0?o/r:NaN);a.set(e,{bc:i,idx:t})}),o.sort(function(e,t){var n=a.get(e),r=a.get(t),o=n.bc,i=r.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(i)?isNaN(o)?isNaN(i)?n.idx-r.idx:1:-1:o-i})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Oy(t,n)-Oy(e,n):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});o.forEach(function(t,o){t.depth==r.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==Oy(t,n)?(t.y0=e.y1/2+o,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+o,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-o,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+o,t.y1=t.y0+t.value*e.ky)})})}function sg(e,t,n,r,o,i){var s=(0,eg.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,l=i;l>0;--l)c(a*=.99,n),u();function c(t,n){var r=s.length;s.forEach(function(o){var i=o.length,s=o[0].depth;o.forEach(function(o){var a;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Oy(o,n)>0){var l=(0,eg.mean)(o.sourceLinks,$y),c=(0,eg.mean)(o.targetLinks,Ly),u=l&&c?(l+c)/2:l||c;if(u){var h=(u-zy(o))*t*.3;o.y0+=h,o.y1+=h}}else if(0==s&&1==i)o.y0=e.y1/2-(a=o.y1-o.y0)/2,o.y1=e.y1/2+a/2;else if(s==r-1&&1==i)o.y0=e.y1/2-(a=o.y1-o.y0)/2,o.y1=e.y1/2+a/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)a=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+a;else{var d=(0,eg.mean)(o.sourceLinks,$y),f=(0,eg.mean)(o.targetLinks,Ly),p=((d&&f?(d+f)/2:d||f)-zy(o))*t;o.y0+=p,o.y1+=p}})})}function u(){s.forEach(function(n){var i,s,a,l=e.y0,c=n.length;for(n.sort(t||Gy),a=0;c>a;++a)(s=l-(i=n[a]).y0)>0&&(i.y0+=s,i.y1+=s),l=i.y1+r;if((s=l-r-e.y1)>0)for(l=i.y0-=s,i.y1-=s,a=c-2;a>=0;--a)(s=(i=n[a]).y1+o-l)>0&&(i.y0-=s,i.y1-=s),l=i.y0})}}function ag(e){e.nodes.forEach(function(e){e.sourceLinks.sort(qy),e.targetLinks.sort(Yy)}),e.nodes.forEach(function(e){var t=e.y0,n=t,r=e.y1,o=r;e.sourceLinks.forEach(function(e){e.circular?(e.y0=r-e.width/2,r-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=o-e.width/2,o-=e.width):(e.y1=n+e.width/2,n+=e.width)})})}function lg(){var e=0,t=0,n=1,r=1,o=24,i=8,s=null,a=ng,l=Ey,c=void 0,u=32,h=2,d=rg,f=og;function p(){var p={nodes:d.apply(null,arguments),links:f.apply(null,arguments)};return function(d){d.x0=e,d.y0=t,d.x1=n,d.y1=r,d.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,eg.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 r=e.source,o=e.target;"object"!=typeof r&&(r=e.source=ky(n,r)),"object"!=typeof o&&(o=e.target=ky(n,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(d,a),function(e,t){var n=0;if(null==t){for(var r=[],o=0;e.links.length>o;o++){var i=e.links[o],s=i.source.index,a=i.target.index;r[s]||(r[s]=[]),r[a]||(r[a]=[]),-1===r[s].indexOf(a)&&r[s].push(a)}var l=Sy(r);l.sort(function(e,t){return e.length-t.length});var c={};for(o=0;l.length>o;o++){var u=l[o].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,r=e.source.index;t===r||c[r]&&c[r][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++)})}(d,c),function(e,t){var n=0,r=0;e.links.forEach(function(o){o.circular&&(o.circularLinkType=o.source.circularLinkType||o.target.circularLinkType?o.source.circularLinkType?o.source.circularLinkType:o.target.circularLinkType:r>n?"top":"bottom","top"==o.circularLinkType?n++:r++,e.nodes.forEach(function(e){Ry(e,t)!=Ry(o.source,t)&&Ry(e,t)!=Ry(o.target,t)||(e.circularLinkType=o.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),My(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(d,a),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max((0,eg.sum)(e.sourceLinks,Dy),(0,eg.sum)(e.targetLinks,Dy)),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)})})}(d),function(e,t,n){var r,o,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(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.depth=i,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(r=e.nodes,o=[],i=0;r.length;++i,r=o,o=[])r.forEach(function(e){e.height=i,e.targetLinks.forEach(function(e){0>o.indexOf(e.source)&&!e.circular&&o.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?n(e,i):e.column})}(d,c,l);var f=i;if(null!==s){var p=(0,eg.groups)(d.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=(0,eg.max)(p,function(e){return e.length});y>1&&(f=Math.max(1,(r-t)*s/(y-1)))}(function(e,t,n){var r=(0,eg.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 o=(0,eg.min)(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/(0,eg.sum)(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var i=(0,eg.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})})(d,f,o),ig(d,c,a),sg(d,c,a,f,f,u),ag(d),Zy(d,a,h,10,8),ig(d,c,a),sg(d,c,a,f,f,u),ag(d),Zy(d,a,h,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 r=n.links.filter(function(n){return Ry(n.source,t)==Ry(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Vy(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=Cy(t,e);return e.y1-n}if(t.target.column>e.target.column)return Cy(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;r.forEach(function(e){e.y0=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,s=0;o>i;i++)s+=r[i].width;t.y0=e.y1-s-t.width/2}})})}(d,a),function(e,t){let n=e;n.nodes.forEach(function(e){var r=n.links.filter(function(n){return Ry(n.target,t)==Ry(e,t)}),o=r.length;o>1&&r.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Vy(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=jy(t,e);return e.y0-n}if(t.source.column>e.source.column)return jy(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;r.forEach(function(e){e.y1=i+e.width/2,i+=e.width}),r.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var i=n+1,s=0;o>i;i++)s+=r[i].width;t.y1=e.y1-s-t.width/2}})})}(d,a),function(e){var t=e.nodes,n=e.links,r=!1,o=!1;if(n.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==r||0==o){let r=function(t){return(t-i)/(s-i)*(e.y1-e.y0)+e.y0};var i=(0,eg.min)(t,function(e){return e.y0}),s=(0,eg.max)(t,function(e){return e.y1}),a=(e.y1-e.y0)/(s-i);1>a?(t.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1)}),n.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1),e.width=e.width*a})):t.forEach(function(e){var t=e.y1-e.y0,n=r(e.y0)-e.y0;e.y0=r(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})})}}(d),Zy(d,a,h,10,8)}(p),p}return p.update=function(e){return ag(e),Zy(e,a,h,10,8),e},p.nodeWidth=function(e){return arguments.length?(o=+e,p):o},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?(d="function"==typeof e?e:tg(e),p):d},p.links=function(e){return arguments.length?(f="function"==typeof e?e:tg(e),p):f},p.nodeId=function(e){return arguments.length?(a="function"==typeof e?e:tg(e),p):a},p.nodeAlign=function(e){return arguments.length?(l="function"==typeof e?e:tg(e),p):l},p.nodeSort=function(e){return arguments.length?(c=e,p):c},p.iterations=function(e){return arguments.length?(u=+e,p):u},p.circularLinkGap=function(e){return arguments.length?(h=+e,p):h},p.extent=function(o){return arguments.length?(e=+o[0][0],t=+o[0][1],n=+o[1][0],r=+o[1][1],p):[[e,t],[n,r]]},p.size=function(o){return arguments.length?(e=t=0,n=+o[0],r=+o[1],p):[n-e,r-t]},p}var cg=require("d3-interpolate"),ug=(require("d3-shape"),.5),hg=e=>{let t,n,r,o,i,s,a,l,c;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,i=e.source.x1,s=e.target.x0,a=(0,cg.interpolateNumber)(i,s),l=a(ug),c=a(.5),`M${t},${i}C${t},${l} ${n},${c} ${n},${s}L${r},${s}C${r},${c} ${o},${l} ${o},${i}Z`;const u=e.sankeyWidth/2,h=(0,cg.interpolateNumber)(e.source.x1,e.target.x0),{pathD:d}=Fh({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:h(ug),cp2X:h(.5)});return d};function dg(e){const t=e.sankeyWidth/2,n=(e._circularWidth??e.sankeyWidth)/2,r=e.circularPathData;if(!r)return null;if("down"===e.direction)return null;if(e._circularStub){const n=r.sourceX,o=r.sourceY,i=r.targetX,s=r.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*(r.rightFullExtent-n))),l=Math.max(15,Math.min(40,.33*(i-r.leftFullExtent)));return`M${n},${o-t}L${n+a},${o-t}L${n+a},${o+t}L${n},${o+t}ZM${i},${s-t}L${i-l},${s-t}L${i-l},${s+t}L${i},${s+t}Z`}const o=r.sourceX,i=r.sourceY,s=r.targetX,a=r.targetY,l=r.rightFullExtent,c=r.leftFullExtent,u=r.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,d=Math.max(4,Math.min(n,15));return`M${o},${i-h*t}L${l},${i-h*t}L${l+n},${i-h*t+h*d}L${l+n},${u+h*n-h*d}L${l+n-d},${u+h*n}L${c-n+d},${u+h*n}L${c-n},${u+h*n-h*d}L${c-n},${a-h*t+h*d}L${c-n+d},${a-h*t}L${s},${a-h*t}L${s},${a+h*t}L${c+n},${a+h*t}L${c+n},${u-h*n}L${l-n},${u-h*n}L${l-n},${i+h*t}L${o},${i+h*t}Z`}var fg=new Set,pg=new WeakMap;function yg(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=pg.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,pg.set(e,n);const r=new Proxy(e,{get(e,n,r){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;fg.has(e)||(fg.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,r)}});return n.set(t,r),r}var gg={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(Iy))-1:0},justify:Ey};function mg(e){return"string"==typeof e?e:e.id}var xg={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o="vertical"===n.orientation?"down":"right",i=n.nodeAlign||"justify",s=n.nodeWidth??15,a=n.nodePaddingRatio??.05,l=n.iterations??100,c=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 h;h="down"===o?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];const d=lg().extent(h).links(u).nodes(c).nodeAlign(gg[i]||Ey).nodeId(e=>e.id).nodeWidth(s).iterations(l);d.nodePaddingRatio&&d.nodePaddingRatio(a),d();{let e=1/0,t=-1/0,n=1/0,o=-1/0;for(const r of c)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),n>r.y0&&(n=r.y0),r.y1>o&&(o=r.y1);for(const r of u){if(!r.circular||!r.circularPathData)continue;const i=r.circularPathData,s=(r._circularWidth??r.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>o&&(o=i.verticalFullExtent+s)}const i=t-e,s=o-n,a=r[0],l=r[1];if(i>0&&s>0&&(0>e||0>n||t>a||o>l)){const t=Math.min(a/i,l/s),r=-e*t+(a-i*t)/2,o=-n*t+(l-s*t)/2;for(const e of c)e.x0=e.x0*t+r,e.x1=e.x1*t+r,e.y0=e.y0*t+o,e.y1=e.y1*t+o;for(const e of u)if(e.y0=e.y0*t+o,e.y1=e.y1*t+o,e.width=(e.width??0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const n=e.circularPathData;n.sourceX=n.sourceX*t+r,n.targetX=n.targetX*t+r,n.sourceY=n.sourceY*t+o,n.targetY=n.targetY*t+o,n.rightFullExtent=n.rightFullExtent*t+r,n.leftFullExtent=n.leftFullExtent*t+r,n.verticalFullExtent=n.verticalFullExtent*t+o,n.rightInnerExtent=n.rightInnerExtent*t+r,n.leftInnerExtent=n.leftInnerExtent*t+r,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+o,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+o,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 c){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=mg(e.source),n=mg(e.target),r=p.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(r){r.y0=e.y0,r.y1=e.y1,r.sankeyWidth=e.width??0,r.circular=!!e.circular,r.circularPathData=e.circularPathData,r._circularWidth=e._circularWidth,r._circularStub=e._circularStub,r.path=e.path,r.circularLinkType=e.circularLinkType,r.direction=o;const i=f.get(t),s=f.get(n);i&&(r.source=i),s&&(r.target=s)}}},buildScene(e,t,n,r){const o="vertical"===n.orientation?"down":"right",i=n.nodeStyle,s=n.edgeStyle,a=n.edgeOpacity??.5,l=n.edgeColorBy||"source",c=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ne,u=new Map;e.forEach((e,t)=>{u.set(e.id,c[t%c.length])});const h=[],d=[],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 r=i?i(yg(t,"nodeStyle")):{},s={fill:r.fill||u.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity};p.set(t.id,("string"==typeof s.fill?s.fill:null)||u.get(t.id)||"#4d430c"),h.push("down"===o?{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,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";o="function"==typeof l?l(e)||o:"target"===l?p.get(r.id)||u.get(r.id)||o:p.get(t.id)||u.get(t.id)||o;const i=s?s(yg(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,r=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),s=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),l=i.fill||o;d.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-n}L${t.sourceX+r},${t.sourceY-n}L${t.sourceX+r},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:l,fillOpacity:i.fillOpacity??a,stroke:"none",opacity:i.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+r}}),d.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:l,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 c;(c=e.circular&&e.circularPathData?dg(e):hg(e),c)&&d.push({type:"bezier",pathD:c,bezierCache:e.bezier,style:{fill:i.fill||o,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,l,c;"down"===o?(a=n.y0+(n.y1-n.y0)/2,l=n.x1+14,c="start"):(r[0]/2>n.x0+e/2?(a=n.x0-6,c="end"):(a=n.x1+6,c="start"),l=n.y0+i/2),f.push({x:a,y:l,text:s+"",anchor:"down"===o?"middle":c,baseline:"middle",fontSize:11})}}var g;return{sceneNodes:h,sceneEdges:d,labels:f}}},bg=require("d3-force"),vg=require("d3-scale");x();var wg={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const o=n.forceStrength??.1,i=r[0]/2,s=r[1]/2,a=Math.max(.1,Math.min(1,Math.min(r[0],r[1])/200)),l=Math.min(.5,.06+1.8*(1-a)),c=n.__previousPositions;let u=0;const h=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),n=c?.get(t.id);e?u++:n?(t.x=n.x,t.y=n.y,u++):h.push(t)}const d=u>0&&.3>=(e.length>0?h.length/e.length:1);if(d){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of h){const r=kg(e.id,t,n);if(r.length>0){let t=0,n=0;for(const e of r)t+=e.x,n+=e.y;const o=Sg(e.id),i=o%360*(Math.PI/180),s=(10+o%20)*a;e.x=t/r.length+s*Math.cos(i),e.y=n/r.length+s*Math.sin(i)}else{const t=Sg(e.id),n=t%360*(Math.PI/180),r=(15+t%30)*a;e.x=i+r*Math.cos(n),e.y=s+r*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const r=e[n];if(null==r.x||null==r.y||0===r.x&&0===r.y){const e=10*Math.sqrt(n+.5)*a,o=n*t;r.x=i+e*Math.cos(o),r.y=s+e*Math.sin(o)}}}const f=n.__skipForceSimulation||0===n.iterations?0:d?40:n.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),p=Ag(n.nodeSize,n.nodeSizeRange,e),y=e=>p(e);if(f>0){const c=new Map,u=new Map;for(const t of e)c.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;c.set(t,(c.get(t)??0)+1),c.set(n,(c.get(n)??0)+1)}const h=(0,bg.forceLink)().strength(e=>{const t=e.weight,n="string"==typeof e.target?e.target:e.target.id,r=Math.max(1,Math.min(c.get("string"==typeof e.source?e.source:e.source.id)??1,c.get(n)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*o/(.1*r))}).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,r=(t?y(t):0)+(n?y(n):0)+Math.max(6,12*a);return Math.max(16,40*a,r)}).id(e=>e.id),p=(0,bg.forceSimulation)();if(void 0===n.random&&void 0===n.seed||p.randomSource(n.random??pl(n.seed)),p.force("charge",(0,bg.forceManyBody)().strength(e=>{const t=c.get(e.id)??0;return-15*a*y(e)*Math.sqrt(t+1)})).force("collide",(0,bg.forceCollide)(e=>y(e)+3*a).strength(.9).iterations(2)).force("center",(0,bg.forceCenter)(i,s).strength(.8)).force("x",(0,bg.forceX)(i).strength(l)).force("y",(0,bg.forceY)(s).strength(l)).force("bounds",function(e,t,n=2,r=.6){let o=[];const i=i=>{const s=r*Math.max(i,.2);for(const r of o){const o=r.x??e[0]/2,i=r.y??e[1]/2,a=r.vx??0,l=r.vy??0,c=t(r)+n,u=Math.min(e[0]/2,c),h=Math.max(e[0]/2,e[0]-c),d=Math.min(e[1]/2,c),f=Math.max(e[1]/2,e[1]-c),p=o+a,y=i+l;u>p?r.vx=a+(u-p)*s:p>h&&(r.vx=a+(h-p)*s),d>y?r.vy=l+(d-y)*s:y>f&&(r.vy=l+(f-y)*s)}};return i.initialize=e=>{o=e},i}(r,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}));h.links(e),p.force("link",h)}d?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,o=Math.min(r[0]/2,e+n),i=Math.min(r[1]/2,e+n);t.x=Math.max(o,Math.min(r[0]-o,t.x)),t.y=Math.max(i,Math.min(r[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,r){const o=n.nodeStyle,i=n.edgeStyle,s=Ag(n.nodeSize,n.nodeSizeRange,e),a=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:ne,l=new Map;e.forEach((e,t)=>{l.set(e.id,a[t%a.length])});const c=[],u=[],h=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=s(yg(t,"nodeSize")),r=o?o(yg(t,"nodeStyle")):{},i={fill:r.fill||l.get(t.id)||n.themeSemantic?.primary||"#007bff",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity};c.push({type:"circle",cx:t.x,cy:t.y,r:e,style:i,datum:t,id:t.id,label:t.id})}const d=new Map;for(const t of e)d.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:d.get(e.source),r="object"==typeof e.target?e.target:d.get(e.target);if(!t||!r)continue;if(null==t.x||null==t.y)continue;if(null==r.x||null==r.y)continue;const o=i?i(yg(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:o.stroke||n.themeSemantic?.border||n.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.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 r=s(yg(n,"nodeSize"));h.push({x:n.x,y:n.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var f;return{sceneNodes:c,sceneEdges:u,labels:h}}};function kg(e,t,n){const r=[];for(const o of t){const t="string"==typeof o.source?o.source:o.source.id,i="string"==typeof o.target?o.target:o.target.id;let s=null;if(t===e?s=i:i===e&&(s=t),s){const e=n.get(s);!e||0===e.x&&0===e.y||r.push({x:e.x,y:e.y})}}return r}function Sg(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 Ag(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 r=t||[5,20],o=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&o.push(n)}if(0===o.length)return()=>r[0];const[i,s]=u(o);if(i===s)return()=>(r[0]+r[1])/2;const a=(0,vg.scaleLinear)().domain([i,s]).range(r).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?r[0]:a(n)}}var Mg=require("d3-chord"),_g=require("d3-shape"),Pg=ne,Cg={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,r){if(0===e.length)return;const{padAngle:o=.01,groupWidth:i=20,sortGroups:s}=n,a=Math.min(r[0],r[1])/2,l=a-i,c=r[0]/2,u=r[1]/2,h=(d=n.valueAccessor)?"function"==typeof d?d:e=>e[d]??1:e=>e.value??1;var d;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),r=f.get(t);if(void 0===n||void 0===r)continue;const o=h(e);y[n][r]=o}const g=(0,Mg.chord)().padAngle(o);s&&g.sortGroups(s);const m=g(y),x=m.groups,b=(0,_g.arc)().innerRadius(l).outerRadius(a);for(const t of x){const n=e[t.index],r=b.centroid({innerRadius:l,outerRadius:a,startAngle:t.startAngle,endAngle:t.endAngle});n.x=r[0]+c,n.y=r[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),r=v.get(t);n&&(e.source=n),r&&(e.target=r)}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,r=e[t.target.index].id,o=w.get(`${n}\0${r}`)||w.get(`${r}\0${n}`);o&&(o.__chordData=t)}},buildScene(e,t,n,r){const{groupWidth:o=20,edgeOpacity:i=.5}=n,s=Math.min(r[0],r[1])/2,a=s-o,l=r[0]/2,c=r[1]/2,u=n.nodeStyle,h=n.edgeStyle,d=n.edgeColorBy||"source",f=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Pg,p=new Map;e.forEach((e,t)=>{p.set(e.id,f[t%f.length])});const y=(0,Mg.ribbon)().radius(a),g=[],m=[],x=[];for(let t=0;e.length>t;t++){const n=e[t],r=n.__arcData;if(!r)continue;let o;o=u?u(yg(n,"nodeStyle")).fill||p.get(n.id)||f[t%f.length]:p.get(n.id)||f[t%f.length];const i=u?u(yg(n,"nodeStyle")):{};g.push({type:"arc",cx:l,cy:c,innerR:a,outerR:s,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:{fill:o,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 r=y(t);if(!r)continue;const o=jg(r,l,c);let s=n.themeSemantic?.border||n.themeSemantic?.secondary||"#999";if(h)s=h(yg(e,"edgeStyle")).fill||s;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===d&&n?s=p.get(n.id)||s:t&&(s=p.get(t.id)||s)}const a=h?h(yg(e,"edgeStyle")):{};m.push({type:"ribbon",pathD:o,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,r=s+12;for(const n of e){const e=n.__arcData;if(!e)continue;const o=t?t(n):n.id;if(!o)continue;const i=(e.startAngle+e.endAngle)/2,s=i-Math.PI/2;x.push({x:l+Math.cos(s)*r,y:c+Math.sin(s)*r,text:o+"",anchor:i>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var b;return{sceneNodes:g,sceneEdges:m,labels:x}}};function jg(e,t,n){const r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;const o=[];let i=0;for(;r.length>i;){const e=r[i];if("M"===e||"L"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("C"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;3>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("Q"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)for(let e=0;2>e&&r.length>i&&!isNaN(Number(r[i]));e++)o.push(Number(r[i])+t+""),i++,r.length>i&&!isNaN(Number(r[i]))&&(o.push(Number(r[i])+n+""),i++);else if("A"===e)for(o.push(e),i++;r.length>i&&!isNaN(Number(r[i]));)o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&o.push(r[i++]),r.length>i&&(o.push(Number(r[i])+t+""),i++),r.length>i&&(o.push(Number(r[i])+n+""),i++);else"Z"===e||"z"===e?(o.push(e),i++):(o.push(r[i]),i++)}return o.join(" ")}var Tg=require("d3-hierarchy"),Rg=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Lg(e){const[t,n,r]=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*r>150?"#222":"#fff"}function $g(e,t,n){const r=t.nodeIDAccessor;return"function"==typeof r?r(e.data)+"":"string"==typeof r&&void 0!==e.data[r]?e.data[r]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function zg(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 Dg(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:Rg}function Og(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 Ig(e,t,n,r,o){if("horizontal"===o){const o=(e+n)/2;return`M ${e},${t} C ${o},${t} ${o},${r} ${n},${r}`}if("radial"===o){const o=(e+n)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+r)/2} T ${n},${r}`}{const o=(t+r)/2;return`M ${e},${t} C ${e},${o} ${n},${o} ${n},${r}`}}var Eg={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;if(!o)return;const i=n.chartType,s=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),a=n.hierarchySum,l="function"==typeof a?a:"string"==typeof a?e=>Number(e[a])||0:e=>Number(e.value)||0,c=(0,Tg.hierarchy)(o,s);c.sum(l),c.sort((e,t)=>(t.value??0)-(e.value??0));const[u,h]=r;switch(i){case"tree":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=(0,Tg.tree)();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(c,n,u,h);break;case"cluster":!function(e,t,n,r){const o=t.treeOrientation||"vertical",i=(0,Tg.cluster)();i.size("horizontal"===o?[r,n]:"radial"===o?[2*Math.PI,Math.min(n,r)/2*.8]:[n,r]),i(e)}(c,n,u,h);break;case"treemap":!function(e,t,n,r){const o=t.padding??4,i=t.paddingTop??0,s=(0,Tg.treemap)().size([n,r]).tile(Tg.treemapBinary).padding(o);i>0&&s.paddingTop(i),s(e)}(c,n,u,h);break;case"circlepack":!function(e,t,n,r){const o=t.padding??4;(0,Tg.pack)().size([n,r]).padding(o)(e)}(c,n,u,h);break;case"partition":!function(e,t,n,r){(0,Tg.partition)().size([n,r]).padding(t.padding??1)(e)}(c,n,u,h)}const d=c.descendants();e.length=0,t.length=0;const f=new Map;for(let t=0;d.length>t;t++){const r=d[t],o={id:$g(r,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:r.value??0,depth:r.depth,data:r.data,createdByFrame:!0};"tree"===i||"cluster"===i?Bg(o,r,n):"treemap"===i||"partition"===i?Fg(o,r):"circlepack"===i&&Ng(o,r),o.__hierarchyNode=r,e.push(o),f.set(r,o)}if("tree"===i||"cluster"===i)for(const e of d)if(e.parent){const n=f.get(e.parent),r=f.get(e);n&&r&&t.push({source:n,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,r){const o=n.nodeStyle||(()=>({})),i=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,r,o,i){const s=[],a=[],l=[],c=n.treeOrientation||"vertical",u="radial"===c,h=r[0]/2,d=r[1]/2,f="number"==typeof(p=n.nodeSize)?p:5;var p;for(const t of e){let e=t.x,r=t.y;u&&(e+=h,r+=d);const i=o(yg(t,"nodeStyle"));let a=i.fill||Og(n);if(n.colorByDepth&&void 0!==t.depth){const e=Dg(n);a=e[t.depth%e.length]}s.push({type:"circle",cx:e,cy:r,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,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=t.x,s=t.y,l=r.x,f=r.y;u&&(o+=h,s+=d,l+=h,f+=d);const p=Ig(o,s,l,f,c),g=i(yg(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=zg(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let r,o,i,s=n.x,a=n.y;if(u&&(s+=h,a+=d),u){const e=s-h,t=a-d,n=Math.sqrt(e*e+t*t);n>0?(r=s+e/n*10,o=a+t/n*10,i=0>e?"end":"start"):(r=s,o=a-12,i="middle")}else"horizontal"===c?(n.data?.children&&0!==n.data.children.length?(r=s-f-6,i="end"):(r=s+f+6,i="start"),o=a):(r=s,o=a+f+14,i="middle");l.push({x:r,y:o,text:e+"",anchor:i,baseline:"middle",fontSize:11})}}return{sceneNodes:s,sceneEdges:a,labels:l}}(e,t,n,r,o,i);case"treemap":case"partition":return function(e,t,n,r){const o=[],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=r(yg(n,"nodeStyle"));let a=s.fill||Og(t);if(t.colorByDepth&&void 0!==n.depth){const e=Dg(t);a=e[n.depth%e.length]}o.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=zg(t.nodeLabel),o=t.labelMode||"leaf",s="partition"===t.chartType;for(const a of e){const e=a.x1-a.x0,l=a.y1-a.y0;if(0>=e||0>=l)continue;const c=!(a.data?.children&&a.data.children.length>0);if(!s){if("leaf"===o&&!c)continue;if("parent"===o&&c)continue}const u=n?n(a):a.id;if(!u)continue;if((c?30:40)>e||(c?16:14)>l)continue;let h=r(yg(a,"nodeStyle")).fill||Og(t);if(t.colorByDepth&&void 0!==a.depth){const e=Dg(t);h=e[a.depth%e.length]}const d="string"==typeof h?Lg(h):t.themeSemantic?.text??"#000";i.push(c?{x:a.x0+e/2,y:a.y0+l/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,l)/6)),fill:d}:{x:a.x0+4,y:a.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:d})}}return{sceneNodes:o,sceneEdges:[],labels:i}}(e,n,0,o);case"circlepack":return function(e,t,n,r){const o=[],i=[];for(const n of e){const e=n.__radius??5;if(0>=e)continue;const i=r(yg(n,"nodeStyle"));let s=i.fill||Og(t);if(t.colorByDepth&&void 0!==n.depth){const e=Dg(t);s=e[n.depth%e.length]}o.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=zg(t.nodeLabel);for(const o of e){const e=o.__radius??5,s=n?n(o):o.id;if(!s)continue;if(15>e)continue;const a=!(o.data?.children&&o.data.children.length>0);let l=r(yg(o,"nodeStyle")).fill||Og(t);if(t.colorByDepth&&void 0!==o.depth){const e=Dg(t);l=e[o.depth%e.length]}if(a){const n="string"==typeof l?Lg(l):t.themeSemantic?.text??"#000";i.push({x:o.x,y:o.y,text:s+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:n})}else i.push({x:o.x,y:o.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:o,sceneEdges:[],labels:i}}(e,n,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Bg(e,t,n){const r=n.treeOrientation||"vertical";if("radial"===r){const n=t.x,r=t.y;e.x=r*Math.cos(n-Math.PI/2),e.y=r*Math.sin(n-Math.PI/2)}else"horizontal"===r?(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 Fg(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 Ng(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 Wg=require("d3-shape");function Yg(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}var qg={sankey:xg,force:wg,chord:Cg,tree:Eg,cluster:Eg,treemap:Eg,circlepack:Eg,partition:Eg,orbit:{supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,r){const o=n.__hierarchyRoot;o&&function(e,t,n,r,o){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),l=n.orbitSize??2.95,c=n.orbitEccentricity??1,u="number"==typeof l?()=>l:l,h="number"==typeof c?()=>c:c,d=Yg(n);d.metaMap.clear(),r.length=0,o.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));r.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}),d.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,l,c,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,Wg.pie)().value(e=>{const t=i(e)?.length;return t?4:1}).sort(null)(w),P=h(A);for(let t=0;w.length>t;t++){const i=(_[t].startAngle+_[t].endAngle)/2,a=w[t],u=p(s(a)),h=l+M*Math.sin(i),f=c+M*Math.cos(i)*P;r.push({id:u,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:y,data:a}),d.metaMap.set(u,{ring:M,angle:i,depth:y,parentId:n,eccentricity:P}),o.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(a,u,h,f,M,y+1,!0)}k+=v}}(e,x,y,g,m,1,!1)}(o,r,n,e,t)},buildScene(e,t,n,r){const o=n.nodeStyle,i=n.nodeSize,s="number"==typeof i?()=>i:"function"==typeof i?i:()=>6,a=[],l=[],c=[];if(!1!==n.orbitShowRings){const t=Yg(n),r=new Map;for(const t of e)r.set(t.id,t);const o=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=r.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;o.has(n)||o.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:r}]of o)for(let o=0;i>o;o++){const a=o/i*Math.PI*2,c=(o+1)/i*Math.PI*2;l.push({type:"line",x1:e+n*Math.sin(a),y1:t+n*Math.cos(a)*r,x2:e+n*Math.sin(c),y2:t+n*Math.cos(c)*r,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=s(yg(t,"nodeSize")),r=o?o(yg(t,"nodeStyle")):{};a.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:r.fill||n.themeSemantic?.primary||"#6366f1",stroke:r.stroke||n.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.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&&l.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(yg(n,"nodeSize"));if(4>=e)continue;const r="function"==typeof t?t(n):t?n.data?.[t]??n.id:n.id;c.push({x:n.x,y:n.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:a,sceneEdges:l,labels:c}},tick:(e,t,n,r,o)=>!1!==n.orbitAnimated&&(function(e,t){const n=Yg(t),r=t.orbitSpeed??.25,o=t.orbitRevolution??function(e){switch(e){case"decay":return e=>Math.pow(.6,e.depth??0);case"alternate":return e=>{const t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),i=(("undefined"!=typeof performance?performance.now():Date.now())-n.startTime)/1e3,s=r*(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 r=a.get(e.parentId);if(!r)continue;const l=e.angle+i*s*o({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=r.x+e.ring*Math.sin(l),t.y=r.y+e.ring*Math.cos(l)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)}},Gg=require("react/jsx-runtime");function Xg(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}var Hg=new Set(["tree","cluster","treemap","circlepack","partition"]);function Vg(e,t){const n=Cu(e.theme),r=e.chartType||"force",o=()=>hp({frameType:"network",width:i[0],height:i[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,nodeCount:0,edgeCount:0}),i=e.size||[500,500],s=Bs({top:20,right:20,bottom:20,left:20,...e.margin},e.title),a=Is(e.title),l=e.showLegend?(()=>{const t="string"==typeof(n=e.colorBy)||"function"==typeof n?e.colorBy:void 0;var n;if(!t)return[];const r=Z(e.nodes||[]);if(r.length>0)return Ap(r,t);const o=Array.isArray(e.edges)?Z(e.edges):[];if(0===o.length)return[];const i=Xg(e.sourceAccessor,"source"),s=Xg(e.targetAccessor,"target");return Ap(Array.from(new Set(o.flatMap(e=>[i(e),s(e)]).filter(e=>null!=e).map(String))).map(e=>({id:e})),t)})():[];Wp(s,{props:e,categories:l,theme:n,size:i,hasTitle:a});const c=i[0]-s.left-s.right,u=i[1]-s.top-s.bottom,h=function(e){return qg[e]}(r);if(!h&&!e.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${r}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition.`);const d={chartType:r,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(Hg.has(r)){const r=e.data||e.edges;if(!r||Array.isArray(r))return t&&(t.evidence=o()),wy.renderToStaticMarkup(Gp(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:c,innerHeight:u,idPrefix:e._idPrefix}));d.__hierarchyRoot=r,f=[],p=[]}else{const r=Z(e.nodes||[]),a=Array.isArray(e.edges)?Z(e.edges):[];if(0===r.length&&0===a.length)return t&&(t.evidence=o()),wy.renderToStaticMarkup(Gp(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:c,innerHeight:u,idPrefix:e._idPrefix}));if(p=function(e,t){const n=Xg(t.sourceAccessor,"source"),r=Xg(t.targetAccessor,"target"),o=Xg(t.valueAccessor,"value");return e.map(e=>({source:n(e)+"",target:r(e)+"",value:Number(o(e))||1,y0:0,y1:0,sankeyWidth:0,data:e}))}(a,d),0===r.length&&p.length>0){const e=new Set;for(const t of p){const n=Op(t.source),r=Op(t.target);n&&e.add(n),r&&e.add(r)}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=Xg(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}))}(r,d)}let y=[],g=[],m=[],x=null;if(d.customNetworkLayout){const e=d.colorScheme,t=Xf(e,n.colors.categorical,ne),r=Hf(t,e),o={nodes:f,edges:p,dimensions:{width:c,height:u,plot:{x:0,y:0,width:c,height:u}},theme:{semantic:n.colors,categorical:[...t]},resolveColor:r,config:d.layoutConfig??{}},i=d.customNetworkLayout(o);y=i.sceneNodes??[],g=i.sceneEdges??[],m=i.labels??[],x=i.overlays??null}else if(h){h.computeLayout(f,p,d,[c,u]);const e=h.buildScene(f,p,d,[c,u]);y=e.sceneNodes,g=e.sceneEdges,m=e.labels}const b=ju(n);for(const e of m)e.fill||(e.fill=b.text);const v=ac({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:Zs(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:Zs(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:Zs(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=ac({nodes:y,renderMode:e.renderMode,fallback:(e,t)=>function(e,t){switch(e.type){case"circle":{const n=e,r=Vr(n.style.fill)?Zr(n.style.fill,`net-circle-${t}-hatch`):void 0;return(0,oa.jsxs)(na.Fragment,{children:[r&&(0,oa.jsx)("defs",{children:r}),(0,oa.jsx)("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:r?`url(#net-circle-${t}-hatch)`:Zs(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-circle-"+t)}case"rect":{const n=e,r=Vr(n.style.fill)?Zr(n.style.fill,`net-rect-${t}-hatch`):void 0;return(0,oa.jsxs)(na.Fragment,{children:[r&&(0,oa.jsx)("defs",{children:r}),(0,oa.jsx)("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:r?`url(#net-rect-${t}-hatch)`:Zs(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-rect-"+t)}case"arc":{const n=e,r=(0,ra.arc)().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(Ks)||"",o=Vr(n.style.fill)?Zr(n.style.fill,`net-arc-${t}-hatch`):void 0;return(0,oa.jsxs)(na.Fragment,{children:[o&&(0,oa.jsx)("defs",{children:o}),(0,oa.jsx)("path",{d:r,transform:`translate(${n.cx},${n.cy})`,fill:o?`url(#net-arc-${t}-hatch)`:Zs(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity})]},"net-arc-"+t)}case"symbol":{const n=e,r=mn(n.symbolType,n.size,n.path);return(0,oa.jsx)("path",{d:r,transform:n.rotation?`translate(${n.cx},${n.cy}) rotate(${180*n.rotation/Math.PI})`:`translate(${n.cx},${n.cy})`,fill:n.style.fill?Zs(n.style.fill):"none",stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-symbol-"+t)}case"glyph":return Js(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t)});t&&(t.evidence=hp({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}));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?Lp({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{},layout:{width:c,height:u},theme:n,idPrefix:e._idPrefix}):null,_=Yp({props:e,categories:l,theme:n,size:i,margin:s,hasTitle:a});return wy.renderToStaticMarkup(Gp((0,Gg.jsxs)(Gg.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:c,innerHeight:u,legend:_,idPrefix:e._idPrefix}))}var Ug=c(require("react-dom/server")),Kg=require("d3-geo"),Zg=require("d3-quadtree"),Qg=require("d3-geo"),Jg={mercator:Qg.geoMercator,equalEarth:Qg.geoEqualEarth,albersUsa:Qg.geoAlbersUsa,orthographic:Qg.geoOrthographic,naturalEarth:Qg.geoNaturalEarth1,equirectangular:Qg.geoEquirectangular};function em(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function tm(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function nm(e,t,n){return e?"function"==typeof e?{...n,...e(t)}:{...n,...e}:{...n}}function rm(e,t){if(2>e.length)return[e];const n=.4*t,r=[];let o=[e[0]];for(let t=1;e.length>t;t++){const i=e[t];Math.abs(i[0]-e[t-1][0])>n?(2>o.length||r.push(o),o=[i]):o.push(i)}return 2>o.length||r.push(o),r}function om(e,t,n=24){const r=t[0]-e[0],o=t[1]-e[1],i=Math.sqrt(r*r+o*o);if(0===i)return[e,t];const s=-o/i,a=r/i,l=Math.min(.3*i,80),c=(e[0]+t[0])/2+s*l,u=(e[1]+t[1])/2+a*l,h=[];for(let r=0;n>=r;r++){const o=r/n,i=1-o;h.push([i*i*e[0]+2*i*o*c+o*o*t[0],i*i*e[1]+2*i*o*u+o*o*t[1]])}return h}function im(e,t){if(2>e.length)return e;const n=t/2+1,r=[];for(let t=0;e.length>t;t++){const o=e[t];let i,s;0===t?(i=e[1][0]-o[0],s=e[1][1]-o[1]):t===e.length-1?(i=o[0]-e[t-1][0],s=o[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;r.push([o[0]+s/a*n,o[1]+-i/a*n])}return r}function sm(e,t,n,r,o){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 l=s/a,c=-i/a,u=o/2+1;return[[e[0]+l*u,e[1]+c*u],[t[0]+l*u,t[1]+c*u]]}var am=require("d3-scale");x();var lm=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],cm=["scene-style","data-paint","accessibility","evidence"],um=(e,t)=>({retainedData:e,invalidations:t}),hm=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],dm=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],fm=["scene-geometry","data-paint","accessibility","evidence"],pm=["scene-style","data-paint","accessibility","evidence"],ym=["overlay","accessibility","evidence"],gm=[],mm={xAccessor:um("rebuild",hm),yAccessor:um("rebuild",hm),lineDataAccessor:um("rebuild",hm),pointIdAccessor:um("rebuild",fm),lineIdAccessor:um("rebuild",fm),windowSize:um("rebuild",hm),projection:um("preserve",dm),projectionExtent:um("preserve",dm),fitPadding:um("preserve",dm),lineType:um("preserve",dm),flowStyle:um("preserve",dm),graticule:um("preserve",dm),projectionTransform:um("preserve",dm),customLayout:um("preserve",dm),layoutConfig:um("preserve",dm),layoutMargin:um("preserve",dm),areaStyle:um("preserve",pm),pointStyle:um("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:um("preserve",pm),colorScheme:um("preserve",pm),themeCategorical:um("preserve",pm),themeDiverging:um("preserve",pm),themeSemantic:um("preserve",pm),themeSequential:um("preserve",pm),decay:um("preserve",pm),pulse:um("preserve",pm),layoutSelection:um("preserve",pm),annotations:um("preserve",ym),autoPlaceAnnotations:um("preserve",ym),clock:um("preserve",gm),transition:um("preserve",gm),introAnimation:um("preserve",gm),onLayoutError:um("preserve",gm)},xm=um("preserve",dm),bm=class{constructor(){this.tracker=new Xn}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}},lm)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},cm):this.recordNoop("restyle")}recordConfig(e,t={}){const n=function(e){let t="preserve";const n=new Set;for(const r of e){const e=mm[r]??xm;"rebuild"===e.retainedData&&(t="rebuild");for(const t of e.invalidations)n.add(t)}return{retainedData:t,invalidations:n}}(e),r=new Set(n.invalidations);return t.retainedDataChanged&&r.add("data"),this.tracker.record({kind:"config",keys:e},r)}},vm=require("d3-geo");function wm(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 km=class e{constructor(e){this.updateResults=new bm,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:wm(e.fitPadding)}}(e)}currentTime(){return this.config.clock?.()??Yt()}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()??[],r=t.slice(-e),o=n.slice(-r.length),i=this.currentTime();this.pointBuffer=new Tt(e),this.timestampBuffer=new Tt(e),r.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(o[t]??i)})}this.retainNewestLines(e)}updateConfig(e){const t=function(e){return"fitPadding"in e?{...e,fitPadding:wm(e.fitPadding)}:e}(e),n=this.config,r=this.getConfiguredWindowSize(),o=Object.keys(t).filter(e=>t[e]!==n[e]);this.config={...this.config,...t};const i=this.getConfiguredWindowSize(),s=this.streaming&&i!==r;s&&(this.resizeStreamingWindow(i),this.version++),"customLayout"in t&&!t.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(o,{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,r=this.timestampBuffer?.toArray()??[],o=n.slice(-t),i=r.slice(-o.length),s=this.currentTime();this.pointBuffer=new Tt(t),this.timestampBuffer=new Tt(t),o.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],r=new Set(Array.isArray(e)?e:[e]),o=[];return this.lineData=this.lineData.filter(e=>!r.has(n(e)+"")||(o.push(e),!1)),o.length>0?(this.version++,this.updateResults.recordData("remove",o.length)):this.updateResults.recordNoop("remove"),o}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],r=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){const e=e=>r.has(n(e)+"");zn(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=>!r.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 r=this._baseStyles.get(n)??n.style,o=t(n,e);n.style=o?{...r,...o}:r}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(e){const{config:t}=this,n=this.projection,r=this.geoPath,o=this.scales,i=this.baseScale,s=[...this.baseTranslate],a=[...this.baseRotation],l=this.scene;this.projection=function(e){if(!e)return(0,Qg.geoEqualEarth)();if("string"==typeof e){const t=Jg[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),(0,Qg.geoEqualEarth)())}if("object"==typeof e&&"type"in e){const t=Jg[e.type],n=t?t():(0,Qg.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,Kg.geoPath)(this.projection),this.fitProjection(e),this.geoPath=(0,Kg.geoPath)(this.projection);const c=this.projection;this.scales={projection:c,geoPath:this.geoPath,projectedPoint:(e,t)=>c([e,t]),invertedPoint:(e,t)=>c.invert?c.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;const u=this.buildSceneNodes(e);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=n,this.geoPath=r,this.scales=o,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,r=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:n}));r.length>0&&this.startTransition(r)}this._hasRenderedOnce=!0,t.transition&&l.length>0&&this.startTransition(l),this.version++}}fitProjection(e){const t=this.projection,n=this.config,r=[...this.areas],o=em(n.xAccessor,"lon"),i=em(n.yAccessor,"lat"),s=this.getPoints();if(s.length>0){const e=s.map(e=>[o(e),i(e)]);r.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}const a=tm(n.lineDataAccessor);for(const e of this.lineData){const t=a(e);if(t&&t.length>0){const e=t.map(e=>[o(e),i(e)]);r.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==r.length){if(n.projectionExtent){const[[r,o],[i,s]]=n.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[r,o],[r,s],[i,s],[i,o],[r,o]]]}})}else if(t.clipAngle&&(t.clipAngle()??0)>0){const r=n.fitPadding??0,o=Math.min(e.width,e.height);t.scale(o/2-o*r),t.translate([e.width/2,e.height/2])}else{const o=n.fitPadding??0,i=e.width*o,s=e.height*o;t.fitExtent([[i,s],[e.width-i,e.height-s]],{type:"FeatureCollection",features:r})}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 r=this.geoPath,o=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,Kg.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 l=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(i),n.translate(s),this.currentZoom=a,this.geoPath=r,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=l,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}applyZoomScale(e,t){const n=this.projection;if(!n)return;const r=this.geoPath,o=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,Kg.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 l=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(n.scale(i),n.translate(s),this.currentZoom=a,this.geoPath=r,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=l,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 r=this.geoPath,o=this.scales,i=[...n.rotate()];n.rotate(e),this.geoPath=(0,Kg.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=r,this.scales=o):(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 r=Array(n);let o=0;for(const e of this.scene)"point"===e.type&&(r[o++]=e);this._quadtree=(0,Zg.quadtree)().x(e=>e.x).y(e=>e.y).addAll(r)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}buildSceneNodes(e){this._customLayoutFailedThisBuild=!1;const{config:t}=this,n=this.projection,r=this.geoPath;if(t.customLayout&&this.scales){const n=t.layoutMargin??{top:0,right:0,bottom:0,left:0},r=Xf(t.colorScheme,t.themeCategorical,Ce),o={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:[...r]},resolveColor:Hf(r,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null};let i;try{i=t.customLayout(o)}catch(e){const n=null!==this.lastCustomLayoutResult,r=Mn("geo",e,n,this.version);this.lastCustomLayoutFailure=r,this._customLayoutFailedThisBuild=!0,"production"!==process.env.NODE_ENV&&console.error("[semiotic] geo customLayout threw:",e);try{t.onLayoutError?.(r)}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 kn({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:r,points:o,lines:i,layout:s}){const a=em(e.xAccessor,"lon"),l=em(e.yAccessor,"lat"),c=[],u=function(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(e),h=function(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(e),d=function(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(e);if(e.graticule){const t=!0===e.graticule?{}:e.graticule,r=(0,vm.geoGraticule)();t.step&&r.step(t.step);const o=n(r())||"";o&&c.push({type:"geoarea",pathData:o,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 r){const r=n(t);if(!r)continue;const o=n.centroid(t),i=n.bounds(t),s=n.area(t);c.push({type:"geoarea",pathData:r,centroid:o,bounds:i,screenArea:s,style:nm(e.areaStyle,t,u),datum:t,interactive:!0})}const f=tm(e.lineDataAccessor);for(const n of i){const r=f(n);if(!r||2>r.length)continue;let o=[];if("geo"===e.lineType){const e=Array(r.length);for(let t=0;r.length>t;t++)e[t]=[a(r[t]),l(r[t])];for(let n=0;e.length-1>n;n++){const r=e[n],i=e[n+1],s=(0,vm.geoDistance)(r,i)||0,a=Math.max(2,Math.ceil(s/(Math.PI/180))),l=(0,vm.geoInterpolate)(r,i);for(let e=0;a>=e;e++){if(n>0&&0===e)continue;const r=t(l(e/a));null!=r&&o.push(r)}}}else for(let e=0;r.length>e;e++){const n=r[e],i=t([a(n),l(n)]);null!=i&&o.push(i)}if(2>o.length)continue;const i=nm(e.lineStyle,n,h),u="number"==typeof i.strokeWidth?i.strokeWidth:1;2!==r.length||2>o.length||"arc"!==e.flowStyle?2!==r.length||2>o.length||"offset"!==e.flowStyle||(o="geo"===e.lineType?im(o,u):sm(o[0],o[o.length-1],0,0,u)):o=om(o[0],o[o.length-1]);const d=rm(o,s.width);if(d.length>1)for(const e of d)2>e.length||c.push({type:"line",path:e,style:{...i,_edgeFade:!0},datum:n});else c.push({type:"line",path:2>o.length&&d[0]||o,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 o){const r=a(n),o=l(n);if(null!=g&&(0,vm.geoDistance)([r,o],b)>g)continue;const i=t([r,o]);if(!i)continue;const s=e.pointStyle?e.pointStyle(n):{...d},u={type:"point",x:i[0],y:i[1],r:s.r||4,style:s,datum:n,pointId:p?p(n)+"":void 0};c.push(u)}return c}({config:t,projection:n,path:r,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:e})}applyCartogramTransform(e,t){const n=function(e,t,n,r){const o=e.filter(e=>"point"===e.type);if(2>o.length)return null;const i=t.strength??1;if(0===i)return null;const s=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,a="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],l=o.find(e=>e.datum&&s(e.datum)+""==t.center+"");if(!l)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;const c=l.x,u=l.y,d=h(o.map(e=>e.datum?a(e.datum):NaN).filter(e=>isFinite(e)&&e>=0),1),f=Math.min(n.width,n.height)/2,p=(0,am.scaleLinear)().domain([0,d]).range([0,f]);r>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)}for(const e of o){if(e===l)continue;if(!e.datum)continue;const t=Math.atan2(e.y-u,e.x-c),n=Math.sqrt((e.x-c)**2+(e.y-u)**2),r=a(e.datum),o=n+((isFinite(r)?p(r):n)-n)*i;e.x=c+Math.cos(t)*o,e.y=u+Math.sin(t)*o}const y=n.width/2,g=n.height/2,m=y-l.x,x=g-l.y;if(Math.abs(m)>.5||Math.abs(x)>.5)for(const e of o)e.x+=m,e.y+=x;const b={cx:y,cy:g,maxCost:d,availableRadius:f},v=e.filter(e=>"line"===e.type);if(v.length>0&&"fractional"!==t.lineMode){const e=new Map;for(const t of o)t.pointId&&e.set(t.pointId,[t.x,t.y]);for(const t of v){const n=t.datum?.source,r=t.datum?.target;if(n&&r){const o=e.get(n+""),i=e.get(r+"");o&&i&&(t.path=[o,i])}}}return b}(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 r=0;n.length>r;r++){const o=qt(e,r,t);n[r]._decayOpacity=o,n[r].style={...n[r].style,opacity:o}}}applyPulse(e=this.currentTime()){const t=this.config.pulse;if(!t||!this.timestampBuffer)return!1;const n=this.scene.filter(e=>"point"===e.type),r=this.timestampBuffer.toArray(),o=t.color||"rgba(255,255,255,0.6)",i=t.glowRadius??4;let s=!1;for(let a=0;n.length>a&&r.length>a;a++){const l=Xt(t,r[a],e);s=Ht(n[a],l,o,i)||s}return s}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&Vt(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 r=this.scene.filter(e=>"point"===e.type);let o=!1;for(const e of r)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)&&(o=!0))}for(const e of r)e.pointId&&!n.has(e.pointId)&&(e._targetOpacity=e.style?.opacity??1,e.style={...e.style,opacity:0},o=!0);o&&(this.activeTransition={startTime:this.currentTime(),duration:t})}cancelIntroAnimation(){this.activeTransition=null}advanceTransition(e){if(!this.activeTransition)return!1;const t=Nt(e,this.activeTransition),n=Ft(t),r=this.scene.filter(e=>"point"===e.type);for(const e of r){if(null!=e._targetX&&null!=e._targetY){const t=e.y;e.x=Wt(e.x,e._targetX,n),e.y=Wt(t,e._targetY,n)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*n})}if(t>=1){for(const e of r)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}};km.QUADTREE_THRESHOLD=500;var Sm=km;Wn(Sm);var Am=require("react/jsx-runtime");function Mm(e,t){const n=Cu(e.theme),r=e.size||[e.width||600,e.height||400],o=Bs({top:10,right:10,bottom:10,left:10,...e.margin},e.title),i=Is(e.title),s=Array.isArray(e.areas)?Z(e.areas):e.areas,a=Z(e.points),l=Z(e.lines),c=e.showLegend?(()=>{const t="string"==typeof(n=e.colorBy)||"function"==typeof n?e.colorBy:void 0;var n;return Ap(a.length>0?a:Array.isArray(s)&&s.length>0?"string"==typeof t?s.map(e=>({...e.properties||{},...e})):s:[],t)})():[];Wp(o,{props:e,categories:c,theme:n,size:r,hasTitle:i});const u=r[0]-(o.left??0)-(o.right??0),h=r[1]-(o.top??0)-(o.bottom??0),d={projection:e.projection||"equalEarth",xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineType:e.lineType,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform,customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:o,themeCategorical:n.colors.categorical,themeSemantic:wt(n)},f=new Sm(d);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(l),f.computeScene({width:u,height:h});const p=ac({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 r=Vr(n.style.fill)?Zr(n.style.fill,`geoarea-${t}-hatch`):void 0;return(0,sa.jsxs)(ia.Fragment,{children:[r&&(0,sa.jsx)("defs",{children:r}),(0,sa.jsx)("path",{d:n.pathData,fill:r?`url(#geoarea-${t}-hatch)`:Zs(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,r=Vr(n.style.fill)?Zr(n.style.fill,`geopoint-${t}-hatch`):void 0;return(0,sa.jsxs)(ia.Fragment,{children:[r&&(0,sa.jsx)("defs",{children:r}),(0,sa.jsx)("circle",{cx:n.x,cy:n.y,r:n.r,fill:r?`url(#geopoint-${t}-hatch)`:Zs(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 r="M"+n.path.map(e=>`${e[0]},${e[1]}`).join("L");return(0,sa.jsx)("path",{d:r,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 Js(e,e.x,e.y,"geo-glyph-"+(e.pointId??t));default:return null}}(e,t)});if(t&&(t.evidence=hp({frameType:"geo",width:r[0],height:r[1],marks:p.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,legendItems:c.length>0?c.length:void 0})),0===p.length){const t=e.backgroundGraphics||e.foregroundGraphics||e.annotations||f.customLayoutOverlays?(0,Am.jsxs)(Am.Fragment,{children:[e.backgroundGraphics,e.annotations?Lp({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:f.scales?.projectedPoint?([e,t])=>f.scales.projectedPoint(e,t):void 0},layout:{width:u,height:h},theme:n,idPrefix:e._idPrefix}):null,e.foregroundGraphics,f.customLayoutOverlays]}):null;return Ug.renderToStaticMarkup(Gp(t,{width:r[0],height:r[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${o.left??0},${o.top??0})`,innerWidth:u,innerHeight:h,idPrefix:e._idPrefix}))}const y=p.map(e=>e.element),g=e.annotations?Lp({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,scales:{geoProjection:f.scales?.projectedPoint?([e,t])=>f.scales.projectedPoint(e,t):void 0},layout:{width:u,height:h},theme:n,idPrefix:e._idPrefix}):null,m=Yp({props:e,categories:c,theme:n,size:r,margin:o,hasTitle:i});return Ug.renderToStaticMarkup(Gp((0,Am.jsxs)(Am.Fragment,{children:[e.backgroundGraphics,y,g,e.foregroundGraphics,f.customLayoutOverlays]}),{width:r[0],height:r[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:n,innerTransform:`translate(${o.left??0},${o.top??0})`,innerWidth:u,innerHeight:h,legend:m,idPrefix:e._idPrefix}))}var _m=c(require("react-dom/server"));function Pm(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 Cm={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};function jm(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 Tm(e,t){const n="function"==typeof t?t(e):t;return{...Cm,...n??{}}}function Rm(e,t={}){return e.map(e=>function(e,t={}){const n=function(e){return e.datum&&"object"==typeof e.datum?e.datum:null}(e),r={label:t.getBodyLabel?.(e)??jm(e)},o={style:Tm(e,t.bodyStyle),datum:n,accessibleDatum:n,accessibility:r,_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,...o}:{type:"point",x:e.x,y:e.y,r:e.shape.radius,pointId:e.id,...o}}(e,t))}var Lm=require("react/jsx-runtime");function $m(e,t){const n=e.size??[e.width??600,e.height??400],r=new jf(e.config);Array.isArray(e.initialSpawns)&&e.initialSpawns.length>0&&r.enqueue(e.initialSpawns.map(e=>({...e,spawnAt:void 0})));const o=function(e,t={}){const{width:n=640,height:r=360,title:o,description:i,background:s,className:a,idPrefix:l="physics",...c}=t,u=function(e,t={}){const n=e.settle(t.maxSteps),r=e.readBodies(),o=e.snapshot(),i=Rm(r,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),r=n.filter(e=>e.sleeping).length;return{bodyCount:n.length,sleepingCount:r,settled:"settled"===e.simulationState&&0===e.queue.length&&r===n.length,stepsRun:Math.max(0,Math.floor(t.stepsRun??0)),seed:e.world.options.seed,binCounts:Pm(t.projectionRows)}}(o,{bodies:r,projectionRows:t.projectionRows,stepsRun:n});return{snapshot:o,bodies:r,sceneNodes:i,evidence:s,stepsRun:n}}(e,c),h=function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"physics-"+t:t}(l),d=o?h+"-title":void 0,f=i?h+"-desc":void 0,p=[d,f].filter(Boolean).join(" ")||void 0;return{svg:_m.renderToStaticMarkup((0,Lm.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:a??"stream-physics-frame",width:n,height:r,viewBox:`0 0 ${n} ${r}`,role:"img","aria-labelledby":p,children:[o&&(0,Lm.jsx)("title",{id:d,children:o}),i&&(0,Lm.jsx)("desc",{id:f,children:i}),s&&"transparent"!==s?(0,Lm.jsx)("rect",{x:0,y:0,width:n,height:r,fill:s}):null,(0,Lm.jsx)("g",{id:h+"-data-area",children:u.sceneNodes.map((e,t)=>ma(e,t,h))})]})),scene:u,evidence:u.evidence}}(r,{...e,width:n[0],height:n[1],idPrefix:e.idPrefix??e._idPrefix??"physics"});return t&&(t.evidence=hp({frameType:"physics",width:n[0],height:n[1],marks:o.scene.sceneNodes,title:e.title,description:e.description,annotations:[],extraWarnings:0===o.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[]})),o.svg}var zm=require("react/jsx-runtime");function Dm(e,t){switch(e){case"xy":return Hp(t);case"ordinal":return vy(t);case"network":return Vg(t);case"geo":return Mm(t);case"physics":return $m(t);default:throw Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function Om(e){return Hp(e)}function Im(e){return vy(e)}function Em(e){return Vg(e)}function Bm(e){return Mm(e)}var Fm=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","scalePadding","sizeRange","innerRadius","centerContent","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","barColors","legend","legendLayout","autoPlaceAnnotations"],Nm=["width","height","showAxes","showGrid","enableHover","showLegend","showLabels","showCategoryTicks","orientation","title","description","summary","accessibleTable","xLabel","yLabel","categoryLabel","valueLabel","linkedHover","mobileInteraction","mobileSemantics","responsiveRules"];function Wm(e,t){const n={};for(const r of t)void 0!==e[r]&&(n[r]=e[r]);return n}function Ym(e,t,n){return Gm(e,t).svg}function qm(e,t,n){const r={},{svg:o,frameType:i}=Gm(e,t,0,r),s=r.evidence??hp({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:o,evidence:s}}function Gm(e,t,n,r){const o=lp[e];if(!o)throw Error(`Unknown chart component: "${e}". See CLAUDE.md for supported chart types.`);var i;const s=G(o.layout?.mode??("string"==typeof(i=t.mode)&&Object.prototype.hasOwnProperty.call(q,i)?t.mode:void 0),{...o.layout?.modeDefaults,...Wm(t,Nm)},o.layout?.primarySize),{data:a,theme:l,background:c,className:u,annotations:h,margin:d,colorScheme:f,colorBy:p,legendPosition:y,...g}=t,{width:m,height:x}=s,b=[m,x],v=g.frameProps||{},w=o.layout?.margin,k="function"==typeof w?w(t,s):w??s.marginDefaults,S=void 0!==d?d:v.margin,A=function(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}(S),M="number"==typeof S?{top:S,right:S,bottom:S,left:S}:{...k,...A},_=Wm(g,Fm),P={...v,..._,theme:l,title:s.title,description:s.description,showAxes:s.showAxes,showLegend:s.showLegend,showLabels:s.showLabels,showGrid:s.showGrid,xLabel:s.xLabel,yLabel:s.yLabel,categoryLabel:s.categoryLabel,valueLabel:s.valueLabel,background:c,className:u,annotations:h,size:b,margin:M,__explicitMargin:S,__autoLegendMargin:!0,...void 0!==f&&{colorScheme:f},...void 0!==y&&{legendPosition:y},_idPrefix:g._idPrefix},C=o.buildProps(a,p,f,P,g);let j;switch(o.frameType){case"xy":j=Hp(C,r);break;case"ordinal":j=vy(C,r);break;case"network":j=Vg(C,r);break;case"geo":j=Mm(C,r);break;case"physics":j=$m(C,r)}const T=o.renderOverlay?.(C,{theme:Cu(l)});if(null!=T){const e=H.renderToStaticMarkup((0,zm.jsx)(zm.Fragment,{children:T}));j=j.replace("</svg>",e+"</svg>")}return{svg:j,frameType:o.frameType}}async function Xm(e,t,n={}){const{format:r="png",scale:o=1,background:i}=n;let s,a;s=["xy","ordinal","network","geo","physics"].includes(e)?Dm(e,t):Ym(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 l=t.width||t.size?.[0]||600,c=t.height||t.size?.[1]||400,u=a(void 0!==globalThis.Buffer?globalThis.Buffer.from(s):(new TextEncoder).encode(s),{density:72*o}).resize(Math.round(l*o),Math.round(c*o));return"jpeg"===r?u.jpeg({quality:90}).toBuffer():u.png().toBuffer()}function Hm(e,t={}){const{title:n,subtitle:r,theme:o,width:i=1200,height:s,layout:a={},background:l}=t,c=ju(Cu(o)),u=a.columns||2,h=a.gap??16;let d=0;n&&(d+=30),r&&(d+=20),d>0&&(d+=10);const f=Math.floor((i-h-h*(u-1))/u),p=[];let y=0,g=d+h,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+h,y=0,m=0),p.push({chart:t,x:h/2+y*(f+h),y:g,w:f*e+h*(e-1),h:n}),m=Math.max(m,n),y+=e}const x=s||g+m+h,b=p.map((e,t)=>{const{chart:n,x:r,y:i,w:s,h:a}=e,l={...n.props,width:s,height:a,theme:o,_idPrefix:"chart-"+t};let c;return c=n.component?Ym(n.component,l):n.frameType?Dm(n.frameType,l):`<svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${a}"></svg>`,(0,zm.jsx)("g",{transform:`translate(${r},${i})`,children:(0,zm.jsx)("foreignObject",{width:s,height:a,children:(0,zm.jsx)("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:c}})})},"dashboard-chart-"+t)});return H.renderToStaticMarkup((0,zm.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:i,height:x,role:"img","aria-label":n||"Dashboard",style:{fontFamily:c.fontFamily},children:[n&&(0,zm.jsx)("title",{children:n}),l&&(0,zm.jsx)("rect",{x:0,y:0,width:i,height:x,fill:l}),n&&(0,zm.jsx)("text",{x:i/2,y:24,textAnchor:"middle",fontSize:c.titleSize+4,fontWeight:"bold",fill:c.text,fontFamily:c.fontFamily,children:n}),r&&(0,zm.jsx)("text",{x:i/2,y:n?46:20,textAnchor:"middle",fontSize:c.labelSize,fill:c.textSecondary,fontFamily:c.fontFamily,children:r}),b]}))}var Vm=c(require("react-dom/server")),Um=require("react/jsx-runtime");function Km(e,t,n,r={}){const{stepSize:o,windowSize:i,frameCount:s,xExtent:a,yExtent:l,transitionFrames:c=4,fps:u=12,easing:h="ease-out",decay:d}=r,f=n.width||600,p=n.height||400,y=Cu(n.theme),g={...n,...a&&{xExtent:a},...l&&{yExtent:l}};if(!t||0===t.length)return[];const m=o||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=Bs({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 r=0;x.length>r;r++){const o=x[r],s=t.slice(i?Math.max(0,o-i):0,o),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,...d&&{decay:d}},l=new my(a);l.ingest({inserts:s,bounded:!0}),l.computeScene({width:w,height:k}),l.scene.length>0&&S.push(nx(l.scene,f,p,y,g))}else for(let r=0;x.length>r;r++){const o=x[r],s=t.slice(i?Math.max(0,o-i):0,o),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:l,colorScheme:n.colorScheme||y.colors.categorical,lineStyle:n.lineStyle,pointStyle:n.pointStyle,areaStyle:n.areaStyle,sizeAccessor:n.sizeAccessor||n.sizeBy,sizeRange:n.sizeRange,...d&&{decay:d},...c>0&&{transition:{duration:c*(1e3/u),easing:h}}},b=new cr(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(tx(b.scene,f,p,y,g,v)),c>0&&r>0&&b.activeTransition){const e=c*(1e3/u);for(let t=1;c>=t;t++)b.advanceTransition(b.activeTransition.startTime+t/c*e),S.push(tx(b.scene,f,p,y,g,v))}}return S}function Zm(e,t,n={}){return t.map(t=>{try{return Ym(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 Qm(e,t,n){const r=t.size??[t.width??600,t.height??400],o=Cu(t.theme),i=ju(o),s=t.background||o.colors.background,a=t.idPrefix??"physics-gif",l=t.title?`${a}-title-${n}`:void 0,c=t.description?`${a}-desc-${n}`:void 0,u=[l,c].filter(Boolean).join(" ")||void 0,h=Rm(e.readBodies(),{bodyStyle:t.bodyStyle,getBodyLabel:t.getBodyLabel}),d=(0,Um.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className??"stream-physics-frame",width:r[0],height:r[1],viewBox:`0 0 ${r[0]} ${r[1]}`,role:"img","aria-labelledby":u,style:{fontFamily:i.fontFamily},children:[t.title&&(0,Um.jsx)("title",{id:l,children:t.title}),t.description&&(0,Um.jsx)("desc",{id:c,children:t.description}),s&&"transparent"!==s?(0,Um.jsx)("rect",{x:0,y:0,width:r[0],height:r[1],fill:s}):null,(0,Um.jsx)("g",{id:`${a}-frame-${n}`,children:h.map((e,t)=>ma(e,t,`${a}-${n}`))})]});return Vm.renderToStaticMarkup(d)}function Jm(e,t={}){const{fps:n=12,frameCount:r,durationSeconds:o=2,includeInitialFrame:i=!0,stepDt:s,stepsPerFrame:a,background:l}=t,c=Math.max(.001,s??e.config?.fixedDt??1/120),u=a??Math.max(1,Math.round(1/Math.max(1,n)/c)),h=r??Math.max(1,Math.ceil(o*Math.max(1,n))),d=l?{...e,background:l}:e,f=new jf(e.config);e.initialSpawns?.length&&f.enqueue(e.initialSpawns,e.initialSpawnPacing);const p=[];for(i&&(f.tick(0),p.push(Qm(f,d,0)));h>p.length;){for(let e=0;u>e;e+=1)f.tick(c);p.push(Qm(f,d,p.length))}return p}function ex(e,t){const n=e.background||t.colors.background;return n&&"transparent"!==n?n:null}function tx(e,t,n,r,o,i){const s=ju(r),a=Bs({top:20,right:20,bottom:30,left:40,...o.margin},o.title),l=t-a.left-a.right,c=n-a.top-a.bottom,u=ex(o,r),h=o.renderMode,d=e.map((e,t)=>sc({node:e,index:t,renderMode:h,fallback:()=>ma(e,t)})).filter(Boolean),f=function(e,t,n,r,o,i){if(!e||0===e.length)return null;const s=ju(r),a=[];for(let r=0;e.length>r;r++){const l=e[r];if("y-threshold"===l.type&&null!=l.value){let e=null;if(i)e=i(l.value);else if(o){const[t,r]=o,i=r-t;if(0===i)continue;e=n-(l.value-t)/i*n}if(null==e)continue;const c=l.color||s.primary,u=l.labelPosition||"right";a.push((0,Um.jsxs)("g",{children:[(0,Um.jsx)("line",{x1:0,y1:e,x2:t,y2:e,stroke:c,strokeWidth:l.strokeWidth??1.5,strokeDasharray:l.strokeDasharray||"6,4"}),l.label&&(0,Um.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:c,fontFamily:s.fontFamily,children:l.label})]},"ann-"+r))}}return a.length>0?(0,Um.jsx)(Um.Fragment,{children:a}):null}(o.annotations,l,c,r,o.yExtent,i?.y),p="string"==typeof o.title?o.title:void 0,y="string"==typeof o.description?o.description:void 0,g=p?"semiotic-title":void 0,m=y?"semiotic-desc":void 0,x=[g,m].filter(Boolean).join(" ")||void 0;return Vm.renderToStaticMarkup((0,Um.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,Um.jsx)("title",{id:g,children:p}),y&&(0,Um.jsx)("desc",{id:m,children:y}),u&&(0,Um.jsx)("rect",{x:0,y:0,width:t,height:n,fill:u}),(0,Um.jsxs)("g",{transform:`translate(${a.left},${a.top})`,children:[f,d]}),p&&(0,Um.jsx)("text",{x:t/2,y:Os,textAnchor:"middle",fontSize:s.titleSize,fontWeight:"bold",fill:s.text,fontFamily:s.fontFamily,children:p})]}))}function nx(e,t,n,r,o){const i=ju(r),s=Bs({top:20,right:20,bottom:30,left:40,...o.margin},o.title),a="radial"===o.projection,l=a?s.left+(t-s.left-s.right)/2:s.left,c=a?s.top+(n-s.top-s.bottom)/2:s.top,u=ex(o,r),h=o.renderMode,d=e.map((e,t)=>sc({node:e,index:t,renderMode:h,fallback:()=>pa(e,t)})).filter(Boolean),f="string"==typeof o.title?o.title:void 0,p="string"==typeof o.description?o.description:void 0,y=f?"semiotic-title":void 0,g=p?"semiotic-desc":void 0,m=[y,g].filter(Boolean).join(" ")||void 0;return Vm.renderToStaticMarkup((0,Um.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,Um.jsx)("title",{id:y,children:f}),p&&(0,Um.jsx)("desc",{id:g,children:p}),u&&(0,Um.jsx)("rect",{x:0,y:0,width:t,height:n,fill:u}),(0,Um.jsx)("g",{transform:`translate(${l},${c})`,children:d}),f&&(0,Um.jsx)("text",{x:t/2,y:Os,textAnchor:"middle",fontSize:i.titleSize,fontWeight:"bold",fill:i.text,fontFamily:i.fontFamily,children:f})]}))}async function rx(e,t,n,r={}){const{fps:o=12,loop:i=!0,scale:s=1,background:a}=r,l=n.width||600,c=n.height||400,u=Km(e,t,a?{...n,background:a}:n,r);if(0===u.length)throw Error("No frames generated — check that data is not empty");return ix(u,l,c,{fps:o,loop:i,scale:s})}async function ox(e,t={}){const{fps:n=12,loop:r=!0,scale:o=1}=t,i=e.size??[e.width??600,e.height??400],s=Jm(e,t);if(0===s.length)throw Error("No physics frames generated");return ix(s,i[0],i[1],{fps:n,loop:r,scale:o})}async function ix(e,t,n,r={}){const{fps:o=12,loop:i=!0,scale:s=1}=r,a=Math.round(t*s),l=Math.round(n*s);let c,u,h,d;try{const e="sharp",t=await import(e);c=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,h=n.quantize,d=n.applyPalette}catch(e){throw Error('Animated GIF export requires "gifenc". Install it:\n npm install gifenc',{cause:e})}const f=Math.round(1e3/o),p=u();for(let t=0;e.length>t;t++){const n=e[t],r=await c(Buffer.from(n),{density:72*s}).resize(a,l).ensureAlpha().raw().toBuffer(),o=new Uint8Array(r),u=h(o,256),y=d(o,u);p.writeFrame(y,a,l,{palette:u,delay:f,repeat:i?0:-1})}return p.finish(),Buffer.from(p.bytes())}
|