semiotic 3.10.0 → 3.10.1
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/README.md +55 -59
- package/ai/artifact-surface-inventory.json +1 -1
- package/ai/componentMetadata.cjs +3 -1
- package/ai/dist/mcp-server.js +45 -45
- package/ai/examples.md +67 -0
- package/ai/reference.md +75 -1
- package/ai/schema.json +5199 -1
- package/ai/surface-manifest.json +24 -3
- package/ai/task-packets/compare-category-totals.json +6 -6
- package/ai/task-packets/compare-category-totals.md +3 -3
- package/ai/task-packets/correct-published-chart.json +6 -6
- package/ai/task-packets/correct-published-chart.md +3 -3
- package/ai/task-packets/index.json +6 -6
- package/ai/task-packets/update-live-chart.json +6 -6
- package/ai/task-packets/update-live-chart.md +3 -3
- package/dist/c-2RL2QPZJ.min.js +1 -0
- package/dist/c-45CQWZZ6.min.js +1 -0
- package/dist/{c-PP6VY3QU.min.js → c-4BRHKVKV.min.js} +1 -1
- package/dist/c-7DVPSB5C.min.js +1 -0
- package/dist/{c-XDQKXPX4.min.js → c-A7OGOFSL.min.js} +1 -1
- package/dist/{c-AZKPVBOC.min.js → c-AH5HWZWS.min.js} +1 -1
- package/dist/c-B7GW7IHJ.min.js +1 -0
- package/dist/{c-ROEHCIGV.min.js → c-C3TZLTZK.min.js} +1 -1
- package/dist/c-CGQAQWBV.min.js +1 -0
- package/dist/c-DIPEYUOW.min.js +1 -0
- package/dist/{c-WNGH47HF.min.js → c-E72OTUZU.min.js} +1 -1
- package/dist/{c-DY2676CR.min.js → c-EUMPMDCS.min.js} +1 -1
- package/dist/c-EZZT2WAE.min.js +1 -0
- package/dist/c-FHBVFCQB.min.js +1 -0
- package/dist/{c-E32M6XW5.min.js → c-G4HCO2IQ.min.js} +1 -1
- package/dist/{c-ZYPXQF7B.min.js → c-G5VIJEOK.min.js} +1 -1
- package/dist/c-GHVOXAYH.min.js +1 -0
- package/dist/{c-EBOQ7ER7.min.js → c-HP4ZFM47.min.js} +1 -1
- package/dist/{c-IDJV3CZK.min.js → c-HYDTS5OP.min.js} +1 -1
- package/dist/c-IK33LNZ6.min.js +1 -0
- package/dist/c-IK3PZHRY.min.js +1 -0
- package/dist/{c-JO2UGTCP.min.js → c-J6DVC236.min.js} +1 -1
- package/dist/{c-MXCP7GNZ.min.js → c-JIMJF6F6.min.js} +1 -1
- package/dist/{c-4FN7Q6VQ.min.js → c-KKPMHAZC.min.js} +1 -1
- package/dist/c-L6WNDBHV.min.js +1 -0
- package/dist/c-LDEX5OFW.min.js +1 -0
- package/dist/{c-CPSPZH6A.min.js → c-LESEUVC5.min.js} +1 -1
- package/dist/c-MB6CV5NC.min.js +1 -0
- package/dist/{c-OO5QLMJC.min.js → c-MOKJOIPE.min.js} +1 -1
- package/dist/{c-BNG5ECK5.min.js → c-N3FXLRNT.min.js} +1 -1
- package/dist/c-N5NPTJVJ.min.js +1 -0
- package/dist/{c-DE5Q3U2X.min.js → c-NHBL4J67.min.js} +1 -1
- package/dist/{c-LMGSSD2E.min.js → c-ODG6TFSY.min.js} +1 -1
- package/dist/{c-HXDKPIKR.min.js → c-PSKKFZNP.min.js} +1 -1
- package/dist/{c-NYZ2QNAM.min.js → c-R2P4RR7Q.min.js} +1 -1
- package/dist/{c-KCRJGUHP.min.js → c-RFC7UAG7.min.js} +1 -1
- package/dist/c-SGAURYHG.min.js +1 -0
- package/dist/{c-DK662R77.min.js → c-SJMWU6UX.min.js} +1 -1
- package/dist/c-STIIGQOD.min.js +1 -0
- package/dist/c-T2ASIJVZ.min.js +1 -0
- package/dist/c-TX3THUTO.min.js +1 -0
- package/dist/{c-55BAJ333.min.js → c-TX7XJM3Z.min.js} +1 -1
- package/dist/c-UMXSJIOV.min.js +1 -0
- package/dist/{c-JLGRHXGZ.min.js → c-VRSXMLYF.min.js} +1 -1
- package/dist/c-VSLWSAN2.min.js +1 -0
- package/dist/{c-33QOXEUG.min.js → c-WCBRPILW.min.js} +1 -1
- package/dist/{c-WH2O53VI.min.js → c-WGHT7OCY.min.js} +1 -1
- package/dist/c-WWCW3APR.min.js +1 -0
- package/dist/c-Y6PYUMFU.min.js +1 -0
- package/dist/c-ZIVPFTOC.min.js +1 -0
- package/dist/components/charts/shared/chartDataProps.d.ts +3 -0
- package/dist/components/charts/shared/chartSpecAtlasSchemas.d.ts +5 -0
- package/dist/components/charts/shared/chartSpecCore.d.ts +4 -0
- package/dist/components/charts/shared/chartSpecsAtlas.d.ts +2 -0
- package/dist/components/charts/shared/hooks.d.ts +3 -1
- package/dist/components/charts/shared/knownChartComponents.d.ts +1 -1
- package/dist/components/recipes/atlas/DependencyForestChart.d.ts +20 -0
- package/dist/components/recipes/atlas/DependencyMatrix.d.ts +7 -0
- package/dist/components/recipes/atlas/FlowCircuitChart.d.ts +20 -0
- package/dist/components/recipes/atlas/MotifBraidChart.d.ts +17 -0
- package/dist/components/recipes/atlas/atlasChartOptions.d.ts +11 -0
- package/dist/components/recipes/atlas/braid.d.ts +62 -0
- package/dist/components/recipes/atlas/capsules.d.ts +18 -0
- package/dist/components/recipes/atlas/compare.d.ts +4 -0
- package/dist/components/recipes/atlas/completeness.d.ts +2 -0
- package/dist/components/recipes/atlas/dependencyForest.d.ts +32 -0
- package/dist/components/recipes/atlas/dependencyForestChartProps.d.ts +58 -0
- package/dist/components/recipes/atlas/dependencyForestLayout.d.ts +17 -0
- package/dist/components/recipes/atlas/dependencyQueries.d.ts +20 -0
- package/dist/components/recipes/atlas/dependencyTypes.d.ts +21 -0
- package/dist/components/recipes/atlas/directedGraph.d.ts +9 -0
- package/dist/components/recipes/atlas/entityCounts.d.ts +3 -0
- package/dist/components/recipes/atlas/flowCircuit.d.ts +32 -0
- package/dist/components/recipes/atlas/flowCircuitChartProps.d.ts +72 -0
- package/dist/components/recipes/atlas/flowCircuitChrome.d.ts +18 -0
- package/dist/components/recipes/atlas/flowCircuitGeometry.d.ts +11 -0
- package/dist/components/recipes/atlas/flowCircuitLayout.d.ts +20 -0
- package/dist/components/recipes/atlas/flowCircuitSemantics.d.ts +26 -0
- package/dist/components/recipes/atlas/flowCircuitTape.d.ts +22 -0
- package/dist/components/recipes/atlas/flowCircuitTypes.d.ts +144 -0
- package/dist/components/recipes/atlas/forests.d.ts +11 -0
- package/dist/components/recipes/atlas/ids.d.ts +6 -0
- package/dist/components/recipes/atlas/index.d.ts +26 -0
- package/dist/components/recipes/atlas/ledger.d.ts +7 -0
- package/dist/components/recipes/atlas/motifBraidChartProps.d.ts +51 -0
- package/dist/components/recipes/atlas/motifBraidGeometry.d.ts +5 -0
- package/dist/components/recipes/atlas/motifBraidLayout.d.ts +11 -0
- package/dist/components/recipes/atlas/motifs.d.ts +3 -0
- package/dist/components/recipes/atlas/prefixForest.d.ts +9 -0
- package/dist/components/recipes/atlas/prepare.d.ts +14 -0
- package/dist/components/recipes/atlas/prepareAsync.d.ts +7 -0
- package/dist/components/recipes/atlas/profile.d.ts +19 -0
- package/dist/components/recipes/atlas/publish.d.ts +10 -0
- package/dist/components/recipes/atlas/queries.d.ts +34 -0
- package/dist/components/recipes/atlas/requiredPaths.d.ts +9 -0
- package/dist/components/recipes/atlas/rootedForest.d.ts +4 -0
- package/dist/components/recipes/atlas/sections.d.ts +3 -0
- package/dist/components/recipes/atlas/support.d.ts +7 -0
- package/dist/components/recipes/atlas/types.d.ts +278 -0
- package/dist/components/recipes/atlas/validate.d.ts +12 -0
- package/dist/components/semiotic-atlas-core.d.ts +20 -0
- package/dist/components/semiotic-atlas.d.ts +8 -0
- package/dist/components/semiotic-recipes-core.d.ts +9 -0
- package/dist/components/server/serverChartConfigs.d.ts +3 -0
- package/dist/components/server/serverChartConfigsAtlas.d.ts +4 -0
- package/dist/components/stream/NetworkPipelineStore.d.ts +1 -0
- package/dist/components/stream/canvasSetup.d.ts +1 -2
- package/dist/components/stream/fontLoading.d.ts +4 -0
- package/dist/components/stream/networkCustomLayout.d.ts +8 -0
- package/dist/components/stream/networkCustomLayoutCache.d.ts +12 -0
- package/dist/components/stream/networkPipelineConfig.d.ts +0 -7
- package/dist/components/stream/physics/physicsSemanticUI.d.ts +2 -0
- package/dist/components/stream/physics/usePhysicsCanvasPointer.d.ts +3 -1
- package/dist/components/stream/physics/usePhysicsSemanticNavigation.d.ts +2 -0
- package/dist/components/stream/shallowEqual.d.ts +2 -0
- package/dist/components/stream/useEnsureCustomXYRenderers.d.ts +4 -2
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/physics.module.min.js +1 -1
- package/dist/rough.module.min.js +1 -1
- package/dist/semiotic-access.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.module.min.js +1 -1
- package/dist/semiotic-artifact.min.js +1 -1
- package/dist/semiotic-artifact.module.min.js +1 -1
- package/dist/semiotic-atlas-core.d.ts +20 -0
- package/dist/semiotic-atlas-core.min.js +1 -0
- package/dist/semiotic-atlas-core.module.min.js +1 -0
- package/dist/semiotic-atlas-selection.module.min.js +2 -0
- package/dist/semiotic-atlas.d.ts +8 -0
- package/dist/semiotic-atlas.min.js +2 -0
- package/dist/semiotic-atlas.module.min.js +2 -0
- package/dist/semiotic-client-cjs-shared.min.js +1 -1
- package/dist/semiotic-evidence.min.js +1 -1
- package/dist/semiotic-evidence.module.min.js +1 -1
- package/dist/semiotic-experimental-auxiliary.module.min.js +1 -1
- package/dist/semiotic-experimental-node-auxiliary.module.min.js +1 -1
- package/dist/semiotic-experimental-react-shared.module.min.js +1 -1
- package/dist/semiotic-experimental-vacp.min.js +1 -1
- package/dist/semiotic-experimental-vacp.module.min.js +1 -1
- package/dist/semiotic-line.module.min.js +1 -1
- package/dist/semiotic-realtime-core.module.min.js +1 -1
- package/dist/semiotic-recipes-core-cjs-base.min.js +1 -1
- package/dist/semiotic-recipes-core.d.ts +9 -0
- package/dist/semiotic-recipes-core.module.min.js +1 -1
- package/dist/semiotic-server-edge-node.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-text.min.js +1 -1
- package/dist/semiotic-text.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.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +16 -1
- package/dist/c-447VIMRO.min.js +0 -1
- package/dist/c-553QUDKA.min.js +0 -1
- package/dist/c-7HP7MB2I.min.js +0 -1
- package/dist/c-7NBU5ZKS.min.js +0 -1
- package/dist/c-CCTGN5CK.min.js +0 -1
- package/dist/c-GSZRZRD6.min.js +0 -1
- package/dist/c-GWX7JGMF.min.js +0 -1
- package/dist/c-ITKX3RC5.min.js +0 -1
- package/dist/c-JG2JCQLP.min.js +0 -1
- package/dist/c-LYVKDBQJ.min.js +0 -1
- package/dist/c-NG7BLZTR.min.js +0 -1
- package/dist/c-PYNW54D2.min.js +0 -1
- package/dist/c-TIXX5CAU.min.js +0 -1
- /package/dist/{c-OOVX2JPQ.min.js → c-UC7SIU2W.min.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){let t=e?.find(e=>"bottom"===e.orient),i=e?.find(e=>"top"===e.orient),r=e?.find(e=>"left"===e.orient),o=e?.find(e=>"right"===e.orient);return{bottomAxis:t,topAxis:i,leftAxis:r,rightAxis:o,xAxis:t??i,yAxis:r??o,xOrient:t||!i?"bottom":"top",yOrient:r||!o?"left":"right"}}function t(e){let t=6;for(let i=1;e.length>i;i++){let r=Math.abs(e[i]-e[i-1]);r>0&&Number.isFinite(r)&&(t=Math.max(t,Math.ceil(Math.log10(Math.max(Math.abs(e[i]),Math.abs(e[i-1]))/r))+1))}let i=Math.min(17,t);return e=>Number.isInteger(e)?e+"":Number(e.toPrecision(i))+""}function i(...e){let t;for(let i of e)i&&(t=r(t)&&r(i)?{legendGroups:[...t.legendGroups,...i.legendGroups],legendDistance:i.legendDistance??t.legendDistance}:i);return t}function r(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}function o(e){return"object"==typeof e&&null!==e&&"gradient"in e}function n(e){return"string"==typeof e&&e.length>0}function a(e,t,i=!1){let r=i?t?58:34:t?36:0;return r>e.top?{...e,top:r}:e}function s(e,t){return a(e,n(t))}function l(e,t,i,r,o=8){let n=r,a="left"===r?"right":"right"===r?"left":"top"===r?"bottom":"top",s=Math.max(t[n],Math.max(0,("left"===r||"right"===r?i[0]:i[1])-o)-e[a]);e[n]>s&&(e[n]=s)}function c(e){return Math.ceil(7*e.length)}function u(e,i){if(r(e)){let t=v(i),r=100;for(let i of e.legendGroups){i.label&&(r=Math.max(r,c(i.label)));for(let e of i.items)r=Math.max(r,t.swatchSize+t.labelGap+c(e.label))}return r}if(o(e)){let{gradient:i}=e,r=i.format||t(i.domain),o=Math.max(c(r(i.domain[0])),c(r(i.domain[1]))),n=i.label?c(i.label):0;return Math.max(100,19+o,n)}return 100}function d(e){return(r(e)||o(e))&&Number.isFinite(e.legendDistance)?Math.max(0,e.legendDistance):10}function h(e,t){return null!=e?.sideGutter?Math.max(0,e.sideGutter):t?.hasAxis?t.hasAxisLabel?Th:Lh:0}function f(e){return Math.max(0,e?.edgeGutter??3)}function p(e,t){return null!=t?.axisGutter?Math.max(0,t.axisGutter):e?.hasAxis?e.hasAxisLabel?e.rotatedTicks?64:46:22:0}function y(t){let{bottomAxis:i,topAxis:r,leftAxis:o,rightAxis:n}=e(t.axes),a=!(r&&!i||!1===i?.visible),s=!!r&&!i&&!1!==r.visible,l=!(n&&!o||!1===o?.visible),c=!!n&&!1!==n.visible,u=!1!==t.showAxes;return{hasAxis:u&&a,hasAxisLabel:u&&a&&!!(i?.label??t.xLabel),rotatedTicks:u&&a&&(t.rotatedTicks??!!i?.autoRotate),topAxis:s?{hasAxis:u,hasAxisLabel:u&&!!(r?.label??t.xLabel),rotatedTicks:u&&(t.rotatedTicks??!!r?.autoRotate)}:void 0,leftAxis:l?{hasAxis:u,hasAxisLabel:u&&!!(o?.label??t.yLabel)}:void 0,rightAxis:c?{hasAxis:u,hasAxisLabel:u&&!!(n?.label??t.yLabelRight??t.yLabel)}:void 0}}function g(e,t,i){if(o(e))return e.gradient.label?46:26;if(!r(e))return 20;let n=v(i),a=Math.max(1,i?.maxWidth??t),s=n.rowHeight;for(let t of e.legendGroups){let e=0,i=0;for(let r of t.items){let t=n.swatchSize+n.labelGap+c(r.label),o=0===i?t:i+n.itemGap+t;i>0&&o>a?(e+=1,i=t):i=o}t.items.length>0&&(e+=1),s=Math.max(s,e*n.rowHeight,t.label?c(t.label):0)}return s+(e.legendGroups.length>1?16:0)}function m(e,t,i){return u(e,t)+d(e)+h(t,i)+f(t)}function b(e,t){let{legend:i}=t;if(!i)return;let r=t.position??"right",o=g(i,Math.max(1,t.size[0]-e.left-e.right),t.legendLayout)+d(i)+p("bottom"===r?t.axisChrome:"top"===r?t.axisChrome?.topAxis:void 0,t.legendLayout)+("top"===r&&t.hasTitle?24:0),n=Math.max(t.minimumMargin??0,"top"===r?t.hasTitle?58:34:0);"right"===r?e.right=Math.max(e.right,n,m(i,t.legendLayout,t.axisChrome?.rightAxis)):"left"===r?e.left=Math.max(e.left,n,m(i,t.legendLayout,t.axisChrome?.leftAxis)):"top"===r?e.top=Math.max(e.top,n,o):e.bottom=Math.max(e.bottom,n,o)}function x(e,t){let i=t.position??"right",r="top"===i||"bottom"===i,o=Math.max(0,t.totalWidth-t.margin.left-t.margin.right),n=Math.max(1,r?t.legendLayout?.maxWidth??o:t.reservedWidth??u(e,t.legendLayout)),a=d(e),s=h(t.legendLayout,"left"===i?t.axisChrome?.leftAxis:t.axisChrome?.rightAxis),l=f(t.legendLayout),c=g(e,o,t.legendLayout),y=p(t.axisChrome,t.legendLayout),m=p(t.axisChrome?.topAxis,t.legendLayout);if("left"===i)return{x:Math.max(l,t.margin.left-s-n-a),y:t.margin.top,width:n,height:c};if("top"===i)return{x:t.margin.left,y:t.margin.top-m-a-c,width:n,height:c};if("bottom"===i){let e=t.totalHeight-t.margin.bottom;return{x:t.margin.left,y:Math.max(e+a,Math.min(e+y+a,t.totalHeight-c)),width:n,height:c}}return{x:Math.min(t.totalWidth-n-l,t.totalWidth-t.margin.right+s+a),y:t.margin.top,width:n,height:c}}function v(e){let t=Math.max(1,e?.swatchSize??16),i=Math.max(t,e?.rowHeight??22);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??6),itemGap:Math.max(0,e?.itemGap??10),rowHeight:i,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}function w(e,t){let i=24;return e.map(({hasLabel:e,itemCount:r})=>{i+=5;let o,n=i;i+=8,e&&(i+=16,o=i,i+=8);let a=i;return i+=r*t+8,{lineY:n,labelY:o,itemsY:a,endY:i}})}function k(e,t,i=!1){let r={...e};for(let e of t??[])!1===e.visible&&("top"!==e.orient||!i)&&(r[e.orient]=0);return r}function A(e){let t=0;for(;e.length>t;){let i=/^\s+/.exec(e.slice(t));i&&(t+=i[0].length);let r=e.startsWith("\x3c!--",t)?"--\x3e":e.startsWith("<?",t)?"?>":void 0;if(r){let i=e.indexOf(r,t+2);if(0>i)return;t=i+r.length;continue}if(/^<!DOCTYPE\s/i.test(e.slice(t))){let i="",r=0,o=t+9;for(;e.length>o;o+=1){let t=e[o];if(i)t===i&&(i="");else if(e.startsWith("\x3c!--",o)){let t=e.indexOf("--\x3e",o+4);if(0>t)return;o=t+2}else if('"'===t||"'"===t)i=t;else if("["===t)r+=1;else if("]"===t)r-=1;else if(">"===t&&0===r)break}if(o===e.length)return;t=o+1;continue}break}let i=/^<((?:[A-Za-z_][\w.-]*:)?svg)(?=[\s/>])((?:[^<>"']|"[^"]*"|'[^']*')*)>/i.exec(e.slice(t));if(!i)return;let r=i[2].endsWith("/"),o=r?i[2].slice(0,-1):i[2];return o.replace(Ch,"").trim()?void 0:{start:t,end:t+i[0].length,name:i[1],attributes:o,selfClosing:r}}function S(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").replace(/\t/g,"	").replace(/\n/g," ").replace(/\r/g," ")}function M(e){return e.replace(/\r\n|[\t\r\n]/g," ").replace(/&(amp|quot|apos|lt|gt|#\d+|#x[\da-fA-F]+);/g,(e,t)=>{if(!t.startsWith("#"))return{amp:"&",quot:'"',apos:"'",lt:"<",gt:">"}[t];let i=t.startsWith("#x")?parseInt(t.slice(2),16):Number(t.slice(1));return i>0&&1114111>=i?String.fromCodePoint(i):e})}function _(e,t){for(let i of e.attributes.matchAll(Ch))if(i[1]===t)return M(i[2]??i[3])}function $(e,t){let i=A(e);if(!i)return t;let r=e=>{let r=_(i,e),o=r&&/^[0-9]+(?:\.[0-9]+)?$/.test(r)?Number(r):NaN;return Number.isFinite(o)&&o>0?o:t[e]};return{width:r("width"),height:r("height")}}function P(e,t){let i=A(e);return i?function(e,t){let i=A(e);if(!i)return e;let r=new Map(Object.entries(t)),o=i.attributes.replace(Ch,(e,t)=>{let i=r.get(t);return void 0===i?e:(r.delete(t),` ${t}="${S(i)}"`)});for(let[e,t]of r)o+=` ${e}="${S(t)}"`;return`${e.slice(0,i.start)}<${i.name}${o}${i.selfClosing?"/":""}>${e.slice(i.end)}`}(e,{width:"100%",height:"100%",...void 0===_(i,"viewBox")?{viewBox:`0 0 ${t.width} ${t.height}`}:{},...void 0===_(i,"preserveAspectRatio")?{preserveAspectRatio:"xMidYMid meet"}:{}}):e}function R(e){return null==e?"null":Array.isArray(e)?`[${e.map(R).join(",")}]`:e instanceof Date?JSON.stringify(e):"object"==typeof e?`{${Object.entries(e).filter(([,e])=>void 0!==e).sort(([e],[t])=>t>e?-1:e>t?1:0).map(([e,t])=>`${JSON.stringify(e)}:${R(t)}`).join(",")}}`:JSON.stringify(e)}function I(e){let t=[...Dh],i=Array.from((new TextEncoder).encode(e)),r=8*i.length;for(i.push(128);i.length%64!=56;)i.push(0);let o=Math.floor(r/4294967296),n=r>>>0;i.push(o>>>24&255,o>>>16&255,o>>>8&255,255&o,n>>>24&255,n>>>16&255,n>>>8&255,255&n);let a=[];for(let e=0;i.length>e;e+=4)a.push((i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3])>>>0);for(let e=0;a.length>e;e+=16){let i=[...a.slice(e,e+16)];for(let e=16;64>e;e+=1){let t=Oh(i[e-15],7)^Oh(i[e-15],18)^i[e-15]>>>3,r=Oh(i[e-2],17)^Oh(i[e-2],19)^i[e-2]>>>10;i[e]=i[e-16]+t+i[e-7]+r>>>0}let[r,o,n,s,l,c,u,d]=t;for(let e=0;64>e;e+=1){let t=d+(Oh(l,6)^Oh(l,11)^Oh(l,25))+(l&c^~l&u)+zh[e]+i[e]>>>0,a=r&o^r&n^o&n;d=u,u=c,c=l,l=s+t>>>0,s=n,n=o,o=r,r=t+((Oh(r,2)^Oh(r,13)^Oh(r,22))+a>>>0)>>>0}let h=[r,o,n,s,l,c,u,d];for(let e=0;8>e;e+=1)t[e]=t[e]+h[e]>>>0}return t.map(e=>e.toString(16).padStart(8,"0")).join("")}function L(e,t){return`${e}[Symbol(${t.description??""})]`}function T(e,t){if(!/^(0|[1-9][0-9]*)$/.test(e))return!1;let i=Number(e);return Number.isSafeInteger(i)&&i>=0&&t>i}function C(e,t){return"number"==typeof t?`${e}[${t}]`:e?`${e}.${t}`:t}function O(e){return e.sort((e,t)=>{let i=JSON.stringify(e),r=JSON.stringify(t);return r>i?-1:i>r?1:0})}function F(e,t,i){if(null===e)return null;if(e instanceof Date){let r=e.getTime();return Number.isFinite(r)?{$type:"date",value:e.toISOString()}:void i.excluded.push(t)}switch(typeof e){case"string":case"boolean":return e;case"number":return Number.isNaN(e)?{$type:"number",value:"NaN"}:e===1/0?{$type:"number",value:"Infinity"}:e===-1/0?{$type:"number",value:"-Infinity"}:Object.is(e,-0)?{$type:"number",value:"-0"}:e;case"bigint":return{$type:"bigint",value:""+e};case"undefined":case"function":case"symbol":return void i.excluded.push(t);case"object":{let r=e;if(i.ancestors.has(r))return void i.excluded.push(t);i.ancestors.add(r);try{if(Array.isArray(e)){for(let r of Reflect.ownKeys(e))"length"===r||"string"==typeof r&&T(r,e.length)||i.excluded.push("symbol"==typeof r?L(t,r):C(t,r));return Array.from({length:e.length},(r,o)=>{let n=C(t,o),a=Object.getOwnPropertyDescriptor(e,o+"");if(!a||!("value"in a)||!a.enumerable)return i.excluded.push(n),null;let s=F(a.value,n,i);return void 0===s?null:s})}let r={},o=Object.getPrototypeOf(e);if(o!==Object.prototype&&null!==o)return void i.excluded.push(t);let n=[];for(let r of Reflect.ownKeys(e)){if("symbol"==typeof r){i.excluded.push(L(t,r));continue}let o=Object.getOwnPropertyDescriptor(e,r);o&&"value"in o&&o.enumerable?n.push(r):i.excluded.push(C(t,r))}for(let o of n.sort()){let n=Object.getOwnPropertyDescriptor(e,o),a=F(n&&"value"in n?n.value:void 0,C(t,o),i);void 0!==a&&Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0})}return r}finally{i.ancestors.delete(r)}}default:return void i.excluded.push(t)}}function D(e,t=new Set){if(null===e)return["null"];if(e instanceof Date)return Number.isFinite(e.getTime())?["date",e.toISOString()]:["excluded"];switch(typeof e){case"string":return["string",e];case"boolean":return["boolean",e];case"number":return["number",Number.isNaN(e)?"NaN":e===1/0?"Infinity":e===-1/0?"-Infinity":Object.is(e,-0)?"-0":e+""];case"bigint":return["bigint",""+e];case"undefined":case"function":case"symbol":return["excluded"];case"object":if(t.has(e))return["excluded"];t.add(e);try{let i=i=>{let r="symbol"==typeof i?["symbol-key",i.description??""]:["string-key",i],o=Object.getOwnPropertyDescriptor(e,i);return o?"value"in o?[r,"data",!!o.enumerable,D(o.value,t)]:[r,"accessor",!!o.enumerable,!!o.get,!!o.set]:[r,"missing"]};if(Array.isArray(e))return["array",Array.from({length:e.length},(t,r)=>{let o=r+"";return Object.prototype.hasOwnProperty.call(e,o)?i(o):["hole"]}),O(Reflect.ownKeys(e).filter(t=>"length"!==t&&!("string"==typeof t&&T(t,e.length))).map(i))];let r=Object.getPrototypeOf(e);return[r!==Object.prototype&&null!==r?"non-json-object":"object",O(Reflect.ownKeys(e).map(i))]}finally{t.delete(e)}default:return["excluded"]}}function z(e){let t={excluded:[],ancestors:new Set},i=F(e,"$",t)??null;return{value:i,text:JSON.stringify(i),excludedPaths:t.excluded}}function N(e){let t=z(e),i=I(JSON.stringify(["semiotic-value-fingerprint","v2",D(e)]));return{...t,algorithm:"sha256",digest:i,fingerprint:"sha256:"+i}}function E(e,t){return"number"==typeof t?`${e}[${t}]`:`${e}.${t}`}function B(e,t){return`${e}[Symbol(${t.description??""})]`}function W(e,t){if(!/^(0|[1-9][0-9]*)$/.test(e))return!1;let i=Number(e);return Number.isSafeInteger(i)&&i>=0&&t>i}function j(e,t){try{return Object.getOwnPropertyDescriptor(e,t)}catch{return}}function Y(e,t,i,r){let o=j(e,t);return o&&"value"in o&&o.enumerable?X(o.value,i,r):[i]}function X(e,t="$",i=new Set){if(null===e||"string"==typeof e||"boolean"==typeof e)return[];if("number"==typeof e)return Number.isFinite(e)&&!Object.is(e,-0)?[]:[t];if("object"!=typeof e)return[t];if(i.has(e))return[t];let r,o,n;try{n=Array.isArray(e),r=Object.getPrototypeOf(e),o=Reflect.ownKeys(e)}catch{return[t]}if(r!==(n?Array.prototype:Object.prototype)&&null!==r)return[t];i.add(e);let a=[];try{if(n){let r=j(e,"length")?.value;if(!Number.isSafeInteger(r)||0>r)return[E(t,"length")];for(let e of o)"length"===e||"string"==typeof e&&W(e,r)||a.push("symbol"==typeof e?B(t,e):E(t,e));for(let o=0;r>o;o+=1)a.push(...Y(e,o+"",E(t,o),i))}else for(let r of o)"symbol"!=typeof r?a.push(...Y(e,r,E(t,r),i)):a.push(B(t,r));return a}catch{return[t]}finally{i.delete(e)}}function q(e,t,i,r){Z(e,Object.keys(t),i,r);for(let[o,n]of Object.entries(t))n.values?(n.required||void 0!==e[o])&&J(e,o,i,n.values,r):n.required?Q(e,o,i,r):oe(e,o,i,r)}function G(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function V(e,t,i,r){void 0!==e[t]&&("number"!=typeof e[t]||!Number.isFinite(e[t]))&&r.push({path:`${i}.${t}`,message:"Expected a finite number."})}function H(e,t,i,r){void 0!==e[t]&&"boolean"!=typeof e[t]&&r.push({path:`${i}.${t}`,message:"Expected a boolean."})}function U(e){return null===e||"string"==typeof e||"boolean"==typeof e||("number"==typeof e?Number.isFinite(e):Array.isArray(e)?e.every(U):G(e)&&Object.values(e).every(U))}function K(e,t,i,r){void 0!==e[t]&&(!G(e[t])||!U(e[t]))&&r.push({path:`${i}.${t}`,message:"Expected a JSON object."})}function Z(e,t,i,r){let o=new Set(t);for(let t of Object.keys(e))o.has(t)||r.push({path:`${i}.${t}`,message:"Unexpected property."})}function Q(e,t,i,r){("string"!=typeof e[t]||!e[t])&&r.push({path:`${i}.${t}`,message:"Expected a non-empty string."})}function J(e,t,i,r,o){("string"!=typeof e[t]||!r.includes(e[t]))&&o.push({path:`${i}.${t}`,message:`Expected one of: ${r.join(", ")}.`})}function ee(e,t,i,r){let o=e[t];if(void 0!==o)return G(o)?o:void r.push({path:`${i}.${t}`,message:"Expected an object."})}function te(e,t,i,r){let o=e[t];if(void 0!==o)return Array.isArray(o)?o:void r.push({path:`${i}.${t}`,message:"Expected an array."})}function ie(e,t,i){e?.some(e=>"string"!=typeof e||!e)&&i.push({path:t,message:"Expected non-empty string values."})}function re(e,t,i,r,o){void 0!==e[t]&&J(e,t,i,r,o)}function oe(e,t,i,r){void 0!==e[t]&&"string"!=typeof e[t]&&r.push({path:`${i}.${t}`,message:"Expected a string."})}function ne(e,t,i){G(e)?(Z(e,["id","name","kind"],t,i),Q(e,"kind",t,i),oe(e,"id",t,i),oe(e,"name",t,i)):i.push({path:t,message:"Expected an actor object."})}function ae(e){for(let t of Object.values(e))Object.freeze(t.suppliedBy),Object.freeze(t);return Object.freeze(e)}function se(e){try{return function(e){let t=[],i=[];if(!G(e))return{valid:!1,errors:[{path:"$",message:"Expected an object."}],warnings:i};let r=X(e);if(r.length>0)return{valid:!1,errors:r.map(e=>({path:e,message:"Expected a JSON-compatible value that survives serialization unchanged."})),warnings:i};if(Z(e,["contractVersion","artifact","purpose","claims","evidence","time","reception","form","contestability","accountability","inheritance","fieldStatus","extensions"],"$",t),"0.1"!==e.contractVersion&&t.push({path:"$.contractVersion",message:"Expected contract version 0.1."}),G(e.artifact)){Z(e.artifact,["id","kind","component","title","createdAt","configFingerprint","dataFingerprint","revision"],"$.artifact",t),Q(e.artifact,"id","$.artifact",t),J(e.artifact,"kind","$.artifact",["chart","dashboard","story","alert","agent-answer"],t);for(let i of["component","title","createdAt","configFingerprint","dataFingerprint","revision"])oe(e.artifact,i,"$.artifact",t)}else t.push({path:"$.artifact",message:"Expected an artifact identity object."});if(G(e.purpose))if(Array.isArray(e.purpose.intents)){Z(e.purpose,["intents","communicativeAct","decisionContext","stakes","allowedUses","prohibitedUses"],"$.purpose",t),e.purpose.intents.forEach((e,i)=>{(!G(e)||"string"!=typeof e.id||!e.id)&&t.push({path:`$.purpose.intents[${i}].id`,message:"Expected a non-empty intent identifier."}),G(e)&&Z(e,["id","strength","source","rationale"],`$.purpose.intents[${i}]`,t),G(e)&&void 0!==e.strength&&J(e,"strength",`$.purpose.intents[${i}]`,["primary","secondary"],t),G(e)&&(re(e,"source",`$.purpose.intents[${i}]`,["author","derived","model-proposal","import"],t),oe(e,"rationale",`$.purpose.intents[${i}]`,t))});for(let i of["allowedUses","prohibitedUses"])ie(te(e.purpose,i,"$.purpose",t),"$.purpose."+i,t);re(e.purpose,"stakes","$.purpose",["exploratory","informational","operational","high"],t),oe(e.purpose,"communicativeAct","$.purpose",t),oe(e.purpose,"decisionContext","$.purpose",t)}else t.push({path:"$.purpose.intents",message:"Expected an intent array."});else t.push({path:"$.purpose",message:"Expected a purpose object."});Array.isArray(e.claims)?e.claims.forEach((e,i)=>{if(!G(e))return void t.push({path:`$.claims[${i}]`,message:"Expected a claim object."});Z(e,["id","text","kind","status","evidenceIds","scope","uncertainty","asOf","supersedes","authoredBy","review","tags"],`$.claims[${i}]`,t),Q(e,"id",`$.claims[${i}]`,t),J(e,"kind",`$.claims[${i}]`,["description","observation","aggregation","inference","forecast","simulation","alert","recommendation","normative"],t),J(e,"status",`$.claims[${i}]`,["supported","provisional","disputed","superseded","retracted","unsupported","unknown"],t),Array.isArray(e.evidenceIds)?e.evidenceIds.some(e=>"string"!=typeof e||!e)&&t.push({path:`$.claims[${i}].evidenceIds`,message:"Expected non-empty string evidence identifiers."}):t.push({path:`$.claims[${i}].evidenceIds`,message:"Expected an evidence identifier array."}),ie(te(e,"supersedes",`$.claims[${i}]`,t),`$.claims[${i}].supersedes`,t),oe(e,"text",`$.claims[${i}]`,t),oe(e,"asOf",`$.claims[${i}]`,t),K(e,"scope",`$.claims[${i}]`,t),ie(te(e,"tags",`$.claims[${i}]`,t),`$.claims[${i}].tags`,t),void 0!==e.authoredBy&&ne(e.authoredBy,`$.claims[${i}].authoredBy`,t);let r=ee(e,"review",`$.claims[${i}]`,t);r&&(Z(r,["status","reviewer","reviewedAt","rationale"],`$.claims[${i}].review`,t),J(r,"status",`$.claims[${i}].review`,["proposed","reviewed","approved","rejected"],t),void 0!==r.reviewer&&ne(r.reviewer,`$.claims[${i}].review.reviewer`,t),oe(r,"reviewedAt",`$.claims[${i}].review`,t),oe(r,"rationale",`$.claims[${i}].review`,t));let o=ee(e,"uncertainty",`$.claims[${i}]`,t);if(o){Z(o,["kind","lower","upper","confidence","unit","description"],`$.claims[${i}].uncertainty`,t),J(o,"kind",`$.claims[${i}].uncertainty`,["interval","distribution","qualitative","unknown"],t);for(let e of["lower","upper","confidence"])V(o,e,`$.claims[${i}].uncertainty`,t);oe(o,"unit",`$.claims[${i}].uncertainty`,t),oe(o,"description",`$.claims[${i}].uncertainty`,t)}}):t.push({path:"$.claims",message:"Expected a claim array."}),Array.isArray(e.evidence)?e.evidence.forEach((e,i)=>{if(!G(e))return void t.push({path:`$.evidence[${i}]`,message:"Expected an evidence object."});Z(e,["id","role","label","source","fingerprint","dataVersion","observedAt","scope","sample","transformation","generatedClaimId","relationship"],`$.evidence[${i}]`,t),Q(e,"id",`$.evidence[${i}]`,t),J(e,"role",`$.evidence[${i}]`,["source-data","external-source","transformation","statistical-test","model-output","human-observation","policy-rule","quality-check"],t);for(let r of["label","fingerprint","dataVersion","observedAt","generatedClaimId"])oe(e,r,`$.evidence[${i}]`,t);K(e,"scope",`$.evidence[${i}]`,t);let r=ee(e,"source",`$.evidence[${i}]`,t);if(r){Z(r,["name","uri","version","retrievedAt","publisher"],`$.evidence[${i}].source`,t);for(let e of["name","uri","version","retrievedAt","publisher"])oe(r,e,`$.evidence[${i}].source`,t)}let o=ee(e,"transformation",`$.evidence[${i}]`,t);if(o){Z(o,["id","kind","description","inputEvidenceIds","parameters","assumptions","implementation","performedAt","performedBy"],`$.evidence[${i}].transformation`,t),Q(o,"id",`$.evidence[${i}].transformation`,t),J(o,"kind",`$.evidence[${i}].transformation`,["aggregation","filter","normalization","binning","join","smoothing","forecasting","simulation","other"],t);let e=te(o,"inputEvidenceIds",`$.evidence[${i}].transformation`,t);e?ie(e,`$.evidence[${i}].transformation.inputEvidenceIds`,t):t.push({path:`$.evidence[${i}].transformation.inputEvidenceIds`,message:"Expected an evidence identifier array."}),ie(te(o,"assumptions",`$.evidence[${i}].transformation`,t),`$.evidence[${i}].transformation.assumptions`,t),oe(o,"description",`$.evidence[${i}].transformation`,t),oe(o,"implementation",`$.evidence[${i}].transformation`,t),oe(o,"performedAt",`$.evidence[${i}].transformation`,t),K(o,"parameters",`$.evidence[${i}].transformation`,t),void 0!==o.performedBy&&ne(o.performedBy,`$.evidence[${i}].transformation.performedBy`,t)}let n=ee(e,"sample",`$.evidence[${i}]`,t);if(n){Z(n,["rowCount","fields","values","truncated"],`$.evidence[${i}].sample`,t),ie(te(n,"fields",`$.evidence[${i}].sample`,t),`$.evidence[${i}].sample.fields`,t);let e=te(n,"values",`$.evidence[${i}].sample`,t);e&&!function(e){return e.every(U)}(e)&&t.push({path:`$.evidence[${i}].sample.values`,message:"Expected JSON values."}),V(n,"rowCount",`$.evidence[${i}].sample`,t),H(n,"truncated",`$.evidence[${i}].sample`,t)}re(e,"relationship",`$.evidence[${i}]`,["descriptive","correlational","causal","unknown"],t)}):t.push({path:"$.evidence",message:"Expected an evidence array."}),function(e,t){if(void 0===e||G(e)){if(G(e))for(let[i,r]of Object.entries(e)){let e="$.fieldStatus."+i;if(!G(r)||"string"!=typeof r.status){t.push({path:e,message:"Expected a field state with a status."});continue}Z(r,["status","reason","suppliedBy","derived","reviewedBy"],e,t),["known","unknown","manual","not-applicable"].includes(r.status)||t.push({path:e+".status",message:"Expected one of: known, unknown, manual, not-applicable."}),void 0!==r.suppliedBy&&("string"!=typeof r.suppliedBy||!["author","system","model-proposal","import"].includes(r.suppliedBy))&&t.push({path:e+".suppliedBy",message:"Expected one of: author, system, model-proposal, import."}),oe(r,"reason",e,t),oe(r,"reviewedBy",e,t),H(r,"derived",e,t);let o=Object.prototype.hasOwnProperty.call(Nh,i)?Nh[i]:void 0,n="model-proposal"===r.suppliedBy,a=n&&!0===o?.modelMayPropose&&"known"!==r.status;o&&"known"===r.status&&"string"!=typeof r.suppliedBy&&t.push({path:e+".suppliedBy",message:`Known field "${i}" must identify an allowed supplier.`}),o&&"string"==typeof r.suppliedBy&&!a&&!o.suppliedBy.includes(r.suppliedBy)&&t.push({path:e+".suppliedBy",message:`Field "${i}" cannot be supplied by ${r.suppliedBy}.`}),o&&!0===r.derived&&!o.derivable&&t.push({path:e+".derived",message:`Field "${i}" cannot be marked as derived.`}),o&&n&&(!o.modelMayPropose||"known"===r.status)&&t.push({path:e+".suppliedBy",message:"known"===r.status?`A model proposal cannot finalize field "${i}" as known.`:`Field "${i}" does not accept model proposals.`}),"required"===o?.humanReview&&"known"===r.status&&("string"!=typeof r.reviewedBy||!r.reviewedBy.trim())&&t.push({path:e+".reviewedBy",message:`Known field "${i}" requires an attributable human review.`})}}else t.push({path:"$.fieldStatus",message:"Expected a field-state object."})}(e.fieldStatus,t);let o=ee(e,"time","$",t);return o&&function(e,t){let i="$.time";Z(e,[...Wh,...Object.keys(jh),"sources"],i,t);for(let r of Wh)oe(e,r,i,t);for(let[r,o]of Object.entries(jh)){let n=ee(e,r,i,t);n&&q(n,o,`${i}.${r}`,t)}te(e,"sources",i,t)?.forEach((e,r)=>{let o=`${i}.sources[${r}]`;G(e)?q(e,Yh,o,t):t.push({path:o,message:"Expected a source object."})})}(o,t),function(e,t){(function(e,t){let i=ee(e,"reception","$",t);if(!i)return;Z(i,["channels","audience","strengths","risks","scaffolds","description","dataFallback","manualChecks"],"$.reception",t);let r=te(i,"channels","$.reception",t);r||t.push({path:"$.reception.channels",message:"Expected a reception-channel array."}),r?.forEach((e,i)=>{let r=`$.reception.channels[${i}]`;G(e)?(Z(e,["channel","disclosure","navigation","interactionInstructions","rawData","tokenBudget","privacyNotes"],r,t),J(e,"channel",r,["visual","screen-reader","sonified","agent","print","low-bandwidth"],t),re(e,"disclosure",r,["summary","standard","detailed"],t),re(e,"rawData",r,["deny","bounded","allow"],t),H(e,"navigation",r,t),H(e,"interactionInstructions",r,t),V(e,"tokenBudget",r,t),ie(te(e,"privacyNotes",r,t),r+".privacyNotes",t)):t.push({path:r,message:"Expected a channel object."})});for(let e of["strengths","risks","scaffolds","manualChecks"])ie(te(i,e,"$.reception",t),"$.reception."+e,t);oe(i,"audience","$.reception",t),oe(i,"description","$.reception",t),H(i,"dataFallback","$.reception",t)})(e,t),function(e,t){let i=ee(e,"form","$",t);i&&(Z(i,["chartFamily","whyThisForm","rejectedAlternatives","risks","misuse"],"$.form",t),oe(i,"chartFamily","$.form",t),oe(i,"whyThisForm","$.form",t),ie(te(i,"risks","$.form",t),"$.form.risks",t),ie(te(i,"misuse","$.form",t),"$.form.misuse",t),te(i,"rejectedAlternatives","$.form",t)?.forEach((e,i)=>{let r=`$.form.rejectedAlternatives[${i}]`;G(e)?(Z(e,["representation","reason"],r,t),Q(e,"representation",r,t),Q(e,"reason",r,t)):t.push({path:r,message:"Expected an alternative object."})}))}(e,t),function(e,t){let i=ee(e,"contestability","$",t);i&&(Z(i,["sourceRequestsAllowed","alternativeViews","challenges","corrections","editorialExceptions"],"$.contestability",t),H(i,"sourceRequestsAllowed","$.contestability",t),te(i,"challenges","$.contestability",t)?.forEach((e,i)=>{let r=`$.contestability.challenges[${i}]`;if(G(e)){Z(e,["id","claimId","status","reason","raisedBy","raisedAt","counterclaimId","resolution"],r,t),Q(e,"id",r,t),Q(e,"claimId",r,t),Q(e,"reason",r,t),J(e,"status",r,["open","accepted","declined","resolved"],t),void 0!==e.raisedBy&&ne(e.raisedBy,r+".raisedBy",t);for(let i of["raisedAt","counterclaimId","resolution"])oe(e,i,r,t)}else t.push({path:r,message:"Expected a challenge object."})}),te(i,"corrections","$.contestability",t)?.forEach((e,i)=>{let r=`$.contestability.corrections[${i}]`;if(!G(e))return void t.push({path:r,message:"Expected a correction object."});Z(e,["id","affectedClaimIds","replacementClaimIds","reason","createdAt","createdBy"],r,t),Q(e,"id",r,t),Q(e,"reason",r,t);let o=te(e,"affectedClaimIds",r,t);o||t.push({path:r+".affectedClaimIds",message:"Expected an affected-claim array."}),ie(o,r+".affectedClaimIds",t),ie(te(e,"replacementClaimIds",r,t),r+".replacementClaimIds",t),oe(e,"createdAt",r,t),void 0!==e.createdBy&&ne(e.createdBy,r+".createdBy",t)}),te(i,"alternativeViews","$.contestability",t)?.forEach((e,i)=>{let r=`$.contestability.alternativeViews[${i}]`;G(e)?(Z(e,["id","label","rationale"],r,t),Q(e,"id",r,t),Q(e,"label",r,t),oe(e,"rationale",r,t)):t.push({path:r,message:"Expected an alternative-view object."})}),te(i,"editorialExceptions","$.contestability",t)?.forEach((e,i)=>{let r=`$.contestability.editorialExceptions[${i}]`;G(e)?(Z(e,["ruleId","rationale","owner","reviewAt"],r,t),Q(e,"ruleId",r,t),Q(e,"rationale",r,t),oe(e,"owner",r,t),oe(e,"reviewAt",r,t)):t.push({path:r,message:"Expected an editorial-exception object."})}))}(e,t),function(e,t){let i=ee(e,"accountability","$",t);i&&(Z(i,["authors","generatedBy","dataSources","codeRef","reviews","actions"],"$.accountability",t),te(i,"authors","$.accountability",t)?.forEach((e,i)=>ne(e,`$.accountability.authors[${i}]`,t)),ie(te(i,"dataSources","$.accountability",t),"$.accountability.dataSources",t),oe(i,"generatedBy","$.accountability",t),oe(i,"codeRef","$.accountability",t),te(i,"reviews","$.accountability",t)?.forEach((e,i)=>{let r=`$.accountability.reviews[${i}]`;if(G(e)){Z(e,["id","status","reviewer","reviewedAt","rationale","policyId"],r,t),Q(e,"id",r,t),J(e,"status",r,["pending","approved","changes-requested","rejected"],t),void 0!==e.reviewer&&ne(e.reviewer,r+".reviewer",t);for(let i of["reviewedAt","rationale","policyId"])oe(e,i,r,t)}else t.push({path:r,message:"Expected a review object."})}),te(i,"actions","$.accountability",t)?.forEach((e,i)=>{let r=`$.accountability.actions[${i}]`;if(!G(e))return void t.push({path:r,message:"Expected an action object."});Z(e,["id","action","actor","actedAt","claimIds","artifactId","artifactRevision","policyId","status","invalidatedByClaimId"],r,t),Q(e,"id",r,t),Q(e,"action",r,t);let o=te(e,"claimIds",r,t);o||t.push({path:r+".claimIds",message:"Expected a claim identifier array."}),ie(o,r+".claimIds",t),void 0!==e.actor&&ne(e.actor,r+".actor",t);for(let i of["actedAt","artifactId","artifactRevision","policyId","invalidatedByClaimId"])oe(e,i,r,t);re(e,"status",r,["proposed","taken","reversed","invalidated"],t)}))}(e,t),function(e,t){let i=ee(e,"inheritance","$",t);if(i){Z(i,["requiredPaths","prohibitedExports","privacy","rawDataDefault","preservation","sourceArtifactIds"],"$.inheritance",t);for(let e of["requiredPaths","prohibitedExports","sourceArtifactIds"])ie(te(i,e,"$.inheritance",t),"$.inheritance."+e,t);re(i,"privacy","$.inheritance",["public","restricted","confidential","unknown"],t),re(i,"rawDataDefault","$.inheritance",["exclude","bounded","include"],t),re(i,"preservation","$.inheritance",["full-fidelity","claim-evidence-preserved","visual-only","lossy","unknown"],t)}}(e,t)}(e,t),K(e,"extensions","$",t),Array.isArray(e.claims)&&0===e.claims.length&&i.push({path:"$.claims",message:"The contract declares no claims."}),Array.isArray(e.evidence)&&0===e.evidence.length&&i.push({path:"$.evidence",message:"The contract declares no evidence."}),{valid:0===t.length,errors:t,warnings:i}}(e)}catch{return{valid:!1,errors:[{path:"$",message:"Artifact contract could not be inspected safely."}],warnings:[]}}}function le(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function ce(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function ue(e,t={}){let i=t.mobileSemantics?.interaction,r="number"==typeof i?.targetSize?i.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,o="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,n=!!i||void 0!==r,a=e&&"object"==typeof e?e:void 0;if(!1===e||!1===a?.enabled||void 0===e&&!o&&!n)return qh;let s=a??{};return{enabled:!0,tapToSelect:s.tapToSelect??!0,tapToLockTooltip:s.tapToLockTooltip??!0,clearSelection:s.clearSelection??"backgroundTap",targetSize:s.targetSize??r??44,snap:s.snap??"nearestDatum",brushHandleSize:s.brushHandleSize??44,standardControls:s.standardControls??!1}}function de(e,t,i){if(!1!==t)return e;let r={...e};return"horizontal"===i?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}function he(e){return e instanceof Date?"date:"+e.getTime():`${typeof e}:${e+""}`}function fe(e,t,i,r){let o=e??t;return"function"==typeof o?o(i,r):i[o+""]}function pe(e){return"string"==typeof e?.code&&e.code.length>0&&("warning"===e.severity||"error"===e.severity)&&"string"==typeof e.message&&e.message.length>0}function ye(e,t,i){if(e.semanticDiagnostics=[],e.semanticStatus="not-assessed",e.empty)return;let r,o=function(e){return function(e){return Kh.has(e)}(e)?function(e){return Kh.get(e)}(e):"BumpChart"===e?Vh:void 0}(t);if(o){try{let t="function"==typeof o?o(i,e):function(e){let t=new Map;(Array.isArray(e.data)?e.data:[]).forEach((i,r)=>{if(!Number.isFinite(Number(fe(e.yAccessor,"y",i,r))))return;let o=he(fe(e.xAccessor,"x",i,r)),n=t.get(o)??new Set;n.add(fe(e.lineBy,"series",i,r)+""),t.set(o,n)});let i=Array.from(t.values(),e=>e.size).sort((e,t)=>e-t);if(0===i.length)return[];let r=Math.floor(i.length/2),o={columns:i.length,median:i.length%2?i[r]:(i[r-1]+i[r])/2,max:i[i.length-1],contestedColumns:i.filter(e=>e>=2).length},n=2>o.max;return n||2>o.contestedColumns||2>o.median?[{code:n?"BUMP_NO_RANK_COMPETITION":"BUMP_SPARSE_RANK_COMPETITION",severity:n?"error":"warning",message:n?"Every ranking column contains one series, so every trajectory remains at rank 1.":"Too few ranking columns contain competing series for reliable rank movement.",fix:"Use a lineBy field with repeated series across shared x columns, or choose a value-based chart.",metrics:{...o}}]:[]}(i);r=Array.from(t).filter(pe)}catch{return void(e.warnings.includes("SEMANTIC_VIABILITY_CHECK_FAILED")||e.warnings.push("SEMANTIC_VIABILITY_CHECK_FAILED"))}e.semanticDiagnostics=r,e.semanticStatus=r.some(e=>"error"===e.severity)?"degenerate":r.some(e=>"warning"===e.severity)?"degraded":"meaningful";for(let t of r)e.warnings.includes(t.code)||e.warnings.push(t.code)}}function ge(e,t,i){let r="function"==typeof t?t(e):e[(t??i)+""];if(null==r||"string"==typeof r&&""===r.trim())return null;let o=Number(r);return Number.isFinite(o)?o:null}function me(e){if(!e)return Jh;let t=!1;for(let i=0;e.length>i;i++){let r=e[i];if(null==r||"object"!=typeof r){t=!0;break}}if(!t)return e;let i=[];for(let t of e)null!=t&&"object"==typeof t&&i.push(t);return i}function be(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function xe(e,t,i){let r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(i)}`}function ve(e){let t=e.map(be),i=t.length-1;return e=>{if(Number.isNaN(e)&&(e=0),0>=e){let[e,i,r]=t[0];return xe(e,i,r)}if(e>=1){let[e,r,o]=t[i];return xe(e,r,o)}let r=e*i,o=Math.floor(r),n=r-o,[a,s,l]=t[o],[c,u,d]=t[o+1];return xe(Math.round(a+(c-a)*n),Math.round(s+(u-s)*n),Math.round(l+(d-l)*n))}}function we(e){return e&&Object.prototype.hasOwnProperty.call(yf,e)?yf[e]:rf}function ke(e,t,i=Sf){if(e&&"object"==typeof e&&!Array.isArray(e)){let 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){let t=Object.prototype.hasOwnProperty.call(Af,e)?Af[e]:void 0;if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:i}function Ae(e,t,i){if("function"==typeof t){let r=t(e);return i&&r&&"string"==typeof r&&!function(e){let t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||Pf.has(t)}(r)?i(r):r}let r=e?.[t]+"";return i?i(r):Sf[Math.abs(function(e){let t=0;for(let i=0;e.length>i;i++)t=(t<<5)-t+e.charCodeAt(i),t&=t;return Math.abs(t)}(r))%Sf.length]}function Se(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;let i=e[t];return"string"==typeof i&&i.length>0?i:void 0}function Me(e,t,i="category10"){if(i&&"object"==typeof i&&!Array.isArray(i)){let e=i;return t=>Se(e,t)??"#999"}let 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(i))return ef().domain(r).range(i).unknown("#999");let n=Object.prototype.hasOwnProperty.call(Af,i)?Af[i]:Af.category10;if(o&&"function"==typeof n){let e=-1/0;for(let t of r){let i=Number(t);i>e&&(e=i)}return t=>n(0===e?0:Number(t)/e)}{let e=Array.isArray(n)?n:Sf;return ef().domain(r).range(e).unknown("#999")}}function _e(e,t,i=[3,20],r){let o;if(o="function"==typeof t?t(e):e?.[t],!r)return o;let[n,a]=r,[s,l]=i;if(a===n)return(s+l)/2;let c=(o-n)/(a-n);return 0>c?c=0:c>1&&(c=1),s+c*(l-s)}function $e(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}function Pe(e,t){if(!$e(t))return e??((...e)=>({}));let i={};return void 0!==t.stroke&&(i.stroke=t.stroke),void 0!==t.strokeWidth&&(i.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(i.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...i}):(...e)=>({...i})}function Re(e){if(null==e)return()=>{};let t="function"==typeof e?e:t=>t[e];return e=>Te(t(e))}function Ie(e,t){let i=Re(e),r=Re(t);return(e,t)=>{let o=r(e);return{value:o,x:i(e),y:o,category:t}}}function Le(e,t){let i=Re(t??"value"),r=null==e?void 0:"function"==typeof e?e:t=>t[e];return e=>{let t=r?r(e):void 0;return{value:i(e),category:null==t?void 0:t+""}}}function Te(e){if("number"==typeof e)return Number.isFinite(e)?e:void 0;if("string"==typeof e&&""!==e.trim()){let t=Number(e);return Number.isFinite(t)?t:void 0}}function Ce(e,t,i){let r=e.when;return void 0===r||!0===r||!1!==r&&("function"==typeof r?r(t,i):function(e,t,i){let r=null!=e.axis?i[e.axis]:null!=e.field?t[e.field]:i.value;if(void 0!==e.eq&&r!==e.eq||void 0!==e.ne&&r===e.ne||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;let o=Te(r);if(void 0===o||void 0!==e.gt&&e.gt>=o||void 0!==e.gte&&e.gte>o||void 0!==e.lt&&o>=e.lt||void 0!==e.lte&&o>e.lte)return!1;if(void 0!==e.within){let[t,i]=e.within;if(t>o||o>i)return!1}if(void 0!==e.outside){let[t,i]=e.outside;if(o>=t&&i>=o)return!1}return!0}(r,t,i))}function Oe(e,t,i){if(!t||0===t.length)return{};let r={};for(let o of t){if(!Ce(o,e,i))continue;let t="function"==typeof o.style?o.style(e,i):o.style;t&&(r={...r,...t})}return r}function Fe(e,t,i,r=e=>e){let o=e??(()=>({}));return t&&0!==t.length?(e,n)=>{let a=r(e),s={...o(e,n)};return Object.assign(s,Oe(a,t,i(a,n))),s}:o}function De(e,t,i,r){if(!e||0===e.length)return r;let o=Le(t,i);return(t,i)=>{let n=t&&t.data||t,a=Oe(n,e,o(n)),s=r?r(t,i):void 0;return s?{...a,...s}:a}}function ze(e){let{lineWidth:t=2,colorBy:i,colorScale:r,color:o,resolveStroke:n,fillArea:a,areaOpacity:s=.3,styleRules:l,ruleContext:c}=e;return(e,u)=>{let d,h={strokeWidth:t},f=!0===a||Array.isArray(a)&&null!=u&&a.includes(u);return n?d=n(e,u):i?r&&(d=Ae(e,i,r)):d=o||Mf,void 0!==d&&(h.stroke=d,f&&(h.fill=d,h.fillOpacity=s)),l?.length&&Object.assign(h,Oe(e,l,c?c(e,u):{value:void 0,category:u})),h}}function Ne(e){if("A"===e.__diffWinner||"B"===e.__diffWinner)return e.__diffWinner;let t=(e.__diffSegment??"")+"";return"line-A"===t||t.endsWith("-A")?"A":"B"}function Ee(e,t){return Fe(e,t,e=>{let t=Number(e.__x),i=Number(e.__y);return{value:Number.isFinite(i)?i:void 0,x:Number.isFinite(t)?t:void 0,y:Number.isFinite(i)?i:void 0,category:Ne(e)}},e=>e.__sourceDatum?{...e.__sourceDatum,...e}:e)}function Be(e){let{seriesAColor:t,seriesBColor:i,areaOpacity:r,styleRules:o}=e;return Ee(e=>({fill:"A"===Ne(e)?t:i,stroke:"none",fillOpacity:r}),o)}function We(e){let{seriesAColor:t,seriesBColor:i,lineWidth:r,styleRules:o}=e;return Ee(e=>({stroke:"A"===Ne(e)?t:i,strokeWidth:r,fill:"none"}),o)}function je(e,t=Rf){if(e)return!0===e?t:"stops"in e?Array.isArray(e.stops)?e:void 0:"colorStops"in e?Array.isArray(e.colorStops)?{stops:e.colorStops.map(({offset:e,color:t})=>({offset:e,color:t}))}:void 0:{stops:[{offset:0,opacity:e.topOpacity??t.stops[0]?.opacity??.8},{offset:1,opacity:e.bottomOpacity??t.stops.at(-1)?.opacity??.05}]}}function Ye(e){return e?je(e):void 0}function Xe(e,t,i){return"function"==typeof e?e(i):i[e||t]}function qe(e){return e instanceof Date?e.getTime():Number(e)}function Ge(e,t){return cf(1===t?.5:e/(t-1))}function Ve(e){let t={};return void 0!==e.stroke&&(t.stroke=e.stroke),void 0!==e.strokeWidth&&(t.strokeWidth=e.strokeWidth),void 0!==e.opacity&&(t.opacity=e.opacity),t}function He(e,t){let i=function(e){if(!e)return;let t="boolean"==typeof e?{}:"string"==typeof e?{method:e}:e;return{type:"trend",method:t.method??"linear",...null!=t.bandwidth&&{bandwidth:t.bandwidth},...null!=t.order&&{order:t.order},...null!=t.color&&{color:t.color},...null!=t.strokeWidth&&{strokeWidth:t.strokeWidth},...null!=t.strokeDasharray&&{strokeDasharray:t.strokeDasharray},...null!=t.label&&{label:t.label}}}(t),r=Array.isArray(e)?e:void 0;return i?[i,...r??[]]:r}function Ue(e){if(!e?.colors)return;let 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 Ke(e){if(!e)return Lf;if("string"==typeof e)return"light"===e?Lf:"dark"===e?Tf:"high-contrast"===e?Cf:(Object.prototype.hasOwnProperty.call(Of,t=e)?Of[t]:void 0)||Lf;var t;let i="dark"===e.mode?Tf:Lf;return function(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:If}}),e.accessibility.highContrast){let 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}({...i,...e,colors:{...i.colors,...e.colors||{}},typography:{...i.typography,...e.typography||{}},tooltip:{...i.tooltip,...e.tooltip||{}}})}function Ze(e){return{background:e.colors.background,text:e.colors.text,textSecondary:e.colors.textSecondary,grid:e.colors.grid,border:e.colors.border,primary:e.colors.primary,fontFamily:e.typography.fontFamily,titleSize:e.typography.titleSize,labelSize:e.typography.labelSize,tickSize:e.typography.tickSize,categorical:e.colors.categorical,annotation:e.colors.annotation??e.colors.text,legendSize:e.typography.legendSize??e.typography.labelSize,legendFontFamily:e.typography.legendFontFamily??e.typography.fontFamily,legendFontWeight:e.typography.legendFontWeight,titleFontSize:e.typography.titleFontSize??e.typography.titleSize,titleFontFamily:e.typography.titleFontFamily??e.typography.fontFamily,titleFontWeight:e.typography.titleFontWeight??"bold",tickFontFamily:e.typography.tickFontFamily??e.typography.fontFamily}}function Qe(e){return e.axes??[{orient:"bottom",visible:!1!==e.showTimeAxis},{orient:"left",visible:!1!==e.showValueAxis}]}function Je(e){let t=1/0,i=-1/0;for(let r of e)t>r&&(t=r),r>i&&(i=r);return[t,i]}function et(e,t=-1/0){let i=t;for(let t of e)t>i&&(i=t);return i}function tt(e){return Math.round(100*e)/100}function it(e,t=2){let i=[],r=[],o=t+1;for(let t=0;o>t;t++){let n=0;for(let[i,r]of e)null!==r&&(n+=i**t*r);i.push(n);let a=[];for(let i=0;o>i;i++){let r=0;for(let[o,n]of e)null!==n&&(r+=o**(t+i));a.push(r)}r.push(a)}r.push(i);let n=function(e,t){let i=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(i[e][o])>Math.abs(i[e][t])&&(t=o);for(let o=e;r+1>o;o++){let r=i[o][e];i[o][e]=i[o][t],i[o][t]=r}for(let t=e+1;r>t;t++)for(let o=r;o>=e;o--)i[o][t]-=i[o][e]*i[e][t]/i[e][e]}for(let e=r-1;e>=0;e--){let t=0;for(let n=e+1;r>n;n++)t+=i[n][e]*o[n];o[e]=(i[r][e]-t)/i[e][e]}return o}(r,o).map(tt);return{points:e.map(([e])=>[tt(e),tt(n.reduce((t,i,r)=>t+i*e**r,0))]),equation:[...n].reverse()}}function rt(e){let t=e.length,i=0,r=0,o=0,n=0;for(let[t,a]of e)i+=t,r+=a,o+=t*t,n+=t*a;let a=t*o-i*i;if(1e-12>Math.abs(a))return null;let s=(t*n-i*r)/a,l=(r-s*i)/t;return e=>l+s*e}function ot(e,t){let i=e.length,r=e.map(([e,i])=>i-t(e)).reduce((e,t)=>e+t*t,0),o=Math.sqrt(r/Math.max(i-2,1)),n=e.reduce((e,t)=>e+t[0],0)/i,a=e.reduce((e,t)=>e+(t[0]-n)**2,0);return{se:o,meanX:n,ssX:a}}function nt(e){return.99>e?.95>e?.9>e?1:1.645:1.96:2.576}function at(e,t,i,r){let o=t.uncertaintyOpacity,n=t.confidenceAccessor;if(!o&&!n)return;let a="object"==typeof o?o:{},s=a.min??.15,l=a.max??1;if(n){let t="function"==typeof n?n:e=>e[n];for(let i of e){let e=t(i);null!=e&&Number.isFinite(e)&&(i[Df]=s+Math.max(0,Math.min(1,e))*(l-s))}return}let c=e.map(e=>{let t=i(e),o=r(e);return null!=t&&null!=o&&Number.isFinite(t)&&Number.isFinite(o)?Math.abs(t-o):NaN}),u=c.filter(e=>Number.isFinite(e));if(0===u.length)return;let[d,h]=Je(u),f=h-d;e.forEach((e,t)=>{let i=c[t];Number.isFinite(i)&&(e[Df]=l-(f>0?(i-d)/f:0)*(l-s))})}function st(e,t){return"function"==typeof t?t(e):!!e[t]}function lt(e,t,i){let r=e[t],o=e[i];return null==r||null==o||Number.isNaN(r)||Number.isNaN(o)}function ct(e){let t=e.xAccessor||"x",i=e.yAccessor||"y",r=e.lineBy,o=e.colorBy||r,n=Array.isArray(e.data)?me(e.data).filter(e=>!!e&&"object"==typeof e):[],a=function(e,t,i){let r="function"==typeof t,o="function"==typeof i,n=r?zf:t,a=o?Nf:i;return r||o?{xKey:n,yKey:a,rows:e.map(e=>{let n={...e};return r&&(n[zf]=t(e)),o&&(n[Nf]=i(e)),n})}:{rows:e,xKey:n,yKey:a}}(n,t,i);n=a.rows;let s,l=a.xKey,c=a.yKey,u=Array.isArray(e.annotations)?[...e.annotations]:[],d="string"==typeof r||"function"==typeof r?r:void 0,h=e.baseLineStyle;if(e.forecast){let t=function(e,t,i,r,o){return(n=r).isTraining||n.isForecast||n.isAnomaly||n.upperBounds||n.lowerBounds?function(e,t,i,r,o){let{isTraining:n,isForecast:a,isAnomaly:s,upperBounds:l,lowerBounds:c,color:u="#6366f1",bandOpacity:d=.15,anomalyColor:h="#ef4444",anomalyRadius:f=6,label:p}=r,y=e.map(e=>{let t="observed";return a&&st(e,a)?t="forecast":n&&st(e,n)&&(t="training"),{...e,[Ff]:t}}),g=r._groupBy,m=[];if(g){let e=new Map;for(let t of y){let i=t[g]??"__default";e.has(i)||e.set(i,[]),e.get(i).push(t)}let t=[];for(let[,i]of e)for(let e=0;i.length-1>e;e++)i[e][Ff]!==i[e+1][Ff]&&(t.push({...i[e+1],[Ff]:i[e][Ff]}),t.push({...i[e],[Ff]:i[e+1][Ff]}));m.push(...y,...t)}else for(let e=0;y.length>e;e++)m.push(y[e]),y.length-1>e&&y[e][Ff]!==y[e+1][Ff]&&(m.push({...y[e+1],[Ff]:y[e][Ff]}),m.push({...y[e],[Ff]:y[e+1][Ff]}));if(r.trainUnderline){let e=[];for(let t of m)"training"===t[Ff]&&e.push({...t,[Ff]:"training-base"});m.unshift(...e)}let b=[];if(l&&c){let e="string"==typeof l?l:"__envUpper",t="string"==typeof c?c:"__envLower";if("function"==typeof l||"function"==typeof c)for(let i of m)"function"==typeof l&&(i[e]=l(i)),"function"==typeof c&&(i[t]=c(i));b.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:u,fillOpacity:d,label:p})}if(r.uncertaintyOpacity||r.confidenceAccessor){let e=l?"function"==typeof l?l:e=>e[l]:()=>{},t=c?"function"==typeof c?c:e=>e[c]:()=>{};at(m.filter(e=>"forecast"===e[Ff]),r,e,t)}if(s){let e=r.anomalyStyle,t={type:"highlight",filter:e=>st(e,s)};e?(t.style=e,t.r=f):"function"==typeof h?(t.style=e=>{let t=h(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=f):(t.color=h,t.r=f,t.style={stroke:h,strokeWidth:1.5,fill:h,fillOpacity:.7}),b.push(t)}return o&&b.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:b}}(e,0,0,r,o):function(e,t,i,r,o){let{trainEnd:n,steps:a=10,confidence:s=.95,color:l="#6366f1",bandOpacity:c=.15,label:u}=r;if(null==n)return{processedData:e,annotations:[]};let d=[],h=[];for(let i of e)i[t]>n?h.push({...i,[Ff]:"observed"}):d.push({...i,[Ff]:"training"});let f=d.map(e=>[e[t],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),p=[],y=[];if(f.length>=3){let o=f.length,n=rt(f);if(n){let{se:d,meanX:h,ssX:g}=ot(f,n),m=nt(s),b=et(e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e))),x=f.length>1?(f[o-1][0]-f[0][0])/(o-1):1;for(let e=1;a>=e;e++){let r=b+e*x,a=n(r),s=d*Math.sqrt(1+1/o+(g>0?(r-h)**2/g:0))*m;y.push({[t]:r,[i]:a,[Ff]:"forecast",__forecastUpper:a+s,__forecastLower:a-s})}at(y,r,e=>e.__forecastUpper,e=>e.__forecastLower),p.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:l,fillOpacity:c,label:u})}}p.push({type:"x-threshold",x:n,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),o&&p.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});let g=[];if(g.push(...d),d.length>0&&h.length>0&&g.push({...d[d.length-1],[Ff]:"observed"}),g.push(...h),y.length>0){let e=h.length>0?h[h.length-1]:d[d.length-1];e&&g.push({...e,[Ff]:"forecast"}),g.push(...y)}return{processedData:g,annotations:p}}(e,t,i,r,o);var n}(n,l,c,r&&"string"==typeof r&&"object"==typeof e.forecast?{...e.forecast,_groupBy:r}:e.forecast,e.anomaly);if(n=t.processedData,u.push(...t.annotations),s=function(e,t,i){let r=i.upperBounds,o=i.lowerBounds;if(!r&&!o)return;let n="function"==typeof r?r:"string"==typeof r?e=>e[r]:null,a="function"==typeof o?o:"string"==typeof o?e=>e[o]:null,s=1/0,l=-1/0;for(let i of e){let e=Number(i[t]);if(Number.isFinite(e)&&(s>e&&(s=e),e>l&&(l=e)),n){let e=n(i);null!=e&&Number.isFinite(e)&&(e>l&&(l=e),s>e&&(s=e))}if(a){let e=a(i);null!=e&&Number.isFinite(e)&&(s>e&&(s=e),e>l&&(l=e))}}return Number.isFinite(s)&&Number.isFinite(l)?[s,l]:void 0}(n,c,e.forecast),r&&"string"==typeof r?(n=n.map(e=>({...e,[Ef]:`${e[r]}__${e[Ff]||"observed"}`})),d=Ef):d=Ff,e.baseLineStyle){let t=function(e,t){let i=t.trainDasharray??"8,4",r=t.forecastDasharray??"4,4",o=t.color||"#6366f1",n=t.trainOpacity,a=t.forecastOpacity,s=t.trainStroke,l=t.trainLinecap,c=t.trainUnderline;return t=>{let u=e(t),d=t[Ff];if("training"===d){let e=u.stroke;return"darken"===s?e=function(e,t=.5){let i=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!i)return e;let r=Math.round(parseInt(i[1],16)*(1-t)),o=Math.round(parseInt(i[2],16)*(1-t)),n=Math.round(parseInt(i[3],16)*(1-t));return`#${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}(u.stroke||"#666",.5):s&&(e=s),{...u,stroke:e,strokeDasharray:i,...l&&{strokeLinecap:l},...null!=n&&{strokeOpacity:n}}}if("training-base"===d){let e=u.stroke||"#666";return"lighten"===c&&(e=function(e,t=.5){let i=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!i)return e;let r=Math.round(parseInt(i[1],16)+(255-parseInt(i[1],16))*t),o=Math.round(parseInt(i[2],16)+(255-parseInt(i[2],16))*t),n=Math.round(parseInt(i[3],16)+(255-parseInt(i[3],16))*t);return`#${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}(e,.4)),{...u,stroke:e,strokeDasharray:void 0}}if("forecast"===d){let e=t[Df]??a;return{...u,stroke:o,strokeDasharray:r,...null!=e&&{strokeOpacity:e}}}return u}}(t=>e.baseLineStyle(t),e.forecast);h=e=>t(e)}}else e.anomaly&&u.push(...(f=e.anomaly,[{type:"anomaly-band",threshold:f.threshold??2,showBand:!1!==f.showBand,fill:f.bandColor||"#6366f1",fillOpacity:f.bandOpacity??.1,anomalyColor:f.anomalyColor||"#ef4444",anomalyRadius:f.anomalyRadius??6,label:f.label}]));var f;if(e.gapStrategy){if("function"==typeof d){let e=d;n=n.map(t=>({...t,__semiotic_gapGroup:e(t)})),d="__semiotic_gapGroup"}let t=function(e,t,i,r,o){let n=new Map;for(let t of e){let e=o?(t[o]??"")+"":"__single";n.has(e)||n.set(e,[]),n.get(e).push(t)}if("interpolate"===t){let e=[];for(let[,t]of n)for(let o of t)lt(o,i,r)||e.push(o);return{rows:e,groupKey:o}}if("zero"===t){let e=[];for(let[,t]of n)for(let o of t)lt(o,i,r)?e.push({...o,[r]:0}):e.push(o);return{rows:e,groupKey:o}}let a=[],s="_gapSegment";for(let[e,t]of n){let o=0,n=[],l=()=>{if(0===n.length)return;let t="__single"===e?"__seg"+o:`${e}__seg${o}`;for(let e of n)a.push({...e,[s]:t});n=[],o++};for(let e of t)lt(e,i,r)?l():n.push(e);l()}return{rows:a,groupKey:s}}(n,e.gapStrategy,l,c,"string"==typeof d?d:void 0);n=t.rows,t.groupKey&&(d=t.groupKey)}let p;if(e.directLabel){let t=function(e,t,i,r,o,n,a,s){if(!t||!i)return{annotations:[]};let l="object"==typeof t?t:{},c=l.position||"end",u=l.fontSize||11,d="function"==typeof i?i:e=>e[i],h=new Map;for(let t of e){let e=d(t);if(null==e)continue;let i=e+"";""!==i&&(h.has(i)||h.set(i,[]),h.get(i).push(t))}let f=new Map;for(let[e,t]of h)t.sort((e,t)=>Number(e[r])-Number(t[r])),f.set(e,"end"===c?t[t.length-1]:t[0]);let p=Me(Array.from(f.entries()).map(([e])=>({__lbl:e})),"__lbl",n??a),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?Ae({__lbl:e},"__lbl",p):s||Mf,fontSize:u}));y.sort((e,t)=>Number(e[o])-Number(t[o]));for(let e=1;y.length>e;e++){let t=y[e-1],i=y[e],r=Number(t[o])+t.dy;u+2>Math.abs(Number(i[o])+i.dy-r)&&(i.dy+=u+2)}let 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}}}(n,e.directLabel,"string"==typeof o||"function"==typeof o?o:void 0,l,c,e.colorScheme,e.themeCategorical,e.color);u.push(...t.annotations),p=t.marginExtra}return{data:n,xAccessor:"function"==typeof t?l:t,yAccessor:"function"==typeof i?c:i,groupAccessor:d,colorAccessor:o,annotations:u,lineStyle:h,yExtent:s,marginExtra:p}}function ut(e,t,i,r,o){let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=Ke(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrScatterColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrScatterColorBy:t(e)})):n,u=t?Me(c,l,s):void 0,d=o.sizeBy,h=Array.isArray(o.sizeRange)?o.sizeRange:[3,15],f=d?n.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],p=f.length?Je(f):void 0,y=Ie(o.xAccessor,o.yAccessor),g=o.styleRules;return e=>{let i={fill:t&&u?Ae(e,t,u):"string"==typeof o.color?o.color:Mf,fillOpacity:"number"==typeof o.pointOpacity?o.pointOpacity:.8,r:d?_e(e,d,h,p):"number"==typeof o.pointRadius?o.pointRadius:5};return g?.length&&Object.assign(i,Oe(e,g,y(e))),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 dt(e,t,i,r,o){let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=Ke(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrBubbleColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrBubbleColorBy:t(e)})):n,u=t?Me(c,l,s):void 0,d=o.sizeBy,h=Array.isArray(o.sizeRange)?o.sizeRange:[5,40],f=d?n.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],p=f.length?Je(f):void 0,y=Ie(o.xAccessor,o.yAccessor),g=o.styleRules;return e=>{let i={fill:t&&u?Ae(e,t,u):"string"==typeof o.color?o.color:Mf,fillOpacity:"number"==typeof o.bubbleOpacity?o.bubbleOpacity:.6,r:d?_e(e,d,h,p):h[0],stroke:o.bubbleStrokeColor??"white",strokeWidth:o.bubbleStrokeWidth??1};return g?.length&&Object.assign(i,Oe(e,g,y(e))),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 ht(e,t){return t?.length&&Object.defineProperty(e,Hf,{configurable:!0,enumerable:!1,value:t}),e}function ft(e){return e?.[Hf]}function pt(e){return e.parentLine?ht({...e.parentLine,...e},ft(e)):e}function yt(e){return ht({...e[0]},e.map(pt))}function gt(e){return!!e&&ft(e)?.[0]===e}function mt(e){let t={"--semiotic-bg":e.colors.background,"--semiotic-text":e.colors.text,"--semiotic-text-secondary":e.colors.textSecondary,"--semiotic-grid":e.colors.grid,"--semiotic-border":e.colors.border,"--semiotic-cell-border":e.colors.cellBorder||e.colors.border,"--semiotic-primary":e.colors.primary,"--semiotic-font-family":e.typography.fontFamily,"--semiotic-secondary":e.colors.secondary||e.colors.primary,"--semiotic-surface":e.colors.surface||e.colors.background};e.colors.categorical.forEach((e,i)=>{t["--semiotic-category-"+(i+1)]=e}),e.colors.focus&&(t["--semiotic-focus"]=e.colors.focus),e.colors.selection&&(t["--semiotic-selection-color"]=e.colors.selection),null!=e.colors.selectionOpacity&&(t["--semiotic-selection-opacity"]=e.colors.selectionOpacity+""),e.colors.diverging&&(t["--semiotic-diverging"]=e.colors.diverging),e.colors.annotation&&(t["--semiotic-annotation-color"]=e.colors.annotation),e.colors.success&&(t["--semiotic-success"]=e.colors.success),e.colors.danger&&(t["--semiotic-danger"]=e.colors.danger),e.colors.warning&&(t["--semiotic-warning"]=e.colors.warning),e.colors.error&&(t["--semiotic-error"]=e.colors.error),e.colors.info&&(t["--semiotic-info"]=e.colors.info),e.tooltip?.background&&(t["--semiotic-tooltip-bg"]=e.tooltip.background),e.tooltip?.text&&(t["--semiotic-tooltip-text"]=e.tooltip.text),e.tooltip?.borderRadius&&(t["--semiotic-tooltip-radius"]=e.tooltip.borderRadius),e.tooltip?.fontSize&&(t["--semiotic-tooltip-font-size"]=e.tooltip.fontSize),e.tooltip?.shadow&&(t["--semiotic-tooltip-shadow"]=e.tooltip.shadow),e.borderRadius&&(t["--semiotic-border-radius"]=e.borderRadius);let i=e.typography.legendSize??e.typography.labelSize;null!=i&&(t["--semiotic-legend-font-size"]=i+"px"),null!=e.typography.legendFontFamily&&(t["--semiotic-legend-font-family"]=e.typography.legendFontFamily),null!=e.typography.legendFontWeight&&(t["--semiotic-legend-font-weight"]=e.typography.legendFontWeight+"");let r=e.typography.titleFontSize??e.typography.titleSize;return null!=r&&(t["--semiotic-title-font-size"]=r+"px"),null!=e.typography.titleFontFamily&&(t["--semiotic-title-font-family"]=e.typography.titleFontFamily),null!=e.typography.titleFontWeight&&(t["--semiotic-title-font-weight"]=e.typography.titleFontWeight+""),null!=e.typography.tickFontFamily&&(t["--semiotic-tick-font-family"]=e.typography.tickFontFamily),null!=e.typography.tickSize&&(t["--semiotic-tick-font-size"]=e.typography.tickSize+"px"),null!=e.typography.labelSize&&(t["--semiotic-axis-label-font-size"]=e.typography.labelSize+"px"),t}function bt(e,t,i,r,o){if(e)return e;if(i&&"object"==typeof i&&!Array.isArray(i)){let e=Se(i,r);if(e)return e}let n;if(Array.isArray(i))n=i;else if(t&&t.length>0)n=t;else if("string"==typeof i){let e=Af[i];Array.isArray(e)&&(n=e)}return n&&0!==n.length?null!=r?(o.has(r)||o.set(r,o.size),n[o.get(r)%n.length]):n[0]:Mf}function xt(e,t,i){return"function"==typeof e?e(t,i):t[e]}function vt(e,t){if(!e?.length)return;let i=new Map(t.map((e,t)=>[he(e),t]));return e.map(e=>{let t={...e},r=r=>{if(!(r in e))return;let o=i.get(he(e[r]));void 0!==o&&(t[r]=o)};return r("x"),r("x0"),r("x1"),"string"==typeof e.type&&("x-threshold"===e.type||"x"===e.type)&&r("value"),t})}function wt(e,t,i,r,o){let n=1-o;return n*n*n*e+3*n*n*o*t+3*n*o*o*i+o*o*o*r}function kt(e,t,i,r,o){let n=1-o;return 3*n*n*(t-e)+6*n*o*(i-t)+3*o*o*(r-i)}function At(e,t,i,r,o){let n=[],a=(e.x+t.x)/2;for(let s=0;o>=s;s++){let l,c,u,d,h=s/o;"linear"===r?(l=e.x+(t.x-e.x)*h,c=e.y+(t.y-e.y)*h,u=t.x-e.x,d=t.y-e.y):(l=wt(e.x,a,a,t.x,h),c=wt(e.y,e.y,t.y,t.y,h),u=kt(e.x,a,a,t.x,h),d=kt(e.y,e.y,t.y,t.y,h)),n.push({x:l,y:c,dx:u,dy:d,radius:e.radius+(t.radius-e.radius)*h,datumIndex:.5>h?i:i+1})}return n}function St(e,t={}){let i=[],r=[],o=[];if(2>e.length)return{topPath:i,bottomPath:r,datumIndices:o};let n=t.curve??"smooth",a=Math.max(2,Math.floor(t.samplesPerSegment??12));for(let t=0;e.length-1>t;t++){let s=At(e[t],e[t+1],t,n,a);for(let e=0===t?0:1;s.length>e;e++){let t=s[e],n=Math.hypot(t.dx,t.dy)||1,a=-t.dy/n,l=t.dx/n,c=Math.max(0,t.radius);i.push([t.x+a*c,t.y+l*c]),r.push([t.x-a*c,t.y-l*c]),o.push(t.datumIndex)}}return{topPath:i,bottomPath:r,datumIndices:o}}function Mt({datum:e,x:t,y:i,side:r,color:o,highlighted:n,labelStyle:a}){let s=function(){let e=(Zf??(Zf=Uf.createContext(null)),Zf);return Uf.useContext(e)??Qf}(),l=s.isActive&&!s.predicate(e),c="function"==typeof a?a(e.__bumpRaw):a;return Jf("text",{className:"semiotic-bump-label",x:t+("end"===r?8:-8),y:i,dy:"0.35em",textAnchor:"end"===r?"start":"end",fill:o,fillOpacity:l?.16:1,fontWeight:n?650:450,fontSize:12,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-axis-label-font-size, 12px)",...c},children:e.__bumpSeries})}function _t(e,t,i){let[r,o]=t,[n,a]=i;return o===r?(n+a)/2:n+(a-n)*Math.max(0,Math.min(1,(e-r)/(o-r)))}function $t(e){let t=e.__bumpXValue instanceof Date?e.__bumpXValue.getTime():Number(e.__bumpXValue);return{value:e.__bumpValue,x:Number.isFinite(t)?t:void 0,y:e.__bumpValue,category:e.__bumpSeries}}function Pt(e){let t=e.config,i=new Map;for(let t of e.data){let e=i.get(t.__bumpSeries)??[];e.push(t),i.set(t.__bumpSeries,e)}let r=t.seriesOrder.filter(e=>i.has(e)).sort((e,r)=>(i.get(e)?.[0]?.__bumpHighlighted?1:0)-(i.get(r)?.[0]?.__bumpHighlighted?1:0)||t.seriesOrder.indexOf(e)-t.seriesOrder.indexOf(r)),o=[],n=[],a=[];for(let n of r){let r=(i.get(n)??[]).sort((e,t)=>e.x-t.x);if(2>r.length)continue;let s=r[0].__bumpHighlighted,l=(t.colorMap&&Se(t.colorMap,n))??e.resolveColor(r[0].__bumpSeries,r[0]),c=t.color??(s?l:t.neutralColor??e.theme.semantic.textSecondary??e.theme.semantic.border??l),u=r.map(i=>({x:e.scales.x(i.x),y:e.scales.y(i.y),radius:t.ribbon?_t(i.__bumpValue,t.valueExtent,t.ribbonSizeRange)/2:Math.max(.5,t.lineWidth/2)})),d=St(u,{curve:t.curve,samplesPerSegment:t.samplesPerSegment}),h={fill:c,fillOpacity:1,opacity:s?t.ribbon?t.ribbonOpacity:t.lineOpacity:Math.min(t.ribbon?t.ribbonOpacity:t.lineOpacity,.58)};t.styleRules?.length&&Object.assign(h,Oe(r[0].__bumpRaw,t.styleRules,$t(r[0]))),t.areaStyle&&Object.assign(h,t.areaStyle(r[0].__bumpRaw)??{}),void 0!==t.stroke&&(h.stroke=t.stroke),void 0!==t.strokeWidth&&(h.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(h.opacity=t.opacity),o.push({type:"area",topPath:d.topPath,bottomPath:d.bottomPath,style:h,datum:d.datumIndices.map(e=>r[e]),accessibleDatum:r.map(e=>e.__bumpRaw),accessibility:{label:n+" ranking trajectory",tableFields:r.map(e=>e.__bumpRaw)},group:n,interactive:!0}),t.showPoints&&r.forEach((e,i)=>{let r={fill:c,stroke:"none",opacity:s?1:.75};t.styleRules?.length&&Object.assign(r,Oe(e.__bumpRaw,t.styleRules,$t(e))),t.pointStyle&&Object.assign(r,t.pointStyle(e.__bumpRaw)??{}),void 0!==t.stroke&&(r.stroke=t.stroke),void 0!==t.strokeWidth&&(r.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(r.opacity=t.opacity),o.push({type:"point",x:u[i].x,y:u[i].y,r:r.r??t.pointRadius,style:r,datum:e,accessibleDatum:e.__bumpRaw,accessibility:{label:`${n}, rank ${e.__bumpRank}, value ${e.__bumpValue}`},pointId:`${n}:${e.x}`})});let f=!0===t.showLabels?"end":t.showLabels,p=(e,i,r)=>{let o=null==t.labelPriorityAccessor?void 0:"function"==typeof t.labelPriorityAccessor?t.labelPriorityAccessor(e.__bumpRaw):Number(e.__bumpRaw[t.labelPriorityAccessor]);a.push({id:`${n}\0${r}`,datum:e,x:u[i].x,y:u[i].y,side:r,rank:e.__bumpRank,highlighted:s,priority:Number.isFinite(o)?o:void 0,color:"string"==typeof h.fill?h.fill:c})};("start"===f||"both"===f)&&p(r[0],0,"start"),("end"===f||"both"===f||"auto"===f)&&p(r.at(-1),r.length-1,"end")}let s=function(e,t,i,r){let o=Math.max(1,Math.floor(t/18)),n="auto"===i?Number.isFinite(r)&&(r??0)>=0?Math.min(o,Math.floor(r)):o:1/0,a=e.map((e,t)=>({candidate:e,index:t})).sort((e,t)=>(t.candidate.priority??0)-(e.candidate.priority??0)||Number(t.candidate.highlighted)-Number(e.candidate.highlighted)||e.candidate.rank-t.candidate.rank||e.index-t.index),s=[];for(let{candidate:e}of a){if(s.length>=n)break;s.some(t=>t.side===e.side&&14>Math.abs(t.y-e.y))||s.push(e)}return new Set(s.map(e=>e.id))}(a,e.dimensions.plot.height,"auto"!==(!0===t.showLabels?"end":t.showLabels)||"auto",t.maxLabels);for(let e of a)s.has(e.id)&&n.push(Jf(Mt,{datum:e.datum,x:e.x,y:e.y,side:e.side,color:e.color,highlighted:e.highlighted,labelStyle:t.labelStyle},e.id));return{nodes:o,overlays:n.length?Jf("g",{className:"semiotic-bump-labels",children:n}):void 0,restyle:(e,t)=>{let i=function(e){let t=Array.isArray(e.datum)?e.datum[0]:e.datum;return t&&"object"==typeof t&&"__bumpSeries"in t?t:void 0}(e);if(t?.isActive&&i&&!t.predicate(i))return{opacity:.14}}}}function Rt(e,t){let i=Re(e),r=t.map((e,t)=>({label:e.label||"Series "+(t+1),readY:Re(e.yAccessor)}));return(e,t)=>{let o=(e[ip]??t??"")+"",n=(r.find(e=>e.label===o)??r[0])?.readY(e);return{value:n,x:i(e),y:n,category:o||void 0}}}function It(e,t,i,r,o){let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=Ke(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrAreaColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrAreaColorBy:t(e)})):n,u=t?Me(c,l,s):void 0,d=!1!==o.showLine,h="number"==typeof o.lineWidth?o.lineWidth:2,f="number"==typeof o.areaOpacity?o.areaOpacity:.7,p=Re(o.yAccessor),y=o.styleRules;return(e,i)=>{let r=t&&u?Ae(e,t,u):"string"==typeof o.color?o.color:Mf,n={fill:r,fillOpacity:f,stroke:d?r:"none",...d&&{strokeWidth:h}};return y?.length&&Object.assign(n,Oe(e,y,{value:p(e),category:i})),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}}function Lt(e,t,i,r,o){if(!o.showPoints)return;let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=Ke(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrPointColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrPointColorBy:t(e)})):n,u=t?Me(c,l,s):void 0,d="number"==typeof o.pointRadius?o.pointRadius:3;return e=>{let i=t&&u?Ae(e,t,u):"string"==typeof o.color?o.color:Mf;return{r:d,fill:i,stroke:"none"}}}function Tt(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function Ct(e,t){if("function"==typeof e)return e;let i=e||t;return e=>e[i]}function Ot(e){return Math.max(0,Math.min(1,e))}function Ft(e){let 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)]}let i=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(i){let e=[Number(i[1]),Number(i[2]),Number(i[3])];if(e.every(Number.isFinite))return e}return null}function Dt(e,t,i){let r=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(i)}`}function zt(e,t,i){let r=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Ot(e.offset),color:e.color??i,opacity:null==e.opacity?1:Ot(e.opacity)})).sort((e,t)=>e.offset-t.offset);if(0===r.length)return"#999999";let o=e=>{if(1===e.opacity)return e.color;let t=Ft(e.color);return t?`rgba(${t[0]},${t[1]},${t[2]},${e.opacity})`:e.color};if(1===r.length)return o(r[0]);let n=Ot(t);if(r[0].offset>=n)return o(r[0]);if(n>=r[r.length-1].offset)return o(r[r.length-1]);for(let e=0;r.length-1>e;e++){let t=r[e],i=r[e+1];if(t.offset>n||n>i.offset)continue;let a=i.offset-t.offset,s=a>0?(n-t.offset)/a:0,l=Ft(t.color),c=Ft(i.color);if(!l||!c)return o(.5>s?t:i);let[u,d,h]=l,[f,p,y]=c,g=u+(f-u)*s,m=d+(p-d)*s,b=h+(y-h)*s,x=t.opacity+(i.opacity-t.opacity)*s;return 1===x?Dt(g,m,b):`rgba(${Math.round(g)},${Math.round(m)},${Math.round(b)},${x})`}return o(r[r.length-1])}function Nt(e,t,i){return null==i?`${e}-${t}`:`${e}-${t}-${i}`}function Et(e=240){let t=360-e,i=180+t/2,r=i*Math.PI/180;return{sweepRad:e*Math.PI/180,gapDeg:t,startAngleDeg:i,startAngleRad:r,offsetRad:-Math.PI/2+r}}function Bt(e){return je(e)}function Wt(e,t,i,r,o,n){let a=Ke(r.theme).colors.categorical,s=i??r.colorScheme,l=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],c="string"==typeof t?t:"__ssrColorBy",u="function"==typeof t?l.map(e=>({...e,__ssrColorBy:t(e)})):l,d=t?Me(u,c,s??a):void 0,h=bt("string"==typeof o.color?o.color:void 0,a,s,void 0,new Map),f=n??Re(o.valueAccessor??"value"),p=o.styleRules,y=r.pieceStyle;return(e,i)=>{let r={fill:t&&d?Ae(e,t,d):h};return p?.length&&Object.assign(r,Oe(e,p,{value:f(e,i),category:i})),"function"==typeof y?Object.assign(r,y(e,i)||{}):y&&"object"==typeof y&&Object.assign(r,y),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 jt(e,t,i,r,o,n="median",a=.8){let s=Re(o.valueAccessor??"value"),l=Wt(e,t,i,r,o,e=>"number"==typeof e[n]?e[n]:s(e));return(e,t)=>{let i=l(e,t);return void 0===i.fillOpacity&&(i.fillOpacity=a),void 0===i.stroke&&(i.stroke=i.fill),i}}function Yt(e,t,i,r,o){return jt(e,t,i,r,o,"median",.6)}function Xt(e,t,i,r,o){let n=Wt(e,t,i,r,o),a="number"==typeof o.dotRadius?o.dotRadius:5;return(e,t)=>({r:a,fillOpacity:.8,...n(e,t)})}function qt(e,t,i,r,o){let n=Wt(e,t,i,r,o),a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=o.sizeBy,l=Array.isArray(o.sizeRange)?o.sizeRange:[3,8],c=s?a.map(e=>"function"==typeof s?s(e):Number(e[s])).filter(Number.isFinite):[],u=c.length?Je(c):void 0,d="number"==typeof o.pointRadius?o.pointRadius:4,h="number"==typeof o.pointOpacity?o.pointOpacity:.7;return(e,t)=>({r:s?_e(e,s,l,u):d,fillOpacity:h,...n(e,t)})}function Gt(e="static"){return jp[e]??jp.static}function Vt(e){return"fatal"===e.severity||"warn"===e.severity?e.severity:Yp.has(e.kind)?"fatal":"warn"}function Ht(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`:"duplicate-node"===e.kind?`node id "${e.id}" is duplicated`:"duplicate-edge"===e.kind?`edge id "${e.id}" is duplicated`:"invalid-system-time"===e.kind?`edge ${e.id} has an invalid systemInTime or systemOutTime`:e.kind}function Ut(e){let{desired:t,minGaps:i,weights:r}=e,o=t.length;if(0===o)return[];if(i.length!==Math.max(0,o-1))throw Error("placeWithMinGap: minGaps must have desired.length - 1 entries");let n=Array(o).fill(0);for(let e=1;o>e;e++)n[e]=n[e-1]+Math.max(0,Number.isFinite(i[e-1])?i[e-1]:0);let a=[];for(let e=0;o>e;e++){let i=Math.max(Number.EPSILON,Number.isFinite(r?.[e])?r[e]:1),o=(Number.isFinite(t[e])?t[e]:0)-n[e];for(a.push({start:e,end:e,weight:i,mean:o});a.length>1;){let e=a[a.length-1],t=a[a.length-2];if(e.mean>=t.mean)break;let i=t.weight+e.weight;a.splice(a.length-2,2,{start:t.start,end:e.end,weight:i,mean:(t.mean*t.weight+e.mean*e.weight)/i})}}let s=Number.isFinite(e.min)?e.min:-1/0,l=Number.isFinite(e.max)?e.max-n[o-1]:1/0,c=s>l?s:l,u=Array(o);for(let e of a){let t=Math.max(s,Math.min(c,e.mean));for(let i=e.start;e.end>=i;i++)u[i]=t+n[i]}return u}function Kt(e,t){let i=0,r=e.length-1,o=-1;for(;r>=i;){let n=i+r>>>1;e[n].at>t?r=n-1:(o=n,i=n+1)}return 0>o?{at:t,before:0,after:0}:e[o]}function Zt(e,t=0){if(0===e.length)return{adjacentClearance:[],positions:[]};let i=[],r=[0];for(let o=0;e.length-1>o;o++){let n=e[o],a=e[o+1],s=[...new Set([...n.map(e=>e.at),...a.map(e=>e.at)])].sort((e,t)=>e-t),l=0;for(let e of s){let t=Kt(n,e),i=Kt(a,e);l=Math.max(l,t.after+i.before)}i.push(l),r.push(r[r.length-1]+l+t)}return{adjacentClearance:i,positions:r}}function Qt(e,t,i,r={}){let o=[...e];if(1>=o.length)return o;let n=[...o],a=i(o),s=1,l=Math.max(0,r.passes??6),c=Math.max(1,r.maxEvaluations??1/0);for(let e=0;l>e&&c>s;e++){let e=new Map(o.map((e,t)=>[e,t])),l=new Map,c=new Map;for(let i of t){let t=e.get(i.source),r=e.get(i.target);if(null==t||null==r)continue;let o=Number.isFinite(i.weight)&&i.weight>0?i.weight:1;l.set(i.source,(l.get(i.source)??0)+r*o),c.set(i.source,(c.get(i.source)??0)+o),l.set(i.target,(l.get(i.target)??0)+t*o),c.set(i.target,(c.get(i.target)??0)+o)}o=o.map((e,t)=>({item:e,index:t,barycenter:(l.get(e)??t)/(c.get(e)??1)})).sort((e,t)=>e.barycenter-t.barycenter||(r.compare?.(e.item,t.item)??e.index-t.index)).map(e=>e.item);let u=i(o);if(s++,a>u)a=u,n=[...o];else if(u===a)break}return n}function Jt(e,t,i={}){let r=[...e],o=r.length;if(1>=o||o>(i.maxItems??8))return r;let n=Math.max(1,i.maxEvaluations??1/0),a=0,s=[...r],l=1/0,c=()=>{if(a>=n)return;let e=t(r);a++,l>e&&(l=e,s=[...r])};c();let u=Array(o).fill(0),d=0;for(;o>d&&n>a;)if(d>u[d]){let e=d%2==0?0:u[d];[r[e],r[d]]=[r[d],r[e]],c(),u[d]++,d=0}else u[d]=0,d++;return s}function ei(){return Object.create(null)}function ti(e,t){return t>e?-1:e>t?1:0}function ii(e){return e.occupants.map(e=>e.id).sort(ti).join("\0")}function ri(e,t,i=0){return e.slice(0,-1).map((r,o)=>null!=r.group&&r.group===e[o+1].group?i:t)}function oi(e,t){return e.map(e=>{let i=new Map;for(let r of e.occupants){let e=t[r.id];if(e)for(let t of e.samples){let e=i.get(t.t)??{before:0,after:0},r=t.boundaryOffset??0;i.set(t.t,{before:Math.max(e.before,t.topMass-r),after:Math.max(e.after,t.botMass+r)})}}return[...i].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({at:e,...t}))})}function ni(e,t,i){if(0===e.length)return[];let{padding:r,plotH:o,valueScale:n}=i,a=i.stackValueScale??n,s=ri(e,r,i.groupPadding??0),l=[r+e[0].peak.topPeak*a];for(let i=1;e.length>i;i++)l.push(l[i-1]+t[i-1]*a+s[i-1]);let c=l[l.length-1]+e[e.length-1].peak.botPeak*a+r;if(c>o&&c>0){let e=o/c;for(let t=0;l.length>t;t++)l[t]*=e}return l}function ai(e,t){let i=(e.boundaryOffset??0)*t,r=e.value*t;if("out"===e.kind){let o=e.sideMassBefore*t;return i+("top"===e.side?r/2-o:o-r/2)}let o=e.sideMassAfter*t;return i+("top"===e.side?r/2-o:o-r/2)}function si(e,t,i,r,o,n){let a=n.adjacentClearance?[...n.adjacentClearance]:Zt(oi(r,i)).adjacentClearance,s=ni(r,a,n),l="hug"===n.lanePlacement?function(e,t,i,r,o,n,a){let s=e.length;if(0===s)return[];let{padding:l,plotH:c,valueScale:u}=a,d=ri(e,l,a.groupPadding??0),h=o.map((e,t)=>e*u+d[t]),f=l+e[0].peak.topPeak*u,p=c-l-e[s-1].peak.botPeak*u;if(h.reduce((e,t)=>e+t,0)+1e-6>=p-f)return ni(e,o,a);let y=1===s?[(f+p)/2]:[...n];for(let e=0;12>e;e++){let e=Array(s).fill(0),o=Array(s).fill(0);for(let n of i){let i=t[n.source],a=t[n.target];if(null==i||null==a||i===a)continue;let s=r[n.source]?.localAttachments.get(n.id),l=r[n.target]?.localAttachments.get(n.id);if(!s||!l)continue;let c=n.value>0&&Number.isFinite(n.value)?n.value:1,d=ai(s,u),h=ai(l,u);e[i]+=(y[a]+h-d)*c,o[i]+=c,e[a]+=(y[i]+d-h)*c,o[a]+=c}let n=Ut({desired:y.map((t,i)=>0===o[i]?t:.45*t+e[i]/o[i]*.55),minGaps:h,weights:o.map(e=>Math.max(1,e)),min:f,max:p}),a=0;for(let e=0;s>e;e++)a=Math.max(a,Math.abs(n[e]-y[e]));if(y=n,.01>a)break}return y}(r,o,t,i,a,s,n):[...s];if("hug"===n.lanePlacement){let i=t=>{let i=ei();for(let r of e)i[r.id]=t[o[r.id]];return i};li(i(l),t)>li(i(s),t)+1e-6&&(l=[...s])}let c=ei();for(let t of e)c[t.id]=l[o[t.id]];let u=1/0,d=-1/0;for(let t of e){let e=c[t.id],r=i[t.id];!Number.isFinite(e)||!r||(u=Math.min(u,e-r.topPeak*n.valueScale),d=Math.max(d,e+r.botPeak*n.valueScale))}return{adjacentClearance:a,centerlines:c,slotCenter:l,stackCenter:s,verticalUtilization:Number.isFinite(u)&&Number.isFinite(d)&&n.plotH>0?Math.max(0,Math.min(1,(d-u)/n.plotH)):0}}function li(e,t){let i=0;for(let r of t){let t=e[r.source],o=e[r.target];Number.isFinite(t)&&Number.isFinite(o)&&(i+=Math.abs(t-o)*(r.value>0?r.value:1))}return i}function ci(e,t){let i=e?.samples;if(!i||0===i.length||i[0].t>t)return{top:0,bot:0};let r=0,o=i.length-1,n=0;for(;o>=r;){let e=r+o>>>1;i[e].t>t?o=e-1:(n=e,r=e+1)}let a=i[n].boundaryOffset??0;return{top:i[n].topMass-a,bot:i[n].botMass+a}}function ui(e,t,i,r,o){let n=1-o;return n*n*n*e+3*n*n*o*t+3*n*o*o*i+o*o*o*r}function di(e,t){let i=0,r=1;for(let o=0;28>o;o++){let o=(i+r)/2;ui(0,t,t,1,o)<e?i=o:r=o}return(i+r)/2}function hi(e,t,i){let r=t+ai(e,i),o=e.value*i/2;return[r-o,r+o]}function fi(e,t,i,r){return Math.max(0,Math.min(t,r)-Math.max(e,i))/Math.max(1e-9,t-e)}function pi(e,t,i,r,o,n,a){let{valueScale:s,domain:l,mode:c="quality"}=a,u="source"===a.ribbonLane?.85:"target"===a.ribbonLane?.15:.5,d=0;for(let a of e){let e=r[a.source],h=r[a.target];if(null==e||null==h||2>Math.abs(e-h))continue;let f=t[a.source]?.localAttachments.get(a.id),p=t[a.target]?.localAttachments.get(a.id);if(!f||!p)continue;let y=Math.max(a.startTime,l?.[0]??-1/0),g=Math.min(a.endTime,l?.[1]??1/0);if(y>=g)continue;let[m,b]=hi(f,o[a.source],s),[x,v]=hi(p,o[a.target],s),w=Math.min(e,h)+1,k=Math.max(e,h)-1;for(let e=w;k>=e;e++){let r=i[e];if(!r)continue;let l=[y,g];if("quality"===c)for(let e of r.occupants)for(let i of t[e.id]?.samples??[])i.t>y&&g>i.t&&l.push(i.t);let h=e=>{let i=di((e-y)/(g-y),u),l=ui(m,m,x,x,i),c=ui(b,b,v,v,i),d=0;for(let i of r.occupants){if(i.id===a.source||i.id===a.target)continue;let r=n[i.id];if(null!=r?.start&&r.start>e||null!=r?.end&&e>r.end)continue;let u=ci(t[i.id],e),h=o[i.id];d=Math.max(d,fi(l,c,h-u.top*s,h+u.bot*s))}return d},f=[...new Set(l)].sort((e,t)=>e-t),p=0;for(let e=0;f.length-1>e;e++){let t=f[e],i=f[e+1]-t;p+=(h(t+.25*i)+h(t+.5*i)+h(t+.75*i))/3*i}d+=p/(g-y)*(a.value>0?a.value:1)}}return d}function yi(e,t,i,r,o,n,a,s,l,c,u="both",d){return{crossings:e,weightedLength:t,pixelLength:li(a,i),transitOcclusion:pi(i,r,o,n,a,s,{valueScale:l,ribbonLane:u,domain:d,mode:"quality"}),verticalUtilization:c}}function gi(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function mi(e,t){return e.map(e=>({t:gi(e.t,t),topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}}))}function bi(e,t,i){let r=t+(e.boundaryOffset??0)*i,o=e.value*i;if("out"===e.kind){let t=e.sideMassBefore*i;if("top"===e.side){let e=r-t;return[e,e+o]}let n=r+t;return[n-o,n]}let n=e.sideMassAfter*i;if("top"===e.side){let e=r-n;return[e,e+o]}let a=r+n;return[a-o,a]}function xi(e,t,i,r,o="temporal"){let n=t.incoming[e.id],a=t.outgoing[e.id],s=[];for(let e of n)s.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:i.get(e.id).targetSide});for(let e of a)s.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:i.get(e.id).sourceSide});let l={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},c=()=>{s.sort((e,t)=>e.time-t.time||(e.phase??0)-(t.phase??0)||(e.sequence??0)-(t.sequence??0)||(l[e.kind]??99)-(l[t.kind]??99)||((e,t)=>{if(!r||!e.edge||!t.edge||e.kind!==t.kind||e.side!==t.side)return 0;if("out"===e.kind){if(e.edge.target===t.edge.target&&e.edge.endTime===t.edge.endTime)return 0;let i=r.get(e.edge.id)?.target,o=r.get(t.edge.id)?.target;return"number"==typeof i&&Number.isFinite(i)&&"number"==typeof o&&Number.isFinite(o)&&i!==o?"top"===e.side?i-o:o-i:0}if("in"===e.kind){if(e.edge.source===t.edge.source&&e.edge.startTime===t.edge.startTime)return 0;let i=r.get(e.edge.id)?.source,o=r.get(t.edge.id)?.source;return"number"==typeof i&&Number.isFinite(i)&&"number"==typeof o&&Number.isFinite(o)&&i!==o?"top"===e.side?o-i:i-o:0}return 0})(e,t)||ti(e.edge?.id??"",t.edge?.id??"")||ti(e.side,t.side)||e.delta-t.delta)},u=s.length?function(e,t=1/0){let i=t;for(let t of e)i>t&&(i=t);return i}(s.map(e=>e.time)):null,d=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,h=null!=d?d-1:null!=u&&Number.isFinite(u)?u-1:null;c();let f=null,p=0;for(let e of s)e.time!==f&&(f=e.time,p=0),e.sequence=p++;let y=e=>({time:e.time,phase:0,sequence:e.sequence??0}),g=[],m=0,b=0;for(let e of s)if("out"===e.kind){let t=Math.abs(e.delta),i=t-("top"===e.side?m:b);if(i>0){let t="top"===e.side?"bot":"top",r=Math.min(i,"top"===t?m:b);if(r>0){let o=y(e);g.push({...o,delta:-r,kind:"transfer-out",side:t}),g.push({...o,delta:+r,kind:"transfer-in",side:e.side}),"top"===t?m-=r:b-=r,"top"===e.side?m+=r:b+=r,i-=r}i>0&&null!==h&&(g.push({time:h,delta:+i,kind:"create",side:e.side}),"top"===e.side?m+=i:b+=i)}"top"===e.side?m-=t:b-=t}else if("in"===e.kind){let t=Math.abs(e.delta);"top"===e.side?m+=t:b+=t}s.push(...g),c();let x=0,v=0,w=0,k=0,A=0,S=0,M=[],_=new Map,$=e=>{M.push({t:e,topMass:x,botMass:v,...Math.abs(w)>1e-12&&{boundaryOffset:w}})},P=()=>{k=Math.max(k,x+v),A=Math.max(A,x-w),S=Math.max(S,v+w)};for(let e of s){if("transfer-out"!==e.kind&&"transfer-in"!==e.kind&&$(e.time),("in"===e.kind||"out"===e.kind)&&e.edge){let t="top"===e.side?x:v;_.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta),...Math.abs(w)>1e-12&&{boundaryOffset:w}})}"top"===e.side?x+=e.delta:v+=e.delta,"transfer-in"===e.kind?(w+="top"===e.side?e.delta:-e.delta,P(),$(e.time)):"transfer-out"!==e.kind&&(P(),"out"===e.kind&&1e-12>=x+v&&(w=0),$(e.time))}let R=[],I=0;for(;M.length>I;){let e=I;for(;M.length>e+1&&M[e+1].t===M[I].t;)e++;R.push(M[I]);for(let t=I+1;e>=t;t++){let e=R[R.length-1];(M[t].topMass!==e.topMass||M[t].botMass!==e.botMass||(M[t].boundaryOffset??0)!==(e.boundaryOffset??0))&&R.push(M[t])}I=e+1}let L=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null,T=null;for(let e of a)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===T||T>e.systemInTime)&&(T=e.systemInTime);let C=null;for(let e of n)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===C||e.systemOutTime>C)&&(C=e.systemOutTime);if(R.length>0){let e=R[R.length-1],t=Math.max(L??-1/0,C??-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&R.push({t:t,topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}});let i,r=R[0],o=R.find(e=>e.topMass+e.botMass>0),n=1/0;null!=d&&Number.isFinite(d)&&r.t>d&&r.topMass+r.botMass>0&&(n=d,i=r),o&&null!=T&&Number.isFinite(T)&&o.t>T&&n>T&&(n=T,i=o),i&&Number.isFinite(n)&&R.unshift({t:n,topMass:i.topMass,botMass:i.botMass,...null!=i.boundaryOffset&&{boundaryOffset:i.boundaryOffset}})}let O=R;if("max"===o&&null!=d&&null!=L&&L>d){let e,t=0;for(let i of R){let r=i.topMass+i.botMass;r>t&&(t=r,e=i)}if(e){let t={topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}};O=[...R.filter(e=>d>e.t),{t:d,...t},{t:L,...t},...R.filter(e=>e.t>L)]}}return{samples:O,peak:k,topPeak:A,botPeak:S,localAttachments:_}}function vi(e){let t=ei();return e.forEach((e,i)=>{for(let r of e.occupants)t[r.id]=i}),t}function wi(e,t,i){e.splice(0,e.length,...i);let r=vi(i);for(let e of Object.keys(t))delete t[e];Object.assign(t,r)}function ki(e){let t=new Map,i=[];e.forEach((e,r)=>{if(!e.group)return void i.push({anchor:r,stableId:ii(e),slots:[e]});let o=t.get(e.group)??{indexes:[],slots:[]};o.indexes.push(r),o.slots.push(e),t.set(e.group,o)});for(let[e,r]of t)i.push({anchor:r.indexes.reduce((e,t)=>e+t,0)/r.indexes.length,stableId:`${e}\0${r.slots.map(ii).join("\0")}`,slots:r.slots});return i.sort((e,t)=>e.anchor-t.anchor||ti(e.stableId,t.stableId))}function Ai(e){return e.some(e=>e.group)?ki(e).flatMap(e=>e.slots):[...e]}function Si(e){return e.flatMap(e=>e.slots)}function Mi(e,t,i){let r=new Map;return e.forEach((e,t)=>{for(let i of e.slots)r.set(i,t)}),e.map((e,o)=>{if(1>=e.slots.length)return e;let n=new Map;for(let t of e.slots)n.set(t,0);for(let e of t){let t=r.get(e.source),i=r.get(e.target);if(null==t||null==i)continue;let a=Number.isFinite(e.weight)&&e.weight>0?e.weight:1;if(t===o&&i!==o){let t=i>o?1:-1;n.set(e.source,(n.get(e.source)??0)+a*t)}else if(i===o&&t!==o){let i=t>o?1:-1;n.set(e.target,(n.get(e.target)??0)+a*i)}}let a=[...e.slots].sort((e,t)=>(n.get(e)??0)-(n.get(t)??0)||i(e,t));return{...e,slots:a}})}function _i(e,t){e.some(e=>e.group)&&wi(e,t,Ai(e))}function $i(e,t){return e.source!==t.source&&e.target!==t.target&&e.source!==t.target&&e.target!==t.source&&Math.min(e.endTime,t.endTime)>Math.max(e.startTime,t.startTime)}function Pi(e,t){return function(e,t,i=()=>!0){let r=0;for(let o=0;e.length>o;o++){let[n,a]=t(e[o]);for(let s=o+1;e.length>s;s++){if(!i(e[o],e[s]))continue;let[l,c]=t(e[s]);0>(n-l)*(a-c)&&r++}}return r}(t,t=>[e[t.source],e[t.target]],$i)}function Ri(e,t){let i=0;for(let r of t){let t=e[r.source],o=e[r.target];null==t||null==o||(i+=Math.abs(t-o)*(r.value>0?r.value:1))}return i}function Ii(e,t,i){let[r,o]=i.get(e.first),[n,a]=i.get(e.second);return 0>(t.get(r)-t.get(n))*(t.get(o)-t.get(a))?1:0}function Li(e,t,i,r,o,n,a){let s=[...o],l=new Map(o.map(e=>[e,ii(e)])),c=new Map;for(let e of o)for(let t of e.occupants)c.set(t.id,e);let u=new Map,d=[];for(let e of t){let t=c.get(e.source),i=c.get(e.target);!t||!i||(u.set(e,[t,i]),t!==i&&d.push({source:t,target:i,weight:e.value}))}let h=[];for(let e=0;t.length>e;e++)if(u.has(t[e]))for(let i=e+1;t.length>i;i++){if(!u.has(t[i])||!$i(t[e],t[i]))continue;let r=new Set([...u.get(t[e]),...u.get(t[i])]);h.push({index:h.length,first:t[e],second:t[i],involvedSlots:r})}let f=new Map;for(let e of o)f.set(e,[]);for(let e of h)for(let t of e.involvedSlots)f.get(t)?.push(e);let p=new Uint32Array(h.length),y=0,g=t.reduce((e,t)=>e+(t.value>0?t.value:1),0),m=a.plotH/Math.max(1,o.length),b=o.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),x=Math.max(1,g)*(Math.max(1,a.plotH)+m*Math.max(b,o.length)+1e-6*Math.max(1,o.length-1))+1,v=4*m,w={fullCrossing:0,localCrossing:0},k=new Map,A=(e,t)=>{let r=k.get(e);r||(r=new Map,k.set(e,r));let o=r.get(t);if(null!=o)return o;let n=function(e,t,i){return Zt(oi([e,t],i)).adjacentClearance[0]??0}(e,t,i);return r.set(t,n),n},S=new Map(o.map((e,t)=>[e,t])),M=t.flatMap(e=>{let t=u.get(e);return t?[{source:S.get(t[0]),target:S.get(t[1]),weight:e.value>0?e.value:1}]:[]}),_=new Map;for(let e of t){let t=u.get(e);t&&_.set(e,{source:S.get(t[0]),target:S.get(t[1])})}let $=new Map,P=new Map,R=new Map,I=(e,t,i)=>{e.has(t)||e.set(t,new Set),e.get(t).add(i)};for(let e of t)I($,e.source,e.target),I(P,e.target,e.source),I(R,e.source,e.target),I(R,e.target,e.source);let L=t.flatMap(e=>{if(!(e=>1===$.get(e.source)?.size&&$.get(e.source).has(e.target)||1===R.get(e.source)?.size||1===R.get(e.target)?.size)(e))return[];let t=_.get(e);return t&&t.source!==t.target?[{source:t.source,target:t.target,weight:e.value>0?e.value:1}]:[]}),T=e=>{let t=0;for(let i of L)t+=Math.max(0,Math.abs(e[i.source]-e[i.target])-1)*i.weight;return t*v},C=e=>{let t=new Int16Array(o.length);for(let i=0;e.length>i;i++)t[S.get(e[i])]=i;return T(t)},O=h.map(e=>{let t=_.get(e.first),i=_.get(e.second);return[t.source,t.target,i.source,i.target]}),F=new Int16Array(o.length),D=new Float64Array(o.length),z=new Float64Array(o.length+1),N=e=>{for(let t=0;e.length>t;t++)F[S.get(e[t])]=t;let t=0;for(let[e,i,r,o]of O)0>(F[e]-F[r])*(F[i]-F[o])&&t++;if(e.length>0){let t=S.get(e[0]);D[t]=a.padding+e[0].peak.topPeak*a.valueScale;for(let t=1;e.length>t;t++){let i=S.get(e[t-1]),r=S.get(e[t]);D[r]=D[i]+A(e[t-1],e[t])*a.valueScale+a.padding}let i=S.get(e[e.length-1]),r=D[i]+e[e.length-1].peak.botPeak*a.valueScale+a.padding;if(r>a.plotH&&r>0){let e=a.plotH/r;for(let t=0;D.length>t;t++)D[t]*=e}}z[0]=0;for(let t=0;e.length>t;t++)z[t+1]=z[t]+e[t].peak.topPeak+e[t].peak.botPeak;let i=0,r=0,o=0;for(let e of M){let t=F[e.source],n=F[e.target];if(i+=Math.abs(t-n)*e.weight,r+=Math.abs(D[e.source]-D[e.target])*e.weight,Math.abs(t-n)>=2){let i=Math.min(t,n)+1;o+=(z[Math.max(t,n)]-z[i])*e.weight}}return t*x+r+o*m+T(F)+1e-6*i},E=(e,i)=>{let r=Array(e.length+1).fill(0);for(let t=0;e.length>t;t++)r[t+1]=r[t]+e[t].peak.topPeak+e[t].peak.botPeak;let o=0;for(let e of t){let t=i[e.source],n=i[e.target];if(null==t||null==n||2>Math.abs(t-n))continue;let a=Math.min(t,n)+1;o+=(r[Math.max(t,n)]-r[a])*(e.value>0?e.value:1)}return o},B=r=>{let o=vi(r),n=r.slice(0,-1).map((e,t)=>A(e,r[t+1])),s=si(e,t,i,r,o,{plotH:a.plotH,padding:a.padding,valueScale:a.valueScale,lanePlacement:a.lanePlacement??"stack",groupPadding:a.groupPadding,adjacentClearance:n});return{map:o,geometry:s,weightedLength:Ri(o,t),pixelLength:li(s.centerlines,t),transitOcclusion:E(r,o)}},W=(e,t,i)=>({crossings:e,weightedLength:t.weightedLength,pixelLength:t.pixelLength,transitOcclusion:t.transitOcclusion,cost:e*x+t.pixelLength+t.transitOcclusion*m+C(i)+1e-6*t.weightedLength}),j=(e,t)=>{let i=t;if(null==i){let t=new Map(e.map((e,t)=>[e,t]));i=h.reduce((e,i)=>e+Ii(i,t,u),0),w.fullCrossing++}return W(i,B(e),e)},Y=(e,o,n="quality")=>{let s=o;if(null==s){let t=new Map(e.map((e,t)=>[e,t]));s=h.reduce((e,i)=>e+Ii(i,t,u),0),w.fullCrossing++}let l=B(e);return W(s,{...l,transitOcclusion:pi(t,i,e,l.map,l.geometry.centerlines,r,{valueScale:a.valueScale,ribbonLane:a.ribbonLane,domain:a.domain,mode:n})},e)},X=[...s],q=(e,t)=>ti(l.get(e),l.get(t)),G=function(e){let t=new Set;for(let i of e)if(i.group){if(t.has(i.group))return!0;t.add(i.group)}return!1}(X),V=e=>{let t=(e=>{let t=Qt(e,d,e=>j(e).cost,{passes:6,compare:q,maxEvaluations:Gp}),i=j(t),r=Gp;for(let e=0;6>e&&r>0;e++){let o=!1,n=Array.from({length:t.length-1},(e,t)=>t);e%2==1&&n.reverse();for(let e of n){if(0>=r--)break;let n=t[e],a=t[e+1],s=new Map(t.map((e,t)=>[e,t])),l=0,c=[];y++;for(let e of[...f.get(n)??[],...f.get(a)??[]])p[e.index]!==y&&(p[e.index]=y,c.push(e),l+=Ii(e,s,u));[t[e],t[e+1]]=[a,n];let d=new Map(s);d.set(n,e+1),d.set(a,e);let h=0;for(let e of c)h+=Ii(e,d,u);w.localCrossing+=c.length;let g=j(t,i.crossings-l+h);i.cost>g.cost?(i=g,o=!0):[t[e],t[e+1]]=[n,a]}if(!o)break}return t})(e);if((e.length>8?1/0:Xp(e.length)*(e.length+M.length+O.length))>qp)return t;let i=Jt(e,N,{maxItems:8,maxEvaluations:5e4}),r=Y(i),o=Y(t);return r.crossings!==o.crossings&&o.crossings>r.crossings?i:t},H="geometry-refine"===a.mode;if(H||"crossing-min"!==a.laneOrder&&"crossing-min+inside-out"!==a.laneOrder){if(!H&&"inside-out"===a.laneOrder)if(G){let e=ki(X),t=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),i=[...e].sort((e,i)=>t(i)-t(e)||ti(e.stableId,i.stableId)),r=Array(i.length),o=Math.floor((i.length-1)/2)-1,n=Math.floor((i.length-1)/2)+1;i.length>0&&(r[Math.floor((i.length-1)/2)]=i[0]);for(let e=1;i.length>e;e++)e%2==1&&i.length>n||0>o?r[n++]=i[e]:r[o--]=i[e];X=Si(r)}else{let e=[...X].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||q(e,t)),t=Array(e.length),i=Math.floor((e.length-1)/2)-1,r=Math.floor((e.length-1)/2)+1;e.length>0&&(t[Math.floor((e.length-1)/2)]=e[0]);for(let o=1;e.length>o;o++)o%2==1&&e.length>r||0>i?t[r++]=e[o]:t[i--]=e[o];X=t}}else X=G?(e=>{let t=ki(e);if(1>=t.length)return Si(t);let i=e=>j(Si(e)).cost;t=ki(V(e)),t=Mi(t,d,q);let r=function(e,t){let i=new Map;for(let t of e)for(let e of t.slots)i.set(e,t);let r=new Map;for(let e of t){let t=i.get(e.source),o=i.get(e.target);if(!t||!o||t===o)continue;let n=Number.isFinite(e.weight)&&e.weight>0?e.weight:1,a=o.stableId>t.stableId?`${t.stableId}\0${o.stableId}`:`${o.stableId}\0${t.stableId}`,s=r.get(a);s?s.weight=(s.weight??0)+n:r.set(a,{source:t,target:o,weight:n})}return[...r.values()]}(t,d);if(t=Qt(t,r,i,{passes:6,compare:(e,t)=>ti(e.stableId,t.stableId),maxEvaluations:Gp}),t=function(e,t,i={}){let r=[...e];if(1>=r.length)return r;let o=t(r),n=1,a=Math.max(0,i.passes??6),s=Math.max(1,i.maxEvaluations??1/0);for(let e=0;a>e&&s>n;e++){let e=!1;for(let i=0;r.length-1>i&&s>n;i++){[r[i],r[i+1]]=[r[i+1],r[i]];let a=t(r);n++,o>a?(o=a,e=!0):[r[i],r[i+1]]=[r[i+1],r[i]]}if(!e)break}return r}(t,i,{passes:8,maxEvaluations:Gp}),(t.length>8?1/0:Xp(t.length)*(t.length+M.length+O.length))<=qp){let e=Jt(t,e=>N(Si(e)),{maxItems:8,maxEvaluations:5e4}),i=Si(e),r=Si(t),o=Y(i),n=Y(r);o.crossings!==n.crossings?t=n.crossings>o.crossings?e:t:n.cost>o.cost&&(t=e)}return t=Mi(t,d,q),Si(t)})(X):V(X);if(!H&&"crossing-min+inside-out"===a.laneOrder&&X.length>1)if(G){let e=ki(X),t=j(Si(e)),i=Si(e),r=t,o=Math.floor((e.length-1)/2),n=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),a=[...e].sort((e,t)=>n(t)-n(e)||ti(e.stableId,t.stableId));for(let n of a){let a=e.indexOf(n);if(a===o)continue;e.splice(a,1),e.splice(o,0,n);let s=Si(e),l=j(s);l.cost>t.cost?(e.splice(o,1),e.splice(a,0,n)):(t=l,r.cost>l.cost&&(i=s,r=l))}X=i}else{let e=j(X),t=[...X],i=e,r=Math.floor((X.length-1)/2),o=[...X].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||q(e,t));for(let n of o){let o=X.indexOf(n);if(o===r)continue;X.splice(o,1),X.splice(r,0,n);let a=j(X);a.cost>e.cost?(X.splice(r,1),X.splice(o,0,n)):(e=a,i.cost>a.cost&&(t=[...X],i=a))}X=t}if((H||"crossing-min"===a.laneOrder||"crossing-min+inside-out"===a.laneOrder)&&X.length>1)if(G){let e=ki(X),t=Y(Si(e),void 0,"score");for(let i=0;6>i&&e.length>1;i++){let i=!1;for(let r=0;e.length-1>r;r++){[e[r],e[r+1]]=[e[r+1],e[r]];let o=Si(e),n=Y(o,void 0,"score");t.cost>n.cost?(X=o,t=n,i=!0):[e[r],e[r+1]]=[e[r+1],e[r]]}if(!i)break}e=Mi(ki(X),d,q),X=Si(e)}else{let e=Y(X,void 0,"score");for(let t=0;X.length-1>t;t++){let i=X[t],r=X[t+1],o=new Map(X.map((e,t)=>[e,t])),n=0,a=[];y++;for(let e of[...f.get(i)??[],...f.get(r)??[]])p[e.index]!==y&&(p[e.index]=y,a.push(e),n+=Ii(e,o,u));[X[t],X[t+1]]=[r,i];let s=new Map(o);s.set(i,t+1),s.set(r,t);let l=0;for(let e of a)l+=Ii(e,s,u);w.localCrossing+=a.length;let c=Y(X,e.crossings-n+l,"score");e.cost>c.cost?e=c:[X[t],X[t+1]]=[i,r]}}let U=Ai(s);X=Ai(X);let K=Y(X),Z=Y(U);if(H){let e=C(U),t=C(X);(K.crossings>Z.crossings||K.crossings===Z.crossings&&t>e+1e-9||K.cost>Z.cost)&&(X=U,K=Z)}else K.cost>Z.cost&&(X=U,K=Z);let Q=function({order:e,after:t,nodes:i,edges:r,outgoingPartners:o,incomingPartners:n,slotForNode:a,averageGap:s,evaluate:l}){let c=(i,o)=>{let n=[...new Set(o.map(t=>e.indexOf(t)))].sort((e,t)=>e-t),a=e.indexOf(i),c=n[0],u=n[n.length-1];if(3>n.length||!n.includes(a)||u-c+1!==n.length||1>=Math.abs(2*a-c-u))return;let d=[...e];d.splice(a,1),d.splice(c+u>>1,0,i);let h=Ai(d),f=l(h),p=new Set(i.occupants.map(e=>e.id)),y=new Set(o.flatMap(e=>e.occupants.map(e=>e.id))),g=r.reduce((e,t)=>p.has(t.source)&&y.has(t.target)||p.has(t.target)&&y.has(t.source)?e+(t.value>0?t.value:1):e,0);(function(e,t,i=0){return t.crossings>e.crossings||e.crossings===t.crossings&&t.cost+i>=e.cost})(f,t,Math.abs(2*a-c-u)*s*Math.max(1,g))&&(e=h,t=f)};for(let[e,t]of o)!n.has(e)&&t.size>=3&&c(a.get(e),[...t].map(e=>a.get(e)));for(let e of i){let t=a.get(e.id);!e.group&&t.group&&(n.get(e.id)?.size??0)>=3&&c(t,[...n.get(e.id)??[]].map(e=>a.get(e)).filter(e=>e===t||e.group===t.group).filter((e,t,i)=>i.indexOf(e)===t))}return{order:e,after:t}}({order:X,after:K,nodes:e,edges:t,outgoingPartners:$,incomingPartners:P,slotForNode:c,averageGap:m,evaluate:Y});return X=Q.order,K=Q.after,wi(o,n,X),{before:Z,after:K,initialOrder:s.map(e=>l.get(e)),evaluations:w}}function Ti(e,t,i){let r=e.map(e=>{let r=e.occupants.map(e=>({id:e.id,end:i[e.id]?.end??e.end})),o=0,n=0;for(let e of r){let i=t[e.id];o=Math.max(o,i?.topPeak||0),n=Math.max(n,i?.botPeak||0)}return{occupants:r,peak:{topPeak:o,botPeak:n},...null!=e.group?{group:e.group}:{}}}),o=ei();return r.forEach((e,t)=>{for(let i of e.occupants)o[i.id]=t}),{slots:r,slotByNode:o}}function Ci(e,t){return null!=e.start&&null!=e.end&&null!=t.start&&null!=t.end&&!(t.start>=e.end||e.start>=t.end)}function Oi(e,t){return ti(e,t)>0?`${t}\0${e}`:`${e}\0${t}`}function Fi(e){let t=new Map,i=new Map;for(let r of e)i.has(r.source)||i.set(r.source,new Set),t.has(r.target)||t.set(r.target,new Set),i.get(r.source).add(r.target),t.get(r.target).add(r.source);return{incoming:new Map([...t].map(([e,t])=>[e,t.size])),outgoing:new Map([...i].map(([e,t])=>[e,t.size]))}}function Di(e){let t=new Map,i=new Map,r=(e,t,i,r)=>{let o=e.get(t);o||(o=new Map,e.set(t,o)),o.set(i,(o.get(i)??0)+r)};for(let o of e){let e=o.value>0&&Number.isFinite(o.value)?o.value:1;r(t,o.source,o.target,e),r(i,o.target,o.source,e)}let o=new Map,n=e=>{if(o.has(e))return;let r=t.get(e),n=i.get(e),a=new Map;for(let[e,t]of r??[])a.set(e,(a.get(e)??0)+t);for(let[e,t]of n??[])a.set(e,(a.get(e)??0)+t);if(1===a.size){let[t,i]=[...a][0];o.set(e,{partner:t,weight:i})}};for(let t of e)n(t.source),n(t.target);return o}function zi(e,t,i){let r=i.get(e),o=i.get(t);return!r||!o||r.partner===o.partner||r.partner===t||o.partner===e}function Ni(e,t,i){return!!i.has(e)&&t.some(t=>!zi(e,t,i))}function Ei(e,t){return(e.value>0&&Number.isFinite(e.value)?e.value:1)*(1+(1===t.outgoing.get(e.source)?1:0)+(1===t.incoming.get(e.target)?1:0))}function Bi(e,t,i,r){if(12>=e.length||1>=r.slotCount)return r.assignment;let o=new Map(e.map((e,t)=>[e,t])),n=Array.from({length:e.length},()=>new Map),a=Fi(i);for(let e of i){let t=o.get(e.source),i=o.get(e.target);if(null==t||null==i||t===i)continue;let r=Ei(e,a);n[t].set(i,(n[t].get(i)??0)+r),n[i].set(t,(n[i].get(t)??0)+r)}let s=Di(i),l=e.map(e=>s.get(e)?.weight??0),c=Array.from({length:e.length},()=>new Map),u=0;for(let i=0;e.length-1>i&&5e4>u;i++)if(s.has(e[i]))for(let r=i+1;e.length>r;r++){if(!s.has(e[r])||t.conflicts(e[i],e[r]))continue;u++;let o=Math.min(l[i],l[r])||Math.max(l[i],l[r]),n=zi(e[i],e[r],s)?o:-o;if(Math.abs(n)>Up&&(c[i].set(r,n),c[r].set(i,n),u>=5e4))break}let d=[...r.assignment],h=Array.from({length:r.slotCount},()=>[]);d.forEach((e,t)=>h[e].push(t));let f=(e,t,i)=>{let r=d[t],o=d[i],n=0,a=new Set;for(let s of[t,i])for(let[l,c]of e[s]){let e=l>s?`${s}:${l}`:`${l}:${s}`;if(a.has(e))continue;a.add(e);let u=(s===t?o:r)===(l===t?o:l===i?r:d[l]);d[s]===d[l]!==u&&(n+=u?c:-c)}return n},p=(e,t,i)=>{let r=0;for(let[o,n]of e[t]){let e=i===d[o];d[t]===d[o]!==e&&(r+=e?n:-n)}return r},y=(e,t)=>e>Up||Up>=Math.abs(e)&&t>Up,g=(e,t,i,r)=>e>i+Up||Up>=Math.abs(e-i)&&t>r+Up,m=0;for(let i=0;32>i&&Hp>m;i++){let i=null,r=-1,o=-1,a=-1,s=-1/0,l=-1/0;for(let u=0;e.length>u;u++){for(let f=0;h.length>f&&m++<Hp;f++){if(f===d[u]||!h[f].every(i=>!t.conflicts(e[u],e[i])))continue;let m=p(n,u,f),b=p(c,u,f);y(m,b)&&g(m,b,s,l)&&(i="move",r=u,o=-1,a=f,s=m,l=b)}if(m>=Hp)break}for(let u=0;e.length-1>u;u++){for(let p=u+1;e.length>p&&m++<Hp;p++){let m=d[u],b=d[p];if(m===b||!h[b].every(i=>i===p||!t.conflicts(e[u],e[i]))||!h[m].every(i=>i===u||!t.conflicts(e[p],e[i])))continue;let x=f(n,u,p),v=f(c,u,p);y(x,v)&&g(x,v,s,l)&&(i="swap",r=u,o=p,a=-1,s=x,l=v)}if(m>=Hp)break}if(null==i||-1===r)break;if("move"===i){let e=d[r];h[e].splice(h[e].indexOf(r),1),h[a].push(r),d[r]=a;continue}let u=d[r],b=d[o];h[u].splice(h[u].indexOf(r),1,o),h[b].splice(h[b].indexOf(o),1,r),d[r]=b,d[o]=u}return d}function Wi(e,t){let i=1/0,r=-1/0;for(let t of e?.samples??[])1e-9>=t.topMass+t.botMass||(i=Math.min(i,t.t),r=Math.max(r,t.t));return Number.isFinite(i)&&Number.isFinite(r)?(null!=t.start&&(i=Math.max(i,t.start)),null!=t.end&&(r=Math.min(r,t.end)),i>r?{start:null,end:null}:{start:i,end:r}):{start:null,end:null}}function ji(e,t,i,r){let o=function(e,t,i,r){return`${e.map(e=>{let t=i[e.id],o=r[e.id];return[e.id,e.group??"",e.xExtent?.[0]??"",e.xExtent?.[1]??"",t?.topPeak??0,t?.botPeak??0,o?.start??"",o?.end??""].join(":")}).join("|")}#${t.map(e=>[e.id,e.source,e.target,e.value,e.startTime,e.endTime].join(":")).join("|")}`}(e,t,i,r),n=Vp.get(o);if(n)return Ti(n.slots,i,r);let a=ei();for(let t of e)a[t.id]=Wi(i[t.id],r[t.id]);let s=function(e,t){return e.filter(e=>null!=t[e.id].start).sort((e,i)=>t[e.id].start-t[i.id].start||t[e.id].end-t[i.id].end||ti(e.id,i.id)).map(e=>e.id)}(e,a),l=new Map(e.map(e=>[e.id,e])),c=new Map(e.map(e=>[e.id,e.group||void 0])),u=Di(t),d=function(e,t,i,r,o,n){let a=new Set,s=new Map(e.map(e=>[e,new Set])),l=new Map(e.map(e=>[e,new Set]));for(let e of r)a.add(Oi(e.source,e.target)),s.get(e.target)?.add(e.source),l.get(e.source)?.add(e.target);let c=new Map,u=new Set,d=(e,t)=>{for(let i=0;e.length>i;i++)for(let r=i+1;e.length>r;r++){let o=Oi(e[i],e[r]);t instanceof Map?t.set(o,[e[i],e[r]]):t.add(o)}};for(let e of l.values())d([...e],c);for(let e of s.values())d([...e],u);let h=new Set;for(let[e,[r,o]]of c)u.has(e)&&(Ci(t[r],t[o])||Ci(i[r],i[o])&&(h.add(r),h.add(o)));return{conflicts:(e,i)=>{let r=o.get(e),s=o.get(i);return!((null==r||null==s||r===s)&&(null!=r==(null!=s)||a.has(Oi(e,i))||n.has(e)&&n.has(i)&&zi(e,i,n))&&!Ci(t[e],t[i])&&(!h.has(e)&&!h.has(i)||a.has(Oi(e,i))))}}}(s,a,r,t,c,u),h=function(e,t,i=new Map){let r=[],o=[];for(let n of e){let e=r.findIndex(e=>e.every(e=>!t.conflicts(n,e))&&!Ni(n,e,i));-1===e&&!i.has(n)&&(e=r.findIndex(e=>e.every(e=>!t.conflicts(n,e)))),-1===e&&(e=r.length,r.push([])),r[e].push(n),o.push(e)}return{assignment:o,slotCount:r.length}}(s,d,u),f=function(e,t,i,r){if(0===e.length||e.length>12||1>=r.slotCount)return r.assignment;let o=new Map(e.map((e,t)=>[e,t])),n=Array.from({length:e.length},()=>new Float64Array(e.length)),a=Array.from({length:e.length},()=>new Map),s=Array.from({length:e.length},()=>new Map),l=Fi(i);for(let e of i){let t=o.get(e.source),i=o.get(e.target);if(null==t||null==i||t===i)continue;let r=Ei(e,l);n[t][i]+=r,n[i][t]+=r,s[t].set(i,(s[t].get(i)??0)+r),a[i].set(t,(a[i].get(t)??0)+r)}let c=Di(i),u=e.map(e=>c.get(e)?.weight??0),d=Array.from({length:e.length},()=>new Float64Array(e.length));for(let t=0;e.length>t;t++)for(let i=t+1;e.length>i;i++){for(let[e,r]of a[t])d[t][i]+=Math.min(r,a[i].get(e)??0);for(let[e,r]of s[t])d[t][i]+=Math.min(r,s[i].get(e)??0);if(c.has(e[t])&&c.has(e[i])){let r=Math.min(u[t],u[i])||Math.max(u[t],u[i]);d[t][i]+=zi(e[t],e[i],c)?r:-r}d[i][t]=d[t][i]}let h=[...r.assignment],f=(t=>{let i=0,r=0;for(let o=0;e.length>o;o++)for(let a=o+1;e.length>a;a++)t[o]===t[a]&&(i+=n[o][a],r+=d[o][a]);return{flow:i,affinity:r}})(h),p=0,y=Array(e.length).fill(-1),g=Array.from({length:r.slotCount},()=>[]),m=(i,o,a,s)=>{if(p>=75e3)return;if(i===e.length)return p++,void((a>f.flow||a===f.flow&&s>f.affinity||a===f.flow&&s===f.affinity&&function(e,t){for(let i=0;Math.min(e.length,t.length)>i;i++)if(e[i]!==t[i])return t[i]>e[i];return t.length>e.length}(y,h))&&(h=[...y],f={flow:a,affinity:s}));let l=Math.min(o+1,r.slotCount-1);for(let r=0;l>=r;r++){if(g[r].some(r=>t.conflicts(e[i],e[r])))continue;let l=0,c=0;for(let e of g[r])l+=n[i][e],c+=d[i][e];if(y[i]=r,g[r].push(i),m(i+1,Math.max(o,r),a+l,s+c),g[r].pop(),y[i]=-1,p>=75e3)return}};return y[0]=0,g[0].push(0),m(1,0,0,0),h}(s,d,t,{...h,assignment:Bi(s,d,t,h)}),p=new Map,y=f.map(e=>(p.has(e)||p.set(e,p.size),p.get(e))),g=Array.from({length:p.size||(e.length>0?1:0)},()=>({occupants:[],peak:{topPeak:0,botPeak:0}})),m=ei();s.forEach((e,t)=>{let i=y[t],r=g[i];r.occupants.push({id:e,end:a[e].end??-1/0});let o=l.get(e)?.group;o&&(r.group=o),m[e]=i});for(let t of[...e].sort((e,t)=>ti(e.id,t.id)))null==m[t.id]&&(g[0].occupants.push({id:t.id,end:-1/0}),m[t.id]=0);for(let e of g){e.occupants.sort((e,t)=>(a[e.id].start??1/0)-(a[t.id].start??1/0)||ti(e.id,t.id));for(let t of e.occupants){let r=i[t.id];e.peak.topPeak=Math.max(e.peak.topPeak,r?.topPeak||0),e.peak.botPeak=Math.max(e.peak.botPeak,r?.botPeak||0)}}let b={slots:g,slotByNode:m};return function(e,t){for(Vp.has(e)&&Vp.delete(e),Vp.set(e,{slots:t.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),slotByNode:Object.assign(ei(),t.slotByNode)});Vp.size>12;){let e=Vp.keys().next().value;if(null==e)break;Vp.delete(e)}}(o,b),b}function Yi(e){return e.topMass+e.botMass}function Xi(e){let t=new Map;for(let i of e.samples){if(Number.isNaN(i.t))continue;let e=t.get(i.t);e||(e=[],t.set(i.t,e)),e.push(i)}let i=0,r=-1/0;return o=>{o>=r||(i=0),r=o;let n=t.get(o);if(n){let e=n.reduce((e,t)=>Yi(t)<Yi(e)?e:t,n[0]);return{exact:n,sample:e}}for(;e.samples.length>i&&o>=e.samples[i].t;)i++;return{exact:n,sample:e.samples[i-1]??null}}}function qi(e,t,i,r,o,n,a=0){let s=new Map;for(let i of e){if(!i.group||!t[i.id])continue;let e=s.get(i.group)??[];e.push(i),s.set(i.group,e)}if(0===s.size||0>=n)return t;let l=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,{...t,samples:t.samples.map(e=>({...e})),localAttachments:new Map([...t.localAttachments].map(([e,t])=>[e,{...t}]))}]));for(let[e,c]of s){let s=i.map((e,t)=>({slot:e,index:t})).filter(({slot:t})=>t.group===e);if(0===s.length)continue;let u=s[0].slot,d=s.at(-1).slot,h=o[u.occupants[0]?.id],f=o[d.occupants[0]?.id];if(!Number.isFinite(h)||!Number.isFinite(f))continue;let p=(h-u.peak.topPeak*n+(f+d.peak.botPeak*n))/2,y=[...new Set(c.flatMap(e=>t[e.id].samples.map(e=>e.t)))].sort((e,t)=>e-t),g=new Map;for(let e of c)g.set(e.id,new Map);let m=new Map(c.map(e=>[e.id,Xi(t[e.id])]));for(let e of y){let t=new Map;for(let i of c){let{sample:o}=m.get(i.id)(e);if(!o||1e-9>=Yi(o))continue;let n=r[i.id];if(null==n)continue;let a=t.get(n)??[];a.push({node:i,sample:o}),t.set(n,a)}let i=[...t].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({slot:e,active:t,mass:Math.max(...t.map(({sample:e})=>Yi(e)))}));if(0===i.length)continue;let s=p-(i.reduce((e,t)=>e+t.mass,0)*n+Math.max(0,a)*Math.max(0,i.length-1))/2;for(let t of i){for(let{node:i,sample:r}of t.active){let t=(s-o[i.id])/n+r.topMass-(r.boundaryOffset??0);g.get(i.id).set(e,t)}s+=t.mass*n+Math.max(0,a)}}for(let e of c){let i=t[e.id],r=l[e.id],o=g.get(e.id),n=m.get(e.id),a=[];for(let e of y){let t=o.get(e),{exact:i,sample:r}=n(e);i?a.push(...i.map(e=>({...e,...null!=t?{boundaryOffset:(e.boundaryOffset??0)+t}:{}}))):null==t||!r||1e-9>=Yi(r)||a.push({...r,t:e,boundaryOffset:(r.boundaryOffset??0)+t})}r.samples=a,r.localAttachments=new Map([...i.localAttachments].map(([e,t])=>{let i=o.get(t.time);return[e,{...t,...null!=i?{boundaryOffset:(t.boundaryOffset??0)+i}:{}}]}))}}return l}function Gi(e,t,i,r,o){let{plotH:n,padding:a,valueScale:s,packing:l,laneOrder:c,lifetimeMode:u="half",lanePlacement:d="stack",groupPadding:h=0,ribbonLane:f="both",domain:p}=o,y=ei(),g=ei();for(let t of e)y[t.id]=i[t.id].topPeak||0,g[t.id]=i[t.id].botPeak||0;let m="half"===u,b=ei();for(let t of e){let e=Array.isArray(t.xExtent)?t.xExtent[0]:null,i=Array.isArray(t.xExtent)?t.xExtent[1]:null,o=null!=e&&Number.isFinite(e)?e:1/0,n=null!=i&&Number.isFinite(i)?i:-1/0;for(let 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);let t=m?(e.startTime+e.endTime)/2:e.endTime;t>n&&(n=t)}for(let e of r.incoming[t.id]){let t=m?(e.startTime+e.endTime)/2:e.startTime;o>t&&(o=t),e.endTime>n&&(n=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>n&&(n=e.systemOutTime)}b[t.id]={start:Number.isFinite(o)?o:null,end:Number.isFinite(n)?n:null}}let x=ei(),v=[],w=[];if(o.frozenSlots){let e=Ti(o.frozenSlots,i,b);v=e.slots,x=e.slotByNode,w=v.map(ii)}else if("reuse"===l){let r=ji(e,t,i,b);v=r.slots,x=r.slotByNode}else e.forEach((e,t)=>{v.push({occupants:[{id:e.id,end:b[e.id]?.end??-1/0}],peak:{topPeak:y[e.id],botPeak:g[e.id]},...e.group?{group:e.group}:{}}),x[e.id]=t});_i(v,x),0===w.length&&(w=v.map(ii));let k=null;o.frozenSlots||(o.fixedSlotOrder?function(e,t,i){let r=new Map(i.map((e,t)=>[e,t]));wi(e,t,[...e].sort((e,t)=>(r.get(ii(e))??1/0)-(r.get(ii(t))??1/0)||ti(ii(e),ii(t))))}(v,x,o.fixedSlotOrder):o.runOrdering&&c&&"insertion"!==c&&(k=Li(e,t,i,b,v,x,{plotH:n,padding:a,valueScale:s,groupPadding:h,laneOrder:c,ribbonLane:f,domain:p}))),_i(v,x);let A=si(e,t,i,v,x,{plotH:n,padding:a,valueScale:s,stackValueScale:o.stackValueScale,lanePlacement:d,groupPadding:h}),S=0===v.length?0:v[0].peak.topPeak+A.adjacentClearance.reduce((e,t)=>e+t,0)+v[v.length-1].peak.botPeak,M=k?.before.crossings??null,_=k?.after.crossings??null,$=k?.before.weightedLength??null,P=k?.after.weightedLength??null;return{effectiveSlotsHeight:S,centerlines:A.centerlines,laneLifetime:b,slots:v,slotByNode:x,slotCenter:A.slotCenter,stackCenter:A.stackCenter,verticalUtilization:A.verticalUtilization,selectedSlotOrder:v.map(ii),initialSlotOrder:w,ordering:k,crossingsBefore:M,crossingsAfter:_,lengthBefore:$,lengthAfter:P}}function Vi(e){let{sx:t,sTop:i,sBot:r,tx:o,tTop:n,tBot:a,cp1X:s,cp2X:l}=e,c=(i+r)/2,u=(n+a)/2;return{pathD:[`M${t},${i}`,`C${s},${i} ${l},${n} ${o},${n}`,`L${o},${a}`,`C${l},${a} ${s},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:s,y:c},{x:l,y:u},{x:o,y:u}],halfWidth:(r-i)/2}}}function Hi(e,t,i,r,o,n,a,s,l={}){let c,u,d,h,f=o,p=e=>s?Math.max(s[0],Math.min(s[1],e)):e,y=n(p(e.time)),g=n(p(i.time)),m=e.value*f,b=i.value*f,x=t+(e.boundaryOffset??0)*f,v=r+(i.boundaryOffset??0)*f,w=e.sideMassBefore*f,k=i.sideMassAfter*f;"top"===e.side?(c=x-w,u=c+m):(u=x+w,c=u-m),"top"===i.side?(d=v-k,h=d+b):(h=v+k,d=h-b);let A=l.sourceRunwayStart,S=l.minRun,M=Math.abs((d+h)/2-(c+u)/2),_=g-y,$="number"==typeof A&&Number.isFinite(A),P="number"==typeof S&&Number.isFinite(S)&&S>0;if($&&M>1e-9&&_>0&&("auto"===S||P)){let t="source"===a?.85:"target"===a?.15:.5,i="auto"===S?Math.min(144,Math.sqrt(8*M/(1.5*Math.min(t*t,(1-t)*(1-t))))):S;if(i>_){let t=n(p(Math.min(A,e.time)));Number.isFinite(t)&&(y=Math.min(y,Math.max(Math.min(y,t),g-i)))}}let R="source"===a?y+.85*(g-y):"target"===a?y+.15*(g-y):(y+g)/2;return{sx:y,sTop:c,sBot:u,tx:g,tTop:d,tBot:h,cp1X:R,cp2X:R}}function Ui(e){return Math.max(18,11*e.length*.58)}function Ki(e){let t=1.22*Ui(e.labelText)+4;return"start"===e.labelAnchor?[e.labelX,e.labelX+t]:"middle"===e.labelAnchor?[e.labelX-t/2,e.labelX+t/2]:[e.labelX-t,e.labelX]}function Zi(e,t){let i=e.labelX-Ui(e.labelText),r=t.labelX-Ui(t.labelText);return t.labelX+3>=i&&e.labelX+3>=r}function Qi(e){return e.replace(Kp,(e,t,i)=>`${i},${t}`)}function Ji(e){if(!e)return;let t=e=>({x:e.y,y:e.x});return{...e,...e.points&&{points:e.points.map(t)},...e.segments&&{segments:e.segments.map(e=>e.map(t))}}}function er(e){return{...e,pathD:Qi(e.pathD),y0:e.x0,y1:e.x1,x0:0,x1:0}}function tr(e){return{type:"hatch",background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle}}function ir(e,t){if(!t)return t;let i=function(e){let t=e.trim();if(!t.startsWith("var(")||!t.endsWith(")"))return null;let i=t.slice(4,-1),r=i.indexOf(",");if(-1===r){let e=i.trim();return e.startsWith("--")?{name:e}:null}let o=i.slice(0,r).trim(),n=i.slice(r+1).trim();return o.startsWith("--")?{name:o,fallback:n||void 0}:null}(t);if(!i)return t;let r=()=>i.fallback?ir(e,i.fallback):t,o=e.canvas;if(!o)return r();let n=Qp.get(o);(!n||0!==n.version)&&(n={version:0,map:new Map},Qp.set(o,n));let a=n.map.get(t);if(void 0!==a)return a;let s=getComputedStyle(o).getPropertyValue(i.name).trim()||r()||t;return n.map.set(t,s),s}function rr(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function or(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}function nr(e,t){let{background:i="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:n=6,angle:a=45,lineOpacity:s=1}=e,l=Math.max(8,Math.ceil(2*n));return ey("pattern",{id:t,width:l,height:l,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0,children:[i&&"transparent"!==i&&Jp("rect",{width:l,height:l,fill:i}),Jp("line",{x1:0,y1:0,x2:0,y2:l,stroke:r,strokeWidth:o,strokeOpacity:s}),Jp("line",{x1:n,y1:0,x2:n,y2:l,stroke:r,strokeWidth:o,strokeOpacity:s})]},t)}function ar(e){let{nodes:t,edges:i,domain:r,plotW:o,plotH:n,ribbonLane:a,ribbonMinRun:s=0,edgeOpacity:l,colorOf:c,layoutOpts:u,orientation:d="horizontal",showLabels:h=!0,labelPriorityAccessor:f,maxLabels:p,selectionDatum:y="raw",styleRules:g,colorBy:m,valueAccessor:b,usageMode:x="static"}=e,v="vertical"===d?n:o,w="vertical"===d?o:n,k=function(e,t,i,r={}){let o=Gt(r.usageMode??"static"),n=[],a=new Set;for(let t of e)a.has(t.id)&&n.push({kind:"duplicate-node",id:t.id,severity:o.duplicateIds}),a.add(t.id);let s=new Set,l=Array.isArray(i)&&2===i.length,c=l&&Number.isFinite(i[0])&&Number.isFinite(i[1]);(!l||!c||!c||i[0]>i[1])&&n.push({kind:"invalid-domain"});for(let t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||n.push({kind:"invalid-node-time",id:t.id}));for(let e of t)s.has(e.id)&&n.push({kind:"duplicate-edge",id:e.id,severity:o.duplicateIds}),s.add(e.id),a.has(e.source)||n.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),a.has(e.target)||n.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?((null!=e.systemInTime&&!Number.isFinite(e.systemInTime)||null!=e.systemOutTime&&!Number.isFinite(e.systemOutTime))&&n.push({kind:"invalid-system-time",id:e.id,severity:"warn"}),(!Number.isFinite(e.value)||0>=e.value)&&n.push({kind:"invalid-value",id:e.id}),e.startTime>e.endTime&&n.push({kind:"backward-edge",severity:"fatal",id:e.id,source:e.source,target:e.target})):n.push({kind:"invalid-edge-time",id:e.id});return n}(t,i,r,{usageMode:x}),{fatal:A,warnings:S}=function(e){let t=[],i=[];for(let r of e)"fatal"===Vt(r)?t.push(r):i.push(r);return{fatal:t,warnings:i}}(k),M=function(e,t,i="static"){if("strip"!==Gt(i).invalidSystemTime)return e;let r=new Set(t.filter(e=>"invalid-system-time"===e.kind).map(e=>e.id));return 0===r.size?e:e.map(e=>{if(!r.has(e.id))return e;let t={...e};return null!=t.systemInTime&&!Number.isFinite(t.systemInTime)&&delete t.systemInTime,null!=t.systemOutTime&&!Number.isFinite(t.systemOutTime)&&delete t.systemOutTime,t})}(i,k,x),_=Wp().domain(r).range([0,v]);if(A.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!1!==h},issues:A,warnings:S,xScale:_};let $=function(e,t,i){let{plotH:r,pairing:o="temporal",packing:n="reuse",laneOrder:a="crossing-min",lifetimeMode:s="half",maxValueScale:l,lanePlacement:c="stack",nodeSizing:u="temporal",groupPadding:d=0,ribbonLane:h="both",domain:f}=i,p=Number.isFinite(d)?Math.max(0,d):0,y=function(e,t){let i=ei(),r=ei();for(let t of e)i[t.id]=[],r[t.id]=[];for(let e of t)r[e.source]&&r[e.source].push(e),i[e.target]&&i[e.target].push(e);return{incoming:i,outgoing:r}}(e,t),g=function(e,t,i,r="temporal"){let o="temporal"===r?(e,t)=>e.endTime-t.endTime||ti(e.id,t.id):(e,t)=>t.value-e.value||ti(e.id,t.id),n="temporal"===r?(e,t)=>e.startTime-t.startTime||ti(e.id,t.id):(e,t)=>t.value-e.value||ti(e.id,t.id),a=new Map;for(let e of t)a.set(e.id,{});let s=(e,t)=>{let i=new Map;for(let r of e){let e=r[t];i.has(e)||i.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});let o=i.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)}let a=[...i.values()];a.sort("temporal"===r?(e,i)=>"target"===t?e.earliestStart-i.earliestStart||ti(e.partner,i.partner):e.latestEnd-i.latestEnd||ti(e.partner,i.partner):(e,t)=>t.total-e.total||ti(e.partner,t.partner));for(let e of a)e.edges.sort("target"===t?n:o);return a};for(let t of e){let e=i.outgoing[t.id],r=i.incoming[t.id];if(0===r.length)s(e,"target").forEach((e,t)=>{let i=t%2==0?"top":"bot";for(let t of e.edges)a.get(t.id).sourceSide=i});else if(0===e.length)s(r,"source").forEach((e,t)=>{let i=t%2==0?"top":"bot";for(let t of e.edges)a.get(t.id).targetSide=i});else{let t=s(r,"source"),i=s(e,"target"),o=Math.max(t.length,i.length);for(let e=0;o>e;e++){let r=e%2==0?"top":"bot";if(t[e])for(let i of t[e].edges)a.get(i.id).targetSide=r;if(i[e])for(let t of i[e].edges)a.get(t.id).sourceSide=r}}}return a}(e,t,y,o),m=ei();for(let t of e)m[t.id]=xi(t,y,g,void 0,u);let b=Gi(e,t,m,y,{plotH:r,padding:12,valueScale:1,packing:n,laneOrder:a,lifetimeMode:s,runOrdering:!0,lanePlacement:"stack",groupPadding:p,ribbonLane:h,domain:f}),x=b.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),v=new Set;for(let e of t){let t=b.slotByNode[e.source],i=b.slotByNode[e.target];if(void 0===t||void 0===i)continue;let r=g.get(e.id);t!==i?t>i?(r.sourceSide="top",r.targetSide="bot"):(r.sourceSide="bot",r.targetSide="top"):(v.add(e.id),r.sourceSide="bot",r.targetSide="bot")}for(let t of e){let e=y.outgoing[t.id],i=y.incoming[t.id],r=new Set(e.map(e=>g.get(e.id).sourceSide)),o=new Set(i.map(e=>g.get(e.id).targetSide));if(1===r.size&&i.length>0){let e=[...r][0];for(let t of i)b.slotByNode[t.source]===b.slotByNode[t.target]&&(g.get(t.id).targetSide=e)}if(1===o.size&&e.length>0){let t=[...o][0];for(let i of e)b.slotByNode[i.source]===b.slotByNode[i.target]&&(g.get(i.id).sourceSide=t)}}(function(e,t,i){let r=new Map,o=[];for(let t of e)o.push({time:t.startTime,kind:"out",edge:t}),o.push({time:t.endTime,kind:"in",edge:t});o.sort((e,t)=>e.time-t.time||(e.kind===t.kind?0:"in"===e.kind?-1:1)||("out"===e.kind?t.edge.value-e.edge.value:0)||ti(e.edge.id,t.edge.id));let n=e=>{let t=r.get(e);return t||(t={top:0,bot:0},r.set(e,t)),t},a=(e,t,i)=>{let r="top"===t?"bot":"top",o=Math.min(i,e[t]);e[t]-=o;let n=i-o;n>0&&(e[r]=Math.max(0,e[r]-n))};for(let e of o){let{edge:r}=e;if("in"===e.kind){let e=t.get(r.id)?.targetSide??"bot";n(r.target)[e]+=r.value;continue}let o=n(r.source),s=t.get(r.id),l=s.sourceSide??"bot";if(i[r.source]===i[r.target]){let e=o.top>=r.value,t=o.bot>=r.value;e!==t?l=e?"top":"bot":!e&&!t&&o.top!==o.bot&&(l=o.top>o.bot?"top":"bot"),s.sourceSide=l,s.targetSide=l}a(o,l,r.value)}})(t,g,b.slotByNode),function(e,t,i,r){for(let o of e){let e=t.incoming[o.id],n=t.outgoing[o.id];if(0===e.length||0===n.length)continue;let a=()=>{let t={inTop:0,inBot:0,outTop:0,outBot:0};for(let r of e)"top"===i.get(r.id).targetSide?t.inTop+=r.value:t.inBot+=r.value;for(let e of n)"top"===i.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},s=(e,t)=>{let o=a(),s="top"===e?o.outTop-o.inTop:o.outBot-o.inBot,l="top"===t?o.inTop-o.outTop:o.inBot-o.outBot;if(0>=s||0>=l)return!1;let c=Math.min(s,l),u=n.filter(t=>!r.has(t.id)&&i.get(t.id).sourceSide===e&&c>=t.value).sort((e,t)=>t.value-e.value||ti(e.id,t.id));return 0!==u.length&&(i.get(u[0].id).sourceSide=t,!0)},l=n.length+1;for(;l-- >0&&(s("top","bot")||s("bot","top")););}}(e,y,g,v),m=ei();for(let t of e)m[t.id]=xi(t,y,g,void 0,u);let w=Gi(e,t,m,y,{plotH:r,padding:12,valueScale:1,packing:n,laneOrder:a,lifetimeMode:s,frozenSlots:x,lanePlacement:"stack",groupPadding:p,ribbonLane:h,domain:f}),k=w.effectiveSlotsHeight??w.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),A=w.slots.slice(0,-1).reduce((e,t,i)=>e+(null!=t.group&&t.group===w.slots[i+1].group?1:0),0),S=Math.max(1,w.slots.length+1-A),M=Math.min(12,Math.max(0,.35*r-A*p)/S),_=2*M+ri(w.slots,M,p).reduce((e,t)=>e+t,0),$=k>0?Math.max(0,(r-_)/k):1,P=Number.isFinite(l)&&l>0?Math.min($,l):$,R=Gi(e,t,m,y,{plotH:r,padding:M,valueScale:P,packing:n,laneOrder:a,lifetimeMode:s,frozenSlots:x,lanePlacement:c,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:$}),I=Number.isFinite(l)&&l>0&&$>l+1e-12;if("insertion"!==a&&("hug"===c||I)&&R.slots.length>1&&(Li(e,t,m,R.laneLifetime,R.slots,R.slotByNode,{plotH:r,padding:M,valueScale:P,groupPadding:p,laneOrder:a,ribbonLane:h,domain:f,lanePlacement:c,mode:"geometry-refine"}),R=Gi(e,t,m,y,{plotH:r,padding:M,valueScale:P,packing:n,laneOrder:a,lifetimeMode:s,frozenSlots:R.slots,fixedSlotOrder:R.slots.map(ii),lanePlacement:c,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:$})),function(e,t){let i=(e,i)=>{for(let r of e){let e=new Map;for(let o of r){let r=`${("out"===i?t.get(o.id)?.sourceSide:t.get(o.id)?.targetSide)??""}\0${"out"===i?o.startTime:o.endTime}`,n="out"===i?`${o.target}\0${o.endTime}`:`${o.source}\0${o.startTime}`,a=e.get(r);if(null!=a&&a!==n)return!0;e.set(r,n)}}return!1};return i(Object.values(e.outgoing),"out")||i(Object.values(e.incoming),"in")}(y,g)){let i=function(e,t,i,r){let o=new Map;for(let n of e){let e=t[n.source]?.localAttachments.get(n.id),a=t[n.target]?.localAttachments.get(n.id),s=i[n.source],l=i[n.target];if(!(e&&a&&Number.isFinite(s)&&Number.isFinite(l)))continue;let c=bi(e,s,r),u=bi(a,l,r);o.set(n.id,{source:(c[0]+c[1])/2,target:(u[0]+u[1])/2})}return o}(t,m,R.centerlines,P);m=ei();for(let t of e)m[t.id]=xi(t,y,g,i,u);R=Gi(e,t,m,y,{plotH:r,padding:M,valueScale:P,packing:n,laneOrder:a,lifetimeMode:s,frozenSlots:R.slots,fixedSlotOrder:R.slots.map(ii),lanePlacement:c,groupPadding:p,ribbonLane:h,domain:f,stackValueScale:$})}let L=new Map(b.initialSlotOrder.map((e,t)=>[e,t])),T=[...R.slots].sort((e,t)=>(L.get(ii(e))??1/0)-(L.get(ii(t))??1/0)||ti(ii(e),ii(t))),C=ei();T.forEach((e,t)=>{for(let i of e.occupants)C[i.id]=t});let O=si(e,t,m,T,C,{plotH:r,padding:M,valueScale:P,stackValueScale:$,lanePlacement:"stack",groupPadding:p}),F=qi(e,m,T,C,O.centerlines,P,p),D=yi(Pi(C,t),Ri(C,t),t,F,T,C,O.centerlines,R.laneLifetime,P,O.verticalUtilization,h,f);m=qi(e,m,R.slots,R.slotByNode,R.centerlines,P,p);let z=yi(Pi(R.slotByNode,t),Ri(R.slotByNode,t),t,m,R.slots,R.slotByNode,R.centerlines,R.laneLifetime,P,R.verticalUtilization,h,f);return{nodeData:m,sides:g,valueScale:P,padding:M,compressedPadding:12>M,centerlines:R.centerlines,laneLifetime:R.laneLifetime,slots:R.slots,slotByNode:R.slotByNode,crossingsBefore:"insertion"===a?null:D.crossings,crossingsAfter:"insertion"===a?null:z.crossings,lengthBefore:"insertion"===a?null:D.weightedLength,lengthAfter:"insertion"===a?null:z.weightedLength,layoutQualityBefore:D,layoutQuality:z}}(t,M,{plotH:w,...u,ribbonLane:a,domain:r}),{centerlines:P,nodeData:R,valueScale:I}=$,L=Le(m,b),T=[],C=[],O=0===s?new Map:function(e,t,i){let r=new Set(t.map(e=>e.target)),o=new Map(e.map(e=>[e.id,e])),n=new Map;for(let e of t){if(r.has(e.source))continue;let t=n.get(e.source)??[];t.push(e),n.set(e.source,t)}let a=new Map;for(let t of e){if(!t.group)continue;let e=a.get(t.group)??[];e.push(t),a.set(t.group,e)}let s=new Set;for(let[e,t]of a){let i=t.flatMap(e=>n.get(e.id)??[]),o=new Set(i.map(e=>e.startTime));i.length>0&&1===o.size&&t.every(e=>{let t=e.xExtent?.[0],o=i[0].startTime;return!r.has(e.id)&&(n.get(e.id)?.length??0)>0&&Number.isFinite(t)&&o>t})&&s.add(e)}let l=new Map;for(let[e,t]of n){let r=o.get(e);if(r?.group&&!s.has(r.group))continue;let n=r?.xExtent?.[0],a=[...t].sort((e,t)=>e.startTime-t.startTime||e.id.localeCompare(t.id)),c=a[0]?.startTime-1,u=null;for(let e=0;a.length>e;){let t=a[e].startTime,r=e+1;for(;a.length>r&&a[r].startTime===t;)r++;for(let t=e;r>t;t++){let e=a[t],r=Number.isFinite(n)&&e.startTime>n,o=Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime;if(!r&&!o)continue;let s=i[0];r&&(s=Math.max(s,n)),o&&(s=Math.max(s,e.systemInTime)),!r&&o&&Number.isFinite(c)&&(s=Math.max(s,c)),null!=u&&(s=Math.max(s,u)),e.startTime>s&&l.set(e.id,s)}u=t,e=r}}for(let[e,t]of a){if(!s.has(e))continue;let i=t.flatMap(e=>n.get(e.id)??[]);if(!i.every(e=>l.has(e.id))){for(let e of i)l.delete(e.id);continue}let r=Math.max(...i.map(e=>l.get(e.id)));for(let e of i)l.set(e.id,r)}return l}(t,M,r),F=new Map(t.filter(e=>e.group).map(e=>[e.id,e.group])),D=new Map;for(let e of M){let t=R[e.source]?.localAttachments.get(e.id),i=R[e.target]?.localAttachments.get(e.id);!t||!i||D.set(e.id,Hi(t,P[e.source],i,P[e.target],I,_,a,r,{minRun:s,sourceRunwayStart:O.get(e.id)}))}let z=function(e,t,i,r,o,n){let a=new Map(t),s=new Map;for(let t of e){let e=n?.get(t.source),i=null==e?"node:"+t.source:"group:"+e,r=s.get(i)??new Map,o=r.get(t.startTime)??[];o.push(t),r.set(t.startTime,o),s.set(i,r)}for(let e of s.values())for(let[n,s]of e){if(!s.some(e=>i.has(e.id)))continue;let e=s.map(e=>t.get(e.id));if(e.some(e=>null==e))continue;let l=r(n),c=Math.min(...e.map(e=>e.sx));if(c>=l-1e-9)continue;let u=Math.max(...s.map(e=>{let t=i.get(e.id);return null==t?l:Math.min(l,r(t))})),d=Math.min(l,Math.max(c,u));for(let e of s){let i=t.get(e.id),r=d+(i.tx-d)*("source"===o?.85:"target"===o?.15:.5);a.set(e.id,{...i,sx:d,cp1X:r,cp2X:r})}}return a}(M,D,O,_,a,F),N=function(e,t,i,r,o){let n=new Map;for(let a of e){if(!i.has(a.id))continue;let e=t.get(a.id);if(!e||e.sx>=r(a.startTime)-1e-9)continue;let s=o(e.sx);Number.isFinite(s)&&a.startTime>s&&n.set(a.id,s)}return n}(M,z,O,_,e=>r[0]+e/v*(r[1]-r[0])),E=function(e,t,i){let r=new Map,o=new Map;for(let[e,t]of i??[]){let i=o.get(t)??[];i.push(e),o.set(t,i)}for(let n of e){let e=t.get(n.id);if(null==e||!Number.isFinite(e)||e>=n.startTime)continue;let a=i?.get(n.source),s=null==a?[n.source]:o.get(a)??[n.source];for(let t of s){let i=r.get(t)??new Map,o=i.get(n.startTime);i.set(n.startTime,null==o?e:Math.min(o,e)),r.set(t,i)}}return r}(M,N,F);t.forEach((e,t)=>{let i=R[e.id];if(!i||0===i.samples.length)return;let o=(a=i.samples,(s=E.get(e.id))&&0!==s.size?a.map(e=>{let t=s.get(e.t);return null==t?e:{...e,t:t}}):a),n=function(e,t,i,r,o){if(0===e.length)return null;let n=mi(e,o),a=e=>t+(n[e].boundaryOffset??0)*i,s=e=>a(e)-n[e].topMass*i,l=e=>a(e)+n[e].botMass*i,c=`M${r(n[0].t)},${s(0)}`;for(let e=1;n.length>e;e++)c+=` L${r(n[e].t)},${s(e)}`;c+=` L${r(n[n.length-1].t)},${l(n.length-1)}`;for(let e=n.length-2;e>=0;e--)c+=` L${r(n[e].t)},${l(e)}`;return c+" Z"}(o,P[e.id],I,_,r);var a,s;if(!n)return;let l,u,h=mi(o,r),f=h.find(e=>e.topMass+e.botMass>0)||h[0],p=P[e.id]+(f.botMass-f.topMass+2*(f.boundaryOffset??0))*I/2,y=c(e.id,t),m=y,b=.5,x=e.__raw??e;if(g&&g.length>0){let e=Oe(x,g,L(x));"string"==typeof e.fill?y=e.fill:null!=e.fill&&rr(e.fill)&&(u=e.fill,y=e.fill.background&&"transparent"!==e.fill.background?e.fill.background:y),"string"==typeof e.stroke&&(m=e.stroke),"number"==typeof e.strokeWidth&&(b=e.strokeWidth),"number"==typeof e.fillOpacity&&(l=e.fillOpacity),"number"==typeof e.opacity&&null==l&&(l=e.opacity)}let v=function(e,t,i,r,o,n){let a=i.nodeData[e];if(!a||0===a.samples.length)return[];let s=i.valueScale,l=i.centerlines[e],c=mi(a.samples,o),u=c.find(e=>e.topMass+e.botMass>0)||c[0],d=[...c].reverse().find(e=>e.topMass+e.botMass>0)||c[c.length-1],h=r(u.t),f=r(d.t),p=e=>r(gi(e,o)),y=[],g=(e,t,i,r)=>`M${e},${t} L${i},${t} L${i},${r} L${e},${r} Z`;for(let i of t){if(i.source===e&&null!=i.systemInTime&&Number.isFinite(i.systemInTime)){let e=a.localAttachments.get(i.id),t=n?.get(i.id)??i.startTime;if(e&&"out"===e.kind&&t>i.systemInTime){let r=p(i.systemInTime),n=p(t),a=null!=o&&o[0]>i.systemInTime,c=a?r:r-20,u=a?Math.min(n,r+20):r,d=Math.max(h,c);if(n>d){let[t,i]=bi(e,l,s);y.push({pathD:g(d,t,n,i),x0:c,x1:u,from:0,to:1})}}}if(i.target===e&&null!=i.systemOutTime&&Number.isFinite(i.systemOutTime)){let e=a.localAttachments.get(i.id);if(e&&"in"===e.kind&&i.systemOutTime>i.endTime){let t=p(i.systemOutTime),r=p(i.endTime),o=t+20,n=Math.min(f,o);if(n>r){let[i,a]=bi(e,l,s);y.push({pathD:g(r,i,n,a),x0:t,x1:o,from:1,to:0})}}}}return y}(e.id,M,$,_,r,N);T.push({id:e.id,pathD:n,fill:y,stroke:m,strokeWidth:b,...null!=l&&{fillOpacity:l},...u&&{hatchFill:u},...v.length>0&&{gradientStubs:v},rawDatum:x,labelX:_("vertical"===d&&e.xExtent?e.xExtent[0]:f.t)-4,labelY:p,labelText:e.label??e.id})});let B=new Map;t.forEach((e,t)=>B.set(e.id,t)),M.forEach(e=>{let t=z.get(e.id);if(!t)return;let i=B.get(e.source)??0,r=c(e.source,i),{pathD:o,bezier:n}=Vi(t),a=e.__raw??e,s="function"==typeof l?Number(l(a)):l,u=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.35;C.push({id:e.id,pathD:o,fill:r,opacity:u,rawDatum:a,bezier:n})});let W=function(e,t,i){let r=e.map(e=>({...e})),o=new Map;for(let e of r){let i=t[e.id];if(null==i)continue;let r=o.get(i)??[];r.push(e),o.set(i,r)}let n=e=>{if(2>e.length)return;let t=e.reduce((e,t)=>e+t.labelY,0)/e.length,r=(e.length-1)/2;e.forEach((e,o)=>{e.labelY=Math.max(8,Math.min(i-8,t+16*(o-r)))})};for(let e of o.values()){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],i=-1/0;for(let r of e){let e=r.labelX-Ui(r.labelText);t.length>0&&e>i+3&&(n(t),t=[],i=-1/0),t.push(r),i=Math.max(i,r.labelX)}n(t)}return function(e,t){let i=[...e].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX||e.id.localeCompare(t.id));for(let e=0;3>e;e+=1){for(let e=0;i.length>e;e+=1){let t=8;for(let r=0;e>r;r+=1)Zi(i[e],i[r])&&(t=Math.max(t,i[r].labelY+16));i[e].labelY=Math.max(i[e].labelY,t)}for(let e=i.length-1;e>=0;e-=1){let r=t-8;for(let t=e+1;i.length>t;t+=1)Zi(i[e],i[t])&&(r=Math.min(r,i[t].labelY-16));i[e].labelY=Math.min(i[e].labelY,r)}}}(r,i),r}(T,$.slotByNode,w).map(e=>function(e,t){return"horizontal"===t?e:{...e,pathD:Qi(e.pathD),gradientStubs:e.gradientStubs?.map(er),labelX:e.labelY,labelY:e.labelX,labelAnchor:"middle",labelBaseline:"auto"}}(e,d)),j="vertical"===d?function(e,t,i){let r=e.map(e=>({...e}));for(let e of r){let i=1.22*Ui(e.labelText)+4;e.labelX=t-4>i?Math.max(i/2+2,Math.min(t-i/2-2,e.labelX)):t/2}let o=[],n=[...r].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX);for(let e of n){let t=o[o.length-1];!t||Math.abs(t[0].labelY-e.labelY)>14?o.push([e]):t.push(e)}for(let e of o){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],r=new Map;for(let i of e){let[e,o]=Ki(i),n=t.findIndex(t=>e>t+8);-1===n&&(n=t.length),t[n]=o,r.set(i,n)}let o=e.reduce((e,t)=>e+t.labelY,0)/e.length,n=14*t.length+8>o;for(let t of e){let e=r.get(t)??0;t.labelY=n?Math.min(i-8,12+14*e):Math.max(8,o-14*e)}}return r}(W,o,n):W,Y=new Map;if(null!=f)for(let e of t){let t=e.__raw??e,i="function"==typeof f?f(t):Number(t[f]);Number.isFinite(i)&&Y.set(e.id,i)}let X=function(e,t,i,r,o={}){if(!1===r)return e.map(e=>({...e,labelText:"",labelDeferred:!1,labelFullText:void 0}));if(!0===r)return e.map(e=>({...e,labelDeferred:!1,labelFullText:void 0}));let n=Math.max(4,Math.min(e.length,Math.floor(Math.max(1,t*i)/14e3)));Number.isFinite(o.maxLabels)&&o.maxLabels>=0&&(n=Math.min(n,Math.floor(o.maxLabels)));let a=e.map((e,t)=>{let i=o.priorityById?.get(e.id),r=Math.abs(e.labelY);return{band:e,index:t,score:null!=i&&Number.isFinite(i)?1e6*i+Ui(e.labelText):Ui(e.labelText)+.01*r}}).filter(e=>e.band.labelText.trim().length>0).sort((e,t)=>t.score-e.score||e.index-t.index||e.band.id.localeCompare(t.band.id)),s=new Set(a.slice(0,n).map(e=>e.band.id));return e.map(e=>s.has(e.id)||0===e.labelText.trim().length?{...e,labelDeferred:!1,labelFullText:void 0}:{...e,labelFullText:e.labelText,labelText:"",labelDeferred:!0})}(j,o,n,h,{...Y.size>0&&{priorityById:Y},...null!=p&&{maxLabels:p}});return{layout:$,layoutConfig:{bands:X,ribbons:C.map(e=>function(e,t){return"horizontal"===t?e:{...e,pathD:Qi(e.pathD),bezier:Ji(e.bezier)}}(e,d)),showLabels:!1!==h,selectionDatum:y},issues:[],warnings:S,xScale:_}}function sr(e,t,i,r="horizontal"){return"vertical"===r?{top:e?38:t?28:16,right:24,bottom:24,left:i?72:24}:{top:e?30:t?24:8,right:80,bottom:i?28:8,left:80}}function lr(e,t,i){return!t?.isActive||t.predicate(function(e,t){return"scene"===t?e:e.data}(e,i))}function cr(e,t){if(!e)return[];let i=[],r=e=>{i.push(e);let o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(r)};return r(e),i}function ur(e,t,i,r){if(e&&e.length>0)return e;let o=new Set;return t.forEach(e=>{let t="function"==typeof i?i(e):e[i],n="function"==typeof r?r(e):e[r];o.add(t),o.add(n)}),Array.from(o).map(e=>({id:e}))}function dr(e,t,i={}){return Pe(t?"function"==typeof t?i=>({...e(i),...t(i)??{}}):i=>({...e(i),...t}):e,i)}function hr(e,t,i){let[r,o]=i;if(!t)return r;let[n,a]=t,s=a>n?a-n:0,l=Number(e),c=Number.isFinite(l)?l:n;return r+Math.max(0,Math.min(1,s>0?(c-n)/s:0))*(o-r)}function fr(e){let{valueAccessor:t,valueDomain:i,edgeWidthRange:r,resolveStroke:o,edgeOpacity:n,edgeLinecap:a,styleRules:s}=e,l=Re(t);return Fe(e=>({stroke:o(e),strokeWidth:hr(e[t],i,r),strokeLinecap:a,opacity:n,fillOpacity:0}),s,e=>({value:l(e)}))}function pr(e,t,i,r){let o,n,a=Array.isArray(e)?e:[];if(t){let e="string"==typeof t?t:"__geoColorBy",r="string"==typeof t?a:a.map(e=>({...e,__geoColorBy:t(e)}));o=Me(r,e,i)}if(r.sizeBy){let e=a.map("function"==typeof r.sizeBy?r.sizeBy:e=>e?.[r.sizeBy]).filter(e=>null!=e&&isFinite(e));e.length>0&&(n=Je(e))}return e=>({fill:t&&o?Ae(e,t,o):Mf,fillOpacity:r.fillOpacity,stroke:"#fff",strokeWidth:r.strokeWidth,r:r.sizeBy?_e(e,r.sizeBy,r.sizeRange,n):r.pointRadius??6})}function yr(e){return e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e}function gr(e){return`${e.getUTCFullYear()}-${mr(e.getUTCMonth()+1)}-${mr(e.getUTCDate())}`}function mr(e){return 10>e?"0"+e:e+""}function br(e,t={}){let i=t.baseOpacity??1;return t.highlight||t.predicate?!function(e,t){if(!t)return!0;let i=Array.isArray(t)?t:[t],r=e;for(let e of i)if(null!=e.value&&r[e.field]+""!=e.value+"")return!1;return!0}(e,t.highlight)||t.predicate&&!t.predicate(e)?t.dimOpacity??.16:Math.min(1,i+(t.brighten??0)):i}function xr(e){let t=e.fontSize??12;return null!=e.maxWidth&&e.text.length*t*.56>e.maxWidth?null:Ry("text",{className:e.className,x:e.x,y:e.y,textAnchor:e.anchor??"middle",dominantBaseline:e.baseline??"middle",fontSize:t,fontWeight:e.fontWeight,fill:e.color,style:{pointerEvents:"none"},children:e.text},e.keyId)}function vr(e){let[t,i]=e,r=160>t||116>i,o=r?Math.min(12,Math.max(2,.08*t)):32,n=r?Math.min(8,Math.max(2,.12*i)):24,a=r?n:34;return{width:t,height:i,plot:{x:o,y:n,width:Math.max(1,t-2*o),height:Math.max(1,i-n-a)}}}function wr(e){let t=(e??"")+"";if(!t)return"#4e79a7";let i=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"],r=0;for(let e=0;t.length>e;e+=1)r=31*r+t.charCodeAt(e)>>>0;return i[r%i.length]}function kr(e,t="#4e79a7",i){let r=i?.styleRules,o=!!r&&r.length>0,n=o?Re(i?.valueAccessor):void 0;return i=>{let a=i.datum,s=a&&e?"function"==typeof e?e(a,0):a[e]:void 0,l={fill:null==s?t:wr(s),stroke:"#111827",strokeWidth:1,opacity:.9};return o&&a&&Object.assign(l,Oe(a,r,{value:n?n(a):void 0,category:null==s?void 0:s+""})),l}}function Ar(e,t,i,r){return{fixedDt:1/120,maxSubsteps:8,colliders:t,observation:{chartType:i},kernel:{seed:e,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...r}}}function Sr(e,t,i){return"function"==typeof i?i(e,t):e[i]}function Mr(e){if(e instanceof Date){let t=e.getTime();return Number.isFinite(t)?t:null}let t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function _r(e,t,i){return Math.max(t,Math.min(i,e))}function $r(e,t){let i=Mr(e);return null!=i&&i>0?i:t}function Pr(e){return((e??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function Rr(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 Ir(e,t,i=0){let r=new Set(e.filter(e=>null!=e.id).map(e=>e.id+"")),o=new Map;for(let n of e){let e=null==n.id?`${t}-${i++}`:n.id+"";for(;null==n.id&&r.has(e);)e=`${t}-${i++}`;r.add(e),o.set(e,null==n.id?{...n,id:e}:n)}return{seed:e,rows:Array.from(o.values()),nextId:i}}function Lr(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}}function Tr(e){let t=e.fixedPosition;Number.isFinite(t?.x)&&(e.x=e.prevX=t.x,e.vx=0),Number.isFinite(t?.y)&&(e.y=e.prevY=t.y,e.vy=0)}function Cr(e){if(!e)return;let t=Number.isFinite(e.x)?e.x:void 0,i=Number.isFinite(e.y)?e.y:void 0;return null==t&&null==i?void 0:{x:t,y:i}}function Or(e,t,i){let r,o="x"===i?"y":"x",n=Math.abs(t[i]-e[i]),a=t[o]-e[o],s=(e,t)=>"circle"===e.shape.type?e.shape.radius:("x"===t?e.shape.width:e.shape.height)/2;if("circle"===e.shape.type&&"circle"===t.shape.type){let i=e.shape.radius+t.shape.radius;r=Math.sqrt(Math.max(0,i*i-n*n))}else if("aabb"===e.shape.type&&"aabb"===t.shape.type)r=s(e,o)+s(t,o);else{let a="aabb"===e.shape.type?e:t,l=s("circle"===e.shape.type?e:t,i),c=Math.max(0,n-s(a,i));r=s(a,o)+Math.sqrt(Math.max(0,l*l-c*c))}let l=0>a?-1:1;return{nx:"x"===o?l:0,ny:"y"===o?l:0,penetration:Math.max(0,r-Math.abs(a))}}function Fr(e){return"circle"===e.type?{type:"circle",radius:e.radius}:{type:"aabb",width:e.width,height:e.height}}function Dr(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 zr(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,...e.fixedPosition?{fixedPosition:Cr(e.fixedPosition)}:{},shape:Fr(e.shape),sleeping:e.sleeping,datum:e.datum,index:e.index,sleepTime:e.sleepTime,restitution:e.restitution,friction:e.friction}}function Nr(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 Er(e){return{id:e.id,shape:Dr(e.shape),sensor:e.sensor,restitution:e.restitution,friction:e.friction,bodyFilter:Nr(e.bodyFilter),index:e.index}}function Br(e,t,i){return Math.max(t,Math.min(i,e))}function Wr(e,t,i){return Math.min(e??i,t??i)}function jr(e,t,i){return Br(Math.max(e??i,t??i),0,1)}function Yr(e){return 0>e?-1:1}function Xr(e){if("circle"===e.shape.type){let t=e.shape.radius;return{minX:e.x-t,minY:e.y-t,maxX:e.x+t,maxY:e.y+t}}let t=e.shape.width/2,i=e.shape.height/2;return{minX:e.x-t,minY:e.y-i,maxX:e.x+t,maxY:e.y+i}}function qr(e){let t=e.shape;if("aabb"===t.type){let e=t.width/2,i=t.height/2;return{minX:t.x-e,minY:t.y-i,maxX:t.x+e,maxY:t.y+i}}let i=(t.thickness??0)/2;return{minX:Math.min(t.x1,t.x2)-i,minY:Math.min(t.y1,t.y2)-i,maxX:Math.max(t.x1,t.x2)+i,maxY:Math.max(t.y1,t.y2)+i}}function Gr(e,t){return!(e.minX>t.maxX||t.minX>e.maxX||e.minY>t.maxY||t.minY>e.maxY)}function Vr(e,t,i,r,o,n,a,s){let l=o-e,c=(i+a)/2-Math.abs(l);if(0>=c)return null;let u=n-t,d=(r+s)/2-Math.abs(u);return d>0?d>c?{nx:Yr(l),ny:0,penetration:c}:{nx:0,ny:Yr(u),penetration:d}:null}function Hr(e,t,i,r,o,n,a){let s=n/2,l=a/2,c=e-Br(e,r-s,r+s),u=t-Br(t,o-l,o+l),d=c*c+u*u;if(d>i*i)return null;if(Ey>=d){let n=Math.abs(e-(r-s)),a=Math.abs(e-(r+s)),c=Math.abs(t-(o-l)),u=Math.abs(t-(o+l)),d=Math.min(n,a,c,u);return d===n?{nx:-1,ny:0,penetration:i+n}:d===a?{nx:1,ny:0,penetration:i+a}:d===c?{nx:0,ny:-1,penetration:i+c}:{nx:0,ny:1,penetration:i+u}}let h=Math.sqrt(d);return{nx:c/h,ny:u/h,penetration:i-h}}function Ur(e,t){if("circle"===e.shape.type&&"circle"===t.shape.type)return function(e,t,i,r,o,n){let a=r-e,s=o-t,l=i+n,c=a*a+s*s;if(c>=l*l)return null;if(Ey>=c)return{nx:1,ny:0,penetration:l};let u=Math.sqrt(c);return{nx:a/u,ny:s/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 Vr(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){let i=Hr(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height);return i?{nx:-i.nx,ny:-i.ny,penetration:i.penetration}:null}return"aabb"===e.shape.type&&"circle"===t.shape.type?Hr(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height):null}function Kr(e,t){let i=t.shape;return"aabb"===i.type?"circle"===e.shape.type?Hr(e.x,e.y,e.shape.radius,i.x,i.y,i.width,i.height):Vr(i.x,i.y,i.width,i.height,e.x,e.y,e.shape.width,e.shape.height):function(e,t,i,r,o,n,a,s=0){let l=n-r,c=a-o,u=l*l+c*c,d=u>Ey?Br(((e-r)*l+(t-o)*c)/u,0,1):0,h=i+s/2,f=e-(r+l*d),p=t-(o+c*d),y=f*f+p*p;if(y>=h*h)return null;if(Ey>=y){let e=Math.sqrt(u);return e>Ey?{nx:-c/e,ny:l/e,penetration:h}:{nx:1,ny:0,penetration:h}}let g=Math.sqrt(y);return{nx:f/g,ny:p/g,penetration:h-g}}(e.x,e.y,"circle"===e.shape.type?e.shape.radius:Math.sqrt(e.shape.width*e.shape.width+e.shape.height*e.shape.height)/2,i.x1,i.y1,i.x2,i.y2,i.thickness??0)}function Zr(e,t){return`${e}\0${t}`}function Qr(e){let t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function Jr(e,t){return!!t?.some(t=>Object.is(e,t))}function eo(e,t){return function(e,t){if(!t)return!0;if("function"==typeof t)return t(e);let i=function(e,t){if(!t)return;let i=e;for(let e of t.split(".")){if(null==i||"object"!=typeof i||!Object.prototype.hasOwnProperty.call(i,e))return;i=i[e]}return i}(e,t.property);return!("equals"in t&&!Object.is(i,t.equals)||"notEquals"in t&&Object.is(i,t.notEquals)||t.oneOf&&!Jr(i,t.oneOf)||t.notOneOf&&Jr(i,t.notOneOf))}(t,e.bodyFilter)}function to(e,t={}){return e?"function"==typeof e?e(t):(e.init(t),e):function(e={}){return new jy(e)}(t)}function io(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);let i=t-e.mean;e.mean+=i/e.count,e.m2+=i*(t-e.mean)}function ro(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 oo(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 no(e,t){if(null!=e[t])return e[t];let i=e.datum;return i&&"object"==typeof i?i[t]:void 0}function ao(e,t,i){return"function"==typeof e?e(t,i):"string"==typeof e?no(t,e):void 0}function so(e){if(null==e)return;let t=e+"";return t.trim()?t:void 0}function lo(e){let t=ro(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:ro(e.x),y:ro(e.y),value:t}}function co(e){let t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}function uo(e={},t=Gy){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 ho(e){return{...e,shape:{...e.shape},...e.fixedPosition?{fixedPosition:{...e.fixedPosition}}:{},datum:e.datum,springs:e.springs?.map(e=>({...e,target:{...e.target}}))}}function fo(e){if(e instanceof Date){let t=e.getTime();return Number.isFinite(t)?t:void 0}let t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function po(e,t){if(null!=e[t])return e[t];let i=e.datum;return i&&"object"==typeof i?i[t]:void 0}function yo(e){return{...ho(e),sequence:e.sequence,spawnAt:e.spawnAt}}function go(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 mo(e){return!1!==e&&{...e}}function bo(e,t){return e.spawnAt===t.spawnAt?e.sequence-t.sequence:e.spawnAt-t.spawnAt}function xo(e){return{...e,gravity:{...e.gravity}}}function vo(e,t,i,r){if("circle"===e.shape.type){let o=e.x-t,n=e.y-i,a=e.shape.radius+r,s=o*o+n*n;return s>a*a?null:s}let o=Math.max(Math.abs(t-e.x)-e.shape.width/2,0),n=Math.max(Math.abs(i-e.y)-e.shape.height/2,0),a=o*o+n*n;return a>r*r?null:a}function wo(e){let t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function ko(e,t={}){let{idPrefix:i="plot",includeFloor:r=!0,includeCeiling:o=!1,includeLeftWall:n=!0,includeRightWall:a=!0,wallThickness:s=20,floorThickness:l=s}=t,c=[],u=e.x+e.width/2,d=e.y+e.height/2;return r&&c.push({id:i+"-floor",shape:{type:"aabb",x:u,y:e.y+e.height+l/2,width:e.width+2*s,height:l}}),o&&c.push({id:i+"-ceiling",shape:{type:"aabb",x:u,y:e.y-l/2,width:e.width+2*s,height:l}}),n&&c.push({id:i+"-left-wall",shape:{type:"aabb",x:e.x-s/2,y:d,width:s,height:e.height+2*l}}),a&&c.push({id:i+"-right-wall",shape:{type:"aabb",x:e.x+e.width+s/2,y:d,width:s,height:e.height+2*l}}),c}function Ao(e){let{idPrefix:t="bin",count:i,domainStart:r,domainStep:o,xScale:n,yTop:a,yBottom:s,wallThickness:l=4,includeBoundaryWalls:c=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=a,lidThickness:f=Math.max(2,l)}=e,p=[],y=a+(s-a)/2,g=Math.abs(s-a),m=c?i:i-1;if(u||c)for(let e=c?0:1;m>=e;e+=1){if(!u&&e>0&&i>e)continue;let a=n(r+e*o);p.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:a,y:y,width:l,height:g}})}if(null!=d)for(let e=0;i>e;e+=1){let i=r+e*o,a=i+o;if(a>=d)continue;let s=n(i),c=n(a);p.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(s,c)+l/2,y1:h,x2:Math.max(s,c)-l/2,y2:h,thickness:f}})}return p}function So(e,t){let i={...e};for(let e of t)i[Vy[e]]++;return i}function Mo(e,t,i){let r=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:r,revisions:So(i,r)}}function _o(e){let t="preserve",i=new Set;for(let r of e){let e=og[r]??ng;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}function $o(e,t){return e===t||!(!e||!t||e.gravity?.x!==t.gravity?.x||e.gravity?.y!==t.gravity?.y)&&ag.every(i=>e[i]===t[i])}function Po(e,t,i,r){return e||!t?"paused":i||!r?"running":"settled"}function Ro(e,t,i,r={}){let o,n=0;for(;t>n&&!r.shouldStop?.()&&(!1===r.stopAtRest||e.queueSize()>0||!e.atRest()||r.continueWhile?.());){e.step(e.fixedDt),e.advanceTime(e.fixedDt);let t=e.drainEvents();i.events&&(i.events.push(...t),e.observeKernelEvents(t,i.observations),e.observeSensorTransitions(i.observations));let a=[];if(e.spawnDue(a,i.observations),a.length>0){i.spawned.push(...a),o=e.observeBodyBudget(i.observations);let t=e.evictOverflow(i.observations);i.evicted?.push(...t.evicted),i.sedimented?.push(...t.sedimented)}n+=1,e.refreshQuiescence(e.fixedDt,a.length),r.afterStep?.()}return{steps:n,budget:o}}function Io(e,t,i,r){let{windowPlot:o,lidSegments:n}=e,a=n[t];return i&&!a?Math.min(o.y+o.height-r,o.y+.48*o.height+2*r+4):!i&&a?Math.min(o.y+o.height-r,Math.max(a.y1,a.y2)+2*r+4):o.y+r+2}function Lo(e,t,i,r,o){let{windowPlot:n,windowCount:a,windowStart:s,windowSize:l}=r;if(i&&t>=r.closedWindowCount)return r.gutter.x+r.gutter.width/2;let c=n.width/a,u=i?n.x:n.x+t*c,d=i?n.x+n.width:u+c,h=Math.min((d-u)/2,o+(i?0:3));return Math.max(u+h,Math.min(d-h,n.x+(e-s)/l*c))}function To(e,t,i){let r=e.width/Math.max(1,t),o=Math.max(2,2*i),n=Math.min(.7*r,Math.max(3.2*o,o+8)),a=Math.max(1,Math.floor(n/o));return{laneWidth:r,tubeWidth:n,ballDiameter:o,perRow:a,centerX:t=>e.x+(t+.5)*r,pileHeight:e=>Math.ceil(Math.max(0,e)/a)*o}}function Co(e,t,i,r){let o=(t+i)/2,n=[];for(let a of e){let s=n.filter(e=>a.radius+e.radius+.5>Math.abs(a.x-e.x)),l=[o];for(let e of s){let t=Math.sqrt((a.radius+e.radius+.5)**2-(a.x-e.x)**2);l.push(e.y-t,e.y+t)}let c=.5>r()?-1:1;l.sort((e,t)=>Math.abs(e-o)-Math.abs(t-o)||c*(e-t));let u=l.find(e=>e-a.radius>=t&&i>=e+a.radius&&s.every(t=>(a.x-t.x)**2+(e-t.y)**2>=(a.radius+t.radius+.5)**2-1e-6));if(null==u){let r=Math.max(...e.map(e=>e.radius)),n=Math.max(0,i-t-2*r);return{positions:e.map((t,i)=>o+(1===e.length?0:i/(e.length-1)-.5)*n),overlapping:!0,entryOffset:0}}n.push({...a,y:u})}return{positions:n.map(e=>e.y),overlapping:!1,entryOffset:Math.max(0,Math.min(36,...n.map(e=>e.y-e.radius-t)))}}function Oo(e){if(Array.isArray(e)&&e.length>=2){let t=Mr(e[0]),i=Mr(e[1]);return null!=t&&null!=i?{x:t,y:i}:null}if(e&&"object"==typeof e){let t=e,i=Mr(t.x),r=Mr(t.y);return null!=i&&null!=r?{x:i,y:r}:null}return null}function Fo(e){return Array.isArray(e)?e.map(Oo).filter(e=>null!=e):[]}function Do(e,t,i){return"normalized"===i?{x:t.plot.x+e.x*t.plot.width,y:t.plot.y+e.y*t.plot.height}:{x:_r(e.x,t.plot.x,t.plot.x+t.plot.width),y:_r(e.y,t.plot.y,t.plot.y+t.plot.height)}}function zo(e){let t=0;for(let i=1;e.length>i;i+=1)t+=Math.hypot(e[i].x-e[i-1].x,e[i].y-e[i-1].y);return t}function No(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};let i=_r(t,0,1)*zo(e),r=0;for(let t=1;e.length>t;t+=1){let o=e[t-1],n=e[t],a=Math.hypot(n.x-o.x,n.y-o.y);if(a>0){if(r+a>=i){let e=(i-r)/a;return{x:o.x+(n.x-o.x)*e,y:o.y+(n.y-o.y)*e}}r+=a}}return{...e[e.length-1]}}function Eo(e,t){let i=No(e,Math.max(0,t-.02)),r=No(e,Math.min(1,t+.02)),o=r.x-i.x,n=r.y-i.y,a=Math.hypot(o,n)||1;return{x:o/a,y:n/a}}function Bo(e,t,i){return Math.max(t,Math.min(i,e))}function Wo(e,t,i,r,o,n={}){return{id:e,friction:n.friction,restitution:n.restitution,bodyFilter:n.bodyFilter,shape:{type:"segment",x1:t,y1:i,x2:r,y2:o,thickness:n.thickness??8}}}function jo(e){return{id:e.id,label:e.label,description:e.description,kind:e.kind,shape:(t=e.x,i=e.y,r=e.width,o=e.height,{type:"aabb",x:t,y:i,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,i,r,o}function Yo(e){let t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...jo({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function Xo(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 qo(e,t,i){return ke(e,t,i)}function Go(e,t){let i=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>i&&Se(i,e)||"#4e79a7":t=>{if(i){let e=Se(i,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 Vo(e,t){let i=t.config??{},r=(t.sensors??[]).map(e=>({...e,sensor:!0})),o=[...t.colliders??[],...r],n=[...e.colliders??[],...i.colliders??[],...o];return{...e,...i,observation:{...e.observation,...i.observation},...n.length>0&&{colliders:n}}}function Ho(e){let t=Jo(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 Uo(e,t,i,r){return i?"function"==typeof i?i(e,t):e[i]??r:r}function Ko(e){return`gauntlet:${e}:core`}function Zo(e,t){return`gauntlet:${e}:positive:${t}`}function Qo(e,t,i){return`gauntlet:${e}:negative:${t}:${i}`}function Jo(e){let t=e.height??e.floorY+36;if(e.width>=220&&t>=160)return fg;let i=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*i))}}function en(e){return Math.max(.12,Math.min(1,e.width/500,(e.height??e.floorY+36)/260))}function tn(e,t,i,r){let o=Jo(r),n=Math.max(2,i+2),a=o.top+o.thickness/2+n,s=r.floorY-n,l=(e,t,i)=>t>i?(t+i)/2:Math.max(t,Math.min(i,e));return{x:l(e,o.left+o.thickness/2+n,r.width-o.rightInset-o.thickness/2-n),y:l(t,a,s)}}function rn(e,t,i=1){let 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)*i}}function on(e,t,i){let r=e.activePositiveIds.reduce((e,i)=>e+(t.get(i)?.value??1),0),o=e.missingPositiveIds.length+e.poppedPositiveIds.length,n=e.negativeIds.reduce((e,t)=>e+(i.get(t)?.load??1),0);return Math.max(0,Math.min(100,75+3*r-8*n-1.2*e.delay-5*o))}function nn(e){let t=function(e,t,i){let[r,o]=e,n=220>r||160>o,a=Math.round(.48*o),s=n?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,d=c>1?(.78*r-u)/(c-1):0,h=n?Math.max(Math.round(.12*r),.08*r+6):Math.max(Math.round(.14*r),110);return{crashY:s-(n?Math.min(i,Math.max(3,.22*o)):i),floorY:s,gates:l.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(u+t*d),width:e.width??Math.max(n?8:54,Math.round(.07*r))})),graveyardX:Math.round(r*(n?.72:.84)),graveyardY:s-4,height:o,routeY:a,socketX:Math.round(r*(n?.82:.92)),startX:h,width:r}}(e.size??[900,520],e.gates,e.crashOffset??30),i=e.positiveProperties??[],r=new Map(i.map(e=>[e.id,e])),o=new Map((e.negativeProperties??[]).map(e=>[e.id,e])),n={idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor},a=(e.data??[]).map((t,a)=>{let s=function(e,t,i,r,o){let n=Uo(e,t,i.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",a=r.map(e=>e.id),s=[...Uo(e,t,i.positiveAccessor,a)],l=[...Uo(e,t,i.negativeAccessor,[])].filter(e=>o.has(e));return{id:n,activePositiveIds:s,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...Uo(e,t,i.metricsAccessor,{})},missingPositiveIds:a.filter(e=>!s.includes(e)),negativeIds:l,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(Uo(e,t,i.startTimeAccessor,0))||0),stage:"project filed",viability:Uo(e,t,i.initialViability,100)}}(t,a,n,i,o);return{...s,viability:e.viability?.(s,{negativeProperties:o,positiveProperties:r})??on(s,r,o)}}),s=a.flatMap((i,n)=>{let a=function(e,t,i,r){let 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}}(i),n=r?.(e,t,i)??{};return{...o,...n,startY:n.startY??n.routeY??o.startY,socketY:n.socketY??n.routeY??o.socketY,graveyardY:n.graveyardY??o.graveyardY}}(i,n,t,e.projectPlacement);return function(e,t,i,r,o,n,a){let s=en(i),l=Math.max(3,28*s),c=r.startX,u=r.startY+(r.startY===i.routeY?38*t*s:0),d=a?.(e,t,i,r)??{},h=d.x??c,f=d.y??u,p={__gauntlet:!0,kind:"gauntlet-core",projectId:e.id,sourceDatum:e.datum},y=[{...d,id:Ko(e.id),x:h,y:f,vx:d.vx??42,vy:d.vy??0,mass:d.mass??7,bodyCollisions:d.bodyCollisions??!0,shape:d.shape??{type:"circle",radius:l},spawnAt:d.spawnAt??e.startedAt,datum:p}],g=tn(h,f,d.shape&&"radius"in d.shape&&Number(d.shape.radius)||l,i);y[0].x=g.x,y[0].y=g.y;for(let t of e.activePositiveIds){let r=o.get(t);if(!r)continue;let n=rn(e.activePositiveIds,t,s),a=r.radius??Math.max(2,10*s),l=tn(g.x+Math.cos(n.angle)*n.radius,g.y+Math.sin(n.angle)*n.radius,a,i);y.push({id:Zo(e.id,t),x:l.x,y:l.y,vx:18*Math.cos(n.angle),vy:18*Math.sin(n.angle),mass:r.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:a},spawnAt:d.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:Ko(e.id)},stiffness:.56,damping:.9,restLength:Math.max(6,(52+n.index%2*4)*s),...r.spring??{}}]})}return e.negativeIds.forEach((t,r)=>{let o=n.get(t);o&&y.push(function(e,t,i,r,o,n,a){let s=en(n),l=t.radius??Math.max(2,7.2*s),c=tn(r+(i%4*12-12)*s,o+(54+12*Math.floor(i/4))*s,l,n);return{id:Qo(e.id,t.id,i),x:c.x,y:c.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:l},spawnAt:a,datum:{__gauntlet:!0,kind:hg,projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:Ko(e.id)},stiffness:.62,damping:.92,restLength:Math.max(6,(52+i%4*3)*s),...t.spring??{}}]}}(e,o,r,g.x,g.y,i,d.spawnAt??e.startedAt))}),y}(i,n,t,a,r,o,e.coreBody)});return{layout:t,states:a,initialSpawns:s,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:Ho(t)}}}function an(e=[]){let t=Object.create(null);for(let[i,r]of e)t[i]=r;return t}function sn(...e){let t=an();for(let i of e)for(let[e,r]of Object.entries(i??{}))t[e]=r;return t}function ln(e){return sn(e)}function cn(e){return e.map(e=>({...e,sourceIds:e.sourceIds?[...e.sourceIds]:void 0,productIds:e.productIds?[...e.productIds]:void 0,relationIds:e.relationIds?[...e.relationIds]:void 0,outletIds:e.outletIds?[...e.outletIds]:void 0}))}function un(e){let t=an(Object.entries(e.components).map(([e,t])=>[e,{...t,initialMetrics:ln(t.initialMetrics),metrics:ln(t.metrics),productIds:[...t.productIds],history:cn(t.history)}])),i=an(Object.entries(e.products).map(([e,t])=>[e,{...t,metrics:ln(t.metrics),sourceIds:[...t.sourceIds],history:cn(t.history)}])),r=an(Object.entries(e.relations).map(([e,t])=>[e,{...t,sourceIds:[...t.sourceIds],metrics:t.metrics?ln(t.metrics):void 0}]));return{...e,eventsApplied:[...e.eventsApplied],components:t,products:i,relations:r,input:{amount:e.input.amount,metrics:ln(e.input.metrics)},metrics:ln(e.metrics),loss:{amount:e.loss.amount,metrics:ln(e.loss.metrics)},history:cn(e.history)}}function dn(e,t){return t>e?-1:e>t?1:0}function hn(e,t,i,r,o){return{severity:e,code:t,message:i,path:r,ids:o?[...o]:void 0}}function fn(e){let t=new Set,i=new Set;for(let r of e)t.has(r)&&i.add(r),t.add(r);return[...i].sort(dn)}function pn(e,t){return e?Object.entries(e).flatMap(([e,i])=>Number.isFinite(i)?[]:[hn("error","invalid-metric",`Metric "${e}" must be a finite number.`,`${t}.${e}`)]):[]}function yn(e,t){for(let[i,r]of Object.entries(t))e[i]=Number(e[i]??0)+r}function gn(e,t,i="selector"){let r=[],o=Object.values(e.components),n=new Set(o.map(e=>e.id)),a=(t.ids??[]).filter(e=>!n.has(e));if(a.length&&r.push(hn("error","unknown-component",`Selector references unknown component id${1===a.length?"":"s"}: ${a.join(", ")}.`,i+".ids",a)),void 0!==t.count&&(!Number.isInteger(t.count)||0>t.count)&&r.push(hn("error","invalid-selector-count","Selector count must be a non-negative integer.",i+".count")),r.some(e=>"error"===e.severity))return{ids:[],diagnostics:r};let s=t.ids?new Set(t.ids):null,l=t.categories?new Set(t.categories):null,c=t.statuses?new Set(t.statuses):null,u=t.outletIds?new Set(t.outletIds):null,d=o.filter(e=>!s||s.has(e.id)).filter(e=>!l||l.has(e.category)).filter(e=>!c||c.has(e.status)).filter(e=>!u||void 0!==e.outletId&&u.has(e.outletId)).map(e=>e.id).sort(dn);return void 0!==t.count&&(d=d.slice(0,t.count)),d.length||r.push(hn("warning","empty-selector","Selector matched no source components.",i)),{ids:d,diagnostics:r}}function mn(e,t,i={}){return{eventId:e.event.id,effectType:t.type,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,label:e.event.label,summary:e.event.summary,...i}}function bn(e,t){let i={...t,eventId:e.event.id};e.materializations.push(i),e.observations.push({...i,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt})}function xn(e,t,i){return!(void 0!==t&&!e.outletIds.has(t)&&(e.diagnostics.push(hn("error","unknown-outlet",`Unknown outlet "${t}".`,i,[t])),1))}function vn(e,t,i){let r=fn(t);t.length||e.diagnostics.push(hn("error","empty-source-list","A product requires at least one source component.",i)),r.length&&e.diagnostics.push(hn("error","duplicate-source",`Source ids may appear only once: ${r.join(", ")}.`,i,r));let o=t.filter(t=>!e.state.components[t]);o.length&&e.diagnostics.push(hn("error","unknown-component",`Unknown source component id${1===o.length?"":"s"}: ${o.join(", ")}.`,i,o));let n=t.filter(t=>(e.state.components[t]?.productIds.length??0)>0);n.length&&e.diagnostics.push(hn("error","source-already-assigned",`Source component${1===n.length?" is":"s are"} already assigned: ${n.join(", ")}.`,i,n));let a=t.filter(t=>"consumed"===e.state.components[t]?.status&&!n.includes(t));return a.length&&e.diagnostics.push(hn("error","source-unavailable",`Consumed source component${1===a.length?" is":"s are"} unavailable: ${a.join(", ")}.`,i,a)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}function wn(e,t,i,r,o){let n=r?.amount??0;(!Number.isFinite(n)||0>n||n>t+pg)&&e.diagnostics.push(hn("error","invalid-loss","Loss amount must be finite, non-negative, and no greater than its sources.",o+".amount")),e.diagnostics.push(...pn(r?.metrics,o+".metrics"));for(let[t,n]of Object.entries(r?.metrics??{}))(0>n||n>Number(i[t]??0)+pg)&&e.diagnostics.push(hn("error","invalid-metric-loss",`Metric loss "${t}" must be non-negative and no greater than its sources.`,`${o}.metrics.${t}`));return!e.diagnostics.some(e=>"error"===e.severity)}function kn(e,t,i,r,o,n,a){return{id:e.id,label:e.label??e.id,description:e.description,category:e.category??"product",color:e.color,order:e.order,declaredAmount:e.amount,amount:n&&void 0!==e.amount?e.amount:i,metrics:n&&e.metrics?sn(r,e.metrics):ln(r),status:n?"complete":"forming",sourceIds:[...t],outletId:n?e.outletId??(o.outletIds.has("product")?"product":void 0):void 0,createdByEventId:o.event.id,createdAt:o.context.appliedAt,completedByEventId:n?o.event.id:void 0,completedAt:n?o.context.appliedAt:void 0,history:[a]}}function An(e,t,i,r){void 0!==t.amount&&Math.abs(t.amount-i)>pg&&e.diagnostics.push(hn("warning","declared-product-amount-mismatch",`Product "${t.id}" declares ${t.amount}, while its sources yield ${i}.`,r,[t.id]))}function Sn(e,t,i){let r=`events.${e.event.id}.effects.${i}`,o=e.state;if("set-state"===t.type){["queued","active","transformed","retained","ejected","failed","recovered"].includes(t.state)||e.diagnostics.push(hn("error","invalid-component-state",`set-state cannot assign "${t.state+""}".`,r+".state")),e.diagnostics.push(...pn(t.metricsDelta,r+".metricsDelta")),xn(e,t.outletId,r+".outletId");let i=gn(o,t.select,r+".select");e.diagnostics.push(...i.diagnostics);let n=i.ids.filter(e=>o.components[e].productIds.length);if(n.length&&e.diagnostics.push(hn("error","source-already-assigned",`Assigned source components cannot be retargeted: ${n.join(", ")}.`,r+".select",n)),e.diagnostics.some(e=>"error"===e.severity))return;let a=mn(e,t,{sourceIds:i.ids,outletIds:t.outletId?[t.outletId]:void 0});for(let e of i.ids){let i=o.components[e];i.status=t.state,i.outletId=t.outletId,i.reason=t.reason,t.metricsDelta&&yn(i.metrics,t.metricsDelta),i.history.push(a)}return o.history.push(a),void(i.ids.length&&bn(e,{type:"retarget-component",sourceIds:i.ids,outletIds:t.outletId?[t.outletId]:void 0}))}if("set-relation"===t.type){let{relation:i}=t;(!i.id||o.relations[i.id])&&e.diagnostics.push(hn("error","duplicate-relation",`Relation id "${i.id}" is missing or already active.`,r+".relation.id",[i.id]));let n=function(e,t,i){let r=fn(t),o=t.filter(t=>!e.state.components[t]);return 2>t.length&&e.diagnostics.push(hn("error","insufficient-relation-sources","A relation requires at least two source components.",i)),r.length&&e.diagnostics.push(hn("error","duplicate-source",`Relation source ids must be unique: ${r.join(", ")}.`,i,r)),o.length&&e.diagnostics.push(hn("error","unknown-component",`Relation references unknown source component${1===o.length?"":"s"}: ${o.join(", ")}.`,i,o)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}(e,i.sourceIds,r+".relation.sourceIds");if(e.diagnostics.push(...pn(i.metrics,r+".relation.metrics")),!n||e.diagnostics.some(e=>"error"===e.severity))return;o.relations[i.id]={...i,sourceIds:[...i.sourceIds],metrics:i.metrics?ln(i.metrics):void 0,status:"active",createdByEventId:e.event.id,createdAt:e.context.appliedAt};let a=mn(e,t,{sourceIds:[...i.sourceIds],relationIds:[i.id]});return o.history.push(a),void bn(e,{type:"activate-relation",sourceIds:[...i.sourceIds],relationIds:[i.id]})}if("resolve-relation"===t.type){let i=fn(t.relationIds),n=t.relationIds.filter(e=>!o.relations[e]),a=t.relationIds.filter(e=>"resolved"===o.relations[e]?.status);if(i.length&&e.diagnostics.push(hn("error","duplicate-relation","Relation ids must be unique.",r+".relationIds",i)),n.length&&e.diagnostics.push(hn("error","unknown-relation",`Unknown relation: ${n.join(", ")}.`,r+".relationIds",n)),a.length&&e.diagnostics.push(hn("error","resolved-relation",`Relation is already resolved: ${a.join(", ")}.`,r+".relationIds",a)),e.diagnostics.some(e=>"error"===e.severity))return;for(let i of t.relationIds){let r=o.relations[i];r.status="resolved",r.resolution=t.resolution,r.resolvedByEventId=e.event.id,r.resolvedAt=e.context.appliedAt,r.reason=t.reason}let s=mn(e,t,{relationIds:[...t.relationIds]});return o.history.push(s),void bn(e,{type:"resolve-relation",relationIds:[...t.relationIds]})}if("combine"===t.type||"contribute"===t.type){let i=e.productDefinitions.get(t.productId);i||e.diagnostics.push(hn("error","unknown-product",`Product "${t.productId}" has no declared mold.`,r+".productId",[t.productId]));let n=o.products[t.productId];"combine"===t.type&&n&&e.diagnostics.push(hn("error","duplicate-product",`Product "${t.productId}" has already been formed.`,r+".productId",[t.productId])),"contribute"===t.type&&(!n||"forming"!==n.status)&&e.diagnostics.push(hn("error","product-not-forming",`Contributions require an existing forming product "${t.productId}".`,r+".productId",[t.productId]));let a=vn(e,t.sourceIds,r+".sourceIds"),s="contribute"===t.type&&n?[...n.sourceIds,...t.sourceIds]:t.sourceIds,l=function(e,t,i,r){if(!t?.length)return[];let o=fn(t),n=t.filter(t=>!e.state.relations[t]),a=t.filter(t=>"resolved"===e.state.relations[t]?.status),s=new Set(i),l=t.filter(t=>(e.state.relations[t]?.sourceIds??[]).some(e=>!s.has(e)));return o.length&&e.diagnostics.push(hn("error","duplicate-relation","Basis relations must be unique.",r,o)),n.length&&e.diagnostics.push(hn("error","unknown-relation",`Unknown basis relation: ${n.join(", ")}.`,r,n)),a.length&&e.diagnostics.push(hn("error","resolved-relation",`Basis relation is already resolved: ${a.join(", ")}.`,r,a)),l.length&&e.diagnostics.push(hn("error","relation-source-mismatch",`Basis relation includes a source outside this product: ${l.join(", ")}.`,r,l)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.relations[t])}(e,t.basisRelationIds,s,r+".basisRelationIds");if(!a||!l||!i||e.diagnostics.some(e=>"error"===e.severity))return;let c=a.reduce((e,t)=>e+t.amount,0),u=function(e){let t=an();for(let i of e)yn(t,i.metrics);return t}(a);if(!wn(e,c,u,t.loss,r+".loss"))return;let d=c-(t.loss?.amount??0);!function(e,t,i){e.state.loss.amount+=i?.amount??0;for(let[r,o]of Object.entries(i?.metrics??{}))t[r]=Number(t[r]??0)-o,e.state.loss.metrics[r]=Number(e.state.loss.metrics[r]??0)+o}(e,u,t.loss);let h,f="combine"===t.type&&!1!==t.complete,p=mn(e,t,{sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0});if("combine"===t.type){if(f&&An(e,i,d,r+".productId"),h=kn(i,t.sourceIds,d,u,e,f,p),f&&!xn(e,h.outletId,r+".productId"))return;o.products[t.productId]=h}else h=n,h.sourceIds.push(...t.sourceIds),h.amount+=d,yn(h.metrics,u),h.history.push(p);for(let e of a)e.productIds=[t.productId],e.status="consumed",e.outletId=void 0,e.history.push(p);return o.history.push(p),function(e,t){if(t.length){for(let i of t)i.status="resolved",i.resolution="combined",i.resolvedByEventId=e.event.id,i.resolvedAt=e.context.appliedAt;bn(e,{type:"resolve-relation",relationIds:t.map(e=>e.id)})}}(e,l),bn(e,{type:"combine"===t.type?"form-product":"update-product",sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0,outletIds:h.outletId?[h.outletId]:void 0}),void(f&&bn(e,{type:"complete-product",sourceIds:[...h.sourceIds],productIds:[h.id],outletIds:h.outletId?[h.outletId]:void 0}))}if("complete-product"===t.type){let i=o.products[t.productId];return i?void function(e,t,i,r,o,n){let a=e.productDefinitions.get(t.id),s=i??a?.outletId??(e.outletIds.has("product")?"product":void 0);if(!xn(e,s,n+".outletId"))return;if("complete"===t.status)return void e.diagnostics.push(hn("error","product-already-complete",`Product "${t.id}" is already complete.`,n,[t.id]));a&&(An(e,a,t.amount,n+".productId"),void 0!==a.amount&&(t.amount=a.amount),a.metrics&&(t.metrics=sn(t.metrics,a.metrics))),t.status="complete",t.outletId=s,t.reason=r,t.completedByEventId=e.event.id,t.completedAt=e.context.appliedAt;let l=mn(e,o,{sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:s?[s]:void 0});t.history.push(l),e.state.history.push(l),bn(e,{type:"complete-product",sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:s?[s]:void 0})}(e,i,t.outletId,t.reason,t,r):void e.diagnostics.push(hn("error","unknown-product-state",`Product "${t.productId}" has not been formed.`,r+".productId",[t.productId]))}if("split"===t.type){let i=vn(e,[t.sourceId],r+".sourceId");t.products.length||e.diagnostics.push(hn("error","empty-split","A split requires at least one product allocation.",r+".products"));let n=t.products.map(e=>e.productId),a=fn(n);a.length&&e.diagnostics.push(hn("error","duplicate-product","Split product ids must be unique.",r+".products",a));let s=n.map(t=>e.productDefinitions.get(t)),l=n.filter((e,t)=>!s[t]),c=n.filter(e=>o.products[e]);l.length&&e.diagnostics.push(hn("error","unknown-product",`Split references undeclared product molds: ${l.join(", ")}.`,r+".products",l)),c.length&&e.diagnostics.push(hn("error","duplicate-product",`Split products already exist: ${c.join(", ")}.`,r+".products",c));for(let[i,o]of t.products.entries())void 0!==o.amount&&(!Number.isFinite(o.amount)||0>o.amount)&&e.diagnostics.push(hn("error","invalid-product-amount","Split allocation amounts must be finite and non-negative.",`${r}.products.${i}.amount`)),e.diagnostics.push(...pn(o.metrics,`${r}.products.${i}.metrics`));if(!i?.length||e.diagnostics.some(e=>"error"===e.severity))return;let u=i[0];if(!wn(e,u.amount,u.metrics,t.loss,r+".loss"))return;let d=u.amount-(t.loss?.amount??0),h=t.products.map((e,t)=>e.amount??s[t]?.amount),f=h.filter(e=>void 0!==e).length;if(0!==f&&f!==h.length)return void e.diagnostics.push(hn("error","partial-split-allocation","Either every split product must declare an amount or none may do so.",r+".products"));let p=f?h:t.products.map(()=>d/t.products.length),y=p.reduce((e,t)=>e+t,0);if(Math.abs(y-d)>pg)return void e.diagnostics.push(hn("error","split-amount-mismatch",`Split allocations total ${y}, but ${d} remains after loss.`,r+".products"));let g=ln(u.metrics);for(let[e,i]of Object.entries(t.loss?.metrics??{}))g[e]=Number(g[e]??0)-i;let m=mn(e,t,{sourceIds:[u.id],productIds:n});if(t.products.forEach((i,n)=>{let a=s[n],l=d>pg?p[n]/d:1/t.products.length,c=an(Object.entries(g).map(([e,t])=>[e,t*l])),h=i.metrics??a.metrics??c,f=kn({...a,amount:p[n],metrics:h},[u.id],p[n],ln(h),e,!0,m);xn(e,f.outletId,`${r}.products.${n}.productId`)&&(o.products[f.id]=f)}),e.diagnostics.some(e=>"error"===e.severity))return;u.productIds=n,u.status="consumed",u.outletId=void 0,u.history.push(m),o.loss.amount+=t.loss?.amount??0;for(let[e,i]of Object.entries(t.loss?.metrics??{}))o.loss.metrics[e]=Number(o.loss.metrics[e]??0)+i;o.history.push(m),bn(e,{type:"split-source",sourceIds:[u.id],productIds:n});for(let t of n)bn(e,{type:"complete-product",sourceIds:[u.id],productIds:[t],outletIds:o.products[t].outletId?[o.products[t].outletId]:void 0});return}if("eject"===t.type){xn(e,t.outletId,r+".outletId");let i=gn(o,t.select,r+".select");e.diagnostics.push(...i.diagnostics);let n=i.ids.filter(e=>o.components[e].productIds.length);if(n.length&&e.diagnostics.push(hn("error","source-already-assigned",`Assigned source components cannot be ejected: ${n.join(", ")}.`,r+".select",n)),e.diagnostics.some(e=>"error"===e.severity))return;let a=mn(e,t,{sourceIds:i.ids,outletIds:[t.outletId]});for(let e of i.ids){let i=o.components[e];i.status=t.state??"ejected",i.outletId=t.outletId,i.reason=t.reason,i.history.push(a)}return o.history.push(a),void(i.ids.length&&bn(e,{type:"retarget-component",sourceIds:i.ids,outletIds:[t.outletId]}))}if("set-metric"===t.type){if(e.diagnostics.push(...pn(t.metricsDelta,r+".metricsDelta")),e.diagnostics.some(e=>"error"===e.severity))return;let i,n;if("run"===t.target)yn(o.metrics,t.metricsDelta);else if("components"in t.target){let n=gn(o,t.target.components,r+".target.components");if(e.diagnostics.push(...n.diagnostics),e.diagnostics.some(e=>"error"===e.severity))return;i=n.ids;for(let e of n.ids)yn(o.components[e].metrics,t.metricsDelta)}else{n=[...t.target.productIds];let i=fn(n),a=n.filter(e=>!o.products[e]);if(i.length&&e.diagnostics.push(hn("error","duplicate-product","Metric target product ids must be unique.",r+".target.productIds",i)),a.length&&e.diagnostics.push(hn("error","unknown-product-state",`Metric target product has not formed: ${a.join(", ")}.`,r+".target.productIds",a)),e.diagnostics.some(e=>"error"===e.severity))return;for(let e of n)yn(o.products[e].metrics,t.metricsDelta)}return void o.history.push(mn(e,t,{sourceIds:i,productIds:n}))}t.outcome.trim()?(o.outcome=t.outcome,o.summary=t.summary,o.history.push(mn(e,t)),e.observations.push({type:"crucible-outcome",eventId:e.event.id,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,outcome:t.outcome})):e.diagnostics.push(hn("error","invalid-outcome","Outcome must be a non-empty string.",r+".outcome"))}function Mn(e,t,i){if(e.eventsApplied.includes(t.id))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:[hn("warning","duplicate-event-application",`Event "${t.id}" has already been applied.`,"events."+t.id,[t.id])]};let r=un(e),o={state:r,event:t,context:i,productDefinitions:new Map(i.products.map(e=>[e.id,e])),outletIds:new Set(i.outlets.map(e=>e.id)),diagnostics:[],materializations:[],observations:[]};for(let[i,r]of t.effects.entries())if(Sn(o,r,i),o.diagnostics.some(e=>"error"===e.severity))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:o.diagnostics};return r.elapsed=Math.max(r.elapsed,i.appliedAt),r.phaseId=i.phaseId,r.eventsApplied.push(t.id),o.observations.unshift({type:"crucible-event",eventId:t.id,phaseId:i.phaseId,authoredAt:i.authoredAt,appliedAt:i.appliedAt}),{applied:!0,state:r,materializations:o.materializations,observations:o.observations,diagnostics:o.diagnostics}}function _n(e,t){return t>e?-1:e>t?1:0}function $n(e,t,i,r,o){return{severity:e,code:t,message:i,path:r,ids:o?[...o]:void 0}}function Pn(e){let t=new Set,i=new Set;for(let r of e)t.has(r)&&i.add(r),t.add(r);return[...i].sort(_n)}function Rn(e){let t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function In(e,t,i,r,o,n){if(!i)return r;try{return("function"==typeof i?i(e,t):e[i])??r}catch(e){return o.push($n("error","accessor-error",`Accessor threw: ${e instanceof Error?e.message:e+""}.`,n)),r}}function Ln(e,t,i){if(!e||"object"!=typeof e||Array.isArray(e))return null!=e&&t.push($n("error","invalid-metrics","Metrics must be a numeric object.",i)),an();let r=an();for(let[o,n]of Object.entries(e)){let e=Rn(n);null!=e?r[o]=e:t.push($n("error","invalid-metric",`Metric "${o}" must be finite.`,`${i}.${o}`))}return r}function Tn(e){return e.map((e,t)=>({outlet:e,index:t})).sort((e,t)=>(e.outlet.order??e.index)-(t.outlet.order??t.index)||e.index-t.index).map(({outlet:e})=>({...e}))}function Cn(e){let{id:t,orientation:i,fixed:r,start:o,end:n,openings:a,thickness:s,friction:l,restitution:c}=e,u=function(e,t,i){let r=i.map(([i,r])=>[Math.max(e,Math.min(i,r)),Math.min(t,Math.max(i,r))]).filter(([e,t])=>t>e+bg).sort((e,t)=>e[0]-t[0]||e[1]-t[1]),o=[],n=e;for(let[e,t]of r)e>n+bg&&o.push([n,e]),n=Math.max(n,t);return t>n+bg&&o.push([n,t]),o}(o,n,a);return u.map(([e,o],n)=>({id:1===u.length?t:`${t}:${n}`,friction:l,restitution:c,shape:"horizontal"===i?{type:"segment",x1:e,y1:r,x2:o,y2:r,thickness:s}:{type:"segment",x1:r,y1:e,x2:r,y2:o,thickness:s}}))}function On(e){let t=2166136261;for(let i=0;e.length>i;i+=1)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return t>>>0}function Fn(e){return"number"==typeof e&&Number.isFinite(e)?e>>>0:"string"==typeof e?On(e):1}function Dn(e,t){return{fixedDt:1/120,maxSubsteps:8,settleStepLimit:7200,colliders:t.map(e=>({...e,shape:{...e.shape}})),observation:{chartType:"crucible"},kernel:{seed:Fn(e),gravity:{x:0,y:0},cellSize:42,collisionIterations:6,velocityDamping:.992,restitution:.12,friction:.42,sleepSpeed:4,sleepAfter:.5,maxVelocity:620}}}function zn(e){return"crucible:component:"+encodeURIComponent(e)}function Nn(e,t,i,r){if(void 0!==i&&Number.isFinite(i)&&i>0)return i;let o=Math.min(...t,e),n=Math.max(...t,e);return n-o>bg?r[0]+(r[1]-r[0])*Math.sqrt(Math.max(0,e-o)/(n-o)):(r[0]+r[1])/2}function En(e,t){let i=Math.max(.25,Math.min(1,t.width/900,t.height/520)),r=e?.[0]??7*i,o=e?.[1]??18*i,n=Math.max(1,Math.min(r,o));return[n,Math.max(n,Math.max(r,o))]}function Bn(e,t){if(!e)return[];let i=Math.min(e,Math.max(1,Math.ceil(Math.sqrt(e*Math.max(.5,t.width/Math.max(1,t.height)))))),r=Math.max(1,Math.ceil(e/i));return Array.from({length:e},(e,o)=>({x:t.x+t.width/i*(o%i+.5),y:t.y+(Math.floor(o/i)+.5)*(t.height/r)}))}function Wn(e){return e.outletId?e.outletId:"failed"===e.status?"failed":"recovered"===e.status?"recovered":"retained"===e.status?"retained":"ejected"===e.status?"residue":void 0}function jn(e,t){return e.outlets.find(e=>e.id===t)||{x:e.chamber.x+.18*e.chamber.width,y:e.chamber.y+.2*e.chamber.height,width:.64*e.chamber.width,height:.6*e.chamber.height}}function Yn(e,t,i={}){let r=Object.values(e.products).sort((e,t)=>_n(e.id,t.id)),o=Object.values(e.components).sort((e,t)=>_n(e.id,t.id)),n=[...o.map(e=>e.amount),...r.map(e=>e.amount)],a=En(i.radiusRange,t),s=function(e,t){let i=new Map;for(let t of e){let e=t.outletId??"__chamber__",r=i.get(e)??[];r.push(t),i.set(e,r)}let r=new Map;for(let[e,o]of i){o.sort((e,t)=>(e.order??Number.MAX_SAFE_INTEGER)-(t.order??Number.MAX_SAFE_INTEGER)||_n(e.id,t.id));let i=Bn(o.length,jn(t,"__chamber__"===e?void 0:e));o.forEach((e,t)=>r.set(e.id,i[t]))}return r}(r,t),l=r.map(e=>{let r=s.get(e.id)??{x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2},o=1.28*Nn(e.amount,n,i.bodyRadius,a),l={__crucible:!0,kind:"product",semanticId:e.id,product:e};return{id:(c=e.id,"crucible:product:"+encodeURIComponent(c)),x:r.x,y:r.y,mass:Math.max(.25,o*o*.018),bodyCollisions:!1,shape:{type:"circle",radius:o},datum:l};var c}),c=new Map;for(let e of o.filter(e=>!e.productIds.length)){let t=Wn(e)??"__chamber__",i=c.get(t)??[];i.push(e),c.set(t,i)}let u=new Map;for(let[e,i]of c){let r=Bn(i.length,jn(t,"__chamber__"===e?void 0:e));i.forEach((e,t)=>u.set(e.id,r[t]))}return[...o.map(e=>{let r=u.get(e.id);if(e.productIds.length){let i=e.productIds.map(e=>s.get(e)).filter(e=>!!e);if(i.length){r={x:i.reduce((e,t)=>e+t.x,0)/i.length,y:i.reduce((e,t)=>e+t.y,0)/i.length};let o=On(e.id)/4294967295*Math.PI*2,n=Math.min(20,Math.max(4,.012*t.width));r={x:r.x+Math.cos(o)*n,y:r.y+Math.sin(o)*n}}}r??(r={x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2});let o=Nn(e.amount,n,i.bodyRadius,a),l={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:zn(e.id),x:r.x,y:r.y,mass:Math.max(.25,o*o*.015),shape:{type:"circle",radius:o},datum:l}}),...l]}function Xn(e){return Array.isArray(e)?e.map(Xn):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e&&"function"!=typeof e).sort(([e],[t])=>_n(e,t)).map(([e,t])=>[e,Xn(t)])):e}function qn(e,t=e.duration){let i=function(e,t){let i=Rn(t)??0,r=Math.max(0,Math.min(e.duration,i));if(!e.phases.length)return{elapsed:r,phaseId:"",phaseIndex:-1,phaseElapsed:0,complete:!0};let o=r>=e.duration-bg,n=o?e.phases[e.phases.length-1]:e.phases.find(e=>r>=e.start&&e.end>r)??e.phases[0];return{elapsed:r,phaseId:n.id,phaseIndex:n.index,phaseElapsed:o?n.duration:Math.max(0,r-n.start),complete:o}}(e,t),r=un(e.initialState),o=[],n=[],a=[];for(let t of e.events){if(t.authoredAt>i.elapsed+bg)break;let s=Mn(r,t,{phaseId:t.phaseId,authoredAt:t.authoredAt,appliedAt:t.authoredAt,products:e.products,outlets:e.outlets});o.push(...s.diagnostics),n.push(...s.materializations),a.push(...s.observations),s.applied&&(r=s.state)}return r.elapsed=i.elapsed,r.phaseId=i.phaseId,r.phaseIndex=i.phaseIndex,r.phaseElapsed=i.phaseElapsed,r.complete=i.complete,i.complete&&"in_process"===r.outcome&&(r.outcome="complete"),r.playing=!1,{state:r,diagnostics:o,materializations:n,observations:a}}function Gn(e){let t=function(e){let t=[];e.length||t.push($n("error","empty-phase-program","CrucibleChart requires at least one phase.","phases"));let i=Pn(e.map(e=>e.id));i.length&&t.push($n("error","duplicate-phase-id",`Phase ids must be unique: ${i.join(", ")}.`,"phases",i));let r=0;return{phases:e.map((e,i)=>{let o=Rn(e.duration),n=null!=o&&o>0?o:0;e.id.trim()||t.push($n("error","invalid-phase-id","Phase ids may not be empty.",`phases.${i}.id`)),(null==o||0>=o)&&t.push($n("error","invalid-phase-duration","Phase duration must be finite and greater than zero.",`phases.${i}.duration`,[e.id])),void 0!==e.intensity&&!Number.isFinite(e.intensity)&&t.push($n("error","invalid-phase-intensity","Phase intensity must be finite.",`phases.${i}.intensity`,[e.id]));let a={...e,duration:n,intensity:void 0===e.intensity?.5:Number.isFinite(e.intensity)?Math.max(0,Math.min(1,e.intensity)):.5,motion:e.motion??"hold",index:i,start:r,end:r+n};return r=a.end,a}),diagnostics:t}}(e.phases),i=t.phases.at(-1)?.end??0,r=Tn(e.outlets??gg),o=(e.products??[]).map(e=>({...e,metrics:e.metrics?sn(e.metrics):void 0})),n=function(e,t,i){let r=[],o=Pn(e.map(e=>e.id));o.length&&r.push($n("error","duplicate-event-id",`Event ids must be unique: ${o.join(", ")}.`,"events",o));let n=[];return e.forEach((e,o)=>{let a,s,l;if(e.id.trim()||r.push($n("error","invalid-event-id","Event ids may not be empty.",`events.${o}.id`)),"time"in e.at&&void 0!==e.at.time){let n=Rn(e.at.time);if(null==n||0>n||n>i+bg)return void r.push($n("error","event-time-out-of-range",`Event time must fall between 0 and ${i}.`,`events.${o}.at.time`,[e.id]));a=Math.max(0,Math.min(i,n));let c=function(e,t,i){let r=e.find(e=>bg>=Math.abs(e.start-i));if(r)return{phase:r,boundaryRank:1};let o=e.find(e=>i>=e.start&&e.end>i);return o?{phase:o,boundaryRank:0}:bg>=Math.abs(i-t)&&e.length?{phase:e[e.length-1],boundaryRank:0}:{phase:void 0,boundaryRank:1}}(t,i,a);s=c.phase,l=c.boundaryRank}else{if(s=t.find(t=>t.id===e.at.phaseId),!s)return void r.push($n("error","unknown-event-phase",`Event references unknown phase "${e.at.phaseId}".`,`events.${o}.at.phaseId`,[e.id,e.at.phaseId]));let i=e.at.progress??0;if(!Number.isFinite(i)||0>i||i>1)return void r.push($n("error","event-progress-out-of-range","Event phase progress must be between 0 and 1.",`events.${o}.at.progress`,[e.id]));a=s.start+s.duration*i,l=0===i?1:0}s?n.push({...e,index:o,authoredAt:a,phaseId:s.id,phaseIndex:s.index,boundaryRank:l}):r.push($n("error","event-without-phase","Event could not be assigned to a phase.",`events.${o}.at`,[e.id]))}),n.sort((e,t)=>e.authoredAt-t.authoredAt||e.boundaryRank-t.boundaryRank||e.index-t.index),{events:n,diagnostics:r}}(e.events??[],t.phases,i),a=function(e){let t=[],i=an(),r=[],o=0,n=an();e.data.forEach((a,s)=>{let l=(a.id??"component-"+s)+"",c=((In(a,s,e.idAccessor,l,t,`data.${s}.id`)??l)+"").trim();if(!c)return void t.push($n("error","invalid-component-id","Component ids may not be empty.",`data.${s}.id`));r.push(c);let u=Rn(In(a,s,e.amountAccessor,1,t,`data.${s}.amount`)),d=null==u||0>u?0:u;(null==u||0>u)&&t.push($n("error","invalid-component-amount","Component amount must be finite and non-negative.",`data.${s}.amount`,[c]));let h=Ln(In(a,s,e.metricsAccessor,{},t,`data.${s}.metrics`),t,`data.${s}.metrics`),f=In(a,s,e.initialStateAccessor,"active",t,`data.${s}.status`),p=mg.has(f)?f:"active";mg.has(f)||t.push($n("error","invalid-component-status",`Unknown component status "${f+""}".`,`data.${s}.status`,[c]));let y=In(a,s,e.labelAccessor,(a.label??a.name??c)+"",t,`data.${s}.label`)+"",g=In(a,s,e.categoryAccessor,"component",t,`data.${s}.category`)+"";Object.hasOwn(i,c)||(i[c]={id:c,label:y,category:g,datum:a,status:p,initialAmount:d,amount:d,initialMetrics:sn(h),metrics:sn(h),productIds:[],history:[]},o+=d,function(e,t){for(let[i,r]of Object.entries(t))e[i]=Number(e[i]??0)+r}(n,h))});let a=Pn(r);a.length&&t.push($n("error","duplicate-component-id",`Component ids must be unique: ${a.join(", ")}.`,"data",a));let s=Ln(e.metrics??{},t,"metrics");return{state:{elapsed:0,phaseElapsed:0,phaseId:e.phases[0]?.id??"",phaseIndex:e.phases.length?0:-1,playing:!1,complete:0===e.phases.length,outcome:"in_process",eventsApplied:[],components:i,products:an(),relations:an(),input:{amount:o,metrics:n},metrics:s,loss:{amount:0,metrics:an()},history:[]},diagnostics:t}}(e),s=function(e=yg,t=gg){let i=Math.max(1,Rn(e[0])??900),r=Math.max(1,Rn(e[1])??520),o=360>i||260>r,n=o?Math.max(4,.035*Math.min(i,r)):20,a=o?Math.max(10,.075*r):34,s={x:n,y:n,width:Math.max(1,i-2*n),height:a},l=o?Math.max(16,.14*r):Math.min(78,.16*r),c={x:n,y:r-n-l,width:Math.max(1,i-2*n),height:l},u=o?Math.max(12,.08*i):Math.min(150,.17*i),d=s.y+s.height+(o?12:38),h=c.y-(o?10:34),f={x:u,y:d,width:Math.max(24,i-2*u),height:Math.max(24,h-d)},p=Math.max(18,Math.min(.32*f.width,o?84:180)),y={x:f.x+(f.width-p)/2,y:f.y-(o?10:24),width:p,height:o?12:28},g=Tn(t),m={left:g.filter(e=>"left"===(e.side??"bottom")),right:g.filter(e=>"right"===e.side),bottom:g.filter(e=>"bottom"===(e.side??"bottom"))},b=[],x=(e,t)=>{let r=Math.max(8,u-1.5*n),a=f.height/Math.max(1,t.length);t.forEach((t,s)=>{b.push({...t,side:e,x:"left"===e?n:i-n-r,y:f.y+s*a,width:r,height:Math.max(8,a-(o?2:8))})})};x("left",m.left),x("right",m.right);let v=f.width/Math.max(1,m.bottom.length);return m.bottom.forEach((e,t)=>{b.push({...e,side:"bottom",x:f.x+t*v,y:f.y+f.height+(o?2:7),width:Math.max(8,v-(o?2:8)),height:Math.max(8,c.y-f.y-f.height-(o?4:12))})}),b.sort((e,t)=>g.findIndex(t=>t.id===e.id)-g.findIndex(e=>e.id===t.id)),{width:i,height:r,phaseRail:s,chamber:f,mouth:y,projection:c,outlets:b}}(e.size??yg,r),l=function(e){let{chamber:t,mouth:i}=e,r=Math.max(2,Math.min(10,.018*Math.min(e.width,e.height))),o=Math.max(t.x,i.x),n=Math.min(t.x+t.width,i.x+i.width),a={left:e.outlets.filter(e=>"left"===e.side),right:e.outlets.filter(e=>"right"===e.side),bottom:e.outlets.filter(e=>"bottom"===e.side)},s=[{id:"crucible:wall:top-left",friction:.42,restitution:.1,shape:{type:"segment",x1:t.x,y1:t.y,x2:o,y2:t.y,thickness:r}},{id:"crucible:wall:top-right",friction:.42,restitution:.1,shape:{type:"segment",x1:n,y1:t.y,x2:t.x+t.width,y2:t.y,thickness:r}}];s.push(...Cn({id:"crucible:wall:left",orientation:"vertical",fixed:t.x,start:t.y,end:t.y+t.height,openings:a.left.map(e=>[e.y,e.y+e.height]),thickness:r,friction:.46,restitution:.12}),...Cn({id:"crucible:wall:right",orientation:"vertical",fixed:t.x+t.width,start:t.y,end:t.y+t.height,openings:a.right.map(e=>[e.y,e.y+e.height]),thickness:r,friction:.46,restitution:.12}),...Cn({id:"crucible:wall:bottom",orientation:"horizontal",fixed:t.y+t.height,start:t.x,end:t.x+t.width,openings:a.bottom.map(e=>[e.x,e.x+e.width]),thickness:r,friction:.5,restitution:.08}));for(let t of e.outlets)s.push({id:"crucible:outlet:"+encodeURIComponent(t.id),sensor:!0,shape:{type:"aabb",x:t.x+t.width/2,y:t.y+t.height/2,width:t.width,height:t.height}});return s}(s),c=function(e,t){let i=[],r=new Set(t.map(e=>e.id)),o=Pn(t.map(e=>e.id)),n=Pn(e.map(e=>e.id));return o.length&&i.push($n("error","duplicate-outlet-id",`Outlet ids must be unique: ${o.join(", ")}.`,"outlets",o)),n.length&&i.push($n("error","duplicate-product-id",`Product ids must be unique: ${n.join(", ")}.`,"products",n)),t.forEach((e,t)=>{e.id.trim()||i.push($n("error","invalid-outlet-id","Outlet ids may not be empty.",`outlets.${t}.id`)),void 0!==e.order&&!Number.isFinite(e.order)&&i.push($n("error","invalid-outlet-order","Outlet order must be finite.",`outlets.${t}.order`,[e.id]))}),e.forEach((e,t)=>{e.id.trim()||i.push($n("error","invalid-product-id","Product ids may not be empty.",`products.${t}.id`)),void 0!==e.amount&&(!Number.isFinite(e.amount)||0>e.amount)&&i.push($n("error","invalid-product-amount","Declared product amount must be finite and non-negative.",`products.${t}.amount`,[e.id])),void 0!==e.outletId&&!r.has(e.outletId)&&i.push($n("error","unknown-outlet",`Product "${e.id}" references unknown outlet "${e.outletId}".`,`products.${t}.outletId`,[e.outletId])),Ln(e.metrics??{},i,`products.${t}.metrics`)}),i}(o,r),u=(m={seed:e.seed??1,components:Object.values(a.state.components).sort((e,t)=>_n(e.id,t.id)).map(e=>({id:e.id,label:e.label,category:e.category,amount:e.amount,metrics:e.metrics,status:e.status})),phases:t.phases.map(({id:e,duration:t,label:i,description:r,intensity:o,motion:n,color:a,metrics:s})=>({id:e,duration:t,label:i,description:r,intensity:o,motion:n,color:a,metrics:s})),products:o,outlets:r,events:n.events.map(({id:e,label:t,description:i,summary:r,authoredAt:o,phaseId:n,boundaryRank:a,effects:s})=>({id:e,label:t,description:i,summary:r,authoredAt:o,phaseId:n,boundaryRank:a,effects:s}))},JSON.stringify(Xn(m))),d=function(e,t,i={}){let r=Object.values(e.components).sort((e,t)=>_n(e.id,t.id)),o=r.map(e=>e.amount),n=En(i.radiusRange,t),a=function(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}(Fn(i.seed)),s=t.mouth.x+t.mouth.width/2,l=t.chamber.y+Math.max(18,.18*t.chamber.height),c=Math.max(4,.28*t.chamber.width),u=Math.max(4,.12*t.chamber.height);return r.map((e,t)=>{let d=t/Math.max(1,r.length)*Math.PI*2+.18*(a()-.5),h=Nn(e.amount,o,i.bodyRadius,n),f={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:zn(e.id),x:s+Math.cos(d)*c*(.45+.45*a()),y:l+Math.sin(d)*u*(.45+.45*a()),vx:24*(a()-.5),vy:18*(a()-.5),mass:Math.max(.25,h*h*.015),restitution:.12,friction:.4,shape:{type:"circle",radius:h},datum:f}})}(a.state,s,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),h=[...t.diagnostics,...n.diagnostics,...a.diagnostics,...c],f={phases:t.phases,events:n.events,products:o,outlets:r,duration:i,initialState:a.state,terminalState:a.state,layout:s,colliders:l,config:Dn(e.seed,l),initialSpawns:d,terminalSpawns:[],semanticKey:u,diagnostics:h},p=qn(f),y=Object.values(p.state.products).filter(e=>"forming"===e.status).map(e=>e.id),g=y.length?[$n("warning","forming-product-at-end",`Products remain forming at the end of the tape: ${y.join(", ")}.`,"events",y)]:[];var m;return f.terminalState=p.state,f.terminalSpawns=xg(p.state,s,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),f.diagnostics=[...h,...p.diagnostics,...g],f}function Vn(e,t){let i=e.fillStyle,r="#010203";try{e.fillStyle=r,e.fillStyle=t}catch{return e.fillStyle=i,[78,121,167]}let o=e.fillStyle;if(e.fillStyle=i,"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)];let n=o.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return n?[+n[1],+n[2],+n[3]]:[78,121,167]}function Hn(e){switch(e){case"monotoneX":return wg;case"monotoneY":return kg;case"cardinal":return Ag;case"catmullRom":return Sg;case"step":return Mg;case"stepBefore":return _g;case"stepAfter":return $g;case"basis":return Pg;case"natural":return Rg;default:return null}}function Un(e,t,i){if(null==t)return i;if(rr(t)){let r=function(e,t){let i=e.background??"transparent",r=e.stroke??"#000",o="transparent"===i||"none"===i?i:ir(t,i)||i,n=ir(t,r)||r||"#000",a="u">typeof window&&window.devicePixelRatio||1,s=`${or(e)}|${o}|${n}@${a}`,l=ty.get(s);if(void 0!==l)return l;let c=function(e={},t){let i,{background:r="transparent",stroke:o="#000",lineWidth:n=1.5,spacing:a=6,angle:s=45}=e,l={background:r,stroke:o,lineWidth:n,spacing:a,angle:s},c=Math.max(8,Math.ceil(2*a));try{i=function(e){return"u">typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Zp||(Zp=document.createElement("canvas")),Zp.width=e,Zp.height=e,Zp)}(c)}catch{return tr(l)}let u=i.getContext("2d");if(!u)return tr(l);r&&"transparent"!==r?(u.fillStyle=r,u.fillRect(0,0,c,c)):u.clearRect(0,0,c,c),u.strokeStyle=o,u.lineWidth=n,u.lineCap="square";let d=s*Math.PI/180;if(45===s||-45===s){let e=s>0?1:-1;for(let t=-c;2*c>=t;t+=a)u.beginPath(),u.moveTo(t,0),u.lineTo(t+e*c,c),u.stroke()}else{u.save(),u.translate(c/2,c/2),u.rotate(d);let e=2*c;for(let t=-e;e>=t;t+=a)u.beginPath(),u.moveTo(-e,t),u.lineTo(e,t),u.stroke();u.restore()}return(t||u).createPattern(i,"repeat")}({background:o,stroke:n,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle},t),u=rr(c)?null:c;return ty.set(s,u),u}(t,e);return r||t.background&&ir(e,t.background)||i}return"string"!=typeof t?t:ir(e,t)||i}function Kn(e,t,i){let r=Un(e,t,i);if("string"==typeof r&&r.trim().startsWith("var(")){let t=ir(e,i);return t&&!t.trim().startsWith("var(")?t:i}return r}function Zn(e,t,i,r,o,n,a){let s=t.stops.filter(e=>Number.isFinite(e.offset)&&(null==e.opacity||Number.isFinite(e.opacity)));if(2>s.length)return null;let l=e.createLinearGradient(r,o,n,a);for(let t of s)l.addColorStop(Math.max(0,Math.min(1,t.offset)),Qn(e,t,i));return l}function Qn(e,t,i){let r=t.color??i,o=ir(e,r)||r;if(null==t.opacity)return o;let n=Math.max(0,Math.min(1,t.opacity)),[a,s,l]=Vn(e,o);return`rgba(${a},${s},${l},${n})`}function Jn(e){return Number.isFinite(e)?1e3>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2).replace(/\.00$/,"").replace(/(\.\d)0$/,"$1"):e.toLocaleString():"0"}function ea(e,t,i,r){let o=e.datum;if(!o?.__crucible)return;let n="circle"===e.shape.type?e.shape.radius:8,a="string"==typeof t.fill?t.fill:"product"===o.kind?"#b8792d":"#356b63",s="string"==typeof t.stroke?t.stroke:"#26323a",l="number"==typeof t.strokeWidth?t.strokeWidth:1.25,c="number"==typeof t.opacity?t.opacity:.96,u=r?`${r}-crucible-body-${i}`:"crucible-body-"+i;if("product"===o.kind){let t=Array.from({length:6},(t,i)=>{let r=-Math.PI/2+i/6*Math.PI*2;return`${e.x+Math.cos(r)*n},${e.y+Math.sin(r)*n}`}).join(" "),i=u+"-glow";return Lg(vg.Fragment,{children:[Ig("defs",{children:Ig("filter",{id:i,x:"-60%",y:"-60%",width:"220%",height:"220%",children:Ig("feDropShadow",{dx:"0",dy:"0",stdDeviation:"4",floodColor:a,floodOpacity:"0.8"})})}),Ig("polygon",{points:t,fill:a,stroke:s,strokeWidth:l,opacity:c,filter:`url(#${i})`}),Ig("circle",{cx:e.x,cy:e.y,r:Math.max(2,.36*n),fill:"none",stroke:"var(--semiotic-bg, #fffaf0)",strokeWidth:l,opacity:.72*c})]},u)}return Lg(vg.Fragment,{children:[Ig("circle",{cx:e.x,cy:e.y,r:n,fill:a,stroke:s,strokeWidth:l,opacity:c}),Ig("circle",{cx:e.x-.25*n,cy:e.y-.28*n,r:Math.max(1,.18*n),fill:"rgba(255,255,255,0.34)"})]},u)}function ta(e){let{x:t,y:i,width:r,height:o}=e.chamber,n=Math.min(.14*r,48),a=i+o;return[`M ${t} ${i}`,`L ${t+n} ${a-.16*o}`,`Q ${t+r/2} ${a+.1*o} ${t+r-n} ${a-.16*o}`,`L ${t+r} ${i}`].join(" ")}function ia({layout:e,phases:t,state:i,compact:r=!1}){let o=Math.max(1,t.reduce((e,t)=>e+Math.max(0,t.duration),0));return Og("svg",{"aria-hidden":"true","data-testid":"crucible-chrome",viewBox:`0 0 ${e.width} ${e.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:[Og("defs",{children:[Og("linearGradient",{id:"semiotic-crucible-heat",x1:"0",x2:"0",y1:"0",y2:"1",children:[Cg("stop",{offset:"0",stopColor:zg,stopOpacity:"0.03"}),Cg("stop",{offset:"0.66",stopColor:zg,stopOpacity:"0.1"}),Cg("stop",{offset:"1",stopColor:Ng,stopOpacity:"0.18"})]}),Cg("pattern",{id:"semiotic-crucible-hatch",width:"7",height:"7",patternUnits:"userSpaceOnUse",patternTransform:"rotate(20)",children:Cg("line",{x1:"0",x2:"0",y1:"0",y2:"7",stroke:Fg,strokeOpacity:"0.08",strokeWidth:"1"})})]}),Cg("rect",{x:e.chamber.x,y:e.chamber.y,width:e.chamber.width,height:e.chamber.height,rx:2,fill:"url(#semiotic-crucible-heat)",stroke:Fg,strokeOpacity:"0.52",strokeWidth:r?1:2.2}),Cg("path",{d:ta(e),fill:"url(#semiotic-crucible-hatch)",stroke:"none"}),Cg("line",{x1:e.mouth.x,x2:e.mouth.x+e.mouth.width,y1:e.mouth.y,y2:e.mouth.y,stroke:Fg,strokeLinecap:"round",strokeOpacity:"0.72",strokeWidth:r?2:5}),r?null:Cg("g",{"data-testid":"crucible-phase-rail",children:t.map((r,n)=>{let a=t.slice(0,n).reduce((e,t)=>e+Math.max(0,t.duration),0),s=e.phaseRail.x+a/o*e.phaseRail.width,l=Math.max(0,r.duration)/o*e.phaseRail.width,c=r.id===i.phaseId,u=i.phaseIndex>n||i.complete;return Og("g",{children:[Cg("rect",{x:s,y:e.phaseRail.y,width:Math.max(1,l-2),height:e.phaseRail.height,rx:2,fill:c?r.color??zg:u?Eg:Fg,fillOpacity:c?.68:u?.28:.09}),46>l?null:Cg("text",{x:s+l/2,y:e.phaseRail.y+e.phaseRail.height+13,fill:c?Fg:Dg,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8.5,fontWeight:c?800:650,letterSpacing:"0.04em",textAnchor:"middle",children:(r.label??r.id).toUpperCase()})]},r.id)})}),e.outlets.map(e=>Og("g",{children:[Cg("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:3,fill:e.color??("left"===e.side?Ng:Eg),fillOpacity:"0.1",stroke:e.color??("left"===e.side?Ng:Eg),strokeDasharray:"3 3",strokeOpacity:"0.62"}),r?null:Cg("text",{x:e.x+e.width/2,y:e.y+Math.min(13,e.height/2+3),fill:Dg,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:750,letterSpacing:"0.05em",textAnchor:"middle",children:(e.label??e.id).toUpperCase()})]},e.id))]})}function ra({rows:e,layout:t,projection:i,amountLabel:r}){if(!e.length)return null;let o=i.measure??"count",n=e.map(e=>Math.max(0,function(e,t){return"count"===t?e.count:"amount"===t?e.amount:Number(e.metrics[t]??0)}(e,o))),a=Math.max(1,...n),s=t.projection.width/Math.max(1,e.length),l=t.projection.height>48?21:4,c=Math.max(5,t.projection.height-l-5);return Cg("svg",{"aria-hidden":"true","data-testid":"crucible-projection-overlay",viewBox:`0 0 ${t.width} ${t.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:e.map((e,i)=>{let u=n[i],d=Math.max(u>0?2:0,u/a*c),h=t.projection.x+i*s+.18*s;return Og("g",{children:[Cg("rect",{x:h,y:t.projection.y+c-d,width:Math.max(3,.64*s),height:d,rx:2,fill:"failed"===e.status||"ejected"===e.status?Ng:"complete"===e.status?zg:Eg,fillOpacity:"0.68"}),l>4&&s>=34?Og(Tg,{children:[Cg("text",{x:h+.32*s,y:t.projection.y+c+10,fill:Dg,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:7.5,fontWeight:700,textAnchor:"middle",children:e.label.length>13?e.label.slice(0,12)+"…":e.label}),Og("text",{x:h+.32*s,y:t.projection.y+c+19,fill:Fg,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:850,textAnchor:"middle",children:[Jn(u),"amount"===o&&r?" "+r:""]})]}):null]},e.key)})})}function oa(e){let t=e.datum;if(t&&"object"==typeof t){let e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e.id}function na(e,t,i,r,o){let n=Array.isArray(o)?o:o?[o]:[];if(!1!==i||0!==n.length)return({size:o})=>{let a=[Number(o[0])||700,Number(o[1])||420],s=vr(a),l=Math.max(2,Math.round(t)),c=s.plot.width/l,u=s.plot.y+s.plot.height,d=Math.max(1,...e.map(e=>e.value)),h=!1!==i,[f,p]=r?.valueExtent??[0,l],y=p===f?1:p-f,g=e.map((e,t)=>{let i=u-e.value/d*s.plot.height*.9;return`${0===t?"M":"L"} ${(s.plot.x+(t+.5)*c).toFixed(1)} ${i.toFixed(1)}`}).join(" ");return jg("svg",{"aria-hidden":"true","data-testid":"galton-board-structure-overlay",width:a[0],height:a[1],viewBox:`0 0 ${a[0]} ${a[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[h?jg(Bg,{children:[Array.from({length:l+1},(e,t)=>{let i=s.plot.x+t*c;return Wg("line",{"data-testid":"galton-board-bin-wall",x1:i,x2:i,y1:s.plot.y,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.28,strokeWidth:1},"bin-wall-"+t)}),Wg("line",{x1:s.plot.x,x2:s.plot.x+s.plot.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),Wg("path",{d:g,fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.7,strokeWidth:2,strokeLinejoin:"round"}),e.map((e,t)=>e.value>0?Wg("text",{x:s.plot.x+(t+.5)*c,y:Math.max(s.plot.y+10,u-e.value/d*s.plot.height*.9-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:e.value},`${e.label}-${t}`):null)]}):null,n.map((e,t)=>{let i=Number(e.value);if(!Number.isFinite(i))return null;let r=s.plot.x+Math.max(0,Math.min(1,(i-f)/y))*s.plot.width,o=e.color??"var(--semiotic-warning, #f28e2b)",n="bottom"===e.labelPosition?Math.min(a[1]-8,u+16):s.plot.y+16;return jg("g",{className:e.className,"data-testid":"galton-board-reference-line",children:[Wg("line",{x1:r,x2:r,y1:s.plot.y+8,y2:u-4,stroke:o,strokeDasharray:e.strokeDasharray??"6 5",strokeWidth:e.strokeWidth??2}),null==e.label?null:Wg("text",{x:Math.min(s.plot.x+s.plot.width-4,r+6),y:n,fill:o,fontSize:10,fontWeight:700,children:e.label})]},`galton-reference-${t}-${i}`)})]})}}function aa(e,t,i){if(!1!==i&&t)return({size:i})=>{let r=[Number(i[0])||760,Number(i[1])||360],o=vr(r),n=Math.max(1,t.windowCount),a=t.plot??o.plot,s=t.gutter??{x:a.x,y:a.y,width:0,height:a.height},l=t.windowPlot??a,c=l.width/n,u=a.y+a.height,d=a.y+.48*a.height,h=t.lidSegments[0]?.y1??d,f=t.windowStart,p=t.windowStart+n*t.windowSize,y=l.x+Math.max(0,Math.min(1,p===f?0:(t.watermarkValue-f)/(p-f)))*l.width;return jg("svg",{"aria-hidden":"true","data-testid":"event-drop-window-overlay",width:r[0],height:r[1],viewBox:`0 0 ${r[0]} ${r[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[Wg("rect",{x:a.x,y:a.y,width:a.width,height:a.height,fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.7,strokeWidth:1}),s.width>0?jg("g",{children:[Wg("rect",{x:s.x,y:h,width:s.width,height:u-h,fill:"var(--semiotic-danger, #e15759)",fillOpacity:.07}),jg("text",{x:s.x+s.width/2,y:h-8,textAnchor:"middle",fill:"var(--semiotic-danger, #e15759)",fontSize:10,fontWeight:700,children:[t.lateCount," late"]})]}):null,Array.from({length:n},(i,o)=>{let n=e[o],a=l.x+o*c,s=t.closedWindowCount>o;return jg("g",{children:[Wg("rect",{x:a,y:d,width:c,height:u-d,fill:s?"var(--semiotic-danger, #e15759)":"var(--semiotic-primary, #4e79a7)",fillOpacity:s?.08:.06}),s?t.lidSegments.filter(e=>e.windowIndex===o).map(e=>Wg("line",{x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2,stroke:"var(--semiotic-danger, #e15759)",strokeOpacity:.78,strokeWidth:2,strokeLinecap:"round"},e.id)):null,Wg("text",{x:a+c/2,y:d-8,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:n?.value??0}),Wg("text",{x:a+c/2,y:Math.min(r[1]-8,u+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:n?.label??""})]},"window-"+o)}),t.windowWalls?.map(({id:e,...t})=>Wg("rect",{...t,fill:"var(--semiotic-border, #d1d5db)",fillOpacity:.68},e)),t.lidSegments.filter(e=>null==e.windowIndex).map(e=>Wg("line",{x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2,stroke:"var(--semiotic-danger, #e15759)",strokeOpacity:.62,strokeWidth:2,strokeLinecap:"round"},e.id)),Wg("line",{x1:a.x,x2:a.x+a.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),Wg("line",{"data-testid":"event-drop-watermark",x1:y,x2:y,y1:a.y+8,y2:u,stroke:"var(--semiotic-warning, #f28e2b)",strokeDasharray:"5 4",strokeWidth:2}),jg("text",{x:Math.min(a.x+a.width-4,y+6),y:a.y+16,fill:"var(--semiotic-warning, #f28e2b)",fontSize:10,fontWeight:700,children:["watermark ",Math.round(100*t.watermarkValue)/100]})]})}}function sa(e,t,i,r=1){if(!1!==i&&0!==e.length)return({size:i})=>{let o=[Number(i[0])||700,Number(i[1])||380],n=vr(o),a=To(n.plot,e.length,t),s=n.plot.y+n.plot.height;return jg("svg",{"aria-hidden":"true","data-testid":"physics-pile-projection-overlay",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[Wg("line",{x1:n.plot.x,x2:n.plot.x+n.plot.width,y1:s,y2:s,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1}),e.map((e,t)=>{let i=Math.min(n.plot.height,a.pileHeight(e.value/r)),l=a.tubeWidth,c=a.centerX(t),u=s-i;return jg("g",{children:[Wg("rect",{x:c-l/2,y:u,width:l,height:i,rx:3,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.08,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.42,strokeWidth:1,strokeDasharray:"4 3"}),Wg("text",{x:c,y:Math.max(n.plot.y+12,u-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:11,fontWeight:700,children:e.value}),Wg("text",{x:c,y:Math.min(o[1]-8,s+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${t}`)}),Wg("text",{x:o[0]/2,y:o[1]-2,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:`Full circle = ${r}; partial circles scaled by area`})]})}}function la(e){return e.toLocaleString(void 0,Math.abs(e)>=1e3||.01>Math.abs(e)?{maximumFractionDigits:0}:{maximumFractionDigits:2})}function ca(e,t){if(!1!==t&&e)return({size:t})=>{let i=[Number(t[0])||700,Number(t[1])||360],r=vr(i),o=r.plot.y+r.plot.height,[n,a]=e.xExtent,s=n+(a-n)/2,l=[{label:la(n),x:e.xRange[0]},{label:la(s),x:e.xRange[0]+(e.xRange[1]-e.xRange[0])/2},{label:la(a),x:e.xRange[1]}];return jg("svg",{"aria-hidden":"true","data-testid":"collision-swarm-projection-overlay",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[e.groups.some(e=>e.overlapping)?Wg("text",{"data-testid":"collision-swarm-overlap-warning",x:r.plot.x,y:Math.max(10,r.plot.y-9),fill:"var(--semiotic-warning, #b45309)",fontSize:10,children:360>i[0]?"Points overlap":"Points overlap. Reduce radius or increase height."}):null,e.groups.map(e=>jg("g",{children:[Wg("line",{x1:r.plot.x,x2:r.plot.x+r.plot.width,y1:e.y,y2:e.y,stroke:"var(--semiotic-border, #d1d5db)",strokeDasharray:"3 5",strokeWidth:1}),Wg("text",{x:r.plot.x+4,y:e.y-7,fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:e.label}),jg("text",{x:r.plot.x+r.plot.width-4,y:e.y-7,textAnchor:"end",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:["n=",e.count,e.overlapping?" · overlaps":""]})]},e.label)),Wg("line",{x1:e.xRange[0],x2:e.xRange[1],y1:o,y2:o,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),l.map(e=>jg("g",{children:[Wg("line",{x1:e.x,x2:e.x,y1:o,y2:o+5,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),Wg("text",{x:e.x,y:Math.min(i[1]-8,o+18),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${e.x}`))]})}}function ua(e,t,i){return Math.max(t,Math.min(i,e))}function da(e){return 6.2*e.length}function ha(e,t,i="auto"){let r=Math.max(1,Math.floor(t/6.2)),o="compact"===i||"full"!==i&&da(e)>t?function(e,t){let i=e.trim();if(t>=i.length)return i;if(1>=t)return i.slice(0,1);let r=i.split(/\s+/).filter(Boolean).map(e=>e[0]).join("").toUpperCase();return r.length>1&&t>=r.length?r:t>3?i.slice(0,Math.max(1,t-2))+"..":i.slice(0,t).toUpperCase()}(e,r):e;return{text:o,textLength:da(o)>t?Math.max(4,t):void 0}}function fa(e,t,i={},r){if(!1===t||!e)return;let{volume:o,stages:n,groups:a,groupCompletion:s}=e,l=new Map(o.stages.map(e=>[e.id,e])),c=new Map(s.map(e=>[e.id,e]));return({size:e})=>{let t=Number(e[0])||o.width,s=Number(e[1])||o.height,u=n.map(e=>{let t=l.get(e.id),r=i["process-stage-"+e.id];return{id:e.id,label:e.label,x0:t?.x0??e.x-e.width/2,x1:(t?.x0??e.x-e.width/2)+(t?.width??e.width),x:e.x,width:t?.width??e.width,count:e.count,capacity:e.capacity,absorb:e.absorb,portalTarget:e.portalTarget,queueDepth:r?.queueDepth,processed:r?.processedCount}}),d=a.map(e=>{let t=c.get(e.id);return{id:e.id,label:e.label??e.id,x:e.anchor?.x??e.x??0,y:e.anchor?.y??e.y??0,absorbed:t?.absorbed,total:t?.total,complete:t?.complete}});return function(e,t={}){let{showFlowSpine:i=!0,showStageCounts:r=!0,showCapacityBadges:o=!0,showGroupSockets:n=!0,stageLabelMode:a="auto",outlineStages:s=!1,testId:l="process-flow-chrome"}=t,{width:c,height:u,left:d,right:h,topY:f,bottomY:p,midY:y,stages:g,groups:m=[]}=e,b=p-f;return qg("svg",{"aria-hidden":"true","data-testid":l,"data-outline-stages":s?"true":void 0,width:c,height:u,viewBox:`0 0 ${c} ${u}`,style:{position:"absolute",inset:0,pointerEvents:"none"},className:["semiotic-process-chrome",s?"semiotic-process-chrome--outline-stages":null].filter(Boolean).join(" "),children:[Xg("defs",{children:qg("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[Xg("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),Xg("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),Xg("rect",{x:0,y:0,width:c,height:u,fill:"url(#semiotic-process-floor)"}),Xg("rect",{x:d-6,y:f-8,width:h-d+12,height:b+16,rx:14,fill:"var(--semiotic-process-lane, var(--semiotic-surface, #111827))",fillOpacity:.45,stroke:"var(--semiotic-process-border, var(--semiotic-border, #334155))",strokeOpacity:.95}),i?Xg("line",{x1:d+8,x2:h-8,y1:y,y2:y,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,g.map((e,t)=>{let i=function(e){return e.absorb?"absorb":e.portalTarget?"portal":null!=e.capacity?"capacity":"flow"}(e),n=Gg[i],l=Math.max(12,e.width-8),c=ua(l-8,22,88),d=ha(e.label,Math.max(8,c-10),a),h="none"!==a&&l-8>=22,m=function(e){if(null!=e.capacity){let t=null!=e.queueDepth?" · q "+e.queueDepth:"";return e.capacityLabel?`${e.capacityLabel}${t}`:`cap ${Number.isInteger(e.capacity)?e.capacity+"":e.capacity.toFixed(1)}${t}`}return e.absorb?"absorb":e.portalTarget?"portal":"flow"}(e),x=ha(m,Math.max(16,l-10),"auto"),v=o&&!1!==e.showBadge&&l>=32,w=null!=e.count?`n=${e.count}${null!=e.processed?" done "+e.processed:""}`:"",k=ha(w,Math.max(16,l-8),"auto"),A=Math.max(30,f-15),S=A-13;return qg("g",{"data-stage":e.id,"data-role":i,children:[Xg("rect",{className:"semiotic-process-chrome__stage-bay",x:e.x0+4,y:f+6,width:l,height:b-12,rx:10,fill:s?"none":n.fill,stroke:n.stroke,strokeWidth:s?1.85:"flow"===i?1:1.6}),g.length-1>t?Xg("polygon",{points:`${e.x1-2},${y-7} ${e.x1+8},${y} ${e.x1-2},${y+7}`,fill:n.accent,opacity:.85}):null,h?qg(Yg,{children:[Xg("rect",{className:"semiotic-process-chrome__stage-label-bg",x:e.x-c/2,y:S,width:c,height:18,rx:9,fill:"var(--semiotic-bg, #0f172a)",fillOpacity:.75,stroke:n.stroke}),qg("text",{x:e.x,y:A,textAnchor:"middle",fill:n.accent,fontSize:10,fontWeight:800,className:"semiotic-process-chrome__stage-label",textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[Xg("title",{children:e.label}),d.text]})]}):null,v?qg("text",{x:e.x,y:f+22,textAnchor:"middle",fill:"var(--semiotic-process-muted, var(--semiotic-text-secondary, #94a3b8))",fontSize:9,fontWeight:700,textLength:x.textLength,lengthAdjust:x.textLength?"spacingAndGlyphs":void 0,children:[Xg("title",{children:m}),x.text]}):null,r&&null!=e.count?qg("text",{x:e.x,y:Math.min(u-8,p+16),textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #e2e8f0))",fontSize:11,fontWeight:800,textLength:k.textLength,lengthAdjust:k.textLength?"spacingAndGlyphs":void 0,children:[Xg("title",{children:w}),k.text]}):null]},e.id)}),n?m.map((e,t)=>{let i=e.total??0,r=e.absorbed??0,o=e.complete??(i>0&&r>=i),n=!o&&i>0&&r/i>=.75,a=o?"rgba(52, 211, 153, 0.35)":n?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",s=o?"#34d399":n?"#fbbf24":"var(--semiotic-border, #64748b)",l=i>0?`${r}/${i}${o?" shipped":n?" almost":""}`:"feature "+(t+1),c=ua(Math.max(54,da(e.label)+18,da(l)+16),54,104),u=ha(e.label,c-12,"auto"),d=ha(l,c-12,"auto");return qg("g",{"data-group":e.id,children:[Xg("rect",{x:e.x-c/2,y:e.y-22,width:c,height:44,rx:10,fill:a,stroke:s,strokeWidth:1.5}),qg("text",{x:e.x,y:e.y-4,textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #f8fafc))",fontSize:10,fontWeight:800,textLength:u.textLength,lengthAdjust:u.textLength?"spacingAndGlyphs":void 0,children:[Xg("title",{children:e.label}),u.text]}),qg("text",{x:e.x,y:e.y+12,textAnchor:"middle",fill:s,fontSize:9,fontWeight:700,textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[Xg("title",{children:l}),d.text]})]},e.id)}):null]})}({width:t,height:s,left:o.left,right:o.right,topY:o.topY,bottomY:o.bottomY,midY:o.midY,stages:u,groups:d},{showCapacityBadges:!0,showGroupSockets:!0,...r})}}function pa(e,t,i){if(!1===i||!t||0===e.length)return;let r=new Map(t.volume.stages.map(e=>[e.id,e]));return({size:i})=>{let o=[Number(i[0])||t.volume.width,Number(i[1])||t.volume.height],n=vr(o),a=Math.max(1,...e.map(e=>e.value)),s=Math.min(48,.18*n.plot.height),l=n.plot.y+6;return Vg("svg",{"aria-hidden":"true","data-testid":"process-flow-projection-overlay",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:t.stages.map((t,i)=>{let o=e[i];if(!o)return null;let n=r.get(t.id);if(!n)return null;let c=Math.max(2,o.value/a*s),u=Math.max(8,.35*n.width);return Vg("rect",{x:n.x-u/2,y:l,width:u,height:c,rx:2,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.18,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.45,strokeWidth:1},t.id)})})}}function ya(e){return e.map((e,t)=>`${0===t?"M":"L"} ${e.x} ${e.y}`).join(" ")}function ga(e,t){let{showNodeLabels:i,showSensors:r,showStaticFlow:o}=t;if(e&&(o||r||i))return({size:t})=>{let n=[Number(t[0])||760,Number(t[1])||420],a=Math.max(1,...e.links.map(e=>e.throughput)),s=new Set(e.nodes.map(e=>e.sensorId));return Ug("svg",{"aria-hidden":"true","data-testid":"physical-flow-static-flow-overlay",width:n[0],height:n[1],viewBox:`0 0 ${n[0]} ${n[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[o?e.links.map(e=>{let t=3+e.throughput/a*16,i=e.path[Math.floor(e.path.length/2)];return Ug("g",{children:[Hg("path",{d:ya(e.path),fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:t+5,strokeLinecap:"round",strokeLinejoin:"round",opacity:.26}),Hg("path",{d:ya(e.path),fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round",opacity:.16}),i?Hg("text",{x:i.x,y:i.y-t/2-5,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:(r=e.throughput,r.toLocaleString(void 0,1e3>Math.abs(r)?{maximumFractionDigits:1}:{maximumFractionDigits:0}))}):null]},e.id);var r}):null,e.nodes.map(e=>Ug("g",{children:[r&&s.has(e.sensorId)?Hg("rect",{"data-testid":"physical-flow-sensor-overlay",x:e.x-12,y:e.y-12,width:24,height:24,rx:4,fill:"none",stroke:"var(--semiotic-warning, #f59e0b)",strokeDasharray:"3 3",strokeWidth:1.5,opacity:.88}):null,o?Hg("circle",{cx:e.x,cy:e.y,r:6,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1.2}):null,i?Hg("text",{x:e.x,y:e.y-14,textAnchor:"middle",fill:"var(--semiotic-text, #111827)",fontSize:11,fontWeight:800,children:e.label}):null]},e.id))]})}}function ma({layout:e,compact:t,showLabels:i}){let r=t?Math.round(.14*e.height):Math.max(80,e.routeY-180),o=t?Math.max(6,Math.round(.72*e.height)):Math.min(360,e.height-170);return Zg(Kg,{children:e.gates.map(n=>Qg("g",{children:[Zg("rect",{x:n.x-n.width/2,y:r,width:n.width,height:o,rx:t?2:12,fill:n.color??"var(--semiotic-primary, #38bdf8)",fillOpacity:.1,stroke:n.color??"var(--semiotic-primary, #38bdf8)",strokeDasharray:"5 5",strokeOpacity:.7}),i?Zg("text",{x:n.x,y:Math.max(64,e.routeY-196),fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:n.label??n.id}):null]},n.id))})}function ba({layout:e,states:t,compact:i=!1}){return i?Zg("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:Zg(ma,{layout:e,compact:!0,showLabels:!1})}):Qg("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[Zg("path",{d:`M ${e.startX-42} ${e.routeY} C ${.24*e.width} ${e.routeY-70}, ${.42*e.width} ${e.routeY+78}, ${.58*e.width} ${e.routeY} S ${.78*e.width} ${e.routeY-82}, ${e.socketX+36} ${e.routeY}`,fill:"none",stroke:"var(--semiotic-primary, #38bdf8)",strokeDasharray:"18 12",strokeLinecap:"round",strokeOpacity:.45,strokeWidth:7}),Zg("line",{x1:Math.round(.06*e.width),x2:Math.round(.94*e.width),y1:e.crashY,y2:e.crashY,stroke:"var(--semiotic-danger, #ef4444)",strokeDasharray:"3 7",strokeOpacity:.64}),Zg("text",{x:Math.round(.07*e.width),y:e.crashY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:9,fontWeight:800,children:"CRASH LINE"}),Zg(ma,{layout:e,compact:!1,showLabels:!0}),Qg("g",{children:[Zg("rect",{x:e.socketX-52,y:e.routeY-56,width:104,height:112,rx:13,fill:"var(--semiotic-success, #22c55e)",fillOpacity:.12,stroke:"var(--semiotic-success, #22c55e)",strokeWidth:1.5}),Zg("text",{x:e.socketX,y:e.routeY-72,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"SOCKET"})]}),Qg("g",{children:[Zg("rect",{x:e.graveyardX-82,y:e.graveyardY-34,width:164,height:58,rx:11,fill:"var(--semiotic-danger, #ef4444)",fillOpacity:.16,stroke:"var(--semiotic-danger, #ef4444)",strokeOpacity:.7}),Zg("text",{x:e.graveyardX,y:e.graveyardY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"GRAVEYARD"}),Zg("text",{x:e.graveyardX,y:e.graveyardY+12,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,textAnchor:"middle",children:t.some(e=>e.killed)?"lift shut off":"too heavy or too small"})]})]})}function xa({states:e,layout:t}){let i=function(e){return e.map(e=>({label:e.id,value:Math.max(0,Number(e.viability)||0),outcome:e.outcome||e.stage||"in-process"}))}(e);if(!i.length)return null;let r=Math.max(1,...i.map(e=>e.value)),o=Math.max(40,(t.width-80)/i.length);return Qg("svg",{"aria-hidden":"true","data-testid":"gauntlet-projection-overlay",width:t.width,height:t.height,viewBox:`0 0 ${t.width} ${t.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[Zg("text",{x:36,y:18,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:800,children:"SETTLED · viability / outcome"}),i.map((e,t)=>{let i=40+t*o,n=Math.max(2,e.value/r*28),a=/kill|crash|block|grave/i.test(e.outcome);return Qg("g",{children:[Zg("rect",{x:i+.18*o,y:28-n+22,width:Math.max(10,.45*o),height:n,rx:2,fill:a?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",fillOpacity:.35,stroke:a?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",strokeOpacity:.55,strokeWidth:1}),Zg("text",{x:i+.4*o,y:62,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,children:e.label})]},e.label)})]})}function va(e){return e.map(e=>({...e,spawnAt:void 0}))}function wa(e,t){return e?t?i=>Dy.createElement(Dy.Fragment,null,"function"==typeof e?e(i):e,"function"==typeof t?t(i):t):e:t}function ka(e,t,i){let r=t[i];return"boolean"==typeof r?r:!0!==e.__compactMode}function Aa(e){let t=2166136261;for(let i=0;e.length>i;i+=1)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return em[(t>>>0)%em.length]}function Sa(e,t){return e===t}function Ma(e,t){if("function"==typeof e)return t=>+e(t);let i=e||t;return e=>+e[i]}function _a(e,t){if("function"==typeof e)return e;let i=e||t;return e=>e[i]}function $a(e,t){return"function"==typeof e?t=>e(t)+"":e?t=>t[e]+"":t?e=>e[t]+"":void 0}function Pa(e){return e?"function"==typeof e?e:t=>t[e]||t.id:null}function Ra(e){return"string"==typeof e?e:e.id}function Ia(e){let t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;let i=ym.test(t)?t+"-01":t;if(i===t&&10>t.length)return NaN;let r=Date.parse(i);return Number.isFinite(r)?r:NaN}function La(e){return e instanceof Date?e.getTime():"string"==typeof e?Ia(e):+e}function Ta(e){return new Set(Array.isArray(e)?e:[e])}function Ca(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function Oa(e,t){return Math.min((e-t.startTime)/t.duration,1)}function Fa(e,t,i){return e+(t-e)*i}function Da(){return"u">typeof performance?performance.now():Date.now()}function za(e,t,i){if(1>=i)return 1;let r=i-1;return function(e){let 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;let i=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>i?1:t;if("exponential"===e.type){let r=e.halfLife??e.extent/2;return t+Math.pow(.5,i/(r>0?r:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-i/e.extent))*(1-t)}({age:r-t,extent:r,type:e.type,halfLife:e.halfLife??i/2,threshold:e.stepThreshold??.5*i,minOpacity:e.minOpacity??.1})}function Na(e){let t=new Map;for(let i=0;e.length>i;i++)t.set(e[i],i);return t}function Ea(e,t,i){let r=e.duration??500,o=i-t;return r>o?1-o/r:0}function Ba(e,t,i,r){let o=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,o=!0),e._pulseColor!==i&&(e._pulseColor=i,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 Wa(e,t,i=("u">typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;let r=e.duration??500,o=t.peek();return null!=o&&r>i-o}function ja(e,t,i){if(t._transitionKey)return t._transitionKey;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){let i=e.getX(t.datum),r=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${i}:${r}`;if(null!=i&&null!=r)return`p:${i}:${r}`}return"p:"+i;case"glyph":return t.pointId?"g:"+t.pointId:"g:"+i;case"rect":return`r:${t.group||""}:${t.datum?.binStart??t.datum?.category??i}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+i:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function Ya(e){return e?null!=e.opacity?e.opacity:null!=e.fillOpacity?e.fillOpacity:1:1}function Xa(e){gm[e.chartType]=e}function qa(e){if("production"===process.env.NODE_ENV)return;let{label:t,nodes:i,overlays:r,warned:o}=e;Ga(r)&&0===i.length&&Va(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.`),i.length>0&&i.every(e=>null==e.datum)&&Va(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 Ga(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(Ga))}function Va(e,t,i){e.has(t)||(e.add(t),console.warn(i))}function Ha(e){try{return{kind:"success",result:e.run()}}catch(t){let i=e.hasPreviousResult,r=function(e,t,i,r){let 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),n="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:n,message:`Semiotic ${e} ${n} failed: ${o.message}`,error:o,recovery:i?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:i,affectedRevision:r}}(e.family,t,i,e.revision);"production"!==process.env.NODE_ENV&&console.error(`[semiotic] ${e.logLabel} threw:`,t);try{e.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:r,preservedLastGoodScene:i}}}function Ua(e,t){let i="function"==typeof e?e:i=>i[e||t];return e=>{let t=i(e);return null==t?NaN:+t}}function Ka(e){let t=[],i=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,r=Ua(i&&e.valueAccessor||e.yAccessor,i?"value":"y");if(e.boundsAccessor){let i=Ma(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{let t=r(e);if(!Number.isFinite(t))return NaN;let o=i(e);return Number.isFinite(o)&&0!==o?t+o:t},getBottom:e=>{let t=r(e);if(!Number.isFinite(t))return NaN;let o=i(e);return Number.isFinite(o)&&0!==o?t-o:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){let i=Array.isArray(e.band)?e.band:[e.band];for(let e of i)t.push({kind:"band",getTop:Ua(e.y1Accessor,"y1"),getBottom:Ua(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}function Za(e,t,i,r,o,n=!1){let a=new Map;for(let s of e){let e=t(s),l=i(s);if(null==e||null==l||Number.isNaN(e)||Number.isNaN(l))continue;let c=Math.floor(e/r)*r,u=a.get(c);if(u||(u={start:c,end:c+r,total:0,categories:new Map,...n?{rows:[],categoryRows:new Map}:{}},a.set(c,u)),u.total+=l,u.rows?.push(s),o){let e=o(s);if(u.categories.set(e,(u.categories.get(e)||0)+l),u.categoryRows){let t=u.categoryRows.get(e);t||(t=[],u.categoryRows.set(e,t)),t.push(s)}}}return a}function Qa(e,t,i,r,o){let n=[];for(let a of e){let e=i(a),s=r(a),l=o?o(a):0;if(!Number.isFinite(e)||!Number.isFinite(s)||!Number.isFinite(l))continue;let c=t.x(e),u=t.y(s),d=o?t.y(l):0;!Number.isFinite(c)||!Number.isFinite(u)||!Number.isFinite(d)||n.push({x:c,y:u,bottom:d,raw:s,datum:a})}n.sort((e,t)=>e.x-t.x);let a=Array(n.length),s=o?Array(n.length):[],l=Array(n.length),c=Array(n.length);for(let e=0;n.length>e;e++){let t=n[e];a[e]=[t.x,t.y],o&&(s[e]=[t.x,t.bottom]),l[e]=t.raw,c[e]=t.datum}return{topPath:a,bottomPath:s,rawValues:l,datum:c}}function Ja(e,t,i,r,o,n){let{topPath:a,rawValues:s,datum:l}=Qa(e,t,i,r);return{type:"line",path:a,rawValues:s,style:o,datum:l,group:n}}function es(e,t,i,r,o,n,a,s){return{type:"area",...Qa(e,t,i,r,s??(()=>o)),style:n,group:a}}function ts(e,t,i,r){let o=new Map;if("silhouette"===r)for(let r of e){let e=0;for(let o of t)e+=i(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++){let n=e[r-1],a=e[r],s=0,l=0,c=0;for(let e of t){let t=i(e,a)||0;s+=(2*c+t)*(t-(i(e,n)||0)),l+=t,c+=t}let u=o.get(n)??0;o.set(a,u-(l>0?s/(2*l):0))}if(e.length>0){let r=0;for(let n of e){let e=0;for(let r of t)e+=i(r,n)||0;r+=(o.get(n)??0)+e/2}let n=r/e.length;for(let t of e)o.set(t,(o.get(t)??0)-n)}}else for(let t of e)o.set(t,0);return o}function is(e,t,i,r,o,n,a){let s=i(e),l=r(e);if(!Number.isFinite(s)||!Number.isFinite(l))return null;let c={type:"point",x:t.x(s),y:t.y(l),r:o,style:n,datum:e};return void 0!==a&&(c.pointId=a),c}function rs(e,t,i,r,o,n,a,s){let l=i(e),c=r(e);if(!Number.isFinite(l)||!Number.isFinite(c))return null;let u={type:"symbol",x:t.x(l),y:t.y(c),size:o,symbolType:n,style:a,datum:e};return void 0!==s&&(u.pointId=s),u}function os(e,t,i,r,o,n,a){return{type:"rect",x:e,y:t,w:i,h:r,style:o,datum:n,group:a}}function ns(e,t,i,r,o,n,a){let s={type:"heatcell",x:e,y:t,w:i,h:r,fill:o,datum:n};return void 0!==a?.value&&(s.value=a.value),a?.showValues&&(s.showValues=!0,a.valueFormat&&(s.valueFormat=a.valueFormat)),s}function as(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function ss(e,t,i){if("log"===e){let e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return vm().domain(e).range(i).clamp(!0)}return"symlog"===e?wm().domain(t).range(i):"time"===e?km().domain([new Date(t[0]),new Date(t[1])]).range(i):xm().domain(t).range(i)}function ls(e,t){return e&&"object"==typeof e&&!Array.isArray(e)?Se(e,t):void 0}function cs(e,t,i){e.capacity>=t||(e.resize(t),i&&t>i.capacity&&i.resize(t))}function us(e,t){let i=new fm(e.capacity);return e.forEach(()=>i.push(t)),i}function ds(e,t,i,r){let o=e.push(t);return i&&i.push(r),o}function hs(e,t,i){if(!t||0===t.size)return;let r=new Set;if(e.forEach((e,t)=>{i(e)&&r.add(t)}),0===r.size)return;let o=t.toArray();t.clear();for(let e=0;o.length>e;e++)r.has(e)||t.push(o[e])}function fs(){return this.updateResults.last}function ps(){return this.updateResults.last}function ys(e){return this.updateResults.subscribe(e)}function gs(e){this.config.layoutSelection=e}function ms(){Am.set(this,!0)}function bs(){let e=!0===Am.get(this);return Am.delete(this),e}function xs(e){Object.assign(e.prototype,{getLastUpdateResult:fs,getUpdateSnapshot:ps,subscribeUpdateResult:ys,setLayoutSelection:gs,markStylePaintPending:ms,consumeStylePaintPending:bs})}function vs(e,t,i,r){return"function"==typeof t.style?t.style(r||{},i):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(i,r)}function ws(e,t,i,r){if(!e.scales)return null;let{topPath:o,bottomPath:n,datum:a}=Qa(t,e.scales,e.getX,r.getTop,r.getBottom);return 2>o.length?null:{type:"area",topPath:o,bottomPath:n,...e.config.curve&&"linear"!==e.config.curve&&{curve:e.config.curve},style:vs(e,r,i,yt(t)),datum:a,group:i,interactive:r.interactive}}function ks(e){let t=[],i=[];if(!e)return{perSeries:t,aggregate:i};for(let r of e)r.perSeries?t.push(r):i.push(r);return{perSeries:t,aggregate:i}}function As(e,t,i){let r=[];for(let o of i){let i=ws(e,t,"__ribbon_aggregate",o);i&&r.push(i)}return r}function Ss(e,t,i,r){let o=[];for(let n of r){let r=ws(e,t,i,n);r&&o.push(r)}return o}function Ms(e,t,i,r){if(!e.config.pointStyle)return;let o=r??e.getY;for(let r of t){let t=e.resolveGroupColor(r.key);for(let n of r.data){let r=e.config.pointStyle(n);!r.fill&&t&&(r={...r,fill:t});let a=r.r??3,s=e.getPointId?e.getPointId(n)+"":void 0,l=is(n,e.scales,e.getX,o,a,r,s);l&&i.push(l)}}}function _s(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}function $s(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Ps(e,t,i=.3){$s(t)&&(e.globalAlpha=t._pulseIntensity*i,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function Rs(e,t,i,r=.35){$s(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",i?e.fill(i):e.fill())}function Is(e,t,i){let r=i;for(let i of t)"lesser"===i.thresholdType?i.value>e&&(r=i.color):e>i.value&&(r=i.color);return r}function Ls(e,t,i,r){if(2>e.length||t.length!==e.length||0===i.length)return[];let o=[],n=(e,t,i)=>{let r=o[o.length-1];r?.color===e?r.path.push(i):o.push({color:e,path:[t,i]})};for(let o=1;e.length>o;o++){let[a,s]=e[o-1],[l,c]=e[o],u=t[o-1],d=t[o]-u,h=[0,...0===d?[]:i.map(({value:e})=>(e-u)/d).filter(e=>e>0&&1>e&&Number.isFinite(e)).sort((e,t)=>e-t).filter((e,t,i)=>0===t||e!==i[t-1]),1];for(let e=1;h.length>e;e++){let t=h[e-1],o=h[e];n(Is(u+d*((t+o)/2),i,r),[a+(l-a)*t,s+(c-s)*t],[a+(l-a)*o,s+(c-s)*o])}}return o}function Ts(e,t){let i=Hn(t.curve);if(!i||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let i=1;t.topPath.length>i;i++)e.lineTo(t.topPath[i][0],t.topPath[i][1]);for(let i=t.bottomPath.length-1;i>=0;i--)e.lineTo(t.bottomPath[i][0],t.bottomPath[i][1]);e.closePath()}else{let r=Wm().x(e=>e[0]).y0((e,i)=>t.bottomPath[i][1]).y1(e=>e[1]).curve(i).context(e);e.beginPath(),r(t.topPath)}}function Cs(e,t){let i=Hn(t.curve);if(e.beginPath(),i)jm().x(e=>e[0]).y(e=>e[1]).curve(i).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let i=1;t.topPath.length>i;i++)e.lineTo(t.topPath[i][0],t.topPath[i][1])}}function Os(e,t,i,r,o,n){if(2>t.length)return;let a=[0];for(let e=1;t.length>e;e++){let i=t[e][0]-t[e-1][0],r=t[e][1]-t[e-1][1];a.push(a[e-1]+Math.sqrt(i*i+r*r))}let s=a[a.length-1];if(0===s)return;let l=Math.min(.2*s,40);e.strokeStyle=i,e.lineWidth=r,e.lineCap=n;for(let i=0;t.length-1>i;i++){let r=(a[i]+a[i+1])/2,n=o;l>r&&(n*=r/l),l>s-r&&(n*=(s-r)/l),e.globalAlpha=Math.max(0,n),e.beginPath(),e.moveTo(t[i][0],t[i][1]),e.lineTo(t[i+1][0],t[i+1][1]),e.stroke()}}function Fs(e){return je(e)}function Ds(e,t,i){if(i)return i;let r=e??"circle";if("chevron"===r)return function(e){let t=1.5*zs(e),i=.92*t;return`M0,${-t}L${i},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-i},${(.78*t).toFixed(3)}Z`}(t);let o=Object.prototype.hasOwnProperty.call(nb,r)?nb[r]:Qm;return Zm(o,Math.max(1,t))()??""}function zs(e){return Math.sqrt(Math.max(1,e)/Math.PI)}function Ns(e,t){let i=new Map,r=0;return o=>{let n=e(o)+"",a=t&&Object.prototype.hasOwnProperty.call(t,n)?t[n]:void 0;if(a&&ab.has(a))return a;let s=i.get(n);return s||(s=sb[r%sb.length],r++,i.set(n,s)),s}}function Es(e,t){let i=[],r="bubble"===e.config.chartType?10:5,o=e.config.sizeRange||[3,15],n=null;if(e.getSize&&!e.config.pointStyle){let i=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(i.length>0){let e=1/0,t=-1/0;for(let r of i)e>r&&(e=r),r>t&&(t=r);n=i=>e===t?(o[0]+o[1])/2:o[0]+(i-e)/(t-e)*(o[1]-o[0])}}let a=e.getColor?e.resolveColorMap(t):null,s=e.config.themeSemantic?.primary||"#4e79a7",l=e.getSymbol,c=l?Ns(l,e.config.symbolMap):null;for(let o of t){let t=e.config.pointStyle?e.config.pointStyle(o):{fill:s,opacity:.8},l=t.r||r;if(n&&e.getSize){let t=e.getSize(o);null!=t&&!Number.isNaN(t)&&(l=n(t))}if(a&&e.getColor&&!t.fill){let i=e.getColor(o);i&&a.has(i)&&(t={...t,fill:a.get(i)})}let u=e.getPointId?e.getPointId(o)+"":void 0;if(c){let r=c(o),n=rs(o,e.scales,e.getX,e.getY,Math.PI*l*l,r,t,u);n&&i.push(n)}else{let r=is(o,e.scales,e.getX,e.getY,l,t,u);r&&i.push(r)}}return i}function Bs(e,t){let[i,r]=e.viewBox??lb,[o,n]=e.anchor??cb,a=r>0?r:1,s=Math.max(0,t)/a,l=(i>0?i:a)*s,c=a*s;return{width:l,height:c,scale:s,offsetX:-o*l,offsetY:-n*c}}function Ws(e,t,i,r){if("none"!==e)return"color"===e||null==e?t??r:"accent"===e?i:e}function js(e){if(typeof Path2D>"u")return null;ub||(ub=new Map);let t=ub.get(e);if(t)return t;let i=new Path2D(e);return ub.size>1024&&ub.clear(),ub.set(e,i),i}function Ys(e,t,i=0,r="horizontal"){let[o,n]=e.viewBox??lb,a=Math.min(1,Math.max(0,i)),s=Math.min(1,Math.max(0,t));return s>a?a>0||1>s?"vertical"===r?{x:0,y:n*(1-s),width:o,height:n*(s-a)}:{x:o*a,y:0,width:o*(s-a),height:n}:null:{x:0,y:0,width:0,height:0}}function Xs(e,t){let i=Bs(e,t);return{centerDx:i.offsetX+i.width/2,centerDy:i.offsetY+i.height/2,halfWidth:i.width/2,halfHeight:i.height/2,radius:Math.hypot(i.width,i.height)/2}}function qs(e,t,i,r,o,n=e=>e){for(let a of t.parts){let t=js(a.d);if(!t)continue;let s=a.opacity??1,l=e.globalAlpha;1!==s&&(e.globalAlpha=l*s);let c=o?"none"===a.fill?void 0:o:Ws(a.fill,i,r);c&&(e.fillStyle=n(c),e.fill(t));let u=o?a.stroke&&"none"!==a.stroke?o:void 0:Ws(a.stroke??"none",i,r);u&&(e.strokeStyle=n(u),e.lineWidth=a.strokeWidth??1,e.lineCap=a.strokeLinecap??"butt",e.lineJoin=a.strokeLinejoin??"miter",e.stroke(t)),1!==s&&(e.globalAlpha=l)}}function Gs(e,t,i,r,o,n){if(0>=t.size)return;let a=function(e,t,i){try{if(i)return js(i);let r=`${e??"circle"}:${t}`,o=db.get(r);return o||(o=new Path2D(Ds(e,t)),db.size>256&&db.clear(),db.set(r,o)),o}catch{return null}}(t.symbolType,t.size,t.path);if(!a)return;e.save(),e.translate(i,r),t.rotation&&e.rotate(t.rotation);let s=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=o*s*(t.style.fillOpacity??1),e.fillStyle=Un(e,t.style.fill,n),e.fill(a)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=o*s,e.strokeStyle=ir(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(a)),e.restore()}function Vs(e,t,i){return t===i?128:Math.min(Math.floor(255*(e-t)/(i-t)+.5),255)}function Hs(e){let t=Object.prototype.hasOwnProperty.call(yf,e)?e:"blues",i=mb.get(t);if(i)return i;i=Array(gb);let r=we(t);for(let e=0;gb>e;e++)i[e]=r(e/255);return mb.set(t,i),i}function Us(e,t,i){let r=i.config.areaStyle?.(t);return r&&("string"==typeof r.fill&&(e.fill=r.fill),e.style=r),e}function Ks(e,t,i){let r=Math.max(1,Math.floor(e.config.heatmapXBins??20)),o=Math.max(1,Math.floor(e.config.heatmapYBins??20)),n=e.config.heatmapAggregation??"count",a=Ma(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];let[s,l]=e.scales.x.domain(),[c,u]=e.scales.y.domain(),d=(l-s||1)/r,h=(u-c||1)/o,f=r*o;if(f>1e6)return[];let p=new Int32Array(f),y=new Float64Array(f),g=e.config.trackHoverRows||gt(e.config.areaStyle)?new Map:void 0;for(let i=0;t.length>i;i++){let n=t[i],l=e.getX(n),u=e.getY(n);if(!isFinite(l)||!isFinite(u))continue;let f=Math.min(Math.floor((l-s)/d),r-1),m=Math.min(Math.floor((u-c)/h),o-1);if(0>f||0>m)continue;let b=m*r+f;p[b]++;let x=a(n);if(y[b]+=isFinite(x)?x:0,g){let e=g.get(b);e||(e=[],g.set(b,e)),e.push(n)}}let m=1/0,b=-1/0;for(let e=0;f>e;e++){if(0===p[e])continue;let t;switch(n){case"sum":t=y[e];break;case"mean":t=y[e]/p[e];break;default:t=p[e]}m>t&&(m=t),t>b&&(b=t)}if(!isFinite(m))return[];let x=e.config.heatmapColorScale,v=x?void 0:Hs("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),w=i.width/r,k=i.height/o,A=e.config.showValues,S=e.config.heatmapValueFormat,M=[];for(let t=0;o>t;t++){let i=t*r;for(let a=0;r>a;a++){let r,l=i+a;if(0===p[l])continue;switch(n){case"sum":r=y[l];break;case"mean":r=y[l]/p[l];break;default:r=p[l]}let u=Vs(r,m,b),f=x?x(r):v[u],_=A?{value:r,showValues:!0,valueFormat:S}:{value:r},$=ht({xi:a,yi:t,value:r,count:p[l],sum:y[l],xCenter:s+(a+.5)*d,yCenter:c+(t+.5)*h,agg:n},g?.get(l));M.push(Us(ns(a*w,(o-1-t)*k,w,k,f,$,_),$,e))}}return M}function Zs(e,t){let[i,r,o]=Vn(e,t);return.299*i+.587*r+.114*o>128?"#000":"#fff"}function Qs(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}function Js(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}function el(e){let t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};let i=Math.min(e.w,e.h)/2,r=e=>Math.max(0,Math.min(e??0,i));return{tl:r(t.tl),tr:r(t.tr),br:r(t.br),bl:r(t.bl)}}function tl(e,t){let{x:i,y:r,w:o,h:n}=t,{tl:a,tr:s,br:l,bl:c}=el(t);e.beginPath(),e.moveTo(i+a,r),e.lineTo(i+o-s,r),s>0&&e.arcTo(i+o,r,i+o,r+s,s),e.lineTo(i+o,r+n-l),l>0&&e.arcTo(i+o,r+n,i+o-l,r+n,l),e.lineTo(i+c,r+n),c>0&&e.arcTo(i,r+n,i,r+n-c,c),e.lineTo(i,r+a),a>0&&e.arcTo(i,r,i+a,r,a),e.closePath()}function il(e,t){let i=Un(e,t.style.fill,ir(e,"var(--semiotic-primary, #007bff)")),r=function(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}}}(t);return(t.fillGradient&&"string"==typeof i?Zn(e,t.fillGradient,i,r.x0,r.y0,r.x1,r.y1):null)||i}function rl(e,t){if(!t.style.stroke||"none"===t.style.stroke)return!1;let i=t.style.strokeWidth??1;return i>0&&(e.strokeStyle=ir(e,t.style.stroke)||t.style.stroke,e.lineWidth=i,!0)}function ol(e,t){let i=t.style.icon,r=t.style.iconPadding||2,o=Math.min(t.w,t.h)-r;if(0>=o)return;let n=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),n){let n=o+r,a=t.x+(t.w-o)/2;for(let r=t.y+t.h-o;r>=t.y-o;r-=n)e.drawImage(i,a,r,o,o)}else{let n=o+r,a=t.y+(t.h-o)/2;for(let r=t.x;t.x+t.w>r;r+=n)e.drawImage(i,r,a,o,o)}e.restore()}function nl(e,t,i,r,o){if(0>=t.size)return;let n=t.glyph;if(!n||!n.parts?.length)return;let a=Bs(n,t.size);if(0>=a.scale)return;let s=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=s)return;let l=t=>{let i=Un(e,t,t);return"string"==typeof i?i:t},c=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(i,r),t.rotation&&e.rotate(t.rotation),e.translate(a.offsetX,a.offsetY),e.scale(a.scale,a.scale),e.globalAlpha=o*s*(t.style.fillOpacity??1);let u=Ys(n,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&qs(e,n,c,t.accent,t.ghostColor,l),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),qs(e,n,c,t.accent,void 0,l),e.restore()}function al(){Xa(Vm),Xa(Hm),Xa(Um),Xa(Km),Xa(pb),Xa(yb),Xa(xb),Xa(wb),Xa(kb),Xa(Sb),Xa(_b),Xa($b)}function sl(e){let t=e.parts.filter(e=>null!=e),i={};for(let e of t)for(let[t,r]of Object.entries(e.markCountByType))i[t]=(i[t]??0)+r;for(let[t,r]of Object.entries(e.additionalMarkCountByType??{}))r>0&&(i[t]=(i[t]??0)+r);let r=Object.values(i).reduce((e,t)=>e+t,0),o=0===r,n=Array.from(new Set([...t.flatMap(e=>e.warnings),...e.extraWarnings??[],...o?["EMPTY_SCENE"]:[]])),a="string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${r} marks`;return{component:"",frameType:e.frameType,status:o?"empty":"ok",empty:o,markCount:r,markCountByType:i,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:t.reduce((e,t)=>e+t.annotationCount,0),ariaLabel:a,warnings:n,semanticStatus:"not-assessed",semanticDiagnostics:[]}}function ll(e){let t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function cl(e){if(!e||2>e.length)return;let t=ll(e[0]),i=ll(e[e.length-1]);return null!==t&&null!==i?[t,i]:void 0}function ul(e){let{count:t,byType:i}=function(e){let t={};for(let i of e){let e="string"==typeof i?.type&&i.type.length>0?i.type:"node";t[e]=(t[e]??0)+1}return{count:e.length,byType:t}}(e.marks),r=0===t,o=[...e.extraWarnings??[]];r&&!o.includes("EMPTY_SCENE")&&o.push("EMPTY_SCENE"),e.annotationRender&&e.annotationRender.unrenderedCount>0&&!o.includes("UNRENDERED_ANNOTATIONS")&&o.push("UNRENDERED_ANNOTATIONS");let n=Array.isArray(e.annotations)?e.annotations.length:0,a=e.margin,s=a?{x:a.left,y:a.top,width:e.width-a.left-a.right,height:e.height-a.top-a.bottom}:void 0;return{component:"",frameType:e.frameType,status:r?"empty":"ok",empty:r,markCount:t,markCountByType:i,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:e.annotationRender?.renderedCount??n,...e.annotationRender?{annotationInputCount:e.annotationRender.inputCount,unrenderedAnnotationCount:e.annotationRender.unrenderedCount,...e.annotationRender.unrenderedTypes.length>0?{unrenderedAnnotationTypes:e.annotationRender.unrenderedTypes}:{}}:{},ariaLabel:"string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${t} marks`,warnings:o,semanticStatus:"not-assessed",semanticDiagnostics:[],...a?{margin:a}:{},...s?{plot:s}:{}}}function dl(e,t="#4e79a7"){return rr(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function hl(e){let t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}function fl(e,t,i,r){let o=e.glyph;if(!o?.parts?.length||0>=e.size)return null;let n=Bs(o,e.size);if(0>=n.scale)return null;let a=`translate(${t},${i})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${n.offsetX},${n.offsetY}) scale(${n.scale})`,s=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),l=Ys(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),c=l?hl(r+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>o.parts.map((i,r)=>{let o=t?"none"===i.fill?void 0:t:Ws(i.fill,s,e.accent),n=t?i.stroke&&"none"!==i.stroke?t:void 0:Ws(i.stroke??"none",s,e.accent);return o||n?Tb("path",{d:i.d,fill:o??"none",stroke:n,strokeWidth:n?i.strokeWidth??1:void 0,strokeLinecap:i.strokeLinecap,strokeLinejoin:i.strokeLinejoin,opacity:i.opacity},r):null});return Cb("g",{transform:a,opacity:1===u?void 0:u,children:[l&&c&&Tb("clipPath",{id:c,children:Tb("rect",{x:l.x,y:l.y,width:l.width,height:l.height})}),l&&e.ghostColor?Tb("g",{children:d(e.ghostColor)}):null,l&&c?Tb("g",{clipPath:`url(#${c})`,children:d()}):d()]},r)}function pl(e,t){let i=e.filter(e=>Number.isFinite(e.offset)&&(null==e.opacity||Number.isFinite(e.opacity))).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color??t,opacity:null==e.opacity?void 0:Math.max(0,Math.min(1,e.opacity))}));return 2>i.length?null:i.map((e,t)=>Tb("stop",{offset:e.offset,stopColor:e.color,stopOpacity:e.opacity},t))}function yl(e,t,i){let r=Ds(e.symbolType,e.size,e.path);return Tb("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?dl(e.style.fill):"none",fillOpacity:e.style.fillOpacity,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${i??""}symbol-${t}`)}function gl(e,t,i){let r="point"===e.type,o=r?"circle":"rect",n=r?{cx:e.x,cy:e.y,r:e.r}:{x:e.x,y:e.y,width:e.w,height:e.h},a=`${i?i+"-":""}${r?"point":"xyrect"}-${t}-hatch`,s=rr(e.style.fill)?nr(e.style.fill,a):void 0;return Cb(Lb.Fragment,{children:[s&&Tb("defs",{children:s}),Lb.createElement(o,{...n,fill:s?`url(#${a})`:dl(e.style.fill),opacity:r?e.style.opacity??e.style.fillOpacity??.8:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},`${e.type}-${t}`)}function ml(e){if(!1!==e?.interactive)return e?.style?.cursor}function bl(e,t,i){let r=ml(t);return r&&null!=e&&!1!==e?Db("g",{style:{cursor:r},"data-semiotic-mark-cursor":r,children:e},i):e}function xl(e,t,i,r){if(!e||2>t.length)return null;let o=pl(e.stops,r);return o?zb("linearGradient",{id:i,gradientUnits:"userSpaceOnUse",x1:t[0][0],y1:0,x2:t[t.length-1][0],y2:0,children:o}):null}function vl(e,t,i,r=30){let o=function(e,t,i,r=30){switch(e.type){case"line":{let r=e;if(0===r.path.length)return null;let o=Hn(r.curve),n=o?Ib().x(([e])=>e).y(([,e])=>e).curve(o)(r.path)??"":"M"+r.path.map(([e,t])=>`${e},${t}`).join("L"),a=hl(`${i?i+"-":""}line-${t}-stroke-gradient`),s=xl(r.strokeGradient,r.path,a,r.style.stroke||"#4e79a7");return Nb(Pb.Fragment,{children:[s&&zb("defs",{children:s}),zb("path",{d:n,fill:"none",stroke:s?`url(#${a})`:r.style.stroke||"#4e79a7",strokeWidth:r.style.strokeWidth??2,strokeDasharray:r.style.strokeDasharray,opacity:r.style.opacity})]},"line-"+t)}case"area":{let o=e;if(0===o.topPath.length)return null;let n=Hn(o.curve),a=!n||2>o.topPath.length||2>o.bottomPath.length?`M${o.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...o.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`:Rb().x(([e])=>e).y0((e,t)=>o.bottomPath[t][1]).y1(([,e])=>e).curve(n)(o.topPath)??"",s=`${i?i+"-":""}area-${t}-hatch`,l=rr(o.style.fill)?nr(o.style.fill,s):void 0,c=hl(`${i?i+"-":""}area-${t}-gradient`),u=function(e,t){let i=e.fillGradient;if(!i||"object"!=typeof i)return null;let r=1/0;for(let[,t]of e.topPath)r=Math.min(r,t);let o=-1/0;for(let[,t]of e.bottomPath)o=Math.max(o,t);if(!Number.isFinite(r)||!Number.isFinite(o))return null;let n=pl(i.stops,dl(e.style.fill));return n?zb("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:0,y1:r,x2:0,y2:o,children:n}):null}(o,c),d=u?`url(#${c})`:l?`url(#${s})`:dl(o.style.fill),h=u?void 0:o.style.fillOpacity??o.style.opacity??.7,f=n?Ib().x(([e])=>e).y(([,e])=>e).curve(n)(o.topPath)??"":"M"+o.topPath.map(([e,t])=>`${e},${t}`).join("L"),p=ml(o),y=p&&r>=0?zb("path",{d:f,fill:"none",stroke:"transparent",strokeWidth:Math.max(1,2*r),strokeLinecap:"round",pointerEvents:"stroke",style:{cursor:p},"data-semiotic-mark-cursor":p,"data-semiotic-cursor-hit-target":"area-top-path","aria-hidden":"true"},`area-${t}-cursor-target`):null,g=hl(`${i?i+"-":""}area-${t}-stroke-gradient`),m=!(!o.colorThresholds?.length||!o.rawValues||o.rawValues.length!==o.topPath.length),b=!!o.strokeColorBands?.length,x=m||b?null:xl(o.strokeGradient,o.topPath,g,o.style.stroke||"#4e79a7"),v=o.style.strokeWidth??2,w=1/0,k=-1/0;for(let[e]of o.topPath)w>e&&(w=e),e>k&&(k=e);let A=b?o.strokeColorBands.map((e,r)=>hl(`${i?i+"-":""}area-${t}-stroke-band-${r}`)):[],S=b?o.strokeColorBands.map((e,t)=>zb("clipPath",{id:A[t],children:zb("rect",{x:w-v,y:e.y,width:k-w+2*v,height:e.height})},A[t])):null,M=o.style.stroke&&"none"!==o.style.stroke?b?o.strokeColorBands.map((e,i)=>zb("path",{d:f,fill:"none",stroke:e.color??dl(o.style.stroke),strokeWidth:v,opacity:(o.style.opacity??1)*(e.opacity??1),clipPath:`url(#${A[i]})`},`area-${t}-stroke-band-${i}`)):m?Ls(o.topPath,o.rawValues,o.colorThresholds,dl(o.style.stroke)).map((e,i)=>zb("path",{d:"M"+e.path.map(([e,t])=>`${e},${t}`).join("L"),fill:"none",stroke:e.color,strokeWidth:v,opacity:o.style.opacity},`area-${t}-threshold-${i}`)):zb("path",{d:f,fill:"none",stroke:x?`url(#${g})`:dl(o.style.stroke),strokeWidth:v,opacity:o.style.opacity}):null;if(o.clipRect){let e=`${i?i+"-":""}area-clip-${t}`;return Nb("g",{children:[Nb("defs",{children:[u,!u&&l,x,S,zb("clipPath",{id:e,children:zb("rect",{x:o.clipRect.x,y:o.clipRect.y,width:o.clipRect.width,height:o.clipRect.height})})]}),Nb("g",{clipPath:`url(#${e})`,children:[zb("path",{d:a,fill:d,fillOpacity:h,opacity:u?o.style.opacity:void 0,stroke:"none"}),M,y]})]},"area-"+t)}return Nb(Pb.Fragment,{children:[(u||l||x||S)&&Nb("defs",{children:[u,!u&&l,x,S]}),zb("path",{d:a,fill:d,fillOpacity:h,opacity:u?o.style.opacity:void 0,stroke:"none"}),M,y]},"area-"+t)}case"point":case"rect":return gl(e,t,i);case"symbol":return yl(e,t);case"glyph":return fl(e,e.x,e.y,`${i??""}glyph-${e.pointId??t}`);case"heatcell":{let i=e,r={x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill,stroke:i.style?.stroke,strokeWidth:i.style?.strokeWidth,...null!=i.style?.opacity&&{opacity:i.style.opacity}};if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){let e=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,n,a]=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)]}let t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(i.fill),s=.299*o+.587*n+.114*a>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));return Nb("g",{children:[zb("rect",{...r}),zb("text",{className:"semiotic-heatmap-value",x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:l+"px",fontFamily:"var(--semiotic-font-family, sans-serif)",children:e})]},"heatcell-"+t)}return zb("rect",{...r},"heatcell-"+t)}case"candlestick":{let r=e,o=`${i?i+"-":""}candle-${t}-hatch`,n=rr(r.style?.fill)?nr(r.style.fill,o):void 0,a=n?`url(#${o})`:void 0,{fill:s,...l}=r.style??{};if(r.isRange){let e=r.dotRadius??Math.max(2,r.bodyWidth/2),i=a??r.wickColor;return Nb(Pb.Fragment,{children:[n&&zb("defs",{children:n}),Nb("g",{style:l,children:[zb("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth,opacity:r.style?.opacity}),zb("circle",{cx:r.x,cy:r.highY,r:e,fill:i,opacity:r.style?.opacity}),zb("circle",{cx:r.x,cy:r.lowY,r:e,fill:i,opacity:r.style?.opacity})]})]},"candle-"+t)}let c=Math.min(r.openY,r.closeY),u=Math.max(Math.abs(r.openY-r.closeY),1),d=r.isUp?r.upColor:r.downColor,h=a??d;return Nb(Pb.Fragment,{children:[n&&zb("defs",{children:n}),Nb("g",{style:l,children:[zb("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth,opacity:r.style?.opacity}),zb("rect",{x:r.x-r.bodyWidth/2,y:c,width:r.bodyWidth,height:u,fill:h,stroke:a?r.wickColor:d,strokeWidth:1,opacity:r.style?.opacity})]})]},"candle-"+t)}default:return null}}(e,t,i,r);return"area"===e.type?o:bl(o,e,"xy-cursor-"+t)}function wl(e){let{node:t,index:i,renderMode:r,fallback:o}=e,n=function(e,t){let i="function"==typeof e?e(t.datum??null,t):e;return(r=i)&&"object"==typeof r&&"string"==typeof r.id&&"function"==typeof r.cacheKey&&"function"==typeof r.drawCanvas&&"function"==typeof r.renderStaticSVG?i:void 0;var r}(r,t);if(!n)return{element:o(),renderedByBackend:!1};let a=n.renderStaticSVG({node:t,style:t.style??{},key:`${n.id}-${i}`});return null!=a?{element:bl(a,t,`${n.id}-${i}-cursor`),renderedByBackend:!0}:(function(e,t){if("u">typeof process&&"production"===process.env?.NODE_ENV)return;let i=`${e}:${t}`;Eb.has(i)||(Eb.add(i),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}(n.id,t.type??"unknown"),{element:o(),renderedByBackend:!1})}function kl(e){let t=[];return e.nodes.forEach((i,r)=>{let o=wl({node:i,index:r,renderMode:e.renderMode,fallback:()=>e.fallback(i,r)});null!=o.element&&!1!==o.element&&t.push({node:i,index:r,...o})}),t}function Al(e,t,i){if(t&&"object"==typeof t&&!Array.isArray(t)){let e=t;return t=>Se(e,t)??"#999"}let r=Array.isArray(t)?t:i.colors.categorical.length>0?i.colors.categorical:tf;return Bb().domain(e).range(r)}function Sl(e,t,i){if(0===e.length)return;let r=Al(e,t,i);return{legendGroups:[{label:"",type:"fill",items:e.map(e=>({label:e})),styleFn:e=>({fill:r(e.label)})}]}}function Ml(e){return"left"===e?"start":"right"===e?"end":e??"start"}function _l(e){return Number(e.typography.legendSize??e.typography.labelSize??e.typography.tickSize)||11}function $l(e){return e.typography.legendFontFamily??e.typography.fontFamily}function Pl(e){return e.typography.legendFontWeight}function Rl(e,t,i,r){let o=_l(r);return t+i+Math.ceil(e.length*o*.58)}function Il(e){let{categories:t,theme:i,position:r="right",totalWidth:o,margin:n,legendLayout:a}=e,{swatchSize:s,labelGap:l,itemGap:c,rowHeight:u}=v(a),d=s+l,h="top"===r||"bottom"===r,f=Math.max(s,o-n.left-n.right),p=t.map(e=>Rl(e,s,l,i));if(h){let e=Math.max(s,a?.maxWidth??f),i=[],r=0,o=0;p.forEach((t,n)=>{let a=0===o?t:o+c+t;o>0&&a>e?(i.push({start:r,end:n,width:o}),r=n,o=t):o=a}),t.length>0&&i.push({start:r,end:t.length,width:o});let n=Ml(a?.align),l=[];return i.forEach((i,r)=>{let o="center"===n?Math.max(0,(e-i.width)/2):"end"===n?Math.max(0,e-i.width):0;for(let e=i.start;i.end>e;e++)l.push({category:t[e],width:p[e],x:o,y:r*u}),o+=p[e]+c}),{items:l,width:i.reduce((e,t)=>Math.max(e,t.width),0),height:i.length*u,swatchSize:s,labelOffset:d,swatchRadius:0}}let y=p.reduce((e,t)=>Math.max(e,t),0);return{items:t.map((e,t)=>({category:e,width:p[t],x:0,y:t*u})),width:y,height:t.length*u,swatchSize:s,labelOffset:d,swatchRadius:0}}function Ll(e,t){if(!t||!e||0===e.length)return[];let i="function"==typeof t?t:e=>e[t],r=new Set;for(let t of e){let e=i(t);null!=e&&r.add(e+"")}return Array.from(r)}function Tl(e){let{x:t,y:i,text:r,fill:o,fontSize:n=12,fontWeight:a,fontFamily:s,textAnchor:l="start",dominantBaseline:c,background:u,className:d}=e,h=function(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{...e,type:e.type??"halo"}}(u),f=e=>Yb("text",{x:t,y:i,textAnchor:l,dominantBaseline:c,fill:o,fontSize:n,fontWeight:a,fontFamily:s,className:d,...e?{style:{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}}:{},children:r});if(!h)return f();if("halo"===h.type)return f({stroke:h.fill??qb,strokeWidth:h.haloWidth??3});let p,y,g=h.padding??{x:6,y:3},m="number"==typeof g?g:g.x,b="number"==typeof g?g:g.y,x=function(e,t){return(e+"").length*t*.6}(r,n),v=n+2*b;return p="middle"===l?t-x/2-m:"end"===l?t-x-m:t-m,y="middle"===c||"central"===c?i-v/2:"hanging"===c||"text-before-edge"===c?i-b:i-.8*n-b,Xb("g",{className:d,children:[Yb("rect",{x:p,y:y,width:x+2*m,height:v,rx:h.radius??3,ry:h.radius??3,fill:h.fill??qb,fillOpacity:h.opacity??.85,stroke:h.stroke,strokeWidth:h.strokeWidth}),f()]})}function Cl(e,t,i){if(!e)return null;let r="object"==typeof e?e:{};return Gb("circle",{className:"semiotic-threshold-end-cap",cx:t[0],cy:t[1],r:Math.max(0,r.radius??4),fill:r.fill??i})}function Ol({ann:e,position:t,vertical:i,width:r,height:o,color:n,fontSize:a=12,fontFamily:s,bold:l,background:c,dash:u="6,3",labelGap:d=4}){let h=e.labelPosition,f=t>.6*r,p=i?t+(f?-4:4):"left"===h?4:"center"===h?r/2:r-4,y=i?"bottom"===h?o-4:"center"===h?o/2:16:20>t?Math.min(o-4,t+16):t-d,g=i?f?"end":"start":"left"===h?"start":"center"===h?"middle":"end",m=i?[t,0]:[0,t],b=i?[t,o]:[r,t];return Hb("g",{opacity:e.opacity,children:[Vb("line",{x1:m[0],y1:m[1],x2:b[0],y2:b[1],stroke:n,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray||u}),Cl(e.endCap,m,n),e.label&&Vb(Tl,{x:p,y:y,text:e.label,textAnchor:g,fill:n,fontSize:a,fontFamily:s,fontWeight:l?"bold":void 0,background:c??e.labelBackground??"halo"})]})}function Fl(e){return{label:e.label,title:e.title,wrap:e.wrap||120,noWrap:"function"==typeof e._noteLayout?e.noWrap:void 0,_noteLayout:e._noteLayout}}function Dl(e){return"function"==typeof e._noteLayout?e._noteLayout(e):void 0}function zl(e,t,i){if(!e)return[];let r=Math.max(1,Math.floor(t/i)),o=[],n="";for(let t of e.split(/\s+/))t&&(n&&n.length+1+t.length>r?(o.push(n),n=t):n=n?`${n} ${t}`:t);return n&&o.push(n),o}function Nl(e,t,i,r){return"curly"===e?r?`M0,0 C${.6*i},0 ${.4*i},${t/2} ${i},${t/2} C${.4*i},${t/2} ${.6*i},${t} 0,${t}`:`M0,0 C0,${.6*i} ${t/2},${.4*i} ${t/2},${i} C${t/2},${.4*i} ${t},${.6*i} ${t},0`:r?`M0,0 L${i},0 L${i},${t} L0,${t}`:`M0,0 L0,${i} L${t},${i} L${t},0`}function El(e,t,i,r){if(!e)return Ub("g",{className:"annotation-note"});let{label:o,title:n,orientation:a,align:s,wrap:l=120,noWrap:c}=e;if(!o&&!n)return Ub("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(t)>Math.abs(i)?"leftRight":"topBottom");let d="topBottom"===u,h="leftRight"===u,f=s;(!f||"dynamic"===f)&&(f=d?0>t?"right":"left":0>i?"bottom":"top");let p="start";d?"right"===f?p="end":"middle"===f&&(p="middle"):p=0>t?"end":"start";let y=e.useHTML||e.html,g=y?void 0:Dl(e),m=g?.lineHeight??16,b=g?.titleLines??(n?c?[n]:zl(n,l,8):[]),x=g?.labelLines??(o?c?[o]:zl(o,l,8):[]),v=b.length+x.length,w=h?"end"===p?-4:4:0,k=[],A=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";if(y)k.push(Ub("foreignObject",{className:"annotation-note-html",x:"end"===p?w-l:"middle"===p?w-l/2:w,y:-m,width:l,height:Math.max(m,v*m+(n&&o?2:0))+m,style:{overflow:"visible"},children:Kb("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:A,fontSize:"12px",lineHeight:m+"px",overflow:"visible",textAlign:"end"===p?"right":"middle"===p?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[n&&Ub("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:n}),o&&Ub("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html"));else for(let e of[!0,!1]){let t=e?b:x;if(0===t.length)continue;let i="annotation-note-"+(e?"title":"label");k.push(Ub("text",{className:i,fill:A,textAnchor:p,fontWeight:e?g?.titleFontWeight??"bold":void 0,y:e?void 0:b.length*m,children:t.map((e,t)=>Ub("tspan",{x:w,dy:0===t?0:m,children:e},t))},i))}let S=null;if((n||o)&&(0!==t||0!==i)){let e=d?g?g.width:Math.min(l,120):(b.length+x.length+(x.length>0?1:0))*m,t=d?p:f,i="end"===t||"bottom"===t?-e:"middle"===t?-e/2:0;S=Ub("line",{className:"note-line",x1:d?i:0,x2:d?i+e:0,y1:d?0:i,y2:d?0:i+e,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}let M=Math.max(0,v-1)*m,_=0;(d||h)&&(_=h&&"middle"===f?-(M+m+(x.length>0&&b.length>0?2:0))/2+m/2:0>i||h&&"bottom"===f?-(M+2):2+m);let $=0!==_?`translate(0,${_})`:void 0;return Kb("g",{className:"annotation-note",transform:`translate(${t},${i})`,...g?.textProps,children:[Ub("g",{className:"annotation-note-content",transform:$,children:k}),S]})}function Bl(e,t,i,r,o){let n=null,a=i||"var(--semiotic-text-secondary, currentColor)";switch(e){case"callout-circle":{let e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&(n=Ub("circle",{r:e,fill:"none",stroke:a},"subject-circle"));break}case"callout-rect":{let e=t?.width||0,i=t?.height||0;(e>0||i>0)&&(n=Ub("rect",{width:e,height:i,fill:"none",stroke:a},"subject-rect"));break}case"callout-custom":n=t?.custom;break;case"xy-threshold":{let e=r||0,i=o||0,s=0,l=0,c=0,u=0;if(void 0!==t?.x)s=l=(t.x||0)-e,c=(t.y1||0)-i,u=(t.y2||0)-i;else if(void 0!==t?.y)c=u=(t.y||0)-i,s=(t.x1||0)-e,l=(t.x2||0)-e;else if(void 0!==t?.x1||void 0!==t?.x2)s=(t.x1||0)-e,l=(t.x2||0)-e;else{if(void 0===t?.y1&&void 0===t?.y2)break;c=(t.y1||0)-i,u=(t.y2||0)-i}n=Ub("line",{x1:s,y1:c,x2:l,y2:u,stroke:a,strokeDasharray:"5,5"},"threshold-line");break}case"bracket":{let e=t?.type||"curly",i=t?.width??t?.height;void 0!==i&&(n=Ub("path",{d:Nl(e,i,t?.depth||30,void 0===t?.width),fill:"none",stroke:a},"bracket-path"));break}}return Ub("g",{className:"annotation-subject",children:n})}function Wl(e,t,i,r,o,n){let a,s,l=0,c=0;if("callout-circle"!==o&&"label"!==o||!n?.radius){if("callout-rect"===o&&n){let i=n.width||0,r=n.height||0;if(i>0||r>0){let o=i/2,n=r/2,a=e-o,s=t-n;if(0!==a||0!==s){let e=Math.abs(a),t=Math.abs(s),u=i/2,d=r/2,h=e*d>t*u?u/e:d/t;l=o+a*h,c=n+s*h}}}else if("bracket"===o&&n){let e=n.width,t=n.height,i=n.depth||30;void 0!==e?(l=e/2,c=i):void 0!==t&&(l=i,c=t/2)}}else{let i=(n.radius||0)+(n.radiusPadding||0);if(i>0&&(0!==e||0!==t)){let r=Math.atan2(t,e);l=Math.cos(r)*i,c=Math.sin(r)*i}}let u=e-l,d=t-c,h=Math.hypot(u,d);if(h>.5){let o=r||"var(--semiotic-text-secondary, currentColor)",n="curve"===i?.type,f=Math.atan2(d,u);if(n){let r=(l+e)/2,n=(c+t)/2,s=-d/h,p=u/h,y=(i?.curve??.25)*h,g=r+s*y,m=n+p*y;a=Ub("path",{className:"connector-curve",d:`M${l},${c}Q${g},${m} ${e},${t}`,fill:"none",stroke:o},"connector-line"),f=Math.atan2(m-c,g-l)}else a=Ub("line",{x1:l,y1:c,x2:e,y2:t,stroke:o},"connector-line");if("arrow"===i?.end){let e=.2792526803190927;s=Ub("path",{d:`M${l},${c}L${l+10*Math.cos(f+e)},${c+10*Math.sin(f+e)}L${l+10*Math.cos(f-e)},${c+10*Math.sin(f-e)}Z`,fill:o,stroke:"none"},"connector-arrow")}}return Kb("g",{className:"annotation-connector",children:[a,s]})}function jl(e){let{x:t=0,y:i=0,dx:r,dy:o,nx:n,ny:a,note:s,connector:l,subject:c,type:u,color:d,className:h,disable:f,opacity:p,strokeDasharray:y,events:g={},"data-testid":m}=e,b=Array.isArray(t)?t[0]??0:t,x=Array.isArray(i)?i[0]??0:i,v=Array.isArray(f)?f:[],w=r||0,k=o||0;null!=n&&(w=n-b),null!=a&&(k=a-x);let A="string"==typeof u?u:"label";if("bracket"===A&&c&&0===w&&0===k)if(void 0!==c.width){w=c.width/2;let e=c.depth||30;k=e+(0>e?-5:5)}else if(void 0!==c.height){let e=c.depth||30;w=e+(0>e?-5:5),k=c.height/2}return Kb("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${b},${x})`,"data-testid":m,...null!=p&&{opacity:p},...y&&{strokeDasharray:y},...g,children:[!v.includes("connector")&&Wl(w,k,l,d,A,c),!v.includes("subject")&&Bl(A,c,d,b,x),!v.includes("note")&&El(s,w,k,d)]})}function Yl(e){let{noteData:t}=e,{screenCoordinates:i}=t,r="string"==typeof t.type?t.type:"label",o=t.eventListeners||t.events||{};if(t.coordinates&&i){let e=t.nx||i[0][0]+(t.dx??0),o=t.ny||i[0][1]+(t.dy??0),n=i.map((i,n)=>{let a=Object.assign({},t,{note:0===n?t.note:{label:""},x:i[0],y:i[1],nx:e,ny:o});return Ub(jl,{"data-testid":"semiotic-annotation",...a,type:r},"multi-annotation-"+n)});return Ub("g",{children:n})}let n=t.note||{title:"none",label:t.label},a=`${n.label}-${n.title}-${t.i}`;return Ub(jl,{"data-testid":"semiotic-annotation",events:o,...t,type:r},a)}function Xl(e){return!0===e?._annotationDeferred}function ql(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function Gl(e){let t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function Vl(e){return Math.max(.72,.95-.06*e)}function Hl(e){let t=e.map((e,t)=>{return{p:e,i:t,emphasis:(i=e.annotation,"primary"===i?.emphasis||"secondary"===i?.emphasis?i.emphasis:null),confidence:Gl(e.annotation),readingOrder:null,rank:1};var i}),i=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>Xl(e.annotation)),o=e.some(e=>null!=ql(e.annotation)),n=e.some(e=>"layer"===ql(e.annotation));if(!i&&!r&&!o)return e.map(e=>e.node);let a=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);a.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,a.length)});for(let e of t)e.emphasis&&(e.rank=Qb[e.emphasis]);let s=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{let{p:t,i:i,emphasis:r,readingOrder:o}=e,n=Xl(t.annotation),a=t.node;if("primary"===r||"secondary"===r||null!=o){let e=null==r&&null!=o;a=Zb("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:Vl(o),"data-annotation-reading-order":o}:{},children:t.node},"annotation-emphasis-"+i)}let s=ql(t.annotation);return s&&(a=Zb("g",{className:"annotation-cohesion--"+s,children:a},"annotation-cohesion-"+i)),n&&(a=Zb("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:a},"annotation-deferred-"+i)),a});return r&&s.unshift(Zb("style",{children:".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}}"},"annotation-disclosure-style")),n&&s.unshift(Zb("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),s}function Ul(e,t){let i=t.scales?.x??t.scales?.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function Kl(e,t){let i=t.scales?.y??t.scales?.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function Zl(e){return null==e?null:e+""}function Ql(e,t,i){return t.stickyPositionCache?.set(e,i),i}function Jl(e,t,i){let r=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===r){if(null!=e.pointId&&i.pointNodes&&i.pointNodes.length>0)for(let r=i.pointNodes.length-1;r>=0;r--){let o=i.pointNodes[r];if(o.pointId===e.pointId)return Ql(t,i,{x:o.x,y:o.y})}let r=function(e){let t=e.data;if(!t||0===t.length)return null;let i=t[t.length-1],r=e.scales?.x??e.scales?.time,o=e.scales?.y??e.scales?.value;if(!r||!o)return null;let n=i[e.xAccessor||"x"],a=i[e.yAccessor||"y"];return null==n||null==a?null:{x:r(n),y:o(a)}}(i);return r?Ql(t,i,r):null}if("semantic"===r){let r=function(e,t,i){let r=function(e){return Zl(e.provenance?.stableId??e.stableId)}(e);if(!r)return null;let o=i.pointNodes?.find(e=>Zl(e.pointId)===r);if(o)return Ql(t,i,{x:o.x,y:o.y});let n=i.data?.find(e=>function(e){return Zl(e.stableId??e.id??e.provenance?.stableId)}(e)===r);if(!n)return null;let a=Ul(n,i),s=Kl(n,i);return null==a||null==s?null:Ql(t,i,{x:a,y:s})}(e,t,i);if(r)return r}let o=null,n=null;if(null!=e.pointId&&i.pointNodes){let t=i.pointNodes.find(t=>t.pointId===e.pointId);t&&(o=t.x,n=t.y)}if((null==o||null==n)&&(o=Ul(e,i),n=Kl(e,i)),null!=o&&null!=n)return Ql(t,i,{x:o,y:n});if("sticky"===r){let e=i.stickyPositionCache?.get(t);if(e)return e}return null}function ec(e){return!!e&&"object"==typeof e&&Jb.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}function tc(e){return"primary"===e?.emphasis||!0===e?.defensive}function ic(e,t,i={}){return"number"==typeof i.maxAnnotations&&Number.isFinite(i.maxAnnotations)?Math.max(0,Math.floor(i.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(i.areaPerAnnotation&&i.areaPerAnnotation>0?i.areaPerAnnotation:2e4))):1/0}function rc(e){let t,i=e?.emphasis;t="primary"===i?100:"secondary"===i?10:50;let 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}function oc(e){let t=e?.provenance;if(!t||"object"!=typeof t)return e;let i="string"==typeof t.source?Object.prototype.hasOwnProperty.call(nx,t.source)?nx[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(!i&&!r||null!=e.label&&"string"!=typeof e.label)return e;let o=[i,r].filter(Boolean).join(" · "),n="string"==typeof e.label?e.label:"";return n.includes(`(${o})`)?e:{...e,label:n?`${n} (${o})`:`(${o})`}}function nc(e){if(!ac(e))return e;let 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 ac(e){return ec(e)}function sc(e,t,i,r,o){let n=e+i,a=t+r;return Math.abs(i)>Math.abs(r)?{x:0>i?n-o.width-4:n+4,y:0>r?a-o.height:a,width:o.width,height:o.height}:{x:0>i?n-o.width:n,y:0>r?a-o.height-4:a+4,width:o.width,height:o.height}}function lc(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function cc(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 uc(e,t,i,r,o,n,a,s){let l=lc(e,a),c=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,i,r){let o=Math.max(0,r-e.x),n=Math.max(0,r-e.y);return(o+Math.max(0,e.x+e.width-(t-r)))*e.height+(n+Math.max(0,e.y+e.height-(i-r)))*e.width}(l,o,n,s);for(let e of i)c+=12*cc(l,e);for(let e of r)c+=4*cc(l,e);return c}function dc(e){let{annotations:t,context:i,defaultOffset:r=ex,notePadding:o=tx,markPadding:n=ix,edgePadding:a=rx,preserveManualOffsets:s=!0,routeLongConnectors:l=!0,connectorThreshold:c=ox,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:p,cohesion:y,audience:g}=e,m=i.width||0,b=i.height||0,x="object"==typeof p?p:{},v=x.breakpoint??480,w=!!p&&v>=m,k=w&&!1!==x.preferShortText?t.map(nc):t,A=w&&!u?{maxAnnotations:x.maxAnnotations??("callout-list"===x.strategy?1:2),minVisible:x.minVisible??1}:u,S=d||w&&(!1!==x.progressiveDisclosure||"callout-list"===x.strategy),M=w&&!f?x.responsive??{minWidth:v}:f,_=w&&!y?x.cohesion:y;if(0===k.length||0>=m||0>=b)return k.slice();let $=[],P=function(e,t){return(e.pointNodes||[]).map(e=>{let i=Math.max(1,e.r||1)+t;return{x:e.x-i,y:e.y-i,width:2*i,height:2*i}})}(i,n),R=!1,I=k.map((e,t)=>{if(!ac(e))return e;let n=function(e,t,i){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};let r=e.pointId??e.nodeId;if(null!=r&&i.pointNodes){let e=i.pointNodes.find(e=>e.pointId===r);if(e)return{x:e.x,y:e.y}}let o=e.coordinates,n=i.scales?.geoProjection;if(Array.isArray(o)&&o.length>=2&&n){let e=o[0],t=o[1];if("number"==typeof e&&"number"==typeof t){let i=n([e,t]);if(i&&"number"==typeof i[0]&&"number"==typeof i[1])return{x:i[0],y:i[1]}}}return i.scales||"number"!=typeof e.x||"number"!=typeof e.y?Jl(e,t,i):{x:e.x,y:e.y}}(e,t,i);if(!n)return e;let u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};let t=Dl(e);if(t)return{width:Math.max(24,t.width+10),height:Math.max(18,t.height+6)};let i="number"==typeof e.wrap?e.wrap:120,r=[...zl("string"==typeof e.title?e.title:void 0,i,7),...zl("string"==typeof e.label?e.label:void 0,i,7)],o=r.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(i,7*o)+10),height:Math.max(18,16*r.length+6)}}(!0===e.defensive?oc(e):e);if(s&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){let t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}(e);return $.push(lc(sc(n.x,n.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),o)),e}var d;let h=null,f=1/0;for(let e of function(e){let 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)){let t=uc(sc(n.x,n.y,e.dx,e.dy,u),e,$,P,m,b,o,a);f>t&&(h=e,f=t)}if(!h)return e;let p=lc(sc(n.x,n.y,h.dx,h.dy,u),o);$.push(p);let y=Math.hypot(h.dx,h.dy),g=l&&y>=c&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return R=!0,{...e,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),L=R?I:k.slice(),T=L;if(h){let e=!1,t=L.map(t=>{let i=function(e){return"text"!==e.type||"string"!=typeof e.color||8>Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)?e:{...e,_redundantConnector:!0}}(t);return i!==t&&(e=!0),i});T=e?t:L}{let e=!1,t=T.map(t=>{if(!0!==t?.defensive)return t;let i=oc(t);return i!==t&&(e=!0),i});T=e?t:T}let C,O=new Set;if(A){let e="object"==typeof A?A:{},t=function(e){if(!e)return 1;let t=function(e){let t=e?.familiarity;if(!t)return 3;let i=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===i.length?3:i.reduce((e,t)=>e+t,0)/i.length}(e);return t>2?4>t?1:.6:1.5}(g),i=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??ic(m,b,e))*t))},{deferred:r}=function(e){let{annotations:t,width:i,height:r}=e,o=Math.max(0,e.minVisible??1),n=ic(i,r,e),a=t.map((e,t)=>{return{annotation:e,index:t,note:(i=e,ec(i))};var i}),s=a.filter(e=>e.note);if(0===s.length||n>=s.length)return{visible:t.slice(),deferred:[],budget:n};let l=s.filter(e=>tc(e.annotation)),c=s.filter(e=>!tc(e.annotation)).sort((e,t)=>rc(t.annotation)-rc(e.annotation)||e.index-t.index),u=Math.min(c.length,Math.max(Math.max(0,n-l.length),Math.max(0,o-l.length))),d=new Set([...l.map(e=>e.index),...c.slice(0,u).map(e=>e.index)]),h=[],f=[];for(let{annotation:e,index:t,note:i}of a)!i||d.has(t)?h.push(e):f.push(e);return{visible:h,deferred:f,budget:n}}({annotations:T,width:m,height:b,...i});for(let e of r)O.add(e)}if(M&&("object"==typeof M&&"number"==typeof M.minWidth?M.minWidth:480)>=m)for(let e of T)ac(e)&&"secondary"===e.emphasis&&O.add(e);if(O.size>0)for(let e of T)!0===e?.defensive&&O.delete(e);return C=0===O.size?T:S?T.map(e=>O.has(e)?{...e,_annotationDeferred:!0}:e):T.filter(e=>!O.has(e)),_?function(e,t){let i=!1,r=e.map(e=>ac(e)&&"blended"!==e.cohesion&&"layer"!==e.cohesion?(i=!0,{...e,cohesion:t}):e);return i?r:e}(C,_):C}function hc(e,t,i,r){let o=function(e,t,i="#4e79a7"){if(rr(e)){let i=function(e,t){let i=2166136261,r=or(t);for(let e=0;r.length>e;e++)i^=r.charCodeAt(e),i=Math.imul(i,16777619);return`${e}-hatch-${(i>>>0).toString(36)}`}(t,e);return{fill:`url(#${i})`,def:nr(e,i)}}return e&&"string"==typeof e?{fill:e}:{fill:i}}(e.fill??e.color,t,r);return function(e,t,i,r){if(!e||"object"!=typeof e)return;let o=e;if(!Array.isArray(o.stops))return;let n=o.stops.flatMap(e=>{if(!e||"object"!=typeof e)return[];let{offset:t,color:i,opacity:o}=e;return"number"==typeof t&&Number.isFinite(t)?[{offset:Math.max(0,Math.min(1,t)),color:"string"==typeof i&&i?i:r,opacity:"number"==typeof o&&Number.isFinite(o)?Math.max(0,Math.min(1,o)):void 0}]:[]}).sort((e,t)=>e.offset-t.offset);if(!n.length)return;let a="horizontal"===o.direction?"horizontal":"vertical"===o.direction?"vertical":i,s=t+"-gradient";return{fill:`url(#${s})`,def:Jp("linearGradient",{id:s,x1:0,y1:0,x2:"horizontal"===a?"100%":0,y2:"vertical"===a?"100%":0,children:n.map((e,t)=>Jp("stop",{offset:100*e.offset+"%",stopColor:e.color,stopOpacity:e.opacity},`${e.offset}-${t}`))},s)}}(e.gradient,t,i,"string"==typeof e.fill&&e.fill?e.fill:"string"==typeof e.color&&e.color?e.color:r)??o}function fc(e,t,i){let r=e.position,o="string"==typeof r&&ax.has(r)?r:"bottom-left",n=o.endsWith("left")?"left":o.endsWith("right")?"right":"center",a=o.startsWith("top")?"top":o.startsWith("bottom")?"bottom":"middle",s="top"===a?0:"bottom"===a?i:i/2;return{x:("left"===n?0:"right"===n?t:t/2)+("number"==typeof e.dx&&Number.isFinite(e.dx)?e.dx:0),y:s+("number"==typeof e.dy&&Number.isFinite(e.dy)?e.dy:0),textAnchor:"start"===e.textAnchor||"middle"===e.textAnchor||"end"===e.textAnchor?e.textAnchor:"left"===n?"start":"right"===n?"end":"middle",dominantBaseline:"auto"===e.dominantBaseline||"middle"===e.dominantBaseline||"hanging"===e.dominantBaseline?e.dominantBaseline:"top"===a?"hanging":"bottom"===a?"auto":"middle"}}function pc(e,t,i,r){return{...fc(e,t,i),fill:e.fill??e.color??r.fill,fontSize:e.fontSize??r.fontSize,fontFamily:e.fontFamily??r.fontFamily,fontWeight:e.fontWeight,fontStyle:e.fontStyle,letterSpacing:e.letterSpacing,opacity:e.opacity,className:e.className,style:{pointerEvents:"none"}}}function yc({annotation:e,width:t,height:i,defaults:r=lx}){let o=e.label??e.text;return null==o?null:sx("text",{...pc(e,t,i,r),children:o})}function gc(e,t={}){let i=function(e){let t=e.provenance,i=e.id??e.stableId??t?.stableId;return null==i||""===i?void 0:i+""}(e);return{"data-semiotic-annotation-widget":"",...i?{"data-semiotic-annotation-id":i}:{},onClickCapture(r){let o=function(e){let t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}(r);t.onAnnotationActivate?.({annotation:e,annotationId:i,chartId:t.chartId,inputType:o}),i&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:i,inputType:o,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}function mc(e,t){return e.color||t.colors.annotation||t.colors.text}function bc(e,t,i){let r=e.labelBackground,o=t.colors.background,n=o&&"transparent"!==o?o:t.colors.surface||o;return void 0===r?"none"===i?"none":{type:"halo",fill:n}:!1===r||"none"===r?"none":!0===r||"halo"===r?{type:"halo",fill:n}:"box"===r?{type:"box",fill:n}:{fill:n,...r}}function xc(e,t,i){return null!=e.x&&t.x?t.x(e.x):i&&null!=e[i]&&t.x?t.x(e[i]):"number"==typeof e.x?e.x:null}function vc(e,t,i){return null!=e.y&&t.y?t.y(e.y):i&&null!=e[i]&&t.y?t.y(e[i]):"number"==typeof e.y?e.y:null}function wc(e){let{annotations:t}=e;if(!t||0===t.length)return e.onRender?.({inputCount:0,eligibleCount:0,renderedCount:0,unrenderedCount:0,unrenderedTypes:[]}),null;let i=function(e,t={}){let i=!0===t.showRetractedAnnotations,r=!0===t.showSupersededAnnotations,o=new Set;for(let t of e){let e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&o.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!i)return!1;let t=e?.provenance?.stableId;return!(t&&o.has(t)&&!r)})}(t),r=e.scales.geoProjection,o=r?i.map(e=>{if(!Array.isArray(e.coordinates)||2>e.coordinates.length)return e;let t=r([Number(e.coordinates[0]),Number(e.coordinates[1])]);return t?{...e,x:t[0],y:t[1]}:e}):i,n=!!r&&!e.scales.x&&!e.scales.y,a=e=>Number(e),s=e.scales.x??(n?a:void 0),l=e.scales.y??(n?a:void 0),c=e.projection?"horizontal"===e.projection?"horizontal":"vertical":void 0,u={scales:{..."vertical"===e.projection?{x:e.scales.o??s,y:e.scales.r??l,time:e.scales.o??s,value:e.scales.r??l,o:e.scales.o}:"horizontal"===e.projection?{x:e.scales.r??s,y:e.scales.o??l,time:e.scales.r??s,value:e.scales.o??l,o:e.scales.o}:{x:s,y:l,time:s,value:l,o:e.scales.o},...r?{geoProjection:r}:{}},width:e.layout.width,height:e.layout.height,xAccessor:e.xAccessor,yAccessor:e.yAccessor,data:e.annotationData,pointNodes:e.pointNodes,frameType:e.frameType??(e.projection?"ordinal":r||e.scales.x||e.scales.y?"xy":"network"),...c?{projection:c}:{}},d=e.autoPlaceAnnotations?dc({annotations:o,context:u,..."object"==typeof e.autoPlaceAnnotations?e.autoPlaceAnnotations:{}}):o,h=function(e,t,i,r){let o=[];return e.forEach((e,n)=>{let a;a=i?i(e,n,r)??t(e,n,r):t(e,n,r),a&&o.push({node:a,annotation:e})}),{nodes:Hl(o),renderedAnnotations:o.map(e=>e.annotation)}}(d,(t,i,r)=>function(e,t,i,r){let{scales:o,layout:n,theme:a,xAccessor:s,yAccessor:l}=i;switch(e.type){case"frame-text":return Sx(yc,{annotation:e,width:n.width,height:n.height,defaults:{fill:a.colors.text,fontSize:11,fontFamily:a.typography.fontFamily}},"ann-frame-text-"+t);case"y-threshold":{let r=e.value??e.y;if(null==r)return null;let s=mc(e,a),l=e.label,c=e.strokeDasharray||"6,4",u=e.strokeWidth??1.5;if("horizontal"===i.projection&&o.r){let i=o.r(r);return null==i?null:Mx("g",{opacity:e.opacity,children:[Sx("line",{x1:i,y1:0,x2:i,y2:n.height,stroke:s,strokeWidth:u,strokeDasharray:c}),Cl(e.endCap,[i,0],s),l&&Sx(Tl,{x:i+4,y:_x,textAnchor:"start",fontSize:a.typography.tickSize,fill:s,fontFamily:a.typography.fontFamily,text:l,background:bc(e,a,"halo")})]},"ann-ythresh-"+t)}let d=o.y?o.y(r):o.r?o.r(r):null;return null==d?null:Sx(Ol,{ann:e,position:d,vertical:!1,width:n.width,height:n.height,color:s,fontSize:a.typography.tickSize,fontFamily:a.typography.fontFamily,background:bc(e,a,"halo"),dash:"6,4",labelGap:6},"ann-ythresh-"+t)}case"x-threshold":{let r=e.value??e.x;if(null==r)return null;let s="horizontal"===i.projection&&o.r?o.r(r):o.x?o.x(r):null;if(null==s)return null;let l=mc(e,a);return Sx(Ol,{ann:e,position:s,vertical:!0,width:n.width,height:n.height,color:l,fontSize:a.typography.tickSize,fontFamily:a.typography.fontFamily,background:bc(e,a,"halo"),dash:"6,4"},"ann-xthresh-"+t)}case"band":{let i=o.y?.domain?.(),r=e.y0??i?.[0],s=e.y1??i?.[1],l=null!=r&&o.y?o.y(r):null,c=null!=s&&o.y?o.y(s):null;if(null==l||null==c)return null;let u=Math.min(l,c),d=Math.abs(c-l),h=hc(e,"ssr-band-"+t,"vertical",mc(e,a)),f=e.fillOpacity??.1;return Mx("g",{opacity:e.opacity,children:[h.def&&Sx("defs",{children:h.def}),Sx("rect",{x:0,y:u,width:n.width,height:d,fill:h.fill,fillOpacity:f}),e.label&&Sx(Tl,{x:n.width-4,y:Math.max(u,0)+_x,textAnchor:"end",fontSize:a.typography.tickSize,fill:e.color||mc(e,a),fontFamily:a.typography.fontFamily,fontWeight:"bold",text:e.label,background:bc(e,a,"halo")})]},"ann-band-"+t)}case"x-band":{let i=o.x?.domain?.(),r=e.x0??i?.[0],s=e.x1??i?.[1],l=null!=r&&o.x?o.x(r):null,c=null!=s&&o.x?o.x(s):null;if(null==l||null==c)return null;let u=Math.min(l,c),d=Math.abs(c-l),h=hc(e,"ssr-xband-"+t,"horizontal",mc(e,a)),f=e.fillOpacity??.1;return Mx("g",{opacity:e.opacity,children:[h.def&&Sx("defs",{children:h.def}),Sx("rect",{x:u,y:0,width:d,height:n.height,fill:h.fill,fillOpacity:f}),e.label&&Sx(Tl,{x:u+4,y:_x,textAnchor:"start",fontSize:a.typography.tickSize,fill:e.color||a.colors.primary||mc(e,a),fontFamily:a.typography.fontFamily,fontWeight:"bold",text:e.label,background:bc(e,a,"halo")})]},"ann-xband-"+t)}case"category-highlight":{if(null==e.category||!o.o)return null;let r=o.o(e.category+"");if(null==r)return null;let s=o.o.bandwidth?o.o.bandwidth():40,l=mc(e,a),c=e.opacity??.1,u=e.label;return Mx("g","horizontal"===i.projection?{children:[Sx("rect",{x:0,y:r,width:n.width,height:s,fill:l,opacity:c}),u&&Sx(Tl,{x:12,y:r+s/2,dominantBaseline:"middle",fill:l,fontSize:a.typography.tickSize,fontWeight:"bold",fontFamily:a.typography.fontFamily,text:u,background:bc(e,a,"none")})]}:{children:[Sx("rect",{x:r,y:0,width:s,height:n.height,fill:l,opacity:c}),u&&Sx(Tl,{x:r+s/2,y:_x,textAnchor:"middle",fill:l,fontSize:a.typography.tickSize,fontWeight:"bold",fontFamily:a.typography.fontFamily,text:u,background:bc(e,a,"none")})]},"ann-cathighlight-"+t)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{let i=function(e,t,i,r){if(Array.isArray(e.coordinates)&&e.coordinates.length>=2&&t.geoProjection){let i=t.geoProjection([e.coordinates[0],e.coordinates[1]]);if(i)return{x:i[0],y:i[1]}}return{x:xc(e,t,i),y:vc(e,t,r)}}(e,o,s,l),n=null==i.x||null==i.y?Jl(e,t,r):null,c=i.x??n?.x??null,u=i.y??n?.y??null;if(null==c||null==u)return null;let d="text"===e.type,h=e.dx??(d?0:30),f=e.dy??(d?0:-30),p=e.color||a.colors.text;if(!d){let i="callout"===e.type?"callout-circle":e.type,r="callout-circle"===i?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===i?{width:e.width,height:e.height}:void 0;return Sx(Yl,{noteData:{x:c,y:u,dx:h,dy:f,note:Fl(e),type:i,...r?{subject:r}:{},connector:e.connector||{end:"arrow"},color:p,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-label-"+t)}return Sx("g",{children:Sx("text",{x:c+h,y:u+f,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||a.typography.labelSize,fill:p,fontFamily:a.typography.fontFamily,fontWeight:e.fontWeight,opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:e.label||e.title})},"ann-label-"+t)}default:return null}}(t,i,e,r)??function(e,t,i){switch(e.type){case"enclose":{let r=(e.coordinates||[]).map(e=>({x:Ul({...e,type:"point"},i),y:Kl({...e,type:"point"},i),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;let o=cx(r),n=e.padding||10;return kx("g",{children:[wx("circle",{cx:o.x,cy:o.y,r:o.r+n,fill:e.fill||"none",fillOpacity:e.fillOpacity??.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&wx(Tl,{x:o.x,y:o.y-o.r-n-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+t)}case"rect-enclose":{let r=(e.coordinates||[]).map(e=>({x:Ul({...e,type:"point"},i),y:Kl({...e,type:"point"},i)})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;let o=e.padding||10,[n,a]=Je(r.map(e=>e.x)),[s,l]=Je(r.map(e=>e.y)),c=n-o,u=a+o,d=s-o;return kx("g",{children:[wx("rect",{x:c,y:d,width:u-c,height:l+o-d,fill:e.fill||"none",fillOpacity:e.fillOpacity??.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&wx(Tl,{x:(c+u)/2,y:d-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+t)}case"highlight":{let r=i.data||[],o="function"==typeof e.filter?r.filter(e.filter):e.field&&null!=e.value?r.filter(t=>t[e.field]===e.value):[],n={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return wx("g",{children:o.map((t,r)=>{let o=Ul(t,i),a=Kl(t,i);if(null==o||null==a)return null;let s="function"==typeof e.r?e.r(t):e.r||6,l="function"==typeof e.style?e.style(t):e.style||n;return wx("circle",{cx:o,cy:a,r:s,...l},"hl-"+r)})},"ann-"+t)}case"bracket":{let r=Ul(e,i),o=Kl(e,i);return wx(Yl,{noteData:{x:r??0,y:o??0,dx:e.dx||0,dy:e.dy||0,note:Fl(e),type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+t)}case"trend":{let r=i.data||[];if(2>r.length)return null;let o,n=i.xAccessor||"x",a=i.yAccessor||"y",s="ordinal"===i.frameType,l="horizontal"===i.projection,c=s?n:null,u=s?a:null,d=[],h=new Map;if(s&&c&&u){for(let e of r){let t=e[c];if(null==t)continue;let i=t+"";h.has(i)||(h.set(i,d.length),d.push(i))}o=r.map(e=>{let t=e[c],i=e[u];if(null==t||null==i)return null;let r=h.get(t+"");return null!=r?[r,+i]:null}).filter(e=>null!==e)}else o=r.map(e=>[e[n],e[a]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>o.length)return null;let f=i.scales?.x??i.scales?.time,p=i.scales?.y??i.scales?.value;if(!f||!p)return null;let y,g=e=>t=>{let i=Math.max(0,Math.floor(t)),r=Math.min(d.length-1,i+1),o=t-i,n=e(d[i]);return n+(e(d[r])-n)*o},m=f,b=p;if(s)if(l){let e=g(b);y=(t,i)=>[m(i),e(t)]}else{let e=g(m);y=(t,i)=>[e(t),b(i)]}else y=(e,t)=>[m(e),b(t)];let x=e.method||"linear",v="loess"===x?function(e,t=.3){let i=e.length;if(2>i)return e.slice();let r=e.slice().sort((e,t)=>e[0]-t[0]),o=r.map(e=>e[0]),n=r.map(e=>e[1]),a=Math.min(i,Math.max(2,Math.ceil(t*i))),s=Number.isFinite(a)&&o.every(Number.isFinite),l=0,c=a-1,u=[];for(let e=0;i>e;e++){let t,r=o[e],d=0,h=i-1;if(s){for(;i-1>c&&Math.abs(o[l]-r)>=Math.abs(o[c+1]-r);)l++,c++;let e=Math.max(Math.abs(o[l]-r),Math.abs(o[c]-r));t=e||1,e>0&&(d=l,h=c)}else t=o.map(e=>Math.abs(e-r)).sort((e,t)=>e-t)[a-1]||1;let f=0,p=0,y=0,g=0,m=0;for(let e=d;h>=e;e++){let i=Math.abs(o[e]-r)/t,a=1>i?Math.pow(1-Math.pow(i,3),3):0;0!==a&&(f+=a,p+=a*o[e],y+=a*n[e],g+=a*o[e]*o[e],m+=a*o[e]*n[e])}if(0===f){u.push([r,n[e]]);continue}let b=f*g-p*p;if(1e-12>Math.abs(b))u.push([r,y/f]);else{let e=(f*m-p*y)/b;u.push([r,(y-e*p)/f+e*r])}}return u}(o,e.bandwidth??.3):("polynomial"===x?it(o,e.order||2):function(e){let t=[0,0,0,0],i=0;for(let[r,o]of e)null!==o&&(i++,t[0]+=r,t[1]+=o,t[2]+=r*r,t[3]+=r*o);let r=i*t[2]-t[0]*t[0],o=0===r?0:tt((i*t[3]-t[0]*t[1])/r),n=tt(t[1]/i-o*t[0]/i);return{points:e.map(([e])=>[tt(e),tt(o*e+n)]),equation:[o,n]}}(o)).points,w=v.map(([e,t])=>{let[i,r]=y(e,t);return`${i},${r}`}).join(" "),k=e.color||"#6366f1",A=v[v.length-1],[S,M]=y(A[0],A[1]);return kx("g",{children:[wx("polyline",{points:w,fill:"none",stroke:k,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&wx("text",{x:S+4,y:M-4,fill:k,fontSize:11,children:e.label})]},"ann-"+t)}case"envelope":{let r=i.data||[];if(2>r.length)return null;let o=i.xAccessor||"x",n=i.scales?.x??i.scales?.time,a=i.scales?.y??i.scales?.value;if(!n||!a)return null;let s=e.upperAccessor||"upperBounds",l=e.lowerAccessor||"lowerBounds",c=e.filter,u=r.filter(e=>null!=e[s]&&null!=e[l]&&(!c||c(e))).sort((e,t)=>e[o]-t[o]);if(2>u.length)return null;let d=Ax[i.curve||"linear"]||px,h=ux().x(e=>n(e[o])).y0(e=>a(e[l])).y1(e=>a(e[s])).curve(d)(u);if(!h)return null;let f=e.fill||"#6366f1",p=u[u.length-1];return kx("g",{children:[wx("path",{d:h,fill:f,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&wx("text",{x:n(p[o])+4,y:a(p[s])-4,fill:f,fontSize:11,children:e.label})]},"ann-"+t)}case"anomaly-band":{let r=i.data||[];if(2>r.length)return null;let o=i.yAccessor||"y",n=i.scales?.x??i.scales?.time,a=i.scales?.y??i.scales?.value;if(!n||!a)return null;let s=r.map(e=>e[o]).filter(e=>null!=e&&isFinite(e));if(2>s.length)return null;let l=s.reduce((e,t)=>e+t,0)/s.length,c=s.reduce((e,t)=>e+(t-l)**2,0)/s.length,u=Math.sqrt(c),d=e.threshold??2,h=l-d*u,f=a(l+d*u),p=a(h),y=e.fill||"#6366f1",g=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,b=r.filter(e=>{let t=e[o];return null!=t&&Math.abs(t-l)>d*u});return kx("g",{children:[!1!==e.showBand&&wx("rect",{x:0,y:Math.min(f,p),width:i.width||0,height:Math.abs(p-f),fill:y,fillOpacity:e.fillOpacity??.1}),b.map((e,t)=>{let r=Ul(e,i),o=Kl(e,i);return null==r||null==o?null:wx("circle",{cx:r,cy:o,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+t)}),e.label&&wx("text",{x:(i.width||0)-4,y:Math.min(f,p)-4,textAnchor:"end",fill:y,fontSize:11,children:e.label})]},"ann-"+t)}case"forecast":{let r=i.data||[];if(3>r.length)return null;let o=i.xAccessor||"x",n=i.yAccessor||"y",a=i.scales?.x??i.scales?.time,s=i.scales?.y??i.scales?.value;if(!a||!s)return null;let l,c=r.map(e=>[e[o],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;if("polynomial"===e.method){let t=it(c,e.order||2).equation;l=e=>t.reduce((t,i,r)=>t+i*Math.pow(e,r),0)}else{let e=rt(c);if(!e)return null;l=e}let{se:u,meanX:d,ssX:h}=ot(c,l),f=c.length,p=nt(e.confidence??.95),y=c[f-1][0],g=(y-c[0][0])/Math.max(f-1,1),m=Array.from({length:e.steps??5},(e,t)=>{let i=y+(t+1)*g,r=l(i),o=u*Math.sqrt(1+1/f+(h>0?(i-d)**2/h:0))*p;return{x:i,center:r,upper:r+o,lower:r-o}}),b=m.map(e=>`${a(e.x)},${s(e.upper)}`).join(" L"),x=m.slice().reverse().map(e=>`${a(e.x)},${s(e.lower)}`).join(" L"),v=m.map(e=>`${a(e.x)},${s(e.center)}`).join(" "),w=e.strokeColor||"#6366f1",k=m[m.length-1];return kx("g",{children:[wx("path",{d:`M${b} L${x} Z`,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),wx("polyline",{points:`${a(y)},${s(l(y))} ${v}`,fill:"none",stroke:w,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&k&&wx("text",{x:a(k.x)+4,y:s(k.center)-4,fill:w,fontSize:11,children:e.label})]},"ann-"+t)}case"widget":{let r,o;if(null!=e.px&&null!=e.py)r=e.px,o=e.py;else{let n=Jl(e,t,i);if(!n)return null;r=n.x,o=n.y}if(!function(e,t,i,r=50){return!(-r>e||e>(i.width||0)+r||-r>t||t>(i.height||0)+r)}(r,o,i))return null;let n=e.width??32,a=e.height??32,s=e.content??wx("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return wx("foreignObject",{x:r+(e.dx??0)-n/2,y:o+(e.dy??0)-a/2,width:n,height:a,style:{overflow:"visible",pointerEvents:"auto"},children:wx("div",{...gc(e),style:{width:n,height:a,display:"flex",alignItems:"center",justifyContent:"center"},children:s})},"ann-"+t)}default:return null}}(t,i,r),e.svgAnnotationRules,u),f=h.nodes,p=new Map;for(let e of h.renderedAnnotations){let t="string"==typeof e.type?e.type:"unknown";p.set(t,(p.get(t)??0)+1)}let y=[];for(let e of t){let t="string"==typeof e.type?e.type:"unknown",i=p.get(t)??0;i>0?p.set(t,i-1):y.push(t)}return e.onRender?.({inputCount:t.length,eligibleCount:d.length,renderedCount:h.renderedAnnotations.length,unrenderedCount:y.length,unrenderedTypes:y}),f.length>0?Sx("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:f}):null}function kc(e,t,i,r="right",o,n){if(null==e||!1===e)return null;let{x:a,y:s}=x(e,{totalWidth:t[0],totalHeight:t[1],margin:i,position:r,legendLayout:o,axisChrome:n});return $x("g",{transform:`translate(${a}, ${s})`,children:e})}function Ac(e){let t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_"),i=/^[A-Za-z_]/.test(t)?t:"c"+t,r=i+"-semiotic-title",o=i+"-semiotic-desc";return{titleId:r,descId:o,labelledBy:`${r} ${o}`}}function Sc(e,t,i){if("edges"===e){if(t)return"start";if(i)return"end"}return"middle"}function Mc(e,t,i){if("edges"===e){if(t)return"hanging";if(i)return"auto"}return"middle"}function _c(e){if(0===e.length)return{min:null,max:null};let t=1/0,i=-1/0;for(let r of e)t>r.pixel&&(t=r.pixel),r.pixel>i&&(i=r.pixel);return{min:t,max:i}}function $c(e){if(e)return"object"==typeof e?e.strokeDasharray:"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Pc(e,t){return e&&"string"!=typeof e?{stroke:e.stroke??t.stroke,strokeWidth:e.strokeWidth??t.strokeWidth,...null!=e.strokeOpacity&&{strokeOpacity:e.strokeOpacity},...e.strokeDasharray&&{strokeDasharray:e.strokeDasharray}}:{...t,..."string"==typeof e&&{strokeDasharray:$c(e)}}}function Rc(e,t,i){if("left"===e||"right"===e){let r="left"===e?i:0,o="left"===e?-1:1,n=Math.ceil(t/8),a="M0,"+r;for(let e=0;n>e;e++){let i=8*(e+1);a+=`L${Math.min(8*e+4,t)},${r+4*o}`,a+=`L${Math.min(i,t)},${r}`}return a}let r="bottom"===e?0:t,o="bottom"===e?1:-1,n=Math.ceil(i/8),a=`M${r},0`;for(let e=0;n>e;e++){let t=8*(e+1);a+=`L${r+4*o},${Math.min(8*e+4,i)}`,a+=`L${r},${Math.min(t,i)}`}return a}function Ic(e,t,i){return"exact"===i?function(e,t){let i=e.domain(),r=i[0],o=i[i.length-1],n=r instanceof Date,a=r instanceof Date?r.getTime():r,s=o instanceof Date?o.getTime():o;if(2>t||a===s)return n?[new Date(a),new Date(s)]:[a,s];let l=(s-a)/(t-1),c=Array(t);for(let e=0;t>e;e++){let i=e===t-1?s:a+e*l;c[e]=n?new Date(i):i}return c}(e,t):e.ticks(t)}function Lc(e){return"string"==typeof e||"number"==typeof e}function Tc(e){let{label:t,x:i,y:r,textAlign:o,fontSize:n,fontFamily:a,color:s}=e;return Rx("foreignObject",{x:i,y:r,width:60,height:24,style:{overflow:"visible"},children:Rx("div",{style:{color:s,fontFamily:a,fontSize:n,textAlign:o,userSelect:"none"},children:t})})}function Cc(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function Oc(e,t,i,r){return!!e&&("function"==typeof e?e(t.value,i):function(e,t){let i=Cc(e);if(!i)return!1;let r=Cc(t);return!r||i.getFullYear()!==r.getFullYear()||i.getMonth()!==r.getMonth()}(t.value,i>0?r[i-1].value:void 0))}function Fc(e){let t=new Date(e instanceof Date?e.valueOf():e);return`${Ix[t.getUTCMonth()]} ${t.getUTCDate()}`}function Dc(e){let t=Math.abs(e[1]-e[0]);return 864e5>t?e=>{let i=new Date(e instanceof Date?e.valueOf():e),r=`${(i.getUTCHours()+"").padStart(2,"0")}:${(i.getUTCMinutes()+"").padStart(2,"0")}`;return 3e5>t&&(r+=":"+(i.getUTCSeconds()+"").padStart(2,"0")),1e4>t&&(r+="."+(i.getUTCMilliseconds()+"").padStart(3,"0")),r}:3156e7>t?Fc:1578e8>t?e=>{let t=new Date(e instanceof Date?e.valueOf():e);return`${Ix[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e instanceof Date?e.valueOf():e).getUTCFullYear()+""}function zc(e){return"string"==typeof e||"number"==typeof e?6.5*(e+"").length:60}function Nc(e){let{scale:i,axis:r,size:o,horizontal:n=!1,axisExtent:a}=e,s=r?.extent??a,l=i.domain(),c=function(e){return e?.ticks??e?.tickCount??5}(r),u=Math.max(2,Math.floor(o/(n?70:30))),d="exact"===s?Math.max(2,c):Math.min(c,u),h=r?.tickValues??Ic(i,d,s),f=h.map(e=>e.valueOf()),p=r?.tickFormat||e.format||(l[0]instanceof Date||h[0]instanceof Date?Dc([l[0].valueOf(),l[l.length-1].valueOf()]):t(f)),y=(e,t)=>n?p(e,t,f):p(e),g=h.map((e,t)=>({value:e,pixel:i(e),label:y(e,t)})),m=22;if(n){let e=g.reduce((e,t)=>Math.max(e,zc(t.label)),0);m=r?.autoRotate?Math.max(20,Math.min(e+8,55)):Math.max(55,e+8)}let b=function(e,t){if(2>=e.length)return e;let i=[e[0]];for(let r=1;e.length-1>r;r++)Math.abs(e[r].pixel-i[i.length-1].pixel)>=t&&i.push(e[r]);let r=e[e.length-1];return t>Math.abs(r.pixel-i[i.length-1].pixel)?i[i.length-1]=r:i.push(r),i}(g,m);if(b.length>1&&(b=b.filter((e,t)=>{return 0===t||(r=b[t-1].label,!!("string"!=typeof(i=e.label)&&"number"!=typeof i||"string"!=typeof r&&"number"!=typeof r||i+""!=r+""));var i,r})),r?.includeMax&&b.length>0&&"exact"!==s&&!r.tickValues){let e=l[l.length-1];if(null!=e){let t=i(e),r=Math.abs(t-b[b.length-1].pixel);if(r>1){let i=y(e,b.length);m>r&&b.length>1&&(b=b.slice(0,-1)),b=[...b,{value:e,pixel:t,label:i}]}}}return b}function Ec(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){let t=e.id;return null==t?null:t+""}return null}function Bc(e){let t=e._idPrefix||e.chartId;if(t){let e=(t+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(e)?e:"c"+e}let i=`${e.chartType||""}:${e.title||""}:${Array.isArray(e.data)?e.data.length:0}`,r=0;for(let e=0;i.length>e;e++)r=31*r+i.charCodeAt(e)|0;return"c"+(r>>>0).toString(36)}function Wc(e,t,r){return i(e.showLegend&&!e.__legendIncludesAutomatic?Sl(t,e.colorScheme,r):void 0,e.legend)}function jc(e,t){if(e.__autoLegendMargin)return Cx[t]}function Yc(e,i){let n={theme:i.theme,position:i.position||"right",totalWidth:i.size[0],totalHeight:i.size[1],margin:i.margin,hasTitle:i.hasTitle,legendLayout:i.legendLayout,idPrefix:i.idPrefix,reservedWidth:i.reservedWidth,axisChrome:i.axisChrome,legendDistance:r(e)||o(e)?e.legendDistance:void 0};return r(e)?function(e){if(0===(t=e.legendGroups,t.flatMap(e=>e.items.map((t,i)=>({group:e,item:t,itemIndex:i,label:t.label})))).length)return null;var t;let i=function(e){let{legendGroups:t,theme:i,position:r="right",totalWidth:o,margin:n,legendLayout:a}=e,{swatchSize:s,labelGap:l,rowHeight:c}=v(a),u=s+l,d=Math.max(12,_l(i)),h="top"===r||"bottom"===r,f=Math.max(s,o-n.left-n.right);if(h){let r=Math.max(s,a?.maxWidth??f),o=Ml(a?.align),n=0,l=0,c=[];for(let o of t){let t=o.items.map(e=>e.label),u=Il({...e,categories:t,legendLayout:{...a,maxWidth:Math.max(s,r-d-8),align:"start"}}),h=o.label?d:0,f=o.label?Rl(o.label,0,0,i):0,p=h>0?h+8:0,y=p+u.width,g=Math.max(u.height,f);c.push({group:o,x:n,y:0,itemOffsetX:p,itemOffsetY:0,width:y,height:g,items:u.items}),n+=y+12,l=Math.max(l,g)}let h=c.length>0?n-12:0,p=h>r?0:"center"===o?Math.max(0,(r-h)/2):"end"===o?Math.max(0,r-h):0;return{groups:c.map(e=>({...e,x:e.x+p})),width:h,height:l,swatchSize:s,labelOffset:u,swatchRadius:0}}let p=w(t.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),c),y=0;return{groups:t.map((e,t)=>{let r=e.items.map(e=>Rl(e.label,s,l,i)),o=Math.max(0,...r,e.label?Rl(e.label,0,0,i):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:s,labelOffset:u,swatchRadius:0}}(e),r="top"===e.position||"bottom"===e.position,o={legendGroups:e.legendGroups,legendDistance:e.legendDistance},n=e.reservedWidth??u(o,e.legendLayout),a=e.theme.colors.grid||e.theme.colors.textSecondary,{x:s,y:l}=x(o,{totalWidth:e.totalWidth,totalHeight:e.totalHeight,margin:e.margin,position:e.position,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:n});if(!r){let t=w(e.legendGroups.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),Math.max(i.swatchSize,e.legendLayout?.rowHeight??22)),r=e.legendGroups.flatMap((r,o)=>{let a=t[o],s=r.type??"fill",l=[Wb("line",{x1:0,y1:a.lineY,x2:n,y2:a.lineY,stroke:"gray"},"legend-group-neatline-"+o)];return r.label&&null!=a.labelY&&l.push(Wb("text",{y:a.labelY,fontSize:_l(e.theme),fill:e.theme.colors.text,fontFamily:$l(e.theme),children:r.label},"legend-group-label-"+o)),l.push(Wb("g",{transform:`translate(0,${a.itemsY})`,children:r.items.map((t,n)=>{let a=r.styleFn(t,n),l="function"==typeof s?s(t):"line"===s?Wb("line",{x1:0,y1:0,x2:i.swatchSize,y2:i.swatchSize,style:a}):Wb("rect",{width:i.swatchSize,height:i.swatchSize,rx:i.swatchRadius,style:a});return jb("g",{transform:`translate(0,${n*Math.max(i.swatchSize,e.legendLayout?.rowHeight??22)})`,children:[l,Wb("text",{x:i.labelOffset,y:i.swatchSize/2,dominantBaseline:"central",fontSize:_l(e.theme),fill:e.theme.colors.text,fontFamily:$l(e.theme),children:t.label})]},`legend-${o}-${n}`)})},"legend-group-"+o)),l});return Wb("g",{className:"semiotic-legend",transform:`translate(${s},${l})`,"data-orientation":"vertical",fontWeight:Pl(e.theme),children:r})}let c=i.groups.flatMap((t,o)=>{let{group:n}=t,s=n.type??"fill",l=[];if(n.label&&l.push(Wb("text",r?{transform:`translate(${t.x},${t.y}) rotate(90)`,textAnchor:"start",fontSize:_l(e.theme),fill:e.theme.colors.text,fontFamily:$l(e.theme),children:n.label}:{x:t.x,y:t.y+_l(e.theme),fontSize:_l(e.theme),fill:e.theme.colors.text,fontFamily:$l(e.theme),children:n.label},"legend-group-label-"+o)),l.push(...t.items.map((r,a)=>{let l=n.items[a],c=n.styleFn(l,a),u="function"==typeof s?s(l):"line"===s?Wb("line",{x1:0,y1:0,x2:i.swatchSize,y2:i.swatchSize,style:c}):Wb("rect",{width:i.swatchSize,height:i.swatchSize,rx:i.swatchRadius,style:c});return jb("g",{transform:`translate(${t.x+t.itemOffsetX+r.x},${t.y+t.itemOffsetY+r.y})`,children:[u,Wb("text",{x:i.labelOffset,y:i.swatchSize/2,dominantBaseline:"central",fontSize:_l(e.theme),fill:e.theme.colors.text,fontFamily:$l(e.theme),children:r.category})]},`legend-${o}-${a}`)})),r&&i.groups.length-1>o){let e=t.x+t.width+6;l.push(Wb("line",{x1:e,y1:0,x2:e,y2:i.height,stroke:a},"legend-group-separator-"+o))}return l});return Wb("g",{className:"semiotic-legend",transform:`translate(${s},${l})`,"data-orientation":r?"horizontal":"vertical",fontWeight:Pl(e.theme),children:c})}({...n,legendGroups:e.legendGroups}):o(e)?function(e){let i=function(e){let t="top"===e.position||"bottom"===e.position,i=Math.max(1,e.totalWidth-e.margin.left-e.margin.right);return t?{width:Math.min(e.legendLayout?.maxWidth??i,200),height:e.gradient.label?46:26,swatchSize:12}:{width:e.gradient.label?86:72,height:e.gradient.label?126:108,swatchSize:14}}(e),r="top"===e.position||"bottom"===e.position,o={gradient:e.gradient,legendDistance:e.legendDistance},n=u(o),a=(e.idPrefix?e.idPrefix+"-":"")+"semiotic-static-gradient-legend",s=e.gradient.format||t(e.gradient.domain),{x:l,y:c}=x(o,{totalWidth:e.totalWidth,totalHeight:e.totalHeight,margin:e.margin,position:e.position,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:n}),d=Array.from({length:17},(t,i)=>{let o=i/16;return Wb("stop",{offset:o,stopColor:e.gradient.colorFn(r?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]))},i)});if(r){let t=e.gradient.label?12:void 0,r=e.gradient.label?18:0;return jb("g",{className:"semiotic-legend",transform:`translate(${l},${c})`,fontWeight:Pl(e.theme),children:[Wb("defs",{children:Wb("linearGradient",{id:a,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:d})}),e.gradient.label&&Wb("text",{x:i.width/2,y:t,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:$l(e.theme),children:e.gradient.label}),Wb("rect",{x:0,y:r,width:i.width,height:12,fill:`url(#${a})`,rx:2}),Wb("text",{x:0,y:r+12+12,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:$l(e.theme),children:s(e.gradient.domain[0])}),Wb("text",{x:i.width,y:r+12+12,textAnchor:"end",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:$l(e.theme),children:s(e.gradient.domain[1])})]})}let h=e.gradient.label?12:void 0,f=e.gradient.label?18:0;return jb("g",{className:"semiotic-legend",transform:`translate(${l},${c})`,fontWeight:Pl(e.theme),children:[Wb("defs",{children:Wb("linearGradient",{id:a,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:d})}),e.gradient.label&&Wb("text",{x:0,y:h,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:$l(e.theme),children:e.gradient.label}),Wb("rect",{x:0,y:f,width:14,height:100,fill:`url(#${a})`,rx:2}),Wb("text",{x:19,y:f+10,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:$l(e.theme),children:s(e.gradient.domain[1])}),Wb("text",{x:19,y:f+100,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:$l(e.theme),children:s(e.gradient.domain[0])})]})}({...n,gradient:e.gradient}):null}function Xc(e,t){let{props:i,categories:r,theme:o,size:n,hasTitle:a}=t,s=i.legendPosition||"right",c={...e},u={theme:o,position:s,size:n,hasTitle:a,legendLayout:i.legendLayout,axisChrome:i.axisChrome,minimumMargin:jc(i,s)};if(null!=i.legend){let t=Wc(i,r,o);null!=t&&!1!==t&&function(e,t){b(e,{legend:t.legend,position:t.position||"right",size:t.size,hasTitle:t.hasTitle,legendLayout:t.legendLayout,minimumMargin:t.minimumMargin,axisChrome:t.axisChrome})}(e,{...u,legend:t})}else i.showLegend&&r.length>0&&function(e,t){if(0===t.categories.length)return;let i=t.position||"right";b(e,{legend:Sl(t.categories,t.colorScheme,t.theme),position:i,size:t.size,hasTitle:t.hasTitle,legendLayout:t.legendLayout,minimumMargin:t.minimumMargin,axisChrome:t.axisChrome})}(e,{...u,categories:r,colorScheme:i.colorScheme});return l(e,c,n,s),s}function qc(e){let{props:t,categories:i,theme:n,size:a,margin:s,hasTitle:l}=e,c=t.legendPosition||"right",d={theme:n,position:c,size:a,margin:s,hasTitle:l,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix};if(null!=t.legend){let e=Wc(t,i,n);return Px.isValidElement(e)?kc(e,a,s,c,t.legendLayout,t.axisChrome):Yc(e,d)||(r(e)||o(e)?null:kc(e??null,a,s,c,t.legendLayout,t.axisChrome))}return t.showLegend&&0!==i.length?function(e){let{categories:t,colorScheme:i,theme:r,position:o="right",totalWidth:n,totalHeight:a,margin:s}=e;if(!t||0===t.length)return null;let l=Al(t,i,r),c="top"===o||"bottom"===o,d=Il(e),h={...Sl(t,i,r),legendDistance:e.legendDistance},f=e.reservedWidth??u(h,e.legendLayout),{x:p,y:y}=x(h,{totalWidth:n,totalHeight:a,margin:s,position:o,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:f});if(c){let e=d.items.map((e,t)=>jb("g",{transform:`translate(${e.x},${e.y})`,children:[Wb("rect",{width:d.swatchSize,height:d.swatchSize,fill:l(e.category),rx:d.swatchRadius}),Wb("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:_l(r),fill:r.colors.text,fontFamily:$l(r),children:e.category})]},"legend-"+t));return Wb("g",{className:"semiotic-legend",transform:`translate(${p},${y})`,fontWeight:Pl(r),children:e})}let g=w([{hasLabel:!1,itemCount:t.length}],Math.max(d.swatchSize,e.legendLayout?.rowHeight??22))[0],m=d.items.map((e,t)=>jb("g",{transform:`translate(${e.x},${e.y+g.itemsY})`,children:[Wb("rect",{width:d.swatchSize,height:d.swatchSize,fill:l(e.category),rx:d.swatchRadius}),Wb("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:_l(r),fill:r.colors.text,fontFamily:$l(r),children:e.category})]},"legend-"+t));return jb("g",{className:"semiotic-legend",transform:`translate(${p},${y})`,fontWeight:Pl(r),children:[Wb("line",{x1:0,y1:g.lineY,x2:f,y2:g.lineY,stroke:"gray"}),m]})}({categories:i,colorScheme:t.colorScheme,theme:n,position:c,totalWidth:a[0],totalHeight:a[1],margin:s,hasTitle:l,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix}):null}function Gc(e,t){let i=Ze(t.theme),r=t.background??i.background,o=t.idPrefix?t.idPrefix+"-":"",n="string"==typeof t.title?t.title:void 0,a=t.idPrefix?Ac(t.idPrefix):{titleId:"semiotic-title",descId:"semiotic-desc"},s=n?a.titleId:void 0,l=t.description?a.descId:void 0,c=[s,l].filter(Boolean).join(" ")||void 0;return Tx("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className,width:t.width,height:t.height,role:"img","aria-labelledby":c,style:{fontFamily:i.fontFamily},children:[n&&Lx("title",{id:s,children:n}),t.description&&Lx("desc",{id:l,children:t.description}),t.defs&&Lx("defs",{children:t.defs}),r&&"transparent"!==r&&Lx("rect",{x:0,y:0,width:t.width,height:t.height,fill:r}),Lx("g",{id:o+"data-area",transform:t.innerTransform,children:e}),n&&Lx("text",{id:o+"chart-title",x:t.width/2,y:22,textAnchor:"middle",fontSize:i.titleFontSize,fontWeight:i.titleFontWeight,fill:i.text,fontFamily:i.titleFontFamily,children:n}),t.legend&&Lx("g",{id:o+"legend",children:t.legend}),t.outerElements]})}function Vc(e,t,i,r){return"function"==typeof e?e({size:t,margin:i,scales:r}):e}function Hc(t,i){let r=Ke(t.theme),o=t.size||[500,300],a=s({...Dx,...t.margin},t.title),l=n(t.title),c=function(e,t){if(!t||0===e.length||!e.some(e=>null!=e&&"object"==typeof e&&Array.isArray(e[t])))return e;let i=[];for(let r of e){if(null==r||"object"!=typeof r)continue;let e=r[t];if(!Array.isArray(e))continue;let o=r.label??r.id??r.key;for(let t of e)null==t||"object"!=typeof t||i.push(null==o?t:{...t,_lineGroup:o})}return i}(me(t.data),t.lineDataAccessor),u=t.showLegend?Ll(c,t.colorAccessor||t.groupAccessor||t.categoryAccessor):[],d=y({showAxes:t.showAxes,xLabel:t.xLabel,yLabel:t.yLabel,yLabelRight:t.yLabelRight,axes:t.axes});Xc(a,{props:{...t,axisChrome:d},categories:u,theme:r,size:o,hasTitle:l});let f=qc({props:{...t,axisChrome:d},categories:u,theme:r,size:o,margin:a,hasTitle:l}),p=o[0]-a.left-a.right,g=o[1]-a.top-a.bottom,m="streaming"===t.runtimeMode||["bar","swarm","waterfall"].includes(t.chartType),b=t.colorScheme||r.colors.categorical,x=(t.axes?.find(e=>"left"===e.orient)??t.axes?.find(e=>"right"===e.orient))?.extent??t.axisExtent,v={chartType:t.chartType,runtimeMode:m?"streaming":"bounded",windowSize:t.windowSize??200,windowMode:t.windowMode??"sliding",arrowOfTime:m?t.arrowOfTime??"right":"right",extentPadding:t.extentPadding??.1,xAccessor:t.xAccessor,yAccessor:t.yAccessor,timeAccessor:m?t.timeAccessor:void 0,valueAccessor:t.valueAccessor,colorAccessor:t.colorAccessor,sizeAccessor:t.sizeAccessor,symbolAccessor:t.symbolAccessor,symbolMap:t.symbolMap,groupAccessor:t.groupAccessor||(t.lineDataAccessor?"_lineGroup":void 0),categoryAccessor:t.categoryAccessor,lineDataAccessor:t.lineDataAccessor,xExtent:t.xExtent,yExtent:t.yExtent,invertY:t.invertY,axisExtent:t.axisExtent,yAxisExtent:x,sizeRange:t.sizeRange,xScaleType:t.xScaleType,yScaleType:t.yScaleType,scalePadding:t.scalePadding,binSize:t.binSize,normalize:t.normalize,baseline:t.baseline,stackOrder:t.stackOrder,boundsAccessor:t.boundsAccessor,boundsStyle:t.boundsStyle,band:t.band,y0Accessor:t.y0Accessor,areaGroups:t.areaGroups?t.areaGroups instanceof Set?t.areaGroups:new Set(t.areaGroups):void 0,curve:t.curve,gradientFill:je(t.gradientFill),lineGradient:Ye(t.lineGradient),semanticLineStops:t.semanticLineStops,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:b,themeCategorical:r.colors.categorical,themeSequential:r.colors.sequential,themeDiverging:r.colors.diverging,themeSemantic:Ue(r),customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:a,layoutSelection:t.layoutSelection,barColors:t.barColors,showValues:t.showValues,heatmapValueFormat:t.heatmapValueFormat,heatmapColorScale:t.heatmapColorScale,heatmapAggregation:t.heatmapAggregation,heatmapXBins:t.heatmapXBins,heatmapYBins:t.heatmapYBins,pointIdAccessor:t.pointIdAccessor,onLayoutError:t.onLayoutError},w=new Bm(v);t.data&&w.ingest({inserts:c,bounded:!0}),w.computeScene({width:p,height:g});let k=Vc(t.backgroundGraphics,o,a,w.scales),A=Vc(t.foregroundGraphics,o,a,w.scales);if(!w.scales){let e,n=t.annotations?wc({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,annotationData:c,scales:{},layout:{width:p,height:g},theme:r,idPrefix:t._idPrefix,onRender:t=>{e=t}}):null;return i&&(i.evidence=ul({frameType:"xy",width:o[0],height:o[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,annotationRender:e,extraWarnings:w.scales?[]:["NO_SCALES"],margin:a})),hm.renderToStaticMarkup(Gc(k||A||t.annotations?Xx(jx,{children:[k,n,A]}):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:r,innerTransform:`translate(${a.left},${a.top})`,innerWidth:p,innerHeight:g,legend:f,idPrefix:t._idPrefix}))}let S,M=t._idPrefix,_=kl({nodes:w.scene,renderMode:t.renderMode,fallback:(e,i)=>vl(e,i,M,t.hoverRadius??30)}),$=!w.xIsDate||t.xFormat||t.tickFormatTime?t:{...t,xFormat:Dc(w.scales.x.domain().map(e=>e.valueOf()))},P=t.showGrid?function(e,t,i,r,o,n,a){let{grid:s}=Ze(i),l=r?r+"-":"",c=n?.find(e=>"bottom"===e.orient),u=n?.find(e=>"top"===e.orient),d=n?.find(e=>"left"===e.orient),h=n?.find(e=>"right"===e.orient),f=c??u,p=d??h,y=Nc({scale:e.x,axis:f,size:t.width,horizontal:!0,format:a?.xFormat||a?.tickFormatTime,axisExtent:o}),g=Nc({scale:e.y,axis:p,size:t.height,format:a?.yFormat||a?.tickFormatValue,axisExtent:o}),m=!1!==f?.grid,b=!1!==p?.grid,x=$c(f?.gridStyle),v=$c(p?.gridStyle),w=Pc(f?.gridStyle,{stroke:s,strokeWidth:.5}),k=Pc(p?.gridStyle,{stroke:s,strokeWidth:.5});return Fx("g",{id:l+"grid",className:"semiotic-grid",opacity:.8,children:[m&&y.map((e,i)=>Ox("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:t.height,...w,strokeDasharray:x??w.strokeDasharray},"gx-"+i)),b&&g.map((e,i)=>Ox("line",{x1:0,y1:e.pixel,x2:t.width,y2:e.pixel,...k,strokeDasharray:v??k.strokeDasharray},"gy-"+i))]})}(w.scales,{width:p,height:g},r,M,t.axisExtent,t.axes,$):null,R=_.map(e=>e.element),I=Bc(t)+"-plot-clip",L=!1!==t.showAxes,T=L?function(t,i,r,o,n,a,s,l=!1){let c=Ze(o),u=r.legendPosition??"right",d=h(r.legendLayout,s?.leftAxis),f=h(r.legendLayout,s?.rightAxis),p=l&&"left"===u&&d>0?d:a?.left??r.margin?.left??40,y=l&&"right"===u&&f>0?f:a?.right??r.margin?.right??40,{xAxis:g,yAxis:m,xOrient:b,yOrient:x}=e(r.axes),v="top"===b?0:i.height,w="right"===x?i.width:0,k="top"===b?-1:1,A="right"===x?1:-1,S=Nc({scale:t.x,axis:g,size:i.width,horizontal:!0,format:r.xFormat||r.tickFormatTime,axisExtent:r.axisExtent}),M=Nc({scale:t.y,axis:m,size:i.height,format:r.yFormat||r.tickFormatValue,axisExtent:r.axisExtent}),_=!(!g?.autoRotate||!function(e){for(let t=1;e.length>t;t++){let i=e[t-1],r=e[t];if(Math.abs(r.pixel-i.pixel)<(zc(i.label)+zc(r.label))/2+8)return!0}return!1}(S)),$=_c(S),P=_c(M),R=g?.label??r.xLabel,I=m?.label??("right"===x?r.yLabelRight??r.yLabel:r.yLabel),L=Pc(g?.axisStyle,{stroke:c.border,strokeWidth:1}),T=Pc(m?.axisStyle,{stroke:c.border,strokeWidth:1}),C="right"===x?i.width+y-15:15-p;return Tx("g",{id:(n?n+"-":"")+"axes",className:"stream-axes",children:[!1!==g?.visible&&Tx("g",{className:"semiotic-axis semiotic-axis-"+b,"data-orient":b,children:[!1!==g?.baseline&&!g?.jaggedBase&&Lx("line",{x1:0,y1:v,x2:i.width,y2:v,...L}),g?.jaggedBase&&Lx("path",{d:Rc(b,i.width,i.height),fill:"none",...L}),S.map((e,t)=>{let i=Oc(g?.landmarkTicks,e,t,S);return Tx("g",{transform:`translate(${e.pixel},${v})`,children:[Lx("line",{y2:5*k,...L}),Lc(e.label)?Lx("text",{y:k*(_?12:18),textAnchor:_?"end":Sc(g?.tickAnchor,e.pixel===$.min,e.pixel===$.max),fontWeight:i?600:400,fontSize:i?c.tickSize+1:c.tickSize,fill:c.textSecondary,fontFamily:c.fontFamily,transform:_?"top"===b?"rotate(45)":"rotate(-45)":void 0,children:e.label}):Tc({label:e.label,x:-30,y:"top"===b?-30:6,textAlign:"center",fontSize:c.tickSize,fontFamily:c.fontFamily,color:c.textSecondary})]},"xtick-"+t)}),R&&Lx("text",{x:i.width/2,y:"top"===b?-(_?58:40):i.height+(_?58:40),textAnchor:"middle",fontSize:c.labelSize,fill:c.text,fontFamily:c.fontFamily,children:R})]}),!1!==m?.visible&&Tx("g",{className:"semiotic-axis semiotic-axis-"+x,"data-orient":x,children:[!1!==m?.baseline&&!m?.jaggedBase&&Lx("line",{x1:w,y1:0,x2:w,y2:i.height,...T}),m?.jaggedBase&&Lx("path",{d:Rc(x,i.width,i.height),fill:"none",...T}),M.map((e,t)=>{let i=Oc(m?.landmarkTicks,e,t,M);return Tx("g",{transform:`translate(${w},${e.pixel})`,children:[Lx("line",{x2:5*A,...T}),Lc(e.label)?Lx("text",{x:8*A,textAnchor:"right"===x?"start":"end",dominantBaseline:Mc(m?.tickAnchor,e.pixel===P.min,e.pixel===P.max),fontWeight:i?600:400,fontSize:i?c.tickSize+1:c.tickSize,fill:c.textSecondary,fontFamily:c.fontFamily,children:e.label}):Tc({label:e.label,x:"right"===x?8:-68,y:-12,textAlign:"right"===x?"left":"right",fontSize:c.tickSize,fontFamily:c.fontFamily,color:c.textSecondary})]},"ytick-"+t)}),I&&Lx("text",{x:C,y:i.height/2,textAnchor:"middle",fontSize:c.labelSize,fill:c.text,fontFamily:c.fontFamily,transform:`rotate(${"right"===x?90:-90}, ${C}, ${i.height/2})`,children:I})]})]})}(w.scales,{width:p,height:g},$,r,M,a,d,!!f):null,C=L?function(e){let{scales:t,layout:i,props:r,theme:o,leftAxis:n,rightAxis:a,margin:s,axisChrome:l,hasRenderedLegend:c}=e;if(!n||!a||!1===a.visible)return null;let u=Ze(o),d=Nc({scale:t.y,axis:a,size:i.height,format:r.yFormat||r.tickFormatValue,axisExtent:r.axisExtent}),f=_c(d),p=a.label??r.yLabelRight,y=Pc(a.axisStyle,{stroke:u.border,strokeWidth:1}),g=r.legendPosition??"right",m=h(r.legendLayout,l?.rightAxis),b=i.width+(c&&"right"===g&&m>0?m:s.right)-15;return Wx("g",{className:"stream-axes semiotic-axis semiotic-axis-right","data-orient":"right",children:[!1!==a.baseline&&!a.jaggedBase&&Bx("line",{x1:i.width,y1:0,x2:i.width,y2:i.height,...y}),a.jaggedBase&&Bx("path",{d:Rc("right",i.width,i.height),fill:"none",...y}),d.map((e,t)=>{let r=Oc(a.landmarkTicks,e,t,d);return Wx("g",{transform:`translate(${i.width},${e.pixel})`,children:[Bx("line",{x2:5,...y}),Lc(e.label)?Bx("text",{x:8,textAnchor:"start",dominantBaseline:Mc(a.tickAnchor,e.pixel===f.min,e.pixel===f.max),fontWeight:r?600:400,fontSize:r?u.tickSize+1:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):Tc({label:e.label,x:8,y:-12,textAlign:"left",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"ytick-r-"+t)}),p&&Bx("text",{x:b,y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(90, ${b}, ${i.height/2})`,children:p})]})}({scales:w.scales,layout:{width:p,height:g},props:t,theme:r,leftAxis:t.axes?.find(e=>"left"===e.orient),rightAxis:t.axes?.find(e=>"right"===e.orient),margin:a,axisChrome:d,hasRenderedLegend:!!f}):null,O=t.annotations?wc({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,annotationData:c,scales:{x:w.scales.x,y:w.scales.y},layout:{width:p,height:g},theme:r,xAccessor:"string"==typeof t.xAccessor?t.xAccessor:void 0,yAccessor:"string"==typeof t.yAccessor?t.yAccessor:void 0,idPrefix:M,onRender:e=>{S=e}}):null;i&&(i.evidence=ul({frameType:"xy",width:o[0],height:o[1],marks:_.map(e=>e.node),title:t.title,description:t.description,annotations:t.annotations,annotationRender:S,xDomain:cl(w.scales.x?.domain?.()),yDomain:cl(w.scales.y?.domain?.()),legendItems:u.length>0?u.length:void 0,margin:a}));let F=t.svgPreRenderers&&w.scales?t.svgPreRenderers.map((e,t)=>{try{return Yx(dm.Fragment,{children:e(w.scene,w.scales,{width:p,height:g})},"pre-"+t)}catch{return null}}).filter(Boolean):null;return hm.renderToStaticMarkup(Gc(Xx(jx,{children:[k,F,P,Yx("defs",{children:Yx("clipPath",{id:I,children:Yx("rect",{x:0,y:0,width:p,height:g})})}),Yx("g",{clipPath:`url(#${I})`,children:R}),T,C,O,A,w.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:r,innerTransform:`translate(${a.left},${a.top})`,innerWidth:p,innerHeight:g,legend:f,idPrefix:t._idPrefix}))}function Uc({machine:e,layout:t,runtime:i,downstreamSet:r,selectedSet:o,width:n,height:a,seed:s,reduced:l,onSelectTask:c}){let u=t.tasks.length?Math.min(...t.tasks.map(e=>e.y-e.height/2)):60,d=Math.max(20,u-12),h=Math.max(26,u-6);return Vx("svg",{"aria-hidden":"true",width:n,height:a,viewBox:`0 0 ${n} ${a}`,style:{position:"absolute",inset:0,overflow:"visible",pointerEvents:"none"},children:[Gx("defs",{children:Gx("filter",{id:"chain-shadow-"+s,x:"-20%",y:"-20%",width:"140%",height:"150%",children:Gx("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodOpacity:"0.2"})})}),e.lanes.map((e,i)=>{let r=t.tasks.filter(e=>e.laneIndex===i)[0]?.x??0;return Vx("g",{children:[Gx("line",{x1:r,x2:r,y1:h,y2:a-24,stroke:"var(--semiotic-grid, #d7dde0)",strokeWidth:1,strokeDasharray:"3 7"}),Gx("text",{x:r,y:d,textAnchor:"middle",fontSize:12,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e})]},e)}),t.routes.map(e=>{let t=i.delivered.has(e.edgeID),o=i.inFlight.has(e.edgeID),n=r.has(e.targetID)||r.has(e.sourceID),a=e.points.map(e=>`${e.x},${e.y}`).join(" ");return Gx("polyline",{points:a,fill:"none",stroke:n?"var(--semiotic-selection-color, #e08a1e)":t?"var(--semiotic-success, #2b8a66)":"var(--semiotic-grid, #aeb8bd)",strokeWidth:n?4:o?3:2,strokeOpacity:t||o||n?.95:.48,strokeLinecap:"round",strokeLinejoin:"round"},e.edgeID)}),t.sockets.map(e=>{let t=i.delivered.has(e.edgeID);return Vx("g",{children:[Gx("circle",{cx:e.x,cy:e.y,r:e.radius+2,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text, #243039)",strokeWidth:1.5}),t&&Gx("circle",{cx:e.x,cy:e.y,r:e.radius-.5,fill:"var(--semiotic-success, #2b8a66)"})]},e.id)}),e.nodes.map(e=>{let n=t.taskByID.get(e.id);if(!n)return null;let a=i.completed.has(e.id),u=i.blockers.has(e.id),d=i.previewTaskID===e.id,h=o.has(e.id)||d,f=r.has(e.id),p=function(e,t){return t.completed.has(e.id)?"var(--semiotic-success, #2b8a66)":t.blockers.has(e.id)?"var(--semiotic-error, #c64035)":"in-progress"===e.status?"var(--semiotic-warning, #d18a22)":t.armed.has(e.id)?"var(--semiotic-primary, #2474a6)":"var(--semiotic-text-secondary, #75818a)"}(e,i),y=n.x-n.width/2,g=n.y-n.height/2,m=Math.max(2,n.height*e.progress);return Vx("g",{children:[Vx("g",{style:{transform:`rotate(${a?76:0}deg)`,transformBox:"fill-box",transformOrigin:"50% 100%",transition:l?"none":"transform 520ms cubic-bezier(.2,.8,.25,1)",filter:"url(#chain-shadow-"+s+")"},children:[Gx("rect",{x:y,y:g,width:n.width,height:n.height,rx:e.milestone?12:4,fill:"var(--semiotic-bg, #fff)",stroke:h||f?"var(--semiotic-selection-color, #e08a1e)":p,strokeWidth:h?4:f?3:2}),Gx("rect",{x:y+3,y:g+n.height-m+1,width:n.width-6,height:Math.max(0,m-4),rx:2,fill:p,opacity:a?.86:.46})]}),u&&Vx("g",{opacity:d?.28:1,children:[Gx("line",{x1:y-8,x2:y+14,y1:n.y+9,y2:n.y-9,stroke:"var(--semiotic-error, #c64035)",strokeWidth:7,strokeLinecap:"round"}),Gx("circle",{cx:y-8,cy:n.y+9,r:3,fill:"var(--semiotic-error, #c64035)"})]}),Vx("g",{onPointerDown:()=>c(e.id),style:{cursor:"pointer",pointerEvents:"auto"},children:[Gx("rect",{x:y,y:g,width:n.width,height:n.height,fill:"transparent"}),Gx("text",{x:n.x,y:n.y-4,textAnchor:"middle",fontSize:10.5,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e.label.length>24?e.label.slice(0,22)+"…":e.label}),Vx("text",{x:n.x,y:n.y+12,textAnchor:"middle",fontSize:9.5,fill:"var(--semiotic-text-secondary, #5f6b72)",children:[Math.round(100*e.progress),"% · ",a?"done":u?"blocked":i.armed.has(e.id)?"ready":"waiting"]})]})]},e.id)})]})}function Kc(e,t=0){if(e instanceof Date)return e.getTime();let i=Number(e);return Number.isFinite(i)?i:t}function Zc(e){if(null==e.completionTime)return null;let t=Kc(e.completionTime,NaN);return Number.isFinite(t)?t:null}function Qc(e,t,i,r){let o=new Set;for(let n of e.nodes){let a=e.incoming.get(n.id)??[];(r.has(n.id)||!i.has(n.id)&&a.every(e=>t.has(e.id)))&&o.add(n.id)}return o}function Jc(e,t,i={}){let r=new Set,o=[...e.get(t)??[]];for(let t=0;o.length>t;t++){let i=o[t];r.has(i)||(r.add(i),o.push(...e.get(i)??[]))}return i.includeStart&&r.add(t),r}function eu(e,t,i){return function(e,t,i){if(null!=e)return"function"==typeof e?e(t,i):"object"==typeof e&&null!==e&&"constant"in e?e.constant:t[e]}(i,e,t)}function tu(e,t){return t>e?-1:e>t?1:0}function iu(e,t){return`dependency:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function ru(e,t){return`socket:${encodeURIComponent(e)}:${t}`}function ou(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(1,t)):0}function nu(e,t,i={}){let r=new Set(i.completedTaskIDs??[]),o=[...Jc(function(e,t){let i=new Map;for(let t of e)i.set(t.id,new Set);for(let e of t)i.has(e.source)||i.set(e.source,new Set),i.has(e.target)||i.set(e.target,new Set),i.get(e.source).add(e.target);return i}(e.nodes,e.edges.map(e=>({source:e.sourceID,target:e.targetID}))),t)].map(t=>e.byID.get(t)).filter(e=>null!=e).filter(e=>!(i.isComplete?i.isComplete(e):r.has(e.id)||"done"===e.status)).sort((e,t)=>e.index-t.index),n=Array.from(new Set(o.map(e=>e.lane)));return{blockerID:t,downstreamTaskCount:o.length,affectedLaneCount:n.length,downstreamTaskIDs:o.map(e=>e.id),affectedLanes:n}}function au(e,t,i,r,o){return{__composite:{data:e,colorBy:t,colorScheme:i,common:r,rest:o}}}function su(e){return e.__composite}function lu(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function cu(e,t){return Math.max(1,Math.floor(lu(e,t)))}function uu(e,t,i,r){return e.replace(/^<svg\b/,`<svg x="${t}" y="${i}" data-semiotic-composite-part="${r}"`)}function du(e,t){for(let i of e){let e=i?.[t];if(Array.isArray(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1])return e}}function hu(e,t){return("function"==typeof t?t(e):e[t])+""}function fu(e,t,i){let{scales:r,config:o,getConnector:n,getO:a}=e;if(!n||!r)return[];let s=[],{projection:l}=r,c=new Map;for(let e of t){if("point"!==e.type&&"rect"!==e.type)continue;let t=e.datum;if(!t)continue;let i,r,o=n(t);o&&("point"===e.type?(i=e.x,r=e.y):(i=e.x+e.w/2,r=e.y+("vertical"===l?0:e.h/2)),c.has(o)||c.set(o,[]),c.get(o).push({x:i,y:r,datum:t,category:a(t)}))}let u=new Map(r.o.domain().map((e,t)=>[e,t])),d=o.connectorStyle,h={stroke:e.config.themeSemantic?.border||e.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5},f=(e,t,i)=>{var r;s.push({type:"connector",x1:e.x,y1:e.y,x2:t.x,y2:t.y,style:(r=e.datum,"function"==typeof d?d(r):d||h),datum:e.datum,group:i})};for(let[e,t]of c)if(t.length>=2){t.sort((e,t)=>(u.get(e.category)??-1)-(u.get(t.category)??-1));for(let i=0;t.length-1>i;i++)f(t[i],t[i+1],e);"radial"===l&&t.length>=3&&f(t[t.length-1],t[0],e)}return s}function pu(e,t,i){let r="function"==typeof e?e(i?t.w:t.h):e;return"number"==typeof r&&Number.isFinite(r)?Math.max(0,r):0}function yu(e){let t=e.getSymbol;return t?Ns(t,e.config.symbolMap):null}function gu(e,t,i,r,o,n,a){e.push(t?{type:"symbol",x:r,y:o,size:Math.PI*n*n,symbolType:t(i),style:a,datum:i}:{type:"point",x:r,y:o,r:n,style:a,datum:i})}function mu(e,t){let{columns:i,config:r,resolvePieceStyle:o}=e,n=[],a=Math.min(t.width,t.height)/2-4,s="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,d=Object.values(i),h=d.some(e=>{let t=e.pieceData[0];return t&&("number"==typeof t._pct||"number"==typeof t._pctStart||null!=t._roundedEnds)}),f=u&&!h&&d.length>1&&(r.cornerRadius??0)>0;for(let e=0;d.length>e;e++){let t=d[e],i=t.pieceData[0],u="number"==typeof i?._pctStart?i._pctStart:t.pctStart,h=l+u*c,p=l+(u+("number"==typeof i?._pct?i._pct:t.pct))*c,y=o(t.pieceData[0],t.name),g=0===e,m=e===d.length-1,b={type:"wedge",cx:0,cy:0,innerRadius:s,outerRadius:a,startAngle:h,endAngle:p,...r.cornerRadius&&{cornerRadius:r.cornerRadius},style:y,datum:i?._nonInteractive?null:t.pieceData,category:t.name};i?._roundedEnds?b.roundedEnds=i._roundedEnds:f&&(b.roundedEnds={start:g,end:m}),i?._gradientBand&&(b._gradientBand=i._gradientBand),n.push(b)}return n}function bu(e,t,i){return{...e[0],...i,category:t,data:e}}function xu(e){let t=e.length,i=e[0],r=e[t-1];return{n:t,min:i,q1:lv(e,.25)??i,median:lv(e,.5)??(i+r)/2,q3:lv(e,.75)??r,max:r,mean:e.reduce((e,t)=>e+t,0)/t}}function vu(e,t,i,r,o){let n=Array(o).fill(0);for(let a of e)t>a||a>i||n[Math.min(Math.floor((a-t)/r),o-1)]++;return n}function wu(e){let{innerRadius:t,outerRadius:i,startAngle:r,endAngle:o}=e,n=0>=t;if(0>=(e.cornerRadius??0)||!e.roundStart&&!e.roundEnd){if(n){let e=Pv(i,r),t=Pv(i,o);return`M0,0 L${e.x},${e.y} A${i},${i} 0 ${o-r>Math.PI?1:0} 1 ${t.x},${t.y} Z`}let e=Pv(i,r),a=Pv(i,o),s=Pv(t,o),l=Pv(t,r),c=o-r>Math.PI?1:0;return`M${e.x},${e.y} A${i},${i} 0 ${c} 1 ${a.x},${a.y} L${s.x},${s.y} A${t},${t} 0 ${c} 0 ${l.x},${l.y} Z`}let a=Math.max(0,Math.min(e.cornerRadius??0,(i-t)/2));if(0===a)return wu({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});let s=Math.asin(Math.min(1,a/Math.max(1e-9,i-a))),l=n?0:Math.asin(Math.min(1,a/Math.max(1e-9,t+a))),c=o-r,u=e.roundStart&&e.roundEnd?c/2:c,d=!!e.roundStart&&u>s,h=!!e.roundEnd&&u>s;if(!d&&!h)return wu({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});let f=r+(d?s:0),p=o-(h?s:0),y=r+(d?l:0),g=o-(h?l:0),m=Pv(i,f),b=Pv(i,p),x=(i-a)*Math.cos(s),v=Pv(x,r),w=Pv(x,o),k=n?null:Pv(t,g),A=n?null:Pv(t,y),S=n?0:(t+a)*Math.cos(l),M=n?null:Pv(S,r),_=n?null:Pv(S,o),$=p-f>Math.PI?1:0,P=n?0:g-y>Math.PI?1:0,R="";if(d)R+=`M${v.x},${v.y}`,R+=` A${a},${a} 0 0 1 ${m.x},${m.y}`;else{let e=Pv(i,r);R+=`M${e.x},${e.y}`}if(h)R+=` A${i},${i} 0 ${$} 1 ${b.x},${b.y}`,R+=` A${a},${a} 0 0 1 ${w.x},${w.y}`;else{let e=Pv(i,o);R+=` A${i},${i} 0 ${$} 1 ${e.x},${e.y}`}if(n)R+=" L0,0";else{if(h)R+=` L${_.x},${_.y}`,R+=` A${a},${a} 0 0 1 ${k.x},${k.y}`;else{let e=Pv(t,o);R+=` L${e.x},${e.y}`}if(d)R+=` A${t},${t} 0 ${P} 0 ${A.x},${A.y}`,R+=` A${a},${a} 0 0 1 ${M.x},${M.y}`;else{let e=Pv(t,r);R+=` A${t},${t} 0 ${P} 0 ${e.x},${e.y}`}}return R+=" Z",R}function ku(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 Au(e,t){let i=e.datum;if(!i)return null;let r=[],o=i.__funnelStepLabel,n=Number(i.__funnelStepLabelX),a=Number(i.__funnelStepLabelY),s=Number(i.__funnelRowWidth);"string"==typeof o&&Number.isFinite(n)&&Number.isFinite(a)&&(!Number.isFinite(s)||s>=8.4*o.length+16)&&r.push(Rv("text",{x:n,y:a+3,textAnchor:"middle",dominantBaseline:"hanging",fontSize:14,fontWeight:"bold",fill:"#fff",fontFamily:"var(--semiotic-font-family, sans-serif)",stroke:"rgba(0,0,0,0.6)",strokeWidth:3,paintOrder:"stroke",children:o},t+"-funnel-step"));let l=Number(i.__funnelValue),c=Number(i.__funnelValueLabelX),u=Number(i.__funnelValueLabelY),d=Number(i.__funnelBarW);if(Number.isFinite(l)&&0!==l&&Number.isFinite(c)&&Number.isFinite(u)&&d>=60){let e=Number(i.__funnelPercent),o=!0!==i.__funnelIsFirstStep&&Number.isFinite(e)?`${ku(l)} (${.05>Math.abs(e-Math.round(e))?Math.round(e):e.toFixed(1)}%)`:ku(l);7.8*o.length+16>d&&(o=ku(l)),d>=7.8*o.length+16&&r.push(Rv("text",{x:c,y:u+22,textAnchor:"middle",dominantBaseline:"hanging",fontSize:13,fontWeight:"bold",fill:"#fff",fontFamily:"var(--semiotic-font-family, sans-serif)",stroke:"rgba(0,0,0,0.5)",strokeWidth:3,paintOrder:"stroke",children:o},t+"-funnel-value"))}return r.length?Rv("g",{children:r},t+"-funnel-labels"):null}function Su(e){return"connector"===e.node.type}function Mu(e,t,i,r){if(2>e.length)return null;let o=e[0].node,n=o.style.fill;if(!n||"none"===n)return null;let a=hl(`${t?t+"-":""}connector-${i}-${r}-hatch`),s=rr(n)?nr(n,a):null,l=[`${o.x1},${o.y1}`,...e.map(({node:e})=>`${e.x2},${e.y2}`)].join(" ");return bl(Tv(Mv.Fragment,{children:[s&&Lv("defs",{children:s}),Lv("polygon",{points:l,fill:s?`url(#${a})`:dl(n,"#999"),opacity:o.style.fillOpacity??o.style.opacity??.3,"data-semiotic-connector-fill":o.group||"_default"})]}),o,`ordinal-connector-fill-${i}-${r}`)}function _u(e,t,i){let r=new Map;for(let t of e){if(!Su(t))continue;let e=t.node.group||"_default",i=r.get(e);i?i.push(t):r.set(e,[t])}if(0===r.size)return;let o=Array.from(r.values()).map((e,r)=>Tv("g",{children:[Mu(e,t,i,r),e.map(e=>e.element)]},`ordinal-connectors-${i}-${r}`)),n=e[0],a=Su(n)?null:n.element;for(let e of r.values())for(let t of e)t.element=null;n.element=Tv(Mv.Fragment,{children:[o,a]},"ordinal-connector-run-"+i)}function $u(e){let t=kl({nodes:e.nodes,renderMode:e.renderMode,fallback:(t,i)=>function(e,t,i){return bl(function(e,t,i){let r=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",o=i=>`ord-${e.type}-${r}-${t}-${i}`,n=`ord-${e.type}-${r}-${t}`;switch(e.type){case"rect":{let t,i,r=e,o=hl(n)+"-grad",a=function(e,t){let i=e.fillGradient;if(!i||"object"!=typeof i)return null;let r=e.x,o=e.y,n=e.x,a=e.y+e.h;"bottom"===e.roundedEdge?(o=e.y+e.h,a=e.y):"right"===e.roundedEdge?(r=e.x+e.w,o=e.y,n=e.x,a=e.y):"left"===e.roundedEdge&&(r=e.x,o=e.y,n=e.x+e.w,a=e.y);let s=pl(i.stops,dl(e.style.fill));return s?Tb("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:r,y1:o,x2:n,y2:a,children:s}):null}(r,o);if(a)i=`url(#${o})`;else if(rr(r.style.fill)){let e=hl(n)+"-hatch";t=nr(r.style.fill,e),i=`url(#${e})`}else i=dl(r.style.fill);let s=a||t?Iv("defs",{children:[a,t]}):null;if(r.cornerRadii&&Js(r.cornerRadii)){let e=function(e){let{x:t,y:i,w:r,h:o}=e,{tl:n,tr:a,br:s,bl:l}=el(e),c=`M${t+n},${i}`;return c+=` L${t+r-a},${i}`,a>0&&(c+=` A${a},${a} 0 0 1 ${t+r},${i+a}`),c+=` L${t+r},${i+o-s}`,s>0&&(c+=` A${s},${s} 0 0 1 ${t+r-s},${i+o}`),c+=` L${t+l},${i+o}`,l>0&&(c+=` A${l},${l} 0 0 1 ${t},${i+o-l}`),c+=` L${t},${i+n}`,n>0&&(c+=` A${n},${n} 0 0 1 ${t+n},${i}`),c+=" Z",c}(r);return Iv(_v.Fragment,{children:[s,Rv("path",{d:e,fill:i,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},n)}if(r.roundedTop&&r.roundedTop>0){let e,t=Math.min(r.roundedTop,r.w/2,r.h/2),{x:o,y:a,w:l,h:c}=r;switch(r.roundedEdge){case"right":e=`M${o},${a} L${o+l-t},${a} A${t},${t} 0 0 1 ${o+l},${a+t} L${o+l},${a+c-t} A${t},${t} 0 0 1 ${o+l-t},${a+c} L${o},${a+c} Z`;break;case"left":e=`M${o+l},${a} L${o+t},${a} A${t},${t} 0 0 0 ${o},${a+t} L${o},${a+c-t} A${t},${t} 0 0 0 ${o+t},${a+c} L${o+l},${a+c} Z`;break;case"bottom":e=`M${o},${a} L${o+l},${a} L${o+l},${a+c-t} A${t},${t} 0 0 1 ${o+l-t},${a+c} L${o+t},${a+c} A${t},${t} 0 0 1 ${o},${a+c-t} Z`;break;default:e=`M${o},${a+c} L${o},${a+t} A${t},${t} 0 0 1 ${o+t},${a} L${o+l-t},${a} A${t},${t} 0 0 1 ${o+l},${a+t} L${o+l},${a+c} Z`}return Iv(_v.Fragment,{children:[s,Rv("path",{d:e,fill:i,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},n)}return Iv(_v.Fragment,{children:[s,Rv("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:i,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth}),Au(r,n)]},n)}case"point":{let t=e;return Rv("circle",{cx:t.x,cy:t.y,r:t.r,fill:dl(t.style.fill),opacity:t.style.opacity??t.style.fillOpacity??.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},n)}case"symbol":return yl(e,t,i);case"glyph":return fl(e,e.x,e.y,`${i??""}ord-glyph-${e.pointId??t}`);case"wedge":{let r,o=e;if(o._gradientBand&&o._gradientBand.colors.length>0){let e=hl(`${i?i+"-":""}gauge-grad-${o.category||n}-${t}`),{clipPath:r,slices:a}=function(e){let t=wu({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,cornerRadius:e.cornerRadius,roundStart:e.roundStart,roundEnd:e.roundEnd}),i=[],r=e.colors;if(r.length>0){let t=(e.endAngle-e.startAngle)/r.length;for(let o=0;r.length>o;o++)i.push({d:wu({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle+o*t,endAngle:e.endAngle}),color:r[o]})}return{clipPath:t,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 Iv("g",{transform:`translate(${o.cx},${o.cy})`,opacity:o.style.opacity,fillOpacity:o.style.fillOpacity,children:[Rv("defs",{children:Rv("clipPath",{id:e,children:Rv("path",{d:r})})}),Rv("g",{clipPath:`url(#${e})`,children:a.map((e,t)=>Rv("path",{d:e.d,fill:dl(e.color)},t))}),o.style.stroke&&"none"!==o.style.stroke&&Rv("path",{d:r,fill:"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},n)}if(o.roundedEnds)r=wu({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds.start,roundEnd:o.roundedEnds.end});else{let e=$v().innerRadius(o.innerRadius).outerRadius(o.outerRadius).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2);o.cornerRadius&&e.cornerRadius(o.cornerRadius),r=e(Ob)||""}return Rv("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:dl(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},n)}case"boxplot":{let t=e,i=t.columnWidth/2,r=t.style.strokeWidth??1;return Iv("g","vertical"===t.projection?{children:[Rv("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:r}),Rv("rect",{x:t.x-i,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:dl(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:r}),Rv("line",{x1:t.x-i,y1:t.medianPos,x2:t.x+i,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2*r}),Rv("line",{x1:t.x-.5*i,y1:t.minPos,x2:t.x+.5*i,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:r}),Rv("line",{x1:t.x-.5*i,y1:t.maxPos,x2:t.x+.5*i,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:r})]}:{children:[Rv("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:r}),Rv("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-i,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:dl(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:r}),Rv("line",{x1:t.medianPos,y1:t.y-i,x2:t.medianPos,y2:t.y+i,stroke:t.style.stroke||"#333",strokeWidth:2*r}),Rv("line",{x1:t.minPos,y1:t.y-.5*i,x2:t.minPos,y2:t.y+.5*i,stroke:t.style.stroke||"#333",strokeWidth:r}),Rv("line",{x1:t.maxPos,y1:t.y-.5*i,x2:t.maxPos,y2:t.y+.5*i,stroke:t.style.stroke||"#333",strokeWidth:r})]},n)}case"violin":{let t=e,i=[Rv("path",{d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:dl(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){let e=t.bounds,r=e.x+e.width/2,n=e.y+e.height/2;t.iqrLine.isVertical?i.push(Rv("line",{x1:r,y1:t.iqrLine.q1Pos,x2:r,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2},o("iqr")),Rv("circle",{cx:r,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},o("med"))):i.push(Rv("line",{x1:t.iqrLine.q1Pos,y1:n,x2:t.iqrLine.q3Pos,y2:n,stroke:t.style.stroke||"#333",strokeWidth:2},o("iqr")),Rv("circle",{cx:t.iqrLine.medianPos,cy:n,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},o("med")))}return Rv("g",{children:i},n)}case"connector":{let t=e,i=t.style.fill&&"none"!==t.style.fill?dl(t.style.fill,"var(--semiotic-border, #999)"):"var(--semiotic-border, #999)";return Rv("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||i,strokeWidth:t.style.strokeWidth??1,opacity:t.style.opacity??.5},n)}case"trapezoid":{let t=e,i=t.points.map(e=>`${e[0]},${e[1]}`).join(" ");return Rv("polygon",{points:i,fill:dl(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},n)}default:return null}}(e,t,i),e,"ordinal-cursor-"+t)}(t,i,e.idPrefix)}),i=0;for(let r=0;t.length>r;){if(t[r].renderedByBackend){r++;continue}let o=r+1;for(;t.length>o&&!t[o].renderedByBackend;)o++;_u(t.slice(r,o),e.idPrefix,i++),r=o}return t}function Pu(e,i){let r=Ke(e.theme),o=e.size||[500,400],a=s({...Dx,...e.margin},e.title),l=n(e.title),c=me(e.data),u=e.showLegend?Ll(c,e.colorAccessor||e.stackBy||e.groupBy):[],d=function(e){let t=e.projection??"vertical",i=!1!==e.showAxes&&"radial"!==t;return{hasAxis:i,hasAxisLabel:i&&("horizontal"===t?e.hasValueLabel:e.hasCategoryLabel),leftAxis:{hasAxis:i,hasAxisLabel:i&&("horizontal"===t?e.hasCategoryLabel:e.hasValueLabel)}}}({showAxes:e.showAxes,projection:e.projection,hasCategoryLabel:!(!e.categoryLabel&&!e.oLabel),hasValueLabel:!(!e.valueLabel&&!e.rLabel)});Xc(a,{props:{...e,axisChrome:d},categories:u,theme:r,size:o,hasTitle:l});let f=qc({props:{...e,axisChrome:d},categories:u,theme:r,size:o,margin:a,hasTitle:l}),p=o[0]-a.left-a.right,y=o[1]-a.top-a.bottom,g=e.projection||"vertical",m="radial"===g,b=e.colorScheme||r.colors.categorical,x={chartType:e.chartType,windowSize:e.windowSize??1e4,windowMode:e.windowMode??"sliding",extentPadding:e.extentPadding??.05,projection:g,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:je(e.gradientFill),symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,multiAxis:e.multiAxis,baselinePadding:e.baselinePadding,trackFill:e.trackFill,connectorOpacity:e.connectorOpacity,showLabels:e.showLabels,colorScheme:b,themeCategorical:r.colors.categorical,themeSemantic:Ue(r),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:a,layoutSelection:e.layoutSelection,barColors:e.barColors},v=new Sv(x);e.data&&v.ingest({inserts:c,bounded:!0}),v.computeScene({width:p,height:y});let w=Vc(e.backgroundGraphics,o,a,v.scales),k=Vc(e.foregroundGraphics,o,a,v.scales);if(!v.scales){let t,n=e.annotations?wc({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:c,scales:{},layout:{width:p,height:y},theme:r,projection:g,idPrefix:e._idPrefix,onRender:e=>{t=e}}):null;return i&&(i.evidence=ul({frameType:"ordinal",width:o[0],height:o[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,annotationRender:t,extraWarnings:v.scales?[]:["NO_SCALES"],margin:a})),ov.renderToStaticMarkup(Gc(w||k||e.annotations?zv(Fv,{children:[w,n,k,v.customLayoutOverlays]}):null,{width:o[0],height:o[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:r,innerTransform:`translate(${a.left},${a.top})`,innerWidth:p,innerHeight:y,legend:f,idPrefix:e._idPrefix}))}let A=e._idPrefix,S=e.showGrid?function(e,t,i,r,o,n){let a=e.scales;if(!a||"radial"===a.projection)return null;let{grid:s}=Ze(i),l=r?r+"-":"",c="vertical"===a.projection,u=n??Ic(a.r,5,o);return Lx("g",c?{id:l+"grid",className:"semiotic-grid",opacity:.8,children:u.map((e,i)=>{let r=a.r(e);return Lx("line",{x1:0,y1:r,x2:t.width,y2:r,stroke:s,strokeWidth:.5},"gr-"+i)})}:{id:l+"grid",className:"semiotic-grid",opacity:.8,children:u.map((e,i)=>{let r=a.r(e);return Lx("line",{x1:r,y1:0,x2:r,y2:t.height,stroke:s,strokeWidth:.5},"gr-"+i)})})}(v,{width:p,height:y},r,A,e.axisExtent,e.rTickValues):null,M=null;if(v.scene.some(e=>"rect"===e.type&&e.datum?.__barFunnelIsDropoff)){let t=Bc(e),i=new Set;for(let e of v.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&i.add("string"==typeof e.style.fill?e.style.fill:"#666");M=Array.from(i).map((e,i)=>function(e){let{id:t,background:i="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:n=6,angle:a=45}=e,s=Math.max(8,Math.ceil(2*n));return Ov("pattern",{id:t,width:s,height:s,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0,children:[i&&"transparent"!==i&&Cv("rect",{width:s,height:s,fill:i}),Cv("line",{x1:0,y1:0,x2:0,y2:s,stroke:r,strokeWidth:o}),Cv("line",{x1:n,y1:0,x2:n,y2:s,stroke:r,strokeWidth:o})]},t)}({id:`funnel-hatch-${t}-${i}`,background:e,stroke:"transparent"===r.colors.background?"#fff":r.colors.background,lineWidth:1.5,spacing:5,angle:45}));let o=new Map;Array.from(i).forEach((e,i)=>o.set(e,`funnel-hatch-${t}-${i}`));for(let e of v.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&(e.style={...e.style,fill:`url(#${o.get("string"==typeof e.style.fill?e.style.fill:"#666")})`})}let _,$=$u({nodes:v.scene,renderMode:e.renderMode,idPrefix:A}),P=$.map(e=>e.element),R=!1!==e.showAxes?function(e,i,r,o,n,a,s,l=!1){let c=e.scales;if(!c||"radial"===c.projection)return null;let u=Ze(o),d="vertical"===c.projection,f=e.columns,p=r.categoryFormat||r.oFormat,y=r.valueFormat||r.rFormat,g=r.categoryLabel||r.oLabel,m=r.valueLabel||r.rLabel,b=r.legendPosition??"right",x=h(r.legendLayout,s?.leftAxis),v=l&&"left"===b&&x>0?x:a?.left??r.margin?.left??40,w=Object.values(f).map((e,t)=>({pixel:e.middle,label:p?p(e.name,t):e.name})),k=r.rTickValues??Ic(c.r,5,r.axisExtent),A=y||t(k),S=k.map(e=>({pixel:c.r(e),label:A(e)}));return zv("g",d?{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[Dv("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:u.border,strokeWidth:1}),w.map((e,t)=>zv("g",{transform:`translate(${e.pixel},${i.height})`,children:[Dv("line",{y2:5,stroke:u.border,strokeWidth:1}),Lc(e.label)?Dv("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):Tc({label:e.label,x:-30,y:6,textAlign:"center",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"oxtick-"+t)),g&&Dv("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:g}),Dv("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:u.border,strokeWidth:1}),S.map((e,t)=>zv("g",{transform:`translate(0,${e.pixel})`,children:[Dv("line",{x2:-5,stroke:u.border,strokeWidth:1}),Dv("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"oytick-"+t)),m&&Dv("text",{x:15-v,y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-v}, ${i.height/2})`,children:m})]}:{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[Dv("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:u.border,strokeWidth:1}),S.map((e,t)=>zv("g",{transform:`translate(${e.pixel},${i.height})`,children:[Dv("line",{y2:5,stroke:u.border,strokeWidth:1}),Dv("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"oxtick-"+t)),m&&Dv("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:m}),Dv("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:u.border,strokeWidth:1}),w.map((e,t)=>zv("g",{transform:`translate(0,${e.pixel})`,children:[Dv("line",{x2:-5,stroke:u.border,strokeWidth:1}),Lc(e.label)?Dv("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):Tc({label:e.label,x:-68,y:-12,textAlign:"right",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"oytick-"+t)),g&&Dv("text",{x:15-v,y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-v}, ${i.height/2})`,children:g})]})}(v,{width:p,height:y},e,r,A,a,d,!!f):null,I=e.annotations?wc({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:c,scales:{o:v.scales.o,r:v.scales.r,y:"vertical"===v.scales.projection?v.scales.r:void 0},layout:{width:p,height:y},theme:r,projection:g,xAccessor:"string"==typeof e.oAccessor?e.oAccessor:void 0,yAccessor:"string"==typeof e.rAccessor?e.rAccessor:void 0,idPrefix:A,onRender:e=>{_=e}}):null;if(i){let t=v.scales.o?.domain?.();i.evidence=ul({frameType:"ordinal",width:o[0],height:o[1],marks:$.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:_,yDomain:cl(v.scales.r?.domain?.()),categories:Array.isArray(t)?t.map(String):void 0,margin:a})}let L=m&&e.centerContent?function(e,t,i){if(!tv.isValidElement(e)||!rv.has(e.type))return null;let r=e,o="text"===r.type?tv.cloneElement(r,{x:r.props.x??0,y:r.props.y??0,textAnchor:r.props.textAnchor??"middle",dominantBaseline:r.props.dominantBaseline??"middle"}):r;return iv("g",{className:"semiotic-radial-center-content",transform:`translate(${t},${i})`,pointerEvents:"none",children:o})}(e.centerContent,a.left+p/2,a.top+y/2):null,T=m&&e.centerContent?L??Dv("foreignObject",{x:a.left,y:a.top,width:p,height:y,pointerEvents:"none",children:Dv("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:e.centerContent})}):null,C=zv(Fv,{children:[S,P,R,I,k,v.customLayoutOverlays]});return ov.renderToStaticMarkup(Gc(zv(Fv,m?{children:[w?Dv("g",{transform:`translate(${-p/2},${-y/2})`,children:w}):null,C]}:{children:[w,C]}),{width:o[0],height:o[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:r,innerTransform:m?`translate(${a.left+p/2},${a.top+y/2})`:`translate(${a.left},${a.top})`,innerWidth:p,innerHeight:y,legend:f,defs:M,outerElements:T,idPrefix:e._idPrefix}))}function Ru(e,t){Ev[e]=t}function Iu(e,t){var i=e.get(t);if(!i)throw Error("missing: "+t);return i}function Lu(e,t){function i(e){c[e]=!1,u.hasOwnProperty(e)&&Object.keys(u[e]).forEach(function(t){delete u[e][t],c[t]&&i(t)})}function r(e){var t,n,s=!1;for(l.push(e),c[e]=!0,t=0;d[e].length>t;t++)(n=d[e][t])===a?(o(a,l),s=!0):c[n]||(s=r(n));if(s)i(e);else for(t=0;d[e].length>t;t++){var h=u[n=d[e][t]];h||(u[n]=h={}),h[n]=!0}return l.pop(),s}function o(e,i){var r=[].concat(i).concat(e);t?t(r):s.push(r)}function n(t){!function(t){for(var i=0;e.length>i;i++)(t>i||!e[i])&&(e[i]=[]),e[i]=e[i].filter(function(e){return e>=t})}(t);for(var i,r=function(e){function t(t){var i=[t],c=[t];for(r[t]=o[t]=d,n[t]=!0,d+=1;c.length>0;){var u=e[t=c[c.length-1]];if(u.length>a[t]){for(var p=a[t];u.length>p;++p){var y=u[p];if(0>r[y]){r[y]=o[y]=d,n[y]=!0,d+=1,i.push(y),c.push(y);break}n[y]&&(o[t]=0|Math.min(o[t],o[y])),s[y]>=0&&l[t].push(s[y])}a[t]=p}else{if(o[t]===r[t]){var g=[],m=[],b=0;for(p=i.length-1;p>=0;--p){var x=i[p];if(n[x]=!1,g.push(x),m.push(l[x]),b+=l[x].length,s[x]=h.length,x===t){i.length=p;break}}h.push(g);var v=Array(b);for(p=0;m.length>p;p++)for(var w=0;m[p].length>w;w++)v[--b]=m[p][w];f.push(v)}c.pop()}}}for(var i=e.length,r=Array(i),o=Array(i),n=Array(i),a=Array(i),s=Array(i),l=Array(i),c=0;i>c;++c)r[c]=-1,o[c]=0,n[c]=!1,a[c]=0,s[c]=-1,l[c]=[];var u,d=0,h=[],f=[];for(c=0;i>c;++c)0>r[c]&&t(c);for(c=0;f.length>c;c++){var p=f[c];if(0!==p.length){p.sort(function(e,t){return e-t}),u=[p[0]];for(var y=1;p.length>y;y++)p[y]!==p[y-1]&&u.push(p[y]);f[c]=u}}return{components:h,adjacencyList:f}}(e),o=r.components.filter(function(e){return e.length>1}),n=1/0,a=0;o.length>a;a++)for(var s=0;o[a].length>s;s++)n>o[a][s]&&(n=o[a][s],i=a);var l=o[i];return!!l&&{leastVertex:n,adjList:e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})})}}var a,s=[],l=[],c=[],u={},d=[];a=0;for(var h=e.length;h>a;){var f=n(a);if(a=f.leastVertex,d=f.adjList){for(var p=0;d.length>p;p++)for(var y=0;d[p].length>y;y++){var g=d[p][y];c[+g]=!1,u[g]={}}r(a),a+=1}else a=h}if(!t)return s}function Tu(e){return e.y0-e.y1>0?"up":"down"}function Cu(e,t){return t(e.source)==t(e.target)}function Ou(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var i=0;return e.target.targetLinks.forEach(function(e){i=e.circular?i+1:i}),!(t>1||i>1)}function Fu(e){return e.target.x0-e.source.x1}function Du(e,t){var i=Nu(e),r=Fu(t)/Math.tan(i);return"up"==Tu(e)?e.y1-r:e.y1+r}function zu(e,t){var i=Nu(e),r=Fu(t)/Math.tan(i);return"up"==Tu(e)?e.y1+r:e.y1-r}function Nu(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Eu(e,t){return t(e)}function Bu(e){return ju(e.source)}function Wu(e){return ju(e.target)}function ju(e){return(e.y0+e.y1)/2}function Yu(e){return e.virtual?0:e.value}function Xu(e,t){var i=0;e.sourceLinks.forEach(function(e){i=e.circular&&!Cu(e,t)?i+1:i});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!Cu(e,t)?r+1:r}),i+r}function qu(e){return e.target.depth}function Gu(e,t){return e.sourceLinks.length?e.depth:t-1}function Vu(e,t){return e.y0-t.y0}function Hu(e,t){return t.y0-e.y0}function Uu(e,t){return e.y1-t.y1}function Ku(e,t){return t.y1-e.y1}function Zu(e,t){return Ju(e.source,t.source)||e.index-t.index}function Qu(e,t){return Ju(e.target,t.target)||e.index-t.index}function Ju(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function ed(e,t){return td(e)==td(t)?"bottom"==e.circularLinkType?Hu(e,t):Vu(e,t):td(t)-td(e)}function td(e){return e.target.column-e.source.column}function id(e,t){return rd(e)==rd(t)}function rd(e){return e.y0-e.y1>0?"up":"down"}function od(e,t,i,r,o){let n=e;var a=Math.max(8,.15*(n.y1-n.y0));n.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,a))});var s=Bv(n.links,function(e){return e.source.y0});n.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=n.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}),nd(n.links.filter(function(e){return"top"==e.circularLinkType}),t,i),nd(n.links.filter(function(e){return"bottom"==e.circularLinkType}),t,i),n.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,Cu(e,t)&&Ou(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 a=e.source.column,l=e.circularLinkType,c=n.links.filter(function(e){return e.source.column==a&&e.circularLinkType==l});c.sort("bottom"==e.circularLinkType?Hu:Vu);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*i+u),u+=t._circularWidth||t.width}),a=e.target.column,(c=n.links.filter(function(e){return e.target.column==a&&e.circularLinkType==l})).sort("bottom"==e.circularLinkType?Ku:Uu),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*i+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(n.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=s-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,i=e.y0,r=e.target.x0,o=e.y1,n=(t+r)/2;return"M"+t+","+i+"C"+n+","+i+" "+n+","+o+" "+r+","+o}(e)}),n}function nd(e,t,i){e.sort(ed);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var n=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(Cu(e,t)&&Ou(e))e.circularPathData.verticalBuffer=n+e._circularWidth/2;else{for(var a=0;r.length>a;a++){var s=r[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&ad(e,s)){var l=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+i;n=l>n?l:n}}e.circularPathData.verticalBuffer=n+e._circularWidth/2}}),e}function ad(e,t){return!(t.target.column>e.source.column||e.target.column>t.source.column)}function sd(e){return function(){return e}}function ld(e){return e.index}function cd(e){return e.nodes}function ud(e){return e.links}function dd(e,t,i){var r=Gv(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,n){var a=o.length;if(t)o.sort(t);else if(n>0){var s=new Map;o.forEach(function(e,t){var i,r,o,n=(r=0,o=0,(i=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=ju(e.source)*t,r+=t}}),i.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=ju(e.target)*t,r+=t}}),r>0?o/r:NaN);s.set(e,{bc:n,idx:t})}),o.sort(function(e,t){var i=s.get(e),r=s.get(t),o=i.bc,n=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||"bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(n)?isNaN(o)?isNaN(n)?i.idx-r.idx:1:-1:o-n})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Xu(t,i)-Xu(e,i):"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==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==Xu(t,i)?(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)/a*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+o,t.y1=t.y0+t.value*e.ky)})})}function hd(e,t,i,r,o,n){function a(t,i){var r=l.length;l.forEach(function(o){var n=o.length,a=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&Xu(o,i)>0){var l=Xv(o.sourceLinks,Wu),c=Xv(o.targetLinks,Bu),u=l&&c?(l+c)/2:l||c;if(u){var d=(u-ju(o))*t*.3;o.y0+=d,o.y1+=d}}else if(0==a&&1==n)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(a==r-1&&1==n)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)s=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+s;else{var h=Xv(o.sourceLinks,Wu),f=Xv(o.targetLinks,Bu),p=((h&&f?(h+f)/2:h||f)-ju(o))*t;o.y0+=p,o.y1+=p}})})}function s(){l.forEach(function(i){var n,a,s,l=e.y0,c=i.length;for(i.sort(t||Ju),s=0;c>s;++s)(a=l-(n=i[s]).y0)>0&&(n.y0+=a,n.y1+=a),l=n.y1+r;if((a=l-r-e.y1)>0)for(l=n.y0-=a,n.y1-=a,s=c-2;s>=0;--s)(a=(n=i[s]).y1+o-l)>0&&(n.y0-=a,n.y1-=a),l=n.y0})}var l=Gv(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});s();for(var c=1,u=n;u>0;--u)a(c*=.99,i),s()}function fd(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Qu),e.targetLinks.sort(Zu)}),e.nodes.forEach(function(e){var t=e.y0,i=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=i+e.width/2,i+=e.width)})})}function pd(){function e(){var e={nodes:p.apply(null,arguments),links:y.apply(null,arguments)};return function(e){e.x0=t,e.y0=i,e.x1=r,e.y1=o,e.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var i=function(e,t){var i=new Map;return qv(e,t).forEach(function(e,t){i.set(t,e[0])}),i}(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=Iu(i,r)),"object"!=typeof o&&(o=e.target=Iu(i,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(e,l),function(e,t){var i=0;if(null==t){for(var r=[],o=0;e.links.length>o;o++){var n=e.links[o],a=n.source.index,s=n.target.index;r[a]||(r[a]=[]),r[s]||(r[s]=[]),-1===r[a].indexOf(s)&&r[a].push(s)}var l=Lu(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=i++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=i++)})}(e,u),function(e,t){var i=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>i?"top":"bottom","top"==o.circularLinkType?i++:r++,e.nodes.forEach(function(e){(Eu(e,t)==Eu(o.source,t)||Eu(e,t)==Eu(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),Cu(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(e,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(Yv(e.sourceLinks,Yu),Yv(e.targetLinks,Yu)),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)})})}(e),function(e,t,i){var r,o,n;if(null!=t){e.nodes.sort(function(e,i){return t(e)<t(i)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(r=e.nodes,o=[],n=0;r.length;++n,r=o,o=[])r.forEach(function(e){e.depth=n,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(r=e.nodes,o=[],n=0;r.length;++n,r=o,o=[])r.forEach(function(e){e.height=n,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?i(e,n):e.column})}(e,u,c);var p=a;if(null!==s){var y=Gv(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),g=jv(y,function(e){return e.length});g>1&&(p=Math.max(1,(o-i)*s/(g-1)))}(function(e,t,i){var r=Gv(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=Wv(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/Yv(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var n=jv(e.nodes,function(e){return e.column});e.nodes.forEach(n>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-i)/n),t.x1=t.x0+i}:function(t){t.x0=e.x0,t.x1=t.x0+i})})(e,p,n),dd(e,u,l),hd(e,u,l,p,p,d),fd(e),od(e,l,h,f,8),dd(e,u,l),hd(e,u,l,p,p,d),fd(e),od(e,l,h,f,8),function(e,t){let i=e;i.nodes.forEach(function(e){e.y+(e.y1-e.y0)>i.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-i.y1));var r=i.links.filter(function(i){return Eu(i.source,t)==Eu(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(!id(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var i=Du(t,e);return e.y1-i}if(t.target.column>e.target.column)return Du(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 n=e.y0;r.forEach(function(e){e.y0=n+e.width/2,n+=e.width}),r.forEach(function(t,i){if("bottom"==t.circularLinkType){for(var n=i+1,a=0;o>n;n++)a+=r[n].width;t.y0=e.y1-a-t.width/2}})})}(e,l),function(e,t){let i=e;i.nodes.forEach(function(e){var r=i.links.filter(function(i){return Eu(i.target,t)==Eu(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(!id(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var i=zu(t,e);return e.y0-i}if(t.source.column>e.source.column)return zu(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 n=e.y0;r.forEach(function(e){e.y1=n+e.width/2,n+=e.width}),r.forEach(function(t,i){if("bottom"==t.circularLinkType){for(var n=i+1,a=0;o>n;n++)a+=r[n].width;t.y1=e.y1-a-t.width/2}})})}(e,l),function(e){var t=e.nodes,i=e.links,r=!1,o=!1;if(i.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==r||0==o){let r=function(t){return(t-n)/(a-n)*(e.y1-e.y0)+e.y0};var n=Wv(t,function(e){return e.y0}),a=jv(t,function(e){return e.y1}),s=(e.y1-e.y0)/(a-n);1>s?(t.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1)}),i.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,i=r(e.y0)-e.y0;e.y0=r(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+i}),e.targetLinks.forEach(function(e){e.y1=e.y1+i})})}}(e),od(e,l,h,f,8)}(e),e}var t=0,i=0,r=1,o=1,n=24,a=8,s=null,l=ld,c=Gu,u=void 0,d=32,h=2,f=10,p=cd,y=ud;return e.update=function(e){return fd(e),od(e,l,h,f,8),e},e.nodeWidth=function(t){return arguments.length?(n=+t,e):n},e.nodePadding=function(t){return arguments.length?(a=+t,e):a},e.nodePaddingRatio=function(t){return arguments.length?(s=+t,e):s},e.nodes=function(t){return arguments.length?(p="function"==typeof t?t:sd(t),e):p},e.links=function(t){return arguments.length?(y="function"==typeof t?t:sd(t),e):y},e.nodeId=function(t){return arguments.length?(l="function"==typeof t?t:sd(t),e):l},e.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:sd(t),e):c},e.nodeSort=function(t){return arguments.length?(u=t,e):u},e.iterations=function(t){return arguments.length?(d=+t,e):d},e.circularLinkGap=function(t){return arguments.length?(h=+t,e):h},e.extent=function(n){return arguments.length?(t=+n[0][0],i=+n[0][1],r=+n[1][0],o=+n[1][1],e):[[t,i],[r,o]]},e.size=function(n){return arguments.length?(t=i=0,r=+n[0],o=+n[1],e):[r-t,o-i]},e}function yd(e){let t=e.sankeyWidth/2,i=(e._circularWidth??e.sankeyWidth)/2,r=e.circularPathData;if(!r||"down"===e.direction)return null;if(e._circularStub){let i=r.sourceX,o=r.sourceY,n=r.targetX,a=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;let s=Math.max(15,Math.min(40,.33*(r.rightFullExtent-i))),l=Math.max(15,Math.min(40,.33*(n-r.leftFullExtent)));return`M${i},${o-t}L${i+s},${o-t}L${i+s},${o+t}L${i},${o+t}ZM${n},${a-t}L${n-l},${a-t}L${n-l},${a+t}L${n},${a+t}Z`}let o=r.sourceX,n=r.sourceY,a=r.targetX,s=r.targetY,l=r.rightFullExtent,c=r.leftFullExtent,u=r.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(i,15));return`M${o},${n-d*t}L${l},${n-d*t}L${l+i},${n-d*t+d*h}L${l+i},${u+d*i-d*h}L${l+i-h},${u+d*i}L${c-i+h},${u+d*i}L${c-i},${u+d*i-d*h}L${c-i},${s-d*t+d*h}L${c-i+h},${s-d*t}L${a},${s-d*t}L${a},${s+d*t}L${c+i},${s+d*t}L${c+i},${u-d*i}L${l-i},${u-d*i}L${l-i},${n+d*t}L${o},${n+d*t}Z`}function gd(e,t){if("production"===process.env.NODE_ENV||!e||!e.data||"object"!=typeof e.data)return e;let i=Qv.get(e);if(i){let e=i.get(t);if(e)return e}else i=new Map,Qv.set(e,i);let r=new Proxy(e,{get(e,i,r){if("string"==typeof i&&!(i in e)&&e.data&&i in e.data){let e=`${t}:${i}`;Zv.has(e)||(Zv.add(e),console.warn(`[Semiotic] "${t}" 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(e,i,r)}});return i.set(t,r),r}function md(e,t,i){if(i.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;let r=t||[5,20],o=[];for(let t of i){let i=t.data?.[e];"number"==typeof i&&o.push(i)}if(0===o.length)return()=>r[0];let[n,a]=Je(o);if(n===a)return()=>(r[0]+r[1])/2;let s=lw().domain([n,a]).range(r).clamp(!0);return t=>{let i=t.data?.[e];return null==i||"number"!=typeof i?r[0]:s(i)}}function bd(e,t,i){let r=[];for(let o of t){let t=Ra(o.source),n=Ra(o.target),a=null;if(t===e?a=n:n===e&&(a=t),a){let e=i.get(a);e&&(0!==e.x||0!==e.y)&&r.push({x:e.x,y:e.y})}}return r}function xd(e){let t=0;for(let i=0;e.length>i;i++)t=(t<<5)-t+e.charCodeAt(i)|0;return Math.abs(t)}function vd(e,t,i){let r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;let o=[],n=0;for(;r.length>n;){let e=r[n];if("M"===e||"L"===e||"C"===e||"Q"===e)for(o.push(e),n++;r.length>n&&!isNaN(Number(r[n]));)o.push(Number(r[n])+t+""),n++,r.length>n&&!isNaN(Number(r[n]))&&(o.push(Number(r[n])+i+""),n++);else if("A"===e)for(o.push(e),n++;r.length>n&&!isNaN(Number(r[n]));)o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&(o.push(Number(r[n])+t+""),n++),r.length>n&&(o.push(Number(r[n])+i+""),n++);else"Z"===e||"z"===e?(o.push(e),n++):(o.push(r[n]),n++)}return o.join(" ")}function wd(e){let[t,i,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)]}let 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*i+.114*r>150?"#222":"#fff"}function kd(e,t,i){let 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-"+i}function Ad(e){if(!e)return null;if("function"==typeof e){let t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function Sd(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:kw}function Md(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 _d(e,t,i,r,o){if("horizontal"===o){let o=(e+i)/2;return`M ${e},${t} C ${o},${t} ${o},${r} ${i},${r}`}if("radial"===o){let o=(e+i)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+r)/2} T ${i},${r}`}{let o=(t+r)/2;return`M ${e},${t} C ${e},${o} ${i},${o} ${i},${r}`}}function $d(e,t,i){let r=i.treeOrientation||"vertical";if("radial"===r){let i=t.x,r=t.y;e.x=r*Math.cos(i-Math.PI/2),e.y=r*Math.sin(i-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 Pd(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 Rd(e,t){let i=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-i,e.x1=t.x+i,e.y0=t.y-i,e.y1=t.y+i,e.width=2*i,e.height=2*i,e.__radius=i}function Id(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"u">typeof performance?performance.now():Date.now()},e.__orbitState=t),t}function Ld(e){let t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}function Td(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){let t=e.cx??e.x,i=e.cy??e.y;if("number"!=typeof t||"number"!=typeof i)return null;let r=Xs(e.glyph,e.size);return{x:t+r.centerDx,y:i+r.centerDy,r:Math.max(1,r.radius)}}let t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),i=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof i?null:{x:t,y:i,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,zs(e.size)):Math.max(1,e.w??0,e.h??0)/2}}function Cd(e){if(!e)return;let t=[];for(let i of e){let e=Td(i);e&&t.push({pointId:Ld(i),...e})}return t}function Od(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function Fd(e){return e.map(e=>{let t=e.datum&&"object"==typeof e.datum?e.datum:{},i=t.data&&"object"==typeof t.data?t.data:t,r="cx"in e?e.cx:e.x+e.w/2,o="cy"in e?e.cy:e.y+e.h/2;return{...i,...null==i.id&&null!=e.id?{id:e.id}:{},x:r,y:o}})}function Dd(e,t){let i=Ke(e.theme),r=e.chartType||"force",o=e.size||[500,500],a=function(e){return Ex.has(e)?Nx:zx}(r),l=s({...a,...e.margin},e.title),c=n(e.title),u=e.showLegend?(()=>{let t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;if(!t)return[];let o=me(e.nodes||[]);if(o.length>0)return Ll(o,t);if(Tw.has(r)&&e.data)return Ll(cr(e.data,e.childrenAccessor||"children"),t);let n=Array.isArray(e.edges)?me(e.edges):[];if(0===n.length)return[];let a=Od(e.sourceAccessor,"source"),s=Od(e.targetAccessor,"target");return Ll(Array.from(new Set(n.flatMap(e=>[a(e),s(e)]).filter(e=>null!=e).map(String))).map(e=>({id:e})),t)})():[];Xc(l,{props:e,categories:u,theme:i,size:o,hasTitle:c});let d=qc({props:e,categories:u,theme:i,size:o,margin:l,hasTitle:c}),h=o[0]-l.left-l.right,f=o[1]-l.top-l.bottom,p=Vc(e.backgroundGraphics,o,l,null),y=Vc(e.foregroundGraphics,o,l,null),g=()=>{let r,n=e=>Number(e),a=e.annotations?wc({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{x:n,y:n},layout:{width:h,height:f},theme:i,frameType:"network",idPrefix:e._idPrefix,onRender:e=>{r=e}}):null;return t&&(t.evidence=(t=>ul({frameType:"network",width:o[0],height:o[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,annotationRender:t,nodeCount:0,edgeCount:0,margin:l}))(r)),Nv.renderToStaticMarkup(Gc(p||y||e.annotations?Lw(Iw,{children:[p,a,y]}):null,{width:o[0],height:o[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${l.left},${l.top})`,innerWidth:h,innerHeight:f,legend:d,idPrefix:e._idPrefix}))},m=function(e){return Ev[e]}(r);if(!m&&!e.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${r}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition, orbit.`);let b,x,v={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||i.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:!1,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig};if(Tw.has(r)){let t=e.data||e.edges;if(!t||Array.isArray(t))return g();v.__hierarchyRoot=t,b=[],x=[]}else{let t=me(e.nodes||[]),i=Array.isArray(e.edges)?me(e.edges):[];if(0===t.length&&0===i.length)return g();if(x=function(e,t){let i=Od(t.sourceAccessor,"source"),r=Od(t.targetAccessor,"target"),o=Od(t.valueAccessor,"value");return e.map((e,t)=>{let n=Number(o(e)),a=i(e)+"",s=r(e)+"";return{source:a,target:s,value:Number.isFinite(n)?n:1,y0:0,y1:0,sankeyWidth:0,data:e,_edgeKey:`${a}\0${s}\0${t}`}})}(i,v),0===t.length&&x.length>0){let e=new Set;for(let t of x){let i=Ec(t.source),r=Ec(t.target);i&&e.add(i),r&&e.add(r)}b=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 b=function(e,t){let i=Od(t.nodeIDAccessor,"id");return e.map(e=>({id:i(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}))}(t,v)}let w=[],k=[],A=[],S=null,M=null;if(v.customNetworkLayout){let e=v.colorScheme,t=qo(e,i.colors.categorical,tf),r=Go(t,e),o={nodes:b,edges:x,dimensions:{width:h,height:f,plot:{x:0,y:0,width:h,height:f}},theme:{semantic:i.colors,categorical:[...t]},resolveColor:r,config:v.layoutConfig??{}},n=v.customNetworkLayout(o);w=n.sceneNodes??[],k=n.sceneEdges??[],A=n.labels??[],S=n.backgrounds??null,M=n.overlays??null}else if(m){m.computeLayout(b,x,v,[h,f]);let e=m.buildScene(b,x,v,[h,f]);w=e.sceneNodes,k=e.sceneEdges,A=e.labels}let _=Ze(i);for(let e of A)e.fill||(e.fill=_.text);let $,P=kl({nodes:k,renderMode:e.renderMode,fallback:(e,t)=>function(e,t){return bl(function(e,t){switch(e.type){case"line":return Pw("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":{let i=e,r=`net-bezier-${t}-hatch`,o=rr(i.style.fill)?nr(i.style.fill,r):void 0;return Rw(_w.Fragment,{children:[o&&Pw("defs",{children:o}),Pw("path",{d:i.pathD,fill:o?`url(#${r})`:dl(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-edge-"+t)}case"ribbon":{let i=e,r=`net-ribbon-${t}-hatch`,o=rr(i.style.fill)?nr(i.style.fill,r):void 0;return Rw(_w.Fragment,{children:[o&&Pw("defs",{children:o}),Pw("path",{d:i.pathD,fill:o?`url(#${r})`:dl(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-edge-"+t)}case"curved":{let i=e;return Pw("path",{d:i.pathD,fill:dl(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth??1,opacity:i.style.opacity},"net-edge-"+t)}default:return null}}(e,t),e,"network-edge-cursor-"+t)}(e,t)}),R=kl({nodes:w,renderMode:e.renderMode,fallback:(e,t)=>function(e,t){return bl(function(e,t){switch(e.type){case"circle":{let i=e,r=rr(i.style.fill)?nr(i.style.fill,`net-circle-${t}-hatch`):void 0;return Rw(_w.Fragment,{children:[r&&Pw("defs",{children:r}),Pw("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:r?`url(#net-circle-${t}-hatch)`:dl(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity})]},"net-circle-"+t)}case"rect":{let i=e,r=rr(i.style.fill)?nr(i.style.fill,`net-rect-${t}-hatch`):void 0;return Rw(_w.Fragment,{children:[r&&Pw("defs",{children:r}),Pw("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:r?`url(#net-rect-${t}-hatch)`:dl(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity})]},"net-rect-"+t)}case"arc":{let i=e,r=$w().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(Ob)||"",o=rr(i.style.fill)?nr(i.style.fill,`net-arc-${t}-hatch`):void 0;return Rw(_w.Fragment,{children:[o&&Pw("defs",{children:o}),Pw("path",{d:r,transform:`translate(${i.cx},${i.cy})`,fill:o?`url(#net-arc-${t}-hatch)`:dl(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity})]},"net-arc-"+t)}case"symbol":{let i=e,r=Ds(i.symbolType,i.size,i.path);return Pw("path",{d:r,transform:i.rotation?`translate(${i.cx},${i.cy}) rotate(${180*i.rotation/Math.PI})`:`translate(${i.cx},${i.cy})`,fill:i.style.fill?dl(i.style.fill):"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity},"net-symbol-"+t)}case"glyph":return fl(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t),e,"network-node-cursor-"+t)}(e,t)}),I=P.map(e=>e.element),L=R.map(e=>e.element),T=A.map((e,t)=>function(e,t){return Pw("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),C=e=>Number(e),O=e.annotations?wc({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{x:C,y:C},layout:{width:h,height:f},theme:i,frameType:"network",annotationData:Fd(w),pointNodes:Cd(w),idPrefix:e._idPrefix,onRender:e=>{$=e}}):null;return t&&(t.evidence=ul({frameType:"network",width:o[0],height:o[1],marks:[...R.map(({node:e})=>({type:"node:"+(e.type??"node")})),...P.map(({node:e})=>({type:"edge:"+(e.type??"edge")}))],title:e.title,description:e.description,annotations:e.annotations,annotationRender:$,nodeCount:R.length,edgeCount:P.length,margin:l})),Nv.renderToStaticMarkup(Gc(Lw(Iw,{children:[p,S,I,L,T,O,y,M]}),{width:o[0],height:o[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${l.left},${l.top})`,innerWidth:h,innerHeight:f,legend:d,idPrefix:e._idPrefix}))}function zd(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function Nd(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function Ed(e,t,i){return e?"function"==typeof e?{...i,...e(t)}:{...i,...e}:{...i}}function Bd(e,t){if(2>e.length)return[e];let i=.4*t,r=[],o=[e[0]];for(let t=1;e.length>t;t++){let n=e[t];Math.abs(n[0]-e[t-1][0])>i?(o.length>=2&&r.push(o),o=[n]):o.push(n)}return o.length>=2&&r.push(o),r}function Wd(e,t,i=24){let r=t[0]-e[0],o=t[1]-e[1],n=Math.sqrt(r*r+o*o);if(0===n)return[e,t];let a=-o/n,s=r/n,l=Math.min(.3*n,80),c=(e[0]+t[0])/2+a*l,u=(e[1]+t[1])/2+s*l,d=[];for(let r=0;i>=r;r++){let o=r/i,n=1-o;d.push([n*n*e[0]+2*n*o*c+o*o*t[0],n*n*e[1]+2*n*o*u+o*o*t[1]])}return d}function jd(e,t){if(2>e.length)return e;let i=t/2+1,r=[];for(let t=0;e.length>t;t++){let o,n,a=e[t];0===t?(o=e[1][0]-a[0],n=e[1][1]-a[1]):t===e.length-1?(o=a[0]-e[t-1][0],n=a[1]-e[t-1][1]):(o=e[t+1][0]-e[t-1][0],n=e[t+1][1]-e[t-1][1]);let s=Math.sqrt(o*o+n*n)||1;r.push([a[0]+n/s*i,a[1]+-o/s*i])}return r}function Yd(e,t,i,r,o){let n=t[0]-e[0],a=t[1]-e[1],s=Math.sqrt(n*n+a*a);if(0===s)return[e,t];let l=a/s,c=-n/s,u=o/2+1;return[[e[0]+l*u,e[1]+c*u],[t[0]+l*u,t[1]+c*u]]}function Xd(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+""}.`)}function qd(e){if(!e)return;let t=[];for(let i of e)if("point"===i.type)t.push(i);else if("glyph"===i.type){let e=i,r=Xs(e.glyph,e.size);t.push({pointId:e.pointId,x:e.x+r.centerDx,y:e.y+r.centerDy,r:r.radius})}return t}function Gd({bottomMargin:e,costLabel:t,layout:{cx:i,cy:r,maxCost:o,availableRadius:n,layout:a},ringStyle:s,ringValues:l,showNorth:c,showRingLabels:u,showRings:d}){let h="strip"===a,f={stroke:h?"var(--semiotic-border, #999)":"#999",strokeWidth:h?1:.8,strokeDasharray:h?"none":"4,3",labelColor:"var(--semiotic-text-secondary, #777)",labelSize:h?8:10,...s};return dk("g",h?{children:[uk("line",{x1:i,y1:r,x2:i+n,y2:r,stroke:f.stroke,strokeWidth:f.strokeWidth,strokeLinecap:"round",opacity:.85}),uk("line",{x1:i,y1:r-3.5,x2:i,y2:r+3.5,stroke:f.stroke,strokeWidth:f.strokeWidth,opacity:.9}),d&&l.map(a=>{let s=i+(o>0?a/o*n:0);return dk("g",{children:[uk("line",{x1:s,y1:r-2.5,x2:s,y2:r+2.5,stroke:f.stroke,strokeWidth:.9,opacity:.65}),u&&dk("text",{x:s,y:r+Math.min(10,(e??2)+8),textAnchor:"middle",fontSize:f.labelSize,fill:f.labelColor,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:[a,t?" "+t:""]})]},a)})]}:{children:[l.map(e=>{let a=e/o*n;return dk("g",{children:[uk("circle",{cx:i,cy:r,r:a,fill:"none",stroke:f.stroke,strokeWidth:f.strokeWidth,strokeDasharray:f.strokeDasharray,opacity:.5}),u&&dk("text",{x:i+a+3,y:r-2,fontSize:f.labelSize,fill:f.labelColor,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:[e,t?" "+t:""]})]},e)}),c&&dk("g",{transform:"translate(24, 24)",children:[uk("circle",{r:16,fill:"white",fillOpacity:.85,stroke:"#bbb",strokeWidth:.8}),uk("path",{d:"M0,-11 L3,-3 L1,-4 L1,7 L-1,7 L-1,-4 L-3,-3 Z",fill:"#555",stroke:"none"}),uk("text",{y:-12,textAnchor:"middle",fontSize:7,fontWeight:700,fill:"#555",fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:"N"}),uk("line",{x1:11,y1:0,x2:13,y2:0,stroke:"#bbb",strokeWidth:.8}),uk("line",{x1:-11,y1:0,x2:-13,y2:0,stroke:"#bbb",strokeWidth:.8}),uk("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})]})]})}function Vd(e,t){let i=Ke(e.theme),r=e.size||[e.width||600,e.height||400],o=s({top:10,right:10,bottom:10,left:10,...e.margin},e.title),a=n(e.title),l=Array.isArray(e.areas)?me(e.areas):e.areas,c=me(e.points),u=me(e.lines),d=e.showLegend?(()=>{let t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;return Ll(c.length>0?c:Array.isArray(l)&&l.length>0?"string"==typeof t?l.map(e=>({...e.properties||{},...e})):l:[],t)})():[];Xc(o,{props:e,categories:d,theme:i,size:r,hasTitle:a});let h=qc({props:e,categories:d,theme:i,size:r,margin:o,hasTitle:a}),f=r[0]-(o.left??0)-(o.right??0),p=r[1]-(o.top??0)-(o.bottom??0),y={projection:e.projection||"equalEarth",projectionExtent:e.projectionExtent,xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineIdAccessor:e.lineIdAccessor,lineType:e.lineType,flowStyle:e.flowStyle,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,colorScheme:e.colorScheme,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform,customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:o,onLayoutError:e.onLayoutError,themeCategorical:i.colors.categorical,themeSemantic:Ue(i),themeSequential:i.colors.sequential,themeDiverging:i.colors.diverging},g=new ak(y);if(l){if("string"==typeof l)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${l}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${l}')\` before calling renderGeoToStaticSVG.`);g.setAreas(l)}e.points&&g.setPoints(c),e.lines&&g.setLines(u),g.computeScene({width:f,height:p});let m=Vc(e.backgroundGraphics,r,o,g.scales),b=Vc(e.foregroundGraphics,r,o,g.scales),x=kl({nodes:g.scene,renderMode:e.renderMode,fallback:(e,t)=>function(e,t){return bl(function(e,t){switch(e.type){case"geoarea":{let i=e;if(!i.pathData)return null;let r=rr(i.style.fill)?nr(i.style.fill,`geoarea-${t}-hatch`):void 0;return ck(sk.Fragment,{children:[r&&lk("defs",{children:r}),lk("path",{d:i.pathData,fill:r?`url(#geoarea-${t}-hatch)`:dl(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-"+t)}case"point":{let i=e,r=rr(i.style.fill)?nr(i.style.fill,`geopoint-${t}-hatch`):void 0;return ck(sk.Fragment,{children:[r&&lk("defs",{children:r}),lk("circle",{cx:i.x,cy:i.y,r:i.r,fill:r?`url(#geopoint-${t}-hatch)`:dl(i.style.fill),fillOpacity:i.style.fillOpacity??.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i._decayOpacity??i.style.opacity??1})]},"point-"+t)}case"line":{let i=e;if(2>i.path.length)return null;let r="M"+i.path.map(e=>`${e[0]},${e[1]}`).join("L");return lk("path",{d:r,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth??1.5,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity??1},"line-"+t)}case"glyph":return fl(e,e.x,e.y,"geo-glyph-"+(e.pointId??t));default:return null}}(e,t),e,"geo-cursor-"+t)}(e,t)});if(0===x.length){let n,a=e.annotations?wc({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{geoProjection:g.scales?.projectedPoint?([e,t])=>g.scales.projectedPoint(e,t):void 0},layout:{width:f,height:p},theme:i,pointNodes:qd(g.scene),idPrefix:e._idPrefix,onRender:e=>{n=e}}):null;return t&&(t.evidence=ul({frameType:"geo",width:r[0],height:r[1],marks:x.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:n,legendItems:d.length>0?d.length:null!=e.legend?1:void 0,margin:o})),Cw.renderToStaticMarkup(Gc(m||b||e.annotations||g.customLayoutOverlays?pk(hk,{children:[m,a,b,g.customLayoutOverlays]}):null,{width:r[0],height:r[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${o.left??0},${o.top??0})`,innerWidth:f,innerHeight:p,legend:h,idPrefix:e._idPrefix}))}let v,w=x.map(e=>e.element),k=e.cartogramChrome,A=g.cartogramLayout&&k?fk(Gd,{layout:{...g.cartogramLayout,layout:g.cartogramLayout.layout??"radial"},ringValues:Hd(g.cartogramLayout.maxCost,k.showRings),showRings:k.showRings??!0,showNorth:k.showNorth??!0,showRingLabels:k.showRingLabels??!0,costLabel:"string"==typeof k.costLabel?k.costLabel:void 0}):null,S=e.annotations?wc({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{geoProjection:g.scales?.projectedPoint?([e,t])=>g.scales.projectedPoint(e,t):void 0},layout:{width:f,height:p},theme:i,pointNodes:qd(g.scene),idPrefix:e._idPrefix,onRender:e=>{v=e}}):null;return t&&(t.evidence=ul({frameType:"geo",width:r[0],height:r[1],marks:x.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:v,legendItems:d.length>0?d.length:null!=e.legend?1:void 0,margin:o})),Cw.renderToStaticMarkup(Gc(pk(hk,{children:[m,w,S,A,b,g.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:i,innerTransform:`translate(${o.left??0},${o.top??0})`,innerWidth:f,innerHeight:p,legend:h,idPrefix:e._idPrefix}))}function Hd(e,t){if(!1===t||0>=e)return[];if(Array.isArray(t))return t.filter(t=>t>0&&e>=t);let i="number"==typeof t?t:Math.min(5,Math.max(2,Math.ceil(e/5))),r=e/i,o=[];for(let e=1;i>=e;e++)o.push(Math.round(r*e*10)/10);return o}function Ud(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}:{}}))}function Kd(e){let t=e.datum;if(t&&"object"==typeof t){let e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e.id}function Zd(e,t,i){let r="function"==typeof t?t(e,i):t;return{...gk,...r??{}}}function Qd(e,t={},i="settled"){return e.map((e,r)=>function(e,t={},i={index:0,simulationState:"settled"}){let r=function(e){return e.datum&&"object"==typeof e.datum?e.datum:null}(e),o={label:t.getBodyLabel?.(e)??Kd(e)},n={style:Zd(e,t.bodyStyle,i),datum:r,accessibleDatum:r,accessibility:o,_transitionKey:e.id};return"aabb"===e.shape.type?{type:"rect",x:e.x-e.shape.width/2,y:e.y-e.shape.height/2,w:e.shape.width,h:e.shape.height,...n}:{type:"point",x:e.x,y:e.y,r:e.shape.radius,pointId:e.id,...n}}(e,t,{index:r,simulationState:i}))}function Jd(e,t,i){return"function"==typeof e?e({size:t,margin:i}):e}function eh(e,t={}){let{element:i,scene:r,evidence:o}=function(e,t={}){let{width:i=640,height:r=360,title:o,description:n,background:a,backgroundGraphics:s,backgroundGraphicsBackdrop:l,className:c,foregroundGraphics:u,idPrefix:d="physics",margin:h,style:f,renderBodySVG:p,renderChrome:y,...g}=t,m=function(e,t={}){let i=e.settle(t.maxSteps),r=e.readBodies(),o=e.snapshot(),n=Qd(r,t,o.simulationState),a=function(e,t={}){let i=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=i.filter(e=>e.sleeping).length,o=e.queue.length,n=e.sediment.reduce((e,t)=>e+t.count,0),a="settled"===e.simulationState&&0===o&&r===i.length,s=[];a||s.push("PHYSICS_NOT_SETTLED"),o>0&&s.push("PHYSICS_QUEUE_UNDRAINED");let l=null!=t.charge&&Number.isFinite(t.charge)?function(e,t,i,r){let o=e-(t+i+r);return{charge:e,live:t,queued:i,sedimented:r,unaccounted:o,balanced:0===o}}(t.charge,i.length,o,n):void 0;return l&&!l.balanced&&s.push("PHYSICS_LEDGER_MISMATCH"),{bodyCount:i.length,sleepingCount:r,settled:a,stepsRun:Math.max(0,Math.floor(t.stepsRun??0)),seed:e.world.options.seed,binCounts:Ud(t.projectionRows),queuedCount:o,sedimentedCount:n,...l?{ledger:l}:{},warnings:s}}(o,{bodies:r,projectionRows:t.projectionRows,stepsRun:i,charge:t.charge});return{snapshot:o,bodies:r,sceneNodes:n,evidence:a,stepsRun:i}}(e,g),b={...xk,...h},x=[i,r],v=Jd(s,x,b),w=Jd(u,x,b),k=function(e){let t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"physics-"+t:t}(d),A=o?k+"-title":void 0,S=n?k+"-desc":void 0,M=[A,S].filter(Boolean).join(" ")||void 0,_=b.left||b.top?`translate(${b.left},${b.top})`:void 0,$=Math.max(1,i-b.left-b.right),P=Math.max(1,r-b.top-b.bottom),R=k+"-plot-clip",I=_&&null!=v?mk("g",{transform:_,children:v}):v;return{element:bk("svg",{xmlns:"http://www.w3.org/2000/svg",className:c??"stream-physics-frame",width:i,height:r,viewBox:`0 0 ${i} ${r}`,role:"img","aria-labelledby":M,style:f,children:[o&&mk("title",{id:A,children:o}),n&&mk("desc",{id:S,children:n}),mk("defs",{children:mk("clipPath",{id:R,children:mk("rect",{width:$,height:P})})}),l&&"transparent"!==l?mk("rect",{className:"stream-frame-background__backdrop",x:0,y:0,width:i,height:r,fill:l}):null,!s&&a&&"transparent"!==a?mk("rect",{x:0,y:0,width:i,height:r,fill:a}):null,I,mk("g",{id:k+"-data-area",transform:_,clipPath:`url(#${R})`,children:m.sceneNodes.map((e,t)=>{let i=m.bodies[t],r=i&&p?p(i,e.style??{},t,k):void 0;return null!=r?bl(r,e,t):bl("point"===e.type||"rect"===e.type?gl(e,t,k):null,e,"xy-cursor-"+t)})}),w,y?.(m)]}),scene:m,evidence:m.evidence}}(e,t);return{svg:yk.renderToStaticMarkup(i),scene:r,evidence:o}}function th(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function ih(e,t){let i="sensor"===e.physics?t.sensorThickness:t.barrierThickness;return Math.max(0,th(e.thickness)??th(i)??th(t.thickness)??4)}function rh(e){return e.sensorId??"stream-region-"+e.id}function oh(e){let t=rh(e),i={bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution};if("boundary"===e.collider&&"aabb"===e.shape.type){let r=e.colliderThickness??8,o=e.shape.x-e.shape.width/2,n=e.shape.x+e.shape.width/2,a=e.shape.y-e.shape.height/2,s=e.shape.y+e.shape.height/2;return[{...i,id:t+"-top",shape:{type:"segment",x1:o,y1:a,x2:n,y2:a,thickness:r}},{...i,id:t+"-right",shape:{type:"segment",x1:n,y1:a,x2:n,y2:s,thickness:r}},{...i,id:t+"-bottom",shape:{type:"segment",x1:n,y1:s,x2:o,y2:s,thickness:r}},{...i,id:t+"-left",shape:{type:"segment",x1:o,y1:s,x2:o,y2:a,thickness:r}}]}return e.collider?[{...i,id:t+"-collider",shape:e.shape}]:[]}function nh({title:e,totalWidth:t,marginTop:i}){return e?"string"!=typeof e?vk("foreignObject",{x:0,y:0,width:t,height:i,children:e}):vk("text",{x:t/2,y:22,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",fontSize:14,className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)",fontFamily:"var(--semiotic-title-font-family, var(--semiotic-font-family, sans-serif))",fontWeight:"var(--semiotic-title-font-weight, bold)"},children:e}):null}function ah(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function sh(e,t){let i=e.size??[e.width??600,e.height??400],r=Ke(e.theme),o=void 0===e.theme?{}:mt(r),n=e.bodyStyle,s=!1,c=e.legendPosition??"right",u=a({...Sk,...e.margin},s,!!e.legend&&"top"===c);if(e.legend){let t={...u};b(u,{legend:e.legend,position:c,size:i,hasTitle:s,legendLayout:e.legendLayout}),l(u,t,i,c)}let d,h=function({annotations:e,chartId:t,chartType:i,config:r,onRegionObservation:o,regionEffects:n,seed:a,size:s}){let l=function(e=[],t={}){let i=t.idPrefix?t.idPrefix+"-":"",r=[];for(let o of e){if("barrier"!==o.physics&&"sensor"!==o.physics)continue;let e,n=o.axis??t.defaultAxis??"x",a=ih(o,t),s=o.colliderId??`${i}${o.id}`;if("x"===n){let i=th(o.x),r=th(o.y1)??th(t.plotBounds?.y)??th(o.y),n=th(o.y2)??(t.plotBounds?t.plotBounds.y+t.plotBounds.height:void 0)??th(o.y);if(null==i||null==r||null==n)continue;e={type:"segment",x1:i,y1:r,x2:i,y2:n,thickness:a}}else{let i=th(o.y),r=th(o.x1)??th(t.plotBounds?.x)??th(o.x),n=th(o.x2)??(t.plotBounds?t.plotBounds.x+t.plotBounds.width:void 0)??th(o.x);if(null==i||null==r||null==n)continue;e={type:"segment",x1:r,y1:i,x2:n,y2:i,thickness:a}}r.push({id:s,shape:e,sensor:"sensor"===o.physics,..."barrier"!==o.physics||null==o.restitution&&null==t.barrierRestitution?{}:{restitution:th(o.restitution)??th(t.barrierRestitution)},..."barrier"!==o.physics||null==o.friction&&null==t.barrierFriction?{}:{friction:th(o.friction)??th(t.barrierFriction)}})}return r}((e??[]).filter(e=>"barrier"===e.physics||"sensor"===e.physics),{idPrefix:t?t+"-ann":"physics-ann",plotBounds:{x:0,y:0,width:s[0],height:s[1]}}),c=void 0===a||void 0!==r?.kernel?.seed?r:{...r,kernel:{...r?.kernel,seed:a}},u=n.flatMap(e=>[{id:rh(e),sensor:!0,shape:e.shape,bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution},...oh(e)]),d=Object.fromEntries(n.map(e=>[rh(e),{binId:e.binId??e.id,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),h=c?.observation,f=n.length>0;return f||u.length>0||l.length>0||null!=t||h?{...c,colliders:[...c?.colliders??[],...u,...l],observation:{...h,chartId:t??h?.chartId,chartType:h?.chartType??i,sensors:{...h?.sensors??{},...d},onObservation:e=>{f&&o(e),h?.onObservation?.(e)}}}:c}({annotations:e.annotations,chartId:e.chartId,chartType:"StreamPhysicsFrame",config:e.config,onRegionObservation:()=>{},regionEffects:e.regionEffects??[],seed:e.seed,size:[Math.max(1,i[0]-u.left-u.right),Math.max(1,i[1]-u.top-u.bottom)]}),f=new lg(h);Array.isArray(e.initialSpawns)&&e.initialSpawns.length>0&&f.enqueue(e.initialSpawns.map(e=>({...e,spawnAt:void 0})));let p=eh(f,{...e,width:i[0],height:i[1],background:e.background??r.colors.background,bodyStyle:(e,t)=>({fill:r.colors.primary,stroke:r.colors.text,strokeWidth:1,opacity:.9,..."function"==typeof n?n(e,t):n}),style:{...o,fontFamily:r.typography.fontFamily,...e.style},charge:e.charge,idPrefix:e.idPrefix??e._idPrefix??"physics",margin:u,renderChrome:t=>{let o=function(e,t,i,r,o){let n=Math.max(1,i[0]-r.left-r.right),a=Math.max(1,i[1]-r.top-r.bottom),s=function(e){return e?.length?e.map(e=>null!=e.pointId||null==e.bodyId?e:{...e,pointId:e.bodyId+""}):e}(t.annotations),l=function(e){let{width:t,height:i,pointNodes:r=[],data:o}=e;return{scales:{x:wk().domain([0,Math.max(1,t)]).range([0,Math.max(1,t)]),y:wk().domain([0,Math.max(1,i)]).range([0,Math.max(1,i)])},width:t,height:i,frameType:"network",pointNodes:r,data:o,xAccessor:"x",yAccessor:"y"}}({width:n,height:a,pointNodes:(d=e.bodies,d.map(e=>({pointId:e.id,x:e.x,y:e.y,r:Math.max(1,ah(e))})))}),c=l.scales?.x,u=l.scales?.y;var d;if(!c||!u)throw Error("Physics annotation context requires pixel scales");let h,f=wc({annotations:s,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{x:c,y:u},layout:{width:n,height:a},theme:o,frameType:"network",xAccessor:l.xAccessor,yAccessor:l.yAccessor,pointNodes:l.pointNodes,svgAnnotationRules:t.svgAnnotationRules,onRender:e=>{h=e}}),p=t.legend?Yc(t.legend,{theme:o,position:t.legendPosition,size:[i[0],i[1]],margin:r,hasTitle:!!t.title,legendLayout:t.legendLayout})??kc(t.legend,i,r,t.legendPosition,t.legendLayout):null;return{annotationRender:h,node:Ak("svg",{className:"stream-physics-frame__overlay","data-testid":"stream-physics-overlay",role:"presentation",width:i[0],height:i[1],style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[kk("g",{transform:`translate(${r.left},${r.top})`,children:f}),kk(nh,{title:t.title,totalWidth:i[0],marginTop:Math.max(r.top,28)}),p]})}}(t,e,i,u,r);return d=o.annotationRender,o.node}});return t&&(t.evidence=ul({frameType:"physics",width:i[0],height:i[1],marks:p.scene.sceneNodes,title:e.title,description:e.description,annotations:e.annotations,annotationRender:d,extraWarnings:[...0===p.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[],...p.scene.evidence.warnings]})),p.svg}function lh(e,t){return"number"==typeof e&&Number.isFinite(e)&&e>0?e:t}function ch(e,t,i){return Rk[e](t,i)}function uh(e,t){switch(e){case"xy":return Hc(t);case"ordinal":return Pu(t);case"network":return Dd(t);case"geo":return Vd(t);case"physics":return sh(t);default:throw Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function dh(e){return Hc(e)}function hh(e){return Pu(e)}function fh(e){return Dd(e)}function ph(e){return Vd(e)}function yh(e,t){let i=Number(e);if(!Number.isFinite(i))return e;let r=10**t,o=Math.round((i+Number.EPSILON)*r)/r;return Object.is(o,-0)?"0":o+""}function gh(e,t){let i=function(e){if(Number.isFinite(e))return Math.max(0,Math.min(8,Math.floor(e)))}(t);return void 0===i?e:function(e){let t=A(e)?.start??0;return e.slice(0,t)+e.slice(t).replace(/<!--[\s\S]*?(?:-->|$)|<!\[CDATA\[[\s\S]*?(?:\]\]>|$)|<\?[\s\S]*?(?:\?>|$)|<([A-Za-z_][\w.:-]*)(?=[\s/>])(?:[^<>"']|"[^"]*"|'[^']*')*>/g,(e,t)=>t?e.replace(Ch,(e,t,r,o)=>{let n=((e,t)=>{if(Fk.has(e)&&!/\b(?:var|calc|url)\(/i.test(t))return function(e,t){let i,r=RegExp(Dk.source,Dk.flags),o="",n=0,a=!1;for(;i=r.exec(e);){let r=e.slice(n,i.index);o+=a&&0===r.length?" ":r,o+=yh(i[0],t),n=i.index+i[0].length,a=!0}return o+e.slice(n)}(t,i)})(t,M(r??o));return void 0===n?e:` ${t}="${S(n)}"`}):e)}(e)}function mh(e,t){let i={};for(let r of t)void 0!==e[r]&&(i[r]=e[r]);return i}function bh(e,t,i){return vh(e,t,i).svg}function xh(e,t,i){let r={},{svg:o,frameType:n}=vh(e,t,i,r),a=r.evidence??ul({frameType:n,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"]});if(a.component=e,a.sceneHashVersion=2,a.sceneHash=function(e,t){return I(R({kind:"semiotic.rendered-svg-scene",version:2,svg:e,frameType:t.frameType,width:t.width,height:t.height,margin:t.margin,plot:t.plot,xDomain:t.xDomain,yDomain:t.yDomain,categories:t.categories}))}(o,a),ye(a,e,t),i?.artifactContract){let r=function(e,t={}){try{return function(e,t){if(!le(e))return{transfer:{status:"invalid",omittedPaths:["artifactContract"],warnings:["Artifact contract must be a JSON object."]}};let i=z(e),r=[...new Set([...i.excludedPaths,...X(e)])].sort(),o=i.value,n=function(e,t){if(!t||!le(e)||!Array.isArray(e.evidence))return[];let i=[];return e.evidence.forEach((e,t)=>{le(e)&&Object.prototype.hasOwnProperty.call(e,"sample")&&(delete e.sample,i.push(`$.evidence[${t}].sample`))}),i}(o,t.excludeEvidenceSamples),a=n.length?["Bounded evidence samples were excluded by the transfer policy."]:[],s=o?.contractVersion;if("string"!=typeof s||!s)return{contract:o,transfer:{status:"invalid",omittedPaths:[...r,...n],warnings:["Artifact contract is missing a string contractVersion.",...a]}};if("0.1"!==s)return{contract:o,transfer:{status:r.length>0?"invalid":"unsupported-version",omittedPaths:[...r,...n],warnings:[`Contract version ${s} is not interpreted by this runtime.`,...r.length>0?[`Non-JSON values could not be preserved at: ${r.join(", ")}.`]:[],...a]}};let l=se(o),c=[...l.errors.map(({path:e,message:t})=>`${e}: ${t}`),...l.warnings.map(({path:e,message:t})=>`${e}: ${t}`),...r.length?[`Non-JSON values could not be preserved at: ${r.join(", ")}.`]:[],...a];return{contract:o,transfer:{status:!l.valid||r.length>0?"invalid":n.length>0?"excluded":"preserved",omittedPaths:[...r,...n],warnings:c}}}(e,t)}catch{let t=X(e);return{transfer:{status:"invalid",omittedPaths:t.length?t:["$"],warnings:["Artifact contract could not be inspected safely."]}}}}(i.artifactContract,{excludeEvidenceSamples:!0});r.contract&&(a.artifactContract=r.contract),a.artifactTransfer=r.transfer,a.artifactBinding="0.1"===r.contract?.contractVersion&&"invalid"!==r.transfer.status?function(e,t,i,r=function(e){let t=Object.entries(e).filter(([e,t])=>Xh.includes(e)&&void 0!==t);if(0!==t.length)return 1===t.length&&"data"===t[0][0]?t[0][1]:Object.fromEntries(t)}(t)){let o=function(e){return Object.fromEntries(Object.entries(e).filter(([e])=>!Xh.includes(e)&&"recipeId"!==e))}(t),n=0===X(o).length?N(o).fingerprint:void 0,a=void 0!==r&&0===X(r).length?function(e,t=[]){if(void 0===e)return;let i=t.filter(e=>!!e.transformation).map(({id:e,transformation:t})=>({evidenceId:e,transformation:t})).sort(({evidenceId:e},{evidenceId:t})=>t>e?-1:e>t?1:0);return N(i.length>0?{data:e,transformations:i}:e).fingerprint}(r,e.evidence):void 0,s="ChartRecipe"===i&&"string"==typeof t.recipeId?t.recipeId:i,l=[],c=[];return void 0!==s&&(void 0===e.artifact.component?c.push("artifact.component"):e.artifact.component!==s&&l.push("artifact.component")),void 0===e.artifact.configFingerprint||void 0===n?c.push("artifact.configFingerprint"):e.artifact.configFingerprint!==n&&l.push("artifact.configFingerprint"),void 0!==e.artifact.dataFingerprint&&a?e.artifact.dataFingerprint!==a&&l.push("artifact.dataFingerprint"):c.push("artifact.dataFingerprint"),{status:l.length>0?"mismatch":c.length>0?"unknown":"match",mismatchPaths:l,unknownPaths:c}}(r.contract,t,e):{status:"unknown",mismatchPaths:[],unknownPaths:["artifactContract"]}}return{svg:o,evidence:a}}function vh(e,t,i,r){if(Object.prototype.hasOwnProperty.call(Rk,e))return{svg:gh(ch(e,t,r),i?.precision),frameType:"value"};if(!Object.prototype.hasOwnProperty.call(ev,e))throw Error(`Unknown chart component: "${e}". Run \`npx semiotic-ai --list\` for supported chart types.`);let o,n=ev[e],a=function(e,t,i){let r=Gh[e||"primary"],o=e&&"primary"!==e||!i?.width?r.width:i.width,n=e&&"primary"!==e||!i?.height?r.height:i.height,a=function(e,t,i=e.responsiveRules){if(!Array.isArray(i)||0===i.length)return{props:e,matches:[]};let r=i.map((e,t)=>({rule:e,index:t})).filter(e=>function(e,t){let{when:i}=e,r=t.width,o=t.height,n=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),a=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof i.minWidth&&i.minWidth>r||"number"==typeof i.maxWidth&&r>i.maxWidth||"number"==typeof i.minHeight&&("number"!=typeof o||i.minHeight>o)||"number"==typeof i.maxHeight&&("number"!=typeof o||o>i.maxHeight)||"number"==typeof i.minAspectRatio&&("number"!=typeof n||i.minAspectRatio>n)||"number"==typeof i.maxAspectRatio&&("number"!=typeof n||n>i.maxAspectRatio)||i.orientation&&a!==i.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){let i={...e,...t};for(let r of["margin","frameProps","mobileSemantics","style"])ce(e[r])&&ce(t[r])&&(i[r]={...e[r],...t[r]});return"string"==typeof e.className&&"string"==typeof t.className&&(i.className=`${e.className} ${t.className}`),i}(e,t.rule.transform),e),matches:r}}({...t,mode:e},{width:t.width??o,height:t.height??n}).props,s=a.mode||e||"primary",l=Gh[s],c="context"===s||"sparkline"===s,u="primary"===s&&i?.width?i.width:l.width;return{mode:s,width:a.width??u,height:a.height??("primary"===s&&i?.height?i.height:l.height),showAxes:a.showAxes??l.showAxes,showGrid:a.showGrid??l.showGrid,enableHover:a.enableHover??(!!a.linkedHover||l.enableHover),showLegend:a.showLegend??l.showLegend,showLabels:a.showLabels??l.showLabels,title:c?void 0:a.title,description:a.description,summary:a.summary,accessibleTable:a.accessibleTable,xLabel:c?void 0:a.xLabel,yLabel:c?void 0:a.yLabel,categoryLabel:c?void 0:a.categoryLabel,valueLabel:c?void 0:a.valueLabel,marginDefaults:de(l.marginDefaults,a.showCategoryTicks,a.orientation),compactMode:c,mobileInteraction:ue(a.mobileInteraction,{mode:s,width:a.width??u,mobileSemantics:a.mobileSemantics}),mobileSemantics:a.mobileSemantics}}(n.layout?.mode??("string"==typeof(T=t.mode)&&Object.prototype.hasOwnProperty.call(Gh,T)?t.mode:void 0),{...n.layout?.modeDefaults,...mh(t,Nk)},n.layout?.primarySize),{data:s,theme:l,background:c,className:u,annotations:d,margin:h,colorScheme:f,colorBy:p,legendPosition:y,...g}=t,{width:m,height:b}=a,x=[m,b],v=g.frameProps||{},w=n.layout?.margin,A="function"==typeof w?w(t,a):w??a.marginDefaults,S="xy"===n.frameType?k(A,g.axes??v.axes,!!a.title):A,M=void 0!==h?h:v.margin,_=function(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};let 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}(M),$="number"==typeof M?{top:M,right:M,bottom:M,left:M}:{...S,..._},P=mh(g,zk),R=e=>v[e]??a[e],I={...v,...P,theme:l,title:a.title,description:a.description,showAxes:R("showAxes"),showLegend:R("showLegend"),showLabels:R("showLabels"),showGrid:R("showGrid"),xLabel:R("xLabel"),yLabel:R("yLabel"),categoryLabel:R("categoryLabel"),valueLabel:R("valueLabel"),background:c,className:u,annotations:d,size:x,margin:$,__compactMode:a.compactMode,__autoLegendMargin:!0,...void 0!==f&&{colorScheme:f},...void 0!==y&&{legendPosition:y},_idPrefix:g._idPrefix},L=n.buildProps(s,p,f,I,g);var T;if(n.renderStatic)o=n.renderStatic(L,r);else switch(n.frameType){case"xy":o=Hc(L,r);break;case"ordinal":o=Pu(L,r);break;case"network":o=Dd(L,r);break;case"geo":o=Vd(L,r);break;case"physics":o=sh(L,r)}let C=n.renderOverlay?.(L,{theme:Ke(l)});if(null!=C){let e=Zh.renderToStaticMarkup(Ok(Ck,{children:C})),t=o.lastIndexOf("</svg>");o=0>t?`${o}${e}`:`${o.slice(0,t)}${e}${o.slice(t)}`}return{svg:gh(o,i?.precision),frameType:n.frameType}}function wh(e,t={}){return function(e,t,i){let{title:r,subtitle:o,theme:n,width:a=1200,height:s,layout:l={},background:c}=t,u=Ze(Ke(n)),d=l.columns||2,h=l.gap??16,f=0;r&&(f+=30),o&&(f+=20),f>0&&(f+=10);let p=Math.floor((a-h-h*(d-1))/d),y=[],g=0,m=f+h,b=0;for(let t of e){let e=Math.min(t.colSpan||1,d),r=p*e+h*(e-1),o=t.props.height||300;g+e>d&&(m+=b+h,g=0,b=0);let a=h/2+g*(p+h),s={...t.props,width:r,height:o,theme:n,_idPrefix:"chart-"+y.length},l=t.component?i.chart(t.component,s):t.frameType?i.frame(t.frameType,s):`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${o}"></svg>`,c=$(l,{width:r,height:o}),u=Math.max(o,c.height);y.push({x:a,y:m,width:r,height:u,svg:l,svgDimensions:c}),b=Math.max(b,u),g+=e}let x=s||m+b+h,v=y.map((e,t)=>Lk("g",{transform:`translate(${e.x},${e.y})`,children:Lk("foreignObject",{width:e.width,height:e.height,children:Lk("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:P(e.svg,e.svgDimensions)}})})},"dashboard-chart-"+t));return Ik.renderToStaticMarkup(Tk("svg",{xmlns:"http://www.w3.org/2000/svg",width:a,height:x,role:"img","aria-label":r||"Dashboard",style:{fontFamily:u.fontFamily},children:[r&&Lk("title",{children:r}),c&&Lk("rect",{x:0,y:0,width:a,height:x,fill:c}),r&&Lk("text",{x:a/2,y:24,textAnchor:"middle",fontSize:u.titleFontSize+4,fontWeight:u.titleFontWeight,fill:u.text,fontFamily:u.titleFontFamily,children:r}),o&&Lk("text",{x:a/2,y:r?46:20,textAnchor:"middle",fontSize:u.labelSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:o}),v]}))}(e,t,{chart:bh,frame:uh})}function kh(e,t,i,r={}){let{stepSize:o,windowSize:n,frameCount:a,xExtent:l,yExtent:c,transitionFrames:u=4,fps:d=12,easing:h="ease-out",decay:f}=r,p=i.width||600,y=i.height||400,g=Ke(i.theme),m={...i,...l&&{xExtent:l},...c&&{yExtent:c}};if(!t||0===t.length)return[];let b=o||Math.max(1,Math.ceil(t.length/(a||Math.min(60,Math.max(10,t.length))))),x=[];for(let e=b;t.length>=e;e+=b)x.push(e);x[x.length-1]!==t.length&&x.push(t.length);let v=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(e),w=s({top:20,right:20,bottom:30,left:40,...i.margin},i.title),k=p-w.left-w.right,A=y-w.top-w.bottom,S=[];if(v)for(let r=0;x.length>r;r++){let o=x[r],a=t.slice(n?Math.max(0,o-n):0,o),s={chartType:e,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,connectorAccessor:i.connectorAccessor,connectorStyle:i.connectorStyle,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||g.colors.categorical,...f&&{decay:f}},l=new Sv(s);l.ingest({inserts:a,bounded:!0}),l.computeScene({width:k,height:A}),l.scene.length>0&&S.push(Ih(l.scene,p,y,g,m,S.length))}else for(let r=0;x.length>r;r++){let o=x[r],a=t.slice(n?Math.max(0,o-n):0,o),s={chartType:e,windowSize:a.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:l,yExtent:c,colorScheme:i.colorScheme||g.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange,...f&&{decay:f},...u>0&&{transition:{duration:u*(1e3/d),easing:h}}},b=new Bm(s);if(b.ingest({inserts:a,bounded:!0}),b.computeScene({width:k,height:A}),0===b.scene.length)continue;let v=b.scales?{y:b.scales.y}:void 0;if(S.push(Rh(b.scene,p,y,g,m,v,S.length)),u>0&&r>0&&b.activeTransition){let e=u*(1e3/d);for(let t=1;u>=t;t++)b.advanceTransition(b.activeTransition.startTime+t/u*e),S.push(Rh(b.scene,p,y,g,m,v,S.length))}}return S}function Ah(e,t,i={}){return t.map(t=>{try{return bh(e,{...i,...t})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${i.width||t.width||600}" height="${i.height||t.height||400}"></svg>`}})}function Sh(e,t,i,r){let o=Ac(`${e}-${t}`),n="string"==typeof i&&i.length>0?i:void 0,a="string"==typeof r&&r.length>0?r:void 0,s=n?o.titleId:void 0,l=a?o.descId:void 0;return{titleText:n,descText:a,titleId:s,descId:l,labelledBy:[s,l].filter(Boolean).join(" ")||void 0}}function Mh(e,t){return"string"==typeof e.idPrefix&&e.idPrefix.length>0?e.idPrefix:Bc(e)||t}function _h(e,t,i){let r=t.size??[t.width??600,t.height??400],o=Ke(t.theme),n=Ze(o),a=t.background||o.colors.background,s=t.idPrefix??"physics-gif",l=Sh(s,i,t.title,t.description),{titleId:c,descId:u,labelledBy:d}=l,h=Qd(e.readBodies(),{bodyStyle:t.bodyStyle,getBodyLabel:t.getBodyLabel}),f=jk("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":d,style:{fontFamily:n.fontFamily},children:[t.title&&Wk("title",{id:c,children:t.title}),t.description&&Wk("desc",{id:u,children:t.description}),a&&"transparent"!==a?Wk("rect",{x:0,y:0,width:r[0],height:r[1],fill:a}):null,Wk("g",{id:`${s}-frame-${i}`,children:h.map((e,t)=>vl(e,t,`${s}-${i}`))})]});return Ek.renderToStaticMarkup(f)}function $h(e,t={}){let{fps:i=12,frameCount:r,durationSeconds:o=2,includeInitialFrame:n=!0,stepDt:a,stepsPerFrame:s,background:l}=t,c=Math.max(.001,a??e.config?.fixedDt??1/120),u=s??Math.max(1,Math.round(1/Math.max(1,i)/c)),d=r??Math.max(1,Math.ceil(o*Math.max(1,i))),h=l?{...e,background:l}:e,f=new lg(e.config);e.initialSpawns?.length&&f.enqueue(e.initialSpawns,e.initialSpawnPacing);let p=[];for(n&&(f.tick(0),p.push(_h(f,h,0)));d>p.length;){for(let e=0;u>e;e+=1)f.tick(c);p.push(_h(f,h,p.length))}return p}function Ph(e,t){let i=e.background||t.colors.background;return i&&"transparent"!==i?i:null}function Rh(e,t,i,r,o,n,a=0){let l=Ze(r),c=s({top:20,right:20,bottom:30,left:40,...o.margin},o.title),u=t-c.left-c.right,d=i-c.top-c.bottom,h=Ph(o,r),f=o.renderMode,p=e.map((e,t)=>wl({node:e,index:t,renderMode:f,fallback:()=>vl(e,t)}).element).filter(Boolean),y=function(e,t,i,r,o,n){if(!e||0===e.length)return null;let a=Ze(r),s=[];for(let r=0;e.length>r;r++){let l=e[r];if("y-threshold"===l.type&&null!=l.value){let e=null;if(n)e=n(l.value);else if(o){let[t,r]=o,n=r-t;if(0===n)continue;e=i-(l.value-t)/n*i}if(null==e)continue;let c=l.color||a.primary,u=l.labelPosition||"right";s.push(jk("g",{children:[Wk("line",{x1:0,y1:e,x2:t,y2:e,stroke:c,strokeWidth:l.strokeWidth??1.5,strokeDasharray:l.strokeDasharray||"6,4"}),l.label&&Wk("text",{x:"left"===u?4:"center"===u?t/2:t-4,y:20>e?Math.min(i-4,e+16):e-5,textAnchor:"left"===u?"start":"center"===u?"middle":"end",fontSize:a.tickSize,fill:c,fontFamily:a.fontFamily,children:l.label})]},"ann-"+r))}}return s.length>0?Wk(Bk,{children:s}):null}(o.annotations,u,d,r,o.yExtent,n?.y),{titleText:g,descText:m,titleId:b,descId:x,labelledBy:v}=Sh(Mh(o,"xy-gif"),a,o.title,o.description);return Ek.renderToStaticMarkup(jk("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:i,role:"img","aria-labelledby":v,style:{fontFamily:l.fontFamily},children:[g&&Wk("title",{id:b,children:g}),m&&Wk("desc",{id:x,children:m}),h&&Wk("rect",{x:0,y:0,width:t,height:i,fill:h}),jk("g",{transform:`translate(${c.left},${c.top})`,children:[y,p]}),g&&Wk("text",{x:t/2,y:22,textAnchor:"middle",fontSize:l.titleFontSize,fontWeight:l.titleFontWeight,fill:l.text,fontFamily:l.titleFontFamily,children:g})]}))}function Ih(e,t,i,r,o,n=0){let a=Ze(r),l=s({top:20,right:20,bottom:30,left:40,...o.margin},o.title),c="radial"===o.projection,u=c?l.left+(t-l.left-l.right)/2:l.left,d=c?l.top+(i-l.top-l.bottom)/2:l.top,h=Ph(o,r),f=$u({nodes:e,renderMode:o.renderMode,idPrefix:o.idPrefix}).map(e=>e.element),{titleText:p,descText:y,titleId:g,descId:m,labelledBy:b}=Sh(Mh(o,"ordinal-gif"),n,o.title,o.description);return Ek.renderToStaticMarkup(jk("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:i,role:"img","aria-labelledby":b,style:{fontFamily:a.fontFamily},children:[p&&Wk("title",{id:g,children:p}),y&&Wk("desc",{id:m,children:y}),h&&Wk("rect",{x:0,y:0,width:t,height:i,fill:h}),Wk("g",{transform:`translate(${u},${d})`,children:f}),p&&Wk("text",{x:t/2,y:22,textAnchor:"middle",fontSize:a.titleFontSize,fontWeight:a.titleFontWeight,fill:a.text,fontFamily:a.titleFontFamily,children:p})]}))}var Lh=34,Th=70,Ch=/\s+([^\s=<>/'"]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g,Oh=(e,t)=>(e>>>t|e<<32-t)>>>0,Fh=e=>Math.floor(4294967296*(e-Math.floor(e)))>>>0,[Dh,zh]=(()=>{let e=[],t=[];for(let i=2;64>t.length;i+=1){let r=!0;for(let e=2;i>=e*e;e+=1)if(i%e===0){r=!1;break}r&&(8>e.length&&e.push(Fh(Math.sqrt(i))),t.push(Fh(Math.cbrt(i))))}return[e,t]})(),Nh=ae({"artifact.id":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"never"},"artifact.createdAt":{suppliedBy:["author","system","import"],derivable:!1,modelMayPropose:!1,humanReview:"never"},"artifact.configFingerprint":{suppliedBy:["system"],derivable:!0,modelMayPropose:!1,humanReview:"never"},"artifact.dataFingerprint":{suppliedBy:["system"],derivable:!0,modelMayPropose:!1,humanReview:"never"},"purpose.intents":{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},"purpose.communicativeAct":{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},"purpose.stakes":{suppliedBy:["author","import"],derivable:!1,modelMayPropose:!0,humanReview:"required"},claims:{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},"claims.status":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},evidence:{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},"evidence.source":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},"evidence.fingerprint":{suppliedBy:["system"],derivable:!0,modelMayPropose:!1,humanReview:"never"},time:{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},"time.completeness":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},reception:{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},form:{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},contestability:{suppliedBy:["author","system","import"],derivable:!1,modelMayPropose:!1,humanReview:"required"},accountability:{suppliedBy:["author","system","import"],derivable:!1,modelMayPropose:!1,humanReview:"policy-dependent"},inheritance:{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"}}),Eh=["fresh","stale","unknown"],Bh=["partial","provisional","settled","unknown"],Wh=["observedAt","ingestedAt","processedAt","publishedAt","snapshotAt"],jh={eventTime:{field:{},value:{},timezone:{},granularity:{}},presentation:{state:{values:["live","historical","mixed"]},label:{}},freshness:{status:{required:!0,values:Eh},checkedAt:{},heartbeatAt:{},expiresAt:{},basis:{}},watermark:{value:{required:!0},policy:{},allowedLateness:{}},window:{start:{required:!0},end:{required:!0},status:{required:!0,values:["open","provisional","settled","reopened","corrected"]}},completeness:{status:{required:!0,values:Bh},basis:{}},revision:{status:{required:!0,values:["original","backfilled","corrected","superseded"]},previousArtifactId:{},correctionId:{},reason:{}},snapshot:{id:{},format:{values:["iceberg","delta","other"]},schemaVersion:{},catalogRef:{}}},Yh={id:{required:!0},kind:{required:!0,values:["stream","processing-job","quality-check","snapshot","publication"]},label:{},observedAt:{},version:{},timezone:{},granularity:{},freshness:{values:Eh},completeness:{values:Bh}},Xh=["data","nodes","edges","points","areas","lines","flows"],qh={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1},Gh={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}}},Vh={kind:"rank-competition"},Hh=Symbol.for("semiotic.semantic-viability"),Uh=globalThis,Kh=Uh[Hh]??(Uh[Hh]=new Map);import*as Zh from"react-dom/server";import*as Qh from"react";var Jh=Object.freeze([]);import{scaleOrdinal as ef}from"d3-scale";var tf=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],rf=ve(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),of=ve(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),nf=ve(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),af=ve(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),sf=ve(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),lf=ve(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),cf=ve(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),uf=ve(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),df=ve(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),hf=ve(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),ff=ve(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),pf=ve(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),yf={blues:rf,reds:of,greens:nf,viridis:cf,oranges:af,purples:sf,greys:lf,plasma:uf,inferno:df,magma:hf,cividis:ff,turbo:pf},gf=ve(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),mf=ve(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),bf=ve(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),xf=ve(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),vf=ve(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),wf=ve(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),kf=ve(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),Af={category10:tf,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...yf},Sf=tf,Mf="#007bff",_f=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],$f=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],Pf=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"]),Rf={stops:[{offset:0,opacity:.8},{offset:1,opacity:.05}]},If=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],Lf={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}},Tf={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}},Cf={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:If,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"},Of={light:Lf,dark:Tf,"high-contrast":Cf,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"}},Ff="__forecastSegment",Df="__forecastOpacity",zf="__semiotic_resolvedX",Nf="__semiotic_resolvedY",Ef="__compoundGroup",Bf={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=ct({data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:r.annotations,themeCategorical:Ke(r.theme).colors.categorical}),a=He(n.annotations,o.regression);return{chartType:"scatter",data:n.data,xAccessor:n.xAccessor,yAccessor:n.yAccessor,colorAccessor:t,sizeAccessor:o.sizeBy,...o.symbolBy&&{symbolAccessor:o.symbolBy},...o.symbolMap&&{symbolMap:o.symbolMap},colorScheme:i,...r,...a&&a.length>0&&{annotations:a},...n.yExtent&&!r.yExtent&&{yExtent:n.yExtent},sizeRange:o.sizeRange||[3,15],pointStyle:r.pointStyle||ut(e,t,i,r,o),showLegend:r.showLegend??!!t}}},Wf={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=He(r.annotations,o.regression);return{chartType:"scatter",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[5,40],colorScheme:i,...r,...n&&{annotations:n},pointStyle:r.pointStyle||dt(e,t,i,r,o),showLegend:r.showLegend??!!t}}};import{useMemo as jf,useCallback as Yf,useState as Xf,useId as qf,useEffect as Gf,useRef as Vf}from"react";var Hf="__semioticSelectionData";import*as Uf from"react";import{jsx as Kf}from"react/jsx-runtime";var Zf,Qf={isActive:!1,predicate:()=>!0};import{jsx as Jf}from"react/jsx-runtime";var ep={frameType:"xy",layout:{margin:e=>({top:20,right:!1===e.showLabels?24:110,bottom:48,left:48})},buildProps:(e,t,i,r,o)=>{let n=function(e,t={}){let i=t.xAccessor??"x",r=t.yAccessor??"y",o=t.lineBy??"series",n=t.rankDirection??"descending",a=[],s=new Map,l=new Map,c=[],u=new Map,d=1/0,h=-1/0;e.forEach((e,t)=>{let n=xt(i,e,t),f=he(n),p=s.get(f);null==p&&(p=a.length,s.set(f,p),a.push(n),l.set(p,[]));let y=xt(o,e,t)+"";u.has(y)||(u.set(y,c.length),c.push(y));let g=Number(xt(r,e,t));Number.isFinite(g)&&(d=Math.min(d,g),h=Math.max(h,g),l.get(p)?.push({datum:e,inputIndex:t,series:y,value:g}))});let f=[],p=new Map,y=new Map;for(let e=0;a.length>e;e++){let t=l.get(e)??[];t.sort((e,t)=>("descending"===n?t.value-e.value:e.value-t.value)||(u.get(e.series)??0)-(u.get(t.series)??0)),t.forEach((t,i)=>{let r=i+1;f.push({datum:t.datum,xIndex:e,xValue:a[e],series:t.series,value:t.value,rank:r}),p.set(t.series,(p.get(t.series)??0)+r),y.set(t.series,(y.get(t.series)??0)+1)})}let g=c.length+1,m=[...c].sort((e,t)=>{let i=y.get(e)??0,r=y.get(t)??0;return((p.get(e)??0)+(a.length-i)*g)/Math.max(1,a.length)-((p.get(t)??0)+(a.length-r)*g)/Math.max(1,a.length)||(u.get(e)??0)-(u.get(t)??0)}),b=new Set(m.slice(0,null==t.highlightTop?m.length:Math.max(0,Math.floor(t.highlightTop))));return{data:f.map(e=>{let t=b.has(e.series);return{...e.datum,x:e.xIndex,y:e.rank,__bumpRaw:e.datum,__bumpSeries:e.series,__bumpColorGroup:t?e.series:"Other",__bumpValue:e.value,__bumpRank:e.rank,__bumpXValue:e.xValue,__bumpHighlighted:t}}),xValues:a,seriesOrder:c,overallOrder:m,valueExtent:d===1/0?[0,0]:[d,h]}}(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],{xAccessor:o.xAccessor,yAccessor:o.yAccessor,lineBy:o.lineBy,rankDirection:o.rankDirection,highlightTop:"number"==typeof o.highlightTop?o.highlightTop:void 0}),a=Math.max(1,n.seriesOrder.length),s=Ke(r.theme),l=function(e){let{seriesOrder:t,overallOrder:i,highlightTop:r,color:o,colorScheme:n,neutralColor:a,themeCategorical:s,themeNeutral:l}=e;if(null==r&&null==o)return n;let c=new Set(i.slice(0,null==r?i.length:Math.max(0,Math.floor(r)))),u=new Map,d={};for(let e of t)Object.defineProperty(d,e,{configurable:!0,enumerable:!0,writable:!0,value:o??(c.has(e)?bt(void 0,s,n,e,u):a??l??"#b8bec8")});return d}({seriesOrder:n.seriesOrder,overallOrder:n.overallOrder,highlightTop:"number"==typeof o.highlightTop?o.highlightTop:void 0,color:"string"==typeof o.color?o.color:void 0,colorScheme:i,neutralColor:"string"==typeof o.neutralColor?o.neutralColor:void 0,themeCategorical:s.colors.categorical,themeNeutral:s.colors.textSecondary}),c={ribbon:!0===o.ribbon,curve:"linear"===o.curve?"linear":"smooth",samplesPerSegment:"number"==typeof o.samplesPerSegment?o.samplesPerSegment:12,ribbonSizeRange:Array.isArray(o.ribbonSizeRange)?o.ribbonSizeRange:[4,28],valueExtent:n.valueExtent,seriesOrder:n.seriesOrder,lineWidth:"number"==typeof o.lineWidth?o.lineWidth:3,ribbonOpacity:"number"==typeof o.ribbonOpacity?o.ribbonOpacity:.82,lineOpacity:"number"==typeof o.lineOpacity?o.lineOpacity:.9,neutralColor:"string"==typeof o.neutralColor?o.neutralColor:void 0,color:"string"==typeof o.color?o.color:void 0,colorMap:l&&"object"==typeof l&&!Array.isArray(l)?l:void 0,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,styleRules:o.styleRules,areaStyle:r.areaStyle,pointStyle:r.pointStyle,labelStyle:o.labelStyle,showPoints:!0===o.showPoints,pointRadius:"number"==typeof o.pointRadius?o.pointRadius:3,showLabels:o.showLabels??!0,labelPriorityAccessor:o.labelPriorityAccessor,maxLabels:"number"==typeof o.maxLabels?o.maxLabels:void 0},u=r.xFormat,d=(e,t)=>{if(0===n.xValues.length)return"";let i=n.xValues[Math.max(0,Math.min(n.xValues.length-1,Math.round(Number(e))))];return u?u(i,t):(i instanceof Date?i.toLocaleDateString():i)+""},h=n.xValues.map((e,t)=>t),f=Array.from({length:a},(e,t)=>t+1),p=r.axes??[{orient:"left",tickValues:f,tickFormat:e=>e+"",label:r.yLabel??"Rank",baseline:!1},{orient:"bottom",tickValues:h,tickFormat:d,label:r.xLabel,tickAnchor:"edges"}];return{...r,chartType:"custom",data:n.data,xAccessor:"x",yAccessor:"y",xExtent:[0,Math.max(1,n.xValues.length-1)],yExtent:[a+.5,.5],customLayout:Pt,layoutConfig:c,colorAccessor:"__bumpSeries",colorScheme:l,xFormat:d,axes:p,axisExtent:"exact",showAxes:r.showAxes??!0,showLegend:r.showLegend??!1,annotations:vt(r.annotations,n.xValues)}}},tp="__ma_unitized",ip="__ma_series",rp={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=Array.isArray(o.series)?o.series:[],s=function(e,t,i){let r=ke(t,i,Sf),o=t&&"object"==typeof t&&!Array.isArray(t)?t:null;return e.map((e,t)=>{if("string"==typeof e.color&&e.color.length>0)return e.color;let i=e.label||"Series "+(t+1),n=o?.[i];return"string"==typeof n&&n.length>0?n:r[t%r.length]})}(a,i,Ke(r.theme).colors.categorical),l=2===a.length,c=a.map(e=>e.extent||function(e,t){let i="function"==typeof t?t:e=>Number(e[t||"y"]),r=1/0,o=-1/0;for(let t of e){let e=i(t);"number"==typeof e&&Number.isFinite(e)&&(r>e&&(r=e),e>o&&(o=e))}if(!Number.isFinite(r)||!Number.isFinite(o))return[0,1];if(r===o){let e=0===r?1:.1*Math.abs(r);return[r-e,o+e]}return[r,o]}(n,e.yAccessor)),u=[];for(let e of n)a.forEach((t,i)=>{let r=("function"==typeof t.yAccessor?t.yAccessor:e=>e[t.yAccessor])(e);if(null==r||!Number.isFinite(Number(r)))return;let o=Number(r),n=c[i],a=n[1]-n[0]||1;u.push({...e,[tp]:l?(o-n[0])/a:o,[ip]:t.label||"Series "+(i+1)})});let d=(e,t)=>i=>{let r=e[0]+i*(e[1]-e[0]);return"function"==typeof t?t(r):Number.isInteger(r)?r+"":r.toFixed(1)},h=l?[{orient:"left",label:a[0].label,tickFormat:d(c[0],a[0].format)},{orient:"right",label:a[1].label,tickFormat:d(c[1],a[1].format)},{orient:"bottom"}]:void 0,f=new Map;a.forEach((e,t)=>{f.set(e.label||"Series "+(t+1),s[t])});let p=Pe(ze({lineWidth:"number"==typeof o.lineWidth?o.lineWidth:2,resolveStroke:e=>f.get((e[ip]??"")+"")||s[0],styleRules:o.styleRules,ruleContext:Rt(o.xAccessor,a)}),{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});return{chartType:"line",data:u,xAccessor:o.xAccessor||"x",yAccessor:tp,groupAccessor:ip,colorAccessor:ip,...h&&{axes:h},...l&&{yExtent:[0,1]},...r,curve:o.curve||r.curve||"monotoneX",showLegend:r.showLegend??!0,colorScheme:s,lineStyle:p}}},op={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=o.xAccessor||"x",s="function"==typeof a?a:e=>e[a],l=n.some(e=>{let t=s(e);return!("number"==typeof t&&Number.isFinite(t)||t instanceof Date)}),c=l?n.map((e,t)=>({...e,__waterfallX:t,__waterfallTick:(s(e)??t)+""})):n,u=o.styleRules?Fe(void 0,o.styleRules,Ie(o.xAccessor,o.yAccessor)):void 0,d=u?e=>{let t=u(e),i="function"==typeof r.areaStyle?r.areaStyle(e):r.areaStyle;return i?{...t,...i}:t}:void 0;return{chartType:"waterfall",data:c,xAccessor:l?"__waterfallX":a,yAccessor:o.yAccessor||"y",waterfallStyle:{positiveColor:o.positiveColor,negativeColor:o.negativeColor,connectorStroke:o.connectorStroke,connectorWidth:o.connectorWidth,gap:o.gap,stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity},...r,...d&&{areaStyle:d},...l&&{axes:r.axes??[{orient:"bottom",tickValues:c.map((e,t)=>t)}],xFormat:e=>{let t=n[Number(e)]?s(n[Number(e)]):e,i=o.xFormat??r.xFormat;return"function"==typeof i?i(t):(t??e)+""}}}}},np={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=t||o.lineBy,a=o.fillArea,s=Array.isArray(a)?"mixed":a?"area":"line",l=Ke(r.theme).colors.categorical,c=function(e,t,i,r,o){let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=Ke(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrLineColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrLineColorBy:t(e)})):n,u=t?Me(c,l,s):void 0,d=Ie(o.xAccessor,o.yAccessor);return Pe(ze({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: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,n,i,r,o),u=ct({data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",lineBy:o.lineBy,colorBy:n,colorScheme:i,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}),d=r.pointStyle||Lt(u.data,u.colorAccessor,i,r,o),h=r.margin;u.marginExtra&&h&&"object"==typeof h?h={...h,...null!=u.marginExtra.right&&{right:Math.max(Number(h.right)||0,u.marginExtra.right)},...null!=u.marginExtra.left&&{left:Math.max(Number(h.left)||0,u.marginExtra.left)}}:u.marginExtra&&null==h&&(h={top:20,right:u.marginExtra.right??20,bottom:30,left:u.marginExtra.left??40});let f=(!o.directLabel||void 0!==r.showLegend)&&(r.showLegend??!!u.colorAccessor);return{chartType:s,data:u.data,xAccessor:u.xAccessor,yAccessor:u.yAccessor,groupAccessor:u.groupAccessor,colorAccessor:u.colorAccessor,colorScheme:i,lineStyle:u.lineStyle||c,...Array.isArray(a)&&{areaGroups:a},...a&&null!=o.areaOpacity&&{areaOpacity:o.areaOpacity},...null!=o.band&&{band:o.band},...r,...void 0!==h&&{margin:h},annotations:u.annotations,...u.yExtent&&!r.yExtent&&{yExtent:u.yExtent},...d&&{pointStyle:d},showLegend:f}}},ap={frameType:"xy",layout:{margin:(e,t)=>function(e,t,i,r=!1){let o=y({axes:t,showAxes:i});return{...k(e,t,r),...!o.hasAxis&&{bottom:0},...!o.leftAxis?.hasAxis&&{left:0}}}(t.marginDefaults,Qe(e),t.showAxes,!!t.title)},buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?me(e):[],a=o.timeAccessor||"time",s=o.valueAccessor||"value",l=o.categoryAccessor,c=o.valueExtent||r.yExtent,u={...Ve(o),...void 0!==o.cursor&&{cursor:o.cursor}},d={...u,...void 0!==o.fill&&{fill:o.fill},...void 0!==o.gap&&{gap:o.gap}},h=Fe(void 0,o.styleRules,e=>{let t=e.categoryValue??e.total,i="number"==typeof t&&Number.isFinite(t)?t:void 0,r=Number(e.binStart),o=Number(e.binEnd);return{value:i,x:Number.isFinite(r)&&Number.isFinite(o)?(r+o)/2:void 0,y:i,category:null==e.category?void 0:e.category+""}});return{chartType:"bar",data:n,...r,runtimeMode:"streaming",windowMode:"growing",windowSize:Math.max(1,n.length),arrowOfTime:o.arrowOfTime||"right",timeAccessor:e=>ge(e,a,"time")??NaN,valueAccessor:e=>ge(e,s,"value")??NaN,xExtent:o.timeExtent||r.xExtent,yExtent:c,invertY:"down"===o.direction,axes:Qe({...o,axes:r.axes??o.axes}),extentPadding:o.extentPadding??r.extentPadding,binSize:o.binSize,categoryAccessor:l,barColors:o.colors||r.barColors,colorScheme:o.colors||r.colorScheme,barStyle:r.barStyle||d,areaStyle:r.areaStyle||(e=>({...h(e),...!l&&void 0!==o.fill&&{fill:o.fill},...u})),showLegend:r.showLegend??!!l}}},sp={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=t||o.areaBy,a=ct({data:Array.isArray(e)?me(e):[],xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",lineBy:o.areaBy,forecast:o.forecast,anomaly:o.anomaly,annotations:r.annotations,themeCategorical:Ke(r.theme).colors.categorical}),s=function({data:e,safeData:t,areaBy:i,lineDataAccessor:r}){if(null==e)return[];let o,n=void 0!==t[0]?.[r];if(!n&&!i)return t;if(n)o=t;else{let e=t.reduce((e,t)=>{let o="function"==typeof i?i(t):t[i],n=o+"";if(!e[n]){let t={[r]:[]};"string"==typeof i&&(t[i]=o),e[n]=t}return e[n][r].push(t),e},{});o=Object.values(e)}return o.flatMap(e=>{let t=Array.isArray(e[r])?e[r]:[];return"string"==typeof i?t.map(t=>({...t,[i]:t[i]??e[i]})):t})}({data:e,safeData:a.data,areaBy:o.areaBy,lineDataAccessor:o.lineDataAccessor||"coordinates"}),l=function(e){if(e)return Array.isArray(e)?{stops:e.map(({at:e,color:t,opacity:i})=>({offset:e/100,color:t,...null!=i&&{opacity:i}}))}:Array.isArray(e.stops)?e:void 0}(o.semanticGradient),c=l?.stops.length?{stops:l.stops.map(e=>({...e,offset:1-e.offset})).sort((e,t)=>e.offset-t.offset)}:je(r.gradientFill),u=!1!==o.semanticLine?function(e){let t=e?.stops.filter(e=>"string"==typeof e.color&&Number.isFinite(e.offset)).map(({offset:e,color:t,opacity:i})=>({offset:Math.max(0,Math.min(1,e)),color:t,...Number.isFinite(i)&&{opacity:Math.max(0,Math.min(1,i))}})).sort((e,t)=>e.offset-t.offset);if(!t?.length)return;let i=t[0];return i.offset>0?[{...i,offset:0},...t]:t}(l):void 0,d=r.pointStyle||Lt(s,n,i,r,o);return{chartType:"area",data:s,xAccessor:a.xAccessor,yAccessor:a.yAccessor,y0Accessor:o.y0Accessor,groupAccessor:o.areaBy||void 0,colorAccessor:n,colorScheme:i,...r,...a.annotations.length>0&&{annotations:a.annotations},...a.yExtent&&!r.yExtent&&{yExtent:a.yExtent},...void 0!==c&&{gradientFill:c},...u&&{semanticLineStops:u},lineStyle:r.lineStyle||It(s,n,i,r,o),...d&&{pointStyle:d}}}},lp={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=o.xAccessor||"x",a=o.seriesAAccessor||"a",s=o.seriesBAccessor||"b",l=e=>qe(Xe(n,"x",e)),c=e=>qe(Xe(a,"a",e)),u=e=>qe(Xe(s,"b",e)),d=o.seriesAColor||"var(--semiotic-danger, #dc2626)",h=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",b=o.seriesBLabel||"B",x=r.legendPosition||"right",v=function(e,t,i,r){if(!e.length)return[];let o=e.filter(e=>Number.isFinite(t(e))).sort((e,i)=>t(e)-t(i)),n=[],a=0,s=null,l=null,c=[],u=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${a}-${e}`,h=e=>n.push(e),f=(e,t)=>{h({__x:e.x,__y:e.y,__y0:e.y,__diffSegment:d(t),__diffWinner:t,__valA:e.y,__valB:e.y,__sourceDatum:e.datum})};for(let e=0;o.length>e;e++){let n=o[e],p=t(n),y=i(n),g=r(n);if(!Number.isFinite(p)||!Number.isFinite(y)||!Number.isFinite(g))continue;let m=u(y,g);if(null!==m){if(null==s){s=m;for(let e of c)f(e,s);c=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(s),__diffWinner:s,__valA:y,__valB:g,__sourceDatum:n}),l={x:p,a:y,b:g,w:m};continue}if(l&&l.w!==m){let e,t;if(c.length>0)e=c[0].x,t=c[0].y;else{let i=y-l.a-(g-l.b);if(0!==i){let r=Math.max(0,Math.min(1,(l.b-l.a)/i));e=l.x+r*(p-l.x),t=l.a+r*(y-l.a)}else e=l.x,t=l.a}h({__x:e,__y:t,__y0:t,__diffSegment:d(s),__diffWinner:s,__valA:t,__valB:t}),a++,s=m,h({__x:e,__y:t,__y0:t,__diffSegment:d(s),__diffWinner:s,__valA:t,__valB:t});for(let e=1;c.length>e;e++)f(c[e],s)}else for(let e of c)f(e,s);c=[],h({__x:p,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(s),__diffWinner:s,__valA:y,__valB:g,__sourceDatum:n}),l={x:p,a:y,b:g,w:m}}else c.push({x:p,y:y,datum:n})}for(let e of c)f(e,s??"A");return n}(Array.isArray(e)?e:[],l,c,u),w=[];if(y&&Array.isArray(e)){let t=e.filter(e=>Number.isFinite(l(e))).sort((e,t)=>l(e)-l(t));for(let e of t){let t=l(e),i=c(e),r=u(e);Number.isFinite(i)&&w.push({__x:t,__y:i,__diffSegment:"line-A",__diffWinner:"A",__sourceDatum:e}),Number.isFinite(r)&&w.push({__x:t,__y:r,__diffSegment:"line-B",__diffWinner:"B",__sourceDatum:e})}}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:Be({seriesAColor:d,seriesBColor:h,areaOpacity:f,styleRules:o.styleRules}),lineStyle:We({seriesAColor:d,seriesBColor:h,lineWidth:p,styleRules:o.styleRules}),curve:o.curve||"linear",...r,...g&&{legend:{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:m,color:d},{label:b,color:h}]}]},legendPosition:x}}}},cp={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=t||o.areaBy,a="string"==typeof n&&Array.isArray(e)?Me(e,n,i):void 0,s="number"==typeof o.areaOpacity?o.areaOpacity:.7,l=r.lineStyle||(e=>{let t=null==n?void 0:Ae(e,n,a),i=o.showLine??!0,r={fill:o.color??t,stroke:i?o.stroke??t:"none",...i?{strokeWidth:o.strokeWidth??o.lineWidth??2}:{},fillOpacity:s,...null==o.opacity?{}:{opacity:o.opacity}},l=o.styleRules;if(l?.length){let t=Re(o.yAccessor),i=n?("function"==typeof n?n(e)??"":e[n]??"")+"":void 0;Object.assign(r,Oe(e,l,{value:t(e),category:i}))}return r}),c=o.normalize?"zero":o.baseline??"zero",u=r.pointStyle||Lt(e,n,i,r,o);return{chartType:"stackedarea",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.areaBy,colorAccessor:n,colorScheme:i,normalize:o.normalize,baseline:c,stackOrder:o.stackOrder,lineStyle:l,...r,...u&&{pointStyle:u},curve:r.curve??o.curve??"monotoneX",showLegend:r.showLegend??!!n}}},up={frameType:"xy",buildProps:(e,t,i,r,o)=>{let[n]=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,...!r.pointStyle&&Array.isArray(o.styleRules)&&o.styleRules.length>0&&{pointStyle:Fe(void 0,o.styleRules,Ie(o.xAccessor||"x",o.closeAccessor||o.highAccessor||"high"))},scalePadding:r.scalePadding??Math.max(2,Math.min(12,Math.round(n/40))),extentPadding:r.extentPadding??(n>200?.1:.02)}}},dp={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=o.xCenter,a=o.yCenter,s=o.quadrants,l=o.centerlineStyle||{},c=!1!==o.showQuadrantLabels,u=o.quadrantLabelSize??12,d=l.stroke||"#999",h=l.strokeWidth??1,f=Array.isArray(l.strokeDasharray)?l.strokeDasharray.join(","):l.strokeDasharray,p=Qh.createElement,y=s?[(e,t,i)=>{if(!t?.x||!t?.y)return null;let r=i.width,o=i.height,l=null!=n?t.x(n):r/2,y=null!=a?t.y(a):o/2;if(null!=n&&!Number.isFinite(l)||null!=a&&!Number.isFinite(y))return null;let g=Math.max(0,Math.min(r,l)),m=Math.max(0,Math.min(o,y)),b=[{c:s.topLeft,x:0,y:0,w:g,h:m},{c:s.topRight,x:g,y:0,w:r-g,h:m},{c:s.bottomLeft,x:0,y:m,w:g,h:o-m},{c:s.bottomRight,x:g,y:m,w:r-g,h:o-m}],x=c?[p("text",{key:"ltl",x:8,y:8+u,fill:s.topLeft.color,fontWeight:600,fontSize:u,opacity:.5},s.topLeft.label),p("text",{key:"ltr",x:r-8,y:8+u,fill:s.topRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},s.topRight.label),p("text",{key:"lbl",x:8,y:o-8,fill:s.bottomLeft.color,fontWeight:600,fontSize:u,opacity:.5},s.bottomLeft.label),p("text",{key:"lbr",x:r-8,y:o-8,fill:s.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},s.bottomRight.label)]:[];return p(Qh.Fragment,null,...b.map((e,t)=>e.w>0&&e.h>0?p("rect",{key:"qf-"+t,x:e.x,y:e.y,width:e.w,height:e.h,fill:e.c.color,opacity:e.c.opacity??.08}):null),p("line",{key:"vc",x1:g,y1:0,x2:g,y2:o,stroke:d,strokeWidth:h,strokeDasharray:f}),p("line",{key:"hc",x1:0,y1:m,x2:r,y2:m,stroke:d,strokeWidth:h,strokeDasharray:f}),...x)}]: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:i,pointStyle:r.pointStyle||o.pointStyle||ut(e,t,i,r,o),...r,showLegend:r.showLegend??!!t,...y&&{svgPreRenderers:y}}}},hp={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=function(e,t){if(!Array.isArray(e))return{data:e,orderMap:new WeakMap};let i=t.xAccessor||"x",r=t.yAccessor||"y",o=t.orderAccessor?[...e].sort((e,i)=>null==e||"object"!=typeof e?1:null==i||"object"!=typeof i?-1:qe(Xe(t.orderAccessor,"order",e))-qe(Xe(t.orderAccessor,"order",i))):e,n=new WeakMap,a=0;for(let e of o){if(null==e||"object"!=typeof e)continue;let t=qe(Xe(i,"x",e)),o=qe(Xe(r,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&a++}let s=0;for(let e of o){if(null==e||"object"!=typeof e)continue;let t=qe(Xe(i,"x",e)),o=qe(Xe(r,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&n.set(e,{idx:s++,total:a})}return{data:o,orderMap:n}}(e,o),a=ct({data:n.data,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:r.annotations,themeCategorical:Ke(r.theme).colors.categorical}),s=He(a.annotations,o.regression),l=o.pointRadius??4,c=Ie(o.xAccessor,o.yAccessor),u=o.styleRules,d=[e=>{let t=e.filter(e=>"point"===e.type&&"number"==typeof e.x&&"number"==typeof e.y);if(2>t.length)return null;let i=[];for(let e=0;t.length-1>e;e++){let r=t[e],o=t[e+1],n=Ge(e,t.length);100>t.length&&i.push(Qh.createElement("line",{key:"halo-"+e,x1:r.x,y1:r.y,x2:o.x,y2:o.y,stroke:"white",strokeWidth:l+2,strokeLinecap:"round",opacity:.5})),i.push(Qh.createElement("line",{key:"segment-"+e,x1:r.x,y1:r.y,x2:o.x,y2:o.y,stroke:n,strokeWidth:l,strokeLinecap:"round"}))}return Qh.createElement(Qh.Fragment,null,...i)}];return{chartType:"scatter",data:a.data,xAccessor:a.xAccessor,yAccessor:a.yAccessor,colorAccessor:t,colorScheme:i,pointStyle:Pe(e=>{let t=n.orderMap.get(e),i=t?.idx??0,r=t?.total??1,o={fill:r>0?Ge(i,r):"#6366f1",stroke:"white",strokeWidth:1,r:l,fillOpacity:1};return u?.length&&Object.assign(o,Oe(e,u,c(e))),o},Ve(o)),...r,...s&&s.length>0&&{annotations:s},...a.yExtent&&!r.yExtent&&{yExtent:a.yExtent},svgPreRenderers:d}}},fp={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=o.frameProps&&"object"==typeof o.frameProps?o.frameProps:void 0,a=Number.isFinite(o.cellBorderWidth)?Math.max(0,o.cellBorderWidth):1,s=Fe(()=>({stroke:o.cellBorderColor??"#fff",strokeWidth:a}),o.styleRules,function(e,t,i){let r=Re(e),o=Re(t),n=Re(i);return e=>{let t="string"==typeof e.agg&&"number"==typeof e.count&&"number"==typeof e.xCenter&&"number"==typeof e.yCenter;return{value:t?Tt(e.value):n(e),x:t?Tt(e.xCenter):r(e),y:t?Tt(e.yCenter):o(e)}}}(o.xAccessor,o.yAccessor,o.valueAccessor)),l=("string"==typeof n?.colorScheme?n.colorScheme:void 0)??i,c=null!=n&&Object.hasOwn(n,"heatmapColorScale"),u=n?.heatmapColorScale,d=c?"function"==typeof u?u:void 0:"custom"===l&&"function"==typeof o.customColorScale?o.customColorScale:void 0;return{chartType:"heatmap",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",valueAccessor:o.valueAccessor,showValues:o.showValues,heatmapValueFormat:o.valueFormat,...o.heatmapAggregation&&{heatmapAggregation:o.heatmapAggregation},...null!=o.heatmapXBins&&{heatmapXBins:o.heatmapXBins},...null!=o.heatmapYBins&&{heatmapYBins:o.heatmapYBins},areaStyle:s,...r,...void 0!==l&&{colorScheme:l},...d&&{heatmapColorScale:d}}}};import{useMemo as pp,useCallback as yp,useRef as gp}from"react";var mp={RdBu:gf,PiYG:mf,PRGn:bf,BrBG:xf,RdYlBu:vf,RdYlGn:wf,Spectral:kf},bp="__likert_neutral_neg",xp="__likert_neutral_pos",vp={frameType:"ordinal",layout:{margin:(e,t)=>({...t.marginDefaults,left:"vertical"===e.orientation?t.marginDefaults.left:Math.max(100,t.marginDefaults.left)})},buildProps:(e,t,r,o,n)=>{let a=Array.isArray(n.levels)&&n.levels.length>=2?n.levels:["Strongly disagree","Disagree","Neutral","Agree","Strongly agree"],s="vertical"!==n.orientation,l=function(e,t,i,r,o,n,a={}){let s=new Map,l=new Set(t);for(let a of e){let e=i(a);s.has(e)||s.set(e,new Map);let c=s.get(e);if(r){let e=r(a);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}let i=e-1;if(0>i||i>=t.length)continue;let o=t[i];c.set(o,(c.get(o)||0)+1)}else if(o&&n){let e=o(a),t=n(a);if(!l.has(e))continue;c.set(e,(c.get(e)||0)+(Number.isFinite(t)?t:0))}}let c=[];for(let[e,i]of s){let r=0;for(let e of t)r+=i.get(e)||0;if(0!==r)for(let o=0;t.length>o;o++){let n=t[o],s=i.get(n)||0,l={};a.category&&(l[a.category]=e),a.level&&(l[a.level]=n),a.count&&(l[a.count]=s),a.score&&(l[a.score]=o+1),c.push({...l,__likertCategory:e,__likertLevel:n,__likertLevelLabel:n,__likertCount:s,__likertPct:s/r*100,__likertLevelIndex:o})}}return c}(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a,Ct(n.categoryAccessor,"question"),n.levelAccessor?null:Ct(n.valueAccessor,"score"),n.levelAccessor?Ct(n.levelAccessor,"level"):null,n.levelAccessor?Ct(n.countAccessor,"count"):null,{category:"string"==typeof n.categoryAccessor?n.categoryAccessor:void 0,level:"string"==typeof n.levelAccessor?n.levelAccessor:void 0,count:"string"==typeof n.countAccessor?n.countAccessor:void 0,score:n.levelAccessor||"string"!=typeof n.valueAccessor?void 0:n.valueAccessor});s&&(l=function(e,t){let i=t.length,r=i%2!=0,o=Math.floor(i/2),n=new Map;for(let t of e){let e=n.get(t.__likertCategory)||[];e.push(t),n.set(t.__likertCategory,e)}let a=[];for(let[,e]of n){let t,n,s=new Map;for(let i of e)i.__likertLevel===bp?t=i:i.__likertLevel===xp?n=i:s.set(i.__likertLevelIndex,i);r&&t&&a.push(t);for(let e=o-1;e>=0;e--){let t=s.get(e);t&&a.push(t)}r&&n&&a.push(n);for(let e=r?o+1:o;i>e;e++){let t=s.get(e);t&&a.push(t)}}return a}(function(e,t){let i=t.length,r=i%2!=0,o=Math.floor(i/2),n=[];for(let t of e){let e=t.__likertLevelIndex;if(r&&e===o){let e=t.__likertPct/2;n.push({...t,__likertLevel:bp,__likertPct:-e}),n.push({...t,__likertLevel:xp,__likertPct:e})}else n.push(o>e?{...t,__likertPct:-t.__likertPct}:t)}return n}(l,a),a));let c=Ke(o.theme).colors.diverging,u=Array.isArray(r)&&r.length>=a.length?r:function(e,t){if(0>=e)return[];if(t&&Object.prototype.hasOwnProperty.call(mp,t)){let i=mp[t];if(1===e)return[i(.5)];let r=[];for(let t=0;e>t;t++)r.push(i(t/(e-1)));return r}let i=["#da1e28","#ff8389","#ffb3b8"],r=["#a6c8ff","#4589ff","#0043ce"],o="#a8a8a8";if(1===e)return[o];let n=e%2!=0,a=Math.floor(e/2),s=[];for(let e=0;a>e;e++)s.push(i[Math.min(Math.floor(e*i.length/a),i.length-1)]);n&&s.push(o);for(let e=0;a>e;e++)s.push(r[Math.min(Math.floor(e*r.length/a),r.length-1)]);return s}(a.length,c),d=new Map(a.map((e,t)=>[e,u[t]||"#888"])),h=a.length%2&&d.get(a[Math.floor(a.length/2)])||"#888",f="function"==typeof n.valueFormat?n.valueFormat:e=>Math.abs(Number(e)).toFixed(0)+"%",p=i(!1===o.showLegend?void 0:{legendGroups:[{label:"",items:a.map(e=>({label:e})),styleFn:e=>({fill:d.get(e.label)||"#888"})}]},o.legend),y=n.styleRules,g=o.pieceStyle;return{chartType:"bar",data:l,oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:s?"horizontal":"vertical",barPadding:n.barPadding,showGrid:o.showGrid,oLabel:n.categoryLabel,rLabel:n.valueLabel||(s?void 0:"Percentage"),rFormat:f,...n.categoryFormat&&{oFormat:n.categoryFormat},...n.valueExtent&&{rExtent:n.valueExtent},...o,pieceStyle:Pe((e,t)=>{let i=e.__likertLevel||e.data?.__likertLevel,r=e.__likertLevelLabel||e.data?.__likertLevelLabel,o=e.__likertPct??e.data?.__likertPct,n={fill:i===bp||i===xp?h:d.get((r||i)+"")||"#888"};return y?.length&&Object.assign(n,Oe(e,y,{value:"number"==typeof o?o:void 0,category:t??(null==r?void 0:r+"")})),"function"==typeof g?Object.assign(n,g(e,t)||{}):g&&"object"==typeof g&&Object.assign(n,g),n},Ve(n)),showLegend:o.showLegend??!0,legendPosition:o.legendPosition||"right",...p&&{legend:p},__legendIncludesAutomatic:!0}}};import{jsx as wp,jsxs as kp}from"react/jsx-runtime";import{Fragment as Ap,jsx as Sp,jsxs as Mp}from"react/jsx-runtime";var _p={frameType:"ordinal",layout:{primarySize:{width:300,height:250}},renderOverlay:function(e,{theme:t}){let i=e.__gauge;if(!i)return null;let r=(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,o=i.needleColor||t.colors.text,n=i.showScaleLabels?(i.thresholds||[]).filter(e=>e.value>i.gMin&&i.gMax>e.value):[];return Mp(Ap,{children:[i.showNeedle&&Mp(Ap,{children:[Sp("line",{x1:i.centerX,y1:i.centerY,x2:i.centerX+i.needleLength*Math.cos(r),y2:i.centerY+i.needleLength*Math.sin(r),stroke:o,strokeWidth:2.5,strokeLinecap:"round"}),Sp("circle",{cx:i.centerX,cy:i.centerY,r:4,fill:o})]}),null!=i.contextValue&&Sp("text",{x:i.centerX,y:i.contextValueY,textAnchor:"middle",dominantBaseline:"middle",fontSize:i.valueFontSize,fontWeight:700,fill:o,children:i.contextValue}),n.map((e,r)=>{let o=(i.startAngleDeg+(i.gMax===i.gMin?0:(e.value-i.gMin)/(i.gMax-i.gMin))*i.sweep-90)*Math.PI/180,n=i.innerRadius-1,a=i.radius+1,s=i.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 Mp("g",{children:[Sp("line",{x1:i.centerX+Math.cos(o)*n,y1:i.centerY+Math.sin(o)*n,x2:i.centerX+Math.cos(o)*a,y2:i.centerY+Math.sin(o)*a,stroke:t.colors.border,strokeWidth:2,strokeLinecap:"round"}),Sp("text",{x:i.centerX+Math.cos(o)*s,y:i.centerY+Math.sin(o)*s,textAnchor:c,dominantBaseline:u,fill:t.colors.textSecondary,fontSize:10,children:e.label||e.value+""})]},"gauge-label-"+r)})]})},buildProps:(e,t,i,r,o)=>{let n=o.min??0,a=o.max??100,s=o.sweep??240,l=o.arcWidth??.3,c=!1!==o.showNeedle,u=!1!==o.fillZones,{startAngleDeg:d}=Et(s),h=o.thresholds,f=Ye(r.gradientFill),p=function(e){let{min:t,max:i,value:r,thresholds:o,fillColor:n,backgroundColor:a,fillZones:s,showScaleLabels:l,gradientFill:c,gradientSteps:u=240}=e,d=i-t||1,h=(Math.max(t,Math.min(i,r))-t)/d,f=o&&o.length>0?[...o].sort((e,t)=>e.value-t.value):[{value:i,color:n||"#007bff"}];f=f.map(e=>({...e,value:Math.max(t,Math.min(i,e.value))})),i>f[f.length-1].value&&f.push({value:i,color:f[f.length-1].color});let p=!!c&&c.stops.length>=2,y=[],g=new Map,m=[];if(p){let e=s?h:1,t=Nt("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:a,opacity:.4}),e>0){let t=Math.max(1,Math.floor(u)),i=Math.max(1,Math.min(t,Math.round(e*t))),r=[];for(let t=0;i>t;t++)r.push(zt(c.stops,e*(t+.5)/i,n||f[0]?.color||"#007bff"));let o=Nt("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]||a})}}else{let e=t;for(let i=0;f.length>i;i++){let r=f[i],o=(r.value-e)/d,n=(e-t)/d,l=(r.value-t)/d,c=Math.max(0,(s?Math.min(h,l):l)-n),u=s?Math.max(0,o-c):0;if(c>0){let e=Nt("fill",i);y.push({category:e,value:c,_zone:r.label||"Zone "+(i+1),_isFill:!0}),g.set(e,{fill:r.color})}if(u>0){let e=Nt("bg",i);y.push({category:e,value:u,_zone:r.label||"Zone "+(i+1),_isFill:!1}),g.set(e,{fill:a,opacity:.4})}e=r.value}}if(l&&o&&o.length>0)for(let e of o)e.value>t&&i>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:a},gaugeAnnotations:m}}({min:n,max:a,value:o.value,thresholds:h,fillColor:o.color,backgroundColor:o.backgroundColor||"#e0e0e0",fillZones:u,showScaleLabels:!1!==o.showScaleLabels,gradientFill:f}),y=o.styleRules,[g,m]=r.size||[300,250],b=function(e=240){let{sweepRad:t,offsetRad:i}=Et(e),r=[[Math.cos(i),Math.sin(i)],[Math.cos(i+t),Math.sin(i+t)],[0,0]];for(let e=0;2*Math.PI>e;e+=Math.PI/2)t+.001>=((e-i)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)&&r.push([Math.cos(e),Math.sin(e)]);let o=r.map(e=>e[0]),n=r.map(e=>e[1]),[a,s]=Je(o),[l,c]=Je(n);return{minX:a,maxX:s,minY:l,maxY:c,width:s-a,height:c-l,cx:(a+s)/2,cy:(l+c)/2}}(s),x=Math.min(10,Math.max(1,Math.min(g,m)/12)),v=Math.max(4,Math.min((g-2*x)/b.width,(m-2*x)/b.height)-2),w=Math.max(0,Math.min(v-1.5,v*(1-l))),k=g/2-b.cx*v,A=m/2-b.cy*v,S=2*(v+4),M=Math.max(n,Math.min(a,o.value??n)),_="function"==typeof o.valueFormat?o.valueFormat(M):Math.round(M)+"",$=o.centerContent??r.centerContent,P=null!=$?"function"==typeof $?$(M,n,a):$:"sparkline"===o.mode||"context"===o.mode?void 0:function({value:e,min:t,max:i,radius:r,showScaleLabels:o}){let n=Math.max(16,.3*r);return kp("g",{textAnchor:"middle",children:[wp("text",{y:0,dominantBaseline:"central",fontSize:n,fontWeight:700,fill:"var(--semiotic-text, #333)",children:e}),o&&kp("text",{y:.7*n+11,fontSize:11,fill:"var(--semiotic-text-secondary, #666)",children:[t," – ",i]})]})}({value:_,min:n,max:a,radius:v,showScaleLabels:!1!==o.showScaleLabels});return{chartType:"donut",data:p.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:w,sweepAngle:s,startAngle:d,oSort:!1,pieceStyle:Pe((e,t)=>{let i={...p.pieceStyle(e,t)};return y?.length&&Object.assign(i,Oe(e,y,{value:"number"==typeof e.value?e.value:void 0,category:t??(null==e.category?void 0:e.category+"")})),i},Ve(o)),...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...r,size:[g,m],margin:{top:A-S/2,bottom:m-A-S/2,left:k-S/2,right:g-k-S/2},...null!=P&&{centerContent:P},showAxes:!1,annotations:[...Array.isArray(r.annotations)?r.annotations:[],...p.gaugeAnnotations],__gauge:{gMin:n,gMax:a,sweep:s,arcWidth:l,value:M,startAngleDeg:d,thresholds:h,centerX:k,centerY:A,radius:v,innerRadius:w,showScaleLabels:!1!==o.showScaleLabels,needleLength:w>20?w-8:v-1,showNeedle:c,needleColor:o.needleColor,..."context"===o.mode&&null==$&&{contextValue:_,contextValueY:A-.2*w,valueFontSize:Math.max(12,Math.min(22,.28*v))}}}}},$p={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=He(r.annotations,o.regression);return{chartType:"bar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??!1,colorAccessor:t,colorScheme:i,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,...n&&{annotations:n},gradientFill:Bt(r.gradientFill),pieceStyle:Wt(e,t,i,r,o)}}},Pp={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=t||o.stackBy;return{chartType:"bar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.stackBy,colorAccessor:n,colorScheme:i,projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},normalize:o.normalize,oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:Bt(r.gradientFill),pieceStyle:Wt(e,n,i,r,o),showLegend:r.showLegend??!!n}}},Rp={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=t||o.groupBy;return{chartType:"clusterbar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",groupBy:o.groupBy,colorAccessor:n,colorScheme:i,projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:Bt(r.gradientFill),pieceStyle:Wt(e,n,i,r,o),showLegend:r.showLegend??!!n}}},Ip={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=t||o.categoryAccessor,a=Re(o.valueAccessor??"value");return{chartType:"pie",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",colorAccessor:n,colorScheme:i,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...null!=o.startAngle&&{startAngle:o.startAngle},...r,pieceStyle:Wt(e,n,i,r,o,e=>{let t=a(e);return null==t?void 0:Math.abs(t)}),showLegend:r.showLegend??!!n}}},Lp={frameType:"ordinal",layout:{primarySize:{width:400,height:400}},buildProps:(e,t,i,r,o)=>{let n=t||o.categoryAccessor,a=Re(o.valueAccessor??"value");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:n,colorScheme:i,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...null!=o.startAngle&&{startAngle:o.startAngle},...r,pieceStyle:Wt(e,n,i,r,o,e=>{let t=a(e);return null==t?void 0:Math.abs(t)})}}},Tp={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=o.valueAccessor||"value",s=n.map(e=>Number("function"==typeof a?a(e):e[a])).filter(Number.isFinite),l=s.length?[Math.min(...s),Math.max(...s)]:void 0;return{chartType:"histogram",data:e,oAccessor:o.categoryAccessor||(e=>null==e.category?"All":e.category+""),rAccessor:a,projection:"horizontal",bins:o.bins??25,normalize:o.relative??!1,colorAccessor:t,colorScheme:i,barPadding:o.categoryPadding??20,...o.valueExtent?{rExtent:o.valueExtent}:l?{rExtent:l}:{},...r,summaryStyle:jt(e,t,i,r,o,"count")}}},Cp={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"boxplot",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},colorAccessor:t,colorScheme:i,...null!=o.showOutliers&&{showOutliers:o.showOutliers},...null!=o.outlierRadius&&{outlierRadius:o.outlierRadius},...r,summaryStyle:jt(e,t,i,r,o)})},Op={frameType:"ordinal",buildProps:(e,t,i,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:i,...r,summaryStyle:Yt(e,t,i,r,o),showLegend:r.showLegend??!!t,...o.valueExtent&&{rExtent:o.valueExtent}})},Fp={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"swarm",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},barPadding:o.categoryPadding??20,colorAccessor:t,...o.symbolBy&&{symbolAccessor:o.symbolBy},...o.symbolMap&&{symbolMap:o.symbolMap},colorScheme:i,...r,sizeRange:o.sizeRange||[3,8],pieceStyle:qt(e,t,i,r,o),showLegend:r.showLegend??!!t})},Dp={frameType:"ordinal",layout:{modeDefaults:{showGrid:!0}},buildProps:(e,t,i,r,o)=>{let n=He(r.annotations,o.regression);return{chartType:"point",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??"auto",barPadding:o.categoryPadding??10,...r,...n&&{annotations:n},pieceStyle:Xt(e,t,i,r,o),showGrid:r.showGrid??!0,showLegend:r.showLegend??!!t}}},zp={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=o.seriesAccessor||t||"__radar",a=t||("__radar"===n?void 0:n),s=Xt(e,a,i,r,{...o,dotRadius:o.pointRadius??4});return{chartType:"point",projection:"radial",data:e,oAccessor:o.categoryAccessor||"attribute",rAccessor:o.valueAccessor||"value",colorAccessor:a,colorScheme:i,connectorAccessor:n,connectorStyle:e=>{let t=s(e),i="string"==typeof t.fill?t.fill:void 0;return{fill:i,fillOpacity:.15,stroke:i,strokeWidth:2,opacity:.7}},pieceStyle:s,rExtent:o.valueExtent||[0],oLabel:"",...r,...o.categoryFormat&&{oFormat:o.categoryFormat},showLegend:r.showLegend??!!a}}},Np={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=t||o.subcategoryAccessor;return{chartType:"swimlane",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.subcategoryAccessor,colorAccessor:n,categoryAccessor:o.categoryAccessor,subcategoryAccessor:o.subcategoryAccessor,colorScheme:i,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:Bt(r.gradientFill),pieceStyle:Wt(e,n,i,r,o),showLegend:r.showLegend??!!n,barPadding:o.barPadding??40}}},Ep={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"ridgeline",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...o.valueExtent&&{rExtent:o.valueExtent},bins:o.bins??20,amplitude:o.amplitude??1.5,barPadding:o.categoryPadding??5,oSort:o.oSort??!1,...r,summaryStyle:jt(e,t,i,r,o,"median",.5),showLegend:r.showLegend??!!t})},Bp={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,i,r,o)=>{let n="vertical"===o.orientation,a=t||o.categoryAccessor;return{chartType:n?"bar-funnel":"funnel",data:e,oAccessor:o.stepAccessor||"step",rAccessor:o.valueAccessor||"value",colorAccessor:a,categoryAccessor:o.categoryAccessor,projection:n?"vertical":"horizontal",connectorAccessor:o.connectorAccessor,connectorStyle:o.connectorStyle,...!n&&null!=o.connectorOpacity&&{connectorOpacity:o.connectorOpacity},barPadding:n?40:0,colorScheme:i,...r,showAxes:n&&!1!==r.showAxes,showGrid:n,pieceStyle:Wt(e,a,i,r,o),showLabels:o.showLabels??!0}}};import{scaleTime as Wp}from"d3-scale";var jp={static:{duplicateIds:"fatal",invalidSystemTime:"warn"},mcp:{duplicateIds:"fatal",invalidSystemTime:"warn"},push:{duplicateIds:"warn",invalidSystemTime:"strip"}},Yp=new Set(["invalid-domain","missing-node","backward-edge","invalid-edge-time","invalid-value","invalid-node-time"]),Xp=e=>{let t=1;for(let i=2;e>=i;i++)t*=i;return t},qp=828*Xp(8),Gp=3e3,Vp=new Map,Hp=1e5,Up=1e-9,Kp=/(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?),(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/gi,Zp=null,Qp=new WeakMap;import{jsx as Jp,jsxs as ey}from"react/jsx-runtime";var ty=new Map;import{Fragment as iy,jsx as ry,jsxs as oy}from"react/jsx-runtime";var ny="var(--semiotic-grid, #94a3b8)",ay="var(--semiotic-text-secondary, #475569)",sy="var(--semiotic-text-secondary, #94a3b8)",ly=e=>{let{bands:t=[],ribbons:i=[],showLabels:r=!0,selectionDatum:o="raw"}=e.config,n=e.selection??null,a=[];for(let e of i){let t={__kind:"ribbon",data:e.rawDatum,id:e.id},i=!lr(t,n,o);a.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:i?Math.min(e.opacity,.22):e.opacity,stroke:"none"},datum:t})}for(let e of t){if(!e.gradientStubs)continue;let t=!lr({__kind:"band",data:e.rawDatum,id:e.id},n,o);for(let i=0;e.gradientStubs.length>i;i++){let r=e.gradientStubs[i];a.push({type:"bezier",pathD:r.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:t?.22:e.fillOpacity??.86,stroke:"none"},_gradient:{x0:r.x0,x1:r.x1,...null!=r.y0&&{y0:r.y0},...null!=r.y1&&{y1:r.y1},from:r.from,to:r.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${i}`}})}}for(let e of t){let t=!(!e.gradientStubs||0>=e.gradientStubs.length),i={__kind:"band",data:e.rawDatum,id:e.id},r=!lr(i,n,o);a.push({type:"bezier",pathD:e.pathD,style:{...t?{fill:"none"}:{fill:e.hatchFill??e.fill,fillOpacity:r?.22:e.fillOpacity??.86},stroke:e.stroke??("string"==typeof e.fill?e.fill:"#666"),strokeWidth:e.strokeWidth??.5,...r&&t?{opacity:.22}:{}},datum:i})}let s=r?t.flatMap(e=>{let t=e.labelDeferred&&e.labelFullText?.trim(),i=e.labelText.trim().length>0,r=t&&n?.isActive&&lr({__kind:"band",data:e.rawDatum,id:e.id},n,o),a=i?e.labelText:r?e.labelFullText:"";return a.trim()?[{x:e.labelX,y:e.labelY,text:a,anchor:e.labelAnchor??"end",baseline:e.labelBaseline??"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:a,labels:s}},cy={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{if(!(t||Array.isArray(o.styleRules)&&o.styleRules.length>0||r.nodeStyle||o.nodeStyle||$e(Ve(o))))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:i,...r,showLegend:(r.showLegend??!!t)&&!!t};let n=Array.isArray(o.edges)?o.edges:[],a=Array.isArray(o.nodes)&&o.nodes.length>0?o.nodes:ur([],n,o.sourceAccessor||"source",o.targetAccessor||"target"),s=Ke(r.theme).colors.categorical,l=ke(i,s),c="string"==typeof t?t:"__ssrChordColorBy",u="function"==typeof t?a.map(e=>({...e,__ssrChordColorBy:t(e)})):a,d=t?Me(u,c,i??r.colorScheme??s):void 0,h=new Map,f=o.nodeIdAccessor||o.nodeIDAccessor||"id",p=(e,i)=>{let r,n=e?.data||e;if(t)r=Ae(n,t,d);else{let t=(e.id??n?.[f]??"")+"";h.has(t)||h.set(t,h.size);let o=e.index??i??h.get(t);r=l[o%l.length]}return{fill:r,stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}},y=De(o.styleRules,t,o.valueAccessor);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:i,nodeStyle:Pe(o.nodeStyle||(y?(e,t)=>({...p(e,t),...y(e,t)}):p),Ve(o)),...r,showLegend:(r.showLegend??!!t)&&!!t}}},uy={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let n=function(e){if(void 0!==e.edgeStyle)return e.edgeStyle;let{edgeWidth:t,edgeColor:i,edgeOpacity:r}=e,o=e.strokeWidth??1;return void 0!==t||void 0!==i||void 0!==r||void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity?n=>{let a=n?.data||n,s=o;if("number"==typeof t)s=t;else if("function"==typeof t)s=t(a);else if("string"==typeof t){let e=a?.[t],i="number"==typeof e?e:Number(e);s=Number.isFinite(i)&&i>0?i:o}return{stroke:i??e.stroke??"#999",strokeWidth:s,opacity:r??e.opacity??.6}}:void 0}(o),a=Ke(r.theme).colors.categorical,s=new Map,l=o.nodeStyle??(e=>({fill:t?Ae(e?.data||e,t,void 0):bt(void 0,a,i,void 0,s),..."number"==typeof o.nodeSize&&{r:o.nodeSize}})),c=De(o.styleRules,t,"number"==typeof o.nodeSize?void 0:o.nodeSize),u=Pe(c?(e,t)=>({...l(e),...c(e,t)}):l,{stroke:o.nodeStroke??o.stroke,strokeWidth:o.nodeStrokeWidth??o.strokeWidth,opacity:o.opacity});return{chartType:"force",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,colorBy:t,colorScheme:i,iterations:o.iterations,forceStrength:o.forceStrength,showLabels:o.showLabels??!1,nodeLabel:o.nodeLabel,nodeSize:o.nodeSize??8,nodeSizeRange:o.nodeSizeRange,nodeStyle:u,edgeStyle:n,...r,showLegend:(r.showLegend??!!t)&&!!t}}},dy={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let n=Ke(r.theme).colors.categorical,a=new Map,s=cr(e??null,o.childrenAccessor),l="function"==typeof t?t:null,c=l?s.map(e=>({__ssrCirclePackColorBy:l(e)})):s,u=l?"__ssrCirclePackColorBy":"string"==typeof t?t:void 0,d=t&&u?Me(c,u,i??r.colorScheme??n):void 0,h=o.showLabels??r.showLabels,f=r.nodeStyle||o.nodeStyle,p=Fe(e=>{let r=e?.data||e;return{fill:o.colorByDepth?$f[Number(e?.depth||0)%$f.length]:t?l?Ae({__ssrCirclePackColorBy:l(r)},"__ssrCirclePackColorBy",d??void 0):Ae(r,t,d??void 0):bt(void 0,n,i,void 0,a),fillOpacity:o.circleOpacity??.7,stroke:"currentColor",strokeWidth:1,strokeOpacity:.3}},o.styleRules,Le(t,o.valueAccessor),e=>e?.data||e);return{chartType:"circlepack",data:e,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:t,colorByDepth:o.colorByDepth,showLabels:o.showLabels,nodeLabel:h?o.nodeLabel||o.nodeIdAccessor:void 0,...null!=o.padding&&{padding:o.padding},colorScheme:i,...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth),nodeStyle:dr(p,f,Ve(o))}}},hy={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let n=e??o.data,a=o.childrenAccessor||"children",s=o.nodeIdAccessor||o.nodeIDAccessor||"name",l=Ke(r.theme).colors.categorical,c=i??r.colorScheme??l,u=ke(c,l),d=cr(n,a),h="__ssrOrbitColorBy",f="function"==typeof t?t:null,p=t?Me(f?d.map(e=>({[h]:f(e)})):d,f?h:t,c):void 0,y=Fe(e=>{let i=e.data||e,r=Number(e.depth??0);return{fill:o.colorByDepth?0===r?u[0]:$f[r%$f.length]:t?f?Ae({[h]:f(i)},h,p):Ae(i,t,p):u[0],stroke:"#fff",strokeWidth:1,opacity:0===r?1:.85}},o.styleRules,Le(t,"value"),e=>e?.data||e);return{chartType:"orbit",data:n,childrenAccessor:a,nodeIDAccessor:s,colorBy:t,colorScheme:c,colorByDepth:o.colorByDepth??!1,nodeSize:o.nodeRadius??6,nodeLabel:o.showLabels?s:void 0,showLabels:o.showLabels??!1,orbitMode:o.orbitMode??"flat",orbitSize:o.orbitSize??2.95,orbitSpeed:o.speed??.25,orbitRevolution:o.revolution,orbitRevolutionStyle:o.revolutionStyle,orbitEccentricity:o.eccentricity??1,orbitShowRings:o.showRings??!0,orbitAnimated:!1,nodeStyle:Pe(y,Ve(o)),edgeStyle:()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth)}}},fy={frameType:"network",layout:{margin:{top:30,right:80,bottom:40,left:80}},buildProps:(e,t,r,o,n)=>{let a=e=>null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime(),s=n.sourceAccessor||"source",l=n.targetAccessor||"target",c=n.valueAccessor||"value",u=n.nodeIdAccessor||"id",d=n.startTimeAccessor||"startTime",h=n.endTimeAccessor||"endTime",f=n.systemInTimeAccessor,p=n.systemOutTimeAccessor,y=n.xExtentAccessor||"xExtent",g=n.groupBy,m=n.edgeIdAccessor||"id",b=(e,t)=>"function"==typeof e?e(t):t[e],x=Array.isArray(n.edges)?n.edges:[],v=Array.isArray(n.nodes)?n.nodes:[],w=v.length>0?v:ur([],x,s,l),k=[a(n.domain?.[0]),a(n.domain?.[1])],A=w.map(e=>{let t=b(u,e)+"",i=b(y,e),r=n.nodeLabel?b(n.nodeLabel,e):t,o={id:t,label:null==r?t:r+"",__raw:e},s=g?b(g,e):null;if(null!=s&&s+""!=""&&(o.group=s+""),Array.isArray(i)&&2===i.length){let e=a(i[0]),t=a(i[1]);Number.isFinite(e)&&Number.isFinite(t)&&(o.xExtent=[e,t])}return o}),S=x.map((e,t)=>{let i=b(m,e),r={id:null!=i?i+"":`${b(s,e)}-${b(l,e)}-${t}`,source:b(s,e)+"",target:b(l,e)+"",value:Number(b(c,e)),startTime:a(b(d,e)),endTime:a(b(h,e)),__raw:e};if(f){let t=a(b(f,e));Number.isFinite(t)&&(r.systemInTime=t)}if(p){let t=a(b(p,e));Number.isFinite(t)&&(r.systemOutTime=t)}return r}),[M,_]=o.size??[600,400],$=o.margin,P="vertical"===n.orientation?"vertical":"horizontal",R={...sr(!!o.title,!!n.showQualityReadout,Array.isArray(n.axisTicks)&&n.axisTicks.length>0,P),...$},I=(o.showLegend??!!t)&&!!t,L=o.legendPosition??"right";I&&("right"===L?R.right=Math.max(R.right,140):"left"===L?R.left=Math.max(R.left,140):"top"===L?R.top=Math.max(R.top,50):"bottom"===L&&(R.bottom=Math.max(R.bottom,80)));let T=R,C=M-T.left-T.right,O=_-T.top-T.bottom,F=ke(r,Ke(o.theme).colors.categorical,tf),D="function"==typeof t?t:null,z=D?w.map(e=>({_cat:D(e)})):w,N=D?"_cat":"string"==typeof t?t:void 0,E=r??[...F],B=N?Me(z,N,E):null,W=new Map;for(let e of A)W.set(e.id,e.__raw);let j=(e,i)=>{if(t&&W.has(e)){let i=W.get(e);return D?Ae({_cat:D(i)},"_cat",B??void 0):Ae(i,"string"==typeof t?t:"id",B??void 0)}return F[i%F.length]},Y=i(I&&t?(()=>{let e=new Map;w.forEach((i,r)=>{let o=b(t,i),n=null==o?"":o+"";!n||e.has(n)||e.set(n,{label:n,color:j(b(u,i)+"",r)})});let i=Array.from(e.values());return i.length>0?{legendGroups:[{type:"fill",label:"",items:i,styleFn:e=>{let t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0})():void 0,o.legend),X=!1!==n.showLabels&&("auto"!==n.showLabels||"auto"),{layout:q,layoutConfig:G,issues:V,xScale:H}=ar({nodes:A,edges:S,domain:k,plotW:C,plotH:O,orientation:P,ribbonLane:n.ribbonLane||"both",ribbonMinRun:"auto"===n.ribbonMinRun||"number"==typeof n.ribbonMinRun?n.ribbonMinRun:0,edgeOpacity:"number"==typeof n.edgeOpacity?n.edgeOpacity:.35,colorOf:j,showLabels:X,styleRules:n.styleRules,colorBy:t,valueAccessor:c,layoutOpts:{pairing:n.pairing||"temporal",packing:n.packing||"reuse",laneOrder:n.laneOrder||"crossing-min",lifetimeMode:n.lifetimeMode||"half",maxValueScale:"number"==typeof n.maxValueScale?n.maxValueScale:void 0,lanePlacement:n.lanePlacement||"stack",nodeSizing:n.nodeSizing||"temporal",groupPadding:"number"==typeof n.groupPadding?n.groupPadding:0}});if(V.length>0){let e=V.map(Ht).join("; ");throw Error("ProcessSankey: data invalid — "+e)}let U=q?function(e){let t=e.layout,i=e.nodes,r=e.orientation,o=e.plotW,n=e.plotH,a=e.timelineExtent,s=e.axisTicks,l=e.showQualityReadout??!1,c=e.showLaneRails??!1,u=(e.warnings??[]).slice(0,3),d=e.timeFormat,h=e.colorOf,f=e.toTime,p=e.xScale,{centerlines:y,laneLifetime:g,nodeData:m,valueScale:b,compressedPadding:x,crossingsBefore:v,crossingsAfter:w,layoutQualityBefore:k,layoutQuality:A}=t,S=null,M=null;for(let e of i){let t=g[e.id];if(!t||null===t.start||null===t.end)continue;let i=p(t.start),r=p(t.end);(null===S||S>i)&&(S=i),(null===M||r>M)&&(M=r)}let _=e=>Math.max(0,Math.min(a,e)),$=_(S??0),P=Math.max($,_(M??a)),R=s.map((e,t)=>({tick:e,index:t,coordinate:p(f(e.date))})).filter(({coordinate:e})=>e>=$-.5&&P+.5>=e),I=null!==(w??null)&&null!=k&&null!=A,L=l&&(I||u.length>0)?oy("g",{fill:sy,fontSize:10,textAnchor:"end",children:[I&&oy(iy,{children:[oy("text",{x:o,y:-14,children:["crossings: ",v," → ",w," ","pixel length: ",Math.round(k.pixelLength)," → ",Math.round(A.pixelLength)]}),oy("text",{x:o,y:-3,children:["transit: ",k.transitOcclusion.toFixed(1)," → ",A.transitOcclusion.toFixed(1)," ","lane use: ",Math.round(100*A.verticalUtilization),"%"]})]}),u.map((e,t)=>oy("text",{x:o,y:I?10+11*t:11*t-3,fill:"var(--semiotic-warning, #b45309)",children:["warn: ",e]},"warn-"+t))]}):null,T=x?ry("text",{x:o,y:"vertical"===r?-3:2,fontSize:10,fill:sy,textAnchor:"end",children:"dense layout: lane gaps compressed"}):null,C=(e,t)=>h?h(e,t):ny;return oy("g","vertical"===r?{children:[L,T,R.map(({index:e,coordinate:t})=>ry("line",{x1:0,y1:t,x2:o,y2:t,stroke:ny,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),c&&i.map((e,t)=>{let i=g[e.id];if(!i||null===i.start)return null;let r=m[e.id],o=r?{topPeak:r.topPeak,botPeak:r.botPeak}:{topPeak:0,botPeak:0},n=y[e.id]+(o.botPeak-o.topPeak)*b/2,a=p(i.start),s=p(i.end),l=C(e.id,t);return oy("g",{children:[ry("line",{x1:n,y1:a,x2:n,y2:s,stroke:l,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),ry("line",{x1:n-4,y1:a,x2:n+4,y2:a,stroke:l,strokeOpacity:.5}),ry("line",{x1:n-4,y1:s,x2:n+4,y2:s,stroke:l,strokeOpacity:.5})]},"lane-"+e.id)}),ry("line",{x1:-4,y1:$,x2:-4,y2:P,stroke:ny}),R.map(({tick:e,index:t,coordinate:i})=>{let r=f(e.date),o=null!=e.label?e.label:d?d(new Date(r)):"";return oy("g",{transform:`translate(-4,${i})`,children:[ry("line",{x2:-6,stroke:ny}),ry("text",{x:-10,y:4,textAnchor:"end",fontSize:11,fill:ay,children:o})]},t)})]}:{children:[L,T,R.map(({index:e,coordinate:t})=>ry("line",{x1:t,y1:0,x2:t,y2:n,stroke:ny,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),c&&i.map((e,t)=>{let i=g[e.id];if(!i||null===i.start)return null;let r=m[e.id],o=r?{topPeak:r.topPeak,botPeak:r.botPeak}:{topPeak:0,botPeak:0},n=y[e.id]+(o.botPeak-o.topPeak)*b/2,a=p(i.start),s=p(i.end),l=C(e.id,t);return oy("g",{children:[ry("line",{x1:a,y1:n,x2:s,y2:n,stroke:l,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),ry("line",{x1:a,y1:n-4,x2:a,y2:n+4,stroke:l,strokeOpacity:.5}),ry("line",{x1:s,y1:n-4,x2:s,y2:n+4,stroke:l,strokeOpacity:.5})]},"lane-"+e.id)}),ry("line",{x1:$,y1:n+4,x2:P,y2:n+4,stroke:ny}),R.map(({tick:e,index:t,coordinate:i})=>{let r=f(e.date),o=null!=e.label?e.label:d?d(new Date(r)):"";return oy("g",{transform:`translate(${i},${n+4})`,children:[ry("line",{y2:6,stroke:ny}),ry("text",{y:20,textAnchor:"middle",fontSize:11,fill:ay,children:o})]},t)})]})}({layout:q,nodes:A,orientation:P,plotW:C,plotH:O,timelineExtent:"vertical"===P?O:C,axisTicks:Array.isArray(n.axisTicks)?n.axisTicks.map(e=>({date:e.date,label:e.label})):[],showQualityReadout:!!n.showQualityReadout,showLaneRails:!!n.showLaneRails,timeFormat:"function"==typeof n.timeFormat?e=>n.timeFormat(e):void 0,colorOf:j,toTime:e=>a(e),xScale:e=>Number(H(e))}):void 0;return{chartType:"force",nodes:w,edges:x,customNetworkLayout:ly,layoutConfig:G,sourceAccessor:s,targetAccessor:l,valueAccessor:c,nodeIDAccessor:u,colorBy:t,colorScheme:r,...U&&{backgroundGraphics:U},...o,showLegend:I,...Y&&{legend:Y,legendPosition:L},__legendIncludesAutomatic:!0,margin:T}}},py={frameType:"network",layout:{primarySize:{width:800,height:600}},buildProps:(e,t,i,r,o)=>{let n=Array.isArray(o.nodes)?o.nodes:ur([],Array.isArray(o.edges)?o.edges:[],o.sourceAccessor||"source",o.targetAccessor||"target"),a=Ke(r.theme).colors.categorical,s=new Map,l="string"==typeof t?t:"__ssrSankeyColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrSankeyColorBy:t(e)})):n,u=t?Me(c,l,i??r.colorScheme??a):void 0,d=e=>({fill:t?Ae(e?.data||e,t,u):bt(void 0,a,i,void 0,s),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}),h=De(o.styleRules,t,o.valueAccessor),f=h?(e,t)=>({...d(e),...h(e,t)}):d,p=function({edgeColorBy:e,colorBy:t,colorScale:i,nodeStyleFn:r,edgeOpacity:o,baseStyle:n={}}){return a=>{let s={fillOpacity:o,...n};if("function"==typeof e)s.fill=e(a);else if("source"===e){let e="object"==typeof a.source?a.source:null;t&&e?s.fill=Ae(e.data||e,t,i):e&&(s.fill=r(e,e.index).fill)}else if("target"===e){let e="object"==typeof a.target?a.target:null;t&&e?s.fill=Ae(e.data||e,t,i):e&&(s.fill=r(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*o);return s}}({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:Pe(o.nodeStyle||f,Ve(o)),edgeStyle:Pe(o.edgeStyle||p,Ve(o)),colorScheme:i,...r,showLegend:(r.showLegend??!!t)&&!!t}}},yy={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let n=Ke(r.theme).colors.categorical,a=new Map,s=cr(e??null,o.childrenAccessor),l="function"==typeof t?t:null,c=l?s.map(e=>({__ssrTreeColorBy:l(e)})):s,u=l?"__ssrTreeColorBy":"string"==typeof t?t:void 0,d=t&&u?Me(c,u,i??r.colorScheme??n):void 0,h=!1!==o.showLabels,f=r.nodeStyle||o.nodeStyle,p=Fe(e=>{let r=e?.data||e;return{fill:o.colorByDepth?$f[Number(e?.depth||0)%$f.length]:t?l?Ae({__ssrTreeColorBy:l(r)},"__ssrTreeColorBy",d??void 0):Ae(r,t,d??void 0):bt(void 0,n,i,void 0,a),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}},o.styleRules,Le(t,o.valueAccessor),e=>e?.data||e);return{chartType:"cluster"===o.layout?"cluster":"tree",data:e,childrenAccessor:o.childrenAccessor,colorBy:t,colorByDepth:o.colorByDepth,orientation:o.orientation,showLabels:o.showLabels,nodeLabel:h?o.nodeLabel||o.nodeIdAccessor:void 0,colorScheme:i,...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth),nodeStyle:dr(p,f,Ve(o))}}},gy={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let n=Ke(r.theme).colors.categorical,a=new Map,s=cr(e??null,o.childrenAccessor),l="function"==typeof t?t:null,c=l?s.map(e=>({__ssrTreemapColorBy:l(e)})):s,u=l?"__ssrTreemapColorBy":"string"==typeof t?t:void 0,d=t&&u?Me(c,u,i??r.colorScheme??n):void 0,h=o.showLabels??r.showLabels,f=o.labelMode,p=void 0!==o.paddingTop?o.paddingTop:r.paddingTop,y=void 0!==p?p:!h||"parent"!==f&&"all"!==f?void 0:18,g=r.nodeStyle||o.nodeStyle,m=Fe(e=>{let r=e?.data||e;return{fill:o.colorByDepth?$f[Number(e?.depth||0)%$f.length]:t?l?Ae({__ssrTreemapColorBy:l(r)},"__ssrTreemapColorBy",d??void 0):Ae(r,t,d??void 0):bt(void 0,n,i,void 0,a),stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8}},o.styleRules,Le(t,o.valueAccessor),e=>e?.data||e);return{chartType:"treemap",data:e,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:t,colorByDepth:o.colorByDepth,showLabels:o.showLabels,labelMode:f,nodeLabel:h?o.nodeLabel||o.nodeIdAccessor:void 0,...null!=o.padding&&{padding:o.padding},...null!=y&&{paddingTop:y},colorScheme:i,...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth),nodeStyle:dr(m,g,Ve(o))}}},my={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5};import{scaleSequential as by}from"d3-scale";var xy={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let n="string"==typeof i?i:"blues",a=function(e,t,i){if(!Array.isArray(e))return;let r=e=>"function"==typeof t?t(e):null!=t?e?.properties?.[t]??e?.[t]:void 0,o=1/0,n=-1/0;for(let t of e){let e=r(t);null==e||!isFinite(e)||(o>e&&(o=e),e>n&&(n=e))}let a=[Number.isFinite(o)?o:0,Number.isFinite(n)?n:1],s=by(we(i)).domain(a);return{domain:a,colorScale:e=>s(e),valueAccessor:r}}(o.areas,o.valueAccessor,n),s=o.areaStyle??function(e,t){if(e)return i=>{let r=e.valueAccessor(i);return{fill:null!=r&&isFinite(r)?e.colorScale(r):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:t}}}(a,o.areaOpacity??1),l=o.styleRules?Fe(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},yr):s,c=!1!==r.showLegend&&a?{gradient:{colorFn:a.colorScale,domain:a.domain,label:"string"==typeof o.valueAccessor?o.valueAccessor:"value"}}:void 0;return{areas:o.areas,projection:o.projection||"equalEarth",areaStyle:l,valueAccessor:o.valueAccessor,colorScheme:n,graticule:o.graticule,fitPadding:o.fitPadding,...r,...void 0===r.legend&&c?{legend:c}:{}}}},vy={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let n=e||o.points,a=o.pointStyle??pr(n,t,i,{sizeBy:o.sizeBy,sizeRange:o.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),s=o.styleRules?Fe(a,o.styleRules,Le(t,o.sizeBy)):a;return{points:n,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",areas:o.areas,areaStyle:o.areaStyle||my,pointStyle:s,sizeBy:o.sizeBy,colorBy:t,colorScheme:i,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,...r}}},wy={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let n=e||o.points,a=o.pointStyle??pr(n,t,i,{pointRadius:"number"==typeof o.pointRadius?o.pointRadius:5,fillOpacity:.85,strokeWidth:1}),s=o.nodeIdAccessor||"id",l=o.cartogramLayout||("sparkline"===o.mode?"strip":"radial"),c="sparkline"===o.mode,u="strip"===l,d=o.styleRules?Fe(a,o.styleRules,Le(t)):a;return{points:n,lines:o.lines,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",pointStyle:e=>{let t="function"==typeof d?d(e):d,i="function"==typeof s?s(e):e[s],r=null!=i&&i+""==o.center+"",n="number"==typeof t.r?t.r:5;return{...t,fillOpacity:r?1:t.fillOpacity??.8,stroke:r?"var(--semiotic-text, #222)":t.stroke??"#fff",strokeWidth:r?1.25:t.strokeWidth??1,r:r?1.35*n:n}},colorBy:t,colorScheme:i,projection:o.projection||"mercator",graticule:o.graticule,fitPadding:o.fitPadding,projectionTransform:{center:o.center,centerAccessor:s,costAccessor:o.costAccessor,strength:o.strength??1,lineMode:o.lineMode||"straight",layout:l},...r,cartogramChrome:{showRings:o.showRings??!0,showNorth:o.showNorth??(!u&&!c),showRingLabels:o.showRingLabels??!u,costLabel:o.costLabel}}}},ky={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let n=(Array.isArray(e)?e:null)||o.flows||[],a=o.nodeIdAccessor||"id",s=o.valueAccessor||"value",l=o.xAccessor||"lon",c=o.yAccessor||"lat",u="function"==typeof l?l:e=>e[l],d="function"==typeof c?c:e=>e[c],h=(o.nodes||[]).map(e=>({...e,x:u(e),y:d(e)})),f=new Map;for(let e of h)f.set(e[a]+"",e);let p=o.edgeColorBy??t,y="function"==typeof p,g=n.map(e=>{if(!e||null==e.source||null==e.target)return null;let t=f.get(e.source+""),i=f.get(e.target+"");return t&&i?{...e,coordinates:[{x:t.x,y:t.y},{x:i.x,y:i.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",b=p?y?Me(g.map(e=>({[m]:p(e)})),m,i||"category10"):Me(g,p,i||"category10"):null,x=g.map(e=>Number(e[s]??0)).filter(e=>Number.isFinite(e)),v=x.length>0?Je(x):void 0,[w,k]=o.edgeWidthRange??[1,8];return{lines:g,points:h,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:o.lineType||"geo",flowStyle:o.flowStyle||"basic",areas:o.areas,areaStyle:o.areaStyle||my,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,colorScheme:i,lineStyle:fr({valueAccessor:s,valueDomain:v,edgeWidthRange:[w,k],resolveStroke:e=>p&&b?Ae(e,p,b):"#007bff",edgeOpacity:o.edgeOpacity??.6,edgeLinecap:o.edgeLinecap??"round",styleRules:o.styleRules}),pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...r}}};import{interpolateRgb as Ay}from"d3-interpolate";var Sy=864e5,My=e=>{let t=e.config,{plot:i}=e.dimensions;if(0>=i.width||0>=i.height)return{nodes:[]};let r=e=>{let i="function"==typeof t.dateAccessor?t.dateAccessor(e):e[t.dateAccessor];return i instanceof Date?i:new Date(i)},o=e=>{let i="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor];return Number(i)},n=new Map,a=null;for(let t of e.data){let e=r(t);if(!isFinite(e.getTime()))continue;null==a&&(a=e.getUTCFullYear());let i=gr(e),s=o(t);n.set(i,(n.get(i)??0)+(Number.isFinite(s)?s:0))}let s=t.year??a??(new Date).getUTCFullYear(),l=1/0,c=-1/0;for(let e of n.values())l>e&&(l=e),e>c&&(c=e);l===1/0&&(l=0,c=0);let[u,d]=t.colorRamp??[e.theme.semantic.surface??"#ebedf0",e.theme.semantic.primary??"#216e39"],h=e=>{if(c===l)return u;let t=(e-l)/(c-l);return Ay(u,d)(t)},f=t.gutter??2,p=t.labelInset??0,y=Math.min((i.width-p-53*f)/54,(i.height-6*f)/7);if(0>=y)return{nodes:[]};let g=new Date(Date.UTC(s,0,1)),m=g.getUTCDay(),b=new Date(g.getTime()-m*Sy),x=[];for(let e=0;54>e;e++)for(let t=0;7>t;t++){let r=new Date(b.getTime()+(7*e+t)*Sy);if(r.getUTCFullYear()!==s)continue;let o=gr(r),a=n.get(o),l=null==a?u:h(a);x.push({type:"rect",x:i.x+p+e*(y+f),y:i.y+t*(y+f),w:y,h:y,style:{fill:l,stroke:"none"},datum:{date:r,value:a??0}})}return{nodes:x}};import*as _y from"react";import{scaleLinear as $y}from"d3-scale";import{interpolateLab as Py}from"d3-interpolate";import{jsx as Ry,jsxs as Iy}from"react/jsx-runtime";var Ly=e=>{let t=e.config,{plot:i}=e.dimensions,r=t.fields??[];if(2>r.length||0>=i.width||0>=i.height)return{nodes:[]};if(0===e.data.length)return{nodes:[]};let o=Object.create(null);for(let i of r){let r=t.domains&&Object.prototype.hasOwnProperty.call(t.domains,i)?t.domains[i]:void 0;if(Array.isArray(r)&&r.length>=2&&"number"==typeof r[0]&&Number.isFinite(r[0])&&"number"==typeof r[1]&&Number.isFinite(r[1])){o[i]=[r[0],r[1]];continue}let n=1/0,a=-1/0;for(let t of e.data){let e=Number(t[i]);Number.isFinite(e)&&(n>e&&(n=e),e>a&&(a=e))}if(Number.isFinite(n)&&Number.isFinite(a))if(n===a){let e=Math.max(.01*Math.abs(n),.5);o[i]=[n-e,a+e]}else o[i]=[n,a];else o[i]=[0,1]}let n=!1!==t.showAxes,a=n?t.axisLabelPadding??24:8,s=n?18:8,l=r.map(e=>$y().domain(o[e]).range([i.y+i.height-s,i.y+a])),c=r.map((e,t)=>1===r.length?i.x+i.width/2:i.x+t/(r.length-1)*i.width),u=t.colorBy?"function"==typeof t.colorBy?t.colorBy:e=>(e[t.colorBy]??"")+"":null,d=t.opacity??.45,h=t.strokeWidth??1.25,f=e.theme.semantic.primary??"#3b6cb1",p=t.dimmedOpacity??.08,y=t.highlightFn,g=[],m=[];for(let i of e.data){let o=u?e.resolveColor(u(i)+""):f,n=!y||y(i),a=br(i,{predicate:y,baseOpacity:d,dimOpacity:p,brighten:.4}),s=n?m:g;for(let e=0;r.length-1>e;e++){let t=Number(i[r[e]]),u=Number(i[r[e+1]]);if(!Number.isFinite(t)||!Number.isFinite(u))continue;let d={type:"connector",x1:c[e],y1:l[e](t),x2:c[e+1],y2:l[e+1](u),style:{stroke:o,strokeWidth:y&&n?h+.75:h,opacity:a,fill:"none"},datum:i};s.push(d)}if(t.showPoints)for(let e=0;r.length>e;e++){let t=Number(i[r[e]]);if(!Number.isFinite(t))continue;let n={type:"point",x:c[e],y:l[e](t),r:2.5,style:{fill:o,stroke:"none",opacity:Math.min(1,a+.3)},datum:i};s.push(n)}}let b=null;if(n){let n=`var(--semiotic-border, ${e.theme.semantic.border??"#aaa"})`,u=`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`,d=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,h=i.y+a,f=i.y+i.height-s,p=[];for(let e=0;r.length>e;e++){let s=r[e],y=c[e],g=t.tickFormat&&Object.prototype.hasOwnProperty.call(t.tickFormat,s)?t.tickFormat[s]:void 0,m="function"==typeof g?g:e=>e.toLocaleString();p.push(_y.createElement("line",{key:"pc-axis-line-"+e,x1:y,x2:y,y1:h,y2:f,stroke:n,strokeWidth:1})),p.push(xr({keyId:"pc-axis-label-"+e,text:s,x:y,y:i.y+a-8,anchor:"middle",baseline:"auto",fontSize:12,fontWeight:600,color:u}));let[b,x]=o[s],v=5;for(let t=0;v>t;t++){let i=b+(x-b)*t/(v-1),r=l[e](i);p.push(_y.createElement("line",{key:`pc-tick-${e}-${t}`,x1:y-3,x2:y+3,y1:r,y2:r,stroke:n,strokeWidth:1}),xr({keyId:`pc-ticktext-${e}-${t}`,text:m(i),x:y+6,y:r+3,anchor:"start",baseline:"auto",fontSize:10,color:d}))}}b=_y.createElement(_y.Fragment,null,...p)}return{nodes:g.concat(m),overlays:b}},Ty={frameType:"xy",buildProps:(e,t,i,r,o)=>({chartType:"custom",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r,showAxes:o.frameProps?.showAxes??o.showAxes??!1,showLegend:r.showLegend??!!t})},Cy={frameType:"ordinal",buildProps:(e,t,i,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:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r,showAxes:o.frameProps?.showAxes??o.showAxes??!1})},Oy={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({...Cy.buildProps(e,t,i,r,o),customLayout:Ly,showAxes:!1})},Fy={frameType:"xy",buildProps:(e,t,i,r,o)=>({...Ty.buildProps(e,t,i,r,o),customLayout:My,showAxes:!1})};import*as Dy from"react";import{scaleLinear as zy}from"d3-scale";var Ny={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},Ey=1e-9,By=.005,Wy=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={...Ny,...e},this.random=Lr(this.options.seed)}init(e={}){this.options={...Ny,...e},this.random=Lr(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){let 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(Ey,e.mass??1),bodyCollisions:e.bodyCollisions??!0,...e.fixedPosition?{fixedPosition:Cr(e.fixedPosition)}:{},shape:Fr(e.shape),sleeping:!1,datum:e.datum,restitution:e.restitution,friction:e.friction,index:this.nextBodyIndex,sleepTime:0};Tr(t),this.nextBodyIndex+=1,this.bodies.set(e.id,t)}remove(e){for(let t of e){this.bodies.delete(t);for(let e of Array.from(this.activeSensors))Qr(e).bodyId===t&&this.activeSensors.delete(e)}}setColliders(e){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(let t of e)this.colliders.set(t.id,{...t,shape:Dr(t.shape),bodyFilter:Nr(t.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(e){let 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,i){let r=this.bodies.get(e);r&&(r.vx+=t/r.mass,r.vy+=i/r.mass,Tr(r),this.wake(r))}step(e=this.options.fixedDt){let t=Math.max(0,e);if(this.lastEvents=[],0===t)return;let i=this.sortedBodies();for(let e of i)e.prevX=e.x,e.prevY=e.y;this.applySprings(t);let r=this.options.maxVelocity;for(let e of i)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,Tr(e),r>0){let t=Math.sqrt(e.vx*e.vx+e.vy*e.vy);if(t>r){let i=r/t;e.vx*=i,e.vy*=i}}e.x+=e.vx*t,e.y+=e.vy*t}this.supportedThisStep.clear();let o=this.bodyPairKeys(i),n=this.sortedColliders().filter(e=>!e.sensor);for(let e=0;this.options.collisionIterations>e;e+=1)this.resolveBodyPairs(i,o,0===e),this.resolveColliders(i,n,0===e);this.updateSensors(i),this.updateSleeping(i,t)}settle(e=1200,t=this.options.fixedDt){let i=0;for(;e>i&&!this.allSleeping();)this.step(t),i+=1;return i}readState(e=[]){e.length=0;for(let 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,...t.fixedPosition?{fixedPosition:Cr(t.fixedPosition)}:{},shape:Fr(t.shape),sleeping:t.sleeping,datum:t.datum});return e}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(Qr)}allSleeping(){for(let 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(zr),colliders:this.sortedColliders().map(Er),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=Lr(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(e.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(let t of e.bodies){let e=zr(t);Tr(e),this.bodies.set(e.id,e),this.nextBodyIndex=Math.max(this.nextBodyIndex,e.index+1)}this.nextColliderIndex=0;for(let t of e.colliders){let e=Er(t);this.colliders.set(e.id,e),this.nextColliderIndex=Math.max(this.nextColliderIndex,e.index+1)}this.nextSpringIndex=0;for(let t of e.springs){this.springs.set(t.id,{...t,target:{...t.target}});let 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(let t of Array.from(this.springs.values()).sort((e,t)=>e.id.localeCompare(t.id))){let i=this.bodies.get(t.bodyId);if(!i||i.sleeping)continue;let r="point"===t.target.type?t.target:this.bodies.get(t.target.bodyId);if(!r)continue;let o=r.x-i.x,n=r.y-i.y,a=Math.sqrt(o*o+n*n);if(Ey>=a)continue;let s=o/a,l=n/a,c=(a-t.restLength)*t.stiffness+((("vx"in r?r.vx:0)-i.vx)*s+(("vy"in r?r.vy:0)-i.vy)*l)*t.damping;i.vx+=c*s*e/i.mass,i.vy+=c*l*e/i.mass}}resolveBodyPairs(e,t,i){for(let r of t){let[t,o]=r.split(":").map(Number),n=e[t],a=e[o];if(!n||!a)continue;let s=Ur(n,a);s&&(this.resolveDynamicCollision(n,a,s),i&&this.lastEvents.push({type:"contact",bodyId:n.id,otherId:a.id,sensor:!1}))}}bodyPairKeys(e){let t=Math.max(1,this.options.cellSize),i=new Map;for(let r=0;e.length>r;r+=1){if(!1===e[r].bodyCollisions)continue;let o=Xr(e[r]),n=Math.floor(o.minX/t),a=Math.floor(o.maxX/t),s=Math.floor(o.minY/t),l=Math.floor(o.maxY/t);for(let e=n;a>=e;e+=1)for(let t=s;l>=t;t+=1){let o=`${e}:${t}`,n=i.get(o);n?n.push(r):i.set(o,[r])}}let r=new Set;for(let t of Array.from(i.keys()).sort()){let o=i.get(t)??[];o.sort((e,t)=>e-t);for(let t=0;o.length>t;t+=1)for(let i=t+1;o.length>i;i+=1){let n=o[t],a=o[i];!1===e[n].bodyCollisions||!1===e[a].bodyCollisions||Gr(Xr(e[n]),Xr(e[a]))&&r.add(`${n}:${a}`)}}return Array.from(r).sort((e,t)=>{let[i,r]=e.split(":").map(Number),[o,n]=t.split(":").map(Number);return i===o?r-n:i-o})}resolveDynamicCollision(e,t,i){(e.fixedPosition||t.fixedPosition)&&(!e.sleeping&&null==e.fixedPosition?.x||!t.sleeping&&null==t.fixedPosition?.x?(e.sleeping||null!=e.fixedPosition?.y)&&(t.sleeping||null!=t.fixedPosition?.y)&&(i=Or(e,t,"y")):i=Or(e,t,"x")),e.sleeping&&this.contactOpposesGravity(i.nx,i.ny)&&this.supportedThisStep.add(t.id),t.sleeping&&this.contactOpposesGravity(-i.nx,-i.ny)&&this.supportedThisStep.add(e.id);let r=e.sleeping?0:1/e.mass,o=t.sleeping?0:1/t.mass,n=null==e.fixedPosition?.x?r:0,a=null==e.fixedPosition?.y?r:0,s=null==t.fixedPosition?.x?o:0,l=null==t.fixedPosition?.y?o:0,c=e.fixedPosition||t.fixedPosition?i.nx**2*(n+s)+i.ny**2*(a+l):r+o;if(Ey>=c)return;let u=Math.max(0,i.penetration-By)/c;e.x-=i.nx*u*n,e.y-=i.ny*u*a,t.x+=i.nx*u*s,t.y+=i.ny*u*l;let d=(t.vx-e.vx)*i.nx+(t.vy-e.vy)*i.ny;if(d>0)return;let h=Math.abs(d),f=-(1+Wr(e.restitution,t.restitution,this.options.restitution))*d/c,p=f*i.nx,y=f*i.ny;e.vx-=p*n,e.vy-=y*a,t.vx+=p*s,t.vy+=y*l,this.applyFriction(e,t,i,f,r,o),h>this.options.contactWakeSpeed&&(this.wake(e),this.wake(t))}applyFriction(e,t,i,r,o,n){let a=-i.ny,s=i.nx,l=(t.vx-e.vx)*a+(t.vy-e.vy)*s,c=null==e.fixedPosition?.x?o:0,u=null==e.fixedPosition?.y?o:0,d=null==t.fixedPosition?.x?n:0,h=null==t.fixedPosition?.y?n:0,f=e.fixedPosition||t.fixedPosition?a**2*(c+d)+s**2*(u+h):o+n;if(Ey>=Math.abs(l)||Ey>=f)return;let p=jr(e.friction,t.friction,this.options.friction),y=Br(-l/f,-r*p,r*p),g=y*a,m=y*s;e.vx-=g*c,e.vy-=m*u,t.vx+=g*d,t.vy+=m*h}resolveColliders(e,t,i){for(let r of e)for(let e of t){if(!eo(e,r)||!Gr(Xr(r),qr(e)))continue;let t=Kr(r,e);t&&(this.resolveStaticCollision(r,e,t),this.contactOpposesGravity(t.nx,t.ny)&&this.supportedThisStep.add(r.id),i&&this.lastEvents.push({type:"contact",bodyId:r.id,otherId:e.id,sensor:!1}))}}resolveStaticCollision(e,t,i){e.x+=i.nx*Math.max(0,i.penetration-By),e.y+=i.ny*Math.max(0,i.penetration-By);let r=e.vx*i.nx+e.vy*i.ny;if(0>r){let o=Wr(e.restitution,t.restitution,this.options.restitution);e.vx-=(1+o)*r*i.nx,e.vy-=(1+o)*r*i.ny;let n=-i.ny,a=i.nx,s=e.vx*n+e.vy*a,l=jr(e.friction,t.friction,this.options.friction);e.vx-=s*n*l,e.vy-=s*a*l}Tr(e)}updateSensors(e){let t=new Set,i=this.sortedColliders().filter(e=>e.sensor);for(let r of e){let e=Xr(r);for(let o of i){if(!eo(o,r)||!Gr(e,qr(o))||!Kr(r,o))continue;let i=Zr(o.id,r.id);t.add(i),this.activeSensors.has(i)||this.lastEvents.push({type:"sensor-enter",bodyId:r.id,sensorId:o.id})}}for(let e of Array.from(this.activeSensors).sort()){if(t.has(e))continue;let{sensorId:i,bodyId:r}=Qr(e);this.lastEvents.push({type:"sensor-exit",bodyId:r,sensorId:i})}this.activeSensors=t}updateSleeping(e,t){let i=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(let r of e)this.options.sleepSpeed>Math.sqrt(r.vx*r.vx+r.vy*r.vy)&&this.options.sleepSpeed*t>Math.sqrt((r.x-r.prevX)*(r.x-r.prevX)+(r.y-r.prevY)*(r.y-r.prevY))&&(!i||this.supportedThisStep.has(r.id))?(r.sleepTime+=t,!r.sleeping&&r.sleepTime>=this.options.sleepAfter&&(r.sleeping=!0,r.vx=0,r.vy=0,this.lastEvents.push({type:"sleep",bodyId:r.id}))):r.sleeping?this.wake(r):r.sleepTime=0}contactOpposesGravity(e,t){let{x:i,y:r}=this.options.gravity,o=Math.hypot(i,r);return 1e-9>=o||-.2>(e*i+t*r)/o}wake(e){e.sleeping&&this.lastEvents.push({type:"wake",bodyId:e.id}),e.sleeping=!1,e.sleepTime=0}nextRandom(){return this.random()}},jy=class{constructor(e={}){this.id="builtin",this.capabilities={...(new Wy).capabilities,engine:"builtin"},this.world=new Wy(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,i){this.world.applyImpulse(e,t,i)}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()}},Yy=["binId","targetBin","category","windowIndex","lane","group"],Xy=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;let t=this.nextIndex;this.nextIndex+=1;let i=so(ao(this.config.binAccessor,e,t))??function(e){for(let t of Yy){let i=so(no(e,t));if(i)return i}return"sediment"}(e),r=so(ao(this.config.labelAccessor,e,t))??i,o=function(e,t,i){if("number"==typeof e)return e;let r="function"==typeof e?e(t,i):"string"==typeof e?no(t,e):1,o="number"==typeof r?r:Number(r);return Number.isFinite(o)?o:1}(this.config.valueAccessor,e,t),n=Math.max(0,Math.floor(this.config.retainBodyIds??12)),a=this.bins.get(i);return a||(a={id:i,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(i,a)),a.label=r,a.lastBodyId=e.id,a.lastDatum=e.datum,io(a.x,e.x),io(a.y,e.y),io(a.value,o),n>0&&(a.bodyIds.push(e.id),a.bodyIds.length>n&&(a.bodyIds=a.bodyIds.slice(a.bodyIds.length-n))),lo(a)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(lo)}restore(e=[]){this.bins.clear();for(let 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:oo(t.x),y:oo(t.y),value:oo(t.value)});this.nextIndex=e.reduce((e,t)=>e+t.count,0)}totals(){let 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)}}},qy={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},Gy={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0},Vy={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"},Hy=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(e){return this.listeners.add(e),()=>this.listeners.delete(e)}record(e,t){let i=Mo(e,t,this.revisions);this.revisions=i.revisions,this.latest=i;for(let e of[...this.listeners])e();return i}};import{quadtree as Uy}from"d3-quadtree";var Ky=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(e,t,i,r,o,n=0,a){let s=this.ensure(e,t);if(!s)return null;let l=null,c=1/0,u=Math.max(0,a?.searchRadius??Math.max(0,n)+this.maxSearchRadius),d=r-u,h=r+u,f=o-u,p=o+u;return s.visit((e,t,s,u,y)=>{if(d>u||t>h||f>y||s>p)return!0;if(e.length)return!1;let g=e;for(;g;){let e=g.data;if(e&&(!a?.include||a.include(e))){let t=a?.distanceSquared?a.distanceSquared(e,r,o):vo(e,r,o,Math.max(0,n));null!=t&&(c>t||t===c&&i.indexOf(e.id)>i.indexOf(l?.id??""))&&(l=e,c=t)}g=g.next}return!1}),l}ensure(e,t){if(this.tree&&this.revision===t)return this.tree;let i=e.readState();return 0===i.length?(this.tree=null,this.maxSearchRadius=0,this.revision=t,null):(this.maxSearchRadius=i.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=Uy().x(e=>e.x).y(e=>e.y).addAll(i),this.revision=t,this.tree)}},Zy=["data","scene-geometry","data-paint","accessibility","evidence"],Qy=["scene-geometry","data-paint","accessibility","evidence"],Jy=["overlay","accessibility","evidence"],eg=(e,t)=>({retainedData:e,invalidations:t}),tg=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ig=["scene-geometry","data-paint","accessibility","evidence"],rg=[],og={engine:eg("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:eg("preserve",ig),colliders:eg("preserve",ig),sediment:eg("preserve",ig),bodyBudget:eg("preserve",tg),bodyLimit:eg("preserve",tg),eviction:eg("preserve",tg),fixedDt:eg("preserve",rg),maxDeltaSeconds:eg("preserve",rg),maxSubsteps:eg("preserve",rg),settleStepLimit:eg("preserve",rg),timeScale:eg("preserve",rg),observation:eg("preserve",rg)},ng=eg("preserve",tg),ag=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"],sg=class{constructor(){this.seconds=0,this.speed=8,this.scratch=[]}setKernelOptions(e){this.speed=function(e){let 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,i){if(i>0)return void(this.seconds=0);let r=e.readState(this.scratch),o=this.speed*this.speed,n=!0;for(let e of r)if(!e.sleeping&&e.vx*e.vx+e.vy*e.vy>=o){n=!1;break}this.seconds=n?this.seconds+Math.max(0,t):0}},lg=class{constructor(e={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new Ky,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new Hy,this.simulationState="settled",this.visible=!0,this.quiescence=new sg;let{bodyBudget:t,colliders:i,engine:r,kernel:o,observation:n,sediment:a,...s}=e;this.config={...qy,...s},this.configInput={...e},this.bodyBudget=t??{},this.engineInput=r,this.observation=uo(n),this.sediment=new Xy(a??!1),this.world=to(r,{fixedDt:this.config.fixedDt,...o}),this.quiescence.setKernelOptions(o),i&&this.world.setColliders(go(i))}updateConfig(e){let t=function(e,t){return Object.keys(e).filter(i=>"kernel"===i?!$o(e.kernel,t.kernel):e[i]!==t[i])}(e,this.configInput),{colliders:i,bodyBudget:r,engine:o,kernel:n,observation:a,sediment:s,...l}=e;if(this.config={...this.config,...l},void 0!==r&&(this.bodyBudget=r,!1===r&&(this.bodyBudgetObservationKey="ok")),o&&o!==this.engineInput){let e=this.world.snapshot();this.world.dispose(),this.engineInput=o,this.world=to(o,e.options),this.world.restore(e),this.revision+=1}if(n&&!$o(n,this.configInput.kernel)){let e=this.world.snapshot(),t={...e.options,...n,gravity:{...e.options.gravity,...n.gravity}};this.world.restore({...e,options:t}),this.quiescence.setKernelOptions(t),this.revision+=1}a&&(this.observation=uo(a,this.observation)),this.sediment.updateConfig(s),i&&(this.world.setColliders(go(i)),this.revision+=1),this.configInput={...this.configInput,...e};let c=_o(t);this.updateResults.record({kind:"config",keys:t},c.invalidations)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setColliders(e){this.world.setColliders(go(e)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},_o(["colliders"]).invalidations)}enqueue(e,t){let i=Array.isArray(e)?e:[e],r=t?function(e,t={}){let i=fo(t.startAt)??0,r=t.pacing??"immediate";if("arrival"===r){let r=e.map((e,i)=>function(e,t,i){return"function"==typeof i?fo(i(e,t)):"string"==typeof i?fo(po(e,i)):fo(e.spawnAt)??fo(po(e,"arrivalTime"))??fo(po(e,"timestamp"))??fo(po(e,"time"))??fo(po(e,"eventTime"))}(e,i,t.timeAccessor)),o=r.filter(e=>null!=e),n=o.length>0?Math.min(...o):0,a=fo(t.timeScale)??1,s=a>0?a:1;return e.map((e,t)=>{let o=r[t],a=null==o?0:Math.max(0,o-n);return{...ho(e),spawnAt:i+a/s}})}if("object"==typeof r){let t=fo(r.ratePerSec);if(t&&t>0)return e.map((e,r)=>({...ho(e),spawnAt:i+r/t}))}return e.map(e=>({...ho(e),spawnAt:i}))}(i,{...t,startAt:t.startAt??this.elapsedSeconds}):i;for(let e of r)this.queue.push({...ho(e),sequence:this.nextSequence,spawnAt:e.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(bo),r.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:r.length},r.length?Zy:[])}enqueueWithResult(e,t){return this.enqueue(e,t),this.updateResults.last}spawnNow(e){this.spawnOne(ho(e)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},Zy)}materializeDueSpawns(){let e=this.revision,t=[],i=[];return this.spawnDue(t,i),0===t.length||(this.observeBodyBudget(i),this.evictOverflow(i),this.syncSimulationState(i),this.revision+=1,this.updateResults.record({kind:"enqueue",count:t.length},this.revision!==e?Zy:[])),t}clear(){let 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"},Zy)}tick(e,t){let i=this.revision,r=[],o=[],n=[],a=[],s=[];if(this.paused||!this.visible){let e=this.result(0,r,o,n,a,s,!1);return this.updateResults.record({kind:"tick",count:0},[]),e}let l=Math.max(0,Math.min(Number.isFinite(e)?e:0,this.config.maxDeltaSeconds))*this.config.timeScale;this.spawnDue(r,s);let c=this.observeBodyBudget(s),u=this.evictOverflow(s);o.push(...u.evicted),n.push(...u.sedimented),this.syncSimulationState(s),r.length>0&&this.quiescence.reset(),this.accumulator+=l;let d=this.stepObserver(t,{spawned:r,evicted:o,sedimented:n,events:a,observations:s}),h=l>0?Math.floor((this.accumulator+1e-9*this.config.fixedDt)/this.config.fixedDt):0,{steps:f,budget:p}=Ro(this.settleHost(),Math.min(h,this.config.maxSubsteps),{spawned:r,evicted:o,sedimented:n,events:a,observations:s},{stopAtRest:!1,shouldStop:()=>this.paused||!this.visible,afterStep:d});this.accumulator=Math.max(0,this.accumulator-f*this.config.fixedDt),f===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),(f>0||r.length>0||o.length>0||n.length>0||a.length>0)&&(this.revision+=1);let y=this.result(f,r,o,n,a,s,void 0,p??c);return this.updateResults.record({kind:"tick",count:f},this.revision!==i?r.length||o.length||n.length?Zy:Qy:[]),y}settle(e=this.config.settleStepLimit){return this.runSettle(e,!1).steps}settleWithObservations(e=this.config.settleStepLimit,t){return this.runSettle(e,!0,t)}stepObserver(e,t){return function(e,t){if(!e)return;let i=["spawned","evicted","sedimented","events","observations"],r={spawned:0,evicted:0,sedimented:0,events:0,observations:0},o=o=>{let n=t(o),a={...n,spawned:n.spawned.slice(r.spawned),evicted:n.evicted.slice(r.evicted),sedimented:n.sedimented.slice(r.sedimented),events:n.events.slice(r.events),observations:n.observations.slice(r.observations)};for(let e of i)r[e]=n[e].length;e.onStep(a)};return o(0),()=>o(1)}(e,e=>(e&&(this.revision+=1),this.result(e,t.spawned,t.evicted,t.sedimented,t.events,t.observations)))}settleHost(){return{fixedDt:this.config.fixedDt,queueSize:()=>this.queue.length,atRest:()=>this.atRest(),advanceTime:e=>{this.elapsedSeconds+=e},spawnDue:(e,t)=>this.spawnDue(e,t),observeBodyBudget:e=>this.observeBodyBudget(e),evictOverflow:e=>this.evictOverflow(e),step:e=>this.world.step(e),drainEvents:()=>this.world.events(),observeKernelEvents:(e,t)=>this.observeKernelEvents(e,t),observeSensorTransitions:e=>this.observeSensorTransitions(e),refreshQuiescence:(e,t)=>this.quiescence.refresh(this.world,e,t)}}runSettle(e,t,i){let r=this.revision,o=[],n=[],a=[],s=[],l=t?[]:void 0;if(t&&(this.paused||!this.visible)){let e=this.result(0,o,n,a,s,l??[],!1);return this.updateResults.record({kind:"settle",count:0},[]),e}this.spawnDue(o,l);let c=this.observeBodyBudget(l),u=this.evictOverflow(l);n.push(...u.evicted),a.push(...u.sedimented),this.syncSimulationState(l),o.length>0&&this.quiescence.reset();let d=t?{spawned:o,evicted:n,sedimented:a,events:s,observations:l}:{spawned:o},h=this.stepObserver(i,{spawned:o,evicted:n,sedimented:a,events:s,observations:l??[]}),{steps:f,budget:p}=Ro(this.settleHost(),e,d,{afterStep:h,continueWhile:i?.continueWhile,shouldStop:t?()=>this.paused||!this.visible:void 0}),y=o.length+n.length+a.length>0;(f>0||y||s.length>0)&&(this.revision+=1);let g=this.result(f,o,n,a,s,l??[],void 0,p??c);return this.updateResults.record({kind:"settle",count:f},this.revision===r?[]:y?Zy:Qy),g}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={}){let{baselineY:i=0,binWidth:r=24,gap:o=2,maxHeight:n=80,value:a="count",x:s}=t,l=Math.max(1,...e.map(e=>e[a]));return e.map((e,t)=>{let c=Math.max(0,e[a]/l*n),u=s?.(e,t)??t*(r+o);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:i-c,width:r,height:c,meanX:e.x.mean,meanY:e.y.mean}})}(this.readSediment(),e)}hitTest(e,t,i=0,r){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,e,t,i,r)}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){let{timestamp:t,chartType:i,chartId:r,...o}=e,n={...o,timestamp:t??this.elapsedSeconds,chartType:i??this.observation.chartType,chartId:r??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(e){return this.updateResults.subscribe(e)}version(){return this.revision}setPaused(e){let t=this.paused!==e;this.paused=e,this.syncSimulationState(),this.updateResults.record({kind:"pause"},t?Jy:[])}setVisible(e){let t=this.visible!==e;this.visible=e,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},t?Jy:[])}remove(e){let t=new Set(e),i=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);let o=e.filter(e=>i.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?Zy:[]),o}setConstraint(e){let t=this.world.setConstraint(e);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},Qy),t}removeConstraint(e){this.world.removeConstraint(e),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},Qy)}applyImpulse(e,t,i){this.world.applyImpulse(e,t,i),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[e]},Qy)}nextRandom(){return this.world.nextRandom()}controls(){return e=this,{applyImpulse:(t,i,r)=>e.applyImpulse(t,i,r),clear:()=>e.clear(),hitTest:(t,i,r)=>e.hitTest(t,i,r),pause:()=>e.setPaused(!0),push:(t,i)=>e.enqueue(t,i),pushMany:(t,i)=>e.enqueue(t,i),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(){let e=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:mo(this.bodyBudget),config:{...this.config,kernel:xo(e.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(yo),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:e}}restore(e){let t=this.simulationState;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:mo(e.bodyBudget??{}),kernel:xo(e.world.options)},this.bodyBudget=mo(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(yo).sort(bo),this.revision=e.revision,this.sediment.restore(e.sediment??[]),this.simulationState=e.simulationState??Po(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"},Zy),this.simulationState!==t&&this.observation.onSimulationStateChange?.(this.simulationState,t)}spawnDue(e,t){for(;this.queue.length>0&&this.elapsedSeconds+1e-9*this.config.fixedDt>=this.queue[0].spawnAt;){let i=this.queue.shift();if(!i)return;this.spawnOne(i,t),e.push(i.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(let t of e.springs??[])this.world.setConstraint({...t,bodyId:e.id});let i=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:i?.datum??e.datum,x:i?.x??e.x,y:i?.y??e.y},t)}result(e,t,i,r,o,n,a,s=this.evaluateBodyBudget()){this.syncSimulationState(n);let l=this.world.allSleeping();return{budget:s,elapsedSeconds:this.elapsedSeconds,evicted:i,events:o,observations:n,queueSize:this.queue.length,revision:this.revision,shouldContinue:a??(!this.paused&&this.visible&&(this.queue.length>0||!this.atRest())),sleeping:l,sedimented:r,spawned:t,steps:e}}observeKernelEvents(e,t){!function(e,t,i){if(0===t.length)return;let r=new Map(e.readState().map(e=>[e.id,e]));for(let e of t){if("sleep"!==e.type)continue;let t=r.get(e.bodyId);i.emit({type:"physics-settle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.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,i){let r=new Set(e.activeSensorPairs().map(e=>`${e.sensorId}\0${e.bodyId}`));if(0===r.size&&0===t.size)return r;let o=new Map(e.readState().map(e=>[e.id,e])),n=(e,t)=>{let{sensorId:r,bodyId:n}=wo(t),a=i.observation.sensors[r],s=o.get(n);i.emit({type:"enter"===e?a?.enterType??"physics-bin-enter":a?.exitType??"physics-bin-exit",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:n,datum:s?.datum,x:s?.x,y:s?.y,sensorId:r,binId:a?.binId??r})};for(let e of Array.from(r).sort())t.has(e)||n("enter",e);for(let e of Array.from(t).sort())r.has(e)||n("exit",e);return r}(this.world,this.activeSensorPairs,this.observationContext(e))}removeActiveSensorPairsForBodies(e){!function(e,t){for(let i of e)t.has(wo(i).bodyId)&&e.delete(i)}(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){let t=Math.max(0,Math.floor(e.liveBodies)),i=Math.max(0,Math.floor(e.queuedBodies??0)),r=t+i,o=co(e.bodyLimit),n=co(e.engineMaxBodiesHint),a=function(e,t,i){if(!1===i)return;let r=co(i?.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,n,e.options),s=null==o?0:Math.max(0,t-o),l=s>0?"overflow":null==a||a>r?"ok":"warning";return{action:"overflow"!==l?"continue":e.sedimentEnabled?"sediment":e.evictionEnabled?"evict":"retain",bodyLimit:o,engineMaxBodiesHint:n,liveBodies:t,overflow:s,projectedBodies:r,queuedBodies:i,state:l,warnAt:a}}({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){let t=this.evaluateBodyBudget();if("ok"===t.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",t;let i=`${t.state}:${t.action}`;return i===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=i,function(e,t){t.emit({type:"overflow"===e.state?"physics-budget-overflow":"physics-budget-warning",timestamp:t.elapsedSeconds,chartType:t.observation.chartType,chartId:t.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,this.observationContext(e))),t}syncSimulationState(e){let t=Po(this.paused,this.visible,this.queue.length>0,this.atRest());if(t===this.simulationState)return;let i=this.simulationState;this.simulationState=t,function(e,t,i){i.observation.onSimulationStateChange?.(t,e),("running"===t||"settled"===t)&&i.emit({type:"running"===t?"sim-active":"sim-idle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,simulationState:t,previousSimulationState:e})}(i,t,this.observationContext(e))}evictOverflow(e){let{evicted:t,sedimented:i,liveBodyOrder:r}=function(e,t,i,r,o,n){let a={evicted:[],sedimented:[],liveBodyOrder:o};if(!1===i)return a;let s=Math.max(0,Math.floor(r));if(!Number.isFinite(s))return a;let l=o.length-s;if(0>=l)return a;let c=function(e,t,i){if("sleeping-first"!==t)return i.slice();let r=new Map(e.readState().map(e=>[e.id,e.sleeping])),o=[],n=[];for(let e of i)r.get(e)?o.push(e):n.push(e);return[...o,...n]}(e,i,o).slice(0,l);if(0===c.length)return a;let u=function(e,t,i,r){let o=new Map(e.readState().map(e=>[e.id,e])),n=[];for(let e of i){let i=o.get(e);if(!i)continue;let a=t.add(i);a&&(n.push(e),r.emit({type:"physics-sediment",timestamp:r.elapsedSeconds,chartType:r.observation.chartType,chartId:r.observation.chartId,bodyId:e,datum:i.datum,x:i.x,y:i.y,binId:a.id,count:a.count,total:a.total}))}return n}(e,t,c,n);e.remove(c);let d=new Set(c);return{evicted:c,sedimented:u,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:i}}};import{scaleLinear as cg}from"d3-scale";import{scaleLinear as ug}from"d3-scale";import{scaleLinear as dg}from"d3-scale";var hg="gauntlet-negative",fg={left:28,top:76,rightInset:30,thickness:8},pg=1e-9,yg=[900,520],gg=[{id:"product",label:"Products",side:"bottom",order:0},{id:"retained",label:"Retained",side:"bottom",order:1},{id:"residue",label:"Residue",side:"left",order:2},{id:"failed",label:"Failed",side:"right",order:3},{id:"recovered",label:"Recovered",side:"right",order:4}],mg=new Set(["queued","active","transformed","consumed","retained","ejected","failed","recovered"]),bg=1e-9,xg=Yn;import*as vg from"react";import{curveMonotoneX as wg,curveMonotoneY as kg,curveCardinal as Ag,curveCatmullRom as Sg,curveStep as Mg,curveStepBefore as _g,curveStepAfter as $g,curveBasis as Pg,curveNatural as Rg}from"d3-shape";import{jsx as Ig,jsxs as Lg}from"react/jsx-runtime";import{Fragment as Tg,jsx as Cg,jsxs as Og}from"react/jsx-runtime";var Fg="var(--semiotic-text, #26323a)",Dg="var(--semiotic-text-secondary, #6c7377)",zg="var(--semiotic-primary, #b8792d)",Ng="var(--semiotic-danger, #9f3d35)",Eg="var(--semiotic-success, #356b63)";import{Fragment as Bg,jsx as Wg,jsxs as jg}from"react/jsx-runtime";import{Fragment as Yg,jsx as Xg,jsxs as qg}from"react/jsx-runtime";var Gg={flow:{fill:"rgba(59, 130, 246, 0.14)",stroke:"rgba(96, 165, 250, 0.7)",accent:"#60a5fa"},capacity:{fill:"rgba(251, 146, 60, 0.18)",stroke:"rgba(251, 146, 60, 0.85)",accent:"#fb923c"},portal:{fill:"rgba(244, 114, 182, 0.14)",stroke:"rgba(244, 114, 182, 0.7)",accent:"#f472b6"},absorb:{fill:"rgba(52, 211, 153, 0.18)",stroke:"rgba(52, 211, 153, 0.8)",accent:"#34d399"}};import{jsx as Vg}from"react/jsx-runtime";import{jsx as Hg,jsxs as Ug}from"react/jsx-runtime";import{Fragment as Kg,jsx as Zg,jsxs as Qg}from"react/jsx-runtime";var Jg={margin:(e,t)=>t.compactMode?"sparkline"===e.mode?{top:2,right:2,bottom:2,left:2}:{top:8,right:8,bottom:8,left:8}:{top:0,right:0,bottom:0,left:0}},em=["#356b63","#a34b43","#c08b38","#3e5f83","#785b7c","#6e7740","#8f5c3a","#41717b"],tm={frameType:"physics",layout:Jg,buildProps:(e,t,i,r,o)=>{let n=r.size??[600,400],a=o.bins??21,s=o.seed??1,l=Math.max(1,Math.round(o.pegRows??a-1)),c="mechanical"===(o.simulationMode??o.mode),u=c?function(e){let t=Math.max(2,Math.round(e.bins)),i=Math.max(1,Math.round(e.pegRows??t-1)),r=Math.max(1,Math.round(e.count??Math.max(64,4*t))),o=_r(Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,0,1),n=Rr(e.seed??1),a=e.idPrefix??"mechanical";return Array.from({length:r},(e,t)=>{let r=0;for(let e=0;i>e;e+=1)n()<o&&(r+=1);let s=i/2;return{id:`${a}-${t}`,value:r,mechanical:!0,pegRows:i,branchProbability:o,pathRights:r,side:s>r?"left":r>s?"right":"center"}})}({bins:a,branchProbability:o.branchProbability,count:o.mechanicalCount,pegRows:l,seed:s}):Array.isArray(e)?e:[],d=function(e){let{data:t,valueAccessor:i,bins:r,ballRadius:o,seed:n,size:a,valueExtent:s}=e,{rows:l}=Ir(t,"galton"),c=vr(a),u=l.map((e,t)=>Mr(Sr(e,t,i))).filter(e=>null!=e),d=function(e){if(!e)return;let t=Mr(e[0]),i=Mr(e[1]);return null!=t&&null!=i?t>i?[i,t]:[t,i]:void 0}(s),h=d?.[0]??(u.length?Math.min(...u):0),f=d?.[1]??(u.length?Math.max(...u):1),p=f===h?1:f-h,y=zy().domain([0,r]).range([c.plot.x,c.plot.x+c.plot.width]),g=Array.from({length:r},()=>0),m=[];l.forEach((e,t)=>{let n=Mr(Sr(e,t,i));if(null==n)return;let a=Math.max(0,Math.min(r-1,Math.floor((n-h)/p*r)));g[a]+=1,m.push({id:(e.id??"galton-"+t)+"",x:y(a+.5),y:c.plot.y+o+2,vx:8*(t%5-2),vy:0,mass:1,shape:{type:"circle",radius:o},datum:{...e,value:n,bin:a}})});let b=c.plot.y+c.plot.height;return{config:Ar(n,[...ko({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...Ao({idPrefix:"galton-bin",count:r,domainStart:0,domainStep:1,xScale:y,yTop:c.plot.y-400,yBottom:b,wallThickness:6})],"GaltonBoardChart"),initialSpawns:m,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:g.map((e,t)=>({label:t+1+"",value:e})),metadata:{kind:"galton-board",bins:r,plot:c.plot,valueExtent:[h,f]}}}({data:u,valueAccessor:o.valueAccessor||"value",bins:a,ballRadius:o.ballRadius??("sparkline"===o.mode?1.5:"context"===o.mode?4:6),seed:s,size:n,valueExtent:c?[0,l]:o.valueExtent});return{...r,config:d.config,initialSpawns:va(d.initialSpawns),projectionRows:d.projectionRows,foregroundGraphics:wa(na(d.projectionRows,a,ka(r,o,"showProjection"),d.metadata,o.referenceLines),r.foregroundGraphics),bodyStyle:kr(t||o.colorBy||(c?"side":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},im={frameType:"physics",layout:Jg,buildProps:(e,t,i,r,o)=>{let n=r.size??[600,400],a=function(e){let{data:t,timeAccessor:i,arrivalAccessor:r,windows:o,watermark:n,watermarkAtArrivalAccessor:a,ballRadius:s,seed:l,size:c,timeExtent:u,timeScale:d=1}=e,{events:h,watermarkValue:f}=function(e){let{windowSize:t,watermark:i,watermarkAtArrivalAccessor:r}=e;if(!Number.isFinite(t)||0>=t)throw new RangeError("EventDrop windows.size must be a finite positive number");let{rows:o}=Ir(e.data,"event"),n=o.flatMap((t,i)=>{let r=Mr(Sr(t,i,e.timeAccessor));return null==r?[]:[{datum:t,index:i,eventTime:r,arrivalTime:Mr(Sr(t,i,e.arrivalAccessor))??r,watermarkAtArrival:0,late:!1}]}),a="function"==typeof i?null:Mr(i?.value),s="function"==typeof i?t:Mr(i?.delay)??t,l=-1/0,c=-1/0;for(let e of n.slice().sort((e,t)=>e.arrivalTime-t.arrivalTime||e.index-t.index)){l=Math.max(l,e.eventTime);let o="function"==typeof i?Mr(i(l)):l-s;c=a??Math.max(c,o??l-t);let n=r?Mr(Sr(e.datum,e.index,r)):null;e.watermarkAtArrival=n??c,e.late=e.watermarkAtArrival>=(Math.floor(e.eventTime/t)+1)*t}return{events:n,watermarkValue:n.length?c:a??-s}}({data:t,timeAccessor:i,arrivalAccessor:r,watermark:n,watermarkAtArrivalAccessor:a,windowSize:o.size}),p=vr(c),y=h.map(e=>e.eventTime),g=h.length?Math.min(...h.map(e=>e.arrivalTime)):0,m=Mr(u?.[0]),b=Mr(u?.[1]),x=y.length?Math.min(...y):0,v=y.length?Math.max(...y):x+o.size,w=Math.min(m??x,x),k=Math.max(b??v,v),A=Math.floor(w/o.size)*o.size,S=Math.max(1,Math.ceil((k-A+o.size)/o.size)),M=Math.max(0,Math.min(S,Array.from({length:S},(e,t)=>t).reduce((e,t)=>A+(t+1)*o.size>f?e:e+1,0))),_=function(e,t){let i=Math.max(5*t,Math.min(92,.13*e.plot.width));return{gutter:{x:e.plot.x,y:e.plot.y,width:i,height:e.plot.height},windowPlot:{x:e.plot.x+i,y:e.plot.y,width:Math.max(40,e.plot.width-i),height:e.plot.height},wallTop:e.plot.y+.48*e.plot.height}}(p,s),$=A+S*o.size,P=cg().domain([A,$]).range([_.windowPlot.x,_.windowPlot.x+_.windowPlot.width]),R=Array.from({length:S},()=>({value:0,secondary:0})),I=[];h.forEach(({datum:e,index:t,eventTime:i,arrivalTime:r,watermarkAtArrival:n,late:a})=>{let l=Math.max(0,Math.min(S-1,Math.floor((i-A)/o.size)));R[l].value+=a?0:1,R[l].secondary+=a?1:0,I.push({id:(e.id??"event-"+t)+"",x:Lo(i,l,a,{windowStart:A,windowSize:o.size,gutter:_.gutter,closedWindowCount:M,windowPlot:_.windowPlot,windowCount:S},s),y:p.plot.y+s+2,vx:0,vy:0,mass:1,friction:.02,spawnAt:r,shape:{type:"circle",radius:s},datum:{...e,eventTime:i,arrivalTime:r,windowIndex:l,watermarkAtArrival:n,late:a}})});let L=p.plot.y+p.plot.height,T={closedWindowCount:M,gutter:_.gutter,plot:p.plot,windowCount:S,windowPlot:_.windowPlot,windowSize:o.size,windowStart:A},C=function(e,t){let i=Math.max(0,Math.min(e.windowCount,e.closedWindowCount));if(!i)return[];let r=e.windowStart,o=e.windowStart+e.windowCount*e.windowSize,n=cg().domain([r,o]).range([e.windowPlot.x,e.windowPlot.x+e.windowPlot.width]),a=n(e.windowStart+i*e.windowSize),s=e.windowPlot.x,l=t+Math.max(18,Math.min(.3*e.windowPlot.height,a-s)),c=e=>a===s?t:l+(e-s)/(a-s)*(t-l),u=[];for(let t=0;i>t;t+=1){let i=e.windowStart+t*e.windowSize,r=i+e.windowSize,o=n(i),a=n(r);u.push({id:"eventdrop-lid-"+t,windowIndex:t,x1:o,y1:c(o),x2:a,y2:c(a)})}return u}(T,p.plot.y+.28*p.plot.height);for(let e of I){let t=e.datum;e.y=Io({...T,lidSegments:C},t.windowIndex,t.late,s)}let O=function(e){let{count:t,idPrefix:i,wallThickness:r,xScale:o,yBottom:n,yTop:a,yTopForIndex:s}=e;return Array.from({length:t+1},(e,t)=>{let l=Math.min(n-1,s?.(t)??a),c=Math.max(1,n-l);return{id:`${i}-wall-${t}`,shape:{type:"aabb",x:o(t),y:l+c/2,width:r,height:c}}})}({idPrefix:"eventdrop-window",count:S,xScale:e=>P(A+e*o.size),yTop:_.wallTop,yTopForIndex:e=>{let t=(e=>{if(0>e||e>M)return null;let t=0===e?C[0]?.y1:C[e-1]?.y2??C[e]?.y1;return"number"==typeof t&&Number.isFinite(t)?t:null})(e);return null==t?_.wallTop:t+1.25*s},yBottom:L,wallThickness:6});return{config:Ar(l,[...ko({x:p.plot.x,y:p.plot.y,width:p.plot.width,height:p.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...O,...C.map(e=>({id:e.id,shape:{type:"segment",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,thickness:Math.max(4,.42*s)},friction:.02,restitution:.01}))],"EventDropChart",{friction:.08}),initialSpawns:I,initialSpawnPacing:{pacing:"arrival",timeAccessor:e=>{let t=e.datum,i=M>t.windowIndex;return i&&!t.late||!i&&t.late?g:t.arrivalTime},timeScale:d},projectionRows:R.map((e,t)=>({label:`${A+t*o.size}-${A+(t+1)*o.size}`,value:e.value,secondary:e.secondary})),metadata:{kind:"event-drop",closedWindowCount:M,gutter:_.gutter,lidSegments:C,lateCount:R.reduce((e,t)=>e+t.secondary,0),plot:p.plot,windowPlot:_.windowPlot,windowWalls:O.map(({id:e,shape:t})=>({id:e,x:t.x-t.width/2,y:t.y-t.height/2,width:t.width,height:t.height})),watermarkValue:f,windowCount:S,windowSize:o.size,windowStart:A}}}({data:Array.isArray(e)?e:[],timeAccessor:o.timeAccessor||"time",arrivalAccessor:o.arrivalAccessor||"arrivalTime",watermarkAtArrivalAccessor:o.watermarkAtArrivalAccessor,windows:o.windows||{size:10},watermark:o.watermark,ballRadius:o.ballRadius??7,seed:o.seed??1,size:n,timeExtent:o.timeExtent,timeScale:o.timeScale??1});return{...r,config:a.config,initialSpawns:va(a.initialSpawns),projectionRows:a.projectionRows,foregroundGraphics:wa(aa(a.projectionRows,a.metadata,ka(r,o,"showProjection")),r.foregroundGraphics),bodyStyle:kr(t||o.colorBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||o.timeAccessor||"time"})}}},rm={frameType:"physics",layout:Jg,buildProps:(e,t,i,r,o)=>{let n=r.size??[600,400],a="mechanical"===(o.simulationMode??o.mode),s=function(e){function t(e){let t=f.get(e);return null==t&&(t=h.length,h.push(e),f.set(e,t)),t}let{data:i,categoryAccessor:r,valueAccessor:o,unitValue:n,ballRadius:a,seed:s,size:l}=e,c=$r(n,1),{rows:u}=Ir(i,"pile"),d=vr(l),h=[],f=new Map,p=new Map,y=[];u.forEach((e,i)=>{t((Sr(e,i,r)??"unknown")+"")});let g=Math.max(1,h.length),m=To(d.plot,g,a),b=Math.max(0,m.tubeWidth/2-a-1),x=h.map(()=>[]);u.forEach((e,i)=>{let n=(Sr(e,i,r)??"unknown")+"",s=t(n),l=o?Mr(Sr(e,i,o)):1,u=Math.max(0,l??0);p.set(n,(p.get(n)??0)+u);let h=function(e,t){let i=e/t,r=Math.round(i);return Math.ceil(r>0&&Number.EPSILON*i*4>=Math.abs(i-r)?r:i)}(u,c),f=m.centerX(s);for(let t=0;h>t;t+=1){let r=x[s].length,o=t===h-1?u-t*c:c,l=Math.min(1,o/c);x[s].push({id:`${(e.id??"pile-"+i)+""}-${t}`,x:f+(m.perRow>1?((m.perRow>1?r%m.perRow:0)/(m.perRow-1)*2-1)*b:0),y:d.plot.y+a+2,vx:(t%3-1)*a/2,vy:0,mass:1,shape:{type:"circle",radius:a*Math.sqrt(l)},datum:{...e,category:n,unitIndex:t,unitValue:c,representedValue:o,unitFraction:l}})}});let v=x.reduce((e,t)=>Math.max(e,t.length),0);for(let e=0;v>e;e+=1)for(let t of x)t.length>e&&y.push(t[e]);let w=d.plot.y+d.plot.height,k=[...ko({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],A=d.plot.y-400;for(let e=0;g>e;e+=1){let t=m.centerX(e);for(let i of[-1,1])k.push({id:`pile-tube-${e}-${0>i?"l":"r"}`,shape:{type:"aabb",x:t+i*m.tubeWidth/2,y:(A+w)/2,width:6,height:w-A}})}return{config:Ar(s,k,"UnitPileChart"),initialSpawns:y,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:h.map(e=>({label:e,value:p.get(e)??0}))}}({data:a?function(e={}){let t=(e.categories?.length?e.categories:["Intake","Review","Build","Ship"]).map(e=>(e+"").trim()).filter(Boolean),i=t.length?t:["Intake"],r=Math.max(i.length,Math.round(e.count??Math.max(48,12*i.length))),o=$r(e.unitValue,1),n=Rr(e.seed??1),a=e.idPrefix??"mechanical-pile",s=i.map(()=>.65+.9*n()),l=s.reduce((e,t)=>e+t,0)||1,c=r-i.length,u=s.map(e=>e/l*c),d=u.map(e=>1+Math.floor(e)),h=r-d.reduce((e,t)=>e+t,0),f=u.map((e,t)=>({index:t,fraction:e-Math.floor(e)})).sort((e,t)=>t.fraction-e.fraction);for(let e=0;h>0;e=(e+1)%f.length)d[f[e].index]+=1,h-=1;return i.map((e,t)=>({id:`${a}-${t}`,category:e,value:d[t]*o,mechanical:!0,unitCount:d[t],unitValue:o,share:d[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||(a?"value":void 0),unitValue:o.unitValue??1,ballRadius:o.ballRadius??8,seed:o.seed??1,size:n});return{...r,config:s.config,initialSpawns:va(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:wa(sa(s.projectionRows,o.ballRadius??8,ka(r,o,"showProjection"),Number.isFinite(o.unitValue)&&o.unitValue>0?o.unitValue:1),r.foregroundGraphics),bodyStyle:kr(t||o.colorBy||(a?"category":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},om={frameType:"physics",layout:Jg,buildProps:(e,t,i,r,o)=>{let n=r.size??[600,360],a=function(e){let{data:t,xAccessor:i,groupAccessor:r,radiusAccessor:o,pointRadius:n,seed:a,size:s,xExtent:l,collisionIterations:c,settle:u}=e,{rows:d}=Ir(t,"collision-swarm"),h=vr(s),f=Rr(a),p=[],y=[],g=new Map;d.forEach((e,t)=>{let a=Mr(Sr(e,t,i));if(null==a)return;let s=r?(Sr(e,t,r)??"All")+"":"All",l=o?Mr(Sr(e,t,o)):null,c=_r(null!=l&&l>0?l:n,2,18);(function(e){let t=g.get(e);null==t&&(t=y.length,y.push(e),g.set(e,t))})(s),p.push({datum:e,index:t,value:a,group:s,radius:c})});let m=p.map(e=>e.value),b=l?Mr(l[0]):null,x=l?Mr(l[1]):null,v=m.length?Math.min(...m):0,w=m.length?Math.max(...m):1,k=b??v,A=x??w;if(k===A&&(k-=.5,A+=.5),k>A){let e=A;A=k,k=e}let S=Math.max(n,...p.map(e=>e.radius)),M=h.plot.x+S+8,_=h.plot.x+h.plot.width-S-8,$=ug().domain([k,A]).range([M,_]),P=h.plot.height/Math.max(1,y.length),R=Math.min(6,.05*P),I=e=>h.plot.y+((g.get(e)??0)+.5)*P,L=new Map,T=new Set,C=new Map;for(let e of y){let t=p.filter(t=>t.group===e),i=I(e),r=t.map(e=>({x:$(e.value),radius:e.radius})),o=Co(r,i-P/2+R,i+P/2-R,f);L.set(e,t.length),o.overlapping&&T.add(e),t.forEach((e,t)=>C.set(e.index,{x:r[t].x,y:o.positions[t],entryOffset:o.entryOffset}))}let O=p.map((e,t)=>{let i=C.get(e.index),r=i.x,o=i.y,n=T.has(e.group);return{id:(e.datum.id??"collision-swarm-"+t)+"",x:r,y:o-(u?0:i.entryOffset),vx:0,vy:0,fixedPosition:{x:r},bodyCollisions:!n,mass:1,shape:{type:"circle",radius:e.radius},datum:{...e.datum,xValue:e.value,group:e.group,radius:e.radius,targetX:r,targetY:o,overlapping:n},springs:[{target:{type:"point",x:r,y:o},restLength:0,stiffness:34,damping:12}]}});return{config:Ar(a,ko({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:O,projectionRows:y.map(e=>({label:e,value:L.get(e)??0})),metadata:{kind:"collision-swarm",xExtent:[k,A],xRange:[M,_],groups:y.map(e=>({label:e,y:I(e),count:L.get(e)??0,overlapping:T.has(e)})),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:n,xExtent:o.xExtent,collisionIterations:o.collisionIterations,settle:o.settle});return{...r,config:a.config,initialSpawns:va(a.initialSpawns),projectionRows:a.projectionRows,foregroundGraphics:wa(ca(a.metadata,ka(r,o,"showProjection")),r.foregroundGraphics),bodyStyle:kr(t||o.colorBy||o.groupAccessor,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.xAccessor||"x"})}}},nm={frameType:"physics",layout:Jg,buildProps:(e,t,i,r,o)=>{let n=r.size??[900,420],a=Array.isArray(o.stages)?o.stages:[],s=function(e){let t=e.stages;if(!t.length)throw Error("buildProcessFlowPhysics requires at least one stage");let i=e.size,r=vr(i),o=_r(e.ballRadius??6,2,18),n=e.seed??1,a=Rr(n),s=e.idAccessor,l=e.stageAccessor??"stage",c=e.groupBy,u=e.groupLabelAccessor,d=e.workAccessor,h=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})),b=function(e){let t=e.shape??"lane",i=Math.max(1,Math.round(e.width)),r=Math.max(1,Math.round(e.height)),o=e.padX??46,n=e.padY??72,a=o,s=i-o,l=n,c=r-Math.max(24,Math.round(.45*n)),u=(l+c)/2,d=Math.max(1,c-l),h=Bo(e.pinchRatio??.18,.06,.5),f=Number(e.pinchHeightOffset??0),p=Number.isFinite(f)?f:0,y=Bo(d*h+p,.06*d,.5*d),g=y/2,m=u-g,b=u+g,x=e.idPrefix??"process",v=e.friction??.58,w=e.restitution??.18,k=e.wallThickness??8,A=e.stages;if(!A.length)throw Error("processStageLayout requires at least one stage");let S=Bo(e.centerStageIndex??Math.floor(A.length/2),0,A.length-1),M=function(e){let t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}(A),_=s-a,$=a,P=A.map((e,t)=>{let i=$,r=t===A.length-1?s:$+(e.share??1)/M*_;return $=r,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:i,x1:r,x:(i+r)/2,width:r-i,y:u,height:d}}),R=P[S],I=R.x0,L=R.x1,T=(e,i)=>{if("lane"===t)return"top"===i?l:c;if("funnel"===t){let t=Bo((e-a)/Math.max(1,s-a),0,1);return"top"===i?l+(m-l)*t:c+(b-c)*t}if(I>=e){let t=Bo((e-a)/Math.max(1,I-a),0,1);return"top"===i?l+(m-l)*t:c+(b-c)*t}if(L>=e)return"top"===i?m:b;let r=Bo((e-L)/Math.max(1,s-L),0,1);return"top"===i?m+(l-m)*r:b+(c-b)*r},C=P.map(e=>{let t=Math.min(T(e.x0,"top"),T(e.x1,"top")),i=Math.max(T(e.x0,"bottom"),T(e.x1,"bottom"));return{...e,y:(t+i)/2,height:Math.max(1,i-t)}}),O={thickness:k,friction:v,restitution:w},F=[];"lane"===t?F.push(Wo(x+"-top",a,l,s,l,O),Wo(x+"-bottom",a,c,s,c,O),Wo(x+"-left",a,l,a,c,{...O,thickness:Math.max(6,k-2)}),Wo(x+"-right",s,l,s,c,{...O,thickness:Math.max(6,k)})):"funnel"===t?F.push(Wo(x+"-top",a,l,s,m,O),Wo(x+"-bottom",a,c,s,b,O),Wo(x+"-left",a,l,a,c,{...O,thickness:Math.max(6,k-2)}),Wo(x+"-right",s,m,s,b,{...O,thickness:Math.max(6,k)})):F.push(Wo(x+"-left-top",a,l,I,m,O),Wo(x+"-left-bottom",a,c,I,b,O),Wo(x+"-center-top",I,m,L,m,O),Wo(x+"-center-bottom",I,b,L,b,O),Wo(x+"-right-top",L,m,s,l,O),Wo(x+"-right-bottom",L,b,s,c,O),Wo(x+"-left",a,l,a,c,{...O,thickness:Math.max(6,k-2)}),Wo(x+"-right",s,l,s,c,{...O,thickness:Math.max(6,k)}));let D=e.membraneDampingScale??.5,z=a,N=Math.max(1,("bowtie"===t?I:s)-z),E=(e.membranes??[]).map(e=>{let t=z+Bo(e.offset,0,1)*N,i=e.width??18+18*e.cost,r=d-16,o=u+.25*(e.wobble??0);return{...e,x:t,y:o,width:i,height:r}}),B=!1===e.includeMembraneRegions?[]:E.map(e=>function(e){let t=e.dampingScale??.5,i=e.energyScale??1,r=Bo(e.cost,0,2);return{...jo({...e,kind:e.kind??"membrane",attributes:{primitive:"membrane",membraneCost:r,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:r*t,energyDelta:-r*i}}({id:e.id,label:e.label??e.id,description:e.description??(e.label??e.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??D,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:i,height:r,padX:o,padY:n,left:a,right:s,topY:l,bottomY:c,midY:u,centerLeft:I,centerRight:L,pinchHeight:y,pinchTop:m,pinchBottom:b,stages:C,membranes:E,colliders:F,regionEffects:B,boundaryY:T}}({width:i[0],height:i[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}),x=new Map(b.stages.map((e,t)=>[e.id,t])),v=new Map(b.stages.map(e=>[e.id,e])),w=b.stages[0].id,k=b.stages[0],A=new Set(t.filter(e=>e.absorb).map(e=>e.id)),S=t.map(e=>{let t=v.get(e.id)??k;return function(e,t){let i={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){let t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...jo({...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"}}({...i,kind:e.kind??"sink",force:Xo(e.force,28),damping:e.damping??.04,charge:"absorbed",attributes:{...i.attributes,primitive:"absorb"}});if(e.portal){let t=e.portal.force??e.force??{x:-40,y:0};return r={...i,kind:e.kind??"force-field",force:Xo(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...i.attributes,primitive:"portal",targetStage:e.portal.targetStageId}},{...jo({...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){let t=Math.max(.1,e.capacity.unitsPerSecond);return function(e){let t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...jo({...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}}({...i,kind:e.kind??"force-field",capacity:t,unitsPerSecond:t,force:Xo(e.force,10+.8*t),damping:e.damping??Math.max(.04,.32-.01*t),attributes:{...i.attributes,unitAccessor:e.capacity.unitAccessor,reviewerCapacity:t}})}if(e.pressure){let t="object"==typeof e.pressure&&e.pressure?e.pressure:{};return function(e){let t=e.pressure??e.occupancy??0,i=e.baseDamping??.08,r=e.dampingPerUnit??.12,o=e.energyPerUnit??0;return{...jo({...e,kind:e.kind??"membrane",attributes:{primitive:"pressureField",pressure:t,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:i+t*r,energyDelta:o?-t*o:void 0,force:e.force}}({...i,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:Xo(e.force,8),attributes:{...i.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?Yo({...i,kind:e.kind??"force-field",force:Xo(e.force,14),damping:e.damping??.02,attributes:{...i.attributes,primitive:"routeSurface"}}):function(e){return{...jo({...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}}({...i,kind:e.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...i.attributes,primitive:"forceField"}})}(e,{x:t.x,y:b.midY,width:t.width,height:b.bottomY-b.topY})});S.unshift(Yo({id:"process-flow-route",label:"process route",description:"Baseline conveyor along the process lane.",x:(b.left+b.right)/2,y:b.midY,width:b.right-b.left,height:b.bottomY-b.topY-12,force:8,damping:.012,semanticItem:!1}));let M=new Map;for(let e of b.stages)M.set(e.id,0);let _=[];e.data.forEach((e,t)=>{let i=(s?Sr(e,t,s)??e.id??"process-flow-"+t:e.id??"process-flow-"+t)+"",r=(Sr(e,t,l)??w)+"",n=x.has(r)?r:w;M.set(n,(M.get(n)??0)+1);let a=c?(Sr(e,t,c)??"")+"":void 0,f=a&&u?(Sr(e,t,u)??a)+"":a,p=d?Mr(Sr(e,t,d))??1:1,y=h?Mr(Sr(e,t,h)):null,g=_r(null!=y&&y>0?y:o,2,18);_.push({datum:e,id:i,stageId:n,groupId:a||void 0,groupLabel:f||void 0,work:p,radius:g,index:t})});let $=new Map,P=new Map;for(let e of _){if(!e.groupId)continue;let t=$.get(e.groupId)??[];t.push(e.id),$.set(e.groupId,t),e.groupLabel&&P.set(e.groupId,e.groupLabel)}let R=_r(e.groupAnchorAlong??.55,.15,.9),I=b.left+(b.right-b.left)*R,L=Array.from($.keys()),T=L.map((e,i)=>{let r=$.get(e)??[],o=L.length>1?b.topY+28+i/Math.max(1,L.length-1)*(b.bottomY-b.topY-56):b.midY;return function(e){let t=e.x??e.anchor?.x??0,i=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:i,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:i},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}({id:e,label:P.get(e)??e,bodyIds:r,anchor:{x:I,y:o},x:I,y:o,completion:"allAbsorbed"===f?{mode:"allMembersAbsorbed",targetZone:t.find(e=>e.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),C=function(e,t){let i=t instanceof Set?t:new Set(t);return e.map(e=>{let t=e.bodyIds??[],r=t.filter(e=>!i.has(e)),o=t.length-r.length,n=e.completion?.mode??"allMembersAbsorbed",a=e.completion?.valueByBodyId,s=e=>{let t=a&&Object.prototype.hasOwnProperty.call(i=a,r=e)?i[r]:void 0;var i,r;return"number"==typeof t&&Number.isFinite(t)&&t>=0?t:1},l=t.reduce((e,t)=>e+s(t),0),c=t.reduce((e,t)=>e+(i.has(t)?s(t):0),0),u=e.completion?.threshold,d="threshold"===n?Number.isFinite(u)&&Number(u)>=0?Number(u):l:void 0;return{id:e.id,label:e.label??e.id,mode:n,complete:t.length>0&&("anyAbsorbed"===n?o>0:"threshold"===n?c>=(d??l):0===r.length),absorbed:o,total:t.length,absorbedValue:c,totalValue:l,threshold:d,missing:r}})}(T,_.filter(e=>A.has(e.stageId)).map(e=>e.id)),O=new Map(T.map(e=>[e.id,e])),F=_.map((e,t)=>{let i=v.get(e.stageId)??k,r=i.x+(a()-.5)*Math.min(24,.2*i.width),o=b.boundaryY(r,"top")+e.radius+10,n=b.boundaryY(r,"bottom")-e.radius-10,s=n>o?o+a()*Math.max(1,n-o):b.midY,l=g?r:b.left+18+t%7*4,c=g?s:b.midY+(a()-.5)*(b.bottomY-b.topY)*.35,u=[{target:{type:"point",x:r,y:s},restLength:.45*e.radius,stiffness:p,damping:y}];if(e.groupId){let t=O.get(e.groupId);t?.anchor&&!A.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*a(),vy:g?0:20*(a()-.5),mass:1,shape:{type:"circle",radius:e.radius},spawnAt:g?0:.03*t,springs:u,datum:{...e.datum,id:e.id,stage:e.stageId,groupId:e.groupId,groupLabel:e.groupLabel,work:e.work,__processFlow:!0}}}),D={kernel:{seed:n,gravity:{x:e.gravityX??22,y:e.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:b.colliders,fixedDt:1/60,maxSubsteps:8},z=b.stages.map(e=>({label:e.label??e.id,value:M.get(e.id)??0})),N=t.map(e=>{let t=v.get(e.id)??k;return{id:e.id,label:e.label??e.id,x:t.x,width:t.width,count:M.get(e.id)??0,capacity:e.capacity?.unitsPerSecond,absorb:!0===e.absorb,portalTarget:e.portal?.targetStageId}});return{config:D,initialSpawns:F,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:z,metadata:{kind:"process-flow",plot:r.plot,volume:b,stages:N,groups:T,groupCompletion:C,regionEffects:S}}}({data:Array.isArray(e)?e:[],stages:a,size:n,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=s.metadata;return{...r,config:s.config,initialSpawns:va(s.initialSpawns),projectionRows:s.projectionRows,regionEffects:l?.regionEffects,backgroundGraphics:wa(fa(s.metadata,ka(r,o,"showChrome"),{},o.chromeOptions),r.backgroundGraphics),foregroundGraphics:wa(pa(s.projectionRows,s.metadata,ka(r,o,"showProjection")),r.foregroundGraphics),bodyStyle:kr(t||o.colorBy||o.groupBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.workAccessor||o.stageAccessor||"stage"})}}},am={frameType:"physics",layout:Jg,buildProps:(e,t,i,r,o)=>{let n=r.size??[900,520],a=nn({data:Array.isArray(e)?e:[],size:n,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:a.config,initialSpawns:va(a.initialSpawns),projectionRows:[],backgroundGraphics:wa(ka(r,o,"showChrome")?Dy.createElement(ba,{layout:a.layout,states:a.states,compact:!0===r.__compactMode}):void 0,r.backgroundGraphics),foregroundGraphics:wa(ka(r,o,"showProjection")?Dy.createElement(xa,{layout:a.layout,states:a.states}):void 0,r.foregroundGraphics),bodyStyle:kr(t||o.colorBy)}}},sm={frameType:"physics",layout:Jg,buildProps:(e,t,i,r,o)=>{let n=r.size??[900,520],a=Gn({data:Array.isArray(e)?e:[],phases:Array.isArray(o.phases)?o.phases:[],products:Array.isArray(o.products)?o.products:void 0,outlets:Array.isArray(o.outlets)?o.outlets:void 0,events:Array.isArray(o.events)?o.events:void 0,idAccessor:o.idAccessor,labelAccessor:o.labelAccessor,categoryAccessor:o.categoryAccessor,amountAccessor:o.amountAccessor,metricsAccessor:o.metricsAccessor,initialStateAccessor:o.initialStateAccessor,metrics:o.metrics,size:n,seed:o.seed,bodyRadius:"number"==typeof o.bodyRadius?o.bodyRadius:void 0,radiusRange:o.radiusRange}),s="snapshot"===o.playback?function(e,t){if(void 0===t)return e.duration;if("number"==typeof t)return Math.max(0,Math.min(e.duration,Rn(t)??0));let i=e.phases.find(e=>e.id===t.phaseId);if(!i)return e.duration;let r=Math.max(0,Math.min(1,Rn(t.progress??0)??0));return i.start+i.duration*r}(a,o.snapshotAt):a.duration,l=qn(a,s).state,c=o.projection&&"object"==typeof o.projection?o.projection:{groupBy:"outlet",measure:"count"},u=function(e,t={}){let i=t.groupBy??"outlet",r=new Map,o=e=>{let t=function(e,t){return"product"===t?"product"===e.kind?e.id:"unassigned":"outlet"===t?e.outletId??"unassigned":"category"===t?e.category:e.status}({...e,status:e.status??"active"},i),o=r.get(t);if(o)return o.count+=1,o.amount+=e.amount,void yn(o.metrics,e.metrics);r.set(t,{key:t,label:"product"===i&&"product"===e.kind?e.label:t,count:1,amount:e.amount,metrics:ln(e.metrics),status:"status"===i?e.status:void 0,outletId:"outlet"===i?e.outletId:void 0,category:"category"===i?e.category:void 0,productId:"product"===i&&"product"===e.kind?e.id:void 0})};for(let t of Object.values(e.components))t.productIds.length||"consumed"===t.status||o({kind:"component",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});for(let t of Object.values(e.products))o({kind:"product",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});let n=new Map((t.order??[]).map((e,t)=>[e,t]));return[...r.values()].sort((e,t)=>(n.get(e.key)??Number.MAX_SAFE_INTEGER)-(n.get(t.key)??Number.MAX_SAFE_INTEGER)||dn(e.key,t.key))}(l,c),d=c.measure??"count",h=function(e,t={}){let i=t.bodies??[],r=Math.max(0,t.recentBodyLimit??6),o=new Map;for(let e of i){let i=t.getContainerId?.(e);if(!i)continue;let r=o.get(i);r?r.push(e):o.set(i,[e])}let n=e.map(e=>{let i=o.get(e.id)??[],n=Math.max(0,Math.floor(e.count??i.length)),a=i.slice(Math.max(0,i.length-r)).map(e=>({id:e.id,label:t.getBodyLabel?.(e)??oa(e),datum:e.datum}));return{id:e.id,label:e.label,count:n,share:0,secondary:e.secondary,secondaryLabel:e.secondaryLabel,observed:e.observed,bodyIds:i.map(e=>e.id),recentBodies:a,metadata:e.metadata}}),a=n.reduce((e,t)=>e+t.count,0);return n.map(e=>({...e,share:a>0?e.count/a:0}))}(u.map(e=>({id:e.key,label:e.label,count:e.count,secondary:"count"===d||"amount"===d?e.amount:Number(e.metrics[d]??0),secondaryLabel:"count"===d||"amount"===d?o.amountLabel??"amount":d,metadata:{amount:e.amount,metrics:e.metrics,status:e.status,outletId:e.outletId,category:e.category,productId:e.productId}}))),f={seed:o.seed,bodyRadius:"number"==typeof o.bodyRadius?o.bodyRadius:void 0,radiusRange:o.radiusRange},p=t??o.colorBy??"category",y=!1===o.showChrome?null:Dy.createElement(ia,{layout:a.layout,phases:a.phases,state:l,compact:520>n[0]||360>n[1]}),g=!1===o.showProjection?null:Dy.createElement(ra,{rows:u,layout:a.layout,projection:c,amountLabel:o.amountLabel});return{...r,config:a.config,initialSpawns:va(Yn(l,a.layout,f)),projectionRows:h,bodyStyle:e=>function(e,t,i,r){let o=e.datum,n={stroke:r.stroke??("product"===o?.kind?"#fffaf0":"#26323a"),strokeWidth:r.strokeWidth??("product"===o?.kind?1.8:1.1),opacity:r.opacity??.96};if(!o?.__crucible)return{...n,fill:r.color??"#b8792d"};if("product"===o.kind){let e=t.products[o.semanticId];return{...n,fill:r.color??e?.color??Aa(e?.id??o.semanticId)}}let a,s=t.components[o.semanticId];return s?(a="status"===i?s.status:"outlet"===i?s.outletId??"in chamber":"product"===i?s.productIds[0]??"unalloyed":"category"===i||null==i?s.category:"function"==typeof i?(i(s.datum)??"unassigned")+"":(s.datum[i+""]??"unassigned")+"",{...n,fill:r.color??Aa(a)}):{...n,fill:r.color??"#356b63"}}(e,l,p,o),getBodyLabel:e=>function(e,t){let i=e.datum;if(i?.__crucible)return"product"===i.kind?t.products[i.semanticId]?.label:t.components[i.semanticId]?.label}(e,l),renderBodySVG:ea,backgroundGraphics:wa(y,r.backgroundGraphics),foregroundGraphics:wa(g,r.foregroundGraphics)}}},lm={frameType:"physics",layout:Jg,buildProps:(e,t,i,r,o)=>{let n=r.size??[760,420],a=function(e){function t(e){if(e&&"object"==typeof e){let t=e;if("function"==typeof a){let e=a(t,0);if(null!=e)return e+""}if("string"==typeof a&&null!=t[a])return t[a]+"";if(null!=t.id)return t.id+""}return(e??"unknown")+""}let{coordinateMode:i,flowSpeed:r,links:o,maxParticles:n,nodeIdAccessor:a,nodeXAccessor:s,nodeYAccessor:l,nodes:c,particleRadius:u,particleRate:d,pathAccessor:h,pathConstraint:f="path",reducedMotion:p,seed:y,size:g,sourceAccessor:m,targetAccessor:b,throughputAccessor:x}=e,v=vr(g),w=Rr(y),k=new Map,A=new Map,S=[];c.forEach((e,t)=>{let i=(Sr(e,t,a)??e.id??t)+"",r=Mr(Sr(e,t,s)),o=Mr(Sr(e,t,l));if(null!=r&&null!=o){let e={x:r,y:o};k.set(i,e),S.push(e)}A.set(i,(e.label??e.name??i)+"")});let M=[];o.forEach((e,i)=>{let r=t(Sr(e,i,m)),o=t(Sr(e,i,b)),n=Math.max(0,Mr(Sr(e,i,x))??0),a=Fo(h?Sr(e,i,h):void 0),s=a.length?a:Fo(e.path??e.points??e.route);s.forEach(e=>S.push(e)),M.push({id:(e.id??`physical-flow-${r}-${o}-${i}`)+"",link:e,index:i,source:r,target:o,throughput:n,rawPath:s})});let _=(R=S,"normalized"===(P=i)||"pixels"===P?P:R.length>0&&R.every(e=>!(0>e.x||e.x>1||0>e.y||e.y>1))?"normalized":"pixels"),$=new Map;var P,R;for(let[e,t]of k)$.set(e,Do(t,v,_));let I=[];for(let e of M){let t=e.rawPath.map(e=>Do(e,v,_));if(2>t.length){let i=$.get(e.source),r=$.get(e.target);i&&r&&(t=[i,r])}else $.has(e.source)||$.set(e.source,t[0]),$.has(e.target)||$.set(e.target,t[t.length-1]);2>t.length||0>=e.throughput||(A.has(e.source)||A.set(e.source,e.source),A.has(e.target)||A.set(e.target,e.target),I.push({...e,path:t,packetCount:0}))}let L=$r(d,.12),T=Math.max(1,Math.round(n)),C=I.map(e=>Math.max(1,Math.round(e.throughput*L))),O=C.reduce((e,t)=>e+t,0),F=O>T?T/O:1;I.forEach((e,t)=>{e.packetCount=Math.max(1,Math.floor(C[t]*F))});let D=I.reduce((e,t)=>e+t.packetCount,0);for(;D>T;){let e=I.reduce((e,t,i)=>t.packetCount>1&&(-1===e||t.packetCount>I[e].packetCount)?i:e,-1);if(-1===e)break;I[e].packetCount-=1,D-=1}let z=new Map,N=new Map,E=[],B=$r(r,90),W=$r(u,4);I.forEach((e,t)=>{z.set(e.target,(z.get(e.target)??0)+e.throughput),N.set(e.source,(N.get(e.source)??0)+e.throughput);let i=zo(e.path);for(let r=0;e.packetCount>r;r+=1){let o=(r+.5)/e.packetCount,n=p?o:_r(.12+.84*o+.04*(w()-.5),.04,.98),a=p?n:Math.max(0,n-(.18+.12*w())),s=No(e.path,a),l=No(e.path,n),c=Eo(e.path,a),u={x:-c.y,y:c.x},d=(w()-.5)*W*1.5;E.push({id:`${e.id}-packet-${r}`,x:s.x+u.x*d,y:s.y+u.y*d,vx:p?0:c.x*B+10*(w()-.5),vy:p?0:c.y*B+10*(w()-.5),mass:.8,spawnAt:p?0:.04*t+r/32,shape:{type:"circle",radius:W},datum:{...e.link,source:e.source,target:e.target,throughput:e.throughput,packetIndex:r,packetCount:e.packetCount,routeProgress:n,flowPath:e.path,flowPathLength:i,flowRouteId:e.id,flowSpeed:B,sourceLabel:A.get(e.source)??e.source,targetLabel:A.get(e.target)??e.target},springs:"none"!==f&&p?[{target:{type:"point",x:l.x,y:l.y},restLength:.7*W,stiffness:26,damping:4.25}]:void 0})}});let j=Math.max(18,5*W),Y=Array.from($,([e,t])=>({nodeId:e,label:A.get(e)??e,sensorId:"physical-flow-node-"+Pr(e),point:t})),X=Y.map(e=>({id:e.sensorId,sensor:!0,shape:{type:"aabb",x:e.point.x,y:e.point.y,width:j,height:j}})),q=Object.fromEntries(Y.map(e=>[e.sensorId,{binId:e.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),G=Ar(y,[...ko({x:v.plot.x,y:v.plot.y,width:v.plot.width,height:v.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...X],"PacketFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*W),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});G.bodyLimit=T,G.eviction="oldest",G.observation={...G.observation,sensors:q};let V=Array.from($,([e,t])=>({id:e,label:A.get(e)??e,x:t.x,y:t.y,sensorId:"physical-flow-node-"+Pr(e),incoming:z.get(e)??0,outgoing:N.get(e)??0})),H=I.map(e=>({id:e.id,source:e.source,target:e.target,sourceLabel:A.get(e.source)??e.source,targetLabel:A.get(e.target)??e.target,throughput:e.throughput,packetCount:e.packetCount,path:e.path}));return{config:G,initialSpawns:E,projectionRows:V.filter(e=>e.incoming>0||e.outgoing>0).map(e=>({label:e.label,value:e.incoming,secondary:e.outgoing})),metadata:{kind:"physical-flow",coordinateMode:_,particleCount:E.length,totalThroughput:I.reduce((e,t)=>e+t.throughput,0),plot:v.plot,nodes:V,links:H}}}({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:n});return{...r,config:a.config,initialSpawns:va(a.initialSpawns),projectionRows:a.projectionRows,foregroundGraphics:wa(ga(a.metadata,{showNodeLabels:!1!==o.showNodeLabels,showSensors:!1!==o.showSensors,showStaticFlow:!1!==o.showStaticFlow}),r.foregroundGraphics),bodyStyle:kr(t||o.colorBy||"source")}}},cm={frameType:"physics",layout:Jg,buildProps:(e,t,i,r,o)=>{let n=r.size??[700,380],a=Ke(r.theme),s=function(e){let t=function(e,t,i){let r=e?.observation;return{...e,observation:{...r,chartId:t??r?.chartId??"physics-custom",chartType:r?.chartType??"PhysicsCustomChart",onObservation:i??r?.onObservation}}}(e.config,e.chartId,e.onObservation),i=qo(e.colorScheme,e.themeCategorical,tf),r=vr(e.size),o={data:e.data,scales:{x:dg().domain(e.xExtent??[0,1]).range([r.plot.x,r.plot.x+r.plot.width]),y:dg().domain(e.yExtent??[0,1]).range([r.plot.y+r.plot.height,r.plot.y])},dimensions:r,theme:{semantic:e.semantic,categorical:[...i]},resolveColor:Go(i,e.colorScheme),config:e.layoutConfig??{},world:new lg(t)},n=e.skipLayout?{}:e.layout(o)??{},a=function(e,t){if(!t?.length)return e;let i=new Map;for(let e of t){let{bodyId:t,...r}=e,o=i.get(t)??[];o.push(r),i.set(t,o)}return e.map(e=>{let t=i.get(e.id);return t?.length?{...e,springs:[...e.springs??[],...t]}:e})}([...n.initialSpawns??n.bodies??[]],n.constraints);return{config:Vo(t,n),context:o,initialSpawnPacing:n.initialSpawnPacing,initialSpawns:a,result:n}}({chartId:o.chartId,colorScheme:i,config:o.config,data:Array.isArray(e)?e:[],layout:o.layout,layoutConfig:o.layoutConfig,semantic:Ue(a)??{},size:n,themeCategorical:a.colors.categorical,xExtent:o.xExtent,yExtent:o.yExtent});return{...r,config:s.config,initialSpawns:va(s.initialSpawns),projectionRows:[],bodyStyle:s.result.bodyStyle??kr(t||o.colorBy),backgroundGraphics:wa(r.backgroundGraphics,s.result.backgroundOverlays),foregroundGraphics:wa(r.foregroundGraphics,s.result.overlays)}}};import*as um from"react-dom/server";import*as dm from"react";import*as hm from"react-dom/server";var fm=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){let t=[];for(let i of e){let e=this.push(i);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){let t=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)e(this.buffer[(t+i)%this._capacity],i)}toArray(){let e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)e[i]=this.buffer[(t+i)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");let t=this.toArray(),i=0,r=[];t.length>e&&(i=t.length-e,r=t.slice(0,i)),this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(let e=i;t.length>e;e++)this.push(t[e]);return r}update(e,t){let i=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){let n=(r+o)%this._capacity,a=this.buffer[n];if(e(a)){let e;e="object"!=typeof a||null===a?a:Array.isArray(a)?[...a]:{...a},i.push(e),this.buffer[n]=t(a)}}return i}remove(e){let t=[],i=[];if(this.forEach(r=>{e(r)?i.push(r):t.push(r)}),0===i.length)return i;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(let e of t)this.push(e);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}},pm=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(let i of e){let e=t?t(i):i;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}},ym=/^\d{4}-\d{1,2}$/,gm=Object.create(null),mm=typeof window>"u"||typeof document>"u",bm=new Set;import{scaleLinear as xm,scaleLog as vm,scaleSymlog as wm,scaleTime as km}from"d3-scale";var Am=new WeakMap,Sm=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Mm=["scene-style","data-paint","accessibility","evidence"],_m=(e,t)=>({retainedData:e,invalidations:t}),$m=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Pm=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Rm=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Im=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Lm=["scene-geometry","data-paint","accessibility","evidence"],Tm=["scene-style","data-paint","accessibility","evidence"],Cm=[],Om={chartType:_m("rebuild",$m),runtimeMode:_m("rebuild",$m),xAccessor:_m("rebuild",$m),yAccessor:_m("rebuild",$m),timeAccessor:_m("rebuild",$m),valueAccessor:_m("rebuild",$m),y0Accessor:_m("rebuild",$m),boundsAccessor:_m("rebuild",$m),band:_m("rebuild",$m),openAccessor:_m("rebuild",$m),highAccessor:_m("rebuild",$m),lowAccessor:_m("rebuild",$m),closeAccessor:_m("rebuild",$m),candlestickRangeMode:_m("rebuild",$m),accessorRevision:_m("rebuild",$m),groupAccessor:_m("rebuild",Pm),categoryAccessor:_m("rebuild",Pm),lineDataAccessor:_m("rebuild",Pm),colorAccessor:_m("rebuild",Tm),sizeAccessor:_m("rebuild",Lm),symbolAccessor:_m("rebuild",Lm),pointIdAccessor:_m("rebuild",Lm),xScaleType:_m("preserve",Rm),yScaleType:_m("preserve",Rm),xExtent:_m("preserve",Rm),invertY:_m("preserve",Rm),yExtent:_m("preserve",Rm),extentPadding:_m("preserve",Rm),scalePadding:_m("preserve",Rm),axisExtent:_m("preserve",Rm),yAxisExtent:_m("preserve",Rm),binSize:_m("preserve",Rm),normalize:_m("preserve",Rm),heatmapAggregation:_m("preserve",Rm),heatmapXBins:_m("preserve",Rm),heatmapYBins:_m("preserve",Rm),arrowOfTime:_m("preserve",Im),baseline:_m("preserve",Im),stackOrder:_m("preserve",Im),sizeRange:_m("preserve",Im),curve:_m("preserve",Im),areaGroups:_m("preserve",Im),customLayout:_m("preserve",Im),layoutConfig:_m("preserve",Im),layoutMargin:_m("preserve",Im),symbolMap:_m("preserve",Lm),showValues:_m("preserve",Lm),heatmapValueFormat:_m("preserve",Lm),trackHoverRows:_m("preserve",Lm),lineStyle:_m("preserve",Tm),pointStyle:_m("preserve",Tm),areaStyle:_m("preserve",Tm),barStyle:_m("preserve",Tm),swarmStyle:_m("preserve",Tm),waterfallStyle:_m("preserve",Tm),candlestickStyle:_m("preserve",Tm),boundsStyle:_m("preserve",Tm),gradientFill:_m("preserve",Tm),lineGradient:_m("preserve",Tm),semanticLineStops:_m("preserve",Tm),colorScheme:_m("preserve",Tm),themeCategorical:_m("preserve",Tm),themeSemantic:_m("preserve",Tm),themeSequential:_m("preserve",Tm),themeDiverging:_m("preserve",Tm),barColors:_m("preserve",Tm),decay:_m("preserve",Tm),pulse:_m("preserve",Tm),staleness:_m("preserve",Tm),layoutSelection:_m("preserve",Tm),annotations:_m("preserve",["overlay","accessibility","evidence"]),windowSize:_m("preserve",Cm),windowMode:_m("preserve",Cm),maxCapacity:_m("preserve",Cm),clock:_m("preserve",Cm),transition:_m("preserve",Cm),introAnimation:_m("preserve",Cm),onLayoutError:_m("preserve",Cm)},Fm=_m("preserve",Im),Dm=class{constructor(){this.tracker=new Hy}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}},Sm)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Mm):this.recordNoop("restyle")}recordConfig(e,t=!1){let i=function(e){let t="preserve",i=new Set;for(let r of e){let e=Om[r]??Fm;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}(e);return this.tracker.record({kind:"config",keys:e},t?new Set([...i.invalidations,...Lm]):i.invalidations)}};import{quadtree as zm}from"d3-quadtree";var Nm=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 i=0,r=0;for(let e of t)"point"===e.type&&!1!==e.interactive&&(i++,e.r>r&&(r=e.r));if(this.maxRadius=r,500>=i)return void(this.tree=null);let o=Array(i),n=0;for(let e of t)"point"===e.type&&!1!==e.interactive&&(o[n++]=e);this.tree=zm().x(e=>e.x).y(e=>e.y).addAll(o)}},Em=class e{constructor(e){if(this.xExtent=new pm,this.yExtent=new pm,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 Dm,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 Nm,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,i)=>!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,i,r,o,n=("u">typeof performance?performance.now():Date.now())){let a=e.color??"rgba(255,255,255,0.6)",s=e.glowRadius??4,l=!1,c=o??(()=>{let e=new Map;for(let t=0;i.length>t;t++)e.set(i[t],t);return e})();for(let i of t){if("line"===i.type)continue;if("area"===i.type){let t=Array.isArray(i.datum)?i.datum:[i.datum],o=0,s=!1;for(let i of t){let t=c.get(i);if(null==t)continue;s=!0;let a=r.get(t);if(null==a)continue;let l=Ea(e,a,n);l>o&&(o=l)}s&&(l=Ba(i,o,a)||l);continue}let t=c.get(i.datum);if(null==t)continue;let o=r.get(t);l=Ba(i,null==o?0:Ea(e,o,n),a,s)||l}return l}(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),i),this.config=e,this.buffer=new fm(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=Ma(e.timeAccessor||e.xAccessor,"time"),this.getY=Ma(e.valueAccessor||e.yAccessor,"value")):(this.getX=Ma(e.xAccessor,"x"),this.getY=Ma(e.yAccessor,"y")),this.getGroup=$a(e.groupAccessor),this.getCategory=$a(e.categoryAccessor),this.getSize=e.sizeAccessor?Ma(e.sizeAccessor,"size"):void 0,this.getColor=$a(e.colorAccessor),this.getSymbol=$a(e.symbolAccessor),this.getY0=e.y0Accessor?Ma(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=Ka(e),this.getPointId=$a(e.pointIdAccessor),"candlestick"===e.chartType){let t=null!=e.openAccessor,i=null!=e.closeAccessor;this.getOpen=t?Ma(e.openAccessor,"open"):void 0,this.getHigh=Ma(e.highAccessor,"high"),this.getLow=Ma(e.lowAccessor,"low"),this.getClose=i?Ma(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!i}e.pulse&&(this.timestampBuffer=new fm(e.windowSize))}currentTime(){return this.config.clock?.()??Da()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=us(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(let t of this.resolvedRibbons){let i=t.getTop(e),r=t.getBottom(e);Number.isFinite(i)&&this.yExtent.push(i),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(let t of this.resolvedRibbons){let i=t.getTop(e),r=t.getBottom(e);Number.isFinite(i)&&this.yExtent.evict(i),Number.isFinite(r)&&this.yExtent.evict(r)}}rebuildYExtent(){this.yExtent.clear();for(let e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(let 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;let 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();let i=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=i?Ma(this.config.timeAccessor||this.config.xAccessor,"time"):Ma(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){let t=e.inserts[0],i=this.config.xAccessor,r="function"==typeof i?i(t):t[i||"x"],o=r instanceof Date,n="string"==typeof r&&Number.isFinite(Ia(r));if(this.xIsDate=o||n,n){let e="string"==typeof i?i:void 0;this.getX=e?t=>La(t[e]):e=>La(i(e))}}cs(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(let i of e.inserts)ds(this.buffer,i,this.timestampBuffer,t),this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i)}else for(let i of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){let 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&&this.growingCap>=5e4&&(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.`)))}let e=ds(this.buffer,i,this.timestampBuffer,t);this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i),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){let{config:t,buffer:i}=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(i,this.getX),this.yExtent.dirty&&this.rebuildYExtent();let n=this.getBufferArray(),a=this.xExtent.extent,s=this.yExtent.extent,l="waterfall"===t.chartType&&i.size>0?function(e,t,i,r,o){let n=Array.from(new Set(e.map(t).filter(e=>Number.isFinite(e)))).sort((e,t)=>e-t);if(2>n.length)return as(i,r);let a=n[0],s=n[1],l=n[n.length-1],c=n[n.length-2];return as("log"===o&&a>0?[a/Math.sqrt(s/a),l*Math.sqrt(l/c)]:[a-(s-a)/2,l+(l-c)/2],r)}(n,this.getX,a,t.xExtent,t.xScaleType):as(a,t.xExtent),c=as(s,t.yExtent),u=!(!(h=t.yExtent)||null==h[0]||null==h[1]),d="exact"===(t.yAxisExtent??t.axisExtent);var h;if("stackedarea"===t.chartType&&!u&&i.size>0){let e=function(e){let{config:t,groups:i,getX:r,getY:o}=e,n="exact"===(t.yAxisExtent??t.axisExtent);if(t.normalize){let i=[0,n?1:1+t.extentPadding];return{yDomain:i,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:i}}}let a=`${e.bufferSize}:${e.ingestVersion}:${t.baseline??"zero"}:${t.stackOrder??"key"}`;if(e.stackExtentCache&&e.stackExtentCache.key===a)return{yDomain:e.stackExtentCache.yDomain,stackExtentCache:e.stackExtentCache};let s=new Map,l=new Set,c=0,u=new Map,d=new Map;for(let e of i){let t=new Map,i=0;for(let n of e.data){let e=r(n),a=o(n);if(!Number.isFinite(e)||!Number.isFinite(a))continue;t.set(e,(t.get(e)||0)+a),l.add(e),i+=a;let s=(u.get(e)||0)+a;u.set(e,s),s>c&&(c=s)}s.set(e.key,t),d.set(e.key,i)}let h,f,p=t.stackOrder??"key",y=(e,t)=>t>e?-1:e>t?1:0;if("input"===p)h=i.map(e=>e.key);else if("insideOut"===p){let e=[...i].map(e=>e.key).sort((e,t)=>{let i=(d.get(t)??0)-(d.get(e)??0);return 0!==i?i:y(e,t)}),t=[],r=[],o=0,n=0;for(let i of e)n>o?(t.push(i),o+=d.get(i)??0):(r.push(i),n+=d.get(i)??0);h=[...r.reverse(),...t]}else h="asc"===p?i.map(e=>e.key).sort((e,t)=>{let i=(d.get(e)??0)-(d.get(t)??0);return 0!==i?i:y(e,t)}):"desc"===p?i.map(e=>e.key).sort((e,t)=>{let i=(d.get(t)??0)-(d.get(e)??0);return 0!==i?i:y(e,t)}):i.map(e=>e.key).sort(y);if("wiggle"===t.baseline||"silhouette"===t.baseline){let e=Array.from(l).sort((e,t)=>e-t),i=ts(e,h,(e,t)=>s.get(e)?.get(t)||0,t.baseline),r=1/0,o=-1/0;for(let t of e){let e=i.get(t)??0,n=u.get(t)??0;r>e&&(r=e),e+n>o&&(o=e+n)}(!Number.isFinite(r)||!Number.isFinite(o))&&(r=0,o=0);let a=o-r,c=n?0:a>0?a*t.extentPadding:1;f=[r-c,o+c]}else if("diverging"===t.baseline){let e=Array.from(l).sort((e,t)=>e-t),[i,r]=function(e,t,i){let r=0,o=0;for(let n of e){let e=0,a=0;for(let r of t){let t=i(r,n)||0;0>t?a+=t:e+=t}r>a&&(r=a),e>o&&(o=e)}return[r,o]}(e,h,(e,t)=>s.get(e)?.get(t)||0),o=r-i,a=n?0:o>0?o*t.extentPadding:1;f=[i-a,r+a]}else f=[0,c+(n?0:c>0?c*t.extentPadding:1)];return{yDomain:f,stackExtentCache:{key:a,yDomain:f}}}({config:t,groups:this.groupData(n),getX:this.getX,getY:this.getY,bufferSize:i.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!u&&i.size>0?c=function(e,t,i,r,o,n,a){let[,s]=function(e,t,i,r,o){let n=Za(e,t,i,r,o);if(0===n.size)return[0,0];let a=0;for(let e of n.values())e.total>a&&(a=e.total);return[0,a]}(e,t,i,r,o);return[0,a?s:s+s*n]}(i,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,d):"waterfall"===t.chartType&&!u&&i.size>0?c=function(e,t,i,r){let[o,n]=function(e,t){let i=0,r=0,o=0;for(let n of e){let e=t(n);null==e||Number.isNaN(e)||(o+=e,i>o&&(i=o),o>r&&(r=o))}return[i,r]}(e,t),a=n-o,s=r?0:a>0?a*i:1;return[Math.min(0,o-Math.abs(s)),Math.max(0,n+Math.abs(s))]}(i,this.getY,t.extentPadding,d):!u&&c[0]!==1/0&&(c=function(e,t,i){if(!i.length)return e;let[r,o]=e;for(let e of t)for(let t of i){let i=t.getTop(e),n=t.getBottom(e);Number.isFinite(i)&&(r>i&&(r=i),i>o&&(o=i)),Number.isFinite(n)&&(r>n&&(r=n),n>o&&(o=n))}return[r,o]}(c,n,this.resolvedRibbons),c=function(e,t){let i=e[1]-e[0],r=t.exactMode?0:i>0?i*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}(c,{exactMode:d,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:s}));c=function(e,t,i){if(!t||i)return e;let r=t[0],o=t[1];return null==r&&null==o?e:[r??e[0],o??e[1]]}(c,t.yExtent,!!u),({xDomain:l,yDomain:c}=function(e,t,i){let r=e,o=t;if(r[0]===1/0||r[1]===-1/0)if("time"===i){let 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}}(l,c,t.xScaleType)),this.scales=function(e){let{config:t,layout:i,xDomain:r}=e,o=t.invertY?[e.yDomain[1],e.yDomain[0]]:e.yDomain,n="streaming"===t.runtimeMode,a=Math.max(0,Math.min(t.scalePadding||0,Math.min(i.width,i.height)/2-1));if(n){let e="left"===t.arrowOfTime?[i.width-a,a]:[a,i.width-a];return{x:xm().domain(r).range(e),y:ss(t.yScaleType,o,[i.height-a,a])}}return{x:ss(t.xScaleType,r,[a,i.width-a]),y:ss(t.yScaleType,o,[i.height-a,a])}}({config:t,layout:e,xDomain:l,yDomain:c}),this._customLayoutFailedThisBuild=!1;let f=this.buildSceneNodes(e,n);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=f,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:e.width,height:e.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(e){let t=e.width/this.lastLayout.width,i=e.height/this.lastLayout.height;for(let e of this.scene)switch(e.type){case"line":for(let r of e.path)r[0]*=t,r[1]*=i;break;case"area":for(let r of e.topPath)r[0]*=t,r[1]*=i;for(let r of e.bottomPath)r[0]*=t,r[1]*=i;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*i,width:e.clipRect.width*t,height:e.clipRect.height*i}),e.strokeColorBands&&(e.strokeColorBands=e.strokeColorBands.map(e=>({...e,y:e.y*i,height:e.height*i})));break;case"point":case"glyph":e.x*=t,e.y*=i;break;case"rect":case"heatcell":e.x*=t,e.y*=i,e.w*=t,e.h*=i;break;case"candlestick":e.x*=t,e.openY*=i,e.closeY*=i,e.highY*=i,e.lowY*=i}let r=this.scales.x.domain(),o=this.scales.y.domain(),n=this.scales.x.range(),a=this.scales.y.range(),s=ss,l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),c=a[1]>a[0];this.scales={x:s(this.config.xScaleType,r,n[0]>n[1]?[e.width-l,l]:[l,e.width-l]),y:s(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){let{config:i,scales:r}=this;if(!r)return[];if(i.customLayout){let o={data:t,scales:r,dimensions:{width:e.width,height:e.height,margin:i.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:i.themeSemantic??{},categorical:i.themeCategorical??_f},resolveColor:(e,t)=>{let r=this.resolveGroupColor(e);if(r)return r;let o=this.resolveLineStyle(e,t);return o.stroke?o.stroke:"string"==typeof o.fill?o.fill:i.themeSemantic?.primary??"#4e79a7"},config:i.layoutConfig??{},selection:i.layoutSelection??null},n=Ha({family:"xy",logLabel:"customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:i.onLayoutError,run:()=>i.customLayout(o)});if("failure"===n.kind)return this.lastCustomLayoutFailure=n.diagnostic,this._customLayoutFailedThisBuild=!0,n.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[]);let a=n.result;this.customLayoutOverlays=a.overlays??null,this.lastCustomLayoutResult=a,this.lastCustomLayoutFailure=null;let s=a.nodes??[];if(this._customRestyle=a.restyle,this.hasCustomRestyle=!!a.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(let e of s)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(s,i.layoutSelection??null)}return qa({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[];let o={scales:r,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:(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},n=(a=i.chartType,gm[a]?.buildScene);var a;if(!n)return function(e){(function(e){return gm[e]})(e)||mm&&(bm.has(e)||(bm.add(e),console.warn(`[semiotic] StreamXYFrame: no XY plugin registered for "${e}" during SSR. Import a chart HOC, or call registerBuiltInXYPlugins() from "semiotic/xy" or "semiotic/realtime/core" before render.`)))}(i.chartType),[];let s=(l=n(o,t,e),Array.isArray(l)?{nodes:l,binBoundaries:[]}:{nodes:l.nodes,binBoundaries:l.binBoundaries});var l;return"bar"===i.chartType&&(this._barCategoryCache=o.barCategoryCache??null,this._binBoundaries=s.binBoundaries),s.nodes}resolveBoundsStyle(e,t){return function(e,t,i,r){let o=e.boundsStyle;if("function"==typeof o)return o(i||{},t);if(o&&"object"==typeof o)return o;let n=r(t,i);return{fill:n.stroke||e.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,...null!=n.opacity&&{opacity:n.opacity},stroke:"none",cursor:n.cursor}}(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){let i=this.config.decay;return i&&t>1?za(i,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;let t=Na(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&function(e,t,i,r=Na(i)){let o=i.length;if(o>1)for(let i of t){if("line"===i.type){let t=Array.isArray(i.datum)?i.datum:[];if(2>t.length)continue;let n=Array(t.length),a=!1;for(let i=0;t.length>i;i++){let s=r.get(t[i]);null!=s?(n[i]=za(e,s,o),1>n[i]&&(a=!0)):n[i]=1}a&&(i._decayOpacities=n);continue}if("area"===i.type){let t=Array.isArray(i.datum)?i.datum:[],n=i.topPath?i.topPath.length:t.length;if(2>n)continue;if(t.length===n){let a=Array(n),s=!1;for(let i=0;t.length>i;i++){let n=r.get(t[i]);null!=n?(a[i]=za(e,n,o),1>a[i]&&(s=!0)):a[i]=1}s&&(i._decayOpacities=a)}else{let a=1;for(let i of t){let t=r.get(i);if(null!=t){let i=za(e,t,o);a>i&&(a=i)}}if(1>a){let e=Array(n);e.fill(a),i._decayOpacities=e}}continue}let t=r.get(i.datum);if(null==t)continue;let n=za(e,t,o);"candlestick"===i.type?i._decayOpacity=n:i.style={...i.style,opacity:(i.style?.opacity??1)*n}}}(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&&Wa(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,i,r){i.clear(),r.clear();for(let o=0;t.length>o;o++){let n=t[o],a=ja(e,n,o);a&&("point"===n.type?i.set(a,{x:n.x,y:n.y,r:n.r,opacity:Ya(n.style)}):"glyph"===n.type?i.set(a,{x:n.x,y:n.y,r:n.size,opacity:Ya(n.style),glyph:n.glyph}):"rect"===n.type||"heatcell"===n.type?i.set(a,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:Ya(n.style)}):"candlestick"===n.type?i.set(a,{x:n.x,y:n.openY,w:n.bodyWidth,openY:n.openY,closeY:n.closeY,highY:n.highY,lowY:n.lowY,opacity:Ya(n.style)}):"line"===n.type?r.set(a,{path:n.path.map(e=>[e[0],e[1]]),opacity:n.style?.opacity}):"area"===n.type&&r.set(a,{topPath:n.topPath.map(e=>[e[0],e[1]]),bottomPath:n.bottomPath.map(e=>[e[0],e[1]]),opacity:n.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();let e=this.scales?.y(0)??0;for(let t=0;this.scene.length>t;t++){let i=this.scene[t],r=ja(this.transitionContext,i,t);r&&("point"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,r:0,opacity:0}):"rect"===i.type?this.prevPositionMap.set(r,{x:i.x,y:e,w:i.w,h:0,opacity:i.style.opacity??1}):"heatcell"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:0}):"line"===i.type?(i._introClipFraction=0,this.prevPathMap.set(r,{path:i.path.map(e=>[e[0],e[1]]),opacity:i.style.opacity})):"area"===i.type&&(i._introClipFraction=0,this.prevPathMap.set(r,{topPath:i.topPath.map(e=>[e[0],e[1]]),bottomPath:i.bottomPath.map(e=>[e[0],e[1]]),opacity:i.style.opacity})))}}startTransition(){if(!this.config.transition)return;let e=function(e,t,i,r,o,n=Da()){if(0===r.size&&0===o.size)return i;let a=t.duration??300;if(i.exitNodes.length>0){let e=new Set(i.exitNodes);i.scene=i.scene.filter(t=>!e.has(t)),i.exitNodes=[]}let s=!1,l=new Set,c=new Set;for(let t=0;i.scene.length>t;t++){let n=i.scene[t],a=ja(e,n,t);if(!a)continue;if(n._transitionKey=a,"line"===n.type||"area"===n.type){let e=o.get(a);if(e){if(c.add(a),"line"===n.type&&e.path&&e.path.length===n.path.length){n._targetPath=n.path.map(e=>[e[0],e[1]]),n._prevPath=e.path;for(let t=0;n.path.length>t;t++)n.path[t]=[e.path[t][0],e.path[t][1]];s=!0}else if("area"===n.type&&e.topPath&&e.bottomPath&&e.topPath.length===n.topPath.length&&e.bottomPath.length===n.bottomPath.length){n._targetTopPath=n.topPath.map(e=>[e[0],e[1]]),n._targetBottomPath=n.bottomPath.map(e=>[e[0],e[1]]),n._prevTopPath=e.topPath,n._prevBottomPath=e.bottomPath;for(let t=0;n.topPath.length>t;t++)n.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;n.bottomPath.length>t;t++)n.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];s=!0}n._targetOpacity=n.style.opacity??1,n._startOpacity=e.opacity??n.style.opacity??1}else n._targetOpacity=n.style.opacity??1,n._startOpacity=0,n.style={...n.style,opacity:0},s=!0;continue}let u=r.get(a);if("point"===n.type)if(u){l.add(a);let e={x:n.x,y:n.y,r:n.r};n._targetOpacity=Ya(n.style),(u.x!==e.x||u.y!==e.y||u.r!==e.r)&&(n._targetX=e.x,n._targetY=e.y,n._targetR=e.r,n.x=u.x,n.y=u.y,n.r=u.r??n.r,s=!0)}else n._targetOpacity=Ya(n.style),n.style={...n.style,opacity:0},s=!0;else if("glyph"===n.type)if(u){l.add(a);let e={x:n.x,y:n.y,size:n.size};n._targetOpacity=Ya(n.style),(u.x!==e.x||u.y!==e.y||u.r!==e.size)&&(n._targetX=e.x,n._targetY=e.y,n._targetR=e.size,n.x=u.x,n.y=u.y,n.size=u.r??n.size,s=!0)}else n._targetOpacity=Ya(n.style),n.style={...n.style,opacity:0},s=!0;else if("rect"===n.type)if(u){l.add(a);let e={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=Ya(n.style),(u.x!==e.x||u.y!==e.y||u.w!==e.w||u.h!==e.h)&&(n._targetX=e.x,n._targetY=e.y,n._targetW=e.w,n._targetH=e.h,n.x=u.x,n.y=u.y,n.w=u.w??n.w,n.h=u.h??n.h,s=!0)}else n._targetOpacity=Ya(n.style),n.style={...n.style,opacity:0},s=!0;else if("heatcell"===n.type)if(u){l.add(a);let e={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=Ya(n.style),(u.x!==e.x||u.y!==e.y||u.w!==e.w||u.h!==e.h)&&(n._targetX=e.x,n._targetY=e.y,n._targetW=e.w,n._targetH=e.h,n.x=u.x,n.y=u.y,n.w=u.w??n.w,n.h=u.h??n.h,s=!0)}else n._targetOpacity=Ya(n.style),n.style={...n.style||{},opacity:0},s=!0;else if("candlestick"===n.type)if(u&&null!=u.openY){l.add(a);let e={x:n.x,openY:n.openY,closeY:n.closeY,highY:n.highY,lowY:n.lowY};n._targetOpacity=Ya(n.style),(u.x!==e.x||u.openY!==e.openY||u.closeY!==e.closeY||u.highY!==e.highY||u.lowY!==e.lowY)&&(n._targetX=e.x,n._targetOpenY=e.openY,n._targetCloseY=e.closeY,n._targetHighY=e.highY,n._targetLowY=e.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,s=!0)}else n._targetOpacity=Ya(n.style),n.style={...n.style||{},opacity:0},s=!0}for(let[e,t]of o)if(!c.has(e))if(e.startsWith("l:")&&t.path){let 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};i.exitNodes.push(r),s=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){let 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};i.exitNodes.push(r),s=!0}for(let[e,t]of r)if(!l.has(e)){if(e.startsWith("p:"))i.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)i.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:"))i.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:"))i.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:")){let r=t.openY??t.y;i.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})}s=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),s&&(i.activeTransition={startTime:n,duration:a}),i}(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;let t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},i=function(e,t,i,r){if(!i.activeTransition)return!1;let o=Oa(e,i.activeTransition),n=Ca(o,"linear"===t.easing?"linear":"ease-out-cubic");for(let e of i.scene){let t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style.opacity=Fa(i?i.opacity??1:0,e._targetOpacity,n)}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=Fa(i.x,e._targetX,n),e.y=Fa(i.y,e._targetY,n),void 0!==e._targetR&&void 0!==i.r&&(e.r=Fa(i.r,e._targetR,n))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style.opacity=Fa(i?i.opacity??1:0,e._targetOpacity,n)}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=Fa(i.x,e._targetX,n),e.y=Fa(i.y,e._targetY,n),void 0!==e._targetR&&void 0!==i.r&&(e.size=Fa(i.r,e._targetR,n))}else if("rect"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style.opacity=Fa(i?i.opacity??1:0,e._targetOpacity,n)}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=Fa(i.x,e._targetX,n),e.y=Fa(i.y,e._targetY,n),void 0!==i.w&&(e.w=Fa(i.w,e._targetW,n)),void 0!==i.h&&(e.h=Fa(i.h,e._targetH,n))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style={...e.style||{},opacity:Fa(i?i.opacity??1:0,e._targetOpacity,n)}}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=Fa(i.x,e._targetX,n),e.y=Fa(i.y,e._targetY,n),void 0!==i.w&&(e.w=Fa(i.w,e._targetW,n)),void 0!==i.h&&(e.h=Fa(i.h,e._targetH,n))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style={...e.style||{},opacity:Fa(i?i.opacity??1:0,e._targetOpacity,n)}}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=Fa(i.x,e._targetX,n),void 0!==i.openY&&(e.openY=Fa(i.openY,e._targetOpenY,n)),void 0!==i.closeY&&(e.closeY=Fa(i.closeY,e._targetCloseY,n)),void 0!==i.highY&&(e.highY=Fa(i.highY,e._targetHighY,n)),void 0!==i.lowY&&(e.lowY=Fa(i.lowY,e._targetLowY,n))}else if("line"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Fa(e._startOpacity??0,e._targetOpacity,n)}),void 0!==e._introClipFraction&&(e._introClipFraction=n);let t=e._prevPath,i=e._targetPath;if(t&&i&&t.length===e.path.length)for(let r=0;e.path.length>r;r++)e.path[r][0]=Fa(t[r][0],i[r][0],n),e.path[r][1]=Fa(t[r][1],i[r][1],n)}else if("area"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:Fa(e._startOpacity??0,e._targetOpacity,n)}),void 0!==e._introClipFraction&&(e._introClipFraction=n);let t=e._prevTopPath,i=e._prevBottomPath,r=e._targetTopPath,o=e._targetBottomPath;if(t&&r&&t.length===e.topPath.length)for(let i=0;e.topPath.length>i;i++)e.topPath[i][0]=Fa(t[i][0],r[i][0],n),e.topPath[i][1]=Fa(t[i][1],r[i][1],n);if(i&&o&&i.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=Fa(i[t][0],o[t][0],n),e.bottomPath[t][1]=Fa(i[t][1],o[t][1],n)}}if(o>=1){for(let e of i.scene){if(void 0!==e._targetOpacity){let 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){let t=e._targetPath;if(t)for(let i=0;e.path.length>i;i++)e.path[i]=t[i];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){let t=e._targetTopPath,i=e._targetBottomPath;if(t)for(let i=0;e.topPath.length>i;i++)e.topPath[i]=t[i];if(i)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=i[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(i.exitNodes.length>0){let e=new Set(i.exitNodes);i.scene=i.scene.filter(t=>!e.has(t)),i.exitNodes=[]}return i.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,i}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null,function(e){for(let t of e){if(void 0!==t._targetOpacity){let e=t._targetOpacity;t.style={...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}if("point"===t.type)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("glyph"===t.type)void 0!==t._targetX&&(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||"heatcell"===t.type)void 0!==t._targetX&&(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)void 0!==t._targetX&&(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||"area"===t.type){if(t._introClipFraction=void 0,"line"===t.type&&t._targetPath){for(let e=0;t.path.length>e;e++)t.path[e]=t._targetPath[e];t._prevPath=void 0,t._targetPath=void 0}if("area"===t.type){if(t._targetTopPath)for(let e=0;t.topPath.length>e;e++)t.topPath[e]=t._targetTopPath[e];if(t._targetBottomPath)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=t._targetBottomPath[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0}}}}(this.scene),this.exitNodes=[]}groupData(e){let{result:t,cache:i}=function(e,t,i,r){if(r&&r.version===i&&r.group===t&&r.data===e)return{result:r.result,cache:r};let o;if(t){let i=new Map;for(let r of e){let e=t(r);i.has(e)||i.set(e,[]),i.get(e).push(r)}o=Array.from(i.entries()).map(([e,t])=>({key:e,data:t}))}else o=[{key:"_default",data:e}];return{result:o,cache:{version:i,group:t,data:e,result:o}}}(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=i,t}resolveColorMap(e){let{map:t,cache:i}=function(e,t,i,r,o){if(o&&o.version===r)return{map:o.map,cache:o};let n=new Set;if(t)for(let i of e){let e=t(i);e&&n.add(e)}let a=Array.from(n).sort(),s=a.join("\0");if(o&&o.key===s){let e={...o,version:r};return{map:e.map,cache:e}}let l=ke(i.colorScheme,i.themeCategorical,_f),c=new Map;for(let e=0;a.length>e;e++)c.set(a[e],ls(i.colorScheme,a[e])??l[e%l.length]);return{map:c,cache:{key:s,map:c,version:r}}}(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=i,t}resolveLineStyle(e,t){return function(e,t,i,r){let o=e.lineStyle;if("function"==typeof o){let e=o(i||{},t);if(e&&!e.stroke&&t){let i=r(t);if(i)return{...e,stroke:i}}return e}let n=e.themeSemantic?.primary;return o&&"object"==typeof o?{stroke:o.stroke||n||"#007bff",strokeWidth:o.strokeWidth??2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity,cursor:o.cursor}:{stroke:r(t)||n||"#007bff",strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return function(e,t,i,r){if(e.areaStyle){let o=e.areaStyle(i||{});if(o&&!o.fill&&t){let e=r(t);if(e)return{...o,fill:e,stroke:o.stroke||e}}return o}let o=e.lineStyle;if("function"==typeof o){let e=o(i||{},t);if(e&&!e.fill&&t){let i=r(t);if(i)return{...e,fill:i,stroke:e.stroke||i}}return e}let n=e.themeSemantic?.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||n||"#4e79a7",fillOpacity:o.fillOpacity??.7,stroke:o.stroke||n||"#4e79a7",strokeWidth:o.strokeWidth??2,cursor:o.cursor};let a=r(t)||n||"#4e79a7";return{fill:a,fillOpacity:.7,stroke:a,strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(t){let{color:i,groupColorCounter:r}=function(e){let{group:t,colorMapCache:i,groupColorMap:r,groupColorMapCap:o,config:n}=e,{groupColorCounter:a}=e,s=ls(n.colorScheme,t);if(s)return{color:s,groupColorCounter:a};if(i){let e=i.map.get(t);if(e)return{color:e,groupColorCounter:a}}let l=r.get(t);if(l)return{color:l,groupColorCounter:a};let c=ke(n.colorScheme,n.themeCategorical,_f);if(0===c.length)return{color:null,groupColorCounter:a};let u=c[a%c.length];if(a++,r.set(t,u),r.size>o){let e=r.keys().next().value;void 0!==e&&r.delete(e)}return{color:u,groupColorCounter:a}}({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:e.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=r,i}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();let t=Ta(e),i=this.getPointId,r=e=>t.has(i(e));hs(this.buffer,this.timestampBuffer,r);let o=this.buffer.remove(r);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(let 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");let i=Ta(e),r=this.getPointId,o=new Set;this.buffer.forEach((e,t)=>{i.has(r(e))&&o.add(t)});let n=this.buffer.update(e=>i.has(r(e)),t);if(0===n.length)return this.updateResults.recordNoop("update"),n;for(let e of n)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",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(e,t){let i=this._customRestyle;if(i)for(let r of e){let e=this._baseStyles.get(r)??r.style??{},o=i(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){let t={...this.config},i=Object.keys(e).filter(i=>e[i]!==t[i]);"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();let n="chartType"in e&&e.chartType!==t.chartType||"runtimeMode"in e&&e.runtimeMode!==t.runtimeMode;if(n||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){let e=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,i=e&&this.config.valueAccessor||this.config.yAccessor,a=e&&t.valueAccessor||t.yAccessor,s=n||!Sa(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),l=n||!Sa(i,a);(s||l)&&(e?(this.getX=Ma(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Ma(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Ma(this.config.xAccessor,"x"),this.getY=Ma(this.config.yAccessor,"y")),l&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=Ka(this.config)),r=!0,o=!0)}if("groupAccessor"in e&&!Sa(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?$a(this.config.groupAccessor):void 0,r=!0),"categoryAccessor"in e&&!Sa(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?$a(this.config.categoryAccessor):void 0,r=!0),"sizeAccessor"in e&&!Sa(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Ma(this.config.sizeAccessor,"size"):void 0,r=!0),"symbolAccessor"in e&&!Sa(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?$a(this.config.symbolAccessor):void 0,r=!0),"colorAccessor"in e&&!Sa(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?$a(this.config.colorAccessor):void 0,r=!0),"y0Accessor"in e&&!Sa(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?Ma(this.config.y0Accessor,"y0"):void 0,r=!0,o=!0),("boundsAccessor"in e&&!Sa(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=Ka(this.config),r=!0,o=!0),"pointIdAccessor"in e&&!Sa(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?$a(this.config.pointIdAccessor):void 0,r=!0),"candlestick"===this.config.chartType&&(n||"openAccessor"in e&&!Sa(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!Sa(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!Sa(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!Sa(e.lowAccessor,t.lowAccessor))){let e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?Ma(this.config.openAccessor,"open"):void 0,this.getHigh=Ma(this.config.highAccessor,"high"),this.getLow=Ma(this.config.lowAccessor,"low"),this.getClose=t?Ma(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){let i=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(let o of i)if(e[o]!==t[o]){r=!0;break}}r&&(o&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(i,("bar"===this.config.chartType||"heatmap"===this.config.chartType)&&!this.config.trackHoverRows&>(t.areaStyle)!==gt(this.config.areaStyle))}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};Em.GROUP_COLOR_MAP_CAP=1e3;var Bm=Em;xs(Bm);import{area as Wm,line as jm}from"d3-shape";var Ym=(e,t,i,r)=>{let o=t.filter(e=>"area"===e.type);for(let t of o){if(2>t.topPath.length)continue;let i=!1;t.clipRect&&(e.save(),e.beginPath(),e.rect(t.clipRect.x,t.clipRect.y,t.clipRect.width,t.clipRect.height),e.clip(),i=!0);let o=t._introClipFraction;void 0!==o&&1>o&&(e.save(),e.beginPath(),e.rect(0,0,r.width*o,r.height),e.clip());let n=Un(e,t.style.fill,"#4e79a7"),a=t._decayOpacities,s=!(!t.colorThresholds?.length||!t.rawValues||t.rawValues.length!==t.topPath.length),l=!!t.strokeColorBands?.length;if(a&&a.length===t.topPath.length&&!s&&!l){let i=t.style.fillOpacity??.7;e.fillStyle=n;for(let r=0;t.topPath.length-1>r;r++)e.globalAlpha=.5*(a[r]+a[r+1])*i,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();let r=t.style.strokeWidth??2;if(t.style.stroke&&"none"!==t.style.stroke&&r>0){e.strokeStyle=ir(e,t.style.stroke)||t.style.stroke,e.lineWidth=r,e.setLineDash([]);for(let i=0;t.topPath.length-1>i;i++)e.globalAlpha=.5*(a[i]+a[i+1]),e.beginPath(),e.moveTo(t.topPath[i][0],t.topPath[i][1]),e.lineTo(t.topPath[i+1][0],t.topPath[i+1][1]),e.stroke()}e.globalAlpha=1;continue}let c=t.style.opacity??1;if(Ts(e,t),t.fillGradient&&t.fillGradient.stops.length>=2&&t.fillGradient){let i=1/0;for(let e of t.topPath)i>e[1]&&(i=e[1]);let r=-1/0;for(let e of t.bottomPath)e[1]>r&&(r=e[1]);let o=Zn(e,t.fillGradient,"string"==typeof n?n:"#4e79a7",0,i,0,r);e.fillStyle=o||n,e.globalAlpha=c}else e.globalAlpha=(t.style.fillOpacity??.7)*c,e.fillStyle=n;e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(Ts(e,t),Rs(e,t));let u=t.style.strokeWidth??2;if(t.style.stroke&&"none"!==t.style.stroke&&u>0){e.globalAlpha=c;let i=ir(e,t.style.stroke)||t.style.stroke,r=s||l||!t.strokeGradient||2>t.topPath.length?null:Zn(e,t.strokeGradient,i,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0);if(e.lineWidth=u,e.setLineDash([]),l){let r=1/0,o=-1/0;for(let[e]of t.topPath)r=Math.min(r,e),o=Math.max(o,e);let n=e.lineWidth;for(let a of t.strokeColorBands){e.save(),e.beginPath(),e.rect(r-n,a.y,o-r+2*n,a.height),e.clip();let s=a.color??i;e.strokeStyle=ir(e,s)||s,e.globalAlpha=c*(a.opacity??1),Cs(e,t),e.stroke(),e.restore()}}else if(s){let r=Ls(t.topPath,t.rawValues,t.colorThresholds,i);for(let t of r){e.beginPath(),e.strokeStyle=ir(e,t.color)||t.color,e.moveTo(t.path[0][0],t.path[0][1]);for(let i=1;t.path.length>i;i++)e.lineTo(t.path[i][0],t.path[i][1]);e.stroke()}}else e.strokeStyle=r||i,Cs(e,t),e.stroke()}void 0!==o&&1>o&&e.restore(),i&&e.restore(),e.globalAlpha=1}};import{line as Xm}from"d3-shape";var qm=(e,t,i,r)=>{let o=t.filter(e=>"line"===e.type);for(let t of o){if(2>t.path.length)continue;let i=t._introClipFraction;void 0!==i&&1>i&&(e.save(),e.beginPath(),e.rect(0,0,r.width*i,r.height),e.clip());let o=t.style.stroke||"#007bff",n=ir(e,o)||o,a=t.style.strokeWidth??2,s=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),a>0&&(e.lineWidth=a),e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade&&a>0){Os(e,t.path,n,a,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}let c=Hn(t.curve),u=s&&s.length>0&&l&&l.length===t.path.length,d=t._decayOpacities;if(a>0&&d&&d.length===t.path.length&&!u){e.strokeStyle=n;let i=t.style.opacity??1;for(let r=0;t.path.length-1>r;r++)e.globalAlpha=.5*(d[r]+d[r+1])*i,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(a>0&&!u){e.beginPath();let i=t.strokeGradient&&t.path.length>=2?Zn(e,t.strokeGradient,n,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=i||n,c)Xm().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{let[i,r]=t.path[0];e.moveTo(i,r);for(let i=1;t.path.length>i;i++)e.lineTo(t.path[i][0],t.path[i][1])}e.stroke()}else if(a>0){let i=Ls(t.path,l,s,n);for(let t of i){e.beginPath(),e.strokeStyle=ir(e,t.color)||t.color,e.moveTo(t.path[0][0],t.path[0][1]);for(let i=1;t.path.length>i;i++)e.lineTo(t.path[i][0],t.path[i][1]);e.stroke()}}if(t.style.fill&&t.style.fillOpacity&&t.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=t.style.fillOpacity,e.fillStyle=Un(e,t.style.fill,t.style.fill),c&&!u)Xm().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{let[i,r]=t.path[0];e.moveTo(i,r);for(let i=1;t.path.length>i;i++)e.lineTo(t.path[i][0],t.path[i][1])}let i=t.path[0][0];e.lineTo(t.path[t.path.length-1][0],r.height),e.lineTo(i,r.height),e.closePath(),e.fill()}void 0!==i&&1>i&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}},Gm=(e,t,i,r)=>{let o=t.filter(e=>"point"===e.type);if(0!==o.length){e.save();try{let t=e.globalAlpha,i=[],r="",n=i=>{e.beginPath(),e.arc(i.x,i.y,i.r,0,2*Math.PI),e.globalAlpha=t*(i.style.opacity??i.style.fillOpacity??1),e.fillStyle=Un(e,i.style.fill,"#4e79a7"),e.fill();let r=i.style.strokeWidth??1;i.style.stroke&&"none"!==i.style.stroke&&r>0&&(e.strokeStyle=Un(e,i.style.stroke,i.style.stroke),e.lineWidth=r,e.stroke()),function(e,t,i=.6){if(!$s(t))return;let r=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,o=t.cx??t.x??0,n=t.cy??t.y??0;e.beginPath(),e.arc(o,n,r,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*i,e.stroke()}(e,i)},a=()=>{if(0===i.length)return;if(1===i.length)return n(i[0]),i=[],void(r="");let o=i[0];e.globalAlpha=t*(o.style.opacity??o.style.fillOpacity??1),e.beginPath();for(let t of i)e.moveTo(t.x+t.r,t.y),e.arc(t.x,t.y,t.r,0,2*Math.PI);e.fillStyle=Un(e,o.style.fill,"#4e79a7"),e.fill();let a=o.style.strokeWidth??1;o.style.stroke&&"none"!==o.style.stroke&&a>0&&(e.strokeStyle=Un(e,o.style.stroke,o.style.stroke),e.lineWidth=a,e.stroke()),i=[],r=""};for(let e of o){let t=e.style.opacity??e.style.fillOpacity??1,o=e.style.fill;if($s(e)||null!=o&&"string"!=typeof o||1>t){a(),n(e);continue}let s=e.style.strokeWidth??1,l=`${o??"#4e79a7"}\0${e.style.stroke&&"none"!==e.style.stroke&&s>0?e.style.stroke+"":""}\0${s}\0${e.r}\0${t}`;i.length>0&&l!==r&&a(),r=l,i.push(e),i.length>=2048&&a()}a()}finally{e.restore()}}},Vm={chartType:"line",buildScene:(e,t)=>function(e,t){let i=e.groupData(t),r=[],o=e.config.annotations?.filter(_s).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){let{perSeries:o,aggregate:n}=ks(e.ribbons);if(n.length>0&&r.push(...As(e,t,n)),o.length>0)for(let t of i)r.push(...Ss(e,t.data,t.key,o))}for(let t of i){let i=e.resolveLineStyle(t.key,yt(t.data)),n=Ja(t.data,e.scales,e.getX,e.getY,i,t.key);o&&o.length>0&&(n.colorThresholds=o),e.config.curve&&"linear"!==e.config.curve&&(n.curve=e.config.curve),e.config.lineGradient&&(n.strokeGradient=e.config.lineGradient),r.push(n)}return Ms(e,i,r),r}(e,t),canvasRenderers:[Ym,qm,Gm]},Hm={chartType:"area",buildScene:(e,t)=>function(e,t){let i=e.groupData(t),r=[];if(e.ribbons&&e.ribbons.length>0){let{perSeries:o,aggregate:n}=ks(e.ribbons);if(n.length>0&&r.push(...As(e,t,n)),o.length>0)for(let t of i)r.push(...Ss(e,t.data,t.key,o))}let o=e.scales.y.domain(),n=o[0],a=e.config.semanticLineStops?.filter(e=>Number.isFinite(e.offset)).map(e=>({value:o[0]+Math.max(0,Math.min(1,e.offset))*(o[1]-o[0]),color:e.color,opacity:e.opacity,thresholdType:"greater"})).sort((e,t)=>e.value-t.value),s=a&&a.length>0?(()=>{let t=a.reduce((e,t)=>(e.at(-1)?.value===t.value?e[e.length-1]=t:e.push(t),e),[]),i=[{from:o[0],to:t[0].value,color:t[0].color,opacity:t[0].opacity}];for(let e=0;t.length>e;e++)i.push({from:t[e].value,to:t[e+1]?.value??o[1],color:t[e].color,opacity:t[e].opacity});return i.map(({from:t,to:i,color:r,opacity:o})=>{let n=e.scales.y(t),a=e.scales.y(i);return{y:Math.min(n,a),height:Math.abs(a-n),color:r,...null!=o&&{opacity:o}}}).filter(e=>e.height>0)})():void 0,l=e.getY0?t=>e.getY0(t)??n:void 0;for(let t of i){let i=e.resolveAreaStyle(t.key,yt(t.data)),o=es(t.data,e.scales,e.getX,e.getY,n,i,t.key,l),c=Fs(e.config.gradientFill);c&&(o.fillGradient=c),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),a&&a.length>0&&(o.colorThresholds=a,o.strokeColorBands=s),r.push(o)}return Ms(e,i,r),r}(e,t),canvasRenderers:[Ym,Gm]},Um={chartType:"stackedarea",buildScene:(e,t)=>function(e,t){let i=e.groupData(t),r=e.config.stackOrder??"key",o=()=>i.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"!==r)if("key"===r)o();else if("asc"===r||"desc"===r||"insideOut"===r){let t=new Map;for(let r of i){let i=0;for(let t of r.data){let r=e.getX(t),o=e.getY(t);Number.isFinite(r)&&Number.isFinite(o)&&(i+=o)}t.set(r.key,i)}let o=(e,t)=>t>e?-1:e>t?1:0;if("asc"===r)i.sort((e,i)=>{let r=(t.get(e.key)??0)-(t.get(i.key)??0);return 0!==r?r:o(e.key,i.key)});else if("desc"===r)i.sort((e,i)=>{let r=(t.get(i.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,i.key)});else{let e=[...i].sort((e,i)=>{let r=(t.get(i.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,i.key)}),r=[],n=[],a=0,s=0;for(let i of e)s>a?(r.push(i),a+=t.get(i.key)??0):(n.push(i),s+=t.get(i.key)??0);i.length=0,i.push(...n.reverse(),...r)}}else o();let n=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,a=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:s,stackedTops:l}=function(e,t,i,r,o,n,a,s="zero"){let l=new Set,c=new Map;for(let t of e){let e=new Map;for(let o of t.data){let t=i(o),n=r(o);if(!Number.isFinite(t)||(l.add(t),!Number.isFinite(n)))continue;let a=e.get(t);a?(a.value+=n,a.sources?a.sources.push(o):a.sources=[a.datum,o]):e.set(t,{value:n,datum:o})}c.set(t.key,e)}let u,d=Array.from(l).sort((e,t)=>e-t);if(n){u=new Map;for(let t of d){let i=0;for(let r of e)i+=c.get(r.key)?.get(t)?.value||0;u.set(t,i||1)}}let h=ts(d,e.map(e=>e.key),(e,t)=>c.get(e)?.get(t)?.value||0,s),f="diverging"===s&&!n,p=[],y=new Map,g=new Map,m=new Map,b=new Map;for(let e of d)g.set(e,h.get(e)??0),m.set(e,0),b.set(e,0);for(let i of e){let e=c.get(i.key),r=new Map,s=[],l=[],h=[],x=[],v=[],w=!1,k=()=>{if(0!==s.length){if(s.length>=2){let e=w?s.map((e,t)=>t).sort((e,t)=>s[e][0]-s[t][0]):void 0,t={type:"area",topPath:e?e.map(e=>s[e]):s,bottomPath:e?e.map(e=>l[e]):l,rawValues:e?e.map(e=>h[e]):h,style:o(i.key,yt(i.data)),datum:e?e.map(e=>x[e]):x,accessibleDatum:e?e.map(e=>v[e]):v,group:i.key};a&&(t.curve=a),p.push(t)}s=[],l=[],h=[],x=[],v=[],w=!1}};for(let o of d){let a,c,d=e.get(o),p=void 0!==d,y=d?.value??0;if(n&&p&&(y/=u.get(o)),!p||!Number.isFinite(y)||0===y){k();continue}f?y>0?(a=m.get(o),c=a+y,m.set(o,c)):(a=b.get(o),c=a+y,b.set(o,c)):(a=g.get(o),c=a+y,g.set(o,c));let A=t.x(o),S=t.y(a),M=t.y(c);if(!Number.isFinite(A)||!Number.isFinite(S)||!Number.isFinite(M)){k();continue}let _=d.sources,$=d.value,P=_?{..._[0],__aggregateValue:$,__aggregateCount:_.length,__aggregateRows:_}:d.datum;s.length>0&&s[s.length-1][0]>A&&(w=!0),s.push([A,M]),l.push([A,S]),x.push(P),h.push($),v.push(_?{x:o,value:$,group:i.key,observations:_.length}:P),r.set(o,c)}k(),y.set(i.key,r)}return{nodes:p,stackedTops:y}}(i,e.scales,e.getX,e.getY,(t,i)=>e.resolveAreaStyle(t,i),e.config.normalize,n,a),c=s;if(e.config.pointStyle){let t=new WeakMap;for(let r of i){let i=l.get(r.key);if(i)for(let o of r.data){let r=e.getX(o),n=e.getY(o);null!=r&&!Number.isNaN(r)&&null!=n&&!Number.isNaN(n)&&i.has(r)&&t.set(o,i.get(r))}}Ms(e,i,c,i=>t.get(i)??e.getY(i))}return c}(e,t),canvasRenderers:[Ym,Gm]},Km={chartType:"mixed",buildScene:(e,t)=>function(e,t){let i=e.groupData(t),r=[],o=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){let{perSeries:o,aggregate:n}=ks(e.ribbons);if(n.length>0&&r.push(...As(e,t,n)),o.length>0)for(let t of i)r.push(...Ss(e,t.data,t.key,o))}let n=e.scales.y.domain()[0],a=e.getY0?t=>e.getY0(t)??n:void 0;for(let t of i)if(o.has(t.key)){let i=e.resolveAreaStyle(t.key,yt(t.data)),o=es(t.data,e.scales,e.getX,e.getY,n,i,t.key,a),s=Fs(e.config.gradientFill);s&&(o.fillGradient=s),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}else{let i=e.resolveLineStyle(t.key,yt(t.data)),o=Ja(t.data,e.scales,e.getX,e.getY,i,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 Ms(e,i,r),r}(e,t),canvasRenderers:[Ym,qm,Gm]};import{symbol as Zm,symbolCircle as Qm,symbolCross as Jm,symbolDiamond as eb,symbolSquare as tb,symbolStar as ib,symbolTriangle as rb,symbolWye as ob}from"d3-shape";var nb={circle:Qm,square:tb,triangle:rb,diamond:eb,star:ib,cross:Jm,wye:ob},ab=new Set(["circle","square","triangle","diamond","star","cross","wye","chevron"]),sb=["circle","triangle","diamond","star","square","chevron","cross","wye"],lb=[40,40],cb=[.5,.5],ub=null,db=new Map,hb=(e,t)=>{let i=e.globalAlpha;for(let r of t)"symbol"===r.type&&Gs(e,r,r.x,r.y,i,"#4e79a7");e.globalAlpha=i},fb=[Gm,hb],pb={chartType:"scatter",buildScene:(e,t)=>Es(e,t),canvasRenderers:fb},yb={chartType:"bubble",buildScene:(e,t)=>Es(e,t),canvasRenderers:fb},gb=256,mb=new Map,bb=(e,t,i,r)=>{let o=t.filter(e=>"heatcell"===e.type);e.save();try{let t=ir(e,"var(--semiotic-font-family, sans-serif)")||"sans-serif";for(let i of o){let r=i.style;null!=r?.opacity&&(e.globalAlpha=r.opacity);let o=Kn(e,i.fill,"#4e79a7");e.fillStyle=o,e.fillRect(i.x,i.y,i.w,i.h);let n=Math.max(0,r?.strokeWidth??1);if(n>0&&(e.strokeStyle=ir(e,r?.stroke??"var(--semiotic-surface, #fff)"),e.lineWidth=n,e.strokeRect(i.x,i.y,i.w,i.h)),Ps(e,i),e.globalAlpha=1,i.showValues&&null!=i.value){if(20>i.w||20>i.h)continue;let r=i.valueFormat?i.valueFormat(i.value):Qs(i.value),n=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h))),a=i.x+i.w/2,s=i.y+i.h/2;e.fillStyle=Zs(e,"string"==typeof o?o:"#4e79a7"),e.font=`${n}px ${t}`,e.textAlign="center",e.textBaseline="middle",e.fillText(r,a,s)}}}finally{e.restore()}},xb={chartType:"heatmap",buildScene:(e,t,i)=>function(e,t,i){if(e.config.heatmapAggregation)return Ks(e,t,i);if(0===t.length)return[];let r=Ma(e.config.valueAccessor,"value"),o=_a(e.config.xAccessor,"x"),n=_a(e.config.yAccessor,"y"),a=new Map,s=new Map,l=Array(t.length),c=Array(t.length);for(let e=0;t.length>e;e++){let i=t[e],r=o(i),u=n(i);l[e]=r,c[e]=u,a.has(r)||a.set(r,a.size),s.has(u)||s.set(u,s.size)}let u=a.size,d=s.size;if(0===u||0===d)return[];let h=Array.from(a.keys()),f=Array.from(s.keys()),p=h.every(e=>"number"==typeof e&&!isNaN(e)),y=f.every(e=>"number"==typeof e&&!isNaN(e)),g=4096;if(p&&y&&u*d>g&&t.length>g){let r=new Set;for(let o=0;t.length>o;o++){let n=a.get(l[o]),d=s.get(c[o]);if(void 0!==n&&void 0!==d&&(r.add(d*u+n),r.size>g))return Ks({...e,config:{...e.config,heatmapAggregation:e.config.valueAccessor?"mean":"count"}},t,i)}}if(p){h.sort((e,t)=>Number(e)-Number(t)),a.clear();for(let e=0;h.length>e;e++)a.set(h[e],e)}if(y){f.sort((e,t)=>Number(e)-Number(t)),s.clear();for(let e=0;f.length>e;e++)s.set(f[e],e)}let m=new Float64Array(t.length),b=new Float64Array(t.length),x=Array(t.length),v=new Map,w=0;for(let e=0;t.length>e;e++){let i=t[e],o=a.get(l[e]),n=s.get(c[e]);if(void 0===o||void 0===n)continue;let d,h=r(i),f=n*u+o,p=v.get(f);void 0!==p?d=p:(d=w++,v.set(f,d)),m[d]=f,b[d]=h,x[d]=i}let k=1/0,A=-1/0;for(let e=0;w>e;e++){let t=b[e];isFinite(t)&&(k>t&&(k=t),t>A&&(A=t))}if(!isFinite(k)||!isFinite(A))return[];let S=e.config.heatmapColorScale,M=S?void 0:Hs("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),_=i.width/u,$=i.height/d,P=e.config.showValues,R=e.config.heatmapValueFormat,I=[];for(let t=0;w>t;t++){let i=b[t];if(!isFinite(i))continue;let r=m[t],o=r%u,n=(r-o)/u,a=Vs(i,k,A),s=S?S(i):M[a],l=x[t];I.push(Us(ns(o*_,(d-1-n)*$,_,$,s,l,P?{value:i,showValues:!0,valueFormat:R}:{value:i}),l,e))}return I}(e,t,i),canvasRenderers:[bb]},vb=(e,t,i,r)=>{let o=t.filter(e=>"rect"===e.type);for(let t of o){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)ol(e,t);else if(t.cornerRadii&&Js(t.cornerRadii))e.fillStyle=il(e,t),tl(e,t),e.fill(),rl(e,t)&&e.stroke();else if(t.roundedTop&&t.roundedTop>0){e.fillStyle=il(e,t);let i=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();let{x:r,y:o,w:n,h:a}=t;switch(t.roundedEdge){case"right":e.moveTo(r,o),e.lineTo(r+n-i,o),e.arcTo(r+n,o,r+n,o+i,i),e.lineTo(r+n,o+a-i),e.arcTo(r+n,o+a,r+n-i,o+a,i),e.lineTo(r,o+a);break;case"left":e.moveTo(r+n,o),e.lineTo(r+i,o),e.arcTo(r,o,r,o+i,i),e.lineTo(r,o+a-i),e.arcTo(r,o+a,r+i,o+a,i),e.lineTo(r+n,o+a);break;case"bottom":e.moveTo(r,o),e.lineTo(r+n,o),e.lineTo(r+n,o+a-i),e.arcTo(r+n,o+a,r+n-i,o+a,i),e.lineTo(r+i,o+a),e.arcTo(r,o+a,r,o+a-i,i);break;default:e.moveTo(r,o+a),e.lineTo(r,o+i),e.arcTo(r,o,r+i,o,i),e.lineTo(r+n-i,o),e.arcTo(r+n,o,r+n,o+i,i),e.lineTo(r+n,o+a)}e.closePath(),e.fill(),rl(e,t)&&e.stroke()}else e.fillStyle=il(e,t),e.fillRect(t.x,t.y,t.w,t.h),rl(e,t)&&e.strokeRect(t.x,t.y,t.w,t.h);Ps(e,t),e.globalAlpha=1}},wb={chartType:"bar",buildScene:(e,t)=>function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};let i=Za(t,e.getX,e.getY,e.config.binSize,e.getCategory,!!e.config.trackHoverRows||gt(e.config.areaStyle));if(0===i.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){let t=new Set;for(let e of i.values())for(let i of e.categories.keys())t.add(i);let o=e.config.barColors?Object.keys(e.config.barColors):[],n=new Set(o),a=Array.from(t).filter(e=>!n.has(e)).sort(),s=o.filter(e=>t.has(e)),l=s.join("\0")+""+a.join("\0");e.barCategoryCache&&e.barCategoryCache.key===l?r=e.barCategoryCache.order:(r=[...s,...a],e.barCategoryCache={key:l,order:r})}let o=[],n=e.scales,[a,s]=n.x.domain(),l=e.config.barStyle,c=e.config.themeSemantic?.primary,u=l?.gap,d="number"!=typeof u||0>u?1:u,h={};l?.stroke&&(h.stroke=l.stroke),"number"==typeof l?.strokeWidth&&(h.strokeWidth=l.strokeWidth),"number"==typeof l?.opacity&&(h.opacity=l.opacity),l?.cursor&&(h.cursor=l.cursor);for(let t of i.values()){let i=Math.max(t.start,a),u=Math.min(t.end,s);if(i>=u)continue;let f=n.x(i),p=n.x(u),y=Math.abs(p-f),g=y>d+1?d:0,m=Math.min(f,p)+g/2,b=Math.max(y-g,1);if(b>0)if(r&&t.categories.size>0){let i=0;for(let a of r){let r=t.categories.get(a)||0;if(0===r)continue;let s=n.y(i),u=n.y(i+r),d=Math.min(s,u),f=Math.abs(s-u),p=(e.config.barColors?Se(e.config.barColors,a):void 0)??l?.fill??c??"#4e79a7",y=ht({binStart:t.start,binEnd:t.end,total:t.total,category:a,categoryValue:r},t.categoryRows?.get(a)),g=e.config.areaStyle?.(y)??{};o.push(os(m,d,b,f,{fill:p,...h,...g},y,a)),i+=r}}else{let i=n.y(0),r=n.y(t.total),a=Math.min(i,r),s=Math.abs(i-r),u=l?.fill||c||"#007bff",d=ht({binStart:t.start,binEnd:t.end,total:t.total},t.rows),f=e.config.areaStyle?.(d)??{};o.push(os(m,a,b,s,{fill:u,...h,...f},d))}}let f=new Set;for(let e of i.values())f.add(e.start),f.add(e.end);return{nodes:o,binBoundaries:Array.from(f).sort((e,t)=>e-t)}}(e,t),canvasRenderers:[vb]},kb={chartType:"swarm",buildScene:(e,t)=>function(e,t){let i=[],r=e.config.swarmStyle||{},o=r.radius??3,n=r.fill??e.config.themeSemantic?.primary??"#007bff",a=r.opacity??.7,s=r.stroke,l=r.strokeWidth,c=r.cursor;for(let r of t){let t=e.getX(r),u=e.getY(r);if(null==u||Number.isNaN(u))continue;let d=e.scales.x(t),h=e.scales.y(u),f=n;if(e.getCategory){let t=e.getCategory(r)+"";f=(e.config.barColors?Se(e.config.barColors,t):void 0)??f}let{r:p,...y}=e.config.pointStyle?.(r)??{},g={type:"point",x:d,y:h,r:p??o,style:{fill:f,opacity:a,stroke:s,strokeWidth:l,cursor:c,...y},datum:r};e.getPointId&&(g.pointId=e.getPointId(r)+""),i.push(g)}return i}(e,t),canvasRenderers:[Gm]},Ab=(e,t,i,r)=>{vb(e,t);let o=t.filter(e=>"rect"===e.type);if(2>o.length)return;let n=o[0].datum,a=n?._connectorStroke;if(a){e.save(),e.strokeStyle=ir(e,a)||a,e.lineWidth=n?._connectorWidth??1,e.setLineDash([]);for(let t=0;o.length-1>t;t++){let r=o[t],n=o[t+1],a=r.datum,s=n.datum;if(null==a?.cumEnd||null==s?.baseline)continue;let l=i.y(a.cumEnd),c=r.x+r.w,u=n.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}},Sb={chartType:"waterfall",buildScene:(e,t,i)=>function(e,t,i){let r=[],o=e.scales,n=e.config.waterfallStyle,a=t.filter(t=>{let i=e.getY(t),r=e.getX(t);return null!=i&&!Number.isNaN(i)&&null!=r&&isFinite(r)});if(0===a.length)return r;let s=n?.positiveColor??e.config.themeSemantic?.success??"#28a745",l=n?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",c=n?.gap??1,u=n?.stroke,d=n?.strokeWidth,h=n?.opacity,f=0;for(let t=0;a.length>t;t++){let p=a[t],y=e.getX(p),g=e.getY(p),m=f+g,b=o.x(y),x=t>0?o.x(e.getX(a[t-1])):void 0,v=a.length-1>t?o.x(e.getX(a[t+1])):void 0,w=null!=x?(x+b)/2:null!=v?b-(v-b)/2:b-i.width/20,k=null!=v?(b+v)/2:null!=x?b+(b-x)/2:b+i.width/20,A=Math.min(w,k)+c/2,S=Math.max(w,k)-c/2-A;if(0>=S){f=m;continue}let M=o.y(f),_=o.y(m),$=Math.min(M,_),P=Math.abs(M-_),R=0>g?l:s,I={...p,baseline:f,cumEnd:m,delta:g,_connectorStroke:n?.connectorStroke,_connectorWidth:n?.connectorWidth},L={fill:R,stroke:u,strokeWidth:d,opacity:h,cursor:n?.cursor,...e.config.areaStyle?.(I)};r.push(os(A,$,S,P,L,I)),f=m}return r}(e,t,i),canvasRenderers:[Ab]},Mb=(e,t,i,r)=>{for(let i of t){if("candlestick"!==i.type)continue;let t=i;e.save();let o=(t._decayOpacity??1)*(t.style?.opacity??1);1!==o&&(e.globalAlpha=o);let n=ir(e,t.wickColor)||t.wickColor,a=60>r.height,s=a?Math.max(t.wickWidth,2):t.wickWidth,l=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=n,e.lineWidth=s,e.stroke()};if(a||l(),t.isRange){let i=t.dotRadius??Math.max(2,Math.min(t.bodyWidth/2,.12*r.height)),o=Kn(e,rr(t.style?.fill)?t.style.fill:t.wickColor,t.wickColor);e.fillStyle=o,e.beginPath(),e.arc(t.x,t.highY,i,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,i,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){let i=Math.min(t.openY,t.closeY),r=Math.abs(t.openY-t.closeY),o=t.isUp?t.upColor:t.downColor,n=Kn(e,rr(t.style?.fill)?t.style.fill:o,o),a="string"==typeof n?n:ir(e,t.wickColor)||t.wickColor;e.fillStyle=n,e.fillRect(t.x-t.bodyWidth/2,i,t.bodyWidth,Math.max(r,1)),e.strokeStyle=a,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,i,t.bodyWidth,Math.max(r,1))}a&&l(),e.restore()}},_b={chartType:"candlestick",buildScene:(e,t,i)=>function(e,t,i){if(!e.getHigh||!e.getLow||!e.scales)return[];let r=e.config.candlestickRangeMode??!1;if(!(r||e.getOpen&&e.getClose))return[];let o=[],n=e.config.candlestickStyle||{},a=n.rangeColor||"#6366f1",s=r?a:n.upColor||"#28a745",l=r?a:n.downColor||"#dc3545",c=r?a:n.wickColor||"#333",u=n.wickWidth||(r?2:1),d=n.bodyWidth??0;if(null==n.bodyWidth){let i=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);if(i.length>1){let t=1/0,r=e.scales.x(i[0]);for(let o=1;i.length>o;o++){let n=e.scales.x(i[o]),a=Math.abs(n-r);a>0&&t>a&&(t=a),r=n}d=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else d=6}for(let a of t){let t=e.getX(a);if(null==t||Number.isNaN(t))continue;let h=e.getHigh(a),f=e.getLow(a);if(null==h||Number.isNaN(h)||null==f||Number.isNaN(f))continue;let p=r?h:e.getOpen(a),y=r?f:e.getClose(a);if(!r&&(null==p||Number.isNaN(p)||null==y||Number.isNaN(y)))continue;let g=y>=p,m=e.config.pointStyle?.(a)??{},b="string"==typeof m.fill?m.fill:void 0,x="string"==typeof m.stroke?m.stroke:void 0,v="number"==typeof m.strokeWidth?m.strokeWidth:void 0,w="number"==typeof m.opacity?m.opacity:"number"==typeof m.fillOpacity?m.fillOpacity:void 0,k={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(p),closeY:e.scales.y(y),highY:e.scales.y(h),lowY:e.scales.y(f),bodyWidth:d,upColor:b&&g?b:s,downColor:b&&!g?b:l,wickColor:x??(r&&b?b:c),wickWidth:v??u,isUp:g,style:{cursor:n.cursor,...m,...void 0!==w&&{opacity:w}},datum:a};r&&(k.isRange=!0,k.dotRadius=Math.max(2,Math.min(d/2,.12*i.height))),o.push(k)}return o}(e,t,i),canvasRenderers:[Mb]},$b={chartType:"custom",buildScene:()=>[],canvasRenderers:[Ym,vb,bb,qm,Gm,hb,(e,t)=>{let i=e.globalAlpha;for(let r of t)"glyph"===r.type&&nl(e,r,r.x,r.y,i);e.globalAlpha=i},Mb,Gm,Ab]};import*as Pb from"react";import{area as Rb,line as Ib}from"d3-shape";import*as Lb from"react";import{jsx as Tb,jsxs as Cb}from"react/jsx-runtime";var Ob={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};import*as Fb from"react";import{jsx as Db}from"react/jsx-runtime";import{jsx as zb,jsxs as Nb}from"react/jsx-runtime";var Eb=new Set;import{scaleOrdinal as Bb}from"d3-scale";import{jsx as Wb,jsxs as jb}from"react/jsx-runtime";import{jsx as Yb,jsxs as Xb}from"react/jsx-runtime";var qb="var(--semiotic-bg, #ffffff)";import{jsx as Gb}from"react/jsx-runtime";import{jsx as Vb,jsxs as Hb}from"react/jsx-runtime";import{jsx as Ub,jsxs as Kb}from"react/jsx-runtime";import{jsx as Zb}from"react/jsx-runtime";var Qb={secondary:0,primary:3},Jb=new Set(["label","callout","callout-circle","callout-rect","text","widget"]),ex=(new Set(["label","callout","callout-circle","callout-rect"]),32),tx=6,ix=4,rx=8,ox=72,nx={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"},ax=new Set(["top-left","top-center","top-right","middle-left","center","middle-right","bottom-left","bottom-center","bottom-right"]);import{jsx as sx}from"react/jsx-runtime";var lx={fill:"var(--semiotic-text, #333)",fontSize:11,fontFamily:"inherit"};import{packEnclose as cx}from"d3-hierarchy";import{area as ux,curveBasis as dx,curveCardinal as hx,curveCatmullRom as fx,curveLinear as px,curveMonotoneX as yx,curveMonotoneY as gx,curveStep as mx,curveStepAfter as bx,curveStepBefore as xx}from"d3-shape";import*as vx from"react";import{jsx as wx,jsxs as kx}from"react/jsx-runtime";var Ax={linear:px,monotoneX:yx,monotoneY:gx,step:mx,stepAfter:bx,stepBefore:xx,basis:dx,cardinal:hx,catmullRom:fx};import{jsx as Sx,jsxs as Mx}from"react/jsx-runtime";var _x=16;import{jsx as $x}from"react/jsx-runtime";import*as Px from"react";import{jsx as Rx}from"react/jsx-runtime";var Ix=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];import{jsx as Lx,jsxs as Tx}from"react/jsx-runtime";var Cx={right:110,left:110,top:50,bottom:80};import{jsx as Ox,jsxs as Fx}from"react/jsx-runtime";var Dx={top:50,right:40,bottom:60,left:70},zx={top:20,right:80,bottom:20,left:80},Nx={top:40,right:40,bottom:40,left:40},Ex=new Set(["chord","force","circlepack","orbit"]);import{jsx as Bx,jsxs as Wx}from"react/jsx-runtime";import{Fragment as jx,jsx as Yx,jsxs as Xx}from"react/jsx-runtime";al();import*as qx from"react-dom/server";import{jsx as Gx,jsxs as Vx}from"react/jsx-runtime";import{jsx as Hx,jsxs as Ux}from"react/jsx-runtime";import{jsx as Kx,jsxs as Zx}from"react/jsx-runtime";var Qx={top:4,bottom:4,left:4,right:4},Jx={frameType:"xy",buildProps:au,renderStatic:function(e,t){let{data:i,colorBy:r,colorScheme:o,common:n,rest:a}=su(e),[s,l]=n.size??[600,400],c=a.minimap&&"object"==typeof a.minimap?a.minimap:{},u=lu(c.height,60),d=n.margin,h=c.margin&&"object"==typeof c.margin?c.margin:{},f={top:lu(h.top,0),right:lu(h.right,lu(d?.right,20)),bottom:lu(h.bottom,20),left:lu(h.left,lu(d?.left,40))},p=u+f.top+f.bottom,y=a.frameProps&&"object"==typeof a.frameProps?a.frameProps:{},g={...a,xAccessor:a.xAccessor||"x",yAccessor:a.yAccessor||"y"},m={...n,size:[s,l],xExtent:y.xExtent??a.brushExtent??n.xExtent,yExtent:y.yExtent??a.yExtent??n.yExtent,_idPrefix:(n._idPrefix??"minimap")+"-detail"},b=np.buildProps(i,r,o,m,g);Object.assign(b,y);let x={...n,size:[s,p],margin:f,title:void 0,description:(n.description??n.title??"Chart")+" overview minimap",showAxes:c.showAxes??!1,showLegend:!1,showGrid:!1,accessibleTable:!1,background:c.background,xExtent:void 0,yExtent:a.yExtent??n.yExtent,_idPrefix:(n._idPrefix??"minimap")+"-overview"};delete x.lineStyle,delete x.pointStyle;let v={...g,fillArea:!1,lineWidth:1,showPoints:!1,directLabel:!1,forecast:void 0,anomaly:void 0,band:void 0},w=np.buildProps(i,r,o,x,v);w.chartType=a.fillArea?"area":"line","function"==typeof c.lineStyle&&(w.lineStyle=c.lineStyle);let k={},A={},S=Hc(b,k),M=Hc(w,A),_=!0===a.renderBefore,$=_?0:l,P=""+uu(S,0,_?p:0,"detail")+uu(M,0,$,"overview"),R=l+p,I=Ze(Ke(n.theme)),L="string"==typeof n.title?n.title:void 0,T="string"==typeof n.description?n.description:L||"Chart with overview minimap",C=Bc(n),O=L?C+"-title":void 0,F=C+"-description",D="y"===c.brushDirection?"y":"x",z=Array.isArray(a.brushExtent)&&a.brushExtent.length>=2?[Number(a.brushExtent[0]),Number(a.brushExtent[1])]:null,N=A.evidence,E=null;if(z&&z.every(Number.isFinite)&&N){let e="x"===D?N.xDomain:N.yDomain;if(e&&e[0]!==e[1]){let t=Math.max(0,s-f.left-f.right),i=u,r=t=>(t-e[0])/(e[1]-e[0]);if("x"===D){let e=r(Math.min(...z))*t,o=r(Math.max(...z))*t;E=Kx("rect",{className:"selection",x:f.left+e,y:$+f.top,width:o-e,height:i,fill:"steelblue",fillOpacity:.2,stroke:"steelblue",strokeWidth:1})}else{let e=(1-r(Math.max(...z)))*i,o=(1-r(Math.min(...z)))*i;E=Kx("rect",{className:"selection",x:f.left,y:$+f.top+e,width:t,height:o-e,fill:"steelblue",fillOpacity:.2,stroke:"steelblue",strokeWidth:1})}}}let B=um.renderToStaticMarkup(Zx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"minimap-chart",width:s,height:R,role:"img","aria-labelledby":[O,F].filter(Boolean).join(" "),style:{fontFamily:I.fontFamily},children:[L&&Kx("title",{id:O,children:L}),Kx("desc",{id:F,children:T}),Kx("g",{dangerouslySetInnerHTML:{__html:P}}),E]}));if(t){let e=[k.evidence,A.evidence];t.evidence=sl({frameType:"xy",width:s,height:R,parts:e,title:L,description:T,xDomain:du(e,"xDomain"),yDomain:du(e,"yDomain")})}return B}},ev={Sparkline:{frameType:"xy",layout:{mode:"sparkline"},buildProps:(e,t,i,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})},BumpChart:ep,LineChart:np,AreaChart:sp,DifferenceChart:lp,StackedAreaChart:cp,Scatterplot:Bf,CandlestickChart:up,BubbleChart:Wf,ConnectedScatterplot:hp,QuadrantChart:dp,Heatmap:fp,WaterfallChart:op,MultiAxisLineChart:rp,MinimapChart:Jx,ScatterplotMatrix:{frameType:"xy",buildProps:au,renderStatic:function(e,t){let{data:i,colorBy:r,colorScheme:o,common:n,rest:a}=su(e),s=Array.isArray(C=i)?C.filter(e=>null!=e&&"object"==typeof e&&!Array.isArray(e)):[],l=Array.isArray(a.fields)?a.fields.filter(e=>"string"==typeof e):[],c=a.fieldLabels&&"object"==typeof a.fieldLabels?a.fieldLabels:{},u=cu(a.cellSize,150),d=Math.max(0,lu(a.cellGap,4)),h=Math.max(0,lu(a.pointRadius,2)),f=Math.max(0,Math.min(1,lu(a.pointOpacity,.5))),p=cu(a.histogramBins,20),y="string"==typeof a.diagonal?a.diagonal:"histogram",g=40+l.length*u+l.length*d,m=l.length*u+40+l.length*d,b=Ke(n.theme),x=Ze(b),v=function(e,t,i,r){if(!t)return{categories:[],color:()=>Mf};let o=Array.from(new Set(e.map(e=>hu(e,t)))),n="string"==typeof t?t:"__semioticSplomColor",a=Me("function"==typeof t?e.map(e=>({...e,[n]:hu(e,t)})):e,n,i??r.colors.categorical);return{categories:o,color:e=>Ae(e,t,a)}}(s,r,o,b),w="string"==typeof n.title?n.title:void 0,k="string"==typeof n.description?n.description:`Scatterplot matrix comparing ${l.length} fields`,A=w?28:0,S=a.showLegend??!!r?v.categories:[],M=0,_=0,$=S.map(e=>{let t=(e=>Math.max(72,30+7*e.length))(e);M>0&&M+t>g&&(_+=1,M=0);let i={label:e,x:M,y:24*_};return M+=t,i}),P=A+(S.length?24*(_+1)+4:0),R=P+m,I=[],L=[],T=0;var C;l.forEach((e,t)=>{l.forEach((i,o)=>{let l=40+d+o*(u+d),g=P+t*(u+d);if(t===o){let t=function(e){let{data:t,field:i,label:r,cellSize:o,bins:n,diagonal:a,colorBy:s,color:l,x:c,y:u}=e;if("label"===a)return{visibleBars:0,svg:um.renderToStaticMarkup(Kx("svg",{x:c,y:u,width:o,height:o,"data-semiotic-composite-part":"diagonal-"+i,children:Kx("text",{x:o/2,y:o/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333",children:r})}))};let d=t.map(e=>Number(e[i])).filter(Number.isFinite),h=d.length?Math.min(...d):0,f=((d.length?Math.max(...d):0)-h)/n||1,p=Array.from({length:n},()=>new Map);for(let e of t){let t=Number(e[i]);if(!Number.isFinite(t))continue;let r=Math.max(0,Math.min(n-1,Math.floor((t-h)/f))),o=s?hu(e,s):"__all",a=p[r];a.set(o,[...a.get(o)??[],e])}let y=p.map(e=>Array.from(e.values()).reduce((e,t)=>e+t.length,0)),g=Math.max(1,...y),m=0,b=p.flatMap((e,t)=>{let i=0;return Array.from(e.entries()).flatMap(([e,r])=>{if(0===r.length)return[];m+=1;let a=r.length/g*(o-24),c=i;return i+=a,Kx("rect",{x:t/n*o,y:o-c-a,width:Math.max(o/n-1,1),height:a,fill:s?l(r[0]):Mf,opacity:.6},`${t}-${e}`)})});return{visibleBars:m,svg:um.renderToStaticMarkup(Zx("svg",{x:c,y:u,width:o,height:o,"data-semiotic-composite-part":"diagonal-"+i,children:[Kx("text",{x:o/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333",children:r}),b]}))}}({data:s,field:e,label:Se(c,e)??e,cellSize:u,bins:p,diagonal:y,colorBy:r,color:v.color,x:l,y:g});return T+=t.visibleBars,void L.push(t.svg)}let m={},b=Hc({chartType:"scatter",data:s,size:[u,u],xAccessor:i,yAccessor:e,pointStyle:Fe(e=>({r:h,opacity:f,fill:v.color(e)}),a.styleRules,Ie(i,e)),margin:Qx,showAxes:!1,showGrid:!1,enableHover:!1,accessibleTable:!1,description:`${Se(c,i)??i} versus ${Se(c,e)??e} scatterplot`,theme:n.theme,_idPrefix:`${(n._idPrefix??"splom")+""}-${t}-${o}`},m);I.push(m.evidence),L.push(uu(b,l,g,`cell-${e}-${i}`))})});let O=Bc(n),F=w?O+"-title":void 0,D=O+"-description",z=um.renderToStaticMarkup(Zx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"scatterplot-matrix",width:g,height:R,role:"img","aria-labelledby":[F,D].filter(Boolean).join(" "),style:{fontFamily:x.fontFamily},children:[w&&Kx("title",{id:F,children:w}),Kx("desc",{id:D,children:k}),Kx("rect",{width:g,height:R,fill:x.background}),w&&Kx("text",{x:0,y:18,fontSize:14,fontWeight:600,fill:x.text,children:w}),$.map(e=>{let t=s.find(t=>r&&hu(t,r)===e.label),i=t?v.color(t):Mf;return Zx("g",{transform:`translate(${e.x},${A+e.y})`,children:[Kx("circle",{cx:5,cy:8,r:5,fill:i}),Kx("text",{x:14,y:12,fontSize:11,fill:x.text,children:e.label})]},e.label)}),l.map((e,t)=>{let i=P+t*(u+d)+u/2;return Kx("text",{x:20,y:i,transform:`rotate(-90 20 ${i})`,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fontWeight:"bold",fill:x.text,children:Se(c,e)??e},"row-"+e)}),l.map((e,t)=>Kx("text",{x:40+d+t*(u+d)+u/2,y:P+l.length*(u+d)+20,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fontWeight:"bold",fill:x.text,children:Se(c,e)??e},"column-"+e)),Kx("g",{dangerouslySetInnerHTML:{__html:L.join("")}})]}));return t&&(t.evidence=sl({frameType:"xy",width:g,height:R,parts:I,additionalMarkCountByType:T>0?{histogram:T}:void 0,title:w,description:k,categories:v.categories.length?v.categories:void 0,legendItems:S.length||void 0})),z}},TemporalHistogram:ap,XYCustomChart:Ty,BarChart:$p,StackedBarChart:Pp,GroupedBarChart:Rp,PieChart:Ip,DonutChart:Lp,Histogram:Tp,BoxPlot:Cp,ViolinPlot:Op,SwarmPlot:Fp,DotPlot:Dp,SwimlaneChart:Np,RidgelinePlot:Ep,LikertChart:vp,FunnelChart:Bp,RadarChart:zp,GaugeChart:_p,OrdinalCustomChart:Cy,ParallelCoordinatesRecipe:Oy,CalendarHeatmapRecipe:Fy,ForceDirectedGraph:uy,NetworkCustomChart:{frameType:"network",layout:{margin:{top:40,right:40,bottom:40,left:40}},buildProps:(e,t,i,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:i,customNetworkLayout:o.layout||o.customNetworkLayout,layoutConfig:o.layoutConfig,...r})},SankeyDiagram:py,ProcessSankey:fy,ChordDiagram:cy,TreeDiagram:yy,Treemap:gy,CirclePack:dy,OrbitDiagram:hy,ChoroplethMap:xy,ProportionalSymbolMap:vy,FlowMap:ky,DistanceCartogram:wy,GeoCustomChart:{frameType:"geo",buildProps:(e,t,i,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:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r})},GaltonBoardChart:tm,EventDropChart:im,UnitPileChart:rm,CollisionSwarmChart:om,ProcessFlowChart:nm,GauntletChart:am,CrucibleChart:sm,PacketFlowChart:lm,ChainReactionChart:{frameType:"physics",layout:{primarySize:{width:920,height:620}},buildProps:au,renderStatic:function(e,t){let{data:i,common:r,rest:o}=function(e){return e.__composite}(e),n=Array.isArray(y=i)?y.filter(e=>null!=e&&"object"==typeof e&&!Array.isArray(e)):[],[a,s]=r.size??[920,620],l="string"==typeof r.title?r.title:"Dependency chain reaction",c=function(e){let t=[],i=new Map,r=[],o=new Set;e.data.forEach((n,a)=>{let s=(eu(n,a,e.taskIDAccessor)??"")+"";if(!s)return void t.push({code:"duplicate-task-id",message:`Task row ${a} has an empty id.`,taskIDs:[]});if(i.has(s))return void t.push({code:"duplicate-task-id",message:`Task id "${s}" occurs more than once.`,taskIDs:[s]});let l=(eu(n,a,e.laneAccessor)??"Unassigned")+"";o.has(l)||(o.add(l),r.push(l));let c=eu(n,a,e.dependencyAccessor)??[],u=Array.from(new Set(Array.from(c,e=>e+""))).sort(tu),d=eu(n,a,e.blockerAccessor),h=eu(n,a,e.statusAccessor)??(d?"blocked":"waiting");i.set(s,{id:s,label:(eu(n,a,e.labelAccessor)??s)+"",lane:l,laneIndex:0,level:0,index:a,datum:n,dependencyIDs:u,incomingEdgeIDs:[],outgoingEdgeIDs:[],socketIDs:[],start:eu(n,a,e.startAccessor),end:eu(n,a,e.endAccessor),progress:ou(eu(n,a,e.progressAccessor)),status:h,completionTime:eu(n,a,e.completionTimeAccessor),blockerReason:d||void 0,milestone:!!eu(n,a,e.milestoneAccessor)})});let n=e.laneOrder?[...e.laneOrder,...r.filter(t=>!e.laneOrder?.includes(t))]:r,a=new Map(n.map((e,t)=>[e,t]));for(let e of i.values())e.laneIndex=a.get(e.lane)??0;let s=new Map,l=new Map;for(let e of i.keys())s.set(e,[]),l.set(e,[]);let c=[],u=[...i.values()].sort((e,t)=>e.index-t.index);for(let e of u)e.dependencyIDs.forEach((r,o)=>{let n=i.get(r);if(!n)return void t.push({code:"missing-dependency",message:`Task "${e.id}" depends on missing task "${r}".`,taskIDs:[e.id,r]});let a={id:iu(r,e.id),sourceID:r,targetID:e.id,sourceIndex:n.index,targetIndex:e.index,socketID:ru(e.id,o),socketIndex:o};c.push(a),s.get(e.id)?.push(a),l.get(r)?.push(a),e.incomingEdgeIDs.push(a.id),e.socketIDs.push(a.socketID),n.outgoingEdgeIDs.push(a.id)});for(let e of s.values())e.sort((e,t)=>tu(e.sourceID,t.sourceID)),e.forEach((e,t)=>{e.socketIndex=t,e.socketID=ru(e.targetID,t)});for(let e of l.values())e.sort((e,t)=>tu(e.targetID,t.targetID));for(let e of i.values()){let t=s.get(e.id)??[];e.incomingEdgeIDs=t.map(e=>e.id),e.socketIDs=t.map(e=>e.socketID),e.outgoingEdgeIDs=(l.get(e.id)??[]).map(e=>e.id)}let d=new Map,h=new Map;for(let e of i.keys())d.set(e,s.get(e)?.length??0),h.set(e,0);let f=[...i.keys()].filter(e=>0===d.get(e)).sort(tu),p=0;for(;f.length;){let e=f.shift();p+=1;for(let t of l.get(e)??[]){let i=Math.max(h.get(t.targetID)??0,(h.get(e)??0)+1);h.set(t.targetID,i);let r=(d.get(t.targetID)??0)-1;if(d.set(t.targetID,r),0===r){let e=f.findIndex(e=>e>t.targetID);0>e?f.push(t.targetID):f.splice(e,0,t.targetID)}}}if(p!==i.size){let e=[...i.keys()].filter(e=>(d.get(e)??0)>0).sort(tu);t.push({code:"cycle",message:`Dependency graph contains a cycle involving: ${e.join(", ")}.`,taskIDs:e})}let y=0,g=[...i.values()].sort((e,t)=>e.index-t.index);for(let e of g)e.level=h.get(e.id)??0,y=Math.max(y,e.level);return{nodes:g,edges:c,byID:i,incoming:s,outgoing:l,lanes:n,maxLevel:y,diagnostics:t,valid:0===t.length}}({data:n,taskIDAccessor:o.taskIDAccessor,labelAccessor:o.labelAccessor,laneAccessor:o.laneAccessor,dependencyAccessor:o.dependencyAccessor,startAccessor:o.startAccessor,endAccessor:o.endAccessor,progressAccessor:o.progressAccessor,statusAccessor:o.statusAccessor,completionTimeAccessor:o.completionTimeAccessor,blockerAccessor:o.blockerAccessor,milestoneAccessor:o.milestoneAccessor}),u=Ke(r.theme),d=Ze(u),h=Bc(r),f=h+"-title",p=h+"-description";var y;if(!c.valid){let e=c.diagnostics.map(e=>e.message).join(" "),i=qx.renderToStaticMarkup(Ux("svg",{xmlns:"http://www.w3.org/2000/svg",className:"chain-reaction-chart",width:a,height:s,role:"img","aria-labelledby":`${f} ${p}`,style:{fontFamily:d.fontFamily},children:[Hx("title",{id:f,children:l}),Hx("desc",{id:p,children:e}),Hx("rect",{width:a,height:s,fill:d.background}),Hx("text",{x:24,y:36,fontSize:16,fontWeight:700,fill:d.text,children:l}),c.diagnostics.map((e,t)=>Hx("text",{x:24,y:72+22*t,fontSize:12,fill:u.colors.error,children:e.message},`${e.code}-${t}`))]}));return t&&(t.evidence=sl({frameType:"physics",width:a,height:s,parts:[],title:l,description:e,nodeCount:c.nodes.length,edgeCount:c.edges.length,extraWarnings:["INVALID_DEPENDENCY_GRAPH"]})),i}let g=function(e,t,i={}){let r=Math.max(240,t.width),o=Math.max(220,t.height),n=t.paddingX??48,a=t.paddingTop??48,s=t.paddingBottom??44,l=Math.max(70,(r-2*n)/Math.max(1,e.lanes.length)),c=Math.max(76,(o-a-s)/Math.max(1,e.maxLevel+1)),u=Math.min(i.taskWidth??112,Math.max(58,.78*l)),d=Math.min(i.taskHeight??58,.64*c),h=i.socketRadius??5,f=Math.max(1,Math.round(i.gutterCount??3)),p=new Map;for(let t of e.nodes){let e=`${t.laneIndex}:${t.level}`,i=p.get(e)??[];i.push(t),p.set(e,i)}for(let e of p.values())e.sort((e,t)=>tu(e.id,t.id));let y=.86*c,g=e.nodes.map(e=>{let t=p.get(`${e.laneIndex}:${e.level}`)??[e],i=Math.max(0,t.findIndex(t=>t.id===e.id))-(t.length-1)/2,r=(o=t.length)>1?Math.max(22,Math.min(d,(y-4*(o-1))/o)):d;var o;return{taskID:e.id,lane:e.lane,laneIndex:e.laneIndex,level:e.level,x:n+l*(e.laneIndex+.5),y:a+c*(e.level+.5)+i*(r+4),width:u,height:r}}),m=new Map(g.map(e=>[e.taskID,e])),b=[],x=[];e.edges.forEach((t,i)=>{let r=m.get(t.sourceID),o=m.get(t.targetID);if(!r||!o)return;let n=e.incoming.get(t.targetID)??[],a=Math.min(.72*o.width,14*Math.max(1,n.length-1)),s=n.length>1?o.x-a/2+a*t.socketIndex/(n.length-1):o.x,l=o.y-o.height/2-h-2;b.push({id:t.socketID,edgeID:t.id,taskID:o.taskID,index:t.socketIndex,x:s,y:l,radius:h});let c={x:r.x,y:r.y+r.height/2+3},u=Math.min(l-10,c.y+.48*Math.max(18,l-c.y)+7*(i%f-(f-1)/2));var d;x.push({edgeID:t.id,sourceID:t.sourceID,targetID:t.targetID,socketID:t.socketID,points:(d=[c,{x:c.x,y:u},{x:s,y:u},{x:s,y:l}],d.filter((e,t)=>{let i=d[t-1];return!i||i.x!==e.x||i.y!==e.y}))})});let v=new Map(b.map(e=>[e.id,e])),w=new Map(x.map(e=>[e.edgeID,e]));return{tasks:g,sockets:b,routes:x,taskByID:m,socketByID:v,routeByEdgeID:w}}(c,{width:a,height:s}),m=function(e,t,i){let r=e.nodes.map(Zc).filter(e=>null!=e),o=i,n=new Set,a=new Map;for(let t of e.nodes){let e=Zc(t);(null!=e&&o>=e||"done"===t.status&&!0)&&n.add(t.id),t.blockerReason&&!n.has(t.id)&&a.set(t.id,t.blockerReason)}let s=new Set;for(let t of e.edges)n.has(t.sourceID)&&s.add(t.id);return{currentTime:o,playing:!1,completed:n,delivered:s,inFlight:new Set,armed:Qc(e,s,a,n),blockers:a,previewTaskID:null}}(c,0,Kc(o.currentTime,1/0)),b=Array.isArray(o.selectedTaskIDs)?o.selectedTaskIDs.map(String):[],x=new Set(b),v=b[0]??null,w=v&&"none"!==o.insight?nu(c,v,{completedTaskIDs:m.completed}):null,k=new Set(w?.downstreamTaskIDs??[]),A=function(e){return"number"==typeof e&&Number.isFinite(e)?e:31}(o.seed),S=function(e,t,i){let r="string"==typeof i?i:"Tasks are arranged by workstream and dependency depth. Completed tasks deliver their authored prerequisites; task completion remains an explicit data event.",o=[...t.blockers.keys()].map(i=>{let r=nu(e,i,{completedTaskIDs:t.completed});return`${e.byID.get(i)?.label??i} affects ${r.downstreamTaskCount} unfinished tasks across ${r.affectedLaneCount} lanes.`}).join(" ");return o?`${r} ${o}`:r+" No explicit blockers are active."}(c,m,r.description),M=qx.renderToStaticMarkup(Hx(Uc,{machine:c,layout:g,runtime:m,downstreamSet:k,selectedSet:x,width:a,height:s,seed:A,reduced:!0,onSelectTask:()=>{}})),_=void 0===r.theme?{}:mt(u),$=qx.renderToStaticMarkup(Ux("svg",{xmlns:"http://www.w3.org/2000/svg",className:"chain-reaction-chart",width:a,height:s,role:"img","aria-labelledby":`${f} ${p}`,style:{..._,fontFamily:d.fontFamily},children:[Hx("title",{id:f,children:l}),Hx("desc",{id:p,children:S}),Hx("rect",{width:a,height:s,fill:d.background}),Hx("text",{x:a/2,y:22,textAnchor:"middle",fontSize:d.titleFontSize,fontFamily:d.titleFontFamily,fontWeight:d.titleFontWeight,fill:d.text,children:l}),Hx("g",{dangerouslySetInnerHTML:{__html:M}})]}));return t&&(t.evidence=sl({frameType:"physics",width:a,height:s,parts:[],additionalMarkCountByType:{task:c.nodes.length,dependency:c.edges.length},title:l,description:S,categories:c.lanes,nodeCount:c.nodes.length,edgeCount:c.edges.length})),$}},PhysicsCustomChart:cm};import*as tv from"react";import{jsx as iv}from"react/jsx-runtime";var rv=new Set(["svg","g","text","tspan","path","circle","ellipse","rect","line","polyline","polygon","use","image","defs","symbol"]);import*as ov from"react-dom/server";import{scaleBand as nv,scaleLinear as av}from"d3-scale";var sv=class{constructor(){this.colorSchemeMap=new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(e,t,i){if(t&&"function"==typeof e.pieceStyle){let r=e.pieceStyle(t,i);return r&&!r.fill&&i?{...r,fill:this.getColorFromScheme(e,i)}:r}return e.pieceStyle&&"object"==typeof e.pieceStyle?e.pieceStyle:e.barColors&&i?{fill:Se(e.barColors,i)??"#007bff"}:{fill:i?this.getColorFromScheme(e,i):"#007bff"}}resolveSummaryStyle(e,t,i){return t&&"function"==typeof e.summaryStyle?e.summaryStyle(t,i):e.summaryStyle&&"object"==typeof e.summaryStyle?e.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(e,t){let i=this.colorSchemeMap.get(t);if(i)return i;let r=Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical||_f,o=r[this.colorSchemeIndex%r.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(t,o),o}};import{quantileSorted as lv}from"d3-array";import{scaleLinear as cv}from"d3-scale";var uv={bar:function(e,t){let{scales:i,columns:r,config:o,getR:n,getStack:a,resolvePieceStyle:s}=e,{r:l,projection:c}=i,u=[],d="vertical"===c,h="horizontal"===c,f=o.normalize,p=[];if(a){let e=new Set;for(let t of Object.values(r))for(let i of t.pieceData){let t=a(i);e.has(t)||(e.add(t),p.push(t))}}else p.push("_default");for(let e of Object.values(r)){let t=new Map;for(let i of e.pieceData){let e=a?a(i):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});let r=t.get(e);r.total+=n(i),r.pieces.push(i)}let i=0;if(f)for(let e of t.values())i+=Math.abs(e.total);let r=0,o=0;for(let n of p){let c=t.get(n);if(!c)continue;let p=c.total;f&&i>0&&(p/=i);let y=s(c.pieces[0],a?n:e.name),g={...c.pieces[0],__aggregateValue:c.total,__pieceCount:c.pieces.length,category:e.name};if(d){let t=l(0>p?o:r+p),i=0>p?l(o+p)-l(o):l(r)-l(r+p);u.push(os(e.x,t,e.width,Math.abs(i),y,g,n)),0>p?o+=p:r+=p}else if(h){let t=l(0>p?o+p:r),i=0>p?l(o)-l(o+p):l(r+p)-l(r);u.push(os(t,e.x,Math.abs(i),e.width,y,g,n)),0>p?o+=p:r+=p}}}let y="vertical"===c;for(let e of u){if("rect"!==e.type)continue;let t=e.datum?.__aggregateValue??0;e.roundedEdge=y?0>t?"bottom":"top":0>t?"left":"right",o.gradientFill&&(e.fillGradient=o.gradientFill)}if(void 0!==o.roundedTop){let e=new Map;for(let t of u){if("rect"!==t.type)continue;let i=t.datum?.category||"";e.has(i)||e.set(i,[]),e.get(i).push(t)}for(let t of e.values()){if(0===t.length)continue;let e=t.filter(e=>(e.datum?.__aggregateValue??0)>=0),i=t.filter(e=>0>(e.datum?.__aggregateValue??0));if(e.length>0){let t=e.reduce(y?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t),i=pu(o.roundedTop,t,y);i>0&&(t.roundedTop=i)}if(i.length>0){let e=i.reduce(y?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t),t=pu(o.roundedTop,e,y);t>0&&(e.roundedTop=t)}}}return u},clusterbar:function(e,t){let{scales:i,columns:r,config:o,getR:n,getGroup:a,resolvePieceStyle:s}=e,{r:l,projection:c}=i,u=[],d="vertical"===c,h=[],f=new Set;for(let e of Object.values(r))for(let t of e.pieceData){let e=a?a(t):"_default";f.has(e)||(f.add(e),h.push(e))}let p=h.length||1;for(let e of Object.values(r)){let t=e.width/p,i=.2*t,r=t-i,o=new Map;for(let t of e.pieceData){let e=a?a(t):"_default";o.has(e)||o.set(e,[]),o.get(e).push(t)}for(let a=0;h.length>a;a++){let c=o.get(h[a])||[];for(let o of c){let c=n(o),f=s(o,h[a]);if(d){let n=e.x+a*t+i/2,s=l(0),d=l(c);u.push(os(n,Math.min(s,d),r,Math.abs(s-d),f,o,h[a]))}else{let n=e.x+a*t+i/2,s=l(0),d=l(c);u.push(os(Math.min(s,d),n,Math.abs(d-s),r,f,o,h[a]))}}}}for(let e of u){if("rect"!==e.type||null==e.datum)continue;let t=n(e.datum),i=pu(o.roundedTop,e,d);i>0&&(e.roundedTop=i),e.roundedEdge=d?0>t?"bottom":"top":0>t?"left":"right",o.gradientFill&&(e.fillGradient=o.gradientFill)}return u},point:function(e,t){let{scales:i,columns:r,getR:o,multiScales:n,resolvePieceStyle:a}=e,{r:s,projection:l}=i,c=[],u="vertical"===l,d="radial"===l,h=n.length>0,f=yu(e),p=2*Math.PI,y=-Math.PI/2;for(let e of Object.values(r))for(let t of e.pieceData){let i,r,l=t.__rIndex??0,g=t.__rValue??o(t),m=h&&n[l]||s,b=a(t,e.name),x=b.r||5;if(d){let t=y+(e.pctStart+e.pct/2)*p,o=m(g);i=Math.cos(t)*o,r=Math.sin(t)*o}else u?(i=e.middle,r=m(g)):(i=m(g),r=e.middle);gu(c,f,t,i,r,x,b)}return c},swarm:function(e,t){let{scales:i,columns:r,getR:o,resolvePieceStyle:n}=e,{r:a,projection:s}=i,l=[],c="vertical"===s,u=yu(e);for(let e of Object.values(r)){let t=e.width/2;for(let i=0;e.pieceData.length>i;i++){let r=e.pieceData[i],s=o(r),d=n(r,e.name),h=d.r||4,f=(7919*i%100/100-.5)*t*.8;gu(l,u,r,c?e.middle+f:a(s),c?a(s):e.middle+f,h,d)}}return l},pie:mu,donut:mu,boxplot:function(e,t){let{scales:i,columns:r,config:o,getR:n,resolveSummaryStyle:a}=e,{r:s,projection:l}=i,c=[],u="vertical"===l,d=!1!==o.showOutliers;for(let t of Object.values(r)){let i=t.pieceData.map(e=>n(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===i.length)continue;let r=xu(i),{min:o,max:l,q1:h,median:f,q3:p}=r,y=p-h,g=h-1.5*y,m=p+1.5*y,b=i.find(e=>e>=g)??o,x=l;for(let e=i.length-1;e>=0;e--)if(m>=i[e]){x=i[e];break}r.min=b,r.max=x;let v=a(bu(t.pieceData,t.name,r),t.name),w=[];if(d)for(let e of t.pieceData){let i=n(e);if(g>i||i>m){let r=u?t.middle:s(i),o=u?s(i):t.middle;w.push({px:r,py:o,value:i,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:s(b),q1Pos:s(h),medianPos:s(f),q3Pos:s(p),maxPos:s(x),stats:r,style:v,datum:t.pieceData,category:t.name,outliers:w}),d)for(let t of w)c.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:v.fill||e.config.themeSemantic?.secondary||"#999",opacity:.6,cursor:v.cursor},datum:t.datum})}return c},violin:function(e,t){let{scales:i,columns:r,config:o,getR:n,resolveSummaryStyle:a}=e,{r:s,projection:l}=i,c=[],u="vertical"===l,d=o.bins||20,h=!1!==o.showIQR;for(let e of Object.values(r)){let t=e.pieceData.map(e=>n(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;let i,r=t[0],o=t[t.length-1],l=(o-r)/d||1,f=vu(t,r,o,l,d),p=et(f,1),y=e.width/2*.9;if(u){i=`M ${e.middle} ${s(r)}`;for(let t=0;d>t;t++){let o=s(r+(t+.5)*l);i+=` L ${e.middle+f[t]/p*y} ${o}`}i+=` L ${e.middle} ${s(o)}`;for(let t=d-1;t>=0;t--){let o=s(r+(t+.5)*l);i+=` L ${e.middle-f[t]/p*y} ${o}`}i+=" Z"}else{i=`M ${s(r)} ${e.middle}`;for(let t=0;d>t;t++)i+=` L ${s(r+(t+.5)*l)} ${e.middle-f[t]/p*y}`;i+=` L ${s(o)} ${e.middle}`;for(let t=d-1;t>=0;t--)i+=` L ${s(r+(t+.5)*l)} ${e.middle+f[t]/p*y}`;i+=" Z"}let g,m=xu(t),b=a(bu(e.pieceData,e.name,m),e.name);h&&t.length>=4&&(g={q1Pos:s(m.q1),medianPos:s(m.median),q3Pos:s(m.q3),centerPos:e.middle,isVertical:u});let x=u?{x:e.x,y:Math.min(s(o),s(r)),width:e.width,height:Math.abs(s(o)-s(r))}:{x:Math.min(s(r),s(o)),y:e.x,width:Math.abs(s(o)-s(r)),height:e.width};c.push({type:"violin",pathString:i,translateX:0,translateY:0,bounds:x,iqrLine:g,stats:m,style:b,datum:e.pieceData,category:e.name})}return c},histogram:function(e,t){let{scales:i,columns:r,config:o,getR:n,resolveSummaryStyle:a}=e,{r:s}=i,l=[],c=o.bins||25,u=o.normalize,d=s.domain?.(),h=d?+d[0]:void 0,f=d?+d[1]:void 0;for(let e of Object.values(r)){let t=e.pieceData.map(e=>n(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;let[i,r]=Je(t),o=null!=h&&isFinite(h)?h:i,d=null!=f&&isFinite(f)?f:r,p=(d-o)/c||1,y=vu(t,o,d,p,c),g=t.length,m=et(y,1);for(let t=0;c>t;t++){if(0===y[t])continue;let i=(u?y[t]/g:y[t]/m)*e.width*.9,r=s(o+t*p),n=s(o+(t+1)*p),c=Math.min(r,n),d=Math.abs(n-r),h=e.x+e.width-i,f={...e.pieceData[0],bin:t,count:y[t],range:[o+t*p,o+(t+1)*p],category:e.name,data:e.pieceData},b=a(f,e.name);l.push(os(c,h,d,i,b,f,e.name))}}return l},ridgeline:function(e,t){let{scales:i,columns:r,config:o,getR:n,resolveSummaryStyle:a}=e,{r:s,projection:l}=i,c=[],u=o.bins||20,d="horizontal"===l,h=o.amplitude||1.5;for(let e of Object.values(r)){let t=e.pieceData.map(e=>n(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;let i,r=t[0],o=t[t.length-1],l=(o-r)/u||1,f=vu(t,r,o,l,u),p=et(f,1),y=xu(t),g=a(bu(e.pieceData,e.name,y),e.name),m=e.width*h;if(d){let t=e.x+e.width;i=`M ${s(r)} ${t}`;for(let e=0;u>e;e++)i+=` L ${s(r+(e+.5)*l)} ${t-f[e]/p*m}`;i+=` L ${s(o)} ${t} Z`}else{let t=e.x;i=`M ${t} ${s(r)}`;for(let e=0;u>e;e++){let o=s(r+(e+.5)*l);i+=` L ${t+f[e]/p*m} ${o}`}i+=` L ${t} ${s(o)} Z`}let b=d?{x:Math.min(s(r),s(o)),y:e.x,width:Math.abs(s(o)-s(r)),height:e.width}:{x:e.x,y:Math.min(s(o),s(r)),width:e.width,height:Math.abs(s(o)-s(r))};c.push({type:"violin",pathString:i,translateX:0,translateY:0,bounds:b,stats:y,style:{...g,fillOpacity:g.fillOpacity??.5},datum:e.pieceData,category:e.name})}return c},timeline:function(e,t){let{scales:i,columns:r,getRawRange:o,resolvePieceStyle:n}=e,{r:a,projection:s}=i,l=[],c="horizontal"===s;for(let e of Object.values(r))for(let t of e.pieceData){let i=o(t);if(!i)continue;let[r,s]=i,u=n(t,e.name);if(c){let i=a(Math.min(r,s)),o=a(Math.max(r,s));l.push(os(i,e.x,o-i,e.width,u,t,e.name))}else{let i=a(Math.max(r,s)),o=a(Math.min(r,s));l.push(os(e.x,i,e.width,o-i,u,t,e.name))}}return l},funnel:function(e,t){let{columns:i,getR:r,getStack:o,resolvePieceStyle:n}=e,a=[],s=t.width/2,l=!1!==e.config.showLabels,c=e.scales.o.domain().map(e=>i[e]).filter(Boolean);if(0===c.length)return a;let u=[],d=new Set;for(let e of c)for(let t of e.pieceData){let e=o?o(t):"_default";d.has(e)||(d.add(e),u.push(e))}let h=u.length>1&&"_default"!==u[0],f=[],p=0;for(let e of c){let t=new Map,i=0;for(let n of e.pieceData){let e=o?o(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});let a=t.get(e),s=r(n);a.total+=s,a.pieces.push(n),i+=s}f.push({col:e,groups:t,stepTotal:i}),h||i>p&&(p=i)}if(h)for(let e of f){let t=0,i=0;for(let r=0;u.length>r;r++){let o=e.groups.get(u[r]);o&&(r%2==0?t+=o.total:i+=o.total)}let r=Math.max(t,i);r>p&&(p=r)}if(0===p)return a;let y=new Map;for(let e of u){let t=f[0].groups.get(e);y.set(e,t?.total??0)}let g=f[0].stepTotal,m=h?.95*s:.9*t.width,b=cv().domain([0,p]).range([0,m]),x=e.config.connectorOpacity??.3,v=new Map;for(let t=0;f.length>t;t++){let i=f[t],r=i.col,o=0===t,c=r.width,d=.55*c,p=r.x+(c-d)/2,m=new Map;if(h){let e=0;for(let t of u){let r=i.groups.get(t);r&&(e+=b(r.total))}let t=s,c=s;for(let h=0;u.length>h;h++){let f=u[h],g=i.groups.get(f);if(!g)continue;let x=b(g.total),v=h%2==0,w=v?t:c-x;v?t+=x:c-=x;let k=n(g.pieces[0],f),A=y.get(f)??g.total,S={...g.pieces[0],__funnelValue:g.total,__funnelPercent:A>0?g.total/A*100:0,__funnelStep:r.name,__funnelIsFirstStep:o,__aggregateValue:g.total,__pieceCount:g.pieces.length,category:f};l&&(0===h&&(S.__funnelStepLabel=r.name,S.__funnelStepLabelX=s,S.__funnelStepLabelY=p,S.__funnelRowWidth=e),S.__funnelValueLabelX=w+x/2,S.__funnelValueLabelY=p,S.__funnelBarW=x),a.push(os(w,p,x,d,k,S,f)),m.set(f,{x:w,y:p,w:x,h:d})}}else{let e=i.stepTotal,t=b(e),c=s-t/2,h=u[0],f="_default"!==h,y=i.groups.get(h)?.pieces[0]??r.pieceData[0],x=f?h:r.name,v=n(y,x),w=g>0?e/g*100:0,k={...y,__funnelValue:e,__funnelPercent:w,__funnelStep:r.name,__funnelIsFirstStep:o,category:f?h:r.name};l&&(k.__funnelStepLabel=r.name,k.__funnelStepLabelX=s,k.__funnelStepLabelY=p,k.__funnelRowWidth=t,k.__funnelValueLabelX=s,k.__funnelValueLabelY=p,k.__funnelBarW=t),a.push(os(c,p,t,d,v,k,x)),m.set(h,{x:c,y:p,w:t,h:d})}if(t>0&&v.size>0){let t=h?u:[u[0]];for(let o of t){let t=v.get(o),s=m.get(o);if(!t||!s)continue;let l=(()=>{let e=i.groups.get(o);return n(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],[s.x+s.w,s.y],[s.x,s.y]],style:{fill:l.fill||e.config.themeSemantic?.secondary||"#999",opacity:x,cursor:l.cursor},datum:i.groups.get(o)?.pieces[0]??r.pieceData[0],category:"_default"===o?r.name:o};a.push(c)}}v=m}return a},"bar-funnel":function(e,t){let{columns:i,getR:r,getStack:o,resolvePieceStyle:n,scales:a}=e,s=[],l=a.o.domain().map(e=>i[e]).filter(Boolean);if(0===l.length)return s;let c=[],u=new Set;for(let e of l)for(let t of e.pieceData){let e=o?o(t):"_default";u.has(e)||(u.add(e),c.push(e))}let d=c.length>1&&"_default"!==c[0],h=[];for(let e of l){let t=new Map,i=0;for(let n of e.pieceData){let e=o?o(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});let a=t.get(e),s=r(n);a.total+=s,a.pieces.push(n),i+=s}h.push({col:e,groups:t,stepTotal:i})}let f=new Map;for(let e of c){let t=h[0]?.groups.get(e);f.set(e,t?.total??0)}let p=a.r,y=d?c.length:1,g=d?.15:0;for(let e=0;h.length>e;e++){let t=h[e],i=t.col,r=0===e,o=e>0?h[e-1]:null,a=i.width/y,l=a*g,u=a-l;for(let e=0;c.length>e;e++){let h=c[e],y=t.groups.get(h);if(!y)continue;let g=y.total,m=f.get(h)??g,b=m>0?g/m*100:0,x=o?.groups.get(h)?.total??g,v=r?0:Math.max(0,x-g),w=i.x+e*a+l/2,k=p(g),A=p(0)-k,S=n(y.pieces[0],d?h:i.name),M={...y.pieces[0],__barFunnelValue:g,__barFunnelPercent:b,__barFunnelIsFirstStep:r,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:i.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:p(g+v)};if(s.push(os(w,k,u,A,S,M,d?h:i.name)),v>0){let e=p(g+v),t=k-e,r={...S},o={...y.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:i.name};s.push(os(w,e,u,t,r,o,d?h:i.name))}}}return s},swimlane:function(e,t){let{scales:i,columns:r,getR:o,getStack:n,resolvePieceStyle:a}=e,{r:s,projection:l}=i,c=[],u="horizontal"===l,d=e.config.gradientFill,h=u?"left":"bottom",f=new Map,p=t=>{let i=f.get(t);if(void 0!==i)return i;let r="function"==typeof e.config.roundedTop?e.config.roundedTop(t.width):e.config.roundedTop,o="number"==typeof r&&Number.isFinite(r)?Math.max(0,r):0;return f.set(t,o),o},y=e.config.trackFill;if(y){let e="string"==typeof y?y:y.color,t="string"==typeof y?1:y.opacity??1,[i,o]=s.range(),n=Math.min(i,o),a=Math.abs(o-i);for(let i of Object.values(r)){let r={fill:e,opacity:t},o=u?os(n,i.x,a,i.width,r,null,"__track__"):os(i.x,n,i.width,a,r,null,"__track__"),s=p(i);s>0&&(o.cornerRadii={tl:s,tr:s,br:s,bl:s}),c.push(o)}}for(let e of Object.values(r)){let t=0,i=c.length,r=p(e);for(let i of e.pieceData){let r=Math.abs(o(i));if(0===r)continue;let l,f=n?n(i):e.name,p=a(i,f);if(u){let o=s(t),n=s(t+r);l=os(o,e.x,n-o,e.width,p,i,f)}else{let o=s(t+r),n=s(t);l=os(e.x,o,e.width,n-o,p,i,f)}d&&(l.fillGradient=d,l.roundedEdge=h),c.push(l),t+=r}if(r>0&&c.length>i){let e=c.slice(i),t=e[0],o=e[e.length-1];1===e.length?t.cornerRadii={tl:r,tr:r,br:r,bl:r}:u?(t.cornerRadii={tl:r,bl:r},o.cornerRadii={tr:r,br:r}):(t.cornerRadii={bl:r,br:r},o.cornerRadii={tl:r,tr:r})}}return c}},dv=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],hv=["scene-style","data-paint","accessibility","evidence"],fv=(e,t)=>({retainedData:e,invalidations:t}),pv=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],yv=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],gv=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],mv=["scene-geometry","data-paint","accessibility","evidence"],bv=["scene-style","data-paint","accessibility","evidence"],xv=[],vv={chartType:fv("rebuild",pv),runtimeMode:fv("rebuild",pv),categoryAccessor:fv("rebuild",pv),valueAccessor:fv("rebuild",pv),oAccessor:fv("rebuild",pv),rAccessor:fv("rebuild",pv),stackBy:fv("rebuild",pv),groupBy:fv("rebuild",pv),timeAccessor:fv("rebuild",pv),accessorRevision:fv("rebuild",pv),colorAccessor:fv("rebuild",bv),symbolAccessor:fv("rebuild",mv),connectorAccessor:fv("rebuild",mv),dataIdAccessor:fv("rebuild",mv),projection:fv("preserve",yv),extentPadding:fv("preserve",yv),axisExtent:fv("preserve",yv),rExtent:fv("preserve",yv),oExtent:fv("preserve",yv),multiAxis:fv("preserve",yv),normalize:fv("preserve",yv),bins:fv("preserve",yv),oSort:fv("preserve",gv),barPadding:fv("preserve",gv),roundedTop:fv("preserve",gv),baselinePadding:fv("preserve",gv),innerRadius:fv("preserve",gv),cornerRadius:fv("preserve",gv),startAngle:fv("preserve",gv),sweepAngle:fv("preserve",gv),trackFill:fv("preserve",gv),showOutliers:fv("preserve",gv),showIQR:fv("preserve",gv),amplitude:fv("preserve",gv),connectorOpacity:fv("preserve",gv),showLabels:fv("preserve",gv),dynamicColumnWidth:fv("rebuild",gv),customLayout:fv("preserve",gv),layoutConfig:fv("preserve",gv),layoutMargin:fv("preserve",gv),symbolMap:fv("preserve",mv),pieceStyle:fv("preserve",bv),summaryStyle:fv("preserve",bv),connectorStyle:fv("preserve",bv),gradientFill:fv("preserve",bv),colorScheme:fv("preserve",bv),themeCategorical:fv("preserve",bv),themeSemantic:fv("preserve",bv),themeSequential:fv("preserve",bv),themeDiverging:fv("preserve",bv),barColors:fv("preserve",bv),decay:fv("preserve",bv),pulse:fv("preserve",bv),staleness:fv("preserve",bv),layoutSelection:fv("preserve",bv),windowSize:fv("preserve",xv),windowMode:fv("preserve",xv),clock:fv("preserve",xv),transition:fv("preserve",xv),introAnimation:fv("preserve",xv),onLayoutError:fv("preserve",xv)},wv=fv("preserve",gv),kv=class{constructor(){this.tracker=new Hy}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}},dv)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},hv):this.recordNoop("restyle")}recordConfig(e){let t=function(e){let t="preserve",i=new Set;for(let r of e){let e=vv[r]??wv;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}};import{quadtree as Av}from"d3-quadtree";var Sv=class{constructor(e){this.rExtent=new pm,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new kv,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new sv,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 fm(e.windowSize),this.getO=$a(e.categoryAccessor||e.oAccessor,"category");let t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>Ma(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new pm)):(this.getR=Ma(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=$a(e.stackBy),this.getGroup=$a(e.groupBy),this.getColor=$a(e.colorAccessor),this.getSymbol=$a(e.symbolAccessor),this.getConnector=$a(e.connectorAccessor),this.getDataId=$a(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new fm(e.windowSize))}syncPulseTimestampBuffer(){var e,t,i,r;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,i=this.timestampBuffer,r=this.currentTime(),e?null!=i&&i.capacity===t.capacity&&i.size===t.size?i:us(t,r):null)}currentTime(){return this.config.clock?.()??Da()}ingest(e){let t=this.currentTime();if(this.lastIngestTime=t,this._dataVersion++,e.bounded){this.buffer.clear(),this.rExtent.clear();for(let e of this.rExtents)e.clear();e.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),cs(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(let i of e.inserts)ds(this.buffer,i,this.timestampBuffer,t),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(let i of e.inserts){let e=ds(this.buffer,i,this.timestampBuffer,t);this.categories.add(this.getO(i)),this.pushValueExtent(i),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){let 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){let 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){let t=this.config.valueAccessor||this.config.rAccessor;if(!t)return null;let i="function"==typeof t?t(e):e[t];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(e){let{config:t,buffer:i}=this,r=this.scales,o=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);let a,s,l=this.getBufferArray(),c=t.projection||"vertical",u=t.oExtent||this.resolveCategories(l),d=this.computeValueDomain(l,u),h="horizontal"===c,f="radial"===c,p=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===c?e.width:e.height):.1));if(f){a=nv().domain(u).range([0,1]).padding(0);let i=Math.min(e.width,e.height)/2,r=t.innerRadius||0;s=av().domain(d).range([r,i])}else h?(a=nv().domain(u).range([0,e.height]).padding(p),s=av().domain(d).range([0,e.width])):(a=nv().domain(u).range([0,e.width]).padding(p),s=av().domain(d).range([e.height,0]));this.scales={o:a,r:s,projection:c},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((r,o)=>{let n=this.rExtents[o];n.dirty&&n.recalculate(i,r);let[a,s]=n.extent;a===1/0&&(a=0,s=1);let l=s-a,c=l>0?l*(t.extentPadding??.05):1;return a-=c,s+=c,a>0&&(a=0),h?av().domain([a,s]).range([0,e.width]):av().domain([a,s]).range([e.height,0])}):[];let y=l;this.rAccessors.length>1&&(y=l.flatMap(e=>this.rAccessors.map((t,i)=>({...e,__rIndex:i,__rValue:t(e),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(y,u,a,c,e),this._customLayoutFailedThisBuild=!1;let g=this.buildSceneNodes(y,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.multiScales=o,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,l),this.config.pulse&&this.applyPulse(this.scene,l),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){let t=this.config.valueAccessor||this.config.rAccessor,i=Array.isArray(t)?t[e]:t;return"string"==typeof i?i:"value"+e}resolveCategories(e){let t=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,r="auto"===t?void 0:t,o=null;if(i){o=new Set;for(let t of e)o.add(this.getO(t))}let n=o?Array.from(this.categories).filter(e=>o.has(e)):Array.from(this.categories);if(i&&void 0===r){let e=Math.max(50,3*o.size);if(this.categories.size>e){let t=this.categories.size-e;for(let e of this.categories){if(0>=t)break;o.has(e)||(this.categories.delete(e),t--)}}return n}if(!1===r)return n;if("function"==typeof r)return n.sort(r);let a=new Map;for(let t of e){let e=this.getO(t);a.set(e,(a.get(e)||0)+Math.abs(this.getR(t)))}return n.sort("asc"===r?(e,t)=>(a.get(e)||0)-(a.get(t)||0):(e,t)=>(a.get(t)||0)-(a.get(e)||0))}computeValueDomain(e,t){return function(e){let{data:t,chartType:i,projection:r,normalize:o,rExtent:n,extentPadding:a=.05,baselinePadding:s,axisExtent:l,getO:c,getR:u,getStack:d,rawRExtent:h}=e,f=a;if("radial"===r&&("pie"===i||"donut"===i))return[0,1];let p=0,y=0;if("bar"===i&&d&&o)p=0,y=1;else if("bar"===i&&d){let e=new Map,i=new Map;for(let r of t){let t=c(r),o=u(r);0>o?i.set(t,(i.get(t)||0)+o):e.set(t,(e.get(t)||0)+o)}for(let t of e.values())t>y&&(y=t);for(let e of i.values())p>e&&(p=e)}else if("bar"===i){let e=new Map;for(let i of t){let t=c(i),r=u(i);e.set(t,(e.get(t)||0)+r)}for(let t of e.values())t>y&&(y=t),p>t&&(p=t)}else if("swimlane"===i){let e=new Map;for(let i of t){let t=c(i),r=Math.abs(u(i));e.set(t,(e.get(t)||0)+r)}for(let t of e.values())t>y&&(y=t)}else if("clusterbar"===i||"bar-funnel"===i)for(let e of t){let t=u(e);t>y&&(y=t),p>t&&(p=t)}else{let e=h[0],t=h[1];e!==1/0&&(p=e),t!==-1/0&&(y=t)}n&&(null!=n[0]&&(p=n[0]),null!=n[1]&&(y=n[1]));let 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"!==l){let e=y-p,t=e>0?e*f:1,r=g&&!s&&0===p,o=g&&!s&&0===y||"swimlane"===i;null==n?.[0]&&!r&&(p-=t),null==n?.[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,i,r,o){return function(e){let{data:t,oExtent:i,oScale:r,projection:o,layout:n,dynamicColumnWidth:a,getO:s,getR:l}=e,c=Object.create(null),u=new Map;for(let e of t){let t=s(e);u.has(t)||u.set(t,[]),u.get(t).push(e)}let d=0;if("radial"===o)for(let e of t)d+=Math.abs(l(e));let h=null;if(a&&"radial"!==o){h=new Map;let e=0;for(let t of i){let i,r=u.get(t)||[];i="string"==typeof a?r.reduce((e,t)=>e+(Number(t[a])||0),0):a(r),h.set(t,i),e+=i}let t=("horizontal"===o?n.height:n.width)-r.padding()*r.step()*i.length;if(e>0)for(let[i,r]of h)h.set(i,r/e*t)}let f=0,p=0;for(let e of i){let t,i,o=u.get(e)||[],n=o.reduce((e,t)=>e+Math.abs(l(t)),0),a=d>0?n/d:0;h?(t=p,i=h.get(e)||r.bandwidth(),p+=i+r.padding()*r.step()):(t=r(e)??0,i=r.bandwidth()),c[e]={name:e,x:t,y:0,width:i,middle:t+i/2,padding:r.padding()*r.step(),pieceData:o,pct:a,pctStart:f},f+=a}return c}({data:e,oExtent:t,oScale:i,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){let i=this.buildLayoutContext(e,t),r=Ha({family:"ordinal",logLabel:"ordinal customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:this.config.onLayoutError,run:()=>this.config.customLayout(i)});if("failure"===r.kind)return this.lastCustomLayoutFailure=r.diagnostic,this._customLayoutFailedThisBuild=!0,r.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[]);let o=r.result;this.customLayoutOverlays=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null;let n=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(let e of n)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(n,this.config.layoutSelection??null)}return qa({label:"ordinal customLayout",nodes:n,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),n}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;let i=this.getSceneContext(),r=uv[this.config.chartType],o=r?r(i,t):[];return this.getConnector&&this.scales&&(o=[...fu(i,o),...o]),o}buildLayoutContext(e,t){let i=this.config,r=i.layoutMargin??{top:0,right:0,bottom:0,left:0},o=qo(i.colorScheme,i.themeCategorical,_f),n=this.scales;return{data:e,scales:{o:n.o,r:n.r,projection:n.projection},dimensions:{width:t.width,height:t.height,margin:r,plot:"radial"===n.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:i.themeSemantic??{},categorical:[...o]},resolveColor:Go(o,i.colorScheme),config:i.layoutConfig??{},selection:i.layoutSelection??null}}computeDecayOpacity(e,t){let i=this.config.decay;return i&&t>1?za(i,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;let t=Na(e);return this._datumIndexCache={version:this._dataVersion,map:t},t}getCategoryIndexMap(e){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;let t=function(e,t){let i="function"==typeof t,r=i?null:t||"category",o=new Map;for(let n=0;e.length>n;n++){let a=e[n],s=i?t(a):a[r],l=o.get(s);l?l.push(n):o.set(s,[n])}return o}(e,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:t},t}rebuildPointQuadtree(){let e=function(e){let t=0,i=0;for(let r of e)"point"===r.type&&!1!==r.interactive&&(t++,r.r>i&&(i=r.r));if(500>=t)return{quadtree:null,maxRadius:i};let r=Array(t),o=0;for(let t of e)"point"===t.type&&!1!==t.interactive&&(r[o++]=t);return{maxRadius:i,quadtree:Av().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;let i=t.length;if(1>=i)return;let r=this.getDatumIndexMap(t);for(let t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type||!t.datum)continue;let e=r.get(t.datum);if(null==e)continue;let o=this.computeDecayOpacity(e,i);t.style={...t.style,opacity:(t.style?.opacity??1)*o}}}applyPulse(e,t,i=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,i,r,o,n){let a=e.color??"rgba(255,255,255,0.6)",s=e.glowRadius??4,l=!1;for(let c of t){if("connector"===c.type||"violin"===c.type||"boxplot"===c.type)continue;if("wedge"===c.type){let t=c.category;if(!t)continue;let r=0;for(let a of o(t)??[]){let t=i.get(a);null!=t&&(r=Math.max(r,Ea(e,t,n)))}l=Ba(c,r,a)||l;continue}if(null==c.datum)continue;let t=r.get(c.datum);if(null==t)continue;let u=i.get(t);l=Ba(c,null==u?0:Ea(e,u,n),a,s)||l}return l}(this.config.pulse,e,this.timestampBuffer,this.getDatumIndexMap(t),e=>this.getCategoryIndexMap(t).get(e),i)}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&Wa(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}synthesizeIntroPositions(){this.prevPositionMap.clear();let e,t=new Map,i=this.scales?.r(0)??0,r="horizontal"!==this.scales?.projection;for(let o=0;this.scene.length>o;o++){let n=this.scene[o],a=this.getNodeKey(n,t);a&&("rect"===n.type?this.prevPositionMap.set(a,r?{x:n.x,y:i,w:n.w,h:0,opacity:n.style.opacity??1}:{x:i,y:n.y,w:0,h:n.h,opacity:n.style.opacity??1}):"point"===n.type?this.prevPositionMap.set(a,{x:n.x,y:n.y,r:0,opacity:0}):"wedge"===n.type&&(void 0===e&&(e=n.startAngle),this.prevPositionMap.set(a,{x:n.cx,y:n.cy,startAngle:e,endAngle:e,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:0})))}}getNodeKey(e,t){if("point"===e.type){let i=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,r=t.get(i)||0;return t.set(i,r+1),`${i}:${r}`}if("rect"===e.type){let i=e.datum?null!=e.datum.category&&""!==e.datum.category?e.datum.category+"":(this.getO(e.datum)??"")+"":"",r=`r:${e.group||""}:${i}`,o=t.get(r)||0;return t.set(r,o+1),0===o?r:`${r}:${o}`}return"wedge"===e.type?"w:"+(e.category??""):null}snapshotPositions(){this.prevPositionMap.clear();let e=new Map;for(let t=0;this.scene.length>t;t++){let i=this.scene[t],r=this.getNodeKey(i,e);r&&("point"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity??i.style.fillOpacity}):"rect"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity??i.style.fillOpacity}):"wedge"===i.type&&this.prevPositionMap.set(r,{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;let e=this.config.transition.duration??300;if(this.exitNodes.length>0){let e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let t=!1,i=new Set,r=new Map;for(let e=0;this.scene.length>e;e++){let o=this.scene[e],n=this.getNodeKey(o,r);if(!n)continue;o._transitionKey=n;let a=this.prevPositionMap.get(n);if("point"===o.type)a?(i.add(n),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(a.x!==o.x||a.y!==o.y||void 0!==a.r&&a.r!==o.r)&&(o._targetX=o.x,o._targetY=o.y,o._targetR=o.r,o.x=a.x,o.y=a.y,void 0!==a.r&&(o.r=a.r),t=!0)):(o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o._targetR=o.r,o.r=0,o.style={...o.style,opacity:0},t=!0);else if("rect"===o.type)a?(i.add(n),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(a.x!==o.x||a.y!==o.y||a.w!==o.w||a.h!==o.h)&&(o._targetX=o.x,o._targetY=o.y,o._targetW=o.w,o._targetH=o.h,o.x=a.x,o.y=a.y,o.w=a.w??o.w,o.h=a.h??o.h,t=!0)):(o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o.style={...o.style,opacity:0},t=!0);else if("wedge"===o.type)if(a)i.add(n),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(a.startAngle!==o.startAngle||a.endAngle!==o.endAngle)&&(o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle,o.startAngle=a.startAngle,o.endAngle=a.endAngle,t=!0);else{o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle;let e=o.startAngle;o.startAngle=e,o.endAngle=e,o.style={...o.style,opacity:0},this.prevPositionMap.set(n,{x:o.cx,y:o.cy,startAngle:e,endAngle:e,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:0}),t=!0}}this.exitNodes=[];for(let[e,r]of this.prevPositionMap)if(!i.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:")){let t=((r.startAngle??0)+(r.endAngle??0))/2,i={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(i)}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;let t=Oa(e,this.activeTransition),i=Ca(t,"linear"===this.config.transition?.easing?"linear":"ease-out-cubic");for(let e of this.scene){let t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){let r=this.prevPositionMap.get(t);e.style.opacity=Fa(r?r.opacity??1:0,e._targetOpacity,i)}let r=this.prevPositionMap.get(t);void 0!==e._targetX&&r&&(e.x=Fa(r.x,e._targetX,i),e.y=Fa(r.y,e._targetY,i)),void 0!==e._targetR&&void 0!==r?.r&&(e.r=Fa(r.r,e._targetR,i))}else if("rect"===e.type){if(void 0!==e._targetOpacity){let r=this.prevPositionMap.get(t);e.style.opacity=Fa(r?r.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;let r=this.prevPositionMap.get(t);if(!r)continue;e.x=Fa(r.x,e._targetX,i),e.y=Fa(r.y,e._targetY,i),void 0!==r.w&&(e.w=Fa(r.w,e._targetW,i),e.h=Fa(r.h,e._targetH,i))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){let r=this.prevPositionMap.get(t);e.style={...e.style,opacity:Fa(r?r.opacity??1:0,e._targetOpacity,i)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){let r=this.prevPositionMap.get(t);r&&void 0!==r.startAngle&&(e.startAngle=Fa(r.startAngle,e._targetStartAngle,i),e.endAngle=Fa(r.endAngle,e._targetEndAngle,i))}}}if(t>=1){for(let 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){let 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,function(e){for(let t of e){if(void 0!==t._targetOpacity){let e=t._targetOpacity;t.style={...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}"point"===t.type?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):void 0!==t._targetR&&(t.r=t._targetR,t._targetR=void 0):"rect"===t.type?void 0!==t._targetX&&(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):"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0)}}(this.scene),this.exitNodes=[]}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();let t=Ta(e),i=this.getDataId,r=e=>t.has(i(e));hs(this.buffer,this.timestampBuffer,r);let o=this.buffer.remove(r);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(let 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");let i=Ta(e),r=this.getDataId,o=new Set;this.buffer.forEach((e,t)=>{i.has(r(e))&&o.add(t)});let n=this.buffer.update(e=>i.has(r(e)),t);if(0===n.length)return this.updateResults.recordNoop("update"),n;for(let e of n)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",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(e,t){let i=this._customRestyle;if(i)for(let r of e){let e=this._baseStyles.get(r)??r.style??{},o=i(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)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(let e of this.rExtents)e.clear();this._categoryIndexCache=null,this.buffer.forEach(e=>{this.categories.add(this.getO(e)),this.pushValueExtent(e)})}updateConfig(e){let t={...this.config},i=Object.keys(e).filter(i=>e[i]!==t[i]);"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&&!Sa(e.colorAccessor,t.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!Sa(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!Sa(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)&&(Sa(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=$a(this.config.categoryAccessor||this.config.oAccessor,"category"),r=!0));let o=!1;if("valueAccessor"in e||"rAccessor"in e){let e=this.config.valueAccessor||this.config.rAccessor,i=t.valueAccessor||t.rAccessor,r=Array.isArray(e)?e:[e],n=Array.isArray(i)?i:[i];if(o=r.length!==n.length||r.some((e,t)=>!Sa(e,n[t])),o){let e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>Ma(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new pm)):(this.getR=Ma(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!Sa(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?$a(this.config.stackBy):void 0),"groupBy"in e&&!Sa(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?$a(this.config.groupBy):void 0),"colorAccessor"in e&&!Sa(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?$a(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!Sa(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?$a(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!Sa(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?$a(this.config.connectorAccessor):void 0),(r||o||"accessorRevision"in e&&e.accessorRevision!==t.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(i)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};xs(Sv);import*as Mv from"react";import*as _v from"react";import{arc as $v}from"d3-shape";var Pv=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)});import{jsx as Rv,jsxs as Iv}from"react/jsx-runtime";import{jsx as Lv,jsxs as Tv}from"react/jsx-runtime";import{jsx as Cv,jsxs as Ov}from"react/jsx-runtime";import{Fragment as Fv,jsx as Dv,jsxs as zv}from"react/jsx-runtime";import*as Nv from"react-dom/server";var Ev=Object.create(null);import{min as Bv}from"d3-array";import{min as Wv,max as jv,sum as Yv,mean as Xv,group as qv,groups as Gv}from"d3-array";import{interpolateNumber as Vv}from"d3-interpolate";import{line as Hv,curveLinearClosed as Uv}from"d3-shape";var Kv=e=>{let t,i,r,o,n,a,s,l,c;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,i=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,n=e.source.x1,a=e.target.x0,s=Vv(n,a),l=s(.5),c=s(.5),`M${t},${n}C${t},${l} ${i},${c} ${i},${a}L${r},${a}C${r},${c} ${o},${l} ${o},${n}Z`;let u=e.sankeyWidth/2,d=Vv(e.source.x1,e.target.x0),{pathD:h}=Vi({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:d(.5),cp2X:d(.5)});return h},Zv=new Set,Qv=new WeakMap,Jv={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(qu))-1:0},justify:Gu},ew={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,i,r){if(0===e.length)return;let o,n="vertical"===i.orientation?"down":"right",a=i.nodeAlign||"justify",s=i.nodeWidth??15,l=i.nodePaddingRatio??.05,c=i.iterations??100,u=e.map(e=>({...e})),d=t.map(e=>({...e,source:Ra(e.source),target:Ra(e.target),value:Math.sqrt(Math.max(1,e.value||1))}));o="down"===n?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];let h=pd().extent(o).links(d).nodes(u).nodeAlign(Jv[a]||Gu).nodeId(e=>e.id).nodeWidth(s).iterations(c);h.nodePaddingRatio&&h.nodePaddingRatio(l),h();{let e=1/0,t=-1/0,i=1/0,o=-1/0;for(let r of u)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),i>r.y0&&(i=r.y0),r.y1>o&&(o=r.y1);for(let r of d){if(!r.circular||!r.circularPathData)continue;let n=r.circularPathData,a=(r._circularWidth??r.width??0)/2;e>n.leftFullExtent-a&&(e=n.leftFullExtent-a),n.rightFullExtent+a>t&&(t=n.rightFullExtent+a),i>n.verticalFullExtent-a&&(i=n.verticalFullExtent-a),n.verticalFullExtent+a>o&&(o=n.verticalFullExtent+a)}let n=t-e,a=o-i,s=r[0],l=r[1];if(n>0&&a>0&&(0>e||0>i||t>s||o>l)){let t=Math.min(s/n,l/a),r=-e*t+(s-n*t)/2,o=-i*t+(l-a*t)/2;for(let e of u)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(let e of d)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){let i=e.circularPathData;i.sourceX=i.sourceX*t+r,i.targetX=i.targetX*t+r,i.sourceY=i.sourceY*t+o,i.targetY=i.targetY*t+o,i.rightFullExtent=i.rightFullExtent*t+r,i.leftFullExtent=i.leftFullExtent*t+r,i.verticalFullExtent=i.verticalFullExtent*t+o,i.rightInnerExtent=i.rightInnerExtent*t+r,i.leftInnerExtent=i.leftInnerExtent*t+r,i.verticalRightInnerExtent=i.verticalRightInnerExtent*t+o,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*t+o,i.rightSmallArcRadius*=t,i.rightLargeArcRadius*=t,i.leftSmallArcRadius*=t,i.leftLargeArcRadius*=t,i.sourceWidth*=t,i.rightNodeBuffer*=t,i.leftNodeBuffer*=t,i.arcRadius*=t}}}let f=new Map;for(let t of e)f.set(t.id,t);for(let e of u){let 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)}let p=new Map;for(let e of t)if(e._edgeKey)p.set(e._edgeKey,e);else{let t=Ra(e.source),i=Ra(e.target);p.set(`${t}\0${i}`,e)}for(let e of d){let t=Ra(e.source),i=Ra(e.target),r=p.get(e._edgeKey?e._edgeKey:`${t}\0${i}`);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=n;let o=f.get(t),a=f.get(i);o&&(r.source=o),a&&(r.target=a)}}},buildScene(e,t,i,r){let o="vertical"===i.orientation?"down":"right",n=i.nodeStyle,a=i.edgeStyle,s=i.edgeOpacity??.5,l=i.edgeColorBy||"source",c=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:tf,u=new Map;e.forEach((e,t)=>{u.set(e.id,c[t%c.length])});let d=[],h=[],f=[],p=new Map;for(let t of e){let e=t.x1-t.x0,i=t.y1-t.y0;if(0>=e||0>=i)continue;let r=n?n(gd(t,"nodeStyle")):{},a={fill:r.fill||u.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity,cursor:r.cursor};p.set(t.id,("string"==typeof a.fill?a.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===o?{type:"rect",x:t.y0,y:t.x0,w:i,h:e,style:a,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:i,style:a,datum:t,id:t.id,label:t.id})}let y=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(let e of y){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;let t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=i.themeSemantic?.border||i.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;let n,c=a?a(gd(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){let t=e.circularPathData,i=e.sankeyWidth/2,r=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),n=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),a=c.fill||o;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-i}L${t.sourceX+r},${t.sourceY-i}L${t.sourceX+r},${t.sourceY+i}L${t.sourceX},${t.sourceY+i}Z`,style:{fill:a,fillOpacity:c.fillOpacity??s,stroke:"none",opacity:c.opacity,cursor:c.cursor},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+r}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-i}L${t.targetX-n},${t.targetY-i}L${t.targetX-n},${t.targetY+i}L${t.targetX},${t.targetY+i}Z`,style:{fill:a,fillOpacity:c.fillOpacity??s,stroke:"none",opacity:c.opacity,cursor:c.cursor},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-n,x1:t.targetX}});continue}n=e.circular&&e.circularPathData?yd(e):Kv(e),n&&h.push({type:"bezier",pathD:n,bezierCache:e.bezier,style:{fill:c.fill||o,fillOpacity:c.fillOpacity??s,stroke:c.stroke||"none",strokeWidth:c.strokeWidth,opacity:c.opacity,cursor:c.cursor},datum:e})}if(!1!==i.showLabels){let t=Pa(i.nodeLabel);for(let i of e){let e=i.x1-i.x0,n=i.y1-i.y0;if(0>=e||0>=n)continue;let a,s,l,c=t?t(i):i.id;c&&("down"===o?(a=i.y0+(i.y1-i.y0)/2,s=i.x1+14,l="start"):(r[0]/2>i.x0+e/2?(a=i.x0-6,l="end"):(a=i.x1+6,l="start"),s=i.y0+n/2),f.push({x:a,y:s,text:c+"",anchor:"down"===o?"middle":l,baseline:"middle",fontSize:11}))}}return{sceneNodes:d,sceneEdges:h,labels:f}}};Ru("sankey",ew);import{forceSimulation as tw,forceCenter as iw,forceX as rw,forceY as ow,forceLink as nw,forceManyBody as aw,forceCollide as sw}from"d3-force";import{scaleLinear as lw}from"d3-scale";var cw={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,i,r){if(0===e.length)return;let o=i.forceStrength??.1,n=r[0]/2,a=r[1]/2,s=Math.max(.1,Math.min(1,Math.min(r[0],r[1])/200)),l=Math.min(.5,.06+1.8*(1-s)),c=i.__previousPositions,u=0,d=[];for(let t of e){let e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),i=c?.get(t.id);e?u++:i?(t.x=i.x,t.y=i.y,u++):d.push(t)}let h=u>0&&.3>=(e.length>0?d.length/e.length:1);if(h){let i=new Map;for(let t of e)i.set(t.id,t);for(let e of d){let r=bd(e.id,t,i);if(r.length>0){let t=0,i=0;for(let e of r)t+=e.x,i+=e.y;let o=xd(e.id),n=o%360*(Math.PI/180),a=(10+o%20)*s;e.x=t/r.length+a*Math.cos(n),e.y=i/r.length+a*Math.sin(n)}else{let t=xd(e.id),i=t%360*(Math.PI/180),r=(15+t%30)*s;e.x=n+r*Math.cos(i),e.y=a+r*Math.sin(i)}}}else{let t=2.399963229728653;for(let i=0;e.length>i;i++){let r=e[i];if(null==r.x||null==r.y||0===r.x&&0===r.y){let e=10*Math.sqrt(i+.5)*s,o=i*t;r.x=n+e*Math.cos(o),r.y=a+e*Math.sin(o)}}}let f=i.__skipForceSimulation||0===i.iterations?0:h?40:i.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),p=md(i.nodeSize,i.nodeSizeRange,e),y=e=>p(e);if(f>0){let c=new Map,u=new Map;for(let t of e)c.set(t.id,0),u.set(t.id,t);for(let e of t){let t=Ra(e.source),i=Ra(e.target);c.set(t,(c.get(t)??0)+1),c.set(i,(c.get(i)??0)+1)}let d=nw().strength(e=>{let t=e.weight,i=Ra(e.source),r=Ra(e.target),n=Math.max(1,Math.min(c.get(i)??1,c.get(r)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*o/(.1*n))}).distance(e=>{let t="string"==typeof e.source?u.get(e.source):e.source,i="string"==typeof e.target?u.get(e.target):e.target,r=(t?y(t):0)+(i?y(i):0)+Math.max(6,12*s);return Math.max(16,40*s,r)}).id(e=>e.id),p=tw();if((void 0!==i.random||void 0!==i.seed)&&p.randomSource(i.random??function(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}(i.seed)),p.force("charge",aw().strength(e=>{let t=c.get(e.id)??0;return-15*s*y(e)*Math.sqrt(t+1)})).force("collide",sw(e=>y(e)+3*s).strength(.9).iterations(2)).force("center",iw(n,a).strength(.8)).force("x",rw(n).strength(l)).force("y",ow(a).strength(l)).force("bounds",function(e,t,i=2,r=.6){let o=[],n=n=>{let a=r*Math.max(n,.2);for(let r of o){let o=r.x??e[0]/2,n=r.y??e[1]/2,s=r.vx??0,l=r.vy??0,c=t(r)+i,u=Math.min(e[0]/2,c),d=Math.max(e[0]/2,e[0]-c),h=Math.min(e[1]/2,c),f=Math.max(e[1]/2,e[1]-c),p=o+s,y=n+l;u>p?r.vx=s+(u-p)*a:p>d&&(r.vx=s+(d-p)*a),h>y?r.vy=l+(h-y)*a:y>f&&(r.vy=l+(f-y)*a)}};return n.initialize=e=>{o=e},n}(r,y)),p.nodes(e),t.length>0){let e=t.map(e=>({...e,source:Ra(e.source),target:Ra(e.target)}));d.links(e),p.force("link",d)}h?p.alpha(.3):.1>p.alpha()&&p.alpha(1),p.stop();for(let e=0;f>e;++e)p.tick()}for(let t of e){if(null==t.x||null==t.y)continue;let e=y(t),i=f>0?2:0,o=Math.min(r[0]/2,e+i),n=Math.min(r[1]/2,e+i);t.x=Math.max(o,Math.min(r[0]-o,t.x)),t.y=Math.max(n,Math.min(r[1]-n,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}let g=new Map;for(let t of e)g.set(t.id,t);for(let e of t){if("string"==typeof e.source){let t=g.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){let t=g.get(e.target);t&&(e.target=t)}}},buildScene(e,t,i,r){let o=i.nodeStyle,n=i.edgeStyle,a=md(i.nodeSize,i.nodeSizeRange,e),s=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:tf,l=new Map;e.forEach((e,t)=>{l.set(e.id,s[t%s.length])});let c=[],u=[],d=[];for(let t of e){if(null==t.x||null==t.y)continue;let e=a(gd(t,"nodeSize")),r=o?o(gd(t,"nodeStyle")):{},n={fill:r.fill||l.get(t.id)||i.themeSemantic?.primary||"#007bff",stroke:r.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity,cursor:r.cursor};c.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id})}let h=new Map;for(let t of e)h.set(t.id,t);for(let e of t){let t="object"==typeof e.source?e.source:h.get(e.source),r="object"==typeof e.target?e.target:h.get(e.target);if(!t||!r||null==t.x||null==t.y||null==r.x||null==r.y)continue;let o=n?n(gd(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:o.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6,cursor:o.cursor},datum:e})}if(!1!==i.showLabels){let t=Pa(i.nodeLabel);for(let i of e){if(null==i.x||null==i.y)continue;let e=t?t(i):i.id;if(!e)continue;let r=a(gd(i,"nodeSize"));d.push({x:i.x,y:i.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}return{sceneNodes:c,sceneEdges:u,labels:d}}};Ru("force",cw);import{chord as uw,ribbon as dw}from"d3-chord";import{arc as hw}from"d3-shape";var fw=tf,pw={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,i,r){if(0===e.length)return;let{padAngle:o=.01,groupWidth:n=20,sortGroups:a}=i,s=Math.min(r[0],r[1])/2,l=s-n,c=r[0]/2,u=r[1]/2,d=(f=i.valueAccessor)?"function"==typeof f?f:e=>e[f]??1:e=>e.value??1,h=new Map;var f;for(let t=0;e.length>t;t++)h.set(e[t].id,t);let p=e.length,y=Array.from({length:p},()=>Array(p).fill(0));for(let e of t){let t=Ra(e.source),i=Ra(e.target),r=h.get(t),o=h.get(i);if(void 0===r||void 0===o)continue;let n=d(e);y[r][o]=n}let g=uw().padAngle(o);a&&g.sortGroups(a);let m=g(y),b=m.groups,x=hw().innerRadius(l).outerRadius(s);for(let t of b){let i=e[t.index],r=x.centroid({innerRadius:l,outerRadius:s,startAngle:t.startAngle,endAngle:t.endAngle});i.x=r[0]+c,i.y=r[1]+u,i.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}let v=new Map;for(let t of e)v.set(t.id,t);for(let e of t){let t=Ra(e.source),i=Ra(e.target),r=v.get(t),o=v.get(i);r&&(e.source=r),o&&(e.target=o)}let w=new Map;for(let e of t){let t=Ra(e.source),i=Ra(e.target);w.set(`${t}\0${i}`,e)}for(let t of m){let i=e[t.source.index].id,r=e[t.target.index].id,o=w.get(`${i}\0${r}`)||w.get(`${r}\0${i}`);o&&(o.__chordData=t)}},buildScene(e,t,i,r){let{groupWidth:o=20,edgeOpacity:n=.5}=i,a=Math.min(r[0],r[1])/2,s=a-o,l=r[0]/2,c=r[1]/2,u=i.nodeStyle,d=i.edgeStyle,h=i.edgeColorBy||"source",f=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:fw,p=new Map;e.forEach((e,t)=>{p.set(e.id,f[t%f.length])});let y=dw().radius(s),g=[],m=[],b=[];for(let t=0;e.length>t;t++){let i=e[t],r=i.__arcData;if(!r)continue;let o=u?u(gd(i,"nodeStyle")):{},n={fill:("string"==typeof o.fill?o.fill:void 0)||p.get(i.id)||f[t%f.length],stroke:o.stroke||"black",strokeWidth:o.strokeWidth??1,opacity:o.opacity,cursor:o.cursor};g.push({type:"arc",cx:l,cy:c,innerR:s,outerR:a,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:n,datum:i,id:i.id,label:i.id})}for(let e of t){let t=e.__chordData;if(!t)continue;let r=y(t);if(!r)continue;let o=vd(r,l,c),a=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",s=d?d(gd(e,"edgeStyle")):{};if(d)a=("string"==typeof s.fill?s.fill:void 0)||a;else{let t="object"==typeof e.source?e.source:null,i="object"==typeof e.target?e.target:null;"target"===h&&i?a=p.get(i.id)||a:t&&(a=p.get(t.id)||a)}m.push({type:"ribbon",pathD:o,style:{fill:a,fillOpacity:s.fillOpacity??n,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity,cursor:s.cursor},datum:e})}if(!1!==i.showLabels){let t=Pa(i.nodeLabel),r=a+12;for(let i of e){let e=i.__arcData;if(!e)continue;let o=t?t(i):i.id;if(!o)continue;let n=(e.startAngle+e.endAngle)/2,a=n-Math.PI/2;b.push({x:l+Math.cos(a)*r,y:c+Math.sin(a)*r,text:o+"",anchor:n>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:m,labels:b}}};Ru("chord",pw);import{hierarchy as yw,tree as gw,cluster as mw,treemap as bw,pack as xw,partition as vw,treemapBinary as ww}from"d3-hierarchy";var kw=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"],Aw={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,i,r){let o=i.__hierarchyRoot;if(!o)return;let n=i.chartType,a=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(i.childrenAccessor),s=i.hierarchySum,l="function"==typeof s?s:"string"==typeof s?e=>Number(e[s])||0:e=>Number(e.value)||0,c=yw(o,a);c.sum(l),c.sort((e,t)=>(t.value??0)-(e.value??0));let[u,d]=r;switch(n){case"tree":!function(e,t,i,r){let o=t.treeOrientation||"vertical",n=gw();n.size("horizontal"===o?[r,i]:"radial"===o?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),n(e)}(c,i,u,d);break;case"cluster":!function(e,t,i,r){let o=t.treeOrientation||"vertical",n=mw();n.size("horizontal"===o?[r,i]:"radial"===o?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),n(e)}(c,i,u,d);break;case"treemap":!function(e,t,i,r){let o=t.padding??4,n=t.paddingTop??0,a=bw().size([i,r]).tile(ww).padding(o);n>0&&a.paddingTop(n),a(e)}(c,i,u,d);break;case"circlepack":!function(e,t,i,r){let o=t.padding??4;xw().size([i,r]).padding(o)(e)}(c,i,u,d);break;case"partition":!function(e,t,i,r){vw().size([i,r]).padding(t.padding??1)(e)}(c,i,u,d)}let h=c.descendants();e.length=0,t.length=0;let f=new Map;for(let t=0;h.length>t;t++){let r=h[t],o={id:kd(r,i,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"===n||"cluster"===n?$d(o,r,i):"treemap"===n||"partition"===n?Pd(o,r):"circlepack"===n&&Rd(o,r),o.__hierarchyNode=r,e.push(o),f.set(r,o)}if("tree"===n||"cluster"===n)for(let e of h)if(e.parent){let i=f.get(e.parent),r=f.get(e);i&&r&&t.push({source:i,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,i,r){let o=i.nodeStyle||(()=>({})),n=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(e,t,i,r,o,n){let a=[],s=[],l=[],c=i.treeOrientation||"vertical",u="radial"===c,d=r[0]/2,h=r[1]/2,f="number"==typeof(p=i.nodeSize)?p:5;var p;for(let t of e){let e=t.x,r=t.y;u&&(e+=d,r+=h);let n=o(gd(t,"nodeStyle")),s=n.fill||Md(i);if(i.colorByDepth&&void 0!==t.depth){let e=Sd(i);s=e[t.depth%e.length]}a.push({type:"circle",cx:e,cy:r,r:f,style:{fill:s,stroke:n.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??1,opacity:n.opacity,cursor:n.cursor},datum:t,id:t.id,label:t.id,depth:t.depth})}let y=i.edgeOpacity??.5;for(let e of t){let t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=t.x,a=t.y,l=r.x,f=r.y;u&&(o+=d,a+=h,l+=d,f+=h);let p=_d(o,a,l,f,c),g=n(gd(e,"edgeStyle"));s.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,cursor:g.cursor},datum:e})}if(!1!==i.showLabels){let t=Ad(i.nodeLabel);for(let i of e){let e=t?t(i):i.id;if(!e)continue;let r,o,n,a=i.x,s=i.y;if(u&&(a+=d,s+=h),u){let e=a-d,t=s-h,i=Math.sqrt(e*e+t*t);i>0?(r=a+e/i*10,o=s+t/i*10,n=0>e?"end":"start"):(r=a,o=s-12,n="middle")}else"horizontal"===c?(i.data?.children&&0!==i.data.children.length?(r=a-f-6,n="end"):(r=a+f+6,n="start"),o=s):(r=a,o=s+f+14,n="middle");l.push({x:r,y:o,text:e+"",anchor:n,baseline:"middle",fontSize:11})}}return{sceneNodes:a,sceneEdges:s,labels:l}}(e,t,i,r,o,n);case"treemap":case"partition":return function(e,t,i,r){let o=[],n=[];for(let i of e){let e=i.x1-i.x0,n=i.y1-i.y0;if(0>=e||0>=n)continue;let a=r(gd(i,"nodeStyle")),s=a.fill||Md(t);if(t.colorByDepth&&void 0!==i.depth){let e=Sd(t);s=e[i.depth%e.length]}o.push({type:"rect",x:i.x0,y:i.y0,w:e,h:n,style:{fill:s,stroke:a.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:a.strokeWidth??1,opacity:a.opacity,fillOpacity:a.fillOpacity,strokeOpacity:a.strokeOpacity,cursor:a.cursor},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==t.showLabels){let i=Ad(t.nodeLabel),o=t.labelMode||"leaf",a="partition"===t.chartType;for(let s of e){let e=s.x1-s.x0,l=s.y1-s.y0;if(0>=e||0>=l)continue;let c=!(s.data?.children&&s.data.children.length>0);if(!a&&("leaf"===o&&!c||"parent"===o&&c))continue;let u=i?i(s):s.id;if(!u)continue;if((c?30:40)>e||(c?16:14)>l)continue;let d=r(gd(s,"nodeStyle")).fill||Md(t);if(t.colorByDepth&&void 0!==s.depth){let e=Sd(t);d=e[s.depth%e.length]}let h="string"==typeof d?wd(d):t.themeSemantic?.text??"#000";n.push(c?{x:s.x0+e/2,y:s.y0+l/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,l)/6)),fill:h}:{x:s.x0+4,y:s.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:o,sceneEdges:[],labels:n}}(e,i,0,o);case"circlepack":return function(e,t,i,r){let o=[],n=[];for(let i of e){let e=i.__radius??5;if(0>=e)continue;let n=r(gd(i,"nodeStyle")),a=n.fill||Md(t);if(t.colorByDepth&&void 0!==i.depth){let e=Sd(t);a=e[i.depth%e.length]}o.push({type:"circle",cx:i.x,cy:i.y,r:e,style:{fill:a,stroke:n.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??1,opacity:n.opacity??.7,cursor:n.cursor},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==t.showLabels){let i=Ad(t.nodeLabel);for(let o of e){let e=o.__radius??5,a=i?i(o):o.id;if(!a||15>e)continue;let s=!(o.data?.children&&o.data.children.length>0),l=r(gd(o,"nodeStyle")).fill||Md(t);if(t.colorByDepth&&void 0!==o.depth){let e=Sd(t);l=e[o.depth%e.length]}if(s){let i="string"==typeof l?wd(l):t.themeSemantic?.text??"#000";n.push({x:o.x,y:o.y,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:i})}else n.push({x:o.x,y:o.y-e+14,text:a+"",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:n}}(e,i,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};Ru("tree",Aw),Ru("cluster",Aw),Ru("treemap",Aw),Ru("circlepack",Aw),Ru("partition",Aw);import{pie as Sw}from"d3-shape";var Mw={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,i,r){let o=i.__hierarchyRoot;o&&function(e,t,i,r,o){function n(e){let t=p.get(e)??0;return p.set(e,t+1),0===t?e:`${e}__${t}`}let a=function(e){if("function"==typeof e)return e;let t=e||"children";return e=>e[t]||null}(i.childrenAccessor),s=function(e){if("function"==typeof e)return e;let t=e||"name";return e=>(e[t]??"")+""}(i.nodeIDAccessor),l=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(i.orbitMode),c=i.orbitSize??2.95,u=i.orbitEccentricity??1,d="number"==typeof c?()=>c:c,h="number"==typeof u?()=>u:u,f=Id(i);f.metaMap.clear(),r.length=0,o.length=0;let p=new Map,y=t[0]/2,g=t[1]/2,m=Math.min(t[0],t[1])/2*.85,b=n(s(e));r.push({id:b,x:y,y:g,x0:y,x1:y,y0:g,y1:g,width:0,height:0,value:0,depth:0,data:e}),f.metaMap.set(b,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,i,c,u,p,y,g){let m=a(t);if(!m?.length)return;let b=m.length,x=0,v=0,w=0;for(;b>v;)v+=l[Math.min(w,l.length-1)],w++,x++;let k=0;for(let b=0;x>b;b++){let v=l[Math.min(b,l.length-1)],w=m.slice(k,k+v);if(!w.length)break;let A=(b+1)/x,S={id:i,depth:y,data:t,parentId:i},M=g?p/d(S)*A:p*A,_=Sw().value(e=>a(e)?.length?4:1).sort(null)(w),$=h(S);for(let t=0;w.length>t;t++){let a=(_[t].startAngle+_[t].endAngle)/2,l=w[t],d=n(s(l)),h=c+M*Math.sin(a),p=u+M*Math.cos(a)*$;r.push({id:d,x:h,y:p,x0:h,x1:h,y0:p,y1:p,width:0,height:0,value:0,depth:y,data:l}),f.metaMap.set(d,{ring:M,angle:a,depth:y,parentId:i,eccentricity:$}),o.push({source:i,target:d,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:d}}),e(l,d,h,p,M,y+1,!0)}k+=v}}(e,b,y,g,m,1,!1)}(o,r,i,e,t)},buildScene(e,t,i,r){let o=i.nodeStyle,n=i.edgeStyle,a=i.nodeSize,s="number"==typeof a?()=>a:"function"==typeof a?a:()=>6,l=[],c=[],u=[];if(!1!==i.orbitShowRings){let t=Id(i),r=new Map;for(let t of e)r.set(t.id,t);let o=new Map;for(let[,e]of t.metaMap){if(!e.parentId)continue;let t=r.get(e.parentId);if(!t)continue;let i=`${e.parentId}:${e.ring}`;o.has(i)||o.set(i,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}let n=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(let[,{parentX:e,parentY:t,ring:i,ecc:r}]of o)for(let o=0;n>o;o++){let s=o/n*Math.PI*2,l=(o+1)/n*Math.PI*2;c.push({type:"line",x1:e+i*Math.sin(s),y1:t+i*Math.cos(s)*r,x2:e+i*Math.sin(l),y2:t+i*Math.cos(l)*r,style:a,datum:null})}}for(let t of e){if(null==t.x||null==t.y)continue;let e=s(gd(t,"nodeSize")),r=o?o(gd(t,"nodeStyle")):{};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:r.fill||i.themeSemantic?.primary||"#6366f1",stroke:r.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??(0===(t.depth??0)?1:.85),cursor:r.cursor},datum:t,id:t.id,label:t.id,depth:t.depth})}let d=new Map;for(let t of e)d.set(t.id,t);for(let e of t){let t="object"==typeof e.source?e.source:d.get(e.source),i="object"==typeof e.target?e.target:d.get(e.target);if(!t||!i||null==t.x||null==i.x)continue;let r=n?n(gd(e,"edgeStyle")):{};c.push({type:"line",x1:t.x,y1:t.y,x2:i.x,y2:i.y,style:{stroke:r.stroke||"rgba(128,128,128,0.35)",strokeWidth:r.strokeWidth??.5,opacity:r.opacity??1,cursor:r.cursor},datum:e})}if(i.showLabels){let t=i.nodeLabel;for(let i of e){let e=s(gd(i,"nodeSize"));if(4>=e)continue;let r="function"==typeof t?t(i):t?i.data?.[t]??i.id:i.id;u.push({x:i.x,y:i.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:l,sceneEdges:c,labels:u}},tick:(e,t,i,r,o)=>!1!==i.orbitAnimated&&(function(e,t){let i=Id(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=>{let t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),n=(("u">typeof performance?performance.now():Date.now())-i.startTime)/1e3,a=r*(Math.PI/6),s=new Map;for(let t of e)s.set(t.id,t);for(let t of e){let e=i.metaMap.get(t.id);if(!e||!e.parentId)continue;let r=s.get(e.parentId);if(!r)continue;let l=e.angle+n*a*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,i),!0)};Ru("orbit",Mw);import*as _w from"react";import{arc as $w}from"d3-shape";import{jsx as Pw,jsxs as Rw}from"react/jsx-runtime";import{Fragment as Iw,jsxs as Lw}from"react/jsx-runtime";Ru("sankey",ew),Ru("force",cw),Ru("chord",pw),Ru("tree",Aw),Ru("cluster",Aw),Ru("treemap",Aw),Ru("circlepack",Aw),Ru("partition",Aw),Ru("orbit",Mw);var Tw=new Set(["tree","cluster","treemap","circlepack","partition","orbit"]);import*as Cw from"react-dom/server";import{geoPath as Ow}from"d3-geo";import{quadtree as Fw}from"d3-quadtree";import{geoMercator as Dw,geoEqualEarth as zw,geoAlbersUsa as Nw,geoOrthographic as Ew,geoNaturalEarth1 as Bw,geoEquirectangular as Ww}from"d3-geo";var jw={mercator:Dw,equalEarth:zw,albersUsa:Nw,orthographic:Ew,naturalEarth:Bw,equirectangular:Ww};import{scaleLinear as Yw}from"d3-scale";var Xw=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],qw=["scene-style","data-paint","accessibility","evidence"],Gw=(e,t)=>({retainedData:e,invalidations:t}),Vw=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Hw=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Uw=["scene-geometry","data-paint","accessibility","evidence"],Kw=["scene-style","data-paint","accessibility","evidence"],Zw=["overlay","accessibility","evidence"],Qw=[],Jw={xAccessor:Gw("rebuild",Vw),yAccessor:Gw("rebuild",Vw),lineDataAccessor:Gw("rebuild",Vw),pointIdAccessor:Gw("rebuild",Uw),lineIdAccessor:Gw("rebuild",Uw),windowSize:Gw("rebuild",Vw),projection:Gw("preserve",Hw),projectionExtent:Gw("preserve",Hw),fitPadding:Gw("preserve",Hw),lineType:Gw("preserve",Hw),flowStyle:Gw("preserve",Hw),graticule:Gw("preserve",Hw),projectionTransform:Gw("preserve",Hw),customLayout:Gw("preserve",Hw),layoutConfig:Gw("preserve",Hw),layoutMargin:Gw("preserve",Hw),areaStyle:Gw("preserve",Kw),pointStyle:Gw("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:Gw("preserve",Kw),colorScheme:Gw("preserve",Kw),themeCategorical:Gw("preserve",Kw),themeDiverging:Gw("preserve",Kw),themeSemantic:Gw("preserve",Kw),themeSequential:Gw("preserve",Kw),decay:Gw("preserve",Kw),pulse:Gw("preserve",Kw),layoutSelection:Gw("preserve",Kw),annotations:Gw("preserve",Zw),autoPlaceAnnotations:Gw("preserve",Zw),clock:Gw("preserve",Qw),transition:Gw("preserve",Qw),introAnimation:Gw("preserve",Qw),onLayoutError:Gw("preserve",Qw)},ek=Gw("preserve",Hw),tk=class{constructor(){this.tracker=new Hy}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}},Xw)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},qw):this.recordNoop("restyle")}recordConfig(e,t={}){let i=function(e){let t="preserve",i=new Set;for(let r of e){let e=Jw[r]??ek;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}(e),r=new Set(i.invalidations);return t.retainedDataChanged&&r.add("data"),this.tracker.record({kind:"config",keys:e},r)}};import{geoDistance as ik,geoGraticule as rk,geoInterpolate as ok}from"d3-geo";var nk=class e{constructor(e){this.updateResults=new tk,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:Xd(e.fitPadding)}}(e)}currentTime(){return this.config.clock?.()??Da()}getConfiguredWindowSize(){let 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){let t=this.pointBuffer.toArray(),i=this.timestampBuffer?.toArray()??[],r=t.slice(-e),o=i.slice(-r.length),n=this.currentTime();this.pointBuffer=new fm(e),this.timestampBuffer=new fm(e),r.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(o[t]??n)})}this.retainNewestLines(e)}updateConfig(e){let t=function(e){return"fitPadding"in e?{...e,fitPadding:Xd(e.fitPadding)}:e}(e),i=this.config,r=this.getConfiguredWindowSize(),o=Object.keys(t).filter(e=>t[e]!==i[e]);this.config={...this.config,...t};let n=this.getConfiguredWindowSize(),a=this.streaming&&n!==r;a&&(this.resizeStreamingWindow(n),this.version++),"customLayout"in t&&!t.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(o,{retainedDataChanged:a})}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});let t=this.getConfiguredWindowSize(),i=this.pointBuffer?this.pointBuffer.toArray():this.pointData,r=this.timestampBuffer?.toArray()??[],o=i.slice(-t),n=r.slice(-o.length),a=this.currentTime();this.pointBuffer=new fm(t),this.timestampBuffer=new fm(t),o.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(n[t]??a)}),this.pointData=[],this.retainNewestLines(t),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();let t=this.currentTime();ds(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();let t=this.currentTime();for(let i of e)ds(this.pointBuffer,i,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");let t=e.filter(e=>null!=e&&"object"==typeof e);if(0!==t.length){this.streaming||this.initStreaming();for(let e of t)this.lineData.push(e);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",t.length)}else this.updateResults.recordNoop("ingest")}removeLine(e){let{lineIdAccessor:t}=this.config;if(!t)throw Error("removeLine() requires lineIdAccessor to be configured");let i="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(i(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){let{pointIdAccessor:t}=this.config;if(!t)throw Error("removePoint() requires pointIdAccessor to be configured");let i="function"==typeof t?t:e=>e[t],r=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){let e=e=>r.has(i(e)+"");hs(this.pointBuffer,this.timestampBuffer,e);let t=this.pointBuffer.remove(e);return t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}{let e=[];return this.pointData=this.pointData.filter(t=>!r.has(i(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){let t=this._customRestyle;if(t){for(let i of this.scene){let r=this._baseStyles.get(i)??i.style,o=t(i,e);i.style=o?{...r,...o}:r}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(e){let{config:t}=this,i=this.projection,r=this.geoPath,o=this.scales,n=this.baseScale,a=[...this.baseTranslate],s=[...this.baseRotation],l=this.scene;this.projection=function(e){if(!e)return zw();if("string"==typeof e){let t=jw[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),zw())}if("object"==typeof e&&"type"in e){let t=jw[e.type],i=t?t():zw();return e.rotate&&"rotate"in i&&i.rotate(e.rotate),e.center&&"center"in i&&i.center(e.center),i}return e}(t.projection),this.geoPath=Ow(this.projection),this.fitProjection(e),this.geoPath=Ow(this.projection);let 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;let u=this.buildSceneNodes(e);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=i,this.geoPath=r,this.scales=o,this.baseScale=n,this.baseTranslate=a,this.baseRotation=s):(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){let t=e.width/2,i=e.height/2,r=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:i}));r.length>0&&this.startTransition(r)}this._hasRenderedOnce=!0,t.transition&&l.length>0&&this.startTransition(l),this.version++}}fitProjection(e){let t=this.projection,i=this.config,r=[...this.areas],o=zd(i.xAccessor,"lon"),n=zd(i.yAccessor,"lat"),a=this.getPoints();if(a.length>0){let e=a.map(e=>[o(e),n(e)]);r.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}let s=Nd(i.lineDataAccessor);for(let e of this.lineData){let t=s(e);if(t&&t.length>0){let e=t.map(e=>[o(e),n(e)]);r.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==r.length){if(i.projectionExtent){let[[r,o],[n,a]]=i.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[r,o],[r,a],[n,a],[n,o],[r,o]]]}})}else if(t.clipAngle&&(t.clipAngle()??0)>0){let r=i.fitPadding??0,o=Math.min(e.width,e.height);t.scale(o/2-o*r),t.translate([e.width/2,e.height/2])}else{let o=i.fitPadding??0,n=e.width*o,a=e.height*o;t.fitExtent([[n,a],[e.width-n,e.height-a]],{type:"FeatureCollection",features:r})}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){let i=this.projection;if(!i)return;let r=this.geoPath,o=this.scales,n=i.scale(),a=[...i.translate()],s=this.currentZoom;i.scale(this.baseScale*e.k),i.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=Ow(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let l=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(n),i.translate(a),this.currentZoom=s,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){let i=this.projection;if(!i)return;let r=this.geoPath,o=this.scales,n=i.scale(),a=[...i.translate()],s=this.currentZoom;i.scale(this.baseScale*e),i.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=Ow(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let l=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(n),i.translate(a),this.currentZoom=s,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){let i=this.projection;if(!i||!i.rotate)return;let r=this.geoPath,o=this.scales,n=[...i.rotate()];i.rotate(e),this.geoPath=Ow(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let a=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.rotate(n),this.geoPath=r,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=a,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){let 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,i=0;for(let e of this.scene)"point"===e.type&&!1!==e.interactive&&(i++,e.r>t&&(t=e.r));if(this._maxPointRadius=t,e.QUADTREE_THRESHOLD>=i)return void(this._quadtree=null);let r=Array(i),o=0;for(let e of this.scene)"point"===e.type&&!1!==e.interactive&&(r[o++]=e);this._quadtree=Fw().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;let{config:t}=this,i=this.projection,r=this.geoPath;if(t.customLayout&&this.scales){let i=t.layoutMargin??{top:0,right:0,bottom:0,left:0},r=qo(t.colorScheme,t.themeCategorical,_f),o={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:i,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...r]},resolveColor:Go(r,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null},n=Ha({family:"geo",logLabel:"geo customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:t.onLayoutError,run:()=>t.customLayout(o)});if("failure"===n.kind)return this.lastCustomLayoutFailure=n.diagnostic,this._customLayoutFailedThisBuild=!0,n.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[]);let a=n.result,s=a.nodes??[];if(this.customLayoutOverlays=a.overlays??null,this.lastCustomLayoutResult=a,this.lastCustomLayoutFailure=null,this._customRestyle=a.restyle,this.hasCustomRestyle=!!a.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle){for(let e of s)this._baseStyles.set(e,e.style);this.restyleScene(t.layoutSelection??null)}return qa({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:i,areas:r,points:o,lines:n,layout:a}){let s=zd(e.xAccessor,"lon"),l=zd(e.yAccessor,"lat"),c=[],u=function(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(e),d=function(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(e),h=function(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(e);if(e.graticule){let t=!0===e.graticule?{}:e.graticule,r=rk();t.step&&r.step(t.step);let o=i(r())||"";o&&c.push({type:"geoarea",pathData:o,centroid:[a.width/2,a.height/2],bounds:[[0,0],[a.width,a.height]],screenArea:0,style:{fill:"none",stroke:t.stroke||"#e0e0e0",strokeWidth:t.strokeWidth??.5,strokeDasharray:t.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(let t of r){let r=i(t);if(!r)continue;let o=i.centroid(t),n=i.bounds(t),a=i.area(t);c.push({type:"geoarea",pathData:r,centroid:o,bounds:n,screenArea:a,style:Ed(e.areaStyle,t,u),datum:t,interactive:!0})}let f=Nd(e.lineDataAccessor);for(let i of n){let r=f(i);if(!r||2>r.length)continue;let o=[];if("geo"===e.lineType){let e=Array(r.length);for(let t=0;r.length>t;t++)e[t]=[s(r[t]),l(r[t])];for(let i=0;e.length-1>i;i++){let r=e[i],n=e[i+1],a=ik(r,n)||0,s=Math.max(2,Math.ceil(a/(Math.PI/180))),l=ok(r,n);for(let e=0;s>=e;e++){if(i>0&&0===e)continue;let r=t(l(e/s));null!=r&&o.push(r)}}}else for(let e=0;r.length>e;e++){let i=r[e],n=t([s(i),l(i)]);null!=n&&o.push(n)}if(2>o.length)continue;let n=Ed(e.lineStyle,i,d),u="number"==typeof n.strokeWidth?n.strokeWidth:1;2!==r.length||2>o.length||"arc"!==e.flowStyle?2===r.length&&o.length>=2&&"offset"===e.flowStyle&&(o="geo"===e.lineType?jd(o,u):Yd(o[0],o[o.length-1],0,0,u)):o=Wd(o[0],o[o.length-1]);let h=Bd(o,a.width);if(h.length>1)for(let e of h)2>e.length||c.push({type:"line",path:e,style:{...n,_edgeFade:!0},datum:i});else c.push({type:"line",path:2>o.length&&h[0]||o,style:n,datum:i})}let 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],b="function"==typeof t.center?t.center():[0,0],x=[(b[0]??0)-m[0],(b[1]??0)-m[1]];for(let i of o){let r=s(i),o=l(i);if(null!=g&&ik([r,o],x)>g)continue;let n=t([r,o]);if(!n)continue;let a=e.pointStyle?e.pointStyle(i):{...h},u={type:"point",x:n[0],y:n[1],r:a.r||4,style:a,datum:i,pointId:p?p(i)+"":void 0};c.push(u)}return c}({config:t,projection:i,path:r,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:e})}applyCartogramTransform(e,t){let i=function(e,t,i,r){let o=e.filter(e=>"point"===e.type);if(2>o.length)return null;let n=t.strength??1,a=Number.isFinite(n)?Math.max(0,Math.min(1,n)):1,s="strip"===t.layout?"strip":"radial";if("radial"===s&&0===a)return null;let l=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,c="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=o.find(e=>e.datum&&l(e.datum)+""==t.center+"");if(!u)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;let d=et(o.map(e=>e.datum?Number(c(e.datum)):NaN).filter(e=>isFinite(e)&&e>=0),1);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--){let i=e[t];"geoarea"===i.type&&i.interactive&&e.splice(t,1)}let h="strip"===s?function(e,t,i,r,o){let n=Math.max(3,Math.min(8,.35*o.height)),a=Math.max(1,o.width-2*n),s=o.height/2,l=Yw().domain([0,r]).range([0,a]);t.x=n,t.y=s;let c=[];for(let o of e){if(o===t)continue;if(!o.datum){o.x=n,o.y=s;continue}let e=Number(i(o.datum)),a=n+(isFinite(e)&&e>=0&&r>0?l(e):0);o.x=a,o.y=s,c.push({node:o,x:a})}c.sort((e,t)=>e.x-t.x);let u=Math.max(0,Math.min(o.height/2-1,6)),d=0;for(;c.length>d;){let e=d+1;for(;c.length>e&&3>Math.abs(c[e].x-c[d].x);)e++;let t=e-d;if(t>1&&u>0)for(let e=0;t>e;e++)c[d+e].node.y=s+(e-(t-1)/2)*Math.min(2.5,2*u/Math.max(1,t-1));d=e}return{cx:n,cy:s,maxCost:r,availableRadius:a,layout:"strip"}}(o,u,c,d,i):function(e,t,i,r,o,n){let a=t.x,s=t.y,l=n.width/2,c=n.height/2,u=Math.min(n.width,n.height)/2,d=Yw().domain([0,r]).range([0,u]);for(let n of e){if(n===t||!n.datum)continue;let e=n.x,u=n.y,h=Math.atan2(u-s,e-a),f=Math.hypot(e-a,u-s),p=Number(i(n.datum)),y=isFinite(p)&&p>=0?r>0?d(p):0:f,g=l+Math.cos(h)*y,m=c+Math.sin(h)*y;n.x=e+(g-e)*o,n.y=u+(m-u)*o}return t.x=a+(l-a)*o,t.y=s+(c-s)*o,{cx:t.x,cy:t.y,maxCost:r,availableRadius:u,layout:"radial"}}(o,u,c,d,a,i),f=e.filter(e=>"line"===e.type);if(f.length>0){let e=new Map;for(let t of o)null!=t.pointId&&e.set(t.pointId+"",[t.x,t.y]);for(let i of f){let r=i.datum?.source,o=i.datum?.target;if(null!=r&&null!=o){let n=e.get(r+""),a=e.get(o+"");if(n&&a)if("fractional"===t.lineMode&&i.path.length>2){let e=i.path[0],t=i.path[i.path.length-1],r=[n[0]-e[0],n[1]-e[1]],o=[a[0]-t[0],a[1]-t[1]],s=[0];for(let e=1;i.path.length>e;e++)s.push(s[e-1]+Math.hypot(i.path[e][0]-i.path[e-1][0],i.path[e][1]-i.path[e-1][1]));let l=s[s.length-1];i.path=i.path.map((e,t)=>{let n=l>0?s[t]/l:t/(i.path.length-1);return[e[0]+r[0]*(1-n)+o[0]*n,e[1]+r[1]*(1-n)+o[1]*n]})}else i.path=[n,a]}}}return h}(this.scene,e,t,this.areas.length);i&&(this.cartogramLayout=i)}applyDecay(){let e=this.config.decay;if(!e||!this.pointBuffer)return;let t=this.pointBuffer.size;if(0===t)return;let i=this.scene.filter(e=>"point"===e.type);for(let r=0;i.length>r;r++){let o=za(e,r,t);i[r]._decayOpacity=o,i[r].style={...i[r].style,opacity:o}}}applyPulse(e=this.currentTime()){let t=this.config.pulse;if(!t||!this.timestampBuffer)return!1;let i=this.scene.filter(e=>"point"===e.type),r=this.timestampBuffer.toArray(),o=t.color||"rgba(255,255,255,0.6)",n=t.glowRadius??4,a=!1;for(let s=0;i.length>s&&r.length>s;s++){let l=Ea(t,r[s],e);a=Ba(i[s],l,o,n)||a}return a}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&Wa(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(e){let t=this.config.transition?.duration??300;if(0>=t)return;let i=new Map;for(let t of e)"point"===t.type&&t.pointId&&i.set(t.pointId,[t.x,t.y]);let r=this.scene.filter(e=>"point"===e.type),o=!1;for(let e of r)if(e.pointId){let t=i.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(let e of r)e.pointId&&!i.has(e.pointId)&&(e._targetOpacity=e.style?.opacity??e.style?.fillOpacity??1,e.style={...e.style,opacity:0},o=!0);o&&(this.activeTransition={startTime:this.currentTime(),duration:t})}cancelIntroAnimation(){this.activeTransition=null;for(let e of this.scene)"point"===e.type&&(null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0),null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0))}advanceTransition(e){if(!this.activeTransition)return!1;let t=Oa(e,this.activeTransition),i=Ca(t),r=this.scene.filter(e=>"point"===e.type);for(let e of r){if(null!=e._targetX&&null!=e._targetY){let t=e.y;e.x=Fa(e.x,e._targetX,i),e.y=Fa(t,e._targetY,i)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*i})}if(t>=1){for(let 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}};nk.QUADTREE_THRESHOLD=500;var ak=nk;xs(ak);import*as sk from"react";import{jsx as lk,jsxs as ck}from"react/jsx-runtime";import{jsx as uk,jsxs as dk}from"react/jsx-runtime";import{Fragment as hk,jsx as fk,jsxs as pk}from"react/jsx-runtime";import*as yk from"react-dom/server";var gk={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};import{jsx as mk,jsxs as bk}from"react/jsx-runtime";var xk={top:0,right:0,bottom:0,left:0};import{jsx as vk}from"react/jsx-runtime";import{scaleLinear as wk}from"d3-scale";import{jsx as kk,jsxs as Ak}from"react/jsx-runtime";var Sk={top:0,right:0,bottom:0,left:0};import*as Mk from"react-dom/server";import{jsx as _k,jsxs as $k}from"react/jsx-runtime";var Pk={tile:{width:280,height:184,padding:16,labelSize:13,captionSize:11,valueSize:40,detailSize:13,align:"start",border:!0,showHeader:!0,showDetail:!0},presentation:{width:540,height:320,padding:32,labelSize:18,captionSize:14,valueSize:96,detailSize:18,align:"center",border:!0,showHeader:!0,showDetail:!0},inline:{width:240,height:64,padding:8,labelSize:0,captionSize:0,valueSize:28,detailSize:13,align:"start",border:!1,showHeader:!1,showDetail:!0},thumbnail:{width:96,height:56,padding:6,labelSize:0,captionSize:0,valueSize:22,detailSize:0,align:"center",border:!1,showHeader:!1,showDetail:!1}},Rk={BigNumber:function(e,t){let i="presentation"===e.mode||"inline"===e.mode||"thumbnail"===e.mode?e.mode:"tile",r=Pk[i],o=lh(e.width,r.width),n=lh(e.height,r.height),a="number"==typeof e.padding&&Number.isFinite(e.padding)?Math.max(0,e.padding):r.padding,s="center"===e.align||"end"===e.align||"start"===e.align?e.align:r.align,l="center"===s?"middle":"end"===s?"end":"start",c="center"===s?o/2:"end"===s?o-a:a,u=Ke(e.theme),d="number"==typeof e.value&&Number.isFinite(e.value)?e.value:void 0,h=function(e,t={}){if("function"==typeof e)return e;let i=t.locale??"en-US";if("currency"===e){let e=t.precision??2,r=new Intl.NumberFormat(i,{style:"currency",currency:t.currency??"USD",maximumFractionDigits:e,minimumFractionDigits:e});return e=>r.format(e)}if("percent"===e){let e=new Intl.NumberFormat(i,{style:"percent",maximumFractionDigits:t.precision??1,minimumFractionDigits:0});return t=>e.format(t)}if("compact"===e){let e=new Intl.NumberFormat(i,{notation:"compact",maximumFractionDigits:t.precision??1,minimumFractionDigits:0});return t=>e.format(t)}if("duration"===e)return e=>function(e){if(!Number.isFinite(e))return e+"";let t=0>e?"-":"",i=Math.abs(e);if(1e3>i)return`${t}${Math.round(i)}ms`;let r=i/1e3;if(60>r)return`${t}${o=r,Math.round(100*o)/100+""}s`;var o;let n=r/60;if(60>n){let e=Math.floor(n),i=Math.round(r-60*e);return 0===i?`${t}${e}m`:`${t}${e}m ${i}s`}let a=n/60;if(24>a){let e=Math.floor(a),i=Math.round(n-60*e);return 0===i?`${t}${e}h`:`${t}${e}h ${i}m`}let s=Math.floor(a/24),l=Math.round(a-24*s);return 0===l?`${t}${s}d`:`${t}${s}d ${l}h`}(e);let r=new Intl.NumberFormat(i,{notation:t.notation??"standard",maximumFractionDigits:t.precision??0,minimumFractionDigits:0});return e=>r.format(e)}("string"==typeof e.format||"function"==typeof e.format?e.format:"number",{locale:"string"==typeof e.locale?e.locale:void 0,currency:"string"==typeof e.currency?e.currency:void 0,precision:"number"==typeof e.precision?e.precision:void 0}),f=void 0===d?"No value":(I=h(d),`${("string"==typeof e.prefix?e.prefix:void 0)??""}${I}${("string"==typeof e.suffix?e.suffix:void 0)??""}`),p=void 0===d?void 0:function(e,t){if(!t||0===t.length||!Number.isFinite(e))return null;let i=t.filter(e=>Number.isFinite(e.at)||e.at===-1/0).slice().sort((e,t)=>e.at-t.at),r=null;for(let t of i){if(t.at>e)break;r=t}return r}(d,e.thresholds),y="string"==typeof e.color?e.color:function(e,t,i){return t||("success"===e?i.colors.success??"#2ca02c":"warning"===e?i.colors.warning??"#b26a00":"danger"===e?i.colors.danger??"#d62728":"info"===e?i.colors.info??i.colors.primary:i.colors.text)}(p?.level??"neutral",p?.color,u),g="string"==typeof e.label?e.label:void 0,m="string"==typeof e.caption?e.caption:void 0,b="string"==typeof e.unit?e.unit:void 0,x=void 0===d?void 0:function(e,t,i){let r=e.comparison&&"object"==typeof e.comparison?e.comparison:void 0,o=r&&"number"==typeof r.value&&Number.isFinite(r.value)?r.value:void 0,n=("number"==typeof e.delta&&Number.isFinite(e.delta)?e.delta:void 0)??(void 0===o?void 0:t-o);if(void 0===n)return;let a=function(e,t){return Number.isFinite(e)?0===e?t(0):`${e>0?"+":"−"}${t(Math.abs(e))}`:""}(n,i);return`${a}${r&&"string"==typeof r.label?" "+r.label:""}`}(e,d,h),v=void 0===d?void 0:function(e,t,i){let r=e.target&&"object"==typeof e.target?e.target:void 0;if(!r||"number"!=typeof r.value||!Number.isFinite(r.value))return;let o="string"==typeof r.label?" "+r.label:"";return 0===r.value?`target ${i(r.value)}${o}`:`${new Intl.NumberFormat("string"==typeof e.locale?e.locale:"en-US",{style:"percent",maximumFractionDigits:0}).format(t/r.value)} of ${i(r.value)}${o}`}(e,d,h),w=[x,v,p?.label].filter(Boolean).join(" · "),k="string"==typeof e.description&&e.description||[g,f,b,w].filter(Boolean).join(", "),A="string"==typeof e.background?e.background:u.colors.surface??u.colors.background,S="string"==typeof e.borderColor?e.borderColor:u.colors.border,M=a+r.labelSize,_=M+r.captionSize+4,$="presentation"===i?n/2+.32*r.valueSize:"thumbnail"===i?n/2+.34*r.valueSize:Math.min(n-a-(w?26:4),(r.showHeader&&(g||m)?m?_+10:M+14:a)+r.valueSize),P=c+("start"===l?Math.max(r.valueSize,f.length*r.valueSize*.55):0),R=Mk.renderToStaticMarkup($k("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:n,viewBox:`0 0 ${o} ${n}`,role:"img","aria-label":k,"data-semiotic-component":"BigNumber",children:[_k("title",{children:g??f}),"string"==typeof e.description&&_k("desc",{children:e.description}),_k("rect",{x:r.border?.5:0,y:r.border?.5:0,width:r.border?o-1:o,height:r.border?n-1:n,rx:r.border?8:0,fill:A,stroke:r.border?S:"none"}),r.showHeader&&g&&_k("text",{x:c,y:M,textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.labelSize,fontWeight:600,fill:u.colors.text,children:g}),r.showHeader&&m&&_k("text",{x:c,y:_,textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.captionSize,fill:u.colors.textSecondary,children:m}),_k("text",{x:c,y:$,textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.valueSize,fontWeight:600,fontVariant:"tabular-nums",fill:void 0===d?u.colors.textSecondary:y,"data-mark-type":"value",children:f}),b&&void 0!==d&&"start"===l&&_k("text",{x:P+6,y:$,textAnchor:"start",fontFamily:u.typography.fontFamily,fontSize:Math.max(11,Math.round(.32*r.valueSize)),fontWeight:500,fill:u.colors.textSecondary,children:b}),r.showDetail&&w&&_k("text",{x:c,y:Math.min(n-a,$+r.detailSize+10),textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.detailSize,fill:u.colors.textSecondary,children:w})]}));var I;return t&&(t.evidence=ul({frameType:"value",width:o,height:n,marks:void 0===d?[]:[{type:"value"}],title:g,description:k})),R}};import*as Ik from"react-dom/server";import{jsx as Lk,jsxs as Tk}from"react/jsx-runtime";import{Fragment as Ck,jsx as Ok}from"react/jsx-runtime";var Fk=new Set(["d","transform","points","viewBox","x","y","x1","x2","y1","y2","cx","cy","r","rx","ry","width","height","dx","dy","offset","startOffset","stroke-width","stroke-opacity","stroke-dasharray","stroke-dashoffset","fill-opacity","opacity","font-size","letter-spacing"]),Dk=/-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?/gi,zk=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","hoverRadius","scalePadding","sizeRange","innerRadius","centerContent","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","svgAnnotationRules","barColors","legend","legendLayout","autoPlaceAnnotations"],Nk=["width","height","showAxes","showGrid","enableHover","showLegend","showLabels","showCategoryTicks","orientation","title","description","summary","accessibleTable","xLabel","yLabel","categoryLabel","valueLabel","linkedHover","mobileInteraction","mobileSemantics","responsiveRules"];import*as Ek from"react-dom/server";import{Fragment as Bk,jsx as Wk,jsxs as jk}from"react/jsx-runtime";al();export{kh as generateFrameSVGs,Ah as generateFrameSequence,$h as generatePhysicsFrameSVGs,bh as renderChart,xh as renderChartWithEvidence,wh as renderDashboard,ph as renderGeoToStaticSVG,fh as renderNetworkToStaticSVG,hh as renderOrdinalToStaticSVG,uh as renderToStaticSVG,dh as renderXYToStaticSVG,Ke as resolveTheme,gh as serializeSvgPrecision,Ze as themeStyles};
|
|
1
|
+
function e(e){let t=e?.find(e=>"bottom"===e.orient),i=e?.find(e=>"top"===e.orient),r=e?.find(e=>"left"===e.orient),o=e?.find(e=>"right"===e.orient);return{bottomAxis:t,topAxis:i,leftAxis:r,rightAxis:o,xAxis:t??i,yAxis:r??o,xOrient:t||!i?"bottom":"top",yOrient:r||!o?"left":"right"}}function t(e){let t=6;for(let i=1;e.length>i;i++){let r=Math.abs(e[i]-e[i-1]);r>0&&Number.isFinite(r)&&(t=Math.max(t,Math.ceil(Math.log10(Math.max(Math.abs(e[i]),Math.abs(e[i-1]))/r))+1))}let i=Math.min(17,t);return e=>Number.isInteger(e)?e+"":Number(e.toPrecision(i))+""}function i(...e){let t;for(let i of e)i&&(t=r(t)&&r(i)?{legendGroups:[...t.legendGroups,...i.legendGroups],legendDistance:i.legendDistance??t.legendDistance}:i);return t}function r(e){return"object"==typeof e&&null!==e&&"legendGroups"in e&&Array.isArray(e.legendGroups)}function o(e){return"object"==typeof e&&null!==e&&"gradient"in e}function n(e){return"string"==typeof e&&e.length>0}function a(e,t,i=!1){let r=i?t?58:34:t?36:0;return r>e.top?{...e,top:r}:e}function s(e,t){return a(e,n(t))}function l(e,t,i,r,o=8){let n=r,a="left"===r?"right":"right"===r?"left":"top"===r?"bottom":"top",s=Math.max(t[n],Math.max(0,("left"===r||"right"===r?i[0]:i[1])-o)-e[a]);e[n]>s&&(e[n]=s)}function c(e){return Math.ceil(7*e.length)}function u(e,i){if(r(e)){let t=v(i),r=100;for(let i of e.legendGroups){i.label&&(r=Math.max(r,c(i.label)));for(let e of i.items)r=Math.max(r,t.swatchSize+t.labelGap+c(e.label))}return r}if(o(e)){let{gradient:i}=e,r=i.format||t(i.domain),o=Math.max(c(r(i.domain[0])),c(r(i.domain[1]))),n=i.label?c(i.label):0;return Math.max(100,19+o,n)}return 100}function d(e){return(r(e)||o(e))&&Number.isFinite(e.legendDistance)?Math.max(0,e.legendDistance):10}function h(e,t){return null!=e?.sideGutter?Math.max(0,e.sideGutter):t?.hasAxis?t.hasAxisLabel?ep:Jh:0}function p(e){return Math.max(0,e?.edgeGutter??3)}function f(e,t){return null!=t?.axisGutter?Math.max(0,t.axisGutter):e?.hasAxis?e.hasAxisLabel?e.rotatedTicks?64:46:22:0}function y(t){let{bottomAxis:i,topAxis:r,leftAxis:o,rightAxis:n}=e(t.axes),a=!(r&&!i||!1===i?.visible),s=!!r&&!i&&!1!==r.visible,l=!(n&&!o||!1===o?.visible),c=!!n&&!1!==n.visible,u=!1!==t.showAxes;return{hasAxis:u&&a,hasAxisLabel:u&&a&&!!(i?.label??t.xLabel),rotatedTicks:u&&a&&(t.rotatedTicks??!!i?.autoRotate),topAxis:s?{hasAxis:u,hasAxisLabel:u&&!!(r?.label??t.xLabel),rotatedTicks:u&&(t.rotatedTicks??!!r?.autoRotate)}:void 0,leftAxis:l?{hasAxis:u,hasAxisLabel:u&&!!(o?.label??t.yLabel)}:void 0,rightAxis:c?{hasAxis:u,hasAxisLabel:u&&!!(n?.label??t.yLabelRight??t.yLabel)}:void 0}}function g(e,t,i){if(o(e))return e.gradient.label?46:26;if(!r(e))return 20;let n=v(i),a=Math.max(1,i?.maxWidth??t),s=n.rowHeight;for(let t of e.legendGroups){let e=0,i=0;for(let r of t.items){let t=n.swatchSize+n.labelGap+c(r.label),o=0===i?t:i+n.itemGap+t;i>0&&o>a?(e+=1,i=t):i=o}t.items.length>0&&(e+=1),s=Math.max(s,e*n.rowHeight,t.label?c(t.label):0)}return s+(e.legendGroups.length>1?16:0)}function m(e,t,i){return u(e,t)+d(e)+h(t,i)+p(t)}function x(e,t){let{legend:i}=t;if(!i)return;let r=t.position??"right",o=g(i,Math.max(1,t.size[0]-e.left-e.right),t.legendLayout)+d(i)+f("bottom"===r?t.axisChrome:"top"===r?t.axisChrome?.topAxis:void 0,t.legendLayout)+("top"===r&&t.hasTitle?24:0),n=Math.max(t.minimumMargin??0,"top"===r?t.hasTitle?58:34:0);"right"===r?e.right=Math.max(e.right,n,m(i,t.legendLayout,t.axisChrome?.rightAxis)):"left"===r?e.left=Math.max(e.left,n,m(i,t.legendLayout,t.axisChrome?.leftAxis)):"top"===r?e.top=Math.max(e.top,n,o):e.bottom=Math.max(e.bottom,n,o)}function b(e,t){let i=t.position??"right",r="top"===i||"bottom"===i,o=Math.max(0,t.totalWidth-t.margin.left-t.margin.right),n=Math.max(1,r?t.legendLayout?.maxWidth??o:t.reservedWidth??u(e,t.legendLayout)),a=d(e),s=h(t.legendLayout,"left"===i?t.axisChrome?.leftAxis:t.axisChrome?.rightAxis),l=p(t.legendLayout),c=g(e,o,t.legendLayout),y=f(t.axisChrome,t.legendLayout),m=f(t.axisChrome?.topAxis,t.legendLayout);if("left"===i)return{x:Math.max(l,t.margin.left-s-n-a),y:t.margin.top,width:n,height:c};if("top"===i)return{x:t.margin.left,y:t.margin.top-m-a-c,width:n,height:c};if("bottom"===i){let e=t.totalHeight-t.margin.bottom;return{x:t.margin.left,y:Math.max(e+a,Math.min(e+y+a,t.totalHeight-c)),width:n,height:c}}return{x:Math.min(t.totalWidth-n-l,t.totalWidth-t.margin.right+s+a),y:t.margin.top,width:n,height:c}}function v(e){let t=Math.max(1,e?.swatchSize??16),i=Math.max(t,e?.rowHeight??22);return{swatchSize:t,labelGap:Math.max(0,e?.labelGap??6),itemGap:Math.max(0,e?.itemGap??10),rowHeight:i,align:"left"===e?.align?"start":"right"===e?.align?"end":e?.align??"start",maxWidth:e?.maxWidth}}function w(e,t){let i=24;return e.map(({hasLabel:e,itemCount:r})=>{i+=5;let o,n=i;i+=8,e&&(i+=16,o=i,i+=8);let a=i;return i+=r*t+8,{lineY:n,labelY:o,itemsY:a,endY:i}})}function k(e,t,i=!1){let r={...e};for(let e of t??[])!1===e.visible&&("top"!==e.orient||!i)&&(r[e.orient]=0);return r}function A(e){let t=0;for(;e.length>t;){let i=/^\s+/.exec(e.slice(t));i&&(t+=i[0].length);let r=e.startsWith("\x3c!--",t)?"--\x3e":e.startsWith("<?",t)?"?>":void 0;if(r){let i=e.indexOf(r,t+2);if(0>i)return;t=i+r.length;continue}if(/^<!DOCTYPE\s/i.test(e.slice(t))){let i="",r=0,o=t+9;for(;e.length>o;o+=1){let t=e[o];if(i)t===i&&(i="");else if(e.startsWith("\x3c!--",o)){let t=e.indexOf("--\x3e",o+4);if(0>t)return;o=t+2}else if('"'===t||"'"===t)i=t;else if("["===t)r+=1;else if("]"===t)r-=1;else if(">"===t&&0===r)break}if(o===e.length)return;t=o+1;continue}break}let i=/^<((?:[A-Za-z_][\w.-]*:)?svg)(?=[\s/>])((?:[^<>"']|"[^"]*"|'[^']*')*)>/i.exec(e.slice(t));if(!i)return;let r=i[2].endsWith("/"),o=r?i[2].slice(0,-1):i[2];return o.replace(tp,"").trim()?void 0:{start:t,end:t+i[0].length,name:i[1],attributes:o,selfClosing:r}}function S(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").replace(/\t/g,"	").replace(/\n/g," ").replace(/\r/g," ")}function M(e){return e.replace(/\r\n|[\t\r\n]/g," ").replace(/&(amp|quot|apos|lt|gt|#\d+|#x[\da-fA-F]+);/g,(e,t)=>{if(!t.startsWith("#"))return{amp:"&",quot:'"',apos:"'",lt:"<",gt:">"}[t];let i=t.startsWith("#x")?parseInt(t.slice(2),16):Number(t.slice(1));return i>0&&1114111>=i?String.fromCodePoint(i):e})}function $(e,t){for(let i of e.attributes.matchAll(tp))if(i[1]===t)return M(i[2]??i[3])}function _(e,t){let i=A(e);if(!i)return t;let r=e=>{let r=$(i,e),o=r&&/^[0-9]+(?:\.[0-9]+)?$/.test(r)?Number(r):NaN;return Number.isFinite(o)&&o>0?o:t[e]};return{width:r("width"),height:r("height")}}function P(e,t){let i=A(e);return i?function(e,t){let i=A(e);if(!i)return e;let r=new Map(Object.entries(t)),o=i.attributes.replace(tp,(e,t)=>{let i=r.get(t);return void 0===i?e:(r.delete(t),` ${t}="${S(i)}"`)});for(let[e,t]of r)o+=` ${e}="${S(t)}"`;return`${e.slice(0,i.start)}<${i.name}${o}${i.selfClosing?"/":""}>${e.slice(i.end)}`}(e,{width:"100%",height:"100%",...void 0===$(i,"viewBox")?{viewBox:`0 0 ${t.width} ${t.height}`}:{},...void 0===$(i,"preserveAspectRatio")?{preserveAspectRatio:"xMidYMid meet"}:{}}):e}function I(e){return null==e?"null":Array.isArray(e)?`[${e.map(I).join(",")}]`:e instanceof Date?JSON.stringify(e):"object"==typeof e?`{${Object.entries(e).filter(([,e])=>void 0!==e).sort(([e],[t])=>t>e?-1:e>t?1:0).map(([e,t])=>`${JSON.stringify(e)}:${I(t)}`).join(",")}}`:JSON.stringify(e)}function R(e){let t=[...op],i=Array.from((new TextEncoder).encode(e)),r=8*i.length;for(i.push(128);i.length%64!=56;)i.push(0);let o=Math.floor(r/4294967296),n=r>>>0;i.push(o>>>24&255,o>>>16&255,o>>>8&255,255&o,n>>>24&255,n>>>16&255,n>>>8&255,255&n);let a=[];for(let e=0;i.length>e;e+=4)a.push((i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3])>>>0);for(let e=0;a.length>e;e+=16){let i=[...a.slice(e,e+16)];for(let e=16;64>e;e+=1){let t=ip(i[e-15],7)^ip(i[e-15],18)^i[e-15]>>>3,r=ip(i[e-2],17)^ip(i[e-2],19)^i[e-2]>>>10;i[e]=i[e-16]+t+i[e-7]+r>>>0}let[r,o,n,s,l,c,u,d]=t;for(let e=0;64>e;e+=1){let t=d+(ip(l,6)^ip(l,11)^ip(l,25))+(l&c^~l&u)+np[e]+i[e]>>>0,a=r&o^r&n^o&n;d=u,u=c,c=l,l=s+t>>>0,s=n,n=o,o=r,r=t+((ip(r,2)^ip(r,13)^ip(r,22))+a>>>0)>>>0}let h=[r,o,n,s,l,c,u,d];for(let e=0;8>e;e+=1)t[e]=t[e]+h[e]>>>0}return t.map(e=>e.toString(16).padStart(8,"0")).join("")}function L(e,t){return`${e}[Symbol(${t.description??""})]`}function C(e,t){if(!/^(0|[1-9][0-9]*)$/.test(e))return!1;let i=Number(e);return Number.isSafeInteger(i)&&i>=0&&t>i}function T(e,t){return"number"==typeof t?`${e}[${t}]`:e?`${e}.${t}`:t}function O(e){return e.sort((e,t)=>{let i=JSON.stringify(e),r=JSON.stringify(t);return r>i?-1:i>r?1:0})}function F(e,t,i){if(null===e)return null;if(e instanceof Date){let r=e.getTime();return Number.isFinite(r)?{$type:"date",value:e.toISOString()}:void i.excluded.push(t)}switch(typeof e){case"string":case"boolean":return e;case"number":return Number.isNaN(e)?{$type:"number",value:"NaN"}:e===1/0?{$type:"number",value:"Infinity"}:e===-1/0?{$type:"number",value:"-Infinity"}:Object.is(e,-0)?{$type:"number",value:"-0"}:e;case"bigint":return{$type:"bigint",value:""+e};case"undefined":case"function":case"symbol":return void i.excluded.push(t);case"object":{let r=e;if(i.ancestors.has(r))return void i.excluded.push(t);i.ancestors.add(r);try{if(Array.isArray(e)){for(let r of Reflect.ownKeys(e))"length"===r||"string"==typeof r&&C(r,e.length)||i.excluded.push("symbol"==typeof r?L(t,r):T(t,r));return Array.from({length:e.length},(r,o)=>{let n=T(t,o),a=Object.getOwnPropertyDescriptor(e,o+"");if(!a||!("value"in a)||!a.enumerable)return i.excluded.push(n),null;let s=F(a.value,n,i);return void 0===s?null:s})}let r={},o=Object.getPrototypeOf(e);if(o!==Object.prototype&&null!==o)return void i.excluded.push(t);let n=[];for(let r of Reflect.ownKeys(e)){if("symbol"==typeof r){i.excluded.push(L(t,r));continue}let o=Object.getOwnPropertyDescriptor(e,r);o&&"value"in o&&o.enumerable?n.push(r):i.excluded.push(T(t,r))}for(let o of n.sort()){let n=Object.getOwnPropertyDescriptor(e,o),a=F(n&&"value"in n?n.value:void 0,T(t,o),i);void 0!==a&&Object.defineProperty(r,o,{value:a,enumerable:!0,configurable:!0,writable:!0})}return r}finally{i.ancestors.delete(r)}}default:return void i.excluded.push(t)}}function D(e,t=new Set){if(null===e)return["null"];if(e instanceof Date)return Number.isFinite(e.getTime())?["date",e.toISOString()]:["excluded"];switch(typeof e){case"string":return["string",e];case"boolean":return["boolean",e];case"number":return["number",Number.isNaN(e)?"NaN":e===1/0?"Infinity":e===-1/0?"-Infinity":Object.is(e,-0)?"-0":e+""];case"bigint":return["bigint",""+e];case"undefined":case"function":case"symbol":return["excluded"];case"object":if(t.has(e))return["excluded"];t.add(e);try{let i=i=>{let r="symbol"==typeof i?["symbol-key",i.description??""]:["string-key",i],o=Object.getOwnPropertyDescriptor(e,i);return o?"value"in o?[r,"data",!!o.enumerable,D(o.value,t)]:[r,"accessor",!!o.enumerable,!!o.get,!!o.set]:[r,"missing"]};if(Array.isArray(e))return["array",Array.from({length:e.length},(t,r)=>{let o=r+"";return Object.prototype.hasOwnProperty.call(e,o)?i(o):["hole"]}),O(Reflect.ownKeys(e).filter(t=>"length"!==t&&!("string"==typeof t&&C(t,e.length))).map(i))];let r=Object.getPrototypeOf(e);return[r!==Object.prototype&&null!==r?"non-json-object":"object",O(Reflect.ownKeys(e).map(i))]}finally{t.delete(e)}default:return["excluded"]}}function E(e){let t={excluded:[],ancestors:new Set},i=F(e,"$",t)??null;return{value:i,text:JSON.stringify(i),excludedPaths:t.excluded}}function N(e){let t=E(e),i=R(JSON.stringify(["semiotic-value-fingerprint","v2",D(e)]));return{...t,algorithm:"sha256",digest:i,fingerprint:"sha256:"+i}}function z(e,t){return"number"==typeof t?`${e}[${t}]`:`${e}.${t}`}function B(e,t){return`${e}[Symbol(${t.description??""})]`}function j(e,t){if(!/^(0|[1-9][0-9]*)$/.test(e))return!1;let i=Number(e);return Number.isSafeInteger(i)&&i>=0&&t>i}function W(e,t){try{return Object.getOwnPropertyDescriptor(e,t)}catch{return}}function Y(e,t,i,r){let o=W(e,t);return o&&"value"in o&&o.enumerable?q(o.value,i,r):[i]}function q(e,t="$",i=new Set){if(null===e||"string"==typeof e||"boolean"==typeof e)return[];if("number"==typeof e)return Number.isFinite(e)&&!Object.is(e,-0)?[]:[t];if("object"!=typeof e)return[t];if(i.has(e))return[t];let r,o,n;try{n=Array.isArray(e),r=Object.getPrototypeOf(e),o=Reflect.ownKeys(e)}catch{return[t]}if(r!==(n?Array.prototype:Object.prototype)&&null!==r)return[t];i.add(e);let a=[];try{if(n){let r=W(e,"length")?.value;if(!Number.isSafeInteger(r)||0>r)return[z(t,"length")];for(let e of o)"length"===e||"string"==typeof e&&j(e,r)||a.push("symbol"==typeof e?B(t,e):z(t,e));for(let o=0;r>o;o+=1)a.push(...Y(e,o+"",z(t,o),i))}else for(let r of o)"symbol"!=typeof r?a.push(...Y(e,r,z(t,r),i)):a.push(B(t,r));return a}catch{return[t]}finally{i.delete(e)}}function X(e,t,i,r){Z(e,Object.keys(t),i,r);for(let[o,n]of Object.entries(t))n.values?(n.required||void 0!==e[o])&&J(e,o,i,n.values,r):n.required?Q(e,o,i,r):oe(e,o,i,r)}function G(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function V(e,t,i,r){void 0!==e[t]&&("number"!=typeof e[t]||!Number.isFinite(e[t]))&&r.push({path:`${i}.${t}`,message:"Expected a finite number."})}function H(e,t,i,r){void 0!==e[t]&&"boolean"!=typeof e[t]&&r.push({path:`${i}.${t}`,message:"Expected a boolean."})}function U(e){return null===e||"string"==typeof e||"boolean"==typeof e||("number"==typeof e?Number.isFinite(e):Array.isArray(e)?e.every(U):G(e)&&Object.values(e).every(U))}function K(e,t,i,r){void 0!==e[t]&&(!G(e[t])||!U(e[t]))&&r.push({path:`${i}.${t}`,message:"Expected a JSON object."})}function Z(e,t,i,r){let o=new Set(t);for(let t of Object.keys(e))o.has(t)||r.push({path:`${i}.${t}`,message:"Unexpected property."})}function Q(e,t,i,r){("string"!=typeof e[t]||!e[t])&&r.push({path:`${i}.${t}`,message:"Expected a non-empty string."})}function J(e,t,i,r,o){("string"!=typeof e[t]||!r.includes(e[t]))&&o.push({path:`${i}.${t}`,message:`Expected one of: ${r.join(", ")}.`})}function ee(e,t,i,r){let o=e[t];if(void 0!==o)return G(o)?o:void r.push({path:`${i}.${t}`,message:"Expected an object."})}function te(e,t,i,r){let o=e[t];if(void 0!==o)return Array.isArray(o)?o:void r.push({path:`${i}.${t}`,message:"Expected an array."})}function ie(e,t,i){e?.some(e=>"string"!=typeof e||!e)&&i.push({path:t,message:"Expected non-empty string values."})}function re(e,t,i,r,o){void 0!==e[t]&&J(e,t,i,r,o)}function oe(e,t,i,r){void 0!==e[t]&&"string"!=typeof e[t]&&r.push({path:`${i}.${t}`,message:"Expected a string."})}function ne(e,t,i){G(e)?(Z(e,["id","name","kind"],t,i),Q(e,"kind",t,i),oe(e,"id",t,i),oe(e,"name",t,i)):i.push({path:t,message:"Expected an actor object."})}function ae(e){for(let t of Object.values(e))Object.freeze(t.suppliedBy),Object.freeze(t);return Object.freeze(e)}function se(e){try{return function(e){let t=[],i=[];if(!G(e))return{valid:!1,errors:[{path:"$",message:"Expected an object."}],warnings:i};let r=q(e);if(r.length>0)return{valid:!1,errors:r.map(e=>({path:e,message:"Expected a JSON-compatible value that survives serialization unchanged."})),warnings:i};if(Z(e,["contractVersion","artifact","purpose","claims","evidence","time","reception","form","contestability","accountability","inheritance","fieldStatus","extensions"],"$",t),"0.1"!==e.contractVersion&&t.push({path:"$.contractVersion",message:"Expected contract version 0.1."}),G(e.artifact)){Z(e.artifact,["id","kind","component","title","createdAt","configFingerprint","dataFingerprint","revision"],"$.artifact",t),Q(e.artifact,"id","$.artifact",t),J(e.artifact,"kind","$.artifact",["chart","dashboard","story","alert","agent-answer"],t);for(let i of["component","title","createdAt","configFingerprint","dataFingerprint","revision"])oe(e.artifact,i,"$.artifact",t)}else t.push({path:"$.artifact",message:"Expected an artifact identity object."});if(G(e.purpose))if(Array.isArray(e.purpose.intents)){Z(e.purpose,["intents","communicativeAct","decisionContext","stakes","allowedUses","prohibitedUses"],"$.purpose",t),e.purpose.intents.forEach((e,i)=>{(!G(e)||"string"!=typeof e.id||!e.id)&&t.push({path:`$.purpose.intents[${i}].id`,message:"Expected a non-empty intent identifier."}),G(e)&&Z(e,["id","strength","source","rationale"],`$.purpose.intents[${i}]`,t),G(e)&&void 0!==e.strength&&J(e,"strength",`$.purpose.intents[${i}]`,["primary","secondary"],t),G(e)&&(re(e,"source",`$.purpose.intents[${i}]`,["author","derived","model-proposal","import"],t),oe(e,"rationale",`$.purpose.intents[${i}]`,t))});for(let i of["allowedUses","prohibitedUses"])ie(te(e.purpose,i,"$.purpose",t),"$.purpose."+i,t);re(e.purpose,"stakes","$.purpose",["exploratory","informational","operational","high"],t),oe(e.purpose,"communicativeAct","$.purpose",t),oe(e.purpose,"decisionContext","$.purpose",t)}else t.push({path:"$.purpose.intents",message:"Expected an intent array."});else t.push({path:"$.purpose",message:"Expected a purpose object."});Array.isArray(e.claims)?e.claims.forEach((e,i)=>{if(!G(e))return void t.push({path:`$.claims[${i}]`,message:"Expected a claim object."});Z(e,["id","text","kind","status","evidenceIds","scope","uncertainty","asOf","supersedes","authoredBy","review","tags"],`$.claims[${i}]`,t),Q(e,"id",`$.claims[${i}]`,t),J(e,"kind",`$.claims[${i}]`,["description","observation","aggregation","inference","forecast","simulation","alert","recommendation","normative"],t),J(e,"status",`$.claims[${i}]`,["supported","provisional","disputed","superseded","retracted","unsupported","unknown"],t),Array.isArray(e.evidenceIds)?e.evidenceIds.some(e=>"string"!=typeof e||!e)&&t.push({path:`$.claims[${i}].evidenceIds`,message:"Expected non-empty string evidence identifiers."}):t.push({path:`$.claims[${i}].evidenceIds`,message:"Expected an evidence identifier array."}),ie(te(e,"supersedes",`$.claims[${i}]`,t),`$.claims[${i}].supersedes`,t),oe(e,"text",`$.claims[${i}]`,t),oe(e,"asOf",`$.claims[${i}]`,t),K(e,"scope",`$.claims[${i}]`,t),ie(te(e,"tags",`$.claims[${i}]`,t),`$.claims[${i}].tags`,t),void 0!==e.authoredBy&&ne(e.authoredBy,`$.claims[${i}].authoredBy`,t);let r=ee(e,"review",`$.claims[${i}]`,t);r&&(Z(r,["status","reviewer","reviewedAt","rationale"],`$.claims[${i}].review`,t),J(r,"status",`$.claims[${i}].review`,["proposed","reviewed","approved","rejected"],t),void 0!==r.reviewer&&ne(r.reviewer,`$.claims[${i}].review.reviewer`,t),oe(r,"reviewedAt",`$.claims[${i}].review`,t),oe(r,"rationale",`$.claims[${i}].review`,t));let o=ee(e,"uncertainty",`$.claims[${i}]`,t);if(o){Z(o,["kind","lower","upper","confidence","unit","description"],`$.claims[${i}].uncertainty`,t),J(o,"kind",`$.claims[${i}].uncertainty`,["interval","distribution","qualitative","unknown"],t);for(let e of["lower","upper","confidence"])V(o,e,`$.claims[${i}].uncertainty`,t);oe(o,"unit",`$.claims[${i}].uncertainty`,t),oe(o,"description",`$.claims[${i}].uncertainty`,t)}}):t.push({path:"$.claims",message:"Expected a claim array."}),Array.isArray(e.evidence)?e.evidence.forEach((e,i)=>{if(!G(e))return void t.push({path:`$.evidence[${i}]`,message:"Expected an evidence object."});Z(e,["id","role","label","source","fingerprint","dataVersion","observedAt","scope","sample","transformation","generatedClaimId","relationship"],`$.evidence[${i}]`,t),Q(e,"id",`$.evidence[${i}]`,t),J(e,"role",`$.evidence[${i}]`,["source-data","external-source","transformation","statistical-test","model-output","human-observation","policy-rule","quality-check"],t);for(let r of["label","fingerprint","dataVersion","observedAt","generatedClaimId"])oe(e,r,`$.evidence[${i}]`,t);K(e,"scope",`$.evidence[${i}]`,t);let r=ee(e,"source",`$.evidence[${i}]`,t);if(r){Z(r,["name","uri","version","retrievedAt","publisher"],`$.evidence[${i}].source`,t);for(let e of["name","uri","version","retrievedAt","publisher"])oe(r,e,`$.evidence[${i}].source`,t)}let o=ee(e,"transformation",`$.evidence[${i}]`,t);if(o){Z(o,["id","kind","description","inputEvidenceIds","parameters","assumptions","implementation","performedAt","performedBy"],`$.evidence[${i}].transformation`,t),Q(o,"id",`$.evidence[${i}].transformation`,t),J(o,"kind",`$.evidence[${i}].transformation`,["aggregation","filter","normalization","binning","join","smoothing","forecasting","simulation","other"],t);let e=te(o,"inputEvidenceIds",`$.evidence[${i}].transformation`,t);e?ie(e,`$.evidence[${i}].transformation.inputEvidenceIds`,t):t.push({path:`$.evidence[${i}].transformation.inputEvidenceIds`,message:"Expected an evidence identifier array."}),ie(te(o,"assumptions",`$.evidence[${i}].transformation`,t),`$.evidence[${i}].transformation.assumptions`,t),oe(o,"description",`$.evidence[${i}].transformation`,t),oe(o,"implementation",`$.evidence[${i}].transformation`,t),oe(o,"performedAt",`$.evidence[${i}].transformation`,t),K(o,"parameters",`$.evidence[${i}].transformation`,t),void 0!==o.performedBy&&ne(o.performedBy,`$.evidence[${i}].transformation.performedBy`,t)}let n=ee(e,"sample",`$.evidence[${i}]`,t);if(n){Z(n,["rowCount","fields","values","truncated"],`$.evidence[${i}].sample`,t),ie(te(n,"fields",`$.evidence[${i}].sample`,t),`$.evidence[${i}].sample.fields`,t);let e=te(n,"values",`$.evidence[${i}].sample`,t);e&&!function(e){return e.every(U)}(e)&&t.push({path:`$.evidence[${i}].sample.values`,message:"Expected JSON values."}),V(n,"rowCount",`$.evidence[${i}].sample`,t),H(n,"truncated",`$.evidence[${i}].sample`,t)}re(e,"relationship",`$.evidence[${i}]`,["descriptive","correlational","causal","unknown"],t)}):t.push({path:"$.evidence",message:"Expected an evidence array."}),function(e,t){if(void 0===e||G(e)){if(G(e))for(let[i,r]of Object.entries(e)){let e="$.fieldStatus."+i;if(!G(r)||"string"!=typeof r.status){t.push({path:e,message:"Expected a field state with a status."});continue}Z(r,["status","reason","suppliedBy","derived","reviewedBy"],e,t),["known","unknown","manual","not-applicable"].includes(r.status)||t.push({path:e+".status",message:"Expected one of: known, unknown, manual, not-applicable."}),void 0!==r.suppliedBy&&("string"!=typeof r.suppliedBy||!["author","system","model-proposal","import"].includes(r.suppliedBy))&&t.push({path:e+".suppliedBy",message:"Expected one of: author, system, model-proposal, import."}),oe(r,"reason",e,t),oe(r,"reviewedBy",e,t),H(r,"derived",e,t);let o=Object.prototype.hasOwnProperty.call(ap,i)?ap[i]:void 0,n="model-proposal"===r.suppliedBy,a=n&&!0===o?.modelMayPropose&&"known"!==r.status;o&&"known"===r.status&&"string"!=typeof r.suppliedBy&&t.push({path:e+".suppliedBy",message:`Known field "${i}" must identify an allowed supplier.`}),o&&"string"==typeof r.suppliedBy&&!a&&!o.suppliedBy.includes(r.suppliedBy)&&t.push({path:e+".suppliedBy",message:`Field "${i}" cannot be supplied by ${r.suppliedBy}.`}),o&&!0===r.derived&&!o.derivable&&t.push({path:e+".derived",message:`Field "${i}" cannot be marked as derived.`}),o&&n&&(!o.modelMayPropose||"known"===r.status)&&t.push({path:e+".suppliedBy",message:"known"===r.status?`A model proposal cannot finalize field "${i}" as known.`:`Field "${i}" does not accept model proposals.`}),"required"===o?.humanReview&&"known"===r.status&&("string"!=typeof r.reviewedBy||!r.reviewedBy.trim())&&t.push({path:e+".reviewedBy",message:`Known field "${i}" requires an attributable human review.`})}}else t.push({path:"$.fieldStatus",message:"Expected a field-state object."})}(e.fieldStatus,t);let o=ee(e,"time","$",t);return o&&function(e,t){let i="$.time";Z(e,[...cp,...Object.keys(up),"sources"],i,t);for(let r of cp)oe(e,r,i,t);for(let[r,o]of Object.entries(up)){let n=ee(e,r,i,t);n&&X(n,o,`${i}.${r}`,t)}te(e,"sources",i,t)?.forEach((e,r)=>{let o=`${i}.sources[${r}]`;G(e)?X(e,dp,o,t):t.push({path:o,message:"Expected a source object."})})}(o,t),function(e,t){(function(e,t){let i=ee(e,"reception","$",t);if(!i)return;Z(i,["channels","audience","strengths","risks","scaffolds","description","dataFallback","manualChecks"],"$.reception",t);let r=te(i,"channels","$.reception",t);r||t.push({path:"$.reception.channels",message:"Expected a reception-channel array."}),r?.forEach((e,i)=>{let r=`$.reception.channels[${i}]`;G(e)?(Z(e,["channel","disclosure","navigation","interactionInstructions","rawData","tokenBudget","privacyNotes"],r,t),J(e,"channel",r,["visual","screen-reader","sonified","agent","print","low-bandwidth"],t),re(e,"disclosure",r,["summary","standard","detailed"],t),re(e,"rawData",r,["deny","bounded","allow"],t),H(e,"navigation",r,t),H(e,"interactionInstructions",r,t),V(e,"tokenBudget",r,t),ie(te(e,"privacyNotes",r,t),r+".privacyNotes",t)):t.push({path:r,message:"Expected a channel object."})});for(let e of["strengths","risks","scaffolds","manualChecks"])ie(te(i,e,"$.reception",t),"$.reception."+e,t);oe(i,"audience","$.reception",t),oe(i,"description","$.reception",t),H(i,"dataFallback","$.reception",t)})(e,t),function(e,t){let i=ee(e,"form","$",t);i&&(Z(i,["chartFamily","whyThisForm","rejectedAlternatives","risks","misuse"],"$.form",t),oe(i,"chartFamily","$.form",t),oe(i,"whyThisForm","$.form",t),ie(te(i,"risks","$.form",t),"$.form.risks",t),ie(te(i,"misuse","$.form",t),"$.form.misuse",t),te(i,"rejectedAlternatives","$.form",t)?.forEach((e,i)=>{let r=`$.form.rejectedAlternatives[${i}]`;G(e)?(Z(e,["representation","reason"],r,t),Q(e,"representation",r,t),Q(e,"reason",r,t)):t.push({path:r,message:"Expected an alternative object."})}))}(e,t),function(e,t){let i=ee(e,"contestability","$",t);i&&(Z(i,["sourceRequestsAllowed","alternativeViews","challenges","corrections","editorialExceptions"],"$.contestability",t),H(i,"sourceRequestsAllowed","$.contestability",t),te(i,"challenges","$.contestability",t)?.forEach((e,i)=>{let r=`$.contestability.challenges[${i}]`;if(G(e)){Z(e,["id","claimId","status","reason","raisedBy","raisedAt","counterclaimId","resolution"],r,t),Q(e,"id",r,t),Q(e,"claimId",r,t),Q(e,"reason",r,t),J(e,"status",r,["open","accepted","declined","resolved"],t),void 0!==e.raisedBy&&ne(e.raisedBy,r+".raisedBy",t);for(let i of["raisedAt","counterclaimId","resolution"])oe(e,i,r,t)}else t.push({path:r,message:"Expected a challenge object."})}),te(i,"corrections","$.contestability",t)?.forEach((e,i)=>{let r=`$.contestability.corrections[${i}]`;if(!G(e))return void t.push({path:r,message:"Expected a correction object."});Z(e,["id","affectedClaimIds","replacementClaimIds","reason","createdAt","createdBy"],r,t),Q(e,"id",r,t),Q(e,"reason",r,t);let o=te(e,"affectedClaimIds",r,t);o||t.push({path:r+".affectedClaimIds",message:"Expected an affected-claim array."}),ie(o,r+".affectedClaimIds",t),ie(te(e,"replacementClaimIds",r,t),r+".replacementClaimIds",t),oe(e,"createdAt",r,t),void 0!==e.createdBy&&ne(e.createdBy,r+".createdBy",t)}),te(i,"alternativeViews","$.contestability",t)?.forEach((e,i)=>{let r=`$.contestability.alternativeViews[${i}]`;G(e)?(Z(e,["id","label","rationale"],r,t),Q(e,"id",r,t),Q(e,"label",r,t),oe(e,"rationale",r,t)):t.push({path:r,message:"Expected an alternative-view object."})}),te(i,"editorialExceptions","$.contestability",t)?.forEach((e,i)=>{let r=`$.contestability.editorialExceptions[${i}]`;G(e)?(Z(e,["ruleId","rationale","owner","reviewAt"],r,t),Q(e,"ruleId",r,t),Q(e,"rationale",r,t),oe(e,"owner",r,t),oe(e,"reviewAt",r,t)):t.push({path:r,message:"Expected an editorial-exception object."})}))}(e,t),function(e,t){let i=ee(e,"accountability","$",t);i&&(Z(i,["authors","generatedBy","dataSources","codeRef","reviews","actions"],"$.accountability",t),te(i,"authors","$.accountability",t)?.forEach((e,i)=>ne(e,`$.accountability.authors[${i}]`,t)),ie(te(i,"dataSources","$.accountability",t),"$.accountability.dataSources",t),oe(i,"generatedBy","$.accountability",t),oe(i,"codeRef","$.accountability",t),te(i,"reviews","$.accountability",t)?.forEach((e,i)=>{let r=`$.accountability.reviews[${i}]`;if(G(e)){Z(e,["id","status","reviewer","reviewedAt","rationale","policyId"],r,t),Q(e,"id",r,t),J(e,"status",r,["pending","approved","changes-requested","rejected"],t),void 0!==e.reviewer&&ne(e.reviewer,r+".reviewer",t);for(let i of["reviewedAt","rationale","policyId"])oe(e,i,r,t)}else t.push({path:r,message:"Expected a review object."})}),te(i,"actions","$.accountability",t)?.forEach((e,i)=>{let r=`$.accountability.actions[${i}]`;if(!G(e))return void t.push({path:r,message:"Expected an action object."});Z(e,["id","action","actor","actedAt","claimIds","artifactId","artifactRevision","policyId","status","invalidatedByClaimId"],r,t),Q(e,"id",r,t),Q(e,"action",r,t);let o=te(e,"claimIds",r,t);o||t.push({path:r+".claimIds",message:"Expected a claim identifier array."}),ie(o,r+".claimIds",t),void 0!==e.actor&&ne(e.actor,r+".actor",t);for(let i of["actedAt","artifactId","artifactRevision","policyId","invalidatedByClaimId"])oe(e,i,r,t);re(e,"status",r,["proposed","taken","reversed","invalidated"],t)}))}(e,t),function(e,t){let i=ee(e,"inheritance","$",t);if(i){Z(i,["requiredPaths","prohibitedExports","privacy","rawDataDefault","preservation","sourceArtifactIds"],"$.inheritance",t);for(let e of["requiredPaths","prohibitedExports","sourceArtifactIds"])ie(te(i,e,"$.inheritance",t),"$.inheritance."+e,t);re(i,"privacy","$.inheritance",["public","restricted","confidential","unknown"],t),re(i,"rawDataDefault","$.inheritance",["exclude","bounded","include"],t),re(i,"preservation","$.inheritance",["full-fidelity","claim-evidence-preserved","visual-only","lossy","unknown"],t)}}(e,t)}(e,t),K(e,"extensions","$",t),Array.isArray(e.claims)&&0===e.claims.length&&i.push({path:"$.claims",message:"The contract declares no claims."}),Array.isArray(e.evidence)&&0===e.evidence.length&&i.push({path:"$.evidence",message:"The contract declares no evidence."}),{valid:0===t.length,errors:t,warnings:i}}(e)}catch{return{valid:!1,errors:[{path:"$",message:"Artifact contract could not be inspected safely."}],warnings:[]}}}function le(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function ce(e,t){return hp.has(e)&&!("reading"===e&&"string"==typeof t)}function ue(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function de(e,t={}){let i=t.mobileSemantics?.interaction,r="number"==typeof i?.targetSize?i.targetSize:"number"==typeof t.mobileSemantics?.minimumHitTarget?t.mobileSemantics.minimumHitTarget:void 0,o="mobile"===t.mode||"number"==typeof t.width&&480>=t.width,n=!!i||void 0!==r,a=e&&"object"==typeof e?e:void 0;if(!1===e||!1===a?.enabled||void 0===e&&!o&&!n)return pp;let s=a??{};return{enabled:!0,tapToSelect:s.tapToSelect??!0,tapToLockTooltip:s.tapToLockTooltip??!0,clearSelection:s.clearSelection??"backgroundTap",targetSize:s.targetSize??r??44,snap:s.snap??"nearestDatum",brushHandleSize:s.brushHandleSize??44,standardControls:s.standardControls??!1}}function he(e,t,i){if(!1!==t)return e;let r={...e};return"horizontal"===i?r.left=Math.min(r.left,15):r.bottom=Math.min(r.bottom,15),r}function pe(e){return e instanceof Date?"date:"+e.getTime():`${typeof e}:${e+""}`}function fe(e,t,i,r){let o=e??t;return"function"==typeof o?o(i,r):i[o+""]}function ye(e){return"string"==typeof e?.code&&e.code.length>0&&("warning"===e.severity||"error"===e.severity)&&"string"==typeof e.message&&e.message.length>0}function ge(e,t,i){if(e.semanticDiagnostics=[],e.semanticStatus="not-assessed",e.empty)return;let r,o=function(e){return function(e){return xp.has(e)}(e)?function(e){return xp.get(e)}(e):"BumpChart"===e?yp:void 0}(t);if(o){try{let t="function"==typeof o?o(i,e):function(e){let t=new Map;(Array.isArray(e.data)?e.data:[]).forEach((i,r)=>{if(!Number.isFinite(Number(fe(e.yAccessor,"y",i,r))))return;let o=pe(fe(e.xAccessor,"x",i,r)),n=t.get(o)??new Set;n.add(fe(e.lineBy,"series",i,r)+""),t.set(o,n)});let i=Array.from(t.values(),e=>e.size).sort((e,t)=>e-t);if(0===i.length)return[];let r=Math.floor(i.length/2),o={columns:i.length,median:i.length%2?i[r]:(i[r-1]+i[r])/2,max:i[i.length-1],contestedColumns:i.filter(e=>e>=2).length},n=2>o.max;return n||2>o.contestedColumns||2>o.median?[{code:n?"BUMP_NO_RANK_COMPETITION":"BUMP_SPARSE_RANK_COMPETITION",severity:n?"error":"warning",message:n?"Every ranking column contains one series, so every trajectory remains at rank 1.":"Too few ranking columns contain competing series for reliable rank movement.",fix:"Use a lineBy field with repeated series across shared x columns, or choose a value-based chart.",metrics:{...o}}]:[]}(i);r=Array.from(t).filter(ye)}catch{return void(e.warnings.includes("SEMANTIC_VIABILITY_CHECK_FAILED")||e.warnings.push("SEMANTIC_VIABILITY_CHECK_FAILED"))}e.semanticDiagnostics=r,e.semanticStatus=r.some(e=>"error"===e.severity)?"degenerate":r.some(e=>"warning"===e.severity)?"degraded":"meaningful";for(let t of r)e.warnings.includes(t.code)||e.warnings.push(t.code)}}function me(e){return`${e.getUTCFullYear()}-${xe(e.getUTCMonth()+1)}-${xe(e.getUTCDate())}`}function xe(e){return 10>e?"0"+e:e+""}function be(e,t={}){let i=t.baseOpacity??1;return t.highlight||t.predicate?!function(e,t){if(!t)return!0;let i=Array.isArray(t)?t:[t],r=e;for(let e of i)if(null!=e.value&&r[e.field]+""!=e.value+"")return!1;return!0}(e,t.highlight)||t.predicate&&!t.predicate(e)?t.dimOpacity??.16:Math.min(1,i+(t.brighten??0)):i}function ve(e){if(0===e.length)return 0;let t=0;for(let i of e)t+=i;return t/e.length}function we(e){let t=e.fontSize??12;return null!=e.maxWidth&&e.text.length*t*.56>e.maxWidth?null:$p("text",{className:e.className,x:e.x,y:e.y,textAnchor:e.anchor??"middle",dominantBaseline:e.baseline??"middle",fontSize:t,fontWeight:e.fontWeight,fill:e.color,style:{pointerEvents:"none"},children:e.text},e.keyId)}function ke(e){if(null==e)return()=>{};let t="function"==typeof e?e:t=>t[e];return e=>Me(t(e))}function Ae(e,t){let i=ke(e),r=ke(t);return(e,t)=>{let o=r(e);return{value:o,x:i(e),y:o,category:t}}}function Se(e,t){let i=ke(t??"value"),r=null==e?void 0:"function"==typeof e?e:t=>t[e];return e=>{let t=r?r(e):void 0;return{value:i(e),category:null==t?void 0:t+""}}}function Me(e){if("number"==typeof e)return Number.isFinite(e)?e:void 0;if("string"==typeof e&&""!==e.trim()){let t=Number(e);return Number.isFinite(t)?t:void 0}}function $e(e,t,i){let r=e.when;return void 0===r||!0===r||!1!==r&&("function"==typeof r?r(t,i):function(e,t,i){let r=null!=e.axis?i[e.axis]:null!=e.field?t[e.field]:i.value;if(void 0!==e.eq&&r!==e.eq||void 0!==e.ne&&r===e.ne||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;let o=Me(r);if(void 0===o||void 0!==e.gt&&e.gt>=o||void 0!==e.gte&&e.gte>o||void 0!==e.lt&&o>=e.lt||void 0!==e.lte&&o>e.lte)return!1;if(void 0!==e.within){let[t,i]=e.within;if(t>o||o>i)return!1}if(void 0!==e.outside){let[t,i]=e.outside;if(o>=t&&i>=o)return!1}return!0}(r,t,i))}function _e(e,t,i){if(!t||0===t.length)return{};let r={};for(let o of t){if(!$e(o,e,i))continue;let t="function"==typeof o.style?o.style(e,i):o.style;t&&(r={...r,...t})}return r}function Pe(e,t,i,r=e=>e){let o=e??(()=>({}));return t&&0!==t.length?(e,n)=>{let a=r(e),s={...o(e,n)};return Object.assign(s,_e(a,t,i(a,n))),s}:o}function Ie(e,t,i,r){if(!e||0===e.length)return r;let o=Se(t,i);return(t,i)=>{let n=t&&t.data||t,a=_e(n,e,o(n)),s=r?r(t,i):void 0;return s?{...a,...s}:a}}function Re(e){let[t,i]=e,r=160>t||116>i,o=r?Math.min(12,Math.max(2,.08*t)):32,n=r?Math.min(8,Math.max(2,.12*i)):24,a=r?n:34;return{width:t,height:i,plot:{x:o,y:n,width:Math.max(1,t-2*o),height:Math.max(1,i-n-a)}}}function Le(e){let t=(e??"")+"";if(!t)return"#4e79a7";let i=["#4e79a7","#59a14f","#e15759","#f28e2b","#76b7b2","#edc948","#b07aa1","#ff9da7"],r=0;for(let e=0;t.length>e;e+=1)r=31*r+t.charCodeAt(e)>>>0;return i[r%i.length]}function Ce(e,t="#4e79a7",i){let r=i?.styleRules,o=!!r&&r.length>0,n=o?ke(i?.valueAccessor):void 0;return i=>{let a=i.datum,s=a&&e?"function"==typeof e?e(a,0):a[e]:void 0,l={fill:null==s?t:Le(s),stroke:"#111827",strokeWidth:1,opacity:.9};return o&&a&&Object.assign(l,_e(a,r,{value:n?n(a):void 0,category:null==s?void 0:s+""})),l}}function Te(e,t,i,r){return{fixedDt:1/120,maxSubsteps:8,colliders:t,observation:{chartType:i},kernel:{seed:e,gravity:{x:0,y:760},cellSize:36,collisionIterations:6,velocityDamping:.995,restitution:.08,friction:.4,sleepSpeed:8,sleepAfter:.6,...r}}}function Oe(e,t,i){return"function"==typeof i?i(e,t):e[i]}function Fe(e){if(e instanceof Date){let t=e.getTime();return Number.isFinite(t)?t:null}let t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function De(e,t,i){return Math.max(t,Math.min(i,e))}function Ee(e,t){let i=Fe(e);return null!=i&&i>0?i:t}function Ne(e){return((e??"unknown")+"").trim().replace(/[^A-Za-z0-9_-]+/g,"_")||"unknown"}function ze(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 Be(e,t,i=0){let r=new Set(e.filter(e=>null!=e.id).map(e=>e.id+"")),o=new Map;for(let n of e){let e=null==n.id?`${t}-${i++}`:n.id+"";for(;null==n.id&&r.has(e);)e=`${t}-${i++}`;r.add(e),o.set(e,null==n.id?{...n,id:e}:n)}return{seed:e,rows:Array.from(o.values()),nextId:i}}function je(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}}function We(e){let t=e.fixedPosition;Number.isFinite(t?.x)&&(e.x=e.prevX=t.x,e.vx=0),Number.isFinite(t?.y)&&(e.y=e.prevY=t.y,e.vy=0)}function Ye(e){if(!e)return;let t=Number.isFinite(e.x)?e.x:void 0,i=Number.isFinite(e.y)?e.y:void 0;return null==t&&null==i?void 0:{x:t,y:i}}function qe(e,t,i){let r,o="x"===i?"y":"x",n=Math.abs(t[i]-e[i]),a=t[o]-e[o],s=(e,t)=>"circle"===e.shape.type?e.shape.radius:("x"===t?e.shape.width:e.shape.height)/2;if("circle"===e.shape.type&&"circle"===t.shape.type){let i=e.shape.radius+t.shape.radius;r=Math.sqrt(Math.max(0,i*i-n*n))}else if("aabb"===e.shape.type&&"aabb"===t.shape.type)r=s(e,o)+s(t,o);else{let a="aabb"===e.shape.type?e:t,l=s("circle"===e.shape.type?e:t,i),c=Math.max(0,n-s(a,i));r=s(a,o)+Math.sqrt(Math.max(0,l*l-c*c))}let l=0>a?-1:1;return{nx:"x"===o?l:0,ny:"y"===o?l:0,penetration:Math.max(0,r-Math.abs(a))}}function Xe(e){return"circle"===e.type?{type:"circle",radius:e.radius}:{type:"aabb",width:e.width,height:e.height}}function Ge(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 Ve(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,...e.fixedPosition?{fixedPosition:Ye(e.fixedPosition)}:{},shape:Xe(e.shape),sleeping:e.sleeping,datum:e.datum,index:e.index,sleepTime:e.sleepTime,restitution:e.restitution,friction:e.friction}}function He(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 Ue(e){return{id:e.id,shape:Ge(e.shape),sensor:e.sensor,restitution:e.restitution,friction:e.friction,bodyFilter:He(e.bodyFilter),index:e.index}}function Ke(e,t,i){return Math.max(t,Math.min(i,e))}function Ze(e,t,i){return Math.min(e??i,t??i)}function Qe(e,t,i){return Ke(Math.max(e??i,t??i),0,1)}function Je(e){return 0>e?-1:1}function et(e){if("circle"===e.shape.type){let t=e.shape.radius;return{minX:e.x-t,minY:e.y-t,maxX:e.x+t,maxY:e.y+t}}let t=e.shape.width/2,i=e.shape.height/2;return{minX:e.x-t,minY:e.y-i,maxX:e.x+t,maxY:e.y+i}}function tt(e){let t=e.shape;if("aabb"===t.type){let e=t.width/2,i=t.height/2;return{minX:t.x-e,minY:t.y-i,maxX:t.x+e,maxY:t.y+i}}let i=(t.thickness??0)/2;return{minX:Math.min(t.x1,t.x2)-i,minY:Math.min(t.y1,t.y2)-i,maxX:Math.max(t.x1,t.x2)+i,maxY:Math.max(t.y1,t.y2)+i}}function it(e,t){return!(e.minX>t.maxX||t.minX>e.maxX||e.minY>t.maxY||t.minY>e.maxY)}function rt(e,t,i,r,o,n,a,s){let l=o-e,c=(i+a)/2-Math.abs(l);if(0>=c)return null;let u=n-t,d=(r+s)/2-Math.abs(u);return d>0?d>c?{nx:Je(l),ny:0,penetration:c}:{nx:0,ny:Je(u),penetration:d}:null}function ot(e,t,i,r,o,n,a){let s=n/2,l=a/2,c=e-Ke(e,r-s,r+s),u=t-Ke(t,o-l,o+l),d=c*c+u*u;if(d>i*i)return null;if(Ep>=d){let n=Math.abs(e-(r-s)),a=Math.abs(e-(r+s)),c=Math.abs(t-(o-l)),u=Math.abs(t-(o+l)),d=Math.min(n,a,c,u);return d===n?{nx:-1,ny:0,penetration:i+n}:d===a?{nx:1,ny:0,penetration:i+a}:d===c?{nx:0,ny:-1,penetration:i+c}:{nx:0,ny:1,penetration:i+u}}let h=Math.sqrt(d);return{nx:c/h,ny:u/h,penetration:i-h}}function nt(e,t){if("circle"===e.shape.type&&"circle"===t.shape.type)return function(e,t,i,r,o,n){let a=r-e,s=o-t,l=i+n,c=a*a+s*s;if(c>=l*l)return null;if(Ep>=c)return{nx:1,ny:0,penetration:l};let u=Math.sqrt(c);return{nx:a/u,ny:s/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 rt(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){let i=ot(e.x,e.y,e.shape.radius,t.x,t.y,t.shape.width,t.shape.height);return i?{nx:-i.nx,ny:-i.ny,penetration:i.penetration}:null}return"aabb"===e.shape.type&&"circle"===t.shape.type?ot(t.x,t.y,t.shape.radius,e.x,e.y,e.shape.width,e.shape.height):null}function at(e,t){let i=t.shape;return"aabb"===i.type?"circle"===e.shape.type?ot(e.x,e.y,e.shape.radius,i.x,i.y,i.width,i.height):rt(i.x,i.y,i.width,i.height,e.x,e.y,e.shape.width,e.shape.height):function(e,t,i,r,o,n,a,s=0){let l=n-r,c=a-o,u=l*l+c*c,d=u>Ep?Ke(((e-r)*l+(t-o)*c)/u,0,1):0,h=i+s/2,p=e-(r+l*d),f=t-(o+c*d),y=p*p+f*f;if(y>=h*h)return null;if(Ep>=y){let e=Math.sqrt(u);return e>Ep?{nx:-c/e,ny:l/e,penetration:h}:{nx:1,ny:0,penetration:h}}let g=Math.sqrt(y);return{nx:p/g,ny:f/g,penetration:h-g}}(e.x,e.y,"circle"===e.shape.type?e.shape.radius:Math.sqrt(e.shape.width*e.shape.width+e.shape.height*e.shape.height)/2,i.x1,i.y1,i.x2,i.y2,i.thickness??0)}function st(e,t){return`${e}\0${t}`}function lt(e){let t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function ct(e,t){return!!t?.some(t=>Object.is(e,t))}function ut(e,t){return function(e,t){if(!t)return!0;if("function"==typeof t)return t(e);let i=function(e,t){if(!t)return;let i=e;for(let e of t.split(".")){if(null==i||"object"!=typeof i||!Object.prototype.hasOwnProperty.call(i,e))return;i=i[e]}return i}(e,t.property);return!("equals"in t&&!Object.is(i,t.equals)||"notEquals"in t&&Object.is(i,t.notEquals)||t.oneOf&&!ct(i,t.oneOf)||t.notOneOf&&ct(i,t.notOneOf))}(t,e.bodyFilter)}function dt(e,t={}){return e?"function"==typeof e?e(t):(e.init(t),e):function(e={}){return new Bp(e)}(t)}function ht(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);let i=t-e.mean;e.mean+=i/e.count,e.m2+=i*(t-e.mean)}function pt(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 ft(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 yt(e,t){if(null!=e[t])return e[t];let i=e.datum;return i&&"object"==typeof i?i[t]:void 0}function gt(e,t,i){return"function"==typeof e?e(t,i):"string"==typeof e?yt(t,e):void 0}function mt(e){if(null==e)return;let t=e+"";return t.trim()?t:void 0}function xt(e){let t=pt(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:pt(e.x),y:pt(e.y),value:t}}function bt(e){let t=Number(e);if(Number.isFinite(t)&&t>0)return Math.floor(t)}function vt(e={},t=qp){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 wt(e){return{...e,shape:{...e.shape},...e.fixedPosition?{fixedPosition:{...e.fixedPosition}}:{},datum:e.datum,springs:e.springs?.map(e=>({...e,target:{...e.target}}))}}function kt(e){if(e instanceof Date){let t=e.getTime();return Number.isFinite(t)?t:void 0}let t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:void 0}function At(e,t){if(null!=e[t])return e[t];let i=e.datum;return i&&"object"==typeof i?i[t]:void 0}function St(e){return{...wt(e),sequence:e.sequence,spawnAt:e.spawnAt}}function Mt(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 $t(e){return!1!==e&&{...e}}function _t(e,t){return e.spawnAt===t.spawnAt?e.sequence-t.sequence:e.spawnAt-t.spawnAt}function Pt(e){return{...e,gravity:{...e.gravity}}}function It(e,t,i,r){if("circle"===e.shape.type){let o=e.x-t,n=e.y-i,a=e.shape.radius+r,s=o*o+n*n;return s>a*a?null:s}let o=Math.max(Math.abs(t-e.x)-e.shape.width/2,0),n=Math.max(Math.abs(i-e.y)-e.shape.height/2,0),a=o*o+n*n;return a>r*r?null:a}function Rt(e){let t=e.indexOf("\0");return{sensorId:e.slice(0,t),bodyId:e.slice(t+1)}}function Lt(e,t={}){let{idPrefix:i="plot",includeFloor:r=!0,includeCeiling:o=!1,includeLeftWall:n=!0,includeRightWall:a=!0,wallThickness:s=20,floorThickness:l=s}=t,c=[],u=e.x+e.width/2,d=e.y+e.height/2;return r&&c.push({id:i+"-floor",shape:{type:"aabb",x:u,y:e.y+e.height+l/2,width:e.width+2*s,height:l}}),o&&c.push({id:i+"-ceiling",shape:{type:"aabb",x:u,y:e.y-l/2,width:e.width+2*s,height:l}}),n&&c.push({id:i+"-left-wall",shape:{type:"aabb",x:e.x-s/2,y:d,width:s,height:e.height+2*l}}),a&&c.push({id:i+"-right-wall",shape:{type:"aabb",x:e.x+e.width+s/2,y:d,width:s,height:e.height+2*l}}),c}function Ct(e){let{idPrefix:t="bin",count:i,domainStart:r,domainStep:o,xScale:n,yTop:a,yBottom:s,wallThickness:l=4,includeBoundaryWalls:c=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=a,lidThickness:p=Math.max(2,l)}=e,f=[],y=a+(s-a)/2,g=Math.abs(s-a),m=c?i:i-1;if(u||c)for(let e=c?0:1;m>=e;e+=1){if(!u&&e>0&&i>e)continue;let a=n(r+e*o);f.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:a,y:y,width:l,height:g}})}if(null!=d)for(let e=0;i>e;e+=1){let i=r+e*o,a=i+o;if(a>=d)continue;let s=n(i),c=n(a);f.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(s,c)+l/2,y1:h,x2:Math.max(s,c)-l/2,y2:h,thickness:p}})}return f}function Tt(e,t){let i={...e};for(let e of t)i[Xp[e]]++;return i}function Ot(e,t,i){let r=new Set(t);return{changeSet:{...e,...e.keys?{keys:[...e.keys]}:{}},changed:r,revisions:Tt(i,r)}}function Ft(e){let t="preserve",i=new Set;for(let r of e){let e=rf[r]??of;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}function Dt(e,t){return e===t||!(!e||!t||e.gravity?.x!==t.gravity?.x||e.gravity?.y!==t.gravity?.y)&&nf.every(i=>e[i]===t[i])}function Et(e,t,i,r){return e||!t?"paused":i||!r?"running":"settled"}function Nt(e,t,i,r={}){let o,n=0;for(;t>n&&!r.shouldStop?.()&&(!1===r.stopAtRest||e.queueSize()>0||!e.atRest()||r.continueWhile?.());){e.step(e.fixedDt),e.advanceTime(e.fixedDt);let t=e.drainEvents();i.events&&(i.events.push(...t),e.observeKernelEvents(t,i.observations),e.observeSensorTransitions(i.observations));let a=[];if(e.spawnDue(a,i.observations),a.length>0){i.spawned.push(...a),o=e.observeBodyBudget(i.observations);let t=e.evictOverflow(i.observations);i.evicted?.push(...t.evicted),i.sedimented?.push(...t.sedimented)}n+=1,e.refreshQuiescence(e.fixedDt,a.length),r.afterStep?.()}return{steps:n,budget:o}}function zt(e,t,i,r){let{windowPlot:o,lidSegments:n}=e,a=n[t];return i&&!a?Math.min(o.y+o.height-r,o.y+.48*o.height+2*r+4):!i&&a?Math.min(o.y+o.height-r,Math.max(a.y1,a.y2)+2*r+4):o.y+r+2}function Bt(e,t,i,r,o){let{windowPlot:n,windowCount:a,windowStart:s,windowSize:l}=r;if(i&&t>=r.closedWindowCount)return r.gutter.x+r.gutter.width/2;let c=n.width/a,u=i?n.x:n.x+t*c,d=i?n.x+n.width:u+c,h=Math.min((d-u)/2,o+(i?0:3));return Math.max(u+h,Math.min(d-h,n.x+(e-s)/l*c))}function jt(e,t,i){let r=e.width/Math.max(1,t),o=Math.max(2,2*i),n=Math.min(.7*r,Math.max(3.2*o,o+8)),a=Math.max(1,Math.floor(n/o));return{laneWidth:r,tubeWidth:n,ballDiameter:o,perRow:a,centerX:t=>e.x+(t+.5)*r,pileHeight:e=>Math.ceil(Math.max(0,e)/a)*o}}function Wt(e,t,i,r){let o=(t+i)/2,n=[];for(let a of e){let s=n.filter(e=>a.radius+e.radius+.5>Math.abs(a.x-e.x)),l=[o];for(let e of s){let t=Math.sqrt((a.radius+e.radius+.5)**2-(a.x-e.x)**2);l.push(e.y-t,e.y+t)}let c=.5>r()?-1:1;l.sort((e,t)=>Math.abs(e-o)-Math.abs(t-o)||c*(e-t));let u=l.find(e=>e-a.radius>=t&&i>=e+a.radius&&s.every(t=>(a.x-t.x)**2+(e-t.y)**2>=(a.radius+t.radius+.5)**2-1e-6));if(null==u){let r=Math.max(...e.map(e=>e.radius)),n=Math.max(0,i-t-2*r);return{positions:e.map((t,i)=>o+(1===e.length?0:i/(e.length-1)-.5)*n),overlapping:!0,entryOffset:0}}n.push({...a,y:u})}return{positions:n.map(e=>e.y),overlapping:!1,entryOffset:Math.max(0,Math.min(36,...n.map(e=>e.y-e.radius-t)))}}function Yt(e){if(Array.isArray(e)&&e.length>=2){let t=Fe(e[0]),i=Fe(e[1]);return null!=t&&null!=i?{x:t,y:i}:null}if(e&&"object"==typeof e){let t=e,i=Fe(t.x),r=Fe(t.y);return null!=i&&null!=r?{x:i,y:r}:null}return null}function qt(e){return Array.isArray(e)?e.map(Yt).filter(e=>null!=e):[]}function Xt(e,t,i){return"normalized"===i?{x:t.plot.x+e.x*t.plot.width,y:t.plot.y+e.y*t.plot.height}:{x:De(e.x,t.plot.x,t.plot.x+t.plot.width),y:De(e.y,t.plot.y,t.plot.y+t.plot.height)}}function Gt(e){let t=0;for(let i=1;e.length>i;i+=1)t+=Math.hypot(e[i].x-e[i-1].x,e[i].y-e[i-1].y);return t}function Vt(e,t){if(0===e.length)return{x:0,y:0};if(1===e.length)return{...e[0]};let i=De(t,0,1)*Gt(e),r=0;for(let t=1;e.length>t;t+=1){let o=e[t-1],n=e[t],a=Math.hypot(n.x-o.x,n.y-o.y);if(a>0){if(r+a>=i){let e=(i-r)/a;return{x:o.x+(n.x-o.x)*e,y:o.y+(n.y-o.y)*e}}r+=a}}return{...e[e.length-1]}}function Ht(e,t){let i=Vt(e,Math.max(0,t-.02)),r=Vt(e,Math.min(1,t+.02)),o=r.x-i.x,n=r.y-i.y,a=Math.hypot(o,n)||1;return{x:o/a,y:n/a}}function Ut(e,t,i){return Math.max(t,Math.min(i,e))}function Kt(e,t,i,r,o,n={}){return{id:e,friction:n.friction,restitution:n.restitution,bodyFilter:n.bodyFilter,shape:{type:"segment",x1:t,y1:i,x2:r,y2:o,thickness:n.thickness??8}}}function Zt(e){let t=e.shape??"lane",i=Math.max(1,Math.round(e.width)),r=Math.max(1,Math.round(e.height)),o=e.padX??46,n=e.padY??72,a=o,s=i-o,l=n,c=r-Math.max(24,Math.round(.45*n)),u=(l+c)/2,d=Math.max(1,c-l),h=Ut(e.pinchRatio??.18,.06,.5),p=Number(e.pinchHeightOffset??0),f=Number.isFinite(p)?p:0,y=Ut(d*h+f,.06*d,.5*d),g=y/2,m=u-g,x=u+g,b=e.idPrefix??"process",v=e.friction??.58,w=e.restitution??.18,k=e.wallThickness??8,A=e.stages;if(!A.length)throw Error("processStageLayout requires at least one stage");let S=Ut(e.centerStageIndex??Math.floor(A.length/2),0,A.length-1),M=function(e){let t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}(A),$=s-a,_=a,P=A.map((e,t)=>{let i=_,r=t===A.length-1?s:_+(e.share??1)/M*$;return _=r,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:i,x1:r,x:(i+r)/2,width:r-i,y:u,height:d}}),I=P[S],R=I.x0,L=I.x1,C=(e,i)=>{if("lane"===t)return"top"===i?l:c;if("funnel"===t){let t=Ut((e-a)/Math.max(1,s-a),0,1);return"top"===i?l+(m-l)*t:c+(x-c)*t}if(R>=e){let t=Ut((e-a)/Math.max(1,R-a),0,1);return"top"===i?l+(m-l)*t:c+(x-c)*t}if(L>=e)return"top"===i?m:x;let r=Ut((e-L)/Math.max(1,s-L),0,1);return"top"===i?m+(l-m)*r:x+(c-x)*r},T=P.map(e=>{let t=Math.min(C(e.x0,"top"),C(e.x1,"top")),i=Math.max(C(e.x0,"bottom"),C(e.x1,"bottom"));return{...e,y:(t+i)/2,height:Math.max(1,i-t)}}),O={thickness:k,friction:v,restitution:w},F=[];"lane"===t?F.push(Kt(b+"-top",a,l,s,l,O),Kt(b+"-bottom",a,c,s,c,O),Kt(b+"-left",a,l,a,c,{...O,thickness:Math.max(6,k-2)}),Kt(b+"-right",s,l,s,c,{...O,thickness:Math.max(6,k)})):"funnel"===t?F.push(Kt(b+"-top",a,l,s,m,O),Kt(b+"-bottom",a,c,s,x,O),Kt(b+"-left",a,l,a,c,{...O,thickness:Math.max(6,k-2)}),Kt(b+"-right",s,m,s,x,{...O,thickness:Math.max(6,k)})):F.push(Kt(b+"-left-top",a,l,R,m,O),Kt(b+"-left-bottom",a,c,R,x,O),Kt(b+"-center-top",R,m,L,m,O),Kt(b+"-center-bottom",R,x,L,x,O),Kt(b+"-right-top",L,m,s,l,O),Kt(b+"-right-bottom",L,x,s,c,O),Kt(b+"-left",a,l,a,c,{...O,thickness:Math.max(6,k-2)}),Kt(b+"-right",s,l,s,c,{...O,thickness:Math.max(6,k)}));let D=e.membraneDampingScale??.5,E=a,N=Math.max(1,("bowtie"===t?R:s)-E),z=(e.membranes??[]).map(e=>{let t=E+Ut(e.offset,0,1)*N,i=e.width??18+18*e.cost,r=d-16,o=u+.25*(e.wobble??0);return{...e,x:t,y:o,width:i,height:r}}),B=!1===e.includeMembraneRegions?[]:z.map(e=>function(e){let t=e.dampingScale??.5,i=e.energyScale??1,r=Ut(e.cost,0,2);return{...Qt({...e,kind:e.kind??"membrane",attributes:{primitive:"membrane",membraneCost:r,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:r*t,energyDelta:-r*i}}({id:e.id,label:e.label??e.id,description:e.description??(e.label??e.id)+" is a permeable region. It taxes energy and damps velocity while bodies overlap it.",x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??D,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:i,height:r,padX:o,padY:n,left:a,right:s,topY:l,bottomY:c,midY:u,centerLeft:R,centerRight:L,pinchHeight:y,pinchTop:m,pinchBottom:x,stages:T,membranes:z,colliders:F,regionEffects:B,boundaryY:C}}function Qt(e){return{id:e.id,label:e.label,description:e.description,kind:e.kind,shape:(t=e.x,i=e.y,r=e.width,o=e.height,{type:"aabb",x:t,y:i,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,i,r,o}function Jt(e){let t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...Qt({...e,kind:e.kind??"force-field",attributes:{primitive:"routeSurface",..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),force:t,damping:e.damping??.015}}function ei(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 ti(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function ii(e,t,i){let r=e=>e.toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(i)}`}function ri(e){let t=e.map(ti),i=t.length-1;return e=>{if(Number.isNaN(e)&&(e=0),0>=e){let[e,i,r]=t[0];return ii(e,i,r)}if(e>=1){let[e,r,o]=t[i];return ii(e,r,o)}let r=e*i,o=Math.floor(r),n=r-o,[a,s,l]=t[o],[c,u,d]=t[o+1];return ii(Math.round(a+(c-a)*n),Math.round(s+(u-s)*n),Math.round(l+(d-l)*n))}}function oi(e){return e&&Object.prototype.hasOwnProperty.call(Mf,e)?Mf[e]:pf}function ni(e,t,i=Of){if(e&&"object"==typeof e&&!Array.isArray(e)){let 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){let t=Object.prototype.hasOwnProperty.call(Tf,e)?Tf[e]:void 0;if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:i}function ai(e,t,i){if("function"==typeof t){let r=t(e);return i&&r&&"string"==typeof r&&!function(e){let t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||Nf.has(t)}(r)?i(r):r}let r=e?.[t]+"";return i?i(r):Of[Math.abs(function(e){let t=0;for(let i=0;e.length>i;i++)t=(t<<5)-t+e.charCodeAt(i),t&=t;return Math.abs(t)}(r))%Of.length]}function si(e,t){if(null==t||!Object.prototype.hasOwnProperty.call(e,t))return;let i=e[t];return"string"==typeof i&&i.length>0?i:void 0}function li(e,t,i="category10"){if(i&&"object"==typeof i&&!Array.isArray(i)){let e=i;return t=>si(e,t)??"#999"}let 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(i))return df().domain(r).range(i).unknown("#999");let n=Object.prototype.hasOwnProperty.call(Tf,i)?Tf[i]:Tf.category10;if(o&&"function"==typeof n){let e=-1/0;for(let t of r){let i=Number(t);i>e&&(e=i)}return t=>n(0===e?0:Number(t)/e)}{let e=Array.isArray(n)?n:Of;return df().domain(r).range(e).unknown("#999")}}function ci(e,t,i=[3,20],r){let o;if(o="function"==typeof t?t(e):e?.[t],!r)return o;let[n,a]=r,[s,l]=i;if(a===n)return(s+l)/2;let c=(o-n)/(a-n);return 0>c?c=0:c>1&&(c=1),s+c*(l-s)}function ui(e,t,i){return ni(e,t,i)}function di(e,t){let i=t&&"object"==typeof t&&!Array.isArray(t)?t:void 0;return 0===e.length?e=>i&&si(i,e)||"#4e79a7":t=>{if(i){let e=si(i,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 hi(e,t){let i=t.config??{},r=(t.sensors??[]).map(e=>({...e,sensor:!0})),o=[...t.colliders??[],...r],n=[...e.colliders??[],...i.colliders??[],...o];return{...e,...i,observation:{...e.observation,...i.observation},...n.length>0&&{colliders:n}}}function pi(e){let t=xi(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 fi(e,t,i,r){return i?"function"==typeof i?i(e,t):e[i]??r:r}function yi(e){return`gauntlet:${e}:core`}function gi(e,t){return`gauntlet:${e}:positive:${t}`}function mi(e,t,i){return`gauntlet:${e}:negative:${t}:${i}`}function xi(e){let t=e.height??e.floorY+36;if(e.width>=220&&t>=160)return Bf;let i=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*i))}}function bi(e){return Math.max(.12,Math.min(1,e.width/500,(e.height??e.floorY+36)/260))}function vi(e,t,i,r){let o=xi(r),n=Math.max(2,i+2),a=o.top+o.thickness/2+n,s=r.floorY-n,l=(e,t,i)=>t>i?(t+i)/2:Math.max(t,Math.min(i,e));return{x:l(e,o.left+o.thickness/2+n,r.width-o.rightInset-o.thickness/2-n),y:l(t,a,s)}}function wi(e,t,i=1){let 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)*i}}function ki(e,t,i){let r=e.activePositiveIds.reduce((e,i)=>e+(t.get(i)?.value??1),0),o=e.missingPositiveIds.length+e.poppedPositiveIds.length,n=e.negativeIds.reduce((e,t)=>e+(i.get(t)?.load??1),0);return Math.max(0,Math.min(100,75+3*r-8*n-1.2*e.delay-5*o))}function Ai(e){let t=function(e,t,i){let[r,o]=e,n=220>r||160>o,a=Math.round(.48*o),s=n?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,d=c>1?(.78*r-u)/(c-1):0,h=n?Math.max(Math.round(.12*r),.08*r+6):Math.max(Math.round(.14*r),110);return{crashY:s-(n?Math.min(i,Math.max(3,.22*o)):i),floorY:s,gates:l.map((e,t)=>({...e,id:e.id,x:e.x??Math.round(u+t*d),width:e.width??Math.max(n?8:54,Math.round(.07*r))})),graveyardX:Math.round(r*(n?.72:.84)),graveyardY:s-4,height:o,routeY:a,socketX:Math.round(r*(n?.82:.92)),startX:h,width:r}}(e.size??[900,520],e.gates,e.crashOffset??30),i=e.positiveProperties??[],r=new Map(i.map(e=>[e.id,e])),o=new Map((e.negativeProperties??[]).map(e=>[e.id,e])),n={idAccessor:e.idAccessor,initialViability:e.initialViability,metricsAccessor:e.metricsAccessor,negativeAccessor:e.negativeAccessor,positiveAccessor:e.positiveAccessor,startTimeAccessor:e.startTimeAccessor},a=(e.data??[]).map((t,a)=>{let s=function(e,t,i,r,o){let n=fi(e,t,i.idAccessor,null!=e.id?e.id+"":"project-"+t)+"",a=r.map(e=>e.id),s=[...fi(e,t,i.positiveAccessor,a)],l=[...fi(e,t,i.negativeAccessor,[])].filter(e=>o.has(e));return{id:n,activePositiveIds:s,datum:e,delay:0,eventsApplied:[],eventHistory:[],killed:!1,metrics:{...fi(e,t,i.metricsAccessor,{})},missingPositiveIds:a.filter(e=>!s.includes(e)),negativeIds:l,outcome:"in_process",poppedPositiveIds:[],poppedNegativeIds:[],startedAt:Math.max(0,Number(fi(e,t,i.startTimeAccessor,0))||0),stage:"project filed",viability:fi(e,t,i.initialViability,100)}}(t,a,n,i,o);return{...s,viability:e.viability?.(s,{negativeProperties:o,positiveProperties:r})??ki(s,r,o)}}),s=a.flatMap((i,n)=>{let a=function(e,t,i,r){let 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}}(i),n=r?.(e,t,i)??{};return{...o,...n,startY:n.startY??n.routeY??o.startY,socketY:n.socketY??n.routeY??o.socketY,graveyardY:n.graveyardY??o.graveyardY}}(i,n,t,e.projectPlacement);return function(e,t,i,r,o,n,a){let s=bi(i),l=Math.max(3,28*s),c=r.startX,u=r.startY+(r.startY===i.routeY?38*t*s:0),d=a?.(e,t,i,r)??{},h=d.x??c,p=d.y??u,f={__gauntlet:!0,kind:"gauntlet-core",projectId:e.id,sourceDatum:e.datum},y=[{...d,id:yi(e.id),x:h,y:p,vx:d.vx??42,vy:d.vy??0,mass:d.mass??7,bodyCollisions:d.bodyCollisions??!0,shape:d.shape??{type:"circle",radius:l},spawnAt:d.spawnAt??e.startedAt,datum:f}],g=vi(h,p,d.shape&&"radius"in d.shape&&Number(d.shape.radius)||l,i);y[0].x=g.x,y[0].y=g.y;for(let t of e.activePositiveIds){let r=o.get(t);if(!r)continue;let n=wi(e.activePositiveIds,t,s),a=r.radius??Math.max(2,10*s),l=vi(g.x+Math.cos(n.angle)*n.radius,g.y+Math.sin(n.angle)*n.radius,a,i);y.push({id:gi(e.id,t),x:l.x,y:l.y,vx:18*Math.cos(n.angle),vy:18*Math.sin(n.angle),mass:r.mass??.75,bodyCollisions:!1,shape:{type:"circle",radius:a},spawnAt:d.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:yi(e.id)},stiffness:.56,damping:.9,restLength:Math.max(6,(52+n.index%2*4)*s),...r.spring??{}}]})}return e.negativeIds.forEach((t,r)=>{let o=n.get(t);o&&y.push(function(e,t,i,r,o,n,a){let s=bi(n),l=t.radius??Math.max(2,7.2*s),c=vi(r+(i%4*12-12)*s,o+(54+12*Math.floor(i/4))*s,l,n);return{id:mi(e.id,t.id,i),x:c.x,y:c.y,vx:10,vy:6,mass:t.mass??.72,bodyCollisions:!1,shape:{type:"circle",radius:l},spawnAt:a,datum:{__gauntlet:!0,kind:zf,projectId:e.id,property:t,sourceDatum:e.datum},springs:!1===t.spring?[]:[{target:{type:"body",bodyId:yi(e.id)},stiffness:.62,damping:.92,restLength:Math.max(6,(52+i%4*3)*s),...t.spring??{}}]}}(e,o,r,g.x,g.y,i,d.spawnAt??e.startedAt))}),y}(i,n,t,a,r,o,e.coreBody)});return{layout:t,states:a,initialSpawns:s,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:pi(t)}}}function Si(e=[]){let t=Object.create(null);for(let[i,r]of e)t[i]=r;return t}function Mi(...e){let t=Si();for(let i of e)for(let[e,r]of Object.entries(i??{}))t[e]=r;return t}function $i(e){return Mi(e)}function _i(e){return e.map(e=>({...e,sourceIds:e.sourceIds?[...e.sourceIds]:void 0,productIds:e.productIds?[...e.productIds]:void 0,relationIds:e.relationIds?[...e.relationIds]:void 0,outletIds:e.outletIds?[...e.outletIds]:void 0}))}function Pi(e){let t=Si(Object.entries(e.components).map(([e,t])=>[e,{...t,initialMetrics:$i(t.initialMetrics),metrics:$i(t.metrics),productIds:[...t.productIds],history:_i(t.history)}])),i=Si(Object.entries(e.products).map(([e,t])=>[e,{...t,metrics:$i(t.metrics),sourceIds:[...t.sourceIds],history:_i(t.history)}])),r=Si(Object.entries(e.relations).map(([e,t])=>[e,{...t,sourceIds:[...t.sourceIds],metrics:t.metrics?$i(t.metrics):void 0}]));return{...e,eventsApplied:[...e.eventsApplied],components:t,products:i,relations:r,input:{amount:e.input.amount,metrics:$i(e.input.metrics)},metrics:$i(e.metrics),loss:{amount:e.loss.amount,metrics:$i(e.loss.metrics)},history:_i(e.history)}}function Ii(e,t){return t>e?-1:e>t?1:0}function Ri(e,t,i,r,o){return{severity:e,code:t,message:i,path:r,ids:o?[...o]:void 0}}function Li(e){let t=new Set,i=new Set;for(let r of e)t.has(r)&&i.add(r),t.add(r);return[...i].sort(Ii)}function Ci(e,t){return e?Object.entries(e).flatMap(([e,i])=>Number.isFinite(i)?[]:[Ri("error","invalid-metric",`Metric "${e}" must be a finite number.`,`${t}.${e}`)]):[]}function Ti(e,t){for(let[i,r]of Object.entries(t))e[i]=Number(e[i]??0)+r}function Oi(e,t,i="selector"){let r=[],o=Object.values(e.components),n=new Set(o.map(e=>e.id)),a=(t.ids??[]).filter(e=>!n.has(e));if(a.length&&r.push(Ri("error","unknown-component",`Selector references unknown component id${1===a.length?"":"s"}: ${a.join(", ")}.`,i+".ids",a)),void 0!==t.count&&(!Number.isInteger(t.count)||0>t.count)&&r.push(Ri("error","invalid-selector-count","Selector count must be a non-negative integer.",i+".count")),r.some(e=>"error"===e.severity))return{ids:[],diagnostics:r};let s=t.ids?new Set(t.ids):null,l=t.categories?new Set(t.categories):null,c=t.statuses?new Set(t.statuses):null,u=t.outletIds?new Set(t.outletIds):null,d=o.filter(e=>!s||s.has(e.id)).filter(e=>!l||l.has(e.category)).filter(e=>!c||c.has(e.status)).filter(e=>!u||void 0!==e.outletId&&u.has(e.outletId)).map(e=>e.id).sort(Ii);return void 0!==t.count&&(d=d.slice(0,t.count)),d.length||r.push(Ri("warning","empty-selector","Selector matched no source components.",i)),{ids:d,diagnostics:r}}function Fi(e,t,i={}){return{eventId:e.event.id,effectType:t.type,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,label:e.event.label,summary:e.event.summary,...i}}function Di(e,t){let i={...t,eventId:e.event.id};e.materializations.push(i),e.observations.push({...i,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt})}function Ei(e,t,i){return!(void 0!==t&&!e.outletIds.has(t)&&(e.diagnostics.push(Ri("error","unknown-outlet",`Unknown outlet "${t}".`,i,[t])),1))}function Ni(e,t,i){let r=Li(t);t.length||e.diagnostics.push(Ri("error","empty-source-list","A product requires at least one source component.",i)),r.length&&e.diagnostics.push(Ri("error","duplicate-source",`Source ids may appear only once: ${r.join(", ")}.`,i,r));let o=t.filter(t=>!e.state.components[t]);o.length&&e.diagnostics.push(Ri("error","unknown-component",`Unknown source component id${1===o.length?"":"s"}: ${o.join(", ")}.`,i,o));let n=t.filter(t=>(e.state.components[t]?.productIds.length??0)>0);n.length&&e.diagnostics.push(Ri("error","source-already-assigned",`Source component${1===n.length?" is":"s are"} already assigned: ${n.join(", ")}.`,i,n));let a=t.filter(t=>"consumed"===e.state.components[t]?.status&&!n.includes(t));return a.length&&e.diagnostics.push(Ri("error","source-unavailable",`Consumed source component${1===a.length?" is":"s are"} unavailable: ${a.join(", ")}.`,i,a)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}function zi(e,t,i,r,o){let n=r?.amount??0;(!Number.isFinite(n)||0>n||n>t+jf)&&e.diagnostics.push(Ri("error","invalid-loss","Loss amount must be finite, non-negative, and no greater than its sources.",o+".amount")),e.diagnostics.push(...Ci(r?.metrics,o+".metrics"));for(let[t,n]of Object.entries(r?.metrics??{}))(0>n||n>Number(i[t]??0)+jf)&&e.diagnostics.push(Ri("error","invalid-metric-loss",`Metric loss "${t}" must be non-negative and no greater than its sources.`,`${o}.metrics.${t}`));return!e.diagnostics.some(e=>"error"===e.severity)}function Bi(e,t,i,r,o,n,a){return{id:e.id,label:e.label??e.id,description:e.description,category:e.category??"product",color:e.color,order:e.order,declaredAmount:e.amount,amount:n&&void 0!==e.amount?e.amount:i,metrics:n&&e.metrics?Mi(r,e.metrics):$i(r),status:n?"complete":"forming",sourceIds:[...t],outletId:n?e.outletId??(o.outletIds.has("product")?"product":void 0):void 0,createdByEventId:o.event.id,createdAt:o.context.appliedAt,completedByEventId:n?o.event.id:void 0,completedAt:n?o.context.appliedAt:void 0,history:[a]}}function ji(e,t,i,r){void 0!==t.amount&&Math.abs(t.amount-i)>jf&&e.diagnostics.push(Ri("warning","declared-product-amount-mismatch",`Product "${t.id}" declares ${t.amount}, while its sources yield ${i}.`,r,[t.id]))}function Wi(e,t,i){let r=`events.${e.event.id}.effects.${i}`,o=e.state;if("set-state"===t.type){["queued","active","transformed","retained","ejected","failed","recovered"].includes(t.state)||e.diagnostics.push(Ri("error","invalid-component-state",`set-state cannot assign "${t.state+""}".`,r+".state")),e.diagnostics.push(...Ci(t.metricsDelta,r+".metricsDelta")),Ei(e,t.outletId,r+".outletId");let i=Oi(o,t.select,r+".select");e.diagnostics.push(...i.diagnostics);let n=i.ids.filter(e=>o.components[e].productIds.length);if(n.length&&e.diagnostics.push(Ri("error","source-already-assigned",`Assigned source components cannot be retargeted: ${n.join(", ")}.`,r+".select",n)),e.diagnostics.some(e=>"error"===e.severity))return;let a=Fi(e,t,{sourceIds:i.ids,outletIds:t.outletId?[t.outletId]:void 0});for(let e of i.ids){let i=o.components[e];i.status=t.state,i.outletId=t.outletId,i.reason=t.reason,t.metricsDelta&&Ti(i.metrics,t.metricsDelta),i.history.push(a)}return o.history.push(a),void(i.ids.length&&Di(e,{type:"retarget-component",sourceIds:i.ids,outletIds:t.outletId?[t.outletId]:void 0}))}if("set-relation"===t.type){let{relation:i}=t;(!i.id||o.relations[i.id])&&e.diagnostics.push(Ri("error","duplicate-relation",`Relation id "${i.id}" is missing or already active.`,r+".relation.id",[i.id]));let n=function(e,t,i){let r=Li(t),o=t.filter(t=>!e.state.components[t]);return 2>t.length&&e.diagnostics.push(Ri("error","insufficient-relation-sources","A relation requires at least two source components.",i)),r.length&&e.diagnostics.push(Ri("error","duplicate-source",`Relation source ids must be unique: ${r.join(", ")}.`,i,r)),o.length&&e.diagnostics.push(Ri("error","unknown-component",`Relation references unknown source component${1===o.length?"":"s"}: ${o.join(", ")}.`,i,o)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.components[t])}(e,i.sourceIds,r+".relation.sourceIds");if(e.diagnostics.push(...Ci(i.metrics,r+".relation.metrics")),!n||e.diagnostics.some(e=>"error"===e.severity))return;o.relations[i.id]={...i,sourceIds:[...i.sourceIds],metrics:i.metrics?$i(i.metrics):void 0,status:"active",createdByEventId:e.event.id,createdAt:e.context.appliedAt};let a=Fi(e,t,{sourceIds:[...i.sourceIds],relationIds:[i.id]});return o.history.push(a),void Di(e,{type:"activate-relation",sourceIds:[...i.sourceIds],relationIds:[i.id]})}if("resolve-relation"===t.type){let i=Li(t.relationIds),n=t.relationIds.filter(e=>!o.relations[e]),a=t.relationIds.filter(e=>"resolved"===o.relations[e]?.status);if(i.length&&e.diagnostics.push(Ri("error","duplicate-relation","Relation ids must be unique.",r+".relationIds",i)),n.length&&e.diagnostics.push(Ri("error","unknown-relation",`Unknown relation: ${n.join(", ")}.`,r+".relationIds",n)),a.length&&e.diagnostics.push(Ri("error","resolved-relation",`Relation is already resolved: ${a.join(", ")}.`,r+".relationIds",a)),e.diagnostics.some(e=>"error"===e.severity))return;for(let i of t.relationIds){let r=o.relations[i];r.status="resolved",r.resolution=t.resolution,r.resolvedByEventId=e.event.id,r.resolvedAt=e.context.appliedAt,r.reason=t.reason}let s=Fi(e,t,{relationIds:[...t.relationIds]});return o.history.push(s),void Di(e,{type:"resolve-relation",relationIds:[...t.relationIds]})}if("combine"===t.type||"contribute"===t.type){let i=e.productDefinitions.get(t.productId);i||e.diagnostics.push(Ri("error","unknown-product",`Product "${t.productId}" has no declared mold.`,r+".productId",[t.productId]));let n=o.products[t.productId];"combine"===t.type&&n&&e.diagnostics.push(Ri("error","duplicate-product",`Product "${t.productId}" has already been formed.`,r+".productId",[t.productId])),"contribute"===t.type&&(!n||"forming"!==n.status)&&e.diagnostics.push(Ri("error","product-not-forming",`Contributions require an existing forming product "${t.productId}".`,r+".productId",[t.productId]));let a=Ni(e,t.sourceIds,r+".sourceIds"),s="contribute"===t.type&&n?[...n.sourceIds,...t.sourceIds]:t.sourceIds,l=function(e,t,i,r){if(!t?.length)return[];let o=Li(t),n=t.filter(t=>!e.state.relations[t]),a=t.filter(t=>"resolved"===e.state.relations[t]?.status),s=new Set(i),l=t.filter(t=>(e.state.relations[t]?.sourceIds??[]).some(e=>!s.has(e)));return o.length&&e.diagnostics.push(Ri("error","duplicate-relation","Basis relations must be unique.",r,o)),n.length&&e.diagnostics.push(Ri("error","unknown-relation",`Unknown basis relation: ${n.join(", ")}.`,r,n)),a.length&&e.diagnostics.push(Ri("error","resolved-relation",`Basis relation is already resolved: ${a.join(", ")}.`,r,a)),l.length&&e.diagnostics.push(Ri("error","relation-source-mismatch",`Basis relation includes a source outside this product: ${l.join(", ")}.`,r,l)),e.diagnostics.some(e=>"error"===e.severity)?null:t.map(t=>e.state.relations[t])}(e,t.basisRelationIds,s,r+".basisRelationIds");if(!a||!l||!i||e.diagnostics.some(e=>"error"===e.severity))return;let c=a.reduce((e,t)=>e+t.amount,0),u=function(e){let t=Si();for(let i of e)Ti(t,i.metrics);return t}(a);if(!zi(e,c,u,t.loss,r+".loss"))return;let d=c-(t.loss?.amount??0);!function(e,t,i){e.state.loss.amount+=i?.amount??0;for(let[r,o]of Object.entries(i?.metrics??{}))t[r]=Number(t[r]??0)-o,e.state.loss.metrics[r]=Number(e.state.loss.metrics[r]??0)+o}(e,u,t.loss);let h,p="combine"===t.type&&!1!==t.complete,f=Fi(e,t,{sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0});if("combine"===t.type){if(p&&ji(e,i,d,r+".productId"),h=Bi(i,t.sourceIds,d,u,e,p,f),p&&!Ei(e,h.outletId,r+".productId"))return;o.products[t.productId]=h}else h=n,h.sourceIds.push(...t.sourceIds),h.amount+=d,Ti(h.metrics,u),h.history.push(f);for(let e of a)e.productIds=[t.productId],e.status="consumed",e.outletId=void 0,e.history.push(f);return o.history.push(f),function(e,t){if(t.length){for(let i of t)i.status="resolved",i.resolution="combined",i.resolvedByEventId=e.event.id,i.resolvedAt=e.context.appliedAt;Di(e,{type:"resolve-relation",relationIds:t.map(e=>e.id)})}}(e,l),Di(e,{type:"combine"===t.type?"form-product":"update-product",sourceIds:[...t.sourceIds],productIds:[t.productId],relationIds:t.basisRelationIds?[...t.basisRelationIds]:void 0,outletIds:h.outletId?[h.outletId]:void 0}),void(p&&Di(e,{type:"complete-product",sourceIds:[...h.sourceIds],productIds:[h.id],outletIds:h.outletId?[h.outletId]:void 0}))}if("complete-product"===t.type){let i=o.products[t.productId];return i?void function(e,t,i,r,o,n){let a=e.productDefinitions.get(t.id),s=i??a?.outletId??(e.outletIds.has("product")?"product":void 0);if(!Ei(e,s,n+".outletId"))return;if("complete"===t.status)return void e.diagnostics.push(Ri("error","product-already-complete",`Product "${t.id}" is already complete.`,n,[t.id]));a&&(ji(e,a,t.amount,n+".productId"),void 0!==a.amount&&(t.amount=a.amount),a.metrics&&(t.metrics=Mi(t.metrics,a.metrics))),t.status="complete",t.outletId=s,t.reason=r,t.completedByEventId=e.event.id,t.completedAt=e.context.appliedAt;let l=Fi(e,o,{sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:s?[s]:void 0});t.history.push(l),e.state.history.push(l),Di(e,{type:"complete-product",sourceIds:[...t.sourceIds],productIds:[t.id],outletIds:s?[s]:void 0})}(e,i,t.outletId,t.reason,t,r):void e.diagnostics.push(Ri("error","unknown-product-state",`Product "${t.productId}" has not been formed.`,r+".productId",[t.productId]))}if("split"===t.type){let i=Ni(e,[t.sourceId],r+".sourceId");t.products.length||e.diagnostics.push(Ri("error","empty-split","A split requires at least one product allocation.",r+".products"));let n=t.products.map(e=>e.productId),a=Li(n);a.length&&e.diagnostics.push(Ri("error","duplicate-product","Split product ids must be unique.",r+".products",a));let s=n.map(t=>e.productDefinitions.get(t)),l=n.filter((e,t)=>!s[t]),c=n.filter(e=>o.products[e]);l.length&&e.diagnostics.push(Ri("error","unknown-product",`Split references undeclared product molds: ${l.join(", ")}.`,r+".products",l)),c.length&&e.diagnostics.push(Ri("error","duplicate-product",`Split products already exist: ${c.join(", ")}.`,r+".products",c));for(let[i,o]of t.products.entries())void 0!==o.amount&&(!Number.isFinite(o.amount)||0>o.amount)&&e.diagnostics.push(Ri("error","invalid-product-amount","Split allocation amounts must be finite and non-negative.",`${r}.products.${i}.amount`)),e.diagnostics.push(...Ci(o.metrics,`${r}.products.${i}.metrics`));if(!i?.length||e.diagnostics.some(e=>"error"===e.severity))return;let u=i[0];if(!zi(e,u.amount,u.metrics,t.loss,r+".loss"))return;let d=u.amount-(t.loss?.amount??0),h=t.products.map((e,t)=>e.amount??s[t]?.amount),p=h.filter(e=>void 0!==e).length;if(0!==p&&p!==h.length)return void e.diagnostics.push(Ri("error","partial-split-allocation","Either every split product must declare an amount or none may do so.",r+".products"));let f=p?h:t.products.map(()=>d/t.products.length),y=f.reduce((e,t)=>e+t,0);if(Math.abs(y-d)>jf)return void e.diagnostics.push(Ri("error","split-amount-mismatch",`Split allocations total ${y}, but ${d} remains after loss.`,r+".products"));let g=$i(u.metrics);for(let[e,i]of Object.entries(t.loss?.metrics??{}))g[e]=Number(g[e]??0)-i;let m=Fi(e,t,{sourceIds:[u.id],productIds:n});if(t.products.forEach((i,n)=>{let a=s[n],l=d>jf?f[n]/d:1/t.products.length,c=Si(Object.entries(g).map(([e,t])=>[e,t*l])),h=i.metrics??a.metrics??c,p=Bi({...a,amount:f[n],metrics:h},[u.id],f[n],$i(h),e,!0,m);Ei(e,p.outletId,`${r}.products.${n}.productId`)&&(o.products[p.id]=p)}),e.diagnostics.some(e=>"error"===e.severity))return;u.productIds=n,u.status="consumed",u.outletId=void 0,u.history.push(m),o.loss.amount+=t.loss?.amount??0;for(let[e,i]of Object.entries(t.loss?.metrics??{}))o.loss.metrics[e]=Number(o.loss.metrics[e]??0)+i;o.history.push(m),Di(e,{type:"split-source",sourceIds:[u.id],productIds:n});for(let t of n)Di(e,{type:"complete-product",sourceIds:[u.id],productIds:[t],outletIds:o.products[t].outletId?[o.products[t].outletId]:void 0});return}if("eject"===t.type){Ei(e,t.outletId,r+".outletId");let i=Oi(o,t.select,r+".select");e.diagnostics.push(...i.diagnostics);let n=i.ids.filter(e=>o.components[e].productIds.length);if(n.length&&e.diagnostics.push(Ri("error","source-already-assigned",`Assigned source components cannot be ejected: ${n.join(", ")}.`,r+".select",n)),e.diagnostics.some(e=>"error"===e.severity))return;let a=Fi(e,t,{sourceIds:i.ids,outletIds:[t.outletId]});for(let e of i.ids){let i=o.components[e];i.status=t.state??"ejected",i.outletId=t.outletId,i.reason=t.reason,i.history.push(a)}return o.history.push(a),void(i.ids.length&&Di(e,{type:"retarget-component",sourceIds:i.ids,outletIds:[t.outletId]}))}if("set-metric"===t.type){if(e.diagnostics.push(...Ci(t.metricsDelta,r+".metricsDelta")),e.diagnostics.some(e=>"error"===e.severity))return;let i,n;if("run"===t.target)Ti(o.metrics,t.metricsDelta);else if("components"in t.target){let n=Oi(o,t.target.components,r+".target.components");if(e.diagnostics.push(...n.diagnostics),e.diagnostics.some(e=>"error"===e.severity))return;i=n.ids;for(let e of n.ids)Ti(o.components[e].metrics,t.metricsDelta)}else{n=[...t.target.productIds];let i=Li(n),a=n.filter(e=>!o.products[e]);if(i.length&&e.diagnostics.push(Ri("error","duplicate-product","Metric target product ids must be unique.",r+".target.productIds",i)),a.length&&e.diagnostics.push(Ri("error","unknown-product-state",`Metric target product has not formed: ${a.join(", ")}.`,r+".target.productIds",a)),e.diagnostics.some(e=>"error"===e.severity))return;for(let e of n)Ti(o.products[e].metrics,t.metricsDelta)}return void o.history.push(Fi(e,t,{sourceIds:i,productIds:n}))}t.outcome.trim()?(o.outcome=t.outcome,o.summary=t.summary,o.history.push(Fi(e,t)),e.observations.push({type:"crucible-outcome",eventId:e.event.id,phaseId:e.context.phaseId,authoredAt:e.context.authoredAt,appliedAt:e.context.appliedAt,outcome:t.outcome})):e.diagnostics.push(Ri("error","invalid-outcome","Outcome must be a non-empty string.",r+".outcome"))}function Yi(e,t,i){if(e.eventsApplied.includes(t.id))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:[Ri("warning","duplicate-event-application",`Event "${t.id}" has already been applied.`,"events."+t.id,[t.id])]};let r=Pi(e),o={state:r,event:t,context:i,productDefinitions:new Map(i.products.map(e=>[e.id,e])),outletIds:new Set(i.outlets.map(e=>e.id)),diagnostics:[],materializations:[],observations:[]};for(let[i,r]of t.effects.entries())if(Wi(o,r,i),o.diagnostics.some(e=>"error"===e.severity))return{applied:!1,state:e,materializations:[],observations:[],diagnostics:o.diagnostics};return r.elapsed=Math.max(r.elapsed,i.appliedAt),r.phaseId=i.phaseId,r.eventsApplied.push(t.id),o.observations.unshift({type:"crucible-event",eventId:t.id,phaseId:i.phaseId,authoredAt:i.authoredAt,appliedAt:i.appliedAt}),{applied:!0,state:r,materializations:o.materializations,observations:o.observations,diagnostics:o.diagnostics}}function qi(e,t){return t>e?-1:e>t?1:0}function Xi(e,t,i,r,o){return{severity:e,code:t,message:i,path:r,ids:o?[...o]:void 0}}function Gi(e){let t=new Set,i=new Set;for(let r of e)t.has(r)&&i.add(r),t.add(r);return[...i].sort(qi)}function Vi(e){let t="number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function Hi(e,t,i,r,o,n){if(!i)return r;try{return("function"==typeof i?i(e,t):e[i])??r}catch(e){return o.push(Xi("error","accessor-error",`Accessor threw: ${e instanceof Error?e.message:e+""}.`,n)),r}}function Ui(e,t,i){if(!e||"object"!=typeof e||Array.isArray(e))return null!=e&&t.push(Xi("error","invalid-metrics","Metrics must be a numeric object.",i)),Si();let r=Si();for(let[o,n]of Object.entries(e)){let e=Vi(n);null!=e?r[o]=e:t.push(Xi("error","invalid-metric",`Metric "${o}" must be finite.`,`${i}.${o}`))}return r}function Ki(e){return e.map((e,t)=>({outlet:e,index:t})).sort((e,t)=>(e.outlet.order??e.index)-(t.outlet.order??t.index)||e.index-t.index).map(({outlet:e})=>({...e}))}function Zi(e){let{id:t,orientation:i,fixed:r,start:o,end:n,openings:a,thickness:s,friction:l,restitution:c}=e,u=function(e,t,i){let r=i.map(([i,r])=>[Math.max(e,Math.min(i,r)),Math.min(t,Math.max(i,r))]).filter(([e,t])=>t>e+Xf).sort((e,t)=>e[0]-t[0]||e[1]-t[1]),o=[],n=e;for(let[e,t]of r)e>n+Xf&&o.push([n,e]),n=Math.max(n,t);return t>n+Xf&&o.push([n,t]),o}(o,n,a);return u.map(([e,o],n)=>({id:1===u.length?t:`${t}:${n}`,friction:l,restitution:c,shape:"horizontal"===i?{type:"segment",x1:e,y1:r,x2:o,y2:r,thickness:s}:{type:"segment",x1:r,y1:e,x2:r,y2:o,thickness:s}}))}function Qi(e){let t=2166136261;for(let i=0;e.length>i;i+=1)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return t>>>0}function Ji(e){return"number"==typeof e&&Number.isFinite(e)?e>>>0:"string"==typeof e?Qi(e):1}function er(e,t){return{fixedDt:1/120,maxSubsteps:8,settleStepLimit:7200,colliders:t.map(e=>({...e,shape:{...e.shape}})),observation:{chartType:"crucible"},kernel:{seed:Ji(e),gravity:{x:0,y:0},cellSize:42,collisionIterations:6,velocityDamping:.992,restitution:.12,friction:.42,sleepSpeed:4,sleepAfter:.5,maxVelocity:620}}}function tr(e){return"crucible:component:"+encodeURIComponent(e)}function ir(e,t,i,r){if(void 0!==i&&Number.isFinite(i)&&i>0)return i;let o=Math.min(...t,e),n=Math.max(...t,e);return n-o>Xf?r[0]+(r[1]-r[0])*Math.sqrt(Math.max(0,e-o)/(n-o)):(r[0]+r[1])/2}function rr(e,t){let i=Math.max(.25,Math.min(1,t.width/900,t.height/520)),r=e?.[0]??7*i,o=e?.[1]??18*i,n=Math.max(1,Math.min(r,o));return[n,Math.max(n,Math.max(r,o))]}function or(e,t){if(!e)return[];let i=Math.min(e,Math.max(1,Math.ceil(Math.sqrt(e*Math.max(.5,t.width/Math.max(1,t.height)))))),r=Math.max(1,Math.ceil(e/i));return Array.from({length:e},(e,o)=>({x:t.x+t.width/i*(o%i+.5),y:t.y+(Math.floor(o/i)+.5)*(t.height/r)}))}function nr(e){return e.outletId?e.outletId:"failed"===e.status?"failed":"recovered"===e.status?"recovered":"retained"===e.status?"retained":"ejected"===e.status?"residue":void 0}function ar(e,t){return e.outlets.find(e=>e.id===t)||{x:e.chamber.x+.18*e.chamber.width,y:e.chamber.y+.2*e.chamber.height,width:.64*e.chamber.width,height:.6*e.chamber.height}}function sr(e,t,i={}){let r=Object.values(e.products).sort((e,t)=>qi(e.id,t.id)),o=Object.values(e.components).sort((e,t)=>qi(e.id,t.id)),n=[...o.map(e=>e.amount),...r.map(e=>e.amount)],a=rr(i.radiusRange,t),s=function(e,t){let i=new Map;for(let t of e){let e=t.outletId??"__chamber__",r=i.get(e)??[];r.push(t),i.set(e,r)}let r=new Map;for(let[e,o]of i){o.sort((e,t)=>(e.order??Number.MAX_SAFE_INTEGER)-(t.order??Number.MAX_SAFE_INTEGER)||qi(e.id,t.id));let i=or(o.length,ar(t,"__chamber__"===e?void 0:e));o.forEach((e,t)=>r.set(e.id,i[t]))}return r}(r,t),l=r.map(e=>{let r=s.get(e.id)??{x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2},o=1.28*ir(e.amount,n,i.bodyRadius,a),l={__crucible:!0,kind:"product",semanticId:e.id,product:e};return{id:(c=e.id,"crucible:product:"+encodeURIComponent(c)),x:r.x,y:r.y,mass:Math.max(.25,o*o*.018),bodyCollisions:!1,shape:{type:"circle",radius:o},datum:l};var c}),c=new Map;for(let e of o.filter(e=>!e.productIds.length)){let t=nr(e)??"__chamber__",i=c.get(t)??[];i.push(e),c.set(t,i)}let u=new Map;for(let[e,i]of c){let r=or(i.length,ar(t,"__chamber__"===e?void 0:e));i.forEach((e,t)=>u.set(e.id,r[t]))}return[...o.map(e=>{let r=u.get(e.id);if(e.productIds.length){let i=e.productIds.map(e=>s.get(e)).filter(e=>!!e);if(i.length){r={x:i.reduce((e,t)=>e+t.x,0)/i.length,y:i.reduce((e,t)=>e+t.y,0)/i.length};let o=Qi(e.id)/4294967295*Math.PI*2,n=Math.min(20,Math.max(4,.012*t.width));r={x:r.x+Math.cos(o)*n,y:r.y+Math.sin(o)*n}}}r??(r={x:t.chamber.x+t.chamber.width/2,y:t.chamber.y+t.chamber.height/2});let o=ir(e.amount,n,i.bodyRadius,a),l={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:tr(e.id),x:r.x,y:r.y,mass:Math.max(.25,o*o*.015),shape:{type:"circle",radius:o},datum:l}}),...l]}function lr(e){return Array.isArray(e)?e.map(lr):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e&&"function"!=typeof e).sort(([e],[t])=>qi(e,t)).map(([e,t])=>[e,lr(t)])):e}function cr(e,t=e.duration){let i=function(e,t){let i=Vi(t)??0,r=Math.max(0,Math.min(e.duration,i));if(!e.phases.length)return{elapsed:r,phaseId:"",phaseIndex:-1,phaseElapsed:0,complete:!0};let o=r>=e.duration-Xf,n=o?e.phases[e.phases.length-1]:e.phases.find(e=>r>=e.start&&e.end>r)??e.phases[0];return{elapsed:r,phaseId:n.id,phaseIndex:n.index,phaseElapsed:o?n.duration:Math.max(0,r-n.start),complete:o}}(e,t),r=Pi(e.initialState),o=[],n=[],a=[];for(let t of e.events){if(t.authoredAt>i.elapsed+Xf)break;let s=Yi(r,t,{phaseId:t.phaseId,authoredAt:t.authoredAt,appliedAt:t.authoredAt,products:e.products,outlets:e.outlets});o.push(...s.diagnostics),n.push(...s.materializations),a.push(...s.observations),s.applied&&(r=s.state)}return r.elapsed=i.elapsed,r.phaseId=i.phaseId,r.phaseIndex=i.phaseIndex,r.phaseElapsed=i.phaseElapsed,r.complete=i.complete,i.complete&&"in_process"===r.outcome&&(r.outcome="complete"),r.playing=!1,{state:r,diagnostics:o,materializations:n,observations:a}}function ur(e){let t=function(e){let t=[];e.length||t.push(Xi("error","empty-phase-program","CrucibleChart requires at least one phase.","phases"));let i=Gi(e.map(e=>e.id));i.length&&t.push(Xi("error","duplicate-phase-id",`Phase ids must be unique: ${i.join(", ")}.`,"phases",i));let r=0;return{phases:e.map((e,i)=>{let o=Vi(e.duration),n=null!=o&&o>0?o:0;e.id.trim()||t.push(Xi("error","invalid-phase-id","Phase ids may not be empty.",`phases.${i}.id`)),(null==o||0>=o)&&t.push(Xi("error","invalid-phase-duration","Phase duration must be finite and greater than zero.",`phases.${i}.duration`,[e.id])),void 0!==e.intensity&&!Number.isFinite(e.intensity)&&t.push(Xi("error","invalid-phase-intensity","Phase intensity must be finite.",`phases.${i}.intensity`,[e.id]));let a={...e,duration:n,intensity:void 0===e.intensity?.5:Number.isFinite(e.intensity)?Math.max(0,Math.min(1,e.intensity)):.5,motion:e.motion??"hold",index:i,start:r,end:r+n};return r=a.end,a}),diagnostics:t}}(e.phases),i=t.phases.at(-1)?.end??0,r=Ki(e.outlets??Yf),o=(e.products??[]).map(e=>({...e,metrics:e.metrics?Mi(e.metrics):void 0})),n=function(e,t,i){let r=[],o=Gi(e.map(e=>e.id));o.length&&r.push(Xi("error","duplicate-event-id",`Event ids must be unique: ${o.join(", ")}.`,"events",o));let n=[];return e.forEach((e,o)=>{let a,s,l;if(e.id.trim()||r.push(Xi("error","invalid-event-id","Event ids may not be empty.",`events.${o}.id`)),"time"in e.at&&void 0!==e.at.time){let n=Vi(e.at.time);if(null==n||0>n||n>i+Xf)return void r.push(Xi("error","event-time-out-of-range",`Event time must fall between 0 and ${i}.`,`events.${o}.at.time`,[e.id]));a=Math.max(0,Math.min(i,n));let c=function(e,t,i){let r=e.find(e=>Xf>=Math.abs(e.start-i));if(r)return{phase:r,boundaryRank:1};let o=e.find(e=>i>=e.start&&e.end>i);return o?{phase:o,boundaryRank:0}:Xf>=Math.abs(i-t)&&e.length?{phase:e[e.length-1],boundaryRank:0}:{phase:void 0,boundaryRank:1}}(t,i,a);s=c.phase,l=c.boundaryRank}else{if(s=t.find(t=>t.id===e.at.phaseId),!s)return void r.push(Xi("error","unknown-event-phase",`Event references unknown phase "${e.at.phaseId}".`,`events.${o}.at.phaseId`,[e.id,e.at.phaseId]));let i=e.at.progress??0;if(!Number.isFinite(i)||0>i||i>1)return void r.push(Xi("error","event-progress-out-of-range","Event phase progress must be between 0 and 1.",`events.${o}.at.progress`,[e.id]));a=s.start+s.duration*i,l=0===i?1:0}s?n.push({...e,index:o,authoredAt:a,phaseId:s.id,phaseIndex:s.index,boundaryRank:l}):r.push(Xi("error","event-without-phase","Event could not be assigned to a phase.",`events.${o}.at`,[e.id]))}),n.sort((e,t)=>e.authoredAt-t.authoredAt||e.boundaryRank-t.boundaryRank||e.index-t.index),{events:n,diagnostics:r}}(e.events??[],t.phases,i),a=function(e){let t=[],i=Si(),r=[],o=0,n=Si();e.data.forEach((a,s)=>{let l=(a.id??"component-"+s)+"",c=((Hi(a,s,e.idAccessor,l,t,`data.${s}.id`)??l)+"").trim();if(!c)return void t.push(Xi("error","invalid-component-id","Component ids may not be empty.",`data.${s}.id`));r.push(c);let u=Vi(Hi(a,s,e.amountAccessor,1,t,`data.${s}.amount`)),d=null==u||0>u?0:u;(null==u||0>u)&&t.push(Xi("error","invalid-component-amount","Component amount must be finite and non-negative.",`data.${s}.amount`,[c]));let h=Ui(Hi(a,s,e.metricsAccessor,{},t,`data.${s}.metrics`),t,`data.${s}.metrics`),p=Hi(a,s,e.initialStateAccessor,"active",t,`data.${s}.status`),f=qf.has(p)?p:"active";qf.has(p)||t.push(Xi("error","invalid-component-status",`Unknown component status "${p+""}".`,`data.${s}.status`,[c]));let y=Hi(a,s,e.labelAccessor,(a.label??a.name??c)+"",t,`data.${s}.label`)+"",g=Hi(a,s,e.categoryAccessor,"component",t,`data.${s}.category`)+"";Object.hasOwn(i,c)||(i[c]={id:c,label:y,category:g,datum:a,status:f,initialAmount:d,amount:d,initialMetrics:Mi(h),metrics:Mi(h),productIds:[],history:[]},o+=d,function(e,t){for(let[i,r]of Object.entries(t))e[i]=Number(e[i]??0)+r}(n,h))});let a=Gi(r);a.length&&t.push(Xi("error","duplicate-component-id",`Component ids must be unique: ${a.join(", ")}.`,"data",a));let s=Ui(e.metrics??{},t,"metrics");return{state:{elapsed:0,phaseElapsed:0,phaseId:e.phases[0]?.id??"",phaseIndex:e.phases.length?0:-1,playing:!1,complete:0===e.phases.length,outcome:"in_process",eventsApplied:[],components:i,products:Si(),relations:Si(),input:{amount:o,metrics:n},metrics:s,loss:{amount:0,metrics:Si()},history:[]},diagnostics:t}}(e),s=function(e=Wf,t=Yf){let i=Math.max(1,Vi(e[0])??900),r=Math.max(1,Vi(e[1])??520),o=360>i||260>r,n=o?Math.max(4,.035*Math.min(i,r)):20,a=o?Math.max(10,.075*r):34,s={x:n,y:n,width:Math.max(1,i-2*n),height:a},l=o?Math.max(16,.14*r):Math.min(78,.16*r),c={x:n,y:r-n-l,width:Math.max(1,i-2*n),height:l},u=o?Math.max(12,.08*i):Math.min(150,.17*i),d=s.y+s.height+(o?12:38),h=c.y-(o?10:34),p={x:u,y:d,width:Math.max(24,i-2*u),height:Math.max(24,h-d)},f=Math.max(18,Math.min(.32*p.width,o?84:180)),y={x:p.x+(p.width-f)/2,y:p.y-(o?10:24),width:f,height:o?12:28},g=Ki(t),m={left:g.filter(e=>"left"===(e.side??"bottom")),right:g.filter(e=>"right"===e.side),bottom:g.filter(e=>"bottom"===(e.side??"bottom"))},x=[],b=(e,t)=>{let r=Math.max(8,u-1.5*n),a=p.height/Math.max(1,t.length);t.forEach((t,s)=>{x.push({...t,side:e,x:"left"===e?n:i-n-r,y:p.y+s*a,width:r,height:Math.max(8,a-(o?2:8))})})};b("left",m.left),b("right",m.right);let v=p.width/Math.max(1,m.bottom.length);return m.bottom.forEach((e,t)=>{x.push({...e,side:"bottom",x:p.x+t*v,y:p.y+p.height+(o?2:7),width:Math.max(8,v-(o?2:8)),height:Math.max(8,c.y-p.y-p.height-(o?4:12))})}),x.sort((e,t)=>g.findIndex(t=>t.id===e.id)-g.findIndex(e=>e.id===t.id)),{width:i,height:r,phaseRail:s,chamber:p,mouth:y,projection:c,outlets:x}}(e.size??Wf,r),l=function(e){let{chamber:t,mouth:i}=e,r=Math.max(2,Math.min(10,.018*Math.min(e.width,e.height))),o=Math.max(t.x,i.x),n=Math.min(t.x+t.width,i.x+i.width),a={left:e.outlets.filter(e=>"left"===e.side),right:e.outlets.filter(e=>"right"===e.side),bottom:e.outlets.filter(e=>"bottom"===e.side)},s=[{id:"crucible:wall:top-left",friction:.42,restitution:.1,shape:{type:"segment",x1:t.x,y1:t.y,x2:o,y2:t.y,thickness:r}},{id:"crucible:wall:top-right",friction:.42,restitution:.1,shape:{type:"segment",x1:n,y1:t.y,x2:t.x+t.width,y2:t.y,thickness:r}}];s.push(...Zi({id:"crucible:wall:left",orientation:"vertical",fixed:t.x,start:t.y,end:t.y+t.height,openings:a.left.map(e=>[e.y,e.y+e.height]),thickness:r,friction:.46,restitution:.12}),...Zi({id:"crucible:wall:right",orientation:"vertical",fixed:t.x+t.width,start:t.y,end:t.y+t.height,openings:a.right.map(e=>[e.y,e.y+e.height]),thickness:r,friction:.46,restitution:.12}),...Zi({id:"crucible:wall:bottom",orientation:"horizontal",fixed:t.y+t.height,start:t.x,end:t.x+t.width,openings:a.bottom.map(e=>[e.x,e.x+e.width]),thickness:r,friction:.5,restitution:.08}));for(let t of e.outlets)s.push({id:"crucible:outlet:"+encodeURIComponent(t.id),sensor:!0,shape:{type:"aabb",x:t.x+t.width/2,y:t.y+t.height/2,width:t.width,height:t.height}});return s}(s),c=function(e,t){let i=[],r=new Set(t.map(e=>e.id)),o=Gi(t.map(e=>e.id)),n=Gi(e.map(e=>e.id));return o.length&&i.push(Xi("error","duplicate-outlet-id",`Outlet ids must be unique: ${o.join(", ")}.`,"outlets",o)),n.length&&i.push(Xi("error","duplicate-product-id",`Product ids must be unique: ${n.join(", ")}.`,"products",n)),t.forEach((e,t)=>{e.id.trim()||i.push(Xi("error","invalid-outlet-id","Outlet ids may not be empty.",`outlets.${t}.id`)),void 0!==e.order&&!Number.isFinite(e.order)&&i.push(Xi("error","invalid-outlet-order","Outlet order must be finite.",`outlets.${t}.order`,[e.id]))}),e.forEach((e,t)=>{e.id.trim()||i.push(Xi("error","invalid-product-id","Product ids may not be empty.",`products.${t}.id`)),void 0!==e.amount&&(!Number.isFinite(e.amount)||0>e.amount)&&i.push(Xi("error","invalid-product-amount","Declared product amount must be finite and non-negative.",`products.${t}.amount`,[e.id])),void 0!==e.outletId&&!r.has(e.outletId)&&i.push(Xi("error","unknown-outlet",`Product "${e.id}" references unknown outlet "${e.outletId}".`,`products.${t}.outletId`,[e.outletId])),Ui(e.metrics??{},i,`products.${t}.metrics`)}),i}(o,r),u=(m={seed:e.seed??1,components:Object.values(a.state.components).sort((e,t)=>qi(e.id,t.id)).map(e=>({id:e.id,label:e.label,category:e.category,amount:e.amount,metrics:e.metrics,status:e.status})),phases:t.phases.map(({id:e,duration:t,label:i,description:r,intensity:o,motion:n,color:a,metrics:s})=>({id:e,duration:t,label:i,description:r,intensity:o,motion:n,color:a,metrics:s})),products:o,outlets:r,events:n.events.map(({id:e,label:t,description:i,summary:r,authoredAt:o,phaseId:n,boundaryRank:a,effects:s})=>({id:e,label:t,description:i,summary:r,authoredAt:o,phaseId:n,boundaryRank:a,effects:s}))},JSON.stringify(lr(m))),d=function(e,t,i={}){let r=Object.values(e.components).sort((e,t)=>qi(e.id,t.id)),o=r.map(e=>e.amount),n=rr(i.radiusRange,t),a=function(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}(Ji(i.seed)),s=t.mouth.x+t.mouth.width/2,l=t.chamber.y+Math.max(18,.18*t.chamber.height),c=Math.max(4,.28*t.chamber.width),u=Math.max(4,.12*t.chamber.height);return r.map((e,t)=>{let d=t/Math.max(1,r.length)*Math.PI*2+.18*(a()-.5),h=ir(e.amount,o,i.bodyRadius,n),p={__crucible:!0,kind:"component",semanticId:e.id,sourceDatum:e.datum};return{id:tr(e.id),x:s+Math.cos(d)*c*(.45+.45*a()),y:l+Math.sin(d)*u*(.45+.45*a()),vx:24*(a()-.5),vy:18*(a()-.5),mass:Math.max(.25,h*h*.015),restitution:.12,friction:.4,shape:{type:"circle",radius:h},datum:p}})}(a.state,s,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),h=[...t.diagnostics,...n.diagnostics,...a.diagnostics,...c],p={phases:t.phases,events:n.events,products:o,outlets:r,duration:i,initialState:a.state,terminalState:a.state,layout:s,colliders:l,config:er(e.seed,l),initialSpawns:d,terminalSpawns:[],semanticKey:u,diagnostics:h},f=cr(p),y=Object.values(f.state.products).filter(e=>"forming"===e.status).map(e=>e.id),g=y.length?[Xi("warning","forming-product-at-end",`Products remain forming at the end of the tape: ${y.join(", ")}.`,"events",y)]:[];var m;return p.terminalState=f.state,p.terminalSpawns=Gf(f.state,s,{seed:e.seed,bodyRadius:e.bodyRadius,radiusRange:e.radiusRange}),p.diagnostics=[...h,...f.diagnostics,...g],p}function dr(e,t){if(!t)return t;let i=function(e){let t=e.trim();if(!t.startsWith("var(")||!t.endsWith(")"))return null;let i=t.slice(4,-1),r=i.indexOf(",");if(-1===r){let e=i.trim();return e.startsWith("--")?{name:e}:null}let o=i.slice(0,r).trim(),n=i.slice(r+1).trim();return o.startsWith("--")?{name:o,fallback:n||void 0}:null}(t);if(!i)return t;let r=()=>i.fallback?dr(e,i.fallback):t,o=e.canvas;if(!o)return r();let n=Hf.get(o);(!n||0!==n.version)&&(n={version:0,map:new Map},Hf.set(o,n));let a=n.map.get(t);if(void 0!==a)return a;let s=getComputedStyle(o).getPropertyValue(i.name).trim()||r()||t;return n.map.set(t,s),s}function hr(e,t){let i=e.fillStyle,r="#010203";try{e.fillStyle=r,e.fillStyle=t}catch{return e.fillStyle=i,[78,121,167]}let o=e.fillStyle;if(e.fillStyle=i,"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)];let n=o.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return n?[+n[1],+n[2],+n[3]]:[78,121,167]}function pr(e){return{type:"hatch",background:e.background,stroke:e.stroke,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle}}function fr(e){return"object"==typeof e&&null!==e&&"hatch"===e.type}function yr(e){return["hatch",e.background??"transparent",e.stroke??"#000",e.lineWidth??1.5,e.spacing??6,e.angle??45,e.lineOpacity??1].join("|")}function gr(e,t){let{background:i="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:n=6,angle:a=45,lineOpacity:s=1}=e,l=Math.max(8,Math.ceil(2*n));return Zf("pattern",{id:t,width:l,height:l,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0,children:[i&&"transparent"!==i&&Kf("rect",{width:l,height:l,fill:i}),Kf("line",{x1:0,y1:0,x2:0,y2:l,stroke:r,strokeWidth:o,strokeOpacity:s}),Kf("line",{x1:n,y1:0,x2:n,y2:l,stroke:r,strokeWidth:o,strokeOpacity:s})]},t)}function mr(e){switch(e){case"monotoneX":return Jf;case"monotoneY":return ey;case"cardinal":return ty;case"catmullRom":return iy;case"step":return ry;case"stepBefore":return oy;case"stepAfter":return ny;case"basis":return ay;case"natural":return sy;default:return null}}function xr(e,t,i){if(null==t)return i;if(fr(t)){let r=function(e,t){let i=e.background??"transparent",r=e.stroke??"#000",o="transparent"===i||"none"===i?i:dr(t,i)||i,n=dr(t,r)||r||"#000",a="u">typeof window&&window.devicePixelRatio||1,s=`${yr(e)}|${o}|${n}@${a}`,l=Qf.get(s);if(void 0!==l)return l;let c=function(e={},t){let i,{background:r="transparent",stroke:o="#000",lineWidth:n=1.5,spacing:a=6,angle:s=45}=e,l={background:r,stroke:o,lineWidth:n,spacing:a,angle:s},c=Math.max(8,Math.ceil(2*a));try{i=function(e){return"u">typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Uf||(Uf=document.createElement("canvas")),Uf.width=e,Uf.height=e,Uf)}(c)}catch{return pr(l)}let u=i.getContext("2d");if(!u)return pr(l);r&&"transparent"!==r?(u.fillStyle=r,u.fillRect(0,0,c,c)):u.clearRect(0,0,c,c),u.strokeStyle=o,u.lineWidth=n,u.lineCap="square";let d=s*Math.PI/180;if(45===s||-45===s){let e=s>0?1:-1;for(let t=-c;2*c>=t;t+=a)u.beginPath(),u.moveTo(t,0),u.lineTo(t+e*c,c),u.stroke()}else{u.save(),u.translate(c/2,c/2),u.rotate(d);let e=2*c;for(let t=-e;e>=t;t+=a)u.beginPath(),u.moveTo(-e,t),u.lineTo(e,t),u.stroke();u.restore()}return(t||u).createPattern(i,"repeat")}({background:o,stroke:n,lineWidth:e.lineWidth,spacing:e.spacing,angle:e.angle},t),u=fr(c)?null:c;return Qf.set(s,u),u}(t,e);return r||t.background&&dr(e,t.background)||i}return"string"!=typeof t?t:dr(e,t)||i}function br(e,t,i){let r=xr(e,t,i);if("string"==typeof r&&r.trim().startsWith("var(")){let t=dr(e,i);return t&&!t.trim().startsWith("var(")?t:i}return r}function vr(e,t,i,r,o,n,a){let s=t.stops.filter(e=>Number.isFinite(e.offset)&&(null==e.opacity||Number.isFinite(e.opacity)));if(2>s.length)return null;let l=e.createLinearGradient(r,o,n,a);for(let t of s)l.addColorStop(Math.max(0,Math.min(1,t.offset)),wr(e,t,i));return l}function wr(e,t,i){let r=t.color??i,o=dr(e,r)||r;if(null==t.opacity)return o;let n=Math.max(0,Math.min(1,t.opacity)),[a,s,l]=hr(e,o);return`rgba(${a},${s},${l},${n})`}function kr(e){return Number.isFinite(e)?1e3>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2).replace(/\.00$/,"").replace(/(\.\d)0$/,"$1"):e.toLocaleString():"0"}function Ar(e,t,i,r){let o=e.datum;if(!o?.__crucible)return;let n="circle"===e.shape.type?e.shape.radius:8,a="string"==typeof t.fill?t.fill:"product"===o.kind?"#b8792d":"#356b63",s="string"==typeof t.stroke?t.stroke:"#26323a",l="number"==typeof t.strokeWidth?t.strokeWidth:1.25,c="number"==typeof t.opacity?t.opacity:.96,u=r?`${r}-crucible-body-${i}`:"crucible-body-"+i;if("product"===o.kind){let t=Array.from({length:6},(t,i)=>{let r=-Math.PI/2+i/6*Math.PI*2;return`${e.x+Math.cos(r)*n},${e.y+Math.sin(r)*n}`}).join(" "),i=u+"-glow";return cy(Vf.Fragment,{children:[ly("defs",{children:ly("filter",{id:i,x:"-60%",y:"-60%",width:"220%",height:"220%",children:ly("feDropShadow",{dx:"0",dy:"0",stdDeviation:"4",floodColor:a,floodOpacity:"0.8"})})}),ly("polygon",{points:t,fill:a,stroke:s,strokeWidth:l,opacity:c,filter:`url(#${i})`}),ly("circle",{cx:e.x,cy:e.y,r:Math.max(2,.36*n),fill:"none",stroke:"var(--semiotic-bg, #fffaf0)",strokeWidth:l,opacity:.72*c})]},u)}return cy(Vf.Fragment,{children:[ly("circle",{cx:e.x,cy:e.y,r:n,fill:a,stroke:s,strokeWidth:l,opacity:c}),ly("circle",{cx:e.x-.25*n,cy:e.y-.28*n,r:Math.max(1,.18*n),fill:"rgba(255,255,255,0.34)"})]},u)}function Sr(e){let{x:t,y:i,width:r,height:o}=e.chamber,n=Math.min(.14*r,48),a=i+o;return[`M ${t} ${i}`,`L ${t+n} ${a-.16*o}`,`Q ${t+r/2} ${a+.1*o} ${t+r-n} ${a-.16*o}`,`L ${t+r} ${i}`].join(" ")}function Mr({layout:e,phases:t,state:i,compact:r=!1}){let o=Math.max(1,t.reduce((e,t)=>e+Math.max(0,t.duration),0));return hy("svg",{"aria-hidden":"true","data-testid":"crucible-chrome",viewBox:`0 0 ${e.width} ${e.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:[hy("defs",{children:[hy("linearGradient",{id:"semiotic-crucible-heat",x1:"0",x2:"0",y1:"0",y2:"1",children:[dy("stop",{offset:"0",stopColor:yy,stopOpacity:"0.03"}),dy("stop",{offset:"0.66",stopColor:yy,stopOpacity:"0.1"}),dy("stop",{offset:"1",stopColor:gy,stopOpacity:"0.18"})]}),dy("pattern",{id:"semiotic-crucible-hatch",width:"7",height:"7",patternUnits:"userSpaceOnUse",patternTransform:"rotate(20)",children:dy("line",{x1:"0",x2:"0",y1:"0",y2:"7",stroke:py,strokeOpacity:"0.08",strokeWidth:"1"})})]}),dy("rect",{x:e.chamber.x,y:e.chamber.y,width:e.chamber.width,height:e.chamber.height,rx:2,fill:"url(#semiotic-crucible-heat)",stroke:py,strokeOpacity:"0.52",strokeWidth:r?1:2.2}),dy("path",{d:Sr(e),fill:"url(#semiotic-crucible-hatch)",stroke:"none"}),dy("line",{x1:e.mouth.x,x2:e.mouth.x+e.mouth.width,y1:e.mouth.y,y2:e.mouth.y,stroke:py,strokeLinecap:"round",strokeOpacity:"0.72",strokeWidth:r?2:5}),r?null:dy("g",{"data-testid":"crucible-phase-rail",children:t.map((r,n)=>{let a=t.slice(0,n).reduce((e,t)=>e+Math.max(0,t.duration),0),s=e.phaseRail.x+a/o*e.phaseRail.width,l=Math.max(0,r.duration)/o*e.phaseRail.width,c=r.id===i.phaseId,u=i.phaseIndex>n||i.complete;return hy("g",{children:[dy("rect",{x:s,y:e.phaseRail.y,width:Math.max(1,l-2),height:e.phaseRail.height,rx:2,fill:c?r.color??yy:u?my:py,fillOpacity:c?.68:u?.28:.09}),46>l?null:dy("text",{x:s+l/2,y:e.phaseRail.y+e.phaseRail.height+13,fill:c?py:fy,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8.5,fontWeight:c?800:650,letterSpacing:"0.04em",textAnchor:"middle",children:(r.label??r.id).toUpperCase()})]},r.id)})}),e.outlets.map(e=>hy("g",{children:[dy("rect",{x:e.x,y:e.y,width:e.width,height:e.height,rx:3,fill:e.color??("left"===e.side?gy:my),fillOpacity:"0.1",stroke:e.color??("left"===e.side?gy:my),strokeDasharray:"3 3",strokeOpacity:"0.62"}),r?null:dy("text",{x:e.x+e.width/2,y:e.y+Math.min(13,e.height/2+3),fill:fy,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:750,letterSpacing:"0.05em",textAnchor:"middle",children:(e.label??e.id).toUpperCase()})]},e.id))]})}function $r({rows:e,layout:t,projection:i,amountLabel:r}){if(!e.length)return null;let o=i.measure??"count",n=e.map(e=>Math.max(0,function(e,t){return"count"===t?e.count:"amount"===t?e.amount:Number(e.metrics[t]??0)}(e,o))),a=Math.max(1,...n),s=t.projection.width/Math.max(1,e.length),l=t.projection.height>48?21:4,c=Math.max(5,t.projection.height-l-5);return dy("svg",{"aria-hidden":"true","data-testid":"crucible-projection-overlay",viewBox:`0 0 ${t.width} ${t.height}`,style:{inset:0,pointerEvents:"none",position:"absolute"},children:e.map((e,i)=>{let u=n[i],d=Math.max(u>0?2:0,u/a*c),h=t.projection.x+i*s+.18*s;return hy("g",{children:[dy("rect",{x:h,y:t.projection.y+c-d,width:Math.max(3,.64*s),height:d,rx:2,fill:"failed"===e.status||"ejected"===e.status?gy:"complete"===e.status?yy:my,fillOpacity:"0.68"}),l>4&&s>=34?hy(uy,{children:[dy("text",{x:h+.32*s,y:t.projection.y+c+10,fill:fy,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:7.5,fontWeight:700,textAnchor:"middle",children:e.label.length>13?e.label.slice(0,12)+"…":e.label}),hy("text",{x:h+.32*s,y:t.projection.y+c+19,fill:py,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",fontSize:8,fontWeight:850,textAnchor:"middle",children:[kr(u),"amount"===o&&r?" "+r:""]})]}):null]},e.key)})})}function _r(e){let t=e.datum;if(t&&"object"==typeof t){let e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e.id}function Pr(e){if(!e?.colors)return;let 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 Ir(e){if(!e)return by;if("string"==typeof e)return"light"===e?by:"dark"===e?vy:"high-contrast"===e?wy:(Object.prototype.hasOwnProperty.call(ky,t=e)?ky[t]:void 0)||by;var t;let i="dark"===e.mode?vy:by;return function(e){if(!e.accessibility)return e;let t=e;if(e.accessibility.colorBlindSafe&&(t={...t,colors:{...t.colors,categorical:xy}}),e.accessibility.highContrast){let 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}({...i,...e,colors:{...i.colors,...e.colors||{}},typography:{...i.typography,...e.typography||{}},tooltip:{...i.tooltip,...e.tooltip||{}}})}function Rr(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,legendFontFamily:e.typography.legendFontFamily??e.typography.fontFamily,legendFontWeight:e.typography.legendFontWeight,titleFontSize:e.typography.titleFontSize??e.typography.titleSize,titleFontFamily:e.typography.titleFontFamily??e.typography.fontFamily,titleFontWeight:e.typography.titleFontWeight??"bold",tickFontFamily:e.typography.tickFontFamily??e.typography.fontFamily}}function Lr(e,t,i,r,o){let n=Array.isArray(o)?o:o?[o]:[];if(!1!==i||0!==n.length)return({size:o})=>{let a=[Number(o[0])||700,Number(o[1])||420],s=Re(a),l=Math.max(2,Math.round(t)),c=s.plot.width/l,u=s.plot.y+s.plot.height,d=Math.max(1,...e.map(e=>e.value)),h=!1!==i,[p,f]=r?.valueExtent??[0,l],y=f===p?1:f-p,g=e.map((e,t)=>{let i=u-e.value/d*s.plot.height*.9;return`${0===t?"M":"L"} ${(s.plot.x+(t+.5)*c).toFixed(1)} ${i.toFixed(1)}`}).join(" ");return My("svg",{"aria-hidden":"true","data-testid":"galton-board-structure-overlay",width:a[0],height:a[1],viewBox:`0 0 ${a[0]} ${a[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[h?My(Ay,{children:[Array.from({length:l+1},(e,t)=>{let i=s.plot.x+t*c;return Sy("line",{"data-testid":"galton-board-bin-wall",x1:i,x2:i,y1:s.plot.y,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.28,strokeWidth:1},"bin-wall-"+t)}),Sy("line",{x1:s.plot.x,x2:s.plot.x+s.plot.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),Sy("path",{d:g,fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.7,strokeWidth:2,strokeLinejoin:"round"}),e.map((e,t)=>e.value>0?Sy("text",{x:s.plot.x+(t+.5)*c,y:Math.max(s.plot.y+10,u-e.value/d*s.plot.height*.9-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:e.value},`${e.label}-${t}`):null)]}):null,n.map((e,t)=>{let i=Number(e.value);if(!Number.isFinite(i))return null;let r=s.plot.x+Math.max(0,Math.min(1,(i-p)/y))*s.plot.width,o=e.color??"var(--semiotic-warning, #f28e2b)",n="bottom"===e.labelPosition?Math.min(a[1]-8,u+16):s.plot.y+16;return My("g",{className:e.className,"data-testid":"galton-board-reference-line",children:[Sy("line",{x1:r,x2:r,y1:s.plot.y+8,y2:u-4,stroke:o,strokeDasharray:e.strokeDasharray??"6 5",strokeWidth:e.strokeWidth??2}),null==e.label?null:Sy("text",{x:Math.min(s.plot.x+s.plot.width-4,r+6),y:n,fill:o,fontSize:10,fontWeight:700,children:e.label})]},`galton-reference-${t}-${i}`)})]})}}function Cr(e,t,i){if(!1!==i&&t)return({size:i})=>{let r=[Number(i[0])||760,Number(i[1])||360],o=Re(r),n=Math.max(1,t.windowCount),a=t.plot??o.plot,s=t.gutter??{x:a.x,y:a.y,width:0,height:a.height},l=t.windowPlot??a,c=l.width/n,u=a.y+a.height,d=a.y+.48*a.height,h=t.lidSegments[0]?.y1??d,p=t.windowStart,f=t.windowStart+n*t.windowSize,y=l.x+Math.max(0,Math.min(1,f===p?0:(t.watermarkValue-p)/(f-p)))*l.width;return My("svg",{"aria-hidden":"true","data-testid":"event-drop-window-overlay",width:r[0],height:r[1],viewBox:`0 0 ${r[0]} ${r[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[Sy("rect",{x:a.x,y:a.y,width:a.width,height:a.height,fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeOpacity:.7,strokeWidth:1}),s.width>0?My("g",{children:[Sy("rect",{x:s.x,y:h,width:s.width,height:u-h,fill:"var(--semiotic-danger, #e15759)",fillOpacity:.07}),My("text",{x:s.x+s.width/2,y:h-8,textAnchor:"middle",fill:"var(--semiotic-danger, #e15759)",fontSize:10,fontWeight:700,children:[t.lateCount," late"]})]}):null,Array.from({length:n},(i,o)=>{let n=e[o],a=l.x+o*c,s=t.closedWindowCount>o;return My("g",{children:[Sy("rect",{x:a,y:d,width:c,height:u-d,fill:s?"var(--semiotic-danger, #e15759)":"var(--semiotic-primary, #4e79a7)",fillOpacity:s?.08:.06}),s?t.lidSegments.filter(e=>e.windowIndex===o).map(e=>Sy("line",{x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2,stroke:"var(--semiotic-danger, #e15759)",strokeOpacity:.78,strokeWidth:2,strokeLinecap:"round"},e.id)):null,Sy("text",{x:a+c/2,y:d-8,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:n?.value??0}),Sy("text",{x:a+c/2,y:Math.min(r[1]-8,u+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:n?.label??""})]},"window-"+o)}),t.windowWalls?.map(({id:e,...t})=>Sy("rect",{...t,fill:"var(--semiotic-border, #d1d5db)",fillOpacity:.68},e)),t.lidSegments.filter(e=>null==e.windowIndex).map(e=>Sy("line",{x1:e.x1,x2:e.x2,y1:e.y1,y2:e.y2,stroke:"var(--semiotic-danger, #e15759)",strokeOpacity:.62,strokeWidth:2,strokeLinecap:"round"},e.id)),Sy("line",{x1:a.x,x2:a.x+a.width,y1:u,y2:u,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1.5}),Sy("line",{"data-testid":"event-drop-watermark",x1:y,x2:y,y1:a.y+8,y2:u,stroke:"var(--semiotic-warning, #f28e2b)",strokeDasharray:"5 4",strokeWidth:2}),My("text",{x:Math.min(a.x+a.width-4,y+6),y:a.y+16,fill:"var(--semiotic-warning, #f28e2b)",fontSize:10,fontWeight:700,children:["watermark ",Math.round(100*t.watermarkValue)/100]})]})}}function Tr(e,t,i,r=1){if(!1!==i&&0!==e.length)return({size:i})=>{let o=[Number(i[0])||700,Number(i[1])||380],n=Re(o),a=jt(n.plot,e.length,t),s=n.plot.y+n.plot.height;return My("svg",{"aria-hidden":"true","data-testid":"physics-pile-projection-overlay",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[Sy("line",{x1:n.plot.x,x2:n.plot.x+n.plot.width,y1:s,y2:s,stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:1}),e.map((e,t)=>{let i=Math.min(n.plot.height,a.pileHeight(e.value/r)),l=a.tubeWidth,c=a.centerX(t),u=s-i;return My("g",{children:[Sy("rect",{x:c-l/2,y:u,width:l,height:i,rx:3,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.08,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.42,strokeWidth:1,strokeDasharray:"4 3"}),Sy("text",{x:c,y:Math.max(n.plot.y+12,u-6),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:11,fontWeight:700,children:e.value}),Sy("text",{x:c,y:Math.min(o[1]-8,s+16),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${t}`)}),Sy("text",{x:o[0]/2,y:o[1]-2,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:`Full circle = ${r}; partial circles scaled by area`})]})}}function Or(e){return e.toLocaleString(void 0,Math.abs(e)>=1e3||.01>Math.abs(e)?{maximumFractionDigits:0}:{maximumFractionDigits:2})}function Fr(e,t){if(!1!==t&&e)return({size:t})=>{let i=[Number(t[0])||700,Number(t[1])||360],r=Re(i),o=r.plot.y+r.plot.height,[n,a]=e.xExtent,s=n+(a-n)/2,l=[{label:Or(n),x:e.xRange[0]},{label:Or(s),x:e.xRange[0]+(e.xRange[1]-e.xRange[0])/2},{label:Or(a),x:e.xRange[1]}];return My("svg",{"aria-hidden":"true","data-testid":"collision-swarm-projection-overlay",width:i[0],height:i[1],viewBox:`0 0 ${i[0]} ${i[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[e.groups.some(e=>e.overlapping)?Sy("text",{"data-testid":"collision-swarm-overlap-warning",x:r.plot.x,y:Math.max(10,r.plot.y-9),fill:"var(--semiotic-warning, #b45309)",fontSize:10,children:360>i[0]?"Points overlap":"Points overlap. Reduce radius or increase height."}):null,e.groups.map(e=>My("g",{children:[Sy("line",{x1:r.plot.x,x2:r.plot.x+r.plot.width,y1:e.y,y2:e.y,stroke:"var(--semiotic-border, #d1d5db)",strokeDasharray:"3 5",strokeWidth:1}),Sy("text",{x:r.plot.x+4,y:e.y-7,fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:e.label}),My("text",{x:r.plot.x+r.plot.width-4,y:e.y-7,textAnchor:"end",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:["n=",e.count,e.overlapping?" · overlaps":""]})]},e.label)),Sy("line",{x1:e.xRange[0],x2:e.xRange[1],y1:o,y2:o,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),l.map(e=>My("g",{children:[Sy("line",{x1:e.x,x2:e.x,y1:o,y2:o+5,stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1}),Sy("text",{x:e.x,y:Math.min(i[1]-8,o+18),textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,children:e.label})]},`${e.label}-${e.x}`))]})}}function Dr(e,t,i){return Math.max(t,Math.min(i,e))}function Er(e){return 6.2*e.length}function Nr(e,t,i="auto"){let r=Math.max(1,Math.floor(t/6.2)),o="compact"===i||"full"!==i&&Er(e)>t?function(e,t){let i=e.trim();if(t>=i.length)return i;if(1>=t)return i.slice(0,1);let r=i.split(/\s+/).filter(Boolean).map(e=>e[0]).join("").toUpperCase();return r.length>1&&t>=r.length?r:t>3?i.slice(0,Math.max(1,t-2))+"..":i.slice(0,t).toUpperCase()}(e,r):e;return{text:o,textLength:Er(o)>t?Math.max(4,t):void 0}}function zr(e,t,i={},r){if(!1===t||!e)return;let{volume:o,stages:n,groups:a,groupCompletion:s}=e,l=new Map(o.stages.map(e=>[e.id,e])),c=new Map(s.map(e=>[e.id,e]));return({size:e})=>{let t=Number(e[0])||o.width,s=Number(e[1])||o.height,u=n.map(e=>{let t=l.get(e.id),r=i["process-stage-"+e.id];return{id:e.id,label:e.label,x0:t?.x0??e.x-e.width/2,x1:(t?.x0??e.x-e.width/2)+(t?.width??e.width),x:e.x,width:t?.width??e.width,count:e.count,capacity:e.capacity,absorb:e.absorb,portalTarget:e.portalTarget,queueDepth:r?.queueDepth,processed:r?.processedCount}}),d=a.map(e=>{let t=c.get(e.id);return{id:e.id,label:e.label??e.id,x:e.anchor?.x??e.x??0,y:e.anchor?.y??e.y??0,absorbed:t?.absorbed,total:t?.total,complete:t?.complete}});return function(e,t={}){let{showFlowSpine:i=!0,showStageCounts:r=!0,showCapacityBadges:o=!0,showGroupSockets:n=!0,stageLabelMode:a="auto",outlineStages:s=!1,testId:l="process-flow-chrome"}=t,{width:c,height:u,left:d,right:h,topY:p,bottomY:f,midY:y,stages:g,groups:m=[]}=e,x=f-p;return Py("svg",{"aria-hidden":"true","data-testid":l,"data-outline-stages":s?"true":void 0,width:c,height:u,viewBox:`0 0 ${c} ${u}`,style:{position:"absolute",inset:0,pointerEvents:"none"},className:["semiotic-process-chrome",s?"semiotic-process-chrome--outline-stages":null].filter(Boolean).join(" "),children:[_y("defs",{children:Py("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[_y("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),_y("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),_y("rect",{x:0,y:0,width:c,height:u,fill:"url(#semiotic-process-floor)"}),_y("rect",{x:d-6,y:p-8,width:h-d+12,height:x+16,rx:14,fill:"var(--semiotic-process-lane, var(--semiotic-surface, #111827))",fillOpacity:.45,stroke:"var(--semiotic-process-border, var(--semiotic-border, #334155))",strokeOpacity:.95}),i?_y("line",{x1:d+8,x2:h-8,y1:y,y2:y,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,g.map((e,t)=>{let i=function(e){return e.absorb?"absorb":e.portalTarget?"portal":null!=e.capacity?"capacity":"flow"}(e),n=Iy[i],l=Math.max(12,e.width-8),c=Dr(l-8,22,88),d=Nr(e.label,Math.max(8,c-10),a),h="none"!==a&&l-8>=22,m=function(e){if(null!=e.capacity){let t=null!=e.queueDepth?" · q "+e.queueDepth:"";return e.capacityLabel?`${e.capacityLabel}${t}`:`cap ${Number.isInteger(e.capacity)?e.capacity+"":e.capacity.toFixed(1)}${t}`}return e.absorb?"absorb":e.portalTarget?"portal":"flow"}(e),b=Nr(m,Math.max(16,l-10),"auto"),v=o&&!1!==e.showBadge&&l>=32,w=null!=e.count?`n=${e.count}${null!=e.processed?" done "+e.processed:""}`:"",k=Nr(w,Math.max(16,l-8),"auto"),A=Math.max(30,p-15),S=A-13;return Py("g",{"data-stage":e.id,"data-role":i,children:[_y("rect",{className:"semiotic-process-chrome__stage-bay",x:e.x0+4,y:p+6,width:l,height:x-12,rx:10,fill:s?"none":n.fill,stroke:n.stroke,strokeWidth:s?1.85:"flow"===i?1:1.6}),g.length-1>t?_y("polygon",{points:`${e.x1-2},${y-7} ${e.x1+8},${y} ${e.x1-2},${y+7}`,fill:n.accent,opacity:.85}):null,h?Py($y,{children:[_y("rect",{className:"semiotic-process-chrome__stage-label-bg",x:e.x-c/2,y:S,width:c,height:18,rx:9,fill:"var(--semiotic-bg, #0f172a)",fillOpacity:.75,stroke:n.stroke}),Py("text",{x:e.x,y:A,textAnchor:"middle",fill:n.accent,fontSize:10,fontWeight:800,className:"semiotic-process-chrome__stage-label",textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[_y("title",{children:e.label}),d.text]})]}):null,v?Py("text",{x:e.x,y:p+22,textAnchor:"middle",fill:"var(--semiotic-process-muted, var(--semiotic-text-secondary, #94a3b8))",fontSize:9,fontWeight:700,textLength:b.textLength,lengthAdjust:b.textLength?"spacingAndGlyphs":void 0,children:[_y("title",{children:m}),b.text]}):null,r&&null!=e.count?Py("text",{x:e.x,y:Math.min(u-8,f+16),textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #e2e8f0))",fontSize:11,fontWeight:800,textLength:k.textLength,lengthAdjust:k.textLength?"spacingAndGlyphs":void 0,children:[_y("title",{children:w}),k.text]}):null]},e.id)}),n?m.map((e,t)=>{let i=e.total??0,r=e.absorbed??0,o=e.complete??(i>0&&r>=i),n=!o&&i>0&&r/i>=.75,a=o?"rgba(52, 211, 153, 0.35)":n?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",s=o?"#34d399":n?"#fbbf24":"var(--semiotic-border, #64748b)",l=i>0?`${r}/${i}${o?" shipped":n?" almost":""}`:"feature "+(t+1),c=Dr(Math.max(54,Er(e.label)+18,Er(l)+16),54,104),u=Nr(e.label,c-12,"auto"),d=Nr(l,c-12,"auto");return Py("g",{"data-group":e.id,children:[_y("rect",{x:e.x-c/2,y:e.y-22,width:c,height:44,rx:10,fill:a,stroke:s,strokeWidth:1.5}),Py("text",{x:e.x,y:e.y-4,textAnchor:"middle",fill:"var(--semiotic-process-text, var(--semiotic-text, #f8fafc))",fontSize:10,fontWeight:800,textLength:u.textLength,lengthAdjust:u.textLength?"spacingAndGlyphs":void 0,children:[_y("title",{children:e.label}),u.text]}),Py("text",{x:e.x,y:e.y+12,textAnchor:"middle",fill:s,fontSize:9,fontWeight:700,textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[_y("title",{children:l}),d.text]})]},e.id)}):null]})}({width:t,height:s,left:o.left,right:o.right,topY:o.topY,bottomY:o.bottomY,midY:o.midY,stages:u,groups:d},{showCapacityBadges:!0,showGroupSockets:!0,...r})}}function Br(e,t,i){if(!1===i||!t||0===e.length)return;let r=new Map(t.volume.stages.map(e=>[e.id,e]));return({size:i})=>{let o=[Number(i[0])||t.volume.width,Number(i[1])||t.volume.height],n=Re(o),a=Math.max(1,...e.map(e=>e.value)),s=Math.min(48,.18*n.plot.height),l=n.plot.y+6;return Ry("svg",{"aria-hidden":"true","data-testid":"process-flow-projection-overlay",width:o[0],height:o[1],viewBox:`0 0 ${o[0]} ${o[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:t.stages.map((t,i)=>{let o=e[i];if(!o)return null;let n=r.get(t.id);if(!n)return null;let c=Math.max(2,o.value/a*s),u=Math.max(8,.35*n.width);return Ry("rect",{x:n.x-u/2,y:l,width:u,height:c,rx:2,fill:"var(--semiotic-primary, #4e79a7)",fillOpacity:.18,stroke:"var(--semiotic-primary, #4e79a7)",strokeOpacity:.45,strokeWidth:1},t.id)})})}}function jr(e){return e.map((e,t)=>`${0===t?"M":"L"} ${e.x} ${e.y}`).join(" ")}function Wr(e,t){let{showNodeLabels:i,showSensors:r,showStaticFlow:o}=t;if(e&&(o||r||i))return({size:t})=>{let n=[Number(t[0])||760,Number(t[1])||420],a=Math.max(1,...e.links.map(e=>e.throughput)),s=new Set(e.nodes.map(e=>e.sensorId));return Cy("svg",{"aria-hidden":"true","data-testid":"physical-flow-static-flow-overlay",width:n[0],height:n[1],viewBox:`0 0 ${n[0]} ${n[1]}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[o?e.links.map(e=>{let t=3+e.throughput/a*16,i=e.path[Math.floor(e.path.length/2)];return Cy("g",{children:[Ly("path",{d:jr(e.path),fill:"none",stroke:"var(--semiotic-border, #d1d5db)",strokeWidth:t+5,strokeLinecap:"round",strokeLinejoin:"round",opacity:.26}),Ly("path",{d:jr(e.path),fill:"none",stroke:"var(--semiotic-primary, #4e79a7)",strokeWidth:t,strokeLinecap:"round",strokeLinejoin:"round",opacity:.16}),i?Ly("text",{x:i.x,y:i.y-t/2-5,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #555)",fontSize:10,fontWeight:700,children:(r=e.throughput,r.toLocaleString(void 0,1e3>Math.abs(r)?{maximumFractionDigits:1}:{maximumFractionDigits:0}))}):null]},e.id);var r}):null,e.nodes.map(e=>Cy("g",{children:[r&&s.has(e.sensorId)?Ly("rect",{"data-testid":"physical-flow-sensor-overlay",x:e.x-12,y:e.y-12,width:24,height:24,rx:4,fill:"none",stroke:"var(--semiotic-warning, #f59e0b)",strokeDasharray:"3 3",strokeWidth:1.5,opacity:.88}):null,o?Ly("circle",{cx:e.x,cy:e.y,r:6,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text-secondary, #555)",strokeWidth:1.2}):null,i?Ly("text",{x:e.x,y:e.y-14,textAnchor:"middle",fill:"var(--semiotic-text, #111827)",fontSize:11,fontWeight:800,children:e.label}):null]},e.id))]})}}function Yr({layout:e,compact:t,showLabels:i}){let r=t?Math.round(.14*e.height):Math.max(80,e.routeY-180),o=t?Math.max(6,Math.round(.72*e.height)):Math.min(360,e.height-170);return Oy(Ty,{children:e.gates.map(n=>Fy("g",{children:[Oy("rect",{x:n.x-n.width/2,y:r,width:n.width,height:o,rx:t?2:12,fill:n.color??"var(--semiotic-primary, #38bdf8)",fillOpacity:.1,stroke:n.color??"var(--semiotic-primary, #38bdf8)",strokeDasharray:"5 5",strokeOpacity:.7}),i?Oy("text",{x:n.x,y:Math.max(64,e.routeY-196),fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:n.label??n.id}):null]},n.id))})}function qr({layout:e,states:t,compact:i=!1}){return i?Oy("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:Oy(Yr,{layout:e,compact:!0,showLabels:!1})}):Fy("svg",{"aria-hidden":"true",viewBox:`0 0 ${e.width} ${e.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[Oy("path",{d:`M ${e.startX-42} ${e.routeY} C ${.24*e.width} ${e.routeY-70}, ${.42*e.width} ${e.routeY+78}, ${.58*e.width} ${e.routeY} S ${.78*e.width} ${e.routeY-82}, ${e.socketX+36} ${e.routeY}`,fill:"none",stroke:"var(--semiotic-primary, #38bdf8)",strokeDasharray:"18 12",strokeLinecap:"round",strokeOpacity:.45,strokeWidth:7}),Oy("line",{x1:Math.round(.06*e.width),x2:Math.round(.94*e.width),y1:e.crashY,y2:e.crashY,stroke:"var(--semiotic-danger, #ef4444)",strokeDasharray:"3 7",strokeOpacity:.64}),Oy("text",{x:Math.round(.07*e.width),y:e.crashY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:9,fontWeight:800,children:"CRASH LINE"}),Oy(Yr,{layout:e,compact:!1,showLabels:!0}),Fy("g",{children:[Oy("rect",{x:e.socketX-52,y:e.routeY-56,width:104,height:112,rx:13,fill:"var(--semiotic-success, #22c55e)",fillOpacity:.12,stroke:"var(--semiotic-success, #22c55e)",strokeWidth:1.5}),Oy("text",{x:e.socketX,y:e.routeY-72,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"SOCKET"})]}),Fy("g",{children:[Oy("rect",{x:e.graveyardX-82,y:e.graveyardY-34,width:164,height:58,rx:11,fill:"var(--semiotic-danger, #ef4444)",fillOpacity:.16,stroke:"var(--semiotic-danger, #ef4444)",strokeOpacity:.7}),Oy("text",{x:e.graveyardX,y:e.graveyardY-8,fill:"var(--semiotic-danger, #ef4444)",fontSize:10,fontWeight:800,textAnchor:"middle",children:"GRAVEYARD"}),Oy("text",{x:e.graveyardX,y:e.graveyardY+12,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,textAnchor:"middle",children:t.some(e=>e.killed)?"lift shut off":"too heavy or too small"})]})]})}function Xr({states:e,layout:t}){let i=function(e){return e.map(e=>({label:e.id,value:Math.max(0,Number(e.viability)||0),outcome:e.outcome||e.stage||"in-process"}))}(e);if(!i.length)return null;let r=Math.max(1,...i.map(e=>e.value)),o=Math.max(40,(t.width-80)/i.length);return Fy("svg",{"aria-hidden":"true","data-testid":"gauntlet-projection-overlay",width:t.width,height:t.height,viewBox:`0 0 ${t.width} ${t.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},children:[Oy("text",{x:36,y:18,fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:800,children:"SETTLED · viability / outcome"}),i.map((e,t)=>{let i=40+t*o,n=Math.max(2,e.value/r*28),a=/kill|crash|block|grave/i.test(e.outcome);return Fy("g",{children:[Oy("rect",{x:i+.18*o,y:28-n+22,width:Math.max(10,.45*o),height:n,rx:2,fill:a?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",fillOpacity:.35,stroke:a?"var(--semiotic-danger, #ef4444)":"var(--semiotic-success, #16a34a)",strokeOpacity:.55,strokeWidth:1}),Oy("text",{x:i+.4*o,y:62,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #64748b)",fontSize:9,fontWeight:700,children:e.label})]},e.label)})]})}function Gr(e){return e.map(e=>({...e,spawnAt:void 0}))}function Vr(e,t){return e?t?i=>Op.createElement(Op.Fragment,null,"function"==typeof e?e(i):e,"function"==typeof t?t(i):t):e:t}function Hr(e,t,i){let r=t[i];return"boolean"==typeof r?r:!0!==e.__compactMode}function Ur(e){let t=2166136261;for(let i=0;e.length>i;i+=1)t^=e.charCodeAt(i),t=Math.imul(t,16777619);return Ey[(t>>>0)%Ey.length]}function Kr(e){return e&&{fields:["nodeId"],..."object"==typeof e?e:{name:"string"==typeof e?e:"hover"}}}function Zr(e){let t=e.roles.occurrence;return"string"==typeof t?[t]:e.entityIds}function Qr(e,t=[],i){let r=void 0===i?void 0:new Set("string"==typeof i?[i]:i),o=t.filter(e=>!e.missingPrehistory&&void 0!==e.partition&&r?.has(e.partition)),n=new Set(o.map(e=>e.id)),a=new Set(o.map(e=>e.entityId)),s=new Map,l=0;for(let t of e){if(void 0!==i&&"string"==typeof t.roles.occurrence&&!n.has(t.roles.occurrence))continue;let e=Object.entries(t.entityWeights);0===e.length&&void 0===i&&(l+=t.entityCount);for(let[t,r]of e)(void 0===i||a.has(t))&&s.set(t,r)}return[...s.values()].reduce((e,t)=>e+t,l)}function Jr(e,t){return e.slice(0,t+1).map(e=>e.replaceAll("%","%25").replaceAll(">","%3E")).join(">")}function eo(e,t,i){return e.entries.find(e=>e.measureId===t&&e.subjectId===i)}function to(e,t,i){return 0===i||1e4*e%i!=0?Math.round((t-e)/Math.max(i,1)*1e4):1e4*(t-e)/i}function io(e,t={}){let i=t.templates??["repeated-state-episode"],r="ordinal"===e.spec.coordinate.kind?e.spec.coordinate.sectionIds:[],o=void 0!==t.partition?function(e,t){let i=e.spec.comparison?.denominatorMeasureId??e.spec.motifs.denominatorRef??"assigned";return eo(e.ledger,i,t)?.value}(e,t.partition)??0:e.spec.comparison?e.comparison?.rows.reduce((e,t)=>e+t.assigned,0)??0:e.ledger.entries.find(t=>"global"===t.subjectKind&&t.measureId===e.spec.motifs.denominatorRef)?.value??0,n=i=>Qr(i,e.source.occurrences,t.partition??e.spec.comparison?.partitions),a=[],s=e.motifs.incompleteCandidates.length>0;for(let l of i)for(let i of r){let r=e.motifs.matches.filter(e=>e.template===l),c=n(r.filter(e=>e.completionSectionId===i)),u=n(r.filter(e=>e.intersectSectionIds.includes(i)));a.push({template:l,sectionId:i,partition:t.partition,completionCount:c,intersectionCount:u,denominator:o,status:s?"incomplete":"exact"})}return{templates:i,sections:r,cells:a}}function ro(e){return e.entityCount??1}function oo(e){if(!e.missingPrehistory)return{id:"group:"+e.id,occurrenceId:e.id,partition:e.partition,nodePath:e.nodePath,entityCount:ro(e),...e.stepEntityCounts&&{stepEntityCounts:[...e.stepEntityCounts]},signature:Jr(e.nodePath,e.nodePath.length-1)}}function no(e){let t=1/0,i=-1/0;for(let r of e)t>r&&(t=r),r>i&&(i=r);return[t,i]}function ao(e,t=-1/0){let i=t;for(let t of e)t>i&&(i=t);return i}function so(e,t){if(0===e.length)return"";if(1===e.length)return`M${e[0].x},${e[0].y}`;let i=Math.max(0,t),r=`M${e[0].x},${e[0].y}`;for(let t=1;e.length-1>t;t+=1){let o=e[t-1],n=e[t],a=e[t+1],s=Math.hypot(n.x-o.x,n.y-o.y),l=Math.hypot(a.x-n.x,a.y-n.y),c=Math.min(i,s/2,l/2);if(.001>=c){r+=` L${n.x},${n.y}`;continue}let u={x:n.x+(o.x-n.x)/s*c,y:n.y+(o.y-n.y)/s*c},d={x:n.x+(a.x-n.x)/l*c,y:n.y+(a.y-n.y)/l*c};r+=` L${u.x},${u.y} Q${n.x},${n.y} ${d.x},${d.y}`}let o=e[e.length-1];return`${r} L${o.x},${o.y}`}function lo(e,t,i){if(2>e.length)return"";let r=function(e){let t=[e[0]];for(let i=1;e.length-1>i;i++){let r=e[i-1],o=e[i],n=e[i+1],a=Hy(r,o),s=Hy(o,n),l=Math.min(8,a/2,s/2);if(0===l)continue;let c=Vy(o,r,l/a),u=Vy(o,n,l/s);t.push(c);for(let e=1;12>=e;e++){let i=e/12;t.push(Vy(Vy(c,o,i),Vy(o,u,i),i))}}return t.push(e[e.length-1]),t.filter((e,i)=>0===i||Hy(t[i-1],e)>1e-8)}(e);if(2>r.length)return"";let o=[0];for(let e=1;r.length>e;e++)o.push(o[e-1]+Hy(r[e-1],r[e]));let n=o[o.length-1],a=function(e){if(2>e.length)return e.map(e=>({...e}));let t=(e,t)=>{let i=t.x-e.x,r=t.y-e.y,o=Math.hypot(i,r)||1;return{x:-r/o,y:i/o}};return e.map((i,r)=>{let o=r>0?t(e[r-1],i):null,n=e.length-1>r?t(i,e[r+1]):null;if(!o||!n){let e=n??o??{x:0,y:0};return{x:i.x+1*e.x,y:i.y+1*e.y}}let a=o.x+n.x,s=o.y+n.y,l=Math.hypot(a,s);if(.001>l)return{x:i.x+1*n.x,y:i.y+1*n.y};a/=l,s/=l;let c=a*n.x+s*n.y;if(.001>Math.abs(c))return{x:i.x+1*n.x,y:i.y+1*n.y};let u=Math.max(-4,Math.min(4,1/c));return{x:i.x+a*u,y:i.y+s*u}})}(r),s=[1,-1].map(e=>r.map((r,s)=>Vy(r,a[s],e*(t+(i-t)*o[s]/n)/2)));return[...s[0],...s[1].reverse()].map((e,t)=>`${0===t?"M":"L"}${e.x},${e.y}`).join(" ")+" Z"}function co(e){let t=-(e.reduce((e,t)=>e+t,0)+3*(e.length-1))/2;return e.map(e=>{let i=t+e/2;return t+=e+3,i})}function uo(e){let t="";return e.split(">").map((e,i)=>t=i?`${t}>${e}`:e)}function ho(e,t){let i=new Set,r=[t];for(;r.length;){let t=r.pop();if(i.has(t))continue;i.add(t);let o=e.children[t];Array.isArray(o)&&r.push(...o)}return i}function po(e,t,i,r,o,n=og,a){let s=Object.values(t.entry.nodes).map(e=>e.queued??0),l=Math.max(1,...s);return e.modules.map(e=>{let{module:s,x:c,y:u,width:d,height:h,queue:p}=e,f=t.entry.nodes[s.nodeId],y=o===s.nodeId?i:(f.queued??0)>0?n.alarm:n.muted,g=c+d/2,m="records"===s.semantics.unit?"rec":"attempts"===s.semantics.unit?"att":"roots",x=null!==f.capacity?`${ng(f.completions)} / ${ng(f.capacity)} ${m}/s`:null!==f.completions?`${ng(f.completions)} ${m}/s complete`:`${ng(f.arrivals)} ${m}/s offered`;return rg("g",{key:s.id,"data-circuit-module":s.nodeId,"data-module-kind":s.kind,opacity:a?.(s.nodeId),"data-queued":f.queued??"unmeasured"},rg("rect",{x:c,y:u,width:d,height:h,fill:"none",stroke:y,strokeWidth:o===s.nodeId?2.5:1}),rg("path",{d:ag[s.kind],transform:`translate(${c+10},${u+12})`,stroke:y,fill:"none",strokeWidth:1.4}),rg("text",{x:g+5,y:u+16,textAnchor:"middle",fontSize:110>d?9:11,fontWeight:600,fill:r},s.semantics.label),rg("text",{x:g,y:u+28,textAnchor:"middle",fontSize:8,fill:r},sg[s.kind]),rg("text",{x:g,y:u+41,textAnchor:"middle",fontSize:110>d?7:9,fill:r},x),rg("text",{x:g,y:u+h-13,textAnchor:"middle",fontSize:8,fill:r},"Queue "+ng(f.queued)),null!==f.queued?rg("rect",{...p,width:p.width*f.queued/l,fill:y,"data-circuit-gauge":"queue"}):null,rg("rect",{...e.sensor,fill:i,"data-circuit-sensor":s.nodeId}),s.semantics.dependencyNodeIds?.length?rg("text",{x:g,y:u-8,fontSize:8,textAnchor:"middle",fill:r,"data-circuit-dependency":s.nodeId},"Requires "+s.semantics.dependencyNodeIds.join(", ")):null)})}function fo(e,t,i,r,o,n){let{history:a}=e,s=e.modules.find(e=>e.module.nodeId===n)?.module,l="records"===t.unit?"queued":"attempts",c=t.entries.map(e=>s?e.nodes[s.nodeId]["records"===t.unit?"queued":"arrivals"]:e.totals[l]),u=Math.max(1,...c.map(e=>e??0)),d=t.entries[0].at,h=t.entries[t.entries.length-1].at,p=e=>a.x+(e-d)/Math.max(1,h-d)*a.width,f="",y=!1;for(let[e,i]of t.entries.entries()){if(null===c[e]){y=!1;continue}let t=a.y+a.height-c[e]/u*a.height;f+=`${y?" H":"M"}${p(i.at)}${y?" V"+t:","+t}`,y=!0}return rg("g",{"data-circuit-history":l,"data-history-module":s?.nodeId},rg("text",{x:a.x,y:a.y-9,fill:o,fontSize:10},s?`${s.semantics.label} · ${"queued"===l?"queued "+s.semantics.unit:`offered ${s.semantics.unit}/s`} · aggregate observations`:"queued"===l?"Queued records · aggregate observations":"Offered attempts/s · aggregate observations"),rg("path",{d:f,fill:"none",stroke:r,strokeWidth:2}),rg("line",{x1:p(i.observedAt),x2:p(i.observedAt),y1:a.y,y2:a.y+a.height,stroke:o,strokeDasharray:"3 3","data-circuit-cursor":i.observedAt}),...t.entries.map(e=>rg("text",{key:e.id,x:p(e.at),y:a.y+a.height+14,textAnchor:"middle",fontSize:9,fill:o},e.at+"s")))}function yo(e,t,i,r){return{id:r.nodeId,nodeId:r.nodeId,kind:"circuit-module",moduleKind:r.kind,label:r.semantics.label,unit:r.semantics.unit,sourceRevision:t.sourceRevision,analysisRevision:e.atlas.analysisRevision,relationScopeId:"directed-admitted",editionId:t.id,editionKind:t.kind,synthetic:t.synthetic,mode:i.mode,observedAt:i.observedAt,...i.entry.nodes[r.nodeId]}}function go(e,t,i,r){return[...t.modules.map(t=>{let o=yo(e,i,r,t.module);return{id:o.id,bodyId:o.id,datum:o,x:t.x+t.width/2,y:t.y+t.height/2,width:t.width,height:t.height,shape:"rect",label:`${o.label}: ${o.moduleKind}`,description:`${o.label}. ${i.kind} at ${r.observedAt}s. Arrivals ${lg(o.arrivals)} ${o.unit}/s; completions ${lg(o.completions)} ${o.unit}/s; installed capacity ${lg(o.capacity)} ${o.unit}/s; queue ${lg(o.queued)} ${o.unit}. Measurement status: ${o.status}. Individual timings unavailable.`,group:"circuit modules"}}),...t.routes.map(t=>{let o=r.entry.flows.find(e=>e.edgeId===t.edgeId),n=t.points[Math.floor(t.points.length/2)];return{id:"pipe:"+t.edgeId,x:n.x,y:n.y,shape:"path",pathData:t.pathD,label:`${t.source} → ${t.target}: ${lg(o.perSecond)} ${o.unit}/s`,description:`Original edge ${t.edgeId}. ${t.residual?"Residual link":"Display backbone"}. ${i.kind} at ${r.observedAt}s; transferred volume ${lg(o.perSecond)} ${o.unit}/s.`,group:"original pipes",datum:{id:t.edgeId,kind:"circuit-pipe",source:t.source,target:t.target,analysisRevision:e.atlas.analysisRevision,sourceRevision:i.sourceRevision,relationScopeId:"directed-admitted",editionId:i.id,editionKind:i.kind,observedAt:r.observedAt,...o}}})]}function mo(e,t,i,r){return{frameType:e.frameType,layout:{...e.layout,primarySize:{width:i[0],height:i[1]},...r&&{margin:r}},buildProps:(i,r,o,n,a)=>{let[s,l]=n.size,c=t({...a,...n,width:s,height:l,colorScheme:o});return e.buildProps(c.data,r,o,{...n,title:c.title,description:c.description,summary:c.summary,accessibleTable:c.accessibleTable},{...a,...c})}}}function xo(e,t,i){let r="function"==typeof t?t(e):e[(t??i)+""];if(null==r||"string"==typeof r&&""===r.trim())return null;let o=Number(r);return Number.isFinite(o)?o:null}function bo(e){if(!e)return gg;let t=!1;for(let i=0;e.length>i;i++){let r=e[i];if(null==r||"object"!=typeof r){t=!0;break}}if(!t)return e;let i=[];for(let t of e)null!=t&&"object"==typeof t&&i.push(t);return i}function vo(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}function wo(e,t){if(!vo(t))return e??((...e)=>({}));let i={};return void 0!==t.stroke&&(i.stroke=t.stroke),void 0!==t.strokeWidth&&(i.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(i.opacity=t.opacity),e?(...t)=>({...e(...t)||{},...i}):(...e)=>({...i})}function ko(e){let{lineWidth:t=2,colorBy:i,colorScale:r,color:o,resolveStroke:n,fillArea:a,areaOpacity:s=.3,styleRules:l,ruleContext:c}=e;return(e,u)=>{let d,h={strokeWidth:t},p=!0===a||Array.isArray(a)&&null!=u&&a.includes(u);return n?d=n(e,u):i?r&&(d=ai(e,i,r)):d=o||Ff,void 0!==d&&(h.stroke=d,p&&(h.fill=d,h.fillOpacity=s)),l?.length&&Object.assign(h,_e(e,l,c?c(e,u):{value:void 0,category:u})),h}}function Ao(e){if("A"===e.__diffWinner||"B"===e.__diffWinner)return e.__diffWinner;let t=(e.__diffSegment??"")+"";return"line-A"===t||t.endsWith("-A")?"A":"B"}function So(e,t){return Pe(e,t,e=>{let t=Number(e.__x),i=Number(e.__y);return{value:Number.isFinite(i)?i:void 0,x:Number.isFinite(t)?t:void 0,y:Number.isFinite(i)?i:void 0,category:Ao(e)}},e=>e.__sourceDatum?{...e.__sourceDatum,...e}:e)}function Mo(e){let{seriesAColor:t,seriesBColor:i,areaOpacity:r,styleRules:o}=e;return So(e=>({fill:"A"===Ao(e)?t:i,stroke:"none",fillOpacity:r}),o)}function $o(e){let{seriesAColor:t,seriesBColor:i,lineWidth:r,styleRules:o}=e;return So(e=>({stroke:"A"===Ao(e)?t:i,strokeWidth:r,fill:"none"}),o)}function _o(e,t=mg){if(e)return!0===e?t:"stops"in e?Array.isArray(e.stops)?e:void 0:"colorStops"in e?Array.isArray(e.colorStops)?{stops:e.colorStops.map(({offset:e,color:t})=>({offset:e,color:t}))}:void 0:{stops:[{offset:0,opacity:e.topOpacity??t.stops[0]?.opacity??.8},{offset:1,opacity:e.bottomOpacity??t.stops.at(-1)?.opacity??.05}]}}function Po(e){return e?_o(e):void 0}function Io(e,t,i){return"function"==typeof e?e(i):i[e||t]}function Ro(e){return e instanceof Date?e.getTime():Number(e)}function Lo(e,t){return bf(1===t?.5:e/(t-1))}function Co(e){let t={};return void 0!==e.stroke&&(t.stroke=e.stroke),void 0!==e.strokeWidth&&(t.strokeWidth=e.strokeWidth),void 0!==e.opacity&&(t.opacity=e.opacity),t}function To(e,t){let i=function(e){if(!e)return;let t="boolean"==typeof e?{}:"string"==typeof e?{method:e}:e;return{type:"trend",method:t.method??"linear",...null!=t.bandwidth&&{bandwidth:t.bandwidth},...null!=t.order&&{order:t.order},...null!=t.color&&{color:t.color},...null!=t.strokeWidth&&{strokeWidth:t.strokeWidth},...null!=t.strokeDasharray&&{strokeDasharray:t.strokeDasharray},...null!=t.label&&{label:t.label}}}(t),r=Array.isArray(e)?e:void 0;return i?[i,...r??[]]:r}function Oo(e){return e.axes??[{orient:"bottom",visible:!1!==e.showTimeAxis},{orient:"left",visible:!1!==e.showValueAxis}]}function Fo(e){return Math.round(100*e)/100}function Do(e,t=2){let i=[],r=[],o=t+1;for(let t=0;o>t;t++){let n=0;for(let[i,r]of e)null!==r&&(n+=i**t*r);i.push(n);let a=[];for(let i=0;o>i;i++){let r=0;for(let[o,n]of e)null!==n&&(r+=o**(t+i));a.push(r)}r.push(a)}r.push(i);let n=function(e,t){let i=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(i[e][o])>Math.abs(i[e][t])&&(t=o);for(let o=e;r+1>o;o++){let r=i[o][e];i[o][e]=i[o][t],i[o][t]=r}for(let t=e+1;r>t;t++)for(let o=r;o>=e;o--)i[o][t]-=i[o][e]*i[e][t]/i[e][e]}for(let e=r-1;e>=0;e--){let t=0;for(let n=e+1;r>n;n++)t+=i[n][e]*o[n];o[e]=(i[r][e]-t)/i[e][e]}return o}(r,o).map(Fo);return{points:e.map(([e])=>[Fo(e),Fo(n.reduce((t,i,r)=>t+i*e**r,0))]),equation:[...n].reverse()}}function Eo(e){let t=e.length,i=0,r=0,o=0,n=0;for(let[t,a]of e)i+=t,r+=a,o+=t*t,n+=t*a;let a=t*o-i*i;if(1e-12>Math.abs(a))return null;let s=(t*n-i*r)/a,l=(r-s*i)/t;return e=>l+s*e}function No(e,t){let i=e.length,r=e.map(([e,i])=>i-t(e)).reduce((e,t)=>e+t*t,0),o=Math.sqrt(r/Math.max(i-2,1)),n=e.reduce((e,t)=>e+t[0],0)/i,a=e.reduce((e,t)=>e+(t[0]-n)**2,0);return{se:o,meanX:n,ssX:a}}function zo(e){return.99>e?.95>e?.9>e?1:1.645:1.96:2.576}function Bo(e,t,i,r){let o=t.uncertaintyOpacity,n=t.confidenceAccessor;if(!o&&!n)return;let a="object"==typeof o?o:{},s=a.min??.15,l=a.max??1;if(n){let t="function"==typeof n?n:e=>e[n];for(let i of e){let e=t(i);null!=e&&Number.isFinite(e)&&(i[bg]=s+Math.max(0,Math.min(1,e))*(l-s))}return}let c=e.map(e=>{let t=i(e),o=r(e);return null!=t&&null!=o&&Number.isFinite(t)&&Number.isFinite(o)?Math.abs(t-o):NaN}),u=c.filter(e=>Number.isFinite(e));if(0===u.length)return;let[d,h]=no(u),p=h-d;e.forEach((e,t)=>{let i=c[t];Number.isFinite(i)&&(e[bg]=l-(p>0?(i-d)/p:0)*(l-s))})}function jo(e,t){return"function"==typeof t?t(e):!!e[t]}function Wo(e,t,i){let r=e[t],o=e[i];return null==r||null==o||Number.isNaN(r)||Number.isNaN(o)}function Yo(e){let t=e.xAccessor||"x",i=e.yAccessor||"y",r=e.lineBy,o=e.colorBy||r,n=Array.isArray(e.data)?bo(e.data).filter(e=>!!e&&"object"==typeof e):[],a=function(e,t,i){let r="function"==typeof t,o="function"==typeof i,n=r?vg:t,a=o?wg:i;return r||o?{xKey:n,yKey:a,rows:e.map(e=>{let n={...e};return r&&(n[vg]=t(e)),o&&(n[wg]=i(e)),n})}:{rows:e,xKey:n,yKey:a}}(n,t,i);n=a.rows;let s,l=a.xKey,c=a.yKey,u=Array.isArray(e.annotations)?[...e.annotations]:[],d="string"==typeof r||"function"==typeof r?r:void 0,h=e.baseLineStyle;if(e.forecast){let t=function(e,t,i,r,o){return(n=r).isTraining||n.isForecast||n.isAnomaly||n.upperBounds||n.lowerBounds?function(e,t,i,r,o){let{isTraining:n,isForecast:a,isAnomaly:s,upperBounds:l,lowerBounds:c,color:u="#6366f1",bandOpacity:d=.15,anomalyColor:h="#ef4444",anomalyRadius:p=6,label:f}=r,y=e.map(e=>{let t="observed";return a&&jo(e,a)?t="forecast":n&&jo(e,n)&&(t="training"),{...e,[xg]:t}}),g=r._groupBy,m=[];if(g){let e=new Map;for(let t of y){let i=t[g]??"__default";e.has(i)||e.set(i,[]),e.get(i).push(t)}let t=[];for(let[,i]of e)for(let e=0;i.length-1>e;e++)i[e][xg]!==i[e+1][xg]&&(t.push({...i[e+1],[xg]:i[e][xg]}),t.push({...i[e],[xg]:i[e+1][xg]}));m.push(...y,...t)}else for(let e=0;y.length>e;e++)m.push(y[e]),y.length-1>e&&y[e][xg]!==y[e+1][xg]&&(m.push({...y[e+1],[xg]:y[e][xg]}),m.push({...y[e],[xg]:y[e+1][xg]}));if(r.trainUnderline){let e=[];for(let t of m)"training"===t[xg]&&e.push({...t,[xg]:"training-base"});m.unshift(...e)}let x=[];if(l&&c){let e="string"==typeof l?l:"__envUpper",t="string"==typeof c?c:"__envLower";if("function"==typeof l||"function"==typeof c)for(let i of m)"function"==typeof l&&(i[e]=l(i)),"function"==typeof c&&(i[t]=c(i));x.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:u,fillOpacity:d,label:f})}if(r.uncertaintyOpacity||r.confidenceAccessor){let e=l?"function"==typeof l?l:e=>e[l]:()=>{},t=c?"function"==typeof c?c:e=>e[c]:()=>{};Bo(m.filter(e=>"forecast"===e[xg]),r,e,t)}if(s){let e=r.anomalyStyle,t={type:"highlight",filter:e=>jo(e,s)};e?(t.style=e,t.r=p):"function"==typeof h?(t.style=e=>{let t=h(e);return{stroke:t,strokeWidth:1.5,fill:t,fillOpacity:.7}},t.r=p):(t.color=h,t.r=p,t.style={stroke:h,strokeWidth:1.5,fill:h,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,i,r,o){let{trainEnd:n,steps:a=10,confidence:s=.95,color:l="#6366f1",bandOpacity:c=.15,label:u}=r;if(null==n)return{processedData:e,annotations:[]};let d=[],h=[];for(let i of e)i[t]>n?h.push({...i,[xg]:"observed"}):d.push({...i,[xg]:"training"});let p=d.map(e=>[e[t],e[i]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),f=[],y=[];if(p.length>=3){let o=p.length,n=Eo(p);if(n){let{se:d,meanX:h,ssX:g}=No(p,n),m=zo(s),x=ao(e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e))),b=p.length>1?(p[o-1][0]-p[0][0])/(o-1):1;for(let e=1;a>=e;e++){let r=x+e*b,a=n(r),s=d*Math.sqrt(1+1/o+(g>0?(r-h)**2/g:0))*m;y.push({[t]:r,[i]:a,[xg]:"forecast",__forecastUpper:a+s,__forecastLower:a-s})}Bo(y,r,e=>e.__forecastUpper,e=>e.__forecastLower),f.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:l,fillOpacity:c,label:u})}}f.push({type:"x-threshold",x:n,color:"#94a3b8",strokeWidth:1,strokeDasharray:"4,2",label:"Train / Forecast"}),o&&f.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});let g=[];if(g.push(...d),d.length>0&&h.length>0&&g.push({...d[d.length-1],[xg]:"observed"}),g.push(...h),y.length>0){let e=h.length>0?h[h.length-1]:d[d.length-1];e&&g.push({...e,[xg]:"forecast"}),g.push(...y)}return{processedData:g,annotations:f}}(e,t,i,r,o);var n}(n,l,c,r&&"string"==typeof r&&"object"==typeof e.forecast?{...e.forecast,_groupBy:r}:e.forecast,e.anomaly);if(n=t.processedData,u.push(...t.annotations),s=function(e,t,i){let r=i.upperBounds,o=i.lowerBounds;if(!r&&!o)return;let n="function"==typeof r?r:"string"==typeof r?e=>e[r]:null,a="function"==typeof o?o:"string"==typeof o?e=>e[o]:null,s=1/0,l=-1/0;for(let i of e){let e=Number(i[t]);if(Number.isFinite(e)&&(s>e&&(s=e),e>l&&(l=e)),n){let e=n(i);null!=e&&Number.isFinite(e)&&(e>l&&(l=e),s>e&&(s=e))}if(a){let e=a(i);null!=e&&Number.isFinite(e)&&(s>e&&(s=e),e>l&&(l=e))}}return Number.isFinite(s)&&Number.isFinite(l)?[s,l]:void 0}(n,c,e.forecast),r&&"string"==typeof r?(n=n.map(e=>({...e,[kg]:`${e[r]}__${e[xg]||"observed"}`})),d=kg):d=xg,e.baseLineStyle){let t=function(e,t){let i=t.trainDasharray??"8,4",r=t.forecastDasharray??"4,4",o=t.color||"#6366f1",n=t.trainOpacity,a=t.forecastOpacity,s=t.trainStroke,l=t.trainLinecap,c=t.trainUnderline;return t=>{let u=e(t),d=t[xg];if("training"===d){let e=u.stroke;return"darken"===s?e=function(e,t=.5){let i=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!i)return e;let r=Math.round(parseInt(i[1],16)*(1-t)),o=Math.round(parseInt(i[2],16)*(1-t)),n=Math.round(parseInt(i[3],16)*(1-t));return`#${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}(u.stroke||"#666",.5):s&&(e=s),{...u,stroke:e,strokeDasharray:i,...l&&{strokeLinecap:l},...null!=n&&{strokeOpacity:n}}}if("training-base"===d){let e=u.stroke||"#666";return"lighten"===c&&(e=function(e,t=.5){let i=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!i)return e;let r=Math.round(parseInt(i[1],16)+(255-parseInt(i[1],16))*t),o=Math.round(parseInt(i[2],16)+(255-parseInt(i[2],16))*t),n=Math.round(parseInt(i[3],16)+(255-parseInt(i[3],16))*t);return`#${r.toString(16).padStart(2,"0")}${o.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}`}(e,.4)),{...u,stroke:e,strokeDasharray:void 0}}if("forecast"===d){let e=t[bg]??a;return{...u,stroke:o,strokeDasharray:r,...null!=e&&{strokeOpacity:e}}}return u}}(t=>e.baseLineStyle(t),e.forecast);h=e=>t(e)}}else e.anomaly&&u.push(...(p=e.anomaly,[{type:"anomaly-band",threshold:p.threshold??2,showBand:!1!==p.showBand,fill:p.bandColor||"#6366f1",fillOpacity:p.bandOpacity??.1,anomalyColor:p.anomalyColor||"#ef4444",anomalyRadius:p.anomalyRadius??6,label:p.label}]));var p;if(e.gapStrategy){if("function"==typeof d){let e=d;n=n.map(t=>({...t,__semiotic_gapGroup:e(t)})),d="__semiotic_gapGroup"}let t=function(e,t,i,r,o){let n=new Map;for(let t of e){let e=o?(t[o]??"")+"":"__single";n.has(e)||n.set(e,[]),n.get(e).push(t)}if("interpolate"===t){let e=[];for(let[,t]of n)for(let o of t)Wo(o,i,r)||e.push(o);return{rows:e,groupKey:o}}if("zero"===t){let e=[];for(let[,t]of n)for(let o of t)Wo(o,i,r)?e.push({...o,[r]:0}):e.push(o);return{rows:e,groupKey:o}}let a=[],s="_gapSegment";for(let[e,t]of n){let o=0,n=[],l=()=>{if(0===n.length)return;let t="__single"===e?"__seg"+o:`${e}__seg${o}`;for(let e of n)a.push({...e,[s]:t});n=[],o++};for(let e of t)Wo(e,i,r)?l():n.push(e);l()}return{rows:a,groupKey:s}}(n,e.gapStrategy,l,c,"string"==typeof d?d:void 0);n=t.rows,t.groupKey&&(d=t.groupKey)}let f;if(e.directLabel){let t=function(e,t,i,r,o,n,a,s){if(!t||!i)return{annotations:[]};let l="object"==typeof t?t:{},c=l.position||"end",u=l.fontSize||11,d="function"==typeof i?i:e=>e[i],h=new Map;for(let t of e){let e=d(t);if(null==e)continue;let i=e+"";""!==i&&(h.has(i)||h.set(i,[]),h.get(i).push(t))}let p=new Map;for(let[e,t]of h)t.sort((e,t)=>Number(e[r])-Number(t[r])),p.set(e,"end"===c?t[t.length-1]:t[0]);let f=li(Array.from(p.entries()).map(([e])=>({__lbl:e})),"__lbl",n??a),y=Array.from(p.entries()).map(([e,t])=>({type:"text",label:e,[r]:t[r],[o]:t[o],dx:"end"===c?6:-6,dy:0,color:f?ai({__lbl:e},"__lbl",f):s||Ff,fontSize:u}));y.sort((e,t)=>Number(e[o])-Number(t[o]));for(let e=1;y.length>e;e++){let t=y[e-1],i=y[e],r=Number(t[o])+t.dy;u+2>Math.abs(Number(i[o])+i.dy-r)&&(i.dy+=u+2)}let 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}}}(n,e.directLabel,"string"==typeof o||"function"==typeof o?o:void 0,l,c,e.colorScheme,e.themeCategorical,e.color);u.push(...t.annotations),f=t.marginExtra}return{data:n,xAccessor:"function"==typeof t?l:t,yAccessor:"function"==typeof i?c:i,groupAccessor:d,colorAccessor:o,annotations:u,lineStyle:h,yExtent:s,marginExtra:f}}function qo(e,t,i,r,o){let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=Ir(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrScatterColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrScatterColorBy:t(e)})):n,u=t?li(c,l,s):void 0,d=o.sizeBy,h=Array.isArray(o.sizeRange)?o.sizeRange:[3,15],p=d?n.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],f=p.length?no(p):void 0,y=Ae(o.xAccessor,o.yAccessor),g=o.styleRules;return e=>{let i={fill:t&&u?ai(e,t,u):"string"==typeof o.color?o.color:Ff,fillOpacity:"number"==typeof o.pointOpacity?o.pointOpacity:.8,r:d?ci(e,d,h,f):"number"==typeof o.pointRadius?o.pointRadius:5};return g?.length&&Object.assign(i,_e(e,g,y(e))),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 Xo(e,t,i,r,o){let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=Ir(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrBubbleColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrBubbleColorBy:t(e)})):n,u=t?li(c,l,s):void 0,d=o.sizeBy,h=Array.isArray(o.sizeRange)?o.sizeRange:[5,40],p=d?n.map(e=>"function"==typeof d?d(e):Number(e[d])).filter(Number.isFinite):[],f=p.length?no(p):void 0,y=Ae(o.xAccessor,o.yAccessor),g=o.styleRules;return e=>{let i={fill:t&&u?ai(e,t,u):"string"==typeof o.color?o.color:Ff,fillOpacity:"number"==typeof o.bubbleOpacity?o.bubbleOpacity:.6,r:d?ci(e,d,h,f):h[0],stroke:o.bubbleStrokeColor??"white",strokeWidth:o.bubbleStrokeWidth??1};return g?.length&&Object.assign(i,_e(e,g,y(e))),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 Go(e,t){return t?.length&&Object.defineProperty(e,Lg,{configurable:!0,enumerable:!1,value:t}),e}function Vo(e){return e?.[Lg]}function Ho(e){return e.parentLine?Go({...e.parentLine,...e},Vo(e)):e}function Uo(e){return Go({...e[0]},e.map(Ho))}function Ko(e){return!!e&&Vo(e)?.[0]===e}function Zo(e){let t={"--semiotic-bg":e.colors.background,"--semiotic-text":e.colors.text,"--semiotic-text-secondary":e.colors.textSecondary,"--semiotic-grid":e.colors.grid,"--semiotic-border":e.colors.border,"--semiotic-cell-border":e.colors.cellBorder||e.colors.border,"--semiotic-primary":e.colors.primary,"--semiotic-font-family":e.typography.fontFamily,"--semiotic-secondary":e.colors.secondary||e.colors.primary,"--semiotic-surface":e.colors.surface||e.colors.background};e.colors.categorical.forEach((e,i)=>{t["--semiotic-category-"+(i+1)]=e}),e.colors.focus&&(t["--semiotic-focus"]=e.colors.focus),e.colors.selection&&(t["--semiotic-selection-color"]=e.colors.selection),null!=e.colors.selectionOpacity&&(t["--semiotic-selection-opacity"]=e.colors.selectionOpacity+""),e.colors.diverging&&(t["--semiotic-diverging"]=e.colors.diverging),e.colors.annotation&&(t["--semiotic-annotation-color"]=e.colors.annotation),e.colors.success&&(t["--semiotic-success"]=e.colors.success),e.colors.danger&&(t["--semiotic-danger"]=e.colors.danger),e.colors.warning&&(t["--semiotic-warning"]=e.colors.warning),e.colors.error&&(t["--semiotic-error"]=e.colors.error),e.colors.info&&(t["--semiotic-info"]=e.colors.info),e.tooltip?.background&&(t["--semiotic-tooltip-bg"]=e.tooltip.background),e.tooltip?.text&&(t["--semiotic-tooltip-text"]=e.tooltip.text),e.tooltip?.borderRadius&&(t["--semiotic-tooltip-radius"]=e.tooltip.borderRadius),e.tooltip?.fontSize&&(t["--semiotic-tooltip-font-size"]=e.tooltip.fontSize),e.tooltip?.shadow&&(t["--semiotic-tooltip-shadow"]=e.tooltip.shadow),e.borderRadius&&(t["--semiotic-border-radius"]=e.borderRadius);let i=e.typography.legendSize??e.typography.labelSize;null!=i&&(t["--semiotic-legend-font-size"]=i+"px"),null!=e.typography.legendFontFamily&&(t["--semiotic-legend-font-family"]=e.typography.legendFontFamily),null!=e.typography.legendFontWeight&&(t["--semiotic-legend-font-weight"]=e.typography.legendFontWeight+"");let r=e.typography.titleFontSize??e.typography.titleSize;return null!=r&&(t["--semiotic-title-font-size"]=r+"px"),null!=e.typography.titleFontFamily&&(t["--semiotic-title-font-family"]=e.typography.titleFontFamily),null!=e.typography.titleFontWeight&&(t["--semiotic-title-font-weight"]=e.typography.titleFontWeight+""),null!=e.typography.tickFontFamily&&(t["--semiotic-tick-font-family"]=e.typography.tickFontFamily),null!=e.typography.tickSize&&(t["--semiotic-tick-font-size"]=e.typography.tickSize+"px"),null!=e.typography.labelSize&&(t["--semiotic-axis-label-font-size"]=e.typography.labelSize+"px"),t}function Qo(e,t,i,r,o){if(e)return e;if(i&&"object"==typeof i&&!Array.isArray(i)){let e=si(i,r);if(e)return e}let n;if(Array.isArray(i))n=i;else if(t&&t.length>0)n=t;else if("string"==typeof i){let e=Tf[i];Array.isArray(e)&&(n=e)}return n&&0!==n.length?null!=r?(o.has(r)||o.set(r,o.size),n[o.get(r)%n.length]):n[0]:Ff}function Jo(e,t,i){return"function"==typeof e?e(t,i):t[e]}function en(e,t){if(!e?.length)return;let i=new Map(t.map((e,t)=>[pe(e),t]));return e.map(e=>{let t={...e},r=r=>{if(!(r in e))return;let o=i.get(pe(e[r]));void 0!==o&&(t[r]=o)};return r("x"),r("x0"),r("x1"),"string"==typeof e.type&&("x-threshold"===e.type||"x"===e.type)&&r("value"),t})}function tn(e,t,i,r,o){let n=1-o;return n*n*n*e+3*n*n*o*t+3*n*o*o*i+o*o*o*r}function rn(e,t,i,r,o){let n=1-o;return 3*n*n*(t-e)+6*n*o*(i-t)+3*o*o*(r-i)}function on(e,t,i,r,o){let n=[],a=(e.x+t.x)/2;for(let s=0;o>=s;s++){let l,c,u,d,h=s/o;"linear"===r?(l=e.x+(t.x-e.x)*h,c=e.y+(t.y-e.y)*h,u=t.x-e.x,d=t.y-e.y):(l=tn(e.x,a,a,t.x,h),c=tn(e.y,e.y,t.y,t.y,h),u=rn(e.x,a,a,t.x,h),d=rn(e.y,e.y,t.y,t.y,h)),n.push({x:l,y:c,dx:u,dy:d,radius:e.radius+(t.radius-e.radius)*h,datumIndex:.5>h?i:i+1})}return n}function nn(e,t={}){let i=[],r=[],o=[];if(2>e.length)return{topPath:i,bottomPath:r,datumIndices:o};let n=t.curve??"smooth",a=Math.max(2,Math.floor(t.samplesPerSegment??12));for(let t=0;e.length-1>t;t++){let s=on(e[t],e[t+1],t,n,a);for(let e=0===t?0:1;s.length>e;e++){let t=s[e],n=Math.hypot(t.dx,t.dy)||1,a=-t.dy/n,l=t.dx/n,c=Math.max(0,t.radius);i.push([t.x+a*c,t.y+l*c]),r.push([t.x-a*c,t.y-l*c]),o.push(t.datumIndex)}}return{topPath:i,bottomPath:r,datumIndices:o}}function an({datum:e,x:t,y:i,side:r,color:o,highlighted:n,labelStyle:a}){let s=function(){let e=(Og??(Og=Cg.createContext(null)),Og);return Cg.useContext(e)??Fg}(),l=s.isActive&&!s.predicate(e),c="function"==typeof a?a(e.__bumpRaw):a;return Dg("text",{className:"semiotic-bump-label",x:t+("end"===r?8:-8),y:i,dy:"0.35em",textAnchor:"end"===r?"start":"end",fill:o,fillOpacity:l?.16:1,fontWeight:n?650:450,fontSize:12,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-axis-label-font-size, 12px)",...c},children:e.__bumpSeries})}function sn(e,t,i){let[r,o]=t,[n,a]=i;return o===r?(n+a)/2:n+(a-n)*Math.max(0,Math.min(1,(e-r)/(o-r)))}function ln(e){let t=e.__bumpXValue instanceof Date?e.__bumpXValue.getTime():Number(e.__bumpXValue);return{value:e.__bumpValue,x:Number.isFinite(t)?t:void 0,y:e.__bumpValue,category:e.__bumpSeries}}function cn(e){let t=e.config,i=new Map;for(let t of e.data){let e=i.get(t.__bumpSeries)??[];e.push(t),i.set(t.__bumpSeries,e)}let r=t.seriesOrder.filter(e=>i.has(e)).sort((e,r)=>(i.get(e)?.[0]?.__bumpHighlighted?1:0)-(i.get(r)?.[0]?.__bumpHighlighted?1:0)||t.seriesOrder.indexOf(e)-t.seriesOrder.indexOf(r)),o=[],n=[],a=[];for(let n of r){let r=(i.get(n)??[]).sort((e,t)=>e.x-t.x);if(2>r.length)continue;let s=r[0].__bumpHighlighted,l=(t.colorMap&&si(t.colorMap,n))??e.resolveColor(r[0].__bumpSeries,r[0]),c=t.color??(s?l:t.neutralColor??e.theme.semantic.textSecondary??e.theme.semantic.border??l),u=r.map(i=>({x:e.scales.x(i.x),y:e.scales.y(i.y),radius:t.ribbon?sn(i.__bumpValue,t.valueExtent,t.ribbonSizeRange)/2:Math.max(.5,t.lineWidth/2)})),d=nn(u,{curve:t.curve,samplesPerSegment:t.samplesPerSegment}),h={fill:c,fillOpacity:1,opacity:s?t.ribbon?t.ribbonOpacity:t.lineOpacity:Math.min(t.ribbon?t.ribbonOpacity:t.lineOpacity,.58)};t.styleRules?.length&&Object.assign(h,_e(r[0].__bumpRaw,t.styleRules,ln(r[0]))),t.areaStyle&&Object.assign(h,t.areaStyle(r[0].__bumpRaw)??{}),void 0!==t.stroke&&(h.stroke=t.stroke),void 0!==t.strokeWidth&&(h.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(h.opacity=t.opacity),o.push({type:"area",topPath:d.topPath,bottomPath:d.bottomPath,style:h,datum:d.datumIndices.map(e=>r[e]),accessibleDatum:r.map(e=>e.__bumpRaw),accessibility:{label:n+" ranking trajectory",tableFields:r.map(e=>e.__bumpRaw)},group:n,interactive:!0}),t.showPoints&&r.forEach((e,i)=>{let r={fill:c,stroke:"none",opacity:s?1:.75};t.styleRules?.length&&Object.assign(r,_e(e.__bumpRaw,t.styleRules,ln(e))),t.pointStyle&&Object.assign(r,t.pointStyle(e.__bumpRaw)??{}),void 0!==t.stroke&&(r.stroke=t.stroke),void 0!==t.strokeWidth&&(r.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(r.opacity=t.opacity),o.push({type:"point",x:u[i].x,y:u[i].y,r:r.r??t.pointRadius,style:r,datum:e,accessibleDatum:e.__bumpRaw,accessibility:{label:`${n}, rank ${e.__bumpRank}, value ${e.__bumpValue}`},pointId:`${n}:${e.x}`})});let p=!0===t.showLabels?"end":t.showLabels,f=(e,i,r)=>{let o=null==t.labelPriorityAccessor?void 0:"function"==typeof t.labelPriorityAccessor?t.labelPriorityAccessor(e.__bumpRaw):Number(e.__bumpRaw[t.labelPriorityAccessor]);a.push({id:`${n}\0${r}`,datum:e,x:u[i].x,y:u[i].y,side:r,rank:e.__bumpRank,highlighted:s,priority:Number.isFinite(o)?o:void 0,color:"string"==typeof h.fill?h.fill:c})};("start"===p||"both"===p)&&f(r[0],0,"start"),("end"===p||"both"===p||"auto"===p)&&f(r.at(-1),r.length-1,"end")}let s=function(e,t,i,r){let o=Math.max(1,Math.floor(t/18)),n="auto"===i?Number.isFinite(r)&&(r??0)>=0?Math.min(o,Math.floor(r)):o:1/0,a=e.map((e,t)=>({candidate:e,index:t})).sort((e,t)=>(t.candidate.priority??0)-(e.candidate.priority??0)||Number(t.candidate.highlighted)-Number(e.candidate.highlighted)||e.candidate.rank-t.candidate.rank||e.index-t.index),s=[];for(let{candidate:e}of a){if(s.length>=n)break;s.some(t=>t.side===e.side&&14>Math.abs(t.y-e.y))||s.push(e)}return new Set(s.map(e=>e.id))}(a,e.dimensions.plot.height,"auto"!==(!0===t.showLabels?"end":t.showLabels)||"auto",t.maxLabels);for(let e of a)s.has(e.id)&&n.push(Dg(an,{datum:e.datum,x:e.x,y:e.y,side:e.side,color:e.color,highlighted:e.highlighted,labelStyle:t.labelStyle},e.id));return{nodes:o,overlays:n.length?Dg("g",{className:"semiotic-bump-labels",children:n}):void 0,restyle:(e,t)=>{let i=function(e){let t=Array.isArray(e.datum)?e.datum[0]:e.datum;return t&&"object"==typeof t&&"__bumpSeries"in t?t:void 0}(e);if(t?.isActive&&i&&!t.predicate(i))return{opacity:.14}}}}function un(e,t){let i=ke(e),r=t.map((e,t)=>({label:e.label||"Series "+(t+1),readY:ke(e.yAccessor)}));return(e,t)=>{let o=(e[zg]??t??"")+"",n=(r.find(e=>e.label===o)??r[0])?.readY(e);return{value:n,x:i(e),y:n,category:o||void 0}}}function dn(e,t,i,r,o){let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=Ir(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrAreaColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrAreaColorBy:t(e)})):n,u=t?li(c,l,s):void 0,d=!1!==o.showLine,h="number"==typeof o.lineWidth?o.lineWidth:2,p="number"==typeof o.areaOpacity?o.areaOpacity:.7,f=ke(o.yAccessor),y=o.styleRules;return(e,i)=>{let r=t&&u?ai(e,t,u):"string"==typeof o.color?o.color:Ff,n={fill:r,fillOpacity:p,stroke:d?r:"none",...d&&{strokeWidth:h}};return y?.length&&Object.assign(n,_e(e,y,{value:f(e),category:i})),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}}function hn(e,t,i,r,o){if(!o.showPoints)return;let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=Ir(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrPointColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrPointColorBy:t(e)})):n,u=t?li(c,l,s):void 0,d="number"==typeof o.pointRadius?o.pointRadius:3;return e=>{let i=t&&u?ai(e,t,u):"string"==typeof o.color?o.color:Ff;return{r:d,fill:i,stroke:"none"}}}function pn(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function fn(e,t){if("function"==typeof e)return e;let i=e||t;return e=>e[i]}function yn(e){return Math.max(0,Math.min(1,e))}function gn(e){let 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)]}let i=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(i){let e=[Number(i[1]),Number(i[2]),Number(i[3])];if(e.every(Number.isFinite))return e}return null}function mn(e,t,i){let r=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(i)}`}function xn(e,t,i){let r=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:yn(e.offset),color:e.color??i,opacity:null==e.opacity?1:yn(e.opacity)})).sort((e,t)=>e.offset-t.offset);if(0===r.length)return"#999999";let o=e=>{if(1===e.opacity)return e.color;let t=gn(e.color);return t?`rgba(${t[0]},${t[1]},${t[2]},${e.opacity})`:e.color};if(1===r.length)return o(r[0]);let n=yn(t);if(r[0].offset>=n)return o(r[0]);if(n>=r[r.length-1].offset)return o(r[r.length-1]);for(let e=0;r.length-1>e;e++){let t=r[e],i=r[e+1];if(t.offset>n||n>i.offset)continue;let a=i.offset-t.offset,s=a>0?(n-t.offset)/a:0,l=gn(t.color),c=gn(i.color);if(!l||!c)return o(.5>s?t:i);let[u,d,h]=l,[p,f,y]=c,g=u+(p-u)*s,m=d+(f-d)*s,x=h+(y-h)*s,b=t.opacity+(i.opacity-t.opacity)*s;return 1===b?mn(g,m,x):`rgba(${Math.round(g)},${Math.round(m)},${Math.round(x)},${b})`}return o(r[r.length-1])}function bn(e,t,i){return null==i?`${e}-${t}`:`${e}-${t}-${i}`}function vn(e=240){let t=360-e,i=180+t/2,r=i*Math.PI/180;return{sweepRad:e*Math.PI/180,gapDeg:t,startAngleDeg:i,startAngleRad:r,offsetRad:-Math.PI/2+r}}function wn(e){return _o(e)}function kn(e,t,i,r,o,n){let a=Ir(r.theme).colors.categorical,s=i??r.colorScheme,l=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],c="string"==typeof t?t:"__ssrColorBy",u="function"==typeof t?l.map(e=>({...e,__ssrColorBy:t(e)})):l,d=t?li(u,c,s??a):void 0,h=Qo("string"==typeof o.color?o.color:void 0,a,s,void 0,new Map),p=n??ke(o.valueAccessor??"value"),f=o.styleRules,y=r.pieceStyle;return(e,i)=>{let r={fill:t&&d?ai(e,t,d):h};return f?.length&&Object.assign(r,_e(e,f,{value:p(e,i),category:i})),"function"==typeof y?Object.assign(r,y(e,i)||{}):y&&"object"==typeof y&&Object.assign(r,y),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 An(e,t,i,r,o,n="median",a=.8){let s=ke(o.valueAccessor??"value"),l=kn(e,t,i,r,o,e=>"number"==typeof e[n]?e[n]:s(e));return(e,t)=>{let i=l(e,t);return void 0===i.fillOpacity&&(i.fillOpacity=a),void 0===i.stroke&&(i.stroke=i.fill),i}}function Sn(e,t,i,r,o){return An(e,t,i,r,o,"median",.6)}function Mn(e,t,i,r,o){let n=kn(e,t,i,r,o),a="number"==typeof o.dotRadius?o.dotRadius:5;return(e,t)=>({r:a,fillOpacity:.8,...n(e,t)})}function $n(e,t,i,r,o){let n=kn(e,t,i,r,o),a=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],s=o.sizeBy,l=Array.isArray(o.sizeRange)?o.sizeRange:[3,8],c=s?a.map(e=>"function"==typeof s?s(e):Number(e[s])).filter(Number.isFinite):[],u=c.length?no(c):void 0,d="number"==typeof o.pointRadius?o.pointRadius:4,h="number"==typeof o.pointOpacity?o.pointOpacity:.7;return(e,t)=>({r:s?ci(e,s,l,u):d,fillOpacity:h,...n(e,t)})}function _n(e="static"){return Mm[e]??Mm.static}function Pn(e){return"fatal"===e.severity||"warn"===e.severity?e.severity:$m.has(e.kind)?"fatal":"warn"}function In(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`:"duplicate-node"===e.kind?`node id "${e.id}" is duplicated`:"duplicate-edge"===e.kind?`edge id "${e.id}" is duplicated`:"invalid-system-time"===e.kind?`edge ${e.id} has an invalid systemInTime or systemOutTime`:e.kind}function Rn(e){let{desired:t,minGaps:i,weights:r}=e,o=t.length;if(0===o)return[];if(i.length!==Math.max(0,o-1))throw Error("placeWithMinGap: minGaps must have desired.length - 1 entries");let n=Array(o).fill(0);for(let e=1;o>e;e++)n[e]=n[e-1]+Math.max(0,Number.isFinite(i[e-1])?i[e-1]:0);let a=[];for(let e=0;o>e;e++){let i=Math.max(Number.EPSILON,Number.isFinite(r?.[e])?r[e]:1),o=(Number.isFinite(t[e])?t[e]:0)-n[e];for(a.push({start:e,end:e,weight:i,mean:o});a.length>1;){let e=a[a.length-1],t=a[a.length-2];if(e.mean>=t.mean)break;let i=t.weight+e.weight;a.splice(a.length-2,2,{start:t.start,end:e.end,weight:i,mean:(t.mean*t.weight+e.mean*e.weight)/i})}}let s=Number.isFinite(e.min)?e.min:-1/0,l=Number.isFinite(e.max)?e.max-n[o-1]:1/0,c=s>l?s:l,u=Array(o);for(let e of a){let t=Math.max(s,Math.min(c,e.mean));for(let i=e.start;e.end>=i;i++)u[i]=t+n[i]}return u}function Ln(e,t){let i=0,r=e.length-1,o=-1;for(;r>=i;){let n=i+r>>>1;e[n].at>t?r=n-1:(o=n,i=n+1)}return 0>o?{at:t,before:0,after:0}:e[o]}function Cn(e,t=0){if(0===e.length)return{adjacentClearance:[],positions:[]};let i=[],r=[0];for(let o=0;e.length-1>o;o++){let n=e[o],a=e[o+1],s=[...new Set([...n.map(e=>e.at),...a.map(e=>e.at)])].sort((e,t)=>e-t),l=0;for(let e of s){let t=Ln(n,e),i=Ln(a,e);l=Math.max(l,t.after+i.before)}i.push(l),r.push(r[r.length-1]+l+t)}return{adjacentClearance:i,positions:r}}function Tn(e,t,i,r={}){let o=[...e];if(1>=o.length)return o;let n=[...o],a=i(o),s=1,l=Math.max(0,r.passes??6),c=Math.max(1,r.maxEvaluations??1/0);for(let e=0;l>e&&c>s;e++){let e=new Map(o.map((e,t)=>[e,t])),l=new Map,c=new Map;for(let i of t){let t=e.get(i.source),r=e.get(i.target);if(null==t||null==r)continue;let o=Number.isFinite(i.weight)&&i.weight>0?i.weight:1;l.set(i.source,(l.get(i.source)??0)+r*o),c.set(i.source,(c.get(i.source)??0)+o),l.set(i.target,(l.get(i.target)??0)+t*o),c.set(i.target,(c.get(i.target)??0)+o)}o=o.map((e,t)=>({item:e,index:t,barycenter:(l.get(e)??t)/(c.get(e)??1)})).sort((e,t)=>e.barycenter-t.barycenter||(r.compare?.(e.item,t.item)??e.index-t.index)).map(e=>e.item);let u=i(o);if(s++,a>u)a=u,n=[...o];else if(u===a)break}return n}function On(e,t,i={}){let r=[...e],o=r.length;if(1>=o||o>(i.maxItems??8))return r;let n=Math.max(1,i.maxEvaluations??1/0),a=0,s=[...r],l=1/0,c=()=>{if(a>=n)return;let e=t(r);a++,l>e&&(l=e,s=[...r])};c();let u=Array(o).fill(0),d=0;for(;o>d&&n>a;)if(d>u[d]){let e=d%2==0?0:u[d];[r[e],r[d]]=[r[d],r[e]],c(),u[d]++,d=0}else u[d]=0,d++;return s}function Fn(){return Object.create(null)}function Dn(e,t){return t>e?-1:e>t?1:0}function En(e){return e.occupants.map(e=>e.id).sort(Dn).join("\0")}function Nn(e,t,i=0){return e.slice(0,-1).map((r,o)=>null!=r.group&&r.group===e[o+1].group?i:t)}function zn(e,t){return e.map(e=>{let i=new Map;for(let r of e.occupants){let e=t[r.id];if(e)for(let t of e.samples){let e=i.get(t.t)??{before:0,after:0},r=t.boundaryOffset??0;i.set(t.t,{before:Math.max(e.before,t.topMass-r),after:Math.max(e.after,t.botMass+r)})}}return[...i].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({at:e,...t}))})}function Bn(e,t,i){if(0===e.length)return[];let{padding:r,plotH:o,valueScale:n}=i,a=i.stackValueScale??n,s=Nn(e,r,i.groupPadding??0),l=[r+e[0].peak.topPeak*a];for(let i=1;e.length>i;i++)l.push(l[i-1]+t[i-1]*a+s[i-1]);let c=l[l.length-1]+e[e.length-1].peak.botPeak*a+r;if(c>o&&c>0){let e=o/c;for(let t=0;l.length>t;t++)l[t]*=e}return l}function jn(e,t){let i=(e.boundaryOffset??0)*t,r=e.value*t;if("out"===e.kind){let o=e.sideMassBefore*t;return i+("top"===e.side?r/2-o:o-r/2)}let o=e.sideMassAfter*t;return i+("top"===e.side?r/2-o:o-r/2)}function Wn(e,t,i,r,o,n){let a=n.adjacentClearance?[...n.adjacentClearance]:Cn(zn(r,i)).adjacentClearance,s=Bn(r,a,n),l="hug"===n.lanePlacement?function(e,t,i,r,o,n,a){let s=e.length;if(0===s)return[];let{padding:l,plotH:c,valueScale:u}=a,d=Nn(e,l,a.groupPadding??0),h=o.map((e,t)=>e*u+d[t]),p=l+e[0].peak.topPeak*u,f=c-l-e[s-1].peak.botPeak*u;if(h.reduce((e,t)=>e+t,0)+1e-6>=f-p)return Bn(e,o,a);let y=1===s?[(p+f)/2]:[...n];for(let e=0;12>e;e++){let e=Array(s).fill(0),o=Array(s).fill(0);for(let n of i){let i=t[n.source],a=t[n.target];if(null==i||null==a||i===a)continue;let s=r[n.source]?.localAttachments.get(n.id),l=r[n.target]?.localAttachments.get(n.id);if(!s||!l)continue;let c=n.value>0&&Number.isFinite(n.value)?n.value:1,d=jn(s,u),h=jn(l,u);e[i]+=(y[a]+h-d)*c,o[i]+=c,e[a]+=(y[i]+d-h)*c,o[a]+=c}let n=Rn({desired:y.map((t,i)=>0===o[i]?t:.45*t+e[i]/o[i]*.55),minGaps:h,weights:o.map(e=>Math.max(1,e)),min:p,max:f}),a=0;for(let e=0;s>e;e++)a=Math.max(a,Math.abs(n[e]-y[e]));if(y=n,.01>a)break}return y}(r,o,t,i,a,s,n):[...s];if("hug"===n.lanePlacement){let i=t=>{let i=Fn();for(let r of e)i[r.id]=t[o[r.id]];return i};Yn(i(l),t)>Yn(i(s),t)+1e-6&&(l=[...s])}let c=Fn();for(let t of e)c[t.id]=l[o[t.id]];let u=1/0,d=-1/0;for(let t of e){let e=c[t.id],r=i[t.id];!Number.isFinite(e)||!r||(u=Math.min(u,e-r.topPeak*n.valueScale),d=Math.max(d,e+r.botPeak*n.valueScale))}return{adjacentClearance:a,centerlines:c,slotCenter:l,stackCenter:s,verticalUtilization:Number.isFinite(u)&&Number.isFinite(d)&&n.plotH>0?Math.max(0,Math.min(1,(d-u)/n.plotH)):0}}function Yn(e,t){let i=0;for(let r of t){let t=e[r.source],o=e[r.target];Number.isFinite(t)&&Number.isFinite(o)&&(i+=Math.abs(t-o)*(r.value>0?r.value:1))}return i}function qn(e,t){let i=e?.samples;if(!i||0===i.length||i[0].t>t)return{top:0,bot:0};let r=0,o=i.length-1,n=0;for(;o>=r;){let e=r+o>>>1;i[e].t>t?o=e-1:(n=e,r=e+1)}let a=i[n].boundaryOffset??0;return{top:i[n].topMass-a,bot:i[n].botMass+a}}function Xn(e,t,i,r,o){let n=1-o;return n*n*n*e+3*n*n*o*t+3*n*o*o*i+o*o*o*r}function Gn(e,t){let i=0,r=1;for(let o=0;28>o;o++){let o=(i+r)/2;Xn(0,t,t,1,o)<e?i=o:r=o}return(i+r)/2}function Vn(e,t,i){let r=t+jn(e,i),o=e.value*i/2;return[r-o,r+o]}function Hn(e,t,i,r){return Math.max(0,Math.min(t,r)-Math.max(e,i))/Math.max(1e-9,t-e)}function Un(e,t,i,r,o,n,a){let{valueScale:s,domain:l,mode:c="quality"}=a,u="source"===a.ribbonLane?.85:"target"===a.ribbonLane?.15:.5,d=0;for(let a of e){let e=r[a.source],h=r[a.target];if(null==e||null==h||2>Math.abs(e-h))continue;let p=t[a.source]?.localAttachments.get(a.id),f=t[a.target]?.localAttachments.get(a.id);if(!p||!f)continue;let y=Math.max(a.startTime,l?.[0]??-1/0),g=Math.min(a.endTime,l?.[1]??1/0);if(y>=g)continue;let[m,x]=Vn(p,o[a.source],s),[b,v]=Vn(f,o[a.target],s),w=Math.min(e,h)+1,k=Math.max(e,h)-1;for(let e=w;k>=e;e++){let r=i[e];if(!r)continue;let l=[y,g];if("quality"===c)for(let e of r.occupants)for(let i of t[e.id]?.samples??[])i.t>y&&g>i.t&&l.push(i.t);let h=e=>{let i=Gn((e-y)/(g-y),u),l=Xn(m,m,b,b,i),c=Xn(x,x,v,v,i),d=0;for(let i of r.occupants){if(i.id===a.source||i.id===a.target)continue;let r=n[i.id];if(null!=r?.start&&r.start>e||null!=r?.end&&e>r.end)continue;let u=qn(t[i.id],e),h=o[i.id];d=Math.max(d,Hn(l,c,h-u.top*s,h+u.bot*s))}return d},p=[...new Set(l)].sort((e,t)=>e-t),f=0;for(let e=0;p.length-1>e;e++){let t=p[e],i=p[e+1]-t;f+=(h(t+.25*i)+h(t+.5*i)+h(t+.75*i))/3*i}d+=f/(g-y)*(a.value>0?a.value:1)}}return d}function Kn(e,t,i,r,o,n,a,s,l,c,u="both",d){return{crossings:e,weightedLength:t,pixelLength:Yn(a,i),transitOcclusion:Un(i,r,o,n,a,s,{valueScale:l,ribbonLane:u,domain:d,mode:"quality"}),verticalUtilization:c}}function Zn(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Qn(e,t){return e.map(e=>({t:Zn(e.t,t),topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}}))}function Jn(e,t,i){let r=t+(e.boundaryOffset??0)*i,o=e.value*i;if("out"===e.kind){let t=e.sideMassBefore*i;if("top"===e.side){let e=r-t;return[e,e+o]}let n=r+t;return[n-o,n]}let n=e.sideMassAfter*i;if("top"===e.side){let e=r-n;return[e,e+o]}let a=r+n;return[a-o,a]}function ea(e,t,i,r,o="temporal"){let n=t.incoming[e.id],a=t.outgoing[e.id],s=[];for(let e of n)s.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:i.get(e.id).targetSide});for(let e of a)s.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:i.get(e.id).sourceSide});let l={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},c=()=>{s.sort((e,t)=>e.time-t.time||(e.phase??0)-(t.phase??0)||(e.sequence??0)-(t.sequence??0)||(l[e.kind]??99)-(l[t.kind]??99)||((e,t)=>{if(!r||!e.edge||!t.edge||e.kind!==t.kind||e.side!==t.side)return 0;if("out"===e.kind){if(e.edge.target===t.edge.target&&e.edge.endTime===t.edge.endTime)return 0;let i=r.get(e.edge.id)?.target,o=r.get(t.edge.id)?.target;return"number"==typeof i&&Number.isFinite(i)&&"number"==typeof o&&Number.isFinite(o)&&i!==o?"top"===e.side?i-o:o-i:0}if("in"===e.kind){if(e.edge.source===t.edge.source&&e.edge.startTime===t.edge.startTime)return 0;let i=r.get(e.edge.id)?.source,o=r.get(t.edge.id)?.source;return"number"==typeof i&&Number.isFinite(i)&&"number"==typeof o&&Number.isFinite(o)&&i!==o?"top"===e.side?o-i:i-o:0}return 0})(e,t)||Dn(e.edge?.id??"",t.edge?.id??"")||Dn(e.side,t.side)||e.delta-t.delta)},u=s.length?function(e,t=1/0){let i=t;for(let t of e)i>t&&(i=t);return i}(s.map(e=>e.time)):null,d=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,h=null!=d?d-1:null!=u&&Number.isFinite(u)?u-1:null;c();let p=null,f=0;for(let e of s)e.time!==p&&(p=e.time,f=0),e.sequence=f++;let y=e=>({time:e.time,phase:0,sequence:e.sequence??0}),g=[],m=0,x=0;for(let e of s)if("out"===e.kind){let t=Math.abs(e.delta),i=t-("top"===e.side?m:x);if(i>0){let t="top"===e.side?"bot":"top",r=Math.min(i,"top"===t?m:x);if(r>0){let o=y(e);g.push({...o,delta:-r,kind:"transfer-out",side:t}),g.push({...o,delta:+r,kind:"transfer-in",side:e.side}),"top"===t?m-=r:x-=r,"top"===e.side?m+=r:x+=r,i-=r}i>0&&null!==h&&(g.push({time:h,delta:+i,kind:"create",side:e.side}),"top"===e.side?m+=i:x+=i)}"top"===e.side?m-=t:x-=t}else if("in"===e.kind){let t=Math.abs(e.delta);"top"===e.side?m+=t:x+=t}s.push(...g),c();let b=0,v=0,w=0,k=0,A=0,S=0,M=[],$=new Map,_=e=>{M.push({t:e,topMass:b,botMass:v,...Math.abs(w)>1e-12&&{boundaryOffset:w}})},P=()=>{k=Math.max(k,b+v),A=Math.max(A,b-w),S=Math.max(S,v+w)};for(let e of s){if("transfer-out"!==e.kind&&"transfer-in"!==e.kind&&_(e.time),("in"===e.kind||"out"===e.kind)&&e.edge){let t="top"===e.side?b:v;$.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta),...Math.abs(w)>1e-12&&{boundaryOffset:w}})}"top"===e.side?b+=e.delta:v+=e.delta,"transfer-in"===e.kind?(w+="top"===e.side?e.delta:-e.delta,P(),_(e.time)):"transfer-out"!==e.kind&&(P(),"out"===e.kind&&1e-12>=b+v&&(w=0),_(e.time))}let I=[],R=0;for(;M.length>R;){let e=R;for(;M.length>e+1&&M[e+1].t===M[R].t;)e++;I.push(M[R]);for(let t=R+1;e>=t;t++){let e=I[I.length-1];(M[t].topMass!==e.topMass||M[t].botMass!==e.botMass||(M[t].boundaryOffset??0)!==(e.boundaryOffset??0))&&I.push(M[t])}R=e+1}let L=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null,C=null;for(let e of a)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===C||C>e.systemInTime)&&(C=e.systemInTime);let T=null;for(let e of n)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===T||e.systemOutTime>T)&&(T=e.systemOutTime);if(I.length>0){let e=I[I.length-1],t=Math.max(L??-1/0,T??-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&I.push({t:t,topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}});let i,r=I[0],o=I.find(e=>e.topMass+e.botMass>0),n=1/0;null!=d&&Number.isFinite(d)&&r.t>d&&r.topMass+r.botMass>0&&(n=d,i=r),o&&null!=C&&Number.isFinite(C)&&o.t>C&&n>C&&(n=C,i=o),i&&Number.isFinite(n)&&I.unshift({t:n,topMass:i.topMass,botMass:i.botMass,...null!=i.boundaryOffset&&{boundaryOffset:i.boundaryOffset}})}let O=I;if("max"===o&&null!=d&&null!=L&&L>d){let e,t=0;for(let i of I){let r=i.topMass+i.botMass;r>t&&(t=r,e=i)}if(e){let t={topMass:e.topMass,botMass:e.botMass,...null!=e.boundaryOffset&&{boundaryOffset:e.boundaryOffset}};O=[...I.filter(e=>d>e.t),{t:d,...t},{t:L,...t},...I.filter(e=>e.t>L)]}}return{samples:O,peak:k,topPeak:A,botPeak:S,localAttachments:$}}function ta(e){let t=Fn();return e.forEach((e,i)=>{for(let r of e.occupants)t[r.id]=i}),t}function ia(e,t,i){e.splice(0,e.length,...i);let r=ta(i);for(let e of Object.keys(t))delete t[e];Object.assign(t,r)}function ra(e){let t=new Map,i=[];e.forEach((e,r)=>{if(!e.group)return void i.push({anchor:r,stableId:En(e),slots:[e]});let o=t.get(e.group)??{indexes:[],slots:[]};o.indexes.push(r),o.slots.push(e),t.set(e.group,o)});for(let[e,r]of t)i.push({anchor:r.indexes.reduce((e,t)=>e+t,0)/r.indexes.length,stableId:`${e}\0${r.slots.map(En).join("\0")}`,slots:r.slots});return i.sort((e,t)=>e.anchor-t.anchor||Dn(e.stableId,t.stableId))}function oa(e){return e.some(e=>e.group)?ra(e).flatMap(e=>e.slots):[...e]}function na(e){return e.flatMap(e=>e.slots)}function aa(e,t,i){let r=new Map;return e.forEach((e,t)=>{for(let i of e.slots)r.set(i,t)}),e.map((e,o)=>{if(1>=e.slots.length)return e;let n=new Map;for(let t of e.slots)n.set(t,0);for(let e of t){let t=r.get(e.source),i=r.get(e.target);if(null==t||null==i)continue;let a=Number.isFinite(e.weight)&&e.weight>0?e.weight:1;if(t===o&&i!==o){let t=i>o?1:-1;n.set(e.source,(n.get(e.source)??0)+a*t)}else if(i===o&&t!==o){let i=t>o?1:-1;n.set(e.target,(n.get(e.target)??0)+a*i)}}let a=[...e.slots].sort((e,t)=>(n.get(e)??0)-(n.get(t)??0)||i(e,t));return{...e,slots:a}})}function sa(e,t){e.some(e=>e.group)&&ia(e,t,oa(e))}function la(e,t){return e.source!==t.source&&e.target!==t.target&&e.source!==t.target&&e.target!==t.source&&Math.min(e.endTime,t.endTime)>Math.max(e.startTime,t.startTime)}function ca(e,t){return function(e,t,i=()=>!0){let r=0;for(let o=0;e.length>o;o++){let[n,a]=t(e[o]);for(let s=o+1;e.length>s;s++){if(!i(e[o],e[s]))continue;let[l,c]=t(e[s]);0>(n-l)*(a-c)&&r++}}return r}(t,t=>[e[t.source],e[t.target]],la)}function ua(e,t){let i=0;for(let r of t){let t=e[r.source],o=e[r.target];null==t||null==o||(i+=Math.abs(t-o)*(r.value>0?r.value:1))}return i}function da(e,t,i){let[r,o]=i.get(e.first),[n,a]=i.get(e.second);return 0>(t.get(r)-t.get(n))*(t.get(o)-t.get(a))?1:0}function ha(e,t,i,r,o,n,a){let s=[...o],l=new Map(o.map(e=>[e,En(e)])),c=new Map;for(let e of o)for(let t of e.occupants)c.set(t.id,e);let u=new Map,d=[];for(let e of t){let t=c.get(e.source),i=c.get(e.target);!t||!i||(u.set(e,[t,i]),t!==i&&d.push({source:t,target:i,weight:e.value}))}let h=[];for(let e=0;t.length>e;e++)if(u.has(t[e]))for(let i=e+1;t.length>i;i++){if(!u.has(t[i])||!la(t[e],t[i]))continue;let r=new Set([...u.get(t[e]),...u.get(t[i])]);h.push({index:h.length,first:t[e],second:t[i],involvedSlots:r})}let p=new Map;for(let e of o)p.set(e,[]);for(let e of h)for(let t of e.involvedSlots)p.get(t)?.push(e);let f=new Uint32Array(h.length),y=0,g=t.reduce((e,t)=>e+(t.value>0?t.value:1),0),m=a.plotH/Math.max(1,o.length),x=o.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),b=Math.max(1,g)*(Math.max(1,a.plotH)+m*Math.max(x,o.length)+1e-6*Math.max(1,o.length-1))+1,v=4*m,w={fullCrossing:0,localCrossing:0},k=new Map,A=(e,t)=>{let r=k.get(e);r||(r=new Map,k.set(e,r));let o=r.get(t);if(null!=o)return o;let n=function(e,t,i){return Cn(zn([e,t],i)).adjacentClearance[0]??0}(e,t,i);return r.set(t,n),n},S=new Map(o.map((e,t)=>[e,t])),M=t.flatMap(e=>{let t=u.get(e);return t?[{source:S.get(t[0]),target:S.get(t[1]),weight:e.value>0?e.value:1}]:[]}),$=new Map;for(let e of t){let t=u.get(e);t&&$.set(e,{source:S.get(t[0]),target:S.get(t[1])})}let _=new Map,P=new Map,I=new Map,R=(e,t,i)=>{e.has(t)||e.set(t,new Set),e.get(t).add(i)};for(let e of t)R(_,e.source,e.target),R(P,e.target,e.source),R(I,e.source,e.target),R(I,e.target,e.source);let L=t.flatMap(e=>{if(!(e=>1===_.get(e.source)?.size&&_.get(e.source).has(e.target)||1===I.get(e.source)?.size||1===I.get(e.target)?.size)(e))return[];let t=$.get(e);return t&&t.source!==t.target?[{source:t.source,target:t.target,weight:e.value>0?e.value:1}]:[]}),C=e=>{let t=0;for(let i of L)t+=Math.max(0,Math.abs(e[i.source]-e[i.target])-1)*i.weight;return t*v},T=e=>{let t=new Int16Array(o.length);for(let i=0;e.length>i;i++)t[S.get(e[i])]=i;return C(t)},O=h.map(e=>{let t=$.get(e.first),i=$.get(e.second);return[t.source,t.target,i.source,i.target]}),F=new Int16Array(o.length),D=new Float64Array(o.length),E=new Float64Array(o.length+1),N=e=>{for(let t=0;e.length>t;t++)F[S.get(e[t])]=t;let t=0;for(let[e,i,r,o]of O)0>(F[e]-F[r])*(F[i]-F[o])&&t++;if(e.length>0){let t=S.get(e[0]);D[t]=a.padding+e[0].peak.topPeak*a.valueScale;for(let t=1;e.length>t;t++){let i=S.get(e[t-1]),r=S.get(e[t]);D[r]=D[i]+A(e[t-1],e[t])*a.valueScale+a.padding}let i=S.get(e[e.length-1]),r=D[i]+e[e.length-1].peak.botPeak*a.valueScale+a.padding;if(r>a.plotH&&r>0){let e=a.plotH/r;for(let t=0;D.length>t;t++)D[t]*=e}}E[0]=0;for(let t=0;e.length>t;t++)E[t+1]=E[t]+e[t].peak.topPeak+e[t].peak.botPeak;let i=0,r=0,o=0;for(let e of M){let t=F[e.source],n=F[e.target];if(i+=Math.abs(t-n)*e.weight,r+=Math.abs(D[e.source]-D[e.target])*e.weight,Math.abs(t-n)>=2){let i=Math.min(t,n)+1;o+=(E[Math.max(t,n)]-E[i])*e.weight}}return t*b+r+o*m+C(F)+1e-6*i},z=(e,i)=>{let r=Array(e.length+1).fill(0);for(let t=0;e.length>t;t++)r[t+1]=r[t]+e[t].peak.topPeak+e[t].peak.botPeak;let o=0;for(let e of t){let t=i[e.source],n=i[e.target];if(null==t||null==n||2>Math.abs(t-n))continue;let a=Math.min(t,n)+1;o+=(r[Math.max(t,n)]-r[a])*(e.value>0?e.value:1)}return o},B=r=>{let o=ta(r),n=r.slice(0,-1).map((e,t)=>A(e,r[t+1])),s=Wn(e,t,i,r,o,{plotH:a.plotH,padding:a.padding,valueScale:a.valueScale,lanePlacement:a.lanePlacement??"stack",groupPadding:a.groupPadding,adjacentClearance:n});return{map:o,geometry:s,weightedLength:ua(o,t),pixelLength:Yn(s.centerlines,t),transitOcclusion:z(r,o)}},j=(e,t,i)=>({crossings:e,weightedLength:t.weightedLength,pixelLength:t.pixelLength,transitOcclusion:t.transitOcclusion,cost:e*b+t.pixelLength+t.transitOcclusion*m+T(i)+1e-6*t.weightedLength}),W=(e,t)=>{let i=t;if(null==i){let t=new Map(e.map((e,t)=>[e,t]));i=h.reduce((e,i)=>e+da(i,t,u),0),w.fullCrossing++}return j(i,B(e),e)},Y=(e,o,n="quality")=>{let s=o;if(null==s){let t=new Map(e.map((e,t)=>[e,t]));s=h.reduce((e,i)=>e+da(i,t,u),0),w.fullCrossing++}let l=B(e);return j(s,{...l,transitOcclusion:Un(t,i,e,l.map,l.geometry.centerlines,r,{valueScale:a.valueScale,ribbonLane:a.ribbonLane,domain:a.domain,mode:n})},e)},q=[...s],X=(e,t)=>Dn(l.get(e),l.get(t)),G=function(e){let t=new Set;for(let i of e)if(i.group){if(t.has(i.group))return!0;t.add(i.group)}return!1}(q),V=e=>{let t=(e=>{let t=Tn(e,d,e=>W(e).cost,{passes:6,compare:X,maxEvaluations:Im}),i=W(t),r=Im;for(let e=0;6>e&&r>0;e++){let o=!1,n=Array.from({length:t.length-1},(e,t)=>t);e%2==1&&n.reverse();for(let e of n){if(0>=r--)break;let n=t[e],a=t[e+1],s=new Map(t.map((e,t)=>[e,t])),l=0,c=[];y++;for(let e of[...p.get(n)??[],...p.get(a)??[]])f[e.index]!==y&&(f[e.index]=y,c.push(e),l+=da(e,s,u));[t[e],t[e+1]]=[a,n];let d=new Map(s);d.set(n,e+1),d.set(a,e);let h=0;for(let e of c)h+=da(e,d,u);w.localCrossing+=c.length;let g=W(t,i.crossings-l+h);i.cost>g.cost?(i=g,o=!0):[t[e],t[e+1]]=[n,a]}if(!o)break}return t})(e);if((e.length>8?1/0:_m(e.length)*(e.length+M.length+O.length))>Pm)return t;let i=On(e,N,{maxItems:8,maxEvaluations:5e4}),r=Y(i),o=Y(t);return r.crossings!==o.crossings&&o.crossings>r.crossings?i:t},H="geometry-refine"===a.mode;if(H||"crossing-min"!==a.laneOrder&&"crossing-min+inside-out"!==a.laneOrder){if(!H&&"inside-out"===a.laneOrder)if(G){let e=ra(q),t=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),i=[...e].sort((e,i)=>t(i)-t(e)||Dn(e.stableId,i.stableId)),r=Array(i.length),o=Math.floor((i.length-1)/2)-1,n=Math.floor((i.length-1)/2)+1;i.length>0&&(r[Math.floor((i.length-1)/2)]=i[0]);for(let e=1;i.length>e;e++)e%2==1&&i.length>n||0>o?r[n++]=i[e]:r[o--]=i[e];q=na(r)}else{let e=[...q].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||X(e,t)),t=Array(e.length),i=Math.floor((e.length-1)/2)-1,r=Math.floor((e.length-1)/2)+1;e.length>0&&(t[Math.floor((e.length-1)/2)]=e[0]);for(let o=1;e.length>o;o++)o%2==1&&e.length>r||0>i?t[r++]=e[o]:t[i--]=e[o];q=t}}else q=G?(e=>{let t=ra(e);if(1>=t.length)return na(t);let i=e=>W(na(e)).cost;t=ra(V(e)),t=aa(t,d,X);let r=function(e,t){let i=new Map;for(let t of e)for(let e of t.slots)i.set(e,t);let r=new Map;for(let e of t){let t=i.get(e.source),o=i.get(e.target);if(!t||!o||t===o)continue;let n=Number.isFinite(e.weight)&&e.weight>0?e.weight:1,a=o.stableId>t.stableId?`${t.stableId}\0${o.stableId}`:`${o.stableId}\0${t.stableId}`,s=r.get(a);s?s.weight=(s.weight??0)+n:r.set(a,{source:t,target:o,weight:n})}return[...r.values()]}(t,d);if(t=Tn(t,r,i,{passes:6,compare:(e,t)=>Dn(e.stableId,t.stableId),maxEvaluations:Im}),t=function(e,t,i={}){let r=[...e];if(1>=r.length)return r;let o=t(r),n=1,a=Math.max(0,i.passes??6),s=Math.max(1,i.maxEvaluations??1/0);for(let e=0;a>e&&s>n;e++){let e=!1;for(let i=0;r.length-1>i&&s>n;i++){[r[i],r[i+1]]=[r[i+1],r[i]];let a=t(r);n++,o>a?(o=a,e=!0):[r[i],r[i+1]]=[r[i+1],r[i]]}if(!e)break}return r}(t,i,{passes:8,maxEvaluations:Im}),(t.length>8?1/0:_m(t.length)*(t.length+M.length+O.length))<=Pm){let e=On(t,e=>N(na(e)),{maxItems:8,maxEvaluations:5e4}),i=na(e),r=na(t),o=Y(i),n=Y(r);o.crossings!==n.crossings?t=n.crossings>o.crossings?e:t:n.cost>o.cost&&(t=e)}return t=aa(t,d,X),na(t)})(q):V(q);if(!H&&"crossing-min+inside-out"===a.laneOrder&&q.length>1)if(G){let e=ra(q),t=W(na(e)),i=na(e),r=t,o=Math.floor((e.length-1)/2),n=e=>e.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),a=[...e].sort((e,t)=>n(t)-n(e)||Dn(e.stableId,t.stableId));for(let n of a){let a=e.indexOf(n);if(a===o)continue;e.splice(a,1),e.splice(o,0,n);let s=na(e),l=W(s);l.cost>t.cost?(e.splice(o,1),e.splice(a,0,n)):(t=l,r.cost>l.cost&&(i=s,r=l))}q=i}else{let e=W(q),t=[...q],i=e,r=Math.floor((q.length-1)/2),o=[...q].sort((e,t)=>t.peak.topPeak+t.peak.botPeak-(e.peak.topPeak+e.peak.botPeak)||X(e,t));for(let n of o){let o=q.indexOf(n);if(o===r)continue;q.splice(o,1),q.splice(r,0,n);let a=W(q);a.cost>e.cost?(q.splice(r,1),q.splice(o,0,n)):(e=a,i.cost>a.cost&&(t=[...q],i=a))}q=t}if((H||"crossing-min"===a.laneOrder||"crossing-min+inside-out"===a.laneOrder)&&q.length>1)if(G){let e=ra(q),t=Y(na(e),void 0,"score");for(let i=0;6>i&&e.length>1;i++){let i=!1;for(let r=0;e.length-1>r;r++){[e[r],e[r+1]]=[e[r+1],e[r]];let o=na(e),n=Y(o,void 0,"score");t.cost>n.cost?(q=o,t=n,i=!0):[e[r],e[r+1]]=[e[r+1],e[r]]}if(!i)break}e=aa(ra(q),d,X),q=na(e)}else{let e=Y(q,void 0,"score");for(let t=0;q.length-1>t;t++){let i=q[t],r=q[t+1],o=new Map(q.map((e,t)=>[e,t])),n=0,a=[];y++;for(let e of[...p.get(i)??[],...p.get(r)??[]])f[e.index]!==y&&(f[e.index]=y,a.push(e),n+=da(e,o,u));[q[t],q[t+1]]=[r,i];let s=new Map(o);s.set(i,t+1),s.set(r,t);let l=0;for(let e of a)l+=da(e,s,u);w.localCrossing+=a.length;let c=Y(q,e.crossings-n+l,"score");e.cost>c.cost?e=c:[q[t],q[t+1]]=[i,r]}}let U=oa(s);q=oa(q);let K=Y(q),Z=Y(U);if(H){let e=T(U),t=T(q);(K.crossings>Z.crossings||K.crossings===Z.crossings&&t>e+1e-9||K.cost>Z.cost)&&(q=U,K=Z)}else K.cost>Z.cost&&(q=U,K=Z);let Q=function({order:e,after:t,nodes:i,edges:r,outgoingPartners:o,incomingPartners:n,slotForNode:a,averageGap:s,evaluate:l}){let c=(i,o)=>{let n=[...new Set(o.map(t=>e.indexOf(t)))].sort((e,t)=>e-t),a=e.indexOf(i),c=n[0],u=n[n.length-1];if(3>n.length||!n.includes(a)||u-c+1!==n.length||1>=Math.abs(2*a-c-u))return;let d=[...e];d.splice(a,1),d.splice(c+u>>1,0,i);let h=oa(d),p=l(h),f=new Set(i.occupants.map(e=>e.id)),y=new Set(o.flatMap(e=>e.occupants.map(e=>e.id))),g=r.reduce((e,t)=>f.has(t.source)&&y.has(t.target)||f.has(t.target)&&y.has(t.source)?e+(t.value>0?t.value:1):e,0);(function(e,t,i=0){return t.crossings>e.crossings||e.crossings===t.crossings&&t.cost+i>=e.cost})(p,t,Math.abs(2*a-c-u)*s*Math.max(1,g))&&(e=h,t=p)};for(let[e,t]of o)!n.has(e)&&t.size>=3&&c(a.get(e),[...t].map(e=>a.get(e)));for(let e of i){let t=a.get(e.id);!e.group&&t.group&&(n.get(e.id)?.size??0)>=3&&c(t,[...n.get(e.id)??[]].map(e=>a.get(e)).filter(e=>e===t||e.group===t.group).filter((e,t,i)=>i.indexOf(e)===t))}return{order:e,after:t}}({order:q,after:K,nodes:e,edges:t,outgoingPartners:_,incomingPartners:P,slotForNode:c,averageGap:m,evaluate:Y});return q=Q.order,K=Q.after,ia(o,n,q),{before:Z,after:K,initialOrder:s.map(e=>l.get(e)),evaluations:w}}function pa(e,t,i){let r=e.map(e=>{let r=e.occupants.map(e=>({id:e.id,end:i[e.id]?.end??e.end})),o=0,n=0;for(let e of r){let i=t[e.id];o=Math.max(o,i?.topPeak||0),n=Math.max(n,i?.botPeak||0)}return{occupants:r,peak:{topPeak:o,botPeak:n},...null!=e.group?{group:e.group}:{}}}),o=Fn();return r.forEach((e,t)=>{for(let i of e.occupants)o[i.id]=t}),{slots:r,slotByNode:o}}function fa(e,t){return null!=e.start&&null!=e.end&&null!=t.start&&null!=t.end&&!(t.start>=e.end||e.start>=t.end)}function ya(e,t){return Dn(e,t)>0?`${t}\0${e}`:`${e}\0${t}`}function ga(e){let t=new Map,i=new Map;for(let r of e)i.has(r.source)||i.set(r.source,new Set),t.has(r.target)||t.set(r.target,new Set),i.get(r.source).add(r.target),t.get(r.target).add(r.source);return{incoming:new Map([...t].map(([e,t])=>[e,t.size])),outgoing:new Map([...i].map(([e,t])=>[e,t.size]))}}function ma(e){let t=new Map,i=new Map,r=(e,t,i,r)=>{let o=e.get(t);o||(o=new Map,e.set(t,o)),o.set(i,(o.get(i)??0)+r)};for(let o of e){let e=o.value>0&&Number.isFinite(o.value)?o.value:1;r(t,o.source,o.target,e),r(i,o.target,o.source,e)}let o=new Map,n=e=>{if(o.has(e))return;let r=t.get(e),n=i.get(e),a=new Map;for(let[e,t]of r??[])a.set(e,(a.get(e)??0)+t);for(let[e,t]of n??[])a.set(e,(a.get(e)??0)+t);if(1===a.size){let[t,i]=[...a][0];o.set(e,{partner:t,weight:i})}};for(let t of e)n(t.source),n(t.target);return o}function xa(e,t,i){let r=i.get(e),o=i.get(t);return!r||!o||r.partner===o.partner||r.partner===t||o.partner===e}function ba(e,t,i){return!!i.has(e)&&t.some(t=>!xa(e,t,i))}function va(e,t){return(e.value>0&&Number.isFinite(e.value)?e.value:1)*(1+(1===t.outgoing.get(e.source)?1:0)+(1===t.incoming.get(e.target)?1:0))}function wa(e,t,i,r){if(12>=e.length||1>=r.slotCount)return r.assignment;let o=new Map(e.map((e,t)=>[e,t])),n=Array.from({length:e.length},()=>new Map),a=ga(i);for(let e of i){let t=o.get(e.source),i=o.get(e.target);if(null==t||null==i||t===i)continue;let r=va(e,a);n[t].set(i,(n[t].get(i)??0)+r),n[i].set(t,(n[i].get(t)??0)+r)}let s=ma(i),l=e.map(e=>s.get(e)?.weight??0),c=Array.from({length:e.length},()=>new Map),u=0;for(let i=0;e.length-1>i&&5e4>u;i++)if(s.has(e[i]))for(let r=i+1;e.length>r;r++){if(!s.has(e[r])||t.conflicts(e[i],e[r]))continue;u++;let o=Math.min(l[i],l[r])||Math.max(l[i],l[r]),n=xa(e[i],e[r],s)?o:-o;if(Math.abs(n)>Cm&&(c[i].set(r,n),c[r].set(i,n),u>=5e4))break}let d=[...r.assignment],h=Array.from({length:r.slotCount},()=>[]);d.forEach((e,t)=>h[e].push(t));let p=(e,t,i)=>{let r=d[t],o=d[i],n=0,a=new Set;for(let s of[t,i])for(let[l,c]of e[s]){let e=l>s?`${s}:${l}`:`${l}:${s}`;if(a.has(e))continue;a.add(e);let u=(s===t?o:r)===(l===t?o:l===i?r:d[l]);d[s]===d[l]!==u&&(n+=u?c:-c)}return n},f=(e,t,i)=>{let r=0;for(let[o,n]of e[t]){let e=i===d[o];d[t]===d[o]!==e&&(r+=e?n:-n)}return r},y=(e,t)=>e>Cm||Cm>=Math.abs(e)&&t>Cm,g=(e,t,i,r)=>e>i+Cm||Cm>=Math.abs(e-i)&&t>r+Cm,m=0;for(let i=0;32>i&&Lm>m;i++){let i=null,r=-1,o=-1,a=-1,s=-1/0,l=-1/0;for(let u=0;e.length>u;u++){for(let p=0;h.length>p&&m++<Lm;p++){if(p===d[u]||!h[p].every(i=>!t.conflicts(e[u],e[i])))continue;let m=f(n,u,p),x=f(c,u,p);y(m,x)&&g(m,x,s,l)&&(i="move",r=u,o=-1,a=p,s=m,l=x)}if(m>=Lm)break}for(let u=0;e.length-1>u;u++){for(let f=u+1;e.length>f&&m++<Lm;f++){let m=d[u],x=d[f];if(m===x||!h[x].every(i=>i===f||!t.conflicts(e[u],e[i]))||!h[m].every(i=>i===u||!t.conflicts(e[f],e[i])))continue;let b=p(n,u,f),v=p(c,u,f);y(b,v)&&g(b,v,s,l)&&(i="swap",r=u,o=f,a=-1,s=b,l=v)}if(m>=Lm)break}if(null==i||-1===r)break;if("move"===i){let e=d[r];h[e].splice(h[e].indexOf(r),1),h[a].push(r),d[r]=a;continue}let u=d[r],x=d[o];h[u].splice(h[u].indexOf(r),1,o),h[x].splice(h[x].indexOf(o),1,r),d[r]=x,d[o]=u}return d}function ka(e,t){let i=1/0,r=-1/0;for(let t of e?.samples??[])1e-9>=t.topMass+t.botMass||(i=Math.min(i,t.t),r=Math.max(r,t.t));return Number.isFinite(i)&&Number.isFinite(r)?(null!=t.start&&(i=Math.max(i,t.start)),null!=t.end&&(r=Math.min(r,t.end)),i>r?{start:null,end:null}:{start:i,end:r}):{start:null,end:null}}function Aa(e,t,i,r){let o=function(e,t,i,r){return`${e.map(e=>{let t=i[e.id],o=r[e.id];return[e.id,e.group??"",e.xExtent?.[0]??"",e.xExtent?.[1]??"",t?.topPeak??0,t?.botPeak??0,o?.start??"",o?.end??""].join(":")}).join("|")}#${t.map(e=>[e.id,e.source,e.target,e.value,e.startTime,e.endTime].join(":")).join("|")}`}(e,t,i,r),n=Rm.get(o);if(n)return pa(n.slots,i,r);let a=Fn();for(let t of e)a[t.id]=ka(i[t.id],r[t.id]);let s=function(e,t){return e.filter(e=>null!=t[e.id].start).sort((e,i)=>t[e.id].start-t[i.id].start||t[e.id].end-t[i.id].end||Dn(e.id,i.id)).map(e=>e.id)}(e,a),l=new Map(e.map(e=>[e.id,e])),c=new Map(e.map(e=>[e.id,e.group||void 0])),u=ma(t),d=function(e,t,i,r,o,n){let a=new Set,s=new Map(e.map(e=>[e,new Set])),l=new Map(e.map(e=>[e,new Set]));for(let e of r)a.add(ya(e.source,e.target)),s.get(e.target)?.add(e.source),l.get(e.source)?.add(e.target);let c=new Map,u=new Set,d=(e,t)=>{for(let i=0;e.length>i;i++)for(let r=i+1;e.length>r;r++){let o=ya(e[i],e[r]);t instanceof Map?t.set(o,[e[i],e[r]]):t.add(o)}};for(let e of l.values())d([...e],c);for(let e of s.values())d([...e],u);let h=new Set;for(let[e,[r,o]]of c)u.has(e)&&(fa(t[r],t[o])||fa(i[r],i[o])&&(h.add(r),h.add(o)));return{conflicts:(e,i)=>{let r=o.get(e),s=o.get(i);return!((null==r||null==s||r===s)&&(null!=r==(null!=s)||a.has(ya(e,i))||n.has(e)&&n.has(i)&&xa(e,i,n))&&!fa(t[e],t[i])&&(!h.has(e)&&!h.has(i)||a.has(ya(e,i))))}}}(s,a,r,t,c,u),h=function(e,t,i=new Map){let r=[],o=[];for(let n of e){let e=r.findIndex(e=>e.every(e=>!t.conflicts(n,e))&&!ba(n,e,i));-1===e&&!i.has(n)&&(e=r.findIndex(e=>e.every(e=>!t.conflicts(n,e)))),-1===e&&(e=r.length,r.push([])),r[e].push(n),o.push(e)}return{assignment:o,slotCount:r.length}}(s,d,u),p=function(e,t,i,r){if(0===e.length||e.length>12||1>=r.slotCount)return r.assignment;let o=new Map(e.map((e,t)=>[e,t])),n=Array.from({length:e.length},()=>new Float64Array(e.length)),a=Array.from({length:e.length},()=>new Map),s=Array.from({length:e.length},()=>new Map),l=ga(i);for(let e of i){let t=o.get(e.source),i=o.get(e.target);if(null==t||null==i||t===i)continue;let r=va(e,l);n[t][i]+=r,n[i][t]+=r,s[t].set(i,(s[t].get(i)??0)+r),a[i].set(t,(a[i].get(t)??0)+r)}let c=ma(i),u=e.map(e=>c.get(e)?.weight??0),d=Array.from({length:e.length},()=>new Float64Array(e.length));for(let t=0;e.length>t;t++)for(let i=t+1;e.length>i;i++){for(let[e,r]of a[t])d[t][i]+=Math.min(r,a[i].get(e)??0);for(let[e,r]of s[t])d[t][i]+=Math.min(r,s[i].get(e)??0);if(c.has(e[t])&&c.has(e[i])){let r=Math.min(u[t],u[i])||Math.max(u[t],u[i]);d[t][i]+=xa(e[t],e[i],c)?r:-r}d[i][t]=d[t][i]}let h=[...r.assignment],p=(t=>{let i=0,r=0;for(let o=0;e.length>o;o++)for(let a=o+1;e.length>a;a++)t[o]===t[a]&&(i+=n[o][a],r+=d[o][a]);return{flow:i,affinity:r}})(h),f=0,y=Array(e.length).fill(-1),g=Array.from({length:r.slotCount},()=>[]),m=(i,o,a,s)=>{if(f>=75e3)return;if(i===e.length)return f++,void((a>p.flow||a===p.flow&&s>p.affinity||a===p.flow&&s===p.affinity&&function(e,t){for(let i=0;Math.min(e.length,t.length)>i;i++)if(e[i]!==t[i])return t[i]>e[i];return t.length>e.length}(y,h))&&(h=[...y],p={flow:a,affinity:s}));let l=Math.min(o+1,r.slotCount-1);for(let r=0;l>=r;r++){if(g[r].some(r=>t.conflicts(e[i],e[r])))continue;let l=0,c=0;for(let e of g[r])l+=n[i][e],c+=d[i][e];if(y[i]=r,g[r].push(i),m(i+1,Math.max(o,r),a+l,s+c),g[r].pop(),y[i]=-1,f>=75e3)return}};return y[0]=0,g[0].push(0),m(1,0,0,0),h}(s,d,t,{...h,assignment:wa(s,d,t,h)}),f=new Map,y=p.map(e=>(f.has(e)||f.set(e,f.size),f.get(e))),g=Array.from({length:f.size||(e.length>0?1:0)},()=>({occupants:[],peak:{topPeak:0,botPeak:0}})),m=Fn();s.forEach((e,t)=>{let i=y[t],r=g[i];r.occupants.push({id:e,end:a[e].end??-1/0});let o=l.get(e)?.group;o&&(r.group=o),m[e]=i});for(let t of[...e].sort((e,t)=>Dn(e.id,t.id)))null==m[t.id]&&(g[0].occupants.push({id:t.id,end:-1/0}),m[t.id]=0);for(let e of g){e.occupants.sort((e,t)=>(a[e.id].start??1/0)-(a[t.id].start??1/0)||Dn(e.id,t.id));for(let t of e.occupants){let r=i[t.id];e.peak.topPeak=Math.max(e.peak.topPeak,r?.topPeak||0),e.peak.botPeak=Math.max(e.peak.botPeak,r?.botPeak||0)}}let x={slots:g,slotByNode:m};return function(e,t){for(Rm.has(e)&&Rm.delete(e),Rm.set(e,{slots:t.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),slotByNode:Object.assign(Fn(),t.slotByNode)});Rm.size>12;){let e=Rm.keys().next().value;if(null==e)break;Rm.delete(e)}}(o,x),x}function Sa(e){return e.topMass+e.botMass}function Ma(e){let t=new Map;for(let i of e.samples){if(Number.isNaN(i.t))continue;let e=t.get(i.t);e||(e=[],t.set(i.t,e)),e.push(i)}let i=0,r=-1/0;return o=>{o>=r||(i=0),r=o;let n=t.get(o);if(n){let e=n.reduce((e,t)=>Sa(t)<Sa(e)?e:t,n[0]);return{exact:n,sample:e}}for(;e.samples.length>i&&o>=e.samples[i].t;)i++;return{exact:n,sample:e.samples[i-1]??null}}}function $a(e,t,i,r,o,n,a=0){let s=new Map;for(let i of e){if(!i.group||!t[i.id])continue;let e=s.get(i.group)??[];e.push(i),s.set(i.group,e)}if(0===s.size||0>=n)return t;let l=Object.fromEntries(Object.entries(t).map(([e,t])=>[e,{...t,samples:t.samples.map(e=>({...e})),localAttachments:new Map([...t.localAttachments].map(([e,t])=>[e,{...t}]))}]));for(let[e,c]of s){let s=i.map((e,t)=>({slot:e,index:t})).filter(({slot:t})=>t.group===e);if(0===s.length)continue;let u=s[0].slot,d=s.at(-1).slot,h=o[u.occupants[0]?.id],p=o[d.occupants[0]?.id];if(!Number.isFinite(h)||!Number.isFinite(p))continue;let f=(h-u.peak.topPeak*n+(p+d.peak.botPeak*n))/2,y=[...new Set(c.flatMap(e=>t[e.id].samples.map(e=>e.t)))].sort((e,t)=>e-t),g=new Map;for(let e of c)g.set(e.id,new Map);let m=new Map(c.map(e=>[e.id,Ma(t[e.id])]));for(let e of y){let t=new Map;for(let i of c){let{sample:o}=m.get(i.id)(e);if(!o||1e-9>=Sa(o))continue;let n=r[i.id];if(null==n)continue;let a=t.get(n)??[];a.push({node:i,sample:o}),t.set(n,a)}let i=[...t].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({slot:e,active:t,mass:Math.max(...t.map(({sample:e})=>Sa(e)))}));if(0===i.length)continue;let s=f-(i.reduce((e,t)=>e+t.mass,0)*n+Math.max(0,a)*Math.max(0,i.length-1))/2;for(let t of i){for(let{node:i,sample:r}of t.active){let t=(s-o[i.id])/n+r.topMass-(r.boundaryOffset??0);g.get(i.id).set(e,t)}s+=t.mass*n+Math.max(0,a)}}for(let e of c){let i=t[e.id],r=l[e.id],o=g.get(e.id),n=m.get(e.id),a=[];for(let e of y){let t=o.get(e),{exact:i,sample:r}=n(e);i?a.push(...i.map(e=>({...e,...null!=t?{boundaryOffset:(e.boundaryOffset??0)+t}:{}}))):null==t||!r||1e-9>=Sa(r)||a.push({...r,t:e,boundaryOffset:(r.boundaryOffset??0)+t})}r.samples=a,r.localAttachments=new Map([...i.localAttachments].map(([e,t])=>{let i=o.get(t.time);return[e,{...t,...null!=i?{boundaryOffset:(t.boundaryOffset??0)+i}:{}}]}))}}return l}function _a(e,t,i,r,o){let{plotH:n,padding:a,valueScale:s,packing:l,laneOrder:c,lifetimeMode:u="half",lanePlacement:d="stack",groupPadding:h=0,ribbonLane:p="both",domain:f}=o,y=Fn(),g=Fn();for(let t of e)y[t.id]=i[t.id].topPeak||0,g[t.id]=i[t.id].botPeak||0;let m="half"===u,x=Fn();for(let t of e){let e=Array.isArray(t.xExtent)?t.xExtent[0]:null,i=Array.isArray(t.xExtent)?t.xExtent[1]:null,o=null!=e&&Number.isFinite(e)?e:1/0,n=null!=i&&Number.isFinite(i)?i:-1/0;for(let 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);let t=m?(e.startTime+e.endTime)/2:e.endTime;t>n&&(n=t)}for(let e of r.incoming[t.id]){let t=m?(e.startTime+e.endTime)/2:e.startTime;o>t&&(o=t),e.endTime>n&&(n=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>n&&(n=e.systemOutTime)}x[t.id]={start:Number.isFinite(o)?o:null,end:Number.isFinite(n)?n:null}}let b=Fn(),v=[],w=[];if(o.frozenSlots){let e=pa(o.frozenSlots,i,x);v=e.slots,b=e.slotByNode,w=v.map(En)}else if("reuse"===l){let r=Aa(e,t,i,x);v=r.slots,b=r.slotByNode}else e.forEach((e,t)=>{v.push({occupants:[{id:e.id,end:x[e.id]?.end??-1/0}],peak:{topPeak:y[e.id],botPeak:g[e.id]},...e.group?{group:e.group}:{}}),b[e.id]=t});sa(v,b),0===w.length&&(w=v.map(En));let k=null;o.frozenSlots||(o.fixedSlotOrder?function(e,t,i){let r=new Map(i.map((e,t)=>[e,t]));ia(e,t,[...e].sort((e,t)=>(r.get(En(e))??1/0)-(r.get(En(t))??1/0)||Dn(En(e),En(t))))}(v,b,o.fixedSlotOrder):o.runOrdering&&c&&"insertion"!==c&&(k=ha(e,t,i,x,v,b,{plotH:n,padding:a,valueScale:s,groupPadding:h,laneOrder:c,ribbonLane:p,domain:f}))),sa(v,b);let A=Wn(e,t,i,v,b,{plotH:n,padding:a,valueScale:s,stackValueScale:o.stackValueScale,lanePlacement:d,groupPadding:h}),S=0===v.length?0:v[0].peak.topPeak+A.adjacentClearance.reduce((e,t)=>e+t,0)+v[v.length-1].peak.botPeak,M=k?.before.crossings??null,$=k?.after.crossings??null,_=k?.before.weightedLength??null,P=k?.after.weightedLength??null;return{effectiveSlotsHeight:S,centerlines:A.centerlines,laneLifetime:x,slots:v,slotByNode:b,slotCenter:A.slotCenter,stackCenter:A.stackCenter,verticalUtilization:A.verticalUtilization,selectedSlotOrder:v.map(En),initialSlotOrder:w,ordering:k,crossingsBefore:M,crossingsAfter:$,lengthBefore:_,lengthAfter:P}}function Pa(e){let{sx:t,sTop:i,sBot:r,tx:o,tTop:n,tBot:a,cp1X:s,cp2X:l}=e,c=(i+r)/2,u=(n+a)/2;return{pathD:[`M${t},${i}`,`C${s},${i} ${l},${n} ${o},${n}`,`L${o},${a}`,`C${l},${a} ${s},${r} ${t},${r}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:s,y:c},{x:l,y:u},{x:o,y:u}],halfWidth:(r-i)/2}}}function Ia(e,t,i,r,o,n,a,s,l={}){let c,u,d,h,p=o,f=e=>s?Math.max(s[0],Math.min(s[1],e)):e,y=n(f(e.time)),g=n(f(i.time)),m=e.value*p,x=i.value*p,b=t+(e.boundaryOffset??0)*p,v=r+(i.boundaryOffset??0)*p,w=e.sideMassBefore*p,k=i.sideMassAfter*p;"top"===e.side?(c=b-w,u=c+m):(u=b+w,c=u-m),"top"===i.side?(d=v-k,h=d+x):(h=v+k,d=h-x);let A=l.sourceRunwayStart,S=l.minRun,M=Math.abs((d+h)/2-(c+u)/2),$=g-y,_="number"==typeof A&&Number.isFinite(A),P="number"==typeof S&&Number.isFinite(S)&&S>0;if(_&&M>1e-9&&$>0&&("auto"===S||P)){let t="source"===a?.85:"target"===a?.15:.5,i="auto"===S?Math.min(144,Math.sqrt(8*M/(1.5*Math.min(t*t,(1-t)*(1-t))))):S;if(i>$){let t=n(f(Math.min(A,e.time)));Number.isFinite(t)&&(y=Math.min(y,Math.max(Math.min(y,t),g-i)))}}let I="source"===a?y+.85*(g-y):"target"===a?y+.15*(g-y):(y+g)/2;return{sx:y,sTop:c,sBot:u,tx:g,tTop:d,tBot:h,cp1X:I,cp2X:I}}function Ra(e){return Math.max(18,11*e.length*.58)}function La(e){let t=1.22*Ra(e.labelText)+4;return"start"===e.labelAnchor?[e.labelX,e.labelX+t]:"middle"===e.labelAnchor?[e.labelX-t/2,e.labelX+t/2]:[e.labelX-t,e.labelX]}function Ca(e,t){let i=e.labelX-Ra(e.labelText),r=t.labelX-Ra(t.labelText);return t.labelX+3>=i&&e.labelX+3>=r}function Ta(e){return e.replace(Tm,(e,t,i)=>`${i},${t}`)}function Oa(e){if(!e)return;let t=e=>({x:e.y,y:e.x});return{...e,...e.points&&{points:e.points.map(t)},...e.segments&&{segments:e.segments.map(e=>e.map(t))}}}function Fa(e){return{...e,pathD:Ta(e.pathD),y0:e.x0,y1:e.x1,x0:0,x1:0}}function Da(e){let{nodes:t,edges:i,domain:r,plotW:o,plotH:n,ribbonLane:a,ribbonMinRun:s=0,edgeOpacity:l,colorOf:c,layoutOpts:u,orientation:d="horizontal",showLabels:h=!0,labelPriorityAccessor:p,maxLabels:f,selectionDatum:y="raw",styleRules:g,colorBy:m,valueAccessor:x,usageMode:b="static"}=e,v="vertical"===d?n:o,w="vertical"===d?o:n,k=function(e,t,i,r={}){let o=_n(r.usageMode??"static"),n=[],a=new Set;for(let t of e)a.has(t.id)&&n.push({kind:"duplicate-node",id:t.id,severity:o.duplicateIds}),a.add(t.id);let s=new Set,l=Array.isArray(i)&&2===i.length,c=l&&Number.isFinite(i[0])&&Number.isFinite(i[1]);(!l||!c||!c||i[0]>i[1])&&n.push({kind:"invalid-domain"});for(let t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||n.push({kind:"invalid-node-time",id:t.id}));for(let e of t)s.has(e.id)&&n.push({kind:"duplicate-edge",id:e.id,severity:o.duplicateIds}),s.add(e.id),a.has(e.source)||n.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),a.has(e.target)||n.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?((null!=e.systemInTime&&!Number.isFinite(e.systemInTime)||null!=e.systemOutTime&&!Number.isFinite(e.systemOutTime))&&n.push({kind:"invalid-system-time",id:e.id,severity:"warn"}),(!Number.isFinite(e.value)||0>=e.value)&&n.push({kind:"invalid-value",id:e.id}),e.startTime>e.endTime&&n.push({kind:"backward-edge",severity:"fatal",id:e.id,source:e.source,target:e.target})):n.push({kind:"invalid-edge-time",id:e.id});return n}(t,i,r,{usageMode:b}),{fatal:A,warnings:S}=function(e){let t=[],i=[];for(let r of e)"fatal"===Pn(r)?t.push(r):i.push(r);return{fatal:t,warnings:i}}(k),M=function(e,t,i="static"){if("strip"!==_n(i).invalidSystemTime)return e;let r=new Set(t.filter(e=>"invalid-system-time"===e.kind).map(e=>e.id));return 0===r.size?e:e.map(e=>{if(!r.has(e.id))return e;let t={...e};return null!=t.systemInTime&&!Number.isFinite(t.systemInTime)&&delete t.systemInTime,null!=t.systemOutTime&&!Number.isFinite(t.systemOutTime)&&delete t.systemOutTime,t})}(i,k,b),$=Sm().domain(r).range([0,v]);if(A.length>0)return{layout:null,layoutConfig:{bands:[],ribbons:[],showLabels:!1!==h},issues:A,warnings:S,xScale:$};let _=function(e,t,i){let{plotH:r,pairing:o="temporal",packing:n="reuse",laneOrder:a="crossing-min",lifetimeMode:s="half",maxValueScale:l,lanePlacement:c="stack",nodeSizing:u="temporal",groupPadding:d=0,ribbonLane:h="both",domain:p}=i,f=Number.isFinite(d)?Math.max(0,d):0,y=function(e,t){let i=Fn(),r=Fn();for(let t of e)i[t.id]=[],r[t.id]=[];for(let e of t)r[e.source]&&r[e.source].push(e),i[e.target]&&i[e.target].push(e);return{incoming:i,outgoing:r}}(e,t),g=function(e,t,i,r="temporal"){let o="temporal"===r?(e,t)=>e.endTime-t.endTime||Dn(e.id,t.id):(e,t)=>t.value-e.value||Dn(e.id,t.id),n="temporal"===r?(e,t)=>e.startTime-t.startTime||Dn(e.id,t.id):(e,t)=>t.value-e.value||Dn(e.id,t.id),a=new Map;for(let e of t)a.set(e.id,{});let s=(e,t)=>{let i=new Map;for(let r of e){let e=r[t];i.has(e)||i.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});let o=i.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)}let a=[...i.values()];a.sort("temporal"===r?(e,i)=>"target"===t?e.earliestStart-i.earliestStart||Dn(e.partner,i.partner):e.latestEnd-i.latestEnd||Dn(e.partner,i.partner):(e,t)=>t.total-e.total||Dn(e.partner,t.partner));for(let e of a)e.edges.sort("target"===t?n:o);return a};for(let t of e){let e=i.outgoing[t.id],r=i.incoming[t.id];if(0===r.length)s(e,"target").forEach((e,t)=>{let i=t%2==0?"top":"bot";for(let t of e.edges)a.get(t.id).sourceSide=i});else if(0===e.length)s(r,"source").forEach((e,t)=>{let i=t%2==0?"top":"bot";for(let t of e.edges)a.get(t.id).targetSide=i});else{let t=s(r,"source"),i=s(e,"target"),o=Math.max(t.length,i.length);for(let e=0;o>e;e++){let r=e%2==0?"top":"bot";if(t[e])for(let i of t[e].edges)a.get(i.id).targetSide=r;if(i[e])for(let t of i[e].edges)a.get(t.id).sourceSide=r}}}return a}(e,t,y,o),m=Fn();for(let t of e)m[t.id]=ea(t,y,g,void 0,u);let x=_a(e,t,m,y,{plotH:r,padding:12,valueScale:1,packing:n,laneOrder:a,lifetimeMode:s,runOrdering:!0,lanePlacement:"stack",groupPadding:f,ribbonLane:h,domain:p}),b=x.slots.map(e=>({occupants:e.occupants.map(e=>({...e})),peak:{...e.peak},...null!=e.group?{group:e.group}:{}})),v=new Set;for(let e of t){let t=x.slotByNode[e.source],i=x.slotByNode[e.target];if(void 0===t||void 0===i)continue;let r=g.get(e.id);t!==i?t>i?(r.sourceSide="top",r.targetSide="bot"):(r.sourceSide="bot",r.targetSide="top"):(v.add(e.id),r.sourceSide="bot",r.targetSide="bot")}for(let t of e){let e=y.outgoing[t.id],i=y.incoming[t.id],r=new Set(e.map(e=>g.get(e.id).sourceSide)),o=new Set(i.map(e=>g.get(e.id).targetSide));if(1===r.size&&i.length>0){let e=[...r][0];for(let t of i)x.slotByNode[t.source]===x.slotByNode[t.target]&&(g.get(t.id).targetSide=e)}if(1===o.size&&e.length>0){let t=[...o][0];for(let i of e)x.slotByNode[i.source]===x.slotByNode[i.target]&&(g.get(i.id).sourceSide=t)}}(function(e,t,i){let r=new Map,o=[];for(let t of e)o.push({time:t.startTime,kind:"out",edge:t}),o.push({time:t.endTime,kind:"in",edge:t});o.sort((e,t)=>e.time-t.time||(e.kind===t.kind?0:"in"===e.kind?-1:1)||("out"===e.kind?t.edge.value-e.edge.value:0)||Dn(e.edge.id,t.edge.id));let n=e=>{let t=r.get(e);return t||(t={top:0,bot:0},r.set(e,t)),t},a=(e,t,i)=>{let r="top"===t?"bot":"top",o=Math.min(i,e[t]);e[t]-=o;let n=i-o;n>0&&(e[r]=Math.max(0,e[r]-n))};for(let e of o){let{edge:r}=e;if("in"===e.kind){let e=t.get(r.id)?.targetSide??"bot";n(r.target)[e]+=r.value;continue}let o=n(r.source),s=t.get(r.id),l=s.sourceSide??"bot";if(i[r.source]===i[r.target]){let e=o.top>=r.value,t=o.bot>=r.value;e!==t?l=e?"top":"bot":!e&&!t&&o.top!==o.bot&&(l=o.top>o.bot?"top":"bot"),s.sourceSide=l,s.targetSide=l}a(o,l,r.value)}})(t,g,x.slotByNode),function(e,t,i,r){for(let o of e){let e=t.incoming[o.id],n=t.outgoing[o.id];if(0===e.length||0===n.length)continue;let a=()=>{let t={inTop:0,inBot:0,outTop:0,outBot:0};for(let r of e)"top"===i.get(r.id).targetSide?t.inTop+=r.value:t.inBot+=r.value;for(let e of n)"top"===i.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},s=(e,t)=>{let o=a(),s="top"===e?o.outTop-o.inTop:o.outBot-o.inBot,l="top"===t?o.inTop-o.outTop:o.inBot-o.outBot;if(0>=s||0>=l)return!1;let c=Math.min(s,l),u=n.filter(t=>!r.has(t.id)&&i.get(t.id).sourceSide===e&&c>=t.value).sort((e,t)=>t.value-e.value||Dn(e.id,t.id));return 0!==u.length&&(i.get(u[0].id).sourceSide=t,!0)},l=n.length+1;for(;l-- >0&&(s("top","bot")||s("bot","top")););}}(e,y,g,v),m=Fn();for(let t of e)m[t.id]=ea(t,y,g,void 0,u);let w=_a(e,t,m,y,{plotH:r,padding:12,valueScale:1,packing:n,laneOrder:a,lifetimeMode:s,frozenSlots:b,lanePlacement:"stack",groupPadding:f,ribbonLane:h,domain:p}),k=w.effectiveSlotsHeight??w.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),A=w.slots.slice(0,-1).reduce((e,t,i)=>e+(null!=t.group&&t.group===w.slots[i+1].group?1:0),0),S=Math.max(1,w.slots.length+1-A),M=Math.min(12,Math.max(0,.35*r-A*f)/S),$=2*M+Nn(w.slots,M,f).reduce((e,t)=>e+t,0),_=k>0?Math.max(0,(r-$)/k):1,P=Number.isFinite(l)&&l>0?Math.min(_,l):_,I=_a(e,t,m,y,{plotH:r,padding:M,valueScale:P,packing:n,laneOrder:a,lifetimeMode:s,frozenSlots:b,lanePlacement:c,groupPadding:f,ribbonLane:h,domain:p,stackValueScale:_}),R=Number.isFinite(l)&&l>0&&_>l+1e-12;if("insertion"!==a&&("hug"===c||R)&&I.slots.length>1&&(ha(e,t,m,I.laneLifetime,I.slots,I.slotByNode,{plotH:r,padding:M,valueScale:P,groupPadding:f,laneOrder:a,ribbonLane:h,domain:p,lanePlacement:c,mode:"geometry-refine"}),I=_a(e,t,m,y,{plotH:r,padding:M,valueScale:P,packing:n,laneOrder:a,lifetimeMode:s,frozenSlots:I.slots,fixedSlotOrder:I.slots.map(En),lanePlacement:c,groupPadding:f,ribbonLane:h,domain:p,stackValueScale:_})),function(e,t){let i=(e,i)=>{for(let r of e){let e=new Map;for(let o of r){let r=`${("out"===i?t.get(o.id)?.sourceSide:t.get(o.id)?.targetSide)??""}\0${"out"===i?o.startTime:o.endTime}`,n="out"===i?`${o.target}\0${o.endTime}`:`${o.source}\0${o.startTime}`,a=e.get(r);if(null!=a&&a!==n)return!0;e.set(r,n)}}return!1};return i(Object.values(e.outgoing),"out")||i(Object.values(e.incoming),"in")}(y,g)){let i=function(e,t,i,r){let o=new Map;for(let n of e){let e=t[n.source]?.localAttachments.get(n.id),a=t[n.target]?.localAttachments.get(n.id),s=i[n.source],l=i[n.target];if(!(e&&a&&Number.isFinite(s)&&Number.isFinite(l)))continue;let c=Jn(e,s,r),u=Jn(a,l,r);o.set(n.id,{source:(c[0]+c[1])/2,target:(u[0]+u[1])/2})}return o}(t,m,I.centerlines,P);m=Fn();for(let t of e)m[t.id]=ea(t,y,g,i,u);I=_a(e,t,m,y,{plotH:r,padding:M,valueScale:P,packing:n,laneOrder:a,lifetimeMode:s,frozenSlots:I.slots,fixedSlotOrder:I.slots.map(En),lanePlacement:c,groupPadding:f,ribbonLane:h,domain:p,stackValueScale:_})}let L=new Map(x.initialSlotOrder.map((e,t)=>[e,t])),C=[...I.slots].sort((e,t)=>(L.get(En(e))??1/0)-(L.get(En(t))??1/0)||Dn(En(e),En(t))),T=Fn();C.forEach((e,t)=>{for(let i of e.occupants)T[i.id]=t});let O=Wn(e,t,m,C,T,{plotH:r,padding:M,valueScale:P,stackValueScale:_,lanePlacement:"stack",groupPadding:f}),F=$a(e,m,C,T,O.centerlines,P,f),D=Kn(ca(T,t),ua(T,t),t,F,C,T,O.centerlines,I.laneLifetime,P,O.verticalUtilization,h,p);m=$a(e,m,I.slots,I.slotByNode,I.centerlines,P,f);let E=Kn(ca(I.slotByNode,t),ua(I.slotByNode,t),t,m,I.slots,I.slotByNode,I.centerlines,I.laneLifetime,P,I.verticalUtilization,h,p);return{nodeData:m,sides:g,valueScale:P,padding:M,compressedPadding:12>M,centerlines:I.centerlines,laneLifetime:I.laneLifetime,slots:I.slots,slotByNode:I.slotByNode,crossingsBefore:"insertion"===a?null:D.crossings,crossingsAfter:"insertion"===a?null:E.crossings,lengthBefore:"insertion"===a?null:D.weightedLength,lengthAfter:"insertion"===a?null:E.weightedLength,layoutQualityBefore:D,layoutQuality:E}}(t,M,{plotH:w,...u,ribbonLane:a,domain:r}),{centerlines:P,nodeData:I,valueScale:R}=_,L=Se(m,x),C=[],T=[],O=0===s?new Map:function(e,t,i){let r=new Set(t.map(e=>e.target)),o=new Map(e.map(e=>[e.id,e])),n=new Map;for(let e of t){if(r.has(e.source))continue;let t=n.get(e.source)??[];t.push(e),n.set(e.source,t)}let a=new Map;for(let t of e){if(!t.group)continue;let e=a.get(t.group)??[];e.push(t),a.set(t.group,e)}let s=new Set;for(let[e,t]of a){let i=t.flatMap(e=>n.get(e.id)??[]),o=new Set(i.map(e=>e.startTime));i.length>0&&1===o.size&&t.every(e=>{let t=e.xExtent?.[0],o=i[0].startTime;return!r.has(e.id)&&(n.get(e.id)?.length??0)>0&&Number.isFinite(t)&&o>t})&&s.add(e)}let l=new Map;for(let[e,t]of n){let r=o.get(e);if(r?.group&&!s.has(r.group))continue;let n=r?.xExtent?.[0],a=[...t].sort((e,t)=>e.startTime-t.startTime||e.id.localeCompare(t.id)),c=a[0]?.startTime-1,u=null;for(let e=0;a.length>e;){let t=a[e].startTime,r=e+1;for(;a.length>r&&a[r].startTime===t;)r++;for(let t=e;r>t;t++){let e=a[t],r=Number.isFinite(n)&&e.startTime>n,o=Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime;if(!r&&!o)continue;let s=i[0];r&&(s=Math.max(s,n)),o&&(s=Math.max(s,e.systemInTime)),!r&&o&&Number.isFinite(c)&&(s=Math.max(s,c)),null!=u&&(s=Math.max(s,u)),e.startTime>s&&l.set(e.id,s)}u=t,e=r}}for(let[e,t]of a){if(!s.has(e))continue;let i=t.flatMap(e=>n.get(e.id)??[]);if(!i.every(e=>l.has(e.id))){for(let e of i)l.delete(e.id);continue}let r=Math.max(...i.map(e=>l.get(e.id)));for(let e of i)l.set(e.id,r)}return l}(t,M,r),F=new Map(t.filter(e=>e.group).map(e=>[e.id,e.group])),D=new Map;for(let e of M){let t=I[e.source]?.localAttachments.get(e.id),i=I[e.target]?.localAttachments.get(e.id);!t||!i||D.set(e.id,Ia(t,P[e.source],i,P[e.target],R,$,a,r,{minRun:s,sourceRunwayStart:O.get(e.id)}))}let E=function(e,t,i,r,o,n){let a=new Map(t),s=new Map;for(let t of e){let e=n?.get(t.source),i=null==e?"node:"+t.source:"group:"+e,r=s.get(i)??new Map,o=r.get(t.startTime)??[];o.push(t),r.set(t.startTime,o),s.set(i,r)}for(let e of s.values())for(let[n,s]of e){if(!s.some(e=>i.has(e.id)))continue;let e=s.map(e=>t.get(e.id));if(e.some(e=>null==e))continue;let l=r(n),c=Math.min(...e.map(e=>e.sx));if(c>=l-1e-9)continue;let u=Math.max(...s.map(e=>{let t=i.get(e.id);return null==t?l:Math.min(l,r(t))})),d=Math.min(l,Math.max(c,u));for(let e of s){let i=t.get(e.id),r=d+(i.tx-d)*("source"===o?.85:"target"===o?.15:.5);a.set(e.id,{...i,sx:d,cp1X:r,cp2X:r})}}return a}(M,D,O,$,a,F),N=function(e,t,i,r,o){let n=new Map;for(let a of e){if(!i.has(a.id))continue;let e=t.get(a.id);if(!e||e.sx>=r(a.startTime)-1e-9)continue;let s=o(e.sx);Number.isFinite(s)&&a.startTime>s&&n.set(a.id,s)}return n}(M,E,O,$,e=>r[0]+e/v*(r[1]-r[0])),z=function(e,t,i){let r=new Map,o=new Map;for(let[e,t]of i??[]){let i=o.get(t)??[];i.push(e),o.set(t,i)}for(let n of e){let e=t.get(n.id);if(null==e||!Number.isFinite(e)||e>=n.startTime)continue;let a=i?.get(n.source),s=null==a?[n.source]:o.get(a)??[n.source];for(let t of s){let i=r.get(t)??new Map,o=i.get(n.startTime);i.set(n.startTime,null==o?e:Math.min(o,e)),r.set(t,i)}}return r}(M,N,F);t.forEach((e,t)=>{let i=I[e.id];if(!i||0===i.samples.length)return;let o=(a=i.samples,(s=z.get(e.id))&&0!==s.size?a.map(e=>{let t=s.get(e.t);return null==t?e:{...e,t:t}}):a),n=function(e,t,i,r,o){if(0===e.length)return null;let n=Qn(e,o),a=e=>t+(n[e].boundaryOffset??0)*i,s=e=>a(e)-n[e].topMass*i,l=e=>a(e)+n[e].botMass*i,c=`M${r(n[0].t)},${s(0)}`;for(let e=1;n.length>e;e++)c+=` L${r(n[e].t)},${s(e)}`;c+=` L${r(n[n.length-1].t)},${l(n.length-1)}`;for(let e=n.length-2;e>=0;e--)c+=` L${r(n[e].t)},${l(e)}`;return c+" Z"}(o,P[e.id],R,$,r);var a,s;if(!n)return;let l,u,h=Qn(o,r),p=h.find(e=>e.topMass+e.botMass>0)||h[0],f=P[e.id]+(p.botMass-p.topMass+2*(p.boundaryOffset??0))*R/2,y=c(e.id,t),m=y,x=.5,b=e.__raw??e;if(g&&g.length>0){let e=_e(b,g,L(b));"string"==typeof e.fill?y=e.fill:null!=e.fill&&fr(e.fill)&&(u=e.fill,y=e.fill.background&&"transparent"!==e.fill.background?e.fill.background:y),"string"==typeof e.stroke&&(m=e.stroke),"number"==typeof e.strokeWidth&&(x=e.strokeWidth),"number"==typeof e.fillOpacity&&(l=e.fillOpacity),"number"==typeof e.opacity&&null==l&&(l=e.opacity)}let v=function(e,t,i,r,o,n){let a=i.nodeData[e];if(!a||0===a.samples.length)return[];let s=i.valueScale,l=i.centerlines[e],c=Qn(a.samples,o),u=c.find(e=>e.topMass+e.botMass>0)||c[0],d=[...c].reverse().find(e=>e.topMass+e.botMass>0)||c[c.length-1],h=r(u.t),p=r(d.t),f=e=>r(Zn(e,o)),y=[],g=(e,t,i,r)=>`M${e},${t} L${i},${t} L${i},${r} L${e},${r} Z`;for(let i of t){if(i.source===e&&null!=i.systemInTime&&Number.isFinite(i.systemInTime)){let e=a.localAttachments.get(i.id),t=n?.get(i.id)??i.startTime;if(e&&"out"===e.kind&&t>i.systemInTime){let r=f(i.systemInTime),n=f(t),a=null!=o&&o[0]>i.systemInTime,c=a?r:r-20,u=a?Math.min(n,r+20):r,d=Math.max(h,c);if(n>d){let[t,i]=Jn(e,l,s);y.push({pathD:g(d,t,n,i),x0:c,x1:u,from:0,to:1})}}}if(i.target===e&&null!=i.systemOutTime&&Number.isFinite(i.systemOutTime)){let e=a.localAttachments.get(i.id);if(e&&"in"===e.kind&&i.systemOutTime>i.endTime){let t=f(i.systemOutTime),r=f(i.endTime),o=t+20,n=Math.min(p,o);if(n>r){let[i,a]=Jn(e,l,s);y.push({pathD:g(r,i,n,a),x0:t,x1:o,from:1,to:0})}}}}return y}(e.id,M,_,$,r,N);C.push({id:e.id,pathD:n,fill:y,stroke:m,strokeWidth:x,...null!=l&&{fillOpacity:l},...u&&{hatchFill:u},...v.length>0&&{gradientStubs:v},rawDatum:b,labelX:$("vertical"===d&&e.xExtent?e.xExtent[0]:p.t)-4,labelY:f,labelText:e.label??e.id})});let B=new Map;t.forEach((e,t)=>B.set(e.id,t)),M.forEach(e=>{let t=E.get(e.id);if(!t)return;let i=B.get(e.source)??0,r=c(e.source,i),{pathD:o,bezier:n}=Pa(t),a=e.__raw??e,s="function"==typeof l?Number(l(a)):l,u=Number.isFinite(s)?Math.max(0,Math.min(1,s)):.35;T.push({id:e.id,pathD:o,fill:r,opacity:u,rawDatum:a,bezier:n})});let j=function(e,t,i){let r=e.map(e=>({...e})),o=new Map;for(let e of r){let i=t[e.id];if(null==i)continue;let r=o.get(i)??[];r.push(e),o.set(i,r)}let n=e=>{if(2>e.length)return;let t=e.reduce((e,t)=>e+t.labelY,0)/e.length,r=(e.length-1)/2;e.forEach((e,o)=>{e.labelY=Math.max(8,Math.min(i-8,t+16*(o-r)))})};for(let e of o.values()){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],i=-1/0;for(let r of e){let e=r.labelX-Ra(r.labelText);t.length>0&&e>i+3&&(n(t),t=[],i=-1/0),t.push(r),i=Math.max(i,r.labelX)}n(t)}return function(e,t){let i=[...e].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX||e.id.localeCompare(t.id));for(let e=0;3>e;e+=1){for(let e=0;i.length>e;e+=1){let t=8;for(let r=0;e>r;r+=1)Ca(i[e],i[r])&&(t=Math.max(t,i[r].labelY+16));i[e].labelY=Math.max(i[e].labelY,t)}for(let e=i.length-1;e>=0;e-=1){let r=t-8;for(let t=e+1;i.length>t;t+=1)Ca(i[e],i[t])&&(r=Math.min(r,i[t].labelY-16));i[e].labelY=Math.min(i[e].labelY,r)}}}(r,i),r}(C,_.slotByNode,w).map(e=>function(e,t){return"horizontal"===t?e:{...e,pathD:Ta(e.pathD),gradientStubs:e.gradientStubs?.map(Fa),labelX:e.labelY,labelY:e.labelX,labelAnchor:"middle",labelBaseline:"auto"}}(e,d)),W="vertical"===d?function(e,t,i){let r=e.map(e=>({...e}));for(let e of r){let i=1.22*Ra(e.labelText)+4;e.labelX=t-4>i?Math.max(i/2+2,Math.min(t-i/2-2,e.labelX)):t/2}let o=[],n=[...r].sort((e,t)=>e.labelY-t.labelY||e.labelX-t.labelX);for(let e of n){let t=o[o.length-1];!t||Math.abs(t[0].labelY-e.labelY)>14?o.push([e]):t.push(e)}for(let e of o){e.sort((e,t)=>e.labelX-t.labelX||e.id.localeCompare(t.id));let t=[],r=new Map;for(let i of e){let[e,o]=La(i),n=t.findIndex(t=>e>t+8);-1===n&&(n=t.length),t[n]=o,r.set(i,n)}let o=e.reduce((e,t)=>e+t.labelY,0)/e.length,n=14*t.length+8>o;for(let t of e){let e=r.get(t)??0;t.labelY=n?Math.min(i-8,12+14*e):Math.max(8,o-14*e)}}return r}(j,o,n):j,Y=new Map;if(null!=p)for(let e of t){let t=e.__raw??e,i="function"==typeof p?p(t):Number(t[p]);Number.isFinite(i)&&Y.set(e.id,i)}let q=function(e,t,i,r,o={}){if(!1===r)return e.map(e=>({...e,labelText:"",labelDeferred:!1,labelFullText:void 0}));if(!0===r)return e.map(e=>({...e,labelDeferred:!1,labelFullText:void 0}));let n=Math.max(4,Math.min(e.length,Math.floor(Math.max(1,t*i)/14e3)));Number.isFinite(o.maxLabels)&&o.maxLabels>=0&&(n=Math.min(n,Math.floor(o.maxLabels)));let a=e.map((e,t)=>{let i=o.priorityById?.get(e.id),r=Math.abs(e.labelY);return{band:e,index:t,score:null!=i&&Number.isFinite(i)?1e6*i+Ra(e.labelText):Ra(e.labelText)+.01*r}}).filter(e=>e.band.labelText.trim().length>0).sort((e,t)=>t.score-e.score||e.index-t.index||e.band.id.localeCompare(t.band.id)),s=new Set(a.slice(0,n).map(e=>e.band.id));return e.map(e=>s.has(e.id)||0===e.labelText.trim().length?{...e,labelDeferred:!1,labelFullText:void 0}:{...e,labelFullText:e.labelText,labelText:"",labelDeferred:!0})}(W,o,n,h,{...Y.size>0&&{priorityById:Y},...null!=f&&{maxLabels:f}});return{layout:_,layoutConfig:{bands:q,ribbons:T.map(e=>function(e,t){return"horizontal"===t?e:{...e,pathD:Ta(e.pathD),bezier:Oa(e.bezier)}}(e,d)),showLabels:!1!==h,selectionDatum:y},issues:[],warnings:S,xScale:$}}function Ea(e,t,i,r="horizontal"){return"vertical"===r?{top:e?38:t?28:16,right:24,bottom:24,left:i?72:24}:{top:e?30:t?24:8,right:80,bottom:i?28:8,left:80}}function Na(e,t,i){return!t?.isActive||t.predicate(function(e,t){return"scene"===t?e:e.data}(e,i))}function za(e,t){if(!e)return[];let i=[],r=e=>{i.push(e);let o="function"==typeof t?t(e):e[t];o&&Array.isArray(o)&&o.forEach(r)};return r(e),i}function Ba(e,t,i,r){if(e&&e.length>0)return e;let o=new Set;return t.forEach(e=>{let t="function"==typeof i?i(e):e[i],n="function"==typeof r?r(e):e[r];o.add(t),o.add(n)}),Array.from(o).map(e=>({id:e}))}function ja(e,t,i={}){return wo(t?"function"==typeof t?i=>({...e(i),...t(i)??{}}):i=>({...e(i),...t}):e,i)}function Wa(e,t,i){let[r,o]=i;if(!t)return r;let[n,a]=t,s=a>n?a-n:0,l=Number(e),c=Number.isFinite(l)?l:n;return r+Math.max(0,Math.min(1,s>0?(c-n)/s:0))*(o-r)}function Ya(e){let{valueAccessor:t,valueDomain:i,edgeWidthRange:r,resolveStroke:o,edgeOpacity:n,edgeLinecap:a,styleRules:s}=e,l=ke(t);return Pe(e=>({stroke:o(e),strokeWidth:Wa(e[t],i,r),strokeLinecap:a,opacity:n,fillOpacity:0}),s,e=>({value:l(e)}))}function qa(e,t,i,r){let o,n,a=Array.isArray(e)?e:[];if(t){let e="string"==typeof t?t:"__geoColorBy",r="string"==typeof t?a:a.map(e=>({...e,__geoColorBy:t(e)}));o=li(r,e,i)}if(r.sizeBy){let e=a.map("function"==typeof r.sizeBy?r.sizeBy:e=>e?.[r.sizeBy]).filter(e=>null!=e&&isFinite(e));e.length>0&&(n=no(e))}return e=>({fill:t&&o?ai(e,t,o):Ff,fillOpacity:r.fillOpacity,stroke:"#fff",strokeWidth:r.strokeWidth,r:r.sizeBy?ci(e,r.sizeBy,r.sizeRange,n):r.pointRadius??6})}function Xa(e){return e&&"object"==typeof e&&e.properties?{...e.properties,...e}:e}function Ga(e,t){return e===t}function Va(e,t){if("function"==typeof e)return t=>+e(t);let i=e||t;return e=>+e[i]}function Ha(e,t){if("function"==typeof e)return e;let i=e||t;return e=>e[i]}function Ua(e,t){return"function"==typeof e?t=>e(t)+"":e?t=>t[e]+"":t?e=>e[t]+"":void 0}function Ka(e){return e?"function"==typeof e?e:t=>t[e]||t.id:null}function Za(e){return"string"==typeof e?e:e.id}function Qa(e){let t=e.trim();if(!t||!Number.isNaN(Number(t)))return NaN;let i=ax.test(t)?t+"-01":t;if(i===t&&10>t.length)return NaN;let r=Date.parse(i);return Number.isFinite(r)?r:NaN}function Ja(e){return e instanceof Date?e.getTime():"string"==typeof e?Qa(e):+e}function es(e){return new Set(Array.isArray(e)?e:[e])}function ts(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function is(e,t){return Math.min((e-t.startTime)/t.duration,1)}function rs(e,t,i){return e+(t-e)*i}function os(){return"u">typeof performance?performance.now():Date.now()}function ns(e,t,i){if(1>=i)return 1;let r=i-1;return function(e){let 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;let i=Math.max(0,e.age);if("step"===e.type)return(e.threshold??.5*e.extent)>i?1:t;if("exponential"===e.type){let r=e.halfLife??e.extent/2;return t+Math.pow(.5,i/(r>0?r:e.extent/2))*(1-t)}return t+Math.max(0,Math.min(1,1-i/e.extent))*(1-t)}({age:r-t,extent:r,type:e.type,halfLife:e.halfLife??i/2,threshold:e.stepThreshold??.5*i,minOpacity:e.minOpacity??.1})}function as(e){let t=new Map;for(let i=0;e.length>i;i++)t.set(e[i],i);return t}function ss(e,t,i){let r=e.duration??500,o=i-t;return r>o?1-o/r:0}function ls(e,t,i,r){let o=!1;return t>0?(e._pulseIntensity!==t&&(e._pulseIntensity=t,o=!0),e._pulseColor!==i&&(e._pulseColor=i,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 cs(e,t,i=("u">typeof performance?performance.now():Date.now())){if(!t||0===t.size)return!1;let r=e.duration??500,o=t.peek();return null!=o&&r>i-o}function us(e,t,i){if(t._transitionKey)return t._transitionKey;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){let i=e.getX(t.datum),r=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${i}:${r}`;if(null!=i&&null!=r)return`p:${i}:${r}`}return"p:"+i;case"glyph":return t.pointId?"g:"+t.pointId:"g:"+i;case"rect":return`r:${t.group||""}:${t.datum?.binStart??t.datum?.category??i}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+i:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function ds(e){return e?null!=e.opacity?e.opacity:null!=e.fillOpacity?e.fillOpacity:1:1}function hs(e){sx[e.chartType]=e}function ps(e){if("production"===process.env.NODE_ENV)return;let{label:t,nodes:i,overlays:r,warned:o}=e;fs(r)&&0===i.length&&ys(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.`),i.length>0&&i.every(e=>null==e.datum)&&ys(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 fs(e){return null!=e&&!1!==e&&""!==e&&(!Array.isArray(e)||e.some(fs))}function ys(e,t,i){e.has(t)||(e.add(t),console.warn(i))}function gs(e){try{return{kind:"success",result:e.run()}}catch(t){let i=e.hasPreviousResult,r=function(e,t,i,r){let 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),n="network"===e?"customNetworkLayout":"customLayout";return{code:"CUSTOM_LAYOUT_ERROR",severity:"error",phase:"layout",component:e,source:n,message:`Semiotic ${e} ${n} failed: ${o.message}`,error:o,recovery:i?"preserved-last-good-scene":"empty-scene",preservedLastGoodScene:i,affectedRevision:r}}(e.family,t,i,e.revision);"production"!==process.env.NODE_ENV&&console.error(`[semiotic] ${e.logLabel} threw:`,t);try{e.onLayoutError?.(r)}catch(e){"production"!==process.env.NODE_ENV&&console.error("[semiotic] onLayoutError threw:",e)}return{kind:"failure",diagnostic:r,preservedLastGoodScene:i}}}function ms(e,t){let i="function"==typeof e?e:i=>i[e||t];return e=>{let t=i(e);return null==t?NaN:+t}}function xs(e){let t=[],i=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,r=ms(i&&e.valueAccessor||e.yAccessor,i?"value":"y");if(e.boundsAccessor){let i=Va(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{let t=r(e);if(!Number.isFinite(t))return NaN;let o=i(e);return Number.isFinite(o)&&0!==o?t+o:t},getBottom:e=>{let t=r(e);if(!Number.isFinite(t))return NaN;let o=i(e);return Number.isFinite(o)&&0!==o?t-o:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){let i=Array.isArray(e.band)?e.band:[e.band];for(let e of i)t.push({kind:"band",getTop:ms(e.y1Accessor,"y1"),getBottom:ms(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}function bs(e,t,i,r,o,n=!1){let a=new Map;for(let s of e){let e=t(s),l=i(s);if(null==e||null==l||Number.isNaN(e)||Number.isNaN(l))continue;let c=Math.floor(e/r)*r,u=a.get(c);if(u||(u={start:c,end:c+r,total:0,categories:new Map,...n?{rows:[],categoryRows:new Map}:{}},a.set(c,u)),u.total+=l,u.rows?.push(s),o){let e=o(s);if(u.categories.set(e,(u.categories.get(e)||0)+l),u.categoryRows){let t=u.categoryRows.get(e);t||(t=[],u.categoryRows.set(e,t)),t.push(s)}}}return a}function vs(e,t,i,r,o){let n=[];for(let a of e){let e=i(a),s=r(a),l=o?o(a):0;if(!Number.isFinite(e)||!Number.isFinite(s)||!Number.isFinite(l))continue;let c=t.x(e),u=t.y(s),d=o?t.y(l):0;!Number.isFinite(c)||!Number.isFinite(u)||!Number.isFinite(d)||n.push({x:c,y:u,bottom:d,raw:s,datum:a})}n.sort((e,t)=>e.x-t.x);let a=Array(n.length),s=o?Array(n.length):[],l=Array(n.length),c=Array(n.length);for(let e=0;n.length>e;e++){let t=n[e];a[e]=[t.x,t.y],o&&(s[e]=[t.x,t.bottom]),l[e]=t.raw,c[e]=t.datum}return{topPath:a,bottomPath:s,rawValues:l,datum:c}}function ws(e,t,i,r,o,n){let{topPath:a,rawValues:s,datum:l}=vs(e,t,i,r);return{type:"line",path:a,rawValues:s,style:o,datum:l,group:n}}function ks(e,t,i,r,o,n,a,s){return{type:"area",...vs(e,t,i,r,s??(()=>o)),style:n,group:a}}function As(e,t,i,r){let o=new Map;if("silhouette"===r)for(let r of e){let e=0;for(let o of t)e+=i(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++){let n=e[r-1],a=e[r],s=0,l=0,c=0;for(let e of t){let t=i(e,a)||0;s+=(2*c+t)*(t-(i(e,n)||0)),l+=t,c+=t}let u=o.get(n)??0;o.set(a,u-(l>0?s/(2*l):0))}if(e.length>0){let r=0;for(let n of e){let e=0;for(let r of t)e+=i(r,n)||0;r+=(o.get(n)??0)+e/2}let n=r/e.length;for(let t of e)o.set(t,(o.get(t)??0)-n)}}else for(let t of e)o.set(t,0);return o}function Ss(e,t,i,r,o,n,a){let s=i(e),l=r(e);if(!Number.isFinite(s)||!Number.isFinite(l))return null;let c={type:"point",x:t.x(s),y:t.y(l),r:o,style:n,datum:e};return void 0!==a&&(c.pointId=a),c}function Ms(e,t,i,r,o,n,a,s){let l=i(e),c=r(e);if(!Number.isFinite(l)||!Number.isFinite(c))return null;let u={type:"symbol",x:t.x(l),y:t.y(c),size:o,symbolType:n,style:a,datum:e};return void 0!==s&&(u.pointId=s),u}function $s(e,t,i,r,o,n,a){return{type:"rect",x:e,y:t,w:i,h:r,style:o,datum:n,group:a}}function _s(e,t,i,r,o,n,a){let s={type:"heatcell",x:e,y:t,w:i,h:r,fill:o,datum:n};return void 0!==a?.value&&(s.value=a.value),a?.showValues&&(s.showValues=!0,a.valueFormat&&(s.valueFormat=a.valueFormat)),s}function Ps(e,t){return t?[t[0]??e[0],t[1]??e[1]]:e}function Is(e,t,i){if("log"===e){let e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return dx().domain(e).range(i).clamp(!0)}return"symlog"===e?hx().domain(t).range(i):"time"===e?px().domain([new Date(t[0]),new Date(t[1])]).range(i):ux().domain(t).range(i)}function Rs(e,t){return e&&"object"==typeof e&&!Array.isArray(e)?si(e,t):void 0}function Ls(e,t,i){e.capacity>=t||(e.resize(t),i&&t>i.capacity&&i.resize(t))}function Cs(e,t){let i=new ox(e.capacity);return e.forEach(()=>i.push(t)),i}function Ts(e,t,i,r){let o=e.push(t);return i&&i.push(r),o}function Os(e,t,i){if(!t||0===t.size)return;let r=new Set;if(e.forEach((e,t)=>{i(e)&&r.add(t)}),0===r.size)return;let o=t.toArray();t.clear();for(let e=0;o.length>e;e++)r.has(e)||t.push(o[e])}function Fs(){return this.updateResults.last}function Ds(){return this.updateResults.last}function Es(e){return this.updateResults.subscribe(e)}function Ns(e){this.config.layoutSelection=e}function zs(){fx.set(this,!0)}function Bs(){let e=!0===fx.get(this);return fx.delete(this),e}function js(e){Object.assign(e.prototype,{getLastUpdateResult:Fs,getUpdateSnapshot:Ds,subscribeUpdateResult:Es,setLayoutSelection:Ns,markStylePaintPending:zs,consumeStylePaintPending:Bs})}function Ws(e,t,i,r){return"function"==typeof t.style?t.style(r||{},i):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(i,r)}function Ys(e,t,i,r){if(!e.scales)return null;let{topPath:o,bottomPath:n,datum:a}=vs(t,e.scales,e.getX,r.getTop,r.getBottom);return 2>o.length?null:{type:"area",topPath:o,bottomPath:n,...e.config.curve&&"linear"!==e.config.curve&&{curve:e.config.curve},style:Ws(e,r,i,Uo(t)),datum:a,group:i,interactive:r.interactive}}function qs(e){let t=[],i=[];if(!e)return{perSeries:t,aggregate:i};for(let r of e)r.perSeries?t.push(r):i.push(r);return{perSeries:t,aggregate:i}}function Xs(e,t,i){let r=[];for(let o of i){let i=Ys(e,t,"__ribbon_aggregate",o);i&&r.push(i)}return r}function Gs(e,t,i,r){let o=[];for(let n of r){let r=Ys(e,t,i,n);r&&o.push(r)}return o}function Vs(e,t,i,r){if(!e.config.pointStyle)return;let o=r??e.getY;for(let r of t){let t=e.resolveGroupColor(r.key);for(let n of r.data){let r=e.config.pointStyle(n);!r.fill&&t&&(r={...r,fill:t});let a=r.r??3,s=e.getPointId?e.getPointId(n)+"":void 0,l=Ss(n,e.scales,e.getX,o,a,r,s);l&&i.push(l)}}}function Hs(e){return"threshold"===e.type&&"string"==typeof e.color&&"number"==typeof e.value}function Us(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Ks(e,t,i=.3){Us(t)&&(e.globalAlpha=t._pulseIntensity*i,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function Zs(e,t,i,r=.35){Us(t)&&(e.globalAlpha=t._pulseIntensity*r,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",i?e.fill(i):e.fill())}function Qs(e,t,i){let r=i;for(let i of t)"lesser"===i.thresholdType?i.value>e&&(r=i.color):e>i.value&&(r=i.color);return r}function Js(e,t,i,r){if(2>e.length||t.length!==e.length||0===i.length)return[];let o=[],n=(e,t,i)=>{let r=o[o.length-1];r?.color===e?r.path.push(i):o.push({color:e,path:[t,i]})};for(let o=1;e.length>o;o++){let[a,s]=e[o-1],[l,c]=e[o],u=t[o-1],d=t[o]-u,h=[0,...0===d?[]:i.map(({value:e})=>(e-u)/d).filter(e=>e>0&&1>e&&Number.isFinite(e)).sort((e,t)=>e-t).filter((e,t,i)=>0===t||e!==i[t-1]),1];for(let e=1;h.length>e;e++){let t=h[e-1],o=h[e];n(Qs(u+d*((t+o)/2),i,r),[a+(l-a)*t,s+(c-s)*t],[a+(l-a)*o,s+(c-s)*o])}}return o}function el(e,t){let i=mr(t.curve);if(!i||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let i=1;t.topPath.length>i;i++)e.lineTo(t.topPath[i][0],t.topPath[i][1]);for(let i=t.bottomPath.length-1;i>=0;i--)e.lineTo(t.bottomPath[i][0],t.bottomPath[i][1]);e.closePath()}else{let r=Cx().x(e=>e[0]).y0((e,i)=>t.bottomPath[i][1]).y1(e=>e[1]).curve(i).context(e);e.beginPath(),r(t.topPath)}}function tl(e,t){let i=mr(t.curve);if(e.beginPath(),i)Tx().x(e=>e[0]).y(e=>e[1]).curve(i).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let i=1;t.topPath.length>i;i++)e.lineTo(t.topPath[i][0],t.topPath[i][1])}}function il(e,t,i,r,o,n){if(2>t.length)return;let a=[0];for(let e=1;t.length>e;e++){let i=t[e][0]-t[e-1][0],r=t[e][1]-t[e-1][1];a.push(a[e-1]+Math.sqrt(i*i+r*r))}let s=a[a.length-1];if(0===s)return;let l=Math.min(.2*s,40);e.strokeStyle=i,e.lineWidth=r,e.lineCap=n;for(let i=0;t.length-1>i;i++){let r=(a[i]+a[i+1])/2,n=o;l>r&&(n*=r/l),l>s-r&&(n*=(s-r)/l),e.globalAlpha=Math.max(0,n),e.beginPath(),e.moveTo(t[i][0],t[i][1]),e.lineTo(t[i+1][0],t[i+1][1]),e.stroke()}}function rl(e){return _o(e)}function ol(e,t,i){if(i)return i;let r=e??"circle";if("chevron"===r)return function(e){let t=1.5*nl(e),i=.92*t;return`M0,${-t}L${i},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-i},${(.78*t).toFixed(3)}Z`}(t);let o=Object.prototype.hasOwnProperty.call(Kx,r)?Kx[r]:Yx;return Wx(o,Math.max(1,t))()??""}function nl(e){return Math.sqrt(Math.max(1,e)/Math.PI)}function al(e,t){let i=new Map,r=0;return o=>{let n=e(o)+"",a=t&&Object.prototype.hasOwnProperty.call(t,n)?t[n]:void 0;if(a&&Zx.has(a))return a;let s=i.get(n);return s||(s=Qx[r%Qx.length],r++,i.set(n,s)),s}}function sl(e,t){let i=[],r="bubble"===e.config.chartType?10:5,o=e.config.sizeRange||[3,15],n=null;if(e.getSize&&!e.config.pointStyle){let i=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(i.length>0){let e=1/0,t=-1/0;for(let r of i)e>r&&(e=r),r>t&&(t=r);n=i=>e===t?(o[0]+o[1])/2:o[0]+(i-e)/(t-e)*(o[1]-o[0])}}let a=e.getColor?e.resolveColorMap(t):null,s=e.config.themeSemantic?.primary||"#4e79a7",l=e.getSymbol,c=l?al(l,e.config.symbolMap):null;for(let o of t){let t=e.config.pointStyle?e.config.pointStyle(o):{fill:s,opacity:.8},l=t.r||r;if(n&&e.getSize){let t=e.getSize(o);null!=t&&!Number.isNaN(t)&&(l=n(t))}if(a&&e.getColor&&!t.fill){let i=e.getColor(o);i&&a.has(i)&&(t={...t,fill:a.get(i)})}let u=e.getPointId?e.getPointId(o)+"":void 0;if(c){let r=c(o),n=Ms(o,e.scales,e.getX,e.getY,Math.PI*l*l,r,t,u);n&&i.push(n)}else{let r=Ss(o,e.scales,e.getX,e.getY,l,t,u);r&&i.push(r)}}return i}function ll(e,t){let[i,r]=e.viewBox??Jx,[o,n]=e.anchor??eb,a=r>0?r:1,s=Math.max(0,t)/a,l=(i>0?i:a)*s,c=a*s;return{width:l,height:c,scale:s,offsetX:-o*l,offsetY:-n*c}}function cl(e,t,i,r){if("none"!==e)return"color"===e||null==e?t??r:"accent"===e?i:e}function ul(e){if(typeof Path2D>"u")return null;tb||(tb=new Map);let t=tb.get(e);if(t)return t;let i=new Path2D(e);return tb.size>1024&&tb.clear(),tb.set(e,i),i}function dl(e,t,i=0,r="horizontal"){let[o,n]=e.viewBox??Jx,a=Math.min(1,Math.max(0,i)),s=Math.min(1,Math.max(0,t));return s>a?a>0||1>s?"vertical"===r?{x:0,y:n*(1-s),width:o,height:n*(s-a)}:{x:o*a,y:0,width:o*(s-a),height:n}:null:{x:0,y:0,width:0,height:0}}function hl(e,t){let i=ll(e,t);return{centerDx:i.offsetX+i.width/2,centerDy:i.offsetY+i.height/2,halfWidth:i.width/2,halfHeight:i.height/2,radius:Math.hypot(i.width,i.height)/2}}function pl(e,t,i,r,o,n=e=>e){for(let a of t.parts){let t=ul(a.d);if(!t)continue;let s=a.opacity??1,l=e.globalAlpha;1!==s&&(e.globalAlpha=l*s);let c=o?"none"===a.fill?void 0:o:cl(a.fill,i,r);c&&(e.fillStyle=n(c),e.fill(t));let u=o?a.stroke&&"none"!==a.stroke?o:void 0:cl(a.stroke??"none",i,r);u&&(e.strokeStyle=n(u),e.lineWidth=a.strokeWidth??1,e.lineCap=a.strokeLinecap??"butt",e.lineJoin=a.strokeLinejoin??"miter",e.stroke(t)),1!==s&&(e.globalAlpha=l)}}function fl(e,t,i,r,o,n){if(0>=t.size)return;let a=function(e,t,i){try{if(i)return ul(i);let r=`${e??"circle"}:${t}`,o=ib.get(r);return o||(o=new Path2D(ol(e,t)),ib.size>256&&ib.clear(),ib.set(r,o)),o}catch{return null}}(t.symbolType,t.size,t.path);if(!a)return;e.save(),e.translate(i,r),t.rotation&&e.rotate(t.rotation);let s=(t.style.opacity??1)*(t._decayOpacity??1);t.style.fill&&(e.globalAlpha=o*s*(t.style.fillOpacity??1),e.fillStyle=xr(e,t.style.fill,n),e.fill(a)),t.style.stroke&&"none"!==t.style.stroke&&(e.globalAlpha=o*s,e.strokeStyle=dr(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth??1,e.stroke(a)),e.restore()}function yl(e,t,i){return t===i?128:Math.min(Math.floor(255*(e-t)/(i-t)+.5),255)}function gl(e){let t=Object.prototype.hasOwnProperty.call(Mf,e)?e:"blues",i=lb.get(t);if(i)return i;i=Array(sb);let r=oi(t);for(let e=0;sb>e;e++)i[e]=r(e/255);return lb.set(t,i),i}function ml(e,t,i){let r=i.config.areaStyle?.(t);return r&&("string"==typeof r.fill&&(e.fill=r.fill),e.style=r),e}function xl(e,t,i){let r=Math.max(1,Math.floor(e.config.heatmapXBins??20)),o=Math.max(1,Math.floor(e.config.heatmapYBins??20)),n=e.config.heatmapAggregation??"count",a=Va(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];let[s,l]=e.scales.x.domain(),[c,u]=e.scales.y.domain(),d=(l-s||1)/r,h=(u-c||1)/o,p=r*o;if(p>1e6)return[];let f=new Int32Array(p),y=new Float64Array(p),g=e.config.trackHoverRows||Ko(e.config.areaStyle)?new Map:void 0;for(let i=0;t.length>i;i++){let n=t[i],l=e.getX(n),u=e.getY(n);if(!isFinite(l)||!isFinite(u))continue;let p=Math.min(Math.floor((l-s)/d),r-1),m=Math.min(Math.floor((u-c)/h),o-1);if(0>p||0>m)continue;let x=m*r+p;f[x]++;let b=a(n);if(y[x]+=isFinite(b)?b:0,g){let e=g.get(x);e||(e=[],g.set(x,e)),e.push(n)}}let m=1/0,x=-1/0;for(let e=0;p>e;e++){if(0===f[e])continue;let t;switch(n){case"sum":t=y[e];break;case"mean":t=y[e]/f[e];break;default:t=f[e]}m>t&&(m=t),t>x&&(x=t)}if(!isFinite(m))return[];let b=e.config.heatmapColorScale,v=b?void 0:gl("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),w=i.width/r,k=i.height/o,A=e.config.showValues,S=e.config.heatmapValueFormat,M=[];for(let t=0;o>t;t++){let i=t*r;for(let a=0;r>a;a++){let r,l=i+a;if(0===f[l])continue;switch(n){case"sum":r=y[l];break;case"mean":r=y[l]/f[l];break;default:r=f[l]}let u=yl(r,m,x),p=b?b(r):v[u],$=A?{value:r,showValues:!0,valueFormat:S}:{value:r},_=Go({xi:a,yi:t,value:r,count:f[l],sum:y[l],xCenter:s+(a+.5)*d,yCenter:c+(t+.5)*h,agg:n},g?.get(l));M.push(ml(_s(a*w,(o-1-t)*k,w,k,p,_,$),_,e))}}return M}function bl(e,t){let[i,r,o]=hr(e,t);return.299*i+.587*r+.114*o>128?"#000":"#fff"}function vl(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}function wl(e){return(e.tl??0)>0||(e.tr??0)>0||(e.br??0)>0||(e.bl??0)>0}function kl(e){let t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};let i=Math.min(e.w,e.h)/2,r=e=>Math.max(0,Math.min(e??0,i));return{tl:r(t.tl),tr:r(t.tr),br:r(t.br),bl:r(t.bl)}}function Al(e,t){let{x:i,y:r,w:o,h:n}=t,{tl:a,tr:s,br:l,bl:c}=kl(t);e.beginPath(),e.moveTo(i+a,r),e.lineTo(i+o-s,r),s>0&&e.arcTo(i+o,r,i+o,r+s,s),e.lineTo(i+o,r+n-l),l>0&&e.arcTo(i+o,r+n,i+o-l,r+n,l),e.lineTo(i+c,r+n),c>0&&e.arcTo(i,r+n,i,r+n-c,c),e.lineTo(i,r+a),a>0&&e.arcTo(i,r,i+a,r,a),e.closePath()}function Sl(e,t){let i=xr(e,t.style.fill,dr(e,"var(--semiotic-primary, #007bff)")),r=function(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}}}(t);return(t.fillGradient&&"string"==typeof i?vr(e,t.fillGradient,i,r.x0,r.y0,r.x1,r.y1):null)||i}function Ml(e,t){if(!t.style.stroke||"none"===t.style.stroke)return!1;let i=t.style.strokeWidth??1;return i>0&&(e.strokeStyle=dr(e,t.style.stroke)||t.style.stroke,e.lineWidth=i,!0)}function $l(e,t){let i=t.style.icon,r=t.style.iconPadding||2,o=Math.min(t.w,t.h)-r;if(0>=o)return;let n=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),n){let n=o+r,a=t.x+(t.w-o)/2;for(let r=t.y+t.h-o;r>=t.y-o;r-=n)e.drawImage(i,a,r,o,o)}else{let n=o+r,a=t.y+(t.h-o)/2;for(let r=t.x;t.x+t.w>r;r+=n)e.drawImage(i,r,a,o,o)}e.restore()}function _l(e,t,i,r,o){if(0>=t.size)return;let n=t.glyph;if(!n||!n.parts?.length)return;let a=ll(n,t.size);if(0>=a.scale)return;let s=(t.style.opacity??1)*(t._decayOpacity??1);if(0>=s)return;let l=t=>{let i=xr(e,t,t);return"string"==typeof i?i:t},c=t.color??("string"==typeof t.style.fill?t.style.fill:void 0);e.save(),e.translate(i,r),t.rotation&&e.rotate(t.rotation),e.translate(a.offsetX,a.offsetY),e.scale(a.scale,a.scale),e.globalAlpha=o*s*(t.style.fillOpacity??1);let u=dl(n,t.fraction??1,t.fractionStart??0,t.fractionDirection??"horizontal");u&&t.ghostColor&&pl(e,n,c,t.accent,t.ghostColor,l),u&&(e.beginPath(),e.rect(u.x,u.y,u.width,u.height),e.clip()),pl(e,n,c,t.accent,void 0,l),e.restore()}function Pl(){hs(Nx),hs(zx),hs(Bx),hs(jx),hs(nb),hs(ab),hs(ub),hs(hb),hs(pb),hs(yb),hs(mb),hs(xb)}function Il(e){let t=e.parts.filter(e=>null!=e),i={};for(let e of t)for(let[t,r]of Object.entries(e.markCountByType))i[t]=(i[t]??0)+r;for(let[t,r]of Object.entries(e.additionalMarkCountByType??{}))r>0&&(i[t]=(i[t]??0)+r);let r=Object.values(i).reduce((e,t)=>e+t,0),o=0===r,n=Array.from(new Set([...t.flatMap(e=>e.warnings),...e.extraWarnings??[],...o?["EMPTY_SCENE"]:[]])),a="string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${r} marks`;return{component:"",frameType:e.frameType,status:o?"empty":"ok",empty:o,markCount:r,markCountByType:i,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:t.reduce((e,t)=>e+t.annotationCount,0),ariaLabel:a,warnings:n,semanticStatus:"not-assessed",semanticDiagnostics:[]}}function Rl(e){let t=e instanceof Date?e.getTime():"number"==typeof e?e:Number(e);return Number.isFinite(t)?t:null}function Ll(e){if(!e||2>e.length)return;let t=Rl(e[0]),i=Rl(e[e.length-1]);return null!==t&&null!==i?[t,i]:void 0}function Cl(e){let{count:t,byType:i}=function(e){let t={};for(let i of e){let e="string"==typeof i?.type&&i.type.length>0?i.type:"node";t[e]=(t[e]??0)+1}return{count:e.length,byType:t}}(e.marks),r=0===t,o=[...e.extraWarnings??[]];r&&!o.includes("EMPTY_SCENE")&&o.push("EMPTY_SCENE"),e.annotationRender&&e.annotationRender.unrenderedCount>0&&!o.includes("UNRENDERED_ANNOTATIONS")&&o.push("UNRENDERED_ANNOTATIONS");let n=Array.isArray(e.annotations)?e.annotations.length:0,a=e.margin,s=a?{x:a.left,y:a.top,width:e.width-a.left-a.right,height:e.height-a.top-a.bottom}:void 0;return{component:"",frameType:e.frameType,status:r?"empty":"ok",empty:r,markCount:t,markCountByType:i,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:e.annotationRender?.renderedCount??n,...e.annotationRender?{annotationInputCount:e.annotationRender.inputCount,unrenderedAnnotationCount:e.annotationRender.unrenderedCount,...e.annotationRender.unrenderedTypes.length>0?{unrenderedAnnotationTypes:e.annotationRender.unrenderedTypes}:{}}:{},ariaLabel:"string"==typeof e.description&&e.description||"string"==typeof e.title&&e.title||`${e.frameType} chart, ${t} marks`,warnings:o,semanticStatus:"not-assessed",semanticDiagnostics:[],...a?{margin:a}:{},...s?{plot:s}:{}}}function Tl(e,t="#4e79a7"){return fr(e)?e.background&&"transparent"!==e.background?e.background:t:e&&"string"==typeof e?e:t}function Ol(e){let t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}function Fl(e,t,i,r){let o=e.glyph;if(!o?.parts?.length||0>=e.size)return null;let n=ll(o,e.size);if(0>=n.scale)return null;let a=`translate(${t},${i})${e.rotation?` rotate(${180*e.rotation/Math.PI})`:""} translate(${n.offsetX},${n.offsetY}) scale(${n.scale})`,s=e.color??("string"==typeof e.style.fill?e.style.fill:void 0),l=dl(o,e.fraction??1,e.fractionStart??0,e.fractionDirection??"horizontal"),c=l?Ol(r+"-clip"):void 0,u=(e.style.opacity??1)*(e._decayOpacity??1)*(e.style.fillOpacity??1),d=t=>o.parts.map((i,r)=>{let o=t?"none"===i.fill?void 0:t:cl(i.fill,s,e.accent),n=t?i.stroke&&"none"!==i.stroke?t:void 0:cl(i.stroke??"none",s,e.accent);return o||n?Ab("path",{d:i.d,fill:o??"none",stroke:n,strokeWidth:n?i.strokeWidth??1:void 0,strokeLinecap:i.strokeLinecap,strokeLinejoin:i.strokeLinejoin,opacity:i.opacity},r):null});return Sb("g",{transform:a,opacity:1===u?void 0:u,children:[l&&c&&Ab("clipPath",{id:c,children:Ab("rect",{x:l.x,y:l.y,width:l.width,height:l.height})}),l&&e.ghostColor?Ab("g",{children:d(e.ghostColor)}):null,l&&c?Ab("g",{clipPath:`url(#${c})`,children:d()}):d()]},r)}function Dl(e,t){let i=e.filter(e=>Number.isFinite(e.offset)&&(null==e.opacity||Number.isFinite(e.opacity))).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color??t,opacity:null==e.opacity?void 0:Math.max(0,Math.min(1,e.opacity))}));return 2>i.length?null:i.map((e,t)=>Ab("stop",{offset:e.offset,stopColor:e.color,stopOpacity:e.opacity},t))}function El(e,t,i){let r=ol(e.symbolType,e.size,e.path);return Ab("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?Tl(e.style.fill):"none",fillOpacity:e.style.fillOpacity,opacity:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth},`${i??""}symbol-${t}`)}function Nl(e,t,i){let r="point"===e.type,o=r?"circle":"rect",n=r?{cx:e.x,cy:e.y,r:e.r}:{x:e.x,y:e.y,width:e.w,height:e.h},a=`${i?i+"-":""}${r?"point":"xyrect"}-${t}-hatch`,s=fr(e.style.fill)?gr(e.style.fill,a):void 0;return Sb(kb.Fragment,{children:[s&&Ab("defs",{children:s}),kb.createElement(o,{...n,fill:s?`url(#${a})`:Tl(e.style.fill),opacity:r?e.style.opacity??e.style.fillOpacity??.8:e.style.opacity,stroke:e.style.stroke,strokeWidth:e.style.strokeWidth})]},`${e.type}-${t}`)}function zl(e){if(!1!==e?.interactive)return e?.style?.cursor}function Bl(e,t,i){let r=zl(t);return r&&null!=e&&!1!==e?_b("g",{style:{cursor:r},"data-semiotic-mark-cursor":r,children:e},i):e}function jl(e,t,i,r){if(!e||2>t.length)return null;let o=Dl(e.stops,r);return o?Pb("linearGradient",{id:i,gradientUnits:"userSpaceOnUse",x1:t[0][0],y1:0,x2:t[t.length-1][0],y2:0,children:o}):null}function Wl(e,t,i,r=30){let o=function(e,t,i,r=30){switch(e.type){case"line":{let r=e;if(0===r.path.length)return null;let o=mr(r.curve),n=o?wb().x(([e])=>e).y(([,e])=>e).curve(o)(r.path)??"":"M"+r.path.map(([e,t])=>`${e},${t}`).join("L"),a=Ol(`${i?i+"-":""}line-${t}-stroke-gradient`),s=jl(r.strokeGradient,r.path,a,r.style.stroke||"#4e79a7");return Ib(bb.Fragment,{children:[s&&Pb("defs",{children:s}),Pb("path",{d:n,fill:"none",stroke:s?`url(#${a})`:r.style.stroke||"#4e79a7",strokeWidth:r.style.strokeWidth??2,strokeDasharray:r.style.strokeDasharray,opacity:r.style.opacity})]},"line-"+t)}case"area":{let o=e;if(0===o.topPath.length)return null;let n=mr(o.curve),a=!n||2>o.topPath.length||2>o.bottomPath.length?`M${o.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...o.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`:vb().x(([e])=>e).y0((e,t)=>o.bottomPath[t][1]).y1(([,e])=>e).curve(n)(o.topPath)??"",s=`${i?i+"-":""}area-${t}-hatch`,l=fr(o.style.fill)?gr(o.style.fill,s):void 0,c=Ol(`${i?i+"-":""}area-${t}-gradient`),u=function(e,t){let i=e.fillGradient;if(!i||"object"!=typeof i)return null;let r=1/0;for(let[,t]of e.topPath)r=Math.min(r,t);let o=-1/0;for(let[,t]of e.bottomPath)o=Math.max(o,t);if(!Number.isFinite(r)||!Number.isFinite(o))return null;let n=Dl(i.stops,Tl(e.style.fill));return n?Pb("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:0,y1:r,x2:0,y2:o,children:n}):null}(o,c),d=u?`url(#${c})`:l?`url(#${s})`:Tl(o.style.fill),h=u?void 0:o.style.fillOpacity??o.style.opacity??.7,p=n?wb().x(([e])=>e).y(([,e])=>e).curve(n)(o.topPath)??"":"M"+o.topPath.map(([e,t])=>`${e},${t}`).join("L"),f=zl(o),y=f&&r>=0?Pb("path",{d:p,fill:"none",stroke:"transparent",strokeWidth:Math.max(1,2*r),strokeLinecap:"round",pointerEvents:"stroke",style:{cursor:f},"data-semiotic-mark-cursor":f,"data-semiotic-cursor-hit-target":"area-top-path","aria-hidden":"true"},`area-${t}-cursor-target`):null,g=Ol(`${i?i+"-":""}area-${t}-stroke-gradient`),m=!(!o.colorThresholds?.length||!o.rawValues||o.rawValues.length!==o.topPath.length),x=!!o.strokeColorBands?.length,b=m||x?null:jl(o.strokeGradient,o.topPath,g,o.style.stroke||"#4e79a7"),v=o.style.strokeWidth??2,w=1/0,k=-1/0;for(let[e]of o.topPath)w>e&&(w=e),e>k&&(k=e);let A=x?o.strokeColorBands.map((e,r)=>Ol(`${i?i+"-":""}area-${t}-stroke-band-${r}`)):[],S=x?o.strokeColorBands.map((e,t)=>Pb("clipPath",{id:A[t],children:Pb("rect",{x:w-v,y:e.y,width:k-w+2*v,height:e.height})},A[t])):null,M=o.style.stroke&&"none"!==o.style.stroke?x?o.strokeColorBands.map((e,i)=>Pb("path",{d:p,fill:"none",stroke:e.color??Tl(o.style.stroke),strokeWidth:v,opacity:(o.style.opacity??1)*(e.opacity??1),clipPath:`url(#${A[i]})`},`area-${t}-stroke-band-${i}`)):m?Js(o.topPath,o.rawValues,o.colorThresholds,Tl(o.style.stroke)).map((e,i)=>Pb("path",{d:"M"+e.path.map(([e,t])=>`${e},${t}`).join("L"),fill:"none",stroke:e.color,strokeWidth:v,opacity:o.style.opacity},`area-${t}-threshold-${i}`)):Pb("path",{d:p,fill:"none",stroke:b?`url(#${g})`:Tl(o.style.stroke),strokeWidth:v,opacity:o.style.opacity}):null;if(o.clipRect){let e=`${i?i+"-":""}area-clip-${t}`;return Ib("g",{children:[Ib("defs",{children:[u,!u&&l,b,S,Pb("clipPath",{id:e,children:Pb("rect",{x:o.clipRect.x,y:o.clipRect.y,width:o.clipRect.width,height:o.clipRect.height})})]}),Ib("g",{clipPath:`url(#${e})`,children:[Pb("path",{d:a,fill:d,fillOpacity:h,opacity:u?o.style.opacity:void 0,stroke:"none"}),M,y]})]},"area-"+t)}return Ib(bb.Fragment,{children:[(u||l||b||S)&&Ib("defs",{children:[u,!u&&l,b,S]}),Pb("path",{d:a,fill:d,fillOpacity:h,opacity:u?o.style.opacity:void 0,stroke:"none"}),M,y]},"area-"+t)}case"point":case"rect":return Nl(e,t,i);case"symbol":return El(e,t);case"glyph":return Fl(e,e.x,e.y,`${i??""}glyph-${e.pointId??t}`);case"heatcell":{let i=e,r={x:i.x,y:i.y,width:i.w,height:i.h,fill:i.fill,stroke:i.style?.stroke,strokeWidth:i.style?.strokeWidth,...null!=i.style?.opacity&&{opacity:i.style.opacity}};if(i.showValues&&null!=i.value&&i.w>=20&&i.h>=20){let e=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,n,a]=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)]}let t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(i.fill),s=.299*o+.587*n+.114*a>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h)));return Ib("g",{children:[Pb("rect",{...r}),Pb("text",{className:"semiotic-heatmap-value",x:i.x+i.w/2,y:i.y+i.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:s,fontSize:l+"px",fontFamily:"var(--semiotic-font-family, sans-serif)",children:e})]},"heatcell-"+t)}return Pb("rect",{...r},"heatcell-"+t)}case"candlestick":{let r=e,o=`${i?i+"-":""}candle-${t}-hatch`,n=fr(r.style?.fill)?gr(r.style.fill,o):void 0,a=n?`url(#${o})`:void 0,{fill:s,...l}=r.style??{};if(r.isRange){let e=r.dotRadius??Math.max(2,r.bodyWidth/2),i=a??r.wickColor;return Ib(bb.Fragment,{children:[n&&Pb("defs",{children:n}),Ib("g",{style:l,children:[Pb("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth,opacity:r.style?.opacity}),Pb("circle",{cx:r.x,cy:r.highY,r:e,fill:i,opacity:r.style?.opacity}),Pb("circle",{cx:r.x,cy:r.lowY,r:e,fill:i,opacity:r.style?.opacity})]})]},"candle-"+t)}let c=Math.min(r.openY,r.closeY),u=Math.max(Math.abs(r.openY-r.closeY),1),d=r.isUp?r.upColor:r.downColor,h=a??d;return Ib(bb.Fragment,{children:[n&&Pb("defs",{children:n}),Ib("g",{style:l,children:[Pb("line",{x1:r.x,y1:r.highY,x2:r.x,y2:r.lowY,stroke:r.wickColor,strokeWidth:r.wickWidth,opacity:r.style?.opacity}),Pb("rect",{x:r.x-r.bodyWidth/2,y:c,width:r.bodyWidth,height:u,fill:h,stroke:a?r.wickColor:d,strokeWidth:1,opacity:r.style?.opacity})]})]},"candle-"+t)}default:return null}}(e,t,i,r);return"area"===e.type?o:Bl(o,e,"xy-cursor-"+t)}function Yl(e){let{node:t,index:i,renderMode:r,fallback:o}=e,n=function(e,t){let i="function"==typeof e?e(t.datum??null,t):e;return(r=i)&&"object"==typeof r&&"string"==typeof r.id&&"function"==typeof r.cacheKey&&"function"==typeof r.drawCanvas&&"function"==typeof r.renderStaticSVG?i:void 0;var r}(r,t);if(!n)return{element:o(),renderedByBackend:!1};let a=n.renderStaticSVG({node:t,style:t.style??{},key:`${n.id}-${i}`});return null!=a?{element:Bl(a,t,`${n.id}-${i}-cursor`),renderedByBackend:!0}:(function(e,t){if("u">typeof process&&"production"===process.env?.NODE_ENV)return;let i=`${e}:${t}`;Rb.has(i)||(Rb.add(i),console.warn(`[Semiotic] Render backend "${e}" does not support scene node "${t}"; using the built-in renderer.`))}(n.id,t.type??"unknown"),{element:o(),renderedByBackend:!1})}function ql(e){let t=[];return e.nodes.forEach((i,r)=>{let o=Yl({node:i,index:r,renderMode:e.renderMode,fallback:()=>e.fallback(i,r)});null!=o.element&&!1!==o.element&&t.push({node:i,index:r,...o})}),t}function Xl(e,t,i){if(t&&"object"==typeof t&&!Array.isArray(t)){let e=t;return t=>si(e,t)??"#999"}let r=Array.isArray(t)?t:i.colors.categorical.length>0?i.colors.categorical:hf;return Lb().domain(e).range(r)}function Gl(e,t,i){if(0===e.length)return;let r=Xl(e,t,i);return{legendGroups:[{label:"",type:"fill",items:e.map(e=>({label:e})),styleFn:e=>({fill:r(e.label)})}]}}function Vl(e){return"left"===e?"start":"right"===e?"end":e??"start"}function Hl(e){return Number(e.typography.legendSize??e.typography.labelSize??e.typography.tickSize)||11}function Ul(e){return e.typography.legendFontFamily??e.typography.fontFamily}function Kl(e){return e.typography.legendFontWeight}function Zl(e,t,i,r){let o=Hl(r);return t+i+Math.ceil(e.length*o*.58)}function Ql(e){let{categories:t,theme:i,position:r="right",totalWidth:o,margin:n,legendLayout:a}=e,{swatchSize:s,labelGap:l,itemGap:c,rowHeight:u}=v(a),d=s+l,h="top"===r||"bottom"===r,p=Math.max(s,o-n.left-n.right),f=t.map(e=>Zl(e,s,l,i));if(h){let e=Math.max(s,a?.maxWidth??p),i=[],r=0,o=0;f.forEach((t,n)=>{let a=0===o?t:o+c+t;o>0&&a>e?(i.push({start:r,end:n,width:o}),r=n,o=t):o=a}),t.length>0&&i.push({start:r,end:t.length,width:o});let n=Vl(a?.align),l=[];return i.forEach((i,r)=>{let o="center"===n?Math.max(0,(e-i.width)/2):"end"===n?Math.max(0,e-i.width):0;for(let e=i.start;i.end>e;e++)l.push({category:t[e],width:f[e],x:o,y:r*u}),o+=f[e]+c}),{items:l,width:i.reduce((e,t)=>Math.max(e,t.width),0),height:i.length*u,swatchSize:s,labelOffset:d,swatchRadius:0}}let y=f.reduce((e,t)=>Math.max(e,t),0);return{items:t.map((e,t)=>({category:e,width:f[t],x:0,y:t*u})),width:y,height:t.length*u,swatchSize:s,labelOffset:d,swatchRadius:0}}function Jl(e,t){if(!t||!e||0===e.length)return[];let i="function"==typeof t?t:e=>e[t],r=new Set;for(let t of e){let e=i(t);null!=e&&r.add(e+"")}return Array.from(r)}function ec(e){let{x:t,y:i,text:r,fill:o,fontSize:n=12,fontWeight:a,fontFamily:s,textAnchor:l="start",dominantBaseline:c,background:u,className:d}=e,h=function(e){return void 0===e||!0===e||"halo"===e?{type:"halo"}:!1===e||"none"===e?null:"box"===e?{type:"box"}:{...e,type:e.type??"halo"}}(u),p=e=>Ob("text",{x:t,y:i,textAnchor:l,dominantBaseline:c,fill:o,fontSize:n,fontWeight:a,fontFamily:s,className:d,...e?{style:{stroke:e.stroke,strokeWidth:e.strokeWidth,paintOrder:"stroke"}}:{},children:r});if(!h)return p();if("halo"===h.type)return p({stroke:h.fill??Db,strokeWidth:h.haloWidth??3});let f,y,g=h.padding??{x:6,y:3},m="number"==typeof g?g:g.x,x="number"==typeof g?g:g.y,b=function(e,t){return(e+"").length*t*.6}(r,n),v=n+2*x;return f="middle"===l?t-b/2-m:"end"===l?t-b-m:t-m,y="middle"===c||"central"===c?i-v/2:"hanging"===c||"text-before-edge"===c?i-x:i-.8*n-x,Fb("g",{className:d,children:[Ob("rect",{x:f,y:y,width:b+2*m,height:v,rx:h.radius??3,ry:h.radius??3,fill:h.fill??Db,fillOpacity:h.opacity??.85,stroke:h.stroke,strokeWidth:h.strokeWidth}),p()]})}function tc(e,t,i){if(!e)return null;let r="object"==typeof e?e:{};return Eb("circle",{className:"semiotic-threshold-end-cap",cx:t[0],cy:t[1],r:Math.max(0,r.radius??4),fill:r.fill??i})}function ic({ann:e,position:t,vertical:i,width:r,height:o,color:n,fontSize:a=12,fontFamily:s,bold:l,background:c,dash:u="6,3",labelGap:d=4}){let h=e.labelPosition,p=t>.6*r,f=i?t+(p?-4:4):"left"===h?4:"center"===h?r/2:r-4,y=i?"bottom"===h?o-4:"center"===h?o/2:16:20>t?Math.min(o-4,t+16):t-d,g=i?p?"end":"start":"left"===h?"start":"center"===h?"middle":"end",m=i?[t,0]:[0,t],x=i?[t,o]:[r,t];return zb("g",{opacity:e.opacity,children:[Nb("line",{x1:m[0],y1:m[1],x2:x[0],y2:x[1],stroke:n,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray||u}),tc(e.endCap,m,n),e.label&&Nb(ec,{x:f,y:y,text:e.label,textAnchor:g,fill:n,fontSize:a,fontFamily:s,fontWeight:l?"bold":void 0,background:c??e.labelBackground??"halo"})]})}function rc(e){return{label:e.label,title:e.title,wrap:e.wrap||120,noWrap:"function"==typeof e._noteLayout?e.noWrap:void 0,_noteLayout:e._noteLayout}}function oc(e){return"function"==typeof e._noteLayout?e._noteLayout(e):void 0}function nc(e,t,i){if(!e)return[];let r=Math.max(1,Math.floor(t/i)),o=[],n="";for(let t of e.split(/\s+/))t&&(n&&n.length+1+t.length>r?(o.push(n),n=t):n=n?`${n} ${t}`:t);return n&&o.push(n),o}function ac(e,t,i,r){return"curly"===e?r?`M0,0 C${.6*i},0 ${.4*i},${t/2} ${i},${t/2} C${.4*i},${t/2} ${.6*i},${t} 0,${t}`:`M0,0 C0,${.6*i} ${t/2},${.4*i} ${t/2},${i} C${t/2},${.4*i} ${t},${.6*i} ${t},0`:r?`M0,0 L${i},0 L${i},${t} L0,${t}`:`M0,0 L0,${i} L${t},${i} L${t},0`}function sc(e,t,i,r){if(!e)return Bb("g",{className:"annotation-note"});let{label:o,title:n,orientation:a,align:s,wrap:l=120,noWrap:c}=e;if(!o&&!n)return Bb("g",{className:"annotation-note"});let u=a;u||(u=Math.abs(t)>Math.abs(i)?"leftRight":"topBottom");let d="topBottom"===u,h="leftRight"===u,p=s;(!p||"dynamic"===p)&&(p=d?0>t?"right":"left":0>i?"bottom":"top");let f="start";d?"right"===p?f="end":"middle"===p&&(f="middle"):f=0>t?"end":"start";let y=e.useHTML||e.html,g=y?void 0:oc(e),m=g?.lineHeight??16,x=g?.titleLines??(n?c?[n]:nc(n,l,8):[]),b=g?.labelLines??(o?c?[o]:nc(o,l,8):[]),v=x.length+b.length,w=h?"end"===f?-4:4:0,k=[],A=r||"var(--semiotic-annotation-color, var(--semiotic-text, #333))";if(y)k.push(Bb("foreignObject",{className:"annotation-note-html",x:"end"===f?w-l:"middle"===f?w-l/2:w,y:-m,width:l,height:Math.max(m,v*m+(n&&o?2:0))+m,style:{overflow:"visible"},children:jb("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{color:A,fontSize:"12px",lineHeight:m+"px",overflow:"visible",textAlign:"end"===f?"right":"middle"===f?"center":"left",whiteSpace:c?"nowrap":"normal",wordBreak:"break-word"},children:[n&&Bb("div",{className:"annotation-note-title",style:{fontWeight:"bold"},children:n}),o&&Bb("div",{className:"annotation-note-label",children:o})]})},"annotation-note-html"));else for(let e of[!0,!1]){let t=e?x:b;if(0===t.length)continue;let i="annotation-note-"+(e?"title":"label");k.push(Bb("text",{className:i,fill:A,textAnchor:f,fontWeight:e?g?.titleFontWeight??"bold":void 0,y:e?void 0:x.length*m,children:t.map((e,t)=>Bb("tspan",{x:w,dy:0===t?0:m,children:e},t))},i))}let S=null;if((n||o)&&(0!==t||0!==i)){let e=d?g?g.width:Math.min(l,120):(x.length+b.length+(b.length>0?1:0))*m,t=d?f:p,i="end"===t||"bottom"===t?-e:"middle"===t?-e/2:0;S=Bb("line",{className:"note-line",x1:d?i:0,x2:d?i+e:0,y1:d?0:i,y2:d?0:i+e,stroke:r||"var(--semiotic-text-secondary, currentColor)"})}let M=Math.max(0,v-1)*m,$=0;(d||h)&&($=h&&"middle"===p?-(M+m+(b.length>0&&x.length>0?2:0))/2+m/2:0>i||h&&"bottom"===p?-(M+2):2+m);let _=0!==$?`translate(0,${$})`:void 0;return jb("g",{className:"annotation-note",transform:`translate(${t},${i})`,...g?.textProps,children:[Bb("g",{className:"annotation-note-content",transform:_,children:k}),S]})}function lc(e,t,i,r,o){let n=null,a=i||"var(--semiotic-text-secondary, currentColor)";switch(e){case"callout-circle":{let e=(t?.radius||0)+(t?.radiusPadding||0);e>0&&(n=Bb("circle",{r:e,fill:"none",stroke:a},"subject-circle"));break}case"callout-rect":{let e=t?.width||0,i=t?.height||0;(e>0||i>0)&&(n=Bb("rect",{width:e,height:i,fill:"none",stroke:a},"subject-rect"));break}case"callout-custom":n=t?.custom;break;case"xy-threshold":{let e=r||0,i=o||0,s=0,l=0,c=0,u=0;if(void 0!==t?.x)s=l=(t.x||0)-e,c=(t.y1||0)-i,u=(t.y2||0)-i;else if(void 0!==t?.y)c=u=(t.y||0)-i,s=(t.x1||0)-e,l=(t.x2||0)-e;else if(void 0!==t?.x1||void 0!==t?.x2)s=(t.x1||0)-e,l=(t.x2||0)-e;else{if(void 0===t?.y1&&void 0===t?.y2)break;c=(t.y1||0)-i,u=(t.y2||0)-i}n=Bb("line",{x1:s,y1:c,x2:l,y2:u,stroke:a,strokeDasharray:"5,5"},"threshold-line");break}case"bracket":{let e=t?.type||"curly",i=t?.width??t?.height;void 0!==i&&(n=Bb("path",{d:ac(e,i,t?.depth||30,void 0===t?.width),fill:"none",stroke:a},"bracket-path"));break}}return Bb("g",{className:"annotation-subject",children:n})}function cc(e,t,i,r,o,n){let a,s,l=0,c=0;if("callout-circle"!==o&&"label"!==o||!n?.radius){if("callout-rect"===o&&n){let i=n.width||0,r=n.height||0;if(i>0||r>0){let o=i/2,n=r/2,a=e-o,s=t-n;if(0!==a||0!==s){let e=Math.abs(a),t=Math.abs(s),u=i/2,d=r/2,h=e*d>t*u?u/e:d/t;l=o+a*h,c=n+s*h}}}else if("bracket"===o&&n){let e=n.width,t=n.height,i=n.depth||30;void 0!==e?(l=e/2,c=i):void 0!==t&&(l=i,c=t/2)}}else{let i=(n.radius||0)+(n.radiusPadding||0);if(i>0&&(0!==e||0!==t)){let r=Math.atan2(t,e);l=Math.cos(r)*i,c=Math.sin(r)*i}}let u=e-l,d=t-c,h=Math.hypot(u,d);if(h>.5){let o=r||"var(--semiotic-text-secondary, currentColor)",n="curve"===i?.type,p=Math.atan2(d,u);if(n){let r=(l+e)/2,n=(c+t)/2,s=-d/h,f=u/h,y=(i?.curve??.25)*h,g=r+s*y,m=n+f*y;a=Bb("path",{className:"connector-curve",d:`M${l},${c}Q${g},${m} ${e},${t}`,fill:"none",stroke:o},"connector-line"),p=Math.atan2(m-c,g-l)}else a=Bb("line",{x1:l,y1:c,x2:e,y2:t,stroke:o},"connector-line");if("arrow"===i?.end){let e=.2792526803190927;s=Bb("path",{d:`M${l},${c}L${l+10*Math.cos(p+e)},${c+10*Math.sin(p+e)}L${l+10*Math.cos(p-e)},${c+10*Math.sin(p-e)}Z`,fill:o,stroke:"none"},"connector-arrow")}}return jb("g",{className:"annotation-connector",children:[a,s]})}function uc(e){let{x:t=0,y:i=0,dx:r,dy:o,nx:n,ny:a,note:s,connector:l,subject:c,type:u,color:d,className:h,disable:p,opacity:f,strokeDasharray:y,events:g={},"data-testid":m}=e,x=Array.isArray(t)?t[0]??0:t,b=Array.isArray(i)?i[0]??0:i,v=Array.isArray(p)?p:[],w=r||0,k=o||0;null!=n&&(w=n-x),null!=a&&(k=a-b);let A="string"==typeof u?u:"label";if("bracket"===A&&c&&0===w&&0===k)if(void 0!==c.width){w=c.width/2;let e=c.depth||30;k=e+(0>e?-5:5)}else if(void 0!==c.height){let e=c.depth||30;w=e+(0>e?-5:5),k=c.height/2}return jb("g",{className:("annotation "+(h||"")).trim(),transform:`translate(${x},${b})`,"data-testid":m,...null!=f&&{opacity:f},...y&&{strokeDasharray:y},...g,children:[!v.includes("connector")&&cc(w,k,l,d,A,c),!v.includes("subject")&&lc(A,c,d,x,b),!v.includes("note")&&sc(s,w,k,d)]})}function dc(e){let{noteData:t}=e,{screenCoordinates:i}=t,r="string"==typeof t.type?t.type:"label",o=t.eventListeners||t.events||{};if(t.coordinates&&i){let e=t.nx||i[0][0]+(t.dx??0),o=t.ny||i[0][1]+(t.dy??0),n=i.map((i,n)=>{let a=Object.assign({},t,{note:0===n?t.note:{label:""},x:i[0],y:i[1],nx:e,ny:o});return Bb(uc,{"data-testid":"semiotic-annotation",...a,type:r},"multi-annotation-"+n)});return Bb("g",{children:n})}let n=t.note||{title:"none",label:t.label},a=`${n.label}-${n.title}-${t.i}`;return Bb(uc,{"data-testid":"semiotic-annotation",events:o,...t,type:r},a)}function hc(e){return!0===e?._annotationDeferred}function pc(e){return"blended"===e?.cohesion||"layer"===e?.cohesion?e.cohesion:null}function fc(e){let t=e?.provenance?.confidence;return"number"==typeof t&&Number.isFinite(t)?Math.max(0,Math.min(1,t)):null}function yc(e){return Math.max(.72,.95-.06*e)}function gc(e){let t=e.map((e,t)=>{return{p:e,i:t,emphasis:(i=e.annotation,"primary"===i?.emphasis||"secondary"===i?.emphasis?i.emphasis:null),confidence:fc(e.annotation),readingOrder:null,rank:1};var i}),i=t.some(e=>null!=e.emphasis||null!=e.confidence),r=e.some(e=>hc(e.annotation)),o=e.some(e=>null!=pc(e.annotation)),n=e.some(e=>"layer"===pc(e.annotation));if(!i&&!r&&!o)return e.map(e=>e.node);let a=t.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>(t.confidence??0)-(e.confidence??0)||e.i-t.i);a.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,a.length)});for(let e of t)e.emphasis&&(e.rank=Yb[e.emphasis]);let s=t.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(e=>{let{p:t,i:i,emphasis:r,readingOrder:o}=e,n=hc(t.annotation),a=t.node;if("primary"===r||"secondary"===r||null!=o){let e=null==r&&null!=o;a=Wb("g",{className:e?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+r,..."secondary"===r?{opacity:.6,fontSize:"0.88em"}:{},...e?{opacity:yc(o),"data-annotation-reading-order":o}:{},children:t.node},"annotation-emphasis-"+i)}let s=pc(t.annotation);return s&&(a=Wb("g",{className:"annotation-cohesion--"+s,children:a},"annotation-cohesion-"+i)),n&&(a=Wb("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:a},"annotation-deferred-"+i)),a});return r&&s.unshift(Wb("style",{children:".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}}"},"annotation-disclosure-style")),n&&s.unshift(Wb("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),s}function mc(e,t){let i=t.scales?.x??t.scales?.time;return i?null!=e.x?i(e.x):t.xAccessor&&null!=e[t.xAccessor]?i(e[t.xAccessor]):null:null}function xc(e,t){let i=t.scales?.y??t.scales?.value;return i?null!=e.y?i(e.y):t.yAccessor&&null!=e[t.yAccessor]?i(e[t.yAccessor]):null:null}function bc(e){return null==e?null:e+""}function vc(e,t,i){return t.stickyPositionCache?.set(e,i),i}function wc(e,t,i){let r=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===r){if(null!=e.pointId&&i.pointNodes&&i.pointNodes.length>0)for(let r=i.pointNodes.length-1;r>=0;r--){let o=i.pointNodes[r];if(o.pointId===e.pointId)return vc(t,i,{x:o.x,y:o.y})}let r=function(e){let t=e.data;if(!t||0===t.length)return null;let i=t[t.length-1],r=e.scales?.x??e.scales?.time,o=e.scales?.y??e.scales?.value;if(!r||!o)return null;let n=i[e.xAccessor||"x"],a=i[e.yAccessor||"y"];return null==n||null==a?null:{x:r(n),y:o(a)}}(i);return r?vc(t,i,r):null}if("semantic"===r){let r=function(e,t,i){let r=function(e){return bc(e.provenance?.stableId??e.stableId)}(e);if(!r)return null;let o=i.pointNodes?.find(e=>bc(e.pointId)===r);if(o)return vc(t,i,{x:o.x,y:o.y});let n=i.data?.find(e=>function(e){return bc(e.stableId??e.id??e.provenance?.stableId)}(e)===r);if(!n)return null;let a=mc(n,i),s=xc(n,i);return null==a||null==s?null:vc(t,i,{x:a,y:s})}(e,t,i);if(r)return r}let o=null,n=null;if(null!=e.pointId&&i.pointNodes){let t=i.pointNodes.find(t=>t.pointId===e.pointId);t&&(o=t.x,n=t.y)}if((null==o||null==n)&&(o=mc(e,i),n=xc(e,i)),null!=o&&null!=n)return vc(t,i,{x:o,y:n});if("sticky"===r){let e=i.stickyPositionCache?.get(t);if(e)return e}return null}function kc(e){return!!e&&"object"==typeof e&&qb.has(function(e){return"string"==typeof e?.type?e.type:""}(e))}function Ac(e){return"primary"===e?.emphasis||!0===e?.defensive}function Sc(e,t,i={}){return"number"==typeof i.maxAnnotations&&Number.isFinite(i.maxAnnotations)?Math.max(0,Math.floor(i.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(i.areaPerAnnotation&&i.areaPerAnnotation>0?i.areaPerAnnotation:2e4))):1/0}function Mc(e){let t,i=e?.emphasis;t="primary"===i?100:"secondary"===i?10:50;let 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}function $c(e){let t=e?.provenance;if(!t||"object"!=typeof t)return e;let i="string"==typeof t.source?Object.prototype.hasOwnProperty.call(Kb,t.source)?Kb[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(!i&&!r||null!=e.label&&"string"!=typeof e.label)return e;let o=[i,r].filter(Boolean).join(" · "),n="string"==typeof e.label?e.label:"";return n.includes(`(${o})`)?e:{...e,label:n?`${n} (${o})`:`(${o})`}}function _c(e){if(!Pc(e))return e;let 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 Pc(e){return kc(e)}function Ic(e,t,i,r,o){let n=e+i,a=t+r;return Math.abs(i)>Math.abs(r)?{x:0>i?n-o.width-4:n+4,y:0>r?a-o.height:a,width:o.width,height:o.height}:{x:0>i?n-o.width:n,y:0>r?a-o.height-4:a+4,width:o.width,height:o.height}}function Rc(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function Lc(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 Cc(e,t,i,r,o,n,a,s){let l=Rc(e,a),c=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,i,r){let o=Math.max(0,r-e.x),n=Math.max(0,r-e.y);return(o+Math.max(0,e.x+e.width-(t-r)))*e.height+(n+Math.max(0,e.y+e.height-(i-r)))*e.width}(l,o,n,s);for(let e of i)c+=12*Lc(l,e);for(let e of r)c+=4*Lc(l,e);return c}function Tc(e){let{annotations:t,context:i,defaultOffset:r=Xb,notePadding:o=Gb,markPadding:n=Vb,edgePadding:a=Hb,preserveManualOffsets:s=!0,routeLongConnectors:l=!0,connectorThreshold:c=Ub,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:p,mobile:f,cohesion:y,audience:g}=e,m=i.width||0,x=i.height||0,b="object"==typeof f?f:{},v=b.breakpoint??480,w=!!f&&v>=m,k=w&&!1!==b.preferShortText?t.map(_c):t,A=w&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,S=d||w&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),M=w&&!p?b.responsive??{minWidth:v}:p,$=w&&!y?b.cohesion:y;if(0===k.length||0>=m||0>=x)return k.slice();let _=[],P=function(e,t){return(e.pointNodes||[]).map(e=>{let i=Math.max(1,e.r||1)+t;return{x:e.x-i,y:e.y-i,width:2*i,height:2*i}})}(i,n),I=!1,R=k.map((e,t)=>{if(!Pc(e))return e;let n=function(e,t,i){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};let r=e.pointId??e.nodeId;if(null!=r&&i.pointNodes){let e=i.pointNodes.find(e=>e.pointId===r);if(e)return{x:e.x,y:e.y}}let o=e.coordinates,n=i.scales?.geoProjection;if(Array.isArray(o)&&o.length>=2&&n){let e=o[0],t=o[1];if("number"==typeof e&&"number"==typeof t){let i=n([e,t]);if(i&&"number"==typeof i[0]&&"number"==typeof i[1])return{x:i[0],y:i[1]}}}return i.scales||"number"!=typeof e.x||"number"!=typeof e.y?wc(e,t,i):{x:e.x,y:e.y}}(e,t,i);if(!n)return e;let u=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};let t=oc(e);if(t)return{width:Math.max(24,t.width+10),height:Math.max(18,t.height+6)};let i="number"==typeof e.wrap?e.wrap:120,r=[...nc("string"==typeof e.title?e.title:void 0,i,7),...nc("string"==typeof e.label?e.label:void 0,i,7)],o=r.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(i,7*o)+10),height:Math.max(18,16*r.length+6)}}(!0===e.defensive?$c(e):e);if(s&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){let t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}(e);return _.push(Rc(Ic(n.x,n.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,u),o)),e}var d;let h=null,p=1/0;for(let e of function(e){let 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)){let t=Cc(Ic(n.x,n.y,e.dx,e.dy,u),e,_,P,m,x,o,a);p>t&&(h=e,p=t)}if(!h)return e;let f=Rc(Ic(n.x,n.y,h.dx,h.dy,u),o);_.push(f);let y=Math.hypot(h.dx,h.dy),g=l&&y>=c&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return I=!0,{...e,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),L=I?R:k.slice(),C=L;if(h){let e=!1,t=L.map(t=>{let i=function(e){return"text"!==e.type||"string"!=typeof e.color||8>Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)?e:{...e,_redundantConnector:!0}}(t);return i!==t&&(e=!0),i});C=e?t:L}{let e=!1,t=C.map(t=>{if(!0!==t?.defensive)return t;let i=$c(t);return i!==t&&(e=!0),i});C=e?t:C}let T,O=new Set;if(A){let e="object"==typeof A?A:{},t=function(e){if(!e)return 1;let t=function(e){let t=e?.familiarity;if(!t)return 3;let i=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===i.length?3:i.reduce((e,t)=>e+t,0)/i.length}(e);return t>2?4>t?1:.6:1.5}(g),i=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??Sc(m,x,e))*t))},{deferred:r}=function(e){let{annotations:t,width:i,height:r}=e,o=Math.max(0,e.minVisible??1),n=Sc(i,r,e),a=t.map((e,t)=>{return{annotation:e,index:t,note:(i=e,kc(i))};var i}),s=a.filter(e=>e.note);if(0===s.length||n>=s.length)return{visible:t.slice(),deferred:[],budget:n};let l=s.filter(e=>Ac(e.annotation)),c=s.filter(e=>!Ac(e.annotation)).sort((e,t)=>Mc(t.annotation)-Mc(e.annotation)||e.index-t.index),u=Math.min(c.length,Math.max(Math.max(0,n-l.length),Math.max(0,o-l.length))),d=new Set([...l.map(e=>e.index),...c.slice(0,u).map(e=>e.index)]),h=[],p=[];for(let{annotation:e,index:t,note:i}of a)!i||d.has(t)?h.push(e):p.push(e);return{visible:h,deferred:p,budget:n}}({annotations:C,width:m,height:x,...i});for(let e of r)O.add(e)}if(M&&("object"==typeof M&&"number"==typeof M.minWidth?M.minWidth:480)>=m)for(let e of C)Pc(e)&&"secondary"===e.emphasis&&O.add(e);if(O.size>0)for(let e of C)!0===e?.defensive&&O.delete(e);return T=0===O.size?C:S?C.map(e=>O.has(e)?{...e,_annotationDeferred:!0}:e):C.filter(e=>!O.has(e)),$?function(e,t){let i=!1,r=e.map(e=>Pc(e)&&"blended"!==e.cohesion&&"layer"!==e.cohesion?(i=!0,{...e,cohesion:t}):e);return i?r:e}(T,$):T}function Oc(e,t,i,r){let o=function(e,t,i="#4e79a7"){if(fr(e)){let i=function(e,t){let i=2166136261,r=yr(t);for(let e=0;r.length>e;e++)i^=r.charCodeAt(e),i=Math.imul(i,16777619);return`${e}-hatch-${(i>>>0).toString(36)}`}(t,e);return{fill:`url(#${i})`,def:gr(e,i)}}return e&&"string"==typeof e?{fill:e}:{fill:i}}(e.fill??e.color,t,r);return function(e,t,i,r){if(!e||"object"!=typeof e)return;let o=e;if(!Array.isArray(o.stops))return;let n=o.stops.flatMap(e=>{if(!e||"object"!=typeof e)return[];let{offset:t,color:i,opacity:o}=e;return"number"==typeof t&&Number.isFinite(t)?[{offset:Math.max(0,Math.min(1,t)),color:"string"==typeof i&&i?i:r,opacity:"number"==typeof o&&Number.isFinite(o)?Math.max(0,Math.min(1,o)):void 0}]:[]}).sort((e,t)=>e.offset-t.offset);if(!n.length)return;let a="horizontal"===o.direction?"horizontal":"vertical"===o.direction?"vertical":i,s=t+"-gradient";return{fill:`url(#${s})`,def:Kf("linearGradient",{id:s,x1:0,y1:0,x2:"horizontal"===a?"100%":0,y2:"vertical"===a?"100%":0,children:n.map((e,t)=>Kf("stop",{offset:100*e.offset+"%",stopColor:e.color,stopOpacity:e.opacity},`${e.offset}-${t}`))},s)}}(e.gradient,t,i,"string"==typeof e.fill&&e.fill?e.fill:"string"==typeof e.color&&e.color?e.color:r)??o}function Fc(e,t,i){let r=e.position,o="string"==typeof r&&Zb.has(r)?r:"bottom-left",n=o.endsWith("left")?"left":o.endsWith("right")?"right":"center",a=o.startsWith("top")?"top":o.startsWith("bottom")?"bottom":"middle",s="top"===a?0:"bottom"===a?i:i/2;return{x:("left"===n?0:"right"===n?t:t/2)+("number"==typeof e.dx&&Number.isFinite(e.dx)?e.dx:0),y:s+("number"==typeof e.dy&&Number.isFinite(e.dy)?e.dy:0),textAnchor:"start"===e.textAnchor||"middle"===e.textAnchor||"end"===e.textAnchor?e.textAnchor:"left"===n?"start":"right"===n?"end":"middle",dominantBaseline:"auto"===e.dominantBaseline||"middle"===e.dominantBaseline||"hanging"===e.dominantBaseline?e.dominantBaseline:"top"===a?"hanging":"bottom"===a?"auto":"middle"}}function Dc(e,t,i,r){return{...Fc(e,t,i),fill:e.fill??e.color??r.fill,fontSize:e.fontSize??r.fontSize,fontFamily:e.fontFamily??r.fontFamily,fontWeight:e.fontWeight,fontStyle:e.fontStyle,letterSpacing:e.letterSpacing,opacity:e.opacity,className:e.className,style:{pointerEvents:"none"}}}function Ec({annotation:e,width:t,height:i,defaults:r=Jb}){let o=e.label??e.text;return null==o?null:Qb("text",{...Dc(e,t,i,r),children:o})}function Nc(e,t={}){let i=function(e){let t=e.provenance,i=e.id??e.stableId??t?.stableId;return null==i||""===i?void 0:i+""}(e);return{"data-semiotic-annotation-widget":"",...i?{"data-semiotic-annotation-id":i}:{},onClickCapture(r){let o=function(e){let t=e.nativeEvent;return"touch"===t.pointerType?"touch":0===t.detail?"keyboard":"pointer"}(r);t.onAnnotationActivate?.({annotation:e,annotationId:i,chartId:t.chartId,inputType:o}),i&&t.onObservation&&t.onObservation({type:"annotation-activate",annotationId:i,inputType:o,timestamp:Date.now(),chartType:t.chartType??"unknown",chartId:t.chartId})}}}function zc(e,t){return e.color||t.colors.annotation||t.colors.text}function Bc(e,t,i){let r=e.labelBackground,o=t.colors.background,n=o&&"transparent"!==o?o:t.colors.surface||o;return void 0===r?"none"===i?"none":{type:"halo",fill:n}:!1===r||"none"===r?"none":!0===r||"halo"===r?{type:"halo",fill:n}:"box"===r?{type:"box",fill:n}:{fill:n,...r}}function jc(e,t,i){return null!=e.x&&t.x?t.x(e.x):i&&null!=e[i]&&t.x?t.x(e[i]):"number"==typeof e.x?e.x:null}function Wc(e,t,i){return null!=e.y&&t.y?t.y(e.y):i&&null!=e[i]&&t.y?t.y(e[i]):"number"==typeof e.y?e.y:null}function Yc(e){let{annotations:t}=e;if(!t||0===t.length)return e.onRender?.({inputCount:0,eligibleCount:0,renderedCount:0,unrenderedCount:0,unrenderedTypes:[]}),null;let i=function(e,t={}){let i=!0===t.showRetractedAnnotations,r=!0===t.showSupersededAnnotations,o=new Set;for(let t of e){let e=t?.lifecycle?.supersedes;e&&"retracted"!==t?.lifecycle?.status&&o.add(e)}return e.filter(e=>{if("retracted"===e?.lifecycle?.status&&!i)return!1;let t=e?.provenance?.stableId;return!(t&&o.has(t)&&!r)})}(t),r=e.scales.geoProjection,o=r?i.map(e=>{if(!Array.isArray(e.coordinates)||2>e.coordinates.length)return e;let t=r([Number(e.coordinates[0]),Number(e.coordinates[1])]);return t?{...e,x:t[0],y:t[1]}:e}):i,n=!!r&&!e.scales.x&&!e.scales.y,a=e=>Number(e),s=e.scales.x??(n?a:void 0),l=e.scales.y??(n?a:void 0),c=e.projection?"horizontal"===e.projection?"horizontal":"vertical":void 0,u={scales:{..."vertical"===e.projection?{x:e.scales.o??s,y:e.scales.r??l,time:e.scales.o??s,value:e.scales.r??l,o:e.scales.o}:"horizontal"===e.projection?{x:e.scales.r??s,y:e.scales.o??l,time:e.scales.r??s,value:e.scales.o??l,o:e.scales.o}:{x:s,y:l,time:s,value:l,o:e.scales.o},...r?{geoProjection:r}:{}},width:e.layout.width,height:e.layout.height,xAccessor:e.xAccessor,yAccessor:e.yAccessor,data:e.annotationData,pointNodes:e.pointNodes,frameType:e.frameType??(e.projection?"ordinal":r||e.scales.x||e.scales.y?"xy":"network"),...c?{projection:c}:{}},d=e.autoPlaceAnnotations?Tc({annotations:o,context:u,..."object"==typeof e.autoPlaceAnnotations?e.autoPlaceAnnotations:{}}):o,h=function(e,t,i,r){let o=[];return e.forEach((e,n)=>{let a;a=i?i(e,n,r)??t(e,n,r):t(e,n,r),a&&o.push({node:a,annotation:e})}),{nodes:gc(o),renderedAnnotations:o.map(e=>e.annotation)}}(d,(t,i,r)=>function(e,t,i,r){let{scales:o,layout:n,theme:a,xAccessor:s,yAccessor:l}=i;switch(e.type){case"frame-text":return yv(Ec,{annotation:e,width:n.width,height:n.height,defaults:{fill:a.colors.text,fontSize:11,fontFamily:a.typography.fontFamily}},"ann-frame-text-"+t);case"y-threshold":{let r=e.value??e.y;if(null==r)return null;let s=zc(e,a),l=e.label,c=e.strokeDasharray||"6,4",u=e.strokeWidth??1.5;if("horizontal"===i.projection&&o.r){let i=o.r(r);return null==i?null:gv("g",{opacity:e.opacity,children:[yv("line",{x1:i,y1:0,x2:i,y2:n.height,stroke:s,strokeWidth:u,strokeDasharray:c}),tc(e.endCap,[i,0],s),l&&yv(ec,{x:i+4,y:mv,textAnchor:"start",fontSize:a.typography.tickSize,fill:s,fontFamily:a.typography.fontFamily,text:l,background:Bc(e,a,"halo")})]},"ann-ythresh-"+t)}let d=o.y?o.y(r):o.r?o.r(r):null;return null==d?null:yv(ic,{ann:e,position:d,vertical:!1,width:n.width,height:n.height,color:s,fontSize:a.typography.tickSize,fontFamily:a.typography.fontFamily,background:Bc(e,a,"halo"),dash:"6,4",labelGap:6},"ann-ythresh-"+t)}case"x-threshold":{let r=e.value??e.x;if(null==r)return null;let s="horizontal"===i.projection&&o.r?o.r(r):o.x?o.x(r):null;if(null==s)return null;let l=zc(e,a);return yv(ic,{ann:e,position:s,vertical:!0,width:n.width,height:n.height,color:l,fontSize:a.typography.tickSize,fontFamily:a.typography.fontFamily,background:Bc(e,a,"halo"),dash:"6,4"},"ann-xthresh-"+t)}case"band":{let i=o.y?.domain?.(),r=e.y0??i?.[0],s=e.y1??i?.[1],l=null!=r&&o.y?o.y(r):null,c=null!=s&&o.y?o.y(s):null;if(null==l||null==c)return null;let u=Math.min(l,c),d=Math.abs(c-l),h=Oc(e,"ssr-band-"+t,"vertical",zc(e,a)),p=e.fillOpacity??.1;return gv("g",{opacity:e.opacity,children:[h.def&&yv("defs",{children:h.def}),yv("rect",{x:0,y:u,width:n.width,height:d,fill:h.fill,fillOpacity:p}),e.label&&yv(ec,{x:n.width-4,y:Math.max(u,0)+mv,textAnchor:"end",fontSize:a.typography.tickSize,fill:e.color||zc(e,a),fontFamily:a.typography.fontFamily,fontWeight:"bold",text:e.label,background:Bc(e,a,"halo")})]},"ann-band-"+t)}case"x-band":{let i=o.x?.domain?.(),r=e.x0??i?.[0],s=e.x1??i?.[1],l=null!=r&&o.x?o.x(r):null,c=null!=s&&o.x?o.x(s):null;if(null==l||null==c)return null;let u=Math.min(l,c),d=Math.abs(c-l),h=Oc(e,"ssr-xband-"+t,"horizontal",zc(e,a)),p=e.fillOpacity??.1;return gv("g",{opacity:e.opacity,children:[h.def&&yv("defs",{children:h.def}),yv("rect",{x:u,y:0,width:d,height:n.height,fill:h.fill,fillOpacity:p}),e.label&&yv(ec,{x:u+4,y:mv,textAnchor:"start",fontSize:a.typography.tickSize,fill:e.color||a.colors.primary||zc(e,a),fontFamily:a.typography.fontFamily,fontWeight:"bold",text:e.label,background:Bc(e,a,"halo")})]},"ann-xband-"+t)}case"category-highlight":{if(null==e.category||!o.o)return null;let r=o.o(e.category+"");if(null==r)return null;let s=o.o.bandwidth?o.o.bandwidth():40,l=zc(e,a),c=e.opacity??.1,u=e.label;return gv("g","horizontal"===i.projection?{children:[yv("rect",{x:0,y:r,width:n.width,height:s,fill:l,opacity:c}),u&&yv(ec,{x:12,y:r+s/2,dominantBaseline:"middle",fill:l,fontSize:a.typography.tickSize,fontWeight:"bold",fontFamily:a.typography.fontFamily,text:u,background:Bc(e,a,"none")})]}:{children:[yv("rect",{x:r,y:0,width:s,height:n.height,fill:l,opacity:c}),u&&yv(ec,{x:r+s/2,y:mv,textAnchor:"middle",fill:l,fontSize:a.typography.tickSize,fontWeight:"bold",fontFamily:a.typography.fontFamily,text:u,background:Bc(e,a,"none")})]},"ann-cathighlight-"+t)}case"label":case"callout":case"callout-circle":case"callout-rect":case"text":{let i=function(e,t,i,r){if(Array.isArray(e.coordinates)&&e.coordinates.length>=2&&t.geoProjection){let i=t.geoProjection([e.coordinates[0],e.coordinates[1]]);if(i)return{x:i[0],y:i[1]}}return{x:jc(e,t,i),y:Wc(e,t,r)}}(e,o,s,l),n=null==i.x||null==i.y?wc(e,t,r):null,c=i.x??n?.x??null,u=i.y??n?.y??null;if(null==c||null==u)return null;let d="text"===e.type,h=e.dx??(d?0:30),p=e.dy??(d?0:-30),f=e.color||a.colors.text;if(!d){let i="callout"===e.type?"callout-circle":e.type,r="callout-circle"===i?{radius:e.radius??12,radiusPadding:e.radiusPadding}:"callout-rect"===i?{width:e.width,height:e.height}:void 0;return yv(dc,{noteData:{x:c,y:u,dx:h,dy:p,note:rc(e),type:i,...r?{subject:r}:{},connector:e.connector||{end:"arrow"},color:f,disable:e.disable,opacity:e.opacity,strokeDasharray:e.strokeDasharray,className:e.className}},"ann-label-"+t)}return yv("g",{children:yv("text",{x:c+h,y:u+p,textAnchor:e.textAnchor||"start",fontSize:e.fontSize||a.typography.labelSize,fill:f,fontFamily:a.typography.fontFamily,fontWeight:e.fontWeight,opacity:e.opacity,strokeDasharray:e.strokeDasharray,children:e.label||e.title})},"ann-label-"+t)}default:return null}}(t,i,e,r)??function(e,t,i){switch(e.type){case"enclose":{let r=(e.coordinates||[]).map(e=>({x:mc({...e,type:"point"},i),y:xc({...e,type:"point"},i),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;let o=ev(r),n=e.padding||10;return pv("g",{children:[hv("circle",{cx:o.x,cy:o.y,r:o.r+n,fill:e.fill||"none",fillOpacity:e.fillOpacity??.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&hv(ec,{x:o.x,y:o.y-o.r-n-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+t)}case"rect-enclose":{let r=(e.coordinates||[]).map(e=>({x:mc({...e,type:"point"},i),y:xc({...e,type:"point"},i)})).filter(e=>null!=e.x&&null!=e.y);if(2>r.length)return null;let o=e.padding||10,[n,a]=no(r.map(e=>e.x)),[s,l]=no(r.map(e=>e.y)),c=n-o,u=a+o,d=s-o;return pv("g",{children:[hv("rect",{x:c,y:d,width:u-c,height:l+o-d,fill:e.fill||"none",fillOpacity:e.fillOpacity??.1,stroke:e.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),e.label&&hv(ec,{x:(c+u)/2,y:d-4,textAnchor:"middle",fill:e.color||"var(--semiotic-text-secondary, #666)",fontSize:12,text:e.label,background:e.labelBackground??"none"})]},"ann-"+t)}case"highlight":{let r=i.data||[],o="function"==typeof e.filter?r.filter(e.filter):e.field&&null!=e.value?r.filter(t=>t[e.field]===e.value):[],n={stroke:e.color||"#f97316",strokeWidth:2,fill:"none"};return hv("g",{children:o.map((t,r)=>{let o=mc(t,i),a=xc(t,i);if(null==o||null==a)return null;let s="function"==typeof e.r?e.r(t):e.r||6,l="function"==typeof e.style?e.style(t):e.style||n;return hv("circle",{cx:o,cy:a,r:s,...l},"hl-"+r)})},"ann-"+t)}case"bracket":{let r=mc(e,i),o=xc(e,i);return hv(dc,{noteData:{x:r??0,y:o??0,dx:e.dx||0,dy:e.dy||0,note:rc(e),type:"bracket",subject:{type:e.bracketType||"curly",width:e.width,height:e.height,depth:e.depth||30},color:e.color}},"ann-"+t)}case"trend":{let r=i.data||[];if(2>r.length)return null;let o,n=i.xAccessor||"x",a=i.yAccessor||"y",s="ordinal"===i.frameType,l="horizontal"===i.projection,c=s?n:null,u=s?a:null,d=[],h=new Map;if(s&&c&&u){for(let e of r){let t=e[c];if(null==t)continue;let i=t+"";h.has(i)||(h.set(i,d.length),d.push(i))}o=r.map(e=>{let t=e[c],i=e[u];if(null==t||null==i)return null;let r=h.get(t+"");return null!=r?[r,+i]:null}).filter(e=>null!==e)}else o=r.map(e=>[e[n],e[a]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>o.length)return null;let p=i.scales?.x??i.scales?.time,f=i.scales?.y??i.scales?.value;if(!p||!f)return null;let y,g=e=>t=>{let i=Math.max(0,Math.floor(t)),r=Math.min(d.length-1,i+1),o=t-i,n=e(d[i]);return n+(e(d[r])-n)*o},m=p,x=f;if(s)if(l){let e=g(x);y=(t,i)=>[m(i),e(t)]}else{let e=g(m);y=(t,i)=>[e(t),x(i)]}else y=(e,t)=>[m(e),x(t)];let b=e.method||"linear",v="loess"===b?function(e,t=.3){let i=e.length;if(2>i)return e.slice();let r=e.slice().sort((e,t)=>e[0]-t[0]),o=r.map(e=>e[0]),n=r.map(e=>e[1]),a=Math.min(i,Math.max(2,Math.ceil(t*i))),s=Number.isFinite(a)&&o.every(Number.isFinite),l=0,c=a-1,u=[];for(let e=0;i>e;e++){let t,r=o[e],d=0,h=i-1;if(s){for(;i-1>c&&Math.abs(o[l]-r)>=Math.abs(o[c+1]-r);)l++,c++;let e=Math.max(Math.abs(o[l]-r),Math.abs(o[c]-r));t=e||1,e>0&&(d=l,h=c)}else t=o.map(e=>Math.abs(e-r)).sort((e,t)=>e-t)[a-1]||1;let p=0,f=0,y=0,g=0,m=0;for(let e=d;h>=e;e++){let i=Math.abs(o[e]-r)/t,a=1>i?Math.pow(1-Math.pow(i,3),3):0;0!==a&&(p+=a,f+=a*o[e],y+=a*n[e],g+=a*o[e]*o[e],m+=a*o[e]*n[e])}if(0===p){u.push([r,n[e]]);continue}let x=p*g-f*f;if(1e-12>Math.abs(x))u.push([r,y/p]);else{let e=(p*m-f*y)/x;u.push([r,(y-e*f)/p+e*r])}}return u}(o,e.bandwidth??.3):("polynomial"===b?Do(o,e.order||2):function(e){let t=[0,0,0,0],i=0;for(let[r,o]of e)null!==o&&(i++,t[0]+=r,t[1]+=o,t[2]+=r*r,t[3]+=r*o);let r=i*t[2]-t[0]*t[0],o=0===r?0:Fo((i*t[3]-t[0]*t[1])/r),n=Fo(t[1]/i-o*t[0]/i);return{points:e.map(([e])=>[Fo(e),Fo(o*e+n)]),equation:[o,n]}}(o)).points,w=v.map(([e,t])=>{let[i,r]=y(e,t);return`${i},${r}`}).join(" "),k=e.color||"#6366f1",A=v[v.length-1],[S,M]=y(A[0],A[1]);return pv("g",{children:[hv("polyline",{points:w,fill:"none",stroke:k,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray||"6,3"}),e.label&&hv("text",{x:S+4,y:M-4,fill:k,fontSize:11,children:e.label})]},"ann-"+t)}case"envelope":{let r=i.data||[];if(2>r.length)return null;let o=i.xAccessor||"x",n=i.scales?.x??i.scales?.time,a=i.scales?.y??i.scales?.value;if(!n||!a)return null;let s=e.upperAccessor||"upperBounds",l=e.lowerAccessor||"lowerBounds",c=e.filter,u=r.filter(e=>null!=e[s]&&null!=e[l]&&(!c||c(e))).sort((e,t)=>e[o]-t[o]);if(2>u.length)return null;let d=fv[i.curve||"linear"]||nv,h=tv().x(e=>n(e[o])).y0(e=>a(e[l])).y1(e=>a(e[s])).curve(d)(u);if(!h)return null;let p=e.fill||"#6366f1",f=u[u.length-1];return pv("g",{children:[hv("path",{d:h,fill:p,fillOpacity:e.fillOpacity??.15,stroke:"none"}),e.label&&hv("text",{x:n(f[o])+4,y:a(f[s])-4,fill:p,fontSize:11,children:e.label})]},"ann-"+t)}case"anomaly-band":{let r=i.data||[];if(2>r.length)return null;let o=i.yAccessor||"y",n=i.scales?.x??i.scales?.time,a=i.scales?.y??i.scales?.value;if(!n||!a)return null;let s=r.map(e=>e[o]).filter(e=>null!=e&&isFinite(e));if(2>s.length)return null;let l=s.reduce((e,t)=>e+t,0)/s.length,c=s.reduce((e,t)=>e+(t-l)**2,0)/s.length,u=Math.sqrt(c),d=e.threshold??2,h=l-d*u,p=a(l+d*u),f=a(h),y=e.fill||"#6366f1",g=e.anomalyColor||"#ef4444",m=e.anomalyRadius??6,x=r.filter(e=>{let t=e[o];return null!=t&&Math.abs(t-l)>d*u});return pv("g",{children:[!1!==e.showBand&&hv("rect",{x:0,y:Math.min(p,f),width:i.width||0,height:Math.abs(f-p),fill:y,fillOpacity:e.fillOpacity??.1}),x.map((e,t)=>{let r=mc(e,i),o=xc(e,i);return null==r||null==o?null:hv("circle",{cx:r,cy:o,r:m,fill:g,fillOpacity:.7,stroke:g,strokeWidth:1.5},"anomaly-"+t)}),e.label&&hv("text",{x:(i.width||0)-4,y:Math.min(p,f)-4,textAnchor:"end",fill:y,fontSize:11,children:e.label})]},"ann-"+t)}case"forecast":{let r=i.data||[];if(3>r.length)return null;let o=i.xAccessor||"x",n=i.yAccessor||"y",a=i.scales?.x??i.scales?.time,s=i.scales?.y??i.scales?.value;if(!a||!s)return null;let l,c=r.map(e=>[e[o],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]);if(3>c.length)return null;if("polynomial"===e.method){let t=Do(c,e.order||2).equation;l=e=>t.reduce((t,i,r)=>t+i*Math.pow(e,r),0)}else{let e=Eo(c);if(!e)return null;l=e}let{se:u,meanX:d,ssX:h}=No(c,l),p=c.length,f=zo(e.confidence??.95),y=c[p-1][0],g=(y-c[0][0])/Math.max(p-1,1),m=Array.from({length:e.steps??5},(e,t)=>{let i=y+(t+1)*g,r=l(i),o=u*Math.sqrt(1+1/p+(h>0?(i-d)**2/h:0))*f;return{x:i,center:r,upper:r+o,lower:r-o}}),x=m.map(e=>`${a(e.x)},${s(e.upper)}`).join(" L"),b=m.slice().reverse().map(e=>`${a(e.x)},${s(e.lower)}`).join(" L"),v=m.map(e=>`${a(e.x)},${s(e.center)}`).join(" "),w=e.strokeColor||"#6366f1",k=m[m.length-1];return pv("g",{children:[hv("path",{d:`M${x} L${b} Z`,fill:e.fill||"#6366f1",fillOpacity:e.fillOpacity??.15,stroke:"none"}),hv("polyline",{points:`${a(y)},${s(l(y))} ${v}`,fill:"none",stroke:w,strokeWidth:e.strokeWidth??2,strokeDasharray:e.strokeDasharray??"6,3"}),e.label&&k&&hv("text",{x:a(k.x)+4,y:s(k.center)-4,fill:w,fontSize:11,children:e.label})]},"ann-"+t)}case"widget":{let r,o;if(null!=e.px&&null!=e.py)r=e.px,o=e.py;else{let n=wc(e,t,i);if(!n)return null;r=n.x,o=n.y}if(!function(e,t,i,r=50){return!(-r>e||e>(i.width||0)+r||-r>t||t>(i.height||0)+r)}(r,o,i))return null;let n=e.width??32,a=e.height??32,s=e.content??hv("span",{style:{fontSize:18,cursor:"default"},title:e.label||"Info",children:"ℹ️"});return hv("foreignObject",{x:r+(e.dx??0)-n/2,y:o+(e.dy??0)-a/2,width:n,height:a,style:{overflow:"visible",pointerEvents:"auto"},children:hv("div",{...Nc(e),style:{width:n,height:a,display:"flex",alignItems:"center",justifyContent:"center"},children:s})},"ann-"+t)}default:return null}}(t,i,r),e.svgAnnotationRules,u),p=h.nodes,f=new Map;for(let e of h.renderedAnnotations){let t="string"==typeof e.type?e.type:"unknown";f.set(t,(f.get(t)??0)+1)}let y=[];for(let e of t){let t="string"==typeof e.type?e.type:"unknown",i=f.get(t)??0;i>0?f.set(t,i-1):y.push(t)}return e.onRender?.({inputCount:t.length,eligibleCount:d.length,renderedCount:h.renderedAnnotations.length,unrenderedCount:y.length,unrenderedTypes:y}),p.length>0?yv("g",{id:(e.idPrefix?e.idPrefix+"-":"")+"annotations",className:"semiotic-annotations",children:p}):null}function qc(e,t,i,r="right",o,n){if(null==e||!1===e)return null;let{x:a,y:s}=b(e,{totalWidth:t[0],totalHeight:t[1],margin:i,position:r,legendLayout:o,axisChrome:n});return xv("g",{transform:`translate(${a}, ${s})`,children:e})}function Xc(e){let t=(e+"").replace(/[^a-zA-Z0-9_-]/g,"_"),i=/^[A-Za-z_]/.test(t)?t:"c"+t,r=i+"-semiotic-title",o=i+"-semiotic-desc";return{titleId:r,descId:o,labelledBy:`${r} ${o}`}}function Gc(e,t,i){if("edges"===e){if(t)return"start";if(i)return"end"}return"middle"}function Vc(e,t,i){if("edges"===e){if(t)return"hanging";if(i)return"auto"}return"middle"}function Hc(e){if(0===e.length)return{min:null,max:null};let t=1/0,i=-1/0;for(let r of e)t>r.pixel&&(t=r.pixel),r.pixel>i&&(i=r.pixel);return{min:t,max:i}}function Uc(e){if(e)return"object"==typeof e?e.strokeDasharray:"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Kc(e,t){return e&&"string"!=typeof e?{stroke:e.stroke??t.stroke,strokeWidth:e.strokeWidth??t.strokeWidth,...null!=e.strokeOpacity&&{strokeOpacity:e.strokeOpacity},...e.strokeDasharray&&{strokeDasharray:e.strokeDasharray}}:{...t,..."string"==typeof e&&{strokeDasharray:Uc(e)}}}function Zc(e,t,i){if("left"===e||"right"===e){let r="left"===e?i:0,o="left"===e?-1:1,n=Math.ceil(t/8),a="M0,"+r;for(let e=0;n>e;e++){let i=8*(e+1);a+=`L${Math.min(8*e+4,t)},${r+4*o}`,a+=`L${Math.min(i,t)},${r}`}return a}let r="bottom"===e?0:t,o="bottom"===e?1:-1,n=Math.ceil(i/8),a=`M${r},0`;for(let e=0;n>e;e++){let t=8*(e+1);a+=`L${r+4*o},${Math.min(8*e+4,i)}`,a+=`L${r},${Math.min(t,i)}`}return a}function Qc(e,t,i){return"exact"===i?function(e,t){let i=e.domain(),r=i[0],o=i[i.length-1],n=r instanceof Date,a=r instanceof Date?r.getTime():r,s=o instanceof Date?o.getTime():o;if(2>t||a===s)return n?[new Date(a),new Date(s)]:[a,s];let l=(s-a)/(t-1),c=Array(t);for(let e=0;t>e;e++){let i=e===t-1?s:a+e*l;c[e]=n?new Date(i):i}return c}(e,t):e.ticks(t)}function Jc(e){return"string"==typeof e||"number"==typeof e}function eu(e){let{label:t,x:i,y:r,textAlign:o,fontSize:n,fontFamily:a,color:s}=e;return vv("foreignObject",{x:i,y:r,width:60,height:24,style:{overflow:"visible"},children:vv("div",{style:{color:s,fontFamily:a,fontSize:n,textAlign:o,userSelect:"none"},children:t})})}function tu(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function iu(e,t,i,r){return!!e&&("function"==typeof e?e(t.value,i):function(e,t){let i=tu(e);if(!i)return!1;let r=tu(t);return!r||i.getFullYear()!==r.getFullYear()||i.getMonth()!==r.getMonth()}(t.value,i>0?r[i-1].value:void 0))}function ru(e){let t=new Date(e instanceof Date?e.valueOf():e);return`${wv[t.getUTCMonth()]} ${t.getUTCDate()}`}function ou(e){let t=Math.abs(e[1]-e[0]);return 864e5>t?e=>{let i=new Date(e instanceof Date?e.valueOf():e),r=`${(i.getUTCHours()+"").padStart(2,"0")}:${(i.getUTCMinutes()+"").padStart(2,"0")}`;return 3e5>t&&(r+=":"+(i.getUTCSeconds()+"").padStart(2,"0")),1e4>t&&(r+="."+(i.getUTCMilliseconds()+"").padStart(3,"0")),r}:3156e7>t?ru:1578e8>t?e=>{let t=new Date(e instanceof Date?e.valueOf():e);return`${wv[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e instanceof Date?e.valueOf():e).getUTCFullYear()+""}function nu(e){return"string"==typeof e||"number"==typeof e?6.5*(e+"").length:60}function au(e){let{scale:i,axis:r,size:o,horizontal:n=!1,axisExtent:a}=e,s=r?.extent??a,l=i.domain(),c=function(e){return e?.ticks??e?.tickCount??5}(r),u=Math.max(2,Math.floor(o/(n?70:30))),d="exact"===s?Math.max(2,c):Math.min(c,u),h=r?.tickValues??Qc(i,d,s),p=h.map(e=>e.valueOf()),f=r?.tickFormat||e.format||(l[0]instanceof Date||h[0]instanceof Date?ou([l[0].valueOf(),l[l.length-1].valueOf()]):t(p)),y=(e,t)=>n?f(e,t,p):f(e),g=h.map((e,t)=>({value:e,pixel:i(e),label:y(e,t)})),m=22;if(n){let e=g.reduce((e,t)=>Math.max(e,nu(t.label)),0);m=r?.autoRotate?Math.max(20,Math.min(e+8,55)):Math.max(55,e+8)}let x=function(e,t){if(2>=e.length)return e;let i=[e[0]];for(let r=1;e.length-1>r;r++)Math.abs(e[r].pixel-i[i.length-1].pixel)>=t&&i.push(e[r]);let r=e[e.length-1];return t>Math.abs(r.pixel-i[i.length-1].pixel)?i[i.length-1]=r:i.push(r),i}(g,m);if(x.length>1&&(x=x.filter((e,t)=>{return 0===t||(r=x[t-1].label,!!("string"!=typeof(i=e.label)&&"number"!=typeof i||"string"!=typeof r&&"number"!=typeof r||i+""!=r+""));var i,r})),r?.includeMax&&x.length>0&&"exact"!==s&&!r.tickValues){let e=l[l.length-1];if(null!=e){let t=i(e),r=Math.abs(t-x[x.length-1].pixel);if(r>1){let i=y(e,x.length);m>r&&x.length>1&&(x=x.slice(0,-1)),x=[...x,{value:e,pixel:t,label:i}]}}}return x}function su(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){let t=e.id;return null==t?null:t+""}return null}function lu(e){let t=e._idPrefix||e.chartId;if(t){let e=(t+"").replace(/[^a-zA-Z0-9_-]/g,"_");return/^[A-Za-z_]/.test(e)?e:"c"+e}let i=`${e.chartType||""}:${e.title||""}:${Array.isArray(e.data)?e.data.length:0}`,r=0;for(let e=0;i.length>e;e++)r=31*r+i.charCodeAt(e)|0;return"c"+(r>>>0).toString(36)}function cu(e,t,r){return i(e.showLegend&&!e.__legendIncludesAutomatic?Gl(t,e.colorScheme,r):void 0,e.legend)}function uu(e,t){if(e.__autoLegendMargin)return Sv[t]}function du(e,i){let n={theme:i.theme,position:i.position||"right",totalWidth:i.size[0],totalHeight:i.size[1],margin:i.margin,hasTitle:i.hasTitle,legendLayout:i.legendLayout,idPrefix:i.idPrefix,reservedWidth:i.reservedWidth,axisChrome:i.axisChrome,legendDistance:r(e)||o(e)?e.legendDistance:void 0};return r(e)?function(e){if(0===(t=e.legendGroups,t.flatMap(e=>e.items.map((t,i)=>({group:e,item:t,itemIndex:i,label:t.label})))).length)return null;var t;let i=function(e){let{legendGroups:t,theme:i,position:r="right",totalWidth:o,margin:n,legendLayout:a}=e,{swatchSize:s,labelGap:l,rowHeight:c}=v(a),u=s+l,d=Math.max(12,Hl(i)),h="top"===r||"bottom"===r,p=Math.max(s,o-n.left-n.right);if(h){let r=Math.max(s,a?.maxWidth??p),o=Vl(a?.align),n=0,l=0,c=[];for(let o of t){let t=o.items.map(e=>e.label),u=Ql({...e,categories:t,legendLayout:{...a,maxWidth:Math.max(s,r-d-8),align:"start"}}),h=o.label?d:0,p=o.label?Zl(o.label,0,0,i):0,f=h>0?h+8:0,y=f+u.width,g=Math.max(u.height,p);c.push({group:o,x:n,y:0,itemOffsetX:f,itemOffsetY:0,width:y,height:g,items:u.items}),n+=y+12,l=Math.max(l,g)}let h=c.length>0?n-12:0,f=h>r?0:"center"===o?Math.max(0,(r-h)/2):"end"===o?Math.max(0,r-h):0;return{groups:c.map(e=>({...e,x:e.x+f})),width:h,height:l,swatchSize:s,labelOffset:u,swatchRadius:0}}let f=w(t.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),c),y=0;return{groups:t.map((e,t)=>{let r=e.items.map(e=>Zl(e.label,s,l,i)),o=Math.max(0,...r,e.label?Zl(e.label,0,0,i):0);return y=Math.max(y,o),{group:e,x:0,y:f[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:f.at(-1)?.endY??0,swatchSize:s,labelOffset:u,swatchRadius:0}}(e),r="top"===e.position||"bottom"===e.position,o={legendGroups:e.legendGroups,legendDistance:e.legendDistance},n=e.reservedWidth??u(o,e.legendLayout),a=e.theme.colors.grid||e.theme.colors.textSecondary,{x:s,y:l}=b(o,{totalWidth:e.totalWidth,totalHeight:e.totalHeight,margin:e.margin,position:e.position,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:n});if(!r){let t=w(e.legendGroups.map(e=>({hasLabel:!!e.label,itemCount:e.items.length})),Math.max(i.swatchSize,e.legendLayout?.rowHeight??22)),r=e.legendGroups.flatMap((r,o)=>{let a=t[o],s=r.type??"fill",l=[Cb("line",{x1:0,y1:a.lineY,x2:n,y2:a.lineY,stroke:"gray"},"legend-group-neatline-"+o)];return r.label&&null!=a.labelY&&l.push(Cb("text",{y:a.labelY,fontSize:Hl(e.theme),fill:e.theme.colors.text,fontFamily:Ul(e.theme),children:r.label},"legend-group-label-"+o)),l.push(Cb("g",{transform:`translate(0,${a.itemsY})`,children:r.items.map((t,n)=>{let a=r.styleFn(t,n),l="function"==typeof s?s(t):"line"===s?Cb("line",{x1:0,y1:0,x2:i.swatchSize,y2:i.swatchSize,style:a}):Cb("rect",{width:i.swatchSize,height:i.swatchSize,rx:i.swatchRadius,style:a});return Tb("g",{transform:`translate(0,${n*Math.max(i.swatchSize,e.legendLayout?.rowHeight??22)})`,children:[l,Cb("text",{x:i.labelOffset,y:i.swatchSize/2,dominantBaseline:"central",fontSize:Hl(e.theme),fill:e.theme.colors.text,fontFamily:Ul(e.theme),children:t.label})]},`legend-${o}-${n}`)})},"legend-group-"+o)),l});return Cb("g",{className:"semiotic-legend",transform:`translate(${s},${l})`,"data-orientation":"vertical",fontWeight:Kl(e.theme),children:r})}let c=i.groups.flatMap((t,o)=>{let{group:n}=t,s=n.type??"fill",l=[];if(n.label&&l.push(Cb("text",r?{transform:`translate(${t.x},${t.y}) rotate(90)`,textAnchor:"start",fontSize:Hl(e.theme),fill:e.theme.colors.text,fontFamily:Ul(e.theme),children:n.label}:{x:t.x,y:t.y+Hl(e.theme),fontSize:Hl(e.theme),fill:e.theme.colors.text,fontFamily:Ul(e.theme),children:n.label},"legend-group-label-"+o)),l.push(...t.items.map((r,a)=>{let l=n.items[a],c=n.styleFn(l,a),u="function"==typeof s?s(l):"line"===s?Cb("line",{x1:0,y1:0,x2:i.swatchSize,y2:i.swatchSize,style:c}):Cb("rect",{width:i.swatchSize,height:i.swatchSize,rx:i.swatchRadius,style:c});return Tb("g",{transform:`translate(${t.x+t.itemOffsetX+r.x},${t.y+t.itemOffsetY+r.y})`,children:[u,Cb("text",{x:i.labelOffset,y:i.swatchSize/2,dominantBaseline:"central",fontSize:Hl(e.theme),fill:e.theme.colors.text,fontFamily:Ul(e.theme),children:r.category})]},`legend-${o}-${a}`)})),r&&i.groups.length-1>o){let e=t.x+t.width+6;l.push(Cb("line",{x1:e,y1:0,x2:e,y2:i.height,stroke:a},"legend-group-separator-"+o))}return l});return Cb("g",{className:"semiotic-legend",transform:`translate(${s},${l})`,"data-orientation":r?"horizontal":"vertical",fontWeight:Kl(e.theme),children:c})}({...n,legendGroups:e.legendGroups}):o(e)?function(e){let i=function(e){let t="top"===e.position||"bottom"===e.position,i=Math.max(1,e.totalWidth-e.margin.left-e.margin.right);return t?{width:Math.min(e.legendLayout?.maxWidth??i,200),height:e.gradient.label?46:26,swatchSize:12}:{width:e.gradient.label?86:72,height:e.gradient.label?126:108,swatchSize:14}}(e),r="top"===e.position||"bottom"===e.position,o={gradient:e.gradient,legendDistance:e.legendDistance},n=u(o),a=(e.idPrefix?e.idPrefix+"-":"")+"semiotic-static-gradient-legend",s=e.gradient.format||t(e.gradient.domain),{x:l,y:c}=b(o,{totalWidth:e.totalWidth,totalHeight:e.totalHeight,margin:e.margin,position:e.position,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:n}),d=Array.from({length:17},(t,i)=>{let o=i/16;return Cb("stop",{offset:o,stopColor:e.gradient.colorFn(r?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]))},i)});if(r){let t=e.gradient.label?12:void 0,r=e.gradient.label?18:0;return Tb("g",{className:"semiotic-legend",transform:`translate(${l},${c})`,fontWeight:Kl(e.theme),children:[Cb("defs",{children:Cb("linearGradient",{id:a,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:d})}),e.gradient.label&&Cb("text",{x:i.width/2,y:t,textAnchor:"middle",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:Ul(e.theme),children:e.gradient.label}),Cb("rect",{x:0,y:r,width:i.width,height:12,fill:`url(#${a})`,rx:2}),Cb("text",{x:0,y:r+12+12,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:Ul(e.theme),children:s(e.gradient.domain[0])}),Cb("text",{x:i.width,y:r+12+12,textAnchor:"end",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:Ul(e.theme),children:s(e.gradient.domain[1])})]})}let h=e.gradient.label?12:void 0,p=e.gradient.label?18:0;return Tb("g",{className:"semiotic-legend",transform:`translate(${l},${c})`,fontWeight:Kl(e.theme),children:[Cb("defs",{children:Cb("linearGradient",{id:a,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:d})}),e.gradient.label&&Cb("text",{x:0,y:h,textAnchor:"start",fontSize:e.theme.typography.tickSize,fill:e.theme.colors.text,fontFamily:Ul(e.theme),children:e.gradient.label}),Cb("rect",{x:0,y:p,width:14,height:100,fill:`url(#${a})`,rx:2}),Cb("text",{x:19,y:p+10,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:Ul(e.theme),children:s(e.gradient.domain[1])}),Cb("text",{x:19,y:p+100,fontSize:e.theme.typography.tickSize,fill:e.theme.colors.textSecondary,fontFamily:Ul(e.theme),children:s(e.gradient.domain[0])})]})}({...n,gradient:e.gradient}):null}function hu(e,t){let{props:i,categories:r,theme:o,size:n,hasTitle:a}=t,s=i.legendPosition||"right",c={...e},u={theme:o,position:s,size:n,hasTitle:a,legendLayout:i.legendLayout,axisChrome:i.axisChrome,minimumMargin:uu(i,s)};if(null!=i.legend){let t=cu(i,r,o);null!=t&&!1!==t&&function(e,t){x(e,{legend:t.legend,position:t.position||"right",size:t.size,hasTitle:t.hasTitle,legendLayout:t.legendLayout,minimumMargin:t.minimumMargin,axisChrome:t.axisChrome})}(e,{...u,legend:t})}else i.showLegend&&r.length>0&&function(e,t){if(0===t.categories.length)return;let i=t.position||"right";x(e,{legend:Gl(t.categories,t.colorScheme,t.theme),position:i,size:t.size,hasTitle:t.hasTitle,legendLayout:t.legendLayout,minimumMargin:t.minimumMargin,axisChrome:t.axisChrome})}(e,{...u,categories:r,colorScheme:i.colorScheme});return l(e,c,n,s),s}function pu(e){let{props:t,categories:i,theme:n,size:a,margin:s,hasTitle:l}=e,c=t.legendPosition||"right",d={theme:n,position:c,size:a,margin:s,hasTitle:l,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix};if(null!=t.legend){let e=cu(t,i,n);return bv.isValidElement(e)?qc(e,a,s,c,t.legendLayout,t.axisChrome):du(e,d)||(r(e)||o(e)?null:qc(e??null,a,s,c,t.legendLayout,t.axisChrome))}return t.showLegend&&0!==i.length?function(e){let{categories:t,colorScheme:i,theme:r,position:o="right",totalWidth:n,totalHeight:a,margin:s}=e;if(!t||0===t.length)return null;let l=Xl(t,i,r),c="top"===o||"bottom"===o,d=Ql(e),h={...Gl(t,i,r),legendDistance:e.legendDistance},p=e.reservedWidth??u(h,e.legendLayout),{x:f,y:y}=b(h,{totalWidth:n,totalHeight:a,margin:s,position:o,legendLayout:e.legendLayout,axisChrome:e.axisChrome,reservedWidth:p});if(c){let e=d.items.map((e,t)=>Tb("g",{transform:`translate(${e.x},${e.y})`,children:[Cb("rect",{width:d.swatchSize,height:d.swatchSize,fill:l(e.category),rx:d.swatchRadius}),Cb("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:Hl(r),fill:r.colors.text,fontFamily:Ul(r),children:e.category})]},"legend-"+t));return Cb("g",{className:"semiotic-legend",transform:`translate(${f},${y})`,fontWeight:Kl(r),children:e})}let g=w([{hasLabel:!1,itemCount:t.length}],Math.max(d.swatchSize,e.legendLayout?.rowHeight??22))[0],m=d.items.map((e,t)=>Tb("g",{transform:`translate(${e.x},${e.y+g.itemsY})`,children:[Cb("rect",{width:d.swatchSize,height:d.swatchSize,fill:l(e.category),rx:d.swatchRadius}),Cb("text",{x:d.labelOffset,y:d.swatchSize/2,dominantBaseline:"central",fontSize:Hl(r),fill:r.colors.text,fontFamily:Ul(r),children:e.category})]},"legend-"+t));return Tb("g",{className:"semiotic-legend",transform:`translate(${f},${y})`,fontWeight:Kl(r),children:[Cb("line",{x1:0,y1:g.lineY,x2:p,y2:g.lineY,stroke:"gray"}),m]})}({categories:i,colorScheme:t.colorScheme,theme:n,position:c,totalWidth:a[0],totalHeight:a[1],margin:s,hasTitle:l,legendLayout:t.legendLayout,axisChrome:t.axisChrome,idPrefix:t._idPrefix}):null}function fu(e,t){let i=Rr(t.theme),r=t.background??i.background,o=t.idPrefix?t.idPrefix+"-":"",n="string"==typeof t.title?t.title:void 0,a=t.idPrefix?Xc(t.idPrefix):{titleId:"semiotic-title",descId:"semiotic-desc"},s=n?a.titleId:void 0,l=t.description?a.descId:void 0,c=[s,l].filter(Boolean).join(" ")||void 0;return Av("svg",{xmlns:"http://www.w3.org/2000/svg",className:t.className,width:t.width,height:t.height,role:"img","aria-labelledby":c,style:{fontFamily:i.fontFamily},children:[n&&kv("title",{id:s,children:n}),t.description&&kv("desc",{id:l,children:t.description}),t.defs&&kv("defs",{children:t.defs}),r&&"transparent"!==r&&kv("rect",{x:0,y:0,width:t.width,height:t.height,fill:r}),kv("g",{id:o+"data-area",transform:t.innerTransform,children:e}),n&&kv("text",{id:o+"chart-title",x:t.width/2,y:22,textAnchor:"middle",fontSize:i.titleFontSize,fontWeight:i.titleFontWeight,fill:i.text,fontFamily:i.titleFontFamily,children:n}),t.legend&&kv("g",{id:o+"legend",children:t.legend}),t.outerElements]})}function yu(e,t,i,r){return"function"==typeof e?e({size:t,margin:i,scales:r}):e}function gu(t,i){let r=Ir(t.theme),o=t.size||[500,300],a=s({..._v,...t.margin},t.title),l=n(t.title),c=function(e,t){if(!t||0===e.length||!e.some(e=>null!=e&&"object"==typeof e&&Array.isArray(e[t])))return e;let i=[];for(let r of e){if(null==r||"object"!=typeof r)continue;let e=r[t];if(!Array.isArray(e))continue;let o=r.label??r.id??r.key;for(let t of e)null==t||"object"!=typeof t||i.push(null==o?t:{...t,_lineGroup:o})}return i}(bo(t.data),t.lineDataAccessor),u=t.showLegend?Jl(c,t.colorAccessor||t.groupAccessor||t.categoryAccessor):[],d=y({showAxes:t.showAxes,xLabel:t.xLabel,yLabel:t.yLabel,yLabelRight:t.yLabelRight,axes:t.axes});hu(a,{props:{...t,axisChrome:d},categories:u,theme:r,size:o,hasTitle:l});let p=pu({props:{...t,axisChrome:d},categories:u,theme:r,size:o,margin:a,hasTitle:l}),f=o[0]-a.left-a.right,g=o[1]-a.top-a.bottom,m="streaming"===t.runtimeMode||["bar","swarm","waterfall"].includes(t.chartType),x=t.colorScheme||r.colors.categorical,b=(t.axes?.find(e=>"left"===e.orient)??t.axes?.find(e=>"right"===e.orient))?.extent??t.axisExtent,v={chartType:t.chartType,runtimeMode:m?"streaming":"bounded",windowSize:t.windowSize??200,windowMode:t.windowMode??"sliding",arrowOfTime:m?t.arrowOfTime??"right":"right",extentPadding:t.extentPadding??.1,xAccessor:t.xAccessor,yAccessor:t.yAccessor,timeAccessor:m?t.timeAccessor:void 0,valueAccessor:t.valueAccessor,colorAccessor:t.colorAccessor,sizeAccessor:t.sizeAccessor,symbolAccessor:t.symbolAccessor,symbolMap:t.symbolMap,groupAccessor:t.groupAccessor||(t.lineDataAccessor?"_lineGroup":void 0),categoryAccessor:t.categoryAccessor,lineDataAccessor:t.lineDataAccessor,xExtent:t.xExtent,yExtent:t.yExtent,invertY:t.invertY,axisExtent:t.axisExtent,yAxisExtent:b,sizeRange:t.sizeRange,xScaleType:t.xScaleType,yScaleType:t.yScaleType,scalePadding:t.scalePadding,binSize:t.binSize,normalize:t.normalize,baseline:t.baseline,stackOrder:t.stackOrder,boundsAccessor:t.boundsAccessor,boundsStyle:t.boundsStyle,band:t.band,y0Accessor:t.y0Accessor,areaGroups:t.areaGroups?t.areaGroups instanceof Set?t.areaGroups:new Set(t.areaGroups):void 0,curve:t.curve,gradientFill:_o(t.gradientFill),lineGradient:Po(t.lineGradient),semanticLineStops:t.semanticLineStops,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:x,themeCategorical:r.colors.categorical,themeSequential:r.colors.sequential,themeDiverging:r.colors.diverging,themeSemantic:Pr(r),customLayout:t.customLayout,layoutConfig:t.layoutConfig,layoutMargin:a,layoutSelection:t.layoutSelection,barColors:t.barColors,showValues:t.showValues,heatmapValueFormat:t.heatmapValueFormat,heatmapColorScale:t.heatmapColorScale,heatmapAggregation:t.heatmapAggregation,heatmapXBins:t.heatmapXBins,heatmapYBins:t.heatmapYBins,pointIdAccessor:t.pointIdAccessor,onLayoutError:t.onLayoutError},w=new Lx(v);t.data&&w.ingest({inserts:c,bounded:!0}),w.computeScene({width:f,height:g});let k=yu(t.backgroundGraphics,o,a,w.scales),A=yu(t.foregroundGraphics,o,a,w.scales);if(!w.scales){let e,n=t.annotations?Yc({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,annotationData:c,scales:{},layout:{width:f,height:g},theme:r,idPrefix:t._idPrefix,onRender:t=>{e=t}}):null;return i&&(i.evidence=Cl({frameType:"xy",width:o[0],height:o[1],marks:[],title:t.title,description:t.description,annotations:t.annotations,annotationRender:e,extraWarnings:w.scales?[]:["NO_SCALES"],margin:a})),rx.renderToStaticMarkup(fu(k||A||t.annotations?Fv(Tv,{children:[k,n,A]}):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:r,innerTransform:`translate(${a.left},${a.top})`,innerWidth:f,innerHeight:g,legend:p,idPrefix:t._idPrefix}))}let S,M=t._idPrefix,$=ql({nodes:w.scene,renderMode:t.renderMode,fallback:(e,i)=>Wl(e,i,M,t.hoverRadius??30)}),_=!w.xIsDate||t.xFormat||t.tickFormatTime?t:{...t,xFormat:ou(w.scales.x.domain().map(e=>e.valueOf()))},P=t.showGrid?function(e,t,i,r,o,n,a){let{grid:s}=Rr(i),l=r?r+"-":"",c=n?.find(e=>"bottom"===e.orient),u=n?.find(e=>"top"===e.orient),d=n?.find(e=>"left"===e.orient),h=n?.find(e=>"right"===e.orient),p=c??u,f=d??h,y=au({scale:e.x,axis:p,size:t.width,horizontal:!0,format:a?.xFormat||a?.tickFormatTime,axisExtent:o}),g=au({scale:e.y,axis:f,size:t.height,format:a?.yFormat||a?.tickFormatValue,axisExtent:o}),m=!1!==p?.grid,x=!1!==f?.grid,b=Uc(p?.gridStyle),v=Uc(f?.gridStyle),w=Kc(p?.gridStyle,{stroke:s,strokeWidth:.5}),k=Kc(f?.gridStyle,{stroke:s,strokeWidth:.5});return $v("g",{id:l+"grid",className:"semiotic-grid",opacity:.8,children:[m&&y.map((e,i)=>Mv("line",{x1:e.pixel,y1:0,x2:e.pixel,y2:t.height,...w,strokeDasharray:b??w.strokeDasharray},"gx-"+i)),x&&g.map((e,i)=>Mv("line",{x1:0,y1:e.pixel,x2:t.width,y2:e.pixel,...k,strokeDasharray:v??k.strokeDasharray},"gy-"+i))]})}(w.scales,{width:f,height:g},r,M,t.axisExtent,t.axes,_):null,I=$.map(e=>e.element),R=lu(t)+"-plot-clip",L=!1!==t.showAxes,C=L?function(t,i,r,o,n,a,s,l=!1){let c=Rr(o),u=r.legendPosition??"right",d=h(r.legendLayout,s?.leftAxis),p=h(r.legendLayout,s?.rightAxis),f=l&&"left"===u&&d>0?d:a?.left??r.margin?.left??40,y=l&&"right"===u&&p>0?p:a?.right??r.margin?.right??40,{xAxis:g,yAxis:m,xOrient:x,yOrient:b}=e(r.axes),v="top"===x?0:i.height,w="right"===b?i.width:0,k="top"===x?-1:1,A="right"===b?1:-1,S=au({scale:t.x,axis:g,size:i.width,horizontal:!0,format:r.xFormat||r.tickFormatTime,axisExtent:r.axisExtent}),M=au({scale:t.y,axis:m,size:i.height,format:r.yFormat||r.tickFormatValue,axisExtent:r.axisExtent}),$=!(!g?.autoRotate||!function(e){for(let t=1;e.length>t;t++){let i=e[t-1],r=e[t];if(Math.abs(r.pixel-i.pixel)<(nu(i.label)+nu(r.label))/2+8)return!0}return!1}(S)),_=Hc(S),P=Hc(M),I=g?.label??r.xLabel,R=m?.label??("right"===b?r.yLabelRight??r.yLabel:r.yLabel),L=Kc(g?.axisStyle,{stroke:c.border,strokeWidth:1}),C=Kc(m?.axisStyle,{stroke:c.border,strokeWidth:1}),T="right"===b?i.width+y-15:15-f;return Av("g",{id:(n?n+"-":"")+"axes",className:"stream-axes",children:[!1!==g?.visible&&Av("g",{className:"semiotic-axis semiotic-axis-"+x,"data-orient":x,children:[!1!==g?.baseline&&!g?.jaggedBase&&kv("line",{x1:0,y1:v,x2:i.width,y2:v,...L}),g?.jaggedBase&&kv("path",{d:Zc(x,i.width,i.height),fill:"none",...L}),S.map((e,t)=>{let i=iu(g?.landmarkTicks,e,t,S);return Av("g",{transform:`translate(${e.pixel},${v})`,children:[kv("line",{y2:5*k,...L}),Jc(e.label)?kv("text",{y:k*($?12:18),textAnchor:$?"end":Gc(g?.tickAnchor,e.pixel===_.min,e.pixel===_.max),fontWeight:i?600:400,fontSize:i?c.tickSize+1:c.tickSize,fill:c.textSecondary,fontFamily:c.fontFamily,transform:$?"top"===x?"rotate(45)":"rotate(-45)":void 0,children:e.label}):eu({label:e.label,x:-30,y:"top"===x?-30:6,textAlign:"center",fontSize:c.tickSize,fontFamily:c.fontFamily,color:c.textSecondary})]},"xtick-"+t)}),I&&kv("text",{x:i.width/2,y:"top"===x?-($?58:40):i.height+($?58:40),textAnchor:"middle",fontSize:c.labelSize,fill:c.text,fontFamily:c.fontFamily,children:I})]}),!1!==m?.visible&&Av("g",{className:"semiotic-axis semiotic-axis-"+b,"data-orient":b,children:[!1!==m?.baseline&&!m?.jaggedBase&&kv("line",{x1:w,y1:0,x2:w,y2:i.height,...C}),m?.jaggedBase&&kv("path",{d:Zc(b,i.width,i.height),fill:"none",...C}),M.map((e,t)=>{let i=iu(m?.landmarkTicks,e,t,M);return Av("g",{transform:`translate(${w},${e.pixel})`,children:[kv("line",{x2:5*A,...C}),Jc(e.label)?kv("text",{x:8*A,textAnchor:"right"===b?"start":"end",dominantBaseline:Vc(m?.tickAnchor,e.pixel===P.min,e.pixel===P.max),fontWeight:i?600:400,fontSize:i?c.tickSize+1:c.tickSize,fill:c.textSecondary,fontFamily:c.fontFamily,children:e.label}):eu({label:e.label,x:"right"===b?8:-68,y:-12,textAlign:"right"===b?"left":"right",fontSize:c.tickSize,fontFamily:c.fontFamily,color:c.textSecondary})]},"ytick-"+t)}),R&&kv("text",{x:T,y:i.height/2,textAnchor:"middle",fontSize:c.labelSize,fill:c.text,fontFamily:c.fontFamily,transform:`rotate(${"right"===b?90:-90}, ${T}, ${i.height/2})`,children:R})]})]})}(w.scales,{width:f,height:g},_,r,M,a,d,!!p):null,T=L?function(e){let{scales:t,layout:i,props:r,theme:o,leftAxis:n,rightAxis:a,margin:s,axisChrome:l,hasRenderedLegend:c}=e;if(!n||!a||!1===a.visible)return null;let u=Rr(o),d=au({scale:t.y,axis:a,size:i.height,format:r.yFormat||r.tickFormatValue,axisExtent:r.axisExtent}),p=Hc(d),f=a.label??r.yLabelRight,y=Kc(a.axisStyle,{stroke:u.border,strokeWidth:1}),g=r.legendPosition??"right",m=h(r.legendLayout,l?.rightAxis),x=i.width+(c&&"right"===g&&m>0?m:s.right)-15;return Cv("g",{className:"stream-axes semiotic-axis semiotic-axis-right","data-orient":"right",children:[!1!==a.baseline&&!a.jaggedBase&&Lv("line",{x1:i.width,y1:0,x2:i.width,y2:i.height,...y}),a.jaggedBase&&Lv("path",{d:Zc("right",i.width,i.height),fill:"none",...y}),d.map((e,t)=>{let r=iu(a.landmarkTicks,e,t,d);return Cv("g",{transform:`translate(${i.width},${e.pixel})`,children:[Lv("line",{x2:5,...y}),Jc(e.label)?Lv("text",{x:8,textAnchor:"start",dominantBaseline:Vc(a.tickAnchor,e.pixel===p.min,e.pixel===p.max),fontWeight:r?600:400,fontSize:r?u.tickSize+1:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):eu({label:e.label,x:8,y:-12,textAlign:"left",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"ytick-r-"+t)}),f&&Lv("text",{x:x,y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(90, ${x}, ${i.height/2})`,children:f})]})}({scales:w.scales,layout:{width:f,height:g},props:t,theme:r,leftAxis:t.axes?.find(e=>"left"===e.orient),rightAxis:t.axes?.find(e=>"right"===e.orient),margin:a,axisChrome:d,hasRenderedLegend:!!p}):null,O=t.annotations?Yc({annotations:t.annotations,autoPlaceAnnotations:t.autoPlaceAnnotations,svgAnnotationRules:t.svgAnnotationRules,annotationData:c,scales:{x:w.scales.x,y:w.scales.y},layout:{width:f,height:g},theme:r,xAccessor:"string"==typeof t.xAccessor?t.xAccessor:void 0,yAccessor:"string"==typeof t.yAccessor?t.yAccessor:void 0,idPrefix:M,onRender:e=>{S=e}}):null;i&&(i.evidence=Cl({frameType:"xy",width:o[0],height:o[1],marks:$.map(e=>e.node),title:t.title,description:t.description,annotations:t.annotations,annotationRender:S,xDomain:Ll(w.scales.x?.domain?.()),yDomain:Ll(w.scales.y?.domain?.()),legendItems:u.length>0?u.length:void 0,margin:a}));let F=t.svgPreRenderers&&w.scales?t.svgPreRenderers.map((e,t)=>{try{return Ov(ix.Fragment,{children:e(w.scene,w.scales,{width:f,height:g})},"pre-"+t)}catch{return null}}).filter(Boolean):null;return rx.renderToStaticMarkup(fu(Fv(Tv,{children:[k,F,P,Ov("defs",{children:Ov("clipPath",{id:R,children:Ov("rect",{x:0,y:0,width:f,height:g})})}),Ov("g",{clipPath:`url(#${R})`,children:I}),C,T,O,A,w.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:r,innerTransform:`translate(${a.left},${a.top})`,innerWidth:f,innerHeight:g,legend:p,idPrefix:t._idPrefix}))}function mu({machine:e,layout:t,runtime:i,downstreamSet:r,selectedSet:o,width:n,height:a,seed:s,reduced:l,onSelectTask:c}){let u=t.tasks.length?Math.min(...t.tasks.map(e=>e.y-e.height/2)):60,d=Math.max(20,u-12),h=Math.max(26,u-6);return Nv("svg",{"aria-hidden":"true",width:n,height:a,viewBox:`0 0 ${n} ${a}`,style:{position:"absolute",inset:0,overflow:"visible",pointerEvents:"none"},children:[Ev("defs",{children:Ev("filter",{id:"chain-shadow-"+s,x:"-20%",y:"-20%",width:"140%",height:"150%",children:Ev("feDropShadow",{dx:"0",dy:"2",stdDeviation:"2",floodOpacity:"0.2"})})}),e.lanes.map((e,i)=>{let r=t.tasks.filter(e=>e.laneIndex===i)[0]?.x??0;return Nv("g",{children:[Ev("line",{x1:r,x2:r,y1:h,y2:a-24,stroke:"var(--semiotic-grid, #d7dde0)",strokeWidth:1,strokeDasharray:"3 7"}),Ev("text",{x:r,y:d,textAnchor:"middle",fontSize:12,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e})]},e)}),t.routes.map(e=>{let t=i.delivered.has(e.edgeID),o=i.inFlight.has(e.edgeID),n=r.has(e.targetID)||r.has(e.sourceID),a=e.points.map(e=>`${e.x},${e.y}`).join(" ");return Ev("polyline",{points:a,fill:"none",stroke:n?"var(--semiotic-selection-color, #e08a1e)":t?"var(--semiotic-success, #2b8a66)":"var(--semiotic-grid, #aeb8bd)",strokeWidth:n?4:o?3:2,strokeOpacity:t||o||n?.95:.48,strokeLinecap:"round",strokeLinejoin:"round"},e.edgeID)}),t.sockets.map(e=>{let t=i.delivered.has(e.edgeID);return Nv("g",{children:[Ev("circle",{cx:e.x,cy:e.y,r:e.radius+2,fill:"var(--semiotic-bg, #fff)",stroke:"var(--semiotic-text, #243039)",strokeWidth:1.5}),t&&Ev("circle",{cx:e.x,cy:e.y,r:e.radius-.5,fill:"var(--semiotic-success, #2b8a66)"})]},e.id)}),e.nodes.map(e=>{let n=t.taskByID.get(e.id);if(!n)return null;let a=i.completed.has(e.id),u=i.blockers.has(e.id),d=i.previewTaskID===e.id,h=o.has(e.id)||d,p=r.has(e.id),f=function(e,t){return t.completed.has(e.id)?"var(--semiotic-success, #2b8a66)":t.blockers.has(e.id)?"var(--semiotic-error, #c64035)":"in-progress"===e.status?"var(--semiotic-warning, #d18a22)":t.armed.has(e.id)?"var(--semiotic-primary, #2474a6)":"var(--semiotic-text-secondary, #75818a)"}(e,i),y=n.x-n.width/2,g=n.y-n.height/2,m=Math.max(2,n.height*e.progress);return Nv("g",{children:[Nv("g",{style:{transform:`rotate(${a?76:0}deg)`,transformBox:"fill-box",transformOrigin:"50% 100%",transition:l?"none":"transform 520ms cubic-bezier(.2,.8,.25,1)",filter:"url(#chain-shadow-"+s+")"},children:[Ev("rect",{x:y,y:g,width:n.width,height:n.height,rx:e.milestone?12:4,fill:"var(--semiotic-bg, #fff)",stroke:h||p?"var(--semiotic-selection-color, #e08a1e)":f,strokeWidth:h?4:p?3:2}),Ev("rect",{x:y+3,y:g+n.height-m+1,width:n.width-6,height:Math.max(0,m-4),rx:2,fill:f,opacity:a?.86:.46})]}),u&&Nv("g",{opacity:d?.28:1,children:[Ev("line",{x1:y-8,x2:y+14,y1:n.y+9,y2:n.y-9,stroke:"var(--semiotic-error, #c64035)",strokeWidth:7,strokeLinecap:"round"}),Ev("circle",{cx:y-8,cy:n.y+9,r:3,fill:"var(--semiotic-error, #c64035)"})]}),Nv("g",{onPointerDown:()=>c(e.id),style:{cursor:"pointer",pointerEvents:"auto"},children:[Ev("rect",{x:y,y:g,width:n.width,height:n.height,fill:"transparent"}),Ev("text",{x:n.x,y:n.y-4,textAnchor:"middle",fontSize:10.5,fontWeight:700,fill:"var(--semiotic-text, #243039)",children:e.label.length>24?e.label.slice(0,22)+"…":e.label}),Nv("text",{x:n.x,y:n.y+12,textAnchor:"middle",fontSize:9.5,fill:"var(--semiotic-text-secondary, #5f6b72)",children:[Math.round(100*e.progress),"% · ",a?"done":u?"blocked":i.armed.has(e.id)?"ready":"waiting"]})]})]},e.id)})]})}function xu(e,t=0){if(e instanceof Date)return e.getTime();let i=Number(e);return Number.isFinite(i)?i:t}function bu(e){if(null==e.completionTime)return null;let t=xu(e.completionTime,NaN);return Number.isFinite(t)?t:null}function vu(e,t,i,r){let o=new Set;for(let n of e.nodes){let a=e.incoming.get(n.id)??[];(r.has(n.id)||!i.has(n.id)&&a.every(e=>t.has(e.id)))&&o.add(n.id)}return o}function wu(e,t,i={}){let r=new Set,o=[...e.get(t)??[]];for(let t=0;o.length>t;t++){let i=o[t];r.has(i)||(r.add(i),o.push(...e.get(i)??[]))}return i.includeStart&&r.add(t),r}function ku(e,t,i){return function(e,t,i){if(null!=e)return"function"==typeof e?e(t,i):"object"==typeof e&&null!==e&&"constant"in e?e.constant:t[e]}(i,e,t)}function Au(e,t){return t>e?-1:e>t?1:0}function Su(e,t){return`dependency:${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Mu(e,t){return`socket:${encodeURIComponent(e)}:${t}`}function $u(e){let t=Number(e);return Number.isFinite(t)?Math.max(0,Math.min(1,t)):0}function _u(e,t,i={}){let r=new Set(i.completedTaskIDs??[]),o=[...wu(function(e,t){let i=new Map;for(let t of e)i.set(t.id,new Set);for(let e of t)i.has(e.source)||i.set(e.source,new Set),i.has(e.target)||i.set(e.target,new Set),i.get(e.source).add(e.target);return i}(e.nodes,e.edges.map(e=>({source:e.sourceID,target:e.targetID}))),t)].map(t=>e.byID.get(t)).filter(e=>null!=e).filter(e=>!(i.isComplete?i.isComplete(e):r.has(e.id)||"done"===e.status)).sort((e,t)=>e.index-t.index),n=Array.from(new Set(o.map(e=>e.lane)));return{blockerID:t,downstreamTaskCount:o.length,affectedLaneCount:n.length,downstreamTaskIDs:o.map(e=>e.id),affectedLanes:n}}function Pu(e,t,i,r,o){return{__composite:{data:e,colorBy:t,colorScheme:i,common:r,rest:o}}}function Iu(e){return e.__composite}function Ru(e,t){return"number"==typeof e&&Number.isFinite(e)?e:t}function Lu(e,t){return Math.max(1,Math.floor(Ru(e,t)))}function Cu(e,t,i,r){return e.replace(/^<svg\b/,`<svg x="${t}" y="${i}" data-semiotic-composite-part="${r}"`)}function Tu(e,t){for(let i of e){let e=i?.[t];if(Array.isArray(e)&&2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1])return e}}function Ou(e,t){return("function"==typeof t?t(e):e[t])+""}function Fu(e,t,i){let{scales:r,config:o,getConnector:n,getO:a}=e;if(!n||!r)return[];let s=[],{projection:l}=r,c=new Map;for(let e of t){if("point"!==e.type&&"rect"!==e.type)continue;let t=e.datum;if(!t)continue;let i,r,o=n(t);o&&("point"===e.type?(i=e.x,r=e.y):(i=e.x+e.w/2,r=e.y+("vertical"===l?0:e.h/2)),c.has(o)||c.set(o,[]),c.get(o).push({x:i,y:r,datum:t,category:a(t)}))}let u=new Map(r.o.domain().map((e,t)=>[e,t])),d=o.connectorStyle,h={stroke:e.config.themeSemantic?.border||e.config.themeSemantic?.secondary||"#999",strokeWidth:1,opacity:.5},p=(e,t,i)=>{var r;s.push({type:"connector",x1:e.x,y1:e.y,x2:t.x,y2:t.y,style:(r=e.datum,"function"==typeof d?d(r):d||h),datum:e.datum,group:i})};for(let[e,t]of c)if(t.length>=2){t.sort((e,t)=>(u.get(e.category)??-1)-(u.get(t.category)??-1));for(let i=0;t.length-1>i;i++)p(t[i],t[i+1],e);"radial"===l&&t.length>=3&&p(t[t.length-1],t[0],e)}return s}function Du(e,t,i){let r="function"==typeof e?e(i?t.w:t.h):e;return"number"==typeof r&&Number.isFinite(r)?Math.max(0,r):0}function Eu(e){let t=e.getSymbol;return t?al(t,e.config.symbolMap):null}function Nu(e,t,i,r,o,n,a){e.push(t?{type:"symbol",x:r,y:o,size:Math.PI*n*n,symbolType:t(i),style:a,datum:i}:{type:"point",x:r,y:o,r:n,style:a,datum:i})}function zu(e,t){let{columns:i,config:r,resolvePieceStyle:o}=e,n=[],a=Math.min(t.width,t.height)/2-4,s="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,d=Object.values(i),h=d.some(e=>{let t=e.pieceData[0];return t&&("number"==typeof t._pct||"number"==typeof t._pctStart||null!=t._roundedEnds)}),p=u&&!h&&d.length>1&&(r.cornerRadius??0)>0;for(let e=0;d.length>e;e++){let t=d[e],i=t.pieceData[0],u="number"==typeof i?._pctStart?i._pctStart:t.pctStart,h=l+u*c,f=l+(u+("number"==typeof i?._pct?i._pct:t.pct))*c,y=o(t.pieceData[0],t.name),g=0===e,m=e===d.length-1,x={type:"wedge",cx:0,cy:0,innerRadius:s,outerRadius:a,startAngle:h,endAngle:f,...r.cornerRadius&&{cornerRadius:r.cornerRadius},style:y,datum:i?._nonInteractive?null:t.pieceData,category:t.name};i?._roundedEnds?x.roundedEnds=i._roundedEnds:p&&(x.roundedEnds={start:g,end:m}),i?._gradientBand&&(x._gradientBand=i._gradientBand),n.push(x)}return n}function Bu(e,t,i){return{...e[0],...i,category:t,data:e}}function ju(e){let t=e.length,i=e[0],r=e[t-1];return{n:t,min:i,q1:Jv(e,.25)??i,median:Jv(e,.5)??(i+r)/2,q3:Jv(e,.75)??r,max:r,mean:e.reduce((e,t)=>e+t,0)/t}}function Wu(e,t,i,r,o){let n=Array(o).fill(0);for(let a of e)t>a||a>i||n[Math.min(Math.floor((a-t)/r),o-1)]++;return n}function Yu(e){let{innerRadius:t,outerRadius:i,startAngle:r,endAngle:o}=e,n=0>=t;if(0>=(e.cornerRadius??0)||!e.roundStart&&!e.roundEnd){if(n){let e=bw(i,r),t=bw(i,o);return`M0,0 L${e.x},${e.y} A${i},${i} 0 ${o-r>Math.PI?1:0} 1 ${t.x},${t.y} Z`}let e=bw(i,r),a=bw(i,o),s=bw(t,o),l=bw(t,r),c=o-r>Math.PI?1:0;return`M${e.x},${e.y} A${i},${i} 0 ${c} 1 ${a.x},${a.y} L${s.x},${s.y} A${t},${t} 0 ${c} 0 ${l.x},${l.y} Z`}let a=Math.max(0,Math.min(e.cornerRadius??0,(i-t)/2));if(0===a)return Yu({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});let s=Math.asin(Math.min(1,a/Math.max(1e-9,i-a))),l=n?0:Math.asin(Math.min(1,a/Math.max(1e-9,t+a))),c=o-r,u=e.roundStart&&e.roundEnd?c/2:c,d=!!e.roundStart&&u>s,h=!!e.roundEnd&&u>s;if(!d&&!h)return Yu({...e,cornerRadius:0,roundStart:!1,roundEnd:!1});let p=r+(d?s:0),f=o-(h?s:0),y=r+(d?l:0),g=o-(h?l:0),m=bw(i,p),x=bw(i,f),b=(i-a)*Math.cos(s),v=bw(b,r),w=bw(b,o),k=n?null:bw(t,g),A=n?null:bw(t,y),S=n?0:(t+a)*Math.cos(l),M=n?null:bw(S,r),$=n?null:bw(S,o),_=f-p>Math.PI?1:0,P=n?0:g-y>Math.PI?1:0,I="";if(d)I+=`M${v.x},${v.y}`,I+=` A${a},${a} 0 0 1 ${m.x},${m.y}`;else{let e=bw(i,r);I+=`M${e.x},${e.y}`}if(h)I+=` A${i},${i} 0 ${_} 1 ${x.x},${x.y}`,I+=` A${a},${a} 0 0 1 ${w.x},${w.y}`;else{let e=bw(i,o);I+=` A${i},${i} 0 ${_} 1 ${e.x},${e.y}`}if(n)I+=" L0,0";else{if(h)I+=` L${$.x},${$.y}`,I+=` A${a},${a} 0 0 1 ${k.x},${k.y}`;else{let e=bw(t,o);I+=` L${e.x},${e.y}`}if(d)I+=` A${t},${t} 0 ${P} 0 ${A.x},${A.y}`,I+=` A${a},${a} 0 0 1 ${M.x},${M.y}`;else{let e=bw(t,r);I+=` A${t},${t} 0 ${P} 0 ${e.x},${e.y}`}}return I+=" Z",I}function qu(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 Xu(e,t){let i=e.datum;if(!i)return null;let r=[],o=i.__funnelStepLabel,n=Number(i.__funnelStepLabelX),a=Number(i.__funnelStepLabelY),s=Number(i.__funnelRowWidth);"string"==typeof o&&Number.isFinite(n)&&Number.isFinite(a)&&(!Number.isFinite(s)||s>=8.4*o.length+16)&&r.push(vw("text",{x:n,y:a+3,textAnchor:"middle",dominantBaseline:"hanging",fontSize:14,fontWeight:"bold",fill:"#fff",fontFamily:"var(--semiotic-font-family, sans-serif)",stroke:"rgba(0,0,0,0.6)",strokeWidth:3,paintOrder:"stroke",children:o},t+"-funnel-step"));let l=Number(i.__funnelValue),c=Number(i.__funnelValueLabelX),u=Number(i.__funnelValueLabelY),d=Number(i.__funnelBarW);if(Number.isFinite(l)&&0!==l&&Number.isFinite(c)&&Number.isFinite(u)&&d>=60){let e=Number(i.__funnelPercent),o=!0!==i.__funnelIsFirstStep&&Number.isFinite(e)?`${qu(l)} (${.05>Math.abs(e-Math.round(e))?Math.round(e):e.toFixed(1)}%)`:qu(l);7.8*o.length+16>d&&(o=qu(l)),d>=7.8*o.length+16&&r.push(vw("text",{x:c,y:u+22,textAnchor:"middle",dominantBaseline:"hanging",fontSize:13,fontWeight:"bold",fill:"#fff",fontFamily:"var(--semiotic-font-family, sans-serif)",stroke:"rgba(0,0,0,0.5)",strokeWidth:3,paintOrder:"stroke",children:o},t+"-funnel-value"))}return r.length?vw("g",{children:r},t+"-funnel-labels"):null}function Gu(e){return"connector"===e.node.type}function Vu(e,t,i,r){if(2>e.length)return null;let o=e[0].node,n=o.style.fill;if(!n||"none"===n)return null;let a=Ol(`${t?t+"-":""}connector-${i}-${r}-hatch`),s=fr(n)?gr(n,a):null,l=[`${o.x1},${o.y1}`,...e.map(({node:e})=>`${e.x2},${e.y2}`)].join(" ");return Bl(Aw(gw.Fragment,{children:[s&&kw("defs",{children:s}),kw("polygon",{points:l,fill:s?`url(#${a})`:Tl(n,"#999"),opacity:o.style.fillOpacity??o.style.opacity??.3,"data-semiotic-connector-fill":o.group||"_default"})]}),o,`ordinal-connector-fill-${i}-${r}`)}function Hu(e,t,i){let r=new Map;for(let t of e){if(!Gu(t))continue;let e=t.node.group||"_default",i=r.get(e);i?i.push(t):r.set(e,[t])}if(0===r.size)return;let o=Array.from(r.values()).map((e,r)=>Aw("g",{children:[Vu(e,t,i,r),e.map(e=>e.element)]},`ordinal-connectors-${i}-${r}`)),n=e[0],a=Gu(n)?null:n.element;for(let e of r.values())for(let t of e)t.element=null;n.element=Aw(gw.Fragment,{children:[o,a]},"ordinal-connector-run-"+i)}function Uu(e){let t=ql({nodes:e.nodes,renderMode:e.renderMode,fallback:(t,i)=>function(e,t,i){return Bl(function(e,t,i){let r=("category"in e?e.category:void 0)||("group"in e?e.group:void 0)||"",o=i=>`ord-${e.type}-${r}-${t}-${i}`,n=`ord-${e.type}-${r}-${t}`;switch(e.type){case"rect":{let t,i,r=e,o=Ol(n)+"-grad",a=function(e,t){let i=e.fillGradient;if(!i||"object"!=typeof i)return null;let r=e.x,o=e.y,n=e.x,a=e.y+e.h;"bottom"===e.roundedEdge?(o=e.y+e.h,a=e.y):"right"===e.roundedEdge?(r=e.x+e.w,o=e.y,n=e.x,a=e.y):"left"===e.roundedEdge&&(r=e.x,o=e.y,n=e.x+e.w,a=e.y);let s=Dl(i.stops,Tl(e.style.fill));return s?Ab("linearGradient",{id:t,gradientUnits:"userSpaceOnUse",x1:r,y1:o,x2:n,y2:a,children:s}):null}(r,o);if(a)i=`url(#${o})`;else if(fr(r.style.fill)){let e=Ol(n)+"-hatch";t=gr(r.style.fill,e),i=`url(#${e})`}else i=Tl(r.style.fill);let s=a||t?ww("defs",{children:[a,t]}):null;if(r.cornerRadii&&wl(r.cornerRadii)){let e=function(e){let{x:t,y:i,w:r,h:o}=e,{tl:n,tr:a,br:s,bl:l}=kl(e),c=`M${t+n},${i}`;return c+=` L${t+r-a},${i}`,a>0&&(c+=` A${a},${a} 0 0 1 ${t+r},${i+a}`),c+=` L${t+r},${i+o-s}`,s>0&&(c+=` A${s},${s} 0 0 1 ${t+r-s},${i+o}`),c+=` L${t+l},${i+o}`,l>0&&(c+=` A${l},${l} 0 0 1 ${t},${i+o-l}`),c+=` L${t},${i+n}`,n>0&&(c+=` A${n},${n} 0 0 1 ${t+n},${i}`),c+=" Z",c}(r);return ww(mw.Fragment,{children:[s,vw("path",{d:e,fill:i,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},n)}if(r.roundedTop&&r.roundedTop>0){let e,t=Math.min(r.roundedTop,r.w/2,r.h/2),{x:o,y:a,w:l,h:c}=r;switch(r.roundedEdge){case"right":e=`M${o},${a} L${o+l-t},${a} A${t},${t} 0 0 1 ${o+l},${a+t} L${o+l},${a+c-t} A${t},${t} 0 0 1 ${o+l-t},${a+c} L${o},${a+c} Z`;break;case"left":e=`M${o+l},${a} L${o+t},${a} A${t},${t} 0 0 0 ${o},${a+t} L${o},${a+c-t} A${t},${t} 0 0 0 ${o+t},${a+c} L${o+l},${a+c} Z`;break;case"bottom":e=`M${o},${a} L${o+l},${a} L${o+l},${a+c-t} A${t},${t} 0 0 1 ${o+l-t},${a+c} L${o+t},${a+c} A${t},${t} 0 0 1 ${o},${a+c-t} Z`;break;default:e=`M${o},${a+c} L${o},${a+t} A${t},${t} 0 0 1 ${o+t},${a} L${o+l-t},${a} A${t},${t} 0 0 1 ${o+l},${a+t} L${o+l},${a+c} Z`}return ww(mw.Fragment,{children:[s,vw("path",{d:e,fill:i,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth})]},n)}return ww(mw.Fragment,{children:[s,vw("rect",{x:r.x,y:r.y,width:r.w,height:r.h,fill:i,opacity:r.style.opacity,stroke:r.style.stroke,strokeWidth:r.style.strokeWidth}),Xu(r,n)]},n)}case"point":{let t=e;return vw("circle",{cx:t.x,cy:t.y,r:t.r,fill:Tl(t.style.fill),opacity:t.style.opacity??t.style.fillOpacity??.8,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},n)}case"symbol":return El(e,t,i);case"glyph":return Fl(e,e.x,e.y,`${i??""}ord-glyph-${e.pointId??t}`);case"wedge":{let r,o=e;if(o._gradientBand&&o._gradientBand.colors.length>0){let e=Ol(`${i?i+"-":""}gauge-grad-${o.category||n}-${t}`),{clipPath:r,slices:a}=function(e){let t=Yu({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,cornerRadius:e.cornerRadius,roundStart:e.roundStart,roundEnd:e.roundEnd}),i=[],r=e.colors;if(r.length>0){let t=(e.endAngle-e.startAngle)/r.length;for(let o=0;r.length>o;o++)i.push({d:Yu({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle+o*t,endAngle:e.endAngle}),color:r[o]})}return{clipPath:t,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 ww("g",{transform:`translate(${o.cx},${o.cy})`,opacity:o.style.opacity,fillOpacity:o.style.fillOpacity,children:[vw("defs",{children:vw("clipPath",{id:e,children:vw("path",{d:r})})}),vw("g",{clipPath:`url(#${e})`,children:a.map((e,t)=>vw("path",{d:e.d,fill:Tl(e.color)},t))}),o.style.stroke&&"none"!==o.style.stroke&&vw("path",{d:r,fill:"none",stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},n)}if(o.roundedEnds)r=Yu({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds.start,roundEnd:o.roundedEnds.end});else{let e=xw().innerRadius(o.innerRadius).outerRadius(o.outerRadius).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2);o.cornerRadius&&e.cornerRadius(o.cornerRadius),r=e(Mb)||""}return vw("path",{d:r,transform:`translate(${o.cx},${o.cy})`,fill:Tl(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},n)}case"boxplot":{let t=e,i=t.columnWidth/2,r=t.style.strokeWidth??1;return ww("g","vertical"===t.projection?{children:[vw("line",{x1:t.x,y1:t.minPos,x2:t.x,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:r}),vw("rect",{x:t.x-i,y:Math.min(t.q1Pos,t.q3Pos),width:t.columnWidth,height:Math.abs(t.q3Pos-t.q1Pos),fill:Tl(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:r}),vw("line",{x1:t.x-i,y1:t.medianPos,x2:t.x+i,y2:t.medianPos,stroke:t.style.stroke||"#333",strokeWidth:2*r}),vw("line",{x1:t.x-.5*i,y1:t.minPos,x2:t.x+.5*i,y2:t.minPos,stroke:t.style.stroke||"#333",strokeWidth:r}),vw("line",{x1:t.x-.5*i,y1:t.maxPos,x2:t.x+.5*i,y2:t.maxPos,stroke:t.style.stroke||"#333",strokeWidth:r})]}:{children:[vw("line",{x1:t.minPos,y1:t.y,x2:t.maxPos,y2:t.y,stroke:t.style.stroke||"#333",strokeWidth:r}),vw("rect",{x:Math.min(t.q1Pos,t.q3Pos),y:t.y-i,width:Math.abs(t.q3Pos-t.q1Pos),height:t.columnWidth,fill:Tl(t.style.fill),fillOpacity:t.style.fillOpacity??.6,stroke:t.style.stroke||"#333",strokeWidth:r}),vw("line",{x1:t.medianPos,y1:t.y-i,x2:t.medianPos,y2:t.y+i,stroke:t.style.stroke||"#333",strokeWidth:2*r}),vw("line",{x1:t.minPos,y1:t.y-.5*i,x2:t.minPos,y2:t.y+.5*i,stroke:t.style.stroke||"#333",strokeWidth:r}),vw("line",{x1:t.maxPos,y1:t.y-.5*i,x2:t.maxPos,y2:t.y+.5*i,stroke:t.style.stroke||"#333",strokeWidth:r})]},n)}case"violin":{let t=e,i=[vw("path",{d:t.pathString,transform:t.translateX||t.translateY?`translate(${t.translateX},${t.translateY})`:void 0,fill:Tl(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){let e=t.bounds,r=e.x+e.width/2,n=e.y+e.height/2;t.iqrLine.isVertical?i.push(vw("line",{x1:r,y1:t.iqrLine.q1Pos,x2:r,y2:t.iqrLine.q3Pos,stroke:t.style.stroke||"#333",strokeWidth:2},o("iqr")),vw("circle",{cx:r,cy:t.iqrLine.medianPos,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},o("med"))):i.push(vw("line",{x1:t.iqrLine.q1Pos,y1:n,x2:t.iqrLine.q3Pos,y2:n,stroke:t.style.stroke||"#333",strokeWidth:2},o("iqr")),vw("circle",{cx:t.iqrLine.medianPos,cy:n,r:3,fill:"white",stroke:t.style.stroke||"#333",strokeWidth:1},o("med")))}return vw("g",{children:i},n)}case"connector":{let t=e,i=t.style.fill&&"none"!==t.style.fill?Tl(t.style.fill,"var(--semiotic-border, #999)"):"var(--semiotic-border, #999)";return vw("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||i,strokeWidth:t.style.strokeWidth??1,opacity:t.style.opacity??.5},n)}case"trapezoid":{let t=e,i=t.points.map(e=>`${e[0]},${e[1]}`).join(" ");return vw("polygon",{points:i,fill:Tl(t.style.fill,"#999"),opacity:t.style.opacity,stroke:t.style.stroke,strokeWidth:t.style.strokeWidth},n)}default:return null}}(e,t,i),e,"ordinal-cursor-"+t)}(t,i,e.idPrefix)}),i=0;for(let r=0;t.length>r;){if(t[r].renderedByBackend){r++;continue}let o=r+1;for(;t.length>o&&!t[o].renderedByBackend;)o++;Hu(t.slice(r,o),e.idPrefix,i++),r=o}return t}function Ku(e,i){let r=Ir(e.theme),o=e.size||[500,400],a=s({..._v,...e.margin},e.title),l=n(e.title),c=bo(e.data),u=e.showLegend?Jl(c,e.colorAccessor||e.stackBy||e.groupBy):[],d=function(e){let t=e.projection??"vertical",i=!1!==e.showAxes&&"radial"!==t;return{hasAxis:i,hasAxisLabel:i&&("horizontal"===t?e.hasValueLabel:e.hasCategoryLabel),leftAxis:{hasAxis:i,hasAxisLabel:i&&("horizontal"===t?e.hasCategoryLabel:e.hasValueLabel)}}}({showAxes:e.showAxes,projection:e.projection,hasCategoryLabel:!(!e.categoryLabel&&!e.oLabel),hasValueLabel:!(!e.valueLabel&&!e.rLabel)});hu(a,{props:{...e,axisChrome:d},categories:u,theme:r,size:o,hasTitle:l});let p=pu({props:{...e,axisChrome:d},categories:u,theme:r,size:o,margin:a,hasTitle:l}),f=o[0]-a.left-a.right,y=o[1]-a.top-a.bottom,g=e.projection||"vertical",m="radial"===g,x=e.colorScheme||r.colors.categorical,b={chartType:e.chartType,windowSize:e.windowSize??1e4,windowMode:e.windowMode??"sliding",extentPadding:e.extentPadding??.05,projection:g,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:_o(e.gradientFill),symbolAccessor:e.symbolAccessor,symbolMap:e.symbolMap,multiAxis:e.multiAxis,baselinePadding:e.baselinePadding,trackFill:e.trackFill,connectorOpacity:e.connectorOpacity,showLabels:e.showLabels,colorScheme:x,themeCategorical:r.colors.categorical,themeSemantic:Pr(r),customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutMargin:a,layoutSelection:e.layoutSelection,barColors:e.barColors},v=new yw(b);e.data&&v.ingest({inserts:c,bounded:!0}),v.computeScene({width:f,height:y});let w=yu(e.backgroundGraphics,o,a,v.scales),k=yu(e.foregroundGraphics,o,a,v.scales);if(!v.scales){let t,n=e.annotations?Yc({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:c,scales:{},layout:{width:f,height:y},theme:r,projection:g,idPrefix:e._idPrefix,onRender:e=>{t=e}}):null;return i&&(i.evidence=Cl({frameType:"ordinal",width:o[0],height:o[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,annotationRender:t,extraWarnings:v.scales?[]:["NO_SCALES"],margin:a})),Uv.renderToStaticMarkup(fu(w||k||e.annotations?Pw($w,{children:[w,n,k,v.customLayoutOverlays]}):null,{width:o[0],height:o[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:r,innerTransform:`translate(${a.left},${a.top})`,innerWidth:f,innerHeight:y,legend:p,idPrefix:e._idPrefix}))}let A=e._idPrefix,S=e.showGrid?function(e,t,i,r,o,n){let a=e.scales;if(!a||"radial"===a.projection)return null;let{grid:s}=Rr(i),l=r?r+"-":"",c="vertical"===a.projection,u=n??Qc(a.r,5,o);return kv("g",c?{id:l+"grid",className:"semiotic-grid",opacity:.8,children:u.map((e,i)=>{let r=a.r(e);return kv("line",{x1:0,y1:r,x2:t.width,y2:r,stroke:s,strokeWidth:.5},"gr-"+i)})}:{id:l+"grid",className:"semiotic-grid",opacity:.8,children:u.map((e,i)=>{let r=a.r(e);return kv("line",{x1:r,y1:0,x2:r,y2:t.height,stroke:s,strokeWidth:.5},"gr-"+i)})})}(v,{width:f,height:y},r,A,e.axisExtent,e.rTickValues):null,M=null;if(v.scene.some(e=>"rect"===e.type&&e.datum?.__barFunnelIsDropoff)){let t=lu(e),i=new Set;for(let e of v.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&i.add("string"==typeof e.style.fill?e.style.fill:"#666");M=Array.from(i).map((e,i)=>function(e){let{id:t,background:i="transparent",stroke:r="#000",lineWidth:o=1.5,spacing:n=6,angle:a=45}=e,s=Math.max(8,Math.ceil(2*n));return Mw("pattern",{id:t,width:s,height:s,patternUnits:"userSpaceOnUse",patternTransform:0!==a?`rotate(${a})`:void 0,children:[i&&"transparent"!==i&&Sw("rect",{width:s,height:s,fill:i}),Sw("line",{x1:0,y1:0,x2:0,y2:s,stroke:r,strokeWidth:o}),Sw("line",{x1:n,y1:0,x2:n,y2:s,stroke:r,strokeWidth:o})]},t)}({id:`funnel-hatch-${t}-${i}`,background:e,stroke:"transparent"===r.colors.background?"#fff":r.colors.background,lineWidth:1.5,spacing:5,angle:45}));let o=new Map;Array.from(i).forEach((e,i)=>o.set(e,`funnel-hatch-${t}-${i}`));for(let e of v.scene)"rect"===e.type&&e.datum?.__barFunnelIsDropoff&&(e.style={...e.style,fill:`url(#${o.get("string"==typeof e.style.fill?e.style.fill:"#666")})`})}let $,_=Uu({nodes:v.scene,renderMode:e.renderMode,idPrefix:A}),P=_.map(e=>e.element),I=!1!==e.showAxes?function(e,i,r,o,n,a,s,l=!1){let c=e.scales;if(!c||"radial"===c.projection)return null;let u=Rr(o),d="vertical"===c.projection,p=e.columns,f=r.categoryFormat||r.oFormat,y=r.valueFormat||r.rFormat,g=r.categoryLabel||r.oLabel,m=r.valueLabel||r.rLabel,x=r.legendPosition??"right",b=h(r.legendLayout,s?.leftAxis),v=l&&"left"===x&&b>0?b:a?.left??r.margin?.left??40,w=Object.values(p).map((e,t)=>({pixel:e.middle,label:f?f(e.name,t):e.name})),k=r.rTickValues??Qc(c.r,5,r.axisExtent),A=y||t(k),S=k.map(e=>({pixel:c.r(e),label:A(e)}));return Pw("g",d?{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[_w("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:u.border,strokeWidth:1}),w.map((e,t)=>Pw("g",{transform:`translate(${e.pixel},${i.height})`,children:[_w("line",{y2:5,stroke:u.border,strokeWidth:1}),Jc(e.label)?_w("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):eu({label:e.label,x:-30,y:6,textAlign:"center",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"oxtick-"+t)),g&&_w("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:g}),_w("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:u.border,strokeWidth:1}),S.map((e,t)=>Pw("g",{transform:`translate(0,${e.pixel})`,children:[_w("line",{x2:-5,stroke:u.border,strokeWidth:1}),_w("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"oytick-"+t)),m&&_w("text",{x:15-v,y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-v}, ${i.height/2})`,children:m})]}:{id:(n?n+"-":"")+"axes",className:"ordinal-axes",children:[_w("line",{x1:0,y1:i.height,x2:i.width,y2:i.height,stroke:u.border,strokeWidth:1}),S.map((e,t)=>Pw("g",{transform:`translate(${e.pixel},${i.height})`,children:[_w("line",{y2:5,stroke:u.border,strokeWidth:1}),_w("text",{y:18,textAnchor:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label})]},"oxtick-"+t)),m&&_w("text",{x:i.width/2,y:i.height+40,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,children:m}),_w("line",{x1:0,y1:0,x2:0,y2:i.height,stroke:u.border,strokeWidth:1}),w.map((e,t)=>Pw("g",{transform:`translate(0,${e.pixel})`,children:[_w("line",{x2:-5,stroke:u.border,strokeWidth:1}),Jc(e.label)?_w("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fontSize:u.tickSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:e.label}):eu({label:e.label,x:-68,y:-12,textAlign:"right",fontSize:u.tickSize,fontFamily:u.fontFamily,color:u.textSecondary})]},"oytick-"+t)),g&&_w("text",{x:15-v,y:i.height/2,textAnchor:"middle",fontSize:u.labelSize,fill:u.text,fontFamily:u.fontFamily,transform:`rotate(-90, ${15-v}, ${i.height/2})`,children:g})]})}(v,{width:f,height:y},e,r,A,a,d,!!p):null,R=e.annotations?Yc({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,annotationData:c,scales:{o:v.scales.o,r:v.scales.r,y:"vertical"===v.scales.projection?v.scales.r:void 0},layout:{width:f,height:y},theme:r,projection:g,xAccessor:"string"==typeof e.oAccessor?e.oAccessor:void 0,yAccessor:"string"==typeof e.rAccessor?e.rAccessor:void 0,idPrefix:A,onRender:e=>{$=e}}):null;if(i){let t=v.scales.o?.domain?.();i.evidence=Cl({frameType:"ordinal",width:o[0],height:o[1],marks:_.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:$,yDomain:Ll(v.scales.r?.domain?.()),categories:Array.isArray(t)?t.map(String):void 0,margin:a})}let L=m&&e.centerContent?function(e,t,i){if(!Gv.isValidElement(e)||!Hv.has(e.type))return null;let r=e,o="text"===r.type?Gv.cloneElement(r,{x:r.props.x??0,y:r.props.y??0,textAnchor:r.props.textAnchor??"middle",dominantBaseline:r.props.dominantBaseline??"middle"}):r;return Vv("g",{className:"semiotic-radial-center-content",transform:`translate(${t},${i})`,pointerEvents:"none",children:o})}(e.centerContent,a.left+f/2,a.top+y/2):null,C=m&&e.centerContent?L??_w("foreignObject",{x:a.left,y:a.top,width:f,height:y,pointerEvents:"none",children:_w("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},children:e.centerContent})}):null,T=Pw($w,{children:[S,P,I,R,k,v.customLayoutOverlays]});return Uv.renderToStaticMarkup(fu(Pw($w,m?{children:[w?_w("g",{transform:`translate(${-f/2},${-y/2})`,children:w}):null,T]}:{children:[w,T]}),{width:o[0],height:o[1],className:"stream-ordinal-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:r,innerTransform:m?`translate(${a.left+f/2},${a.top+y/2})`:`translate(${a.left},${a.top})`,innerWidth:f,innerHeight:y,legend:p,defs:M,outerElements:C,idPrefix:e._idPrefix}))}function Zu(e,t){Rw[e]=t}function Qu(e,t){var i=e.get(t);if(!i)throw Error("missing: "+t);return i}function Ju(e,t){function i(e){c[e]=!1,u.hasOwnProperty(e)&&Object.keys(u[e]).forEach(function(t){delete u[e][t],c[t]&&i(t)})}function r(e){var t,n,s=!1;for(l.push(e),c[e]=!0,t=0;d[e].length>t;t++)(n=d[e][t])===a?(o(a,l),s=!0):c[n]||(s=r(n));if(s)i(e);else for(t=0;d[e].length>t;t++){var h=u[n=d[e][t]];h||(u[n]=h={}),h[n]=!0}return l.pop(),s}function o(e,i){var r=[].concat(i).concat(e);t?t(r):s.push(r)}function n(t){!function(t){for(var i=0;e.length>i;i++)(t>i||!e[i])&&(e[i]=[]),e[i]=e[i].filter(function(e){return e>=t})}(t);for(var i,r=function(e){function t(t){var i=[t],c=[t];for(r[t]=o[t]=d,n[t]=!0,d+=1;c.length>0;){var u=e[t=c[c.length-1]];if(u.length>a[t]){for(var f=a[t];u.length>f;++f){var y=u[f];if(0>r[y]){r[y]=o[y]=d,n[y]=!0,d+=1,i.push(y),c.push(y);break}n[y]&&(o[t]=0|Math.min(o[t],o[y])),s[y]>=0&&l[t].push(s[y])}a[t]=f}else{if(o[t]===r[t]){var g=[],m=[],x=0;for(f=i.length-1;f>=0;--f){var b=i[f];if(n[b]=!1,g.push(b),m.push(l[b]),x+=l[b].length,s[b]=h.length,b===t){i.length=f;break}}h.push(g);var v=Array(x);for(f=0;m.length>f;f++)for(var w=0;m[f].length>w;w++)v[--x]=m[f][w];p.push(v)}c.pop()}}}for(var i=e.length,r=Array(i),o=Array(i),n=Array(i),a=Array(i),s=Array(i),l=Array(i),c=0;i>c;++c)r[c]=-1,o[c]=0,n[c]=!1,a[c]=0,s[c]=-1,l[c]=[];var u,d=0,h=[],p=[];for(c=0;i>c;++c)0>r[c]&&t(c);for(c=0;p.length>c;c++){var f=p[c];if(0!==f.length){f.sort(function(e,t){return e-t}),u=[f[0]];for(var y=1;f.length>y;y++)f[y]!==f[y-1]&&u.push(f[y]);p[c]=u}}return{components:h,adjacencyList:p}}(e),o=r.components.filter(function(e){return e.length>1}),n=1/0,a=0;o.length>a;a++)for(var s=0;o[a].length>s;s++)n>o[a][s]&&(n=o[a][s],i=a);var l=o[i];return!!l&&{leastVertex:n,adjList:e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})})}}var a,s=[],l=[],c=[],u={},d=[];a=0;for(var h=e.length;h>a;){var p=n(a);if(a=p.leastVertex,d=p.adjList){for(var f=0;d.length>f;f++)for(var y=0;d[f].length>y;y++){var g=d[f][y];c[+g]=!1,u[g]={}}r(a),a+=1}else a=h}if(!t)return s}function ed(e){return e.y0-e.y1>0?"up":"down"}function td(e,t){return t(e.source)==t(e.target)}function id(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var i=0;return e.target.targetLinks.forEach(function(e){i=e.circular?i+1:i}),!(t>1||i>1)}function rd(e){return e.target.x0-e.source.x1}function od(e,t){var i=ad(e),r=rd(t)/Math.tan(i);return"up"==ed(e)?e.y1-r:e.y1+r}function nd(e,t){var i=ad(e),r=rd(t)/Math.tan(i);return"up"==ed(e)?e.y1+r:e.y1-r}function ad(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function sd(e,t){return t(e)}function ld(e){return ud(e.source)}function cd(e){return ud(e.target)}function ud(e){return(e.y0+e.y1)/2}function dd(e){return e.virtual?0:e.value}function hd(e,t){var i=0;e.sourceLinks.forEach(function(e){i=e.circular&&!td(e,t)?i+1:i});var r=0;return e.targetLinks.forEach(function(e){r=e.circular&&!td(e,t)?r+1:r}),i+r}function pd(e){return e.target.depth}function fd(e,t){return e.sourceLinks.length?e.depth:t-1}function yd(e,t){return e.y0-t.y0}function gd(e,t){return t.y0-e.y0}function md(e,t){return e.y1-t.y1}function xd(e,t){return t.y1-e.y1}function bd(e,t){return wd(e.source,t.source)||e.index-t.index}function vd(e,t){return wd(e.target,t.target)||e.index-t.index}function wd(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function kd(e,t){return Ad(e)==Ad(t)?"bottom"==e.circularLinkType?gd(e,t):yd(e,t):Ad(t)-Ad(e)}function Ad(e){return e.target.column-e.source.column}function Sd(e,t){return Md(e)==Md(t)}function Md(e){return e.y0-e.y1>0?"up":"down"}function $d(e,t,i,r,o){let n=e;var a=Math.max(8,.15*(n.y1-n.y0));n.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,a))});var s=Lw(n.links,function(e){return e.source.y0});n.links.forEach(function(e){e.circular&&(e.circularPathData={})});var l=n.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}),_d(n.links.filter(function(e){return"top"==e.circularLinkType}),t,i),_d(n.links.filter(function(e){return"bottom"==e.circularLinkType}),t,i),n.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,td(e,t)&&id(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 a=e.source.column,l=e.circularLinkType,c=n.links.filter(function(e){return e.source.column==a&&e.circularLinkType==l});c.sort("bottom"==e.circularLinkType?gd:yd);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*i+u),u+=t._circularWidth||t.width}),a=e.target.column,(c=n.links.filter(function(e){return e.target.column==a&&e.circularLinkType==l})).sort("bottom"==e.circularLinkType?xd:md),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*i+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(n.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=s-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,i=e.y0,r=e.target.x0,o=e.y1,n=(t+r)/2;return"M"+t+","+i+"C"+n+","+i+" "+n+","+o+" "+r+","+o}(e)}),n}function _d(e,t,i){e.sort(kd);var r=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,o){var n=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(td(e,t)&&id(e))e.circularPathData.verticalBuffer=n+e._circularWidth/2;else{for(var a=0;r.length>a;a++){var s=r[a];if(s!==e&&s.circularPathData&&void 0!==s.circularPathData.verticalBuffer&&Pd(e,s)){var l=s.circularPathData.verticalBuffer+(s._circularWidth||s.width)/2+i;n=l>n?l:n}}e.circularPathData.verticalBuffer=n+e._circularWidth/2}}),e}function Pd(e,t){return!(t.target.column>e.source.column||e.target.column>t.source.column)}function Id(e){return function(){return e}}function Rd(e){return e.index}function Ld(e){return e.nodes}function Cd(e){return e.links}function Td(e,t,i){var r=Ew(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,n){var a=o.length;if(t)o.sort(t);else if(n>0){var s=new Map;o.forEach(function(e,t){var i,r,o,n=(r=0,o=0,(i=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=ud(e.source)*t,r+=t}}),i.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;o+=ud(e.target)*t,r+=t}}),r>0?o/r:NaN);s.set(e,{bc:n,idx:t})}),o.sort(function(e,t){var i=s.get(e),r=s.get(t),o=i.bc,n=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||"bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(o)||isNaN(n)?isNaN(o)?isNaN(n)?i.idx-r.idx:1:-1:o-n})}else o.sort(function(e,t){return e.circularLinkType==t.circularLinkType?hd(t,i)-hd(e,i):"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==a||0==t.depth&&1==a?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==hd(t,i)?(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)/a*o,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-a/2+o,t.y1=t.y0+t.value*e.ky)})})}function Od(e,t,i,r,o,n){function a(t,i){var r=l.length;l.forEach(function(o){var n=o.length,a=o[0].depth;o.forEach(function(o){var s;if(o.sourceLinks.length||o.targetLinks.length)if(o.partOfCycle&&hd(o,i)>0){var l=Fw(o.sourceLinks,cd),c=Fw(o.targetLinks,ld),u=l&&c?(l+c)/2:l||c;if(u){var d=(u-ud(o))*t*.3;o.y0+=d,o.y1+=d}}else if(0==a&&1==n)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(a==r-1&&1==n)o.y0=e.y1/2-(s=o.y1-o.y0)/2,o.y1=e.y1/2+s/2;else if(1==o.targetLinks.length&&1==o.targetLinks[0].source.sourceLinks.length)s=o.y1-o.y0,o.y0=o.targetLinks[0].source.y0,o.y1=o.y0+s;else{var h=Fw(o.sourceLinks,cd),p=Fw(o.targetLinks,ld),f=((h&&p?(h+p)/2:h||p)-ud(o))*t;o.y0+=f,o.y1+=f}})})}function s(){l.forEach(function(i){var n,a,s,l=e.y0,c=i.length;for(i.sort(t||wd),s=0;c>s;++s)(a=l-(n=i[s]).y0)>0&&(n.y0+=a,n.y1+=a),l=n.y1+r;if((a=l-r-e.y1)>0)for(l=n.y0-=a,n.y1-=a,s=c-2;s>=0;--s)(a=(n=i[s]).y1+o-l)>0&&(n.y0-=a,n.y1-=a),l=n.y0})}var l=Ew(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});s();for(var c=1,u=n;u>0;--u)a(c*=.99,i),s()}function Fd(e){e.nodes.forEach(function(e){e.sourceLinks.sort(vd),e.targetLinks.sort(bd)}),e.nodes.forEach(function(e){var t=e.y0,i=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=i+e.width/2,i+=e.width)})})}function Dd(){function e(){var e={nodes:f.apply(null,arguments),links:y.apply(null,arguments)};return function(e){e.x0=t,e.y0=i,e.x1=r,e.y1=o,e.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var i=function(e,t){var i=new Map;return Dw(e,t).forEach(function(e,t){i.set(t,e[0])}),i}(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=Qu(i,r)),"object"!=typeof o&&(o=e.target=Qu(i,o)),r.sourceLinks.push(e),o.targetLinks.push(e)})}(e,l),function(e,t){var i=0;if(null==t){for(var r=[],o=0;e.links.length>o;o++){var n=e.links[o],a=n.source.index,s=n.target.index;r[a]||(r[a]=[]),r[s]||(r[s]=[]),-1===r[a].indexOf(s)&&r[a].push(s)}var l=Ju(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=i++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=i++)})}(e,u),function(e,t){var i=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>i?"top":"bottom","top"==o.circularLinkType?i++:r++,e.nodes.forEach(function(e){(sd(e,t)==sd(o.source,t)||sd(e,t)==sd(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),td(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(e,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(Ow(e.sourceLinks,dd),Ow(e.targetLinks,dd)),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)})})}(e),function(e,t,i){var r,o,n;if(null!=t){e.nodes.sort(function(e,i){return t(e)<t(i)?-1:1});var a=0,s=t(e.nodes[0]);e.nodes.forEach(function(e){a=t(e)==s?a:a+1,s=t(e)==s?s:t(e),e.column=a})}for(r=e.nodes,o=[],n=0;r.length;++n,r=o,o=[])r.forEach(function(e){e.depth=n,e.sourceLinks.forEach(function(e){0>o.indexOf(e.target)&&!e.circular&&o.push(e.target)})});for(r=e.nodes,o=[],n=0;r.length;++n,r=o,o=[])r.forEach(function(e){e.height=n,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?i(e,n):e.column})}(e,u,c);var f=a;if(null!==s){var y=Ew(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),g=Tw(y,function(e){return e.length});g>1&&(f=Math.max(1,(o-i)*s/(g-1)))}(function(e,t,i){var r=Ew(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=Cw(r,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/Ow(t,function(e){return e.value})});e.ky=o,e.links.forEach(function(t){t.width=t.value*e.ky});var n=Tw(e.nodes,function(e){return e.column});e.nodes.forEach(n>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-i)/n),t.x1=t.x0+i}:function(t){t.x0=e.x0,t.x1=t.x0+i})})(e,f,n),Td(e,u,l),Od(e,u,l,f,f,d),Fd(e),$d(e,l,h,p,8),Td(e,u,l),Od(e,u,l,f,f,d),Fd(e),$d(e,l,h,p,8),function(e,t){let i=e;i.nodes.forEach(function(e){e.y+(e.y1-e.y0)>i.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-i.y1));var r=i.links.filter(function(i){return sd(i.source,t)==sd(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(!Sd(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var i=od(t,e);return e.y1-i}if(t.target.column>e.target.column)return od(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 n=e.y0;r.forEach(function(e){e.y0=n+e.width/2,n+=e.width}),r.forEach(function(t,i){if("bottom"==t.circularLinkType){for(var n=i+1,a=0;o>n;n++)a+=r[n].width;t.y0=e.y1-a-t.width/2}})})}(e,l),function(e,t){let i=e;i.nodes.forEach(function(e){var r=i.links.filter(function(i){return sd(i.target,t)==sd(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(!Sd(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var i=nd(t,e);return e.y0-i}if(t.source.column>e.source.column)return nd(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 n=e.y0;r.forEach(function(e){e.y1=n+e.width/2,n+=e.width}),r.forEach(function(t,i){if("bottom"==t.circularLinkType){for(var n=i+1,a=0;o>n;n++)a+=r[n].width;t.y1=e.y1-a-t.width/2}})})}(e,l),function(e){var t=e.nodes,i=e.links,r=!1,o=!1;if(i.forEach(function(e){"top"==e.circularLinkType?r=!0:"bottom"==e.circularLinkType&&(o=!0)}),0==r||0==o){let r=function(t){return(t-n)/(a-n)*(e.y1-e.y0)+e.y0};var n=Cw(t,function(e){return e.y0}),a=Tw(t,function(e){return e.y1}),s=(e.y1-e.y0)/(a-n);1>s?(t.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1)}),i.forEach(function(e){e.y0=r(e.y0),e.y1=r(e.y1),e.width=e.width*s})):t.forEach(function(e){var t=e.y1-e.y0,i=r(e.y0)-e.y0;e.y0=r(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+i}),e.targetLinks.forEach(function(e){e.y1=e.y1+i})})}}(e),$d(e,l,h,p,8)}(e),e}var t=0,i=0,r=1,o=1,n=24,a=8,s=null,l=Rd,c=fd,u=void 0,d=32,h=2,p=10,f=Ld,y=Cd;return e.update=function(e){return Fd(e),$d(e,l,h,p,8),e},e.nodeWidth=function(t){return arguments.length?(n=+t,e):n},e.nodePadding=function(t){return arguments.length?(a=+t,e):a},e.nodePaddingRatio=function(t){return arguments.length?(s=+t,e):s},e.nodes=function(t){return arguments.length?(f="function"==typeof t?t:Id(t),e):f},e.links=function(t){return arguments.length?(y="function"==typeof t?t:Id(t),e):y},e.nodeId=function(t){return arguments.length?(l="function"==typeof t?t:Id(t),e):l},e.nodeAlign=function(t){return arguments.length?(c="function"==typeof t?t:Id(t),e):c},e.nodeSort=function(t){return arguments.length?(u=t,e):u},e.iterations=function(t){return arguments.length?(d=+t,e):d},e.circularLinkGap=function(t){return arguments.length?(h=+t,e):h},e.extent=function(n){return arguments.length?(t=+n[0][0],i=+n[0][1],r=+n[1][0],o=+n[1][1],e):[[t,i],[r,o]]},e.size=function(n){return arguments.length?(t=i=0,r=+n[0],o=+n[1],e):[r-t,o-i]},e}function Ed(e){let t=e.sankeyWidth/2,i=(e._circularWidth??e.sankeyWidth)/2,r=e.circularPathData;if(!r||"down"===e.direction)return null;if(e._circularStub){let i=r.sourceX,o=r.sourceY,n=r.targetX,a=r.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;let s=Math.max(15,Math.min(40,.33*(r.rightFullExtent-i))),l=Math.max(15,Math.min(40,.33*(n-r.leftFullExtent)));return`M${i},${o-t}L${i+s},${o-t}L${i+s},${o+t}L${i},${o+t}ZM${n},${a-t}L${n-l},${a-t}L${n-l},${a+t}L${n},${a+t}Z`}let o=r.sourceX,n=r.sourceY,a=r.targetX,s=r.targetY,l=r.rightFullExtent,c=r.leftFullExtent,u=r.verticalFullExtent,d="bottom"===e.circularLinkType?1:-1,h=Math.max(4,Math.min(i,15));return`M${o},${n-d*t}L${l},${n-d*t}L${l+i},${n-d*t+d*h}L${l+i},${u+d*i-d*h}L${l+i-h},${u+d*i}L${c-i+h},${u+d*i}L${c-i},${u+d*i-d*h}L${c-i},${s-d*t+d*h}L${c-i+h},${s-d*t}L${a},${s-d*t}L${a},${s+d*t}L${c+i},${s+d*t}L${c+i},${u-d*i}L${l-i},${u-d*i}L${l-i},${n+d*t}L${o},${n+d*t}Z`}function Nd(e,t){if("production"===process.env.NODE_ENV||!e||!e.data||"object"!=typeof e.data)return e;let i=Yw.get(e);if(i){let e=i.get(t);if(e)return e}else i=new Map,Yw.set(e,i);let r=new Proxy(e,{get(e,i,r){if("string"==typeof i&&!(i in e)&&e.data&&i in e.data){let e=`${t}:${i}`;Ww.has(e)||(Ww.add(e),console.warn(`[Semiotic] "${t}" 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(e,i,r)}});return i.set(t,r),r}function zd(e,t,i){if(i.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;let r=t||[5,20],o=[];for(let t of i){let i=t.data?.[e];"number"==typeof i&&o.push(i)}if(0===o.length)return()=>r[0];let[n,a]=no(o);if(n===a)return()=>(r[0]+r[1])/2;let s=Jw().domain([n,a]).range(r).clamp(!0);return t=>{let i=t.data?.[e];return null==i||"number"!=typeof i?r[0]:s(i)}}function Bd(e,t,i){let r=[];for(let o of t){let t=Za(o.source),n=Za(o.target),a=null;if(t===e?a=n:n===e&&(a=t),a){let e=i.get(a);e&&(0!==e.x||0!==e.y)&&r.push({x:e.x,y:e.y})}}return r}function jd(e){let t=0;for(let i=0;e.length>i;i++)t=(t<<5)-t+e.charCodeAt(i)|0;return Math.abs(t)}function Wd(e,t,i){let r=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!r)return e;let o=[],n=0;for(;r.length>n;){let e=r[n];if("M"===e||"L"===e||"C"===e||"Q"===e)for(o.push(e),n++;r.length>n&&!isNaN(Number(r[n]));)o.push(Number(r[n])+t+""),n++,r.length>n&&!isNaN(Number(r[n]))&&(o.push(Number(r[n])+i+""),n++);else if("A"===e)for(o.push(e),n++;r.length>n&&!isNaN(Number(r[n]));)o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&o.push(r[n++]),r.length>n&&(o.push(Number(r[n])+t+""),n++),r.length>n&&(o.push(Number(r[n])+i+""),n++);else"Z"===e||"z"===e?(o.push(e),n++):(o.push(r[n]),n++)}return o.join(" ")}function Yd(e){let[t,i,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)]}let 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*i+.114*r>150?"#222":"#fff"}function qd(e,t,i){let 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-"+i}function Xd(e){if(!e)return null;if("function"==typeof e){let t=e;return e=>t(e.data??e)}return t=>t.data?.[e]||t[e]||t.id}function Gd(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:pk}function Vd(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 Hd(e,t,i,r,o){if("horizontal"===o){let o=(e+i)/2;return`M ${e},${t} C ${o},${t} ${o},${r} ${i},${r}`}if("radial"===o){let o=(e+i)/2;return`M ${e},${t} Q ${o},${t} ${o},${(t+r)/2} T ${i},${r}`}{let o=(t+r)/2;return`M ${e},${t} C ${e},${o} ${i},${o} ${i},${r}`}}function Ud(e,t,i){let r=i.treeOrientation||"vertical";if("radial"===r){let i=t.x,r=t.y;e.x=r*Math.cos(i-Math.PI/2),e.y=r*Math.sin(i-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 Kd(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 Zd(e,t){let i=t.r??0;e.x=t.x,e.y=t.y,e.x0=t.x-i,e.x1=t.x+i,e.y0=t.y-i,e.y1=t.y+i,e.width=2*i,e.height=2*i,e.__radius=i}function Qd(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"u">typeof performance?performance.now():Date.now()},e.__orbitState=t),t}function Jd(e){let t=e.id??e.datum?.id??e.datum?.data?.id??e.datum?.data?.name;return null==t?void 0:t+""}function eh(e){if("glyph"===e.type&&e.glyph&&"number"==typeof e.size){let t=e.cx??e.x,i=e.cy??e.y;if("number"!=typeof t||"number"!=typeof i)return null;let r=hl(e.glyph,e.size);return{x:t+r.centerDx,y:i+r.centerDy,r:Math.max(1,r.radius)}}let t=e.cx??(null!=e.x&&null!=e.w?e.x+e.w/2:e.x),i=e.cy??(null!=e.y&&null!=e.h?e.y+e.h/2:e.y);return"number"!=typeof t||"number"!=typeof i?null:{x:t,y:i,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):"number"==typeof e.size?Math.max(1,nl(e.size)):Math.max(1,e.w??0,e.h??0)/2}}function th(e){if(!e)return;let t=[];for(let i of e){let e=eh(i);e&&t.push({pointId:Jd(i),...e})}return t}function ih(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function rh(e){return e.map(e=>{let t=e.datum&&"object"==typeof e.datum?e.datum:{},i=t.data&&"object"==typeof t.data?t.data:t,r="cx"in e?e.cx:e.x+e.w/2,o="cy"in e?e.cy:e.y+e.h/2;return{...i,...null==i.id&&null!=e.id?{id:e.id}:{},x:r,y:o}})}function oh(e,t){let i=Ir(e.theme),r=e.chartType||"force",o=e.size||[500,500],a=function(e){return Rv.has(e)?Iv:Pv}(r),l=s({...a,...e.margin},e.title),c=n(e.title),u=e.showLegend?(()=>{let t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;if(!t)return[];let o=bo(e.nodes||[]);if(o.length>0)return Jl(o,t);if(Ak.has(r)&&e.data)return Jl(za(e.data,e.childrenAccessor||"children"),t);let n=Array.isArray(e.edges)?bo(e.edges):[];if(0===n.length)return[];let a=ih(e.sourceAccessor,"source"),s=ih(e.targetAccessor,"target");return Jl(Array.from(new Set(n.flatMap(e=>[a(e),s(e)]).filter(e=>null!=e).map(String))).map(e=>({id:e})),t)})():[];hu(l,{props:e,categories:u,theme:i,size:o,hasTitle:c});let d=pu({props:e,categories:u,theme:i,size:o,margin:l,hasTitle:c}),h=o[0]-l.left-l.right,p=o[1]-l.top-l.bottom,f=yu(e.backgroundGraphics,o,l,null),y=yu(e.foregroundGraphics,o,l,null),g=()=>{let r,n=e=>Number(e),a=e.annotations?Yc({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{x:n,y:n},layout:{width:h,height:p},theme:i,frameType:"network",idPrefix:e._idPrefix,onRender:e=>{r=e}}):null;return t&&(t.evidence=(t=>Cl({frameType:"network",width:o[0],height:o[1],marks:[],title:e.title,description:e.description,annotations:e.annotations,annotationRender:t,nodeCount:0,edgeCount:0,margin:l}))(r)),Iw.renderToStaticMarkup(fu(f||y||e.annotations?kk(wk,{children:[f,a,y]}):null,{width:o[0],height:o[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${l.left},${l.top})`,innerWidth:h,innerHeight:p,legend:d,idPrefix:e._idPrefix}))},m=function(e){return Rw[e]}(r);if(!m&&!e.customNetworkLayout)throw Error(`No layout plugin found for chart type: "${r}". Supported types: force, sankey, chord, tree, cluster, treemap, circlepack, partition, orbit.`);let x,b,v={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||i.colors.categorical,edgeColorBy:e.edgeColorBy,edgeOpacity:e.edgeOpacity,colorByDepth:e.colorByDepth,nodeSize:e.nodeSize,nodeSizeRange:e.nodeSizeRange,orbitMode:e.orbitMode,orbitSize:e.orbitSize,orbitSpeed:e.orbitSpeed,orbitRevolution:e.orbitRevolution,orbitRevolutionStyle:e.orbitRevolutionStyle,orbitEccentricity:e.orbitEccentricity,orbitShowRings:e.orbitShowRings,orbitAnimated:!1,customNetworkLayout:e.customNetworkLayout,layoutConfig:e.layoutConfig};if(Ak.has(r)){let t=e.data||e.edges;if(!t||Array.isArray(t))return g();v.__hierarchyRoot=t,x=[],b=[]}else{let t=bo(e.nodes||[]),i=Array.isArray(e.edges)?bo(e.edges):[];if(0===t.length&&0===i.length)return g();if(b=function(e,t){let i=ih(t.sourceAccessor,"source"),r=ih(t.targetAccessor,"target"),o=ih(t.valueAccessor,"value");return e.map((e,t)=>{let n=Number(o(e)),a=i(e)+"",s=r(e)+"";return{source:a,target:s,value:Number.isFinite(n)?n:1,y0:0,y1:0,sankeyWidth:0,data:e,_edgeKey:`${a}\0${s}\0${t}`}})}(i,v),0===t.length&&b.length>0){let e=new Set;for(let t of b){let i=su(t.source),r=su(t.target);i&&e.add(i),r&&e.add(r)}x=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 x=function(e,t){let i=ih(t.nodeIDAccessor,"id");return e.map(e=>({id:i(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}))}(t,v)}let w=[],k=[],A=[],S=null,M=null;if(v.customNetworkLayout){let t=v.colorScheme,r=ui(t,i.colors.categorical,hf),o=di(r,t),n={nodes:x,edges:b,dimensions:{width:h,height:p,plot:{x:0,y:0,width:h,height:p}},theme:{semantic:i.colors,categorical:[...r]},resolveColor:o,config:v.layoutConfig??{},selection:e.layoutSelection??null},a=v.customNetworkLayout(n);w=a.sceneNodes??[],k=a.sceneEdges??[],function({nodes:e,edges:t,restyle:i,restyleEdge:r,baseStyles:o,selection:n}){if(i)for(let t of e){let e=o.get(t)??t.style,r=i(t,n);t.style=r?{...e,...r}:e}if(r)for(let e of t){let t=o.get(e)??e.style,i=r(e,n);e.style=i?{...t,...i}:t}}({nodes:w,edges:k,restyle:a.restyle,restyleEdge:a.restyleEdge,selection:e.layoutSelection??null,baseStyles:new WeakMap}),A=a.labels??[],S=a.backgrounds??null,M=a.overlays??null}else if(m){m.computeLayout(x,b,v,[h,p]);let e=m.buildScene(x,b,v,[h,p]);w=e.sceneNodes,k=e.sceneEdges,A=e.labels}let $=Rr(i);for(let e of A)e.fill||(e.fill=$.text);let _,P=ql({nodes:k,renderMode:e.renderMode,fallback:(e,t)=>function(e,t){return Bl(function(e,t){switch(e.type){case"line":return bk("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":{let i=e,r=`net-bezier-${t}-hatch`,o=fr(i.style.fill)?gr(i.style.fill,r):void 0;return vk(mk.Fragment,{children:[o&&bk("defs",{children:o}),bk("path",{d:i.pathD,fill:o?`url(#${r})`:Tl(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-edge-"+t)}case"ribbon":{let i=e,r=`net-ribbon-${t}-hatch`,o=fr(i.style.fill)?gr(i.style.fill,r):void 0;return vk(mk.Fragment,{children:[o&&bk("defs",{children:o}),bk("path",{d:i.pathD,fill:o?`url(#${r})`:Tl(i.style.fill,"#999"),fillOpacity:i.style.fillOpacity,stroke:i.style.stroke||"none",strokeWidth:i.style.strokeWidth,opacity:i.style.opacity})]},"net-edge-"+t)}case"curved":{let i=e;return bk("path",{d:i.pathD,fill:Tl(i.style.fill,"none"),stroke:i.style.stroke||"#999",strokeWidth:i.style.strokeWidth??1,opacity:i.style.opacity},"net-edge-"+t)}default:return null}}(e,t),e,"network-edge-cursor-"+t)}(e,t)}),I=ql({nodes:w,renderMode:e.renderMode,fallback:(e,t)=>function(e,t){return Bl(function(e,t){switch(e.type){case"circle":{let i=e,r=fr(i.style.fill)?gr(i.style.fill,`net-circle-${t}-hatch`):void 0;return vk(mk.Fragment,{children:[r&&bk("defs",{children:r}),bk("circle",{cx:i.cx,cy:i.cy,r:i.r,fill:r?`url(#net-circle-${t}-hatch)`:Tl(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity})]},"net-circle-"+t)}case"rect":{let i=e,r=fr(i.style.fill)?gr(i.style.fill,`net-rect-${t}-hatch`):void 0;return vk(mk.Fragment,{children:[r&&bk("defs",{children:r}),bk("rect",{x:i.x,y:i.y,width:i.w,height:i.h,fill:r?`url(#net-rect-${t}-hatch)`:Tl(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity})]},"net-rect-"+t)}case"arc":{let i=e,r=xk().innerRadius(i.innerR).outerRadius(i.outerR).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2)(Mb)||"",o=fr(i.style.fill)?gr(i.style.fill,`net-arc-${t}-hatch`):void 0;return vk(mk.Fragment,{children:[o&&bk("defs",{children:o}),bk("path",{d:r,transform:`translate(${i.cx},${i.cy})`,fill:o?`url(#net-arc-${t}-hatch)`:Tl(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity})]},"net-arc-"+t)}case"symbol":{let i=e,r=ol(i.symbolType,i.size,i.path);return bk("path",{d:r,transform:i.rotation?`translate(${i.cx},${i.cy}) rotate(${180*i.rotation/Math.PI})`:`translate(${i.cx},${i.cy})`,fill:i.style.fill?Tl(i.style.fill):"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,fillOpacity:i.style.fillOpacity,strokeOpacity:i.style.strokeOpacity,opacity:i.style.opacity},"net-symbol-"+t)}case"glyph":return Fl(e,e.cx,e.cy,"net-glyph-"+(e.id??t));default:return null}}(e,t),e,"network-node-cursor-"+t)}(e,t)}),R=P.map(e=>e.element),L=I.map(e=>e.element),C=A.map((e,t)=>function(e,t){return bk("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),T=e=>Number(e),O=e.annotations?Yc({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{x:T,y:T},layout:{width:h,height:p},theme:i,frameType:"network",annotationData:rh(w),pointNodes:th(w),idPrefix:e._idPrefix,onRender:e=>{_=e}}):null;return t&&(t.evidence=Cl({frameType:"network",width:o[0],height:o[1],marks:[...I.map(({node:e})=>({type:"node:"+(e.type??"node")})),...P.map(({node:e})=>({type:"edge:"+(e.type??"edge")}))],title:e.title,description:e.description,annotations:e.annotations,annotationRender:_,nodeCount:I.length,edgeCount:P.length,margin:l})),Iw.renderToStaticMarkup(fu(kk(wk,{children:[f,S,R,L,C,O,y,M]}),{width:o[0],height:o[1],className:"stream-network-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${l.left},${l.top})`,innerWidth:h,innerHeight:p,legend:d,idPrefix:e._idPrefix}))}function nh(e,t){return e?"function"==typeof e?e:t=>t[e]:e=>e[t]}function ah(e){return e?"function"==typeof e?e:t=>t[e]:e=>e.coordinates||e.data||[]}function sh(e,t,i){return e?"function"==typeof e?{...i,...e(t)}:{...i,...e}:{...i}}function lh(e,t){if(2>e.length)return[e];let i=.4*t,r=[],o=[e[0]];for(let t=1;e.length>t;t++){let n=e[t];Math.abs(n[0]-e[t-1][0])>i?(o.length>=2&&r.push(o),o=[n]):o.push(n)}return o.length>=2&&r.push(o),r}function ch(e,t,i=24){let r=t[0]-e[0],o=t[1]-e[1],n=Math.sqrt(r*r+o*o);if(0===n)return[e,t];let a=-o/n,s=r/n,l=Math.min(.3*n,80),c=(e[0]+t[0])/2+a*l,u=(e[1]+t[1])/2+s*l,d=[];for(let r=0;i>=r;r++){let o=r/i,n=1-o;d.push([n*n*e[0]+2*n*o*c+o*o*t[0],n*n*e[1]+2*n*o*u+o*o*t[1]])}return d}function uh(e,t){if(2>e.length)return e;let i=t/2+1,r=[];for(let t=0;e.length>t;t++){let o,n,a=e[t];0===t?(o=e[1][0]-a[0],n=e[1][1]-a[1]):t===e.length-1?(o=a[0]-e[t-1][0],n=a[1]-e[t-1][1]):(o=e[t+1][0]-e[t-1][0],n=e[t+1][1]-e[t-1][1]);let s=Math.sqrt(o*o+n*n)||1;r.push([a[0]+n/s*i,a[1]+-o/s*i])}return r}function dh(e,t,i,r,o){let n=t[0]-e[0],a=t[1]-e[1],s=Math.sqrt(n*n+a*a);if(0===s)return[e,t];let l=a/s,c=-n/s,u=o/2+1;return[[e[0]+l*u,e[1]+c*u],[t[0]+l*u,t[1]+c*u]]}function hh(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+""}.`)}function ph(e){if(!e)return;let t=[];for(let i of e)if("point"===i.type)t.push(i);else if("glyph"===i.type){let e=i,r=hl(e.glyph,e.size);t.push({pointId:e.pointId,x:e.x+r.centerDx,y:e.y+r.centerDy,r:r.radius})}return t}function fh({bottomMargin:e,costLabel:t,layout:{cx:i,cy:r,maxCost:o,availableRadius:n,layout:a},ringStyle:s,ringValues:l,showNorth:c,showRingLabels:u,showRings:d}){let h="strip"===a,p={stroke:h?"var(--semiotic-border, #999)":"#999",strokeWidth:h?1:.8,strokeDasharray:h?"none":"4,3",labelColor:"var(--semiotic-text-secondary, #777)",labelSize:h?8:10,...s};return iA("g",h?{children:[tA("line",{x1:i,y1:r,x2:i+n,y2:r,stroke:p.stroke,strokeWidth:p.strokeWidth,strokeLinecap:"round",opacity:.85}),tA("line",{x1:i,y1:r-3.5,x2:i,y2:r+3.5,stroke:p.stroke,strokeWidth:p.strokeWidth,opacity:.9}),d&&l.map(a=>{let s=i+(o>0?a/o*n:0);return iA("g",{children:[tA("line",{x1:s,y1:r-2.5,x2:s,y2:r+2.5,stroke:p.stroke,strokeWidth:.9,opacity:.65}),u&&iA("text",{x:s,y:r+Math.min(10,(e??2)+8),textAnchor:"middle",fontSize:p.labelSize,fill:p.labelColor,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:[a,t?" "+t:""]})]},a)})]}:{children:[l.map(e=>{let a=e/o*n;return iA("g",{children:[tA("circle",{cx:i,cy:r,r:a,fill:"none",stroke:p.stroke,strokeWidth:p.strokeWidth,strokeDasharray:p.strokeDasharray,opacity:.5}),u&&iA("text",{x:i+a+3,y:r-2,fontSize:p.labelSize,fill:p.labelColor,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:[e,t?" "+t:""]})]},e)}),c&&iA("g",{transform:"translate(24, 24)",children:[tA("circle",{r:16,fill:"white",fillOpacity:.85,stroke:"#bbb",strokeWidth:.8}),tA("path",{d:"M0,-11 L3,-3 L1,-4 L1,7 L-1,7 L-1,-4 L-3,-3 Z",fill:"#555",stroke:"none"}),tA("text",{y:-12,textAnchor:"middle",fontSize:7,fontWeight:700,fill:"#555",fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",children:"N"}),tA("line",{x1:11,y1:0,x2:13,y2:0,stroke:"#bbb",strokeWidth:.8}),tA("line",{x1:-11,y1:0,x2:-13,y2:0,stroke:"#bbb",strokeWidth:.8}),tA("line",{x1:0,y1:11,x2:0,y2:13,stroke:"#bbb",strokeWidth:.8})]})]})}function yh(e,t){let i=Ir(e.theme),r=e.size||[e.width||600,e.height||400],o=s({top:10,right:10,bottom:10,left:10,...e.margin},e.title),a=n(e.title),l=Array.isArray(e.areas)?bo(e.areas):e.areas,c=bo(e.points),u=bo(e.lines),d=e.showLegend?(()=>{let t="string"==typeof(i=e.colorBy)||"function"==typeof i?e.colorBy:void 0;var i;return Jl(c.length>0?c:Array.isArray(l)&&l.length>0?"string"==typeof t?l.map(e=>({...e.properties||{},...e})):l:[],t)})():[];hu(o,{props:e,categories:d,theme:i,size:r,hasTitle:a});let h=pu({props:e,categories:d,theme:i,size:r,margin:o,hasTitle:a}),p=r[0]-(o.left??0)-(o.right??0),f=r[1]-(o.top??0)-(o.bottom??0),y={projection:e.projection||"equalEarth",projectionExtent:e.projectionExtent,xAccessor:e.xAccessor,yAccessor:e.yAccessor,lineDataAccessor:e.lineDataAccessor,pointIdAccessor:e.pointIdAccessor,lineIdAccessor:e.lineIdAccessor,lineType:e.lineType,flowStyle:e.flowStyle,areaStyle:e.areaStyle,pointStyle:e.pointStyle,lineStyle:e.lineStyle,colorScheme:e.colorScheme,graticule:e.graticule,fitPadding:e.fitPadding,projectionTransform:e.projectionTransform,customLayout:e.customLayout,layoutConfig:e.layoutConfig,layoutSelection:e.layoutSelection,layoutMargin:o,onLayoutError:e.onLayoutError,themeCategorical:i.colors.categorical,themeSemantic:Pr(i),themeSequential:i.colors.sequential,themeDiverging:i.colors.diverging},g=new Zk(y);if(l){if("string"==typeof l)throw Error(`Geo SSR requires pre-resolved GeoJSON features. Reference string "${l}" cannot be resolved synchronously. Use \`const features = await resolveReferenceGeography('${l}')\` before calling renderGeoToStaticSVG.`);g.setAreas(l)}e.points&&g.setPoints(c),e.lines&&g.setLines(u),g.computeScene({width:p,height:f});let m=yu(e.backgroundGraphics,r,o,g.scales),x=yu(e.foregroundGraphics,r,o,g.scales),b=ql({nodes:g.scene,renderMode:e.renderMode,fallback:(e,t)=>function(e,t){return Bl(function(e,t){switch(e.type){case"geoarea":{let i=e;if(!i.pathData)return null;let r=fr(i.style.fill)?gr(i.style.fill,`geoarea-${t}-hatch`):void 0;return eA(Qk.Fragment,{children:[r&&Jk("defs",{children:r}),Jk("path",{d:i.pathData,fill:r?`url(#geoarea-${t}-hatch)`:Tl(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.style.opacity??1)*(i._decayOpacity??1)})]},"geoarea-"+t)}case"point":{let i=e,r=fr(i.style.fill)?gr(i.style.fill,`geopoint-${t}-hatch`):void 0;return eA(Qk.Fragment,{children:[r&&Jk("defs",{children:r}),Jk("circle",{cx:i.x,cy:i.y,r:i.r,fill:r?`url(#geopoint-${t}-hatch)`:Tl(i.style.fill),fillOpacity:i.style.fillOpacity??.8,stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i._decayOpacity??i.style.opacity??1})]},"point-"+t)}case"line":{let i=e;if(2>i.path.length)return null;let r="M"+i.path.map(e=>`${e[0]},${e[1]}`).join("L");return Jk("path",{d:r,fill:"none",stroke:i.style.stroke||"#4e79a7",strokeWidth:i.style.strokeWidth??1.5,strokeDasharray:i.style.strokeDasharray,opacity:i.style.opacity??1},"line-"+t)}case"glyph":return Fl(e,e.x,e.y,"geo-glyph-"+(e.pointId??t));default:return null}}(e,t),e,"geo-cursor-"+t)}(e,t)});if(0===b.length){let n,a=e.annotations?Yc({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{geoProjection:g.scales?.projectedPoint?([e,t])=>g.scales.projectedPoint(e,t):void 0},layout:{width:p,height:f},theme:i,pointNodes:ph(g.scene),idPrefix:e._idPrefix,onRender:e=>{n=e}}):null;return t&&(t.evidence=Cl({frameType:"geo",width:r[0],height:r[1],marks:b.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:n,legendItems:d.length>0?d.length:null!=e.legend?1:void 0,margin:o})),Sk.renderToStaticMarkup(fu(m||x||e.annotations||g.customLayoutOverlays?nA(rA,{children:[m,a,x,g.customLayoutOverlays]}):null,{width:r[0],height:r[1],className:"stream-geo-frame"+(e.className?" "+e.className:""),title:e.title,description:e.description,background:e.background,theme:i,innerTransform:`translate(${o.left??0},${o.top??0})`,innerWidth:p,innerHeight:f,legend:h,idPrefix:e._idPrefix}))}let v,w=b.map(e=>e.element),k=e.cartogramChrome,A=g.cartogramLayout&&k?oA(fh,{layout:{...g.cartogramLayout,layout:g.cartogramLayout.layout??"radial"},ringValues:gh(g.cartogramLayout.maxCost,k.showRings),showRings:k.showRings??!0,showNorth:k.showNorth??!0,showRingLabels:k.showRingLabels??!0,costLabel:"string"==typeof k.costLabel?k.costLabel:void 0}):null,S=e.annotations?Yc({annotations:e.annotations,autoPlaceAnnotations:e.autoPlaceAnnotations,svgAnnotationRules:e.svgAnnotationRules,scales:{geoProjection:g.scales?.projectedPoint?([e,t])=>g.scales.projectedPoint(e,t):void 0},layout:{width:p,height:f},theme:i,pointNodes:ph(g.scene),idPrefix:e._idPrefix,onRender:e=>{v=e}}):null;return t&&(t.evidence=Cl({frameType:"geo",width:r[0],height:r[1],marks:b.map(e=>e.node),title:e.title,description:e.description,annotations:e.annotations,annotationRender:v,legendItems:d.length>0?d.length:null!=e.legend?1:void 0,margin:o})),Sk.renderToStaticMarkup(fu(nA(rA,{children:[m,w,S,A,x,g.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:i,innerTransform:`translate(${o.left??0},${o.top??0})`,innerWidth:p,innerHeight:f,legend:h,idPrefix:e._idPrefix}))}function gh(e,t){if(!1===t||0>=e)return[];if(Array.isArray(t))return t.filter(t=>t>0&&e>=t);let i="number"==typeof t?t:Math.min(5,Math.max(2,Math.ceil(e/5))),r=e/i,o=[];for(let e=1;i>=e;e++)o.push(Math.round(r*e*10)/10);return o}function mh(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}:{}}))}function xh(e){let t=e.datum;if(t&&"object"==typeof t){let e=t.label??t.name??t.id;if(null!=e&&""!==e)return e+""}return e.id}function bh(e,t,i){let r="function"==typeof t?t(e,i):t;return{...sA,...r??{}}}function vh(e,t={},i="settled"){return e.map((e,r)=>function(e,t={},i={index:0,simulationState:"settled"}){let r=function(e){return e.datum&&"object"==typeof e.datum?e.datum:null}(e),o={label:t.getBodyLabel?.(e)??xh(e)},n={style:bh(e,t.bodyStyle,i),datum:r,accessibleDatum:r,accessibility:o,_transitionKey:e.id};return"aabb"===e.shape.type?{type:"rect",x:e.x-e.shape.width/2,y:e.y-e.shape.height/2,w:e.shape.width,h:e.shape.height,...n}:{type:"point",x:e.x,y:e.y,r:e.shape.radius,pointId:e.id,...n}}(e,t,{index:r,simulationState:i}))}function wh(e,t,i){return"function"==typeof e?e({size:t,margin:i}):e}function kh(e,t={}){let{element:i,scene:r,evidence:o}=function(e,t={}){let{width:i=640,height:r=360,title:o,description:n,background:a,backgroundGraphics:s,backgroundGraphicsBackdrop:l,className:c,foregroundGraphics:u,idPrefix:d="physics",margin:h,style:p,renderBodySVG:f,renderChrome:y,...g}=t,m=function(e,t={}){let i=e.settle(t.maxSteps),r=e.readBodies(),o=e.snapshot(),n=vh(r,t,o.simulationState),a=function(e,t={}){let i=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=i.filter(e=>e.sleeping).length,o=e.queue.length,n=e.sediment.reduce((e,t)=>e+t.count,0),a="settled"===e.simulationState&&0===o&&r===i.length,s=[];a||s.push("PHYSICS_NOT_SETTLED"),o>0&&s.push("PHYSICS_QUEUE_UNDRAINED");let l=null!=t.charge&&Number.isFinite(t.charge)?function(e,t,i,r){let o=e-(t+i+r);return{charge:e,live:t,queued:i,sedimented:r,unaccounted:o,balanced:0===o}}(t.charge,i.length,o,n):void 0;return l&&!l.balanced&&s.push("PHYSICS_LEDGER_MISMATCH"),{bodyCount:i.length,sleepingCount:r,settled:a,stepsRun:Math.max(0,Math.floor(t.stepsRun??0)),seed:e.world.options.seed,binCounts:mh(t.projectionRows),queuedCount:o,sedimentedCount:n,...l?{ledger:l}:{},warnings:s}}(o,{bodies:r,projectionRows:t.projectionRows,stepsRun:i,charge:t.charge});return{snapshot:o,bodies:r,sceneNodes:n,evidence:a,stepsRun:i}}(e,g),x={...uA,...h},b=[i,r],v=wh(s,b,x),w=wh(u,b,x),k=function(e){let t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"physics-"+t:t}(d),A=o?k+"-title":void 0,S=n?k+"-desc":void 0,M=[A,S].filter(Boolean).join(" ")||void 0,$=x.left||x.top?`translate(${x.left},${x.top})`:void 0,_=Math.max(1,i-x.left-x.right),P=Math.max(1,r-x.top-x.bottom),I=k+"-plot-clip",R=$&&null!=v?lA("g",{transform:$,children:v}):v;return{element:cA("svg",{xmlns:"http://www.w3.org/2000/svg",className:c??"stream-physics-frame",width:i,height:r,viewBox:`0 0 ${i} ${r}`,role:"img","aria-labelledby":M,style:p,children:[o&&lA("title",{id:A,children:o}),n&&lA("desc",{id:S,children:n}),lA("defs",{children:lA("clipPath",{id:I,children:lA("rect",{width:_,height:P})})}),l&&"transparent"!==l?lA("rect",{className:"stream-frame-background__backdrop",x:0,y:0,width:i,height:r,fill:l}):null,!s&&a&&"transparent"!==a?lA("rect",{x:0,y:0,width:i,height:r,fill:a}):null,R,lA("g",{id:k+"-data-area",transform:$,clipPath:`url(#${I})`,children:m.sceneNodes.map((e,t)=>{let i=m.bodies[t],r=i&&f?f(i,e.style??{},t,k):void 0;return null!=r?Bl(r,e,t):Bl("point"===e.type||"rect"===e.type?Nl(e,t,k):null,e,"xy-cursor-"+t)})}),w,y?.(m)]}),scene:m,evidence:m.evidence}}(e,t);return{svg:aA.renderToStaticMarkup(i),scene:r,evidence:o}}function Ah(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function Sh(e,t){let i="sensor"===e.physics?t.sensorThickness:t.barrierThickness;return Math.max(0,Ah(e.thickness)??Ah(i)??Ah(t.thickness)??4)}function Mh(e){return e.sensorId??"stream-region-"+e.id}function $h(e){let t=Mh(e),i={bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution};if("boundary"===e.collider&&"aabb"===e.shape.type){let r=e.colliderThickness??8,o=e.shape.x-e.shape.width/2,n=e.shape.x+e.shape.width/2,a=e.shape.y-e.shape.height/2,s=e.shape.y+e.shape.height/2;return[{...i,id:t+"-top",shape:{type:"segment",x1:o,y1:a,x2:n,y2:a,thickness:r}},{...i,id:t+"-right",shape:{type:"segment",x1:n,y1:a,x2:n,y2:s,thickness:r}},{...i,id:t+"-bottom",shape:{type:"segment",x1:n,y1:s,x2:o,y2:s,thickness:r}},{...i,id:t+"-left",shape:{type:"segment",x1:o,y1:s,x2:o,y2:a,thickness:r}}]}return e.collider?[{...i,id:t+"-collider",shape:e.shape}]:[]}function _h({title:e,totalWidth:t,marginTop:i}){return e?"string"!=typeof e?dA("foreignObject",{x:0,y:0,width:t,height:i,children:e}):dA("text",{x:t/2,y:22,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",fontSize:14,className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)",fontFamily:"var(--semiotic-title-font-family, var(--semiotic-font-family, sans-serif))",fontWeight:"var(--semiotic-title-font-weight, bold)"},children:e}):null}function Ph(e){return"circle"===e.shape.type?e.shape.radius:Math.max(e.shape.width,e.shape.height)/2}function Ih(e,t){let i=e.size??[e.width??600,e.height??400],r=Ir(e.theme),o=void 0===e.theme?{}:Zo(r),n=e.bodyStyle,s=!1,c=e.legendPosition??"right",u=a({...yA,...e.margin},s,!!e.legend&&"top"===c);if(e.legend){let t={...u};x(u,{legend:e.legend,position:c,size:i,hasTitle:s,legendLayout:e.legendLayout}),l(u,t,i,c)}let d,h=function({annotations:e,chartId:t,chartType:i,config:r,onRegionObservation:o,regionEffects:n,seed:a,size:s}){let l=function(e=[],t={}){let i=t.idPrefix?t.idPrefix+"-":"",r=[];for(let o of e){if("barrier"!==o.physics&&"sensor"!==o.physics)continue;let e,n=o.axis??t.defaultAxis??"x",a=Sh(o,t),s=o.colliderId??`${i}${o.id}`;if("x"===n){let i=Ah(o.x),r=Ah(o.y1)??Ah(t.plotBounds?.y)??Ah(o.y),n=Ah(o.y2)??(t.plotBounds?t.plotBounds.y+t.plotBounds.height:void 0)??Ah(o.y);if(null==i||null==r||null==n)continue;e={type:"segment",x1:i,y1:r,x2:i,y2:n,thickness:a}}else{let i=Ah(o.y),r=Ah(o.x1)??Ah(t.plotBounds?.x)??Ah(o.x),n=Ah(o.x2)??(t.plotBounds?t.plotBounds.x+t.plotBounds.width:void 0)??Ah(o.x);if(null==i||null==r||null==n)continue;e={type:"segment",x1:r,y1:i,x2:n,y2:i,thickness:a}}r.push({id:s,shape:e,sensor:"sensor"===o.physics,..."barrier"!==o.physics||null==o.restitution&&null==t.barrierRestitution?{}:{restitution:Ah(o.restitution)??Ah(t.barrierRestitution)},..."barrier"!==o.physics||null==o.friction&&null==t.barrierFriction?{}:{friction:Ah(o.friction)??Ah(t.barrierFriction)}})}return r}((e??[]).filter(e=>"barrier"===e.physics||"sensor"===e.physics),{idPrefix:t?t+"-ann":"physics-ann",plotBounds:{x:0,y:0,width:s[0],height:s[1]}}),c=void 0===a||void 0!==r?.kernel?.seed?r:{...r,kernel:{...r?.kernel,seed:a}},u=n.flatMap(e=>[{id:Mh(e),sensor:!0,shape:e.shape,bodyFilter:e.bodyFilter,friction:e.friction,restitution:e.restitution},...$h(e)]),d=Object.fromEntries(n.map(e=>[Mh(e),{binId:e.binId??e.id,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),h=c?.observation,p=n.length>0;return p||u.length>0||l.length>0||null!=t||h?{...c,colliders:[...c?.colliders??[],...u,...l],observation:{...h,chartId:t??h?.chartId,chartType:h?.chartType??i,sensors:{...h?.sensors??{},...d},onObservation:e=>{p&&o(e),h?.onObservation?.(e)}}}:c}({annotations:e.annotations,chartId:e.chartId,chartType:"StreamPhysicsFrame",config:e.config,onRegionObservation:()=>{},regionEffects:e.regionEffects??[],seed:e.seed,size:[Math.max(1,i[0]-u.left-u.right),Math.max(1,i[1]-u.top-u.bottom)]}),p=new sf(h);Array.isArray(e.initialSpawns)&&e.initialSpawns.length>0&&p.enqueue(e.initialSpawns.map(e=>({...e,spawnAt:void 0})));let f=kh(p,{...e,width:i[0],height:i[1],background:e.background??r.colors.background,bodyStyle:(e,t)=>({fill:r.colors.primary,stroke:r.colors.text,strokeWidth:1,opacity:.9,..."function"==typeof n?n(e,t):n}),style:{...o,fontFamily:r.typography.fontFamily,...e.style},charge:e.charge,idPrefix:e.idPrefix??e._idPrefix??"physics",margin:u,renderChrome:t=>{let o=function(e,t,i,r,o){let n=Math.max(1,i[0]-r.left-r.right),a=Math.max(1,i[1]-r.top-r.bottom),s=function(e){return e?.length?e.map(e=>null!=e.pointId||null==e.bodyId?e:{...e,pointId:e.bodyId+""}):e}(t.annotations),l=function(e){let{width:t,height:i,pointNodes:r=[],data:o}=e;return{scales:{x:hA().domain([0,Math.max(1,t)]).range([0,Math.max(1,t)]),y:hA().domain([0,Math.max(1,i)]).range([0,Math.max(1,i)])},width:t,height:i,frameType:"network",pointNodes:r,data:o,xAccessor:"x",yAccessor:"y"}}({width:n,height:a,pointNodes:(d=e.bodies,d.map(e=>({pointId:e.id,x:e.x,y:e.y,r:Math.max(1,Ph(e))})))}),c=l.scales?.x,u=l.scales?.y;var d;if(!c||!u)throw Error("Physics annotation context requires pixel scales");let h,p=Yc({annotations:s,autoPlaceAnnotations:t.autoPlaceAnnotations,scales:{x:c,y:u},layout:{width:n,height:a},theme:o,frameType:"network",xAccessor:l.xAccessor,yAccessor:l.yAccessor,pointNodes:l.pointNodes,svgAnnotationRules:t.svgAnnotationRules,onRender:e=>{h=e}}),f=t.legend?du(t.legend,{theme:o,position:t.legendPosition,size:[i[0],i[1]],margin:r,hasTitle:!!t.title,legendLayout:t.legendLayout})??qc(t.legend,i,r,t.legendPosition,t.legendLayout):null;return{annotationRender:h,node:fA("svg",{className:"stream-physics-frame__overlay","data-testid":"stream-physics-overlay",role:"presentation",width:i[0],height:i[1],style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[pA("g",{transform:`translate(${r.left},${r.top})`,children:p}),pA(_h,{title:t.title,totalWidth:i[0],marginTop:Math.max(r.top,28)}),f]})}}(t,e,i,u,r);return d=o.annotationRender,o.node}});return t&&(t.evidence=Cl({frameType:"physics",width:i[0],height:i[1],marks:f.scene.sceneNodes,title:e.title,description:e.description,annotations:e.annotations,annotationRender:d,extraWarnings:[...0===f.scene.sceneNodes.length?["PHYSICS_EMPTY_SCENE"]:[],...f.scene.evidence.warnings]})),f.svg}function Rh(e,t){return"number"==typeof e&&Number.isFinite(e)&&e>0?e:t}function Lh(e,t,i){return vA[e](t,i)}function Ch(e,t){switch(e){case"xy":return gu(t);case"ordinal":return Ku(t);case"network":return oh(t);case"geo":return yh(t);case"physics":return Ih(t);default:throw Error(`Unknown frame type: ${e}. Must be "xy", "ordinal", "network", "geo", or "physics".`)}}function Th(e){return gu(e)}function Oh(e){return Ku(e)}function Fh(e){return oh(e)}function Dh(e){return yh(e)}function Eh(e,t){let i=Number(e);if(!Number.isFinite(i))return e;let r=10**t,o=Math.round((i+Number.EPSILON)*r)/r;return Object.is(o,-0)?"0":o+""}function Nh(e,t){let i=function(e){if(Number.isFinite(e))return Math.max(0,Math.min(8,Math.floor(e)))}(t);return void 0===i?e:function(e){let t=A(e)?.start??0;return e.slice(0,t)+e.slice(t).replace(/<!--[\s\S]*?(?:-->|$)|<!\[CDATA\[[\s\S]*?(?:\]\]>|$)|<\?[\s\S]*?(?:\?>|$)|<([A-Za-z_][\w.:-]*)(?=[\s/>])(?:[^<>"']|"[^"]*"|'[^']*')*>/g,(e,t)=>t?e.replace(tp,(e,t,r,o)=>{let n=((e,t)=>{if($A.has(e)&&!/\b(?:var|calc|url)\(/i.test(t))return function(e,t){let i,r=RegExp(_A.source,_A.flags),o="",n=0,a=!1;for(;i=r.exec(e);){let r=e.slice(n,i.index);o+=a&&0===r.length?" ":r,o+=Eh(i[0],t),n=i.index+i[0].length,a=!0}return o+e.slice(n)}(t,i)})(t,M(r??o));return void 0===n?e:` ${t}="${S(n)}"`}):e)}(e)}function zh(e,t){let i={};for(let r of t)void 0!==e[r]&&(i[r]=e[r]);return i}function Bh(e,t,i){return Wh(e,t,i).svg}function jh(e,t,i){let r={},{svg:o,frameType:n}=Wh(e,t,i,r),a=r.evidence??Cl({frameType:n,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"]});if(a.component=e,a.sceneHashVersion=2,a.sceneHash=function(e,t){return R(I({kind:"semiotic.rendered-svg-scene",version:2,svg:e,frameType:t.frameType,width:t.width,height:t.height,margin:t.margin,plot:t.plot,xDomain:t.xDomain,yDomain:t.yDomain,categories:t.categories}))}(o,a),ge(a,e,t),i?.artifactContract){let r=function(e,t={}){try{return function(e,t){if(!le(e))return{transfer:{status:"invalid",omittedPaths:["artifactContract"],warnings:["Artifact contract must be a JSON object."]}};let i=E(e),r=[...new Set([...i.excludedPaths,...q(e)])].sort(),o=i.value,n=function(e,t){if(!t||!le(e)||!Array.isArray(e.evidence))return[];let i=[];return e.evidence.forEach((e,t)=>{le(e)&&Object.prototype.hasOwnProperty.call(e,"sample")&&(delete e.sample,i.push(`$.evidence[${t}].sample`))}),i}(o,t.excludeEvidenceSamples),a=n.length?["Bounded evidence samples were excluded by the transfer policy."]:[],s=o?.contractVersion;if("string"!=typeof s||!s)return{contract:o,transfer:{status:"invalid",omittedPaths:[...r,...n],warnings:["Artifact contract is missing a string contractVersion.",...a]}};if("0.1"!==s)return{contract:o,transfer:{status:r.length>0?"invalid":"unsupported-version",omittedPaths:[...r,...n],warnings:[`Contract version ${s} is not interpreted by this runtime.`,...r.length>0?[`Non-JSON values could not be preserved at: ${r.join(", ")}.`]:[],...a]}};let l=se(o),c=[...l.errors.map(({path:e,message:t})=>`${e}: ${t}`),...l.warnings.map(({path:e,message:t})=>`${e}: ${t}`),...r.length?[`Non-JSON values could not be preserved at: ${r.join(", ")}.`]:[],...a];return{contract:o,transfer:{status:!l.valid||r.length>0?"invalid":n.length>0?"excluded":"preserved",omittedPaths:[...r,...n],warnings:c}}}(e,t)}catch{let t=q(e);return{transfer:{status:"invalid",omittedPaths:t.length?t:["$"],warnings:["Artifact contract could not be inspected safely."]}}}}(i.artifactContract,{excludeEvidenceSamples:!0});r.contract&&(a.artifactContract=r.contract),a.artifactTransfer=r.transfer,a.artifactBinding="0.1"===r.contract?.contractVersion&&"invalid"!==r.transfer.status?function(e,t,i,r=function(e){let t=Object.entries(e).filter(([e,t])=>ce(e,t)&&void 0!==t);if(0!==t.length)return 1===t.length&&"data"===t[0][0]?t[0][1]:Object.fromEntries(t)}(t)){let o=function(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>!ce(e,t)&&"recipeId"!==e))}(t),n=0===q(o).length?N(o).fingerprint:void 0,a=void 0!==r&&0===q(r).length?function(e,t=[]){if(void 0===e)return;let i=t.filter(e=>!!e.transformation).map(({id:e,transformation:t})=>({evidenceId:e,transformation:t})).sort(({evidenceId:e},{evidenceId:t})=>t>e?-1:e>t?1:0);return N(i.length>0?{data:e,transformations:i}:e).fingerprint}(r,e.evidence):void 0,s="ChartRecipe"===i&&"string"==typeof t.recipeId?t.recipeId:i,l=[],c=[];return void 0!==s&&(void 0===e.artifact.component?c.push("artifact.component"):e.artifact.component!==s&&l.push("artifact.component")),void 0===e.artifact.configFingerprint||void 0===n?c.push("artifact.configFingerprint"):e.artifact.configFingerprint!==n&&l.push("artifact.configFingerprint"),void 0!==e.artifact.dataFingerprint&&a?e.artifact.dataFingerprint!==a&&l.push("artifact.dataFingerprint"):c.push("artifact.dataFingerprint"),{status:l.length>0?"mismatch":c.length>0?"unknown":"match",mismatchPaths:l,unknownPaths:c}}(r.contract,t,e):{status:"unknown",mismatchPaths:[],unknownPaths:["artifactContract"]}}return{svg:o,evidence:a}}function Wh(e,t,i,r){if(Object.prototype.hasOwnProperty.call(vA,e))return{svg:Nh(Lh(e,t,r),i?.precision),frameType:"value"};if(!Object.prototype.hasOwnProperty.call(Xv,e))throw Error(`Unknown chart component: "${e}". Run \`npx semiotic-ai --list\` for supported chart types.`);let o,n=Xv[e],a=function(e,t,i){let r=fp[e||"primary"],o=e&&"primary"!==e||!i?.width?r.width:i.width,n=e&&"primary"!==e||!i?.height?r.height:i.height,a=function(e,t,i=e.responsiveRules){if(!Array.isArray(i)||0===i.length)return{props:e,matches:[]};let r=i.map((e,t)=>({rule:e,index:t})).filter(e=>function(e,t){let{when:i}=e,r=t.width,o=t.height,n=function(e){if("number"==typeof e.height&&e.height>0)return e.width/e.height}(t),a=function(e){if("number"==typeof e.height&&e.height>0)return e.height>e.width?"portrait":"landscape"}(t);return!("number"==typeof i.minWidth&&i.minWidth>r||"number"==typeof i.maxWidth&&r>i.maxWidth||"number"==typeof i.minHeight&&("number"!=typeof o||i.minHeight>o)||"number"==typeof i.maxHeight&&("number"!=typeof o||o>i.maxHeight)||"number"==typeof i.minAspectRatio&&("number"!=typeof n||i.minAspectRatio>n)||"number"==typeof i.maxAspectRatio&&("number"!=typeof n||n>i.maxAspectRatio)||i.orientation&&a!==i.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){let i={...e,...t};for(let r of["margin","frameProps","mobileSemantics","style"])ue(e[r])&&ue(t[r])&&(i[r]={...e[r],...t[r]});return"string"==typeof e.className&&"string"==typeof t.className&&(i.className=`${e.className} ${t.className}`),i}(e,t.rule.transform),e),matches:r}}({...t,mode:e},{width:t.width??o,height:t.height??n}).props,s=a.mode||e||"primary",l=fp[s],c="context"===s||"sparkline"===s,u="primary"===s&&i?.width?i.width:l.width;return{mode:s,width:a.width??u,height:a.height??("primary"===s&&i?.height?i.height:l.height),showAxes:a.showAxes??l.showAxes,showGrid:a.showGrid??l.showGrid,enableHover:a.enableHover??(!!a.linkedHover||l.enableHover),showLegend:a.showLegend??l.showLegend,showLabels:a.showLabels??l.showLabels,title:c?void 0:a.title,description:a.description,summary:a.summary,accessibleTable:a.accessibleTable,xLabel:c?void 0:a.xLabel,yLabel:c?void 0:a.yLabel,categoryLabel:c?void 0:a.categoryLabel,valueLabel:c?void 0:a.valueLabel,marginDefaults:he(l.marginDefaults,a.showCategoryTicks,a.orientation),compactMode:c,mobileInteraction:de(a.mobileInteraction,{mode:s,width:a.width??u,mobileSemantics:a.mobileSemantics}),mobileSemantics:a.mobileSemantics}}(n.layout?.mode??("string"==typeof(C=t.mode)&&Object.prototype.hasOwnProperty.call(fp,C)?t.mode:void 0),{...n.layout?.modeDefaults,...zh(t,IA)},n.layout?.primarySize),{data:s,theme:l,background:c,className:u,annotations:d,margin:h,colorScheme:p,colorBy:f,legendPosition:y,...g}=t,{width:m,height:x}=a,b=[m,x],v=g.frameProps||{},w=n.layout?.margin,A="function"==typeof w?w(t,a):w??a.marginDefaults,S="xy"===n.frameType?k(A,g.axes??v.axes,!!a.title):A,M=void 0!==h?h:v.margin,$=function(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};let 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}(M),_="number"==typeof M?{top:M,right:M,bottom:M,left:M}:{...S,...$},P=zh(g,PA),I=e=>v[e]??a[e],R={...v,...P,theme:l,title:a.title,description:a.description,showAxes:I("showAxes"),showLegend:I("showLegend"),showLabels:I("showLabels"),showGrid:I("showGrid"),xLabel:I("xLabel"),yLabel:I("yLabel"),categoryLabel:I("categoryLabel"),valueLabel:I("valueLabel"),background:c,className:u,annotations:d,size:b,margin:_,__compactMode:a.compactMode,__autoLegendMargin:!0,...void 0!==p&&{colorScheme:p},...void 0!==y&&{legendPosition:y},_idPrefix:g._idPrefix},L=n.buildProps(s,f,p,R,g);var C;if(n.renderStatic)o=n.renderStatic(L,r);else switch(n.frameType){case"xy":o=gu(L,r);break;case"ordinal":o=Ku(L,r);break;case"network":o=oh(L,r);break;case"geo":o=yh(L,r);break;case"physics":o=Ih(L,r)}let T=n.renderOverlay?.(L,{theme:Ir(l)});if(null!=T){let e=bp.renderToStaticMarkup(MA(SA,{children:T})),t=o.lastIndexOf("</svg>");o=0>t?`${o}${e}`:`${o.slice(0,t)}${e}${o.slice(t)}`}return{svg:Nh(o,i?.precision),frameType:n.frameType}}function Yh(e,t={}){return function(e,t,i){let{title:r,subtitle:o,theme:n,width:a=1200,height:s,layout:l={},background:c}=t,u=Rr(Ir(n)),d=l.columns||2,h=l.gap??16,p=0;r&&(p+=30),o&&(p+=20),p>0&&(p+=10);let f=Math.floor((a-h-h*(d-1))/d),y=[],g=0,m=p+h,x=0;for(let t of e){let e=Math.min(t.colSpan||1,d),r=f*e+h*(e-1),o=t.props.height||300;g+e>d&&(m+=x+h,g=0,x=0);let a=h/2+g*(f+h),s={...t.props,width:r,height:o,theme:n,_idPrefix:"chart-"+y.length},l=t.component?i.chart(t.component,s):t.frameType?i.frame(t.frameType,s):`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${o}"></svg>`,c=_(l,{width:r,height:o}),u=Math.max(o,c.height);y.push({x:a,y:m,width:r,height:u,svg:l,svgDimensions:c}),x=Math.max(x,u),g+=e}let b=s||m+x+h,v=y.map((e,t)=>kA("g",{transform:`translate(${e.x},${e.y})`,children:kA("foreignObject",{width:e.width,height:e.height,children:kA("div",{xmlns:"http://www.w3.org/1999/xhtml",dangerouslySetInnerHTML:{__html:P(e.svg,e.svgDimensions)}})})},"dashboard-chart-"+t));return wA.renderToStaticMarkup(AA("svg",{xmlns:"http://www.w3.org/2000/svg",width:a,height:b,role:"img","aria-label":r||"Dashboard",style:{fontFamily:u.fontFamily},children:[r&&kA("title",{children:r}),c&&kA("rect",{x:0,y:0,width:a,height:b,fill:c}),r&&kA("text",{x:a/2,y:24,textAnchor:"middle",fontSize:u.titleFontSize+4,fontWeight:u.titleFontWeight,fill:u.text,fontFamily:u.titleFontFamily,children:r}),o&&kA("text",{x:a/2,y:r?46:20,textAnchor:"middle",fontSize:u.labelSize,fill:u.textSecondary,fontFamily:u.fontFamily,children:o}),v]}))}(e,t,{chart:Bh,frame:Ch})}function qh(e,t,i,r={}){let{stepSize:o,windowSize:n,frameCount:a,xExtent:l,yExtent:c,transitionFrames:u=4,fps:d=12,easing:h="ease-out",decay:p}=r,f=i.width||600,y=i.height||400,g=Ir(i.theme),m={...i,...l&&{xExtent:l},...c&&{yExtent:c}};if(!t||0===t.length)return[];let x=o||Math.max(1,Math.ceil(t.length/(a||Math.min(60,Math.max(10,t.length))))),b=[];for(let e=x;t.length>=e;e+=x)b.push(e);b[b.length-1]!==t.length&&b.push(t.length);let v=new Set(["bar","pie","donut","clusterbar","swarm","point","boxplot","violin","histogram","timeline","swimlane","ridgeline","funnel","bar-funnel"]).has(e),w=s({top:20,right:20,bottom:30,left:40,...i.margin},i.title),k=f-w.left-w.right,A=y-w.top-w.bottom,S=[];if(v)for(let r=0;b.length>r;r++){let o=b[r],a=t.slice(n?Math.max(0,o-n):0,o),s={chartType:e,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,connectorAccessor:i.connectorAccessor,connectorStyle:i.connectorStyle,barPadding:i.barPadding,innerRadius:i.innerRadius,normalize:i.normalize,bins:i.bins,colorScheme:i.colorScheme||g.colors.categorical,...p&&{decay:p}},l=new yw(s);l.ingest({inserts:a,bounded:!0}),l.computeScene({width:k,height:A}),l.scene.length>0&&S.push(Qh(l.scene,f,y,g,m,S.length))}else for(let r=0;b.length>r;r++){let o=b[r],a=t.slice(n?Math.max(0,o-n):0,o),s={chartType:e,windowSize:a.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:l,yExtent:c,colorScheme:i.colorScheme||g.colors.categorical,lineStyle:i.lineStyle,pointStyle:i.pointStyle,areaStyle:i.areaStyle,sizeAccessor:i.sizeAccessor||i.sizeBy,sizeRange:i.sizeRange,...p&&{decay:p},...u>0&&{transition:{duration:u*(1e3/d),easing:h}}},x=new Lx(s);if(x.ingest({inserts:a,bounded:!0}),x.computeScene({width:k,height:A}),0===x.scene.length)continue;let v=x.scales?{y:x.scales.y}:void 0;if(S.push(Zh(x.scene,f,y,g,m,v,S.length)),u>0&&r>0&&x.activeTransition){let e=u*(1e3/d);for(let t=1;u>=t;t++)x.advanceTransition(x.activeTransition.startTime+t/u*e),S.push(Zh(x.scene,f,y,g,m,v,S.length))}}return S}function Xh(e,t,i={}){return t.map(t=>{try{return Bh(e,{...i,...t})}catch{return`<svg xmlns="http://www.w3.org/2000/svg" width="${i.width||t.width||600}" height="${i.height||t.height||400}"></svg>`}})}function Gh(e,t,i,r){let o=Xc(`${e}-${t}`),n="string"==typeof i&&i.length>0?i:void 0,a="string"==typeof r&&r.length>0?r:void 0,s=n?o.titleId:void 0,l=a?o.descId:void 0;return{titleText:n,descText:a,titleId:s,descId:l,labelledBy:[s,l].filter(Boolean).join(" ")||void 0}}function Vh(e,t){return"string"==typeof e.idPrefix&&e.idPrefix.length>0?e.idPrefix:lu(e)||t}function Hh(e,t,i){let r=t.size??[t.width??600,t.height??400],o=Ir(t.theme),n=Rr(o),a=t.background||o.colors.background,s=t.idPrefix??"physics-gif",l=Gh(s,i,t.title,t.description),{titleId:c,descId:u,labelledBy:d}=l,h=vh(e.readBodies(),{bodyStyle:t.bodyStyle,getBodyLabel:t.getBodyLabel}),p=TA("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":d,style:{fontFamily:n.fontFamily},children:[t.title&&CA("title",{id:c,children:t.title}),t.description&&CA("desc",{id:u,children:t.description}),a&&"transparent"!==a?CA("rect",{x:0,y:0,width:r[0],height:r[1],fill:a}):null,CA("g",{id:`${s}-frame-${i}`,children:h.map((e,t)=>Wl(e,t,`${s}-${i}`))})]});return RA.renderToStaticMarkup(p)}function Uh(e,t={}){let{fps:i=12,frameCount:r,durationSeconds:o=2,includeInitialFrame:n=!0,stepDt:a,stepsPerFrame:s,background:l}=t,c=Math.max(.001,a??e.config?.fixedDt??1/120),u=s??Math.max(1,Math.round(1/Math.max(1,i)/c)),d=r??Math.max(1,Math.ceil(o*Math.max(1,i))),h=l?{...e,background:l}:e,p=new sf(e.config);e.initialSpawns?.length&&p.enqueue(e.initialSpawns,e.initialSpawnPacing);let f=[];for(n&&(p.tick(0),f.push(Hh(p,h,0)));d>f.length;){for(let e=0;u>e;e+=1)p.tick(c);f.push(Hh(p,h,f.length))}return f}function Kh(e,t){let i=e.background||t.colors.background;return i&&"transparent"!==i?i:null}function Zh(e,t,i,r,o,n,a=0){let l=Rr(r),c=s({top:20,right:20,bottom:30,left:40,...o.margin},o.title),u=t-c.left-c.right,d=i-c.top-c.bottom,h=Kh(o,r),p=o.renderMode,f=e.map((e,t)=>Yl({node:e,index:t,renderMode:p,fallback:()=>Wl(e,t)}).element).filter(Boolean),y=function(e,t,i,r,o,n){if(!e||0===e.length)return null;let a=Rr(r),s=[];for(let r=0;e.length>r;r++){let l=e[r];if("y-threshold"===l.type&&null!=l.value){let e=null;if(n)e=n(l.value);else if(o){let[t,r]=o,n=r-t;if(0===n)continue;e=i-(l.value-t)/n*i}if(null==e)continue;let c=l.color||a.primary,u=l.labelPosition||"right";s.push(TA("g",{children:[CA("line",{x1:0,y1:e,x2:t,y2:e,stroke:c,strokeWidth:l.strokeWidth??1.5,strokeDasharray:l.strokeDasharray||"6,4"}),l.label&&CA("text",{x:"left"===u?4:"center"===u?t/2:t-4,y:20>e?Math.min(i-4,e+16):e-5,textAnchor:"left"===u?"start":"center"===u?"middle":"end",fontSize:a.tickSize,fill:c,fontFamily:a.fontFamily,children:l.label})]},"ann-"+r))}}return s.length>0?CA(LA,{children:s}):null}(o.annotations,u,d,r,o.yExtent,n?.y),{titleText:g,descText:m,titleId:x,descId:b,labelledBy:v}=Gh(Vh(o,"xy-gif"),a,o.title,o.description);return RA.renderToStaticMarkup(TA("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:i,role:"img","aria-labelledby":v,style:{fontFamily:l.fontFamily},children:[g&&CA("title",{id:x,children:g}),m&&CA("desc",{id:b,children:m}),h&&CA("rect",{x:0,y:0,width:t,height:i,fill:h}),TA("g",{transform:`translate(${c.left},${c.top})`,children:[y,f]}),g&&CA("text",{x:t/2,y:22,textAnchor:"middle",fontSize:l.titleFontSize,fontWeight:l.titleFontWeight,fill:l.text,fontFamily:l.titleFontFamily,children:g})]}))}function Qh(e,t,i,r,o,n=0){let a=Rr(r),l=s({top:20,right:20,bottom:30,left:40,...o.margin},o.title),c="radial"===o.projection,u=c?l.left+(t-l.left-l.right)/2:l.left,d=c?l.top+(i-l.top-l.bottom)/2:l.top,h=Kh(o,r),p=Uu({nodes:e,renderMode:o.renderMode,idPrefix:o.idPrefix}).map(e=>e.element),{titleText:f,descText:y,titleId:g,descId:m,labelledBy:x}=Gh(Vh(o,"ordinal-gif"),n,o.title,o.description);return RA.renderToStaticMarkup(TA("svg",{xmlns:"http://www.w3.org/2000/svg",width:t,height:i,role:"img","aria-labelledby":x,style:{fontFamily:a.fontFamily},children:[f&&CA("title",{id:g,children:f}),y&&CA("desc",{id:m,children:y}),h&&CA("rect",{x:0,y:0,width:t,height:i,fill:h}),CA("g",{transform:`translate(${u},${d})`,children:p}),f&&CA("text",{x:t/2,y:22,textAnchor:"middle",fontSize:a.titleFontSize,fontWeight:a.titleFontWeight,fill:a.text,fontFamily:a.titleFontFamily,children:f})]}))}var Jh=34,ep=70,tp=/\s+([^\s=<>/'"]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g,ip=(e,t)=>(e>>>t|e<<32-t)>>>0,rp=e=>Math.floor(4294967296*(e-Math.floor(e)))>>>0,[op,np]=(()=>{let e=[],t=[];for(let i=2;64>t.length;i+=1){let r=!0;for(let e=2;i>=e*e;e+=1)if(i%e===0){r=!1;break}r&&(8>e.length&&e.push(rp(Math.sqrt(i))),t.push(rp(Math.cbrt(i))))}return[e,t]})(),ap=ae({"artifact.id":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"never"},"artifact.createdAt":{suppliedBy:["author","system","import"],derivable:!1,modelMayPropose:!1,humanReview:"never"},"artifact.configFingerprint":{suppliedBy:["system"],derivable:!0,modelMayPropose:!1,humanReview:"never"},"artifact.dataFingerprint":{suppliedBy:["system"],derivable:!0,modelMayPropose:!1,humanReview:"never"},"purpose.intents":{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},"purpose.communicativeAct":{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},"purpose.stakes":{suppliedBy:["author","import"],derivable:!1,modelMayPropose:!0,humanReview:"required"},claims:{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},"claims.status":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},evidence:{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},"evidence.source":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},"evidence.fingerprint":{suppliedBy:["system"],derivable:!0,modelMayPropose:!1,humanReview:"never"},time:{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},"time.completeness":{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"},reception:{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},form:{suppliedBy:["author","system","model-proposal","import"],derivable:!0,modelMayPropose:!0,humanReview:"policy-dependent"},contestability:{suppliedBy:["author","system","import"],derivable:!1,modelMayPropose:!1,humanReview:"required"},accountability:{suppliedBy:["author","system","import"],derivable:!1,modelMayPropose:!1,humanReview:"policy-dependent"},inheritance:{suppliedBy:["author","system","import"],derivable:!0,modelMayPropose:!1,humanReview:"policy-dependent"}}),sp=["fresh","stale","unknown"],lp=["partial","provisional","settled","unknown"],cp=["observedAt","ingestedAt","processedAt","publishedAt","snapshotAt"],up={eventTime:{field:{},value:{},timezone:{},granularity:{}},presentation:{state:{values:["live","historical","mixed"]},label:{}},freshness:{status:{required:!0,values:sp},checkedAt:{},heartbeatAt:{},expiresAt:{},basis:{}},watermark:{value:{required:!0},policy:{},allowedLateness:{}},window:{start:{required:!0},end:{required:!0},status:{required:!0,values:["open","provisional","settled","reopened","corrected"]}},completeness:{status:{required:!0,values:lp},basis:{}},revision:{status:{required:!0,values:["original","backfilled","corrected","superseded"]},previousArtifactId:{},correctionId:{},reason:{}},snapshot:{id:{},format:{values:["iceberg","delta","other"]},schemaVersion:{},catalogRef:{}}},dp={id:{required:!0},kind:{required:!0,values:["stream","processing-job","quality-check","snapshot","publication"]},label:{},observedAt:{},version:{},timezone:{},granularity:{},freshness:{values:sp},completeness:{values:lp}},hp=new Set(["data","nodes","edges","points","areas","lines","flows","atlas","forest","circuit","edition","reading"]),pp={enabled:!0,tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:44,snap:"nearestDatum",brushHandleSize:44,standardControls:!1,enabled:!1,tapToSelect:!1,tapToLockTooltip:!1},fp={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}}},yp={kind:"rank-competition"},gp=Symbol.for("semiotic.semantic-viability"),mp=globalThis,xp=mp[gp]??(mp[gp]=new Map);import*as bp from"react-dom/server";import{interpolateRgb as vp}from"d3-interpolate";var wp=864e5,kp=e=>{let t=e.config,{plot:i}=e.dimensions;if(0>=i.width||0>=i.height)return{nodes:[]};let r=e=>{let i="function"==typeof t.dateAccessor?t.dateAccessor(e):e[t.dateAccessor];return i instanceof Date?i:new Date(i)},o=e=>{let i="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor];return Number(i)},n=new Map,a=null;for(let t of e.data){let e=r(t);if(!isFinite(e.getTime()))continue;null==a&&(a=e.getUTCFullYear());let i=me(e),s=o(t);n.set(i,(n.get(i)??0)+(Number.isFinite(s)?s:0))}let s=t.year??a??(new Date).getUTCFullYear(),l=1/0,c=-1/0;for(let e of n.values())l>e&&(l=e),e>c&&(c=e);l===1/0&&(l=0,c=0);let[u,d]=t.colorRamp??[e.theme.semantic.surface??"#ebedf0",e.theme.semantic.primary??"#216e39"],h=e=>{if(c===l)return u;let t=(e-l)/(c-l);return vp(u,d)(t)},p=t.gutter??2,f=t.labelInset??0,y=Math.min((i.width-f-53*p)/54,(i.height-6*p)/7);if(0>=y)return{nodes:[]};let g=new Date(Date.UTC(s,0,1)),m=g.getUTCDay(),x=new Date(g.getTime()-m*wp),b=[];for(let e=0;54>e;e++)for(let t=0;7>t;t++){let r=new Date(x.getTime()+(7*e+t)*wp);if(r.getUTCFullYear()!==s)continue;let o=me(r),a=n.get(o),l=null==a?u:h(a);b.push({type:"rect",x:i.x+f+e*(y+p),y:i.y+t*(y+p),w:y,h:y,style:{fill:l,stroke:"none"},datum:{date:r,value:a??0}})}return{nodes:b}};import*as Ap from"react";import{scaleLinear as Sp}from"d3-scale";import{interpolateLab as Mp}from"d3-interpolate";import{jsx as $p,jsxs as _p}from"react/jsx-runtime";var Pp=e=>{let t=e.config,{plot:i}=e.dimensions,r=t.fields??[];if(2>r.length||0>=i.width||0>=i.height)return{nodes:[]};if(0===e.data.length)return{nodes:[]};let o=Object.create(null);for(let i of r){let r=t.domains&&Object.prototype.hasOwnProperty.call(t.domains,i)?t.domains[i]:void 0;if(Array.isArray(r)&&r.length>=2&&"number"==typeof r[0]&&Number.isFinite(r[0])&&"number"==typeof r[1]&&Number.isFinite(r[1])){o[i]=[r[0],r[1]];continue}let n=1/0,a=-1/0;for(let t of e.data){let e=Number(t[i]);Number.isFinite(e)&&(n>e&&(n=e),e>a&&(a=e))}if(Number.isFinite(n)&&Number.isFinite(a))if(n===a){let e=Math.max(.01*Math.abs(n),.5);o[i]=[n-e,a+e]}else o[i]=[n,a];else o[i]=[0,1]}let n=!1!==t.showAxes,a=n?t.axisLabelPadding??24:8,s=n?18:8,l=r.map(e=>Sp().domain(o[e]).range([i.y+i.height-s,i.y+a])),c=r.map((e,t)=>1===r.length?i.x+i.width/2:i.x+t/(r.length-1)*i.width),u=t.colorBy?"function"==typeof t.colorBy?t.colorBy:e=>(e[t.colorBy]??"")+"":null,d=t.opacity??.45,h=t.strokeWidth??1.25,p=e.theme.semantic.primary??"#3b6cb1",f=t.dimmedOpacity??.08,y=t.highlightFn,g=[],m=[];for(let i of e.data){let o=u?e.resolveColor(u(i)+""):p,n=!y||y(i),a=be(i,{predicate:y,baseOpacity:d,dimOpacity:f,brighten:.4}),s=n?m:g;for(let e=0;r.length-1>e;e++){let t=Number(i[r[e]]),u=Number(i[r[e+1]]);if(!Number.isFinite(t)||!Number.isFinite(u))continue;let d={type:"connector",x1:c[e],y1:l[e](t),x2:c[e+1],y2:l[e+1](u),style:{stroke:o,strokeWidth:y&&n?h+.75:h,opacity:a,fill:"none"},datum:i};s.push(d)}if(t.showPoints)for(let e=0;r.length>e;e++){let t=Number(i[r[e]]);if(!Number.isFinite(t))continue;let n={type:"point",x:c[e],y:l[e](t),r:2.5,style:{fill:o,stroke:"none",opacity:Math.min(1,a+.3)},datum:i};s.push(n)}}let x=null;if(n){let n=`var(--semiotic-border, ${e.theme.semantic.border??"#aaa"})`,u=`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`,d=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,h=i.y+a,p=i.y+i.height-s,f=[];for(let e=0;r.length>e;e++){let s=r[e],y=c[e],g=t.tickFormat&&Object.prototype.hasOwnProperty.call(t.tickFormat,s)?t.tickFormat[s]:void 0,m="function"==typeof g?g:e=>e.toLocaleString();f.push(Ap.createElement("line",{key:"pc-axis-line-"+e,x1:y,x2:y,y1:h,y2:p,stroke:n,strokeWidth:1})),f.push(we({keyId:"pc-axis-label-"+e,text:s,x:y,y:i.y+a-8,anchor:"middle",baseline:"auto",fontSize:12,fontWeight:600,color:u}));let[x,b]=o[s],v=5;for(let t=0;v>t;t++){let i=x+(b-x)*t/(v-1),r=l[e](i);f.push(Ap.createElement("line",{key:`pc-tick-${e}-${t}`,x1:y-3,x2:y+3,y1:r,y2:r,stroke:n,strokeWidth:1}),we({keyId:`pc-ticktext-${e}-${t}`,text:m(i),x:y+6,y:r+3,anchor:"start",baseline:"auto",fontSize:10,color:d}))}}x=Ap.createElement(Ap.Fragment,null,...f)}return{nodes:g.concat(m),overlays:x}},Ip={frameType:"xy",buildProps:(e,t,i,r,o)=>({chartType:"custom",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,colorScheme:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r,showAxes:o.frameProps?.showAxes??o.showAxes??!1,showLegend:r.showLegend??!!t})},Rp={frameType:"ordinal",buildProps:(e,t,i,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:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r,showAxes:o.frameProps?.showAxes??o.showAxes??!1})},Lp={frameType:"network",layout:{margin:{top:40,right:40,bottom:40,left:40}},buildProps:(e,t,i,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:i,customNetworkLayout:o.layout||o.customNetworkLayout,layoutConfig:o.layoutConfig,...r})},Cp={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({...Rp.buildProps(e,t,i,r,o),customLayout:Pp,showAxes:!1})},Tp={frameType:"xy",buildProps:(e,t,i,r,o)=>({...Ip.buildProps(e,t,i,r,o),customLayout:kp,showAxes:!1})};import*as Op from"react";import{scaleLinear as Fp}from"d3-scale";var Dp={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},Ep=1e-9,Np=.005,zp=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={...Dp,...e},this.random=je(this.options.seed)}init(e={}){this.options={...Dp,...e},this.random=je(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){let 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(Ep,e.mass??1),bodyCollisions:e.bodyCollisions??!0,...e.fixedPosition?{fixedPosition:Ye(e.fixedPosition)}:{},shape:Xe(e.shape),sleeping:!1,datum:e.datum,restitution:e.restitution,friction:e.friction,index:this.nextBodyIndex,sleepTime:0};We(t),this.nextBodyIndex+=1,this.bodies.set(e.id,t)}remove(e){for(let t of e){this.bodies.delete(t);for(let e of Array.from(this.activeSensors))lt(e).bodyId===t&&this.activeSensors.delete(e)}}setColliders(e){this.colliders.clear(),this.activeSensors.clear(),this.nextColliderIndex=0;for(let t of e)this.colliders.set(t.id,{...t,shape:Ge(t.shape),bodyFilter:He(t.bodyFilter),index:this.nextColliderIndex}),this.nextColliderIndex+=1}setConstraint(e){let 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,i){let r=this.bodies.get(e);r&&(r.vx+=t/r.mass,r.vy+=i/r.mass,We(r),this.wake(r))}step(e=this.options.fixedDt){let t=Math.max(0,e);if(this.lastEvents=[],0===t)return;let i=this.sortedBodies();for(let e of i)e.prevX=e.x,e.prevY=e.y;this.applySprings(t);let r=this.options.maxVelocity;for(let e of i)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,We(e),r>0){let t=Math.sqrt(e.vx*e.vx+e.vy*e.vy);if(t>r){let i=r/t;e.vx*=i,e.vy*=i}}e.x+=e.vx*t,e.y+=e.vy*t}this.supportedThisStep.clear();let o=this.bodyPairKeys(i),n=this.sortedColliders().filter(e=>!e.sensor);for(let e=0;this.options.collisionIterations>e;e+=1)this.resolveBodyPairs(i,o,0===e),this.resolveColliders(i,n,0===e);this.updateSensors(i),this.updateSleeping(i,t)}settle(e=1200,t=this.options.fixedDt){let i=0;for(;e>i&&!this.allSleeping();)this.step(t),i+=1;return i}readState(e=[]){e.length=0;for(let 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,...t.fixedPosition?{fixedPosition:Ye(t.fixedPosition)}:{},shape:Xe(t.shape),sleeping:t.sleeping,datum:t.datum});return e}events(){return this.lastEvents.slice()}activeSensorPairs(){return Array.from(this.activeSensors).sort().map(lt)}allSleeping(){for(let 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(Ve),colliders:this.sortedColliders().map(Ue),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=je(this.options.seed),this.bodies.clear(),this.colliders.clear(),this.springs.clear(),this.activeSensors=new Set(e.activeSensors),this.lastEvents=[],this.nextBodyIndex=0;for(let t of e.bodies){let e=Ve(t);We(e),this.bodies.set(e.id,e),this.nextBodyIndex=Math.max(this.nextBodyIndex,e.index+1)}this.nextColliderIndex=0;for(let t of e.colliders){let e=Ue(t);this.colliders.set(e.id,e),this.nextColliderIndex=Math.max(this.nextColliderIndex,e.index+1)}this.nextSpringIndex=0;for(let t of e.springs){this.springs.set(t.id,{...t,target:{...t.target}});let 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(let t of Array.from(this.springs.values()).sort((e,t)=>e.id.localeCompare(t.id))){let i=this.bodies.get(t.bodyId);if(!i||i.sleeping)continue;let r="point"===t.target.type?t.target:this.bodies.get(t.target.bodyId);if(!r)continue;let o=r.x-i.x,n=r.y-i.y,a=Math.sqrt(o*o+n*n);if(Ep>=a)continue;let s=o/a,l=n/a,c=(a-t.restLength)*t.stiffness+((("vx"in r?r.vx:0)-i.vx)*s+(("vy"in r?r.vy:0)-i.vy)*l)*t.damping;i.vx+=c*s*e/i.mass,i.vy+=c*l*e/i.mass}}resolveBodyPairs(e,t,i){for(let r of t){let[t,o]=r.split(":").map(Number),n=e[t],a=e[o];if(!n||!a)continue;let s=nt(n,a);s&&(this.resolveDynamicCollision(n,a,s),i&&this.lastEvents.push({type:"contact",bodyId:n.id,otherId:a.id,sensor:!1}))}}bodyPairKeys(e){let t=Math.max(1,this.options.cellSize),i=new Map;for(let r=0;e.length>r;r+=1){if(!1===e[r].bodyCollisions)continue;let o=et(e[r]),n=Math.floor(o.minX/t),a=Math.floor(o.maxX/t),s=Math.floor(o.minY/t),l=Math.floor(o.maxY/t);for(let e=n;a>=e;e+=1)for(let t=s;l>=t;t+=1){let o=`${e}:${t}`,n=i.get(o);n?n.push(r):i.set(o,[r])}}let r=new Set;for(let t of Array.from(i.keys()).sort()){let o=i.get(t)??[];o.sort((e,t)=>e-t);for(let t=0;o.length>t;t+=1)for(let i=t+1;o.length>i;i+=1){let n=o[t],a=o[i];!1===e[n].bodyCollisions||!1===e[a].bodyCollisions||it(et(e[n]),et(e[a]))&&r.add(`${n}:${a}`)}}return Array.from(r).sort((e,t)=>{let[i,r]=e.split(":").map(Number),[o,n]=t.split(":").map(Number);return i===o?r-n:i-o})}resolveDynamicCollision(e,t,i){(e.fixedPosition||t.fixedPosition)&&(!e.sleeping&&null==e.fixedPosition?.x||!t.sleeping&&null==t.fixedPosition?.x?(e.sleeping||null!=e.fixedPosition?.y)&&(t.sleeping||null!=t.fixedPosition?.y)&&(i=qe(e,t,"y")):i=qe(e,t,"x")),e.sleeping&&this.contactOpposesGravity(i.nx,i.ny)&&this.supportedThisStep.add(t.id),t.sleeping&&this.contactOpposesGravity(-i.nx,-i.ny)&&this.supportedThisStep.add(e.id);let r=e.sleeping?0:1/e.mass,o=t.sleeping?0:1/t.mass,n=null==e.fixedPosition?.x?r:0,a=null==e.fixedPosition?.y?r:0,s=null==t.fixedPosition?.x?o:0,l=null==t.fixedPosition?.y?o:0,c=e.fixedPosition||t.fixedPosition?i.nx**2*(n+s)+i.ny**2*(a+l):r+o;if(Ep>=c)return;let u=Math.max(0,i.penetration-Np)/c;e.x-=i.nx*u*n,e.y-=i.ny*u*a,t.x+=i.nx*u*s,t.y+=i.ny*u*l;let d=(t.vx-e.vx)*i.nx+(t.vy-e.vy)*i.ny;if(d>0)return;let h=Math.abs(d),p=-(1+Ze(e.restitution,t.restitution,this.options.restitution))*d/c,f=p*i.nx,y=p*i.ny;e.vx-=f*n,e.vy-=y*a,t.vx+=f*s,t.vy+=y*l,this.applyFriction(e,t,i,p,r,o),h>this.options.contactWakeSpeed&&(this.wake(e),this.wake(t))}applyFriction(e,t,i,r,o,n){let a=-i.ny,s=i.nx,l=(t.vx-e.vx)*a+(t.vy-e.vy)*s,c=null==e.fixedPosition?.x?o:0,u=null==e.fixedPosition?.y?o:0,d=null==t.fixedPosition?.x?n:0,h=null==t.fixedPosition?.y?n:0,p=e.fixedPosition||t.fixedPosition?a**2*(c+d)+s**2*(u+h):o+n;if(Ep>=Math.abs(l)||Ep>=p)return;let f=Qe(e.friction,t.friction,this.options.friction),y=Ke(-l/p,-r*f,r*f),g=y*a,m=y*s;e.vx-=g*c,e.vy-=m*u,t.vx+=g*d,t.vy+=m*h}resolveColliders(e,t,i){for(let r of e)for(let e of t){if(!ut(e,r)||!it(et(r),tt(e)))continue;let t=at(r,e);t&&(this.resolveStaticCollision(r,e,t),this.contactOpposesGravity(t.nx,t.ny)&&this.supportedThisStep.add(r.id),i&&this.lastEvents.push({type:"contact",bodyId:r.id,otherId:e.id,sensor:!1}))}}resolveStaticCollision(e,t,i){e.x+=i.nx*Math.max(0,i.penetration-Np),e.y+=i.ny*Math.max(0,i.penetration-Np);let r=e.vx*i.nx+e.vy*i.ny;if(0>r){let o=Ze(e.restitution,t.restitution,this.options.restitution);e.vx-=(1+o)*r*i.nx,e.vy-=(1+o)*r*i.ny;let n=-i.ny,a=i.nx,s=e.vx*n+e.vy*a,l=Qe(e.friction,t.friction,this.options.friction);e.vx-=s*n*l,e.vy-=s*a*l}We(e)}updateSensors(e){let t=new Set,i=this.sortedColliders().filter(e=>e.sensor);for(let r of e){let e=et(r);for(let o of i){if(!ut(o,r)||!it(e,tt(o))||!at(r,o))continue;let i=st(o.id,r.id);t.add(i),this.activeSensors.has(i)||this.lastEvents.push({type:"sensor-enter",bodyId:r.id,sensorId:o.id})}}for(let e of Array.from(this.activeSensors).sort()){if(t.has(e))continue;let{sensorId:i,bodyId:r}=lt(e);this.lastEvents.push({type:"sensor-exit",bodyId:r,sensorId:i})}this.activeSensors=t}updateSleeping(e,t){let i=Math.hypot(this.options.gravity.x,this.options.gravity.y)>1;for(let r of e)this.options.sleepSpeed>Math.sqrt(r.vx*r.vx+r.vy*r.vy)&&this.options.sleepSpeed*t>Math.sqrt((r.x-r.prevX)*(r.x-r.prevX)+(r.y-r.prevY)*(r.y-r.prevY))&&(!i||this.supportedThisStep.has(r.id))?(r.sleepTime+=t,!r.sleeping&&r.sleepTime>=this.options.sleepAfter&&(r.sleeping=!0,r.vx=0,r.vy=0,this.lastEvents.push({type:"sleep",bodyId:r.id}))):r.sleeping?this.wake(r):r.sleepTime=0}contactOpposesGravity(e,t){let{x:i,y:r}=this.options.gravity,o=Math.hypot(i,r);return 1e-9>=o||-.2>(e*i+t*r)/o}wake(e){e.sleeping&&this.lastEvents.push({type:"wake",bodyId:e.id}),e.sleeping=!1,e.sleepTime=0}nextRandom(){return this.random()}},Bp=class{constructor(e={}){this.id="builtin",this.capabilities={...(new zp).capabilities,engine:"builtin"},this.world=new zp(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,i){this.world.applyImpulse(e,t,i)}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()}},jp=["binId","targetBin","category","windowIndex","lane","group"],Wp=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;let t=this.nextIndex;this.nextIndex+=1;let i=mt(gt(this.config.binAccessor,e,t))??function(e){for(let t of jp){let i=mt(yt(e,t));if(i)return i}return"sediment"}(e),r=mt(gt(this.config.labelAccessor,e,t))??i,o=function(e,t,i){if("number"==typeof e)return e;let r="function"==typeof e?e(t,i):"string"==typeof e?yt(t,e):1,o="number"==typeof r?r:Number(r);return Number.isFinite(o)?o:1}(this.config.valueAccessor,e,t),n=Math.max(0,Math.floor(this.config.retainBodyIds??12)),a=this.bins.get(i);return a||(a={id:i,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(i,a)),a.label=r,a.lastBodyId=e.id,a.lastDatum=e.datum,ht(a.x,e.x),ht(a.y,e.y),ht(a.value,o),n>0&&(a.bodyIds.push(e.id),a.bodyIds.length>n&&(a.bodyIds=a.bodyIds.slice(a.bodyIds.length-n))),xt(a)}clear(){this.bins.clear(),this.nextIndex=0}snapshot(){return Array.from(this.bins.values()).map(xt)}restore(e=[]){this.bins.clear();for(let 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:ft(t.x),y:ft(t.y),value:ft(t.value)});this.nextIndex=e.reduce((e,t)=>e+t.count,0)}totals(){let 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)}}},Yp={bodyLimit:1/0,eviction:"oldest",fixedDt:1/120,maxDeltaSeconds:.1,maxSubsteps:8,settleStepLimit:1200,timeScale:1},qp={chartId:"physics",chartType:"physics",sensors:{},onObservation:void 0,onSimulationStateChange:void 0},Xp={data:"data",domain:"domain",layout:"layout","scene-geometry":"sceneGeometry","scene-style":"sceneStyle","data-paint":"dataPaint","interaction-paint":"interactionPaint",overlay:"overlay",accessibility:"accessibility",evidence:"evidence"},Gp=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=Ot({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){let i=Ot(e,t,this.revisions);this.revisions=i.revisions,this.latest=i;for(let e of[...this.listeners])e();return i}};import{quadtree as Vp}from"d3-quadtree";var Hp=class{constructor(){this.maxSearchRadius=0,this.revision=-1,this.tree=null}hitTest(e,t,i,r,o,n=0,a){let s=this.ensure(e,t);if(!s)return null;let l=null,c=1/0,u=Math.max(0,a?.searchRadius??Math.max(0,n)+this.maxSearchRadius),d=r-u,h=r+u,p=o-u,f=o+u;return s.visit((e,t,s,u,y)=>{if(d>u||t>h||p>y||s>f)return!0;if(e.length)return!1;let g=e;for(;g;){let e=g.data;if(e&&(!a?.include||a.include(e))){let t=a?.distanceSquared?a.distanceSquared(e,r,o):It(e,r,o,Math.max(0,n));null!=t&&(c>t||t===c&&i.indexOf(e.id)>i.indexOf(l?.id??""))&&(l=e,c=t)}g=g.next}return!1}),l}ensure(e,t){if(this.tree&&this.revision===t)return this.tree;let i=e.readState();return 0===i.length?(this.tree=null,this.maxSearchRadius=0,this.revision=t,null):(this.maxSearchRadius=i.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=Vp().x(e=>e.x).y(e=>e.y).addAll(i),this.revision=t,this.tree)}},Up=["data","scene-geometry","data-paint","accessibility","evidence"],Kp=["scene-geometry","data-paint","accessibility","evidence"],Zp=["overlay","accessibility","evidence"],Qp=(e,t)=>({retainedData:e,invalidations:t}),Jp=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],ef=["scene-geometry","data-paint","accessibility","evidence"],tf=[],rf={engine:Qp("rebuild",["scene-geometry","data-paint","accessibility","evidence"]),kernel:Qp("preserve",ef),colliders:Qp("preserve",ef),sediment:Qp("preserve",ef),bodyBudget:Qp("preserve",Jp),bodyLimit:Qp("preserve",Jp),eviction:Qp("preserve",Jp),fixedDt:Qp("preserve",tf),maxDeltaSeconds:Qp("preserve",tf),maxSubsteps:Qp("preserve",tf),settleStepLimit:Qp("preserve",tf),timeScale:Qp("preserve",tf),observation:Qp("preserve",tf)},of=Qp("preserve",Jp),nf=["seed","fixedDt","cellSize","collisionIterations","velocityDamping","sleepSpeed","sleepAfter","restitution","friction","maxVelocity","contactWakeSpeed"],af=class{constructor(){this.seconds=0,this.speed=8,this.scratch=[]}setKernelOptions(e){this.speed=function(e){let 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,i){if(i>0)return void(this.seconds=0);let r=e.readState(this.scratch),o=this.speed*this.speed,n=!0;for(let e of r)if(!e.sleeping&&e.vx*e.vx+e.vy*e.vy>=o){n=!1;break}this.seconds=n?this.seconds+Math.max(0,t):0}},sf=class{constructor(e={}){this.activeSensorPairs=new Set,this.accumulator=0,this.bodyBudgetObservationKey="ok",this.bodySpatialIndex=new Hp,this.elapsedSeconds=0,this.liveBodyOrder=[],this.nextSequence=0,this.paused=!1,this.queue=[],this.revision=0,this.updateResults=new Gp,this.simulationState="settled",this.visible=!0,this.quiescence=new af;let{bodyBudget:t,colliders:i,engine:r,kernel:o,observation:n,sediment:a,...s}=e;this.config={...Yp,...s},this.configInput={...e},this.bodyBudget=t??{},this.engineInput=r,this.observation=vt(n),this.sediment=new Wp(a??!1),this.world=dt(r,{fixedDt:this.config.fixedDt,...o}),this.quiescence.setKernelOptions(o),i&&this.world.setColliders(Mt(i))}updateConfig(e){let t=function(e,t){return Object.keys(e).filter(i=>"kernel"===i?!Dt(e.kernel,t.kernel):e[i]!==t[i])}(e,this.configInput),{colliders:i,bodyBudget:r,engine:o,kernel:n,observation:a,sediment:s,...l}=e;if(this.config={...this.config,...l},void 0!==r&&(this.bodyBudget=r,!1===r&&(this.bodyBudgetObservationKey="ok")),o&&o!==this.engineInput){let e=this.world.snapshot();this.world.dispose(),this.engineInput=o,this.world=dt(o,e.options),this.world.restore(e),this.revision+=1}if(n&&!Dt(n,this.configInput.kernel)){let e=this.world.snapshot(),t={...e.options,...n,gravity:{...e.options.gravity,...n.gravity}};this.world.restore({...e,options:t}),this.quiescence.setKernelOptions(t),this.revision+=1}a&&(this.observation=vt(a,this.observation)),this.sediment.updateConfig(s),i&&(this.world.setColliders(Mt(i)),this.revision+=1),this.configInput={...this.configInput,...e};let c=Ft(t);this.updateResults.record({kind:"config",keys:t},c.invalidations)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}setColliders(e){this.world.setColliders(Mt(e)),this.revision+=1,this.updateResults.record({kind:"config",keys:["colliders"]},Ft(["colliders"]).invalidations)}enqueue(e,t){let i=Array.isArray(e)?e:[e],r=t?function(e,t={}){let i=kt(t.startAt)??0,r=t.pacing??"immediate";if("arrival"===r){let r=e.map((e,i)=>function(e,t,i){return"function"==typeof i?kt(i(e,t)):"string"==typeof i?kt(At(e,i)):kt(e.spawnAt)??kt(At(e,"arrivalTime"))??kt(At(e,"timestamp"))??kt(At(e,"time"))??kt(At(e,"eventTime"))}(e,i,t.timeAccessor)),o=r.filter(e=>null!=e),n=o.length>0?Math.min(...o):0,a=kt(t.timeScale)??1,s=a>0?a:1;return e.map((e,t)=>{let o=r[t],a=null==o?0:Math.max(0,o-n);return{...wt(e),spawnAt:i+a/s}})}if("object"==typeof r){let t=kt(r.ratePerSec);if(t&&t>0)return e.map((e,r)=>({...wt(e),spawnAt:i+r/t}))}return e.map(e=>({...wt(e),spawnAt:i}))}(i,{...t,startAt:t.startAt??this.elapsedSeconds}):i;for(let e of r)this.queue.push({...wt(e),sequence:this.nextSequence,spawnAt:e.spawnAt??this.elapsedSeconds}),this.nextSequence+=1;this.queue.sort(_t),r.length>0&&(this.revision+=1),this.updateResults.record({kind:"enqueue",count:r.length},r.length?Up:[])}enqueueWithResult(e,t){return this.enqueue(e,t),this.updateResults.last}spawnNow(e){this.spawnOne(wt(e)),this.nextSequence+=1,this.observeBodyBudget(),this.evictOverflow(),this.revision+=1,this.updateResults.record({kind:"enqueue",count:1},Up)}materializeDueSpawns(){let e=this.revision,t=[],i=[];return this.spawnDue(t,i),0===t.length||(this.observeBodyBudget(i),this.evictOverflow(i),this.syncSimulationState(i),this.revision+=1,this.updateResults.record({kind:"enqueue",count:t.length},this.revision!==e?Up:[])),t}clear(){let 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"},Up)}tick(e,t){let i=this.revision,r=[],o=[],n=[],a=[],s=[];if(this.paused||!this.visible){let e=this.result(0,r,o,n,a,s,!1);return this.updateResults.record({kind:"tick",count:0},[]),e}let l=Math.max(0,Math.min(Number.isFinite(e)?e:0,this.config.maxDeltaSeconds))*this.config.timeScale;this.spawnDue(r,s);let c=this.observeBodyBudget(s),u=this.evictOverflow(s);o.push(...u.evicted),n.push(...u.sedimented),this.syncSimulationState(s),r.length>0&&this.quiescence.reset(),this.accumulator+=l;let d=this.stepObserver(t,{spawned:r,evicted:o,sedimented:n,events:a,observations:s}),h=l>0?Math.floor((this.accumulator+1e-9*this.config.fixedDt)/this.config.fixedDt):0,{steps:p,budget:f}=Nt(this.settleHost(),Math.min(h,this.config.maxSubsteps),{spawned:r,evicted:o,sedimented:n,events:a,observations:s},{stopAtRest:!1,shouldStop:()=>this.paused||!this.visible,afterStep:d});this.accumulator=Math.max(0,this.accumulator-p*this.config.fixedDt),p===this.config.maxSubsteps&&(this.accumulator=Math.min(this.accumulator,this.config.fixedDt)),(p>0||r.length>0||o.length>0||n.length>0||a.length>0)&&(this.revision+=1);let y=this.result(p,r,o,n,a,s,void 0,f??c);return this.updateResults.record({kind:"tick",count:p},this.revision!==i?r.length||o.length||n.length?Up:Kp:[]),y}settle(e=this.config.settleStepLimit){return this.runSettle(e,!1).steps}settleWithObservations(e=this.config.settleStepLimit,t){return this.runSettle(e,!0,t)}stepObserver(e,t){return function(e,t){if(!e)return;let i=["spawned","evicted","sedimented","events","observations"],r={spawned:0,evicted:0,sedimented:0,events:0,observations:0},o=o=>{let n=t(o),a={...n,spawned:n.spawned.slice(r.spawned),evicted:n.evicted.slice(r.evicted),sedimented:n.sedimented.slice(r.sedimented),events:n.events.slice(r.events),observations:n.observations.slice(r.observations)};for(let e of i)r[e]=n[e].length;e.onStep(a)};return o(0),()=>o(1)}(e,e=>(e&&(this.revision+=1),this.result(e,t.spawned,t.evicted,t.sedimented,t.events,t.observations)))}settleHost(){return{fixedDt:this.config.fixedDt,queueSize:()=>this.queue.length,atRest:()=>this.atRest(),advanceTime:e=>{this.elapsedSeconds+=e},spawnDue:(e,t)=>this.spawnDue(e,t),observeBodyBudget:e=>this.observeBodyBudget(e),evictOverflow:e=>this.evictOverflow(e),step:e=>this.world.step(e),drainEvents:()=>this.world.events(),observeKernelEvents:(e,t)=>this.observeKernelEvents(e,t),observeSensorTransitions:e=>this.observeSensorTransitions(e),refreshQuiescence:(e,t)=>this.quiescence.refresh(this.world,e,t)}}runSettle(e,t,i){let r=this.revision,o=[],n=[],a=[],s=[],l=t?[]:void 0;if(t&&(this.paused||!this.visible)){let e=this.result(0,o,n,a,s,l??[],!1);return this.updateResults.record({kind:"settle",count:0},[]),e}this.spawnDue(o,l);let c=this.observeBodyBudget(l),u=this.evictOverflow(l);n.push(...u.evicted),a.push(...u.sedimented),this.syncSimulationState(l),o.length>0&&this.quiescence.reset();let d=t?{spawned:o,evicted:n,sedimented:a,events:s,observations:l}:{spawned:o},h=this.stepObserver(i,{spawned:o,evicted:n,sedimented:a,events:s,observations:l??[]}),{steps:p,budget:f}=Nt(this.settleHost(),e,d,{afterStep:h,continueWhile:i?.continueWhile,shouldStop:t?()=>this.paused||!this.visible:void 0}),y=o.length+n.length+a.length>0;(p>0||y||s.length>0)&&(this.revision+=1);let g=this.result(p,o,n,a,s,l??[],void 0,f??c);return this.updateResults.record({kind:"settle",count:p},this.revision===r?[]:y?Up:Kp),g}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={}){let{baselineY:i=0,binWidth:r=24,gap:o=2,maxHeight:n=80,value:a="count",x:s}=t,l=Math.max(1,...e.map(e=>e[a]));return e.map((e,t)=>{let c=Math.max(0,e[a]/l*n),u=s?.(e,t)??t*(r+o);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:i-c,width:r,height:c,meanX:e.x.mean,meanY:e.y.mean}})}(this.readSediment(),e)}hitTest(e,t,i=0,r){return this.bodySpatialIndex.hitTest(this.world,this.revision,this.liveBodyOrder,e,t,i,r)}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){let{timestamp:t,chartType:i,chartId:r,...o}=e,n={...o,timestamp:t??this.elapsedSeconds,chartType:i??this.observation.chartType,chartId:r??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(e){return this.updateResults.subscribe(e)}version(){return this.revision}setPaused(e){let t=this.paused!==e;this.paused=e,this.syncSimulationState(),this.updateResults.record({kind:"pause"},t?Zp:[])}setVisible(e){let t=this.visible!==e;this.visible=e,this.syncSimulationState(),this.updateResults.record({kind:"visibility"},t?Zp:[])}remove(e){let t=new Set(e),i=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);let o=e.filter(e=>i.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?Up:[]),o}setConstraint(e){let t=this.world.setConstraint(e);return this.revision+=1,this.updateResults.record({kind:"constraint",keys:[t]},Kp),t}removeConstraint(e){this.world.removeConstraint(e),this.revision+=1,this.updateResults.record({kind:"constraint",keys:[e]},Kp)}applyImpulse(e,t,i){this.world.applyImpulse(e,t,i),this.revision+=1,this.updateResults.record({kind:"impulse",keys:[e]},Kp)}nextRandom(){return this.world.nextRandom()}controls(){return e=this,{applyImpulse:(t,i,r)=>e.applyImpulse(t,i,r),clear:()=>e.clear(),hitTest:(t,i,r)=>e.hitTest(t,i,r),pause:()=>e.setPaused(!0),push:(t,i)=>e.enqueue(t,i),pushMany:(t,i)=>e.enqueue(t,i),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(){let e=this.world.snapshot();return{accumulator:this.accumulator,activeSensorPairs:Array.from(this.activeSensorPairs).sort(),bodyBudget:$t(this.bodyBudget),config:{...this.config,kernel:Pt(e.options)},elapsedSeconds:this.elapsedSeconds,paused:this.paused,queue:this.queue.map(St),revision:this.revision,sediment:this.readSediment(),simulationState:this.simulationState,liveBodyOrder:this.liveBodyOrder.slice(),visible:this.visible,world:e}}restore(e){let t=this.simulationState;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:$t(e.bodyBudget??{}),kernel:Pt(e.world.options)},this.bodyBudget=$t(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(St).sort(_t),this.revision=e.revision,this.sediment.restore(e.sediment??[]),this.simulationState=e.simulationState??Et(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"},Up),this.simulationState!==t&&this.observation.onSimulationStateChange?.(this.simulationState,t)}spawnDue(e,t){for(;this.queue.length>0&&this.elapsedSeconds+1e-9*this.config.fixedDt>=this.queue[0].spawnAt;){let i=this.queue.shift();if(!i)return;this.spawnOne(i,t),e.push(i.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(let t of e.springs??[])this.world.setConstraint({...t,bodyId:e.id});let i=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:i?.datum??e.datum,x:i?.x??e.x,y:i?.y??e.y},t)}result(e,t,i,r,o,n,a,s=this.evaluateBodyBudget()){this.syncSimulationState(n);let l=this.world.allSleeping();return{budget:s,elapsedSeconds:this.elapsedSeconds,evicted:i,events:o,observations:n,queueSize:this.queue.length,revision:this.revision,shouldContinue:a??(!this.paused&&this.visible&&(this.queue.length>0||!this.atRest())),sleeping:l,sedimented:r,spawned:t,steps:e}}observeKernelEvents(e,t){!function(e,t,i){if(0===t.length)return;let r=new Map(e.readState().map(e=>[e.id,e]));for(let e of t){if("sleep"!==e.type)continue;let t=r.get(e.bodyId);i.emit({type:"physics-settle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.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,i){let r=new Set(e.activeSensorPairs().map(e=>`${e.sensorId}\0${e.bodyId}`));if(0===r.size&&0===t.size)return r;let o=new Map(e.readState().map(e=>[e.id,e])),n=(e,t)=>{let{sensorId:r,bodyId:n}=Rt(t),a=i.observation.sensors[r],s=o.get(n);i.emit({type:"enter"===e?a?.enterType??"physics-bin-enter":a?.exitType??"physics-bin-exit",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,bodyId:n,datum:s?.datum,x:s?.x,y:s?.y,sensorId:r,binId:a?.binId??r})};for(let e of Array.from(r).sort())t.has(e)||n("enter",e);for(let e of Array.from(t).sort())r.has(e)||n("exit",e);return r}(this.world,this.activeSensorPairs,this.observationContext(e))}removeActiveSensorPairsForBodies(e){!function(e,t){for(let i of e)t.has(Rt(i).bodyId)&&e.delete(i)}(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){let t=Math.max(0,Math.floor(e.liveBodies)),i=Math.max(0,Math.floor(e.queuedBodies??0)),r=t+i,o=bt(e.bodyLimit),n=bt(e.engineMaxBodiesHint),a=function(e,t,i){if(!1===i)return;let r=bt(i?.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,n,e.options),s=null==o?0:Math.max(0,t-o),l=s>0?"overflow":null==a||a>r?"ok":"warning";return{action:"overflow"!==l?"continue":e.sedimentEnabled?"sediment":e.evictionEnabled?"evict":"retain",bodyLimit:o,engineMaxBodiesHint:n,liveBodies:t,overflow:s,projectedBodies:r,queuedBodies:i,state:l,warnAt:a}}({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){let t=this.evaluateBodyBudget();if("ok"===t.state||!1===this.bodyBudget)return this.bodyBudgetObservationKey="ok",t;let i=`${t.state}:${t.action}`;return i===this.bodyBudgetObservationKey||(this.bodyBudgetObservationKey=i,function(e,t){t.emit({type:"overflow"===e.state?"physics-budget-overflow":"physics-budget-warning",timestamp:t.elapsedSeconds,chartType:t.observation.chartType,chartId:t.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,this.observationContext(e))),t}syncSimulationState(e){let t=Et(this.paused,this.visible,this.queue.length>0,this.atRest());if(t===this.simulationState)return;let i=this.simulationState;this.simulationState=t,function(e,t,i){i.observation.onSimulationStateChange?.(t,e),("running"===t||"settled"===t)&&i.emit({type:"running"===t?"sim-active":"sim-idle",timestamp:i.elapsedSeconds,chartType:i.observation.chartType,chartId:i.observation.chartId,simulationState:t,previousSimulationState:e})}(i,t,this.observationContext(e))}evictOverflow(e){let{evicted:t,sedimented:i,liveBodyOrder:r}=function(e,t,i,r,o,n){let a={evicted:[],sedimented:[],liveBodyOrder:o};if(!1===i)return a;let s=Math.max(0,Math.floor(r));if(!Number.isFinite(s))return a;let l=o.length-s;if(0>=l)return a;let c=function(e,t,i){if("sleeping-first"!==t)return i.slice();let r=new Map(e.readState().map(e=>[e.id,e.sleeping])),o=[],n=[];for(let e of i)r.get(e)?o.push(e):n.push(e);return[...o,...n]}(e,i,o).slice(0,l);if(0===c.length)return a;let u=function(e,t,i,r){let o=new Map(e.readState().map(e=>[e.id,e])),n=[];for(let e of i){let i=o.get(e);if(!i)continue;let a=t.add(i);a&&(n.push(e),r.emit({type:"physics-sediment",timestamp:r.elapsedSeconds,chartType:r.observation.chartType,chartId:r.observation.chartId,bodyId:e,datum:i.datum,x:i.x,y:i.y,binId:a.id,count:a.count,total:a.total}))}return n}(e,t,c,n);e.remove(c);let d=new Set(c);return{evicted:c,sedimented:u,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:i}}};import{scaleLinear as lf}from"d3-scale";import{scaleLinear as cf}from"d3-scale";import{scaleLinear as uf}from"d3-scale";import{scaleOrdinal as df}from"d3-scale";var hf=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],pf=ri(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),ff=ri(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),yf=ri(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),gf=ri(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),mf=ri(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),xf=ri(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),bf=ri(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),vf=ri(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),wf=ri(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),kf=ri(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),Af=ri(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),Sf=ri(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),Mf={blues:pf,reds:ff,greens:yf,viridis:bf,oranges:gf,purples:mf,greys:xf,plasma:vf,inferno:wf,magma:kf,cividis:Af,turbo:Sf},$f=ri(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),_f=ri(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),Pf=ri(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),If=ri(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),Rf=ri(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),Lf=ri(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),Cf=ri(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),Tf={category10:hf,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],...Mf},Of=hf,Ff="#007bff",Df=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Ef=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],Nf=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"]),zf="gauntlet-negative",Bf={left:28,top:76,rightInset:30,thickness:8},jf=1e-9,Wf=[900,520],Yf=[{id:"product",label:"Products",side:"bottom",order:0},{id:"retained",label:"Retained",side:"bottom",order:1},{id:"residue",label:"Residue",side:"left",order:2},{id:"failed",label:"Failed",side:"right",order:3},{id:"recovered",label:"Recovered",side:"right",order:4}],qf=new Set(["queued","active","transformed","consumed","retained","ejected","failed","recovered"]),Xf=1e-9,Gf=sr;import*as Vf from"react";var Hf=new WeakMap,Uf=null;import{jsx as Kf,jsxs as Zf}from"react/jsx-runtime";var Qf=new Map;import{curveMonotoneX as Jf,curveMonotoneY as ey,curveCardinal as ty,curveCatmullRom as iy,curveStep as ry,curveStepBefore as oy,curveStepAfter as ny,curveBasis as ay,curveNatural as sy}from"d3-shape";import{jsx as ly,jsxs as cy}from"react/jsx-runtime";import{Fragment as uy,jsx as dy,jsxs as hy}from"react/jsx-runtime";var py="var(--semiotic-text, #26323a)",fy="var(--semiotic-text-secondary, #6c7377)",yy="var(--semiotic-primary, #b8792d)",gy="var(--semiotic-danger, #9f3d35)",my="var(--semiotic-success, #356b63)",xy=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],by={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}},vy={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}},wy={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:xy,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"},ky={light:by,dark:vy,"high-contrast":wy,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"}};import{Fragment as Ay,jsx as Sy,jsxs as My}from"react/jsx-runtime";import{Fragment as $y,jsx as _y,jsxs as Py}from"react/jsx-runtime";var Iy={flow:{fill:"rgba(59, 130, 246, 0.14)",stroke:"rgba(96, 165, 250, 0.7)",accent:"#60a5fa"},capacity:{fill:"rgba(251, 146, 60, 0.18)",stroke:"rgba(251, 146, 60, 0.85)",accent:"#fb923c"},portal:{fill:"rgba(244, 114, 182, 0.14)",stroke:"rgba(244, 114, 182, 0.7)",accent:"#f472b6"},absorb:{fill:"rgba(52, 211, 153, 0.18)",stroke:"rgba(52, 211, 153, 0.8)",accent:"#34d399"}};import{jsx as Ry}from"react/jsx-runtime";import{jsx as Ly,jsxs as Cy}from"react/jsx-runtime";import{Fragment as Ty,jsx as Oy,jsxs as Fy}from"react/jsx-runtime";var Dy={margin:(e,t)=>t.compactMode?"sparkline"===e.mode?{top:2,right:2,bottom:2,left:2}:{top:8,right:8,bottom:8,left:8}:{top:0,right:0,bottom:0,left:0}},Ey=["#356b63","#a34b43","#c08b38","#3e5f83","#785b7c","#6e7740","#8f5c3a","#41717b"],Ny={frameType:"physics",layout:Dy,buildProps:(e,t,i,r,o)=>{let n=r.size??[600,400],a=o.bins??21,s=o.seed??1,l=Math.max(1,Math.round(o.pegRows??a-1)),c="mechanical"===(o.simulationMode??o.mode),u=c?function(e){let t=Math.max(2,Math.round(e.bins)),i=Math.max(1,Math.round(e.pegRows??t-1)),r=Math.max(1,Math.round(e.count??Math.max(64,4*t))),o=De(Number.isFinite(e.branchProbability)?e.branchProbability??.5:.5,0,1),n=ze(e.seed??1),a=e.idPrefix??"mechanical";return Array.from({length:r},(e,t)=>{let r=0;for(let e=0;i>e;e+=1)n()<o&&(r+=1);let s=i/2;return{id:`${a}-${t}`,value:r,mechanical:!0,pegRows:i,branchProbability:o,pathRights:r,side:s>r?"left":r>s?"right":"center"}})}({bins:a,branchProbability:o.branchProbability,count:o.mechanicalCount,pegRows:l,seed:s}):Array.isArray(e)?e:[],d=function(e){let{data:t,valueAccessor:i,bins:r,ballRadius:o,seed:n,size:a,valueExtent:s}=e,{rows:l}=Be(t,"galton"),c=Re(a),u=l.map((e,t)=>Fe(Oe(e,t,i))).filter(e=>null!=e),d=function(e){if(!e)return;let t=Fe(e[0]),i=Fe(e[1]);return null!=t&&null!=i?t>i?[i,t]:[t,i]:void 0}(s),h=d?.[0]??(u.length?Math.min(...u):0),p=d?.[1]??(u.length?Math.max(...u):1),f=p===h?1:p-h,y=Fp().domain([0,r]).range([c.plot.x,c.plot.x+c.plot.width]),g=Array.from({length:r},()=>0),m=[];l.forEach((e,t)=>{let n=Fe(Oe(e,t,i));if(null==n)return;let a=Math.max(0,Math.min(r-1,Math.floor((n-h)/f*r)));g[a]+=1,m.push({id:(e.id??"galton-"+t)+"",x:y(a+.5),y:c.plot.y+o+2,vx:8*(t%5-2),vy:0,mass:1,shape:{type:"circle",radius:o},datum:{...e,value:n,bin:a}})});let x=c.plot.y+c.plot.height;return{config:Te(n,[...Lt({x:c.plot.x,y:c.plot.y,width:c.plot.width,height:c.plot.height},{idPrefix:"galton",wallThickness:20,floorThickness:20}),...Ct({idPrefix:"galton-bin",count:r,domainStart:0,domainStep:1,xScale:y,yTop:c.plot.y-400,yBottom:x,wallThickness:6})],"GaltonBoardChart"),initialSpawns:m,initialSpawnPacing:{pacing:{ratePerSec:55}},projectionRows:g.map((e,t)=>({label:t+1+"",value:e})),metadata:{kind:"galton-board",bins:r,plot:c.plot,valueExtent:[h,p]}}}({data:u,valueAccessor:o.valueAccessor||"value",bins:a,ballRadius:o.ballRadius??("sparkline"===o.mode?1.5:"context"===o.mode?4:6),seed:s,size:n,valueExtent:c?[0,l]:o.valueExtent});return{...r,config:d.config,initialSpawns:Gr(d.initialSpawns),projectionRows:d.projectionRows,foregroundGraphics:Vr(Lr(d.projectionRows,a,Hr(r,o,"showProjection"),d.metadata,o.referenceLines),r.foregroundGraphics),bodyStyle:Ce(t||o.colorBy||(c?"side":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},zy={frameType:"physics",layout:Dy,buildProps:(e,t,i,r,o)=>{let n=r.size??[600,400],a=function(e){let{data:t,timeAccessor:i,arrivalAccessor:r,windows:o,watermark:n,watermarkAtArrivalAccessor:a,ballRadius:s,seed:l,size:c,timeExtent:u,timeScale:d=1}=e,{events:h,watermarkValue:p}=function(e){let{windowSize:t,watermark:i,watermarkAtArrivalAccessor:r}=e;if(!Number.isFinite(t)||0>=t)throw new RangeError("EventDrop windows.size must be a finite positive number");let{rows:o}=Be(e.data,"event"),n=o.flatMap((t,i)=>{let r=Fe(Oe(t,i,e.timeAccessor));return null==r?[]:[{datum:t,index:i,eventTime:r,arrivalTime:Fe(Oe(t,i,e.arrivalAccessor))??r,watermarkAtArrival:0,late:!1}]}),a="function"==typeof i?null:Fe(i?.value),s="function"==typeof i?t:Fe(i?.delay)??t,l=-1/0,c=-1/0;for(let e of n.slice().sort((e,t)=>e.arrivalTime-t.arrivalTime||e.index-t.index)){l=Math.max(l,e.eventTime);let o="function"==typeof i?Fe(i(l)):l-s;c=a??Math.max(c,o??l-t);let n=r?Fe(Oe(e.datum,e.index,r)):null;e.watermarkAtArrival=n??c,e.late=e.watermarkAtArrival>=(Math.floor(e.eventTime/t)+1)*t}return{events:n,watermarkValue:n.length?c:a??-s}}({data:t,timeAccessor:i,arrivalAccessor:r,watermark:n,watermarkAtArrivalAccessor:a,windowSize:o.size}),f=Re(c),y=h.map(e=>e.eventTime),g=h.length?Math.min(...h.map(e=>e.arrivalTime)):0,m=Fe(u?.[0]),x=Fe(u?.[1]),b=y.length?Math.min(...y):0,v=y.length?Math.max(...y):b+o.size,w=Math.min(m??b,b),k=Math.max(x??v,v),A=Math.floor(w/o.size)*o.size,S=Math.max(1,Math.ceil((k-A+o.size)/o.size)),M=Math.max(0,Math.min(S,Array.from({length:S},(e,t)=>t).reduce((e,t)=>A+(t+1)*o.size>p?e:e+1,0))),$=function(e,t){let i=Math.max(5*t,Math.min(92,.13*e.plot.width));return{gutter:{x:e.plot.x,y:e.plot.y,width:i,height:e.plot.height},windowPlot:{x:e.plot.x+i,y:e.plot.y,width:Math.max(40,e.plot.width-i),height:e.plot.height},wallTop:e.plot.y+.48*e.plot.height}}(f,s),_=A+S*o.size,P=lf().domain([A,_]).range([$.windowPlot.x,$.windowPlot.x+$.windowPlot.width]),I=Array.from({length:S},()=>({value:0,secondary:0})),R=[];h.forEach(({datum:e,index:t,eventTime:i,arrivalTime:r,watermarkAtArrival:n,late:a})=>{let l=Math.max(0,Math.min(S-1,Math.floor((i-A)/o.size)));I[l].value+=a?0:1,I[l].secondary+=a?1:0,R.push({id:(e.id??"event-"+t)+"",x:Bt(i,l,a,{windowStart:A,windowSize:o.size,gutter:$.gutter,closedWindowCount:M,windowPlot:$.windowPlot,windowCount:S},s),y:f.plot.y+s+2,vx:0,vy:0,mass:1,friction:.02,spawnAt:r,shape:{type:"circle",radius:s},datum:{...e,eventTime:i,arrivalTime:r,windowIndex:l,watermarkAtArrival:n,late:a}})});let L=f.plot.y+f.plot.height,C={closedWindowCount:M,gutter:$.gutter,plot:f.plot,windowCount:S,windowPlot:$.windowPlot,windowSize:o.size,windowStart:A},T=function(e,t){let i=Math.max(0,Math.min(e.windowCount,e.closedWindowCount));if(!i)return[];let r=e.windowStart,o=e.windowStart+e.windowCount*e.windowSize,n=lf().domain([r,o]).range([e.windowPlot.x,e.windowPlot.x+e.windowPlot.width]),a=n(e.windowStart+i*e.windowSize),s=e.windowPlot.x,l=t+Math.max(18,Math.min(.3*e.windowPlot.height,a-s)),c=e=>a===s?t:l+(e-s)/(a-s)*(t-l),u=[];for(let t=0;i>t;t+=1){let i=e.windowStart+t*e.windowSize,r=i+e.windowSize,o=n(i),a=n(r);u.push({id:"eventdrop-lid-"+t,windowIndex:t,x1:o,y1:c(o),x2:a,y2:c(a)})}return u}(C,f.plot.y+.28*f.plot.height);for(let e of R){let t=e.datum;e.y=zt({...C,lidSegments:T},t.windowIndex,t.late,s)}let O=function(e){let{count:t,idPrefix:i,wallThickness:r,xScale:o,yBottom:n,yTop:a,yTopForIndex:s}=e;return Array.from({length:t+1},(e,t)=>{let l=Math.min(n-1,s?.(t)??a),c=Math.max(1,n-l);return{id:`${i}-wall-${t}`,shape:{type:"aabb",x:o(t),y:l+c/2,width:r,height:c}}})}({idPrefix:"eventdrop-window",count:S,xScale:e=>P(A+e*o.size),yTop:$.wallTop,yTopForIndex:e=>{let t=(e=>{if(0>e||e>M)return null;let 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?$.wallTop:t+1.25*s},yBottom:L,wallThickness:6});return{config:Te(l,[...Lt({x:f.plot.x,y:f.plot.y,width:f.plot.width,height:f.plot.height},{idPrefix:"eventdrop",wallThickness:20,floorThickness:20}),...O,...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:R,initialSpawnPacing:{pacing:"arrival",timeAccessor:e=>{let t=e.datum,i=M>t.windowIndex;return i&&!t.late||!i&&t.late?g:t.arrivalTime},timeScale:d},projectionRows:I.map((e,t)=>({label:`${A+t*o.size}-${A+(t+1)*o.size}`,value:e.value,secondary:e.secondary})),metadata:{kind:"event-drop",closedWindowCount:M,gutter:$.gutter,lidSegments:T,lateCount:I.reduce((e,t)=>e+t.secondary,0),plot:f.plot,windowPlot:$.windowPlot,windowWalls:O.map(({id:e,shape:t})=>({id:e,x:t.x-t.width/2,y:t.y-t.height/2,width:t.width,height:t.height})),watermarkValue:p,windowCount:S,windowSize:o.size,windowStart:A}}}({data:Array.isArray(e)?e:[],timeAccessor:o.timeAccessor||"time",arrivalAccessor:o.arrivalAccessor||"arrivalTime",watermarkAtArrivalAccessor:o.watermarkAtArrivalAccessor,windows:o.windows||{size:10},watermark:o.watermark,ballRadius:o.ballRadius??7,seed:o.seed??1,size:n,timeExtent:o.timeExtent,timeScale:o.timeScale??1});return{...r,config:a.config,initialSpawns:Gr(a.initialSpawns),projectionRows:a.projectionRows,foregroundGraphics:Vr(Cr(a.projectionRows,a.metadata,Hr(r,o,"showProjection")),r.foregroundGraphics),bodyStyle:Ce(t||o.colorBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||o.timeAccessor||"time"})}}},By={frameType:"physics",layout:Dy,buildProps:(e,t,i,r,o)=>{let n=r.size??[600,400],a="mechanical"===(o.simulationMode??o.mode),s=function(e){function t(e){let t=p.get(e);return null==t&&(t=h.length,h.push(e),p.set(e,t)),t}let{data:i,categoryAccessor:r,valueAccessor:o,unitValue:n,ballRadius:a,seed:s,size:l}=e,c=Ee(n,1),{rows:u}=Be(i,"pile"),d=Re(l),h=[],p=new Map,f=new Map,y=[];u.forEach((e,i)=>{t((Oe(e,i,r)??"unknown")+"")});let g=Math.max(1,h.length),m=jt(d.plot,g,a),x=Math.max(0,m.tubeWidth/2-a-1),b=h.map(()=>[]);u.forEach((e,i)=>{let n=(Oe(e,i,r)??"unknown")+"",s=t(n),l=o?Fe(Oe(e,i,o)):1,u=Math.max(0,l??0);f.set(n,(f.get(n)??0)+u);let h=function(e,t){let i=e/t,r=Math.round(i);return Math.ceil(r>0&&Number.EPSILON*i*4>=Math.abs(i-r)?r:i)}(u,c),p=m.centerX(s);for(let t=0;h>t;t+=1){let r=b[s].length,o=t===h-1?u-t*c:c,l=Math.min(1,o/c);b[s].push({id:`${(e.id??"pile-"+i)+""}-${t}`,x:p+(m.perRow>1?((m.perRow>1?r%m.perRow:0)/(m.perRow-1)*2-1)*x:0),y:d.plot.y+a+2,vx:(t%3-1)*a/2,vy:0,mass:1,shape:{type:"circle",radius:a*Math.sqrt(l)},datum:{...e,category:n,unitIndex:t,unitValue:c,representedValue:o,unitFraction:l}})}});let v=b.reduce((e,t)=>Math.max(e,t.length),0);for(let e=0;v>e;e+=1)for(let t of b)t.length>e&&y.push(t[e]);let w=d.plot.y+d.plot.height,k=[...Lt({x:d.plot.x,y:d.plot.y,width:d.plot.width,height:d.plot.height},{idPrefix:"pile",wallThickness:20,floorThickness:20})],A=d.plot.y-400;for(let e=0;g>e;e+=1){let t=m.centerX(e);for(let i of[-1,1])k.push({id:`pile-tube-${e}-${0>i?"l":"r"}`,shape:{type:"aabb",x:t+i*m.tubeWidth/2,y:(A+w)/2,width:6,height:w-A}})}return{config:Te(s,k,"UnitPileChart"),initialSpawns:y,initialSpawnPacing:{pacing:{ratePerSec:20}},projectionRows:h.map(e=>({label:e,value:f.get(e)??0}))}}({data:a?function(e={}){let t=(e.categories?.length?e.categories:["Intake","Review","Build","Ship"]).map(e=>(e+"").trim()).filter(Boolean),i=t.length?t:["Intake"],r=Math.max(i.length,Math.round(e.count??Math.max(48,12*i.length))),o=Ee(e.unitValue,1),n=ze(e.seed??1),a=e.idPrefix??"mechanical-pile",s=i.map(()=>.65+.9*n()),l=s.reduce((e,t)=>e+t,0)||1,c=r-i.length,u=s.map(e=>e/l*c),d=u.map(e=>1+Math.floor(e)),h=r-d.reduce((e,t)=>e+t,0),p=u.map((e,t)=>({index:t,fraction:e-Math.floor(e)})).sort((e,t)=>t.fraction-e.fraction);for(let e=0;h>0;e=(e+1)%p.length)d[p[e].index]+=1,h-=1;return i.map((e,t)=>({id:`${a}-${t}`,category:e,value:d[t]*o,mechanical:!0,unitCount:d[t],unitValue:o,share:d[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||(a?"value":void 0),unitValue:o.unitValue??1,ballRadius:o.ballRadius??8,seed:o.seed??1,size:n});return{...r,config:s.config,initialSpawns:Gr(s.initialSpawns),projectionRows:s.projectionRows,foregroundGraphics:Vr(Tr(s.projectionRows,o.ballRadius??8,Hr(r,o,"showProjection"),Number.isFinite(o.unitValue)&&o.unitValue>0?o.unitValue:1),r.foregroundGraphics),bodyStyle:Ce(t||o.colorBy||(a?"category":void 0),"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.valueAccessor||"value"})}}},jy={frameType:"physics",layout:Dy,buildProps:(e,t,i,r,o)=>{let n=r.size??[600,360],a=function(e){let{data:t,xAccessor:i,groupAccessor:r,radiusAccessor:o,pointRadius:n,seed:a,size:s,xExtent:l,collisionIterations:c,settle:u}=e,{rows:d}=Be(t,"collision-swarm"),h=Re(s),p=ze(a),f=[],y=[],g=new Map;d.forEach((e,t)=>{let a=Fe(Oe(e,t,i));if(null==a)return;let s=r?(Oe(e,t,r)??"All")+"":"All",l=o?Fe(Oe(e,t,o)):null,c=De(null!=l&&l>0?l:n,2,18);(function(e){let t=g.get(e);null==t&&(t=y.length,y.push(e),g.set(e,t))})(s),f.push({datum:e,index:t,value:a,group:s,radius:c})});let m=f.map(e=>e.value),x=l?Fe(l[0]):null,b=l?Fe(l[1]):null,v=m.length?Math.min(...m):0,w=m.length?Math.max(...m):1,k=x??v,A=b??w;if(k===A&&(k-=.5,A+=.5),k>A){let e=A;A=k,k=e}let S=Math.max(n,...f.map(e=>e.radius)),M=h.plot.x+S+8,$=h.plot.x+h.plot.width-S-8,_=cf().domain([k,A]).range([M,$]),P=h.plot.height/Math.max(1,y.length),I=Math.min(6,.05*P),R=e=>h.plot.y+((g.get(e)??0)+.5)*P,L=new Map,C=new Set,T=new Map;for(let e of y){let t=f.filter(t=>t.group===e),i=R(e),r=t.map(e=>({x:_(e.value),radius:e.radius})),o=Wt(r,i-P/2+I,i+P/2-I,p);L.set(e,t.length),o.overlapping&&C.add(e),t.forEach((e,t)=>T.set(e.index,{x:r[t].x,y:o.positions[t],entryOffset:o.entryOffset}))}let O=f.map((e,t)=>{let i=T.get(e.index),r=i.x,o=i.y,n=C.has(e.group);return{id:(e.datum.id??"collision-swarm-"+t)+"",x:r,y:o-(u?0:i.entryOffset),vx:0,vy:0,fixedPosition:{x:r},bodyCollisions:!n,mass:1,shape:{type:"circle",radius:e.radius},datum:{...e.datum,xValue:e.value,group:e.group,radius:e.radius,targetX:r,targetY:o,overlapping:n},springs:[{target:{type:"point",x:r,y:o},restLength:0,stiffness:34,damping:12}]}});return{config:Te(a,Lt({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:O,projectionRows:y.map(e=>({label:e,value:L.get(e)??0})),metadata:{kind:"collision-swarm",xExtent:[k,A],xRange:[M,$],groups:y.map(e=>({label:e,y:R(e),count:L.get(e)??0,overlapping:C.has(e)})),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:n,xExtent:o.xExtent,collisionIterations:o.collisionIterations,settle:o.settle});return{...r,config:a.config,initialSpawns:Gr(a.initialSpawns),projectionRows:a.projectionRows,foregroundGraphics:Vr(Fr(a.metadata,Hr(r,o,"showProjection")),r.foregroundGraphics),bodyStyle:Ce(t||o.colorBy||o.groupAccessor,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.xAccessor||"x"})}}},Wy={frameType:"physics",layout:Dy,buildProps:(e,t,i,r,o)=>{let n=r.size??[900,420],a=Array.isArray(o.stages)?o.stages:[],s=function(e){let t=e.stages;if(!t.length)throw Error("buildProcessFlowPhysics requires at least one stage");let i=e.size,r=Re(i),o=De(e.ballRadius??6,2,18),n=e.seed??1,a=ze(n),s=e.idAccessor,l=e.stageAccessor??"stage",c=e.groupBy,u=e.groupLabelAccessor,d=e.workAccessor,h=e.radiusAccessor,p=e.groupCompletion??(c?"allAbsorbed":"none"),f=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=Zt({width:i[0],height:i[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],A=new Set(t.filter(e=>e.absorb).map(e=>e.id)),S=t.map(e=>{let t=v.get(e.id)??k;return function(e,t){let i={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){let t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...Qt({...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"}}({...i,kind:e.kind??"sink",force:ei(e.force,28),damping:e.damping??.04,charge:"absorbed",attributes:{...i.attributes,primitive:"absorb"}});if(e.portal){let t=e.portal.force??e.force??{x:-40,y:0};return r={...i,kind:e.kind??"force-field",force:ei(t,-40),damping:e.damping??.1,targetStage:e.portal.targetStageId,attributes:{...i.attributes,primitive:"portal",targetStage:e.portal.targetStageId}},{...Qt({...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){let t=Math.max(.1,e.capacity.unitsPerSecond);return function(e){let t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...Qt({...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}}({...i,kind:e.kind??"force-field",capacity:t,unitsPerSecond:t,force:ei(e.force,10+.8*t),damping:e.damping??Math.max(.04,.32-.01*t),attributes:{...i.attributes,unitAccessor:e.capacity.unitAccessor,reviewerCapacity:t}})}if(e.pressure){let t="object"==typeof e.pressure&&e.pressure?e.pressure:{};return function(e){let t=e.pressure??e.occupancy??0,i=e.baseDamping??.08,r=e.dampingPerUnit??.12,o=e.energyPerUnit??0;return{...Qt({...e,kind:e.kind??"membrane",attributes:{primitive:"pressureField",pressure:t,..."object"==typeof e.attributes&&e.attributes?e.attributes:{}}}),damping:i+t*r,energyDelta:o?-t*o:void 0,force:e.force}}({...i,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:ei(e.force,8),attributes:{...i.attributes,primitive:"pressureField"}})}return null!=e.force||null!=e.damping?Jt({...i,kind:e.kind??"force-field",force:ei(e.force,14),damping:e.damping??.02,attributes:{...i.attributes,primitive:"routeSurface"}}):function(e){return{...Qt({...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}}({...i,kind:e.kind??"force-field",force:{x:10,y:0},damping:.02,attributes:{...i.attributes,primitive:"forceField"}})}(e,{x:t.x,y:x.midY,width:t.width,height:x.bottomY-x.topY})});S.unshift(Jt({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}));let M=new Map;for(let e of x.stages)M.set(e.id,0);let $=[];e.data.forEach((e,t)=>{let i=(s?Oe(e,t,s)??e.id??"process-flow-"+t:e.id??"process-flow-"+t)+"",r=(Oe(e,t,l)??w)+"",n=b.has(r)?r:w;M.set(n,(M.get(n)??0)+1);let a=c?(Oe(e,t,c)??"")+"":void 0,p=a&&u?(Oe(e,t,u)??a)+"":a,f=d?Fe(Oe(e,t,d))??1:1,y=h?Fe(Oe(e,t,h)):null,g=De(null!=y&&y>0?y:o,2,18);$.push({datum:e,id:i,stageId:n,groupId:a||void 0,groupLabel:p||void 0,work:f,radius:g,index:t})});let _=new Map,P=new Map;for(let e of $){if(!e.groupId)continue;let t=_.get(e.groupId)??[];t.push(e.id),_.set(e.groupId,t),e.groupLabel&&P.set(e.groupId,e.groupLabel)}let I=De(e.groupAnchorAlong??.55,.15,.9),R=x.left+(x.right-x.left)*I,L=Array.from(_.keys()),C=L.map((e,i)=>{let r=_.get(e)??[],o=L.length>1?x.topY+28+i/Math.max(1,L.length-1)*(x.bottomY-x.topY-56):x.midY;return function(e){let t=e.x??e.anchor?.x??0,i=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:i,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:i},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}({id:e,label:P.get(e)??e,bodyIds:r,anchor:{x:R,y:o},x:R,y:o,completion:"allAbsorbed"===p?{mode:"allMembersAbsorbed",targetZone:t.find(e=>e.absorb)?.id??"merged"}:void 0,tether:{stiffness:.06,visible:!0,restLength:18}})}),T=function(e,t){let i=t instanceof Set?t:new Set(t);return e.map(e=>{let t=e.bodyIds??[],r=t.filter(e=>!i.has(e)),o=t.length-r.length,n=e.completion?.mode??"allMembersAbsorbed",a=e.completion?.valueByBodyId,s=e=>{let t=a&&Object.prototype.hasOwnProperty.call(i=a,r=e)?i[r]:void 0;var i,r;return"number"==typeof t&&Number.isFinite(t)&&t>=0?t:1},l=t.reduce((e,t)=>e+s(t),0),c=t.reduce((e,t)=>e+(i.has(t)?s(t):0),0),u=e.completion?.threshold,d="threshold"===n?Number.isFinite(u)&&Number(u)>=0?Number(u):l:void 0;return{id:e.id,label:e.label??e.id,mode:n,complete:t.length>0&&("anyAbsorbed"===n?o>0:"threshold"===n?c>=(d??l):0===r.length),absorbed:o,total:t.length,absorbedValue:c,totalValue:l,threshold:d,missing:r}})}(C,$.filter(e=>A.has(e.stageId)).map(e=>e.id)),O=new Map(C.map(e=>[e.id,e])),F=$.map((e,t)=>{let i=v.get(e.stageId)??k,r=i.x+(a()-.5)*Math.min(24,.2*i.width),o=x.boundaryY(r,"top")+e.radius+10,n=x.boundaryY(r,"bottom")-e.radius-10,s=n>o?o+a()*Math.max(1,n-o):x.midY,l=g?r:x.left+18+t%7*4,c=g?s:x.midY+(a()-.5)*(x.bottomY-x.topY)*.35,u=[{target:{type:"point",x:r,y:s},restLength:.45*e.radius,stiffness:f,damping:y}];if(e.groupId){let t=O.get(e.groupId);t?.anchor&&!A.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*a(),vy:g?0:20*(a()-.5),mass:1,shape:{type:"circle",radius:e.radius},spawnAt:g?0:.03*t,springs:u,datum:{...e.datum,id:e.id,stage:e.stageId,groupId:e.groupId,groupLabel:e.groupLabel,work:e.work,__processFlow:!0}}}),D={kernel:{seed:n,gravity:{x:e.gravityX??22,y:e.gravityY??0},restitution:.14,friction:.48,velocityDamping:.988,maxVelocity:420,sleepSpeed:8,sleepAfter:.9,collisionIterations:4},colliders:x.colliders,fixedDt:1/60,maxSubsteps:8},E=x.stages.map(e=>({label:e.label??e.id,value:M.get(e.id)??0})),N=t.map(e=>{let t=v.get(e.id)??k;return{id:e.id,label:e.label??e.id,x:t.x,width:t.width,count:M.get(e.id)??0,capacity:e.capacity?.unitsPerSecond,absorb:!0===e.absorb,portalTarget:e.portal?.targetStageId}});return{config:D,initialSpawns:F,initialSpawnPacing:g?void 0:{pacing:"arrival",timeAccessor:"spawnAt",timeScale:1},projectionRows:E,metadata:{kind:"process-flow",plot:r.plot,volume:x,stages:N,groups:C,groupCompletion:T,regionEffects:S}}}({data:Array.isArray(e)?e:[],stages:a,size:n,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=s.metadata;return{...r,config:s.config,initialSpawns:Gr(s.initialSpawns),projectionRows:s.projectionRows,regionEffects:l?.regionEffects,backgroundGraphics:Vr(zr(s.metadata,Hr(r,o,"showChrome"),{},o.chromeOptions),r.backgroundGraphics),foregroundGraphics:Vr(Br(s.projectionRows,s.metadata,Hr(r,o,"showProjection")),r.foregroundGraphics),bodyStyle:Ce(t||o.colorBy||o.groupBy,"#4e79a7",{styleRules:o.styleRules,valueAccessor:o.workAccessor||o.stageAccessor||"stage"})}}},Yy={frameType:"physics",layout:Dy,buildProps:(e,t,i,r,o)=>{let n=r.size??[900,520],a=Ai({data:Array.isArray(e)?e:[],size:n,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:a.config,initialSpawns:Gr(a.initialSpawns),projectionRows:[],backgroundGraphics:Vr(Hr(r,o,"showChrome")?Op.createElement(qr,{layout:a.layout,states:a.states,compact:!0===r.__compactMode}):void 0,r.backgroundGraphics),foregroundGraphics:Vr(Hr(r,o,"showProjection")?Op.createElement(Xr,{layout:a.layout,states:a.states}):void 0,r.foregroundGraphics),bodyStyle:Ce(t||o.colorBy)}}},qy={frameType:"physics",layout:Dy,buildProps:(e,t,i,r,o)=>{let n=r.size??[900,520],a=ur({data:Array.isArray(e)?e:[],phases:Array.isArray(o.phases)?o.phases:[],products:Array.isArray(o.products)?o.products:void 0,outlets:Array.isArray(o.outlets)?o.outlets:void 0,events:Array.isArray(o.events)?o.events:void 0,idAccessor:o.idAccessor,labelAccessor:o.labelAccessor,categoryAccessor:o.categoryAccessor,amountAccessor:o.amountAccessor,metricsAccessor:o.metricsAccessor,initialStateAccessor:o.initialStateAccessor,metrics:o.metrics,size:n,seed:o.seed,bodyRadius:"number"==typeof o.bodyRadius?o.bodyRadius:void 0,radiusRange:o.radiusRange}),s="snapshot"===o.playback?function(e,t){if(void 0===t)return e.duration;if("number"==typeof t)return Math.max(0,Math.min(e.duration,Vi(t)??0));let i=e.phases.find(e=>e.id===t.phaseId);if(!i)return e.duration;let r=Math.max(0,Math.min(1,Vi(t.progress??0)??0));return i.start+i.duration*r}(a,o.snapshotAt):a.duration,l=cr(a,s).state,c=o.projection&&"object"==typeof o.projection?o.projection:{groupBy:"outlet",measure:"count"},u=function(e,t={}){let i=t.groupBy??"outlet",r=new Map,o=e=>{let t=function(e,t){return"product"===t?"product"===e.kind?e.id:"unassigned":"outlet"===t?e.outletId??"unassigned":"category"===t?e.category:e.status}({...e,status:e.status??"active"},i),o=r.get(t);if(o)return o.count+=1,o.amount+=e.amount,void Ti(o.metrics,e.metrics);r.set(t,{key:t,label:"product"===i&&"product"===e.kind?e.label:t,count:1,amount:e.amount,metrics:$i(e.metrics),status:"status"===i?e.status:void 0,outletId:"outlet"===i?e.outletId:void 0,category:"category"===i?e.category:void 0,productId:"product"===i&&"product"===e.kind?e.id:void 0})};for(let t of Object.values(e.components))t.productIds.length||"consumed"===t.status||o({kind:"component",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});for(let t of Object.values(e.products))o({kind:"product",id:t.id,label:t.label,status:t.status,outletId:t.outletId,category:t.category,amount:t.amount,metrics:t.metrics});let n=new Map((t.order??[]).map((e,t)=>[e,t]));return[...r.values()].sort((e,t)=>(n.get(e.key)??Number.MAX_SAFE_INTEGER)-(n.get(t.key)??Number.MAX_SAFE_INTEGER)||Ii(e.key,t.key))}(l,c),d=c.measure??"count",h=function(e,t={}){let i=t.bodies??[],r=Math.max(0,t.recentBodyLimit??6),o=new Map;for(let e of i){let i=t.getContainerId?.(e);if(!i)continue;let r=o.get(i);r?r.push(e):o.set(i,[e])}let n=e.map(e=>{let i=o.get(e.id)??[],n=Math.max(0,Math.floor(e.count??i.length)),a=i.slice(Math.max(0,i.length-r)).map(e=>({id:e.id,label:t.getBodyLabel?.(e)??_r(e),datum:e.datum}));return{id:e.id,label:e.label,count:n,share:0,secondary:e.secondary,secondaryLabel:e.secondaryLabel,observed:e.observed,bodyIds:i.map(e=>e.id),recentBodies:a,metadata:e.metadata}}),a=n.reduce((e,t)=>e+t.count,0);return n.map(e=>({...e,share:a>0?e.count/a:0}))}(u.map(e=>({id:e.key,label:e.label,count:e.count,secondary:"count"===d||"amount"===d?e.amount:Number(e.metrics[d]??0),secondaryLabel:"count"===d||"amount"===d?o.amountLabel??"amount":d,metadata:{amount:e.amount,metrics:e.metrics,status:e.status,outletId:e.outletId,category:e.category,productId:e.productId}}))),p={seed:o.seed,bodyRadius:"number"==typeof o.bodyRadius?o.bodyRadius:void 0,radiusRange:o.radiusRange},f=t??o.colorBy??"category",y=!1===o.showChrome?null:Op.createElement(Mr,{layout:a.layout,phases:a.phases,state:l,compact:520>n[0]||360>n[1]}),g=!1===o.showProjection?null:Op.createElement($r,{rows:u,layout:a.layout,projection:c,amountLabel:o.amountLabel});return{...r,config:a.config,initialSpawns:Gr(sr(l,a.layout,p)),projectionRows:h,bodyStyle:e=>function(e,t,i,r){let o=e.datum,n={stroke:r.stroke??("product"===o?.kind?"#fffaf0":"#26323a"),strokeWidth:r.strokeWidth??("product"===o?.kind?1.8:1.1),opacity:r.opacity??.96};if(!o?.__crucible)return{...n,fill:r.color??"#b8792d"};if("product"===o.kind){let e=t.products[o.semanticId];return{...n,fill:r.color??e?.color??Ur(e?.id??o.semanticId)}}let a,s=t.components[o.semanticId];return s?(a="status"===i?s.status:"outlet"===i?s.outletId??"in chamber":"product"===i?s.productIds[0]??"unalloyed":"category"===i||null==i?s.category:"function"==typeof i?(i(s.datum)??"unassigned")+"":(s.datum[i+""]??"unassigned")+"",{...n,fill:r.color??Ur(a)}):{...n,fill:r.color??"#356b63"}}(e,l,f,o),getBodyLabel:e=>function(e,t){let i=e.datum;if(i?.__crucible)return"product"===i.kind?t.products[i.semanticId]?.label:t.components[i.semanticId]?.label}(e,l),renderBodySVG:Ar,backgroundGraphics:Vr(y,r.backgroundGraphics),foregroundGraphics:Vr(g,r.foregroundGraphics)}}},Xy={frameType:"physics",layout:Dy,buildProps:(e,t,i,r,o)=>{let n=r.size??[760,420],a=function(e){function t(e){if(e&&"object"==typeof e){let t=e;if("function"==typeof a){let e=a(t,0);if(null!=e)return e+""}if("string"==typeof a&&null!=t[a])return t[a]+"";if(null!=t.id)return t.id+""}return(e??"unknown")+""}let{coordinateMode:i,flowSpeed:r,links:o,maxParticles:n,nodeIdAccessor:a,nodeXAccessor:s,nodeYAccessor:l,nodes:c,particleRadius:u,particleRate:d,pathAccessor:h,pathConstraint:p="path",reducedMotion:f,seed:y,size:g,sourceAccessor:m,targetAccessor:x,throughputAccessor:b}=e,v=Re(g),w=ze(y),k=new Map,A=new Map,S=[];c.forEach((e,t)=>{let i=(Oe(e,t,a)??e.id??t)+"",r=Fe(Oe(e,t,s)),o=Fe(Oe(e,t,l));if(null!=r&&null!=o){let e={x:r,y:o};k.set(i,e),S.push(e)}A.set(i,(e.label??e.name??i)+"")});let M=[];o.forEach((e,i)=>{let r=t(Oe(e,i,m)),o=t(Oe(e,i,x)),n=Math.max(0,Fe(Oe(e,i,b))??0),a=qt(h?Oe(e,i,h):void 0),s=a.length?a:qt(e.path??e.points??e.route);s.forEach(e=>S.push(e)),M.push({id:(e.id??`physical-flow-${r}-${o}-${i}`)+"",link:e,index:i,source:r,target:o,throughput:n,rawPath:s})});let $=(I=S,"normalized"===(P=i)||"pixels"===P?P:I.length>0&&I.every(e=>!(0>e.x||e.x>1||0>e.y||e.y>1))?"normalized":"pixels"),_=new Map;var P,I;for(let[e,t]of k)_.set(e,Xt(t,v,$));let R=[];for(let e of M){let t=e.rawPath.map(e=>Xt(e,v,$));if(2>t.length){let i=_.get(e.source),r=_.get(e.target);i&&r&&(t=[i,r])}else _.has(e.source)||_.set(e.source,t[0]),_.has(e.target)||_.set(e.target,t[t.length-1]);2>t.length||0>=e.throughput||(A.has(e.source)||A.set(e.source,e.source),A.has(e.target)||A.set(e.target,e.target),R.push({...e,path:t,packetCount:0}))}let L=Ee(d,.12),C=Math.max(1,Math.round(n)),T=R.map(e=>Math.max(1,Math.round(e.throughput*L))),O=T.reduce((e,t)=>e+t,0),F=O>C?C/O:1;R.forEach((e,t)=>{e.packetCount=Math.max(1,Math.floor(T[t]*F))});let D=R.reduce((e,t)=>e+t.packetCount,0);for(;D>C;){let e=R.reduce((e,t,i)=>t.packetCount>1&&(-1===e||t.packetCount>R[e].packetCount)?i:e,-1);if(-1===e)break;R[e].packetCount-=1,D-=1}let E=new Map,N=new Map,z=[],B=Ee(r,90),j=Ee(u,4);R.forEach((e,t)=>{E.set(e.target,(E.get(e.target)??0)+e.throughput),N.set(e.source,(N.get(e.source)??0)+e.throughput);let i=Gt(e.path);for(let r=0;e.packetCount>r;r+=1){let o=(r+.5)/e.packetCount,n=f?o:De(.12+.84*o+.04*(w()-.5),.04,.98),a=f?n:Math.max(0,n-(.18+.12*w())),s=Vt(e.path,a),l=Vt(e.path,n),c=Ht(e.path,a),u={x:-c.y,y:c.x},d=(w()-.5)*j*1.5;z.push({id:`${e.id}-packet-${r}`,x:s.x+u.x*d,y:s.y+u.y*d,vx:f?0:c.x*B+10*(w()-.5),vy:f?0:c.y*B+10*(w()-.5),mass:.8,spawnAt:f?0:.04*t+r/32,shape:{type:"circle",radius:j},datum:{...e.link,source:e.source,target:e.target,throughput:e.throughput,packetIndex:r,packetCount:e.packetCount,routeProgress:n,flowPath:e.path,flowPathLength:i,flowRouteId:e.id,flowSpeed:B,sourceLabel:A.get(e.source)??e.source,targetLabel:A.get(e.target)??e.target},springs:"none"!==p&&f?[{target:{type:"point",x:l.x,y:l.y},restLength:.7*j,stiffness:26,damping:4.25}]:void 0})}});let W=Math.max(18,5*j),Y=Array.from(_,([e,t])=>({nodeId:e,label:A.get(e)??e,sensorId:"physical-flow-node-"+Ne(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}})),X=Object.fromEntries(Y.map(e=>[e.sensorId,{binId:e.label,enterType:"physics-proximity-enter",exitType:"physics-proximity-exit"}])),G=Te(y,[...Lt({x:v.plot.x,y:v.plot.y,width:v.plot.width,height:v.plot.height},{idPrefix:"physical-flow",wallThickness:18,floorThickness:18}),...q],"PacketFlowChart",{gravity:{x:0,y:0},cellSize:Math.max(24,7*j),collisionIterations:3,velocityDamping:.994,restitution:.01,friction:.16,sleepSpeed:2.5,sleepAfter:.7});G.bodyLimit=C,G.eviction="oldest",G.observation={...G.observation,sensors:X};let V=Array.from(_,([e,t])=>({id:e,label:A.get(e)??e,x:t.x,y:t.y,sensorId:"physical-flow-node-"+Ne(e),incoming:E.get(e)??0,outgoing:N.get(e)??0})),H=R.map(e=>({id:e.id,source:e.source,target:e.target,sourceLabel:A.get(e.source)??e.source,targetLabel:A.get(e.target)??e.target,throughput:e.throughput,packetCount:e.packetCount,path:e.path}));return{config:G,initialSpawns:z,projectionRows:V.filter(e=>e.incoming>0||e.outgoing>0).map(e=>({label:e.label,value:e.incoming,secondary:e.outgoing})),metadata:{kind:"physical-flow",coordinateMode:$,particleCount:z.length,totalThroughput:R.reduce((e,t)=>e+t.throughput,0),plot:v.plot,nodes:V,links:H}}}({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:n});return{...r,config:a.config,initialSpawns:Gr(a.initialSpawns),projectionRows:a.projectionRows,foregroundGraphics:Vr(Wr(a.metadata,{showNodeLabels:!1!==o.showNodeLabels,showSensors:!1!==o.showSensors,showStaticFlow:!1!==o.showStaticFlow}),r.foregroundGraphics),bodyStyle:Ce(t||o.colorBy||"source")}}},Gy={frameType:"physics",layout:Dy,buildProps:(e,t,i,r,o)=>{let n=r.size??[700,380],a=Ir(r.theme),s=function(e){let t=function(e,t,i){let r=e?.observation;return{...e,observation:{...r,chartId:t??r?.chartId??"physics-custom",chartType:r?.chartType??"PhysicsCustomChart",onObservation:i??r?.onObservation}}}(e.config,e.chartId,e.onObservation),i=ui(e.colorScheme,e.themeCategorical,hf),r=Re(e.size),o={data:e.data,scales:{x:uf().domain(e.xExtent??[0,1]).range([r.plot.x,r.plot.x+r.plot.width]),y:uf().domain(e.yExtent??[0,1]).range([r.plot.y+r.plot.height,r.plot.y])},dimensions:r,theme:{semantic:e.semantic,categorical:[...i]},resolveColor:di(i,e.colorScheme),config:e.layoutConfig??{},world:new sf(t)},n=e.skipLayout?{}:e.layout(o)??{},a=function(e,t){if(!t?.length)return e;let i=new Map;for(let e of t){let{bodyId:t,...r}=e,o=i.get(t)??[];o.push(r),i.set(t,o)}return e.map(e=>{let t=i.get(e.id);return t?.length?{...e,springs:[...e.springs??[],...t]}:e})}([...n.initialSpawns??n.bodies??[]],n.constraints);return{config:hi(t,n),context:o,initialSpawnPacing:n.initialSpawnPacing,initialSpawns:a,result:n}}({chartId:o.chartId,colorScheme:i,config:o.config,data:Array.isArray(e)?e:[],layout:o.layout,layoutConfig:o.layoutConfig,semantic:Pr(a)??{},size:n,themeCategorical:a.colors.categorical,xExtent:o.xExtent,yExtent:o.yExtent});return{...r,config:s.config,initialSpawns:Gr(s.initialSpawns),projectionRows:[],bodyStyle:s.result.bodyStyle??Ce(t||o.colorBy),backgroundGraphics:Vr(r.backgroundGraphics,s.result.backgroundOverlays),foregroundGraphics:Vr(r.foregroundGraphics,s.result.overlays)}}},Vy=(e,t,i)=>({x:e.x+(t.x-e.x)*i,y:e.y+(t.y-e.y)*i}),Hy=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),Uy={viewBox:[24,24],parts:[{d:"M5,0 H19 Q24,0 24,5 V19 Q24,24 19,24 H5 Q0,24 0,19 V5 Q0,0 5,0 Z",stroke:"accent"}]},Ky=(e,t)=>e.stepEntityCounts?.[t]??e.entityCount,Zy=({datum:e},t)=>({opacity:!t?.isActive||t.predicate(e)||null!=e?.fromNodeId&&t.predicate({...e,nodeId:e.fromNodeId})?1:.2}),Qy=e=>{let t=e.config.braid,i=e.dimensions.plot,r=t.atlas.spec.comparison?.partitions??[...new Set(t.groups.map(e=>e.partition))],o=t.groups.filter(e=>r.includes(e.partition)&&e.nodePath.length>0),n=[],a=[],s=[];if(0===o.length)return{sceneNodes:a,sceneEdges:n,labels:s};let l=new Set(o.map(e=>e.signature)),c=[...t.signatureOrder.filter(e=>l.delete(e)),...l],u=new Map(c.map((e,t)=>[e,t])),d=[...o].sort((e,t)=>u.get(e.signature)-u.get(t.signature)),h=r.map(e=>d.filter(t=>t.partition===e)),p=function(e){let t=new Map;for(let i of e){let e=uo(i.signature);i.nodePath.forEach((r,o)=>{let n=e[o],a=t.get(n);a||(a={id:n,state:r,depth:o+1,signatures:new Set},t.set(n,a)),a.signatures.add(i.signature)})}return[...t.values()]}(d),f=ao(p.map(e=>e.depth)),y=o.map(e=>ao(e.stepEntityCounts??[e.entityCount])),g=ao(y),m=e=>e>0?Math.max(1,10*e/g):0,x=new Map(o.map((e,t)=>[e.id,m(y[t])])),b=i.height/r.length,{semantic:v}=e.theme,w=(e,t,i,r={})=>s.push({x:e,y:t,text:i,fill:v.text??"#333",fontSize:10,anchor:"middle",...r}),k={sourceRevision:t.atlas.provenance.sourceRevision,analysisRevision:t.atlas.analysisRevision,relationScopeId:"directed-admitted"},A=new Map(p.map(e=>{let t=h.map(t=>t.reduce((t,i)=>t+(e.signatures.has(i.signature)?x.get(i.id)+3:0),5));return[e.id,ao(t,24)]})),S=ao([...A.values()],24),M=Math.min(i.width/4,S/2+16),$=(i.width-2*M)/Math.max(f-1,1),_=e=>i.x+M+(e-1)*$,P=48+S/2,I=22+S/2,R=(e,t)=>e+P+(u.get(t)+.5)*Math.max(0,b-P-I)/c.length,L=(t,i,r,o,a)=>{let s=Ky(i,o),l=Ky(i,a),c=m(s),u=m(l);if(0===c&&0===u)return;let d=c!==u,h=e.resolveColor(i.signature);n.push({type:"curved",id:r,pathD:d?lo(t,c,u):so(t,8),style:{fill:d?h:"none",fillOpacity:1,stroke:d?"none":h,strokeWidth:d?0:c},datum:{...k,id:r,kind:"braid-track",nodeId:i.nodePath[a],fromNodeId:i.nodePath[o],groupId:i.id,signature:i.signature,partition:i.partition,entityCount:i.entityCount,fromStep:o,toStep:a,fromCount:s,toCount:l,falseRoot:!1},accessibleDatum:{journey:i.nodePath.join(" → "),partition:i.partition??"all",fromStep:o+1,toStep:a+1,fromCount:s,toCount:l}})};return r.forEach((e,t)=>{let r=i.y+t*b,o=h[t];if(e&&w(i.x+8,r+14,e,{fontSize:12,fontWeight:600,anchor:"start"}),0===o.length)return;for(let e=1;f>=e;e++)w(_(e),r+34,"Step "+e);let n=new Map;for(let t of p){let i=o.filter(e=>t.signatures.has(e.signature));if(0===i.length)continue;let s=_(t.depth),l=ve([...t.signatures].map(e=>R(r,e))),c=co(i.map(e=>x.get(e.id)));n.set(t.id,new Map(i.map((e,t)=>[e.id,{x:s,y:l+c[t],offset:c[t]}])));let u=A.get(t.id),d={state:t.state,step:t.depth,partition:e??"all"},h=`vertex:${e??"all"}:${t.id}`;a.push({type:"glyph",id:h,cx:s,cy:l,size:u,depth:t.depth,label:`${t.state} (step ${t.depth})`,glyph:Uy,accent:v.border??"#888",style:{fill:v.surface??"#fff"},datum:{...k,id:h,nodeId:t.state,kind:"braid-step",prefixId:t.id,...d},accessibleDatum:d}),w(s,l+u/2+12,t.state)}for(let t of o){let i=uo(t.signature);for(let r=1;i.length>r;r++){let o=n.get(i[r-1]).get(t.id),a=n.get(i[r]).get(t.id),s=(o.x+a.x)/2-Math.sign(a.y-o.y)*a.offset;L(1e-8>Math.abs(o.y-a.y)?[o,a]:[o,{x:s,y:o.y},{x:s,y:a.y},a],t,`step:${e??"all"}:${i[r]}:${t.id}`,r-1,r)}}}),{sceneNodes:a,sceneEdges:n,labels:s,restyle:Zy,restyleEdge:Zy}};import*as Jy from"react";var eg=e=>{let{forest:t,selection:i,reading:r="organize"}=e.config,{atlas:o}=t,n=e.dimensions.plot,a=e.theme.semantic.text??"#273442",s=e.config.colors?.backbone??e.theme.semantic.textSecondary??"#8995a3",l=e.config.colors?.residual??e.theme.semantic.warning??"#b66631",c=e.config.colors?.required??e.theme.semantic.primary??"#3983a5",u=i?.analysisRevision===o.analysisRevision&&"directed-admitted"===i.relationScopeId&&o.source.nodes.some(e=>e.id===i.nodeId)?i.nodeId:void 0,d=new Map;for(let i of t.order)if(e.config.collapsedNodeIds?.includes(i)&&!d.has(i))for(let e of ho(t,i))e!==i&&d.set(e,i);let h=t.order.filter(e=>!d.has(e)),p=new Map(o.source.nodes.map(e=>[e.id,e])),f=new Map;for(let e of d.values())f.set(e,(f.get(e)??0)+1);let y=new Map;for(let e of o.source.edges){let t=d.get(e.source)??e.source;if(t===(d.get(e.target)??e.target)&&(e.source!==t||e.target!==t)){let i=y.get(t);i?i.push(e.id):y.set(t,[e.id])}}let g=[...o.sections.sectionIds];o.source.nodes.some(e=>!e.sectionId)&&g.push("Unsectioned");let m=new Map(o.source.nodes.map(e=>[e.id,e.sectionId??"Unsectioned"])),x=g.map(e=>h.filter(t=>m.get(t)===e)),b=new Map,v=[],w=[],k=[],A=[],S=(e,t,i,r=11)=>v.push({x:e,y:t,text:i,fill:a,anchor:"middle",fontSize:r}),M=Math.max(16,Math.min(94,n.width/Math.max(1,g.length)-20));x.forEach((e,t)=>{let i=n.x+n.width*(t+.5)/g.length;S(i,n.y+18,g[t],12),e.forEach((t,r)=>{b.set(t,{x:i,y:n.y+58+(r+.5)*Math.max(40,n.height-110)/Math.max(1,e.length)})})});for(let t of h){let i=b.get(t),r=p.get(t),n=f.get(t)??0,a=y.get(t)??[],d=o.requiredPaths?.unreachableNodeIds.includes(t),h=r.completeness&&"known"!==r.completeness,g=h?"Unknown upstream":d?"Unreachable from roots":void 0;w.push({type:"glyph",id:t,cx:i.x,cy:i.y,size:34,glyph:{viewBox:[M,34],parts:[{d:`M6,0 H${M-6} Q${M},0 ${M},6 V28 Q${M},34 ${M-6},34 H6 Q0,34 0,28 V6 Q0,0 6,0 Z`,stroke:"accent"}]},accent:u===t?c:h?l:s,style:{fill:e.theme.semantic.surface??"#fff",strokeWidth:u===t?2.5:1},label:t,datum:{...r,nodeId:t,kind:"dependency-node",sourceRevision:o.provenance.sourceRevision,analysisRevision:o.analysisRevision,relationScopeId:"directed-admitted",hiddenCount:n,internalEdgeIds:a},accessibleDatum:{node:t,section:m.get(t),status:g??"Admitted",hiddenCount:n,internalEdges:a.join(", ")}}),S(i.x,i.y+4,n?`${t} +${n}`:t,12),g?S(i.x,i.y+30,g,9):n&&S(i.x,i.y+30,a.length+" internal links",9)}let $=new Set(t.forest.backboneEdgeIds),_=new Set(e.config.highlightedEdgeIds),P=new Map;for(let e of o.source.edges){let t=d.get(e.source)??e.source,i=d.get(e.target)??e.target;if(t===i&&(e.source!==t||e.target!==i))continue;let r=b.get(t),a=b.get(i),u=JSON.stringify([t,i]),h=12*(P.get(u)??0);P.set(u,(P.get(u)??0)+1);let p,f,y=$.has(e.id),m=_.has(e.id)?c:y?s:l,x=a.x>r.x,v=r.x+(x?M/2:-M/2),w=a.x+(x?-M/2:M/2),S=[...b.values()].filter(e=>e.x>Math.min(r.x,a.x)&&Math.max(r.x,a.x)>e.x);if(t===i)p=`M${r.x-14},${r.y-17} C${r.x-35-h},${r.y-64-h} ${r.x+35+h},${r.y-64-h} ${r.x+14},${r.y-17}`,f=1;else if(r.x===a.x){let e=a.y>r.y?1:-1,t=r.x+e*M/2,i=t+e*(32+h);p=`M${t},${r.y} C${i},${r.y} ${i},${a.y} ${t},${a.y}`,f=1===e?2:0}else if(S.length){let e=Math.min(r.y,a.y,...S.map(e=>e.y))-17-26-h,t=(n.width/g.length-M)/2*(x?1:-1);p=`M${v},${r.y} C${v+t},${r.y} ${v},${e} ${v+t},${e} H${w-t} C${w},${e} ${w-t},${a.y} ${w},${a.y}`,f=x?0:2}else if(x){let e=(v+w)/2;p=`M${v},${r.y} C${e},${r.y-h} ${e},${a.y-h} ${w},${a.y}`,f=0}else{let e=Math.min(r.y,a.y)-48-h;p=`M${v},${r.y} C${v-25},${e} ${w+25},${e} ${w},${a.y}`,f=2}k.push({type:"curved",id:e.id,pathD:p,style:{stroke:m,strokeWidth:_.has(e.id)?3:y?1.3:2,fill:"none"},datum:{...e,sourceRevision:o.provenance.sourceRevision,analysisRevision:o.analysisRevision,relationScopeId:"directed-admitted",kind:"dependency-edge",edgeClass:y?"backbone":"residual"},accessibleDatum:{edge:e.id,source:e.source,target:e.target,display:y?"backbone":"residual cross-link"}}),A.push(Jy.createElement("path",{key:"arrow:"+e.id,"data-dependency-edge":e.id,"data-source":e.source,"data-target":e.target,d:"M-6,-3 L0,0 L-6,3",fill:"none",stroke:m,transform:`translate(${t===i?r.x+14:r.x===a.x?r.x+(a.y>r.y?M/2:-M/2):w},${t===i?r.y-17:a.y}) rotate(${90*f})`}))}if("required-paths"===r&&u){let e=function(e,t){let i=[],r=e.requiredChildren[t],o=Array.isArray(r)?[...r]:[];for(;o.length;){let t=o.pop();i.push(t),o.push(...e.requiredChildren[t])}return i.sort()}(t,u),i=[...new Set(e.map(e=>d.get(e)??e))].filter(e=>e!==u&&b.has(e));if(i.length){let e=i.map(e=>b.get(e)),t=Math.max(...e.map(e=>e.x))+M/2+8,r=Math.min(...e.map(e=>e.y))-23,o=Math.max(...e.map(e=>e.y))+23;A.push(Jy.createElement("path",{key:"required-bracket",d:`M${t-7},${r} H${t} V${o} H${t-7}`,fill:"none",stroke:c,strokeWidth:2,"data-kind":"dominator-bracket"}))}S(n.x+n.width/2,n.y+n.height-16,e.length?`${u} lies on all admitted paths to ${e.join(", ")}${"incomplete"===o.requiredPaths?.status?" · incomplete scope":""}`:o.requiredPaths?u+": no other required targets in the admitted graph":"Required paths have not been prepared")}let I=new Map(w.map(e=>[e.id,e.datum]));return{sceneNodes:w,sceneEdges:k,labels:v,restyle:(e,t)=>({opacity:t?.isActive&&!t.predicate(e.datum)?.2:1}),restyleEdge:(e,t)=>({opacity:t?.isActive&&![e.datum,I.get(e.datum?.source+""),I.get(e.datum?.target+"")].some(e=>e&&t.predicate(e))?.2:1}),overlays:Jy.createElement("g",{"aria-hidden":!0},A)}};import*as tg from"react";import*as ig from"react";var rg=ig.createElement,og={observed:"#387e98",modeled:"#946344",residual:"#a56537",muted:"#778796",alarm:"#bb5149"},ng=e=>null===e?"unmeasured":1e6>e?1e3>e?e+"":Number((e/1e3).toFixed(1))+"k":Number((e/1e6).toFixed(2))+"m",ag={stage:"M-5,0 H5",distributor:"M-5,0 H0 M0,0 L6,-5 M0,0 H6 M0,0 L6,5",queue:"M-6,-5 V5 H6 V-5 M-3,2 H3",retry:"M-5,2 A5,5 0 1,1 4,3 M4,-1 V4 H0","join-all":"M-6,-4 L0,0 L6,0 M-6,4 L0,0 M2,-5 V5",selector:"M-6,-4 L0,0 L6,0 M-6,4 L0,0 M1,-4 L5,0 L1,4",dependency:"M-5,-5 H5 V5 H-5 Z M-2,-2 L2,2 M-2,2 L2,-2",junction:"M0,-6 L6,0 L0,6 L-6,0 Z"},sg={stage:"stage",distributor:"distributor",queue:"FIFO queue",retry:"retry episode","join-all":"all-member join",selector:"first success",dependency:"dependency gate",junction:"unclassified junction"},lg=e=>null===e?"unmeasured":e+"",cg=tg.createElement,ug=e=>{let{circuit:t,edition:i,reading:r,selection:o}=e.config;if(r.editionId!==i.id||i.analysisRevision!==t.atlas.analysisRevision)throw Error("Circuit render inputs must share an edition and analysis revision");let n=function(e,t,i){if(!Number.isFinite(t)||!Number.isFinite(i)||360>t||300>i)throw Error("Circuit geometry needs at least 360 × 300 pixels");let r=[...e.atlas.sections.sectionIds];e.atlas.source.nodes.some(e=>!e.sectionId)&&r.push("Unsectioned");let o=Zt({width:t,height:i-110,padX:22,padY:70,stages:r.map(e=>({id:e})),shape:"lane"}),n=new Map(e.atlas.source.nodes.map(e=>[e.id,e.sectionId??"Unsectioned"])),a=o.stages.flatMap(t=>{let r=e.order.filter(e=>n.get(e)===t.id),o=(i-235)/Math.max(1,r.length);if(r.length&&78>o)throw Error("Increase circuit height to keep every module readable");return r.map((i,r)=>{let n=e.modules.find(e=>e.nodeId===i),a=Math.max(68,Math.min(142,t.width-56)),s=Math.min(68,o-10),l=t.x-a/2,c=95+(r+.5)*o-s/2;return{module:n,x:l,y:c,width:a,height:s,queue:{x:l+8,y:c+s-8,width:a-16,height:4},sensor:{x:l+a-5,y:c+s/2-4,width:8,height:8}}})}),s=new Map(a.map(e=>[e.module.nodeId,e])),l=new Set(e.residualEdgeIds),c=0,u=e.atlas.source.edges.map(e=>{let t,i=s.get(e.source),o=s.get(e.target),a=o.x>i.x,u=o.x===i.x,d=(t,i)=>{let r=t.module.ports.filter(e=>e.direction===i),o=r.findIndex(t=>t.edgeId===e.id);return t.y+10+(o+.5)*(t.height-20)/r.length},h={x:i.x+(a||u?i.width:0),y:d(i,"out")},p={x:o.x+(a?0:o.width),y:d(o,"in")};if(u){let r=h.x+18+5*c++;t=e.source===e.target?[h,{x:r,y:h.y},{x:r,y:i.y-15},{x:p.x-8,y:i.y-15},{x:p.x-8,y:i.y}]:[h,{x:r,y:h.y},{x:r,y:p.y},p]}else if(!a||Math.abs(r.indexOf(n.get(e.source))-r.indexOf(n.get(e.target)))>1){let e=a?1:-1,i=62+7*c++;t=[h,{x:h.x+16*e,y:h.y},{x:h.x+16*e,y:i},{x:p.x-16*e,y:i},{x:p.x-16*e,y:p.y},p]}else{let e=(h.x+p.x)/2;t=[h,{x:e,y:h.y},{x:e,y:p.y},p]}return{edgeId:e.id,source:e.source,target:e.target,residual:l.has(e.id),points:t,pathD:jr(t)}});return{width:t,height:i,modules:a,routes:u,sections:o.stages.map(e=>({id:e.id,x:e.x})),history:{x:42,y:i-88,width:t-84,height:46}}}(t,e.dimensions.width,e.dimensions.height),a=e.theme.semantic.text??"#273442",s=e.theme.semantic.surface??"#fff",l=function(e,t={}){return{observed:t.observed??e.info??e.primary??"#387e98",modeled:t.modeled??e.secondary??"#946344",residual:t.residual??e.warning??"#a56537",muted:t.muted??e.textSecondary??og.muted,alarm:t.alarm??e.danger??og.alarm}}(e.theme.semantic,e.config.colors),c="modeled"===i.kind?l.modeled:l.observed,u={width:n.width,height:n.height,viewBox:`0 0 ${n.width} ${n.height}`,style:{position:"absolute",inset:0,pointerEvents:"none"},"aria-hidden":!0},d=o?.analysisRevision===t.atlas.analysisRevision&&"directed-admitted"===o.relationScopeId?o.nodeId:void 0,h=Math.max(1,...r.entry.flows.map(e=>e.perSecond??0)),p=new Map(r.entry.flows.map(e=>[e.edgeId,e])),f=new Map(t.modules.map(e=>[e.nodeId,yo(t,i,r,e)])),y=t=>e.config.layoutSelection?.isActive&&!e.config.layoutSelection.predicate(f.get(t))?.2:1,g=Math.max(0,Math.min(200,Math.floor(e.config.particleBudget??24))),m=ze(e.config.placementSeed??1),x=n.routes.filter(e=>(p.get(e.edgeId)?.perSecond??0)>0),b=e.config.reducedMotion?[]:Array.from({length:x.length?g:0},(e,t)=>{let i=x[t%x.length],o=function(e,t){let i=e.slice(1).map((t,i)=>Math.hypot(t.x-e[i].x,t.y-e[i].y)),r=i.reduce((e,t)=>e+t,0),o=Math.max(0,Math.min(1,t))*r;for(let t=0;i.length>t;t++){if(i[t]>=o){let r=i[t]?o/i[t]:0;return{x:e[t].x+(e[t+1].x-e[t].x)*r,y:e[t].y+(e[t+1].y-e[t].y)*r}}o-=i[t]}return e[e.length-1]}(i.points,(m()+r.requestedTime/10)%1);return cg("circle",{key:"cue:"+t,cx:o.x,cy:o.y,r:2.3,fill:a,opacity:Math.max(y(i.source),y(i.target)),"data-circuit-particle":i.edgeId})}),v=n.modules.map(e=>({id:e.module.nodeId,x:e.x+e.width/2,y:e.y+e.height/2,fixedPosition:{x:e.x+e.width/2,y:e.y+e.height/2},shape:{type:"aabb",width:e.width,height:e.height},bodyCollisions:!1,datum:yo(t,i,r,e.module)}));return{bodies:v,config:{kernel:{gravity:{x:0,y:0},seed:e.config.placementSeed??1,sleepAfter:.01},bodyBudget:!1,bodyLimit:v.length,eviction:!1,sediment:!1,settleStepLimit:4},bodyStyle:e=>({fill:s,stroke:l.muted,strokeWidth:1,opacity:y(e.id)}),colliders:n.modules.flatMap(e=>function(e){let t=e.idPrefix??"lane",i={thickness:e.thickness??8,friction:e.friction??.5,restitution:e.restitution??.16},r=[Kt(t+"-top",e.left,e.top,e.right,e.top,i),Kt(t+"-bottom",e.left,e.bottom,e.right,e.bottom,i)];return e.openEnds||r.push(Kt(t+"-left",e.left,e.top,e.left,e.bottom,i),Kt(t+"-right",e.right,e.top,e.right,e.bottom,i)),r}({idPrefix:"queue:"+e.module.nodeId,left:e.queue.x,right:e.queue.x+e.queue.width,top:e.queue.y,bottom:e.queue.y+e.queue.height,thickness:1,openEnds:!0})),sensors:n.modules.map(e=>({id:"sensor:"+e.module.nodeId,shape:{type:"aabb",x:e.sensor.x+e.sensor.width/2,y:e.sensor.y+e.sensor.height/2,width:e.sensor.width,height:e.sensor.height}})),semanticItems:go(t,n,i,r),backgroundOverlays:cg("svg",u,...n.routes.map(t=>{let i=p.get(t.edgeId),r=t.points[t.points.length-1],o=t.points[t.points.length-2],s=n.modules.find(e=>e.module.nodeId===t.source),u=n.modules.find(e=>e.module.nodeId===t.target),d=s.module.ports.filter(e=>"out"===e.direction).length<u.module.ports.filter(e=>"in"===e.direction).length,f=d?t.points[0]:r,g=d?f.x>=s.x+s.width:f.x>u.x,m=180*Math.atan2(r.y-o.y,r.x-o.x)/Math.PI,x=e.config.highlightedEdgeIds?.includes(t.edgeId),b=x?a:t.residual?l.residual:c,v="records"===i.unit?"rec":"attempts"===i.unit?"att":"roots";return cg("g",{key:t.edgeId,"data-circuit-edge":t.edgeId,opacity:Math.max(y(t.source),y(t.target)),"data-source":t.source,"data-target":t.target,"data-flow":i.perSecond??"unmeasured","data-highlighted":x||void 0,"data-unit":i.unit+"/s"},cg("title",null,`${t.edgeId}: ${t.source} → ${t.target}; ${i.perSecond??"unmeasured"} ${i.unit}/s`),cg("path",{d:t.pathD,stroke:b,strokeWidth:null===i.perSecond?1.5:1+i.perSecond/h*7,strokeDasharray:null===i.perSecond?"4 3":void 0,strokeLinejoin:"round",fill:"none",opacity:0===i.perSecond?.35:.75}),cg("path",{d:"M-5,-3 L0,0 L-5,3",transform:`translate(${r.x},${r.y}) rotate(${m})`,fill:"none",stroke:b}),cg("text",{x:f.x+(g?5:-5),y:f.y-7,textAnchor:g?"start":"end",fontSize:8,fill:a},`${null===i.perSecond?"?":ng(i.perSecond)} ${v}/s`))})),overlays:cg("svg",{...u,"data-circuit-edition":i.kind,"data-circuit-time":r.observedAt},...n.sections.map(e=>cg("text",{key:e.id,x:e.x,y:43,textAnchor:"middle",fontSize:11,fill:a},e.id)),...po(n,r,c,a,d,l,y),...b,fo(n,i,r,c,a,d),cg("text",{x:n.width/2,y:n.height-8,textAnchor:"middle",fontSize:9,fill:a},`${"modeled"===i.kind?"Modeled":"Observed"} · ${r.observedAt}s · pipe width = transferred volume/s · individual timings unavailable`))}},dg=()=>null,hg=mo(Lp,function({atlas:e,linkedHover:t,...i},r=function(e){let t=e.prefixForest;if(!t)return{atlas:e,groups:[],signatureOrder:[],ribbons:[],capsules:[],profile:io(e),differences:[],prefixForest:{kind:"observed-prefix",rootIds:[],nodes:[],order:[]},sceneSeeds:{nodes:[],edges:[]}};let i=(e.source.occurrences??[]).map(oo).filter(e=>!!e),r=new Map;for(let e of i){let i=t.order.indexOf(e.signature),o=r.get(e.signature),n=-1===i?t.order.length:i;(null==o||o>n)&&r.set(e.signature,n)}let o=[...new Set(i.map(e=>e.signature))].sort((e,t)=>{let i=(r.get(e)??0)-(r.get(t)??0);return 0!==i?i:e.localeCompare(t)}),n=[];for(let e of i)for(let t=0;e.nodePath.length-1>t;t++){let i=Jr(e.nodePath,t),r=Jr(e.nodePath,t+1);n.push({id:`ribbon:${e.id}:${t}`,groupId:e.id,partition:e.partition,fromPrefixId:i,toPrefixId:r,fromState:e.nodePath[t],toState:e.nodePath[t+1],entityCount:e.stepEntityCounts?.[t]??e.entityCount,...e.stepEntityCounts&&{toEntityCount:e.stepEntityCounts[t+1]}})}let a=function(e,t={}){let i=new Set(t.templates??["repeated-state-episode"]),r=e.filter(e=>i.has(e.template)).map(e=>({id:"capsule:"+e.id,matchId:e.id,template:e.template,entryState:"string"==typeof e.roles.state?e.roles.state:e.nodePath[0],exitState:e.nodePath[e.nodePath.length-1],entityCount:e.entityCount,occurrenceIds:Zr(e),selected:!1})).sort((e,t)=>t.entityCount!==e.entityCount?t.entityCount-e.entityCount:e.id.localeCompare(t.id)),o=new Set;for(let e of r)if(!e.occurrenceIds.some(e=>o.has(e))){e.selected=!0;for(let t of e.occurrenceIds)o.add(t)}return r}(e.motifs.matches),s=e.comparison??function(e){let t=e.spec.comparison;if(!t)return;let i=t.partitions.map(i=>{let r=eo(e.ledger,t.denominatorMeasureId,i)?.value??0,o={};return o["repeated-state-episode"]=Qr(e.motifs.matches.filter(e=>"repeated-state-episode"===e.template),e.source.occurrences,i),{partition:i,assigned:r,motifUsers:o,outcomes:{purchases:eo(e.ledger,"purchases",i)?.value??0}}});return{partitions:[...t.partitions],denominatorMeasureId:t.denominatorMeasureId,referencePartition:t.referencePartition,rows:i}}(e),l=[];if(s&&s.partitions.length>=2){let e=s.rows[0],t=s.rows[1],i=Math.min(e.assigned,t.assigned)||e.assigned,r=e.motifUsers["repeated-state-episode"]??0,o=t.motifUsers["repeated-state-episode"]??0;l.push({motif:"repeated-state-episode",leftPartition:e.partition,rightPartition:t.partition,leftCount:r,rightCount:o,deltaCount:o-r,deltaBps:to(r,o,i),denominator:i}),l.push({motif:"purchases",leftPartition:e.partition,rightPartition:t.partition,leftCount:e.outcomes.purchases??0,rightCount:t.outcomes.purchases??0,deltaCount:(t.outcomes.purchases??0)-(e.outcomes.purchases??0),deltaBps:to(e.outcomes.purchases??0,t.outcomes.purchases??0,i),denominator:i})}let c={nodes:i.map(e=>({id:e.id,partition:e.partition,signature:e.signature})),edges:n.map(e=>({id:e.id,source:e.fromPrefixId,target:e.toPrefixId}))};return{atlas:e,groups:i,signatureOrder:o,ribbons:n,capsules:a,profile:io(e),differences:l,prefixForest:t,sceneSeeds:c}}(e)){return{...i,linkedHover:Kr(t),title:i.title??e.spec.dataRevision,description:i.description??"Motif Braid. Labeled squares show successive journey steps; parallel strands split at diverging prefixes and taper with per-step traffic.",summary:i.summary??`${r.groups.length} supported journey groups. Counts use ${e.spec.motifs.countUnit}; overlapping motifs do not partition the population. Source revision: ${e.provenance.sourceRevision}.`,accessibleTable:i.accessibleTable??!0,nodes:r.sceneSeeds.nodes,edges:r.sceneSeeds.edges,layout:Qy,layoutConfig:{braid:r}}},[600,400]),pg=mo(Lp,function({width:e=920,height:t=440,title:i="Dependency X-Ray",description:r,summary:o,accessibleTable:n=!0,chartId:a,className:s,onObservation:l,linkedHover:c,linkedSelection:u,annotations:d,frameProps:h,onSelectNode:p,...f}){return{nodes:f.forest.sceneSeeds.nodes,edges:f.forest.sceneSeeds.edges,layout:eg,layoutConfig:f,nodeIDAccessor:"id",sourceAccessor:"source",targetAccessor:"target",width:e,height:t,title:i,chartId:a,className:s,onObservation:l,linkedHover:Kr(c),selection:u,annotations:d,frameProps:h,animate:!1,margin:{top:12,right:24,bottom:12,left:12},description:r??`Sections organize the admitted directed graph. Backbone links organize the drawing; residual links retain other original edges. Brackets describe required paths, separately from transport. Roots: ${f.forest.atlas.requiredPaths?.roots.join(", ")??"not declared"}. Relation scope: directed-admitted. Completeness: ${f.forest.atlas.requiredPaths?.status??"not prepared"}.`,summary:o??`Roots: ${f.forest.atlas.requiredPaths?.roots.join(", ")??"not declared"}. Relation scope: directed-admitted. Required-path completeness: ${f.forest.atlas.requiredPaths?.status??"not prepared"}. ${f.forest.residual.originalEdgeIds.length} original edges retained.`,accessibleTable:n}},[920,440],{top:12,right:24,bottom:12,left:12}),fg=mo(Gy,function({width:e=980,height:t=860,title:i,description:r,summary:o,accessibleTable:n=!0,chartId:a,className:s,onObservation:l,linkedHover:c,annotations:u,frameProps:d,linkedSelection:h,onSelectNode:p,...f}){return{key:JSON.stringify([f.circuit.atlas.analysisRevision,f.circuit.order,f.circuit.backboneEdgeIds,e,t]),data:f.circuit.modules.map(e=>yo(f.circuit,f.edition,f.reading,e)),layout:ug,layoutConfig:f,width:e,height:t,chartId:a,className:s,onObservation:l,linkedHover:Kr(c),annotations:u,frameProps:d,paused:!0,title:i??f.edition.label,description:r??`${f.edition.label}. ${f.edition.kind} aggregate interval tape at ${f.reading.observedAt} seconds. Pipe widths encode transferred volume per second in their labeled units; module readouts separate completions, capacity and queue stock. Individual timings are unavailable.`,summary:o??f.edition.assumptions.join(" "),accessibleTable:n,tooltip:!!(a||c||l)&&dg}},[980,860]);import*as yg from"react";var gg=Object.freeze([]),mg={stops:[{offset:0,opacity:.8},{offset:1,opacity:.05}]},xg="__forecastSegment",bg="__forecastOpacity",vg="__semiotic_resolvedX",wg="__semiotic_resolvedY",kg="__compoundGroup",Ag={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=Yo({data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:r.annotations,themeCategorical:Ir(r.theme).colors.categorical}),a=To(n.annotations,o.regression);return{chartType:"scatter",data:n.data,xAccessor:n.xAccessor,yAccessor:n.yAccessor,colorAccessor:t,sizeAccessor:o.sizeBy,...o.symbolBy&&{symbolAccessor:o.symbolBy},...o.symbolMap&&{symbolMap:o.symbolMap},colorScheme:i,...r,...a&&a.length>0&&{annotations:a},...n.yExtent&&!r.yExtent&&{yExtent:n.yExtent},sizeRange:o.sizeRange||[3,15],pointStyle:r.pointStyle||qo(e,t,i,r,o),showLegend:r.showLegend??!!t}}},Sg={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=To(r.annotations,o.regression);return{chartType:"scatter",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",colorAccessor:t,sizeAccessor:o.sizeBy,sizeRange:o.sizeRange||[5,40],colorScheme:i,...r,...n&&{annotations:n},pointStyle:r.pointStyle||Xo(e,t,i,r,o),showLegend:r.showLegend??!!t}}};import{useMemo as Mg,useCallback as $g,useState as _g,useId as Pg,useEffect as Ig,useRef as Rg}from"react";var Lg="__semioticSelectionData";import*as Cg from"react";import{jsx as Tg}from"react/jsx-runtime";var Og,Fg={isActive:!1,predicate:()=>!0};import{jsx as Dg}from"react/jsx-runtime";var Eg={frameType:"xy",layout:{margin:e=>({top:20,right:!1===e.showLabels?24:110,bottom:48,left:48})},buildProps:(e,t,i,r,o)=>{let n=function(e,t={}){let i=t.xAccessor??"x",r=t.yAccessor??"y",o=t.lineBy??"series",n=t.rankDirection??"descending",a=[],s=new Map,l=new Map,c=[],u=new Map,d=1/0,h=-1/0;e.forEach((e,t)=>{let n=Jo(i,e,t),p=pe(n),f=s.get(p);null==f&&(f=a.length,s.set(p,f),a.push(n),l.set(f,[]));let y=Jo(o,e,t)+"";u.has(y)||(u.set(y,c.length),c.push(y));let g=Number(Jo(r,e,t));Number.isFinite(g)&&(d=Math.min(d,g),h=Math.max(h,g),l.get(f)?.push({datum:e,inputIndex:t,series:y,value:g}))});let p=[],f=new Map,y=new Map;for(let e=0;a.length>e;e++){let t=l.get(e)??[];t.sort((e,t)=>("descending"===n?t.value-e.value:e.value-t.value)||(u.get(e.series)??0)-(u.get(t.series)??0)),t.forEach((t,i)=>{let r=i+1;p.push({datum:t.datum,xIndex:e,xValue:a[e],series:t.series,value:t.value,rank:r}),f.set(t.series,(f.get(t.series)??0)+r),y.set(t.series,(y.get(t.series)??0)+1)})}let g=c.length+1,m=[...c].sort((e,t)=>{let i=y.get(e)??0,r=y.get(t)??0;return((f.get(e)??0)+(a.length-i)*g)/Math.max(1,a.length)-((f.get(t)??0)+(a.length-r)*g)/Math.max(1,a.length)||(u.get(e)??0)-(u.get(t)??0)}),x=new Set(m.slice(0,null==t.highlightTop?m.length:Math.max(0,Math.floor(t.highlightTop))));return{data:p.map(e=>{let t=x.has(e.series);return{...e.datum,x:e.xIndex,y:e.rank,__bumpRaw:e.datum,__bumpSeries:e.series,__bumpColorGroup:t?e.series:"Other",__bumpValue:e.value,__bumpRank:e.rank,__bumpXValue:e.xValue,__bumpHighlighted:t}}),xValues:a,seriesOrder:c,overallOrder:m,valueExtent:d===1/0?[0,0]:[d,h]}}(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],{xAccessor:o.xAccessor,yAccessor:o.yAccessor,lineBy:o.lineBy,rankDirection:o.rankDirection,highlightTop:"number"==typeof o.highlightTop?o.highlightTop:void 0}),a=Math.max(1,n.seriesOrder.length),s=Ir(r.theme),l=function(e){let{seriesOrder:t,overallOrder:i,highlightTop:r,color:o,colorScheme:n,neutralColor:a,themeCategorical:s,themeNeutral:l}=e;if(null==r&&null==o)return n;let c=new Set(i.slice(0,null==r?i.length:Math.max(0,Math.floor(r)))),u=new Map,d={};for(let e of t)Object.defineProperty(d,e,{configurable:!0,enumerable:!0,writable:!0,value:o??(c.has(e)?Qo(void 0,s,n,e,u):a??l??"#b8bec8")});return d}({seriesOrder:n.seriesOrder,overallOrder:n.overallOrder,highlightTop:"number"==typeof o.highlightTop?o.highlightTop:void 0,color:"string"==typeof o.color?o.color:void 0,colorScheme:i,neutralColor:"string"==typeof o.neutralColor?o.neutralColor:void 0,themeCategorical:s.colors.categorical,themeNeutral:s.colors.textSecondary}),c={ribbon:!0===o.ribbon,curve:"linear"===o.curve?"linear":"smooth",samplesPerSegment:"number"==typeof o.samplesPerSegment?o.samplesPerSegment:12,ribbonSizeRange:Array.isArray(o.ribbonSizeRange)?o.ribbonSizeRange:[4,28],valueExtent:n.valueExtent,seriesOrder:n.seriesOrder,lineWidth:"number"==typeof o.lineWidth?o.lineWidth:3,ribbonOpacity:"number"==typeof o.ribbonOpacity?o.ribbonOpacity:.82,lineOpacity:"number"==typeof o.lineOpacity?o.lineOpacity:.9,neutralColor:"string"==typeof o.neutralColor?o.neutralColor:void 0,color:"string"==typeof o.color?o.color:void 0,colorMap:l&&"object"==typeof l&&!Array.isArray(l)?l:void 0,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,styleRules:o.styleRules,areaStyle:r.areaStyle,pointStyle:r.pointStyle,labelStyle:o.labelStyle,showPoints:!0===o.showPoints,pointRadius:"number"==typeof o.pointRadius?o.pointRadius:3,showLabels:o.showLabels??!0,labelPriorityAccessor:o.labelPriorityAccessor,maxLabels:"number"==typeof o.maxLabels?o.maxLabels:void 0},u=r.xFormat,d=(e,t)=>{if(0===n.xValues.length)return"";let i=n.xValues[Math.max(0,Math.min(n.xValues.length-1,Math.round(Number(e))))];return u?u(i,t):(i instanceof Date?i.toLocaleDateString():i)+""},h=n.xValues.map((e,t)=>t),p=Array.from({length:a},(e,t)=>t+1),f=r.axes??[{orient:"left",tickValues:p,tickFormat:e=>e+"",label:r.yLabel??"Rank",baseline:!1},{orient:"bottom",tickValues:h,tickFormat:d,label:r.xLabel,tickAnchor:"edges"}];return{...r,chartType:"custom",data:n.data,xAccessor:"x",yAccessor:"y",xExtent:[0,Math.max(1,n.xValues.length-1)],yExtent:[a+.5,.5],customLayout:cn,layoutConfig:c,colorAccessor:"__bumpSeries",colorScheme:l,xFormat:d,axes:f,axisExtent:"exact",showAxes:r.showAxes??!0,showLegend:r.showLegend??!1,annotations:en(r.annotations,n.xValues)}}},Ng="__ma_unitized",zg="__ma_series",Bg={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=Array.isArray(o.series)?o.series:[],s=function(e,t,i){let r=ni(t,i,Of),o=t&&"object"==typeof t&&!Array.isArray(t)?t:null;return e.map((e,t)=>{if("string"==typeof e.color&&e.color.length>0)return e.color;let i=e.label||"Series "+(t+1),n=o?.[i];return"string"==typeof n&&n.length>0?n:r[t%r.length]})}(a,i,Ir(r.theme).colors.categorical),l=2===a.length,c=a.map(e=>e.extent||function(e,t){let i="function"==typeof t?t:e=>Number(e[t||"y"]),r=1/0,o=-1/0;for(let t of e){let e=i(t);"number"==typeof e&&Number.isFinite(e)&&(r>e&&(r=e),e>o&&(o=e))}if(!Number.isFinite(r)||!Number.isFinite(o))return[0,1];if(r===o){let e=0===r?1:.1*Math.abs(r);return[r-e,o+e]}return[r,o]}(n,e.yAccessor)),u=[];for(let e of n)a.forEach((t,i)=>{let r=("function"==typeof t.yAccessor?t.yAccessor:e=>e[t.yAccessor])(e);if(null==r||!Number.isFinite(Number(r)))return;let o=Number(r),n=c[i],a=n[1]-n[0]||1;u.push({...e,[Ng]:l?(o-n[0])/a:o,[zg]:t.label||"Series "+(i+1)})});let d=(e,t)=>i=>{let r=e[0]+i*(e[1]-e[0]);return"function"==typeof t?t(r):Number.isInteger(r)?r+"":r.toFixed(1)},h=l?[{orient:"left",label:a[0].label,tickFormat:d(c[0],a[0].format)},{orient:"right",label:a[1].label,tickFormat:d(c[1],a[1].format)},{orient:"bottom"}]:void 0,p=new Map;a.forEach((e,t)=>{p.set(e.label||"Series "+(t+1),s[t])});let f=wo(ko({lineWidth:"number"==typeof o.lineWidth?o.lineWidth:2,resolveStroke:e=>p.get((e[zg]??"")+"")||s[0],styleRules:o.styleRules,ruleContext:un(o.xAccessor,a)}),{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});return{chartType:"line",data:u,xAccessor:o.xAccessor||"x",yAccessor:Ng,groupAccessor:zg,colorAccessor:zg,...h&&{axes:h},...l&&{yExtent:[0,1]},...r,curve:o.curve||r.curve||"monotoneX",showLegend:r.showLegend??!0,colorScheme:s,lineStyle:f}}},jg={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=o.xAccessor||"x",s="function"==typeof a?a:e=>e[a],l=n.some(e=>{let t=s(e);return!("number"==typeof t&&Number.isFinite(t)||t instanceof Date)}),c=l?n.map((e,t)=>({...e,__waterfallX:t,__waterfallTick:(s(e)??t)+""})):n,u=o.styleRules?Pe(void 0,o.styleRules,Ae(o.xAccessor,o.yAccessor)):void 0,d=u?e=>{let t=u(e),i="function"==typeof r.areaStyle?r.areaStyle(e):r.areaStyle;return i?{...t,...i}:t}:void 0;return{chartType:"waterfall",data:c,xAccessor:l?"__waterfallX":a,yAccessor:o.yAccessor||"y",waterfallStyle:{positiveColor:o.positiveColor,negativeColor:o.negativeColor,connectorStroke:o.connectorStroke,connectorWidth:o.connectorWidth,gap:o.gap,stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.opacity},...r,...d&&{areaStyle:d},...l&&{axes:r.axes??[{orient:"bottom",tickValues:c.map((e,t)=>t)}],xFormat:e=>{let t=n[Number(e)]?s(n[Number(e)]):e,i=o.xFormat??r.xFormat;return"function"==typeof i?i(t):(t??e)+""}}}}},Wg={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=t||o.lineBy,a=o.fillArea,s=Array.isArray(a)?"mixed":a?"area":"line",l=Ir(r.theme).colors.categorical,c=function(e,t,i,r,o){let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=Ir(r.theme).colors.categorical,s=i??r.colorScheme??a,l="string"==typeof t?t:"__ssrLineColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrLineColorBy:t(e)})):n,u=t?li(c,l,s):void 0,d=Ae(o.xAccessor,o.yAccessor);return wo(ko({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: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,n,i,r,o),u=Yo({data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",lineBy:o.lineBy,colorBy:n,colorScheme:i,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}),d=r.pointStyle||hn(u.data,u.colorAccessor,i,r,o),h=r.margin;u.marginExtra&&h&&"object"==typeof h?h={...h,...null!=u.marginExtra.right&&{right:Math.max(Number(h.right)||0,u.marginExtra.right)},...null!=u.marginExtra.left&&{left:Math.max(Number(h.left)||0,u.marginExtra.left)}}:u.marginExtra&&null==h&&(h={top:20,right:u.marginExtra.right??20,bottom:30,left:u.marginExtra.left??40});let p=(!o.directLabel||void 0!==r.showLegend)&&(r.showLegend??!!u.colorAccessor);return{chartType:s,data:u.data,xAccessor:u.xAccessor,yAccessor:u.yAccessor,groupAccessor:u.groupAccessor,colorAccessor:u.colorAccessor,colorScheme:i,lineStyle:u.lineStyle||c,...Array.isArray(a)&&{areaGroups:a},...a&&null!=o.areaOpacity&&{areaOpacity:o.areaOpacity},...null!=o.band&&{band:o.band},...r,...void 0!==h&&{margin:h},annotations:u.annotations,...u.yExtent&&!r.yExtent&&{yExtent:u.yExtent},...d&&{pointStyle:d},showLegend:p}}},Yg={frameType:"xy",layout:{margin:(e,t)=>function(e,t,i,r=!1){let o=y({axes:t,showAxes:i});return{...k(e,t,r),...!o.hasAxis&&{bottom:0},...!o.leftAxis?.hasAxis&&{left:0}}}(t.marginDefaults,Oo(e),t.showAxes,!!t.title)},buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?bo(e):[],a=o.timeAccessor||"time",s=o.valueAccessor||"value",l=o.categoryAccessor,c=o.valueExtent||r.yExtent,u={...Co(o),...void 0!==o.cursor&&{cursor:o.cursor}},d={...u,...void 0!==o.fill&&{fill:o.fill},...void 0!==o.gap&&{gap:o.gap}},h=Pe(void 0,o.styleRules,e=>{let t=e.categoryValue??e.total,i="number"==typeof t&&Number.isFinite(t)?t:void 0,r=Number(e.binStart),o=Number(e.binEnd);return{value:i,x:Number.isFinite(r)&&Number.isFinite(o)?(r+o)/2:void 0,y:i,category:null==e.category?void 0:e.category+""}});return{chartType:"bar",data:n,...r,runtimeMode:"streaming",windowMode:"growing",windowSize:Math.max(1,n.length),arrowOfTime:o.arrowOfTime||"right",timeAccessor:e=>xo(e,a,"time")??NaN,valueAccessor:e=>xo(e,s,"value")??NaN,xExtent:o.timeExtent||r.xExtent,yExtent:c,invertY:"down"===o.direction,axes:Oo({...o,axes:r.axes??o.axes}),extentPadding:o.extentPadding??r.extentPadding,binSize:o.binSize,categoryAccessor:l,barColors:o.colors||r.barColors,colorScheme:o.colors||r.colorScheme,barStyle:r.barStyle||d,areaStyle:r.areaStyle||(e=>({...h(e),...!l&&void 0!==o.fill&&{fill:o.fill},...u})),showLegend:r.showLegend??!!l}}},qg={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=t||o.areaBy,a=Yo({data:Array.isArray(e)?bo(e):[],xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",lineBy:o.areaBy,forecast:o.forecast,anomaly:o.anomaly,annotations:r.annotations,themeCategorical:Ir(r.theme).colors.categorical}),s=function({data:e,safeData:t,areaBy:i,lineDataAccessor:r}){if(null==e)return[];let o,n=void 0!==t[0]?.[r];if(!n&&!i)return t;if(n)o=t;else{let e=t.reduce((e,t)=>{let o="function"==typeof i?i(t):t[i],n=o+"";if(!e[n]){let t={[r]:[]};"string"==typeof i&&(t[i]=o),e[n]=t}return e[n][r].push(t),e},{});o=Object.values(e)}return o.flatMap(e=>{let t=Array.isArray(e[r])?e[r]:[];return"string"==typeof i?t.map(t=>({...t,[i]:t[i]??e[i]})):t})}({data:e,safeData:a.data,areaBy:o.areaBy,lineDataAccessor:o.lineDataAccessor||"coordinates"}),l=function(e){if(e)return Array.isArray(e)?{stops:e.map(({at:e,color:t,opacity:i})=>({offset:e/100,color:t,...null!=i&&{opacity:i}}))}:Array.isArray(e.stops)?e:void 0}(o.semanticGradient),c=l?.stops.length?{stops:l.stops.map(e=>({...e,offset:1-e.offset})).sort((e,t)=>e.offset-t.offset)}:_o(r.gradientFill),u=!1!==o.semanticLine?function(e){let t=e?.stops.filter(e=>"string"==typeof e.color&&Number.isFinite(e.offset)).map(({offset:e,color:t,opacity:i})=>({offset:Math.max(0,Math.min(1,e)),color:t,...Number.isFinite(i)&&{opacity:Math.max(0,Math.min(1,i))}})).sort((e,t)=>e.offset-t.offset);if(!t?.length)return;let i=t[0];return i.offset>0?[{...i,offset:0},...t]:t}(l):void 0,d=r.pointStyle||hn(s,n,i,r,o);return{chartType:"area",data:s,xAccessor:a.xAccessor,yAccessor:a.yAccessor,y0Accessor:o.y0Accessor,groupAccessor:o.areaBy||void 0,colorAccessor:n,colorScheme:i,...r,...a.annotations.length>0&&{annotations:a.annotations},...a.yExtent&&!r.yExtent&&{yExtent:a.yExtent},...void 0!==c&&{gradientFill:c},...u&&{semanticLineStops:u},lineStyle:r.lineStyle||dn(s,n,i,r,o),...d&&{pointStyle:d}}}},Xg={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=o.xAccessor||"x",a=o.seriesAAccessor||"a",s=o.seriesBAccessor||"b",l=e=>Ro(Io(n,"x",e)),c=e=>Ro(Io(a,"a",e)),u=e=>Ro(Io(s,"b",e)),d=o.seriesAColor||"var(--semiotic-danger, #dc2626)",h=o.seriesBColor||"var(--semiotic-info, #2563eb)",p=o.areaOpacity??.6,f=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,i,r){if(!e.length)return[];let o=e.filter(e=>Number.isFinite(t(e))).sort((e,i)=>t(e)-t(i)),n=[],a=0,s=null,l=null,c=[],u=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${a}-${e}`,h=e=>n.push(e),p=(e,t)=>{h({__x:e.x,__y:e.y,__y0:e.y,__diffSegment:d(t),__diffWinner:t,__valA:e.y,__valB:e.y,__sourceDatum:e.datum})};for(let e=0;o.length>e;e++){let n=o[e],f=t(n),y=i(n),g=r(n);if(!Number.isFinite(f)||!Number.isFinite(y)||!Number.isFinite(g))continue;let m=u(y,g);if(null!==m){if(null==s){s=m;for(let e of c)p(e,s);c=[],h({__x:f,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(s),__diffWinner:s,__valA:y,__valB:g,__sourceDatum:n}),l={x:f,a:y,b:g,w:m};continue}if(l&&l.w!==m){let e,t;if(c.length>0)e=c[0].x,t=c[0].y;else{let i=y-l.a-(g-l.b);if(0!==i){let r=Math.max(0,Math.min(1,(l.b-l.a)/i));e=l.x+r*(f-l.x),t=l.a+r*(y-l.a)}else e=l.x,t=l.a}h({__x:e,__y:t,__y0:t,__diffSegment:d(s),__diffWinner:s,__valA:t,__valB:t}),a++,s=m,h({__x:e,__y:t,__y0:t,__diffSegment:d(s),__diffWinner:s,__valA:t,__valB:t});for(let e=1;c.length>e;e++)p(c[e],s)}else for(let e of c)p(e,s);c=[],h({__x:f,__y:g>y?g:y,__y0:g>y?y:g,__diffSegment:d(s),__diffWinner:s,__valA:y,__valB:g,__sourceDatum:n}),l={x:f,a:y,b:g,w:m}}else c.push({x:f,y:y,datum:n})}for(let e of c)p(e,s??"A");return n}(Array.isArray(e)?e:[],l,c,u),w=[];if(y&&Array.isArray(e)){let t=e.filter(e=>Number.isFinite(l(e))).sort((e,t)=>l(e)-l(t));for(let e of t){let t=l(e),i=c(e),r=u(e);Number.isFinite(i)&&w.push({__x:t,__y:i,__diffSegment:"line-A",__diffWinner:"A",__sourceDatum:e}),Number.isFinite(r)&&w.push({__x:t,__y:r,__diffSegment:"line-B",__diffWinner:"B",__sourceDatum:e})}}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:Mo({seriesAColor:d,seriesBColor:h,areaOpacity:p,styleRules:o.styleRules}),lineStyle:$o({seriesAColor:d,seriesBColor:h,lineWidth:f,styleRules:o.styleRules}),curve:o.curve||"linear",...r,...g&&{legend:{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:m,color:d},{label:x,color:h}]}]},legendPosition:b}}}},Gg={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=t||o.areaBy,a="string"==typeof n&&Array.isArray(e)?li(e,n,i):void 0,s="number"==typeof o.areaOpacity?o.areaOpacity:.7,l=r.lineStyle||(e=>{let t=null==n?void 0:ai(e,n,a),i=o.showLine??!0,r={fill:o.color??t,stroke:i?o.stroke??t:"none",...i?{strokeWidth:o.strokeWidth??o.lineWidth??2}:{},fillOpacity:s,...null==o.opacity?{}:{opacity:o.opacity}},l=o.styleRules;if(l?.length){let t=ke(o.yAccessor),i=n?("function"==typeof n?n(e)??"":e[n]??"")+"":void 0;Object.assign(r,_e(e,l,{value:t(e),category:i}))}return r}),c=o.normalize?"zero":o.baseline??"zero",u=r.pointStyle||hn(e,n,i,r,o);return{chartType:"stackedarea",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",groupAccessor:o.areaBy,colorAccessor:n,colorScheme:i,normalize:o.normalize,baseline:c,stackOrder:o.stackOrder,lineStyle:l,...r,...u&&{pointStyle:u},curve:r.curve??o.curve??"monotoneX",showLegend:r.showLegend??!!n}}},Vg={frameType:"xy",buildProps:(e,t,i,r,o)=>{let[n]=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,...!r.pointStyle&&Array.isArray(o.styleRules)&&o.styleRules.length>0&&{pointStyle:Pe(void 0,o.styleRules,Ae(o.xAccessor||"x",o.closeAccessor||o.highAccessor||"high"))},scalePadding:r.scalePadding??Math.max(2,Math.min(12,Math.round(n/40))),extentPadding:r.extentPadding??(n>200?.1:.02)}}},Hg={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=o.xCenter,a=o.yCenter,s=o.quadrants,l=o.centerlineStyle||{},c=!1!==o.showQuadrantLabels,u=o.quadrantLabelSize??12,d=l.stroke||"#999",h=l.strokeWidth??1,p=Array.isArray(l.strokeDasharray)?l.strokeDasharray.join(","):l.strokeDasharray,f=yg.createElement,y=s?[(e,t,i)=>{if(!t?.x||!t?.y)return null;let r=i.width,o=i.height,l=null!=n?t.x(n):r/2,y=null!=a?t.y(a):o/2;if(null!=n&&!Number.isFinite(l)||null!=a&&!Number.isFinite(y))return null;let g=Math.max(0,Math.min(r,l)),m=Math.max(0,Math.min(o,y)),x=[{c:s.topLeft,x:0,y:0,w:g,h:m},{c:s.topRight,x:g,y:0,w:r-g,h:m},{c:s.bottomLeft,x:0,y:m,w:g,h:o-m},{c:s.bottomRight,x:g,y:m,w:r-g,h:o-m}],b=c?[f("text",{key:"ltl",x:8,y:8+u,fill:s.topLeft.color,fontWeight:600,fontSize:u,opacity:.5},s.topLeft.label),f("text",{key:"ltr",x:r-8,y:8+u,fill:s.topRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},s.topRight.label),f("text",{key:"lbl",x:8,y:o-8,fill:s.bottomLeft.color,fontWeight:600,fontSize:u,opacity:.5},s.bottomLeft.label),f("text",{key:"lbr",x:r-8,y:o-8,fill:s.bottomRight.color,fontWeight:600,fontSize:u,opacity:.5,textAnchor:"end"},s.bottomRight.label)]:[];return f(yg.Fragment,null,...x.map((e,t)=>e.w>0&&e.h>0?f("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),f("line",{key:"vc",x1:g,y1:0,x2:g,y2:o,stroke:d,strokeWidth:h,strokeDasharray:p}),f("line",{key:"hc",x1:0,y1:m,x2:r,y2:m,stroke:d,strokeWidth:h,strokeDasharray:p}),...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:i,pointStyle:r.pointStyle||o.pointStyle||qo(e,t,i,r,o),...r,showLegend:r.showLegend??!!t,...y&&{svgPreRenderers:y}}}},Ug={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=function(e,t){if(!Array.isArray(e))return{data:e,orderMap:new WeakMap};let i=t.xAccessor||"x",r=t.yAccessor||"y",o=t.orderAccessor?[...e].sort((e,i)=>null==e||"object"!=typeof e?1:null==i||"object"!=typeof i?-1:Ro(Io(t.orderAccessor,"order",e))-Ro(Io(t.orderAccessor,"order",i))):e,n=new WeakMap,a=0;for(let e of o){if(null==e||"object"!=typeof e)continue;let t=Ro(Io(i,"x",e)),o=Ro(Io(r,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&a++}let s=0;for(let e of o){if(null==e||"object"!=typeof e)continue;let t=Ro(Io(i,"x",e)),o=Ro(Io(r,"y",e));Number.isFinite(t)&&Number.isFinite(o)&&n.set(e,{idx:s++,total:a})}return{data:o,orderMap:n}}(e,o),a=Yo({data:n.data,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",forecast:o.forecast,anomaly:o.anomaly,annotations:r.annotations,themeCategorical:Ir(r.theme).colors.categorical}),s=To(a.annotations,o.regression),l=o.pointRadius??4,c=Ae(o.xAccessor,o.yAccessor),u=o.styleRules,d=[e=>{let t=e.filter(e=>"point"===e.type&&"number"==typeof e.x&&"number"==typeof e.y);if(2>t.length)return null;let i=[];for(let e=0;t.length-1>e;e++){let r=t[e],o=t[e+1],n=Lo(e,t.length);100>t.length&&i.push(yg.createElement("line",{key:"halo-"+e,x1:r.x,y1:r.y,x2:o.x,y2:o.y,stroke:"white",strokeWidth:l+2,strokeLinecap:"round",opacity:.5})),i.push(yg.createElement("line",{key:"segment-"+e,x1:r.x,y1:r.y,x2:o.x,y2:o.y,stroke:n,strokeWidth:l,strokeLinecap:"round"}))}return yg.createElement(yg.Fragment,null,...i)}];return{chartType:"scatter",data:a.data,xAccessor:a.xAccessor,yAccessor:a.yAccessor,colorAccessor:t,colorScheme:i,pointStyle:wo(e=>{let t=n.orderMap.get(e),i=t?.idx??0,r=t?.total??1,o={fill:r>0?Lo(i,r):"#6366f1",stroke:"white",strokeWidth:1,r:l,fillOpacity:1};return u?.length&&Object.assign(o,_e(e,u,c(e))),o},Co(o)),...r,...s&&s.length>0&&{annotations:s},...a.yExtent&&!r.yExtent&&{yExtent:a.yExtent},svgPreRenderers:d}}},Kg={frameType:"xy",buildProps:(e,t,i,r,o)=>{let n=o.frameProps&&"object"==typeof o.frameProps?o.frameProps:void 0,a=Number.isFinite(o.cellBorderWidth)?Math.max(0,o.cellBorderWidth):1,s=Pe(()=>({stroke:o.cellBorderColor??"#fff",strokeWidth:a}),o.styleRules,function(e,t,i){let r=ke(e),o=ke(t),n=ke(i);return e=>{let t="string"==typeof e.agg&&"number"==typeof e.count&&"number"==typeof e.xCenter&&"number"==typeof e.yCenter;return{value:t?pn(e.value):n(e),x:t?pn(e.xCenter):r(e),y:t?pn(e.yCenter):o(e)}}}(o.xAccessor,o.yAccessor,o.valueAccessor)),l=("string"==typeof n?.colorScheme?n.colorScheme:void 0)??i,c=null!=n&&Object.hasOwn(n,"heatmapColorScale"),u=n?.heatmapColorScale,d=c?"function"==typeof u?u:void 0:"custom"===l&&"function"==typeof o.customColorScale?o.customColorScale:void 0;return{chartType:"heatmap",data:e,xAccessor:o.xAccessor||"x",yAccessor:o.yAccessor||"y",valueAccessor:o.valueAccessor,showValues:o.showValues,heatmapValueFormat:o.valueFormat,...o.heatmapAggregation&&{heatmapAggregation:o.heatmapAggregation},...null!=o.heatmapXBins&&{heatmapXBins:o.heatmapXBins},...null!=o.heatmapYBins&&{heatmapYBins:o.heatmapYBins},areaStyle:s,...r,...void 0!==l&&{colorScheme:l},...d&&{heatmapColorScale:d}}}};import{useMemo as Zg,useCallback as Qg,useRef as Jg}from"react";var em={RdBu:$f,PiYG:_f,PRGn:Pf,BrBG:If,RdYlBu:Rf,RdYlGn:Lf,Spectral:Cf},tm="__likert_neutral_neg",im="__likert_neutral_pos",rm={frameType:"ordinal",layout:{margin:(e,t)=>({...t.marginDefaults,left:"vertical"===e.orientation?t.marginDefaults.left:Math.max(100,t.marginDefaults.left)})},buildProps:(e,t,r,o,n)=>{let a=Array.isArray(n.levels)&&n.levels.length>=2?n.levels:["Strongly disagree","Disagree","Neutral","Agree","Strongly agree"],s="vertical"!==n.orientation,l=function(e,t,i,r,o,n,a={}){let s=new Map,l=new Set(t);for(let a of e){let e=i(a);s.has(e)||s.set(e,new Map);let c=s.get(e);if(r){let e=r(a);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}let i=e-1;if(0>i||i>=t.length)continue;let o=t[i];c.set(o,(c.get(o)||0)+1)}else if(o&&n){let e=o(a),t=n(a);if(!l.has(e))continue;c.set(e,(c.get(e)||0)+(Number.isFinite(t)?t:0))}}let c=[];for(let[e,i]of s){let r=0;for(let e of t)r+=i.get(e)||0;if(0!==r)for(let o=0;t.length>o;o++){let n=t[o],s=i.get(n)||0,l={};a.category&&(l[a.category]=e),a.level&&(l[a.level]=n),a.count&&(l[a.count]=s),a.score&&(l[a.score]=o+1),c.push({...l,__likertCategory:e,__likertLevel:n,__likertLevelLabel:n,__likertCount:s,__likertPct:s/r*100,__likertLevelIndex:o})}}return c}(Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a,fn(n.categoryAccessor,"question"),n.levelAccessor?null:fn(n.valueAccessor,"score"),n.levelAccessor?fn(n.levelAccessor,"level"):null,n.levelAccessor?fn(n.countAccessor,"count"):null,{category:"string"==typeof n.categoryAccessor?n.categoryAccessor:void 0,level:"string"==typeof n.levelAccessor?n.levelAccessor:void 0,count:"string"==typeof n.countAccessor?n.countAccessor:void 0,score:n.levelAccessor||"string"!=typeof n.valueAccessor?void 0:n.valueAccessor});s&&(l=function(e,t){let i=t.length,r=i%2!=0,o=Math.floor(i/2),n=new Map;for(let t of e){let e=n.get(t.__likertCategory)||[];e.push(t),n.set(t.__likertCategory,e)}let a=[];for(let[,e]of n){let t,n,s=new Map;for(let i of e)i.__likertLevel===tm?t=i:i.__likertLevel===im?n=i:s.set(i.__likertLevelIndex,i);r&&t&&a.push(t);for(let e=o-1;e>=0;e--){let t=s.get(e);t&&a.push(t)}r&&n&&a.push(n);for(let e=r?o+1:o;i>e;e++){let t=s.get(e);t&&a.push(t)}}return a}(function(e,t){let i=t.length,r=i%2!=0,o=Math.floor(i/2),n=[];for(let t of e){let e=t.__likertLevelIndex;if(r&&e===o){let e=t.__likertPct/2;n.push({...t,__likertLevel:tm,__likertPct:-e}),n.push({...t,__likertLevel:im,__likertPct:e})}else n.push(o>e?{...t,__likertPct:-t.__likertPct}:t)}return n}(l,a),a));let c=Ir(o.theme).colors.diverging,u=Array.isArray(r)&&r.length>=a.length?r:function(e,t){if(0>=e)return[];if(t&&Object.prototype.hasOwnProperty.call(em,t)){let i=em[t];if(1===e)return[i(.5)];let r=[];for(let t=0;e>t;t++)r.push(i(t/(e-1)));return r}let i=["#da1e28","#ff8389","#ffb3b8"],r=["#a6c8ff","#4589ff","#0043ce"],o="#a8a8a8";if(1===e)return[o];let n=e%2!=0,a=Math.floor(e/2),s=[];for(let e=0;a>e;e++)s.push(i[Math.min(Math.floor(e*i.length/a),i.length-1)]);n&&s.push(o);for(let e=0;a>e;e++)s.push(r[Math.min(Math.floor(e*r.length/a),r.length-1)]);return s}(a.length,c),d=new Map(a.map((e,t)=>[e,u[t]||"#888"])),h=a.length%2&&d.get(a[Math.floor(a.length/2)])||"#888",p="function"==typeof n.valueFormat?n.valueFormat:e=>Math.abs(Number(e)).toFixed(0)+"%",f=i(!1===o.showLegend?void 0:{legendGroups:[{label:"",items:a.map(e=>({label:e})),styleFn:e=>({fill:d.get(e.label)||"#888"})}]},o.legend),y=n.styleRules,g=o.pieceStyle;return{chartType:"bar",data:l,oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:s?"horizontal":"vertical",barPadding:n.barPadding,showGrid:o.showGrid,oLabel:n.categoryLabel,rLabel:n.valueLabel||(s?void 0:"Percentage"),rFormat:p,...n.categoryFormat&&{oFormat:n.categoryFormat},...n.valueExtent&&{rExtent:n.valueExtent},...o,pieceStyle:wo((e,t)=>{let i=e.__likertLevel||e.data?.__likertLevel,r=e.__likertLevelLabel||e.data?.__likertLevelLabel,o=e.__likertPct??e.data?.__likertPct,n={fill:i===tm||i===im?h:d.get((r||i)+"")||"#888"};return y?.length&&Object.assign(n,_e(e,y,{value:"number"==typeof o?o:void 0,category:t??(null==r?void 0:r+"")})),"function"==typeof g?Object.assign(n,g(e,t)||{}):g&&"object"==typeof g&&Object.assign(n,g),n},Co(n)),showLegend:o.showLegend??!0,legendPosition:o.legendPosition||"right",...f&&{legend:f},__legendIncludesAutomatic:!0}}};import{jsx as om,jsxs as nm}from"react/jsx-runtime";import{Fragment as am,jsx as sm,jsxs as lm}from"react/jsx-runtime";var cm={frameType:"ordinal",layout:{primarySize:{width:300,height:250}},renderOverlay:function(e,{theme:t}){let i=e.__gauge;if(!i)return null;let r=(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,o=i.needleColor||t.colors.text,n=i.showScaleLabels?(i.thresholds||[]).filter(e=>e.value>i.gMin&&i.gMax>e.value):[];return lm(am,{children:[i.showNeedle&&lm(am,{children:[sm("line",{x1:i.centerX,y1:i.centerY,x2:i.centerX+i.needleLength*Math.cos(r),y2:i.centerY+i.needleLength*Math.sin(r),stroke:o,strokeWidth:2.5,strokeLinecap:"round"}),sm("circle",{cx:i.centerX,cy:i.centerY,r:4,fill:o})]}),null!=i.contextValue&&sm("text",{x:i.centerX,y:i.contextValueY,textAnchor:"middle",dominantBaseline:"middle",fontSize:i.valueFontSize,fontWeight:700,fill:o,children:i.contextValue}),n.map((e,r)=>{let o=(i.startAngleDeg+(i.gMax===i.gMin?0:(e.value-i.gMin)/(i.gMax-i.gMin))*i.sweep-90)*Math.PI/180,n=i.innerRadius-1,a=i.radius+1,s=i.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 lm("g",{children:[sm("line",{x1:i.centerX+Math.cos(o)*n,y1:i.centerY+Math.sin(o)*n,x2:i.centerX+Math.cos(o)*a,y2:i.centerY+Math.sin(o)*a,stroke:t.colors.border,strokeWidth:2,strokeLinecap:"round"}),sm("text",{x:i.centerX+Math.cos(o)*s,y:i.centerY+Math.sin(o)*s,textAnchor:c,dominantBaseline:u,fill:t.colors.textSecondary,fontSize:10,children:e.label||e.value+""})]},"gauge-label-"+r)})]})},buildProps:(e,t,i,r,o)=>{let n=o.min??0,a=o.max??100,s=o.sweep??240,l=o.arcWidth??.3,c=!1!==o.showNeedle,u=!1!==o.fillZones,{startAngleDeg:d}=vn(s),h=o.thresholds,p=Po(r.gradientFill),f=function(e){let{min:t,max:i,value:r,thresholds:o,fillColor:n,backgroundColor:a,fillZones:s,showScaleLabels:l,gradientFill:c,gradientSteps:u=240}=e,d=i-t||1,h=(Math.max(t,Math.min(i,r))-t)/d,p=o&&o.length>0?[...o].sort((e,t)=>e.value-t.value):[{value:i,color:n||"#007bff"}];p=p.map(e=>({...e,value:Math.max(t,Math.min(i,e.value))})),i>p[p.length-1].value&&p.push({value:i,color:p[p.length-1].color});let f=!!c&&c.stops.length>=2,y=[],g=new Map,m=[];if(f){let e=s?h:1,t=bn("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:a,opacity:.4}),e>0){let t=Math.max(1,Math.floor(u)),i=Math.max(1,Math.min(t,Math.round(e*t))),r=[];for(let t=0;i>t;t++)r.push(xn(c.stops,e*(t+.5)/i,n||p[0]?.color||"#007bff"));let o=bn("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]||a})}}else{let e=t;for(let i=0;p.length>i;i++){let r=p[i],o=(r.value-e)/d,n=(e-t)/d,l=(r.value-t)/d,c=Math.max(0,(s?Math.min(h,l):l)-n),u=s?Math.max(0,o-c):0;if(c>0){let e=bn("fill",i);y.push({category:e,value:c,_zone:r.label||"Zone "+(i+1),_isFill:!0}),g.set(e,{fill:r.color})}if(u>0){let e=bn("bg",i);y.push({category:e,value:u,_zone:r.label||"Zone "+(i+1),_isFill:!1}),g.set(e,{fill:a,opacity:.4})}e=r.value}}if(l&&o&&o.length>0)for(let e of o)e.value>t&&i>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:a},gaugeAnnotations:m}}({min:n,max:a,value:o.value,thresholds:h,fillColor:o.color,backgroundColor:o.backgroundColor||"#e0e0e0",fillZones:u,showScaleLabels:!1!==o.showScaleLabels,gradientFill:p}),y=o.styleRules,[g,m]=r.size||[300,250],x=function(e=240){let{sweepRad:t,offsetRad:i}=vn(e),r=[[Math.cos(i),Math.sin(i)],[Math.cos(i+t),Math.sin(i+t)],[0,0]];for(let e=0;2*Math.PI>e;e+=Math.PI/2)t+.001>=((e-i)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)&&r.push([Math.cos(e),Math.sin(e)]);let o=r.map(e=>e[0]),n=r.map(e=>e[1]),[a,s]=no(o),[l,c]=no(n);return{minX:a,maxX:s,minY:l,maxY:c,width:s-a,height:c-l,cx:(a+s)/2,cy:(l+c)/2}}(s),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,A=m/2-x.cy*v,S=2*(v+4),M=Math.max(n,Math.min(a,o.value??n)),$="function"==typeof o.valueFormat?o.valueFormat(M):Math.round(M)+"",_=o.centerContent??r.centerContent,P=null!=_?"function"==typeof _?_(M,n,a):_:"sparkline"===o.mode||"context"===o.mode?void 0:function({value:e,min:t,max:i,radius:r,showScaleLabels:o}){let n=Math.max(16,.3*r);return nm("g",{textAnchor:"middle",children:[om("text",{y:0,dominantBaseline:"central",fontSize:n,fontWeight:700,fill:"var(--semiotic-text, #333)",children:e}),o&&nm("text",{y:.7*n+11,fontSize:11,fill:"var(--semiotic-text-secondary, #666)",children:[t," – ",i]})]})}({value:$,min:n,max:a,radius:v,showScaleLabels:!1!==o.showScaleLabels});return{chartType:"donut",data:f.gaugeData,oAccessor:"category",rAccessor:"value",projection:"radial",innerRadius:w,sweepAngle:s,startAngle:d,oSort:!1,pieceStyle:wo((e,t)=>{let i={...f.pieceStyle(e,t)};return y?.length&&Object.assign(i,_e(e,y,{value:"number"==typeof e.value?e.value:void 0,category:t??(null==e.category?void 0:e.category+"")})),i},Co(o)),...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...r,size:[g,m],margin:{top:A-S/2,bottom:m-A-S/2,left:k-S/2,right:g-k-S/2},...null!=P&&{centerContent:P},showAxes:!1,annotations:[...Array.isArray(r.annotations)?r.annotations:[],...f.gaugeAnnotations],__gauge:{gMin:n,gMax:a,sweep:s,arcWidth:l,value:M,startAngleDeg:d,thresholds:h,centerX:k,centerY:A,radius:v,innerRadius:w,showScaleLabels:!1!==o.showScaleLabels,needleLength:w>20?w-8:v-1,showNeedle:c,needleColor:o.needleColor,..."context"===o.mode&&null==_&&{contextValue:$,contextValueY:A-.2*w,valueFontSize:Math.max(12,Math.min(22,.28*v))}}}}},um={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=To(r.annotations,o.regression);return{chartType:"bar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??!1,colorAccessor:t,colorScheme:i,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,...n&&{annotations:n},gradientFill:wn(r.gradientFill),pieceStyle:kn(e,t,i,r,o)}}},dm={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=t||o.stackBy;return{chartType:"bar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.stackBy,colorAccessor:n,colorScheme:i,projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},normalize:o.normalize,oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:wn(r.gradientFill),pieceStyle:kn(e,n,i,r,o),showLegend:r.showLegend??!!n}}},hm={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=t||o.groupBy;return{chartType:"clusterbar",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",groupBy:o.groupBy,colorAccessor:n,colorScheme:i,projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??!1,barPadding:o.barPadding,...null!=o.roundedTop&&{roundedTop:o.roundedTop},...r,gradientFill:wn(r.gradientFill),pieceStyle:kn(e,n,i,r,o),showLegend:r.showLegend??!!n}}},pm={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=t||o.categoryAccessor,a=ke(o.valueAccessor??"value");return{chartType:"pie",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"radial",colorAccessor:n,colorScheme:i,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...null!=o.startAngle&&{startAngle:o.startAngle},...r,pieceStyle:kn(e,n,i,r,o,e=>{let t=a(e);return null==t?void 0:Math.abs(t)}),showLegend:r.showLegend??!!n}}},fm={frameType:"ordinal",layout:{primarySize:{width:400,height:400}},buildProps:(e,t,i,r,o)=>{let n=t||o.categoryAccessor,a=ke(o.valueAccessor??"value");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:n,colorScheme:i,...null!=o.cornerRadius&&{cornerRadius:o.cornerRadius},...null!=o.startAngle&&{startAngle:o.startAngle},...r,pieceStyle:kn(e,n,i,r,o,e=>{let t=a(e);return null==t?void 0:Math.abs(t)})}}},ym={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=Array.isArray(e)?e.filter(e=>!!e&&"object"==typeof e):[],a=o.valueAccessor||"value",s=n.map(e=>Number("function"==typeof a?a(e):e[a])).filter(Number.isFinite),l=s.length?[Math.min(...s),Math.max(...s)]:void 0;return{chartType:"histogram",data:e,oAccessor:o.categoryAccessor||(e=>null==e.category?"All":e.category+""),rAccessor:a,projection:"horizontal",bins:o.bins??25,normalize:o.relative??!1,colorAccessor:t,colorScheme:i,barPadding:o.categoryPadding??20,...o.valueExtent?{rExtent:o.valueExtent}:l?{rExtent:l}:{},...r,summaryStyle:An(e,t,i,r,o,"count")}}},gm={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"boxplot",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},colorAccessor:t,colorScheme:i,...null!=o.showOutliers&&{showOutliers:o.showOutliers},...null!=o.outlierRadius&&{outlierRadius:o.outlierRadius},...r,summaryStyle:An(e,t,i,r,o)})},mm={frameType:"ordinal",buildProps:(e,t,i,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:i,...r,summaryStyle:Sn(e,t,i,r,o),showLegend:r.showLegend??!!t,...o.valueExtent&&{rExtent:o.valueExtent}})},xm={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"swarm",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",projection:"horizontal"===o.orientation?"horizontal":"vertical",...o.valueExtent&&{rExtent:o.valueExtent},barPadding:o.categoryPadding??20,colorAccessor:t,...o.symbolBy&&{symbolAccessor:o.symbolBy},...o.symbolMap&&{symbolMap:o.symbolMap},colorScheme:i,...r,sizeRange:o.sizeRange||[3,8],pieceStyle:$n(e,t,i,r,o),showLegend:r.showLegend??!!t})},bm={frameType:"ordinal",layout:{modeDefaults:{showGrid:!0}},buildProps:(e,t,i,r,o)=>{let n=To(r.annotations,o.regression);return{chartType:"point",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...o.valueExtent&&{rExtent:o.valueExtent},oSort:o.sort??"auto",barPadding:o.categoryPadding??10,...r,...n&&{annotations:n},pieceStyle:Mn(e,t,i,r,o),showGrid:r.showGrid??!0,showLegend:r.showLegend??!!t}}},vm={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=o.seriesAccessor||t||"__radar",a=t||("__radar"===n?void 0:n),s=Mn(e,a,i,r,{...o,dotRadius:o.pointRadius??4});return{chartType:"point",projection:"radial",data:e,oAccessor:o.categoryAccessor||"attribute",rAccessor:o.valueAccessor||"value",colorAccessor:a,colorScheme:i,connectorAccessor:n,connectorStyle:e=>{let t=s(e),i="string"==typeof t.fill?t.fill:void 0;return{fill:i,fillOpacity:.15,stroke:i,strokeWidth:2,opacity:.7}},pieceStyle:s,rExtent:o.valueExtent||[0],oLabel:"",...r,...o.categoryFormat&&{oFormat:o.categoryFormat},showLegend:r.showLegend??!!a}}},wm={frameType:"ordinal",buildProps:(e,t,i,r,o)=>{let n=t||o.subcategoryAccessor;return{chartType:"swimlane",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",stackBy:o.subcategoryAccessor,colorAccessor:n,categoryAccessor:o.categoryAccessor,subcategoryAccessor:o.subcategoryAccessor,colorScheme:i,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:wn(r.gradientFill),pieceStyle:kn(e,n,i,r,o),showLegend:r.showLegend??!!n,barPadding:o.barPadding??40}}},km={frameType:"ordinal",buildProps:(e,t,i,r,o)=>({chartType:"ridgeline",data:e,oAccessor:o.categoryAccessor||"category",rAccessor:o.valueAccessor||"value",colorAccessor:t,colorScheme:i,projection:"vertical"===o.orientation?"vertical":"horizontal",...o.valueExtent&&{rExtent:o.valueExtent},bins:o.bins??20,amplitude:o.amplitude??1.5,barPadding:o.categoryPadding??5,oSort:o.oSort??!1,...r,summaryStyle:An(e,t,i,r,o,"median",.5),showLegend:r.showLegend??!!t})},Am={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,i,r,o)=>{let n="vertical"===o.orientation,a=t||o.categoryAccessor;return{chartType:n?"bar-funnel":"funnel",data:e,oAccessor:o.stepAccessor||"step",rAccessor:o.valueAccessor||"value",colorAccessor:a,categoryAccessor:o.categoryAccessor,projection:n?"vertical":"horizontal",connectorAccessor:o.connectorAccessor,connectorStyle:o.connectorStyle,...!n&&null!=o.connectorOpacity&&{connectorOpacity:o.connectorOpacity},barPadding:n?40:0,colorScheme:i,...r,showAxes:n&&!1!==r.showAxes,showGrid:n,pieceStyle:kn(e,a,i,r,o),showLabels:o.showLabels??!0}}};import{scaleTime as Sm}from"d3-scale";var Mm={static:{duplicateIds:"fatal",invalidSystemTime:"warn"},mcp:{duplicateIds:"fatal",invalidSystemTime:"warn"},push:{duplicateIds:"warn",invalidSystemTime:"strip"}},$m=new Set(["invalid-domain","missing-node","backward-edge","invalid-edge-time","invalid-value","invalid-node-time"]),_m=e=>{let t=1;for(let i=2;e>=i;i++)t*=i;return t},Pm=828*_m(8),Im=3e3,Rm=new Map,Lm=1e5,Cm=1e-9,Tm=/(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?),(-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?)/gi;import{Fragment as Om,jsx as Fm,jsxs as Dm}from"react/jsx-runtime";var Em="var(--semiotic-grid, #94a3b8)",Nm="var(--semiotic-text-secondary, #475569)",zm="var(--semiotic-text-secondary, #94a3b8)",Bm=e=>{let{bands:t=[],ribbons:i=[],showLabels:r=!0,selectionDatum:o="raw"}=e.config,n=e.selection??null,a=[];for(let e of i){let t={__kind:"ribbon",data:e.rawDatum,id:e.id},i=!Na(t,n,o);a.push({type:"bezier",pathD:e.pathD,...e.bezier&&{bezierCache:e.bezier},style:{fill:e.fill,opacity:i?Math.min(e.opacity,.22):e.opacity,stroke:"none"},datum:t})}for(let e of t){if(!e.gradientStubs)continue;let t=!Na({__kind:"band",data:e.rawDatum,id:e.id},n,o);for(let i=0;e.gradientStubs.length>i;i++){let r=e.gradientStubs[i];a.push({type:"bezier",pathD:r.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:t?.22:e.fillOpacity??.86,stroke:"none"},_gradient:{x0:r.x0,x1:r.x1,...null!=r.y0&&{y0:r.y0},...null!=r.y1&&{y1:r.y1},from:r.from,to:r.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${i}`}})}}for(let e of t){let t=!(!e.gradientStubs||0>=e.gradientStubs.length),i={__kind:"band",data:e.rawDatum,id:e.id},r=!Na(i,n,o);a.push({type:"bezier",pathD:e.pathD,style:{...t?{fill:"none"}:{fill:e.hatchFill??e.fill,fillOpacity:r?.22:e.fillOpacity??.86},stroke:e.stroke??("string"==typeof e.fill?e.fill:"#666"),strokeWidth:e.strokeWidth??.5,...r&&t?{opacity:.22}:{}},datum:i})}let s=r?t.flatMap(e=>{let t=e.labelDeferred&&e.labelFullText?.trim(),i=e.labelText.trim().length>0,r=t&&n?.isActive&&Na({__kind:"band",data:e.rawDatum,id:e.id},n,o),a=i?e.labelText:r?e.labelFullText:"";return a.trim()?[{x:e.labelX,y:e.labelY,text:a,anchor:e.labelAnchor??"end",baseline:e.labelBaseline??"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:a,labels:s}},jm={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{if(!(t||Array.isArray(o.styleRules)&&o.styleRules.length>0||r.nodeStyle||o.nodeStyle||vo(Co(o))))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:i,...r,showLegend:(r.showLegend??!!t)&&!!t};let n=Array.isArray(o.edges)?o.edges:[],a=Array.isArray(o.nodes)&&o.nodes.length>0?o.nodes:Ba([],n,o.sourceAccessor||"source",o.targetAccessor||"target"),s=Ir(r.theme).colors.categorical,l=ni(i,s),c="string"==typeof t?t:"__ssrChordColorBy",u="function"==typeof t?a.map(e=>({...e,__ssrChordColorBy:t(e)})):a,d=t?li(u,c,i??r.colorScheme??s):void 0,h=new Map,p=o.nodeIdAccessor||o.nodeIDAccessor||"id",f=(e,i)=>{let r,n=e?.data||e;if(t)r=ai(n,t,d);else{let t=(e.id??n?.[p]??"")+"";h.has(t)||h.set(t,h.size);let o=e.index??i??h.get(t);r=l[o%l.length]}return{fill:r,stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}},y=Ie(o.styleRules,t,o.valueAccessor);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:i,nodeStyle:wo(o.nodeStyle||(y?(e,t)=>({...f(e,t),...y(e,t)}):f),Co(o)),...r,showLegend:(r.showLegend??!!t)&&!!t}}},Wm={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let n=function(e){if(void 0!==e.edgeStyle)return e.edgeStyle;let{edgeWidth:t,edgeColor:i,edgeOpacity:r}=e,o=e.strokeWidth??1;return void 0!==t||void 0!==i||void 0!==r||void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity?n=>{let a=n?.data||n,s=o;if("number"==typeof t)s=t;else if("function"==typeof t)s=t(a);else if("string"==typeof t){let e=a?.[t],i="number"==typeof e?e:Number(e);s=Number.isFinite(i)&&i>0?i:o}return{stroke:i??e.stroke??"#999",strokeWidth:s,opacity:r??e.opacity??.6}}:void 0}(o),a=Ir(r.theme).colors.categorical,s=new Map,l=o.nodeStyle??(e=>({fill:t?ai(e?.data||e,t,void 0):Qo(void 0,a,i,void 0,s),..."number"==typeof o.nodeSize&&{r:o.nodeSize}})),c=Ie(o.styleRules,t,"number"==typeof o.nodeSize?void 0:o.nodeSize),u=wo(c?(e,t)=>({...l(e),...c(e,t)}):l,{stroke:o.nodeStroke??o.stroke,strokeWidth:o.nodeStrokeWidth??o.strokeWidth,opacity:o.opacity});return{chartType:"force",nodes:o.nodes,edges:o.edges,nodeIDAccessor:o.nodeIdAccessor||o.nodeIDAccessor,sourceAccessor:o.sourceAccessor,targetAccessor:o.targetAccessor,colorBy:t,colorScheme:i,iterations:o.iterations,forceStrength:o.forceStrength,showLabels:o.showLabels??!1,nodeLabel:o.nodeLabel,nodeSize:o.nodeSize??8,nodeSizeRange:o.nodeSizeRange,nodeStyle:u,edgeStyle:n,...r,showLegend:(r.showLegend??!!t)&&!!t}}},Ym={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let n=Ir(r.theme).colors.categorical,a=new Map,s=za(e??null,o.childrenAccessor),l="function"==typeof t?t:null,c=l?s.map(e=>({__ssrCirclePackColorBy:l(e)})):s,u=l?"__ssrCirclePackColorBy":"string"==typeof t?t:void 0,d=t&&u?li(c,u,i??r.colorScheme??n):void 0,h=o.showLabels??r.showLabels,p=r.nodeStyle||o.nodeStyle,f=Pe(e=>{let r=e?.data||e;return{fill:o.colorByDepth?Ef[Number(e?.depth||0)%Ef.length]:t?l?ai({__ssrCirclePackColorBy:l(r)},"__ssrCirclePackColorBy",d??void 0):ai(r,t,d??void 0):Qo(void 0,n,i,void 0,a),fillOpacity:o.circleOpacity??.7,stroke:"currentColor",strokeWidth:1,strokeOpacity:.3}},o.styleRules,Se(t,o.valueAccessor),e=>e?.data||e);return{chartType:"circlepack",data:e,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:t,colorByDepth:o.colorByDepth,showLabels:o.showLabels,nodeLabel:h?o.nodeLabel||o.nodeIdAccessor:void 0,...null!=o.padding&&{padding:o.padding},colorScheme:i,...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth),nodeStyle:ja(f,p,Co(o))}}},qm={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let n=e??o.data,a=o.childrenAccessor||"children",s=o.nodeIdAccessor||o.nodeIDAccessor||"name",l=Ir(r.theme).colors.categorical,c=i??r.colorScheme??l,u=ni(c,l),d=za(n,a),h="__ssrOrbitColorBy",p="function"==typeof t?t:null,f=t?li(p?d.map(e=>({[h]:p(e)})):d,p?h:t,c):void 0,y=Pe(e=>{let i=e.data||e,r=Number(e.depth??0);return{fill:o.colorByDepth?0===r?u[0]:Ef[r%Ef.length]:t?p?ai({[h]:p(i)},h,f):ai(i,t,f):u[0],stroke:"#fff",strokeWidth:1,opacity:0===r?1:.85}},o.styleRules,Se(t,"value"),e=>e?.data||e);return{chartType:"orbit",data:n,childrenAccessor:a,nodeIDAccessor:s,colorBy:t,colorScheme:c,colorByDepth:o.colorByDepth??!1,nodeSize:o.nodeRadius??6,nodeLabel:o.showLabels?s:void 0,showLabels:o.showLabels??!1,orbitMode:o.orbitMode??"flat",orbitSize:o.orbitSize??2.95,orbitSpeed:o.speed??.25,orbitRevolution:o.revolution,orbitRevolutionStyle:o.revolutionStyle,orbitEccentricity:o.eccentricity??1,orbitShowRings:o.showRings??!0,orbitAnimated:!1,nodeStyle:wo(y,Co(o)),edgeStyle:()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth)}}},Xm={frameType:"network",layout:{margin:{top:30,right:80,bottom:40,left:80}},buildProps:(e,t,r,o,n)=>{let a=e=>null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime(),s=n.sourceAccessor||"source",l=n.targetAccessor||"target",c=n.valueAccessor||"value",u=n.nodeIdAccessor||"id",d=n.startTimeAccessor||"startTime",h=n.endTimeAccessor||"endTime",p=n.systemInTimeAccessor,f=n.systemOutTimeAccessor,y=n.xExtentAccessor||"xExtent",g=n.groupBy,m=n.edgeIdAccessor||"id",x=(e,t)=>"function"==typeof e?e(t):t[e],b=Array.isArray(n.edges)?n.edges:[],v=Array.isArray(n.nodes)?n.nodes:[],w=v.length>0?v:Ba([],b,s,l),k=[a(n.domain?.[0]),a(n.domain?.[1])],A=w.map(e=>{let t=x(u,e)+"",i=x(y,e),r=n.nodeLabel?x(n.nodeLabel,e):t,o={id:t,label:null==r?t:r+"",__raw:e},s=g?x(g,e):null;if(null!=s&&s+""!=""&&(o.group=s+""),Array.isArray(i)&&2===i.length){let e=a(i[0]),t=a(i[1]);Number.isFinite(e)&&Number.isFinite(t)&&(o.xExtent=[e,t])}return o}),S=b.map((e,t)=>{let i=x(m,e),r={id:null!=i?i+"":`${x(s,e)}-${x(l,e)}-${t}`,source:x(s,e)+"",target:x(l,e)+"",value:Number(x(c,e)),startTime:a(x(d,e)),endTime:a(x(h,e)),__raw:e};if(p){let t=a(x(p,e));Number.isFinite(t)&&(r.systemInTime=t)}if(f){let t=a(x(f,e));Number.isFinite(t)&&(r.systemOutTime=t)}return r}),[M,$]=o.size??[600,400],_=o.margin,P="vertical"===n.orientation?"vertical":"horizontal",I={...Ea(!!o.title,!!n.showQualityReadout,Array.isArray(n.axisTicks)&&n.axisTicks.length>0,P),..._},R=(o.showLegend??!!t)&&!!t,L=o.legendPosition??"right";R&&("right"===L?I.right=Math.max(I.right,140):"left"===L?I.left=Math.max(I.left,140):"top"===L?I.top=Math.max(I.top,50):"bottom"===L&&(I.bottom=Math.max(I.bottom,80)));let C=I,T=M-C.left-C.right,O=$-C.top-C.bottom,F=ni(r,Ir(o.theme).colors.categorical,hf),D="function"==typeof t?t:null,E=D?w.map(e=>({_cat:D(e)})):w,N=D?"_cat":"string"==typeof t?t:void 0,z=r??[...F],B=N?li(E,N,z):null,j=new Map;for(let e of A)j.set(e.id,e.__raw);let W=(e,i)=>{if(t&&j.has(e)){let i=j.get(e);return D?ai({_cat:D(i)},"_cat",B??void 0):ai(i,"string"==typeof t?t:"id",B??void 0)}return F[i%F.length]},Y=i(R&&t?(()=>{let e=new Map;w.forEach((i,r)=>{let o=x(t,i),n=null==o?"":o+"";!n||e.has(n)||e.set(n,{label:n,color:W(x(u,i)+"",r)})});let i=Array.from(e.values());return i.length>0?{legendGroups:[{type:"fill",label:"",items:i,styleFn:e=>{let t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0})():void 0,o.legend),q=!1!==n.showLabels&&("auto"!==n.showLabels||"auto"),{layout:X,layoutConfig:G,issues:V,xScale:H}=Da({nodes:A,edges:S,domain:k,plotW:T,plotH:O,orientation:P,ribbonLane:n.ribbonLane||"both",ribbonMinRun:"auto"===n.ribbonMinRun||"number"==typeof n.ribbonMinRun?n.ribbonMinRun:0,edgeOpacity:"number"==typeof n.edgeOpacity?n.edgeOpacity:.35,colorOf:W,showLabels:q,styleRules:n.styleRules,colorBy:t,valueAccessor:c,layoutOpts:{pairing:n.pairing||"temporal",packing:n.packing||"reuse",laneOrder:n.laneOrder||"crossing-min",lifetimeMode:n.lifetimeMode||"half",maxValueScale:"number"==typeof n.maxValueScale?n.maxValueScale:void 0,lanePlacement:n.lanePlacement||"stack",nodeSizing:n.nodeSizing||"temporal",groupPadding:"number"==typeof n.groupPadding?n.groupPadding:0}});if(V.length>0){let e=V.map(In).join("; ");throw Error("ProcessSankey: data invalid — "+e)}let U=X?function(e){let t=e.layout,i=e.nodes,r=e.orientation,o=e.plotW,n=e.plotH,a=e.timelineExtent,s=e.axisTicks,l=e.showQualityReadout??!1,c=e.showLaneRails??!1,u=(e.warnings??[]).slice(0,3),d=e.timeFormat,h=e.colorOf,p=e.toTime,f=e.xScale,{centerlines:y,laneLifetime:g,nodeData:m,valueScale:x,compressedPadding:b,crossingsBefore:v,crossingsAfter:w,layoutQualityBefore:k,layoutQuality:A}=t,S=null,M=null;for(let e of i){let t=g[e.id];if(!t||null===t.start||null===t.end)continue;let i=f(t.start),r=f(t.end);(null===S||S>i)&&(S=i),(null===M||r>M)&&(M=r)}let $=e=>Math.max(0,Math.min(a,e)),_=$(S??0),P=Math.max(_,$(M??a)),I=s.map((e,t)=>({tick:e,index:t,coordinate:f(p(e.date))})).filter(({coordinate:e})=>e>=_-.5&&P+.5>=e),R=null!==(w??null)&&null!=k&&null!=A,L=l&&(R||u.length>0)?Dm("g",{fill:zm,fontSize:10,textAnchor:"end",children:[R&&Dm(Om,{children:[Dm("text",{x:o,y:-14,children:["crossings: ",v," → ",w," ","pixel length: ",Math.round(k.pixelLength)," → ",Math.round(A.pixelLength)]}),Dm("text",{x:o,y:-3,children:["transit: ",k.transitOcclusion.toFixed(1)," → ",A.transitOcclusion.toFixed(1)," ","lane use: ",Math.round(100*A.verticalUtilization),"%"]})]}),u.map((e,t)=>Dm("text",{x:o,y:R?10+11*t:11*t-3,fill:"var(--semiotic-warning, #b45309)",children:["warn: ",e]},"warn-"+t))]}):null,C=b?Fm("text",{x:o,y:"vertical"===r?-3:2,fontSize:10,fill:zm,textAnchor:"end",children:"dense layout: lane gaps compressed"}):null,T=(e,t)=>h?h(e,t):Em;return Dm("g","vertical"===r?{children:[L,C,I.map(({index:e,coordinate:t})=>Fm("line",{x1:0,y1:t,x2:o,y2:t,stroke:Em,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),c&&i.map((e,t)=>{let i=g[e.id];if(!i||null===i.start)return null;let r=m[e.id],o=r?{topPeak:r.topPeak,botPeak:r.botPeak}:{topPeak:0,botPeak:0},n=y[e.id]+(o.botPeak-o.topPeak)*x/2,a=f(i.start),s=f(i.end),l=T(e.id,t);return Dm("g",{children:[Fm("line",{x1:n,y1:a,x2:n,y2:s,stroke:l,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),Fm("line",{x1:n-4,y1:a,x2:n+4,y2:a,stroke:l,strokeOpacity:.5}),Fm("line",{x1:n-4,y1:s,x2:n+4,y2:s,stroke:l,strokeOpacity:.5})]},"lane-"+e.id)}),Fm("line",{x1:-4,y1:_,x2:-4,y2:P,stroke:Em}),I.map(({tick:e,index:t,coordinate:i})=>{let r=p(e.date),o=null!=e.label?e.label:d?d(new Date(r)):"";return Dm("g",{transform:`translate(-4,${i})`,children:[Fm("line",{x2:-6,stroke:Em}),Fm("text",{x:-10,y:4,textAnchor:"end",fontSize:11,fill:Nm,children:o})]},t)})]}:{children:[L,C,I.map(({index:e,coordinate:t})=>Fm("line",{x1:t,y1:0,x2:t,y2:n,stroke:Em,strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+e)),c&&i.map((e,t)=>{let i=g[e.id];if(!i||null===i.start)return null;let r=m[e.id],o=r?{topPeak:r.topPeak,botPeak:r.botPeak}:{topPeak:0,botPeak:0},n=y[e.id]+(o.botPeak-o.topPeak)*x/2,a=f(i.start),s=f(i.end),l=T(e.id,t);return Dm("g",{children:[Fm("line",{x1:a,y1:n,x2:s,y2:n,stroke:l,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),Fm("line",{x1:a,y1:n-4,x2:a,y2:n+4,stroke:l,strokeOpacity:.5}),Fm("line",{x1:s,y1:n-4,x2:s,y2:n+4,stroke:l,strokeOpacity:.5})]},"lane-"+e.id)}),Fm("line",{x1:_,y1:n+4,x2:P,y2:n+4,stroke:Em}),I.map(({tick:e,index:t,coordinate:i})=>{let r=p(e.date),o=null!=e.label?e.label:d?d(new Date(r)):"";return Dm("g",{transform:`translate(${i},${n+4})`,children:[Fm("line",{y2:6,stroke:Em}),Fm("text",{y:20,textAnchor:"middle",fontSize:11,fill:Nm,children:o})]},t)})]})}({layout:X,nodes:A,orientation:P,plotW:T,plotH:O,timelineExtent:"vertical"===P?O:T,axisTicks:Array.isArray(n.axisTicks)?n.axisTicks.map(e=>({date:e.date,label:e.label})):[],showQualityReadout:!!n.showQualityReadout,showLaneRails:!!n.showLaneRails,timeFormat:"function"==typeof n.timeFormat?e=>n.timeFormat(e):void 0,colorOf:W,toTime:e=>a(e),xScale:e=>Number(H(e))}):void 0;return{chartType:"force",nodes:w,edges:b,customNetworkLayout:Bm,layoutConfig:G,sourceAccessor:s,targetAccessor:l,valueAccessor:c,nodeIDAccessor:u,colorBy:t,colorScheme:r,...U&&{backgroundGraphics:U},...o,showLegend:R,...Y&&{legend:Y,legendPosition:L},__legendIncludesAutomatic:!0,margin:C}}},Gm={frameType:"network",layout:{primarySize:{width:800,height:600}},buildProps:(e,t,i,r,o)=>{let n=Array.isArray(o.nodes)?o.nodes:Ba([],Array.isArray(o.edges)?o.edges:[],o.sourceAccessor||"source",o.targetAccessor||"target"),a=Ir(r.theme).colors.categorical,s=new Map,l="string"==typeof t?t:"__ssrSankeyColorBy",c="function"==typeof t?n.map(e=>({...e,__ssrSankeyColorBy:t(e)})):n,u=t?li(c,l,i??r.colorScheme??a):void 0,d=e=>({fill:t?ai(e?.data||e,t,u):Qo(void 0,a,i,void 0,s),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}),h=Ie(o.styleRules,t,o.valueAccessor),p=h?(e,t)=>({...d(e),...h(e,t)}):d,f=function({edgeColorBy:e,colorBy:t,colorScale:i,nodeStyleFn:r,edgeOpacity:o,baseStyle:n={}}){return a=>{let s={fillOpacity:o,...n};if("function"==typeof e)s.fill=e(a);else if("source"===e){let e="object"==typeof a.source?a.source:null;t&&e?s.fill=ai(e.data||e,t,i):e&&(s.fill=r(e,e.index).fill)}else if("target"===e){let e="object"==typeof a.target?a.target:null;t&&e?s.fill=ai(e.data||e,t,i):e&&(s.fill=r(e,e.index).fill)}else"gradient"===e&&(s.fill="#999",s.fillOpacity=.7*o);return s}}({edgeColorBy:o.edgeColorBy??"source",colorBy:t,colorScale:u,nodeStyleFn:p,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:wo(o.nodeStyle||p,Co(o)),edgeStyle:wo(o.edgeStyle||f,Co(o)),colorScheme:i,...r,showLegend:(r.showLegend??!!t)&&!!t}}},Vm={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let n=Ir(r.theme).colors.categorical,a=new Map,s=za(e??null,o.childrenAccessor),l="function"==typeof t?t:null,c=l?s.map(e=>({__ssrTreeColorBy:l(e)})):s,u=l?"__ssrTreeColorBy":"string"==typeof t?t:void 0,d=t&&u?li(c,u,i??r.colorScheme??n):void 0,h=!1!==o.showLabels,p=r.nodeStyle||o.nodeStyle,f=Pe(e=>{let r=e?.data||e;return{fill:o.colorByDepth?Ef[Number(e?.depth||0)%Ef.length]:t?l?ai({__ssrTreeColorBy:l(r)},"__ssrTreeColorBy",d??void 0):ai(r,t,d??void 0):Qo(void 0,n,i,void 0,a),stroke:o.stroke??"black",strokeWidth:o.strokeWidth??1,...void 0!==o.opacity&&{opacity:o.opacity}}},o.styleRules,Se(t,o.valueAccessor),e=>e?.data||e);return{chartType:"cluster"===o.layout?"cluster":"tree",data:e,childrenAccessor:o.childrenAccessor,colorBy:t,colorByDepth:o.colorByDepth,orientation:o.orientation,showLabels:o.showLabels,nodeLabel:h?o.nodeLabel||o.nodeIdAccessor:void 0,colorScheme:i,...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth),nodeStyle:ja(f,p,Co(o))}}},Hm={frameType:"network",layout:{primarySize:{width:600,height:600}},buildProps:(e,t,i,r,o)=>{let n=Ir(r.theme).colors.categorical,a=new Map,s=za(e??null,o.childrenAccessor),l="function"==typeof t?t:null,c=l?s.map(e=>({__ssrTreemapColorBy:l(e)})):s,u=l?"__ssrTreemapColorBy":"string"==typeof t?t:void 0,d=t&&u?li(c,u,i??r.colorScheme??n):void 0,h=o.showLabels??r.showLabels,p=o.labelMode,f=void 0!==o.paddingTop?o.paddingTop:r.paddingTop,y=void 0!==f?f:!h||"parent"!==p&&"all"!==p?void 0:18,g=r.nodeStyle||o.nodeStyle,m=Pe(e=>{let r=e?.data||e;return{fill:o.colorByDepth?Ef[Number(e?.depth||0)%Ef.length]:t?l?ai({__ssrTreemapColorBy:l(r)},"__ssrTreemapColorBy",d??void 0):ai(r,t,d??void 0):Qo(void 0,n,i,void 0,a),stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8}},o.styleRules,Se(t,o.valueAccessor),e=>e?.data||e);return{chartType:"treemap",data:e,childrenAccessor:o.childrenAccessor,hierarchySum:o.valueAccessor,colorBy:t,colorByDepth:o.colorByDepth,showLabels:o.showLabels,labelMode:p,nodeLabel:h?o.nodeLabel||o.nodeIdAccessor:void 0,...null!=o.padding&&{padding:o.padding},...null!=y&&{paddingTop:y},colorScheme:i,...r,showLegend:(r.showLegend??!(!t||o.colorByDepth))&&!(!t||o.colorByDepth),nodeStyle:ja(m,g,Co(o))}}},Um={fill:"#f0f0f0",stroke:"#ccc",strokeWidth:.5};import{scaleSequential as Km}from"d3-scale";var Zm={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let n="string"==typeof i?i:"blues",a=function(e,t,i){if(!Array.isArray(e))return;let r=e=>"function"==typeof t?t(e):null!=t?e?.properties?.[t]??e?.[t]:void 0,o=1/0,n=-1/0;for(let t of e){let e=r(t);null==e||!isFinite(e)||(o>e&&(o=e),e>n&&(n=e))}let a=[Number.isFinite(o)?o:0,Number.isFinite(n)?n:1],s=Km(oi(i)).domain(a);return{domain:a,colorScale:e=>s(e),valueAccessor:r}}(o.areas,o.valueAccessor,n),s=o.areaStyle??function(e,t){if(e)return i=>{let r=e.valueAccessor(i);return{fill:null!=r&&isFinite(r)?e.colorScale(r):"#ccc",stroke:"#999",strokeWidth:.5,fillOpacity:t}}}(a,o.areaOpacity??1),l=o.styleRules?Pe(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},Xa):s,c=!1!==r.showLegend&&a?{gradient:{colorFn:a.colorScale,domain:a.domain,label:"string"==typeof o.valueAccessor?o.valueAccessor:"value"}}:void 0;return{areas:o.areas,projection:o.projection||"equalEarth",areaStyle:l,valueAccessor:o.valueAccessor,colorScheme:n,graticule:o.graticule,fitPadding:o.fitPadding,...r,...void 0===r.legend&&c?{legend:c}:{}}}},Qm={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let n=e||o.points,a=o.pointStyle??qa(n,t,i,{sizeBy:o.sizeBy,sizeRange:o.sizeRange||[3,30],fillOpacity:.7,strokeWidth:.5}),s=o.styleRules?Pe(a,o.styleRules,Se(t,o.sizeBy)):a;return{points:n,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",areas:o.areas,areaStyle:o.areaStyle||Um,pointStyle:s,sizeBy:o.sizeBy,colorBy:t,colorScheme:i,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,...r}}},Jm={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let n=e||o.points,a=o.pointStyle??qa(n,t,i,{pointRadius:"number"==typeof o.pointRadius?o.pointRadius:5,fillOpacity:.85,strokeWidth:1}),s=o.nodeIdAccessor||"id",l=o.cartogramLayout||("sparkline"===o.mode?"strip":"radial"),c="sparkline"===o.mode,u="strip"===l,d=o.styleRules?Pe(a,o.styleRules,Se(t)):a;return{points:n,lines:o.lines,xAccessor:o.xAccessor||"lon",yAccessor:o.yAccessor||"lat",pointStyle:e=>{let t="function"==typeof d?d(e):d,i="function"==typeof s?s(e):e[s],r=null!=i&&i+""==o.center+"",n="number"==typeof t.r?t.r:5;return{...t,fillOpacity:r?1:t.fillOpacity??.8,stroke:r?"var(--semiotic-text, #222)":t.stroke??"#fff",strokeWidth:r?1.25:t.strokeWidth??1,r:r?1.35*n:n}},colorBy:t,colorScheme:i,projection:o.projection||"mercator",graticule:o.graticule,fitPadding:o.fitPadding,projectionTransform:{center:o.center,centerAccessor:s,costAccessor:o.costAccessor,strength:o.strength??1,lineMode:o.lineMode||"straight",layout:l},...r,cartogramChrome:{showRings:o.showRings??!0,showNorth:o.showNorth??(!u&&!c),showRingLabels:o.showRingLabels??!u,costLabel:o.costLabel}}}},ex={frameType:"geo",layout:{margin:{top:10,right:10,bottom:10,left:10}},buildProps:(e,t,i,r,o)=>{let n=(Array.isArray(e)?e:null)||o.flows||[],a=o.nodeIdAccessor||"id",s=o.valueAccessor||"value",l=o.xAccessor||"lon",c=o.yAccessor||"lat",u="function"==typeof l?l:e=>e[l],d="function"==typeof c?c:e=>e[c],h=(o.nodes||[]).map(e=>({...e,x:u(e),y:d(e)})),p=new Map;for(let e of h)p.set(e[a]+"",e);let f=o.edgeColorBy??t,y="function"==typeof f,g=n.map(e=>{if(!e||null==e.source||null==e.target)return null;let t=p.get(e.source+""),i=p.get(e.target+"");return t&&i?{...e,coordinates:[{x:t.x,y:t.y},{x:i.x,y:i.y}]}:null}).filter(Boolean),m="__flowMapEdgeColor",x=f?y?li(g.map(e=>({[m]:f(e)})),m,i||"category10"):li(g,f,i||"category10"):null,b=g.map(e=>Number(e[s]??0)).filter(e=>Number.isFinite(e)),v=b.length>0?no(b):void 0,[w,k]=o.edgeWidthRange??[1,8];return{lines:g,points:h,xAccessor:"x",yAccessor:"y",lineDataAccessor:"coordinates",lineType:o.lineType||"geo",flowStyle:o.flowStyle||"basic",areas:o.areas,areaStyle:o.areaStyle||Um,projection:o.projection||"equalEarth",graticule:o.graticule,fitPadding:o.fitPadding,colorScheme:i,lineStyle:Ya({valueAccessor:s,valueDomain:v,edgeWidthRange:[w,k],resolveStroke:e=>f&&x?ai(e,f,x):"#007bff",edgeOpacity:o.edgeOpacity??.6,edgeLinecap:o.edgeLinecap??"round",styleRules:o.styleRules}),pointStyle:()=>({fill:"#333",r:4,fillOpacity:.8}),...r}}};import*as tx from"react-dom/server";import*as ix from"react";import*as rx from"react-dom/server";var ox=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){let t=[];for(let i of e){let e=this.push(i);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){let t=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)e(this.buffer[(t+i)%this._capacity],i)}toArray(){let e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++)e[i]=this.buffer[(t+i)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");let t=this.toArray(),i=0,r=[];t.length>e&&(i=t.length-e,r=t.slice(0,i)),this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(let e=i;t.length>e;e++)this.push(t[e]);return r}update(e,t){let i=[],r=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++){let n=(r+o)%this._capacity,a=this.buffer[n];if(e(a)){let e;e="object"!=typeof a||null===a?a:Array.isArray(a)?[...a]:{...a},i.push(e),this.buffer[n]=t(a)}}return i}remove(e){let t=[],i=[];if(this.forEach(r=>{e(r)?i.push(r):t.push(r)}),0===i.length)return i;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(let e of t)this.push(e);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}},nx=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(let i of e){let e=t?t(i):i;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}},ax=/^\d{4}-\d{1,2}$/,sx=Object.create(null),lx=typeof window>"u"||typeof document>"u",cx=new Set;import{scaleLinear as ux,scaleLog as dx,scaleSymlog as hx,scaleTime as px}from"d3-scale";var fx=new WeakMap,yx=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],gx=["scene-style","data-paint","accessibility","evidence"],mx=(e,t)=>({retainedData:e,invalidations:t}),xx=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],bx=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],vx=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],wx=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],kx=["scene-geometry","data-paint","accessibility","evidence"],Ax=["scene-style","data-paint","accessibility","evidence"],Sx=[],Mx={chartType:mx("rebuild",xx),runtimeMode:mx("rebuild",xx),xAccessor:mx("rebuild",xx),yAccessor:mx("rebuild",xx),timeAccessor:mx("rebuild",xx),valueAccessor:mx("rebuild",xx),y0Accessor:mx("rebuild",xx),boundsAccessor:mx("rebuild",xx),band:mx("rebuild",xx),openAccessor:mx("rebuild",xx),highAccessor:mx("rebuild",xx),lowAccessor:mx("rebuild",xx),closeAccessor:mx("rebuild",xx),candlestickRangeMode:mx("rebuild",xx),accessorRevision:mx("rebuild",xx),groupAccessor:mx("rebuild",bx),categoryAccessor:mx("rebuild",bx),lineDataAccessor:mx("rebuild",bx),colorAccessor:mx("rebuild",Ax),sizeAccessor:mx("rebuild",kx),symbolAccessor:mx("rebuild",kx),pointIdAccessor:mx("rebuild",kx),xScaleType:mx("preserve",vx),yScaleType:mx("preserve",vx),xExtent:mx("preserve",vx),invertY:mx("preserve",vx),yExtent:mx("preserve",vx),extentPadding:mx("preserve",vx),scalePadding:mx("preserve",vx),axisExtent:mx("preserve",vx),yAxisExtent:mx("preserve",vx),binSize:mx("preserve",vx),normalize:mx("preserve",vx),heatmapAggregation:mx("preserve",vx),heatmapXBins:mx("preserve",vx),heatmapYBins:mx("preserve",vx),arrowOfTime:mx("preserve",wx),baseline:mx("preserve",wx),stackOrder:mx("preserve",wx),sizeRange:mx("preserve",wx),curve:mx("preserve",wx),areaGroups:mx("preserve",wx),customLayout:mx("preserve",wx),layoutConfig:mx("preserve",wx),layoutMargin:mx("preserve",wx),symbolMap:mx("preserve",kx),showValues:mx("preserve",kx),heatmapValueFormat:mx("preserve",kx),trackHoverRows:mx("preserve",kx),lineStyle:mx("preserve",Ax),pointStyle:mx("preserve",Ax),areaStyle:mx("preserve",Ax),barStyle:mx("preserve",Ax),swarmStyle:mx("preserve",Ax),waterfallStyle:mx("preserve",Ax),candlestickStyle:mx("preserve",Ax),boundsStyle:mx("preserve",Ax),gradientFill:mx("preserve",Ax),lineGradient:mx("preserve",Ax),semanticLineStops:mx("preserve",Ax),colorScheme:mx("preserve",Ax),themeCategorical:mx("preserve",Ax),themeSemantic:mx("preserve",Ax),themeSequential:mx("preserve",Ax),themeDiverging:mx("preserve",Ax),barColors:mx("preserve",Ax),decay:mx("preserve",Ax),pulse:mx("preserve",Ax),staleness:mx("preserve",Ax),layoutSelection:mx("preserve",Ax),annotations:mx("preserve",["overlay","accessibility","evidence"]),windowSize:mx("preserve",Sx),windowMode:mx("preserve",Sx),maxCapacity:mx("preserve",Sx),clock:mx("preserve",Sx),transition:mx("preserve",Sx),introAnimation:mx("preserve",Sx),onLayoutError:mx("preserve",Sx)},$x=mx("preserve",wx),_x=class{constructor(){this.tracker=new Gp}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}},yx)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},gx):this.recordNoop("restyle")}recordConfig(e,t=!1){let i=function(e){let t="preserve",i=new Set;for(let r of e){let e=Mx[r]??$x;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}(e);return this.tracker.record({kind:"config",keys:e},t?new Set([...i.invalidations,...kx]):i.invalidations)}};import{quadtree as Px}from"d3-quadtree";var Ix=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 i=0,r=0;for(let e of t)"point"===e.type&&!1!==e.interactive&&(i++,e.r>r&&(r=e.r));if(this.maxRadius=r,500>=i)return void(this.tree=null);let o=Array(i),n=0;for(let e of t)"point"===e.type&&!1!==e.interactive&&(o[n++]=e);this.tree=Px().x(e=>e.x).y(e=>e.y).addAll(o)}},Rx=class e{constructor(e){if(this.xExtent=new nx,this.yExtent=new nx,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 _x,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 Ix,this._lastBoundedInsertsRef=null,this.applyPulse=(e,t,i)=>!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,i,r,o,n=("u">typeof performance?performance.now():Date.now())){let a=e.color??"rgba(255,255,255,0.6)",s=e.glowRadius??4,l=!1,c=o??(()=>{let e=new Map;for(let t=0;i.length>t;t++)e.set(i[t],t);return e})();for(let i of t){if("line"===i.type)continue;if("area"===i.type){let t=Array.isArray(i.datum)?i.datum:[i.datum],o=0,s=!1;for(let i of t){let t=c.get(i);if(null==t)continue;s=!0;let a=r.get(t);if(null==a)continue;let l=ss(e,a,n);l>o&&(o=l)}s&&(l=ls(i,o,a)||l);continue}let t=c.get(i.datum);if(null==t)continue;let o=r.get(t);l=ls(i,null==o?0:ss(e,o,n),a,s)||l}return l}(this.config.pulse,e,t,this.timestampBuffer,this.getDatumIndexMap(t),i),this.config=e,this.buffer=new ox(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=Va(e.timeAccessor||e.xAccessor,"time"),this.getY=Va(e.valueAccessor||e.yAccessor,"value")):(this.getX=Va(e.xAccessor,"x"),this.getY=Va(e.yAccessor,"y")),this.getGroup=Ua(e.groupAccessor),this.getCategory=Ua(e.categoryAccessor),this.getSize=e.sizeAccessor?Va(e.sizeAccessor,"size"):void 0,this.getColor=Ua(e.colorAccessor),this.getSymbol=Ua(e.symbolAccessor),this.getY0=e.y0Accessor?Va(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=xs(e),this.getPointId=Ua(e.pointIdAccessor),"candlestick"===e.chartType){let t=null!=e.openAccessor,i=null!=e.closeAccessor;this.getOpen=t?Va(e.openAccessor,"open"):void 0,this.getHigh=Va(e.highAccessor,"high"),this.getLow=Va(e.lowAccessor,"low"),this.getClose=i?Va(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!i}e.pulse&&(this.timestampBuffer=new ox(e.windowSize))}currentTime(){return this.config.clock?.()??os()}syncPulseTimestampBuffer(){this.config.pulse?null!=this.timestampBuffer&&this.timestampBuffer.capacity===this.buffer.capacity&&this.timestampBuffer.size===this.buffer.size||(this.timestampBuffer=Cs(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(let t of this.resolvedRibbons){let i=t.getTop(e),r=t.getBottom(e);Number.isFinite(i)&&this.yExtent.push(i),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(let t of this.resolvedRibbons){let i=t.getTop(e),r=t.getBottom(e);Number.isFinite(i)&&this.yExtent.evict(i),Number.isFinite(r)&&this.yExtent.evict(r)}}rebuildYExtent(){this.yExtent.clear();for(let e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(let 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;let 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();let i=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode;if(this.getX=i?Va(this.config.timeAccessor||this.config.xAccessor,"time"):Va(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){let t=e.inserts[0],i=this.config.xAccessor,r="function"==typeof i?i(t):t[i||"x"],o=r instanceof Date,n="string"==typeof r&&Number.isFinite(Qa(r));if(this.xIsDate=o||n,n){let e="string"==typeof i?i:void 0;this.getX=e?t=>Ja(t[e]):e=>Ja(i(e))}}Ls(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(let i of e.inserts)Ts(this.buffer,i,this.timestampBuffer,t),this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i)}else for(let i of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){let 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&&this.growingCap>=5e4&&(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.`)))}let e=Ts(this.buffer,i,this.timestampBuffer,t);this.xExtent.push(this.getX(i)),this.pushDatumYExtent(i),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){let{config:t,buffer:i}=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(i,this.getX),this.yExtent.dirty&&this.rebuildYExtent();let n=this.getBufferArray(),a=this.xExtent.extent,s=this.yExtent.extent,l="waterfall"===t.chartType&&i.size>0?function(e,t,i,r,o){let n=Array.from(new Set(e.map(t).filter(e=>Number.isFinite(e)))).sort((e,t)=>e-t);if(2>n.length)return Ps(i,r);let a=n[0],s=n[1],l=n[n.length-1],c=n[n.length-2];return Ps("log"===o&&a>0?[a/Math.sqrt(s/a),l*Math.sqrt(l/c)]:[a-(s-a)/2,l+(l-c)/2],r)}(n,this.getX,a,t.xExtent,t.xScaleType):Ps(a,t.xExtent),c=Ps(s,t.yExtent),u=!(!(h=t.yExtent)||null==h[0]||null==h[1]),d="exact"===(t.yAxisExtent??t.axisExtent);var h;if("stackedarea"===t.chartType&&!u&&i.size>0){let e=function(e){let{config:t,groups:i,getX:r,getY:o}=e,n="exact"===(t.yAxisExtent??t.axisExtent);if(t.normalize){let i=[0,n?1:1+t.extentPadding];return{yDomain:i,stackExtentCache:{key:`${e.bufferSize}:${e.ingestVersion}:norm`,yDomain:i}}}let a=`${e.bufferSize}:${e.ingestVersion}:${t.baseline??"zero"}:${t.stackOrder??"key"}`;if(e.stackExtentCache&&e.stackExtentCache.key===a)return{yDomain:e.stackExtentCache.yDomain,stackExtentCache:e.stackExtentCache};let s=new Map,l=new Set,c=0,u=new Map,d=new Map;for(let e of i){let t=new Map,i=0;for(let n of e.data){let e=r(n),a=o(n);if(!Number.isFinite(e)||!Number.isFinite(a))continue;t.set(e,(t.get(e)||0)+a),l.add(e),i+=a;let s=(u.get(e)||0)+a;u.set(e,s),s>c&&(c=s)}s.set(e.key,t),d.set(e.key,i)}let h,p,f=t.stackOrder??"key",y=(e,t)=>t>e?-1:e>t?1:0;if("input"===f)h=i.map(e=>e.key);else if("insideOut"===f){let e=[...i].map(e=>e.key).sort((e,t)=>{let i=(d.get(t)??0)-(d.get(e)??0);return 0!==i?i:y(e,t)}),t=[],r=[],o=0,n=0;for(let i of e)n>o?(t.push(i),o+=d.get(i)??0):(r.push(i),n+=d.get(i)??0);h=[...r.reverse(),...t]}else h="asc"===f?i.map(e=>e.key).sort((e,t)=>{let i=(d.get(e)??0)-(d.get(t)??0);return 0!==i?i:y(e,t)}):"desc"===f?i.map(e=>e.key).sort((e,t)=>{let i=(d.get(t)??0)-(d.get(e)??0);return 0!==i?i:y(e,t)}):i.map(e=>e.key).sort(y);if("wiggle"===t.baseline||"silhouette"===t.baseline){let e=Array.from(l).sort((e,t)=>e-t),i=As(e,h,(e,t)=>s.get(e)?.get(t)||0,t.baseline),r=1/0,o=-1/0;for(let t of e){let e=i.get(t)??0,n=u.get(t)??0;r>e&&(r=e),e+n>o&&(o=e+n)}(!Number.isFinite(r)||!Number.isFinite(o))&&(r=0,o=0);let a=o-r,c=n?0:a>0?a*t.extentPadding:1;p=[r-c,o+c]}else if("diverging"===t.baseline){let e=Array.from(l).sort((e,t)=>e-t),[i,r]=function(e,t,i){let r=0,o=0;for(let n of e){let e=0,a=0;for(let r of t){let t=i(r,n)||0;0>t?a+=t:e+=t}r>a&&(r=a),e>o&&(o=e)}return[r,o]}(e,h,(e,t)=>s.get(e)?.get(t)||0),o=r-i,a=n?0:o>0?o*t.extentPadding:1;p=[i-a,r+a]}else p=[0,c+(n?0:c>0?c*t.extentPadding:1)];return{yDomain:p,stackExtentCache:{key:a,yDomain:p}}}({config:t,groups:this.groupData(n),getX:this.getX,getY:this.getY,bufferSize:i.size,ingestVersion:this._ingestVersion,stackExtentCache:this._stackExtentCache});c=e.yDomain,this._stackExtentCache=e.stackExtentCache}else"bar"===t.chartType&&t.binSize&&!u&&i.size>0?c=function(e,t,i,r,o,n,a){let[,s]=function(e,t,i,r,o){let n=bs(e,t,i,r,o);if(0===n.size)return[0,0];let a=0;for(let e of n.values())e.total>a&&(a=e.total);return[0,a]}(e,t,i,r,o);return[0,a?s:s+s*n]}(i,this.getX,this.getY,t.binSize,this.getCategory,t.extentPadding,d):"waterfall"===t.chartType&&!u&&i.size>0?c=function(e,t,i,r){let[o,n]=function(e,t){let i=0,r=0,o=0;for(let n of e){let e=t(n);null==e||Number.isNaN(e)||(o+=e,i>o&&(i=o),o>r&&(r=o))}return[i,r]}(e,t),a=n-o,s=r?0:a>0?a*i:1;return[Math.min(0,o-Math.abs(s)),Math.max(0,n+Math.abs(s))]}(i,this.getY,t.extentPadding,d):!u&&c[0]!==1/0&&(c=function(e,t,i){if(!i.length)return e;let[r,o]=e;for(let e of t)for(let t of i){let i=t.getTop(e),n=t.getBottom(e);Number.isFinite(i)&&(r>i&&(r=i),i>o&&(o=i)),Number.isFinite(n)&&(r>n&&(r=n),n>o&&(o=n))}return[r,o]}(c,n,this.resolvedRibbons),c=function(e,t){let i=e[1]-e[0],r=t.exactMode?0:i>0?i*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}(c,{exactMode:d,extentPadding:t.extentPadding,userMin:t.yExtent?.[0],userMax:t.yExtent?.[1],yScaleType:t.yScaleType,dataYDomain:s}));c=function(e,t,i){if(!t||i)return e;let r=t[0],o=t[1];return null==r&&null==o?e:[r??e[0],o??e[1]]}(c,t.yExtent,!!u),({xDomain:l,yDomain:c}=function(e,t,i){let r=e,o=t;if(r[0]===1/0||r[1]===-1/0)if("time"===i){let 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}}(l,c,t.xScaleType)),this.scales=function(e){let{config:t,layout:i,xDomain:r}=e,o=t.invertY?[e.yDomain[1],e.yDomain[0]]:e.yDomain,n="streaming"===t.runtimeMode,a=Math.max(0,Math.min(t.scalePadding||0,Math.min(i.width,i.height)/2-1));if(n){let e="left"===t.arrowOfTime?[i.width-a,a]:[a,i.width-a];return{x:ux().domain(r).range(e),y:Is(t.yScaleType,o,[i.height-a,a])}}return{x:Is(t.xScaleType,r,[a,i.width-a]),y:Is(t.yScaleType,o,[i.height-a,a])}}({config:t,layout:e,xDomain:l,yDomain:c}),this._customLayoutFailedThisBuild=!1;let p=this.buildSceneNodes(e,n);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=p,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:e.width,height:e.height},this.version++}get quadtree(){return this.spatialIndex.quadtree}get maxPointRadius(){return this.spatialIndex.maxPointRadius}remapScene(e){let t=e.width/this.lastLayout.width,i=e.height/this.lastLayout.height;for(let e of this.scene)switch(e.type){case"line":for(let r of e.path)r[0]*=t,r[1]*=i;break;case"area":for(let r of e.topPath)r[0]*=t,r[1]*=i;for(let r of e.bottomPath)r[0]*=t,r[1]*=i;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*i,width:e.clipRect.width*t,height:e.clipRect.height*i}),e.strokeColorBands&&(e.strokeColorBands=e.strokeColorBands.map(e=>({...e,y:e.y*i,height:e.height*i})));break;case"point":case"glyph":e.x*=t,e.y*=i;break;case"rect":case"heatcell":e.x*=t,e.y*=i,e.w*=t,e.h*=i;break;case"candlestick":e.x*=t,e.openY*=i,e.closeY*=i,e.highY*=i,e.lowY*=i}let r=this.scales.x.domain(),o=this.scales.y.domain(),n=this.scales.x.range(),a=this.scales.y.range(),s=Is,l=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),c=a[1]>a[0];this.scales={x:s(this.config.xScaleType,r,n[0]>n[1]?[e.width-l,l]:[l,e.width-l]),y:s(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){let{config:i,scales:r}=this;if(!r)return[];if(i.customLayout){let o={data:t,scales:r,dimensions:{width:e.width,height:e.height,margin:i.layoutMargin??{top:0,right:0,bottom:0,left:0},plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:i.themeSemantic??{},categorical:i.themeCategorical??Df},resolveColor:(e,t)=>{let r=this.resolveGroupColor(e);if(r)return r;let o=this.resolveLineStyle(e,t);return o.stroke?o.stroke:"string"==typeof o.fill?o.fill:i.themeSemantic?.primary??"#4e79a7"},config:i.layoutConfig??{},selection:i.layoutSelection??null},n=gs({family:"xy",logLabel:"customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:i.onLayoutError,run:()=>i.customLayout(o)});if("failure"===n.kind)return this.lastCustomLayoutFailure=n.diagnostic,this._customLayoutFailedThisBuild=!0,n.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[]);let a=n.result;this.customLayoutOverlays=a.overlays??null,this.lastCustomLayoutResult=a,this.lastCustomLayoutFailure=null;let s=a.nodes??[];if(this._customRestyle=a.restyle,this.hasCustomRestyle=!!a.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(let e of s)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(s,i.layoutSelection??null)}return ps({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[];let o={scales:r,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:(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},n=(a=i.chartType,sx[a]?.buildScene);var a;if(!n)return function(e){(function(e){return sx[e]})(e)||lx&&(cx.has(e)||(cx.add(e),console.warn(`[semiotic] StreamXYFrame: no XY plugin registered for "${e}" during SSR. Import a chart HOC, or call registerBuiltInXYPlugins() from "semiotic/xy" or "semiotic/realtime/core" before render.`)))}(i.chartType),[];let s=(l=n(o,t,e),Array.isArray(l)?{nodes:l,binBoundaries:[]}:{nodes:l.nodes,binBoundaries:l.binBoundaries});var l;return"bar"===i.chartType&&(this._barCategoryCache=o.barCategoryCache??null,this._binBoundaries=s.binBoundaries),s.nodes}resolveBoundsStyle(e,t){return function(e,t,i,r){let o=e.boundsStyle;if("function"==typeof o)return o(i||{},t);if(o&&"object"==typeof o)return o;let n=r(t,i);return{fill:n.stroke||e.themeSemantic?.primary||"#4e79a7",fillOpacity:.2,...null!=n.opacity&&{opacity:n.opacity},stroke:"none",cursor:n.cursor}}(this.config,e,t,(e,t)=>this.resolveLineStyle(e,t))}computeDecayOpacity(e,t){let i=this.config.decay;return i&&t>1?ns(i,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._ingestVersion)return this._datumIndexCache.map;let t=as(e);return this._datumIndexCache={version:this._ingestVersion,map:t},t}applyDecay(e,t){this.config.decay&&function(e,t,i,r=as(i)){let o=i.length;if(o>1)for(let i of t){if("line"===i.type){let t=Array.isArray(i.datum)?i.datum:[];if(2>t.length)continue;let n=Array(t.length),a=!1;for(let i=0;t.length>i;i++){let s=r.get(t[i]);null!=s?(n[i]=ns(e,s,o),1>n[i]&&(a=!0)):n[i]=1}a&&(i._decayOpacities=n);continue}if("area"===i.type){let t=Array.isArray(i.datum)?i.datum:[],n=i.topPath?i.topPath.length:t.length;if(2>n)continue;if(t.length===n){let a=Array(n),s=!1;for(let i=0;t.length>i;i++){let n=r.get(t[i]);null!=n?(a[i]=ns(e,n,o),1>a[i]&&(s=!0)):a[i]=1}s&&(i._decayOpacities=a)}else{let a=1;for(let i of t){let t=r.get(i);if(null!=t){let i=ns(e,t,o);a>i&&(a=i)}}if(1>a){let e=Array(n);e.fill(a),i._decayOpacities=e}}continue}let t=r.get(i.datum);if(null==t)continue;let n=ns(e,t,o);"candlestick"===i.type?i._decayOpacity=n:i.style={...i.style,opacity:(i.style?.opacity??1)*n}}}(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&&cs(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,i,r){i.clear(),r.clear();for(let o=0;t.length>o;o++){let n=t[o],a=us(e,n,o);a&&("point"===n.type?i.set(a,{x:n.x,y:n.y,r:n.r,opacity:ds(n.style)}):"glyph"===n.type?i.set(a,{x:n.x,y:n.y,r:n.size,opacity:ds(n.style),glyph:n.glyph}):"rect"===n.type||"heatcell"===n.type?i.set(a,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:ds(n.style)}):"candlestick"===n.type?i.set(a,{x:n.x,y:n.openY,w:n.bodyWidth,openY:n.openY,closeY:n.closeY,highY:n.highY,lowY:n.lowY,opacity:ds(n.style)}):"line"===n.type?r.set(a,{path:n.path.map(e=>[e[0],e[1]]),opacity:n.style?.opacity}):"area"===n.type&&r.set(a,{topPath:n.topPath.map(e=>[e[0],e[1]]),bottomPath:n.bottomPath.map(e=>[e[0],e[1]]),opacity:n.style?.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){this.prevPositionMap.clear(),this.prevPathMap.clear();let e=this.scales?.y(0)??0;for(let t=0;this.scene.length>t;t++){let i=this.scene[t],r=us(this.transitionContext,i,t);r&&("point"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,r:0,opacity:0}):"rect"===i.type?this.prevPositionMap.set(r,{x:i.x,y:e,w:i.w,h:0,opacity:i.style.opacity??1}):"heatcell"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:0}):"line"===i.type?(i._introClipFraction=0,this.prevPathMap.set(r,{path:i.path.map(e=>[e[0],e[1]]),opacity:i.style.opacity})):"area"===i.type&&(i._introClipFraction=0,this.prevPathMap.set(r,{topPath:i.topPath.map(e=>[e[0],e[1]]),bottomPath:i.bottomPath.map(e=>[e[0],e[1]]),opacity:i.style.opacity})))}}startTransition(){if(!this.config.transition)return;let e=function(e,t,i,r,o,n=os()){if(0===r.size&&0===o.size)return i;let a=t.duration??300;if(i.exitNodes.length>0){let e=new Set(i.exitNodes);i.scene=i.scene.filter(t=>!e.has(t)),i.exitNodes=[]}let s=!1,l=new Set,c=new Set;for(let t=0;i.scene.length>t;t++){let n=i.scene[t],a=us(e,n,t);if(!a)continue;if(n._transitionKey=a,"line"===n.type||"area"===n.type){let e=o.get(a);if(e){if(c.add(a),"line"===n.type&&e.path&&e.path.length===n.path.length){n._targetPath=n.path.map(e=>[e[0],e[1]]),n._prevPath=e.path;for(let t=0;n.path.length>t;t++)n.path[t]=[e.path[t][0],e.path[t][1]];s=!0}else if("area"===n.type&&e.topPath&&e.bottomPath&&e.topPath.length===n.topPath.length&&e.bottomPath.length===n.bottomPath.length){n._targetTopPath=n.topPath.map(e=>[e[0],e[1]]),n._targetBottomPath=n.bottomPath.map(e=>[e[0],e[1]]),n._prevTopPath=e.topPath,n._prevBottomPath=e.bottomPath;for(let t=0;n.topPath.length>t;t++)n.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;n.bottomPath.length>t;t++)n.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];s=!0}n._targetOpacity=n.style.opacity??1,n._startOpacity=e.opacity??n.style.opacity??1}else n._targetOpacity=n.style.opacity??1,n._startOpacity=0,n.style={...n.style,opacity:0},s=!0;continue}let u=r.get(a);if("point"===n.type)if(u){l.add(a);let e={x:n.x,y:n.y,r:n.r};n._targetOpacity=ds(n.style),(u.x!==e.x||u.y!==e.y||u.r!==e.r)&&(n._targetX=e.x,n._targetY=e.y,n._targetR=e.r,n.x=u.x,n.y=u.y,n.r=u.r??n.r,s=!0)}else n._targetOpacity=ds(n.style),n.style={...n.style,opacity:0},s=!0;else if("glyph"===n.type)if(u){l.add(a);let e={x:n.x,y:n.y,size:n.size};n._targetOpacity=ds(n.style),(u.x!==e.x||u.y!==e.y||u.r!==e.size)&&(n._targetX=e.x,n._targetY=e.y,n._targetR=e.size,n.x=u.x,n.y=u.y,n.size=u.r??n.size,s=!0)}else n._targetOpacity=ds(n.style),n.style={...n.style,opacity:0},s=!0;else if("rect"===n.type)if(u){l.add(a);let e={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=ds(n.style),(u.x!==e.x||u.y!==e.y||u.w!==e.w||u.h!==e.h)&&(n._targetX=e.x,n._targetY=e.y,n._targetW=e.w,n._targetH=e.h,n.x=u.x,n.y=u.y,n.w=u.w??n.w,n.h=u.h??n.h,s=!0)}else n._targetOpacity=ds(n.style),n.style={...n.style,opacity:0},s=!0;else if("heatcell"===n.type)if(u){l.add(a);let e={x:n.x,y:n.y,w:n.w,h:n.h};n._targetOpacity=ds(n.style),(u.x!==e.x||u.y!==e.y||u.w!==e.w||u.h!==e.h)&&(n._targetX=e.x,n._targetY=e.y,n._targetW=e.w,n._targetH=e.h,n.x=u.x,n.y=u.y,n.w=u.w??n.w,n.h=u.h??n.h,s=!0)}else n._targetOpacity=ds(n.style),n.style={...n.style||{},opacity:0},s=!0;else if("candlestick"===n.type)if(u&&null!=u.openY){l.add(a);let e={x:n.x,openY:n.openY,closeY:n.closeY,highY:n.highY,lowY:n.lowY};n._targetOpacity=ds(n.style),(u.x!==e.x||u.openY!==e.openY||u.closeY!==e.closeY||u.highY!==e.highY||u.lowY!==e.lowY)&&(n._targetX=e.x,n._targetOpenY=e.openY,n._targetCloseY=e.closeY,n._targetHighY=e.highY,n._targetLowY=e.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,s=!0)}else n._targetOpacity=ds(n.style),n.style={...n.style||{},opacity:0},s=!0}for(let[e,t]of o)if(!c.has(e))if(e.startsWith("l:")&&t.path){let 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};i.exitNodes.push(r),s=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){let 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};i.exitNodes.push(r),s=!0}for(let[e,t]of r)if(!l.has(e)){if(e.startsWith("p:"))i.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)i.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:"))i.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:"))i.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:")){let r=t.openY??t.y;i.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})}s=!0}return i.exitNodes.length>0&&(i.scene=[...i.scene,...i.exitNodes]),s&&(i.activeTransition={startTime:n,duration:a}),i}(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;let t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},i=function(e,t,i,r){if(!i.activeTransition)return!1;let o=is(e,i.activeTransition),n=ts(o,"linear"===t.easing?"linear":"ease-out-cubic");for(let e of i.scene){let t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style.opacity=rs(i?i.opacity??1:0,e._targetOpacity,n)}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=rs(i.x,e._targetX,n),e.y=rs(i.y,e._targetY,n),void 0!==e._targetR&&void 0!==i.r&&(e.r=rs(i.r,e._targetR,n))}else if("glyph"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style.opacity=rs(i?i.opacity??1:0,e._targetOpacity,n)}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=rs(i.x,e._targetX,n),e.y=rs(i.y,e._targetY,n),void 0!==e._targetR&&void 0!==i.r&&(e.size=rs(i.r,e._targetR,n))}else if("rect"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style.opacity=rs(i?i.opacity??1:0,e._targetOpacity,n)}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=rs(i.x,e._targetX,n),e.y=rs(i.y,e._targetY,n),void 0!==i.w&&(e.w=rs(i.w,e._targetW,n)),void 0!==i.h&&(e.h=rs(i.h,e._targetH,n))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style={...e.style||{},opacity:rs(i?i.opacity??1:0,e._targetOpacity,n)}}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=rs(i.x,e._targetX,n),e.y=rs(i.y,e._targetY,n),void 0!==i.w&&(e.w=rs(i.w,e._targetW,n)),void 0!==i.h&&(e.h=rs(i.h,e._targetH,n))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){let i=t?r.get(t):void 0;e.style={...e.style||{},opacity:rs(i?i.opacity??1:0,e._targetOpacity,n)}}if(void 0===e._targetX||!t)continue;let i=r.get(t);if(!i)continue;e.x=rs(i.x,e._targetX,n),void 0!==i.openY&&(e.openY=rs(i.openY,e._targetOpenY,n)),void 0!==i.closeY&&(e.closeY=rs(i.closeY,e._targetCloseY,n)),void 0!==i.highY&&(e.highY=rs(i.highY,e._targetHighY,n)),void 0!==i.lowY&&(e.lowY=rs(i.lowY,e._targetLowY,n))}else if("line"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:rs(e._startOpacity??0,e._targetOpacity,n)}),void 0!==e._introClipFraction&&(e._introClipFraction=n);let t=e._prevPath,i=e._targetPath;if(t&&i&&t.length===e.path.length)for(let r=0;e.path.length>r;r++)e.path[r][0]=rs(t[r][0],i[r][0],n),e.path[r][1]=rs(t[r][1],i[r][1],n)}else if("area"===e.type){void 0!==e._targetOpacity&&(e.style={...e.style,opacity:rs(e._startOpacity??0,e._targetOpacity,n)}),void 0!==e._introClipFraction&&(e._introClipFraction=n);let t=e._prevTopPath,i=e._prevBottomPath,r=e._targetTopPath,o=e._targetBottomPath;if(t&&r&&t.length===e.topPath.length)for(let i=0;e.topPath.length>i;i++)e.topPath[i][0]=rs(t[i][0],r[i][0],n),e.topPath[i][1]=rs(t[i][1],r[i][1],n);if(i&&o&&i.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=rs(i[t][0],o[t][0],n),e.bottomPath[t][1]=rs(i[t][1],o[t][1],n)}}if(o>=1){for(let e of i.scene){if(void 0!==e._targetOpacity){let 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){let t=e._targetPath;if(t)for(let i=0;e.path.length>i;i++)e.path[i]=t[i];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){let t=e._targetTopPath,i=e._targetBottomPath;if(t)for(let i=0;e.topPath.length>i;i++)e.topPath[i]=t[i];if(i)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=i[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(i.exitNodes.length>0){let e=new Set(i.exitNodes);i.scene=i.scene.filter(t=>!e.has(t)),i.exitNodes=[]}return i.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,i}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null,function(e){for(let t of e){if(void 0!==t._targetOpacity){let e=t._targetOpacity;t.style={...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}if("point"===t.type)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("glyph"===t.type)void 0!==t._targetX&&(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||"heatcell"===t.type)void 0!==t._targetX&&(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)void 0!==t._targetX&&(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||"area"===t.type){if(t._introClipFraction=void 0,"line"===t.type&&t._targetPath){for(let e=0;t.path.length>e;e++)t.path[e]=t._targetPath[e];t._prevPath=void 0,t._targetPath=void 0}if("area"===t.type){if(t._targetTopPath)for(let e=0;t.topPath.length>e;e++)t.topPath[e]=t._targetTopPath[e];if(t._targetBottomPath)for(let e=0;t.bottomPath.length>e;e++)t.bottomPath[e]=t._targetBottomPath[e];t._prevTopPath=void 0,t._prevBottomPath=void 0,t._targetTopPath=void 0,t._targetBottomPath=void 0}}}}(this.scene),this.exitNodes=[]}groupData(e){let{result:t,cache:i}=function(e,t,i,r){if(r&&r.version===i&&r.group===t&&r.data===e)return{result:r.result,cache:r};let o;if(t){let i=new Map;for(let r of e){let e=t(r);i.has(e)||i.set(e,[]),i.get(e).push(r)}o=Array.from(i.entries()).map(([e,t])=>({key:e,data:t}))}else o=[{key:"_default",data:e}];return{result:o,cache:{version:i,group:t,data:e,result:o}}}(e,this.getGroup,this._ingestVersion,this._groupDataCache);return this._groupDataCache=i,t}resolveColorMap(e){let{map:t,cache:i}=function(e,t,i,r,o){if(o&&o.version===r)return{map:o.map,cache:o};let n=new Set;if(t)for(let i of e){let e=t(i);e&&n.add(e)}let a=Array.from(n).sort(),s=a.join("\0");if(o&&o.key===s){let e={...o,version:r};return{map:e.map,cache:e}}let l=ni(i.colorScheme,i.themeCategorical,Df),c=new Map;for(let e=0;a.length>e;e++)c.set(a[e],Rs(i.colorScheme,a[e])??l[e%l.length]);return{map:c,cache:{key:s,map:c,version:r}}}(e,this.getColor,this.config,this._ingestVersion,this._colorMapCache);return this._colorMapCache=i,t}resolveLineStyle(e,t){return function(e,t,i,r){let o=e.lineStyle;if("function"==typeof o){let e=o(i||{},t);if(e&&!e.stroke&&t){let i=r(t);if(i)return{...e,stroke:i}}return e}let n=e.themeSemantic?.primary;return o&&"object"==typeof o?{stroke:o.stroke||n||"#007bff",strokeWidth:o.strokeWidth??2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity,cursor:o.cursor}:{stroke:r(t)||n||"#007bff",strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveAreaStyle(e,t){return function(e,t,i,r){if(e.areaStyle){let o=e.areaStyle(i||{});if(o&&!o.fill&&t){let e=r(t);if(e)return{...o,fill:e,stroke:o.stroke||e}}return o}let o=e.lineStyle;if("function"==typeof o){let e=o(i||{},t);if(e&&!e.fill&&t){let i=r(t);if(i)return{...e,fill:i,stroke:e.stroke||i}}return e}let n=e.themeSemantic?.primary;if(o&&"object"==typeof o)return{fill:o.fill||o.stroke||n||"#4e79a7",fillOpacity:o.fillOpacity??.7,stroke:o.stroke||n||"#4e79a7",strokeWidth:o.strokeWidth??2,cursor:o.cursor};let a=r(t)||n||"#4e79a7";return{fill:a,fillOpacity:.7,stroke:a,strokeWidth:2}}(this.config,e,t,e=>this.resolveGroupColor(e))}resolveGroupColor(t){let{color:i,groupColorCounter:r}=function(e){let{group:t,colorMapCache:i,groupColorMap:r,groupColorMapCap:o,config:n}=e,{groupColorCounter:a}=e,s=Rs(n.colorScheme,t);if(s)return{color:s,groupColorCounter:a};if(i){let e=i.map.get(t);if(e)return{color:e,groupColorCounter:a}}let l=r.get(t);if(l)return{color:l,groupColorCounter:a};let c=ni(n.colorScheme,n.themeCategorical,Df);if(0===c.length)return{color:null,groupColorCounter:a};let u=c[a%c.length];if(a++,r.set(t,u),r.size>o){let e=r.keys().next().value;void 0!==e&&r.delete(e)}return{color:u,groupColorCounter:a}}({group:t,colorMapCache:this._colorMapCache,groupColorMap:this._groupColorMap,groupColorCounter:this._groupColorCounter,groupColorMapCap:e.GROUP_COLOR_MAP_CAP,config:this.config});return this._groupColorCounter=r,i}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();let t=es(e),i=this.getPointId,r=e=>t.has(i(e));Os(this.buffer,this.timestampBuffer,r);let o=this.buffer.remove(r);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(let 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");let i=es(e),r=this.getPointId,o=new Set;this.buffer.forEach((e,t)=>{i.has(r(e))&&o.add(t)});let n=this.buffer.update(e=>i.has(r(e)),t);if(0===n.length)return this.updateResults.recordNoop("update"),n;for(let e of n)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",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(e,t){let i=this._customRestyle;if(i)for(let r of e){let e=this._baseStyles.get(r)??r.style??{},o=i(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){let t={...this.config},i=Object.keys(e).filter(i=>e[i]!==t[i]);"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();let n="chartType"in e&&e.chartType!==t.chartType||"runtimeMode"in e&&e.runtimeMode!==t.runtimeMode;if(n||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){let e=["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode,i=e&&this.config.valueAccessor||this.config.yAccessor,a=e&&t.valueAccessor||t.yAccessor,s=n||!Ga(e&&this.config.timeAccessor||this.config.xAccessor,e&&t.timeAccessor||t.xAccessor),l=n||!Ga(i,a);(s||l)&&(e?(this.getX=Va(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Va(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Va(this.config.xAccessor,"x"),this.getY=Va(this.config.yAccessor,"y")),l&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=xs(this.config)),r=!0,o=!0)}if("groupAccessor"in e&&!Ga(e.groupAccessor,t.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?Ua(this.config.groupAccessor):void 0,r=!0),"categoryAccessor"in e&&!Ga(e.categoryAccessor,t.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?Ua(this.config.categoryAccessor):void 0,r=!0),"sizeAccessor"in e&&!Ga(e.sizeAccessor,t.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Va(this.config.sizeAccessor,"size"):void 0,r=!0),"symbolAccessor"in e&&!Ga(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Ua(this.config.symbolAccessor):void 0,r=!0),"colorAccessor"in e&&!Ga(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Ua(this.config.colorAccessor):void 0,r=!0),"y0Accessor"in e&&!Ga(e.y0Accessor,t.y0Accessor)&&(this.getY0=this.config.y0Accessor?Va(this.config.y0Accessor,"y0"):void 0,r=!0,o=!0),("boundsAccessor"in e&&!Ga(e.boundsAccessor,t.boundsAccessor)||"band"in e&&e.band!==t.band||"boundsStyle"in e&&e.boundsStyle!==t.boundsStyle)&&(this.resolvedRibbons=xs(this.config),r=!0,o=!0),"pointIdAccessor"in e&&!Ga(e.pointIdAccessor,t.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?Ua(this.config.pointIdAccessor):void 0,r=!0),"candlestick"===this.config.chartType&&(n||"openAccessor"in e&&!Ga(e.openAccessor,t.openAccessor)||"closeAccessor"in e&&!Ga(e.closeAccessor,t.closeAccessor)||"highAccessor"in e&&!Ga(e.highAccessor,t.highAccessor)||"lowAccessor"in e&&!Ga(e.lowAccessor,t.lowAccessor))){let e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?Va(this.config.openAccessor,"open"):void 0,this.getHigh=Va(this.config.highAccessor,"high"),this.getLow=Va(this.config.lowAccessor,"low"),this.getClose=t?Va(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){let i=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(let o of i)if(e[o]!==t[o]){r=!0;break}}r&&(o&&this.rebuildExtents(),this.needsFullRebuild=!0),this.updateResults.recordConfig(i,("bar"===this.config.chartType||"heatmap"===this.config.chartType)&&!this.config.trackHoverRows&&Ko(t.areaStyle)!==Ko(this.config.areaStyle))}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};Rx.GROUP_COLOR_MAP_CAP=1e3;var Lx=Rx;js(Lx);import{area as Cx,line as Tx}from"d3-shape";var Ox=(e,t,i,r)=>{let o=t.filter(e=>"area"===e.type);for(let t of o){if(2>t.topPath.length)continue;let i=!1;t.clipRect&&(e.save(),e.beginPath(),e.rect(t.clipRect.x,t.clipRect.y,t.clipRect.width,t.clipRect.height),e.clip(),i=!0);let o=t._introClipFraction;void 0!==o&&1>o&&(e.save(),e.beginPath(),e.rect(0,0,r.width*o,r.height),e.clip());let n=xr(e,t.style.fill,"#4e79a7"),a=t._decayOpacities,s=!(!t.colorThresholds?.length||!t.rawValues||t.rawValues.length!==t.topPath.length),l=!!t.strokeColorBands?.length;if(a&&a.length===t.topPath.length&&!s&&!l){let i=t.style.fillOpacity??.7;e.fillStyle=n;for(let r=0;t.topPath.length-1>r;r++)e.globalAlpha=.5*(a[r]+a[r+1])*i,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();let r=t.style.strokeWidth??2;if(t.style.stroke&&"none"!==t.style.stroke&&r>0){e.strokeStyle=dr(e,t.style.stroke)||t.style.stroke,e.lineWidth=r,e.setLineDash([]);for(let i=0;t.topPath.length-1>i;i++)e.globalAlpha=.5*(a[i]+a[i+1]),e.beginPath(),e.moveTo(t.topPath[i][0],t.topPath[i][1]),e.lineTo(t.topPath[i+1][0],t.topPath[i+1][1]),e.stroke()}e.globalAlpha=1;continue}let c=t.style.opacity??1;if(el(e,t),t.fillGradient&&t.fillGradient.stops.length>=2&&t.fillGradient){let i=1/0;for(let e of t.topPath)i>e[1]&&(i=e[1]);let r=-1/0;for(let e of t.bottomPath)e[1]>r&&(r=e[1]);let o=vr(e,t.fillGradient,"string"==typeof n?n:"#4e79a7",0,i,0,r);e.fillStyle=o||n,e.globalAlpha=c}else e.globalAlpha=(t.style.fillOpacity??.7)*c,e.fillStyle=n;e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(el(e,t),Zs(e,t));let u=t.style.strokeWidth??2;if(t.style.stroke&&"none"!==t.style.stroke&&u>0){e.globalAlpha=c;let i=dr(e,t.style.stroke)||t.style.stroke,r=s||l||!t.strokeGradient||2>t.topPath.length?null:vr(e,t.strokeGradient,i,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0);if(e.lineWidth=u,e.setLineDash([]),l){let r=1/0,o=-1/0;for(let[e]of t.topPath)r=Math.min(r,e),o=Math.max(o,e);let n=e.lineWidth;for(let a of t.strokeColorBands){e.save(),e.beginPath(),e.rect(r-n,a.y,o-r+2*n,a.height),e.clip();let s=a.color??i;e.strokeStyle=dr(e,s)||s,e.globalAlpha=c*(a.opacity??1),tl(e,t),e.stroke(),e.restore()}}else if(s){let r=Js(t.topPath,t.rawValues,t.colorThresholds,i);for(let t of r){e.beginPath(),e.strokeStyle=dr(e,t.color)||t.color,e.moveTo(t.path[0][0],t.path[0][1]);for(let i=1;t.path.length>i;i++)e.lineTo(t.path[i][0],t.path[i][1]);e.stroke()}}else e.strokeStyle=r||i,tl(e,t),e.stroke()}void 0!==o&&1>o&&e.restore(),i&&e.restore(),e.globalAlpha=1}};import{line as Fx}from"d3-shape";var Dx=(e,t,i,r)=>{let o=t.filter(e=>"line"===e.type);for(let t of o){if(2>t.path.length)continue;let i=t._introClipFraction;void 0!==i&&1>i&&(e.save(),e.beginPath(),e.rect(0,0,r.width*i,r.height),e.clip());let o=t.style.stroke||"#007bff",n=dr(e,o)||o,a=t.style.strokeWidth??2,s=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),a>0&&(e.lineWidth=a),e.lineCap=t.style.strokeLinecap||"butt",t.style._edgeFade&&a>0){il(e,t.path,n,a,t.style.opacity??1,t.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}let c=mr(t.curve),u=s&&s.length>0&&l&&l.length===t.path.length,d=t._decayOpacities;if(a>0&&d&&d.length===t.path.length&&!u){e.strokeStyle=n;let i=t.style.opacity??1;for(let r=0;t.path.length-1>r;r++)e.globalAlpha=.5*(d[r]+d[r+1])*i,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(a>0&&!u){e.beginPath();let i=t.strokeGradient&&t.path.length>=2?vr(e,t.strokeGradient,n,t.path[0][0],0,t.path[t.path.length-1][0],0):null;if(e.strokeStyle=i||n,c)Fx().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{let[i,r]=t.path[0];e.moveTo(i,r);for(let i=1;t.path.length>i;i++)e.lineTo(t.path[i][0],t.path[i][1])}e.stroke()}else if(a>0){let i=Js(t.path,l,s,n);for(let t of i){e.beginPath(),e.strokeStyle=dr(e,t.color)||t.color,e.moveTo(t.path[0][0],t.path[0][1]);for(let i=1;t.path.length>i;i++)e.lineTo(t.path[i][0],t.path[i][1]);e.stroke()}}if(t.style.fill&&t.style.fillOpacity&&t.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=t.style.fillOpacity,e.fillStyle=xr(e,t.style.fill,t.style.fill),c&&!u)Fx().x(e=>e[0]).y(e=>e[1]).curve(c).context(e)(t.path);else{let[i,r]=t.path[0];e.moveTo(i,r);for(let i=1;t.path.length>i;i++)e.lineTo(t.path[i][0],t.path[i][1])}let i=t.path[0][0];e.lineTo(t.path[t.path.length-1][0],r.height),e.lineTo(i,r.height),e.closePath(),e.fill()}void 0!==i&&1>i&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}},Ex=(e,t,i,r)=>{let o=t.filter(e=>"point"===e.type);if(0!==o.length){e.save();try{let t=e.globalAlpha,i=[],r="",n=i=>{e.beginPath(),e.arc(i.x,i.y,i.r,0,2*Math.PI),e.globalAlpha=t*(i.style.opacity??i.style.fillOpacity??1),e.fillStyle=xr(e,i.style.fill,"#4e79a7"),e.fill();let r=i.style.strokeWidth??1;i.style.stroke&&"none"!==i.style.stroke&&r>0&&(e.strokeStyle=xr(e,i.style.stroke,i.style.stroke),e.lineWidth=r,e.stroke()),function(e,t,i=.6){if(!Us(t))return;let r=t.r+(t._pulseGlowRadius??4)*t._pulseIntensity,o=t.cx??t.x??0,n=t.cy??t.y??0;e.beginPath(),e.arc(o,n,r,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*i,e.stroke()}(e,i)},a=()=>{if(0===i.length)return;if(1===i.length)return n(i[0]),i=[],void(r="");let o=i[0];e.globalAlpha=t*(o.style.opacity??o.style.fillOpacity??1),e.beginPath();for(let t of i)e.moveTo(t.x+t.r,t.y),e.arc(t.x,t.y,t.r,0,2*Math.PI);e.fillStyle=xr(e,o.style.fill,"#4e79a7"),e.fill();let a=o.style.strokeWidth??1;o.style.stroke&&"none"!==o.style.stroke&&a>0&&(e.strokeStyle=xr(e,o.style.stroke,o.style.stroke),e.lineWidth=a,e.stroke()),i=[],r=""};for(let e of o){let t=e.style.opacity??e.style.fillOpacity??1,o=e.style.fill;if(Us(e)||null!=o&&"string"!=typeof o||1>t){a(),n(e);continue}let s=e.style.strokeWidth??1,l=`${o??"#4e79a7"}\0${e.style.stroke&&"none"!==e.style.stroke&&s>0?e.style.stroke+"":""}\0${s}\0${e.r}\0${t}`;i.length>0&&l!==r&&a(),r=l,i.push(e),i.length>=2048&&a()}a()}finally{e.restore()}}},Nx={chartType:"line",buildScene:(e,t)=>function(e,t){let i=e.groupData(t),r=[],o=e.config.annotations?.filter(Hs).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){let{perSeries:o,aggregate:n}=qs(e.ribbons);if(n.length>0&&r.push(...Xs(e,t,n)),o.length>0)for(let t of i)r.push(...Gs(e,t.data,t.key,o))}for(let t of i){let i=e.resolveLineStyle(t.key,Uo(t.data)),n=ws(t.data,e.scales,e.getX,e.getY,i,t.key);o&&o.length>0&&(n.colorThresholds=o),e.config.curve&&"linear"!==e.config.curve&&(n.curve=e.config.curve),e.config.lineGradient&&(n.strokeGradient=e.config.lineGradient),r.push(n)}return Vs(e,i,r),r}(e,t),canvasRenderers:[Ox,Dx,Ex]},zx={chartType:"area",buildScene:(e,t)=>function(e,t){let i=e.groupData(t),r=[];if(e.ribbons&&e.ribbons.length>0){let{perSeries:o,aggregate:n}=qs(e.ribbons);if(n.length>0&&r.push(...Xs(e,t,n)),o.length>0)for(let t of i)r.push(...Gs(e,t.data,t.key,o))}let o=e.scales.y.domain(),n=o[0],a=e.config.semanticLineStops?.filter(e=>Number.isFinite(e.offset)).map(e=>({value:o[0]+Math.max(0,Math.min(1,e.offset))*(o[1]-o[0]),color:e.color,opacity:e.opacity,thresholdType:"greater"})).sort((e,t)=>e.value-t.value),s=a&&a.length>0?(()=>{let t=a.reduce((e,t)=>(e.at(-1)?.value===t.value?e[e.length-1]=t:e.push(t),e),[]),i=[{from:o[0],to:t[0].value,color:t[0].color,opacity:t[0].opacity}];for(let e=0;t.length>e;e++)i.push({from:t[e].value,to:t[e+1]?.value??o[1],color:t[e].color,opacity:t[e].opacity});return i.map(({from:t,to:i,color:r,opacity:o})=>{let n=e.scales.y(t),a=e.scales.y(i);return{y:Math.min(n,a),height:Math.abs(a-n),color:r,...null!=o&&{opacity:o}}}).filter(e=>e.height>0)})():void 0,l=e.getY0?t=>e.getY0(t)??n:void 0;for(let t of i){let i=e.resolveAreaStyle(t.key,Uo(t.data)),o=ks(t.data,e.scales,e.getX,e.getY,n,i,t.key,l),c=rl(e.config.gradientFill);c&&(o.fillGradient=c),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),a&&a.length>0&&(o.colorThresholds=a,o.strokeColorBands=s),r.push(o)}return Vs(e,i,r),r}(e,t),canvasRenderers:[Ox,Ex]},Bx={chartType:"stackedarea",buildScene:(e,t)=>function(e,t){let i=e.groupData(t),r=e.config.stackOrder??"key",o=()=>i.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("input"!==r)if("key"===r)o();else if("asc"===r||"desc"===r||"insideOut"===r){let t=new Map;for(let r of i){let i=0;for(let t of r.data){let r=e.getX(t),o=e.getY(t);Number.isFinite(r)&&Number.isFinite(o)&&(i+=o)}t.set(r.key,i)}let o=(e,t)=>t>e?-1:e>t?1:0;if("asc"===r)i.sort((e,i)=>{let r=(t.get(e.key)??0)-(t.get(i.key)??0);return 0!==r?r:o(e.key,i.key)});else if("desc"===r)i.sort((e,i)=>{let r=(t.get(i.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,i.key)});else{let e=[...i].sort((e,i)=>{let r=(t.get(i.key)??0)-(t.get(e.key)??0);return 0!==r?r:o(e.key,i.key)}),r=[],n=[],a=0,s=0;for(let i of e)s>a?(r.push(i),a+=t.get(i.key)??0):(n.push(i),s+=t.get(i.key)??0);i.length=0,i.push(...n.reverse(),...r)}}else o();let n=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,a=e.config.normalize?"zero":e.config.baseline??"zero",{nodes:s,stackedTops:l}=function(e,t,i,r,o,n,a,s="zero"){let l=new Set,c=new Map;for(let t of e){let e=new Map;for(let o of t.data){let t=i(o),n=r(o);if(!Number.isFinite(t)||(l.add(t),!Number.isFinite(n)))continue;let a=e.get(t);a?(a.value+=n,a.sources?a.sources.push(o):a.sources=[a.datum,o]):e.set(t,{value:n,datum:o})}c.set(t.key,e)}let u,d=Array.from(l).sort((e,t)=>e-t);if(n){u=new Map;for(let t of d){let i=0;for(let r of e)i+=c.get(r.key)?.get(t)?.value||0;u.set(t,i||1)}}let h=As(d,e.map(e=>e.key),(e,t)=>c.get(e)?.get(t)?.value||0,s),p="diverging"===s&&!n,f=[],y=new Map,g=new Map,m=new Map,x=new Map;for(let e of d)g.set(e,h.get(e)??0),m.set(e,0),x.set(e,0);for(let i of e){let e=c.get(i.key),r=new Map,s=[],l=[],h=[],b=[],v=[],w=!1,k=()=>{if(0!==s.length){if(s.length>=2){let e=w?s.map((e,t)=>t).sort((e,t)=>s[e][0]-s[t][0]):void 0,t={type:"area",topPath:e?e.map(e=>s[e]):s,bottomPath:e?e.map(e=>l[e]):l,rawValues:e?e.map(e=>h[e]):h,style:o(i.key,Uo(i.data)),datum:e?e.map(e=>b[e]):b,accessibleDatum:e?e.map(e=>v[e]):v,group:i.key};a&&(t.curve=a),f.push(t)}s=[],l=[],h=[],b=[],v=[],w=!1}};for(let o of d){let a,c,d=e.get(o),f=void 0!==d,y=d?.value??0;if(n&&f&&(y/=u.get(o)),!f||!Number.isFinite(y)||0===y){k();continue}p?y>0?(a=m.get(o),c=a+y,m.set(o,c)):(a=x.get(o),c=a+y,x.set(o,c)):(a=g.get(o),c=a+y,g.set(o,c));let A=t.x(o),S=t.y(a),M=t.y(c);if(!Number.isFinite(A)||!Number.isFinite(S)||!Number.isFinite(M)){k();continue}let $=d.sources,_=d.value,P=$?{...$[0],__aggregateValue:_,__aggregateCount:$.length,__aggregateRows:$}:d.datum;s.length>0&&s[s.length-1][0]>A&&(w=!0),s.push([A,M]),l.push([A,S]),b.push(P),h.push(_),v.push($?{x:o,value:_,group:i.key,observations:$.length}:P),r.set(o,c)}k(),y.set(i.key,r)}return{nodes:f,stackedTops:y}}(i,e.scales,e.getX,e.getY,(t,i)=>e.resolveAreaStyle(t,i),e.config.normalize,n,a),c=s;if(e.config.pointStyle){let t=new WeakMap;for(let r of i){let i=l.get(r.key);if(i)for(let o of r.data){let r=e.getX(o),n=e.getY(o);null!=r&&!Number.isNaN(r)&&null!=n&&!Number.isNaN(n)&&i.has(r)&&t.set(o,i.get(r))}}Vs(e,i,c,i=>t.get(i)??e.getY(i))}return c}(e,t),canvasRenderers:[Ox,Ex]},jx={chartType:"mixed",buildScene:(e,t)=>function(e,t){let i=e.groupData(t),r=[],o=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){let{perSeries:o,aggregate:n}=qs(e.ribbons);if(n.length>0&&r.push(...Xs(e,t,n)),o.length>0)for(let t of i)r.push(...Gs(e,t.data,t.key,o))}let n=e.scales.y.domain()[0],a=e.getY0?t=>e.getY0(t)??n:void 0;for(let t of i)if(o.has(t.key)){let i=e.resolveAreaStyle(t.key,Uo(t.data)),o=ks(t.data,e.scales,e.getX,e.getY,n,i,t.key,a),s=rl(e.config.gradientFill);s&&(o.fillGradient=s),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),r.push(o)}else{let i=e.resolveLineStyle(t.key,Uo(t.data)),o=ws(t.data,e.scales,e.getX,e.getY,i,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 Vs(e,i,r),r}(e,t),canvasRenderers:[Ox,Dx,Ex]};import{symbol as Wx,symbolCircle as Yx,symbolCross as qx,symbolDiamond as Xx,symbolSquare as Gx,symbolStar as Vx,symbolTriangle as Hx,symbolWye as Ux}from"d3-shape";var Kx={circle:Yx,square:Gx,triangle:Hx,diamond:Xx,star:Vx,cross:qx,wye:Ux},Zx=new Set(["circle","square","triangle","diamond","star","cross","wye","chevron"]),Qx=["circle","triangle","diamond","star","square","chevron","cross","wye"],Jx=[40,40],eb=[.5,.5],tb=null,ib=new Map,rb=(e,t)=>{let i=e.globalAlpha;for(let r of t)"symbol"===r.type&&fl(e,r,r.x,r.y,i,"#4e79a7");e.globalAlpha=i},ob=[Ex,rb],nb={chartType:"scatter",buildScene:(e,t)=>sl(e,t),canvasRenderers:ob},ab={chartType:"bubble",buildScene:(e,t)=>sl(e,t),canvasRenderers:ob},sb=256,lb=new Map,cb=(e,t,i,r)=>{let o=t.filter(e=>"heatcell"===e.type);e.save();try{let t=dr(e,"var(--semiotic-font-family, sans-serif)")||"sans-serif";for(let i of o){let r=i.style;null!=r?.opacity&&(e.globalAlpha=r.opacity);let o=br(e,i.fill,"#4e79a7");e.fillStyle=o,e.fillRect(i.x,i.y,i.w,i.h);let n=Math.max(0,r?.strokeWidth??1);if(n>0&&(e.strokeStyle=dr(e,r?.stroke??"var(--semiotic-surface, #fff)"),e.lineWidth=n,e.strokeRect(i.x,i.y,i.w,i.h)),Ks(e,i),e.globalAlpha=1,i.showValues&&null!=i.value){if(20>i.w||20>i.h)continue;let r=i.valueFormat?i.valueFormat(i.value):vl(i.value),n=Math.max(10,Math.min(16,.3*Math.min(i.w,i.h))),a=i.x+i.w/2,s=i.y+i.h/2;e.fillStyle=bl(e,"string"==typeof o?o:"#4e79a7"),e.font=`${n}px ${t}`,e.textAlign="center",e.textBaseline="middle",e.fillText(r,a,s)}}}finally{e.restore()}},ub={chartType:"heatmap",buildScene:(e,t,i)=>function(e,t,i){if(e.config.heatmapAggregation)return xl(e,t,i);if(0===t.length)return[];let r=Va(e.config.valueAccessor,"value"),o=Ha(e.config.xAccessor,"x"),n=Ha(e.config.yAccessor,"y"),a=new Map,s=new Map,l=Array(t.length),c=Array(t.length);for(let e=0;t.length>e;e++){let i=t[e],r=o(i),u=n(i);l[e]=r,c[e]=u,a.has(r)||a.set(r,a.size),s.has(u)||s.set(u,s.size)}let u=a.size,d=s.size;if(0===u||0===d)return[];let h=Array.from(a.keys()),p=Array.from(s.keys()),f=h.every(e=>"number"==typeof e&&!isNaN(e)),y=p.every(e=>"number"==typeof e&&!isNaN(e)),g=4096;if(f&&y&&u*d>g&&t.length>g){let r=new Set;for(let o=0;t.length>o;o++){let n=a.get(l[o]),d=s.get(c[o]);if(void 0!==n&&void 0!==d&&(r.add(d*u+n),r.size>g))return xl({...e,config:{...e.config,heatmapAggregation:e.config.valueAccessor?"mean":"count"}},t,i)}}if(f){h.sort((e,t)=>Number(e)-Number(t)),a.clear();for(let e=0;h.length>e;e++)a.set(h[e],e)}if(y){p.sort((e,t)=>Number(e)-Number(t)),s.clear();for(let e=0;p.length>e;e++)s.set(p[e],e)}let m=new Float64Array(t.length),x=new Float64Array(t.length),b=Array(t.length),v=new Map,w=0;for(let e=0;t.length>e;e++){let i=t[e],o=a.get(l[e]),n=s.get(c[e]);if(void 0===o||void 0===n)continue;let d,h=r(i),p=n*u+o,f=v.get(p);void 0!==f?d=f:(d=w++,v.set(p,d)),m[d]=p,x[d]=h,b[d]=i}let k=1/0,A=-1/0;for(let e=0;w>e;e++){let t=x[e];isFinite(t)&&(k>t&&(k=t),t>A&&(A=t))}if(!isFinite(k)||!isFinite(A))return[];let S=e.config.heatmapColorScale,M=S?void 0:gl("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),$=i.width/u,_=i.height/d,P=e.config.showValues,I=e.config.heatmapValueFormat,R=[];for(let t=0;w>t;t++){let i=x[t];if(!isFinite(i))continue;let r=m[t],o=r%u,n=(r-o)/u,a=yl(i,k,A),s=S?S(i):M[a],l=b[t];R.push(ml(_s(o*$,(d-1-n)*_,$,_,s,l,P?{value:i,showValues:!0,valueFormat:I}:{value:i}),l,e))}return R}(e,t,i),canvasRenderers:[cb]},db=(e,t,i,r)=>{let o=t.filter(e=>"rect"===e.type);for(let t of o){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)$l(e,t);else if(t.cornerRadii&&wl(t.cornerRadii))e.fillStyle=Sl(e,t),Al(e,t),e.fill(),Ml(e,t)&&e.stroke();else if(t.roundedTop&&t.roundedTop>0){e.fillStyle=Sl(e,t);let i=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();let{x:r,y:o,w:n,h:a}=t;switch(t.roundedEdge){case"right":e.moveTo(r,o),e.lineTo(r+n-i,o),e.arcTo(r+n,o,r+n,o+i,i),e.lineTo(r+n,o+a-i),e.arcTo(r+n,o+a,r+n-i,o+a,i),e.lineTo(r,o+a);break;case"left":e.moveTo(r+n,o),e.lineTo(r+i,o),e.arcTo(r,o,r,o+i,i),e.lineTo(r,o+a-i),e.arcTo(r,o+a,r+i,o+a,i),e.lineTo(r+n,o+a);break;case"bottom":e.moveTo(r,o),e.lineTo(r+n,o),e.lineTo(r+n,o+a-i),e.arcTo(r+n,o+a,r+n-i,o+a,i),e.lineTo(r+i,o+a),e.arcTo(r,o+a,r,o+a-i,i);break;default:e.moveTo(r,o+a),e.lineTo(r,o+i),e.arcTo(r,o,r+i,o,i),e.lineTo(r+n-i,o),e.arcTo(r+n,o,r+n,o+i,i),e.lineTo(r+n,o+a)}e.closePath(),e.fill(),Ml(e,t)&&e.stroke()}else e.fillStyle=Sl(e,t),e.fillRect(t.x,t.y,t.w,t.h),Ml(e,t)&&e.strokeRect(t.x,t.y,t.w,t.h);Ks(e,t),e.globalAlpha=1}},hb={chartType:"bar",buildScene:(e,t)=>function(e,t){if(!e.config.binSize)return{nodes:[],binBoundaries:[]};let i=bs(t,e.getX,e.getY,e.config.binSize,e.getCategory,!!e.config.trackHoverRows||Ko(e.config.areaStyle));if(0===i.size)return{nodes:[],binBoundaries:[]};let r=null;if(e.getCategory){let t=new Set;for(let e of i.values())for(let i of e.categories.keys())t.add(i);let o=e.config.barColors?Object.keys(e.config.barColors):[],n=new Set(o),a=Array.from(t).filter(e=>!n.has(e)).sort(),s=o.filter(e=>t.has(e)),l=s.join("\0")+""+a.join("\0");e.barCategoryCache&&e.barCategoryCache.key===l?r=e.barCategoryCache.order:(r=[...s,...a],e.barCategoryCache={key:l,order:r})}let o=[],n=e.scales,[a,s]=n.x.domain(),l=e.config.barStyle,c=e.config.themeSemantic?.primary,u=l?.gap,d="number"!=typeof u||0>u?1:u,h={};l?.stroke&&(h.stroke=l.stroke),"number"==typeof l?.strokeWidth&&(h.strokeWidth=l.strokeWidth),"number"==typeof l?.opacity&&(h.opacity=l.opacity),l?.cursor&&(h.cursor=l.cursor);for(let t of i.values()){let i=Math.max(t.start,a),u=Math.min(t.end,s);if(i>=u)continue;let p=n.x(i),f=n.x(u),y=Math.abs(f-p),g=y>d+1?d:0,m=Math.min(p,f)+g/2,x=Math.max(y-g,1);if(x>0)if(r&&t.categories.size>0){let i=0;for(let a of r){let r=t.categories.get(a)||0;if(0===r)continue;let s=n.y(i),u=n.y(i+r),d=Math.min(s,u),p=Math.abs(s-u),f=(e.config.barColors?si(e.config.barColors,a):void 0)??l?.fill??c??"#4e79a7",y=Go({binStart:t.start,binEnd:t.end,total:t.total,category:a,categoryValue:r},t.categoryRows?.get(a)),g=e.config.areaStyle?.(y)??{};o.push($s(m,d,x,p,{fill:f,...h,...g},y,a)),i+=r}}else{let i=n.y(0),r=n.y(t.total),a=Math.min(i,r),s=Math.abs(i-r),u=l?.fill||c||"#007bff",d=Go({binStart:t.start,binEnd:t.end,total:t.total},t.rows),p=e.config.areaStyle?.(d)??{};o.push($s(m,a,x,s,{fill:u,...h,...p},d))}}let p=new Set;for(let e of i.values())p.add(e.start),p.add(e.end);return{nodes:o,binBoundaries:Array.from(p).sort((e,t)=>e-t)}}(e,t),canvasRenderers:[db]},pb={chartType:"swarm",buildScene:(e,t)=>function(e,t){let i=[],r=e.config.swarmStyle||{},o=r.radius??3,n=r.fill??e.config.themeSemantic?.primary??"#007bff",a=r.opacity??.7,s=r.stroke,l=r.strokeWidth,c=r.cursor;for(let r of t){let t=e.getX(r),u=e.getY(r);if(null==u||Number.isNaN(u))continue;let d=e.scales.x(t),h=e.scales.y(u),p=n;if(e.getCategory){let t=e.getCategory(r)+"";p=(e.config.barColors?si(e.config.barColors,t):void 0)??p}let{r:f,...y}=e.config.pointStyle?.(r)??{},g={type:"point",x:d,y:h,r:f??o,style:{fill:p,opacity:a,stroke:s,strokeWidth:l,cursor:c,...y},datum:r};e.getPointId&&(g.pointId=e.getPointId(r)+""),i.push(g)}return i}(e,t),canvasRenderers:[Ex]},fb=(e,t,i,r)=>{db(e,t);let o=t.filter(e=>"rect"===e.type);if(2>o.length)return;let n=o[0].datum,a=n?._connectorStroke;if(a){e.save(),e.strokeStyle=dr(e,a)||a,e.lineWidth=n?._connectorWidth??1,e.setLineDash([]);for(let t=0;o.length-1>t;t++){let r=o[t],n=o[t+1],a=r.datum,s=n.datum;if(null==a?.cumEnd||null==s?.baseline)continue;let l=i.y(a.cumEnd),c=r.x+r.w,u=n.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}},yb={chartType:"waterfall",buildScene:(e,t,i)=>function(e,t,i){let r=[],o=e.scales,n=e.config.waterfallStyle,a=t.filter(t=>{let i=e.getY(t),r=e.getX(t);return null!=i&&!Number.isNaN(i)&&null!=r&&isFinite(r)});if(0===a.length)return r;let s=n?.positiveColor??e.config.themeSemantic?.success??"#28a745",l=n?.negativeColor??e.config.themeSemantic?.danger??"#dc3545",c=n?.gap??1,u=n?.stroke,d=n?.strokeWidth,h=n?.opacity,p=0;for(let t=0;a.length>t;t++){let f=a[t],y=e.getX(f),g=e.getY(f),m=p+g,x=o.x(y),b=t>0?o.x(e.getX(a[t-1])):void 0,v=a.length-1>t?o.x(e.getX(a[t+1])):void 0,w=null!=b?(b+x)/2:null!=v?x-(v-x)/2:x-i.width/20,k=null!=v?(x+v)/2:null!=b?x+(x-b)/2:x+i.width/20,A=Math.min(w,k)+c/2,S=Math.max(w,k)-c/2-A;if(0>=S){p=m;continue}let M=o.y(p),$=o.y(m),_=Math.min(M,$),P=Math.abs(M-$),I=0>g?l:s,R={...f,baseline:p,cumEnd:m,delta:g,_connectorStroke:n?.connectorStroke,_connectorWidth:n?.connectorWidth},L={fill:I,stroke:u,strokeWidth:d,opacity:h,cursor:n?.cursor,...e.config.areaStyle?.(R)};r.push($s(A,_,S,P,L,R)),p=m}return r}(e,t,i),canvasRenderers:[fb]},gb=(e,t,i,r)=>{for(let i of t){if("candlestick"!==i.type)continue;let t=i;e.save();let o=(t._decayOpacity??1)*(t.style?.opacity??1);1!==o&&(e.globalAlpha=o);let n=dr(e,t.wickColor)||t.wickColor,a=60>r.height,s=a?Math.max(t.wickWidth,2):t.wickWidth,l=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=n,e.lineWidth=s,e.stroke()};if(a||l(),t.isRange){let i=t.dotRadius??Math.max(2,Math.min(t.bodyWidth/2,.12*r.height)),o=br(e,fr(t.style?.fill)?t.style.fill:t.wickColor,t.wickColor);e.fillStyle=o,e.beginPath(),e.arc(t.x,t.highY,i,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,i,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){let i=Math.min(t.openY,t.closeY),r=Math.abs(t.openY-t.closeY),o=t.isUp?t.upColor:t.downColor,n=br(e,fr(t.style?.fill)?t.style.fill:o,o),a="string"==typeof n?n:dr(e,t.wickColor)||t.wickColor;e.fillStyle=n,e.fillRect(t.x-t.bodyWidth/2,i,t.bodyWidth,Math.max(r,1)),e.strokeStyle=a,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,i,t.bodyWidth,Math.max(r,1))}a&&l(),e.restore()}},mb={chartType:"candlestick",buildScene:(e,t,i)=>function(e,t,i){if(!e.getHigh||!e.getLow||!e.scales)return[];let r=e.config.candlestickRangeMode??!1;if(!(r||e.getOpen&&e.getClose))return[];let o=[],n=e.config.candlestickStyle||{},a=n.rangeColor||"#6366f1",s=r?a:n.upColor||"#28a745",l=r?a:n.downColor||"#dc3545",c=r?a:n.wickColor||"#333",u=n.wickWidth||(r?2:1),d=n.bodyWidth??0;if(null==n.bodyWidth){let i=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);if(i.length>1){let t=1/0,r=e.scales.x(i[0]);for(let o=1;i.length>o;o++){let n=e.scales.x(i[o]),a=Math.abs(n-r);a>0&&t>a&&(t=a),r=n}d=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else d=6}for(let a of t){let t=e.getX(a);if(null==t||Number.isNaN(t))continue;let h=e.getHigh(a),p=e.getLow(a);if(null==h||Number.isNaN(h)||null==p||Number.isNaN(p))continue;let f=r?h:e.getOpen(a),y=r?p:e.getClose(a);if(!r&&(null==f||Number.isNaN(f)||null==y||Number.isNaN(y)))continue;let g=y>=f,m=e.config.pointStyle?.(a)??{},x="string"==typeof m.fill?m.fill:void 0,b="string"==typeof m.stroke?m.stroke:void 0,v="number"==typeof m.strokeWidth?m.strokeWidth:void 0,w="number"==typeof m.opacity?m.opacity:"number"==typeof m.fillOpacity?m.fillOpacity:void 0,k={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(f),closeY:e.scales.y(y),highY:e.scales.y(h),lowY:e.scales.y(p),bodyWidth:d,upColor:x&&g?x:s,downColor:x&&!g?x:l,wickColor:b??(r&&x?x:c),wickWidth:v??u,isUp:g,style:{cursor:n.cursor,...m,...void 0!==w&&{opacity:w}},datum:a};r&&(k.isRange=!0,k.dotRadius=Math.max(2,Math.min(d/2,.12*i.height))),o.push(k)}return o}(e,t,i),canvasRenderers:[gb]},xb={chartType:"custom",buildScene:()=>[],canvasRenderers:[Ox,db,cb,Dx,Ex,rb,(e,t)=>{let i=e.globalAlpha;for(let r of t)"glyph"===r.type&&_l(e,r,r.x,r.y,i);e.globalAlpha=i},gb,Ex,fb]};import*as bb from"react";import{area as vb,line as wb}from"d3-shape";import*as kb from"react";import{jsx as Ab,jsxs as Sb}from"react/jsx-runtime";var Mb={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};import*as $b from"react";import{jsx as _b}from"react/jsx-runtime";import{jsx as Pb,jsxs as Ib}from"react/jsx-runtime";var Rb=new Set;import{scaleOrdinal as Lb}from"d3-scale";import{jsx as Cb,jsxs as Tb}from"react/jsx-runtime";import{jsx as Ob,jsxs as Fb}from"react/jsx-runtime";var Db="var(--semiotic-bg, #ffffff)";import{jsx as Eb}from"react/jsx-runtime";import{jsx as Nb,jsxs as zb}from"react/jsx-runtime";import{jsx as Bb,jsxs as jb}from"react/jsx-runtime";import{jsx as Wb}from"react/jsx-runtime";var Yb={secondary:0,primary:3},qb=new Set(["label","callout","callout-circle","callout-rect","text","widget"]),Xb=(new Set(["label","callout","callout-circle","callout-rect"]),32),Gb=6,Vb=4,Hb=8,Ub=72,Kb={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"},Zb=new Set(["top-left","top-center","top-right","middle-left","center","middle-right","bottom-left","bottom-center","bottom-right"]);import{jsx as Qb}from"react/jsx-runtime";var Jb={fill:"var(--semiotic-text, #333)",fontSize:11,fontFamily:"inherit"};import{packEnclose as ev}from"d3-hierarchy";import{area as tv,curveBasis as iv,curveCardinal as rv,curveCatmullRom as ov,curveLinear as nv,curveMonotoneX as av,curveMonotoneY as sv,curveStep as lv,curveStepAfter as cv,curveStepBefore as uv}from"d3-shape";import*as dv from"react";import{jsx as hv,jsxs as pv}from"react/jsx-runtime";var fv={linear:nv,monotoneX:av,monotoneY:sv,step:lv,stepAfter:cv,stepBefore:uv,basis:iv,cardinal:rv,catmullRom:ov};import{jsx as yv,jsxs as gv}from"react/jsx-runtime";var mv=16;import{jsx as xv}from"react/jsx-runtime";import*as bv from"react";import{jsx as vv}from"react/jsx-runtime";var wv=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];import{jsx as kv,jsxs as Av}from"react/jsx-runtime";var Sv={right:110,left:110,top:50,bottom:80};import{jsx as Mv,jsxs as $v}from"react/jsx-runtime";var _v={top:50,right:40,bottom:60,left:70},Pv={top:20,right:80,bottom:20,left:80},Iv={top:40,right:40,bottom:40,left:40},Rv=new Set(["chord","force","circlepack","orbit"]);import{jsx as Lv,jsxs as Cv}from"react/jsx-runtime";import{Fragment as Tv,jsx as Ov,jsxs as Fv}from"react/jsx-runtime";Pl();import*as Dv from"react-dom/server";import{jsx as Ev,jsxs as Nv}from"react/jsx-runtime";import{jsx as zv,jsxs as Bv}from"react/jsx-runtime";import{jsx as jv,jsxs as Wv}from"react/jsx-runtime";var Yv={top:4,bottom:4,left:4,right:4},qv={frameType:"xy",buildProps:Pu,renderStatic:function(e,t){let{data:i,colorBy:r,colorScheme:o,common:n,rest:a}=Iu(e),[s,l]=n.size??[600,400],c=a.minimap&&"object"==typeof a.minimap?a.minimap:{},u=Ru(c.height,60),d=n.margin,h=c.margin&&"object"==typeof c.margin?c.margin:{},p={top:Ru(h.top,0),right:Ru(h.right,Ru(d?.right,20)),bottom:Ru(h.bottom,20),left:Ru(h.left,Ru(d?.left,40))},f=u+p.top+p.bottom,y=a.frameProps&&"object"==typeof a.frameProps?a.frameProps:{},g={...a,xAccessor:a.xAccessor||"x",yAccessor:a.yAccessor||"y"},m={...n,size:[s,l],xExtent:y.xExtent??a.brushExtent??n.xExtent,yExtent:y.yExtent??a.yExtent??n.yExtent,_idPrefix:(n._idPrefix??"minimap")+"-detail"},x=Wg.buildProps(i,r,o,m,g);Object.assign(x,y);let b={...n,size:[s,f],margin:p,title:void 0,description:(n.description??n.title??"Chart")+" overview minimap",showAxes:c.showAxes??!1,showLegend:!1,showGrid:!1,accessibleTable:!1,background:c.background,xExtent:void 0,yExtent:a.yExtent??n.yExtent,_idPrefix:(n._idPrefix??"minimap")+"-overview"};delete b.lineStyle,delete b.pointStyle;let v={...g,fillArea:!1,lineWidth:1,showPoints:!1,directLabel:!1,forecast:void 0,anomaly:void 0,band:void 0},w=Wg.buildProps(i,r,o,b,v);w.chartType=a.fillArea?"area":"line","function"==typeof c.lineStyle&&(w.lineStyle=c.lineStyle);let k={},A={},S=gu(x,k),M=gu(w,A),$=!0===a.renderBefore,_=$?0:l,P=""+Cu(S,0,$?f:0,"detail")+Cu(M,0,_,"overview"),I=l+f,R=Rr(Ir(n.theme)),L="string"==typeof n.title?n.title:void 0,C="string"==typeof n.description?n.description:L||"Chart with overview minimap",T=lu(n),O=L?T+"-title":void 0,F=T+"-description",D="y"===c.brushDirection?"y":"x",E=Array.isArray(a.brushExtent)&&a.brushExtent.length>=2?[Number(a.brushExtent[0]),Number(a.brushExtent[1])]:null,N=A.evidence,z=null;if(E&&E.every(Number.isFinite)&&N){let e="x"===D?N.xDomain:N.yDomain;if(e&&e[0]!==e[1]){let t=Math.max(0,s-p.left-p.right),i=u,r=t=>(t-e[0])/(e[1]-e[0]);if("x"===D){let e=r(Math.min(...E))*t,o=r(Math.max(...E))*t;z=jv("rect",{className:"selection",x:p.left+e,y:_+p.top,width:o-e,height:i,fill:"steelblue",fillOpacity:.2,stroke:"steelblue",strokeWidth:1})}else{let e=(1-r(Math.max(...E)))*i,o=(1-r(Math.min(...E)))*i;z=jv("rect",{className:"selection",x:p.left,y:_+p.top+e,width:t,height:o-e,fill:"steelblue",fillOpacity:.2,stroke:"steelblue",strokeWidth:1})}}}let B=tx.renderToStaticMarkup(Wv("svg",{xmlns:"http://www.w3.org/2000/svg",className:"minimap-chart",width:s,height:I,role:"img","aria-labelledby":[O,F].filter(Boolean).join(" "),style:{fontFamily:R.fontFamily},children:[L&&jv("title",{id:O,children:L}),jv("desc",{id:F,children:C}),jv("g",{dangerouslySetInnerHTML:{__html:P}}),z]}));if(t){let e=[k.evidence,A.evidence];t.evidence=Il({frameType:"xy",width:s,height:I,parts:e,title:L,description:C,xDomain:Tu(e,"xDomain"),yDomain:Tu(e,"yDomain")})}return B}},Xv={MotifBraidChart:hg,DependencyForestChart:pg,FlowCircuitChart:fg,Sparkline:{frameType:"xy",layout:{mode:"sparkline"},buildProps:(e,t,i,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})},BumpChart:Eg,LineChart:Wg,AreaChart:qg,DifferenceChart:Xg,StackedAreaChart:Gg,Scatterplot:Ag,CandlestickChart:Vg,BubbleChart:Sg,ConnectedScatterplot:Ug,QuadrantChart:Hg,Heatmap:Kg,WaterfallChart:jg,MultiAxisLineChart:Bg,MinimapChart:qv,ScatterplotMatrix:{frameType:"xy",buildProps:Pu,renderStatic:function(e,t){let{data:i,colorBy:r,colorScheme:o,common:n,rest:a}=Iu(e),s=Array.isArray(T=i)?T.filter(e=>null!=e&&"object"==typeof e&&!Array.isArray(e)):[],l=Array.isArray(a.fields)?a.fields.filter(e=>"string"==typeof e):[],c=a.fieldLabels&&"object"==typeof a.fieldLabels?a.fieldLabels:{},u=Lu(a.cellSize,150),d=Math.max(0,Ru(a.cellGap,4)),h=Math.max(0,Ru(a.pointRadius,2)),p=Math.max(0,Math.min(1,Ru(a.pointOpacity,.5))),f=Lu(a.histogramBins,20),y="string"==typeof a.diagonal?a.diagonal:"histogram",g=40+l.length*u+l.length*d,m=l.length*u+40+l.length*d,x=Ir(n.theme),b=Rr(x),v=function(e,t,i,r){if(!t)return{categories:[],color:()=>Ff};let o=Array.from(new Set(e.map(e=>Ou(e,t)))),n="string"==typeof t?t:"__semioticSplomColor",a=li("function"==typeof t?e.map(e=>({...e,[n]:Ou(e,t)})):e,n,i??r.colors.categorical);return{categories:o,color:e=>ai(e,t,a)}}(s,r,o,x),w="string"==typeof n.title?n.title:void 0,k="string"==typeof n.description?n.description:`Scatterplot matrix comparing ${l.length} fields`,A=w?28:0,S=a.showLegend??!!r?v.categories:[],M=0,$=0,_=S.map(e=>{let t=(e=>Math.max(72,30+7*e.length))(e);M>0&&M+t>g&&($+=1,M=0);let i={label:e,x:M,y:24*$};return M+=t,i}),P=A+(S.length?24*($+1)+4:0),I=P+m,R=[],L=[],C=0;var T;l.forEach((e,t)=>{l.forEach((i,o)=>{let l=40+d+o*(u+d),g=P+t*(u+d);if(t===o){let t=function(e){let{data:t,field:i,label:r,cellSize:o,bins:n,diagonal:a,colorBy:s,color:l,x:c,y:u}=e;if("label"===a)return{visibleBars:0,svg:tx.renderToStaticMarkup(jv("svg",{x:c,y:u,width:o,height:o,"data-semiotic-composite-part":"diagonal-"+i,children:jv("text",{x:o/2,y:o/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333",children:r})}))};let d=t.map(e=>Number(e[i])).filter(Number.isFinite),h=d.length?Math.min(...d):0,p=((d.length?Math.max(...d):0)-h)/n||1,f=Array.from({length:n},()=>new Map);for(let e of t){let t=Number(e[i]);if(!Number.isFinite(t))continue;let r=Math.max(0,Math.min(n-1,Math.floor((t-h)/p))),o=s?Ou(e,s):"__all",a=f[r];a.set(o,[...a.get(o)??[],e])}let y=f.map(e=>Array.from(e.values()).reduce((e,t)=>e+t.length,0)),g=Math.max(1,...y),m=0,x=f.flatMap((e,t)=>{let i=0;return Array.from(e.entries()).flatMap(([e,r])=>{if(0===r.length)return[];m+=1;let a=r.length/g*(o-24),c=i;return i+=a,jv("rect",{x:t/n*o,y:o-c-a,width:Math.max(o/n-1,1),height:a,fill:s?l(r[0]):Ff,opacity:.6},`${t}-${e}`)})});return{visibleBars:m,svg:tx.renderToStaticMarkup(Wv("svg",{x:c,y:u,width:o,height:o,"data-semiotic-composite-part":"diagonal-"+i,children:[jv("text",{x:o/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:"bold",fill:"#333",children:r}),x]}))}}({data:s,field:e,label:si(c,e)??e,cellSize:u,bins:f,diagonal:y,colorBy:r,color:v.color,x:l,y:g});return C+=t.visibleBars,void L.push(t.svg)}let m={},x=gu({chartType:"scatter",data:s,size:[u,u],xAccessor:i,yAccessor:e,pointStyle:Pe(e=>({r:h,opacity:p,fill:v.color(e)}),a.styleRules,Ae(i,e)),margin:Yv,showAxes:!1,showGrid:!1,enableHover:!1,accessibleTable:!1,description:`${si(c,i)??i} versus ${si(c,e)??e} scatterplot`,theme:n.theme,_idPrefix:`${(n._idPrefix??"splom")+""}-${t}-${o}`},m);R.push(m.evidence),L.push(Cu(x,l,g,`cell-${e}-${i}`))})});let O=lu(n),F=w?O+"-title":void 0,D=O+"-description",E=tx.renderToStaticMarkup(Wv("svg",{xmlns:"http://www.w3.org/2000/svg",className:"scatterplot-matrix",width:g,height:I,role:"img","aria-labelledby":[F,D].filter(Boolean).join(" "),style:{fontFamily:b.fontFamily},children:[w&&jv("title",{id:F,children:w}),jv("desc",{id:D,children:k}),jv("rect",{width:g,height:I,fill:b.background}),w&&jv("text",{x:0,y:18,fontSize:14,fontWeight:600,fill:b.text,children:w}),_.map(e=>{let t=s.find(t=>r&&Ou(t,r)===e.label),i=t?v.color(t):Ff;return Wv("g",{transform:`translate(${e.x},${A+e.y})`,children:[jv("circle",{cx:5,cy:8,r:5,fill:i}),jv("text",{x:14,y:12,fontSize:11,fill:b.text,children:e.label})]},e.label)}),l.map((e,t)=>{let i=P+t*(u+d)+u/2;return jv("text",{x:20,y:i,transform:`rotate(-90 20 ${i})`,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fontWeight:"bold",fill:b.text,children:si(c,e)??e},"row-"+e)}),l.map((e,t)=>jv("text",{x:40+d+t*(u+d)+u/2,y:P+l.length*(u+d)+20,textAnchor:"middle",dominantBaseline:"middle",fontSize:11,fontWeight:"bold",fill:b.text,children:si(c,e)??e},"column-"+e)),jv("g",{dangerouslySetInnerHTML:{__html:L.join("")}})]}));return t&&(t.evidence=Il({frameType:"xy",width:g,height:I,parts:R,additionalMarkCountByType:C>0?{histogram:C}:void 0,title:w,description:k,categories:v.categories.length?v.categories:void 0,legendItems:S.length||void 0})),E}},TemporalHistogram:Yg,XYCustomChart:Ip,BarChart:um,StackedBarChart:dm,GroupedBarChart:hm,PieChart:pm,DonutChart:fm,Histogram:ym,BoxPlot:gm,ViolinPlot:mm,SwarmPlot:xm,DotPlot:bm,SwimlaneChart:wm,RidgelinePlot:km,LikertChart:rm,FunnelChart:Am,RadarChart:vm,GaugeChart:cm,OrdinalCustomChart:Rp,ParallelCoordinatesRecipe:Cp,CalendarHeatmapRecipe:Tp,ForceDirectedGraph:Wm,NetworkCustomChart:Lp,SankeyDiagram:Gm,ProcessSankey:Xm,ChordDiagram:jm,TreeDiagram:Vm,Treemap:Hm,CirclePack:Ym,OrbitDiagram:qm,ChoroplethMap:Zm,ProportionalSymbolMap:Qm,FlowMap:ex,DistanceCartogram:Jm,GeoCustomChart:{frameType:"geo",buildProps:(e,t,i,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:i,customLayout:o.layout||o.customLayout,layoutConfig:o.layoutConfig,...r})},GaltonBoardChart:Ny,EventDropChart:zy,UnitPileChart:By,CollisionSwarmChart:jy,ProcessFlowChart:Wy,GauntletChart:Yy,CrucibleChart:qy,PacketFlowChart:Xy,ChainReactionChart:{frameType:"physics",layout:{primarySize:{width:920,height:620}},buildProps:Pu,renderStatic:function(e,t){let{data:i,common:r,rest:o}=function(e){return e.__composite}(e),n=Array.isArray(y=i)?y.filter(e=>null!=e&&"object"==typeof e&&!Array.isArray(e)):[],[a,s]=r.size??[920,620],l="string"==typeof r.title?r.title:"Dependency chain reaction",c=function(e){let t=[],i=new Map,r=[],o=new Set;e.data.forEach((n,a)=>{let s=(ku(n,a,e.taskIDAccessor)??"")+"";if(!s)return void t.push({code:"duplicate-task-id",message:`Task row ${a} has an empty id.`,taskIDs:[]});if(i.has(s))return void t.push({code:"duplicate-task-id",message:`Task id "${s}" occurs more than once.`,taskIDs:[s]});let l=(ku(n,a,e.laneAccessor)??"Unassigned")+"";o.has(l)||(o.add(l),r.push(l));let c=ku(n,a,e.dependencyAccessor)??[],u=Array.from(new Set(Array.from(c,e=>e+""))).sort(Au),d=ku(n,a,e.blockerAccessor),h=ku(n,a,e.statusAccessor)??(d?"blocked":"waiting");i.set(s,{id:s,label:(ku(n,a,e.labelAccessor)??s)+"",lane:l,laneIndex:0,level:0,index:a,datum:n,dependencyIDs:u,incomingEdgeIDs:[],outgoingEdgeIDs:[],socketIDs:[],start:ku(n,a,e.startAccessor),end:ku(n,a,e.endAccessor),progress:$u(ku(n,a,e.progressAccessor)),status:h,completionTime:ku(n,a,e.completionTimeAccessor),blockerReason:d||void 0,milestone:!!ku(n,a,e.milestoneAccessor)})});let n=e.laneOrder?[...e.laneOrder,...r.filter(t=>!e.laneOrder?.includes(t))]:r,a=new Map(n.map((e,t)=>[e,t]));for(let e of i.values())e.laneIndex=a.get(e.lane)??0;let s=new Map,l=new Map;for(let e of i.keys())s.set(e,[]),l.set(e,[]);let c=[],u=[...i.values()].sort((e,t)=>e.index-t.index);for(let e of u)e.dependencyIDs.forEach((r,o)=>{let n=i.get(r);if(!n)return void t.push({code:"missing-dependency",message:`Task "${e.id}" depends on missing task "${r}".`,taskIDs:[e.id,r]});let a={id:Su(r,e.id),sourceID:r,targetID:e.id,sourceIndex:n.index,targetIndex:e.index,socketID:Mu(e.id,o),socketIndex:o};c.push(a),s.get(e.id)?.push(a),l.get(r)?.push(a),e.incomingEdgeIDs.push(a.id),e.socketIDs.push(a.socketID),n.outgoingEdgeIDs.push(a.id)});for(let e of s.values())e.sort((e,t)=>Au(e.sourceID,t.sourceID)),e.forEach((e,t)=>{e.socketIndex=t,e.socketID=Mu(e.targetID,t)});for(let e of l.values())e.sort((e,t)=>Au(e.targetID,t.targetID));for(let e of i.values()){let t=s.get(e.id)??[];e.incomingEdgeIDs=t.map(e=>e.id),e.socketIDs=t.map(e=>e.socketID),e.outgoingEdgeIDs=(l.get(e.id)??[]).map(e=>e.id)}let d=new Map,h=new Map;for(let e of i.keys())d.set(e,s.get(e)?.length??0),h.set(e,0);let p=[...i.keys()].filter(e=>0===d.get(e)).sort(Au),f=0;for(;p.length;){let e=p.shift();f+=1;for(let t of l.get(e)??[]){let i=Math.max(h.get(t.targetID)??0,(h.get(e)??0)+1);h.set(t.targetID,i);let r=(d.get(t.targetID)??0)-1;if(d.set(t.targetID,r),0===r){let e=p.findIndex(e=>e>t.targetID);0>e?p.push(t.targetID):p.splice(e,0,t.targetID)}}}if(f!==i.size){let e=[...i.keys()].filter(e=>(d.get(e)??0)>0).sort(Au);t.push({code:"cycle",message:`Dependency graph contains a cycle involving: ${e.join(", ")}.`,taskIDs:e})}let y=0,g=[...i.values()].sort((e,t)=>e.index-t.index);for(let e of g)e.level=h.get(e.id)??0,y=Math.max(y,e.level);return{nodes:g,edges:c,byID:i,incoming:s,outgoing:l,lanes:n,maxLevel:y,diagnostics:t,valid:0===t.length}}({data:n,taskIDAccessor:o.taskIDAccessor,labelAccessor:o.labelAccessor,laneAccessor:o.laneAccessor,dependencyAccessor:o.dependencyAccessor,startAccessor:o.startAccessor,endAccessor:o.endAccessor,progressAccessor:o.progressAccessor,statusAccessor:o.statusAccessor,completionTimeAccessor:o.completionTimeAccessor,blockerAccessor:o.blockerAccessor,milestoneAccessor:o.milestoneAccessor}),u=Ir(r.theme),d=Rr(u),h=lu(r),p=h+"-title",f=h+"-description";var y;if(!c.valid){let e=c.diagnostics.map(e=>e.message).join(" "),i=Dv.renderToStaticMarkup(Bv("svg",{xmlns:"http://www.w3.org/2000/svg",className:"chain-reaction-chart",width:a,height:s,role:"img","aria-labelledby":`${p} ${f}`,style:{fontFamily:d.fontFamily},children:[zv("title",{id:p,children:l}),zv("desc",{id:f,children:e}),zv("rect",{width:a,height:s,fill:d.background}),zv("text",{x:24,y:36,fontSize:16,fontWeight:700,fill:d.text,children:l}),c.diagnostics.map((e,t)=>zv("text",{x:24,y:72+22*t,fontSize:12,fill:u.colors.error,children:e.message},`${e.code}-${t}`))]}));return t&&(t.evidence=Il({frameType:"physics",width:a,height:s,parts:[],title:l,description:e,nodeCount:c.nodes.length,edgeCount:c.edges.length,extraWarnings:["INVALID_DEPENDENCY_GRAPH"]})),i}let g=function(e,t,i={}){let r=Math.max(240,t.width),o=Math.max(220,t.height),n=t.paddingX??48,a=t.paddingTop??48,s=t.paddingBottom??44,l=Math.max(70,(r-2*n)/Math.max(1,e.lanes.length)),c=Math.max(76,(o-a-s)/Math.max(1,e.maxLevel+1)),u=Math.min(i.taskWidth??112,Math.max(58,.78*l)),d=Math.min(i.taskHeight??58,.64*c),h=i.socketRadius??5,p=Math.max(1,Math.round(i.gutterCount??3)),f=new Map;for(let t of e.nodes){let e=`${t.laneIndex}:${t.level}`,i=f.get(e)??[];i.push(t),f.set(e,i)}for(let e of f.values())e.sort((e,t)=>Au(e.id,t.id));let y=.86*c,g=e.nodes.map(e=>{let t=f.get(`${e.laneIndex}:${e.level}`)??[e],i=Math.max(0,t.findIndex(t=>t.id===e.id))-(t.length-1)/2,r=(o=t.length)>1?Math.max(22,Math.min(d,(y-4*(o-1))/o)):d;var o;return{taskID:e.id,lane:e.lane,laneIndex:e.laneIndex,level:e.level,x:n+l*(e.laneIndex+.5),y:a+c*(e.level+.5)+i*(r+4),width:u,height:r}}),m=new Map(g.map(e=>[e.taskID,e])),x=[],b=[];e.edges.forEach((t,i)=>{let r=m.get(t.sourceID),o=m.get(t.targetID);if(!r||!o)return;let n=e.incoming.get(t.targetID)??[],a=Math.min(.72*o.width,14*Math.max(1,n.length-1)),s=n.length>1?o.x-a/2+a*t.socketIndex/(n.length-1):o.x,l=o.y-o.height/2-h-2;x.push({id:t.socketID,edgeID:t.id,taskID:o.taskID,index:t.socketIndex,x:s,y:l,radius:h});let c={x:r.x,y:r.y+r.height/2+3},u=Math.min(l-10,c.y+.48*Math.max(18,l-c.y)+7*(i%p-(p-1)/2));var d;b.push({edgeID:t.id,sourceID:t.sourceID,targetID:t.targetID,socketID:t.socketID,points:(d=[c,{x:c.x,y:u},{x:s,y:u},{x:s,y:l}],d.filter((e,t)=>{let i=d[t-1];return!i||i.x!==e.x||i.y!==e.y}))})});let v=new Map(x.map(e=>[e.id,e])),w=new Map(b.map(e=>[e.edgeID,e]));return{tasks:g,sockets:x,routes:b,taskByID:m,socketByID:v,routeByEdgeID:w}}(c,{width:a,height:s}),m=function(e,t,i){let r=e.nodes.map(bu).filter(e=>null!=e),o=i,n=new Set,a=new Map;for(let t of e.nodes){let e=bu(t);(null!=e&&o>=e||"done"===t.status&&!0)&&n.add(t.id),t.blockerReason&&!n.has(t.id)&&a.set(t.id,t.blockerReason)}let s=new Set;for(let t of e.edges)n.has(t.sourceID)&&s.add(t.id);return{currentTime:o,playing:!1,completed:n,delivered:s,inFlight:new Set,armed:vu(e,s,a,n),blockers:a,previewTaskID:null}}(c,0,xu(o.currentTime,1/0)),x=Array.isArray(o.selectedTaskIDs)?o.selectedTaskIDs.map(String):[],b=new Set(x),v=x[0]??null,w=v&&"none"!==o.insight?_u(c,v,{completedTaskIDs:m.completed}):null,k=new Set(w?.downstreamTaskIDs??[]),A=function(e){return"number"==typeof e&&Number.isFinite(e)?e:31}(o.seed),S=function(e,t,i){let r="string"==typeof i?i:"Tasks are arranged by workstream and dependency depth. Completed tasks deliver their authored prerequisites; task completion remains an explicit data event.",o=[...t.blockers.keys()].map(i=>{let r=_u(e,i,{completedTaskIDs:t.completed});return`${e.byID.get(i)?.label??i} affects ${r.downstreamTaskCount} unfinished tasks across ${r.affectedLaneCount} lanes.`}).join(" ");return o?`${r} ${o}`:r+" No explicit blockers are active."}(c,m,r.description),M=Dv.renderToStaticMarkup(zv(mu,{machine:c,layout:g,runtime:m,downstreamSet:k,selectedSet:b,width:a,height:s,seed:A,reduced:!0,onSelectTask:()=>{}})),$=void 0===r.theme?{}:Zo(u),_=Dv.renderToStaticMarkup(Bv("svg",{xmlns:"http://www.w3.org/2000/svg",className:"chain-reaction-chart",width:a,height:s,role:"img","aria-labelledby":`${p} ${f}`,style:{...$,fontFamily:d.fontFamily},children:[zv("title",{id:p,children:l}),zv("desc",{id:f,children:S}),zv("rect",{width:a,height:s,fill:d.background}),zv("text",{x:a/2,y:22,textAnchor:"middle",fontSize:d.titleFontSize,fontFamily:d.titleFontFamily,fontWeight:d.titleFontWeight,fill:d.text,children:l}),zv("g",{dangerouslySetInnerHTML:{__html:M}})]}));return t&&(t.evidence=Il({frameType:"physics",width:a,height:s,parts:[],additionalMarkCountByType:{task:c.nodes.length,dependency:c.edges.length},title:l,description:S,categories:c.lanes,nodeCount:c.nodes.length,edgeCount:c.edges.length})),_}},PhysicsCustomChart:Gy};import*as Gv from"react";import{jsx as Vv}from"react/jsx-runtime";var Hv=new Set(["svg","g","text","tspan","path","circle","ellipse","rect","line","polyline","polygon","use","image","defs","symbol"]);import*as Uv from"react-dom/server";import{scaleBand as Kv,scaleLinear as Zv}from"d3-scale";var Qv=class{constructor(){this.colorSchemeMap=new Map,this.colorSchemeIndex=0}resetColors(){this.colorSchemeMap.clear(),this.colorSchemeIndex=0}resolvePieceStyle(e,t,i){if(t&&"function"==typeof e.pieceStyle){let r=e.pieceStyle(t,i);return r&&!r.fill&&i?{...r,fill:this.getColorFromScheme(e,i)}:r}return e.pieceStyle&&"object"==typeof e.pieceStyle?e.pieceStyle:e.barColors&&i?{fill:si(e.barColors,i)??"#007bff"}:{fill:i?this.getColorFromScheme(e,i):"#007bff"}}resolveSummaryStyle(e,t,i){return t&&"function"==typeof e.summaryStyle?e.summaryStyle(t,i):e.summaryStyle&&"object"==typeof e.summaryStyle?e.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}getColorFromScheme(e,t){let i=this.colorSchemeMap.get(t);if(i)return i;let r=Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical||Df,o=r[this.colorSchemeIndex%r.length];return this.colorSchemeIndex++,this.colorSchemeMap.set(t,o),o}};import{quantileSorted as Jv}from"d3-array";import{scaleLinear as ew}from"d3-scale";var tw={bar:function(e,t){let{scales:i,columns:r,config:o,getR:n,getStack:a,resolvePieceStyle:s}=e,{r:l,projection:c}=i,u=[],d="vertical"===c,h="horizontal"===c,p=o.normalize,f=[];if(a){let e=new Set;for(let t of Object.values(r))for(let i of t.pieceData){let t=a(i);e.has(t)||(e.add(t),f.push(t))}}else f.push("_default");for(let e of Object.values(r)){let t=new Map;for(let i of e.pieceData){let e=a?a(i):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});let r=t.get(e);r.total+=n(i),r.pieces.push(i)}let i=0;if(p)for(let e of t.values())i+=Math.abs(e.total);let r=0,o=0;for(let n of f){let c=t.get(n);if(!c)continue;let f=c.total;p&&i>0&&(f/=i);let y=s(c.pieces[0],a?n:e.name),g={...c.pieces[0],__aggregateValue:c.total,__pieceCount:c.pieces.length,category:e.name};if(d){let t=l(0>f?o:r+f),i=0>f?l(o+f)-l(o):l(r)-l(r+f);u.push($s(e.x,t,e.width,Math.abs(i),y,g,n)),0>f?o+=f:r+=f}else if(h){let t=l(0>f?o+f:r),i=0>f?l(o)-l(o+f):l(r+f)-l(r);u.push($s(t,e.x,Math.abs(i),e.width,y,g,n)),0>f?o+=f:r+=f}}}let y="vertical"===c;for(let e of u){if("rect"!==e.type)continue;let t=e.datum?.__aggregateValue??0;e.roundedEdge=y?0>t?"bottom":"top":0>t?"left":"right",o.gradientFill&&(e.fillGradient=o.gradientFill)}if(void 0!==o.roundedTop){let e=new Map;for(let t of u){if("rect"!==t.type)continue;let i=t.datum?.category||"";e.has(i)||e.set(i,[]),e.get(i).push(t)}for(let t of e.values()){if(0===t.length)continue;let e=t.filter(e=>(e.datum?.__aggregateValue??0)>=0),i=t.filter(e=>0>(e.datum?.__aggregateValue??0));if(e.length>0){let t=e.reduce(y?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t),i=Du(o.roundedTop,t,y);i>0&&(t.roundedTop=i)}if(i.length>0){let e=i.reduce(y?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t),t=Du(o.roundedTop,e,y);t>0&&(e.roundedTop=t)}}}return u},clusterbar:function(e,t){let{scales:i,columns:r,config:o,getR:n,getGroup:a,resolvePieceStyle:s}=e,{r:l,projection:c}=i,u=[],d="vertical"===c,h=[],p=new Set;for(let e of Object.values(r))for(let t of e.pieceData){let e=a?a(t):"_default";p.has(e)||(p.add(e),h.push(e))}let f=h.length||1;for(let e of Object.values(r)){let t=e.width/f,i=.2*t,r=t-i,o=new Map;for(let t of e.pieceData){let e=a?a(t):"_default";o.has(e)||o.set(e,[]),o.get(e).push(t)}for(let a=0;h.length>a;a++){let c=o.get(h[a])||[];for(let o of c){let c=n(o),p=s(o,h[a]);if(d){let n=e.x+a*t+i/2,s=l(0),d=l(c);u.push($s(n,Math.min(s,d),r,Math.abs(s-d),p,o,h[a]))}else{let n=e.x+a*t+i/2,s=l(0),d=l(c);u.push($s(Math.min(s,d),n,Math.abs(d-s),r,p,o,h[a]))}}}}for(let e of u){if("rect"!==e.type||null==e.datum)continue;let t=n(e.datum),i=Du(o.roundedTop,e,d);i>0&&(e.roundedTop=i),e.roundedEdge=d?0>t?"bottom":"top":0>t?"left":"right",o.gradientFill&&(e.fillGradient=o.gradientFill)}return u},point:function(e,t){let{scales:i,columns:r,getR:o,multiScales:n,resolvePieceStyle:a}=e,{r:s,projection:l}=i,c=[],u="vertical"===l,d="radial"===l,h=n.length>0,p=Eu(e),f=2*Math.PI,y=-Math.PI/2;for(let e of Object.values(r))for(let t of e.pieceData){let i,r,l=t.__rIndex??0,g=t.__rValue??o(t),m=h&&n[l]||s,x=a(t,e.name),b=x.r||5;if(d){let t=y+(e.pctStart+e.pct/2)*f,o=m(g);i=Math.cos(t)*o,r=Math.sin(t)*o}else u?(i=e.middle,r=m(g)):(i=m(g),r=e.middle);Nu(c,p,t,i,r,b,x)}return c},swarm:function(e,t){let{scales:i,columns:r,getR:o,resolvePieceStyle:n}=e,{r:a,projection:s}=i,l=[],c="vertical"===s,u=Eu(e);for(let e of Object.values(r)){let t=e.width/2;for(let i=0;e.pieceData.length>i;i++){let r=e.pieceData[i],s=o(r),d=n(r,e.name),h=d.r||4,p=(7919*i%100/100-.5)*t*.8;Nu(l,u,r,c?e.middle+p:a(s),c?a(s):e.middle+p,h,d)}}return l},pie:zu,donut:zu,boxplot:function(e,t){let{scales:i,columns:r,config:o,getR:n,resolveSummaryStyle:a}=e,{r:s,projection:l}=i,c=[],u="vertical"===l,d=!1!==o.showOutliers;for(let t of Object.values(r)){let i=t.pieceData.map(e=>n(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===i.length)continue;let r=ju(i),{min:o,max:l,q1:h,median:p,q3:f}=r,y=f-h,g=h-1.5*y,m=f+1.5*y,x=i.find(e=>e>=g)??o,b=l;for(let e=i.length-1;e>=0;e--)if(m>=i[e]){b=i[e];break}r.min=x,r.max=b;let v=a(Bu(t.pieceData,t.name,r),t.name),w=[];if(d)for(let e of t.pieceData){let i=n(e);if(g>i||i>m){let r=u?t.middle:s(i),o=u?s(i):t.middle;w.push({px:r,py:o,value:i,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:s(x),q1Pos:s(h),medianPos:s(p),q3Pos:s(f),maxPos:s(b),stats:r,style:v,datum:t.pieceData,category:t.name,outliers:w}),d)for(let t of w)c.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:v.fill||e.config.themeSemantic?.secondary||"#999",opacity:.6,cursor:v.cursor},datum:t.datum})}return c},violin:function(e,t){let{scales:i,columns:r,config:o,getR:n,resolveSummaryStyle:a}=e,{r:s,projection:l}=i,c=[],u="vertical"===l,d=o.bins||20,h=!1!==o.showIQR;for(let e of Object.values(r)){let t=e.pieceData.map(e=>n(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;let i,r=t[0],o=t[t.length-1],l=(o-r)/d||1,p=Wu(t,r,o,l,d),f=ao(p,1),y=e.width/2*.9;if(u){i=`M ${e.middle} ${s(r)}`;for(let t=0;d>t;t++){let o=s(r+(t+.5)*l);i+=` L ${e.middle+p[t]/f*y} ${o}`}i+=` L ${e.middle} ${s(o)}`;for(let t=d-1;t>=0;t--){let o=s(r+(t+.5)*l);i+=` L ${e.middle-p[t]/f*y} ${o}`}i+=" Z"}else{i=`M ${s(r)} ${e.middle}`;for(let t=0;d>t;t++)i+=` L ${s(r+(t+.5)*l)} ${e.middle-p[t]/f*y}`;i+=` L ${s(o)} ${e.middle}`;for(let t=d-1;t>=0;t--)i+=` L ${s(r+(t+.5)*l)} ${e.middle+p[t]/f*y}`;i+=" Z"}let g,m=ju(t),x=a(Bu(e.pieceData,e.name,m),e.name);h&&t.length>=4&&(g={q1Pos:s(m.q1),medianPos:s(m.median),q3Pos:s(m.q3),centerPos:e.middle,isVertical:u});let b=u?{x:e.x,y:Math.min(s(o),s(r)),width:e.width,height:Math.abs(s(o)-s(r))}:{x:Math.min(s(r),s(o)),y:e.x,width:Math.abs(s(o)-s(r)),height:e.width};c.push({type:"violin",pathString:i,translateX:0,translateY:0,bounds:b,iqrLine:g,stats:m,style:x,datum:e.pieceData,category:e.name})}return c},histogram:function(e,t){let{scales:i,columns:r,config:o,getR:n,resolveSummaryStyle:a}=e,{r:s}=i,l=[],c=o.bins||25,u=o.normalize,d=s.domain?.(),h=d?+d[0]:void 0,p=d?+d[1]:void 0;for(let e of Object.values(r)){let t=e.pieceData.map(e=>n(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;let[i,r]=no(t),o=null!=h&&isFinite(h)?h:i,d=null!=p&&isFinite(p)?p:r,f=(d-o)/c||1,y=Wu(t,o,d,f,c),g=t.length,m=ao(y,1);for(let t=0;c>t;t++){if(0===y[t])continue;let i=(u?y[t]/g:y[t]/m)*e.width*.9,r=s(o+t*f),n=s(o+(t+1)*f),c=Math.min(r,n),d=Math.abs(n-r),h=e.x+e.width-i,p={...e.pieceData[0],bin:t,count:y[t],range:[o+t*f,o+(t+1)*f],category:e.name,data:e.pieceData},x=a(p,e.name);l.push($s(c,h,d,i,x,p,e.name))}}return l},ridgeline:function(e,t){let{scales:i,columns:r,config:o,getR:n,resolveSummaryStyle:a}=e,{r:s,projection:l}=i,c=[],u=o.bins||20,d="horizontal"===l,h=o.amplitude||1.5;for(let e of Object.values(r)){let t=e.pieceData.map(e=>n(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;let i,r=t[0],o=t[t.length-1],l=(o-r)/u||1,p=Wu(t,r,o,l,u),f=ao(p,1),y=ju(t),g=a(Bu(e.pieceData,e.name,y),e.name),m=e.width*h;if(d){let t=e.x+e.width;i=`M ${s(r)} ${t}`;for(let e=0;u>e;e++)i+=` L ${s(r+(e+.5)*l)} ${t-p[e]/f*m}`;i+=` L ${s(o)} ${t} Z`}else{let t=e.x;i=`M ${t} ${s(r)}`;for(let e=0;u>e;e++){let o=s(r+(e+.5)*l);i+=` L ${t+p[e]/f*m} ${o}`}i+=` L ${t} ${s(o)} Z`}let x=d?{x:Math.min(s(r),s(o)),y:e.x,width:Math.abs(s(o)-s(r)),height:e.width}:{x:e.x,y:Math.min(s(o),s(r)),width:e.width,height:Math.abs(s(o)-s(r))};c.push({type:"violin",pathString:i,translateX:0,translateY:0,bounds:x,stats:y,style:{...g,fillOpacity:g.fillOpacity??.5},datum:e.pieceData,category:e.name})}return c},timeline:function(e,t){let{scales:i,columns:r,getRawRange:o,resolvePieceStyle:n}=e,{r:a,projection:s}=i,l=[],c="horizontal"===s;for(let e of Object.values(r))for(let t of e.pieceData){let i=o(t);if(!i)continue;let[r,s]=i,u=n(t,e.name);if(c){let i=a(Math.min(r,s)),o=a(Math.max(r,s));l.push($s(i,e.x,o-i,e.width,u,t,e.name))}else{let i=a(Math.max(r,s)),o=a(Math.min(r,s));l.push($s(e.x,i,e.width,o-i,u,t,e.name))}}return l},funnel:function(e,t){let{columns:i,getR:r,getStack:o,resolvePieceStyle:n}=e,a=[],s=t.width/2,l=!1!==e.config.showLabels,c=e.scales.o.domain().map(e=>i[e]).filter(Boolean);if(0===c.length)return a;let u=[],d=new Set;for(let e of c)for(let t of e.pieceData){let e=o?o(t):"_default";d.has(e)||(d.add(e),u.push(e))}let h=u.length>1&&"_default"!==u[0],p=[],f=0;for(let e of c){let t=new Map,i=0;for(let n of e.pieceData){let e=o?o(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});let a=t.get(e),s=r(n);a.total+=s,a.pieces.push(n),i+=s}p.push({col:e,groups:t,stepTotal:i}),h||i>f&&(f=i)}if(h)for(let e of p){let t=0,i=0;for(let r=0;u.length>r;r++){let o=e.groups.get(u[r]);o&&(r%2==0?t+=o.total:i+=o.total)}let r=Math.max(t,i);r>f&&(f=r)}if(0===f)return a;let y=new Map;for(let e of u){let t=p[0].groups.get(e);y.set(e,t?.total??0)}let g=p[0].stepTotal,m=h?.95*s:.9*t.width,x=ew().domain([0,f]).range([0,m]),b=e.config.connectorOpacity??.3,v=new Map;for(let t=0;p.length>t;t++){let i=p[t],r=i.col,o=0===t,c=r.width,d=.55*c,f=r.x+(c-d)/2,m=new Map;if(h){let e=0;for(let t of u){let r=i.groups.get(t);r&&(e+=x(r.total))}let t=s,c=s;for(let h=0;u.length>h;h++){let p=u[h],g=i.groups.get(p);if(!g)continue;let b=x(g.total),v=h%2==0,w=v?t:c-b;v?t+=b:c-=b;let k=n(g.pieces[0],p),A=y.get(p)??g.total,S={...g.pieces[0],__funnelValue:g.total,__funnelPercent:A>0?g.total/A*100:0,__funnelStep:r.name,__funnelIsFirstStep:o,__aggregateValue:g.total,__pieceCount:g.pieces.length,category:p};l&&(0===h&&(S.__funnelStepLabel=r.name,S.__funnelStepLabelX=s,S.__funnelStepLabelY=f,S.__funnelRowWidth=e),S.__funnelValueLabelX=w+b/2,S.__funnelValueLabelY=f,S.__funnelBarW=b),a.push($s(w,f,b,d,k,S,p)),m.set(p,{x:w,y:f,w:b,h:d})}}else{let e=i.stepTotal,t=x(e),c=s-t/2,h=u[0],p="_default"!==h,y=i.groups.get(h)?.pieces[0]??r.pieceData[0],b=p?h:r.name,v=n(y,b),w=g>0?e/g*100:0,k={...y,__funnelValue:e,__funnelPercent:w,__funnelStep:r.name,__funnelIsFirstStep:o,category:p?h:r.name};l&&(k.__funnelStepLabel=r.name,k.__funnelStepLabelX=s,k.__funnelStepLabelY=f,k.__funnelRowWidth=t,k.__funnelValueLabelX=s,k.__funnelValueLabelY=f,k.__funnelBarW=t),a.push($s(c,f,t,d,v,k,b)),m.set(h,{x:c,y:f,w:t,h:d})}if(t>0&&v.size>0){let t=h?u:[u[0]];for(let o of t){let t=v.get(o),s=m.get(o);if(!t||!s)continue;let l=(()=>{let e=i.groups.get(o);return n(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],[s.x+s.w,s.y],[s.x,s.y]],style:{fill:l.fill||e.config.themeSemantic?.secondary||"#999",opacity:b,cursor:l.cursor},datum:i.groups.get(o)?.pieces[0]??r.pieceData[0],category:"_default"===o?r.name:o};a.push(c)}}v=m}return a},"bar-funnel":function(e,t){let{columns:i,getR:r,getStack:o,resolvePieceStyle:n,scales:a}=e,s=[],l=a.o.domain().map(e=>i[e]).filter(Boolean);if(0===l.length)return s;let c=[],u=new Set;for(let e of l)for(let t of e.pieceData){let e=o?o(t):"_default";u.has(e)||(u.add(e),c.push(e))}let d=c.length>1&&"_default"!==c[0],h=[];for(let e of l){let t=new Map,i=0;for(let n of e.pieceData){let e=o?o(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});let a=t.get(e),s=r(n);a.total+=s,a.pieces.push(n),i+=s}h.push({col:e,groups:t,stepTotal:i})}let p=new Map;for(let e of c){let t=h[0]?.groups.get(e);p.set(e,t?.total??0)}let f=a.r,y=d?c.length:1,g=d?.15:0;for(let e=0;h.length>e;e++){let t=h[e],i=t.col,r=0===e,o=e>0?h[e-1]:null,a=i.width/y,l=a*g,u=a-l;for(let e=0;c.length>e;e++){let h=c[e],y=t.groups.get(h);if(!y)continue;let g=y.total,m=p.get(h)??g,x=m>0?g/m*100:0,b=o?.groups.get(h)?.total??g,v=r?0:Math.max(0,b-g),w=i.x+e*a+l/2,k=f(g),A=f(0)-k,S=n(y.pieces[0],d?h:i.name),M={...y.pieces[0],__barFunnelValue:g,__barFunnelPercent:x,__barFunnelIsFirstStep:r,__barFunnelIsDropoff:!1,__barFunnelStep:i.name,__barFunnelDropoffValue:v,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:i.name,__barFunnelLabelX:w+u/2,__barFunnelLabelY:f(g+v)};if(s.push($s(w,k,u,A,S,M,d?h:i.name)),v>0){let e=f(g+v),t=k-e,r={...S},o={...y.pieces[0],__barFunnelValue:v,__barFunnelPercent:m>0?v/m*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:i.name,__barFunnelCategory:"_default"===h?void 0:h,category:d?h:i.name};s.push($s(w,e,u,t,r,o,d?h:i.name))}}}return s},swimlane:function(e,t){let{scales:i,columns:r,getR:o,getStack:n,resolvePieceStyle:a}=e,{r:s,projection:l}=i,c=[],u="horizontal"===l,d=e.config.gradientFill,h=u?"left":"bottom",p=new Map,f=t=>{let i=p.get(t);if(void 0!==i)return i;let r="function"==typeof e.config.roundedTop?e.config.roundedTop(t.width):e.config.roundedTop,o="number"==typeof r&&Number.isFinite(r)?Math.max(0,r):0;return p.set(t,o),o},y=e.config.trackFill;if(y){let e="string"==typeof y?y:y.color,t="string"==typeof y?1:y.opacity??1,[i,o]=s.range(),n=Math.min(i,o),a=Math.abs(o-i);for(let i of Object.values(r)){let r={fill:e,opacity:t},o=u?$s(n,i.x,a,i.width,r,null,"__track__"):$s(i.x,n,i.width,a,r,null,"__track__"),s=f(i);s>0&&(o.cornerRadii={tl:s,tr:s,br:s,bl:s}),c.push(o)}}for(let e of Object.values(r)){let t=0,i=c.length,r=f(e);for(let i of e.pieceData){let r=Math.abs(o(i));if(0===r)continue;let l,p=n?n(i):e.name,f=a(i,p);if(u){let o=s(t),n=s(t+r);l=$s(o,e.x,n-o,e.width,f,i,p)}else{let o=s(t+r),n=s(t);l=$s(e.x,o,e.width,n-o,f,i,p)}d&&(l.fillGradient=d,l.roundedEdge=h),c.push(l),t+=r}if(r>0&&c.length>i){let e=c.slice(i),t=e[0],o=e[e.length-1];1===e.length?t.cornerRadii={tl:r,tr:r,br:r,bl:r}:u?(t.cornerRadii={tl:r,bl:r},o.cornerRadii={tr:r,br:r}):(t.cornerRadii={bl:r,br:r},o.cornerRadii={tl:r,tr:r})}}return c}},iw=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],rw=["scene-style","data-paint","accessibility","evidence"],ow=(e,t)=>({retainedData:e,invalidations:t}),nw=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],aw=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],sw=["layout","scene-geometry","data-paint","overlay","accessibility","evidence"],lw=["scene-geometry","data-paint","accessibility","evidence"],cw=["scene-style","data-paint","accessibility","evidence"],uw=[],dw={chartType:ow("rebuild",nw),runtimeMode:ow("rebuild",nw),categoryAccessor:ow("rebuild",nw),valueAccessor:ow("rebuild",nw),oAccessor:ow("rebuild",nw),rAccessor:ow("rebuild",nw),stackBy:ow("rebuild",nw),groupBy:ow("rebuild",nw),timeAccessor:ow("rebuild",nw),accessorRevision:ow("rebuild",nw),colorAccessor:ow("rebuild",cw),symbolAccessor:ow("rebuild",lw),connectorAccessor:ow("rebuild",lw),dataIdAccessor:ow("rebuild",lw),projection:ow("preserve",aw),extentPadding:ow("preserve",aw),axisExtent:ow("preserve",aw),rExtent:ow("preserve",aw),oExtent:ow("preserve",aw),multiAxis:ow("preserve",aw),normalize:ow("preserve",aw),bins:ow("preserve",aw),oSort:ow("preserve",sw),barPadding:ow("preserve",sw),roundedTop:ow("preserve",sw),baselinePadding:ow("preserve",sw),innerRadius:ow("preserve",sw),cornerRadius:ow("preserve",sw),startAngle:ow("preserve",sw),sweepAngle:ow("preserve",sw),trackFill:ow("preserve",sw),showOutliers:ow("preserve",sw),showIQR:ow("preserve",sw),amplitude:ow("preserve",sw),connectorOpacity:ow("preserve",sw),showLabels:ow("preserve",sw),dynamicColumnWidth:ow("rebuild",sw),customLayout:ow("preserve",sw),layoutConfig:ow("preserve",sw),layoutMargin:ow("preserve",sw),symbolMap:ow("preserve",lw),pieceStyle:ow("preserve",cw),summaryStyle:ow("preserve",cw),connectorStyle:ow("preserve",cw),gradientFill:ow("preserve",cw),colorScheme:ow("preserve",cw),themeCategorical:ow("preserve",cw),themeSemantic:ow("preserve",cw),themeSequential:ow("preserve",cw),themeDiverging:ow("preserve",cw),barColors:ow("preserve",cw),decay:ow("preserve",cw),pulse:ow("preserve",cw),staleness:ow("preserve",cw),layoutSelection:ow("preserve",cw),windowSize:ow("preserve",uw),windowMode:ow("preserve",uw),clock:ow("preserve",uw),transition:ow("preserve",uw),introAnimation:ow("preserve",uw),onLayoutError:ow("preserve",uw)},hw=ow("preserve",sw),pw=class{constructor(){this.tracker=new Gp}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}},iw)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},rw):this.recordNoop("restyle")}recordConfig(e){let t=function(e){let t="preserve",i=new Set;for(let r of e){let e=dw[r]??hw;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}(e);return this.tracker.record({kind:"config",keys:e},t.invalidations)}};import{quadtree as fw}from"d3-quadtree";var yw=class{constructor(e){this.rExtent=new nx,this.rExtents=[],this.windowSizeWarned=!1,this.updateResults=new pw,this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this.styleResolver=new Qv,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 ox(e.windowSize),this.getO=Ua(e.categoryAccessor||e.oAccessor,"category");let t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>Va(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new nx)):(this.getR=Va(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=Ua(e.stackBy),this.getGroup=Ua(e.groupBy),this.getColor=Ua(e.colorAccessor),this.getSymbol=Ua(e.symbolAccessor),this.getConnector=Ua(e.connectorAccessor),this.getDataId=Ua(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new ox(e.windowSize))}syncPulseTimestampBuffer(){var e,t,i,r;this.timestampBuffer=(e=!!this.config.pulse,t=this.buffer,i=this.timestampBuffer,r=this.currentTime(),e?null!=i&&i.capacity===t.capacity&&i.size===t.size?i:Cs(t,r):null)}currentTime(){return this.config.clock?.()??os()}ingest(e){let t=this.currentTime();if(this.lastIngestTime=t,this._dataVersion++,e.bounded){this.buffer.clear(),this.rExtent.clear();for(let e of this.rExtents)e.clear();e.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear(),Ls(this.buffer,e.totalSize||e.inserts.length,this.timestampBuffer);for(let i of e.inserts)Ts(this.buffer,i,this.timestampBuffer,t),this.categories.add(this.getO(i)),this.pushValueExtent(i)}else{this._hasStreamingData=!0;for(let i of e.inserts){let e=Ts(this.buffer,i,this.timestampBuffer,t);this.categories.add(this.getO(i)),this.pushValueExtent(i),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){let 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){let 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){let t=this.config.valueAccessor||this.config.rAccessor;if(!t)return null;let i="function"==typeof t?t(e):e[t];return Array.isArray(i)&&i.length>=2?[+i[0],+i[1]]:null}computeScene(e){let{config:t,buffer:i}=this,r=this.scales,o=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);let a,s,l=this.getBufferArray(),c=t.projection||"vertical",u=t.oExtent||this.resolveCategories(l),d=this.computeValueDomain(l,u),h="horizontal"===c,p="radial"===c,f=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===c?e.width:e.height):.1));if(p){a=Kv().domain(u).range([0,1]).padding(0);let i=Math.min(e.width,e.height)/2,r=t.innerRadius||0;s=Zv().domain(d).range([r,i])}else h?(a=Kv().domain(u).range([0,e.height]).padding(f),s=Zv().domain(d).range([0,e.width])):(a=Kv().domain(u).range([0,e.width]).padding(f),s=Zv().domain(d).range([e.height,0]));this.scales={o:a,r:s,projection:c},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((r,o)=>{let n=this.rExtents[o];n.dirty&&n.recalculate(i,r);let[a,s]=n.extent;a===1/0&&(a=0,s=1);let l=s-a,c=l>0?l*(t.extentPadding??.05):1;return a-=c,s+=c,a>0&&(a=0),h?Zv().domain([a,s]).range([0,e.width]):Zv().domain([a,s]).range([e.height,0])}):[];let y=l;this.rAccessors.length>1&&(y=l.flatMap(e=>this.rAccessors.map((t,i)=>({...e,__rIndex:i,__rValue:t(e),__rName:this.resolveRAccessorName(i)})))),this.columns=this.buildColumns(y,u,a,c,e),this._customLayoutFailedThisBuild=!1;let g=this.buildSceneNodes(y,e);this._customLayoutFailedThisBuild?!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.scales=r,this.multiScales=o,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,l),this.config.pulse&&this.applyPulse(this.scene,l),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){let t=this.config.valueAccessor||this.config.rAccessor,i=Array.isArray(t)?t[e]:t;return"string"==typeof i?i:"value"+e}resolveCategories(e){let t=this.config.oSort,i="streaming"===this.config.runtimeMode||this._hasStreamingData,r="auto"===t?void 0:t,o=null;if(i){o=new Set;for(let t of e)o.add(this.getO(t))}let n=o?Array.from(this.categories).filter(e=>o.has(e)):Array.from(this.categories);if(i&&void 0===r){let e=Math.max(50,3*o.size);if(this.categories.size>e){let t=this.categories.size-e;for(let e of this.categories){if(0>=t)break;o.has(e)||(this.categories.delete(e),t--)}}return n}if(!1===r)return n;if("function"==typeof r)return n.sort(r);let a=new Map;for(let t of e){let e=this.getO(t);a.set(e,(a.get(e)||0)+Math.abs(this.getR(t)))}return n.sort("asc"===r?(e,t)=>(a.get(e)||0)-(a.get(t)||0):(e,t)=>(a.get(t)||0)-(a.get(e)||0))}computeValueDomain(e,t){return function(e){let{data:t,chartType:i,projection:r,normalize:o,rExtent:n,extentPadding:a=.05,baselinePadding:s,axisExtent:l,getO:c,getR:u,getStack:d,rawRExtent:h}=e,p=a;if("radial"===r&&("pie"===i||"donut"===i))return[0,1];let f=0,y=0;if("bar"===i&&d&&o)f=0,y=1;else if("bar"===i&&d){let e=new Map,i=new Map;for(let r of t){let t=c(r),o=u(r);0>o?i.set(t,(i.get(t)||0)+o):e.set(t,(e.get(t)||0)+o)}for(let t of e.values())t>y&&(y=t);for(let e of i.values())f>e&&(f=e)}else if("bar"===i){let e=new Map;for(let i of t){let t=c(i),r=u(i);e.set(t,(e.get(t)||0)+r)}for(let t of e.values())t>y&&(y=t),f>t&&(f=t)}else if("swimlane"===i){let e=new Map;for(let i of t){let t=c(i),r=Math.abs(u(i));e.set(t,(e.get(t)||0)+r)}for(let t of e.values())t>y&&(y=t)}else if("clusterbar"===i||"bar-funnel"===i)for(let e of t){let t=u(e);t>y&&(y=t),f>t&&(f=t)}else{let e=h[0],t=h[1];e!==1/0&&(f=e),t!==-1/0&&(y=t)}n&&(null!=n[0]&&(f=n[0]),null!=n[1]&&(y=n[1]));let g="bar"===i||"clusterbar"===i||"bar-funnel"===i||"swimlane"===i;if(g&&(null!=n?.[0]||null!=n?.[1]||(f>0&&(f=0),0>y&&(y=0))),"bar-funnel"!==i&&"exact"!==l){let e=y-f,t=e>0?e*p:1,r=g&&!s&&0===f,o=g&&!s&&0===y||"swimlane"===i;null==n?.[0]&&!r&&(f-=t),null==n?.[1]&&!o&&(y+=t)}return[f,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,i,r,o){return function(e){let{data:t,oExtent:i,oScale:r,projection:o,layout:n,dynamicColumnWidth:a,getO:s,getR:l}=e,c=Object.create(null),u=new Map;for(let e of t){let t=s(e);u.has(t)||u.set(t,[]),u.get(t).push(e)}let d=0;if("radial"===o)for(let e of t)d+=Math.abs(l(e));let h=null;if(a&&"radial"!==o){h=new Map;let e=0;for(let t of i){let i,r=u.get(t)||[];i="string"==typeof a?r.reduce((e,t)=>e+(Number(t[a])||0),0):a(r),h.set(t,i),e+=i}let t=("horizontal"===o?n.height:n.width)-r.padding()*r.step()*i.length;if(e>0)for(let[i,r]of h)h.set(i,r/e*t)}let p=0,f=0;for(let e of i){let t,i,o=u.get(e)||[],n=o.reduce((e,t)=>e+Math.abs(l(t)),0),a=d>0?n/d:0;h?(t=f,i=h.get(e)||r.bandwidth(),f+=i+r.padding()*r.step()):(t=r(e)??0,i=r.bandwidth()),c[e]={name:e,x:t,y:0,width:i,middle:t+i/2,padding:r.padding()*r.step(),pieceData:o,pct:a,pctStart:p},p+=a}return c}({data:e,oExtent:t,oScale:i,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){let i=this.buildLayoutContext(e,t),r=gs({family:"ordinal",logLabel:"ordinal customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:this.config.onLayoutError,run:()=>this.config.customLayout(i)});if("failure"===r.kind)return this.lastCustomLayoutFailure=r.diagnostic,this._customLayoutFailedThisBuild=!0,r.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[]);let o=r.result;this.customLayoutOverlays=o.overlays??null,this.lastCustomLayoutResult=o,this.lastCustomLayoutFailure=null;let n=o.nodes??[];if(this._customRestyle=o.restyle,this.hasCustomRestyle=!!o.restyle,this.hasCustomRestyle){this._baseStyles=new WeakMap;for(let e of n)e.style&&this._baseStyles.set(e,e.style);this.applyCustomRestyle(n,this.config.layoutSelection??null)}return ps({label:"ordinal customLayout",nodes:n,overlays:this.customLayoutOverlays,warned:this._customLayoutDiagnosticsWarned}),n}this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this.lastCustomLayoutFailure=null,this._customRestyle=void 0,this.hasCustomRestyle=!1;let i=this.getSceneContext(),r=tw[this.config.chartType],o=r?r(i,t):[];return this.getConnector&&this.scales&&(o=[...Fu(i,o),...o]),o}buildLayoutContext(e,t){let i=this.config,r=i.layoutMargin??{top:0,right:0,bottom:0,left:0},o=ui(i.colorScheme,i.themeCategorical,Df),n=this.scales;return{data:e,scales:{o:n.o,r:n.r,projection:n.projection},dimensions:{width:t.width,height:t.height,margin:r,plot:"radial"===n.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:i.themeSemantic??{},categorical:[...o]},resolveColor:di(o,i.colorScheme),config:i.layoutConfig??{},selection:i.layoutSelection??null}}computeDecayOpacity(e,t){let i=this.config.decay;return i&&t>1?ns(i,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;let t=as(e);return this._datumIndexCache={version:this._dataVersion,map:t},t}getCategoryIndexMap(e){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;let t=function(e,t){let i="function"==typeof t,r=i?null:t||"category",o=new Map;for(let n=0;e.length>n;n++){let a=e[n],s=i?t(a):a[r],l=o.get(s);l?l.push(n):o.set(s,[n])}return o}(e,this.config.categoryAccessor||this.config.oAccessor);return this._categoryIndexCache={version:this._dataVersion,map:t},t}rebuildPointQuadtree(){let e=function(e){let t=0,i=0;for(let r of e)"point"===r.type&&!1!==r.interactive&&(t++,r.r>i&&(i=r.r));if(500>=t)return{quadtree:null,maxRadius:i};let r=Array(t),o=0;for(let t of e)"point"===t.type&&!1!==t.interactive&&(r[o++]=t);return{maxRadius:i,quadtree:fw().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;let i=t.length;if(1>=i)return;let r=this.getDatumIndexMap(t);for(let t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type||!t.datum)continue;let e=r.get(t.datum);if(null==e)continue;let o=this.computeDecayOpacity(e,i);t.style={...t.style,opacity:(t.style?.opacity??1)*o}}}applyPulse(e,t,i=this.currentTime()){return!(!this.config.pulse||!this.timestampBuffer)&&function(e,t,i,r,o,n){let a=e.color??"rgba(255,255,255,0.6)",s=e.glowRadius??4,l=!1;for(let c of t){if("connector"===c.type||"violin"===c.type||"boxplot"===c.type)continue;if("wedge"===c.type){let t=c.category;if(!t)continue;let r=0;for(let a of o(t)??[]){let t=i.get(a);null!=t&&(r=Math.max(r,ss(e,t,n)))}l=ls(c,r,a)||l;continue}if(null==c.datum)continue;let t=r.get(c.datum);if(null==t)continue;let u=i.get(t);l=ls(c,null==u?0:ss(e,u,n),a,s)||l}return l}(this.config.pulse,e,this.timestampBuffer,this.getDatumIndexMap(t),e=>this.getCategoryIndexMap(t).get(e),i)}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(this.scene,this.getBufferArray(),e)}hasActivePulsesAt(e){return!!this.config.pulse&&cs(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}synthesizeIntroPositions(){this.prevPositionMap.clear();let e,t=new Map,i=this.scales?.r(0)??0,r="horizontal"!==this.scales?.projection;for(let o=0;this.scene.length>o;o++){let n=this.scene[o],a=this.getNodeKey(n,t);a&&("rect"===n.type?this.prevPositionMap.set(a,r?{x:n.x,y:i,w:n.w,h:0,opacity:n.style.opacity??1}:{x:i,y:n.y,w:0,h:n.h,opacity:n.style.opacity??1}):"point"===n.type?this.prevPositionMap.set(a,{x:n.x,y:n.y,r:0,opacity:0}):"wedge"===n.type&&(void 0===e&&(e=n.startAngle),this.prevPositionMap.set(a,{x:n.cx,y:n.cy,startAngle:e,endAngle:e,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:0})))}}getNodeKey(e,t){if("point"===e.type){let i=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,r=t.get(i)||0;return t.set(i,r+1),`${i}:${r}`}if("rect"===e.type){let i=e.datum?null!=e.datum.category&&""!==e.datum.category?e.datum.category+"":(this.getO(e.datum)??"")+"":"",r=`r:${e.group||""}:${i}`,o=t.get(r)||0;return t.set(r,o+1),0===o?r:`${r}:${o}`}return"wedge"===e.type?"w:"+(e.category??""):null}snapshotPositions(){this.prevPositionMap.clear();let e=new Map;for(let t=0;this.scene.length>t;t++){let i=this.scene[t],r=this.getNodeKey(i,e);r&&("point"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,r:i.r,opacity:i.style.opacity??i.style.fillOpacity}):"rect"===i.type?this.prevPositionMap.set(r,{x:i.x,y:i.y,w:i.w,h:i.h,opacity:i.style.opacity??i.style.fillOpacity}):"wedge"===i.type&&this.prevPositionMap.set(r,{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;let e=this.config.transition.duration??300;if(this.exitNodes.length>0){let e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let t=!1,i=new Set,r=new Map;for(let e=0;this.scene.length>e;e++){let o=this.scene[e],n=this.getNodeKey(o,r);if(!n)continue;o._transitionKey=n;let a=this.prevPositionMap.get(n);if("point"===o.type)a?(i.add(n),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(a.x!==o.x||a.y!==o.y||void 0!==a.r&&a.r!==o.r)&&(o._targetX=o.x,o._targetY=o.y,o._targetR=o.r,o.x=a.x,o.y=a.y,void 0!==a.r&&(o.r=a.r),t=!0)):(o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o._targetR=o.r,o.r=0,o.style={...o.style,opacity:0},t=!0);else if("rect"===o.type)a?(i.add(n),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(a.x!==o.x||a.y!==o.y||a.w!==o.w||a.h!==o.h)&&(o._targetX=o.x,o._targetY=o.y,o._targetW=o.w,o._targetH=o.h,o.x=a.x,o.y=a.y,o.w=a.w??o.w,o.h=a.h??o.h,t=!0)):(o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o.style={...o.style,opacity:0},t=!0);else if("wedge"===o.type)if(a)i.add(n),o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,(a.startAngle!==o.startAngle||a.endAngle!==o.endAngle)&&(o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle,o.startAngle=a.startAngle,o.endAngle=a.endAngle,t=!0);else{o._targetOpacity=o.style.opacity??o.style.fillOpacity??1,o._targetStartAngle=o.startAngle,o._targetEndAngle=o.endAngle;let e=o.startAngle;o.startAngle=e,o.endAngle=e,o.style={...o.style,opacity:0},this.prevPositionMap.set(n,{x:o.cx,y:o.cy,startAngle:e,endAngle:e,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:0}),t=!0}}this.exitNodes=[];for(let[e,r]of this.prevPositionMap)if(!i.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:")){let t=((r.startAngle??0)+(r.endAngle??0))/2,i={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(i)}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;let t=is(e,this.activeTransition),i=ts(t,"linear"===this.config.transition?.easing?"linear":"ease-out-cubic");for(let e of this.scene){let t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){let r=this.prevPositionMap.get(t);e.style.opacity=rs(r?r.opacity??1:0,e._targetOpacity,i)}let r=this.prevPositionMap.get(t);void 0!==e._targetX&&r&&(e.x=rs(r.x,e._targetX,i),e.y=rs(r.y,e._targetY,i)),void 0!==e._targetR&&void 0!==r?.r&&(e.r=rs(r.r,e._targetR,i))}else if("rect"===e.type){if(void 0!==e._targetOpacity){let r=this.prevPositionMap.get(t);e.style.opacity=rs(r?r.opacity??1:0,e._targetOpacity,i)}if(void 0===e._targetX)continue;let r=this.prevPositionMap.get(t);if(!r)continue;e.x=rs(r.x,e._targetX,i),e.y=rs(r.y,e._targetY,i),void 0!==r.w&&(e.w=rs(r.w,e._targetW,i),e.h=rs(r.h,e._targetH,i))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){let r=this.prevPositionMap.get(t);e.style={...e.style,opacity:rs(r?r.opacity??1:0,e._targetOpacity,i)}}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){let r=this.prevPositionMap.get(t);r&&void 0!==r.startAngle&&(e.startAngle=rs(r.startAngle,e._targetStartAngle,i),e.endAngle=rs(r.endAngle,e._targetEndAngle,i))}}}if(t>=1){for(let 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){let 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,function(e){for(let t of e){if(void 0!==t._targetOpacity){let e=t._targetOpacity;t.style={...t.style||{},opacity:0===e?0:e},t._targetOpacity=void 0}"point"===t.type?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):void 0!==t._targetR&&(t.r=t._targetR,t._targetR=void 0):"rect"===t.type?void 0!==t._targetX&&(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):"wedge"===t.type&&void 0!==t._targetStartAngle&&(t.startAngle=t._targetStartAngle,t.endAngle=t._targetEndAngle,t._targetStartAngle=void 0,t._targetEndAngle=void 0)}}(this.scene),this.exitNodes=[]}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();let t=es(e),i=this.getDataId,r=e=>t.has(i(e));Os(this.buffer,this.timestampBuffer,r);let o=this.buffer.remove(r);if(0===o.length)return this.updateResults.recordNoop("remove"),o;for(let 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");let i=es(e),r=this.getDataId,o=new Set;this.buffer.forEach((e,t)=>{i.has(r(e))&&o.add(t)});let n=this.buffer.update(e=>i.has(r(e)),t);if(0===n.length)return this.updateResults.recordNoop("update"),n;for(let e of n)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",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(e,t){let i=this._customRestyle;if(i)for(let r of e){let e=this._baseStyles.get(r)??r.style??{},o=i(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)}rebuildAccessorDerivedState(){this.categories.clear(),this.rExtent.clear();for(let e of this.rExtents)e.clear();this._categoryIndexCache=null,this.buffer.forEach(e=>{this.categories.add(this.getO(e)),this.pushValueExtent(e)})}updateConfig(e){let t={...this.config},i=Object.keys(e).filter(i=>e[i]!==t[i]);"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&&!Ga(e.colorAccessor,t.colorAccessor))&&this.styleResolver.resetColors(),("categoryAccessor"in e&&!Ga(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!Ga(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)&&(Ga(this.config.categoryAccessor||this.config.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=Ua(this.config.categoryAccessor||this.config.oAccessor,"category"),r=!0));let o=!1;if("valueAccessor"in e||"rAccessor"in e){let e=this.config.valueAccessor||this.config.rAccessor,i=t.valueAccessor||t.rAccessor,r=Array.isArray(e)?e:[e],n=Array.isArray(i)?i:[i];if(o=r.length!==n.length||r.some((e,t)=>!Ga(e,n[t])),o){let e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>Va(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new nx)):(this.getR=Va(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!Ga(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?Ua(this.config.stackBy):void 0),"groupBy"in e&&!Ga(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?Ua(this.config.groupBy):void 0),"colorAccessor"in e&&!Ga(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?Ua(this.config.colorAccessor):void 0),"symbolAccessor"in e&&!Ga(e.symbolAccessor,t.symbolAccessor)&&(this.getSymbol=null!=this.config.symbolAccessor?Ua(this.config.symbolAccessor):void 0),"connectorAccessor"in e&&!Ga(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?Ua(this.config.connectorAccessor):void 0),(r||o||"accessorRevision"in e&&e.accessorRevision!==t.accessorRevision)&&this.rebuildAccessorDerivedState(),this.updateResults.recordConfig(i)}updateConfigWithResult(e){return this.updateConfig(e),this.updateResults.last}};js(yw);import*as gw from"react";import*as mw from"react";import{arc as xw}from"d3-shape";var bw=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)});import{jsx as vw,jsxs as ww}from"react/jsx-runtime";import{jsx as kw,jsxs as Aw}from"react/jsx-runtime";import{jsx as Sw,jsxs as Mw}from"react/jsx-runtime";import{Fragment as $w,jsx as _w,jsxs as Pw}from"react/jsx-runtime";import*as Iw from"react-dom/server";var Rw=Object.create(null);import{min as Lw}from"d3-array";import{min as Cw,max as Tw,sum as Ow,mean as Fw,group as Dw,groups as Ew}from"d3-array";import{interpolateNumber as Nw}from"d3-interpolate";import{line as zw,curveLinearClosed as Bw}from"d3-shape";var jw=e=>{let t,i,r,o,n,a,s,l,c;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,i=e.y1-e.sankeyWidth/2,r=e.y1+e.sankeyWidth/2,o=e.y0+e.sankeyWidth/2,n=e.source.x1,a=e.target.x0,s=Nw(n,a),l=s(.5),c=s(.5),`M${t},${n}C${t},${l} ${i},${c} ${i},${a}L${r},${a}C${r},${c} ${o},${l} ${o},${n}Z`;let u=e.sankeyWidth/2,d=Nw(e.source.x1,e.target.x0),{pathD:h}=Pa({sx:e.source.x1,sTop:e.y0-u,sBot:e.y0+u,tx:e.target.x0,tTop:e.y1-u,tBot:e.y1+u,cp1X:d(.5),cp2X:d(.5)});return h},Ww=new Set,Yw=new WeakMap,qw={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(pd))-1:0},justify:fd},Xw={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,i,r){if(0===e.length)return;let o,n="vertical"===i.orientation?"down":"right",a=i.nodeAlign||"justify",s=i.nodeWidth??15,l=i.nodePaddingRatio??.05,c=i.iterations??100,u=e.map(e=>({...e})),d=t.map(e=>({...e,source:Za(e.source),target:Za(e.target),value:Math.sqrt(Math.max(1,e.value||1))}));o="down"===n?[[0,0],[r[1],r[0]]]:[[0,0],[r[0],r[1]]];let h=Dd().extent(o).links(d).nodes(u).nodeAlign(qw[a]||fd).nodeId(e=>e.id).nodeWidth(s).iterations(c);h.nodePaddingRatio&&h.nodePaddingRatio(l),h();{let e=1/0,t=-1/0,i=1/0,o=-1/0;for(let r of u)e>r.x0&&(e=r.x0),r.x1>t&&(t=r.x1),i>r.y0&&(i=r.y0),r.y1>o&&(o=r.y1);for(let r of d){if(!r.circular||!r.circularPathData)continue;let n=r.circularPathData,a=(r._circularWidth??r.width??0)/2;e>n.leftFullExtent-a&&(e=n.leftFullExtent-a),n.rightFullExtent+a>t&&(t=n.rightFullExtent+a),i>n.verticalFullExtent-a&&(i=n.verticalFullExtent-a),n.verticalFullExtent+a>o&&(o=n.verticalFullExtent+a)}let n=t-e,a=o-i,s=r[0],l=r[1];if(n>0&&a>0&&(0>e||0>i||t>s||o>l)){let t=Math.min(s/n,l/a),r=-e*t+(s-n*t)/2,o=-i*t+(l-a*t)/2;for(let e of u)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(let e of d)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){let i=e.circularPathData;i.sourceX=i.sourceX*t+r,i.targetX=i.targetX*t+r,i.sourceY=i.sourceY*t+o,i.targetY=i.targetY*t+o,i.rightFullExtent=i.rightFullExtent*t+r,i.leftFullExtent=i.leftFullExtent*t+r,i.verticalFullExtent=i.verticalFullExtent*t+o,i.rightInnerExtent=i.rightInnerExtent*t+r,i.leftInnerExtent=i.leftInnerExtent*t+r,i.verticalRightInnerExtent=i.verticalRightInnerExtent*t+o,i.verticalLeftInnerExtent=i.verticalLeftInnerExtent*t+o,i.rightSmallArcRadius*=t,i.rightLargeArcRadius*=t,i.leftSmallArcRadius*=t,i.leftLargeArcRadius*=t,i.sourceWidth*=t,i.rightNodeBuffer*=t,i.leftNodeBuffer*=t,i.arcRadius*=t}}}let p=new Map;for(let t of e)p.set(t.id,t);for(let e of u){let t=p.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)}let f=new Map;for(let e of t)if(e._edgeKey)f.set(e._edgeKey,e);else{let t=Za(e.source),i=Za(e.target);f.set(`${t}\0${i}`,e)}for(let e of d){let t=Za(e.source),i=Za(e.target),r=f.get(e._edgeKey?e._edgeKey:`${t}\0${i}`);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=n;let o=p.get(t),a=p.get(i);o&&(r.source=o),a&&(r.target=a)}}},buildScene(e,t,i,r){let o="vertical"===i.orientation?"down":"right",n=i.nodeStyle,a=i.edgeStyle,s=i.edgeOpacity??.5,l=i.edgeColorBy||"source",c=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:hf,u=new Map;e.forEach((e,t)=>{u.set(e.id,c[t%c.length])});let d=[],h=[],p=[],f=new Map;for(let t of e){let e=t.x1-t.x0,i=t.y1-t.y0;if(0>=e||0>=i)continue;let r=n?n(Nd(t,"nodeStyle")):{},a={fill:r.fill||u.get(t.id)||"#4d430c",stroke:r.stroke,strokeWidth:r.strokeWidth,opacity:r.opacity,cursor:r.cursor};f.set(t.id,("string"==typeof a.fill?a.fill:null)||u.get(t.id)||"#4d430c"),d.push("down"===o?{type:"rect",x:t.y0,y:t.x0,w:i,h:e,style:a,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:i,style:a,datum:t,id:t.id,label:t.id})}let y=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(let e of y){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;let t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999";o="function"==typeof l?l(e)||o:"target"===l?f.get(r.id)||u.get(r.id)||o:f.get(t.id)||u.get(t.id)||o;let n,c=a?a(Nd(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){let t=e.circularPathData,i=e.sankeyWidth/2,r=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),n=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),a=c.fill||o;h.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-i}L${t.sourceX+r},${t.sourceY-i}L${t.sourceX+r},${t.sourceY+i}L${t.sourceX},${t.sourceY+i}Z`,style:{fill:a,fillOpacity:c.fillOpacity??s,stroke:"none",opacity:c.opacity,cursor:c.cursor},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+r}}),h.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-i}L${t.targetX-n},${t.targetY-i}L${t.targetX-n},${t.targetY+i}L${t.targetX},${t.targetY+i}Z`,style:{fill:a,fillOpacity:c.fillOpacity??s,stroke:"none",opacity:c.opacity,cursor:c.cursor},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-n,x1:t.targetX}});continue}n=e.circular&&e.circularPathData?Ed(e):jw(e),n&&h.push({type:"bezier",pathD:n,bezierCache:e.bezier,style:{fill:c.fill||o,fillOpacity:c.fillOpacity??s,stroke:c.stroke||"none",strokeWidth:c.strokeWidth,opacity:c.opacity,cursor:c.cursor},datum:e})}if(!1!==i.showLabels){let t=Ka(i.nodeLabel);for(let i of e){let e=i.x1-i.x0,n=i.y1-i.y0;if(0>=e||0>=n)continue;let a,s,l,c=t?t(i):i.id;c&&("down"===o?(a=i.y0+(i.y1-i.y0)/2,s=i.x1+14,l="start"):(r[0]/2>i.x0+e/2?(a=i.x0-6,l="end"):(a=i.x1+6,l="start"),s=i.y0+n/2),p.push({x:a,y:s,text:c+"",anchor:"down"===o?"middle":l,baseline:"middle",fontSize:11}))}}return{sceneNodes:d,sceneEdges:h,labels:p}}};Zu("sankey",Xw);import{forceSimulation as Gw,forceCenter as Vw,forceX as Hw,forceY as Uw,forceLink as Kw,forceManyBody as Zw,forceCollide as Qw}from"d3-force";import{scaleLinear as Jw}from"d3-scale";var ek={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,i,r){if(0===e.length)return;let o=i.forceStrength??.1,n=r[0]/2,a=r[1]/2,s=Math.max(.1,Math.min(1,Math.min(r[0],r[1])/200)),l=Math.min(.5,.06+1.8*(1-s)),c=i.__previousPositions,u=0,d=[];for(let t of e){let e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),i=c?.get(t.id);e?u++:i?(t.x=i.x,t.y=i.y,u++):d.push(t)}let h=u>0&&.3>=(e.length>0?d.length/e.length:1);if(h){let i=new Map;for(let t of e)i.set(t.id,t);for(let e of d){let r=Bd(e.id,t,i);if(r.length>0){let t=0,i=0;for(let e of r)t+=e.x,i+=e.y;let o=jd(e.id),n=o%360*(Math.PI/180),a=(10+o%20)*s;e.x=t/r.length+a*Math.cos(n),e.y=i/r.length+a*Math.sin(n)}else{let t=jd(e.id),i=t%360*(Math.PI/180),r=(15+t%30)*s;e.x=n+r*Math.cos(i),e.y=a+r*Math.sin(i)}}}else{let t=2.399963229728653;for(let i=0;e.length>i;i++){let r=e[i];if(null==r.x||null==r.y||0===r.x&&0===r.y){let e=10*Math.sqrt(i+.5)*s,o=i*t;r.x=n+e*Math.cos(o),r.y=a+e*Math.sin(o)}}}let p=i.__skipForceSimulation||0===i.iterations?0:h?40:i.iterations??Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),f=zd(i.nodeSize,i.nodeSizeRange,e),y=e=>f(e);if(p>0){let c=new Map,u=new Map;for(let t of e)c.set(t.id,0),u.set(t.id,t);for(let e of t){let t=Za(e.source),i=Za(e.target);c.set(t,(c.get(t)??0)+1),c.set(i,(c.get(i)??0)+1)}let d=Kw().strength(e=>{let t=e.weight,i=Za(e.source),r=Za(e.target),n=Math.max(1,Math.min(c.get(i)??1,c.get(r)??1));return Math.min(2.5,(t&&t>0?Math.sqrt(t):1)*o/(.1*n))}).distance(e=>{let t="string"==typeof e.source?u.get(e.source):e.source,i="string"==typeof e.target?u.get(e.target):e.target,r=(t?y(t):0)+(i?y(i):0)+Math.max(6,12*s);return Math.max(16,40*s,r)}).id(e=>e.id),f=Gw();if((void 0!==i.random||void 0!==i.seed)&&f.randomSource(i.random??function(e){let t=e>>>0;return()=>{t+=1831565813;let e=t;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}(i.seed)),f.force("charge",Zw().strength(e=>{let t=c.get(e.id)??0;return-15*s*y(e)*Math.sqrt(t+1)})).force("collide",Qw(e=>y(e)+3*s).strength(.9).iterations(2)).force("center",Vw(n,a).strength(.8)).force("x",Hw(n).strength(l)).force("y",Uw(a).strength(l)).force("bounds",function(e,t,i=2,r=.6){let o=[],n=n=>{let a=r*Math.max(n,.2);for(let r of o){let o=r.x??e[0]/2,n=r.y??e[1]/2,s=r.vx??0,l=r.vy??0,c=t(r)+i,u=Math.min(e[0]/2,c),d=Math.max(e[0]/2,e[0]-c),h=Math.min(e[1]/2,c),p=Math.max(e[1]/2,e[1]-c),f=o+s,y=n+l;u>f?r.vx=s+(u-f)*a:f>d&&(r.vx=s+(d-f)*a),h>y?r.vy=l+(h-y)*a:y>p&&(r.vy=l+(p-y)*a)}};return n.initialize=e=>{o=e},n}(r,y)),f.nodes(e),t.length>0){let e=t.map(e=>({...e,source:Za(e.source),target:Za(e.target)}));d.links(e),f.force("link",d)}h?f.alpha(.3):.1>f.alpha()&&f.alpha(1),f.stop();for(let e=0;p>e;++e)f.tick()}for(let t of e){if(null==t.x||null==t.y)continue;let e=y(t),i=p>0?2:0,o=Math.min(r[0]/2,e+i),n=Math.min(r[1]/2,e+i);t.x=Math.max(o,Math.min(r[0]-o,t.x)),t.y=Math.max(n,Math.min(r[1]-n,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}let g=new Map;for(let t of e)g.set(t.id,t);for(let e of t){if("string"==typeof e.source){let t=g.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){let t=g.get(e.target);t&&(e.target=t)}}},buildScene(e,t,i,r){let o=i.nodeStyle,n=i.edgeStyle,a=zd(i.nodeSize,i.nodeSizeRange,e),s=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:hf,l=new Map;e.forEach((e,t)=>{l.set(e.id,s[t%s.length])});let c=[],u=[],d=[];for(let t of e){if(null==t.x||null==t.y)continue;let e=a(Nd(t,"nodeSize")),r=o?o(Nd(t,"nodeStyle")):{},n={fill:r.fill||l.get(t.id)||i.themeSemantic?.primary||"#007bff",stroke:r.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??2,opacity:r.opacity,cursor:r.cursor};c.push({type:"circle",cx:t.x,cy:t.y,r:e,style:n,datum:t,id:t.id,label:t.id})}let h=new Map;for(let t of e)h.set(t.id,t);for(let e of t){let t="object"==typeof e.source?e.source:h.get(e.source),r="object"==typeof e.target?e.target:h.get(e.target);if(!t||!r||null==t.x||null==t.y||null==r.x||null==r.y)continue;let o=n?n(Nd(e,"edgeStyle")):{};u.push({type:"line",x1:t.x,y1:t.y,x2:r.x,y2:r.y,style:{stroke:o.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:o.strokeWidth??1,opacity:o.opacity??.6,cursor:o.cursor},datum:e})}if(!1!==i.showLabels){let t=Ka(i.nodeLabel);for(let i of e){if(null==i.x||null==i.y)continue;let e=t?t(i):i.id;if(!e)continue;let r=a(Nd(i,"nodeSize"));d.push({x:i.x,y:i.y-r-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}return{sceneNodes:c,sceneEdges:u,labels:d}}};Zu("force",ek);import{chord as tk,ribbon as ik}from"d3-chord";import{arc as rk}from"d3-shape";var ok=hf,nk={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,i,r){if(0===e.length)return;let{padAngle:o=.01,groupWidth:n=20,sortGroups:a}=i,s=Math.min(r[0],r[1])/2,l=s-n,c=r[0]/2,u=r[1]/2,d=(p=i.valueAccessor)?"function"==typeof p?p:e=>e[p]??1:e=>e.value??1,h=new Map;var p;for(let t=0;e.length>t;t++)h.set(e[t].id,t);let f=e.length,y=Array.from({length:f},()=>Array(f).fill(0));for(let e of t){let t=Za(e.source),i=Za(e.target),r=h.get(t),o=h.get(i);if(void 0===r||void 0===o)continue;let n=d(e);y[r][o]=n}let g=tk().padAngle(o);a&&g.sortGroups(a);let m=g(y),x=m.groups,b=rk().innerRadius(l).outerRadius(s);for(let t of x){let i=e[t.index],r=b.centroid({innerRadius:l,outerRadius:s,startAngle:t.startAngle,endAngle:t.endAngle});i.x=r[0]+c,i.y=r[1]+u,i.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}let v=new Map;for(let t of e)v.set(t.id,t);for(let e of t){let t=Za(e.source),i=Za(e.target),r=v.get(t),o=v.get(i);r&&(e.source=r),o&&(e.target=o)}let w=new Map;for(let e of t){let t=Za(e.source),i=Za(e.target);w.set(`${t}\0${i}`,e)}for(let t of m){let i=e[t.source.index].id,r=e[t.target.index].id,o=w.get(`${i}\0${r}`)||w.get(`${r}\0${i}`);o&&(o.__chordData=t)}},buildScene(e,t,i,r){let{groupWidth:o=20,edgeOpacity:n=.5}=i,a=Math.min(r[0],r[1])/2,s=a-o,l=r[0]/2,c=r[1]/2,u=i.nodeStyle,d=i.edgeStyle,h=i.edgeColorBy||"source",p=Array.isArray(i.colorScheme)?i.colorScheme:i.themeCategorical&&i.themeCategorical.length>0?i.themeCategorical:ok,f=new Map;e.forEach((e,t)=>{f.set(e.id,p[t%p.length])});let y=ik().radius(s),g=[],m=[],x=[];for(let t=0;e.length>t;t++){let i=e[t],r=i.__arcData;if(!r)continue;let o=u?u(Nd(i,"nodeStyle")):{},n={fill:("string"==typeof o.fill?o.fill:void 0)||f.get(i.id)||p[t%p.length],stroke:o.stroke||"black",strokeWidth:o.strokeWidth??1,opacity:o.opacity,cursor:o.cursor};g.push({type:"arc",cx:l,cy:c,innerR:s,outerR:a,startAngle:r.startAngle-Math.PI/2,endAngle:r.endAngle-Math.PI/2,style:n,datum:i,id:i.id,label:i.id})}for(let e of t){let t=e.__chordData;if(!t)continue;let r=y(t);if(!r)continue;let o=Wd(r,l,c),a=i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",s=d?d(Nd(e,"edgeStyle")):{};if(d)a=("string"==typeof s.fill?s.fill:void 0)||a;else{let t="object"==typeof e.source?e.source:null,i="object"==typeof e.target?e.target:null;"target"===h&&i?a=f.get(i.id)||a:t&&(a=f.get(t.id)||a)}m.push({type:"ribbon",pathD:o,style:{fill:a,fillOpacity:s.fillOpacity??n,stroke:s.stroke||"none",strokeWidth:s.strokeWidth,opacity:s.opacity,cursor:s.cursor},datum:e})}if(!1!==i.showLabels){let t=Ka(i.nodeLabel),r=a+12;for(let i of e){let e=i.__arcData;if(!e)continue;let o=t?t(i):i.id;if(!o)continue;let n=(e.startAngle+e.endAngle)/2,a=n-Math.PI/2;x.push({x:l+Math.cos(a)*r,y:c+Math.sin(a)*r,text:o+"",anchor:n>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:m,labels:x}}};Zu("chord",nk);import{hierarchy as ak,tree as sk,cluster as lk,treemap as ck,pack as uk,partition as dk,treemapBinary as hk}from"d3-hierarchy";var pk=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"],fk={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,i,r){let o=i.__hierarchyRoot;if(!o)return;let n=i.chartType,a=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(i.childrenAccessor),s=i.hierarchySum,l="function"==typeof s?s:"string"==typeof s?e=>Number(e[s])||0:e=>Number(e.value)||0,c=ak(o,a);c.sum(l),c.sort((e,t)=>(t.value??0)-(e.value??0));let[u,d]=r;switch(n){case"tree":!function(e,t,i,r){let o=t.treeOrientation||"vertical",n=sk();n.size("horizontal"===o?[r,i]:"radial"===o?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),n(e)}(c,i,u,d);break;case"cluster":!function(e,t,i,r){let o=t.treeOrientation||"vertical",n=lk();n.size("horizontal"===o?[r,i]:"radial"===o?[2*Math.PI,Math.min(i,r)/2*.8]:[i,r]),n(e)}(c,i,u,d);break;case"treemap":!function(e,t,i,r){let o=t.padding??4,n=t.paddingTop??0,a=ck().size([i,r]).tile(hk).padding(o);n>0&&a.paddingTop(n),a(e)}(c,i,u,d);break;case"circlepack":!function(e,t,i,r){let o=t.padding??4;uk().size([i,r]).padding(o)(e)}(c,i,u,d);break;case"partition":!function(e,t,i,r){dk().size([i,r]).padding(t.padding??1)(e)}(c,i,u,d)}let h=c.descendants();e.length=0,t.length=0;let p=new Map;for(let t=0;h.length>t;t++){let r=h[t],o={id:qd(r,i,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"===n||"cluster"===n?Ud(o,r,i):"treemap"===n||"partition"===n?Kd(o,r):"circlepack"===n&&Zd(o,r),o.__hierarchyNode=r,e.push(o),p.set(r,o)}if("tree"===n||"cluster"===n)for(let e of h)if(e.parent){let i=p.get(e.parent),r=p.get(e);i&&r&&t.push({source:i,target:r,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,i,r){let o=i.nodeStyle||(()=>({})),n=i.edgeStyle||(()=>({}));switch(i.chartType){case"tree":case"cluster":return function(e,t,i,r,o,n){let a=[],s=[],l=[],c=i.treeOrientation||"vertical",u="radial"===c,d=r[0]/2,h=r[1]/2,p="number"==typeof(f=i.nodeSize)?f:5;var f;for(let t of e){let e=t.x,r=t.y;u&&(e+=d,r+=h);let n=o(Nd(t,"nodeStyle")),s=n.fill||Vd(i);if(i.colorByDepth&&void 0!==t.depth){let e=Gd(i);s=e[t.depth%e.length]}a.push({type:"circle",cx:e,cy:r,r:p,style:{fill:s,stroke:n.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??1,opacity:n.opacity,cursor:n.cursor},datum:t,id:t.id,label:t.id,depth:t.depth})}let y=i.edgeOpacity??.5;for(let e of t){let t="object"==typeof e.source?e.source:null,r="object"==typeof e.target?e.target:null;if(!t||!r)continue;let o=t.x,a=t.y,l=r.x,p=r.y;u&&(o+=d,a+=h,l+=d,p+=h);let f=Hd(o,a,l,p,c),g=n(Nd(e,"edgeStyle"));s.push({type:"curved",pathD:f,style:{fill:"none",stroke:g.stroke||i.themeSemantic?.border||i.themeSemantic?.secondary||"#999",strokeWidth:g.strokeWidth??1.5,opacity:g.opacity??y,cursor:g.cursor},datum:e})}if(!1!==i.showLabels){let t=Xd(i.nodeLabel);for(let i of e){let e=t?t(i):i.id;if(!e)continue;let r,o,n,a=i.x,s=i.y;if(u&&(a+=d,s+=h),u){let e=a-d,t=s-h,i=Math.sqrt(e*e+t*t);i>0?(r=a+e/i*10,o=s+t/i*10,n=0>e?"end":"start"):(r=a,o=s-12,n="middle")}else"horizontal"===c?(i.data?.children&&0!==i.data.children.length?(r=a-p-6,n="end"):(r=a+p+6,n="start"),o=s):(r=a,o=s+p+14,n="middle");l.push({x:r,y:o,text:e+"",anchor:n,baseline:"middle",fontSize:11})}}return{sceneNodes:a,sceneEdges:s,labels:l}}(e,t,i,r,o,n);case"treemap":case"partition":return function(e,t,i,r){let o=[],n=[];for(let i of e){let e=i.x1-i.x0,n=i.y1-i.y0;if(0>=e||0>=n)continue;let a=r(Nd(i,"nodeStyle")),s=a.fill||Vd(t);if(t.colorByDepth&&void 0!==i.depth){let e=Gd(t);s=e[i.depth%e.length]}o.push({type:"rect",x:i.x0,y:i.y0,w:e,h:n,style:{fill:s,stroke:a.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:a.strokeWidth??1,opacity:a.opacity,fillOpacity:a.fillOpacity,strokeOpacity:a.strokeOpacity,cursor:a.cursor},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==t.showLabels){let i=Xd(t.nodeLabel),o=t.labelMode||"leaf",a="partition"===t.chartType;for(let s of e){let e=s.x1-s.x0,l=s.y1-s.y0;if(0>=e||0>=l)continue;let c=!(s.data?.children&&s.data.children.length>0);if(!a&&("leaf"===o&&!c||"parent"===o&&c))continue;let u=i?i(s):s.id;if(!u)continue;if((c?30:40)>e||(c?16:14)>l)continue;let d=r(Nd(s,"nodeStyle")).fill||Vd(t);if(t.colorByDepth&&void 0!==s.depth){let e=Gd(t);d=e[s.depth%e.length]}let h="string"==typeof d?Yd(d):t.themeSemantic?.text??"#000";n.push(c?{x:s.x0+e/2,y:s.y0+l/2,text:u+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,l)/6)),fill:h}:{x:s.x0+4,y:s.y0+12,text:u+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:h})}}return{sceneNodes:o,sceneEdges:[],labels:n}}(e,i,0,o);case"circlepack":return function(e,t,i,r){let o=[],n=[];for(let i of e){let e=i.__radius??5;if(0>=e)continue;let n=r(Nd(i,"nodeStyle")),a=n.fill||Vd(t);if(t.colorByDepth&&void 0!==i.depth){let e=Gd(t);a=e[i.depth%e.length]}o.push({type:"circle",cx:i.x,cy:i.y,r:e,style:{fill:a,stroke:n.stroke||t.themeSemantic?.surface||"#fff",strokeWidth:n.strokeWidth??1,opacity:n.opacity??.7,cursor:n.cursor},datum:i,id:i.id,label:i.id,depth:i.depth})}if(!1!==t.showLabels){let i=Xd(t.nodeLabel);for(let o of e){let e=o.__radius??5,a=i?i(o):o.id;if(!a||15>e)continue;let s=!(o.data?.children&&o.data.children.length>0),l=r(Nd(o,"nodeStyle")).fill||Vd(t);if(t.colorByDepth&&void 0!==o.depth){let e=Gd(t);l=e[o.depth%e.length]}if(s){let i="string"==typeof l?Yd(l):t.themeSemantic?.text??"#000";n.push({x:o.x,y:o.y,text:a+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:i})}else n.push({x:o.x,y:o.y-e+14,text:a+"",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:n}}(e,i,0,o);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};Zu("tree",fk),Zu("cluster",fk),Zu("treemap",fk),Zu("circlepack",fk),Zu("partition",fk);import{pie as yk}from"d3-shape";var gk={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,i,r){let o=i.__hierarchyRoot;o&&function(e,t,i,r,o){function n(e){let t=f.get(e)??0;return f.set(e,t+1),0===t?e:`${e}__${t}`}let a=function(e){if("function"==typeof e)return e;let t=e||"children";return e=>e[t]||null}(i.childrenAccessor),s=function(e){if("function"==typeof e)return e;let t=e||"name";return e=>(e[t]??"")+""}(i.nodeIDAccessor),l=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(i.orbitMode),c=i.orbitSize??2.95,u=i.orbitEccentricity??1,d="number"==typeof c?()=>c:c,h="number"==typeof u?()=>u:u,p=Qd(i);p.metaMap.clear(),r.length=0,o.length=0;let f=new Map,y=t[0]/2,g=t[1]/2,m=Math.min(t[0],t[1])/2*.85,x=n(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}),p.metaMap.set(x,{ring:m,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,i,c,u,f,y,g){let m=a(t);if(!m?.length)return;let x=m.length,b=0,v=0,w=0;for(;x>v;)v+=l[Math.min(w,l.length-1)],w++,b++;let k=0;for(let x=0;b>x;x++){let v=l[Math.min(x,l.length-1)],w=m.slice(k,k+v);if(!w.length)break;let A=(x+1)/b,S={id:i,depth:y,data:t,parentId:i},M=g?f/d(S)*A:f*A,$=yk().value(e=>a(e)?.length?4:1).sort(null)(w),_=h(S);for(let t=0;w.length>t;t++){let a=($[t].startAngle+$[t].endAngle)/2,l=w[t],d=n(s(l)),h=c+M*Math.sin(a),f=u+M*Math.cos(a)*_;r.push({id:d,x:h,y:f,x0:h,x1:h,y0:f,y1:f,width:0,height:0,value:0,depth:y,data:l}),p.metaMap.set(d,{ring:M,angle:a,depth:y,parentId:i,eccentricity:_}),o.push({source:i,target:d,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:i,target:d}}),e(l,d,h,f,M,y+1,!0)}k+=v}}(e,x,y,g,m,1,!1)}(o,r,i,e,t)},buildScene(e,t,i,r){let o=i.nodeStyle,n=i.edgeStyle,a=i.nodeSize,s="number"==typeof a?()=>a:"function"==typeof a?a:()=>6,l=[],c=[],u=[];if(!1!==i.orbitShowRings){let t=Qd(i),r=new Map;for(let t of e)r.set(t.id,t);let o=new Map;for(let[,e]of t.metaMap){if(!e.parentId)continue;let t=r.get(e.parentId);if(!t)continue;let i=`${e.parentId}:${e.ring}`;o.has(i)||o.set(i,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}let n=48,a={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(let[,{parentX:e,parentY:t,ring:i,ecc:r}]of o)for(let o=0;n>o;o++){let s=o/n*Math.PI*2,l=(o+1)/n*Math.PI*2;c.push({type:"line",x1:e+i*Math.sin(s),y1:t+i*Math.cos(s)*r,x2:e+i*Math.sin(l),y2:t+i*Math.cos(l)*r,style:a,datum:null})}}for(let t of e){if(null==t.x||null==t.y)continue;let e=s(Nd(t,"nodeSize")),r=o?o(Nd(t,"nodeStyle")):{};l.push({type:"circle",cx:t.x,cy:t.y,r:e,style:{fill:r.fill||i.themeSemantic?.primary||"#6366f1",stroke:r.stroke||i.themeSemantic?.surface||"#fff",strokeWidth:r.strokeWidth??1,opacity:r.opacity??(0===(t.depth??0)?1:.85),cursor:r.cursor},datum:t,id:t.id,label:t.id,depth:t.depth})}let d=new Map;for(let t of e)d.set(t.id,t);for(let e of t){let t="object"==typeof e.source?e.source:d.get(e.source),i="object"==typeof e.target?e.target:d.get(e.target);if(!t||!i||null==t.x||null==i.x)continue;let r=n?n(Nd(e,"edgeStyle")):{};c.push({type:"line",x1:t.x,y1:t.y,x2:i.x,y2:i.y,style:{stroke:r.stroke||"rgba(128,128,128,0.35)",strokeWidth:r.strokeWidth??.5,opacity:r.opacity??1,cursor:r.cursor},datum:e})}if(i.showLabels){let t=i.nodeLabel;for(let i of e){let e=s(Nd(i,"nodeSize"));if(4>=e)continue;let r="function"==typeof t?t(i):t?i.data?.[t]??i.id:i.id;u.push({x:i.x,y:i.y+e+12,text:r+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:l,sceneEdges:c,labels:u}},tick:(e,t,i,r,o)=>!1!==i.orbitAnimated&&(function(e,t){let i=Qd(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=>{let t=e.depth??0;return(t%2==0?1:-1)/(t+1)};default:return e=>1/((e.depth??0)+1)}}(t.orbitRevolutionStyle),n=(("u">typeof performance?performance.now():Date.now())-i.startTime)/1e3,a=r*(Math.PI/6),s=new Map;for(let t of e)s.set(t.id,t);for(let t of e){let e=i.metaMap.get(t.id);if(!e||!e.parentId)continue;let r=s.get(e.parentId);if(!r)continue;let l=e.angle+n*a*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,i),!0)};Zu("orbit",gk);import*as mk from"react";import{arc as xk}from"d3-shape";import{jsx as bk,jsxs as vk}from"react/jsx-runtime";import{Fragment as wk,jsxs as kk}from"react/jsx-runtime";Zu("sankey",Xw),Zu("force",ek),Zu("chord",nk),Zu("tree",fk),Zu("cluster",fk),Zu("treemap",fk),Zu("circlepack",fk),Zu("partition",fk),Zu("orbit",gk);var Ak=new Set(["tree","cluster","treemap","circlepack","partition","orbit"]);import*as Sk from"react-dom/server";import{geoPath as Mk}from"d3-geo";import{quadtree as $k}from"d3-quadtree";import{geoMercator as _k,geoEqualEarth as Pk,geoAlbersUsa as Ik,geoOrthographic as Rk,geoNaturalEarth1 as Lk,geoEquirectangular as Ck}from"d3-geo";var Tk={mercator:_k,equalEarth:Pk,albersUsa:Ik,orthographic:Rk,naturalEarth:Lk,equirectangular:Ck};import{scaleLinear as Ok}from"d3-scale";var Fk=["data","domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Dk=["scene-style","data-paint","accessibility","evidence"],Ek=(e,t)=>({retainedData:e,invalidations:t}),Nk=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],zk=["domain","layout","scene-geometry","data-paint","overlay","accessibility","evidence"],Bk=["scene-geometry","data-paint","accessibility","evidence"],jk=["scene-style","data-paint","accessibility","evidence"],Wk=["overlay","accessibility","evidence"],Yk=[],qk={xAccessor:Ek("rebuild",Nk),yAccessor:Ek("rebuild",Nk),lineDataAccessor:Ek("rebuild",Nk),pointIdAccessor:Ek("rebuild",Bk),lineIdAccessor:Ek("rebuild",Bk),windowSize:Ek("rebuild",Nk),projection:Ek("preserve",zk),projectionExtent:Ek("preserve",zk),fitPadding:Ek("preserve",zk),lineType:Ek("preserve",zk),flowStyle:Ek("preserve",zk),graticule:Ek("preserve",zk),projectionTransform:Ek("preserve",zk),customLayout:Ek("preserve",zk),layoutConfig:Ek("preserve",zk),layoutMargin:Ek("preserve",zk),areaStyle:Ek("preserve",jk),pointStyle:Ek("preserve",["scene-geometry","scene-style","data-paint","accessibility","evidence"]),lineStyle:Ek("preserve",jk),colorScheme:Ek("preserve",jk),themeCategorical:Ek("preserve",jk),themeDiverging:Ek("preserve",jk),themeSemantic:Ek("preserve",jk),themeSequential:Ek("preserve",jk),decay:Ek("preserve",jk),pulse:Ek("preserve",jk),layoutSelection:Ek("preserve",jk),annotations:Ek("preserve",Wk),autoPlaceAnnotations:Ek("preserve",Wk),clock:Ek("preserve",Yk),transition:Ek("preserve",Yk),introAnimation:Ek("preserve",Yk),onLayoutError:Ek("preserve",Yk)},Xk=Ek("preserve",zk),Gk=class{constructor(){this.tracker=new Gp}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}},Fk)}recordNoop(e){return this.tracker.record({kind:e,..."restyle"===e?{}:{count:0}},[])}recordRestyle(e){return e?this.tracker.record({kind:"restyle"},Dk):this.recordNoop("restyle")}recordConfig(e,t={}){let i=function(e){let t="preserve",i=new Set;for(let r of e){let e=qk[r]??Xk;"rebuild"===e.retainedData&&(t="rebuild");for(let t of e.invalidations)i.add(t)}return{retainedData:t,invalidations:i}}(e),r=new Set(i.invalidations);return t.retainedDataChanged&&r.add("data"),this.tracker.record({kind:"config",keys:e},r)}};import{geoDistance as Vk,geoGraticule as Hk,geoInterpolate as Uk}from"d3-geo";var Kk=class e{constructor(e){this.updateResults=new Gk,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:hh(e.fitPadding)}}(e)}currentTime(){return this.config.clock?.()??os()}getConfiguredWindowSize(){let 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){let t=this.pointBuffer.toArray(),i=this.timestampBuffer?.toArray()??[],r=t.slice(-e),o=i.slice(-r.length),n=this.currentTime();this.pointBuffer=new ox(e),this.timestampBuffer=new ox(e),r.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(o[t]??n)})}this.retainNewestLines(e)}updateConfig(e){let t=function(e){return"fitPadding"in e?{...e,fitPadding:hh(e.fitPadding)}:e}(e),i=this.config,r=this.getConfiguredWindowSize(),o=Object.keys(t).filter(e=>t[e]!==i[e]);this.config={...this.config,...t};let n=this.getConfiguredWindowSize(),a=this.streaming&&n!==r;a&&(this.resizeStreamingWindow(n),this.version++),"customLayout"in t&&!t.customLayout&&(this.lastCustomLayoutFailure=null),this.updateResults.recordConfig(o,{retainedDataChanged:a})}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});let t=this.getConfiguredWindowSize(),i=this.pointBuffer?this.pointBuffer.toArray():this.pointData,r=this.timestampBuffer?.toArray()??[],o=i.slice(-t),n=r.slice(-o.length),a=this.currentTime();this.pointBuffer=new ox(t),this.timestampBuffer=new ox(t),o.forEach((e,t)=>{this.pointBuffer.push(e),this.timestampBuffer.push(n[t]??a)}),this.pointData=[],this.retainNewestLines(t),this.streaming=!0}pushPoint(e){this.pointBuffer||this.initStreaming();let t=this.currentTime();Ts(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();let t=this.currentTime();for(let i of e)Ts(this.pointBuffer,i,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");let t=e.filter(e=>null!=e&&"object"==typeof e);if(0!==t.length){this.streaming||this.initStreaming();for(let e of t)this.lineData.push(e);this.retainNewestLines(),this.version++,this.updateResults.recordData("ingest",t.length)}else this.updateResults.recordNoop("ingest")}removeLine(e){let{lineIdAccessor:t}=this.config;if(!t)throw Error("removeLine() requires lineIdAccessor to be configured");let i="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(i(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){let{pointIdAccessor:t}=this.config;if(!t)throw Error("removePoint() requires pointIdAccessor to be configured");let i="function"==typeof t?t:e=>e[t],r=new Set(Array.isArray(e)?e:[e]);if(this.streaming&&this.pointBuffer){let e=e=>r.has(i(e)+"");Os(this.pointBuffer,this.timestampBuffer,e);let t=this.pointBuffer.remove(e);return t.length>0?(this.version++,this.updateResults.recordData("remove",t.length)):this.updateResults.recordNoop("remove"),t}{let e=[];return this.pointData=this.pointData.filter(t=>!r.has(i(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){let t=this._customRestyle;if(t){for(let i of this.scene){let r=this._baseStyles.get(i)??i.style,o=t(i,e);i.style=o?{...r,...o}:r}this.markStylePaintPending(),this.updateResults.recordRestyle(!0)}else this.updateResults.recordRestyle(!1)}computeScene(e){let{config:t}=this,i=this.projection,r=this.geoPath,o=this.scales,n=this.baseScale,a=[...this.baseTranslate],s=[...this.baseRotation],l=this.scene;this.projection=function(e){if(!e)return Pk();if("string"==typeof e){let t=Tk[e];return t?t():("production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Unknown projection "${e}", falling back to equalEarth`),Pk())}if("object"==typeof e&&"type"in e){let t=Tk[e.type],i=t?t():Pk();return e.rotate&&"rotate"in i&&i.rotate(e.rotate),e.center&&"center"in i&&i.center(e.center),i}return e}(t.projection),this.geoPath=Mk(this.projection),this.fitProjection(e),this.geoPath=Mk(this.projection);let 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;let u=this.buildSceneNodes(e);if(this._customLayoutFailedThisBuild)!0===this.lastCustomLayoutFailure?.preservedLastGoodScene?(this.projection=i,this.geoPath=r,this.scales=o,this.baseScale=n,this.baseTranslate=a,this.baseRotation=s):(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){let t=e.width/2,i=e.height/2,r=this.scene.filter(e=>"point"===e.type).map(e=>({...e,x:t,y:i}));r.length>0&&this.startTransition(r)}this._hasRenderedOnce=!0,t.transition&&l.length>0&&this.startTransition(l),this.version++}}fitProjection(e){let t=this.projection,i=this.config,r=[...this.areas],o=nh(i.xAccessor,"lon"),n=nh(i.yAccessor,"lat"),a=this.getPoints();if(a.length>0){let e=a.map(e=>[o(e),n(e)]);r.push({type:"Feature",properties:{},geometry:{type:"MultiPoint",coordinates:e}})}let s=ah(i.lineDataAccessor);for(let e of this.lineData){let t=s(e);if(t&&t.length>0){let e=t.map(e=>[o(e),n(e)]);r.push({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:e}})}}if(0!==r.length){if(i.projectionExtent){let[[r,o],[n,a]]=i.projectionExtent;t.fitExtent([[0,0],[e.width,e.height]],{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[r,o],[r,a],[n,a],[n,o],[r,o]]]}})}else if(t.clipAngle&&(t.clipAngle()??0)>0){let r=i.fitPadding??0,o=Math.min(e.width,e.height);t.scale(o/2-o*r),t.translate([e.width/2,e.height/2])}else{let o=i.fitPadding??0,n=e.width*o,a=e.height*o;t.fitExtent([[n,a],[e.width-n,e.height-a]],{type:"FeatureCollection",features:r})}this.baseScale=t.scale(),this.baseTranslate=t.translate(),this.baseRotation=t.rotate?.()??[0,0,0]}}applyZoomTransform(e,t){let i=this.projection;if(!i)return;let r=this.geoPath,o=this.scales,n=i.scale(),a=[...i.translate()],s=this.currentZoom;i.scale(this.baseScale*e.k),i.translate([this.baseTranslate[0]*e.k+e.x,this.baseTranslate[1]*e.k+e.y]),this.currentZoom=e.k,this.geoPath=Mk(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let l=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(n),i.translate(a),this.currentZoom=s,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){let i=this.projection;if(!i)return;let r=this.geoPath,o=this.scales,n=i.scale(),a=[...i.translate()],s=this.currentZoom;i.scale(this.baseScale*e),i.translate(this.baseTranslate),this.currentZoom=e,this.geoPath=Mk(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let l=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.scale(n),i.translate(a),this.currentZoom=s,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){let i=this.projection;if(!i||!i.rotate)return;let r=this.geoPath,o=this.scales,n=[...i.rotate()];i.rotate(e),this.geoPath=Mk(i),this.scales={projection:i,geoPath:this.geoPath,projectedPoint:(e,t)=>i([e,t]),invertedPoint:(e,t)=>i.invert?i.invert([e,t]):null},this._customLayoutFailedThisBuild=!1;let a=this.buildSceneNodes(t);this._customLayoutFailedThisBuild?this.lastCustomLayoutFailure?.preservedLastGoodScene?(i.rotate(n),this.geoPath=r,this.scales=o):(this.scene=[],this.rebuildQuadtree()):(this.scene=a,this.rebuildQuadtree(),this.config.projectionTransform&&this.applyCartogramTransform(this.config.projectionTransform,t),this.version++)}setRotation(e){let 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,i=0;for(let e of this.scene)"point"===e.type&&!1!==e.interactive&&(i++,e.r>t&&(t=e.r));if(this._maxPointRadius=t,e.QUADTREE_THRESHOLD>=i)return void(this._quadtree=null);let r=Array(i),o=0;for(let e of this.scene)"point"===e.type&&!1!==e.interactive&&(r[o++]=e);this._quadtree=$k().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;let{config:t}=this,i=this.projection,r=this.geoPath;if(t.customLayout&&this.scales){let i=t.layoutMargin??{top:0,right:0,bottom:0,left:0},r=ui(t.colorScheme,t.themeCategorical,Df),o={areas:this.areas.slice(),points:this.getPoints().slice(),lines:this.lineData.slice(),scales:this.scales,dimensions:{width:e.width,height:e.height,margin:i,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:t.themeSemantic??{},categorical:[...r]},resolveColor:di(r,t.colorScheme),config:t.layoutConfig??{},selection:t.layoutSelection??null},n=gs({family:"geo",logLabel:"geo customLayout",revision:this.version,hasPreviousResult:null!==this.lastCustomLayoutResult,onLayoutError:t.onLayoutError,run:()=>t.customLayout(o)});if("failure"===n.kind)return this.lastCustomLayoutFailure=n.diagnostic,this._customLayoutFailedThisBuild=!0,n.preservedLastGoodScene?this.scene:(this.customLayoutOverlays=null,this.lastCustomLayoutResult=null,this._customRestyle=void 0,this.hasCustomRestyle=!1,this._baseStyles=new WeakMap,[]);let a=n.result,s=a.nodes??[];if(this.customLayoutOverlays=a.overlays??null,this.lastCustomLayoutResult=a,this.lastCustomLayoutFailure=null,this._customRestyle=a.restyle,this.hasCustomRestyle=!!a.restyle,this._baseStyles=new WeakMap,this.hasCustomRestyle)for(let e of s){this._baseStyles.set(e,e.style);let i=a.restyle?.(e,t.layoutSelection??null);i&&(e.style={...e.style,...i})}return ps({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:i,areas:r,points:o,lines:n,layout:a}){let s=nh(e.xAccessor,"lon"),l=nh(e.yAccessor,"lat"),c=[],u=function(e){return{fill:e.themeSemantic?.surface||"#e0e0e0",stroke:e.themeSemantic?.border||"#999",strokeWidth:.5,fillOpacity:1}}(e),d=function(e){return{stroke:e.themeSemantic?.primary||"#4e79a7",strokeWidth:1.5,fill:"none"}}(e),h=function(e){return{fill:e.themeSemantic?.primary||"#4e79a7",r:4,fillOpacity:.8}}(e);if(e.graticule){let t=!0===e.graticule?{}:e.graticule,r=Hk();t.step&&r.step(t.step);let o=i(r())||"";o&&c.push({type:"geoarea",pathData:o,centroid:[a.width/2,a.height/2],bounds:[[0,0],[a.width,a.height]],screenArea:0,style:{fill:"none",stroke:t.stroke||"#e0e0e0",strokeWidth:t.strokeWidth??.5,strokeDasharray:t.strokeDasharray||"2,2"},datum:null,interactive:!1})}for(let t of r){let r=i(t);if(!r)continue;let o=i.centroid(t),n=i.bounds(t),a=i.area(t);c.push({type:"geoarea",pathData:r,centroid:o,bounds:n,screenArea:a,style:sh(e.areaStyle,t,u),datum:t,interactive:!0})}let p=ah(e.lineDataAccessor);for(let i of n){let r=p(i);if(!r||2>r.length)continue;let o=[];if("geo"===e.lineType){let e=Array(r.length);for(let t=0;r.length>t;t++)e[t]=[s(r[t]),l(r[t])];for(let i=0;e.length-1>i;i++){let r=e[i],n=e[i+1],a=Vk(r,n)||0,s=Math.max(2,Math.ceil(a/(Math.PI/180))),l=Uk(r,n);for(let e=0;s>=e;e++){if(i>0&&0===e)continue;let r=t(l(e/s));null!=r&&o.push(r)}}}else for(let e=0;r.length>e;e++){let i=r[e],n=t([s(i),l(i)]);null!=n&&o.push(n)}if(2>o.length)continue;let n=sh(e.lineStyle,i,d),u="number"==typeof n.strokeWidth?n.strokeWidth:1;2!==r.length||2>o.length||"arc"!==e.flowStyle?2===r.length&&o.length>=2&&"offset"===e.flowStyle&&(o="geo"===e.lineType?uh(o,u):dh(o[0],o[o.length-1],0,0,u)):o=ch(o[0],o[o.length-1]);let h=lh(o,a.width);if(h.length>1)for(let e of h)2>e.length||c.push({type:"line",path:e,style:{...n,_edgeFade:!0},datum:i});else c.push({type:"line",path:2>o.length&&h[0]||o,style:n,datum:i})}let f=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(let i of o){let r=s(i),o=l(i);if(null!=g&&Vk([r,o],b)>g)continue;let n=t([r,o]);if(!n)continue;let a=e.pointStyle?e.pointStyle(i):{...h},u={type:"point",x:n[0],y:n[1],r:a.r||4,style:a,datum:i,pointId:f?f(i)+"":void 0};c.push(u)}return c}({config:t,projection:i,path:r,areas:this.areas,points:this.getPoints(),lines:this.lineData,layout:e})}applyCartogramTransform(e,t){let i=function(e,t,i,r){let o=e.filter(e=>"point"===e.type);if(2>o.length)return null;let n=t.strength??1,a=Number.isFinite(n)?Math.max(0,Math.min(1,n)):1,s="strip"===t.layout?"strip":"radial";if("radial"===s&&0===a)return null;let l=t.centerAccessor?"function"==typeof t.centerAccessor?t.centerAccessor:e=>e[t.centerAccessor]:e=>e.id,c="function"==typeof t.costAccessor?t.costAccessor:e=>e[t.costAccessor],u=o.find(e=>e.datum&&l(e.datum)+""==t.center+"");if(!u)return"production"!==process.env.NODE_ENV&&console.warn(`GeoFrame: Distance cartogram center "${t.center}" not found in point data`),null;let d=ao(o.map(e=>e.datum?Number(c(e.datum)):NaN).filter(e=>isFinite(e)&&e>=0),1);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--){let i=e[t];"geoarea"===i.type&&i.interactive&&e.splice(t,1)}let h="strip"===s?function(e,t,i,r,o){let n=Math.max(3,Math.min(8,.35*o.height)),a=Math.max(1,o.width-2*n),s=o.height/2,l=Ok().domain([0,r]).range([0,a]);t.x=n,t.y=s;let c=[];for(let o of e){if(o===t)continue;if(!o.datum){o.x=n,o.y=s;continue}let e=Number(i(o.datum)),a=n+(isFinite(e)&&e>=0&&r>0?l(e):0);o.x=a,o.y=s,c.push({node:o,x:a})}c.sort((e,t)=>e.x-t.x);let u=Math.max(0,Math.min(o.height/2-1,6)),d=0;for(;c.length>d;){let e=d+1;for(;c.length>e&&3>Math.abs(c[e].x-c[d].x);)e++;let t=e-d;if(t>1&&u>0)for(let e=0;t>e;e++)c[d+e].node.y=s+(e-(t-1)/2)*Math.min(2.5,2*u/Math.max(1,t-1));d=e}return{cx:n,cy:s,maxCost:r,availableRadius:a,layout:"strip"}}(o,u,c,d,i):function(e,t,i,r,o,n){let a=t.x,s=t.y,l=n.width/2,c=n.height/2,u=Math.min(n.width,n.height)/2,d=Ok().domain([0,r]).range([0,u]);for(let n of e){if(n===t||!n.datum)continue;let e=n.x,u=n.y,h=Math.atan2(u-s,e-a),p=Math.hypot(e-a,u-s),f=Number(i(n.datum)),y=isFinite(f)&&f>=0?r>0?d(f):0:p,g=l+Math.cos(h)*y,m=c+Math.sin(h)*y;n.x=e+(g-e)*o,n.y=u+(m-u)*o}return t.x=a+(l-a)*o,t.y=s+(c-s)*o,{cx:t.x,cy:t.y,maxCost:r,availableRadius:u,layout:"radial"}}(o,u,c,d,a,i),p=e.filter(e=>"line"===e.type);if(p.length>0){let e=new Map;for(let t of o)null!=t.pointId&&e.set(t.pointId+"",[t.x,t.y]);for(let i of p){let r=i.datum?.source,o=i.datum?.target;if(null!=r&&null!=o){let n=e.get(r+""),a=e.get(o+"");if(n&&a)if("fractional"===t.lineMode&&i.path.length>2){let e=i.path[0],t=i.path[i.path.length-1],r=[n[0]-e[0],n[1]-e[1]],o=[a[0]-t[0],a[1]-t[1]],s=[0];for(let e=1;i.path.length>e;e++)s.push(s[e-1]+Math.hypot(i.path[e][0]-i.path[e-1][0],i.path[e][1]-i.path[e-1][1]));let l=s[s.length-1];i.path=i.path.map((e,t)=>{let n=l>0?s[t]/l:t/(i.path.length-1);return[e[0]+r[0]*(1-n)+o[0]*n,e[1]+r[1]*(1-n)+o[1]*n]})}else i.path=[n,a]}}}return h}(this.scene,e,t,this.areas.length);i&&(this.cartogramLayout=i)}applyDecay(){let e=this.config.decay;if(!e||!this.pointBuffer)return;let t=this.pointBuffer.size;if(0===t)return;let i=this.scene.filter(e=>"point"===e.type);for(let r=0;i.length>r;r++){let o=ns(e,r,t);i[r]._decayOpacity=o,i[r].style={...i[r].style,opacity:o}}}applyPulse(e=this.currentTime()){let t=this.config.pulse;if(!t||!this.timestampBuffer)return!1;let i=this.scene.filter(e=>"point"===e.type),r=this.timestampBuffer.toArray(),o=t.color||"rgba(255,255,255,0.6)",n=t.glowRadius??4,a=!1;for(let s=0;i.length>s&&r.length>s;s++){let l=ss(t,r[s],e);a=ls(i[s],l,o,n)||a}return a}refreshPulse(e){return!0!==this.lastCustomLayoutFailure?.preservedLastGoodScene&&this.applyPulse(e)}hasActivePulsesAt(e){return!!this.config.pulse&&cs(this.config.pulse,this.timestampBuffer,e)}get hasActivePulses(){return this.hasActivePulsesAt(this.currentTime())}startTransition(e){let t=this.config.transition?.duration??300;if(0>=t)return;let i=new Map;for(let t of e)"point"===t.type&&t.pointId&&i.set(t.pointId,[t.x,t.y]);let r=this.scene.filter(e=>"point"===e.type),o=!1;for(let e of r)if(e.pointId){let t=i.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(let e of r)e.pointId&&!i.has(e.pointId)&&(e._targetOpacity=e.style?.opacity??e.style?.fillOpacity??1,e.style={...e.style,opacity:0},o=!0);o&&(this.activeTransition={startTime:this.currentTime(),duration:t})}cancelIntroAnimation(){this.activeTransition=null;for(let e of this.scene)"point"===e.type&&(null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity},e._targetOpacity=void 0),null!=e._targetX&&(e.x=e._targetX,e.y=e._targetY,e._targetX=void 0,e._targetY=void 0))}advanceTransition(e){if(!this.activeTransition)return!1;let t=is(e,this.activeTransition),i=ts(t),r=this.scene.filter(e=>"point"===e.type);for(let e of r){if(null!=e._targetX&&null!=e._targetY){let t=e.y;e.x=rs(e.x,e._targetX,i),e.y=rs(t,e._targetY,i)}null!=e._targetOpacity&&(e.style={...e.style,opacity:e._targetOpacity*i})}if(t>=1){for(let 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}};Kk.QUADTREE_THRESHOLD=500;var Zk=Kk;js(Zk);import*as Qk from"react";import{jsx as Jk,jsxs as eA}from"react/jsx-runtime";import{jsx as tA,jsxs as iA}from"react/jsx-runtime";import{Fragment as rA,jsx as oA,jsxs as nA}from"react/jsx-runtime";import*as aA from"react-dom/server";var sA={fill:"#4e79a7",stroke:"#172033",strokeWidth:1,opacity:.85};import{jsx as lA,jsxs as cA}from"react/jsx-runtime";var uA={top:0,right:0,bottom:0,left:0};import{jsx as dA}from"react/jsx-runtime";import{scaleLinear as hA}from"d3-scale";import{jsx as pA,jsxs as fA}from"react/jsx-runtime";var yA={top:0,right:0,bottom:0,left:0};import*as gA from"react-dom/server";import{jsx as mA,jsxs as xA}from"react/jsx-runtime";var bA={tile:{width:280,height:184,padding:16,labelSize:13,captionSize:11,valueSize:40,detailSize:13,align:"start",border:!0,showHeader:!0,showDetail:!0},presentation:{width:540,height:320,padding:32,labelSize:18,captionSize:14,valueSize:96,detailSize:18,align:"center",border:!0,showHeader:!0,showDetail:!0},inline:{width:240,height:64,padding:8,labelSize:0,captionSize:0,valueSize:28,detailSize:13,align:"start",border:!1,showHeader:!1,showDetail:!0},thumbnail:{width:96,height:56,padding:6,labelSize:0,captionSize:0,valueSize:22,detailSize:0,align:"center",border:!1,showHeader:!1,showDetail:!1}},vA={BigNumber:function(e,t){let i="presentation"===e.mode||"inline"===e.mode||"thumbnail"===e.mode?e.mode:"tile",r=bA[i],o=Rh(e.width,r.width),n=Rh(e.height,r.height),a="number"==typeof e.padding&&Number.isFinite(e.padding)?Math.max(0,e.padding):r.padding,s="center"===e.align||"end"===e.align||"start"===e.align?e.align:r.align,l="center"===s?"middle":"end"===s?"end":"start",c="center"===s?o/2:"end"===s?o-a:a,u=Ir(e.theme),d="number"==typeof e.value&&Number.isFinite(e.value)?e.value:void 0,h=function(e,t={}){if("function"==typeof e)return e;let i=t.locale??"en-US";if("currency"===e){let e=t.precision??2,r=new Intl.NumberFormat(i,{style:"currency",currency:t.currency??"USD",maximumFractionDigits:e,minimumFractionDigits:e});return e=>r.format(e)}if("percent"===e){let e=new Intl.NumberFormat(i,{style:"percent",maximumFractionDigits:t.precision??1,minimumFractionDigits:0});return t=>e.format(t)}if("compact"===e){let e=new Intl.NumberFormat(i,{notation:"compact",maximumFractionDigits:t.precision??1,minimumFractionDigits:0});return t=>e.format(t)}if("duration"===e)return e=>function(e){if(!Number.isFinite(e))return e+"";let t=0>e?"-":"",i=Math.abs(e);if(1e3>i)return`${t}${Math.round(i)}ms`;let r=i/1e3;if(60>r)return`${t}${o=r,Math.round(100*o)/100+""}s`;var o;let n=r/60;if(60>n){let e=Math.floor(n),i=Math.round(r-60*e);return 0===i?`${t}${e}m`:`${t}${e}m ${i}s`}let a=n/60;if(24>a){let e=Math.floor(a),i=Math.round(n-60*e);return 0===i?`${t}${e}h`:`${t}${e}h ${i}m`}let s=Math.floor(a/24),l=Math.round(a-24*s);return 0===l?`${t}${s}d`:`${t}${s}d ${l}h`}(e);let r=new Intl.NumberFormat(i,{notation:t.notation??"standard",maximumFractionDigits:t.precision??0,minimumFractionDigits:0});return e=>r.format(e)}("string"==typeof e.format||"function"==typeof e.format?e.format:"number",{locale:"string"==typeof e.locale?e.locale:void 0,currency:"string"==typeof e.currency?e.currency:void 0,precision:"number"==typeof e.precision?e.precision:void 0}),p=void 0===d?"No value":(R=h(d),`${("string"==typeof e.prefix?e.prefix:void 0)??""}${R}${("string"==typeof e.suffix?e.suffix:void 0)??""}`),f=void 0===d?void 0:function(e,t){if(!t||0===t.length||!Number.isFinite(e))return null;let i=t.filter(e=>Number.isFinite(e.at)||e.at===-1/0).slice().sort((e,t)=>e.at-t.at),r=null;for(let t of i){if(t.at>e)break;r=t}return r}(d,e.thresholds),y="string"==typeof e.color?e.color:function(e,t,i){return t||("success"===e?i.colors.success??"#2ca02c":"warning"===e?i.colors.warning??"#b26a00":"danger"===e?i.colors.danger??"#d62728":"info"===e?i.colors.info??i.colors.primary:i.colors.text)}(f?.level??"neutral",f?.color,u),g="string"==typeof e.label?e.label:void 0,m="string"==typeof e.caption?e.caption:void 0,x="string"==typeof e.unit?e.unit:void 0,b=void 0===d?void 0:function(e,t,i){let r=e.comparison&&"object"==typeof e.comparison?e.comparison:void 0,o=r&&"number"==typeof r.value&&Number.isFinite(r.value)?r.value:void 0,n=("number"==typeof e.delta&&Number.isFinite(e.delta)?e.delta:void 0)??(void 0===o?void 0:t-o);if(void 0===n)return;let a=function(e,t){return Number.isFinite(e)?0===e?t(0):`${e>0?"+":"−"}${t(Math.abs(e))}`:""}(n,i);return`${a}${r&&"string"==typeof r.label?" "+r.label:""}`}(e,d,h),v=void 0===d?void 0:function(e,t,i){let r=e.target&&"object"==typeof e.target?e.target:void 0;if(!r||"number"!=typeof r.value||!Number.isFinite(r.value))return;let o="string"==typeof r.label?" "+r.label:"";return 0===r.value?`target ${i(r.value)}${o}`:`${new Intl.NumberFormat("string"==typeof e.locale?e.locale:"en-US",{style:"percent",maximumFractionDigits:0}).format(t/r.value)} of ${i(r.value)}${o}`}(e,d,h),w=[b,v,f?.label].filter(Boolean).join(" · "),k="string"==typeof e.description&&e.description||[g,p,x,w].filter(Boolean).join(", "),A="string"==typeof e.background?e.background:u.colors.surface??u.colors.background,S="string"==typeof e.borderColor?e.borderColor:u.colors.border,M=a+r.labelSize,$=M+r.captionSize+4,_="presentation"===i?n/2+.32*r.valueSize:"thumbnail"===i?n/2+.34*r.valueSize:Math.min(n-a-(w?26:4),(r.showHeader&&(g||m)?m?$+10:M+14:a)+r.valueSize),P=c+("start"===l?Math.max(r.valueSize,p.length*r.valueSize*.55):0),I=gA.renderToStaticMarkup(xA("svg",{xmlns:"http://www.w3.org/2000/svg",width:o,height:n,viewBox:`0 0 ${o} ${n}`,role:"img","aria-label":k,"data-semiotic-component":"BigNumber",children:[mA("title",{children:g??p}),"string"==typeof e.description&&mA("desc",{children:e.description}),mA("rect",{x:r.border?.5:0,y:r.border?.5:0,width:r.border?o-1:o,height:r.border?n-1:n,rx:r.border?8:0,fill:A,stroke:r.border?S:"none"}),r.showHeader&&g&&mA("text",{x:c,y:M,textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.labelSize,fontWeight:600,fill:u.colors.text,children:g}),r.showHeader&&m&&mA("text",{x:c,y:$,textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.captionSize,fill:u.colors.textSecondary,children:m}),mA("text",{x:c,y:_,textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.valueSize,fontWeight:600,fontVariant:"tabular-nums",fill:void 0===d?u.colors.textSecondary:y,"data-mark-type":"value",children:p}),x&&void 0!==d&&"start"===l&&mA("text",{x:P+6,y:_,textAnchor:"start",fontFamily:u.typography.fontFamily,fontSize:Math.max(11,Math.round(.32*r.valueSize)),fontWeight:500,fill:u.colors.textSecondary,children:x}),r.showDetail&&w&&mA("text",{x:c,y:Math.min(n-a,_+r.detailSize+10),textAnchor:l,fontFamily:u.typography.fontFamily,fontSize:r.detailSize,fill:u.colors.textSecondary,children:w})]}));var R;return t&&(t.evidence=Cl({frameType:"value",width:o,height:n,marks:void 0===d?[]:[{type:"value"}],title:g,description:k})),I}};import*as wA from"react-dom/server";import{jsx as kA,jsxs as AA}from"react/jsx-runtime";import{Fragment as SA,jsx as MA}from"react/jsx-runtime";var $A=new Set(["d","transform","points","viewBox","x","y","x1","x2","y1","y2","cx","cy","r","rx","ry","width","height","dx","dy","offset","startOffset","stroke-width","stroke-opacity","stroke-dasharray","stroke-dashoffset","fill-opacity","opacity","font-size","letter-spacing"]),_A=/-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?/gi,PA=["showAxes","axes","axisExtent","xLabel","yLabel","yLabelRight","categoryLabel","valueLabel","xFormat","yFormat","categoryFormat","valueFormat","tickFormatTime","tickFormatValue","xScaleType","yScaleType","xExtent","yExtent","rExtent","oExtent","extentPadding","hoverRadius","scalePadding","sizeRange","innerRadius","centerContent","curve","gradientFill","lineGradient","lineStyle","pointStyle","areaStyle","barStyle","waterfallStyle","swarmStyle","pieceStyle","summaryStyle","nodeStyle","edgeStyle","connectorStyle","backgroundGraphics","foregroundGraphics","svgPreRenderers","svgAnnotationRules","barColors","legend","legendLayout","autoPlaceAnnotations"],IA=["width","height","showAxes","showGrid","enableHover","showLegend","showLabels","showCategoryTicks","orientation","title","description","summary","accessibleTable","xLabel","yLabel","categoryLabel","valueLabel","linkedHover","mobileInteraction","mobileSemantics","responsiveRules"];import*as RA from"react-dom/server";import{Fragment as LA,jsx as CA,jsxs as TA}from"react/jsx-runtime";Pl();export{qh as generateFrameSVGs,Xh as generateFrameSequence,Uh as generatePhysicsFrameSVGs,Bh as renderChart,jh as renderChartWithEvidence,Yh as renderDashboard,Dh as renderGeoToStaticSVG,Fh as renderNetworkToStaticSVG,Oh as renderOrdinalToStaticSVG,Ch as renderToStaticSVG,Th as renderXYToStaticSVG,Ir as resolveTheme,Nh as serializeSvgPrecision,Rr as themeStyles};
|