semiotic 3.12.0 → 3.12.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 +50 -46
- package/ai/artifact-surface-inventory.json +1 -1
- package/ai/behaviorContracts.cjs +1 -1
- package/ai/dist/diagnose-operation.js +3 -3
- package/ai/dist/mcp-server.js +1 -1
- package/ai/reference.md +15 -3
- package/ai/schema.json +908 -96
- package/ai/surface-manifest.json +1 -1
- package/ai/task-packets/compare-category-totals.json +5 -5
- package/ai/task-packets/compare-category-totals.md +2 -2
- package/ai/task-packets/correct-published-chart.json +5 -5
- package/ai/task-packets/correct-published-chart.md +2 -2
- package/ai/task-packets/index.json +6 -6
- package/ai/task-packets/update-live-chart.json +5 -5
- package/ai/task-packets/update-live-chart.md +2 -2
- package/dist/c-27DCB5T6.min.js +7 -7
- package/dist/c-2CKIGFD2.min.js +1 -1
- package/dist/c-3FATLOH4.min.js +1 -0
- package/dist/{c-STVM6CBI.min.js → c-4SCJKAWZ.min.js} +200 -200
- package/dist/c-5FUOKMH6.min.js +7 -0
- package/dist/c-AAIPWVQ5.min.js +6 -6
- package/dist/{c-2RG4WOVX.min.js → c-ALLF3Y77.min.js} +1 -1
- package/dist/{c-QMKQVCCZ.min.js → c-C5GXUHUO.min.js} +6 -6
- package/dist/c-C67QDKTU.min.js +34 -0
- package/dist/c-F76M77YC.min.js +1 -0
- package/dist/c-FEVXPKQH.min.js +1 -1
- package/dist/c-G42WVQO2.min.js +1 -0
- package/dist/c-G5A3YWTN.min.js +66 -0
- package/dist/c-H4HVKBU3.min.js +1 -0
- package/dist/c-HU3ASFKT.min.js +1 -0
- package/dist/c-I4FYCVJB.min.js +391 -0
- package/dist/{c-5L7JGWQW.min.js → c-IATPZOL7.min.js} +28 -28
- package/dist/c-IE5EBBP6.min.js +110 -0
- package/dist/c-IGONIKZL.min.js +1 -0
- package/dist/c-IKPM53JH.min.js +1 -0
- package/dist/c-IU4QZ7Y5.min.js +1 -1
- package/dist/{c-2ACLVPKF.min.js → c-K5VE57OI.min.js} +1 -1
- package/dist/c-KWJIBJ4R.min.js +1 -0
- package/dist/c-LIMFU6RD.min.js +1 -0
- package/dist/c-M4T43G76.min.js +1 -0
- package/dist/c-M7QUZZCE.min.js +1 -1
- package/dist/c-NVSINXE5.min.js +1 -0
- package/dist/{c-FAF6EV4E.min.js → c-NWRYV6ZF.min.js} +1 -1
- package/dist/c-O5GU2R5W.min.js +1 -0
- package/dist/c-OC7GNXGZ.min.js +1 -0
- package/dist/c-OV5F3DQP.min.js +1 -0
- package/dist/{c-5TAXHW7I.min.js → c-PJ5CAYAW.min.js} +1 -1
- package/dist/c-Q5LZRQGD.min.js +1 -0
- package/dist/c-QP3PXK3N.min.js +1 -0
- package/dist/c-SGZ7ZD2I.min.js +51 -0
- package/dist/c-SSKV5JPW.min.js +1 -1
- package/dist/c-THWTHWXU.min.js +37 -0
- package/dist/c-TRMNDRC4.min.js +41 -0
- package/dist/c-UP656CST.min.js +1 -1
- package/dist/c-USYOK5OX.min.js +1 -0
- package/dist/c-VI753KBO.min.js +1 -0
- package/dist/{c-TT4CTEBR.min.js → c-VLAAAFST.min.js} +1 -1
- package/dist/c-VSOQPII4.min.js +5 -5
- package/dist/c-WGDM4ZRP.min.js +26 -0
- package/dist/c-XCV7VUU3.min.js +87 -0
- package/dist/c-XGDZPYBI.min.js +1 -0
- package/dist/c-XI6CLZII.min.js +1 -0
- package/dist/{c-L4Q2YMXO.min.js → c-XLC7PKM7.min.js} +1 -1
- package/dist/{c-3YAGKCPU.min.js → c-YEB6Z35F.min.js} +1 -1
- package/dist/c-YWZBFG63.min.js +1 -0
- package/dist/c-ZMYO3NZU.min.js +2 -0
- package/dist/c-ZO36H5VH.min.js +48 -0
- package/dist/components/LinkedCharts.d.ts +6 -1
- package/dist/components/Tooltip/Tooltip.d.ts +11 -1
- package/dist/components/Tooltip/tooltipChrome.d.ts +8 -2
- package/dist/components/bundling/semioticVite.d.ts +24 -0
- package/dist/components/charts/physics/cruciblePhysics.d.ts +2 -2
- package/dist/components/charts/physics/gauntletPhysics.d.ts +2 -6
- package/dist/components/charts/physics/physicsHocUtils.d.ts +8 -1
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +2 -0
- package/dist/components/charts/shared/chartSize.d.ts +58 -0
- package/dist/components/charts/shared/chartSizeDefaults.d.ts +189 -0
- package/dist/components/charts/shared/chartSizeDefaultsAtlas.d.ts +9 -0
- package/dist/components/charts/shared/chartSizeDefaultsNetwork.d.ts +29 -0
- package/dist/components/charts/shared/chartSizeDefaultsOrdinal.d.ts +13 -0
- package/dist/components/charts/shared/chartSizeDefaultsPhysics.d.ts +41 -0
- package/dist/components/charts/shared/chartSizeDefaultsValue.d.ts +19 -0
- package/dist/components/charts/shared/chartSizeDefaultsXY.d.ts +10 -0
- package/dist/components/charts/shared/networkPerspectiveWireSchema.d.ts +3 -0
- package/dist/components/charts/shared/useChartSetup.d.ts +3 -0
- package/dist/components/charts/shared/useCustomChartSetup.d.ts +4 -0
- package/dist/components/charts/shared/useNetworkChartSetup.d.ts +2 -0
- package/dist/components/charts/shared/withChartWrapper.d.ts +6 -2
- package/dist/components/charts/value/BigNumber.d.ts +0 -8
- package/dist/components/charts/xy/minimapLayout.d.ts +10 -0
- package/dist/components/realtime/BinAccumulator.d.ts +5 -2
- package/dist/components/recipes/atlas/dependencyForestChartProps.d.ts +4 -4
- package/dist/components/recipes/atlas/flowCircuitChartProps.d.ts +177 -1
- package/dist/components/recipes/atlas/flowCircuitLayout.d.ts +3 -0
- package/dist/components/recipes/atlas/motifBraidChartProps.d.ts +2 -0
- package/dist/components/recipes/atlas/resolution/BoundaryLoomChart.d.ts +3 -0
- package/dist/components/recipes/atlas/resolution/ComponentCutaway.d.ts +16 -0
- package/dist/components/recipes/atlas/resolution/ResolutionAtlasChart.d.ts +3 -0
- package/dist/components/recipes/atlas/resolution/ResolutionGlyphs.d.ts +15 -0
- package/dist/components/recipes/atlas/resolution/ResolutionReader.d.ts +5 -0
- package/dist/components/recipes/atlas/resolution/appearance.d.ts +58 -0
- package/dist/components/recipes/atlas/resolution/boundaryLoomLayout.d.ts +4 -0
- package/dist/components/recipes/atlas/resolution/chartProps.d.ts +75 -0
- package/dist/components/recipes/atlas/resolution/componentCutawayLayout.d.ts +12 -0
- package/dist/components/recipes/atlas/resolution/cutawayContext.d.ts +23 -0
- package/dist/components/recipes/atlas/resolution/cutawayGraph.d.ts +4 -0
- package/dist/components/recipes/atlas/resolution/cycles.d.ts +7 -0
- package/dist/components/recipes/atlas/resolution/evidence.d.ts +43 -0
- package/dist/components/recipes/atlas/resolution/glyphs.d.ts +40 -0
- package/dist/components/recipes/atlas/resolution/identity.d.ts +4 -0
- package/dist/components/recipes/atlas/resolution/indexGraph.d.ts +32 -0
- package/dist/components/recipes/atlas/resolution/ownership.d.ts +25 -0
- package/dist/components/recipes/atlas/resolution/plan.d.ts +12 -0
- package/dist/components/recipes/atlas/resolution/ports.d.ts +44 -0
- package/dist/components/recipes/atlas/resolution/prepare.d.ts +4 -0
- package/dist/components/recipes/atlas/resolution/project.d.ts +70 -0
- package/dist/components/recipes/atlas/resolution/queries.d.ts +23 -0
- package/dist/components/recipes/atlas/resolution/resolutionAtlasLayout.d.ts +9 -0
- package/dist/components/recipes/atlas/resolution/rules.d.ts +14 -0
- package/dist/components/recipes/atlas/resolution/scene.d.ts +52 -0
- package/dist/components/recipes/atlas/resolution/selection.d.ts +3 -0
- package/dist/components/recipes/atlas/resolution/sets.d.ts +10 -0
- package/dist/components/recipes/atlas/resolution/types.d.ts +401 -0
- package/dist/components/recipes/atlas/resolution/validate.d.ts +4 -0
- package/dist/components/recipes/atlas/resolution/witnesses.d.ts +18 -0
- package/dist/components/recipes/atlas/resolution/worker.d.ts +34 -0
- package/dist/components/recipes/lineageDag.d.ts +4 -0
- package/dist/components/recipes/recipeUtils.d.ts +2 -0
- package/dist/components/recipes/transitDiagram.d.ts +2 -61
- package/dist/components/recipes/transitDiagramTypes.d.ts +65 -0
- package/dist/components/semiotic-ai.d.ts +2 -0
- package/dist/components/semiotic-experimental-network-resolution-react.d.ts +12 -0
- package/dist/components/semiotic-experimental-network-resolution.d.ts +13 -0
- package/dist/components/semiotic-geo.d.ts +1 -1
- package/dist/components/semiotic-network-perspective-core.d.ts +6 -0
- package/dist/components/semiotic-network.d.ts +1 -1
- package/dist/components/semiotic-ordinal.d.ts +1 -1
- package/dist/components/semiotic-physics.d.ts +1 -1
- package/dist/components/semiotic-realtime-core.d.ts +1 -1
- package/dist/components/semiotic-realtime-react.d.ts +2 -0
- package/dist/components/semiotic-utils-core.d.ts +3 -1
- package/dist/components/semiotic-vite.d.ts +2 -0
- package/dist/components/semiotic-xy.d.ts +3 -1
- package/dist/components/semiotic.d.ts +3 -1
- package/dist/components/server/renderToStaticSVG.d.ts +2 -1
- package/dist/components/server/serverChartConfigShared.d.ts +2 -0
- package/dist/components/store/LinkedCrosshairStore.d.ts +43 -11
- package/dist/components/store/themeCore.d.ts +2 -0
- package/dist/components/stream/frameKeyboardNavigation.d.ts +3 -1
- package/dist/components/stream/hoverUtils.d.ts +5 -0
- package/dist/components/stream/networkCustomLayout.d.ts +3 -0
- package/dist/components/stream/networkPerspective.d.ts +2 -0
- package/dist/components/stream/networkPerspectiveFit.d.ts +12 -1
- package/dist/components/stream/networkPerspectiveSolid.d.ts +1 -1
- package/dist/components/stream/networkSceneTypes.d.ts +4 -0
- package/dist/components/stream/networkTypes.d.ts +2 -0
- package/dist/components/stream/pipelineConfig.d.ts +2 -0
- package/dist/components/stream/pipelineDomainResolution.d.ts +4 -1
- package/dist/components/stream/types.d.ts +2 -0
- package/dist/components/stream/useFrame.d.ts +2 -0
- package/dist/components/stream/xySceneBuilders/types.d.ts +2 -0
- package/dist/controls.module.min.js +31 -31
- package/dist/geo.min.js +150 -150
- package/dist/geo.module.min.js +31 -31
- 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-ai-core.min.js +1 -1
- package/dist/semiotic-ai-core.module.min.js +1 -1
- package/dist/semiotic-ai.d.ts +2 -0
- package/dist/semiotic-ai.module.min.js +13 -13
- package/dist/semiotic-artifact-react.module.min.js +4 -4
- package/dist/semiotic-artifact.min.js +1 -1
- package/dist/semiotic-artifact.module.min.js +1 -1
- package/dist/semiotic-atlas-selection.module.min.js +1 -1
- package/dist/semiotic-atlas.module.min.js +10 -12
- package/dist/semiotic-client-cjs-shared.min.js +1078 -925
- package/dist/semiotic-client-glyph.module.min.js +2 -2
- package/dist/semiotic-client-shared.module.min.js +1 -1
- package/dist/semiotic-experimental-auxiliary.module.min.js +8 -9
- package/dist/semiotic-experimental-network-resolution-react.d.ts +12 -0
- package/dist/semiotic-experimental-network-resolution-react.min.js +2 -0
- package/dist/semiotic-experimental-network-resolution-react.module.min.js +89 -0
- package/dist/semiotic-experimental-network-resolution.d.ts +13 -0
- package/dist/semiotic-experimental-network-resolution.min.js +2 -0
- package/dist/semiotic-experimental-network-resolution.module.min.js +2 -0
- package/dist/semiotic-experimental-node-auxiliary.module.min.js +9 -10
- package/dist/semiotic-geo.d.ts +1 -1
- package/dist/semiotic-line.module.min.js +1 -1
- package/dist/semiotic-network-perspective-core.d.ts +6 -0
- package/dist/semiotic-network-perspective-core.min.js +1 -0
- package/dist/semiotic-network-perspective-core.module.min.js +1 -0
- package/dist/semiotic-network-perspective.module.min.js +1 -1
- package/dist/semiotic-network-placement.min.js +4 -0
- package/dist/semiotic-network-placement.module.min.js +4 -0
- package/dist/semiotic-network-zoom.module.min.js +1 -1
- package/dist/semiotic-network.d.ts +1 -1
- package/dist/semiotic-ordinal.d.ts +1 -1
- package/dist/semiotic-physics.d.ts +1 -1
- package/dist/semiotic-realtime-core.d.ts +1 -1
- package/dist/semiotic-realtime-core.module.min.js +1 -1
- package/dist/semiotic-realtime-react.d.ts +2 -0
- package/dist/semiotic-realtime-react.module.min.js +1 -1
- package/dist/semiotic-recipes-core-cjs-base.min.js +101 -106
- package/dist/semiotic-recipes-core.module.min.js +75 -76
- package/dist/semiotic-server-edge-node.module.min.js +391 -392
- package/dist/semiotic-server-edge.min.js +387 -388
- package/dist/semiotic-server-edge.module.min.js +371 -371
- package/dist/semiotic-server-node.min.js +387 -388
- package/dist/semiotic-server-node.module.min.js +1 -1
- package/dist/semiotic-utils-core.d.ts +3 -1
- package/dist/semiotic-utils-core.min.js +12 -11
- package/dist/semiotic-utils-core.module.min.js +12 -11
- package/dist/semiotic-value.module.min.js +4 -4
- package/dist/semiotic-vite.d.ts +2 -0
- package/dist/semiotic-vite.min.js +1 -0
- package/dist/semiotic-vite.module.min.js +1 -0
- package/dist/semiotic-xy.d.ts +3 -1
- package/dist/semiotic.d.ts +3 -1
- package/dist/semiotic.module.min.js +12 -12
- package/dist/server.min.js +387 -388
- package/dist/server.module.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +42 -13
- package/dist/c-2AB65V3L.min.js +0 -1
- package/dist/c-2U5JMOPN.min.js +0 -88
- package/dist/c-3DCTIRW4.min.js +0 -1
- package/dist/c-3OKFRTYM.min.js +0 -1
- package/dist/c-3VZHOPFW.min.js +0 -1
- package/dist/c-4ZSQIBC7.min.js +0 -1
- package/dist/c-5M4RUS7V.min.js +0 -34
- package/dist/c-6O5WWP7F.min.js +0 -1
- package/dist/c-73TOIYIW.min.js +0 -48
- package/dist/c-AE4M7BWH.min.js +0 -1
- package/dist/c-AEIK2NFW.min.js +0 -30
- package/dist/c-AFQSEIZ4.min.js +0 -4
- package/dist/c-BBX7DVVB.min.js +0 -51
- package/dist/c-CNYFCSG4.min.js +0 -5
- package/dist/c-E6QH2WYE.min.js +0 -1
- package/dist/c-GOMQWQJR.min.js +0 -1
- package/dist/c-GTYG4PDT.min.js +0 -1
- package/dist/c-H23GIKTK.min.js +0 -1
- package/dist/c-HQLUUSRJ.min.js +0 -1
- package/dist/c-HXUOFDSD.min.js +0 -64
- package/dist/c-L3LKYOLK.min.js +0 -1
- package/dist/c-MIKDFGKH.min.js +0 -1
- package/dist/c-OYSPTIAG.min.js +0 -1
- package/dist/c-PWPJNYQP.min.js +0 -1
- package/dist/c-QZ5SWKHC.min.js +0 -392
- package/dist/c-RXJH4IRX.min.js +0 -41
- package/dist/c-SN2D6QMH.min.js +0 -1
- package/dist/c-U5YGK6HL.min.js +0 -1
- package/dist/c-VIN5ASK2.min.js +0 -37
- package/dist/c-XZ3GASUJ.min.js +0 -1
- package/dist/c-ZLZZTH4I.min.js +0 -118
|
@@ -1,172 +1,167 @@
|
|
|
1
1
|
"use strict";function e(e,t=[],n){const o=void 0===n?void 0:new Set("string"==typeof n?[n]:n),r=t.filter(e=>!e.missingPrehistory&&void 0!==e.partition&&o?.has(e.partition)),i=new Set(r.map(e=>e.id)),s=new Set(r.map(e=>e.entityId)),a=/* @__PURE__ */new Map;let c=0;for(const t of e){if(void 0!==n&&"string"==typeof t.roles.occurrence&&!i.has(t.roles.occurrence))continue;const e=Object.entries(t.entityWeights);0===e.length&&void 0===n&&(c+=t.entityCount);for(const[t,o]of e)(void 0===n||s.has(t))&&a.set(t,o)}return[...a.values()].reduce((e,t)=>e+t,c)}function t(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function n(e,n){return t(e,n)?e[n]:void 0}function o(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function r(){/* @__PURE__ */
|
|
2
|
-
return Object.create(null)}function i(e,t){return e.slice(0,t+1).map(e=>e.replaceAll("%","%25").replaceAll(">","%3E")).join(">")}function s(e,t,o){return t.has(e)?"node":n(o.nodeIdsBySection,e)?"section":"global"}function a(e,t,n){const i=[],a=new Set(t.nodes.map(e=>e.id)),c=/* @__PURE__ */new Set;for(const o of t.measureValues){const t=e.measures[o.measureId];if(!t)continue;const r=s(o.subjectId,a,n);i.push({measureId:o.measureId,subjectId:o.subjectId,subjectKind:r,value:o.value,status:o.status,unitKind:t.unitKind,countUnit:t.countUnit,timeDenominator:t.timeDenominator}),"section"===r&&c.add(`${o.measureId}\0${o.subjectId}`)}const l=r();for(const e of t.nodes)o(l,e.id,e);const u=r(),d=r();for(const e of i){if("node"!==e.subjectKind)continue;const t=l[e.subjectId];if(!t?.sectionId)continue;const n=`${e.measureId}\0${t.sectionId}`;c.has(n)||(u[n]=(u[n]??0)+e.value,"exact"!==e.status?d[n]=e.status:d[n]||(d[n]="exact"))}for(const[t,n]of Object.entries(u)){const o=t.split("\0"),r=o[0],s=o[1],a=e.measures[r];a&&i.push({measureId:r,subjectId:s,subjectKind:"section",value:n,status:d[t]??"exact",unitKind:a.unitKind,countUnit:a.countUnit,timeDenominator:a.timeDenominator})}return{entries:i}}function c(e,t,n){return e.entries.find(e=>e.measureId===t&&e.subjectId===n)}function l(t){const n=t.spec.comparison;if(!n)return;const o=n.partitions.map(o=>{const r=c(t.ledger,n.denominatorMeasureId,o)?.value??0,i={};return i["repeated-state-episode"]=e(t.motifs.matches.filter(e=>"repeated-state-episode"===e.template),t.source.occurrences,o),{partition:o,assigned:r,motifUsers:i,outcomes:{purchases:c(t.ledger,"purchases",o)?.value??0}}});return{partitions:[...n.partitions],denominatorMeasureId:n.denominatorMeasureId,referencePartition:n.referencePartition,rows:o}}function u(e,t){const n=e.spec.comparison?.denominatorMeasureId??e.spec.motifs.denominatorRef??"assigned";return c(e.ledger,n,t)?.value}function d(e,t,n){return 0===n||1e4*e%n!=0?Math.round((t-e)/Math.max(n,1)*1e4):1e4*(t-e)/n}function h(e,t){const n=r();for(const t of e.nodes)o(n,t.id,t.completeness??"known");const i=r();for(const e of t.unsupportedTemplates)o(i,e,"unsupported-template");if(t.incompleteCandidates.length>0){const e=new Set(t.incompleteCandidates.map(e=>e.template));for(const t of e)o(i,t,"incomplete")}const s=t.matches.find(e=>e.truncation),a={nodes:n,motifs:i,traces:e.occurrences?.some(e=>e.missingPrehistory||!1===e.complete)?"incomplete":e.nodes.some(e=>"unknown"===e.completeness)?"unknown":"known"};return s?.truncation&&(a.truncation={disclosed:!0,template:s.template,omitted:s.truncation.omitted}),a}function f(e){const t=new Map(e.nodes.map(e=>[e.id,[]])),n=new Map(e.nodes.map(e=>[e.id,[]]));for(const o of e.edges)t.get(o.source).push(o),n.get(o.target).push(o);return{outgoing:t,incoming:n}}function m(e,t){const n=/* @__PURE__ */new Set,o=[];for(const r of t){if(n.has(r))continue;n.add(r);const t=[{node:r,next:0}];for(;t.length;){const r=t[t.length-1],i=e[r.node][r.next++];void 0===i?(o.push(r.node),t.pop()):n.has(i)||(n.add(i),t.push({node:i,next:0}))}}return o}function p(e){const t=e.nodes.map(e=>e.id).sort(),n=new Map(t.map((e,t)=>[e,t])),o=t.map(()=>[]),r=t.map(()=>[]);for(const t of e.edges){const e=n.get(t.source),i=n.get(t.target);o[e].push(i),r[i].push(e)}const i=/* @__PURE__ */new Set,s=[];for(const e of m(o,t.map((e,t)=>t)).reverse()){if(i.has(e))continue;const n=[],o=[e];for(i.add(e);o.length;){const e=o.pop();n.push(t[e]);for(const t of r[e])i.has(t)||(i.add(t),o.push(t))}s.push(n.sort())}return s.sort((e,t)=>e[0].localeCompare(t[0]))}function g(e,t,n="rooted-traversal:id-asc"){const{outgoing:o}=f(e),r=n.endsWith("id-desc")?-1:1;for(const e of o.values())e.sort((e,t)=>r*e.id.localeCompare(t.id));const i=new Set(t),s=[],a=[...new Set(t)],c=e=>{const t=[{node:e,next:0}];for(;t.length;){const e=t[t.length-1],n=o.get(e.node)?.[e.next++];n?i.has(n.target)||(i.add(n.target),s.push([n.target,n.id]),t.push({node:n.target,next:0})):t.pop()}};for(const e of a)c(e);for(const t of e.nodes.map(e=>e.id).sort())i.has(t)||(a.push(t),i.add(t),c(t));const l=s.map(([,e])=>e),u=new Set(l);return{forest:{kind:"rooted-backbone",roots:a,rankingPolicyId:n,backboneEdgeIds:l,primaryParentEdgeIdByNode:Object.fromEntries(s)},residual:{originalEdgeIds:e.edges.map(e=>e.id),residualEdgeIds:e.edges.filter(e=>!u.has(e.id)).map(e=>e.id)}}}function y(e){const[t,n]=e.split(":");return{mode:"tree-only"===t?"tree-only":"main-transport",order:"id-desc"===n?"id-desc":"id-asc"}}function x(e,t,n){if("ordinal"!==t.coordinate.kind)return!0;const o=e.nodes.find(e=>e.id===n);return Boolean(o?.sectionId&&t.coordinate.sectionIds.includes(o.sectionId))}function b(e,t){return[...e].sort((e,n)=>"id-asc"===t?e.id.localeCompare(n.id):n.id.localeCompare(e.id))}function w(e,t){if(e.forest.display.rankingPolicyId?.startsWith("rooted-traversal"))return g(t,e.forest.display.roots??[],e.forest.display.rankingPolicyId);const n=t.edges.map(e=>e.id),i=e.forest.display.rankingPolicyId??"main-transport",{mode:s,order:a}=y(i),c=n=>x(t,e,n.source)&&x(t,e,n.target),l=/* @__PURE__ */new Map;for(const e of t.nodes)l.set(e.id,[]);for(const e of t.edges)l.has(e.target)||l.set(e.target,[]),l.get(e.target).push(e);const u=r(),d=e.forest.display.roots&&e.forest.display.roots.length>0?e.forest.display.roots:t.nodes[0]?[t.nodes[0].id]:[],h=new Set(d);for(const e of t.nodes){if(h.has(e.id))continue;const t=b(l.get(e.id)??[],a),n=t.find(e=>c(e))??t[0];n&&o(u,e.id,n.id)}let f;f="tree-only"===s?Object.values(u):t.edges.filter(e=>c(e)).map(e=>e.id);const m=new Set(f),p=n.filter(e=>!m.has(e));return{forest:{kind:"rooted-backbone",roots:[...d],rankingPolicyId:i,backboneEdgeIds:f,primaryParentEdgeIdByNode:u},residual:{residualEdgeIds:p,originalEdgeIds:n}}}function M(e,t){const n=new Set(e.originalEdgeIds),o=new Set(t.backboneEdgeIds),r=new Set(e.residualEdgeIds);if(o.size!==t.backboneEdgeIds.length)throw new Error("duplicate backbone edge id");if(r.size!==e.residualEdgeIds.length)throw new Error("duplicate residual edge id");for(const e of o){if(r.has(e))throw new Error(`edge ${e} is both backbone and residual`);if(!n.has(e))throw new Error(`backbone edge ${e} is not original`)}for(const e of r)if(!n.has(e))throw new Error(`residual edge ${e} is not original`);if(o.size+r.size!==n.size)throw new Error("original edge IDs != backbone ⊎ residual")}function v(e){const t=new Map(e.nodes.map(e=>[e.id,/* @__PURE__ */new Set])),n=new Map(e.nodes.map(e=>[e.id,/* @__PURE__ */new Set])),o=/* @__PURE__ */new Map;for(const r of e.edges){t.get(r.target)?.add(r.source),n.get(r.source)?.add(r.target);let e=o.get(r.source);e||o.set(r.source,e=/* @__PURE__ */new Map);const i=e.get(r.target);i?i.push(r.id):e.set(r.target,[r.id])}return{incoming:new Map([...t].map(([e,t])=>[e,[...t]])),outgoing:new Map([...n].map(([e,t])=>[e,[...t]])),sectionByNode:new Map(e.nodes.map(e=>[e.id,e.sectionId])),pairs:o}}function k(e,t){return e.sectionByNode.get(t)}function $(e,t){const n=/* @__PURE__ */new Set,o=[];for(const r of t){const t=k(e,r);t&&!n.has(t)&&(n.add(t),o.push(t))}return o}function S(e,t,n){return e.pairs.get(t)?.get(n)??[]}function I(e){return e.entityCount??1}function A(e,t){const n=[];let o=0;for(const r of e)r.nodePath.includes(t)&&!r.missingPrehistory&&(n.push(r.entityId),o+=I(r));return{entityIds:n,entityCount:o}}function C(e,t){return null==t||e.length<=t?{kept:e}:{kept:e.slice(0,t),truncation:{disclosed:!0,omitted:e.length-t,fullCount:e.length}}}function N(e,t,n,o,i,s){if(n.length<2)return;const{kept:a,truncation:c}=C(n,s),l=[t,...a],u=[];for(const n of a){const o="fan-out"===e?S(i,t,n):S(i,n,t);u.push(...o)}const d=$(i,[t,...n]),h=A(o.occurrences??[],t);return{id:`${e}:${t}`,template:e,roles:"fan-out"===e?{source:t,destinations:a}:{destination:t,sources:a},nodePath:l,edgeIds:u,startSectionId:d[0],completionSectionId:d[d.length-1],intersectSectionIds:d,entityIds:h.entityIds,entityWeights:r(),entityCount:h.entityCount,flags:{occurrence:h.entityIds.length>0,temporal:!1,trajectorySupported:h.entityIds.length>0,enriched:!1},truncation:c}}function j(e,t,n){return 1===t.length&&1===n.length}function F(e,t){const n=t.incoming,o=t.outgoing,i=[];for(const s of e.nodes){const a=n.get(s.id)??[],c=o.get(s.id)??[];if(1!==c.length)continue;const l=1===a.length&&j(a[0],n.get(a[0])??[],o.get(a[0])??[]);if(j(s.id,a,c)&&l)continue;const u=[s.id];let d=s.id;const h=/* @__PURE__ */new Set([d]);for(;;){const e=(o.get(d)??[])[0];if(!e||h.has(e))break;if(u.push(e),h.add(e),!j(0,n.get(e)??[],o.get(e)??[]))break;d=e}if(u.length<2)continue;const f=[];for(let e=0;e<u.length-1;e++)f.push(...S(t,u[e],u[e+1]));const m=$(t,u),p=A(e.occurrences??[],u[0]);i.push({id:`serial-chain:${u.join(">")}`,template:"serial-chain",roles:{nodes:u,start:u[0],end:u[u.length-1]},nodePath:u,edgeIds:f,startSectionId:m[0],completionSectionId:m[m.length-1],intersectSectionIds:m,entityIds:p.entityIds,entityWeights:r(),entityCount:p.entityCount,flags:{occurrence:p.entityIds.length>0,temporal:!1,trajectorySupported:p.entityIds.length>0,enriched:!1}})}return i}function E(e,t){const n=t.occurrences??[];if(0!==n.length)for(const t of e){if("repeated-state-episode"===t.template)continue;const e=t.nodePath,i=r();for(const t of n)t.missingPrehistory||e.some(e=>t.nodePath.includes(e))&&o(i,t.entityId,I(t));const s=Object.keys(i);t.entityIds=s,t.entityWeights=i,t.entityCount=s.reduce((e,t)=>e+(i[t]??0),0),t.flags={...t.flags,occurrence:s.length>0,trajectorySupported:s.length>0}}}function P(e,t){const n=[];for(const i of e.occurrences??[]){if(i.missingPrehistory)continue;const e=/* @__PURE__ */new Map,s=/* @__PURE__ */new Set;for(const[a,c]of i.nodePath.entries()){const l=e.get(c);if(null==l){e.set(c,a);continue}if(s.has(c))continue;s.add(c);const u=i.nodePath.slice(l,a+1),d=$(t,u),h=r();o(h,i.entityId,I(i)),n.push({id:`repeated-state-episode:${i.id}:${c}`,template:"repeated-state-episode",roles:{state:c,occurrence:i.id},nodePath:u,edgeIds:[],startSectionId:k(t,u[0]),completionSectionId:k(t,u[u.length-1]),intersectSectionIds:d,entityIds:[i.entityId],entityWeights:h,entityCount:I(i),flags:{occurrence:!0,temporal:!1,trajectorySupported:!0,enriched:!1}})}}return n}function z(e,t){const n=e.motifs.matchBudget,o=v(t),r=[];for(const e of t.nodes){const i=N("fan-out",e.id,o.outgoing.get(e.id)??[],t,o,n);i&&r.push(i);const s=N("fan-in",e.id,o.incoming.get(e.id)??[],t,o,n);s&&r.push(s)}r.push(...F(t,o)),r.push(...P(t,o)),E(r,t);const i=[];for(const e of t.occurrences??[])e.missingPrehistory&&(i.push({template:"serial-chain",occurrenceId:e.id,reason:"missing-prehistory"}),i.push({template:"repeated-state-episode",occurrenceId:e.id,reason:"missing-prehistory"}));const s=kl.filter(e=>!Sl.includes(e));return{catalogId:e.motifs.catalogId,catalogVersion:e.motifs.catalogVersion,matches:r,incompleteCandidates:i,unsupportedTemplates:s}}function L(e){return e.entityCount??1}function O(e,t,n){const o=t??"";e.partitionCounts.set(o,(e.partitionCounts.get(o)??0)+n)}function T(e,t={}){function n(e){const t=[...e.children.keys()];return t.sort((t,n)=>{const o=e.children.get(t),r=e.children.get(n),i=l?o.partitionCounts.get(l)??0:1;return i>0!=(l?r.partitionCounts.get(l)??0:1)>0?i>0?-1:1:t.localeCompare(n)}),t}const s={id:"",stateId:"",prefix:[],children:/* @__PURE__ */new Map,occurrenceIds:[],entityCount:0,partitionCounts:/* @__PURE__ */new Map};for(const t of e){if(t.missingPrehistory)continue;const e=L(t);let n=s;n.occurrenceIds.push(t.id),n.entityCount+=e,O(n,t.partition,e);for(const o of t.nodePath){const r=[...n.prefix,o],s=i(r,r.length-1);let a=n.children.get(o);a||(a={id:s,stateId:o,prefix:r,children:/* @__PURE__ */new Map,occurrenceIds:[],entityCount:0,partitionCounts:/* @__PURE__ */new Map},n.children.set(o,a)),a.occurrenceIds.push(t.id),a.entityCount+=e,O(a,t.partition,e),n=a}}const a=[],c=[],l=t.referencePartition;return function e(t,i){if(t.id){const e=r();for(const[n,r]of t.partitionCounts)o(e,n,r);a.push({id:t.id,stateId:t.stateId,prefix:t.prefix,parentId:i,childIds:n(t).map(e=>t.children.get(e).id),entityCount:t.entityCount,occurrenceIds:[...t.occurrenceIds],partitionCounts:e}),c.push(t.id)}for(const o of n(t))e(t.children.get(o),t.id||null)}(s,null),{kind:"observed-prefix",rootIds:n(s).map(e=>s.children.get(e).id),nodes:a,order:c,referencePartition:l}}function R(e,t){if("ordinal"!==e.coordinate.kind)return{kind:"ordinal",sectionIds:[],nodeIdsBySection:r()};const n=r();for(const t of e.coordinate.sectionIds)o(n,t,[]);for(const e of t.nodes){if(!e.sectionId)continue;const t=n[e.sectionId];t&&t.push(e.id)}return{kind:"ordinal",sectionIds:[...e.coordinate.sectionIds],nodeIdsBySection:n}}function W(e,t){return t.length>0&&e.some((n,o)=>t.every((t,n)=>e[o+n]===t))}function q(e){const t=[];for(const n of e.occurrences??[]){if(n.missingPrehistory)continue;const e=n.nodePath;for(let o=0;o<e.length-1;o++)t.push({from:e[o],to:e[o+1],via:o>0?e[o-1]:void 0,occurrenceIds:[n.id]})}return{hops:t,graphAdjacency:e.edges.map(e=>({source:e.source,target:e.target,edgeId:e.id}))}}function D(e,t){const n=e.nodes.map(e=>e.id).sort(),o=new Map(n.map((e,t)=>[e,t])),r=n.length,i=Array.from({length:n.length+1},()=>[]),s=i.map(()=>[]),a=(e,t)=>{i[e].push(t),s[t].push(e)};for(const t of e.edges)a(o.get(t.source),o.get(t.target));for(const e of t.roots)a(r,o.get(e));const c=m(i,[r]).reverse(),l=new Map(c.map((e,t)=>[e,t])),u=/* @__PURE__ */new Map([[r,r]]),d=(e,t)=>{for(;e!==t;)l.get(e)>l.get(t)?e=u.get(e):t=u.get(t);return e};let h=!0;for(;h;){h=!1;for(const e of c.slice(1)){const t=s[e].filter(e=>u.has(e)).reduce(d);u.get(e)!==t&&(u.set(e,t),h=!0)}}return{...t,roots:[...new Set(t.roots)].sort(),status:e.nodes.some(e=>e.completeness&&"known"!==e.completeness)?"incomplete":"exact",immediateDominatorByNode:Object.fromEntries(n.flatMap((e,t)=>u.has(t)?[[e,u.get(t)===r?null:n[u.get(t)]]]:[])),reachableNodeIds:n.filter((e,t)=>u.has(t)),unreachableNodeIds:n.filter((e,t)=>!u.has(t))}}function B(e,t,n,o){e.push({kind:t,severity:"fatal",message:n,id:o})}function Y(e,t){const n=[];e.schemaVersion!==vl&&B(n,"schema-version",`expected schemaVersion ${vl}`),e.relations.directed&&!0===e.relations.edgeIdRequired||B(n,"relations","Phase 1 requires directed edges with ids"),"rooted-backbone"!==e.forest.display.kind&&"observed-prefix"!==e.forest.display.kind&&B(n,"forest","supported display kinds: rooted-backbone, observed-prefix"),"ordinal"!==e.coordinate.kind&&B(n,"coordinate","Phase 1 kernel uses ordinal sections");const i=r();for(const r of t.nodes)r.id?(i[r.id]&&B(n,"duplicate-node","duplicate node id",r.id),o(i,r.id,!0),"ordinal"===e.coordinate.kind&&r.sectionId&&!e.coordinate.sectionIds.includes(r.sectionId)&&B(n,"section-membership",`node section ${r.sectionId} is not in the coordinate`,r.id)):B(n,"node-id","node is missing id");const s=r();for(const e of t.edges)e.id?(s[e.id]&&B(n,"duplicate-edge","duplicate edge id",e.id),o(s,e.id,!0),i[e.source]||B(n,"dangling-source","edge source is not a node",e.id),i[e.target]||B(n,"dangling-target","edge target is not a node",e.id)):B(n,"edge-id","edge is missing id");for(const t of e.forest.display.roots??[])i[t]||B(n,"missing-root","display root is not a node",t);const a=e.forest.requiredPaths;if(a)if("directed-admitted"!==a.relationScopeId&&B(n,"required-path-scope","required paths use the full directed-admitted relation scope"),Array.isArray(a.roots)&&0!==a.roots.length)for(const e of a.roots)i[e]||B(n,"required-path-roots","required-path root is not a node",e);else B(n,"required-path-roots","required paths need declared roots");if("rooted-backbone"===e.forest.display.kind&&0===e.forest.display.roots.length&&B(n,"missing-root","rooted-backbone requires at least one root"),e.comparison&&(e.comparison.partitions.length<2&&B(n,"comparison","comparison requires at least two partitions"),e.measures[e.comparison.denominatorMeasureId]||B(n,"comparison-denominator","comparison denominatorMeasureId is not a declared measure")),null===(c=e.measures)||"object"!=typeof c||Array.isArray(c))B(n,"measures","measures must be an object");else for(const[t,o]of Object.entries(e.measures))"rate"!==o.unitKind||o.timeDenominator||B(n,"rate-denominator","rate measures require a timeDenominator",t);var c;for(const o of t.measureValues)e.measures[o.measureId]?Number.isFinite(o.value)||B(n,"non-finite-measure","measure value is not finite",o.measureId):B(n,"unknown-measure","measureValue refers to an undeclared measure",o.measureId);for(const e of t.occurrences??[])if(e.id&&e.entityId){void 0===e.stepEntityCounts||Array.isArray(e.stepEntityCounts)&&e.stepEntityCounts.length===e.nodePath.length&&!Array.from(e.stepEntityCounts).some(e=>!Number.isFinite(e)||e<0)||B(n,"occurrence-step-counts","stepEntityCounts must contain one finite, nonnegative count per nodePath step",e.id);for(const t of e.nodePath)i[t]||B(n,"occurrence-node","occurrence path references a missing node",e.id)}else B(n,"occurrence","occurrence needs id and entityId");return{ok:n.every(e=>"fatal"!==e.severity),issues:n}}function V(e,t,n){return JSON.stringify([n,t.graphRef,t.revision,e],(e,t)=>t&&"object"==typeof t&&!Array.isArray(t)?Object.fromEntries(Object.keys(t).sort().map(e=>[e,t[e]])):t)}function G(e,t,n={}){const o=Y(e,t);if(!o.ok)return{ok:!1,issues:o.issues};const r=n.generation??1,i=R(e,t),s=z(e,t),c=w(e,t);M(c.residual,c.forest);const u=a(e,t,i),d=h(t,s),f=q(t),m=V(e,t,r),p="observed-prefix"===e.forest.display.kind||(t.occurrences?.length??0)>0?T(t.occurrences??[],{referencePartition:"observed-prefix"===e.forest.display.kind?e.forest.display.referencePartition??e.comparison?.referencePartition:e.comparison?.referencePartition}):void 0,g={sourceGraphRef:t.graphRef,analysisRevision:m,spec:e,source:t,sections:i,motifs:s,forest:c.forest,residualEdges:c.residual,ports:f,ledger:u,completeness:d,provenance:{sourceRevision:t.revision,analysisRevision:m,generation:r,relationScope:"directed-admitted",motifCatalogVersion:e.motifs.catalogVersion,coordinatePolicy:"ordinal"===e.coordinate.kind?`ordinal:${e.coordinate.sectionIds.join(",")}`:`numeric:${e.coordinate.field}`,forestRoots:[...e.forest.display.roots??c.forest.roots],rankingPolicyId:c.forest.rankingPolicyId,population:e.motifs.countUnit,temporalHorizon:e.temporal.kind,evidencePolicyId:e.evidencePolicyId},prefixForest:p,...e.forest.requiredPaths&&{requiredPaths:D(t,e.forest.requiredPaths)}};return g.comparison=l(g),{ok:!0,atlas:g,issues:o.issues}}function _(e){const t=e.roles.occurrence;return"string"==typeof t?[t]:e.entityIds}function H(e,t={}){const n=new Set(t.templates??["repeated-state-episode"]),o=e.filter(e=>n.has(e.template)).map(e=>{const t="string"==typeof e.roles.state?e.roles.state:e.nodePath[0],n=e.nodePath[e.nodePath.length-1];return{id:`capsule:${e.id}`,matchId:e.id,template:e.template,entryState:t,exitState:n,entityCount:e.entityCount,occurrenceIds:_(e),selected:!1}}).sort((e,t)=>t.entityCount!==e.entityCount?t.entityCount-e.entityCount:e.id.localeCompare(t.id)),r=/* @__PURE__ */new Set;for(const e of o)if(!e.occurrenceIds.some(e=>r.has(e))){e.selected=!0;for(const t of e.occurrenceIds)r.add(t)}return o}function X(t,n={}){const o=n.templates??["repeated-state-episode"],r="ordinal"===t.spec.coordinate.kind?t.spec.coordinate.sectionIds:[],i=void 0!==n.partition?u(t,n.partition)??0:t.spec.comparison?t.comparison?.rows.reduce((e,t)=>e+t.assigned,0)??0:t.ledger.entries.find(e=>"global"===e.subjectKind&&e.measureId===t.spec.motifs.denominatorRef)?.value??0,s=o=>e(o,t.source.occurrences,n.partition??t.spec.comparison?.partitions),a=[],c=t.motifs.incompleteCandidates.length>0;for(const e of o)for(const o of r){const r=t.motifs.matches.filter(t=>t.template===e),l=s(r.filter(e=>e.completionSectionId===o)),u=s(r.filter(e=>e.intersectSectionIds.includes(o)));a.push({template:e,sectionId:o,partition:n.partition,completionCount:l,intersectionCount:u,denominator:i,status:c?"incomplete":"exact"})}return{templates:o,sections:r,cells:a}}function U(e){return e.entityCount??1}function K(e){if(!e.missingPrehistory)return{id:`group:${e.id}`,occurrenceId:e.id,partition:e.partition,nodePath:e.nodePath,entityCount:U(e),...e.stepEntityCounts&&{stepEntityCounts:[...e.stepEntityCounts]},signature:i(e.nodePath,e.nodePath.length-1)}}function Z(e){const t=e.prefixForest;if(!t)return{atlas:e,groups:[],signatureOrder:[],ribbons:[],capsules:[],profile:X(e),differences:[],prefixForest:{kind:"observed-prefix",rootIds:[],nodes:[],order:[]},sceneSeeds:{nodes:[],edges:[]}};const n=(e.source.occurrences??[]).map(K).filter(e=>Boolean(e)),o=/* @__PURE__ */new Map;for(const e of n){const n=t.order.indexOf(e.signature),r=o.get(e.signature),i=-1===n?t.order.length:n;(null==r||i<r)&&o.set(e.signature,i)}const r=[...new Set(n.map(e=>e.signature))].sort((e,t)=>{const n=(o.get(e)??0)-(o.get(t)??0);return 0!==n?n:e.localeCompare(t)}),s=[];for(const e of n)for(let t=0;t<e.nodePath.length-1;t++){const n=i(e.nodePath,t),o=i(e.nodePath,t+1);s.push({id:`ribbon:${e.id}:${t}`,groupId:e.id,partition:e.partition,fromPrefixId:n,toPrefixId:o,fromState:e.nodePath[t],toState:e.nodePath[t+1],entityCount:e.stepEntityCounts?.[t]??e.entityCount,...e.stepEntityCounts&&{toEntityCount:e.stepEntityCounts[t+1]}})}const a=H(e.motifs.matches),c=e.comparison??l(e),u=[];if(c&&c.partitions.length>=2){const e=c.rows[0],t=c.rows[1],n=Math.min(e.assigned,t.assigned)||e.assigned,o=e.motifUsers["repeated-state-episode"]??0,r=t.motifUsers["repeated-state-episode"]??0;u.push({motif:"repeated-state-episode",leftPartition:e.partition,rightPartition:t.partition,leftCount:o,rightCount:r,deltaCount:r-o,deltaBps:d(o,r,n),denominator:n}),u.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:d(e.outcomes.purchases??0,t.outcomes.purchases??0,n),denominator:n})}const h={nodes:n.map(e=>({id:e.id,partition:e.partition,signature:e.signature})),edges:s.map(e=>({id:e.id,source:e.fromPrefixId,target:e.toPrefixId}))};return{atlas:e,groups:n,signatureOrder:r,ribbons:s,capsules:a,profile:X(e),differences:u,prefixForest:t,sceneSeeds:h}}function Q(e,t){return e.groups.some(e=>W(e.nodePath,t))}function J(e){let t=1/0,n=-1/0;for(const o of e)o<t&&(t=o),o>n&&(n=o);return[t,n]}function ee(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}function te(e,t,n){if(n.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const o=t||[5,20],r=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&r.push(n)}if(0===r.length)return()=>o[0];const[i,s]=J(r);if(i===s)return()=>(o[0]+o[1])/2;const a=(0,nu.scaleLinear)().domain([i,s]).range(o).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?o[0]:a(n)}}function ne(e){const t=e.data?.weight??e.weight;return"number"==typeof t&&Number.isFinite(t)?t:Number.isFinite(e.value)?e.value:1}function oe(e,t,n,o,r=ou){return"sync"!==e&&("worker"===e||o*(t+n)>=r)}function re(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function ie(e,t,n,o,r){const i=te(n.nodeSize,n.nodeSizeRange,e);return{kind:"frame",nodes:e.map(e=>{const t=e,n=r?.get(e.id),o=0!==e.x||0!==e.y?e.x:n?.x??0,s=0!==e.x||0!==e.y?e.y:n?.y??0;return{id:e.id,x:o,y:s,vx:t.vx,vy:t.vy,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:e.value,__forceRadius:i(e)}}),edges:t.map(e=>({source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:e.value,y0:0,y1:0,sankeyWidth:0,data:{weight:ne(e)}})),config:{chartType:"force",iterations:n.iterations,forceStrength:n.forceStrength,seed:n.seed,__previousPositions:r??n.__previousPositions},size:o}}function se(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:`/${t}`;return new URL(`./${e}`,`file:${n}`)}throw new Error(`Cannot resolve module worker asset: ${e}`)}function ae(e){if("undefined"!=typeof DOMException)return new DOMException(`${e} aborted`,"AbortError");const t=new Error(`${e} aborted`);return t.name="AbortError",t}function ce(e){const t=new Error(e.message);return t.name=e.name??"Error",e.stack&&(t.stack=e.stack),t}function le(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Malformed worker response");const t=e;if(void 0!==t.requestId&&(!Number.isInteger(t.requestId)||t.requestId<1)||void 0!==t.error&&(!t.error||"string"!=typeof t.error.message||[t.error.name,t.error.stack].some(e=>void 0!==e&&"string"!=typeof e)))throw new Error("Malformed worker response");return{requestId:t.requestId,error:t.error}}function ue(e){let t=null,n=null;return{get available(){return!n&&!t?.failure},get:()=>{if(n||t?.failure)throw n||t?.failure;if(!t||t.isDead)try{t=e()}catch(e){throw n=e instanceof Error?e:new Error(String(e)),n}return t},resetForTest:()=>{if(n=null,t){try{t.terminate()}catch{}t=null}}}}function de(){return"string"==typeof iu.url&&iu.url?new Worker(new URL("./forceLayoutWorker.js",iu.url),{type:"module",name:"semiotic-force-layout"}):new Worker(se("forceLayoutWorker.js"),{type:"module",name:"semiotic-force-layout"})}function he(){au.resetForTest()}async function fe(e,t){return re()?au.get().request(e,t):Promise.reject(new Error("Web Workers are unavailable"))}function me(e,t,n){return Math.max(t,Math.min(n,e))}function pe(e){return"function"==typeof e?e:t=>t[e]}function ge(e,t,n){const o=e?.data,r=o?o[t]:void 0;if(null!=r)return r;const i=e?.[t];return null==i?n:i}function ye(e){if(null==e)return null;const t=e;return t.data??t.datum??e}function xe(e,t){const n=/* @__PURE__ */new Map;for(const o of e){const e=t(o),r=n.get(e);r?r.push(o):n.set(e,[o])}return n}function be(e){const t=/* @__PURE__ */Object.create(null);return e((e,n)=>{t[e]=n}),t}function we(e,t){if(!t)return!0;const n=Array.isArray(t)?t:[t],o=e;for(const e of n)if(null!=e.value&&String(o[e.field])!==String(e.value))return!1;return!0}function Me(e,t={}){const n=t.baseOpacity??1;return t.highlight||t.predicate?!we(e,t.highlight)||t.predicate&&!t.predicate(e)?t.dimOpacity??.16:Math.min(1,n+(t.brighten??0)):n}function ve(e){return e.join("|")}function ke(e,t=.72){const n=(0,wu.interpolateLab)(e,"#ffffff"),o=(0,wu.interpolateLab)(e,"#000000"),r=(0,wu.interpolateLab)(e,e)(0);return e=>{const i=e<0?0:e>1?1:e;return.5===i?r:i<.5?n(2*(.5-i)*t):o(2*(i-.5)*t)}}function $e(e,t,n=.72){return ke(e,n)(t)}function Se(e){return be(t=>{for(const[n,o]of Object.entries(e))t(n,o)})}function Ie(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"item"}function Ae(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}function Ce(e){if(0===e.length)return 0;let t=0;for(const n of e)t+=n;return t/e.length}function Ne(e,t){const n=me(t,0,1),o=e.trim().replace(/^#/,""),r=3===o.length?o.split("").map(e=>e+e).join(""):o;return/^[0-9a-fA-F]{6}$/.test(r)?`rgba(${parseInt(r.slice(0,2),16)}, ${parseInt(r.slice(2,4),16)}, ${parseInt(r.slice(4,6),16)}, ${n})`:e}function je(e,t,n,o,r,{force:i=!1}={}){if(t===n&&!i)return null;const s=`${t} of ${n} ${o} shown`;return(0,vu.createElement)("text",{key:"recipe-notice",x:e.x,y:e.y+e.height-4,fontSize:11,fill:"var(--semiotic-text, currentColor)",pointerEvents:"none",role:"img","aria-label":`${s}. ${r}`},(0,vu.createElement)("title",null,r),s)}function Fe(e,t,n){return Ee(e,t,n)}function Ee(e,t,n,o=!1){const r=Number.isFinite(t)?Math.max(0,Math.floor(t)):0,i=e=>Number.isFinite(e)?Math.max(0,e):0,s=e.reduce((e,t)=>e+(i(t.weight)>0?1:0),0),a=Math.max(0,Math.floor(n?.minPerCategory??0)),c=s>0?Math.min(a,Math.floor(r/s)):0,l=e.reduce((e,t)=>e+i(t.weight),0);if(r<=0||l<=0)return e.map(e=>({...e,exact:0,cells:0,remainder:0}));const u=e.map(e=>{const t=i(e.weight),n=t/l*r;return{...e,exact:n,cells:t>0?Math.max(c,Math.floor(n)):0,remainder:n-Math.floor(n)}});let d=u.reduce((e,t)=>e+t.cells,0);for(;d>r;){const e=u.filter(e=>e.cells>c).sort((e,t)=>t.cells-e.cells||e.remainder-t.remainder||e.key.localeCompare(t.key))[0];if(!e)break;e.cells--,d--}const h=u.filter(e=>i(e.weight)>0).sort((e,t)=>t.remainder-e.remainder||(o?0:i(t.weight)-i(e.weight)||e.key.localeCompare(t.key)));for(let e=0;d<r;e++)h[e%h.length].cells++,d++;return u}function Pe(e,t,n,o){const r=/* @__PURE__ */new Set;return e.map((e,i)=>{const s=String(t(e,i)),a=Number(n(e,i));if(!s)throw new Error(`${o} snapshot contains an empty id at index ${i}.`);if(r.has(s))throw new Error(`${o} snapshot contains duplicate id "${s}".`);if(!Number.isFinite(a)||a<0)throw new Error(`${o} snapshot value for "${s}" must be a finite non-negative number.`);return r.add(s),{id:s,value:a}})}function ze(e,t,n){const o=n.afterId??n.beforeId,r=n.afterValue??n.beforeValue,i=null!=n.epsilon&&n.epsilon>=0?n.epsilon:1e-9,s=Pe(e,n.beforeId,n.beforeValue,"Before"),a=Pe(t,o,r,"After"),c=new Map(s.map(e=>[e.id,e.value])),l=new Map(a.map(e=>[e.id,e.value])),u=s.reduce((e,t)=>e+t.value,0),d=a.reduce((e,t)=>e+t.value,0),h=Math.abs(u-d)<=i;if(!h&&!n.allowImbalance)throw new Error(`Snapshot totals must match (before ${u}, after ${d}). Pass allowImbalance to inspect residuals.`);const f=[],m=[...s.map(e=>e.id),...a.map(e=>e.id).filter(e=>!c.has(e))];for(const e of m){const t=Math.min(c.get(e)??0,l.get(e)??0);t>i&&f.push({sourceId:e,targetId:e,value:t,kind:"stay"})}const p=s.map(e=>({id:e.id,value:e.value-(l.get(e.id)??0)})).filter(e=>e.value>i),g=a.map(e=>({id:e.id,value:e.value-(c.get(e.id)??0)})).filter(e=>e.value>i);let y=0,x=0;for(;y<p.length&&x<g.length;){const e=p[y],t=g[x],n=Math.min(e.value,t.value);n>i&&f.push({sourceId:e.id,targetId:t.id,value:n,kind:"move"}),e.value-=n,t.value-=n,e.value<=i&&(y+=1),t.value<=i&&(x+=1)}return{flows:f,beforeTotal:u,afterTotal:d,balanced:h,unmatchedBefore:p.slice(y).filter(e=>e.value>i).map(({id:e,value:t})=>({id:e,value:t})),unmatchedAfter:g.slice(x).filter(e=>e.value>i).map(({id:e,value:t})=>({id:e,value:t}))}}function Le(e){return Number.isFinite(e)?Math.max(0,e):0}function Oe(e,t){const n=Number(t.unit),o=Le(e),r=t.maxUnits??1/0,i=t.minFraction??0;if(!(n>0)||!(r>0)||o<=0)return{units:[],unit:n>0?n:0,total:o,shown:0,overflow:o>0&&!(r>0)};const s=o/n,a=Math.ceil(s-$u),c=Math.min(r,a),l=a>r,u=[];for(let e=0;e<c;e+=1){const t=e*n,r=Math.min(o,t+n);let i=Math.min(1,Math.max(0,(r-t)/n));1-i<$u&&(i=1),u.push({index:e,fraction:i,start:t,end:t+i*n,value:i*n})}const d=u[u.length-1];d&&d.fraction<i&&d.fraction<1&&u.pop();const h=u.reduce((e,t)=>e+t.value,0);return{units:u,unit:n,total:o,shown:h,overflow:l}}function Te(e,t,n){const o=Oe(e,n),r=Math.max(Le(t),o.total);if(r<=o.total)return{...o,rangeUnits:[],rangeTotal:o.total};const i=Oe(r,{unit:n.unit,maxUnits:n.maxUnits}),s=i.unit>0?o.total/i.unit:0,a=Math.floor(s+$u);let c=Math.min(1,Math.max(0,s-a));c<$u&&(c=0);const l=[];for(const e of i.units)e.index<a||(e.index===a&&c>0?e.fraction-c>$u&&l.push({...e,startFraction:c,start:e.index*i.unit+c*i.unit,value:(e.fraction-c)*i.unit}):l.push({...e,startFraction:0}));return{...o,overflow:o.overflow||i.overflow,rangeUnits:l,rangeTotal:r}}function Re(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,t,n={}){const o=n.seed??1,r=n.iterations??260,i=n.repulsion??5200,s=n.linkDistance??165,a=n.linkStrength??.045,c=n.centerStrength??.018,l=n.damping??.84,u=n.nodeRadius??12,d=n.nodePadding??3,h=n.inset??.06,f=Re(o),m=/* @__PURE__ */new Map;for(const t of e)m.set(t.id,0);for(const e of t)m.set(e.source,(m.get(e.source)??0)+1),m.set(e.target,(m.get(e.target)??0)+1);const p=Iu/2,g=e.map(e=>({id:e.id,data:e,x:200+600*f(),y:200+600*f()})),y=e=>"function"==typeof u?u(e.data):u,x=new Set(e.map(e=>e.id)),b=t.filter(e=>x.has(e.source)&&x.has(e.target)).map(e=>({source:e.source,target:e.target}));if(r>0){const e=(0,Su.forceSimulation)(g).randomSource(f).alphaDecay(1-Math.pow(.001,1/r)).velocityDecay(Math.max(0,Math.min(1,1-l))).force("charge",(0,Su.forceManyBody)().strength(e=>{const t=m.get(e.id)??0;return 2.5*-Math.sqrt(i)*Math.sqrt(t+1)})).force("collide",(0,Su.forceCollide)(e=>y(e)+d).strength(.9).iterations(2)).force("center",(0,Su.forceCenter)(p,p).strength(.8)).force("x",(0,Su.forceX)(p).strength(c)).force("y",(0,Su.forceY)(p).strength(c));b.length>0&&e.force("link",(0,Su.forceLink)(b).id(e=>e.id).distance(s).strength(e=>{const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id,o=Math.max(1,Math.min(m.get(t)??1,m.get(n)??1));return a/.045/o})),e.stop();for(let t=0;t<r;t+=1)e.tick()}let w=1/0,M=1/0,v=-1/0,k=-1/0;for(const e of g){const t=e.x??p,n=e.y??p;t<w&&(w=t),n<M&&(M=n),t>v&&(v=t),n>k&&(k=n)}const $=v-w,S=k-M,I={};for(const e of g){const t={x:0===$?.5:h+((e.x??p)-w)/$*(1-2*h),y:0===S?.5:h+((e.y??p)-M)/S*(1-2*h)};Object.defineProperty(I,e.id,{value:t,enumerable:!0,configurable:!0,writable:!0})}return I}function qe(e){return e?e.map(Number).filter(Number.isFinite):[]}function De(e){if("fixed-denominator"===e.countStrategy)return 1/0;const t=e.maxTokens??1/0;return t>0?Math.floor(t):0}function Be(e,t){const n=De(t);return e.length<=n?{tokens:e,overflow:!1}:{tokens:e.slice(0,n),overflow:!0}}function Ye(e){return"number"==typeof e?{value:e}:Array.isArray(e)?{samples:qe(e),data:e}:e}function Ve(e){const t=e.unitValue??e.unit,n=e.icon??e.token;return{...e,...null!=t&&{unitValue:t},...null!=n&&{icon:n}}}function Ge(e){if(e.samples)return qe(e.samples);if(!e.data||!e.valueAccessor)return[];const t=e.valueAccessor;return e.data.map(e=>"function"==typeof t?t(e):Number(e[t])).filter(Number.isFinite)}function _e(e,t){const n=e.length;if(0===n)return 0;if(1===n)return e[0];const o=(n-1)*Math.min(1,Math.max(0,t)),r=Math.floor(o),i=Math.ceil(o),s=o-r;return e[r]*(1-s)+e[i]*s}function He(e,t=1){const n=Array.from({length:e},(e,t)=>t),o=Re(Math.floor(t)||1);for(let e=n.length-1;e>0;e-=1){const t=Math.floor(o()*(e+1)),r=n[e];n[e]=n[t],n[t]=r}return n}function Xe(e,t,n,o={}){return{index:t,tokenType:e.tokenType,tokenSemantics:e.tokenSemantics,countStrategy:e.countStrategy,fraction:1,startFraction:0,value:n,start:t,end:t+n,unitValue:e.unitValue,unitMeaning:e.unitMeaning,...o}}function Ue(e,t){const n=Ve(t),o=Ye(e);let r,i,s,a,c,l,u,d=0,h=!1;if("unitized"===n.countStrategy){c=n.unitValue??1;const e={unit:c,maxUnits:n.maxTokens,minFraction:n.minFraction},t=null==o.rangeValue?Oe(Ae(o.value),e):Te(Ae(o.value),Ae(o.rangeValue),e);if(r=t.units.map(e=>Xe(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:t.unit})),i=t.total,d=t.shown,h=t.overflow,null!=o.rangeValue){const e=t;l=e.rangeTotal,u=e.rangeUnits.map(e=>Xe(n,e.index,e.value,{fraction:e.fraction,startFraction:e.startFraction,start:e.start,end:e.end,unitValue:t.unit,range:"scenario"}))}}else if("fixed-denominator"===n.countStrategy){a=Math.floor(Ae(o.denominator??n.denominator)),s=Ae(o.numerator??n.numerator??o.value);const e=Math.min(a,Math.max(0,Math.round(s)));r=Array.from({length:a},(t,o)=>Xe(n,o,1,{highlighted:o<e,start:o,end:o+1})),i=a,d=r.length,h=!1}else if("quantile"===n.countStrategy){const e=Ge(o).sort((e,t)=>e-t),t=Math.max(0,Math.floor(n.tokenCount??50)),s=e.length>0?Math.min(t,De(n)):0;r=Array.from({length:s},(t,o)=>{const r=(o+.5)/s,i=_e(e,r);return Xe(n,o,i,{sample:i,quantile:r,start:i,end:i})}),i=e.length,d=r.length,h=e.length>0&&t>r.length}else if("sample"===n.countStrategy||"posterior-sample"===n.countStrategy||"random-sample"===n.countStrategy){const e=Ge(o),t=Math.min(e.length,Math.max(0,Math.floor(n.tokenCount??e.length))),s=Math.min(t,De(n));r=("random-sample"===n.countStrategy?He(e.length,n.seed).slice(0,s):Array.from({length:s},(t,n)=>Math.floor(n/Math.max(1,s-1)*(e.length-1)))).map((t,o)=>{const r=e[t];return Xe(n,o,r,{sample:r,start:r,end:r})}),i=e.length,d=r.length,h=t>r.length}else{const e=o.data;if(e&&null==o.value)r=e.map((e,t)=>Xe(n,t,1,{datum:e})),i=e.length;else{const e=Oe(Ae(o.value),{unit:1,maxUnits:n.maxTokens,minFraction:n.minFraction});r=e.units.map(e=>Xe(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:1})),i=e.total,d=e.shown,h=e.overflow}if(e&&null==o.value){const e=Be(r,n);r=e.tokens,d=r.length,h=e.overflow}}return{tokens:r,encoding:n,total:i,shown:d,overflow:h,numerator:s,denominator:a,unitValue:c,rangeTotal:l,rangeTokens:u,diagnostics:Ze(n,{visibleTokens:r.length+(u?.length??0)})}}function Ke(e,t={}){const n=(o=e,Array.isArray(o)?e:e.tokens);var o;const r=n.length;if(0===r)return[];const i=t.flow??"row",s=t.cellWidth??16,a=t.cellHeight??s,c=t.gutter??2,l=t.anchor??[.5,.5],u=Math.max(1,Math.floor(t.columns??(t.rows?Math.ceil(r/t.rows):Math.ceil(Math.sqrt(r))))),d=Math.max(1,Math.floor(t.rows??Math.ceil(r/u))),h="row"===i?Math.max(d,Math.ceil(r/u)):d,f="column"===i?Math.max(u,Math.ceil(r/d)):u,m=t.x??0,p=t.y??0;return n.map((e,n)=>{let o,r;return"column"===i?(r=Math.floor(n/d),o=n%d):(o=Math.floor(n/u),r=n%u),"left"===t.columnDirection&&(r=f-1-r),"up"===t.rowDirection&&(o=h-1-o),{...e,row:o,column:r,x:m+r*(s+c)+l[0]*s,y:p+o*(a+c)+l[1]*a}})}function Ze(e,t={}){const n=[],o=e.tokenSemantics,r=e.countStrategy,i=t.maxRecommendedTokens??("fixed-denominator"===r&&Ae(e.denominator)<=Cu?Cu:Au);return o||n.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),r||n.push({code:"MISSING_COUNT_STRATEGY",severity:"warning",message:"Every tokenized encoding should state how token counts are produced."}),"icon"!==e.tokenType&&"glyph"!==e.tokenType||"icon-only"!==e.labelPolicy&&"token-only"!==e.labelPolicy||n.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=t.visibleTokens&&t.visibleTokens>i&&n.push({code:"TOO_MANY_VISIBLE_TOKENS",severity:"warning",message:`This encoding renders ${t.visibleTokens} visible tokens. Consider unitizing, sampling, or a hybrid bar/token view.`}),"decorative"!==o||"icon"!==e.tokenType&&"glyph"!==e.tokenType||n.push({code:"DECORATIVE_PICTOGRAPHS",severity:"warning",message:"Decorative pictographs can harm recall and speed when they do not clarify the data."}),"unitized-measure"===o&&r&&"unitized"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Unitized measures should use the unitized count strategy so each token has a stable value."}),"risk-case"===o&&r&&"fixed-denominator"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),"possible-outcome"!==o&&"posterior-sample"!==o&&"hypothetical-case"!==o||!r||"quantile"===r||"sample"===r||"posterior-sample"===r||"random-sample"===r||n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===o&&"unitized"===r&&null==e.unitValue&&null==e.unit&&n.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"!==o||"unitized"!==r||e.unitMeaning||n.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),n}function Qe(e){return"measure"===e?"precise-comparison":"estimate probability"===e?"probability-estimation":"understand risk"===e?"risk-communication":"remember"===e?"memory":"decide"===e?"support-decision":e}function Je(e){const t=Qe(e);return"precise-comparison"===t?["compare-categories","rank"]:"probability-estimation"===t?["distribution"]:"risk-communication"===t?["part-to-whole","distribution"]:"frequency-reasoning"===t?["distribution","compare-categories"]:"memory"===t||"editorial-engagement"===t?["compare-categories"]:"public-explanation"===t||"support-decision"===t?["distribution","compare-categories"]:["compare-categories"]}function et(e){const t=Qe(e.taskIntent),n="small"===(o=e.availableSpace)?25:"large"===o?100:50;var o;if("precise-comparison"===t)return{recommendedEncoding:"bar-or-line",rationale:"Use continuous position/length encodings when precise magnitude comparison is the primary task.",warnings:[],alternatives:["hybrid-bar-token","unitized-measure"]};if("probability-estimation"===t){const e={tokenType:"dot",tokenSemantics:"possible-outcome",countStrategy:"quantile",tokenCount:n,layout:"dotplot",labelPolicy:"text-plus-token"};return{recommendedEncoding:"quantile-dotplot",tokenEncoding:e,rationale:"This task asks readers to estimate probability from a distribution. Quantile tokens turn probability mass into countable possible outcomes.",warnings:Ze(e),alternatives:["cdf-with-threshold","density-with-threshold"]}}if("risk-communication"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"risk-case",countStrategy:"fixed-denominator",denominator:100,layout:"waffle",labelPolicy:"text-plus-token"};return{recommendedEncoding:"fixed-denominator-icon-array",tokenEncoding:t,rationale:"Risk is often clearer as natural frequency: highlighted cases out of a fixed denominator.",warnings:Ze(t,{visibleTokens:100,maxRecommendedTokens:100}),alternatives:["labeled-percent","bar-with-risk-threshold"]}}if("memory"===t||"editorial-engagement"===t){const t={tokenType:e.concreteEntity?"glyph":"icon",icon:e.concreteEntity,tokenSemantics:"unitized-measure",countStrategy:"unitized",unitValue:1,layout:"grid",labelPolicy:"text-plus-token",unitMeaning:e.concreteEntity?`one token represents a unit of ${e.concreteEntity}`:"one token represents one unit"};return{recommendedEncoding:"semantic-isotype",tokenEncoding:t,rationale:"Semantic tokens are useful when the chart needs to make a topic concrete and memorable.",warnings:Ze(t),alternatives:["labeled-bar","hybrid-bar-token"]}}if("frequency-reasoning"===t||"public-explanation"===t||"support-decision"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"distribution"===e.dataType?"possible-outcome":"unitized-measure",countStrategy:"distribution"===e.dataType?"quantile":"unitized",unitValue:"distribution"===e.dataType?void 0:1,tokenCount:n,layout:"distribution"===e.dataType?"dotplot":"bar-segment",labelPolicy:"text-plus-token",unitMeaning:"distribution"===e.dataType?void 0:"one token represents one unit interval"};return{recommendedEncoding:"hybrid-continuous-token",tokenEncoding:t,rationale:"A hybrid view preserves measurement while adding countable tokens for explanation and decisions.",warnings:Ze(t),alternatives:["bar-or-line","quantile-dotplot","fixed-denominator-icon-array"]}}return{recommendedEncoding:"bar-or-line",rationale:"Use continuous encodings unless the task needs frequency, risk, memory, or outcome reasoning.",warnings:[],alternatives:["unitized-measure","quantile-dotplot","fixed-denominator-icon-array"]}}function tt(e,t,n){if(n)return n;const o=e??"circle";if("chevron"===o)return rt(t);const r=Object.prototype.hasOwnProperty.call(ju,o)?ju[o]:Nu.symbolCircle;return(0,Nu.symbol)(r,Math.max(1,t))()??""}function nt(e){return Math.sqrt(Math.max(1,e)/Math.PI)}function ot(e,t,n){if(!n&&"circle"===(e??"circle"))return nt(t);const o=n?`p:${n}`:`s:${e??"circle"}:${t}`,r=Eu.get(o);if(null!=r)return r;const i=tt(e,t,n).match(/-?\d*\.?\d+(?:e-?\d+)?/gi);let s=0;if(i)for(let e=0;e+1<i.length;e+=2){const t=+i[e],n=+i[e+1],o=Math.sqrt(t*t+n*n);o>s&&(s=o)}return s>0?(Eu.size>512&&Eu.clear(),Eu.set(o,s),s):nt(t)}function rt(e){const t=1.5*nt(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}function it(e){return"object"==typeof e&&null!==e&&"tokens"in e&&"encoding"in e}function st(e,t,n){return"function"==typeof e?e(t)??n:e??n}function at(e,t){return"function"==typeof e?e(t):e}function ct(e){return e.sample??e.value??e.index}function lt(e,t,n){if(t.columns)return t.columns;if(t.width&&n>0){const e=t.gutter??2;return Math.max(1,Math.floor((t.width+e)/(n+e)))}return e.length>0?Math.ceil(Math.sqrt(e.length)):1}function ut(e,t){const n=t.positionToken;return n?e.map((t,o)=>{const r=n(t,o,e);return{...t,x:r.x,y:r.y,row:r.row??o,column:r.column??0}}):[]}function dt(e,t){if(0===e.length)return[];const n=t.x??0,o=t.y??0,r=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),i=t.gutter??2,s=Math.max(1,Math.floor(t.rows??1)),a=e.map(ct),c=Math.min(...a),l=Math.max(...a)-c||1;return e.map((a,u)=>{const d=ct(a),h=u%s,f=t.valueToX?t.valueToX(d,a):n+(d-c)/l*(t.width??12*Math.max(1,e.length-1)),m=t.valueToY?t.valueToY(d,a):o+h*(r+i);return{...a,x:f,y:m,row:h,column:u}})}function ht(e,t){if(0===e.length)return[];const n=t.x??0,o=t.y??0,r="number"==typeof t.tokenSize?t.tokenSize:12,i=t.gutter??2,s=t.cellWidth??r+i,a=t.cellHeight??r+i,c=e.map(ct),l=Math.min(...c),u=Math.max(...c)-l||1,d=/* @__PURE__ */new Map;return e.map(r=>{const i=ct(r),c=t.valueToX?t.valueToX(i,r):n+(i-l)/u*(t.width??Math.max(1,e.length-1)*s),h=Math.round((c-n)/Math.max(1,s)),f=d.get(h)??0;d.set(h,f+1);const m=t.valueToY?t.valueToY(i,r):o+f*a;return{...r,x:n+h*s,y:m,row:f,column:h}})}function ft(e,t){if(!t.valueToX)return[];const n=t.y??0,o=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),r=t.anchor??[.5,.5];return e.map((e,i)=>{const s=Number.isFinite(e.start)?e.start:ct(e),a=(s+(Number.isFinite(e.end)?e.end:s+e.value))/2,c=t.valueToY?t.valueToY(a,e):n+r[1]*o;return{...e,x:t.valueToX(a,e),y:c,row:0,column:i}})}function mt(e,t){const n=t.includeRange&&e.rangeTokens?[...e.tokens,...e.rangeTokens]:e.tokens;if(t.positionToken)return ut(n,t);const o=t.layout??e.encoding.layout??"grid";if("quantile-strip"===o)return dt(n,t);if("dotplot"===o)return ht(n,t);if("bar-segment"===o){if(!t.valueToX)throw new Error('tokenLayer layout "bar-segment" requires valueToX and optionally valueToY.');return ft(n,t)}if("beeswarm"===o||"small-multiple"===o)throw new Error(`tokenLayer layout "${o}" is not implemented yet; use row, column, stack, grid, waffle, dotplot, quantile-strip, bar-segment with valueToX, or positionToken.`);const r="number"==typeof t.tokenSize?t.tokenSize:void 0,i=t.cellWidth??r??12,s=t.cellHeight??r??i,a="row"===o?Math.max(1,n.length):"column"===o||"stack"===o?1:"waffle"===o&&"fixed-denominator"===e.encoding.countStrategy&&100===e.denominator?10:lt(n,t,i);return Ke(n,{...t,columns:a,cellWidth:i,cellHeight:s})}function pt(e){if(e)return Bu[e]}function gt(e,t){return void 0!==t.datum?st(t.datum,e,null):e.datum??null}function yt(e,t){return{fill:!1!==e.highlighted?"scenario"===e.range?st(t.rangeColor,e,Gu):st(t.color,e,Yu):st(t.inactiveColor,e,Vu),stroke:"none",...at(t.style,e)??{}}}function xt(e,t){const n=at(t.pointId,e)??(t.idPrefix?`${t.idPrefix}-${"scenario"===e.range?"range-":""}${e.index}`:void 0);return{datum:gt(e,t),accessibleDatum:at(t.accessibleDatum,e),accessibility:at(t.accessibility,e),pointId:n,_transitionKey:n}}function bt(e,t){const n=st(t.tokenSize,e,12);return{type:"point",x:e.x,y:e.y,r:st(t.radius,e,n/2),style:yt(e,t),...xt(e,t)}}function wt(e,t){const n=st(t.tokenSize,e,12);return{type:"symbol",x:e.x,y:e.y,size:Math.PI*Math.max(1,n/2)**2,symbolType:st(t.symbolType,e,"circle"),path:at(t.symbolPath,e),rotation:at(t.rotation,e),style:yt(e,t),...xt(e,t)}}function Mt(e,t,n){const o=yt(e,n),r=st(n.tokenSize,e,12);return{type:"glyph",x:e.x,y:e.y,size:r,glyph:t,color:String(o.fill??Yu),accent:st(n.accent,e,_u),fraction:e.fraction<1?e.fraction:void 0,fractionStart:e.startFraction>0?e.startFraction:void 0,fractionDirection:st(n.fractionDirection,e,"horizontal"),ghostColor:e.fraction<1?at(n.ghostColor,e)??Vu:void 0,rotation:at(n.rotation,e),style:o,...xt(e,n)}}function vt(e,t,n){if("dot"===n.tokenType)return bt(e,t);const o=at(t.glyph,e)??pt(n.icon);if(o)return Mt(e,o,t);const r=(i=n.icon)&&Hu.has(i)?i:void 0;var i;return wt(e,r&&null==t.symbolType?{...t,symbolType:r}:t)}function kt({input:e,encoding:t,options:n={}}){if(!it(e)&&!t)throw new Error("tokenLayer requires an encoding when input is not a TokenSet.");const o=it(e)?{...e,encoding:Ve(e.encoding)}:Ue(e,t),r=mt(o,n).filter(e=>!n.include||n.include(e));return{tokenSet:o,positionedTokens:r,nodes:r.map(e=>vt(e,n,o.encoding))}}function $t(e){return`${e.getUTCFullYear()}-${St(e.getUTCMonth()+1)}-${St(e.getUTCDate())}`}function St(e){return e<10?`0${e}`:String(e)}function It(e,t){return e<t?-1:e>t?1:0}function At(e,t){if("function"==typeof e)return e;const n=e??t;return e=>e[n]}function Ct(e,t,n){const o=(t+n.lat)/2*(Math.PI/180);return[111.32*(e-n.lon)*Math.cos(o),110.574*(t-n.lat)]}function Nt(e){const t=Math.max(3,Math.round(e??5));return t%2==0?t+1:t}function jt(e){return Qu.has(e)?e:"monument"}function Ft(e,t){const n=Nt(t.gridSize),o=Math.max(1,t.gridRadiusKm??75),r=2*o/n,i=Math.floor(n/2),s=At(t.idAccessor,"id"),a=At(t.nameAccessor,"name"),c=At(t.longitudeAccessor,"lon"),l=At(t.latitudeAccessor,"lat"),u=At(t.kindAccessor,"kind"),d=t.candidatePriorityAccessor?At(t.candidatePriorityAccessor,"priority"):()=>0,h=Array.from({length:n*n},(e,t)=>{const i=Math.floor(t/n),s=t%n;return{id:`tile-${i}-${s}`,row:i,column:s,centerXKm:(s+.5)*r-o,centerYKm:o-(i+.5)*r,terrainIndex:(17*i+31*s)%Zu.length,landmark:null,landmarks:[]}}),f=[];for(const i of e){const e=Number(c(i)),m=Number(l(i));if(!Number.isFinite(e)||!Number.isFinite(m))continue;const p=String(s(i)??`${e},${m}`),g=String(a(i)??p),y=jt(u(i)),[x,b]=Ct(e,m,t.center);if(Math.abs(x)>o||Math.abs(b)>o)continue;const w=Math.min(n-1,Math.floor((x+o)/r)),M=Math.min(n-1,Math.floor((o-b)/r)),v=h[M*n+w],k=Number(d(i)),$={...i,id:p,name:g,kind:y,lon:e,lat:m,distanceKm:Math.sqrt(x*x+b*b),row:M,column:w,cellDistanceSq:(x-v.centerXKm)**2+(b-v.centerYKm)**2,candidatePriority:Number.isFinite(k)?k:0};v.landmarks.push($),p===t.centerId&&f.push($)}const m=(e,t)=>It(e.name,t.name)||It(e.id,t.id)||e.lon-t.lon||e.lat-t.lat||It(e.kind,t.kind),p=(e,t)=>e.candidatePriority-t.candidatePriority||e.cellDistanceSq-t.cellDistanceSq||m(e,t),g=h[i*n+i],y=f.sort(p)[0]??[...g.landmarks].sort((e,t)=>e.candidatePriority-t.candidatePriority||Number("city"===t.kind)-Number("city"===e.kind)||e.distanceKm-t.distanceKm||m(e,t))[0],x=/* @__PURE__ */new Map;y&&x.set(y.kind,1);const b=e=>e.cellDistanceSq+(x.get(e.kind)??0)*r*r*.35,w=(e,t)=>e.candidatePriority-t.candidatePriority||b(e)-b(t)||m(e,t);for(const e of h){const t=e===g;if(e.landmarks=e.landmarks.filter(e=>e!==y).sort(t?p:w),t&&y&&e.landmarks.unshift(y),e.landmark=e.landmarks[0]??null,e.landmark&&e.landmark!==y){const t=e.landmark.kind;x.set(t,(x.get(t)??0)+1)}}return h}function Et(){const e=(bu??(bu=Ju.createContext(null)),bu);return Ju.useContext(e)??ed}function Pt(e,t){if(null!=e&&"object"==typeof e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function zt(e,t){const n=Pt(e,t);return"string"==typeof n&&n.length>0?n:void 0}function Lt(e){return id.has(e)?e:void 0}function Ot(e,t){const n=Pt(e,t),o=Lt("string"==typeof n?n:Pt(n,"kind"));if(!o)return;if("string"==typeof n)return{kind:o};const r=Pt(n,"coverage"),i="number"==typeof r&&Number.isFinite(r)?Math.max(0,Math.min(1,r)):void 0,s=zt(n,"fill");return{kind:o,...null==i?{}:{coverage:i},...s?{fill:s}:{}}}function Tt({tiles:e,tileWidth:t,tileHeight:n,sprites:o,resourceSize:r,citySize:i,showCityLabel:s}){const a=Et(),c=e.filter(e=>e.landmark).sort((e,t)=>e.y-t.y||e.x-t.x);/* @__PURE__ */ /* @__PURE__ */
|
|
3
|
-
return(0,
|
|
4
|
-
return(0,
|
|
2
|
+
return Object.create(null)}function i(e,t){return e.slice(0,t+1).map(e=>e.replaceAll("%","%25").replaceAll(">","%3E")).join(">")}function s(e,t,o){return t.has(e)?"node":n(o.nodeIdsBySection,e)?"section":"global"}function a(e,t,n){const i=[],a=new Set(t.nodes.map(e=>e.id)),c=/* @__PURE__ */new Set;for(const o of t.measureValues){const t=e.measures[o.measureId];if(!t)continue;const r=s(o.subjectId,a,n);i.push({measureId:o.measureId,subjectId:o.subjectId,subjectKind:r,value:o.value,status:o.status,unitKind:t.unitKind,countUnit:t.countUnit,timeDenominator:t.timeDenominator}),"section"===r&&c.add(`${o.measureId}\0${o.subjectId}`)}const l=r();for(const e of t.nodes)o(l,e.id,e);const u=r(),d=r();for(const e of i){if("node"!==e.subjectKind)continue;const t=l[e.subjectId];if(!t?.sectionId)continue;const n=`${e.measureId}\0${t.sectionId}`;c.has(n)||(u[n]=(u[n]??0)+e.value,"exact"!==e.status?d[n]=e.status:d[n]||(d[n]="exact"))}for(const[t,n]of Object.entries(u)){const o=t.split("\0"),r=o[0],s=o[1],a=e.measures[r];a&&i.push({measureId:r,subjectId:s,subjectKind:"section",value:n,status:d[t]??"exact",unitKind:a.unitKind,countUnit:a.countUnit,timeDenominator:a.timeDenominator})}return{entries:i}}function c(e,t,n){return e.entries.find(e=>e.measureId===t&&e.subjectId===n)}function l(t){const n=t.spec.comparison;if(!n)return;const o=n.partitions.map(o=>{const r=c(t.ledger,n.denominatorMeasureId,o)?.value??0,i={};return i["repeated-state-episode"]=e(t.motifs.matches.filter(e=>"repeated-state-episode"===e.template),t.source.occurrences,o),{partition:o,assigned:r,motifUsers:i,outcomes:{purchases:c(t.ledger,"purchases",o)?.value??0}}});return{partitions:[...n.partitions],denominatorMeasureId:n.denominatorMeasureId,referencePartition:n.referencePartition,rows:o}}function u(e,t){const n=e.spec.comparison?.denominatorMeasureId??e.spec.motifs.denominatorRef??"assigned";return c(e.ledger,n,t)?.value}function d(e,t,n){return 0===n||1e4*e%n!=0?Math.round((t-e)/Math.max(n,1)*1e4):1e4*(t-e)/n}function h(e,t){const n=r();for(const t of e.nodes)o(n,t.id,t.completeness??"known");const i=r();for(const e of t.unsupportedTemplates)o(i,e,"unsupported-template");if(t.incompleteCandidates.length>0){const e=new Set(t.incompleteCandidates.map(e=>e.template));for(const t of e)o(i,t,"incomplete")}const s=t.matches.find(e=>e.truncation),a={nodes:n,motifs:i,traces:e.occurrences?.some(e=>e.missingPrehistory||!1===e.complete)?"incomplete":e.nodes.some(e=>"unknown"===e.completeness)?"unknown":"known"};return s?.truncation&&(a.truncation={disclosed:!0,template:s.template,omitted:s.truncation.omitted}),a}function f(e){const t=new Map(e.nodes.map(e=>[e.id,[]])),n=new Map(e.nodes.map(e=>[e.id,[]]));for(const o of e.edges)t.get(o.source).push(o),n.get(o.target).push(o);return{outgoing:t,incoming:n}}function m(e,t){const n=/* @__PURE__ */new Set,o=[];for(const r of t){if(n.has(r))continue;n.add(r);const t=[{node:r,next:0}];for(;t.length;){const r=t[t.length-1],i=e[r.node][r.next++];void 0===i?(o.push(r.node),t.pop()):n.has(i)||(n.add(i),t.push({node:i,next:0}))}}return o}function p(e){const t=e.nodes.map(e=>e.id).sort(),n=new Map(t.map((e,t)=>[e,t])),o=t.map(()=>[]),r=t.map(()=>[]);for(const t of e.edges){const e=n.get(t.source),i=n.get(t.target);o[e].push(i),r[i].push(e)}const i=/* @__PURE__ */new Set,s=[];for(const e of m(o,t.map((e,t)=>t)).reverse()){if(i.has(e))continue;const n=[],o=[e];for(i.add(e);o.length;){const e=o.pop();n.push(t[e]);for(const t of r[e])i.has(t)||(i.add(t),o.push(t))}s.push(n.sort())}return s.sort((e,t)=>e[0].localeCompare(t[0]))}function g(e,t,n="rooted-traversal:id-asc"){const{outgoing:o}=f(e),r=n.endsWith("id-desc")?-1:1;for(const e of o.values())e.sort((e,t)=>r*e.id.localeCompare(t.id));const i=new Set(t),s=[],a=[...new Set(t)],c=e=>{const t=[{node:e,next:0}];for(;t.length;){const e=t[t.length-1],n=o.get(e.node)?.[e.next++];n?i.has(n.target)||(i.add(n.target),s.push([n.target,n.id]),t.push({node:n.target,next:0})):t.pop()}};for(const e of a)c(e);for(const t of e.nodes.map(e=>e.id).sort())i.has(t)||(a.push(t),i.add(t),c(t));const l=s.map(([,e])=>e),u=new Set(l);return{forest:{kind:"rooted-backbone",roots:a,rankingPolicyId:n,backboneEdgeIds:l,primaryParentEdgeIdByNode:Object.fromEntries(s)},residual:{originalEdgeIds:e.edges.map(e=>e.id),residualEdgeIds:e.edges.filter(e=>!u.has(e.id)).map(e=>e.id)}}}function y(e){const[t,n]=e.split(":");return{mode:"tree-only"===t?"tree-only":"main-transport",order:"id-desc"===n?"id-desc":"id-asc"}}function x(e,t,n){if("ordinal"!==t.coordinate.kind)return!0;const o=e.nodes.find(e=>e.id===n);return Boolean(o?.sectionId&&t.coordinate.sectionIds.includes(o.sectionId))}function b(e,t){return[...e].sort((e,n)=>"id-asc"===t?e.id.localeCompare(n.id):n.id.localeCompare(e.id))}function w(e,t){if(e.forest.display.rankingPolicyId?.startsWith("rooted-traversal"))return g(t,e.forest.display.roots??[],e.forest.display.rankingPolicyId);const n=t.edges.map(e=>e.id),i=e.forest.display.rankingPolicyId??"main-transport",{mode:s,order:a}=y(i),c=n=>x(t,e,n.source)&&x(t,e,n.target),l=/* @__PURE__ */new Map;for(const e of t.nodes)l.set(e.id,[]);for(const e of t.edges)l.has(e.target)||l.set(e.target,[]),l.get(e.target).push(e);const u=r(),d=e.forest.display.roots&&e.forest.display.roots.length>0?e.forest.display.roots:t.nodes[0]?[t.nodes[0].id]:[],h=new Set(d);for(const e of t.nodes){if(h.has(e.id))continue;const t=b(l.get(e.id)??[],a),n=t.find(e=>c(e))??t[0];n&&o(u,e.id,n.id)}let f;f="tree-only"===s?Object.values(u):t.edges.filter(e=>c(e)).map(e=>e.id);const m=new Set(f),p=n.filter(e=>!m.has(e));return{forest:{kind:"rooted-backbone",roots:[...d],rankingPolicyId:i,backboneEdgeIds:f,primaryParentEdgeIdByNode:u},residual:{residualEdgeIds:p,originalEdgeIds:n}}}function M(e,t){const n=new Set(e.originalEdgeIds),o=new Set(t.backboneEdgeIds),r=new Set(e.residualEdgeIds);if(o.size!==t.backboneEdgeIds.length)throw new Error("duplicate backbone edge id");if(r.size!==e.residualEdgeIds.length)throw new Error("duplicate residual edge id");for(const e of o){if(r.has(e))throw new Error(`edge ${e} is both backbone and residual`);if(!n.has(e))throw new Error(`backbone edge ${e} is not original`)}for(const e of r)if(!n.has(e))throw new Error(`residual edge ${e} is not original`);if(o.size+r.size!==n.size)throw new Error("original edge IDs != backbone ⊎ residual")}function v(e){const t=new Map(e.nodes.map(e=>[e.id,/* @__PURE__ */new Set])),n=new Map(e.nodes.map(e=>[e.id,/* @__PURE__ */new Set])),o=/* @__PURE__ */new Map;for(const r of e.edges){t.get(r.target)?.add(r.source),n.get(r.source)?.add(r.target);let e=o.get(r.source);e||o.set(r.source,e=/* @__PURE__ */new Map);const i=e.get(r.target);i?i.push(r.id):e.set(r.target,[r.id])}return{incoming:new Map([...t].map(([e,t])=>[e,[...t]])),outgoing:new Map([...n].map(([e,t])=>[e,[...t]])),sectionByNode:new Map(e.nodes.map(e=>[e.id,e.sectionId])),pairs:o}}function k(e,t){return e.sectionByNode.get(t)}function $(e,t){const n=/* @__PURE__ */new Set,o=[];for(const r of t){const t=k(e,r);t&&!n.has(t)&&(n.add(t),o.push(t))}return o}function S(e,t,n){return e.pairs.get(t)?.get(n)??[]}function I(e){return e.entityCount??1}function A(e,t){const n=[];let o=0;for(const r of e)r.nodePath.includes(t)&&!r.missingPrehistory&&(n.push(r.entityId),o+=I(r));return{entityIds:n,entityCount:o}}function C(e,t){return null==t||e.length<=t?{kept:e}:{kept:e.slice(0,t),truncation:{disclosed:!0,omitted:e.length-t,fullCount:e.length}}}function N(e,t,n,o,i,s){if(n.length<2)return;const{kept:a,truncation:c}=C(n,s),l=[t,...a],u=[];for(const n of a){const o="fan-out"===e?S(i,t,n):S(i,n,t);u.push(...o)}const d=$(i,[t,...n]),h=A(o.occurrences??[],t);return{id:`${e}:${t}`,template:e,roles:"fan-out"===e?{source:t,destinations:a}:{destination:t,sources:a},nodePath:l,edgeIds:u,startSectionId:d[0],completionSectionId:d[d.length-1],intersectSectionIds:d,entityIds:h.entityIds,entityWeights:r(),entityCount:h.entityCount,flags:{occurrence:h.entityIds.length>0,temporal:!1,trajectorySupported:h.entityIds.length>0,enriched:!1},truncation:c}}function j(e,t,n){return 1===t.length&&1===n.length}function F(e,t){const n=t.incoming,o=t.outgoing,i=[];for(const s of e.nodes){const a=n.get(s.id)??[],c=o.get(s.id)??[];if(1!==c.length)continue;const l=1===a.length&&j(a[0],n.get(a[0])??[],o.get(a[0])??[]);if(j(s.id,a,c)&&l)continue;const u=[s.id];let d=s.id;const h=/* @__PURE__ */new Set([d]);for(;;){const e=(o.get(d)??[])[0];if(!e||h.has(e))break;if(u.push(e),h.add(e),!j(0,n.get(e)??[],o.get(e)??[]))break;d=e}if(u.length<2)continue;const f=[];for(let e=0;e<u.length-1;e++)f.push(...S(t,u[e],u[e+1]));const m=$(t,u),p=A(e.occurrences??[],u[0]);i.push({id:`serial-chain:${u.join(">")}`,template:"serial-chain",roles:{nodes:u,start:u[0],end:u[u.length-1]},nodePath:u,edgeIds:f,startSectionId:m[0],completionSectionId:m[m.length-1],intersectSectionIds:m,entityIds:p.entityIds,entityWeights:r(),entityCount:p.entityCount,flags:{occurrence:p.entityIds.length>0,temporal:!1,trajectorySupported:p.entityIds.length>0,enriched:!1}})}return i}function E(e,t){const n=t.occurrences??[];if(0!==n.length)for(const t of e){if("repeated-state-episode"===t.template)continue;const e=t.nodePath,i=r();for(const t of n)t.missingPrehistory||e.some(e=>t.nodePath.includes(e))&&o(i,t.entityId,I(t));const s=Object.keys(i);t.entityIds=s,t.entityWeights=i,t.entityCount=s.reduce((e,t)=>e+(i[t]??0),0),t.flags={...t.flags,occurrence:s.length>0,trajectorySupported:s.length>0}}}function P(e,t){const n=[];for(const i of e.occurrences??[]){if(i.missingPrehistory)continue;const e=/* @__PURE__ */new Map,s=/* @__PURE__ */new Set;for(const[a,c]of i.nodePath.entries()){const l=e.get(c);if(null==l){e.set(c,a);continue}if(s.has(c))continue;s.add(c);const u=i.nodePath.slice(l,a+1),d=$(t,u),h=r();o(h,i.entityId,I(i)),n.push({id:`repeated-state-episode:${i.id}:${c}`,template:"repeated-state-episode",roles:{state:c,occurrence:i.id},nodePath:u,edgeIds:[],startSectionId:k(t,u[0]),completionSectionId:k(t,u[u.length-1]),intersectSectionIds:d,entityIds:[i.entityId],entityWeights:h,entityCount:I(i),flags:{occurrence:!0,temporal:!1,trajectorySupported:!0,enriched:!1}})}}return n}function z(e,t){const n=e.motifs.matchBudget,o=v(t),r=[];for(const e of t.nodes){const i=N("fan-out",e.id,o.outgoing.get(e.id)??[],t,o,n);i&&r.push(i);const s=N("fan-in",e.id,o.incoming.get(e.id)??[],t,o,n);s&&r.push(s)}r.push(...F(t,o)),r.push(...P(t,o)),E(r,t);const i=[];for(const e of t.occurrences??[])e.missingPrehistory&&(i.push({template:"serial-chain",occurrenceId:e.id,reason:"missing-prehistory"}),i.push({template:"repeated-state-episode",occurrenceId:e.id,reason:"missing-prehistory"}));const s=xl.filter(e=>!wl.includes(e));return{catalogId:e.motifs.catalogId,catalogVersion:e.motifs.catalogVersion,matches:r,incompleteCandidates:i,unsupportedTemplates:s}}function L(e){return e.entityCount??1}function O(e,t,n){const o=t??"";e.partitionCounts.set(o,(e.partitionCounts.get(o)??0)+n)}function T(e,t={}){function n(e){const t=[...e.children.keys()];return t.sort((t,n)=>{const o=e.children.get(t),r=e.children.get(n),i=l?o.partitionCounts.get(l)??0:1;return i>0!=(l?r.partitionCounts.get(l)??0:1)>0?i>0?-1:1:t.localeCompare(n)}),t}const s={id:"",stateId:"",prefix:[],children:/* @__PURE__ */new Map,occurrenceIds:[],entityCount:0,partitionCounts:/* @__PURE__ */new Map};for(const t of e){if(t.missingPrehistory)continue;const e=L(t);let n=s;n.occurrenceIds.push(t.id),n.entityCount+=e,O(n,t.partition,e);for(const o of t.nodePath){const r=[...n.prefix,o],s=i(r,r.length-1);let a=n.children.get(o);a||(a={id:s,stateId:o,prefix:r,children:/* @__PURE__ */new Map,occurrenceIds:[],entityCount:0,partitionCounts:/* @__PURE__ */new Map},n.children.set(o,a)),a.occurrenceIds.push(t.id),a.entityCount+=e,O(a,t.partition,e),n=a}}const a=[],c=[],l=t.referencePartition;return function e(t,i){if(t.id){const e=r();for(const[n,r]of t.partitionCounts)o(e,n,r);a.push({id:t.id,stateId:t.stateId,prefix:t.prefix,parentId:i,childIds:n(t).map(e=>t.children.get(e).id),entityCount:t.entityCount,occurrenceIds:[...t.occurrenceIds],partitionCounts:e}),c.push(t.id)}for(const o of n(t))e(t.children.get(o),t.id||null)}(s,null),{kind:"observed-prefix",rootIds:n(s).map(e=>s.children.get(e).id),nodes:a,order:c,referencePartition:l}}function R(e,t){if("ordinal"!==e.coordinate.kind)return{kind:"ordinal",sectionIds:[],nodeIdsBySection:r()};const n=r();for(const t of e.coordinate.sectionIds)o(n,t,[]);for(const e of t.nodes){if(!e.sectionId)continue;const t=n[e.sectionId];t&&t.push(e.id)}return{kind:"ordinal",sectionIds:[...e.coordinate.sectionIds],nodeIdsBySection:n}}function W(e,t){return t.length>0&&e.some((n,o)=>t.every((t,n)=>e[o+n]===t))}function q(e){const t=[];for(const n of e.occurrences??[]){if(n.missingPrehistory)continue;const e=n.nodePath;for(let o=0;o<e.length-1;o++)t.push({from:e[o],to:e[o+1],via:o>0?e[o-1]:void 0,occurrenceIds:[n.id]})}return{hops:t,graphAdjacency:e.edges.map(e=>({source:e.source,target:e.target,edgeId:e.id}))}}function D(e,t){const n=e.nodes.map(e=>e.id).sort(),o=new Map(n.map((e,t)=>[e,t])),r=n.length,i=Array.from({length:n.length+1},()=>[]),s=i.map(()=>[]),a=(e,t)=>{i[e].push(t),s[t].push(e)};for(const t of e.edges)a(o.get(t.source),o.get(t.target));for(const e of t.roots)a(r,o.get(e));const c=m(i,[r]).reverse(),l=new Map(c.map((e,t)=>[e,t])),u=/* @__PURE__ */new Map([[r,r]]),d=(e,t)=>{for(;e!==t;)l.get(e)>l.get(t)?e=u.get(e):t=u.get(t);return e};let h=!0;for(;h;){h=!1;for(const e of c.slice(1)){const t=s[e].filter(e=>u.has(e)).reduce(d);u.get(e)!==t&&(u.set(e,t),h=!0)}}return{...t,roots:[...new Set(t.roots)].sort(),status:e.nodes.some(e=>e.completeness&&"known"!==e.completeness)?"incomplete":"exact",immediateDominatorByNode:Object.fromEntries(n.flatMap((e,t)=>u.has(t)?[[e,u.get(t)===r?null:n[u.get(t)]]]:[])),reachableNodeIds:n.filter((e,t)=>u.has(t)),unreachableNodeIds:n.filter((e,t)=>!u.has(t))}}function B(e,t,n,o){e.push({kind:t,severity:"fatal",message:n,id:o})}function Y(e,t){const n=[];e.schemaVersion!==yl&&B(n,"schema-version",`expected schemaVersion ${yl}`),e.relations.directed&&!0===e.relations.edgeIdRequired||B(n,"relations","Phase 1 requires directed edges with ids"),"rooted-backbone"!==e.forest.display.kind&&"observed-prefix"!==e.forest.display.kind&&B(n,"forest","supported display kinds: rooted-backbone, observed-prefix"),"ordinal"!==e.coordinate.kind&&B(n,"coordinate","Phase 1 kernel uses ordinal sections");const i=r();for(const r of t.nodes)r.id?(i[r.id]&&B(n,"duplicate-node","duplicate node id",r.id),o(i,r.id,!0),"ordinal"===e.coordinate.kind&&r.sectionId&&!e.coordinate.sectionIds.includes(r.sectionId)&&B(n,"section-membership",`node section ${r.sectionId} is not in the coordinate`,r.id)):B(n,"node-id","node is missing id");const s=r();for(const e of t.edges)e.id?(s[e.id]&&B(n,"duplicate-edge","duplicate edge id",e.id),o(s,e.id,!0),i[e.source]||B(n,"dangling-source","edge source is not a node",e.id),i[e.target]||B(n,"dangling-target","edge target is not a node",e.id)):B(n,"edge-id","edge is missing id");for(const t of e.forest.display.roots??[])i[t]||B(n,"missing-root","display root is not a node",t);const a=e.forest.requiredPaths;if(a)if("directed-admitted"!==a.relationScopeId&&B(n,"required-path-scope","required paths use the full directed-admitted relation scope"),Array.isArray(a.roots)&&0!==a.roots.length)for(const e of a.roots)i[e]||B(n,"required-path-roots","required-path root is not a node",e);else B(n,"required-path-roots","required paths need declared roots");if("rooted-backbone"===e.forest.display.kind&&0===e.forest.display.roots.length&&B(n,"missing-root","rooted-backbone requires at least one root"),e.comparison&&(e.comparison.partitions.length<2&&B(n,"comparison","comparison requires at least two partitions"),e.measures[e.comparison.denominatorMeasureId]||B(n,"comparison-denominator","comparison denominatorMeasureId is not a declared measure")),null===(c=e.measures)||"object"!=typeof c||Array.isArray(c))B(n,"measures","measures must be an object");else for(const[t,o]of Object.entries(e.measures))"rate"!==o.unitKind||o.timeDenominator||B(n,"rate-denominator","rate measures require a timeDenominator",t);var c;for(const o of t.measureValues)e.measures[o.measureId]?Number.isFinite(o.value)||B(n,"non-finite-measure","measure value is not finite",o.measureId):B(n,"unknown-measure","measureValue refers to an undeclared measure",o.measureId);for(const e of t.occurrences??[])if(e.id&&e.entityId){void 0===e.stepEntityCounts||Array.isArray(e.stepEntityCounts)&&e.stepEntityCounts.length===e.nodePath.length&&!Array.from(e.stepEntityCounts).some(e=>!Number.isFinite(e)||e<0)||B(n,"occurrence-step-counts","stepEntityCounts must contain one finite, nonnegative count per nodePath step",e.id);for(const t of e.nodePath)i[t]||B(n,"occurrence-node","occurrence path references a missing node",e.id)}else B(n,"occurrence","occurrence needs id and entityId");return{ok:n.every(e=>"fatal"!==e.severity),issues:n}}function V(e,t,n){return JSON.stringify([n,t.graphRef,t.revision,e],(e,t)=>t&&"object"==typeof t&&!Array.isArray(t)?Object.fromEntries(Object.keys(t).sort().map(e=>[e,t[e]])):t)}function G(e,t,n={}){const o=Y(e,t);if(!o.ok)return{ok:!1,issues:o.issues};const r=n.generation??1,i=R(e,t),s=z(e,t),c=w(e,t);M(c.residual,c.forest);const u=a(e,t,i),d=h(t,s),f=q(t),m=V(e,t,r),p="observed-prefix"===e.forest.display.kind||(t.occurrences?.length??0)>0?T(t.occurrences??[],{referencePartition:"observed-prefix"===e.forest.display.kind?e.forest.display.referencePartition??e.comparison?.referencePartition:e.comparison?.referencePartition}):void 0,g={sourceGraphRef:t.graphRef,analysisRevision:m,spec:e,source:t,sections:i,motifs:s,forest:c.forest,residualEdges:c.residual,ports:f,ledger:u,completeness:d,provenance:{sourceRevision:t.revision,analysisRevision:m,generation:r,relationScope:"directed-admitted",motifCatalogVersion:e.motifs.catalogVersion,coordinatePolicy:"ordinal"===e.coordinate.kind?`ordinal:${e.coordinate.sectionIds.join(",")}`:`numeric:${e.coordinate.field}`,forestRoots:[...e.forest.display.roots??c.forest.roots],rankingPolicyId:c.forest.rankingPolicyId,population:e.motifs.countUnit,temporalHorizon:e.temporal.kind,evidencePolicyId:e.evidencePolicyId},prefixForest:p,...e.forest.requiredPaths&&{requiredPaths:D(t,e.forest.requiredPaths)}};return g.comparison=l(g),{ok:!0,atlas:g,issues:o.issues}}function _(e){const t=e.roles.occurrence;return"string"==typeof t?[t]:e.entityIds}function H(e,t={}){const n=new Set(t.templates??["repeated-state-episode"]),o=e.filter(e=>n.has(e.template)).map(e=>{const t="string"==typeof e.roles.state?e.roles.state:e.nodePath[0],n=e.nodePath[e.nodePath.length-1];return{id:`capsule:${e.id}`,matchId:e.id,template:e.template,entryState:t,exitState:n,entityCount:e.entityCount,occurrenceIds:_(e),selected:!1}}).sort((e,t)=>t.entityCount!==e.entityCount?t.entityCount-e.entityCount:e.id.localeCompare(t.id)),r=/* @__PURE__ */new Set;for(const e of o)if(!e.occurrenceIds.some(e=>r.has(e))){e.selected=!0;for(const t of e.occurrenceIds)r.add(t)}return o}function X(t,n={}){const o=n.templates??["repeated-state-episode"],r="ordinal"===t.spec.coordinate.kind?t.spec.coordinate.sectionIds:[],i=void 0!==n.partition?u(t,n.partition)??0:t.spec.comparison?t.comparison?.rows.reduce((e,t)=>e+t.assigned,0)??0:t.ledger.entries.find(e=>"global"===e.subjectKind&&e.measureId===t.spec.motifs.denominatorRef)?.value??0,s=o=>e(o,t.source.occurrences,n.partition??t.spec.comparison?.partitions),a=[],c=t.motifs.incompleteCandidates.length>0;for(const e of o)for(const o of r){const r=t.motifs.matches.filter(t=>t.template===e),l=s(r.filter(e=>e.completionSectionId===o)),u=s(r.filter(e=>e.intersectSectionIds.includes(o)));a.push({template:e,sectionId:o,partition:n.partition,completionCount:l,intersectionCount:u,denominator:i,status:c?"incomplete":"exact"})}return{templates:o,sections:r,cells:a}}function U(e){return e.entityCount??1}function K(e){if(!e.missingPrehistory)return{id:`group:${e.id}`,occurrenceId:e.id,partition:e.partition,nodePath:e.nodePath,entityCount:U(e),...e.stepEntityCounts&&{stepEntityCounts:[...e.stepEntityCounts]},signature:i(e.nodePath,e.nodePath.length-1)}}function Z(e){const t=e.prefixForest;if(!t)return{atlas:e,groups:[],signatureOrder:[],ribbons:[],capsules:[],profile:X(e),differences:[],prefixForest:{kind:"observed-prefix",rootIds:[],nodes:[],order:[]},sceneSeeds:{nodes:[],edges:[]}};const n=(e.source.occurrences??[]).map(K).filter(e=>Boolean(e)),o=/* @__PURE__ */new Map;for(const e of n){const n=t.order.indexOf(e.signature),r=o.get(e.signature),i=-1===n?t.order.length:n;(null==r||i<r)&&o.set(e.signature,i)}const r=[...new Set(n.map(e=>e.signature))].sort((e,t)=>{const n=(o.get(e)??0)-(o.get(t)??0);return 0!==n?n:e.localeCompare(t)}),s=[];for(const e of n)for(let t=0;t<e.nodePath.length-1;t++){const n=i(e.nodePath,t),o=i(e.nodePath,t+1);s.push({id:`ribbon:${e.id}:${t}`,groupId:e.id,partition:e.partition,fromPrefixId:n,toPrefixId:o,fromState:e.nodePath[t],toState:e.nodePath[t+1],entityCount:e.stepEntityCounts?.[t]??e.entityCount,...e.stepEntityCounts&&{toEntityCount:e.stepEntityCounts[t+1]}})}const a=H(e.motifs.matches),c=e.comparison??l(e),u=[];if(c&&c.partitions.length>=2){const e=c.rows[0],t=c.rows[1],n=Math.min(e.assigned,t.assigned)||e.assigned,o=e.motifUsers["repeated-state-episode"]??0,r=t.motifUsers["repeated-state-episode"]??0;u.push({motif:"repeated-state-episode",leftPartition:e.partition,rightPartition:t.partition,leftCount:o,rightCount:r,deltaCount:r-o,deltaBps:d(o,r,n),denominator:n}),u.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:d(e.outcomes.purchases??0,t.outcomes.purchases??0,n),denominator:n})}const h={nodes:n.map(e=>({id:e.id,partition:e.partition,signature:e.signature})),edges:s.map(e=>({id:e.id,source:e.fromPrefixId,target:e.toPrefixId}))};return{atlas:e,groups:n,signatureOrder:r,ribbons:s,capsules:a,profile:X(e),differences:u,prefixForest:t,sceneSeeds:h}}function Q(e,t){return e.groups.some(e=>W(e.nodePath,t))}function J(e){let t=1/0,n=-1/0;for(const o of e)o<t&&(t=o),o>n&&(n=o);return[t,n]}function ee(e,t=-1/0){let n=t;for(const t of e)t>n&&(n=t);return n}function te(e,t,n){if(n.some(e=>null!=e.__forceRadius))return e=>e.__forceRadius??8;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const o=t||[5,20],r=[];for(const t of n){const n=t.data?.[e];"number"==typeof n&&r.push(n)}if(0===r.length)return()=>o[0];const[i,s]=J(r);if(i===s)return()=>(o[0]+o[1])/2;const a=(0,Zl.scaleLinear)().domain([i,s]).range(o).clamp(!0);return t=>{const n=t.data?.[e];return null==n||"number"!=typeof n?o[0]:a(n)}}function ne(e){const t=e.data?.weight??e.weight;return"number"==typeof t&&Number.isFinite(t)?t:Number.isFinite(e.value)?e.value:1}function oe(e,t,n,o,r=Ql){return"sync"!==e&&("worker"===e||o*(t+n)>=r)}function re(){return"undefined"!=typeof window&&"undefined"!=typeof Worker}function ie(e,t,n,o,r){const i=te(n.nodeSize,n.nodeSizeRange,e);return{kind:"frame",nodes:e.map(e=>{const t=e,n=r?.get(e.id),o=0!==e.x||0!==e.y?e.x:n?.x??0,s=0!==e.x||0!==e.y?e.y:n?.y??0;return{id:e.id,x:o,y:s,vx:t.vx,vy:t.vy,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:e.value,__forceRadius:i(e)}}),edges:t.map(e=>({source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:e.value,y0:0,y1:0,sankeyWidth:0,data:{weight:ne(e)}})),config:{chartType:"force",iterations:n.iterations,forceStrength:n.forceStrength,seed:n.seed,__previousPositions:r??n.__previousPositions},size:o}}function se(e){if("undefined"!=typeof __filename){const t=__filename.replace(/\\/g,"/"),n=t.startsWith("/")?t:`/${t}`;return new URL(`./${e}`,`file:${n}`)}throw new Error(`Cannot resolve module worker asset: ${e}`)}function ae(e){if("undefined"!=typeof DOMException)return new DOMException(`${e} aborted`,"AbortError");const t=new Error(`${e} aborted`);return t.name="AbortError",t}function ce(e){const t=new Error(e.message);return t.name=e.name??"Error",e.stack&&(t.stack=e.stack),t}function le(e){if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Malformed worker response");const t=e;if(void 0!==t.requestId&&(!Number.isInteger(t.requestId)||t.requestId<1)||void 0!==t.error&&(!t.error||"string"!=typeof t.error.message||[t.error.name,t.error.stack].some(e=>void 0!==e&&"string"!=typeof e)))throw new Error("Malformed worker response");return{requestId:t.requestId,error:t.error}}function ue(e){let t=null,n=null;return{get available(){return!n&&!t?.failure},get:()=>{if(n||t?.failure)throw n||t?.failure;if(!t||t.isDead)try{t=e()}catch(e){throw n=e instanceof Error?e:new Error(String(e)),n}return t},resetForTest:()=>{if(n=null,t){try{t.terminate()}catch{}t=null}}}}function de(){return"string"==typeof eu.url&&eu.url?new Worker(new URL("./forceLayoutWorker.js",eu.url),{type:"module",name:"semiotic-force-layout"}):new Worker(se("forceLayoutWorker.js"),{type:"module",name:"semiotic-force-layout"})}function he(){nu.resetForTest()}async function fe(e,t){return re()?nu.get().request(e,t):Promise.reject(new Error("Web Workers are unavailable"))}function me(e,t,n){return Math.max(t,Math.min(n,e))}function pe(e){return"function"==typeof e?e:t=>t[e]}function ge(e,t,n){const o=e?.data,r=o?o[t]:void 0;if(null!=r)return r;const i=e?.[t];return null==i?n:i}function ye(e){if(null==e)return null;const t=e;return t.data??t.datum??e}function xe(e,t){const n=/* @__PURE__ */new Map;for(const o of e){const e=t(o),r=n.get(e);r?r.push(o):n.set(e,[o])}return n}function be(e){const t=/* @__PURE__ */Object.create(null);return e((e,n)=>{t[e]=n}),t}function we(e,t){if(!t)return!0;const n=Array.isArray(t)?t:[t],o=e;for(const e of n)if(null!=e.value&&String(o[e.field])!==String(e.value))return!1;return!0}function Me(e,t={}){const n=t.baseOpacity??1;return t.highlight||t.predicate?!we(e,t.highlight)||t.predicate&&!t.predicate(e)?t.dimOpacity??.16:Math.min(1,n+(t.brighten??0)):n}function ve(e){return e.join("|")}function ke(e,t=.72){const n=(0,pu.interpolateLab)(e,"#ffffff"),o=(0,pu.interpolateLab)(e,"#000000"),r=(0,pu.interpolateLab)(e,e)(0);return e=>{const i=e<0?0:e>1?1:e;return.5===i?r:i<.5?n(2*(.5-i)*t):o(2*(i-.5)*t)}}function $e(e,t,n=.72){return ke(e,n)(t)}function Se(e){return be(t=>{for(const[n,o]of Object.entries(e))t(n,o)})}function Ie(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"item"}function Ae(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,t):0}function Ce(e){if(0===e.length)return 0;let t=0;for(const n of e)t+=n;return t/e.length}function Ne(e,t){const n=me(t,0,1),o=e.trim().replace(/^#/,""),r=3===o.length?o.split("").map(e=>e+e).join(""):o;return/^[0-9a-fA-F]{6}$/.test(r)?`rgba(${parseInt(r.slice(0,2),16)}, ${parseInt(r.slice(2,4),16)}, ${parseInt(r.slice(4,6),16)}, ${n})`:e}function je(e,t){return e<t?-1:e>t?1:0}function Fe(e,t,n,o,r,{force:i=!1}={}){if(t===n&&!i)return null;const s=`${t} of ${n} ${o} shown`;return(0,yu.createElement)("text",{key:"recipe-notice",x:e.x,y:e.y+e.height-4,fontSize:11,fill:"var(--semiotic-text, currentColor)",pointerEvents:"none",role:"img","aria-label":`${s}. ${r}`},(0,yu.createElement)("title",null,r),s)}function Ee(e,t,n){return Pe(e,t,n)}function Pe(e,t,n,o=!1){const r=Number.isFinite(t)?Math.max(0,Math.floor(t)):0,i=e=>Number.isFinite(e)?Math.max(0,e):0,s=e.reduce((e,t)=>e+(i(t.weight)>0?1:0),0),a=Math.max(0,Math.floor(n?.minPerCategory??0)),c=s>0?Math.min(a,Math.floor(r/s)):0,l=e.reduce((e,t)=>e+i(t.weight),0);if(r<=0||l<=0)return e.map(e=>({...e,exact:0,cells:0,remainder:0}));const u=e.map(e=>{const t=i(e.weight),n=t/l*r;return{...e,exact:n,cells:t>0?Math.max(c,Math.floor(n)):0,remainder:n-Math.floor(n)}});let d=u.reduce((e,t)=>e+t.cells,0);for(;d>r;){const e=u.filter(e=>e.cells>c).sort((e,t)=>t.cells-e.cells||e.remainder-t.remainder||e.key.localeCompare(t.key))[0];if(!e)break;e.cells--,d--}const h=u.filter(e=>i(e.weight)>0).sort((e,t)=>t.remainder-e.remainder||(o?0:i(t.weight)-i(e.weight)||e.key.localeCompare(t.key)));for(let e=0;d<r;e++)h[e%h.length].cells++,d++;return u}function ze(e,t,n,o){const r=/* @__PURE__ */new Set;return e.map((e,i)=>{const s=String(t(e,i)),a=Number(n(e,i));if(!s)throw new Error(`${o} snapshot contains an empty id at index ${i}.`);if(r.has(s))throw new Error(`${o} snapshot contains duplicate id "${s}".`);if(!Number.isFinite(a)||a<0)throw new Error(`${o} snapshot value for "${s}" must be a finite non-negative number.`);return r.add(s),{id:s,value:a}})}function Le(e,t,n){const o=n.afterId??n.beforeId,r=n.afterValue??n.beforeValue,i=null!=n.epsilon&&n.epsilon>=0?n.epsilon:1e-9,s=ze(e,n.beforeId,n.beforeValue,"Before"),a=ze(t,o,r,"After"),c=new Map(s.map(e=>[e.id,e.value])),l=new Map(a.map(e=>[e.id,e.value])),u=s.reduce((e,t)=>e+t.value,0),d=a.reduce((e,t)=>e+t.value,0),h=Math.abs(u-d)<=i;if(!h&&!n.allowImbalance)throw new Error(`Snapshot totals must match (before ${u}, after ${d}). Pass allowImbalance to inspect residuals.`);const f=[],m=[...s.map(e=>e.id),...a.map(e=>e.id).filter(e=>!c.has(e))];for(const e of m){const t=Math.min(c.get(e)??0,l.get(e)??0);t>i&&f.push({sourceId:e,targetId:e,value:t,kind:"stay"})}const p=s.map(e=>({id:e.id,value:e.value-(l.get(e.id)??0)})).filter(e=>e.value>i),g=a.map(e=>({id:e.id,value:e.value-(c.get(e.id)??0)})).filter(e=>e.value>i);let y=0,x=0;for(;y<p.length&&x<g.length;){const e=p[y],t=g[x],n=Math.min(e.value,t.value);n>i&&f.push({sourceId:e.id,targetId:t.id,value:n,kind:"move"}),e.value-=n,t.value-=n,e.value<=i&&(y+=1),t.value<=i&&(x+=1)}return{flows:f,beforeTotal:u,afterTotal:d,balanced:h,unmatchedBefore:p.slice(y).filter(e=>e.value>i).map(({id:e,value:t})=>({id:e,value:t})),unmatchedAfter:g.slice(x).filter(e=>e.value>i).map(({id:e,value:t})=>({id:e,value:t}))}}function Oe(e){return Number.isFinite(e)?Math.max(0,e):0}function Te(e,t){const n=Number(t.unit),o=Oe(e),r=t.maxUnits??1/0,i=t.minFraction??0;if(!(n>0)||!(r>0)||o<=0)return{units:[],unit:n>0?n:0,total:o,shown:0,overflow:o>0&&!(r>0)};const s=o/n,a=Math.ceil(s-bu),c=Math.min(r,a),l=a>r,u=[];for(let e=0;e<c;e+=1){const t=e*n,r=Math.min(o,t+n);let i=Math.min(1,Math.max(0,(r-t)/n));1-i<bu&&(i=1),u.push({index:e,fraction:i,start:t,end:t+i*n,value:i*n})}const d=u[u.length-1];d&&d.fraction<i&&d.fraction<1&&u.pop();const h=u.reduce((e,t)=>e+t.value,0);return{units:u,unit:n,total:o,shown:h,overflow:l}}function Re(e,t,n){const o=Te(e,n),r=Math.max(Oe(t),o.total);if(r<=o.total)return{...o,rangeUnits:[],rangeTotal:o.total};const i=Te(r,{unit:n.unit,maxUnits:n.maxUnits}),s=i.unit>0?o.total/i.unit:0,a=Math.floor(s+bu);let c=Math.min(1,Math.max(0,s-a));c<bu&&(c=0);const l=[];for(const e of i.units)e.index<a||(e.index===a&&c>0?e.fraction-c>bu&&l.push({...e,startFraction:c,start:e.index*i.unit+c*i.unit,value:(e.fraction-c)*i.unit}):l.push({...e,startFraction:0}));return{...o,overflow:o.overflow||i.overflow,rangeUnits:l,rangeTotal:r}}function We(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 qe(e,t,n={}){const o=n.seed??1,r=n.iterations??260,i=n.repulsion??5200,s=n.linkDistance??165,a=n.linkStrength??.045,c=n.centerStrength??.018,l=n.damping??.84,u=n.nodeRadius??12,d=n.nodePadding??3,h=n.inset??.06,f=We(o),m=/* @__PURE__ */new Map;for(const t of e)m.set(t.id,0);for(const e of t)m.set(e.source,(m.get(e.source)??0)+1),m.set(e.target,(m.get(e.target)??0)+1);const p=Mu/2,g=e.map(e=>({id:e.id,data:e,x:200+600*f(),y:200+600*f()})),y=e=>"function"==typeof u?u(e.data):u,x=new Set(e.map(e=>e.id)),b=t.filter(e=>x.has(e.source)&&x.has(e.target)).map(e=>({source:e.source,target:e.target}));if(r>0){const e=(0,wu.forceSimulation)(g).randomSource(f).alphaDecay(1-Math.pow(.001,1/r)).velocityDecay(Math.max(0,Math.min(1,1-l))).force("charge",(0,wu.forceManyBody)().strength(e=>{const t=m.get(e.id)??0;return 2.5*-Math.sqrt(i)*Math.sqrt(t+1)})).force("collide",(0,wu.forceCollide)(e=>y(e)+d).strength(.9).iterations(2)).force("center",(0,wu.forceCenter)(p,p).strength(.8)).force("x",(0,wu.forceX)(p).strength(c)).force("y",(0,wu.forceY)(p).strength(c));b.length>0&&e.force("link",(0,wu.forceLink)(b).id(e=>e.id).distance(s).strength(e=>{const t="string"==typeof e.source?e.source:e.source.id,n="string"==typeof e.target?e.target:e.target.id,o=Math.max(1,Math.min(m.get(t)??1,m.get(n)??1));return a/.045/o})),e.stop();for(let t=0;t<r;t+=1)e.tick()}let w=1/0,M=1/0,v=-1/0,k=-1/0;for(const e of g){const t=e.x??p,n=e.y??p;t<w&&(w=t),n<M&&(M=n),t>v&&(v=t),n>k&&(k=n)}const $=v-w,S=k-M,I={};for(const e of g){const t={x:0===$?.5:h+((e.x??p)-w)/$*(1-2*h),y:0===S?.5:h+((e.y??p)-M)/S*(1-2*h)};Object.defineProperty(I,e.id,{value:t,enumerable:!0,configurable:!0,writable:!0})}return I}function De(e){return e?e.map(Number).filter(Number.isFinite):[]}function Be(e){if("fixed-denominator"===e.countStrategy)return 1/0;const t=e.maxTokens??1/0;return t>0?Math.floor(t):0}function Ye(e,t){const n=Be(t);return e.length<=n?{tokens:e,overflow:!1}:{tokens:e.slice(0,n),overflow:!0}}function Ve(e){return"number"==typeof e?{value:e}:Array.isArray(e)?{samples:De(e),data:e}:e}function Ge(e){const t=e.unitValue??e.unit,n=e.icon??e.token;return{...e,...null!=t&&{unitValue:t},...null!=n&&{icon:n}}}function _e(e){if(e.samples)return De(e.samples);if(!e.data||!e.valueAccessor)return[];const t=e.valueAccessor;return e.data.map(e=>"function"==typeof t?t(e):Number(e[t])).filter(Number.isFinite)}function He(e,t){const n=e.length;if(0===n)return 0;if(1===n)return e[0];const o=(n-1)*Math.min(1,Math.max(0,t)),r=Math.floor(o),i=Math.ceil(o),s=o-r;return e[r]*(1-s)+e[i]*s}function Xe(e,t=1){const n=Array.from({length:e},(e,t)=>t),o=We(Math.floor(t)||1);for(let e=n.length-1;e>0;e-=1){const t=Math.floor(o()*(e+1)),r=n[e];n[e]=n[t],n[t]=r}return n}function Ue(e,t,n,o={}){return{index:t,tokenType:e.tokenType,tokenSemantics:e.tokenSemantics,countStrategy:e.countStrategy,fraction:1,startFraction:0,value:n,start:t,end:t+n,unitValue:e.unitValue,unitMeaning:e.unitMeaning,...o}}function Ke(e,t){const n=Ge(t),o=Ve(e);let r,i,s,a,c,l,u,d=0,h=!1;if("unitized"===n.countStrategy){c=n.unitValue??1;const e={unit:c,maxUnits:n.maxTokens,minFraction:n.minFraction},t=null==o.rangeValue?Te(Ae(o.value),e):Re(Ae(o.value),Ae(o.rangeValue),e);if(r=t.units.map(e=>Ue(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:t.unit})),i=t.total,d=t.shown,h=t.overflow,null!=o.rangeValue){const e=t;l=e.rangeTotal,u=e.rangeUnits.map(e=>Ue(n,e.index,e.value,{fraction:e.fraction,startFraction:e.startFraction,start:e.start,end:e.end,unitValue:t.unit,range:"scenario"}))}}else if("fixed-denominator"===n.countStrategy){a=Math.floor(Ae(o.denominator??n.denominator)),s=Ae(o.numerator??n.numerator??o.value);const e=Math.min(a,Math.max(0,Math.round(s)));r=Array.from({length:a},(t,o)=>Ue(n,o,1,{highlighted:o<e,start:o,end:o+1})),i=a,d=r.length,h=!1}else if("quantile"===n.countStrategy){const e=_e(o).sort((e,t)=>e-t),t=Math.max(0,Math.floor(n.tokenCount??50)),s=e.length>0?Math.min(t,Be(n)):0;r=Array.from({length:s},(t,o)=>{const r=(o+.5)/s,i=He(e,r);return Ue(n,o,i,{sample:i,quantile:r,start:i,end:i})}),i=e.length,d=r.length,h=e.length>0&&t>r.length}else if("sample"===n.countStrategy||"posterior-sample"===n.countStrategy||"random-sample"===n.countStrategy){const e=_e(o),t=Math.min(e.length,Math.max(0,Math.floor(n.tokenCount??e.length))),s=Math.min(t,Be(n));r=("random-sample"===n.countStrategy?Xe(e.length,n.seed).slice(0,s):Array.from({length:s},(t,n)=>Math.floor(n/Math.max(1,s-1)*(e.length-1)))).map((t,o)=>{const r=e[t];return Ue(n,o,r,{sample:r,start:r,end:r})}),i=e.length,d=r.length,h=t>r.length}else{const e=o.data;if(e&&null==o.value)r=e.map((e,t)=>Ue(n,t,1,{datum:e})),i=e.length;else{const e=Te(Ae(o.value),{unit:1,maxUnits:n.maxTokens,minFraction:n.minFraction});r=e.units.map(e=>Ue(n,e.index,e.value,{fraction:e.fraction,start:e.start,end:e.end,unitValue:1})),i=e.total,d=e.shown,h=e.overflow}if(e&&null==o.value){const e=Ye(r,n);r=e.tokens,d=r.length,h=e.overflow}}return{tokens:r,encoding:n,total:i,shown:d,overflow:h,numerator:s,denominator:a,unitValue:c,rangeTotal:l,rangeTokens:u,diagnostics:Qe(n,{visibleTokens:r.length+(u?.length??0)})}}function Ze(e,t={}){const n=(o=e,Array.isArray(o)?e:e.tokens);var o;const r=n.length;if(0===r)return[];const i=t.flow??"row",s=t.cellWidth??16,a=t.cellHeight??s,c=t.gutter??2,l=t.anchor??[.5,.5],u=Math.max(1,Math.floor(t.columns??(t.rows?Math.ceil(r/t.rows):Math.ceil(Math.sqrt(r))))),d=Math.max(1,Math.floor(t.rows??Math.ceil(r/u))),h="row"===i?Math.max(d,Math.ceil(r/u)):d,f="column"===i?Math.max(u,Math.ceil(r/d)):u,m=t.x??0,p=t.y??0;return n.map((e,n)=>{let o,r;return"column"===i?(r=Math.floor(n/d),o=n%d):(o=Math.floor(n/u),r=n%u),"left"===t.columnDirection&&(r=f-1-r),"up"===t.rowDirection&&(o=h-1-o),{...e,row:o,column:r,x:m+r*(s+c)+l[0]*s,y:p+o*(a+c)+l[1]*a}})}function Qe(e,t={}){const n=[],o=e.tokenSemantics,r=e.countStrategy,i=t.maxRecommendedTokens??("fixed-denominator"===r&&Ae(e.denominator)<=ku?ku:vu);return o||n.push({code:"TOKEN_SEMANTICS_UNCLEAR",severity:"warning",message:"Every tokenized encoding should state what one token represents."}),r||n.push({code:"MISSING_COUNT_STRATEGY",severity:"warning",message:"Every tokenized encoding should state how token counts are produced."}),"icon"!==e.tokenType&&"glyph"!==e.tokenType||"icon-only"!==e.labelPolicy&&"token-only"!==e.labelPolicy||n.push({code:"ICON_ONLY_LABELS",severity:"warning",message:"Icons should supplement text labels, not replace them."}),null!=t.visibleTokens&&t.visibleTokens>i&&n.push({code:"TOO_MANY_VISIBLE_TOKENS",severity:"warning",message:`This encoding renders ${t.visibleTokens} visible tokens. Consider unitizing, sampling, or a hybrid bar/token view.`}),"decorative"!==o||"icon"!==e.tokenType&&"glyph"!==e.tokenType||n.push({code:"DECORATIVE_PICTOGRAPHS",severity:"warning",message:"Decorative pictographs can harm recall and speed when they do not clarify the data."}),"unitized-measure"===o&&r&&"unitized"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Unitized measures should use the unitized count strategy so each token has a stable value."}),"risk-case"===o&&r&&"fixed-denominator"!==r&&n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Risk cases are usually clearest as a fixed-denominator natural frequency."}),"possible-outcome"!==o&&"posterior-sample"!==o&&"hypothetical-case"!==o||!r||"quantile"===r||"sample"===r||"posterior-sample"===r||"random-sample"===r||n.push({code:"TOKEN_STRATEGY_MISMATCH",severity:"warning",message:"Outcome/sample tokens should come from quantiles or samples, not from a unitized magnitude."}),"unitized-measure"===o&&"unitized"===r&&null==e.unitValue&&null==e.unit&&n.push({code:"MISSING_UNIT_VALUE",severity:"warning",message:"Unitized measures should set unitValue so each token has a declared value."}),"unitized-measure"!==o||"unitized"!==r||e.unitMeaning||n.push({code:"MISSING_UNIT_MEANING",severity:"info",message:"Add unitMeaning so readers know what one full token represents."}),n}function Je(e){return"measure"===e?"precise-comparison":"estimate probability"===e?"probability-estimation":"understand risk"===e?"risk-communication":"remember"===e?"memory":"decide"===e?"support-decision":e}function et(e){const t=Je(e);return"precise-comparison"===t?["compare-categories","rank"]:"probability-estimation"===t?["distribution"]:"risk-communication"===t?["part-to-whole","distribution"]:"frequency-reasoning"===t?["distribution","compare-categories"]:"memory"===t||"editorial-engagement"===t?["compare-categories"]:"public-explanation"===t||"support-decision"===t?["distribution","compare-categories"]:["compare-categories"]}function tt(e){const t=Je(e.taskIntent),n="small"===(o=e.availableSpace)?25:"large"===o?100:50;var o;if("precise-comparison"===t)return{recommendedEncoding:"bar-or-line",rationale:"Use continuous position/length encodings when precise magnitude comparison is the primary task.",warnings:[],alternatives:["hybrid-bar-token","unitized-measure"]};if("probability-estimation"===t){const e={tokenType:"dot",tokenSemantics:"possible-outcome",countStrategy:"quantile",tokenCount:n,layout:"dotplot",labelPolicy:"text-plus-token"};return{recommendedEncoding:"quantile-dotplot",tokenEncoding:e,rationale:"This task asks readers to estimate probability from a distribution. Quantile tokens turn probability mass into countable possible outcomes.",warnings:Qe(e),alternatives:["cdf-with-threshold","density-with-threshold"]}}if("risk-communication"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"risk-case",countStrategy:"fixed-denominator",denominator:100,layout:"waffle",labelPolicy:"text-plus-token"};return{recommendedEncoding:"fixed-denominator-icon-array",tokenEncoding:t,rationale:"Risk is often clearer as natural frequency: highlighted cases out of a fixed denominator.",warnings:Qe(t,{visibleTokens:100,maxRecommendedTokens:100}),alternatives:["labeled-percent","bar-with-risk-threshold"]}}if("memory"===t||"editorial-engagement"===t){const t={tokenType:e.concreteEntity?"glyph":"icon",icon:e.concreteEntity,tokenSemantics:"unitized-measure",countStrategy:"unitized",unitValue:1,layout:"grid",labelPolicy:"text-plus-token",unitMeaning:e.concreteEntity?`one token represents a unit of ${e.concreteEntity}`:"one token represents one unit"};return{recommendedEncoding:"semantic-isotype",tokenEncoding:t,rationale:"Semantic tokens are useful when the chart needs to make a topic concrete and memorable.",warnings:Qe(t),alternatives:["labeled-bar","hybrid-bar-token"]}}if("frequency-reasoning"===t||"public-explanation"===t||"support-decision"===t){const t={tokenType:e.concreteEntity?"icon":"dot",icon:e.concreteEntity,tokenSemantics:"distribution"===e.dataType?"possible-outcome":"unitized-measure",countStrategy:"distribution"===e.dataType?"quantile":"unitized",unitValue:"distribution"===e.dataType?void 0:1,tokenCount:n,layout:"distribution"===e.dataType?"dotplot":"bar-segment",labelPolicy:"text-plus-token",unitMeaning:"distribution"===e.dataType?void 0:"one token represents one unit interval"};return{recommendedEncoding:"hybrid-continuous-token",tokenEncoding:t,rationale:"A hybrid view preserves measurement while adding countable tokens for explanation and decisions.",warnings:Qe(t),alternatives:["bar-or-line","quantile-dotplot","fixed-denominator-icon-array"]}}return{recommendedEncoding:"bar-or-line",rationale:"Use continuous encodings unless the task needs frequency, risk, memory, or outcome reasoning.",warnings:[],alternatives:["unitized-measure","quantile-dotplot","fixed-denominator-icon-array"]}}function nt(e,t,n){if(n)return n;const o=e??"circle";if("chevron"===o)return it(t);const r=Object.prototype.hasOwnProperty.call(Su,o)?Su[o]:$u.symbolCircle;return(0,$u.symbol)(r,Math.max(1,t))()??""}function ot(e){return Math.sqrt(Math.max(1,e)/Math.PI)}function rt(e,t,n){if(!n&&"circle"===(e??"circle"))return ot(t);const o=n?`p:${n}`:`s:${e??"circle"}:${t}`,r=Au.get(o);if(null!=r)return r;const i=nt(e,t,n).match(/-?\d*\.?\d+(?:e-?\d+)?/gi);let s=0;if(i)for(let e=0;e+1<i.length;e+=2){const t=+i[e],n=+i[e+1],o=Math.sqrt(t*t+n*n);o>s&&(s=o)}return s>0?(Au.size>512&&Au.clear(),Au.set(o,s),s):ot(t)}function it(e){const t=1.5*ot(e),n=.92*t;return`M0,${-t}L${n},${(.78*t).toFixed(3)}L0,${(.28*t).toFixed(3)}L${-n},${(.78*t).toFixed(3)}Z`}function st(e){return"object"==typeof e&&null!==e&&"tokens"in e&&"encoding"in e}function at(e,t,n){return"function"==typeof e?e(t)??n:e??n}function ct(e,t){return"function"==typeof e?e(t):e}function lt(e){return e.sample??e.value??e.index}function ut(e,t,n){if(t.columns)return t.columns;if(t.width&&n>0){const e=t.gutter??2;return Math.max(1,Math.floor((t.width+e)/(n+e)))}return e.length>0?Math.ceil(Math.sqrt(e.length)):1}function dt(e,t){const n=t.positionToken;return n?e.map((t,o)=>{const r=n(t,o,e);return{...t,x:r.x,y:r.y,row:r.row??o,column:r.column??0}}):[]}function ht(e,t){if(0===e.length)return[];const n=t.x??0,o=t.y??0,r=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),i=t.gutter??2,s=Math.max(1,Math.floor(t.rows??1)),a=e.map(lt),c=Math.min(...a),l=Math.max(...a)-c||1;return e.map((a,u)=>{const d=lt(a),h=u%s,f=t.valueToX?t.valueToX(d,a):n+(d-c)/l*(t.width??12*Math.max(1,e.length-1)),m=t.valueToY?t.valueToY(d,a):o+h*(r+i);return{...a,x:f,y:m,row:h,column:u}})}function ft(e,t){if(0===e.length)return[];const n=t.x??0,o=t.y??0,r="number"==typeof t.tokenSize?t.tokenSize:12,i=t.gutter??2,s=t.cellWidth??r+i,a=t.cellHeight??r+i,c=e.map(lt),l=Math.min(...c),u=Math.max(...c)-l||1,d=/* @__PURE__ */new Map;return e.map(r=>{const i=lt(r),c=t.valueToX?t.valueToX(i,r):n+(i-l)/u*(t.width??Math.max(1,e.length-1)*s),h=Math.round((c-n)/Math.max(1,s)),f=d.get(h)??0;d.set(h,f+1);const m=t.valueToY?t.valueToY(i,r):o+f*a;return{...r,x:n+h*s,y:m,row:f,column:h}})}function mt(e,t){if(!t.valueToX)return[];const n=t.y??0,o=t.cellHeight??("number"==typeof t.tokenSize?t.tokenSize:12),r=t.anchor??[.5,.5];return e.map((e,i)=>{const s=Number.isFinite(e.start)?e.start:lt(e),a=(s+(Number.isFinite(e.end)?e.end:s+e.value))/2,c=t.valueToY?t.valueToY(a,e):n+r[1]*o;return{...e,x:t.valueToX(a,e),y:c,row:0,column:i}})}function pt(e,t){const n=t.includeRange&&e.rangeTokens?[...e.tokens,...e.rangeTokens]:e.tokens;if(t.positionToken)return dt(n,t);const o=t.layout??e.encoding.layout??"grid";if("quantile-strip"===o)return ht(n,t);if("dotplot"===o)return ft(n,t);if("bar-segment"===o){if(!t.valueToX)throw new Error('tokenLayer layout "bar-segment" requires valueToX and optionally valueToY.');return mt(n,t)}if("beeswarm"===o||"small-multiple"===o)throw new Error(`tokenLayer layout "${o}" is not implemented yet; use row, column, stack, grid, waffle, dotplot, quantile-strip, bar-segment with valueToX, or positionToken.`);const r="number"==typeof t.tokenSize?t.tokenSize:void 0,i=t.cellWidth??r??12,s=t.cellHeight??r??i,a="row"===o?Math.max(1,n.length):"column"===o||"stack"===o?1:"waffle"===o&&"fixed-denominator"===e.encoding.countStrategy&&100===e.denominator?10:ut(n,t,i);return Ze(n,{...t,columns:a,cellWidth:i,cellHeight:s})}function gt(e){if(e)return Tu[e]}function yt(e,t){return void 0!==t.datum?at(t.datum,e,null):e.datum??null}function xt(e,t){return{fill:!1!==e.highlighted?"scenario"===e.range?at(t.rangeColor,e,qu):at(t.color,e,Ru):at(t.inactiveColor,e,Wu),stroke:"none",...ct(t.style,e)??{}}}function bt(e,t){const n=ct(t.pointId,e)??(t.idPrefix?`${t.idPrefix}-${"scenario"===e.range?"range-":""}${e.index}`:void 0);return{datum:yt(e,t),accessibleDatum:ct(t.accessibleDatum,e),accessibility:ct(t.accessibility,e),pointId:n,_transitionKey:n}}function wt(e,t){const n=at(t.tokenSize,e,12);return{type:"point",x:e.x,y:e.y,r:at(t.radius,e,n/2),style:xt(e,t),...bt(e,t)}}function Mt(e,t){const n=at(t.tokenSize,e,12);return{type:"symbol",x:e.x,y:e.y,size:Math.PI*Math.max(1,n/2)**2,symbolType:at(t.symbolType,e,"circle"),path:ct(t.symbolPath,e),rotation:ct(t.rotation,e),style:xt(e,t),...bt(e,t)}}function vt(e,t,n){const o=xt(e,n),r=at(n.tokenSize,e,12);return{type:"glyph",x:e.x,y:e.y,size:r,glyph:t,color:String(o.fill??Ru),accent:at(n.accent,e,Du),fraction:e.fraction<1?e.fraction:void 0,fractionStart:e.startFraction>0?e.startFraction:void 0,fractionDirection:at(n.fractionDirection,e,"horizontal"),ghostColor:e.fraction<1?ct(n.ghostColor,e)??Wu:void 0,rotation:ct(n.rotation,e),style:o,...bt(e,n)}}function kt(e,t,n){if("dot"===n.tokenType)return wt(e,t);const o=ct(t.glyph,e)??gt(n.icon);if(o)return vt(e,o,t);const r=(i=n.icon)&&Bu.has(i)?i:void 0;var i;return Mt(e,r&&null==t.symbolType?{...t,symbolType:r}:t)}function $t({input:e,encoding:t,options:n={}}){if(!st(e)&&!t)throw new Error("tokenLayer requires an encoding when input is not a TokenSet.");const o=st(e)?{...e,encoding:Ge(e.encoding)}:Ke(e,t),r=pt(o,n).filter(e=>!n.include||n.include(e));return{tokenSet:o,positionedTokens:r,nodes:r.map(e=>kt(e,n,o.encoding))}}function St(e){return`${e.getUTCFullYear()}-${It(e.getUTCMonth()+1)}-${It(e.getUTCDate())}`}function It(e){return e<10?`0${e}`:String(e)}function At(e,t){return e<t?-1:e>t?1:0}function Ct(e,t){if("function"==typeof e)return e;const n=e??t;return e=>e[n]}function Nt(e,t,n){const o=(t+n.lat)/2*(Math.PI/180);return[111.32*(e-n.lon)*Math.cos(o),110.574*(t-n.lat)]}function jt(e){const t=Math.max(3,Math.round(e??5));return t%2==0?t+1:t}function Ft(e){return Hu.has(e)?e:"monument"}function Et(e,t){const n=jt(t.gridSize),o=Math.max(1,t.gridRadiusKm??75),r=2*o/n,i=Math.floor(n/2),s=Ct(t.idAccessor,"id"),a=Ct(t.nameAccessor,"name"),c=Ct(t.longitudeAccessor,"lon"),l=Ct(t.latitudeAccessor,"lat"),u=Ct(t.kindAccessor,"kind"),d=t.candidatePriorityAccessor?Ct(t.candidatePriorityAccessor,"priority"):()=>0,h=Array.from({length:n*n},(e,t)=>{const i=Math.floor(t/n),s=t%n;return{id:`tile-${i}-${s}`,row:i,column:s,centerXKm:(s+.5)*r-o,centerYKm:o-(i+.5)*r,terrainIndex:(17*i+31*s)%_u.length,landmark:null,landmarks:[]}}),f=[];for(const i of e){const e=Number(c(i)),m=Number(l(i));if(!Number.isFinite(e)||!Number.isFinite(m))continue;const p=String(s(i)??`${e},${m}`),g=String(a(i)??p),y=Ft(u(i)),[x,b]=Nt(e,m,t.center);if(Math.abs(x)>o||Math.abs(b)>o)continue;const w=Math.min(n-1,Math.floor((x+o)/r)),M=Math.min(n-1,Math.floor((o-b)/r)),v=h[M*n+w],k=Number(d(i)),$={...i,id:p,name:g,kind:y,lon:e,lat:m,distanceKm:Math.sqrt(x*x+b*b),row:M,column:w,cellDistanceSq:(x-v.centerXKm)**2+(b-v.centerYKm)**2,candidatePriority:Number.isFinite(k)?k:0};v.landmarks.push($),p===t.centerId&&f.push($)}const m=(e,t)=>At(e.name,t.name)||At(e.id,t.id)||e.lon-t.lon||e.lat-t.lat||At(e.kind,t.kind),p=(e,t)=>e.candidatePriority-t.candidatePriority||e.cellDistanceSq-t.cellDistanceSq||m(e,t),g=h[i*n+i],y=f.sort(p)[0]??[...g.landmarks].sort((e,t)=>e.candidatePriority-t.candidatePriority||Number("city"===t.kind)-Number("city"===e.kind)||e.distanceKm-t.distanceKm||m(e,t))[0],x=/* @__PURE__ */new Map;y&&x.set(y.kind,1);const b=e=>e.cellDistanceSq+(x.get(e.kind)??0)*r*r*.35,w=(e,t)=>e.candidatePriority-t.candidatePriority||b(e)-b(t)||m(e,t);for(const e of h){const t=e===g;if(e.landmarks=e.landmarks.filter(e=>e!==y).sort(t?p:w),t&&y&&e.landmarks.unshift(y),e.landmark=e.landmarks[0]??null,e.landmark&&e.landmark!==y){const t=e.landmark.kind;x.set(t,(x.get(t)??0)+1)}}return h}function Pt(){const e=(mu??(mu=Xu.createContext(null)),mu);return Xu.useContext(e)??Uu}function zt(e,t){if(null!=e&&"object"==typeof e&&Object.prototype.hasOwnProperty.call(e,t))return e[t]}function Lt(e,t){const n=zt(e,t);return"string"==typeof n&&n.length>0?n:void 0}function Ot(e){return ed.has(e)?e:void 0}function Tt(e,t){const n=zt(e,t),o=Ot("string"==typeof n?n:zt(n,"kind"));if(!o)return;if("string"==typeof n)return{kind:o};const r=zt(n,"coverage"),i="number"==typeof r&&Number.isFinite(r)?Math.max(0,Math.min(1,r)):void 0,s=Lt(n,"fill");return{kind:o,...null==i?{}:{coverage:i},...s?{fill:s}:{}}}function Rt({tiles:e,tileWidth:t,tileHeight:n,sprites:o,resourceSize:r,citySize:i,showCityLabel:s}){const a=Pt(),c=e.filter(e=>e.landmark).sort((e,t)=>e.y-t.y||e.x-t.x);/* @__PURE__ */ /* @__PURE__ */
|
|
3
|
+
return(0,Ku.jsxs)("g",{"aria-hidden":"true",pointerEvents:"none",children:[c.map(e=>{const s=e.landmark,c="city"===s.kind?i:r,l=e.y+n/2,u=a.isActive&&!a.predicate(s)?.28:1;/* @__PURE__ */ /* @__PURE__ */
|
|
4
|
+
return(0,Ku.jsxs)("g",{opacity:u,children:[
|
|
5
5
|
/* @__PURE__ */
|
|
6
|
-
/* @__PURE__ */(0,
|
|
6
|
+
/* @__PURE__ */(0,Ku.jsx)("ellipse",{cx:e.x,cy:e.y+.15*n,rx:.28*c,ry:.1*c,fill:"#17251d",opacity:.32}),
|
|
7
7
|
/* @__PURE__ */
|
|
8
|
-
/* @__PURE__ */(0,
|
|
9
|
-
return(0,
|
|
8
|
+
/* @__PURE__ */(0,Ku.jsx)(qt,{kind:s.kind,href:Lt(o,s.kind),x:e.x-c/2,y:l-c,size:c}),e.landmarks.length>1&&/* @__PURE__ */ /* @__PURE__ */(0,Ku.jsx)(Wt,{x:e.x+.3*t,y:e.y-.19*n,count:e.landmarks.length-1,tileHeight:n})]},e.id)}),s&&c.filter(e=>"city"===e.landmark?.kind).map(e=>{const t=e.landmark.name.toUpperCase(),o=Math.max(56,6.4*t.length+14);/* @__PURE__ */ /* @__PURE__ */
|
|
9
|
+
return(0,Ku.jsxs)("g",{transform:`translate(${e.x},${e.y+.72*n})`,children:[
|
|
10
10
|
/* @__PURE__ */
|
|
11
|
-
/* @__PURE__ */(0,
|
|
11
|
+
/* @__PURE__ */(0,Ku.jsx)("rect",{x:-o/2,y:-7,width:o,height:14,rx:1,fill:"#17251d",opacity:.92}),
|
|
12
12
|
/* @__PURE__ */
|
|
13
|
-
/* @__PURE__ */(0,
|
|
14
|
-
return(0,
|
|
13
|
+
/* @__PURE__ */(0,Ku.jsx)("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:9,fontWeight:700,letterSpacing:.8,children:t})]},`${e.landmark.id}-label`)})]})}function Wt({x:e,y:t,count:n,tileHeight:o}){const r=Math.max(10,Math.min(15,.34*o)),i=`+${n}`,s=Math.max(r,i.length*r*.58);/* @__PURE__ */ /* @__PURE__ */
|
|
14
|
+
return(0,Ku.jsxs)("g",{transform:`translate(${e},${t})`,children:[
|
|
15
15
|
/* @__PURE__ */
|
|
16
|
-
/* @__PURE__ */(0,
|
|
16
|
+
/* @__PURE__ */(0,Ku.jsx)("rect",{x:-s/2,y:-r/2,width:s,height:r,rx:1,fill:"#17251d",stroke:"#f0d36d",strokeWidth:1}),
|
|
17
17
|
/* @__PURE__ */
|
|
18
|
-
/* @__PURE__ */(0,
|
|
19
|
-
return(0,
|
|
20
|
-
return(0,
|
|
21
|
-
return(0,
|
|
22
|
-
return(0,ld.jsx)("text",{x:e.x,y:e.y,fill:t,fontFamily:o,fontSize:n,fontWeight:r,opacity:s?1:.18,textAnchor:"middle",dominantBaseline:"central",children:e.label},e.id)})})}function Qt(){throw new Error("geographicDotGrid requires the geo recipe bundle")}function Jt(){throw new Error("geographicDotGrid requires the geo recipe bundle")}function en(e){if(Number.isFinite(e)&&!(Number(e)<=0))return Number(e)}function tn(e,t){return"function"==typeof t?t(e,e.dotIndex):"string"==typeof t?e[t]:void 0}function nn(e){return e.properties&&"object"==typeof e.properties?{...e.properties}:{}}function on(e,t){const n=nn(e);return String(e.id??n.id??n.name??`feature-${t}`)}function rn(e,t){if(0===e.length)return null;const n={type:"FeatureCollection",features:e},o=t.bounds(n);return Number.isFinite(o[0][0])&&Number.isFinite(o[0][1])&&Number.isFinite(o[1][0])&&Number.isFinite(o[1][1])?o:null}function sn(e,t,n,o){return[Math.ceil((e-n)/o-.5),Math.floor((t-n)/o-.5)]}function an(e){if(!e)return 0;const t=xd.get(e);if(t)return t;const n=bd;return bd+=1,xd.set(e,n),n}function cn(e){return e.map((e,t)=>{if(yd.has(e))return{feature:e,index:t,bounds:yd.get(e)??null};try{const n=Qt();return yd.set(e,n),{feature:e,index:t,bounds:n}}catch{return yd.set(e,null),{feature:e,index:t,bounds:null}}})}function ln(e,t){return!t||e[1]>=t[0][1]&&e[1]<=t[1][1]&&(n=e[0],(o=t[0][0])<=(r=t[1][0])?n>=o&&n<=r:n>=o||n<=r);var n,o,r}function un(e,t){for(const n of e){const{feature:e,index:o}=n;if(e.geometry&&ln(t,n.bounds))try{if(Jt())return{feature:e,index:o}}catch{}}return null}function dn(e,t,n,o={}){const r=e.filter((e,t)=>e.geometry&&(!o.featureFilter||o.featureFilter(e,t))),i=rn(r,t.geoPath);if(!i)return{dots:[],cellSize:md,features:r};const s=Math.max(0,o.layoutPadding??0),a=[[me(i[0][0],s,Math.max(s,n.width-s)),me(i[0][1],s,Math.max(s,n.height-s))],[me(i[1][0],s,Math.max(s,n.width-s)),me(i[1][1],s,Math.max(s,n.height-s))]],c=Math.max(0,a[1][0]-a[0][0]),l=Math.max(0,a[1][1]-a[0][1]);if(0===c||0===l)return{dots:[],cellSize:md,features:r};const u=en(o.columns);let d=Math.max(2,u?c/u:en(o.cellSize)??md);const h=Math.max(100,Math.round(en(o.maxSamples)??pd)),f=Math.ceil(c/d)*Math.ceil(l/d);f>h&&(d*=Math.sqrt(f/h));const m=o.gridOrigin?.[0]??0,p=o.gridOrigin?.[1]??0,[g,y]=sn(a[0][0],a[1][0],m,d),[x,b]=sn(a[0][1],a[1][1],p,d),w=[],M=cn(r);for(let e=x;e<=b;e+=1){const n=p+(e+.5)*d;for(let r=g;r<=y;r+=1){const i=m+(r+.5)*d,s=t.invertedPoint(i,n);if(!s||!Number.isFinite(s[0])||!Number.isFinite(s[1]))continue;const a=un(M,s);if(!a)continue;const c={...nn(a.feature),featureId:on(a.feature,a.index),featureIndex:a.index,gridRow:e,gridColumn:r,longitude:s[0],latitude:s[1],dotIndex:w.length};o.dotFilter&&!o.dotFilter(c,w.length)||w.push(c)}}return{dots:w,cellSize:d,features:r}}function hn(e){return Math.round(1e4*e)/1e4}function fn(e){return Array.isArray(e)&&e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1])?`${hn(Number(e[0]))},${hn(Number(e[1]))}`:"null"}function mn(e,t){const n=e[t];return"function"==typeof n?n.call(e):void 0}function pn(e){return"number"==typeof e&&Number.isFinite(e)?String(hn(e)):null===e?"null":"unavailable"}function gn(e){const t=e.scales.projection;return[pn(mn(t,"scale")),fn(mn(t,"translate")),fn(mn(t,"center")),(n=mn(t,"rotate"),Array.isArray(n)&&n.every(Number.isFinite)?n.map(e=>hn(Number(e))).join(","):"unavailable"),pn(mn(t,"clipAngle")),pn(mn(t,"precision")),...[[0,0],[-120,35],[45,45],[120,-30]].map(([t,n])=>fn(e.scales.projectedPoint(t,n)))].join("|");var n}function yn(e){const t=e.config;return[e.areas.length,e.dimensions.width,e.dimensions.height,t.cellSize??"",t.columns??"",t.layoutPadding??"",t.gridOrigin?.join(",")??"",t.maxSamples??"",an(t.featureFilter),an(t.dotFilter),gn(e)].join("::")}function xn(e){let t=gd.get(e.areas);t||(t=/* @__PURE__ */new Map,gd.set(e.areas,t));const n=yn(e),o=t.get(n);if(o)return o;const r=dn(e.areas,e.scales,e.dimensions,e.config);if(t.size>=12){const e=t.keys().next().value;void 0!==e&&t.delete(e)}return t.set(n,r),r}function bn(e){return`${e.map(([e,t],n)=>`${0===n?"M":"L"}${e},${t}`).join("")}Z`}function wn(e,t,n){return bn([[e-n,t-n],[e+n,t-n],[e+n,t+n],[e-n,t+n]])}function Mn(e,t,n){return bn(Array.from({length:6},(o,r)=>{const i=-Math.PI/2+r*(Math.PI/3);return[e+Math.cos(i)*n,t+Math.sin(i)*n]}))}function vn(e,t,n){const o=e.data??e,r=o.x??e.x,i=o.y??e.y,s=e.createdByFrame&&0===e.width?void 0:e.width,a=e.createdByFrame&&0===e.height?void 0:e.height,c=o.width??s??t,l=o.height??a??n;if(!("number"!=typeof r||"number"!=typeof i||"number"!=typeof c||"number"!=typeof l||![r,i,c,l].every(Number.isFinite)||c<=0||l<=0))return{x:r,y:i,w:c,h:l}}function kn(e,t,n){const{nodeWidth:o,nodeHeight:r,waypoints:i=[]}=n,s="none"===n.fit?"none":"contain";let a=1/0,c=1/0,l=-1/0,u=-1/0;const d=(e,t)=>{a=Math.min(a,e),c=Math.min(c,t),l=Math.max(l,e),u=Math.max(u,t)};let h=!1;for(const t of e){const e=vn(t,o,r);e&&(h=!0,d(e.x-e.w/2,e.y-e.h/2),d(e.x+e.w/2,e.y+e.h/2))}for(const e of i)d(e.x,e.y);let f=1,m=0,p=0;if("contain"===s&&h){const e=l-a,n=u-c;if(![e,n,t.x,t.y,t.width,t.height].every(Number.isFinite)||e<=0||n<=0||t.width<=0||t.height<=0)h=!1;else{const o=Math.min(1,t.width/4,t.height/4);f=Math.min(1,(t.width-2*o)/e,(t.height-2*o)/n),m=t.x+(t.width-e*f)/2-a*f,p=t.y+(t.height-n*f)/2-c*f}}const g=({x:e,y:t})=>({x:e*f+m,y:t*f+p});return{fit:s,scale:f,dx:m,dy:p,bounds:h?{x:a,y:c,width:l-a,height:u-c}:null,project:g,invert:({x:e,y:t})=>({x:(e-m)/f,y:(t-p)/f}),nodeBounds:e=>{const t=h?vn(e,o,r):void 0;if(!t)return;const{x:n,y:i}=g(t),s=t.w*f,a=t.h*f;return{x:n-s/2,y:i-a/2,width:s,height:a,cx:n,cy:i}}}}function $n(e,t,n,o=[]){const r=kn(e.nodes,e.dimensions.plot,{nodeWidth:t.nodeWidth,nodeHeight:t.nodeHeight,fit:t.fit,waypoints:o}),i=/* @__PURE__ */new Map,s=[],a=[];for(const o of e.nodes){const c=r.nodeBounds(o);if(!c)continue;const{cx:l,cy:u,width:d,height:h}=c;i.set(o.id,{x:l,y:u,w:d,h:h});const f=o.data??o,m=t.labelAccessor??"id",p=String("function"==typeof m?m(f):f[m]??o.id);s.push({type:"rect",x:c.x,y:c.y,w:d,h:h,style:{fill:t.nodeFill??e.resolveColor(o.id),stroke:n,strokeWidth:Math.min(1.5,d/2,h/2)},datum:f,id:o.id,label:p}),!1!==t.showLabels&&a.push({x:l,y:u,text:p,anchor:"middle",baseline:"middle",fontSize:11*r.scale})}return{positions:i,sceneNodes:s,labels:a,project:r.project}}function Sn(e,t,n={}){return kn(e,t,{nodeWidth:n.nodeWidth??80,nodeHeight:n.nodeHeight??30,fit:n.fit})}function In(e,t){const n=t.x-e.x,o=t.y-e.y,r=Math.min(0===n?1/0:e.w/2/Math.abs(n),0===o?1/0:e.h/2/Math.abs(o));return Number.isFinite(r)?{x:e.x+n*r,y:e.y+o*r}:{x:e.x,y:e.y}}function An(e,t,n,o,r,i=1){const s=t.x-n.x,a=t.y-n.y,c=Math.hypot(s,a);if(0===c||r<=0)return null;const l=Math.min(r,c)/c,u=s*l,d=a*l;return(0,kd.createElement)("polygon",{key:e,className:"recipe-edge-arrow",points:`${t.x},${t.y} ${t.x-u-d/2},${t.y-d+u/2} ${t.x-u+d/2},${t.y-d-u/2}`,fill:o,opacity:i,"aria-hidden":!0,style:{pointerEvents:"none"}})}function Cn(){const e=globalThis;return e[Id]??(e[Id]=$d.createContext(Sd))}function Nn(){return $d.useContext(Cn())}function jn(e,t){return"top"===t?e.thickness??0:Number.isFinite(t)?t:0}function Fn(e){const[t,n,o,r,i,s]=e.matrix;return 1===t&&0===n&&0===o&&1===r&&0===i&&0===s}function En({z:e=0,children:t}){const n=Nn();if(Fn(n))/* @__PURE__ */ /* @__PURE__ */return(0,Ad.jsx)(Ad.Fragment,{children:t});const[o,r,i,s,a,c]=n.matrix,l=c-n.lift*jn(n,e);/* @__PURE__ */ /* @__PURE__ */
|
|
23
|
-
return(0,Ad.jsx)("g",{"
|
|
24
|
-
return(0,Ad.
|
|
25
|
-
return(0,Ad.jsx)("g",{"data-perspective":"on-ground",transform:`translate(${Cd(s)},${Cd(a)}) matrix(${f} 0 0) translate(${Cd(-e)},${Cd(-t)})`,children:r})}function zn(e){const t=e.data??e,n=Array.isArray(t.points)?t.points:e.points;return Array.isArray(n)&&n.length>=2&&n.every(e=>e&&Number.isFinite(e.x)&&Number.isFinite(e.y))?n:[]}function Ln(e,t,n,o={}){return kn(e,n,{nodeWidth:o.nodeWidth??100,nodeHeight:o.nodeHeight??36,fit:o.fit,waypoints:t.flatMap(zn)})}function On(e,t){const n="function"==typeof t?t(e):e[t];return Fd(n)?n:void 0}function Tn(e){return[...e].sort((e,t)=>e.localeCompare(t))}function Rn(e,t){const n=new Map(e.map(e=>[e,/* @__PURE__ */new Set]));for(const e of t)n.has(e.source)&&n.has(e.target)&&(n.get(e.source)?.add(e.target),n.get(e.target)?.add(e.source));return n}function Wn(e){const t=new Set(e.keys()),n=[];for(const o of Tn(t)){if(!t.has(o))continue;const r=[o],i=[];t.delete(o);for(let n=0;n<r.length;n++){const o=r[n];i.push(o);for(const n of Tn(e.get(o)??[]))t.has(n)&&(t.delete(n),r.push(n))}n.push(i.sort((e,t)=>e.localeCompare(t)))}return n.sort((e,t)=>t.length-e.length||e[0].localeCompare(t[0]))}function qn(e,t,n){const o=/* @__PURE__ */new Map([[e,0]]),r=[e];for(let e=0;e<r.length;e++){const i=r[e],s=o.get(i);for(const e of Tn(n.get(i)??[]))t.has(e)&&!o.has(e)&&(o.set(e,s+1),r.push(e))}return o}function Dn(e,t,n){const o=qn(e,t,n);let r=e,i=-1;for(const[e,t]of o)(t>i||t===i&&e.localeCompare(r)<0)&&(r=e,i=t);return r}function Bn(e,t,n){const o=new Set(e),r=e.filter(e=>(t.get(e)?.size??0)<=1)[0]??e[0],i=qn(n&&o.has(n)?n:Dn(Dn(r,o,t),o,t),o,t);let s=0;for(const e of i.values())s=Math.max(s,e);const a=Array.from({length:s+1},()=>[]);for(const t of e)a[i.get(t)??0].push(t);a.forEach(e=>e.sort((e,t)=>e.localeCompare(t)));const c=(e,n)=>{const o=new Map(a[n].map((e,t)=>[e,t])),r=e=>{const n=[...t.get(e)??[]].map(e=>o.get(e)).filter(e=>null!=e);return 0===n.length?Number.POSITIVE_INFINITY:n.reduce((e,t)=>e+t,0)/n.length},i=new Map(a[e].map(e=>[e,r(e)]));a[e].sort((e,t)=>i.get(e)-i.get(t)||e.localeCompare(t))};for(let e=0;e<4;e+=1){for(let e=1;e<a.length;e+=1)c(e,e-1);for(let e=a.length-2;e>=0;e-=1)c(e,e+1)}return a}function Yn(e,t,n,o,r,i){const s=Rn(e.map(e=>e.id),t),a=Wn(s),c=new Map(e.map(e=>[e.id,e.data])),l=/* @__PURE__ */new Map,u=Math.max(0,n.width),d=Math.max(0,n.height),h=Math.min(o,u/2),f=Math.min(o,d/2),m=Math.max(0,d-2*f),p=a.length>1?Math.min(r,m/a.length):0,g=Math.max(0,m-p*Math.max(0,a.length-1)),y=a.reduce((e,t)=>e+Math.sqrt(t.length),0);let x=f;for(const e of a){const t=g*(Math.sqrt(e.length)/y),n=Bn(e,s,i),o=Math.max(0,u-2*h);n.forEach((e,r)=>{const i=1===n.length?u/2:h+r/(n.length-1)*o;e.forEach((n,o)=>{const r=1===e.length?x+t/2:x+o/(e.length-1)*t;l.set(n,{id:n,x:i,y:r,data:c.get(n)})})}),x+=t+p}return l}function Vn(e,t,n,o={}){const r=Math.max(0,o.padding??36),i=Math.max(0,o.componentGap??26),s=o.xAccessor??"x",a=o.yAccessor??"y",c=e.map(e=>({...e,authoredX:On(e.data,s),authoredY:On(e.data,a)})),l=c.length>0&&c.every(e=>Fd(e.authoredX)&&Fd(e.authoredY)),u="authored"===o.layoutMode||"automatic"!==o.layoutMode&&l,d=[];if(u&&!l&&d.push("Authored transit layout requested, but at least one station has no finite x/y position; using automatic topology layout."),!u||!l){l||"automatic"===o.layoutMode||d.push("Complete station positions were not supplied; using the deterministic automatic topology layout.");const s=Yn(e,t,n,r,i,o.rootId);if("right-to-left"===o.direction)for(const e of s.values())e.x=n.width-e.x;return{positions:s,mode:"automatic",warnings:d,projectAuthoredPoint:e=>e}}let h=1/0,f=-1/0,m=1/0,p=-1/0;for(const e of c)h=Math.min(h,e.authoredX),f=Math.max(f,e.authoredX),m=Math.min(m,e.authoredY),p=Math.max(p,e.authoredY);const g=Math.max(1,n.width-2*r),y=Math.max(1,n.height-2*r),x=e=>({x:f===h?n.width/2:r+(e.x-h)/(f-h)*g,y:p===m?n.height/2:r+(e.y-m)/(p-m)*y}),b=/* @__PURE__ */new Map;for(const e of c){const t=x({x:e.authoredX,y:e.authoredY});b.set(e.id,{id:e.id,...t,data:e.data})}return{positions:b,mode:"authored",warnings:d,projectAuthoredPoint:x}}function Gn(e,t){const n=t.x-e.x,o=t.y-e.y,r=Math.abs(n),i=Math.abs(o);if(r<.001||i<.001||Math.abs(r-i)<.001)return[e,t];const s=Math.sign(n),a=Math.sign(o);if(r>i){const n=(r-i)/2;return[e,{x:e.x+s*n,y:e.y},{x:t.x-s*n,y:t.y},t]}const c=(i-r)/2;return[e,{x:e.x,y:e.y+a*c},{x:t.x,y:t.y-a*c},t]}function _n(e,t){if(0===t||e.length<2)return e.map(e=>({...e}));const n=(e,t)=>{const n=t.x-e.x,o=t.y-e.y,r=Math.hypot(n,o)||1;return{x:-o/r,y:n/r}};return e.map((o,r)=>{const i=r>0?n(e[r-1],o):null,s=r<e.length-1?n(o,e[r+1]):null;if(!i||!s){const e=s??i??{x:0,y:0};return{x:o.x+e.x*t,y:o.y+e.y*t}}let a=i.x+s.x,c=i.y+s.y;const l=Math.hypot(a,c);if(l<.001)return{x:o.x+s.x*t,y:o.y+s.y*t};a/=l,c/=l;const u=a*s.x+c*s.y;if(Math.abs(u)<.001)return{x:o.x+s.x*t,y:o.y+s.y*t};const d=4*Math.abs(t),h=t/u,f=Math.max(-d,Math.min(d,h));return{x:o.x+a*f,y:o.y+c*f}})}function Hn(e,t){if(0===e.length)return"";if(1===e.length)return`M${e[0].x},${e[0].y}`;const n=Math.max(0,t);let o=`M${e[0].x},${e[0].y}`;for(let t=1;t<e.length-1;t+=1){const r=e[t-1],i=e[t],s=e[t+1],a=Math.hypot(i.x-r.x,i.y-r.y),c=Math.hypot(s.x-i.x,s.y-i.y),l=Math.min(n,a/2,c/2);if(l<=.001){o+=` L${i.x},${i.y}`;continue}const u={x:i.x+(r.x-i.x)/a*l,y:i.y+(r.y-i.y)/a*l},d={x:i.x+(s.x-i.x)/c*l,y:i.y+(s.y-i.y)/c*l};o+=` L${u.x},${u.y} Q${i.x},${i.y} ${d.x},${d.y}`}const r=e[e.length-1];return`${o} L${r.x},${r.y}`}function Xn(e,t){return"function"==typeof t.labelAccessor?t.labelAccessor(e.data):ge(e.data,t.labelAccessor??"label",e.id)}function Un(e){return"string"==typeof e?e:e.id}function Kn(e){const t=(Array.isArray(e)?e:null==e?[]:[e]).map(e=>"object"==typeof e?{...e,id:String(e.id)}:{id:String(e)});return t.length>0?t:[{id:"network"}]}function Zn(e,t){const n=t.lineAccessor;let o;return o="function"==typeof n?n(e.data):"string"==typeof n?e.data[n]:e.data.lines??e.data.line??e.data.route??e.data.group,Kn(o)}function Qn(e,t,n){const o=t.sourceColorAccessor,r="function"==typeof o?o(e.data):"string"==typeof o?e.data[o]:e.data.color;return"string"==typeof r&&r?r:n(e.id)}function Jn(e,t,n,o){const r=new Set(e.map(e=>e.id)),i=new Map(e.map(e=>[e.id,0])),s=new Map(e.map(e=>[e.id,[]]));for(const e of t)r.has(e.source)&&r.has(e.target)&&(i.set(e.target,(i.get(e.target)??0)+1),s.get(e.source)?.push(e));const a=e.filter(e=>0===(i.get(e.id)??0)),c=/* @__PURE__ */new Map,l=new Map(e.map(e=>[e.id,/* @__PURE__ */new Map]));for(const e of a){const t={id:e.id,label:String(Xn(e,n)),color:Qn(e,n,o)},r=/* @__PURE__ */new Set,i=[e.id];for(;i.length>0;){const e=i.shift();if(!r.has(e)){r.add(e),l.get(e)?.set(t.id,t);for(const n of s.get(e)??[]){let e=c.get(n);e||(e=/* @__PURE__ */new Map,c.set(n,e)),e.set(t.id,t),r.has(n.target)||i.push(n.target)}}}}const u=e=>[...e].sort((e,t)=>e.id.localeCompare(t.id));return{byEdge:new Map(t.map(e=>[e,u(c.get(e)?.values()??[])])),byNode:new Map(e.map(e=>[e.id,u(l.get(e.id)?.values()??[])]))}}function eo(e,t,n,o){if(e.color)return e.color;const r=n.lineColors&&Object.prototype.hasOwnProperty.call(n.lineColors,e.id)?n.lineColors[e.id]:void 0;if("string"==typeof r&&r)return r;const i=n.lineColorAccessor,s="function"==typeof i?i(t.data):"string"==typeof i?t.data[i]:t.data.color;return"string"==typeof s?s:o(e.id)}function to(e,t,n){const o=/* @__PURE__ */new Map;for(const r of e){const e=r.source<r.target?`${r.source}\0${r.target}`:`${r.target}\0${r.source}`;let i=o.get(e);i||(i={key:e,source:r.source,target:r.target,lines:/* @__PURE__ */new Map},o.set(e,i));const s=r.data.lineOrder;Array.isArray(s)&&(i.authoredOrder=s.map(String));const a=n?.byEdge.get(r)??Zn(r,t);for(const e of a)i.lines.has(e.id)||i.lines.set(e.id,{descriptor:e,edge:r})}return[...o.values()].sort((e,t)=>e.key.localeCompare(t.key))}function no(e,t){const n=new Map((t.lineOrder??[]).map((e,t)=>[e,t]));return[...e].sort((e,t)=>(n.get(e)??Number.POSITIVE_INFINITY)-(n.get(t)??Number.POSITIVE_INFINITY)||e.localeCompare(t))}function oo(e,t){const n=e.authoredOrder??t.lineOrder??[],o=new Map(n.map((e,t)=>[e,t]));return[...e.lines.values()].sort((e,t)=>(o.get(e.descriptor.id)??Number.POSITIVE_INFINITY)-(o.get(t.descriptor.id)??Number.POSITIVE_INFINITY)||e.descriptor.id.localeCompare(t.descriptor.id))}function ro(e,t,n,o){if("authored"!==t.mode)return null;const r=e.data[n.pointsAccessor??"points"];if(!Array.isArray(r))return null;const i=r.map(e=>{const n=e;return"number"==typeof n.x&&"number"==typeof n.y?t.projectAuthoredPoint({x:n.x,y:n.y}):null}).filter(e=>null!=e);return 0===i.length?null:o?i.reverse():i}function io(e,t){return be(n=>{for(const[t,o]of Object.entries(e.data))n(t,o);n("source",e.source),n("target",e.target),n("lineId",t.id),n("lineLabel",t.label??t.id)})}function so(e,t,n,o,r,i){if(!1===i.showLabels)return[];const s=i.labelFontSize??11,a=[],c=[],l=[...e].sort((e,t)=>(n.get(t.id)?.size??0)-(n.get(e.id)?.size??0)||e.id.localeCompare(t.id));for(const e of l){const n=t.get(e.id);if(!n)continue;const l=("function"==typeof i.labelAccessor?i.labelAccessor(e.data):String(ge(e.data,i.labelAccessor??"label",e.id)))||e.id,u=Math.max(2*s,l.length*s*.58),d=1.25*s,h=Math.max(i.interchangeRadius??7,o.get(e.id)??i.stationRadius??4)+5,f=[{x:n.x+h,y:n.y,anchor:"start",left:n.x+h},{x:n.x-h,y:n.y,anchor:"end",left:n.x-h-u},{x:n.x,y:n.y-h,anchor:"middle",left:n.x-u/2},{x:n.x,y:n.y+h,anchor:"middle",left:n.x-u/2}].map((e,t)=>{const n={left:e.left,right:e.left+u,top:e.y-d/2,bottom:e.y+d/2},o=a.filter(e=>{return o=e,(t=n).left<o.right&&t.right>o.left&&t.top<o.bottom&&t.bottom>o.top;var t,o}).length,i=Math.max(0,-n.left)+Math.max(0,n.right-r.width)+Math.max(0,-n.top)+Math.max(0,n.bottom-r.height);return{candidate:e,box:n,score:1e4*o+10*i+t}}).sort((e,t)=>e.score-t.score)[0];a.push(f.box),c.push({x:f.candidate.x,y:f.candidate.y,anchorPoint:[n.x,n.y],text:l,anchor:f.candidate.anchor,baseline:"middle",fontSize:s,fill:i.labelColor??"var(--semiotic-text, #222)",stroke:"var(--semiotic-bg, white)",strokeWidth:3,paintOrder:"stroke"})}return c}function ao(e,t,n={}){const o=n.layerAccessor??"x",r=n.rowAccessor??"y";let i=1/0,s=-1/0,a=1/0,c=-1/0;for(const t of e){const e=Number(ge(t,o,0)),n=Number(ge(t,r,0));Number.isFinite(e)&&Number.isFinite(n)&&(i=Math.min(i,e),s=Math.max(s,e),a=Math.min(a,n),c=Math.max(c,n))}if(i===1/0&&(i=s=a=c=0),Number.isFinite(n.layerCount)&&n.layerCount>0&&(i=Math.min(i,0),s=Math.max(s,n.layerCount-1)),Number.isFinite(n.maxLayerSize)&&n.maxLayerSize>0){const e=Math.max(0,n.maxLayerSize-1)/2;a=Math.min(a,-e),c=Math.max(c,e)}const l=s-i,u=Math.max(1,c-a),d=(a+c-u)/2,h=l+1,f=c-a+1,m=t.width/Math.max(1,h),p=t.height/Math.max(1,f);let g=Math.min(n.nodeWidth??172,Math.max(8,m-(n.minGapX??26))),y=Math.min(n.nodeHeight??54,Math.max(8,p-(n.minGapY??18)));const x=n.lod&&"auto"!==n.lod?n.lod:g<16?"dot":g<48?"icon":g<108?"compact":"full";if("dot"===x){const e=Math.min(g,y,11);g=e,y=e}const b=Math.max(1,t.width-g),w=Math.max(1,t.height-y),{x:M,y:v}=t,k=(e,t)=>({x:M+g/2+(l>0?(e-i)/l:.5)*b,y:v+y/2+(t-d)/u*w});return{layerCount:h,maxLayerSize:f,nodeWidth:g,nodeHeight:y,lod:x,project:k,invert:(e,t)=>({layer:l>0?i+(e-M-g/2)/b*l:null,row:(t-v-y/2)/w*u+d}),nodeBounds:e=>{const t=k(Number(ge(e,o,0)),Number(ge(e,r,0)));return{x:t.x-g/2,y:t.y-y/2,width:g,height:y,cx:t.x,cy:t.y}}}}function co(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function lo(e){const t=e.slice().sort((e,t)=>e.x-t.x||e.y-t.y).filter((e,t,n)=>0===t||e.x!==n[t-1].x||e.y!==n[t-1].y);if(t.length<=2)return t;const n=[];for(const e of t){for(;n.length>=2&&co(n[n.length-2],n[n.length-1],e)<=0;)n.pop();n.push(e)}const o=[];for(let e=t.length-1;e>=0;e--){const n=t[e];for(;o.length>=2&&co(o[o.length-2],o[o.length-1],n)<=0;)o.pop();o.push(n)}return n.pop(),o.pop(),n.concat(o)}function uo(e,t){if(0===t||e.length<3)return e;const n=e.reduce((t,n,o)=>{const r=e[(o+1)%e.length];return t+n.x*r.y-r.x*n.y},0)>=0?1:-1;return e.map((o,r)=>{const i=e[(r-1+e.length)%e.length],s=e[(r+1)%e.length],a=Math.hypot(o.x-i.x,o.y-i.y)||1,c=Math.hypot(s.x-o.x,s.y-o.y)||1,l=n>0?{x:(o.y-i.y)/a,y:-(o.x-i.x)/a}:{x:-(o.y-i.y)/a,y:(o.x-i.x)/a},u=n>0?{x:(s.y-o.y)/c,y:-(s.x-o.x)/c}:{x:-(s.y-o.y)/c,y:(s.x-o.x)/c},d={x:l.x+u.x,y:l.y+u.y},h=Math.hypot(d.x,d.y);if(h<1e-9)return{x:o.x+u.x*t,y:o.y+u.y*t};const f=d.x/h,m=d.y/h,p=Math.max(1e-6,f*u.x+m*u.y),g=t/p;return{x:o.x+f*g,y:o.y+m*g}})}function ho(e){return String(Math.abs(e)<1e-12?0:e)}function fo(e,t){if(0===e.length)return"";if(e.length<3||0===t)return`${e.map((e,t)=>`${0===t?"M":"L"}${ho(e.x)},${ho(e.y)}`).join(" ")} Z`;const n=e.map((n,o)=>{const r=e[(o-1+e.length)%e.length],i=e[(o+1)%e.length],s=Math.hypot(r.x-n.x,r.y-n.y)||1,a=Math.hypot(i.x-n.x,i.y-n.y)||1,c=Math.min(t,s/2,a/2);return{point:n,incoming:{x:n.x+(r.x-n.x)/s*c,y:n.y+(r.y-n.y)/s*c},outgoing:{x:n.x+(i.x-n.x)/a*c,y:n.y+(i.y-n.y)/a*c}}}),o=n[0].outgoing;let r=`M${ho(o.x)},${ho(o.y)}`;for(let e=1;e<n.length;e++){const t=n[e];r+=` L${ho(t.incoming.x)},${ho(t.incoming.y)}`,r+=` Q${ho(t.point.x)},${ho(t.point.y)} ${ho(t.outgoing.x)},${ho(t.outgoing.y)}`}const i=n[0];return r+=` L${ho(i.incoming.x)},${ho(i.incoming.y)}`,r+=` Q${ho(i.point.x)},${ho(i.point.y)} ${ho(i.outgoing.x)},${ho(i.outgoing.y)} Z`,r}function mo(e,t){const n=[];for(const[o,r]of e){const e=uo(lo(r.flatMap(e=>[{x:e.x,y:e.y},{x:e.x+e.w,y:e.y},{x:e.x+e.w,y:e.y+e.h},{x:e.x,y:e.y+e.h}])),t.padding);if(!e.length)continue;const i=e.map(e=>e.x),s=e.map(e=>e.y),a=Math.min(...i),c=Math.min(...s);n.push({x:a,y:c,width:Math.max(...i)-a,height:Math.max(...s)-c});const l=t.label?.(o);l&&n.push({x:a+8,y:c+14,z:0,extent:[0,6.6*l.length,12,3]})}return n}function po(e,t){const n=Array.from(e.entries()).sort(([e],[t])=>e<t?-1:e>t?1:0);/* @__PURE__ */ /* @__PURE__ */
|
|
26
|
-
return(0,Pd.jsx)("g",{className:"lineage-dag-hulls","aria-hidden":"true",style:{pointerEvents:"none"},children:n.map(([e,n])=>{const o=uo(lo(n.flatMap(e=>[{x:e.x,y:e.y},{x:e.x+e.w,y:e.y},{x:e.x+e.w,y:e.y+e.h},{x:e.x,y:e.y+e.h}])),t.padding),r=fo(o,t.radius),i=Object.prototype.hasOwnProperty.call(t.colors??{},e)?t.colors?.[e]??t.resolveColor(e):t.resolveColor(e),s=n.every(e=>!0===t.dimById.get(e.id)&&e.id!==t.selectedId),a=Math.min(...o.map(e=>e.x)),c=Math.min(...o.map(e=>e.y)),l=t.label?.(e);/* @__PURE__ */ /* @__PURE__ */
|
|
27
|
-
return(0,Pd.jsxs)("g",{"data-lineage-hull":e,opacity:s?t.dimOpacity:void 0,children:[
|
|
18
|
+
/* @__PURE__ */(0,Ku.jsx)("text",{textAnchor:"middle",dominantBaseline:"central",fill:"#f5edcf",fontFamily:"monospace",fontSize:Math.max(7,.62*r),fontWeight:700,children:i})]})}function qt({kind:e,href:t,x:n,y:o,size:r}){if(t)/* @__PURE__ */ /* @__PURE__ */
|
|
19
|
+
return(0,Ku.jsx)("image",{href:t,x:n,y:o,width:r,height:r,preserveAspectRatio:"xMidYMax meet",style:{imageRendering:"pixelated"}});const i=nd[e],s=od[e];/* @__PURE__ */ /* @__PURE__ */
|
|
20
|
+
return(0,Ku.jsx)("svg",{x:n,y:o,width:r,height:r,viewBox:"0 0 8 8",shapeRendering:"crispEdges",children:i.flatMap((e,t)=>[...e].map((e,n)=>"."===e?null:/* @__PURE__ */ /* @__PURE__ */(0,Ku.jsx)("rect",{x:n,y:t,width:1,height:1,fill:s[e]},`${t}-${n}`)))})}function Dt(e){if(Number.isFinite(e))return Math.max(1,Math.round(e))}function Bt(e){let t=1/0,n=-1/0;for(const o of e)Number.isFinite(o)&&(o<t&&(t=o),o>n&&(n=o));return t===1/0?[0,0]:[t,n]}function Yt(e,t){const n=t[1]-t[0];return 0===n?.5:(e-t[0])/n}function Vt(e,t={}){const n=e.map((e,t)=>({...e,index:t})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));if(0===n.length)return[];const o=me(Number.isFinite(t.occupancy)?Number(t.occupancy):id,.2,1),r=Number.isFinite(t.aspectRatio)&&Number(t.aspectRatio)>0?Number(t.aspectRatio):sd;let i=Dt(t.columns)??Math.max(1,Math.ceil(Math.sqrt(n.length*r/o))),s=Dt(t.rows)??Math.max(1,Math.ceil(n.length/(i*o)));i*s<n.length&&(null!=t.columns&&null==t.rows?s=Math.ceil(n.length/i):null!=t.rows&&null==t.columns?i=Math.ceil(n.length/s):s=Math.ceil(n.length/i));const a=Bt(n.map(e=>e.x)),c=Bt(n.map(e=>e.y)),l=n.map(e=>({...e,desiredColumn:Yt(e.x,a)*Math.max(0,i-1),desiredRow:Yt(e.y,c)*Math.max(0,s-1)})),u=(i-1)/2,d=(s-1)/2;l.sort((e,t)=>{const n=(e.desiredColumn-u)**2+(e.desiredRow-d)**2;return(t.desiredColumn-u)**2+(t.desiredRow-d)**2-n||e.desiredRow-t.desiredRow||e.desiredColumn-t.desiredColumn||e.index-t.index});const h=/* @__PURE__ */new Set;for(let e=0;e<s;e+=1)for(let t=0;t<i;t+=1)h.add(e*i+t);const f=[];for(const e of l){let t=-1,n=1/0;for(const o of h){const r=Math.floor(o/i),s=(o%i-e.desiredColumn)**2+(r-e.desiredRow)**2;(s<n||s===n&&o<t)&&(t=o,n=s)}t<0||(h.delete(t),f.push({datum:e.datum,x:e.x,y:e.y,row:Math.floor(t/i),column:t%i,index:e.index}))}return f.sort((e,t)=>e.index-t.index),f.map(({index:e,...t})=>t)}function Gt(e,t,n=[]){if("function"==typeof t)return t(e);if("string"==typeof t)return e[t];for(const t of n)if(null!=e[t])return e[t]}function _t(e,t){const n=e.properties&&"object"==typeof e.properties?e.properties:{},o=e.id??n.id??n.name??`area-${t}`;return{...n,id:String(o)}}function Ht(e){return`${e.map(([e,t],n)=>`${0===n?"M":"L"}${e},${t}`).join("")}Z`}function Xt(e,t,n){const o=[];for(let r=0;r<6;r+=1){const i=-Math.PI/2+r*(Math.PI/3);o.push([e+Math.cos(i)*n,t+Math.sin(i)*n])}return Ht(o)}function Ut(e){return e.areas.map((t,n)=>{const o=_t(t,n),r=e.scales.geoPath.centroid(t),i=Number.isFinite(r[0])&&Number.isFinite(r[1])?e.scales.invertedPoint(r[0],r[1]):null;return{datum:{...o,gridLongitude:i?.[0],gridLatitude:i?.[1]},x:r[0],y:r[1]}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}function Kt(e){return e.points.map(t=>{const n=Number(Gt(t,e.config.longitudeAccessor,["lon","longitude"])),o=Number(Gt(t,e.config.latitudeAccessor,["lat","latitude"])),r=Number.isFinite(n)&&Number.isFinite(o)?e.scales.projectedPoint(n,o):null;return{datum:t,x:r?.[0]??NaN,y:r?.[1]??NaN}}).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}function Zt(e,t){if(!t.rowAccessor||!t.columnAccessor)return null;const n=e.map(e=>({datum:e,x:Number(Gt(e,t.columnAccessor)),y:Number(Gt(e,t.rowAccessor))})).filter(e=>Number.isFinite(e.x)&&Number.isFinite(e.y));return n.length!==e.length?null:n.map(e=>({...e,row:e.y,column:e.x}))}function Qt({marks:e,color:t,fontSize:n,fontFamily:o,fontWeight:r}){const i=Pt();/* @__PURE__ */ /* @__PURE__ */
|
|
21
|
+
return(0,rd.jsx)("g",{"aria-hidden":"true",pointerEvents:"none",children:e.map(e=>{const s=!i.isActive||i.predicate(e.datum);/* @__PURE__ */ /* @__PURE__ */
|
|
22
|
+
return(0,rd.jsx)("text",{x:e.x,y:e.y,fill:t,fontFamily:o,fontSize:n,fontWeight:r,opacity:s?1:.18,textAnchor:"middle",dominantBaseline:"central",children:e.label},e.id)})})}function Jt(){throw new Error("geographicDotGrid requires the geo recipe bundle")}function en(){throw new Error("geographicDotGrid requires the geo recipe bundle")}function tn(e){if(Number.isFinite(e)&&!(Number(e)<=0))return Number(e)}function nn(e,t){return"function"==typeof t?t(e,e.dotIndex):"string"==typeof t?e[t]:void 0}function on(e){return e.properties&&"object"==typeof e.properties?{...e.properties}:{}}function rn(e,t){const n=on(e);return String(e.id??n.id??n.name??`feature-${t}`)}function sn(e,t){if(0===e.length)return null;const n={type:"FeatureCollection",features:e},o=t.bounds(n);return Number.isFinite(o[0][0])&&Number.isFinite(o[0][1])&&Number.isFinite(o[1][0])&&Number.isFinite(o[1][1])?o:null}function an(e,t,n,o){return[Math.ceil((e-n)/o-.5),Math.floor((t-n)/o-.5)]}function cn(e){if(!e)return 0;const t=fd.get(e);if(t)return t;const n=md;return md+=1,fd.set(e,n),n}function ln(e){return e.map((e,t)=>{if(hd.has(e))return{feature:e,index:t,bounds:hd.get(e)??null};try{const n=Jt();return hd.set(e,n),{feature:e,index:t,bounds:n}}catch{return hd.set(e,null),{feature:e,index:t,bounds:null}}})}function un(e,t){return!t||e[1]>=t[0][1]&&e[1]<=t[1][1]&&(n=e[0],(o=t[0][0])<=(r=t[1][0])?n>=o&&n<=r:n>=o||n<=r);var n,o,r}function dn(e,t){for(const n of e){const{feature:e,index:o}=n;if(e.geometry&&un(t,n.bounds))try{if(en())return{feature:e,index:o}}catch{}}return null}function hn(e,t,n,o={}){const r=e.filter((e,t)=>e.geometry&&(!o.featureFilter||o.featureFilter(e,t))),i=sn(r,t.geoPath);if(!i)return{dots:[],cellSize:ld,features:r};const s=Math.max(0,o.layoutPadding??0),a=[[me(i[0][0],s,Math.max(s,n.width-s)),me(i[0][1],s,Math.max(s,n.height-s))],[me(i[1][0],s,Math.max(s,n.width-s)),me(i[1][1],s,Math.max(s,n.height-s))]],c=Math.max(0,a[1][0]-a[0][0]),l=Math.max(0,a[1][1]-a[0][1]);if(0===c||0===l)return{dots:[],cellSize:ld,features:r};const u=tn(o.columns);let d=Math.max(2,u?c/u:tn(o.cellSize)??ld);const h=Math.max(100,Math.round(tn(o.maxSamples)??ud)),f=Math.ceil(c/d)*Math.ceil(l/d);f>h&&(d*=Math.sqrt(f/h));const m=o.gridOrigin?.[0]??0,p=o.gridOrigin?.[1]??0,[g,y]=an(a[0][0],a[1][0],m,d),[x,b]=an(a[0][1],a[1][1],p,d),w=[],M=ln(r);for(let e=x;e<=b;e+=1){const n=p+(e+.5)*d;for(let r=g;r<=y;r+=1){const i=m+(r+.5)*d,s=t.invertedPoint(i,n);if(!s||!Number.isFinite(s[0])||!Number.isFinite(s[1]))continue;const a=dn(M,s);if(!a)continue;const c={...on(a.feature),featureId:rn(a.feature,a.index),featureIndex:a.index,gridRow:e,gridColumn:r,longitude:s[0],latitude:s[1],dotIndex:w.length};o.dotFilter&&!o.dotFilter(c,w.length)||w.push(c)}}return{dots:w,cellSize:d,features:r}}function fn(e){return Math.round(1e4*e)/1e4}function mn(e){return Array.isArray(e)&&e.length>=2&&Number.isFinite(e[0])&&Number.isFinite(e[1])?`${fn(Number(e[0]))},${fn(Number(e[1]))}`:"null"}function pn(e,t){const n=e[t];return"function"==typeof n?n.call(e):void 0}function gn(e){return"number"==typeof e&&Number.isFinite(e)?String(fn(e)):null===e?"null":"unavailable"}function yn(e){const t=e.scales.projection;return[gn(pn(t,"scale")),mn(pn(t,"translate")),mn(pn(t,"center")),(n=pn(t,"rotate"),Array.isArray(n)&&n.every(Number.isFinite)?n.map(e=>fn(Number(e))).join(","):"unavailable"),gn(pn(t,"clipAngle")),gn(pn(t,"precision")),...[[0,0],[-120,35],[45,45],[120,-30]].map(([t,n])=>mn(e.scales.projectedPoint(t,n)))].join("|");var n}function xn(e){const t=e.config;return[e.areas.length,e.dimensions.width,e.dimensions.height,t.cellSize??"",t.columns??"",t.layoutPadding??"",t.gridOrigin?.join(",")??"",t.maxSamples??"",cn(t.featureFilter),cn(t.dotFilter),yn(e)].join("::")}function bn(e){let t=dd.get(e.areas);t||(t=/* @__PURE__ */new Map,dd.set(e.areas,t));const n=xn(e),o=t.get(n);if(o)return o;const r=hn(e.areas,e.scales,e.dimensions,e.config);if(t.size>=12){const e=t.keys().next().value;void 0!==e&&t.delete(e)}return t.set(n,r),r}function wn(e){return`${e.map(([e,t],n)=>`${0===n?"M":"L"}${e},${t}`).join("")}Z`}function Mn(e,t,n){return wn([[e-n,t-n],[e+n,t-n],[e+n,t+n],[e-n,t+n]])}function vn(e,t,n){return wn(Array.from({length:6},(o,r)=>{const i=-Math.PI/2+r*(Math.PI/3);return[e+Math.cos(i)*n,t+Math.sin(i)*n]}))}function kn(e,t,n){const o=e.data??e,r=o.x??e.x,i=o.y??e.y,s=e.createdByFrame&&0===e.width?void 0:e.width,a=e.createdByFrame&&0===e.height?void 0:e.height,c=o.width??s??t,l=o.height??a??n;if(!("number"!=typeof r||"number"!=typeof i||"number"!=typeof c||"number"!=typeof l||![r,i,c,l].every(Number.isFinite)||c<=0||l<=0))return{x:r,y:i,w:c,h:l}}function $n(e,t,n){const{nodeWidth:o,nodeHeight:r,waypoints:i=[]}=n,s="none"===n.fit?"none":"contain";let a=1/0,c=1/0,l=-1/0,u=-1/0;const d=(e,t)=>{a=Math.min(a,e),c=Math.min(c,t),l=Math.max(l,e),u=Math.max(u,t)};let h=!1;for(const t of e){const e=kn(t,o,r);e&&(h=!0,d(e.x-e.w/2,e.y-e.h/2),d(e.x+e.w/2,e.y+e.h/2))}for(const e of i)d(e.x,e.y);let f=1,m=0,p=0;if("contain"===s&&h){const e=l-a,n=u-c;if(![e,n,t.x,t.y,t.width,t.height].every(Number.isFinite)||e<=0||n<=0||t.width<=0||t.height<=0)h=!1;else{const o=Math.min(1,t.width/4,t.height/4);f=Math.min(1,(t.width-2*o)/e,(t.height-2*o)/n),m=t.x+(t.width-e*f)/2-a*f,p=t.y+(t.height-n*f)/2-c*f}}const g=({x:e,y:t})=>({x:e*f+m,y:t*f+p});return{fit:s,scale:f,dx:m,dy:p,bounds:h?{x:a,y:c,width:l-a,height:u-c}:null,project:g,invert:({x:e,y:t})=>({x:(e-m)/f,y:(t-p)/f}),nodeBounds:e=>{const t=h?kn(e,o,r):void 0;if(!t)return;const{x:n,y:i}=g(t),s=t.w*f,a=t.h*f;return{x:n-s/2,y:i-a/2,width:s,height:a,cx:n,cy:i}}}}function Sn(e,t,n,o=[]){const r=$n(e.nodes,e.dimensions.plot,{nodeWidth:t.nodeWidth,nodeHeight:t.nodeHeight,fit:t.fit,waypoints:o}),i=/* @__PURE__ */new Map,s=[],a=[];for(const o of e.nodes){const c=r.nodeBounds(o);if(!c)continue;const{cx:l,cy:u,width:d,height:h}=c;i.set(o.id,{x:l,y:u,w:d,h:h});const f=o.data??o,m=t.labelAccessor??"id",p=String("function"==typeof m?m(f):f[m]??o.id);s.push({type:"rect",x:c.x,y:c.y,w:d,h:h,style:{fill:t.nodeFill??e.resolveColor(o.id),stroke:n,strokeWidth:Math.min(1.5,d/2,h/2)},datum:f,id:o.id,label:p}),!1!==t.showLabels&&a.push({x:l,y:u,text:p,anchor:"middle",baseline:"middle",fontSize:11*r.scale})}return{positions:i,sceneNodes:s,labels:a,project:r.project}}function In(e,t,n={}){return $n(e,t,{nodeWidth:n.nodeWidth??80,nodeHeight:n.nodeHeight??30,fit:n.fit})}function An(e,t){const n=t.x-e.x,o=t.y-e.y,r=Math.min(0===n?1/0:e.w/2/Math.abs(n),0===o?1/0:e.h/2/Math.abs(o));return Number.isFinite(r)?{x:e.x+n*r,y:e.y+o*r}:{x:e.x,y:e.y}}function Cn(e,t,n,o,r,i=1){const s=t.x-n.x,a=t.y-n.y,c=Math.hypot(s,a);if(0===c||r<=0)return null;const l=Math.min(r,c)/c,u=s*l,d=a*l;return(0,xd.createElement)("polygon",{key:e,className:"recipe-edge-arrow",points:`${t.x},${t.y} ${t.x-u-d/2},${t.y-d+u/2} ${t.x-u+d/2},${t.y-d-u/2}`,fill:o,opacity:i,"aria-hidden":!0,style:{pointerEvents:"none"}})}function Nn(e){const t=e.data??e,n=Array.isArray(t.points)?t.points:e.points;return Array.isArray(n)&&n.length>=2&&n.every(e=>e&&Number.isFinite(e.x)&&Number.isFinite(e.y))?n:[]}function jn(e,t,n,o={}){return $n(e,n,{nodeWidth:o.nodeWidth??100,nodeHeight:o.nodeHeight??36,fit:o.fit,waypoints:t.flatMap(Nn)})}function Fn(e,t){const n="function"==typeof t?t(e):e[t];return kd(n)?n:void 0}function En(e){return[...e].sort((e,t)=>je(e,t))}function Pn(e,t){const n=new Map(e.map(e=>[e,/* @__PURE__ */new Set]));for(const e of t)n.has(e.source)&&n.has(e.target)&&(n.get(e.source)?.add(e.target),n.get(e.target)?.add(e.source));return n}function zn(e){const t=new Set(e.keys()),n=[];for(const o of En(t)){if(!t.has(o))continue;const r=[o],i=[];t.delete(o);for(let n=0;n<r.length;n++){const o=r[n];i.push(o);for(const n of En(e.get(o)??[]))t.has(n)&&(t.delete(n),r.push(n))}n.push(i.sort((e,t)=>je(e,t)))}return n.sort((e,t)=>t.length-e.length||je(e[0],t[0]))}function Ln(e,t,n){const o=/* @__PURE__ */new Map([[e,0]]),r=[e];for(let e=0;e<r.length;e++){const i=r[e],s=o.get(i);for(const e of En(n.get(i)??[]))t.has(e)&&!o.has(e)&&(o.set(e,s+1),r.push(e))}return o}function On(e,t,n){const o=Ln(e,t,n);let r=e,i=-1;for(const[e,t]of o)(t>i||t===i&&je(e,r)<0)&&(r=e,i=t);return r}function Tn(e,t,n){const o=new Set(e),r=e.filter(e=>(t.get(e)?.size??0)<=1)[0]??e[0],i=Ln(n&&o.has(n)?n:On(On(r,o,t),o,t),o,t);let s=0;for(const e of i.values())s=Math.max(s,e);const a=Array.from({length:s+1},()=>[]);for(const t of e)a[i.get(t)??0].push(t);a.forEach(e=>e.sort((e,t)=>je(e,t)));const c=(e,n)=>{const o=new Map(a[n].map((e,t)=>[e,t])),r=e=>{const n=[...t.get(e)??[]].map(e=>o.get(e)).filter(e=>null!=e);return 0===n.length?Number.POSITIVE_INFINITY:n.reduce((e,t)=>e+t,0)/n.length},i=new Map(a[e].map(e=>[e,r(e)]));a[e].sort((e,t)=>i.get(e)-i.get(t)||je(e,t))};for(let e=0;e<4;e+=1){for(let e=1;e<a.length;e+=1)c(e,e-1);for(let e=a.length-2;e>=0;e-=1)c(e,e+1)}return a}function Rn(e,t,n,o,r,i){const s=Pn(e.map(e=>e.id),t),a=zn(s),c=new Map(e.map(e=>[e.id,e.data])),l=/* @__PURE__ */new Map,u=Math.max(0,n.width),d=Math.max(0,n.height),h=Math.min(o,u/2),f=Math.min(o,d/2),m=Math.max(0,d-2*f),p=a.length>1?Math.min(r,m/a.length):0,g=Math.max(0,m-p*Math.max(0,a.length-1)),y=a.reduce((e,t)=>e+Math.sqrt(t.length),0);let x=f;for(const e of a){const t=g*(Math.sqrt(e.length)/y),n=Tn(e,s,i),o=Math.max(0,u-2*h);n.forEach((e,r)=>{const i=1===n.length?u/2:h+r/(n.length-1)*o;e.forEach((n,o)=>{const r=1===e.length?x+t/2:x+o/(e.length-1)*t;l.set(n,{id:n,x:i,y:r,data:c.get(n)})})}),x+=t+p}return l}function Wn(e,t,n,o={}){const r=Math.max(0,o.padding??36),i=Math.max(0,o.componentGap??26),s=o.xAccessor??"x",a=o.yAccessor??"y",c=e.map(e=>({...e,authoredX:Fn(e.data,s),authoredY:Fn(e.data,a)})),l=c.length>0&&c.every(e=>kd(e.authoredX)&&kd(e.authoredY)),u="authored"===o.layoutMode||"automatic"!==o.layoutMode&&l,d=[];if(u&&!l&&d.push("Authored transit layout requested, but at least one station has no finite x/y position; using automatic topology layout."),!u||!l){l||"automatic"===o.layoutMode||d.push("Complete station positions were not supplied; using the deterministic automatic topology layout.");const s=Rn(e,t,n,r,i,o.rootId);if("right-to-left"===o.direction)for(const e of s.values())e.x=n.width-e.x;return{positions:s,mode:"automatic",warnings:d,projectAuthoredPoint:e=>e}}let h=1/0,f=-1/0,m=1/0,p=-1/0;for(const e of c)h=Math.min(h,e.authoredX),f=Math.max(f,e.authoredX),m=Math.min(m,e.authoredY),p=Math.max(p,e.authoredY);const g=Math.max(1,n.width-2*r),y=Math.max(1,n.height-2*r),x=e=>({x:f===h?n.width/2:r+(e.x-h)/(f-h)*g,y:p===m?n.height/2:r+(e.y-m)/(p-m)*y}),b=/* @__PURE__ */new Map;for(const e of c){const t=x({x:e.authoredX,y:e.authoredY});b.set(e.id,{id:e.id,...t,data:e.data})}return{positions:b,mode:"authored",warnings:d,projectAuthoredPoint:x}}function qn(e,t){const n=t.x-e.x,o=t.y-e.y,r=Math.abs(n),i=Math.abs(o);if(r<.001||i<.001||Math.abs(r-i)<.001)return[e,t];const s=Math.sign(n),a=Math.sign(o);if(r>i){const n=(r-i)/2;return[e,{x:e.x+s*n,y:e.y},{x:t.x-s*n,y:t.y},t]}const c=(i-r)/2;return[e,{x:e.x,y:e.y+a*c},{x:t.x,y:t.y-a*c},t]}function Dn(e,t){if(0===t||e.length<2)return e.map(e=>({...e}));const n=(e,t)=>{const n=t.x-e.x,o=t.y-e.y,r=Math.hypot(n,o)||1;return{x:-o/r,y:n/r}};return e.map((o,r)=>{const i=r>0?n(e[r-1],o):null,s=r<e.length-1?n(o,e[r+1]):null;if(!i||!s){const e=s??i??{x:0,y:0};return{x:o.x+e.x*t,y:o.y+e.y*t}}let a=i.x+s.x,c=i.y+s.y;const l=Math.hypot(a,c);if(l<.001)return{x:o.x+s.x*t,y:o.y+s.y*t};a/=l,c/=l;const u=a*s.x+c*s.y;if(Math.abs(u)<.001)return{x:o.x+s.x*t,y:o.y+s.y*t};const d=4*Math.abs(t),h=t/u,f=Math.max(-d,Math.min(d,h));return{x:o.x+a*f,y:o.y+c*f}})}function Bn(e,t){if(0===e.length)return"";if(1===e.length)return`M${e[0].x},${e[0].y}`;const n=Math.max(0,t);let o=`M${e[0].x},${e[0].y}`;for(let t=1;t<e.length-1;t+=1){const r=e[t-1],i=e[t],s=e[t+1],a=Math.hypot(i.x-r.x,i.y-r.y),c=Math.hypot(s.x-i.x,s.y-i.y),l=Math.min(n,a/2,c/2);if(l<=.001){o+=` L${i.x},${i.y}`;continue}const u={x:i.x+(r.x-i.x)/a*l,y:i.y+(r.y-i.y)/a*l},d={x:i.x+(s.x-i.x)/c*l,y:i.y+(s.y-i.y)/c*l};o+=` L${u.x},${u.y} Q${i.x},${i.y} ${d.x},${d.y}`}const r=e[e.length-1];return`${o} L${r.x},${r.y}`}function Yn(e,t){return"function"==typeof t.labelAccessor?t.labelAccessor(e.data):ge(e.data,t.labelAccessor??"label",e.id)}function Vn(e){return"string"==typeof e?e:e.id}function Gn(e){const t=(Array.isArray(e)?e:null==e?[]:[e]).map(e=>"object"==typeof e?{...e,id:String(e.id)}:{id:String(e)});return t.length>0?t:[{id:"network"}]}function _n(e,t){const n=t.lineAccessor;let o;return o="function"==typeof n?n(e.data):"string"==typeof n?e.data[n]:e.data.lines??e.data.line??e.data.route??e.data.group,Gn(o)}function Hn(e,t,n){const o=t.sourceColorAccessor,r="function"==typeof o?o(e.data):"string"==typeof o?e.data[o]:e.data.color;return"string"==typeof r&&r?r:n(e.id)}function Xn(e,t,n,o){const r=new Set(e.map(e=>e.id)),i=new Map(e.map(e=>[e.id,0])),s=new Map(e.map(e=>[e.id,[]]));for(const e of t)r.has(e.source)&&r.has(e.target)&&(i.set(e.target,(i.get(e.target)??0)+1),s.get(e.source)?.push(e));const a=e.filter(e=>0===(i.get(e.id)??0)),c=/* @__PURE__ */new Map,l=new Map(e.map(e=>[e.id,/* @__PURE__ */new Map]));for(const e of a){const t={id:e.id,label:String(Yn(e,n)),color:Hn(e,n,o)},r=/* @__PURE__ */new Set,i=[e.id];for(;i.length>0;){const e=i.shift();if(!r.has(e)){r.add(e),l.get(e)?.set(t.id,t);for(const n of s.get(e)??[]){let e=c.get(n);e||(e=/* @__PURE__ */new Map,c.set(n,e)),e.set(t.id,t),r.has(n.target)||i.push(n.target)}}}}const u=e=>[...e].sort((e,t)=>je(e.id,t.id));return{byEdge:new Map(t.map(e=>[e,u(c.get(e)?.values()??[])])),byNode:new Map(e.map(e=>[e.id,u(l.get(e.id)?.values()??[])]))}}function Un(e,t,n,o){if(e.color)return e.color;const r=n.lineColors&&Object.prototype.hasOwnProperty.call(n.lineColors,e.id)?n.lineColors[e.id]:void 0;if("string"==typeof r&&r)return r;const i=n.lineColorAccessor,s="function"==typeof i?i(t.data):"string"==typeof i?t.data[i]:t.data.color;return"string"==typeof s?s:o(e.id)}function Kn(e,t,n){const o=/* @__PURE__ */new Map;for(const r of e){const e=r.source<r.target?`${r.source}\0${r.target}`:`${r.target}\0${r.source}`;let i=o.get(e);i||(i={key:e,source:r.source,target:r.target,lines:/* @__PURE__ */new Map},o.set(e,i));const s=r.data.lineOrder;Array.isArray(s)&&(i.authoredOrder=s.map(String));const a=n?.byEdge.get(r)??_n(r,t);for(const e of a)i.lines.has(e.id)||i.lines.set(e.id,{descriptor:e,edge:r})}return[...o.values()].sort((e,t)=>je(e.key,t.key))}function Zn(e,t){const n=new Map((t.lineOrder??[]).map((e,t)=>[e,t]));return[...e].sort((e,t)=>(n.get(e)??Number.POSITIVE_INFINITY)-(n.get(t)??Number.POSITIVE_INFINITY)||je(e,t))}function Qn(e,t){const n=e.authoredOrder??t.lineOrder??[],o=new Map(n.map((e,t)=>[e,t]));return[...e.lines.values()].sort((e,t)=>(o.get(e.descriptor.id)??Number.POSITIVE_INFINITY)-(o.get(t.descriptor.id)??Number.POSITIVE_INFINITY)||je(e.descriptor.id,t.descriptor.id))}function Jn(e,t,n,o){if("authored"!==t.mode)return null;const r=e.data[n.pointsAccessor??"points"];if(!Array.isArray(r))return null;const i=r.map(e=>{const n=e;return"number"==typeof n.x&&"number"==typeof n.y?t.projectAuthoredPoint({x:n.x,y:n.y}):null}).filter(e=>null!=e);return 0===i.length?null:o?i.reverse():i}function eo(e,t){return be(n=>{for(const[t,o]of Object.entries(e.data))n(t,o);n("source",e.source),n("target",e.target),n("lineId",t.id),n("lineLabel",t.label??t.id)})}function to(e,t,n,o,r,i){if(!1===i.showLabels)return[];const s=i.labelFontSize??11,a=[],c=[],l=[...e].sort((e,t)=>(n.get(t.id)?.size??0)-(n.get(e.id)?.size??0)||je(e.id,t.id));for(const e of l){const n=t.get(e.id);if(!n)continue;const l=("function"==typeof i.labelAccessor?i.labelAccessor(e.data):String(ge(e.data,i.labelAccessor??"label",e.id)))||e.id,u=Math.max(2*s,l.length*s*.58),d=1.25*s,h=Math.max(i.interchangeRadius??7,o.get(e.id)??i.stationRadius??4)+5,f=[{x:n.x+h,y:n.y,anchor:"start",left:n.x+h},{x:n.x-h,y:n.y,anchor:"end",left:n.x-h-u},{x:n.x,y:n.y-h,anchor:"middle",left:n.x-u/2},{x:n.x,y:n.y+h,anchor:"middle",left:n.x-u/2}].map((e,t)=>{const n={left:e.left,right:e.left+u,top:e.y-d/2,bottom:e.y+d/2},o=a.filter(e=>{return o=e,(t=n).left<o.right&&t.right>o.left&&t.top<o.bottom&&t.bottom>o.top;var t,o}).length,i=Math.max(0,-n.left)+Math.max(0,n.right-r.width)+Math.max(0,-n.top)+Math.max(0,n.bottom-r.height);return{candidate:e,box:n,score:1e4*o+10*i+t}}).sort((e,t)=>e.score-t.score)[0];a.push(f.box),c.push({x:f.candidate.x,y:f.candidate.y,anchorPoint:[n.x,n.y],text:l,anchor:f.candidate.anchor,baseline:"middle",fontSize:s,fill:i.labelColor??"var(--semiotic-text, #222)",stroke:"var(--semiotic-bg, white)",strokeWidth:3,paintOrder:"stroke"})}return c}function no(e,t,n={}){const o=n.layerAccessor??"x",r=n.rowAccessor??"y";let i=1/0,s=-1/0,a=1/0,c=-1/0;for(const t of e){const e=Number(ge(t,o,0)),n=Number(ge(t,r,0));Number.isFinite(e)&&Number.isFinite(n)&&(i=Math.min(i,e),s=Math.max(s,e),a=Math.min(a,n),c=Math.max(c,n))}if(i===1/0&&(i=s=a=c=0),Number.isFinite(n.layerCount)&&n.layerCount>0&&(i=Math.min(i,0),s=Math.max(s,n.layerCount-1)),Number.isFinite(n.maxLayerSize)&&n.maxLayerSize>0){const e=Math.max(0,n.maxLayerSize-1)/2;a=Math.min(a,-e),c=Math.max(c,e)}const l=s-i,u=Math.max(1,c-a),d=(a+c-u)/2,h=l+1,f=c-a+1,m=t.width/Math.max(1,h),p=t.height/Math.max(1,f);let g=Math.min(n.nodeWidth??172,Math.max(8,m-(n.minGapX??26))),y=Math.min(n.nodeHeight??54,Math.max(8,p-(n.minGapY??18)));const x=n.lod&&"auto"!==n.lod?n.lod:g<16?"dot":g<48?"icon":g<108?"compact":"full";if("dot"===x){const e=Math.min(g,y,11);g=e,y=e}const b=Math.max(1,t.width-g),w=Math.max(1,t.height-y),{x:M,y:v}=t,k=(e,t)=>({x:M+g/2+(l>0?(e-i)/l:.5)*b,y:v+y/2+(t-d)/u*w});return{layerCount:h,maxLayerSize:f,nodeWidth:g,nodeHeight:y,lod:x,project:k,invert:(e,t)=>({layer:l>0?i+(e-M-g/2)/b*l:null,row:(t-v-y/2)/w*u+d}),nodeBounds:e=>{const t=k(Number(ge(e,o,0)),Number(ge(e,r,0)));return{x:t.x-g/2,y:t.y-y/2,width:g,height:y,cx:t.x,cy:t.y}}}}function oo(e,t,n){return(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x)}function ro(e){const t=e.slice().sort((e,t)=>e.x-t.x||e.y-t.y).filter((e,t,n)=>0===t||e.x!==n[t-1].x||e.y!==n[t-1].y);if(t.length<=2)return t;const n=[];for(const e of t){for(;n.length>=2&&oo(n[n.length-2],n[n.length-1],e)<=0;)n.pop();n.push(e)}const o=[];for(let e=t.length-1;e>=0;e--){const n=t[e];for(;o.length>=2&&oo(o[o.length-2],o[o.length-1],n)<=0;)o.pop();o.push(n)}return n.pop(),o.pop(),n.concat(o)}function io(e,t){if(0===t||e.length<3)return e;const n=e.reduce((t,n,o)=>{const r=e[(o+1)%e.length];return t+n.x*r.y-r.x*n.y},0)>=0?1:-1;return e.map((o,r)=>{const i=e[(r-1+e.length)%e.length],s=e[(r+1)%e.length],a=Math.hypot(o.x-i.x,o.y-i.y)||1,c=Math.hypot(s.x-o.x,s.y-o.y)||1,l=n>0?{x:(o.y-i.y)/a,y:-(o.x-i.x)/a}:{x:-(o.y-i.y)/a,y:(o.x-i.x)/a},u=n>0?{x:(s.y-o.y)/c,y:-(s.x-o.x)/c}:{x:-(s.y-o.y)/c,y:(s.x-o.x)/c},d={x:l.x+u.x,y:l.y+u.y},h=Math.hypot(d.x,d.y);if(h<1e-9)return{x:o.x+u.x*t,y:o.y+u.y*t};const f=d.x/h,m=d.y/h,p=Math.max(1e-6,f*u.x+m*u.y),g=t/p;return{x:o.x+f*g,y:o.y+m*g}})}function so(e){return String(Math.abs(e)<1e-12?0:e)}function ao(e,t){if(0===e.length)return"";if(e.length<3||0===t)return`${e.map((e,t)=>`${0===t?"M":"L"}${so(e.x)},${so(e.y)}`).join(" ")} Z`;const n=e.map((n,o)=>{const r=e[(o-1+e.length)%e.length],i=e[(o+1)%e.length],s=Math.hypot(r.x-n.x,r.y-n.y)||1,a=Math.hypot(i.x-n.x,i.y-n.y)||1,c=Math.min(t,s/2,a/2);return{point:n,incoming:{x:n.x+(r.x-n.x)/s*c,y:n.y+(r.y-n.y)/s*c},outgoing:{x:n.x+(i.x-n.x)/a*c,y:n.y+(i.y-n.y)/a*c}}}),o=n[0].outgoing;let r=`M${so(o.x)},${so(o.y)}`;for(let e=1;e<n.length;e++){const t=n[e];r+=` L${so(t.incoming.x)},${so(t.incoming.y)}`,r+=` Q${so(t.point.x)},${so(t.point.y)} ${so(t.outgoing.x)},${so(t.outgoing.y)}`}const i=n[0];return r+=` L${so(i.incoming.x)},${so(i.incoming.y)}`,r+=` Q${so(i.point.x)},${so(i.point.y)} ${so(i.outgoing.x)},${so(i.outgoing.y)} Z`,r}function co(e,t){const n=[];for(const[o,r]of e){const e=io(ro(r.flatMap(e=>[{x:e.x,y:e.y},{x:e.x+e.w,y:e.y},{x:e.x+e.w,y:e.y+e.h},{x:e.x,y:e.y+e.h}])),t.padding);if(!e.length)continue;const i=e.map(e=>e.x),s=e.map(e=>e.y),a=Math.min(...i),c=Math.min(...s);n.push({x:a,y:c,width:Math.max(...i)-a,height:Math.max(...s)-c});const l=t.label?.(o);l&&n.push({x:a+8,y:c+14,z:0,extent:[0,6.6*l.length,12,3]})}return n}function lo(e,t){const n=Array.from(e.entries()).sort(([e],[t])=>e<t?-1:e>t?1:0);/* @__PURE__ */ /* @__PURE__ */
|
|
23
|
+
return(0,Ad.jsx)("g",{className:"lineage-dag-hulls","aria-hidden":"true",style:{pointerEvents:"none"},children:n.map(([e,n])=>{const o=io(ro(n.flatMap(e=>[{x:e.x,y:e.y},{x:e.x+e.w,y:e.y},{x:e.x+e.w,y:e.y+e.h},{x:e.x,y:e.y+e.h}])),t.padding),r=ao(o,t.radius),i=Object.prototype.hasOwnProperty.call(t.colors??{},e)?t.colors?.[e]??t.resolveColor(e):t.resolveColor(e),s=n.every(e=>!0===t.dimById.get(e.id)&&e.id!==t.selectedId),a=Math.min(...o.map(e=>e.x)),c=Math.min(...o.map(e=>e.y)),l=t.label?.(e);/* @__PURE__ */ /* @__PURE__ */
|
|
24
|
+
return(0,Ad.jsxs)("g",{"data-lineage-hull":e,opacity:s?t.dimOpacity:void 0,children:[
|
|
28
25
|
/* @__PURE__ */
|
|
29
|
-
/* @__PURE__ */(0,
|
|
30
|
-
return(0,
|
|
26
|
+
/* @__PURE__ */(0,Ad.jsx)(Id.NetworkPerspectiveGround,{children:/* @__PURE__ */ /* @__PURE__ */(0,Ad.jsx)("path",{className:"lineage-dag-hull",d:r,fill:i,fillOpacity:t.fillOpacity,stroke:i,strokeOpacity:t.strokeOpacity,strokeWidth:1,vectorEffect:"non-scaling-stroke",style:{pointerEvents:"none"}})}),l?/* @__PURE__ */ /* @__PURE__ */(0,Ad.jsx)(Id.NetworkPerspectiveBillboard,{x:a+8,y:c+14,z:0,children:/* @__PURE__ */ /* @__PURE__ */(0,Ad.jsx)("text",{className:"lineage-dag-hull-label",x:a+8,y:c+14,fill:i,fillOpacity:Math.max(t.strokeOpacity,.7),fontSize:11,fontWeight:600,style:{pointerEvents:"none"},children:l})}):null]},e)})})}function uo(e){return Array.isArray(e)?e.map((e,t)=>"string"==typeof e?{storeName:e,slotIndex:t}:{storeName:String(e.storeName??""),slotIndex:e.slotIndex??t}):[]}function ho(e,t){return Number.isFinite(e)?me(e,0,1):t}function fo(e,t){const{w:n,h:o,lod:r}=t,i="icon"===r?Math.min(n,o):Math.min(o-14,26),s=(Object.prototype.hasOwnProperty.call(t.partColors,e.partition)?t.partColors[e.partition]:t.partColors.unknown)??"#5a5a6a",a="icon"===r?0:8+i+8,c=null!=t.renderIcon?t.renderIcon({semantic:e.semantic,partition:e.partition,size:i,color:s,node:e.node}):mo(e.semantic,e.partition,i),l="full"===r,u="icon"!==r,d="full"===r&&t.showChips&&e.stores.length>0;/* @__PURE__ */ /* @__PURE__ */
|
|
27
|
+
return(0,Cd.jsxs)("g",{transform:`translate(${e.cx-n/2}, ${e.cy-o/2})`,opacity:e.opacity,style:{pointerEvents:"none"},children:[
|
|
31
28
|
/* @__PURE__ */
|
|
32
|
-
/* @__PURE__ */(0,
|
|
29
|
+
/* @__PURE__ */(0,Cd.jsx)("g",{transform:`translate(${"icon"===r?(n-i)/2:8}, ${(o-i)/2})`,children:c}),u&&
|
|
33
30
|
/* @__PURE__ */
|
|
34
|
-
/* @__PURE__ */(0,
|
|
35
|
-
return(0,
|
|
31
|
+
/* @__PURE__ */(0,Cd.jsx)("foreignObject",{x:a,y:l?o/2-12:o/2-9,width:Math.max(8,n-a-8),height:18,style:{pointerEvents:"none"},children:/* @__PURE__ */ /* @__PURE__ */(0,Cd.jsx)("div",{title:e.label,style:{pointerEvents:"none",fontFamily:"var(--semiotic-font-family, inherit)",fontSize:"full"===r?12.5:11.5,fontWeight:600,color:"var(--semiotic-text, #f4f4f8)",lineHeight:"18px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.label})}),l&&/* @__PURE__ */ /* @__PURE__ */(0,Cd.jsx)("text",{x:a,y:o/2-16,dominantBaseline:"middle",fontSize:9.5,fontWeight:500,fill:"var(--semiotic-text-secondary, #b9b9c8)",style:{textTransform:"uppercase",letterSpacing:"0.04em"},children:t.typeLabel?t.typeLabel({semantic:e.semantic,partition:e.partition,node:e.node}):e.partition.startsWith("topic")?"topic":e.semantic}),d&&e.stores.map((e,n)=>/* @__PURE__ */ /* @__PURE__ */(0,Cd.jsx)("rect",{x:a+15*n,y:o-10,width:12,height:5,rx:1.5,fill:t.chipColor,children:/* @__PURE__ */ /* @__PURE__ */(0,Cd.jsx)("title",{children:e.storeName})},e.storeName+n))]},e.id)}function mo(e,t,n){const o=t.startsWith("topic")?"T":{source:"SR",sink:"SK",filter:"FL",map:"MP",aggregate:"AG",reduce:"RD","join-this":"JN","join-other":"JN",merge:"MG",suppress:"SP",select:"SE",tostream:"TS"}[e]??"PR";/* @__PURE__ */ /* @__PURE__ */
|
|
32
|
+
return(0,Cd.jsxs)("g",{children:[
|
|
36
33
|
/* @__PURE__ */
|
|
37
|
-
/* @__PURE__ */(0,
|
|
34
|
+
/* @__PURE__ */(0,Cd.jsx)("rect",{width:n,height:n,rx:4,fill:"rgba(255,255,255,0.08)",stroke:"rgba(255,255,255,0.18)"}),
|
|
38
35
|
/* @__PURE__ */
|
|
39
|
-
/* @__PURE__ */(0,
|
|
40
|
-
return(0,
|
|
41
|
-
return(0,
|
|
42
|
-
return(0,
|
|
43
|
-
return(0,
|
|
44
|
-
return(0,
|
|
36
|
+
/* @__PURE__ */(0,Cd.jsx)("text",{x:n/2,y:n/2+.5,textAnchor:"middle",dominantBaseline:"middle",fontSize:.42*n,fontWeight:700,fill:"var(--semiotic-text, #fff)",children:o})]})}async function po(e,t,n={}){const{prepareNetworkAtlas:o}=await Promise.resolve().then(()=>(Hl(),_l));return o(e,t,n)}async function go(e){const{prepareMotifBraid:t}=await Promise.resolve().then(()=>(ou(),Kl));return t(e)}function yo(e){const t=[e[0]];for(let n=1;n<e.length-1;n++){const o=e[n-1],r=e[n],i=e[n+1],s=Pd(o,r),a=Pd(r,i),c=Math.min(8,s/2,a/2);if(0===c)continue;const l=Ed(r,o,c/s),u=Ed(r,i,c/a);t.push(l);for(let e=1;e<=12;e++){const n=e/12;t.push(Ed(Ed(l,r,n),Ed(r,u,n),n))}}return t.push(e[e.length-1]),t.filter((e,n)=>0===n||Pd(t[n-1],e)>1e-8)}function xo(e,t,n){if(e.length<2)return"";const o=yo(e);if(o.length<2)return"";const r=[0];for(let e=1;e<o.length;e++)r.push(r[e-1]+Pd(o[e-1],o[e]));const i=r[r.length-1],s=Dn(o,1),a=[1,-1].map(e=>o.map((o,a)=>{const c=t+(n-t)*r[a]/i;return Ed(o,s[a],e*c/2)}));return[...a[0],...a[1].reverse()].map((e,t)=>`${0===t?"M":"L"}${e.x},${e.y}`).join(" ")+" Z"}function bo(e){let t=-(e.reduce((e,t)=>e+t,0)+3*(e.length-1))/2;return e.map(e=>{const n=t+e/2;return t+=e+3,n})}function wo(e){let t="";return e.split(">").map((e,n)=>t=n?`${t}>${e}`:e)}function Mo(e){const t=/* @__PURE__ */new Map;for(const n of e){const e=wo(n.signature);n.nodePath.forEach((o,r)=>{const i=e[r];let s=t.get(i);s||(s={id:i,state:o,depth:r+1,signatures:/* @__PURE__ */new Set},t.set(i,s)),s.signatures.add(n.signature)})}return[...t.values()]}function vo(e,t){return e.length>t?`${e.slice(0,Math.max(1,t-1))}…`:e}function ko(e,t,n,o,r,i,s,a){const c=t-o/2,l=n-r/2,u={fill:i,stroke:s,strokeWidth:a};switch(e){case"diamond":{const e=`${t},${l} ${t+o/2},${n} ${t},${n+r/2} ${c},${n}`;/* @__PURE__ */ /* @__PURE__ */
|
|
37
|
+
return(0,Wd.jsx)("polygon",{points:e,...u})}case"circle":/* @__PURE__ */ /* @__PURE__ */
|
|
38
|
+
return(0,Wd.jsx)("circle",{cx:t,cy:n,r:Math.min(o,r)/2,...u});case"stadium":case"round":/* @__PURE__ */ /* @__PURE__ */
|
|
39
|
+
return(0,Wd.jsx)("rect",{x:c,y:l,width:o,height:r,rx:"stadium"===e?r/2:8,ry:"stadium"===e?r/2:8,...u});case"hexagon":{const e=Math.min(.18*o,16),i=`${c+e},${l} ${t+o/2-e},${l} ${t+o/2},${n} ${t+o/2-e},${n+r/2} ${c+e},${n+r/2} ${c},${n}`;/* @__PURE__ */ /* @__PURE__ */
|
|
40
|
+
return(0,Wd.jsx)("polygon",{points:i,...u})}case"cylinder":{const e=Math.min(.16*r,8),t=`M${c},${l+e} a${o/2},${e} 0 0 0 ${o},0 v${r-2*e} a${o/2},${e} 0 0 1 ${-o},0 z`,n=`M${c},${l+e} a${o/2},${e} 0 0 1 ${o},0`;/* @__PURE__ */ /* @__PURE__ */
|
|
41
|
+
return(0,Wd.jsxs)("g",{children:[
|
|
45
42
|
/* @__PURE__ */
|
|
46
|
-
/* @__PURE__ */(0,
|
|
43
|
+
/* @__PURE__ */(0,Wd.jsx)("path",{d:t,...u}),
|
|
47
44
|
/* @__PURE__ */
|
|
48
|
-
/* @__PURE__ */(0,
|
|
49
|
-
return(0,
|
|
45
|
+
/* @__PURE__ */(0,Wd.jsx)("path",{d:n,fill:"none",stroke:s,strokeWidth:a})]})}case"subroutine":{const e=Math.min(8,.08*o);/* @__PURE__ */ /* @__PURE__ */
|
|
46
|
+
return(0,Wd.jsxs)("g",{children:[
|
|
50
47
|
/* @__PURE__ */
|
|
51
|
-
/* @__PURE__ */(0,
|
|
48
|
+
/* @__PURE__ */(0,Wd.jsx)("rect",{x:c,y:l,width:o,height:r,rx:3,...u}),
|
|
52
49
|
/* @__PURE__ */
|
|
53
|
-
/* @__PURE__ */(0,
|
|
50
|
+
/* @__PURE__ */(0,Wd.jsx)("line",{x1:c+e,y1:l,x2:c+e,y2:l+r,stroke:s,strokeWidth:a}),
|
|
54
51
|
/* @__PURE__ */
|
|
55
|
-
/* @__PURE__ */(0,
|
|
56
|
-
return(0,
|
|
57
|
-
return(0,
|
|
58
|
-
return(0,
|
|
59
|
-
return(0,
|
|
60
|
-
return(0,
|
|
52
|
+
/* @__PURE__ */(0,Wd.jsx)("line",{x1:c+o-e,y1:l,x2:c+o-e,y2:l+r,stroke:s,strokeWidth:a})]})}default:/* @__PURE__ */ /* @__PURE__ */
|
|
53
|
+
return(0,Wd.jsx)("rect",{x:c,y:l,width:o,height:r,rx:4,...u})}}function $o(e,t,n,o,r){const i=Math.max(0,Math.min(r,n/2,o/2)),s=e+n,a=t+o;return`M${e+i},${t} H${s-i} A${i},${i} 0 0 1 ${s},${t+i} V${a-i} A${i},${i} 0 0 1 ${s-i},${a} H${e+i} A${i},${i} 0 0 1 ${e},${a-i} V${t+i} A${i},${i} 0 0 1 ${e+i},${t} Z`}function So(e,t,n,o,r){const i=t-o/2,s=n-r/2;switch(e){case"diamond":return`M${t},${s} L${t+o/2},${n} L${t},${n+r/2} L${i},${n} Z`;case"circle":{const e=Math.min(o,r)/2;return`M${t-e},${n} A${e},${e} 0 1 1 ${t+e},${n} A${e},${e} 0 1 1 ${t-e},${n} Z`}case"stadium":case"round":return $o(i,s,o,r,"stadium"===e?r/2:8);case"hexagon":{const e=Math.min(.18*o,16);return`M${i+e},${s} L${t+o/2-e},${s} L${t+o/2},${n} L${t+o/2-e},${n+r/2} L${i+e},${n+r/2} L${i},${n} Z`}case"cylinder":{const e=Math.min(.16*r,8);return`M${i},${s+e} A${o/2},${e} 0 0 1 ${i+o},${s+e} V${s+r-e} A${o/2},${e} 0 0 1 ${i},${s+r-e} Z`}case"subroutine":return $o(i,s,o,r,3);default:return $o(i,s,o,r,4)}}function Io(e,t,n,o,r,i){const s=t-o/2,a=n-r/2;if("cylinder"===e){const e=Math.min(.16*r,8);/* @__PURE__ */ /* @__PURE__ */
|
|
54
|
+
return(0,Wd.jsx)("path",{d:`M${s},${a+e} a${o/2},${e} 0 0 0 ${o},0`,fill:"none",stroke:i,strokeWidth:1.5})}if("subroutine"===e){const e=Math.min(8,.08*o);/* @__PURE__ */ /* @__PURE__ */
|
|
55
|
+
return(0,Wd.jsx)("path",{d:`M${s+e},${a} V${a+r} M${s+o-e},${a} V${a+r}`,fill:"none",stroke:i,strokeWidth:1.5})}return null}function Ao(e,t){const n=p({nodes:e.map(e=>({id:e})),edges:e.flatMap(e=>[...t.get(e)].map(t=>({source:e,target:t})))}),o=/* @__PURE__ */new Map;n.forEach((e,t)=>e.forEach(e=>o.set(e,t)));const r=n.length,i=Array.from({length:r},()=>/* @__PURE__ */new Set),s=Array.from({length:r},()=>/* @__PURE__ */new Set);for(const n of e){const e=o.get(n);for(const r of t.get(n)){const t=o.get(r);e!==t&&(s[e].add(t),i[t].add(e))}}const a=s.map(e=>e.size),c=a.flatMap((e,t)=>0===e?[t]:[]),l=c.length,u=i.filter(e=>0===e.size).length,d=new Int32Array(r);let h=0;for(let e=0;e<c.length;e++){const t=c[e];for(const e of i[t])d[e]=Math.max(d[e],d[t]+1),h=Math.max(h,d[e]),0===--a[e]&&c.push(e)}return{sinkCount:l,sourceCount:u,layerCount:h+1,layer:new Map(e.map(e=>[e,h-d[o.get(e)]]))}}function Co(e,t=2166136261){let n=t;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return n>>>0}function No(e){return Co(e)/4294967295}function jo(e){/* @__PURE__ */ /* @__PURE__ */
|
|
56
|
+
return(0,Yd.jsx)("rect",{className:e.className,x:e.x,y:e.y,width:Math.max(0,e.width),height:Math.max(0,e.height),rx:e.radius??10,ry:e.radius??10,fill:e.fill??"none",stroke:e.stroke,strokeWidth:e.strokeWidth??1.5,strokeDasharray:e.strokeDasharray,opacity:e.opacity??.6,style:{pointerEvents:"none"}},e.keyId)}function Fo(e,t=0){let n=1/0,o=1/0,r=-1/0,i=-1/0;for(const t of e){const e=t.r??0;t.x-e<n&&(n=t.x-e),t.x+e>r&&(r=t.x+e),t.y-e<o&&(o=t.y-e),t.y+e>i&&(i=t.y+e)}return Number.isFinite(n)?{x:n-t,y:o-t,width:r-n+2*t,height:i-o+2*t}:null}function Eo(e,t=0){if(!e.length)return null;const n="number"==typeof t?t:t.x??0,o="number"==typeof t?t:t.y??0;let r=1/0,i=1/0,s=-1/0,a=-1/0;for(const t of e){if(!Number.isFinite(t.x)||!Number.isFinite(t.y))continue;if(!Number.isFinite(t.width)||!Number.isFinite(t.height))continue;const e=Math.max(0,t.width),n=Math.max(0,t.height);t.x<r&&(r=t.x),t.y<i&&(i=t.y),t.x+e>s&&(s=t.x+e),t.y+n>a&&(a=t.y+n)}return Number.isFinite(r)?{x:r-n,y:i-o,width:s-r+2*n,height:a-i+2*o}:null}function Po(e){const t=e.fontSize??12;return null!=e.maxWidth&&e.text.length*t*.56>e.maxWidth?null:/* @__PURE__ */ /* @__PURE__ */(0,Yd.jsx)("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 zo(e){const t=e.spacing??8,n=e.color??"currentColor";return{def:/* @__PURE__ */ /* @__PURE__ */(0,Yd.jsx)("pattern",{id:e.id,width:t,height:t,patternUnits:"userSpaceOnUse",patternTransform:`rotate(${e.angle??45})`,children:/* @__PURE__ */ /* @__PURE__ */(0,Yd.jsx)("line",{x1:0,y1:0,x2:0,y2:t,stroke:n,strokeWidth:e.strokeWidth??1,opacity:e.opacity??.5})},e.id),fill:`url(#${e.id})`}}function Lo(e){const t=e.orient??"bottom",n="bottom"===t||"top"===t,o=e.offset??0,r=e.tickLength??6,i=e.gridLength??0,s=e.labelGap??4,a=e.fontSize??11,c=e.color??"var(--semiotic-text-secondary, #888)",l=e.gridColor??c,u=e.format??(e=>String(e)),d="top"===t||"left"===t?-1:1,h=e.ticks.length-1,f=e.ticks.map((f,m)=>{const p=e.scale(f),g=o+d*r,y=o-d*i,x=g+d*s;let b;b=e.labelAnchor?e.labelAnchor:n?e.edgeAnchor&&0===m?"start":e.edgeAnchor&&m===h?"end":"middle":"left"===t?"end":"start";const w=n?{x1:p,x2:p,y1:g,y2:y}:{x1:g,x2:y,y1:p,y2:p},M=n?"top"===t?"auto":"hanging":"middle",v=n?{x:p,y:x}:{x:x,y:p};/* @__PURE__ */ /* @__PURE__ */
|
|
57
|
+
return(0,Yd.jsxs)("g",{children:[(r>0||i>0)&&/* @__PURE__ */ /* @__PURE__ */(0,Yd.jsx)("line",{...w,stroke:i>0?l:c,strokeWidth:1,strokeDasharray:i>0?e.gridDasharray:void 0,opacity:i>0?.7:1}),
|
|
61
58
|
/* @__PURE__ */
|
|
62
|
-
/* @__PURE__ */(0,
|
|
63
|
-
return(0,
|
|
59
|
+
/* @__PURE__ */(0,Yd.jsx)("text",{x:v.x,y:v.y,textAnchor:b,dominantBaseline:M,fontSize:a,fontWeight:e.fontWeight,fill:c,children:u(f)})]},`tick-${f}-${m}`)});/* @__PURE__ */ /* @__PURE__ */
|
|
60
|
+
return(0,Yd.jsx)("g",{className:e.className,style:{pointerEvents:"none"},children:f},e.keyId)}function Oo(e){const t=e.stroke??"var(--semiotic-text, #f4f4f8)",n=e.strokeWidth??1,o=e.markRadius??0,r=e.labelX-e.markX,i=e.labelY-e.markY,s=Math.hypot(r,i)||1,a=e.markX+r/s*o,c=e.markY+i/s*o;let l;return l="elbow"===e.connector?`M${a},${c} L${a},${e.labelY} L${e.labelX},${e.labelY}`:"curve"===e.connector?`M${a},${c} Q${(a+e.labelX)/2},${c} ${e.labelX},${e.labelY}`:`M${a},${c} L${e.labelX},${e.labelY}`,/* @__PURE__ */ /* @__PURE__ */(0,Yd.jsxs)("g",{className:e.className,style:{pointerEvents:"none"},children:[o>0&&/* @__PURE__ */ /* @__PURE__ */(0,Yd.jsx)("circle",{cx:e.markX,cy:e.markY,r:o,fill:"none",stroke:t,strokeWidth:n}),
|
|
64
61
|
/* @__PURE__ */
|
|
65
|
-
/* @__PURE__ */(0,
|
|
62
|
+
/* @__PURE__ */(0,Yd.jsx)("path",{d:l,fill:"none",stroke:t,strokeWidth:n}),
|
|
66
63
|
/* @__PURE__ */
|
|
67
|
-
/* @__PURE__ */(0,
|
|
64
|
+
/* @__PURE__ */(0,Yd.jsx)("text",{x:e.labelX,y:e.labelY,textAnchor:e.labelAnchor??"middle",dominantBaseline:e.labelBaseline??"hanging",fontSize:e.fontSize??11,fontWeight:e.fontWeight,fill:e.color??t,children:e.label})]},e.keyId)}function To(e,t,n,o){if(!t)return{bands:e};const r=e=>o?(n?48:4)+Math.max(13*e.descriptor.length*.6,11*`×${e.count} · ${e.directed?"converges to 1 sink":"branches to ≥2 sinks"}`.length*.56):n?44:0,i=e.map(e=>({...e,width:Math.min(e.width,Math.max(e.contentWidth??e.width,r(e)))}));return{bands:i,bounds:i.flatMap(e=>[{x:e.x-6,y:e.y-4,width:e.width+12,height:e.height+4},{x:e.x,y:e.y,z:0,extent:[0,r(e),2,32]}])}}function Ro(e,t){const n=[];for(const o of e){const e=o.directed?t.convergeColor:t.branchColor,r=[];if(n.push(
|
|
68
65
|
/* @__PURE__ */
|
|
69
|
-
/* @__PURE__ */(0,
|
|
66
|
+
/* @__PURE__ */(0,Vd.jsx)(Bd.NetworkPerspectiveGround,{children:jo({keyId:`band-${o.motif}`,x:o.x-6,y:o.y-4,width:o.width+12,height:o.height+4,radius:8,stroke:e,strokeWidth:1,opacity:.28})},`ground-${o.motif}`)),t.showExemplars&&o.exemplar){const n=o.exemplar;r.push(
|
|
70
67
|
/* @__PURE__ */
|
|
71
|
-
/* @__PURE__ */(0,
|
|
68
|
+
/* @__PURE__ */(0,Vd.jsxs)("g",{style:{pointerEvents:"none"},children:[n.edges.map((e,n)=>/* @__PURE__ */ /* @__PURE__ */(0,Vd.jsx)("line",{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:t.edgeColor,strokeWidth:.75,opacity:.55},`exe-${n}`)),n.nodes.map(t=>/* @__PURE__ */ /* @__PURE__ */(0,Vd.jsx)("circle",{cx:t.cx,cy:t.cy,r:Math.max(1.6,t.r),fill:e},`exn-${t.id}`))]},`ex-${o.motif}`))}if(t.showBandLabels){const e=o.x+(t.showExemplars?48:4);r.push(
|
|
72
69
|
/* @__PURE__ */
|
|
73
|
-
/* @__PURE__ */(0,
|
|
70
|
+
/* @__PURE__ */(0,Vd.jsx)("text",{x:e,y:o.y+12,fontSize:13,fontWeight:600,fill:t.textColor,style:{pointerEvents:"none"},children:o.descriptor},`bl-${o.motif}`)),r.push(
|
|
74
71
|
/* @__PURE__ */
|
|
75
|
-
/* @__PURE__ */(0,
|
|
72
|
+
/* @__PURE__ */(0,Vd.jsx)("text",{x:e,y:o.y+27,fontSize:11,fill:t.subText,style:{pointerEvents:"none"},children:`×${o.count} · ${o.directed?"converges to 1 sink":"branches to ≥2 sinks"}`},`bc-${o.motif}`))}r.length&&n.push(
|
|
76
73
|
/* @__PURE__ */
|
|
77
|
-
/* @__PURE__ */(0,
|
|
74
|
+
/* @__PURE__ */(0,Vd.jsx)(Bd.NetworkPerspectiveBillboard,{x:o.x,y:o.y,z:0,children:r},`header-${o.motif}`))}if(t.showLegend){const e=t.plot.x+t.plot.width-168,i=t.plot.y-2;n.push(
|
|
78
75
|
/* @__PURE__ */
|
|
79
|
-
/* @__PURE__ */(0,
|
|
76
|
+
/* @__PURE__ */(0,Vd.jsxs)("g",{style:{pointerEvents:"none"},children:[
|
|
80
77
|
/* @__PURE__ */
|
|
81
|
-
/* @__PURE__ */(0,
|
|
78
|
+
/* @__PURE__ */(0,Vd.jsx)("circle",{cx:e,cy:i,r:5,fill:t.convergeColor}),
|
|
82
79
|
/* @__PURE__ */
|
|
83
|
-
/* @__PURE__ */(0,
|
|
80
|
+
/* @__PURE__ */(0,Vd.jsx)("text",{x:e+10,y:i+4,fontSize:11,fill:t.subText,children:"converges (1 sink)"}),
|
|
84
81
|
/* @__PURE__ */
|
|
85
|
-
/* @__PURE__ */(0,
|
|
82
|
+
/* @__PURE__ */(0,Vd.jsx)("path",{d:(o=e,r=i+18,`M${o},${r-5} L${o+5},${r} L${o},${r+5} L${o-5},${r} Z`),fill:t.branchColor}),
|
|
86
83
|
/* @__PURE__ */
|
|
87
|
-
/* @__PURE__ */(0,
|
|
88
|
-
return(0,Xd.jsx)("g",{className:"net-ensemble-overlays",children:n})}function Vo(e,t,n={}){const o=n.fingerprintRounds??3,r=[],i=/* @__PURE__ */new Set;for(const t of e)null==t.id||i.has(t.id)||(i.add(t.id),r.push(t.id));const{components:s}=Qo(r,t,o),a=s.map(e=>({ids:[...e.ids],nodeCount:e.nodeCount,edgeCount:e.edgeCount,sinkCount:e.sinkCount,sourceCount:e.sourceCount,directed:e.directed,motif:e.motif,descriptor:Uo(e)})),c=/* @__PURE__ */new Map;for(const e of a){const t=c.get(e.motif);t?t.count+=1:c.set(e.motif,{motif:e.motif,descriptor:e.descriptor,count:1,directed:e.directed})}return{components:a,motifs:[...c.values()].sort((e,t)=>t.count-e.count),directedCount:a.filter(e=>e.directed).length,branchingCount:a.filter(e=>!e.directed).length}}function Go(e){return Po(e).toString(36)}function _o(e){return"string"==typeof e?e:e?.id}function Ho(e,t,n,o,r){const i=new Set(e);let s=/* @__PURE__ */new Map;for(const o of e){let e=0,r=0;for(const e of t.get(o)??[])i.has(e)&&(r+=1);for(const t of n.get(o)??[])i.has(t)&&(e+=1);s.set(o,`${e}:${r}`)}for(let o=0;o<r;o+=1){const o=/* @__PURE__ */new Map;for(const r of e){const e=[];for(const n of t.get(r)??[])i.has(n)&&e.push(s.get(n));const a=[];for(const e of n.get(r)??[])i.has(e)&&a.push(s.get(e));e.sort(),a.sort(),o.set(r,Go(`${s.get(r)}>${e.join(",")}<${a.join(",")}`))}s=o}const a=e.map(e=>s.get(e)).sort();return Go(`${e.length}#${o}#${a.join(";")}`)}function Xo(e,t,n,o,r){function i(e){let t=0,r=0;for(const o of n.get(e)??[]){const e=h.get(o);f.has(o)&&e&&(t+=e.x,r+=1)}return r>0?t/r:o.x+u/2}const{layer:s,layerCount:a}=e,c=Array.from({length:a},()=>[]);for(const t of e.ids)c[s.get(t)].push(t);const l=.14*Math.min(o.width,o.height),u=Math.max(1,o.width-2*l),d=Math.max(1,o.height-2*l),h=/* @__PURE__ */new Map,f=new Set(e.ids);for(let e=0;e<a;e+=1){let t=c[e];e>0&&(t=[...t].sort((e,t)=>i(e)-i(t)));const n=t.length,r=o.y+l+(1===a?.5:e/(a-1))*d;t.forEach((e,t)=>{const i=o.x+l+(1===n?.5:t/(n-1))*u;h.set(e,{x:i,y:r})})}const m=c.reduce((e,t)=>Math.max(e,t.length),1),p=me(Math.min(r,u/(2.4*m),d/(2.4*a)),1.4,r),g=e.ids.map(e=>{const t=h.get(e);return{id:e,cx:t.x,cy:t.y,r:p,datum:Se({id:e}),category:""}}),y=[];for(const n of e.ids){const e=h.get(n);for(const o of t.get(n)??[]){if(!f.has(o))continue;const t=h.get(o);y.push({source:n,target:o,x1:e.x,y1:e.y,x2:t.x,y2:t.y})}}return{nodes:g,edges:y}}function Uo(e){const{nodeCount:t,edgeCount:n,sinkCount:o,sourceCount:r}=e;return 1===t?"isolate":2===t&&1===n?"pair":1===r&&1===o&&n===t-1?`chain of ${t}`:e.directed&&1===r&&n>t-1?"diamond / mesh":e.directed?`converging (${t})`:`branching → ${o}`}function Ko(e,t){const n=new Set(e),o=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map;for(const t of e)o.set(t,/* @__PURE__ */new Set),r.set(t,/* @__PURE__ */new Set),i.set(t,/* @__PURE__ */new Set);for(const e of t){const t=e.source,s=e.target;n.has(t)&&n.has(s)&&t!==s&&(o.get(t).has(s)||(o.get(t).add(s),r.get(s).add(t),i.get(t).add(s),i.get(s).add(t)))}return{outAdj:o,inAdj:r,undirected:i}}function Zo(e,t,n,o,r){const i=/* @__PURE__ */new Set,s=[];for(const a of e){if(i.has(a))continue;const e=[a];i.add(a);const c=[];for(;e.length;){const t=e.pop();c.push(t);for(const n of o.get(t)??[])i.has(n)||(i.add(n),e.push(n))}c.sort();const l=Eo(c,t),{sinkCount:u,sourceCount:d}=l;let h=0;for(const e of c)h+=t.get(e).size;s.push({...l,ids:c,nodeCount:c.length,edgeCount:h,sinkCount:u,sourceCount:d,directed:1===u,motif:Ho(c,t,n,h,r)})}return s}function Qo(e,t,n){const o=[...e].sort(),r=t.map(e=>[e.source,e.target]).sort((e,t)=>e[0]<t[0]?-1:e[0]>t[0]?1:e[1]<t[1]?-1:e[1]>t[1]?1:0),i=JSON.stringify([n,o,r]);return Ud.getOrCompute(i,()=>{const{outAdj:e,inAdj:t,undirected:s}=Ko(o,r.map(([e,t])=>({source:e,target:t})));return{key:i,outAdj:e,inAdj:t,components:Zo(o,e,t,s,n)}})}function Jo(e,t){const{plot:n}=t,o=n.width,r=(()=>{for(let r=Math.min(t.maxCellSize,o);r>=Math.max(1,t.minCellSize);r-=2){const i=Math.max(1,Math.floor((o+t.cellGap)/(r+t.cellGap)));let s=0;for(const[,n]of e){const e=Math.ceil(n.length/i);s+=t.headerHeight+e*(r+t.cellGap)+t.bandGap}if(s<=n.height)return{cell:r,cols:i}}return null})();if(!r){const t=e.flatMap(([,e])=>e),o=Math.max(1,Math.ceil(Math.sqrt(t.length*n.width/n.height))),r=Math.ceil(t.length/o),i=n.width/o,s=n.height/r;return{bands:[],cells:t.map((e,t)=>({component:e,lod:"glyph",cx:n.x+(t%o+.5)*i,cy:n.y+(Math.floor(t/o)+.5)*s,glyphR:Math.min(i,s)*(e.directed?.36:.28),nodes:[],edges:[]}))}}const{cell:i,cols:s}=r,a=[],c=[];let l=n.y;for(const[r,u]of e){const e=Math.ceil(u.length/s),d=l,h=d+t.headerHeight,f=i>=t.minCellForFull;u.forEach((e,o)=>{const r=o%s,c=Math.floor(o/s),l=n.x+r*(i+t.cellGap),u=h+c*(i+t.cellGap),d={x:l,y:u,width:i,height:i};if(f){const n=Xo(e,t.outAdj,t.inAdj,d,t.nodeRadius);a.push({component:e,lod:"full",cx:l+i/2,cy:u+i/2,glyphR:0,nodes:n.nodes,edges:n.edges})}else a.push({component:e,lod:"glyph",cx:l+i/2,cy:u+i/2,glyphR:Math.max(2.5,.36*i),nodes:[],edges:[]})});const m=er(u[0],t,{x:n.x,y:d+2,width:Math.min(t.headerHeight-6,40),height:t.headerHeight-6});c.push({motif:r,descriptor:Uo(u[0]),count:u.length,directed:u[0].directed,x:n.x,y:d,width:o,height:t.headerHeight+e*(i+t.cellGap),contentWidth:Math.min(u.length,s)*(i+t.cellGap)-t.cellGap,exemplar:m}),l=h+e*(i+t.cellGap)+t.bandGap}return{cells:a,bands:c}}function er(e,t,n){return e?Xo(e,t.outAdj,t.inAdj,n,3):null}function tr(e){return ye(e)??e}function nr(e){return"string"==typeof e?e:e.id}function or(e,t){const n=Number(e);return Number.isFinite(n)&&n>0?n:t}function rr(e){return String(Math.round(100*e)/100)}function ir(e,t){if(e.length<2)return"";let n=`M${rr(e[0][0])},${rr(e[0][1])}`;for(let o=1;o<e.length-1;o+=1){const r=e[o-1],i=e[o],s=e[o+1],a=Math.hypot(i[0]-r[0],i[1]-r[1]),c=Math.hypot(s[0]-i[0],s[1]-i[1]),l=Math.min(t,a/2,c/2);if(l<=0){n+=`L${rr(i[0])},${rr(i[1])}`;continue}const u=[(i[0]-r[0])/a,(i[1]-r[1])/a],d=[(s[0]-i[0])/c,(s[1]-i[1])/c],h=[i[0]-u[0]*l,i[1]-u[1]*l],f=[i[0]+d[0]*l,i[1]+d[1]*l];n+=`L${rr(h[0])},${rr(h[1])}Q${rr(i[0])},${rr(i[1])} ${rr(f[0])},${rr(f[1])}`}const o=e[e.length-1];return`${n}L${rr(o[0])},${rr(o[1])}`}function sr(e,t,n,o,r=.92*o){const i=Math.cos(n),s=Math.sin(n),a=-s,c=[e+i*o*.56,t+s*o*.56],l=e-i*o*.44,u=t-s*o*.44,d=[l+a*r*.5,u+i*r*.5],h=[l-a*r*.5,u-i*r*.5];return`M${rr(c[0])},${rr(c[1])}L${rr(d[0])},${rr(d[1])}L${rr(h[0])},${rr(h[1])}Z`}function ar(e,t){return`${t}\0${e}`}function cr(e,t,n){const o=/* @__PURE__ */new Map;for(const r of e){const e=nr(r.source),i=nr(r.target),s=t.get(e),a=t.get(i);if(null==s||null==a)continue;const c=tr(r),l=or("function"==typeof n.valueAccessor?n.valueAccessor(c):ge(c,n.valueAccessor??"value",r.value??1),0);if(l<=0)continue;let u=o.get(e);u||(u=/* @__PURE__ */new Map,o.set(e,u));const d=u.get(i);d?(d.value+=l,d.edgeCount+=1,d.memberEdges.push(c)):u.set(i,{key:`${s}-${a}`,source:e,target:i,sourceIndex:s,targetIndex:a,value:l,edgeCount:1,memberEdges:[c],datum:c,width:1,color:""})}const r=[...o.values()].flatMap(e=>[...e.values()]);for(const e of r)e.datum=be(t=>{for(const[n,o]of Object.entries(e.memberEdges[0]??{}))t(n,o);t("source",e.source),t("target",e.target),t("value",e.value),t("edgeCount",e.edgeCount),t("internal",e.source===e.target),t("memberEdges",e.memberEdges)});return r}function lr(e,t,n){const o=/* @__PURE__ */new Map,r=(e,t)=>{const n=o.get(e);n?n.push(t):o.set(e,[t])};for(const t of e)r(ar(t.source,t.targetIndex>=t.sourceIndex?"out-right":"out-left"),t),r(ar(t.target,t.sourceIndex<t.targetIndex?"in-top":"in-bottom"),t);for(const[e,t]of o){const n=e.startsWith("out-");t.sort((e,t)=>(n?e.targetIndex:e.sourceIndex)-(n?t.targetIndex:t.sourceIndex)||e.key.localeCompare(t.key))}const i=dr(t,n);let s=null==n.flowScale?Number.POSITIVE_INFINITY:Math.max(0,n.flowScale);if(null==n.flowScale){for(const e of o.values()){const o=e.reduce((e,t)=>e+t.value,0),r=hr(e.length,t,n),a=Math.max(.1,i-r*Math.max(0,e.length-1));o>0&&(s=Math.min(s,a/o))}Number.isFinite(s)||(s=1)}const a=Math.max(0,n.minFlowWidth??1.25),c=Math.max(a,n.maxFlowWidth??Number.POSITIVE_INFINITY);for(const t of e)t.width=Math.min(c,Math.max(a,t.value*s));let l=1;for(const e of o.values()){const o=e.reduce((e,t)=>e+t.width,0),r=hr(e.length,t,n),s=Math.max(.1,i-r*Math.max(0,e.length-1));o>0&&(l=Math.min(l,s/o))}if(l<1)for(const t of e)t.width*=l;return o}function ur(e,t,n,o){const r=/* @__PURE__ */new Map;for(const[i,s]of e){const e=i.slice(i.indexOf("\0")+1),a=t.get(e);if(!a)continue;const c=i.startsWith("out-")?a.cy:a.cx,l=hr(s.length,n,o);let u=c-(s.reduce((e,t)=>e+t.width,0)+l*Math.max(0,s.length-1))/2;for(const e of s){const t=u+e.width/2,n=i.startsWith("out-");r.set(`${e.key}:${n?"source":"target"}`,t),u+=e.width+l}}return r}function dr(e,t){return Math.max(1,e-2*Math.max(0,t.portPadding??4))}function hr(e,t,n){if(e<=1)return 0;const o=Math.max(0,n.flowGap??.75),r=dr(t,n),i=Math.min(.1,r);return Math.min(o,Math.max(0,(r-i)/(e-1)))}function fr(e,t,n){const o="function"==typeof t?t(e):ge(e,t,n);return null==o||""===o?n:String(o)}function mr(e,t){const n="function"==typeof t?t(e):ge(e,t,void 0);if(null!=n){if("object"==typeof n){const e=n.id;return null==e?void 0:String(e)}return String(n)}}function pr(e,t){const n="function"==typeof t?t(e):ge(e,t,1);return Number(n)}function gr(e,t){if(!t.has(e))return t.add(e),e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;const o=`${e}-${n}`;return t.add(o),o}function yr(e,t,n={}){const o=n.nodeIdAccessor??"id",r=n.groupAccessor??"group",i=n.labelAccessor??"label",s=n.sourceAccessor??"source",a=n.targetAccessor??"target",c=n.valueAccessor??"value",l=new Set(n.expandedGroups??[]),u=n.includeInternalFlows??!0,d=[],h=/* @__PURE__ */new Map,f=/* @__PURE__ */new Map;for(const t of e){const e=fr(t,o,String(d.length));if(h.has(e))continue;const n=fr(t,i,e),s=fr(t,r,e),a={id:e,label:n,group:s,datum:t};d.push(a),h.set(e,a);const c=f.get(s);c?c.push(a):f.set(s,[a])}const m=new Set(d.map(e=>e.id)),p=[],g=/* @__PURE__ */new Map,y=/* @__PURE__ */new Map,x=[];for(const[e,t]of f){if(!l.has(e)&&(!0===n.collapseSingletons||t.length>1)){const o=gr(`${n.groupIdPrefix??"group:"}${e}`,m),r={id:o,label:e,group:e,aggregate:!0,memberIds:t.map(e=>e.id),memberCount:t.length,internalValue:0,incomingValue:0,outgoingValue:0};p.push(r),g.set(o,r);for(const e of t)y.set(e.id,o);x.push({group:e,nodeId:o,label:e,collapsed:!0,memberIds:[...r.memberIds],internalValue:0,incomingValue:0,outgoingValue:0});continue}for(const n of t){const t={...n.datum,id:n.id,label:n.label,group:e,aggregate:!1,memberIds:[n.id],memberCount:1,internalValue:0,incomingValue:0,outgoingValue:0};p.push(t),g.set(t.id,t),y.set(n.id,t.id)}x.push({group:e,nodeId:null,label:e,collapsed:!1,memberIds:t.map(e=>e.id),internalValue:0,incomingValue:0,outgoingValue:0})}const b=new Map(x.map(e=>[e.group,e])),w=/* @__PURE__ */new Map;let M=0;for(const e of t){const t=mr(e,s),n=mr(e,a),o=pr(e,c),r=null==t?void 0:y.get(t),i=null==n?void 0:y.get(n);if(!r||!i||!Number.isFinite(o)||o<=0){M+=1;continue}const l=h.get(t)?.group,u=h.get(n)?.group;if(l&&u&&l===u){const e=b.get(l);e&&(e.internalValue+=o)}else{if(l){const e=b.get(l);e&&(e.outgoingValue+=o)}if(u){const e=b.get(u);e&&(e.incomingValue+=o)}}let d=w.get(r);d||(d=/* @__PURE__ */new Map,w.set(r,d));const f=d.get(i);f?(f.value+=o,f.edgeCount+=1,f.memberEdges.push(e)):d.set(i,{source:r,target:i,value:o,edgeCount:1,internal:r===i,memberEdges:[e]})}const v=[...w.values()].flatMap(e=>[...e.values()]);for(const e of v){const t=g.get(e.source),n=g.get(e.target);e.internal?t&&(t.internalValue+=e.value):(t&&(t.outgoingValue+=e.value),n&&(n.incomingValue+=e.value))}return{nodes:p,edges:u?v:v.filter(e=>!e.internal),groups:x,omittedEdgeCount:M}}function xr(e,t){const n=t.showEnclosures?e.enclosures.map(e=>({x:e.x,y:e.y,width:e.w,height:e.h})):[];if(t.showColumnHeaders)for(const o of e.colBands){const e=eh((t.columnLabel??String)(o.col),t.headerFontSize)/2;n.push({x:o.x+o.w/2,y:t.headerY,z:0,extent:[e,e,t.headerFontSize,4]})}if(t.showRowLabels)for(const[o,r]of e.rowLabelY){const e=eh((t.rowLabel??String)(o),t.labelFontSize);n.push({x:t.labelX,y:r,z:0,extent:[e,0,t.labelFontSize,t.labelFontSize]})}for(const e of t.callouts){const t=eh("string"==typeof e.label?e.label:"",e.fontSize??11)/2,o=e.labelX-e.markX,r=e.labelY-e.markY;n.push({x:e.markX,y:e.markY,extent:[Math.max(0,t-o),Math.max(0,o+t),Math.max(0,14-r),Math.max(0,r)]})}return n}function br(e){if(null==e)return NaN;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();const t=String(e),n=Number(t);if(!Number.isNaN(n)&&""!==t.trim())return n;const o=Date.parse(t);return Number.isNaN(o)?NaN:o}function wr(e,t,n){return e<t?t:e>n?n:e}function Mr(e){let t=e>>>0||1;return()=>(t=Math.imul(t,1664525)+1013904223>>>0,t/4294967296)}function vr(e,t){const n=/* @__PURE__ */new Map;for(const t of e){let e=n.get(t.col);e||(e=[],n.set(t.col,e)),e.push(t)}const o=t.columnOrder.filter(e=>n.has(e)),r=t.columnGap*Math.max(0,o.length-1),i=Math.max(1,t.innerW-r),s=t.proportionExponent,a=o.map(e=>Math.pow(n.get(e).length,s)),c=a.reduce((e,t)=>e+t,0)||1,l=e=>"uniform"===t.cellSizing?i/o.length:a[e]/c*i,u=/* @__PURE__ */new Map,d=[];let h=t.innerX;for(let e=0;e<o.length;e++)d.push({col:o[e],x:h,w:l(e)}),h+=l(e)+t.columnGap;let f=1;const m=/* @__PURE__ */new Map,p=[],g=(e,t,n,o)=>{let r=m.get(e);r||(r={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},m.set(e,r)),t-o<r.minX&&(r.minX=t-o),t+o>r.maxX&&(r.maxX=t+o),n-o<r.minY&&(r.minY=n-o),n+o>r.maxY&&(r.maxY=n+o)},y=(e,n,o,r,i,s)=>{const a=e.map(e=>({id:e.id,r:e.packR})),c=kr(a,n,o,r,i,t.packPadding,t.iterations,f++);let l=1/0,d=1/0,h=-1/0,m=-1/0;for(const e of a){const t=c.get(e.id);u.set(e.id,{px:t.px,py:t.py}),g(s,t.px,t.py,e.r),t.px-e.r<l&&(l=t.px-e.r),t.px+e.r>h&&(h=t.px+e.r),t.py-e.r<d&&(d=t.py-e.r),t.py+e.r>m&&(m=t.py+e.r)}return Number.isFinite(l)?{x:l-rh,y:d-rh,w:h-l+2*rh,h:m-d+2*rh}:null};if("banded"===t.rowMode){const r=/* @__PURE__ */new Map;for(const t of e)r.set(t.row,(r.get(t.row)??0)+1);const i=t.rowOrder.filter(e=>r.has(e)),a=t.rowGap*Math.max(0,i.length-1),c=Math.max(1,t.innerH-a),l=i.map(e=>Math.pow(r.get(e),s)),h=l.reduce((e,t)=>e+t,0)||1,f=/* @__PURE__ */new Map;let p=t.innerY+t.innerH;for(let e=0;e<i.length;e++){const n="uniform"===t.cellSizing?c/i.length:l[e]/h*c,o=p-n;f.set(i[e],{y:o,h:n}),p=o-t.rowGap}o.forEach((e,t)=>{const o=xe(n.get(e),e=>e.row);for(const e of i){const n=o.get(e),r=f.get(e);n&&r&&y(n,d[t].x,r.y,d[t].w,r.h,e)}});const g=[],x=/* @__PURE__ */new Map;for(const e of i){const t=f.get(e);x.set(e,t.y+t.h/2);const n=m.get(e);n&&Number.isFinite(n.minX)&&g.push({x:n.minX-rh,y:n.minY-rh,w:n.maxX-n.minX+2*rh,h:n.maxY-n.minY+2*rh})}return{positions:u,enclosures:g,colBands:d,rowLabelY:x}}const x=/* @__PURE__ */new Map;o.forEach((e,o)=>{const r=xe(n.get(e),e=>e.row),i=t.rowOrder.filter(e=>r.has(e)),a=t.rowGap*Math.max(0,i.length-1),c=Math.max(1,t.innerH-a),l=i.map(e=>Math.pow(r.get(e).length,s)),u=l.reduce((e,t)=>e+t,0)||1;let h=t.innerY+t.innerH;i.forEach((e,n)=>{const s="uniform"===t.cellSizing?c/i.length:l[n]/u*c,a=h-s,f=y(r.get(e),d[o].x,a,d[o].w,s,e);if(f){p.push(f);const t=x.get(e)??{sum:0,n:0};t.sum+=f.y+f.h/2,t.n+=1,x.set(e,t)}h=a-t.rowGap})});const b=/* @__PURE__ */new Map;for(const[e,t]of x)b.set(e,t.sum/t.n);return{positions:u,enclosures:p,colBands:d,rowLabelY:b}}function kr(e,t,n,o,r,i,s,a){const c=t+o/2,l=n+r/2,u=/* @__PURE__ */new Map,d=e.length;if(0===d)return u;if(1===d)return u.set(e[0].id,{px:c,py:l}),u;const h=Mr(a),f=new Float64Array(d);let m=0;for(let t=0;t<d;t++)f[t]=e[t].r+i,f[t]>m&&(m=f[t]);const p=Math.max(1,Math.round(Math.sqrt(d*o/Math.max(1,r)))),g=new Float64Array(d),y=new Float64Array(d),x=o/p,b=r/Math.ceil(d/p);for(let e=0;e<d;e++){const o=e%p,r=Math.floor(e/p);g[e]=t+(o+.3+.4*h())*x,y[e]=n+(r+.3+.4*h())*b}const w=Math.max(0,Math.min(s,14)),M=Math.max(1,2*m),v=/* @__PURE__ */new Map,k=Math.max(1,Math.ceil(o/M)+3),$=(e,t)=>(t+1)*k+(e+1);for(let e=0;e<w;e++){v.clear();for(let e=0;e<d;e++){const o=$(Math.floor((g[e]-t)/M),Math.floor((y[e]-n)/M)),r=v.get(o);r?r.push(e):v.set(o,[e])}for(let e=0;e<d;e++){const o=Math.floor((g[e]-t)/M),r=Math.floor((y[e]-n)/M);for(let t=-1;t<=1;t++)for(let n=-1;n<=1;n++){const i=v.get($(o+t,r+n));if(i)for(let t=0;t<i.length;t++){const n=i[t];if(n<=e)continue;let o=g[n]-g[e],r=y[n]-y[e];const s=f[e]+f[n],a=o*o+r*r;if(!(a>=s*s))if(a>1e-9){const t=Math.sqrt(a),i=(s-t)/2;o/=t,r/=t,g[e]-=o*i,y[e]-=r*i,g[n]+=o*i,y[n]+=r*i}else{const t=2.39996323*e;g[e]+=Math.cos(t)*f[e],y[e]+=Math.sin(t)*f[e]}}}}for(let e=0;e<d;e++){const i=f[e],s=t+i,a=t+o-i,u=n+i,d=n+r-i;g[e]=a>s?wr(g[e],s,a):c,y[e]=d>u?wr(y[e],u,d):l}}for(let t=0;t<d;t++)u.set(e[t].id,{px:g[t],py:y[t]});return u}function $r(e){let t=2166136261;for(const n of e)t=Po(n.row,Po(n.col,Po(n.id,t))),t^=Math.round(8*n.packR),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function Sr(e,t){const n=t.columnLabel??(e=>e),o=t.rowLabel??(e=>e),r=(e,t,n,o)=>/* @__PURE__ */ /* @__PURE__ */(0,th.jsx)(Pn,{x:t,y:n,onGround:!0,children:o},e),i=(e,t,n,o,r)=>/* @__PURE__ */ /* @__PURE__ */(0,th.jsx)(Pn,{x:t,y:n,z:o,children:r},e);/* @__PURE__ */ /* @__PURE__ */
|
|
89
|
-
return(0,
|
|
84
|
+
/* @__PURE__ */(0,Vd.jsx)("text",{x:e+10,y:i+22,fontSize:11,fill:t.subText,children:"branches (≥2 sinks)"})]},"net-legend"))}var o,r;/* @__PURE__ */ /* @__PURE__ */
|
|
85
|
+
return(0,Vd.jsx)("g",{className:"net-ensemble-overlays",children:n})}function Wo(e,t,n={}){const o=n.fingerprintRounds??3,r=[],i=/* @__PURE__ */new Set;for(const t of e)null==t.id||i.has(t.id)||(i.add(t.id),r.push(t.id));const{components:s}=Ho(r,t,o),a=s.map(e=>({ids:[...e.ids],nodeCount:e.nodeCount,edgeCount:e.edgeCount,sinkCount:e.sinkCount,sourceCount:e.sourceCount,directed:e.directed,motif:e.motif,descriptor:Vo(e)})),c=/* @__PURE__ */new Map;for(const e of a){const t=c.get(e.motif);t?t.count+=1:c.set(e.motif,{motif:e.motif,descriptor:e.descriptor,count:1,directed:e.directed})}return{components:a,motifs:[...c.values()].sort((e,t)=>t.count-e.count),directedCount:a.filter(e=>e.directed).length,branchingCount:a.filter(e=>!e.directed).length}}function qo(e){return Co(e).toString(36)}function Do(e){return"string"==typeof e?e:e?.id}function Bo(e,t,n,o,r){const i=new Set(e);let s=/* @__PURE__ */new Map;for(const o of e){let e=0,r=0;for(const e of t.get(o)??[])i.has(e)&&(r+=1);for(const t of n.get(o)??[])i.has(t)&&(e+=1);s.set(o,`${e}:${r}`)}for(let o=0;o<r;o+=1){const o=/* @__PURE__ */new Map;for(const r of e){const e=[];for(const n of t.get(r)??[])i.has(n)&&e.push(s.get(n));const a=[];for(const e of n.get(r)??[])i.has(e)&&a.push(s.get(e));e.sort(),a.sort(),o.set(r,qo(`${s.get(r)}>${e.join(",")}<${a.join(",")}`))}s=o}const a=e.map(e=>s.get(e)).sort();return qo(`${e.length}#${o}#${a.join(";")}`)}function Yo(e,t,n,o,r){function i(e){let t=0,r=0;for(const o of n.get(e)??[]){const e=h.get(o);f.has(o)&&e&&(t+=e.x,r+=1)}return r>0?t/r:o.x+u/2}const{layer:s,layerCount:a}=e,c=Array.from({length:a},()=>[]);for(const t of e.ids)c[s.get(t)].push(t);const l=.14*Math.min(o.width,o.height),u=Math.max(1,o.width-2*l),d=Math.max(1,o.height-2*l),h=/* @__PURE__ */new Map,f=new Set(e.ids);for(let e=0;e<a;e+=1){let t=c[e];e>0&&(t=[...t].sort((e,t)=>i(e)-i(t)));const n=t.length,r=o.y+l+(1===a?.5:e/(a-1))*d;t.forEach((e,t)=>{const i=o.x+l+(1===n?.5:t/(n-1))*u;h.set(e,{x:i,y:r})})}const m=c.reduce((e,t)=>Math.max(e,t.length),1),p=me(Math.min(r,u/(2.4*m),d/(2.4*a)),1.4,r),g=e.ids.map(e=>{const t=h.get(e);return{id:e,cx:t.x,cy:t.y,r:p,datum:Se({id:e}),category:""}}),y=[];for(const n of e.ids){const e=h.get(n);for(const o of t.get(n)??[]){if(!f.has(o))continue;const t=h.get(o);y.push({source:n,target:o,x1:e.x,y1:e.y,x2:t.x,y2:t.y})}}return{nodes:g,edges:y}}function Vo(e){const{nodeCount:t,edgeCount:n,sinkCount:o,sourceCount:r}=e;return 1===t?"isolate":2===t&&1===n?"pair":1===r&&1===o&&n===t-1?`chain of ${t}`:e.directed&&1===r&&n>t-1?"diamond / mesh":e.directed?`converging (${t})`:`branching → ${o}`}function Go(e,t){const n=new Set(e),o=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map,i=/* @__PURE__ */new Map;for(const t of e)o.set(t,/* @__PURE__ */new Set),r.set(t,/* @__PURE__ */new Set),i.set(t,/* @__PURE__ */new Set);for(const e of t){const t=e.source,s=e.target;n.has(t)&&n.has(s)&&t!==s&&(o.get(t).has(s)||(o.get(t).add(s),r.get(s).add(t),i.get(t).add(s),i.get(s).add(t)))}return{outAdj:o,inAdj:r,undirected:i}}function _o(e,t,n,o,r){const i=/* @__PURE__ */new Set,s=[];for(const a of e){if(i.has(a))continue;const e=[a];i.add(a);const c=[];for(;e.length;){const t=e.pop();c.push(t);for(const n of o.get(t)??[])i.has(n)||(i.add(n),e.push(n))}c.sort();const l=Ao(c,t),{sinkCount:u,sourceCount:d}=l;let h=0;for(const e of c)h+=t.get(e).size;s.push({...l,ids:c,nodeCount:c.length,edgeCount:h,sinkCount:u,sourceCount:d,directed:1===u,motif:Bo(c,t,n,h,r)})}return s}function Ho(e,t,n){const o=[...e].sort(),r=t.map(e=>[e.source,e.target]).sort((e,t)=>e[0]<t[0]?-1:e[0]>t[0]?1:e[1]<t[1]?-1:e[1]>t[1]?1:0),i=JSON.stringify([n,o,r]);return Gd.getOrCompute(i,()=>{const{outAdj:e,inAdj:t,undirected:s}=Go(o,r.map(([e,t])=>({source:e,target:t})));return{key:i,outAdj:e,inAdj:t,components:_o(o,e,t,s,n)}})}function Xo(e,t){const{plot:n}=t,o=n.width,r=(()=>{for(let r=Math.min(t.maxCellSize,o);r>=Math.max(1,t.minCellSize);r-=2){const i=Math.max(1,Math.floor((o+t.cellGap)/(r+t.cellGap)));let s=0;for(const[,n]of e){const e=Math.ceil(n.length/i);s+=t.headerHeight+e*(r+t.cellGap)+t.bandGap}if(s<=n.height)return{cell:r,cols:i}}return null})();if(!r){const t=e.flatMap(([,e])=>e),o=Math.max(1,Math.ceil(Math.sqrt(t.length*n.width/n.height))),r=Math.ceil(t.length/o),i=n.width/o,s=n.height/r;return{bands:[],cells:t.map((e,t)=>({component:e,lod:"glyph",cx:n.x+(t%o+.5)*i,cy:n.y+(Math.floor(t/o)+.5)*s,glyphR:Math.min(i,s)*(e.directed?.36:.28),nodes:[],edges:[]}))}}const{cell:i,cols:s}=r,a=[],c=[];let l=n.y;for(const[r,u]of e){const e=Math.ceil(u.length/s),d=l,h=d+t.headerHeight,f=i>=t.minCellForFull;u.forEach((e,o)=>{const r=o%s,c=Math.floor(o/s),l=n.x+r*(i+t.cellGap),u=h+c*(i+t.cellGap),d={x:l,y:u,width:i,height:i};if(f){const n=Yo(e,t.outAdj,t.inAdj,d,t.nodeRadius);a.push({component:e,lod:"full",cx:l+i/2,cy:u+i/2,glyphR:0,nodes:n.nodes,edges:n.edges})}else a.push({component:e,lod:"glyph",cx:l+i/2,cy:u+i/2,glyphR:Math.max(2.5,.36*i),nodes:[],edges:[]})});const m=Uo(u[0],t,{x:n.x,y:d+2,width:Math.min(t.headerHeight-6,40),height:t.headerHeight-6});c.push({motif:r,descriptor:Vo(u[0]),count:u.length,directed:u[0].directed,x:n.x,y:d,width:o,height:t.headerHeight+e*(i+t.cellGap),contentWidth:Math.min(u.length,s)*(i+t.cellGap)-t.cellGap,exemplar:m}),l=h+e*(i+t.cellGap)+t.bandGap}return{cells:a,bands:c}}function Uo(e,t,n){return e?Yo(e,t.outAdj,t.inAdj,n,3):null}function Ko(e){return ye(e)??e}function Zo(e){return"string"==typeof e?e:e.id}function Qo(e,t){const n=Number(e);return Number.isFinite(n)&&n>0?n:t}function Jo(e){return String(Math.round(100*e)/100)}function er(e,t){if(e.length<2)return"";let n=`M${Jo(e[0][0])},${Jo(e[0][1])}`;for(let o=1;o<e.length-1;o+=1){const r=e[o-1],i=e[o],s=e[o+1],a=Math.hypot(i[0]-r[0],i[1]-r[1]),c=Math.hypot(s[0]-i[0],s[1]-i[1]),l=Math.min(t,a/2,c/2);if(l<=0){n+=`L${Jo(i[0])},${Jo(i[1])}`;continue}const u=[(i[0]-r[0])/a,(i[1]-r[1])/a],d=[(s[0]-i[0])/c,(s[1]-i[1])/c],h=[i[0]-u[0]*l,i[1]-u[1]*l],f=[i[0]+d[0]*l,i[1]+d[1]*l];n+=`L${Jo(h[0])},${Jo(h[1])}Q${Jo(i[0])},${Jo(i[1])} ${Jo(f[0])},${Jo(f[1])}`}const o=e[e.length-1];return`${n}L${Jo(o[0])},${Jo(o[1])}`}function tr(e,t,n,o,r=.92*o){const i=Math.cos(n),s=Math.sin(n),a=-s,c=[e+i*o*.56,t+s*o*.56],l=e-i*o*.44,u=t-s*o*.44,d=[l+a*r*.5,u+i*r*.5],h=[l-a*r*.5,u-i*r*.5];return`M${Jo(c[0])},${Jo(c[1])}L${Jo(d[0])},${Jo(d[1])}L${Jo(h[0])},${Jo(h[1])}Z`}function nr(e,t){return`${t}\0${e}`}function or(e,t,n){const o=/* @__PURE__ */new Map;for(const r of e){const e=Zo(r.source),i=Zo(r.target),s=t.get(e),a=t.get(i);if(null==s||null==a)continue;const c=Ko(r),l=Qo("function"==typeof n.valueAccessor?n.valueAccessor(c):ge(c,n.valueAccessor??"value",r.value??1),0);if(l<=0)continue;let u=o.get(e);u||(u=/* @__PURE__ */new Map,o.set(e,u));const d=u.get(i);d?(d.value+=l,d.edgeCount+=1,d.memberEdges.push(c)):u.set(i,{key:`${s}-${a}`,source:e,target:i,sourceIndex:s,targetIndex:a,value:l,edgeCount:1,memberEdges:[c],datum:c,width:1,color:""})}const r=[...o.values()].flatMap(e=>[...e.values()]);for(const e of r)e.datum=be(t=>{for(const[n,o]of Object.entries(e.memberEdges[0]??{}))t(n,o);t("source",e.source),t("target",e.target),t("value",e.value),t("edgeCount",e.edgeCount),t("internal",e.source===e.target),t("memberEdges",e.memberEdges)});return r}function rr(e,t,n){const o=/* @__PURE__ */new Map,r=(e,t)=>{const n=o.get(e);n?n.push(t):o.set(e,[t])};for(const t of e)r(nr(t.source,t.targetIndex>=t.sourceIndex?"out-right":"out-left"),t),r(nr(t.target,t.sourceIndex<t.targetIndex?"in-top":"in-bottom"),t);for(const[e,t]of o){const n=e.startsWith("out-");t.sort((e,t)=>(n?e.targetIndex:e.sourceIndex)-(n?t.targetIndex:t.sourceIndex)||e.key.localeCompare(t.key))}const i=sr(t,n);let s=null==n.flowScale?Number.POSITIVE_INFINITY:Math.max(0,n.flowScale);if(null==n.flowScale){for(const e of o.values()){const o=e.reduce((e,t)=>e+t.value,0),r=ar(e.length,t,n),a=Math.max(.1,i-r*Math.max(0,e.length-1));o>0&&(s=Math.min(s,a/o))}Number.isFinite(s)||(s=1)}const a=Math.max(0,n.minFlowWidth??1.25),c=Math.max(a,n.maxFlowWidth??Number.POSITIVE_INFINITY);for(const t of e)t.width=Math.min(c,Math.max(a,t.value*s));let l=1;for(const e of o.values()){const o=e.reduce((e,t)=>e+t.width,0),r=ar(e.length,t,n),s=Math.max(.1,i-r*Math.max(0,e.length-1));o>0&&(l=Math.min(l,s/o))}if(l<1)for(const t of e)t.width*=l;return o}function ir(e,t,n,o){const r=/* @__PURE__ */new Map;for(const[i,s]of e){const e=i.slice(i.indexOf("\0")+1),a=t.get(e);if(!a)continue;const c=i.startsWith("out-")?a.cy:a.cx,l=ar(s.length,n,o);let u=c-(s.reduce((e,t)=>e+t.width,0)+l*Math.max(0,s.length-1))/2;for(const e of s){const t=u+e.width/2,n=i.startsWith("out-");r.set(`${e.key}:${n?"source":"target"}`,t),u+=e.width+l}}return r}function sr(e,t){return Math.max(1,e-2*Math.max(0,t.portPadding??4))}function ar(e,t,n){if(e<=1)return 0;const o=Math.max(0,n.flowGap??.75),r=sr(t,n),i=Math.min(.1,r);return Math.min(o,Math.max(0,(r-i)/(e-1)))}function cr(e,t,n){const o="function"==typeof t?t(e):ge(e,t,n);return null==o||""===o?n:String(o)}function lr(e,t){const n="function"==typeof t?t(e):ge(e,t,void 0);if(null!=n){if("object"==typeof n){const e=n.id;return null==e?void 0:String(e)}return String(n)}}function ur(e,t){const n="function"==typeof t?t(e):ge(e,t,1);return Number(n)}function dr(e,t){if(!t.has(e))return t.add(e),e;let n=2;for(;t.has(`${e}-${n}`);)n+=1;const o=`${e}-${n}`;return t.add(o),o}function hr(e,t,n={}){const o=n.nodeIdAccessor??"id",r=n.groupAccessor??"group",i=n.labelAccessor??"label",s=n.sourceAccessor??"source",a=n.targetAccessor??"target",c=n.valueAccessor??"value",l=new Set(n.expandedGroups??[]),u=n.includeInternalFlows??!0,d=[],h=/* @__PURE__ */new Map,f=/* @__PURE__ */new Map;for(const t of e){const e=cr(t,o,String(d.length));if(h.has(e))continue;const n=cr(t,i,e),s=cr(t,r,e),a={id:e,label:n,group:s,datum:t};d.push(a),h.set(e,a);const c=f.get(s);c?c.push(a):f.set(s,[a])}const m=new Set(d.map(e=>e.id)),p=[],g=/* @__PURE__ */new Map,y=/* @__PURE__ */new Map,x=[];for(const[e,t]of f){if(!l.has(e)&&(!0===n.collapseSingletons||t.length>1)){const o=dr(`${n.groupIdPrefix??"group:"}${e}`,m),r={id:o,label:e,group:e,aggregate:!0,memberIds:t.map(e=>e.id),memberCount:t.length,internalValue:0,incomingValue:0,outgoingValue:0};p.push(r),g.set(o,r);for(const e of t)y.set(e.id,o);x.push({group:e,nodeId:o,label:e,collapsed:!0,memberIds:[...r.memberIds],internalValue:0,incomingValue:0,outgoingValue:0});continue}for(const n of t){const t={...n.datum,id:n.id,label:n.label,group:e,aggregate:!1,memberIds:[n.id],memberCount:1,internalValue:0,incomingValue:0,outgoingValue:0};p.push(t),g.set(t.id,t),y.set(n.id,t.id)}x.push({group:e,nodeId:null,label:e,collapsed:!1,memberIds:t.map(e=>e.id),internalValue:0,incomingValue:0,outgoingValue:0})}const b=new Map(x.map(e=>[e.group,e])),w=/* @__PURE__ */new Map;let M=0;for(const e of t){const t=lr(e,s),n=lr(e,a),o=ur(e,c),r=null==t?void 0:y.get(t),i=null==n?void 0:y.get(n);if(!r||!i||!Number.isFinite(o)||o<=0){M+=1;continue}const l=h.get(t)?.group,u=h.get(n)?.group;if(l&&u&&l===u){const e=b.get(l);e&&(e.internalValue+=o)}else{if(l){const e=b.get(l);e&&(e.outgoingValue+=o)}if(u){const e=b.get(u);e&&(e.incomingValue+=o)}}let d=w.get(r);d||(d=/* @__PURE__ */new Map,w.set(r,d));const f=d.get(i);f?(f.value+=o,f.edgeCount+=1,f.memberEdges.push(e)):d.set(i,{source:r,target:i,value:o,edgeCount:1,internal:r===i,memberEdges:[e]})}const v=[...w.values()].flatMap(e=>[...e.values()]);for(const e of v){const t=g.get(e.source),n=g.get(e.target);e.internal?t&&(t.internalValue+=e.value):(t&&(t.outgoingValue+=e.value),n&&(n.incomingValue+=e.value))}return{nodes:p,edges:u?v:v.filter(e=>!e.internal),groups:x,omittedEdgeCount:M}}function fr(e,t){const n=t.showEnclosures?e.enclosures.map(e=>({x:e.x,y:e.y,width:e.w,height:e.h})):[];if(t.showColumnHeaders)for(const o of e.colBands){const e=Qd((t.columnLabel??String)(o.col),t.headerFontSize)/2;n.push({x:o.x+o.w/2,y:t.headerY,z:0,extent:[e,e,t.headerFontSize,4]})}if(t.showRowLabels)for(const[o,r]of e.rowLabelY){const e=Qd((t.rowLabel??String)(o),t.labelFontSize);n.push({x:t.labelX,y:r,z:0,extent:[e,0,t.labelFontSize,t.labelFontSize]})}for(const e of t.callouts){const t=Qd("string"==typeof e.label?e.label:"",e.fontSize??11)/2,o=e.labelX-e.markX,r=e.labelY-e.markY;n.push({x:e.markX,y:e.markY,extent:[Math.max(0,t-o),Math.max(0,o+t),Math.max(0,14-r),Math.max(0,r)]})}return n}function mr(e){if(null==e)return NaN;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();const t=String(e),n=Number(t);if(!Number.isNaN(n)&&""!==t.trim())return n;const o=Date.parse(t);return Number.isNaN(o)?NaN:o}function pr(e,t,n){return e<t?t:e>n?n:e}function gr(e){let t=e>>>0||1;return()=>(t=Math.imul(t,1664525)+1013904223>>>0,t/4294967296)}function yr(e,t){const n=/* @__PURE__ */new Map;for(const t of e){let e=n.get(t.col);e||(e=[],n.set(t.col,e)),e.push(t)}const o=t.columnOrder.filter(e=>n.has(e)),r=t.columnGap*Math.max(0,o.length-1),i=Math.max(1,t.innerW-r),s=t.proportionExponent,a=o.map(e=>Math.pow(n.get(e).length,s)),c=a.reduce((e,t)=>e+t,0)||1,l=e=>"uniform"===t.cellSizing?i/o.length:a[e]/c*i,u=/* @__PURE__ */new Map,d=[];let h=t.innerX;for(let e=0;e<o.length;e++)d.push({col:o[e],x:h,w:l(e)}),h+=l(e)+t.columnGap;let f=1;const m=/* @__PURE__ */new Map,p=[],g=(e,t,n,o)=>{let r=m.get(e);r||(r={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},m.set(e,r)),t-o<r.minX&&(r.minX=t-o),t+o>r.maxX&&(r.maxX=t+o),n-o<r.minY&&(r.minY=n-o),n+o>r.maxY&&(r.maxY=n+o)},y=(e,n,o,r,i,s)=>{const a=e.map(e=>({id:e.id,r:e.packR})),c=xr(a,n,o,r,i,t.packPadding,t.iterations,f++);let l=1/0,d=1/0,h=-1/0,m=-1/0;for(const e of a){const t=c.get(e.id);u.set(e.id,{px:t.px,py:t.py}),g(s,t.px,t.py,e.r),t.px-e.r<l&&(l=t.px-e.r),t.px+e.r>h&&(h=t.px+e.r),t.py-e.r<d&&(d=t.py-e.r),t.py+e.r>m&&(m=t.py+e.r)}return Number.isFinite(l)?{x:l-nh,y:d-nh,w:h-l+2*nh,h:m-d+2*nh}:null};if("banded"===t.rowMode){const r=/* @__PURE__ */new Map;for(const t of e)r.set(t.row,(r.get(t.row)??0)+1);const i=t.rowOrder.filter(e=>r.has(e)),a=t.rowGap*Math.max(0,i.length-1),c=Math.max(1,t.innerH-a),l=i.map(e=>Math.pow(r.get(e),s)),h=l.reduce((e,t)=>e+t,0)||1,f=/* @__PURE__ */new Map;let p=t.innerY+t.innerH;for(let e=0;e<i.length;e++){const n="uniform"===t.cellSizing?c/i.length:l[e]/h*c,o=p-n;f.set(i[e],{y:o,h:n}),p=o-t.rowGap}o.forEach((e,t)=>{const o=xe(n.get(e),e=>e.row);for(const e of i){const n=o.get(e),r=f.get(e);n&&r&&y(n,d[t].x,r.y,d[t].w,r.h,e)}});const g=[],x=/* @__PURE__ */new Map;for(const e of i){const t=f.get(e);x.set(e,t.y+t.h/2);const n=m.get(e);n&&Number.isFinite(n.minX)&&g.push({x:n.minX-nh,y:n.minY-nh,w:n.maxX-n.minX+2*nh,h:n.maxY-n.minY+2*nh})}return{positions:u,enclosures:g,colBands:d,rowLabelY:x}}const x=/* @__PURE__ */new Map;o.forEach((e,o)=>{const r=xe(n.get(e),e=>e.row),i=t.rowOrder.filter(e=>r.has(e)),a=t.rowGap*Math.max(0,i.length-1),c=Math.max(1,t.innerH-a),l=i.map(e=>Math.pow(r.get(e).length,s)),u=l.reduce((e,t)=>e+t,0)||1;let h=t.innerY+t.innerH;i.forEach((e,n)=>{const s="uniform"===t.cellSizing?c/i.length:l[n]/u*c,a=h-s,f=y(r.get(e),d[o].x,a,d[o].w,s,e);if(f){p.push(f);const t=x.get(e)??{sum:0,n:0};t.sum+=f.y+f.h/2,t.n+=1,x.set(e,t)}h=a-t.rowGap})});const b=/* @__PURE__ */new Map;for(const[e,t]of x)b.set(e,t.sum/t.n);return{positions:u,enclosures:p,colBands:d,rowLabelY:b}}function xr(e,t,n,o,r,i,s,a){const c=t+o/2,l=n+r/2,u=/* @__PURE__ */new Map,d=e.length;if(0===d)return u;if(1===d)return u.set(e[0].id,{px:c,py:l}),u;const h=gr(a),f=new Float64Array(d);let m=0;for(let t=0;t<d;t++)f[t]=e[t].r+i,f[t]>m&&(m=f[t]);const p=Math.max(1,Math.round(Math.sqrt(d*o/Math.max(1,r)))),g=new Float64Array(d),y=new Float64Array(d),x=o/p,b=r/Math.ceil(d/p);for(let e=0;e<d;e++){const o=e%p,r=Math.floor(e/p);g[e]=t+(o+.3+.4*h())*x,y[e]=n+(r+.3+.4*h())*b}const w=Math.max(0,Math.min(s,14)),M=Math.max(1,2*m),v=/* @__PURE__ */new Map,k=Math.max(1,Math.ceil(o/M)+3),$=(e,t)=>(t+1)*k+(e+1);for(let e=0;e<w;e++){v.clear();for(let e=0;e<d;e++){const o=$(Math.floor((g[e]-t)/M),Math.floor((y[e]-n)/M)),r=v.get(o);r?r.push(e):v.set(o,[e])}for(let e=0;e<d;e++){const o=Math.floor((g[e]-t)/M),r=Math.floor((y[e]-n)/M);for(let t=-1;t<=1;t++)for(let n=-1;n<=1;n++){const i=v.get($(o+t,r+n));if(i)for(let t=0;t<i.length;t++){const n=i[t];if(n<=e)continue;let o=g[n]-g[e],r=y[n]-y[e];const s=f[e]+f[n],a=o*o+r*r;if(!(a>=s*s))if(a>1e-9){const t=Math.sqrt(a),i=(s-t)/2;o/=t,r/=t,g[e]-=o*i,y[e]-=r*i,g[n]+=o*i,y[n]+=r*i}else{const t=2.39996323*e;g[e]+=Math.cos(t)*f[e],y[e]+=Math.sin(t)*f[e]}}}}for(let e=0;e<d;e++){const i=f[e],s=t+i,a=t+o-i,u=n+i,d=n+r-i;g[e]=a>s?pr(g[e],s,a):c,y[e]=d>u?pr(y[e],u,d):l}}for(let t=0;t<d;t++)u.set(e[t].id,{px:g[t],py:y[t]});return u}function br(e){let t=2166136261;for(const n of e)t=Co(n.row,Co(n.col,Co(n.id,t))),t^=Math.round(8*n.packR),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function wr(e,t){const n=t.columnLabel??(e=>e),o=t.rowLabel??(e=>e),r=(e,t,n,o)=>/* @__PURE__ */ /* @__PURE__ */(0,Jd.jsx)(Zd.NetworkPerspectiveBillboard,{x:t,y:n,onGround:!0,children:o},e),i=(e,t,n,o,r)=>/* @__PURE__ */ /* @__PURE__ */(0,Jd.jsx)(Zd.NetworkPerspectiveBillboard,{x:t,y:n,z:o,children:r},e);/* @__PURE__ */ /* @__PURE__ */
|
|
86
|
+
return(0,Jd.jsxs)("g",{className:"packed-cluster-matrix-chrome",style:{pointerEvents:"none"},children:[
|
|
90
87
|
/* @__PURE__ */
|
|
91
|
-
/* @__PURE__ */(0,
|
|
88
|
+
/* @__PURE__ */(0,Jd.jsx)(Zd.NetworkPerspectiveGround,{children:t.showEnclosures&&e.enclosures.map((e,n)=>jo({keyId:`enc-${n}`,x:e.x,y:e.y,width:e.w,height:e.h,radius:t.enclosureRadius,stroke:t.enclosureColor,strokeWidth:t.enclosureWidth,opacity:t.enclosureOpacity}))}),t.iconMarks.length>0&&/* @__PURE__ */ /* @__PURE__ */(0,Jd.jsx)("g",{className:"packed-cluster-matrix-icons",children:t.iconMarks.map((e,n)=>r(`ic-${n}`,e.x,e.y,
|
|
92
89
|
/* @__PURE__ */
|
|
93
|
-
/* @__PURE__ */(0,th.jsx)("path",{d:tt(e.shape,e.size),transform:`translate(${e.x},${e.y})`,fill:"none",stroke:t.iconColor,strokeWidth:t.iconStrokeWidth,opacity:e.opacity})))}),t.markerDots.length>0&&/* @__PURE__ */ /* @__PURE__ */(0,th.jsx)("g",{className:"packed-cluster-matrix-markers",children:t.markerDots.map((e,n)=>r(`mk-${n}`,e.x,e.y,/* @__PURE__ */ /* @__PURE__ */(0,th.jsx)("circle",{cx:e.x,cy:e.y,r:e.r,fill:t.markerColor})))}),t.showColumnHeaders&&e.colBands.map((e,o)=>i(`col-${o}`,e.x+e.w/2,t.headerY,0,Ro({keyId:`col-${o}`,text:n(e.col),x:e.x+e.w/2,y:t.headerY,anchor:"middle",fontSize:t.headerFontSize,fontWeight:700,color:t.headerColor}))),t.showRowLabels&&[...e.rowLabelY].map(([e,n])=>i(`row-${e}`,t.labelX,n,0,Ro({keyId:`row-${e}`,text:o(e),x:t.labelX,y:n,anchor:"end",fontSize:t.labelFontSize,fontWeight:600,color:t.labelColor}))),t.callouts.map(e=>i(String(e.keyId),e.markX,e.markY,"top",Do(e)))]})}function Ir(e,t,n){const o=e.map((e,o)=>Ro({keyId:`marimekko-label-${o}`,text:e.cat,x:e.x+e.w/2,y:t+12,anchor:"middle",baseline:"auto",maxWidth:e.w-4,fontSize:12,color:n}));return ih.createElement(ih.Fragment,null,...o)}function Ar(e,t,n){const o=/* @__PURE__ */new Set,r=[];for(const t of e)n(t)&&!o.has(t)&&(o.add(t),r.push(t));for(const e of t)o.has(e)||r.push(e);return r}function Cr(e,t,n){return Math.PI*n/3*(e*e+e*t+t*t)}function Nr(e,t){const n=Math.min(1,Math.max(0,t/e.height));return e.bottomRadius*(1-n)+e.topRadius*n}function jr(e,t){return Cr(Nr(e,t),e.bottomRadius,t)}function Fr(e,t){if(t<=0)return 0;if(t>=jr(e,e.height))return e.height;let n=0,o=e.height;for(let r=0;r<60;r++){const r=n+(o-n)/2;jr(e,r)<t?n=r:o=r}return n+(o-n)/2}function Er(e,t){const n=43758.5453*Math.sin(12.9898*e+78.233);return 2*(n-Math.floor(n)-.5)*t}function Pr(e,t){if(!(t>0)||!Number.isFinite(e)||t>e)return[];if(e<2*t)return[{x:0,y:0}];const n=[];let o=e-t;for(;n.length<ph;){let e=Math.min(ph,Math.floor(Math.PI*o/t));e<1&&(e=1);const r=o*Math.cos(0),i=o*Math.sin(0),s=o*Math.cos(2*Math.PI/e),a=o*Math.sin(2*Math.PI/e);Math.hypot(r-s,i-a)<2*t&&e>1&&e--;for(let t=0;t<e&&n.length<ph;t++)n.push({x:o*Math.cos(2*t*Math.PI/e),y:o*Math.sin(2*t*Math.PI/e)});const c=o-2*t;if(!(c>=t)){o>2*t&&n.length<ph&&n.push({x:0,y:0});break}o=c}return n}function zr(e,t,n){const o=[];let r=Math.min(n,ph),i=0;for(;r>0&&i<60;){const n=t*(1+2*i);if(n+t>e.height)break;const s=Pr(Nr(e,n),t),a=s.length-r,c=a>0?s.slice(Math.floor(a/2),Math.floor(a/2)+r):s,l=e.height-n;if(c.forEach((e,t)=>{o.push({x:e.x+Er(97*i+t,.15),z:l+Er(31*i+t,.05)})}),r-=c.length,i++,0===c.length)break}return{pearls:o,layers:i}}function Lr(e,t,n){let o=n,r=0;for(;o>0&&r<60;){const n=t+.875*(1+2*r);if(n+.875>e.height)break;const i=Nr(e,n);if(2*i<fh)break;o-=Math.max(1,Math.floor(2*i/fh)),r++}return r}function Or(e,t,n,o){if(o<=0)return[];const r=Lr(e,t,o=Math.min(o,ph)),i=r*fh,s=Math.max(t,n-i)+.875,a=[];let c=0;for(let t=0;t<r&&c<o;t++){const n=s+fh*t,r=Nr(e,n),i=Math.max(1,Math.floor(2*r/fh)),l=(2*r-i*fh)/(i+1),u=-r+l,d=e.height-n-.875-.1;for(let e=0;e<i&&c<o;e++){const n=u+(l+fh)*e;a.push({cx:n+.875,cy:d+.875,rotation:Er(53*t+e,10)}),c++}}return a}function Tr(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Rr(e,t){const n=Tr(e,t);return n>0?n:t}function Wr(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function qr(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function Dr(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],o=e.scales?.x??e.scales?.time,r=e.scales?.y??e.scales?.value;if(!o||!r)return null;const i=e.xAccessor||"x",s=e.yAccessor||"y",a=n[i],c=n[s];return null==a||null==c?null:{x:o(a),y:r(c)}}function Br(e){return null==e?null:String(e)}function Yr(e){return Br(e.provenance?.stableId??e.stableId)}function Vr(e){return Br(e.stableId??e.id??e.provenance?.stableId)}function Gr(e,t,n){return t.stickyPositionCache?.set(e,n),n}function _r(e,t,n){const o=Yr(e);if(!o)return null;const r=n.pointNodes?.find(e=>Br(e.pointId)===o);if(r)return Gr(t,n,{x:r.x,y:r.y});const i=n.data?.find(e=>Vr(e)===o);if(!i)return null;const s=Wr(i,n),a=qr(i,n);return null==s||null==a?null:Gr(t,n,{x:s,y:a})}function Hr(e,t,n){const o=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===e.pointId)return Gr(t,n,{x:r.x,y:r.y})}const o=Dr(n);return o?Gr(t,n,o):null}if("semantic"===o){const o=_r(e,t,n);if(o)return o}let r=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(r=t.x,i=t.y)}if(null!=r&&null!=i||(r=Wr(e,n),i=qr(e,n)),null!=r&&null!=i)return Gr(t,n,{x:r,y:i});if("sticky"===o){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function Xr(e){return"string"==typeof e?.type?e.type:""}function Ur(e){return!!e&&"object"==typeof e&&xh.has(Xr(e))}function Kr(e,t,n){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=[];let i="";for(const t of e.split(/\s+/))t&&(i&&i.length+1+t.length>o?(r.push(i),i=t):i=i?`${i} ${t}`:t);return i&&r.push(i),r}function Zr(e){return"primary"===e?.emphasis||!0===e?.defensive}function Qr(e,t,n={}){if("number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations))return Math.max(0,Math.floor(n.maxAnnotations));if(!(e>0&&t>0))return 1/0;const o=n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:bh;return Math.max(1,Math.round(e*t/o))}function Jr(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const o=e?.provenance?.confidence;switch("number"==typeof o&&Number.isFinite(o)&&(t+=15*me(o,0,1)),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 ei(e){const{annotations:t,width:n,height:o}=e,r=Math.max(0,e.minVisible??wh),i=Qr(n,o,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,Ur(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||a.length<=i)return{visible:t.slice(),deferred:[],budget:i};const c=a.filter(e=>Zr(e.annotation)),l=a.filter(e=>!Zr(e.annotation)).sort((e,t)=>Jr(t.annotation)-Jr(e.annotation)||e.index-t.index),u=Math.max(0,i-c.length),d=Math.max(0,r-c.length),h=Math.min(l.length,Math.max(u,d)),f=/* @__PURE__ */new Set([...c.map(e=>e.index),...l.slice(0,h).map(e=>e.index)]),m=[],p=[];for(const{annotation:e,index:t,note:n}of s)!n||f.has(t)?m.push(e):p.push(e);return{visible:m,deferred:p,budget:i}}function ti(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:Ih,dy:Ah}}function ni(e){const t=e?.familiarity;if(!t)return jh;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?jh:n.reduce((e,t)=>e+t,0)/n.length}function oi(e){if(!e)return 1;const t=ni(e);return t<=2?1.5:t>=4?.6:1}function ri(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?Object.prototype.hasOwnProperty.call(Fh,t.source)?Fh[t.source]:t.source:null,o="number"==typeof t.confidence&&Number.isFinite(t.confidence)?`${Math.round(100*Math.max(0,Math.min(1,t.confidence)))}%`:null;if(!n&&!o)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const r=[n,o].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${r})`)?e:{...e,label:i?`${i} (${r})`:`(${r})`}}function ii(e,t){let n=!1;const o=e.map(e=>ci(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?o:e}function si(e){if(!ci(e))return e;const t="string"==typeof e.mobileText?e.mobileText:void 0,n="string"==typeof e.shortText?e.shortText:void 0,o=t??n;return!o||"string"!=typeof e.label&&null!=e.label?e:{...e,label:o}}function ai(e){if("text"!==e.type||"string"!=typeof e.color)return e;const t="number"==typeof e.dx?e.dx:0,n="number"==typeof e.dy?e.dy:0;return Math.hypot(t,n)<Ch?e:{...e,_redundantConnector:!0}}function ci(e){return Ur(e)}function li(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="function"==typeof(n=e)._noteLayout?n._noteLayout(n):void 0;var n;if(t)return{width:Math.max(24,t.width+10),height:Math.max(18,t.height+6)};const o="number"==typeof e.wrap?e.wrap:120,r=[...Kr("string"==typeof e.title?e.title:void 0,o,7),...Kr("string"==typeof e.label?e.label:void 0,o,7)],i=r.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(o,7*i)+10),height:Math.max(18,16*r.length+6)}}function ui(e,t,n,o,r){const i=e+n,s=t+o;return Math.abs(n)>Math.abs(o)?{x:n>=0?i+4:i-r.width-4,y:o<0?s-r.height:s,width:r.width,height:r.height}:{x:n>=0?i:i-r.width,y:o<0?s-r.height-4:s+4,width:r.width,height:r.height}}function di(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function hi(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 fi(e,t,n,o){const r=Math.max(0,o-e.x),i=Math.max(0,o-e.y),s=Math.max(0,e.x+e.width-(t-o)),a=Math.max(0,e.y+e.height-(n-o));return(r+s)*e.height+(i+a)*e.width}function mi(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}function pi(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}function gi(e,t,n,o,r,i,s,a){const c=di(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*fi(c,r,i,a);for(const e of n)l+=12*hi(c,e);for(const e of o)l+=4*hi(c,e);return l}function yi(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const o=e.pointId??e.nodeId;if(null!=o&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===o);if(e)return{x:e.x,y:e.y}}const r=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(r)&&r.length>=2&&i){const e=r[0],t=r[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?Hr(e,t,n):{x:e.x,y:e.y}}function xi(e){const{annotations:t,context:n,defaultOffset:o=Mh,notePadding:r=vh,markPadding:i=kh,edgePadding:s=$h,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=Sh,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:m,cohesion:p,audience:g}=e,y=n.width||0,x=n.height||0,b="object"==typeof m?m:{},w=b.breakpoint??Nh,M=!!m&&y<=w,v=M&&!1!==b.preferShortText?t.map(si):t,k=M&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,$=d||M&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),S=M&&!f?b.responsive??{minWidth:w}:f,I=M&&!p?b.cohesion:p;if(0===v.length||y<=0||x<=0)return v.slice();const A=[],C=pi(n,i);let N=!1;const j=v.map((e,t)=>{if(!ci(e))return e;const i=yi(e,t,n);if(!i)return e;const u=li(!0===e.defensive?ri(e):e);if(a&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=ti(e),n="number"==typeof e.dx?e.dx:t.dx,o="number"==typeof e.dy?e.dy:t.dy;return A.push(di(ui(i.x,i.y,n,o,u),r)),e}var d;let h=null,f=1/0;for(const e of mi(o)){const t=gi(ui(i.x,i.y,e.dx,e.dy,u),e,A,C,y,x,r,s);t<f&&(h=e,f=t)}if(!h)return e;const m=di(ui(i.x,i.y,h.dx,h.dy,u),r);A.push(m);const p=Math.hypot(h.dx,h.dy),g=c&&p>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return N=!0,{...e,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),F=N?j:v.slice();let E=F;if(h){let e=!1;const t=F.map(t=>{const n=ai(t);return n!==t&&(e=!0),n});E=e?t:F}{let e=!1;const t=E.map(t=>{if(!0!==t?.defensive)return t;const n=ri(t);return n!==t&&(e=!0),n});E=e?t:E}const P=/* @__PURE__ */new Set;if(k){const e="object"==typeof k?k:{},t=oi(g),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??Qr(y,x,e))*t))},{deferred:o}=ei({annotations:E,width:y,height:x,...n});for(const e of o)P.add(e)}if(S){const e="object"==typeof S&&"number"==typeof S.minWidth?S.minWidth:Nh;if(y<=e)for(const e of E)ci(e)&&"secondary"===e.emphasis&&P.add(e)}if(P.size>0)for(const e of E)!0===e?.defensive&&P.delete(e);let z;return z=0===P.size?E:$?E.map(e=>P.has(e)?{...e,_annotationDeferred:!0}:e):E.filter(e=>!P.has(e)),I?ii(z,I):z}function bi(e,t=0){return"number"==typeof e&&Number.isFinite(e)?e:t}function wi(e){const t=bi(e.tight,zh.tight),n=Math.max(t,bi(e.watch,zh.watch));return{tight:t,watch:n,comfortable:Math.max(n,bi(e.comfortable,zh.comfortable))}}function Mi(e={}){const{tight:t,watch:n,comfortable:o}=wi(e);return[{id:"tight",name:"Tight",label:`Tight (< ${t}%)`,max:t,color:Lh.tight},{id:"watch",name:"Watch",label:`Watch (${t}% to < ${n}%)`,min:t,max:n,color:Lh.watch},{id:"moderate",name:"Moderate",label:`Moderate (${n}% to < ${o}%)`,min:n,max:o,color:Lh.moderate},{id:"comfortable",name:"Comfortable",label:`Comfortable (≥ ${o}%)`,min:o,color:Lh.comfortable}].filter(e=>null==e.min||null==e.max||e.max>e.min)}function vi(e,t={}){return Number.isFinite(e)?Mi(t).find(t=>(null==t.min||e>=t.min)&&(null==t.max||e<t.max))??null:null}function ki(e,t={}){const n=t.fuels??Eh,o=!0===t.includeZero,r=[];for(const t of e)if(t&&"number"==typeof t.t)for(const e of n){const n=bi(t.fuels?.[e]);!o&&n<=0||r.push({t:t.t,fuel:e,fuelLabel:Ph[e],mw:n,ba:t.ba})}return r}function $i(e){const t=[];for(const n of e){if(!n||"number"!=typeof n.t)continue;const e=bi(n.demandMw),o=n.forecastMw;"number"==typeof o&&Number.isFinite(o)&&t.push({t:n.t,a:e,b:o,demandMw:e,forecastMw:o,errorMw:e-o,ba:n.ba})}return t}function Si(e){const t=bi(e.demand);if(t<=0)return 0;const n=bi(e.capacityOrNetGen),o=bi(e.interchange);return(n+(o<0?-o:0)-t)/t*100}function Ii(e){return e.filter(e=>e&&"number"==typeof e.t).map(e=>{const t=bi(e.demandMw),n=bi(e.netGenMw),o=Si({demand:t,capacityOrNetGen:n,interchange:e.interchangeMw}),r=Math.max(0,bi(e.fuels?.wind))+Math.max(0,bi(e.fuels?.solar));return{t:e.t,ba:e.ba,reserveMarginPct:o,netLoadMw:t-r,demandMw:t,netGenMw:n}})}function Ai(e={},t={}){const n=t.field,o=n?{field:n}:{},r=t.tightHatch??{type:"hatch",background:Lh.tight,stroke:"rgba(255, 240, 200, 0.55)",spacing:5,angle:-35,lineWidth:1.25,lineOpacity:.9},i={comfortable:{fill:t.comfortableFill??Lh.comfortable,fillOpacity:.85},moderate:{fill:t.moderateFill??Lh.moderate,fillOpacity:.85},watch:{fill:t.watchFill??Lh.watch,fillOpacity:.9},tight:{fill:r,stroke:t.tightFill??Lh.tight,strokeWidth:1,fillOpacity:1}};return Mi(e).reverse().map(e=>({id:`reserve-${e.id}`,label:e.label,when:{...o,...null!=e.min?{gte:e.min}:{},...null!=e.max?{lt:e.max}:{}},style:i[e.id]}))}function Ci(e={},t={}){const{tight:n,comfortable:o}=wi(e),[r,i]=t.extent??[],s=Math.min(n,bi(r,-50)),a=Math.max(o,bi(i,Math.max(o+30,40))),c={tight:.12,watch:.1,moderate:.08,comfortable:.06};return Mi(e).map(e=>({type:"band",y0:e.min??s,y1:e.max??a,label:e.name,color:e.color,fillOpacity:c[e.id],emphasis:"secondary"}))}function Ni(e,t){if(!e.length)return null;const n=[...e].filter(e=>e&&"number"==typeof e.t).sort((e,t)=>e.t-t.t);if(!n.length)return null;let o=n[n.length-1];if("number"==typeof t&&Number.isFinite(t)){const e=n.filter(e=>e.t<=t);o=e.length?e[e.length-1]:n[0]}const r=bi(o.demandMw),i=bi(o.netGenMw),s="number"==typeof o.forecastMw&&Number.isFinite(o.forecastMw)?o.forecastMw:null,a=Si({demand:r,capacityOrNetGen:i,interchange:o.interchangeMw}),c={};let l=null,u=0,d=0;for(const e of Eh){const t=bi(o.fuels?.[e]);t<=0||(d+=t,c[e]=t,t>u&&(u=t,l=e))}if(d>0)for(const e of Object.keys(c))c[e]=c[e]/d;return{t:o.t,ba:o.ba,demandMw:r,forecastMw:s,forecastErrorMw:null==s?null:r-s,netGenMw:i,reserveMarginPct:a,topFuel:l,topFuelShare:d>0?u/d:0,topFuelMw:u,fuelShares:c}}function ji(e,t={}){const n=t.now??Date.now(),o=t.author??"system",r=t.source??"authored-scenario";return e.map(e=>{const i=(e.start+e.end)/2,s=new Date(e.start).toISOString();return{type:"x-band",x0:e.start,x1:e.end,label:e.label,color:"outage"===e.kind?"var(--semiotic-danger)":"var(--semiotic-warning)",fillOpacity:.12,emphasis:"secondary",x:i,y:e.y??e.value,note:e.note,provenance:{author:o,authorKind:"system",source:r,basis:"rule",..."number"==typeof t.confidence&&Number.isFinite(t.confidence)?{confidence:Math.min(1,Math.max(0,t.confidence))}:{},createdAt:s,stableId:e.id,dataVersion:String(e.start)},lifecycle:{status:"accepted",ttlHint:e.ttlHint??"P14D",anchor:"fixed"},_eventKind:e.kind,_createdAtMs:e.start,_nowMs:n}})}function Fi(e,t=12){return[...e].filter(e=>Number.isFinite(e.reserveMarginPct)).sort((e,t)=>e.reserveMarginPct-t.reserveMarginPct).slice(0,Math.max(0,t))}function Ei(e,t=0){return Number.isFinite(e)?`${e.toLocaleString(void 0,{maximumFractionDigits:t,minimumFractionDigits:t})} MW`:"—"}function Pi(e,t=1){return Number.isFinite(e)?`${e>0?"+":""}${e.toFixed(t)}%`:"—"}function zi(e,t){if("function"==typeof e)return e;const n=e??t;return e=>Number(e[n])}function Li(e,t={}){const n=zi(t.start,"start"),o=zi(t.end,"end"),r=!1===t.sort?e.slice():e.slice().sort((e,t)=>n(e)-n(t)||o(t)-o(e)),i=new Rh;return{packed:r.map(e=>({item:e,track:i.assign(n(e),o(e))})),trackCount:Math.max(1,i.count)}}function Oi(e,t){const n=zi(t.start,"start"),o=zi(t.end,"end"),[r,i]=t.domain,s=t.step??1,a="half-open"===t.bounds;if(!Number.isFinite(r)||!Number.isFinite(i)||r>i||!Number.isFinite(s)||s<=0)return[];const c=(i-r)/s;if(c>=Number.MAX_SAFE_INTEGER||r<i&&(r+s<=r||i-s>=i))return[];const l=Math.min(.25,4*Number.EPSILON*Math.max(1,c)),u=Math.floor(c+l),d=c>Math.log2(e.length+1),h=[],f=[];if(d){for(const t of e){const e=n(t),r=o(t);e<=r&&(h.push(e),f.push(r))}h.sort((e,t)=>e-t),f.sort((e,t)=>e-t)}let m=0,p=0;const g=[];for(let t=0;t<=u;t++){const y=t>0&&t===u&&Math.abs(t-c)<=l?i:r+t*s;let x=0;if(d){for(;m<h.length&&h[m]<=y;)m++;for(;p<f.length&&(a?f[p]<=y:f[p]<y);)p++;x=m-p}else for(const t of e){const e=n(t),r=o(t);e<=y&&(a?y<r:y<=r)&&x++}g.push({value:y,count:x})}return g}function Ti(e,t,n){const o="x"===t?"width":"height",r=new Float64Array(e.length),i=new Float64Array(e.length),s=Array.from({length:e.length},(e,t)=>t);let a=0;const c=()=>{for(let s=0;s<e.length;s++){const a=(e[s][o]+Math.max(0,n))/2;r[s]=e[s][t]-a,i[s]=e[s][t]+a}s.sort((e,t)=>r[e]-r[t]||e-t),a=0;for(let e=0;e<s.length;e++){let t=e+1,n=s.length;for(;t<n;){const o=t+n>>>1;r[s[o]]<=i[s[e]]?t=o+1:n=o}a+=t-e-1}};return c(),{lower:r,upper:i,order:s,update:c,get pairs(){return a}}}function Ri(e,t,n,o,r=!1){const i="x"===t?"y":"x",s="x"===t?"width":"height",a="x"===t?"height":"width",c=Ti(e,t,n),l=Ti(e,i,n),u=new Float64Array(e.length);return()=>{u.fill(0),c.update(),r||l.update();const{order:d,lower:h,upper:f}=c.pairs<l.pairs?c:l;for(let r=0;r<d.length;r++){const c=d[r],l=e[c];for(let m=r+1;m<d.length&&h[d[m]]<=f[c];m++){const r=d[m],h=e[r];if(Math.abs(l[i]-h[i])>(l[a]+h[a])/2+n)continue;const f=h[t]-l[t]||(l.id<h.id?-.5:.5),p=(l[s]+h[s])/2+n-Math.abs(f);if(p<=0)continue;const g=p*o*Math.sign(f);u[c]-=g,u[r]+=g}}return u}}function Wi(e,t,n){const o=n?.orientation??"vertical",r=n?.bend??0,i=n?.minAlong??18,s=(e,t)=>(e+t)/2;if("vertical"===o){if(Math.abs(t.y-e.y)<i){const n=e.x<=t.x?1:-1,o=s(e.x,t.x)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${o},${s(e.y,t.y)} ${t.x},${t.y}`}const n=s(e.y,t.y)+r;return`M${e.x},${e.y} C${e.x},${n} ${t.x},${n} ${t.x},${t.y}`}if(Math.abs(t.x-e.x)<i){const n=e.y<=t.y?1:-1,o=s(e.y,t.y)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${s(e.x,t.x)},${o} ${t.x},${t.y}`}const a=s(e.x,t.x)+r;return`M${e.x},${e.y} C${a},${e.y} ${a},${t.y} ${t.x},${t.y}`}function qi(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=(e.y+t.y)/2;return`M${e.x},${e.y} L${e.x},${n} L${t.x},${n} L${t.x},${t.y}`}const o=(e.x+t.x)/2;return`M${e.x},${e.y} L${o},${e.y} L${o},${t.y} L${t.x},${t.y}`}function Di(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=t.cy>=e.cy;return{from:{x:e.cx,y:e.cy+(n?e.height/2:-e.height/2)},to:{x:t.cx,y:t.cy+(n?-t.height/2:t.height/2)}}}const o=t.cx>=e.cx;return{from:{x:e.cx+(o?e.width/2:-e.width/2),y:e.cy},to:{x:t.cx+(o?-t.width/2:t.width/2),y:t.cy}}}function Bi(e,t){const n=t?.spread??5;return t?.modulo&&t.modulo>0?(e%t.modulo-(t.modulo-1)/2)*n:(e-((t?.count??1)-1)/2)*n}function Yi(e,t){const n=1-t,o=n*n*n,r=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:o*e.p0.x+r*e.p1.x+i*e.p2.x+s*e.p3.x,y:o*e.p0.y+r*e.p1.y+i*e.p2.y+s*e.p3.y}}function Vi(e,t){const n=1-t,o=3*n*n,r=6*n*t,i=3*t*t;return{x:o*(e.p1.x-e.p0.x)+r*(e.p2.x-e.p1.x)+i*(e.p3.x-e.p2.x),y:o*(e.p1.y-e.p0.y)+r*(e.p2.y-e.p1.y)+i*(e.p3.y-e.p2.y)}}function Gi(e){return`M${e.p0.x},${e.p0.y} C${e.p1.x},${e.p1.y} ${e.p2.x},${e.p2.y} ${e.p3.x},${e.p3.y}`}function _i(e,t){const n=Ri(e,t?.axis??"x",t?.padding??0,t?.strength??.5)(),o=/* @__PURE__ */new Map;return e.forEach((e,t)=>o.set(e.id,(o.get(e.id)??0)+n[t])),o}function Hi(e,t,n=!1){if("function"==typeof e)return n?t=>e(ye(t)??t):e;const o=e??t;return e=>ge(e,o,void 0)}function Xi(e,t,n,o){return Ui(e,t,n,o,!1)}function Ui(e,t,n,o,r){const i=o.fixedAxis??"y",s=Hi(o.fixedAccessor,"fixed",r),a=e=>String(Hi(o.sourceAccessor,"source",r)(e)),c=e=>String(Hi(o.targetAccessor,"target",r)(e)),l=o.size??(()=>qh),u=o.iterations??180,d=o.attraction??.012,h=o.anchorStrength??.003,f=o.collisionStrength??.12,m=o.collisionPadding??15,p=o.edgePadding??42,g=o.fixedPadding??16,y=o.damping??.72,x=o.spread??1,[b,w]=o.fixedDomain;if(![b,w,n.x,n.y,n.width,n.height].every(Number.isFinite)||n.width<=0||n.height<=0)return{positioned:[],byId:/* @__PURE__ */new Map};const M=w-b||1,v=("y"===i?n.y:n.x)+g,k=("y"===i?n.y+n.height:n.x+n.width)-g,$=("y"===i?n.x:n.y)+p,S=("y"===i?n.x+n.width:n.y+n.height)-p,I=Math.max(1,S-$),A=e.flatMap(e=>{const t=s(e);if("number"!=typeof t&&("string"!=typeof t||!t.trim()))return[];const n=Number(t),i=v+(n-b)/M*(k-v);if(!Number.isFinite(n)||!Number.isFinite(i))return[];const a=ye(e)??e,c=(u=e,String(Hi(o.idAccessor,"id",r)(u)));var u;const{width:d,height:h}=l(a);if(![d,h].every(e=>Number.isFinite(e)&&e>0))return[];const f=$+zo(c)*I;return[{data:a,id:c,width:d,height:h,fixedValue:n,fixed:i,free:f,anchor:f}]}),C=e=>"y"===i?e.width:e.height,N=new Map(A.map((e,t)=>[e.id,t])),j=[];for(const e of t){const t=N.get(a(e)),n=N.get(c(e));void 0!==t&&void 0!==n&&j.push([t,n])}const F=A.map(e=>({id:e.id,x:"y"===i?e.free:e.fixed,y:"y"===i?e.fixed:e.free,width:e.width,height:e.height})),E="y"===i?"x":"y",P=Ri(F,E,m,f,!0),z=new Float64Array(A.length);for(let e=0;e<u;e++){z.fill(0);for(const[e,t]of j){const n=(A[t].free-A[e].free)*d;z[e]+=n,z[t]-=n}for(let e=0;e<A.length;e++){const t=A[e];z[e]+=(t.anchor-t.free)*h,F[e][E]=t.free}const e=P();for(let t=0;t<A.length;t++){const n=A[t];n.free+=(z[t]+e[t])*y;const o=C(n)/2;n.free=Math.max($+o,Math.min(S-o,n.free))}}if(1!==x){const e=($+S)/2;for(const t of A){const n=C(t)/2;t.free=Math.max($+n,Math.min(S-n,e+(t.free-e)*x))}}const L=A.map(e=>({data:e.data,id:e.id,x:"y"===i?e.free:e.fixed,y:"y"===i?e.fixed:e.free,width:e.width,height:e.height,fixedValue:e.fixedValue}));return{positioned:L,byId:new Map(L.map(e=>[e.id,e]))}}function Ki(e){let t=0;for(const n of e)t+=Vh[n]??(n>="0"&&n<="9"?Gh:(n.codePointAt(0)??0)>=11904?Hh:_h);return t}function Zi(e,t){return Math.max(8,Ki(e)*t*Xh+Uh)}function Qi(e,t,n){if(!n)return{w:e,h:t};const o=Math.abs(n)*Math.PI/180,r=Math.cos(o),i=Math.sin(o);return{w:e*r+t*i,h:e*i+t*r}}function Ji(e,t){let n=t>>>0;for(const t of e){n=Po(t.col,n);for(const e of t.rows)n=Po(`${e.text}␟${e.weight}␟${e.segment}`,n)}return(n>>>0).toString(36)}function es(e){const{plans:t,colW:n,bodyH:o,yTop:r,yBot:i,segToY:s,collisionPadding:a}=e,c=n*o;let l=1/0,u=1/0;for(const o of t){let t=0;for(const e of o.rows){const o=Ki(e.text)*Xh;t+=o*Bh*e.baseFont*e.baseFont;const r=Qi(o,Bh,e.rotation);u=Math.min(u,(n-8-Uh)/(r.w*e.baseFont))}t>0&&(l=Math.min(l,Math.sqrt(e.packingDensity*c/t)))}const d=e=>{const o=[],c=[];return t.forEach((t,l)=>{if(n<=0)return;const u=t.colLeft+4,d=t.colLeft+n-4,h=t.rows.map((t,o)=>{const r=e*t.baseFont,i=Math.max(Yh,r),a=Qi(Zi(t.text,i),i*Bh+2,t.rotation);return{rowIndex:o,id:t.id,font:i,floored:t.floored||r<Yh,rotation:t.rotation,w:a.w,h:a.h,anchorY:s(t.segment),seed:(zo(t.id)-.5)*Math.min(.5*n,80)}}).sort((e,t)=>t.font-e.font||(e.id<t.id?-1:1)),f=new Kh(Zh);for(const e of h){const n=e.w/2,s=e.h/2,h=me(t.center+e.seed,u+n,d-n),m=e.anchorY;let p=null;for(let t=0;t<Qh;t++){const o=3.2*Math.sqrt(t),c=2.399963229728653*t,l={x:me(h+o*Math.cos(c),u+n,d-n),y:me(m+o*Math.sin(c),r+s,i-s),w:e.w,h:e.h};if(!f.collides(l,a)){p=l;break}}p?(f.insert(p),o.push({planIndex:l,rowIndex:e.rowIndex,id:e.id,x:p.x,y:p.y,fontSize:e.font,rotation:e.rotation,w:e.w,h:e.h,floored:e.floored})):c.push({planIndex:l,rowIndex:e.rowIndex})}}),{placements:o,unplaced:c}};let h=e.scaleToFit?Math.min(1,l,u):Math.min(1,u),f=d(h);if(e.scaleToFit)for(let e=0;e<6&&f.unplaced.length>0&&h>.1;e++)h*=.88,f=d(h);return f}function ts(e){const t=Number(e.segmentDomain?.[0]),n=Number(e.segmentDomain?.[1]),o=Number.isFinite(t)?t:0,r=Number.isFinite(n)?n:o,i=r<o?-1:1,s=Math.abs(r-o),a=Number(e.currentSegment),c=Number.isFinite(a)?me((a-o)*i,0,s):0,l=(e,t)=>{const n=Number(e);return Number.isFinite(n)?me(n,0,1):t},u=l(e.oldestOpacity,.25),d=l(e.currentOpacity,1),h=l(e.futureOpacity,0);return{weightOpacity:!0===e.combineWeightOpacity,wordOpacity:({segment:e})=>{const t=Number(e);if(!Number.isFinite(t))return h;const n=(t-o)*i;if(n>c)return h;if(0===c)return d;const r=me(n/c,0,1);return u+(d-u)*r}}}function ns(e){const t=e.config,{plot:n}=e.dimensions,o={nodes:[],unplaced:[],sizeFloored:[]};if(n.width<=0||n.height<=0||0===e.data.length)return o;const r=pe(t.textAccessor),i=e=>{const n=Number(pe(t.weightAccessor)(e));return Number.isFinite(n)&&n>0?n:0},s=pe(t.columnAccessor),a=e=>Number(pe(t.segmentAccessor)(e)),c=t.minFontSize??11,l=t.maxFontSize??42,u=t.columnGutter??18,d=t.collisionPadding??2,h=!1!==t.showColumnLabels,f=!1!==t.showSegmentAxis,m=t.segmentTickCount??6,p=t.segmentTickFormat??(e=>String(Math.round(e))),g=t.rotate??0,y=!0===t.repeatWords,x=!1!==t.scaleToFit,b=t.packingDensity??.6,w="string"==typeof t.textAccessor?t.textAccessor:"word",M="string"==typeof t.weightAccessor?t.weightAccessor:"weight",v="string"==typeof t.columnAccessor?t.columnAccessor:"column",k="string"==typeof t.segmentAccessor?t.segmentAccessor:"segment",$=[],S=/* @__PURE__ */new Map;let I=1/0,A=-1/0;for(let t=0;t<e.data.length;t++){const n=e.data[t],o=String(s(n)),c=String(r(n)),l=i(n),u=a(n);c&&Number.isFinite(u)&&(S.has(o)||($.push(o),S.set(o,[])),S.get(o).push({col:o,text:c,weight:l,segment:u,datum:n,dataIndex:t}),u<I&&(I=u),u>A&&(A=u))}if(0===$.length)return o;if(!y)for(const[e,t]of S){const n=/* @__PURE__ */new Map;for(const e of t){const t=n.get(e.text);(!t||e.weight>t.weight)&&n.set(e.text,e)}S.set(e,[...n.values()])}let C=1/0,N=-1/0;for(const e of S.values())for(const t of e)t.weight<C&&(C=t.weight),t.weight>N&&(N=t.weight);if(!Number.isFinite(C))return o;const j=t.columnOrder?[...t.columnOrder.filter(e=>S.has(e)),...$.filter(e=>!t.columnOrder.includes(e))]:$,F=new Map(j.map(n=>[n,t.columnColor?.(n)||e.resolveColor(n)])),[E,P]=t.segmentDomain??[I,A],z=P-E||1,L=N-C||1,O=h?22:0,T=f?52:0,R=n.x+T,W=n.y+O,q=Math.max(0,n.width-T),D=Math.max(0,n.height-O),B=j.length,Y=Math.max(0,q-u*Math.max(0,B-1)),V=B>0?Y/B:0,G=W+14,_=W+D-14,H=e=>G+(e-E)/z*(_-G),X=j.map((e,n)=>{const o=F.get(e),r=(S.get(e)??[]).map((r,i)=>{const s={word:r.text,column:r.col,weight:r.weight,segment:r.segment,datum:r.datum,dataIndex:r.dataIndex,columnIndex:n,resolvedColumnColor:o},a=t.wordOpacity?Number(t.wordOpacity(s)):1,u=t.wordColor?.(s),d=`${e}::${r.text}::${i}`,h=(f=r.weight,N>0?l*Math.sqrt(f/N):0);var f;return{id:d,text:r.text,weight:r.weight,segment:r.segment,baseFont:Math.max(c,h),floored:h<c,rotation:g>0?2*(zo(d+"r")-.5)*g:0,opacity:Number.isFinite(a)?me(a,0,1):0,color:u||o,info:s}});return 0===r.length?null:{col:e,colLeft:R+n*(V+u),center:R+n*(V+u)+V/2,rows:r}}).filter(e=>null!==e),U=ve([n.x,n.y,n.width,n.height,O,T,u,d,c,l,g,x,b,E,P,X.length,Ji(X,2166136261),Ji(X,16777619)]),K=ef.getOrCompute(U,()=>es({plans:X,colW:V,bodyH:D,yTop:G,yBot:_,segToY:H,collisionPadding:d,packingDensity:b,scaleToFit:x})),Z=(e,t)=>X[e].rows[t],Q=K.unplaced.map(({planIndex:e,rowIndex:t})=>Z(e,t).info),J=K.placements.map(e=>{const t=Z(e.planIndex,e.rowIndex),n=X[e.planIndex].col,o=Math.sqrt((t.weight-C)/L);return{id:e.id,text:t.text,x:e.x,y:e.y,w:e.w,h:e.h,fontSize:e.fontSize,rotation:e.rotation,floored:e.floored,color:t.color,opacity:t.opacity,info:t.info,datum:be(e=>{for(const n of Object.keys(t.info.datum))e(n,t.info.datum[n]);e("word",t.text),e("weight",t.weight),e("column",n),e("segment",t.segment),"word"!==w&&e(w,t.text),"weight"!==M&&e(M,t.weight),"column"!==v&&e(v,n),"segment"!==k&&e(k,t.segment),e("__strength",.5+.5*o)})}}),ee=J.filter(e=>e.opacity>0);return{nodes:ee.map(e=>{const t=e.rotation?e.w:Zi(e.text,e.fontSize),n=e.rotation?e.h:e.fontSize*Bh;return{type:"rect",x:e.x-t/2,y:e.y-n/2,w:t,h:n,style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:e.datum,group:String(e.datum.column),_transitionKey:e.id}}),overlays:/* @__PURE__ */ /* @__PURE__ */(0,Jh.jsxs)("g",{className:"semiotic-word-trails","data-unplaced-count":Q.length||void 0,children:[f&&os({x:n.x+T-10,yTop:G,yBot:_,segLo:E,segHi:P,segToY:H,tickCount:m,tickFormat:p,color:`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,label:t.segmentAxisLabel,labelX:n.x}),h&&j.map((e,t)=>{if(V<=0)return null;const o=R+t*(V+u);/* @__PURE__ */ /* @__PURE__ */
|
|
94
|
-
return(0,
|
|
95
|
-
return(0,
|
|
90
|
+
/* @__PURE__ */(0,Jd.jsx)("path",{d:nt(e.shape,e.size),transform:`translate(${e.x},${e.y})`,fill:"none",stroke:t.iconColor,strokeWidth:t.iconStrokeWidth,opacity:e.opacity})))}),t.markerDots.length>0&&/* @__PURE__ */ /* @__PURE__ */(0,Jd.jsx)("g",{className:"packed-cluster-matrix-markers",children:t.markerDots.map((e,n)=>r(`mk-${n}`,e.x,e.y,/* @__PURE__ */ /* @__PURE__ */(0,Jd.jsx)("circle",{cx:e.x,cy:e.y,r:e.r,fill:t.markerColor})))}),t.showColumnHeaders&&e.colBands.map((e,o)=>i(`col-${o}`,e.x+e.w/2,t.headerY,0,Po({keyId:`col-${o}`,text:n(e.col),x:e.x+e.w/2,y:t.headerY,anchor:"middle",fontSize:t.headerFontSize,fontWeight:700,color:t.headerColor}))),t.showRowLabels&&[...e.rowLabelY].map(([e,n])=>i(`row-${e}`,t.labelX,n,0,Po({keyId:`row-${e}`,text:o(e),x:t.labelX,y:n,anchor:"end",fontSize:t.labelFontSize,fontWeight:600,color:t.labelColor}))),t.callouts.map(e=>i(String(e.keyId),e.markX,e.markY,"top",Oo(e)))]})}function Mr(e,t,n){const o=e.map((e,o)=>Po({keyId:`marimekko-label-${o}`,text:e.cat,x:e.x+e.w/2,y:t+12,anchor:"middle",baseline:"auto",maxWidth:e.w-4,fontSize:12,color:n}));return oh.createElement(oh.Fragment,null,...o)}function vr(e,t,n){const o=/* @__PURE__ */new Set,r=[];for(const t of e)n(t)&&!o.has(t)&&(o.add(t),r.push(t));for(const e of t)o.has(e)||r.push(e);return r}function kr(e,t,n){return Math.PI*n/3*(e*e+e*t+t*t)}function $r(e,t){const n=Math.min(1,Math.max(0,t/e.height));return e.bottomRadius*(1-n)+e.topRadius*n}function Sr(e,t){return kr($r(e,t),e.bottomRadius,t)}function Ir(e,t){if(t<=0)return 0;if(t>=Sr(e,e.height))return e.height;let n=0,o=e.height;for(let r=0;r<60;r++){const r=n+(o-n)/2;Sr(e,r)<t?n=r:o=r}return n+(o-n)/2}function Ar(e,t){const n=43758.5453*Math.sin(12.9898*e+78.233);return 2*(n-Math.floor(n)-.5)*t}function Cr(e,t){if(!(t>0)||!Number.isFinite(e)||t>e)return[];if(e<2*t)return[{x:0,y:0}];const n=[];let o=e-t;for(;n.length<fh;){let e=Math.min(fh,Math.floor(Math.PI*o/t));e<1&&(e=1);const r=o*Math.cos(0),i=o*Math.sin(0),s=o*Math.cos(2*Math.PI/e),a=o*Math.sin(2*Math.PI/e);Math.hypot(r-s,i-a)<2*t&&e>1&&e--;for(let t=0;t<e&&n.length<fh;t++)n.push({x:o*Math.cos(2*t*Math.PI/e),y:o*Math.sin(2*t*Math.PI/e)});const c=o-2*t;if(!(c>=t)){o>2*t&&n.length<fh&&n.push({x:0,y:0});break}o=c}return n}function Nr(e,t,n){const o=[];let r=Math.min(n,fh),i=0;for(;r>0&&i<60;){const n=t*(1+2*i);if(n+t>e.height)break;const s=Cr($r(e,n),t),a=s.length-r,c=a>0?s.slice(Math.floor(a/2),Math.floor(a/2)+r):s,l=e.height-n;if(c.forEach((e,t)=>{o.push({x:e.x+Ar(97*i+t,.15),z:l+Ar(31*i+t,.05)})}),r-=c.length,i++,0===c.length)break}return{pearls:o,layers:i}}function jr(e,t,n){let o=n,r=0;for(;o>0&&r<60;){const n=t+.875*(1+2*r);if(n+.875>e.height)break;const i=$r(e,n);if(2*i<dh)break;o-=Math.max(1,Math.floor(2*i/dh)),r++}return r}function Fr(e,t,n,o){if(o<=0)return[];const r=jr(e,t,o=Math.min(o,fh)),i=r*dh,s=Math.max(t,n-i)+.875,a=[];let c=0;for(let t=0;t<r&&c<o;t++){const n=s+dh*t,r=$r(e,n),i=Math.max(1,Math.floor(2*r/dh)),l=(2*r-i*dh)/(i+1),u=-r+l,d=e.height-n-.875-.1;for(let e=0;e<i&&c<o;e++){const n=u+(l+dh)*e;a.push({cx:n+.875,cy:d+.875,rotation:Ar(53*t+e,10)}),c++}}return a}function Er(e,t){const n=Number(e);return Number.isFinite(n)?n:t}function Pr(e,t){const n=Er(e,t);return n>0?n:t}function zr(e,t){const n=t.scales?.x??t.scales?.time;return n?null!=e.x?n(e.x):t.xAccessor&&null!=e[t.xAccessor]?n(e[t.xAccessor]):null:null}function Lr(e,t){const n=t.scales?.y??t.scales?.value;return n?null!=e.y?n(e.y):t.yAccessor&&null!=e[t.yAccessor]?n(e[t.yAccessor]):null:null}function Or(e){const t=e.data;if(!t||0===t.length)return null;const n=t[t.length-1],o=e.scales?.x??e.scales?.time,r=e.scales?.y??e.scales?.value;if(!o||!r)return null;const i=e.xAccessor||"x",s=e.yAccessor||"y",a=n[i],c=n[s];return null==a||null==c?null:{x:o(a),y:r(c)}}function Tr(e){return null==e?null:String(e)}function Rr(e){return Tr(e.provenance?.stableId??e.stableId)}function Wr(e){return Tr(e.stableId??e.id??e.provenance?.stableId)}function qr(e,t,n){return t.stickyPositionCache?.set(e,n),n}function Dr(e,t,n){const o=Rr(e);if(!o)return null;const r=n.pointNodes?.find(e=>Tr(e.pointId)===o);if(r)return qr(t,n,{x:r.x,y:r.y});const i=n.data?.find(e=>Wr(e)===o);if(!i)return null;const s=zr(i,n),a=Lr(i,n);return null==s||null==a?null:qr(t,n,{x:s,y:a})}function Br(e,t,n){const o=e.anchor||e.lifecycle?.anchor||"fixed";if("latest"===o){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const r=n.pointNodes[o];if(r.pointId===e.pointId)return qr(t,n,{x:r.x,y:r.y})}const o=Or(n);return o?qr(t,n,o):null}if("semantic"===o){const o=Dr(e,t,n);if(o)return o}let r=null,i=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(r=t.x,i=t.y)}if(null!=r&&null!=i||(r=zr(e,n),i=Lr(e,n)),null!=r&&null!=i)return qr(t,n,{x:r,y:i});if("sticky"===o){const e=n.stickyPositionCache?.get(t);if(e)return e}return null}function Yr(e){return"string"==typeof e?.type?e.type:""}function Vr(e){return!!e&&"object"==typeof e&&gh.has(Yr(e))}function Gr(e,t,n){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),r=[];let i="";for(const t of e.split(/\s+/))t&&(i&&i.length+1+t.length>o?(r.push(i),i=t):i=i?`${i} ${t}`:t);return i&&r.push(i),r}function _r(e){return"primary"===e?.emphasis||!0===e?.defensive}function Hr(e,t,n={}){if("number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations))return Math.max(0,Math.floor(n.maxAnnotations));if(!(e>0&&t>0))return 1/0;const o=n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:yh;return Math.max(1,Math.round(e*t/o))}function Xr(e){let t;const n=e?.emphasis;t="primary"===n?100:"secondary"===n?10:50;const o=e?.provenance?.confidence;switch("number"==typeof o&&Number.isFinite(o)&&(t+=15*me(o,0,1)),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 Ur(e){const{annotations:t,width:n,height:o}=e,r=Math.max(0,e.minVisible??xh),i=Hr(n,o,e),s=t.map((e,t)=>{return{annotation:e,index:t,note:(n=e,Vr(n))};var n}),a=s.filter(e=>e.note);if(0===a.length||a.length<=i)return{visible:t.slice(),deferred:[],budget:i};const c=a.filter(e=>_r(e.annotation)),l=a.filter(e=>!_r(e.annotation)).sort((e,t)=>Xr(t.annotation)-Xr(e.annotation)||e.index-t.index),u=Math.max(0,i-c.length),d=Math.max(0,r-c.length),h=Math.min(l.length,Math.max(u,d)),f=/* @__PURE__ */new Set([...c.map(e=>e.index),...l.slice(0,h).map(e=>e.index)]),m=[],p=[];for(const{annotation:e,index:t,note:n}of s)!n||f.has(t)?m.push(e):p.push(e);return{visible:m,deferred:p,budget:i}}function Kr(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:$h,dy:Sh}}function Zr(e){const t=e?.familiarity;if(!t)return Ch;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?Ch:n.reduce((e,t)=>e+t,0)/n.length}function Qr(e){if(!e)return 1;const t=Zr(e);return t<=2?1.5:t>=4?.6:1}function Jr(e){const t=e?.provenance;if(!t||"object"!=typeof t)return e;const n="string"==typeof t.source?Object.prototype.hasOwnProperty.call(Nh,t.source)?Nh[t.source]:t.source:null,o="number"==typeof t.confidence&&Number.isFinite(t.confidence)?`${Math.round(100*Math.max(0,Math.min(1,t.confidence)))}%`:null;if(!n&&!o)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const r=[n,o].filter(Boolean).join(" · "),i="string"==typeof e.label?e.label:"";return i.includes(`(${r})`)?e:{...e,label:i?`${i} (${r})`:`(${r})`}}function ei(e,t){let n=!1;const o=e.map(e=>oi(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,{...e,cohesion:t}):e);return n?o:e}function ti(e){if(!oi(e))return e;const t="string"==typeof e.mobileText?e.mobileText:void 0,n="string"==typeof e.shortText?e.shortText:void 0,o=t??n;return!o||"string"!=typeof e.label&&null!=e.label?e:{...e,label:o}}function ni(e){if("text"!==e.type||"string"!=typeof e.color)return e;const t="number"==typeof e.dx?e.dx:0,n="number"==typeof e.dy?e.dy:0;return Math.hypot(t,n)<Ih?e:{...e,_redundantConnector:!0}}function oi(e){return Vr(e)}function ri(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="function"==typeof(n=e)._noteLayout?n._noteLayout(n):void 0;var n;if(t)return{width:Math.max(24,t.width+10),height:Math.max(18,t.height+6)};const o="number"==typeof e.wrap?e.wrap:120,r=[...Gr("string"==typeof e.title?e.title:void 0,o,7),...Gr("string"==typeof e.label?e.label:void 0,o,7)],i=r.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(o,7*i)+10),height:Math.max(18,16*r.length+6)}}function ii(e,t,n,o,r){const i=e+n,s=t+o;return Math.abs(n)>Math.abs(o)?{x:n>=0?i+4:i-r.width-4,y:o<0?s-r.height:s,width:r.width,height:r.height}:{x:n>=0?i:i-r.width,y:o<0?s-r.height-4:s+4,width:r.width,height:r.height}}function si(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function ai(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 ci(e,t,n,o){const r=Math.max(0,o-e.x),i=Math.max(0,o-e.y),s=Math.max(0,e.x+e.width-(t-o)),a=Math.max(0,e.y+e.height-(n-o));return(r+s)*e.height+(i+a)*e.width}function li(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}function ui(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}function di(e,t,n,o,r,i,s,a){const c=si(e,s);let l=.4*Math.hypot(t.dx,t.dy)+80*ci(c,r,i,a);for(const e of n)l+=12*ai(c,e);for(const e of o)l+=4*ai(c,e);return l}function hi(e,t,n){if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const o=e.pointId??e.nodeId;if(null!=o&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===o);if(e)return{x:e.x,y:e.y}}const r=e.coordinates,i=n.scales?.geoProjection;if(Array.isArray(r)&&r.length>=2&&i){const e=r[0],t=r[1];if("number"==typeof e&&"number"==typeof t){const n=i([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?Br(e,t,n):{x:e.x,y:e.y}}function fi(e){const{annotations:t,context:n,defaultOffset:o=bh,notePadding:r=wh,markPadding:i=Mh,edgePadding:s=vh,preserveManualOffsets:a=!0,routeLongConnectors:c=!0,connectorThreshold:l=kh,density:u,progressiveDisclosure:d=!1,redundantCues:h=!1,responsive:f,mobile:m,cohesion:p,audience:g}=e,y=n.width||0,x=n.height||0,b="object"==typeof m?m:{},w=b.breakpoint??Ah,M=!!m&&y<=w,v=M&&!1!==b.preferShortText?t.map(ti):t,k=M&&!u?{maxAnnotations:b.maxAnnotations??("callout-list"===b.strategy?1:2),minVisible:b.minVisible??1}:u,$=d||M&&(!1!==b.progressiveDisclosure||"callout-list"===b.strategy),S=M&&!f?b.responsive??{minWidth:w}:f,I=M&&!p?b.cohesion:p;if(0===v.length||y<=0||x<=0)return v.slice();const A=[],C=ui(n,i);let N=!1;const j=v.map((e,t)=>{if(!oi(e))return e;const i=hi(e,t,n);if(!i)return e;const u=ri(!0===e.defensive?Jr(e):e);if(a&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=Kr(e),n="number"==typeof e.dx?e.dx:t.dx,o="number"==typeof e.dy?e.dy:t.dy;return A.push(si(ii(i.x,i.y,n,o,u),r)),e}var d;let h=null,f=1/0;for(const e of li(o)){const t=di(ii(i.x,i.y,e.dx,e.dy,u),e,A,C,y,x,r,s);t<f&&(h=e,f=t)}if(!h)return e;const m=si(ii(i.x,i.y,h.dx,h.dy,u),r);A.push(m);const p=Math.hypot(h.dx,h.dy),g=c&&p>=l&&"text"!==e.type&&"widget"!==e.type?{...e.connector||{end:"arrow"},type:"curve"}:e.connector;return N=!0,{...e,dx:h.dx,dy:h.dy,...g?{connector:g}:{}}}),F=N?j:v.slice();let E=F;if(h){let e=!1;const t=F.map(t=>{const n=ni(t);return n!==t&&(e=!0),n});E=e?t:F}{let e=!1;const t=E.map(t=>{if(!0!==t?.defensive)return t;const n=Jr(t);return n!==t&&(e=!0),n});E=e?t:E}const P=/* @__PURE__ */new Set;if(k){const e="object"==typeof k?k:{},t=Qr(g),n=1===t?e:{...e,maxAnnotations:Math.max(0,Math.round((e.maxAnnotations??Hr(y,x,e))*t))},{deferred:o}=Ur({annotations:E,width:y,height:x,...n});for(const e of o)P.add(e)}if(S){const e="object"==typeof S&&"number"==typeof S.minWidth?S.minWidth:Ah;if(y<=e)for(const e of E)oi(e)&&"secondary"===e.emphasis&&P.add(e)}if(P.size>0)for(const e of E)!0===e?.defensive&&P.delete(e);let z;return z=0===P.size?E:$?E.map(e=>P.has(e)?{...e,_annotationDeferred:!0}:e):E.filter(e=>!P.has(e)),I?ei(z,I):z}function mi(e,t=0){return"number"==typeof e&&Number.isFinite(e)?e:t}function pi(e){const t=mi(e.tight,Eh.tight),n=Math.max(t,mi(e.watch,Eh.watch));return{tight:t,watch:n,comfortable:Math.max(n,mi(e.comfortable,Eh.comfortable))}}function gi(e={}){const{tight:t,watch:n,comfortable:o}=pi(e);return[{id:"tight",name:"Tight",label:`Tight (< ${t}%)`,max:t,color:Ph.tight},{id:"watch",name:"Watch",label:`Watch (${t}% to < ${n}%)`,min:t,max:n,color:Ph.watch},{id:"moderate",name:"Moderate",label:`Moderate (${n}% to < ${o}%)`,min:n,max:o,color:Ph.moderate},{id:"comfortable",name:"Comfortable",label:`Comfortable (≥ ${o}%)`,min:o,color:Ph.comfortable}].filter(e=>null==e.min||null==e.max||e.max>e.min)}function yi(e,t={}){return Number.isFinite(e)?gi(t).find(t=>(null==t.min||e>=t.min)&&(null==t.max||e<t.max))??null:null}function xi(e,t={}){const n=t.fuels??jh,o=!0===t.includeZero,r=[];for(const t of e)if(t&&"number"==typeof t.t)for(const e of n){const n=mi(t.fuels?.[e]);!o&&n<=0||r.push({t:t.t,fuel:e,fuelLabel:Fh[e],mw:n,ba:t.ba})}return r}function bi(e){const t=[];for(const n of e){if(!n||"number"!=typeof n.t)continue;const e=mi(n.demandMw),o=n.forecastMw;"number"==typeof o&&Number.isFinite(o)&&t.push({t:n.t,a:e,b:o,demandMw:e,forecastMw:o,errorMw:e-o,ba:n.ba})}return t}function wi(e){const t=mi(e.demand);if(t<=0)return 0;const n=mi(e.capacityOrNetGen),o=mi(e.interchange);return(n+(o<0?-o:0)-t)/t*100}function Mi(e){return e.filter(e=>e&&"number"==typeof e.t).map(e=>{const t=mi(e.demandMw),n=mi(e.netGenMw),o=wi({demand:t,capacityOrNetGen:n,interchange:e.interchangeMw}),r=Math.max(0,mi(e.fuels?.wind))+Math.max(0,mi(e.fuels?.solar));return{t:e.t,ba:e.ba,reserveMarginPct:o,netLoadMw:t-r,demandMw:t,netGenMw:n}})}function vi(e={},t={}){const n=t.field,o=n?{field:n}:{},r=t.tightHatch??{type:"hatch",background:Ph.tight,stroke:"rgba(255, 240, 200, 0.55)",spacing:5,angle:-35,lineWidth:1.25,lineOpacity:.9},i={comfortable:{fill:t.comfortableFill??Ph.comfortable,fillOpacity:.85},moderate:{fill:t.moderateFill??Ph.moderate,fillOpacity:.85},watch:{fill:t.watchFill??Ph.watch,fillOpacity:.9},tight:{fill:r,stroke:t.tightFill??Ph.tight,strokeWidth:1,fillOpacity:1}};return gi(e).reverse().map(e=>({id:`reserve-${e.id}`,label:e.label,when:{...o,...null!=e.min?{gte:e.min}:{},...null!=e.max?{lt:e.max}:{}},style:i[e.id]}))}function ki(e={},t={}){const{tight:n,comfortable:o}=pi(e),[r,i]=t.extent??[],s=Math.min(n,mi(r,-50)),a=Math.max(o,mi(i,Math.max(o+30,40))),c={tight:.12,watch:.1,moderate:.08,comfortable:.06};return gi(e).map(e=>({type:"band",y0:e.min??s,y1:e.max??a,label:e.name,color:e.color,fillOpacity:c[e.id],emphasis:"secondary"}))}function $i(e,t){if(!e.length)return null;const n=[...e].filter(e=>e&&"number"==typeof e.t).sort((e,t)=>e.t-t.t);if(!n.length)return null;let o=n[n.length-1];if("number"==typeof t&&Number.isFinite(t)){const e=n.filter(e=>e.t<=t);o=e.length?e[e.length-1]:n[0]}const r=mi(o.demandMw),i=mi(o.netGenMw),s="number"==typeof o.forecastMw&&Number.isFinite(o.forecastMw)?o.forecastMw:null,a=wi({demand:r,capacityOrNetGen:i,interchange:o.interchangeMw}),c={};let l=null,u=0,d=0;for(const e of jh){const t=mi(o.fuels?.[e]);t<=0||(d+=t,c[e]=t,t>u&&(u=t,l=e))}if(d>0)for(const e of Object.keys(c))c[e]=c[e]/d;return{t:o.t,ba:o.ba,demandMw:r,forecastMw:s,forecastErrorMw:null==s?null:r-s,netGenMw:i,reserveMarginPct:a,topFuel:l,topFuelShare:d>0?u/d:0,topFuelMw:u,fuelShares:c}}function Si(e,t={}){const n=t.now??Date.now(),o=t.author??"system",r=t.source??"authored-scenario";return e.map(e=>{const i=(e.start+e.end)/2,s=new Date(e.start).toISOString();return{type:"x-band",x0:e.start,x1:e.end,label:e.label,color:"outage"===e.kind?"var(--semiotic-danger)":"var(--semiotic-warning)",fillOpacity:.12,emphasis:"secondary",x:i,y:e.y??e.value,note:e.note,provenance:{author:o,authorKind:"system",source:r,basis:"rule",..."number"==typeof t.confidence&&Number.isFinite(t.confidence)?{confidence:Math.min(1,Math.max(0,t.confidence))}:{},createdAt:s,stableId:e.id,dataVersion:String(e.start)},lifecycle:{status:"accepted",ttlHint:e.ttlHint??"P14D",anchor:"fixed"},_eventKind:e.kind,_createdAtMs:e.start,_nowMs:n}})}function Ii(e,t=12){return[...e].filter(e=>Number.isFinite(e.reserveMarginPct)).sort((e,t)=>e.reserveMarginPct-t.reserveMarginPct).slice(0,Math.max(0,t))}function Ai(e,t=0){return Number.isFinite(e)?`${e.toLocaleString(void 0,{maximumFractionDigits:t,minimumFractionDigits:t})} MW`:"—"}function Ci(e,t=1){return Number.isFinite(e)?`${e>0?"+":""}${e.toFixed(t)}%`:"—"}function Ni(e,t){if("function"==typeof e)return e;const n=e??t;return e=>Number(e[n])}function ji(e,t={}){const n=Ni(t.start,"start"),o=Ni(t.end,"end"),r=!1===t.sort?e.slice():e.slice().sort((e,t)=>n(e)-n(t)||o(t)-o(e)),i=new Oh;return{packed:r.map(e=>({item:e,track:i.assign(n(e),o(e))})),trackCount:Math.max(1,i.count)}}function Fi(e,t){const n=Ni(t.start,"start"),o=Ni(t.end,"end"),[r,i]=t.domain,s=t.step??1,a="half-open"===t.bounds;if(!Number.isFinite(r)||!Number.isFinite(i)||r>i||!Number.isFinite(s)||s<=0)return[];const c=(i-r)/s;if(c>=Number.MAX_SAFE_INTEGER||r<i&&(r+s<=r||i-s>=i))return[];const l=Math.min(.25,4*Number.EPSILON*Math.max(1,c)),u=Math.floor(c+l),d=c>Math.log2(e.length+1),h=[],f=[];if(d){for(const t of e){const e=n(t),r=o(t);e<=r&&(h.push(e),f.push(r))}h.sort((e,t)=>e-t),f.sort((e,t)=>e-t)}let m=0,p=0;const g=[];for(let t=0;t<=u;t++){const y=t>0&&t===u&&Math.abs(t-c)<=l?i:r+t*s;let x=0;if(d){for(;m<h.length&&h[m]<=y;)m++;for(;p<f.length&&(a?f[p]<=y:f[p]<y);)p++;x=m-p}else for(const t of e){const e=n(t),r=o(t);e<=y&&(a?y<r:y<=r)&&x++}g.push({value:y,count:x})}return g}function Ei(e,t,n){const o="x"===t?"width":"height",r=new Float64Array(e.length),i=new Float64Array(e.length),s=Array.from({length:e.length},(e,t)=>t);let a=0;const c=()=>{for(let s=0;s<e.length;s++){const a=(e[s][o]+Math.max(0,n))/2;r[s]=e[s][t]-a,i[s]=e[s][t]+a}s.sort((e,t)=>r[e]-r[t]||e-t),a=0;for(let e=0;e<s.length;e++){let t=e+1,n=s.length;for(;t<n;){const o=t+n>>>1;r[s[o]]<=i[s[e]]?t=o+1:n=o}a+=t-e-1}};return c(),{lower:r,upper:i,order:s,update:c,get pairs(){return a}}}function Pi(e,t,n,o,r=!1){const i="x"===t?"y":"x",s="x"===t?"width":"height",a="x"===t?"height":"width",c=Ei(e,t,n),l=Ei(e,i,n),u=new Float64Array(e.length);return()=>{u.fill(0),c.update(),r||l.update();const{order:d,lower:h,upper:f}=c.pairs<l.pairs?c:l;for(let r=0;r<d.length;r++){const c=d[r],l=e[c];for(let m=r+1;m<d.length&&h[d[m]]<=f[c];m++){const r=d[m],h=e[r];if(Math.abs(l[i]-h[i])>(l[a]+h[a])/2+n)continue;const f=h[t]-l[t]||(l.id<h.id?-.5:.5),p=(l[s]+h[s])/2+n-Math.abs(f);if(p<=0)continue;const g=p*o*Math.sign(f);u[c]-=g,u[r]+=g}}return u}}function zi(e,t,n){const o=n?.orientation??"vertical",r=n?.bend??0,i=n?.minAlong??18,s=(e,t)=>(e+t)/2;if("vertical"===o){if(Math.abs(t.y-e.y)<i){const n=e.x<=t.x?1:-1,o=s(e.x,t.x)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${o},${s(e.y,t.y)} ${t.x},${t.y}`}const n=s(e.y,t.y)+r;return`M${e.x},${e.y} C${e.x},${n} ${t.x},${n} ${t.x},${t.y}`}if(Math.abs(t.x-e.x)<i){const n=e.y<=t.y?1:-1,o=s(e.y,t.y)+n*(22+Math.abs(r));return`M${e.x},${e.y} Q${s(e.x,t.x)},${o} ${t.x},${t.y}`}const a=s(e.x,t.x)+r;return`M${e.x},${e.y} C${a},${e.y} ${a},${t.y} ${t.x},${t.y}`}function Li(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=(e.y+t.y)/2;return`M${e.x},${e.y} L${e.x},${n} L${t.x},${n} L${t.x},${t.y}`}const o=(e.x+t.x)/2;return`M${e.x},${e.y} L${o},${e.y} L${o},${t.y} L${t.x},${t.y}`}function Oi(e,t,n){if("vertical"===(n?.orientation??"vertical")){const n=t.cy>=e.cy;return{from:{x:e.cx,y:e.cy+(n?e.height/2:-e.height/2)},to:{x:t.cx,y:t.cy+(n?-t.height/2:t.height/2)}}}const o=t.cx>=e.cx;return{from:{x:e.cx+(o?e.width/2:-e.width/2),y:e.cy},to:{x:t.cx+(o?-t.width/2:t.width/2),y:t.cy}}}function Ti(e,t){const n=t?.spread??5;return t?.modulo&&t.modulo>0?(e%t.modulo-(t.modulo-1)/2)*n:(e-((t?.count??1)-1)/2)*n}function Ri(e,t){const n=1-t,o=n*n*n,r=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:o*e.p0.x+r*e.p1.x+i*e.p2.x+s*e.p3.x,y:o*e.p0.y+r*e.p1.y+i*e.p2.y+s*e.p3.y}}function Wi(e,t){const n=1-t,o=3*n*n,r=6*n*t,i=3*t*t;return{x:o*(e.p1.x-e.p0.x)+r*(e.p2.x-e.p1.x)+i*(e.p3.x-e.p2.x),y:o*(e.p1.y-e.p0.y)+r*(e.p2.y-e.p1.y)+i*(e.p3.y-e.p2.y)}}function qi(e){return`M${e.p0.x},${e.p0.y} C${e.p1.x},${e.p1.y} ${e.p2.x},${e.p2.y} ${e.p3.x},${e.p3.y}`}function Di(e,t){const n=Pi(e,t?.axis??"x",t?.padding??0,t?.strength??.5)(),o=/* @__PURE__ */new Map;return e.forEach((e,t)=>o.set(e.id,(o.get(e.id)??0)+n[t])),o}function Bi(e,t,n=!1){if("function"==typeof e)return n?t=>e(ye(t)??t):e;const o=e??t;return e=>ge(e,o,void 0)}function Yi(e,t,n,o){return Vi(e,t,n,o,!1)}function Vi(e,t,n,o,r){const i=o.fixedAxis??"y",s=Bi(o.fixedAccessor,"fixed",r),a=e=>String(Bi(o.sourceAccessor,"source",r)(e)),c=e=>String(Bi(o.targetAccessor,"target",r)(e)),l=o.size??(()=>Rh),u=o.iterations??180,d=o.attraction??.012,h=o.anchorStrength??.003,f=o.collisionStrength??.12,m=o.collisionPadding??15,p=o.edgePadding??42,g=o.fixedPadding??16,y=o.damping??.72,x=o.spread??1,[b,w]=o.fixedDomain;if(![b,w,n.x,n.y,n.width,n.height].every(Number.isFinite)||n.width<=0||n.height<=0)return{positioned:[],byId:/* @__PURE__ */new Map};const M=w-b||1,v=("y"===i?n.y:n.x)+g,k=("y"===i?n.y+n.height:n.x+n.width)-g,$=("y"===i?n.x:n.y)+p,S=("y"===i?n.x+n.width:n.y+n.height)-p,I=Math.max(1,S-$),A=e.flatMap(e=>{const t=s(e);if("number"!=typeof t&&("string"!=typeof t||!t.trim()))return[];const n=Number(t),i=v+(n-b)/M*(k-v);if(!Number.isFinite(n)||!Number.isFinite(i))return[];const a=ye(e)??e,c=(u=e,String(Bi(o.idAccessor,"id",r)(u)));var u;const{width:d,height:h}=l(a);if(![d,h].every(e=>Number.isFinite(e)&&e>0))return[];const f=$+No(c)*I;return[{data:a,id:c,width:d,height:h,fixedValue:n,fixed:i,free:f,anchor:f}]}),C=e=>"y"===i?e.width:e.height,N=new Map(A.map((e,t)=>[e.id,t])),j=[];for(const e of t){const t=N.get(a(e)),n=N.get(c(e));void 0!==t&&void 0!==n&&j.push([t,n])}const F=A.map(e=>({id:e.id,x:"y"===i?e.free:e.fixed,y:"y"===i?e.fixed:e.free,width:e.width,height:e.height})),E="y"===i?"x":"y",P=Pi(F,E,m,f,!0),z=new Float64Array(A.length);for(let e=0;e<u;e++){z.fill(0);for(const[e,t]of j){const n=(A[t].free-A[e].free)*d;z[e]+=n,z[t]-=n}for(let e=0;e<A.length;e++){const t=A[e];z[e]+=(t.anchor-t.free)*h,F[e][E]=t.free}const e=P();for(let t=0;t<A.length;t++){const n=A[t];n.free+=(z[t]+e[t])*y;const o=C(n)/2;n.free=Math.max($+o,Math.min(S-o,n.free))}}if(1!==x){const e=($+S)/2;for(const t of A){const n=C(t)/2;t.free=Math.max($+n,Math.min(S-n,e+(t.free-e)*x))}}const L=A.map(e=>({data:e.data,id:e.id,x:"y"===i?e.free:e.fixed,y:"y"===i?e.fixed:e.free,width:e.width,height:e.height,fixedValue:e.fixedValue}));return{positioned:L,byId:new Map(L.map(e=>[e.id,e]))}}function Gi(e){let t=0;for(const n of e)t+=Bh[n]??(n>="0"&&n<="9"?Yh:(n.codePointAt(0)??0)>=11904?Gh:Vh);return t}function _i(e,t){return Math.max(8,Gi(e)*t*_h+Hh)}function Hi(e,t,n){if(!n)return{w:e,h:t};const o=Math.abs(n)*Math.PI/180,r=Math.cos(o),i=Math.sin(o);return{w:e*r+t*i,h:e*i+t*r}}function Xi(e,t){let n=t>>>0;for(const t of e){n=Co(t.col,n);for(const e of t.rows)n=Co(`${e.text}␟${e.weight}␟${e.segment}`,n)}return(n>>>0).toString(36)}function Ui(e){const{plans:t,colW:n,bodyH:o,yTop:r,yBot:i,segToY:s,collisionPadding:a}=e,c=n*o;let l=1/0,u=1/0;for(const o of t){let t=0;for(const e of o.rows){const o=Gi(e.text)*_h;t+=o*qh*e.baseFont*e.baseFont;const r=Hi(o,qh,e.rotation);u=Math.min(u,(n-8-Hh)/(r.w*e.baseFont))}t>0&&(l=Math.min(l,Math.sqrt(e.packingDensity*c/t)))}const d=e=>{const o=[],c=[];return t.forEach((t,l)=>{if(n<=0)return;const u=t.colLeft+4,d=t.colLeft+n-4,h=t.rows.map((t,o)=>{const r=e*t.baseFont,i=Math.max(Dh,r),a=Hi(_i(t.text,i),i*qh+2,t.rotation);return{rowIndex:o,id:t.id,font:i,floored:t.floored||r<Dh,rotation:t.rotation,w:a.w,h:a.h,anchorY:s(t.segment),seed:(No(t.id)-.5)*Math.min(.5*n,80)}}).sort((e,t)=>t.font-e.font||(e.id<t.id?-1:1)),f=new Xh(Uh);for(const e of h){const n=e.w/2,s=e.h/2,h=me(t.center+e.seed,u+n,d-n),m=e.anchorY;let p=null;for(let t=0;t<Kh;t++){const o=3.2*Math.sqrt(t),c=2.399963229728653*t,l={x:me(h+o*Math.cos(c),u+n,d-n),y:me(m+o*Math.sin(c),r+s,i-s),w:e.w,h:e.h};if(!f.collides(l,a)){p=l;break}}p?(f.insert(p),o.push({planIndex:l,rowIndex:e.rowIndex,id:e.id,x:p.x,y:p.y,fontSize:e.font,rotation:e.rotation,w:e.w,h:e.h,floored:e.floored})):c.push({planIndex:l,rowIndex:e.rowIndex})}}),{placements:o,unplaced:c}};let h=e.scaleToFit?Math.min(1,l,u):Math.min(1,u),f=d(h);if(e.scaleToFit)for(let e=0;e<6&&f.unplaced.length>0&&h>.1;e++)h*=.88,f=d(h);return f}function Ki(e){const t=Number(e.segmentDomain?.[0]),n=Number(e.segmentDomain?.[1]),o=Number.isFinite(t)?t:0,r=Number.isFinite(n)?n:o,i=r<o?-1:1,s=Math.abs(r-o),a=Number(e.currentSegment),c=Number.isFinite(a)?me((a-o)*i,0,s):0,l=(e,t)=>{const n=Number(e);return Number.isFinite(n)?me(n,0,1):t},u=l(e.oldestOpacity,.25),d=l(e.currentOpacity,1),h=l(e.futureOpacity,0);return{weightOpacity:!0===e.combineWeightOpacity,wordOpacity:({segment:e})=>{const t=Number(e);if(!Number.isFinite(t))return h;const n=(t-o)*i;if(n>c)return h;if(0===c)return d;const r=me(n/c,0,1);return u+(d-u)*r}}}function Zi(e){const t=e.config,{plot:n}=e.dimensions,o={nodes:[],unplaced:[],sizeFloored:[]};if(n.width<=0||n.height<=0||0===e.data.length)return o;const r=pe(t.textAccessor),i=e=>{const n=Number(pe(t.weightAccessor)(e));return Number.isFinite(n)&&n>0?n:0},s=pe(t.columnAccessor),a=e=>Number(pe(t.segmentAccessor)(e)),c=t.minFontSize??11,l=t.maxFontSize??42,u=t.columnGutter??18,d=t.collisionPadding??2,h=!1!==t.showColumnLabels,f=!1!==t.showSegmentAxis,m=t.segmentTickCount??6,p=t.segmentTickFormat??(e=>String(Math.round(e))),g=t.rotate??0,y=!0===t.repeatWords,x=!1!==t.scaleToFit,b=t.packingDensity??.6,w="string"==typeof t.textAccessor?t.textAccessor:"word",M="string"==typeof t.weightAccessor?t.weightAccessor:"weight",v="string"==typeof t.columnAccessor?t.columnAccessor:"column",k="string"==typeof t.segmentAccessor?t.segmentAccessor:"segment",$=[],S=/* @__PURE__ */new Map;let I=1/0,A=-1/0;for(let t=0;t<e.data.length;t++){const n=e.data[t],o=String(s(n)),c=String(r(n)),l=i(n),u=a(n);c&&Number.isFinite(u)&&(S.has(o)||($.push(o),S.set(o,[])),S.get(o).push({col:o,text:c,weight:l,segment:u,datum:n,dataIndex:t}),u<I&&(I=u),u>A&&(A=u))}if(0===$.length)return o;if(!y)for(const[e,t]of S){const n=/* @__PURE__ */new Map;for(const e of t){const t=n.get(e.text);(!t||e.weight>t.weight)&&n.set(e.text,e)}S.set(e,[...n.values()])}let C=1/0,N=-1/0;for(const e of S.values())for(const t of e)t.weight<C&&(C=t.weight),t.weight>N&&(N=t.weight);if(!Number.isFinite(C))return o;const j=t.columnOrder?[...t.columnOrder.filter(e=>S.has(e)),...$.filter(e=>!t.columnOrder.includes(e))]:$,F=new Map(j.map(n=>[n,t.columnColor?.(n)||e.resolveColor(n)])),[E,P]=t.segmentDomain??[I,A],z=P-E||1,L=N-C||1,O=h?22:0,T=f?52:0,R=n.x+T,W=n.y+O,q=Math.max(0,n.width-T),D=Math.max(0,n.height-O),B=j.length,Y=Math.max(0,q-u*Math.max(0,B-1)),V=B>0?Y/B:0,G=W+14,_=W+D-14,H=e=>G+(e-E)/z*(_-G),X=j.map((e,n)=>{const o=F.get(e),r=(S.get(e)??[]).map((r,i)=>{const s={word:r.text,column:r.col,weight:r.weight,segment:r.segment,datum:r.datum,dataIndex:r.dataIndex,columnIndex:n,resolvedColumnColor:o},a=t.wordOpacity?Number(t.wordOpacity(s)):1,u=t.wordColor?.(s),d=`${e}::${r.text}::${i}`,h=(f=r.weight,N>0?l*Math.sqrt(f/N):0);var f;return{id:d,text:r.text,weight:r.weight,segment:r.segment,baseFont:Math.max(c,h),floored:h<c,rotation:g>0?2*(No(d+"r")-.5)*g:0,opacity:Number.isFinite(a)?me(a,0,1):0,color:u||o,info:s}});return 0===r.length?null:{col:e,colLeft:R+n*(V+u),center:R+n*(V+u)+V/2,rows:r}}).filter(e=>null!==e),U=ve([n.x,n.y,n.width,n.height,O,T,u,d,c,l,g,x,b,E,P,X.length,Xi(X,2166136261),Xi(X,16777619)]),K=Qh.getOrCompute(U,()=>Ui({plans:X,colW:V,bodyH:D,yTop:G,yBot:_,segToY:H,collisionPadding:d,packingDensity:b,scaleToFit:x})),Z=(e,t)=>X[e].rows[t],Q=K.unplaced.map(({planIndex:e,rowIndex:t})=>Z(e,t).info),J=K.placements.map(e=>{const t=Z(e.planIndex,e.rowIndex),n=X[e.planIndex].col,o=Math.sqrt((t.weight-C)/L);return{id:e.id,text:t.text,x:e.x,y:e.y,w:e.w,h:e.h,fontSize:e.fontSize,rotation:e.rotation,floored:e.floored,color:t.color,opacity:t.opacity,info:t.info,datum:be(e=>{for(const n of Object.keys(t.info.datum))e(n,t.info.datum[n]);e("word",t.text),e("weight",t.weight),e("column",n),e("segment",t.segment),"word"!==w&&e(w,t.text),"weight"!==M&&e(M,t.weight),"column"!==v&&e(v,n),"segment"!==k&&e(k,t.segment),e("__strength",.5+.5*o)})}}),ee=J.filter(e=>e.opacity>0);return{nodes:ee.map(e=>{const t=e.rotation?e.w:_i(e.text,e.fontSize),n=e.rotation?e.h:e.fontSize*qh;return{type:"rect",x:e.x-t/2,y:e.y-n/2,w:t,h:n,style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:e.datum,group:String(e.datum.column),_transitionKey:e.id}}),overlays:/* @__PURE__ */ /* @__PURE__ */(0,Zh.jsxs)("g",{className:"semiotic-word-trails","data-unplaced-count":Q.length||void 0,children:[f&&Qi({x:n.x+T-10,yTop:G,yBot:_,segLo:E,segHi:P,segToY:H,tickCount:m,tickFormat:p,color:`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,label:t.segmentAxisLabel,labelX:n.x}),h&&j.map((e,t)=>{if(V<=0)return null;const o=R+t*(V+u);/* @__PURE__ */ /* @__PURE__ */
|
|
91
|
+
return(0,Zh.jsx)("text",{x:o+V/2,y:n.y+14,textAnchor:"middle",fontSize:13,fontWeight:600,fill:F.get(e),style:{pointerEvents:"none"},children:e},`wt-col-${t}`)}),ee.map(e=>/* @__PURE__ */ /* @__PURE__ */(0,Zh.jsx)("text",{x:e.x,y:e.y,textAnchor:"middle",dominantBaseline:"central",fontSize:e.fontSize,fontWeight:600,fill:e.color,opacity:(!1===t.weightOpacity?1:Number(e.datum.__strength))*e.opacity,transform:e.rotation?`rotate(${e.rotation} ${e.x} ${e.y})`:void 0,style:{pointerEvents:"none"},children:e.text},`wt-${e.id}`))]}),restyle:()=>{},unplaced:Q,sizeFloored:J.filter(e=>e.floored).map(e=>e.info)}}function Qi(e){const t=[],n=e.segHi-e.segLo||1;for(let o=0;o<e.tickCount;o++)t.push(e.segLo+n*o/Math.max(1,e.tickCount-1));/* @__PURE__ */ /* @__PURE__ */
|
|
92
|
+
return(0,Zh.jsxs)("g",{className:"semiotic-word-trails-axis",style:{pointerEvents:"none"},children:[
|
|
96
93
|
/* @__PURE__ */
|
|
97
|
-
/* @__PURE__ */(0,
|
|
98
|
-
return(0,
|
|
94
|
+
/* @__PURE__ */(0,Zh.jsx)("line",{x1:e.x,y1:e.yTop,x2:e.x,y2:e.yBot,stroke:e.color,strokeWidth:1,opacity:.5}),t.map((t,n)=>{const o=e.segToY(t);/* @__PURE__ */ /* @__PURE__ */
|
|
95
|
+
return(0,Zh.jsxs)("g",{children:[
|
|
99
96
|
/* @__PURE__ */
|
|
100
|
-
/* @__PURE__ */(0,
|
|
97
|
+
/* @__PURE__ */(0,Zh.jsx)("line",{x1:e.x-4,y1:o,x2:e.x,y2:o,stroke:e.color,strokeWidth:1,opacity:.6}),
|
|
101
98
|
/* @__PURE__ */
|
|
102
|
-
/* @__PURE__ */(0,Jh.jsx)("text",{x:e.x-7,y:o,textAnchor:"end",dominantBaseline:"central",fontSize:11,fill:e.color,children:e.tickFormat(t)})]},`wt-tick-${n}`)}),e.label&&/* @__PURE__ */ /* @__PURE__ */(0,Jh.jsx)("text",{transform:`rotate(-90 ${e.labelX+10} ${(e.yTop+e.yBot)/2})`,x:e.labelX+10,y:(e.yTop+e.yBot)/2,textAnchor:"middle",fontSize:11,fontWeight:600,fill:e.color,children:e.label})]})}function rs(e){return null==e?void 0:String(e)}function is(e){const t=rs(e.id);return{type:"point",x:e.x,y:e.y,r:e.r??nf,style:{...tf,cursor:e.cursor},datum:e.datum,pointId:t,_transitionKey:t}}function ss(e){return is(e)}function as(e){const[[t,n],[o,r]]=e.bounds;return{type:"geoarea",pathData:e.pathData,centroid:e.centroid,bounds:e.bounds,screenArea:e.screenArea??Math.abs((o-t)*(r-n)),style:{...tf,cursor:e.cursor},datum:e.datum,group:e.group,interactive:!0}}function cs(e){return{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...tf,cursor:e.cursor},datum:e.datum,group:e.group,_transitionKey:rs(e.id)}}function ls(e){const t=rs(e.id);return"width"in e&&"height"in e?{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...tf,cursor:e.cursor},datum:e.datum,id:t,label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility}:{type:"circle",cx:e.x,cy:e.y,r:e.r??nf,style:{...tf,cursor:e.cursor},datum:e.datum,id:t,label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility}}function us(e){const t={style:{...tf,cursor:e.cursor},datum:e.datum,id:rs(e.id),label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility,interactive:e.interactive??!0};return"pathD"in e?(e.type&&"curved"!==e.type||(t.style.fill="none"),{type:e.type??"curved",pathD:e.pathD,...t}):{type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,...t}}function ds(e,t,n={}){const{coord:o,step:r=1,equals:i=Object.is,truthyOnly:s=!1}=n,a=[],c=t=>o?o(e[t],t):t,l=(e,t,n)=>{e.endIndex=t,e.count=t-e.startIndex+1,e.end=o?null!=n&&c(n)-c(t)<=r?c(n):c(t)+r:t+1,a.push(e)};let u=null;for(let n=0;n<e.length;n++){const a=t(e[n],n);if(s&&!a){u&&(l(u,u.endIndex,n),u=null);continue}const d=!(o&&n>0)||c(n)-c(n-1)<=r;u&&d&&i(u.value,a)?u.endIndex=n:(u&&l(u,u.endIndex,n),u={value:a,start:c(n),end:c(n),count:1,startIndex:n,endIndex:n})}return u&&l(u,u.endIndex,null),a}function hs(e,t,n=0){return t<=0?e:((e-n)%t+t)%t+n}function fs(e,t,n){if(n<=0)return t-e;let o=(t-e)%n;return o>n/2?o-=n:o<=-n/2&&(o+=n),o}function ms(e,t,n){return t<=n?e>=t&&e<=n:e>=t||e<=n}function ps(e,t,n,o){return n<=o?e.filter(e=>ms(t(e),n,o)):[...e.filter(e=>t(e)>=n),...e.filter(e=>t(e)<=o)]}function gs(e){const{desired:t,minGaps:n,weights:o}=e,r=t.length;if(0===r)return[];if(n.length!==Math.max(0,r-1))throw new Error("placeWithMinGap: minGaps must have desired.length - 1 entries");const i=new Array(r).fill(0);for(let e=1;e<r;e++)i[e]=i[e-1]+Math.max(0,Number.isFinite(n[e-1])?n[e-1]:0);const s=[];for(let e=0;e<r;e++){const n=Math.max(Number.EPSILON,Number.isFinite(o?.[e])?o[e]:1),r=(Number.isFinite(t[e])?t[e]:0)-i[e];for(s.push({start:e,end:e,weight:n,mean:r});s.length>1;){const e=s[s.length-1],t=s[s.length-2];if(t.mean<=e.mean)break;const n=t.weight+e.weight;s.splice(s.length-2,2,{start:t.start,end:e.end,weight:n,mean:(t.mean*t.weight+e.mean*e.weight)/n})}}const a=Number.isFinite(e.min)?e.min:-1/0,c=Number.isFinite(e.max)?e.max-i[r-1]:1/0,l=c<a?a:c,u=new Array(r);for(const e of s){const t=Math.max(a,Math.min(l,e.mean));for(let n=e.start;n<=e.end;n++)u[n]=t+i[n]}return u}function ys(e,t){let n=0,o=e.length-1,r=-1;for(;n<=o;){const i=n+o>>>1;e[i].at<=t?(r=i,n=i+1):o=i-1}return r<0?{at:t,before:0,after:0}:e[r]}function xs(e,t=0){if(0===e.length)return{adjacentClearance:[],positions:[]};const n=[],o=[0];for(let r=0;r<e.length-1;r++){const i=e[r],s=e[r+1],a=[.../* @__PURE__ */new Set([...i.map(e=>e.at),...s.map(e=>e.at)])].sort((e,t)=>e-t);let c=0;for(const e of a){const t=ys(i,e),n=ys(s,e);c=Math.max(c,t.after+n.before)}n.push(c),o.push(o[o.length-1]+c+t)}return{adjacentClearance:n,positions:o}}function bs(e,t,n,o={}){let r=[...e];if(r.length<=1)return r;let i=[...r],s=n(r),a=1;const c=Math.max(0,o.passes??6),l=Math.max(1,o.maxEvaluations??1/0);for(let e=0;e<c&&a<l;e++){const e=new Map(r.map((e,t)=>[e,t])),c=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map;for(const n of t){const t=e.get(n.source),o=e.get(n.target);if(null==t||null==o)continue;const r=Number.isFinite(n.weight)&&n.weight>0?n.weight:1;c.set(n.source,(c.get(n.source)??0)+o*r),l.set(n.source,(l.get(n.source)??0)+r),c.set(n.target,(c.get(n.target)??0)+t*r),l.set(n.target,(l.get(n.target)??0)+r)}r=r.map((e,t)=>({item:e,index:t,barycenter:(c.get(e)??t)/(l.get(e)??1)})).sort((e,t)=>e.barycenter-t.barycenter||(o.compare?.(e.item,t.item)??e.index-t.index)).map(e=>e.item);const u=n(r);if(a++,u<s)s=u,i=[...r];else if(u===s)break}return i}function ws(e,t,n={}){const o=[...e];if(o.length<=1)return o;let r=t(o),i=1;const s=Math.max(0,n.passes??6),a=Math.max(1,n.maxEvaluations??1/0);for(let e=0;e<s&&i<a;e++){let e=!1;for(let n=0;n<o.length-1&&i<a;n++){[o[n],o[n+1]]=[o[n+1],o[n]];const s=t(o);i++,s<r?(r=s,e=!0):[o[n],o[n+1]]=[o[n+1],o[n]]}if(!e)break}return o}function Ms(e,t,n={}){const o=[...e],r=o.length;if(r<=1||r>(n.maxItems??8))return o;const i=Math.max(1,n.maxEvaluations??1/0);let s=0,a=[...o],c=1/0;const l=()=>{if(s>=i)return;const e=t(o);s++,e<c&&(c=e,a=[...o])};l();const u=new Array(r).fill(0);let d=0;for(;d<r&&s<i;)if(u[d]<d){const e=d%2==0?0:u[d];[o[e],o[d]]=[o[d],o[e]],l(),u[d]++,d=0}else u[d]=0,d++;return a}function vs(e,t,n=()=>!0){let o=0;for(let r=0;r<e.length;r++){const[i,s]=t(e[r]);for(let a=r+1;a<e.length;a++){if(!n(e[r],e[a]))continue;const[c,l]=t(e[a]);(i-c)*(s-l)<0&&o++}}return o}function ks(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,s=t.paddingRight??r,a=Math.max(0,n-i-s),c=e.length>1?a/(e.length-1):0,l=/* @__PURE__ */new Map;return e.forEach((e,t)=>{l.set(e.id,{id:e.id,x:i+c*t,y:o,index:t})}),l}function $s(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,s=t.paddingRight??r,a=t.gap??8,c=!1!==t.distribute,l=t.estimateWidth??(e=>Ss(e.label??e.id)),u=e.map((e,t)=>Math.max(1,l(e,t))),d=u.reduce((e,t)=>e+t,0)+a*Math.max(0,e.length-1),h=Math.max(0,n-i-s),f=Math.max(0,h-d),m=c&&e.length>1?f/(e.length-1):0,p=/* @__PURE__ */new Map;let g=i;return c||1!==e.length||(g=i+Math.max(0,(h-u[0])/2)),e.forEach((e,t)=>{const n=u[t];p.set(e.id,{id:e.id,x:g+n/2,y:o,index:t,width:n}),g+=n+a+m}),p}function Ss(e,t=38,n=7.4,o=20){return Math.max(t,String(e??"").length*n+o)}function Is(e){const t=e.map(e=>{const t=Math.min(e.a,e.b),n=Math.max(e.a,e.b);return{span:e,a:t,b:n,width:n-t}}).sort((e,t)=>e.width-t.width||e.a-t.a),n=new Rh,o=t.map(e=>{const t=n.assign(e.a,e.b);return{span:e.span,level:t}}),r=Math.max(0,n.count-1);return{packed:o,maxLevel:r,levelCount:o.length?r+1:1}}function As(e){const t=e.labelRoom??18,n=Math.max(48,e.baselineY-e.ceilingY-28),o=Math.max(1,e.levelCount),r=Math.min(42,Math.max(26,.18*n)),i=Math.max(24,n-r-t),s=o<=1?i:i/Math.max(1,o-1);return{arcLift:r,levelStep:Math.min(72,Math.max(28,s))}}function Cs(e,t,n,o,r={}){const i=n-(r.footLift??26);return`M${e} ${i}Q${(e+t)/2} ${o} ${t} ${i}`}function Ns(e,t,n){return e-n.arcLift-t*n.levelStep}function js(e,t=Fs){if(!e.length)return{shared:[],exclusive:[]};if(1===e.length)return{shared:[...e[0]],exclusive:[[]]};const n=e.map(e=>new Set(e.map(e=>t(e)))),o=/* @__PURE__ */new Set;for(const e of n[0])n.every(t=>t.has(e))&&o.add(e);const r=[],i=/* @__PURE__ */new Set;for(const n of e[0]){const e=t(n);o.has(e)&&!i.has(e)&&(r.push(n),i.add(e))}return{shared:r,exclusive:e.map(e=>e.filter(e=>!o.has(t(e))))}}function Fs(e){if(null==e)return String(e);if("object"!=typeof e)return String(e);const t=e;if(null!=t.id)return String(t.id);const n=t.sourceTokenId??t.source,o=t.targetTokenId??t.target,r=t.relation??t.label??"";return`${String(n)}|${String(o)}|${String(r)}`}function Es(e,t,n){const o=n?.center?.x??0,r=n?.center?.y??0;return{x:o+Math.sin(e)*t,y:r-Math.cos(e)*t}}function Ps(e,t,n){const o=n?.center?.x??0,r=n?.center?.y??0;return(Math.atan2(e-o,-(t-r))+rf)%rf}function zs(e,t){const[n,o]=e,r=o-n||1,i=t?.startAngle??0,s=t?.endAngle??rf;return e=>i+(e-n)/r*(s-i)}function Ls(e,t){const[n,o]=e,[r,i]=t,s=o-n||1;return e=>r+(e-n)/s*(i-r)}function Os(e,t,n,o,r){const i=r?.center,s=(e,t)=>{const{x:n,y:o}=Es(e,t,{center:i});return`${Ts(n)},${Ts(o)}`},a=Math.max(0,n),c=Math.max(a,o),l=Math.abs(t-e),u=t>=e?1:0;if(l>=rf-1e-6){const e=i?.x??0,t=i?.y??0,n=`${Ts(e)},${Ts(t-c)}`,o=`${Ts(e)},${Ts(t+c)}`;let r=`M${n} A${Ts(c)},${Ts(c)} 0 1 1 ${o} A${Ts(c)},${Ts(c)} 0 1 1 ${n} Z`;if(a>0){const n=`${Ts(e)},${Ts(t-a)}`,o=`${Ts(e)},${Ts(t+a)}`;r+=` M${n} A${Ts(a)},${Ts(a)} 0 1 0 ${o} A${Ts(a)},${Ts(a)} 0 1 0 ${n} Z`}return r}const d=l>Math.PI?1:0,h=s(e,c),f=s(t,c);if(a<=0){const e=i?.x??0,t=i?.y??0;return`M${Ts(e)},${Ts(t)} L${h} A${Ts(c)},${Ts(c)} 0 ${d} ${u} ${f} Z`}const m=s(t,a),p=s(e,a);return`M${h} A${Ts(c)},${Ts(c)} 0 ${d} ${u} ${f} L${m} A${Ts(a)},${Ts(a)} 0 ${d} ${1===u?0:1} ${p} Z`}function Ts(e){return Math.round(1e3*e)/1e3}function Rs(e,t){return{x:e.x+t.x,y:e.y+t.y}}function Ws(e,t){return{x:e.x-t.x,y:e.y-t.y}}function qs(e,t){return{x:e.x*t,y:e.y*t}}function Ds(e){return Math.hypot(e.x,e.y)}function Bs(e){const t=Ds(e)||1;return{x:e.x/t,y:e.y/t}}function Ys(e,t){const[n,o]=e.viewBox??sf,[r,i]=e.anchor??af,s=o>0?o:1,a=Math.max(0,t)/s,c=(n>0?n:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-r*c,offsetY:-i*l}}function Vs(e,t){const n=Ys(e,t),o=[[n.offsetX,n.offsetY],[n.offsetX+n.width,n.offsetY],[n.offsetX,n.offsetY+n.height],[n.offsetX+n.width,n.offsetY+n.height]];let r=0;for(const[e,t]of o){const n=Math.sqrt(e*e+t*t);n>r&&(r=n)}return r}function Gs(e,t,n=0,o="horizontal"){const[r,i]=e.viewBox??sf,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a<=s?{x:0,y:0,width:0,height:0}:s<=0&&a>=1?null:"vertical"===o?{x:0,y:i*(1-a),width:r,height:i*(a-s)}:{x:r*s,y:0,width:r*(a-s),height:i}}function _s(e,t){const n=ot(e,100);return n>0?t/n*100*(t/n):Math.PI*t*t}function Hs(e){const t=[],n=e.colorMap?Object.entries(e.colorMap):e.keys?e.keys.map(t=>[t,e.color?e.color(t):void 0]):[];if(n.length>0){const o=e.colorType??"fill",r=n.map(([e,t])=>({label:e,color:t})),i="line"===o?e=>({stroke:e.color??lf,strokeWidth:2,fill:"none"}):e=>({fill:e.color??lf,stroke:e.color??lf});t.push({type:o,label:e.colorLabel??"",items:r,styleFn:i})}if(e.symbolMap&&Object.keys(e.symbolMap).length>0){const n=e.symbolColor??lf,o=Object.entries(e.symbolMap).map(([e,t])=>({label:e,shape:t,color:n}));t.push({label:e.symbolLabel??"",items:o,styleFn:()=>({}),type:e=>{const t=e.shape;/* @__PURE__ */ /* @__PURE__ */
|
|
103
|
-
return(0,
|
|
99
|
+
/* @__PURE__ */(0,Zh.jsx)("text",{x:e.x-7,y:o,textAnchor:"end",dominantBaseline:"central",fontSize:11,fill:e.color,children:e.tickFormat(t)})]},`wt-tick-${n}`)}),e.label&&/* @__PURE__ */ /* @__PURE__ */(0,Zh.jsx)("text",{transform:`rotate(-90 ${e.labelX+10} ${(e.yTop+e.yBot)/2})`,x:e.labelX+10,y:(e.yTop+e.yBot)/2,textAnchor:"middle",fontSize:11,fontWeight:600,fill:e.color,children:e.label})]})}function Ji(e){return null==e?void 0:String(e)}function es(e){const t=Ji(e.id);return{type:"point",x:e.x,y:e.y,r:e.r??ef,style:{...Jh,cursor:e.cursor},datum:e.datum,pointId:t,_transitionKey:t}}function ts(e){return es(e)}function ns(e){const[[t,n],[o,r]]=e.bounds;return{type:"geoarea",pathData:e.pathData,centroid:e.centroid,bounds:e.bounds,screenArea:e.screenArea??Math.abs((o-t)*(r-n)),style:{...Jh,cursor:e.cursor},datum:e.datum,group:e.group,interactive:!0}}function os(e){return{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...Jh,cursor:e.cursor},datum:e.datum,group:e.group,_transitionKey:Ji(e.id)}}function rs(e){const t=Ji(e.id);return"width"in e&&"height"in e?{type:"rect",x:e.x,y:e.y,w:e.width,h:e.height,style:{...Jh,cursor:e.cursor},datum:e.datum,id:t,label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility}:{type:"circle",cx:e.x,cy:e.y,r:e.r??ef,style:{...Jh,cursor:e.cursor},datum:e.datum,id:t,label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility}}function is(e){const t={style:{...Jh,cursor:e.cursor},datum:e.datum,id:Ji(e.id),label:e.label,accessibleDatum:e.accessibleDatum,accessibility:e.accessibility,interactive:e.interactive??!0};return"pathD"in e?(e.type&&"curved"!==e.type||(t.style.fill="none"),{type:e.type??"curved",pathD:e.pathD,...t}):{type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,...t}}function ss(e,t,n={}){const{coord:o,step:r=1,equals:i=Object.is,truthyOnly:s=!1}=n,a=[],c=t=>o?o(e[t],t):t,l=(e,t,n)=>{e.endIndex=t,e.count=t-e.startIndex+1,e.end=o?null!=n&&c(n)-c(t)<=r?c(n):c(t)+r:t+1,a.push(e)};let u=null;for(let n=0;n<e.length;n++){const a=t(e[n],n);if(s&&!a){u&&(l(u,u.endIndex,n),u=null);continue}const d=!(o&&n>0)||c(n)-c(n-1)<=r;u&&d&&i(u.value,a)?u.endIndex=n:(u&&l(u,u.endIndex,n),u={value:a,start:c(n),end:c(n),count:1,startIndex:n,endIndex:n})}return u&&l(u,u.endIndex,null),a}function as(e,t,n=0){return t<=0?e:((e-n)%t+t)%t+n}function cs(e,t,n){if(n<=0)return t-e;let o=(t-e)%n;return o>n/2?o-=n:o<=-n/2&&(o+=n),o}function ls(e,t,n){return t<=n?e>=t&&e<=n:e>=t||e<=n}function us(e,t,n,o){return n<=o?e.filter(e=>ls(t(e),n,o)):[...e.filter(e=>t(e)>=n),...e.filter(e=>t(e)<=o)]}function ds(e){const{desired:t,minGaps:n,weights:o}=e,r=t.length;if(0===r)return[];if(n.length!==Math.max(0,r-1))throw new Error("placeWithMinGap: minGaps must have desired.length - 1 entries");const i=new Array(r).fill(0);for(let e=1;e<r;e++)i[e]=i[e-1]+Math.max(0,Number.isFinite(n[e-1])?n[e-1]:0);const s=[];for(let e=0;e<r;e++){const n=Math.max(Number.EPSILON,Number.isFinite(o?.[e])?o[e]:1),r=(Number.isFinite(t[e])?t[e]:0)-i[e];for(s.push({start:e,end:e,weight:n,mean:r});s.length>1;){const e=s[s.length-1],t=s[s.length-2];if(t.mean<=e.mean)break;const n=t.weight+e.weight;s.splice(s.length-2,2,{start:t.start,end:e.end,weight:n,mean:(t.mean*t.weight+e.mean*e.weight)/n})}}const a=Number.isFinite(e.min)?e.min:-1/0,c=Number.isFinite(e.max)?e.max-i[r-1]:1/0,l=c<a?a:c,u=new Array(r);for(const e of s){const t=Math.max(a,Math.min(l,e.mean));for(let n=e.start;n<=e.end;n++)u[n]=t+i[n]}return u}function hs(e,t){let n=0,o=e.length-1,r=-1;for(;n<=o;){const i=n+o>>>1;e[i].at<=t?(r=i,n=i+1):o=i-1}return r<0?{at:t,before:0,after:0}:e[r]}function fs(e,t=0){if(0===e.length)return{adjacentClearance:[],positions:[]};const n=[],o=[0];for(let r=0;r<e.length-1;r++){const i=e[r],s=e[r+1],a=[.../* @__PURE__ */new Set([...i.map(e=>e.at),...s.map(e=>e.at)])].sort((e,t)=>e-t);let c=0;for(const e of a){const t=hs(i,e),n=hs(s,e);c=Math.max(c,t.after+n.before)}n.push(c),o.push(o[o.length-1]+c+t)}return{adjacentClearance:n,positions:o}}function ms(e,t,n,o={}){let r=[...e];if(r.length<=1)return r;let i=[...r],s=n(r),a=1;const c=Math.max(0,o.passes??6),l=Math.max(1,o.maxEvaluations??1/0);for(let e=0;e<c&&a<l;e++){const e=new Map(r.map((e,t)=>[e,t])),c=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map;for(const n of t){const t=e.get(n.source),o=e.get(n.target);if(null==t||null==o)continue;const r=Number.isFinite(n.weight)&&n.weight>0?n.weight:1;c.set(n.source,(c.get(n.source)??0)+o*r),l.set(n.source,(l.get(n.source)??0)+r),c.set(n.target,(c.get(n.target)??0)+t*r),l.set(n.target,(l.get(n.target)??0)+r)}r=r.map((e,t)=>({item:e,index:t,barycenter:(c.get(e)??t)/(l.get(e)??1)})).sort((e,t)=>e.barycenter-t.barycenter||(o.compare?.(e.item,t.item)??e.index-t.index)).map(e=>e.item);const u=n(r);if(a++,u<s)s=u,i=[...r];else if(u===s)break}return i}function ps(e,t,n={}){const o=[...e];if(o.length<=1)return o;let r=t(o),i=1;const s=Math.max(0,n.passes??6),a=Math.max(1,n.maxEvaluations??1/0);for(let e=0;e<s&&i<a;e++){let e=!1;for(let n=0;n<o.length-1&&i<a;n++){[o[n],o[n+1]]=[o[n+1],o[n]];const s=t(o);i++,s<r?(r=s,e=!0):[o[n],o[n+1]]=[o[n+1],o[n]]}if(!e)break}return o}function gs(e,t,n={}){const o=[...e],r=o.length;if(r<=1||r>(n.maxItems??8))return o;const i=Math.max(1,n.maxEvaluations??1/0);let s=0,a=[...o],c=1/0;const l=()=>{if(s>=i)return;const e=t(o);s++,e<c&&(c=e,a=[...o])};l();const u=new Array(r).fill(0);let d=0;for(;d<r&&s<i;)if(u[d]<d){const e=d%2==0?0:u[d];[o[e],o[d]]=[o[d],o[e]],l(),u[d]++,d=0}else u[d]=0,d++;return a}function ys(e,t,n=()=>!0){let o=0;for(let r=0;r<e.length;r++){const[i,s]=t(e[r]);for(let a=r+1;a<e.length;a++){if(!n(e[r],e[a]))continue;const[c,l]=t(e[a]);(i-c)*(s-l)<0&&o++}}return o}function xs(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,s=t.paddingRight??r,a=Math.max(0,n-i-s),c=e.length>1?a/(e.length-1):0,l=/* @__PURE__ */new Map;return e.forEach((e,t)=>{l.set(e.id,{id:e.id,x:i+c*t,y:o,index:t})}),l}function bs(e,t){const n=Math.max(0,t.width),o=t.y,r=Math.min(74,Math.max(34,.08*n)),i=t.paddingLeft??r,s=t.paddingRight??r,a=t.gap??8,c=!1!==t.distribute,l=t.estimateWidth??(e=>ws(e.label??e.id)),u=e.map((e,t)=>Math.max(1,l(e,t))),d=u.reduce((e,t)=>e+t,0)+a*Math.max(0,e.length-1),h=Math.max(0,n-i-s),f=Math.max(0,h-d),m=c&&e.length>1?f/(e.length-1):0,p=/* @__PURE__ */new Map;let g=i;return c||1!==e.length||(g=i+Math.max(0,(h-u[0])/2)),e.forEach((e,t)=>{const n=u[t];p.set(e.id,{id:e.id,x:g+n/2,y:o,index:t,width:n}),g+=n+a+m}),p}function ws(e,t=38,n=7.4,o=20){return Math.max(t,String(e??"").length*n+o)}function Ms(e){const t=e.map(e=>{const t=Math.min(e.a,e.b),n=Math.max(e.a,e.b);return{span:e,a:t,b:n,width:n-t}}).sort((e,t)=>e.width-t.width||e.a-t.a),n=new Oh,o=t.map(e=>{const t=n.assign(e.a,e.b);return{span:e.span,level:t}}),r=Math.max(0,n.count-1);return{packed:o,maxLevel:r,levelCount:o.length?r+1:1}}function vs(e){const t=e.labelRoom??18,n=Math.max(48,e.baselineY-e.ceilingY-28),o=Math.max(1,e.levelCount),r=Math.min(42,Math.max(26,.18*n)),i=Math.max(24,n-r-t),s=o<=1?i:i/Math.max(1,o-1);return{arcLift:r,levelStep:Math.min(72,Math.max(28,s))}}function ks(e,t,n,o,r={}){const i=n-(r.footLift??26);return`M${e} ${i}Q${(e+t)/2} ${o} ${t} ${i}`}function $s(e,t,n){return e-n.arcLift-t*n.levelStep}function Ss(e,t=Is){if(!e.length)return{shared:[],exclusive:[]};if(1===e.length)return{shared:[...e[0]],exclusive:[[]]};const n=e.map(e=>new Set(e.map(e=>t(e)))),o=/* @__PURE__ */new Set;for(const e of n[0])n.every(t=>t.has(e))&&o.add(e);const r=[],i=/* @__PURE__ */new Set;for(const n of e[0]){const e=t(n);o.has(e)&&!i.has(e)&&(r.push(n),i.add(e))}return{shared:r,exclusive:e.map(e=>e.filter(e=>!o.has(t(e))))}}function Is(e){if(null==e)return String(e);if("object"!=typeof e)return String(e);const t=e;if(null!=t.id)return String(t.id);const n=t.sourceTokenId??t.source,o=t.targetTokenId??t.target,r=t.relation??t.label??"";return`${String(n)}|${String(o)}|${String(r)}`}function As(e,t,n){const o=n?.center?.x??0,r=n?.center?.y??0;return{x:o+Math.sin(e)*t,y:r-Math.cos(e)*t}}function Cs(e,t,n){const o=n?.center?.x??0,r=n?.center?.y??0;return(Math.atan2(e-o,-(t-r))+nf)%nf}function Ns(e,t){const[n,o]=e,r=o-n||1,i=t?.startAngle??0,s=t?.endAngle??nf;return e=>i+(e-n)/r*(s-i)}function js(e,t){const[n,o]=e,[r,i]=t,s=o-n||1;return e=>r+(e-n)/s*(i-r)}function Fs(e,t,n,o,r){const i=r?.center,s=(e,t)=>{const{x:n,y:o}=As(e,t,{center:i});return`${Es(n)},${Es(o)}`},a=Math.max(0,n),c=Math.max(a,o),l=Math.abs(t-e),u=t>=e?1:0;if(l>=nf-1e-6){const e=i?.x??0,t=i?.y??0,n=`${Es(e)},${Es(t-c)}`,o=`${Es(e)},${Es(t+c)}`;let r=`M${n} A${Es(c)},${Es(c)} 0 1 1 ${o} A${Es(c)},${Es(c)} 0 1 1 ${n} Z`;if(a>0){const n=`${Es(e)},${Es(t-a)}`,o=`${Es(e)},${Es(t+a)}`;r+=` M${n} A${Es(a)},${Es(a)} 0 1 0 ${o} A${Es(a)},${Es(a)} 0 1 0 ${n} Z`}return r}const d=l>Math.PI?1:0,h=s(e,c),f=s(t,c);if(a<=0){const e=i?.x??0,t=i?.y??0;return`M${Es(e)},${Es(t)} L${h} A${Es(c)},${Es(c)} 0 ${d} ${u} ${f} Z`}const m=s(t,a),p=s(e,a);return`M${h} A${Es(c)},${Es(c)} 0 ${d} ${u} ${f} L${m} A${Es(a)},${Es(a)} 0 ${d} ${1===u?0:1} ${p} Z`}function Es(e){return Math.round(1e3*e)/1e3}function Ps(e,t){return{x:e.x+t.x,y:e.y+t.y}}function zs(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ls(e,t){return{x:e.x*t,y:e.y*t}}function Os(e){return Math.hypot(e.x,e.y)}function Ts(e){const t=Os(e)||1;return{x:e.x/t,y:e.y/t}}function Rs(e,t){const[n,o]=e.viewBox??of,[r,i]=e.anchor??rf,s=o>0?o:1,a=Math.max(0,t)/s,c=(n>0?n:s)*a,l=s*a;return{width:c,height:l,scale:a,offsetX:-r*c,offsetY:-i*l}}function Ws(e,t){const n=Rs(e,t),o=[[n.offsetX,n.offsetY],[n.offsetX+n.width,n.offsetY],[n.offsetX,n.offsetY+n.height],[n.offsetX+n.width,n.offsetY+n.height]];let r=0;for(const[e,t]of o){const n=Math.sqrt(e*e+t*t);n>r&&(r=n)}return r}function qs(e,t,n=0,o="horizontal"){const[r,i]=e.viewBox??of,s=Math.min(1,Math.max(0,n)),a=Math.min(1,Math.max(0,t));return a<=s?{x:0,y:0,width:0,height:0}:s<=0&&a>=1?null:"vertical"===o?{x:0,y:i*(1-a),width:r,height:i*(a-s)}:{x:r*s,y:0,width:r*(a-s),height:i}}function Ds(e,t){const n=rt(e,100);return n>0?t/n*100*(t/n):Math.PI*t*t}function Bs(e){const t=[],n=e.colorMap?Object.entries(e.colorMap):e.keys?e.keys.map(t=>[t,e.color?e.color(t):void 0]):[];if(n.length>0){const o=e.colorType??"fill",r=n.map(([e,t])=>({label:e,color:t})),i="line"===o?e=>({stroke:e.color??af,strokeWidth:2,fill:"none"}):e=>({fill:e.color??af,stroke:e.color??af});t.push({type:o,label:e.colorLabel??"",items:r,styleFn:i})}if(e.symbolMap&&Object.keys(e.symbolMap).length>0){const n=e.symbolColor??af,o=Object.entries(e.symbolMap).map(([e,t])=>({label:e,shape:t,color:n}));t.push({label:e.symbolLabel??"",items:o,styleFn:()=>({}),type:e=>{const t=e.shape;/* @__PURE__ */ /* @__PURE__ */
|
|
100
|
+
return(0,sf.jsx)("path",{d:nt(t,Ds(t,cf-1)),transform:`translate(${cf},${cf})`,fill:e.color??n})}})}if(e.sizeStops&&e.sizeStops.length>0&&e.sizeRadius){const n=e.sizeRadius,o=e.sizeFormat??(e=>String(e)),r=e.sizeColor??af,i=e.sizeStops.map(e=>({label:o(e),r:Math.max(.5,n(e)),color:r}));t.push({label:e.sizeLabel??"",items:i,styleFn:()=>({}),type:e=>/* @__PURE__ */ /* @__PURE__ */(0,sf.jsx)("circle",{cx:cf,cy:cf,r:e.r,fill:e.color??r})})}return t}function Ys(e){const t=e.orientation??"vertical",n=e.swatchSize??14,o=e.gap??8,r=e.labelGap??6,i=e.fontSize??12,s=e.color??"var(--semiotic-text-secondary, #888)",a=n+o;let c=0;const l=[];return e.entries.forEach((e,u)=>{const d="vertical"===t?0:c,h="vertical"===t?c:0,f=e.color??e.line??s;l.push(
|
|
104
101
|
/* @__PURE__ */
|
|
105
|
-
/* @__PURE__ */(0,
|
|
102
|
+
/* @__PURE__ */(0,sf.jsxs)("g",{transform:`translate(${d},${h})`,children:[Vs(e,n,f,s),
|
|
106
103
|
/* @__PURE__ */
|
|
107
|
-
/* @__PURE__ */(0,
|
|
108
|
-
return(0,
|
|
109
|
-
return(0,
|
|
104
|
+
/* @__PURE__ */(0,sf.jsx)("text",{x:n+r,y:n/2,dominantBaseline:"middle",fontSize:i,fill:s,children:e.label})]},`legend-${u}`)),c+="vertical"===t?a:n+r+e.label.length*i*.58+o+8}),/* @__PURE__ */ /* @__PURE__ */(0,sf.jsx)("g",{className:e.className,transform:`translate(${e.x},${e.y})`,style:{pointerEvents:"none"},children:l},e.keyId)}function Vs(e,t,n,o){if(e.shape){const o=Ds(e.shape,t/2-1);/* @__PURE__ */ /* @__PURE__ */
|
|
105
|
+
return(0,sf.jsx)("path",{d:nt(e.shape,o),transform:`translate(${t/2},${t/2})`,fill:n})}if(e.hatch){const n=e.color??o;/* @__PURE__ */ /* @__PURE__ */
|
|
106
|
+
return(0,sf.jsxs)("g",{children:[
|
|
110
107
|
/* @__PURE__ */
|
|
111
|
-
/* @__PURE__ */(0,
|
|
108
|
+
/* @__PURE__ */(0,sf.jsx)("svg",{width:t,height:t,style:{overflow:"hidden"},children:[-t,-t/2,0,t/2].map((e,o)=>/* @__PURE__ */ /* @__PURE__ */(0,sf.jsx)("line",{x1:e,y1:t,x2:e+t,y2:0,stroke:n,strokeWidth:1,opacity:.7},o))}),
|
|
112
109
|
/* @__PURE__ */
|
|
113
|
-
/* @__PURE__ */(0,cf.jsx)("rect",{width:t,height:t,fill:"none",stroke:n,strokeWidth:1,opacity:.5,rx:2})]})}return e.line?/* @__PURE__ */ /* @__PURE__ */(0,cf.jsx)("rect",{y:t/2-1.5,width:t,height:3,rx:1.5,fill:e.line}):/* @__PURE__ */ /* @__PURE__ */(0,cf.jsx)("rect",{width:t,height:t,rx:2,fill:n})}function Ks(e){const t=e,n=[ea(t,["datum","data"]),ea(t,["datum"]),ea(t,["data","data"]),ea(t,["data"]),ea(t,["node","datum","data"]),ea(t,["node","datum"]),e];for(const e of n){if(!ta(e))continue;const t={};for(const[n,o]of Object.entries(e))n.startsWith("_")||"function"==typeof o||(t[n]=o);if(Object.keys(t).length>0)return t}return null}function Zs(e,t={}){const n=Ks(e);if(!n)return[];const o=new Set(df);if(t.excludeKeys)for(const e of t.excludeKeys)o.add(e);const r=[];for(const[e,i]of Object.entries(n))if((t.includeInternal||!e.startsWith("_"))&&!o.has(e)&&(t.includeEmpty||null!=i&&""!==i)&&"function"!=typeof i&&(r.push({key:e,label:Js(e,t.labels),value:i,formatted:t.valueFormat?t.valueFormat(i,e,n):Qs(i)}),r.length>=(t.maxEntries??8)))break;return r}function Qs(e){if(null==e)return"";if(e instanceof Date)return e.toISOString();if("number"==typeof e)return Number.isInteger(e)?String(e):e.toLocaleString(void 0,{maximumFractionDigits:2});if("boolean"==typeof e)return e?"true":"false";if(Array.isArray(e))return`${e.length} items`;if("object"==typeof e)try{return JSON.stringify(e)}catch{return String(e)}return String(e)}function Js(e,t){if("function"==typeof t)return t(e);if(t&&Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];if("string"==typeof n&&n.length>0)return n}return e}function ea(e,t){let n=e;for(const e of t){if(!ta(n))return;n=n[e]}return n}function ta(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function na(e,t){const n=/* @__PURE__ */new Map;for(const t of e)n.set(t.id,/* @__PURE__ */new Set);for(const e of t)n.has(e.source)||n.set(e.source,/* @__PURE__ */new Set),n.has(e.target)||n.set(e.target,/* @__PURE__ */new Set),n.get(e.source).add(e.target),n.get(e.target).add(e.source);return n}function oa(e,t){const r={};for(const t of e)o(r,t.id,0);for(const e of t)o(r,e.source,(n(r,e.source)??0)+1),o(r,e.target,(n(r,e.target)??0)+1);return r}function ra(e,n){const r={};o(r,n,0);const i=[n];let s=0;for(;s<i.length;){const n=i[s];s+=1;for(const s of e.get(n)||[])t(r,s)||(o(r,s,r[n]+1),i.push(s))}return r}function ia(e,n,o,i){if(o===i)return o?[o]:[];const s=na(e,n),a=r();a[o]=null;const c=[o];let l=0;for(;l<c.length;){const e=c[l];if(l+=1,e===i)break;for(const n of s.get(e)||[])t(a,n)||(a[n]=e,c.push(n))}if(!t(a,i))return[];const u=[];let d=i;for(;null!=d;)u.unshift(d),d=a[d];return u}function sa(e,t,n,o=1){const r=na(e,t);if(!r.has(n))/* @__PURE__ */return new Set;const i=ra(r,n),s=/* @__PURE__ */new Set;for(const e of Object.keys(i))i[e]<=o&&s.add(e);return s}function aa(e,t){const i=na(e,t),s={};for(const t of e)o(s,t.id,0);for(const t of e.map(e=>e.id)){const a=[],c=r(),l=r(),u=r();for(const t of e)c[t.id]=[],l[t.id]=0,u[t.id]=-1;l[t]=1,u[t]=0;const d=[t];let h=0;for(;h<d.length;){const e=d[h];h+=1,a.push(e);for(const t of i.get(e)||[])u[t]<0&&(u[t]=u[e]+1,d.push(t)),u[t]===u[e]+1&&(l[t]+=l[e],c[t].push(e))}const f=r();for(const t of e)f[t.id]=0;for(;a.length;){const e=a.pop();for(const t of c[e])f[t]+=l[t]/l[e]*(1+f[e]);e!==t&&o(s,e,(n(s,e)??0)+f[e])}}for(const e of Object.keys(s))o(s,e,s[e]/2);return s}function ca(e,t){const n=na(e,t),r={};for(const t of e){const e=ra(n,t.id);let i=0,s=0;for(const t of Object.keys(e))i+=e[t],s+=1;o(r,t.id,i>0?(s-1)/i:0)}return r}function la(e,t){const n=na(e,t),r={};for(const t of e){const e=[...n.get(t.id)||[]],i=e.length;if(i<2){o(r,t.id,0);continue}let s=0;for(let t=0;t<e.length;t+=1)for(let o=t+1;o<e.length;o+=1)n.get(e[t])?.has(e[o])&&(s+=1);o(r,t.id,2*s/(i*(i-1)))}return r}function ua(e){let t=0;for(const n of Object.keys(e))e[n]>t&&(t=e[n]);const n={};for(const r of Object.keys(e))o(n,r,t>0?e[r]/t:0);return n}function da(e,t,o,i={}){const s=na(e,t),a=r();for(const t of e)a[t.id]=ra(s,t.id);let c=i.minHops??4,l=i.startThreshold??.08;const u=i.maxThreshold??.2,d=/* @__PURE__ */new Set;let h=0;for(;0===d.size&&h<40;){for(let t=0;t<e.length;t+=1)for(let r=t+1;r<e.length;r+=1){const i=e[t].id,s=e[r].id,u=n(o,i),h=n(o,s);if(!u||!h)continue;const f=void 0===a[i][s]?1/0:a[i][s],m=u.x-h.x,p=u.y-h.y,g=Math.sqrt(m*m+p*p);f>=c&&g<l&&(d.add(i),d.add(s))}0===d.size&&(l+=.02,l>u&&(l=i.startThreshold??.08,c=Math.max(2,c-1))),h+=1}return{problemIds:d,threshold:l,minHops:c}}async function ha(e,t,n={}){const{execution:o="auto",signal:r,workerThreshold:i,nodeRadius:s,...a}=n,c=a.iterations??260;if(!re()||!oe(o,e.length,t.length,c,i))return We(e,t,{...a,nodeRadius:s});const l={kind:"normalized",nodes:e.map(e=>({...e})),edges:t.map(e=>({...e})),options:a,nodeRadii:"function"==typeof s?Object.fromEntries(e.map(e=>[e.id,s(e)])):null==s?void 0:Object.fromEntries(e.map(e=>[e.id,s]))};try{const{runForceLayoutWorker:e}=await Promise.resolve().then(()=>(yu(),pu));return(await e(l,r)).positions}catch(n){if("AbortError"===n?.name)throw n;return We(e,t,{...a,nodeRadius:s})}}function fa(e,t={}){const{baselineY:n=0,binWidth:o=24,gap:r=2,maxHeight:i=80,value:s="count",x:a}=t,c=e.reduce((e,t)=>Math.max(e,t[s]),1);return e.map((e,t)=>{const l=Math.max(0,e[s]/c*i),u=a?.(e,t)??t*(o+r);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:n-l,width:o,height:l,meanX:e.x.mean,meanY:e.y.mean}})}function ma(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;if(!Object.prototype.hasOwnProperty.call(n,e))return;n=n[e]}return n}function pa(e,t){return Boolean(t?.some(t=>Object.is(e,t)))}function ga(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const n=ma(e,t.property);return!("equals"in t&&!Object.is(n,t.equals)||"notEquals"in t&&Object.is(n,t.notEquals)||t.oneOf&&!pa(n,t.oneOf)||t.notOneOf&&pa(n,t.notOneOf))}function ya(e,t={}){const{idPrefix:n="plot",includeFloor:o=!0,includeCeiling:r=!1,includeLeftWall:i=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=t,l=[],u=e.x+e.width/2,d=e.y+e.height/2,h=(e,t,o,r,i)=>{l.push({id:`${n}-${e}`,shape:{type:"aabb",x:t,y:o,width:r,height:i}})};return o&&h("floor",u,e.y+e.height+c/2,e.width+2*a,c),r&&h("ceiling",u,e.y-c/2,e.width+2*a,c),i&&h("left-wall",e.x-a/2,d,a,e.height+2*c),s&&h("right-wall",e.x+e.width+a/2,d,a,e.height+2*c),l}function xa(e){const{idPrefix:t="bin",count:n,domainStart:o,domainStep:r,xScale:i,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=s,lidThickness:f=Math.max(2,c)}=e,m=[],p=s+(a-s)/2,g=Math.abs(a-s),y=l?n:n-1;if(u||l)for(let e=l?0:1;e<=y;e+=1){if(!u&&e>0&&e<n)continue;const s=i(o+e*r);m.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:s,y:p,width:c,height:g}})}if(null!=d)for(let e=0;e<n;e+=1){const n=o+e*r,s=n+r;if(s>=d)continue;const a=i(n),l=i(s);m.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:h,x2:Math.max(a,l)-c/2,y2:h,thickness:f}})}return m}function ba(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function wa(e){if(!e||"object"!=typeof e)return!1;const t=e;return"string"==typeof t.id&&(null==t.label||"string"==typeof t.label)&&"number"==typeof t.count&&Number.isFinite(t.count)&&Array.isArray(t.bodyIds)&&t.bodyIds.every(e=>"string"==typeof e)}function Ma(e,t){if("region-enter"!==t.type)return e;const n=t.region.id,o=ba(e,n),r=wa(o)?o:{id:n,label:t.region.label??n,count:0,bodyIds:[]};if(r.bodyIds.includes(t.bodyId))return e;const i=[...r.bodyIds,t.bodyId];return{...e,[n]:{...r,count:i.length,bodyIds:i}}}function va(e,t){return(t??Object.keys(e)).map(t=>ba(e,t)).filter(wa).map(e=>({label:e.label??e.id,value:e.count}))}function ka(e,t){const n=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],o=t.filter(e=>!n.has(e)),r=t.length-o.length,i=e.completion?.mode??"allMembersAbsorbed",s=e.completion?.valueByBodyId,a=e=>{const t=s?ba(s,e):void 0;return"number"==typeof t&&Number.isFinite(t)&&t>=0?t:1},c=t.reduce((e,t)=>e+a(t),0),l=t.reduce((e,t)=>e+(n.has(t)?a(t):0),0),u=e.completion?.threshold,d="threshold"===i?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0,h=t.length>0&&("anyAbsorbed"===i?r>0:"threshold"===i?l>=(d??c):0===o.length);return{id:e.id,label:e.label??e.id,mode:i,complete:h,absorbed:r,total:t.length,absorbedValue:l,totalValue:c,threshold:d,missing:o}})}function $a(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}function Sa(e,t,n,o,r,i={}){return{id:e,friction:i.friction,restitution:i.restitution,bodyFilter:i.bodyFilter,shape:{type:"segment",x1:t,y1:n,x2:o,y2:r,thickness:i.thickness??8}}}function Ia(e){const t=e.shape??"lane",n=Math.max(1,Math.round(e.width)),o=Math.max(1,Math.round(e.height)),r=e.padX??46,i=e.padY??72,s=r,a=n-r,c=i,l=o-Math.max(24,Math.round(.45*i)),u=(c+l)/2,d=Math.max(1,l-c),h=me(e.pinchRatio??.18,.06,.5),f=Number(e.pinchHeightOffset??0),m=Number.isFinite(f)?f:0,p=me(d*h+m,.06*d,.5*d),g=p/2,y=u-g,x=u+g,b=e.idPrefix??"process",w=e.friction??.58,M=e.restitution??.18,v=e.wallThickness??8,k=e.stages;if(!k.length)throw new Error("processStageLayout requires at least one stage");const $=me(e.centerStageIndex??Math.floor(k.length/2),0,k.length-1),S=$a(k),I=a-s;let A=s;const C=k.map((e,t)=>{const n=(e.share??1)/S*I,o=A,r=t===k.length-1?a:A+n;return A=r,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:o,x1:r,x:(o+r)/2,width:r-o,y:u,height:d}}),N=C[$],j=N.x0,F=N.x1,E=(e,n)=>{if("lane"===t)return"top"===n?c:l;if("funnel"===t){const t=me((e-s)/Math.max(1,a-s),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(e<=j){const t=me((e-s)/Math.max(1,j-s),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(e<=F)return"top"===n?y:x;const o=me((e-F)/Math.max(1,a-F),0,1);return"top"===n?y+(c-y)*o:x+(l-x)*o},P=C.map(e=>{const t=Math.min(E(e.x0,"top"),E(e.x1,"top")),n=Math.max(E(e.x0,"bottom"),E(e.x1,"bottom"));return{...e,y:(t+n)/2,height:Math.max(1,n-t)}}),z={thickness:v,friction:w,restitution:M},L=[];"lane"===t?L.push(Sa(`${b}-top`,s,c,a,c,z),Sa(`${b}-bottom`,s,l,a,l,z),Sa(`${b}-left`,s,c,s,l,{...z,thickness:Math.max(6,v-2)}),Sa(`${b}-right`,a,c,a,l,{...z,thickness:Math.max(6,v)})):"funnel"===t?L.push(Sa(`${b}-top`,s,c,a,y,z),Sa(`${b}-bottom`,s,l,a,x,z),Sa(`${b}-left`,s,c,s,l,{...z,thickness:Math.max(6,v-2)}),Sa(`${b}-right`,a,y,a,x,{...z,thickness:Math.max(6,v)})):L.push(Sa(`${b}-left-top`,s,c,j,y,z),Sa(`${b}-left-bottom`,s,l,j,x,z),Sa(`${b}-center-top`,j,y,F,y,z),Sa(`${b}-center-bottom`,j,x,F,x,z),Sa(`${b}-right-top`,F,y,a,c,z),Sa(`${b}-right-bottom`,F,x,a,l,z),Sa(`${b}-left`,s,c,s,l,{...z,thickness:Math.max(6,v-2)}),Sa(`${b}-right`,a,c,a,l,{...z,thickness:Math.max(6,v)}));const O=e.membraneDampingScale??.5,T=s,R="bowtie"===t?j:a,W=Math.max(1,R-T),q=(e.membranes??[]).map(e=>{const t=T+me(e.offset,0,1)*W,n=e.width??18+18*e.cost,o=d-16,r=u+.25*(e.wobble??0);return{...e,x:t,y:r,width:n,height:o}}),D=!1===e.includeMembraneRegions?[]:q.map(e=>ja({id:e.id,label:e.label??e.id,description:e.description??`${e.label??e.id} is a permeable region. It taxes energy and damps velocity while bodies overlap it.`,x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??O,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:n,height:o,padX:r,padY:i,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:j,centerRight:F,pinchHeight:p,pinchTop:y,pinchBottom:x,stages:P,membranes:q,colliders:L,regionEffects:D,boundaryY:E}}function Aa(e,t,n){return"function"==typeof t?o=>({...n,...t(o),primitive:e}):{...n,...t,primitive:e}}function Ca(e,t,n,o){return{id:e.id,label:e.label,description:e.description,kind:e.kind??t,shape:(r=e.x,i=e.y,s=e.width,a=e.height,{type:"aabb",x:r,y:i,width:s,height:a}),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:n?Aa(n,e.attributes,o):e.attributes,onEnter:e.onEnter,onExit:e.onExit};var r,i,s,a}function Na(e,t={}){const n=t.idPrefix??"stage",o=Math.max(0,t.insetX??0),r=Math.max(0,t.insetY??1);return e.stages.map(e=>{const i="function"==typeof t.metadata?t.metadata(e):t.metadata??{};return{...Ca({id:n?`${n}:${e.id}`:e.id,label:e.label??e.id,description:e.description,kind:"region",x:e.x,y:e.y,width:Math.max(1,e.width-2*o),height:Math.max(1,e.height-2*r),bodyFilter:t.bodyFilter,semanticItem:t.semanticItem,attributes:{primitive:"processStage",stageId:e.id,stageIndex:e.index},metadata:{...i,primitive:"processStage",stageId:e.id,stageIndex:e.index}})}})}function ja(e){const t=e.dampingScale??.5,n=e.energyScale??1,o=me(e.cost,0,2);return{...Ca(e,"membrane","membrane",{membraneCost:o}),damping:o*t,energyDelta:-o*n}}function Fa(e){return{...Ca(e,"charge-gate","chargeGate"),charge:e.charge??!0,energyDelta:e.energyDelta,impulseOnEnter:e.impulseOnEnter}}function Ea(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...Ca(e,"force-field","routeSurface"),force:t,damping:e.damping??.015}}function Pa(e){const t=e.pressure??e.occupancy??0,n=e.baseDamping??.08,o=e.dampingPerUnit??.12,r=e.energyPerUnit??0;return{...Ca(e,"membrane","pressureField",{pressure:t}),damping:n+t*o,energyDelta:r?-t*r:void 0,force:e.force}}function za(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...Ca(e,"force-field","capacitatedSensor",{capacity:e.capacity,unitsPerSecond:e.unitsPerSecond??e.capacity}),force:t,damping:e.damping,charge:e.charge??e.capacity}}function La(e){return{...Ca(e,"force-field","portal",{targetStage:e.targetStage}),force:e.force,impulseOnEnter:e.impulseOnEnter,damping:e.damping??.08}}function Oa(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...Ca(e,"sink","absorb"),force:t,damping:e.damping??.02,charge:e.charge??"absorbed"}}function Ta(e){return{...Ca(e,"force-field","forceField"),force:e.force,damping:e.damping,energyDelta:e.energyDelta}}function Ra(e){const t=e.x??e.anchor?.x??0,n=e.y??e.anchor?.y??0;return{id:e.id,label:e.label,description:e.description,group:e.group,bodyIds:e.bodyIds,datum:e.datum,state:e.state,x:t,y:n,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:n},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}function Wa(e){const t=e.idPrefix??"lane",n={thickness:e.thickness??8,friction:e.friction??.5,restitution:e.restitution??.16},o=[Sa(`${t}-top`,e.left,e.top,e.right,e.top,n),Sa(`${t}-bottom`,e.left,e.bottom,e.right,e.bottom,n)];return e.openEnds||o.push(Sa(`${t}-left`,e.left,e.top,e.left,e.bottom,n),Sa(`${t}-right`,e.right,e.top,e.right,e.bottom,n)),o}function qa(e,t,n={}){const o=n.random??Math.random,r=e.stages.find(e=>e.id===t)??e.stages[e.stages.length-1],i=me(n.along??.5,.05,.95),s=n.jitterX??0,a=n.padY??20,c=r.x0+(r.x1-r.x0)*i+(2*o()-1)*s,l=Math.min(1,r.width/2),u=me(c,r.x0+l,r.x1-l),d=e.boundaryY(u,"top")+a,h=e.boundaryY(u,"bottom")-a;return{x:u,y:h<=d?e.midY:d+o()*Math.max(1,h-d)}}function Da(e){return"bowtie"===e.shape?[{id:"incoming",role:"incoming",points:[[e.left,e.topY],[e.centerLeft,e.pinchTop],[e.centerLeft,e.pinchBottom],[e.left,e.bottomY]]},{id:"center",role:"center",points:[[e.centerLeft,e.pinchTop],[e.centerRight,e.pinchTop],[e.centerRight,e.pinchBottom],[e.centerLeft,e.pinchBottom]]},{id:"outgoing",role:"outgoing",points:[[e.centerRight,e.pinchTop],[e.right,e.topY],[e.right,e.bottomY],[e.centerRight,e.pinchBottom]]}]:[{id:"volume",role:"volume",points:[[e.left,e.topY],[e.right,"funnel"===e.shape?e.pinchTop:e.topY],[e.right,"funnel"===e.shape?e.pinchBottom:e.bottomY],[e.left,e.bottomY]]}]}function Ba(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Ya(e,t){let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;if(!Object.prototype.hasOwnProperty.call(n,e))return;n=n[e]}return n}function Va(e,t,n,o,r){return"function"==typeof o?o(e,t,n):Ya(e,o??r)}function Ga(e){const t=Number(e.toFixed(mf));return Object.is(t,-0)?0:t}function _a(e){const t=(e??hf).map(e=>{const t=Ba(e);if(null==t||t<0||t>1)throw new RangeError(`physicsReferenceEnvelope quantiles must be finite values from 0 to 1; received ${String(e)}`);return Ga(t)});return Array.from(new Set(t)).sort((e,t)=>e-t)}function Ha(e){if(Array.isArray(e)){if(e.length>ff)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${ff} points`);return Array.from(new Set(e.map(Ba).filter(e=>null!=e).map(Ga))).sort((e,t)=>e-t)}const t=e,n=Ba(t.start),o=Ba(t.end),r=Ba(t.step);if(null==n||null==o||null==r||r<=0||o<n)throw new RangeError("physicsReferenceEnvelope sampleAt requires finite start/end values with end >= start and step > 0");const i=Math.floor((o-n)/r)+1;if(i>ff)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${ff} points`);const s=[],a=1e-10*Math.max(1,Math.abs(o),Math.abs(n));for(let e=0;e<i;e+=1){const t=n+e*r;if(t>o+a)break;s.push(Ga(Math.min(t,o)))}if((!s.length||Math.abs(s[s.length-1]-o)>a)&&s.push(Ga(o)),s.length>ff)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${ff} points`);return Array.from(new Set(s)).sort((e,t)=>e-t)}function Xa(e,t,n,o){const r=e.flatMap((e,r)=>{const i=Ba(Va(e,r,t,n,"time")),s=Ba(Va(e,r,t,o,"value"));return null==i||null==s?[]:[{time:Ga(i),value:s,index:r}]});r.sort((e,t)=>e.time-t.time||e.index-t.index);const i=[];for(const e of r){const t=i[i.length-1];t?.time===e.time?t.value=e.value:i.push({time:e.time,value:e.value})}return i}function Ua(e,t){let n=0,o=e.length;for(;n<o;){const r=n+o>>>1;e[r].time<t?n=r+1:o=r}return n}function Ka(e,t,n,o){if(!e.length)return null;const r=e[0],i=e[e.length-1];if(t<r.time)return"clamp"===o?r.value:null;if(t>i.time)return"clamp"===o?i.value:null;const s=Ua(e,t),a=e[s];if(a?.time===t)return a.value;const c=e[Math.max(0,s-1)];if("step"===n||!a||a.time===c.time)return c.value;const l=(t-c.time)/(a.time-c.time);return c.value+(a.value-c.value)*l}function Za(e,t){if(1===e.length)return e[0];const n=(e.length-1)*t,o=Math.floor(n),r=Math.ceil(n);if(o===r)return e[o];const i=n-o;return e[o]+(e[r]-e[o])*i}function Qa(e){const t=e.interpolation??"step",n=e.outsideDomain??"omit",o=_a(e.quantiles),r=Ha(e.sampleAt),i=e.runs.map(t=>Xa(t.samples,t.id,e.timeAccessor,e.valueAccessor));return{points:r.map(e=>{const r=i.map(o=>Ka(o,e,t,n)).filter(e=>null!=e).sort((e,t)=>e-t),s={};for(const e of o)s[e]=r.length?Za(r,e):null;return{time:e,count:r.length,min:r.length?r[0]:null,max:r.length?r[r.length-1]:null,median:r.length?Za(r,.5):null,quantiles:s}}),quantiles:o,interpolation:t,outsideDomain:n,runCount:e.runs.length}}function Ja(e,t){return e.quantiles.length?"lower"===t?e.quantiles[0]:e.quantiles[e.quantiles.length-1]:"lower"===t?"min":"max"}function ec(e,t){if("min"===t||"median"===t||"max"===t)return e[t];const n=Ba(t);if(null==n||n<0||n>1)throw new RangeError(`comparePhysicsTrace quantile selectors must be from 0 to 1; received ${String(t)}`);const o=Ga(n);if(!Object.prototype.hasOwnProperty.call(e.quantiles,o))throw new Error(`comparePhysicsTrace could not find quantile ${o} in the reference envelope`);return e.quantiles[o]??null}function tc(e,t,n){return e<t?"below":e>n?"above":"inside"}function nc(e,t){const n=Math.max(0,t.time-e.time);if(!(n>0)||null==e.value||null==e.lower||null==e.upper||null==t.value||null==t.lower||null==t.upper)return{below:0,inside:0,above:0,observed:0};const o=e.value-e.lower,r=t.value-t.lower,i=e.value-e.upper,s=t.value-t.upper,a=[0,1];for(const[e,t]of[[o,r],[i,s]])(e<0&&t>0||e>0&&t<0)&&a.push(-e/(t-e));a.sort((e,t)=>e-t);let c=0,l=0,u=0;for(let o=0;o<a.length-1;o+=1){const r=a[o],i=a[o+1];if(!(i>r))continue;const s=(r+i)/2,d=(i-r)*n,h=tc(e.value+(t.value-e.value)*s,e.lower+(t.lower-e.lower)*s,e.upper+(t.upper-e.upper)*s);"below"===h?c+=d:"above"===h?u+=d:l+=d}return{below:c,inside:l,above:u,observed:n}}function oc(e,t,n={}){const o=n.interpolation??t.interpolation,r=n.outsideDomain??t.outsideDomain,i=Xa(e,n.traceId??"trace",n.timeAccessor,n.valueAccessor),s=n.lower??Ja(t,"lower"),a=n.upper??Ja(t,"upper"),c=t.points.map(e=>{const t=Ka(i,e.time,o,r),n=ec(e,s),c=ec(e,a);if(null!=n&&null!=c&&n>c)throw new RangeError(`comparePhysicsTrace lower band exceeds upper band at time ${e.time}`);return{time:e.time,value:t,lower:n,upper:c,status:null==t||null==n||null==c?"unobserved":tc(t,n,c)}});let l=0,u=0,d=0,h=0,f=null,m=0,p=null;for(const e of c){if("below"===e.status?l+=1:"inside"===e.status?u+=1:"above"===e.status&&(d+=1),null==e.value||null==e.lower||null==e.upper)continue;const t=Math.max(0,e.value-e.upper),n=Math.max(0,e.lower-e.value);t>h&&(h=t,f=e.time),n>m&&(m=n,p=e.time)}let g=0,y=0,x=0,b=0;for(let e=0;e<c.length-1;e+=1){const t=c[e],n=c[e+1],r=Math.max(0,n.time-t.time);if(r>0){if("linear"===o){const e=nc(t,n);g+=e.below,y+=e.inside,x+=e.above,b+=e.observed;continue}"unobserved"!==t.status&&(b+=r,"below"===t.status?g+=r:"above"===t.status?x+=r:y+=r)}}const w=c[0]?.time,M=c[c.length-1]?.time,v=null==w||null==M?0:Math.max(0,M-w),k=l+u+d;return{points:c,sampleCount:c.length,observedSamples:k,belowSamples:l,insideSamples:u,aboveSamples:d,totalDuration:v,observedDuration:b,unobservedDuration:Math.max(0,v-b),belowDuration:g,insideDuration:y,aboveDuration:x,peakExcess:h,peakExcessAt:f,peakDeficit:m,peakDeficitAt:p}}function rc(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function ic(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function sc(e){return!!ic(e)&&"string"==typeof e.id&&"number"==typeof e.furthestStageIndex&&Number.isFinite(e.furthestStageIndex)&&Array.isArray(e.visitedStageIds)&&e.visitedStageIds.every(e=>"string"==typeof e)&&ic(e.visitsByStage)&&ic(e.firstEnteredAt)&&ic(e.lastEnteredAt)&&"number"==typeof e.regressionCount&&Number.isFinite(e.regressionCount)}function ac(e){return{id:e,furthestStageIndex:-1,visitedStageIds:[],visitsByStage:{},firstEnteredAt:{},lastEnteredAt:{},regressionCount:0}}function cc(e,t){const n=t.stageId?.(e);if(n)return n;const o=e.region.metadata;if(o&&"object"==typeof o&&Object.prototype.hasOwnProperty.call(o,"stageId")){const e=o.stageId;if("string"==typeof e)return e}return e.region.id}function lc(e){const t=Array.from(new Set(e.bodyIds??[]));return{stages:e.stages.map(e=>({...e})),bodyIds:t,entities:Object.fromEntries(t.map(e=>[e,ac(e)]))}}function uc(e,t,n={}){if("region-enter"!==t.type)return e;const o=cc(t,n),r=e.stages.findIndex(e=>e.id===o);if(r<0)return e;const i=n.entityId?.(t)??t.bodyId;if(!i)return e;const s=rc(e.entities,i),a=sc(s)?s:ac(i),c=a.currentStageId?e.stages.findIndex(e=>e.id===a.currentStageId):-1,l=!a.visitedStageIds.includes(o),u=Number(t.observation.timestamp),d=Number.isFinite(u)?u:0,h=rc(a.visitsByStage,o),f="number"==typeof h&&Number.isFinite(h)?h:0,m={...a,currentStageId:o,furthestStageId:r>a.furthestStageIndex?o:a.furthestStageId,furthestStageIndex:Math.max(a.furthestStageIndex,r),visitedStageIds:l?[...a.visitedStageIds,o]:a.visitedStageIds,visitsByStage:{...a.visitsByStage,[o]:f+1},firstEnteredAt:l?{...a.firstEnteredAt,[o]:d}:a.firstEnteredAt,lastEnteredAt:{...a.lastEnteredAt,[o]:d},regressionCount:c>=0&&r<c?a.regressionCount+1:a.regressionCount};return{...e,bodyIds:e.bodyIds.includes(i)?e.bodyIds:[...e.bodyIds,i],entities:{...e.entities,[i]:m}}}function dc(e){const t=e.bodyIds.map(t=>{const n=rc(e.entities,t);return sc(n)?n:ac(t)}),n=t.length;let o=n;return e.stages.map((e,r)=>{const i=t.filter(e=>e.furthestStageIndex>=r).length,s=t.filter(t=>t.visitedStageIds.includes(e.id)).length,a=t.reduce((t,n)=>{const o=rc(n.visitsByStage,e.id);return t+("number"==typeof o&&Number.isFinite(o)?o:0)},0),c={id:e.id,label:e.label??e.id,reached:i,entered:s,total:n,conversion:n>0?i/n:0,fromPrevious:o>0?i/o:0,dropoff:Math.max(0,o-i),visits:a,repeatVisits:Math.max(0,a-s)};return o=i,c})}function hc(e,t){if("function"==typeof t){const n=t(e);return Number.isFinite(n)&&n>0?Number(n):1}const n=e.datum;if(t&&n&&"object"==typeof n){const e=Number(n[t]);if(Number.isFinite(e)&&e>0)return e}const o=Number(n?.work??n?.reviewWork??n?.value);return Number.isFinite(o)&&o>0?o:1}function fc(e,t){if("function"==typeof t){const n=t(e);if(null!=n&&String(n).length>0)return String(n)}else if(t){const n=ma(e.datum,t),o=ma(e,t),r=n??o;if(null!=r&&String(r).length>0)return String(r)}return e.id}function mc(e,t){if(0===e.length)return 0;if(1===e.length)return e[0];const n=Math.max(0,Math.min(1,t))*(e.length-1),o=Math.floor(n),r=Math.ceil(n),i=n-o;return e[o]+(e[r]-e[o])*i}function pc(e){function t(e,t){const n=t(e);return!!n&&n.activeRegionIds.includes(f)}function n(){X+=1}function o(e){return{bodyId:e.bodyId,jobId:e.jobId,visitId:e.visitId,visit:e.visit,regionId:f,work:e.total,queuedAt:e.queuedAt}}function r(t,n,r){const i=o(n);e.onQueued?.(t,i),r.controls.recordObservation({type:"physics-capacity-queued",bodyId:t.id,datum:t.datum,x:t.x,y:t.y,regionId:f,work:n.total,jobId:n.jobId,visitId:n.visitId,visit:n.visit,queuedAt:n.queuedAt,queueDepth:v.size})}function i(e,t,o,i){const s={bodyId:e.id,jobId:t.jobId,visitId:t.visitId,visit:t.visit,remaining:t.work,total:t.work,queuedAt:t.queuedAt,sequence:i};return v.set(t.jobId,s),C.delete(e.id),A.set(e.id,t.jobId),R+=1,W+=t.work,n(),r(e,s,o),s}function s(e){if(v.size>=x||0===k.size)return;const t=Array.from(k.values()).sort((e,t)=>e.sequence-t.sequence);for(const n of t){if(v.size>=x)break;const t=I.get(n.jobId);t&&$.has(n.jobId)?(k.delete(n.jobId),C.delete(n.bodyId),i(t,n,e,n.sequence)):k.delete(n.jobId)}}function a(){let e=0;for(const t of v.values())e+=t.remaining;return e}function c(){let e=0;for(const t of k.values())e+=t.work;return e}function l(){G=Math.max(G,v.size),_=Math.max(_,a())}function u(){const e=Array.from(v.values()).sort((e,t)=>e.sequence-t.sequence);F=new Map(e.map((e,t)=>[e.bodyId,t]));const t=Array.from(k.values()).sort((e,t)=>e.sequence-t.sequence);E=new Map(t.map((e,t)=>[e.bodyId,t])),P=e.length}function d(e){(e.end>e.start||e.arrivals>0||e.completions>0||e.processedWork>0)&&N.push(e);const t=L-b;for(;N.length>0&&N[0].end<t;)N.shift()}function h(){const e=L-b,t=Math.max(0,Math.min(b,L-(O??L)));let n=0,o=0,r=0,i=0,s=0;for(const t of N){if(t.end<e)continue;n+=t.arrivals,o+=t.arrivalWork,r+=t.completions,i+=t.completedWork;const a=t.end-t.start;if(a<=0||t.start>=e)s+=t.processedWork;else{const n=Math.max(0,t.end-e);s+=t.processedWork*Math.min(1,n/a)}}const a=t>0?o/t:0;return{seconds:t,arrivals:n,arrivalWork:o,completions:r,completedWork:i,processedWork:s,arrivalsPerSecond:t>0?n/t:0,throughputPerSecond:t>0?r/t:0,utilization:t>0&&m>0?Math.max(0,Math.min(1,s/(m*t))):0,pressure:m>0?a/m:0}}const f=e.regionId,m=Math.max(0,e.unitsPerSecond),p=e.queueLayout??"lane",g=e.queueSlotSpacing??14,y=e.queueStiffness??.35,x=Number.isFinite(e.maxQueue)?Math.max(0,Math.floor(Number(e.maxQueue))):Number.POSITIVE_INFINITY,b=Math.max(.25,e.metricWindowSeconds??30),w=Math.max(1/60,e.snapshotIntervalSeconds??.25),M=e.releaseImpulse??{x:90,y:0},v=/* @__PURE__ */new Map,k=/* @__PURE__ */new Map,$=/* @__PURE__ */new Map,S=/* @__PURE__ */new Map,I=/* @__PURE__ */new Map,A=/* @__PURE__ */new Map,C=/* @__PURE__ */new Map,N=[];let j=0,F=/* @__PURE__ */new Map,E=/* @__PURE__ */new Map,P=0,z=0,L=0,O=null,T=0,R=0,W=0,q=0,D=0,B=0,Y=0,V=0,G=0,_=0,H=0,X=0,U=-1,K=!1;return{id:e.id??`capacity-queue:${f}`,continuous:!1!==e.continuous,tick:r=>{const a=r.controls.readBodies(),c=/* @__PURE__ */new Map,h=/* @__PURE__ */new Map;for(const n of a){if(c.set(n.id,n),!t(n.id,r.getRegionState))continue;if(!ga(n,e.bodyFilter))continue;const o=fc(n,e.jobKey),i=h.get(o)??[];i.push(n),h.set(o,i)}const p=Number.isFinite(r.dt)?Math.max(0,r.dt):0;if(!K){const e=Number.isFinite(r.elapsed)?Math.max(0,r.elapsed):p;L=Math.max(0,e-p),K=!0}const g=L,y=g+p;L=y,O=null==O?g:Math.min(O,g);const b={start:g,end:y,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},N=/* @__PURE__ */new Map;for(const[e,t]of h){const n=$.get(e)?.bodyId,o=t.find(e=>e.id===n)??t[0];N.set(e,o),I.set(e,o)}for(const[t,i]of $){if(N.has(t))continue;const s=v.get(t),a=c.get(i.bodyId)??I.get(t);if(s){v.delete(t),A.delete(s.bodyId),Y+=1,V+=s.remaining,n();const c={...o(s),abandonedAt:L,remainingWork:s.remaining,queueSeconds:Math.max(0,L-s.queuedAt)};a&&e.onAbandoned?.(a,c),r.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:i.bodyId,datum:a?.datum,x:a?.x,y:a?.y,regionId:f,work:s.total,remainingWork:s.remaining,jobId:t,visitId:s.visitId,visit:s.visit,queuedAt:s.queuedAt,abandonedAt:L,queueSeconds:c.queueSeconds,queueDepth:v.size})}k.delete(t),C.delete(i.bodyId),$.delete(t),I.delete(t)}for(const[t,o]of N){if($.has(t))continue;const s=(S.get(t)??0)+1;S.set(t,s);const a=hc(o,e.unitAccessor),c={bodyId:o.id,jobId:t,visitId:`${f}:${t}:${s}`,visit:s,regionId:f,work:a,queuedAt:L};$.set(t,c),T+=1,b.arrivals+=1,b.arrivalWork+=a;const l=j++;if(v.size<x)i(o,c,r,l);else{const i={...c,blockedAt:L,sequence:l};k.set(t,i),C.set(o.id,t),B+=1,n(),e.onBlocked?.(o,i),r.controls.recordObservation({type:"physics-capacity-blocked",bodyId:o.id,datum:o.datum,x:o.x,y:o.y,regionId:f,work:a,jobId:t,visitId:c.visitId,visit:s,queuedAt:L,blockedAt:L,queueDepth:v.size,blockedDepth:k.size})}}s(r),l();const F=Array.from(v.values()).sort((e,t)=>e.sequence-t.sequence);let E=m*p;for(const t of F){if(!(E>0))break;const i=Math.min(t.remaining,E);if(t.remaining-=i,E-=i,q+=i,b.processedWork+=i,t.remaining>1e-6)continue;v.delete(t.jobId),A.delete(t.bodyId),z+=1,D+=t.total,b.completions+=1,b.completedWork+=t.total;const s=Math.max(0,L-t.queuedAt);H+=s,n();const a=c.get(t.bodyId);if(!a)continue;r.controls.applyImpulse(t.bodyId,M.x??0,M.y??0);const l={...o(t),completedAt:L,queueSeconds:s};e.onProcessed?.(a,l),r.controls.recordObservation({type:"physics-capacity-processed",bodyId:t.bodyId,datum:a.datum,x:a.x,y:a.y,regionId:f,work:t.total,jobId:t.jobId,visitId:t.visitId,visit:t.visit,queuedAt:t.queuedAt,completedAt:L,queueSeconds:s,queueDepth:v.size})}s(r),l(),u(),d(b);const P=Math.floor(L/w);P!==U&&(U=P,n())},getSnapshot:()=>{const e=a(),t=c(),n=v.size,o=Array.from(v.values()).map(e=>Math.max(0,L-e.queuedAt)).sort((e,t)=>e-t),r=o.reduce((e,t)=>e+t,0);return{regionId:f,queueDepth:n,processedCount:z,unitsPerSecond:m,remainingWork:e,meanRemainingWork:n>0?e/n:0,waitingWork:e+t,blockedDepth:k.size,blockedWork:t,arrivalCount:T,admittedCount:R,admittedWork:W,processedWork:q,completedWork:D,blockedCount:B,abandonedCount:Y,abandonedWork:V,peakQueueDepth:G,peakRemainingWork:_,queueAge:{count:o.length,meanSeconds:o.length>0?r/o.length:0,p50Seconds:mc(o,.5),p95Seconds:mc(o,.95),oldestSeconds:o.at(-1)??0},meanCompletedQueueSeconds:z>0?H/z:0,window:h(),simulatedAt:L,metricRevision:X}},bodyForce:e=>{if("none"===p)return null;const t=A.get(e.body.id),n=C.get(e.body.id),o=t?v.get(t):void 0,r=n?k.get(n):void 0;if(!o&&!r)return null;const i=o?F.get(e.body.id):E.get(e.body.id);if(null==i)return null;let s;const a=e.regions;if(a)for(let e=0;e<a.length;e+=1)if(a[e].id===f){const t=a[e].shape;t&&"aabb"===t.type&&(s=t);break}if(!s)return{x:8*-Math.sign(e.body.vx||1),y:0};const c=r?s.x-.44*s.width:s.x-.22*s.width-i*(.15*g),l=s.y-(i-((r?k.size:P)-1)/2)*g/Math.max(1,Math.sqrt(r?k.size:P)),u=c-e.body.x,d=l-e.body.y;return{x:u*y,y:d*y*.85}}}}function gc(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}function yc(e){if(!e?.length)return null;const t=e.slice(),n=t.some(e=>!1!==e.continuous);return{controllers:t,continuous:n,onTick:(e,n,o)=>{const r={result:e,controls:n,dt:o.dt,elapsed:o.elapsed,getRegionState:o.getRegionState};for(const e of t)e.tick(r)},bodyForce:e=>{let n=null;for(const o of t)o.bodyForce&&(n=gc(n,o.bodyForce(e)));return n}}}function xc(e){const t=/* @__PURE__ */new Set,n=e.impulse??{x:-60,y:0};return{id:e.id??`portal:${e.fromRegionId}`,continuous:!0===e.continuous,tick:o=>{const r=o.controls.readBodies();for(const i of r){const r=o.getRegionState(i.id),s=r?.activeRegionIds.includes(e.fromRegionId);s?t.has(i.id)||(t.add(i.id),o.controls.applyImpulse(i.id,n.x??0,n.y??0),e.onPortal?.(i)):t.delete(i.id)}}}}function bc(e){const t=e.resources.map(e=>({...e,bodyId:e.bodyId??e.id})),n=new Map(t.map(e=>[e.bodyId,e])),o=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map,i=e.assignmentForce??.45,s=e.returnForce??.35,a=e.caseAttraction??.08,c=e.assignmentOffset??{x:0,y:0};let l=/* @__PURE__ */new Map,u=0,d=0;return{id:e.id??"service-resource-pool",continuous:!0,assign:e=>{const n=o.get(e);if(n)return n;const i=t.find(e=>!r.has(e.id));if(!i)return null;const s={resourceId:i.id,resourceBodyId:i.bodyId,caseBodyId:e,assignedAt:u};return o.set(e,s),r.set(i.id,s),d+=1,s},release:e=>{const t=o.get(e);return!!t&&(o.delete(e),r.delete(t.resourceId),d+=1,!0)},getAssignment:e=>o.get(e),tick:e=>{u=Math.max(u,e.elapsed),l=new Map(e.controls.readBodies().map(e=>[e.id,e]));for(const[e,t]of o)l.has(e)&&l.has(t.resourceBodyId)||(o.delete(e),r.delete(t.resourceId),d+=1)},getSnapshot:()=>({total:t.length,available:t.length-r.size,assigned:r.size,assignments:Array.from(o.values()),simulatedAt:u,metricRevision:d}),bodyForce:e=>{const t=n.get(e.body.id);if(t){const n=r.get(t.id),o=n?l.get(n.caseBodyId):void 0,a=o?o.x+(c.x??0):t.home.x,u=o?o.y+(c.y??0):t.home.y,d=n?i:s;return{x:(a-e.body.x)*d,y:(u-e.body.y)*d}}const u=o.get(e.body.id);if(!u||a<=0)return null;const d=l.get(u.resourceBodyId);return d?{x:(d.x-e.body.x)*a,y:(d.y-e.body.y)*a}:null}}}function wc(e,t){const n="function"==typeof t.deadlineAccessor?t.deadlineAccessor(e):ma(e.datum,t.deadlineAccessor)??ma(e,t.deadlineAccessor);return Number.isFinite(Number(n))?Math.max(0,Number(n)):0}function Mc(e){function t(t){o.set(t.bodyId,t),i+=1,e.onStateChange?.({...t})}function n(e){const n=o.get(e);return!(!n||null!=n.completedAt||(t({...n,completedAt:r,state:"unhappy"===n.state?"resolved-unhappy":"resolved"}),0))}const o=/* @__PURE__ */new Map;let r=0,i=0;return{id:e.id??"service-level",continuous:!0,protect:e=>{const n=o.get(e);return!(!n||null!=n.completedAt||"unhappy"===n.state||(t({...n,state:"protected",protectedAt:r}),0))},complete:n,getCase:e=>o.get(e),tick:i=>{r=Math.max(r,i.elapsed);for(const s of i.controls.readBodies()){if(!ga(s,e.bodyFilter))continue;if(!o.has(s.id)){const n=wc(s,e);t({bodyId:s.id,openedAt:r,deadlineAt:r+n,state:"waiting"})}const a=o.get(s.id);a&&null==a.completedAt&&(e.completionRegionId&&i.getRegionState(s.id)?.activeRegionIds.includes(e.completionRegionId)?n(s.id):"waiting"===a.state&&r>=a.deadlineAt&&t({...a,state:"unhappy"}))}},getSnapshot:()=>{const e=Array.from(o.values()),t=t=>e.filter(e=>e.state===t).length;return{total:e.length,waiting:t("waiting"),protected:t("protected"),unhappy:t("unhappy"),resolved:t("resolved"),resolvedUnhappy:t("resolved-unhappy"),simulatedAt:r,metricRevision:i}}}}function vc(e){const t=/* @__PURE__ */new Set;let n=0,o=0,r=0,i=!1;return{id:e.id??`dependency-gate:${e.regionId}`,continuous:!0,tick:s=>{n=Math.max(n,s.elapsed);const a=i;var c;c=n,i=e.isOpen?e.isOpen(c):null!=e.opensAt&&c>=e.opensAt;const l=s.controls.readBodies(),u=new Map(l.map(e=>[e.id,e]));for(const n of l){const o=s.getRegionState(n.id)?.activeRegionIds.includes(e.regionId);o&&ga(n,e.bodyFilter)&&(i||t.has(n.id)||(t.add(n.id),r+=1,e.onHeld?.(n)))}if(i&&!a){for(const n of t){const t=u.get(n);t&&(s.controls.applyImpulse(n,e.releaseImpulse?.x??86,e.releaseImpulse?.y??0),o+=1,e.onReleased?.(t))}t.clear(),r+=1}for(const e of t)u.has(e)||(t.delete(e),r+=1)},getSnapshot:()=>({regionId:e.regionId,isOpen:i,blocked:t.size,released:o,simulatedAt:n,metricRevision:r}),bodyForce:n=>{if(i||!t.has(n.body.id))return null;const o=n.regions?.find(t=>t.id===e.regionId),r=o?.shape;if(!r||"aabb"!==r.type)return{x:.8*-n.body.vx,y:.8*-n.body.vy};const s=e.holdForce??.4;return{x:(r.x-n.body.x)*s-.45*n.body.vx,y:(r.y-n.body.y)*s-.45*n.body.vy}}}}function kc(e){return e.length*yf}function $c(e,t){const n=e.trim();if(n.length<=t)return n;if(t<=1)return n.slice(0,1);const o=n.split(/\s+/).filter(Boolean).map(e=>e[0]).join("").toUpperCase();return o.length>1&&o.length<=t?o:t<=3?n.slice(0,t).toUpperCase():`${n.slice(0,Math.max(1,t-2))}..`}function Sc(e,t,n="auto"){const o=Math.max(1,Math.floor(t/yf)),r="compact"===n?$c(e,o):"full"===n||kc(e)<=t?e:$c(e,o);return{text:r,textLength:kc(r)>t?Math.max(4,t):void 0}}function Ic(e){return e.absorb?"absorb":e.portalTarget?"portal":null!=e.capacity?"capacity":"flow"}function Ac(e){if(null!=e.capacity){const t=null!=e.queueDepth?` · q ${e.queueDepth}`:"";return e.capacityLabel?`${e.capacityLabel}${t}`:`cap ${Number.isInteger(e.capacity)?String(e.capacity):e.capacity.toFixed(1)}${t}`}return e.absorb?"absorb":e.portalTarget?"portal":"flow"}function Cc(e,t={}){const{showFlowSpine:n=!0,showStageCounts:o=!0,showCapacityBadges:r=!0,showGroupSockets:i=!0,stageLabelMode:s="auto",outlineStages:a=!1,testId:c="process-flow-chrome"}=t,{width:l,height:u,left:d,right:h,topY:f,bottomY:m,midY:p,stages:g,groups:y=[]}=e,x=m-f;/* @__PURE__ */ /* @__PURE__ */
|
|
114
|
-
return(0,
|
|
110
|
+
/* @__PURE__ */(0,sf.jsx)("rect",{width:t,height:t,fill:"none",stroke:n,strokeWidth:1,opacity:.5,rx:2})]})}return e.line?/* @__PURE__ */ /* @__PURE__ */(0,sf.jsx)("rect",{y:t/2-1.5,width:t,height:3,rx:1.5,fill:e.line}):/* @__PURE__ */ /* @__PURE__ */(0,sf.jsx)("rect",{width:t,height:t,rx:2,fill:n})}function Gs(e){const t=e,n=[Us(t,["datum","data"]),Us(t,["datum"]),Us(t,["data","data"]),Us(t,["data"]),Us(t,["node","datum","data"]),Us(t,["node","datum"]),e];for(const e of n){if(!Ks(e))continue;const t={};for(const[n,o]of Object.entries(e))n.startsWith("_")||"function"==typeof o||(t[n]=o);if(Object.keys(t).length>0)return t}return null}function _s(e,t={}){const n=Gs(e);if(!n)return[];const o=new Set(lf);if(t.excludeKeys)for(const e of t.excludeKeys)o.add(e);const r=[];for(const[e,i]of Object.entries(n))if((t.includeInternal||!e.startsWith("_"))&&!o.has(e)&&(t.includeEmpty||null!=i&&""!==i)&&"function"!=typeof i&&(r.push({key:e,label:Xs(e,t.labels),value:i,formatted:t.valueFormat?t.valueFormat(i,e,n):Hs(i)}),r.length>=(t.maxEntries??8)))break;return r}function Hs(e){if(null==e)return"";if(e instanceof Date)return e.toISOString();if("number"==typeof e)return Number.isInteger(e)?String(e):e.toLocaleString(void 0,{maximumFractionDigits:2});if("boolean"==typeof e)return e?"true":"false";if(Array.isArray(e))return`${e.length} items`;if("object"==typeof e)try{return JSON.stringify(e)}catch{return String(e)}return String(e)}function Xs(e,t){if("function"==typeof t)return t(e);if(t&&Object.prototype.hasOwnProperty.call(t,e)){const n=t[e];if("string"==typeof n&&n.length>0)return n}return e}function Us(e,t){let n=e;for(const e of t){if(!Ks(n))return;n=n[e]}return n}function Ks(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Zs(e,t){const n=/* @__PURE__ */new Map;for(const t of e)n.set(t.id,/* @__PURE__ */new Set);for(const e of t)n.has(e.source)||n.set(e.source,/* @__PURE__ */new Set),n.has(e.target)||n.set(e.target,/* @__PURE__ */new Set),n.get(e.source).add(e.target),n.get(e.target).add(e.source);return n}function Qs(e,t){const r={};for(const t of e)o(r,t.id,0);for(const e of t)o(r,e.source,(n(r,e.source)??0)+1),o(r,e.target,(n(r,e.target)??0)+1);return r}function Js(e,n){const r={};o(r,n,0);const i=[n];let s=0;for(;s<i.length;){const n=i[s];s+=1;for(const s of e.get(n)||[])t(r,s)||(o(r,s,r[n]+1),i.push(s))}return r}function ea(e,n,o,i){if(o===i)return o?[o]:[];const s=Zs(e,n),a=r();a[o]=null;const c=[o];let l=0;for(;l<c.length;){const e=c[l];if(l+=1,e===i)break;for(const n of s.get(e)||[])t(a,n)||(a[n]=e,c.push(n))}if(!t(a,i))return[];const u=[];let d=i;for(;null!=d;)u.unshift(d),d=a[d];return u}function ta(e,t,n,o=1){const r=Zs(e,t);if(!r.has(n))/* @__PURE__ */return new Set;const i=Js(r,n),s=/* @__PURE__ */new Set;for(const e of Object.keys(i))i[e]<=o&&s.add(e);return s}function na(e,t){const i=Zs(e,t),s={};for(const t of e)o(s,t.id,0);for(const t of e.map(e=>e.id)){const a=[],c=r(),l=r(),u=r();for(const t of e)c[t.id]=[],l[t.id]=0,u[t.id]=-1;l[t]=1,u[t]=0;const d=[t];let h=0;for(;h<d.length;){const e=d[h];h+=1,a.push(e);for(const t of i.get(e)||[])u[t]<0&&(u[t]=u[e]+1,d.push(t)),u[t]===u[e]+1&&(l[t]+=l[e],c[t].push(e))}const f=r();for(const t of e)f[t.id]=0;for(;a.length;){const e=a.pop();for(const t of c[e])f[t]+=l[t]/l[e]*(1+f[e]);e!==t&&o(s,e,(n(s,e)??0)+f[e])}}for(const e of Object.keys(s))o(s,e,s[e]/2);return s}function oa(e,t){const n=Zs(e,t),r={};for(const t of e){const e=Js(n,t.id);let i=0,s=0;for(const t of Object.keys(e))i+=e[t],s+=1;o(r,t.id,i>0?(s-1)/i:0)}return r}function ra(e,t){const n=Zs(e,t),r={};for(const t of e){const e=[...n.get(t.id)||[]],i=e.length;if(i<2){o(r,t.id,0);continue}let s=0;for(let t=0;t<e.length;t+=1)for(let o=t+1;o<e.length;o+=1)n.get(e[t])?.has(e[o])&&(s+=1);o(r,t.id,2*s/(i*(i-1)))}return r}function ia(e){let t=0;for(const n of Object.keys(e))e[n]>t&&(t=e[n]);const n={};for(const r of Object.keys(e))o(n,r,t>0?e[r]/t:0);return n}function sa(e,t,o,i={}){const s=Zs(e,t),a=r();for(const t of e)a[t.id]=Js(s,t.id);let c=i.minHops??4,l=i.startThreshold??.08;const u=i.maxThreshold??.2,d=/* @__PURE__ */new Set;let h=0;for(;0===d.size&&h<40;){for(let t=0;t<e.length;t+=1)for(let r=t+1;r<e.length;r+=1){const i=e[t].id,s=e[r].id,u=n(o,i),h=n(o,s);if(!u||!h)continue;const f=void 0===a[i][s]?1/0:a[i][s],m=u.x-h.x,p=u.y-h.y,g=Math.sqrt(m*m+p*p);f>=c&&g<l&&(d.add(i),d.add(s))}0===d.size&&(l+=.02,l>u&&(l=i.startThreshold??.08,c=Math.max(2,c-1))),h+=1}return{problemIds:d,threshold:l,minHops:c}}async function aa(e,t,n={}){const{execution:o="auto",signal:r,workerThreshold:i,nodeRadius:s,...a}=n,c=a.iterations??260;if(!re()||!oe(o,e.length,t.length,c,i))return qe(e,t,{...a,nodeRadius:s});const l={kind:"normalized",nodes:e.map(e=>({...e})),edges:t.map(e=>({...e})),options:a,nodeRadii:"function"==typeof s?Object.fromEntries(e.map(e=>[e.id,s(e)])):null==s?void 0:Object.fromEntries(e.map(e=>[e.id,s]))};try{const{runForceLayoutWorker:e}=await Promise.resolve().then(()=>(hu(),uu));return(await e(l,r)).positions}catch(n){if("AbortError"===n?.name)throw n;return qe(e,t,{...a,nodeRadius:s})}}function ca(e,t={}){const{baselineY:n=0,binWidth:o=24,gap:r=2,maxHeight:i=80,value:s="count",x:a}=t,c=e.reduce((e,t)=>Math.max(e,t[s]),1);return e.map((e,t)=>{const l=Math.max(0,e[s]/c*i),u=a?.(e,t)??t*(o+r);return{binId:e.id,label:e.label,index:t,count:e.count,total:e.total,x:u,y:n-l,width:o,height:l,meanX:e.x.mean,meanY:e.y.mean}})}function la(e,t){if(!t)return;let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;if(!Object.prototype.hasOwnProperty.call(n,e))return;n=n[e]}return n}function ua(e,t){return Boolean(t?.some(t=>Object.is(e,t)))}function da(e,t){if(!t)return!0;if("function"==typeof t)return t(e);const n=la(e,t.property);return!("equals"in t&&!Object.is(n,t.equals)||"notEquals"in t&&Object.is(n,t.notEquals)||t.oneOf&&!ua(n,t.oneOf)||t.notOneOf&&ua(n,t.notOneOf))}function ha(e,t={}){const{idPrefix:n="plot",includeFloor:o=!0,includeCeiling:r=!1,includeLeftWall:i=!0,includeRightWall:s=!0,wallThickness:a=20,floorThickness:c=a}=t,l=[],u=e.x+e.width/2,d=e.y+e.height/2,h=(e,t,o,r,i)=>{l.push({id:`${n}-${e}`,shape:{type:"aabb",x:t,y:o,width:r,height:i}})};return o&&h("floor",u,e.y+e.height+c/2,e.width+2*a,c),r&&h("ceiling",u,e.y-c/2,e.width+2*a,c),i&&h("left-wall",e.x-a/2,d,a,e.height+2*c),s&&h("right-wall",e.x+e.width+a/2,d,a,e.height+2*c),l}function fa(e){const{idPrefix:t="bin",count:n,domainStart:o,domainStep:r,xScale:i,yTop:s,yBottom:a,wallThickness:c=4,includeBoundaryWalls:l=!0,includeInteriorWalls:u=!0,closedBefore:d,lidY:h=s,lidThickness:f=Math.max(2,c)}=e,m=[],p=s+(a-s)/2,g=Math.abs(a-s),y=l?n:n-1;if(u||l)for(let e=l?0:1;e<=y;e+=1){if(!u&&e>0&&e<n)continue;const s=i(o+e*r);m.push({id:`${t}-wall-${e}`,shape:{type:"aabb",x:s,y:p,width:c,height:g}})}if(null!=d)for(let e=0;e<n;e+=1){const n=o+e*r,s=n+r;if(s>=d)continue;const a=i(n),l=i(s);m.push({id:`${t}-lid-${e}`,shape:{type:"segment",x1:Math.min(a,l)+c/2,y1:h,x2:Math.max(a,l)-c/2,y2:h,thickness:f}})}return m}function ma(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function pa(e){if(!e||"object"!=typeof e)return!1;const t=e;return"string"==typeof t.id&&(null==t.label||"string"==typeof t.label)&&"number"==typeof t.count&&Number.isFinite(t.count)&&Array.isArray(t.bodyIds)&&t.bodyIds.every(e=>"string"==typeof e)}function ga(e,t){if("region-enter"!==t.type)return e;const n=t.region.id,o=ma(e,n),r=pa(o)?o:{id:n,label:t.region.label??n,count:0,bodyIds:[]};if(r.bodyIds.includes(t.bodyId))return e;const i=[...r.bodyIds,t.bodyId];return{...e,[n]:{...r,count:i.length,bodyIds:i}}}function ya(e,t){return(t??Object.keys(e)).map(t=>ma(e,t)).filter(pa).map(e=>({label:e.label??e.id,value:e.count}))}function xa(e,t){const n=t instanceof Set?t:new Set(t);return e.map(e=>{const t=e.bodyIds??[],o=t.filter(e=>!n.has(e)),r=t.length-o.length,i=e.completion?.mode??"allMembersAbsorbed",s=e.completion?.valueByBodyId,a=e=>{const t=s?ma(s,e):void 0;return"number"==typeof t&&Number.isFinite(t)&&t>=0?t:1},c=t.reduce((e,t)=>e+a(t),0),l=t.reduce((e,t)=>e+(n.has(t)?a(t):0),0),u=e.completion?.threshold,d="threshold"===i?Number.isFinite(u)&&Number(u)>=0?Number(u):c:void 0,h=t.length>0&&("anyAbsorbed"===i?r>0:"threshold"===i?l>=(d??c):0===o.length);return{id:e.id,label:e.label??e.id,mode:i,complete:h,absorbed:r,total:t.length,absorbedValue:l,totalValue:c,threshold:d,missing:o}})}function ba(e){const t=e.reduce((e,t)=>e+(t.share??1),0);return t>0?t:e.length}function wa(e,t,n,o,r,i={}){return{id:e,friction:i.friction,restitution:i.restitution,bodyFilter:i.bodyFilter,shape:{type:"segment",x1:t,y1:n,x2:o,y2:r,thickness:i.thickness??8}}}function Ma(e){const t=e.shape??"lane",n=Math.max(1,Math.round(e.width)),o=Math.max(1,Math.round(e.height)),r=e.padX??46,i=e.padY??72,s=r,a=n-r,c=i,l=o-Math.max(24,Math.round(.45*i)),u=(c+l)/2,d=Math.max(1,l-c),h=me(e.pinchRatio??.18,.06,.5),f=Number(e.pinchHeightOffset??0),m=Number.isFinite(f)?f:0,p=me(d*h+m,.06*d,.5*d),g=p/2,y=u-g,x=u+g,b=e.idPrefix??"process",w=e.friction??.58,M=e.restitution??.18,v=e.wallThickness??8,k=e.stages;if(!k.length)throw new Error("processStageLayout requires at least one stage");const $=me(e.centerStageIndex??Math.floor(k.length/2),0,k.length-1),S=ba(k),I=a-s;let A=s;const C=k.map((e,t)=>{const n=(e.share??1)/S*I,o=A,r=t===k.length-1?a:A+n;return A=r,{id:e.id,label:e.label,description:e.description,kind:e.kind??"stage",index:t,x0:o,x1:r,x:(o+r)/2,width:r-o,y:u,height:d}}),N=C[$],j=N.x0,F=N.x1,E=(e,n)=>{if("lane"===t)return"top"===n?c:l;if("funnel"===t){const t=me((e-s)/Math.max(1,a-s),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(e<=j){const t=me((e-s)/Math.max(1,j-s),0,1);return"top"===n?c+(y-c)*t:l+(x-l)*t}if(e<=F)return"top"===n?y:x;const o=me((e-F)/Math.max(1,a-F),0,1);return"top"===n?y+(c-y)*o:x+(l-x)*o},P=C.map(e=>{const t=Math.min(E(e.x0,"top"),E(e.x1,"top")),n=Math.max(E(e.x0,"bottom"),E(e.x1,"bottom"));return{...e,y:(t+n)/2,height:Math.max(1,n-t)}}),z={thickness:v,friction:w,restitution:M},L=[];"lane"===t?L.push(wa(`${b}-top`,s,c,a,c,z),wa(`${b}-bottom`,s,l,a,l,z),wa(`${b}-left`,s,c,s,l,{...z,thickness:Math.max(6,v-2)}),wa(`${b}-right`,a,c,a,l,{...z,thickness:Math.max(6,v)})):"funnel"===t?L.push(wa(`${b}-top`,s,c,a,y,z),wa(`${b}-bottom`,s,l,a,x,z),wa(`${b}-left`,s,c,s,l,{...z,thickness:Math.max(6,v-2)}),wa(`${b}-right`,a,y,a,x,{...z,thickness:Math.max(6,v)})):L.push(wa(`${b}-left-top`,s,c,j,y,z),wa(`${b}-left-bottom`,s,l,j,x,z),wa(`${b}-center-top`,j,y,F,y,z),wa(`${b}-center-bottom`,j,x,F,x,z),wa(`${b}-right-top`,F,y,a,c,z),wa(`${b}-right-bottom`,F,x,a,l,z),wa(`${b}-left`,s,c,s,l,{...z,thickness:Math.max(6,v-2)}),wa(`${b}-right`,a,c,a,l,{...z,thickness:Math.max(6,v)}));const O=e.membraneDampingScale??.5,T=s,R="bowtie"===t?j:a,W=Math.max(1,R-T),q=(e.membranes??[]).map(e=>{const t=T+me(e.offset,0,1)*W,n=e.width??18+18*e.cost,o=d-16,r=u+.25*(e.wobble??0);return{...e,x:t,y:r,width:n,height:o}}),D=!1===e.includeMembraneRegions?[]:q.map(e=>Sa({id:e.id,label:e.label??e.id,description:e.description??`${e.label??e.id} is a permeable region. It taxes energy and damps velocity while bodies overlap it.`,x:e.x,y:e.y,width:e.width,height:e.height,cost:e.cost,dampingScale:e.dampingScale??O,bodyStyle:e.bodyStyle,metadata:e.metadata,semanticItem:e.semanticItem,color:e.color}));return{shape:t,width:n,height:o,padX:r,padY:i,left:s,right:a,topY:c,bottomY:l,midY:u,centerLeft:j,centerRight:F,pinchHeight:p,pinchTop:y,pinchBottom:x,stages:P,membranes:q,colliders:L,regionEffects:D,boundaryY:E}}function va(e,t,n){return"function"==typeof t?o=>({...n,...t(o),primitive:e}):{...n,...t,primitive:e}}function ka(e,t,n,o){return{id:e.id,label:e.label,description:e.description,kind:e.kind??t,shape:(r=e.x,i=e.y,s=e.width,a=e.height,{type:"aabb",x:r,y:i,width:s,height:a}),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:n?va(n,e.attributes,o):e.attributes,onEnter:e.onEnter,onExit:e.onExit};var r,i,s,a}function $a(e,t={}){const n=t.idPrefix??"stage",o=Math.max(0,t.insetX??0),r=Math.max(0,t.insetY??1);return e.stages.map(e=>{const i="function"==typeof t.metadata?t.metadata(e):t.metadata??{};return{...ka({id:n?`${n}:${e.id}`:e.id,label:e.label??e.id,description:e.description,kind:"region",x:e.x,y:e.y,width:Math.max(1,e.width-2*o),height:Math.max(1,e.height-2*r),bodyFilter:t.bodyFilter,semanticItem:t.semanticItem,attributes:{primitive:"processStage",stageId:e.id,stageIndex:e.index},metadata:{...i,primitive:"processStage",stageId:e.id,stageIndex:e.index}})}})}function Sa(e){const t=e.dampingScale??.5,n=e.energyScale??1,o=me(e.cost,0,2);return{...ka(e,"membrane","membrane",{membraneCost:o}),damping:o*t,energyDelta:-o*n}}function Ia(e){return{...ka(e,"charge-gate","chargeGate"),charge:e.charge??!0,energyDelta:e.energyDelta,impulseOnEnter:e.impulseOnEnter}}function Aa(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:12,y:0};return{...ka(e,"force-field","routeSurface"),force:t,damping:e.damping??.015}}function Ca(e){const t=e.pressure??e.occupancy??0,n=e.baseDamping??.08,o=e.dampingPerUnit??.12,r=e.energyPerUnit??0;return{...ka(e,"membrane","pressureField",{pressure:t}),damping:n+t*o,energyDelta:r?-t*r:void 0,force:e.force}}function Na(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force;return{...ka(e,"force-field","capacitatedSensor",{capacity:e.capacity,unitsPerSecond:e.unitsPerSecond??e.capacity}),force:t,damping:e.damping,charge:e.charge??e.capacity}}function ja(e){return{...ka(e,"force-field","portal",{targetStage:e.targetStage}),force:e.force,impulseOnEnter:e.impulseOnEnter,damping:e.damping??.08}}function Fa(e){const t="number"==typeof e.force?{x:e.force,y:0}:e.force??{x:24,y:0};return{...ka(e,"sink","absorb"),force:t,damping:e.damping??.02,charge:e.charge??"absorbed"}}function Ea(e){return{...ka(e,"force-field","forceField"),force:e.force,damping:e.damping,energyDelta:e.energyDelta}}function Pa(e){const t=e.x??e.anchor?.x??0,n=e.y??e.anchor?.y??0;return{id:e.id,label:e.label,description:e.description,group:e.group,bodyIds:e.bodyIds,datum:e.datum,state:e.state,x:t,y:n,width:e.width,height:e.height,anchor:e.anchor??{x:t,y:n},completion:e.completion,tether:e.tether,semanticItem:e.semanticItem}}function za(e){const t=e.idPrefix??"lane",n={thickness:e.thickness??8,friction:e.friction??.5,restitution:e.restitution??.16},o=[wa(`${t}-top`,e.left,e.top,e.right,e.top,n),wa(`${t}-bottom`,e.left,e.bottom,e.right,e.bottom,n)];return e.openEnds||o.push(wa(`${t}-left`,e.left,e.top,e.left,e.bottom,n),wa(`${t}-right`,e.right,e.top,e.right,e.bottom,n)),o}function La(e,t,n={}){const o=n.random??Math.random,r=e.stages.find(e=>e.id===t)??e.stages[e.stages.length-1],i=me(n.along??.5,.05,.95),s=n.jitterX??0,a=n.padY??20,c=r.x0+(r.x1-r.x0)*i+(2*o()-1)*s,l=Math.min(1,r.width/2),u=me(c,r.x0+l,r.x1-l),d=e.boundaryY(u,"top")+a,h=e.boundaryY(u,"bottom")-a;return{x:u,y:h<=d?e.midY:d+o()*Math.max(1,h-d)}}function Oa(e){return"bowtie"===e.shape?[{id:"incoming",role:"incoming",points:[[e.left,e.topY],[e.centerLeft,e.pinchTop],[e.centerLeft,e.pinchBottom],[e.left,e.bottomY]]},{id:"center",role:"center",points:[[e.centerLeft,e.pinchTop],[e.centerRight,e.pinchTop],[e.centerRight,e.pinchBottom],[e.centerLeft,e.pinchBottom]]},{id:"outgoing",role:"outgoing",points:[[e.centerRight,e.pinchTop],[e.right,e.topY],[e.right,e.bottomY],[e.centerRight,e.pinchBottom]]}]:[{id:"volume",role:"volume",points:[[e.left,e.topY],[e.right,"funnel"===e.shape?e.pinchTop:e.topY],[e.right,"funnel"===e.shape?e.pinchBottom:e.bottomY],[e.left,e.bottomY]]}]}function Ta(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Ra(e,t){let n=e;for(const e of t.split(".")){if(null==n||"object"!=typeof n)return;if(!Object.prototype.hasOwnProperty.call(n,e))return;n=n[e]}return n}function Wa(e,t,n,o,r){return"function"==typeof o?o(e,t,n):Ra(e,o??r)}function qa(e){const t=Number(e.toFixed(hf));return Object.is(t,-0)?0:t}function Da(e){const t=(e??uf).map(e=>{const t=Ta(e);if(null==t||t<0||t>1)throw new RangeError(`physicsReferenceEnvelope quantiles must be finite values from 0 to 1; received ${String(e)}`);return qa(t)});return Array.from(new Set(t)).sort((e,t)=>e-t)}function Ba(e){if(Array.isArray(e)){if(e.length>df)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${df} points`);return Array.from(new Set(e.map(Ta).filter(e=>null!=e).map(qa))).sort((e,t)=>e-t)}const t=e,n=Ta(t.start),o=Ta(t.end),r=Ta(t.step);if(null==n||null==o||null==r||r<=0||o<n)throw new RangeError("physicsReferenceEnvelope sampleAt requires finite start/end values with end >= start and step > 0");const i=Math.floor((o-n)/r)+1;if(i>df)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${df} points`);const s=[],a=1e-10*Math.max(1,Math.abs(o),Math.abs(n));for(let e=0;e<i;e+=1){const t=n+e*r;if(t>o+a)break;s.push(qa(Math.min(t,o)))}if((!s.length||Math.abs(s[s.length-1]-o)>a)&&s.push(qa(o)),s.length>df)throw new RangeError(`physicsReferenceEnvelope sampleAt exceeds ${df} points`);return Array.from(new Set(s)).sort((e,t)=>e-t)}function Ya(e,t,n,o){const r=e.flatMap((e,r)=>{const i=Ta(Wa(e,r,t,n,"time")),s=Ta(Wa(e,r,t,o,"value"));return null==i||null==s?[]:[{time:qa(i),value:s,index:r}]});r.sort((e,t)=>e.time-t.time||e.index-t.index);const i=[];for(const e of r){const t=i[i.length-1];t?.time===e.time?t.value=e.value:i.push({time:e.time,value:e.value})}return i}function Va(e,t){let n=0,o=e.length;for(;n<o;){const r=n+o>>>1;e[r].time<t?n=r+1:o=r}return n}function Ga(e,t,n,o){if(!e.length)return null;const r=e[0],i=e[e.length-1];if(t<r.time)return"clamp"===o?r.value:null;if(t>i.time)return"clamp"===o?i.value:null;const s=Va(e,t),a=e[s];if(a?.time===t)return a.value;const c=e[Math.max(0,s-1)];if("step"===n||!a||a.time===c.time)return c.value;const l=(t-c.time)/(a.time-c.time);return c.value+(a.value-c.value)*l}function _a(e,t){if(1===e.length)return e[0];const n=(e.length-1)*t,o=Math.floor(n),r=Math.ceil(n);if(o===r)return e[o];const i=n-o;return e[o]+(e[r]-e[o])*i}function Ha(e){const t=e.interpolation??"step",n=e.outsideDomain??"omit",o=Da(e.quantiles),r=Ba(e.sampleAt),i=e.runs.map(t=>Ya(t.samples,t.id,e.timeAccessor,e.valueAccessor));return{points:r.map(e=>{const r=i.map(o=>Ga(o,e,t,n)).filter(e=>null!=e).sort((e,t)=>e-t),s={};for(const e of o)s[e]=r.length?_a(r,e):null;return{time:e,count:r.length,min:r.length?r[0]:null,max:r.length?r[r.length-1]:null,median:r.length?_a(r,.5):null,quantiles:s}}),quantiles:o,interpolation:t,outsideDomain:n,runCount:e.runs.length}}function Xa(e,t){return e.quantiles.length?"lower"===t?e.quantiles[0]:e.quantiles[e.quantiles.length-1]:"lower"===t?"min":"max"}function Ua(e,t){if("min"===t||"median"===t||"max"===t)return e[t];const n=Ta(t);if(null==n||n<0||n>1)throw new RangeError(`comparePhysicsTrace quantile selectors must be from 0 to 1; received ${String(t)}`);const o=qa(n);if(!Object.prototype.hasOwnProperty.call(e.quantiles,o))throw new Error(`comparePhysicsTrace could not find quantile ${o} in the reference envelope`);return e.quantiles[o]??null}function Ka(e,t,n){return e<t?"below":e>n?"above":"inside"}function Za(e,t){const n=Math.max(0,t.time-e.time);if(!(n>0)||null==e.value||null==e.lower||null==e.upper||null==t.value||null==t.lower||null==t.upper)return{below:0,inside:0,above:0,observed:0};const o=e.value-e.lower,r=t.value-t.lower,i=e.value-e.upper,s=t.value-t.upper,a=[0,1];for(const[e,t]of[[o,r],[i,s]])(e<0&&t>0||e>0&&t<0)&&a.push(-e/(t-e));a.sort((e,t)=>e-t);let c=0,l=0,u=0;for(let o=0;o<a.length-1;o+=1){const r=a[o],i=a[o+1];if(!(i>r))continue;const s=(r+i)/2,d=(i-r)*n,h=Ka(e.value+(t.value-e.value)*s,e.lower+(t.lower-e.lower)*s,e.upper+(t.upper-e.upper)*s);"below"===h?c+=d:"above"===h?u+=d:l+=d}return{below:c,inside:l,above:u,observed:n}}function Qa(e,t,n={}){const o=n.interpolation??t.interpolation,r=n.outsideDomain??t.outsideDomain,i=Ya(e,n.traceId??"trace",n.timeAccessor,n.valueAccessor),s=n.lower??Xa(t,"lower"),a=n.upper??Xa(t,"upper"),c=t.points.map(e=>{const t=Ga(i,e.time,o,r),n=Ua(e,s),c=Ua(e,a);if(null!=n&&null!=c&&n>c)throw new RangeError(`comparePhysicsTrace lower band exceeds upper band at time ${e.time}`);return{time:e.time,value:t,lower:n,upper:c,status:null==t||null==n||null==c?"unobserved":Ka(t,n,c)}});let l=0,u=0,d=0,h=0,f=null,m=0,p=null;for(const e of c){if("below"===e.status?l+=1:"inside"===e.status?u+=1:"above"===e.status&&(d+=1),null==e.value||null==e.lower||null==e.upper)continue;const t=Math.max(0,e.value-e.upper),n=Math.max(0,e.lower-e.value);t>h&&(h=t,f=e.time),n>m&&(m=n,p=e.time)}let g=0,y=0,x=0,b=0;for(let e=0;e<c.length-1;e+=1){const t=c[e],n=c[e+1],r=Math.max(0,n.time-t.time);if(r>0){if("linear"===o){const e=Za(t,n);g+=e.below,y+=e.inside,x+=e.above,b+=e.observed;continue}"unobserved"!==t.status&&(b+=r,"below"===t.status?g+=r:"above"===t.status?x+=r:y+=r)}}const w=c[0]?.time,M=c[c.length-1]?.time,v=null==w||null==M?0:Math.max(0,M-w),k=l+u+d;return{points:c,sampleCount:c.length,observedSamples:k,belowSamples:l,insideSamples:u,aboveSamples:d,totalDuration:v,observedDuration:b,unobservedDuration:Math.max(0,v-b),belowDuration:g,insideDuration:y,aboveDuration:x,peakExcess:h,peakExcessAt:f,peakDeficit:m,peakDeficitAt:p}}function Ja(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function ec(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function tc(e){return!!ec(e)&&"string"==typeof e.id&&"number"==typeof e.furthestStageIndex&&Number.isFinite(e.furthestStageIndex)&&Array.isArray(e.visitedStageIds)&&e.visitedStageIds.every(e=>"string"==typeof e)&&ec(e.visitsByStage)&&ec(e.firstEnteredAt)&&ec(e.lastEnteredAt)&&"number"==typeof e.regressionCount&&Number.isFinite(e.regressionCount)}function nc(e){return{id:e,furthestStageIndex:-1,visitedStageIds:[],visitsByStage:{},firstEnteredAt:{},lastEnteredAt:{},regressionCount:0}}function oc(e,t){const n=t.stageId?.(e);if(n)return n;const o=e.region.metadata;if(o&&"object"==typeof o&&Object.prototype.hasOwnProperty.call(o,"stageId")){const e=o.stageId;if("string"==typeof e)return e}return e.region.id}function rc(e){const t=Array.from(new Set(e.bodyIds??[]));return{stages:e.stages.map(e=>({...e})),bodyIds:t,entities:Object.fromEntries(t.map(e=>[e,nc(e)]))}}function ic(e,t,n={}){if("region-enter"!==t.type)return e;const o=oc(t,n),r=e.stages.findIndex(e=>e.id===o);if(r<0)return e;const i=n.entityId?.(t)??t.bodyId;if(!i)return e;const s=Ja(e.entities,i),a=tc(s)?s:nc(i),c=a.currentStageId?e.stages.findIndex(e=>e.id===a.currentStageId):-1,l=!a.visitedStageIds.includes(o),u=Number(t.observation.timestamp),d=Number.isFinite(u)?u:0,h=Ja(a.visitsByStage,o),f="number"==typeof h&&Number.isFinite(h)?h:0,m={...a,currentStageId:o,furthestStageId:r>a.furthestStageIndex?o:a.furthestStageId,furthestStageIndex:Math.max(a.furthestStageIndex,r),visitedStageIds:l?[...a.visitedStageIds,o]:a.visitedStageIds,visitsByStage:{...a.visitsByStage,[o]:f+1},firstEnteredAt:l?{...a.firstEnteredAt,[o]:d}:a.firstEnteredAt,lastEnteredAt:{...a.lastEnteredAt,[o]:d},regressionCount:c>=0&&r<c?a.regressionCount+1:a.regressionCount};return{...e,bodyIds:e.bodyIds.includes(i)?e.bodyIds:[...e.bodyIds,i],entities:{...e.entities,[i]:m}}}function sc(e){const t=e.bodyIds.map(t=>{const n=Ja(e.entities,t);return tc(n)?n:nc(t)}),n=t.length;let o=n;return e.stages.map((e,r)=>{const i=t.filter(e=>e.furthestStageIndex>=r).length,s=t.filter(t=>t.visitedStageIds.includes(e.id)).length,a=t.reduce((t,n)=>{const o=Ja(n.visitsByStage,e.id);return t+("number"==typeof o&&Number.isFinite(o)?o:0)},0),c={id:e.id,label:e.label??e.id,reached:i,entered:s,total:n,conversion:n>0?i/n:0,fromPrevious:o>0?i/o:0,dropoff:Math.max(0,o-i),visits:a,repeatVisits:Math.max(0,a-s)};return o=i,c})}function ac(e,t){if("function"==typeof t){const n=t(e);return Number.isFinite(n)&&n>0?Number(n):1}const n=e.datum;if(t&&n&&"object"==typeof n){const e=Number(n[t]);if(Number.isFinite(e)&&e>0)return e}const o=Number(n?.work??n?.reviewWork??n?.value);return Number.isFinite(o)&&o>0?o:1}function cc(e,t){if("function"==typeof t){const n=t(e);if(null!=n&&String(n).length>0)return String(n)}else if(t){const n=la(e.datum,t),o=la(e,t),r=n??o;if(null!=r&&String(r).length>0)return String(r)}return e.id}function lc(e,t){if(0===e.length)return 0;if(1===e.length)return e[0];const n=Math.max(0,Math.min(1,t))*(e.length-1),o=Math.floor(n),r=Math.ceil(n),i=n-o;return e[o]+(e[r]-e[o])*i}function uc(e){function t(e,t){const n=t(e);return!!n&&n.activeRegionIds.includes(f)}function n(){X+=1}function o(e){return{bodyId:e.bodyId,jobId:e.jobId,visitId:e.visitId,visit:e.visit,regionId:f,work:e.total,queuedAt:e.queuedAt}}function r(t,n,r){const i=o(n);e.onQueued?.(t,i),r.controls.recordObservation({type:"physics-capacity-queued",bodyId:t.id,datum:t.datum,x:t.x,y:t.y,regionId:f,work:n.total,jobId:n.jobId,visitId:n.visitId,visit:n.visit,queuedAt:n.queuedAt,queueDepth:v.size})}function i(e,t,o,i){const s={bodyId:e.id,jobId:t.jobId,visitId:t.visitId,visit:t.visit,remaining:t.work,total:t.work,queuedAt:t.queuedAt,sequence:i};return v.set(t.jobId,s),C.delete(e.id),A.set(e.id,t.jobId),R+=1,W+=t.work,n(),r(e,s,o),s}function s(e){if(v.size>=x||0===k.size)return;const t=Array.from(k.values()).sort((e,t)=>e.sequence-t.sequence);for(const n of t){if(v.size>=x)break;const t=I.get(n.jobId);t&&$.has(n.jobId)?(k.delete(n.jobId),C.delete(n.bodyId),i(t,n,e,n.sequence)):k.delete(n.jobId)}}function a(){let e=0;for(const t of v.values())e+=t.remaining;return e}function c(){let e=0;for(const t of k.values())e+=t.work;return e}function l(){G=Math.max(G,v.size),_=Math.max(_,a())}function u(){const e=Array.from(v.values()).sort((e,t)=>e.sequence-t.sequence);F=new Map(e.map((e,t)=>[e.bodyId,t]));const t=Array.from(k.values()).sort((e,t)=>e.sequence-t.sequence);E=new Map(t.map((e,t)=>[e.bodyId,t])),P=e.length}function d(e){(e.end>e.start||e.arrivals>0||e.completions>0||e.processedWork>0)&&N.push(e);const t=L-b;for(;N.length>0&&N[0].end<t;)N.shift()}function h(){const e=L-b,t=Math.max(0,Math.min(b,L-(O??L)));let n=0,o=0,r=0,i=0,s=0;for(const t of N){if(t.end<e)continue;n+=t.arrivals,o+=t.arrivalWork,r+=t.completions,i+=t.completedWork;const a=t.end-t.start;if(a<=0||t.start>=e)s+=t.processedWork;else{const n=Math.max(0,t.end-e);s+=t.processedWork*Math.min(1,n/a)}}const a=t>0?o/t:0;return{seconds:t,arrivals:n,arrivalWork:o,completions:r,completedWork:i,processedWork:s,arrivalsPerSecond:t>0?n/t:0,throughputPerSecond:t>0?r/t:0,utilization:t>0&&m>0?Math.max(0,Math.min(1,s/(m*t))):0,pressure:m>0?a/m:0}}const f=e.regionId,m=Math.max(0,e.unitsPerSecond),p=e.queueLayout??"lane",g=e.queueSlotSpacing??14,y=e.queueStiffness??.35,x=Number.isFinite(e.maxQueue)?Math.max(0,Math.floor(Number(e.maxQueue))):Number.POSITIVE_INFINITY,b=Math.max(.25,e.metricWindowSeconds??30),w=Math.max(1/60,e.snapshotIntervalSeconds??.25),M=e.releaseImpulse??{x:90,y:0},v=/* @__PURE__ */new Map,k=/* @__PURE__ */new Map,$=/* @__PURE__ */new Map,S=/* @__PURE__ */new Map,I=/* @__PURE__ */new Map,A=/* @__PURE__ */new Map,C=/* @__PURE__ */new Map,N=[];let j=0,F=/* @__PURE__ */new Map,E=/* @__PURE__ */new Map,P=0,z=0,L=0,O=null,T=0,R=0,W=0,q=0,D=0,B=0,Y=0,V=0,G=0,_=0,H=0,X=0,U=-1,K=!1;return{id:e.id??`capacity-queue:${f}`,continuous:!1!==e.continuous,tick:r=>{const a=r.controls.readBodies(),c=/* @__PURE__ */new Map,h=/* @__PURE__ */new Map;for(const n of a){if(c.set(n.id,n),!t(n.id,r.getRegionState))continue;if(!da(n,e.bodyFilter))continue;const o=cc(n,e.jobKey),i=h.get(o)??[];i.push(n),h.set(o,i)}const p=Number.isFinite(r.dt)?Math.max(0,r.dt):0;if(!K){const e=Number.isFinite(r.elapsed)?Math.max(0,r.elapsed):p;L=Math.max(0,e-p),K=!0}const g=L,y=g+p;L=y,O=null==O?g:Math.min(O,g);const b={start:g,end:y,arrivals:0,arrivalWork:0,completions:0,completedWork:0,processedWork:0},N=/* @__PURE__ */new Map;for(const[e,t]of h){const n=$.get(e)?.bodyId,o=t.find(e=>e.id===n)??t[0];N.set(e,o),I.set(e,o)}for(const[t,i]of $){if(N.has(t))continue;const s=v.get(t),a=c.get(i.bodyId)??I.get(t);if(s){v.delete(t),A.delete(s.bodyId),Y+=1,V+=s.remaining,n();const c={...o(s),abandonedAt:L,remainingWork:s.remaining,queueSeconds:Math.max(0,L-s.queuedAt)};a&&e.onAbandoned?.(a,c),r.controls.recordObservation({type:"physics-capacity-abandoned",bodyId:i.bodyId,datum:a?.datum,x:a?.x,y:a?.y,regionId:f,work:s.total,remainingWork:s.remaining,jobId:t,visitId:s.visitId,visit:s.visit,queuedAt:s.queuedAt,abandonedAt:L,queueSeconds:c.queueSeconds,queueDepth:v.size})}k.delete(t),C.delete(i.bodyId),$.delete(t),I.delete(t)}for(const[t,o]of N){if($.has(t))continue;const s=(S.get(t)??0)+1;S.set(t,s);const a=ac(o,e.unitAccessor),c={bodyId:o.id,jobId:t,visitId:`${f}:${t}:${s}`,visit:s,regionId:f,work:a,queuedAt:L};$.set(t,c),T+=1,b.arrivals+=1,b.arrivalWork+=a;const l=j++;if(v.size<x)i(o,c,r,l);else{const i={...c,blockedAt:L,sequence:l};k.set(t,i),C.set(o.id,t),B+=1,n(),e.onBlocked?.(o,i),r.controls.recordObservation({type:"physics-capacity-blocked",bodyId:o.id,datum:o.datum,x:o.x,y:o.y,regionId:f,work:a,jobId:t,visitId:c.visitId,visit:s,queuedAt:L,blockedAt:L,queueDepth:v.size,blockedDepth:k.size})}}s(r),l();const F=Array.from(v.values()).sort((e,t)=>e.sequence-t.sequence);let E=m*p;for(const t of F){if(!(E>0))break;const i=Math.min(t.remaining,E);if(t.remaining-=i,E-=i,q+=i,b.processedWork+=i,t.remaining>1e-6)continue;v.delete(t.jobId),A.delete(t.bodyId),z+=1,D+=t.total,b.completions+=1,b.completedWork+=t.total;const s=Math.max(0,L-t.queuedAt);H+=s,n();const a=c.get(t.bodyId);if(!a)continue;r.controls.applyImpulse(t.bodyId,M.x??0,M.y??0);const l={...o(t),completedAt:L,queueSeconds:s};e.onProcessed?.(a,l),r.controls.recordObservation({type:"physics-capacity-processed",bodyId:t.bodyId,datum:a.datum,x:a.x,y:a.y,regionId:f,work:t.total,jobId:t.jobId,visitId:t.visitId,visit:t.visit,queuedAt:t.queuedAt,completedAt:L,queueSeconds:s,queueDepth:v.size})}s(r),l(),u(),d(b);const P=Math.floor(L/w);P!==U&&(U=P,n())},getSnapshot:()=>{const e=a(),t=c(),n=v.size,o=Array.from(v.values()).map(e=>Math.max(0,L-e.queuedAt)).sort((e,t)=>e-t),r=o.reduce((e,t)=>e+t,0);return{regionId:f,queueDepth:n,processedCount:z,unitsPerSecond:m,remainingWork:e,meanRemainingWork:n>0?e/n:0,waitingWork:e+t,blockedDepth:k.size,blockedWork:t,arrivalCount:T,admittedCount:R,admittedWork:W,processedWork:q,completedWork:D,blockedCount:B,abandonedCount:Y,abandonedWork:V,peakQueueDepth:G,peakRemainingWork:_,queueAge:{count:o.length,meanSeconds:o.length>0?r/o.length:0,p50Seconds:lc(o,.5),p95Seconds:lc(o,.95),oldestSeconds:o.at(-1)??0},meanCompletedQueueSeconds:z>0?H/z:0,window:h(),simulatedAt:L,metricRevision:X}},bodyForce:e=>{if("none"===p)return null;const t=A.get(e.body.id),n=C.get(e.body.id),o=t?v.get(t):void 0,r=n?k.get(n):void 0;if(!o&&!r)return null;const i=o?F.get(e.body.id):E.get(e.body.id);if(null==i)return null;let s;const a=e.regions;if(a)for(let e=0;e<a.length;e+=1)if(a[e].id===f){const t=a[e].shape;t&&"aabb"===t.type&&(s=t);break}if(!s)return{x:8*-Math.sign(e.body.vx||1),y:0};const c=r?s.x-.44*s.width:s.x-.22*s.width-i*(.15*g),l=s.y-(i-((r?k.size:P)-1)/2)*g/Math.max(1,Math.sqrt(r?k.size:P)),u=c-e.body.x,d=l-e.body.y;return{x:u*y,y:d*y*.85}}}}function dc(e,t){return e||t?{x:(e?.x??0)+(t?.x??0),y:(e?.y??0)+(t?.y??0)}:null}function hc(e){if(!e?.length)return null;const t=e.slice(),n=t.some(e=>!1!==e.continuous);return{controllers:t,continuous:n,onTick:(e,n,o)=>{const r={result:e,controls:n,dt:o.dt,elapsed:o.elapsed,getRegionState:o.getRegionState};for(const e of t)e.tick(r)},bodyForce:e=>{let n=null;for(const o of t)o.bodyForce&&(n=dc(n,o.bodyForce(e)));return n}}}function fc(e){const t=/* @__PURE__ */new Set,n=e.impulse??{x:-60,y:0};return{id:e.id??`portal:${e.fromRegionId}`,continuous:!0===e.continuous,tick:o=>{const r=o.controls.readBodies();for(const i of r){const r=o.getRegionState(i.id),s=r?.activeRegionIds.includes(e.fromRegionId);s?t.has(i.id)||(t.add(i.id),o.controls.applyImpulse(i.id,n.x??0,n.y??0),e.onPortal?.(i)):t.delete(i.id)}}}}function mc(e){const t=e.resources.map(e=>({...e,bodyId:e.bodyId??e.id})),n=new Map(t.map(e=>[e.bodyId,e])),o=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map,i=e.assignmentForce??.45,s=e.returnForce??.35,a=e.caseAttraction??.08,c=e.assignmentOffset??{x:0,y:0};let l=/* @__PURE__ */new Map,u=0,d=0;return{id:e.id??"service-resource-pool",continuous:!0,assign:e=>{const n=o.get(e);if(n)return n;const i=t.find(e=>!r.has(e.id));if(!i)return null;const s={resourceId:i.id,resourceBodyId:i.bodyId,caseBodyId:e,assignedAt:u};return o.set(e,s),r.set(i.id,s),d+=1,s},release:e=>{const t=o.get(e);return!!t&&(o.delete(e),r.delete(t.resourceId),d+=1,!0)},getAssignment:e=>o.get(e),tick:e=>{u=Math.max(u,e.elapsed),l=new Map(e.controls.readBodies().map(e=>[e.id,e]));for(const[e,t]of o)l.has(e)&&l.has(t.resourceBodyId)||(o.delete(e),r.delete(t.resourceId),d+=1)},getSnapshot:()=>({total:t.length,available:t.length-r.size,assigned:r.size,assignments:Array.from(o.values()),simulatedAt:u,metricRevision:d}),bodyForce:e=>{const t=n.get(e.body.id);if(t){const n=r.get(t.id),o=n?l.get(n.caseBodyId):void 0,a=o?o.x+(c.x??0):t.home.x,u=o?o.y+(c.y??0):t.home.y,d=n?i:s;return{x:(a-e.body.x)*d,y:(u-e.body.y)*d}}const u=o.get(e.body.id);if(!u||a<=0)return null;const d=l.get(u.resourceBodyId);return d?{x:(d.x-e.body.x)*a,y:(d.y-e.body.y)*a}:null}}}function pc(e,t){const n="function"==typeof t.deadlineAccessor?t.deadlineAccessor(e):la(e.datum,t.deadlineAccessor)??la(e,t.deadlineAccessor);return Number.isFinite(Number(n))?Math.max(0,Number(n)):0}function gc(e){function t(t){o.set(t.bodyId,t),i+=1,e.onStateChange?.({...t})}function n(e){const n=o.get(e);return!(!n||null!=n.completedAt||(t({...n,completedAt:r,state:"unhappy"===n.state?"resolved-unhappy":"resolved"}),0))}const o=/* @__PURE__ */new Map;let r=0,i=0;return{id:e.id??"service-level",continuous:!0,protect:e=>{const n=o.get(e);return!(!n||null!=n.completedAt||"unhappy"===n.state||(t({...n,state:"protected",protectedAt:r}),0))},complete:n,getCase:e=>o.get(e),tick:i=>{r=Math.max(r,i.elapsed);for(const s of i.controls.readBodies()){if(!da(s,e.bodyFilter))continue;if(!o.has(s.id)){const n=pc(s,e);t({bodyId:s.id,openedAt:r,deadlineAt:r+n,state:"waiting"})}const a=o.get(s.id);a&&null==a.completedAt&&(e.completionRegionId&&i.getRegionState(s.id)?.activeRegionIds.includes(e.completionRegionId)?n(s.id):"waiting"===a.state&&r>=a.deadlineAt&&t({...a,state:"unhappy"}))}},getSnapshot:()=>{const e=Array.from(o.values()),t=t=>e.filter(e=>e.state===t).length;return{total:e.length,waiting:t("waiting"),protected:t("protected"),unhappy:t("unhappy"),resolved:t("resolved"),resolvedUnhappy:t("resolved-unhappy"),simulatedAt:r,metricRevision:i}}}}function yc(e){const t=/* @__PURE__ */new Set;let n=0,o=0,r=0,i=!1;return{id:e.id??`dependency-gate:${e.regionId}`,continuous:!0,tick:s=>{n=Math.max(n,s.elapsed);const a=i;var c;c=n,i=e.isOpen?e.isOpen(c):null!=e.opensAt&&c>=e.opensAt;const l=s.controls.readBodies(),u=new Map(l.map(e=>[e.id,e]));for(const n of l){const o=s.getRegionState(n.id)?.activeRegionIds.includes(e.regionId);o&&da(n,e.bodyFilter)&&(i||t.has(n.id)||(t.add(n.id),r+=1,e.onHeld?.(n)))}if(i&&!a){for(const n of t){const t=u.get(n);t&&(s.controls.applyImpulse(n,e.releaseImpulse?.x??86,e.releaseImpulse?.y??0),o+=1,e.onReleased?.(t))}t.clear(),r+=1}for(const e of t)u.has(e)||(t.delete(e),r+=1)},getSnapshot:()=>({regionId:e.regionId,isOpen:i,blocked:t.size,released:o,simulatedAt:n,metricRevision:r}),bodyForce:n=>{if(i||!t.has(n.body.id))return null;const o=n.regions?.find(t=>t.id===e.regionId),r=o?.shape;if(!r||"aabb"!==r.type)return{x:.8*-n.body.vx,y:.8*-n.body.vy};const s=e.holdForce??.4;return{x:(r.x-n.body.x)*s-.45*n.body.vx,y:(r.y-n.body.y)*s-.45*n.body.vy}}}}function xc(e){return e.length*pf}function bc(e,t){const n=e.trim();if(n.length<=t)return n;if(t<=1)return n.slice(0,1);const o=n.split(/\s+/).filter(Boolean).map(e=>e[0]).join("").toUpperCase();return o.length>1&&o.length<=t?o:t<=3?n.slice(0,t).toUpperCase():`${n.slice(0,Math.max(1,t-2))}..`}function wc(e,t,n="auto"){const o=Math.max(1,Math.floor(t/pf)),r="compact"===n?bc(e,o):"full"===n||xc(e)<=t?e:bc(e,o);return{text:r,textLength:xc(r)>t?Math.max(4,t):void 0}}function Mc(e){return e.absorb?"absorb":e.portalTarget?"portal":null!=e.capacity?"capacity":"flow"}function vc(e){if(null!=e.capacity){const t=null!=e.queueDepth?` · q ${e.queueDepth}`:"";return e.capacityLabel?`${e.capacityLabel}${t}`:`cap ${Number.isInteger(e.capacity)?String(e.capacity):e.capacity.toFixed(1)}${t}`}return e.absorb?"absorb":e.portalTarget?"portal":"flow"}function kc(e,t={}){const{showFlowSpine:n=!0,showStageCounts:o=!0,showCapacityBadges:r=!0,showGroupSockets:i=!0,stageLabelMode:s="auto",outlineStages:a=!1,testId:c="process-flow-chrome"}=t,{width:l,height:u,left:d,right:h,topY:f,bottomY:m,midY:p,stages:g,groups:y=[]}=e,x=m-f;/* @__PURE__ */ /* @__PURE__ */
|
|
111
|
+
return(0,ff.jsxs)("svg",{"aria-hidden":"true","data-testid":c,"data-outline-stages":a?"true":void 0,width:l,height:u,viewBox:`0 0 ${l} ${u}`,style:{position:"absolute",inset:0,pointerEvents:"none"},className:["semiotic-process-chrome",a?"semiotic-process-chrome--outline-stages":null].filter(Boolean).join(" "),children:[
|
|
115
112
|
/* @__PURE__ */
|
|
116
|
-
/* @__PURE__ */(0,
|
|
113
|
+
/* @__PURE__ */(0,ff.jsx)("defs",{children:/* @__PURE__ */ /* @__PURE__ */(0,ff.jsxs)("linearGradient",{id:"semiotic-process-floor",x1:"0",x2:"0",y1:"0",y2:"1",children:[
|
|
117
114
|
/* @__PURE__ */
|
|
118
|
-
/* @__PURE__ */(0,
|
|
115
|
+
/* @__PURE__ */(0,ff.jsx)("stop",{offset:"0%",stopColor:"var(--semiotic-process-floor, var(--semiotic-bg, #0f172a))",stopOpacity:"0.2"}),
|
|
119
116
|
/* @__PURE__ */
|
|
120
|
-
/* @__PURE__ */(0,
|
|
117
|
+
/* @__PURE__ */(0,ff.jsx)("stop",{offset:"100%",stopColor:"var(--semiotic-process-lane, var(--semiotic-surface, #1e293b))",stopOpacity:"0.55"})]})}),
|
|
121
118
|
/* @__PURE__ */
|
|
122
|
-
/* @__PURE__ */(0,
|
|
119
|
+
/* @__PURE__ */(0,ff.jsx)("rect",{x:0,y:0,width:l,height:u,fill:"url(#semiotic-process-floor)"}),
|
|
123
120
|
/* @__PURE__ */
|
|
124
|
-
/* @__PURE__ */(0,
|
|
125
|
-
return(0,
|
|
121
|
+
/* @__PURE__ */(0,ff.jsx)("rect",{x:d-6,y:f-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}),n?/* @__PURE__ */ /* @__PURE__ */(0,ff.jsx)("line",{x1:d+8,x2:h-8,y1:p,y2:p,stroke:"var(--semiotic-process-border, var(--semiotic-border, #475569))",strokeWidth:2,strokeDasharray:"6 8",opacity:.55}):null,g.map((e,t)=>{const n=Mc(e),i=mf[n],c=Math.max(12,e.width-8),l=me(c-8,22,88),d=Math.max(8,l-10),h=wc(e.label,d,s),y="none"!==s&&c-8>=22,b=vc(e),w=wc(b,Math.max(16,c-10),"auto"),M=r&&!1!==e.showBadge&&c>=32,v=null!=e.count?`n=${e.count}${null!=e.processed?` done ${e.processed}`:""}`:"",k=wc(v,Math.max(16,c-8),"auto"),$=Math.max(30,f-15),S=$-13;/* @__PURE__ */ /* @__PURE__ */
|
|
122
|
+
return(0,ff.jsxs)("g",{"data-stage":e.id,"data-role":n,children:[
|
|
126
123
|
/* @__PURE__ */
|
|
127
|
-
/* @__PURE__ */(0,
|
|
124
|
+
/* @__PURE__ */(0,ff.jsx)("rect",{className:"semiotic-process-chrome__stage-bay",x:e.x0+4,y:f+6,width:c,height:x-12,rx:10,fill:a?"none":i.fill,stroke:i.stroke,strokeWidth:a?1.85:"flow"===n?1:1.6}),t<g.length-1?/* @__PURE__ */ /* @__PURE__ */(0,ff.jsx)("polygon",{points:`${e.x1-2},${p-7} ${e.x1+8},${p} ${e.x1-2},${p+7}`,fill:i.accent,opacity:.85}):null,y?/* @__PURE__ */ /* @__PURE__ */(0,ff.jsxs)(ff.Fragment,{children:[
|
|
128
125
|
/* @__PURE__ */
|
|
129
|
-
/* @__PURE__ */(0,
|
|
126
|
+
/* @__PURE__ */(0,ff.jsx)("rect",{className:"semiotic-process-chrome__stage-label-bg",x:e.x-l/2,y:S,width:l,height:18,rx:9,fill:"var(--semiotic-bg, #0f172a)",fillOpacity:.75,stroke:i.stroke}),
|
|
130
127
|
/* @__PURE__ */
|
|
131
|
-
/* @__PURE__ */(0,
|
|
128
|
+
/* @__PURE__ */(0,ff.jsxs)("text",{x:e.x,y:$,textAnchor:"middle",fill:i.accent,fontSize:10,fontWeight:800,className:"semiotic-process-chrome__stage-label",textLength:h.textLength,lengthAdjust:h.textLength?"spacingAndGlyphs":void 0,children:[
|
|
132
129
|
/* @__PURE__ */
|
|
133
|
-
/* @__PURE__ */(0,
|
|
130
|
+
/* @__PURE__ */(0,ff.jsx)("title",{children:e.label}),h.text]})]}):null,M?/* @__PURE__ */ /* @__PURE__ */(0,ff.jsxs)("text",{x:e.x,y:f+22,textAnchor:"middle",fill:"var(--semiotic-process-muted, var(--semiotic-text-secondary, #94a3b8))",fontSize:9,fontWeight:700,textLength:w.textLength,lengthAdjust:w.textLength?"spacingAndGlyphs":void 0,children:[
|
|
134
131
|
/* @__PURE__ */
|
|
135
|
-
/* @__PURE__ */(0,
|
|
132
|
+
/* @__PURE__ */(0,ff.jsx)("title",{children:b}),w.text]}):null,o&&null!=e.count?/* @__PURE__ */ /* @__PURE__ */(0,ff.jsxs)("text",{x:e.x,y:Math.min(u-8,m+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:[
|
|
136
133
|
/* @__PURE__ */
|
|
137
|
-
/* @__PURE__ */(0,
|
|
138
|
-
return(0,
|
|
134
|
+
/* @__PURE__ */(0,ff.jsx)("title",{children:v}),k.text]}):null]},e.id)}),i?y.map((e,t)=>{const n=e.total??0,o=e.absorbed??0,r=e.complete??(n>0&&o>=n),i=!r&&n>0&&o/n>=.75,s=r?"rgba(52, 211, 153, 0.35)":i?"rgba(251, 191, 36, 0.28)":"rgba(15, 23, 42, 0.75)",a=r?"#34d399":i?"#fbbf24":"var(--semiotic-border, #64748b)",c=n>0?`${o}/${n}${r?" shipped":i?" almost":""}`:`feature ${t+1}`,l=me(Math.max(54,xc(e.label)+18,xc(c)+16),54,104),u=wc(e.label,l-12,"auto"),d=wc(c,l-12,"auto");/* @__PURE__ */ /* @__PURE__ */
|
|
135
|
+
return(0,ff.jsxs)("g",{"data-group":e.id,children:[
|
|
139
136
|
/* @__PURE__ */
|
|
140
|
-
/* @__PURE__ */(0,
|
|
137
|
+
/* @__PURE__ */(0,ff.jsx)("rect",{x:e.x-l/2,y:e.y-22,width:l,height:44,rx:10,fill:s,stroke:a,strokeWidth:1.5}),
|
|
141
138
|
/* @__PURE__ */
|
|
142
|
-
/* @__PURE__ */(0,
|
|
139
|
+
/* @__PURE__ */(0,ff.jsxs)("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:[
|
|
143
140
|
/* @__PURE__ */
|
|
144
|
-
/* @__PURE__ */(0,
|
|
141
|
+
/* @__PURE__ */(0,ff.jsx)("title",{children:e.label}),u.text]}),
|
|
145
142
|
/* @__PURE__ */
|
|
146
|
-
/* @__PURE__ */(0,
|
|
143
|
+
/* @__PURE__ */(0,ff.jsxs)("text",{x:e.x,y:e.y+12,textAnchor:"middle",fill:a,fontSize:9,fontWeight:700,textLength:d.textLength,lengthAdjust:d.textLength?"spacingAndGlyphs":void 0,children:[
|
|
147
144
|
/* @__PURE__ */
|
|
148
|
-
/* @__PURE__ */(0,pf.jsx)("title",{children:c}),d.text]})]},e.id)}):null]})}function Nc(e){if(null==e){const e=xf.padding;return{top:e,right:e,bottom:e,left:e}}return"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function jc(e){if("number"==typeof e){const t=Math.max(1,Math.round(e));return Array.from({length:t},(e,t)=>({id:`bin-${t}`,label:String(t)}))}return 0===e.length?[{id:"bin-0",label:"0"}]:e.map((e,t)=>({id:e.id,label:e.label??e.id??String(t)}))}function Fc(e){const[t,n]=e.size,o=e.flow??xf.flow,r=Nc(e.padding),i=Math.max(.05,Math.min(1,e.channelRatio??xf.channelRatio)),s={x:r.left,y:r.top,width:Math.max(1,t-r.left-r.right),height:Math.max(1,n-r.top-r.bottom)},a="down"===o?s.height:s.width,c=a*Math.max(0,e.chargeExtent??xf.chargeExtent),l=a*Math.max(0,e.projectionExtent??xf.projectionExtent),u=a*Math.max(0,e.destinationExtent??xf.destinationExtent),d=Math.max(0,a-c-u-l),h=jc(e.destinations),f=("down"===o?s.width:s.height)/h.length,m="down"===o?(e,t)=>({x:s.x,y:s.y+e,width:s.width,height:t}):(e,t)=>({x:s.x+e,y:s.y,width:t,height:s.height}),p=m(0,c),g=m(c,d),y=c+d,x=m(y,u),b=m(y+u,l),w=h.map((e,t)=>{const n=t*f,r=f*i,a=(f-r)/2;if("down"===o){const o=s.x+n+a;return{id:e.id,label:e.label,order:t,x:o,y:x.y,width:r,height:x.height,centerX:s.x+(t+.5)*f,centerY:x.y+x.height/2}}const c=s.y+n+a;return{id:e.id,label:e.label,order:t,x:x.x,y:c,width:x.width,height:r,centerX:x.x+x.width/2,centerY:s.y+(t+.5)*f}});return{width:t,height:n,flow:o,charge:p,apparatus:g,destinations:w,projection:b}}function Ec(e,t){return e.destinations.find(e=>e.id===t)}function Pc(e,t,n){const{charge:o,flow:r}=e,i=Math.max(1,n),s=(t%i+.5)/i;return"down"===r?{x:o.x+o.width*s,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height*s}}function zc(e,t={}){const n=t.thickness??4,o=t.idPrefix??"stage",{destinations:r,flow:i,width:s,height:a}=e,c=[];if(r.length>0){const t=r[0];if("down"===i){const i=t.y+t.height;c.push({id:`${o}-floor`,shape:{type:"segment",x1:e.charge.x,y1:i,x2:e.charge.x+e.charge.width,y2:i,thickness:n}});for(let e=1;e<r.length;e+=1){const s=r[e].centerX-(r[e].centerX-r[e-1].centerX)/2;c.push({id:`${o}-divider-${e}`,shape:{type:"segment",x1:s,y1:t.y,x2:s,y2:i,thickness:n}})}}else{const i=t.x+t.width;c.push({id:`${o}-floor`,shape:{type:"segment",x1:i,y1:e.charge.y,x2:i,y2:e.charge.y+e.charge.height,thickness:n}});for(let e=1;e<r.length;e+=1){const s=r[e].centerY-(r[e].centerY-r[e-1].centerY)/2;c.push({id:`${o}-divider-${e}`,shape:{type:"segment",x1:t.x,y1:s,x2:i,y2:s,thickness:n}})}}}return!1!==t.walls&&c.push({id:`${o}-wall-left`,shape:{type:"segment",x1:1,y1:0,x2:1,y2:a,thickness:n}},{id:`${o}-wall-right`,shape:{type:"segment",x1:s-1,y1:0,x2:s-1,y2:a,thickness:n}}),c}function Lc(e,t={}){const n=t.charge??"bodies",o=t.apparatus??"the apparatus",r=t.destination??"destinations",i=e.destinations.length,s="down"===e.flow?"downward":"left to right";return`${n} enter at the ${"down"===e.flow?"top":"left"}, travel ${s} through ${o}, and come to rest in ${i} ${r}: ${e.destinations.map(e=>e.label).join(", ")}.`}function Oc(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Tc(e,t,n,o){const r="function"==typeof e?e(t,n):e;return Number.isFinite(r)?Number(r):o}function Rc(e,t,n){return Oc(e[t])??n}function Wc(e,t){return"number"==typeof e?e:e?.[t]??0}function qc(e){const t=e.bandwidth??e.scale.bandwidth?.()??0,n=/* @__PURE__ */new Set;for(const o of e.values){const r=e.scale(o);Number.isFinite(r)&&(n.add(Number(r)),n.add(Number(r)+t))}return Array.from(n).sort((e,t)=>e-t)}function Dc(e){const{band:t,idPrefix:n,plot:o,projection:r}=e,{includeBoundaryWalls:i=!0,includeInteriorWalls:s=!0,wallThickness:a=4}=t,c=qc(t);if(c.length<2)return[];const l=i?0:1,u=i?c.length-1:c.length-2,d=[];for(let e=l;e<=u;e+=1){if(!s&&e>0&&e<c.length-1)continue;const t=c[e];d.push({id:`${n}-wall-${e}`,shape:"x"===r?{type:"aabb",x:t,y:o.y+o.height/2,width:a,height:o.height}:{type:"aabb",x:o.x+o.width/2,y:t,width:o.width,height:a}})}return d}function Bc(e){const{plot:t,idPrefix:n="physics-scale",bounds:o={},xBins:r,xBands:i,yBands:s}=e,a=[];if(!1!==o&&a.push(...ya(t,{idPrefix:n,...o})),r){const{idPrefix:e,yTop:o,yBottom:i,...s}=r;a.push(...xa({...s,idPrefix:e??`${n}-xbin`,yTop:o??t.y,yBottom:i??t.y+t.height}))}return i&&a.push(...Dc({band:i,idPrefix:i.idPrefix??`${n}-xband`,plot:t,projection:"x"})),s&&a.push(...Dc({band:s,idPrefix:s.idPrefix??`${n}-yband`,plot:t,projection:"y"})),a}function Yc(e){const{plot:t,rows:n,columns:o=n+1,pegRadius:r=3,idPrefix:i="galton-peg",yStart:s=t.y+.18*t.height,yEnd:a=t.y+.58*t.height,stagger:c=!0,restitution:l=.2,friction:u=.04}=e,d=Math.max(0,Math.floor(n)),h=Math.max(1,Math.floor(o));if(0===d)return[];const f=d<=1?0:(a-s)/(d-1),m=t.width/h,p=[];for(let e=0;e<d;e+=1){const n=c&&e%2==1?m/2:0;for(let o=0;o<h;o+=1){const a=t.x+m*(o+.5)+n;a<t.x+r||a>t.x+t.width-r||p.push({id:`${i}-${e}-${o}`,shape:{type:"aabb",x:a,y:s+e*f,width:2*r,height:2*r},restitution:l,friction:u})}}return p}function Vc(e,t={}){const{idPrefix:n="physics-token",radius:o=5,shape:r,mass:i,vx:s,vy:a,spawnAt:c,seed:l=1,jitter:u,datum:d}=t,h=Re(l),f=Wc(u,"x"),m=Wc(u,"y");return e.map((e,l)=>{const u=Tc(t.x,e,l,Rc(e,"x",0)),p=Tc(t.y,e,l,Rc(e,"y",0)),g=Tc(o,e,l,5),y="function"==typeof r?r(e,l):r??{type:"circle",radius:g};return{id:`${n}-${e.index??l}`,x:u+(h()-.5)*f,y:p+(h()-.5)*m,vx:Tc(s,e,l,0),vy:Tc(a,e,l,0),mass:Tc(i,e,l,1),spawnAt:Tc(c,e,l,void 0),shape:y,datum:d?d(e,l):e.datum??e}}).map(e=>{if(Number.isFinite(e.spawnAt))return e;const{spawnAt:t,...n}=e;return n})}function Gc(e,t={}){const{idPrefix:n="sediment",collider:o=!0,colliderThickness:r=1,restitution:i=.05,friction:s=.2,...a}=t,c=fa(e,a),l=o?c.filter(e=>e.height>0).map(e=>({id:`${n}-${e.binId}`,shape:{type:"aabb",x:e.x+e.width/2,y:e.y+r/2,width:e.width,height:r},restitution:i,friction:s})):[];return{columns:c,colliders:l}}function _c(e,t,n){return Oc("function"==typeof n?n(e,t):e[n]??e.datum?.[n])}function Hc(e,t={}){const{timeAccessor:n="arrivalTime",timeScale:o=1,startAt:r=0,rebase:i=!0,sort:s=!0}=t,a=e.map((e,t)=>({spawn:e,time:_c(e,t,n)??e.spawnAt??t})),c=a.length?Math.min(...a.map(e=>e.time)):0;return{initialSpawns:a.map(({spawn:e,time:t})=>({...e,spawnAt:r+(i?t-c:t)})).sort((e,t)=>s?(e.spawnAt??0)-(t.spawnAt??0):0),initialSpawnPacing:{pacing:"arrival",startAt:r,timeAccessor:"spawnAt",timeScale:o}}}function Xc(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function Uc(e,t,n="group"){const o=oa(e,t),r=e=>"function"==typeof n?n(e):e[n]??0;return e.slice().sort((e,t)=>{const n=r(e),i=r(t);return n<i?-1:n>i?1:(o[t.id]||0)-(o[e.id]||0)}).map(e=>e.id)}function Kc(e,t={}){const n=t.baseline??.62,o=t.inset??.06,r={},i=e.length;return e.forEach((e,t)=>{Xc(r,e,{x:i>1?o+t/(i-1)*(1-2*o):.5,y:n})}),r}function Zc(e,t,n=.55){const o=Math.abs(t.x-e.x),r=(e.x+t.x)/2,i=e.y-o*n;return`M${e.x},${e.y} Q${r},${i} ${t.x},${t.y}`}function Qc(e,t={}){const n=t.radius??.42,o=t.center?.x??.5,r=t.center?.y??.5,i=t.startAngle??0,s={},a=e.length;return e.forEach((e,t)=>{const c=i+t/a*Math.PI*2-Math.PI/2;Xc(s,e,{x:o+Math.cos(c)*n,y:r+Math.sin(c)*n})}),s}function Jc(e,t,n={}){const o=(n.order??Uc(e,t,n.groupAccessor??"group")).slice(),r=new Map(o.map((e,t)=>[e,t])),i=/* @__PURE__ */new Map;for(const e of t){if(!r.has(e.source)||!r.has(e.target)||e.source===e.target)continue;const t=e.source<e.target?`${e.source}${bf}${e.target}`:`${e.target}${bf}${e.source}`;i.set(t,(i.get(t)||0)+(e.value??1))}const s=[];let a=0;for(const[e,t]of i){const[n,o]=e.split(bf),i=r.get(n),c=r.get(o);t>a&&(a=t),s.push({row:i,col:c,source:n,target:o,value:t}),s.push({row:c,col:i,source:o,target:n,value:t})}return{order:o,cells:s,size:o.length,maxValue:a}}function el(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function tl(e){if("string"!=typeof e)return;const t=e.trim();return t.length?t:void 0}function nl(e,t){const n=el(e.note)?e.note:void 0;return t?tl(e.mobileText)||tl(e.shortText)||tl(e.label)||tl(n?.mobileText)||tl(n?.shortText)||tl(n?.label)||tl(n?.title):tl(e.label)||tl(e.mobileText)||tl(e.shortText)||tl(n?.label)||tl(n?.title)}function ol(e,t,n){if(!n)return;const o="function"==typeof n?n(e,t):e[n];return"number"==typeof o&&Number.isFinite(o)?o:void 0}function rl(e,t,n){const o=ol(e,t,n.priorityAccessor);if(void 0!==o)return o;let r=1e3-t;const i=String(e.emphasis??"").toLowerCase();"primary"!==i&&"critical"!==i||(r+=1e4),"secondary"===i&&(r-=1e3),"high"===e.priority&&(r+=5e3),"low"===e.priority&&(r-=1500),"number"==typeof e.priority&&(r+=100*e.priority);const s=el(e.provenance)?e.provenance:void 0;"number"==typeof s?.confidence&&(r+=100*s.confidence);const a=el(e.lifecycle)?e.lifecycle:void 0,c=String(a?.freshness??"").toLowerCase();return"expired"!==c&&"stale"!==c||(r-=3e3),r}function il(e,t){if(!t)return e;const n=nl(e,!0);return n&&"string"==typeof e.label?{...e,label:n}:e}function sl(e,t,n,o){const r=nl(e,o);if(!r)return null;const i=tl(e.id)||tl(e.key)||tl(e.pointId)||`annotation-${t+1}`,s=el(e.provenance)?tl(e.provenance.source)||tl(e.provenance.authorKind):void 0;return{id:i,label:r,shortLabel:tl(e.shortText),pointId:e.pointId,emphasis:"string"==typeof e.emphasis?e.emphasis:void 0,source:s,priority:n,annotation:e}}function al(e,t={}){const n=Array.isArray(e)?e.filter(el):[],o=t.breakpoint??480,r=t.active??(null==t.width||t.width<=o),i=t.strategy??"hybrid",s=!1!==t.preferShortText,a=!1!==t.preservePrimary,c=Math.max(0,t.maxPlotAnnotations??t.maxAnnotations??("callout-list"===i?1:2)),l=Math.max(0,t.minPlotAnnotations??t.minVisible??1);if(!r||"plot"===i)return{active:r,strategy:i,budget:n.length,visible:s?n.map(e=>il(e,s)):n,deferred:[],calloutList:[],hidden:[]};const u=[],d=n.map((e,n)=>({annotation:e,index:n,priority:rl(e,n,t)})).filter(e=>!!Ur(e.annotation)||(u.push(e.annotation),!1)).sort((e,t)=>t.priority-e.priority),h=a?d.filter(e=>"primary"===String(e.annotation.emphasis??"").toLowerCase()):[],f=new Set(h.map(e=>e.index)),m=d.filter(e=>!f.has(e.index)),p=[...h,...m].slice(0,Math.max(c,l)),g=new Set(p.map(e=>e.index)),y=d.filter(e=>!g.has(e.index)),x=[...u,...p.sort((e,t)=>e.index-t.index).map(e=>il(e.annotation,s))],b=y.sort((e,t)=>e.index-t.index).map(e=>e.annotation),w=Math.max(0,t.maxCalloutItems??6),M=y.filter(e=>!t.calloutFilter||t.calloutFilter(e.annotation,e.index)).map(e=>sl(e.annotation,e.index,e.priority,s)).filter(e=>!!e).slice(0,w),v=new Set(M.map(e=>e.annotation)),k=b.filter(e=>!v.has(e));return{active:r,strategy:i,budget:c,visible:x,deferred:b,calloutList:M,hidden:k}}function cl(e){return{tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:e.targetSize??44,snap:e.snap??"nearestDatum",brushHandleSize:e.targetSize??44,standardControls:e.standardControls??!1}}function ll(e,t){const n=t.targetSize??44,o=[],r=t.standardControls,i=e=>!0===r||"all"===r||r===e||Array.isArray(r)&&r.includes(e);return i("brush")&&o.push("range-inputs","clear-brush"),i("zoom")&&o.push("zoom-buttons","reset-view"),i("legend")&&o.push("legend-chips","show-all-series"),{strategy:`${e}-${t.transformProfile??"overview"}-mobile-recipe`,supportsResponsiveLayout:!0,breakpoints:[320,360,390,430,t.breakpoint??480,768],maxAnnotations:t.maxAnnotations??2,minimumHitTarget:n,summary:t.summary??!0,interaction:{primary:"tap",hoverFallback:"tap-to-lock",targetSize:n,...o.length>0&&{alternatives:o}},labels:{strategy:!1===t.directLabel?"compact":"direct",minFontSize:12}}}function ul(e){return"dense"===e.density?.75:"compact"===e.density?.9:1}function dl(e,t){const n=!1!==t.keepAxes,o=!1===t.directLabel?12:28;return"ordinal"===e?{top:12,right:o,bottom:n?44:12,left:n?48:12}:"geo"===e||"network"===e?{top:12,right:12,bottom:12,left:12}:{top:12,right:o,bottom:n?42:14,left:n?44:14}}function hl(e,t,n,o={}){const r={...n},i={mode:!1===t.mode?void 0:"mobile",...r,margin:dl(e,t),...o},s=Object.fromEntries(Object.entries(r).filter(([,e])=>void 0!==e)),a=Object.fromEntries(Object.entries(i).filter(([,e])=>void 0!==e)),c=ll(e,t),l=cl(t);return{family:e,props:s,responsiveRules:[{id:`${e}-mobile`,description:`Apply Semiotic's mobile ${e} recipe at phone width.`,when:{maxWidth:t.breakpoint??480},transform:{...a,mobileInteraction:l,mobileSemantics:c}}],mobileInteraction:l,mobileSemantics:c}}function fl(e={}){const t=ul(e);return hl("line",e,{showLegend:e.showLegend??!1,directLabel:e.directLabel??!0,lineWidth:"inspect"===e.transformProfile?3:Math.max(1.5,2.5*t),showPoints:"inspect"===e.transformProfile,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function ml(e={}){const t=ul(e);return hl("area",e,{showLegend:e.showLegend??!1,showPoints:!1,areaOpacity:"compare"===e.transformProfile?.55:.42,lineWidth:Math.max(1.25,2*t),autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function pl(e={}){return hl("ordinal",e,{showLegend:e.showLegend??!1,showCategoryTicks:e.keepAxes??!0,sort:"compare"===e.transformProfile?"desc":void 0},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function gl(e={}){const t=ul(e);return hl("scatter",e,{showLegend:e.showLegend??!1,pointRadius:Math.max(4,Math.round((e.targetSize??44)/8*t)),hoverRadius:Math.ceil((e.targetSize??44)/2),pointOpacity:"dense"===e.density?.42:.68,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??1,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function yl(e={}){const t=ul(e);return hl("network",e,{showLegend:e.showLegend??!1,nodeSizeRange:[Math.max(4,Math.round(6*t)),Math.max(12,Math.round((e.targetSize??44)/2*t))],showLabels:"inspect"===e.transformProfile,edgeOpacity:"dense"===e.density?.28:.44})}function xl(e={}){return hl("geo",e,{showLegend:e.showLegend??!1})}function bl(e={}){return hl("small-multiple",e,{mobileColumns:e.mobileColumns??1,tabletColumns:e.tabletColumns??2,chartHeight:e.chartHeight??180,sharedExtent:!0})}function wl(e,t={}){switch(e){case"line":return fl(t);case"area":return ml(t);case"ordinal":return pl(t);case"scatter":return gl(t);case"network":return yl(t);case"geo":return xl(t);case"small-multiple":return bl(t)}}function Ml(e={}){const t=e.targetSize??44,n=e.controls??["range-inputs","chip-filter","clear"];return{mobileInteraction:{enabled:!0,targetSize:t,tapToSelect:!0,tapToLockTooltip:!0,standardControls:"brush"},mobileSemantics:{interaction:{primary:"filter",alternatives:n,summary:e.summary??"Expose brushable ranges through touch-sized controls in addition to drag gestures."}},controls:n}}var vl,kl,$l,Sl,Il=Object.create,Al=Object.defineProperty,Cl=Object.getOwnPropertyDescriptor,Nl=Object.getOwnPropertyNames,jl=Object.getPrototypeOf,Fl=Object.prototype.hasOwnProperty,El=(e,t,n)=>function(){if(n)throw n[0];try{return e&&(t=(0,e[Nl(e)[0]])(e=0)),t}catch(e){throw n=[e],e}},Pl=(e,t)=>{for(var n in t)Al(e,n,{get:t[n],enumerable:!0})},zl=(e,t,n,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of Nl(t))Fl.call(e,r)||r===n||Al(e,r,{get:()=>t[r],enumerable:!(o=Cl(t,r))||o.enumerable});return e},Ll=(e,t,n)=>(n=null!=e?Il(jl(e)):{},zl(!t&&e&&e.__esModule?n:Al(n,"default",{value:e,enumerable:!0}),e)),Ol=El({"src/components/recipes/atlas/entityCounts.ts"(){}}),Tl=El({"src/components/recipes/atlas/ids.ts"(){}}),Rl=El({"src/components/recipes/atlas/ledger.ts"(){Tl()}}),Wl=El({"src/components/recipes/atlas/compare.ts"(){Ol(),Rl()}}),ql=El({"src/components/recipes/atlas/completeness.ts"(){Tl()}}),Dl=El({"src/components/recipes/atlas/directedGraph.ts"(){}}),Bl=El({"src/components/recipes/atlas/rootedForest.ts"(){Dl()}}),Yl=El({"src/components/recipes/atlas/forests.ts"(){Tl(),Bl()}}),Vl=El({"src/components/recipes/atlas/types.ts"(){vl="0.2",kl=["serial-chain","repeated-state-episode","fan-out","fan-in","split-rejoin-diamond","shared-upstream-source","connector-bypass"],$l=["serial-chain","fan-out","fan-in"],Sl=[...$l,"repeated-state-episode"]}}),Gl=El({"src/components/recipes/atlas/motifs.ts"(){Tl(),Vl()}}),_l=El({"src/components/recipes/atlas/prefixForest.ts"(){Tl()}}),Hl=El({"src/components/recipes/atlas/sections.ts"(){Tl()}}),Xl=El({"src/components/recipes/atlas/support.ts"(){}}),Ul=El({"src/components/recipes/atlas/requiredPaths.ts"(){Dl()}}),Kl=El({"src/components/recipes/atlas/validate.ts"(){Tl(),Vl()}}),Zl={};Pl(Zl,{prepareNetworkAtlas:()=>G});var Ql=El({"src/components/recipes/atlas/prepare.ts"(){Wl(),ql(),Yl(),Rl(),Gl(),_l(),Hl(),Xl(),Ul(),Kl()}}),Jl=El({"src/components/recipes/atlas/capsules.ts"(){}}),eu=El({"src/components/recipes/atlas/profile.ts"(){Ol(),Wl()}}),tu={};Pl(tu,{assignedDenominator:()=>u,prepareMotifBraid:()=>Z,ribbonSupportsRoute:()=>Q});var nu,ou,ru,iu,su,au,cu=El({"src/components/recipes/atlas/braid.ts"(){Jl(),Wl(),Xl(),Tl(),eu()}}),lu=El({"src/components/charts/shared/minMax.ts"(){}}),uu=El({"src/components/stream/layouts/forceLayoutNodeSize.ts"(){nu=require("d3-scale"),lu()}}),du=El({"src/components/stream/layouts/forceLayoutEdgeWeight.ts"(){}}),hu=El({"src/components/stream/layouts/forceLayoutWorkerPolicy.ts"(){uu(),du(),ou=4e4}}),fu=El({"src/components/stream/workerModuleUrl.ts"(){}}),mu=El({"src/components/stream/moduleWorkerSession.ts"(){ru=class{constructor(e){this.nextRequestId=1,this.pending=/* @__PURE__ */new Map,this.dead=!1,this.failure=null,this.options=e,this.worker=e.createWorker(),this.worker.onmessage=e=>{if(this.dead)return;let t;try{t=this.options.parseMessage(e.data)}catch(e){return void this.fail(e instanceof Error?e:new Error(String(e)))}const n=t.requestId,o=null!=n?this.pending.get(n):this.pending.values().next().value;if(o){if(null!=n)this.pending.delete(n);else{for(const e of this.pending.values())e!==o&&(e.cleanup(),e.reject(new Error(`${this.options.name} worker response missing requestId`)));this.pending.clear()}o.cleanup(),t.ok?o.resolve(t.payload):o.reject(t.error)}},this.worker.onmessageerror=()=>{this.fail(new Error(`${this.options.name} worker response could not be deserialized`))},this.worker.onerror=e=>{this.fail(new Error(e.message||`${this.options.name} worker failed`))}}get isDead(){return this.dead}fail(e){this.dead||(this.failure=e,this.rejectAll(e),this.terminate())}request(e,t){if(this.dead)return Promise.reject(new Error(`${this.options.name} worker session is closed`));if(t?.aborted)return Promise.reject(ae(this.options.name));const n=this.nextRequestId;this.nextRequestId+=1;const o=this.options.encodeRequest?.(n,e)??{requestId:n,request:e};return new Promise((e,r)=>{const i=()=>{const e=1===this.pending.size;this.pending.delete(n),t?.removeEventListener("abort",i),r(ae(this.options.name)),this.options.terminateOnAbort&&e&&this.terminate()},s=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:s,reject:r,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(o)}catch(e){this.pending.delete(n),s(),r(e instanceof Error?e:new Error(String(e)))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(new Error(`${this.options.name} worker terminated`)),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}}}}),pu={};Pl(pu,{DEFAULT_FORCE_WORKER_THRESHOLD:()=>ou,ForceLayoutWorkerSession:()=>su,_resetSharedForceLayoutSessionForTest:()=>he,canUseForceWorker:()=>re,createForceLayoutWorker:()=>de,createFrameForceWorkerRequest:()=>ie,runForceLayoutWorker:()=>fe,shouldUseForceWorker:()=>oe});var gu,yu=El({"src/components/stream/layouts/forceLayoutWorkerClient.ts"(){fu(),mu(),hu(),hu(),iu={},su=class{constructor(e=de()){this.session=new ru({name:"Force layout",createWorker:()=>e,terminateOnAbort:!0,parseMessage:e=>{const t=e,{requestId:n,error:o}=le(t);if(o)return{requestId:n,ok:!1,error:ce(o)};if(!t?.positions||"object"!=typeof t.positions||Array.isArray(t.positions)||!Object.values(t.positions).every(e=>e&&Number.isFinite(e.x)&&Number.isFinite(e.y)))throw new Error("Malformed force worker response");return{requestId:n,ok:!0,payload:{positions:t.positions}}}})}get isDead(){return this.session.isDead}get failure(){return this.session.failure}request(e,t){return this.session.request(e,t)}terminate(){this.session.terminate()}},au=/* @__PURE__ */ue(()=>new su)}}),xu={};Pl(xu,{DEFAULT_AREA_PER_ANNOTATION:()=>bh,DEFAULT_GLYPH_ANCHOR:()=>af,DEFAULT_GLYPH_VIEWBOX:()=>sf,DEFAULT_HIT_RADIUS:()=>nf,DEFAULT_ISOMETRIC_SPRITE_SIZES:()=>nd,GRID_FUEL_KEYS:()=>Eh,GRID_FUEL_LABELS:()=>Ph,LayoutCache:()=>Mu,SYMBOL_SEQUENCE:()=>Fu,TAU:()=>rf,absorbRegion:()=>Oa,activeCountOverDomain:()=>Oi,addPoints:()=>Rs,adjacencyFlowLayout:()=>Jd,adjacencyMatrix:()=>Jc,aggregateAdjacencyFlow:()=>yr,aggregateRegionCounts:()=>Ma,allocateCells:()=>Fe,analyzeNetEnsemble:()=>Vo,angleScale:()=>zs,annotationBudget:()=>Qr,annotationDensity:()=>ei,annotationLayout:()=>xi,arcLayout:()=>Kc,arcPath:()=>Zc,arrivalReplay:()=>Hc,axisFixedForceLayout:()=>Dh,axisFixedForcePositions:()=>Xi,balanceSnapshotsToFlows:()=>ze,bandLabel:()=>Ro,betweenness:()=>aa,bfsDistances:()=>ra,bobaLayout:()=>yh,bodyGroupSpec:()=>Ra,boundsOf:()=>Oo,boxEdgeAnchors:()=>Di,buildAdjacency:()=>na,buildTooltipEntries:()=>Zs,bulletLayout:()=>ch,calendarLayout:()=>Ku,capacitatedRegion:()=>za,chargeGateRegion:()=>Fa,circularLayout:()=>Qc,clamp:()=>me,classifyReserve:()=>vi,closeness:()=>ca,clustering:()=>la,collidersFromScales:()=>Bc,comparePhysicsTrace:()=>oc,composePhysicsControllers:()=>yc,computeTransitDiagramPositions:()=>Vn,countPairwiseCrossings:()=>vs,createCapacityQueueController:()=>pc,createDagreFit:()=>Ln,createDependencyGateController:()=>vc,createFlextreeFit:()=>Sn,createLineageDagFit:()=>ao,createPortalController:()=>xc,createProcessJourneyLedger:()=>lc,createServiceLevelController:()=>Mc,createServiceResourcePoolController:()=>bc,cubicPath:()=>Gi,cubicPoint:()=>Yi,cubicTangent:()=>Vi,curvedEdgePath:()=>Wi,cyclicRangeContains:()=>ms,dagreLayout:()=>Nd,degree:()=>oa,demandForecastRows:()=>$i,describePhysicsStageGeography:()=>Lc,diagnoseTokenEncoding:()=>Ze,dimFor:()=>Me,egoNetwork:()=>sa,estimateLabelWidth:()=>Ss,extractTooltipDatum:()=>Ks,fanOutBend:()=>Bi,flextreeLayout:()=>Md,forceFieldRegion:()=>Ta,forceLayout:()=>We,forceLayoutAsync:()=>ha,formatMw:()=>Ei,formatReservePct:()=>Pi,formatTooltipValue:()=>Qs,galtonPegs:()=>Yc,generateTokens:()=>Ue,geoAreaHitTarget:()=>as,geoHitTarget:()=>ss,geographicDotGridLayout:()=>wd,geographicGridLayout:()=>hd,glyphExtent:()=>Vs,glyphFractionClipRect:()=>Gs,glyphPlacement:()=>Ys,gridEventAnnotations:()=>ji,gridifyGeographicPoints:()=>Yt,groupBy:()=>xe,groupCompletionRows:()=>ka,hatchFill:()=>Wo,hitTargetPoint:()=>is,hitTargetRect:()=>cs,hullFromBoxes:()=>To,intervalLanesLayout:()=>Wh,isometricLandmarkLayout:()=>sd,isotypeBoltGlyph:()=>Ru,isotypeBusGlyph:()=>Wu,isotypeChipGlyph:()=>Tu,isotypeGhost:()=>Lu,isotypeInk:()=>Pu,isotypeNetworkGlyphs:()=>Bu,isotypePaper:()=>zu,isotypePersonGlyph:()=>Du,isotypePersonPath:()=>qu,isotypeServerGlyph:()=>Ou,layoutChipStrip:()=>$s,layoutSequence:()=>ks,layoutTokenGrid:()=>Ke,legendGroupsFrom:()=>Hs,legendSwatches:()=>Xs,lineageDagLayout:()=>Td,linearAxis:()=>qo,makeShade:()=>ke,marimekkoLayout:()=>sh,markCallout:()=>Do,matchesHighlight:()=>we,mean:()=>Ce,membraneRegion:()=>ja,mermaidDagLayout:()=>_d,mobileAnnotationStrategy:()=>al,mobileAreaChartRecipe:()=>ml,mobileBrushAlternatives:()=>Ml,mobileChartFamilyRecipe:()=>wl,mobileGeoChartRecipe:()=>xl,mobileLineChartRecipe:()=>fl,mobileNetworkChartRecipe:()=>yl,mobileOrdinalChartRecipe:()=>pl,mobileScatterplotRecipe:()=>gl,mobileSmallMultipleRecipe:()=>bl,motifBraidLayout:()=>Yd,mulberry32:()=>Re,netEnsembleLayout:()=>Zd,networkEdgeHitTarget:()=>us,networkHitTarget:()=>ls,nonNegativeFinite:()=>Ae,normalizePoint:()=>Bs,normalizeScores:()=>ua,normalizeTokenEncoding:()=>Ve,octilinearRoute:()=>Gn,offsetTransitPath:()=>_n,orderByBarycenter:()=>bs,orderByGroupDegree:()=>Uc,orderExactSmall:()=>Ms,orthogonalEdgePath:()=>qi,packBandsBySilhouette:()=>xs,packIntervals:()=>Li,packSpanLevels:()=>Is,packedClusterMatrix:()=>oh,parallelCoordinatesLayout:()=>dh,partitionSharedEdges:()=>js,physicsChargePoint:()=>Pc,physicsDestination:()=>Ec,physicsReferenceEnvelope:()=>Qa,physicsStageColliders:()=>zc,physicsStageGeography:()=>Fc,placeWithMinGap:()=>gs,pointMagnitude:()=>Ds,polarToXY:()=>Es,portalRegion:()=>La,prepareMotifBraid:()=>Mo,prepareNetworkAtlasAsync:()=>wo,pressureFieldRegion:()=>Pa,processChrome:()=>Cc,processJourneyRows:()=>dc,processLaneWalls:()=>Wa,processStageLayout:()=>Ia,processStageRegions:()=>Na,processVolumePolygons:()=>Da,proximityProblem:()=>da,radiusScale:()=>Ls,readField:()=>ge,rectCollide:()=>_i,refineByAdjacentSwaps:()=>ws,regionCountsToProjectionRows:()=>va,reserveAnnotationBands:()=>Ci,reserveClasses:()=>Mi,reserveMarginPct:()=>Si,reserveSeries:()=>Ii,ringArcPath:()=>Os,roundedEnclosure:()=>Lo,roundedTransitPath:()=>Hn,routeSurfaceRegion:()=>Ea,runLengthEncode:()=>of,runs:()=>ds,sampleGeographicDotGrid:()=>dn,scaleArcBand:()=>As,scalePoint:()=>qs,sedimentBake:()=>Gc,selectCyclicRange:()=>ps,selectIsometricLandmarks:()=>Ft,shade:()=>$e,shortestArcDelta:()=>fs,shortestPath:()=>ia,signatureKey:()=>ve,spanArcPath:()=>Cs,spanArcPeakY:()=>Ns,spawnFromTokens:()=>Vc,stackFuelSeries:()=>ki,stageTargetInVolume:()=>qa,subtractPoints:()=>Ws,suggestTokenEncoding:()=>et,summarizeOperatingPoint:()=>Ni,symbolExtent:()=>ot,symbolPathString:()=>tt,symbolRadius:()=>nt,thresholdBandsForReserve:()=>Ai,tightestHours:()=>Fi,tokenLayer:()=>kt,tokenTaskIntentToCapabilityIntents:()=>Je,transitDiagramLayout:()=>Ed,unitize:()=>Oe,unitizeRange:()=>Te,unwrapDatum:()=>ye,updateProcessJourney:()=>uc,waffleLayout:()=>ku,withAlpha:()=>Ne,wordTrailsLayout:()=>ns,wordTrailsProgressiveReveal:()=>ts,wrapValue:()=>hs,xyToAngle:()=>Ps}),module.exports=(gu=xu,zl(Al({},"__esModule",{value:!0}),gu));var bu,wu=require("d3-interpolate"),Mu=class{constructor(e=12){this.maxSize=e,this.store=/* @__PURE__ */new Map}get(e){return this.store.get(e)}set(e,t){this.store.size>=this.maxSize&&this.store.clear(),this.store.set(e,t)}getOrCompute(e,t){const n=this.store.get(e);if(void 0!==n)return n;const o=t();return this.set(e,o),o}clear(){this.store.clear()}get size(){return this.store.size}},vu=require("react"),ku=e=>{const t=e.config,n=t.rows??10,o=t.columns??10,r=t.gutter??2,{plot:i}=e.dimensions;if(i.width<=0||i.height<=0)return{nodes:[]};const s=()=>({nodes:[],overlays:je(i,0,e.data.length,"rows","The grid needs positive integer dimensions and enough space for its gutters.",{force:!0})}),a=n*o;if(!Number.isSafeInteger(n)||!Number.isSafeInteger(o)||!Number.isSafeInteger(a)||n<=0||o<=0||!Number.isFinite(r)||r<0)return s();const c=(i.width-r*(o-1))/o;if(c<=0||i.height<=r*(n-1))return s();const l=null==t.categoryAccessor?()=>"_default":pe(t.categoryAccessor),u=null==t.valueAccessor?()=>1:pe(t.valueAccessor),d=/* @__PURE__ */new Map;for(const t of e.data){const e=String(l(t)),n=Ae(Number(u(t)));d.set(e,(d.get(e)??0)+n)}const h=Array.from(d.values()).reduce((e,t)=>e+t,0);if(!(h>0&&Number.isFinite(h)))return{nodes:[],overlays:je(i,0,d.size,"categories","Category values must have a finite positive total.")};const f=[.../* @__PURE__ */new Set([...t.categoryOrder??[],...d.keys()])].filter(e=>d.has(e)),m=Ee(f.map(e=>({key:e,weight:d.get(e)??0})),a,void 0,!0),p=m.filter(e=>e.cells>0).length,g=je(i,p,f.length,"categories","Zero-valued categories and categories rounded to zero cells are omitted."),y=(i.height-(g?18:0)-r*(n-1))/n;if(y<=0)return s();const x="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",b="string"==typeof t.valueAccessor?t.valueAccessor:"value",w=(e,t,n)=>be(o=>{o("category",e),o("value",d.get(e)??0),o("share",(d.get(e)??0)/h),"category"!==x&&o(x,e),"value"!==b&&o(b,d.get(e)??0),o("cells",n),o("_waffleCategory",e),o("_waffleIndex",t)}),M=[];let v=0;for(const t of m){const s=e.resolveColor(t.key);for(let e=0;e<t.cells;e++){const a=v%o,l=n-1-Math.floor(v/o);M.push({type:"rect",x:i.x+a*(c+r),y:i.y+l*(y+r),w:c,h:y,style:{fill:s,stroke:"none"},datum:w(t.key,v,t.cells),group:t.key,_transitionKey:`waffle-${t.key}-${e}`}),v++}}return{nodes:M,overlays:g}},$u=1e-6,Su=require("d3-force"),Iu=1e3,Au=80,Cu=100,Nu=require("d3-shape"),ju={circle:Nu.symbolCircle,square:Nu.symbolSquare,triangle:Nu.symbolTriangle,diamond:Nu.symbolDiamond,star:Nu.symbolStar,cross:Nu.symbolCross,wye:Nu.symbolWye},Fu=["circle","triangle","diamond","star","square","chevron","cross","wye"],Eu=/* @__PURE__ */new Map,Pu="#334155",zu="#f8fafc",Lu="#cbd5e1",Ou={viewBox:[40,40],anchor:[.5,1],parts:[{d:"M8 3h24v34H8z",fill:"color"},{d:"M12 9h16v5H12zM12 18h16v5H12zM12 27h16v5H12z",fill:"accent"},{d:"M23.8 11.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 20.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 29.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0",fill:"color"}]},Tu={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M10 8h20a2 2 0 0 1 2 2v20a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2z",fill:"color"},{d:"M15 15h10v10H15z",fill:"accent"},{d:"M7 2v6M14 2v6M21 2v6M28 2v6M7 32v6M14 32v6M21 32v6M28 32v6M2 7h6M2 14h6M2 21h6M2 28h6M32 7h6M32 14h6M32 21h6M32 28h6",fill:"none",stroke:"color",strokeWidth:3}]},Ru={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M23 1L7 23h10l-3 16 19-25H22z",fill:"color"}]},Wu={viewBox:[48,40],anchor:[.5,.78],parts:[{d:"M7 12c0-4 3-7 7-7h20c4 0 7 3 7 7v15H7z",fill:"color"},{d:"M11 15h26v8H11z",fill:"accent",opacity:.9},{d:"M12 27h7v4h-7zM29 27h7v4h-7z",fill:"accent",opacity:.95},{d:"M12 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0M28 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0",fill:"color",stroke:"accent",strokeWidth:1.8},{d:"M5 13h4v8H5zM39 13h4v8h-4z",fill:"color"}]},qu="M 9.12,3.34 C 8.28,3.29 7.44,3.40 6.64,3.69 4.17,3.63 1.97,5.37 0.91,7.51 -1.32,11.80 2.55,17.76 8.19,16.55 11.62,16.13 15.55,14.04 16.17,10.33 16.38,6.53 12.77,3.52 9.12,3.34 Z M 9.35,19.86 C 8.89,19.84 8.41,19.92 7.92,20.11 5.12,21.55 3.72,24.68 2.79,27.54 2.32,29.86 0.87,32.04 1.36,34.49 1.63,37.60 8.04,38.95 8.04,38.95 8.04,38.95 14.67,39.65 16.50,36.33 17.16,31.95 16.34,27.23 14.01,23.42 13.07,21.69 11.36,19.92 9.35,19.86 Z",Du={viewBox:[18,40],anchor:[.5,1],parts:[{d:qu,fill:"color",stroke:"color",strokeWidth:1.4}]},Bu={server:Ou,chip:Tu,bolt:Ru,bus:Wu,person:Du},Yu="var(--semiotic-primary, #4e79a7)",Vu="var(--semiotic-border, #d1d5db)",Gu="var(--semiotic-secondary, #9ca3af)",_u="var(--semiotic-bg, #ffffff)",Hu=/* @__PURE__ */new Set(Fu),Xu=require("d3-interpolate"),Uu=864e5,Ku=e=>{const t=e.config,{plot:n}=e.dimensions;if(n.width<=0||n.height<=0)return{nodes:[]};const o=e=>{const n="function"==typeof t.dateAccessor?t.dateAccessor(e):e[t.dateAccessor];return n instanceof Date?n:new Date(n)},r=e=>{const n="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor];return Number(n)},i=/* @__PURE__ */new Map;let s=null;for(const t of e.data){const e=o(t);if(!isFinite(e.getTime()))continue;null==s&&(s=e.getUTCFullYear());const n=$t(e),a=r(t);i.set(n,(i.get(n)??0)+(Number.isFinite(a)?a:0))}const a=t.year??s??/* @__PURE__ */(new Date).getUTCFullYear();let c=1/0,l=-1/0;for(const e of i.values())e<c&&(c=e),e>l&&(l=e);c===1/0&&(c=0,l=0);const[u,d]=t.colorRamp??[e.theme.semantic.surface??"#ebedf0",e.theme.semantic.primary??"#216e39"],h=e=>{if(l===c)return u;const t=(e-c)/(l-c);return(0,Xu.interpolateRgb)(u,d)(t)},f=t.gutter??2,m=t.labelInset??0,p=n.width-m,g=n.height,y=Math.min((p-53*f)/54,(g-6*f)/7);if(y<=0)return{nodes:[]};const x=new Date(Date.UTC(a,0,1)),b=x.getUTCDay(),w=new Date(x.getTime()-b*Uu),M=[];for(let e=0;e<54;e++)for(let t=0;t<7;t++){const o=new Date(w.getTime()+(7*e+t)*Uu);if(o.getUTCFullYear()!==a)continue;const r=$t(o),s=i.get(r),c=null==s?u:h(s);M.push({type:"rect",x:n.x+m+e*(y+f),y:n.y+t*(y+f),w:y,h:y,style:{fill:c,stroke:"none"},datum:{date:o,value:s??0}})}return{nodes:M}},Zu=["#739b58","#83a964","#668d52","#8baa68"],Qu=/* @__PURE__ */new Set(["city","culture","monument","faith","nature","knowledge","defense","arena","transport"]),Ju=Ll(require("react")),ed=(require("react/jsx-runtime"),{isActive:!1,predicate:()=>!0}),td=require("react/jsx-runtime"),nd={resource:32,city:64},od={land:"#78985c",ocean:"#4d8192",forest:"#4f7c4b",grassland:"#8eaa68",cropland:"#a6a568",wetland:"#668f79",urban:"#8d8a72",scrub:"#9b9665",bare:"#aa906a",snow:"#d8ddcf"},rd={land:"Open land",ocean:"Open ocean",forest:"Forest",grassland:"Grassland",cropland:"Cropland",wetland:"Wetland",urban:"Urban district",scrub:"Scrubland",bare:"Bare ground",snow:"Snow cover"},id=/* @__PURE__ */new Set(["land","ocean","forest","grassland","cropland","wetland","urban","scrub","bare","snow"]),sd=e=>{const t=Nt(e.config.gridSize),n=Math.max(20,e.config.tileWidth??80),o=Math.max(10,e.config.tileHeight??40),r=e.config.terrainColors?.length?e.config.terrainColors:Zu,i=t*o,s=e.dimensions.width/2,a=(e.dimensions.height-i)/2+o/2,c=Ft(e.points,e.config).map(e=>({...e,x:s+(e.column-e.row)*(n/2),y:a+(e.column+e.row)*(o/2)}));return{nodes:c.map(t=>{const i=Ot(e.config.terrainByCell,t.id),s="city"===t.landmark?.kind?"urban":i?.kind??"land",a=i?.fill??zt(e.config.terrainPalette,s)??zt(od,s)??od.land,c=t.landmark?{...t.landmark,gridRow:t.row,gridColumn:t.column,cellId:t.id,terrainKind:s,terrainCoverage:i?.coverage,features:t.landmarks,featureCount:t.landmarks.length}:{id:t.id,name:(l=s,zt(rd,l)??rd.land),kind:"terrain",terrainKind:s,terrainCoverage:i?.coverage,gridRow:t.row,gridColumn:t.column,cellId:t.id,features:[],featureCount:0};var l,u,d,h,f;return{type:"geoarea",pathData:(u=t.x,d=t.y,h=n,f=o,[`M${u},${d-f/2}`,`L${u+h/2},${d}`,`L${u},${d+f/2}`,`L${u-h/2},${d}`,"Z"].join("")),centroid:[t.x,t.y],bounds:[[t.x-n/2,t.y-o/2],[t.x+n/2,t.y+o/2]],screenArea:n*o/2,style:{fill:i||"urban"===s?a:r[t.terrainIndex%r.length],stroke:"ocean"===s?"#315d6c":e.config.tileStroke??"#314934",strokeWidth:1},datum:c,group:t.landmark?.kind??s,interactive:!0}}),overlays:/* @__PURE__ */ /* @__PURE__ */(0,td.jsx)(Tt,{tiles:c,tileWidth:n,tileHeight:o,sprites:e.config.sprites,resourceSize:e.config.resourceSpriteSize??nd.resource,citySize:e.config.citySpriteSize??nd.city,showCityLabel:!1!==e.config.showCityLabel}),restyle:(e,t)=>t?.isActive&&e.datum&&"terrain"!==e.datum.kind?{fillOpacity:t.predicate(e.datum)?1:.28}:{fillOpacity:1}}},ad={city:["..1111..","..1221..",".111111.",".133331.","11111111","13311331","14411441","11111111"],culture:["..1111..",".122221.","11111111",".133331.",".133331.",".133331.","11111111",".444444."],monument:["...11...","..1221..","..1221..","..1331..",".113311.",".133331.","11111111",".444444."],faith:["...11...","...11...","..1111..","...11...","..1221..",".133331.","11111111",".444444."],nature:["...11...","..1221..",".122221.","12222221",".133331.","...11...","..1441..",".144441."],knowledge:[".111111.","12211221","12211221","13311331","13311331","13311331","11111111",".444444."],defense:["11.11.11","11111111","12222221","12211221","13311331","13333331","11111111",".444444."],arena:["..1111..",".122221.","12333321","12344321","12344321","12333321",".122221.","..1111.."],transport:["...11...","..1221..",".122221.","11111111","..1331..","..1331..",".114411.","11444411"]},cd={city:{1:"#29364a",2:"#d8b45b",3:"#b7693c",4:"#6d9fc5"},culture:{1:"#29364a",2:"#d5c9a3",3:"#9c6fb2",4:"#ece3c4"},monument:{1:"#29364a",2:"#d8cba8",3:"#9c8f79",4:"#ece3c4"},faith:{1:"#29364a",2:"#d9c36d",3:"#a877a5",4:"#ece3c4"},nature:{1:"#29364a",2:"#4f8a4e",3:"#79aa56",4:"#79583a"},knowledge:{1:"#29364a",2:"#d5c9a3",3:"#4f7da0",4:"#ece3c4"},defense:{1:"#29364a",2:"#a6a298",3:"#777b7f",4:"#d5c9a3"},arena:{1:"#29364a",2:"#cb8056",3:"#d8cba8",4:"#6d9fc5"},transport:{1:"#29364a",2:"#d8b45b",3:"#6d9fc5",4:"#ece3c4"}},ld=require("react/jsx-runtime"),ud=.72,dd=1.8,hd=e=>{const t=e.config,n=t.source??"auto",o="areas"===n||"auto"===n&&e.areas.length>0,r=(o?Xt(e):e.points.map((e,t)=>({datum:e,x:t,y:t}))).filter((e,n)=>!t.filter||t.filter(e.datum,n)),i=Kt(r.map(e=>e.datum),t),s=o?r:Ut({...e,points:r.map(e=>e.datum)}),a=i??Yt(s,{columns:t.columns,rows:t.rows,occupancy:t.occupancy,aspectRatio:e.dimensions.width/Math.max(1,e.dimensions.height)});if(0===a.length)return{nodes:[]};const c=Dt(a.map(e=>e.row)),l=Dt(a.map(e=>e.column)),u=Math.max(1,Math.round(c[1]-c[0])+1),d=Math.max(1,Math.round(l[1]-l[0])+1),h=Math.max(0,t.layoutPadding??8),f=Math.max(1,e.dimensions.width-2*h),m=Math.max(1,e.dimensions.height-2*h),p=f/d,g=m/u,y=p*d,x=g*u,b=(e.dimensions.width-y)/2,w=(e.dimensions.height-x)/2,M=me(t.cellPadding??.12,0,.8),v=Math.max(1,.5*Math.min(p,g)*(1-M)),k=t.sizeAccessor?a.map(e=>Number(Vt(e.datum,t.sizeAccessor))):[],$=t.sizeDomain??Dt(k),S=t.sizeRange??[.36,1],I=me(Math.min(S[0],S[1]),.05,1),A=me(Math.max(S[0],S[1]),I,1),C=a.map((n,o)=>{const r={...n.datum,gridRow:n.row,gridColumn:n.column},i=String(Vt(r,t.idAccessor,["id","key","name"])??`grid-${o}`),s=String(Vt(r,t.labelAccessor,["abbr","code","label","name","id"])??i),a=Math.max(1,t.maxLabelLength??4),u=s.length>a?s.slice(0,a):s,d=Vt(r,t.categoryAccessor),h=null==d?void 0:String(d),f=Vt(r,t.fillAccessor),m=null!=f?String(f):h?e.resolveColor(h):e.theme.categorical[0]??"#4f86c6",y=t.sizeAccessor?Number(Vt(r,t.sizeAccessor)):NaN,x=t.sizeAccessor&&Number.isFinite(y)?Math.sqrt(me(Bt(y,$),0,1)):1,M=v*(I+x*(A-I)),k="function"==typeof t.markStyle?t.markStyle(r,o):t.markStyle;return{datum:r,id:i,label:u,category:h,row:n.row,column:n.column,x:b+(n.column-l[0]+.5)*p,y:w+(n.row-c[0]+.5)*g,radius:M,style:{fill:m,fillOpacity:.94,stroke:"rgba(255,255,255,0.9)",strokeWidth:1,...k}}}),N=t.shape??"circle";return{nodes:C.map(e=>{return"circle"===N?{type:"point",x:e.x,y:e.y,r:e.radius,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},pointId:e.id,_transitionKey:e.id}:{type:"geoarea",pathData:"hexagon"===N?Ht(e.x,e.y,e.radius):(t=e.x,n=e.y,o=e.radius,_t([[t-o,n-o],[t+o,n-o],[t+o,n+o],[t-o,n+o]])),centroid:[e.x,e.y],bounds:[[e.x-e.radius,e.y-e.radius],[e.x+e.radius,e.y+e.radius]],screenArea:"hexagon"===N?3*Math.sqrt(3)*e.radius*e.radius/2:(2*e.radius)**2,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},group:e.category,interactive:!0};var t,n,o}),overlays:!1===t.showLabels?null:/* @__PURE__ */ /* @__PURE__ */(0,ld.jsx)(Zt,{marks:C,color:t.labelColor??"#ffffff",fontSize:t.labelFontSize??me(.23*Math.min(p,g),7,14),fontFamily:t.labelFontFamily,fontWeight:t.labelFontWeight??700}),restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.18}:{opacity:1}}},fd=require("react/jsx-runtime"),md=10,pd=25e3,gd=/* @__PURE__ */new WeakMap,yd=/* @__PURE__ */new WeakMap,xd=/* @__PURE__ */new WeakMap,bd=1,wd=e=>{const t=xn(e),n=e.config,o=n.shape??"circle",r=Math.max(.5,en(n.dotRadius)??t.cellSize*me(n.radiusRatio??.24,.05,.5)),i=n.gridOrigin?.[0]??0,s=n.gridOrigin?.[1]??0;return{nodes:t.dots.map((a,c)=>{const l=i+(a.gridColumn+.5)*t.cellSize,u=s+(a.gridRow+.5)*t.cellSize,d=tn(a,n.categoryAccessor),h=tn(a,n.fillAccessor),f={fill:null!=h?String(h):null!=d?e.resolveColor(String(d)):e.theme.categorical[0]??"#4f86c6",fillOpacity:.92,strokeWidth:0,..."function"==typeof n.markStyle?n.markStyle(a,c):n.markStyle},m=`dot-${a.gridRow}-${a.gridColumn}`;return"circle"===o?{type:"point",x:l,y:u,r:r,style:f,datum:a,interactive:!1,pointId:m,_transitionKey:m}:{type:"geoarea",pathData:"hexagon"===o?Mn(l,u,r):wn(l,u,r),centroid:[l,u],bounds:[[l-r,u-r],[l+r,u+r]],screenArea:"hexagon"===o?3*Math.sqrt(3)*r*r/2:(2*r)**2,style:f,datum:a,group:a.featureId,interactive:!1}}),overlays:n.showOutline?/* @__PURE__ */ /* @__PURE__ */(0,fd.jsx)("g",{"aria-hidden":"true",pointerEvents:"none",children:t.features.map((t,o)=>{const r=e.scales.geoPath(t);return r?/* @__PURE__ */ /* @__PURE__ */(0,fd.jsx)("path",{d:r,fill:"none",stroke:n.outlineStyle?.stroke??"currentColor",strokeOpacity:n.outlineStyle?.opacity??n.outlineStyle?.fillOpacity??.22,strokeWidth:n.outlineStyle?.strokeWidth??.7,strokeDasharray:n.outlineStyle?.strokeDasharray,strokeLinecap:n.outlineStyle?.strokeLinecap,vectorEffect:"non-scaling-stroke"},on(t,o)):null})}):null,restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.14}:{opacity:1}}},Md=e=>{const t=e.config??{},n=t.orientation??"vertical",o=t.edgeCurve??"curved",{positions:r,sceneNodes:i,labels:s}=$n(e,{...t,nodeWidth:t.nodeWidth??80,nodeHeight:t.nodeHeight??30},`var(--semiotic-surface, ${e.theme.semantic.surface??"#fff"})`),a=[];for(const t of e.edges){const i="string"==typeof t.source?t.source:t.source.id,s="string"==typeof t.target?t.target:t.target.id,c=r.get(i),l=r.get(s);if(!c||!l)continue;const u="vertical"===n?{x:c.x,y:c.y+c.h/2}:{x:c.x+c.w/2,y:c.y},d="vertical"===n?{x:l.x,y:l.y-l.h/2}:{x:l.x-l.w/2,y:l.y};if("line"===o)a.push({type:"line",x1:u.x,y1:u.y,x2:d.x,y2:d.y,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1},datum:t.data??t});else{const o=(u.y+d.y)/2,r=(u.x+d.x)/2,i="vertical"===n?`M${u.x},${u.y} C${u.x},${o} ${d.x},${o} ${d.x},${d.y}`:`M${u.x},${u.y} C${r},${u.y} ${r},${d.y} ${d.x},${d.y}`;a.push({type:"curved",pathD:i,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1,fill:"none"},datum:t.data??t})}}return{sceneNodes:i,sceneEdges:a,labels:s}},vd=require("react"),kd=require("react"),$d=Ll(require("react")),Sd=(require("react/jsx-runtime"),{type:"flat",matrix:[1,0,0,1,0,0],lift:0,scale:1,bounds:null,project:(e,t)=>[e,t],unproject:(e,t)=>[e,t],depth:(e,t)=>t,groundTransform:"matrix(1 0 0 1 0 0)",billboardTransform:(e,t)=>`translate(${e},${t})`}),Id=/* @__PURE__ */Symbol.for("semiotic.networkPerspectiveContext"),Ad=require("react/jsx-runtime"),Cd=e=>Math.round(100*e)/100,Nd=e=>{const t=e.config??{},n=t.edgeStyle??"polyline",o=new Map(e.edges.map(e=>[e,zn(e)])),{positions:r,sceneNodes:i,labels:s,project:a}=$n(e,{...t,nodeWidth:t.nodeWidth??100,nodeHeight:t.nodeHeight??36,labelAccessor:t.labelAccessor??"label"},`var(--semiotic-border, ${e.theme.semantic.border??"#888"})`,[...o.values()].flat()),c=t.edgeStroke??`var(--semiotic-border, ${e.theme.semantic.border??"#666"})`;for(let e=0;e<s.length;e++){const t=s[e],n=r.get(i[e].id);if(!n)continue;const o=Math.max(1,Math.floor(n.w/(.6*(t.fontSize??11))-2));t.text.length>o&&(t.text=t.text.slice(0,o-1)+"…")}const l=[],u=[];for(const t of e.edges){const e="string"==typeof t.source?t.source:t.source.id,i="string"==typeof t.target?t.target:t.target.id,s=r.get(e),d=r.get(i);if(!s||!d)continue;const h=o.get(t).map(a);if(h.length<2){const e=In(s,d),n=In(d,s);l.push(An(l.length,n,e,c,Math.min(7,d.w/4,d.h/3))),u.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:c,strokeWidth:1},datum:t.data??t});continue}const f=h[h.length-1],m=h.slice(0,-1).reverse().find(e=>e.x!==f.x||e.y!==f.y);if(m&&l.push(An(l.length,f,m,c,Math.min(7,d.w/4,d.h/3))),"smooth"===n&&h.length>=3){let e=`M${h[0].x},${h[0].y}`;for(let t=1;t<h.length-1;t++){const n=(h[t].x+h[t+1].x)/2,o=(h[t].y+h[t+1].y)/2;e+=` Q${h[t].x},${h[t].y} ${n},${o}`}const n=h[h.length-1];e+=` T${n.x},${n.y}`,u.push({type:"curved",pathD:e,style:{stroke:c,strokeWidth:1,fill:"none"},datum:t.data??t})}else{const e="M"+h.map(e=>`${e.x},${e.y}`).join(" L ");u.push({type:"curved",pathD:e,style:{stroke:c,strokeWidth:1,fill:"none"},datum:t.data??t})}}return{sceneNodes:i,sceneEdges:u,labels:s,overlays:l.length?(0,vd.createElement)("g",null,(0,vd.createElement)(En,{z:"top"},l)):null,perspective:"manual"}},jd=require("react"),Fd=e=>"number"==typeof e&&Number.isFinite(e),Ed=e=>{const t=e.config??{},n=t.mode??"primary",o=t.dimOpacity??.14,r=(t,n=e.selection)=>n?.isActive&&!n.predicate(t)?o:1,i=e.nodes.map(e=>({id:e.id,data:ye(e),wrapper:e})).sort((e,t)=>e.id.localeCompare(t.id)),s=e.edges.map(e=>({source:Un(e.source),target:Un(e.target),data:ye(e),wrapper:e})).sort((e,t)=>e.source.localeCompare(t.source)||e.target.localeCompare(t.target)),a=Vn(i,s,e.dimensions.plot,t),c="source-rooted"===t.lineMode?Jn(i,s,t,e.resolveColor):void 0,l=to(s,t,c),u=new Map(i.map(e=>[e.id,/* @__PURE__ */new Set])),d=/* @__PURE__ */new Map;if(c)for(const[e,t]of c.byNode)for(const n of t)u.get(e)?.add(n.id),n.color&&d.set(n.id,n.color);const h=Math.max(1,t.lineWidth??("primary"===n?6:"compact"===n?3.5:2)),f=Math.max(0,t.lineGap??("primary"===n?2:"compact"===n?1:.5)),m=/* @__PURE__ */new Map,p=[];for(const n of l){const o=a.positions.get(n.source),i=a.positions.get(n.target);if(!o||!i)continue;const s=oo(n,t),c=(s.length-1)/2*(h+f)+h/2;for(const e of[n.source,n.target])m.set(e,Math.max(m.get(e)??0,c));s.forEach((c,l)=>{u.get(n.source)?.add(c.descriptor.id),u.get(n.target)?.add(c.descriptor.id);const m=ro(c.edge,a,t,c.edge.source!==n.source),g=_n(m?[o,...m,i]:Gn(o,i),(l-(s.length-1)/2)*(h+f)),y=io(c.edge,c.descriptor),x=eo(c.descriptor,c.edge,t,e.resolveColor);d.has(c.descriptor.id)||d.set(c.descriptor.id,x),p.push({type:"curved",id:`${n.key}:${c.descriptor.id}`,label:`${c.descriptor.label??c.descriptor.id}: ${c.edge.source} to ${c.edge.target}`,pathD:Hn(g,t.cornerRadius??10),style:{fill:"none",stroke:x,strokeWidth:h,strokeLinecap:"round",opacity:r(y)},datum:y,accessibleDatum:y,accessibility:{label:`${c.descriptor.label??c.descriptor.id}, ${c.edge.source} to ${c.edge.target}`,tableFields:{line:c.descriptor.label??c.descriptor.id,source:c.edge.source,target:c.edge.target}}})})}const g=/* @__PURE__ */new Map,y=[],x=[],b=e=>String(Xn(e,t)||e.id);if("minimap"===n){const n=/* @__PURE__ */new Map;for(const e of i){const t=a.positions.get(e.id);if(!t)continue;const o=`${t.x}\0${t.y}`;let r=n.get(o);r||(r={x:t.x,y:t.y,nodes:[],lineIds:/* @__PURE__ */new Set,bundleRadius:0},n.set(o,r)),r.nodes.push(e);for(const t of u.get(e.id)??[])r.lineIds.add(t);r.bundleRadius=Math.max(r.bundleRadius,m.get(e.id)??0)}const o=[...n.values()].sort((e,t)=>e.x-t.x||e.y-t.y||e.nodes[0].id.localeCompare(t.nodes[0].id));for(const n of o){const o=no(n.lineIds,t),i=o.length>1||n.nodes.length>1||n.nodes.some(e=>!0===e.data.interchange||!0===e.data.transfer),s=i?t.interchangeRadius??Math.max(5,n.bundleRadius):t.stationRadius??Math.max(3.5,n.bundleRadius);for(const e of n.nodes)g.set(e.id,s);const a=n.nodes.map(b).join(" / "),c=n.nodes.map(e=>e.id).join("--"),l=1===n.nodes.length?n.nodes[0].data:be(e=>{e("id",c),e("label",a),e("stationIds",n.nodes.map(e=>e.id)),e("stations",n.nodes.map(e=>e.data)),e("lineIds",o),e("interchange",i)}),u={label:`${a}${i?", interchange":""}`,tableFields:{station:a,lines:o.join(", ")}};o.length<=1?y.push({type:"circle",cx:n.x,cy:n.y,r:s,style:{fill:(o[0]&&d.get(o[0]))??t.stationFill??"var(--semiotic-bg, white)",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:r(l)},datum:l,accessibleDatum:l,accessibility:u,id:c,label:a}):(o.forEach((t,i)=>{const a=-Math.PI/2+i/o.length*Math.PI*2,u=-Math.PI/2+(i+1)/o.length*Math.PI*2,h={type:"arc",cx:n.x,cy:n.y,innerR:0,outerR:s,startAngle:a,endAngle:u,style:{fill:d.get(t)??e.resolveColor(t),stroke:"none",opacity:r(l)},datum:null,id:`${c}:${t}`};y.push(h)}),y.push({type:"circle",cx:n.x,cy:n.y,r:s,style:{fill:"transparent",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:r(l)},datum:l,accessibleDatum:l,accessibility:u,id:c,label:a}))}}else for(const e of i){const o=a.positions.get(e.id);if(!o)continue;const i=no(u.get(e.id)??[],t),s=i.length>1||!0===e.data.interchange||!0===e.data.transfer,c=s?t.interchangeRadius??Math.max("primary"===n?7:5,m.get(e.id)??0):t.stationRadius??("primary"===n?4:2.75);g.set(e.id,c);const l=b(e),d=null!=t.renderStation;if(y.push({type:"circle",cx:o.x,cy:o.y,r:c,style:d?{fill:"transparent",stroke:"transparent"}:{fill:t.stationFill??"var(--semiotic-bg, white)",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:s?"primary"===n?3:2:1.5,opacity:r(e.data)},datum:e.data,accessibleDatum:e.data,accessibility:{label:`${l}${s?", interchange":""}`,tableFields:{station:l,lines:i.join(", ")}},id:e.id,label:l}),t.renderStation){const a=t.renderStation({station:e.data,x:o.x,y:o.y,radius:c,lineIds:i,interchange:s,mode:n});null!=a&&x.push((0,jd.createElement)(Pn,{key:e.id,x:o.x,y:o.y},(0,jd.createElement)("g",{opacity:r(e.data),style:{pointerEvents:"none"}},a)))}}const w=x.length>0?(0,jd.createElement)("g",{className:"transit-diagram-stations"},...x):void 0,M={sceneEdges:p,sceneNodes:y,overlays:w,perspective:"manual",labels:so(i,a.positions,u,g,e.dimensions.plot,"primary"===n?t:{...t,showLabels:!1})};if(x.length>0||"minimap"===n)return M;const v=(e,t)=>({opacity:r(e.datum,t)});return{...M,restyle:v,restyleEdge:v}},Pd=require("react/jsx-runtime"),zd=require("react/jsx-runtime"),Ld={"topic-source":"#1f7a8c","topic-sink":"#b4451f","topic-bridge":"#4b5a82",processor:"#34344a",unknown:"#5a5a6a"},Od={internal:"var(--semiotic-border, #6b6b7d)","cross-subtopology":"var(--semiotic-info, #6a8caf)","topic-bridge":"var(--semiotic-secondary, #8b78c4)",back:"var(--semiotic-danger, #e0556b)"},Td=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.partitionAccessor??"partition",r=t.semanticAccessor??"semantic",i=t.labelAccessor??"label",s=t.storesAccessor??"stores",a=t.backEdgeAccessor??"isBackEdge",c=t.edgeTypeAccessor??"edgeType",l={...Ld,...t.partitionColors},u={...Od,...t.edgeColors},d=t.accentColor??"var(--semiotic-focus, #ffcc33)",h=t.borderColor??"var(--semiotic-border, #555)",f=t.dimOpacity??.14,m=t.edgeOpacity??.5,p=t.edgeWidth??1.25,g=t.backEdgeWidth??t.edgeWidth??1.5,y=!1!==t.showStoreChips,x=t.storeChipColor??"var(--semiotic-info, #6a8caf)",b=t.hullGroupAccessor,w=ao(e.nodes,n,t),{nodeWidth:M,nodeHeight:v,lod:k}=w,$=t.reachableIds?new Set(t.reachableIds):null,S=t.selectedId??null,I=e.selection,A=/* @__PURE__ */new Map,C=/* @__PURE__ */new Map,N=[],j=null==b?null:/* @__PURE__ */new Map,F=[];for(const t of e.nodes){const e=t.id,n=String(ge(t,o,"processor")),a=String(ge(t,r,"processor")),c=String(ge(t,i,e)),u=go(ge(t,s,[])),m=t.data??t,{cx:p,cy:g}=w.nodeBounds(t);if(!Number.isFinite(p)||!Number.isFinite(g))continue;A.set(e,{cx:p,cy:g});const y=$?$.has(e):null,x=I?.isActive?I.predicate(m):null,E=null!==y?!y:null!==x&&!x;C.set(e,E);const P=null!=S&&e===S,z=E&&!P?f:1,L=Object.prototype.hasOwnProperty.call(l,n)?l[n]:l.unknown;if("dot"===k){const t={type:"circle",cx:p,cy:g,r:M/2,style:{fill:L,opacity:z,stroke:P?d:"transparent",strokeWidth:P?2:0},datum:m,id:e,label:c};N.push(t)}else{const t={type:"rect",x:p-M/2,y:g-v/2,w:M,h:v,style:{fill:L,opacity:z,stroke:P?d:h,strokeWidth:P?3:1},datum:m,id:e,label:c};N.push(t),F.push({id:e,cx:p,cy:g,partition:n,semantic:a,label:c,stores:u,opacity:z,selected:P,node:m})}if(j&&null!=b){const n=ge(t,b,null);if(null!=n){const t=String(n),o=j.get(t)??[];o.push({id:e,x:p-M/2,y:g-v/2,w:M,h:v}),j.set(t,o)}}}const E=[],P=[];for(const t of e.edges){const e="string"==typeof t.source?t.source:t.source.id,o="string"==typeof t.target?t.target:t.target.id,r=A.get(e),i=A.get(o);if(!r||!i)continue;const s=Boolean(ge(t,a,null)??r.cx>=i.cx),l=String(ge(t,c,"internal")),d=C.get(e)||C.get(o)?Math.min(m,1.4*f):m,h=s?u.back:Object.prototype.hasOwnProperty.call(u,l)?u[l]:u.internal;let y,x,b;if(s){const t=Math.min(r.cy,i.cy)-v/2-n.y,s=n.y+n.height-Math.max(r.cy,i.cy)-v/2,a=(r.cy+i.cy)/2>n.y+n.height/2?t>8?-1:s>8?1:0:s>8?1:t>8?-1:0,c=Math.max(48,.28*Math.abs(r.cx-i.cx))+v,l=a<0?Math.max(n.y+1,Math.min(r.cy,i.cy)-v/2-c):a>0?Math.min(n.y+n.height-1,Math.max(r.cy,i.cy)+v/2+c):(r.cy+i.cy)/2,u=e===o,d=u?M/4:0,h=u&&"dot"===k?Math.sqrt((v/2)**2-d**2):v/2,f=r.cx-d,m=r.cy+Math.sign(l-r.cy)*h;x={x:i.cx+d,y:i.cy+Math.sign(l-i.cy)*h},b={x:x.x,y:l},y=`M${f},${m} C${f},${l} ${b.x},${b.y} ${x.x},${x.y}`}else{const e=Math.sign(i.cx-r.cx)||1,t=r.cx+e*M/2;x={x:i.cx-e*M/2,y:i.cy};const n=(t+x.x)/2;b={x:n,y:x.y},y=`M${t},${r.cy} C${n},${r.cy} ${n},${x.y} ${x.x},${x.y}`}P.push(An(P.length,x,b,h,Math.min(7,M/4,v/3),d));const w={type:"curved",pathD:y,style:{stroke:h,strokeWidth:s?g:p,fill:"none",opacity:d,...s?{strokeDasharray:"5 4",strokeLinecap:"round"}:{}},datum:t.data??t};E.push(w)}const z=0===F.length&&0===P.length?null:/* @__PURE__ */ /* @__PURE__ */(0,zd.jsxs)("g",{children:[
|
|
145
|
+
/* @__PURE__ */(0,ff.jsx)("title",{children:c}),d.text]})]},e.id)}):null]})}function $c(e){if(null==e){const e=gf.padding;return{top:e,right:e,bottom:e,left:e}}return"number"==typeof e?{top:e,right:e,bottom:e,left:e}:{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Sc(e){if("number"==typeof e){const t=Math.max(1,Math.round(e));return Array.from({length:t},(e,t)=>({id:`bin-${t}`,label:String(t)}))}return 0===e.length?[{id:"bin-0",label:"0"}]:e.map((e,t)=>({id:e.id,label:e.label??e.id??String(t)}))}function Ic(e){const[t,n]=e.size,o=e.flow??gf.flow,r=$c(e.padding),i=Math.max(.05,Math.min(1,e.channelRatio??gf.channelRatio)),s={x:r.left,y:r.top,width:Math.max(1,t-r.left-r.right),height:Math.max(1,n-r.top-r.bottom)},a="down"===o?s.height:s.width,c=a*Math.max(0,e.chargeExtent??gf.chargeExtent),l=a*Math.max(0,e.projectionExtent??gf.projectionExtent),u=a*Math.max(0,e.destinationExtent??gf.destinationExtent),d=Math.max(0,a-c-u-l),h=Sc(e.destinations),f=("down"===o?s.width:s.height)/h.length,m="down"===o?(e,t)=>({x:s.x,y:s.y+e,width:s.width,height:t}):(e,t)=>({x:s.x+e,y:s.y,width:t,height:s.height}),p=m(0,c),g=m(c,d),y=c+d,x=m(y,u),b=m(y+u,l),w=h.map((e,t)=>{const n=t*f,r=f*i,a=(f-r)/2;if("down"===o){const o=s.x+n+a;return{id:e.id,label:e.label,order:t,x:o,y:x.y,width:r,height:x.height,centerX:s.x+(t+.5)*f,centerY:x.y+x.height/2}}const c=s.y+n+a;return{id:e.id,label:e.label,order:t,x:x.x,y:c,width:x.width,height:r,centerX:x.x+x.width/2,centerY:s.y+(t+.5)*f}});return{width:t,height:n,flow:o,charge:p,apparatus:g,destinations:w,projection:b}}function Ac(e,t){return e.destinations.find(e=>e.id===t)}function Cc(e,t,n){const{charge:o,flow:r}=e,i=Math.max(1,n),s=(t%i+.5)/i;return"down"===r?{x:o.x+o.width*s,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height*s}}function Nc(e,t={}){const n=t.thickness??4,o=t.idPrefix??"stage",{destinations:r,flow:i,width:s,height:a}=e,c=[];if(r.length>0){const t=r[0];if("down"===i){const i=t.y+t.height;c.push({id:`${o}-floor`,shape:{type:"segment",x1:e.charge.x,y1:i,x2:e.charge.x+e.charge.width,y2:i,thickness:n}});for(let e=1;e<r.length;e+=1){const s=r[e].centerX-(r[e].centerX-r[e-1].centerX)/2;c.push({id:`${o}-divider-${e}`,shape:{type:"segment",x1:s,y1:t.y,x2:s,y2:i,thickness:n}})}}else{const i=t.x+t.width;c.push({id:`${o}-floor`,shape:{type:"segment",x1:i,y1:e.charge.y,x2:i,y2:e.charge.y+e.charge.height,thickness:n}});for(let e=1;e<r.length;e+=1){const s=r[e].centerY-(r[e].centerY-r[e-1].centerY)/2;c.push({id:`${o}-divider-${e}`,shape:{type:"segment",x1:t.x,y1:s,x2:i,y2:s,thickness:n}})}}}return!1!==t.walls&&c.push({id:`${o}-wall-left`,shape:{type:"segment",x1:1,y1:0,x2:1,y2:a,thickness:n}},{id:`${o}-wall-right`,shape:{type:"segment",x1:s-1,y1:0,x2:s-1,y2:a,thickness:n}}),c}function jc(e,t={}){const n=t.charge??"bodies",o=t.apparatus??"the apparatus",r=t.destination??"destinations",i=e.destinations.length,s="down"===e.flow?"downward":"left to right";return`${n} enter at the ${"down"===e.flow?"top":"left"}, travel ${s} through ${o}, and come to rest in ${i} ${r}: ${e.destinations.map(e=>e.label).join(", ")}.`}function Fc(e){const t="number"==typeof e?e:"string"==typeof e&&e.trim()?Number(e):NaN;return Number.isFinite(t)?t:null}function Ec(e,t,n,o){const r="function"==typeof e?e(t,n):e;return Number.isFinite(r)?Number(r):o}function Pc(e,t,n){return Fc(e[t])??n}function zc(e,t){return"number"==typeof e?e:e?.[t]??0}function Lc(e){const t=e.bandwidth??e.scale.bandwidth?.()??0,n=/* @__PURE__ */new Set;for(const o of e.values){const r=e.scale(o);Number.isFinite(r)&&(n.add(Number(r)),n.add(Number(r)+t))}return Array.from(n).sort((e,t)=>e-t)}function Oc(e){const{band:t,idPrefix:n,plot:o,projection:r}=e,{includeBoundaryWalls:i=!0,includeInteriorWalls:s=!0,wallThickness:a=4}=t,c=Lc(t);if(c.length<2)return[];const l=i?0:1,u=i?c.length-1:c.length-2,d=[];for(let e=l;e<=u;e+=1){if(!s&&e>0&&e<c.length-1)continue;const t=c[e];d.push({id:`${n}-wall-${e}`,shape:"x"===r?{type:"aabb",x:t,y:o.y+o.height/2,width:a,height:o.height}:{type:"aabb",x:o.x+o.width/2,y:t,width:o.width,height:a}})}return d}function Tc(e){const{plot:t,idPrefix:n="physics-scale",bounds:o={},xBins:r,xBands:i,yBands:s}=e,a=[];if(!1!==o&&a.push(...ha(t,{idPrefix:n,...o})),r){const{idPrefix:e,yTop:o,yBottom:i,...s}=r;a.push(...fa({...s,idPrefix:e??`${n}-xbin`,yTop:o??t.y,yBottom:i??t.y+t.height}))}return i&&a.push(...Oc({band:i,idPrefix:i.idPrefix??`${n}-xband`,plot:t,projection:"x"})),s&&a.push(...Oc({band:s,idPrefix:s.idPrefix??`${n}-yband`,plot:t,projection:"y"})),a}function Rc(e){const{plot:t,rows:n,columns:o=n+1,pegRadius:r=3,idPrefix:i="galton-peg",yStart:s=t.y+.18*t.height,yEnd:a=t.y+.58*t.height,stagger:c=!0,restitution:l=.2,friction:u=.04}=e,d=Math.max(0,Math.floor(n)),h=Math.max(1,Math.floor(o));if(0===d)return[];const f=d<=1?0:(a-s)/(d-1),m=t.width/h,p=[];for(let e=0;e<d;e+=1){const n=c&&e%2==1?m/2:0;for(let o=0;o<h;o+=1){const a=t.x+m*(o+.5)+n;a<t.x+r||a>t.x+t.width-r||p.push({id:`${i}-${e}-${o}`,shape:{type:"aabb",x:a,y:s+e*f,width:2*r,height:2*r},restitution:l,friction:u})}}return p}function Wc(e,t={}){const{idPrefix:n="physics-token",radius:o=5,shape:r,mass:i,vx:s,vy:a,spawnAt:c,seed:l=1,jitter:u,datum:d}=t,h=We(l),f=zc(u,"x"),m=zc(u,"y");return e.map((e,l)=>{const u=Ec(t.x,e,l,Pc(e,"x",0)),p=Ec(t.y,e,l,Pc(e,"y",0)),g=Ec(o,e,l,5),y="function"==typeof r?r(e,l):r??{type:"circle",radius:g};return{id:`${n}-${e.index??l}`,x:u+(h()-.5)*f,y:p+(h()-.5)*m,vx:Ec(s,e,l,0),vy:Ec(a,e,l,0),mass:Ec(i,e,l,1),spawnAt:Ec(c,e,l,void 0),shape:y,datum:d?d(e,l):e.datum??e}}).map(e=>{if(Number.isFinite(e.spawnAt))return e;const{spawnAt:t,...n}=e;return n})}function qc(e,t={}){const{idPrefix:n="sediment",collider:o=!0,colliderThickness:r=1,restitution:i=.05,friction:s=.2,...a}=t,c=ca(e,a),l=o?c.filter(e=>e.height>0).map(e=>({id:`${n}-${e.binId}`,shape:{type:"aabb",x:e.x+e.width/2,y:e.y+r/2,width:e.width,height:r},restitution:i,friction:s})):[];return{columns:c,colliders:l}}function Dc(e,t,n){return Fc("function"==typeof n?n(e,t):e[n]??e.datum?.[n])}function Bc(e,t={}){const{timeAccessor:n="arrivalTime",timeScale:o=1,startAt:r=0,rebase:i=!0,sort:s=!0}=t,a=e.map((e,t)=>({spawn:e,time:Dc(e,t,n)??e.spawnAt??t})),c=a.length?Math.min(...a.map(e=>e.time)):0;return{initialSpawns:a.map(({spawn:e,time:t})=>({...e,spawnAt:r+(i?t-c:t)})).sort((e,t)=>s?(e.spawnAt??0)-(t.spawnAt??0):0),initialSpawnPacing:{pacing:"arrival",startAt:r,timeAccessor:"spawnAt",timeScale:o}}}function Yc(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function Vc(e,t,n="group"){const o=Qs(e,t),r=e=>"function"==typeof n?n(e):e[n]??0;return e.slice().sort((e,t)=>{const n=r(e),i=r(t);return n<i?-1:n>i?1:(o[t.id]||0)-(o[e.id]||0)}).map(e=>e.id)}function Gc(e,t={}){const n=t.baseline??.62,o=t.inset??.06,r={},i=e.length;return e.forEach((e,t)=>{Yc(r,e,{x:i>1?o+t/(i-1)*(1-2*o):.5,y:n})}),r}function _c(e,t,n=.55){const o=Math.abs(t.x-e.x),r=(e.x+t.x)/2,i=e.y-o*n;return`M${e.x},${e.y} Q${r},${i} ${t.x},${t.y}`}function Hc(e,t={}){const n=t.radius??.42,o=t.center?.x??.5,r=t.center?.y??.5,i=t.startAngle??0,s={},a=e.length;return e.forEach((e,t)=>{const c=i+t/a*Math.PI*2-Math.PI/2;Yc(s,e,{x:o+Math.cos(c)*n,y:r+Math.sin(c)*n})}),s}function Xc(e,t,n={}){const o=(n.order??Vc(e,t,n.groupAccessor??"group")).slice(),r=new Map(o.map((e,t)=>[e,t])),i=/* @__PURE__ */new Map;for(const e of t){if(!r.has(e.source)||!r.has(e.target)||e.source===e.target)continue;const t=e.source<e.target?`${e.source}${yf}${e.target}`:`${e.target}${yf}${e.source}`;i.set(t,(i.get(t)||0)+(e.value??1))}const s=[];let a=0;for(const[e,t]of i){const[n,o]=e.split(yf),i=r.get(n),c=r.get(o);t>a&&(a=t),s.push({row:i,col:c,source:n,target:o,value:t}),s.push({row:c,col:i,source:o,target:n,value:t})}return{order:o,cells:s,size:o.length,maxValue:a}}function Uc(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function Kc(e){if("string"!=typeof e)return;const t=e.trim();return t.length?t:void 0}function Zc(e,t){const n=Uc(e.note)?e.note:void 0;return t?Kc(e.mobileText)||Kc(e.shortText)||Kc(e.label)||Kc(n?.mobileText)||Kc(n?.shortText)||Kc(n?.label)||Kc(n?.title):Kc(e.label)||Kc(e.mobileText)||Kc(e.shortText)||Kc(n?.label)||Kc(n?.title)}function Qc(e,t,n){if(!n)return;const o="function"==typeof n?n(e,t):e[n];return"number"==typeof o&&Number.isFinite(o)?o:void 0}function Jc(e,t,n){const o=Qc(e,t,n.priorityAccessor);if(void 0!==o)return o;let r=1e3-t;const i=String(e.emphasis??"").toLowerCase();"primary"!==i&&"critical"!==i||(r+=1e4),"secondary"===i&&(r-=1e3),"high"===e.priority&&(r+=5e3),"low"===e.priority&&(r-=1500),"number"==typeof e.priority&&(r+=100*e.priority);const s=Uc(e.provenance)?e.provenance:void 0;"number"==typeof s?.confidence&&(r+=100*s.confidence);const a=Uc(e.lifecycle)?e.lifecycle:void 0,c=String(a?.freshness??"").toLowerCase();return"expired"!==c&&"stale"!==c||(r-=3e3),r}function el(e,t){if(!t)return e;const n=Zc(e,!0);return n&&"string"==typeof e.label?{...e,label:n}:e}function tl(e,t,n,o){const r=Zc(e,o);if(!r)return null;const i=Kc(e.id)||Kc(e.key)||Kc(e.pointId)||`annotation-${t+1}`,s=Uc(e.provenance)?Kc(e.provenance.source)||Kc(e.provenance.authorKind):void 0;return{id:i,label:r,shortLabel:Kc(e.shortText),pointId:e.pointId,emphasis:"string"==typeof e.emphasis?e.emphasis:void 0,source:s,priority:n,annotation:e}}function nl(e,t={}){const n=Array.isArray(e)?e.filter(Uc):[],o=t.breakpoint??480,r=t.active??(null==t.width||t.width<=o),i=t.strategy??"hybrid",s=!1!==t.preferShortText,a=!1!==t.preservePrimary,c=Math.max(0,t.maxPlotAnnotations??t.maxAnnotations??("callout-list"===i?1:2)),l=Math.max(0,t.minPlotAnnotations??t.minVisible??1);if(!r||"plot"===i)return{active:r,strategy:i,budget:n.length,visible:s?n.map(e=>el(e,s)):n,deferred:[],calloutList:[],hidden:[]};const u=[],d=n.map((e,n)=>({annotation:e,index:n,priority:Jc(e,n,t)})).filter(e=>!!Vr(e.annotation)||(u.push(e.annotation),!1)).sort((e,t)=>t.priority-e.priority),h=a?d.filter(e=>"primary"===String(e.annotation.emphasis??"").toLowerCase()):[],f=new Set(h.map(e=>e.index)),m=d.filter(e=>!f.has(e.index)),p=[...h,...m].slice(0,Math.max(c,l)),g=new Set(p.map(e=>e.index)),y=d.filter(e=>!g.has(e.index)),x=[...u,...p.sort((e,t)=>e.index-t.index).map(e=>el(e.annotation,s))],b=y.sort((e,t)=>e.index-t.index).map(e=>e.annotation),w=Math.max(0,t.maxCalloutItems??6),M=y.filter(e=>!t.calloutFilter||t.calloutFilter(e.annotation,e.index)).map(e=>tl(e.annotation,e.index,e.priority,s)).filter(e=>!!e).slice(0,w),v=new Set(M.map(e=>e.annotation)),k=b.filter(e=>!v.has(e));return{active:r,strategy:i,budget:c,visible:x,deferred:b,calloutList:M,hidden:k}}function ol(e){return{tapToSelect:!0,tapToLockTooltip:!0,clearSelection:"backgroundTap",targetSize:e.targetSize??44,snap:e.snap??"nearestDatum",brushHandleSize:e.targetSize??44,standardControls:e.standardControls??!1}}function rl(e,t){const n=t.targetSize??44,o=[],r=t.standardControls,i=e=>!0===r||"all"===r||r===e||Array.isArray(r)&&r.includes(e);return i("brush")&&o.push("range-inputs","clear-brush"),i("zoom")&&o.push("zoom-buttons","reset-view"),i("legend")&&o.push("legend-chips","show-all-series"),{strategy:`${e}-${t.transformProfile??"overview"}-mobile-recipe`,supportsResponsiveLayout:!0,breakpoints:[320,360,390,430,t.breakpoint??480,768],maxAnnotations:t.maxAnnotations??2,minimumHitTarget:n,summary:t.summary??!0,interaction:{primary:"tap",hoverFallback:"tap-to-lock",targetSize:n,...o.length>0&&{alternatives:o}},labels:{strategy:!1===t.directLabel?"compact":"direct",minFontSize:12}}}function il(e){return"dense"===e.density?.75:"compact"===e.density?.9:1}function sl(e,t){const n=!1!==t.keepAxes,o=!1===t.directLabel?12:28;return"ordinal"===e?{top:12,right:o,bottom:n?44:12,left:n?48:12}:"geo"===e||"network"===e?{top:12,right:12,bottom:12,left:12}:{top:12,right:o,bottom:n?42:14,left:n?44:14}}function al(e,t,n,o={}){const r={...n},i={mode:!1===t.mode?void 0:"mobile",...r,margin:sl(e,t),...o},s=Object.fromEntries(Object.entries(r).filter(([,e])=>void 0!==e)),a=Object.fromEntries(Object.entries(i).filter(([,e])=>void 0!==e)),c=rl(e,t),l=ol(t);return{family:e,props:s,responsiveRules:[{id:`${e}-mobile`,description:`Apply Semiotic's mobile ${e} recipe at phone width.`,when:{maxWidth:t.breakpoint??480},transform:{...a,mobileInteraction:l,mobileSemantics:c}}],mobileInteraction:l,mobileSemantics:c}}function cl(e={}){const t=il(e);return al("line",e,{showLegend:e.showLegend??!1,directLabel:e.directLabel??!0,lineWidth:"inspect"===e.transformProfile?3:Math.max(1.5,2.5*t),showPoints:"inspect"===e.transformProfile,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function ll(e={}){const t=il(e);return al("area",e,{showLegend:e.showLegend??!1,showPoints:!1,areaOpacity:"compare"===e.transformProfile?.55:.42,lineWidth:Math.max(1.25,2*t),autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??2,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function ul(e={}){return al("ordinal",e,{showLegend:e.showLegend??!1,showCategoryTicks:e.keepAxes??!0,sort:"compare"===e.transformProfile?"desc":void 0},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function dl(e={}){const t=il(e);return al("scatter",e,{showLegend:e.showLegend??!1,pointRadius:Math.max(4,Math.round((e.targetSize??44)/8*t)),hoverRadius:Math.ceil((e.targetSize??44)/2),pointOpacity:"dense"===e.density?.42:.68,autoPlaceAnnotations:{mobile:{strategy:"callout-list",maxAnnotations:e.maxAnnotations??1,maxCalloutItems:e.maxCalloutItems??4,progressiveDisclosure:!0,preferShortText:!0}}},{showAxes:e.keepAxes??!0,axisExtent:"exact"})}function hl(e={}){const t=il(e);return al("network",e,{showLegend:e.showLegend??!1,nodeSizeRange:[Math.max(4,Math.round(6*t)),Math.max(12,Math.round((e.targetSize??44)/2*t))],showLabels:"inspect"===e.transformProfile,edgeOpacity:"dense"===e.density?.28:.44})}function fl(e={}){return al("geo",e,{showLegend:e.showLegend??!1})}function ml(e={}){return al("small-multiple",e,{mobileColumns:e.mobileColumns??1,tabletColumns:e.tabletColumns??2,chartHeight:e.chartHeight??180,sharedExtent:!0})}function pl(e,t={}){switch(e){case"line":return cl(t);case"area":return ll(t);case"ordinal":return ul(t);case"scatter":return dl(t);case"network":return hl(t);case"geo":return fl(t);case"small-multiple":return ml(t)}}function gl(e={}){const t=e.targetSize??44,n=e.controls??["range-inputs","chip-filter","clear"];return{mobileInteraction:{enabled:!0,targetSize:t,tapToSelect:!0,tapToLockTooltip:!0,standardControls:"brush"},mobileSemantics:{interaction:{primary:"filter",alternatives:n,summary:e.summary??"Expose brushable ranges through touch-sized controls in addition to drag gestures."}},controls:n}}var yl,xl,bl,wl,Ml=Object.create,vl=Object.defineProperty,kl=Object.getOwnPropertyDescriptor,$l=Object.getOwnPropertyNames,Sl=Object.getPrototypeOf,Il=Object.prototype.hasOwnProperty,Al=(e,t,n)=>function(){if(n)throw n[0];try{return e&&(t=(0,e[$l(e)[0]])(e=0)),t}catch(e){throw n=[e],e}},Cl=(e,t)=>{for(var n in t)vl(e,n,{get:t[n],enumerable:!0})},Nl=(e,t,n,o)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of $l(t))Il.call(e,r)||r===n||vl(e,r,{get:()=>t[r],enumerable:!(o=kl(t,r))||o.enumerable});return e},jl=(e,t,n)=>(n=null!=e?Ml(Sl(e)):{},Nl(!t&&e&&e.__esModule?n:vl(n,"default",{value:e,enumerable:!0}),e)),Fl=Al({"src/components/recipes/atlas/entityCounts.ts"(){}}),El=Al({"src/components/recipes/atlas/ids.ts"(){}}),Pl=Al({"src/components/recipes/atlas/ledger.ts"(){El()}}),zl=Al({"src/components/recipes/atlas/compare.ts"(){Fl(),Pl()}}),Ll=Al({"src/components/recipes/atlas/completeness.ts"(){El()}}),Ol=Al({"src/components/recipes/atlas/directedGraph.ts"(){}}),Tl=Al({"src/components/recipes/atlas/rootedForest.ts"(){Ol()}}),Rl=Al({"src/components/recipes/atlas/forests.ts"(){El(),Tl()}}),Wl=Al({"src/components/recipes/atlas/types.ts"(){yl="0.2",xl=["serial-chain","repeated-state-episode","fan-out","fan-in","split-rejoin-diamond","shared-upstream-source","connector-bypass"],bl=["serial-chain","fan-out","fan-in"],wl=[...bl,"repeated-state-episode"]}}),ql=Al({"src/components/recipes/atlas/motifs.ts"(){El(),Wl()}}),Dl=Al({"src/components/recipes/atlas/prefixForest.ts"(){El()}}),Bl=Al({"src/components/recipes/atlas/sections.ts"(){El()}}),Yl=Al({"src/components/recipes/atlas/support.ts"(){}}),Vl=Al({"src/components/recipes/atlas/requiredPaths.ts"(){Ol()}}),Gl=Al({"src/components/recipes/atlas/validate.ts"(){El(),Wl()}}),_l={};Cl(_l,{prepareNetworkAtlas:()=>G});var Hl=Al({"src/components/recipes/atlas/prepare.ts"(){zl(),Ll(),Rl(),Pl(),ql(),Dl(),Bl(),Yl(),Vl(),Gl()}}),Xl=Al({"src/components/recipes/atlas/capsules.ts"(){}}),Ul=Al({"src/components/recipes/atlas/profile.ts"(){Fl(),zl()}}),Kl={};Cl(Kl,{assignedDenominator:()=>u,prepareMotifBraid:()=>Z,ribbonSupportsRoute:()=>Q});var Zl,Ql,Jl,eu,tu,nu,ou=Al({"src/components/recipes/atlas/braid.ts"(){Xl(),zl(),Yl(),El(),Ul()}}),ru=Al({"src/components/charts/shared/minMax.ts"(){}}),iu=Al({"src/components/stream/layouts/forceLayoutNodeSize.ts"(){Zl=require("d3-scale"),ru()}}),su=Al({"src/components/stream/layouts/forceLayoutEdgeWeight.ts"(){}}),au=Al({"src/components/stream/layouts/forceLayoutWorkerPolicy.ts"(){iu(),su(),Ql=4e4}}),cu=Al({"src/components/stream/workerModuleUrl.ts"(){}}),lu=Al({"src/components/stream/moduleWorkerSession.ts"(){Jl=class{constructor(e){this.nextRequestId=1,this.pending=/* @__PURE__ */new Map,this.dead=!1,this.failure=null,this.options=e,this.worker=e.createWorker(),this.worker.onmessage=e=>{if(this.dead)return;let t;try{t=this.options.parseMessage(e.data)}catch(e){return void this.fail(e instanceof Error?e:new Error(String(e)))}const n=t.requestId,o=null!=n?this.pending.get(n):this.pending.values().next().value;if(o){if(null!=n)this.pending.delete(n);else{for(const e of this.pending.values())e!==o&&(e.cleanup(),e.reject(new Error(`${this.options.name} worker response missing requestId`)));this.pending.clear()}o.cleanup(),t.ok?o.resolve(t.payload):o.reject(t.error)}},this.worker.onmessageerror=()=>{this.fail(new Error(`${this.options.name} worker response could not be deserialized`))},this.worker.onerror=e=>{this.fail(new Error(e.message||`${this.options.name} worker failed`))}}get isDead(){return this.dead}fail(e){this.dead||(this.failure=e,this.rejectAll(e),this.terminate())}request(e,t){if(this.dead)return Promise.reject(new Error(`${this.options.name} worker session is closed`));if(t?.aborted)return Promise.reject(ae(this.options.name));const n=this.nextRequestId;this.nextRequestId+=1;const o=this.options.encodeRequest?.(n,e)??{requestId:n,request:e};return new Promise((e,r)=>{const i=()=>{const e=1===this.pending.size;this.pending.delete(n),t?.removeEventListener("abort",i),r(ae(this.options.name)),this.options.terminateOnAbort&&e&&this.terminate()},s=()=>t?.removeEventListener("abort",i);this.pending.set(n,{cleanup:s,reject:r,resolve:e}),t?.addEventListener("abort",i,{once:!0});try{this.worker.postMessage(o)}catch(e){this.pending.delete(n),s(),r(e instanceof Error?e:new Error(String(e)))}})}terminate(){this.dead||(this.dead=!0,this.rejectAll(new Error(`${this.options.name} worker terminated`)),this.worker.terminate())}rejectAll(e){for(const t of this.pending.values())t.cleanup(),t.reject(e);this.pending.clear()}}}}),uu={};Cl(uu,{DEFAULT_FORCE_WORKER_THRESHOLD:()=>Ql,ForceLayoutWorkerSession:()=>tu,_resetSharedForceLayoutSessionForTest:()=>he,canUseForceWorker:()=>re,createForceLayoutWorker:()=>de,createFrameForceWorkerRequest:()=>ie,runForceLayoutWorker:()=>fe,shouldUseForceWorker:()=>oe});var du,hu=Al({"src/components/stream/layouts/forceLayoutWorkerClient.ts"(){cu(),lu(),au(),au(),eu={},tu=class{constructor(e=de()){this.session=new Jl({name:"Force layout",createWorker:()=>e,terminateOnAbort:!0,parseMessage:e=>{const t=e,{requestId:n,error:o}=le(t);if(o)return{requestId:n,ok:!1,error:ce(o)};if(!t?.positions||"object"!=typeof t.positions||Array.isArray(t.positions)||!Object.values(t.positions).every(e=>e&&Number.isFinite(e.x)&&Number.isFinite(e.y)))throw new Error("Malformed force worker response");return{requestId:n,ok:!0,payload:{positions:t.positions}}}})}get isDead(){return this.session.isDead}get failure(){return this.session.failure}request(e,t){return this.session.request(e,t)}terminate(){this.session.terminate()}},nu=/* @__PURE__ */ue(()=>new tu)}}),fu={};Cl(fu,{DEFAULT_AREA_PER_ANNOTATION:()=>yh,DEFAULT_GLYPH_ANCHOR:()=>rf,DEFAULT_GLYPH_VIEWBOX:()=>of,DEFAULT_HIT_RADIUS:()=>ef,DEFAULT_ISOMETRIC_SPRITE_SIZES:()=>Zu,GRID_FUEL_KEYS:()=>jh,GRID_FUEL_LABELS:()=>Fh,LayoutCache:()=>gu,SYMBOL_SEQUENCE:()=>Iu,TAU:()=>nf,absorbRegion:()=>Fa,activeCountOverDomain:()=>Fi,addPoints:()=>Ps,adjacencyFlowLayout:()=>Kd,adjacencyMatrix:()=>Xc,aggregateAdjacencyFlow:()=>hr,aggregateRegionCounts:()=>ga,allocateCells:()=>Ee,analyzeNetEnsemble:()=>Wo,angleScale:()=>Ns,annotationBudget:()=>Hr,annotationDensity:()=>Ur,annotationLayout:()=>fi,arcLayout:()=>Gc,arcPath:()=>_c,arrivalReplay:()=>Bc,axisFixedForceLayout:()=>Wh,axisFixedForcePositions:()=>Yi,balanceSnapshotsToFlows:()=>Le,bandLabel:()=>Po,betweenness:()=>na,bfsDistances:()=>Js,bobaLayout:()=>ph,bodyGroupSpec:()=>Pa,boundsOf:()=>Fo,boxEdgeAnchors:()=>Oi,buildAdjacency:()=>Zs,buildTooltipEntries:()=>_s,bulletLayout:()=>sh,calendarLayout:()=>Gu,capacitatedRegion:()=>Na,chargeGateRegion:()=>Ia,circularLayout:()=>Hc,clamp:()=>me,classifyReserve:()=>yi,closeness:()=>oa,clustering:()=>ra,collidersFromScales:()=>Tc,comparePhysicsTrace:()=>Qa,composePhysicsControllers:()=>hc,computeTransitDiagramPositions:()=>Wn,countPairwiseCrossings:()=>ys,createCapacityQueueController:()=>uc,createDagreFit:()=>jn,createDependencyGateController:()=>yc,createFlextreeFit:()=>In,createLineageDagFit:()=>no,createPortalController:()=>fc,createProcessJourneyLedger:()=>rc,createServiceLevelController:()=>gc,createServiceResourcePoolController:()=>mc,cubicPath:()=>qi,cubicPoint:()=>Ri,cubicTangent:()=>Wi,curvedEdgePath:()=>zi,cyclicRangeContains:()=>ls,dagreLayout:()=>wd,degree:()=>Qs,demandForecastRows:()=>bi,describePhysicsStageGeography:()=>jc,diagnoseTokenEncoding:()=>Qe,dimFor:()=>Me,egoNetwork:()=>ta,estimateLabelWidth:()=>ws,extractTooltipDatum:()=>Gs,fanOutBend:()=>Ti,flextreeLayout:()=>gd,forceFieldRegion:()=>Ea,forceLayout:()=>qe,forceLayoutAsync:()=>aa,formatMw:()=>Ai,formatReservePct:()=>Ci,formatTooltipValue:()=>Hs,galtonPegs:()=>Rc,generateTokens:()=>Ke,geoAreaHitTarget:()=>ns,geoHitTarget:()=>ts,geographicDotGridLayout:()=>pd,geographicGridLayout:()=>ad,glyphExtent:()=>Ws,glyphFractionClipRect:()=>qs,glyphPlacement:()=>Rs,gridEventAnnotations:()=>Si,gridifyGeographicPoints:()=>Vt,groupBy:()=>xe,groupCompletionRows:()=>xa,hatchFill:()=>zo,hitTargetPoint:()=>es,hitTargetRect:()=>os,hullFromBoxes:()=>Eo,intervalLanesLayout:()=>Th,isometricLandmarkLayout:()=>td,isotypeBoltGlyph:()=>Pu,isotypeBusGlyph:()=>zu,isotypeChipGlyph:()=>Eu,isotypeGhost:()=>ju,isotypeInk:()=>Cu,isotypeNetworkGlyphs:()=>Tu,isotypePaper:()=>Nu,isotypePersonGlyph:()=>Ou,isotypePersonPath:()=>Lu,isotypeServerGlyph:()=>Fu,layoutChipStrip:()=>bs,layoutSequence:()=>xs,layoutTokenGrid:()=>Ze,legendGroupsFrom:()=>Bs,legendSwatches:()=>Ys,lineageDagLayout:()=>Fd,linearAxis:()=>Lo,makeShade:()=>ke,marimekkoLayout:()=>rh,markCallout:()=>Oo,matchesHighlight:()=>we,mean:()=>Ce,membraneRegion:()=>Sa,mermaidDagLayout:()=>Dd,mobileAnnotationStrategy:()=>nl,mobileAreaChartRecipe:()=>ll,mobileBrushAlternatives:()=>gl,mobileChartFamilyRecipe:()=>pl,mobileGeoChartRecipe:()=>fl,mobileLineChartRecipe:()=>cl,mobileNetworkChartRecipe:()=>hl,mobileOrdinalChartRecipe:()=>ul,mobileScatterplotRecipe:()=>dl,mobileSmallMultipleRecipe:()=>ml,motifBraidLayout:()=>Td,mulberry32:()=>We,netEnsembleLayout:()=>Hd,networkEdgeHitTarget:()=>is,networkHitTarget:()=>rs,nonNegativeFinite:()=>Ae,normalizePoint:()=>Ts,normalizeScores:()=>ia,normalizeTokenEncoding:()=>Ge,octilinearRoute:()=>qn,offsetTransitPath:()=>Dn,orderByBarycenter:()=>ms,orderByGroupDegree:()=>Vc,orderExactSmall:()=>gs,orthogonalEdgePath:()=>Li,packBandsBySilhouette:()=>fs,packIntervals:()=>ji,packSpanLevels:()=>Ms,packedClusterMatrix:()=>th,parallelCoordinatesLayout:()=>lh,partitionSharedEdges:()=>Ss,physicsChargePoint:()=>Cc,physicsDestination:()=>Ac,physicsReferenceEnvelope:()=>Ha,physicsStageColliders:()=>Nc,physicsStageGeography:()=>Ic,placeWithMinGap:()=>ds,pointMagnitude:()=>Os,polarToXY:()=>As,portalRegion:()=>ja,prepareMotifBraid:()=>go,prepareNetworkAtlasAsync:()=>po,pressureFieldRegion:()=>Ca,processChrome:()=>kc,processJourneyRows:()=>sc,processLaneWalls:()=>za,processStageLayout:()=>Ma,processStageRegions:()=>$a,processVolumePolygons:()=>Oa,proximityProblem:()=>sa,radiusScale:()=>js,readField:()=>ge,rectCollide:()=>Di,refineByAdjacentSwaps:()=>ps,regionCountsToProjectionRows:()=>ya,reserveAnnotationBands:()=>ki,reserveClasses:()=>gi,reserveMarginPct:()=>wi,reserveSeries:()=>Mi,ringArcPath:()=>Fs,roundedEnclosure:()=>jo,roundedTransitPath:()=>Bn,routeSurfaceRegion:()=>Aa,runLengthEncode:()=>tf,runs:()=>ss,sampleGeographicDotGrid:()=>hn,scaleArcBand:()=>vs,scalePoint:()=>Ls,sedimentBake:()=>qc,selectCyclicRange:()=>us,selectIsometricLandmarks:()=>Et,shade:()=>$e,shortestArcDelta:()=>cs,shortestPath:()=>ea,signatureKey:()=>ve,spanArcPath:()=>ks,spanArcPeakY:()=>$s,spawnFromTokens:()=>Wc,stackFuelSeries:()=>xi,stageTargetInVolume:()=>La,subtractPoints:()=>zs,suggestTokenEncoding:()=>tt,summarizeOperatingPoint:()=>$i,symbolExtent:()=>rt,symbolPathString:()=>nt,symbolRadius:()=>ot,thresholdBandsForReserve:()=>vi,tightestHours:()=>Ii,tokenLayer:()=>$t,tokenTaskIntentToCapabilityIntents:()=>et,transitDiagramLayout:()=>$d,unitize:()=>Te,unitizeRange:()=>Re,unwrapDatum:()=>ye,updateProcessJourney:()=>ic,waffleLayout:()=>xu,withAlpha:()=>Ne,wordTrailsLayout:()=>Zi,wordTrailsProgressiveReveal:()=>Ki,wrapValue:()=>as,xyToAngle:()=>Cs}),module.exports=(du=fu,Nl(vl({},"__esModule",{value:!0}),du));var mu,pu=require("d3-interpolate"),gu=class{constructor(e=12){this.maxSize=e,this.store=/* @__PURE__ */new Map}get(e){return this.store.get(e)}set(e,t){this.store.size>=this.maxSize&&this.store.clear(),this.store.set(e,t)}getOrCompute(e,t){const n=this.store.get(e);if(void 0!==n)return n;const o=t();return this.set(e,o),o}clear(){this.store.clear()}get size(){return this.store.size}},yu=require("react"),xu=e=>{const t=e.config,n=t.rows??10,o=t.columns??10,r=t.gutter??2,{plot:i}=e.dimensions;if(i.width<=0||i.height<=0)return{nodes:[]};const s=()=>({nodes:[],overlays:Fe(i,0,e.data.length,"rows","The grid needs positive integer dimensions and enough space for its gutters.",{force:!0})}),a=n*o;if(!Number.isSafeInteger(n)||!Number.isSafeInteger(o)||!Number.isSafeInteger(a)||n<=0||o<=0||!Number.isFinite(r)||r<0)return s();const c=(i.width-r*(o-1))/o;if(c<=0||i.height<=r*(n-1))return s();const l=null==t.categoryAccessor?()=>"_default":pe(t.categoryAccessor),u=null==t.valueAccessor?()=>1:pe(t.valueAccessor),d=/* @__PURE__ */new Map;for(const t of e.data){const e=String(l(t)),n=Ae(Number(u(t)));d.set(e,(d.get(e)??0)+n)}const h=Array.from(d.values()).reduce((e,t)=>e+t,0);if(!(h>0&&Number.isFinite(h)))return{nodes:[],overlays:Fe(i,0,d.size,"categories","Category values must have a finite positive total.")};const f=[.../* @__PURE__ */new Set([...t.categoryOrder??[],...d.keys()])].filter(e=>d.has(e)),m=Pe(f.map(e=>({key:e,weight:d.get(e)??0})),a,void 0,!0),p=m.filter(e=>e.cells>0).length,g=Fe(i,p,f.length,"categories","Zero-valued categories and categories rounded to zero cells are omitted."),y=(i.height-(g?18:0)-r*(n-1))/n;if(y<=0)return s();const x="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",b="string"==typeof t.valueAccessor?t.valueAccessor:"value",w=(e,t,n)=>be(o=>{o("category",e),o("value",d.get(e)??0),o("share",(d.get(e)??0)/h),"category"!==x&&o(x,e),"value"!==b&&o(b,d.get(e)??0),o("cells",n),o("_waffleCategory",e),o("_waffleIndex",t)}),M=[];let v=0;for(const t of m){const s=e.resolveColor(t.key);for(let e=0;e<t.cells;e++){const a=v%o,l=n-1-Math.floor(v/o);M.push({type:"rect",x:i.x+a*(c+r),y:i.y+l*(y+r),w:c,h:y,style:{fill:s,stroke:"none"},datum:w(t.key,v,t.cells),group:t.key,_transitionKey:`waffle-${t.key}-${e}`}),v++}}return{nodes:M,overlays:g}},bu=1e-6,wu=require("d3-force"),Mu=1e3,vu=80,ku=100,$u=require("d3-shape"),Su={circle:$u.symbolCircle,square:$u.symbolSquare,triangle:$u.symbolTriangle,diamond:$u.symbolDiamond,star:$u.symbolStar,cross:$u.symbolCross,wye:$u.symbolWye},Iu=["circle","triangle","diamond","star","square","chevron","cross","wye"],Au=/* @__PURE__ */new Map,Cu="#334155",Nu="#f8fafc",ju="#cbd5e1",Fu={viewBox:[40,40],anchor:[.5,1],parts:[{d:"M8 3h24v34H8z",fill:"color"},{d:"M12 9h16v5H12zM12 18h16v5H12zM12 27h16v5H12z",fill:"accent"},{d:"M23.8 11.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 20.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M23.8 29.5a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0",fill:"color"}]},Eu={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M10 8h20a2 2 0 0 1 2 2v20a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2z",fill:"color"},{d:"M15 15h10v10H15z",fill:"accent"},{d:"M7 2v6M14 2v6M21 2v6M28 2v6M7 32v6M14 32v6M21 32v6M28 32v6M2 7h6M2 14h6M2 21h6M2 28h6M32 7h6M32 14h6M32 21h6M32 28h6",fill:"none",stroke:"color",strokeWidth:3}]},Pu={viewBox:[40,40],anchor:[.5,.5],parts:[{d:"M23 1L7 23h10l-3 16 19-25H22z",fill:"color"}]},zu={viewBox:[48,40],anchor:[.5,.78],parts:[{d:"M7 12c0-4 3-7 7-7h20c4 0 7 3 7 7v15H7z",fill:"color"},{d:"M11 15h26v8H11z",fill:"accent",opacity:.9},{d:"M12 27h7v4h-7zM29 27h7v4h-7z",fill:"accent",opacity:.95},{d:"M12 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0M28 31a4 4 0 1 0 8 0a4 4 0 1 0-8 0",fill:"color",stroke:"accent",strokeWidth:1.8},{d:"M5 13h4v8H5zM39 13h4v8h-4z",fill:"color"}]},Lu="M 9.12,3.34 C 8.28,3.29 7.44,3.40 6.64,3.69 4.17,3.63 1.97,5.37 0.91,7.51 -1.32,11.80 2.55,17.76 8.19,16.55 11.62,16.13 15.55,14.04 16.17,10.33 16.38,6.53 12.77,3.52 9.12,3.34 Z M 9.35,19.86 C 8.89,19.84 8.41,19.92 7.92,20.11 5.12,21.55 3.72,24.68 2.79,27.54 2.32,29.86 0.87,32.04 1.36,34.49 1.63,37.60 8.04,38.95 8.04,38.95 8.04,38.95 14.67,39.65 16.50,36.33 17.16,31.95 16.34,27.23 14.01,23.42 13.07,21.69 11.36,19.92 9.35,19.86 Z",Ou={viewBox:[18,40],anchor:[.5,1],parts:[{d:Lu,fill:"color",stroke:"color",strokeWidth:1.4}]},Tu={server:Fu,chip:Eu,bolt:Pu,bus:zu,person:Ou},Ru="var(--semiotic-primary, #4e79a7)",Wu="var(--semiotic-border, #d1d5db)",qu="var(--semiotic-secondary, #9ca3af)",Du="var(--semiotic-bg, #ffffff)",Bu=/* @__PURE__ */new Set(Iu),Yu=require("d3-interpolate"),Vu=864e5,Gu=e=>{const t=e.config,{plot:n}=e.dimensions;if(n.width<=0||n.height<=0)return{nodes:[]};const o=e=>{const n="function"==typeof t.dateAccessor?t.dateAccessor(e):e[t.dateAccessor];return n instanceof Date?n:new Date(n)},r=e=>{const n="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor];return Number(n)},i=/* @__PURE__ */new Map;let s=null;for(const t of e.data){const e=o(t);if(!isFinite(e.getTime()))continue;null==s&&(s=e.getUTCFullYear());const n=St(e),a=r(t);i.set(n,(i.get(n)??0)+(Number.isFinite(a)?a:0))}const a=t.year??s??/* @__PURE__ */(new Date).getUTCFullYear();let c=1/0,l=-1/0;for(const e of i.values())e<c&&(c=e),e>l&&(l=e);c===1/0&&(c=0,l=0);const[u,d]=t.colorRamp??[e.theme.semantic.surface??"#ebedf0",e.theme.semantic.primary??"#216e39"],h=e=>{if(l===c)return u;const t=(e-c)/(l-c);return(0,Yu.interpolateRgb)(u,d)(t)},f=t.gutter??2,m=t.labelInset??0,p=n.width-m,g=n.height,y=Math.min((p-53*f)/54,(g-6*f)/7);if(y<=0)return{nodes:[]};const x=new Date(Date.UTC(a,0,1)),b=x.getUTCDay(),w=new Date(x.getTime()-b*Vu),M=[];for(let e=0;e<54;e++)for(let t=0;t<7;t++){const o=new Date(w.getTime()+(7*e+t)*Vu);if(o.getUTCFullYear()!==a)continue;const r=St(o),s=i.get(r),c=null==s?u:h(s);M.push({type:"rect",x:n.x+m+e*(y+f),y:n.y+t*(y+f),w:y,h:y,style:{fill:c,stroke:"none"},datum:{date:o,value:s??0}})}return{nodes:M}},_u=["#739b58","#83a964","#668d52","#8baa68"],Hu=/* @__PURE__ */new Set(["city","culture","monument","faith","nature","knowledge","defense","arena","transport"]),Xu=jl(require("react")),Uu=(require("react/jsx-runtime"),{isActive:!1,predicate:()=>!0}),Ku=require("react/jsx-runtime"),Zu={resource:32,city:64},Qu={land:"#78985c",ocean:"#4d8192",forest:"#4f7c4b",grassland:"#8eaa68",cropland:"#a6a568",wetland:"#668f79",urban:"#8d8a72",scrub:"#9b9665",bare:"#aa906a",snow:"#d8ddcf"},Ju={land:"Open land",ocean:"Open ocean",forest:"Forest",grassland:"Grassland",cropland:"Cropland",wetland:"Wetland",urban:"Urban district",scrub:"Scrubland",bare:"Bare ground",snow:"Snow cover"},ed=/* @__PURE__ */new Set(["land","ocean","forest","grassland","cropland","wetland","urban","scrub","bare","snow"]),td=e=>{const t=jt(e.config.gridSize),n=Math.max(20,e.config.tileWidth??80),o=Math.max(10,e.config.tileHeight??40),r=e.config.terrainColors?.length?e.config.terrainColors:_u,i=t*o,s=e.dimensions.width/2,a=(e.dimensions.height-i)/2+o/2,c=Et(e.points,e.config).map(e=>({...e,x:s+(e.column-e.row)*(n/2),y:a+(e.column+e.row)*(o/2)}));return{nodes:c.map(t=>{const i=Tt(e.config.terrainByCell,t.id),s="city"===t.landmark?.kind?"urban":i?.kind??"land",a=i?.fill??Lt(e.config.terrainPalette,s)??Lt(Qu,s)??Qu.land,c=t.landmark?{...t.landmark,gridRow:t.row,gridColumn:t.column,cellId:t.id,terrainKind:s,terrainCoverage:i?.coverage,features:t.landmarks,featureCount:t.landmarks.length}:{id:t.id,name:(l=s,Lt(Ju,l)??Ju.land),kind:"terrain",terrainKind:s,terrainCoverage:i?.coverage,gridRow:t.row,gridColumn:t.column,cellId:t.id,features:[],featureCount:0};var l,u,d,h,f;return{type:"geoarea",pathData:(u=t.x,d=t.y,h=n,f=o,[`M${u},${d-f/2}`,`L${u+h/2},${d}`,`L${u},${d+f/2}`,`L${u-h/2},${d}`,"Z"].join("")),centroid:[t.x,t.y],bounds:[[t.x-n/2,t.y-o/2],[t.x+n/2,t.y+o/2]],screenArea:n*o/2,style:{fill:i||"urban"===s?a:r[t.terrainIndex%r.length],stroke:"ocean"===s?"#315d6c":e.config.tileStroke??"#314934",strokeWidth:1},datum:c,group:t.landmark?.kind??s,interactive:!0}}),overlays:/* @__PURE__ */ /* @__PURE__ */(0,Ku.jsx)(Rt,{tiles:c,tileWidth:n,tileHeight:o,sprites:e.config.sprites,resourceSize:e.config.resourceSpriteSize??Zu.resource,citySize:e.config.citySpriteSize??Zu.city,showCityLabel:!1!==e.config.showCityLabel}),restyle:(e,t)=>t?.isActive&&e.datum&&"terrain"!==e.datum.kind?{fillOpacity:t.predicate(e.datum)?1:.28}:{fillOpacity:1}}},nd={city:["..1111..","..1221..",".111111.",".133331.","11111111","13311331","14411441","11111111"],culture:["..1111..",".122221.","11111111",".133331.",".133331.",".133331.","11111111",".444444."],monument:["...11...","..1221..","..1221..","..1331..",".113311.",".133331.","11111111",".444444."],faith:["...11...","...11...","..1111..","...11...","..1221..",".133331.","11111111",".444444."],nature:["...11...","..1221..",".122221.","12222221",".133331.","...11...","..1441..",".144441."],knowledge:[".111111.","12211221","12211221","13311331","13311331","13311331","11111111",".444444."],defense:["11.11.11","11111111","12222221","12211221","13311331","13333331","11111111",".444444."],arena:["..1111..",".122221.","12333321","12344321","12344321","12333321",".122221.","..1111.."],transport:["...11...","..1221..",".122221.","11111111","..1331..","..1331..",".114411.","11444411"]},od={city:{1:"#29364a",2:"#d8b45b",3:"#b7693c",4:"#6d9fc5"},culture:{1:"#29364a",2:"#d5c9a3",3:"#9c6fb2",4:"#ece3c4"},monument:{1:"#29364a",2:"#d8cba8",3:"#9c8f79",4:"#ece3c4"},faith:{1:"#29364a",2:"#d9c36d",3:"#a877a5",4:"#ece3c4"},nature:{1:"#29364a",2:"#4f8a4e",3:"#79aa56",4:"#79583a"},knowledge:{1:"#29364a",2:"#d5c9a3",3:"#4f7da0",4:"#ece3c4"},defense:{1:"#29364a",2:"#a6a298",3:"#777b7f",4:"#d5c9a3"},arena:{1:"#29364a",2:"#cb8056",3:"#d8cba8",4:"#6d9fc5"},transport:{1:"#29364a",2:"#d8b45b",3:"#6d9fc5",4:"#ece3c4"}},rd=require("react/jsx-runtime"),id=.72,sd=1.8,ad=e=>{const t=e.config,n=t.source??"auto",o="areas"===n||"auto"===n&&e.areas.length>0,r=(o?Ut(e):e.points.map((e,t)=>({datum:e,x:t,y:t}))).filter((e,n)=>!t.filter||t.filter(e.datum,n)),i=Zt(r.map(e=>e.datum),t),s=o?r:Kt({...e,points:r.map(e=>e.datum)}),a=i??Vt(s,{columns:t.columns,rows:t.rows,occupancy:t.occupancy,aspectRatio:e.dimensions.width/Math.max(1,e.dimensions.height)});if(0===a.length)return{nodes:[]};const c=Bt(a.map(e=>e.row)),l=Bt(a.map(e=>e.column)),u=Math.max(1,Math.round(c[1]-c[0])+1),d=Math.max(1,Math.round(l[1]-l[0])+1),h=Math.max(0,t.layoutPadding??8),f=Math.max(1,e.dimensions.width-2*h),m=Math.max(1,e.dimensions.height-2*h),p=f/d,g=m/u,y=p*d,x=g*u,b=(e.dimensions.width-y)/2,w=(e.dimensions.height-x)/2,M=me(t.cellPadding??.12,0,.8),v=Math.max(1,.5*Math.min(p,g)*(1-M)),k=t.sizeAccessor?a.map(e=>Number(Gt(e.datum,t.sizeAccessor))):[],$=t.sizeDomain??Bt(k),S=t.sizeRange??[.36,1],I=me(Math.min(S[0],S[1]),.05,1),A=me(Math.max(S[0],S[1]),I,1),C=a.map((n,o)=>{const r={...n.datum,gridRow:n.row,gridColumn:n.column},i=String(Gt(r,t.idAccessor,["id","key","name"])??`grid-${o}`),s=String(Gt(r,t.labelAccessor,["abbr","code","label","name","id"])??i),a=Math.max(1,t.maxLabelLength??4),u=s.length>a?s.slice(0,a):s,d=Gt(r,t.categoryAccessor),h=null==d?void 0:String(d),f=Gt(r,t.fillAccessor),m=null!=f?String(f):h?e.resolveColor(h):e.theme.categorical[0]??"#4f86c6",y=t.sizeAccessor?Number(Gt(r,t.sizeAccessor)):NaN,x=t.sizeAccessor&&Number.isFinite(y)?Math.sqrt(me(Yt(y,$),0,1)):1,M=v*(I+x*(A-I)),k="function"==typeof t.markStyle?t.markStyle(r,o):t.markStyle;return{datum:r,id:i,label:u,category:h,row:n.row,column:n.column,x:b+(n.column-l[0]+.5)*p,y:w+(n.row-c[0]+.5)*g,radius:M,style:{fill:m,fillOpacity:.94,stroke:"rgba(255,255,255,0.9)",strokeWidth:1,...k}}}),N=t.shape??"circle";return{nodes:C.map(e=>{return"circle"===N?{type:"point",x:e.x,y:e.y,r:e.radius,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},pointId:e.id,_transitionKey:e.id}:{type:"geoarea",pathData:"hexagon"===N?Xt(e.x,e.y,e.radius):(t=e.x,n=e.y,o=e.radius,Ht([[t-o,n-o],[t+o,n-o],[t+o,n+o],[t-o,n+o]])),centroid:[e.x,e.y],bounds:[[e.x-e.radius,e.y-e.radius],[e.x+e.radius,e.y+e.radius]],screenArea:"hexagon"===N?3*Math.sqrt(3)*e.radius*e.radius/2:(2*e.radius)**2,style:e.style,datum:e.datum,accessibleDatum:e.datum,accessibility:{label:e.label,tableFields:{name:e.datum.name??e.label,label:e.label,row:e.row,column:e.column,...e.category?{category:e.category}:{}}},group:e.category,interactive:!0};var t,n,o}),overlays:!1===t.showLabels?null:/* @__PURE__ */ /* @__PURE__ */(0,rd.jsx)(Qt,{marks:C,color:t.labelColor??"#ffffff",fontSize:t.labelFontSize??me(.23*Math.min(p,g),7,14),fontFamily:t.labelFontFamily,fontWeight:t.labelFontWeight??700}),restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.18}:{opacity:1}}},cd=require("react/jsx-runtime"),ld=10,ud=25e3,dd=/* @__PURE__ */new WeakMap,hd=/* @__PURE__ */new WeakMap,fd=/* @__PURE__ */new WeakMap,md=1,pd=e=>{const t=bn(e),n=e.config,o=n.shape??"circle",r=Math.max(.5,tn(n.dotRadius)??t.cellSize*me(n.radiusRatio??.24,.05,.5)),i=n.gridOrigin?.[0]??0,s=n.gridOrigin?.[1]??0;return{nodes:t.dots.map((a,c)=>{const l=i+(a.gridColumn+.5)*t.cellSize,u=s+(a.gridRow+.5)*t.cellSize,d=nn(a,n.categoryAccessor),h=nn(a,n.fillAccessor),f={fill:null!=h?String(h):null!=d?e.resolveColor(String(d)):e.theme.categorical[0]??"#4f86c6",fillOpacity:.92,strokeWidth:0,..."function"==typeof n.markStyle?n.markStyle(a,c):n.markStyle},m=`dot-${a.gridRow}-${a.gridColumn}`;return"circle"===o?{type:"point",x:l,y:u,r:r,style:f,datum:a,interactive:!1,pointId:m,_transitionKey:m}:{type:"geoarea",pathData:"hexagon"===o?vn(l,u,r):Mn(l,u,r),centroid:[l,u],bounds:[[l-r,u-r],[l+r,u+r]],screenArea:"hexagon"===o?3*Math.sqrt(3)*r*r/2:(2*r)**2,style:f,datum:a,group:a.featureId,interactive:!1}}),overlays:n.showOutline?/* @__PURE__ */ /* @__PURE__ */(0,cd.jsx)("g",{"aria-hidden":"true",pointerEvents:"none",children:t.features.map((t,o)=>{const r=e.scales.geoPath(t);return r?/* @__PURE__ */ /* @__PURE__ */(0,cd.jsx)("path",{d:r,fill:"none",stroke:n.outlineStyle?.stroke??"currentColor",strokeOpacity:n.outlineStyle?.opacity??n.outlineStyle?.fillOpacity??.22,strokeWidth:n.outlineStyle?.strokeWidth??.7,strokeDasharray:n.outlineStyle?.strokeDasharray,strokeLinecap:n.outlineStyle?.strokeLinecap,vectorEffect:"non-scaling-stroke"},rn(t,o)):null})}):null,restyle:(e,t)=>t?.isActive&&e.datum?{opacity:t.predicate(e.datum)?1:.14}:{opacity:1}}},gd=e=>{const t=e.config??{},n=t.orientation??"vertical",o=t.edgeCurve??"curved",{positions:r,sceneNodes:i,labels:s}=Sn(e,{...t,nodeWidth:t.nodeWidth??80,nodeHeight:t.nodeHeight??30},`var(--semiotic-surface, ${e.theme.semantic.surface??"#fff"})`),a=[];for(const t of e.edges){const i="string"==typeof t.source?t.source:t.source.id,s="string"==typeof t.target?t.target:t.target.id,c=r.get(i),l=r.get(s);if(!c||!l)continue;const u="vertical"===n?{x:c.x,y:c.y+c.h/2}:{x:c.x+c.w/2,y:c.y},d="vertical"===n?{x:l.x,y:l.y-l.h/2}:{x:l.x-l.w/2,y:l.y};if("line"===o)a.push({type:"line",x1:u.x,y1:u.y,x2:d.x,y2:d.y,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1},datum:t.data??t});else{const o=(u.y+d.y)/2,r=(u.x+d.x)/2,i="vertical"===n?`M${u.x},${u.y} C${u.x},${o} ${d.x},${o} ${d.x},${d.y}`:`M${u.x},${u.y} C${r},${u.y} ${r},${d.y} ${d.x},${d.y}`;a.push({type:"curved",pathD:i,style:{stroke:`var(--semiotic-border, ${e.theme.semantic.border??"#999"})`,strokeWidth:1,fill:"none"},datum:t.data??t})}}return{sceneNodes:i,sceneEdges:a,labels:s}},yd=require("react"),xd=require("react"),bd=require("./semiotic-network-placement.min.js"),wd=e=>{const t=e.config??{},n=t.edgeStyle??"polyline",o=new Map(e.edges.map(e=>[e,Nn(e)])),{positions:r,sceneNodes:i,labels:s,project:a}=Sn(e,{...t,nodeWidth:t.nodeWidth??100,nodeHeight:t.nodeHeight??36,labelAccessor:t.labelAccessor??"label"},`var(--semiotic-border, ${e.theme.semantic.border??"#888"})`,[...o.values()].flat()),c=t.edgeStroke??`var(--semiotic-border, ${e.theme.semantic.border??"#666"})`;for(let e=0;e<s.length;e++){const t=s[e],n=r.get(i[e].id);if(!n)continue;const o=Math.max(1,Math.floor(n.w/(.6*(t.fontSize??11))-2));t.text.length>o&&(t.text=t.text.slice(0,o-1)+"…")}const l=[],u=[];for(const t of e.edges){const e="string"==typeof t.source?t.source:t.source.id,i="string"==typeof t.target?t.target:t.target.id,s=r.get(e),d=r.get(i);if(!s||!d)continue;const h=o.get(t).map(a);if(h.length<2){const e=An(s,d),n=An(d,s);l.push(Cn(l.length,n,e,c,Math.min(7,d.w/4,d.h/3))),u.push({type:"line",x1:e.x,y1:e.y,x2:n.x,y2:n.y,style:{stroke:c,strokeWidth:1},datum:t.data??t});continue}const f=h[h.length-1],m=h.slice(0,-1).reverse().find(e=>e.x!==f.x||e.y!==f.y);if(m&&l.push(Cn(l.length,f,m,c,Math.min(7,d.w/4,d.h/3))),"smooth"===n&&h.length>=3){let e=`M${h[0].x},${h[0].y}`;for(let t=1;t<h.length-1;t++){const n=(h[t].x+h[t+1].x)/2,o=(h[t].y+h[t+1].y)/2;e+=` Q${h[t].x},${h[t].y} ${n},${o}`}const n=h[h.length-1];e+=` T${n.x},${n.y}`,u.push({type:"curved",pathD:e,style:{stroke:c,strokeWidth:1,fill:"none"},datum:t.data??t})}else{const e="M"+h.map(e=>`${e.x},${e.y}`).join(" L ");u.push({type:"curved",pathD:e,style:{stroke:c,strokeWidth:1,fill:"none"},datum:t.data??t})}}return{sceneNodes:i,sceneEdges:u,labels:s,overlays:l.length?(0,yd.createElement)("g",null,(0,yd.createElement)(bd.NetworkPerspectiveGround,{z:"top"},l)):null,perspective:"manual"}},Md=require("react"),vd=require("./semiotic-network-placement.min.js"),kd=e=>"number"==typeof e&&Number.isFinite(e),$d=e=>{const t=e.config??{},n=t.mode??"primary",o=t.dimOpacity??.14,r=(t,n=e.selection)=>n?.isActive&&!n.predicate(t)?o:1,i=e.nodes.map(e=>({id:e.id,data:ye(e),wrapper:e})).sort((e,t)=>je(e.id,t.id)),s=e.edges.map(e=>({source:Vn(e.source),target:Vn(e.target),data:ye(e),wrapper:e})).sort((e,t)=>je(e.source,t.source)||je(e.target,t.target)),a=Wn(i,s,e.dimensions.plot,t),c="source-rooted"===t.lineMode?Xn(i,s,t,e.resolveColor):void 0,l=Kn(s,t,c),u=new Map(i.map(e=>[e.id,/* @__PURE__ */new Set])),d=/* @__PURE__ */new Map;if(c)for(const[e,t]of c.byNode)for(const n of t)u.get(e)?.add(n.id),n.color&&d.set(n.id,n.color);const h=Math.max(1,t.lineWidth??("primary"===n?6:"compact"===n?3.5:2)),f=Math.max(0,t.lineGap??("primary"===n?2:"compact"===n?1:.5)),m=/* @__PURE__ */new Map,p=[];for(const n of l){const o=a.positions.get(n.source),i=a.positions.get(n.target);if(!o||!i)continue;const s=Qn(n,t),c=(s.length-1)/2*(h+f)+h/2;for(const e of[n.source,n.target])m.set(e,Math.max(m.get(e)??0,c));s.forEach((c,l)=>{u.get(n.source)?.add(c.descriptor.id),u.get(n.target)?.add(c.descriptor.id);const m=Jn(c.edge,a,t,c.edge.source!==n.source),g=Dn(m?[o,...m,i]:qn(o,i),(l-(s.length-1)/2)*(h+f)),y=eo(c.edge,c.descriptor),x=Un(c.descriptor,c.edge,t,e.resolveColor);d.has(c.descriptor.id)||d.set(c.descriptor.id,x),p.push({type:"curved",id:`${n.key}:${c.descriptor.id}`,label:`${c.descriptor.label??c.descriptor.id}: ${c.edge.source} to ${c.edge.target}`,pathD:Bn(g,t.cornerRadius??10),style:{fill:"none",stroke:x,strokeWidth:h,strokeLinecap:"round",opacity:r(y)},datum:y,accessibleDatum:y,accessibility:{label:`${c.descriptor.label??c.descriptor.id}, ${c.edge.source} to ${c.edge.target}`,tableFields:{line:c.descriptor.label??c.descriptor.id,source:c.edge.source,target:c.edge.target}}})})}const g=/* @__PURE__ */new Map,y=[],x=[],b=[],w=e=>String(Yn(e,t)||e.id);if("minimap"===n){const n=/* @__PURE__ */new Map;for(const e of i){const t=a.positions.get(e.id);if(!t)continue;const o=`${t.x}\0${t.y}`;let r=n.get(o);r||(r={x:t.x,y:t.y,nodes:[],lineIds:/* @__PURE__ */new Set,bundleRadius:0},n.set(o,r)),r.nodes.push(e);for(const t of u.get(e.id)??[])r.lineIds.add(t);r.bundleRadius=Math.max(r.bundleRadius,m.get(e.id)??0)}const o=[...n.values()].sort((e,t)=>e.x-t.x||e.y-t.y||je(e.nodes[0].id,t.nodes[0].id));for(const n of o){const o=Zn(n.lineIds,t),i=o.length>1||n.nodes.length>1||n.nodes.some(e=>!0===e.data.interchange||!0===e.data.transfer),s=i?t.interchangeRadius??Math.max(5,n.bundleRadius):t.stationRadius??Math.max(3.5,n.bundleRadius);for(const e of n.nodes)g.set(e.id,s);const a=n.nodes.map(w).join(" / "),c=n.nodes.map(e=>e.id).join("--"),l=1===n.nodes.length?n.nodes[0].data:be(e=>{e("id",c),e("label",a),e("stationIds",n.nodes.map(e=>e.id)),e("stations",n.nodes.map(e=>e.data)),e("lineIds",o),e("interchange",i)}),u={label:`${a}${i?", interchange":""}`,tableFields:{station:a,lines:o.join(", ")}};o.length<=1?y.push({type:"circle",cx:n.x,cy:n.y,r:s,style:{fill:(o[0]&&d.get(o[0]))??t.stationFill??"var(--semiotic-bg, white)",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:r(l)},datum:l,accessibleDatum:l,accessibility:u,id:c,label:a}):(o.forEach((t,i)=>{const a=-Math.PI/2+i/o.length*Math.PI*2,u=-Math.PI/2+(i+1)/o.length*Math.PI*2,h={type:"arc",cx:n.x,cy:n.y,innerR:0,outerR:s,startAngle:a,endAngle:u,style:{fill:d.get(t)??e.resolveColor(t),stroke:"none",opacity:r(l)},datum:null,id:`${c}:${t}`};y.push(h)}),y.push({type:"circle",cx:n.x,cy:n.y,r:s,style:{fill:"transparent",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:1.25,opacity:r(l)},datum:l,accessibleDatum:l,accessibility:u,id:c,label:a}))}}else for(const o of i){const i=a.positions.get(o.id);if(!i)continue;const s=Zn(u.get(o.id)??[],t),c=s.length>1||!0===o.data.interchange||!0===o.data.transfer,l=c?t.interchangeRadius??Math.max("primary"===n?7:5,m.get(o.id)??0):t.stationRadius??("primary"===n?4:2.75);g.set(o.id,l);const d=w(o),h=null!=t.renderStation;if(y.push({type:"circle",cx:i.x,cy:i.y,r:l,style:h?{fill:"transparent",stroke:"transparent"}:{fill:t.stationFill??"var(--semiotic-bg, white)",stroke:t.stationStroke??"var(--semiotic-text, #222)",strokeWidth:c?"primary"===n?3:2:1.5,opacity:r(o.data)},datum:o.data,accessibleDatum:o.data,accessibility:{label:`${d}${c?", interchange":""}`,tableFields:{station:d,lines:s.join(", ")}},id:o.id,label:d}),t.renderStation){const a={station:o.data,x:i.x,y:i.y,radius:l,lineIds:s,interchange:c,mode:n},u=t.renderStation(a);if(null!=u){if(e.perspective){const[e,n,o,r]=t.stationBounds?.(a)??[l,l,l,l];b.push("ground"===t.chromePlacement?{x:i.x-e,y:i.y-o,width:e+n,height:o+r,z:"top"}:{x:i.x,y:i.y,extent:[e,n,o,r]})}x.push((0,Md.createElement)("ground"===t.chromePlacement?vd.NetworkPerspectiveGround:vd.NetworkPerspectiveBillboard,{key:o.id,x:i.x,y:i.y,z:"top"},(0,Md.createElement)("g",{opacity:r(o.data),style:{pointerEvents:"none"}},u)))}}}const M=x.length>0?(0,Md.createElement)("g",{className:"transit-diagram-stations"},...x):void 0,v={sceneEdges:p,sceneNodes:y,overlays:M,perspective:"manual",...b.length?{perspectiveBounds:b}:{},labels:to(i,a.positions,u,g,e.dimensions.plot,"primary"===n?t:{...t,showLabels:!1})};if(x.length>0||"minimap"===n)return v;const k=(e,t)=>({opacity:r(e.datum,t)});return{...v,restyle:k,restyleEdge:k}},Sd=require("./semiotic-network-placement.min.js"),Id=require("./semiotic-network-placement.min.js"),Ad=require("react/jsx-runtime"),Cd=require("react/jsx-runtime"),Nd={"topic-source":"#1f7a8c","topic-sink":"#b4451f","topic-bridge":"#4b5a82",processor:"#34344a",unknown:"#5a5a6a"},jd={internal:"var(--semiotic-border, #6b6b7d)","cross-subtopology":"var(--semiotic-info, #6a8caf)","topic-bridge":"var(--semiotic-secondary, #8b78c4)",back:"var(--semiotic-danger, #e0556b)"},Fd=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.partitionAccessor??"partition",r=t.semanticAccessor??"semantic",i=t.labelAccessor??"label",s=t.storesAccessor??"stores",a=t.backEdgeAccessor??"isBackEdge",c=t.edgeTypeAccessor??"edgeType",l={...Nd,...t.partitionColors},u={...jd,...t.edgeColors},d=t.accentColor??"var(--semiotic-focus, #ffcc33)",h=t.borderColor??"var(--semiotic-border, #555)",f=t.dimOpacity??.14,m=t.edgeOpacity??.5,p=t.edgeWidth??1.25,g=t.backEdgeWidth??t.edgeWidth??1.5,y=!1!==t.showStoreChips,x=t.storeChipColor??"var(--semiotic-info, #6a8caf)",b=t.hullGroupAccessor,w=no(e.nodes,n,t),{nodeWidth:M,nodeHeight:v,lod:k}=w,$=t.reachableIds?new Set(t.reachableIds):null,S=t.selectedId??null,I=e.selection,A=/* @__PURE__ */new Map,C=/* @__PURE__ */new Map,N=[],j=null==b?null:/* @__PURE__ */new Map,F=[];for(const t of e.nodes){const e=t.id,n=String(ge(t,o,"processor")),a=String(ge(t,r,"processor")),c=String(ge(t,i,e)),u=uo(ge(t,s,[])),m=t.data??t,{cx:p,cy:g}=w.nodeBounds(t);if(!Number.isFinite(p)||!Number.isFinite(g))continue;A.set(e,{cx:p,cy:g});const y=$?$.has(e):null,x=I?.isActive?I.predicate(m):null,E=null!==y?!y:null!==x&&!x;C.set(e,E);const P=null!=S&&e===S,z=E&&!P?f:1,L=Object.prototype.hasOwnProperty.call(l,n)?l[n]:l.unknown;if("dot"===k){const t={type:"circle",cx:p,cy:g,r:M/2,style:{fill:L,opacity:z,stroke:P?d:"transparent",strokeWidth:P?2:0},datum:m,id:e,label:c};N.push(t)}else{const t={type:"rect",x:p-M/2,y:g-v/2,w:M,h:v,style:{fill:L,opacity:z,stroke:P?d:h,strokeWidth:P?3:1},datum:m,id:e,label:c};N.push(t),F.push({id:e,cx:p,cy:g,partition:n,semantic:a,label:c,stores:u,opacity:z,selected:P,node:m})}if(j&&null!=b){const n=ge(t,b,null);if(null!=n){const t=String(n),o=j.get(t)??[];o.push({id:e,x:p-M/2,y:g-v/2,w:M,h:v}),j.set(t,o)}}}const E=[],P=[];for(const o of e.edges){const e="string"==typeof o.source?o.source:o.source.id,r="string"==typeof o.target?o.target:o.target.id,i=A.get(e),s=A.get(r);if(!i||!s)continue;const l=Boolean(ge(o,a,null)??i.cx>=s.cx),d=String(ge(o,c,"internal")),h=C.get(e)||C.get(r)?Math.min(m,1.4*f):m,y=l?u.back:Object.prototype.hasOwnProperty.call(u,d)?u[d]:u.internal;let x,b,w;if(l){const t=Math.min(i.cy,s.cy)-v/2-n.y,o=n.y+n.height-Math.max(i.cy,s.cy)-v/2,a=(i.cy+s.cy)/2>n.y+n.height/2?t>8?-1:o>8?1:0:o>8?1:t>8?-1:0,c=Math.max(48,.28*Math.abs(i.cx-s.cx))+v,l=a<0?Math.max(n.y+1,Math.min(i.cy,s.cy)-v/2-c):a>0?Math.min(n.y+n.height-1,Math.max(i.cy,s.cy)+v/2+c):(i.cy+s.cy)/2,u=e===r,d=u?M/4:0,h=u&&"dot"===k?Math.sqrt((v/2)**2-d**2):v/2,f=i.cx-d,m=i.cy+Math.sign(l-i.cy)*h;b={x:s.cx+d,y:s.cy+Math.sign(l-s.cy)*h},w={x:b.x,y:l},x=`M${f},${m} C${f},${l} ${w.x},${w.y} ${b.x},${b.y}`}else{const e=Math.sign(s.cx-i.cx)||1,t=i.cx+e*M/2;b={x:s.cx-e*M/2,y:s.cy};const n=(t+b.x)/2;w={x:n,y:b.y},x=`M${t},${i.cy} C${n},${i.cy} ${n},${b.y} ${b.x},${b.y}`}!1!==t.showArrowheads&&P.push(Cn(P.length,b,w,y,Math.min(7,M/4,v/3),h));const $={type:"curved",pathD:x,style:{stroke:y,strokeWidth:l?g:p,fill:"none",opacity:h,...l?{strokeDasharray:"5 4",strokeLinecap:"round"}:{}},datum:o.data??o};E.push($)}const z="ground"===t.chromePlacement?Sd.NetworkPerspectiveGround:Sd.NetworkPerspectiveBillboard,L=0===F.length&&0===P.length?null:/* @__PURE__ */ /* @__PURE__ */(0,Cd.jsxs)("g",{children:[P.length>0&&/* @__PURE__ */ /* @__PURE__ */(0,Cd.jsx)(Sd.NetworkPerspectiveGround,{z:"top",children:P}),F.length>0&&/* @__PURE__ */ /* @__PURE__ */(0,Cd.jsx)("g",{className:"lineage-dag-glyphs",children:F.map(e=>/* @__PURE__ */ /* @__PURE__ */(0,Cd.jsx)(z,{x:e.cx,y:e.cy,z:"top",children:fo(e,{w:M,h:v,lod:k,partColors:l,chipColor:x,showChips:y,renderIcon:t.renderIcon,typeLabel:t.typeLabel})},e.id))})]}),O=j&&j.size>0?lo(j,{colors:t.hullColors,padding:null==t.hullPadding?16:Ae(t.hullPadding),radius:null==t.hullRadius?12:Ae(t.hullRadius),fillOpacity:ho(t.hullFillOpacity,.08),strokeOpacity:ho(t.hullStrokeOpacity,.4),label:t.hullLabel,resolveColor:e.resolveColor,dimById:C,selectedId:S,dimOpacity:f}):null,T=e.perspective?[...F.map(e=>"ground"===t.chromePlacement?{x:e.cx-M/2,y:e.cy-v/2,width:M,height:v,z:"top"}:{x:e.cx,y:e.cy,extent:[M/2,M/2,v/2,v/2]}),...j?co(j,{padding:null==t.hullPadding?16:Ae(t.hullPadding),label:t.hullLabel}):[]]:void 0,R=O?{sceneNodes:N,sceneEdges:E,backgrounds:O,overlays:L,perspective:"manual"}:{sceneNodes:N,sceneEdges:E,overlays:L,perspective:"manual"};return T?{...R,perspectiveBounds:T}:R};ru();var Ed=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}),Pd=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),zd={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"}]},Ld=(e,t)=>e.stepEntityCounts?.[t]??e.entityCount,Od=({datum:e},t)=>({opacity:!t?.isActive||t.predicate(e)||null!=e?.fromNodeId&&t.predicate({...e,nodeId:e.fromNodeId})?1:.2}),Td=e=>{const t=e.config.braid,n=e.dimensions.plot,o=t.atlas.spec.comparison?.partitions??[...new Set(t.groups.map(e=>e.partition))],r=t.groups.filter(e=>o.includes(e.partition)&&e.nodePath.length>0),i=[],s=[],a=[];if(0===r.length)return{sceneNodes:s,sceneEdges:i,labels:a};const c=new Set(r.map(e=>e.signature)),l=[...t.signatureOrder.filter(e=>c.delete(e)),...c],u=new Map(l.map((e,t)=>[e,t])),d=[...r].sort((e,t)=>u.get(e.signature)-u.get(t.signature)),h=o.map(e=>d.filter(t=>t.partition===e)),f=Mo(d),m=ee(f.map(e=>e.depth)),p=r.map(e=>ee(e.stepEntityCounts??[e.entityCount])),g=ee(p),y=e=>e<=0?0:Math.max(1,10*e/g),x=new Map(r.map((e,t)=>[e.id,y(p[t])])),b=n.height/o.length,{semantic:w}=e.theme,M=(e,t,n,o={})=>a.push({x:e,y:t,text:n,fill:w.text??"#333",fontSize:10,anchor:"middle",...o}),v={sourceRevision:t.atlas.provenance.sourceRevision,analysisRevision:t.atlas.analysisRevision,relationScopeId:"directed-admitted"},k=new Map(f.map(e=>{const t=h.map(t=>t.reduce((t,n)=>t+(e.signatures.has(n.signature)?x.get(n.id)+3:0),5));return[e.id,ee(t,24)]})),$=ee([...k.values()],24),S=Math.min(n.width/4,$/2+16),I=(n.width-2*S)/Math.max(m-1,1),A=e=>n.x+S+(e-1)*I,C=48+$/2,N=22+$/2,j=(e,t)=>e+C+(u.get(t)+.5)*Math.max(0,b-C-N)/l.length,F=(t,n,o,r,s)=>{const a=Ld(n,r),c=Ld(n,s),l=y(a),u=y(c);if(0===l&&0===u)return;const d=l!==u,h=e.resolveColor(n.signature);i.push({type:"curved",id:o,pathD:d?xo(t,l,u):Bn(t,8),style:{fill:d?h:"none",fillOpacity:1,stroke:d?"none":h,strokeWidth:d?0:l},datum:{...v,id:o,kind:"braid-track",nodeId:n.nodePath[s],fromNodeId:n.nodePath[r],groupId:n.id,signature:n.signature,partition:n.partition,entityCount:n.entityCount,fromStep:r,toStep:s,fromCount:a,toCount:c,falseRoot:!1},accessibleDatum:{journey:n.nodePath.join(" → "),partition:n.partition??"all",fromStep:r+1,toStep:s+1,fromCount:a,toCount:c}})};return o.forEach((e,t)=>{const o=n.y+t*b,r=h[t];if(e&&M(n.x+8,o+14,e,{fontSize:12,fontWeight:600,anchor:"start"}),0===r.length)return;for(let e=1;e<=m;e++)M(A(e),o+34,`Step ${e}`);const i=/* @__PURE__ */new Map;for(const t of f){const n=r.filter(e=>t.signatures.has(e.signature));if(0===n.length)continue;const a=A(t.depth),c=Ce([...t.signatures].map(e=>j(o,e))),l=bo(n.map(e=>x.get(e.id)));i.set(t.id,new Map(n.map((e,t)=>[e.id,{x:a,y:c+l[t],offset:l[t]}])));const u=k.get(t.id),d={state:t.state,step:t.depth,partition:e??"all"},h=`vertex:${e??"all"}:${t.id}`;s.push({type:"glyph",id:h,cx:a,cy:c,size:u,depth:t.depth,label:`${t.state} (step ${t.depth})`,glyph:zd,accent:w.border??"#888",style:{fill:w.surface??"#fff"},datum:{...v,id:h,nodeId:t.state,kind:"braid-step",prefixId:t.id,...d},accessibleDatum:d}),M(a,c+u/2+12,t.state,{anchorPoint:[a,c]})}for(const t of r){const n=wo(t.signature);for(let o=1;o<n.length;o++){const r=i.get(n[o-1]).get(t.id),s=i.get(n[o]).get(t.id),a=(r.x+s.x)/2-Math.sign(s.y-r.y)*s.offset,c=Math.abs(r.y-s.y)<1e-8?[r,s]:[r,{x:a,y:r.y},{x:a,y:s.y},s];F(c,t,`step:${e??"all"}:${n[o]}:${t.id}`,o-1,o)}}}),{sceneNodes:s,sceneEdges:i,labels:a,restyle:Od,restyleEdge:Od}},Rd=require("./semiotic-network-placement.min.js"),Wd=require("react/jsx-runtime"),qd={rect:"process",round:"process",stadium:"terminal",subroutine:"subprocess",cylinder:"database",circle:"connector",diamond:"decision",hexagon:"preparation",flag:"process"},Dd=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.direction??"TD",r="LR"===o||"RL"===o,i="BT"===o||"RL"===o,s=t.layerAccessor??"layer",a=t.rowAccessor??"row",c=t.labelAccessor??"label",l=t.shapeAccessor??"shape",u=t.edgeLabelAccessor??"label",d=t.nodeFill??"var(--semiotic-surface, #20242d)",h=t.nodeStroke??"var(--semiotic-border, #5a6573)",f=t.textColor??"var(--semiotic-text, #e6e6e6)",m=t.edgeColor??"var(--semiotic-text-secondary, #9aa0a6)",p=t.accentColor??"var(--semiotic-warning, #d49a00)";if(0===e.nodes.length)return{sceneNodes:[],overlays:null};const g=/* @__PURE__ */new Map;let y=0;for(const t of e.nodes){const e=Math.round(Number(ge(t,s,0)));y=Math.max(y,e);const n=g.get(e)||[];n.push(t),g.set(e,n)}const x=y+1;let b=1;for(const e of g.values())e.sort((e,t)=>Number(ge(e,a,0))-Number(ge(t,a,0))),b=Math.max(b,e.length);const w=r?n.width:n.height,M=r?n.height:n.width,v=w/x,k=M/(b+1),$=Math.max(44,Math.min(t.nodeWidth??150,r?v-36:.92*k)),S=Math.max(26,Math.min(t.nodeHeight??46,r?.7*k:.5*v)),I=(r?$:S)/2+6,A=Math.max(1,w-2*I),C=e=>{const t=x>1?(i?x-1-e:e)/(x-1)*A:A/2;return(r?n.x:n.y)+I+t},N=/* @__PURE__ */new Map,j=null!=e.perspective,F=[],E=[],P=[],z=[];for(const[e,t]of g)t.forEach((o,i)=>{const s=C(e),a=(u=i,m=t.length,(r?n.y:n.x)+(u+1)/(m+1)*M);var u,m;const g=r?s:a,y=r?a:s,x=String(ge(o,l,"rect")),b=String(ge(o,c,o.id));N.set(o.id,{cx:g,cy:y,shape:x});const w={id:o.id,name:b,type:qd[x]??"process",shape:x},v=vo(b,Math.max(4,Math.floor(($-12)/7)));if(j){const e="diamond"===x?p:h;F.push({type:"rect",x:g-$/2,y:y-S/2,w:$,h:S,style:{fill:d,stroke:e,strokeWidth:1.5},_hitPath:{pathD:So(x,g,y,$,S),transform:[0,0,1,1],fill:!0,strokeWidth:0},datum:w,id:o.id,label:b}),P.push({x:g,y:y,text:v,anchor:"middle",baseline:"middle",fontSize:13,fill:f,anchorPoint:[g,y]});const t=Io(x,g,y,$,S,e);return void(t&&z.push(/* @__PURE__ */ /* @__PURE__ */(0,Wd.jsx)("g",{children:t},`n-${o.id}`)))}F.push({type:"rect",x:g-$/2,y:y-S/2,w:$,h:S,style:{fill:"transparent",stroke:"transparent"},datum:w,id:o.id,label:b}),z.push(
|
|
149
146
|
/* @__PURE__ */
|
|
150
|
-
/* @__PURE__ */(0,
|
|
147
|
+
/* @__PURE__ */(0,Wd.jsxs)("g",{children:[ko(x,g,y,$,S,d,"diamond"===x?p:h,1.5),
|
|
151
148
|
/* @__PURE__ */
|
|
152
|
-
/* @__PURE__ */(0,
|
|
149
|
+
/* @__PURE__ */(0,Wd.jsx)("text",{x:g,y:y,textAnchor:"middle",dominantBaseline:"central",fontSize:13,fill:f,style:{pointerEvents:"none"},children:v})]},`n-${o.id}`))});const L=[];e.edges.forEach((e,t)=>{const n="string"==typeof e.source?e.source:e.source.id,o="string"==typeof e.target?e.target:e.target.id,i=N.get(n),s=N.get(o);if(!i||!s)return;const a=r?i.cx+$/2:i.cx,c=r?i.cy:i.cy+S/2,l=r?s.cx-$/2:s.cx,d=r?s.cy:s.cy-S/2,p=r?`M${a},${c} C${(a+l)/2},${c} ${(a+l)/2},${d} ${l},${d}`:`M${a},${c} C${a},${(c+d)/2} ${l},${(c+d)/2} ${l},${d}`,g=Math.atan2(d-c,l-a),y=l-9*Math.cos(g),x=d-9*Math.sin(g),b=4.5*-Math.sin(g),w=4.5*Math.cos(g),M=`${l},${d} ${y+b},${x+w} ${y-b},${x-w}`,v=ge(e,u,void 0),k=(a+l)/2,I=(c+d)/2;j&&E.push({type:"curved",pathD:p,style:{stroke:m,strokeWidth:1.4,fill:"none"},datum:e.data??e}),L.push(
|
|
153
150
|
/* @__PURE__ */
|
|
154
|
-
/* @__PURE__ */(0,
|
|
151
|
+
/* @__PURE__ */(0,Wd.jsxs)("g",{children:[!j&&/* @__PURE__ */ /* @__PURE__ */(0,Wd.jsx)("path",{d:p,fill:"none",stroke:m,strokeWidth:1.4}),
|
|
155
152
|
/* @__PURE__ */
|
|
156
|
-
/* @__PURE__ */(0,
|
|
153
|
+
/* @__PURE__ */(0,Wd.jsx)(Rd.NetworkPerspectiveGround,{z:"top",children:/* @__PURE__ */ /* @__PURE__ */(0,Wd.jsx)("polygon",{points:M,fill:m})}),"string"==typeof v&&v.length>0&&/* @__PURE__ */ /* @__PURE__ */(0,Wd.jsx)(Rd.NetworkPerspectiveBillboard,{x:k,y:I,children:/* @__PURE__ */ /* @__PURE__ */(0,Wd.jsxs)("g",{children:[
|
|
157
154
|
/* @__PURE__ */
|
|
158
|
-
/* @__PURE__ */(0,
|
|
155
|
+
/* @__PURE__ */(0,Wd.jsx)("rect",{x:k-6.5*v.length/2-4,y:I-9,width:6.5*v.length+8,height:18,rx:3,fill:"var(--semiotic-bg, #11151c)",stroke:h,strokeWidth:.75}),
|
|
159
156
|
/* @__PURE__ */
|
|
160
|
-
/* @__PURE__ */(0,Vd.jsx)("rect",{x:k-6.5*v.length/2-4,y:I-9,width:6.5*v.length+8,height:18,rx:3,fill:"var(--semiotic-bg, #11151c)",stroke:h,strokeWidth:.75}),
|
|
157
|
+
/* @__PURE__ */(0,Wd.jsx)("text",{x:k,y:I,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fill:f,style:{pointerEvents:"none"},children:v})]})})]},`e-${t}`))});const O=/* @__PURE__ */ /* @__PURE__ */(0,Wd.jsxs)("g",{className:"mermaid-dag",children:[L,j?/* @__PURE__ */ /* @__PURE__ */(0,Wd.jsx)(Rd.NetworkPerspectiveGround,{z:"top",children:z}):z]});return j?{sceneNodes:F,sceneEdges:E,labels:P,overlays:O,perspective:"manual"}:{sceneNodes:F,overlays:O}};Ol();var Bd=require("./semiotic-network-placement.min.js"),Yd=require("react/jsx-runtime"),Vd=require("react/jsx-runtime"),Gd=/* @__PURE__ */new gu(8),_d=/* @__PURE__ */new gu(8),Hd=e=>{const t=e.config||{},n=e.dimensions.plot;if(!e.nodes.length||n.width<=0||n.height<=0)return{sceneNodes:[]};const o=t.sourceAccessor??"source",r=t.targetAccessor??"target",i=t.labelAccessor??"label",s=t.categoryAccessor??"category",a=t.nodeRadius??4,c=t.cellGap??16,l=t.bandGap??22,u=t.headerHeight??34,d=t.minCellForFull??38,h=t.maxCellSize??120,f=t.minCellSize??12,m=t.fingerprintRounds??3,p=!1!==t.groupByMotif,g=t.sort??"frequency",y=/* @__PURE__ */new Map,x=/* @__PURE__ */new Map,b=[];for(const t of e.nodes){const e=t.id;null==e||y.has(e)||(b.push(e),y.set(e,t.data??t),x.set(e,String(ge(t,s,""))))}const w=[];for(const t of e.edges){const e=Do(t.source??ge(t,o,void 0)),n=Do(t.target??ge(t,r,void 0));null!=e&&null!=n&&w.push({source:e,target:n})}const{outAdj:M,inAdj:v,components:k,key:$}=Ho(b,w,m),S=/* @__PURE__ */new Map;if(p)for(const e of k){const t=S.get(e.motif);t?t.push(e):S.set(e.motif,[e])}else S.set("all",[...k].sort((e,t)=>t.nodeCount-e.nodeCount));const I=[...S.entries()];I.sort((e,t)=>"size"===g?t[1][0].nodeCount-e[1][0].nodeCount:"directedness"===g?Number(t[1][0].directed)-Number(e[1][0].directed):t[1].length-e[1].length);const A=ve([n.x,n.y,n.width,n.height,c,l,u,d,h,f,m,p,g,a,I.map(([e,t])=>e+":"+t.length).join(","),$]),C=_d.getOrCompute(A,()=>Xo(I,{plot:n,cellGap:c,bandGap:l,headerHeight:u,minCellForFull:d,maxCellSize:h,minCellSize:f,nodeRadius:a,outAdj:M,inAdj:v})),N=e.theme.semantic||{},j=t.convergeColor??N.info??"#4c78a8",F=t.branchColor??N.warning??"#e8853a",E=t.edgeColor??N.border??"#9aa0aa",P=t.colorMode??"directedness",z={predicate:e.selection?.isActive?e.selection.predicate:null,highlight:t.highlight??null,dimOpacity:.14},L=t=>"motif"===P?e.resolveColor(t.motif):"category"===P||t.directed?j:F,O=[],T=[];for(const t of C.cells){const n=t.component,o=L(n);if("full"===t.lod){for(const e of t.edges){const t={type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,style:{stroke:E,strokeWidth:1,opacity:.5*Math.max(Me(y.get(e.source),z),Me(y.get(e.target),z))},datum:null};T.push(t)}for(const n of t.nodes){const t=y.get(n.id),r=x.get(n.id),s="category"===P&&r?e.resolveColor(r):o,a={type:"symbol",cx:n.cx,cy:n.cy,size:Math.PI*n.r*n.r,symbolType:"circle",style:{fill:s,opacity:Me(t,z)},datum:t,id:n.id,label:String(ge(t,i,n.id))};O.push(a)}}else{const e=Se({id:`component-${JSON.stringify(n.ids)}`,motif:n.motif,shape:Vo(n),nodes:n.nodeCount,edges:n.edgeCount,sinks:n.sinkCount,sources:n.sourceCount,directedness:n.directed?"converging":"branching"}),r={type:"symbol",cx:t.cx,cy:t.cy,size:Math.PI*t.glyphR*t.glyphR,symbolType:n.directed?"circle":"diamond",style:{fill:o,opacity:n.ids.some(e=>1===Me(y.get(e),z))?1:.14,stroke:E,strokeWidth:.75},datum:e,id:String(e.id),label:Vo(n)};O.push(r)}}const R=!1!==t.showExemplars,W=!1!==t.showBandLabels,q=To(C.bands,!!e.perspective,R,W);return{sceneNodes:O,sceneEdges:T,overlays:Ro(q.bands,{convergeColor:j,branchColor:F,edgeColor:E,plot:n,showBandLabels:W,showExemplars:R,showLegend:!1!==t.showLegend&&"directedness"===P,textColor:N.text??"var(--semiotic-text, #1a1a1a)",subText:N.textSecondary??"var(--semiotic-text-secondary, #888)"}),perspective:"manual",...q.bounds?{perspectiveBounds:q.bounds}:{}}},Xd=jl(require("react")),Ud=require("./semiotic-network-placement.min.js"),Kd=e=>{const t=e.config??{},n=e.dimensions.plot,o=e.nodes.map((e,t)=>({id:e.id,datum:Ko(e),inputIndex:t})),r=new Map(o.map(e=>[e.id,e.inputIndex])),i=new Map((t.order??[]).map((e,t)=>[String(e),t]));if(o.sort((e,t)=>{const n=i.get(e.id),o=i.get(t.id);return null!=n&&null!=o?n-o:null!=n?-1:null!=o?1:(r.get(e.id)??0)-(r.get(t.id)??0)}),0===o.length)return{sceneNodes:[],sceneEdges:[],labels:[]};const s=Math.max(0,t.padding??18),a=Math.max(1,Math.min(n.width,n.height)-2*s),c=Math.min(Math.max(1,t.maxCellSize??120),a/o.length),l=c*o.length,u=n.x+(n.width-l)/2,d=n.y+(n.height-l)/2,h=Math.max(4,Math.min(.76*c,t.nodeSize??.56*c)),f=h/2,m=o.map((e,n)=>{const o="function"==typeof t.labelAccessor?t.labelAccessor(e.datum):String(ge(e.datum,t.labelAccessor??"label",e.id));return{id:e.id,label:o,datum:e.datum,index:n,cx:u+(n+.5)*c,cy:d+(n+.5)*c}}),p=new Map(m.map(e=>[e.id,e])),g=new Map(m.map(e=>[e.id,e.index])),y=or(e.edges,g,t),x=ir(rr(y,h,t),p,h,t),b=e.theme.semantic.info??e.theme.semantic.primary??e.resolveColor("adjacency-flow"),w=e.theme.semantic.text??"var(--semiotic-text, currentColor)",M=e.theme.semantic.surface??"var(--semiotic-bg, white)",v=e.theme.semantic.border??"var(--semiotic-border, currentColor)",k=e.theme.semantic.grid??v,$=e.theme.semantic.primary??e.resolveColor("adjacency-flow-node"),S=t.valueFormat??(e=>String(Math.round(100*e)/100)),I=Math.max(0,Math.min(t.cornerRadius??10,.22*c)),A=new Map(m.map(e=>[e.id,0])),C=new Map(m.map(e=>[e.id,0])),N=[],j=[],F=[];for(const n of y){const o=p.get(n.source),r=p.get(n.target);if(!o||!r)continue;A.set(o.id,(A.get(o.id)??0)+n.value),C.set(r.id,(C.get(r.id)??0)+n.value);const i=t.colorMode??"single",s="function"==typeof t.edgeColor?t.edgeColor(n.datum):void 0;n.color=s??("string"==typeof t.edgeColor?t.edgeColor:void 0)??("source"===i?e.resolveColor(n.source):"target"===i?e.resolveColor(n.target):"edge"===i?e.resolveColor(`${n.source}→${n.target}`):b);const a=x.get(`${n.key}:source`)??o.cy,l=x.get(`${n.key}:target`)??r.cx;let h,m,g,y,v,k,$;if(n.sourceIndex<n.targetIndex){const e=[o.cx+f,a],t=[l,r.cy-f];h=[e,[t[0],e[1]],t],m=t[0],g=e[1]+.68*(t[1]-e[1]),y=Math.PI/2,v=t[0]-I-4,k=e[1]-n.width/2-3,$="end"}else if(n.sourceIndex>n.targetIndex){const e=[o.cx-f,a],i=[l,r.cy+f];h=[e,[i[0],e[1]],i],m=i[0],g=e[1]+.68*(i[1]-e[1]),y=-Math.PI/2,v=i[0]+I+4,k=e[1]+n.width/2+(t.valueFontSize??10),$="start"}else{const e=u+(o.index+1)*c,t=d+(o.index+1)*c,i=Math.max(2,Math.min(6,.07*c)),s=Math.max(o.cx+f+2,e-i),p=Math.max(o.cy+f+2,t-i),x=[o.cx+f,a],b=[l,r.cy+f];h=[x,[s,x[1]],[s,p],[b[0],p],b],m=(s+b[0])/2,g=p,y=Math.PI,v=s-3,k=p-n.width/2-3,$="end"}const E=er(h,I);if(F.push({type:"curved",id:`adjacency-flow-${n.key}`,label:`${o.label} to ${r.label}: ${S(n.value,n.datum)}`,pathD:E,style:{fill:"none",stroke:n.color,strokeWidth:n.width,opacity:.82,cursor:"pointer"},datum:n.datum,accessibleDatum:n.datum,accessibility:{label:`${o.label} to ${r.label}, ${S(n.value,n.datum)}`,tableFields:{source:o.label,target:r.label,value:n.value,edges:n.edgeCount}}}),(t.showValues??!0)&&j.push({x:v,y:k,text:S(n.value,n.datum),anchor:$,fontSize:t.valueFontSize??Math.max(7,Math.min(10,.14*c)),fontWeight:650,fill:w,stroke:M,strokeWidth:3,paintOrder:"stroke"}),t.showArrows??!0){const e=Math.min(Math.max(0,t.arrowSize??14),Math.max(0,n.width-2));if(e<=2)continue;const o=Math.max(3,1.08*e);N.push(Xd.createElement("path",{key:`arrow-${n.key}`,className:"semiotic-adjacency-flow-arrow",d:tr(m,g,y,o,e),fill:t.arrowColor??"var(--semiotic-adjacency-flow-arrow-fill, rgba(255, 255, 255, 0.72))",stroke:"none","data-edge-width":n.width,"data-arrow-width":e,"aria-hidden":!0,focusable:!1,pointerEvents:"none",opacity:1}))}}const E=m.map(n=>{const o=("function"==typeof t.nodeColor?t.nodeColor(n.datum,n.index):void 0)??("string"==typeof t.nodeColor?t.nodeColor:"source"===(t.colorMode??"single")?e.resolveColor(n.id):$);return{type:"rect",id:n.id,label:n.label,x:n.cx-f,y:n.cy-f,w:h,h:h,style:{fill:o,stroke:t.nodeStroke??v,strokeWidth:1.25,cursor:"pointer"},datum:n.datum,accessibleDatum:n.datum,accessibility:{label:`${n.label}, step ${n.index+1}`,tableFields:{step:n.index+1,node:n.label,incoming:C.get(n.id)??0,outgoing:A.get(n.id)??0}}}}),P=Math.max(2,t.maxLabelLength??14),z=m.map(e=>{return{x:e.cx,y:e.cy,text:(n=e.label,o=P,n.length<=o?n:`${n.slice(0,Math.max(1,o-1))}…`),anchor:"middle",baseline:"middle",fontSize:t.labelFontSize??Math.max(6,Math.min(15,.34*h,h/Math.max(1.8,.62*e.label.length))),fontWeight:750,fill:t.nodeTextColor??M};var n,o});let L=null;if(t.showGrid??!0){const e=[];for(let t=0;t<=m.length;t+=1){const n=u+t*c,o=d+t*c;e.push(Xd.createElement("line",{key:`grid-v-${t}`,x1:n,y1:d,x2:n,y2:d+l,stroke:k,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}),Xd.createElement("line",{key:`grid-h-${t}`,x1:u,y1:o,x2:u+l,y2:o,stroke:k,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}))}L=Xd.createElement(Ud.NetworkPerspectiveGround,null,...e)}return{sceneEdges:F,sceneNodes:E,labels:[...j,...z],backgrounds:L,overlays:Xd.createElement(Ud.NetworkPerspectiveGround,{z:"top"},...N),perspective:"manual",...e.perspective&&L?{perspectiveBounds:[{x:u,y:d,width:l,height:l}]}:{}}},Zd=require("./semiotic-network-placement.min.js"),Qd=(e,t)=>e.length*t*.6,Jd=require("react/jsx-runtime"),eh=/* @__PURE__ */new gu(12),th=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.columnAccessor??"column",r=t.rowAccessor??"row",i=t.sizeAccessor,s=t.colorAccessor,a=t.symbolAccessor,c=t.shadeAccessor,l=t.markerAccessor,u=t.iconAccessor,d=t.defaultSymbol??"circle",[h,f]=t.sizeRange??[2,8],m=t.shadeStrength??.72,p=t.shadeReverse??!1,g=t.rowMode??"banded",y=t.cellSizing??"proportional",x=t.proportionExponent??1,b=t.columnGap??16,w=t.rowGap??12,M=t.packPadding??1,v=t.iterations??12,k=!1!==t.showEnclosures,$=!1!==t.showColumnHeaders,S=!1!==t.showRowLabels,I=$?t.headerHeight??26:0,A=S?t.labelWidth??66:0,C=t.callouts&&t.callouts.length>0?t.footerHeight??30:0,N=n.x+A,j=n.y+I,F=Math.max(1,n.width-A),E=Math.max(1,n.height-I-C),P=[];for(const t of e.nodes){const e=t.data??t;P.push({id:t.id,col:String(ge(t,o,"—")),row:String(ge(t,r,"—")),sizeVal:i?Number(ge(t,i,1)):1,colorKey:s?String(ge(t,s,"")):"",symVal:a?String(ge(t,a,"")):"",shadeVal:c?mr(ge(t,c,null)):NaN,marker:!!l&&Boolean(ge(t,l,!1)),iconVal:u?String(ge(t,u,"")):"",datum:e,size:0,packR:0,baseShape:"circle",iconShape:null})}if(0===P.length)return{sceneNodes:[]};let z=1/0,L=-1/0;if(i)for(const e of P)Number.isFinite(e.sizeVal)&&(e.sizeVal<z&&(z=e.sizeVal),e.sizeVal>L&&(L=e.sizeVal));t.sizeDomain&&([z,L]=t.sizeDomain),Number.isFinite(z)&&Number.isFinite(L)||(z=0,L=1);const O=e=>{if(L<=z)return(h+f)/2;const t=Math.sqrt(pr((e-z)/(L-z),0,1));return h+t*(f-h)};let T=1/0,R=-1/0;if(c)for(const e of P)Number.isFinite(e.shadeVal)&&(e.shadeVal<T&&(T=e.shadeVal),e.shadeVal>R&&(R=e.shadeVal));t.shadeDomain&&([T,R]=t.shadeDomain);const W=e=>{if(!c||!Number.isFinite(e)||R<=T)return.5;const t=pr((e-T)/(R-T),0,1);return p?1-t:t},q=t.colorMap,D=/* @__PURE__ */new Map,B=(t,n)=>{let o=D.get(t);return o||(o=ke(q&&Object.prototype.hasOwnProperty.call(q,t)&&"string"==typeof q[t]&&q[t]?q[t]:e.resolveColor(t),m),D.set(t,o)),o(n)},Y=/* @__PURE__ */new Map;if(t.symbolMap)for(const[e,n]of Object.entries(t.symbolMap))Y.set(e,n);let V=0;const G=e=>{if(!a)return d;let t=Y.get(e);return t||(t=Iu[V%Iu.length],V++,Y.set(e,t)),t},_=t.iconMap,H=e=>u&&_&&Object.prototype.hasOwnProperty.call(_,e)?_[e]??null:null,X=e=>u?"circle":G(e.symVal),U=t.maxAreaFraction??.4;let K=0;const Z=new Array(P.length),Q=new Array(P.length);for(let e=0;e<P.length;e++){const t=P[e],n=O(t.sizeVal);Z[e]=n,t.baseShape=X(t),t.iconShape=H(t.iconVal);const o=rt(t.baseShape,Math.PI*n*n);Q[e]=o,K+=Math.PI*o*o}const J=U*F*E,ee=K>J?Math.sqrt(J/K):1;for(let e=0;e<P.length;e++){const t=P[e],n=Z[e]*ee;t.size=Math.PI*n*n,t.packR=Q[e]*ee}const te=/* @__PURE__ */new Map,ne=/* @__PURE__ */new Map;for(const e of P)te.set(e.col,(te.get(e.col)??0)+1),ne.set(e.row,(ne.get(e.row)??0)+1);const oe=t.columnOrder?.filter(e=>te.has(e))??[...te.keys()].sort((e,t)=>(te.get(t)??0)-(te.get(e)??0)),re=t.rowOrder?.filter(e=>ne.has(e))??[...ne.keys()].sort((e,t)=>(ne.get(t)??0)-(ne.get(e)??0)),ie=ve([Math.round(n.x),Math.round(n.y),Math.round(n.width),Math.round(n.height),I,A,C,g,y,x,b,w,M,v,h,f,z,L,U,oe.join(","),re.join(","),P.length,br(P)]),se=eh.getOrCompute(ie,()=>yr(P,{columnOrder:oe,rowOrder:re,innerX:N,innerY:j,innerW:F,innerH:E,rowMode:g,cellSizing:y,proportionExponent:x,columnGap:b,rowGap:w,packPadding:M,iterations:v})),ae=e.selection,ce=ae?.isActive?ae.predicate:null,le=t.highlight??null,ue=t.dimOpacity??.16,de=t.markStroke,he=t.markStrokeWidth??0,fe=t.markerColor??"#ffffff",me=t.iconColor??"rgba(255,255,255,0.92)",pe=t.iconStrokeWidth??1,ye=t.iconScale??.72,xe=[],be=[],we=[];for(const e of P){const t=se.positions.get(e.id);if(!t)continue;const n=Me(e.datum,{highlight:le,predicate:ce,dimOpacity:ue}),o={type:"symbol",cx:t.px,cy:t.py,size:e.size,symbolType:e.baseShape,style:{fill:B(e.colorKey,W(e.shadeVal)),opacity:n,...de?{stroke:de,strokeWidth:he}:{}},datum:e.datum,id:e.id,label:String(e.id)};if(xe.push(o),e.iconShape){const o=Math.sqrt(e.size/Math.PI)*ye,r=rt(e.iconShape,100),i=r>0?o/r*100*(o/r):Math.PI*o*o;we.push({x:t.px,y:t.py,size:i,shape:e.iconShape,opacity:n})}e.marker&&n>ue+.001&&be.push({x:t.px,y:t.py,r:Math.max(1,.4*Math.sqrt(e.size/Math.PI))})}const $e=[];if(t.callouts&&t.callouts.length>0){const e=t.calloutColor??"var(--semiotic-text, #f4f4f8)",o=n.y+n.height-(C>0?.45*C:9),r=[];for(let e=0;e<t.callouts.length;e++){const n=t.callouts[e],o=P.find(e=>String(e.datum[n.field])===String(n.value));if(!o)continue;const i=se.positions.get(o.id);i&&r.push({c:n,ci:e,px:i.px,py:i.py,markR:Math.sqrt(o.size/Math.PI)})}const i=r.filter(e=>null==e.c.at).sort((e,t)=>e.px-t.px),s=/* @__PURE__ */new Map;i.forEach((e,t)=>{s.set(e.ci,N+(t+.5)/i.length*F)});for(const t of r){const r=t.c;let i=s.get(t.ci)??t.px,a=o;const c=r.connector??(s.has(t.ci)?"elbow":"straight");"object"==typeof r.at&&r.at?(i=r.at.x,a=r.at.y):"number"==typeof r.at&&(a=n.y+r.at*n.height),$e.push({keyId:`callout-${t.ci}`,markX:t.px,markY:t.py,labelX:i,labelY:a,label:r.label,connector:c,markRadius:Math.max(t.markR+3,7),stroke:e,color:e,fontSize:11,labelAnchor:"middle",labelBaseline:"auto"})}}const Se={markerDots:be,markerColor:fe,iconMarks:we,iconColor:me,iconStrokeWidth:pe,callouts:$e,plot:n,showEnclosures:k,showColumnHeaders:$,showRowLabels:S,enclosureColor:t.enclosureColor??"var(--semiotic-text, #f4f4f8)",enclosureRadius:t.enclosureRadius??9,enclosureOpacity:t.enclosureOpacity??.5,enclosureWidth:t.enclosureWidth??1.5,headerColor:t.headerColor??"var(--semiotic-text, #f4f4f8)",labelColor:t.labelColor??"var(--semiotic-text-secondary, #b9b9c8)",headerFontSize:t.headerFontSize??13,labelFontSize:t.labelFontSize??11,headerY:n.y+.62*I,labelX:n.x+A-10,columnLabel:t.columnLabel,rowLabel:t.rowLabel};return{sceneNodes:xe,overlays:wr(se,Se),perspective:"manual",...e.perspective?{perspectiveBounds:fr(se,Se)}:{}}},nh=4,oh=jl(require("react")),rh=e=>{const t=e.config,{plot:n}=e.dimensions;if(n.width<=0||n.height<=0)return{nodes:[]};const o=pe(t.categoryAccessor),r=pe(t.stackBy),i=e=>{const n="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor],o=Number(n);return Number.isFinite(o)&&o>0?o:0},s=t.gutter??2,a="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",c="string"==typeof t.stackBy?t.stackBy:"stack",l="string"==typeof t.valueAccessor?t.valueAccessor:"value",u=(e,t,n)=>be(o=>{o("category",e),o("stack",t),o("value",n),"category"!==a&&o(a,e),"stack"!==c&&o(c,t),"value"!==l&&o(l,n)}),d=!1!==t.showCategoryLabels,h=t.labelPadding??(d?22:0),f=Math.max(0,n.height-h),m=[],p=/* @__PURE__ */new Map,g=[],y=/* @__PURE__ */new Set,x=/* @__PURE__ */new Map;for(const t of e.data){const e=String(o(t)),n=String(r(t)),s=i(t);p.has(e)||(m.push(e),p.set(e,0),x.set(e,/* @__PURE__ */new Map)),y.has(n)||(y.add(n),g.push(n)),p.set(e,(p.get(e)??0)+s);const a=x.get(e);a.set(n,(a.get(n)??0)+s)}const b=t.categoryOrder?vr(t.categoryOrder,m,e=>p.has(e)):m,w=t.stackOrder?vr(t.stackOrder,g,()=>!0):g,M=b.reduce((e,t)=>e+(p.get(t)??0),0);if(M<=0)return{nodes:[]};const v=s*Math.max(0,b.length-1),k=Math.max(0,n.width-v),$=[],S=[];let I=n.x;for(const t of b){const o=p.get(t)??0,r=o/M*k;if(r<=0)continue;S.push({cat:t,x:I,w:r});const i=x.get(t);let a=n.y;for(const n of w){const s=i.get(n)??0;if(s<=0)continue;const c=s/o*f;$.push({type:"rect",x:I,y:a,w:r,h:c,style:{fill:e.resolveColor(n),stroke:"none"},datum:u(t,n,s),group:n}),a+=c}I+=r+s}return{nodes:$,overlays:d&&S.length>0?Mr(S,n.y+f+4,`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`):null}},ih=jl(require("react")),sh=e=>{const t=e.config,{plot:n}=e.dimensions;if(n.width<=0||n.height<=0||0===e.data.length)return{nodes:[]};const o=Math.max(1,Ae(t.rowHeight??28)),r=Ae(t.rowGap??12),i=!1!==t.showLabels,s=i?Ae(t.labelWidth??120):0,a=!1!==t.showTicks,c=a?14:0,l=t.tickFormat??(e=>e.toLocaleString()),u=n.x+s,d=Math.max(0,n.width-s),h=pe(t.categoryAccessor),f=pe(t.valueAccessor),m=pe(t.targetAccessor),p=pe(t.rangesAccessor),g="string"==typeof t.categoryAccessor?t.categoryAccessor:"metric",y="string"==typeof t.valueAccessor?t.valueAccessor:"value",x="string"==typeof t.targetAccessor?t.targetAccessor:"target",b=t.actualColor??e.theme.semantic.primary??"#3b6cb1",w=e.theme.semantic.text??"currentColor",M=e.theme.semantic.textSecondary??"#888",v=e.theme.semantic.surface??"#e8eaed",k=e.theme.semantic.grid??"#cdd1d6",$=e.theme.semantic.border??"#a3a8af",S=t.targetColor??`var(--semiotic-text, ${w})`,I=[`var(--semiotic-surface, ${v})`,`var(--semiotic-grid, ${k})`,`var(--semiotic-border, ${$})`],A=`var(--semiotic-text, ${w})`,C=`var(--semiotic-text-secondary, ${M})`,N=[],j=e.data.map(e=>{const t=p(e),n=Array.isArray(t)?t.map(Ae).sort((e,t)=>e-t):[],o=Ae(f(e)),r=Ae(m(e));return{label:h(e),ranges:n,actual:o,target:r,maxVal:Math.max(o,r,...n)}}).filter(e=>e.maxVal>0),F=e=>d>0?Math.max(0,Math.floor((e+r)/(o+r+c))):0,E=Math.min(j.length,F(n.height))<e.data.length,P=j.slice(0,F(n.height-(E?18:0))).map((e,t)=>({...e,yTop:n.y+t*(o+r+c)}));for(const{yTop:e,label:t,ranges:n,actual:r,target:i,maxVal:s}of P){const a=e=>u+e/s*d,c=e=>be(n=>{n("metric",t),"metric"!==g&&n(g,t),e(n)});let l=u;for(let t=0;t<n.length;t++){const r=a(n[t]),i=r-l;i>0&&N.push({type:"rect",x:l,y:e,w:i,h:o,style:{fill:I[Math.min(t,I.length-1)],stroke:"none"},datum:c(e=>{e("range",t),e("rangeValue",n[t]),e("kind","range")}),group:`range-${t}`}),l=r}const h=Math.min(o,Math.max(6,Math.floor(.45*o)));N.push({type:"rect",x:u,y:e+(o-h)/2,w:a(r)-u,h:h,style:{fill:b,stroke:"none"},datum:c(e=>{e("value",r),e("kind","actual"),"value"!==y&&e(y,r)}),group:"actual"});const f=3,m=.8*o;N.push({type:"rect",x:a(i)-f/2,y:e+(o-m)/2,w:f,h:m,style:{fill:S,stroke:"none"},datum:c(e=>{e("target",i),e("kind","target"),"target"!==x&&e(x,i)}),group:"target"})}const z=[],L=Fe(n,P.length,e.data.length,"rows","Rows without positive values or enough plot space are omitted.");L&&z.push(L);for(let e=0;e<P.length;e++){const t=P[e],r=t.yTop+o/2;if(i&&z.push(Po({keyId:`bullet-label-${e}`,text:t.label,x:n.x+s-8,y:r,anchor:"end",baseline:"middle",fontSize:13,fontWeight:500,color:A})),a){const n=5,r=t.yTop+o+2;for(let o=0;o<n;o++){const i=t.maxVal*o/(n-1),s=u+i/t.maxVal*d;z.push(ih.createElement("line",{key:`bullet-tick-${e}-${o}`,x1:s,x2:s,y1:r,y2:r+3,stroke:C,strokeWidth:1}),Po({keyId:`bullet-ticktext-${e}-${o}`,text:l(i),x:s,y:r+12,anchor:0===o?"start":o===n-1?"end":"middle",baseline:"auto",fontSize:10,color:C}))}}}return{nodes:N,overlays:z.length>0?ih.createElement(ih.Fragment,null,...z):null}},ah=jl(require("react")),ch=require("d3-scale"),lh=e=>{const t=e.config,{plot:n}=e.dimensions,o=t.fields??[];if(o.length<2||n.width<=0||n.height<=0)return{nodes:[]};if(0===e.data.length)return{nodes:[]};const r=/* @__PURE__ */Object.create(null);for(const n of o){const o=t.domains&&Object.prototype.hasOwnProperty.call(t.domains,n)?t.domains[n]:void 0;if(Array.isArray(o)&&o.length>=2&&"number"==typeof o[0]&&Number.isFinite(o[0])&&"number"==typeof o[1]&&Number.isFinite(o[1])){r[n]=[o[0],o[1]];continue}let i=1/0,s=-1/0;for(const t of e.data){const e=Number(t[n]);Number.isFinite(e)&&(e<i&&(i=e),e>s&&(s=e))}if(Number.isFinite(i)&&Number.isFinite(s))if(i===s){const e=Math.max(.01*Math.abs(i),.5);r[n]=[i-e,s+e]}else r[n]=[i,s];else r[n]=[0,1]}const i=!1!==t.showAxes,s=i?t.axisLabelPadding??24:8,a=i?18:8,c=o.map(e=>(0,ch.scaleLinear)().domain(r[e]).range([n.y+n.height-a,n.y+s])),l=o.map((e,t)=>1===o.length?n.x+n.width/2:n.x+t/(o.length-1)*n.width),u=t.colorBy?"function"==typeof t.colorBy?t.colorBy:e=>String(e[t.colorBy]??""):null,d=t.opacity??.45,h=t.strokeWidth??1.25,f=e.theme.semantic.primary??"#3b6cb1",m=t.dimmedOpacity??.08,p=t.highlightFn,g=[],y=[];for(const n of e.data){const r=u?e.resolveColor(String(u(n))):f,i=!p||p(n),s=Me(n,{predicate:p,baseOpacity:d,dimOpacity:m,brighten:.4}),a=i?y:g;for(let e=0;e<o.length-1;e++){const t=Number(n[o[e]]),u=Number(n[o[e+1]]);if(!Number.isFinite(t)||!Number.isFinite(u))continue;const d={type:"connector",x1:l[e],y1:c[e](t),x2:l[e+1],y2:c[e+1](u),style:{stroke:r,strokeWidth:p&&i?h+.75:h,opacity:s,fill:"none"},datum:n};a.push(d)}if(t.showPoints)for(let e=0;e<o.length;e++){const t=Number(n[o[e]]);if(!Number.isFinite(t))continue;const i={type:"point",x:l[e],y:c[e](t),r:2.5,style:{fill:r,stroke:"none",opacity:Math.min(1,s+.3)},datum:n};a.push(i)}}let x=null;if(i){const i=`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=n.y+s,f=n.y+n.height-a,m=[];for(let e=0;e<o.length;e++){const a=o[e],p=l[e],g=t.tickFormat&&Object.prototype.hasOwnProperty.call(t.tickFormat,a)?t.tickFormat[a]:void 0,y="function"==typeof g?g:e=>e.toLocaleString();m.push(ah.createElement("line",{key:`pc-axis-line-${e}`,x1:p,x2:p,y1:h,y2:f,stroke:i,strokeWidth:1})),m.push(Po({keyId:`pc-axis-label-${e}`,text:a,x:p,y:n.y+s-8,anchor:"middle",baseline:"auto",fontSize:12,fontWeight:600,color:u}));const[x,b]=r[a],w=5;for(let t=0;t<w;t++){const n=x+(b-x)*t/(w-1),o=c[e](n);m.push(ah.createElement("line",{key:`pc-tick-${e}-${t}`,x1:p-3,x2:p+3,y1:o,y2:o,stroke:i,strokeWidth:1}),Po({keyId:`pc-ticktext-${e}-${t}`,text:y(n),x:p+6,y:o+3,anchor:"start",baseline:"auto",fontSize:10,color:d}))}}x=ah.createElement(ah.Fragment,null,...m)}return{nodes:g.concat(y),overlays:x}},uh=require("react/jsx-runtime"),dh=1.75,hh="#222222",fh=2e3,mh={height:15.5,topRadius:4.75,bottomRadius:3.75},ph=e=>{const t=e.config,{plot:n}=e.dimensions;if(!Number.isFinite(n.width)||!Number.isFinite(n.height)||n.width<=0||n.height<=0)return{nodes:[]};const o=pe(t.categoryAccessor??"name"),r=pe(t.teaVolumeAccessor??"teaVolume"),i=pe(t.bobaVolumeAccessor??"bobaVolume"),s=pe(t.iceVolumeAccessor??"iceVolume"),a=pe(t.cupHeightAccessor??"cupHeight"),c=pe(t.cupTopRadiusAccessor??"cupTopRadius"),l=pe(t.cupBottomRadiusAccessor??"cupBottomRadius"),u=pe(t.bobaRadiusAccessor??"bobaRadius"),d=Pr(t.cupWidthRatio,.82),h=e.scales.o,f=h.bandwidth(),m=Math.max(1,n.height-26-8),p=n.y+8,g=[],y=[];for(const t of e.data){const n=String(o(t)),x=h(n);if(null==x)continue;let b={height:Pr(a(t),mh.height),topRadius:Pr(c(t),mh.topRadius),bottomRadius:Pr(l(t),mh.bottomRadius)};const w=Sr(b,b.height);(!Number.isFinite(w)||w<=0)&&(b=mh);let M=Pr(u(t),.6);const v=Math.max(0,Er(r(t),450)),k=Math.max(0,Er(i(t),110)),$=Math.max(0,Er(s(t),135));let S=Math.PI*M*M;(!Number.isFinite(S)||S<=0||!Number.isFinite(k/S))&&(M=.6,S=Math.PI*M*M);const I=Math.floor(k/S),A=Math.min(k,I*S),C=Math.floor($/5.359375),N=Math.min($,C*dh*dh*dh),j=v+A+N;if(!Number.isFinite(j))throw new RangeError("Boba total volume exceeds the finite numeric range");const F=Ir(b,j),E=Math.min(b.height,Math.max(0,F)),P=$r(b,E),{pearls:z,layers:L}=Nr(b,M,I),O=E,T=Fr(b,L*M*2,O,C),R=b.height-20.32,W=Math.min(0,R),q=b.height-W,D=2*(b.topRadius+1),B=Math.min(f*d/D,m/q),Y=x+f/2,V=e=>Y+e*B,G=e=>p+(e-W)*B,_=V(-(b.topRadius+1)),H=V(b.topRadius+1),X=G(W),U=G(b.height),K=Se({name:n,teaVolume:v,bobaVolume:Math.round(A),iceVolume:Math.round(N),totalVolume:Math.round(j),numBobas:I,numIce:C,renderedBobas:z.length,renderedIce:T.length,kind:"boba cup"});g.push({type:"rect",x:_,y:X,w:Math.max(1,H-_),h:Math.max(1,U-X),style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:K,group:n,_transitionKey:`boba-${Ie(n)}`});const Z=b.height-O,Q=Ie(n),J=e.resolveColor(n);y.push(
|
|
161
158
|
/* @__PURE__ */
|
|
162
|
-
/* @__PURE__ */(0,Vd.jsx)("text",{x:k,y:I,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fill:f,style:{pointerEvents:"none"},children:v})]})})]},`e-${t}`))});const O=/* @__PURE__ */ /* @__PURE__ */(0,Vd.jsxs)("g",{className:"mermaid-dag",children:[L,j?/* @__PURE__ */ /* @__PURE__ */(0,Vd.jsx)(En,{z:"top",children:z}):z]});return j?{sceneNodes:F,sceneEdges:E,labels:P,overlays:O,perspective:"manual"}:{sceneNodes:F,overlays:O}};Dl();var Hd=require("react/jsx-runtime"),Xd=require("react/jsx-runtime"),Ud=/* @__PURE__ */new Mu(8),Kd=/* @__PURE__ */new Mu(8),Zd=e=>{const t=e.config||{},n=e.dimensions.plot;if(!e.nodes.length||n.width<=0||n.height<=0)return{sceneNodes:[]};const o=t.sourceAccessor??"source",r=t.targetAccessor??"target",i=t.labelAccessor??"label",s=t.categoryAccessor??"category",a=t.nodeRadius??4,c=t.cellGap??16,l=t.bandGap??22,u=t.headerHeight??34,d=t.minCellForFull??38,h=t.maxCellSize??120,f=t.minCellSize??12,m=t.fingerprintRounds??3,p=!1!==t.groupByMotif,g=t.sort??"frequency",y=/* @__PURE__ */new Map,x=/* @__PURE__ */new Map,b=[];for(const t of e.nodes){const e=t.id;null==e||y.has(e)||(b.push(e),y.set(e,t.data??t),x.set(e,String(ge(t,s,""))))}const w=[];for(const t of e.edges){const e=_o(t.source??ge(t,o,void 0)),n=_o(t.target??ge(t,r,void 0));null!=e&&null!=n&&w.push({source:e,target:n})}const{outAdj:M,inAdj:v,components:k,key:$}=Qo(b,w,m),S=/* @__PURE__ */new Map;if(p)for(const e of k){const t=S.get(e.motif);t?t.push(e):S.set(e.motif,[e])}else S.set("all",[...k].sort((e,t)=>t.nodeCount-e.nodeCount));const I=[...S.entries()];I.sort((e,t)=>"size"===g?t[1][0].nodeCount-e[1][0].nodeCount:"directedness"===g?Number(t[1][0].directed)-Number(e[1][0].directed):t[1].length-e[1].length);const A=ve([n.x,n.y,n.width,n.height,c,l,u,d,h,f,m,p,g,a,I.map(([e,t])=>e+":"+t.length).join(","),$]),C=Kd.getOrCompute(A,()=>Jo(I,{plot:n,cellGap:c,bandGap:l,headerHeight:u,minCellForFull:d,maxCellSize:h,minCellSize:f,nodeRadius:a,outAdj:M,inAdj:v})),N=e.theme.semantic||{},j=t.convergeColor??N.info??"#4c78a8",F=t.branchColor??N.warning??"#e8853a",E=t.edgeColor??N.border??"#9aa0aa",P=t.colorMode??"directedness",z={predicate:e.selection?.isActive?e.selection.predicate:null,highlight:t.highlight??null,dimOpacity:.14},L=t=>"motif"===P?e.resolveColor(t.motif):"category"===P||t.directed?j:F,O=[],T=[];for(const t of C.cells){const n=t.component,o=L(n);if("full"===t.lod){for(const e of t.edges){const t={type:"line",x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,style:{stroke:E,strokeWidth:1,opacity:.5*Math.max(Me(y.get(e.source),z),Me(y.get(e.target),z))},datum:null};T.push(t)}for(const n of t.nodes){const t=y.get(n.id),r=x.get(n.id),s="category"===P&&r?e.resolveColor(r):o,a={type:"symbol",cx:n.cx,cy:n.cy,size:Math.PI*n.r*n.r,symbolType:"circle",style:{fill:s,opacity:Me(t,z)},datum:t,id:n.id,label:String(ge(t,i,n.id))};O.push(a)}}else{const e=Se({id:`component-${JSON.stringify(n.ids)}`,motif:n.motif,shape:Uo(n),nodes:n.nodeCount,edges:n.edgeCount,sinks:n.sinkCount,sources:n.sourceCount,directedness:n.directed?"converging":"branching"}),r={type:"symbol",cx:t.cx,cy:t.cy,size:Math.PI*t.glyphR*t.glyphR,symbolType:n.directed?"circle":"diamond",style:{fill:o,opacity:n.ids.some(e=>1===Me(y.get(e),z))?1:.14,stroke:E,strokeWidth:.75},datum:e,id:String(e.id),label:Uo(n)};O.push(r)}}const R=!1!==t.showExemplars,W=!1!==t.showBandLabels,q=Bo(C.bands,!!e.perspective,R,W);return{sceneNodes:O,sceneEdges:T,overlays:Yo(q.bands,{convergeColor:j,branchColor:F,edgeColor:E,plot:n,showBandLabels:W,showExemplars:R,showLegend:!1!==t.showLegend&&"directedness"===P,textColor:N.text??"var(--semiotic-text, #1a1a1a)",subText:N.textSecondary??"var(--semiotic-text-secondary, #888)"}),perspective:"manual",...q.bounds?{perspectiveBounds:q.bounds}:{}}},Qd=Ll(require("react")),Jd=e=>{const t=e.config??{},n=e.dimensions.plot,o=e.nodes.map((e,t)=>({id:e.id,datum:tr(e),inputIndex:t})),r=new Map(o.map(e=>[e.id,e.inputIndex])),i=new Map((t.order??[]).map((e,t)=>[String(e),t]));if(o.sort((e,t)=>{const n=i.get(e.id),o=i.get(t.id);return null!=n&&null!=o?n-o:null!=n?-1:null!=o?1:(r.get(e.id)??0)-(r.get(t.id)??0)}),0===o.length)return{sceneNodes:[],sceneEdges:[],labels:[]};const s=Math.max(0,t.padding??18),a=Math.max(1,Math.min(n.width,n.height)-2*s),c=Math.min(Math.max(1,t.maxCellSize??120),a/o.length),l=c*o.length,u=n.x+(n.width-l)/2,d=n.y+(n.height-l)/2,h=Math.max(4,Math.min(.76*c,t.nodeSize??.56*c)),f=h/2,m=o.map((e,n)=>{const o="function"==typeof t.labelAccessor?t.labelAccessor(e.datum):String(ge(e.datum,t.labelAccessor??"label",e.id));return{id:e.id,label:o,datum:e.datum,index:n,cx:u+(n+.5)*c,cy:d+(n+.5)*c}}),p=new Map(m.map(e=>[e.id,e])),g=new Map(m.map(e=>[e.id,e.index])),y=cr(e.edges,g,t),x=ur(lr(y,h,t),p,h,t),b=e.theme.semantic.info??e.theme.semantic.primary??e.resolveColor("adjacency-flow"),w=e.theme.semantic.text??"var(--semiotic-text, currentColor)",M=e.theme.semantic.surface??"var(--semiotic-bg, white)",v=e.theme.semantic.border??"var(--semiotic-border, currentColor)",k=e.theme.semantic.grid??v,$=e.theme.semantic.primary??e.resolveColor("adjacency-flow-node"),S=t.valueFormat??(e=>String(Math.round(100*e)/100)),I=Math.max(0,Math.min(t.cornerRadius??10,.22*c)),A=new Map(m.map(e=>[e.id,0])),C=new Map(m.map(e=>[e.id,0])),N=[],j=[],F=[];for(const n of y){const o=p.get(n.source),r=p.get(n.target);if(!o||!r)continue;A.set(o.id,(A.get(o.id)??0)+n.value),C.set(r.id,(C.get(r.id)??0)+n.value);const i=t.colorMode??"single",s="function"==typeof t.edgeColor?t.edgeColor(n.datum):void 0;n.color=s??("string"==typeof t.edgeColor?t.edgeColor:void 0)??("source"===i?e.resolveColor(n.source):"target"===i?e.resolveColor(n.target):"edge"===i?e.resolveColor(`${n.source}→${n.target}`):b);const a=x.get(`${n.key}:source`)??o.cy,l=x.get(`${n.key}:target`)??r.cx;let h,m,g,y,v,k,$;if(n.sourceIndex<n.targetIndex){const e=[o.cx+f,a],t=[l,r.cy-f];h=[e,[t[0],e[1]],t],m=t[0],g=e[1]+.68*(t[1]-e[1]),y=Math.PI/2,v=t[0]-I-4,k=e[1]-n.width/2-3,$="end"}else if(n.sourceIndex>n.targetIndex){const e=[o.cx-f,a],i=[l,r.cy+f];h=[e,[i[0],e[1]],i],m=i[0],g=e[1]+.68*(i[1]-e[1]),y=-Math.PI/2,v=i[0]+I+4,k=e[1]+n.width/2+(t.valueFontSize??10),$="start"}else{const e=u+(o.index+1)*c,t=d+(o.index+1)*c,i=Math.max(2,Math.min(6,.07*c)),s=Math.max(o.cx+f+2,e-i),p=Math.max(o.cy+f+2,t-i),x=[o.cx+f,a],b=[l,r.cy+f];h=[x,[s,x[1]],[s,p],[b[0],p],b],m=(s+b[0])/2,g=p,y=Math.PI,v=s-3,k=p-n.width/2-3,$="end"}const E=ir(h,I);if(F.push({type:"curved",id:`adjacency-flow-${n.key}`,label:`${o.label} to ${r.label}: ${S(n.value,n.datum)}`,pathD:E,style:{fill:"none",stroke:n.color,strokeWidth:n.width,opacity:.82,cursor:"pointer"},datum:n.datum,accessibleDatum:n.datum,accessibility:{label:`${o.label} to ${r.label}, ${S(n.value,n.datum)}`,tableFields:{source:o.label,target:r.label,value:n.value,edges:n.edgeCount}}}),(t.showValues??!0)&&j.push({x:v,y:k,text:S(n.value,n.datum),anchor:$,fontSize:t.valueFontSize??Math.max(7,Math.min(10,.14*c)),fontWeight:650,fill:w,stroke:M,strokeWidth:3,paintOrder:"stroke"}),t.showArrows??!0){const e=Math.min(Math.max(0,t.arrowSize??14),Math.max(0,n.width-2));if(e<=2)continue;const o=Math.max(3,1.08*e);N.push(Qd.createElement("path",{key:`arrow-${n.key}`,className:"semiotic-adjacency-flow-arrow",d:sr(m,g,y,o,e),fill:t.arrowColor??"var(--semiotic-adjacency-flow-arrow-fill, rgba(255, 255, 255, 0.72))",stroke:"none","data-edge-width":n.width,"data-arrow-width":e,"aria-hidden":!0,focusable:!1,pointerEvents:"none",opacity:1}))}}const E=m.map(n=>{const o=("function"==typeof t.nodeColor?t.nodeColor(n.datum,n.index):void 0)??("string"==typeof t.nodeColor?t.nodeColor:"source"===(t.colorMode??"single")?e.resolveColor(n.id):$);return{type:"rect",id:n.id,label:n.label,x:n.cx-f,y:n.cy-f,w:h,h:h,style:{fill:o,stroke:t.nodeStroke??v,strokeWidth:1.25,cursor:"pointer"},datum:n.datum,accessibleDatum:n.datum,accessibility:{label:`${n.label}, step ${n.index+1}`,tableFields:{step:n.index+1,node:n.label,incoming:C.get(n.id)??0,outgoing:A.get(n.id)??0}}}}),P=Math.max(2,t.maxLabelLength??14),z=m.map(e=>{return{x:e.cx,y:e.cy,text:(n=e.label,o=P,n.length<=o?n:`${n.slice(0,Math.max(1,o-1))}…`),anchor:"middle",baseline:"middle",fontSize:t.labelFontSize??Math.max(6,Math.min(15,.34*h,h/Math.max(1.8,.62*e.label.length))),fontWeight:750,fill:t.nodeTextColor??M};var n,o});let L=null;if(t.showGrid??!0){const e=[];for(let t=0;t<=m.length;t+=1){const n=u+t*c,o=d+t*c;e.push(Qd.createElement("line",{key:`grid-v-${t}`,x1:n,y1:d,x2:n,y2:d+l,stroke:k,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}),Qd.createElement("line",{key:`grid-h-${t}`,x1:u,y1:o,x2:u+l,y2:o,stroke:k,strokeWidth:.75,strokeDasharray:"2 5",opacity:.5,pointerEvents:"none"}))}L=Qd.createElement(En,null,...e)}return{sceneEdges:F,sceneNodes:E,labels:[...j,...z],backgrounds:L,overlays:Qd.createElement(En,{z:"top"},...N),perspective:"manual",...e.perspective&&L?{perspectiveBounds:[{x:u,y:d,width:l,height:l}]}:{}}},eh=(e,t)=>e.length*t*.6,th=require("react/jsx-runtime"),nh=/* @__PURE__ */new Mu(12),oh=e=>{const t=e.config||{},n=e.dimensions.plot,o=t.columnAccessor??"column",r=t.rowAccessor??"row",i=t.sizeAccessor,s=t.colorAccessor,a=t.symbolAccessor,c=t.shadeAccessor,l=t.markerAccessor,u=t.iconAccessor,d=t.defaultSymbol??"circle",[h,f]=t.sizeRange??[2,8],m=t.shadeStrength??.72,p=t.shadeReverse??!1,g=t.rowMode??"banded",y=t.cellSizing??"proportional",x=t.proportionExponent??1,b=t.columnGap??16,w=t.rowGap??12,M=t.packPadding??1,v=t.iterations??12,k=!1!==t.showEnclosures,$=!1!==t.showColumnHeaders,S=!1!==t.showRowLabels,I=$?t.headerHeight??26:0,A=S?t.labelWidth??66:0,C=t.callouts&&t.callouts.length>0?t.footerHeight??30:0,N=n.x+A,j=n.y+I,F=Math.max(1,n.width-A),E=Math.max(1,n.height-I-C),P=[];for(const t of e.nodes){const e=t.data??t;P.push({id:t.id,col:String(ge(t,o,"—")),row:String(ge(t,r,"—")),sizeVal:i?Number(ge(t,i,1)):1,colorKey:s?String(ge(t,s,"")):"",symVal:a?String(ge(t,a,"")):"",shadeVal:c?br(ge(t,c,null)):NaN,marker:!!l&&Boolean(ge(t,l,!1)),iconVal:u?String(ge(t,u,"")):"",datum:e,size:0,packR:0,baseShape:"circle",iconShape:null})}if(0===P.length)return{sceneNodes:[]};let z=1/0,L=-1/0;if(i)for(const e of P)Number.isFinite(e.sizeVal)&&(e.sizeVal<z&&(z=e.sizeVal),e.sizeVal>L&&(L=e.sizeVal));t.sizeDomain&&([z,L]=t.sizeDomain),Number.isFinite(z)&&Number.isFinite(L)||(z=0,L=1);const O=e=>{if(L<=z)return(h+f)/2;const t=Math.sqrt(wr((e-z)/(L-z),0,1));return h+t*(f-h)};let T=1/0,R=-1/0;if(c)for(const e of P)Number.isFinite(e.shadeVal)&&(e.shadeVal<T&&(T=e.shadeVal),e.shadeVal>R&&(R=e.shadeVal));t.shadeDomain&&([T,R]=t.shadeDomain);const W=e=>{if(!c||!Number.isFinite(e)||R<=T)return.5;const t=wr((e-T)/(R-T),0,1);return p?1-t:t},q=t.colorMap,D=/* @__PURE__ */new Map,B=(t,n)=>{let o=D.get(t);return o||(o=ke(q&&Object.prototype.hasOwnProperty.call(q,t)&&"string"==typeof q[t]&&q[t]?q[t]:e.resolveColor(t),m),D.set(t,o)),o(n)},Y=/* @__PURE__ */new Map;if(t.symbolMap)for(const[e,n]of Object.entries(t.symbolMap))Y.set(e,n);let V=0;const G=e=>{if(!a)return d;let t=Y.get(e);return t||(t=Fu[V%Fu.length],V++,Y.set(e,t)),t},_=t.iconMap,H=e=>u&&_&&Object.prototype.hasOwnProperty.call(_,e)?_[e]??null:null,X=e=>u?"circle":G(e.symVal),U=t.maxAreaFraction??.4;let K=0;const Z=new Array(P.length),Q=new Array(P.length);for(let e=0;e<P.length;e++){const t=P[e],n=O(t.sizeVal);Z[e]=n,t.baseShape=X(t),t.iconShape=H(t.iconVal);const o=ot(t.baseShape,Math.PI*n*n);Q[e]=o,K+=Math.PI*o*o}const J=U*F*E,ee=K>J?Math.sqrt(J/K):1;for(let e=0;e<P.length;e++){const t=P[e],n=Z[e]*ee;t.size=Math.PI*n*n,t.packR=Q[e]*ee}const te=/* @__PURE__ */new Map,ne=/* @__PURE__ */new Map;for(const e of P)te.set(e.col,(te.get(e.col)??0)+1),ne.set(e.row,(ne.get(e.row)??0)+1);const oe=t.columnOrder?.filter(e=>te.has(e))??[...te.keys()].sort((e,t)=>(te.get(t)??0)-(te.get(e)??0)),re=t.rowOrder?.filter(e=>ne.has(e))??[...ne.keys()].sort((e,t)=>(ne.get(t)??0)-(ne.get(e)??0)),ie=ve([Math.round(n.x),Math.round(n.y),Math.round(n.width),Math.round(n.height),I,A,C,g,y,x,b,w,M,v,h,f,z,L,U,oe.join(","),re.join(","),P.length,$r(P)]),se=nh.getOrCompute(ie,()=>vr(P,{columnOrder:oe,rowOrder:re,innerX:N,innerY:j,innerW:F,innerH:E,rowMode:g,cellSizing:y,proportionExponent:x,columnGap:b,rowGap:w,packPadding:M,iterations:v})),ae=e.selection,ce=ae?.isActive?ae.predicate:null,le=t.highlight??null,ue=t.dimOpacity??.16,de=t.markStroke,he=t.markStrokeWidth??0,fe=t.markerColor??"#ffffff",me=t.iconColor??"rgba(255,255,255,0.92)",pe=t.iconStrokeWidth??1,ye=t.iconScale??.72,xe=[],be=[],we=[];for(const e of P){const t=se.positions.get(e.id);if(!t)continue;const n=Me(e.datum,{highlight:le,predicate:ce,dimOpacity:ue}),o={type:"symbol",cx:t.px,cy:t.py,size:e.size,symbolType:e.baseShape,style:{fill:B(e.colorKey,W(e.shadeVal)),opacity:n,...de?{stroke:de,strokeWidth:he}:{}},datum:e.datum,id:e.id,label:String(e.id)};if(xe.push(o),e.iconShape){const o=Math.sqrt(e.size/Math.PI)*ye,r=ot(e.iconShape,100),i=r>0?o/r*100*(o/r):Math.PI*o*o;we.push({x:t.px,y:t.py,size:i,shape:e.iconShape,opacity:n})}e.marker&&n>ue+.001&&be.push({x:t.px,y:t.py,r:Math.max(1,.4*Math.sqrt(e.size/Math.PI))})}const $e=[];if(t.callouts&&t.callouts.length>0){const e=t.calloutColor??"var(--semiotic-text, #f4f4f8)",o=n.y+n.height-(C>0?.45*C:9),r=[];for(let e=0;e<t.callouts.length;e++){const n=t.callouts[e],o=P.find(e=>String(e.datum[n.field])===String(n.value));if(!o)continue;const i=se.positions.get(o.id);i&&r.push({c:n,ci:e,px:i.px,py:i.py,markR:Math.sqrt(o.size/Math.PI)})}const i=r.filter(e=>null==e.c.at).sort((e,t)=>e.px-t.px),s=/* @__PURE__ */new Map;i.forEach((e,t)=>{s.set(e.ci,N+(t+.5)/i.length*F)});for(const t of r){const r=t.c;let i=s.get(t.ci)??t.px,a=o;const c=r.connector??(s.has(t.ci)?"elbow":"straight");"object"==typeof r.at&&r.at?(i=r.at.x,a=r.at.y):"number"==typeof r.at&&(a=n.y+r.at*n.height),$e.push({keyId:`callout-${t.ci}`,markX:t.px,markY:t.py,labelX:i,labelY:a,label:r.label,connector:c,markRadius:Math.max(t.markR+3,7),stroke:e,color:e,fontSize:11,labelAnchor:"middle",labelBaseline:"auto"})}}const Se={markerDots:be,markerColor:fe,iconMarks:we,iconColor:me,iconStrokeWidth:pe,callouts:$e,plot:n,showEnclosures:k,showColumnHeaders:$,showRowLabels:S,enclosureColor:t.enclosureColor??"var(--semiotic-text, #f4f4f8)",enclosureRadius:t.enclosureRadius??9,enclosureOpacity:t.enclosureOpacity??.5,enclosureWidth:t.enclosureWidth??1.5,headerColor:t.headerColor??"var(--semiotic-text, #f4f4f8)",labelColor:t.labelColor??"var(--semiotic-text-secondary, #b9b9c8)",headerFontSize:t.headerFontSize??13,labelFontSize:t.labelFontSize??11,headerY:n.y+.62*I,labelX:n.x+A-10,columnLabel:t.columnLabel,rowLabel:t.rowLabel};return{sceneNodes:xe,overlays:Sr(se,Se),perspective:"manual",...e.perspective?{perspectiveBounds:xr(se,Se)}:{}}},rh=4,ih=Ll(require("react")),sh=e=>{const t=e.config,{plot:n}=e.dimensions;if(n.width<=0||n.height<=0)return{nodes:[]};const o=pe(t.categoryAccessor),r=pe(t.stackBy),i=e=>{const n="function"==typeof t.valueAccessor?t.valueAccessor(e):e[t.valueAccessor],o=Number(n);return Number.isFinite(o)&&o>0?o:0},s=t.gutter??2,a="string"==typeof t.categoryAccessor?t.categoryAccessor:"category",c="string"==typeof t.stackBy?t.stackBy:"stack",l="string"==typeof t.valueAccessor?t.valueAccessor:"value",u=(e,t,n)=>be(o=>{o("category",e),o("stack",t),o("value",n),"category"!==a&&o(a,e),"stack"!==c&&o(c,t),"value"!==l&&o(l,n)}),d=!1!==t.showCategoryLabels,h=t.labelPadding??(d?22:0),f=Math.max(0,n.height-h),m=[],p=/* @__PURE__ */new Map,g=[],y=/* @__PURE__ */new Set,x=/* @__PURE__ */new Map;for(const t of e.data){const e=String(o(t)),n=String(r(t)),s=i(t);p.has(e)||(m.push(e),p.set(e,0),x.set(e,/* @__PURE__ */new Map)),y.has(n)||(y.add(n),g.push(n)),p.set(e,(p.get(e)??0)+s);const a=x.get(e);a.set(n,(a.get(n)??0)+s)}const b=t.categoryOrder?Ar(t.categoryOrder,m,e=>p.has(e)):m,w=t.stackOrder?Ar(t.stackOrder,g,()=>!0):g,M=b.reduce((e,t)=>e+(p.get(t)??0),0);if(M<=0)return{nodes:[]};const v=s*Math.max(0,b.length-1),k=Math.max(0,n.width-v),$=[],S=[];let I=n.x;for(const t of b){const o=p.get(t)??0,r=o/M*k;if(r<=0)continue;S.push({cat:t,x:I,w:r});const i=x.get(t);let a=n.y;for(const n of w){const s=i.get(n)??0;if(s<=0)continue;const c=s/o*f;$.push({type:"rect",x:I,y:a,w:r,h:c,style:{fill:e.resolveColor(n),stroke:"none"},datum:u(t,n,s),group:n}),a+=c}I+=r+s}return{nodes:$,overlays:d&&S.length>0?Ir(S,n.y+f+4,`var(--semiotic-text, ${e.theme.semantic.text??"currentColor"})`):null}},ah=Ll(require("react")),ch=e=>{const t=e.config,{plot:n}=e.dimensions;if(n.width<=0||n.height<=0||0===e.data.length)return{nodes:[]};const o=Math.max(1,Ae(t.rowHeight??28)),r=Ae(t.rowGap??12),i=!1!==t.showLabels,s=i?Ae(t.labelWidth??120):0,a=!1!==t.showTicks,c=a?14:0,l=t.tickFormat??(e=>e.toLocaleString()),u=n.x+s,d=Math.max(0,n.width-s),h=pe(t.categoryAccessor),f=pe(t.valueAccessor),m=pe(t.targetAccessor),p=pe(t.rangesAccessor),g="string"==typeof t.categoryAccessor?t.categoryAccessor:"metric",y="string"==typeof t.valueAccessor?t.valueAccessor:"value",x="string"==typeof t.targetAccessor?t.targetAccessor:"target",b=t.actualColor??e.theme.semantic.primary??"#3b6cb1",w=e.theme.semantic.text??"currentColor",M=e.theme.semantic.textSecondary??"#888",v=e.theme.semantic.surface??"#e8eaed",k=e.theme.semantic.grid??"#cdd1d6",$=e.theme.semantic.border??"#a3a8af",S=t.targetColor??`var(--semiotic-text, ${w})`,I=[`var(--semiotic-surface, ${v})`,`var(--semiotic-grid, ${k})`,`var(--semiotic-border, ${$})`],A=`var(--semiotic-text, ${w})`,C=`var(--semiotic-text-secondary, ${M})`,N=[],j=e.data.map(e=>{const t=p(e),n=Array.isArray(t)?t.map(Ae).sort((e,t)=>e-t):[],o=Ae(f(e)),r=Ae(m(e));return{label:h(e),ranges:n,actual:o,target:r,maxVal:Math.max(o,r,...n)}}).filter(e=>e.maxVal>0),F=e=>d>0?Math.max(0,Math.floor((e+r)/(o+r+c))):0,E=Math.min(j.length,F(n.height))<e.data.length,P=j.slice(0,F(n.height-(E?18:0))).map((e,t)=>({...e,yTop:n.y+t*(o+r+c)}));for(const{yTop:e,label:t,ranges:n,actual:r,target:i,maxVal:s}of P){const a=e=>u+e/s*d,c=e=>be(n=>{n("metric",t),"metric"!==g&&n(g,t),e(n)});let l=u;for(let t=0;t<n.length;t++){const r=a(n[t]),i=r-l;i>0&&N.push({type:"rect",x:l,y:e,w:i,h:o,style:{fill:I[Math.min(t,I.length-1)],stroke:"none"},datum:c(e=>{e("range",t),e("rangeValue",n[t]),e("kind","range")}),group:`range-${t}`}),l=r}const h=Math.min(o,Math.max(6,Math.floor(.45*o)));N.push({type:"rect",x:u,y:e+(o-h)/2,w:a(r)-u,h:h,style:{fill:b,stroke:"none"},datum:c(e=>{e("value",r),e("kind","actual"),"value"!==y&&e(y,r)}),group:"actual"});const f=3,m=.8*o;N.push({type:"rect",x:a(i)-f/2,y:e+(o-m)/2,w:f,h:m,style:{fill:S,stroke:"none"},datum:c(e=>{e("target",i),e("kind","target"),"target"!==x&&e(x,i)}),group:"target"})}const z=[],L=je(n,P.length,e.data.length,"rows","Rows without positive values or enough plot space are omitted.");L&&z.push(L);for(let e=0;e<P.length;e++){const t=P[e],r=t.yTop+o/2;if(i&&z.push(Ro({keyId:`bullet-label-${e}`,text:t.label,x:n.x+s-8,y:r,anchor:"end",baseline:"middle",fontSize:13,fontWeight:500,color:A})),a){const n=5,r=t.yTop+o+2;for(let o=0;o<n;o++){const i=t.maxVal*o/(n-1),s=u+i/t.maxVal*d;z.push(ah.createElement("line",{key:`bullet-tick-${e}-${o}`,x1:s,x2:s,y1:r,y2:r+3,stroke:C,strokeWidth:1}),Ro({keyId:`bullet-ticktext-${e}-${o}`,text:l(i),x:s,y:r+12,anchor:0===o?"start":o===n-1?"end":"middle",baseline:"auto",fontSize:10,color:C}))}}}return{nodes:N,overlays:z.length>0?ah.createElement(ah.Fragment,null,...z):null}},lh=Ll(require("react")),uh=require("d3-scale"),dh=e=>{const t=e.config,{plot:n}=e.dimensions,o=t.fields??[];if(o.length<2||n.width<=0||n.height<=0)return{nodes:[]};if(0===e.data.length)return{nodes:[]};const r=/* @__PURE__ */Object.create(null);for(const n of o){const o=t.domains&&Object.prototype.hasOwnProperty.call(t.domains,n)?t.domains[n]:void 0;if(Array.isArray(o)&&o.length>=2&&"number"==typeof o[0]&&Number.isFinite(o[0])&&"number"==typeof o[1]&&Number.isFinite(o[1])){r[n]=[o[0],o[1]];continue}let i=1/0,s=-1/0;for(const t of e.data){const e=Number(t[n]);Number.isFinite(e)&&(e<i&&(i=e),e>s&&(s=e))}if(Number.isFinite(i)&&Number.isFinite(s))if(i===s){const e=Math.max(.01*Math.abs(i),.5);r[n]=[i-e,s+e]}else r[n]=[i,s];else r[n]=[0,1]}const i=!1!==t.showAxes,s=i?t.axisLabelPadding??24:8,a=i?18:8,c=o.map(e=>(0,uh.scaleLinear)().domain(r[e]).range([n.y+n.height-a,n.y+s])),l=o.map((e,t)=>1===o.length?n.x+n.width/2:n.x+t/(o.length-1)*n.width),u=t.colorBy?"function"==typeof t.colorBy?t.colorBy:e=>String(e[t.colorBy]??""):null,d=t.opacity??.45,h=t.strokeWidth??1.25,f=e.theme.semantic.primary??"#3b6cb1",m=t.dimmedOpacity??.08,p=t.highlightFn,g=[],y=[];for(const n of e.data){const r=u?e.resolveColor(String(u(n))):f,i=!p||p(n),s=Me(n,{predicate:p,baseOpacity:d,dimOpacity:m,brighten:.4}),a=i?y:g;for(let e=0;e<o.length-1;e++){const t=Number(n[o[e]]),u=Number(n[o[e+1]]);if(!Number.isFinite(t)||!Number.isFinite(u))continue;const d={type:"connector",x1:l[e],y1:c[e](t),x2:l[e+1],y2:c[e+1](u),style:{stroke:r,strokeWidth:p&&i?h+.75:h,opacity:s,fill:"none"},datum:n};a.push(d)}if(t.showPoints)for(let e=0;e<o.length;e++){const t=Number(n[o[e]]);if(!Number.isFinite(t))continue;const i={type:"point",x:l[e],y:c[e](t),r:2.5,style:{fill:r,stroke:"none",opacity:Math.min(1,s+.3)},datum:n};a.push(i)}}let x=null;if(i){const i=`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=n.y+s,f=n.y+n.height-a,m=[];for(let e=0;e<o.length;e++){const a=o[e],p=l[e],g=t.tickFormat&&Object.prototype.hasOwnProperty.call(t.tickFormat,a)?t.tickFormat[a]:void 0,y="function"==typeof g?g:e=>e.toLocaleString();m.push(lh.createElement("line",{key:`pc-axis-line-${e}`,x1:p,x2:p,y1:h,y2:f,stroke:i,strokeWidth:1})),m.push(Ro({keyId:`pc-axis-label-${e}`,text:a,x:p,y:n.y+s-8,anchor:"middle",baseline:"auto",fontSize:12,fontWeight:600,color:u}));const[x,b]=r[a],w=5;for(let t=0;t<w;t++){const n=x+(b-x)*t/(w-1),o=c[e](n);m.push(lh.createElement("line",{key:`pc-tick-${e}-${t}`,x1:p-3,x2:p+3,y1:o,y2:o,stroke:i,strokeWidth:1}),Ro({keyId:`pc-ticktext-${e}-${t}`,text:y(n),x:p+6,y:o+3,anchor:"start",baseline:"auto",fontSize:10,color:d}))}}x=lh.createElement(lh.Fragment,null,...m)}return{nodes:g.concat(y),overlays:x}},hh=require("react/jsx-runtime"),fh=1.75,mh="#222222",ph=2e3,gh={height:15.5,topRadius:4.75,bottomRadius:3.75},yh=e=>{const t=e.config,{plot:n}=e.dimensions;if(!Number.isFinite(n.width)||!Number.isFinite(n.height)||n.width<=0||n.height<=0)return{nodes:[]};const o=pe(t.categoryAccessor??"name"),r=pe(t.teaVolumeAccessor??"teaVolume"),i=pe(t.bobaVolumeAccessor??"bobaVolume"),s=pe(t.iceVolumeAccessor??"iceVolume"),a=pe(t.cupHeightAccessor??"cupHeight"),c=pe(t.cupTopRadiusAccessor??"cupTopRadius"),l=pe(t.cupBottomRadiusAccessor??"cupBottomRadius"),u=pe(t.bobaRadiusAccessor??"bobaRadius"),d=Rr(t.cupWidthRatio,.82),h=e.scales.o,f=h.bandwidth(),m=Math.max(1,n.height-26-8),p=n.y+8,g=[],y=[];for(const t of e.data){const n=String(o(t)),x=h(n);if(null==x)continue;let b={height:Rr(a(t),gh.height),topRadius:Rr(c(t),gh.topRadius),bottomRadius:Rr(l(t),gh.bottomRadius)};const w=jr(b,b.height);(!Number.isFinite(w)||w<=0)&&(b=gh);let M=Rr(u(t),.6);const v=Math.max(0,Tr(r(t),450)),k=Math.max(0,Tr(i(t),110)),$=Math.max(0,Tr(s(t),135));let S=Math.PI*M*M;(!Number.isFinite(S)||S<=0||!Number.isFinite(k/S))&&(M=.6,S=Math.PI*M*M);const I=Math.floor(k/S),A=Math.min(k,I*S),C=Math.floor($/5.359375),N=Math.min($,C*fh*fh*fh),j=v+A+N;if(!Number.isFinite(j))throw new RangeError("Boba total volume exceeds the finite numeric range");const F=Fr(b,j),E=Math.min(b.height,Math.max(0,F)),P=Nr(b,E),{pearls:z,layers:L}=zr(b,M,I),O=E,T=Or(b,L*M*2,O,C),R=b.height-20.32,W=Math.min(0,R),q=b.height-W,D=2*(b.topRadius+1),B=Math.min(f*d/D,m/q),Y=x+f/2,V=e=>Y+e*B,G=e=>p+(e-W)*B,_=V(-(b.topRadius+1)),H=V(b.topRadius+1),X=G(W),U=G(b.height),K=Se({name:n,teaVolume:v,bobaVolume:Math.round(A),iceVolume:Math.round(N),totalVolume:Math.round(j),numBobas:I,numIce:C,renderedBobas:z.length,renderedIce:T.length,kind:"boba cup"});g.push({type:"rect",x:_,y:X,w:Math.max(1,H-_),h:Math.max(1,U-X),style:{fill:"rgba(0,0,0,0)",stroke:"none"},datum:K,group:n,_transitionKey:`boba-${Ie(n)}`});const Z=b.height-O,Q=Ie(n),J=e.resolveColor(n);y.push(
|
|
159
|
+
/* @__PURE__ */(0,uh.jsxs)("g",{children:[v>0?/* @__PURE__ */ /* @__PURE__ */(0,uh.jsx)("path",{d:`M${V(-P)},${G(Z)} L${V(-b.bottomRadius)},${G(b.height)} L${V(b.bottomRadius)},${G(b.height)} L${V(P)},${G(Z)} z`,fill:"#D2B799"}):null,z.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,uh.jsx)("circle",{cx:V(e.x),cy:G(e.z),r:M*B,fill:"#222222",opacity:.5},`p-${t}`)),T.map((e,t)=>/* @__PURE__ */ /* @__PURE__ */(0,uh.jsx)("rect",{x:V(e.cx)-.95*dh*B/2,y:G(e.cy)-.95*dh*B/2,width:.95*dh*B,height:.95*dh*B,rx:2,fill:"#a5f2f3",opacity:.85,transform:`rotate(${e.rotation} ${V(e.cx)} ${G(e.cy)})`},`i-${t}`)),
|
|
163
160
|
/* @__PURE__ */
|
|
164
|
-
/* @__PURE__ */(0,
|
|
161
|
+
/* @__PURE__ */(0,uh.jsx)("path",{d:`M${V(-b.topRadius)},${G(0)} L${V(-b.bottomRadius)},${G(b.height)} L${V(b.bottomRadius)},${G(b.height)} L${V(b.topRadius)},${G(0)}`,fill:"none",stroke:hh,strokeWidth:2.5}),
|
|
165
162
|
/* @__PURE__ */
|
|
166
|
-
/* @__PURE__ */(0,hh.jsx)("path",{d:`M${V(
|
|
163
|
+
/* @__PURE__ */(0,uh.jsx)("line",{x1:V(-(b.topRadius+1)),y1:G(0),x2:V(b.topRadius+1),y2:G(0),stroke:hh,strokeWidth:3,strokeLinecap:"round"}),v>0?/* @__PURE__ */ /* @__PURE__ */(0,uh.jsx)("path",{d:`M${V(-.635)},${G(R)} L${V(-.635)},${G(b.height-.4)} L${V(.635)},${G(b.height-1.27-.4)} L${V(.635)},${G(R)} z`,fill:"#4F91CB",stroke:hh,strokeWidth:1,opacity:.78}):null,
|
|
167
164
|
/* @__PURE__ */
|
|
168
|
-
/* @__PURE__ */(0,
|
|
165
|
+
/* @__PURE__ */(0,uh.jsx)("text",{x:Y,y:U+16,textAnchor:"middle",fontSize:12,fontWeight:600,fill:"var(--semiotic-text, #333)",children:n}),
|
|
169
166
|
/* @__PURE__ */
|
|
170
|
-
/* @__PURE__ */(0,
|
|
171
|
-
/* @__PURE__ */
|
|
172
|
-
/* @__PURE__ */(0,hh.jsx)("text",{x:Y,y:U+30,textAnchor:"middle",fontSize:10,fill:J,children:`${I} pearls${z.length<I?` (${z.length} shown)`:""}${T.length<C?` · ${T.length}/${C} ice shown`:""} · ${Math.round(j)} cm³`})]},`boba-${Q}`))}return{nodes:g,overlays:/* @__PURE__ */ /* @__PURE__ */(0,hh.jsx)("g",{className:"semiotic-boba",style:{pointerEvents:"none"},children:y})}},xh=/* @__PURE__ */new Set(["label","callout","callout-circle","callout-rect","text","widget"]),bh=2e4,wh=1,Mh=32,vh=6,kh=4,$h=8,Sh=72,Ih=30,Ah=-30,Ch=8,Nh=480,jh=3,Fh={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"},Eh=["naturalGas","coal","nuclear","hydro","wind","solar","other"],Ph={naturalGas:"Natural gas",coal:"Coal",nuclear:"Nuclear",hydro:"Hydro",wind:"Wind",solar:"Solar",other:"Other"},zh={tight:5,watch:12,comfortable:20},Lh={tight:"var(--semiotic-danger, #c2410c)",watch:"var(--semiotic-warning, #d97706)",moderate:"var(--semiotic-info, #0891b2)",comfortable:"var(--semiotic-success, #16a34a)"},Oh=Ll(require("react")),Th=require("d3-array"),Rh=class{constructor(){this.count=0,this.capacity=1,this.tree=new Float64Array(2).fill(NaN)}assign(e,t){let n;if(this.tree[1]<=e){let t=1;for(;t<this.capacity;)t*=2,this.tree[t]<=e||t++;n=t-this.capacity}else n=this.count++,n===this.capacity&&this.grow();let o=this.capacity+n;for(this.tree[o]=t;o>1;){o=Math.floor(o/2);const e=this.minimum(o);if(this.tree[o]===e)break;this.tree[o]=e}return n}minimum(e){const t=this.tree[2*e],n=this.tree[2*e+1];return t<=n||Number.isNaN(n)?t:n}grow(){const e=this.tree,t=this.capacity;this.capacity*=2,this.tree=new Float64Array(2*this.capacity).fill(NaN),this.tree.set(e.subarray(t),this.capacity);for(let e=this.capacity-1;e>0;e--)this.tree[e]=this.minimum(e)}},Wh=e=>{const t=e.config,{plot:n}=e.dimensions;if(n.width<=0||n.height<=0||0===e.data.length||!t?.domain)return{nodes:[]};const o=pe(t.laneAccessor),r=pe(t.startAccessor),i=pe(t.endAccessor),s=t.idAccessor?pe(t.idAccessor):null,a=t.unit??0,c=Ae(t.barGap??1.5),l=Math.max(0,t.minBarWidth??2),u=Ae(t.minBarHeight??3.5)||3.5,d=Ae(t.maxBarHeight??10)||10,h=t.cornerRadius??2,f=Ae(t.bottomInset??0),m=t.color??((t,n)=>e.resolveColor(n)),[p,g]=t.domain;if(!Number.isFinite(p)||!Number.isFinite(g)||p>g||!Number.isFinite(g-p))return{nodes:[]};const y=g-p||1,x=e=>n.x+(e-p)/y*n.width,b=e.scales?.o?.domain?.()??[],w=t.lanes??(b.length>0?b:[...new Set(e.data.map(o))]),M=Math.max(0,n.height-f)/Math.max(1,w.length);if(M<=0)return{nodes:[]};const v=Math.min(M/4,Ae(t.lanePadding??7)),k=e=>x(r(e)),$=e=>Math.max(k(e)+l,x(i(e)+a)),S=[];w.forEach((t,r)=>{const i=n.y+r*M,a=e.data.filter(e=>o(e)===t);if(0===a.length)return;const{packed:l,trackCount:f}=Li(a,{start:k,end:$}),p=/* @__PURE__ */new Map,g=/* @__PURE__ */new Map;for(const{item:e,track:t}of l){const n=g.get(t);n&&p.set(n,k(e)),g.set(t,e)}const y=(M-2*v)/f,x=Math.min(d,y,Math.max(u,y-c));for(const{item:e,track:n}of l){const o=k(e),r=p.get(e),a=$(e)-o,c=void 0!==r&&o+a>r-1?Math.max(1,r-1-o):a,l=i+v+n*y;S.push({type:"rect",x:o,y:l,w:c,h:x,cornerRadii:h>0?{tl:h,tr:h,br:h,bl:h}:void 0,style:{fill:m(e,t),stroke:"none"},datum:e,group:t,_transitionKey:s?String(s(e)):void 0})}});const I=`var(--semiotic-text, ${e.theme.semantic.text??"#1a1a1a"})`,A=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,C=`var(--semiotic-border, ${e.theme.semantic.border??"#94a3b8"})`,N=[];(t.periods??[]).forEach((e,t)=>{const o=x(e.start),r=Math.max(1,x(e.end+a)-o);N.push(Oh.createElement("rect",{key:`period-${t}`,x:o,y:n.y,width:r,height:n.height,fill:C,opacity:t%2==0?.06:.025,pointerEvents:"none"})),e.name&&N.push(Ro({keyId:`period-label-${t}`,text:e.name,x:o+4,y:n.y+12,anchor:"start",baseline:"hanging",fontSize:13,fontWeight:700,color:A}))});const j=!1!==t.showLaneLabels,F=t.laneLabelGap??12;if(w.forEach((e,t)=>{const o=n.y+t*M;N.push(Oh.createElement("line",{key:`lane-sep-${t}`,x1:n.x,x2:n.x+n.width,y1:o,y2:o,stroke:C,opacity:.45})),j&&N.push(Ro({keyId:`lane-label-${t}`,text:e,x:n.x-F,y:o+M/2,anchor:"end",baseline:"middle",fontSize:12,fontWeight:600,color:I}))}),!1!==t.showAxis){const e=t.axisTicks??(0,Th.ticks)(p,g,7);N.push(qo({keyId:"interval-axis",scale:x,ticks:e,orient:"top",offset:n.y,tickLength:0,gridLength:n.height,gridDasharray:"3 5",edgeAnchor:!0,format:t.tickFormat,color:A}))}return{nodes:S,overlays:Oh.createElement(Oh.Fragment,null,...N)}},qh={width:60,height:34},Dh=e=>{const{plot:t}=e.dimensions;if(t.width<=0||t.height<=0||0===e.nodes.length||!e.config?.fixedDomain)return{sceneNodes:[]};const n=e.config.fixedAxis??"y",{positioned:o,byId:r}=Ui(e.nodes,e.edges,t,e.config,!0),i=o.map(t=>({type:"rect",x:t.x-t.width/2,y:t.y-t.height/2,w:t.width,h:t.height,style:{fill:e.resolveColor(t.id),stroke:"none"},datum:t.data,id:t.id,label:t.id})),s=[],a=Hi(e.config.sourceAccessor,"source",!0),c=Hi(e.config.targetAccessor,"target",!0),l=e=>String(a(e)),u=e=>String(c(e));e.edges.forEach((e,t)=>{const o=r.get(l(e)),i=r.get(u(e));if(!o||!i)return;const{from:a,to:c}=Di({cx:o.x,cy:o.y,width:o.width,height:o.height},{cx:i.x,cy:i.y,width:i.width,height:i.height},{orientation:"y"===n?"vertical":"horizontal"});s.push({type:"curved",pathD:Wi(a,c,{orientation:"y"===n?"vertical":"horizontal",bend:Bi(t,{modulo:5,spread:5})}),style:{stroke:"var(--semiotic-border, #888)",fill:"none",strokeWidth:1.4},datum:ye(e)??e})});const d=o.map(e=>({x:e.x,y:e.y,text:e.id}));return{sceneNodes:i,sceneEdges:s,labels:d}},Bh=1.15,Yh=5,Vh={a:.556,b:.611,c:.556,d:.611,e:.556,f:.333,g:.611,h:.611,i:.278,j:.278,k:.556,l:.278,m:.889,n:.611,o:.611,p:.611,q:.611,r:.389,s:.556,t:.333,u:.611,v:.556,w:.778,x:.556,y:.556,z:.5,A:.722,B:.722,C:.722,D:.722,E:.667,F:.611,G:.778,H:.722,I:.278,J:.556,K:.722,L:.611,M:.833,N:.722,O:.778,P:.667,Q:.778,R:.722,S:.667,T:.611,U:.722,V:.667,W:.944,X:.667,Y:.667,Z:.611,"'":.278,"’":.278,"-":.333,".":.278,",":.278," ":.278},Gh=.556,_h=.65,Hh=1,Xh=1.05,Uh=1,Kh=class e{constructor(e){this.cell=e,this.cells=/* @__PURE__ */new Map}span(e,t){return[Math.floor(e/this.cell),Math.floor(t/this.cell)]}static key(e,t){return 65536*(e+32768)+(t+32768)}insert(t){const[n,o]=this.span(t.x-t.w/2,t.x+t.w/2),[r,i]=this.span(t.y-t.h/2,t.y+t.h/2);for(let s=n;s<=o;s++)for(let n=r;n<=i;n++){const o=e.key(s,n),r=this.cells.get(o);r?r.push(t):this.cells.set(o,[t])}}collides(t,n){const[o,r]=this.span(t.x-t.w/2-n,t.x+t.w/2+n),[i,s]=this.span(t.y-t.h/2-n,t.y+t.h/2+n);for(let a=o;a<=r;a++)for(let o=i;o<=s;o++){const r=this.cells.get(e.key(a,o));if(r)for(const e of r)if(Math.abs(t.x-e.x)<(t.w+e.w)/2+n&&Math.abs(t.y-e.y)<(t.h+e.h)/2+n)return!0}return!1}},Zh=32,Qh=2600,Jh=require("react/jsx-runtime"),ef=/* @__PURE__ */new Mu(12),tf={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},nf=8,of=ds,rf=2*Math.PI,sf=[40,40],af=[.5,.5],cf=require("react/jsx-runtime"),lf="var(--semiotic-text, currentColor)",uf=8,df=/* @__PURE__ */new Set(["rows"]);Tl(),hu(),Number.POSITIVE_INFINITY;var hf=[.1,.5,.9],ff=1e6,mf=12,pf=require("react/jsx-runtime"),gf={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"}},yf=6.2,xf={flow:"down",padding:24,chargeExtent:.12,destinationExtent:.55,projectionExtent:0,channelRatio:1},bf="\0";
|
|
167
|
+
/* @__PURE__ */(0,uh.jsx)("text",{x:Y,y:U+30,textAnchor:"middle",fontSize:10,fill:J,children:`${I} pearls${z.length<I?` (${z.length} shown)`:""}${T.length<C?` · ${T.length}/${C} ice shown`:""} · ${Math.round(j)} cm³`})]},`boba-${Q}`))}return{nodes:g,overlays:/* @__PURE__ */ /* @__PURE__ */(0,uh.jsx)("g",{className:"semiotic-boba",style:{pointerEvents:"none"},children:y})}},gh=/* @__PURE__ */new Set(["label","callout","callout-circle","callout-rect","text","widget"]),yh=2e4,xh=1,bh=32,wh=6,Mh=4,vh=8,kh=72,$h=30,Sh=-30,Ih=8,Ah=480,Ch=3,Nh={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"},jh=["naturalGas","coal","nuclear","hydro","wind","solar","other"],Fh={naturalGas:"Natural gas",coal:"Coal",nuclear:"Nuclear",hydro:"Hydro",wind:"Wind",solar:"Solar",other:"Other"},Eh={tight:5,watch:12,comfortable:20},Ph={tight:"var(--semiotic-danger, #c2410c)",watch:"var(--semiotic-warning, #d97706)",moderate:"var(--semiotic-info, #0891b2)",comfortable:"var(--semiotic-success, #16a34a)"},zh=jl(require("react")),Lh=require("d3-array"),Oh=class{constructor(){this.count=0,this.capacity=1,this.tree=new Float64Array(2).fill(NaN)}assign(e,t){let n;if(this.tree[1]<=e){let t=1;for(;t<this.capacity;)t*=2,this.tree[t]<=e||t++;n=t-this.capacity}else n=this.count++,n===this.capacity&&this.grow();let o=this.capacity+n;for(this.tree[o]=t;o>1;){o=Math.floor(o/2);const e=this.minimum(o);if(this.tree[o]===e)break;this.tree[o]=e}return n}minimum(e){const t=this.tree[2*e],n=this.tree[2*e+1];return t<=n||Number.isNaN(n)?t:n}grow(){const e=this.tree,t=this.capacity;this.capacity*=2,this.tree=new Float64Array(2*this.capacity).fill(NaN),this.tree.set(e.subarray(t),this.capacity);for(let e=this.capacity-1;e>0;e--)this.tree[e]=this.minimum(e)}},Th=e=>{const t=e.config,{plot:n}=e.dimensions;if(n.width<=0||n.height<=0||0===e.data.length||!t?.domain)return{nodes:[]};const o=pe(t.laneAccessor),r=pe(t.startAccessor),i=pe(t.endAccessor),s=t.idAccessor?pe(t.idAccessor):null,a=t.unit??0,c=Ae(t.barGap??1.5),l=Math.max(0,t.minBarWidth??2),u=Ae(t.minBarHeight??3.5)||3.5,d=Ae(t.maxBarHeight??10)||10,h=t.cornerRadius??2,f=Ae(t.bottomInset??0),m=t.color??((t,n)=>e.resolveColor(n)),[p,g]=t.domain;if(!Number.isFinite(p)||!Number.isFinite(g)||p>g||!Number.isFinite(g-p))return{nodes:[]};const y=g-p||1,x=e=>n.x+(e-p)/y*n.width,b=e.scales?.o?.domain?.()??[],w=t.lanes??(b.length>0?b:[...new Set(e.data.map(o))]),M=Math.max(0,n.height-f)/Math.max(1,w.length);if(M<=0)return{nodes:[]};const v=Math.min(M/4,Ae(t.lanePadding??7)),k=e=>x(r(e)),$=e=>Math.max(k(e)+l,x(i(e)+a)),S=[];w.forEach((t,r)=>{const i=n.y+r*M,a=e.data.filter(e=>o(e)===t);if(0===a.length)return;const{packed:l,trackCount:f}=ji(a,{start:k,end:$}),p=/* @__PURE__ */new Map,g=/* @__PURE__ */new Map;for(const{item:e,track:t}of l){const n=g.get(t);n&&p.set(n,k(e)),g.set(t,e)}const y=(M-2*v)/f,x=Math.min(d,y,Math.max(u,y-c));for(const{item:e,track:n}of l){const o=k(e),r=p.get(e),a=$(e)-o,c=void 0!==r&&o+a>r-1?Math.max(1,r-1-o):a,l=i+v+n*y;S.push({type:"rect",x:o,y:l,w:c,h:x,cornerRadii:h>0?{tl:h,tr:h,br:h,bl:h}:void 0,style:{fill:m(e,t),stroke:"none"},datum:e,group:t,_transitionKey:s?String(s(e)):void 0})}});const I=`var(--semiotic-text, ${e.theme.semantic.text??"#1a1a1a"})`,A=`var(--semiotic-text-secondary, ${e.theme.semantic.textSecondary??"#888"})`,C=`var(--semiotic-border, ${e.theme.semantic.border??"#94a3b8"})`,N=[];(t.periods??[]).forEach((e,t)=>{const o=x(e.start),r=Math.max(1,x(e.end+a)-o);N.push(zh.createElement("rect",{key:`period-${t}`,x:o,y:n.y,width:r,height:n.height,fill:C,opacity:t%2==0?.06:.025,pointerEvents:"none"})),e.name&&N.push(Po({keyId:`period-label-${t}`,text:e.name,x:o+4,y:n.y+12,anchor:"start",baseline:"hanging",fontSize:13,fontWeight:700,color:A}))});const j=!1!==t.showLaneLabels,F=t.laneLabelGap??12;if(w.forEach((e,t)=>{const o=n.y+t*M;N.push(zh.createElement("line",{key:`lane-sep-${t}`,x1:n.x,x2:n.x+n.width,y1:o,y2:o,stroke:C,opacity:.45})),j&&N.push(Po({keyId:`lane-label-${t}`,text:e,x:n.x-F,y:o+M/2,anchor:"end",baseline:"middle",fontSize:12,fontWeight:600,color:I}))}),!1!==t.showAxis){const e=t.axisTicks??(0,Lh.ticks)(p,g,7);N.push(Lo({keyId:"interval-axis",scale:x,ticks:e,orient:"top",offset:n.y,tickLength:0,gridLength:n.height,gridDasharray:"3 5",edgeAnchor:!0,format:t.tickFormat,color:A}))}return{nodes:S,overlays:zh.createElement(zh.Fragment,null,...N)}},Rh={width:60,height:34},Wh=e=>{const{plot:t}=e.dimensions;if(t.width<=0||t.height<=0||0===e.nodes.length||!e.config?.fixedDomain)return{sceneNodes:[]};const n=e.config.fixedAxis??"y",{positioned:o,byId:r}=Vi(e.nodes,e.edges,t,e.config,!0),i=o.map(t=>({type:"rect",x:t.x-t.width/2,y:t.y-t.height/2,w:t.width,h:t.height,style:{fill:e.resolveColor(t.id),stroke:"none"},datum:t.data,id:t.id,label:t.id})),s=[],a=Bi(e.config.sourceAccessor,"source",!0),c=Bi(e.config.targetAccessor,"target",!0),l=e=>String(a(e)),u=e=>String(c(e));e.edges.forEach((e,t)=>{const o=r.get(l(e)),i=r.get(u(e));if(!o||!i)return;const{from:a,to:c}=Oi({cx:o.x,cy:o.y,width:o.width,height:o.height},{cx:i.x,cy:i.y,width:i.width,height:i.height},{orientation:"y"===n?"vertical":"horizontal"});s.push({type:"curved",pathD:zi(a,c,{orientation:"y"===n?"vertical":"horizontal",bend:Ti(t,{modulo:5,spread:5})}),style:{stroke:"var(--semiotic-border, #888)",fill:"none",strokeWidth:1.4},datum:ye(e)??e})});const d=o.map(e=>({x:e.x,y:e.y,text:e.id}));return{sceneNodes:i,sceneEdges:s,labels:d}},qh=1.15,Dh=5,Bh={a:.556,b:.611,c:.556,d:.611,e:.556,f:.333,g:.611,h:.611,i:.278,j:.278,k:.556,l:.278,m:.889,n:.611,o:.611,p:.611,q:.611,r:.389,s:.556,t:.333,u:.611,v:.556,w:.778,x:.556,y:.556,z:.5,A:.722,B:.722,C:.722,D:.722,E:.667,F:.611,G:.778,H:.722,I:.278,J:.556,K:.722,L:.611,M:.833,N:.722,O:.778,P:.667,Q:.778,R:.722,S:.667,T:.611,U:.722,V:.667,W:.944,X:.667,Y:.667,Z:.611,"'":.278,"’":.278,"-":.333,".":.278,",":.278," ":.278},Yh=.556,Vh=.65,Gh=1,_h=1.05,Hh=1,Xh=class e{constructor(e){this.cell=e,this.cells=/* @__PURE__ */new Map}span(e,t){return[Math.floor(e/this.cell),Math.floor(t/this.cell)]}static key(e,t){return 65536*(e+32768)+(t+32768)}insert(t){const[n,o]=this.span(t.x-t.w/2,t.x+t.w/2),[r,i]=this.span(t.y-t.h/2,t.y+t.h/2);for(let s=n;s<=o;s++)for(let n=r;n<=i;n++){const o=e.key(s,n),r=this.cells.get(o);r?r.push(t):this.cells.set(o,[t])}}collides(t,n){const[o,r]=this.span(t.x-t.w/2-n,t.x+t.w/2+n),[i,s]=this.span(t.y-t.h/2-n,t.y+t.h/2+n);for(let a=o;a<=r;a++)for(let o=i;o<=s;o++){const r=this.cells.get(e.key(a,o));if(r)for(const e of r)if(Math.abs(t.x-e.x)<(t.w+e.w)/2+n&&Math.abs(t.y-e.y)<(t.h+e.h)/2+n)return!0}return!1}},Uh=32,Kh=2600,Zh=require("react/jsx-runtime"),Qh=/* @__PURE__ */new gu(12),Jh={fill:"rgba(0,0,0,0)",stroke:"rgba(0,0,0,0)",opacity:0},ef=8,tf=ss,nf=2*Math.PI,of=[40,40],rf=[.5,.5],sf=require("react/jsx-runtime"),af="var(--semiotic-text, currentColor)",cf=8,lf=/* @__PURE__ */new Set(["rows"]);El(),au(),Number.POSITIVE_INFINITY;var uf=[.1,.5,.9],df=1e6,hf=12,ff=require("react/jsx-runtime"),mf={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"}},pf=6.2,gf={flow:"down",padding:24,chargeExtent:.12,destinationExtent:.55,projectionExtent:0,channelRatio:1},yf="\0";
|